asta-ui 0.9.5 → 0.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/asta.css +2 -2
- package/css/asta.js +1461 -1
- package/css/components.css +1900 -138
- package/css/runtime/agent.css +136 -0
- package/css/runtime/agent.js +173 -0
- package/css/runtime/assist.css +79 -0
- package/css/runtime/assist.js +799 -0
- package/css/runtime/controls.css +48 -0
- package/css/runtime/controls.js +482 -0
- package/css/src/agent.css +484 -0
- package/css/src/assist.css +598 -0
- package/css/src/controls.css +424 -0
- package/css/tokens.css +16 -0
- package/dist/agent-plan.d.ts +2 -0
- package/dist/agent-plan.js +11 -0
- package/dist/agent-team.d.ts +2 -0
- package/dist/agent-team.js +7 -0
- package/dist/api-keys.d.ts +2 -0
- package/dist/api-keys.js +10 -0
- package/dist/autonomy-dial.d.ts +2 -0
- package/dist/autonomy-dial.js +7 -0
- package/dist/base/agent-plan.d.ts +2 -0
- package/dist/base/agent-plan.js +11 -0
- package/dist/base/agent-team.d.ts +2 -0
- package/dist/base/agent-team.js +7 -0
- package/dist/base/api-keys.d.ts +2 -0
- package/dist/base/api-keys.js +10 -0
- package/dist/base/autonomy-dial.d.ts +2 -0
- package/dist/base/autonomy-dial.js +7 -0
- package/dist/base/change-ledger.d.ts +2 -0
- package/dist/base/change-ledger.js +7 -0
- package/dist/base/citations.d.ts +2 -0
- package/dist/base/citations.js +9 -0
- package/dist/base/context-meter.d.ts +2 -0
- package/dist/base/context-meter.js +14 -0
- package/dist/base/fallback-chain.d.ts +2 -0
- package/dist/base/fallback-chain.js +7 -0
- package/dist/base/model-picker.d.ts +2 -0
- package/dist/base/model-picker.js +9 -0
- package/dist/base/navbar.js +1 -1
- package/dist/base/prompt-composer.d.ts +2 -0
- package/dist/base/prompt-composer.js +9 -0
- package/dist/base/scrub-input.d.ts +2 -0
- package/dist/base/scrub-input.js +13 -0
- package/dist/base/sidebar.js +1 -1
- package/dist/base/thinking.d.ts +2 -0
- package/dist/base/thinking.js +11 -0
- package/dist/base/tool-approval.d.ts +2 -0
- package/dist/base/tool-approval.js +9 -0
- package/dist/base/trace-waterfall.d.ts +2 -0
- package/dist/base/trace-waterfall.js +9 -0
- package/dist/base.js +204 -136
- package/dist/change-ledger.d.ts +2 -0
- package/dist/change-ledger.js +7 -0
- package/dist/chunk-24O5V2PQ.js +253 -0
- package/dist/chunk-44DNL43W.js +490 -0
- package/dist/chunk-45IXJ7W7.js +245 -0
- package/dist/chunk-ANL6VX4X.js +326 -0
- package/dist/chunk-DNROUJ62.js +432 -0
- package/dist/{chunk-2EBWWZPS.js → chunk-DWPGFNNF.js} +38 -9
- package/dist/{chunk-CACW5LH3.js → chunk-EAHHWF3V.js} +38 -9
- package/dist/chunk-F4CWSZXK.js +226 -0
- package/dist/chunk-FT66LAUZ.js +388 -0
- package/dist/chunk-GBOJUMMY.js +163 -0
- package/dist/chunk-H4NFBYKY.js +275 -0
- package/dist/chunk-KFPGQ5RT.js +321 -0
- package/dist/chunk-OIIMYSVT.js +342 -0
- package/dist/chunk-SUWA7DM6.js +388 -0
- package/dist/chunk-TL32C2SQ.js +221 -0
- package/dist/chunk-UBTYMAKF.js +240 -0
- package/dist/chunk-W6YVDJHX.js +235 -0
- package/dist/chunk-XYQI4ZYV.js +314 -0
- package/dist/citations.d.ts +2 -0
- package/dist/citations.js +9 -0
- package/dist/context-meter.d.ts +2 -0
- package/dist/context-meter.js +14 -0
- package/dist/fallback-chain.d.ts +2 -0
- package/dist/fallback-chain.js +7 -0
- package/dist/index.js +204 -136
- package/dist/model-picker.d.ts +2 -0
- package/dist/model-picker.js +9 -0
- package/dist/navbar.js +1 -1
- package/dist/prompt-composer.d.ts +2 -0
- package/dist/prompt-composer.js +9 -0
- package/dist/scrub-input.d.ts +2 -0
- package/dist/scrub-input.js +13 -0
- package/dist/sidebar.js +1 -1
- package/dist/thinking.d.ts +2 -0
- package/dist/thinking.js +11 -0
- package/dist/tool-approval.d.ts +2 -0
- package/dist/tool-approval.js +9 -0
- package/dist/trace-waterfall.d.ts +2 -0
- package/dist/trace-waterfall.js +9 -0
- package/dist/types/components/kit/agent-plan.d.ts +34 -0
- package/dist/types/components/kit/api-keys.d.ts +62 -0
- package/dist/types/components/kit/base/navbar.d.ts +4 -1
- package/dist/types/components/kit/base/sidebar.d.ts +29 -7
- package/dist/types/components/kit/citations.d.ts +34 -0
- package/dist/types/components/kit/context-meter.d.ts +38 -0
- package/dist/types/components/kit/model-picker.d.ts +46 -0
- package/dist/types/components/kit/navbar.d.ts +4 -1
- package/dist/types/components/kit/prompt-composer.d.ts +61 -0
- package/dist/types/components/kit/scrub-input.d.ts +44 -0
- package/dist/types/components/kit/sidebar.d.ts +29 -7
- package/dist/types/components/kit/thinking.d.ts +28 -0
- package/dist/types/components/kit/tool-approval.d.ts +43 -0
- package/dist/types/components/kit/trace-waterfall.d.ts +44 -0
- package/dist/types/components/lab/blocks/AgentTeam.d.ts +2 -0
- package/dist/types/components/lab/blocks/AutonomyDial.d.ts +2 -0
- package/dist/types/components/lab/blocks/ChangeLedger.d.ts +2 -0
- package/dist/types/components/lab/blocks/FallbackChain.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/agent-plan.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/agent-team.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/api-keys.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/autonomy-dial.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/agent-plan.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/agent-team.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/api-keys.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/autonomy-dial.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/change-ledger.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/citations.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/context-meter.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/fallback-chain.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/model-picker.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/prompt-composer.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/scrub-input.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/thinking.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/tool-approval.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/trace-waterfall.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base.d.ts +26 -2
- package/dist/types/packages/asta-ui/src/change-ledger.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/citations.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/context-meter.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/fallback-chain.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/index.d.ts +26 -2
- package/dist/types/packages/asta-ui/src/model-picker.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/prompt-composer.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/scrub-input.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/thinking.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/tool-approval.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/trace-waterfall.d.ts +2 -0
- package/package.json +1 -1
- package/dist/chunk-MVE7RJJ6.js +0 -322
- package/dist/chunk-TBMUSER2.js +0 -322
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// components/kit/trace-waterfall.tsx
|
|
4
|
+
import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
var cx = (...c) => c.filter(Boolean).join(" ");
|
|
7
|
+
var KEYFRAMES = `@keyframes asta-tw-grow { from { transform: translateX(var(--x)) scaleX(0) } }
|
|
8
|
+
@keyframes asta-tw-run { 50% { opacity: .45 } }
|
|
9
|
+
@keyframes asta-tw-in { from { opacity: 0; transform: translateY(6px) } }
|
|
10
|
+
@media (prefers-reduced-motion: reduce) { .asta-tw, .asta-tw * { animation: none !important; transition-duration: 0s !important } }`;
|
|
11
|
+
var EASE = "cubic-bezier(.16,1,.3,1)";
|
|
12
|
+
var KINDS = {
|
|
13
|
+
agent: { label: "Agent", fill: "bg-[color-mix(in_srgb,var(--ink)_22%,var(--paper))]", path: "M8 2.5v3M8 10.5v3M3.5 8h-1M13.5 8h-1M5 5l-.8-.8M11.8 11.8 11 11M11 5l.8-.8M4.2 11.8 5 11M8 5.5a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5Z" },
|
|
14
|
+
llm: { label: "LLM call", fill: "bg-brand", path: "M8 2c.4 2.9 1.6 4.1 4.5 4.5-2.9.4-4.1 1.6-4.5 4.5-.4-2.9-1.6-4.1-4.5-4.5C6.4 6.1 7.6 4.9 8 2Z" },
|
|
15
|
+
tool: { label: "Tool call", fill: "bg-ink", path: "M10.2 2.8a3 3 0 0 0-3.6 3.9L2.8 10.5a1.3 1.3 0 0 0 1.8 1.8l3.8-3.8a3 3 0 0 0 3.9-3.6l-1.8 1.8-1.6-.4-.4-1.6Z" },
|
|
16
|
+
retrieval: { label: "Retrieval", fill: "bg-[color-mix(in_srgb,var(--brand)_42%,var(--paper))]", path: "M3 4.5c0-1.1 2.2-2 5-2s5 .9 5 2-2.2 2-5 2-5-.9-5-2ZM3 4.5v7c0 1.1 2.2 2 5 2s5-.9 5-2v-7M3 8c0 1.1 2.2 2 5 2s5-.9 5-2" }
|
|
17
|
+
};
|
|
18
|
+
var STEPS = [10, 20, 50, 100, 200, 250, 500, 1e3, 2e3, 2500, 5e3, 1e4, 2e4, 3e4, 6e4];
|
|
19
|
+
var GRID = "grid grid-cols-[minmax(200px,1.3fr)_minmax(240px,2fr)_56px_68px_76px] sm:grid-cols-[minmax(232px,1.3fr)_minmax(240px,2fr)_56px_68px_76px] items-center gap-x-3";
|
|
20
|
+
var ms = (n) => n < 1e3 ? `${Math.round(n)} ms` : `${(n / 1e3).toFixed(n < 1e4 ? 2 : 1)} s`;
|
|
21
|
+
var tick = (n) => n === 0 ? "0" : n < 1e3 ? `${n}ms` : `${+(n / 1e3).toFixed(1)}s`;
|
|
22
|
+
var usd = (n) => `$${n < 0.01 ? n.toFixed(4) : n.toFixed(3)}`;
|
|
23
|
+
var num = (n) => n.toLocaleString("en-US");
|
|
24
|
+
function Glyph({ d, className }) {
|
|
25
|
+
return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", className: cx("h-3.5 w-3.5 shrink-0", className), fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d }) });
|
|
26
|
+
}
|
|
27
|
+
var WARN = "M8 2.5 14 13H2zM8 6.5v3M8 11.2h.01";
|
|
28
|
+
function Stat({ label, children }) {
|
|
29
|
+
return /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
30
|
+
/* @__PURE__ */ jsx("dt", { className: "text-[11.5px] text-mute", children: label }),
|
|
31
|
+
/* @__PURE__ */ jsx("dd", { className: "mt-0.5 truncate text-[13px] tabular-nums text-ink", children })
|
|
32
|
+
] });
|
|
33
|
+
}
|
|
34
|
+
function TraceWaterfall({ spans, title = "Agent run", live = false, startedAt, selected, defaultSelected = null, onSelect, loading, className }) {
|
|
35
|
+
const [innerSel, setInnerSel] = useState(defaultSelected);
|
|
36
|
+
const sel = selected !== void 0 ? selected : innerSel;
|
|
37
|
+
const [folded, setFolded] = useState(() => /* @__PURE__ */ new Set());
|
|
38
|
+
const [focusId, setFocusId] = useState(null);
|
|
39
|
+
const [now, setNow] = useState(0);
|
|
40
|
+
const [onScreen, setOnScreen] = useState(true);
|
|
41
|
+
const root = useRef(null);
|
|
42
|
+
const scroller = useRef(null);
|
|
43
|
+
const pinned = useRef(true);
|
|
44
|
+
const uid = useId();
|
|
45
|
+
const running = live && spans.some((s) => s.duration === void 0);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
const el = root.current;
|
|
48
|
+
if (!el) return;
|
|
49
|
+
const io = new IntersectionObserver(([e]) => setOnScreen(e.isIntersecting));
|
|
50
|
+
io.observe(el);
|
|
51
|
+
return () => io.disconnect();
|
|
52
|
+
}, []);
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (!running || !onScreen || startedAt === void 0) return;
|
|
55
|
+
let id;
|
|
56
|
+
const start = () => {
|
|
57
|
+
clearInterval(id);
|
|
58
|
+
if (!document.hidden) id = setInterval(() => setNow(Date.now() - startedAt), 200);
|
|
59
|
+
};
|
|
60
|
+
start();
|
|
61
|
+
document.addEventListener("visibilitychange", start);
|
|
62
|
+
return () => {
|
|
63
|
+
clearInterval(id);
|
|
64
|
+
document.removeEventListener("visibilitychange", start);
|
|
65
|
+
};
|
|
66
|
+
}, [running, onScreen, startedAt]);
|
|
67
|
+
const kids = useMemo(() => {
|
|
68
|
+
const m = /* @__PURE__ */ new Map();
|
|
69
|
+
const ids = new Set(spans.map((s) => s.id));
|
|
70
|
+
for (const s of spans) {
|
|
71
|
+
const p = s.parentId && ids.has(s.parentId) ? s.parentId : "";
|
|
72
|
+
m.set(p, [...m.get(p) ?? [], s]);
|
|
73
|
+
}
|
|
74
|
+
m.forEach((list) => list.sort((a, b) => a.start - b.start));
|
|
75
|
+
return m;
|
|
76
|
+
}, [spans]);
|
|
77
|
+
const rows = useMemo(() => {
|
|
78
|
+
const out = [];
|
|
79
|
+
const walk = (pid, depth) => {
|
|
80
|
+
for (const s of kids.get(pid) ?? []) {
|
|
81
|
+
const hasKids = (kids.get(s.id)?.length ?? 0) > 0;
|
|
82
|
+
out.push({ s, depth, parent: pid || null, hasKids });
|
|
83
|
+
if (hasKids && !folded.has(s.id)) walk(s.id, depth + 1);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
walk("", 0);
|
|
87
|
+
return out;
|
|
88
|
+
}, [kids, folded]);
|
|
89
|
+
const end = (s) => s.start + (s.duration ?? Math.max(now - s.start, 0));
|
|
90
|
+
const total = Math.max(1, ...spans.map(end));
|
|
91
|
+
const step = STEPS.find((st) => total / st <= 5) ?? 6e4;
|
|
92
|
+
const axis = Math.ceil(total / step) * step;
|
|
93
|
+
const ticks = Array.from({ length: Math.round(axis / step) + 1 }, (_, i) => i * step);
|
|
94
|
+
const tokens = spans.reduce((a, s) => a + (s.tokensIn ?? 0) + (s.tokensOut ?? 0), 0);
|
|
95
|
+
const cost = spans.reduce((a, s) => a + (s.cost ?? 0), 0);
|
|
96
|
+
const errors = spans.filter((s) => s.status === "error").length;
|
|
97
|
+
const current = spans.find((s) => s.id === sel) ?? null;
|
|
98
|
+
useLayoutEffect(() => {
|
|
99
|
+
const el = scroller.current;
|
|
100
|
+
if (live && el && pinned.current) el.scrollTop = el.scrollHeight;
|
|
101
|
+
}, [live, spans.length]);
|
|
102
|
+
const choose = (id) => {
|
|
103
|
+
if (selected === void 0) setInnerSel(id);
|
|
104
|
+
onSelect?.(id);
|
|
105
|
+
};
|
|
106
|
+
const fold = (id, to) => setFolded((f) => {
|
|
107
|
+
const n = new Set(f);
|
|
108
|
+
if (to ?? !n.has(id)) n.add(id);
|
|
109
|
+
else n.delete(id);
|
|
110
|
+
return n;
|
|
111
|
+
});
|
|
112
|
+
const focusRow = (id) => {
|
|
113
|
+
if (!id) return;
|
|
114
|
+
setFocusId(id);
|
|
115
|
+
root.current?.querySelector(`[data-span="${CSS.escape(id)}"]`)?.focus();
|
|
116
|
+
};
|
|
117
|
+
const onKey = (e, k) => {
|
|
118
|
+
const r = rows[k];
|
|
119
|
+
if (e.key === "ArrowDown") focusRow(rows[k + 1]?.s.id);
|
|
120
|
+
else if (e.key === "ArrowUp") focusRow(rows[k - 1]?.s.id);
|
|
121
|
+
else if (e.key === "Home") focusRow(rows[0]?.s.id);
|
|
122
|
+
else if (e.key === "End") focusRow(rows[rows.length - 1]?.s.id);
|
|
123
|
+
else if (e.key === "ArrowRight") {
|
|
124
|
+
if (r.hasKids && folded.has(r.s.id)) fold(r.s.id, false);
|
|
125
|
+
else if (r.hasKids) focusRow(rows[k + 1]?.s.id);
|
|
126
|
+
} else if (e.key === "ArrowLeft") {
|
|
127
|
+
if (r.hasKids && !folded.has(r.s.id)) fold(r.s.id, true);
|
|
128
|
+
else focusRow(r.parent ?? void 0);
|
|
129
|
+
} else if (e.key === "Enter" || e.key === " ") choose(sel === r.s.id ? null : r.s.id);
|
|
130
|
+
else if (e.key === "Escape" && sel) choose(null);
|
|
131
|
+
else return;
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
};
|
|
134
|
+
const tabbable = focusId && rows.some((r) => r.s.id === focusId) ? focusId : rows[0]?.s.id;
|
|
135
|
+
const head = "sticky top-0 z-20 bg-paper font-mono text-[10.5px] uppercase tracking-wider text-mute";
|
|
136
|
+
return /* @__PURE__ */ jsxs("div", { ref: root, className: cx("asta-tw flex w-full flex-col overflow-hidden rounded-[14px] bg-paper shadow-[0_0_0_1px_color-mix(in_srgb,var(--ink)_9%,transparent),0_1px_2px_rgb(0_0_0/0.04)]", className), children: [
|
|
137
|
+
/* @__PURE__ */ jsx("style", { href: "asta-trace-waterfall", precedence: "asta", children: KEYFRAMES }),
|
|
138
|
+
/* @__PURE__ */ jsxs("header", { className: "flex flex-wrap items-center gap-x-4 gap-y-2 px-4 pt-4 pb-3 sm:px-5", children: [
|
|
139
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
140
|
+
/* @__PURE__ */ jsx("h3", { className: "truncate text-[14px] font-medium tracking-[-0.01em] text-ink", children: title }),
|
|
141
|
+
running && /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5 rounded-[5px] bg-[color-mix(in_srgb,var(--brand)_10%,transparent)] px-1.5 py-0.5 text-[11.5px] font-medium text-brand", children: [
|
|
142
|
+
/* @__PURE__ */ jsx("span", { className: "h-1.5 w-1.5 rounded-full bg-brand", style: { animation: `asta-tw-run 1.2s ${EASE} infinite ${onScreen ? "running" : "paused"}` } }),
|
|
143
|
+
"Live"
|
|
144
|
+
] })
|
|
145
|
+
] }),
|
|
146
|
+
/* @__PURE__ */ jsxs("dl", { className: "flex flex-wrap items-center gap-x-4 gap-y-1 text-[12.5px] tabular-nums text-mute", children: [
|
|
147
|
+
[
|
|
148
|
+
["Duration", ms(total)],
|
|
149
|
+
["Tokens", num(tokens)],
|
|
150
|
+
["Cost", usd(cost)]
|
|
151
|
+
].map(([k, v]) => /* @__PURE__ */ jsxs("div", { className: "flex gap-1.5", children: [
|
|
152
|
+
/* @__PURE__ */ jsx("dt", { children: k }),
|
|
153
|
+
/* @__PURE__ */ jsx("dd", { className: "font-medium text-ink", children: v })
|
|
154
|
+
] }, k)),
|
|
155
|
+
errors > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 font-medium text-ink", children: [
|
|
156
|
+
/* @__PURE__ */ jsx(Glyph, { d: WARN }),
|
|
157
|
+
/* @__PURE__ */ jsx("dt", { className: "sr-only", children: "Errors" }),
|
|
158
|
+
/* @__PURE__ */ jsxs("dd", { children: [
|
|
159
|
+
errors,
|
|
160
|
+
" ",
|
|
161
|
+
errors === 1 ? "error" : "errors"
|
|
162
|
+
] })
|
|
163
|
+
] })
|
|
164
|
+
] }),
|
|
165
|
+
/* @__PURE__ */ jsx("ul", { className: "flex flex-wrap items-center gap-3 text-[11.5px] text-mute sm:ml-auto", "aria-label": "Legend", children: ["llm", "tool", "retrieval"].map((k) => /* @__PURE__ */ jsxs("li", { className: "flex items-center gap-1.5", children: [
|
|
166
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, className: cx("h-2 w-2 rounded-[2px]", KINDS[k].fill) }),
|
|
167
|
+
KINDS[k].label
|
|
168
|
+
] }, k)) })
|
|
169
|
+
] }),
|
|
170
|
+
/* @__PURE__ */ jsx(
|
|
171
|
+
"div",
|
|
172
|
+
{
|
|
173
|
+
ref: scroller,
|
|
174
|
+
onScroll: (e) => {
|
|
175
|
+
const el = e.currentTarget;
|
|
176
|
+
pinned.current = el.scrollHeight - el.scrollTop - el.clientHeight < 24;
|
|
177
|
+
},
|
|
178
|
+
className: "max-h-[440px] overflow-auto overscroll-contain [scrollbar-width:thin]",
|
|
179
|
+
children: /* @__PURE__ */ jsxs("div", { role: "treegrid", "aria-label": `${title} spans`, "aria-busy": loading || running || void 0, "aria-rowcount": rows.length + 1, className: "min-w-[700px] pb-2 sm:min-w-[740px]", children: [
|
|
180
|
+
/* @__PURE__ */ jsxs("div", { role: "row", className: cx(GRID, head, "h-8"), children: [
|
|
181
|
+
/* @__PURE__ */ jsx("span", { role: "columnheader", className: "left-0 z-10 bg-paper pl-4 sm:sticky sm:pl-5", children: "Span" }),
|
|
182
|
+
/* @__PURE__ */ jsxs("span", { role: "columnheader", className: "relative h-full", children: [
|
|
183
|
+
/* @__PURE__ */ jsxs("span", { className: "sr-only", children: [
|
|
184
|
+
"Timeline, 0 to ",
|
|
185
|
+
ms(axis)
|
|
186
|
+
] }),
|
|
187
|
+
ticks.map((t) => /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: cx("absolute top-1/2 -translate-y-1/2 normal-case tracking-normal", t === 0 ? "" : t === axis ? "-translate-x-full" : "-translate-x-1/2"), style: { left: `${t / axis * 100}%` }, children: tick(t) }, t))
|
|
188
|
+
] }),
|
|
189
|
+
/* @__PURE__ */ jsx("span", { role: "columnheader", className: "text-right", children: "Tokens" }),
|
|
190
|
+
/* @__PURE__ */ jsx("span", { role: "columnheader", className: "text-right", children: "Cost" }),
|
|
191
|
+
/* @__PURE__ */ jsx("span", { role: "columnheader", className: "pr-4 text-right sm:pr-5", children: "Latency" })
|
|
192
|
+
] }),
|
|
193
|
+
loading ? Array.from({ length: 6 }, (_, i) => /* @__PURE__ */ jsxs("div", { role: "row", className: cx(GRID, "h-10"), children: [
|
|
194
|
+
/* @__PURE__ */ jsx("span", { className: "pl-4 sm:pl-5", children: /* @__PURE__ */ jsx("span", { className: "block h-2.5 rounded-full bg-paper-2", style: { width: `${70 - i * 6}%`, marginLeft: i ? 16 : 0, animation: `asta-tw-run 1.4s ${EASE} ${i * 100}ms infinite` } }) }),
|
|
195
|
+
/* @__PURE__ */ jsx("span", { className: "relative h-2", children: /* @__PURE__ */ jsx("span", { className: "absolute inset-y-0 rounded-[2px] bg-paper-2", style: { left: `${i * 12}%`, width: `${30 - i * 3}%`, animation: `asta-tw-run 1.4s ${EASE} ${i * 100}ms infinite` } }) }),
|
|
196
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
197
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
198
|
+
/* @__PURE__ */ jsx("span", {})
|
|
199
|
+
] }, i)) : rows.map((r, k) => {
|
|
200
|
+
const s = r.s;
|
|
201
|
+
const kind = KINDS[s.kind];
|
|
202
|
+
const run = s.duration === void 0;
|
|
203
|
+
const dur = run ? Math.max(now - s.start, 0) : s.duration;
|
|
204
|
+
const x = s.start / axis;
|
|
205
|
+
const w = Math.max(dur / axis, 4e-3);
|
|
206
|
+
const on = sel === s.id;
|
|
207
|
+
const err = s.status === "error";
|
|
208
|
+
const bg = on ? "bg-[color-mix(in_srgb,var(--brand)_7%,var(--paper))]" : "bg-paper group-hover/row:bg-paper-2";
|
|
209
|
+
return /* @__PURE__ */ jsxs(
|
|
210
|
+
"div",
|
|
211
|
+
{
|
|
212
|
+
role: "row",
|
|
213
|
+
"data-span": s.id,
|
|
214
|
+
"aria-level": r.depth + 1,
|
|
215
|
+
"aria-expanded": r.hasKids ? !folded.has(s.id) : void 0,
|
|
216
|
+
"aria-selected": on,
|
|
217
|
+
tabIndex: tabbable === s.id ? 0 : -1,
|
|
218
|
+
onFocus: () => setFocusId(s.id),
|
|
219
|
+
onClick: () => choose(on ? null : s.id),
|
|
220
|
+
onKeyDown: (e) => onKey(e, k),
|
|
221
|
+
className: cx(GRID, "group/row h-10 cursor-pointer text-[13px] outline-none transition-colors duration-150 focus-visible:shadow-[inset_0_0_0_2px_color-mix(in_srgb,var(--brand)_55%,transparent)]", bg),
|
|
222
|
+
style: { animation: `asta-tw-in .35s ${EASE} both` },
|
|
223
|
+
children: [
|
|
224
|
+
/* @__PURE__ */ jsxs("span", { role: "gridcell", className: cx("left-0 z-10 flex h-full min-w-0 sm:sticky items-center gap-1.5 pr-3 transition-colors duration-150", bg), style: { paddingLeft: 16 + r.depth * 18 }, children: [
|
|
225
|
+
r.hasKids ? /* @__PURE__ */ jsx(
|
|
226
|
+
"button",
|
|
227
|
+
{
|
|
228
|
+
type: "button",
|
|
229
|
+
tabIndex: -1,
|
|
230
|
+
"aria-label": folded.has(s.id) ? `Expand ${s.name}` : `Collapse ${s.name}`,
|
|
231
|
+
onClick: (e) => {
|
|
232
|
+
e.stopPropagation();
|
|
233
|
+
fold(s.id);
|
|
234
|
+
},
|
|
235
|
+
className: "-ml-1 grid h-5 w-5 shrink-0 place-items-center rounded text-mute hover:bg-[color-mix(in_srgb,var(--ink)_8%,transparent)] hover:text-ink",
|
|
236
|
+
children: /* @__PURE__ */ jsx(Glyph, { d: "m6 4 4 4-4 4", className: cx("h-3 w-3 transition-transform duration-200 ease-[cubic-bezier(.16,1,.3,1)]", !folded.has(s.id) && "rotate-90") })
|
|
237
|
+
}
|
|
238
|
+
) : /* @__PURE__ */ jsx("span", { className: "w-4 shrink-0" }),
|
|
239
|
+
/* @__PURE__ */ jsx("span", { className: cx("grid h-5 w-5 shrink-0 place-items-center rounded-[5px]", s.kind === "llm" ? "bg-[color-mix(in_srgb,var(--brand)_12%,transparent)] text-brand" : "bg-paper-2 text-ink-2"), title: kind.label, children: /* @__PURE__ */ jsx(Glyph, { d: kind.path, className: "h-3 w-3" }) }),
|
|
240
|
+
/* @__PURE__ */ jsx("span", { className: cx("min-w-0 truncate", s.kind === "agent" ? "font-medium text-ink" : "text-ink-2"), children: s.name }),
|
|
241
|
+
/* @__PURE__ */ jsxs("span", { className: "sr-only", children: [
|
|
242
|
+
", ",
|
|
243
|
+
kind.label
|
|
244
|
+
] }),
|
|
245
|
+
err && /* @__PURE__ */ jsxs("span", { title: "Error", className: "grid h-5 w-5 shrink-0 place-items-center rounded-[5px] bg-ink text-paper", children: [
|
|
246
|
+
/* @__PURE__ */ jsx(Glyph, { d: WARN, className: "h-3 w-3" }),
|
|
247
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: ", Error" })
|
|
248
|
+
] })
|
|
249
|
+
] }),
|
|
250
|
+
/* @__PURE__ */ jsxs("span", { role: "gridcell", className: "relative h-full", children: [
|
|
251
|
+
ticks.slice(1, -1).map((t) => /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "absolute inset-y-0 w-px bg-[color-mix(in_srgb,var(--ink)_6%,transparent)]", style: { left: `${t / axis * 100}%` } }, t)),
|
|
252
|
+
/* @__PURE__ */ jsx("span", { className: "absolute inset-x-0 top-1/2 -mt-[5px] h-2.5", children: /* @__PURE__ */ jsx(
|
|
253
|
+
"span",
|
|
254
|
+
{
|
|
255
|
+
className: cx("absolute inset-0 origin-left rounded-[2px]", kind.fill, err && "opacity-60"),
|
|
256
|
+
style: {
|
|
257
|
+
"--x": `${x * 100}%`,
|
|
258
|
+
transform: `translateX(var(--x)) scaleX(${w})`,
|
|
259
|
+
transition: `transform .45s ${EASE}`,
|
|
260
|
+
animation: run ? `asta-tw-grow .6s ${EASE} both, asta-tw-run 1.2s ${EASE} .6s infinite ${onScreen ? "running" : "paused"}` : `asta-tw-grow .7s ${EASE} ${Math.round(x * 500)}ms both`
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
) }),
|
|
264
|
+
/* @__PURE__ */ jsxs("span", { className: "sr-only", children: [
|
|
265
|
+
"Starts at ",
|
|
266
|
+
ms(s.start),
|
|
267
|
+
", ",
|
|
268
|
+
run ? "running" : `takes ${ms(dur)}`
|
|
269
|
+
] })
|
|
270
|
+
] }),
|
|
271
|
+
/* @__PURE__ */ jsx("span", { role: "gridcell", className: "text-right text-[12.5px] tabular-nums text-ink-2", title: s.tokensIn !== void 0 ? `${num(s.tokensIn)} in \xB7 ${num(s.tokensOut ?? 0)} out` : void 0, children: s.tokensIn !== void 0 || s.tokensOut !== void 0 ? num((s.tokensIn ?? 0) + (s.tokensOut ?? 0)) : /* @__PURE__ */ jsx("span", { className: "text-mute", children: "\u2013" }) }),
|
|
272
|
+
/* @__PURE__ */ jsx("span", { role: "gridcell", className: "text-right text-[12.5px] tabular-nums text-ink-2", children: s.cost !== void 0 ? usd(s.cost) : /* @__PURE__ */ jsx("span", { className: "text-mute", children: "\u2013" }) }),
|
|
273
|
+
/* @__PURE__ */ jsx("span", { role: "gridcell", className: "pr-4 text-right text-[12.5px] tabular-nums text-ink sm:pr-5", children: run ? /* @__PURE__ */ jsx("span", { className: "font-medium text-brand", children: "Running" }) : ms(dur) })
|
|
274
|
+
]
|
|
275
|
+
},
|
|
276
|
+
s.id
|
|
277
|
+
);
|
|
278
|
+
}),
|
|
279
|
+
!loading && rows.length === 0 && /* @__PURE__ */ jsxs("div", { role: "row", className: "flex flex-col items-center gap-1 px-4 py-12 text-center", children: [
|
|
280
|
+
/* @__PURE__ */ jsx("span", { role: "gridcell", className: "text-[13px] font-medium text-ink-2", children: "No spans yet" }),
|
|
281
|
+
/* @__PURE__ */ jsx("span", { className: "text-[12.5px] text-mute", children: "Start a run and its steps show up here as they happen." })
|
|
282
|
+
] })
|
|
283
|
+
] })
|
|
284
|
+
}
|
|
285
|
+
),
|
|
286
|
+
current && /* @__PURE__ */ jsxs("section", { "aria-labelledby": `${uid}-d`, className: "flex flex-col gap-4 bg-paper-2 px-4 py-4 sm:px-5", style: { animation: `asta-tw-in .3s ${EASE}` }, children: [
|
|
287
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2.5", children: [
|
|
288
|
+
/* @__PURE__ */ jsx("span", { className: cx("grid h-7 w-7 shrink-0 place-items-center rounded-md", current.kind === "llm" ? "bg-[color-mix(in_srgb,var(--brand)_12%,transparent)] text-brand" : "bg-paper text-ink-2"), children: /* @__PURE__ */ jsx(Glyph, { d: KINDS[current.kind].path }) }),
|
|
289
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
290
|
+
/* @__PURE__ */ jsx("h4", { id: `${uid}-d`, className: "truncate text-[14px] font-medium text-ink", children: current.name }),
|
|
291
|
+
/* @__PURE__ */ jsxs("p", { className: "text-[12px] text-mute", children: [
|
|
292
|
+
KINDS[current.kind].label,
|
|
293
|
+
current.model && ` \xB7 ${current.model}`
|
|
294
|
+
] })
|
|
295
|
+
] }),
|
|
296
|
+
/* @__PURE__ */ jsx(
|
|
297
|
+
"button",
|
|
298
|
+
{
|
|
299
|
+
type: "button",
|
|
300
|
+
"aria-label": "Close span details",
|
|
301
|
+
onClick: () => {
|
|
302
|
+
choose(null);
|
|
303
|
+
focusRow(current.id);
|
|
304
|
+
},
|
|
305
|
+
className: "grid h-7 w-7 shrink-0 place-items-center rounded-md text-mute outline-none transition-colors hover:bg-paper hover:text-ink focus-visible:ring-2 focus-visible:ring-brand/50",
|
|
306
|
+
children: /* @__PURE__ */ jsx(Glyph, { d: "m4.5 4.5 7 7M11.5 4.5l-7 7" })
|
|
307
|
+
}
|
|
308
|
+
)
|
|
309
|
+
] }),
|
|
310
|
+
/* @__PURE__ */ jsxs("dl", { className: "grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-5", children: [
|
|
311
|
+
/* @__PURE__ */ jsxs(Stat, { label: "Starts at", children: [
|
|
312
|
+
"+",
|
|
313
|
+
ms(current.start)
|
|
314
|
+
] }),
|
|
315
|
+
/* @__PURE__ */ jsx(Stat, { label: "Latency", children: current.duration === void 0 ? "Running" : ms(current.duration) }),
|
|
316
|
+
/* @__PURE__ */ jsx(Stat, { label: "Tokens in / out", children: current.tokensIn !== void 0 ? `${num(current.tokensIn)} / ${num(current.tokensOut ?? 0)}` : "\u2013" }),
|
|
317
|
+
/* @__PURE__ */ jsx(Stat, { label: "Cost", children: current.cost !== void 0 ? usd(current.cost) : "\u2013" }),
|
|
318
|
+
/* @__PURE__ */ jsx(Stat, { label: "Status", children: current.status === "error" ? /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1 font-medium", children: [
|
|
319
|
+
/* @__PURE__ */ jsx(Glyph, { d: WARN, className: "h-3 w-3" }),
|
|
320
|
+
"Error"
|
|
321
|
+
] }) : current.duration === void 0 ? "Running" : "Done" })
|
|
322
|
+
] }),
|
|
323
|
+
current.error && /* @__PURE__ */ jsxs("p", { className: "flex gap-2 rounded-lg bg-paper px-3 py-2.5 text-[12.5px] leading-relaxed text-ink shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_14%,transparent)]", children: [
|
|
324
|
+
/* @__PURE__ */ jsx(Glyph, { d: WARN, className: "mt-0.5" }),
|
|
325
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
326
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: "Error: " }),
|
|
327
|
+
current.error
|
|
328
|
+
] })
|
|
329
|
+
] }),
|
|
330
|
+
/* @__PURE__ */ jsx("div", { className: "grid gap-3 md:grid-cols-2", children: ["input", "output"].map((f) => /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
331
|
+
/* @__PURE__ */ jsx("p", { className: "mb-1.5 font-mono text-[10.5px] uppercase tracking-wider text-mute", children: f }),
|
|
332
|
+
/* @__PURE__ */ jsx("pre", { className: "max-h-40 overflow-auto overscroll-contain whitespace-pre-wrap break-words rounded-lg bg-paper p-3 font-mono text-[12px] leading-relaxed text-ink-2 [scrollbar-width:thin]", children: current[f] || (f === "output" && current.duration === void 0 ? "Waiting for output\u2026" : "Nothing recorded.") })
|
|
333
|
+
] }, f)) })
|
|
334
|
+
] }, current.id)
|
|
335
|
+
] });
|
|
336
|
+
}
|
|
337
|
+
var trace_waterfall_default = TraceWaterfall;
|
|
338
|
+
|
|
339
|
+
export {
|
|
340
|
+
TraceWaterfall,
|
|
341
|
+
trace_waterfall_default
|
|
342
|
+
};
|