protocol-proxy 2.8.3 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/public/index.html CHANGED
@@ -24,6 +24,11 @@
24
24
  <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="7"></rect><rect x="14" y="3" width="7" height="7"></rect><rect x="14" y="14" width="7" height="7"></rect><rect x="3" y="14" width="7" height="7"></rect></svg>
25
25
  <span>总览</span>
26
26
  </a>
27
+ <a href="#" class="nav-item" data-page="assistant">
28
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>
29
+ <span>智控助手</span>
30
+ <span class="nav-badge" style="background:var(--accent);color:#fff">AI</span>
31
+ </a>
27
32
  <a href="#" class="nav-item" data-page="proxies">
28
33
  <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2 2 7 12 12 22 7 12 2"></polygon><polyline points="2 17 12 22 22 17"></polyline><polyline points="2 12 12 17 22 12"></polyline></svg>
29
34
  <span>代理管理</span>
@@ -46,11 +51,6 @@
46
51
  <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path><polyline points="13 2 13 9 20 9"></polyline></svg>
47
52
  <span>系统日志</span>
48
53
  </a>
49
- <a href="#" class="nav-item" data-page="assistant">
50
- <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>
51
- <span>智控助手</span>
52
- <span class="nav-badge" style="background:var(--accent);color:#fff">AI</span>
53
- </a>
54
54
  <a href="#" class="nav-item" data-page="settings">
55
55
  <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 5 15.34a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 9 4.6a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 20.39 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg>
56
56
  <span>设置</span>
@@ -328,8 +328,27 @@
328
328
  <option value="">选择后端代理...</option>
329
329
  </select>
330
330
  </div>
331
+ <div class="assistant-model-select">
332
+ <label>供应商</label>
333
+ <select id="assistant-provider-select" onchange="onAssistantProviderChange(this.value)">
334
+ <option value="">自动(跟随代理)</option>
335
+ </select>
336
+ </div>
337
+ <div class="assistant-model-select">
338
+ <label>模型</label>
339
+ <select id="assistant-model-select">
340
+ <option value="">自动(跟随代理)</option>
341
+ </select>
342
+ </div>
343
+ <div class="assistant-model-select">
344
+ <label>会话</label>
345
+ <div class="conversation-dropdown" id="conversation-dropdown">
346
+ <button class="conversation-dropdown-trigger" id="conversation-dropdown-trigger" onclick="toggleConversationDropdown()">新会话</button>
347
+ <div class="conversation-dropdown-menu" id="conversation-dropdown-menu"></div>
348
+ </div>
349
+ </div>
331
350
  <div class="toolbar-actions">
332
- <button class="btn btn-sm" onclick="clearAssistantChat()">清空对话</button>
351
+ <button class="btn btn-sm" onclick="clearAssistantChat()">新会话</button>
333
352
  </div>
334
353
  </div>
335
354
  <div class="assistant-chat" id="assistant-chat">
@@ -348,6 +367,17 @@
348
367
  <p class="assistant-hint">请先选择一个运行中的代理作为对话后端</p>
349
368
  </div>
350
369
  </div>
370
+ <div class="assistant-context-bar" id="assistant-context-bar" style="display:none">
371
+ <div class="context-bar-track">
372
+ <div class="context-bar-fill" id="context-bar-fill" style="width:0%"></div>
373
+ </div>
374
+ <div class="context-bar-info">
375
+ <span id="context-bar-tokens">0</span> / <span id="context-bar-max">200K</span> tokens
376
+ (<span id="context-bar-percent">0</span>%)
377
+ · <span id="context-bar-messages">0</span> 条消息
378
+ </div>
379
+ <button class="btn btn-sm context-compress-btn" id="context-compress-btn" onclick="compressAssistantContext()" style="display:none">压缩</button>
380
+ </div>
351
381
  <div class="assistant-input-area">
352
382
  <textarea id="assistant-input" placeholder="输入问题,例如:帮我看看哪个供应商最慢,最近有什么异常?" rows="1"></textarea>
353
383
  <button class="btn btn-primary" id="assistant-send-btn" onclick="sendAssistantMessage()" disabled>发送</button>
@@ -409,6 +439,37 @@
409
439
  </div>
410
440
  </div>
411
441
  </div>
