@vantageos/mosaic-blocks 0.5.6-alpha → 0.5.8-alpha
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/README.md +8 -5
- package/dist/index.cjs +513 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +305 -3
- package/dist/index.d.ts +305 -3
- package/dist/index.js +509 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ import { Menu } from '@base-ui/react/menu';
|
|
|
27
27
|
import { AlertDialog } from '@base-ui/react/alert-dialog';
|
|
28
28
|
|
|
29
29
|
// src/version.ts
|
|
30
|
-
var version = "0.5.
|
|
30
|
+
var version = "0.5.8-alpha";
|
|
31
31
|
function Placeholder({ label = "mosaic-blocks placeholder" }) {
|
|
32
32
|
return /* @__PURE__ */ jsx("div", { "data-mosaic-block": "placeholder", children: label });
|
|
33
33
|
}
|
|
@@ -11663,7 +11663,514 @@ function MosaicChatComposer(props) {
|
|
|
11663
11663
|
);
|
|
11664
11664
|
}
|
|
11665
11665
|
MosaicChatComposer.displayName = "MosaicChatComposer";
|
|
11666
|
+
var markdownRootVariants = cva([
|
|
11667
|
+
"min-w-0 text-[15px] leading-6 text-foreground [&>*:first-child]:mt-0 [&>*:last-child]:mb-0"
|
|
11668
|
+
]);
|
|
11669
|
+
var markdownHeadingVariants = cva(["font-medium tracking-normal text-foreground"], {
|
|
11670
|
+
variants: {
|
|
11671
|
+
level: {
|
|
11672
|
+
1: "mt-7 mb-4 text-xl leading-7",
|
|
11673
|
+
2: "mt-6 mb-3 text-base leading-6",
|
|
11674
|
+
3: "mt-5 mb-2 text-sm leading-6",
|
|
11675
|
+
4: "mt-4 mb-2 text-sm leading-6",
|
|
11676
|
+
5: "mt-4 mb-2 text-xs leading-5",
|
|
11677
|
+
6: "mt-4 mb-2 text-xs leading-5 text-muted-foreground"
|
|
11678
|
+
}
|
|
11679
|
+
},
|
|
11680
|
+
defaultVariants: {
|
|
11681
|
+
level: 1
|
|
11682
|
+
}
|
|
11683
|
+
});
|
|
11684
|
+
var markdownParagraphVariants = cva(["mb-3 text-[15px] leading-6 text-foreground"]);
|
|
11685
|
+
var markdownListVariants = cva(["mb-3 flex flex-col gap-1.5 pl-8 text-[15px] leading-6"], {
|
|
11686
|
+
variants: {
|
|
11687
|
+
ordered: {
|
|
11688
|
+
true: "list-decimal",
|
|
11689
|
+
false: "list-disc"
|
|
11690
|
+
}
|
|
11691
|
+
},
|
|
11692
|
+
defaultVariants: {
|
|
11693
|
+
ordered: false
|
|
11694
|
+
}
|
|
11695
|
+
});
|
|
11696
|
+
var markdownListItemVariants = cva(["pl-1 text-[15px] leading-6 text-foreground"]);
|
|
11697
|
+
var markdownBlockquoteVariants = cva([
|
|
11698
|
+
"mb-3 border-l-2 border-border pl-3 text-[15px] leading-6 text-muted-foreground"
|
|
11699
|
+
]);
|
|
11700
|
+
var markdownHrVariants = cva(["my-4 border-border/70"]);
|
|
11701
|
+
var markdownEmphasisVariants = cva([], {
|
|
11702
|
+
variants: {
|
|
11703
|
+
tone: {
|
|
11704
|
+
strong: "font-medium text-foreground",
|
|
11705
|
+
emphasis: "italic"
|
|
11706
|
+
}
|
|
11707
|
+
}
|
|
11708
|
+
});
|
|
11709
|
+
var markdownInlineCodeVariants = cva([
|
|
11710
|
+
"rounded-md border border-border/70 bg-muted/40 px-1.5 py-0.5 font-mono text-[0.92em] text-foreground"
|
|
11711
|
+
]);
|
|
11712
|
+
var markdownCodeBlockVariants = cva([
|
|
11713
|
+
"mb-3 overflow-x-auto rounded-md border border-border bg-muted/40 p-3 font-mono text-[0.92em] text-foreground"
|
|
11714
|
+
]);
|
|
11715
|
+
var markdownLinkVariants = cva([
|
|
11716
|
+
"font-medium text-foreground underline decoration-border underline-offset-4 transition-colors hover:decoration-foreground"
|
|
11717
|
+
]);
|
|
11718
|
+
var markdownTableWrapperVariants = cva(["mb-3 w-full overflow-x-auto"]);
|
|
11719
|
+
var markdownTableVariants = cva(["w-full border-collapse text-[15px] leading-6"]);
|
|
11720
|
+
var markdownTableCellVariants = cva(["border border-border px-3 py-1.5"], {
|
|
11721
|
+
variants: {
|
|
11722
|
+
header: {
|
|
11723
|
+
true: "bg-muted/40 font-medium text-foreground",
|
|
11724
|
+
false: "text-foreground"
|
|
11725
|
+
},
|
|
11726
|
+
align: {
|
|
11727
|
+
left: "text-left",
|
|
11728
|
+
center: "text-center",
|
|
11729
|
+
right: "text-right"
|
|
11730
|
+
}
|
|
11731
|
+
},
|
|
11732
|
+
defaultVariants: {
|
|
11733
|
+
header: false,
|
|
11734
|
+
align: "left"
|
|
11735
|
+
}
|
|
11736
|
+
});
|
|
11737
|
+
function cn75(...classes) {
|
|
11738
|
+
return classes.filter(Boolean).join(" ");
|
|
11739
|
+
}
|
|
11740
|
+
function sanitizeHref(rawHref) {
|
|
11741
|
+
const href = rawHref.replace(/[\x00-\x20]/g, "");
|
|
11742
|
+
if (!href) return null;
|
|
11743
|
+
const schemeMatch = /^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(href);
|
|
11744
|
+
if (!schemeMatch) return href;
|
|
11745
|
+
const scheme = schemeMatch[1].toLowerCase();
|
|
11746
|
+
return scheme === "http" || scheme === "https" || scheme === "mailto" ? href : null;
|
|
11747
|
+
}
|
|
11748
|
+
function makeIdSource() {
|
|
11749
|
+
let current = 0;
|
|
11750
|
+
return {
|
|
11751
|
+
next: () => {
|
|
11752
|
+
current += 1;
|
|
11753
|
+
return current;
|
|
11754
|
+
}
|
|
11755
|
+
};
|
|
11756
|
+
}
|
|
11757
|
+
function parseInline(text, ids) {
|
|
11758
|
+
const nodes = [];
|
|
11759
|
+
let buffer = "";
|
|
11760
|
+
let i = 0;
|
|
11761
|
+
const flush = () => {
|
|
11762
|
+
if (buffer.length > 0) {
|
|
11763
|
+
nodes.push(buffer);
|
|
11764
|
+
buffer = "";
|
|
11765
|
+
}
|
|
11766
|
+
};
|
|
11767
|
+
while (i < text.length) {
|
|
11768
|
+
const rest = text.slice(i);
|
|
11769
|
+
const codeMatch = /^`([^`]+)`/.exec(rest);
|
|
11770
|
+
if (codeMatch) {
|
|
11771
|
+
flush();
|
|
11772
|
+
nodes.push(
|
|
11773
|
+
/* @__PURE__ */ jsx("code", { className: markdownInlineCodeVariants(), children: codeMatch[1] }, ids.next())
|
|
11774
|
+
);
|
|
11775
|
+
i += codeMatch[0].length;
|
|
11776
|
+
continue;
|
|
11777
|
+
}
|
|
11778
|
+
const linkMatch = /^\[([^\]]*)\]\(((?:[^()]|\([^()]*\))*)\)/.exec(rest);
|
|
11779
|
+
if (linkMatch) {
|
|
11780
|
+
flush();
|
|
11781
|
+
const label = linkMatch[1];
|
|
11782
|
+
const safeHref = sanitizeHref(linkMatch[2]);
|
|
11783
|
+
if (safeHref) {
|
|
11784
|
+
nodes.push(
|
|
11785
|
+
/* @__PURE__ */ jsx(
|
|
11786
|
+
"a",
|
|
11787
|
+
{
|
|
11788
|
+
href: safeHref,
|
|
11789
|
+
target: "_blank",
|
|
11790
|
+
rel: "noopener noreferrer",
|
|
11791
|
+
className: markdownLinkVariants(),
|
|
11792
|
+
children: parseInline(label, ids)
|
|
11793
|
+
},
|
|
11794
|
+
ids.next()
|
|
11795
|
+
)
|
|
11796
|
+
);
|
|
11797
|
+
} else {
|
|
11798
|
+
nodes.push(...parseInline(label, ids));
|
|
11799
|
+
}
|
|
11800
|
+
i += linkMatch[0].length;
|
|
11801
|
+
continue;
|
|
11802
|
+
}
|
|
11803
|
+
const boldMatch = /^\*\*([^*]+)\*\*/.exec(rest);
|
|
11804
|
+
if (boldMatch) {
|
|
11805
|
+
flush();
|
|
11806
|
+
nodes.push(
|
|
11807
|
+
/* @__PURE__ */ jsx("strong", { className: markdownEmphasisVariants({ tone: "strong" }), children: parseInline(boldMatch[1], ids) }, ids.next())
|
|
11808
|
+
);
|
|
11809
|
+
i += boldMatch[0].length;
|
|
11810
|
+
continue;
|
|
11811
|
+
}
|
|
11812
|
+
const italicMatch = /^\*([^*]+)\*/.exec(rest);
|
|
11813
|
+
if (italicMatch) {
|
|
11814
|
+
flush();
|
|
11815
|
+
nodes.push(
|
|
11816
|
+
/* @__PURE__ */ jsx("em", { className: markdownEmphasisVariants({ tone: "emphasis" }), children: parseInline(italicMatch[1], ids) }, ids.next())
|
|
11817
|
+
);
|
|
11818
|
+
i += italicMatch[0].length;
|
|
11819
|
+
continue;
|
|
11820
|
+
}
|
|
11821
|
+
buffer += text[i];
|
|
11822
|
+
i += 1;
|
|
11823
|
+
}
|
|
11824
|
+
flush();
|
|
11825
|
+
return nodes;
|
|
11826
|
+
}
|
|
11827
|
+
var FENCE_RE = /^```(\S*)\s*$/;
|
|
11828
|
+
var HEADING_RE = /^(#{1,6})\s+(.*)$/;
|
|
11829
|
+
var HR_RE = /^(-{3,}|\*{3,}|_{3,})$/;
|
|
11830
|
+
var UNORDERED_ITEM_RE = /^[-*+]\s+/;
|
|
11831
|
+
var ORDERED_ITEM_RE = /^\d+\.\s+/;
|
|
11832
|
+
var BLOCKQUOTE_LINE_RE = /^>\s?/;
|
|
11833
|
+
var TABLE_SEPARATOR_RE = /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/;
|
|
11834
|
+
function parseTableRow(line) {
|
|
11835
|
+
const trimmed = line.trim().replace(/^\|/, "").replace(/\|$/, "");
|
|
11836
|
+
return trimmed.split("|").map((cell) => cell.trim());
|
|
11837
|
+
}
|
|
11838
|
+
function parseBlocks(content) {
|
|
11839
|
+
const lines = content.split(/\r?\n/);
|
|
11840
|
+
const blocks = [];
|
|
11841
|
+
let id = 0;
|
|
11842
|
+
const nextId = () => {
|
|
11843
|
+
id += 1;
|
|
11844
|
+
return id;
|
|
11845
|
+
};
|
|
11846
|
+
let i = 0;
|
|
11847
|
+
while (i < lines.length) {
|
|
11848
|
+
const line = lines[i];
|
|
11849
|
+
if (line.trim() === "") {
|
|
11850
|
+
i += 1;
|
|
11851
|
+
continue;
|
|
11852
|
+
}
|
|
11853
|
+
const fenceMatch = FENCE_RE.exec(line);
|
|
11854
|
+
if (fenceMatch) {
|
|
11855
|
+
const language = fenceMatch[1] || void 0;
|
|
11856
|
+
const codeLines = [];
|
|
11857
|
+
i += 1;
|
|
11858
|
+
while (i < lines.length && !/^```\s*$/.test(lines[i])) {
|
|
11859
|
+
codeLines.push(lines[i]);
|
|
11860
|
+
i += 1;
|
|
11861
|
+
}
|
|
11862
|
+
i += 1;
|
|
11863
|
+
blocks.push({ id: nextId(), kind: "code", language, code: codeLines.join("\n") });
|
|
11864
|
+
continue;
|
|
11865
|
+
}
|
|
11866
|
+
const headingMatch = HEADING_RE.exec(line);
|
|
11867
|
+
if (headingMatch) {
|
|
11868
|
+
blocks.push({
|
|
11869
|
+
id: nextId(),
|
|
11870
|
+
kind: "heading",
|
|
11871
|
+
level: headingMatch[1].length,
|
|
11872
|
+
text: headingMatch[2].trim()
|
|
11873
|
+
});
|
|
11874
|
+
i += 1;
|
|
11875
|
+
continue;
|
|
11876
|
+
}
|
|
11877
|
+
if (HR_RE.test(line.trim())) {
|
|
11878
|
+
blocks.push({ id: nextId(), kind: "hr" });
|
|
11879
|
+
i += 1;
|
|
11880
|
+
continue;
|
|
11881
|
+
}
|
|
11882
|
+
if (line.includes("|") && i + 1 < lines.length && TABLE_SEPARATOR_RE.test(lines[i + 1])) {
|
|
11883
|
+
const header = parseTableRow(line);
|
|
11884
|
+
i += 2;
|
|
11885
|
+
const rows = [];
|
|
11886
|
+
while (i < lines.length && lines[i].trim() !== "" && lines[i].includes("|")) {
|
|
11887
|
+
rows.push(parseTableRow(lines[i]));
|
|
11888
|
+
i += 1;
|
|
11889
|
+
}
|
|
11890
|
+
blocks.push({ id: nextId(), kind: "table", header, rows });
|
|
11891
|
+
continue;
|
|
11892
|
+
}
|
|
11893
|
+
if (BLOCKQUOTE_LINE_RE.test(line)) {
|
|
11894
|
+
const quoteLines = [];
|
|
11895
|
+
while (i < lines.length && BLOCKQUOTE_LINE_RE.test(lines[i])) {
|
|
11896
|
+
quoteLines.push(lines[i].replace(BLOCKQUOTE_LINE_RE, ""));
|
|
11897
|
+
i += 1;
|
|
11898
|
+
}
|
|
11899
|
+
blocks.push({ id: nextId(), kind: "blockquote", text: quoteLines.join(" ") });
|
|
11900
|
+
continue;
|
|
11901
|
+
}
|
|
11902
|
+
if (UNORDERED_ITEM_RE.test(line)) {
|
|
11903
|
+
const items = [];
|
|
11904
|
+
while (i < lines.length && UNORDERED_ITEM_RE.test(lines[i])) {
|
|
11905
|
+
items.push({ id: nextId(), text: lines[i].replace(UNORDERED_ITEM_RE, "") });
|
|
11906
|
+
i += 1;
|
|
11907
|
+
}
|
|
11908
|
+
blocks.push({ id: nextId(), kind: "list", ordered: false, items });
|
|
11909
|
+
continue;
|
|
11910
|
+
}
|
|
11911
|
+
if (ORDERED_ITEM_RE.test(line)) {
|
|
11912
|
+
const items = [];
|
|
11913
|
+
while (i < lines.length && ORDERED_ITEM_RE.test(lines[i])) {
|
|
11914
|
+
items.push({ id: nextId(), text: lines[i].replace(ORDERED_ITEM_RE, "") });
|
|
11915
|
+
i += 1;
|
|
11916
|
+
}
|
|
11917
|
+
blocks.push({ id: nextId(), kind: "list", ordered: true, items });
|
|
11918
|
+
continue;
|
|
11919
|
+
}
|
|
11920
|
+
const paragraphLines = [];
|
|
11921
|
+
while (i < lines.length && lines[i].trim() !== "" && !FENCE_RE.test(lines[i]) && !HEADING_RE.test(lines[i]) && !UNORDERED_ITEM_RE.test(lines[i]) && !ORDERED_ITEM_RE.test(lines[i]) && !BLOCKQUOTE_LINE_RE.test(lines[i]) && !HR_RE.test(lines[i].trim())) {
|
|
11922
|
+
paragraphLines.push(lines[i]);
|
|
11923
|
+
i += 1;
|
|
11924
|
+
}
|
|
11925
|
+
blocks.push({ id: nextId(), kind: "paragraph", text: paragraphLines.join(" ") });
|
|
11926
|
+
}
|
|
11927
|
+
return blocks;
|
|
11928
|
+
}
|
|
11929
|
+
function MosaicMarkdown({ content, renderCodeBlock, className, ref }) {
|
|
11930
|
+
const blocks = parseBlocks(content);
|
|
11931
|
+
const ids = makeIdSource();
|
|
11932
|
+
return /* @__PURE__ */ jsx("div", { ref, "data-slot": "markdown", className: cn75(markdownRootVariants(), className), children: blocks.map((block) => {
|
|
11933
|
+
if (block.kind === "heading") {
|
|
11934
|
+
const HeadingTag = `h${block.level}`;
|
|
11935
|
+
return /* @__PURE__ */ jsx(HeadingTag, { className: markdownHeadingVariants({ level: block.level }), children: parseInline(block.text, ids) }, block.id);
|
|
11936
|
+
}
|
|
11937
|
+
if (block.kind === "paragraph") {
|
|
11938
|
+
return /* @__PURE__ */ jsx("p", { className: markdownParagraphVariants(), children: parseInline(block.text, ids) }, block.id);
|
|
11939
|
+
}
|
|
11940
|
+
if (block.kind === "list") {
|
|
11941
|
+
const ListTag = block.ordered ? "ol" : "ul";
|
|
11942
|
+
return /* @__PURE__ */ jsx(ListTag, { className: markdownListVariants({ ordered: block.ordered }), children: block.items.map((item) => /* @__PURE__ */ jsx("li", { className: markdownListItemVariants(), children: parseInline(item.text, ids) }, item.id)) }, block.id);
|
|
11943
|
+
}
|
|
11944
|
+
if (block.kind === "blockquote") {
|
|
11945
|
+
return /* @__PURE__ */ jsx("blockquote", { className: markdownBlockquoteVariants(), children: parseInline(block.text, ids) }, block.id);
|
|
11946
|
+
}
|
|
11947
|
+
if (block.kind === "hr") {
|
|
11948
|
+
return /* @__PURE__ */ jsx("hr", { className: markdownHrVariants() }, block.id);
|
|
11949
|
+
}
|
|
11950
|
+
if (block.kind === "code") {
|
|
11951
|
+
if (renderCodeBlock) {
|
|
11952
|
+
return /* @__PURE__ */ jsx("div", { children: renderCodeBlock({ language: block.language, code: block.code }) }, block.id);
|
|
11953
|
+
}
|
|
11954
|
+
return /* @__PURE__ */ jsx(
|
|
11955
|
+
"pre",
|
|
11956
|
+
{
|
|
11957
|
+
"data-slot": "markdown-code-block",
|
|
11958
|
+
...block.language ? { "data-language": block.language } : {},
|
|
11959
|
+
className: markdownCodeBlockVariants(),
|
|
11960
|
+
children: /* @__PURE__ */ jsx("code", { children: block.code })
|
|
11961
|
+
},
|
|
11962
|
+
block.id
|
|
11963
|
+
);
|
|
11964
|
+
}
|
|
11965
|
+
return /* @__PURE__ */ jsx("div", { className: markdownTableWrapperVariants(), children: /* @__PURE__ */ jsxs("table", { className: markdownTableVariants(), children: [
|
|
11966
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: block.header.map((cell) => /* @__PURE__ */ jsx("th", { className: markdownTableCellVariants({ header: true }), children: parseInline(cell, ids) }, ids.next())) }) }),
|
|
11967
|
+
/* @__PURE__ */ jsx("tbody", { children: block.rows.map((row) => /* @__PURE__ */ jsx("tr", { children: row.map((cell) => /* @__PURE__ */ jsx("td", { className: markdownTableCellVariants({ header: false }), children: parseInline(cell, ids) }, ids.next())) }, ids.next())) })
|
|
11968
|
+
] }) }, block.id);
|
|
11969
|
+
}) });
|
|
11970
|
+
}
|
|
11971
|
+
MosaicMarkdown.displayName = "MosaicMarkdown";
|
|
11972
|
+
var chatMessageContainerVariants = cva(["flex w-full min-w-0"], {
|
|
11973
|
+
variants: {
|
|
11974
|
+
align: {
|
|
11975
|
+
start: "justify-start",
|
|
11976
|
+
end: "justify-end"
|
|
11977
|
+
}
|
|
11978
|
+
},
|
|
11979
|
+
defaultVariants: {
|
|
11980
|
+
align: "start"
|
|
11981
|
+
}
|
|
11982
|
+
});
|
|
11983
|
+
var chatMessageBubbleVariants = cva(["min-w-0"], {
|
|
11984
|
+
variants: {
|
|
11985
|
+
role: {
|
|
11986
|
+
user: [
|
|
11987
|
+
"max-w-[85%] rounded-[18px] border border-border/40 bg-muted/70 px-3 py-1.5",
|
|
11988
|
+
"text-[15px] leading-6 text-foreground shadow-sm"
|
|
11989
|
+
],
|
|
11990
|
+
assistant: "w-full max-w-none text-sm leading-relaxed text-foreground"
|
|
11991
|
+
}
|
|
11992
|
+
},
|
|
11993
|
+
defaultVariants: {
|
|
11994
|
+
role: "assistant"
|
|
11995
|
+
}
|
|
11996
|
+
});
|
|
11997
|
+
var chatMessageToolStatusVariants = cva(["text-xs font-medium"], {
|
|
11998
|
+
variants: {
|
|
11999
|
+
status: {
|
|
12000
|
+
running: "text-muted-foreground",
|
|
12001
|
+
completed: "text-emerald-600 dark:text-emerald-500",
|
|
12002
|
+
denied: "text-destructive",
|
|
12003
|
+
error: "text-destructive"
|
|
12004
|
+
}
|
|
12005
|
+
},
|
|
12006
|
+
defaultVariants: {
|
|
12007
|
+
status: "running"
|
|
12008
|
+
}
|
|
12009
|
+
});
|
|
12010
|
+
function cn76(...classes) {
|
|
12011
|
+
return classes.filter(Boolean).join(" ");
|
|
12012
|
+
}
|
|
12013
|
+
function partKey(part, index) {
|
|
12014
|
+
return part.type === "tool" ? part.toolCallId : `${part.type}:${index}`;
|
|
12015
|
+
}
|
|
12016
|
+
function toolStatusOf(part) {
|
|
12017
|
+
switch (part.state) {
|
|
12018
|
+
case "input-streaming":
|
|
12019
|
+
case "approval-requested":
|
|
12020
|
+
return "running";
|
|
12021
|
+
case "output-available":
|
|
12022
|
+
return "completed";
|
|
12023
|
+
case "output-denied":
|
|
12024
|
+
return "denied";
|
|
12025
|
+
case "output-error":
|
|
12026
|
+
return "error";
|
|
12027
|
+
}
|
|
12028
|
+
}
|
|
12029
|
+
function formatPayload(value) {
|
|
12030
|
+
if (typeof value === "string") {
|
|
12031
|
+
return value;
|
|
12032
|
+
}
|
|
12033
|
+
try {
|
|
12034
|
+
return JSON.stringify(value, null, 2);
|
|
12035
|
+
} catch {
|
|
12036
|
+
return String(value);
|
|
12037
|
+
}
|
|
12038
|
+
}
|
|
12039
|
+
function ChatMessageTextPartView({
|
|
12040
|
+
part,
|
|
12041
|
+
renderText
|
|
12042
|
+
}) {
|
|
12043
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "chat-message-text", className: "whitespace-pre-wrap break-words", children: renderText(part.text) });
|
|
12044
|
+
}
|
|
12045
|
+
function ChatMessageReasoningPartView({
|
|
12046
|
+
part,
|
|
12047
|
+
reasoningLabel,
|
|
12048
|
+
reasoningStreamingLabel,
|
|
12049
|
+
renderText
|
|
12050
|
+
}) {
|
|
12051
|
+
const isStreaming = Boolean(part.isStreaming);
|
|
12052
|
+
return /* @__PURE__ */ jsxs(
|
|
12053
|
+
MosaicCollapsible,
|
|
12054
|
+
{
|
|
12055
|
+
"data-slot": "chat-message-reasoning",
|
|
12056
|
+
defaultOpen: isStreaming,
|
|
12057
|
+
className: "my-3 w-full",
|
|
12058
|
+
children: [
|
|
12059
|
+
/* @__PURE__ */ jsx(MosaicCollapsibleTrigger, { className: "justify-start gap-2 text-sm text-muted-foreground", children: /* @__PURE__ */ jsx("span", { children: isStreaming ? reasoningStreamingLabel : reasoningLabel }) }),
|
|
12060
|
+
/* @__PURE__ */ jsx(MosaicCollapsiblePanel, { className: "border-l border-border pl-4 text-muted-foreground", children: renderText(part.text) })
|
|
12061
|
+
]
|
|
12062
|
+
}
|
|
12063
|
+
);
|
|
12064
|
+
}
|
|
12065
|
+
function ChatMessageToolPartView({
|
|
12066
|
+
part,
|
|
12067
|
+
toolStatusLabels
|
|
12068
|
+
}) {
|
|
12069
|
+
const status = toolStatusOf(part);
|
|
12070
|
+
return /* @__PURE__ */ jsxs("div", { "data-slot": "chat-message-tool", className: "my-2 flex flex-col gap-1 px-3", children: [
|
|
12071
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
12072
|
+
/* @__PURE__ */ jsx(
|
|
12073
|
+
"span",
|
|
12074
|
+
{
|
|
12075
|
+
"data-slot": "chat-message-tool-name",
|
|
12076
|
+
className: "rounded bg-muted/60 px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",
|
|
12077
|
+
children: part.toolName
|
|
12078
|
+
}
|
|
12079
|
+
),
|
|
12080
|
+
/* @__PURE__ */ jsx(
|
|
12081
|
+
"span",
|
|
12082
|
+
{
|
|
12083
|
+
"data-slot": "chat-message-tool-status",
|
|
12084
|
+
className: chatMessageToolStatusVariants({ status }),
|
|
12085
|
+
children: toolStatusLabels[status]
|
|
12086
|
+
}
|
|
12087
|
+
)
|
|
12088
|
+
] }),
|
|
12089
|
+
part.input !== void 0 && /* @__PURE__ */ jsx(
|
|
12090
|
+
"pre",
|
|
12091
|
+
{
|
|
12092
|
+
"data-slot": "chat-message-tool-input",
|
|
12093
|
+
className: "max-h-56 overflow-auto rounded bg-muted/30 p-2 font-mono text-[11px] leading-5 text-muted-foreground",
|
|
12094
|
+
children: formatPayload(part.input)
|
|
12095
|
+
}
|
|
12096
|
+
),
|
|
12097
|
+
part.state === "approval-requested" && /* @__PURE__ */ jsx("div", { "data-slot": "chat-message-tool-approval", children: part.renderApproval(part) }),
|
|
12098
|
+
part.state === "output-available" && /* @__PURE__ */ jsx(
|
|
12099
|
+
"pre",
|
|
12100
|
+
{
|
|
12101
|
+
"data-slot": "chat-message-tool-output",
|
|
12102
|
+
className: "max-h-56 overflow-auto rounded bg-muted/30 p-2 font-mono text-[11px] leading-5 text-muted-foreground",
|
|
12103
|
+
children: formatPayload(part.output)
|
|
12104
|
+
}
|
|
12105
|
+
),
|
|
12106
|
+
part.state === "output-error" && /* @__PURE__ */ jsx(
|
|
12107
|
+
"p",
|
|
12108
|
+
{
|
|
12109
|
+
"data-slot": "chat-message-tool-error",
|
|
12110
|
+
className: "rounded bg-destructive/10 p-2 font-mono text-[11px] leading-5 text-destructive",
|
|
12111
|
+
children: part.errorText
|
|
12112
|
+
}
|
|
12113
|
+
)
|
|
12114
|
+
] });
|
|
12115
|
+
}
|
|
12116
|
+
function ChatMessagePartView({
|
|
12117
|
+
part,
|
|
12118
|
+
renderText,
|
|
12119
|
+
reasoningLabel,
|
|
12120
|
+
reasoningStreamingLabel,
|
|
12121
|
+
toolStatusLabels
|
|
12122
|
+
}) {
|
|
12123
|
+
switch (part.type) {
|
|
12124
|
+
case "text":
|
|
12125
|
+
return /* @__PURE__ */ jsx(ChatMessageTextPartView, { part, renderText });
|
|
12126
|
+
case "reasoning":
|
|
12127
|
+
return /* @__PURE__ */ jsx(
|
|
12128
|
+
ChatMessageReasoningPartView,
|
|
12129
|
+
{
|
|
12130
|
+
part,
|
|
12131
|
+
reasoningLabel,
|
|
12132
|
+
reasoningStreamingLabel,
|
|
12133
|
+
renderText
|
|
12134
|
+
}
|
|
12135
|
+
);
|
|
12136
|
+
case "tool":
|
|
12137
|
+
return /* @__PURE__ */ jsx(ChatMessageToolPartView, { part, toolStatusLabels });
|
|
12138
|
+
}
|
|
12139
|
+
}
|
|
12140
|
+
function MosaicChatMessage({
|
|
12141
|
+
messageRole,
|
|
12142
|
+
parts,
|
|
12143
|
+
renderText,
|
|
12144
|
+
reasoningLabel,
|
|
12145
|
+
reasoningStreamingLabel,
|
|
12146
|
+
toolStatusLabels,
|
|
12147
|
+
className,
|
|
12148
|
+
ref
|
|
12149
|
+
}) {
|
|
12150
|
+
const isUser = messageRole === "user";
|
|
12151
|
+
return /* @__PURE__ */ jsx(
|
|
12152
|
+
"article",
|
|
12153
|
+
{
|
|
12154
|
+
ref,
|
|
12155
|
+
"data-slot": "chat-message",
|
|
12156
|
+
"data-role": messageRole,
|
|
12157
|
+
className: cn76(chatMessageContainerVariants({ align: isUser ? "end" : "start" }), className),
|
|
12158
|
+
children: /* @__PURE__ */ jsx("div", { className: chatMessageBubbleVariants({ role: messageRole }), children: parts.map((part, index) => /* @__PURE__ */ jsx(
|
|
12159
|
+
ChatMessagePartView,
|
|
12160
|
+
{
|
|
12161
|
+
part,
|
|
12162
|
+
renderText,
|
|
12163
|
+
reasoningLabel,
|
|
12164
|
+
reasoningStreamingLabel,
|
|
12165
|
+
toolStatusLabels
|
|
12166
|
+
},
|
|
12167
|
+
partKey(part, index)
|
|
12168
|
+
)) })
|
|
12169
|
+
}
|
|
12170
|
+
);
|
|
12171
|
+
}
|
|
12172
|
+
MosaicChatMessage.displayName = "MosaicChatMessage";
|
|
11666
12173
|
|
|
11667
|
-
export { MosaicAccordion, MosaicAccordionItem, MosaicAccordionPanel, MosaicAccordionTrigger, MosaicActivityFeed, MosaicActivityItem, MosaicAdaptiveGrid, MosaicAdaptiveModal, MosaicAdaptiveNavigation, MosaicAgentCard, MosaicAgentComposer, MosaicAgentComposerDesktop, MosaicAgentComposerMobile, MosaicAgentList, AgentListDesktop as MosaicAgentListDesktop, AgentListMobile as MosaicAgentListMobile, MosaicAgentTeamPreview, MosaicAnimatedList, MosaicAppSidebar, MosaicAvatar, MosaicBadge, MosaicBlurredOrb, MosaicButton, MosaicCard, MosaicCardContent, MosaicCardDescription, MosaicCardFooter, MosaicCardHeader, MosaicCardTitle, MosaicChatComposer, MosaicChatThread, MosaicCheckbox, MosaicClerkOrgSwitcher, MosaicClerkWebhookHandler, MosaicCollapsible, MosaicCollapsiblePanel, MosaicCollapsibleTrigger, MosaicCombobox, MosaicCounter, MosaicCreateOrgDialog, MosaicDashboardContent, MosaicDashboardHeader, MosaicDashboardLayout, MosaicDataTable, MosaicDeleteConfirmationDialog, MosaicDeviceProvider, MosaicDocumentUpload, MosaicDropdownMenu, MosaicEmptyState, MosaicFallingPattern, MosaicFeature3Col, MosaicFeatureCenteredMedia, MosaicField, MosaicFieldControl, MosaicFieldDescription, MosaicFieldError, MosaicFieldLabel, MosaicFilterBar, MosaicFilterSidebar, MosaicFooterSimple, MosaicHeroSplit, MosaicInput, MosaicInputGroup, MosaicIntegrationsBadge, MosaicInviteMemberDialog, MosaicKanbanBoard, MosaicKanbanColumn, MosaicLogosGrid, MosaicMainNav, MosaicMarketplaceList, MarketplaceListDesktop as MosaicMarketplaceListDesktop, MarketplaceListMobile as MosaicMarketplaceListMobile, MosaicMemberList, MosaicMemoryCard, MosaicMessageCard, MosaicMessageList, MessageListDesktop as MosaicMessageListDesktop, MessageListMobile as MosaicMessageListMobile, MosaicModuleCard, MosaicModuleForm, MosaicModuleLibrary, MosaicMultiOrgIndicator, MosaicMultiTenantProvider, MosaicNavbar, MosaicOrgPanel, MosaicOrgProfilePage, MosaicOrgRoleBadge, MosaicOrgSwitcher, MosaicPreferencesPanel, MosaicPricingCard, MosaicProfilePanel, MosaicProgress, MosaicQuickActionCard, MosaicQuickActionsMenu, MosaicQuickAgentSelector, MosaicQuickStartPanel, MosaicRadioGroup, MosaicRadioGroupItem, MosaicScrollArea, MosaicSelect, MosaicSelectorModal, MosaicSeparator, MosaicSignInLayout, MosaicSignUpLayout, MosaicSkeleton, MosaicSlider, MosaicStatsGrid, MosaicStepPipeline, MosaicSwitch, MosaicTabs, MosaicTabsList, MosaicTabsPanel, MosaicTabsTrigger, MosaicTemplateCard, MosaicTemplateGallery, MosaicTemplatePreview, MosaicTestimonialsGrid, MosaicTextarea, MosaicThemeProvider, MosaicThemeToggle, MosaicTooltip, MosaicTooltipContent, MosaicTooltipProvider, MosaicTooltipRoot, MosaicTooltipTrigger, MosaicUrlScraper, MosaicUserButton, Placeholder, badgeVariants, buttonVariants, skeletonVariants, useBreakpoint, useDevice, useMosaicWorkspace as useEffectiveWorkspaceId, useIsDesktop, useIsMobile, useIsTablet, useMediaQuery, useMosaicWorkspace, useOrientation, useViewport, version };
|
|
12174
|
+
export { MosaicAccordion, MosaicAccordionItem, MosaicAccordionPanel, MosaicAccordionTrigger, MosaicActivityFeed, MosaicActivityItem, MosaicAdaptiveGrid, MosaicAdaptiveModal, MosaicAdaptiveNavigation, MosaicAgentCard, MosaicAgentComposer, MosaicAgentComposerDesktop, MosaicAgentComposerMobile, MosaicAgentList, AgentListDesktop as MosaicAgentListDesktop, AgentListMobile as MosaicAgentListMobile, MosaicAgentTeamPreview, MosaicAnimatedList, MosaicAppSidebar, MosaicAvatar, MosaicBadge, MosaicBlurredOrb, MosaicButton, MosaicCard, MosaicCardContent, MosaicCardDescription, MosaicCardFooter, MosaicCardHeader, MosaicCardTitle, MosaicChatComposer, MosaicChatMessage, MosaicChatThread, MosaicCheckbox, MosaicClerkOrgSwitcher, MosaicClerkWebhookHandler, MosaicCollapsible, MosaicCollapsiblePanel, MosaicCollapsibleTrigger, MosaicCombobox, MosaicCounter, MosaicCreateOrgDialog, MosaicDashboardContent, MosaicDashboardHeader, MosaicDashboardLayout, MosaicDataTable, MosaicDeleteConfirmationDialog, MosaicDeviceProvider, MosaicDocumentUpload, MosaicDropdownMenu, MosaicEmptyState, MosaicFallingPattern, MosaicFeature3Col, MosaicFeatureCenteredMedia, MosaicField, MosaicFieldControl, MosaicFieldDescription, MosaicFieldError, MosaicFieldLabel, MosaicFilterBar, MosaicFilterSidebar, MosaicFooterSimple, MosaicHeroSplit, MosaicInput, MosaicInputGroup, MosaicIntegrationsBadge, MosaicInviteMemberDialog, MosaicKanbanBoard, MosaicKanbanColumn, MosaicLogosGrid, MosaicMainNav, MosaicMarkdown, MosaicMarketplaceList, MarketplaceListDesktop as MosaicMarketplaceListDesktop, MarketplaceListMobile as MosaicMarketplaceListMobile, MosaicMemberList, MosaicMemoryCard, MosaicMessageCard, MosaicMessageList, MessageListDesktop as MosaicMessageListDesktop, MessageListMobile as MosaicMessageListMobile, MosaicModuleCard, MosaicModuleForm, MosaicModuleLibrary, MosaicMultiOrgIndicator, MosaicMultiTenantProvider, MosaicNavbar, MosaicOrgPanel, MosaicOrgProfilePage, MosaicOrgRoleBadge, MosaicOrgSwitcher, MosaicPreferencesPanel, MosaicPricingCard, MosaicProfilePanel, MosaicProgress, MosaicQuickActionCard, MosaicQuickActionsMenu, MosaicQuickAgentSelector, MosaicQuickStartPanel, MosaicRadioGroup, MosaicRadioGroupItem, MosaicScrollArea, MosaicSelect, MosaicSelectorModal, MosaicSeparator, MosaicSignInLayout, MosaicSignUpLayout, MosaicSkeleton, MosaicSlider, MosaicStatsGrid, MosaicStepPipeline, MosaicSwitch, MosaicTabs, MosaicTabsList, MosaicTabsPanel, MosaicTabsTrigger, MosaicTemplateCard, MosaicTemplateGallery, MosaicTemplatePreview, MosaicTestimonialsGrid, MosaicTextarea, MosaicThemeProvider, MosaicThemeToggle, MosaicTooltip, MosaicTooltipContent, MosaicTooltipProvider, MosaicTooltipRoot, MosaicTooltipTrigger, MosaicUrlScraper, MosaicUserButton, Placeholder, badgeVariants, buttonVariants, chatMessageBubbleVariants, chatMessageContainerVariants, chatMessageToolStatusVariants, skeletonVariants, useBreakpoint, useDevice, useMosaicWorkspace as useEffectiveWorkspaceId, useIsDesktop, useIsMobile, useIsTablet, useMediaQuery, useMosaicWorkspace, useOrientation, useViewport, version };
|
|
11668
12175
|
//# sourceMappingURL=index.js.map
|
|
11669
12176
|
//# sourceMappingURL=index.js.map
|