@zhongqian97-code/ecode 0.5.64 → 0.5.65
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/dist/index.js
CHANGED
|
@@ -802,7 +802,7 @@ if (rawArgs[0] === "web") {
|
|
|
802
802
|
webAutoApprove = true;
|
|
803
803
|
}
|
|
804
804
|
}
|
|
805
|
-
const { buildServer, generateAccessToken } = await import("./web-
|
|
805
|
+
const { buildServer, generateAccessToken } = await import("./web-6WYKHML6.js");
|
|
806
806
|
const token = finalConfig.webToken ?? generateAccessToken();
|
|
807
807
|
const manager = new SessionManager(finalConfig);
|
|
808
808
|
const __webDirname = dirname(fileURLToPath(import.meta.url));
|
|
@@ -826,10 +826,18 @@ function generateAdminHtml(version) {
|
|
|
826
826
|
const lines = text.split('\\n').filter(l => l.trim());
|
|
827
827
|
const msgsEl = document.getElementById('messages');
|
|
828
828
|
msgsEl.innerHTML = '';
|
|
829
|
+
const toolNames = {};
|
|
829
830
|
for (const line of lines) {
|
|
830
831
|
try {
|
|
831
832
|
const m = JSON.parse(line);
|
|
832
|
-
if (m.
|
|
833
|
+
if (Array.isArray(m.tool_calls)) {
|
|
834
|
+
for (const tc of m.tool_calls) {
|
|
835
|
+
if (tc && tc.id && tc.function) toolNames[tc.id] = tc.function.name;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
if (m.role === 'tool') {
|
|
839
|
+
appendToolBox(toolNames[m.tool_call_id] || 'tool', m.content || '');
|
|
840
|
+
} else if (typeof m.content === 'string' && m.content) {
|
|
833
841
|
appendMessage(m.role === 'user' ? 'user' : 'assistant', renderMarkdown(m.content));
|
|
834
842
|
}
|
|
835
843
|
} catch { /* skip malformed lines */ }
|
|
@@ -842,6 +850,24 @@ function generateAdminHtml(version) {
|
|
|
842
850
|
}
|
|
843
851
|
}
|
|
844
852
|
|
|
853
|
+
// \u5386\u53F2\u56DE\u653E: \u628A\u5DE5\u5177\u8C03\u7528\u6E32\u67D3\u4E3A\u53EF\u6298\u53E0 tool-box\uFF08\u4E0E\u5B9E\u65F6\u6D41\u5F0F\u4E00\u81F4\uFF0C\u9ED8\u8BA4\u6298\u53E0\uFF09
|
|
854
|
+
function appendToolBox(name, output) {
|
|
855
|
+
const msgsEl = document.getElementById('messages');
|
|
856
|
+
const placeholder = msgsEl.querySelector('.empty-chat');
|
|
857
|
+
if (placeholder) placeholder.remove();
|
|
858
|
+
const boxEl = document.createElement('div');
|
|
859
|
+
boxEl.className = 'tool-box collapsed';
|
|
860
|
+
boxEl.innerHTML =
|
|
861
|
+
'<div class="tool-box-header" onclick="toggleToolBox(this)">' +
|
|
862
|
+
'<span class="tb-indicator">\u25B6</span>' +
|
|
863
|
+
'<span class="tb-name">\u2713 ' + escHtml(name) + '</span>' +
|
|
864
|
+
'</div>' +
|
|
865
|
+
'<div class="tool-box-body"></div>';
|
|
866
|
+
boxEl.querySelector('.tool-box-body').textContent = output;
|
|
867
|
+
if (!state.showTools) boxEl.style.display = 'none';
|
|
868
|
+
msgsEl.appendChild(boxEl);
|
|
869
|
+
}
|
|
870
|
+
|
|
845
871
|
function appendMessage(role, htmlContent, opts) {
|
|
846
872
|
const msgsEl = document.getElementById('messages');
|
|
847
873
|
// Remove empty-chat placeholder
|