@symerian/symi 3.4.30 → 3.4.31

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 (177) hide show
  1. package/dist/{agent-O3PihJOY.js → agent-ZFfYdexc.js} +10 -10
  2. package/dist/{agents-C2MpIr16.js → agents-C8naPegc.js} +5 -5
  3. package/dist/{audit-yf3H4Y1h.js → audit-DOfexJi4.js} +8 -8
  4. package/dist/{auth-choice-CyBcsQ9T.js → auth-choice-DxH-c3vK.js} +4 -4
  5. package/dist/{banner-D7__HlM-.js → banner-D7zYLyA8.js} +1 -1
  6. package/dist/{browser-cli-B_6WWHm_.js → browser-cli-MYIql1Ic.js} +3 -3
  7. package/dist/build-info.json +1 -1
  8. package/dist/bundled/boot-md/handler.js +4 -4
  9. package/dist/bundled/session-memory/handler.js +4 -4
  10. package/dist/{call-IfleM0ap.js → call-D9U2Sfhp.js} +1 -1
  11. package/dist/{channel-options-B5974x-7.js → channel-options-9PzSNQLG.js} +1 -1
  12. package/dist/{channels-cli-C6Nv9mzy.js → channels-cli-C3XnNkE5.js} +30 -30
  13. package/dist/{chrome-DT1fIVG1.js → chrome-B4P7ycw5.js} +7 -7
  14. package/dist/{chrome-DJCkCRLf.js → chrome-ClVIwINy.js} +1 -1
  15. package/dist/{cli-DZoms4qg.js → cli-DhTdzhjk.js} +26 -26
  16. package/dist/{command-registry--D98SJ6k.js → command-registry-BOwku-e8.js} +11 -11
  17. package/dist/{completion-cli-CHYvpIPw.js → completion-cli-KZYbGY4H.js} +2 -2
  18. package/dist/{config-BTSBEAnk.js → config-Byd2Y9rr.js} +5 -5
  19. package/dist/{config-cli-DstpcB33.js → config-cli-CJ1CRfG8.js} +5 -5
  20. package/dist/{config-guard-CCJrDmON.js → config-guard-zt0zhFHl.js} +2 -2
  21. package/dist/{config-validation-YCrMlM9Z.js → config-validation-CRazk6Kd.js} +1 -1
  22. package/dist/{configure-B-UvSZZ7.js → configure-CFY_XEps.js} +10 -10
  23. package/dist/{control-service-CwRG4M_O.js → control-service-DN6-IdFk.js} +4 -4
  24. package/dist/{cron-cli-DUETe3Of.js → cron-cli-fmiz43Pz.js} +3 -3
  25. package/dist/{daemon-cli-Dy5eY4M7.js → daemon-cli-BilAL40g.js} +6 -6
  26. package/dist/{daemon-runtime-ChztAKDA.js → daemon-runtime-D4KHzQq2.js} +1 -1
  27. package/dist/{deliver-59sRVaYQ.js → deliver-BkCYBlzi.js} +4 -4
  28. package/dist/{deliver-BHmK4isn.js → deliver-CnsfN7km.js} +1 -1
  29. package/dist/{devices-cli-BCZ2HHjT.js → devices-cli-D7HdOwRI.js} +2 -2
  30. package/dist/{directory-cli-BVGd0l0T.js → directory-cli-ed6QacBC.js} +1 -1
  31. package/dist/{dns-cli-DH-ksmiI.js → dns-cli-RPa1dGTQ.js} +1 -1
  32. package/dist/{docs-cli-BuX8FDdh.js → docs-cli-ZTdS_Gak.js} +2 -2
  33. package/dist/{doctor-completion-C4Sf8CFV.js → doctor-completion-DpGX8dau.js} +1 -1
  34. package/dist/{doctor-config-flow-BhmF6EAq.js → doctor-config-flow-CIrG_yW_.js} +4 -4
  35. package/dist/entry.js +3 -3
  36. package/dist/{exec-approvals-cli-CyXTXgft.js → exec-approvals-cli-65pcsa1y.js} +6 -6
  37. package/dist/{frontmatter-BH3ExkUY.js → frontmatter-B4levtVg.js} +2 -2
  38. package/dist/{gateway-cli-fT43bqlv.js → gateway-cli-CTi7Wl2k.js} +50 -50
  39. package/dist/{gateway-rpc-BEqCo2JK.js → gateway-rpc-2VPLhMhx.js} +1 -1
  40. package/dist/{glass-ui-ws-BfMKuf9v.js → glass-ui-ws-Bah_A-jn.js} +38 -38
  41. package/dist/{gmail-setup-utils-Cz9Tb30q.js → gmail-setup-utils-C9WBC6Cd.js} +1 -1
  42. package/dist/{health-DDxrkioj.js → health-B5rRzhyV.js} +3 -3
  43. package/dist/{hooks-cli-Btgk__9z.js → hooks-cli-CSDCGO-W.js} +29 -29
  44. package/dist/{hooks-status-BaV4_YaJ.js → hooks-status-OorbLcc2.js} +2 -2
  45. package/dist/index.js +0 -0
  46. package/dist/{lifecycle-core-B0tG8ERp.js → lifecycle-core-BRc-XqTk.js} +2 -2
  47. package/dist/llm-slug-generator.js +4 -4
  48. package/dist/{logs-cli-CUhZrDw7.js → logs-cli-D5phVUOT.js} +3 -3
  49. package/dist/{manager-BeNnzSJv.js → manager-BfhHvsI9.js} +1 -1
  50. package/dist/{manager-Di9qtuZF.js → manager-DzBH9uQG.js} +1 -1
  51. package/dist/{memory-BDeydRz3.js → memory-BCj0cj5v.js} +3 -3
  52. package/dist/{memory-cli-D4hZiGr5.js → memory-cli-9WUMBHol.js} +3 -3
  53. package/dist/{model-catalog-DPnCNs5N.js → model-catalog-CD2kTz4V.js} +2 -2
  54. package/dist/{model-picker-DuPommMc.js → model-picker-CVd5UuXV.js} +2 -2
  55. package/dist/{models-cli-CL5K06Wu.js → models-cli-rd4eX_6P.js} +30 -30
  56. package/dist/{models-config-CPlvO1b0.js → models-config-oxaGiRUT.js} +1 -1
  57. package/dist/{models-B0wNKA18.js → models-sbKIrJBG.js} +9 -9
  58. package/dist/{node-cli-CWWMajKF.js → node-cli-ClLXSdFL.js} +9 -9
  59. package/dist/{nodes-cli-YmE7S-JB.js → nodes-cli-DY38p5In.js} +3 -3
  60. package/dist/{onboard-HqUZVKyD.js → onboard-BAyp_UFm.js} +7 -7
  61. package/dist/{onboard-channels-BbF5-N3g.js → onboard-channels-CUpkV_IJ.js} +1 -1
  62. package/dist/{onboard-custom-63SI3jrk.js → onboard-custom-BMgLK-vo.js} +2 -2
  63. package/dist/{onboard-helpers-Cb3WFLl9.js → onboard-helpers-DIQjpQ-s.js} +2 -2
  64. package/dist/{onboard-hooks-DXXg3YH9.js → onboard-hooks-KZKmj5Dk.js} +3 -3
  65. package/dist/{onboard-remote-CqtCrqtm.js → onboard-remote-C-_NUgBl.js} +1 -1
  66. package/dist/{onboard-skills-CS3l5fhH.js → onboard-skills-CwvicFTi.js} +3 -3
  67. package/dist/{onboarding-Be_HJIFA.js → onboarding-BxCNNo75.js} +11 -11
  68. package/dist/{onboarding.finalize-dsCUTKCQ.js → onboarding.finalize-DgMPXTtO.js} +18 -18
  69. package/dist/{onboarding.gateway-config-Ctd1_QW4.js → onboarding.gateway-config-BAaWvPSX.js} +4 -4
  70. package/dist/{outbound-send-deps-DPsU_Xdy.js → outbound-send-deps-qhFaNYAY.js} +1 -1
  71. package/dist/{pairing-cli-PtlNv7Gr.js → pairing-cli-CFkiSx8t.js} +1 -1
  72. package/dist/{pi-embedded-helpers-CVKIHnFv.js → pi-embedded-helpers-CRG5LMS7.js} +1 -1
  73. package/dist/{pi-tools.policy-8_wTu7v2.js → pi-tools.policy-De6xHjVL.js} +2 -2
  74. package/dist/{plugin-registry-BG51uZOA.js → plugin-registry-BNe5jtPK.js} +2 -2
  75. package/dist/plugin-sdk/index.js +6 -6
  76. package/dist/{plugins-cli-B-zVOiQN.js → plugins-cli-CWj33_Hj.js} +27 -27
  77. package/dist/{program-BOh0XGsA.js → program-Z2OLlhsB.js} +33 -33
  78. package/dist/{prompt-select-styled-Bj-hrPCx.js → prompt-select-styled-BNwbBBcH.js} +16 -16
  79. package/dist/{provider-auth-helpers-BK6NFk2Q.js → provider-auth-helpers-5qb15Hje.js} +2 -2
  80. package/dist/{push-apns-CMxk3Hxf.js → push-apns-D6qV5P4h.js} +1 -1
  81. package/dist/{pw-ai-C5MJKzUM.js → pw-ai-BsEf8C15.js} +1 -1
  82. package/dist/{pw-ai-CE2TBGif.js → pw-ai-C7mvVllB.js} +2 -2
  83. package/dist/{qr-cli-BeHlC33g.js → qr-cli-oENcXq8d.js} +1 -1
  84. package/dist/{redact-identifier-B1VHIbnd.js → redact-identifier-ZE8OIUof.js} +1 -1
  85. package/dist/{register.agent-COv5OPLQ.js → register.agent-DpiHPMca.js} +36 -36
  86. package/dist/{register.configure-RhKVlfWH.js → register.configure-DRFaroYF.js} +40 -40
  87. package/dist/{register.maintenance-BAK-DiQY.js → register.maintenance-BGNNTt_1.js} +38 -38
  88. package/dist/{register.message-CCBmn5ja.js → register.message-R4AIHhlU.js} +28 -28
  89. package/dist/{register.onboard-B3jO_Goy.js → register.onboard-Cl-_Suyv.js} +13 -13
  90. package/dist/{register.setup-CYSISTDO.js → register.setup-Dt98v2V3.js} +15 -15
  91. package/dist/{register.status-health-sessions-CGbg9k6d.js → register.status-health-sessions-DiX5lVyr.js} +23 -23
  92. package/dist/{register.subclis-loifbhVx.js → register.subclis-DVObuR_P.js} +28 -28
  93. package/dist/{replies-Dj640LxQ.js → replies-VTJu1jUK.js} +1 -1
  94. package/dist/{routes-B5y-oAKp.js → routes-DOFg6X5M.js} +3 -3
  95. package/dist/{rpc-qWm1bRo5.js → rpc-BIHKXdlN.js} +1 -1
  96. package/dist/{run-main-B7Ria3zD.js → run-main-NAgYKzSu.js} +44 -44
  97. package/dist/{sandbox-BJgHc4Vu.js → sandbox-EB7cFSML.js} +6 -6
  98. package/dist/{sandbox-cli-CSudrHYL.js → sandbox-cli-D4dy6sUK.js} +8 -8
  99. package/dist/{security-cli-B2lCR2xX.js → security-cli-DwCKOrFm.js} +11 -11
  100. package/dist/{send-CY9na-Jw.js → send-CkRtuQbr.js} +1 -1
  101. package/dist/{server-context-DdWWaDf6.js → server-context-ww1jytet.js} +5 -5
  102. package/dist/{server-methods-Dk_EnINI.js → server-methods-BDiZyPvS.js} +23 -23
  103. package/dist/{server-node-events-BHegSgG9.js → server-node-events-9cY40B4m.js} +29 -29
  104. package/dist/{session-utils-CAVPV2Hh.js → session-utils-CStjqGE6.js} +3 -3
  105. package/dist/{sessions-BDM9kNY0.js → sessions-BSRHJH8T.js} +3 -3
  106. package/dist/{sessions-CqLQkkWg.js → sessions-CInbrqsF.js} +1 -1
  107. package/dist/{shared-CpwtQRJB.js → shared-DEAo94kI.js} +1 -1
  108. package/dist/{skill-commands-CRQniaHy.js → skill-commands-BkKfrbHt.js} +2 -2
  109. package/dist/{skills-CTcjFd_F.js → skills-CFLijAZ-.js} +1 -1
  110. package/dist/{skills-cli-9Mlb7VRg.js → skills-cli-BbagnO6p.js} +5 -5
  111. package/dist/{skills-install-D5ikt72d.js → skills-install-dLRO1KGp.js} +2 -2
  112. package/dist/{skills-remote-BASG1Doo.js → skills-remote-DQVB-3Pj.js} +1 -1
  113. package/dist/{skills-status-1iVfuVIG.js → skills-status-HWybfj0K.js} +2 -2
  114. package/dist/{status-Bci6O3aA.js → status-BSrVEUoJ.js} +2 -2
  115. package/dist/{status-D5RhVO0A.js → status-FIp7UKru.js} +12 -12
  116. package/dist/{status.update-D5CachQ_.js → status.update-Cm8Fm8QD.js} +1 -1
  117. package/dist/{subagent-registry-CsXaK_sy.js → subagent-registry-DqryocLT.js} +31 -31
  118. package/dist/{synthesis-dplLmFIP.js → synthesis-CS-lrEGy.js} +4 -4
  119. package/dist/{synthesis-BoZf8BeO.js → synthesis-DKhH0YwU.js} +26 -26
  120. package/dist/{system-cli-D5FffFX5.js → system-cli-DYSI6cIB.js} +3 -3
  121. package/dist/{systemd-hints-CufcSfMk.js → systemd-hints-EIfW5y8K.js} +1 -1
  122. package/dist/{tui-DZ8gksSZ.js → tui-C20rHOeB.js} +4 -4
  123. package/dist/{tui-cli-CyBJYh9u.js → tui-cli-JwlzHCza.js} +11 -11
  124. package/dist/{unified-runner-BFLLzEHE.js → unified-runner-AM9tFC5q.js} +10 -10
  125. package/dist/{update-cli-yW6Xl6fs.js → update-cli-BYfA3RPc.js} +41 -41
  126. package/dist/{update-runner-CIgLduhH.js → update-runner-CBG8p9iG.js} +1 -1
  127. package/dist/{webhooks-cli-4bmyKzwb.js → webhooks-cli-MuG_QGLp.js} +4 -4
  128. package/dist/{with-timeout-bWr6yBeX.js → with-timeout-BvxaeAo6.js} +1 -1
  129. package/dist/{workspace-DxscDsm6.js → workspace-D0d7Gi4-.js} +1 -1
  130. package/extensions/memory-core/node_modules/.bin/symi +0 -0
  131. package/extensions/msteams/node_modules/.bin/symi +0 -0
  132. package/extensions/outlook/node_modules/.bin/symi +0 -0
  133. package/extensions/slack/node_modules/.bin/symi +0 -0
  134. package/package.json +108 -79
  135. package/dist/control-ui/css/revert-red-theme.md +0 -141
  136. package/dist/control-ui/css/style.css +0 -5843
  137. package/dist/control-ui/css/style.css.backup-2026-03-03-162525 +0 -3546
  138. package/dist/control-ui/css/style.css.backup-before-red-2026-03-03-162525 +0 -3546
  139. package/dist/control-ui/css/style.css.backup-before-red-theme-2026-03-03-162530 +0 -3546
  140. package/dist/control-ui/css/style.css.pre-2row +0 -2165
  141. package/dist/control-ui/css/style.css.pre-brand +0 -1776
  142. package/dist/control-ui/css/style.css.pre-history +0 -1974
  143. package/dist/control-ui/css/style.css.pre-nav +0 -2264
  144. package/dist/control-ui/css/style.css.pre-newsession +0 -1898
  145. package/dist/control-ui/css/style.css.pre-queue +0 -2195
  146. package/dist/control-ui/css/style.css.pre-red-prompt +0 -2524
  147. package/dist/control-ui/css/style.css.pre-stop +0 -2239
  148. package/dist/control-ui/css/style.css.pre-textarea +0 -2184
  149. package/dist/control-ui/css/style.css.pre-watchdog +0 -1848
  150. package/dist/control-ui/css/style.css.red-theme +0 -2999
  151. package/dist/control-ui/index.html +0 -1042
  152. package/dist/control-ui/js/app.js +0 -1304
  153. package/dist/control-ui/js/app.js.pre-2row +0 -463
  154. package/dist/control-ui/js/app.js.pre-heartbeat-filter +0 -595
  155. package/dist/control-ui/js/app.js.pre-newsession +0 -408
  156. package/dist/control-ui/js/app.js.pre-queue +0 -476
  157. package/dist/control-ui/js/app.js.pre-stop +0 -564
  158. package/dist/control-ui/js/app.js.pre-textarea +0 -467
  159. package/dist/control-ui/js/app.js.pre-watchdog +0 -293
  160. package/dist/control-ui/js/connections.js +0 -438
  161. package/dist/control-ui/js/gateway.js +0 -233
  162. package/dist/control-ui/js/gateway.js.pre-stop +0 -110
  163. package/dist/control-ui/js/history.js +0 -732
  164. package/dist/control-ui/js/logs.js +0 -238
  165. package/dist/control-ui/js/menu.js +0 -230
  166. package/dist/control-ui/js/menu.js.pre-nav +0 -66
  167. package/dist/control-ui/js/metrics.js +0 -53
  168. package/dist/control-ui/js/models.js +0 -138
  169. package/dist/control-ui/js/render.js +0 -882
  170. package/dist/control-ui/js/render.test.js +0 -112
  171. package/dist/control-ui/js/scheduling.js +0 -461
  172. package/dist/control-ui/js/settings.js +0 -909
  173. package/dist/control-ui/js/slash-autocomplete.js +0 -168
  174. package/dist/control-ui/js/subagents.js +0 -560
  175. package/dist/control-ui/js/utils.js +0 -29
  176. package/dist/control-ui/vendor/highlight.min.js +0 -2518
  177. package/dist/control-ui/vendor/marked.min.js +0 -69
