@aparte/core 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/client/stream-adapter.d.ts +20 -0
  2. package/dist/client/stream-adapter.d.ts.map +1 -1
  3. package/dist/client/wire-history.d.ts +2 -0
  4. package/dist/client/wire-history.d.ts.map +1 -1
  5. package/dist/components/bubble/aparte-chat-bubble.d.ts +14 -0
  6. package/dist/components/bubble/aparte-chat-bubble.d.ts.map +1 -1
  7. package/dist/components/conversation-list/aparte-conversation-list.d.ts +46 -22
  8. package/dist/components/conversation-list/aparte-conversation-list.d.ts.map +1 -1
  9. package/dist/components/viewport/aparte-chat-viewport.d.ts +5 -0
  10. package/dist/components/viewport/aparte-chat-viewport.d.ts.map +1 -1
  11. package/dist/config/aparte-config.d.ts +44 -1
  12. package/dist/config/aparte-config.d.ts.map +1 -1
  13. package/dist/config/bubble-shell-renderer.d.ts +3 -0
  14. package/dist/config/bubble-shell-renderer.d.ts.map +1 -1
  15. package/dist/config/index.d.ts +1 -1
  16. package/dist/config/index.d.ts.map +1 -1
  17. package/dist/custom-elements.json +721 -69
  18. package/dist/{defer-hydration-W4yhnyfc.js → defer-hydration-o5MFsc_Z.js} +423 -193
  19. package/dist/defer-hydration-o5MFsc_Z.js.map +1 -0
  20. package/dist/elicitation/panel.d.ts.map +1 -1
  21. package/dist/host/aparte-chat-host.d.ts +8 -0
  22. package/dist/host/aparte-chat-host.d.ts.map +1 -1
  23. package/dist/index.css +1 -1
  24. package/dist/index.d.ts +6 -2
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +238 -179
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.node.d.ts +6 -2
  29. package/dist/index.node.d.ts.map +1 -1
  30. package/dist/index.node.js +52 -47
  31. package/dist/index.node.js.map +1 -1
  32. package/dist/kit-keyboard-BUSLQ5i4.js +434 -0
  33. package/dist/kit-keyboard-BUSLQ5i4.js.map +1 -0
  34. package/dist/renderers/segment-renderers.d.ts.map +1 -1
  35. package/dist/renderers/segments/activity.d.ts +5 -0
  36. package/dist/renderers/segments/activity.d.ts.map +1 -0
  37. package/dist/renderers/segments/tool-call.d.ts.map +1 -1
  38. package/dist/types/chat.d.ts +22 -0
  39. package/dist/types/chat.d.ts.map +1 -1
  40. package/dist/types/event-map.d.ts +4 -0
  41. package/dist/types/event-map.d.ts.map +1 -1
  42. package/dist/types/index.d.ts +2 -2
  43. package/dist/types/index.d.ts.map +1 -1
  44. package/dist/types/segments.d.ts +53 -1
  45. package/dist/types/segments.d.ts.map +1 -1
  46. package/dist/types/tools.d.ts +27 -1
  47. package/dist/types/tools.d.ts.map +1 -1
  48. package/dist/utils/menu.d.ts +90 -0
  49. package/dist/utils/menu.d.ts.map +1 -0
  50. package/dist/utils/tabs.d.ts +49 -0
  51. package/dist/utils/tabs.d.ts.map +1 -0
  52. package/package.json +2 -2
  53. package/dist/defer-hydration-W4yhnyfc.js.map +0 -1
@@ -1,4 +1,5 @@
1
1
  import { runSubAgent as runSubAgent$1, startSubAgent as startSubAgent$1, toolRefusal as toolRefusal$1, unansweredTail, runStreamAgent } from "@aparte/engine";
2
+ import { c as cssEscape, b as enhanceTabs, d as eventOrigin, r as rootOf } from "./kit-keyboard-BUSLQ5i4.js";
2
3
  import { A as APARTE_ICON_GLYPHS } from "./glyphs-LolG04CC.js";
