@aparte/core 1.0.2 → 1.1.1
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/aparte-client.d.ts +2 -0
- package/dist/client/aparte-client.d.ts.map +1 -1
- package/dist/components/bubble/aparte-chat-bubble.d.ts +25 -0
- package/dist/components/bubble/aparte-chat-bubble.d.ts.map +1 -1
- package/dist/components/bubble/bubble-sync.d.ts +2 -1
- package/dist/components/bubble/bubble-sync.d.ts.map +1 -1
- package/dist/components/bubble/feedback-reasons.d.ts +13 -0
- package/dist/components/bubble/feedback-reasons.d.ts.map +1 -0
- package/dist/components/bubble/message-tokens.d.ts +10 -0
- package/dist/components/bubble/message-tokens.d.ts.map +1 -0
- package/dist/components/bubble/turn-groups.d.ts +24 -0
- package/dist/components/bubble/turn-groups.d.ts.map +1 -0
- package/dist/components/composer/aparte-composer-attachments.d.ts +3 -0
- package/dist/components/composer/aparte-composer-attachments.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-input.d.ts +29 -0
- package/dist/components/composer/aparte-composer-input.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-toolbar.d.ts +4 -0
- package/dist/components/composer/aparte-composer-toolbar.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer.d.ts +15 -3
- package/dist/components/composer/aparte-composer.d.ts.map +1 -1
- package/dist/components/composer/composer-tokens.d.ts +21 -0
- package/dist/components/composer/composer-tokens.d.ts.map +1 -0
- package/dist/components/conversation-list/aparte-conversation-list.d.ts.map +1 -1
- package/dist/components/viewport/aparte-chat-viewport.d.ts +2 -0
- package/dist/components/viewport/aparte-chat-viewport.d.ts.map +1 -1
- package/dist/config/aparte-config.d.ts +24 -1
- package/dist/config/aparte-config.d.ts.map +1 -1
- package/dist/config/locale.d.ts +44 -0
- package/dist/config/locale.d.ts.map +1 -1
- package/dist/conversations/conversation-controller.d.ts +19 -0
- package/dist/conversations/conversation-controller.d.ts.map +1 -1
- package/dist/conversations/conversation-manager.d.ts +2 -0
- package/dist/conversations/conversation-manager.d.ts.map +1 -1
- package/dist/conversations/types.d.ts +4 -0
- package/dist/conversations/types.d.ts.map +1 -1
- package/dist/custom-elements.json +1545 -6
- package/dist/{defer-hydration-_SZv5PeY.js → defer-hydration-BBdqAZej.js} +252 -61
- package/dist/defer-hydration-BBdqAZej.js.map +1 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +605 -94
- package/dist/index.js.map +1 -1
- package/dist/index.node.d.ts +3 -1
- package/dist/index.node.d.ts.map +1 -1
- package/dist/index.node.js +21 -20
- 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/types/chat.d.ts +3 -0
- package/dist/types/chat.d.ts.map +1 -1
- package/dist/types/event-map.d.ts +4 -1
- package/dist/types/event-map.d.ts.map +1 -1
- package/dist/types/events.d.ts +93 -1
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/model-provider.d.ts +6 -0
- package/dist/types/model-provider.d.ts.map +1 -1
- package/dist/types/models.d.ts +44 -0
- package/dist/types/models.d.ts.map +1 -1
- package/dist/utils/place-floating.d.ts +20 -0
- package/dist/utils/place-floating.d.ts.map +1 -0
- package/dist/utils/plural.d.ts +7 -0
- package/dist/utils/plural.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/defer-hydration-_SZv5PeY.js.map +0 -1
|
@@ -157,6 +157,28 @@ const APARTE_DEFAULT_LOCALE = {
|
|
|
157
157
|
artifactNotCreated: "Not created",
|
|
158
158
|
thoughtFor: "Thought for {duration}",
|
|
159
159
|
thought: "Thought",
|
|
160
|
+
turnWorking: "Working…",
|
|
161
|
+
turnWorked: "Worked {duration}",
|
|
162
|
+
turnUsed: "Used {tools}",
|
|
163
|
+
turnTools: "one:{n} tool|other:{n} tools",
|
|
164
|
+
feedbackReasonTitle: "What went wrong?",
|
|
165
|
+
feedbackReasonDismiss: "Not now",
|
|
166
|
+
triggersLoading: "Loading…",
|
|
167
|
+
triggersEmpty: "No results",
|
|
168
|
+
triggersError: "This list could not be loaded",
|
|
169
|
+
triggersRetry: "Try again",
|
|
170
|
+
triggersBack: "Back",
|
|
171
|
+
triggersCommandNew: "Start a new conversation",
|
|
172
|
+
triggersCommandStop: "Stop the reply",
|
|
173
|
+
triggersCommandRetry: "Answer again",
|
|
174
|
+
triggersCommandCopy: "Copy the last reply",
|
|
175
|
+
triggersCommandCompact: "Summarise the earlier messages",
|
|
176
|
+
triggersCompactNothing: "There is nothing to compact yet",
|
|
177
|
+
triggersCompactBusy: "Wait for the reply to finish",
|
|
178
|
+
triggersCompactNoWindow: "This model does not say how much it can read",
|
|
179
|
+
triggersCompactFailed: "The summary could not be written",
|
|
180
|
+
triggersCommandModel: "Change the model",
|
|
181
|
+
triggersCommandApproval: "Change the approval mode",
|
|
160
182
|
approvalOptionsLabel: "Your decision",
|
|
161
183
|
approvalArgsLabel: "Arguments",
|
|
162
184
|
actionUpload: "Attach file",
|
|
@@ -4929,6 +4951,9 @@ class AparteConfig {
|
|
|
4929
4951
|
// Bubble Actions — APARTE_DEFAULT_BUBBLE_ACTIONS is the single source of truth
|
|
4930
4952
|
// (init here, restored by reset(), and the fallback in getBubbleActions()).
|
|
4931
4953
|
_bubbleActionsConfig = { ...APARTE_DEFAULT_BUBBLE_ACTIONS };
|
|
4954
|
+
_turnSummary = null;
|
|
4955
|
+
_streamingCaret = false;
|
|
4956
|
+
_dateSeparators = false;
|
|
4932
4957
|
// ─────────────────────────────────────────────────────────────────────────
|
|
4933
4958
|
// Provider Setters (Dependency Injection)
|
|
4934
4959
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -4974,6 +4999,41 @@ class AparteConfig {
|
|
|
4974
4999
|
this._bubbleActionsConfig = { ...this._bubbleActionsConfig, ...config };
|
|
4975
5000
|
this._notify();
|
|
4976
5001
|
}
|
|
5002
|
+
/**
|
|
5003
|
+
* Fold the steps of a reply behind one line: a run of reasoning and tool calls between two
|
|
5004
|
+
* pieces of text becomes "Worked 9 s · 7 tools", which opens on the usual rows. A call
|
|
5005
|
+
* waiting for approval, a call that failed and a tool drawn by its own renderer stay out
|
|
5006
|
+
* of the fold. Off by default; `false` turns it off again.
|
|
5007
|
+
*
|
|
5008
|
+
* @example
|
|
5009
|
+
* aparteGlobalConfig.setTurnSummary(true);
|
|
5010
|
+
* aparteGlobalConfig.setTurnSummary({ openWhileRunning: true }); // watch the steps, folded at the end
|
|
5011
|
+
*/
|
|
5012
|
+
setTurnSummary(options) {
|
|
5013
|
+
this._turnSummary = options === false ? null : options === true ? {} : options;
|
|
5014
|
+
bumpRenderingVersion(this);
|
|
5015
|
+
this._notify();
|
|
5016
|
+
}
|
|
5017
|
+
/** Draw a blinking caret where the words of a reply are arriving. Off by default. */
|
|
5018
|
+
setStreamingCaret(on) {
|
|
5019
|
+
this._streamingCaret = on;
|
|
5020
|
+
this._notify();
|
|
5021
|
+
}
|
|
5022
|
+
getStreamingCaret() {
|
|
5023
|
+
return this._streamingCaret;
|
|
5024
|
+
}
|
|
5025
|
+
/** Draw the date above the first message of each day. Off by default. */
|
|
5026
|
+
setDateSeparators(on) {
|
|
5027
|
+
this._dateSeparators = on;
|
|
5028
|
+
this._notify();
|
|
5029
|
+
}
|
|
5030
|
+
getDateSeparators() {
|
|
5031
|
+
return this._dateSeparators;
|
|
5032
|
+
}
|
|
5033
|
+
/** The options {@link setTurnSummary} left, or null when replies are not folded. */
|
|
5034
|
+
getTurnSummary() {
|
|
5035
|
+
return this._turnSummary;
|
|
5036
|
+
}
|
|
4977
5037
|
/**
|
|
4978
5038
|
* Declare which host-dependent affordances your app handles. Core renders the
|
|
4979
5039
|
* trigger only for the ones you claim — see {@link AparteHostHandlersConfig}.
|
|
@@ -5005,6 +5065,7 @@ class AparteConfig {
|
|
|
5005
5065
|
edit: this._bubbleActionsConfig.edit ?? APARTE_DEFAULT_BUBBLE_ACTIONS.edit,
|
|
5006
5066
|
feedback: this._bubbleActionsConfig.feedback ?? APARTE_DEFAULT_BUBBLE_ACTIONS.feedback,
|
|
5007
5067
|
info: this._bubbleActionsConfig.info ?? APARTE_DEFAULT_BUBBLE_ACTIONS.info,
|
|
5068
|
+
feedbackReasons: this._bubbleActionsConfig.feedbackReasons,
|
|
5008
5069
|
user: this._bubbleActionsConfig.user,
|
|
5009
5070
|
assistant: this._bubbleActionsConfig.assistant
|
|
5010
5071
|
};
|
|
@@ -6381,6 +6442,9 @@ class AparteConfig {
|
|
|
6381
6442
|
this._approvalPolicy = null;
|
|
6382
6443
|
this._compactor = null;
|
|
6383
6444
|
this._bubbleActionsConfig = { ...APARTE_DEFAULT_BUBBLE_ACTIONS };
|
|
6445
|
+
this._turnSummary = null;
|
|
6446
|
+
this._streamingCaret = false;
|
|
6447
|
+
this._dateSeparators = false;
|
|
6384
6448
|
this._hostHandlers = { ...APARTE_DEFAULT_HOST_HANDLERS };
|
|
6385
6449
|
this._notify();
|
|
6386
6450
|
}
|
|
@@ -6571,6 +6635,7 @@ function withLastArriving(message) {
|
|
|
6571
6635
|
return [...segments.slice(0, -1), { ...last, isStreaming: true }];
|
|
6572
6636
|
}
|
|
6573
6637
|
function populateBubbleFromMessage(bubble, message, siblingInfo) {
|
|
6638
|
+
bubble.setTokens?.(message.tokens);
|
|
6574
6639
|
if (message.segments && message.segments.length > 0) {
|
|
6575
6640
|
const existing = bubble.getSegments?.() ?? [];
|
|
6576
6641
|
if (existing.length === message.segments.length) {
|
|
@@ -6687,6 +6752,10 @@ class AparteConversationManager {
|
|
|
6687
6752
|
_appending = /* @__PURE__ */ new Map();
|
|
6688
6753
|
/** The list on its way: a conversation created meanwhile waits for it, or the list would replace it. */
|
|
6689
6754
|
_initPromise = null;
|
|
6755
|
+
/** The store this manager writes to. */
|
|
6756
|
+
get adapter() {
|
|
6757
|
+
return this._adapter;
|
|
6758
|
+
}
|
|
6690
6759
|
constructor(adapter, options) {
|
|
6691
6760
|
this._adapter = adapter;
|
|
6692
6761
|
this._retention = options?.retention ?? null;
|
|
@@ -7067,6 +7136,9 @@ class AparteConversationManager {
|
|
|
7067
7136
|
return (msg.content ?? "").trim();
|
|
7068
7137
|
}
|
|
7069
7138
|
}
|
|
7139
|
+
function cssEscape(value) {
|
|
7140
|
+
return value.replace(/["\\]/g, "\\$&").replace(/[\n\r\f]/g, (c) => `\\${c.charCodeAt(0).toString(16)} `);
|
|
7141
|
+
}
|
|
7070
7142
|
function filesToAttachments(files) {
|
|
7071
7143
|
return files.map((file) => ({
|
|
7072
7144
|
id: uuid(),
|
|
@@ -7235,6 +7307,7 @@ class AparteConversationController {
|
|
|
7235
7307
|
const evt = e;
|
|
7236
7308
|
const targetId = evt.detail?.targetId;
|
|
7237
7309
|
if (targetId && targetId !== this._binding.hostId) return;
|
|
7310
|
+
this._forgetDraft();
|
|
7238
7311
|
const content = evt.detail?.content ?? "";
|
|
7239
7312
|
const files = evt.detail?.files;
|
|
7240
7313
|
const attachments = files?.length ? filesToAttachments(files) : void 0;
|
|
@@ -7243,7 +7316,9 @@ class AparteConversationController {
|
|
|
7243
7316
|
role: "user",
|
|
7244
7317
|
content,
|
|
7245
7318
|
timestamp: evt.detail?.timestamp ?? Date.now(),
|
|
7246
|
-
...attachments ? { attachments } : {}
|
|
7319
|
+
...attachments ? { attachments } : {},
|
|
7320
|
+
...evt.detail?.tokens?.length ? { tokens: evt.detail.tokens } : {},
|
|
7321
|
+
...evt.detail?.meta ? { metadata: evt.detail.meta } : {}
|
|
7247
7322
|
};
|
|
7248
7323
|
this._binding.appendMessage(userMsg);
|
|
7249
7324
|
evt.detail.echoed = true;
|
|
@@ -7381,6 +7456,71 @@ class AparteConversationController {
|
|
|
7381
7456
|
* reload never kills an in-flight response.
|
|
7382
7457
|
*/
|
|
7383
7458
|
async setConversationId(id) {
|
|
7459
|
+
if (!this._options.keepDrafts || id === this._activeId) {
|
|
7460
|
+
await this._openConversation(id);
|
|
7461
|
+
return;
|
|
7462
|
+
}
|
|
7463
|
+
const call = ++this._draftCalls;
|
|
7464
|
+
if (!this._draftAway) this._stashDraft();
|
|
7465
|
+
this._draftAway = true;
|
|
7466
|
+
try {
|
|
7467
|
+
await this._openConversation(id);
|
|
7468
|
+
} finally {
|
|
7469
|
+
if (call === this._draftCalls) this._draftAway = false;
|
|
7470
|
+
}
|
|
7471
|
+
if (call === this._draftCalls) await this._restoreDraft(call);
|
|
7472
|
+
}
|
|
7473
|
+
/** Drafts by conversation; the empty key is a chat that has no conversation yet. */
|
|
7474
|
+
_drafts = /* @__PURE__ */ new Map();
|
|
7475
|
+
_draftCalls = 0;
|
|
7476
|
+
_draftAway = false;
|
|
7477
|
+
get _composer() {
|
|
7478
|
+
const { host: host2, hostId } = this._binding;
|
|
7479
|
+
return host2.querySelector("aparte-composer") ?? document.querySelector(`aparte-composer[target="${cssEscape(hostId)}"]`);
|
|
7480
|
+
}
|
|
7481
|
+
_stashDraft() {
|
|
7482
|
+
if (!this._options.keepDrafts) return;
|
|
7483
|
+
const composer = this._composer;
|
|
7484
|
+
if (!composer) return;
|
|
7485
|
+
const key = this._activeId ?? "";
|
|
7486
|
+
const text = composer.value;
|
|
7487
|
+
if (text) this._drafts.set(key, text);
|
|
7488
|
+
else this._drafts.delete(key);
|
|
7489
|
+
this._saveDraft(key, text);
|
|
7490
|
+
}
|
|
7491
|
+
/** A message was sent: what it was drafted from must not come back, in this tab or the next. */
|
|
7492
|
+
_forgetDraft() {
|
|
7493
|
+
if (!this._options.keepDrafts) return;
|
|
7494
|
+
const key = this._activeId ?? "";
|
|
7495
|
+
this._drafts.delete(key);
|
|
7496
|
+
this._saveDraft(key, "");
|
|
7497
|
+
}
|
|
7498
|
+
/** A store that fails loses a draft, and nothing else. */
|
|
7499
|
+
_saveDraft(key, text) {
|
|
7500
|
+
const adapter = this._draftAdapter();
|
|
7501
|
+
if (!key || !adapter) return;
|
|
7502
|
+
Promise.resolve().then(() => adapter.saveDraft(key, text)).catch((error) => {
|
|
7503
|
+
console.warn("[ConversationController] the draft could not be saved:", key, error);
|
|
7504
|
+
});
|
|
7505
|
+
}
|
|
7506
|
+
async _restoreDraft(call) {
|
|
7507
|
+
const key = this._activeId ?? "";
|
|
7508
|
+
const adapter = this._draftAdapter();
|
|
7509
|
+
let text = this._drafts.get(key);
|
|
7510
|
+
if (text === void 0 && key && adapter) {
|
|
7511
|
+
try {
|
|
7512
|
+
text = await adapter.loadDraft(key) ?? "";
|
|
7513
|
+
} catch (error) {
|
|
7514
|
+
console.warn("[ConversationController] the draft could not be read:", key, error);
|
|
7515
|
+
}
|
|
7516
|
+
}
|
|
7517
|
+
if (call === this._draftCalls) this._composer?.setValue(text ?? "");
|
|
7518
|
+
}
|
|
7519
|
+
_draftAdapter() {
|
|
7520
|
+
const adapter = this._manager()?.adapter ?? null;
|
|
7521
|
+
return adapter?.loadDraft && adapter.saveDraft ? adapter : null;
|
|
7522
|
+
}
|
|
7523
|
+
async _openConversation(id) {
|
|
7384
7524
|
const isSwitch = id !== this._activeId;
|
|
7385
7525
|
const manager = this._manager();
|
|
7386
7526
|
if (isSwitch && this._isStreaming) {
|
|
@@ -7597,9 +7737,6 @@ class AparteConversationController {
|
|
|
7597
7737
|
if (!this._isStreaming && this._activeId === convId) this._persistActive();
|
|
7598
7738
|
}
|
|
7599
7739
|
}
|
|
7600
|
-
function cssEscape(value) {
|
|
7601
|
-
return value.replace(/["\\]/g, "\\$&").replace(/[\n\r\f]/g, (c) => `\\${c.charCodeAt(0).toString(16)} `);
|
|
7602
|
-
}
|
|
7603
7740
|
function gateGlide(el2) {
|
|
7604
7741
|
if (el2.hasAttribute("data-glide")) return () => {
|
|
7605
7742
|
};
|
|
@@ -9287,6 +9424,17 @@ function remoteProvider(id) {
|
|
|
9287
9424
|
}
|
|
9288
9425
|
};
|
|
9289
9426
|
}
|
|
9427
|
+
function tokensStillIn(content, tokens) {
|
|
9428
|
+
const kept = [];
|
|
9429
|
+
let from = 0;
|
|
9430
|
+
for (const token of [...tokens].sort((a, b) => a.start - b.start)) {
|
|
9431
|
+
const start = content.indexOf(token.text, from);
|
|
9432
|
+
if (start < 0) continue;
|
|
9433
|
+
from = start + token.text.length;
|
|
9434
|
+
kept.push({ ...token, start, end: from });
|
|
9435
|
+
}
|
|
9436
|
+
return kept;
|
|
9437
|
+
}
|
|
9290
9438
|
class AparteClient {
|
|
9291
9439
|
_boundHandler = null;
|
|
9292
9440
|
/** Between `start()` and `stop()`: the listeners are on `window`. The send handler alone is
|
|
@@ -9624,7 +9772,8 @@ class AparteClient {
|
|
|
9624
9772
|
modelId,
|
|
9625
9773
|
stream: true,
|
|
9626
9774
|
tools: registeredTools.length ? registeredTools : void 0,
|
|
9627
|
-
...opts?.temperature !== void 0 ? { temperature: opts.temperature } : {}
|
|
9775
|
+
...opts?.temperature !== void 0 ? { temperature: opts.temperature } : {},
|
|
9776
|
+
...opts?.meta ? { _meta: opts.meta } : {}
|
|
9628
9777
|
};
|
|
9629
9778
|
if (this.options.requestInterceptor) {
|
|
9630
9779
|
built = await this.options.requestInterceptor(built);
|
|
@@ -9846,7 +9995,8 @@ class AparteClient {
|
|
|
9846
9995
|
config.defaultModel || "",
|
|
9847
9996
|
authConfig,
|
|
9848
9997
|
{
|
|
9849
|
-
temperature:
|
|
9998
|
+
...provider.retryTemperature !== void 0 ? { temperature: provider.retryTemperature } : {},
|
|
9999
|
+
...this._turnMeta([...historyMessages].reverse().find((m) => m.role === "user")),
|
|
9850
10000
|
rebuild: async () => [
|
|
9851
10001
|
...this._systemMessages(),
|
|
9852
10002
|
...mergeAdjacentUserMessages(this._messagesToChatMessages(this._current(targetElement, historyMessages)))
|
|
@@ -9883,7 +10033,11 @@ class AparteClient {
|
|
|
9883
10033
|
console.warn("[AparteClient] aparte-edit — no target found");
|
|
9884
10034
|
return;
|
|
9885
10035
|
}
|
|
9886
|
-
targetElement.
|
|
10036
|
+
const before = targetElement.getMessages?.().find((m) => m.id === messageId);
|
|
10037
|
+
targetElement.updateMessage?.(messageId, {
|
|
10038
|
+
content: newContent,
|
|
10039
|
+
...before?.tokens ? { tokens: tokensStillIn(newContent, before.tokens) } : {}
|
|
10040
|
+
});
|
|
9887
10041
|
const allMessages = targetElement.getMessages?.() ?? [];
|
|
9888
10042
|
const editIdx = allMessages.findIndex((m) => m.id === messageId);
|
|
9889
10043
|
if (targetElement.truncateResponsesAfter) {
|
|
@@ -9918,6 +10072,7 @@ class AparteClient {
|
|
|
9918
10072
|
config.defaultModel || "",
|
|
9919
10073
|
authConfig,
|
|
9920
10074
|
{
|
|
10075
|
+
...this._turnMeta(editIdx >= 0 ? allMessages[editIdx] : void 0),
|
|
9921
10076
|
rebuild: async () => [
|
|
9922
10077
|
...this._systemMessages(),
|
|
9923
10078
|
...mergeAdjacentUserMessages(this._messagesToChatMessages(this._current(targetElement, historyMessages)))
|
|
@@ -10080,6 +10235,11 @@ class AparteClient {
|
|
|
10080
10235
|
_summaryMessage(summary) {
|
|
10081
10236
|
return summary === void 0 ? [] : [{ role: "user", content: underPreamble(summary) }];
|
|
10082
10237
|
}
|
|
10238
|
+
/** A message's tokens and metadata as a turn's `_meta`: a send and its retry say the same. */
|
|
10239
|
+
_turnMeta(asked2) {
|
|
10240
|
+
const meta = { ...asked2?.metadata ?? asked2?.meta, ...asked2?.tokens?.length ? { tokens: asked2.tokens } : {} };
|
|
10241
|
+
return Object.keys(meta).length > 0 ? { meta } : {};
|
|
10242
|
+
}
|
|
10083
10243
|
/** The "no model selected" warning is said once per client, not once per dropped send. */
|
|
10084
10244
|
_warnedNoModel = false;
|
|
10085
10245
|
async _handleSend(event) {
|
|
@@ -10130,7 +10290,9 @@ class AparteClient {
|
|
|
10130
10290
|
role: "user",
|
|
10131
10291
|
content,
|
|
10132
10292
|
timestamp: Date.now(),
|
|
10133
|
-
...echoFiles.length > 0 ? { attachments: filesToAttachments(echoFiles) } : {}
|
|
10293
|
+
...echoFiles.length > 0 ? { attachments: filesToAttachments(echoFiles) } : {},
|
|
10294
|
+
...event.detail?.tokens?.length ? { tokens: event.detail.tokens } : {},
|
|
10295
|
+
...event.detail?.meta ? { metadata: event.detail.meta } : {}
|
|
10134
10296
|
});
|
|
10135
10297
|
if (event.detail && typeof event.detail === "object") event.detail.echoed = true;
|
|
10136
10298
|
}
|
|
@@ -10189,7 +10351,8 @@ class AparteClient {
|
|
|
10189
10351
|
authConfig,
|
|
10190
10352
|
{
|
|
10191
10353
|
rebuild: async () => this._buildMessages(content, targetElement, fileParts),
|
|
10192
|
-
...rawFiles.length > 0 ? { files: rawFiles } : {}
|
|
10354
|
+
...rawFiles.length > 0 ? { files: rawFiles } : {},
|
|
10355
|
+
...this._turnMeta(event.detail)
|
|
10193
10356
|
}
|
|
10194
10357
|
);
|
|
10195
10358
|
}
|
|
@@ -11012,6 +11175,7 @@ const APARTE_DEFAULT_UI_EVENTS = [
|
|
|
11012
11175
|
"aparte-retry",
|
|
11013
11176
|
"aparte-edit",
|
|
11014
11177
|
"aparte-feedback",
|
|
11178
|
+
"aparte-feedback-reason",
|
|
11015
11179
|
"aparte-message-info",
|
|
11016
11180
|
"aparte-branch-navigate",
|
|
11017
11181
|
"aparte-link-click",
|
|
@@ -11075,6 +11239,31 @@ function isAwaitingReply(message) {
|
|
|
11075
11239
|
if (message.status === "streaming" || message.status === "pending") return true;
|
|
11076
11240
|
return message.status === void 0 && message.role === "assistant" && !message.content?.trim() && !message.segments?.length;
|
|
11077
11241
|
}
|
|
11242
|
+
function placeFloating(anchor, floating, options = {}) {
|
|
11243
|
+
const { gap = 4, margin = 8, side = "below", align = "start", rtl = false } = options;
|
|
11244
|
+
const box = floating.getBoundingClientRect();
|
|
11245
|
+
const clamp = (value, room, size) => Math.max(margin, Math.min(value, room - size - margin));
|
|
11246
|
+
let top;
|
|
11247
|
+
let left;
|
|
11248
|
+
if (side === "beside") {
|
|
11249
|
+
const after = anchor.right + gap;
|
|
11250
|
+
const before = anchor.left - box.width - gap;
|
|
11251
|
+
const [first, second] = rtl ? [before, after] : [after, before];
|
|
11252
|
+
const fits = (x) => x >= margin && x + box.width <= window.innerWidth - margin;
|
|
11253
|
+
left = fits(first) || !fits(second) ? first : second;
|
|
11254
|
+
top = anchor.top;
|
|
11255
|
+
} else {
|
|
11256
|
+
const below = anchor.bottom + gap;
|
|
11257
|
+
const above = anchor.top - box.height - gap;
|
|
11258
|
+
const fitsBelow = below + box.height <= window.innerHeight - margin;
|
|
11259
|
+
const fitsAbove = above >= margin;
|
|
11260
|
+
if (side === "below") top = fitsBelow || !fitsAbove ? below : above;
|
|
11261
|
+
else top = fitsAbove || !fitsBelow ? above : below;
|
|
11262
|
+
left = align === "start" !== rtl ? anchor.left : anchor.right - box.width;
|
|
11263
|
+
}
|
|
11264
|
+
floating.style.top = `${clamp(top, window.innerHeight, box.height)}px`;
|
|
11265
|
+
floating.style.left = `${clamp(left, window.innerWidth, box.width)}px`;
|
|
11266
|
+
}
|
|
11078
11267
|
const RENDERED_CONTENT = ".aparte-message-content, .aparte-segments, .aparte-content, .aparte-checkpoint__summary";
|
|
11079
11268
|
function inRenderedContent(el2) {
|
|
11080
11269
|
return !!el2?.closest?.(RENDERED_CONTENT);
|
|
@@ -11248,57 +11437,59 @@ export {
|
|
|
11248
11437
|
overrideSegmentRenderer as a2,
|
|
11249
11438
|
parseAparteEventStream as a3,
|
|
11250
11439
|
parseMarkdownToSegments as a4,
|
|
11251
|
-
|
|
11252
|
-
|
|
11253
|
-
|
|
11254
|
-
|
|
11255
|
-
|
|
11256
|
-
|
|
11257
|
-
|
|
11258
|
-
|
|
11259
|
-
|
|
11260
|
-
|
|
11261
|
-
|
|
11262
|
-
|
|
11263
|
-
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11269
|
-
|
|
11270
|
-
|
|
11271
|
-
|
|
11272
|
-
|
|
11273
|
-
|
|
11274
|
-
|
|
11275
|
-
|
|
11276
|
-
|
|
11277
|
-
|
|
11278
|
-
|
|
11279
|
-
|
|
11280
|
-
|
|
11281
|
-
|
|
11282
|
-
|
|
11283
|
-
|
|
11284
|
-
|
|
11285
|
-
|
|
11286
|
-
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
|
|
11290
|
-
|
|
11291
|
-
|
|
11292
|
-
|
|
11293
|
-
|
|
11294
|
-
|
|
11295
|
-
|
|
11296
|
-
|
|
11297
|
-
|
|
11298
|
-
|
|
11299
|
-
|
|
11300
|
-
|
|
11301
|
-
|
|
11440
|
+
placeFloating as a5,
|
|
11441
|
+
populateBubbleFromMessage as a6,
|
|
11442
|
+
readableToAsyncIterable as a7,
|
|
11443
|
+
registerDefaultRenderers as a8,
|
|
11444
|
+
registerSegmentRenderer as a9,
|
|
11445
|
+
renderSourceList as aA,
|
|
11446
|
+
mergeSegmentUpdate as aB,
|
|
11447
|
+
formatDuration as aC,
|
|
11448
|
+
writeStreamedMarkdown as aD,
|
|
11449
|
+
replaceHighlighted as aE,
|
|
11450
|
+
CheckpointStateWatcher as aF,
|
|
11451
|
+
chatIdOf as aG,
|
|
11452
|
+
stampSegmentActivity as aH,
|
|
11453
|
+
stampSegmentOnInsert as aI,
|
|
11454
|
+
stampSegmentOnUpdate as aJ,
|
|
11455
|
+
renumberSegments as aK,
|
|
11456
|
+
openSegmentIds as aL,
|
|
11457
|
+
isTerminalStatus as aM,
|
|
11458
|
+
adoptMessageSegments as aN,
|
|
11459
|
+
APARTE_DERIVED_SEGMENTS as aO,
|
|
11460
|
+
rememberConversationStatus as aP,
|
|
11461
|
+
tellConversationStatus as aQ,
|
|
11462
|
+
conversationStatusOf as aR,
|
|
11463
|
+
visibleReply as aS,
|
|
11464
|
+
usageTokens as aT,
|
|
11465
|
+
rootOf as aU,
|
|
11466
|
+
inRenderedContent as aV,
|
|
11467
|
+
releaseDeferredHydration as aa,
|
|
11468
|
+
renderCitations as ab,
|
|
11469
|
+
renderCodeLanguages as ac,
|
|
11470
|
+
requestUserInput as ad,
|
|
11471
|
+
resolveConfig as ae,
|
|
11472
|
+
revokeAttachmentUrls as af,
|
|
11473
|
+
runWithConfig as ag,
|
|
11474
|
+
segmentDuration as ah,
|
|
11475
|
+
segmentTiming as ai,
|
|
11476
|
+
setupSuggestionBlocks as aj,
|
|
11477
|
+
subscribeConfigChange as ak,
|
|
11478
|
+
toToolCallView as al,
|
|
11479
|
+
toolRefusal as am,
|
|
11480
|
+
unregisterSegmentRenderer as an,
|
|
11481
|
+
uuid as ao,
|
|
11482
|
+
eventOrigin as ap,
|
|
11483
|
+
activeElementIn as aq,
|
|
11484
|
+
gateGlide as ar,
|
|
11485
|
+
chatBoundaryOf as as,
|
|
11486
|
+
relabelCodeLanguages as at,
|
|
11487
|
+
relabelCitations as au,
|
|
11488
|
+
toolCallRenderer as av,
|
|
11489
|
+
toolRendererThatDrew as aw,
|
|
11490
|
+
isMountedRenderer as ax,
|
|
11491
|
+
renderingVersionOf as ay,
|
|
11492
|
+
onRenderersChange as az,
|
|
11302
11493
|
APARTE_DEFAULT_BUBBLE_ACTIONS as b,
|
|
11303
11494
|
APARTE_DEFAULT_HOST_HANDLERS as c,
|
|
11304
11495
|
APARTE_DEFAULT_ICON_FALLBACKS as d,
|
|
@@ -11325,4 +11516,4 @@ export {
|
|
|
11325
11516
|
collectRendererStyles as y,
|
|
11326
11517
|
contentToText as z
|
|
11327
11518
|
};
|
|
11328
|
-
//# sourceMappingURL=defer-hydration-
|
|
11519
|
+
//# sourceMappingURL=defer-hydration-BBdqAZej.js.map
|