442
+ <div class="panel">
443
+ <div class="panel-header">
444
+ <h3>智控助手</h3>
445
+ </div>
446
+ <div class="settings-body">
447
+ <div class="setting-item">
448
+ <div class="setting-info">
449
+ <div class="setting-name">模型上下文大小</div>
450
+ <div class="setting-desc">设置所用模型的上下文窗口大小(Token),影响压缩触发阈值</div>
451
+ </div>
452
+ <input type="number" id="settings-max-context" value="200000" min="10000" step="10000"
453
+ style="width:120px" onchange="updateMaxContext(this.value)">
454
+ </div>
455
+ <div class="setting-item">
456
+ <div class="setting-info">
457
+ <div class="setting-name">最大工具调用轮次</div>
458
+ <div class="setting-desc">单次对话中模型可连续调用工具的最大轮数,达到上限后模型会自动总结回复</div>
459
+ </div>
460
+ <input type="number" id="settings-max-rounds" value="10" min="1" max="100"
461
+ style="width:120px" onchange="updateMaxRounds(this.value)">
462
+ </div>
463
+ <div class="setting-item">
464
+ <div class="setting-info">
465
+ <div class="setting-name">最大会话数</div>
466
+ <div class="setting-desc">保存的历史会话数量上限,超出时自动删除最早的会话,0 表示不限制</div>
467
+ </div>
468
+ <input type="number" id="settings-max-conversations" value="0" min="0"
469
+ style="width:120px" onchange="updateMaxConversations(this.value)">
470
+ </div>
471
+ </div>
472
+ </div>
412
473
  </div>
413
474
  </div>
414
475
  </main>
package/public/style.css CHANGED
@@ -1828,6 +1828,86 @@ body {
1828
1828
  cursor: pointer;
1829
1829
  }
1830
1830
 
