jev-dev-harness 0.2.15 → 0.2.17

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +145 -115
  2. package/LICENSE +21 -21
  3. package/README.md +687 -664
  4. package/bin/jev-dev.js +2 -2
  5. package/bin/jev-mcp.js +7 -7
  6. package/dashboard/index.html +1122 -1122
  7. package/dist/cli/delegate.d.ts +4 -0
  8. package/dist/cli/delegate.d.ts.map +1 -0
  9. package/dist/cli/delegate.js +62 -0
  10. package/dist/cli/delegate.js.map +1 -0
  11. package/dist/cli/doctor.js +46 -46
  12. package/dist/cli/index.d.ts.map +1 -1
  13. package/dist/cli/index.js +19 -3
  14. package/dist/cli/index.js.map +1 -1
  15. package/dist/cli/setup.d.ts.map +1 -1
  16. package/dist/cli/setup.js +25 -9
  17. package/dist/cli/setup.js.map +1 -1
  18. package/dist/context-ranker/stage-a-filter.d.ts.map +1 -1
  19. package/dist/context-ranker/stage-a-filter.js +26 -29
  20. package/dist/context-ranker/stage-a-filter.js.map +1 -1
  21. package/dist/context-ranker/types.d.ts +1 -0
  22. package/dist/context-ranker/types.d.ts.map +1 -1
  23. package/dist/delegate/index.d.ts +129 -0
  24. package/dist/delegate/index.d.ts.map +1 -0
  25. package/dist/delegate/index.js +87 -0
  26. package/dist/delegate/index.js.map +1 -0
  27. package/dist/hooks/index.js +73 -73
  28. package/dist/mcp/server.d.ts.map +1 -1
  29. package/dist/mcp/server.js +6 -0
  30. package/dist/mcp/server.js.map +1 -1
  31. package/dist/shared/efficiency.d.ts +4 -1
  32. package/dist/shared/efficiency.d.ts.map +1 -1
  33. package/dist/shared/efficiency.js +8 -4
  34. package/dist/shared/efficiency.js.map +1 -1
  35. package/dist/shared/telemetry.d.ts +6 -0
  36. package/dist/shared/telemetry.d.ts.map +1 -1
  37. package/dist/shared/telemetry.js +6 -0
  38. package/dist/shared/telemetry.js.map +1 -1
  39. package/dist/shared/typesafe-client.d.ts +2 -0
  40. package/dist/shared/typesafe-client.d.ts.map +1 -1
  41. package/dist/shared/typesafe-client.js +20 -9
  42. package/dist/shared/typesafe-client.js.map +1 -1
  43. package/dist/shared/version.js +1 -1
  44. package/docs/RELEASING.md +250 -243
  45. package/docs/jev/DELEGATED-REVIEW.md +86 -0
  46. package/docs/jev/JEV-0.2.16-DEFAULTS.md +60 -0
  47. package/docs/jev/JEV-1.14-EVALUATION.md +99 -99
  48. package/docs/jev/MEASURED-USAGE.md +155 -155
  49. package/docs/jev/MULTI-HARNESS-USAGE.md +163 -163
  50. package/docs/jev/OPENROUTER-NATIVE.md +93 -93
  51. package/docs/jev/README.md +85 -85
  52. package/docs/jev/evaluation-jev-1.14-2026-10-15.json +1731 -1731
  53. package/package.json +139 -133
