@aparte/core 0.25.0 → 0.27.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.
- package/dist/client/agent-runner.d.ts.map +1 -1
- package/dist/client/aparte-client.d.ts +37 -76
- package/dist/client/aparte-client.d.ts.map +1 -1
- package/dist/client/stream-adapter.d.ts.map +1 -1
- package/dist/client/wire-history.d.ts +78 -0
- package/dist/client/wire-history.d.ts.map +1 -1
- package/dist/components/bubble/aparte-chat-bubble.d.ts +90 -4
- package/dist/components/bubble/aparte-chat-bubble.d.ts.map +1 -1
- package/dist/components/bubble/bubble-sync.d.ts +5 -1
- package/dist/components/bubble/bubble-sync.d.ts.map +1 -1
- package/dist/components/bubble/checkpoint-separator.d.ts +40 -0
- package/dist/components/bubble/checkpoint-separator.d.ts.map +1 -0
- package/dist/components/composer/accepts-file.d.ts +10 -0
- package/dist/components/composer/accepts-file.d.ts.map +1 -0
- package/dist/components/composer/aparte-composer-add-attachment.d.ts +5 -1
- package/dist/components/composer/aparte-composer-add-attachment.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-attachments.d.ts +9 -4
- package/dist/components/composer/aparte-composer-attachments.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-input.d.ts.map +1 -1
- package/dist/components/context/aparte-context.d.ts +172 -25
- package/dist/components/context/aparte-context.d.ts.map +1 -1
- package/dist/components/elicitation/aparte-elicitation.d.ts +2 -2
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/launcher/aparte-launcher.d.ts +167 -0
- package/dist/components/launcher/aparte-launcher.d.ts.map +1 -0
- package/dist/components/launcher/index.d.ts +3 -0
- package/dist/components/launcher/index.d.ts.map +1 -0
- package/dist/components/viewport/aparte-chat-viewport.d.ts +7 -0
- package/dist/components/viewport/aparte-chat-viewport.d.ts.map +1 -1
- package/dist/config/aparte-config.d.ts +23 -1
- package/dist/config/aparte-config.d.ts.map +1 -1
- package/dist/config/error-renderer.d.ts +21 -10
- package/dist/config/error-renderer.d.ts.map +1 -1
- package/dist/config/icon-provider.d.ts +2 -0
- package/dist/config/icon-provider.d.ts.map +1 -1
- package/dist/config/locale.d.ts +85 -5
- package/dist/config/locale.d.ts.map +1 -1
- package/dist/context/checkpoint-state.d.ts +70 -0
- package/dist/context/checkpoint-state.d.ts.map +1 -0
- package/dist/context/checkpoint.d.ts +28 -0
- package/dist/context/checkpoint.d.ts.map +1 -0
- package/dist/context/measure.d.ts +148 -0
- package/dist/context/measure.d.ts.map +1 -0
- package/dist/context/restore.d.ts +24 -0
- package/dist/context/restore.d.ts.map +1 -0
- package/dist/conversations/conversation-controller.d.ts +13 -4
- package/dist/conversations/conversation-controller.d.ts.map +1 -1
- package/dist/conversations/conversation-manager.d.ts +6 -0
- package/dist/conversations/conversation-manager.d.ts.map +1 -1
- package/dist/custom-elements.json +13893 -11714
- package/dist/{defer-hydration-BwMqeRHq.js → defer-hydration-DSZE-bKi.js} +788 -269
- package/dist/defer-hydration-DSZE-bKi.js.map +1 -0
- package/dist/generated/element-attributes.d.ts +21 -3
- package/dist/generated/element-attributes.d.ts.map +1 -1
- package/dist/{glyphs-2bym5jl5.js → glyphs-DFp-825O.js} +33 -30
- package/dist/{glyphs-2bym5jl5.js.map → glyphs-DFp-825O.js.map} +1 -1
- package/dist/host/aparte-chat-host.d.ts +19 -2
- package/dist/host/aparte-chat-host.d.ts.map +1 -1
- package/dist/icons/extended.d.ts +2 -2
- package/dist/icons/extended.d.ts.map +1 -1
- package/dist/icons/glyphs.d.ts +3 -0
- package/dist/icons/glyphs.d.ts.map +1 -1
- package/dist/icons.js +29 -30
- package/dist/icons.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1140 -95
- package/dist/index.js.map +1 -1
- package/dist/index.node.d.ts +6 -2
- package/dist/index.node.d.ts.map +1 -1
- package/dist/index.node.js +33 -29
- package/dist/index.node.js.map +1 -1
- package/dist/interop/element-props.d.ts +1 -1
- package/dist/interop/element-props.d.ts.map +1 -1
- package/dist/renderers/segments/error.d.ts.map +1 -1
- package/dist/renderers/segments/tool-call.d.ts.map +1 -1
- package/dist/transport/agent-handler.d.ts.map +1 -1
- package/dist/transport/backend-handler.d.ts.map +1 -1
- package/dist/transport/types.d.ts +24 -4
- package/dist/transport/types.d.ts.map +1 -1
- package/dist/types/chat.d.ts +16 -1
- package/dist/types/chat.d.ts.map +1 -1
- package/dist/types/compactor.d.ts +104 -0
- package/dist/types/compactor.d.ts.map +1 -0
- package/dist/types/element-map.d.ts +2 -0
- package/dist/types/element-map.d.ts.map +1 -1
- package/dist/types/errors.d.ts +9 -0
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/event-map.d.ts +2 -0
- package/dist/types/event-map.d.ts.map +1 -1
- package/dist/types/events.d.ts +50 -3
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/model-provider.d.ts +3 -0
- package/dist/types/model-provider.d.ts.map +1 -1
- package/dist/types/models.d.ts +43 -3
- package/dist/types/models.d.ts.map +1 -1
- package/dist/types/segments.d.ts +13 -5
- package/dist/types/segments.d.ts.map +1 -1
- package/dist/types/tools.d.ts +6 -1
- package/dist/types/tools.d.ts.map +1 -1
- package/dist/utils/error-sentence.d.ts +21 -0
- package/dist/utils/error-sentence.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/defer-hydration-BwMqeRHq.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { K as deferHydrationOf,
|
|
2
|
-
import { A, a, b, c, d, f,
|
|
1
|
+
import { K as deferHydrationOf, aa as resolveConfig, ak as eventOrigin, al as activeElementIn, af as subscribeConfigChange, ac as runWithConfig, o as AparteElicitationAbortError, w as buildApprovalPanel, x as buildElicitationPanel, am as gateGlide, O as escapeAttr, an as chatBoundaryOf, ao as toolCallRenderer, ap as toolRendererThatDrew, t as aparteGlobalConfig, aq as isMountedRenderer, ar as renderingVersionOf, H as cssEscape, as as onRenderersChange, at as mergeSegmentUpdate, P as escapeHtml, $ as isSegmentSettled, au as writeStreamedMarkdown, _ as isSafeUrl, C as copyText, U as getSegmentRenderer, W as installDefaultRenderersOnce, r as AparteMessageRepository, av as CheckpointStateWatcher, aw as chatIdOf, ax as stampSegmentActivity, ay as stampSegmentOnInsert, az as stampSegmentOnUpdate, aA as renumberSegments, aB as openSegmentIds, aC as isTerminalStatus, aD as adoptMessageSegments, Y as isAwaitingReply, a4 as populateBubbleFromMessage, aj as uuid, ab as revokeAttachmentUrls, a3 as parseMarkdownToSegments, aE as APARTE_DERIVED_SEGMENTS, aF as rememberConversationStatus, aG as tellConversationStatus, aH as conversationStatusOf, e as APARTE_DEFAULT_LOCALE, aI as usageTokens, q as AparteErrorCode, a0 as measureContext, aJ as rootOf, g as APARTE_HOST_ATTR, X as installDialogTriggersOnce } from "./defer-hydration-DSZE-bKi.js";
|
|
2
|
+
import { A, a, b, c, d, f, h, i, j, k, l, m, n, p, s, u, v, y, z, B, D, E, F, G, I, J, L, M, N, Q, R, S, T, V, Z, a1, a2, a5, a6, a7, a8, a9, ad, ae, ag, ah, ai } from "./defer-hydration-DSZE-bKi.js";
|
|
3
3
|
function presenceOn(value) {
|
|
4
4
|
return value === "" ? true : Boolean(value);
|
|
5
5
|
}
|
|
@@ -1307,6 +1307,96 @@ deferHydrationOf(AparteChat);
|
|
|
1307
1307
|
if (!customElements.get("aparte-chat")) {
|
|
1308
1308
|
customElements.define("aparte-chat", AparteChat);
|
|
1309
1309
|
}
|
|
1310
|
+
const isStore = (candidate) => !!candidate && typeof candidate.getMessages === "function" && typeof candidate.updateMessage === "function";
|
|
1311
|
+
function storeOf(from) {
|
|
1312
|
+
const boundary = chatBoundaryOf(from);
|
|
1313
|
+
if (isStore(boundary)) return boundary;
|
|
1314
|
+
const viewport = from.closest("aparte-chat-viewport");
|
|
1315
|
+
return isStore(viewport) ? viewport : null;
|
|
1316
|
+
}
|
|
1317
|
+
function restoreContext(from, detail) {
|
|
1318
|
+
const store = storeOf(from);
|
|
1319
|
+
if (!store) return 0;
|
|
1320
|
+
const carrying = store.getMessages().filter((m2) => m2.contextSummary !== void 0).map((m2) => m2.id);
|
|
1321
|
+
for (const id of carrying) store.updateMessage(id, { contextSummary: void 0 });
|
|
1322
|
+
const done = { restored: true };
|
|
1323
|
+
if (detail.messageId) done.messageId = detail.messageId;
|
|
1324
|
+
if (detail.targetId) done.targetId = detail.targetId;
|
|
1325
|
+
window.dispatchEvent(new CustomEvent("aparte-compact-done", { detail: done }));
|
|
1326
|
+
return carrying.length;
|
|
1327
|
+
}
|
|
1328
|
+
function el$1(tag, className, text) {
|
|
1329
|
+
const node = document.createElement(tag);
|
|
1330
|
+
node.className = className;
|
|
1331
|
+
if (text !== void 0) node.textContent = text;
|
|
1332
|
+
return node;
|
|
1333
|
+
}
|
|
1334
|
+
function action(name, label) {
|
|
1335
|
+
const button = el$1("button", "aparte-btn aparte-btn--ghost aparte-btn--sm aparte-checkpoint__action", label);
|
|
1336
|
+
button.type = "button";
|
|
1337
|
+
button.setAttribute("data-checkpoint-action", name);
|
|
1338
|
+
return button;
|
|
1339
|
+
}
|
|
1340
|
+
function buildCheckpointSeparator(options) {
|
|
1341
|
+
const { kind, locale } = options;
|
|
1342
|
+
const root = el$1("div", "aparte-checkpoint");
|
|
1343
|
+
root.setAttribute("role", "group");
|
|
1344
|
+
root.setAttribute("aria-label", locale.checkpointGroup ?? "Context summary");
|
|
1345
|
+
root.setAttribute("data-state", kind);
|
|
1346
|
+
const row = el$1("div", "aparte-checkpoint__row aparte-divider aparte-divider--label");
|
|
1347
|
+
const label = el$1("div", "aparte-checkpoint__label");
|
|
1348
|
+
row.appendChild(label);
|
|
1349
|
+
root.appendChild(row);
|
|
1350
|
+
let sentence;
|
|
1351
|
+
if (kind === "done") {
|
|
1352
|
+
const n2 = options.count ?? 0;
|
|
1353
|
+
sentence = n2 === 1 ? locale.checkpointCountOne ?? "1 message summarised for the model" : (locale.checkpointCount ?? "{n} messages summarised for the model").replace("{n}", () => String(n2));
|
|
1354
|
+
} else if (kind === "legacy") {
|
|
1355
|
+
sentence = locale.checkpointLegacy ?? "Earlier messages were summarised";
|
|
1356
|
+
} else if (kind === "pending") {
|
|
1357
|
+
sentence = locale.checkpointPending ?? "Summarising the context…";
|
|
1358
|
+
} else {
|
|
1359
|
+
sentence = locale.checkpointFailed ?? "Couldn't summarise the context";
|
|
1360
|
+
}
|
|
1361
|
+
const text = el$1("span", "aparte-checkpoint__text", sentence);
|
|
1362
|
+
if (kind === "pending") {
|
|
1363
|
+
text.classList.add("aparte-shimmer");
|
|
1364
|
+
text.setAttribute("role", "status");
|
|
1365
|
+
} else if (kind === "failed") {
|
|
1366
|
+
text.setAttribute("role", "status");
|
|
1367
|
+
if (options.reason) {
|
|
1368
|
+
text.title = options.reason;
|
|
1369
|
+
text.appendChild(el$1("span", "aparte-sr-only", `: ${options.reason}`));
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
label.appendChild(text);
|
|
1373
|
+
if (kind === "done" || kind === "legacy") {
|
|
1374
|
+
if (options.confirming && kind === "done") {
|
|
1375
|
+
const confirm = el$1("span", "aparte-checkpoint__confirm");
|
|
1376
|
+
const question = el$1("span", "aparte-checkpoint__question", locale.checkpointRestoreConfirm ?? "Send the original messages to the model again?");
|
|
1377
|
+
question.id = `${options.summaryId}-question`;
|
|
1378
|
+
const yes = action("restore-confirm", locale.checkpointRestore ?? "Restore");
|
|
1379
|
+
yes.setAttribute("aria-describedby", question.id);
|
|
1380
|
+
confirm.append(question, yes, action("restore-cancel", locale.cancel ?? "Cancel"));
|
|
1381
|
+
label.appendChild(confirm);
|
|
1382
|
+
} else {
|
|
1383
|
+
const toggle = action("toggle", options.open ? locale.checkpointHide ?? "Hide summary" : locale.checkpointShow ?? "Show summary");
|
|
1384
|
+
toggle.setAttribute("aria-expanded", String(options.open));
|
|
1385
|
+
toggle.setAttribute("aria-controls", options.summaryId);
|
|
1386
|
+
label.appendChild(toggle);
|
|
1387
|
+
if (kind === "done") label.appendChild(action("restore", locale.checkpointRestore ?? "Restore"));
|
|
1388
|
+
}
|
|
1389
|
+
} else if (kind === "failed") {
|
|
1390
|
+
label.appendChild(action("retry", locale.retry ?? "Retry"));
|
|
1391
|
+
}
|
|
1392
|
+
if (kind === "done" || kind === "legacy") {
|
|
1393
|
+
const panel = el$1("div", "aparte-checkpoint__summary aparte-segment-content");
|
|
1394
|
+
panel.id = options.summaryId;
|
|
1395
|
+
if (!options.open) panel.hidden = true;
|
|
1396
|
+
root.appendChild(panel);
|
|
1397
|
+
}
|
|
1398
|
+
return root;
|
|
1399
|
+
}
|
|
1310
1400
|
let _warnedNoRenderer = false;
|
|
1311
1401
|
function warnMissingRenderer(type) {
|
|
1312
1402
|
if (_warnedNoRenderer) return;
|
|
@@ -1349,6 +1439,7 @@ function flushAvatarMarks() {
|
|
|
1349
1439
|
});
|
|
1350
1440
|
batch.forEach(([avatar], i2) => avatar.toggleAttribute("data-image", shown[i2]));
|
|
1351
1441
|
}
|
|
1442
|
+
let checkpointIds = 0;
|
|
1352
1443
|
class AparteChatBubble extends HTMLElement {
|
|
1353
1444
|
_contentEl = null;
|
|
1354
1445
|
_segmentsEl = null;
|
|
@@ -1362,6 +1453,23 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1362
1453
|
_role = "assistant";
|
|
1363
1454
|
_attachments = [];
|
|
1364
1455
|
_usage = null;
|
|
1456
|
+
_finishReason = null;
|
|
1457
|
+
/** The checkpoint this message carries: the separator above it is drawn from it. */
|
|
1458
|
+
_contextSummary = null;
|
|
1459
|
+
/**
|
|
1460
|
+
* This message is one an older compaction wrote (`compaction: true`), as the host told
|
|
1461
|
+
* us. `null` until told: the `data-kind="compaction"` attribute the viewport and the
|
|
1462
|
+
* wrappers stamp from the same flag answers meanwhile.
|
|
1463
|
+
*/
|
|
1464
|
+
_legacyCompaction = null;
|
|
1465
|
+
/** The summary panel under the separator is open. Kept here, not in the DOM, because a redraw rebuilds the DOM. */
|
|
1466
|
+
_checkpointOpen = false;
|
|
1467
|
+
/** Restore asked for confirmation and has not been answered. */
|
|
1468
|
+
_confirmingRestore = false;
|
|
1469
|
+
/** What the separator was last drawn from, so a re-sync that changes nothing leaves it (and a focused button) alone. */
|
|
1470
|
+
_checkpointDrawn = "";
|
|
1471
|
+
/** Names the separator's panel for `aria-controls`, unique on the page without needing a message id. */
|
|
1472
|
+
_checkpointId = `aparte-checkpoint-${++checkpointIds}`;
|
|
1365
1473
|
/** Cleanup returned by the avatar provider — called on disconnect/re-render. */
|
|
1366
1474
|
_avatarCleanup = null;
|
|
1367
1475
|
/** Whether the avatar slot holds what a provider drew, which goes when the provider does. */
|
|
@@ -1391,7 +1499,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1391
1499
|
*/
|
|
1392
1500
|
_editReturnAction = null;
|
|
1393
1501
|
static get observedAttributes() {
|
|
1394
|
-
return ["data-role", "content", "timestamp", "message-id", "streaming", "name"];
|
|
1502
|
+
return ["data-role", "content", "timestamp", "message-id", "streaming", "name", "data-checkpoint", "data-checkpoint-reason"];
|
|
1395
1503
|
}
|
|
1396
1504
|
constructor() {
|
|
1397
1505
|
super();
|
|
@@ -1406,6 +1514,9 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1406
1514
|
this._updateName();
|
|
1407
1515
|
this._updateLocalizedLabels();
|
|
1408
1516
|
this._updateWaiting();
|
|
1517
|
+
this._updateFinishNote();
|
|
1518
|
+
this._checkpointDrawn = "";
|
|
1519
|
+
this._updateCheckpoint();
|
|
1409
1520
|
this._renderAvatar();
|
|
1410
1521
|
this._redrawSegmentsWhoseRendererChanged();
|
|
1411
1522
|
this._relabelSegments();
|
|
@@ -1633,6 +1744,8 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1633
1744
|
this._offRenderers ??= onRenderersChange(this._onRenderersChange);
|
|
1634
1745
|
this.addEventListener("click", this._onBranchPickerClick);
|
|
1635
1746
|
this.addEventListener("click", this._onLinkClick);
|
|
1747
|
+
this.addEventListener("click", this._onCheckpointClick);
|
|
1748
|
+
this.addEventListener("keydown", this._onCheckpointKeydown);
|
|
1636
1749
|
}
|
|
1637
1750
|
/**
|
|
1638
1751
|
* The boundary above this bubble changed — under every wrapper the chat's own config is
|
|
@@ -1671,6 +1784,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1671
1784
|
this._updateAttachments();
|
|
1672
1785
|
this._updateTimestamp(this.getAttribute("timestamp"));
|
|
1673
1786
|
this._updateBranchPicker();
|
|
1787
|
+
this._updateCheckpoint();
|
|
1674
1788
|
}
|
|
1675
1789
|
disconnectedCallback() {
|
|
1676
1790
|
window.removeEventListener("aparte-config-change", this._onConfigChange);
|
|
@@ -1678,6 +1792,8 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1678
1792
|
this._offRenderers = null;
|
|
1679
1793
|
this.removeEventListener("click", this._onBranchPickerClick);
|
|
1680
1794
|
this.removeEventListener("click", this._onLinkClick);
|
|
1795
|
+
this.removeEventListener("click", this._onCheckpointClick);
|
|
1796
|
+
this.removeEventListener("keydown", this._onCheckpointKeydown);
|
|
1681
1797
|
if (this._avatarCleanup) {
|
|
1682
1798
|
try {
|
|
1683
1799
|
this._avatarCleanup();
|
|
@@ -1704,6 +1820,12 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1704
1820
|
case "timestamp":
|
|
1705
1821
|
this._updateTimestamp(newValue);
|
|
1706
1822
|
break;
|
|
1823
|
+
case "data-checkpoint":
|
|
1824
|
+
this._updateCheckpoint();
|
|
1825
|
+
break;
|
|
1826
|
+
case "data-checkpoint-reason":
|
|
1827
|
+
if (this.getAttribute("data-checkpoint") === "failed") this._updateCheckpoint();
|
|
1828
|
+
break;
|
|
1707
1829
|
case "streaming":
|
|
1708
1830
|
this._updateStreaming(newValue !== null && newValue !== "false");
|
|
1709
1831
|
break;
|
|
@@ -1853,6 +1975,38 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1853
1975
|
this._usage = usage ?? null;
|
|
1854
1976
|
this._updateActionBar();
|
|
1855
1977
|
}
|
|
1978
|
+
/**
|
|
1979
|
+
* Say why the model stopped writing this reply (assistant only).
|
|
1980
|
+
*
|
|
1981
|
+
* Only `'length'` draws anything: a quiet note after the content that the reply was cut
|
|
1982
|
+
* off, because otherwise a truncated answer reads as a finished one. Every other reason
|
|
1983
|
+
* is the ordinary end of a turn and says nothing. The note waits for the turn to settle.
|
|
1984
|
+
*/
|
|
1985
|
+
setFinishReason(reason) {
|
|
1986
|
+
this._finishReason = reason ?? null;
|
|
1987
|
+
this._updateFinishNote();
|
|
1988
|
+
}
|
|
1989
|
+
/**
|
|
1990
|
+
* Say that the messages before this one were summarised for the model, or that they no
|
|
1991
|
+
* longer are (`null`).
|
|
1992
|
+
*
|
|
1993
|
+
* Draws, or removes, the separator above the message: "{n} messages summarised for the
|
|
1994
|
+
* model", with Show summary and Restore. The separator sits OUTSIDE `.aparte-message`
|
|
1995
|
+
* and inside this element, so it is not part of the message's frame and survives the
|
|
1996
|
+
* frame being drawn again. `legacy: true` says the message is itself the summary an
|
|
1997
|
+
* older compaction wrote (`compaction: true`): it is replaced by the separator, which
|
|
1998
|
+
* then has no count and no Restore. Omit `legacy` to leave what the host last said (or
|
|
1999
|
+
* the `data-kind="compaction"` attribute) in force.
|
|
2000
|
+
*/
|
|
2001
|
+
setContextSummary(summary, options) {
|
|
2002
|
+
this._contextSummary = summary ?? null;
|
|
2003
|
+
if (options?.legacy !== void 0) this._legacyCompaction = options.legacy;
|
|
2004
|
+
if (!this._contextSummary) {
|
|
2005
|
+
this._confirmingRestore = false;
|
|
2006
|
+
if (!this._isLegacyCompaction()) this._checkpointOpen = false;
|
|
2007
|
+
}
|
|
2008
|
+
this._updateCheckpoint();
|
|
2009
|
+
}
|
|
1856
2010
|
/**
|
|
1857
2011
|
* Update the branch picker UI for tree-based navigation.
|
|
1858
2012
|
* The viewport calls this after a branch switch or re-render.
|
|
@@ -1891,7 +2045,170 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1891
2045
|
this._updateAttachments();
|
|
1892
2046
|
this._updateWaiting();
|
|
1893
2047
|
}
|
|
2048
|
+
if ("finishReason" in updates) this.setFinishReason(updates.finishReason);
|
|
2049
|
+
if ("contextSummary" in updates || "compaction" in updates) {
|
|
2050
|
+
this.setContextSummary(
|
|
2051
|
+
"contextSummary" in updates ? updates.contextSummary : this._contextSummary,
|
|
2052
|
+
"compaction" in updates ? { legacy: updates.compaction === true } : void 0
|
|
2053
|
+
);
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
/**
|
|
2057
|
+
* Draw, or remove, the note under a reply cut off at the model's length limit.
|
|
2058
|
+
*
|
|
2059
|
+
* Created here rather than in the shell markup: a custom shell written from the contract
|
|
2060
|
+
* has no such region, and the note is only ever wanted next to the content it qualifies.
|
|
2061
|
+
* A shell with no content region simply shows none (the same null-guarded degradation as
|
|
2062
|
+
* the other regions).
|
|
2063
|
+
*/
|
|
2064
|
+
_updateFinishNote() {
|
|
2065
|
+
const show = this._finishReason === "length" && !this._streaming && this._role !== "user";
|
|
2066
|
+
let note = this.querySelector(".aparte-finish-note");
|
|
2067
|
+
if (!show) {
|
|
2068
|
+
note?.remove();
|
|
2069
|
+
return;
|
|
2070
|
+
}
|
|
2071
|
+
if (!note) {
|
|
2072
|
+
const region = this.querySelector(".aparte-message-content");
|
|
2073
|
+
if (!region) return;
|
|
2074
|
+
note = document.createElement("div");
|
|
2075
|
+
note.className = "aparte-finish-note";
|
|
2076
|
+
region.after(note);
|
|
2077
|
+
}
|
|
2078
|
+
note.textContent = this._cfg.getLocale().responseCutOff ?? "Cut off at the model's length limit.";
|
|
2079
|
+
}
|
|
2080
|
+
/** This message was written by an older compaction, as the host said or as its `data-kind` stamp says. */
|
|
2081
|
+
_isLegacyCompaction() {
|
|
2082
|
+
return this._legacyCompaction ?? this.getAttribute("data-kind") === "compaction";
|
|
2083
|
+
}
|
|
2084
|
+
/**
|
|
2085
|
+
* What the separator should say, or `null` for none. A compaction in progress or
|
|
2086
|
+
* failed outranks what the message already carries: it is what is happening now.
|
|
2087
|
+
*/
|
|
2088
|
+
_checkpointKind() {
|
|
2089
|
+
const run = this.getAttribute("data-checkpoint");
|
|
2090
|
+
if (run === "pending" || run === "failed") return run;
|
|
2091
|
+
if (this._contextSummary) return "done";
|
|
2092
|
+
return this._isLegacyCompaction() ? "legacy" : null;
|
|
1894
2093
|
}
|
|
2094
|
+
/** The text the summary panel shows: the checkpoint's summary, or the older compaction message itself. */
|
|
2095
|
+
_checkpointSummaryText() {
|
|
2096
|
+
return this._contextSummary ? this._contextSummary.summary : this._content;
|
|
2097
|
+
}
|
|
2098
|
+
/**
|
|
2099
|
+
* Draw the separator above the message, or take it off.
|
|
2100
|
+
*
|
|
2101
|
+
* Written into the light DOM as the FIRST child of the bubble, outside `.aparte-message`:
|
|
2102
|
+
* a custom shell roots at that class and is free to be anything, and the separator is not
|
|
2103
|
+
* its to carry. Drawn from `_render` (so every frame gets it) and from every setter that
|
|
2104
|
+
* changes what it says. A re-sync that changes nothing — the framework host calls this on
|
|
2105
|
+
* every render of every bubble — finds the same signature and the element in place and
|
|
2106
|
+
* leaves both alone, so a keyboard user's focus and a scrolled summary are not lost to a
|
|
2107
|
+
* rebuild; one that does change something rebuilds it and puts the focus back on the
|
|
2108
|
+
* button that had it (or on `focus`, which a click that swaps the buttons names).
|
|
2109
|
+
*
|
|
2110
|
+
* A message an older compaction wrote is marked `data-superseded` on its own row: it
|
|
2111
|
+
* stays in the DOM and does not paint (bubble.css), the separator speaking for it.
|
|
2112
|
+
*/
|
|
2113
|
+
_updateCheckpoint(focus) {
|
|
2114
|
+
const frame = this.querySelector(".aparte-message");
|
|
2115
|
+
if (!frame) return;
|
|
2116
|
+
const kind = this._checkpointKind();
|
|
2117
|
+
frame.toggleAttribute("data-superseded", this._isLegacyCompaction() && !this._contextSummary);
|
|
2118
|
+
const current = this.querySelector(":scope > .aparte-checkpoint");
|
|
2119
|
+
if (!kind) {
|
|
2120
|
+
const holdsFocus = current && document.activeElement && current.contains(document.activeElement);
|
|
2121
|
+
current?.remove();
|
|
2122
|
+
this._checkpointDrawn = "";
|
|
2123
|
+
if (holdsFocus) {
|
|
2124
|
+
if (!frame.hasAttribute("tabindex")) frame.setAttribute("tabindex", "-1");
|
|
2125
|
+
frame.focus({ preventScroll: true });
|
|
2126
|
+
}
|
|
2127
|
+
return;
|
|
2128
|
+
}
|
|
2129
|
+
const reason = this.getAttribute("data-checkpoint-reason") ?? "";
|
|
2130
|
+
const summary = this._checkpointSummaryText();
|
|
2131
|
+
const signature = JSON.stringify([
|
|
2132
|
+
kind,
|
|
2133
|
+
this._contextSummary?.count,
|
|
2134
|
+
this._contextSummary?.createdAt,
|
|
2135
|
+
reason,
|
|
2136
|
+
this._checkpointOpen,
|
|
2137
|
+
this._confirmingRestore,
|
|
2138
|
+
this._checkpointOpen ? summary : ""
|
|
2139
|
+
]);
|
|
2140
|
+
if (current && !focus && signature === this._checkpointDrawn) return;
|
|
2141
|
+
const active = document.activeElement;
|
|
2142
|
+
const hadFocus = current && active && current.contains(active) ? active.getAttribute("data-checkpoint-action") : null;
|
|
2143
|
+
const next = buildCheckpointSeparator({
|
|
2144
|
+
kind,
|
|
2145
|
+
count: this._contextSummary?.count,
|
|
2146
|
+
reason,
|
|
2147
|
+
open: this._checkpointOpen,
|
|
2148
|
+
confirming: this._confirmingRestore,
|
|
2149
|
+
summaryId: this._checkpointId,
|
|
2150
|
+
locale: this._cfg.getLocale()
|
|
2151
|
+
});
|
|
2152
|
+
if (this._checkpointOpen && (kind === "done" || kind === "legacy")) {
|
|
2153
|
+
const panel = next.querySelector(".aparte-checkpoint__summary");
|
|
2154
|
+
if (panel) panel.innerHTML = this._cfg.renderMarkdown(summary);
|
|
2155
|
+
}
|
|
2156
|
+
if (current) current.replaceWith(next);
|
|
2157
|
+
else this.prepend(next);
|
|
2158
|
+
this._checkpointDrawn = signature;
|
|
2159
|
+
const wanted = focus ?? hadFocus;
|
|
2160
|
+
if (wanted) next.querySelector(`[data-checkpoint-action="${cssEscape(wanted)}"]`)?.focus();
|
|
2161
|
+
}
|
|
2162
|
+
/**
|
|
2163
|
+
* The separator's buttons. One delegated listener on the bubble, for the reason the branch
|
|
2164
|
+
* picker has one: the separator is rebuilt on every change, and a listener per button would
|
|
2165
|
+
* be lost with it.
|
|
2166
|
+
*/
|
|
2167
|
+
_onCheckpointClick = (event) => {
|
|
2168
|
+
const button = event.target?.closest?.("[data-checkpoint-action]");
|
|
2169
|
+
const separator = button?.closest(".aparte-checkpoint");
|
|
2170
|
+
if (!button || !separator || separator.parentElement !== this) return;
|
|
2171
|
+
switch (button.getAttribute("data-checkpoint-action")) {
|
|
2172
|
+
case "toggle":
|
|
2173
|
+
this._checkpointOpen = !this._checkpointOpen;
|
|
2174
|
+
this._updateCheckpoint("toggle");
|
|
2175
|
+
break;
|
|
2176
|
+
case "restore":
|
|
2177
|
+
this._confirmingRestore = true;
|
|
2178
|
+
this._updateCheckpoint("restore-confirm");
|
|
2179
|
+
break;
|
|
2180
|
+
case "restore-cancel":
|
|
2181
|
+
this._confirmingRestore = false;
|
|
2182
|
+
this._updateCheckpoint("restore");
|
|
2183
|
+
break;
|
|
2184
|
+
case "restore-confirm": {
|
|
2185
|
+
this._confirmingRestore = false;
|
|
2186
|
+
const messageId = this.getAttribute("message-id") ?? void 0;
|
|
2187
|
+
restoreContext(this, { messageId, targetId: this._resolveTargetId() });
|
|
2188
|
+
this.setContextSummary(null);
|
|
2189
|
+
break;
|
|
2190
|
+
}
|
|
2191
|
+
case "retry": {
|
|
2192
|
+
const targetId = this._resolveTargetId();
|
|
2193
|
+
const compactor = this._cfg.getCompactor();
|
|
2194
|
+
if (compactor) {
|
|
2195
|
+
void compactor.compact({ target: chatBoundaryOf(this), ...targetId ? { targetId } : {}, force: true, reason: "retry" });
|
|
2196
|
+
} else {
|
|
2197
|
+
window.dispatchEvent(new CustomEvent("aparte-compact", { detail: { targetId } }));
|
|
2198
|
+
}
|
|
2199
|
+
break;
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
};
|
|
2203
|
+
/** Escape withdraws Restore's question, the way it closes every other inline prompt here. */
|
|
2204
|
+
_onCheckpointKeydown = (event) => {
|
|
2205
|
+
if (event.key !== "Escape" || !this._confirmingRestore) return;
|
|
2206
|
+
const separator = event.target?.closest?.(".aparte-checkpoint");
|
|
2207
|
+
if (!separator || separator.parentElement !== this) return;
|
|
2208
|
+
event.stopPropagation();
|
|
2209
|
+
this._confirmingRestore = false;
|
|
2210
|
+
this._updateCheckpoint("restore");
|
|
2211
|
+
};
|
|
1895
2212
|
// ─────────────────────────────────────────────────────────────────────────
|
|
1896
2213
|
// Private Methods
|
|
1897
2214
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -2071,6 +2388,8 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2071
2388
|
this._renderAvatar();
|
|
2072
2389
|
if (this._streaming) this._updateStreaming(true);
|
|
2073
2390
|
this._updateWaiting();
|
|
2391
|
+
this._updateFinishNote();
|
|
2392
|
+
this._updateCheckpoint();
|
|
2074
2393
|
}
|
|
2075
2394
|
/**
|
|
2076
2395
|
* Show the built-in waiting indicator while this bubble is in flight and has
|
|
@@ -2302,18 +2621,18 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2302
2621
|
const customAttachment = this._cfg.getAttachmentRenderer?.();
|
|
2303
2622
|
if (customAttachment) {
|
|
2304
2623
|
this._attachmentsEl.replaceChildren();
|
|
2305
|
-
for (const
|
|
2306
|
-
const el2 = segmentRenderResultToElement(runWithConfig(this._cfg, () => customAttachment(
|
|
2624
|
+
for (const a3 of this._attachments) {
|
|
2625
|
+
const el2 = segmentRenderResultToElement(runWithConfig(this._cfg, () => customAttachment(a3)));
|
|
2307
2626
|
if (el2) this._attachmentsEl.appendChild(el2);
|
|
2308
2627
|
}
|
|
2309
2628
|
return;
|
|
2310
2629
|
}
|
|
2311
|
-
this._attachmentsEl.innerHTML = this._attachments.map((
|
|
2312
|
-
const name = escapeHtml(
|
|
2313
|
-
if (
|
|
2314
|
-
return `<div class="aparte-thumbnail aparte-thumb aparte-thumb--image" title="${name}"><img class="aparte-thumbnail__image" src="${escapeHtml(
|
|
2630
|
+
this._attachmentsEl.innerHTML = this._attachments.map((a3) => {
|
|
2631
|
+
const name = escapeHtml(a3.name);
|
|
2632
|
+
if (a3.type.startsWith("image/") && this._isShowableUrl(a3.url)) {
|
|
2633
|
+
return `<div class="aparte-thumbnail aparte-thumb aparte-thumb--image" title="${name}"><img class="aparte-thumbnail__image" src="${escapeHtml(a3.url)}" alt="${name}" loading="lazy" /><span class="aparte-thumb__name">${name}</span></div>`;
|
|
2315
2634
|
}
|
|
2316
|
-
return `<div class="aparte-thumbnail aparte-thumb aparte-thumb--file" title="${name}"><span class="aparte-thumbnail__label">${escapeHtml(this._fileExt(
|
|
2635
|
+
return `<div class="aparte-thumbnail aparte-thumb aparte-thumb--file" title="${name}"><span class="aparte-thumbnail__label">${escapeHtml(this._fileExt(a3.name))}</span><span class="aparte-thumb__name">${name}</span></div>`;
|
|
2317
2636
|
}).join("");
|
|
2318
2637
|
if (!this._cfg.getHostHandlers().attachmentPreview) return;
|
|
2319
2638
|
this._attachmentsEl.querySelectorAll(".aparte-thumb--image").forEach((tile) => {
|
|
@@ -2469,7 +2788,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2469
2788
|
/**
|
|
2470
2789
|
* What the copy action copies: the reply, not the reasoning. A `thinking` segment is
|
|
2471
2790
|
* the model's scratchpad, and the client already keeps it out of the history it sends
|
|
2472
|
-
* back (`
|
|
2791
|
+
* back (`segmentsToWireText`) for the same reason — copying it along with the answer
|
|
2473
2792
|
* pasted a paragraph of deliberation above every reply, which no assistant on the
|
|
2474
2793
|
* market does. Segments with no `content` (a tool call) contribute nothing, so a
|
|
2475
2794
|
* turn made only of those copies as `''` — and the action bar reads this to decide
|
|
@@ -2499,14 +2818,14 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2499
2818
|
const buttons = [];
|
|
2500
2819
|
if (this._role === "user") {
|
|
2501
2820
|
if (config.user) {
|
|
2502
|
-
for (const
|
|
2821
|
+
for (const a3 of config.user) buttons.push(this._actionButtonHtml(a3, icons, locale));
|
|
2503
2822
|
} else {
|
|
2504
2823
|
if (config.copy) buttons.push(this._actionButtonHtml("copy", icons, locale));
|
|
2505
2824
|
if (config.edit) buttons.push(this._actionButtonHtml("edit", icons, locale));
|
|
2506
2825
|
}
|
|
2507
2826
|
} else if (this._role === "assistant") {
|
|
2508
2827
|
if (config.assistant) {
|
|
2509
|
-
for (const
|
|
2828
|
+
for (const a3 of config.assistant) buttons.push(this._actionButtonHtml(a3, icons, locale));
|
|
2510
2829
|
} else {
|
|
2511
2830
|
if (config.copy) buttons.push(this._actionButtonHtml("copy", icons, locale));
|
|
2512
2831
|
if (config.retry) buttons.push(this._actionButtonHtml("retry", icons, locale));
|
|
@@ -2602,22 +2921,22 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2602
2921
|
/** Append the registered custom action buttons for this bubble's role. */
|
|
2603
2922
|
_appendCustomActions() {
|
|
2604
2923
|
if (!this._actionBarEl) return;
|
|
2605
|
-
for (const
|
|
2606
|
-
const roles =
|
|
2924
|
+
for (const a3 of this._cfg.getActions("bubble")) {
|
|
2925
|
+
const roles = a3.bubble?.roles ?? ["user", "assistant"];
|
|
2607
2926
|
if (!roles.includes(this._role)) continue;
|
|
2608
2927
|
const btn = document.createElement("button");
|
|
2609
2928
|
btn.type = "button";
|
|
2610
2929
|
btn.className = "aparte-btn aparte-btn--icon aparte-btn--sm aparte-action-btn aparte-action-custom";
|
|
2611
|
-
btn.dataset["action"] = `custom:${
|
|
2612
|
-
btn.setAttribute("aria-label",
|
|
2613
|
-
btn.setAttribute("title",
|
|
2614
|
-
btn.innerHTML =
|
|
2930
|
+
btn.dataset["action"] = `custom:${a3.id}`;
|
|
2931
|
+
btn.setAttribute("aria-label", a3.label);
|
|
2932
|
+
btn.setAttribute("title", a3.label);
|
|
2933
|
+
btn.innerHTML = a3.icon.startsWith("<") ? a3.icon : this._cfg.getIcon(a3.icon) ?? a3.iconFallback ?? "";
|
|
2615
2934
|
this._actionBarEl.appendChild(btn);
|
|
2616
2935
|
}
|
|
2617
2936
|
}
|
|
2618
2937
|
/** Build the `<button>` HTML for a single named action (shared by flag + per-role rendering). */
|
|
2619
|
-
_actionButtonHtml(
|
|
2620
|
-
switch (
|
|
2938
|
+
_actionButtonHtml(action2, icons, locale) {
|
|
2939
|
+
switch (action2) {
|
|
2621
2940
|
case "copy": {
|
|
2622
2941
|
const l2 = locale.copy ?? "Copy";
|
|
2623
2942
|
return `<button type="button" class="aparte-btn aparte-btn--icon aparte-btn--sm aparte-action-btn aparte-action-copy" data-action="copy" aria-label="${escapeAttr(l2)}" title="${escapeAttr(l2)}">${icons.copy()}</button>`;
|
|
@@ -2661,10 +2980,10 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2661
2980
|
}
|
|
2662
2981
|
_handleActionClick(e) {
|
|
2663
2982
|
const btn = e.currentTarget;
|
|
2664
|
-
const
|
|
2983
|
+
const action2 = btn.dataset["action"];
|
|
2665
2984
|
const messageId = this.getAttribute("message-id");
|
|
2666
|
-
if (
|
|
2667
|
-
const actionId =
|
|
2985
|
+
if (action2?.startsWith("custom:") && messageId) {
|
|
2986
|
+
const actionId = action2.slice("custom:".length);
|
|
2668
2987
|
const detail = {
|
|
2669
2988
|
actionId,
|
|
2670
2989
|
zone: "bubble",
|
|
@@ -2680,7 +2999,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2680
2999
|
this._cfg.getActions("bubble").find((x) => x.id === actionId)?.onClick?.(e);
|
|
2681
3000
|
return;
|
|
2682
3001
|
}
|
|
2683
|
-
switch (
|
|
3002
|
+
switch (action2) {
|
|
2684
3003
|
case "copy": {
|
|
2685
3004
|
const text = this._copyableText();
|
|
2686
3005
|
const icons = this._cfg.getIconProvider();
|
|
@@ -2729,7 +3048,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2729
3048
|
case "feedback-positive":
|
|
2730
3049
|
case "feedback-negative": {
|
|
2731
3050
|
if (!messageId) break;
|
|
2732
|
-
const value =
|
|
3051
|
+
const value = action2 === "feedback-positive" ? "positive" : "negative";
|
|
2733
3052
|
btn.setAttribute("data-submitted", "");
|
|
2734
3053
|
const detail = { messageId, value };
|
|
2735
3054
|
this.dispatchEvent(new CustomEvent("aparte-feedback", {
|
|
@@ -2857,6 +3176,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2857
3176
|
}
|
|
2858
3177
|
}
|
|
2859
3178
|
this._updateWaiting();
|
|
3179
|
+
this._updateFinishNote();
|
|
2860
3180
|
if (wasStreaming && !streaming) this._updateContent();
|
|
2861
3181
|
if (wasStreaming && !streaming && this._segments.length > 0) this._redrawIfStale();
|
|
2862
3182
|
}
|
|
@@ -3151,6 +3471,13 @@ class AparteChatViewport extends HTMLElement {
|
|
|
3151
3471
|
/** Last `--aparte-transcript-inset` written on the host, in px — same write-on-change rule. */
|
|
3152
3472
|
_transcriptInset = -1;
|
|
3153
3473
|
_boundResetHandler = null;
|
|
3474
|
+
/**
|
|
3475
|
+
* Marks the bubble a compaction is writing its checkpoint onto (`data-checkpoint`). The
|
|
3476
|
+
* vanilla viewport's job: under a wrapper the transcript is the framework's, and the
|
|
3477
|
+
* host answers for it instead (`active` below).
|
|
3478
|
+
*/
|
|
3479
|
+
_checkpointState = null;
|
|
3480
|
+
_stopCheckpointState = null;
|
|
3154
3481
|
/**
|
|
3155
3482
|
* When true, _reRenderActivePath() only dispatches aparte-path-changed without
|
|
3156
3483
|
* touching the DOM. Set via setFrameworkManagedDOM(true) when a framework
|
|
@@ -3220,6 +3547,16 @@ class AparteChatViewport extends HTMLElement {
|
|
|
3220
3547
|
this._boundResetHandler = () => this.clearAll();
|
|
3221
3548
|
window.addEventListener("aparte-reset", this._boundResetHandler);
|
|
3222
3549
|
window.addEventListener("aparte-config-change", this._onConfigChange);
|
|
3550
|
+
this._checkpointState ??= new CheckpointStateWatcher({
|
|
3551
|
+
// A bare `<aparte-chat-viewport id="…">` with no named host around it is its own
|
|
3552
|
+
// chat: the client names its events with that id (`_targetIdOf` falls back to the
|
|
3553
|
+
// element's own), so the watcher answers to it too, or every event is someone else's.
|
|
3554
|
+
ownId: () => chatIdOf(this) ?? (this.id || void 0),
|
|
3555
|
+
bubbleOf: (id) => this.querySelector(`aparte-chat-bubble[message-id="${cssEscape(id)}"]`),
|
|
3556
|
+
owns: (id) => !!this.getMessage(id),
|
|
3557
|
+
active: () => !this._frameworkManagedDOM
|
|
3558
|
+
});
|
|
3559
|
+
this._stopCheckpointState ??= this._checkpointState.start();
|
|
3223
3560
|
}
|
|
3224
3561
|
/**
|
|
3225
3562
|
* A locale switch changes the reading direction, and `dir` follows it, so a chat
|
|
@@ -3276,6 +3613,8 @@ class AparteChatViewport extends HTMLElement {
|
|
|
3276
3613
|
window.removeEventListener("aparte-reset", this._boundResetHandler);
|
|
3277
3614
|
this._boundResetHandler = null;
|
|
3278
3615
|
}
|
|
3616
|
+
this._stopCheckpointState?.();
|
|
3617
|
+
this._stopCheckpointState = null;
|
|
3279
3618
|
this._cleanup();
|
|
3280
3619
|
}
|
|
3281
3620
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
@@ -3448,10 +3787,10 @@ class AparteChatViewport extends HTMLElement {
|
|
|
3448
3787
|
this._notifyBubble(messageId, "addSegment", stamped);
|
|
3449
3788
|
this._autoScroll();
|
|
3450
3789
|
}
|
|
3451
|
-
updateSegment(
|
|
3790
|
+
updateSegment(a3, b2, c2) {
|
|
3452
3791
|
const clientForm = c2 === void 0 && typeof b2 === "object";
|
|
3453
|
-
const messageId = clientForm ? this._activeMessageId() :
|
|
3454
|
-
const segmentId = clientForm ?
|
|
3792
|
+
const messageId = clientForm ? this._activeMessageId() : a3;
|
|
3793
|
+
const segmentId = clientForm ? a3 : b2;
|
|
3455
3794
|
const updates = clientForm ? b2 : c2;
|
|
3456
3795
|
if (!messageId) return;
|
|
3457
3796
|
const message = this._repo.getMessageById(messageId);
|
|
@@ -3464,10 +3803,10 @@ class AparteChatViewport extends HTMLElement {
|
|
|
3464
3803
|
this._notifyBubble(messageId, "updateSegment", { segmentId, updates: stamped });
|
|
3465
3804
|
}
|
|
3466
3805
|
}
|
|
3467
|
-
removeSegment(
|
|
3806
|
+
removeSegment(a3, b2) {
|
|
3468
3807
|
const clientForm = b2 === void 0;
|
|
3469
|
-
const messageId = clientForm ? this._activeMessageId() :
|
|
3470
|
-
const segmentId = clientForm ?
|
|
3808
|
+
const messageId = clientForm ? this._activeMessageId() : a3;
|
|
3809
|
+
const segmentId = clientForm ? a3 : b2;
|
|
3471
3810
|
if (!messageId || !segmentId) return;
|
|
3472
3811
|
const message = this._repo.getMessageById(messageId);
|
|
3473
3812
|
if (message?.segments) {
|
|
@@ -3818,6 +4157,7 @@ class AparteChatViewport extends HTMLElement {
|
|
|
3818
4157
|
this._setSpacerHeight(0);
|
|
3819
4158
|
this._isAutoScrollEnabled = true;
|
|
3820
4159
|
this._updateScrollButton();
|
|
4160
|
+
this._checkpointState?.clear();
|
|
3821
4161
|
this.dispatchEvent(new CustomEvent("aparte-reset-done", { bubbles: true, composed: true }));
|
|
3822
4162
|
}
|
|
3823
4163
|
/**
|
|
@@ -3893,12 +4233,12 @@ class AparteChatViewport extends HTMLElement {
|
|
|
3893
4233
|
this._repo.addOrUpdateMessage(this._repo.headId, message);
|
|
3894
4234
|
return message;
|
|
3895
4235
|
}
|
|
3896
|
-
_notifyBubble(messageId,
|
|
4236
|
+
_notifyBubble(messageId, action2, payload, segmentId) {
|
|
3897
4237
|
const bubble = this.querySelector(
|
|
3898
4238
|
`aparte-chat-bubble[message-id="${cssEscape(messageId)}"], [data-aparte-bubble][message-id="${cssEscape(messageId)}"]`
|
|
3899
4239
|
);
|
|
3900
4240
|
if (!bubble) return;
|
|
3901
|
-
switch (
|
|
4241
|
+
switch (action2) {
|
|
3902
4242
|
case "appendToken":
|
|
3903
4243
|
bubble.appendToken?.(payload);
|
|
3904
4244
|
break;
|
|
@@ -3921,7 +4261,7 @@ class AparteChatViewport extends HTMLElement {
|
|
|
3921
4261
|
break;
|
|
3922
4262
|
case "update": {
|
|
3923
4263
|
const updates = payload;
|
|
3924
|
-
const renderable = ["status", "segments", "content", "attachments", "usage"];
|
|
4264
|
+
const renderable = ["status", "segments", "content", "attachments", "usage", "finishReason", "contextSummary", "compaction"];
|
|
3925
4265
|
if (renderable.some((key) => key in updates)) {
|
|
3926
4266
|
bubble.updateMessage?.(payload);
|
|
3927
4267
|
}
|
|
@@ -3972,6 +4312,7 @@ class AparteChatViewport extends HTMLElement {
|
|
|
3972
4312
|
}
|
|
3973
4313
|
this._dispatchPathChanged(activeMessages, siblingsInfo);
|
|
3974
4314
|
this._syncBusy();
|
|
4315
|
+
this._checkpointState?.reapply();
|
|
3975
4316
|
this._recalculateSpacer();
|
|
3976
4317
|
}
|
|
3977
4318
|
_dispatchPathChanged(messages, siblings) {
|
|
@@ -5115,6 +5456,13 @@ deferHydrationOf(AparteComposer);
|
|
|
5115
5456
|
if (!customElements.get("aparte-composer")) {
|
|
5116
5457
|
customElements.define("aparte-composer", AparteComposer);
|
|
5117
5458
|
}
|
|
5459
|
+
function acceptsFile(accept, file) {
|
|
5460
|
+
const tokens = (accept ?? "").split(",").map((token) => token.trim().toLowerCase()).filter(Boolean);
|
|
5461
|
+
if (tokens.length === 0) return true;
|
|
5462
|
+
const name = file.name.toLowerCase();
|
|
5463
|
+
const type = file.type.toLowerCase();
|
|
5464
|
+
return tokens.some((token) => token.startsWith(".") ? name.endsWith(token) : token.endsWith("/*") ? type.startsWith(token.slice(0, -1)) : type === token);
|
|
5465
|
+
}
|
|
5118
5466
|
class AparteComposerInput extends HTMLElement {
|
|
5119
5467
|
_editor = null;
|
|
5120
5468
|
_maxHeight = 200;
|
|
@@ -5306,8 +5654,9 @@ class AparteComposerInput extends HTMLElement {
|
|
|
5306
5654
|
const cd = e.clipboardData;
|
|
5307
5655
|
if (!cd) return;
|
|
5308
5656
|
const root = this._getRoot();
|
|
5309
|
-
const
|
|
5310
|
-
|
|
5657
|
+
const picker = root?.querySelector("aparte-composer-add-attachment");
|
|
5658
|
+
const imageFile = picker ? Array.from(cd.items).find((i2) => i2.type.startsWith("image/"))?.getAsFile() : void 0;
|
|
5659
|
+
if (imageFile && acceptsFile(picker?.getAttribute("accept"), imageFile)) {
|
|
5311
5660
|
root?.addAttachments([imageFile]);
|
|
5312
5661
|
return;
|
|
5313
5662
|
}
|
|
@@ -5765,11 +6114,16 @@ class AparteComposerAddAttachment extends HTMLElement {
|
|
|
5765
6114
|
input.style.display = "none";
|
|
5766
6115
|
document.body.appendChild(input);
|
|
5767
6116
|
input.addEventListener("change", () => {
|
|
5768
|
-
if (input.files?.length) this.
|
|
6117
|
+
if (input.files?.length) this._admit(input.files);
|
|
5769
6118
|
document.body.removeChild(input);
|
|
5770
6119
|
}, { once: true });
|
|
5771
6120
|
input.click();
|
|
5772
6121
|
}
|
|
6122
|
+
/** Attach the files `accept` admits: the dialog's "All files" and a drop both bypass the browser's filter. */
|
|
6123
|
+
_admit(files) {
|
|
6124
|
+
const admitted = Array.from(files).filter((file) => acceptsFile(this.getAttribute("accept"), file));
|
|
6125
|
+
if (admitted.length) this._getRoot()?.addAttachments(admitted);
|
|
6126
|
+
}
|
|
5773
6127
|
_setupDragDrop() {
|
|
5774
6128
|
const root = this._getRoot();
|
|
5775
6129
|
if (!root) return;
|
|
@@ -5791,7 +6145,7 @@ class AparteComposerAddAttachment extends HTMLElement {
|
|
|
5791
6145
|
root.classList.remove("aparte-is-dragover");
|
|
5792
6146
|
if (root.disabled) return;
|
|
5793
6147
|
const files = e.dataTransfer?.files;
|
|
5794
|
-
if (files?.length) this.
|
|
6148
|
+
if (files?.length) this._admit(files);
|
|
5795
6149
|
};
|
|
5796
6150
|
root.addEventListener("dragover", onDragOver);
|
|
5797
6151
|
root.addEventListener("dragleave", onDragLeave);
|
|
@@ -6156,7 +6510,7 @@ class AparteConversationList extends HTMLElement {
|
|
|
6156
6510
|
return;
|
|
6157
6511
|
}
|
|
6158
6512
|
const line = this.querySelector(":scope > .aparte-conv-list-no-match");
|
|
6159
|
-
const groups = this._groups().map((
|
|
6513
|
+
const groups = this._groups().map((g) => this._renderGroup(g)).join("");
|
|
6160
6514
|
if (line) {
|
|
6161
6515
|
for (const child of Array.from(this.childNodes)) if (child !== line) child.remove();
|
|
6162
6516
|
line.insertAdjacentHTML("beforebegin", groups);
|
|
@@ -6237,12 +6591,12 @@ class AparteConversationList extends HTMLElement {
|
|
|
6237
6591
|
const tag = resolveConfig(this).getLocale().tag;
|
|
6238
6592
|
const buckets = /* @__PURE__ */ new Map();
|
|
6239
6593
|
const push = (key, label, item) => {
|
|
6240
|
-
let
|
|
6241
|
-
if (!
|
|
6242
|
-
|
|
6243
|
-
buckets.set(key,
|
|
6594
|
+
let g = buckets.get(key);
|
|
6595
|
+
if (!g) {
|
|
6596
|
+
g = { key, label, items: [] };
|
|
6597
|
+
buckets.set(key, g);
|
|
6244
6598
|
}
|
|
6245
|
-
|
|
6599
|
+
g.items.push(item);
|
|
6246
6600
|
};
|
|
6247
6601
|
for (const c2 of items) {
|
|
6248
6602
|
if (c2.pinnedAt) {
|
|
@@ -6266,8 +6620,8 @@ class AparteConversationList extends HTMLElement {
|
|
|
6266
6620
|
push(`m-${d2.getFullYear()}-${String(d2.getMonth()).padStart(2, "0")}`, label, c2);
|
|
6267
6621
|
}
|
|
6268
6622
|
}
|
|
6269
|
-
const fixed = ["pinned", "today", "yesterday", "week", "month"].map((k2) => buckets.get(k2)).filter((
|
|
6270
|
-
const months = [...buckets.keys()].filter((k2) => k2.startsWith("m-")).sort((
|
|
6623
|
+
const fixed = ["pinned", "today", "yesterday", "week", "month"].map((k2) => buckets.get(k2)).filter((g) => !!g);
|
|
6624
|
+
const months = [...buckets.keys()].filter((k2) => k2.startsWith("m-")).sort((a3, b2) => b2.localeCompare(a3)).map((k2) => buckets.get(k2));
|
|
6271
6625
|
const undated = buckets.get("undated");
|
|
6272
6626
|
return [...fixed, ...months, ...undated ? [undated] : []];
|
|
6273
6627
|
}
|
|
@@ -6465,7 +6819,7 @@ class AparteConversationList extends HTMLElement {
|
|
|
6465
6819
|
console.warn("[aparte-conversation-list] the conversation manager refused the change:", err);
|
|
6466
6820
|
});
|
|
6467
6821
|
}
|
|
6468
|
-
_onMenuAction(
|
|
6822
|
+
_onMenuAction(action2) {
|
|
6469
6823
|
const open = this._open;
|
|
6470
6824
|
if (!open) return;
|
|
6471
6825
|
const conv = this._conversations.find((c2) => c2.id === open.id);
|
|
@@ -6474,7 +6828,7 @@ class AparteConversationList extends HTMLElement {
|
|
|
6474
6828
|
return;
|
|
6475
6829
|
}
|
|
6476
6830
|
const id = conv.id;
|
|
6477
|
-
switch (
|
|
6831
|
+
switch (action2) {
|
|
6478
6832
|
case "rename":
|
|
6479
6833
|
this._closeMenu();
|
|
6480
6834
|
this._startRename(open.row, conv);
|
|
@@ -6922,9 +7276,14 @@ const fraction = (raw, fallback) => {
|
|
|
6922
7276
|
const n2 = Number(raw);
|
|
6923
7277
|
return raw !== null && Number.isFinite(n2) && n2 > 0 && n2 <= 1 ? n2 : fallback;
|
|
6924
7278
|
};
|
|
6925
|
-
const
|
|
7279
|
+
const hostIdOf = (target) => {
|
|
7280
|
+
const node = target instanceof Element ? target.closest("aparte-chat, [data-aparte-chat]") : null;
|
|
7281
|
+
return node?.id || void 0;
|
|
7282
|
+
};
|
|
7283
|
+
const el = (tag, className, text) => {
|
|
6926
7284
|
const node = document.createElement(tag);
|
|
6927
7285
|
node.className = className;
|
|
7286
|
+
if (text !== void 0) node.textContent = text;
|
|
6928
7287
|
return node;
|
|
6929
7288
|
};
|
|
6930
7289
|
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
@@ -6943,33 +7302,129 @@ const ringSvg = () => {
|
|
|
6943
7302
|
}
|
|
6944
7303
|
return svg;
|
|
6945
7304
|
};
|
|
7305
|
+
const readsMessages = (candidate) => !!candidate && typeof candidate.getMessages === "function";
|
|
7306
|
+
const transcriptOf = (chat) => {
|
|
7307
|
+
if (!chat) return null;
|
|
7308
|
+
if (readsMessages(chat)) return chat;
|
|
7309
|
+
const viewport = chat.viewport ?? chat.querySelector("aparte-chat-viewport");
|
|
7310
|
+
return readsMessages(viewport) ? viewport : null;
|
|
7311
|
+
};
|
|
7312
|
+
let panelSeq = 0;
|
|
7313
|
+
const NO_PARTS = { system: 0, tools: 0, summary: 0, messages: 0 };
|
|
6946
7314
|
class AparteContext extends HTMLElement {
|
|
6947
7315
|
static get observedAttributes() {
|
|
6948
7316
|
return ["window", "warn", "danger", "target", "variant", "used"];
|
|
6949
7317
|
}
|
|
7318
|
+
/**
|
|
7319
|
+
* A reading with no transcript behind it: the `used` attribute's seed, or a turn's usage
|
|
7320
|
+
* when the chat's list cannot be read from here (a gauge placed far from its chat, a test).
|
|
7321
|
+
* When the list can be read, the measure comes from it and this is only the fallback.
|
|
7322
|
+
*/
|
|
6950
7323
|
_used = null;
|
|
6951
7324
|
_level = null;
|
|
6952
7325
|
_compactRequested = false;
|
|
7326
|
+
/** The last turn's usage and the reply it belongs to, so the measure has it before the list has written it back. */
|
|
7327
|
+
_lastDone = null;
|
|
7328
|
+
/** What the model reads changed with nothing on the path to say so (a Restore): the reading is an estimate until the next turn reports. */
|
|
7329
|
+
_viewChanged = false;
|
|
7330
|
+
/** A conversation was replaced and nothing has reported or loaded since: the list on screen is not read yet. */
|
|
7331
|
+
_blank = false;
|
|
7332
|
+
/** The model refused a request as over its window; the level is `danger` until something changes. */
|
|
7333
|
+
_overflow = false;
|
|
7334
|
+
_compact = null;
|
|
7335
|
+
_failure = "";
|
|
7336
|
+
_open = false;
|
|
7337
|
+
/** The reading drawn last, so the `used` getter and the panel read what is on screen. */
|
|
7338
|
+
_measured = null;
|
|
7339
|
+
/** The chat an event last came from, for a gauge that is neither under its chat nor names it with `target`. */
|
|
7340
|
+
_seen = null;
|
|
7341
|
+
/** What the panel was last built from: a render that changes nothing leaves its nodes, and the focus in them, alone. */
|
|
7342
|
+
_panelSignature = "";
|
|
7343
|
+
_remember(target) {
|
|
7344
|
+
const chat = target instanceof Element ? chatBoundaryOf(target) : null;
|
|
7345
|
+
if (chat) this._seen = chat;
|
|
7346
|
+
}
|
|
6953
7347
|
_onDone = (e) => {
|
|
6954
7348
|
const detail = e.detail;
|
|
6955
7349
|
if (!detail?.usage || !this._isMine(detail.targetId)) return;
|
|
6956
|
-
|
|
6957
|
-
this._used =
|
|
7350
|
+
this._remember(e.target);
|
|
7351
|
+
this._used = usageTokens(detail.usage);
|
|
7352
|
+
this._lastDone = { messageId: detail.messageId, usage: detail.usage };
|
|
7353
|
+
this._viewChanged = false;
|
|
7354
|
+
this._blank = false;
|
|
7355
|
+
this._overflow = false;
|
|
7356
|
+
this._render(true);
|
|
7357
|
+
};
|
|
7358
|
+
/**
|
|
7359
|
+
* A conversation is replaced — a new chat, or one loaded in place of the last — and the
|
|
7360
|
+
* previous reading is not this one's. The viewport says so with `aparte-reset-done` (no
|
|
7361
|
+
* detail: the chat is found from where the event came from). A load clears first and
|
|
7362
|
+
* `aparte-conversation-loaded` follows, so the reading is dropped here and read again
|
|
7363
|
+
* there. Until then the chat's list is not trusted: a framework's may not have caught up.
|
|
7364
|
+
*/
|
|
7365
|
+
_onReset = (e) => {
|
|
7366
|
+
if (!this._isMine(hostIdOf(e.target))) return;
|
|
7367
|
+
this._remember(e.target);
|
|
7368
|
+
this._used = null;
|
|
7369
|
+
this._lastDone = null;
|
|
7370
|
+
this._viewChanged = false;
|
|
7371
|
+
this._overflow = false;
|
|
7372
|
+
this._compact = null;
|
|
7373
|
+
this._blank = true;
|
|
7374
|
+
this._render();
|
|
7375
|
+
};
|
|
7376
|
+
/**
|
|
7377
|
+
* The messages of a stored conversation are on screen: the reading is the last reply's
|
|
7378
|
+
* usage — what a turn would have reported had it just ended. A transcript with none
|
|
7379
|
+
* (an empty one, a conversation saved before usage was kept) shows nothing, the same as
|
|
7380
|
+
* a chat that has not spoken yet.
|
|
7381
|
+
*/
|
|
7382
|
+
_onLoaded = (e) => {
|
|
7383
|
+
const detail = e.detail;
|
|
7384
|
+
if (!this._isMine(detail?.targetId)) return;
|
|
7385
|
+
this._remember(e.target);
|
|
7386
|
+
this._blank = false;
|
|
7387
|
+
this._lastDone = null;
|
|
7388
|
+
this._viewChanged = false;
|
|
7389
|
+
this._overflow = false;
|
|
7390
|
+
this._compact = null;
|
|
7391
|
+
const host = e.target;
|
|
7392
|
+
const messages = host?.getMessages?.() ?? [];
|
|
7393
|
+
const last = [...messages].reverse().find((m2) => m2.role === "assistant" && m2.usage);
|
|
7394
|
+
this._used = last?.usage ? usageTokens(last.usage) : null;
|
|
7395
|
+
this._render();
|
|
7396
|
+
};
|
|
7397
|
+
/** A compaction began for this chat: say so on the element and in the panel. */
|
|
7398
|
+
_onCompactStart = (e) => {
|
|
7399
|
+
const detail = e.detail;
|
|
7400
|
+
if (!this._isMine(detail?.targetId)) return;
|
|
7401
|
+
this._compact = "running";
|
|
7402
|
+
this._failure = "";
|
|
6958
7403
|
this._render();
|
|
6959
7404
|
};
|
|
6960
7405
|
/**
|
|
6961
|
-
* After a real compaction the
|
|
6962
|
-
* yet
|
|
6963
|
-
*
|
|
6964
|
-
*
|
|
6965
|
-
*
|
|
7406
|
+
* After a real compaction — or a Restore — what the model reads is a different size by an
|
|
7407
|
+
* amount nobody has measured yet, and the last reply's reported usage describes the request
|
|
7408
|
+
* from before. The gauge measures the request that would be sent now and says so with `~`,
|
|
7409
|
+
* rather than keeping a number it knows to be wrong or going blank until the next turn. The
|
|
7410
|
+
* event names the chat it compacted, so on a multi-chat page only that chat's gauge
|
|
7411
|
+
* moves; an unnamed one moves every gauge.
|
|
7412
|
+
*
|
|
7413
|
+
* Without a transcript to measure (a gauge that cannot read its chat's list) there is
|
|
7414
|
+
* nothing to estimate from, and the reading is dropped as it always was.
|
|
6966
7415
|
*/
|
|
6967
7416
|
_onCompacted = (e) => {
|
|
6968
7417
|
const detail = e.detail;
|
|
6969
7418
|
if (!this._isMine(detail?.targetId)) return;
|
|
6970
7419
|
this._compactRequested = false;
|
|
6971
|
-
|
|
6972
|
-
|
|
7420
|
+
this._compact = null;
|
|
7421
|
+
if (detail?.skipped) {
|
|
7422
|
+
this._render();
|
|
7423
|
+
return;
|
|
7424
|
+
}
|
|
7425
|
+
this._viewChanged = true;
|
|
7426
|
+
this._overflow = false;
|
|
7427
|
+
if (!this._messages()) this._used = null;
|
|
6973
7428
|
this._render();
|
|
6974
7429
|
};
|
|
6975
7430
|
/** A failed compaction spends the request too; the next `danger` asks again. */
|
|
@@ -6977,11 +7432,23 @@ class AparteContext extends HTMLElement {
|
|
|
6977
7432
|
const detail = e.detail;
|
|
6978
7433
|
if (!this._isMine(detail?.targetId)) return;
|
|
6979
7434
|
this._compactRequested = false;
|
|
7435
|
+
this._compact = detail?.aborted ? null : "failed";
|
|
7436
|
+
this._failure = detail?.aborted ? "" : typeof detail?.error === "string" ? detail.error : "";
|
|
7437
|
+
this._render();
|
|
7438
|
+
};
|
|
7439
|
+
/** The model refused this chat's request as over its window: the number was wrong, and so is "ok". */
|
|
7440
|
+
_onMessageError = (e) => {
|
|
7441
|
+
const detail = e.detail;
|
|
7442
|
+
if (!this._isMine(detail?.targetId)) return;
|
|
7443
|
+
if (detail?.error?.code !== AparteErrorCode.USAGE_CONTEXT_EXCEEDED) return;
|
|
7444
|
+
this._remember(e.target);
|
|
7445
|
+
this._overflow = true;
|
|
7446
|
+
this._render();
|
|
6980
7447
|
};
|
|
6981
7448
|
_onRerender = () => this._render();
|
|
6982
|
-
/** Tokens
|
|
7449
|
+
/** Tokens in use — what is drawn — else the last reported or seeded reading, else `null`. */
|
|
6983
7450
|
get used() {
|
|
6984
|
-
return this._used;
|
|
7451
|
+
return this._measured?.used ?? this._used;
|
|
6985
7452
|
}
|
|
6986
7453
|
/**
|
|
6987
7454
|
* Writes the `used` attribute: a reading for a conversation restored without a turn of
|
|
@@ -7010,18 +7477,35 @@ class AparteContext extends HTMLElement {
|
|
|
7010
7477
|
get level() {
|
|
7011
7478
|
return this._level;
|
|
7012
7479
|
}
|
|
7480
|
+
/** The reading drawn now, parts and all, or `null` while nothing is shown. */
|
|
7481
|
+
get measure() {
|
|
7482
|
+
return this._measured;
|
|
7483
|
+
}
|
|
7013
7484
|
connectedCallback() {
|
|
7014
7485
|
window.addEventListener("aparte-message-done", this._onDone);
|
|
7486
|
+
window.addEventListener("aparte-message-error", this._onMessageError);
|
|
7487
|
+
window.addEventListener("aparte-compact-start", this._onCompactStart);
|
|
7015
7488
|
window.addEventListener("aparte-compact-done", this._onCompacted);
|
|
7016
7489
|
window.addEventListener("aparte-compact-error", this._onCompactError);
|
|
7490
|
+
window.addEventListener("aparte-reset-done", this._onReset);
|
|
7491
|
+
window.addEventListener("aparte-conversation-loaded", this._onLoaded);
|
|
7017
7492
|
window.addEventListener("aparte-config-change", this._onRerender);
|
|
7493
|
+
this.addEventListener("click", this._onClick);
|
|
7494
|
+
this.addEventListener("keydown", this._onKeydown);
|
|
7018
7495
|
this._render();
|
|
7019
7496
|
}
|
|
7020
7497
|
disconnectedCallback() {
|
|
7021
7498
|
window.removeEventListener("aparte-message-done", this._onDone);
|
|
7499
|
+
window.removeEventListener("aparte-message-error", this._onMessageError);
|
|
7500
|
+
window.removeEventListener("aparte-compact-start", this._onCompactStart);
|
|
7022
7501
|
window.removeEventListener("aparte-compact-done", this._onCompacted);
|
|
7023
7502
|
window.removeEventListener("aparte-compact-error", this._onCompactError);
|
|
7503
|
+
window.removeEventListener("aparte-reset-done", this._onReset);
|
|
7504
|
+
window.removeEventListener("aparte-conversation-loaded", this._onLoaded);
|
|
7024
7505
|
window.removeEventListener("aparte-config-change", this._onRerender);
|
|
7506
|
+
this.removeEventListener("click", this._onClick);
|
|
7507
|
+
this.removeEventListener("keydown", this._onKeydown);
|
|
7508
|
+
this._stopListeningWhileOpen();
|
|
7025
7509
|
}
|
|
7026
7510
|
attributeChangedCallback(name) {
|
|
7027
7511
|
if (name === "used") {
|
|
@@ -7030,10 +7514,21 @@ class AparteContext extends HTMLElement {
|
|
|
7030
7514
|
}
|
|
7031
7515
|
if (this.isConnected) this._render();
|
|
7032
7516
|
}
|
|
7517
|
+
/**
|
|
7518
|
+
* The config the chat this gauge watches answers to, not the one at the gauge's own
|
|
7519
|
+
* position. A gauge in a header, with `target=`, stands outside the chat's boundary, and
|
|
7520
|
+
* a chat that carries its own config (a wrapper's `config` prop) has its own prompt, tools,
|
|
7521
|
+
* window and compactor: the client and the plugin read them from there, so the gauge must
|
|
7522
|
+
* too, or it measures a different request and offers no Compact now. Resolved live, like
|
|
7523
|
+
* every config read: the boundary may be attached after this element connects.
|
|
7524
|
+
*/
|
|
7525
|
+
_cfg() {
|
|
7526
|
+
return resolveConfig(this._chat() ?? this);
|
|
7527
|
+
}
|
|
7033
7528
|
_window() {
|
|
7034
7529
|
const attr = Number(this.getAttribute("window"));
|
|
7035
7530
|
if (this.hasAttribute("window") && Number.isFinite(attr) && attr > 0) return attr;
|
|
7036
|
-
const model =
|
|
7531
|
+
const model = this._cfg().getCurrentModel();
|
|
7037
7532
|
return model?.contextWindow && model.contextWindow > 0 ? model.contextWindow : null;
|
|
7038
7533
|
}
|
|
7039
7534
|
/** The chat this gauge watches: `target`, else the chat host above it — the composer's rule. */
|
|
@@ -7052,43 +7547,113 @@ class AparteContext extends HTMLElement {
|
|
|
7052
7547
|
const own = this._ownTargetId();
|
|
7053
7548
|
return !targetId || !own || targetId === own;
|
|
7054
7549
|
}
|
|
7055
|
-
|
|
7550
|
+
/**
|
|
7551
|
+
* The chat's element: the one `target` names, else the chat above the gauge, else the one
|
|
7552
|
+
* its events last came from. Passed to the compactor as it is — a chat inside a shadow
|
|
7553
|
+
* root is not found by id, so the element is the address that always works.
|
|
7554
|
+
*/
|
|
7555
|
+
_chat() {
|
|
7556
|
+
const attr = this.getAttribute("target");
|
|
7557
|
+
if (attr) {
|
|
7558
|
+
const root = this.getRootNode();
|
|
7559
|
+
const named = root.getElementById?.(attr) ?? document.getElementById(attr);
|
|
7560
|
+
if (named) return named;
|
|
7561
|
+
}
|
|
7562
|
+
const above = chatBoundaryOf(this);
|
|
7563
|
+
if (above) return above;
|
|
7564
|
+
return this._seen?.isConnected ? this._seen : null;
|
|
7565
|
+
}
|
|
7566
|
+
/** The chat's active path, or `null` when it cannot be read from here. */
|
|
7567
|
+
_messages() {
|
|
7568
|
+
const reader = transcriptOf(this._chat());
|
|
7569
|
+
if (!reader) return null;
|
|
7570
|
+
try {
|
|
7571
|
+
return reader.getMessages();
|
|
7572
|
+
} catch {
|
|
7573
|
+
return null;
|
|
7574
|
+
}
|
|
7575
|
+
}
|
|
7576
|
+
/**
|
|
7577
|
+
* What to draw: the measure of the chat's own transcript when it holds a reply with usage
|
|
7578
|
+
* (or the model has just refused a request, and an estimate is better than nothing), else
|
|
7579
|
+
* the seeded or reported number with nothing to break down.
|
|
7580
|
+
*
|
|
7581
|
+
* The last turn's usage is laid over its reply when the list has not written it back yet.
|
|
7582
|
+
* If the list does not hold that reply at all it is not used: the list is the path on
|
|
7583
|
+
* screen, and a reply that is not on it (a branch was switched) is not its reading.
|
|
7584
|
+
*/
|
|
7585
|
+
_measure(capacity) {
|
|
7586
|
+
const stored = this._messages();
|
|
7587
|
+
const done = this._lastDone;
|
|
7588
|
+
const messages = stored && done?.messageId ? stored.map((m2) => m2.id === done.messageId && !m2.usage ? { ...m2, usage: done.usage } : m2) : stored;
|
|
7589
|
+
const hasUsage = !!messages?.some((m2) => m2.role === "assistant" && m2.usage);
|
|
7590
|
+
if (messages && (hasUsage && !this._blank || this._overflow && messages.length > 0)) {
|
|
7591
|
+
return measureContext({ messages, config: this._cfg(), windowOverride: capacity, viewChanged: this._viewChanged });
|
|
7592
|
+
}
|
|
7593
|
+
if (this._used === null) return null;
|
|
7594
|
+
return { window: capacity, used: this._used, estimated: false, parts: { ...NO_PARTS }, other: this._used };
|
|
7595
|
+
}
|
|
7596
|
+
_render(askToCompact = false) {
|
|
7056
7597
|
const capacity = this._window();
|
|
7057
|
-
|
|
7598
|
+
const measure = capacity === null ? null : this._measure(capacity);
|
|
7599
|
+
if (this._compact) this.setAttribute("data-compact", this._compact);
|
|
7600
|
+
else this.removeAttribute("data-compact");
|
|
7601
|
+
if (capacity === null || measure === null) {
|
|
7602
|
+
this._measured = null;
|
|
7058
7603
|
this.setAttribute("data-empty", "");
|
|
7059
7604
|
this.removeAttribute("data-level");
|
|
7605
|
+
this._open = false;
|
|
7606
|
+
this._stopListeningWhileOpen();
|
|
7607
|
+
this._panelSignature = "";
|
|
7060
7608
|
this.replaceChildren();
|
|
7061
7609
|
this._level = null;
|
|
7062
7610
|
return;
|
|
7063
7611
|
}
|
|
7612
|
+
this._measured = measure;
|
|
7064
7613
|
this.removeAttribute("data-empty");
|
|
7065
|
-
const used =
|
|
7614
|
+
const used = measure.used;
|
|
7066
7615
|
const ratio = Math.min(1, used / capacity);
|
|
7067
7616
|
const warn = fraction(this.getAttribute("warn"), 0.75);
|
|
7068
7617
|
const danger = fraction(this.getAttribute("danger"), 0.9);
|
|
7069
|
-
const level = ratio >= danger ? "danger" : ratio >= warn ? "warn" : "ok";
|
|
7618
|
+
const level = this._overflow || ratio >= danger ? "danger" : ratio >= warn ? "warn" : "ok";
|
|
7070
7619
|
this.setAttribute("data-level", level);
|
|
7071
7620
|
const ring = this.getAttribute("variant") === "ring";
|
|
7072
7621
|
let root = this.querySelector(".aparte-context");
|
|
7073
7622
|
if (root && root.classList.contains("aparte-context--ring") !== ring) {
|
|
7074
7623
|
this.replaceChildren();
|
|
7075
7624
|
root = null;
|
|
7625
|
+
this._panelSignature = "";
|
|
7076
7626
|
}
|
|
7077
7627
|
let meter = this.querySelector('[role="meter"]');
|
|
7078
7628
|
let text = this.querySelector(".aparte-context__text");
|
|
7079
|
-
|
|
7629
|
+
let toggle = this.querySelector(".aparte-context__toggle");
|
|
7630
|
+
let name = this.querySelector(".aparte-context__name");
|
|
7631
|
+
let panel = this.querySelector(".aparte-context__panel");
|
|
7632
|
+
if (!root || !meter || !text || !toggle || !name || !panel) {
|
|
7080
7633
|
root = el("div", ring ? "aparte-context aparte-context--ring" : "aparte-context");
|
|
7081
7634
|
meter = ring ? ringSvg() : el("div", "aparte-progress");
|
|
7082
7635
|
meter.setAttribute("role", "meter");
|
|
7083
7636
|
if (!ring) meter.appendChild(el("div", "aparte-progress__bar"));
|
|
7637
|
+
toggle = el("button", "aparte-btn aparte-btn--ghost aparte-btn--sm aparte-context__toggle");
|
|
7638
|
+
toggle.type = "button";
|
|
7639
|
+
name = el("span", "aparte-sr-only");
|
|
7640
|
+
name.classList.add("aparte-context__name");
|
|
7084
7641
|
text = el("span", "aparte-context__text");
|
|
7085
|
-
|
|
7642
|
+
toggle.append(name, text);
|
|
7643
|
+
panel = el("div", "aparte-context__panel aparte-popover");
|
|
7644
|
+
panel.id = `aparte-context-panel-${++panelSeq}`;
|
|
7645
|
+
panel.setAttribute("role", "group");
|
|
7646
|
+
panel.hidden = true;
|
|
7647
|
+
toggle.setAttribute("aria-controls", panel.id);
|
|
7648
|
+
root.append(meter, toggle, panel);
|
|
7086
7649
|
this.replaceChildren(root);
|
|
7650
|
+
this._panelSignature = "";
|
|
7087
7651
|
}
|
|
7088
|
-
const cfg =
|
|
7652
|
+
const cfg = this._cfg();
|
|
7089
7653
|
const tag = cfg.getLocale().tag || void 0;
|
|
7090
7654
|
const format = new Intl.NumberFormat(tag, { notation: "compact", maximumFractionDigits: 1 });
|
|
7091
|
-
const
|
|
7655
|
+
const approx = measure.estimated ? "~" : "";
|
|
7656
|
+
const reading = `${approx}${format.format(used)} / ${format.format(capacity)}`;
|
|
7092
7657
|
const percent = Math.round(ratio * 100);
|
|
7093
7658
|
const label = cfg.t("contextLabel") || "Context window";
|
|
7094
7659
|
if (ring) {
|
|
@@ -7103,7 +7668,13 @@ class AparteContext extends HTMLElement {
|
|
|
7103
7668
|
meter.setAttribute("aria-valuemax", String(capacity));
|
|
7104
7669
|
meter.setAttribute("aria-valuenow", String(used));
|
|
7105
7670
|
meter.setAttribute("aria-label", `${label}: ${reading}`);
|
|
7106
|
-
|
|
7671
|
+
name.textContent = `${label}: `;
|
|
7672
|
+
toggle.setAttribute("aria-expanded", String(this._open));
|
|
7673
|
+
text.textContent = ring ? `${approx}${new Intl.NumberFormat(tag, { style: "percent", maximumFractionDigits: 0 }).format(percent / 100)}` : reading;
|
|
7674
|
+
panel.setAttribute("aria-label", label);
|
|
7675
|
+
panel.hidden = !this._open;
|
|
7676
|
+
if (this._open) this._renderPanel(panel, measure, capacity, format);
|
|
7677
|
+
else this._panelSignature = "";
|
|
7107
7678
|
if (level !== this._level) {
|
|
7108
7679
|
this._level = level;
|
|
7109
7680
|
const targetId = this._ownTargetId();
|
|
@@ -7111,10 +7682,206 @@ class AparteContext extends HTMLElement {
|
|
|
7111
7682
|
this.dispatchEvent(new CustomEvent("aparte-context-threshold", { detail, bubbles: true, composed: true }));
|
|
7112
7683
|
if (level !== "danger") this._compactRequested = false;
|
|
7113
7684
|
}
|
|
7114
|
-
if (level === "danger" && this.hasAttribute("auto-compact") && !this._compactRequested) {
|
|
7685
|
+
if (askToCompact && level === "danger" && this.hasAttribute("auto-compact") && !this._compactRequested) {
|
|
7115
7686
|
this._compactRequested = true;
|
|
7116
|
-
window.dispatchEvent(new CustomEvent("aparte-compact", {
|
|
7687
|
+
window.dispatchEvent(new CustomEvent("aparte-compact", {
|
|
7688
|
+
detail: { targetId: this._ownTargetId(), auto: true, window: capacity }
|
|
7689
|
+
}));
|
|
7690
|
+
}
|
|
7691
|
+
}
|
|
7692
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
7693
|
+
// The panel
|
|
7694
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
7695
|
+
/**
|
|
7696
|
+
* What the window holds, row by row, and what can be done about it.
|
|
7697
|
+
*
|
|
7698
|
+
* The parts are raw estimates and `used` is the number the gauge draws — measured or
|
|
7699
|
+
* calibrated — so they need not agree. The panel never shows a sum above the total: when
|
|
7700
|
+
* the estimates add up to more than `used`, each is scaled down to fit and `other` is
|
|
7701
|
+
* zero; otherwise the difference is `other`, the part the heuristic cannot see.
|
|
7702
|
+
*/
|
|
7703
|
+
_renderPanel(panel, measure, capacity, format) {
|
|
7704
|
+
const cfg = this._cfg();
|
|
7705
|
+
const compactor = cfg.getCompactor();
|
|
7706
|
+
const chat = this._chat();
|
|
7707
|
+
const targetId = this._ownTargetId();
|
|
7708
|
+
let preview = null;
|
|
7709
|
+
try {
|
|
7710
|
+
preview = compactor?.preview?.({ target: chat, ...targetId ? { targetId } : {} }) ?? null;
|
|
7711
|
+
} catch {
|
|
7712
|
+
preview = null;
|
|
7713
|
+
}
|
|
7714
|
+
const { parts, used } = measure;
|
|
7715
|
+
const sum = parts.system + parts.tools + parts.summary + parts.messages;
|
|
7716
|
+
const scale = sum > used && sum > 0 ? used / sum : 1;
|
|
7717
|
+
const approxOf = measure.estimated ? "~" : "";
|
|
7718
|
+
const rows = [
|
|
7719
|
+
{ key: "system", label: cfg.t("contextSystem") || "System prompt", tokens: parts.system * scale, approx: "~" },
|
|
7720
|
+
{ key: "tools", label: cfg.t("contextTools") || "Tools", tokens: parts.tools * scale, approx: "~" },
|
|
7721
|
+
{ key: "summary", label: cfg.t("contextSummary") || "Summary", tokens: parts.summary * scale, approx: "~" },
|
|
7722
|
+
{ key: "messages", label: cfg.t("contextMessages") || "Messages", tokens: parts.messages * scale, approx: "~" },
|
|
7723
|
+
{ key: "other", label: cfg.t("contextOther") || "Other", tokens: scale < 1 ? 0 : measure.other, approx: "~" },
|
|
7724
|
+
{ key: "free", label: cfg.t("contextFree") || "Free", tokens: Math.max(0, capacity - used), approx: approxOf }
|
|
7725
|
+
];
|
|
7726
|
+
const total = `${approxOf}${format.format(used)} / ${format.format(capacity)}`;
|
|
7727
|
+
const reclaim = preview && preview.tokens > 0 ? (cfg.t("contextReclaim") || "Compacting now would free ~{n} tokens").replace("{n}", () => format.format(Math.round(preview.tokens))) : "";
|
|
7728
|
+
const canCompact = !!compactor && !!preview && this._compact === null;
|
|
7729
|
+
const list = el("ul", "aparte-context__rows");
|
|
7730
|
+
for (const row of rows) {
|
|
7731
|
+
const item = el("li", "aparte-context__row");
|
|
7732
|
+
item.setAttribute("data-part", row.key);
|
|
7733
|
+
item.append(el("span", "aparte-context__row-label", row.label));
|
|
7734
|
+
item.append(el("span", "aparte-context__row-value", `${row.approx}${format.format(Math.round(row.tokens))}`));
|
|
7735
|
+
const bar = el("div", "aparte-progress aparte-context__row-bar");
|
|
7736
|
+
bar.setAttribute("aria-hidden", "true");
|
|
7737
|
+
bar.style.setProperty("--aparte-progress-value", String(Math.round(Math.min(1, row.tokens / capacity) * 100)));
|
|
7738
|
+
bar.appendChild(el("div", "aparte-progress__bar"));
|
|
7739
|
+
item.append(bar);
|
|
7740
|
+
list.append(item);
|
|
7741
|
+
}
|
|
7742
|
+
const totalRow = el("li", "aparte-context__row aparte-context__row--total");
|
|
7743
|
+
totalRow.setAttribute("data-part", "total");
|
|
7744
|
+
totalRow.append(el("span", "aparte-context__row-label", cfg.t("contextTotal") || "Total"), el("span", "aparte-context__row-value", total));
|
|
7745
|
+
list.append(totalRow);
|
|
7746
|
+
const nodes = [list];
|
|
7747
|
+
if (this._compact === "running") {
|
|
7748
|
+
const status = el("p", "aparte-context__status aparte-shimmer", cfg.t("checkpointPending") || "Summarising the context…");
|
|
7749
|
+
status.setAttribute("role", "status");
|
|
7750
|
+
nodes.push(status);
|
|
7751
|
+
} else if (this._compact === "failed") {
|
|
7752
|
+
const status = el("p", "aparte-context__status aparte-context__status--failed", cfg.t("checkpointFailed") || "Couldn't summarise the context");
|
|
7753
|
+
status.setAttribute("role", "status");
|
|
7754
|
+
if (this._failure) {
|
|
7755
|
+
status.title = this._failure;
|
|
7756
|
+
status.appendChild(el("span", "aparte-sr-only", `: ${this._failure}`));
|
|
7757
|
+
}
|
|
7758
|
+
nodes.push(status, this._action("retry", cfg.t("retry") || "Retry"));
|
|
7759
|
+
}
|
|
7760
|
+
if (reclaim) nodes.push(el("p", "aparte-context__reclaim", reclaim));
|
|
7761
|
+
if (canCompact) nodes.push(this._action("compact", cfg.t("contextCompactNow") || "Compact now"));
|
|
7762
|
+
const next = el("div", "aparte-context__content");
|
|
7763
|
+
next.append(...nodes);
|
|
7764
|
+
if (next.innerHTML === this._panelSignature) return;
|
|
7765
|
+
this._panelSignature = next.innerHTML;
|
|
7766
|
+
const active = document.activeElement;
|
|
7767
|
+
const hadFocus = active && panel.contains(active) ? active.getAttribute("data-context-action") ?? "" : null;
|
|
7768
|
+
panel.replaceChildren(...Array.from(next.childNodes));
|
|
7769
|
+
if (hadFocus !== null) {
|
|
7770
|
+
const same = hadFocus ? panel.querySelector(`[data-context-action="${cssEscape(hadFocus)}"]`) : null;
|
|
7771
|
+
(same ?? this.querySelector(".aparte-context__toggle"))?.focus();
|
|
7772
|
+
}
|
|
7773
|
+
}
|
|
7774
|
+
_action(name, label) {
|
|
7775
|
+
const button = el("button", "aparte-btn aparte-btn--sm aparte-btn--surface aparte-context__action", label);
|
|
7776
|
+
button.type = "button";
|
|
7777
|
+
button.setAttribute("data-context-action", name);
|
|
7778
|
+
return button;
|
|
7779
|
+
}
|
|
7780
|
+
/**
|
|
7781
|
+
* Ask the registered compactor to compact this chat now, as a person asked. With none
|
|
7782
|
+
* registered (Retry only — Compact now is not offered without one) the command event
|
|
7783
|
+
* is the way to ask, the one a host's own button uses.
|
|
7784
|
+
*/
|
|
7785
|
+
async _compactNow(reason) {
|
|
7786
|
+
const compactor = this._cfg().getCompactor();
|
|
7787
|
+
const targetId = this._ownTargetId();
|
|
7788
|
+
if (!compactor) {
|
|
7789
|
+
window.dispatchEvent(new CustomEvent("aparte-compact", { detail: { targetId } }));
|
|
7790
|
+
return;
|
|
7791
|
+
}
|
|
7792
|
+
this._compact = "running";
|
|
7793
|
+
this._failure = "";
|
|
7794
|
+
this._render();
|
|
7795
|
+
let failed = null;
|
|
7796
|
+
try {
|
|
7797
|
+
const outcome = await compactor.compact({ target: this._chat(), ...targetId ? { targetId } : {}, force: true, reason });
|
|
7798
|
+
if (!outcome.ok) failed = outcome.error;
|
|
7799
|
+
else if (!outcome.skipped) this._viewChanged = true;
|
|
7800
|
+
} catch (error) {
|
|
7801
|
+
failed = error instanceof Error ? error.message : String(error);
|
|
7117
7802
|
}
|
|
7803
|
+
if (this._compact === "running") {
|
|
7804
|
+
this._compact = failed === null ? null : "failed";
|
|
7805
|
+
this._failure = failed ?? "";
|
|
7806
|
+
}
|
|
7807
|
+
if (this.isConnected) this._render();
|
|
7808
|
+
}
|
|
7809
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
7810
|
+
// The disclosure
|
|
7811
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
7812
|
+
_onClick = (event) => {
|
|
7813
|
+
const target = event.target;
|
|
7814
|
+
const action2 = target?.closest?.("[data-context-action]");
|
|
7815
|
+
if (action2) {
|
|
7816
|
+
void this._compactNow(action2.getAttribute("data-context-action") === "retry" ? "retry" : "manual");
|
|
7817
|
+
return;
|
|
7818
|
+
}
|
|
7819
|
+
if (target?.closest?.(".aparte-context__panel")) return;
|
|
7820
|
+
if (!target?.closest?.(".aparte-context")) return;
|
|
7821
|
+
this._setOpen(!this._open);
|
|
7822
|
+
};
|
|
7823
|
+
_setOpen(open, returnFocus = false) {
|
|
7824
|
+
if (open === this._open) return;
|
|
7825
|
+
this._open = open;
|
|
7826
|
+
if (open) this._listenWhileOpen();
|
|
7827
|
+
else this._stopListeningWhileOpen();
|
|
7828
|
+
this._render();
|
|
7829
|
+
if (open) this._place();
|
|
7830
|
+
else if (returnFocus) this.querySelector(".aparte-context__toggle")?.focus();
|
|
7831
|
+
}
|
|
7832
|
+
/**
|
|
7833
|
+
* Escape and a click anywhere else close the panel. Listened for on the document only
|
|
7834
|
+
* while it is open: a page full of closed gauges holds no listeners but its own.
|
|
7835
|
+
*/
|
|
7836
|
+
_onDocumentClick = (event) => {
|
|
7837
|
+
if (!event.composedPath().includes(this)) this._setOpen(false);
|
|
7838
|
+
};
|
|
7839
|
+
/**
|
|
7840
|
+
* Escape from inside the gauge — the toggle, the panel — is the gauge's, and it is
|
|
7841
|
+
* answered HERE, on the element, not on the document. An ancestor that also answers
|
|
7842
|
+
* Escape (a launcher closing its card, a dialog) listens on its own element, which runs
|
|
7843
|
+
* before any listener on the document, so a press consumed only there had already
|
|
7844
|
+
* closed the card around the panel it was meant for. Taken means stopped, so nothing
|
|
7845
|
+
* above answers it too, and prevented, so a listener that still sees it — one on this
|
|
7846
|
+
* element, a capture listener — knows it is spoken for, and a dialog around does not
|
|
7847
|
+
* take it as its own close request.
|
|
7848
|
+
*/
|
|
7849
|
+
_onKeydown = (event) => {
|
|
7850
|
+
if (!this._open || event.key !== "Escape") return;
|
|
7851
|
+
event.preventDefault();
|
|
7852
|
+
event.stopPropagation();
|
|
7853
|
+
this._setOpen(false, true);
|
|
7854
|
+
};
|
|
7855
|
+
/**
|
|
7856
|
+
* A press elsewhere still closes the panel, but is left to whatever else listens for
|
|
7857
|
+
* Escape (a dialog, the composer).
|
|
7858
|
+
*/
|
|
7859
|
+
_onDocumentKeydown = (event) => {
|
|
7860
|
+
if (event.key !== "Escape") return;
|
|
7861
|
+
this._setOpen(false, this.contains(document.activeElement));
|
|
7862
|
+
};
|
|
7863
|
+
_listenWhileOpen() {
|
|
7864
|
+
document.addEventListener("click", this._onDocumentClick);
|
|
7865
|
+
document.addEventListener("keydown", this._onDocumentKeydown);
|
|
7866
|
+
}
|
|
7867
|
+
_stopListeningWhileOpen() {
|
|
7868
|
+
document.removeEventListener("click", this._onDocumentClick);
|
|
7869
|
+
document.removeEventListener("keydown", this._onDocumentKeydown);
|
|
7870
|
+
}
|
|
7871
|
+
/**
|
|
7872
|
+
* Where the panel opens: above the reading by default, since a gauge usually sits in the
|
|
7873
|
+
* composer at the foot of the page; below when there is no room above, and flush with the
|
|
7874
|
+
* other edge when it would run past the window's.
|
|
7875
|
+
*/
|
|
7876
|
+
_place() {
|
|
7877
|
+
const panel = this.querySelector(".aparte-context__panel");
|
|
7878
|
+
if (!panel) return;
|
|
7879
|
+
panel.removeAttribute("data-placement");
|
|
7880
|
+
panel.removeAttribute("data-align");
|
|
7881
|
+
const anchor = this.getBoundingClientRect();
|
|
7882
|
+
const box = panel.getBoundingClientRect();
|
|
7883
|
+
if (box.height > 0 && anchor.top < box.height) panel.setAttribute("data-placement", "below");
|
|
7884
|
+
if (box.width > 0 && box.right > document.documentElement.clientWidth) panel.setAttribute("data-align", "end");
|
|
7118
7885
|
}
|
|
7119
7886
|
}
|
|
7120
7887
|
deferHydrationOf(AparteContext);
|
|
@@ -7580,9 +8347,9 @@ class AparteScrollRail extends HTMLElement {
|
|
|
7580
8347
|
this._held = null;
|
|
7581
8348
|
}
|
|
7582
8349
|
}
|
|
7583
|
-
function sameElements(
|
|
7584
|
-
if (
|
|
7585
|
-
for (let i2 = 0; i2 <
|
|
8350
|
+
function sameElements(a3, b2) {
|
|
8351
|
+
if (a3.length !== b2.length) return false;
|
|
8352
|
+
for (let i2 = 0; i2 < a3.length; i2++) if (a3[i2] !== b2[i2]) return false;
|
|
7586
8353
|
return true;
|
|
7587
8354
|
}
|
|
7588
8355
|
deferHydrationOf(AparteScrollRail);
|
|
@@ -7922,7 +8689,7 @@ class AparteSidebar extends HTMLElement {
|
|
|
7922
8689
|
}
|
|
7923
8690
|
}
|
|
7924
8691
|
let sidebarIdSeq = 0;
|
|
7925
|
-
const FOCUSABLE = [
|
|
8692
|
+
const FOCUSABLE$1 = [
|
|
7926
8693
|
"a[href]",
|
|
7927
8694
|
"button:not([disabled])",
|
|
7928
8695
|
'input:not([disabled]):not([type="hidden"])',
|
|
@@ -7931,7 +8698,7 @@ const FOCUSABLE = [
|
|
|
7931
8698
|
'[tabindex]:not([tabindex="-1"])'
|
|
7932
8699
|
].join(",");
|
|
7933
8700
|
function visibleFocusable(root) {
|
|
7934
|
-
return Array.from(root.querySelectorAll(FOCUSABLE)).filter((el2) => !el2.closest("[hidden]") && el2.checkVisibility?.() !== false);
|
|
8701
|
+
return Array.from(root.querySelectorAll(FOCUSABLE$1)).filter((el2) => !el2.closest("[hidden]") && el2.checkVisibility?.() !== false);
|
|
7935
8702
|
}
|
|
7936
8703
|
function nearestSidebar(control) {
|
|
7937
8704
|
return control.closest("aparte-sidebar") ?? rootOf(control).querySelector("aparte-sidebar") ?? document.querySelector("aparte-sidebar");
|
|
@@ -8719,6 +9486,278 @@ deferHydrationOf(AparteSplit);
|
|
|
8719
9486
|
if (!customElements.get("aparte-split")) {
|
|
8720
9487
|
customElements.define("aparte-split", AparteSplit);
|
|
8721
9488
|
}
|
|
9489
|
+
const SHEET_QUERY = "(max-width: 30rem), (max-height: 30rem)";
|
|
9490
|
+
const FOCUSABLE = [
|
|
9491
|
+
"a[href]",
|
|
9492
|
+
"button:not([disabled])",
|
|
9493
|
+
'input:not([disabled]):not([type="hidden"])',
|
|
9494
|
+
"select:not([disabled])",
|
|
9495
|
+
"textarea:not([disabled])",
|
|
9496
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
9497
|
+
].join(",");
|
|
9498
|
+
class AparteLauncher extends HTMLElement {
|
|
9499
|
+
static get observedAttributes() {
|
|
9500
|
+
return ["open", "label", "breakpoint"];
|
|
9501
|
+
}
|
|
9502
|
+
_button = null;
|
|
9503
|
+
/**
|
|
9504
|
+
* Watches the element's own children. The button is the one child that is not the host's,
|
|
9505
|
+
* so it is the one a framework reconciling the others knows nothing about: Vue's
|
|
9506
|
+
* hydration removes "more child nodes than client vdom", Svelte 4's removes what its
|
|
9507
|
+
* claim did not take. Without this it stays removed — a closed launcher then shows
|
|
9508
|
+
* nothing, and nothing can open the chat.
|
|
9509
|
+
*/
|
|
9510
|
+
_childWatch = null;
|
|
9511
|
+
/**
|
|
9512
|
+
* Watches for a config boundary appearing, changing or leaving inside the element. A
|
|
9513
|
+
* framework wrapper attaches its chat's `config` from a post-mount hook, after the
|
|
9514
|
+
* launcher has connected and drawn its button, and `attachConfig` tells the elements
|
|
9515
|
+
* INSIDE the boundary, never the launcher around it.
|
|
9516
|
+
*/
|
|
9517
|
+
_hostWatch = null;
|
|
9518
|
+
_media = null;
|
|
9519
|
+
_lastOpen = null;
|
|
9520
|
+
/**
|
|
9521
|
+
* `connectedCallback` has run. During an UPGRADE `attributeChangedCallback` fires for
|
|
9522
|
+
* every authored attribute before it — `<aparte-launcher open>` server-rendered and
|
|
9523
|
+
* upgraded when the module loads — and announcing a toggle there tells the host its
|
|
9524
|
+
* chat just opened when all that happened is that the markup was read.
|
|
9525
|
+
*/
|
|
9526
|
+
_ready = false;
|
|
9527
|
+
/** The chat is open. */
|
|
9528
|
+
get open() {
|
|
9529
|
+
return this.hasAttribute("open");
|
|
9530
|
+
}
|
|
9531
|
+
set open(value) {
|
|
9532
|
+
this.toggleAttribute("open", presenceOn(value));
|
|
9533
|
+
}
|
|
9534
|
+
/** True while the window is under the breakpoint, where the open chat fills it. */
|
|
9535
|
+
get sheet() {
|
|
9536
|
+
return this.hasAttribute("data-sheet");
|
|
9537
|
+
}
|
|
9538
|
+
connectedCallback() {
|
|
9539
|
+
if (!this.classList.contains("aparte-launcher")) this.classList.add("aparte-launcher");
|
|
9540
|
+
if (!this._button) {
|
|
9541
|
+
this._button = document.createElement("button");
|
|
9542
|
+
this._button.type = "button";
|
|
9543
|
+
this._button.addEventListener("click", this._onButtonClick);
|
|
9544
|
+
}
|
|
9545
|
+
this.appendChild(this._button);
|
|
9546
|
+
if (typeof MutationObserver === "function") {
|
|
9547
|
+
this._childWatch ??= new MutationObserver(() => this._keepButton());
|
|
9548
|
+
this._childWatch.observe(this, { childList: true });
|
|
9549
|
+
this._hostWatch ??= new MutationObserver(() => this._renderButton());
|
|
9550
|
+
this._hostWatch.observe(this, { attributes: true, attributeFilter: [APARTE_HOST_ATTR], subtree: true });
|
|
9551
|
+
}
|
|
9552
|
+
this.addEventListener("click", this._onClick);
|
|
9553
|
+
this.addEventListener("keydown", this._onKeydown);
|
|
9554
|
+
window.addEventListener("aparte-config-change", this._onConfigChange);
|
|
9555
|
+
this._watchBreakpoint();
|
|
9556
|
+
this._lastOpen = this.open;
|
|
9557
|
+
this._renderButton();
|
|
9558
|
+
this._ready = true;
|
|
9559
|
+
}
|
|
9560
|
+
disconnectedCallback() {
|
|
9561
|
+
this.removeEventListener("click", this._onClick);
|
|
9562
|
+
this.removeEventListener("keydown", this._onKeydown);
|
|
9563
|
+
window.removeEventListener("aparte-config-change", this._onConfigChange);
|
|
9564
|
+
this._childWatch?.disconnect();
|
|
9565
|
+
this._hostWatch?.disconnect();
|
|
9566
|
+
this._media?.removeEventListener("change", this._onMediaChange);
|
|
9567
|
+
this._media = null;
|
|
9568
|
+
this._ready = false;
|
|
9569
|
+
}
|
|
9570
|
+
attributeChangedCallback(name) {
|
|
9571
|
+
if (!this._ready) return;
|
|
9572
|
+
if (name === "breakpoint") {
|
|
9573
|
+
this._watchBreakpoint();
|
|
9574
|
+
return;
|
|
9575
|
+
}
|
|
9576
|
+
this._renderButton();
|
|
9577
|
+
if (name !== "open") return;
|
|
9578
|
+
const open = this.open;
|
|
9579
|
+
if (open === this._lastOpen) return;
|
|
9580
|
+
this._lastOpen = open;
|
|
9581
|
+
if (!open && this._button && this.contains(activeElementIn(this))) this._button.focus();
|
|
9582
|
+
this._announce();
|
|
9583
|
+
}
|
|
9584
|
+
_announce() {
|
|
9585
|
+
this.dispatchEvent(new CustomEvent("aparte-launcher-toggle", {
|
|
9586
|
+
detail: { open: this.open, sheet: this.sheet },
|
|
9587
|
+
bubbles: true,
|
|
9588
|
+
composed: true
|
|
9589
|
+
}));
|
|
9590
|
+
}
|
|
9591
|
+
// ─── Public API ───────────────────────────────────────────────────────
|
|
9592
|
+
/** Open the chat. */
|
|
9593
|
+
show() {
|
|
9594
|
+
this.open = true;
|
|
9595
|
+
}
|
|
9596
|
+
/** Close the chat. */
|
|
9597
|
+
close() {
|
|
9598
|
+
this.open = false;
|
|
9599
|
+
}
|
|
9600
|
+
/** Open the chat when it is closed, close it when it is open. */
|
|
9601
|
+
toggle() {
|
|
9602
|
+
this.open = !this.open;
|
|
9603
|
+
}
|
|
9604
|
+
// ─── Button ───────────────────────────────────────────────────────────
|
|
9605
|
+
/**
|
|
9606
|
+
* The one opening that is a person's: the composer takes the focus, since they opened the
|
|
9607
|
+
* chat to write. `show()` and `open` are a script's — a page restoring the state it saved,
|
|
9608
|
+
* a host driving `open` from its own state — and a focus that jumps on page load is
|
|
9609
|
+
* unasked for, and on a phone raises the keyboard over a sheet nobody pressed. An authored
|
|
9610
|
+
* `open` never took the focus either, so the three ways of starting open now agree.
|
|
9611
|
+
*/
|
|
9612
|
+
_onButtonClick = () => {
|
|
9613
|
+
const opening = !this.open;
|
|
9614
|
+
this.toggle();
|
|
9615
|
+
if (opening) this._focusChat();
|
|
9616
|
+
};
|
|
9617
|
+
_onConfigChange = () => this._renderButton();
|
|
9618
|
+
/**
|
|
9619
|
+
* The config the button answers to: the chat's own when the chat inside carries an
|
|
9620
|
+
* instance config (a wrapper's `config` prop, `attachConfig(chat, config)`), else the
|
|
9621
|
+
* one at the launcher's own place — an ancestor's boundary, or the page's. The button
|
|
9622
|
+
* labels and draws a control of THAT chat, and the chat's boundary is below the launcher,
|
|
9623
|
+
* so resolving from the launcher alone read the page's locale and icons next to a chat
|
|
9624
|
+
* in another language. Resolved live, never kept: the boundary may arrive after connect.
|
|
9625
|
+
*/
|
|
9626
|
+
_config() {
|
|
9627
|
+
return resolveConfig(this.querySelector(`[${APARTE_HOST_ATTR}]`) ?? this);
|
|
9628
|
+
}
|
|
9629
|
+
/**
|
|
9630
|
+
* The button is a child of the element, whatever was done to the children since: put
|
|
9631
|
+
* back at the end when something took it out. A button that is still a child stays
|
|
9632
|
+
* where it is, since the host may have placed it. Called on every render, and from the
|
|
9633
|
+
* observer for the removal that comes with no render at all.
|
|
9634
|
+
*/
|
|
9635
|
+
_keepButton() {
|
|
9636
|
+
if (this._button && this._button.parentNode !== this) this.appendChild(this._button);
|
|
9637
|
+
}
|
|
9638
|
+
/**
|
|
9639
|
+
* The button, for the state it is in: the bubble (and the label, as a pill) while
|
|
9640
|
+
* closed, a close glyph while open. Its name comes from the locale when it shows no
|
|
9641
|
+
* text, and from that text when it does — a visible label the name did not contain
|
|
9642
|
+
* is what speech users cannot say to press it. `aria-expanded` is the disclosure's whole
|
|
9643
|
+
* contract: there is no `aria-controls`, since the one element it could name without
|
|
9644
|
+
* writing an id on the host's card is the launcher itself, the button's own ancestor.
|
|
9645
|
+
*/
|
|
9646
|
+
_renderButton() {
|
|
9647
|
+
const button = this._button;
|
|
9648
|
+
if (!button) return;
|
|
9649
|
+
this._keepButton();
|
|
9650
|
+
const config = this._config();
|
|
9651
|
+
const locale = config.getLocale();
|
|
9652
|
+
const open = this.open;
|
|
9653
|
+
const label = open ? "" : (this.getAttribute("label") ?? "").trim();
|
|
9654
|
+
const shape = label ? "aparte-btn--pill" : "aparte-btn--circle";
|
|
9655
|
+
button.className = ["aparte-btn", "aparte-btn--primary", "aparte-btn--solid", "aparte-btn--lg", shape, "aparte-launcher__button"].join(" ");
|
|
9656
|
+
button.setAttribute("aria-expanded", String(open));
|
|
9657
|
+
if (label) button.removeAttribute("aria-label");
|
|
9658
|
+
else button.setAttribute("aria-label", open ? locale.launcherClose ?? "Close the chat" : locale.launcherOpen ?? "Open the chat");
|
|
9659
|
+
const icon = document.createElement("span");
|
|
9660
|
+
icon.className = "aparte-launcher__icon";
|
|
9661
|
+
icon.setAttribute("aria-hidden", "true");
|
|
9662
|
+
icon.innerHTML = open ? config.getIcon("launcherClose") ?? config.getIcon("close") : config.getIcon("launcherOpen") ?? config.getIcon("messageSquare");
|
|
9663
|
+
const parts = [icon];
|
|
9664
|
+
if (label) {
|
|
9665
|
+
const text = document.createElement("span");
|
|
9666
|
+
text.className = "aparte-launcher__label";
|
|
9667
|
+
text.textContent = label;
|
|
9668
|
+
parts.push(text);
|
|
9669
|
+
}
|
|
9670
|
+
button.replaceChildren(...parts);
|
|
9671
|
+
}
|
|
9672
|
+
// ─── Sheet ────────────────────────────────────────────────────────────
|
|
9673
|
+
_onMediaChange = (e) => this._applySheet(e.matches);
|
|
9674
|
+
/** The sheet's media query, from `breakpoint`: a length, or `none` for a card at any width. */
|
|
9675
|
+
_watchBreakpoint() {
|
|
9676
|
+
this._media?.removeEventListener("change", this._onMediaChange);
|
|
9677
|
+
this._media = null;
|
|
9678
|
+
const attr = (this.getAttribute("breakpoint") ?? "").trim();
|
|
9679
|
+
if (attr === "none" || typeof matchMedia !== "function") {
|
|
9680
|
+
this._applySheet(false);
|
|
9681
|
+
return;
|
|
9682
|
+
}
|
|
9683
|
+
this._media = matchMedia(attr ? `(max-width: ${attr})` : SHEET_QUERY);
|
|
9684
|
+
this._media.addEventListener("change", this._onMediaChange);
|
|
9685
|
+
this._applySheet(this._media.matches);
|
|
9686
|
+
}
|
|
9687
|
+
/**
|
|
9688
|
+
* An open chat that turns into a sheet now covers the page, and one that turns back no
|
|
9689
|
+
* longer does: announced, so a host that takes its page out of reach under the sheet
|
|
9690
|
+
* follows the window without a media query of its own, which would be a second copy
|
|
9691
|
+
* of `breakpoint` to keep in step.
|
|
9692
|
+
*/
|
|
9693
|
+
_applySheet(sheet) {
|
|
9694
|
+
if (sheet === this.sheet) return;
|
|
9695
|
+
this.toggleAttribute("data-sheet", sheet);
|
|
9696
|
+
if (this._ready && this.open) this._announce();
|
|
9697
|
+
}
|
|
9698
|
+
// ─── Focus and keys ───────────────────────────────────────────────────
|
|
9699
|
+
/** What the chat lets the focus land on: yours to decide, so only what is visible. */
|
|
9700
|
+
_focusables() {
|
|
9701
|
+
return Array.from(this.querySelectorAll(FOCUSABLE)).filter((el2) => !el2.closest("[hidden]") && el2.checkVisibility?.() !== false);
|
|
9702
|
+
}
|
|
9703
|
+
/**
|
|
9704
|
+
* The composer when there is one — the person opened the chat to write — else the
|
|
9705
|
+
* first thing in the card that holds focus. The button itself never: it is what the
|
|
9706
|
+
* person just pressed.
|
|
9707
|
+
*/
|
|
9708
|
+
_focusChat() {
|
|
9709
|
+
const composer = Array.from(this.querySelectorAll('[role="textbox"]:not([aria-disabled="true"])')).find((el2) => !el2.closest("[hidden]") && el2.checkVisibility?.() !== false);
|
|
9710
|
+
const target = composer ?? this._focusables().find((el2) => el2 !== this._button);
|
|
9711
|
+
target?.focus();
|
|
9712
|
+
}
|
|
9713
|
+
/** A `[data-aparte-launcher-close]` inside closes the chat — no script in your card. */
|
|
9714
|
+
_onClick = (e) => {
|
|
9715
|
+
const control = eventOrigin(e)?.closest?.("[data-aparte-launcher-close]");
|
|
9716
|
+
if (control && this.contains(control)) this.close();
|
|
9717
|
+
};
|
|
9718
|
+
/**
|
|
9719
|
+
* A modal dialog open inside the card, with the key pressed inside it. The browser
|
|
9720
|
+
* closes it on Escape — unless the keydown was cancelled, which is what closing the
|
|
9721
|
+
* launcher would do: the dialog refused its close request and the card hidden under it.
|
|
9722
|
+
* An engine that cannot tell a modal dialog from one opened with `show()` (no `:modal`)
|
|
9723
|
+
* leaves the key to the dialog, which is the answer that loses nothing.
|
|
9724
|
+
*/
|
|
9725
|
+
_inModalDialog(e) {
|
|
9726
|
+
const dialog = eventOrigin(e)?.closest?.("dialog[open]");
|
|
9727
|
+
if (!dialog || !this.contains(dialog)) return false;
|
|
9728
|
+
try {
|
|
9729
|
+
return dialog.matches(":modal");
|
|
9730
|
+
} catch {
|
|
9731
|
+
return true;
|
|
9732
|
+
}
|
|
9733
|
+
}
|
|
9734
|
+
_onKeydown = (e) => {
|
|
9735
|
+
if (!this.open) return;
|
|
9736
|
+
if (e.key === "Escape") {
|
|
9737
|
+
if (e.defaultPrevented || e.isComposing || e.keyCode === 229 || this._inModalDialog(e)) return;
|
|
9738
|
+
e.preventDefault();
|
|
9739
|
+
this.close();
|
|
9740
|
+
return;
|
|
9741
|
+
}
|
|
9742
|
+
if (e.key !== "Tab" || !this.sheet) return;
|
|
9743
|
+
const focusable = this._focusables();
|
|
9744
|
+
if (focusable.length === 0) return;
|
|
9745
|
+
const first = focusable[0];
|
|
9746
|
+
const last = focusable[focusable.length - 1];
|
|
9747
|
+
const active = activeElementIn(this);
|
|
9748
|
+
if (e.shiftKey && active === first) {
|
|
9749
|
+
e.preventDefault();
|
|
9750
|
+
last.focus();
|
|
9751
|
+
} else if (!e.shiftKey && active === last) {
|
|
9752
|
+
e.preventDefault();
|
|
9753
|
+
first.focus();
|
|
9754
|
+
}
|
|
9755
|
+
};
|
|
9756
|
+
}
|
|
9757
|
+
deferHydrationOf(AparteLauncher);
|
|
9758
|
+
if (!customElements.get("aparte-launcher")) {
|
|
9759
|
+
customElements.define("aparte-launcher", AparteLauncher);
|
|
9760
|
+
}
|
|
8722
9761
|
const APARTE_ELEMENTS = [
|
|
8723
9762
|
// Chat shell + transcript
|
|
8724
9763
|
["aparte-chat", AparteChat],
|
|
@@ -8740,6 +9779,7 @@ const APARTE_ELEMENTS = [
|
|
|
8740
9779
|
["aparte-scroll-rail", AparteScrollRail],
|
|
8741
9780
|
["aparte-sidebar", AparteSidebar],
|
|
8742
9781
|
["aparte-split", AparteSplit],
|
|
9782
|
+
["aparte-launcher", AparteLauncher],
|
|
8743
9783
|
["aparte-suggestions", AparteSuggestions],
|
|
8744
9784
|
["aparte-context", AparteContext],
|
|
8745
9785
|
// Primitives
|
|
@@ -8766,7 +9806,7 @@ export {
|
|
|
8766
9806
|
d as APARTE_DEFAULT_ICON_FALLBACKS,
|
|
8767
9807
|
APARTE_DEFAULT_LOCALE,
|
|
8768
9808
|
f as APARTE_DEFAULT_UI_EVENTS,
|
|
8769
|
-
|
|
9809
|
+
APARTE_HOST_ATTR,
|
|
8770
9810
|
h as AparteBackendTransport,
|
|
8771
9811
|
AparteChat,
|
|
8772
9812
|
AparteChatBubble,
|
|
@@ -8791,8 +9831,9 @@ export {
|
|
|
8791
9831
|
AparteElicitation,
|
|
8792
9832
|
AparteElicitationAbortError,
|
|
8793
9833
|
p as AparteError,
|
|
8794
|
-
|
|
9834
|
+
AparteErrorCode,
|
|
8795
9835
|
AparteIcon,
|
|
9836
|
+
AparteLauncher,
|
|
8796
9837
|
AparteMessageRepository,
|
|
8797
9838
|
AparteOptgroup,
|
|
8798
9839
|
AparteOption,
|
|
@@ -8825,34 +9866,38 @@ export {
|
|
|
8825
9866
|
N as detachConfig,
|
|
8826
9867
|
escapeAttr,
|
|
8827
9868
|
escapeHtml,
|
|
8828
|
-
Q as
|
|
8829
|
-
R as
|
|
9869
|
+
Q as estimateTokens,
|
|
9870
|
+
R as estimateWireTokens,
|
|
9871
|
+
S as filesToAttachments,
|
|
9872
|
+
T as getAllRenderers,
|
|
8830
9873
|
getSegmentRenderer,
|
|
9874
|
+
V as historyFromCheckpoint,
|
|
8831
9875
|
installDefaultRenderersOnce,
|
|
8832
9876
|
installDialogTriggersOnce,
|
|
8833
9877
|
isAwaitingReply,
|
|
8834
|
-
|
|
9878
|
+
Z as isFormatAdapter,
|
|
8835
9879
|
isSafeUrl,
|
|
8836
9880
|
isSegmentSettled,
|
|
8837
|
-
|
|
8838
|
-
|
|
9881
|
+
measureContext,
|
|
9882
|
+
a1 as overrideSegmentRenderer,
|
|
9883
|
+
a2 as parseAparteEventStream,
|
|
8839
9884
|
parseMarkdownToSegments,
|
|
8840
9885
|
populateBubbleFromMessage,
|
|
8841
|
-
|
|
9886
|
+
a5 as readableToAsyncIterable,
|
|
8842
9887
|
registerAllComponents,
|
|
8843
|
-
|
|
8844
|
-
|
|
8845
|
-
|
|
8846
|
-
|
|
9888
|
+
a6 as registerDefaultRenderers,
|
|
9889
|
+
a7 as registerSegmentRenderer,
|
|
9890
|
+
a8 as releaseDeferredHydration,
|
|
9891
|
+
a9 as requestUserInput,
|
|
8847
9892
|
resolveConfig,
|
|
8848
9893
|
revokeAttachmentUrls,
|
|
8849
9894
|
runWithConfig,
|
|
8850
|
-
|
|
8851
|
-
|
|
9895
|
+
ad as segmentDuration,
|
|
9896
|
+
ae as segmentTiming,
|
|
8852
9897
|
subscribeConfigChange,
|
|
8853
|
-
|
|
8854
|
-
|
|
8855
|
-
|
|
9898
|
+
ag as toToolCallView,
|
|
9899
|
+
ah as toolRefusal,
|
|
9900
|
+
ai as unregisterSegmentRenderer,
|
|
8856
9901
|
uuid
|
|
8857
9902
|
};
|
|
8858
9903
|
//# sourceMappingURL=index.js.map
|