1831
+ .conversation-dropdown {
1832
+ position: relative;
1833
+ }
1834
+ .conversation-dropdown-trigger {
1835
+ height: 32px;
1836
+ padding: 0 10px;
1837
+ background: var(--bg-elevated);
1838
+ border: 1px solid var(--border-default);
1839
+ border-radius: var(--radius-md);
1840
+ color: var(--text-primary);
1841
+ font-size: 13px;
1842
+ font-family: var(--font-body);
1843
+ cursor: pointer;
1844
+ text-align: left;
1845
+ min-width: 180px;
1846
+ max-width: 260px;
1847
+ overflow: hidden;
1848
+ text-overflow: ellipsis;
1849
+ white-space: nowrap;
1850
+ }
1851
+ .conversation-dropdown-menu {
1852
+ display: none;
1853
+ position: absolute;
1854
+ top: 100%;
1855
+ left: 0;
1856
+ z-index: 100;
1857
+ min-width: 280px;
1858
+ max-height: 320px;
1859
+ overflow-y: auto;
1860
+ background: var(--bg-elevated);
1861
+ border: 1px solid var(--border-default);
1862
+ border-radius: var(--radius-md);
1863
+ box-shadow: 0 4px 12px rgba(0,0,0,0.15);
1864
+ margin-top: 4px;
1865
+ }
1866
+ .conversation-dropdown-menu.open {
1867
+ display: block;
1868
+ }
1869
+ .conversation-dropdown-item {
1870
+ display: flex;
1871
+ align-items: center;
1872
+ justify-content: space-between;
1873
+ padding: 8px 10px;
1874
+ cursor: pointer;
1875
+ font-size: 13px;
1876
+ gap: 8px;
1877
+ }
1878
+ .conversation-dropdown-item:hover {
1879
+ background: var(--bg-hover);
1880
+ }
1881
+ .conversation-dropdown-item.active {
1882
+ background: var(--bg-selected);
1883
+ }
1884
+ .conversation-dropdown-item-label {
1885
+ flex: 1;
1886
+ overflow: hidden;
1887
+ text-overflow: ellipsis;
1888
+ white-space: nowrap;
1889
+ color: var(--text-primary);
1890
+ }
1891
+ .conversation-dropdown-item-delete {
1892
+ flex-shrink: 0;
1893
+ width: 20px;
1894
+ height: 20px;
1895
+ display: flex;
1896
+ align-items: center;
1897
+ justify-content: center;
1898
+ border: none;
1899
+ background: transparent;
1900
+ color: var(--text-muted);
1901
+ cursor: pointer;
1902
+ border-radius: 4px;
1903
+ font-size: 14px;
1904
+ line-height: 1;
1905
+ }
1906
+ .conversation-dropdown-item-delete:hover {
1907
+ background: var(--error);
1908
+ color: #fff;
1909
+ }
1910
+
1831
1911
  .assistant-chat {
1832
1912
  flex: 1;
1833
1913
  overflow-y: auto;
@@ -1897,6 +1977,32 @@ body {
1897
1977
  margin-bottom: 0;
1898
1978
  }
1899
1979
 
1980
+ .think-block {
1981
+ margin: 8px 0;
1982
+ border: 1px solid var(--border-subtle);
1983
+ border-radius: var(--radius-md);
1984
+ background: var(--bg-base);
1985
+ font-size: 12px;
1986
+ }
1987
+ .think-block summary {
1988
+ padding: 6px 10px;
1989
+ cursor: pointer;
1990
+ color: var(--text-muted);
1991
+ user-select: none;
1992
+ }
1993
+ .think-block summary:hover {
1994
+ color: var(--text-secondary);
1995
+ }
1996
+ .think-content {
1997
+ padding: 8px 10px;
1998
+ border-top: 1px solid var(--border-subtle);
1999
+ color: var(--text-secondary);
2000
+ white-space: pre-wrap;
2001
+ line-height: 1.5;
2002
+ max-height: 300px;
2003
+ overflow-y: auto;
2004
+ }
2005
+
1900
2006
  .assistant-message.assistant ul,
1901
2007
  .assistant-message.assistant ol {
1902
2008
  margin: 8px 0;
@@ -1950,6 +2056,73 @@ body {
1950
2056
  margin-top: 16px;
1951
2057
  }
1952
2058
 
2059
+ .compression-summary {
2060
+ margin: 12px 24px;
2061
+ padding: 8px 12px;
2062
+ background: var(--bg-elevated);
2063
+ border: 1px solid var(--border-subtle);
2064
+ border-radius: 8px;
2065
+ font-size: 13px;
2066
+ color: var(--text-secondary);
2067
+ }
2068
+ .compression-summary summary {
2069
+ cursor: pointer;
2070
+ font-weight: 500;
2071
+ color: var(--text-primary);
2072
+ }
2073
+ .compression-summary-content {
2074
+ margin-top: 8px;
2075
+ white-space: pre-wrap;
2076
+ line-height: 1.5;
2077
+ }
2078
+
2079
+ /* 上下文占用栏 */
2080
+ .assistant-context-bar {
2081
+ display: flex;
2082
+ align-items: center;
2083
+ gap: 10px;
2084
+ padding: 6px 12px;
2085
+ flex-shrink: 0;
2086
+ border-top: 1px solid var(--border-subtle);
2087
+ }
2088
+
2089
+ .context-bar-track {
2090
+ flex: 1;
2091
+ height: 4px;
2092
+ background: var(--bg-base);
2093
+ border-radius: 2px;
2094
+ overflow: hidden;
2095
+ min-width: 60px;
2096
+ }
2097
+
2098
+ .context-bar-fill {
2099
+ height: 100%;
2100
+ border-radius: 2px;
2101
+ transition: width 0.3s ease, background 0.3s ease;
2102
+ background: var(--success);
2103
+ }
2104
+
2105
+ .context-bar-fill.mid {
2106
+ background: var(--warning);
2107
+ }
2108
+
2109
+ .context-bar-fill.high {
2110
+ background: var(--error);
2111
+ }
2112
+
2113
+ .context-bar-info {
2114
+ font-size: 11px;
2115
+ color: var(--text-muted);
2116
+ font-family: var(--font-mono);
2117
+ white-space: nowrap;
2118
+ }
2119
+
2120
+ .context-compress-btn {
2121
+ white-space: nowrap;
2122
+ color: var(--warning) !important;
2123
+ border-color: var(--warning) !important;
2124
+ }
2125
+
1953
2126
  .assistant-input-area {
1954
2127
  display: flex;
1955
2128
  gap: 8px;
@@ -1992,6 +2165,13 @@ body {
1992
2165
  border: 1px solid var(--border-default);
1993
2166
  }
1994
2167
 
2168
+ .assistant-message.thinking {
2169
+ display: flex;
2170
+ gap: 5px;
2171
+ align-items: center;
2172
+ padding: 14px 18px;
2173
+ }
2174
+
1995
2175
  .assistant-dot {
1996
2176
  width: 6px;
1997
2177
  height: 6px;
@@ -2067,6 +2247,14 @@ body {
2067
2247
  color: var(--text-faint);
2068
2248
  }
2069
2249
 
2250
+ .assistant-message.tool-result.tool-error {
2251
+ border-left-color: var(--error);
2252
+ }
2253
+
2254
+ .assistant-message.tool-result.tool-error .tool-result-name {
2255
+ color: var(--error);
2256
+ }
2257
+
2070
2258
  .tool-result-header {
2071
2259
  display: flex;
2072
2260
  align-items: center;