tagword-codeagent 1.1.6__py3-none-any.whl
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.
- codeagent/__init__.py +10 -0
- codeagent/__main__.py +13 -0
- codeagent/cli/__init__.py +13 -0
- codeagent/cli/entrypoint.py +161 -0
- codeagent/cli/main.py +979 -0
- codeagent/core/__init__.py +2 -0
- codeagent/core/attachments.py +342 -0
- codeagent/core/audio_models.py +50 -0
- codeagent/core/bootstrap.py +178 -0
- codeagent/core/default_presets.py +159 -0
- codeagent/core/env.py +106 -0
- codeagent/core/folder_picker.py +151 -0
- codeagent/core/image_understanding.py +90 -0
- codeagent/core/models.py +6 -0
- codeagent/core/paths.py +238 -0
- codeagent/core/pricing.py +107 -0
- codeagent/core/process_ports.py +258 -0
- codeagent/core/seed_bridge.py +21 -0
- codeagent/core/settings.py +98 -0
- codeagent/core/speech_synth.py +330 -0
- codeagent/core/team_config.py +247 -0
- codeagent/core/team_manager.py +245 -0
- codeagent/core/token_counter.py +41 -0
- codeagent/core/tts_voices.py +103 -0
- codeagent/core/usage_billing.py +72 -0
- codeagent/core/vision_models.py +93 -0
- codeagent/memory/diary.py +144 -0
- codeagent/persona_defaults/README.md +12 -0
- codeagent/persona_defaults/agent.md +352 -0
- codeagent/persona_defaults/identity.md +29 -0
- codeagent/persona_defaults/memory.md +4 -0
- codeagent/persona_defaults/skills.md +325 -0
- codeagent/persona_defaults/soul.md +38 -0
- codeagent/persona_defaults/tools.md +41 -0
- codeagent/persona_defaults/user.md +18 -0
- codeagent/runtime/__init__.py +11 -0
- codeagent/runtime/agent_context.py +6 -0
- codeagent/runtime/agent_runtime.py +21 -0
- codeagent/runtime/compact_prompt.py +9 -0
- codeagent/runtime/compact_state.py +40 -0
- codeagent/runtime/llm_worker.py +132 -0
- codeagent/runtime/orchestrator.py +161 -0
- codeagent/runtime/prompt_enrichment.py +324 -0
- codeagent/runtime/session_manager.py +30 -0
- codeagent/runtime/task_split.py +38 -0
- codeagent/runtime/turn_loop.py +13 -0
- codeagent/runtime/worker.py +48 -0
- codeagent/server/__init__.py +505 -0
- codeagent/server/app_factory.py +1292 -0
- codeagent/server/attachment_api.py +261 -0
- codeagent/server/hub.py +175 -0
- codeagent/server/icon.png +0 -0
- codeagent/server/self_healing.py +143 -0
- codeagent/server/team_engine.py +243 -0
- codeagent/server/tts_api.py +51 -0
- codeagent/server/webui_api_app.py +3180 -0
- codeagent/skills/__init__.py +2 -0
- codeagent/skills/select.py +144 -0
- codeagent/tools/__init__.py +6 -0
- codeagent/tools/agent_tools.py +10 -0
- codeagent/web/__init__.py +1 -0
- codeagent/web/__pycache__/__init__.cpython-313.pyc +0 -0
- codeagent/web/__pycache__/app.cpython-313.pyc +0 -0
- codeagent/web/__pycache__/auth_impl.cpython-313.pyc +0 -0
- codeagent/web/auth_impl.py +326 -0
- codeagent/web/static/00-marked.min.js +6 -0
- codeagent/web/static/00-mermaid.min.js +2314 -0
- codeagent/web/static/00-purify.min.js +3 -0
- codeagent/web/static/00-storage.js +83 -0
- codeagent/web/static/00-utils.js +51 -0
- codeagent/web/static/01-theme.css +96 -0
- codeagent/web/static/01a-scroll.js +86 -0
- codeagent/web/static/01b-think.js +62 -0
- codeagent/web/static/01c-session-identity.js +81 -0
- codeagent/web/static/01c-session-thinking.js +61 -0
- codeagent/web/static/01c-session-tree-menus.js +349 -0
- codeagent/web/static/01c-session-tree.js +531 -0
- codeagent/web/static/01c-session-utilities.js +83 -0
- codeagent/web/static/01c-vision-model.js +132 -0
- codeagent/web/static/01d-image-gen-model.js +84 -0
- codeagent/web/static/01e-audio-model.js +97 -0
- codeagent/web/static/01f-compose-ui.js +88 -0
- codeagent/web/static/01g-tts-settings.js +128 -0
- codeagent/web/static/01h-music-model.js +85 -0
- codeagent/web/static/01i-model-stack.js +291 -0
- codeagent/web/static/01j-video-gen-model.js +85 -0
- codeagent/web/static/01k-model-stack-bootstrap.js +66 -0
- codeagent/web/static/01k-model-stack-state.js +209 -0
- codeagent/web/static/01q-inflight.js +195 -0
- codeagent/web/static/02-reset.css +22 -0
- codeagent/web/static/02-session-ui.js +201 -0
- codeagent/web/static/03-layout-p1.css +2 -0
- codeagent/web/static/03-layout-p2.css +2 -0
- codeagent/web/static/03a-links-stream.js +88 -0
- codeagent/web/static/03b-stream-text.js +119 -0
- codeagent/web/static/03c-render-bubble.js +520 -0
- codeagent/web/static/03d-agent-bubble.js +126 -0
- codeagent/web/static/03e-tool-trace.js +182 -0
- codeagent/web/static/03f-timeline.js +54 -0
- codeagent/web/static/03g-bubble-tts.js +292 -0
- codeagent/web/static/04-components-p1.css +1 -0
- codeagent/web/static/04-components-p2b.css +1 -0
- codeagent/web/static/04-components-p3.css +2 -0
- codeagent/web/static/04-components-p4.css +1 -0
- codeagent/web/static/04-components-p5.css +1 -0
- codeagent/web/static/04-components-p6.css +58 -0
- codeagent/web/static/04-components-p7.css +4 -0
- codeagent/web/static/04-components-p8.css +1 -0
- codeagent/web/static/04-components-p9.css +1 -0
- codeagent/web/static/04-ws-connect.js +351 -0
- codeagent/web/static/04-ws-helpers.js +116 -0
- codeagent/web/static/05-chat-p1.css +1058 -0
- codeagent/web/static/05-chat-p2.css +1 -0
- codeagent/web/static/05-chat-p3.css +295 -0
- codeagent/web/static/05a-session-history.js +176 -0
- codeagent/web/static/05b-session-list.js +114 -0
- codeagent/web/static/05c-dialog.js +123 -0
- codeagent/web/static/05d-project-create.js +172 -0
- codeagent/web/static/05e-project-remote.js +143 -0
- codeagent/web/static/06-chat.js +552 -0
- codeagent/web/static/06-utilities.css +181 -0
- codeagent/web/static/06b-attachments.js +304 -0
- codeagent/web/static/06c-camera.js +488 -0
- codeagent/web/static/07-activity-bar.css +127 -0
- codeagent/web/static/09-git-p1.css +1 -0
- codeagent/web/static/09-git-p2.css +1 -0
- codeagent/web/static/09a-init-bind.js +110 -0
- codeagent/web/static/09b-panel-toggle.js +80 -0
- codeagent/web/static/09c-api-refresh.js +100 -0
- codeagent/web/static/09d-status-log.js +80 -0
- codeagent/web/static/09e-commit.js +80 -0
- codeagent/web/static/09f-remote.js +93 -0
- codeagent/web/static/11a-cron-parse.js +117 -0
- codeagent/web/static/11b-cron-panel.js +100 -0
- codeagent/web/static/11c-cron-card.js +133 -0
- codeagent/web/static/11d-cron-form.js +105 -0
- codeagent/web/static/11e-env-config.js +168 -0
- codeagent/web/static/11f-env-llm-a-state.js +136 -0
- codeagent/web/static/11f-env-llm-b-form.js +409 -0
- codeagent/web/static/11f-env-llm-c-board.js +322 -0
- codeagent/web/static/11g-env-paths-git.js +973 -0
- codeagent/web/static/11h-env-mcp-a-state.js +161 -0
- codeagent/web/static/11h-env-mcp-b-form.js +229 -0
- codeagent/web/static/11h-env-mcp-c-board.js +565 -0
- codeagent/web/static/12-plugins.js +127 -0
- codeagent/web/static/13a-skills.js +156 -0
- codeagent/web/static/13a-todo-utils.js +140 -0
- codeagent/web/static/13b-todo-fetch.js +106 -0
- codeagent/web/static/13b-tools.js +127 -0
- codeagent/web/static/13c-todo-crud.js +92 -0
- codeagent/web/static/14-activity-bar.js +177 -0
- codeagent/web/static/15-plans.css +194 -0
- codeagent/web/static/15-plans.js +219 -0
- codeagent/web/static/16-mobile.css +612 -0
- codeagent/web/static/16-mobile.js +178 -0
- codeagent/web/static/17-preset-ux.css +287 -0
- codeagent/web/static/18-agent-mgr.css +616 -0
- codeagent/web/static/18-agent-mgr.js +204 -0
- codeagent/web/static/24-health-dashboard.js +68 -0
- codeagent/web/static/99-brand-polish.css +152 -0
- codeagent/web/static/body.html +824 -0
- codeagent/web/static/setup/setup_form.html +171 -0
- codeagent/web/static/setup/setup_head.html +100 -0
- codeagent/web/static/setup/setup_tail.html +264 -0
- codeagent/web/static/setup/setup_test.html +38 -0
- codeagent/web/web_login.html +265 -0
- codeagent/web/webui.html +35 -0
- tagword_codeagent-1.1.6.dist-info/METADATA +273 -0
- tagword_codeagent-1.1.6.dist-info/RECORD +173 -0
- tagword_codeagent-1.1.6.dist-info/WHEEL +5 -0
- tagword_codeagent-1.1.6.dist-info/entry_points.txt +3 -0
- tagword_codeagent-1.1.6.dist-info/licenses/LICENSE +21 -0
- tagword_codeagent-1.1.6.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/* ---- 新建项目对话框 ---- */.modal-overlay { position: fixed; inset: 0; z-index: 999; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center;}.modal-dialog, .modal { background: var(--bg-primary, #fff); border-radius: 10px; box-shadow: 0 8px 32px rgba(0,0,0,0.2); width: 420px; max-width: 90vw; max-height: 85vh; overflow: hidden; animation: modalFadeIn 0.15s ease-out; display: flex; flex-direction: column;}.modal__header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; flex-shrink: 0;}.modal__body { padding: 16px 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1;}.modal__footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border-color, #e5e5ea); flex-shrink: 0;}@keyframes modalFadeIn { from { opacity: 0; transform: translateY(-12px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); }}.modal-dialog__header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0;}.modal-dialog__title { font-size: 16px; font-weight: 600; color: var(--text-primary, #1a1a2e);}.modal-dialog__close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-secondary, #888); padding: 0 4px; line-height: 1;}.modal-dialog__close:hover { color: var(--text-primary, #1a1a2e); }.modal-dialog__body { padding: 16px 20px; }.modal-dialog__footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border-color, #e5e5ea);}.modal-field { margin-bottom: 14px; }.modal-field:last-child { margin-bottom: 0; }.modal-field__label { display: block; font-size: 13px; font-weight: 500; color: var(--text-primary, #1a1a2e); margin-bottom: 5px;}.modal-field__label .required { color: #e74c3c; }.modal-field__label .optional { color: var(--text-secondary, #888); font-weight: 400; }.modal-field__input { width: 100%; box-sizing: border-box; padding: 8px 12px; border: 1px solid var(--border-color, #d1d1d6); border-radius: 6px; font-size: 14px; background: var(--bg-primary, #fff); color: var(--text-primary, #1a1a2e); outline: none; transition: border-color 0.15s;}.modal-field__input:focus { border-color: var(--accent, #007aff); box-shadow: 0 0 0 2px rgba(0,122,255,0.15); }.modal-field__hint { font-size: 12px; color: var(--text-secondary, #888); margin-top: 4px; }.modal-btn { padding: 7px 16px; border-radius: 6px; font-size: 14px; cursor: pointer; border: 1px solid var(--border-color, #d1d1d6); background: var(--bg-primary, #fff); color: var(--text-primary, #1a1a2e); transition: background 0.1s;}.modal-btn:hover { background: var(--bg-hover, #f2f2f7); }.modal-btn--confirm { background: var(--accent, #007aff); color: #fff; border-color: var(--accent, #007aff);}.modal-btn--confirm:hover { opacity: 0.9; }.modal-btn--browse { font-size: 13px; padding: 6px 12px; white-space: nowrap; flex-shrink: 0;}.modal-field__input-row { display: flex; gap: 6px; align-items: stretch;}.modal-field__input-row .modal-field__input { flex: 1; }/* ================================================================ * Todo panel — slide-out right panel for todo items * ================================================================ */.todo-panel { position: absolute; top: var(--topbar-h, 44px); right: 0; bottom: 0; width: 360px; max-width: 90vw; background: var(--bg-panel); border-left: 1px solid var(--border); display: none; flex-direction: column; z-index: 50; box-shadow: -4px 0 16px rgba(0,0,0,0.06); overflow: hidden;}.todo-panel__header { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-3) var(--sp-4); font-size: 13px; font-weight: 600; color: var(--text); border-bottom: 1px solid var(--border); flex-shrink: 0;}.todo-panel__list { flex: 1; overflow-y: auto; padding: var(--sp-2) 0; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;}.todo-panel__list::-webkit-scrollbar { width: 8px; }.todo-panel__list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }/* ---- Scope toggle ---- */.todo-scope-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden;}.todo-scope-btn { padding: 2px 8px; font-size: 11px; font-weight: 500; background: transparent; border: none; color: var(--text-secondary); cursor: pointer; transition: background 0.15s, color 0.15s; line-height: 1.6;}.todo-scope-btn:hover { background: var(--bg-hover); color: var(--text);}.todo-scope-btn.is-active { background: var(--accent); color: #fff;}.todo-panel__footer { display: flex; align-items: center; justify-content: center; padding: var(--sp-2) var(--sp-4); border-top: 1px solid var(--border); flex-shrink: 0;}/* ---- Empty state ---- */.todo-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; text-align: center; color: var(--text-muted); font-size: 13px; line-height: 1.6; padding: var(--sp-8);}/* ---- Group separator ---- */.todo-group-sep { height: 1px; background: var(--border); margin: var(--sp-1) var(--sp-4);}/* ---- Panel close button (for Plan/Todo/Git slide panels) ---- */.panel-close-btn { background: none; border: none; font-size: 20px; line-height: 1; cursor: pointer; color: var(--text-muted, #888); padding: 0 2px; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-sm, 4px); transition: background 0.12s, color 0.12s; flex-shrink: 0;}.panel-close-btn:hover { background: var(--bg-hover, rgba(128,128,128,0.12)); color: var(--text, #333);}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/* ---- Group header ---- */.todo-group-header { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-4) var(--sp-1); cursor: default;}.todo-group-badge { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: var(--r-full); font-size: 10px; font-weight: 600; font-family: var(--font-mono, monospace); letter-spacing: 0.02em; background: var(--gb-bg); color: var(--gb-text); border: 1px solid var(--gb-border); flex-shrink: 0; line-height: 1.6;}.todo-group-meta { display: flex; align-items: center; gap: var(--sp-2); font-size: 10.5px; color: var(--text-muted); overflow: hidden;}.todo-group-count { flex-shrink: 0;}.todo-group-time { overflow: hidden; text-overflow: ellipsis; white-space: nowrap;}/* ---- Todo item (v2: two-row layout) ---- */.todo-item { display: flex; flex-direction: column; padding: var(--sp-1) var(--sp-4); transition: background 0.1s ease; cursor: default; gap: 1px;}.todo-item:hover { background: var(--bg-hover);}/* Main row: checkbox + content + delete */.todo-item__main { display: flex; align-items: center; gap: var(--sp-2); min-height: 26px;}.todo-item__checkbox { flex-shrink: 0; width: 14px; height: 14px; margin: 0; accent-color: var(--accent, #2563eb); cursor: pointer;}.todo-item__content { flex: 1; min-width: 0; font-size: 12.5px; color: var(--text); line-height: 1.4; word-break: break-word; overflow-wrap: break-word; white-space: pre-wrap;}.todo-item__content--done { text-decoration: line-through; color: var(--text-muted);}/* Meta row: time + status + session badge */.todo-item__meta { display: flex; align-items: center; gap: var(--sp-2); padding-left: calc(14px + var(--sp-2)); min-height: 18px;}.todo-item__time { flex-shrink: 0; font-size: 10px; color: var(--text-subtle); white-space: nowrap;}.todo-item__status { flex-shrink: 0; display: inline-flex; align-items: center; padding: 0 6px; border-radius: var(--r-xs, 3px); font-size: 10px; font-weight: 500; line-height: 1.6;}.todo-item__status--pending { background: var(--accent-soft, #e8f0fe); color: var(--accent, #2563eb);}.todo-item__status--in_progress { background: #fff3e0; color: #e65100;}.todo-item__status--completed { background: #e8f5e9; color: #2e7d32;}.todo-item__status--cancelled { background: #f5f5f5; color: #9e9e9e;}.todo-item__session { flex-shrink: 0; display: inline-flex; align-items: center; padding: 0 5px; border-radius: var(--r-xs, 3px); font-size: 9px; font-weight: 600; font-family: var(--font-mono, monospace); line-height: 1.6; background: var(--s-bg); color: var(--s-text); border: 1px solid var(--s-border); cursor: default;}/* Delete button -- appeared on hover */.todo-item__delete { flex-shrink: 0; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; border: none; background: transparent; color: var(--text-subtle); font-size: 15px; line-height: 1; cursor: pointer; border-radius: var(--r-xs, 3px); opacity: 0; transition: opacity 0.12s, background 0.12s, color 0.12s;}.todo-item:hover .todo-item__delete { opacity: 1;}.todo-item__delete:hover { background: var(--bg-hover); color: var(--text-danger, #e53935);}
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
// ── Token 用量更新(DeepSeek 精确计数) ─────────────────────────
|
|
2
|
+
let _tokenContextMax = 200000; // 默认 200k tokens
|
|
3
|
+
let _lastKnownPromptTokens = 0; // 末次有效分子,避免运行结束后被空 payload 清零
|
|
4
|
+
|
|
5
|
+
/** 从持久化/WS payload 取 API 分子(peak 优先于末轮 prompt_tokens) */
|
|
6
|
+
function pickContextUsageTokens(cu) {
|
|
7
|
+
if (!cu || typeof cu !== 'object') return 0;
|
|
8
|
+
var peak = Number(cu.peak_prompt_tokens) || 0;
|
|
9
|
+
var pt = Number(cu.prompt_tokens) || 0;
|
|
10
|
+
return Math.max(peak, pt);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function setTokenContextMax(maxTokens) {
|
|
14
|
+
_tokenContextMax = maxTokens > 0 ? maxTokens : 200000;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function resetTokenUsageCache() {
|
|
18
|
+
_lastKnownPromptTokens = 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** 更新 token 用量指示器(仅 token 用量,不含费用)
|
|
22
|
+
* @param {number|Object} curOrUsage - {prompt_tokens, ...} 或 {total_tokens, ...}
|
|
23
|
+
* @param {number} [compactMinTokens] - 兼容旧格式的 min_tokens
|
|
24
|
+
*/
|
|
25
|
+
function updateTokenUsage(curOrUsage, compactMinTokens) {
|
|
26
|
+
var el = document.getElementById('tokenUsage');
|
|
27
|
+
if (!el) return;
|
|
28
|
+
var segEls = el.querySelectorAll('.token-usage__seg');
|
|
29
|
+
var pctEl = el.querySelector('.token-usage__pct');
|
|
30
|
+
var curTokens = 0;
|
|
31
|
+
var maxTokens = _tokenContextMax;
|
|
32
|
+
if (typeof curOrUsage === 'object' && curOrUsage !== null) {
|
|
33
|
+
var picked = pickContextUsageTokens(curOrUsage);
|
|
34
|
+
if (picked > 0) {
|
|
35
|
+
curTokens = picked;
|
|
36
|
+
} else if (curOrUsage.total_tokens != null && Number(curOrUsage.total_tokens) > 0) {
|
|
37
|
+
curTokens = Number(curOrUsage.total_tokens);
|
|
38
|
+
}
|
|
39
|
+
// 分母只用 compact 触发阈值;不用 context_limit(模型窗口)
|
|
40
|
+
if (curOrUsage.compact_min_tokens != null && Number(curOrUsage.compact_min_tokens) > 0) {
|
|
41
|
+
maxTokens = Number(curOrUsage.compact_min_tokens);
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
curTokens = Math.round((curOrUsage || 0) / 4);
|
|
45
|
+
if (compactMinTokens > 0) maxTokens = compactMinTokens;
|
|
46
|
+
}
|
|
47
|
+
if (curTokens <= 0) {
|
|
48
|
+
// 无有效分子时不覆盖已有读数(运行结束后的空 WS/空 ctx 不应把指示器清零)
|
|
49
|
+
if (_lastKnownPromptTokens > 0) return;
|
|
50
|
+
el.style.display = 'inline-flex';
|
|
51
|
+
for (var si = 0; si < segEls.length; si++) {
|
|
52
|
+
segEls[si].classList.toggle('is-on', false);
|
|
53
|
+
}
|
|
54
|
+
if (pctEl) pctEl.textContent = '0%';
|
|
55
|
+
el.setAttribute('aria-valuenow', '0');
|
|
56
|
+
el.setAttribute('aria-valuetext', '0 / 5 档,0%');
|
|
57
|
+
el.title = '上下文占用';
|
|
58
|
+
el.classList.remove('is-warm', 'is-hot');
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
_lastKnownPromptTokens = curTokens;
|
|
62
|
+
el.style.display = 'inline-flex';
|
|
63
|
+
var pct = maxTokens > 0 ? Math.round(Math.min((curTokens / maxTokens) * 100, 100)) : 0;
|
|
64
|
+
var filled = pct > 0 ? Math.min(5, Math.ceil((pct / 100) * 5)) : 0;
|
|
65
|
+
for (var si = 0; si < segEls.length; si++) {
|
|
66
|
+
segEls[si].classList.toggle('is-on', si < filled);
|
|
67
|
+
}
|
|
68
|
+
if (pctEl) pctEl.textContent = pct + '%';
|
|
69
|
+
el.setAttribute('aria-valuenow', String(pct));
|
|
70
|
+
el.setAttribute('aria-valuemax', '100');
|
|
71
|
+
el.setAttribute('aria-valuetext', filled + ' / 5 档,' + pct + '%');
|
|
72
|
+
var curLabel = curTokens >= 1000 ? (curTokens / 1000).toFixed(1) + 'k' : String(curTokens);
|
|
73
|
+
var maxLabel = maxTokens >= 1000 ? (maxTokens / 1000).toFixed(0) + 'k' : String(maxTokens);
|
|
74
|
+
el.title = '上下文 ' + curLabel + ' / ' + maxLabel + ' tokens(' + pct + '%)';
|
|
75
|
+
el.classList.toggle('is-warm', pct >= 60 && pct < 85);
|
|
76
|
+
el.classList.toggle('is-hot', pct >= 85);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** 更新侧边栏费用汇总
|
|
80
|
+
* @param {Object} accUsage - accumulated_usage 对象(含 per_model, total_cost)
|
|
81
|
+
*/
|
|
82
|
+
function updateSidebarCost(accUsage) {
|
|
83
|
+
var el = document.getElementById('sidebarCost');
|
|
84
|
+
if (!el) return;
|
|
85
|
+
var body = el.querySelector('.sidebar-cost__body');
|
|
86
|
+
if (!accUsage || !accUsage.per_model) { el.style.display = 'none'; return; }
|
|
87
|
+
el.style.display = '';
|
|
88
|
+
var totalCost = typeof accUsage.total_cost === 'number' ? accUsage.total_cost : 0;
|
|
89
|
+
var lines = [];
|
|
90
|
+
for (var model in accUsage.per_model) {
|
|
91
|
+
var md = accUsage.per_model[model];
|
|
92
|
+
var tok = md.total_tokens || 0;
|
|
93
|
+
var cost = typeof md.cost === 'number' ? md.cost : 0;
|
|
94
|
+
if (typeof accUsage.total_cost !== 'number') totalCost += cost;
|
|
95
|
+
var modelLabel = model.replace(/^deepseek-/, 'DS ');
|
|
96
|
+
var tokStr = tok >= 1000 ? (tok / 1000).toFixed(1) + 'k' : String(tok);
|
|
97
|
+
var costStr = cost < 0.01 ? '\u00A5' + cost.toFixed(4) : (cost < 1 ? '\u00A5' + cost.toFixed(3) : '\u00A5' + cost.toFixed(2));
|
|
98
|
+
lines.push({ model: modelLabel, tokens: tokStr, cost: costStr });
|
|
99
|
+
}
|
|
100
|
+
var html = '<div class="cost__list">';
|
|
101
|
+
for (var i = 0; i < lines.length; i++) {
|
|
102
|
+
var l = lines[i];
|
|
103
|
+
html += '<div class="cost__row"><span class="cost__model">' + l.model + '</span>'
|
|
104
|
+
+ '<span class="cost__tokens">' + l.tokens + '</span>'
|
|
105
|
+
+ '<span class="cost__amount">' + l.cost + '</span></div>';
|
|
106
|
+
}
|
|
107
|
+
if (lines.length > 1) {
|
|
108
|
+
var totalStr = totalCost < 0.01 ? '\u00A5' + totalCost.toFixed(4) : (totalCost < 1 ? '\u00A5' + totalCost.toFixed(3) : '\u00A5' + totalCost.toFixed(2));
|
|
109
|
+
html += '<div class="cost__row cost__row--total"><span class="cost__model">\u5408\u8BA1</span><span class="cost__tokens"></span><span class="cost__amount">' + totalStr + '</span></div>';
|
|
110
|
+
}
|
|
111
|
+
html += '</div>';
|
|
112
|
+
if (body) body.innerHTML = html;
|
|
113
|
+
else el.innerHTML = '<div class="sidebar-cost__title">\u8FD0\u884C\u8D39\u7528</div>' + html;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** 从 DOM 中所有气泡内容重新估算 token 用量(WS/API 不可用时的 fallback)
|
|
117
|
+
* 使用 DeepSeek 公式:中文 0.6 token/char,英文 0.3 token/char
|
|
118
|
+
*/
|
|
119
|
+
function recalcTokenUsageFromDom() {
|
|
120
|
+
var totalTokens = 0;
|
|
121
|
+
var bubbles = document.querySelectorAll('.bubble');
|
|
122
|
+
bubbles.forEach(function (b) {
|
|
123
|
+
var text = b.textContent || '';
|
|
124
|
+
var cn = 0, en = 0;
|
|
125
|
+
for (var i = 0; i < text.length; i++) {
|
|
126
|
+
var code = text.charCodeAt(i);
|
|
127
|
+
if ((code >= 0x4E00 && code <= 0x9FFF) ||
|
|
128
|
+
(code >= 0x3400 && code <= 0x4DBF) ||
|
|
129
|
+
(code >= 0x20000 && code <= 0x2A6DF)) {
|
|
130
|
+
cn++;
|
|
131
|
+
} else {
|
|
132
|
+
en++;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
totalTokens += Math.round(cn * 0.6 + en * 0.3);
|
|
136
|
+
});
|
|
137
|
+
// 每条消息系统开销(role 标记等)
|
|
138
|
+
totalTokens += bubbles.length * 4;
|
|
139
|
+
updateTokenUsage({ total_tokens: totalTokens });
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function connectWs() {
|
|
143
|
+
if (wsReconnectTimer) { clearTimeout(wsReconnectTimer); wsReconnectTimer = null; }
|
|
144
|
+
if (ws) { try { ws.close(); } catch (e) {} ws = undefined; }
|
|
145
|
+
const proto = location.protocol === 'https:' ? 'wss' : 'ws';
|
|
146
|
+
var wsTokQs = '';
|
|
147
|
+
try {
|
|
148
|
+
var wst = tryGetSS(STORAGE_KEYS.WS_TOKEN);
|
|
149
|
+
if (wst) wsTokQs = '&webui_token=' + encodeURIComponent(wst);
|
|
150
|
+
} catch (_) {}
|
|
151
|
+
const sock = new WebSocket(
|
|
152
|
+
proto + '//' + location.host +
|
|
153
|
+
'/ws?session_id=' + encodeURIComponent(sessionId) +
|
|
154
|
+
'&agent_id=' + encodeURIComponent(agentId) +
|
|
155
|
+
wsTokQs
|
|
156
|
+
);
|
|
157
|
+
ws = sock;
|
|
158
|
+
sock.onopen = () => {
|
|
159
|
+
// WS 重连后从后端恢复正在运行中的会话状态(断连期间 run_started/run_finished 事件已丢失)
|
|
160
|
+
if (typeof restoreRunningSessions === 'function') restoreRunningSessions();
|
|
161
|
+
};
|
|
162
|
+
sock.onmessage = (ev) => {
|
|
163
|
+
try {
|
|
164
|
+
const j = JSON.parse(ev.data);
|
|
165
|
+
const handler = WS_HANDLERS[j.type];
|
|
166
|
+
if (handler) { handler(j); return; }
|
|
167
|
+
if (j.type === 'reply') handleWsReply(j);
|
|
168
|
+
} catch (_) {}
|
|
169
|
+
};
|
|
170
|
+
sock.onclose = () => {
|
|
171
|
+
if (pauseWsReconnect) return;
|
|
172
|
+
wsReconnectTimer = setTimeout(connectWs, 2000);
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// ---- WS message dispatcher (data-driven) -------------------------------
|
|
177
|
+
|
|
178
|
+
/** 派发表:j.type → handler。handler 必须容忍字段缺失;sessionId 匹配在主循环中已确认。 */
|
|
179
|
+
const WS_HANDLERS = {
|
|
180
|
+
tool_start: handleProgressEvent,
|
|
181
|
+
tool_output: handleProgressEvent,
|
|
182
|
+
tool_end: handleProgressEvent,
|
|
183
|
+
chat_stop_requested: function (j) {
|
|
184
|
+
if (j.session_id === sessionId) systemMsg('info', '⏳ 正在完成本轮回答…');
|
|
185
|
+
},
|
|
186
|
+
chat_cancelled: function (j) {
|
|
187
|
+
if (j.session_id) setSessionRunning(j.session_id, false);
|
|
188
|
+
if (j.session_id === sessionId) systemMsg('info', '✅ 已停止。');
|
|
189
|
+
if (webuiSessionsEnabled) refreshSessionList().catch(function() {});
|
|
190
|
+
},
|
|
191
|
+
run_started: function (j) {
|
|
192
|
+
if (j.session_id) setSessionRunning(j.session_id, true);
|
|
193
|
+
if (webuiSessionsEnabled) refreshSessionList().catch(function() {});
|
|
194
|
+
},
|
|
195
|
+
run_finished: function (j) {
|
|
196
|
+
if (j.session_id) {
|
|
197
|
+
setSessionRunning(j.session_id, false);
|
|
198
|
+
// 标记 completed(绿色),除非用户手动清除过
|
|
199
|
+
var k = String(j.session_id);
|
|
200
|
+
if (!_userClearedCompletedSids[k]) {
|
|
201
|
+
chatCompletedBySid[k] = true;
|
|
202
|
+
persistCompletedSessions();
|
|
203
|
+
if (typeof applySessionCompletedState === 'function') applySessionCompletedState(k);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (webuiSessionsEnabled) refreshSessionList().catch(function() {});
|
|
207
|
+
},
|
|
208
|
+
context_compact: handleWsContextCompact,
|
|
209
|
+
context_usage: handleWsContextUsage,
|
|
210
|
+
text_delta: handleWsTextDelta,
|
|
211
|
+
text_done: handleWsTextDone,
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
function handleWsContextCompact(j) {
|
|
215
|
+
if (j.session_id !== sessionId) return;
|
|
216
|
+
systemMsg('info', '上下文已压缩(compact):丢弃 ' + (j.dropped_messages || 0)
|
|
217
|
+
+ ' 条历史消息,保留最近 ' + (j.kept_user_rounds || 0) + ' 轮。');
|
|
218
|
+
if (j.prompt_tokens_after != null && Number(j.prompt_tokens_after) > 0) {
|
|
219
|
+
updateTokenUsage({
|
|
220
|
+
prompt_tokens: Number(j.prompt_tokens_after),
|
|
221
|
+
compact_min_tokens: j.compact_min_tokens,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** context_usage:统一入口(prompt_tokens 来自 LLM API,最精确) */
|
|
227
|
+
function handleWsContextUsage(j) {
|
|
228
|
+
if (j.session_id && j.session_id !== sessionId) return;
|
|
229
|
+
var cu = { compact_min_tokens: j.compact_min_tokens };
|
|
230
|
+
var picked = pickContextUsageTokens(j);
|
|
231
|
+
if (picked > 0) {
|
|
232
|
+
cu.prompt_tokens = picked;
|
|
233
|
+
if (j.peak_prompt_tokens != null && Number(j.peak_prompt_tokens) > 0) {
|
|
234
|
+
cu.peak_prompt_tokens = Number(j.peak_prompt_tokens);
|
|
235
|
+
}
|
|
236
|
+
} else if (j.token_usage && typeof j.token_usage === 'object') {
|
|
237
|
+
var tu = Object.assign({}, j.token_usage, { compact_min_tokens: j.compact_min_tokens });
|
|
238
|
+
var tuPt = pickContextUsageTokens(tu) || Number(tu.total_tokens) || 0;
|
|
239
|
+
if (tuPt > 0) updateTokenUsage(Object.assign({}, tu, { prompt_tokens: tuPt }));
|
|
240
|
+
if (j.accumulated_usage && typeof updateSidebarCost === 'function') {
|
|
241
|
+
updateSidebarCost(j.accumulated_usage);
|
|
242
|
+
}
|
|
243
|
+
return;
|
|
244
|
+
} else {
|
|
245
|
+
if (j.accumulated_usage && typeof updateSidebarCost === 'function') {
|
|
246
|
+
updateSidebarCost(j.accumulated_usage);
|
|
247
|
+
}
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
updateTokenUsage(cu);
|
|
251
|
+
if (j.accumulated_usage && typeof updateSidebarCost === 'function') {
|
|
252
|
+
updateSidebarCost(j.accumulated_usage);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function handleWsTextDelta(j) {
|
|
257
|
+
if (j.session_id !== sessionId) return;
|
|
258
|
+
updateStreamBubbleText(j.text || '');
|
|
259
|
+
if (typeof markLiveProgressSeen === 'function') markLiveProgressSeen(sessionId);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function handleWsTextDone(j) {
|
|
263
|
+
if (j.session_id !== sessionId) return;
|
|
264
|
+
var finalized = finalizeStreamBubble(j.text || '');
|
|
265
|
+
if (!finalized) {
|
|
266
|
+
var remainingText = '';
|
|
267
|
+
if (typeof _streamUnconsumedSuffix === 'function') {
|
|
268
|
+
remainingText = _streamUnconsumedSuffix(j.text || '');
|
|
269
|
+
} else if (typeof _streamDeltaText === 'function') {
|
|
270
|
+
remainingText = _streamDeltaText(j.text || '');
|
|
271
|
+
}
|
|
272
|
+
if (remainingText && typeof bubbleAgentWithSplitToolTrace === 'function') {
|
|
273
|
+
bubbleAgentWithSplitToolTrace(remainingText, [], { at: Date.now(), skipScroll: true });
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (typeof _advanceStreamConsumedLen === 'function') _advanceStreamConsumedLen(j.text || '');
|
|
277
|
+
if (typeof syncLiveToolsFromToolTrace === 'function') syncLiveToolsFromToolTrace(j.tool_trace || []);
|
|
278
|
+
// Remember this reply so the subsequent WS 'reply' event is deduped.
|
|
279
|
+
if (typeof rememberLocalAgentReply === 'function') rememberLocalAgentReply(j.text || '');
|
|
280
|
+
if (typeof markWsTextDone === 'function') markWsTextDone(sessionId);
|
|
281
|
+
if (typeof markLiveProgressSeen === 'function') markLiveProgressSeen(sessionId);
|
|
282
|
+
if (webuiSessionsEnabled) refreshSessionList().catch(function() {});
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function handleWsReply(j) {
|
|
286
|
+
if (isSessionRunning(sessionId)) return;
|
|
287
|
+
const t = normReply(j.text);
|
|
288
|
+
if (!t) return;
|
|
289
|
+
// 15s 内已收到相同正文(streaming 'text_done' 已写过)→ 去重
|
|
290
|
+
if (t === lastLocalAgentReplyNorm && (Date.now() - lastLocalAgentReplyAt) < 15000) return;
|
|
291
|
+
if (typeof bubbleAgentWithSplitToolTrace === 'function') {
|
|
292
|
+
bubbleAgentWithSplitToolTrace(j.text || '', j.tool_trace || [], { at: Date.now() });
|
|
293
|
+
} else {
|
|
294
|
+
bubble('agent', j.text || '', { at: Date.now(), toolTrace: j.tool_trace || [] });
|
|
295
|
+
}
|
|
296
|
+
if (webuiSessionsEnabled) refreshSessionList().catch(function() {});
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function reconnectWsForSession() {
|
|
300
|
+
resetTokenUsageCache();
|
|
301
|
+
pauseWsReconnect = true;
|
|
302
|
+
if (wsReconnectTimer) { clearTimeout(wsReconnectTimer); wsReconnectTimer = null; }
|
|
303
|
+
if (ws) { try { ws.close(); } catch (e) {} ws = undefined; }
|
|
304
|
+
pauseWsReconnect = false;
|
|
305
|
+
connectWs();
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// Optional WS connection, gated by /api/ui/flags.ws_enabled
|
|
309
|
+
try {
|
|
310
|
+
fetch('/api/ui/flags?agent_id=' + encodeURIComponent(agentId)).then(async (r) => {
|
|
311
|
+
if (!r.ok) return { ws_enabled: false };
|
|
312
|
+
return await r.json();
|
|
313
|
+
}).then(f => {
|
|
314
|
+
if (f && f.ws_enabled === false) return;
|
|
315
|
+
connectWs();
|
|
316
|
+
}).catch(_ => {});
|
|
317
|
+
} catch (_) {}
|
|
318
|
+
|
|
319
|
+
// ── Compact 阈值输入框(tokens) ────────────────────────────
|
|
320
|
+
function initCompactMinInput() {
|
|
321
|
+
var inp = document.getElementById('inpCompactMinBytes');
|
|
322
|
+
if (!inp) return;
|
|
323
|
+
// 加载当前值
|
|
324
|
+
fetch('/api/ui/compact-config').then(r => r.json()).then(d => {
|
|
325
|
+
if (d.compact_min_tokens > 0) {
|
|
326
|
+
inp.value = d.compact_min_tokens;
|
|
327
|
+
setTokenContextMax(d.compact_min_tokens);
|
|
328
|
+
}
|
|
329
|
+
}).catch(_ => {});
|
|
330
|
+
// 变更时保存
|
|
331
|
+
inp.addEventListener('change', function() {
|
|
332
|
+
var val = parseInt(this.value, 10) || 0;
|
|
333
|
+
setTokenContextMax(val);
|
|
334
|
+
fetch('/api/ui/compact-config', {
|
|
335
|
+
method: 'POST',
|
|
336
|
+
headers: { 'Content-Type': 'application/json' },
|
|
337
|
+
body: JSON.stringify({ compact_min_tokens: val }),
|
|
338
|
+
credentials: 'same-origin',
|
|
339
|
+
}).catch(_ => {});
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
// 页面加载完成后初始化
|
|
343
|
+
if (document.readyState === 'complete' || document.readyState === 'interactive') {
|
|
344
|
+
setTimeout(initCompactMinInput, 500);
|
|
345
|
+
} else {
|
|
346
|
+
document.addEventListener('DOMContentLoaded', function() { setTimeout(initCompactMinInput, 500); });
|
|
347
|
+
}
|
|
348
|
+
// 立即初始化 _tokenContextMax(不等 DOM,避免 restore 时用 200000 默认值)
|
|
349
|
+
fetch('/api/ui/compact-config').then(r => r.json()).then(d => {
|
|
350
|
+
if (d.compact_min_tokens > 0) setTokenContextMax(d.compact_min_tokens);
|
|
351
|
+
}).catch(_ => {});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/* ================================================================
|
|
2
|
+
* 04-websocket.js
|
|
3
|
+
* - WebSocket connection management (connectWs, reconnectWsForSession)
|
|
4
|
+
* - Live tool event stream (liveToolBlocks, handleProgressEvent)
|
|
5
|
+
* - WS flag check
|
|
6
|
+
* ================================================================ */
|
|
7
|
+
|
|
8
|
+
let ws;
|
|
9
|
+
let wsReconnectTimer = null;
|
|
10
|
+
let pauseWsReconnect = false;
|
|
11
|
+
|
|
12
|
+
const liveToolBlocks = new Map();
|
|
13
|
+
const liveProgressSeenBySid = Object.create(null);
|
|
14
|
+
const wsTextDoneBySid = Object.create(null);
|
|
15
|
+
|
|
16
|
+
function markLiveProgressSeen(sid) {
|
|
17
|
+
if (!sid) return;
|
|
18
|
+
liveProgressSeenBySid[sid] = true;
|
|
19
|
+
}
|
|
20
|
+
function consumeLiveProgressSeen(sid) {
|
|
21
|
+
const v = !!liveProgressSeenBySid[sid];
|
|
22
|
+
delete liveProgressSeenBySid[sid];
|
|
23
|
+
return v;
|
|
24
|
+
}
|
|
25
|
+
/** WS 已发过 text_done(本轮助手输出已由 WS 收尾),HTTP /api/chat 不应再画一遍正文 */
|
|
26
|
+
function markWsTextDone(sid) {
|
|
27
|
+
if (sid) wsTextDoneBySid[String(sid)] = true;
|
|
28
|
+
}
|
|
29
|
+
function consumeWsTextDone(sid) {
|
|
30
|
+
const k = String(sid || '');
|
|
31
|
+
const v = !!wsTextDoneBySid[k];
|
|
32
|
+
delete wsTextDoneBySid[k];
|
|
33
|
+
return v;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function ensureLiveToolBlock(evt) {
|
|
37
|
+
const id = String((evt && evt.event_id) || '');
|
|
38
|
+
if (!id) return null;
|
|
39
|
+
let row = liveToolBlocks.get(id);
|
|
40
|
+
if (row) return row;
|
|
41
|
+
const typ = String((evt && evt.type) || '');
|
|
42
|
+
const running = typ !== 'tool_end';
|
|
43
|
+
const wrap = appendAgentToolTraceRowToLog(
|
|
44
|
+
{
|
|
45
|
+
tool: String((evt && evt.tool) || 'tool'),
|
|
46
|
+
arguments: String((evt && evt.arguments) || ''),
|
|
47
|
+
result: String((evt && evt.result) || ''),
|
|
48
|
+
},
|
|
49
|
+
0,
|
|
50
|
+
1,
|
|
51
|
+
{ running: running, skipScroll: true, hideIndex: true }
|
|
52
|
+
);
|
|
53
|
+
try {
|
|
54
|
+
wrap.dataset.oaEventId = id;
|
|
55
|
+
} catch (_) {}
|
|
56
|
+
const pre = wrap.querySelector('.oa-tool-trace-pre');
|
|
57
|
+
const title = wrap.querySelector('.oa-live-tool-title');
|
|
58
|
+
row = { wrap: wrap, title: title, pre: pre, hasOutput: false };
|
|
59
|
+
liveToolBlocks.set(id, row);
|
|
60
|
+
scrollLog();
|
|
61
|
+
return row;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function appendLiveToolOutput(evt) {
|
|
65
|
+
const row = ensureLiveToolBlock(evt);
|
|
66
|
+
if (!row) return;
|
|
67
|
+
const text = String((evt && evt.text) || '');
|
|
68
|
+
if (!text) return;
|
|
69
|
+
if (!row.title.textContent) {
|
|
70
|
+
try { const tool = String((evt && evt.tool) || 'tool'); row.title.textContent = '执行中:' + tool; } catch (_) {}
|
|
71
|
+
}
|
|
72
|
+
row.hasOutput = true;
|
|
73
|
+
row.pre.textContent += text;
|
|
74
|
+
scrollLog();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function handleProgressEvent(evt) {
|
|
78
|
+
const t = String((evt && evt.type) || '');
|
|
79
|
+
if (!t) return;
|
|
80
|
+
markLiveProgressSeen(sessionId);
|
|
81
|
+
if (t === 'tool_start') {
|
|
82
|
+
// ── Split streaming bubble at tool boundary ──────────────────────
|
|
83
|
+
// If the agent was still speaking, finalize that speech segment so
|
|
84
|
+
// the next text_delta creates a fresh bubble (instead of appending
|
|
85
|
+
// all rounds into one bubble).
|
|
86
|
+
if (typeof splitStreamBubbleAtToolStart === 'function') {
|
|
87
|
+
splitStreamBubbleAtToolStart();
|
|
88
|
+
}
|
|
89
|
+
// ── Create / update live tool block ──────────────────────────────
|
|
90
|
+
const row = ensureLiveToolBlock(evt);
|
|
91
|
+
if (!row) return;
|
|
92
|
+
const args = String((evt && evt.arguments) || '');
|
|
93
|
+
if (args) row.pre.textContent = '参数:\n' + args + '\n';
|
|
94
|
+
scrollLog();
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (t === 'tool_output') { appendLiveToolOutput(evt); return; }
|
|
98
|
+
if (t === 'tool_end') {
|
|
99
|
+
const row = ensureLiveToolBlock(evt);
|
|
100
|
+
if (!row) return;
|
|
101
|
+
const tool = String((evt && evt.tool) || 'tool');
|
|
102
|
+
if (typeof updateTimelineToolRowElement === 'function') {
|
|
103
|
+
updateTimelineToolRowElement(row.wrap, {
|
|
104
|
+
tool: tool,
|
|
105
|
+
arguments: String((evt && evt.arguments) || ''),
|
|
106
|
+
result: String((evt && evt.result) || ''),
|
|
107
|
+
}, 0, 1);
|
|
108
|
+
}
|
|
109
|
+
liveToolBlocks.delete(String((evt && evt.event_id) || ''));
|
|
110
|
+
// Auto-refresh todo panel when todo finishes
|
|
111
|
+
if (tool === 'todo' && typeof refreshTodos === 'function' && typeof todoIsVisible === 'function' && todoIsVisible()) {
|
|
112
|
+
refreshTodos();
|
|
113
|
+
}
|
|
114
|
+
scrollLog();
|
|
115
|
+
}
|
|
116
|
+
}
|