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.
Files changed (144) 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/navbar.js +1 -1
  41. package/dist/base/prompt-composer.d.ts +2 -0
  42. package/dist/base/prompt-composer.js +9 -0
  43. package/dist/base/scrub-input.d.ts +2 -0
  44. package/dist/base/scrub-input.js +13 -0
  45. package/dist/base/sidebar.js +1 -1
  46. package/dist/base/thinking.d.ts +2 -0
  47. package/dist/base/thinking.js +11 -0
  48. package/dist/base/tool-approval.d.ts +2 -0
  49. package/dist/base/tool-approval.js +9 -0
  50. package/dist/base/trace-waterfall.d.ts +2 -0
  51. package/dist/base/trace-waterfall.js +9 -0
  52. package/dist/base.js +204 -136
  53. package/dist/change-ledger.d.ts +2 -0
  54. package/dist/change-ledger.js +7 -0
  55. package/dist/chunk-24O5V2PQ.js +253 -0
  56. package/dist/chunk-44DNL43W.js +490 -0
  57. package/dist/chunk-45IXJ7W7.js +245 -0
  58. package/dist/chunk-ANL6VX4X.js +326 -0
  59. package/dist/chunk-DNROUJ62.js +432 -0
  60. package/dist/{chunk-2EBWWZPS.js → chunk-DWPGFNNF.js} +38 -9
  61. package/dist/{chunk-CACW5LH3.js → chunk-EAHHWF3V.js} +38 -9
  62. package/dist/chunk-F4CWSZXK.js +226 -0
  63. package/dist/chunk-FT66LAUZ.js +388 -0
  64. package/dist/chunk-GBOJUMMY.js +163 -0
  65. package/dist/chunk-H4NFBYKY.js +275 -0
  66. package/dist/chunk-KFPGQ5RT.js +321 -0
  67. package/dist/chunk-OIIMYSVT.js +342 -0
  68. package/dist/chunk-SUWA7DM6.js +388 -0
  69. package/dist/chunk-TL32C2SQ.js +221 -0
  70. package/dist/chunk-UBTYMAKF.js +240 -0
  71. package/dist/chunk-W6YVDJHX.js +235 -0
  72. package/dist/chunk-XYQI4ZYV.js +314 -0
  73. package/dist/citations.d.ts +2 -0
  74. package/dist/citations.js +9 -0
  75. package/dist/context-meter.d.ts +2 -0
  76. package/dist/context-meter.js +14 -0
  77. package/dist/fallback-chain.d.ts +2 -0
  78. package/dist/fallback-chain.js +7 -0
  79. package/dist/index.js +204 -136
  80. package/dist/model-picker.d.ts +2 -0
  81. package/dist/model-picker.js +9 -0
  82. package/dist/navbar.js +1 -1
  83. package/dist/prompt-composer.d.ts +2 -0
  84. package/dist/prompt-composer.js +9 -0
  85. package/dist/scrub-input.d.ts +2 -0
  86. package/dist/scrub-input.js +13 -0
  87. package/dist/sidebar.js +1 -1
  88. package/dist/thinking.d.ts +2 -0
  89. package/dist/thinking.js +11 -0
  90. package/dist/tool-approval.d.ts +2 -0
  91. package/dist/tool-approval.js +9 -0
  92. package/dist/trace-waterfall.d.ts +2 -0
  93. package/dist/trace-waterfall.js +9 -0
  94. package/dist/types/components/kit/agent-plan.d.ts +34 -0
  95. package/dist/types/components/kit/api-keys.d.ts +62 -0
  96. package/dist/types/components/kit/base/navbar.d.ts +4 -1
  97. package/dist/types/components/kit/base/sidebar.d.ts +29 -7
  98. package/dist/types/components/kit/citations.d.ts +34 -0
  99. package/dist/types/components/kit/context-meter.d.ts +38 -0
  100. package/dist/types/components/kit/model-picker.d.ts +46 -0
  101. package/dist/types/components/kit/navbar.d.ts +4 -1
  102. package/dist/types/components/kit/prompt-composer.d.ts +61 -0
  103. package/dist/types/components/kit/scrub-input.d.ts +44 -0
  104. package/dist/types/components/kit/sidebar.d.ts +29 -7
  105. package/dist/types/components/kit/thinking.d.ts +28 -0
  106. package/dist/types/components/kit/tool-approval.d.ts +43 -0
  107. package/dist/types/components/kit/trace-waterfall.d.ts +44 -0
  108. package/dist/types/components/lab/blocks/AgentTeam.d.ts +2 -0
  109. package/dist/types/components/lab/blocks/AutonomyDial.d.ts +2 -0
  110. package/dist/types/components/lab/blocks/ChangeLedger.d.ts +2 -0
  111. package/dist/types/components/lab/blocks/FallbackChain.d.ts +2 -0
  112. package/dist/types/packages/asta-ui/src/agent-plan.d.ts +2 -0
  113. package/dist/types/packages/asta-ui/src/agent-team.d.ts +2 -0
  114. package/dist/types/packages/asta-ui/src/api-keys.d.ts +2 -0
  115. package/dist/types/packages/asta-ui/src/autonomy-dial.d.ts +2 -0
  116. package/dist/types/packages/asta-ui/src/base/agent-plan.d.ts +2 -0
  117. package/dist/types/packages/asta-ui/src/base/agent-team.d.ts +2 -0
  118. package/dist/types/packages/asta-ui/src/base/api-keys.d.ts +2 -0
  119. package/dist/types/packages/asta-ui/src/base/autonomy-dial.d.ts +2 -0
  120. package/dist/types/packages/asta-ui/src/base/change-ledger.d.ts +2 -0
  121. package/dist/types/packages/asta-ui/src/base/citations.d.ts +2 -0
  122. package/dist/types/packages/asta-ui/src/base/context-meter.d.ts +2 -0
  123. package/dist/types/packages/asta-ui/src/base/fallback-chain.d.ts +2 -0
  124. package/dist/types/packages/asta-ui/src/base/model-picker.d.ts +2 -0
  125. package/dist/types/packages/asta-ui/src/base/prompt-composer.d.ts +2 -0
  126. package/dist/types/packages/asta-ui/src/base/scrub-input.d.ts +2 -0
  127. package/dist/types/packages/asta-ui/src/base/thinking.d.ts +2 -0
  128. package/dist/types/packages/asta-ui/src/base/tool-approval.d.ts +2 -0
  129. package/dist/types/packages/asta-ui/src/base/trace-waterfall.d.ts +2 -0
  130. package/dist/types/packages/asta-ui/src/base.d.ts +26 -2
  131. package/dist/types/packages/asta-ui/src/change-ledger.d.ts +2 -0
  132. package/dist/types/packages/asta-ui/src/citations.d.ts +2 -0
  133. package/dist/types/packages/asta-ui/src/context-meter.d.ts +2 -0
  134. package/dist/types/packages/asta-ui/src/fallback-chain.d.ts +2 -0
  135. package/dist/types/packages/asta-ui/src/index.d.ts +26 -2
  136. package/dist/types/packages/asta-ui/src/model-picker.d.ts +2 -0
  137. package/dist/types/packages/asta-ui/src/prompt-composer.d.ts +2 -0
  138. package/dist/types/packages/asta-ui/src/scrub-input.d.ts +2 -0
  139. package/dist/types/packages/asta-ui/src/thinking.d.ts +2 -0
  140. package/dist/types/packages/asta-ui/src/tool-approval.d.ts +2 -0
  141. package/dist/types/packages/asta-ui/src/trace-waterfall.d.ts +2 -0
  142. package/package.json +1 -1
  143. package/dist/chunk-MVE7RJJ6.js +0 -322
  144. package/dist/chunk-TBMUSER2.js +0 -322
