@warmdrift/kgauto-compiler 2.0.0-alpha.7 → 2.0.0-alpha.70

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 (55) hide show
  1. package/README.md +176 -46
  2. package/dist/brain-proxy.d.mts +113 -0
  3. package/dist/brain-proxy.d.ts +113 -0
  4. package/dist/brain-proxy.js +193 -0
  5. package/dist/brain-proxy.mjs +6 -0
  6. package/dist/chunk-4UO4CCSP.mjs +1620 -0
  7. package/dist/chunk-65ZMX5OT.mjs +169 -0
  8. package/dist/{chunk-5TI6PNSK.mjs → chunk-BVEXV5KC.mjs} +11 -0
  9. package/dist/chunk-FR4DNGLW.mjs +203 -0
  10. package/dist/chunk-NBO4R5PC.mjs +313 -0
  11. package/dist/chunk-P3TOAEG4.mjs +56 -0
  12. package/dist/chunk-RO22VFIF.mjs +29 -0
  13. package/dist/chunk-SBFSYCQG.mjs +719 -0
  14. package/dist/dialect.d.mts +41 -3
  15. package/dist/dialect.d.ts +41 -3
  16. package/dist/dialect.js +14 -2
  17. package/dist/dialect.mjs +5 -3
  18. package/dist/glassbox/index.d.mts +59 -0
  19. package/dist/glassbox/index.d.ts +59 -0
  20. package/dist/glassbox/index.js +312 -0
  21. package/dist/glassbox/index.mjs +12 -0
  22. package/dist/glassbox-routes/format.d.mts +24 -0
  23. package/dist/glassbox-routes/format.d.ts +24 -0
  24. package/dist/glassbox-routes/format.js +86 -0
  25. package/dist/glassbox-routes/format.mjs +18 -0
  26. package/dist/glassbox-routes/index.d.mts +191 -0
  27. package/dist/glassbox-routes/index.d.ts +191 -0
  28. package/dist/glassbox-routes/index.js +2888 -0
  29. package/dist/glassbox-routes/index.mjs +667 -0
  30. package/dist/glassbox-routes/react/index.d.mts +74 -0
  31. package/dist/glassbox-routes/react/index.d.ts +74 -0
  32. package/dist/glassbox-routes/react/index.js +819 -0
  33. package/dist/glassbox-routes/react/index.mjs +754 -0
  34. package/dist/index.d.mts +2739 -17
  35. package/dist/index.d.ts +2739 -17
  36. package/dist/index.js +8989 -1659
  37. package/dist/index.mjs +5078 -367
  38. package/dist/ir-Bqn1RVdV.d.mts +1583 -0
  39. package/dist/ir-Bvlkw5ja.d.ts +1583 -0
  40. package/dist/key-health.d.mts +131 -0
  41. package/dist/key-health.d.ts +131 -0
  42. package/dist/key-health.js +228 -0
  43. package/dist/key-health.mjs +6 -0
  44. package/dist/profiles.d.mts +292 -2
  45. package/dist/profiles.d.ts +292 -2
  46. package/dist/profiles.js +1231 -16
  47. package/dist/profiles.mjs +9 -1
  48. package/dist/types-Bon96eyc.d.ts +131 -0
  49. package/dist/types-CwGhacGT.d.mts +149 -0
  50. package/dist/types-DIxRZ3Dj.d.ts +149 -0
  51. package/dist/types-DsEq35WY.d.mts +131 -0
  52. package/package.json +54 -8
  53. package/dist/chunk-MBEI5UOM.mjs +0 -409
  54. package/dist/profiles-B3eNQ2py.d.ts +0 -619
  55. package/dist/profiles-Py8c7zjJ.d.mts +0 -619
