asta-ui 0.9.4 → 0.9.6

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 (130) hide show
  1. package/css/asta.css +2 -2
  2. package/css/asta.js +1461 -1
  3. package/css/components.css +1900 -138
  4. package/css/runtime/agent.css +136 -0
  5. package/css/runtime/agent.js +173 -0
  6. package/css/runtime/assist.css +79 -0
  7. package/css/runtime/assist.js +799 -0
  8. package/css/runtime/controls.css +48 -0
  9. package/css/runtime/controls.js +482 -0
  10. package/css/src/agent.css +484 -0
  11. package/css/src/assist.css +598 -0
  12. package/css/src/controls.css +424 -0
  13. package/css/tokens.css +16 -0
  14. package/dist/agent-plan.d.ts +2 -0
  15. package/dist/agent-plan.js +11 -0
  16. package/dist/agent-team.d.ts +2 -0
  17. package/dist/agent-team.js +7 -0
  18. package/dist/api-keys.d.ts +2 -0
  19. package/dist/api-keys.js +10 -0
  20. package/dist/autonomy-dial.d.ts +2 -0
  21. package/dist/autonomy-dial.js +7 -0
  22. package/dist/base/agent-plan.d.ts +2 -0
  23. package/dist/base/agent-plan.js +11 -0
  24. package/dist/base/agent-team.d.ts +2 -0
  25. package/dist/base/agent-team.js +7 -0
  26. package/dist/base/api-keys.d.ts +2 -0
  27. package/dist/base/api-keys.js +10 -0
  28. package/dist/base/autonomy-dial.d.ts +2 -0
  29. package/dist/base/autonomy-dial.js +7 -0
  30. package/dist/base/change-ledger.d.ts +2 -0
  31. package/dist/base/change-ledger.js +7 -0
  32. package/dist/base/citations.d.ts +2 -0
  33. package/dist/base/citations.js +9 -0
  34. package/dist/base/context-meter.d.ts +2 -0
  35. package/dist/base/context-meter.js +14 -0
  36. package/dist/base/fallback-chain.d.ts +2 -0
  37. package/dist/base/fallback-chain.js +7 -0
  38. package/dist/base/model-picker.d.ts +2 -0
  39. package/dist/base/model-picker.js +9 -0
  40. package/dist/base/prompt-composer.d.ts +2 -0
  41. package/dist/base/prompt-composer.js +9 -0
  42. package/dist/base/scrub-input.d.ts +2 -0
  43. package/dist/base/scrub-input.js +13 -0
  44. package/dist/base/thinking.d.ts +2 -0
  45. package/dist/base/thinking.js +11 -0
  46. package/dist/base/tool-approval.d.ts +2 -0
  47. package/dist/base/tool-approval.js +9 -0
  48. package/dist/base/trace-waterfall.d.ts +2 -0
  49. package/dist/base/trace-waterfall.js +9 -0
  50. package/dist/base.js +202 -134
  51. package/dist/change-ledger.d.ts +2 -0
  52. package/dist/change-ledger.js +7 -0
  53. package/dist/chunk-24O5V2PQ.js +253 -0
  54. package/dist/chunk-44DNL43W.js +490 -0
  55. package/dist/chunk-45IXJ7W7.js +245 -0
  56. package/dist/chunk-ANL6VX4X.js +326 -0
  57. package/dist/chunk-DNROUJ62.js +432 -0
  58. package/dist/chunk-F4CWSZXK.js +226 -0
  59. package/dist/chunk-GBOJUMMY.js +163 -0
  60. package/dist/chunk-H4NFBYKY.js +275 -0
  61. package/dist/chunk-KFPGQ5RT.js +321 -0
  62. package/dist/chunk-OIIMYSVT.js +342 -0
  63. package/dist/chunk-TL32C2SQ.js +221 -0
  64. package/dist/chunk-UBTYMAKF.js +240 -0
  65. package/dist/chunk-W6YVDJHX.js +235 -0
  66. package/dist/chunk-XYQI4ZYV.js +314 -0
  67. package/dist/citations.d.ts +2 -0
  68. package/dist/citations.js +9 -0
  69. package/dist/context-meter.d.ts +2 -0
  70. package/dist/context-meter.js +14 -0
  71. package/dist/fallback-chain.d.ts +2 -0
  72. package/dist/fallback-chain.js +7 -0
  73. package/dist/index.js +202 -134
  74. package/dist/model-picker.d.ts +2 -0
  75. package/dist/model-picker.js +9 -0
  76. package/dist/prompt-composer.d.ts +2 -0
  77. package/dist/prompt-composer.js +9 -0
  78. package/dist/scrub-input.d.ts +2 -0
  79. package/dist/scrub-input.js +13 -0
  80. package/dist/thinking.d.ts +2 -0
  81. package/dist/thinking.js +11 -0
  82. package/dist/tool-approval.d.ts +2 -0
  83. package/dist/tool-approval.js +9 -0
  84. package/dist/trace-waterfall.d.ts +2 -0
  85. package/dist/trace-waterfall.js +9 -0
  86. package/dist/types/components/kit/agent-plan.d.ts +34 -0
  87. package/dist/types/components/kit/api-keys.d.ts +62 -0
  88. package/dist/types/components/kit/citations.d.ts +34 -0
  89. package/dist/types/components/kit/context-meter.d.ts +38 -0
  90. package/dist/types/components/kit/model-picker.d.ts +46 -0
  91. package/dist/types/components/kit/prompt-composer.d.ts +61 -0
  92. package/dist/types/components/kit/scrub-input.d.ts +44 -0
  93. package/dist/types/components/kit/thinking.d.ts +28 -0
  94. package/dist/types/components/kit/tool-approval.d.ts +43 -0
  95. package/dist/types/components/kit/trace-waterfall.d.ts +44 -0
  96. package/dist/types/components/lab/blocks/AgentTeam.d.ts +2 -0
  97. package/dist/types/components/lab/blocks/AutonomyDial.d.ts +2 -0
  98. package/dist/types/components/lab/blocks/ChangeLedger.d.ts +2 -0
  99. package/dist/types/components/lab/blocks/FallbackChain.d.ts +2 -0
  100. package/dist/types/packages/asta-ui/src/agent-plan.d.ts +2 -0
  101. package/dist/types/packages/asta-ui/src/agent-team.d.ts +2 -0
  102. package/dist/types/packages/asta-ui/src/api-keys.d.ts +2 -0
  103. package/dist/types/packages/asta-ui/src/autonomy-dial.d.ts +2 -0
  104. package/dist/types/packages/asta-ui/src/base/agent-plan.d.ts +2 -0
  105. package/dist/types/packages/asta-ui/src/base/agent-team.d.ts +2 -0
  106. package/dist/types/packages/asta-ui/src/base/api-keys.d.ts +2 -0
  107. package/dist/types/packages/asta-ui/src/base/autonomy-dial.d.ts +2 -0
  108. package/dist/types/packages/asta-ui/src/base/change-ledger.d.ts +2 -0
  109. package/dist/types/packages/asta-ui/src/base/citations.d.ts +2 -0
  110. package/dist/types/packages/asta-ui/src/base/context-meter.d.ts +2 -0
  111. package/dist/types/packages/asta-ui/src/base/fallback-chain.d.ts +2 -0
  112. package/dist/types/packages/asta-ui/src/base/model-picker.d.ts +2 -0
  113. package/dist/types/packages/asta-ui/src/base/prompt-composer.d.ts +2 -0
  114. package/dist/types/packages/asta-ui/src/base/scrub-input.d.ts +2 -0
  115. package/dist/types/packages/asta-ui/src/base/thinking.d.ts +2 -0
  116. package/dist/types/packages/asta-ui/src/base/tool-approval.d.ts +2 -0
  117. package/dist/types/packages/asta-ui/src/base/trace-waterfall.d.ts +2 -0
  118. package/dist/types/packages/asta-ui/src/base.d.ts +25 -1
  119. package/dist/types/packages/asta-ui/src/change-ledger.d.ts +2 -0
  120. package/dist/types/packages/asta-ui/src/citations.d.ts +2 -0
  121. package/dist/types/packages/asta-ui/src/context-meter.d.ts +2 -0
  122. package/dist/types/packages/asta-ui/src/fallback-chain.d.ts +2 -0
  123. package/dist/types/packages/asta-ui/src/index.d.ts +25 -1
  124. package/dist/types/packages/asta-ui/src/model-picker.d.ts +2 -0
  125. package/dist/types/packages/asta-ui/src/prompt-composer.d.ts +2 -0
  126. package/dist/types/packages/asta-ui/src/scrub-input.d.ts +2 -0
  127. package/dist/types/packages/asta-ui/src/thinking.d.ts +2 -0
  128. package/dist/types/packages/asta-ui/src/tool-approval.d.ts +2 -0
  129. package/dist/types/packages/asta-ui/src/trace-waterfall.d.ts +2 -0
  130. package/package.json +1 -1