@@ -63,7 +63,26 @@ function Tile({ tile, big }) {
63
63
  }
64
64
  );
65
65
  }
66
+ function List({ links }) {
67
+ return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-0.5 p-1.5", children: links.map((l) => /* @__PURE__ */ jsxs(
68
+ "a",
69
+ {
70
+ href: l.href,
71
+ "data-kit-nav-link": true,
72
+ className: "group/item flex items-start gap-3 rounded-lg px-2.5 py-2 outline-none transition-colors duration-150 hover:bg-paper-2 focus-visible:bg-paper-2",
73
+ children: [
74
+ l.icon && /* @__PURE__ */ jsx("span", { className: cx("mt-px flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-paper text-mute transition-colors duration-150 group-hover/item:text-ink [&_svg]:h-3.5 [&_svg]:w-3.5", RING), children: l.icon }),
75
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-col", children: [
76
+ /* @__PURE__ */ jsx("span", { className: "text-[13.5px] font-medium text-ink", children: l.title }),
77
+ l.description && /* @__PURE__ */ jsx("span", { className: "text-[12px] leading-snug text-mute", children: l.description })
78
+ ] })
79
+ ]
80
+ },
81
+ l.title
82
+ )) });
83
+ }
66
84
  function Panel({ menu }) {
85
+ if (menu.list) return /* @__PURE__ */ jsx(List, { links: menu.list });
67
86
  const tiles = menu.tiles ?? [];
68
87
  const big = tiles.some((t) => t.preview);
69
88
  return /* @__PURE__ */ jsxs("div", { className: "group/menu flex flex-col gap-2 p-2", children: [
@@ -109,13 +128,14 @@ function Panel({ menu }) {
109
128
  ] })
110
129
  ] });
