import { renderAdminLayout } from './layout'; export function renderLiveLogsPage(): string { const extraStyles = ` .log-row-item { padding: 0.65rem 0.75rem; border-radius: 8px; border: 1px solid var(--border-dark); background: rgba(0, 0, 0, 0.15); cursor: pointer; transition: all 0.15s ease; display: flex; flex-direction: column; gap: 0.3rem; } body.light-theme .log-row-item { background: rgba(0, 0, 0, 0.02); border-color: var(--border-light); } .log-row-item:hover { background: rgba(187, 134, 252, 0.08); border-color: rgba(187, 134, 252, 0.4); } .log-row-item.active { border-color: var(--primary-color); background: rgba(187, 134, 252, 0.15); box-shadow: 0 0 10px rgba(187, 134, 252, 0.2); } .code-box { background: #0d0d0d; color: #f1f1f1; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 8px; padding: 0.75rem; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 0.8rem; overflow-x: auto; white-space: pre-wrap; word-break: break-word; line-height: 1.45; } body.light-theme .code-box { background: #f8f9fa; color: #212529; border-color: #dee2e6; } .chat-bubble { border-radius: 8px; padding: 0.65rem 0.85rem; margin-bottom: 0.6rem; font-size: 0.82rem; line-height: 1.45; } .chat-bubble.user { background: rgba(100, 181, 246, 0.12); border-left: 3px solid var(--accent-info); } .chat-bubble.assistant { background: rgba(3, 218, 198, 0.12); border-left: 3px solid var(--accent-success); } .chat-bubble.system { background: rgba(255, 183, 77, 0.12); border-left: 3px solid var(--accent-warning); } /* Dedicated Inspector Sub-tabs (isolated from page navigation) */ .insp-tabs-bar { display: flex; gap: 0.5rem; border-bottom: 1px solid var(--border-dark); margin-bottom: 0.75rem; overflow-x: auto; } body.light-theme .insp-tabs-bar { border-bottom-color: var(--border-light); } .insp-tab-btn { background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--muted-dark); padding: 0.6rem 1.1rem; font-size: 0.88rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 0.45rem; transition: all 0.2s ease; white-space: nowrap; } body.light-theme .insp-tab-btn { color: var(--muted-light); } .insp-tab-btn:hover { color: var(--text-dark); } body.light-theme .insp-tab-btn:hover { color: var(--text-light); } .insp-tab-btn.active { color: var(--primary-color); border-bottom-color: var(--primary-color); } `; const bodyHtml = `

Live Request Log Watcher

Inspect live incoming + served requests in RAM (input, output, metadata, debug data). Flushes from memory when toggled off.

Watcher:
0 / 250 in RAM (0 KB)
Captured Requests (0) Disconnected

Live Watcher is currently idle. Toggle Watcher ON to begin capturing requests in RAM.

Request Inspector

Select a request from the list to inspect full RAM data

No request selected.

Toggle Watcher ON and select an incoming request from the stream to inspect.

`; const pageScript = ` let currentConfig = { providers: [], customModels: [] }; let isWatcherActive = false; let liveLogs = []; let selectedLog = null; let activeInspectorTab = 'insp-input'; let autoScroll = true; let liveLogsEventSource = null; let liveSearchQuery = ''; let liveStatusFilter = 'all'; let liveModelFilter = 'all'; async function initPage() { try { const cfgRes = await apiRequest('/api/admin/config'); if (cfgRes.ok) { currentConfig = await cfgRes.json(); } } catch (err) {} await updateWatcherStatus(); connectLiveLogsSSE(); updateModelFilterOptions(); } async function updateWatcherStatus() { try { const res = await apiRequest('/api/admin/live-logs/state'); if (!res.ok) return; const data = await res.json(); isWatcherActive = !!data.active; const navBadge = document.getElementById('nav-live-badge'); if (navBadge) { navBadge.textContent = isWatcherActive ? 'LIVE' : 'OFF'; navBadge.style.background = isWatcherActive ? 'var(--accent-success)' : 'rgba(255,255,255,0.1)'; navBadge.style.color = isWatcherActive ? '#000' : 'inherit'; } const ramText = document.getElementById('ram-count-text'); if (ramText) { ramText.textContent = data.bufferCount + ' / ' + data.maxCapacity + ' in RAM (' + data.memoryEstimateKb + ' KB)'; } const toggleBtn = document.getElementById('watcher-toggle-btn'); if (toggleBtn) { if (isWatcherActive) { toggleBtn.className = 'nav-btn danger'; toggleBtn.innerHTML = ' Stop Watching'; } else { toggleBtn.className = 'nav-btn primary'; toggleBtn.innerHTML = ' Start Watching'; } } if (isWatcherActive && liveLogs.length === 0) { const entriesRes = await apiRequest('/api/admin/live-logs/entries?limit=100'); if (entriesRes.ok) { const entData = await entriesRes.json(); liveLogs = entData.entries || []; if (selectedLog) { const refreshed = liveLogs.find(l => l.id === selectedLog.id); if (refreshed) selectedLog = refreshed; } renderLiveLogsList(); renderInspector(); updateModelFilterOptions(); } } } catch (err) { console.error('Failed to update watcher status:', err); } } async function toggleWatcher() { const targetState = !isWatcherActive; try { const res = await apiRequest('/api/admin/live-logs/toggle', { method: 'POST', body: { enabled: targetState } }); if (!res.ok) throw new Error('Failed to toggle watcher'); const data = await res.json(); isWatcherActive = !!data.active; if (!isWatcherActive) { liveLogs = []; selectedLog = null; renderLiveLogsList(); renderInspector(); showToast('Live Watcher stopped. All request logs flushed from RAM.', 'info'); } else { showToast('Live Watcher started! Now capturing requests in RAM.', 'success'); } await updateWatcherStatus(); } catch (err) { showToast('Error toggling watcher: ' + err.message, 'error'); } } async function flushWatcher() { try { const res = await apiRequest('/api/admin/live-logs/flush', { method: 'POST' }); if (!res.ok) throw new Error('Failed to flush watcher logs'); liveLogs = []; selectedLog = null; renderLiveLogsList(); renderInspector(); await updateWatcherStatus(); showToast('RAM request logs purged successfully.', 'info'); } catch (err) { showToast('Error flushing watcher: ' + err.message, 'error'); } } function connectLiveLogsSSE() { if (liveLogsEventSource) return; try { liveLogsEventSource = new EventSource('/api/admin/live-logs/stream?api_key=' + encodeURIComponent(activeKey)); liveLogsEventSource.onopen = function() { const statusElem = document.getElementById('live-connection-status'); if (statusElem) { statusElem.className = 'badge badge-success'; statusElem.innerHTML = ' Connected'; } }; liveLogsEventSource.onmessage = function(e) { try { const msg = JSON.parse(e.data); handleLiveLogSSEMessage(msg); } catch (err) { console.error('Failed to parse live log SSE:', err); } }; liveLogsEventSource.onerror = function() { const statusElem = document.getElementById('live-connection-status'); if (statusElem) { statusElem.className = 'badge badge-warning'; statusElem.innerHTML = ' Reconnecting...'; } }; } catch (err) { console.error('Live logs SSE error:', err); } } function handleLiveLogSSEMessage(msg) { if (msg.type === 'snapshot') { if (msg.state) { isWatcherActive = msg.state.active; } if (Array.isArray(msg.entries)) { liveLogs = msg.entries; if (selectedLog) { const refreshed = liveLogs.find(l => l.id === selectedLog.id); if (refreshed) { selectedLog = refreshed; renderInspector(); } } renderLiveLogsList(); updateModelFilterOptions(); } updateWatcherStatus(); } else if (msg.type === 'watcher_status') { isWatcherActive = msg.data.active; updateWatcherStatus(); } else if (msg.type === 'watcher_flushed') { liveLogs = []; selectedLog = null; renderLiveLogsList(); renderInspector(); updateWatcherStatus(); } else if (msg.type === 'request_started') { liveLogs.unshift(msg.data); if (liveLogs.length > 250) liveLogs.length = 250; renderLiveLogsList(); updateModelFilterOptions(); updateWatcherStatus(); } else if (msg.type === 'stream_chunk') { const item = liveLogs.find(l => l.id === msg.requestId); if (item) { item.output.completionText = (item.output.completionText || '') + msg.chunkText; item.durationMs = msg.durationMs || item.durationMs; if (selectedLog && selectedLog.id === msg.requestId) { selectedLog = item; const outText = document.getElementById('insp-output-text'); if (outText) { outText.textContent = item.output.completionText; } else { renderInspectorOutputPane(selectedLog); } } } } else if (msg.type === 'candidate_step') { const item = liveLogs.find(l => l.id === msg.requestId); if (item) { item.debug.stepTraces.push(msg.data); item.metadata.totalCandidatesAttempted = item.debug.stepTraces.length; if (item.debug.stepTraces.length > 1) item.metadata.fallbackOccurred = true; if (selectedLog && selectedLog.id === msg.requestId) { selectedLog = item; renderInspectorMetadataPane(item); renderInspectorDebugPane(item); } } } else if (msg.type === 'request_completed' || msg.type === 'request_failed' || msg.type === 'request_cancelled') { const updated = msg.data; const idx = liveLogs.findIndex(l => l.id === updated.id); if (idx !== -1) { liveLogs[idx] = updated; } else { liveLogs.unshift(updated); } renderLiveLogsList(); if (selectedLog && selectedLog.id === updated.id) { selectedLog = updated; renderInspector(); } updateWatcherStatus(); } } function updateModelFilterOptions() { const select = document.getElementById('live-model-filter'); if (!select) return; const currentVal = select.value; const models = new Set(); liveLogs.forEach(l => { if (l.input && (l.input.requestedModel || l.input.model)) { models.add(l.input.requestedModel || l.input.model); } }); if (currentConfig && Array.isArray(currentConfig.customModels)) { currentConfig.customModels.forEach(m => models.add(m.name)); } let opts = ''; models.forEach(m => { opts += ''; }); select.innerHTML = opts; select.value = currentVal || 'all'; } function renderLiveLogsList() { const container = document.getElementById('live-requests-list'); const countElem = document.getElementById('live-displayed-count'); if (!container) return; const prevScrollTop = container.scrollTop; let filtered = [...liveLogs]; if (liveStatusFilter !== 'all') { filtered = filtered.filter(l => l.status === liveStatusFilter); } if (liveModelFilter !== 'all') { filtered = filtered.filter(l => { const reqM = (l.input && (l.input.requestedModel || l.input.model)) || ''; return reqM.toLowerCase() === liveModelFilter.toLowerCase(); }); } if (liveSearchQuery.trim() !== '') { const q = liveSearchQuery.toLowerCase().trim(); filtered = filtered.filter(l => { if (l.id.toLowerCase().includes(q)) return true; const reqM = (l.input && (l.input.requestedModel || l.input.model)) || ''; if (reqM.toLowerCase().includes(q)) return true; if ((l.output && l.output.completionText || '').toLowerCase().includes(q)) return true; if (Array.isArray(l.input?.messages)) { for (const m of l.input.messages) { const str = typeof m.content === 'string' ? m.content : JSON.stringify(m.content || ''); if (str.toLowerCase().includes(q)) return true; } } return false; }); } if (countElem) countElem.textContent = filtered.length; container.innerHTML = ''; if (filtered.length === 0) { container.innerHTML = '

' + (liveLogs.length === 0 ? 'No requests captured yet. Toggle Watcher ON and send API requests.' : 'No requests match the current search/filter criteria.') + '

'; return; } filtered.forEach(item => { const row = document.createElement('div'); row.className = 'log-row-item' + (selectedLog && selectedLog.id === item.id ? ' active' : ''); let statusBadge = ''; if (item.status === 'streaming') { statusBadge = ' Stream'; } else if (item.status === 'completed') { statusBadge = ' ' + (item.statusCode || 200) + ''; } else if (item.status === 'fallback_completed') { statusBadge = ' Fallback'; } else if (item.status === 'failed') { statusBadge = ' ' + (item.statusCode || 500) + ''; } else { statusBadge = ' Cancel'; } const modelName = item.input.requestedModel || item.input.model || 'unknown-model'; const tokCount = item.output?.tokens?.totalTokens ? item.output.tokens.totalTokens + ' tok' : ''; row.innerHTML = '
' + '' + escapeHtml(item.id.slice(0, 16)) + '...' + statusBadge + '
' + '
' + '' + escapeHtml(modelName) + '' + '' + item.durationMs + ' ms' + '
' + '
' + '' + new Date(item.timestamp).toLocaleTimeString() + '' + '' + tokCount + '' + '
'; row.addEventListener('click', () => { selectedLog = item; document.querySelectorAll('.log-row-item').forEach(r => r.classList.remove('active')); row.classList.add('active'); renderInspector(); }); container.appendChild(row); }); if (autoScroll && !selectedLog) { container.scrollTop = 0; } else { container.scrollTop = prevScrollTop; } } function renderInspector() { const emptyState = document.getElementById('inspector-empty-state'); const tabs = document.getElementById('inspector-tabs'); const actions = document.getElementById('inspector-actions'); const title = document.getElementById('inspector-title'); const subtitle = document.getElementById('inspector-subtitle'); const badge = document.getElementById('inspector-status-badge'); if (!selectedLog) { if (emptyState) emptyState.style.display = 'block'; if (tabs) tabs.style.display = 'none'; if (actions) actions.style.display = 'none'; if (title) title.textContent = 'Request Inspector'; if (subtitle) subtitle.textContent = 'Select a request from the list to inspect full RAM data'; if (badge) badge.innerHTML = ''; document.querySelectorAll('.insp-pane').forEach(p => p.style.display = 'none'); return; } if (emptyState) emptyState.style.display = 'none'; if (tabs) tabs.style.display = 'flex'; if (actions) actions.style.display = 'flex'; if (title) title.textContent = selectedLog.method + ' ' + selectedLog.path; if (subtitle) subtitle.textContent = selectedLog.id + ' • ' + new Date(selectedLog.timestamp).toLocaleString() + ' • ' + selectedLog.durationMs + ' ms'; let statusBadge = ''; if (selectedLog.status === 'streaming') { statusBadge = ' Streaming'; } else if (selectedLog.status === 'completed') { statusBadge = ' 200 OK'; } else if (selectedLog.status === 'fallback_completed') { statusBadge = ' Fallback Served'; } else if (selectedLog.status === 'failed') { statusBadge = ' Error ' + (selectedLog.statusCode || 500) + ''; } else { statusBadge = ' Cancelled'; } if (badge) badge.innerHTML = statusBadge; renderInspectorInputPane(selectedLog); renderInspectorOutputPane(selectedLog); renderInspectorMetadataPane(selectedLog); renderInspectorDebugPane(selectedLog); // Activate currently selected inspector sub-tab document.querySelectorAll('.insp-tab-btn').forEach(b => { b.classList.toggle('active', b.getAttribute('data-insp-tab') === activeInspectorTab); }); document.querySelectorAll('.insp-pane').forEach(p => p.style.display = 'none'); const activePane = document.getElementById(activeInspectorTab); if (activePane) activePane.style.display = 'block'; } function renderInspectorInputPane(item) { const pane = document.getElementById('insp-input'); if (!pane) return; let messagesHtml = ''; if (Array.isArray(item.input.messages) && item.input.messages.length > 0) { item.input.messages.forEach((msg, idx) => { const role = (msg.role || 'user').toLowerCase(); const bubbleClass = 'chat-bubble ' + (role === 'assistant' ? 'assistant' : (role === 'system' ? 'system' : 'user')); const roleBadgeClass = role === 'assistant' ? 'badge-success' : (role === 'system' ? 'badge-warning' : 'badge-info'); const content = typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content, null, 2); messagesHtml += '
' + '
' + '' + escapeHtml(role.toUpperCase()) + '' + '#' + (idx + 1) + '' + '
' + '
' + escapeHtml(content) + '
' + '
'; }); } else { messagesHtml = '

No messages array present in request payload.

'; } pane.innerHTML = '
' + '
' + '
Model: ' + escapeHtml(item.input.requestedModel || item.input.model || 'N/A') + '
' + '
Stream: ' + (item.isStreaming ? 'Yes (SSE)' : 'No (JSON)') + '
' + '
Temperature: ' + (item.input.temperature ?? 'default') + '
' + '
Max Tokens: ' + (item.input.maxTokens ?? 'unlimited') + '
' + '
Client IP: ' + escapeHtml(item.clientIp || '127.0.0.1') + '
' + '
' + '
' + '

Prompt Messages (' + (item.input.messages ? item.input.messages.length : 0) + ')

' + '
' + messagesHtml + '
'; } function renderInspectorOutputPane(item) { const pane = document.getElementById('insp-output'); if (!pane) return; let contentHtml = ''; if (item.status === 'failed' || item.output.error) { const errObj = item.output.error || {}; contentHtml = '
' + '
Error Response (' + (item.statusCode || 500) + ')
' + '
' + escapeHtml(errObj.message || JSON.stringify(errObj, null, 2)) + '
' + '
'; } else if (item.output.completionText) { contentHtml = '
' + '
' + ' Assistant Response' + '' + (item.output.finishReason ? 'finish: ' + item.output.finishReason : '') + '' + '
' + '
' + escapeHtml(item.output.completionText) + '
' + '
'; } else { contentHtml = '

' + (item.status === 'streaming' ? 'Streaming response bytes in real time...' : 'No output text returned.') + '

'; } const tok = item.output?.tokens; const tokBar = tok ? '
' + '
Prompt Tokens: ' + tok.promptTokens + '
' + '
Completion Tokens: ' + tok.completionTokens + '
' + '
Total Tokens: ' + tok.totalTokens + '
' + '
' : ''; pane.innerHTML = tokBar + contentHtml; } function renderInspectorMetadataPane(item) { const pane = document.getElementById('insp-metadata'); if (!pane) return; const served = item.metadata.servedBy; const servedStr = served ? 'Tier ' + served.tierIndex + ' (' + escapeHtml(served.tierName) + ') • ' + escapeHtml(served.providerName) + ' (' + escapeHtml(served.providerType) + ') • ' + escapeHtml(served.model) + ' [Key: ' + escapeHtml(served.maskedKey) + ']' : 'N/A'; pane.innerHTML = '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
Request ID' + escapeHtml(item.id) + '
Timestamp' + new Date(item.timestamp).toISOString() + ' (' + new Date(item.timestamp).toLocaleString() + ')
Total Latency' + item.durationMs + ' ms
Status Code' + (item.statusCode || 200) + ' (' + escapeHtml(item.status) + ')
Method / Path' + item.method + ' ' + item.path + '
Streaming Mode' + (item.isStreaming ? 'Yes (SSE transfer)' : 'No (standard JSON)') + '
Client IP Address' + escapeHtml(item.clientIp || '127.0.0.1') + '
Client User-Agent' + escapeHtml(item.userAgent || 'None') + '
Requested Model' + escapeHtml(item.input.requestedModel || item.input.model || 'None') + '
Resolved Custom Model' + escapeHtml(item.metadata.resolvedCustomModelName || item.metadata.resolvedCustomModelId || 'Direct Fallback') + '
Fallback Occurred' + (item.metadata.fallbackOccurred ? 'YES' : 'NO (Direct)') + '
Total Hops Tried' + item.metadata.totalCandidatesAttempted + '
Final Serving Key' + servedStr + '
'; } function renderInspectorDebugPane(item) { const pane = document.getElementById('insp-debug'); if (!pane) return; let stepsHtml = ''; if (Array.isArray(item.debug.stepTraces) && item.debug.stepTraces.length > 0) { stepsHtml += '

Candidate Attempts & Failover Cascade

' + '' + '' + '' + '' + '' + '' + ''; item.debug.stepTraces.forEach(st => { const statusCol = st.status === 'success' ? 'var(--accent-success)' : (st.status === 'rate_limited' ? 'var(--accent-warning)' : 'var(--accent-danger)'); stepsHtml += '' + '' + '' + '' + '' + '' + '' + ''; }); stepsHtml += '
HopTier / ProviderModel / KeyDurationResultNext Action
#' + st.stepIndex + 'Tier ' + st.tierIndex + ' (' + escapeHtml(st.tierName) + ')
' + escapeHtml(st.providerName) + '
' + escapeHtml(st.model) + '
' + escapeHtml(st.maskedKey) + '
' + st.durationMs + ' ms' + (st.statusCode ? st.statusCode + ' ' : '') + escapeHtml(st.status) + '' + (st.errorMessage ? '
' + escapeHtml(st.errorMessage) + '' : '') + '
' + escapeHtml(st.nextAction || '') + '
'; } let eventsHtml = ''; if (Array.isArray(item.debug.events) && item.debug.events.length > 0) { eventsHtml += '

Server Execution Events

' + '
'; item.debug.events.forEach(ev => { const lvlColor = ev.level === 'error' ? 'var(--accent-danger)' : (ev.level === 'warn' ? 'var(--accent-warning)' : 'var(--accent-info)'); eventsHtml += '
' + '[' + new Date(ev.time).toLocaleTimeString() + '] ' + '[' + ev.level.toUpperCase() + '] ' + '' + escapeHtml(ev.message) + '' + '
'; }); eventsHtml += '
'; } const keepaliveSummary = '
' + '
SSE Keep-Alive Pings: ' + (item.debug.keepAlivePingsCount || 0) + '
' + '
Whitespace Keep-Alives: ' + (item.debug.nonStreamingWhitespaceCount || 0) + '
' + '
'; pane.innerHTML = keepaliveSummary + stepsHtml + eventsHtml; } // Inspector Sub-tab navigation (strictly scoped to .insp-tab-btn and .insp-pane) document.querySelectorAll('.insp-tab-btn').forEach(btn => { btn.addEventListener('click', (e) => { e.stopPropagation(); const targetId = btn.getAttribute('data-insp-tab'); if (!targetId) return; activeInspectorTab = targetId; document.querySelectorAll('.insp-tab-btn').forEach(b => b.classList.remove('active')); document.querySelectorAll('.insp-pane').forEach(p => p.style.display = 'none'); btn.classList.add('active'); const targetPane = document.getElementById(targetId); if (targetPane) targetPane.style.display = 'block'; }); }); // Copy / Export Handlers const copyBtn = document.getElementById('copy-log-json-btn'); if (copyBtn) { copyBtn.addEventListener('click', () => { if (!selectedLog) return; navigator.clipboard.writeText(JSON.stringify(selectedLog, null, 2)) .then(() => showToast('Full request inspection copied to clipboard!', 'success')) .catch(() => showToast('Failed to copy to clipboard', 'error')); }); } const exportBtn = document.getElementById('export-log-json-btn'); if (exportBtn) { exportBtn.addEventListener('click', () => { if (!selectedLog) return; const blob = new Blob([JSON.stringify(selectedLog, null, 2)], { type: 'application/json' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'request-' + selectedLog.id + '.json'; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); showToast('Exported request inspection as JSON.', 'success'); }); } const toggleBtn = document.getElementById('watcher-toggle-btn'); if (toggleBtn) { toggleBtn.addEventListener('click', toggleWatcher); } const flushBtn = document.getElementById('flush-watcher-btn'); if (flushBtn) { flushBtn.addEventListener('click', flushWatcher); } const searchInput = document.getElementById('live-search-input'); if (searchInput) { searchInput.addEventListener('input', (e) => { liveSearchQuery = e.target.value; renderLiveLogsList(); }); } const statusFilterSelect = document.getElementById('live-status-filter'); if (statusFilterSelect) { statusFilterSelect.addEventListener('change', (e) => { liveStatusFilter = e.target.value; renderLiveLogsList(); }); } const modelFilterSelect = document.getElementById('live-model-filter'); if (modelFilterSelect) { modelFilterSelect.addEventListener('change', (e) => { liveModelFilter = e.target.value; renderLiveLogsList(); }); } const autoScrollBtn = document.getElementById('live-auto-scroll-btn'); if (autoScrollBtn) { autoScrollBtn.addEventListener('click', () => { autoScroll = !autoScroll; autoScrollBtn.innerHTML = autoScroll ? ' Auto-Scroll: ON' : ' Auto-Scroll: OFF'; autoScrollBtn.className = autoScroll ? 'nav-btn' : 'nav-btn warning'; }); } `; return renderAdminLayout({ activePage: 'live_logs', pageTitle: 'Live Logs', bodyHtml, pageScript, extraStyles }); }