@bastani/atomic 0.9.40-alpha.1 → 0.9.40
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/CHANGELOG.md +37 -0
- package/dist/builtin/intercom/CHANGELOG.md +14 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +31 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/web-access/CHANGELOG.md +12 -0
- package/dist/builtin/web-access/README.md +1 -1
- package/dist/builtin/web-access/index.bundle.mjs +2 -5
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +25 -0
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +11 -2
- package/dist/cli/args.js +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +3 -2
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/template.html +1 -0
- package/dist/core/export-html/template.js +37 -20
- package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
- package/dist/core/export-html/vendor/marked.min.js +76 -3
- package/docs/providers.md +1 -1
- package/docs/settings.md +1 -1
- package/npm-shrinkwrap.json +35 -35
- package/package.json +5 -5
- package/dist/core/export-html/template-js/data-tree.js +0 -287
- package/dist/core/export-html/template-js/entries-navigation.js +0 -434
- package/dist/core/export-html/template-js/initialization.js +0 -335
- package/dist/core/export-html/template-js/message-tools.js +0 -428
- package/dist/core/export-html/template-js/tree-filter-render.js +0 -419
- package/dist/core/export-html/template-script.d.ts +0 -3
- package/dist/core/export-html/template-script.d.ts.map +0 -1
- package/dist/core/export-html/template-script.js +0 -13
- package/dist/core/export-html/template-script.js.map +0 -1
|
@@ -1,434 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copy text to clipboard with visual feedback.
|
|
3
|
-
* Uses navigator.clipboard with fallback to execCommand for HTTP contexts.
|
|
4
|
-
*/
|
|
5
|
-
async function copyToClipboard(text, button) {
|
|
6
|
-
let success = false;
|
|
7
|
-
try {
|
|
8
|
-
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
9
|
-
await navigator.clipboard.writeText(text);
|
|
10
|
-
success = true;
|
|
11
|
-
}
|
|
12
|
-
} catch (err) {
|
|
13
|
-
// Clipboard API failed, try fallback
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Fallback for HTTP or when Clipboard API is unavailable
|
|
17
|
-
if (!success) {
|
|
18
|
-
try {
|
|
19
|
-
const textarea = document.createElement('textarea');
|
|
20
|
-
textarea.value = text;
|
|
21
|
-
textarea.style.position = 'fixed';
|
|
22
|
-
textarea.style.opacity = '0';
|
|
23
|
-
document.body.appendChild(textarea);
|
|
24
|
-
textarea.select();
|
|
25
|
-
success = document.execCommand('copy');
|
|
26
|
-
document.body.removeChild(textarea);
|
|
27
|
-
} catch (err) {
|
|
28
|
-
console.error('Failed to copy:', err);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (success && button) {
|
|
33
|
-
const originalHtml = button.innerHTML;
|
|
34
|
-
button.innerHTML = '✓';
|
|
35
|
-
button.classList.add('copied');
|
|
36
|
-
setTimeout(() => {
|
|
37
|
-
button.innerHTML = originalHtml;
|
|
38
|
-
button.classList.remove('copied');
|
|
39
|
-
}, 1500);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Render the copy-link button HTML for a message.
|
|
45
|
-
*/
|
|
46
|
-
function renderCopyLinkButton(entryId) {
|
|
47
|
-
return `<button class="copy-link-btn" data-entry-id="${escapeHtml(entryId)}" title="Copy link to this message">
|
|
48
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
49
|
-
<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/>
|
|
50
|
-
<path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>
|
|
51
|
-
</svg>
|
|
52
|
-
</button>`;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function renderEntry(entry) {
|
|
56
|
-
const ts = formatTimestamp(entry.timestamp);
|
|
57
|
-
const tsHtml = ts ? `<div class="message-timestamp">${ts}</div>` : '';
|
|
58
|
-
const entryDomId = `entry-${escapeHtml(entry.id)}`;
|
|
59
|
-
const copyBtnHtml = renderCopyLinkButton(entry.id);
|
|
60
|
-
|
|
61
|
-
if (entry.type === 'message') {
|
|
62
|
-
const msg = entry.message;
|
|
63
|
-
|
|
64
|
-
if (msg.role === 'user') {
|
|
65
|
-
const content = msg.content;
|
|
66
|
-
const text = typeof content === 'string' ? content :
|
|
67
|
-
content.filter(c => c.type === 'text').map(c => c.text).join('\n');
|
|
68
|
-
const skillBlock = parseSkillBlock(text);
|
|
69
|
-
|
|
70
|
-
if (skillBlock) {
|
|
71
|
-
// Collect images from content array
|
|
72
|
-
const images = Array.isArray(content) ? content.filter(c => c.type === 'image') : [];
|
|
73
|
-
const hasUserContent = skillBlock.userMessage || images.length > 0;
|
|
74
|
-
let html = `<div class="skill-user-entry" id="${entryDomId}">${copyBtnHtml}${tsHtml}`;
|
|
75
|
-
|
|
76
|
-
// Skill invocation (collapsed by default, click to expand)
|
|
77
|
-
html += `<div class="skill-invocation" onclick="if(window.getSelection().toString())return;this.classList.toggle('expanded')">
|
|
78
|
-
<div class="skill-invocation-label">[skill] ${escapeHtml(skillBlock.name)}</div>
|
|
79
|
-
<div class="skill-invocation-collapsed">${escapeHtml(skillBlock.name)} (click to expand)</div>
|
|
80
|
-
<div class="skill-invocation-content markdown-content">${safeMarkedParse(skillBlock.content)}</div>
|
|
81
|
-
</div>`;
|
|
82
|
-
|
|
83
|
-
// User message (separate block if present)
|
|
84
|
-
if (hasUserContent) {
|
|
85
|
-
html += '<div class="user-message">';
|
|
86
|
-
if (images.length > 0) {
|
|
87
|
-
html += '<div class="message-images">';
|
|
88
|
-
for (const img of images) {
|
|
89
|
-
html += `<img src="data:${escapeHtml(img.mimeType || 'image/png')};base64,${escapeHtml(img.data || '')}" class="message-image" />`;
|
|
90
|
-
}
|
|
91
|
-
html += '</div>';
|
|
92
|
-
}
|
|
93
|
-
if (skillBlock.userMessage) {
|
|
94
|
-
html += `<div class="markdown-content">${safeMarkedParse(skillBlock.userMessage)}</div>`;
|
|
95
|
-
}
|
|
96
|
-
html += '</div>';
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
html += '</div>';
|
|
100
|
-
return html;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// No skill block - normal user message
|
|
104
|
-
let html = `<div class="user-message" id="${entryDomId}">${copyBtnHtml}${tsHtml}`;
|
|
105
|
-
|
|
106
|
-
if (Array.isArray(content)) {
|
|
107
|
-
const images = content.filter(c => c.type === 'image');
|
|
108
|
-
if (images.length > 0) {
|
|
109
|
-
html += '<div class="message-images">';
|
|
110
|
-
for (const img of images) {
|
|
111
|
-
html += `<img src="data:${escapeHtml(img.mimeType || 'image/png')};base64,${escapeHtml(img.data || '')}" class="message-image" />`;
|
|
112
|
-
}
|
|
113
|
-
html += '</div>';
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (text.trim()) {
|
|
118
|
-
html += `<div class="markdown-content">${safeMarkedParse(text)}</div>`;
|
|
119
|
-
}
|
|
120
|
-
html += '</div>';
|
|
121
|
-
return html;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (msg.role === 'assistant') {
|
|
125
|
-
let html = `<div class="assistant-message" id="${entryDomId}">${copyBtnHtml}${tsHtml}`;
|
|
126
|
-
|
|
127
|
-
for (const block of msg.content) {
|
|
128
|
-
if (block.type === 'text' && block.text.trim()) {
|
|
129
|
-
html += `<div class="assistant-text markdown-content">${safeMarkedParse(block.text)}</div>`;
|
|
130
|
-
} else if (block.type === 'thinking' && block.thinking.trim()) {
|
|
131
|
-
html += `<div class="thinking-block">
|
|
132
|
-
<div class="thinking-text">${escapeHtml(block.thinking)}</div>
|
|
133
|
-
<div class="thinking-collapsed">Thinking ...</div>
|
|
134
|
-
</div>`;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
for (const block of msg.content) {
|
|
139
|
-
if (block.type === 'toolCall') {
|
|
140
|
-
html += renderToolCall(block);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (msg.stopReason === 'aborted') {
|
|
145
|
-
html += '<div class="error-text">Aborted</div>';
|
|
146
|
-
} else if (msg.stopReason === 'error') {
|
|
147
|
-
html += `<div class="error-text">Error: ${escapeHtml(msg.errorMessage || 'Unknown error')}</div>`;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
html += '</div>';
|
|
151
|
-
return html;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (msg.role === 'bashExecution') {
|
|
155
|
-
const isError = msg.cancelled || (msg.exitCode !== 0 && msg.exitCode !== null);
|
|
156
|
-
let html = `<div class="tool-execution ${isError ? 'error' : 'success'}" id="${entryDomId}">${tsHtml}`;
|
|
157
|
-
html += `<div class="tool-command">$ ${escapeHtml(msg.command)}</div>`;
|
|
158
|
-
if (msg.output) html += formatExpandableOutput(msg.output, 10);
|
|
159
|
-
if (msg.cancelled) {
|
|
160
|
-
html += '<div style="color: var(--warning)">(cancelled)</div>';
|
|
161
|
-
} else if (msg.exitCode !== 0 && msg.exitCode !== null) {
|
|
162
|
-
html += `<div style="color: var(--error)">(exit ${msg.exitCode})</div>`;
|
|
163
|
-
}
|
|
164
|
-
html += '</div>';
|
|
165
|
-
return html;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (msg.role === 'toolResult') return '';
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (entry.type === 'model_change') {
|
|
172
|
-
return `<div class="model-change" id="${entryDomId}">${tsHtml}Switched to model: <span class="model-name">${escapeHtml(entry.provider)}/${escapeHtml(entry.modelId)}</span></div>`;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (entry.type === 'context_window_change') {
|
|
176
|
-
return `<div class="model-change" id="${entryDomId}">${tsHtml}Context window: <span class="model-name">${escapeHtml(String(entry.contextWindow))}</span></div>`;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (entry.type === 'compaction') {
|
|
180
|
-
return `<div class="compaction" id="${entryDomId}" onclick="if(window.getSelection().toString())return;this.classList.toggle('expanded')">
|
|
181
|
-
<div class="compaction-label">[compaction]</div>
|
|
182
|
-
<div class="compaction-collapsed">Compacted from ${entry.tokensBefore.toLocaleString()} tokens</div>
|
|
183
|
-
<div class="compaction-content"><strong>Compacted from ${entry.tokensBefore.toLocaleString()} tokens</strong>\n\n${escapeHtml(entry.summary)}</div>
|
|
184
|
-
</div>`;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (entry.type === 'branch_summary') {
|
|
188
|
-
return `<div class="branch-summary" id="${entryDomId}">${tsHtml}
|
|
189
|
-
<div class="branch-summary-header">Branch Summary</div>
|
|
190
|
-
<div class="markdown-content">${safeMarkedParse(entry.summary)}</div>
|
|
191
|
-
</div>`;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (entry.type === 'custom_message') {
|
|
195
|
-
const hidden = entry.display === false;
|
|
196
|
-
return `<div class="hook-message${hidden ? ' hook-message-hidden' : ''}" id="${entryDomId}">${tsHtml}
|
|
197
|
-
<div class="hook-type">[${escapeHtml(entry.customType)}]${hidden ? ' · Hidden in terminal' : ''}</div>
|
|
198
|
-
<div class="markdown-content">${safeMarkedParse(typeof entry.content === 'string' ? entry.content : JSON.stringify(entry.content))}</div>
|
|
199
|
-
</div>`;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return '';
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// ============================================================
|
|
206
|
-
// HEADER / STATS
|
|
207
|
-
// ============================================================
|
|
208
|
-
|
|
209
|
-
function computeStats(entryList) {
|
|
210
|
-
let userMessages = 0, assistantMessages = 0, toolResults = 0;
|
|
211
|
-
let customMessages = 0, compactions = 0, branchSummaries = 0, toolCalls = 0;
|
|
212
|
-
const tokens = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
|
213
|
-
const cost = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
|
214
|
-
const models = new Set();
|
|
215
|
-
|
|
216
|
-
for (const entry of entryList) {
|
|
217
|
-
if (entry.type === 'message') {
|
|
218
|
-
const msg = entry.message;
|
|
219
|
-
if (msg.role === 'user') userMessages++;
|
|
220
|
-
if (msg.role === 'assistant') {
|
|
221
|
-
assistantMessages++;
|
|
222
|
-
if (msg.model) models.add(msg.provider ? `${msg.provider}/${msg.model}` : msg.model);
|
|
223
|
-
if (msg.usage) {
|
|
224
|
-
tokens.input += msg.usage.input || 0;
|
|
225
|
-
tokens.output += msg.usage.output || 0;
|
|
226
|
-
tokens.cacheRead += msg.usage.cacheRead || 0;
|
|
227
|
-
tokens.cacheWrite += msg.usage.cacheWrite || 0;
|
|
228
|
-
if (msg.usage.cost) {
|
|
229
|
-
cost.input += msg.usage.cost.input || 0;
|
|
230
|
-
cost.output += msg.usage.cost.output || 0;
|
|
231
|
-
cost.cacheRead += msg.usage.cost.cacheRead || 0;
|
|
232
|
-
cost.cacheWrite += msg.usage.cost.cacheWrite || 0;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
toolCalls += msg.content.filter(c => c.type === 'toolCall').length;
|
|
236
|
-
}
|
|
237
|
-
if (msg.role === 'toolResult') toolResults++;
|
|
238
|
-
} else if (entry.type === 'compaction') {
|
|
239
|
-
compactions++;
|
|
240
|
-
} else if (entry.type === 'branch_summary') {
|
|
241
|
-
branchSummaries++;
|
|
242
|
-
} else if (entry.type === 'custom_message') {
|
|
243
|
-
customMessages++;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return { userMessages, assistantMessages, toolResults, customMessages, compactions, branchSummaries, toolCalls, tokens, cost, models: Array.from(models) };
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
const globalStats = computeStats(entries);
|
|
251
|
-
|
|
252
|
-
function renderHeader() {
|
|
253
|
-
const totalCost = globalStats.cost.input + globalStats.cost.output + globalStats.cost.cacheRead + globalStats.cost.cacheWrite;
|
|
254
|
-
|
|
255
|
-
const tokenParts = [];
|
|
256
|
-
if (globalStats.tokens.input) tokenParts.push(`↑${formatTokens(globalStats.tokens.input)}`);
|
|
257
|
-
if (globalStats.tokens.output) tokenParts.push(`↓${formatTokens(globalStats.tokens.output)}`);
|
|
258
|
-
if (globalStats.tokens.cacheRead) tokenParts.push(`R${formatTokens(globalStats.tokens.cacheRead)}`);
|
|
259
|
-
if (globalStats.tokens.cacheWrite) tokenParts.push(`W${formatTokens(globalStats.tokens.cacheWrite)}`);
|
|
260
|
-
|
|
261
|
-
const msgParts = [];
|
|
262
|
-
if (globalStats.userMessages) msgParts.push(`${globalStats.userMessages} user`);
|
|
263
|
-
if (globalStats.assistantMessages) msgParts.push(`${globalStats.assistantMessages} assistant`);
|
|
264
|
-
if (globalStats.toolResults) msgParts.push(`${globalStats.toolResults} tool results`);
|
|
265
|
-
if (globalStats.customMessages) msgParts.push(`${globalStats.customMessages} custom`);
|
|
266
|
-
if (globalStats.compactions) msgParts.push(`${globalStats.compactions} compactions`);
|
|
267
|
-
if (globalStats.branchSummaries) msgParts.push(`${globalStats.branchSummaries} branch summaries`);
|
|
268
|
-
|
|
269
|
-
let html = `
|
|
270
|
-
<div class="header">
|
|
271
|
-
<h1>Session: ${escapeHtml(header?.id || 'unknown')}</h1>
|
|
272
|
-
<div class="help-bar">
|
|
273
|
-
<span class="help-hint">T toggle thinking · O toggle tools · H toggle hidden messages</span>
|
|
274
|
-
<div class="help-actions">
|
|
275
|
-
<button type="button" class="header-toggle-btn" data-action="toggle-thinking" aria-pressed="${thinkingExpanded}" title="Toggle thinking (T)">Toggle thinking</button>
|
|
276
|
-
<button type="button" class="header-toggle-btn" data-action="toggle-tools" aria-pressed="${toolOutputsExpanded}" title="Toggle tools (O)">Toggle tools</button>
|
|
277
|
-
<button type="button" class="header-toggle-btn" data-action="toggle-hidden-messages" aria-pressed="${showHiddenMessages}" title="Show custom messages marked as hidden in the terminal (H).">${showHiddenMessages ? 'Hide hidden messages' : 'Show hidden messages'}</button>
|
|
278
|
-
<button type="button" class="download-json-btn" onclick="downloadSessionJson()" title="Download session as JSONL">↓ JSONL</button>
|
|
279
|
-
</div>
|
|
280
|
-
</div>
|
|
281
|
-
<div class="header-info">
|
|
282
|
-
<div class="info-item"><span class="info-label">Date:</span><span class="info-value">${header?.createdAt ? new Date(header.createdAt).toLocaleString() : 'unknown'}</span></div>
|
|
283
|
-
<div class="info-item"><span class="info-label">Models:</span><span class="info-value">${escapeHtml(globalStats.models.join(', ') || 'unknown')}</span></div>
|
|
284
|
-
<div class="info-item"><span class="info-label">Messages:</span><span class="info-value">${msgParts.join(', ') || '0'}</span></div>
|
|
285
|
-
<div class="info-item"><span class="info-label">Tool Calls:</span><span class="info-value">${globalStats.toolCalls}</span></div>
|
|
286
|
-
<div class="info-item"><span class="info-label">Tokens:</span><span class="info-value">${tokenParts.join(' ') || '0'}</span></div>
|
|
287
|
-
<div class="info-item"><span class="info-label">Cost:</span><span class="info-value">$${totalCost.toFixed(3)}</span></div>
|
|
288
|
-
</div>
|
|
289
|
-
</div>`;
|
|
290
|
-
|
|
291
|
-
// Render system prompt (user's base prompt, applies to all providers)
|
|
292
|
-
if (systemPrompt) {
|
|
293
|
-
const lines = systemPrompt.split('\n');
|
|
294
|
-
const previewLines = 10;
|
|
295
|
-
if (lines.length > previewLines) {
|
|
296
|
-
const preview = lines.slice(0, previewLines).join('\n');
|
|
297
|
-
const remaining = lines.length - previewLines;
|
|
298
|
-
html += `<div class="system-prompt expandable" onclick="if(window.getSelection().toString())return;this.classList.toggle('expanded')">
|
|
299
|
-
<div class="system-prompt-header">System Prompt</div>
|
|
300
|
-
<div class="system-prompt-preview">${escapeHtml(preview)}</div>
|
|
301
|
-
<div class="system-prompt-expand-hint">... (${remaining} more lines, click to expand)</div>
|
|
302
|
-
<div class="system-prompt-full">${escapeHtml(systemPrompt)}</div>
|
|
303
|
-
</div>`;
|
|
304
|
-
} else {
|
|
305
|
-
html += `<div class="system-prompt">
|
|
306
|
-
<div class="system-prompt-header">System Prompt</div>
|
|
307
|
-
<div class="system-prompt-full" style="display: block">${escapeHtml(systemPrompt)}</div>
|
|
308
|
-
</div>`;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
if (tools && tools.length > 0) {
|
|
313
|
-
html += `<div class="tools-list">
|
|
314
|
-
<div class="tools-header">Available Tools</div>
|
|
315
|
-
<div class="tools-content">
|
|
316
|
-
${tools.map(t => {
|
|
317
|
-
const hasParams = t.parameters && typeof t.parameters === 'object' && t.parameters.properties && Object.keys(t.parameters.properties).length > 0;
|
|
318
|
-
if (!hasParams) {
|
|
319
|
-
return `<div class="tool-item"><span class="tool-item-name">${escapeHtml(t.name)}</span> - <span class="tool-item-desc">${escapeHtml(t.description)}</span></div>`;
|
|
320
|
-
}
|
|
321
|
-
const params = t.parameters;
|
|
322
|
-
const properties = params.properties;
|
|
323
|
-
const required = params.required || [];
|
|
324
|
-
let paramsHtml = '';
|
|
325
|
-
for (const [name, prop] of Object.entries(properties)) {
|
|
326
|
-
const isRequired = required.includes(name);
|
|
327
|
-
const typeStr = prop.type || 'any';
|
|
328
|
-
const reqLabel = isRequired ? '<span class="tool-param-required">required</span>' : '<span class="tool-param-optional">optional</span>';
|
|
329
|
-
paramsHtml += `<div class="tool-param"><span class="tool-param-name">${escapeHtml(name)}</span> <span class="tool-param-type">${escapeHtml(typeStr)}</span> ${reqLabel}`;
|
|
330
|
-
if (prop.description) {
|
|
331
|
-
paramsHtml += `<div class="tool-param-desc">${escapeHtml(prop.description)}</div>`;
|
|
332
|
-
}
|
|
333
|
-
paramsHtml += `</div>`;
|
|
334
|
-
}
|
|
335
|
-
return `<div class="tool-item" onclick="if(window.getSelection().toString())return;this.classList.toggle('params-expanded')"><span class="tool-item-name">${escapeHtml(t.name)}</span> - <span class="tool-item-desc">${escapeHtml(t.description)}</span> <span class="tool-params-hint"></span><div class="tool-params-content">${paramsHtml}</div></div>`;
|
|
336
|
-
}).join('')}
|
|
337
|
-
</div>
|
|
338
|
-
</div>`;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
return html;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
// ============================================================
|
|
345
|
-
// NAVIGATION
|
|
346
|
-
// ============================================================
|
|
347
|
-
|
|
348
|
-
// Cache for rendered entry DOM nodes
|
|
349
|
-
const entryCache = new Map();
|
|
350
|
-
|
|
351
|
-
function renderEntryToNode(entry) {
|
|
352
|
-
// Check cache first
|
|
353
|
-
if (entryCache.has(entry.id)) {
|
|
354
|
-
return entryCache.get(entry.id).cloneNode(true);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
// Render to HTML string, then parse to node
|
|
358
|
-
const html = renderEntry(entry);
|
|
359
|
-
if (!html) return null;
|
|
360
|
-
|
|
361
|
-
const template = document.createElement('template');
|
|
362
|
-
template.innerHTML = html;
|
|
363
|
-
const node = template.content.firstElementChild;
|
|
364
|
-
|
|
365
|
-
// Cache the node
|
|
366
|
-
if (node) {
|
|
367
|
-
entryCache.set(entry.id, node.cloneNode(true));
|
|
368
|
-
}
|
|
369
|
-
return node;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
function navigateTo(targetId, scrollMode = 'target', scrollToEntryId = null) {
|
|
373
|
-
currentLeafId = targetId;
|
|
374
|
-
currentTargetId = scrollToEntryId || targetId;
|
|
375
|
-
const targetEntry = byId.get(currentTargetId);
|
|
376
|
-
if (scrollMode === 'target' && targetEntry?.type === 'custom_message' && targetEntry.display === false) {
|
|
377
|
-
setHiddenMessagesVisible(true);
|
|
378
|
-
}
|
|
379
|
-
const path = getPath(targetId);
|
|
380
|
-
|
|
381
|
-
renderTree();
|
|
382
|
-
|
|
383
|
-
document.getElementById('header-container').innerHTML = renderHeader();
|
|
384
|
-
attachHeaderHandlers();
|
|
385
|
-
|
|
386
|
-
// Build messages using cached DOM nodes
|
|
387
|
-
const messagesEl = document.getElementById('messages');
|
|
388
|
-
const fragment = document.createDocumentFragment();
|
|
389
|
-
|
|
390
|
-
for (const entry of path) {
|
|
391
|
-
const node = renderEntryToNode(entry);
|
|
392
|
-
if (node) {
|
|
393
|
-
fragment.appendChild(node);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
messagesEl.innerHTML = '';
|
|
398
|
-
messagesEl.appendChild(fragment);
|
|
399
|
-
|
|
400
|
-
// Cached nodes contain their initial presentation; reapply the viewer's toggle states.
|
|
401
|
-
setThinkingExpanded(thinkingExpanded);
|
|
402
|
-
setToolOutputsExpanded(toolOutputsExpanded);
|
|
403
|
-
|
|
404
|
-
// Attach click handlers for copy-link buttons
|
|
405
|
-
messagesEl.querySelectorAll('.copy-link-btn').forEach(btn => {
|
|
406
|
-
btn.addEventListener('click', (e) => {
|
|
407
|
-
e.stopPropagation();
|
|
408
|
-
const entryId = btn.dataset.entryId;
|
|
409
|
-
const shareUrl = buildShareUrl(entryId);
|
|
410
|
-
copyToClipboard(shareUrl, btn);
|
|
411
|
-
});
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
// Use setTimeout(0) to ensure DOM is fully laid out before scrolling
|
|
415
|
-
setTimeout(() => {
|
|
416
|
-
const content = document.getElementById('content');
|
|
417
|
-
if (scrollMode === 'bottom') {
|
|
418
|
-
content.scrollTop = content.scrollHeight;
|
|
419
|
-
} else if (scrollMode === 'target') {
|
|
420
|
-
// If scrollToEntryId is provided, scroll to that specific entry
|
|
421
|
-
const scrollTargetId = scrollToEntryId || targetId;
|
|
422
|
-
const targetEl = document.getElementById(`entry-${scrollTargetId}`);
|
|
423
|
-
if (targetEl) {
|
|
424
|
-
targetEl.scrollIntoView({ block: 'center' });
|
|
425
|
-
// Briefly highlight the target message
|
|
426
|
-
if (scrollToEntryId) {
|
|
427
|
-
targetEl.classList.add('highlight');
|
|
428
|
-
setTimeout(() => targetEl.classList.remove('highlight'), 2000);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
}, 0);
|
|
433
|
-
}
|
|
434
|
-
|