@@ -1,595 +0,0 @@
1
- // ── Symi UI — Live Gateway App ────────────────────────────────────────
2
-
3
- const responseArea = document.getElementById('response-area');
4
- const promptInput = document.getElementById('prompt-input');
5
- const sendBtn = document.getElementById('send-btn');
6
- const newSessionBtn = document.getElementById('new-session-btn');
7
- const stopBtn = document.getElementById('stop-btn');
8
-
9
- let isStreaming = false;
10
- let currentRunId = null;
11
- let streamBubble = null;
12
- let streamContent = null;
13
- let streamStart = 0;
14
-
15
- // ── Prompt queue ──────────────────────────────────────────────────
16
- let chatQueue = []; // [{id, text}]
17
-
18
- // ── Watchdog + elapsed timer state ────────────────────────────────
19
- let watchdogTimer = null; // fires if no activity for WATCHDOG_MS
20
- let elapsedTimer = null; // ticks every second to show run duration
21
- let activityStart = 0; // timestamp of when current run began
22
- let elapsedBaseText = ''; // base sub-text for the elapsed display
23
- const WATCHDOG_MS = 90000; // 90 seconds of silence → failure
24
-
25
- // ── Utility ───────────────────────────────────────────────────────
26
- const sleep = ms => new Promise(r => setTimeout(r, ms));
27
- function escapeHtml(t) {
28
- return t.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
29
- }
30
-
31
- // ── Status indicator (top-right of response area) ─────────────────
32
- const statusEl = document.createElement('div');
33
- statusEl.className = 'conn-status';
34
- statusEl.innerHTML = '<span class="conn-dot dot-yellow pulse"></span><span class="conn-label">connecting…</span>';
35
- responseArea.before(statusEl);
36
-
37
- function setStatus(state) { // 'connecting' | 'online' | 'offline'
38
- const dot = statusEl.querySelector('.conn-dot');
39
- const label = statusEl.querySelector('.conn-label');
40
- dot.className = `conn-dot ${state === 'online' ? 'dot-green pulse' : state === 'offline' ? 'dot-red' : 'dot-yellow pulse'}`;
41
- label.textContent = state === 'online' ? 'live' : state === 'offline' ? 'disconnected' : 'connecting…';
42
- }
43
-
44
- // ── Render helpers ─────────────────────────────────────────────────
45
- function addUserMessage(text) {
46
- const msg = document.createElement('div');
47
- msg.className = 'message user-msg';
48
- msg.innerHTML = `<div class="bubble">${escapeHtml(text)}</div><div class="message-clearfix"></div>`;
49
- responseArea.appendChild(msg);
50
- msg.scrollIntoView({ behavior: 'smooth', block: 'end' });
51
- }
52
-
53
- // ── Thinking bubble ────────────────────────────────────────────────
54
- function createThinkingBubble() {
55
- const msg = document.createElement('div');
56
- msg.className = 'message symi-msg thinking-msg';
57
- msg.innerHTML = `
58
- <div class="bubble thinking-bubble">
59
- <div class="think-header">
60
- <span class="think-badge">◈ PROCESSING</span>
61
- <span class="think-dots"><span>.</span><span>.</span><span>.</span></span>
62
- </div>
63
- <div class="think-bar-wrap"><div class="think-bar"></div></div>
64
- </div>
65
- <div class="message-clearfix"></div>
66
- `;
67
- responseArea.appendChild(msg);
68
- msg.scrollIntoView({ behavior: 'smooth', block: 'end' });
69
- return msg;
70
- }
71
-
72
- // ── Stream bubble lifecycle ────────────────────────────────────────
73
- function openStreamBubble() {
74
- streamStart = Date.now();
75
- const msg = document.createElement('div');
76
- msg.className = 'message symi-msg stream-msg';
77
- msg.innerHTML = `<div class="bubble stream-bubble streaming"><div class="bubble-content"></div></div><div class="message-clearfix"></div>`;
78
- responseArea.appendChild(msg);
79
- streamBubble = msg.querySelector('.stream-bubble');
80
- streamContent = msg.querySelector('.bubble-content');
81
- msg.scrollIntoView({ behavior: 'smooth', block: 'end' });
82
- return msg;
83
- }
84
-
85
- function updateStream(text) {
86
- if (!streamContent) return;
87
- streamContent.textContent = text;
88
- responseArea.scrollTop = responseArea.scrollHeight;
89
- }
90
-
91
- function closeStreamBubble(model = 'claude-sonnet-4-6') {
92
- if (!streamBubble) return;
93
- streamBubble.classList.remove('streaming');
94
- streamBubble.classList.add('done');
95
-
96
- // Apply full markdown rendering to the final text
97
- const rawText = streamContent?.textContent ?? '';
98
- if (streamContent && rawText) {
99
- streamContent.innerHTML = '';
100
- const textBlock = renderBlock({ type: 'text', text: rawText });
101
- streamContent.appendChild(textBlock);
102
- window.applyHighlighting(streamContent);
103
- }
104
-
105
- const elapsed = Date.now() - streamStart;
106
- const chars = Math.round(rawText.length / 4);
107
-
108
- // Add copy button
109
- const copyBtn = document.createElement('button');
110
- copyBtn.className = 'msg-copy-btn msg-copy-visible';
111
- copyBtn.title = 'Copy';
112
- copyBtn.onclick = function() { window.copyMessage(this); };
113
- copyBtn.innerHTML = `<svg width="12" height="12" viewBox="0 0 24 24" fill="none">
114
- <rect x="9" y="9" width="13" height="13" rx="2" stroke="currentColor" stroke-width="2"/>
115
- <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" stroke="currentColor" stroke-width="2"/>
116
- </svg>`;
117
- streamBubble.appendChild(copyBtn);
118
-
119
- const footer = document.createElement('div');
120
- footer.className = 'telemetry';
121
- footer.innerHTML = `
122
- <span class="tele-item">✦ ${model}</span>
123
- <span class="tele-sep">·</span>
124
- <span class="tele-item">${chars} tokens</span>
125
- <span class="tele-sep">·</span>
126
- <span class="tele-item">${elapsed}ms</span>
127
- `;
128
- streamBubble.appendChild(footer);
129
- requestAnimationFrame(() => {
130
- footer.classList.add('tele-visible');
131
- // Scroll to bottom immediately after markdown + footer are in the DOM
132
- responseArea.scrollTop = responseArea.scrollHeight;
133
- });
134
-
135
- // Second scroll after the fit-content width transition finishes (0.3s)
136
- setTimeout(() => { responseArea.scrollTop = responseArea.scrollHeight; }, 350);
137
-
138
- streamBubble = null;
139
- streamContent = null;
140
- }
141
-
142
- // ── Elapsed timer ─────────────────────────────────────────────────
143
- function startElapsedTimer(baseText) {
144
- stopElapsedTimer();
145
- activityStart = Date.now();
146
- elapsedBaseText = baseText;
147
- elapsedTimer = setInterval(() => {
148
- const secs = Math.floor((Date.now() - activityStart) / 1000);
149
- const m = Math.floor(secs / 60);
150
- const s = String(secs % 60).padStart(2, '0');
151
- if (asoSub) asoSub.textContent = `${elapsedBaseText} ${m}:${s}`;
152
- }, 1000);
153
- }
154
-
155
- function stopElapsedTimer() {
156
- if (elapsedTimer) { clearInterval(elapsedTimer); elapsedTimer = null; }
157
- }
158
-
159
- // ── Watchdog ───────────────────────────────────────────────────────
160
- function armWatchdog() {
161
- clearWatchdog();
162
- watchdogTimer = setTimeout(() => handleRunFailure('timeout'), WATCHDOG_MS);
163
- }
164
-
165
- function clearWatchdog() {
166
- if (watchdogTimer) { clearTimeout(watchdogTimer); watchdogTimer = null; }
167
- }
168
-
169
- // ── Unified run failure handler ────────────────────────────────────
170
- // Called when: watchdog fires, gateway disconnects mid-run, or server
171
- // sends an explicit error event. Cleans up all state and shows the user
172
- // a clear error message + ERROR orb state.
173
- function handleRunFailure(reason) {
174
- // Stop timers immediately
175
- stopElapsedTimer();
176
- clearWatchdog();
177
-
178
- // Clean up any in-flight UI elements
179
- if (thinkingEl) { thinkingEl.remove(); thinkingEl = null; }
180
- if (streamBubble) {
181
- // Don't render markdown on a partial/failed response — just mark it failed
182
- streamBubble.classList.remove('streaming');
183
- streamBubble.classList.add('done', 'stream-failed');
184
- streamBubble = null;
185
- streamContent = null;
186
- }
187
-
188
- // Human-readable reason labels
189
- const labels = {
190
- timeout: `No response received after ${WATCHDOG_MS / 1000}s — the agent may still be running in the background`,
191
- disconnected: 'Connection lost mid-run — gateway disconnected',
192
- };
193
- const label = labels[reason] || reason;
194
-
195
- // Inject error bubble into the feed
196
- const errEl = document.createElement('div');
197
- errEl.className = 'message symi-msg';
198
- errEl.innerHTML = `
199
- <div class="bubble stream-bubble done run-error-bubble">
200
- <div class="run-error-icon">⚠</div>
201
- <div class="bubble-content run-error-text">${escapeHtml(label)}</div>
202
- </div>
203
- <div class="message-clearfix"></div>
204
- `;
205
- responseArea.appendChild(errEl);
206
- requestAnimationFrame(() => { responseArea.scrollTop = responseArea.scrollHeight; });
207
-
208
- // Show ERROR state on orb, then reset input
209
- setAgentStatus('error');
210
- isStreaming = false;
211
- currentRunId = null;
212
- stopBtn.style.opacity = '';
213
- stopBtn.disabled = false;
214
- enableInput();
215
- updateQueueBtn(); // keep queue button visible if items remain
216
- }
217
-
218
- // ── Render history (on first connect) ─────────────────────────────
219
- function renderHistory(messages) {
220
- responseArea.innerHTML = '';
221
- for (const m of messages) {
222
- if (!m || !m.role) continue;
223
- const hasContent = Array.isArray(m.content)
224
- ? m.content.some(b => (b.text ?? b.thinking ?? b.name ?? '').trim())
225
- : extractText(m.content).trim();
226
- if (!hasContent) continue;
227
-
228
- const el = window.renderMessage(m);
229
- responseArea.appendChild(el);
230
- window.applyHighlighting(el);
231
- }
232
-
233
- // Scroll to very bottom after history renders
234
- requestAnimationFrame(() => { responseArea.scrollTop = responseArea.scrollHeight; });
235
- }
236
-
237
- // ── Gateway event handler ──────────────────────────────────────────
238
- let thinkingEl = null;
239
-
240
- function handleGatewayEvent(event) {
241
- if (event.event !== 'chat') return;
242
- const p = event.payload;
243
- if (!p || p.sessionKey !== window.SESSION_KEY) return;
244
-
245
- if (p.state === 'delta') {
246
- // Capture runId on first delta so abort can target the exact run
247
- if (p.runId && !currentRunId) currentRunId = p.runId;
248
-
249
- // Each delta proves the agent is alive — reset the watchdog
250
- armWatchdog();
251
-
252
- // First delta — remove thinking bubble, open stream bubble
253
- if (thinkingEl) { thinkingEl.remove(); thinkingEl = null; }
254
- if (!streamBubble) {
255
- openStreamBubble();
256
- setAgentStatus('streaming');
257
- }
258
-
259
- const text = extractText(p.message);
260
- if (text) updateStream(text);
261
-
262
- } else if (p.state === 'final') {
263
- stopElapsedTimer();
264
- clearWatchdog();
265
- closeStreamBubble();
266
- setAgentStatus('done');
267
- isStreaming = false;
268
- currentRunId = null;
269
- stopBtn.style.opacity = ''; // reset stop button visual state
270
- stopBtn.disabled = false;
271
- enableInput();
272
- drainQueue();
273
-
274
- } else if (p.state === 'aborted') {
275
- // Clean abort (user-initiated or model decided to stop) — not an error
276
- stopElapsedTimer();
277
- clearWatchdog();
278
- if (streamBubble) closeStreamBubble();
279
- if (thinkingEl) { thinkingEl.remove(); thinkingEl = null; }
280
- setAgentStatus('idle');
281
- isStreaming = false;
282
- currentRunId = null;
283
- stopBtn.style.opacity = ''; // reset stop button visual state
284
- stopBtn.disabled = false;
285
- enableInput();
286
- drainQueue();
287
-
288
- } else if (p.state === 'error') {
289
- // Server-reported error — route through unified failure handler
290
- handleRunFailure(p.error?.message || 'Server reported an error');
291
- }
292
- }
293
-
294
- // ── Agent Status Orb ───────────────────────────────────────────────
295
- const asoPanel = document.getElementById('agent-status-panel');
296
- const asoLabel = document.getElementById('aso-label');
297
- const asoSub = document.getElementById('aso-sub');
298
- let asoDoneTimer = null;
299
-
300
- const ASO_STATES = {
301
- idle: { state: 'idle', label: 'STANDBY', sub: 'Awaiting your prompt' },
302
- waiting: { state: 'waiting', label: 'WAITING', sub: 'Sending to Symi\u2026' },
303
- thinking: { state: 'thinking', label: 'PROCESSING', sub: 'Reasoning through request' },
304
- streaming: { state: 'streaming', label: 'RESPONDING', sub: 'Generating response' },
305
- done: { state: 'done', label: 'COMPLETE', sub: 'Response ready' },
306
- error: { state: 'error', label: 'FAILED', sub: 'Run ended unexpectedly' },
307
- };
308
-
309
- function setAgentStatus(key) {
310
- if (!asoPanel) return;
311
-
312
- // Clear any pending auto-transition timers
313
- if (asoDoneTimer) { clearTimeout(asoDoneTimer); asoDoneTimer = null; }
314
-
315
- const s = ASO_STATES[key] || ASO_STATES.idle;
316
- asoPanel.dataset.state = s.state;
317
- if (asoLabel) asoLabel.textContent = s.label;
318
- if (asoSub) asoSub.textContent = s.sub;
319
-
320
- // ── Elapsed timer management ──────────────────────────────────
321
- if (key === 'thinking') {
322
- // Start elapsed timer and watchdog when processing begins
323
- armWatchdog();
324
- startElapsedTimer('Reasoning through request');
325
- } else if (key === 'streaming') {
326
- // Transition from thinking → streaming: keep watchdog running (will be
327
- // reset on each delta), switch elapsed timer base text
328
- elapsedBaseText = 'Generating response';
329
- } else {
330
- // Any terminal/non-active state: stop elapsed timer and watchdog
331
- stopElapsedTimer();
332
- clearWatchdog();
333
- }
334
-
335
- // ── Auto-revert timers ────────────────────────────────────────
336
- if (key === 'done') {
337
- asoDoneTimer = setTimeout(() => setAgentStatus('idle'), 3000);
338
- }
339
- if (key === 'error') {
340
- asoDoneTimer = setTimeout(() => setAgentStatus('idle'), 4000);
341
- }
342
- }
343
-
344
- // ── Input state ────────────────────────────────────────────────────
345
- function disableInput() {
346
- // Keep textarea enabled so user can type their next queued message while AI responds
347
- sendBtn.disabled = true;
348
- newSessionBtn.disabled = true;
349
- sendBtn.classList.add('btn-loading');
350
- }
351
-
352
- function enableInput() {
353
- sendBtn.disabled = false;
354
- newSessionBtn.disabled = false;
355
- sendBtn.classList.remove('btn-loading');
356
- promptInput.focus();
357
- }
358
-
359
- // ── Queue helpers ──────────────────────────────────────────────────
360
- const queueBtn = document.getElementById('queue-btn');
361
- const queueCancelX = document.getElementById('queue-cancel-x');
362
-
363
- function updateQueueBtn() {
364
- const streaming = isStreaming;
365
- const count = chatQueue.length;
366
-
367
- if (streaming || count > 0) {
368
- // Show stop + queue buttons, hide New Session
369
- stopBtn.classList.add('visible');
370
- queueBtn.classList.add('visible');
371
- newSessionBtn.style.display = 'none';
372
-
373
- if (count > 0) {
374
- queueBtn.classList.add('has-queue');
375
- queueBtn.querySelector('.queue-btn-label').textContent = `Queued (${count})`;
376
- } else {
377
- queueBtn.classList.remove('has-queue');
378
- queueBtn.querySelector('.queue-btn-label').textContent = 'Queue ↵';
379
- }
380
- } else {
381
- // Hide stop + queue, restore New Session
382
- stopBtn.classList.remove('visible');
383
- queueBtn.classList.remove('visible', 'has-queue');
384
- newSessionBtn.style.display = '';
385
- }
386
- }
387
-
388
- function queueMessage(text) {
389
- if (!text.trim()) return;
390
- chatQueue = [...chatQueue, { id: Date.now(), text: text.trim() }];
391
- updateQueueBtn();
392
- }
393
-
394
- function clearQueue() {
395
- chatQueue = [];
396
- updateQueueBtn();
397
- }
398
-
399
- function drainQueue() {
400
- if (chatQueue.length === 0) {
401
- updateQueueBtn();
402
- return;
403
- }
404
- const [next, ...rest] = chatQueue;
405
- chatQueue = rest;
406
- updateQueueBtn();
407
- // Small delay so the UI settles before starting the next send
408
- setTimeout(() => sendText(next.text), 120);
409
- }
410
-
411
- // ── Core send (no input reading — accepts text directly) ───────────
412
- async function sendText(text) {
413
- if (!gateway.connected) return;
414
- isStreaming = true;
415
- disableInput();
416
- updateQueueBtn();
417
-
418
- addUserMessage(text);
419
- await sleep(200);
420
-
421
- setAgentStatus('waiting');
422
- thinkingEl = createThinkingBubble();
423
- setAgentStatus('thinking');
424
-
425
- try {
426
- await gateway.send(text);
427
- } catch (err) {
428
- handleRunFailure(err.message || 'Failed to send message');
429
- }
430
- }
431
-
432
- // ── Send handler (reads input, queues if busy) ─────────────────────
433
- async function handleSend() {
434
- const text = promptInput.value.trim();
435
- if (!text) return;
436
-
437
- // Clear the input immediately regardless of streaming state
438
- promptInput.value = '';
439
- promptInput.style.height = 'auto';
440
-
441
- if (isStreaming) {
442
- // AI is busy — queue it
443
- queueMessage(text);
444
- return;
445
- }
446
-
447
- if (!gateway.connected) return;
448
- await sendText(text);
449
- }
450
-
451
- // ── New Session handler ────────────────────────────────────────────
452
- async function handleNewSession() {
453
- if (isStreaming || !gateway.connected) return;
454
-
455
- promptInput.disabled = true; // lock textarea during reset
456
- disableInput();
457
- setAgentStatus('waiting');
458
-
459
- try {
460
- // Send the /new slash command — gateway resets the session
461
- await gateway.send('/new');
462
-
463
- // Fade out existing messages, then show cleared state
464
- responseArea.style.transition = 'opacity 0.25s ease';
465
- responseArea.style.opacity = '0';
466
-
467
- await sleep(260);
468
-
469
- responseArea.innerHTML = '';
470
- responseArea.style.opacity = '1';
471
-
472
- // Show empty-state indicator
473
- const cleared = document.createElement('div');
474
- cleared.className = 'session-cleared';
475
- cleared.innerHTML = `
476
- <div class="session-cleared-icon">◈</div>
477
- <div class="session-cleared-text">NEW SESSION STARTED</div>
478
- `;
479
- responseArea.appendChild(cleared);
480
-
481
- setAgentStatus('idle');
482
- clearQueue(); // discard any queued prompts — new session = clean slate
483
-
484
- // Show archive toast — lets user jump directly to history if they regret it
485
- if (typeof window.showArchiveToast === 'function') window.showArchiveToast();
486
-
487
- // After a short pause, remove the cleared indicator and let history load
488
- await sleep(1800);
489
- cleared.style.transition = 'opacity 0.4s ease';
490
- cleared.style.opacity = '0';
491
- await sleep(420);
492
- cleared.remove();
493
-
494
- } catch (err) {
495
- handleRunFailure(err.message || 'Failed to start new session');
496
- return;
497
- }
498
-
499
- promptInput.disabled = false; // re-enable textarea after reset
500
- enableInput();
501
- }
502
-
503
- // ── Stop handler ───────────────────────────────────────────────────
504
- async function handleStop() {
505
- if (!isStreaming || !gateway.connected) return;
506
- try {
507
- await gateway.abort(currentRunId);
508
- // The gateway will send an 'aborted' event which cleans up state.
509
- // Visually dim the stop button while we wait for confirmation.
510
- stopBtn.style.opacity = '0.45';
511
- stopBtn.disabled = true;
512
- } catch (err) {
513
- console.warn('[stop] abort failed:', err.message);
514
- }
515
- }
516
-
517
- sendBtn.addEventListener('click', handleSend);
518
- newSessionBtn.addEventListener('click', handleNewSession);
519
- stopBtn.addEventListener('click', handleStop);
520
-
521
- // Queue button — queue current input (if idle text present) or show queued count
522
- queueBtn.addEventListener('click', e => {
523
- // Cancel X — clears the queue
524
- if (e.target === queueCancelX || queueCancelX.contains(e.target)) {
525
- clearQueue();
526
- return;
527
- }
528
- // Main button click — queue the current input if no item queued yet
529
- if (chatQueue.length === 0) {
530
- const text = promptInput.value.trim();
531
- if (text) {
532
- promptInput.value = '';
533
- promptInput.style.height = 'auto';
534
- queueMessage(text);
535
- }
536
- }
537
- });
538
- promptInput.addEventListener('keydown', e => {
539
- if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); handleSend(); }
540
- });
541
-
542
- // ── Textarea auto-resize (up to 3 lines) ──────────────────────────
543
- function autoResizePrompt() {
544
- promptInput.style.height = 'auto';
545
- promptInput.style.height = promptInput.scrollHeight + 'px';
546
- }
547
-
548
- promptInput.addEventListener('input', autoResizePrompt);
549
-
550
- // Clicking anywhere on the prompt bar (padding, icon, gaps) focuses the input
551
- // Click anywhere on the main input row (not buttons) focuses the input
552
- document.getElementById('prompt-bar').addEventListener('click', e => {
553
- const inSend = sendBtn.contains(e.target) || e.target === sendBtn;
554
- const inNewSession = newSessionBtn.contains(e.target) || e.target === newSessionBtn;
555
- const inHistory = document.getElementById('history-btn').contains(e.target);
556
- const inQueue = queueBtn.contains(e.target);
557
- const inStop = stopBtn.contains(e.target);
558
- // Only focus if clicking in the main row area (not the actions row)
559
- const inActionsRow = e.target.closest('.prompt-row-actions');
560
- if (!inSend && !inNewSession && !inHistory && !inQueue && !inStop && !inActionsRow) {
561
- promptInput.focus();
562
- }
563
- });
564
-
565
- // ── Gateway setup ──────────────────────────────────────────────────
566
- const gateway = new SymiGateway();
567
- window.gateway = gateway; // expose for native page viewers (logs, etc.)
568
-
569
- gateway.addEventListener('connect', () => {
570
- setStatus('online');
571
- enableInput();
572
- // History arrives via separate 'history' event pushed by the server
573
- });
574
-
575
- gateway.addEventListener('history', (e) => {
576
- const msgs = Array.isArray(e.detail?.messages) ? e.detail.messages : [];
577
- renderHistory(msgs);
578
- });
579
-
580
- gateway.addEventListener('disconnect', () => {
581
- setStatus('offline');
582
- // If the gateway drops while a run is in progress, surface the failure
583
- // immediately rather than leaving the UI in a permanently locked state.
584
- if (isStreaming) {
585
- handleRunFailure('disconnected');
586
- }
587
- });
588
-
589
- gateway.addEventListener('event', (e) => {
590
- handleGatewayEvent(e.detail);
591
- });
592
-
593
- // Start connecting
594
- disableInput();
595
- gateway.start();