111
130
  }
112
- var flat = (m) => [...m.tiles ?? [], ...m.columns?.flatMap((c) => c.links) ?? []];
131
+ var flat = (m) => [...m.list ?? [], ...m.tiles ?? [], ...m.columns?.flatMap((c) => c.links) ?? []];
113
132
  function Navbar({ brand, brandHref = "/", items, docs, cta, scrollRoot, className }) {
114
133
  const [open, setOpen] = useState(null);
115
134
  const [dir, setDir] = useState(1);
116
135
  const [last, setLast] = useState(null);
117
136
  const [slide, setSlide] = useState(false);
118
137
  const [size, setSize] = useState({ w: 0, h: 0 });
138
+ const [anchor, setAnchor] = useState({ left: 0, bar: 0 });
119
139
  const [scrolled, setScrolled] = useState(false);
120
140
  const [sheet, setSheet] = useState(false);
121
141
  const [section, setSection] = useState(null);
@@ -135,17 +155,22 @@ function Navbar({ brand, brandHref = "/", items, docs, cta, scrollRoot, classNam
135
155
  const moving = i !== null && cur !== null && i !== cur;
136
156
  if (moving) setDir(i > cur ? 1 : -1);
137
157
  setSlide(moving);
138
- if (i !== null) setLast(i);
158
+ if (i !== null) {
159
+ setLast(i);
160
+ const t = triggers.current[i];
161
+ const bar = t?.closest("[data-kit-nav-bar]");
162
+ if (t && bar) setAnchor({ left: t.getBoundingClientRect().left - bar.getBoundingClientRect().left, bar: bar.offsetWidth });
163
+ }
139
164
  setOpen(i);
140
165
  }, []);
141
166
  const enter = (i) => {
142
167
  clearTimeout(timer.current);
143
- if (openRef.current === null) timer.current = setTimeout(() => show(i), 110);
168
+ if (openRef.current === null) timer.current = setTimeout(() => show(i), 80);
144
169
  else show(i);
145
170
  };
146
171
  const leave = () => {
147
172
  clearTimeout(timer.current);
148
- timer.current = setTimeout(() => show(null), 180);
173
+ timer.current = setTimeout(() => show(null), 150);
149
174
  };
150
175
  const stay = () => clearTimeout(timer.current);
151
176
  useLayoutEffect(() => {
@@ -194,6 +219,7 @@ function Navbar({ brand, brandHref = "/", items, docs, cta, scrollRoot, classNam
194
219
  }, [show]);
195
220
  useEffect(() => () => clearTimeout(timer.current), []);
196
221
  const menu = shown !== null ? items[shown]?.menu : void 0;
222
+ const panelX = menu?.list ? Math.max(12, Math.min(anchor.left - 6, anchor.bar - size.w - 12)) : (anchor.bar - size.w) / 2;
197
223
  const trigger = "flex h-8 items-center gap-1 rounded-md px-2.5 text-[13.5px] font-medium text-ink-2 outline-none transition-colors duration-200 hover:bg-paper-2 hover:text-ink focus-visible:ring-2 focus-visible:ring-brand/50 aria-expanded:bg-paper-2 aria-expanded:text-ink";
198
224
  return /* @__PURE__ */ jsxs(
199
225
  "header",
@@ -206,11 +232,11 @@ function Navbar({ brand, brandHref = "/", items, docs, cta, scrollRoot, classNam
206
232
  ),
207
233
  children: [
208
234
  /* @__PURE__ */ jsx("style", { href: "asta-navbar", precedence: "asta", children: `
209
- @keyframes kit-nav-in { from { opacity: 0; transform: translateX(calc(var(--kit-dir) * 36px)); } to { opacity: 1; transform: none; } }
235
+ @keyframes kit-nav-in { from { opacity: 0; transform: translateX(calc(var(--kit-dir) * 14px)); } to { opacity: 1; transform: none; } }
210
236
  @keyframes kit-nav-pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
211
237
  @media (prefers-reduced-motion: reduce) { .kit-nav-motion, .kit-nav-motion * { animation: none !important; transition-duration: 0s !important; } }
212
238
  ` }),
213
- /* @__PURE__ */ jsxs("div", { className: "kit-nav-motion relative flex h-14 items-center gap-3 px-4", children: [
239
+ /* @__PURE__ */ jsxs("div", { "data-kit-nav-bar": true, className: "kit-nav-motion relative flex h-14 items-center gap-3 px-4", children: [
214
240
  /* @__PURE__ */ jsx("a", { href: brandHref, className: "flex flex-1 items-center gap-2 text-[15px] font-semibold tracking-[-0.02em] text-ink outline-none focus-visible:ring-2 focus-visible:ring-brand/50 rounded-md", children: brand }),
215
241
  /* @__PURE__ */ jsx("nav", { "aria-label": "Main", className: "hidden @min-[560px]:block", onPointerLeave: leave, onPointerEnter: stay, children: /* @__PURE__ */ jsx("ul", { className: "flex items-center gap-0.5", children: items.map((it, i) => /* @__PURE__ */ jsx("li", { children: it.menu ? /* @__PURE__ */ jsxs(
216
242
  "button",
@@ -280,9 +306,12 @@ function Navbar({ brand, brandHref = "/", items, docs, cta, scrollRoot, classNam
280
306
  onPointerEnter: stay,
281
307
  onPointerLeave: leave,
282
308
  className: cx(
283
- "absolute left-1/2 top-[calc(100%-2px)] hidden -translate-x-1/2 @min-[560px]:block",
309
+ "absolute left-0 top-[calc(100%-2px)] hidden @min-[560px]:block",
310
+ size.w > 0 && "transition-transform duration-300",
311
+ EASE,
284
312
  open === null && "pointer-events-none"
285
313
  ),
314
+ style: { transform: `translateX(${Math.round(panelX)}px)` },
286
315
  children: /* @__PURE__ */ jsx(
287
316
  "div",
288
317
  {
@@ -299,8 +328,8 @@ function Navbar({ brand, brandHref = "/", items, docs, cta, scrollRoot, classNam
299
328
  className: "w-max",
300
329
  style: {
301
330
  "--kit-dir": dir,
302
- width: `min(${menu.width ?? 560}px, calc(100cqw - 24px))`,
303
- animation: slide ? "kit-nav-in .38s cubic-bezier(.16,1,.3,1) both" : void 0
331
+ width: `min(${menu.width ?? (menu.list ? 300 : 560)}px, calc(100cqw - 24px))`,
332
+ animation: slide ? "kit-nav-in .28s cubic-bezier(.16,1,.3,1) both" : void 0
304
333
  },
305
334
  children: /* @__PURE__ */ jsx(Panel, { menu })
306
335
  },
@@ -0,0 +1,226 @@
1
+ "use client";
2
+
3
+ // components/kit/agent-plan.tsx
4
+ import { useEffect, useRef, useState } from "react";
5
+ import { Fragment, 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-plan-spin { to { transform: rotate(360deg) } }
9
+ @keyframes asta-plan-pop { from { opacity: 0; transform: scale(.6) } }
10
+ @keyframes asta-plan-draw { from { stroke-dashoffset: 1 } }
11
+ @keyframes asta-plan-in { from { opacity: 0; transform: translateY(4px) } }
12
+ @media (prefers-reduced-motion: reduce) { .asta-plan-a, .asta-plan-a * { animation: none !important; transition-duration: 0s !important } }`;
13
+ var formatStepTime = (ms) => {
14
+ const s = Math.max(0, ms) / 1e3;
15
+ if (s < 10) return `${s.toFixed(1)}s`;
16
+ if (s < 60) return `${Math.floor(s)}s`;
17
+ return `${Math.floor(s / 60)}m ${String(Math.floor(s % 60)).padStart(2, "0")}s`;
18
+ };
19
+ var settled = (s) => s === "done" || s === "skipped" || s === "failed";
20
+ function useNow(on, el) {
21
+ const [now, setNow] = useState(0);
22
+ useEffect(() => {
23
+ if (!on) return;
24
+ const node = el.current;
25
+ let seen = true;
26
+ let timer;
27
+ const tick = () => setNow(Date.now());
28
+ const sync = () => {
29
+ clearInterval(timer);
30
+ timer = void 0;
31
+ if (seen && !document.hidden) {
32
+ tick();
33
+ timer = setInterval(tick, 250);
34
+ }
35
+ };
36
+ const io = node ? new IntersectionObserver(([e]) => {
37
+ seen = e.isIntersecting;
38
+ sync();
39
+ }) : null;
40
+ if (node) io?.observe(node);
41
+ document.addEventListener("visibilitychange", sync);
42
+ sync();
43
+ return () => {
44
+ clearInterval(timer);
45
+ io?.disconnect();
46
+ document.removeEventListener("visibilitychange", sync);
47
+ };
48
+ }, [on, el]);
49
+ return now;
50
+ }
51
+ function StatusIcon({ status, small }) {
52
+ const box = small ? "h-3.5 w-3.5" : "h-[18px] w-[18px]";
53
+ if (status === "running")
54
+ return /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 18 18", className: cx(box, "asta-plan-a shrink-0 animate-[asta-plan-spin_.8s_linear_infinite] text-brand"), fill: "none", "aria-hidden": true, children: [
55
+ /* @__PURE__ */ jsx("circle", { cx: "9", cy: "9", r: "7", stroke: "currentColor", strokeOpacity: ".2", strokeWidth: "2" }),
56
+ /* @__PURE__ */ jsx("path", { d: "M16 9a7 7 0 0 0-7-7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" })
57
+ ] });
58
+ if (status === "done")
59
+ return /* @__PURE__ */ jsx("span", { className: cx(box, "asta-plan-a grid shrink-0 place-items-center rounded-full bg-brand text-white animate-[asta-plan-pop_.35s_cubic-bezier(.16,1,.3,1)_both]"), "aria-hidden": true, children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", className: "h-[70%] w-[70%]", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "m3.5 8.5 3 3 6-7", pathLength: 1, strokeDasharray: 1, className: "asta-plan-a animate-[asta-plan-draw_.45s_cubic-bezier(.16,1,.3,1)_.1s_both]" }) }) });
60
+ if (status === "failed")
61
+ return /* @__PURE__ */ jsx("span", { className: cx(box, "asta-plan-a grid shrink-0 place-items-center rounded-full bg-ink text-paper animate-[asta-plan-pop_.35s_cubic-bezier(.16,1,.3,1)_both]"), "aria-hidden": true, children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", className: "h-[70%] w-[70%]", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", children: /* @__PURE__ */ jsx("path", { d: "M8 4v5M8 12h.01" }) }) });
62
+ if (status === "skipped")
63
+ return /* @__PURE__ */ jsx("span", { className: cx(box, "grid shrink-0 place-items-center rounded-full text-mute shadow-[inset_0_0_0_1.5px_color-mix(in_srgb,var(--ink)_20%,transparent)]"), "aria-hidden": true, children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", className: "h-[70%] w-[70%]", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", children: /* @__PURE__ */ jsx("path", { d: "M5 8h6" }) }) });
64
+ return /* @__PURE__ */ jsx("span", { className: cx(box, "shrink-0 rounded-full shadow-[inset_0_0_0_1.5px_color-mix(in_srgb,var(--ink)_20%,transparent)]"), "aria-hidden": true });
65
+ }
66
+ var WORD = { pending: "Pending", running: "Running", done: "Done", skipped: "Skipped", failed: "Failed" };
67
+ function elapsed(s, now) {
68
+ if (s.status === "running" && s.startedAt) return Math.max(0, (now || s.startedAt) - s.startedAt);
69
+ return s.duration;
70
+ }
71
+ function AgentPlan({ title, steps, action, footer, className }) {
72
+ const root = useRef(null);
73
+ const [pinned, setPinned] = useState({});
74
+ const running = steps.some((s) => s.status === "running" || s.substeps?.some((x) => x.status === "running"));
75
+ const now = useNow(running, root);
76
+ const total = steps.length;
77
+ const doneCount = steps.filter((s) => settled(s.status)).length;
78
+ const failedAt = steps.findIndex((s) => s.status === "failed");
79
+ const current = steps.findIndex((s) => s.status === "running");
80
+ const allDone = total > 0 && doneCount === total && failedAt < 0;
81
+ const spent = steps.reduce((a, s) => a + (elapsed(s, now) ?? 0), 0);
82
+ const state = failedAt >= 0 ? `Stopped at step ${failedAt + 1}` : allDone ? "Done" : running ? "Running" : doneCount === 0 ? "Not started" : "Paused";
83
+ const live = failedAt >= 0 ? `Step ${failedAt + 1} failed: ${steps[failedAt].title}.` : current >= 0 ? `Step ${current + 1} of ${total}: ${steps[current].title}.` : allDone ? `All ${total} steps done.` : "";
84
+ return /* @__PURE__ */ jsxs(
85
+ "section",
86
+ {
87
+ ref: root,
88
+ "aria-label": title,
89
+ className: cx(
90
+ "asta-plan-a flex w-full flex-col rounded-[14px] bg-paper text-ink shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_9%,transparent),0_1px_2px_rgb(0_0_0/0.04)]",
91
+ className
92
+ ),
93
+ children: [
94
+ /* @__PURE__ */ jsx("style", { href: "asta-agent-plan", precedence: "asta", children: KEYFRAMES }),
95
+ /* @__PURE__ */ jsx("p", { className: "sr-only", "aria-live": "polite", children: live }),
96
+ /* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-3 px-4 pb-3 pt-4", children: [
97
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3", children: [
98
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
99
+ /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-1.5 text-[12px] text-mute", children: [
100
+ running && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "h-1.5 w-1.5 rounded-full bg-brand animate-[asta-plan-pop_1.2s_ease-in-out_infinite_alternate]" }),
101
+ /* @__PURE__ */ jsx("span", { className: cx(failedAt >= 0 && "font-medium text-ink"), children: state }),
102
+ spent > 0 && /* @__PURE__ */ jsxs("span", { className: "tabular-nums", children: [
103
+ "\xB7 ",
104
+ formatStepTime(spent)
105
+ ] })
106
+ ] }),
107
+ /* @__PURE__ */ jsx("h3", { className: "mt-0.5 text-[14.5px] font-medium leading-snug tracking-[-0.01em]", children: title })
108
+ ] }),
109
+ action
110
+ ] }),
111
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
112
+ /* @__PURE__ */ jsx("div", { className: "relative h-1 flex-1 overflow-hidden rounded-full bg-paper-2", children: /* @__PURE__ */ jsx(
113
+ "span",
114
+ {
115
+ className: cx("absolute inset-0 origin-left transition-[transform,background-color] duration-700 motion-reduce:transition-none", failedAt >= 0 ? "bg-ink" : "bg-brand"),
116
+ style: { transform: `scaleX(${total ? doneCount / total : 0})`, transitionTimingFunction: CURVE }
117
+ }
118
+ ) }),
119
+ /* @__PURE__ */ jsxs("p", { className: "shrink-0 text-[12px] tabular-nums text-mute", children: [
120
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-ink", children: doneCount }),
121
+ " of ",
122
+ total
123
+ ] })
124
+ ] })
125
+ ] }),
126
+ total === 0 ? /* @__PURE__ */ jsx("p", { className: "px-4 pb-5 text-[13px] text-mute", children: "The plan shows up here once the agent has one." }) : /* @__PURE__ */ jsx("ol", { className: "flex flex-col px-2 pb-2", children: steps.map((s, i) => {
127
+ const subs = s.substeps ?? [];
128
+ const canOpen = !!s.detail || subs.length > 0;
129
+ const open = canOpen && (pinned[s.id] ?? (s.status === "running" || s.status === "failed"));
130
+ const t = elapsed(s, now);
131
+ const bodyId = `plan-${s.id}`;
132
+ const row = /* @__PURE__ */ jsxs(Fragment, { children: [
133
+ /* @__PURE__ */ jsx(StatusIcon, { status: s.status }, s.status),
134
+ /* @__PURE__ */ jsx(
135
+ "span",
136
+ {
137
+ className: cx(
138
+ "min-w-0 flex-1 text-left text-[13.5px] leading-snug [overflow-wrap:anywhere]",
139
+ s.status === "pending" && "text-mute",
140
+ s.status === "running" && "font-medium text-ink",
141
+ s.status === "done" && "text-ink-2",
142
+ s.status === "skipped" && "text-mute line-through decoration-[color-mix(in_srgb,var(--ink)_30%,transparent)]",
143
+ s.status === "failed" && "font-medium text-ink"
144
+ ),
145
+ children: s.title
146
+ }
147
+ ),
148
+ (s.status === "skipped" || s.status === "failed") && /* @__PURE__ */ jsx("span", { className: cx("shrink-0 rounded px-1.5 py-px text-[11px]", s.status === "failed" ? "bg-ink font-medium text-paper" : "bg-paper-2 text-mute"), children: WORD[s.status] }),
149
+ t !== void 0 && s.status !== "skipped" && /* @__PURE__ */ jsx("span", { className: "w-12 shrink-0 text-right text-[12px] tabular-nums text-mute", children: formatStepTime(t) }),
150
+ canOpen && /* @__PURE__ */ jsx(
151
+ "svg",
152
+ {
153
+ viewBox: "0 0 16 16",
154
+ "aria-hidden": true,
155
+ className: cx("h-3.5 w-3.5 shrink-0 text-mute transition-transform duration-300", open && "rotate-90"),
156
+ style: { transitionTimingFunction: CURVE },
157
+ fill: "none",
158
+ stroke: "currentColor",
159
+ strokeWidth: "1.7",
160
+ strokeLinecap: "round",
161
+ strokeLinejoin: "round",
162
+ children: /* @__PURE__ */ jsx("path", { d: "m6 4 4 4-4 4" })
163
+ }
164
+ )
165
+ ] });
166
+ return /* @__PURE__ */ jsxs("li", { className: "relative", children: [
167
+ i < total - 1 && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute bottom-[-6px] left-[17px] top-[30px] w-px bg-[color-mix(in_srgb,var(--ink)_10%,transparent)]" }),
168
+ canOpen ? /* @__PURE__ */ jsxs(
169
+ "button",
170
+ {
171
+ type: "button",
172
+ "aria-expanded": open,
173
+ "aria-controls": bodyId,
174
+ onClick: () => setPinned((p) => ({ ...p, [s.id]: !open })),
175
+ className: "flex min-h-10 w-full items-center gap-2.5 rounded-lg px-2 py-2 outline-none transition-colors duration-200 hover:bg-paper-2 focus-visible:ring-2 focus-visible:ring-brand/50",
176
+ children: [
177
+ row,
178
+ /* @__PURE__ */ jsxs("span", { className: "sr-only", children: [
179
+ ", ",
180
+ WORD[s.status]
181
+ ] })
182
+ ]
183
+ }
184
+ ) : /* @__PURE__ */ jsxs("div", { className: "flex min-h-10 w-full items-center gap-2.5 px-2 py-2", children: [
185
+ row,
186
+ /* @__PURE__ */ jsxs("span", { className: "sr-only", children: [
187
+ ", ",
188
+ WORD[s.status]
189
+ ] })
190
+ ] }),
191
+ open && /* @__PURE__ */ jsxs("div", { id: bodyId, className: "asta-plan-a flex flex-col gap-1.5 pb-2 pl-[38px] pr-2 animate-[asta-plan-in_.3s_cubic-bezier(.16,1,.3,1)_both]", children: [
192
+ s.detail && /* @__PURE__ */ jsx(
193
+ "p",
194
+ {
195
+ className: cx(
196
+ "asta-plan-a truncate text-[12px] leading-relaxed animate-[asta-plan-in_.3s_cubic-bezier(.16,1,.3,1)_both]",
197
+ s.status === "running" ? "font-mono text-mute" : s.status === "failed" ? "whitespace-normal text-ink" : "text-mute"
198
+ ),
199
+ title: s.detail,
200
+ children: s.detail
201
+ },
202
+ s.detail
203
+ ),
204
+ subs.length > 0 && /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-1", children: subs.map((x) => /* @__PURE__ */ jsxs("li", { className: "flex items-center gap-2 text-[12.5px]", children: [
205
+ /* @__PURE__ */ jsx(StatusIcon, { status: x.status, small: true }, x.status),
206
+ /* @__PURE__ */ jsx("span", { className: cx("min-w-0 flex-1 truncate", x.status === "pending" ? "text-mute" : x.status === "running" ? "text-ink" : "text-ink-2"), children: x.title }),
207
+ /* @__PURE__ */ jsxs("span", { className: "sr-only", children: [
208
+ ", ",
209
+ WORD[x.status]
210
+ ] })
211
+ ] }, x.id)) })
212
+ ] })
213
+ ] }, s.id);
214
+ }) }),
215
+ footer && /* @__PURE__ */ jsx("div", { className: "px-4 pb-4", children: footer })
216
+ ]
217
+ }
218
+ );
219
+ }
220
+ var agent_plan_default = AgentPlan;
221
+
222
+ export {
223
+ formatStepTime,
224
+ AgentPlan,
225
+ agent_plan_default
226
+ };