3
4
  function contentToText(content) {
4
5
  if (typeof content === "string") return content;
@@ -3265,28 +3266,43 @@ function outcomeOf(segment) {
3265
3266
  if (segment.status === "rejected" && segment.refusal) return null;
3266
3267
  return { key: "toolOutput", text };
3267
3268
  }
3268
- function behindOf(segment, line) {
3269
+ function behindOf(segment, line, row) {
3269
3270
  const display = contextConfig().getToolDisplay(segment.toolCall?.name ?? "");
3270
3271
  const details = display && "details" in display ? display.details : line?.details;
3271
3272
  if (details === false) return { kind: "none" };
3272
3273
  if (typeof details !== "function") return { kind: "parts" };
3273
3274
  try {
3274
- const out = details(segment);
3275
+ const out = details(segment, row ? heldBy(row) : void 0);
3275
3276
  if (!out) return { kind: "none" };
3276
3277
  return { kind: "body", body: typeof out === "string" ? contextConfig().sanitizeHtml(out) : out };
3277
3278
  } catch {
3278
3279
  return { kind: "none" };
3279
3280
  }
3280
3281
  }
3281
- const appDetailOf = (element) => element.querySelector(':scope > .aparte-tool-detail[data-details="app"]');
3282
+ function disclosureOf(row) {
3283
+ if (row.tagName === "DETAILS") return row;
3284
+ return row.querySelector(":scope > details.aparte-tool-disclosure");
3285
+ }
3286
+ const appDetailOf = (element) => element.querySelector(':scope > .aparte-tool-detail[data-details="app"], :scope > .aparte-tool-disclosure > .aparte-tool-detail[data-details="app"]');
3282
3287
  function setBody(element, body) {
3283
3288
  const detail = element.querySelector(".aparte-tool-detail");
3284
3289
  if (!detail) return;
3285
3290
  if (typeof body !== "string" && body.parentNode === detail) return;
3286
- if (typeof body === "string") detail.innerHTML = body;
3287
- else detail.replaceChildren(body);
3291
+ if (typeof body === "string") {
3292
+ detail.innerHTML = body;
3293
+ heldBodies.delete(detail);
3294
+ } else {
3295
+ detail.replaceChildren(body);
3296
+ heldBodies.set(detail, body);
3297
+ }
3288
3298
  drawnBodies.set(detail, serialized(body));
3289
3299
  }
3300
+ const heldBodies = /* @__PURE__ */ new WeakMap();
3301
+ function heldBy(row) {
3302
+ const detail = appDetailOf(row);
3303
+ const body = detail ? heldBodies.get(detail) : void 0;
3304
+ return body && body.parentNode === detail ? body : void 0;
3305
+ }
3290
3306
  const drawnBodies = /* @__PURE__ */ new WeakMap();
3291
3307
  const serialized = (body) => typeof body === "string" ? body : body.outerHTML;
3292
3308
  function relabelBody(detail, body) {
@@ -3303,7 +3319,11 @@ function relabelBody(detail, body) {
3303
3319
  const prev = document.createElement("div");
3304
3320
  if (before !== void 0) prev.innerHTML = before;
3305
3321
  if (before !== void 0 && sameShape(prev, next) && sameShape(prev, detail)) patchChanges(detail, prev, next);
3306
- else detail.replaceChildren(...Array.from(next.childNodes));
3322
+ else {
3323
+ detail.replaceChildren(...Array.from(next.childNodes));
3324
+ if (typeof body === "string") heldBodies.delete(detail);
3325
+ else heldBodies.set(detail, body);
3326
+ }
3307
3327
  drawnBodies.set(detail, now);
3308
3328
  }
3309
3329
  function sameShape(a, b) {
@@ -3471,7 +3491,70 @@ function setName(element, segment, line) {
3471
3491
  if (el2.textContent !== text) el2.textContent = text;
3472
3492
  el2.classList.toggle("aparte-tool-name--label", isLabel);
3473
3493
  }
3474
- function pillMarkup(segment, line) {
3494
+ const opens = /* @__PURE__ */ new WeakMap();
3495
+ function openOf(line) {
3496
+ const open = line?.open;
3497
+ return open && typeof open.onOpen === "function" ? open : void 0;
3498
+ }
3499
+ function openAttrs(line) {
3500
+ const open = openOf(line);
3501
+ return open ? ` data-opens${open.current ? " data-current" : ""}` : "";
3502
+ }
3503
+ function openMarkup(line) {
3504
+ const open = openOf(line);
3505
+ if (!open) return "";
3506
+ const label = escapeAttr(typeof open.label === "string" ? open.label.trim() : "");
3507
+ const icon = contextConfig().getIcon("maximize");
3508
+ return `<button type="button" class="aparte-btn aparte-btn--icon aparte-btn--sm aparte-tool-open" aria-label="${label}" title="${label}"${open.current ? ' aria-current="true"' : ""}>${icon}</button>`;
3509
+ }
3510
+ function setOpen(row, line, structural) {
3511
+ const open = openOf(line);
3512
+ const lineEl = row.querySelector(":scope > .aparte-tool-line");
3513
+ let button = row.querySelector(":scope > :is(.aparte-tool-line, .aparte-tool-open-slot) > .aparte-tool-open");
3514
+ if (open) opens.set(row, open);
3515
+ else opens.delete(row);
3516
+ if (structural && lineEl && !!open !== !!button) {
3517
+ if (button) {
3518
+ button.remove();
3519
+ button = null;
3520
+ } else {
3521
+ const tpl = document.createElement("template");
3522
+ tpl.innerHTML = openMarkup(line);
3523
+ button = tpl.content.firstElementChild;
3524
+ lineEl.insertBefore(button, lineEl.querySelector(":scope > .aparte-tool-activity"));
3525
+ }
3526
+ }
3527
+ row.toggleAttribute("data-opens", !!open && !!button);
3528
+ row.toggleAttribute("data-current", !!open?.current && !!button);
3529
+ if (!open || !button) return;
3530
+ const label = typeof open.label === "string" ? open.label.trim() : "";
3531
+ if (button.getAttribute("aria-label") !== label) {
3532
+ button.setAttribute("aria-label", label);
3533
+ button.title = label;
3534
+ }
3535
+ if (open.current) button.setAttribute("aria-current", "true");
3536
+ else button.removeAttribute("aria-current");
3537
+ }
3538
+ const wiredOpen = /* @__PURE__ */ new WeakSet();
3539
+ function wireOpen(row) {
3540
+ if (wiredOpen.has(row)) return;
3541
+ wiredOpen.add(row);
3542
+ row.addEventListener("click", (event) => {
3543
+ const open = opens.get(row);
3544
+ const target = event.target;
3545
+ if (!open || !target?.closest || target.closest(".aparte-segment-tool-call") !== row) return;
3546
+ if (!target.closest(".aparte-tool-open")) {
3547
+ if (disclosureOf(row) || target.closest(".aparte-tool-line")?.parentElement !== row) return;
3548
+ if (row.ownerDocument.getSelection?.()?.isCollapsed === false) return;
3549
+ }
3550
+ try {
3551
+ open.onOpen(row);
3552
+ } catch (err) {
3553
+ console.error("[aparte] a tool line's onOpen threw", err);
3554
+ }
3555
+ });
3556
+ }
3557
+ function pillMarkup(segment, line, withOpen = true) {
3475
3558
  const badge = stateBadge(segment);
3476
3559
  const icon = iconOf(segment);
3477
3560
  const target = toolTarget(segment, line);
@@ -3479,6 +3562,7 @@ function pillMarkup(segment, line) {
3479
3562
  const note = noteOf(segment, line);
3480
3563
  const name = nameOf(segment, line);
3481
3564
  const quiet = quietOf(segment);
3565
+ const open = withOpen ? openMarkup(line) : "";
3482
3566
  return `
3483
3567
  <span class="aparte-tool-label">
3484
3568
  <span class="aparte-tool-icon">${icon}</span>
@@ -3487,20 +3571,20 @@ function pillMarkup(segment, line) {
3487
3571
  </span>
3488
3572
  <span class="aparte-spinner aparte-tool-spinner" aria-hidden="true"${quiet.spinner ? "" : " hidden"}></span>
3489
3573
  <span class="aparte-tool-state${quiet.stateHidden ? " aparte-sr-only" : ""}">${badge}</span>
3490
- <span class="aparte-tool-note"${note ? ` title="${escapeAttr(note)}"` : " hidden"}>${escapeHtml(note)}</span>
3574
+ <span class="aparte-tool-note"${note ? ` title="${escapeAttr(note)}"` : " hidden"}>${escapeHtml(note)}</span>${open}
3491
3575
  <span class="aparte-tool-activity"${activity ? "" : " hidden"}>${escapeHtml(activity)}</span>`;
3492
3576
  }
3493
3577
  function placeholderMarkup(segment) {
3494
3578
  return `<div class="aparte-segment aparte-segment-tool-call" data-segment-id="${escapeHtml(segment.id)}" data-status="${escapeAttr(segment.status ?? "pending")}" data-tool-call-id="${escapeAttr(segment.toolCall?.id ?? "")}" data-tool-name="${escapeAttr(segment.toolCall?.name ?? "tool")}" hidden></div>`;
3495
3579
  }
3496
- const isPlaceholder = (element) => element.hidden && element.classList.contains("aparte-segment-tool-call") && element.childElementCount === 0;
3497
- const drawnBy = /* @__PURE__ */ new WeakMap();
3498
- const behind = /* @__PURE__ */ new WeakMap();
3580
+ const isPlaceholder$1 = (element) => element.hidden && element.classList.contains("aparte-segment-tool-call") && element.childElementCount === 0;
3581
+ const drawnBy$1 = /* @__PURE__ */ new WeakMap();
3582
+ const behind$1 = /* @__PURE__ */ new WeakMap();
3499
3583
  function toolRendererThatDrew(element) {
3500
- return behind.get(element) ?? null;
3584
+ return behind$1.get(element) ?? null;
3501
3585
  }
3502
3586
  function drawerOf(element, current) {
3503
- const recorded = drawnBy.get(element);
3587
+ const recorded = drawnBy$1.get(element);
3504
3588
  if (recorded) return recorded;
3505
3589
  return element.classList.contains("aparte-segment-tool-call") ? null : current;
3506
3590
  }
@@ -3510,32 +3594,38 @@ function drawDefault(segment, behind2, line) {
3510
3594
  const toolCallId = segment.toolCall?.id ?? "";
3511
3595
  const pill = pillMarkup(segment, line);
3512
3596
  const quiet = isQuiet(segment) ? " data-quiet" : "";
3597
+ const opensAt = openAttrs(line);
3513
3598
  const toggle = contextConfig().getIcon("expand");
3514
3599
  const input = behind2.kind === "parts" ? describeInput(segment) : "";
3515
3600
  const outcome = behind2.kind === "parts" ? outcomeOf(segment) : null;
3516
3601
  if (behind2.kind === "none" || behind2.kind === "parts" && !input && !outcome) {
3517
3602
  return `
3518
- <div class="aparte-segment aparte-segment-tool-call" data-segment-id="${escapeHtml(segment.id)}" data-status="${escapeAttr(status)}" data-tool-call-id="${escapeAttr(toolCallId)}" data-tool-name="${escapeAttr(name)}"${quiet}><div class="aparte-tool-line">${pill}</div>
3603
+ <div class="aparte-segment aparte-segment-tool-call" data-segment-id="${escapeHtml(segment.id)}" data-status="${escapeAttr(status)}" data-tool-call-id="${escapeAttr(toolCallId)}" data-tool-name="${escapeAttr(name)}"${quiet}${opensAt}><div class="aparte-tool-line">${pill}</div>
3519
3604
  </div>
3520
3605
  `;
3521
3606
  }
3522
3607
  const cfg = contextConfig();
3523
3608
  const copy = copyButtonMarkup("aparte-tool-copy");
3524
3609
  const open = segment.collapsed !== void 0 ? !segment.collapsed : cfg.getToolDisplay(name)?.open === true;
3610
+ const openButton = openMarkup(line);
3611
+ const disclosure = openButton ? `<details class="aparte-tool-disclosure"${open ? " open" : ""}>` : "";
3612
+ const rowStart = openButton ? `<div class="aparte-segment aparte-segment-tool-call" data-segment-id="${escapeHtml(segment.id)}" data-status="${escapeAttr(status)}" data-tool-call-id="${escapeAttr(toolCallId)}" data-tool-name="${escapeAttr(name)}"${quiet}${opensAt}>${disclosure}` : `<details class="aparte-segment aparte-segment-tool-call" data-segment-id="${escapeHtml(segment.id)}" data-status="${escapeAttr(status)}" data-tool-call-id="${escapeAttr(toolCallId)}" data-tool-name="${escapeAttr(name)}"${quiet}${opensAt}${open ? " open" : ""}>`;
3613
+ const rowEnd = openButton ? `</details><span class="aparte-tool-open-slot">${openButton}</span></div>` : "</details>";
3614
+ const summaryPill = pillMarkup(segment, line, false);
3525
3615
  if (behind2.kind === "body") {
3526
3616
  const tpl = document.createElement("template");
3527
3617
  tpl.innerHTML = `
3528
- <details class="aparte-segment aparte-segment-tool-call" data-segment-id="${escapeHtml(segment.id)}" data-status="${escapeAttr(status)}" data-tool-call-id="${escapeAttr(toolCallId)}" data-tool-name="${escapeAttr(name)}"${quiet}${open ? " open" : ""}>
3529
- <summary class="aparte-tool-summary"><span class="aparte-tool-toggle">${toggle}</span>${pill}</summary>
3618
+ ${rowStart}
3619
+ <summary class="aparte-tool-summary"><span class="aparte-tool-toggle">${toggle}</span>${summaryPill}</summary>
3530
3620
  <div class="aparte-tool-detail" data-details="app"></div>
3531
- </details>`.trim();
3621
+ ${rowEnd}`.trim();
3532
3622
  const row = tpl.content.firstElementChild;
3533
3623
  setBody(row, behind2.body);
3534
3624
  return row;
3535
3625
  }
3536
3626
  return `
3537
- <details class="aparte-segment aparte-segment-tool-call" data-segment-id="${escapeHtml(segment.id)}" data-status="${escapeAttr(status)}" data-tool-call-id="${escapeAttr(toolCallId)}" data-tool-name="${escapeAttr(name)}"${quiet}${open ? " open" : ""}>
3538
- <summary class="aparte-tool-summary"><span class="aparte-tool-toggle">${toggle}</span>${pill}</summary>
3627
+ ${rowStart}
3628
+ <summary class="aparte-tool-summary"><span class="aparte-tool-toggle">${toggle}</span>${summaryPill}</summary>
3539
3629
  <div class="aparte-tool-detail">
3540
3630
  ${input ? `
3541
3631
  <div class="aparte-tool-part" data-part="input">
@@ -3548,7 +3638,7 @@ function drawDefault(segment, behind2, line) {
3548
3638
  <div class="aparte-tool-part-body" role="region" tabindex="0" aria-label="${escapeAttr(cfg.t(outcome.key))}"><pre><code>${escapeHtml(outcome.text)}</code></pre></div>
3549
3639
  </div>` : ""}
3550
3640
  </div>
3551
- </details>
3641
+ ${rowEnd}
3552
3642
  `;
3553
3643
  }
3554
3644
  const toolCallRenderer = {
@@ -3561,8 +3651,8 @@ const toolCallRenderer = {
3561
3651
  injectToolRendererStyles(name, customRenderer);
3562
3652
  const out = customRenderer.render(segment);
3563
3653
  if (out instanceof HTMLElement) {
3564
- drawnBy.set(out, customRenderer);
3565
- behind.set(out, customRenderer);
3654
+ drawnBy$1.set(out, customRenderer);
3655
+ behind$1.set(out, customRenderer);
3566
3656
  }
3567
3657
  return out || placeholderMarkup(segment);
3568
3658
  }
@@ -3580,7 +3670,7 @@ const toolCallRenderer = {
3580
3670
  * No child node is added or removed, per the relabel contract.
3581
3671
  */
3582
3672
  relabel: (element, segment) => {
3583
- if (isPlaceholder(element)) return;
3673
+ if (isPlaceholder$1(element)) return;
3584
3674
  const cfg = contextConfig();
3585
3675
  const custom = drawerOf(element, cfg.getToolRenderer(segment.toolCall?.name) ?? null);
3586
3676
  if (custom) {
@@ -3594,6 +3684,7 @@ const toolCallRenderer = {
3594
3684
  setTarget(element, segment, line);
3595
3685
  setActivity(element, segment, line);
3596
3686
  setNote(element, segment, line);
3687
+ setOpen(element, line, false);
3597
3688
  const inputLabel = element.querySelector('[data-part="input"] .aparte-tool-part-label');
3598
3689
  if (inputLabel) inputLabel.textContent = cfg.t("toolInput");
3599
3690
  element.querySelector('[data-part="input"] .aparte-tool-part-body')?.setAttribute("aria-label", cfg.t("toolInput"));
@@ -3604,7 +3695,7 @@ const toolCallRenderer = {
3604
3695
  for (const button of element.querySelectorAll(".aparte-tool-copy")) relabelCopyButton(button);
3605
3696
  const appDetail = appDetailOf(element);
3606
3697
  if (appDetail) {
3607
- const behind2 = behindOf(segment, line);
3698
+ const behind2 = behindOf(segment, line, element);
3608
3699
  if (behind2.kind === "body") relabelBody(appDetail, behind2.body);
3609
3700
  }
3610
3701
  const statusEl = element.querySelector(".aparte-tool-state");
@@ -3627,13 +3718,13 @@ const toolCallRenderer = {
3627
3718
  update: (element, segment) => {
3628
3719
  const status = segment.status ?? "pending";
3629
3720
  const hidden = contextConfig().isToolHidden(segment.toolCall?.name ?? "tool");
3630
- if (hidden && isPlaceholder(element)) {
3721
+ if (hidden && isPlaceholder$1(element)) {
3631
3722
  element.setAttribute("data-status", status);
3632
3723
  return;
3633
3724
  }
3634
3725
  const custom = hidden ? null : contextConfig().getToolRenderer(segment.toolCall?.name) ?? null;
3635
- const drawn2 = isPlaceholder(element) ? null : drawerOf(element, custom);
3636
- if (drawn2 && drawn2 === custom && drawn2.update && !isPlaceholder(element)) {
3726
+ const drawn2 = isPlaceholder$1(element) ? null : drawerOf(element, custom);
3727
+ if (drawn2 && drawn2 === custom && drawn2.update && !isPlaceholder$1(element)) {
3637
3728
  drawn2.update(element, segment);
3638
3729
  return;
3639
3730
  }
@@ -3647,19 +3738,25 @@ const toolCallRenderer = {
3647
3738
  element.replaceWith(rebuilt);
3648
3739
  toolCallRenderer.setup?.(rebuilt, segment);
3649
3740
  }
3741
+ return rebuilt;
3650
3742
  };
3651
- if (custom || drawn2 || hidden || isPlaceholder(element)) {
3743
+ if (custom || drawn2 || hidden || isPlaceholder$1(element)) {
3652
3744
  rebuild(toolCallRenderer.render(segment));
3653
3745
  return;
3654
3746
  }
3655
3747
  const line = toolLineOf(segment, contextConfig());
3656
- const behind2 = behindOf(segment, line);
3748
+ const behind2 = behindOf(segment, line, element);
3657
3749
  const input = behind2.kind === "parts" ? describeInput(segment) : "";
3658
3750
  const outcome = behind2.kind === "parts" ? outcomeOf(segment) : null;
3659
3751
  const wantsDetail = behind2.kind === "body" || !!input || !!outcome;
3660
3752
  const holdsAppDetail = !!appDetailOf(element);
3661
- if (wantsDetail !== (element.tagName === "DETAILS") || wantsDetail && behind2.kind === "body" !== holdsAppDetail) {
3662
- rebuild(drawDefault(segment, behind2, line));
3753
+ const disclosure = disclosureOf(element);
3754
+ const wrapped = !!disclosure && disclosure !== element;
3755
+ if (wantsDetail !== !!disclosure || wantsDetail && behind2.kind === "body" !== holdsAppDetail || wantsDetail && wrapped !== !!openOf(line)) {
3756
+ const wasOpen = disclosure?.open;
3757
+ const now = rebuild(drawDefault(segment, behind2, line));
3758
+ const next = now && wasOpen !== void 0 ? disclosureOf(now) : null;
3759
+ if (next && wasOpen !== void 0) next.open = wasOpen;
3663
3760
  return;
3664
3761
  }
3665
3762
  element.setAttribute("data-status", status);
@@ -3670,6 +3767,7 @@ const toolCallRenderer = {
3670
3767
  setTarget(element, segment, line);
3671
3768
  setActivity(element, segment, line);
3672
3769
  setNote(element, segment, line);
3770
+ setOpen(element, line, true);
3673
3771
  if (behind2.kind === "body") {
3674
3772
  setBody(element, behind2.body);
3675
3773
  return;
@@ -3681,11 +3779,15 @@ const toolCallRenderer = {
3681
3779
  setup: (element, segment) => {
3682
3780
  const hidden = contextConfig().isToolHidden(segment.toolCall?.name ?? "tool");
3683
3781
  const customRenderer = hidden ? void 0 : contextConfig().getToolRenderer(segment.toolCall?.name);
3684
- if (customRenderer) behind.set(element, customRenderer);
3685
- if (isPlaceholder(element)) return;
3782
+ if (customRenderer) behind$1.set(element, customRenderer);
3783
+ if (isPlaceholder$1(element)) return;
3784
+ if (!customRenderer) {
3785
+ setOpen(element, toolLineOf(segment, contextConfig()), false);
3786
+ wireOpen(element);
3787
+ }
3686
3788
  wireParts(element);
3687
3789
  highlightParts(element);
3688
- if (customRenderer) drawnBy.set(element, customRenderer);
3790
+ if (customRenderer) drawnBy$1.set(element, customRenderer);
3689
3791
  customRenderer?.setup?.(element, segment);
3690
3792
  },
3691
3793
  /**
@@ -3694,10 +3796,10 @@ const toolCallRenderer = {
3694
3796
  * all the same, and the stream that caused it is not interrupted.
3695
3797
  */
3696
3798
  cleanup: (element, segment) => {
3697
- behind.delete(element);
3698
- const custom = drawnBy.get(element);
3799
+ behind$1.delete(element);
3800
+ const custom = drawnBy$1.get(element);
3699
3801
  if (!custom) return;
3700
- drawnBy.delete(element);
3802
+ drawnBy$1.delete(element);
3701
3803
  try {
3702
3804
  custom.cleanup?.(element, segment);
3703
3805
  } catch (err) {
@@ -3709,6 +3811,88 @@ const toolCallRenderer = {
3709
3811
  // has no other way onto the page.
3710
3812
  getStyles: () => ""
3711
3813
  };
3814
+ function placeholder(segment) {
3815
+ const el2 = document.createElement("div");
3816
+ el2.className = "aparte-segment aparte-segment-activity";
3817
+ el2.setAttribute("data-segment-id", segment.id);
3818
+ el2.setAttribute("data-activity-type", segment.activityType);
3819
+ el2.hidden = true;
3820
+ return el2;
3821
+ }
3822
+ const isPlaceholder = (element) => element.hidden && element.classList.contains("aparte-segment-activity") && element.childElementCount === 0;
3823
+ const drawnBy = /* @__PURE__ */ new WeakMap();
3824
+ const behind = /* @__PURE__ */ new WeakMap();
3825
+ function activityRendererThatDrew(element) {
3826
+ return behind.get(element) ?? null;
3827
+ }
3828
+ const rendererOf = (segment) => contextConfig().getActivityRenderer(segment.activityType) ?? null;
3829
+ const activityRenderer = {
3830
+ type: "activity",
3831
+ render: (segment) => {
3832
+ const custom = rendererOf(segment);
3833
+ if (!custom) return placeholder(segment);
3834
+ const out = custom.render(segment);
3835
+ if (out instanceof HTMLElement) {
3836
+ drawnBy.set(out, custom);
3837
+ behind.set(out, custom);
3838
+ return out;
3839
+ }
3840
+ return out.trim() ? out : placeholder(segment);
3841
+ },
3842
+ setup: (element, segment) => {
3843
+ const custom = rendererOf(segment);
3844
+ if (!custom) return;
3845
+ behind.set(element, custom);
3846
+ if (isPlaceholder(element)) return;
3847
+ drawnBy.set(element, custom);
3848
+ custom.setup?.(element, segment);
3849
+ },
3850
+ /**
3851
+ * The agent sent it again. The renderer that drew it patches it, when it can and is still
3852
+ * the one registered; otherwise it is drawn again here, and the bubble follows the element.
3853
+ */
3854
+ update: (element, segment) => {
3855
+ const custom = rendererOf(segment);
3856
+ const drawn2 = drawnBy.get(element) ?? null;
3857
+ if (drawn2 && drawn2 === custom && drawn2.update) {
3858
+ drawn2.update(element, segment);
3859
+ return;
3860
+ }
3861
+ if (!custom && !drawn2 && isPlaceholder(element)) {
3862
+ element.setAttribute("data-activity-type", segment.activityType);
3863
+ return;
3864
+ }
3865
+ const out = activityRenderer.render(segment);
3866
+ let rebuilt;
3867
+ if (typeof out === "string") {
3868
+ const tpl = document.createElement("template");
3869
+ tpl.innerHTML = out.trim();
3870
+ rebuilt = tpl.content.firstElementChild;
3871
+ } else {
3872
+ rebuilt = out;
3873
+ }
3874
+ if (!rebuilt) return;
3875
+ if (!rebuilt.hasAttribute("data-segment-id")) rebuilt.setAttribute("data-segment-id", segment.id);
3876
+ activityRenderer.cleanup?.(element, segment);
3877
+ element.replaceWith(rebuilt);
3878
+ activityRenderer.setup?.(rebuilt, segment);
3879
+ },
3880
+ relabel: (element, segment) => {
3881
+ drawnBy.get(element)?.relabel?.(element, segment);
3882
+ },
3883
+ /** The element leaves for good: the renderer that drew it cleans up. A cleanup that throws is reported, nothing more. */
3884
+ cleanup: (element, segment) => {
3885
+ behind.delete(element);
3886
+ const custom = drawnBy.get(element);
3887
+ if (!custom) return;
3888
+ drawnBy.delete(element);
3889
+ try {
3890
+ custom.cleanup?.(element, segment);
3891
+ } catch (err) {
3892
+ console.error("[aparte] an activity renderer's cleanup threw", err);
3893
+ }
3894
+ }
3895
+ };
3712
3896
  const registries = /* @__PURE__ */ new WeakMap();
3713
3897
  function registryFor(config) {
3714
3898
  let reg = registries.get(config);
@@ -3847,7 +4031,8 @@ const DEFAULT_RENDERERS = [
3847
4031
  thinkingRenderer,
3848
4032
  codeRenderer,
3849
4033
  errorRenderer,
3850
- toolCallRenderer
4034
+ toolCallRenderer,
4035
+ activityRenderer
3851
4036
  ];
3852
4037
  const toolRefusal = toolRefusal$1;
3853
4038
  const runSubAgent = runSubAgent$1;
@@ -3882,20 +4067,20 @@ function createStreamAdapter(opts) {
3882
4067
  return { id, text, start, length: content.length, citations: [] };
3883
4068
  }).filter((s) => s.text);
3884
4069
  if (spans.length === 0) return;
3885
- const placed = /* @__PURE__ */ new Set();
4070
+ const placed2 = /* @__PURE__ */ new Set();
3886
4071
  for (const citation of callCitations) {
3887
4072
  const span = spans.find((s) => s.start >= 0 && citation.end > s.start && citation.end <= s.start + s.length);
3888
4073
  if (!span) continue;
3889
4074
  const end = citation.end - span.start;
3890
4075
  const start = citation.start === void 0 ? void 0 : Math.max(0, Math.min(end, citation.start - span.start));
3891
4076
  span.citations.push({ ...citation, end, ...start === void 0 ? {} : { start } });
3892
- for (const id of citation.sources) placed.add(id);
4077
+ for (const id of citation.sources) placed2.add(id);
3893
4078
  }
3894
4079
  const last = spans[spans.length - 1];
3895
4080
  const now = /* @__PURE__ */ new Set();
3896
4081
  for (const span of spans) {
3897
4082
  const named = new Set(span.citations.flatMap((c) => c.sources));
3898
- const sources2 = callSources.filter((s) => named.has(s.id) || span === last && !placed.has(s.id));
4083
+ const sources2 = callSources.filter((s) => named.has(s.id) || span === last && !placed2.has(s.id));
3899
4084
  if (sources2.length === 0) {
3900
4085
  if (given.has(span.id)) target.updateSegment?.(span.id, { sources: void 0, citations: void 0 });
3901
4086
  continue;
@@ -3912,8 +4097,47 @@ function createStreamAdapter(opts) {
3912
4097
  target.updateSegment?.(thinkingId, keepOpen ? { isStreaming: false } : { collapsed: true, isStreaming: false });
3913
4098
  thinkingCollapsed = true;
3914
4099
  };
4100
+ const steps = [];
4101
+ let shownStep = null;
4102
+ const showStep = () => {
4103
+ const next = steps.at(-1) ?? null;
4104
+ if (next === shownStep) return;
4105
+ shownStep = next;
4106
+ target.setStep?.(messageId, next);
4107
+ };
4108
+ const endSteps = () => {
4109
+ steps.length = 0;
4110
+ showStep();
4111
+ };
4112
+ const flushText = () => {
4113
+ const finals = parser.finalize();
4114
+ for (const s of finals) {
4115
+ noteText(s);
4116
+ if (!streaming.has(s.id)) target.addSegment?.(s);
4117
+ else if ("content" in s) target.updateSegment?.(s.id, segmentContentUpdate(s));
4118
+ }
4119
+ placeSources();
4120
+ };
4121
+ const activities = /* @__PURE__ */ new Set();
4122
+ const placed = (id) => {
4123
+ if (activities.has(id)) return true;
4124
+ const existing = target.getMessage ? target.getMessage(messageId)?.segments : target.segments;
4125
+ if (!existing?.some((s) => s.id === id)) return false;
4126
+ activities.add(id);
4127
+ return true;
4128
+ };
3915
4129
  const handle = (e) => {
3916
4130
  switch (e.type) {
4131
+ case "step-start":
4132
+ steps.push(e.name);
4133
+ showStep();
4134
+ break;
4135
+ case "step-end": {
4136
+ const at = steps.lastIndexOf(e.name);
4137
+ if (at >= 0) steps.splice(at, 1);
4138
+ showStep();
4139
+ break;
4140
+ }
3917
4141
  case "run-start":
3918
4142
  target.updateMessage?.(messageId, { status: "streaming" });
3919
4143
  break;
@@ -3972,14 +4196,19 @@ function createStreamAdapter(opts) {
3972
4196
  } else if (result.segments.length === 0) ;
3973
4197
  break;
3974
4198
  }
3975
- case "text-flush": {
3976
- const finals = parser.finalize();
3977
- for (const s of finals) {
3978
- noteText(s);
3979
- if (!streaming.has(s.id)) target.addSegment?.(s);
3980
- else if ("content" in s) target.updateSegment?.(s.id, segmentContentUpdate(s));
4199
+ case "text-flush":
4200
+ flushText();
4201
+ break;
4202
+ case "activity": {
4203
+ const id = `activity-${e.id}`;
4204
+ if (placed(id)) {
4205
+ target.updateSegment?.(id, { activityType: e.activityType, content: e.content });
4206
+ break;
3981
4207
  }
3982
- placeSources();
4208
+ activities.add(id);
4209
+ flushText();
4210
+ const segment = { id, type: "activity", activityId: e.id, activityType: e.activityType, content: e.content };
4211
+ target.addSegment?.(segment);
3983
4212
  break;
3984
4213
  }
3985
4214
  case "sources": {
@@ -4054,9 +4283,11 @@ function createStreamAdapter(opts) {
4054
4283
  }
4055
4284
  break;
4056
4285
  case "run-aborted":
4286
+ endSteps();
4057
4287
  dispatchLifecycleEvent(target, "aparte-message-aborted", { messageId }, targetId);
4058
4288
  break;
4059
4289
  case "run-suspended": {
4290
+ endSteps();
4060
4291
  const ticket = e.ticket;
4061
4292
  for (const p of e.pending) {
4062
4293
  if (p.agentId != null) continue;
@@ -4075,6 +4306,7 @@ function createStreamAdapter(opts) {
4075
4306
  break;
4076
4307
  }
4077
4308
  case "run-done":
4309
+ endSteps();
4078
4310
  target.updateMessage?.(messageId, {
4079
4311
  status: "completed",
4080
4312
  ...e.finishReason ? { finishReason: e.finishReason } : {}
@@ -5049,6 +5281,8 @@ class AparteConfig {
5049
5281
  /** Bumped by `reset()`: a restore function from before it must not undo what came after. */
5050
5282
  _overrideGeneration = 0;
5051
5283
  _toolDisplays = new ToolTable();
5284
+ /** By activity type — see {@link registerActivityRenderer}. */
5285
+ _activityRenderers = /* @__PURE__ */ new Map();
5052
5286
  /** What a plugin says about a call, read after the app's display — see {@link setToolLineProvider}. */
5053
5287
  _toolLineProvider = null;
5054
5288
  /** Tagged blocks the stream parser recognises in the prose — see {@link registerStreamBlock}. */
@@ -6184,6 +6418,45 @@ class AparteConfig {
6184
6418
  this._toolRenderers.delete(match);
6185
6419
  notifyRenderersChanged(this);
6186
6420
  }
6421
+ /**
6422
+ * Draw one type of agent activity — the structured progress an agent reports while it
6423
+ * works ("3 of 5 sources read"), which reaches the reply as an `activity` segment and is
6424
+ * updated in place each time the agent sends it again. Returns the function that takes
6425
+ * this renderer off again (it changes nothing once another one has replaced it).
6426
+ *
6427
+ * An activity with no renderer for its type is kept on the message and draws nothing:
6428
+ * no row, no room, no orphan header on a turn that holds nothing else. It is never sent
6429
+ * to the model either way. Activities already on screen follow a registration.
6430
+ *
6431
+ * @example
6432
+ * const off = aparteGlobalConfig.registerActivityRenderer('search-progress', {
6433
+ * render: (segment) => {
6434
+ * const el = document.createElement('p');
6435
+ * const { read, of } = segment.content as { read: number; of: number };
6436
+ * el.textContent = `${read} of ${of} sources read`;
6437
+ * return el;
6438
+ * },
6439
+ * update: (el, segment) => {
6440
+ * const { read, of } = segment.content as { read: number; of: number };
6441
+ * el.textContent = `${read} of ${of} sources read`;
6442
+ * },
6443
+ * });
6444
+ */
6445
+ registerActivityRenderer(activityType, renderer) {
6446
+ if (this._activityRenderers.get(activityType) !== renderer) {
6447
+ this._activityRenderers.set(activityType, renderer);
6448
+ notifyRenderersChanged(this);
6449
+ }
6450
+ return () => {
6451
+ if (this._activityRenderers.get(activityType) !== renderer) return;
6452
+ this._activityRenderers.delete(activityType);
6453
+ notifyRenderersChanged(this);
6454
+ };
6455
+ }
6456
+ /** The renderer registered for an activity type, or undefined. */
6457
+ getActivityRenderer(activityType) {
6458
+ return this._activityRenderers.get(activityType);
6459
+ }
6187
6460
  /** The renderer that draws a tool named `toolName` — exact, pattern or `'*'` — or undefined. */
6188
6461
  getToolRenderer(toolName) {
6189
6462
  return this._toolRenderers.resolve(toolName)?.value;
@@ -6600,6 +6873,7 @@ class AparteConfig {
6600
6873
  this._tools.clear();
6601
6874
  this._toolRenderers.clear();
6602
6875
  this._toolRendererOverrides.clear();
6876
+ this._activityRenderers.clear();
6603
6877
  this._overrideGeneration++;
6604
6878
  notifyRenderersChanged(this);
6605
6879
  this._toolDisplays.clear();
@@ -7310,9 +7584,6 @@ class AparteConversationManager {
7310
7584
  return (msg.content ?? "").trim();
7311
7585
  }
7312
7586
  }
7313
- function cssEscape(value) {
7314
- return value.replace(/["\\]/g, "\\$&").replace(/[\n\r\f]/g, (c) => `\\${c.charCodeAt(0).toString(16)} `);
7315
- }
7316
7587
  function filesToAttachments(files) {
7317
7588
  return files.map((file) => ({
7318
7589
  id: uuid(),
@@ -8036,6 +8307,8 @@ class AparteChatHost {
8036
8307
  options;
8037
8308
  /** Id of the assistant message currently streaming (null when idle). */
8038
8309
  _streamingId = null;
8310
+ /** The step the streaming reply is on: kept until its bubble is painted, never in the list. */
8311
+ _step = null;
8039
8312
  /**
8040
8313
  * The message object each bubble was last drawn from, by id (skip-rerender cache).
8041
8314
  *
@@ -8307,6 +8580,7 @@ class AparteChatHost {
8307
8580
  if (updates.status) {
8308
8581
  this._bubbleById(messageId)?.updateMessage?.({ status: updates.status });
8309
8582
  }
8583
+ if (this._step?.messageId === messageId && isTerminalStatus(merged.status)) this._step = null;
8310
8584
  if (index !== msgs.length - 1 && RENDERED_FIELDS.some((key) => key in updates)) {
8311
8585
  this._renderedIds.delete(messageId);
8312
8586
  const bubble = this._bubbleById(messageId);
@@ -8320,6 +8594,15 @@ class AparteChatHost {
8320
8594
  }
8321
8595
  }
8322
8596
  }
8597
+ /**
8598
+ * Say the step the agent is on in the reply's waiting indicator, or `null` for none. Live
8599
+ * only: never written into the message list. Kept for a bubble the framework has not
8600
+ * painted yet, and given to it when it is.
8601
+ */
8602
+ setStep(messageId, name) {
8603
+ this._step = name === null ? null : { messageId, name };
8604
+ this._bubbleById(messageId)?.setStep?.(name);
8605
+ }
8323
8606
  /** Append/replace the last message content (streaming text). */
8324
8607
  updateLastMessage(content, options) {
8325
8608
  if (options?.append) this.binding.onTypingChange?.(false);
@@ -8624,6 +8907,7 @@ class AparteChatHost {
8624
8907
  if (!bubble) return;
8625
8908
  populateBubbleFromMessage(bubble, message);
8626
8909
  this._renderedIds.set(message.id, message);
8910
+ if (this._step?.messageId === message.id) bubble.setStep?.(this._step.name);
8627
8911
  });
8628
8912
  this._checkpointState.reapply();
8629
8913
  }
@@ -8742,6 +9026,7 @@ class AparteChatHost {
8742
9026
  host2["updateLastMessage"] = (c, o) => this.updateLastMessage(c, o);
8743
9027
  host2["addSegment"] = (s) => this.addSegment(s);
8744
9028
  host2["updateSegment"] = (id, u) => this.updateSegment(id, u);
9029
+ host2["setStep"] = (id, name) => this.setStep(id, name);
8745
9030
  host2["removeSegment"] = (id) => this.removeSegment(id);
8746
9031
  host2["appendToSegment"] = (id, c) => this.appendToSegment(id, c);
8747
9032
  host2["getMessages"] = () => this.getMessages();
@@ -8916,7 +9201,7 @@ function segmentsToWireText(segments) {
8916
9201
  parts.push(`${fence}${lang}
8917
9202
  ${content ?? ""}
8918
9203
  ${fence}`);
8919
- } else if (segment.type === "thinking" || segment.type === "tool_call" || segment.type === "error") {
9204
+ } else if (segment.type === "thinking" || segment.type === "tool_call" || segment.type === "error" || segment.type === "activity") {
8920
9205
  continue;
8921
9206
  } else if (typeof content === "string" && content) {
8922
9207
  const wire = segment.wire;
@@ -9039,15 +9324,6 @@ function measureContext(input) {
9039
9324
  if (reply && unchanged) return result(nextRequestTokens(reply, k), false);
9040
9325
  return result(Math.round(k * total), true);
9041
9326
  }
9042
- function eventOrigin(e) {
9043
- return e.composedPath?.()[0] ?? e.target;
9044
- }
9045
- function rootOf(node) {
9046
- return node.getRootNode();
9047
- }
9048
- function activeElementIn(node) {
9049
- return node.getRootNode().activeElement ?? document.activeElement;
9050
- }
9051
9327
  let steppedPanelSeq = 0;
9052
9328
  let _relabels = null;
9053
9329
  function onRelabel(fn) {
@@ -9373,13 +9649,6 @@ function buildPanel(message, schema, onChange) {
9373
9649
  const dismiss = el$1("div", "aparte-elic-dismiss");
9374
9650
  panel.appendChild(dismiss);
9375
9651
  if (schema.type === "object") {
9376
- let show = function(index) {
9377
- current = index;
9378
- fields.forEach((f, i) => {
9379
- f.field.el.hidden = i !== index;
9380
- });
9381
- syncNav();
9382
- };
9383
9652
  const entries = Object.entries(schema.properties);
9384
9653
  const requiredKeys = new Set(schema.required ?? entries.map(([k]) => k));
9385
9654
  const cfg = contextConfig();
@@ -9426,36 +9695,25 @@ function buildPanel(message, schema, onChange) {
9426
9695
  chip.setAttribute("role", "tab");
9427
9696
  chip.textContent = f.header?.trim() || String(i + 1);
9428
9697
  chip.dir = "auto";
9429
- chip.addEventListener("click", () => {
9430
- show(i);
9431
- f.field.focus();
9432
- });
9433
9698
  chip.id = `${scope}-tab-${i}`;
9434
9699
  f.field.el.id = `${scope}-panel-${i}`;
9435
9700
  f.field.el.setAttribute("role", "tabpanel");
9436
9701
  f.field.el.setAttribute("aria-labelledby", chip.id);
9437
9702
  chip.setAttribute("aria-controls", f.field.el.id);
9438
- chip.addEventListener("keydown", (e) => {
9439
- const forward = getComputedStyle(steps).direction === "rtl" ? "ArrowLeft" : "ArrowRight";
9440
- const back = forward === "ArrowRight" ? "ArrowLeft" : "ArrowRight";
9441
- const step = e.key === forward ? 1 : e.key === back ? -1 : 0;
9442
- let next = -1;
9443
- if (step) next = (i + step + fields.length) % fields.length;
9444
- else if (e.key === "Home") next = 0;
9445
- else if (e.key === "End") next = fields.length - 1;
9446
- if (next < 0) return;
9447
- e.preventDefault();
9448
- show(next);
9449
- chips[next]?.focus();
9450
- });
9451
9703
  steps.appendChild(chip);
9452
9704
  return chip;
9453
9705
  });
9454
9706
  panel.insertBefore(steps, body);
9707
+ steps.addEventListener("aparte-tab-change", (e) => {
9708
+ current = chips.indexOf(e.detail.tab);
9709
+ });
9710
+ enhanceTabs(steps);
9711
+ steps.addEventListener("click", (e) => {
9712
+ const at = chips.indexOf(e.target.closest(".aparte-elic-step"));
9713
+ if (at >= 0 && at === current) fields[at].field.focus();
9714
+ });
9455
9715
  syncNav = () => {
9456
9716
  chips.forEach((chip, i) => {
9457
- chip.setAttribute("aria-selected", String(i === current));
9458
- chip.tabIndex = i === current ? 0 : -1;
9459
9717
  const answered = fields[i].field.isComplete();
9460
9718
  chip.toggleAttribute("data-answered", answered);
9461
9719
  const mark = chip.querySelector(".aparte-elic-step__mark");
@@ -9469,7 +9727,7 @@ function buildPanel(message, schema, onChange) {
9469
9727
  }
9470
9728
  });
9471
9729
  };
9472
- show(0);
9730
+ syncNav();
9473
9731
  return {
9474
9732
  ...api,
9475
9733
  focus: () => fields[current]?.field.focus()
@@ -11470,31 +11728,6 @@ function isAwaitingReply(message) {
11470
11728
  if (message.status === "streaming" || message.status === "pending") return true;
11471
11729
  return message.status === void 0 && message.role === "assistant" && !message.content?.trim() && !message.segments?.length;
11472
11730
  }
11473
- function placeFloating(anchor, floating, options = {}) {
11474
- const { gap = 4, margin = 8, side = "below", align = "start", rtl = false } = options;
11475
- const box = floating.getBoundingClientRect();
11476
- const clamp = (value, room, size) => Math.max(margin, Math.min(value, room - size - margin));
11477
- let top;
11478
- let left;
11479
- if (side === "beside") {
11480
- const after = anchor.right + gap;
11481
- const before = anchor.left - box.width - gap;
11482
- const [first, second] = rtl ? [before, after] : [after, before];
11483
- const fits = (x) => x >= margin && x + box.width <= window.innerWidth - margin;
11484
- left = fits(first) || !fits(second) ? first : second;
11485
- top = anchor.top;
11486
- } else {
11487
- const below = anchor.bottom + gap;
11488
- const above = anchor.top - box.height - gap;
11489
- const fitsBelow = below + box.height <= window.innerHeight - margin;
11490
- const fitsAbove = above >= margin;
11491
- if (side === "below") top = fitsBelow || !fitsAbove ? below : above;
11492
- else top = fitsAbove || !fitsBelow ? above : below;
11493
- left = align === "start" !== rtl ? anchor.left : anchor.right - box.width;
11494
- }
11495
- floating.style.top = `${clamp(top, window.innerHeight, box.height)}px`;
11496
- floating.style.left = `${clamp(left, window.innerWidth, box.width)}px`;
11497
- }
11498
11731
  function createSegmentList(opts) {
11499
11732
  const { messageId, config } = opts;
11500
11733
  let segments = (opts.segments ?? []).reduce((acc, segment) => {
@@ -11694,7 +11927,7 @@ function deferHydrationOf(ctor) {
11694
11927
  };
11695
11928
  }
11696
11929
  export {
11697
- isAwaitingReply as $,
11930
+ isFormatAdapter as $,
11698
11931
  APARTE_CONFIG_CHANGE as A,
11699
11932
  contextConfig as B,
11700
11933
  copyText as C,
@@ -11703,89 +11936,86 @@ export {
11703
11936
  createAparteChatHandler as F,
11704
11937
  createSegmentList as G,
11705
11938
  createStreamAdapter as H,
11706
- cssEscape as I,
11707
- declineDefaultRenderers as J,
11708
- defaultSanitizer as K,
11709
- deferHydrationOf as L,
11710
- defineMountedSegmentRenderer as M,
11711
- defineMountedToolRenderer as N,
11712
- detachConfig as O,
11713
- escapeAttr as P,
11714
- escapeHtml as Q,
11715
- estimateTokens as R,
11939
+ declineDefaultRenderers as I,
11940
+ defaultSanitizer as J,
11941
+ deferHydrationOf as K,
11942
+ defineMountedSegmentRenderer as L,
11943
+ defineMountedToolRenderer as M,
11944
+ detachConfig as N,
11945
+ escapeAttr as O,
11946
+ escapeHtml as P,
11947
+ estimateTokens as Q,
11948
+ estimateWireTokens as R,
11716
11949
  SUGGESTIONS_BLOCK_LANGUAGE as S,
11717
- estimateWireTokens as T,
11718
- filesToAttachments as U,
11719
- formatDuration as V,
11720
- getAllRenderers as W,
11721
- getSegmentRenderer as X,
11722
- historyFromCheckpoint as Y,
11723
- installDefaultRenderersOnce as Z,
11724
- installDialogTriggersOnce as _,
11950
+ filesToAttachments as T,
11951
+ formatDuration as U,
11952
+ getAllRenderers as V,
11953
+ getSegmentRenderer as W,
11954
+ historyFromCheckpoint as X,
11955
+ installDefaultRenderersOnce as Y,
11956
+ installDialogTriggersOnce as Z,
11957
+ isAwaitingReply as _,
11725
11958
  APARTE_CONVERSATION_SCHEMA_VERSION as a,
11726
- isFormatAdapter as a0,
11727
- isSafeUrl as a1,
11728
- isSegmentSettled as a2,
11729
- measureContext as a3,
11959
+ isSafeUrl as a0,
11960
+ isSegmentSettled as a1,
11961
+ measureContext as a2,
11962
+ onRenderersChange as a3,
11730
11963
  overrideSegmentRenderer as a4,
11731
11964
  parseAparteEventStream as a5,
11732
11965
  parseMarkdownToSegments as a6,
11733
- placeFloating as a7,
11734
- pluralize as a8,
11735
- populateBubbleFromMessage as a9,
11736
- toolCallRenderer as aA,
11737
- toolRendererThatDrew as aB,
11738
- isMountedRenderer as aC,
11739
- renderingVersionOf as aD,
11740
- onRenderersChange as aE,
11741
- renderSourceList as aF,
11742
- mergeSegmentUpdate as aG,
11743
- toolNameOf as aH,
11744
- writeStreamedMarkdown as aI,
11745
- replaceHighlighted as aJ,
11746
- CheckpointStateWatcher as aK,
11747
- chatIdOf as aL,
11748
- stampSegmentActivity as aM,
11749
- stampSegmentOnInsert as aN,
11750
- stampSegmentOnUpdate as aO,
11751
- renumberSegments as aP,
11752
- openSegmentIds as aQ,
11753
- isTerminalStatus as aR,
11754
- adoptMessageSegments as aS,
11755
- APARTE_DERIVED_SEGMENTS as aT,
11756
- rememberConversationStatus as aU,
11757
- tellConversationStatus as aV,
11758
- conversationStatusOf as aW,
11759
- visibleReply as aX,
11760
- usageTokens as aY,
11761
- rootOf as aZ,
11762
- inRenderedContent as a_,
11763
- readableToAsyncIterable as aa,
11764
- registerDefaultRenderers as ab,
11765
- registerSegmentRenderer as ac,
11766
- releaseDeferredHydration as ad,
11767
- renderCitations as ae,
11768
- renderCodeLanguages as af,
11769
- requestUserInput as ag,
11770
- resolveConfig as ah,
11771
- revokeAttachmentUrls as ai,
11772
- runSubAgent as aj,
11773
- runWithConfig as ak,
11774
- segmentDuration as al,
11775
- segmentTiming as am,
11776
- setupSuggestionBlocks as an,
11777
- startSubAgent as ao,
11778
- subscribeConfigChange as ap,
11779
- toToolCallView as aq,
11780
- toolRefusal as ar,
11781
- unregisterSegmentRenderer as as,
11782
- uuid as at,
11783
- eventOrigin as au,
11784
- activeElementIn as av,
11785
- gateGlide as aw,
11786
- chatBoundaryOf as ax,
11787
- relabelCodeLanguages as ay,
11788
- relabelCitations as az,
11966
+ pluralize as a7,
11967
+ populateBubbleFromMessage as a8,
11968
+ readableToAsyncIterable as a9,
11969
+ renderingVersionOf as aA,
11970
+ renderSourceList as aB,
11971
+ mergeSegmentUpdate as aC,
11972
+ toolNameOf as aD,
11973
+ writeStreamedMarkdown as aE,
11974
+ replaceHighlighted as aF,
11975
+ toolRendererThatDrew as aG,
11976
+ activityRendererThatDrew as aH,
11977
+ CheckpointStateWatcher as aI,
11978
+ chatIdOf as aJ,
11979
+ stampSegmentActivity as aK,
11980
+ stampSegmentOnInsert as aL,
11981
+ stampSegmentOnUpdate as aM,
11982
+ renumberSegments as aN,
11983
+ openSegmentIds as aO,
11984
+ isTerminalStatus as aP,
11985
+ adoptMessageSegments as aQ,
11986
+ APARTE_DERIVED_SEGMENTS as aR,
11987
+ rememberConversationStatus as aS,
11988
+ tellConversationStatus as aT,
11989
+ conversationStatusOf as aU,
11990
+ visibleReply as aV,
11991
+ usageTokens as aW,
11992
+ inRenderedContent as aX,
11993
+ registerDefaultRenderers as aa,
11994
+ registerSegmentRenderer as ab,
11995
+ releaseDeferredHydration as ac,
11996
+ renderCitations as ad,
11997
+ renderCodeLanguages as ae,
11998
+ requestUserInput as af,
11999
+ resolveConfig as ag,
12000
+ revokeAttachmentUrls as ah,
12001
+ runSubAgent as ai,
12002
+ runWithConfig as aj,
12003
+ segmentDuration as ak,
12004
+ segmentTiming as al,
12005
+ setupSuggestionBlocks as am,
12006
+ startSubAgent as an,
12007
+ subscribeConfigChange as ao,
12008
+ toToolCallView as ap,
12009
+ toolRefusal as aq,
12010
+ unregisterSegmentRenderer as ar,
12011
+ uuid as as,
12012
+ gateGlide as at,
12013
+ chatBoundaryOf as au,
12014
+ relabelCodeLanguages as av,
12015
+ relabelCitations as aw,
12016
+ toolCallRenderer as ax,
12017
+ activityRenderer as ay,
12018
+ isMountedRenderer as az,
11789
12019
  APARTE_DEFAULT_BUBBLE_ACTIONS as b,
11790
12020
  APARTE_DEFAULT_HOST_HANDLERS as c,
11791
12021
  APARTE_DEFAULT_ICON_FALLBACKS as d,
@@ -11812,4 +12042,4 @@ export {
11812
12042
  collectRendererStyles as y,
11813
12043
  contentToText as z
11814
12044
  };
11815
- //# sourceMappingURL=defer-hydration-W4yhnyfc.js.map
12045
+ //# sourceMappingURL=defer-hydration-o5MFsc_Z.js.map