@@ -1,1122 +1,1122 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Jev Developer Harness — Live Telemetry & ROI Dashboard</title>
7
- <link rel="icon" type="image/png" href="/assets/logo.png">
8
- <script src="https://www.gstatic.com/antigravity/web/dev/tailwindcss.min.js"></script>
9
- <style>
10
- @keyframes pulse-slow {
11
- 0%, 100% { opacity: 1; }
12
- 50% { opacity: 0.5; }
13
- }
14
- .animate-pulse-slow {
15
- animation: pulse-slow 2.5s infinite ease-in-out;
16
- }
17
- .tab-active {
18
- background-color: #3b82f6;
19
- color: #ffffff;
20
- box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.39);
21
- }
22
- .tab-inactive {
23
- background-color: transparent;
24
- color: #94a3b8;
25
- }
26
- .tab-inactive:hover {
27
- color: #f1f5f9;
28
- background-color: #1e293b;
29
- }
30
- </style>
31
- </head>
32
- <body class="bg-slate-950 text-slate-100 antialiased min-h-screen p-4 md:p-8 font-sans selection:bg-blue-500 selection:text-white">
33
-
34
- <!-- Main Container -->
35
- <div class="max-w-6xl mx-auto space-y-6">
36
-
37
- <!-- Top Navigation Bar & Brand Header -->
38
- <header class="border border-slate-800 bg-slate-900/90 backdrop-blur-md rounded-2xl p-5 md:p-6 shadow-2xl relative overflow-hidden flex flex-col md:flex-row items-start md:items-center justify-between gap-4">
39
- <div class="flex items-center gap-3.5">
40
- <img src="/assets/logo.png" alt="Jev Developer Harness Logo" class="w-12 h-12 rounded-xl object-cover border border-blue-500/40 shadow-lg shadow-blue-500/25 shrink-0" />
41
- <div>
42
- <div class="flex items-center gap-2">
43
- <h1 class="text-xl md:text-2xl font-extrabold tracking-tight text-white font-mono">
44
- jev-dev-harness
45
- </h1>
46
- <span class="text-[10px] font-mono uppercase px-2 py-0.5 rounded-full bg-blue-500/10 border border-blue-500/30 text-blue-400 font-bold">
47
- v0.2.7
48
- </span>
49
- </div>
50
- <p class="text-xs text-slate-400" data-i18n="header_subtitle">
51
- Runtime Developer Harness & Live Telemetry for AI Coding Agents
52
- </p>
53
- </div>
54
- </div>
55
-
56
- <!-- Header Controls: Language Toggle & Tab Switcher -->
57
- <div class="flex flex-wrap items-center gap-2.5">
58
- <!-- Language Selector Toggle -->
59
- <div class="flex items-center bg-slate-950/80 p-1 rounded-xl border border-slate-800 text-xs font-mono">
60
- <button id="langBtnEn" onclick="setLanguage('en')" class="px-2.5 py-1.5 rounded-lg text-xs font-semibold font-mono transition-all cursor-pointer flex items-center gap-1.5" title="English">
61
- <span>🇺🇸</span><span>EN</span>
62
- </button>
63
- <button id="langBtnPt" onclick="setLanguage('pt')" class="px-2.5 py-1.5 rounded-lg text-xs font-semibold font-mono transition-all cursor-pointer flex items-center gap-1.5" title="Português (Brasil)">
64
- <span>🇧🇷</span><span>PT</span>
65
- </button>
66
- </div>
67
-
68
- <!-- Tab Switcher -->
69
- <div class="flex items-center gap-1.5 bg-slate-950/80 p-1 rounded-xl border border-slate-800">
70
- <button id="tabBtnLive" onclick="switchTab('live')" class="px-3.5 py-1.5 rounded-lg text-xs font-semibold font-mono transition-all flex items-center gap-2 tab-active cursor-pointer">
71
- <span class="w-2 h-2 rounded-full bg-emerald-400 animate-pulse"></span>
72
- <span data-i18n="tab_live">Live Telemetry</span>
73
- </button>
74
- <button id="tabBtnRoi" onclick="switchTab('roi')" class="px-3.5 py-1.5 rounded-lg text-xs font-semibold font-mono transition-all flex items-center gap-2 tab-inactive cursor-pointer">
75
- <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"></path></svg>
76
- <span data-i18n="tab_roi">ROI & Simulator</span>
77
- </button>
78
- </div>
79
- </div>
80
- </header>
81
-
82
- <!-- Update Available Notification Banner -->
83
- <div id="updateBanner" class="hidden p-3.5 rounded-xl bg-gradient-to-r from-purple-950/60 to-blue-950/60 border border-purple-500/40 text-xs font-mono flex flex-col sm:flex-row sm:items-center justify-between gap-3 shadow-lg shadow-purple-950/30">
84
- <p id="updateNotice" role="status" class="text-slate-200 whitespace-pre-line"></p>
85
- <a id="updateRelease" href="https://github.com/celolopes/jev-dev-harness/releases" target="_blank" rel="noopener noreferrer" class="px-3 py-1.5 rounded-lg bg-purple-600 hover:bg-purple-500 active:scale-95 text-white font-bold transition-all text-center self-start sm:self-auto cursor-pointer" data-i18n="update_view">
86
- View Release
87
- </a>
88
- <button id="dismissUpdate" type="button" aria-label="Dismiss update notice" class="text-slate-300 px-2 py-1">×</button>
89
- </div>
90
-
91
- <!-- ============================================================== -->
92
- <!-- TAB 1: LIVE TELEMETRY (Real Data from Codex / Antigravity / Claude) -->
93
- <!-- ============================================================== -->
94
- <div id="tabContentLive" class="space-y-6">
95
-
96
- <!-- Active Gateway / Agent Status Banner (Inspired by Jev Gateway) -->
97
- <div class="border border-emerald-500/30 bg-emerald-950/20 backdrop-blur-md rounded-2xl p-5 md:p-6 shadow-xl relative overflow-hidden">
98
- <div class="flex flex-col md:flex-row items-start md:items-center justify-between gap-4">
99
- <div class="space-y-1.5">
100
- <div class="inline-flex items-center gap-2 font-mono text-xs text-emerald-400 font-semibold bg-emerald-500/10 px-2.5 py-1 rounded-full border border-emerald-500/20" data-i18n="status_banner_badge">
101
- <span class="w-2 h-2 rounded-full bg-emerald-400 animate-ping"></span>
102
- Codex Desktop • Antigravity • Claude Code
103
- </div>
104
- <div class="flex items-center gap-2">
105
- <svg class="w-6 h-6 text-emerald-400 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"></path></svg>
106
- <h2 class="text-2xl font-bold text-white tracking-tight" data-i18n="status_banner_title">Active Telemetry & Protection</h2>
107
- </div>
108
- <p id="liveStatusSubtext" class="text-xs md:text-sm text-slate-300">
109
- Jev recorded <strong id="liveDecidedCount" class="text-emerald-300">0</strong> requests across your coding agents.
110
- </p>
111
- <div class="text-[11px] text-slate-400 font-mono flex flex-wrap items-center gap-2 pt-1">
112
- <span><span data-i18n="status_model">Model:</span> <span class="text-slate-200">TypeSafe Jev System One</span></span>
113
- <span>•</span>
114
- <span id="liveStreamStatus" class="text-emerald-400" data-i18n="status_stream">⚡ Live Stream: Connected</span>
115
- <span>•</span>
116
- <span><span data-i18n="status_store">Store:</span> <code class="text-slate-300">~/.jev-dev/telemetry.jsonl</code></span>
117
- </div>
118
- </div>
119
-
120
- <div class="flex items-center gap-2 self-start md:self-auto">
121
- <button onclick="clearHistory()" class="px-3.5 py-2 rounded-xl bg-slate-900 hover:bg-slate-800 border border-slate-700 text-slate-300 hover:text-white text-xs font-mono transition-all cursor-pointer" data-i18n="btn_clear">
122
- Clear History
123
- </button>
124
- <button onclick="refreshData()" class="px-3.5 py-2 rounded-xl bg-emerald-600 hover:bg-emerald-500 text-white text-xs font-mono font-bold transition-all shadow-lg shadow-emerald-600/20 cursor-pointer" data-i18n="btn_refresh">
125
- Refresh
126
- </button>
127
- </div>
128
- </div>
129
- </div>
130
-
131
- <!-- Live Metric Cards Grid -->
132
- <div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3">
133
- <!-- Card 1: Requests -->
134
- <div class="p-4 rounded-xl bg-slate-900 border border-slate-800 shadow-sm">
135
- <div class="text-[11px] font-semibold text-slate-400 uppercase tracking-wider mb-1" data-i18n="card_ops_title">Agent Ops</div>
136
- <div id="metricTotalEvents" class="text-2xl font-extrabold text-white font-mono">0</div>
137
- <p class="text-[10px] text-slate-400 mt-1" data-i18n="card_ops_sub">Through harness</p>
138
- </div>
139
-
140
- <!-- Card 2: Token savings -->
141
- <div class="p-4 rounded-xl bg-slate-900 border border-slate-800 shadow-sm">
142
- <div class="text-[11px] font-semibold text-purple-400 uppercase tracking-wider mb-1" data-i18n="card_tokens_title">Token savings</div>
143
- <div id="metricTokensSaved" class="text-2xl font-extrabold text-purple-300 font-mono">Not measured</div>
144
- <p id="metricTokensSavedSub" class="text-[10px] text-slate-400 mt-1" data-i18n="card_tokens_sub">No measured baseline</p>
145
- </div>
146
-
147
- <!-- Card 3: Cash Saved -->
148
- <div class="p-4 rounded-xl bg-slate-900 border border-slate-800 shadow-sm">
149
- <div class="text-[11px] font-semibold text-emerald-400 uppercase tracking-wider mb-1" data-i18n="card_cash_title">Money savings</div>
150
- <div id="metricDollarsSaved" class="text-2xl font-extrabold text-emerald-300 font-mono">Not measured</div>
151
- <p class="text-[10px] text-slate-400 mt-1" data-i18n="card_cash_sub">No measured baseline</p>
152
- </div>
153
-
154
- <!-- Card 4: Jev Latency -->
155
- <div class="p-4 rounded-xl bg-slate-900 border border-slate-800 shadow-sm">
156
- <div class="text-[11px] font-semibold text-blue-400 uppercase tracking-wider mb-1" data-i18n="card_latency_title">Avg Latency</div>
157
- <div id="metricLatency" class="text-2xl font-extrabold text-blue-300 font-mono">-- ms</div>
158
- <p id="metricLatencySub" class="text-[10px] text-slate-400 mt-1">p95: -- ms</p>
159
- </div>
160
-
161
- <!-- Card 5: Tool Guard -->
162
- <div class="p-4 rounded-xl bg-slate-900 border border-slate-800 shadow-sm">
163
- <div class="text-[11px] font-semibold text-amber-400 uppercase tracking-wider mb-1" data-i18n="card_guard_title">Tool Guard</div>
164
- <div id="metricGuardCount" class="text-2xl font-extrabold text-amber-300 font-mono">0</div>
165
- <p id="metricGuardSub" class="text-[10px] text-slate-400 mt-1">0 blocked</p>
166
- </div>
167
-
168
- <!-- Card 6: Patch Audits -->
169
- <div class="p-4 rounded-xl bg-slate-900 border border-slate-800 shadow-sm">
170
- <div class="text-[11px] font-semibold text-rose-400 uppercase tracking-wider mb-1" data-i18n="card_patch_title">Patch Audits</div>
171
- <div id="metricPatchCount" class="text-2xl font-extrabold text-rose-300 font-mono">0</div>
172
- <p id="metricPatchSub" class="text-[10px] text-slate-400 mt-1">Avg risk: --/100</p>
173
- </div>
174
- </div>
175
-
176
- <p id="measuredUsage" class="text-xs text-slate-400">Reported context-rank usage: not informed.</p>
177
- <div class="border border-slate-800 bg-slate-900/90 rounded-2xl p-5 space-y-2">
178
- <h3 class="text-sm font-bold text-white" id="comparisonTitle">Measured task comparison</h3>
179
- <pre id="measuredComparison" class="whitespace-pre-wrap text-xs text-slate-300">No paired execution imported. Savings are not measured.</pre>
180
- </div>
181
- <!-- Distribution & Operations Breakdown (Mirroring Jev Gateway UI) -->
182
- <div class="grid grid-cols-1 lg:grid-cols-12 gap-6">
183
- <!-- What happened to each request -->
184
- <div class="lg:col-span-7 border border-slate-800 bg-slate-900/90 rounded-2xl p-5 shadow-xl space-y-4">
185
- <div class="flex items-center justify-between">
186
- <h3 class="text-sm font-bold text-white uppercase tracking-wider font-mono" data-i18n="chart_title">What happened to each request</h3>
187
- <span id="distSummaryText" class="text-xs text-slate-400 font-mono">0 total requests</span>
188
- </div>
189
-
190
- <!-- Stacked Bar Representation -->
191
- <div class="w-full h-5 rounded-lg bg-slate-800 overflow-hidden flex" id="distStackedBar">
192
- <div id="barRank" class="bg-purple-500 h-full transition-all" style="width: 0%" title="Context Ranker"></div>
193
- <div id="barGuard" class="bg-amber-500 h-full transition-all" style="width: 0%" title="Tool Guard"></div>
194
- <div id="barPatch" class="bg-blue-500 h-full transition-all" style="width: 0%" title="Patch Reviewer"></div>
195
- <div id="barLint" class="bg-emerald-500 h-full transition-all" style="width: 0%" title="Semantic Linter"></div>
196
- </div>
197
-
198
- <!-- Legend -->
199
- <div class="grid grid-cols-2 sm:grid-cols-4 gap-2 pt-2 text-xs font-mono">
200
- <div class="flex items-center gap-2">
201
- <span class="w-3 h-3 rounded bg-purple-500 flex-shrink-0"></span>
202
- <span class="text-slate-300"><span data-i18n="legend_rank">Context Rank</span> (<span id="pctRank">0%</span>)</span>
203
- </div>
204
- <div class="flex items-center gap-2">
205
- <span class="w-3 h-3 rounded bg-amber-500 flex-shrink-0"></span>
206
- <span class="text-slate-300"><span data-i18n="legend_guard">Tool Guard</span> (<span id="pctGuard">0%</span>)</span>
207
- </div>
208
- <div class="flex items-center gap-2">
209
- <span class="w-3 h-3 rounded bg-blue-500 flex-shrink-0"></span>
210
- <span class="text-slate-300"><span data-i18n="legend_patch">Patch Audit</span> (<span id="pctPatch">0%</span>)</span>
211
- </div>
212
- <div class="flex items-center gap-2">
213
- <span class="w-3 h-3 rounded bg-emerald-500 flex-shrink-0"></span>
214
- <span class="text-slate-300"><span data-i18n="legend_lint">Semantic Lint</span> (<span id="pctLint">0%</span>)</span>
215
- </div>
216
- </div>
217
- </div>
218
-
219
- <!-- Protection & Interception Summary -->
220
- <div class="lg:col-span-5 border border-slate-800 bg-slate-900/90 rounded-2xl p-5 shadow-xl space-y-3 flex flex-col justify-between">
221
- <h3 class="text-sm font-bold text-white uppercase tracking-wider font-mono" data-i18n="verdicts_title">Safety & Gate Verdicts</h3>
222
- <div class="space-y-2 text-xs font-mono">
223
- <div class="flex justify-between items-center p-2 rounded-lg bg-slate-950/60 border border-slate-800">
224
- <span class="text-slate-400" data-i18n="verdicts_cmd_label">Destructive Commands Blocked:</span>
225
- <span id="gateBlockedVal" class="text-emerald-400 font-bold">0 safe</span>
226
- </div>
227
- <div class="flex justify-between items-center p-2 rounded-lg bg-slate-950/60 border border-slate-800">
228
- <span class="text-slate-400" data-i18n="verdicts_patch_label">Patches Escalated / Blocked:</span>
229
- <span id="gateEscalatedVal" class="text-amber-400 font-bold">0 escalated</span>
230
- </div>
231
- <div class="flex justify-between items-center p-2 rounded-lg bg-slate-950/60 border border-slate-800">
232
- <span class="text-slate-400" data-i18n="verdicts_reduction_label">File selection reduction:</span>
233
- <span id="gateAvgReductionVal" class="text-purple-400 font-bold">--</span>
234
- </div>
235
- </div>
236
- <div class="text-[11px] text-slate-500 text-right" data-i18n="verdicts_engine">
237
- Deterministic rule gates + Jev System One
238
- </div>
239
- </div>
240
- </div>
241
-
242
- <!-- Real-Time Activity Feed / Event Log -->
243
- <div class="border border-slate-800 bg-slate-900/90 rounded-2xl p-5 shadow-xl space-y-4">
244
- <div class="flex items-center justify-between">
245
- <div class="flex items-center gap-2">
246
- <span class="w-2 h-2 rounded-full bg-emerald-400 animate-ping"></span>
247
- <h3 class="text-base font-bold text-white font-mono" data-i18n="stream_title">Live Operations Stream</h3>
248
- </div>
249
- <span class="text-xs text-slate-400 font-mono" id="feedCountText" data-i18n="stream_listening">Listening for agent tool calls...</span>
250
- </div>
251
-
252
- <div class="overflow-x-auto">
253
- <table class="w-full text-left text-xs font-mono text-slate-300">
254
- <thead class="text-[11px] uppercase bg-slate-950/80 text-slate-400 border-y border-slate-800">
255
- <tr>
256
- <th scope="col" class="py-2.5 px-3" data-i18n="th_time">Time</th>
257
- <th scope="col" class="py-2.5 px-3" data-i18n="th_platform">Platform / Agent</th>
258
- <th scope="col" class="py-2.5 px-3" data-i18n="th_harness">Harness / Engine</th>
259
- <th scope="col" class="py-2.5 px-3" data-i18n="th_operation">Operation</th>
260
- <th scope="col" class="py-2.5 px-3" data-i18n="th_target">Target / Detail</th>
261
- <th scope="col" class="py-2.5 px-3" data-i18n="th_outcome">Outcome / Impact</th>
262
- <th scope="col" class="py-2.5 px-3" data-i18n="th_speed">Speed</th>
263
- <th scope="col" class="py-2.5 px-3" data-i18n="th_status">Status</th>
264
- </tr>
265
- </thead>
266
- <tbody id="eventsTableBody" class="divide-y divide-slate-800/60">
267
- <tr id="emptyEventsRow">
268
- <td colspan="8" class="py-8 text-center text-slate-500" data-i18n="table_empty">
269
- No telemetry events recorded yet. Run a prompt in Codex Desktop or Antigravity to see live data here!
270
- </td>
271
- </tr>
272
- </tbody>
273
- </table>
274
- </div>
275
- </div>
276
-
277
- </div>
278
-
279
- <!-- ============================================================== -->
280
- <!-- TAB 2: ROI & BENCHMARK SIMULATOR -->
281
- <!-- ============================================================== -->
282
- <div id="tabContentRoi" class="space-y-6 hidden">
283
-
284
- <!-- Interactive Calculator Section -->
285
- <section class="border border-slate-800 bg-slate-900/90 rounded-2xl p-6 md:p-8 shadow-xl">
286
- <div class="flex flex-col md:flex-row items-start md:items-center justify-between gap-4 pb-6 border-b border-slate-800">
287
- <div>
288
- <h2 class="text-xl font-bold text-white flex items-center gap-2">
289
- <svg class="w-5 h-5 text-emerald-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
290
- <span data-i18n="calc_title">Interactive ROI & Dollar Savings Calculator</span>
291
- </h2>
292
- <p class="text-xs md:text-sm text-slate-400" data-i18n="calc_subtitle">Hypothetical simulation using fixed assumptions (85,000 vs 6,500 tokens/prompt). Not measured telemetry or evidence of savings.</p>
293
- </div>
294
- <span class="px-3 py-1 rounded-full text-xs font-mono bg-emerald-500/10 text-emerald-300 border border-emerald-500/20" data-i18n="calc_badge">
295
- Interactive Model
296
- </span>
297
- </div>
298
-
299
- <div class="grid grid-cols-1 lg:grid-cols-12 gap-8 mt-6">
300
- <!-- Sliders & Controls -->
301
- <div class="lg:col-span-6 space-y-6">
302
- <div>
303
- <div class="flex justify-between items-center mb-2">
304
- <label class="text-sm font-medium text-slate-300" data-i18n="calc_team_label">Team Size (Engineers with AI Agents)</label>
305
- <span id="teamSizeVal" class="text-base font-bold text-purple-400 font-mono">10 devs</span>
306
- </div>
307
- <input id="teamSize" type="range" min="1" max="100" value="10" class="w-full h-2 bg-slate-700 rounded-lg appearance-none cursor-pointer accent-purple-500" oninput="updateCalculator()">
308
- <div class="flex justify-between text-[11px] text-slate-500 mt-1 font-mono">
309
- <span data-i18n="calc_team_solo">1 solo</span>
310
- <span data-i18n="calc_team_team">10 team</span>
311
- <span data-i18n="calc_team_squad">50 squad</span>
312
- <span data-i18n="calc_team_enterprise">100 enterprise</span>
313
- </div>
314
- </div>
315
-
316
- <div>
317
- <div class="flex justify-between items-center mb-2">
318
- <label class="text-sm font-medium text-slate-300" data-i18n="calc_prompts_label">Agent Prompts per Dev / Day</label>
319
- <span id="promptsVal" class="text-base font-bold text-blue-400 font-mono">40 prompts</span>
320
- </div>
321
- <input id="promptsPerDay" type="range" min="10" max="150" step="5" value="40" class="w-full h-2 bg-slate-700 rounded-lg appearance-none cursor-pointer accent-blue-500" oninput="updateCalculator()">
322
- <div class="flex justify-between text-[11px] text-slate-500 mt-1 font-mono">
323
- <span data-i18n="calc_prompts_light">10 light</span>
324
- <span data-i18n="calc_prompts_standard">40 standard</span>
325
- <span data-i18n="calc_prompts_intense">80 intense</span>
326
- <span data-i18n="calc_prompts_power">150 power user</span>
327
- </div>
328
- </div>
329
-
330
- <div>
331
- <label class="block text-sm font-medium text-slate-300 mb-2" data-i18n="calc_model_label">Target Agent Model & Pricing</label>
332
- <select id="modelSelect" class="w-full bg-slate-800 border border-slate-700 rounded-xl px-4 py-2.5 text-sm text-slate-200 focus:outline-none focus:border-purple-500" onchange="updateCalculator()">
333
- <option value="3.00">Claude 3.5 Sonnet ($3.00 / million input tokens)</option>
334
- <option value="2.50">OpenAI GPT-4o ($2.50 / million input tokens)</option>
335
- <option value="0.80">Claude 3.5 Haiku ($0.80 / million input tokens)</option>
336
- <option value="0.14">DeepSeek V3 ($0.14 / million input tokens)</option>
337
- </select>
338
- </div>
339
- </div>
340
-
341
- <!-- Calculated Results Cards -->
342
- <div class="lg:col-span-6 bg-slate-950/60 border border-slate-800/80 rounded-xl p-6 flex flex-col justify-between">
343
- <div class="space-y-4">
344
- <div class="flex items-center justify-between pb-3 border-b border-slate-800 text-xs">
345
- <span class="text-slate-400" data-i18n="calc_tokens_without">Monthly Tokens Without Jev:</span>
346
- <span id="tokensWithoutVal" class="font-mono text-slate-300 font-semibold">748M tokens</span>
347
- </div>
348
- <div class="flex items-center justify-between pb-3 border-b border-slate-800 text-xs">
349
- <span class="text-slate-400" data-i18n="calc_tokens_with">Monthly Tokens With Jev (Surgical):</span>
350
- <span id="tokensWithVal" class="font-mono text-purple-300 font-semibold">57M tokens (-92.4%)</span>
351
- </div>
352
- <div class="grid grid-cols-2 gap-3 pt-2">
353
- <div class="p-3 rounded-lg bg-red-950/20 border border-red-900/30">
354
- <span class="text-[11px] uppercase font-bold text-red-400 block" data-i18n="calc_cost_without">Cost Without Jev</span>
355
- <span id="costWithoutVal" class="text-xl font-bold font-mono text-red-200">$2,244.00</span>
356
- <span class="text-[10px] text-slate-400 block mt-0.5" data-i18n="calc_per_month">/ month</span>
357
- </div>
358
- <div class="p-3 rounded-lg bg-emerald-950/20 border border-emerald-900/30">
359
- <span class="text-[11px] uppercase font-bold text-emerald-400 block" data-i18n="calc_cost_with">Cost With Jev</span>
360
- <span id="costWithVal" class="text-xl font-bold font-mono text-emerald-200">$171.60</span>
361
- <span class="text-[10px] text-slate-400 block mt-0.5" data-i18n="calc_per_month">/ month</span>
362
- </div>
363
- </div>
364
- </div>
365
-
366
- <div class="mt-6 pt-4 border-t border-slate-800/80 bg-gradient-to-r from-purple-950/30 to-emerald-950/30 p-4 rounded-xl border border-purple-900/30">
367
- <div class="flex items-baseline justify-between">
368
- <div>
369
- <span class="text-xs uppercase font-extrabold tracking-wider text-emerald-400 block" data-i18n="calc_net_monthly">Net Monthly Cash Saved</span>
370
- <span id="savingsMonthVal" class="text-3xl font-black font-mono text-white">$2,072.40</span>
371
- </div>
372
- <div class="text-right">
373
- <span class="text-xs uppercase font-extrabold tracking-wider text-purple-400 block" data-i18n="calc_annual">Annual Savings</span>
374
- <span id="savingsYearVal" class="text-xl font-bold font-mono text-purple-200">$24,868.80</span>
375
- </div>
376
- </div>
377
- </div>
378
- </div>
379
- </div>
380
- </section>
381
-
382
- <!-- Side-by-Side Matrix -->
383
- <section class="border border-slate-800 bg-slate-900/80 rounded-2xl p-6 md:p-8 shadow-xl space-y-6">
384
- <h2 class="text-xl font-bold text-white font-mono" data-i18n="matrix_title">Side-by-Side Architectural Matrix</h2>
385
- <div class="overflow-x-auto">
386
- <table class="w-full text-left text-sm text-slate-300">
387
- <thead class="text-xs uppercase bg-slate-950/60 text-slate-400 border-y border-slate-800">
388
- <tr>
389
- <th scope="col" class="py-3 px-4" data-i18n="matrix_th_feat">Feature / Dimension</th>
390
- <th scope="col" class="py-3 px-4 text-red-400 bg-red-950/10 border-x border-slate-800" data-i18n="matrix_th_without">Without Jev (Vanilla Agent)</th>
391
- <th scope="col" class="py-3 px-4 text-emerald-400 bg-emerald-950/10" data-i18n="matrix_th_with">With Jev Developer Harness</th>
392
- <th scope="col" class="py-3 px-4 text-purple-400" data-i18n="matrix_th_adv">Competitive Advantage</th>
393
- </tr>
394
- </thead>
395
- <tbody class="divide-y divide-slate-800/60 font-normal">
396
- <tr class="hover:bg-slate-800/30">
397
- <td class="py-3.5 px-4 font-semibold text-white" data-i18n="matrix_r1_feat">Context Discovery</td>
398
- <td class="py-3.5 px-4 text-slate-400 bg-red-950/5 border-x border-slate-800" data-i18n="matrix_r1_without">Dumps 40–90 files into prompt. High "lost in the middle" rate.</td>
399
- <td class="py-3.5 px-4 text-emerald-200 bg-emerald-950/5 font-medium" data-i18n="matrix_r1_with">4-stage ranker isolates the exact 3–5 crucial files.</td>
400
- <td class="py-3.5 px-4 font-semibold text-purple-300" data-i18n="matrix_r1_adv">Selected file counts; token savings not measured.</td>
401
- </tr>
402
- <tr class="hover:bg-slate-800/30">
403
- <td class="py-3.5 px-4 font-semibold text-white" data-i18n="matrix_r2_feat">Shell Command Execution</td>
404
- <td class="py-3.5 px-4 text-slate-400 bg-red-950/5 border-x border-slate-800" data-i18n="matrix_r2_without">LLM executes terminal commands blindly (risk of `rm -rf`, `git reset`).</td>
405
- <td class="py-3.5 px-4 text-emerald-200 bg-emerald-950/5 font-medium" data-i18n="matrix_r2_with">&lt;1ms lexical classifier + Jev evaluator for unknown syntax.</td>
406
- <td class="py-3.5 px-4 font-semibold text-purple-300" data-i18n="matrix_r2_adv">100% deterministic guard blocking destructive actions.</td>
407
- </tr>
408
- <tr class="hover:bg-slate-800/30">
409
- <td class="py-3.5 px-4 font-semibold text-white" data-i18n="matrix_r3_feat">Git Diff & Patch Audit</td>
410
- <td class="py-3.5 px-4 text-slate-400 bg-red-950/5 border-x border-slate-800" data-i18n="matrix_r3_without">Manual developer review or waiting minutes for remote CI runs.</td>
411
- <td class="py-3.5 px-4 text-emerald-200 bg-emerald-950/5 font-medium" data-i18n="matrix_r3_with">Sub-second (~750ms) System One pre-commit hook automatically audits diffs.</td>
412
- <td class="py-3.5 px-4 font-semibold text-purple-300" data-i18n="matrix_r3_adv">Catches credential leaks & regression risk before commit.</td>
413
- </tr>
414
- </tbody>
415
- </table>
416
- </div>
417
- </section>
418
-
419
- </div>
420
-
421
- <!-- Footer -->
422
- <footer class="text-center text-xs text-slate-500 py-4 font-mono" data-i18n="footer">
423
- jev-dev-harness v0.2.7 • Licensed under MIT • Powered by TypeSafe AI / Jev System One
424
- </footer>
425
-
426
- </div>
427
-
428
- <!-- Client-side Telemetry & Calculator Script -->
429
- <script>
430
- // Tab switching
431
- function switchTab(tab) {
432
- const liveTab = document.getElementById('tabContentLive');
433
- const roiTab = document.getElementById('tabContentRoi');
434
- const btnLive = document.getElementById('tabBtnLive');
435
- const btnRoi = document.getElementById('tabBtnRoi');
436
-
437
- if (tab === 'live') {
438
- liveTab.classList.remove('hidden');
439
- roiTab.classList.add('hidden');
440
- btnLive.className = 'px-4 py-2 rounded-lg text-xs font-semibold font-mono transition-all flex items-center gap-2 tab-active cursor-pointer';
441
- btnRoi.className = 'px-4 py-2 rounded-lg text-xs font-semibold font-mono transition-all flex items-center gap-2 tab-inactive cursor-pointer';
442
- } else {
443
- liveTab.classList.add('hidden');
444
- roiTab.classList.remove('hidden');
445
- btnLive.className = 'px-4 py-2 rounded-lg text-xs font-semibold font-mono transition-all flex items-center gap-2 tab-inactive cursor-pointer';
446
- btnRoi.className = 'px-4 py-2 rounded-lg text-xs font-semibold font-mono transition-all flex items-center gap-2 tab-active cursor-pointer';
447
- }
448
- }
449
-
450
- // ==========================================
451
- // Internationalization (i18n) - EN & PT-BR
452
- // ==========================================
453
- const I18N = {
454
- en: {
455
- header_subtitle: 'Runtime Developer Harness & Live Telemetry for AI Coding Agents',
456
- tab_live: 'Live Telemetry',
457
- tab_roi: 'ROI & Simulator',
458
- update_new: 'New update available:',
459
- update_view: 'View Release',
460
- status_banner_badge: 'Codex Desktop • Antigravity • Claude Code',
461
- status_banner_title: 'Active Telemetry & Protection',
462
- status_model: 'Model:',
463
- status_stream: '⚡ Live Stream: Connected',
464
- status_store: 'Store:',
465
- btn_clear: 'Clear History',
466
- btn_refresh: 'Refresh',
467
- card_ops_title: 'Agent Ops',
468
- card_ops_sub: 'Through harness',
469
- card_tokens_title: 'Token savings',
470
- card_tokens_sub: 'No measured baseline',
471
- card_cash_title: 'Money savings',
472
- card_cash_sub: 'No measured baseline',
473
- card_latency_title: 'Avg Latency',
474
- card_guard_title: 'Tool Guard',
475
- card_patch_title: 'Patch Audits',
476
- chart_title: 'What happened to each request',
477
- legend_rank: 'Context Rank',
478
- legend_guard: 'Tool Guard',
479
- legend_patch: 'Patch Audit',
480
- legend_lint: 'Semantic Lint',
481
- verdicts_title: 'Safety & Gate Verdicts',
482
- verdicts_cmd_label: 'Destructive Commands Blocked:',
483
- verdicts_patch_label: 'Patches Escalated / Blocked:',
484
- verdicts_reduction_label: 'File selection reduction:',
485
- verdicts_engine: 'Deterministic rule gates + Jev System One',
486
- stream_title: 'Live Operations Stream',
487
- stream_listening: 'Listening for agent tool calls...',
488
- th_time: 'Time',
489
- th_platform: 'Platform / Agent',
490
- th_harness: 'Harness & Engine',
491
- th_operation: 'Operation',
492
- th_target: 'Target / Detail',
493
- th_outcome: 'Outcome / Impact',
494
- th_speed: 'Speed',
495
- th_status: 'Status',
496
- table_empty: 'No telemetry events recorded yet. Run a prompt in Codex Desktop or Antigravity to see live data here!',
497
- calc_title: 'Interactive ROI & Dollar Savings Calculator',
498
- calc_subtitle: 'Hypothetical simulation using fixed assumptions (85,000 vs 6,500 tokens/prompt). Not measured telemetry or evidence of savings.',
499
- calc_badge: 'Interactive Model',
500
- calc_team_label: 'Team Size (Engineers with AI Agents)',
501
- calc_team_solo: '1 solo',
502
- calc_team_team: '10 team',
503
- calc_team_squad: '50 squad',
504
- calc_team_enterprise: '100 enterprise',
505
- calc_prompts_label: 'Agent Prompts per Dev / Day',
506
- calc_prompts_light: '10 light',
507
- calc_prompts_standard: '40 standard',
508
- calc_prompts_intense: '80 intense',
509
- calc_prompts_power: '150 power user',
510
- calc_model_label: 'Target Agent Model & Pricing',
511
- calc_tokens_without: 'Monthly Tokens Without Jev:',
512
- calc_tokens_with: 'Monthly Tokens With Jev (Surgical):',
513
- calc_cost_without: 'Cost Without Jev',
514
- calc_cost_with: 'Cost With Jev',
515
- calc_per_month: '/ month',
516
- calc_net_monthly: 'Net Monthly Cash Saved',
517
- calc_annual: 'Annual Savings',
518
- matrix_title: 'Side-by-Side Architectural Matrix',
519
- matrix_th_feat: 'Feature / Dimension',
520
- matrix_th_without: 'Without Jev (Vanilla Agent)',
521
- matrix_th_with: 'With Jev Developer Harness',
522
- matrix_th_adv: 'Competitive Advantage',
523
- matrix_r1_feat: 'Context Discovery',
524
- matrix_r1_without: 'Dumps 40–90 files into prompt. High "lost in the middle" rate.',
525
- matrix_r1_with: '4-stage ranker isolates the exact 3–5 crucial files.',
526
- matrix_r1_adv: 'Selected file counts; token savings not measured.',
527
- matrix_r2_feat: 'Shell Command Execution',
528
- matrix_r2_without: 'LLM executes terminal commands blindly (risk of `rm -rf`, `git reset`).',
529
- matrix_r2_with: 'Lexical classifier + optional evaluator; measured latency per operation.',
530
- matrix_r2_adv: '100% deterministic guard blocking destructive actions.',
531
- matrix_r3_feat: 'Git Diff & Patch Audit',
532
- matrix_r3_without: 'Manual developer review or waiting minutes for remote CI runs.',
533
- matrix_r3_with: 'Sub-second (~750ms) System One pre-commit hook automatically audits diffs.',
534
- matrix_r3_adv: 'Catches credential leaks & regression risk before commit.',
535
- footer: 'jev-dev-harness v0.2.7 • Licensed under MIT • Powered by TypeSafe AI / Jev System One'
536
- },
537
- pt: {
538
- header_subtitle: 'Runtime Developer Harness e Telemetria em Tempo Real para Agentes de IA',
539
- tab_live: 'Telemetria em Tempo Real',
540
- tab_roi: 'ROI e Simulador',
541
- update_new: 'Nova atualização disponível:',
542
- update_view: 'Ver Lançamento',
543
- status_banner_badge: 'Codex Desktop • Antigravity • Claude Code',
544
- status_banner_title: 'Telemetria Ativa & Proteção',
545
- status_model: 'Modelo:',
546
- status_stream: '⚡ Fluxo ao Vivo: Conectado',
547
- status_store: 'Armazenamento:',
548
- btn_clear: 'Limpar Histórico',
549
- btn_refresh: 'Atualizar',
550
- card_ops_title: 'Operações de IA',
551
- card_ops_sub: 'Via harness',
552
- card_tokens_title: 'Economia de tokens',
553
- card_tokens_sub: 'Sem baseline medido',
554
- card_cash_title: 'Economia de dinheiro',
555
- card_cash_sub: 'Sem baseline medido',
556
- card_latency_title: 'Latência Média',
557
- card_guard_title: 'Guarda de Comandos',
558
- card_patch_title: 'Auditorias de Patch',
559
- chart_title: 'O que ocorreu com cada requisição',
560
- legend_rank: 'Rank de Contexto',
561
- legend_guard: 'Guarda de Comandos',
562
- legend_patch: 'Auditoria de Patch',
563
- legend_lint: 'Lint Semântico',
564
- verdicts_title: 'Vereditos de Segurança & Portões',
565
- verdicts_cmd_label: 'Comandos Destrutivos Bloqueados:',
566
- verdicts_patch_label: 'Patches Escalados / Bloqueados:',
567
- verdicts_reduction_label: 'Redução na seleção de arquivos:',
568
- verdicts_engine: 'Regras determinísticas + Jev System One',
569
- stream_title: 'Fluxo de Operações em Tempo Real',
570
- stream_listening: 'Escutando chamadas de ferramentas dos agentes...',
571
- th_time: 'Horário',
572
- th_platform: 'Plataforma Acionada',
573
- th_harness: 'Módulo & Provedor',
574
- th_operation: 'Operação',
575
- th_target: 'Alvo / Detalhe',
576
- th_outcome: 'Resultado / Impacto',
577
- th_speed: 'Tempo',
578
- th_status: 'Status',
579
- table_empty: 'Nenhum evento de telemetria registrado ainda. Execute um prompt no Codex Desktop ou Antigravity para ver os dados ao vivo aqui!',
580
- calc_title: 'Calculadora Interativa de ROI e Economia Financeira',
581
- calc_subtitle: 'Simulação hipotética com premissas fixas (85.000 vs 6.500 tokens/prompt). Não é telemetria medida nem comprovação de economia.',
582
- calc_badge: 'Modelo Interativo',
583
- calc_team_label: 'Tamanho da Equipe (Engenheiros com Agentes IA)',
584
- calc_team_solo: '1 solo',
585
- calc_team_team: '10 time',
586
- calc_team_squad: '50 squad',
587
- calc_team_enterprise: '100 corporativo',
588
- calc_prompts_label: 'Prompts do Agente por Dev / Dia',
589
- calc_prompts_light: '10 leve',
590
- calc_prompts_standard: '40 padrão',
591
- calc_prompts_intense: '80 intenso',
592
- calc_prompts_power: '150 avançado',
593
- calc_model_label: 'Modelo do Agente e Custo',
594
- calc_tokens_without: 'Tokens Mensais Sem o Jev:',
595
- calc_tokens_with: 'Tokens Mensais Com o Jev (Cirúrgico):',
596
- calc_cost_without: 'Custo Sem o Jev',
597
- calc_cost_with: 'Custo Com o Jev',
598
- calc_per_month: '/ mês',
599
- calc_net_monthly: 'Economia Líquida Mensal',
600
- calc_annual: 'Economia Anual',
601
- matrix_title: 'Matriz Comparativa de Arquitetura',
602
- matrix_th_feat: 'Funcionalidade / Dimensão',
603
- matrix_th_without: 'Sem o Jev (Agente Padrão)',
604
- matrix_th_with: 'Com Jev Developer Harness',
605
- matrix_th_adv: 'Vantagem Competitiva',
606
- matrix_r1_feat: 'Descoberta de Contexto',
607
- matrix_r1_without: 'Despeja 40–90 arquivos no prompt. Alta taxa de perda de atenção ("lost in the middle").',
608
- matrix_r1_with: 'Ranker em 4 estágios isola com precisão os 3–5 arquivos cruciais.',
609
- matrix_r1_adv: 'Contagem de arquivos selecionados; economia de tokens não medida.',
610
- matrix_r2_feat: 'Execução de Comandos de Shell',
611
- matrix_r2_without: 'LLM executa comandos às cegas no terminal (risco de `rm -rf`, `git reset`).',
612
- matrix_r2_with: 'Classificador léxico + avaliador opcional; latência medida por operação.',
613
- matrix_r2_adv: 'Guarda 100% determinístico que bloqueia ações destrutivas.',
614
- matrix_r3_feat: 'Auditoria de Diffs & Patches Git',
615
- matrix_r3_without: 'Revisão manual do dev ou minutos de espera em pipelines lentos de CI.',
616
- matrix_r3_with: 'Pre-commit hook System One sub-segundo (~750ms) audita diffs automaticamente.',
617
- matrix_r3_adv: 'Detecta vazamentos de credenciais e risco de regressão antes do commit.',
618
- footer: 'jev-dev-harness v0.2.7 • Licenciado sob MIT • Desenvolvido com TypeSafe AI / Jev System One'
619
- }
620
- };
621
-
622
- let currentLang = 'en';
623
-
624
- function setLanguage(lang) {
625
- currentLang = (lang === 'pt' || lang === 'pt-BR') ? 'pt' : 'en';
626
- try {
627
- localStorage.setItem('jev_dashboard_lang', currentLang);
628
- } catch (e) {}
629
-
630
- // Update button visual styles
631
- const btnEn = document.getElementById('langBtnEn');
632
- const btnPt = document.getElementById('langBtnPt');
633
- if (btnEn && btnPt) {
634
- if (currentLang === 'pt') {
635
- btnPt.className = 'px-2.5 py-1.5 rounded-lg text-xs font-semibold font-mono transition-all cursor-pointer flex items-center gap-1.5 bg-emerald-600 text-white shadow-sm font-bold';
636
- btnEn.className = 'px-2.5 py-1.5 rounded-lg text-xs font-semibold font-mono transition-all cursor-pointer flex items-center gap-1.5 text-slate-400 hover:text-white font-medium';
637
- } else {
638
- btnEn.className = 'px-2.5 py-1.5 rounded-lg text-xs font-semibold font-mono transition-all cursor-pointer flex items-center gap-1.5 bg-purple-600 text-white shadow-sm font-bold';
639
- btnPt.className = 'px-2.5 py-1.5 rounded-lg text-xs font-semibold font-mono transition-all cursor-pointer flex items-center gap-1.5 text-slate-400 hover:text-white font-medium';
640
- }
641
- }
642
-
643
- // Translate all [data-i18n] elements
644
- document.querySelectorAll('[data-i18n]').forEach(el => {
645
- const key = el.getAttribute('data-i18n');
646
- if (I18N[currentLang] && I18N[currentLang][key]) {
647
- el.innerHTML = I18N[currentLang][key];
648
- }
649
- });
650
-
651
- // Re-render dynamic elements with active translation
652
- if (currentSummary) {
653
- updateTelemetryUi(currentSummary, eventsList);
654
- } else {
655
- renderEventsTable(eventsList);
656
- }
657
- updateCalculator();
658
- }
659
-
660
- // Live Telemetry Handlers
661
- let currentSummary = null;
662
- let eventsList = [];
663
-
664
- function updateTelemetryUi(summary, events) {
665
- try {
666
- if (summary) {
667
- currentSummary = summary;
668
- const subtextEl = document.getElementById('liveStatusSubtext');
669
- if (subtextEl) {
670
- subtextEl.innerHTML = currentLang === 'pt'
671
- ? `O Jev registrou <strong id="liveDecidedCount" class="text-emerald-300">${summary.totalEvents}</strong> eventos em todos os seus agentes de codificação.`
672
- : `Jev recorded <strong id="liveDecidedCount" class="text-emerald-300">${summary.totalEvents}</strong> events across your coding agents.`;
673
- }
674
-
675
- const totalEl = document.getElementById('metricTotalEvents');
676
- if (totalEl) totalEl.innerText = summary.totalEvents;
677
-
678
- const tokensEl = document.getElementById('metricTokensSaved');
679
- if (tokensEl) tokensEl.innerText = currentLang === 'pt' ? 'Não medida' : 'Not measured';
680
-
681
- const dollarsEl = document.getElementById('metricDollarsSaved');
682
- if (dollarsEl) dollarsEl.innerText = currentLang === 'pt' ? 'Não medida' : 'Not measured';
683
- const usageEl = document.getElementById('measuredUsage');
684
- const usage = summary.usage;
685
- if (usageEl) usageEl.innerText = usage
686
- ? `${currentLang === 'pt' ? 'Uso reportado (ranking de contexto)' : 'Reported usage (context ranking)'}: ${usage.inputTokens ?? (currentLang === 'pt' ? 'não informado' : 'not informed')}/${usage.outputTokens ?? (currentLang === 'pt' ? 'não informado' : 'not informed')} tokens; ${usage.newModelCalls} calls; USD ${usage.reportedCostUsd ?? (currentLang === 'pt' ? 'não informado' : 'not informed')} (${usage.costedRequests}/${usage.newModelCalls} cost coverage); ${usage.eventsWithUsage}/${usage.eventsWithUsage + usage.eventsWithoutUsage} events with usage. Validated responses only; unreported retries/failures excluded.`
687
- : (currentLang === 'pt' ? 'Uso reportado: não informado.' : 'Reported usage: not informed.');
688
- const comparisonTitle = document.getElementById('comparisonTitle');
689
- if (comparisonTitle) comparisonTitle.innerText = currentLang === 'pt' ? 'Comparação medida por tarefa' : 'Measured task comparison';
690
- const comparisonEl = document.getElementById('measuredComparison');
691
- if (comparisonEl) comparisonEl.textContent = summary.latestComparison?.summaryMessage
692
- || (currentLang === 'pt' ? 'Nenhum par de execuções importado. Economia não medida.' : 'No paired execution imported. Savings are not measured.');
693
-
694
- const latEl = document.getElementById('metricLatency');
695
- if (latEl) latEl.innerText = summary.avgLatencyMs ? `${summary.avgLatencyMs} ms` : '-- ms';
696
-
697
- const latSubEl = document.getElementById('metricLatencySub');
698
- if (latSubEl) latSubEl.innerText = summary.p95LatencyMs ? `p95: ${summary.p95LatencyMs} ms` : 'p95: -- ms';
699
-
700
- const guardEl = document.getElementById('metricGuardCount');
701
- if (guardEl) guardEl.innerText = summary.guardStats?.totalChecked || 0;
702
-
703
- const guardSubEl = document.getElementById('metricGuardSub');
704
- if (guardSubEl) guardSubEl.innerText = currentLang === 'pt'
705
- ? `${summary.guardStats?.blocked || 0} bloqueados`
706
- : `${summary.guardStats?.blocked || 0} blocked`;
707
-
708
- const patchEl = document.getElementById('metricPatchCount');
709
- if (patchEl) patchEl.innerText = summary.patchStats?.totalAudited || 0;
710
-
711
- const patchSubEl = document.getElementById('metricPatchSub');
712
- if (patchSubEl) patchSubEl.innerText = currentLang === 'pt'
713
- ? `Risco médio: ${summary.patchStats?.avgRiskScore || 0}/100`
714
- : `Avg risk: ${summary.patchStats?.avgRiskScore || 0}/100`;
715
-
716
- const gateBlockedEl = document.getElementById('gateBlockedVal');
717
- if (gateBlockedEl) gateBlockedEl.innerText = currentLang === 'pt'
718
- ? `${summary.guardStats?.blocked || 0} bloqueados (${summary.guardStats?.allowed || 0} seguros)`
719
- : `${summary.guardStats?.blocked || 0} blocked (${summary.guardStats?.allowed || 0} safe)`;
720
-
721
- const gateEscalatedEl = document.getElementById('gateEscalatedVal');
722
- if (gateEscalatedEl) gateEscalatedEl.innerText = currentLang === 'pt'
723
- ? `${summary.patchStats?.escalated || 0} escalados (${summary.patchStats?.approved || 0} aprovados)`
724
- : `${summary.patchStats?.escalated || 0} escalated (${summary.patchStats?.approved || 0} approved)`;
725
-
726
- const gateRedEl = document.getElementById('gateAvgReductionVal');
727
- if (gateRedEl) gateRedEl.innerText = summary.contextStats?.avgReductionPct ? `${summary.contextStats.avgReductionPct}%` : '--';
728
-
729
- // Stacked Bar
730
- const total = summary.totalEvents || 1;
731
- const rankCount = summary.byType?.context_rank || 0;
732
- const guardCount = summary.byType?.guard_check || 0;
733
- const patchCount = summary.byType?.patch_review || 0;
734
- const lintCount = summary.byType?.lint_semantic || 0;
735
-
736
- const pRank = Math.round((rankCount / total) * 100);
737
- const pGuard = Math.round((guardCount / total) * 100);
738
- const pPatch = Math.round((patchCount / total) * 100);
739
- const pLint = Math.round((lintCount / total) * 100);
740
-
741
- const barRank = document.getElementById('barRank');
742
- if (barRank) barRank.style.width = `${pRank}%`;
743
- const barGuard = document.getElementById('barGuard');
744
- if (barGuard) barGuard.style.width = `${pGuard}%`;
745
- const barPatch = document.getElementById('barPatch');
746
- if (barPatch) barPatch.style.width = `${pPatch}%`;
747
- const barLint = document.getElementById('barLint');
748
- if (barLint) barLint.style.width = `${pLint}%`;
749
-
750
- const pctRank = document.getElementById('pctRank');
751
- if (pctRank) pctRank.innerText = `${pRank}%`;
752
- const pctGuard = document.getElementById('pctGuard');
753
- if (pctGuard) pctGuard.innerText = `${pGuard}%`;
754
- const pctPatch = document.getElementById('pctPatch');
755
- if (pctPatch) pctPatch.innerText = `${pPatch}%`;
756
- const pctLint = document.getElementById('pctLint');
757
- if (pctLint) pctLint.innerText = `${pLint}%`;
758
-
759
- const distSummary = document.getElementById('distSummaryText');
760
- if (distSummary) distSummary.innerText = currentLang === 'pt'
761
- ? `${summary.totalEvents} requisições totais registradas`
762
- : `${summary.totalEvents} total requests logged`;
763
- }
764
-
765
- if (events && Array.isArray(events)) {
766
- eventsList = events;
767
- renderEventsTable(events);
768
- }
769
- } catch (err) {
770
- console.error('Error updating telemetry UI:', err);
771
- }
772
- }
773
-
774
- function renderEventsTable(events) {
775
- const tbody = document.getElementById('eventsTableBody');
776
- if (!events || events.length === 0) {
777
- const emptyMsg = currentLang === 'pt'
778
- ? 'Nenhum evento de telemetria registrado ainda. Execute um prompt no Codex Desktop ou Antigravity para ver os dados ao vivo aqui!'
779
- : 'No telemetry events recorded yet. Run a prompt in Codex Desktop or Antigravity to see live data here!';
780
- tbody.innerHTML = `<tr id="emptyEventsRow"><td colspan="7" class="py-8 text-center text-slate-500">${emptyMsg}</td></tr>`;
781
- document.getElementById('feedCountText').innerText = currentLang === 'pt' ? '0 eventos gravados' : '0 events recorded';
782
- return;
783
- }
784
-
785
- document.getElementById('feedCountText').innerText = currentLang === 'pt'
786
- ? `${events.length} eventos recentes`
787
- : `${events.length} latest events`;
788
-
789
- tbody.innerHTML = events.map(e => {
790
- const time = new Date(e.timestamp).toLocaleTimeString();
791
- let typeBadge = '';
792
- let detail = '';
793
- let outcome = '';
794
- let statusBadge = '';
795
-
796
- // Platform / Agent metadata (Codex, Claude, Gemini, Antigravity, Cursor, Trae, etc.)
797
- const rawPlatform = e.platform || (
798
- e.agent ? (e.agent.charAt(0).toUpperCase() + e.agent.slice(1)) :
799
- (e.type === 'proxy_turn' ? 'Proxy' : 'Antigravity')
800
- );
801
-
802
- let platformIcon = '🤖';
803
- let platformBadgeStyle = 'bg-slate-800 text-slate-200 border-slate-700';
804
-
805
- const pLower = rawPlatform.toLowerCase();
806
- if (pLower.includes('codex')) {
807
- platformIcon = '⚡';
808
- platformBadgeStyle = 'bg-emerald-500/10 text-emerald-300 border-emerald-500/30';
809
- } else if (pLower.includes('claude')) {
810
- platformIcon = '🧠';
811
- platformBadgeStyle = 'bg-amber-500/10 text-amber-300 border-amber-500/30';
812
- } else if (pLower.includes('gemini')) {
813
- platformIcon = '💎';
814
- platformBadgeStyle = 'bg-blue-500/10 text-blue-300 border-blue-500/30';
815
- } else if (pLower.includes('antigravity')) {
816
- platformIcon = '🚀';
817
- platformBadgeStyle = 'bg-purple-500/10 text-purple-300 border-purple-500/30';
818
- } else if (pLower.includes('cursor')) {
819
- platformIcon = '🎯';
820
- platformBadgeStyle = 'bg-cyan-500/10 text-cyan-300 border-cyan-500/30';
821
- } else if (pLower.includes('trae')) {
822
- platformIcon = '🔮';
823
- platformBadgeStyle = 'bg-indigo-500/10 text-indigo-300 border-indigo-500/30';
824
- } else if (pLower.includes('windsurf')) {
825
- platformIcon = '🌊';
826
- platformBadgeStyle = 'bg-teal-500/10 text-teal-300 border-teal-500/30';
827
- } else if (pLower.includes('roo')) {
828
- platformIcon = '🦘';
829
- platformBadgeStyle = 'bg-rose-500/10 text-rose-300 border-rose-500/30';
830
- } else if (pLower.includes('cline')) {
831
- platformIcon = '🤖';
832
- platformBadgeStyle = 'bg-violet-500/10 text-violet-300 border-violet-500/30';
833
- } else if (pLower.includes('continue')) {
834
- platformIcon = '⏩';
835
- platformBadgeStyle = 'bg-orange-500/10 text-orange-300 border-orange-500/30';
836
- } else if (pLower.includes('opencode')) {
837
- platformIcon = '🌐';
838
- platformBadgeStyle = 'bg-lime-500/10 text-lime-300 border-lime-500/30';
839
- } else if (pLower.includes('vscode') || pLower.includes('vs code')) {
840
- platformIcon = '🔷';
841
- platformBadgeStyle = 'bg-sky-500/10 text-sky-300 border-sky-500/30';
842
- } else if (pLower.includes('cli') || pLower.includes('terminal')) {
843
- platformIcon = '💻';
844
- platformBadgeStyle = 'bg-slate-800 text-slate-300 border-slate-700';
845
- }
846
-
847
- const platformCell = `
848
- <span class="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md border font-semibold text-xs font-mono ${platformBadgeStyle} whitespace-nowrap shadow-sm">
849
- <span>${platformIcon}</span>
850
- <span>${escapeHtml(rawPlatform)}</span>
851
- </span>
852
- `;
853
-
854
- // Harness & Provider metadata
855
- const harnessName = e.harness || (
856
- e.type === 'context_rank' ? 'Context Ranker' :
857
- e.type === 'guard_check' ? 'Tool Guard' :
858
- e.type === 'patch_review' ? 'Patch Reviewer' :
859
- e.type === 'tool_rank' ? 'Tool Ranker' :
860
- e.type === 'proxy_turn' ? `Proxy (${e.agent || 'gateway'})` :
861
- 'Semantic Linter'
862
- );
863
- const providerName = (e.provider || 'typesafe').toLowerCase();
864
-
865
- let provBadgeClass = 'bg-slate-800 text-slate-300 border-slate-700';
866
- if (providerName.includes('vercel')) {
867
- provBadgeClass = 'bg-cyan-500/10 text-cyan-300 border-cyan-500/30';
868
- } else if (providerName.includes('typesafe')) {
869
- provBadgeClass = 'bg-purple-500/10 text-purple-300 border-purple-500/30';
870
- } else if (providerName.includes('openrouter')) {
871
- provBadgeClass = 'bg-blue-500/10 text-blue-300 border-blue-500/30';
872
- } else if (providerName.includes('offline')) {
873
- provBadgeClass = 'bg-amber-500/10 text-amber-300 border-amber-500/30';
874
- }
875
-
876
- const harnessCell = `
877
- <div class="flex flex-col">
878
- <span class="font-bold text-slate-200 text-[11px] whitespace-nowrap">${escapeHtml(harnessName)}</span>
879
- <span class="inline-block mt-0.5 px-1.5 py-0.5 text-[9px] rounded border font-mono ${provBadgeClass} w-max uppercase tracking-wider">
880
- ${escapeHtml(providerName)}
881
- </span>
882
- </div>
883
- `;
884
-
885
- if (e.type === 'usage_comparison') {
886
- typeBadge = '<span class="px-2 py-0.5 rounded bg-cyan-500/10 text-cyan-400">USAGE_COMPARISON</span>';
887
- const comparedHarness = e.comparison?.baseline?.runs?.[0]?.harness;
888
- detail = `<span class="text-slate-300">${escapeHtml(e.comparison?.taskId || '')}${comparedHarness ? ` (${escapeHtml(comparedHarness)})` : ''}</span>`;
889
- const deltaLabel = e.comparison?.agentTokenDelta == null
890
- ? (currentLang === 'pt' ? 'não medida' : 'not measured')
891
- : `${e.comparison.agentTokenDelta} token delta (agent scope)`;
892
- outcome = `<span class="text-cyan-300">${escapeHtml(deltaLabel)}</span>`;
893
- statusBadge = '<span class="text-slate-400">IMPORTED PAIR</span>';
894
- } else if (e.type === 'context_rank') {
895
- typeBadge = '<span class="px-2 py-0.5 rounded bg-purple-500/10 text-purple-400 border border-purple-500/20 font-bold">CONTEXT_RANK</span>';
896
- detail = `<span class="text-slate-300 truncate max-w-xs block" title="${escapeHtml(e.task)}">${escapeHtml(e.task || (currentLang === 'pt' ? 'Ranqueamento de contexto' : 'File context ranking'))}</span>`;
897
- outcome = `<span class="text-purple-300 font-semibold">${e.selectedFiles} selected / ${e.initialCandidates} found ${currentLang === 'pt' ? 'arquivos' : 'files'} (-${e.reductionPct}%)</span>`;
898
- statusBadge = `<span class="px-2 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20">${currentLang === 'pt' ? 'RANQUEADO' : 'RANKED'}</span>`;
899
- } else if (e.type === 'guard_check') {
900
- typeBadge = '<span class="px-2 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20 font-bold">TOOL_GUARD</span>';
901
- detail = `<code class="text-slate-300 truncate max-w-xs block text-[11px]" title="${escapeHtml(e.command)}">${escapeHtml(e.command)}</code>`;
902
- outcome = `<span class="${e.allowed ? 'text-emerald-400' : 'text-red-400'}">${e.category} (${e.riskLevel})</span>`;
903
- statusBadge = e.allowed
904
- ? `<span class="px-2 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20">${currentLang === 'pt' ? 'PERMITIDO' : 'ALLOWED'}</span>`
905
- : `<span class="px-2 py-0.5 rounded bg-red-500/10 text-red-400 border border-red-500/20 font-bold animate-pulse">${currentLang === 'pt' ? 'BLOQUEADO' : 'BLOCKED'}</span>`;
906
- } else if (e.type === 'patch_review') {
907
- typeBadge = '<span class="px-2 py-0.5 rounded bg-blue-500/10 text-blue-400 border border-blue-500/20 font-bold">PATCH_REVIEW</span>';
908
- detail = `<span class="text-slate-300">${e.filesCount} ${currentLang === 'pt' ? 'arquivo(s)' : 'file(s)'} (+${e.additions}/-${e.deletions})</span>`;
909
- outcome = `<span class="text-slate-300 font-semibold">${currentLang === 'pt' ? 'Risco' : 'Risk'}: ${e.riskScore}/100</span>`;
910
- statusBadge = e.status === 'APPROVED'
911
- ? `<span class="px-2 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20">${currentLang === 'pt' ? 'APROVADO' : 'APPROVED'}</span>`
912
- : `<span class="px-2 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20">${currentLang === 'pt' ? 'ESCALADO' : 'ESCALATED'}</span>`;
913
- } else if (e.type === 'tool_rank') {
914
- typeBadge = '<span class="px-2 py-0.5 rounded bg-indigo-500/10 text-indigo-400 border border-indigo-500/20 font-bold">TOOL_RANK</span>';
915
- detail = `<span class="text-slate-300 truncate max-w-xs block" title="${escapeHtml(e.task)}">${escapeHtml(e.task || 'Tool pruning')}</span>`;
916
- outcome = `<span class="text-indigo-300 font-semibold">${e.selectedTools}/${e.initialTools} tools (-${e.reductionPct}%)</span>`;
917
- statusBadge = `<span class="px-2 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20">${currentLang === 'pt' ? 'OTIMIZADO' : 'PRUNED'}</span>`;
918
- } else if (e.type === 'proxy_turn') {
919
- typeBadge = `<span class="px-2 py-0.5 rounded bg-cyan-500/10 text-cyan-400 border border-cyan-500/20 font-bold">PROXY_${escapeHtml((e.agent || 'GATEWAY').toUpperCase())}</span>`;
920
- detail = `<span class="text-slate-300 font-mono text-[11px]">${e.tool ? `tool: ${escapeHtml(e.tool)}` : 'turn routing'}</span>`;
921
- outcome = `<span class="text-cyan-300 font-semibold">Mode: ${escapeHtml(e.mode?.toUpperCase() || 'PASSTHROUGH')}</span>`;
922
- statusBadge = (e.mode === 'forced' || e.mode === 'hint')
923
- ? `<span class="px-2 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20">${currentLang === 'pt' ? 'ROTEADO' : 'ROUTED'}</span>`
924
- : `<span class="px-2 py-0.5 rounded bg-slate-500/10 text-slate-400 border border-slate-500/20">PASS</span>`;
925
- } else {
926
- typeBadge = '<span class="px-2 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 font-bold">LINT_SEMANTIC</span>';
927
- detail = `<span class="text-slate-300">${e.violationsCount || 0} ${currentLang === 'pt' ? 'violações' : 'violations'}</span>`;
928
- outcome = `<span class="text-slate-300">${e.status}</span>`;
929
- statusBadge = e.passed
930
- ? `<span class="px-2 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20">${currentLang === 'pt' ? 'APROVADO' : 'PASSED'}</span>`
931
- : `<span class="px-2 py-0.5 rounded bg-red-500/10 text-red-400 border border-red-500/20">${currentLang === 'pt' ? 'VIOLAÇÕES' : 'VIOLATIONS'}</span>`;
932
- }
933
-
934
- return `<tr class="hover:bg-slate-800/40">
935
- <td class="py-2.5 px-3 text-slate-400 whitespace-nowrap">${time}</td>
936
- <td class="py-2.5 px-3 whitespace-nowrap">${platformCell}</td>
937
- <td class="py-2.5 px-3 whitespace-nowrap">${harnessCell}</td>
938
- <td class="py-2.5 px-3">${typeBadge}</td>
939
- <td class="py-2.5 px-3">${detail}</td>
940
- <td class="py-2.5 px-3">${outcome}</td>
941
- <td class="py-2.5 px-3 text-slate-400 whitespace-nowrap">${e.latencyMs || 0}ms</td>
942
- <td class="py-2.5 px-3">${statusBadge}</td>
943
- </tr>`;
944
- }).join('');
945
- }
946
-
947
- function escapeHtml(str) {
948
- if (!str) return '';
949
- return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
950
- }
951
-
952
- // Connect to SSE Live Stream
953
- function initLiveStream() {
954
- try {
955
- const evtSource = new EventSource('/api/live');
956
- evtSource.onmessage = function(event) {
957
- try {
958
- const data = JSON.parse(event.data);
959
- if (data.type === 'init') {
960
- updateTelemetryUi(data.summary, data.events);
961
- } else if (data.type === 'event') {
962
- if (data.event && data.event.id) {
963
- const existingIdx = eventsList.findIndex(e => e.id === data.event.id);
964
- if (existingIdx >= 0) {
965
- eventsList[existingIdx] = data.event;
966
- } else {
967
- eventsList.unshift(data.event);
968
- if (eventsList.length > 100) eventsList.pop();
969
- }
970
- }
971
- updateTelemetryUi(data.summary, eventsList);
972
- }
973
- } catch (e) {
974
- // Non-JSON ping
975
- }
976
- };
977
-
978
- evtSource.onopen = function() {
979
- const statusEl = document.getElementById('liveStreamStatus');
980
- if (statusEl) {
981
- statusEl.innerText = currentLang === 'pt' ? '⚡ Fluxo ao Vivo: Conectado' : '⚡ Live Stream: Connected';
982
- statusEl.className = 'text-emerald-400';
983
- }
984
- };
985
-
986
- evtSource.onerror = function() {
987
- const statusEl = document.getElementById('liveStreamStatus');
988
- if (statusEl) {
989
- statusEl.innerText = currentLang === 'pt' ? '🔄 Reconectando...' : '🔄 Reconnecting...';
990
- statusEl.className = 'text-amber-400';
991
- }
992
- };
993
- } catch {
994
- // Fallback handled by auto-sync below
995
- }
996
- }
997
-
998
- async function refreshData() {
999
- try {
1000
- const nocache = `_t=${Date.now()}`;
1001
- const [sumRes, evRes] = await Promise.all([
1002
- fetch(`/api/summary?${nocache}`),
1003
- fetch(`/api/events?limit=50&${nocache}`)
1004
- ]);
1005
- if (sumRes.ok && evRes.ok) {
1006
- const summary = await sumRes.json();
1007
- const events = await evRes.json();
1008
- updateTelemetryUi(summary, events);
1009
- }
1010
- } catch (err) {
1011
- console.error('Failed to fetch telemetry data:', err);
1012
- }
1013
- }
1014
-
1015
- // Continuous background sync (every 2.5s) to guarantee real-time updates across multiple processes
1016
- setInterval(refreshData, 2500);
1017
-
1018
- // Sync immediately whenever the developer switches back to the dashboard tab
1019
- document.addEventListener('visibilitychange', () => {
1020
- if (!document.hidden) refreshData();
1021
- });
1022
- window.addEventListener('focus', refreshData);
1023
-
1024
- async function clearHistory() {
1025
- const confirmMsg = currentLang === 'pt'
1026
- ? 'Deseja limpar todo o histórico de telemetria gravado?'
1027
- : 'Clear all recorded telemetry history?';
1028
- if (!confirm(confirmMsg)) return;
1029
- try {
1030
- const res = await fetch('/api/clear', { method: 'POST' });
1031
- if (res.ok) {
1032
- await refreshData();
1033
- }
1034
- } catch (err) {
1035
- alert(currentLang === 'pt' ? 'Falha ao limpar histórico' : 'Failed to clear history');
1036
- }
1037
- }
1038
-
1039
- // ROI Calculator Logic
1040
- function updateCalculator() {
1041
- const teamSize = parseInt(document.getElementById('teamSize').value, 10);
1042
- const promptsPerDay = parseInt(document.getElementById('promptsPerDay').value, 10);
1043
- const costPerMillion = parseFloat(document.getElementById('modelSelect').value);
1044
-
1045
- document.getElementById('teamSizeVal').innerText = `${teamSize} devs`;
1046
- document.getElementById('promptsVal').innerText = `${promptsPerDay} prompts`;
1047
-
1048
- const workingDays = 22;
1049
- const totalPromptsMonth = teamSize * promptsPerDay * workingDays;
1050
-
1051
- const avgTokensWithout = 85000;
1052
- const avgTokensWith = 6500;
1053
-
1054
- const monthlyTokensWithout = (totalPromptsMonth * avgTokensWithout) / 1000000;
1055
- const monthlyTokensWith = (totalPromptsMonth * avgTokensWith) / 1000000;
1056
-
1057
- const costWithout = monthlyTokensWithout * costPerMillion;
1058
- const costWith = monthlyTokensWith * costPerMillion;
1059
- const savingsMonth = costWithout - costWith;
1060
- const savingsYear = savingsMonth * 12;
1061
-
1062
- document.getElementById('tokensWithoutVal').innerText = `${monthlyTokensWithout.toFixed(1)}M tokens`;
1063
- document.getElementById('tokensWithVal').innerText = `${monthlyTokensWith.toFixed(1)}M tokens (-92.4%)`;
1064
-
1065
- document.getElementById('costWithoutVal').innerText = `$${costWithout.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
1066
- document.getElementById('costWithVal').innerText = `$${costWith.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
1067
-
1068
- document.getElementById('savingsMonthVal').innerText = `$${savingsMonth.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
1069
- document.getElementById('savingsYearVal').innerText = `$${savingsYear.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
1070
- }
1071
-
1072
- let updateNoticeKey = null;
1073
- const dismissedUpdates = new Set();
1074
- document.getElementById('dismissUpdate').addEventListener('click', () => {
1075
- if (updateNoticeKey) {
1076
- dismissedUpdates.add(updateNoticeKey);
1077
- try { localStorage.setItem('jev_update_dismissed', updateNoticeKey); } catch { /* Storage may be disabled. */ }
1078
- }
1079
- document.getElementById('updateBanner').classList.add('hidden');
1080
- });
1081
- function renderUpdate(info) {
1082
- const banner = document.getElementById('updateBanner');
1083
- updateNoticeKey = `${info.currentVersion}:${info.status}:${info.latestVersion}`;
1084
- let dismissed = dismissedUpdates.has(updateNoticeKey);
1085
- try { dismissed ||= localStorage.getItem('jev_update_dismissed') === updateNoticeKey; } catch { /* Storage may be disabled. */ }
1086
- banner.classList.toggle('hidden', !info.notice || dismissed);
1087
- document.getElementById('updateNotice').textContent = info.notice || '';
1088
- const release = document.getElementById('updateRelease');
1089
- release.classList.toggle('hidden', !info.releaseUrl);
1090
- // Links are generated from validated versions by our server, never from release metadata.
1091
- release.href = info.releaseUrl || 'https://github.com/celolopes/jev-dev-harness/releases';
1092
- }
1093
- async function checkUpdates() {
1094
- try {
1095
- const res = await fetch('/api/update-status');
1096
- if (res.ok) {
1097
- const info = await res.json();
1098
- renderUpdate(info);
1099
- } else throw new Error('Update status unavailable');
1100
- } catch {
1101
- renderUpdate({ status: 'unavailable', latestVersion: null, notice: "Jev update check unavailable. Run 'jev-dev version' to retry; update status is unknown." });
1102
- }
1103
- }
1104
-
1105
- // Init & Language Auto-detection
1106
- const urlParams = new URLSearchParams(window.location.search);
1107
- const queryLang = urlParams.get('lang');
1108
- const savedLang = localStorage.getItem('jev_dashboard_lang');
1109
- const browserLang = (navigator.language || '').toLowerCase().startsWith('pt') ? 'pt' : 'en';
1110
- setLanguage(queryLang || savedLang || browserLang);
1111
-
1112
- if (urlParams.get('tab') === 'roi' || window.location.hash === '#roi') {
1113
- switchTab('roi');
1114
- }
1115
-
1116
- refreshData();
1117
- initLiveStream();
1118
- checkUpdates();
1119
- setInterval(checkUpdates, 60 * 60 * 1000);
1120
- </script>
1121
- </body>
1122
- </html>
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Jev Developer Harness — Live Telemetry & ROI Dashboard</title>
7
+ <link rel="icon" type="image/png" href="/assets/logo.png">
8
+ <script src="https://www.gstatic.com/antigravity/web/dev/tailwindcss.min.js"></script>
9
+ <style>
10
+ @keyframes pulse-slow {
11
+ 0%, 100% { opacity: 1; }
12
+ 50% { opacity: 0.5; }
13
+ }
14
+ .animate-pulse-slow {
15
+ animation: pulse-slow 2.5s infinite ease-in-out;
16
+ }
17
+ .tab-active {
18
+ background-color: #3b82f6;
19
+ color: #ffffff;
20
+ box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.39);
21
+ }
22
+ .tab-inactive {
23
+ background-color: transparent;
24
+ color: #94a3b8;
25
+ }
26
+ .tab-inactive:hover {
27
+ color: #f1f5f9;
28
+ background-color: #1e293b;
29
+ }
30
+ </style>
31
+ </head>
32
+ <body class="bg-slate-950 text-slate-100 antialiased min-h-screen p-4 md:p-8 font-sans selection:bg-blue-500 selection:text-white">
33
+
34
+ <!-- Main Container -->
35
+ <div class="max-w-6xl mx-auto space-y-6">
36
+
37
+ <!-- Top Navigation Bar & Brand Header -->
38
+ <header class="border border-slate-800 bg-slate-900/90 backdrop-blur-md rounded-2xl p-5 md:p-6 shadow-2xl relative overflow-hidden flex flex-col md:flex-row items-start md:items-center justify-between gap-4">
39
+ <div class="flex items-center gap-3.5">
40
+ <img src="/assets/logo.png" alt="Jev Developer Harness Logo" class="w-12 h-12 rounded-xl object-cover border border-blue-500/40 shadow-lg shadow-blue-500/25 shrink-0" />
41
+ <div>
42
+ <div class="flex items-center gap-2">
43
+ <h1 class="text-xl md:text-2xl font-extrabold tracking-tight text-white font-mono">
44
+ jev-dev-harness
45
+ </h1>
46
+ <span class="text-[10px] font-mono uppercase px-2 py-0.5 rounded-full bg-blue-500/10 border border-blue-500/30 text-blue-400 font-bold">
47
+ v0.2.7
48
+ </span>
49
+ </div>
50
+ <p class="text-xs text-slate-400" data-i18n="header_subtitle">
51
+ Runtime Developer Harness & Live Telemetry for AI Coding Agents
52
+ </p>
53
+ </div>
54
+ </div>
55
+
56
+ <!-- Header Controls: Language Toggle & Tab Switcher -->
57
+ <div class="flex flex-wrap items-center gap-2.5">
58
+ <!-- Language Selector Toggle -->
59
+ <div class="flex items-center bg-slate-950/80 p-1 rounded-xl border border-slate-800 text-xs font-mono">
60
+ <button id="langBtnEn" onclick="setLanguage('en')" class="px-2.5 py-1.5 rounded-lg text-xs font-semibold font-mono transition-all cursor-pointer flex items-center gap-1.5" title="English">
61
+ <span>🇺🇸</span><span>EN</span>
62
+ </button>
63
+ <button id="langBtnPt" onclick="setLanguage('pt')" class="px-2.5 py-1.5 rounded-lg text-xs font-semibold font-mono transition-all cursor-pointer flex items-center gap-1.5" title="Português (Brasil)">
64
+ <span>🇧🇷</span><span>PT</span>
65
+ </button>
66
+ </div>
67
+
68
+ <!-- Tab Switcher -->
69
+ <div class="flex items-center gap-1.5 bg-slate-950/80 p-1 rounded-xl border border-slate-800">
70
+ <button id="tabBtnLive" onclick="switchTab('live')" class="px-3.5 py-1.5 rounded-lg text-xs font-semibold font-mono transition-all flex items-center gap-2 tab-active cursor-pointer">
71
+ <span class="w-2 h-2 rounded-full bg-emerald-400 animate-pulse"></span>
72
+ <span data-i18n="tab_live">Live Telemetry</span>
73
+ </button>
74
+ <button id="tabBtnRoi" onclick="switchTab('roi')" class="px-3.5 py-1.5 rounded-lg text-xs font-semibold font-mono transition-all flex items-center gap-2 tab-inactive cursor-pointer">
75
+ <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"></path></svg>
76
+ <span data-i18n="tab_roi">ROI & Simulator</span>
77
+ </button>
78
+ </div>
79
+ </div>
80
+ </header>
81
+
82
+ <!-- Update Available Notification Banner -->
83
+ <div id="updateBanner" class="hidden p-3.5 rounded-xl bg-gradient-to-r from-purple-950/60 to-blue-950/60 border border-purple-500/40 text-xs font-mono flex flex-col sm:flex-row sm:items-center justify-between gap-3 shadow-lg shadow-purple-950/30">
84
+ <p id="updateNotice" role="status" class="text-slate-200 whitespace-pre-line"></p>
85
+ <a id="updateRelease" href="https://github.com/celolopes/jev-dev-harness/releases" target="_blank" rel="noopener noreferrer" class="px-3 py-1.5 rounded-lg bg-purple-600 hover:bg-purple-500 active:scale-95 text-white font-bold transition-all text-center self-start sm:self-auto cursor-pointer" data-i18n="update_view">
86
+ View Release
87
+ </a>
88
+ <button id="dismissUpdate" type="button" aria-label="Dismiss update notice" class="text-slate-300 px-2 py-1">×</button>
89
+ </div>
90
+
91
+ <!-- ============================================================== -->
92
+ <!-- TAB 1: LIVE TELEMETRY (Real Data from Codex / Antigravity / Claude) -->
93
+ <!-- ============================================================== -->
94
+ <div id="tabContentLive" class="space-y-6">
95
+
96
+ <!-- Active Gateway / Agent Status Banner (Inspired by Jev Gateway) -->
97
+ <div class="border border-emerald-500/30 bg-emerald-950/20 backdrop-blur-md rounded-2xl p-5 md:p-6 shadow-xl relative overflow-hidden">
98
+ <div class="flex flex-col md:flex-row items-start md:items-center justify-between gap-4">
99
+ <div class="space-y-1.5">
100
+ <div class="inline-flex items-center gap-2 font-mono text-xs text-emerald-400 font-semibold bg-emerald-500/10 px-2.5 py-1 rounded-full border border-emerald-500/20" data-i18n="status_banner_badge">
101
+ <span class="w-2 h-2 rounded-full bg-emerald-400 animate-ping"></span>
102
+ Codex Desktop • Antigravity • Claude Code
103
+ </div>
104
+ <div class="flex items-center gap-2">
105
+ <svg class="w-6 h-6 text-emerald-400 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"></path></svg>
106
+ <h2 class="text-2xl font-bold text-white tracking-tight" data-i18n="status_banner_title">Active Telemetry & Protection</h2>
107
+ </div>
108
+ <p id="liveStatusSubtext" class="text-xs md:text-sm text-slate-300">
109
+ Jev recorded <strong id="liveDecidedCount" class="text-emerald-300">0</strong> requests across your coding agents.
110
+ </p>
111
+ <div class="text-[11px] text-slate-400 font-mono flex flex-wrap items-center gap-2 pt-1">
112
+ <span><span data-i18n="status_model">Model:</span> <span class="text-slate-200">TypeSafe Jev System One</span></span>
113
+ <span>•</span>
114
+ <span id="liveStreamStatus" class="text-emerald-400" data-i18n="status_stream">⚡ Live Stream: Connected</span>
115
+ <span>•</span>
116
+ <span><span data-i18n="status_store">Store:</span> <code class="text-slate-300">~/.jev-dev/telemetry.jsonl</code></span>
117
+ </div>
118
+ </div>
119
+
120
+ <div class="flex items-center gap-2 self-start md:self-auto">
121
+ <button onclick="clearHistory()" class="px-3.5 py-2 rounded-xl bg-slate-900 hover:bg-slate-800 border border-slate-700 text-slate-300 hover:text-white text-xs font-mono transition-all cursor-pointer" data-i18n="btn_clear">
122
+ Clear History
123
+ </button>
124
+ <button onclick="refreshData()" class="px-3.5 py-2 rounded-xl bg-emerald-600 hover:bg-emerald-500 text-white text-xs font-mono font-bold transition-all shadow-lg shadow-emerald-600/20 cursor-pointer" data-i18n="btn_refresh">
125
+ Refresh
126
+ </button>
127
+ </div>
128
+ </div>
129
+ </div>
130
+
131
+ <!-- Live Metric Cards Grid -->
132
+ <div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3">
133
+ <!-- Card 1: Requests -->
134
+ <div class="p-4 rounded-xl bg-slate-900 border border-slate-800 shadow-sm">
135
+ <div class="text-[11px] font-semibold text-slate-400 uppercase tracking-wider mb-1" data-i18n="card_ops_title">Agent Ops</div>
136
+ <div id="metricTotalEvents" class="text-2xl font-extrabold text-white font-mono">0</div>
137
+ <p class="text-[10px] text-slate-400 mt-1" data-i18n="card_ops_sub">Through harness</p>
138
+ </div>
139
+
140
+ <!-- Card 2: Token savings -->
141
+ <div class="p-4 rounded-xl bg-slate-900 border border-slate-800 shadow-sm">
142
+ <div class="text-[11px] font-semibold text-purple-400 uppercase tracking-wider mb-1" data-i18n="card_tokens_title">Token savings</div>
143
+ <div id="metricTokensSaved" class="text-2xl font-extrabold text-purple-300 font-mono">Not measured</div>
144
+ <p id="metricTokensSavedSub" class="text-[10px] text-slate-400 mt-1" data-i18n="card_tokens_sub">No measured baseline</p>
145
+ </div>
146
+
147
+ <!-- Card 3: Cash Saved -->
148
+ <div class="p-4 rounded-xl bg-slate-900 border border-slate-800 shadow-sm">
149
+ <div class="text-[11px] font-semibold text-emerald-400 uppercase tracking-wider mb-1" data-i18n="card_cash_title">Money savings</div>
150
+ <div id="metricDollarsSaved" class="text-2xl font-extrabold text-emerald-300 font-mono">Not measured</div>
151
+ <p class="text-[10px] text-slate-400 mt-1" data-i18n="card_cash_sub">No measured baseline</p>
152
+ </div>
153
+
154
+ <!-- Card 4: Jev Latency -->
155
+ <div class="p-4 rounded-xl bg-slate-900 border border-slate-800 shadow-sm">
156
+ <div class="text-[11px] font-semibold text-blue-400 uppercase tracking-wider mb-1" data-i18n="card_latency_title">Avg Latency</div>
157
+ <div id="metricLatency" class="text-2xl font-extrabold text-blue-300 font-mono">-- ms</div>
158
+ <p id="metricLatencySub" class="text-[10px] text-slate-400 mt-1">p95: -- ms</p>
159
+ </div>
160
+
161
+ <!-- Card 5: Tool Guard -->
162
+ <div class="p-4 rounded-xl bg-slate-900 border border-slate-800 shadow-sm">
163
+ <div class="text-[11px] font-semibold text-amber-400 uppercase tracking-wider mb-1" data-i18n="card_guard_title">Tool Guard</div>
164
+ <div id="metricGuardCount" class="text-2xl font-extrabold text-amber-300 font-mono">0</div>
165
+ <p id="metricGuardSub" class="text-[10px] text-slate-400 mt-1">0 blocked</p>
166
+ </div>
167
+
168
+ <!-- Card 6: Patch Audits -->
169
+ <div class="p-4 rounded-xl bg-slate-900 border border-slate-800 shadow-sm">
170
+ <div class="text-[11px] font-semibold text-rose-400 uppercase tracking-wider mb-1" data-i18n="card_patch_title">Patch Audits</div>
171
+ <div id="metricPatchCount" class="text-2xl font-extrabold text-rose-300 font-mono">0</div>
172
+ <p id="metricPatchSub" class="text-[10px] text-slate-400 mt-1">Avg risk: --/100</p>
173
+ </div>
174
+ </div>
175
+
176
+ <p id="measuredUsage" class="text-xs text-slate-400">Reported context-rank usage: not informed.</p>
177
+ <div class="border border-slate-800 bg-slate-900/90 rounded-2xl p-5 space-y-2">
178
+ <h3 class="text-sm font-bold text-white" id="comparisonTitle">Measured task comparison</h3>
179
+ <pre id="measuredComparison" class="whitespace-pre-wrap text-xs text-slate-300">No paired execution imported. Savings are not measured.</pre>
180
+ </div>
181
+ <!-- Distribution & Operations Breakdown (Mirroring Jev Gateway UI) -->
182
+ <div class="grid grid-cols-1 lg:grid-cols-12 gap-6">
183
+ <!-- What happened to each request -->
184
+ <div class="lg:col-span-7 border border-slate-800 bg-slate-900/90 rounded-2xl p-5 shadow-xl space-y-4">
185
+ <div class="flex items-center justify-between">
186
+ <h3 class="text-sm font-bold text-white uppercase tracking-wider font-mono" data-i18n="chart_title">What happened to each request</h3>
187
+ <span id="distSummaryText" class="text-xs text-slate-400 font-mono">0 total requests</span>
188
+ </div>
189
+
190
+ <!-- Stacked Bar Representation -->
191
+ <div class="w-full h-5 rounded-lg bg-slate-800 overflow-hidden flex" id="distStackedBar">
192
+ <div id="barRank" class="bg-purple-500 h-full transition-all" style="width: 0%" title="Context Ranker"></div>
193
+ <div id="barGuard" class="bg-amber-500 h-full transition-all" style="width: 0%" title="Tool Guard"></div>
194
+ <div id="barPatch" class="bg-blue-500 h-full transition-all" style="width: 0%" title="Patch Reviewer"></div>
195
+ <div id="barLint" class="bg-emerald-500 h-full transition-all" style="width: 0%" title="Semantic Linter"></div>
196
+ </div>
197
+
198
+ <!-- Legend -->
199
+ <div class="grid grid-cols-2 sm:grid-cols-4 gap-2 pt-2 text-xs font-mono">
200
+ <div class="flex items-center gap-2">
201
+ <span class="w-3 h-3 rounded bg-purple-500 flex-shrink-0"></span>
202
+ <span class="text-slate-300"><span data-i18n="legend_rank">Context Rank</span> (<span id="pctRank">0%</span>)</span>
203
+ </div>
204
+ <div class="flex items-center gap-2">
205
+ <span class="w-3 h-3 rounded bg-amber-500 flex-shrink-0"></span>
206
+ <span class="text-slate-300"><span data-i18n="legend_guard">Tool Guard</span> (<span id="pctGuard">0%</span>)</span>
207
+ </div>
208
+ <div class="flex items-center gap-2">
209
+ <span class="w-3 h-3 rounded bg-blue-500 flex-shrink-0"></span>
210
+ <span class="text-slate-300"><span data-i18n="legend_patch">Patch Audit</span> (<span id="pctPatch">0%</span>)</span>
211
+ </div>
212
+ <div class="flex items-center gap-2">
213
+ <span class="w-3 h-3 rounded bg-emerald-500 flex-shrink-0"></span>
214
+ <span class="text-slate-300"><span data-i18n="legend_lint">Semantic Lint</span> (<span id="pctLint">0%</span>)</span>
215
+ </div>
216
+ </div>
217
+ </div>
218
+
219
+ <!-- Protection & Interception Summary -->
220
+ <div class="lg:col-span-5 border border-slate-800 bg-slate-900/90 rounded-2xl p-5 shadow-xl space-y-3 flex flex-col justify-between">
221
+ <h3 class="text-sm font-bold text-white uppercase tracking-wider font-mono" data-i18n="verdicts_title">Safety & Gate Verdicts</h3>
222
+ <div class="space-y-2 text-xs font-mono">
223
+ <div class="flex justify-between items-center p-2 rounded-lg bg-slate-950/60 border border-slate-800">
224
+ <span class="text-slate-400" data-i18n="verdicts_cmd_label">Destructive Commands Blocked:</span>
225
+ <span id="gateBlockedVal" class="text-emerald-400 font-bold">0 safe</span>
226
+ </div>
227
+ <div class="flex justify-between items-center p-2 rounded-lg bg-slate-950/60 border border-slate-800">
228
+ <span class="text-slate-400" data-i18n="verdicts_patch_label">Patches Escalated / Blocked:</span>
229
+ <span id="gateEscalatedVal" class="text-amber-400 font-bold">0 escalated</span>
230
+ </div>
231
+ <div class="flex justify-between items-center p-2 rounded-lg bg-slate-950/60 border border-slate-800">
232
+ <span class="text-slate-400" data-i18n="verdicts_reduction_label">File selection reduction:</span>
233
+ <span id="gateAvgReductionVal" class="text-purple-400 font-bold">--</span>
234
+ </div>
235
+ </div>
236
+ <div class="text-[11px] text-slate-500 text-right" data-i18n="verdicts_engine">
237
+ Deterministic rule gates + Jev System One
238
+ </div>
239
+ </div>
240
+ </div>
241
+
242
+ <!-- Real-Time Activity Feed / Event Log -->
243
+ <div class="border border-slate-800 bg-slate-900/90 rounded-2xl p-5 shadow-xl space-y-4">
244
+ <div class="flex items-center justify-between">
245
+ <div class="flex items-center gap-2">
246
+ <span class="w-2 h-2 rounded-full bg-emerald-400 animate-ping"></span>
247
+ <h3 class="text-base font-bold text-white font-mono" data-i18n="stream_title">Live Operations Stream</h3>
248
+ </div>
249
+ <span class="text-xs text-slate-400 font-mono" id="feedCountText" data-i18n="stream_listening">Listening for agent tool calls...</span>
250
+ </div>
251
+
252
+ <div class="overflow-x-auto">
253
+ <table class="w-full text-left text-xs font-mono text-slate-300">
254
+ <thead class="text-[11px] uppercase bg-slate-950/80 text-slate-400 border-y border-slate-800">
255
+ <tr>
256
+ <th scope="col" class="py-2.5 px-3" data-i18n="th_time">Time</th>
257
+ <th scope="col" class="py-2.5 px-3" data-i18n="th_platform">Platform / Agent</th>
258
+ <th scope="col" class="py-2.5 px-3" data-i18n="th_harness">Harness / Engine</th>
259
+ <th scope="col" class="py-2.5 px-3" data-i18n="th_operation">Operation</th>
260
+ <th scope="col" class="py-2.5 px-3" data-i18n="th_target">Target / Detail</th>
261
+ <th scope="col" class="py-2.5 px-3" data-i18n="th_outcome">Outcome / Impact</th>
262
+ <th scope="col" class="py-2.5 px-3" data-i18n="th_speed">Speed</th>
263
+ <th scope="col" class="py-2.5 px-3" data-i18n="th_status">Status</th>
264
+ </tr>
265
+ </thead>
266
+ <tbody id="eventsTableBody" class="divide-y divide-slate-800/60">
267
+ <tr id="emptyEventsRow">
268
+ <td colspan="8" class="py-8 text-center text-slate-500" data-i18n="table_empty">
269
+ No telemetry events recorded yet. Run a prompt in Codex Desktop or Antigravity to see live data here!
270
+ </td>
271
+ </tr>
272
+ </tbody>
273
+ </table>
274
+ </div>
275
+ </div>
276
+
277
+ </div>
278
+
279
+ <!-- ============================================================== -->
280
+ <!-- TAB 2: ROI & BENCHMARK SIMULATOR -->
281
+ <!-- ============================================================== -->
282
+ <div id="tabContentRoi" class="space-y-6 hidden">
283
+
284
+ <!-- Interactive Calculator Section -->
285
+ <section class="border border-slate-800 bg-slate-900/90 rounded-2xl p-6 md:p-8 shadow-xl">
286
+ <div class="flex flex-col md:flex-row items-start md:items-center justify-between gap-4 pb-6 border-b border-slate-800">
287
+ <div>
288
+ <h2 class="text-xl font-bold text-white flex items-center gap-2">
289
+ <svg class="w-5 h-5 text-emerald-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
290
+ <span data-i18n="calc_title">Interactive ROI & Dollar Savings Calculator</span>
291
+ </h2>
292
+ <p class="text-xs md:text-sm text-slate-400" data-i18n="calc_subtitle">Hypothetical simulation using fixed assumptions (85,000 vs 6,500 tokens/prompt). Not measured telemetry or evidence of savings.</p>
293
+ </div>
294
+ <span class="px-3 py-1 rounded-full text-xs font-mono bg-emerald-500/10 text-emerald-300 border border-emerald-500/20" data-i18n="calc_badge">
295
+ Interactive Model
296
+ </span>
297
+ </div>
298
+
299
+ <div class="grid grid-cols-1 lg:grid-cols-12 gap-8 mt-6">
300
+ <!-- Sliders & Controls -->
301
+ <div class="lg:col-span-6 space-y-6">
302
+ <div>
303
+ <div class="flex justify-between items-center mb-2">
304
+ <label class="text-sm font-medium text-slate-300" data-i18n="calc_team_label">Team Size (Engineers with AI Agents)</label>
305
+ <span id="teamSizeVal" class="text-base font-bold text-purple-400 font-mono">10 devs</span>
306
+ </div>
307
+ <input id="teamSize" type="range" min="1" max="100" value="10" class="w-full h-2 bg-slate-700 rounded-lg appearance-none cursor-pointer accent-purple-500" oninput="updateCalculator()">
308
+ <div class="flex justify-between text-[11px] text-slate-500 mt-1 font-mono">
309
+ <span data-i18n="calc_team_solo">1 solo</span>
310
+ <span data-i18n="calc_team_team">10 team</span>
311
+ <span data-i18n="calc_team_squad">50 squad</span>
312
+ <span data-i18n="calc_team_enterprise">100 enterprise</span>
313
+ </div>
314
+ </div>
315
+
316
+ <div>
317
+ <div class="flex justify-between items-center mb-2">
318
+ <label class="text-sm font-medium text-slate-300" data-i18n="calc_prompts_label">Agent Prompts per Dev / Day</label>
319
+ <span id="promptsVal" class="text-base font-bold text-blue-400 font-mono">40 prompts</span>
320
+ </div>
321
+ <input id="promptsPerDay" type="range" min="10" max="150" step="5" value="40" class="w-full h-2 bg-slate-700 rounded-lg appearance-none cursor-pointer accent-blue-500" oninput="updateCalculator()">
322
+ <div class="flex justify-between text-[11px] text-slate-500 mt-1 font-mono">
323
+ <span data-i18n="calc_prompts_light">10 light</span>
324
+ <span data-i18n="calc_prompts_standard">40 standard</span>
325
+ <span data-i18n="calc_prompts_intense">80 intense</span>
326
+ <span data-i18n="calc_prompts_power">150 power user</span>
327
+ </div>
328
+ </div>
329
+
330
+ <div>
331
+ <label class="block text-sm font-medium text-slate-300 mb-2" data-i18n="calc_model_label">Target Agent Model & Pricing</label>
332
+ <select id="modelSelect" class="w-full bg-slate-800 border border-slate-700 rounded-xl px-4 py-2.5 text-sm text-slate-200 focus:outline-none focus:border-purple-500" onchange="updateCalculator()">
333
+ <option value="3.00">Claude 3.5 Sonnet ($3.00 / million input tokens)</option>
334
+ <option value="2.50">OpenAI GPT-4o ($2.50 / million input tokens)</option>
335
+ <option value="0.80">Claude 3.5 Haiku ($0.80 / million input tokens)</option>
336
+ <option value="0.14">DeepSeek V3 ($0.14 / million input tokens)</option>
337
+ </select>
338
+ </div>
339
+ </div>
340
+
341
+ <!-- Calculated Results Cards -->
342
+ <div class="lg:col-span-6 bg-slate-950/60 border border-slate-800/80 rounded-xl p-6 flex flex-col justify-between">
343
+ <div class="space-y-4">
344
+ <div class="flex items-center justify-between pb-3 border-b border-slate-800 text-xs">
345
+ <span class="text-slate-400" data-i18n="calc_tokens_without">Monthly Tokens Without Jev:</span>
346
+ <span id="tokensWithoutVal" class="font-mono text-slate-300 font-semibold">748M tokens</span>
347
+ </div>
348
+ <div class="flex items-center justify-between pb-3 border-b border-slate-800 text-xs">
349
+ <span class="text-slate-400" data-i18n="calc_tokens_with">Monthly Tokens With Jev (Surgical):</span>
350
+ <span id="tokensWithVal" class="font-mono text-purple-300 font-semibold">57M tokens (-92.4%)</span>
351
+ </div>
352
+ <div class="grid grid-cols-2 gap-3 pt-2">
353
+ <div class="p-3 rounded-lg bg-red-950/20 border border-red-900/30">
354
+ <span class="text-[11px] uppercase font-bold text-red-400 block" data-i18n="calc_cost_without">Cost Without Jev</span>
355
+ <span id="costWithoutVal" class="text-xl font-bold font-mono text-red-200">$2,244.00</span>
356
+ <span class="text-[10px] text-slate-400 block mt-0.5" data-i18n="calc_per_month">/ month</span>
357
+ </div>
358
+ <div class="p-3 rounded-lg bg-emerald-950/20 border border-emerald-900/30">
359
+ <span class="text-[11px] uppercase font-bold text-emerald-400 block" data-i18n="calc_cost_with">Cost With Jev</span>
360
+ <span id="costWithVal" class="text-xl font-bold font-mono text-emerald-200">$171.60</span>
361
+ <span class="text-[10px] text-slate-400 block mt-0.5" data-i18n="calc_per_month">/ month</span>
362
+ </div>
363
+ </div>
364
+ </div>
365
+
366
+ <div class="mt-6 pt-4 border-t border-slate-800/80 bg-gradient-to-r from-purple-950/30 to-emerald-950/30 p-4 rounded-xl border border-purple-900/30">
367
+ <div class="flex items-baseline justify-between">
368
+ <div>
369
+ <span class="text-xs uppercase font-extrabold tracking-wider text-emerald-400 block" data-i18n="calc_net_monthly">Net Monthly Cash Saved</span>
370
+ <span id="savingsMonthVal" class="text-3xl font-black font-mono text-white">$2,072.40</span>
371
+ </div>
372
+ <div class="text-right">
373
+ <span class="text-xs uppercase font-extrabold tracking-wider text-purple-400 block" data-i18n="calc_annual">Annual Savings</span>
374
+ <span id="savingsYearVal" class="text-xl font-bold font-mono text-purple-200">$24,868.80</span>
375
+ </div>
376
+ </div>
377
+ </div>
378
+ </div>
379
+ </div>
380
+ </section>
381
+
382
+ <!-- Side-by-Side Matrix -->
383
+ <section class="border border-slate-800 bg-slate-900/80 rounded-2xl p-6 md:p-8 shadow-xl space-y-6">
384
+ <h2 class="text-xl font-bold text-white font-mono" data-i18n="matrix_title">Side-by-Side Architectural Matrix</h2>
385
+ <div class="overflow-x-auto">
386
+ <table class="w-full text-left text-sm text-slate-300">
387
+ <thead class="text-xs uppercase bg-slate-950/60 text-slate-400 border-y border-slate-800">
388
+ <tr>
389
+ <th scope="col" class="py-3 px-4" data-i18n="matrix_th_feat">Feature / Dimension</th>
390
+ <th scope="col" class="py-3 px-4 text-red-400 bg-red-950/10 border-x border-slate-800" data-i18n="matrix_th_without">Without Jev (Vanilla Agent)</th>
391
+ <th scope="col" class="py-3 px-4 text-emerald-400 bg-emerald-950/10" data-i18n="matrix_th_with">With Jev Developer Harness</th>
392
+ <th scope="col" class="py-3 px-4 text-purple-400" data-i18n="matrix_th_adv">Competitive Advantage</th>
393
+ </tr>
394
+ </thead>
395
+ <tbody class="divide-y divide-slate-800/60 font-normal">
396
+ <tr class="hover:bg-slate-800/30">
397
+ <td class="py-3.5 px-4 font-semibold text-white" data-i18n="matrix_r1_feat">Context Discovery</td>
398
+ <td class="py-3.5 px-4 text-slate-400 bg-red-950/5 border-x border-slate-800" data-i18n="matrix_r1_without">Dumps 40–90 files into prompt. High "lost in the middle" rate.</td>
399
+ <td class="py-3.5 px-4 text-emerald-200 bg-emerald-950/5 font-medium" data-i18n="matrix_r1_with">4-stage ranker isolates the exact 3–5 crucial files.</td>
400
+ <td class="py-3.5 px-4 font-semibold text-purple-300" data-i18n="matrix_r1_adv">Selected file counts; token savings not measured.</td>
401
+ </tr>
402
+ <tr class="hover:bg-slate-800/30">
403
+ <td class="py-3.5 px-4 font-semibold text-white" data-i18n="matrix_r2_feat">Shell Command Execution</td>
404
+ <td class="py-3.5 px-4 text-slate-400 bg-red-950/5 border-x border-slate-800" data-i18n="matrix_r2_without">LLM executes terminal commands blindly (risk of `rm -rf`, `git reset`).</td>
405
+ <td class="py-3.5 px-4 text-emerald-200 bg-emerald-950/5 font-medium" data-i18n="matrix_r2_with">&lt;1ms lexical classifier + Jev evaluator for unknown syntax.</td>
406
+ <td class="py-3.5 px-4 font-semibold text-purple-300" data-i18n="matrix_r2_adv">100% deterministic guard blocking destructive actions.</td>
407
+ </tr>
408
+ <tr class="hover:bg-slate-800/30">
409
+ <td class="py-3.5 px-4 font-semibold text-white" data-i18n="matrix_r3_feat">Git Diff & Patch Audit</td>
410
+ <td class="py-3.5 px-4 text-slate-400 bg-red-950/5 border-x border-slate-800" data-i18n="matrix_r3_without">Manual developer review or waiting minutes for remote CI runs.</td>
411
+ <td class="py-3.5 px-4 text-emerald-200 bg-emerald-950/5 font-medium" data-i18n="matrix_r3_with">Sub-second (~750ms) System One pre-commit hook automatically audits diffs.</td>
412
+ <td class="py-3.5 px-4 font-semibold text-purple-300" data-i18n="matrix_r3_adv">Catches credential leaks & regression risk before commit.</td>
413
+ </tr>
414
+ </tbody>
415
+ </table>
416
+ </div>
417
+ </section>
418
+
419
+ </div>
420
+
421
+ <!-- Footer -->
422
+ <footer class="text-center text-xs text-slate-500 py-4 font-mono" data-i18n="footer">
423
+ jev-dev-harness v0.2.7 • Licensed under MIT • Powered by TypeSafe AI / Jev System One
424
+ </footer>
425
+
426
+ </div>
427
+
428
+ <!-- Client-side Telemetry & Calculator Script -->
429
+ <script>
430
+ // Tab switching
431
+ function switchTab(tab) {
432
+ const liveTab = document.getElementById('tabContentLive');
433
+ const roiTab = document.getElementById('tabContentRoi');
434
+ const btnLive = document.getElementById('tabBtnLive');
435
+ const btnRoi = document.getElementById('tabBtnRoi');
436
+
437
+ if (tab === 'live') {
438
+ liveTab.classList.remove('hidden');
439
+ roiTab.classList.add('hidden');
440
+ btnLive.className = 'px-4 py-2 rounded-lg text-xs font-semibold font-mono transition-all flex items-center gap-2 tab-active cursor-pointer';
441
+ btnRoi.className = 'px-4 py-2 rounded-lg text-xs font-semibold font-mono transition-all flex items-center gap-2 tab-inactive cursor-pointer';
442
+ } else {
443
+ liveTab.classList.add('hidden');
444
+ roiTab.classList.remove('hidden');
445
+ btnLive.className = 'px-4 py-2 rounded-lg text-xs font-semibold font-mono transition-all flex items-center gap-2 tab-inactive cursor-pointer';
446
+ btnRoi.className = 'px-4 py-2 rounded-lg text-xs font-semibold font-mono transition-all flex items-center gap-2 tab-active cursor-pointer';
447
+ }
448
+ }
449
+
450
+ // ==========================================
451
+ // Internationalization (i18n) - EN & PT-BR
452
+ // ==========================================
453
+ const I18N = {
454
+ en: {
455
+ header_subtitle: 'Runtime Developer Harness & Live Telemetry for AI Coding Agents',
456
+ tab_live: 'Live Telemetry',
457
+ tab_roi: 'ROI & Simulator',
458
+ update_new: 'New update available:',
459
+ update_view: 'View Release',
460
+ status_banner_badge: 'Codex Desktop • Antigravity • Claude Code',
461
+ status_banner_title: 'Active Telemetry & Protection',
462
+ status_model: 'Model:',
463
+ status_stream: '⚡ Live Stream: Connected',
464
+ status_store: 'Store:',
465
+ btn_clear: 'Clear History',
466
+ btn_refresh: 'Refresh',
467
+ card_ops_title: 'Agent Ops',
468
+ card_ops_sub: 'Through harness',
469
+ card_tokens_title: 'Token savings',
470
+ card_tokens_sub: 'No measured baseline',
471
+ card_cash_title: 'Money savings',
472
+ card_cash_sub: 'No measured baseline',
473
+ card_latency_title: 'Avg Latency',
474
+ card_guard_title: 'Tool Guard',
475
+ card_patch_title: 'Patch Audits',
476
+ chart_title: 'What happened to each request',
477
+ legend_rank: 'Context Rank',
478
+ legend_guard: 'Tool Guard',
479
+ legend_patch: 'Patch Audit',
480
+ legend_lint: 'Semantic Lint',
481
+ verdicts_title: 'Safety & Gate Verdicts',
482
+ verdicts_cmd_label: 'Destructive Commands Blocked:',
483
+ verdicts_patch_label: 'Patches Escalated / Blocked:',
484
+ verdicts_reduction_label: 'File selection reduction:',
485
+ verdicts_engine: 'Deterministic rule gates + Jev System One',
486
+ stream_title: 'Live Operations Stream',
487
+ stream_listening: 'Listening for agent tool calls...',
488
+ th_time: 'Time',
489
+ th_platform: 'Platform / Agent',
490
+ th_harness: 'Harness & Engine',
491
+ th_operation: 'Operation',
492
+ th_target: 'Target / Detail',
493
+ th_outcome: 'Outcome / Impact',
494
+ th_speed: 'Speed',
495
+ th_status: 'Status',
496
+ table_empty: 'No telemetry events recorded yet. Run a prompt in Codex Desktop or Antigravity to see live data here!',
497
+ calc_title: 'Interactive ROI & Dollar Savings Calculator',
498
+ calc_subtitle: 'Hypothetical simulation using fixed assumptions (85,000 vs 6,500 tokens/prompt). Not measured telemetry or evidence of savings.',
499
+ calc_badge: 'Interactive Model',
500
+ calc_team_label: 'Team Size (Engineers with AI Agents)',
501
+ calc_team_solo: '1 solo',
502
+ calc_team_team: '10 team',
503
+ calc_team_squad: '50 squad',
504
+ calc_team_enterprise: '100 enterprise',
505
+ calc_prompts_label: 'Agent Prompts per Dev / Day',
506
+ calc_prompts_light: '10 light',
507
+ calc_prompts_standard: '40 standard',
508
+ calc_prompts_intense: '80 intense',
509
+ calc_prompts_power: '150 power user',
510
+ calc_model_label: 'Target Agent Model & Pricing',
511
+ calc_tokens_without: 'Monthly Tokens Without Jev:',
512
+ calc_tokens_with: 'Monthly Tokens With Jev (Surgical):',
513
+ calc_cost_without: 'Cost Without Jev',
514
+ calc_cost_with: 'Cost With Jev',
515
+ calc_per_month: '/ month',
516
+ calc_net_monthly: 'Net Monthly Cash Saved',
517
+ calc_annual: 'Annual Savings',
518
+ matrix_title: 'Side-by-Side Architectural Matrix',
519
+ matrix_th_feat: 'Feature / Dimension',
520
+ matrix_th_without: 'Without Jev (Vanilla Agent)',
521
+ matrix_th_with: 'With Jev Developer Harness',
522
+ matrix_th_adv: 'Competitive Advantage',
523
+ matrix_r1_feat: 'Context Discovery',
524
+ matrix_r1_without: 'Dumps 40–90 files into prompt. High "lost in the middle" rate.',
525
+ matrix_r1_with: '4-stage ranker isolates the exact 3–5 crucial files.',
526
+ matrix_r1_adv: 'Selected file counts; token savings not measured.',
527
+ matrix_r2_feat: 'Shell Command Execution',
528
+ matrix_r2_without: 'LLM executes terminal commands blindly (risk of `rm -rf`, `git reset`).',
529
+ matrix_r2_with: 'Lexical classifier + optional evaluator; measured latency per operation.',
530
+ matrix_r2_adv: '100% deterministic guard blocking destructive actions.',
531
+ matrix_r3_feat: 'Git Diff & Patch Audit',
532
+ matrix_r3_without: 'Manual developer review or waiting minutes for remote CI runs.',
533
+ matrix_r3_with: 'Sub-second (~750ms) System One pre-commit hook automatically audits diffs.',
534
+ matrix_r3_adv: 'Catches credential leaks & regression risk before commit.',
535
+ footer: 'jev-dev-harness v0.2.7 • Licensed under MIT • Powered by TypeSafe AI / Jev System One'
536
+ },
537
+ pt: {
538
+ header_subtitle: 'Runtime Developer Harness e Telemetria em Tempo Real para Agentes de IA',
539
+ tab_live: 'Telemetria em Tempo Real',
540
+ tab_roi: 'ROI e Simulador',
541
+ update_new: 'Nova atualização disponível:',
542
+ update_view: 'Ver Lançamento',
543
+ status_banner_badge: 'Codex Desktop • Antigravity • Claude Code',
544
+ status_banner_title: 'Telemetria Ativa & Proteção',
545
+ status_model: 'Modelo:',
546
+ status_stream: '⚡ Fluxo ao Vivo: Conectado',
547
+ status_store: 'Armazenamento:',
548
+ btn_clear: 'Limpar Histórico',
549
+ btn_refresh: 'Atualizar',
550
+ card_ops_title: 'Operações de IA',
551
+ card_ops_sub: 'Via harness',
552
+ card_tokens_title: 'Economia de tokens',
553
+ card_tokens_sub: 'Sem baseline medido',
554
+ card_cash_title: 'Economia de dinheiro',
555
+ card_cash_sub: 'Sem baseline medido',
556
+ card_latency_title: 'Latência Média',
557
+ card_guard_title: 'Guarda de Comandos',
558
+ card_patch_title: 'Auditorias de Patch',
559
+ chart_title: 'O que ocorreu com cada requisição',
560
+ legend_rank: 'Rank de Contexto',
561
+ legend_guard: 'Guarda de Comandos',
562
+ legend_patch: 'Auditoria de Patch',
563
+ legend_lint: 'Lint Semântico',
564
+ verdicts_title: 'Vereditos de Segurança & Portões',
565
+ verdicts_cmd_label: 'Comandos Destrutivos Bloqueados:',
566
+ verdicts_patch_label: 'Patches Escalados / Bloqueados:',
567
+ verdicts_reduction_label: 'Redução na seleção de arquivos:',
568
+ verdicts_engine: 'Regras determinísticas + Jev System One',
569
+ stream_title: 'Fluxo de Operações em Tempo Real',
570
+ stream_listening: 'Escutando chamadas de ferramentas dos agentes...',
571
+ th_time: 'Horário',
572
+ th_platform: 'Plataforma Acionada',
573
+ th_harness: 'Módulo & Provedor',
574
+ th_operation: 'Operação',
575
+ th_target: 'Alvo / Detalhe',
576
+ th_outcome: 'Resultado / Impacto',
577
+ th_speed: 'Tempo',
578
+ th_status: 'Status',
579
+ table_empty: 'Nenhum evento de telemetria registrado ainda. Execute um prompt no Codex Desktop ou Antigravity para ver os dados ao vivo aqui!',
580
+ calc_title: 'Calculadora Interativa de ROI e Economia Financeira',
581
+ calc_subtitle: 'Simulação hipotética com premissas fixas (85.000 vs 6.500 tokens/prompt). Não é telemetria medida nem comprovação de economia.',
582
+ calc_badge: 'Modelo Interativo',
583
+ calc_team_label: 'Tamanho da Equipe (Engenheiros com Agentes IA)',
584
+ calc_team_solo: '1 solo',
585
+ calc_team_team: '10 time',
586
+ calc_team_squad: '50 squad',
587
+ calc_team_enterprise: '100 corporativo',
588
+ calc_prompts_label: 'Prompts do Agente por Dev / Dia',
589
+ calc_prompts_light: '10 leve',
590
+ calc_prompts_standard: '40 padrão',
591
+ calc_prompts_intense: '80 intenso',
592
+ calc_prompts_power: '150 avançado',
593
+ calc_model_label: 'Modelo do Agente e Custo',
594
+ calc_tokens_without: 'Tokens Mensais Sem o Jev:',
595
+ calc_tokens_with: 'Tokens Mensais Com o Jev (Cirúrgico):',
596
+ calc_cost_without: 'Custo Sem o Jev',
597
+ calc_cost_with: 'Custo Com o Jev',
598
+ calc_per_month: '/ mês',
599
+ calc_net_monthly: 'Economia Líquida Mensal',
600
+ calc_annual: 'Economia Anual',
601
+ matrix_title: 'Matriz Comparativa de Arquitetura',
602
+ matrix_th_feat: 'Funcionalidade / Dimensão',
603
+ matrix_th_without: 'Sem o Jev (Agente Padrão)',
604
+ matrix_th_with: 'Com Jev Developer Harness',
605
+ matrix_th_adv: 'Vantagem Competitiva',
606
+ matrix_r1_feat: 'Descoberta de Contexto',
607
+ matrix_r1_without: 'Despeja 40–90 arquivos no prompt. Alta taxa de perda de atenção ("lost in the middle").',
608
+ matrix_r1_with: 'Ranker em 4 estágios isola com precisão os 3–5 arquivos cruciais.',
609
+ matrix_r1_adv: 'Contagem de arquivos selecionados; economia de tokens não medida.',
610
+ matrix_r2_feat: 'Execução de Comandos de Shell',
611
+ matrix_r2_without: 'LLM executa comandos às cegas no terminal (risco de `rm -rf`, `git reset`).',
612
+ matrix_r2_with: 'Classificador léxico + avaliador opcional; latência medida por operação.',
613
+ matrix_r2_adv: 'Guarda 100% determinístico que bloqueia ações destrutivas.',
614
+ matrix_r3_feat: 'Auditoria de Diffs & Patches Git',
615
+ matrix_r3_without: 'Revisão manual do dev ou minutos de espera em pipelines lentos de CI.',
616
+ matrix_r3_with: 'Pre-commit hook System One sub-segundo (~750ms) audita diffs automaticamente.',
617
+ matrix_r3_adv: 'Detecta vazamentos de credenciais e risco de regressão antes do commit.',
618
+ footer: 'jev-dev-harness v0.2.7 • Licenciado sob MIT • Desenvolvido com TypeSafe AI / Jev System One'
619
+ }
620
+ };
621
+
622
+ let currentLang = 'en';
623
+
624
+ function setLanguage(lang) {
625
+ currentLang = (lang === 'pt' || lang === 'pt-BR') ? 'pt' : 'en';
626
+ try {
627
+ localStorage.setItem('jev_dashboard_lang', currentLang);
628
+ } catch (e) {}
629
+
630
+ // Update button visual styles
631
+ const btnEn = document.getElementById('langBtnEn');
632
+ const btnPt = document.getElementById('langBtnPt');
633
+ if (btnEn && btnPt) {
634
+ if (currentLang === 'pt') {
635
+ btnPt.className = 'px-2.5 py-1.5 rounded-lg text-xs font-semibold font-mono transition-all cursor-pointer flex items-center gap-1.5 bg-emerald-600 text-white shadow-sm font-bold';
636
+ btnEn.className = 'px-2.5 py-1.5 rounded-lg text-xs font-semibold font-mono transition-all cursor-pointer flex items-center gap-1.5 text-slate-400 hover:text-white font-medium';
637
+ } else {
638
+ btnEn.className = 'px-2.5 py-1.5 rounded-lg text-xs font-semibold font-mono transition-all cursor-pointer flex items-center gap-1.5 bg-purple-600 text-white shadow-sm font-bold';
639
+ btnPt.className = 'px-2.5 py-1.5 rounded-lg text-xs font-semibold font-mono transition-all cursor-pointer flex items-center gap-1.5 text-slate-400 hover:text-white font-medium';
640
+ }
641
+ }
642
+
643
+ // Translate all [data-i18n] elements
644
+ document.querySelectorAll('[data-i18n]').forEach(el => {
645
+ const key = el.getAttribute('data-i18n');
646
+ if (I18N[currentLang] && I18N[currentLang][key]) {
647
+ el.innerHTML = I18N[currentLang][key];
648
+ }
649
+ });
650
+
651
+ // Re-render dynamic elements with active translation
652
+ if (currentSummary) {
653
+ updateTelemetryUi(currentSummary, eventsList);
654
+ } else {
655
+ renderEventsTable(eventsList);
656
+ }
657
+ updateCalculator();
658
+ }
659
+
660
+ // Live Telemetry Handlers
661
+ let currentSummary = null;
662
+ let eventsList = [];
663
+
664
+ function updateTelemetryUi(summary, events) {
665
+ try {
666
+ if (summary) {
667
+ currentSummary = summary;
668
+ const subtextEl = document.getElementById('liveStatusSubtext');
669
+ if (subtextEl) {
670
+ subtextEl.innerHTML = currentLang === 'pt'
671
+ ? `O Jev registrou <strong id="liveDecidedCount" class="text-emerald-300">${summary.totalEvents}</strong> eventos em todos os seus agentes de codificação.`
672
+ : `Jev recorded <strong id="liveDecidedCount" class="text-emerald-300">${summary.totalEvents}</strong> events across your coding agents.`;
673
+ }
674
+
675
+ const totalEl = document.getElementById('metricTotalEvents');
676
+ if (totalEl) totalEl.innerText = summary.totalEvents;
677
+
678
+ const tokensEl = document.getElementById('metricTokensSaved');
679
+ if (tokensEl) tokensEl.innerText = currentLang === 'pt' ? 'Não medida' : 'Not measured';
680
+
681
+ const dollarsEl = document.getElementById('metricDollarsSaved');
682
+ if (dollarsEl) dollarsEl.innerText = currentLang === 'pt' ? 'Não medida' : 'Not measured';
683
+ const usageEl = document.getElementById('measuredUsage');
684
+ const usage = summary.usage;
685
+ if (usageEl) usageEl.innerText = usage
686
+ ? `${currentLang === 'pt' ? 'Uso reportado (ranking de contexto)' : 'Reported usage (context ranking)'}: ${usage.inputTokens ?? (currentLang === 'pt' ? 'não informado' : 'not informed')}/${usage.outputTokens ?? (currentLang === 'pt' ? 'não informado' : 'not informed')} tokens; ${usage.newModelCalls} calls; USD ${usage.reportedCostUsd ?? (currentLang === 'pt' ? 'não informado' : 'not informed')} (${usage.costedRequests}/${usage.newModelCalls} cost coverage); ${usage.eventsWithUsage}/${usage.eventsWithUsage + usage.eventsWithoutUsage} events with usage. Validated responses only; unreported retries/failures excluded.`
687
+ : (currentLang === 'pt' ? 'Uso reportado: não informado.' : 'Reported usage: not informed.');
688
+ const comparisonTitle = document.getElementById('comparisonTitle');
689
+ if (comparisonTitle) comparisonTitle.innerText = currentLang === 'pt' ? 'Comparação medida por tarefa' : 'Measured task comparison';
690
+ const comparisonEl = document.getElementById('measuredComparison');
691
+ if (comparisonEl) comparisonEl.textContent = summary.latestComparison?.summaryMessage
692
+ || (currentLang === 'pt' ? 'Nenhum par de execuções importado. Economia não medida.' : 'No paired execution imported. Savings are not measured.');
693
+
694
+ const latEl = document.getElementById('metricLatency');
695
+ if (latEl) latEl.innerText = summary.avgLatencyMs ? `${summary.avgLatencyMs} ms` : '-- ms';
696
+
697
+ const latSubEl = document.getElementById('metricLatencySub');
698
+ if (latSubEl) latSubEl.innerText = summary.p95LatencyMs ? `p95: ${summary.p95LatencyMs} ms` : 'p95: -- ms';
699
+
700
+ const guardEl = document.getElementById('metricGuardCount');
701
+ if (guardEl) guardEl.innerText = summary.guardStats?.totalChecked || 0;
702
+
703
+ const guardSubEl = document.getElementById('metricGuardSub');
704
+ if (guardSubEl) guardSubEl.innerText = currentLang === 'pt'
705
+ ? `${summary.guardStats?.blocked || 0} bloqueados`
706
+ : `${summary.guardStats?.blocked || 0} blocked`;
707
+
708
+ const patchEl = document.getElementById('metricPatchCount');
709
+ if (patchEl) patchEl.innerText = summary.patchStats?.totalAudited || 0;
710
+
711
+ const patchSubEl = document.getElementById('metricPatchSub');
712
+ if (patchSubEl) patchSubEl.innerText = currentLang === 'pt'
713
+ ? `Risco médio: ${summary.patchStats?.avgRiskScore || 0}/100`
714
+ : `Avg risk: ${summary.patchStats?.avgRiskScore || 0}/100`;
715
+
716
+ const gateBlockedEl = document.getElementById('gateBlockedVal');
717
+ if (gateBlockedEl) gateBlockedEl.innerText = currentLang === 'pt'
718
+ ? `${summary.guardStats?.blocked || 0} bloqueados (${summary.guardStats?.allowed || 0} seguros)`
719
+ : `${summary.guardStats?.blocked || 0} blocked (${summary.guardStats?.allowed || 0} safe)`;
720
+
721
+ const gateEscalatedEl = document.getElementById('gateEscalatedVal');
722
+ if (gateEscalatedEl) gateEscalatedEl.innerText = currentLang === 'pt'
723
+ ? `${summary.patchStats?.escalated || 0} escalados (${summary.patchStats?.approved || 0} aprovados)`
724
+ : `${summary.patchStats?.escalated || 0} escalated (${summary.patchStats?.approved || 0} approved)`;
725
+
726
+ const gateRedEl = document.getElementById('gateAvgReductionVal');
727
+ if (gateRedEl) gateRedEl.innerText = summary.contextStats?.avgReductionPct ? `${summary.contextStats.avgReductionPct}%` : '--';
728
+
729
+ // Stacked Bar
730
+ const total = summary.totalEvents || 1;
731
+ const rankCount = summary.byType?.context_rank || 0;
732
+ const guardCount = summary.byType?.guard_check || 0;
733
+ const patchCount = summary.byType?.patch_review || 0;
734
+ const lintCount = summary.byType?.lint_semantic || 0;
735
+
736
+ const pRank = Math.round((rankCount / total) * 100);
737
+ const pGuard = Math.round((guardCount / total) * 100);
738
+ const pPatch = Math.round((patchCount / total) * 100);
739
+ const pLint = Math.round((lintCount / total) * 100);
740
+
741
+ const barRank = document.getElementById('barRank');
742
+ if (barRank) barRank.style.width = `${pRank}%`;
743
+ const barGuard = document.getElementById('barGuard');
744
+ if (barGuard) barGuard.style.width = `${pGuard}%`;
745
+ const barPatch = document.getElementById('barPatch');
746
+ if (barPatch) barPatch.style.width = `${pPatch}%`;
747
+ const barLint = document.getElementById('barLint');
748
+ if (barLint) barLint.style.width = `${pLint}%`;
749
+
750
+ const pctRank = document.getElementById('pctRank');
751
+ if (pctRank) pctRank.innerText = `${pRank}%`;
752
+ const pctGuard = document.getElementById('pctGuard');
753
+ if (pctGuard) pctGuard.innerText = `${pGuard}%`;
754
+ const pctPatch = document.getElementById('pctPatch');
755
+ if (pctPatch) pctPatch.innerText = `${pPatch}%`;
756
+ const pctLint = document.getElementById('pctLint');
757
+ if (pctLint) pctLint.innerText = `${pLint}%`;
758
+
759
+ const distSummary = document.getElementById('distSummaryText');
760
+ if (distSummary) distSummary.innerText = currentLang === 'pt'
761
+ ? `${summary.totalEvents} requisições totais registradas`
762
+ : `${summary.totalEvents} total requests logged`;
763
+ }
764
+
765
+ if (events && Array.isArray(events)) {
766
+ eventsList = events;
767
+ renderEventsTable(events);
768
+ }
769
+ } catch (err) {
770
+ console.error('Error updating telemetry UI:', err);
771
+ }
772
+ }
773
+
774
+ function renderEventsTable(events) {
775
+ const tbody = document.getElementById('eventsTableBody');
776
+ if (!events || events.length === 0) {
777
+ const emptyMsg = currentLang === 'pt'
778
+ ? 'Nenhum evento de telemetria registrado ainda. Execute um prompt no Codex Desktop ou Antigravity para ver os dados ao vivo aqui!'
779
+ : 'No telemetry events recorded yet. Run a prompt in Codex Desktop or Antigravity to see live data here!';
780
+ tbody.innerHTML = `<tr id="emptyEventsRow"><td colspan="7" class="py-8 text-center text-slate-500">${emptyMsg}</td></tr>`;
781
+ document.getElementById('feedCountText').innerText = currentLang === 'pt' ? '0 eventos gravados' : '0 events recorded';
782
+ return;
783
+ }
784
+
785
+ document.getElementById('feedCountText').innerText = currentLang === 'pt'
786
+ ? `${events.length} eventos recentes`
787
+ : `${events.length} latest events`;
788
+
789
+ tbody.innerHTML = events.map(e => {
790
+ const time = new Date(e.timestamp).toLocaleTimeString();
791
+ let typeBadge = '';
792
+ let detail = '';
793
+ let outcome = '';
794
+ let statusBadge = '';
795
+
796
+ // Platform / Agent metadata (Codex, Claude, Gemini, Antigravity, Cursor, Trae, etc.)
797
+ const rawPlatform = e.platform || (
798
+ e.agent ? (e.agent.charAt(0).toUpperCase() + e.agent.slice(1)) :
799
+ (e.type === 'proxy_turn' ? 'Proxy' : 'Antigravity')
800
+ );
801
+
802
+ let platformIcon = '🤖';
803
+ let platformBadgeStyle = 'bg-slate-800 text-slate-200 border-slate-700';
804
+
805
+ const pLower = rawPlatform.toLowerCase();
806
+ if (pLower.includes('codex')) {
807
+ platformIcon = '⚡';
808
+ platformBadgeStyle = 'bg-emerald-500/10 text-emerald-300 border-emerald-500/30';
809
+ } else if (pLower.includes('claude')) {
810
+ platformIcon = '🧠';
811
+ platformBadgeStyle = 'bg-amber-500/10 text-amber-300 border-amber-500/30';
812
+ } else if (pLower.includes('gemini')) {
813
+ platformIcon = '💎';
814
+ platformBadgeStyle = 'bg-blue-500/10 text-blue-300 border-blue-500/30';
815
+ } else if (pLower.includes('antigravity')) {
816
+ platformIcon = '🚀';
817
+ platformBadgeStyle = 'bg-purple-500/10 text-purple-300 border-purple-500/30';
818
+ } else if (pLower.includes('cursor')) {
819
+ platformIcon = '🎯';
820
+ platformBadgeStyle = 'bg-cyan-500/10 text-cyan-300 border-cyan-500/30';
821
+ } else if (pLower.includes('trae')) {
822
+ platformIcon = '🔮';
823
+ platformBadgeStyle = 'bg-indigo-500/10 text-indigo-300 border-indigo-500/30';
824
+ } else if (pLower.includes('windsurf')) {
825
+ platformIcon = '🌊';
826
+ platformBadgeStyle = 'bg-teal-500/10 text-teal-300 border-teal-500/30';
827
+ } else if (pLower.includes('roo')) {
828
+ platformIcon = '🦘';
829
+ platformBadgeStyle = 'bg-rose-500/10 text-rose-300 border-rose-500/30';
830
+ } else if (pLower.includes('cline')) {
831
+ platformIcon = '🤖';
832
+ platformBadgeStyle = 'bg-violet-500/10 text-violet-300 border-violet-500/30';
833
+ } else if (pLower.includes('continue')) {
834
+ platformIcon = '⏩';
835
+ platformBadgeStyle = 'bg-orange-500/10 text-orange-300 border-orange-500/30';
836
+ } else if (pLower.includes('opencode')) {
837
+ platformIcon = '🌐';
838
+ platformBadgeStyle = 'bg-lime-500/10 text-lime-300 border-lime-500/30';
839
+ } else if (pLower.includes('vscode') || pLower.includes('vs code')) {
840
+ platformIcon = '🔷';
841
+ platformBadgeStyle = 'bg-sky-500/10 text-sky-300 border-sky-500/30';
842
+ } else if (pLower.includes('cli') || pLower.includes('terminal')) {
843
+ platformIcon = '💻';
844
+ platformBadgeStyle = 'bg-slate-800 text-slate-300 border-slate-700';
845
+ }
846
+
847
+ const platformCell = `
848
+ <span class="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md border font-semibold text-xs font-mono ${platformBadgeStyle} whitespace-nowrap shadow-sm">
849
+ <span>${platformIcon}</span>
850
+ <span>${escapeHtml(rawPlatform)}</span>
851
+ </span>
852
+ `;
853
+
854
+ // Harness & Provider metadata
855
+ const harnessName = e.harness || (
856
+ e.type === 'context_rank' ? 'Context Ranker' :
857
+ e.type === 'guard_check' ? 'Tool Guard' :
858
+ e.type === 'patch_review' ? 'Patch Reviewer' :
859
+ e.type === 'tool_rank' ? 'Tool Ranker' :
860
+ e.type === 'proxy_turn' ? `Proxy (${e.agent || 'gateway'})` :
861
+ 'Semantic Linter'
862
+ );
863
+ const providerName = (e.provider || 'typesafe').toLowerCase();
864
+
865
+ let provBadgeClass = 'bg-slate-800 text-slate-300 border-slate-700';
866
+ if (providerName.includes('vercel')) {
867
+ provBadgeClass = 'bg-cyan-500/10 text-cyan-300 border-cyan-500/30';
868
+ } else if (providerName.includes('typesafe')) {
869
+ provBadgeClass = 'bg-purple-500/10 text-purple-300 border-purple-500/30';
870
+ } else if (providerName.includes('openrouter')) {
871
+ provBadgeClass = 'bg-blue-500/10 text-blue-300 border-blue-500/30';
872
+ } else if (providerName.includes('offline')) {
873
+ provBadgeClass = 'bg-amber-500/10 text-amber-300 border-amber-500/30';
874
+ }
875
+
876
+ const harnessCell = `
877
+ <div class="flex flex-col">
878
+ <span class="font-bold text-slate-200 text-[11px] whitespace-nowrap">${escapeHtml(harnessName)}</span>
879
+ <span class="inline-block mt-0.5 px-1.5 py-0.5 text-[9px] rounded border font-mono ${provBadgeClass} w-max uppercase tracking-wider">
880
+ ${escapeHtml(providerName)}
881
+ </span>
882
+ </div>
883
+ `;
884
+
885
+ if (e.type === 'usage_comparison') {
886
+ typeBadge = '<span class="px-2 py-0.5 rounded bg-cyan-500/10 text-cyan-400">USAGE_COMPARISON</span>';
887
+ const comparedHarness = e.comparison?.baseline?.runs?.[0]?.harness;
888
+ detail = `<span class="text-slate-300">${escapeHtml(e.comparison?.taskId || '')}${comparedHarness ? ` (${escapeHtml(comparedHarness)})` : ''}</span>`;
889
+ const deltaLabel = e.comparison?.agentTokenDelta == null
890
+ ? (currentLang === 'pt' ? 'não medida' : 'not measured')
891
+ : `${e.comparison.agentTokenDelta} token delta (agent scope)`;
892
+ outcome = `<span class="text-cyan-300">${escapeHtml(deltaLabel)}</span>`;
893
+ statusBadge = '<span class="text-slate-400">IMPORTED PAIR</span>';
894
+ } else if (e.type === 'context_rank') {
895
+ typeBadge = '<span class="px-2 py-0.5 rounded bg-purple-500/10 text-purple-400 border border-purple-500/20 font-bold">CONTEXT_RANK</span>';
896
+ detail = `<span class="text-slate-300 truncate max-w-xs block" title="${escapeHtml(e.task)}">${escapeHtml(e.task || (currentLang === 'pt' ? 'Ranqueamento de contexto' : 'File context ranking'))}</span>`;
897
+ outcome = `<span class="text-purple-300 font-semibold">${e.selectedFiles} selected / ${e.initialCandidates} found ${currentLang === 'pt' ? 'arquivos' : 'files'} (-${e.reductionPct}%)</span>`;
898
+ statusBadge = `<span class="px-2 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20">${currentLang === 'pt' ? 'RANQUEADO' : 'RANKED'}</span>`;
899
+ } else if (e.type === 'guard_check') {
900
+ typeBadge = '<span class="px-2 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20 font-bold">TOOL_GUARD</span>';
901
+ detail = `<code class="text-slate-300 truncate max-w-xs block text-[11px]" title="${escapeHtml(e.command)}">${escapeHtml(e.command)}</code>`;
902
+ outcome = `<span class="${e.allowed ? 'text-emerald-400' : 'text-red-400'}">${e.category} (${e.riskLevel})</span>`;
903
+ statusBadge = e.allowed
904
+ ? `<span class="px-2 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20">${currentLang === 'pt' ? 'PERMITIDO' : 'ALLOWED'}</span>`
905
+ : `<span class="px-2 py-0.5 rounded bg-red-500/10 text-red-400 border border-red-500/20 font-bold animate-pulse">${currentLang === 'pt' ? 'BLOQUEADO' : 'BLOCKED'}</span>`;
906
+ } else if (e.type === 'patch_review') {
907
+ typeBadge = '<span class="px-2 py-0.5 rounded bg-blue-500/10 text-blue-400 border border-blue-500/20 font-bold">PATCH_REVIEW</span>';
908
+ detail = `<span class="text-slate-300">${e.filesCount} ${currentLang === 'pt' ? 'arquivo(s)' : 'file(s)'} (+${e.additions}/-${e.deletions})</span>`;
909
+ outcome = `<span class="text-slate-300 font-semibold">${currentLang === 'pt' ? 'Risco' : 'Risk'}: ${e.riskScore}/100</span>`;
910
+ statusBadge = e.status === 'APPROVED'
911
+ ? `<span class="px-2 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20">${currentLang === 'pt' ? 'APROVADO' : 'APPROVED'}</span>`
912
+ : `<span class="px-2 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20">${currentLang === 'pt' ? 'ESCALADO' : 'ESCALATED'}</span>`;
913
+ } else if (e.type === 'tool_rank') {
914
+ typeBadge = '<span class="px-2 py-0.5 rounded bg-indigo-500/10 text-indigo-400 border border-indigo-500/20 font-bold">TOOL_RANK</span>';
915
+ detail = `<span class="text-slate-300 truncate max-w-xs block" title="${escapeHtml(e.task)}">${escapeHtml(e.task || 'Tool pruning')}</span>`;
916
+ outcome = `<span class="text-indigo-300 font-semibold">${e.selectedTools}/${e.initialTools} tools (-${e.reductionPct}%)</span>`;
917
+ statusBadge = `<span class="px-2 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20">${currentLang === 'pt' ? 'OTIMIZADO' : 'PRUNED'}</span>`;
918
+ } else if (e.type === 'proxy_turn') {
919
+ typeBadge = `<span class="px-2 py-0.5 rounded bg-cyan-500/10 text-cyan-400 border border-cyan-500/20 font-bold">PROXY_${escapeHtml((e.agent || 'GATEWAY').toUpperCase())}</span>`;
920
+ detail = `<span class="text-slate-300 font-mono text-[11px]">${e.tool ? `tool: ${escapeHtml(e.tool)}` : 'turn routing'}</span>`;
921
+ outcome = `<span class="text-cyan-300 font-semibold">Mode: ${escapeHtml(e.mode?.toUpperCase() || 'PASSTHROUGH')}</span>`;
922
+ statusBadge = (e.mode === 'forced' || e.mode === 'hint')
923
+ ? `<span class="px-2 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20">${currentLang === 'pt' ? 'ROTEADO' : 'ROUTED'}</span>`
924
+ : `<span class="px-2 py-0.5 rounded bg-slate-500/10 text-slate-400 border border-slate-500/20">PASS</span>`;
925
+ } else {
926
+ typeBadge = '<span class="px-2 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 font-bold">LINT_SEMANTIC</span>';
927
+ detail = `<span class="text-slate-300">${e.violationsCount || 0} ${currentLang === 'pt' ? 'violações' : 'violations'}</span>`;
928
+ outcome = `<span class="text-slate-300">${e.status}</span>`;
929
+ statusBadge = e.passed
930
+ ? `<span class="px-2 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20">${currentLang === 'pt' ? 'APROVADO' : 'PASSED'}</span>`
931
+ : `<span class="px-2 py-0.5 rounded bg-red-500/10 text-red-400 border border-red-500/20">${currentLang === 'pt' ? 'VIOLAÇÕES' : 'VIOLATIONS'}</span>`;
932
+ }
933
+
934
+ return `<tr class="hover:bg-slate-800/40">
935
+ <td class="py-2.5 px-3 text-slate-400 whitespace-nowrap">${time}</td>
936
+ <td class="py-2.5 px-3 whitespace-nowrap">${platformCell}</td>
937
+ <td class="py-2.5 px-3 whitespace-nowrap">${harnessCell}</td>
938
+ <td class="py-2.5 px-3">${typeBadge}</td>
939
+ <td class="py-2.5 px-3">${detail}</td>
940
+ <td class="py-2.5 px-3">${outcome}</td>
941
+ <td class="py-2.5 px-3 text-slate-400 whitespace-nowrap">${e.latencyMs || 0}ms</td>
942
+ <td class="py-2.5 px-3">${statusBadge}</td>
943
+ </tr>`;
944
+ }).join('');
945
+ }
946
+
947
+ function escapeHtml(str) {
948
+ if (!str) return '';
949
+ return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
950
+ }
951
+
952
+ // Connect to SSE Live Stream
953
+ function initLiveStream() {
954
+ try {
955
+ const evtSource = new EventSource('/api/live');
956
+ evtSource.onmessage = function(event) {
957
+ try {
958
+ const data = JSON.parse(event.data);
959
+ if (data.type === 'init') {
960
+ updateTelemetryUi(data.summary, data.events);
961
+ } else if (data.type === 'event') {
962
+ if (data.event && data.event.id) {
963
+ const existingIdx = eventsList.findIndex(e => e.id === data.event.id);
964
+ if (existingIdx >= 0) {
965
+ eventsList[existingIdx] = data.event;
966
+ } else {
967
+ eventsList.unshift(data.event);
968
+ if (eventsList.length > 100) eventsList.pop();
969
+ }
970
+ }
971
+ updateTelemetryUi(data.summary, eventsList);
972
+ }
973
+ } catch (e) {
974
+ // Non-JSON ping
975
+ }
976
+ };
977
+
978
+ evtSource.onopen = function() {
979
+ const statusEl = document.getElementById('liveStreamStatus');
980
+ if (statusEl) {
981
+ statusEl.innerText = currentLang === 'pt' ? '⚡ Fluxo ao Vivo: Conectado' : '⚡ Live Stream: Connected';
982
+ statusEl.className = 'text-emerald-400';
983
+ }
984
+ };
985
+
986
+ evtSource.onerror = function() {
987
+ const statusEl = document.getElementById('liveStreamStatus');
988
+ if (statusEl) {
989
+ statusEl.innerText = currentLang === 'pt' ? '🔄 Reconectando...' : '🔄 Reconnecting...';
990
+ statusEl.className = 'text-amber-400';
991
+ }
992
+ };
993
+ } catch {
994
+ // Fallback handled by auto-sync below
995
+ }
996
+ }
997
+
998
+ async function refreshData() {
999
+ try {
1000
+ const nocache = `_t=${Date.now()}`;
1001
+ const [sumRes, evRes] = await Promise.all([
1002
+ fetch(`/api/summary?${nocache}`),
1003
+ fetch(`/api/events?limit=50&${nocache}`)
1004
+ ]);
1005
+ if (sumRes.ok && evRes.ok) {
1006
+ const summary = await sumRes.json();
1007
+ const events = await evRes.json();
1008
+ updateTelemetryUi(summary, events);
1009
+ }
1010
+ } catch (err) {
1011
+ console.error('Failed to fetch telemetry data:', err);
1012
+ }
1013
+ }
1014
+
1015
+ // Continuous background sync (every 2.5s) to guarantee real-time updates across multiple processes
1016
+ setInterval(refreshData, 2500);
1017
+
1018
+ // Sync immediately whenever the developer switches back to the dashboard tab
1019
+ document.addEventListener('visibilitychange', () => {
1020
+ if (!document.hidden) refreshData();
1021
+ });
1022
+ window.addEventListener('focus', refreshData);
1023
+
1024
+ async function clearHistory() {
1025
+ const confirmMsg = currentLang === 'pt'
1026
+ ? 'Deseja limpar todo o histórico de telemetria gravado?'
1027
+ : 'Clear all recorded telemetry history?';
1028
+ if (!confirm(confirmMsg)) return;
1029
+ try {
1030
+ const res = await fetch('/api/clear', { method: 'POST' });
1031
+ if (res.ok) {
1032
+ await refreshData();
1033
+ }
1034
+ } catch (err) {
1035
+ alert(currentLang === 'pt' ? 'Falha ao limpar histórico' : 'Failed to clear history');
1036
+ }
1037
+ }
1038
+
1039
+ // ROI Calculator Logic
1040
+ function updateCalculator() {
1041
+ const teamSize = parseInt(document.getElementById('teamSize').value, 10);
1042
+ const promptsPerDay = parseInt(document.getElementById('promptsPerDay').value, 10);
1043
+ const costPerMillion = parseFloat(document.getElementById('modelSelect').value);
1044
+
1045
+ document.getElementById('teamSizeVal').innerText = `${teamSize} devs`;
1046
+ document.getElementById('promptsVal').innerText = `${promptsPerDay} prompts`;
1047
+
1048
+ const workingDays = 22;
1049
+ const totalPromptsMonth = teamSize * promptsPerDay * workingDays;
1050
+
1051
+ const avgTokensWithout = 85000;
1052
+ const avgTokensWith = 6500;
1053
+
1054
+ const monthlyTokensWithout = (totalPromptsMonth * avgTokensWithout) / 1000000;
1055
+ const monthlyTokensWith = (totalPromptsMonth * avgTokensWith) / 1000000;
1056
+
1057
+ const costWithout = monthlyTokensWithout * costPerMillion;
1058
+ const costWith = monthlyTokensWith * costPerMillion;
1059
+ const savingsMonth = costWithout - costWith;
1060
+ const savingsYear = savingsMonth * 12;
1061
+
1062
+ document.getElementById('tokensWithoutVal').innerText = `${monthlyTokensWithout.toFixed(1)}M tokens`;
1063
+ document.getElementById('tokensWithVal').innerText = `${monthlyTokensWith.toFixed(1)}M tokens (-92.4%)`;
1064
+
1065
+ document.getElementById('costWithoutVal').innerText = `$${costWithout.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
1066
+ document.getElementById('costWithVal').innerText = `$${costWith.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
1067
+
1068
+ document.getElementById('savingsMonthVal').innerText = `$${savingsMonth.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
1069
+ document.getElementById('savingsYearVal').innerText = `$${savingsYear.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
1070
+ }
1071
+
1072
+ let updateNoticeKey = null;
1073
+ const dismissedUpdates = new Set();
1074
+ document.getElementById('dismissUpdate').addEventListener('click', () => {
1075
+ if (updateNoticeKey) {
1076
+ dismissedUpdates.add(updateNoticeKey);
1077
+ try { localStorage.setItem('jev_update_dismissed', updateNoticeKey); } catch { /* Storage may be disabled. */ }
1078
+ }
1079
+ document.getElementById('updateBanner').classList.add('hidden');
1080
+ });
1081
+ function renderUpdate(info) {
1082
+ const banner = document.getElementById('updateBanner');
1083
+ updateNoticeKey = `${info.currentVersion}:${info.status}:${info.latestVersion}`;
1084
+ let dismissed = dismissedUpdates.has(updateNoticeKey);
1085
+ try { dismissed ||= localStorage.getItem('jev_update_dismissed') === updateNoticeKey; } catch { /* Storage may be disabled. */ }
1086
+ banner.classList.toggle('hidden', !info.notice || dismissed);
1087
+ document.getElementById('updateNotice').textContent = info.notice || '';
1088
+ const release = document.getElementById('updateRelease');
1089
+ release.classList.toggle('hidden', !info.releaseUrl);
1090
+ // Links are generated from validated versions by our server, never from release metadata.
1091
+ release.href = info.releaseUrl || 'https://github.com/celolopes/jev-dev-harness/releases';
1092
+ }
1093
+ async function checkUpdates() {
1094
+ try {
1095
+ const res = await fetch('/api/update-status');
1096
+ if (res.ok) {
1097
+ const info = await res.json();
1098
+ renderUpdate(info);
1099
+ } else throw new Error('Update status unavailable');
1100
+ } catch {
1101
+ renderUpdate({ status: 'unavailable', latestVersion: null, notice: "Jev update check unavailable. Run 'jev-dev version' to retry; update status is unknown." });
1102
+ }
1103
+ }
1104
+
1105
+ // Init & Language Auto-detection
1106
+ const urlParams = new URLSearchParams(window.location.search);
1107
+ const queryLang = urlParams.get('lang');
1108
+ const savedLang = localStorage.getItem('jev_dashboard_lang');
1109
+ const browserLang = (navigator.language || '').toLowerCase().startsWith('pt') ? 'pt' : 'en';
1110
+ setLanguage(queryLang || savedLang || browserLang);
1111
+
1112
+ if (urlParams.get('tab') === 'roi' || window.location.hash === '#roi') {
1113
+ switchTab('roi');
1114
+ }
1115
+
1116
+ refreshData();
1117
+ initLiveStream();
1118
+ checkUpdates();
1119
+ setInterval(checkUpdates, 60 * 60 * 1000);
1120
+ </script>
1121
+ </body>
1122
+ </html>