@lukeashford/aurelius 3.7.0 → 3.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +11 -28
- package/dist/index.d.ts +11 -28
- package/dist/index.js +36 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -24
- package/dist/index.mjs.map +1 -1
- package/llms.md +1 -5
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3972,7 +3972,7 @@ var Message = React55.forwardRef(
|
|
|
3972
3972
|
const isUser = variant === "user";
|
|
3973
3973
|
const [copied, setCopied] = useState10(false);
|
|
3974
3974
|
const [isEditing, setIsEditing] = useState10(false);
|
|
3975
|
-
const [editValue, setEditValue] = useState10(content);
|
|
3975
|
+
const [editValue, setEditValue] = useState10(typeof content === "string" ? content : "");
|
|
3976
3976
|
const textareaRef = useRef5(null);
|
|
3977
3977
|
const showBranchNav = branchInfo && branchInfo.total > 1;
|
|
3978
3978
|
const showActions = actions && !hideActions && !isStreaming;
|
|
@@ -3986,6 +3986,9 @@ var Message = React55.forwardRef(
|
|
|
3986
3986
|
}
|
|
3987
3987
|
}, [isEditing]);
|
|
3988
3988
|
const handleCopy = async () => {
|
|
3989
|
+
if (typeof content !== "string") {
|
|
3990
|
+
return;
|
|
3991
|
+
}
|
|
3989
3992
|
try {
|
|
3990
3993
|
await navigator.clipboard.writeText(content);
|
|
3991
3994
|
setCopied(true);
|
|
@@ -4002,16 +4005,20 @@ var Message = React55.forwardRef(
|
|
|
4002
4005
|
}
|
|
4003
4006
|
};
|
|
4004
4007
|
const handleStartEdit = () => {
|
|
4005
|
-
|
|
4006
|
-
|
|
4008
|
+
if (typeof content === "string") {
|
|
4009
|
+
setEditValue(content);
|
|
4010
|
+
setIsEditing(true);
|
|
4011
|
+
}
|
|
4007
4012
|
};
|
|
4008
4013
|
const handleCancelEdit = () => {
|
|
4009
4014
|
setIsEditing(false);
|
|
4010
|
-
|
|
4015
|
+
if (typeof content === "string") {
|
|
4016
|
+
setEditValue(content);
|
|
4017
|
+
}
|
|
4011
4018
|
};
|
|
4012
4019
|
const handleSubmitEdit = () => {
|
|
4013
4020
|
const trimmed = editValue.trim();
|
|
4014
|
-
if (trimmed && trimmed !== content) {
|
|
4021
|
+
if (typeof content === "string" && trimmed && trimmed !== content) {
|
|
4015
4022
|
actions?.onEdit?.(trimmed);
|
|
4016
4023
|
}
|
|
4017
4024
|
setIsEditing(false);
|
|
@@ -4078,7 +4085,7 @@ var Message = React55.forwardRef(
|
|
|
4078
4085
|
variantStyles2[variant]
|
|
4079
4086
|
)
|
|
4080
4087
|
},
|
|
4081
|
-
/* @__PURE__ */ React55.createElement(
|
|
4088
|
+
typeof content === "string" ? /* @__PURE__ */ React55.createElement(
|
|
4082
4089
|
MarkdownContent,
|
|
4083
4090
|
{
|
|
4084
4091
|
content,
|
|
@@ -4086,7 +4093,7 @@ var Message = React55.forwardRef(
|
|
|
4086
4093
|
isStreaming,
|
|
4087
4094
|
cursorClassName: "ml-0.5"
|
|
4088
4095
|
}
|
|
4089
|
-
)
|
|
4096
|
+
) : content
|
|
4090
4097
|
),
|
|
4091
4098
|
showActions && !isEditing && /* @__PURE__ */ React55.createElement("div", { className: cx(
|
|
4092
4099
|
"flex items-center gap-0.5 mt-1",
|
|
@@ -4098,7 +4105,7 @@ var Message = React55.forwardRef(
|
|
|
4098
4105
|
label: copied ? "Copied!" : "Copy message"
|
|
4099
4106
|
},
|
|
4100
4107
|
copied ? /* @__PURE__ */ React55.createElement(CheckIcon, null) : /* @__PURE__ */ React55.createElement(CopyIcon, null)
|
|
4101
|
-
), isUser && actions.onEdit && /* @__PURE__ */ React55.createElement(ActionButton, { onClick: handleStartEdit, label: "Edit message" }, /* @__PURE__ */ React55.createElement(PencilIcon, null)), !isUser && actions.onRetry && /* @__PURE__ */ React55.createElement(ActionButton, { onClick: actions.onRetry, label: "Regenerate response" }, /* @__PURE__ */ React55.createElement(RetryIcon, null)), showBranchNav && /* @__PURE__ */ React55.createElement(React55.Fragment, null, /* @__PURE__ */ React55.createElement("div", { className: "w-px h-4 bg-ash/40 mx-1" }), /* @__PURE__ */ React55.createElement("div", { className: "flex items-center gap-0.5 text-silver/70" }, /* @__PURE__ */ React55.createElement(GitBranchIcon, null), /* @__PURE__ */ React55.createElement(
|
|
4108
|
+
), isUser && actions.onEdit && typeof content === "string" && /* @__PURE__ */ React55.createElement(ActionButton, { onClick: handleStartEdit, label: "Edit message" }, /* @__PURE__ */ React55.createElement(PencilIcon, null)), !isUser && actions.onRetry && /* @__PURE__ */ React55.createElement(ActionButton, { onClick: actions.onRetry, label: "Regenerate response" }, /* @__PURE__ */ React55.createElement(RetryIcon, null)), showBranchNav && /* @__PURE__ */ React55.createElement(React55.Fragment, null, /* @__PURE__ */ React55.createElement("div", { className: "w-px h-4 bg-ash/40 mx-1" }), /* @__PURE__ */ React55.createElement("div", { className: "flex items-center gap-0.5 text-silver/70" }, /* @__PURE__ */ React55.createElement(GitBranchIcon, null), /* @__PURE__ */ React55.createElement(
|
|
4102
4109
|
"button",
|
|
4103
4110
|
{
|
|
4104
4111
|
type: "button",
|
|
@@ -4497,14 +4504,13 @@ function addMessageToTree(tree, message, parentId = null) {
|
|
|
4497
4504
|
} else if (!parentId) {
|
|
4498
4505
|
branchIndex = newRootIds.length;
|
|
4499
4506
|
}
|
|
4500
|
-
|
|
4507
|
+
newNodes[message.id] = {
|
|
4501
4508
|
...message,
|
|
4502
4509
|
parentId,
|
|
4503
4510
|
children: [],
|
|
4504
4511
|
branchIndex,
|
|
4505
4512
|
createdAt: message.createdAt ?? Date.now()
|
|
4506
4513
|
};
|
|
4507
|
-
newNodes[message.id] = newNode;
|
|
4508
4514
|
if (parentId && newNodes[parentId]) {
|
|
4509
4515
|
newNodes[parentId] = {
|
|
4510
4516
|
...newNodes[parentId],
|
|
@@ -4580,8 +4586,7 @@ function switchBranch(tree, nodeId, direction) {
|
|
|
4580
4586
|
return tree;
|
|
4581
4587
|
}
|
|
4582
4588
|
const newIndex = direction === "next" ? (currentIndex + 1) % siblings.length : (currentIndex - 1 + siblings.length) % siblings.length;
|
|
4583
|
-
|
|
4584
|
-
let leafId = newNodeId;
|
|
4589
|
+
let leafId = siblings[newIndex];
|
|
4585
4590
|
let currentNode = tree.nodes[leafId];
|
|
4586
4591
|
while (currentNode && currentNode.children.length > 0) {
|
|
4587
4592
|
leafId = currentNode.children[0];
|
|
@@ -6781,19 +6786,13 @@ var ChatInterface = React74.forwardRef(
|
|
|
6781
6786
|
const isTreeMode = !!conversationTree;
|
|
6782
6787
|
const effectiveMessages = useMemo5(() => {
|
|
6783
6788
|
if (isTreeMode && conversationTree) {
|
|
6784
|
-
|
|
6785
|
-
return pathNodes.map((node) => ({
|
|
6786
|
-
id: node.id,
|
|
6787
|
-
variant: node.role,
|
|
6788
|
-
content: node.content,
|
|
6789
|
-
isStreaming: node.isStreaming
|
|
6790
|
-
}));
|
|
6789
|
+
return getActivePathMessages(conversationTree);
|
|
6791
6790
|
}
|
|
6792
|
-
return messages;
|
|
6791
|
+
return messages || [];
|
|
6793
6792
|
}, [isTreeMode, conversationTree, messages]);
|
|
6794
6793
|
const latestUserMessageIndex = useMemo5(() => {
|
|
6795
6794
|
for (let i = effectiveMessages.length - 1; i >= 0; i--) {
|
|
6796
|
-
if (effectiveMessages[i].
|
|
6795
|
+
if (effectiveMessages[i].role === "user") {
|
|
6797
6796
|
return i;
|
|
6798
6797
|
}
|
|
6799
6798
|
}
|
|
@@ -6850,10 +6849,23 @@ var ChatInterface = React74.forwardRef(
|
|
|
6850
6849
|
}
|
|
6851
6850
|
const actions = enableMessageActions ? {
|
|
6852
6851
|
showCopy: true,
|
|
6853
|
-
onEdit: msg.
|
|
6854
|
-
onRetry: msg.
|
|
6852
|
+
onEdit: msg.role === "user" && onEditMessage ? (newContent) => onEditMessage(msg.id, newContent) : void 0,
|
|
6853
|
+
onRetry: msg.role === "assistant" && onRetryMessage ? () => onRetryMessage(msg.id) : void 0
|
|
6855
6854
|
} : void 0;
|
|
6856
|
-
|
|
6855
|
+
const {
|
|
6856
|
+
role,
|
|
6857
|
+
parentId,
|
|
6858
|
+
children,
|
|
6859
|
+
branchIndex,
|
|
6860
|
+
createdAt,
|
|
6861
|
+
...rest2
|
|
6862
|
+
} = msg;
|
|
6863
|
+
return {
|
|
6864
|
+
...rest2,
|
|
6865
|
+
variant: role,
|
|
6866
|
+
branchInfo,
|
|
6867
|
+
actions
|
|
6868
|
+
};
|
|
6857
6869
|
});
|
|
6858
6870
|
}, [
|
|
6859
6871
|
effectiveMessages,
|