@@ -0,0 +1,275 @@
1
+ "use client";
2
+
3
+ // components/lab/blocks/FallbackChain.tsx
4
+ import { useEffect, useRef, useState } from "react";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ var EASE = "cubic-bezier(.16,1,.3,1)";
7
+ var RING = "shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_10%,transparent)]";
8
+ var FAINT = "bg-[color-mix(in_srgb,var(--ink)_8%,transparent)]";
9
+ var MODELS = [
10
+ { name: "Astra 2 Pro", note: "Primary \xB7 200k context", error: "Timed out", detail: "10 s", tryMs: 1900, okMs: 1240 },
11
+ { name: "Astra 2", note: "Fallback \xB7 128k context", error: "Rate limited", detail: "429", tryMs: 800, okMs: 960 },
12
+ { name: "Astra Fast", note: "Last resort \xB7 32k context", error: "Overloaded", detail: "503", tryMs: 900, okMs: 842 }
13
+ ];
14
+ var DEFAULT = [true, true, false];
15
+ var PROMPT = "Summarise this week\u2019s support tickets";
16
+ var REPLY = "14 tickets this week, down from 22. Most are about invoice exports, and 3 still need a reply.".split(" ");
17
+ var LABEL = { idle: "Waiting", trying: "Trying", failed: "Failed", ok: "Answered", skipped: "Not needed" };
18
+ var ms = (n) => n >= 1e3 ? `${(n / 1e3).toFixed(1)} s` : `${Math.round(n)} ms`;
19
+ function FallbackChain() {
20
+ const [status, setStatus] = useState(MODELS.map(() => "idle"));
21
+ const [elapsed, setElapsed] = useState(0);
22
+ const [words, setWords] = useState(0);
23
+ const [fade, setFade] = useState(false);
24
+ const [run, setRun] = useState(0);
25
+ const [armed, setArmed] = useState(null);
26
+ const [visible, setVisible] = useState(true);
27
+ const root = useRef(null);
28
+ const rows = useRef([]);
29
+ const plan = useRef(DEFAULT);
30
+ useEffect(() => {
31
+ plan.current = armed ?? DEFAULT;
32
+ }, [armed]);
33
+ useEffect(() => {
34
+ const el = root.current;
35
+ if (!el) return;
36
+ let seen = true;
37
+ const sync = () => setVisible(seen && !document.hidden);
38
+ const io = new IntersectionObserver(([e]) => {
39
+ seen = e.isIntersecting;
40
+ sync();
41
+ });
42
+ io.observe(el);
43
+ document.addEventListener("visibilitychange", sync);
44
+ return () => {
45
+ io.disconnect();
46
+ document.removeEventListener("visibilitychange", sync);
47
+ };
48
+ }, []);
49
+ useEffect(() => {
50
+ if (!visible) return;
51
+ const t = [];
52
+ let tick;
53
+ let alive = true;
54
+ const later = (at2, f) => t.push(setTimeout(() => alive && f(), at2));
55
+ const fails = plan.current;
56
+ const set = (i, s) => setStatus((v) => v.map((x, k) => k === i ? s : x));
57
+ const clock = (scale) => {
58
+ clearInterval(tick);
59
+ const start = performance.now();
60
+ setElapsed(0);
61
+ tick = setInterval(() => setElapsed((performance.now() - start) * scale), 90);
62
+ };
63
+ later(0, () => {
64
+ setStatus(MODELS.map(() => "idle"));
65
+ setWords(0);
66
+ setElapsed(0);
67
+ setFade(false);
68
+ });
69
+ let at = 650;
70
+ let answered = -1;
71
+ for (let i = 0; i < MODELS.length && answered < 0; i++) {
72
+ const m = MODELS[i];
73
+ const dur = fails[i] ? m.tryMs : 1100;
74
+ const scale = fails[i] ? i === 0 ? 1e4 / dur : 1 : m.okMs / dur;
75
+ later(at, () => {
76
+ set(i, "trying");
77
+ clock(scale);
78
+ });
79
+ at += dur;
80
+ if (fails[i]) {
81
+ later(at, () => {
82
+ clearInterval(tick);
83
+ set(i, "failed");
84
+ });
85
+ at += 520;
86
+ } else {
87
+ answered = i;
88
+ later(at, () => {
89
+ clearInterval(tick);
90
+ setElapsed(m.okMs);
91
+ setStatus((v) => v.map((x, k) => k === i ? "ok" : k > i ? "skipped" : x));
92
+ });
93
+ at += 280;
94
+ REPLY.forEach((_, w) => later(at + w * 55, () => setWords(w + 1)));
95
+ at += REPLY.length * 55;
96
+ }
97
+ }
98
+ at += answered < 0 ? 4200 : 3e3;
99
+ later(at, () => setFade(true));
100
+ later(at + 480, () => setRun((r) => r + 1));
101
+ return () => {
102
+ alive = false;
103
+ t.forEach(clearTimeout);
104
+ clearInterval(tick);
105
+ };
106
+ }, [visible, run]);
107
+ const toggle = (i) => setArmed((a) => (a ?? DEFAULT).map((f, k) => k === i ? !f : f));
108
+ const retry = () => setRun((r) => r + 1);
109
+ const onKey = (e) => {
110
+ if (e.key === "r" || e.key === "R") {
111
+ e.preventDefault();
112
+ retry();
113
+ return;
114
+ }
115
+ const i = rows.current.findIndex((b) => b === document.activeElement);
116
+ const d = e.key === "ArrowDown" ? 1 : e.key === "ArrowUp" ? -1 : 0;
117
+ if (!d || i < 0) return;
118
+ e.preventDefault();
119
+ rows.current[(i + d + MODELS.length) % MODELS.length]?.focus();
120
+ };
121
+ const okAt = status.indexOf("ok");
122
+ const trying = status.indexOf("trying");
123
+ const allFailed = status.every((s) => s === "failed");
124
+ const falls = status.filter((s) => s === "failed").length;
125
+ const attempt = trying >= 0 ? trying + 1 : okAt >= 0 ? okAt + 1 : Math.max(1, falls);
126
+ const winner = okAt >= 0 ? MODELS[okAt] : null;
127
+ const next = armed ?? DEFAULT;
128
+ return /* @__PURE__ */ jsxs(
129
+ "div",
130
+ {
131
+ ref: root,
132
+ role: "group",
133
+ "aria-label": "Model fallback chain. Press a model to make it fail or recover on the next run. Press R to retry",
134
+ onKeyDown: onKey,
135
+ className: "flex h-full w-full items-center justify-center px-5 pb-5 pt-11",
136
+ style: { containerType: "size" },
137
+ children: [
138
+ /* @__PURE__ */ jsx("style", { href: "asta-fallbackchain", precedence: "asta", children: `
139
+ @keyframes lab-fc-spin { to { transform: rotate(360deg) } }
140
+ @keyframes lab-fc-pop { from { transform: scale(.92); opacity: 0 } to { transform: none; opacity: 1 } }
141
+ @keyframes lab-fc-word { from { transform: translateY(3px); opacity: 0 } to { transform: none; opacity: 1 } }
142
+ @keyframes lab-fc-pulse { from { transform: scale(1); opacity: .45 } to { transform: scale(2.4); opacity: 0 } }
143
+ .lab-fc-spin { animation: lab-fc-spin .85s ${EASE} infinite }
144
+ .lab-fc-pop { animation: lab-fc-pop .45s ${EASE} both }
145
+ .lab-fc-word { animation: lab-fc-word .4s ${EASE} both }
146
+ .lab-fc-pulse { animation: lab-fc-pulse 1.3s ${EASE} infinite }
147
+ .lab-fc-note { display: none }
148
+ @container (min-height: 330px) and (min-width: 280px) { .lab-fc-note { display: block } }
149
+ @container (max-height: 250px) { .lab-fc-head { display: none } }
150
+ @container (min-height: 400px) { .lab-fc-reply { -webkit-line-clamp: 3 } }
151
+ @media (prefers-reduced-motion: reduce) { .lab-fc-spin, .lab-fc-pop, .lab-fc-word, .lab-fc-pulse { animation: none } }
152
+ ` }),
153
+ /* @__PURE__ */ jsxs(
154
+ "div",
155
+ {
156
+ className: `flex w-full max-w-[460px] flex-col gap-[max(6px,2.2cqh)] rounded-[14px] bg-paper p-[clamp(10px,3.4cqmin,16px)] ${RING} shadow-[0_18px_40px_-28px_rgb(0_0_0/0.35)]`,
157
+ style: { opacity: fade ? 0 : 1, transition: `opacity .45s ${EASE}` },
158
+ children: [
159
+ /* @__PURE__ */ jsxs("div", { className: "lab-fc-head flex items-end justify-between gap-3 px-1", children: [
160
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
161
+ /* @__PURE__ */ jsx("p", { className: "font-mono text-[10.5px] uppercase tracking-wider text-brand", children: "Request" }),
162
+ /* @__PURE__ */ jsx("p", { className: "truncate text-[13px] font-medium tracking-[-0.01em] text-ink", children: PROMPT })
163
+ ] }),
164
+ /* @__PURE__ */ jsxs("span", { className: "shrink-0 rounded-md bg-paper-2 px-2 py-1 text-[11px] tabular-nums text-ink-2", children: [
165
+ "Attempt ",
166
+ attempt,
167
+ " of ",
168
+ MODELS.length
169
+ ] })
170
+ ] }),
171
+ /* @__PURE__ */ jsxs("ol", { className: "relative flex flex-col", "aria-label": "Models in fallback order", children: [
172
+ /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "absolute bottom-[17%] left-[19px] top-[17%] w-px bg-[color-mix(in_srgb,var(--ink)_14%,transparent)]" }),
173
+ MODELS.map((m, i) => {
174
+ const s = status[i];
175
+ const dim = s === "failed" || s === "skipped";
176
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
177
+ "button",
178
+ {
179
+ ref: (el) => {
180
+ rows.current[i] = el;
181
+ },
182
+ type: "button",
183
+ onClick: () => toggle(i),
184
+ "aria-pressed": next[i],
185
+ "aria-label": `${m.name}: ${s === "failed" ? `${m.error} ${m.detail}` : s === "ok" ? `Answered in ${ms(m.okMs)}` : LABEL[s]}. ${next[i] ? "Fails" : "Healthy"} on the next run, press to switch`,
186
+ className: `relative flex h-[clamp(34px,12cqh,48px)] w-full items-center gap-3 rounded-[10px] px-[11px] text-left outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-brand/60 ${s === "trying" ? "bg-paper-2" : ""}`,
187
+ style: { transition: `background-color .35s ${EASE}` },
188
+ children: [
189
+ /* @__PURE__ */ jsxs("span", { className: "relative grid h-[17px] w-[17px] shrink-0 place-items-center", children: [
190
+ s === "trying" && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "lab-fc-pulse absolute inset-0 rounded-full bg-brand" }),
191
+ /* @__PURE__ */ jsxs(
192
+ "span",
193
+ {
194
+ "aria-hidden": true,
195
+ className: `relative grid h-full w-full place-items-center rounded-full ${s === "ok" || s === "trying" ? "bg-brand text-paper" : s === "failed" ? "bg-ink text-paper" : `bg-paper ${RING}`}`,
196
+ style: { transition: `background-color .3s ${EASE}` },
197
+ children: [
198
+ s === "ok" && /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", className: "lab-fc-pop h-2.5 w-2.5", fill: "none", stroke: "currentColor", strokeWidth: "2.6", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M3.5 8.5l3 3 6-7" }) }),
199
+ s === "failed" && /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", className: "lab-fc-pop h-2 w-2", fill: "none", stroke: "currentColor", strokeWidth: "2.8", strokeLinecap: "round", children: /* @__PURE__ */ jsx("path", { d: "M4 4l8 8M12 4l-8 8" }) })
200
+ ]
201
+ }
202
+ )
203
+ ] }),
204
+ /* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1 leading-tight", style: { opacity: dim ? 0.45 : 1, transition: `opacity .45s ${EASE}` }, children: [
205
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5", children: [
206
+ /* @__PURE__ */ jsx("span", { className: "truncate text-[13px] font-medium text-ink", children: m.name }),
207
+ armed && next[i] && /* @__PURE__ */ jsx("span", { className: "lab-fc-pop shrink-0 rounded bg-paper-2 px-1 py-px font-mono text-[9.5px] uppercase tracking-wide text-ink-2", children: "Fails next" })
208
+ ] }),
209
+ /* @__PURE__ */ jsx("span", { className: "lab-fc-note truncate text-[11px] text-mute", children: m.note })
210
+ ] }),
211
+ /* @__PURE__ */ jsxs("span", { className: "flex shrink-0 items-center gap-1.5 text-[11.5px] tabular-nums", children: [
212
+ s === "trying" && /* @__PURE__ */ jsxs(Fragment, { children: [
213
+ /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "lab-fc-spin h-3 w-3 rounded-full border-[1.5px] border-brand border-r-transparent" }),
214
+ /* @__PURE__ */ jsx("span", { className: "w-[40px] text-right text-ink-2", children: ms(elapsed) })
215
+ ] }),
216
+ s === "failed" && /* @__PURE__ */ jsxs("span", { className: "lab-fc-pop", children: [
217
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-ink", children: m.error }),
218
+ " ",
219
+ /* @__PURE__ */ jsx("span", { className: "text-mute", children: m.detail })
220
+ ] }),
221
+ s === "ok" && /* @__PURE__ */ jsx("span", { className: "lab-fc-pop font-medium text-brand", children: "Answered" }),
222
+ (s === "idle" || s === "skipped") && /* @__PURE__ */ jsx("span", { className: "text-mute", children: LABEL[s] })
223
+ ] })
224
+ ]
225
+ }
226
+ ) }, m.name);
227
+ })
228
+ ] }),
229
+ /* @__PURE__ */ jsx("div", { className: "relative h-[clamp(74px,21cqh,90px)] overflow-hidden rounded-[11px] bg-paper-2 px-3 py-2.5", "aria-live": "polite", children: winner ? /* @__PURE__ */ jsxs("div", { className: "lab-fc-pop flex h-full flex-col gap-1", children: [
230
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 text-[11px]", children: [
231
+ /* @__PURE__ */ jsxs("span", { className: "truncate text-mute", children: [
232
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-ink", children: winner.name }),
233
+ falls ? ` \xB7 fell back ${falls === 1 ? "once" : "twice"}` : " \xB7 first try"
234
+ ] }),
235
+ /* @__PURE__ */ jsxs("span", { className: "flex shrink-0 items-center gap-1 rounded-md bg-ink px-1.5 py-0.5 font-mono text-[10.5px] text-paper", children: [
236
+ /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", className: "h-2.5 w-2.5", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M9.2 1.5 3.5 9h4l-1 5.5L12.5 7h-4z" }) }),
237
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Latency" }),
238
+ ms(winner.okMs)
239
+ ] })
240
+ ] }),
241
+ /* @__PURE__ */ jsx("p", { className: "lab-fc-reply line-clamp-2 text-[12.5px] leading-snug text-ink", children: REPLY.slice(0, words).map((w, k) => /* @__PURE__ */ jsxs("span", { className: "lab-fc-word inline-block whitespace-pre", children: [
242
+ w,
243
+ " "
244
+ ] }, k)) })
245
+ ] }, `w${run}`) : allFailed ? /* @__PURE__ */ jsxs("div", { className: "lab-fc-pop flex h-full items-center justify-between gap-3", children: [
246
+ /* @__PURE__ */ jsxs("p", { className: "min-w-0 text-[12px] leading-snug text-ink", children: [
247
+ /* @__PURE__ */ jsx("span", { className: "font-medium", children: "All 3 models failed." }),
248
+ " ",
249
+ /* @__PURE__ */ jsx("span", { className: "text-mute", children: "Let one recover, then retry." })
250
+ ] }),
251
+ /* @__PURE__ */ jsx(
252
+ "button",
253
+ {
254
+ type: "button",
255
+ onClick: retry,
256
+ className: "shrink-0 rounded-[8px] bg-ink px-2.5 py-1.5 text-[11.5px] font-medium text-paper outline-none focus-visible:ring-2 focus-visible:ring-brand/60",
257
+ children: "Retry request"
258
+ }
259
+ )
260
+ ] }) : /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col justify-center gap-2", children: [
261
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Waiting for a reply" }),
262
+ /* @__PURE__ */ jsx("span", { className: `h-2 w-[72%] rounded-full ${FAINT}` }),
263
+ /* @__PURE__ */ jsx("span", { className: `h-2 w-[46%] rounded-full ${FAINT}` })
264
+ ] }) })
265
+ ]
266
+ }
267
+ )
268
+ ]
269
+ }
270
+ );
271
+ }
272
+
273
+ export {
274
+ FallbackChain
275
+ };
@@ -0,0 +1,321 @@
1
+ "use client";
2
+
3
+ // components/kit/tool-approval.tsx
4
+ import { useEffect, useId, useRef, useState } from "react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ var cx = (...c) => c.filter(Boolean).join(" ");
7
+ var CURVE = "cubic-bezier(.16,1,.3,1)";
8
+ var KEYFRAMES = `@keyframes asta-ta-in { from { opacity: 0; transform: translateY(6px) scale(.98) } }
9
+ @keyframes asta-ta-row { from { opacity: 0; transform: translateY(-4px) } }
10
+ @keyframes asta-ta-menu { from { opacity: 0; transform: translateY(-4px) scale(.96) } }
11
+ @keyframes asta-ta-spin { to { transform: rotate(360deg) } }
12
+ @media (prefers-reduced-motion: reduce) { .asta-ta-a, .asta-ta-a * { animation: none !important; transition-duration: 0s !important } }`;
13
+ var svg = { viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true };
14
+ var KIND = {
15
+ sql: /* @__PURE__ */ jsx("path", { d: "M3 4c0-1.1 2.2-2 5-2s5 .9 5 2-2.2 2-5 2-5-.9-5-2Zm0 0v8c0 1.1 2.2 2 5 2s5-.9 5-2V4M3 8c0 1.1 2.2 2 5 2s5-.9 5-2" }),
16
+ shell: /* @__PURE__ */ jsx("path", { d: "M2.5 3.5h11v9h-11zM5 7l1.8 1.5L5 10M8.5 10.5h2.5" }),
17
+ file: /* @__PURE__ */ jsx("path", { d: "M9 2H4.5v12h7V4.5zM9 2v2.5h2.5M6.5 8.5h3M6.5 11h3" }),
18
+ web: /* @__PURE__ */ jsx("path", { d: "M8 14A6 6 0 1 0 8 2a6 6 0 0 0 0 12ZM2 8h12M8 2c1.6 1.7 2.4 3.7 2.4 6S9.6 12.3 8 14c-1.6-1.7-2.4-3.7-2.4-6S6.4 3.7 8 2Z" }),
19
+ mail: /* @__PURE__ */ jsx("path", { d: "M2 4h12v8.5H2zM2.5 4.5 8 9l5.5-4.5" })
20
+ };
21
+ var RISK = {
22
+ read: { word: "Read only", icon: /* @__PURE__ */ jsx("path", { d: "M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8ZM8 10a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z" }) },
23
+ write: { word: "Changes data", icon: /* @__PURE__ */ jsx("path", { d: "M10.5 2.5 13.5 5.5 6 13H3v-3zM9 4l3 3" }) },
24
+ destructive: { word: "Can't be undone", icon: /* @__PURE__ */ jsx("path", { d: "M8 2.5 14 13H2zM8 6.5v3M8 11.2h.01" }) }
25
+ };
26
+ var fmt = (ms) => ms < 1e3 ? `${Math.max(1, Math.round(ms / 100)) / 10}s` : `${(ms / 1e3).toFixed(1)}s`;
27
+ function Kbd({ children }) {
28
+ return /* @__PURE__ */ jsx("kbd", { "aria-hidden": true, className: "ml-1 hidden rounded bg-[color-mix(in_srgb,currentColor_14%,transparent)] px-1 font-sans text-[10.5px] leading-[1.5] sm:inline", children });
29
+ }
30
+ function Preview({ call }) {
31
+ const [all, setAll] = useState(false);
32
+ const lines = call.code?.split("\n") ?? [];
33
+ const long = lines.length > 6;
34
+ const args = Object.entries(call.args ?? {});
35
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
36
+ call.code && /* @__PURE__ */ jsxs("div", { className: "overflow-hidden rounded-lg bg-paper-2", children: [
37
+ /* @__PURE__ */ jsx("pre", { className: "overflow-x-auto px-3 py-2.5 font-mono text-[12px] leading-[1.6] text-ink [scrollbar-width:thin]", children: (long && !all ? lines.slice(0, 6) : lines).join("\n") }),
38
+ long && /* @__PURE__ */ jsx(
39
+ "button",
40
+ {
41
+ type: "button",
42
+ onClick: () => setAll(!all),
43
+ "aria-expanded": all,
44
+ className: "w-full px-3 pb-2 text-left text-[12px] font-medium text-brand outline-none hover:underline focus-visible:underline",
45
+ children: all ? "Show less" : `Show all ${lines.length} lines`
46
+ }
47
+ )
48
+ ] }),
49
+ call.diff && /* @__PURE__ */ jsxs("div", { className: "overflow-hidden rounded-lg bg-paper-2 text-[12px]", children: [
50
+ /* @__PURE__ */ jsxs("p", { className: "flex items-center justify-between gap-3 px-3 pb-1 pt-2 font-mono text-ink-2", children: [
51
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: call.diff.file }),
52
+ /* @__PURE__ */ jsxs("span", { className: "shrink-0 tabular-nums text-mute", children: [
53
+ "+",
54
+ call.diff.lines.filter((l) => l[0] === "+").length,
55
+ " \u2212",
56
+ call.diff.lines.filter((l) => l[0] === "-").length
57
+ ] })
58
+ ] }),
59
+ /* @__PURE__ */ jsx("div", { className: "overflow-x-auto pb-1.5 font-mono leading-[1.6] [scrollbar-width:thin]", children: call.diff.lines.map((l, i) => {
60
+ const sign = l[0] === "+" ? "+" : l[0] === "-" ? "\u2212" : " ";
61
+ return /* @__PURE__ */ jsxs("div", { className: cx("flex min-w-max pr-3", sign === "+" && "bg-[color-mix(in_srgb,var(--brand)_9%,transparent)]"), children: [
62
+ /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: cx("w-6 shrink-0 select-none text-center", sign === "+" ? "text-brand" : "text-mute"), children: sign }),
63
+ /* @__PURE__ */ jsxs("span", { className: cx("whitespace-pre", sign === "\u2212" ? "text-mute line-through decoration-[color-mix(in_srgb,var(--ink)_25%,transparent)]" : "text-ink"), children: [
64
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: sign === "+" ? "Added: " : sign === "\u2212" ? "Removed: " : "" }),
65
+ l.slice(1)
66
+ ] })
67
+ ] }, i);
68
+ }) })
69
+ ] }),
70
+ args.length > 0 && /* @__PURE__ */ jsx("dl", { className: "grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 rounded-lg bg-paper-2 px-3 py-2.5 text-[12.5px]", children: args.map(([k, v]) => /* @__PURE__ */ jsxs("div", { className: "contents", children: [
71
+ /* @__PURE__ */ jsx("dt", { className: "text-mute", children: k }),
72
+ /* @__PURE__ */ jsx("dd", { className: "min-w-0 break-words font-mono text-[12px] text-ink", children: String(v) })
73
+ ] }, k)) })
74
+ ] });
75
+ }
76
+ function Card({ call, index, count, onDecide }) {
77
+ const [menu, setMenu] = useState(false);
78
+ const menuId = useId();
79
+ const root = useRef(null);
80
+ const caret = useRef(null);
81
+ const risk = call.risk ? RISK[call.risk] : null;
82
+ useEffect(() => {
83
+ if (!menu) return;
84
+ root.current?.querySelector('[role="menuitem"]')?.focus();
85
+ const away = (e) => {
86
+ if (!e.target.closest?.("[data-ta-menu]")) setMenu(false);
87
+ };
88
+ document.addEventListener("pointerdown", away);
89
+ return () => document.removeEventListener("pointerdown", away);
90
+ }, [menu]);
91
+ const decide = (d) => onDecide(d, !!root.current?.contains(document.activeElement));
92
+ const onKey = (e) => {
93
+ if (e.defaultPrevented || e.nativeEvent.isComposing) return;
94
+ const t = e.target;
95
+ if (e.key === "Escape") {
96
+ e.preventDefault();
97
+ decide("deny");
98
+ } else if (e.key === "Enter" && !t.closest("button,a,input,textarea,select,summary")) {
99
+ e.preventDefault();
100
+ decide("once");
101
+ }
102
+ };
103
+ const onMenuKey = (e) => {
104
+ const items = [...e.currentTarget.querySelectorAll('[role="menuitem"]')];
105
+ const i = items.indexOf(document.activeElement);
106
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
107
+ e.preventDefault();
108
+ items[(i + (e.key === "ArrowDown" ? 1 : -1) + items.length) % items.length]?.focus();
109
+ } else if (e.key === "Escape" || e.key === "Tab") {
110
+ if (e.key === "Escape") e.preventDefault();
111
+ e.stopPropagation();
112
+ setMenu(false);
113
+ caret.current?.focus();
114
+ }
115
+ };
116
+ return /* @__PURE__ */ jsxs(
117
+ "div",
118
+ {
119
+ ref: root,
120
+ role: "group",
121
+ tabIndex: 0,
122
+ "aria-label": `Approve ${call.tool}${count > 1 ? `, ${index + 1} of ${count}` : ""}`,
123
+ "aria-describedby": `${menuId}-sum`,
124
+ onKeyDown: onKey,
125
+ className: "asta-ta-a relative flex flex-col gap-3 rounded-[14px] bg-paper p-4 outline-none shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_10%,transparent),0_10px_28px_-16px_rgb(0_0_0/0.25),0_1px_2px_rgb(0_0_0/0.04)] focus-visible:shadow-[inset_0_0_0_1px_var(--brand),0_0_0_3px_color-mix(in_srgb,var(--brand)_16%,transparent)] animate-[asta-ta-in_.35s_cubic-bezier(.16,1,.3,1)_both]",
126
+ children: [
127
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
128
+ /* @__PURE__ */ jsx("span", { className: "grid h-8 w-8 shrink-0 place-items-center rounded-lg bg-paper-2 text-ink", children: /* @__PURE__ */ jsx("svg", { ...svg, className: "h-4 w-4", children: KIND[call.kind ?? "shell"] }) }),
129
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
130
+ /* @__PURE__ */ jsxs("p", { className: "truncate text-[12px] text-mute", children: [
131
+ "Wants to use a tool",
132
+ call.source ? ` \xB7 ${call.source}` : ""
133
+ ] }),
134
+ /* @__PURE__ */ jsx("p", { className: "truncate font-mono text-[13.5px] font-medium text-ink", children: call.tool })
135
+ ] }),
136
+ count > 1 && /* @__PURE__ */ jsxs("span", { className: "shrink-0 rounded-md bg-paper-2 px-1.5 py-0.5 text-[11.5px] tabular-nums text-mute", children: [
137
+ index + 1,
138
+ " of ",
139
+ count
140
+ ] })
141
+ ] }),
142
+ call.summary && /* @__PURE__ */ jsx("p", { id: `${menuId}-sum`, className: "text-[13.5px] leading-snug text-ink-2", children: call.summary }),
143
+ /* @__PURE__ */ jsx(Preview, { call }),
144
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-between gap-x-3 gap-y-2.5 pt-0.5", children: [
145
+ risk ? /* @__PURE__ */ jsxs("p", { className: cx("flex items-center gap-1.5 text-[12.5px]", call.risk === "destructive" ? "font-medium text-ink" : "text-mute"), children: [
146
+ /* @__PURE__ */ jsx("svg", { ...svg, className: "h-3.5 w-3.5 shrink-0", children: risk.icon }),
147
+ call.note ?? risk.word
148
+ ] }) : /* @__PURE__ */ jsx("span", {}),
149
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
150
+ /* @__PURE__ */ jsxs(
151
+ "button",
152
+ {
153
+ type: "button",
154
+ onClick: () => decide("deny"),
155
+ "aria-keyshortcuts": "Escape",
156
+ className: "inline-flex h-8 items-center rounded-md px-3 text-[13px] font-medium text-ink-2 outline-none shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_14%,transparent)] transition-[background-color,color,transform] duration-150 hover:bg-paper-2 hover:text-ink active:scale-[0.97] focus-visible:ring-2 focus-visible:ring-brand/50",
157
+ children: [
158
+ "Deny",
159
+ /* @__PURE__ */ jsx(Kbd, { children: "Esc" })
160
+ ]
161
+ }
162
+ ),
163
+ /* @__PURE__ */ jsxs("div", { className: "relative flex", "data-ta-menu": true, children: [
164
+ /* @__PURE__ */ jsxs(
165
+ "button",
166
+ {
167
+ type: "button",
168
+ onClick: () => decide("once"),
169
+ "aria-keyshortcuts": "Enter",
170
+ className: "inline-flex h-8 items-center rounded-l-md bg-ink pl-3 pr-2.5 text-[13px] font-medium text-paper outline-none transition-[background-color,transform] duration-150 hover:bg-[color-mix(in_srgb,var(--ink)_86%,var(--paper))] active:scale-[0.97] focus-visible:ring-2 focus-visible:ring-brand/50 focus-visible:ring-offset-2 focus-visible:ring-offset-paper",
171
+ children: [
172
+ "Allow once",
173
+ /* @__PURE__ */ jsx(Kbd, { children: "\u21B5" })
174
+ ]
175
+ }
176
+ ),
177
+ /* @__PURE__ */ jsx(
178
+ "button",
179
+ {
180
+ ref: caret,
181
+ type: "button",
182
+ "aria-label": "More ways to allow",
183
+ "aria-haspopup": "menu",
184
+ "aria-expanded": menu,
185
+ "aria-controls": menu ? menuId : void 0,
186
+ onClick: () => setMenu(!menu),
187
+ className: "grid h-8 w-7 place-items-center rounded-r-md bg-ink text-paper shadow-[inset_1px_0_0_color-mix(in_srgb,var(--paper)_22%,transparent)] outline-none transition-[background-color,transform] duration-150 hover:bg-[color-mix(in_srgb,var(--ink)_86%,var(--paper))] active:scale-[0.97] focus-visible:ring-2 focus-visible:ring-brand/50 focus-visible:ring-offset-2 focus-visible:ring-offset-paper",
188
+ children: /* @__PURE__ */ jsx("svg", { ...svg, strokeWidth: 1.7, className: cx("h-3.5 w-3.5 transition-transform duration-300", menu && "rotate-180"), style: { transitionTimingFunction: CURVE }, children: /* @__PURE__ */ jsx("path", { d: "m4 6 4 4 4-4" }) })
189
+ }
190
+ ),
191
+ menu && /* @__PURE__ */ jsx(
192
+ "div",
193
+ {
194
+ id: menuId,
195
+ role: "menu",
196
+ "aria-label": `Allow ${call.tool}`,
197
+ onKeyDown: onMenuKey,
198
+ className: "asta-ta-a absolute right-0 top-full z-20 mt-1.5 w-[248px] origin-top-right rounded-xl bg-paper p-1.5 text-left shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_10%,transparent),0_12px_32px_-12px_rgb(0_0_0/0.28),0_4px_10px_-6px_rgb(0_0_0/0.12)] animate-[asta-ta-menu_.18s_cubic-bezier(.16,1,.3,1)_both]",
199
+ children: [
200
+ ["once", "Allow once", "Ask again next time"],
201
+ ["always", `Always allow ${call.tool}`, "Won't ask again in this chat"]
202
+ ].map(([d, label, hint]) => /* @__PURE__ */ jsxs(
203
+ "button",
204
+ {
205
+ type: "button",
206
+ role: "menuitem",
207
+ tabIndex: -1,
208
+ onClick: () => {
209
+ setMenu(false);
210
+ decide(d);
211
+ },
212
+ className: "flex w-full flex-col items-start rounded-[9px] px-2.5 py-2 text-left outline-none transition-colors duration-150 hover:bg-paper-2 focus:bg-paper-2",
213
+ children: [
214
+ /* @__PURE__ */ jsx("span", { className: "max-w-full truncate text-[13px] font-medium text-ink", children: label }),
215
+ /* @__PURE__ */ jsx("span", { className: "text-[12px] text-mute", children: hint })
216
+ ]
217
+ },
218
+ d
219
+ ))
220
+ }
221
+ )
222
+ ] })
223
+ ] })
224
+ ] })
225
+ ]
226
+ }
227
+ );
228
+ }
229
+ var WORD = { once: "Allowed", always: "Always allowed", auto: "Auto-allowed", deny: "Denied" };
230
+ function Receipt({ call, r }) {
231
+ const denied = r.decision === "deny";
232
+ const word = r.state === "running" ? "Running" : r.state === "error" ? "Failed" : WORD[r.decision];
233
+ return /* @__PURE__ */ jsxs("li", { className: "asta-ta-a flex min-h-8 items-center gap-2 rounded-lg px-2.5 py-1.5 text-[12.5px] animate-[asta-ta-row_.35s_cubic-bezier(.16,1,.3,1)_both]", children: [
234
+ /* @__PURE__ */ jsx("span", { className: cx("grid h-4 w-4 shrink-0 place-items-center", denied || r.state === "error" ? "text-ink" : "text-brand"), children: r.state === "running" ? /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", className: "h-3.5 w-3.5 animate-[asta-ta-spin_.8s_linear_infinite]", fill: "none", "aria-hidden": true, children: [
235
+ /* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "6", stroke: "currentColor", strokeOpacity: ".2", strokeWidth: "2" }),
236
+ /* @__PURE__ */ jsx("path", { d: "M14 8a6 6 0 0 0-6-6", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" })
237
+ ] }) : /* @__PURE__ */ jsx("svg", { ...svg, strokeWidth: 1.8, className: "h-3.5 w-3.5", children: denied ? /* @__PURE__ */ jsx("path", { d: "M8 14A6 6 0 1 0 8 2a6 6 0 0 0 0 12ZM3.8 12.2l8.4-8.4" }) : r.state === "error" ? /* @__PURE__ */ jsx("path", { d: "M8 2.5 14 13H2zM8 6.5v3M8 11.2h.01" }) : /* @__PURE__ */ jsx("path", { d: "m3.5 8.5 3 3 6-7" }) }) }),
238
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-ink", children: word }),
239
+ /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "text-mute", children: "\xB7" }),
240
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate font-mono text-[12px] text-ink-2", children: call.tool }),
241
+ call.summary && /* @__PURE__ */ jsx("span", { className: "hidden min-w-0 flex-1 truncate text-mute sm:block", children: call.summary }),
242
+ r.ms !== void 0 && r.state !== "running" && !denied && /* @__PURE__ */ jsx("span", { className: "ml-auto shrink-0 tabular-nums text-mute", children: fmt(r.ms) })
243
+ ] });
244
+ }
245
+ function ToolApproval({ calls, onDecide, defaultAllowed = [], className }) {
246
+ const [results, setResults] = useState({});
247
+ const [allowed, setAllowed] = useState(defaultAllowed);
248
+ const [refocus, setRefocus] = useState(false);
249
+ const list = useRef(null);
250
+ const started = useRef(/* @__PURE__ */ new Set());
251
+ const alive = useRef(true);
252
+ useEffect(() => {
253
+ alive.current = true;
254
+ return () => {
255
+ alive.current = false;
256
+ };
257
+ }, []);
258
+ const pending = calls.filter((c) => !results[c.id] && !allowed.includes(c.tool));
259
+ const active = pending[0];
260
+ const run = (call, decision) => {
261
+ if (started.current.has(call.id)) return;
262
+ started.current.add(call.id);
263
+ const t0 = performance.now();
264
+ const done2 = (state) => alive.current && setResults((r) => ({ ...r, [call.id]: { decision, state, ms: performance.now() - t0 } }));
265
+ setResults((r) => ({ ...r, [call.id]: { decision, state: decision === "deny" ? "ok" : "running" } }));
266
+ let out = void 0;
267
+ try {
268
+ out = onDecide?.(call, decision === "auto" ? "always" : decision);
269
+ } catch {
270
+ return done2("error");
271
+ }
272
+ if (decision === "deny") return;
273
+ if (out && typeof out.then === "function") out.then(() => done2("ok"), () => done2("error"));
274
+ else done2("ok");
275
+ };
276
+ useEffect(() => {
277
+ const auto = calls.filter((c) => !started.current.has(c.id) && allowed.includes(c.tool));
278
+ if (!auto.length) return;
279
+ const t = setTimeout(() => auto.forEach((c) => run(c, "auto")), 0);
280
+ return () => clearTimeout(t);
281
+ }, [calls, allowed]);
282
+ useEffect(() => {
283
+ if (!refocus) return;
284
+ const t = setTimeout(() => {
285
+ list.current?.querySelector('[role="group"]')?.focus({ preventScroll: true });
286
+ if (!list.current?.contains(document.activeElement)) list.current?.focus({ preventScroll: true });
287
+ setRefocus(false);
288
+ }, 0);
289
+ return () => clearTimeout(t);
290
+ }, [refocus, active?.id]);
291
+ const decide = (call, d, keepFocus) => {
292
+ if (d === "always") setAllowed((a) => a.includes(call.tool) ? a : [...a, call.tool]);
293
+ run(call, d);
294
+ if (keepFocus) setRefocus(true);
295
+ };
296
+ const done = calls.filter((c) => results[c.id]);
297
+ const status = active ? `${pending.length} tool call${pending.length > 1 ? "s" : ""} waiting for approval.` : done.length ? "No tool calls waiting." : "";
298
+ return /* @__PURE__ */ jsxs("div", { ref: list, tabIndex: -1, className: cx("asta-ta-a flex w-full flex-col gap-3 text-ink outline-none", className), children: [
299
+ /* @__PURE__ */ jsx("style", { href: "asta-tool-approval", precedence: "asta", children: KEYFRAMES }),
300
+ /* @__PURE__ */ jsx("p", { className: "sr-only", "aria-live": "polite", children: status }),
301
+ done.length > 0 && /* @__PURE__ */ jsx("ul", { "aria-label": "Tool calls", className: "-mx-2.5 flex flex-col", children: done.map((c) => /* @__PURE__ */ jsx(Receipt, { call: c, r: results[c.id] }, c.id)) }),
302
+ active ? /* @__PURE__ */ jsxs("div", { className: cx("relative isolate", pending.length > 1 && "pb-3"), children: [
303
+ pending.slice(1, 3).map((c, i) => /* @__PURE__ */ jsx(
304
+ "div",
305
+ {
306
+ "aria-hidden": true,
307
+ className: "absolute inset-x-0 bottom-3 top-0 rounded-[14px] bg-paper shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_9%,transparent)] transition-transform duration-500",
308
+ style: { transform: `translateY(${(i + 1) * 7}px) scaleX(${1 - (i + 1) * 0.04})`, opacity: 1 - (i + 1) * 0.25, zIndex: -1 - i, transitionTimingFunction: CURVE }
309
+ },
310
+ c.id
311
+ )),
312
+ /* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsx(Card, { call: active, index: calls.length - pending.length, count: calls.length, onDecide: (d, f) => decide(active, d, f) }, active.id) })
313
+ ] }) : done.length === 0 && /* @__PURE__ */ jsx("p", { className: "rounded-lg bg-paper-2 px-3 py-2.5 text-[12.5px] text-mute", children: "No tool calls waiting. Requests from the agent show up here." })
314
+ ] });
315
+ }
316
+ var tool_approval_default = ToolApproval;
317
+
318
+ export {
319
+ ToolApproval,
320
+ tool_approval_default
321
+ };