@copilotkit/core 2.0.0-rc.19 → 2.0.0-rc.20
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/index.cjs +1085 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +691 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +691 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1044 -2
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +1210 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +4 -3
package/dist/index.umd.js
CHANGED
|
@@ -4018,8 +4018,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
4018
4018
|
}
|
|
4019
4019
|
/** Reject ambiguous assistant definitions before executing or answering a call. */
|
|
4020
4020
|
validateToolCalls(messages) {
|
|
4021
|
-
var _classPrivateFieldGet2$
|
|
4022
|
-
if (((_classPrivateFieldGet2$
|
|
4021
|
+
var _classPrivateFieldGet2$3;
|
|
4022
|
+
if (((_classPrivateFieldGet2$3 = _classPrivateFieldGet2(_pending, this)) === null || _classPrivateFieldGet2$3 === void 0 ? void 0 : _classPrivateFieldGet2$3.kind) !== "standard") return;
|
|
4023
4023
|
const pendingCalls = new Set(_classPrivateFieldGet2(_pending, this).interrupts.filter((interrupt) => interrupt.reason === "tool_call").map((interrupt) => interrupt.toolCallId));
|
|
4024
4024
|
const seen = /* @__PURE__ */ new Set();
|
|
4025
4025
|
for (const message of messages) {
|
|
@@ -12551,6 +12551,152 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
12551
12551
|
licensePending: status === null
|
|
12552
12552
|
};
|
|
12553
12553
|
}
|
|
12554
|
+
const PRICING_URL = "https://copilotkit.ai/pricing";
|
|
12555
|
+
const DASHBOARD_URL = "https://dashboard.operations.copilotkit.ai";
|
|
12556
|
+
/**
|
|
12557
|
+
* What one license banner shows: its severity, text, and link. React, Vue,
|
|
12558
|
+
* and Angular render it with {@link ɵLICENSE_BANNER_STYLE}.
|
|
12559
|
+
*
|
|
12560
|
+
* @param type - The banner type, for example from
|
|
12561
|
+
* {@link ɵresolveLicenseState}'s `bannerType`.
|
|
12562
|
+
* @param labels - The chat labels in effect, so apps can translate the text.
|
|
12563
|
+
* @param details - The feature name, expiry date, or days left.
|
|
12564
|
+
*
|
|
12565
|
+
* @example
|
|
12566
|
+
* ```ts
|
|
12567
|
+
* const spec = ɵgetLicenseBannerSpec("expiring", labels, { graceRemaining: 3 });
|
|
12568
|
+
* // { severity: "warning", message: "… expires in 3 days …", actionLabel: "Renew", … }
|
|
12569
|
+
* ```
|
|
12570
|
+
*/
|
|
12571
|
+
function ɵgetLicenseBannerSpec(type, labels, { featureName, expiryDate, graceRemaining } = {}) {
|
|
12572
|
+
switch (type) {
|
|
12573
|
+
case "no_license": return bannerSpec("info", labels.licensePoweredByText, labels.licenseGetLicenseLabel, PRICING_URL);
|
|
12574
|
+
case "feature_unlicensed": return bannerSpec("warning", ɵformatLabel(labels.licenseFeatureUnlicensedText, { feature: featureName !== null && featureName !== void 0 ? featureName : "" }), labels.licenseGetLicenseLabel, PRICING_URL);
|
|
12575
|
+
case "expiring": return bannerSpec("warning", expiringMessage(labels, graceRemaining), labels.licenseRenewLabel, DASHBOARD_URL);
|
|
12576
|
+
case "expired": return bannerSpec("critical", expiryDate ? ɵformatLabel(labels.licenseExpiredOnDateText, { date: expiryDate }) : labels.licenseExpiredText, labels.licenseRenewNowLabel, PRICING_URL);
|
|
12577
|
+
case "invalid": return bannerSpec("critical", labels.licenseInvalidText, labels.licenseGetLicenseLabel, PRICING_URL);
|
|
12578
|
+
}
|
|
12579
|
+
}
|
|
12580
|
+
const bannerSpec = (severity, message, actionLabel, actionUrl) => ({
|
|
12581
|
+
severity,
|
|
12582
|
+
message,
|
|
12583
|
+
actionLabel,
|
|
12584
|
+
actionUrl
|
|
12585
|
+
});
|
|
12586
|
+
/**
|
|
12587
|
+
* The "expires soon" text. Without a day count it says "soon", never "in
|
|
12588
|
+
* undefined days".
|
|
12589
|
+
*/
|
|
12590
|
+
function expiringMessage(labels, graceRemaining) {
|
|
12591
|
+
if (graceRemaining === void 0) return labels.licenseExpiringText;
|
|
12592
|
+
return ɵformatLabel(graceRemaining === 1 ? labels.licenseExpiringInDaysOne : labels.licenseExpiringInDaysOther, { days: graceRemaining });
|
|
12593
|
+
}
|
|
12594
|
+
const FONT_FAMILY = "-apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif";
|
|
12595
|
+
/**
|
|
12596
|
+
* Inline styles of the fixed license banner, in camelCase, for React `style`
|
|
12597
|
+
* and Vue `:style`. `base` is the layout; `severity` holds the colours.
|
|
12598
|
+
*/
|
|
12599
|
+
const ɵLICENSE_BANNER_STYLE = {
|
|
12600
|
+
base: {
|
|
12601
|
+
position: "fixed",
|
|
12602
|
+
bottom: "8px",
|
|
12603
|
+
left: "50%",
|
|
12604
|
+
transform: "translateX(-50%)",
|
|
12605
|
+
zIndex: 99999,
|
|
12606
|
+
display: "inline-flex",
|
|
12607
|
+
alignItems: "center",
|
|
12608
|
+
gap: "12px",
|
|
12609
|
+
whiteSpace: "nowrap",
|
|
12610
|
+
padding: "8px 16px",
|
|
12611
|
+
fontSize: "13px",
|
|
12612
|
+
fontFamily: FONT_FAMILY,
|
|
12613
|
+
borderRadius: "6px",
|
|
12614
|
+
boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)"
|
|
12615
|
+
},
|
|
12616
|
+
severity: {
|
|
12617
|
+
info: {
|
|
12618
|
+
backgroundColor: "#eff6ff",
|
|
12619
|
+
border: "1px solid #93c5fd",
|
|
12620
|
+
color: "#1e40af"
|
|
12621
|
+
},
|
|
12622
|
+
warning: {
|
|
12623
|
+
backgroundColor: "#fffbeb",
|
|
12624
|
+
border: "1px solid #fbbf24",
|
|
12625
|
+
color: "#92400e"
|
|
12626
|
+
},
|
|
12627
|
+
critical: {
|
|
12628
|
+
backgroundColor: "#fef2f2",
|
|
12629
|
+
border: "1px solid #fca5a5",
|
|
12630
|
+
color: "#991b1b"
|
|
12631
|
+
}
|
|
12632
|
+
},
|
|
12633
|
+
actions: {
|
|
12634
|
+
display: "flex",
|
|
12635
|
+
gap: "8px",
|
|
12636
|
+
alignItems: "center"
|
|
12637
|
+
},
|
|
12638
|
+
link: {
|
|
12639
|
+
fontWeight: 600,
|
|
12640
|
+
textDecoration: "underline",
|
|
12641
|
+
color: "inherit"
|
|
12642
|
+
},
|
|
12643
|
+
dismiss: {
|
|
12644
|
+
background: "none",
|
|
12645
|
+
border: "none",
|
|
12646
|
+
cursor: "pointer",
|
|
12647
|
+
color: "inherit",
|
|
12648
|
+
fontSize: "16px"
|
|
12649
|
+
}
|
|
12650
|
+
};
|
|
12651
|
+
/**
|
|
12652
|
+
* The bottom space the fixed banner takes: banner height (~36px) + bottom
|
|
12653
|
+
* offset (8px) + gap above the chat input (~8px). The chat input reads it
|
|
12654
|
+
* through `padding-bottom: var(--copilotkit-license-banner-offset)`.
|
|
12655
|
+
*/
|
|
12656
|
+
const ɵLICENSE_BANNER_OFFSET = {
|
|
12657
|
+
cssVar: "--copilotkit-license-banner-offset",
|
|
12658
|
+
px: 52
|
|
12659
|
+
};
|
|
12660
|
+
/**
|
|
12661
|
+
* Publishes {@link ɵLICENSE_BANNER_OFFSET} on the root element while a
|
|
12662
|
+
* banner shows. Does nothing without a document (SSR).
|
|
12663
|
+
*
|
|
12664
|
+
* @returns A function that removes the offset again.
|
|
12665
|
+
*/
|
|
12666
|
+
function ɵreserveLicenseBannerOffset() {
|
|
12667
|
+
if (typeof document === "undefined") return () => {};
|
|
12668
|
+
const root = document.documentElement;
|
|
12669
|
+
root.style.setProperty(ɵLICENSE_BANNER_OFFSET.cssVar, `${ɵLICENSE_BANNER_OFFSET.px}px`);
|
|
12670
|
+
return () => root.style.removeProperty(ɵLICENSE_BANNER_OFFSET.cssVar);
|
|
12671
|
+
}
|
|
12672
|
+
/**
|
|
12673
|
+
* What the inline warning shows when a chat component needs a license it
|
|
12674
|
+
* does not have: the `licenseFeatureUnlicensedText` label and a pricing
|
|
12675
|
+
* link. Render it with {@link ɵINLINE_FEATURE_WARNING_STYLE}.
|
|
12676
|
+
*/
|
|
12677
|
+
function ɵgetInlineFeatureWarningSpec(featureName, labels) {
|
|
12678
|
+
return {
|
|
12679
|
+
message: ɵformatLabel(labels.licenseFeatureUnlicensedText, { feature: featureName }),
|
|
12680
|
+
actionLabel: "Get one at copilotkit.ai/pricing",
|
|
12681
|
+
actionUrl: PRICING_URL
|
|
12682
|
+
};
|
|
12683
|
+
}
|
|
12684
|
+
/** Inline styles of the inline feature warning, in camelCase. */
|
|
12685
|
+
const ɵINLINE_FEATURE_WARNING_STYLE = {
|
|
12686
|
+
container: {
|
|
12687
|
+
padding: "8px 12px",
|
|
12688
|
+
backgroundColor: "#fffbeb",
|
|
12689
|
+
border: "1px solid #fbbf24",
|
|
12690
|
+
borderRadius: "6px",
|
|
12691
|
+
fontSize: "13px",
|
|
12692
|
+
color: "#92400e",
|
|
12693
|
+
fontFamily: FONT_FAMILY
|
|
12694
|
+
},
|
|
12695
|
+
link: {
|
|
12696
|
+
color: "#b45309",
|
|
12697
|
+
textDecoration: "underline"
|
|
12698
|
+
}
|
|
12699
|
+
};
|
|
12554
12700
|
|
|
12555
12701
|
//#endregion
|
|
12556
12702
|
//#region src/chat/icons.ts
|
|
@@ -12779,6 +12925,1003 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
12779
12925
|
"stroke-linejoin": "round"
|
|
12780
12926
|
};
|
|
12781
12927
|
|
|
12928
|
+
//#endregion
|
|
12929
|
+
//#region src/chat/message-feedback.ts
|
|
12930
|
+
/** Trajectory event name for a rating of one assistant message. */
|
|
12931
|
+
const ɵMESSAGE_FEEDBACK_EVENT_NAME = "message.feedback";
|
|
12932
|
+
/** Longest comment kept, in characters; the rest is cut so the event stays small. */
|
|
12933
|
+
const ɵMESSAGE_FEEDBACK_MAX_COMMENT_LENGTH = 1e3;
|
|
12934
|
+
/** Longest excerpt of the rated response sent with the rating, in characters. */
|
|
12935
|
+
const RESPONSE_EXCERPT_LENGTH = 500;
|
|
12936
|
+
/**
|
|
12937
|
+
* How long the pointer may be away from the rating and its comment before the
|
|
12938
|
+
* comment closes: enough to cross the gap between them, short enough that
|
|
12939
|
+
* passing over a rating does not leave it open.
|
|
12940
|
+
*/
|
|
12941
|
+
const ɵFEEDBACK_COMMENT_CLOSE_DELAY_MS = 150;
|
|
12942
|
+
const ratings = /* @__PURE__ */ new Map();
|
|
12943
|
+
const listeners = /* @__PURE__ */ new Map();
|
|
12944
|
+
const threadKey = (agentId, threadId) => JSON.stringify([agentId, threadId]);
|
|
12945
|
+
const messageKey = (agentId, threadId, messageId) => JSON.stringify([
|
|
12946
|
+
agentId,
|
|
12947
|
+
threadId,
|
|
12948
|
+
messageId
|
|
12949
|
+
]);
|
|
12950
|
+
/** Cuts `text` to `max` characters without splitting a surrogate pair. */
|
|
12951
|
+
const clip = (text, max) => {
|
|
12952
|
+
const characters = Array.from(text);
|
|
12953
|
+
return characters.length > max ? characters.slice(0, max).join("") : text;
|
|
12954
|
+
};
|
|
12955
|
+
/** The comment as kept and sent: trimmed and capped, or none. */
|
|
12956
|
+
const normalizeComment = (comment) => {
|
|
12957
|
+
if (comment === void 0) return void 0;
|
|
12958
|
+
const text = clip(comment.trim(), ɵMESSAGE_FEEDBACK_MAX_COMMENT_LENGTH);
|
|
12959
|
+
return text === "" ? void 0 : text;
|
|
12960
|
+
};
|
|
12961
|
+
/** The rating this page gave one message, if any. */
|
|
12962
|
+
function ɵgetMessageFeedback(agentId, threadId, messageId) {
|
|
12963
|
+
return ratings.get(messageKey(agentId, threadId, messageId));
|
|
12964
|
+
}
|
|
12965
|
+
/** Calls `listener` whenever a rating in this Thread changes. */
|
|
12966
|
+
function ɵsubscribeToMessageFeedback(agentId, threadId, listener) {
|
|
12967
|
+
const key = threadKey(agentId, threadId);
|
|
12968
|
+
let set = listeners.get(key);
|
|
12969
|
+
if (set === void 0) {
|
|
12970
|
+
set = /* @__PURE__ */ new Set();
|
|
12971
|
+
listeners.set(key, set);
|
|
12972
|
+
}
|
|
12973
|
+
const subscribed = set;
|
|
12974
|
+
subscribed.add(listener);
|
|
12975
|
+
return () => {
|
|
12976
|
+
subscribed.delete(listener);
|
|
12977
|
+
if (subscribed.size === 0) listeners.delete(key);
|
|
12978
|
+
};
|
|
12979
|
+
}
|
|
12980
|
+
/**
|
|
12981
|
+
* Sets (or, with `null`, clears) this page's rating of one message and sends
|
|
12982
|
+
* it to the active Trajectory. Every change is a new event; the newest event
|
|
12983
|
+
* for a `feedbackId` is the current one. Like any Trajectory event, a change
|
|
12984
|
+
* made while no Trajectory captures, for example during a reconnect, is not
|
|
12985
|
+
* sent; the page still shows it.
|
|
12986
|
+
*/
|
|
12987
|
+
function ɵsetMessageFeedback(params) {
|
|
12988
|
+
var _params$feedback, _listeners$get, _feedback$rating, _message$content;
|
|
12989
|
+
const { copilotkit, agentId, threadId, message } = params;
|
|
12990
|
+
const comment = normalizeComment((_params$feedback = params.feedback) === null || _params$feedback === void 0 ? void 0 : _params$feedback.comment);
|
|
12991
|
+
const feedback = params.feedback && {
|
|
12992
|
+
rating: params.feedback.rating,
|
|
12993
|
+
...comment ? { comment } : {}
|
|
12994
|
+
};
|
|
12995
|
+
const key = messageKey(agentId, threadId, message.id);
|
|
12996
|
+
if (feedback) ratings.set(key, feedback);
|
|
12997
|
+
else ratings.delete(key);
|
|
12998
|
+
const threadListeners = (_listeners$get = listeners.get(threadKey(agentId, threadId))) !== null && _listeners$get !== void 0 ? _listeners$get : [];
|
|
12999
|
+
for (const listener of threadListeners) listener();
|
|
13000
|
+
const runId = copilotkit.getRunIdForMessage(agentId, threadId, message.id);
|
|
13001
|
+
copilotkit.emitTrajectoryEvent(ɵMESSAGE_FEEDBACK_EVENT_NAME, {
|
|
13002
|
+
feedbackId: `${threadId}:${message.id}`,
|
|
13003
|
+
threadId,
|
|
13004
|
+
messageId: message.id,
|
|
13005
|
+
agentId,
|
|
13006
|
+
...runId ? { runId } : {},
|
|
13007
|
+
rating: (_feedback$rating = feedback === null || feedback === void 0 ? void 0 : feedback.rating) !== null && _feedback$rating !== void 0 ? _feedback$rating : null,
|
|
13008
|
+
...(feedback === null || feedback === void 0 ? void 0 : feedback.comment) ? { comment: feedback.comment } : {},
|
|
13009
|
+
...copilotkit.ɵlearningCapturesAgentText ? { response: clip((_message$content = message.content) !== null && _message$content !== void 0 ? _message$content : "", RESPONSE_EXCERPT_LENGTH) } : {}
|
|
13010
|
+
});
|
|
13011
|
+
}
|
|
13012
|
+
/** @internal Forgets every rating, so each test starts empty. */
|
|
13013
|
+
function ɵresetMessageFeedbackCache() {
|
|
13014
|
+
ratings.clear();
|
|
13015
|
+
}
|
|
13016
|
+
const capturedCores = /* @__PURE__ */ new WeakSet();
|
|
13017
|
+
const rememberCapture = (copilotkit) => {
|
|
13018
|
+
if (capturedCores.has(copilotkit)) return;
|
|
13019
|
+
capturedCores.add(copilotkit);
|
|
13020
|
+
const unsubscribe = copilotkit.ɵsubscribeToLearningConfigured(() => {
|
|
13021
|
+
if (copilotkit.ɵlearningConfigured) return;
|
|
13022
|
+
capturedCores.delete(copilotkit);
|
|
13023
|
+
unsubscribe();
|
|
13024
|
+
});
|
|
13025
|
+
};
|
|
13026
|
+
/**
|
|
13027
|
+
* Whether the thumbs record feedback for Learning. True once a Trajectory of
|
|
13028
|
+
* this Core has started and as long as Learning stays configured, also while
|
|
13029
|
+
* capture reconnects or is stopped, so the buttons do not flicker. Ratings
|
|
13030
|
+
* given meanwhile still show but, like any Trajectory event, are not sent. A
|
|
13031
|
+
* capture that never starts (for example without a license) leaves it false.
|
|
13032
|
+
*
|
|
13033
|
+
* Re-read it when {@link ɵsubscribeToLearningFeedbackEnabled} notifies.
|
|
13034
|
+
*/
|
|
13035
|
+
function ɵisLearningFeedbackEnabled(copilotkit) {
|
|
13036
|
+
const capturing = copilotkit.trajectoryId !== null;
|
|
13037
|
+
if (capturing) rememberCapture(copilotkit);
|
|
13038
|
+
return copilotkit.ɵlearningConfigured && (capturing || capturedCores.has(copilotkit));
|
|
13039
|
+
}
|
|
13040
|
+
/**
|
|
13041
|
+
* Calls `listener` when {@link ɵisLearningFeedbackEnabled} may have changed:
|
|
13042
|
+
* when Learning is configured or removed, and when the Trajectory changes.
|
|
13043
|
+
* Returns the unsubscribe function.
|
|
13044
|
+
*/
|
|
13045
|
+
function ɵsubscribeToLearningFeedbackEnabled(copilotkit, listener) {
|
|
13046
|
+
const unsubscribeConfigured = copilotkit.ɵsubscribeToLearningConfigured(listener);
|
|
13047
|
+
const subscription = copilotkit.subscribe({ onTrajectoryChanged: listener });
|
|
13048
|
+
return () => {
|
|
13049
|
+
unsubscribeConfigured();
|
|
13050
|
+
subscription.unsubscribe();
|
|
13051
|
+
};
|
|
13052
|
+
}
|
|
13053
|
+
/**
|
|
13054
|
+
* The feedback this page gave `message` in `scope`, and how to change it.
|
|
13055
|
+
* Read it again when {@link ɵsubscribeToMessageFeedback} notifies for the
|
|
13056
|
+
* scope's Thread.
|
|
13057
|
+
*/
|
|
13058
|
+
function ɵgetMessageFeedbackControls(scope, message) {
|
|
13059
|
+
const feedback = ɵgetMessageFeedback(scope.agentId, scope.threadId, message.id);
|
|
13060
|
+
const save = (next) => ɵsetMessageFeedback({
|
|
13061
|
+
...scope,
|
|
13062
|
+
message,
|
|
13063
|
+
feedback: next
|
|
13064
|
+
});
|
|
13065
|
+
return {
|
|
13066
|
+
feedback,
|
|
13067
|
+
rate: (rating) => {
|
|
13068
|
+
if ((feedback === null || feedback === void 0 ? void 0 : feedback.rating) !== rating) save({ rating });
|
|
13069
|
+
},
|
|
13070
|
+
clear: () => {
|
|
13071
|
+
if (feedback) save(null);
|
|
13072
|
+
},
|
|
13073
|
+
comment: (comment) => {
|
|
13074
|
+
if (feedback) save({
|
|
13075
|
+
rating: feedback.rating,
|
|
13076
|
+
comment
|
|
13077
|
+
});
|
|
13078
|
+
}
|
|
13079
|
+
};
|
|
13080
|
+
}
|
|
13081
|
+
var _getControls = /* @__PURE__ */ new WeakMap();
|
|
13082
|
+
var _closeDelayMs$1 = /* @__PURE__ */ new WeakMap();
|
|
13083
|
+
var _listeners$3 = /* @__PURE__ */ new WeakMap();
|
|
13084
|
+
var _state$2 = /* @__PURE__ */ new WeakMap();
|
|
13085
|
+
var _timer$3 = /* @__PURE__ */ new WeakMap();
|
|
13086
|
+
var _editing = /* @__PURE__ */ new WeakMap();
|
|
13087
|
+
var _focusWaiting = /* @__PURE__ */ new WeakMap();
|
|
13088
|
+
var _pointerOver = /* @__PURE__ */ new WeakMap();
|
|
13089
|
+
var _returning = /* @__PURE__ */ new WeakMap();
|
|
13090
|
+
var _ɵFeedbackCommentController_brand = /* @__PURE__ */ new WeakSet();
|
|
13091
|
+
/**
|
|
13092
|
+
* Drives the comment popover of a rated message.
|
|
13093
|
+
*
|
|
13094
|
+
* It opens when a rating is given and whenever the pointer or keyboard focus
|
|
13095
|
+
* reaches the chosen thumb, with the saved comment in the field. It closes by
|
|
13096
|
+
* itself shortly after the pointer leaves the thumb and the popover, unless
|
|
13097
|
+
* focus is in the field: then it stays until focus moves away, Enter, or
|
|
13098
|
+
* Escape. Closing saves a changed comment; Escape, a click on a thumb, and
|
|
13099
|
+
* removing the rating discard it.
|
|
13100
|
+
*
|
|
13101
|
+
* Frameworks render from `getSnapshot()` and re-render when `subscribe()`
|
|
13102
|
+
* notifies. Call `dispose()` on unmount: it keeps an unsaved edit, for a
|
|
13103
|
+
* message that scrolls out of a virtual list. The controller stays usable
|
|
13104
|
+
* after `dispose()`, so a remount (React Strict Mode) can keep it.
|
|
13105
|
+
*
|
|
13106
|
+
* @example
|
|
13107
|
+
* ```ts
|
|
13108
|
+
* const comment = new ɵFeedbackCommentController({ getControls: () => controls });
|
|
13109
|
+
* comment.subscribe(() => render(comment.getSnapshot()));
|
|
13110
|
+
* comment.show({ comment: "", focus: false });
|
|
13111
|
+
* // On unmount:
|
|
13112
|
+
* comment.dispose();
|
|
13113
|
+
* ```
|
|
13114
|
+
*/
|
|
13115
|
+
var ɵFeedbackCommentController = class {
|
|
13116
|
+
constructor(options) {
|
|
13117
|
+
var _options$closeDelayMs;
|
|
13118
|
+
_classPrivateMethodInitSpec(this, _ɵFeedbackCommentController_brand);
|
|
13119
|
+
_classPrivateFieldInitSpec(this, _getControls, void 0);
|
|
13120
|
+
_classPrivateFieldInitSpec(this, _closeDelayMs$1, void 0);
|
|
13121
|
+
_classPrivateFieldInitSpec(this, _listeners$3, /* @__PURE__ */ new Set());
|
|
13122
|
+
_classPrivateFieldInitSpec(this, _state$2, {
|
|
13123
|
+
open: false,
|
|
13124
|
+
draft: "",
|
|
13125
|
+
focusRequest: 0
|
|
13126
|
+
});
|
|
13127
|
+
_classPrivateFieldInitSpec(this, _timer$3, void 0);
|
|
13128
|
+
_classPrivateFieldInitSpec(this, _editing, false);
|
|
13129
|
+
_classPrivateFieldInitSpec(this, _focusWaiting, false);
|
|
13130
|
+
_classPrivateFieldInitSpec(this, _pointerOver, false);
|
|
13131
|
+
_classPrivateFieldInitSpec(this, _returning, false);
|
|
13132
|
+
_defineProperty(
|
|
13133
|
+
this,
|
|
13134
|
+
/** The current state. The same object until something changes. */
|
|
13135
|
+
"getSnapshot",
|
|
13136
|
+
() => _classPrivateFieldGet2(_state$2, this)
|
|
13137
|
+
);
|
|
13138
|
+
_defineProperty(
|
|
13139
|
+
this,
|
|
13140
|
+
/** Calls `listener` when the state changes. Returns the unsubscribe function. */
|
|
13141
|
+
"subscribe",
|
|
13142
|
+
(listener) => {
|
|
13143
|
+
_classPrivateFieldGet2(_listeners$3, this).add(listener);
|
|
13144
|
+
return () => {
|
|
13145
|
+
_classPrivateFieldGet2(_listeners$3, this).delete(listener);
|
|
13146
|
+
};
|
|
13147
|
+
}
|
|
13148
|
+
);
|
|
13149
|
+
_defineProperty(
|
|
13150
|
+
this,
|
|
13151
|
+
/** Sets the comment being edited. */
|
|
13152
|
+
"setDraft",
|
|
13153
|
+
(draft) => {
|
|
13154
|
+
_assertClassBrand(_ɵFeedbackCommentController_brand, this, _update).call(this, { draft });
|
|
13155
|
+
}
|
|
13156
|
+
);
|
|
13157
|
+
_defineProperty(
|
|
13158
|
+
this,
|
|
13159
|
+
/** Whether a focus request waits; reading it answers the request. */
|
|
13160
|
+
"takeFocusRequest",
|
|
13161
|
+
() => {
|
|
13162
|
+
const waiting = _classPrivateFieldGet2(_focusWaiting, this);
|
|
13163
|
+
_classPrivateFieldSet2(_focusWaiting, this, false);
|
|
13164
|
+
return waiting;
|
|
13165
|
+
}
|
|
13166
|
+
);
|
|
13167
|
+
_defineProperty(
|
|
13168
|
+
this,
|
|
13169
|
+
/** Opens with `comment` in the field. */
|
|
13170
|
+
"show",
|
|
13171
|
+
({ comment, focus }) => {
|
|
13172
|
+
_assertClassBrand(_ɵFeedbackCommentController_brand, this, _cancelClose).call(this);
|
|
13173
|
+
if (focus) _classPrivateFieldSet2(_focusWaiting, this, true);
|
|
13174
|
+
_assertClassBrand(_ɵFeedbackCommentController_brand, this, _update).call(this, {
|
|
13175
|
+
open: true,
|
|
13176
|
+
draft: comment,
|
|
13177
|
+
focusRequest: _classPrivateFieldGet2(_state$2, this).focusRequest + (focus ? 1 : 0)
|
|
13178
|
+
});
|
|
13179
|
+
}
|
|
13180
|
+
);
|
|
13181
|
+
_defineProperty(
|
|
13182
|
+
this,
|
|
13183
|
+
/** The pointer or focus reached the rating or the popover. */
|
|
13184
|
+
"enter",
|
|
13185
|
+
(via = "focus") => {
|
|
13186
|
+
var _classPrivateFieldGet2$2;
|
|
13187
|
+
_assertClassBrand(_ɵFeedbackCommentController_brand, this, _cancelClose).call(this);
|
|
13188
|
+
if (via === "pointer") _classPrivateFieldSet2(_pointerOver, this, true);
|
|
13189
|
+
if (_classPrivateFieldGet2(_returning, this)) return;
|
|
13190
|
+
if (!_classPrivateFieldGet2(_state$2, this).open && ((_classPrivateFieldGet2$2 = _classPrivateFieldGet2(_getControls, this).call(this)) === null || _classPrivateFieldGet2$2 === void 0 ? void 0 : _classPrivateFieldGet2$2.feedback)) this.show({
|
|
13191
|
+
comment: _assertClassBrand(_ɵFeedbackCommentController_brand, this, _savedComment).call(this),
|
|
13192
|
+
focus: false
|
|
13193
|
+
});
|
|
13194
|
+
}
|
|
13195
|
+
);
|
|
13196
|
+
_defineProperty(
|
|
13197
|
+
this,
|
|
13198
|
+
/**
|
|
13199
|
+
* It left them: close soon, unless the user is editing the comment or, when
|
|
13200
|
+
* focus left, the pointer is still on the rating or the popover.
|
|
13201
|
+
*/
|
|
13202
|
+
"leave",
|
|
13203
|
+
(via = "focus") => {
|
|
13204
|
+
if (via === "pointer") _classPrivateFieldSet2(_pointerOver, this, false);
|
|
13205
|
+
else if (_classPrivateFieldGet2(_pointerOver, this)) return;
|
|
13206
|
+
_assertClassBrand(_ɵFeedbackCommentController_brand, this, _cancelClose).call(this);
|
|
13207
|
+
_classPrivateFieldSet2(_timer$3, this, setTimeout(() => {
|
|
13208
|
+
_classPrivateFieldSet2(_timer$3, this, void 0);
|
|
13209
|
+
if (!_classPrivateFieldGet2(_editing, this)) this.close();
|
|
13210
|
+
}, _classPrivateFieldGet2(_closeDelayMs$1, this)));
|
|
13211
|
+
}
|
|
13212
|
+
);
|
|
13213
|
+
_defineProperty(
|
|
13214
|
+
this,
|
|
13215
|
+
/** Tracks whether focus is in the comment form. */
|
|
13216
|
+
"setEditing",
|
|
13217
|
+
(editing) => {
|
|
13218
|
+
_classPrivateFieldSet2(_editing, this, editing);
|
|
13219
|
+
}
|
|
13220
|
+
);
|
|
13221
|
+
_defineProperty(
|
|
13222
|
+
this,
|
|
13223
|
+
/** Closes, saving a changed comment unless `save` is false. */
|
|
13224
|
+
"close",
|
|
13225
|
+
({ save = true } = {}) => {
|
|
13226
|
+
_assertClassBrand(_ɵFeedbackCommentController_brand, this, _cancelClose).call(this);
|
|
13227
|
+
_classPrivateFieldSet2(_focusWaiting, this, false);
|
|
13228
|
+
_classPrivateFieldSet2(_pointerOver, this, false);
|
|
13229
|
+
if (!_classPrivateFieldGet2(_state$2, this).open) return;
|
|
13230
|
+
if (save) _assertClassBrand(_ɵFeedbackCommentController_brand, this, _saveDraft).call(this);
|
|
13231
|
+
_classPrivateFieldSet2(_editing, this, false);
|
|
13232
|
+
_assertClassBrand(_ɵFeedbackCommentController_brand, this, _update).call(this, { open: false });
|
|
13233
|
+
}
|
|
13234
|
+
);
|
|
13235
|
+
_defineProperty(
|
|
13236
|
+
this,
|
|
13237
|
+
/** Moves focus back to the thumb without opening the comment again. */
|
|
13238
|
+
"returnFocus",
|
|
13239
|
+
(target) => {
|
|
13240
|
+
_classPrivateFieldSet2(_returning, this, true);
|
|
13241
|
+
try {
|
|
13242
|
+
target === null || target === void 0 || target.focus();
|
|
13243
|
+
} finally {
|
|
13244
|
+
_classPrivateFieldSet2(_returning, this, false);
|
|
13245
|
+
}
|
|
13246
|
+
}
|
|
13247
|
+
);
|
|
13248
|
+
_defineProperty(
|
|
13249
|
+
this,
|
|
13250
|
+
/** Stops the close timer and saves a changed comment that is still open. */
|
|
13251
|
+
"dispose",
|
|
13252
|
+
() => {
|
|
13253
|
+
_assertClassBrand(_ɵFeedbackCommentController_brand, this, _cancelClose).call(this);
|
|
13254
|
+
if (_classPrivateFieldGet2(_state$2, this).open) _assertClassBrand(_ɵFeedbackCommentController_brand, this, _saveDraft).call(this);
|
|
13255
|
+
}
|
|
13256
|
+
);
|
|
13257
|
+
_classPrivateFieldSet2(_getControls, this, options.getControls);
|
|
13258
|
+
_classPrivateFieldSet2(_closeDelayMs$1, this, (_options$closeDelayMs = options.closeDelayMs) !== null && _options$closeDelayMs !== void 0 ? _options$closeDelayMs : ɵFEEDBACK_COMMENT_CLOSE_DELAY_MS);
|
|
13259
|
+
}
|
|
13260
|
+
};
|
|
13261
|
+
function _savedComment() {
|
|
13262
|
+
var _this$getControls$fee, _classPrivateFieldGet3;
|
|
13263
|
+
return (_this$getControls$fee = (_classPrivateFieldGet3 = _classPrivateFieldGet2(_getControls, this).call(this)) === null || _classPrivateFieldGet3 === void 0 || (_classPrivateFieldGet3 = _classPrivateFieldGet3.feedback) === null || _classPrivateFieldGet3 === void 0 ? void 0 : _classPrivateFieldGet3.comment) !== null && _this$getControls$fee !== void 0 ? _this$getControls$fee : "";
|
|
13264
|
+
}
|
|
13265
|
+
function _saveDraft() {
|
|
13266
|
+
const controls = _classPrivateFieldGet2(_getControls, this).call(this);
|
|
13267
|
+
const draft = _classPrivateFieldGet2(_state$2, this).draft;
|
|
13268
|
+
if ((controls === null || controls === void 0 ? void 0 : controls.feedback) && draft.trim() !== _assertClassBrand(_ɵFeedbackCommentController_brand, this, _savedComment).call(this)) controls.comment(draft);
|
|
13269
|
+
}
|
|
13270
|
+
function _cancelClose() {
|
|
13271
|
+
if (_classPrivateFieldGet2(_timer$3, this) === void 0) return;
|
|
13272
|
+
clearTimeout(_classPrivateFieldGet2(_timer$3, this));
|
|
13273
|
+
_classPrivateFieldSet2(_timer$3, this, void 0);
|
|
13274
|
+
}
|
|
13275
|
+
function _update(patch) {
|
|
13276
|
+
const next = {
|
|
13277
|
+
..._classPrivateFieldGet2(_state$2, this),
|
|
13278
|
+
...patch
|
|
13279
|
+
};
|
|
13280
|
+
if (next.open === _classPrivateFieldGet2(_state$2, this).open && next.draft === _classPrivateFieldGet2(_state$2, this).draft && next.focusRequest === _classPrivateFieldGet2(_state$2, this).focusRequest) return;
|
|
13281
|
+
_classPrivateFieldSet2(_state$2, this, next);
|
|
13282
|
+
for (const listener of _classPrivateFieldGet2(_listeners$3, this)) listener();
|
|
13283
|
+
}
|
|
13284
|
+
|
|
13285
|
+
//#endregion
|
|
13286
|
+
//#region src/chat/viewport.ts
|
|
13287
|
+
const AUTO_SCROLL_MODES = [
|
|
13288
|
+
"pin-to-bottom",
|
|
13289
|
+
"pin-to-send",
|
|
13290
|
+
"none"
|
|
13291
|
+
];
|
|
13292
|
+
const isAutoScrollMode = (value) => AUTO_SCROLL_MODES.includes(value);
|
|
13293
|
+
/**
|
|
13294
|
+
* Turns the `autoScroll` prop into a mode. `true` and a missing value mean
|
|
13295
|
+
* `"pin-to-bottom"`, `false` means `"none"`, and an unknown string falls back
|
|
13296
|
+
* to `"pin-to-bottom"`.
|
|
13297
|
+
*/
|
|
13298
|
+
function ɵnormalizeAutoScroll(value) {
|
|
13299
|
+
if (value === false) return "none";
|
|
13300
|
+
if (value === void 0 || value === true) return "pin-to-bottom";
|
|
13301
|
+
return isAutoScrollMode(value) ? value : "pin-to-bottom";
|
|
13302
|
+
}
|
|
13303
|
+
/**
|
|
13304
|
+
* Media query for the mobile range, where the threads drawer and the chat
|
|
13305
|
+
* modal are mutually exclusive.
|
|
13306
|
+
*/
|
|
13307
|
+
const ɵMOBILE_MAX_WIDTH_QUERY = "(max-width: 767px)";
|
|
13308
|
+
/** `window.matchMedia` for the mobile query, or `null` without a DOM. */
|
|
13309
|
+
const mobileMediaQuery = () => {
|
|
13310
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia(ɵMOBILE_MAX_WIDTH_QUERY) : null;
|
|
13311
|
+
};
|
|
13312
|
+
/**
|
|
13313
|
+
* Whether the viewport is in the mobile range (`<768px`). `false` during SSR
|
|
13314
|
+
* and where `window.matchMedia` is missing (some test runners and webviews).
|
|
13315
|
+
*/
|
|
13316
|
+
function ɵisMobileViewport() {
|
|
13317
|
+
var _mobileMediaQuery$mat, _mobileMediaQuery;
|
|
13318
|
+
return (_mobileMediaQuery$mat = (_mobileMediaQuery = mobileMediaQuery()) === null || _mobileMediaQuery === void 0 ? void 0 : _mobileMediaQuery.matches) !== null && _mobileMediaQuery$mat !== void 0 ? _mobileMediaQuery$mat : false;
|
|
13319
|
+
}
|
|
13320
|
+
/**
|
|
13321
|
+
* Calls `listener` with {@link ɵisMobileViewport} now and each time the
|
|
13322
|
+
* viewport enters or leaves the mobile range. Does nothing without
|
|
13323
|
+
* `window.matchMedia`. Returns the unsubscribe function.
|
|
13324
|
+
*/
|
|
13325
|
+
function ɵwatchMobileViewport(listener) {
|
|
13326
|
+
const query = mobileMediaQuery();
|
|
13327
|
+
if (query === null) return () => {};
|
|
13328
|
+
const update = () => listener(query.matches);
|
|
13329
|
+
update();
|
|
13330
|
+
query.addEventListener("change", update);
|
|
13331
|
+
return () => query.removeEventListener("change", update);
|
|
13332
|
+
}
|
|
13333
|
+
/**
|
|
13334
|
+
* The on-screen keyboard is treated as open once it covers more than this
|
|
13335
|
+
* many pixels of the layout viewport.
|
|
13336
|
+
*/
|
|
13337
|
+
const ɵKEYBOARD_OPEN_THRESHOLD_PX = 150;
|
|
13338
|
+
/**
|
|
13339
|
+
* Reads the keyboard state with the Visual Viewport API: the keyboard height
|
|
13340
|
+
* is `innerHeight - visualViewport.height`, clamped to 0. Without the API (or
|
|
13341
|
+
* during SSR) it reports a closed keyboard and the full window height.
|
|
13342
|
+
*/
|
|
13343
|
+
function ɵreadKeyboardState() {
|
|
13344
|
+
if (typeof window === "undefined") return closedKeyboard(0);
|
|
13345
|
+
const visualViewport = window.visualViewport;
|
|
13346
|
+
if (!visualViewport) return closedKeyboard(window.innerHeight);
|
|
13347
|
+
const layoutHeight = window.innerHeight;
|
|
13348
|
+
const keyboardHeight = Math.max(0, layoutHeight - visualViewport.height);
|
|
13349
|
+
return {
|
|
13350
|
+
isKeyboardOpen: keyboardHeight > ɵKEYBOARD_OPEN_THRESHOLD_PX,
|
|
13351
|
+
keyboardHeight,
|
|
13352
|
+
availableHeight: visualViewport.height,
|
|
13353
|
+
viewportHeight: layoutHeight
|
|
13354
|
+
};
|
|
13355
|
+
}
|
|
13356
|
+
const closedKeyboard = (height) => ({
|
|
13357
|
+
isKeyboardOpen: false,
|
|
13358
|
+
keyboardHeight: 0,
|
|
13359
|
+
availableHeight: height,
|
|
13360
|
+
viewportHeight: height
|
|
13361
|
+
});
|
|
13362
|
+
/**
|
|
13363
|
+
* The state for the first render, before {@link ɵwatchKeyboardState} reads
|
|
13364
|
+
* the visual viewport: a closed keyboard over the full window height (0
|
|
13365
|
+
* during SSR).
|
|
13366
|
+
*/
|
|
13367
|
+
function ɵinitialKeyboardState() {
|
|
13368
|
+
return closedKeyboard(typeof window === "undefined" ? 0 : window.innerHeight);
|
|
13369
|
+
}
|
|
13370
|
+
/**
|
|
13371
|
+
* Calls `listener` with {@link ɵreadKeyboardState} now and on each visual
|
|
13372
|
+
* viewport resize or scroll. Does nothing during SSR or without the Visual
|
|
13373
|
+
* Viewport API. Returns the unsubscribe function.
|
|
13374
|
+
*/
|
|
13375
|
+
function ɵwatchKeyboardState(listener) {
|
|
13376
|
+
if (typeof window === "undefined") return () => {};
|
|
13377
|
+
const visualViewport = window.visualViewport;
|
|
13378
|
+
if (!visualViewport) return () => {};
|
|
13379
|
+
const update = () => listener(ɵreadKeyboardState());
|
|
13380
|
+
update();
|
|
13381
|
+
visualViewport.addEventListener("resize", update);
|
|
13382
|
+
visualViewport.addEventListener("scroll", update);
|
|
13383
|
+
return () => {
|
|
13384
|
+
visualViewport.removeEventListener("resize", update);
|
|
13385
|
+
visualViewport.removeEventListener("scroll", update);
|
|
13386
|
+
};
|
|
13387
|
+
}
|
|
13388
|
+
/** Escapes `id` for a CSS attribute selector, also without `CSS.escape`. */
|
|
13389
|
+
const escapeSelectorValue = (id) => typeof CSS !== "undefined" && typeof CSS.escape === "function" ? CSS.escape(id) : id.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g, "\\$&");
|
|
13390
|
+
/**
|
|
13391
|
+
* Offset of `el` from the top of `stopAt`'s content, including `stopAt`'s
|
|
13392
|
+
* scroll. Uses `getBoundingClientRect`, so it works for any CSS position.
|
|
13393
|
+
*/
|
|
13394
|
+
const offsetTopWithin = (el, stopAt) => el.getBoundingClientRect().top - stopAt.getBoundingClientRect().top + stopAt.scrollTop;
|
|
13395
|
+
/**
|
|
13396
|
+
* Pins a sent message to the top of the chat: sizes the spacer so the
|
|
13397
|
+
* message bubble can scroll to `topOffset` from the viewport top, scrolls
|
|
13398
|
+
* there on the next frame, and then shrinks the spacer as the reply below
|
|
13399
|
+
* grows, so the bubble stays put.
|
|
13400
|
+
*
|
|
13401
|
+
* The message element's top padding is scrolled off-screen: the bubble, not
|
|
13402
|
+
* its padded box, is pinned. Does nothing when no element in `contentEl` has
|
|
13403
|
+
* `data-message-id` equal to `messageId`. Skips the scroll without
|
|
13404
|
+
* `requestAnimationFrame` and the spacer updates without `ResizeObserver`.
|
|
13405
|
+
*
|
|
13406
|
+
* @returns A function that cancels the scroll and stops the spacer updates.
|
|
13407
|
+
* It returns `false` when it cancelled a scroll that had not run yet, so the
|
|
13408
|
+
* caller can pin the same send again. React's StrictMode tears an effect
|
|
13409
|
+
* down before the next frame, so the first run never scrolls.
|
|
13410
|
+
*
|
|
13411
|
+
* @example
|
|
13412
|
+
* ```ts
|
|
13413
|
+
* const unpin = ɵpinMessageToTop({ scrollEl, contentEl, spacerEl, messageId });
|
|
13414
|
+
* // On the next send or on unmount:
|
|
13415
|
+
* unpin();
|
|
13416
|
+
* ```
|
|
13417
|
+
*/
|
|
13418
|
+
function ɵpinMessageToTop({ scrollEl, contentEl, spacerEl, messageId, topOffset = 16 }) {
|
|
13419
|
+
const targetEl = contentEl.querySelector(`[data-message-id="${escapeSelectorValue(messageId)}"]`);
|
|
13420
|
+
if (!targetEl) return () => true;
|
|
13421
|
+
const viewportHeight = scrollEl.clientHeight;
|
|
13422
|
+
const userMessageHeight = targetEl.getBoundingClientRect().height;
|
|
13423
|
+
const paddingTop = parseFloat(getComputedStyle(targetEl).paddingTop) || 0;
|
|
13424
|
+
const bubbleHeight = Math.max(0, userMessageHeight - paddingTop);
|
|
13425
|
+
const spacerHeight = Math.max(0, viewportHeight - bubbleHeight - topOffset);
|
|
13426
|
+
spacerEl.style.height = `${spacerHeight}px`;
|
|
13427
|
+
let scrolled = false;
|
|
13428
|
+
const frame = typeof requestAnimationFrame === "function" ? requestAnimationFrame(() => {
|
|
13429
|
+
scrolled = true;
|
|
13430
|
+
const targetTop = offsetTopWithin(targetEl, scrollEl) + paddingTop - topOffset;
|
|
13431
|
+
scrollEl.scrollTo({
|
|
13432
|
+
top: Math.max(0, targetTop),
|
|
13433
|
+
behavior: "smooth"
|
|
13434
|
+
});
|
|
13435
|
+
}) : null;
|
|
13436
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(() => {
|
|
13437
|
+
const consumedBelow = contentEl.getBoundingClientRect().height - offsetTopWithin(targetEl, contentEl) - userMessageHeight;
|
|
13438
|
+
const remaining = Math.max(0, spacerHeight - consumedBelow);
|
|
13439
|
+
spacerEl.style.height = `${remaining}px`;
|
|
13440
|
+
});
|
|
13441
|
+
observer === null || observer === void 0 || observer.observe(contentEl);
|
|
13442
|
+
return () => {
|
|
13443
|
+
if (frame !== null && typeof cancelAnimationFrame === "function") cancelAnimationFrame(frame);
|
|
13444
|
+
observer === null || observer === void 0 || observer.disconnect();
|
|
13445
|
+
return frame === null || scrolled;
|
|
13446
|
+
};
|
|
13447
|
+
}
|
|
13448
|
+
|
|
13449
|
+
//#endregion
|
|
13450
|
+
//#region src/chat/message-display.ts
|
|
13451
|
+
/**
|
|
13452
|
+
* How long the model reasoned, as label text: "a few seconds", "4 seconds",
|
|
13453
|
+
* "2 minutes", or "1m 5s".
|
|
13454
|
+
*
|
|
13455
|
+
* @param seconds - The elapsed time in seconds. It may have a fraction.
|
|
13456
|
+
* @param labels - The chat labels that hold the duration texts.
|
|
13457
|
+
*/
|
|
13458
|
+
function ɵformatReasoningDurationLabel(seconds, labels) {
|
|
13459
|
+
const duration = formatReasoningDuration(seconds);
|
|
13460
|
+
switch (duration.unit) {
|
|
13461
|
+
case "fewSeconds": return labels.reasoningMessageDurationFewSeconds;
|
|
13462
|
+
case "seconds": return ɵformatLabel(labels.reasoningMessageDurationSeconds, { count: duration.seconds });
|
|
13463
|
+
case "minutes": return ɵformatCountLabel(duration.minutes, {
|
|
13464
|
+
one: labels.reasoningMessageDurationMinutesOne,
|
|
13465
|
+
other: labels.reasoningMessageDurationMinutesOther
|
|
13466
|
+
});
|
|
13467
|
+
case "minutesSeconds": return ɵformatLabel(labels.reasoningMessageDurationMinutesSeconds, {
|
|
13468
|
+
minutes: duration.minutes,
|
|
13469
|
+
seconds: duration.seconds
|
|
13470
|
+
});
|
|
13471
|
+
}
|
|
13472
|
+
}
|
|
13473
|
+
/**
|
|
13474
|
+
* The text of the work summary line at the top of a reply in the `"turn"`
|
|
13475
|
+
* tool-call display.
|
|
13476
|
+
*
|
|
13477
|
+
* - While working: `label` is "Working" and `detail` the live timer ("4s"),
|
|
13478
|
+
* or `null` when the elapsed time is not known.
|
|
13479
|
+
* - When done with a known time: `label` is "Worked for 9s" (at least 1s)
|
|
13480
|
+
* and `detail` the tool count ("7 tools").
|
|
13481
|
+
* - When done without a time: `label` is "Used 7 tools" and `detail` `null`.
|
|
13482
|
+
* - `failed` is "2 failed" when tool calls failed, otherwise `null`. It is
|
|
13483
|
+
* always `null` while working.
|
|
13484
|
+
*/
|
|
13485
|
+
function ɵgetWorkSummaryText({ isWorking, calls, elapsedMs, workingSince, now, labels }) {
|
|
13486
|
+
if (isWorking) {
|
|
13487
|
+
const isTimed = elapsedMs !== void 0 && workingSince !== void 0;
|
|
13488
|
+
return {
|
|
13489
|
+
label: labels.workSummaryWorkingLabel,
|
|
13490
|
+
detail: isTimed ? formatWorkDuration(elapsedMs + Math.max(0, now - workingSince)) : null,
|
|
13491
|
+
failed: null
|
|
13492
|
+
};
|
|
13493
|
+
}
|
|
13494
|
+
const failedCount = countFailedToolCalls(calls);
|
|
13495
|
+
const failed = failedCount > 0 ? ɵformatLabel(labels.toolCallFailedCountLabel, { count: failedCount }) : null;
|
|
13496
|
+
if (elapsedMs === void 0) return {
|
|
13497
|
+
label: ɵformatCountLabel(calls.length, {
|
|
13498
|
+
one: labels.toolCallUsedToolsOne,
|
|
13499
|
+
other: labels.toolCallUsedToolsOther
|
|
13500
|
+
}),
|
|
13501
|
+
detail: null,
|
|
13502
|
+
failed
|
|
13503
|
+
};
|
|
13504
|
+
const duration = formatWorkDuration(Math.max(1e3, elapsedMs));
|
|
13505
|
+
return {
|
|
13506
|
+
label: ɵformatLabel(labels.workSummaryWorkedForLabel, { duration }),
|
|
13507
|
+
detail: ɵformatCountLabel(calls.length, {
|
|
13508
|
+
one: labels.toolCallToolCountOne,
|
|
13509
|
+
other: labels.toolCallToolCountOther
|
|
13510
|
+
}),
|
|
13511
|
+
failed
|
|
13512
|
+
};
|
|
13513
|
+
}
|
|
13514
|
+
/**
|
|
13515
|
+
* The text of a user message: the string content, or its text parts joined
|
|
13516
|
+
* by newlines. Parts that are not text, and malformed parts from untyped
|
|
13517
|
+
* data, add nothing.
|
|
13518
|
+
*/
|
|
13519
|
+
function ɵflattenUserMessageContent(content) {
|
|
13520
|
+
if (!content) return "";
|
|
13521
|
+
if (typeof content === "string") return content;
|
|
13522
|
+
return content.map((part) => (part === null || part === void 0 ? void 0 : part.type) === "text" && typeof part.text === "string" ? part.text : "").filter((text) => text.length > 0).join("\n");
|
|
13523
|
+
}
|
|
13524
|
+
const isMediaPart = (part) => (part === null || part === void 0 ? void 0 : part.type) === "image" || (part === null || part === void 0 ? void 0 : part.type) === "audio" || (part === null || part === void 0 ? void 0 : part.type) === "video" || (part === null || part === void 0 ? void 0 : part.type) === "document";
|
|
13525
|
+
/** The image, audio, video, and document parts of a user message. */
|
|
13526
|
+
function ɵgetUserMessageMediaParts(content) {
|
|
13527
|
+
if (!content || typeof content === "string") return [];
|
|
13528
|
+
return content.filter(isMediaPart);
|
|
13529
|
+
}
|
|
13530
|
+
/** The file name stored in an attachment's `metadata.filename`, if any. */
|
|
13531
|
+
function ɵgetUserMessageMediaFilename(part) {
|
|
13532
|
+
const meta = part.metadata;
|
|
13533
|
+
return meta != null && typeof meta === "object" && "filename" in meta && typeof meta.filename === "string" ? meta.filename : void 0;
|
|
13534
|
+
}
|
|
13535
|
+
/**
|
|
13536
|
+
* Whether a user message shows its branch navigation and which arrows work.
|
|
13537
|
+
* It shows only with more than one branch and a switch handler: without the
|
|
13538
|
+
* handler the arrows would do nothing.
|
|
13539
|
+
*/
|
|
13540
|
+
function ɵgetBranchNavState({ branchIndex, numberOfBranches, canSwitch }) {
|
|
13541
|
+
const show = canSwitch && numberOfBranches > 1;
|
|
13542
|
+
return {
|
|
13543
|
+
show,
|
|
13544
|
+
canGoPrev: show && branchIndex > 0,
|
|
13545
|
+
canGoNext: show && branchIndex < numberOfBranches - 1
|
|
13546
|
+
};
|
|
13547
|
+
}
|
|
13548
|
+
/** Whether an assistant message has text beyond whitespace. */
|
|
13549
|
+
function ɵhasAssistantMessageText(content) {
|
|
13550
|
+
return !!content && content.trim().length > 0;
|
|
13551
|
+
}
|
|
13552
|
+
/**
|
|
13553
|
+
* Whether an assistant message shows its toolbar: when toolbars are on, the
|
|
13554
|
+
* message has text or the Inspector shortcut shows, and the message is not
|
|
13555
|
+
* the one still streaming (the latest while the agent runs).
|
|
13556
|
+
*/
|
|
13557
|
+
function ɵshouldShowAssistantToolbar({ toolbarVisible, hasContent, showInspectorShortcut, isRunning, isLatest }) {
|
|
13558
|
+
return toolbarVisible && (hasContent || showInspectorShortcut) && !(isRunning && isLatest);
|
|
13559
|
+
}
|
|
13560
|
+
/** How long a copy button shows its "copied" check mark, in ms. */
|
|
13561
|
+
const ɵCOPY_FEEDBACK_RESET_MS = 2e3;
|
|
13562
|
+
var _listeners$2 = /* @__PURE__ */ new WeakMap();
|
|
13563
|
+
var _resetMs = /* @__PURE__ */ new WeakMap();
|
|
13564
|
+
var _copied = /* @__PURE__ */ new WeakMap();
|
|
13565
|
+
var _timer$2 = /* @__PURE__ */ new WeakMap();
|
|
13566
|
+
var _ɵCopyFeedback_brand = /* @__PURE__ */ new WeakSet();
|
|
13567
|
+
/**
|
|
13568
|
+
* The "copied" state of a copy button. After a copy it is `true` for
|
|
13569
|
+
* {@link ɵCOPY_FEEDBACK_RESET_MS}; another copy in that time restarts the
|
|
13570
|
+
* wait, so rapid clicks do not flicker.
|
|
13571
|
+
*
|
|
13572
|
+
* Frameworks render from `getSnapshot()` and re-render when `subscribe()`
|
|
13573
|
+
* notifies. Call `dispose()` on unmount. The controller stays usable after
|
|
13574
|
+
* `dispose()`, so a remount (React Strict Mode) can keep it.
|
|
13575
|
+
*
|
|
13576
|
+
* @example
|
|
13577
|
+
* ```ts
|
|
13578
|
+
* const feedback = new ɵCopyFeedback();
|
|
13579
|
+
* feedback.subscribe(() => render(feedback.getSnapshot()));
|
|
13580
|
+
* await feedback.copy(text);
|
|
13581
|
+
* ```
|
|
13582
|
+
*/
|
|
13583
|
+
var ɵCopyFeedback = class {
|
|
13584
|
+
constructor({ resetMs = ɵCOPY_FEEDBACK_RESET_MS } = {}) {
|
|
13585
|
+
_classPrivateMethodInitSpec(this, _ɵCopyFeedback_brand);
|
|
13586
|
+
_classPrivateFieldInitSpec(this, _listeners$2, /* @__PURE__ */ new Set());
|
|
13587
|
+
_classPrivateFieldInitSpec(this, _resetMs, void 0);
|
|
13588
|
+
_classPrivateFieldInitSpec(this, _copied, false);
|
|
13589
|
+
_classPrivateFieldInitSpec(this, _timer$2, void 0);
|
|
13590
|
+
_defineProperty(
|
|
13591
|
+
this,
|
|
13592
|
+
/** Whether the check mark shows. */
|
|
13593
|
+
"getSnapshot",
|
|
13594
|
+
() => _classPrivateFieldGet2(_copied, this)
|
|
13595
|
+
);
|
|
13596
|
+
_defineProperty(
|
|
13597
|
+
this,
|
|
13598
|
+
/** Calls `listener` when the state changes. Returns the unsubscribe function. */
|
|
13599
|
+
"subscribe",
|
|
13600
|
+
(listener) => {
|
|
13601
|
+
_classPrivateFieldGet2(_listeners$2, this).add(listener);
|
|
13602
|
+
return () => {
|
|
13603
|
+
_classPrivateFieldGet2(_listeners$2, this).delete(listener);
|
|
13604
|
+
};
|
|
13605
|
+
}
|
|
13606
|
+
);
|
|
13607
|
+
_defineProperty(
|
|
13608
|
+
this,
|
|
13609
|
+
/** Shows the check mark, or keeps it for the full time again. */
|
|
13610
|
+
"markCopied",
|
|
13611
|
+
() => {
|
|
13612
|
+
_assertClassBrand(_ɵCopyFeedback_brand, this, _clearTimer$1).call(this);
|
|
13613
|
+
_assertClassBrand(_ɵCopyFeedback_brand, this, _set).call(this, true);
|
|
13614
|
+
_classPrivateFieldSet2(_timer$2, this, setTimeout(() => {
|
|
13615
|
+
_classPrivateFieldSet2(_timer$2, this, void 0);
|
|
13616
|
+
_assertClassBrand(_ɵCopyFeedback_brand, this, _set).call(this, false);
|
|
13617
|
+
}, _classPrivateFieldGet2(_resetMs, this)));
|
|
13618
|
+
}
|
|
13619
|
+
);
|
|
13620
|
+
_defineProperty(
|
|
13621
|
+
this,
|
|
13622
|
+
/**
|
|
13623
|
+
* Copies `text` to the clipboard and shows the check mark on success.
|
|
13624
|
+
* Empty text copies nothing.
|
|
13625
|
+
*
|
|
13626
|
+
* @returns Whether the text was copied.
|
|
13627
|
+
*/
|
|
13628
|
+
"copy",
|
|
13629
|
+
async (text) => {
|
|
13630
|
+
if (!text) return false;
|
|
13631
|
+
const copied = await (0, _copilotkit_shared.copyToClipboard)(text);
|
|
13632
|
+
if (copied) this.markCopied();
|
|
13633
|
+
return copied;
|
|
13634
|
+
}
|
|
13635
|
+
);
|
|
13636
|
+
_defineProperty(
|
|
13637
|
+
this,
|
|
13638
|
+
/** Stops the reset timer. */
|
|
13639
|
+
"dispose",
|
|
13640
|
+
() => {
|
|
13641
|
+
_assertClassBrand(_ɵCopyFeedback_brand, this, _clearTimer$1).call(this);
|
|
13642
|
+
}
|
|
13643
|
+
);
|
|
13644
|
+
_classPrivateFieldSet2(_resetMs, this, resetMs);
|
|
13645
|
+
}
|
|
13646
|
+
};
|
|
13647
|
+
function _clearTimer$1() {
|
|
13648
|
+
if (_classPrivateFieldGet2(_timer$2, this) === void 0) return;
|
|
13649
|
+
clearTimeout(_classPrivateFieldGet2(_timer$2, this));
|
|
13650
|
+
_classPrivateFieldSet2(_timer$2, this, void 0);
|
|
13651
|
+
}
|
|
13652
|
+
function _set(copied) {
|
|
13653
|
+
if (copied === _classPrivateFieldGet2(_copied, this)) return;
|
|
13654
|
+
_classPrivateFieldSet2(_copied, this, copied);
|
|
13655
|
+
for (const listener of _classPrivateFieldGet2(_listeners$2, this)) listener();
|
|
13656
|
+
}
|
|
13657
|
+
|
|
13658
|
+
//#endregion
|
|
13659
|
+
//#region src/chat/inspector-button.ts
|
|
13660
|
+
let shortcutsHidden = false;
|
|
13661
|
+
const shortcutListeners = /* @__PURE__ */ new Set();
|
|
13662
|
+
const notifyShortcutListeners = () => {
|
|
13663
|
+
for (const listener of shortcutListeners) listener();
|
|
13664
|
+
};
|
|
13665
|
+
/**
|
|
13666
|
+
* Whether the user hid the Inspector shortcuts in the message toolbars
|
|
13667
|
+
* ("Hide this icon"). It lasts until the page reloads and applies to every
|
|
13668
|
+
* chat on the page.
|
|
13669
|
+
*
|
|
13670
|
+
* @example
|
|
13671
|
+
* ```ts
|
|
13672
|
+
* ɵinspectorShortcuts.subscribe(() => render(ɵinspectorShortcuts.hidden));
|
|
13673
|
+
* ɵinspectorShortcuts.hide();
|
|
13674
|
+
* ```
|
|
13675
|
+
*/
|
|
13676
|
+
const ɵinspectorShortcuts = {
|
|
13677
|
+
get hidden() {
|
|
13678
|
+
return shortcutsHidden;
|
|
13679
|
+
},
|
|
13680
|
+
hide() {
|
|
13681
|
+
if (shortcutsHidden) return;
|
|
13682
|
+
shortcutsHidden = true;
|
|
13683
|
+
notifyShortcutListeners();
|
|
13684
|
+
},
|
|
13685
|
+
subscribe(listener) {
|
|
13686
|
+
shortcutListeners.add(listener);
|
|
13687
|
+
return () => {
|
|
13688
|
+
shortcutListeners.delete(listener);
|
|
13689
|
+
};
|
|
13690
|
+
},
|
|
13691
|
+
reset() {
|
|
13692
|
+
if (!shortcutsHidden) return;
|
|
13693
|
+
shortcutsHidden = false;
|
|
13694
|
+
notifyShortcutListeners();
|
|
13695
|
+
}
|
|
13696
|
+
};
|
|
13697
|
+
const kiteStroke = (d, stroke, strokeWidth) => ({
|
|
13698
|
+
d,
|
|
13699
|
+
stroke,
|
|
13700
|
+
strokeWidth,
|
|
13701
|
+
strokeLinecap: "round"
|
|
13702
|
+
});
|
|
13703
|
+
/**
|
|
13704
|
+
* The Inspector kite artwork as data, as in
|
|
13705
|
+
* `web-inspector/src/assets/inspector-logo-kite.svg`. Render an `<svg>` with
|
|
13706
|
+
* `viewBox` and `fill="none"`, one `<path>` per entry of `paths`, and a
|
|
13707
|
+
* `<linearGradient gradientUnits="userSpaceOnUse">` per entry of `gradients`
|
|
13708
|
+
* in `<defs>`. Give each gradient the id `${prefix}-${gradient.id}` with a
|
|
13709
|
+
* prefix unique to the icon, and fill paths with
|
|
13710
|
+
* {@link ɵinspectorKiteFill}.
|
|
13711
|
+
*/
|
|
13712
|
+
const ɵinspectorKiteIcon = {
|
|
13713
|
+
viewBox: "4.57 3.36 17.8 17.8",
|
|
13714
|
+
paths: [
|
|
13715
|
+
{
|
|
13716
|
+
d: "M6.36084 10.9855C8.34277 8.393 9.98843 5.82939 10.6204 3.75914C10.6382 3.70281 10.7043 3.67888 10.7534 3.7114C12.9536 5.16894 16.9635 6.12833 20.5086 6.15085C20.5703 6.15124 20.6124 6.2114 20.5895 6.26829C19.4109 9.25938 17.9705 14.6189 17.9148 20.7392C17.9148 20.8301 17.7873 20.8627 17.7419 20.7837C15.7236 17.2522 9.26021 12.2898 6.39414 11.1186C6.34112 11.0968 6.32556 11.0313 6.36084 10.9855Z",
|
|
13717
|
+
fillGradient: "paint0_linear"
|
|
13718
|
+
},
|
|
13719
|
+
{
|
|
13720
|
+
d: "M13.0475 9.39974C9.95016 10.3806 7.11935 10.9259 6.44331 11.0498C6.40027 11.0577 6.39115 11.1172 6.43152 11.134C9.3203 12.3347 15.7516 17.2826 17.7511 20.7998C17.7551 20.8075 17.7647 20.8103 17.7728 20.8068C17.7809 20.803 17.7853 20.793 17.7819 20.7844L13.0475 9.39974Z",
|
|
13721
|
+
fillGradient: "paint1_linear"
|
|
13722
|
+
},
|
|
13723
|
+
{
|
|
13724
|
+
d: "M10.762 3.705C13.4137 5.15161 16.4787 5.80132 20.545 6.14367C20.5703 6.14585 20.5787 6.18008 20.5557 6.19197C20.0359 6.45923 17.0574 7.97512 14.8455 8.78701C14.2524 9.00453 13.6564 9.20632 13.0692 9.39249C13.0562 9.39656 13.0419 9.39015 13.0369 9.37774L10.7005 3.75979C10.6849 3.72196 10.7257 3.68538 10.762 3.705Z",
|
|
13725
|
+
fillGradient: "paint2_linear"
|
|
13726
|
+
},
|
|
13727
|
+
kiteStroke("M10.7145 3.79041L17.8305 20.7659", "#513C9F", "0.17284"),
|
|
13728
|
+
kiteStroke("M6.44531 11.0476C6.44531 11.0476 10.375 10.3422 14.0686 9.06804C17.7623 7.7939 20.5122 6.23373 20.5122 6.23373", "#513C9F", "0.17284"),
|
|
13729
|
+
kiteStroke("M11.6914 5.93518L9.05534 14.7068M9.05534 14.7068H15.3203M9.05534 14.7068L0.15625 26.3646", "#ABABAB", "0.302474"),
|
|
13730
|
+
{
|
|
13731
|
+
d: "M6.02539 23.9646L4.85806 24.1287C5.46272 25.7287 6.70381 26.4276 8.18528 26.4276C11.8147 26.4276 10.707 22.3227 12.8103 22.3227C14.3358 22.3227 13.7155 25.6498 16.9992 25.6498C19.0029 25.6498 19.2028 23.631 18.8607 22.7625C18.8589 22.7572 18.8568 22.7524 18.8538 22.7476L18.3166 21.9253C18.2817 21.8706 18.1968 21.8912 18.1907 21.9562L18.0908 22.9529C18.0838 23.0222 18.0857 23.0913 18.0936 23.1605C18.1764 23.8491 18.2291 25.5202 16.9992 25.5202C15.7015 25.5202 15.3895 22.2362 12.8103 22.2362C9.78393 22.2362 10.1726 26.298 8.31487 26.298C7.08938 26.298 6.15447 24.9153 6.02539 23.9646Z",
|
|
13732
|
+
fillGradient: "paint3_linear"
|
|
13733
|
+
}
|
|
13734
|
+
],
|
|
13735
|
+
gradients: [
|
|
13736
|
+
{
|
|
13737
|
+
id: "paint0_linear",
|
|
13738
|
+
x1: "15.5372",
|
|
13739
|
+
y1: "5.0278",
|
|
13740
|
+
x2: "12.0802",
|
|
13741
|
+
y2: "14.534",
|
|
13742
|
+
stops: [{ color: "#6430AB" }, {
|
|
13743
|
+
offset: "1",
|
|
13744
|
+
color: "#AA89D8"
|
|
13745
|
+
}]
|
|
13746
|
+
},
|
|
13747
|
+
{
|
|
13748
|
+
id: "paint1_linear",
|
|
13749
|
+
x1: "12.8583",
|
|
13750
|
+
y1: "10.3858",
|
|
13751
|
+
x2: "8.40764",
|
|
13752
|
+
y2: "18.9846",
|
|
13753
|
+
stops: [{ color: "#005DBB" }, {
|
|
13754
|
+
offset: "1",
|
|
13755
|
+
color: "#3D92E8"
|
|
13756
|
+
}]
|
|
13757
|
+
},
|
|
13758
|
+
{
|
|
13759
|
+
id: "paint2_linear",
|
|
13760
|
+
x1: "14.8452",
|
|
13761
|
+
y1: "5.02774",
|
|
13762
|
+
x2: "13.5047",
|
|
13763
|
+
y2: "9.21911",
|
|
13764
|
+
stops: [{ color: "#1B70C4" }, {
|
|
13765
|
+
offset: "1",
|
|
13766
|
+
color: "#54A4F2"
|
|
13767
|
+
}]
|
|
13768
|
+
},
|
|
13769
|
+
{
|
|
13770
|
+
id: "paint3_linear",
|
|
13771
|
+
x1: "4.85806",
|
|
13772
|
+
y1: "24.2455",
|
|
13773
|
+
x2: "18.9963",
|
|
13774
|
+
y2: "24.2455",
|
|
13775
|
+
stops: [
|
|
13776
|
+
{ color: "#4497EA" },
|
|
13777
|
+
{
|
|
13778
|
+
offset: "0.254755",
|
|
13779
|
+
color: "#1463B2"
|
|
13780
|
+
},
|
|
13781
|
+
{
|
|
13782
|
+
offset: "0.498725",
|
|
13783
|
+
color: "#0A437D"
|
|
13784
|
+
},
|
|
13785
|
+
{
|
|
13786
|
+
offset: "0.666667",
|
|
13787
|
+
color: "#2476C8"
|
|
13788
|
+
},
|
|
13789
|
+
{
|
|
13790
|
+
offset: "0.972542",
|
|
13791
|
+
color: "#0C549A"
|
|
13792
|
+
}
|
|
13793
|
+
]
|
|
13794
|
+
}
|
|
13795
|
+
]
|
|
13796
|
+
};
|
|
13797
|
+
/**
|
|
13798
|
+
* The `fill` of a kite path: its gradient under the icon's id `prefix`, or
|
|
13799
|
+
* `undefined` for a stroke-only path.
|
|
13800
|
+
*/
|
|
13801
|
+
function ɵinspectorKiteFill(prefix, path) {
|
|
13802
|
+
return path.fillGradient === void 0 ? void 0 : `url(#${prefix}-${path.fillGradient})`;
|
|
13803
|
+
}
|
|
13804
|
+
/** How long a hover-opened menu stays after the pointer leaves, in ms. */
|
|
13805
|
+
const ɵHOVER_MENU_CLOSE_DELAY_MS = 180;
|
|
13806
|
+
var _closeDelayMs = /* @__PURE__ */ new WeakMap();
|
|
13807
|
+
var _listeners$1 = /* @__PURE__ */ new WeakMap();
|
|
13808
|
+
var _state$1 = /* @__PURE__ */ new WeakMap();
|
|
13809
|
+
var _timer$1 = /* @__PURE__ */ new WeakMap();
|
|
13810
|
+
var _openedByHover = /* @__PURE__ */ new WeakMap();
|
|
13811
|
+
/**
|
|
13812
|
+
* The open state of a menu that opens when the pointer reaches its trigger,
|
|
13813
|
+
* like the Inspector shortcut's menu.
|
|
13814
|
+
*
|
|
13815
|
+
* - A mouse or pen over the trigger opens it; touch does not.
|
|
13816
|
+
* - Leaving the trigger or the menu closes it after `closeDelayMs`, unless
|
|
13817
|
+
* the pointer comes back first or the keyboard has used the menu since.
|
|
13818
|
+
* - Opening reads whether the trigger is inside a `.dark` element, so a menu
|
|
13819
|
+
* in a portal can match the theme.
|
|
13820
|
+
*
|
|
13821
|
+
* Frameworks render from `getSnapshot()` and re-render when `subscribe()`
|
|
13822
|
+
* notifies. Call `dispose()` on unmount; the controller stays usable.
|
|
13823
|
+
*/
|
|
13824
|
+
var ɵHoverMenuController = class {
|
|
13825
|
+
constructor({ closeDelayMs = ɵHOVER_MENU_CLOSE_DELAY_MS } = {}) {
|
|
13826
|
+
_classPrivateFieldInitSpec(this, _closeDelayMs, void 0);
|
|
13827
|
+
_classPrivateFieldInitSpec(this, _listeners$1, /* @__PURE__ */ new Set());
|
|
13828
|
+
_classPrivateFieldInitSpec(this, _state$1, {
|
|
13829
|
+
open: false,
|
|
13830
|
+
dark: false
|
|
13831
|
+
});
|
|
13832
|
+
_classPrivateFieldInitSpec(this, _timer$1, void 0);
|
|
13833
|
+
_classPrivateFieldInitSpec(this, _openedByHover, false);
|
|
13834
|
+
_defineProperty(
|
|
13835
|
+
this,
|
|
13836
|
+
/** The current state. The same object until something changes. */
|
|
13837
|
+
"getSnapshot",
|
|
13838
|
+
() => _classPrivateFieldGet2(_state$1, this)
|
|
13839
|
+
);
|
|
13840
|
+
_defineProperty(
|
|
13841
|
+
this,
|
|
13842
|
+
/** Calls `listener` when the state changes. Returns the unsubscribe function. */
|
|
13843
|
+
"subscribe",
|
|
13844
|
+
(listener) => {
|
|
13845
|
+
_classPrivateFieldGet2(_listeners$1, this).add(listener);
|
|
13846
|
+
return () => {
|
|
13847
|
+
_classPrivateFieldGet2(_listeners$1, this).delete(listener);
|
|
13848
|
+
};
|
|
13849
|
+
}
|
|
13850
|
+
);
|
|
13851
|
+
_defineProperty(
|
|
13852
|
+
this,
|
|
13853
|
+
/**
|
|
13854
|
+
* Opens or closes the menu and stops a pending close. `trigger` is read on
|
|
13855
|
+
* open for the dark theme.
|
|
13856
|
+
*/
|
|
13857
|
+
"setOpen",
|
|
13858
|
+
(open, trigger) => {
|
|
13859
|
+
this.cancelClose();
|
|
13860
|
+
const dark = open ? !!(trigger === null || trigger === void 0 ? void 0 : trigger.closest(".dark")) : _classPrivateFieldGet2(_state$1, this).dark;
|
|
13861
|
+
if (open === _classPrivateFieldGet2(_state$1, this).open && dark === _classPrivateFieldGet2(_state$1, this).dark) return;
|
|
13862
|
+
_classPrivateFieldSet2(_state$1, this, {
|
|
13863
|
+
open,
|
|
13864
|
+
dark
|
|
13865
|
+
});
|
|
13866
|
+
for (const listener of _classPrivateFieldGet2(_listeners$1, this)) listener();
|
|
13867
|
+
}
|
|
13868
|
+
);
|
|
13869
|
+
_defineProperty(
|
|
13870
|
+
this,
|
|
13871
|
+
/** The pointer reached the trigger: opens, except for touch or disabled. */
|
|
13872
|
+
"pointerEnter",
|
|
13873
|
+
({ pointerType, disabled = false, trigger }) => {
|
|
13874
|
+
if (disabled || pointerType === "touch") return;
|
|
13875
|
+
_classPrivateFieldSet2(_openedByHover, this, true);
|
|
13876
|
+
this.setOpen(true, trigger);
|
|
13877
|
+
}
|
|
13878
|
+
);
|
|
13879
|
+
_defineProperty(
|
|
13880
|
+
this,
|
|
13881
|
+
/** The keyboard used the trigger or the menu: keep it open on leave. */
|
|
13882
|
+
"keyboardUsed",
|
|
13883
|
+
() => {
|
|
13884
|
+
_classPrivateFieldSet2(_openedByHover, this, false);
|
|
13885
|
+
}
|
|
13886
|
+
);
|
|
13887
|
+
_defineProperty(
|
|
13888
|
+
this,
|
|
13889
|
+
/** The pointer left the trigger or the menu: close soon if hover opened it. */
|
|
13890
|
+
"scheduleClose",
|
|
13891
|
+
() => {
|
|
13892
|
+
this.cancelClose();
|
|
13893
|
+
_classPrivateFieldSet2(_timer$1, this, setTimeout(() => {
|
|
13894
|
+
_classPrivateFieldSet2(_timer$1, this, void 0);
|
|
13895
|
+
if (_classPrivateFieldGet2(_openedByHover, this)) this.setOpen(false);
|
|
13896
|
+
}, _classPrivateFieldGet2(_closeDelayMs, this)));
|
|
13897
|
+
}
|
|
13898
|
+
);
|
|
13899
|
+
_defineProperty(
|
|
13900
|
+
this,
|
|
13901
|
+
/** The pointer came back: keep the menu open. */
|
|
13902
|
+
"cancelClose",
|
|
13903
|
+
() => {
|
|
13904
|
+
if (_classPrivateFieldGet2(_timer$1, this) === void 0) return;
|
|
13905
|
+
clearTimeout(_classPrivateFieldGet2(_timer$1, this));
|
|
13906
|
+
_classPrivateFieldSet2(_timer$1, this, void 0);
|
|
13907
|
+
}
|
|
13908
|
+
);
|
|
13909
|
+
_defineProperty(
|
|
13910
|
+
this,
|
|
13911
|
+
/** Stops a pending close. */
|
|
13912
|
+
"dispose",
|
|
13913
|
+
() => {
|
|
13914
|
+
this.cancelClose();
|
|
13915
|
+
}
|
|
13916
|
+
);
|
|
13917
|
+
_classPrivateFieldSet2(_closeDelayMs, this, closeDelayMs);
|
|
13918
|
+
}
|
|
13919
|
+
/** Whether the pointer opened the menu and the keyboard has not used it. */
|
|
13920
|
+
get openedByHover() {
|
|
13921
|
+
return _classPrivateFieldGet2(_openedByHover, this);
|
|
13922
|
+
}
|
|
13923
|
+
};
|
|
13924
|
+
|
|
12782
13925
|
//#endregion
|
|
12783
13926
|
//#region src/open-generative-ui/content.ts
|
|
12784
13927
|
/**
|
|
@@ -13617,6 +14760,28 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
13617
14760
|
for (const listener of _classPrivateFieldGet2(_listeners, this)) listener();
|
|
13618
14761
|
}
|
|
13619
14762
|
|
|
14763
|
+
//#endregion
|
|
14764
|
+
//#region src/utils/class-names.ts
|
|
14765
|
+
/**
|
|
14766
|
+
* Joins class names, skipping falsy values. Takes the same inputs as `clsx`.
|
|
14767
|
+
* Classes are not merged: every rule CopilotKit ships sits in `:where()`, so a
|
|
14768
|
+
* class the app adds wins without removing ours.
|
|
14769
|
+
*/
|
|
14770
|
+
function cn(...inputs) {
|
|
14771
|
+
const out = [];
|
|
14772
|
+
for (const input of inputs) {
|
|
14773
|
+
if (!input) continue;
|
|
14774
|
+
if (typeof input === "string" || typeof input === "number" || typeof input === "bigint") out.push(String(input));
|
|
14775
|
+
else if (Array.isArray(input)) {
|
|
14776
|
+
const nested = cn(...input);
|
|
14777
|
+
if (nested) out.push(nested);
|
|
14778
|
+
} else if (typeof input === "object") {
|
|
14779
|
+
for (const key in input) if (input[key]) out.push(key);
|
|
14780
|
+
}
|
|
14781
|
+
}
|
|
14782
|
+
return out.join(" ");
|
|
14783
|
+
}
|
|
14784
|
+
|
|
13620
14785
|
//#endregion
|
|
13621
14786
|
exports.A2UI_FENCE_LANGUAGE = A2UI_FENCE_LANGUAGE;
|
|
13622
14787
|
exports.AgentRegistry = AgentRegistry;
|
|
@@ -13679,12 +14844,26 @@ exports.segmentSurfaceProse = segmentSurfaceProse;
|
|
|
13679
14844
|
exports.select = select;
|
|
13680
14845
|
exports.splitA2UIMarkdown = splitA2UIMarkdown;
|
|
13681
14846
|
exports.ɵCOPILOTKIT_FEATURES = ɵCOPILOTKIT_FEATURES;
|
|
14847
|
+
exports.ɵCOPY_FEEDBACK_RESET_MS = ɵCOPY_FEEDBACK_RESET_MS;
|
|
14848
|
+
exports.ɵCopyFeedback = ɵCopyFeedback;
|
|
14849
|
+
exports.ɵFEEDBACK_COMMENT_CLOSE_DELAY_MS = ɵFEEDBACK_COMMENT_CLOSE_DELAY_MS;
|
|
14850
|
+
exports.ɵFeedbackCommentController = ɵFeedbackCommentController;
|
|
14851
|
+
exports.ɵHOVER_MENU_CLOSE_DELAY_MS = ɵHOVER_MENU_CLOSE_DELAY_MS;
|
|
14852
|
+
exports.ɵHoverMenuController = ɵHoverMenuController;
|
|
14853
|
+
exports.ɵINLINE_FEATURE_WARNING_STYLE = ɵINLINE_FEATURE_WARNING_STYLE;
|
|
13682
14854
|
exports.ɵInterruptState = ɵInterruptState;
|
|
14855
|
+
exports.ɵKEYBOARD_OPEN_THRESHOLD_PX = ɵKEYBOARD_OPEN_THRESHOLD_PX;
|
|
14856
|
+
exports.ɵLICENSE_BANNER_OFFSET = ɵLICENSE_BANNER_OFFSET;
|
|
14857
|
+
exports.ɵLICENSE_BANNER_STYLE = ɵLICENSE_BANNER_STYLE;
|
|
13683
14858
|
exports.ɵMAX_SOCKET_RETRIES = ɵMAX_SOCKET_RETRIES;
|
|
14859
|
+
exports.ɵMESSAGE_FEEDBACK_EVENT_NAME = ɵMESSAGE_FEEDBACK_EVENT_NAME;
|
|
14860
|
+
exports.ɵMESSAGE_FEEDBACK_MAX_COMMENT_LENGTH = ɵMESSAGE_FEEDBACK_MAX_COMMENT_LENGTH;
|
|
14861
|
+
exports.ɵMOBILE_MAX_WIDTH_QUERY = ɵMOBILE_MAX_WIDTH_QUERY;
|
|
13684
14862
|
exports.ɵOpenGenerativeUIController = OpenGenerativeUIController;
|
|
13685
14863
|
exports.ɵRUNTIME_PROBE_TIMEOUT_MS = ɵRUNTIME_PROBE_TIMEOUT_MS;
|
|
13686
14864
|
exports.ɵTHREAD_REQUEST_TIMEOUT_MS = ɵTHREAD_REQUEST_TIMEOUT_MS;
|
|
13687
14865
|
exports.ɵclearAgentInterruptState = ɵclearAgentInterruptState;
|
|
14866
|
+
exports.ɵcn = cn;
|
|
13688
14867
|
exports.ɵcomposerButtonState = ɵcomposerButtonState;
|
|
13689
14868
|
exports.ɵcopilotIconSvgAttributes = ɵcopilotIconSvgAttributes;
|
|
13690
14869
|
exports.ɵcopilotIcons = ɵcopilotIcons;
|
|
@@ -13694,23 +14873,40 @@ exports.ɵcreateThreadSelectors = ɵcreateThreadSelectors;
|
|
|
13694
14873
|
exports.ɵcreateThreadStore = createThreadStore;
|
|
13695
14874
|
exports.ɵdeduplicateMessages = ɵdeduplicateMessages;
|
|
13696
14875
|
exports.ɵextractCompleteStyles = extractCompleteStyles;
|
|
14876
|
+
exports.ɵflattenUserMessageContent = ɵflattenUserMessageContent;
|
|
13697
14877
|
exports.ɵformatCountLabel = ɵformatCountLabel;
|
|
13698
14878
|
exports.ɵformatLabel = ɵformatLabel;
|
|
13699
14879
|
exports.ɵformatReasoningDuration = formatReasoningDuration;
|
|
14880
|
+
exports.ɵformatReasoningDurationLabel = ɵformatReasoningDurationLabel;
|
|
13700
14881
|
exports.ɵformatToolNames = formatToolNames;
|
|
13701
14882
|
exports.ɵformatWorkDuration = formatWorkDuration;
|
|
13702
14883
|
exports.ɵgetAgentInterruptState = ɵgetAgentInterruptState;
|
|
13703
14884
|
exports.ɵgetArgumentPreview = getArgumentPreview;
|
|
14885
|
+
exports.ɵgetBranchNavState = ɵgetBranchNavState;
|
|
14886
|
+
exports.ɵgetInlineFeatureWarningSpec = ɵgetInlineFeatureWarningSpec;
|
|
13704
14887
|
exports.ɵgetLatestTurnKey = getLatestTurnKey;
|
|
14888
|
+
exports.ɵgetLicenseBannerSpec = ɵgetLicenseBannerSpec;
|
|
14889
|
+
exports.ɵgetMessageFeedback = ɵgetMessageFeedback;
|
|
14890
|
+
exports.ɵgetMessageFeedbackControls = ɵgetMessageFeedbackControls;
|
|
13705
14891
|
exports.ɵgetToolCallLayouts = getToolCallLayouts;
|
|
13706
14892
|
exports.ɵgetToolCallPreview = getToolCallPreview;
|
|
13707
14893
|
exports.ɵgetToolCallRendererNames = getToolCallRendererNames;
|
|
13708
14894
|
exports.ɵgetToolCallRowStatus = getToolCallRowStatus;
|
|
13709
14895
|
exports.ɵgetToolResults = getToolResults;
|
|
13710
14896
|
exports.ɵgetTurnWork = getTurnWork;
|
|
14897
|
+
exports.ɵgetUserMessageMediaFilename = ɵgetUserMessageMediaFilename;
|
|
14898
|
+
exports.ɵgetUserMessageMediaParts = ɵgetUserMessageMediaParts;
|
|
13711
14899
|
exports.ɵgetWorkOpenState = getWorkOpenState;
|
|
14900
|
+
exports.ɵgetWorkSummaryText = ɵgetWorkSummaryText;
|
|
14901
|
+
exports.ɵhasAssistantMessageText = ɵhasAssistantMessageText;
|
|
14902
|
+
exports.ɵinitialKeyboardState = ɵinitialKeyboardState;
|
|
14903
|
+
exports.ɵinspectorKiteFill = ɵinspectorKiteFill;
|
|
14904
|
+
exports.ɵinspectorKiteIcon = ɵinspectorKiteIcon;
|
|
14905
|
+
exports.ɵinspectorShortcuts = ɵinspectorShortcuts;
|
|
13712
14906
|
exports.ɵisCopilotKitFeature = ɵisCopilotKitFeature;
|
|
13713
14907
|
exports.ɵisHttpAgent = ɵisHttpAgent;
|
|
14908
|
+
exports.ɵisLearningFeedbackEnabled = ɵisLearningFeedbackEnabled;
|
|
14909
|
+
exports.ɵisMobileViewport = ɵisMobileViewport;
|
|
13714
14910
|
exports.ɵisRetryableMemoryStatus = isRetryableStatus;
|
|
13715
14911
|
exports.ɵisTurnWorkOpen = isTurnWorkOpen;
|
|
13716
14912
|
exports.ɵisTurnWorking = isTurnWorking;
|
|
@@ -13722,15 +14918,20 @@ exports.ɵmemoryDomainEvents = ɵmemoryDomainEvents;
|
|
|
13722
14918
|
exports.ɵmemoryReducer = ɵmemoryReducer;
|
|
13723
14919
|
exports.ɵmemoryRestEvents = ɵmemoryRestEvents;
|
|
13724
14920
|
exports.ɵmessagesFingerprint = ɵmessagesFingerprint;
|
|
14921
|
+
exports.ɵnormalizeAutoScroll = ɵnormalizeAutoScroll;
|
|
13725
14922
|
exports.ɵobservePhoenixEvent$ = ɵobservePhoenixEvent$;
|
|
13726
14923
|
exports.ɵobservePhoenixJoinOutcome$ = ɵobservePhoenixJoinOutcome$;
|
|
13727
14924
|
exports.ɵobservePhoenixSocketHealth$ = ɵobservePhoenixSocketHealth$;
|
|
13728
14925
|
exports.ɵobservePhoenixSocketSignals$ = ɵobservePhoenixSocketSignals$;
|
|
13729
14926
|
exports.ɵphoenixChannel$ = ɵphoenixChannel$;
|
|
13730
14927
|
exports.ɵphoenixSocket$ = ɵphoenixSocket$;
|
|
14928
|
+
exports.ɵpinMessageToTop = ɵpinMessageToTop;
|
|
13731
14929
|
exports.ɵpluralize = pluralize;
|
|
13732
14930
|
exports.ɵprocessPartialHtml = processPartialHtml;
|
|
14931
|
+
exports.ɵreadKeyboardState = ɵreadKeyboardState;
|
|
13733
14932
|
exports.ɵrecordWorkTime = recordWorkTime;
|
|
14933
|
+
exports.ɵreserveLicenseBannerOffset = ɵreserveLicenseBannerOffset;
|
|
14934
|
+
exports.ɵresetMessageFeedbackCache = ɵresetMessageFeedbackCache;
|
|
13734
14935
|
exports.ɵresolveActivityRenderer = ɵresolveActivityRenderer;
|
|
13735
14936
|
exports.ɵresolveComposerKey = ɵresolveComposerKey;
|
|
13736
14937
|
exports.ɵresolveCustomMessageRenderers = ɵresolveCustomMessageRenderers;
|
|
@@ -13750,10 +14951,17 @@ exports.ɵselectMemoriesRealtimeStatus = ɵselectMemoriesRealtimeStatus;
|
|
|
13750
14951
|
exports.ɵselectThreads = ɵselectThreads;
|
|
13751
14952
|
exports.ɵselectThreadsError = ɵselectThreadsError;
|
|
13752
14953
|
exports.ɵselectThreadsIsLoading = ɵselectThreadsIsLoading;
|
|
14954
|
+
exports.ɵsetMessageFeedback = ɵsetMessageFeedback;
|
|
14955
|
+
exports.ɵshallowEqualRecord = shallowEqualRecord;
|
|
14956
|
+
exports.ɵshouldShowAssistantToolbar = ɵshouldShowAssistantToolbar;
|
|
13753
14957
|
exports.ɵstringifyToolCallPayload = stringifyToolCallPayload;
|
|
14958
|
+
exports.ɵsubscribeToLearningFeedbackEnabled = ɵsubscribeToLearningFeedbackEnabled;
|
|
14959
|
+
exports.ɵsubscribeToMessageFeedback = ɵsubscribeToMessageFeedback;
|
|
13754
14960
|
exports.ɵthreadAdapterEvents = ɵthreadAdapterEvents;
|
|
13755
14961
|
exports.ɵtranscribeAudio = ɵtranscribeAudio;
|
|
13756
14962
|
exports.ɵtranscriptionErrorMessageKey = ɵtranscriptionErrorMessageKey;
|
|
14963
|
+
exports.ɵwatchKeyboardState = ɵwatchKeyboardState;
|
|
14964
|
+
exports.ɵwatchMobileViewport = ɵwatchMobileViewport;
|
|
13757
14965
|
exports.ɵwithHeaderDefaults = ɵwithHeaderDefaults;
|
|
13758
14966
|
});
|
|
13759
14967
|
//# sourceMappingURL=index.umd.js.map
|