@@ -0,0 +1,819 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/glassbox-routes/react/index.ts
21
+ var react_exports = {};
22
+ __export(react_exports, {
23
+ DEFAULT_GLASSBOX_THEME: () => DEFAULT_GLASSBOX_THEME,
24
+ GlassboxTraceCard: () => GlassboxTraceCard
25
+ });
26
+ module.exports = __toCommonJS(react_exports);
27
+
28
+ // src/glassbox-routes/format.ts
29
+ function formatAgo(iso, now = Date.now()) {
30
+ const t = Date.parse(iso);
31
+ if (Number.isNaN(t)) return iso;
32
+ const sec = Math.max(0, Math.floor((now - t) / 1e3));
33
+ if (sec < 60) return `${sec}s ago`;
34
+ if (sec < 3600) return `${Math.floor(sec / 60)}m ago`;
35
+ if (sec < 86400) return `${Math.floor(sec / 3600)}h ago`;
36
+ return `${Math.floor(sec / 86400)}d ago`;
37
+ }
38
+ function shortTraceId(traceId) {
39
+ return traceId.slice(-6);
40
+ }
41
+ function formatCost(usd) {
42
+ if (usd === void 0 || usd === null || Number.isNaN(usd)) return "\u2014";
43
+ if (usd === 0) return "$0.0000";
44
+ if (usd < 0.01) return `$${usd.toFixed(4)}`;
45
+ return `$${usd.toFixed(3)}`;
46
+ }
47
+ function formatMs(ms) {
48
+ if (ms === void 0 || ms === null) return "\u2014";
49
+ if (ms < 1e3) return `${ms}ms`;
50
+ return `${(ms / 1e3).toFixed(1)}s`;
51
+ }
52
+ function formatOrDash(v) {
53
+ if (v === void 0 || v === null) return "\u2014";
54
+ if (typeof v === "number") return v.toLocaleString();
55
+ return v;
56
+ }
57
+ function inputRatioLabel(status) {
58
+ switch (status) {
59
+ case "green":
60
+ return "healthy";
61
+ case "yellow":
62
+ return "borderline";
63
+ case "red":
64
+ return "input-heavy";
65
+ }
66
+ }
67
+ function formatMutation(mutation) {
68
+ const m = /^(.*)-(\d+)-to-(\d+)$/.exec(mutation);
69
+ if (m) {
70
+ return `${m[1]} (${m[2]} \u2192 ${m[3]})`;
71
+ }
72
+ return mutation;
73
+ }
74
+
75
+ // src/glassbox-routes/react/theme.ts
76
+ var DEFAULT_GLASSBOX_THEME = {
77
+ colors: {
78
+ surface: "#F8FAFC",
79
+ border: "#E2E8F0",
80
+ borderSoft: "#F1F5F9",
81
+ cardBg: "#FFFFFF",
82
+ text: "#1E293B",
83
+ textMuted: "#64748B",
84
+ textFaint: "#94A3B8",
85
+ ok: "#15803D",
86
+ warn: "#B45309",
87
+ fail: "#B91C1C",
88
+ info: "#1D4ED8"
89
+ },
90
+ fonts: {
91
+ sans: 'system-ui, -apple-system, "Segoe UI", sans-serif',
92
+ serif: 'Georgia, "Times New Roman", serif',
93
+ mono: "ui-monospace, Menlo, Consolas, monospace"
94
+ }
95
+ };
96
+
97
+ // src/glassbox-routes/react/GlassboxTraceCard.tsx
98
+ var import_jsx_runtime = require("react/jsx-runtime");
99
+ function Card({ children, title, emphasis = "default", theme }) {
100
+ const { colors, fonts } = theme;
101
+ const accentColor = emphasis === "coaching" ? colors.warn : emphasis === "counterfactuals" ? colors.ok : emphasis === "mutations" ? colors.textMuted : null;
102
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
103
+ "div",
104
+ {
105
+ style: {
106
+ background: colors.cardBg,
107
+ border: `1px solid ${colors.border}`,
108
+ borderLeft: accentColor ? `4px solid ${accentColor}` : `1px solid ${colors.border}`,
109
+ borderRadius: 6,
110
+ padding: 14,
111
+ marginBottom: 10
112
+ },
113
+ children: [
114
+ title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
115
+ "div",
116
+ {
117
+ style: {
118
+ fontSize: 11,
119
+ fontWeight: 600,
120
+ textTransform: "uppercase",
121
+ letterSpacing: 0.4,
122
+ color: colors.textMuted,
123
+ fontFamily: fonts.sans,
124
+ marginBottom: 8
125
+ },
126
+ children: title
127
+ }
128
+ ),
129
+ children
130
+ ]
131
+ }
132
+ );
133
+ }
134
+ function HealthDot({
135
+ axis,
136
+ status,
137
+ theme
138
+ }) {
139
+ const { colors } = theme;
140
+ const color = status === "green" ? colors.ok : status === "yellow" ? colors.warn : status === "red" ? colors.fail : colors.textFaint;
141
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
142
+ "span",
143
+ {
144
+ title: `${axis}: ${status}`,
145
+ "aria-label": `${axis} ${status}`,
146
+ style: {
147
+ display: "inline-block",
148
+ width: 8,
149
+ height: 8,
150
+ borderRadius: "50%",
151
+ background: color,
152
+ marginRight: 6
153
+ }
154
+ }
155
+ );
156
+ }
157
+ function AdvisoryRow({
158
+ advisory,
159
+ theme
160
+ }) {
161
+ const { colors, fonts } = theme;
162
+ const color = advisory.level === "critical" ? colors.fail : advisory.level === "warn" ? colors.warn : colors.info;
163
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
164
+ "div",
165
+ {
166
+ style: {
167
+ display: "flex",
168
+ flexWrap: "wrap",
169
+ gap: 8,
170
+ alignItems: "baseline",
171
+ padding: "6px 0",
172
+ borderTop: `1px solid ${colors.borderSoft}`,
173
+ fontFamily: fonts.sans,
174
+ fontSize: 13
175
+ },
176
+ children: [
177
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
178
+ "span",
179
+ {
180
+ style: {
181
+ fontFamily: fonts.mono,
182
+ fontSize: 11,
183
+ color,
184
+ fontWeight: 600,
185
+ minWidth: 140
186
+ },
187
+ children: advisory.code
188
+ }
189
+ ),
190
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { color: colors.text, flex: 1 }, children: advisory.message }),
191
+ advisory.suggestedAdaptation && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
192
+ "span",
193
+ {
194
+ style: {
195
+ fontFamily: fonts.mono,
196
+ fontSize: 11,
197
+ color: colors.textMuted
198
+ },
199
+ title: advisory.suggestedAdaptation.consequence,
200
+ children: [
201
+ "\u2192 try ",
202
+ advisory.suggestedAdaptation.parameter,
203
+ ":\xA0",
204
+ String(advisory.suggestedAdaptation.value)
205
+ ]
206
+ }
207
+ )
208
+ ]
209
+ }
210
+ );
211
+ }
212
+ function SectionRewriteRow({
213
+ rewrite,
214
+ theme
215
+ }) {
216
+ const { colors, fonts } = theme;
217
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
218
+ "div",
219
+ {
220
+ style: {
221
+ display: "flex",
222
+ flexWrap: "wrap",
223
+ gap: 8,
224
+ alignItems: "baseline",
225
+ padding: "6px 0",
226
+ borderTop: `1px solid ${colors.borderSoft}`,
227
+ fontFamily: fonts.sans,
228
+ fontSize: 13
229
+ },
230
+ title: `${rewrite.rule} \xB7 ${rewrite.kind} \xB7 ${rewrite.sectionId}`,
231
+ children: [
232
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
233
+ "span",
234
+ {
235
+ style: {
236
+ fontFamily: fonts.mono,
237
+ fontSize: 11,
238
+ color: colors.info,
239
+ fontWeight: 600,
240
+ minWidth: 140
241
+ },
242
+ children: "translator-rewrite"
243
+ }
244
+ ),
245
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { color: colors.text, flex: 1 }, children: rewrite.summary })
246
+ ]
247
+ }
248
+ );
249
+ }
250
+ function CounterfactualAsAdvisoryRow({
251
+ cf,
252
+ theme
253
+ }) {
254
+ const { colors, fonts } = theme;
255
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
256
+ "div",
257
+ {
258
+ style: {
259
+ display: "flex",
260
+ flexWrap: "wrap",
261
+ gap: 8,
262
+ alignItems: "baseline",
263
+ padding: "6px 0",
264
+ borderTop: `1px solid ${colors.borderSoft}`,
265
+ fontFamily: fonts.sans,
266
+ fontSize: 13
267
+ },
268
+ children: [
269
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
270
+ "span",
271
+ {
272
+ style: {
273
+ fontFamily: fonts.mono,
274
+ fontSize: 11,
275
+ color: colors.info,
276
+ fontWeight: 600,
277
+ minWidth: 140
278
+ },
279
+ children: "cheaper-alternative"
280
+ }
281
+ ),
282
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { style: { color: colors.text, flex: 1 }, children: [
283
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { fontFamily: fonts.serif, fontWeight: 600, fontSize: 15 }, children: cf.modelId }),
284
+ " ",
285
+ "would do this for ",
286
+ formatCost(cf.estimatedCostUsd),
287
+ " (saves",
288
+ " ",
289
+ formatCost(cf.savingsUsd),
290
+ " / ",
291
+ cf.savingsPercent,
292
+ "%)"
293
+ ] })
294
+ ]
295
+ }
296
+ );
297
+ }
298
+ function HeaderRow({
299
+ detail,
300
+ theme
301
+ }) {
302
+ const { colors, fonts } = theme;
303
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
304
+ "div",
305
+ {
306
+ style: {
307
+ display: "flex",
308
+ alignItems: "baseline",
309
+ gap: 12,
310
+ flexWrap: "wrap"
311
+ },
312
+ children: [
313
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
314
+ "span",
315
+ {
316
+ style: {
317
+ fontFamily: fonts.serif,
318
+ fontWeight: 600,
319
+ fontSize: 22,
320
+ color: colors.text
321
+ },
322
+ children: detail.archetype
323
+ }
324
+ ),
325
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { color: colors.textFaint }, children: "\xB7" }),
326
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
327
+ "span",
328
+ {
329
+ style: {
330
+ fontFamily: fonts.sans,
331
+ fontSize: 12,
332
+ color: colors.textMuted
333
+ },
334
+ children: formatAgo(detail.createdAt)
335
+ }
336
+ ),
337
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { color: colors.textFaint }, children: "\xB7" }),
338
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
339
+ "span",
340
+ {
341
+ title: detail.traceId,
342
+ style: {
343
+ fontFamily: fonts.mono,
344
+ fontSize: 11,
345
+ background: colors.surface,
346
+ border: `1px solid ${colors.border}`,
347
+ borderRadius: 999,
348
+ padding: "2px 10px",
349
+ color: colors.textMuted
350
+ },
351
+ children: shortTraceId(detail.traceId)
352
+ }
353
+ )
354
+ ]
355
+ }
356
+ );
357
+ }
358
+ function OutcomeCard({
359
+ detail,
360
+ theme
361
+ }) {
362
+ const { colors, fonts } = theme;
363
+ const isFail = detail.finishReason !== void 0 && detail.finishReason !== "stop" && detail.finishReason !== "tool_use";
364
+ const statusColor = isFail ? colors.fail : colors.ok;
365
+ const totalLabel = detail.totalMs !== void 0 ? formatMs(detail.totalMs) : "\u2014";
366
+ const ttftLabel = detail.ttftMs !== void 0 ? ` \xB7 TTFT ${formatMs(detail.ttftMs)}` : "";
367
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card, { theme, children: [
368
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
369
+ "div",
370
+ {
371
+ style: {
372
+ display: "flex",
373
+ alignItems: "baseline",
374
+ gap: 14,
375
+ flexWrap: "wrap",
376
+ fontFamily: fonts.sans,
377
+ fontSize: 14
378
+ },
379
+ children: [
380
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
381
+ "span",
382
+ {
383
+ style: {
384
+ color: statusColor,
385
+ fontWeight: 700,
386
+ fontSize: 18
387
+ },
388
+ children: isFail ? "\u2717" : "\u2713"
389
+ }
390
+ ),
391
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
392
+ "span",
393
+ {
394
+ style: {
395
+ fontFamily: fonts.mono,
396
+ fontSize: 13,
397
+ color: colors.text,
398
+ fontWeight: 600
399
+ },
400
+ children: detail.target
401
+ }
402
+ ),
403
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
404
+ "span",
405
+ {
406
+ style: {
407
+ fontFamily: fonts.serif,
408
+ fontWeight: 600,
409
+ fontSize: 18,
410
+ color: colors.text
411
+ },
412
+ children: formatCost(detail.estimatedCostUsd)
413
+ }
414
+ ),
415
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { style: { color: colors.textMuted, fontSize: 12 }, children: [
416
+ totalLabel,
417
+ ttftLabel
418
+ ] })
419
+ ]
420
+ }
421
+ ),
422
+ detail.fellOverFrom && detail.fellOverFrom !== detail.target && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
423
+ "div",
424
+ {
425
+ style: {
426
+ marginTop: 6,
427
+ fontFamily: fonts.sans,
428
+ fontSize: 12,
429
+ color: colors.warn
430
+ },
431
+ children: [
432
+ "\u2191 fell over from",
433
+ " ",
434
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { fontFamily: fonts.mono }, children: detail.fellOverFrom }),
435
+ detail.fallbackReason && ` (${detail.fallbackReason})`
436
+ ]
437
+ }
438
+ )
439
+ ] });
440
+ }
441
+ function CoachingCard({
442
+ detail,
443
+ theme
444
+ }) {
445
+ const advisories = detail.advisories ?? [];
446
+ const sectionRewrites = detail.sectionRewritesApplied ?? [];
447
+ const counterfactuals = detail.counterfactuals ?? [];
448
+ const topCF = counterfactuals[0];
449
+ if (advisories.length === 0 && sectionRewrites.length === 0 && !topCF) {
450
+ return null;
451
+ }
452
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card, { title: "\u26A0 Coaching", emphasis: "coaching", theme, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
453
+ advisories.map((a, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AdvisoryRow, { advisory: a, theme }, `adv-${i}`)),
454
+ sectionRewrites.map((r, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SectionRewriteRow, { rewrite: r, theme }, `rw-${i}`)),
455
+ topCF && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CounterfactualAsAdvisoryRow, { cf: topCF, theme })
456
+ ] }) });
457
+ }
458
+ function ShapeCard({
459
+ detail,
460
+ theme
461
+ }) {
462
+ const { colors, fonts } = theme;
463
+ const total = detail.tokensIn + detail.tokensOut;
464
+ const ratioPct = total > 0 ? Math.round(detail.tokensIn / total * 100) : 0;
465
+ const cachingOff = detail.historyCacheableTokens > 1e3 && detail.cacheReadInputTokens === 0;
466
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card, { theme, children: [
467
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
468
+ "div",
469
+ {
470
+ style: {
471
+ display: "flex",
472
+ justifyContent: "space-between",
473
+ alignItems: "center",
474
+ marginBottom: 8
475
+ },
476
+ children: [
477
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
478
+ "div",
479
+ {
480
+ style: {
481
+ fontSize: 11,
482
+ fontWeight: 600,
483
+ textTransform: "uppercase",
484
+ letterSpacing: 0.4,
485
+ color: colors.textMuted,
486
+ fontFamily: fonts.sans
487
+ },
488
+ children: "\u{1F4CA} Shape"
489
+ }
490
+ ),
491
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
492
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
493
+ HealthDot,
494
+ {
495
+ axis: "input",
496
+ status: detail.health.inputRatioStatus,
497
+ theme
498
+ }
499
+ ),
500
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
501
+ HealthDot,
502
+ {
503
+ axis: "cache",
504
+ status: detail.health.cacheStatus,
505
+ theme
506
+ }
507
+ ),
508
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
509
+ HealthDot,
510
+ {
511
+ axis: "fallback",
512
+ status: detail.health.fallbackStatus,
513
+ theme
514
+ }
515
+ )
516
+ ] })
517
+ ]
518
+ }
519
+ ),
520
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
521
+ "div",
522
+ {
523
+ style: {
524
+ fontFamily: fonts.sans,
525
+ fontSize: 13,
526
+ color: colors.text,
527
+ marginBottom: 4
528
+ },
529
+ children: [
530
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { fontFamily: fonts.serif, fontWeight: 600, fontSize: 15 }, children: detail.tokensIn.toLocaleString() }),
531
+ " ",
532
+ "in \xB7",
533
+ " ",
534
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { fontFamily: fonts.serif, fontWeight: 600, fontSize: 15 }, children: detail.tokensOut.toLocaleString() }),
535
+ " ",
536
+ "out (",
537
+ ratioPct,
538
+ "% input \u2014 ",
539
+ inputRatioLabel(detail.health.inputRatioStatus),
540
+ ")"
541
+ ]
542
+ }
543
+ ),
544
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
545
+ "div",
546
+ {
547
+ style: {
548
+ fontFamily: fonts.sans,
549
+ fontSize: 12,
550
+ color: colors.textMuted,
551
+ marginBottom: 4
552
+ },
553
+ children: detail.historyCacheableTokens === 0 ? "cache: no cacheable history" : `cache: ${detail.cacheReadInputTokens.toLocaleString()} / ${detail.historyCacheableTokens.toLocaleString()} of cacheable history${cachingOff ? " (caching off)" : ""}`
554
+ }
555
+ ),
556
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
557
+ "div",
558
+ {
559
+ style: {
560
+ fontFamily: fonts.sans,
561
+ fontSize: 12,
562
+ color: colors.textMuted
563
+ },
564
+ children: [
565
+ formatOrDash(detail.toolsCount),
566
+ " tools \xB7",
567
+ " ",
568
+ formatOrDash(detail.historyDepth),
569
+ " history msgs \xB7 system",
570
+ " ",
571
+ detail.systemPromptChars !== void 0 ? `${detail.systemPromptChars.toLocaleString()} chars` : "\u2014"
572
+ ]
573
+ }
574
+ )
575
+ ] });
576
+ }
577
+ function MutationsCard({
578
+ detail,
579
+ theme
580
+ }) {
581
+ const { colors, fonts } = theme;
582
+ const mutations = detail.mutationsApplied ?? [];
583
+ if (mutations.length === 0) return null;
584
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card, { title: "\u{1F4CB} What kgauto did", emphasis: "mutations", theme, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
585
+ "ul",
586
+ {
587
+ style: {
588
+ margin: 0,
589
+ padding: 0,
590
+ listStyle: "none",
591
+ fontFamily: fonts.sans,
592
+ fontSize: 13,
593
+ color: colors.text
594
+ },
595
+ children: mutations.map((m, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
596
+ "li",
597
+ {
598
+ style: {
599
+ padding: "4px 0",
600
+ borderTop: i === 0 ? "none" : `1px solid ${colors.borderSoft}`,
601
+ fontFamily: fonts.mono,
602
+ fontSize: 12
603
+ },
604
+ children: formatMutation(m)
605
+ },
606
+ `mut-${i}`
607
+ ))
608
+ }
609
+ ) });
610
+ }
611
+ function CounterfactualsCard({
612
+ detail,
613
+ coachingPresent,
614
+ theme
615
+ }) {
616
+ const { colors, fonts } = theme;
617
+ const cfs = detail.counterfactuals ?? [];
618
+ if (cfs.length === 0) return null;
619
+ if (coachingPresent) return null;
620
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card, { title: "\u{1F4B0} Cheaper alternatives", emphasis: "counterfactuals", theme, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
621
+ "ul",
622
+ {
623
+ style: {
624
+ margin: 0,
625
+ padding: 0,
626
+ listStyle: "none",
627
+ fontFamily: fonts.sans,
628
+ fontSize: 13,
629
+ color: colors.text
630
+ },
631
+ children: cfs.slice(0, 2).map((cf, i) => {
632
+ const yearlySavings = detail.projectedDailyCostUsd !== void 0 && detail.estimatedCostUsd > 0 ? cf.savingsUsd * (detail.projectedDailyCostUsd / Math.max(detail.estimatedCostUsd, 1e-9)) * 365 : null;
633
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
634
+ "li",
635
+ {
636
+ style: {
637
+ padding: "6px 0",
638
+ borderTop: i === 0 ? "none" : `1px solid ${colors.borderSoft}`
639
+ },
640
+ children: [
641
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
642
+ "span",
643
+ {
644
+ style: {
645
+ fontFamily: fonts.serif,
646
+ fontWeight: 600,
647
+ fontSize: 16
648
+ },
649
+ children: cf.modelId
650
+ }
651
+ ),
652
+ " ",
653
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { fontFamily: fonts.mono, fontSize: 12 }, children: formatCost(cf.estimatedCostUsd) }),
654
+ " ",
655
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { style: { color: colors.textMuted, fontSize: 12 }, children: [
656
+ "(saves ",
657
+ formatCost(cf.savingsUsd),
658
+ " / ",
659
+ cf.savingsPercent,
660
+ "%",
661
+ yearlySavings !== null ? ` / $${yearlySavings.toFixed(0)}/year at current volume` : "",
662
+ ")"
663
+ ] })
664
+ ]
665
+ },
666
+ `cf-${i}`
667
+ );
668
+ })
669
+ }
670
+ ) });
671
+ }
672
+ function RawExpandCard({
673
+ detail,
674
+ theme
675
+ }) {
676
+ const { colors, fonts } = theme;
677
+ if (detail.rawRequest === void 0 && detail.rawResponse === void 0) {
678
+ return null;
679
+ }
680
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card, { theme, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("details", { children: [
681
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
682
+ "summary",
683
+ {
684
+ style: {
685
+ cursor: "pointer",
686
+ fontFamily: fonts.sans,
687
+ fontSize: 12,
688
+ color: colors.textMuted,
689
+ listStyle: "none"
690
+ },
691
+ children: "\u25B6 Request / Response"
692
+ }
693
+ ),
694
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { marginTop: 8 }, children: [
695
+ detail.rawRequest !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
696
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
697
+ "div",
698
+ {
699
+ style: {
700
+ fontFamily: fonts.sans,
701
+ fontSize: 10,
702
+ fontWeight: 600,
703
+ textTransform: "uppercase",
704
+ letterSpacing: 0.4,
705
+ color: colors.textMuted,
706
+ marginTop: 6,
707
+ marginBottom: 4
708
+ },
709
+ children: "Request"
710
+ }
711
+ ),
712
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
713
+ "pre",
714
+ {
715
+ style: {
716
+ fontFamily: fonts.mono,
717
+ fontSize: 11,
718
+ lineHeight: 1.5,
719
+ background: colors.surface,
720
+ border: `1px solid ${colors.border}`,
721
+ borderRadius: 6,
722
+ padding: 10,
723
+ maxHeight: 280,
724
+ overflow: "auto",
725
+ whiteSpace: "pre-wrap",
726
+ wordBreak: "break-word",
727
+ color: colors.text,
728
+ margin: 0
729
+ },
730
+ children: detail.rawRequest
731
+ }
732
+ )
733
+ ] }),
734
+ detail.rawResponse !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
735
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
736
+ "div",
737
+ {
738
+ style: {
739
+ fontFamily: fonts.sans,
740
+ fontSize: 10,
741
+ fontWeight: 600,
742
+ textTransform: "uppercase",
743
+ letterSpacing: 0.4,
744
+ color: colors.textMuted,
745
+ marginTop: 10,
746
+ marginBottom: 4
747
+ },
748
+ children: "Response"
749
+ }
750
+ ),
751
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
752
+ "pre",
753
+ {
754
+ style: {
755
+ fontFamily: fonts.mono,
756
+ fontSize: 11,
757
+ lineHeight: 1.5,
758
+ background: colors.surface,
759
+ border: `1px solid ${colors.border}`,
760
+ borderRadius: 6,
761
+ padding: 10,
762
+ maxHeight: 280,
763
+ overflow: "auto",
764
+ whiteSpace: "pre-wrap",
765
+ wordBreak: "break-word",
766
+ color: colors.text,
767
+ margin: 0
768
+ },
769
+ children: detail.rawResponse
770
+ }
771
+ )
772
+ ] })
773
+ ] })
774
+ ] }) });
775
+ }
776
+ function GlassboxTraceCard({
777
+ detail,
778
+ theme = DEFAULT_GLASSBOX_THEME
779
+ }) {
780
+ const { colors } = theme;
781
+ const advisories = detail.advisories ?? [];
782
+ const sectionRewrites = detail.sectionRewritesApplied ?? [];
783
+ const counterfactuals = detail.counterfactuals ?? [];
784
+ const topCF = counterfactuals[0];
785
+ const coachingPresent = advisories.length > 0 || sectionRewrites.length > 0 || !!topCF;
786
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
787
+ "div",
788
+ {
789
+ style: {
790
+ background: colors.surface,
791
+ border: `1px solid ${colors.border}`,
792
+ borderRadius: 8,
793
+ padding: 14,
794
+ marginBottom: 16
795
+ },
796
+ children: [
797
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { marginBottom: 10 }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(HeaderRow, { detail, theme }) }),
798
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeCard, { detail, theme }),
799
+ coachingPresent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CoachingCard, { detail, theme }),
800
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ShapeCard, { detail, theme }),
801
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MutationsCard, { detail, theme }),
802
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
803
+ CounterfactualsCard,
804
+ {
805
+ detail,
806
+ coachingPresent,
807
+ theme
808
+ }
809
+ ),
810
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RawExpandCard, { detail, theme })
811
+ ]
812
+ }
813
+ );
814
+ }
815
+ // Annotate the CommonJS export names for ESM import in node:
816
+ 0 && (module.exports = {
817
+ DEFAULT_GLASSBOX_THEME,
818
+ GlassboxTraceCard
819
+ });