@agent-native/core 0.11.1 → 0.11.2
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/agent/thread-data-builder.d.ts +1 -0
- package/dist/agent/thread-data-builder.d.ts.map +1 -1
- package/dist/agent/thread-data-builder.js +1 -0
- package/dist/agent/thread-data-builder.js.map +1 -1
- package/dist/client/AgentPanel.js +2 -2
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +71 -6
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/components/ui/dropdown-menu.js +2 -2
- package/dist/client/components/ui/dropdown-menu.js.map +1 -1
- package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
- package/dist/client/resources/ResourcesPanel.js +6 -6
- package/dist/client/resources/ResourcesPanel.js.map +1 -1
- package/dist/client/settings/useBuilderStatus.d.ts.map +1 -1
- package/dist/client/settings/useBuilderStatus.js +6 -2
- package/dist/client/settings/useBuilderStatus.js.map +1 -1
- package/dist/client/sharing/ShareButton.d.ts +2 -0
- package/dist/client/sharing/ShareButton.d.ts.map +1 -1
- package/dist/client/sharing/ShareButton.js +26 -3
- package/dist/client/sharing/ShareButton.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +14 -0
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +77 -12
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/builder-browser.d.ts +8 -6
- package/dist/server/builder-browser.d.ts.map +1 -1
- package/dist/server/builder-browser.js +54 -32
- package/dist/server/builder-browser.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts +7 -0
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +100 -74
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ import { AgentTaskCard } from "./AgentTaskCard.js";
|
|
|
13
13
|
import { ConnectBuilderCard } from "./ConnectBuilderCard.js";
|
|
14
14
|
import { useBuilderConnectFlow } from "./settings/useBuilderStatus.js";
|
|
15
15
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "./components/ui/tooltip.js";
|
|
16
|
-
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "./components/ui/dropdown-menu.js";
|
|
16
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "./components/ui/dropdown-menu.js";
|
|
17
17
|
import { IframeEmbed, parseEmbedBody } from "./IframeEmbed.js";
|
|
18
18
|
import { useDevMode } from "./use-dev-mode.js";
|
|
19
19
|
import { agentNativePath } from "./api-path.js";
|
|
@@ -144,6 +144,67 @@ async function waitForThreadRunToClear(apiUrl, threadId) {
|
|
|
144
144
|
await new Promise((resolve) => window.setTimeout(resolve, ACTIVE_RUN_POLL_INTERVAL_MS));
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
+
function coerceMessageDate(value) {
|
|
148
|
+
if (value instanceof Date) {
|
|
149
|
+
return Number.isNaN(value.getTime()) ? null : value;
|
|
150
|
+
}
|
|
151
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
152
|
+
const date = new Date(value);
|
|
153
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
function isSameCalendarDay(a, b) {
|
|
158
|
+
return (a.getFullYear() === b.getFullYear() &&
|
|
159
|
+
a.getMonth() === b.getMonth() &&
|
|
160
|
+
a.getDate() === b.getDate());
|
|
161
|
+
}
|
|
162
|
+
function formatMessageTimestamp(value) {
|
|
163
|
+
const date = coerceMessageDate(value);
|
|
164
|
+
if (!date)
|
|
165
|
+
return null;
|
|
166
|
+
const now = new Date();
|
|
167
|
+
const yesterday = new Date(now);
|
|
168
|
+
yesterday.setDate(now.getDate() - 1);
|
|
169
|
+
const time = new Intl.DateTimeFormat(undefined, {
|
|
170
|
+
hour: "numeric",
|
|
171
|
+
minute: "2-digit",
|
|
172
|
+
}).format(date);
|
|
173
|
+
let short;
|
|
174
|
+
if (isSameCalendarDay(date, now)) {
|
|
175
|
+
short = time;
|
|
176
|
+
}
|
|
177
|
+
else if (isSameCalendarDay(date, yesterday)) {
|
|
178
|
+
short = `Yesterday ${time}`;
|
|
179
|
+
}
|
|
180
|
+
else if (date.getFullYear() === now.getFullYear()) {
|
|
181
|
+
short = `${new Intl.DateTimeFormat(undefined, {
|
|
182
|
+
month: "short",
|
|
183
|
+
day: "numeric",
|
|
184
|
+
}).format(date)}, ${time}`;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
short = `${new Intl.DateTimeFormat(undefined, {
|
|
188
|
+
month: "short",
|
|
189
|
+
day: "numeric",
|
|
190
|
+
year: "numeric",
|
|
191
|
+
}).format(date)}, ${time}`;
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
short,
|
|
195
|
+
full: new Intl.DateTimeFormat(undefined, {
|
|
196
|
+
weekday: "short",
|
|
197
|
+
month: "short",
|
|
198
|
+
day: "numeric",
|
|
199
|
+
year: "numeric",
|
|
200
|
+
hour: "numeric",
|
|
201
|
+
minute: "2-digit",
|
|
202
|
+
}).format(date),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function MessageTimestamp({ timestamp, className, }) {
|
|
206
|
+
return (_jsx("span", { className: cn("text-[11px] leading-none text-muted-foreground", className), title: timestamp.full, children: timestamp.short }));
|
|
207
|
+
}
|
|
147
208
|
function SelectionAttachedPill() {
|
|
148
209
|
const [length, setLength] = useState(null);
|
|
149
210
|
useEffect(() => {
|
|
@@ -589,6 +650,8 @@ function UserMessage() {
|
|
|
589
650
|
const [expanded, setExpanded] = useState(false);
|
|
590
651
|
const [isExpandable, setIsExpandable] = useState(false);
|
|
591
652
|
const contentRef = useRef(null);
|
|
653
|
+
const messageRuntime = useMessageRuntime();
|
|
654
|
+
const timestamp = formatMessageTimestamp(messageRuntime.getState().createdAt);
|
|
592
655
|
useEffect(() => {
|
|
593
656
|
const el = contentRef.current;
|
|
594
657
|
if (!el)
|
|
@@ -601,7 +664,7 @@ function UserMessage() {
|
|
|
601
664
|
observer.observe(el);
|
|
602
665
|
return () => observer.disconnect();
|
|
603
666
|
}, []);
|
|
604
|
-
return (_jsx("div", { className: "flex justify-end", style: { contentVisibility: "auto" }, children: _jsxs("div", { className: "max-w-[85%]", children: [_jsx(UserMessageAttachments, {}), _jsxs("div", { className: "relative rounded-lg bg-accent px-3 py-2 text-sm leading-relaxed text-foreground", onCopy: (e) => {
|
|
667
|
+
return (_jsx("div", { className: "group flex justify-end", style: { contentVisibility: "auto" }, children: _jsxs("div", { className: "max-w-[85%]", children: [_jsx(UserMessageAttachments, {}), _jsxs("div", { className: "relative rounded-lg bg-accent px-3 py-2 text-sm leading-relaxed text-foreground", onCopy: (e) => {
|
|
605
668
|
const selection = window.getSelection();
|
|
606
669
|
if (!selection || selection.rangeCount === 0)
|
|
607
670
|
return;
|
|
@@ -618,7 +681,7 @@ function UserMessage() {
|
|
|
618
681
|
e.clipboardData.setData("text/plain", div.textContent || "");
|
|
619
682
|
}, children: [_jsx("div", { ref: contentRef, className: cn("whitespace-pre-wrap break-words", !expanded && isExpandable && "max-h-[200px] overflow-hidden"), children: _jsx(MessagePrimitive.Parts, { components: {
|
|
620
683
|
Text: UserMessageText,
|
|
621
|
-
} }) }), !expanded && isExpandable && (_jsx("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 h-14 rounded-b-lg bg-gradient-to-t from-accent via-accent/90 to-transparent" }))] }), isExpandable && (_jsxs("button", { type: "button", onClick: () => setExpanded((prev) => !prev), className: "mt-1 inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-[11px] font-medium text-muted-foreground hover:text-foreground", children: [_jsx(IconChevronDown, { className: cn("h-3.5 w-3.5 transition-transform", expanded && "rotate-180") }), expanded ? "Collapse" : "Expand"] }))] }) }));
|
|
684
|
+
} }) }), !expanded && isExpandable && (_jsx("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 h-14 rounded-b-lg bg-gradient-to-t from-accent via-accent/90 to-transparent" }))] }), isExpandable && (_jsxs("button", { type: "button", onClick: () => setExpanded((prev) => !prev), className: "mt-1 inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-[11px] font-medium text-muted-foreground hover:text-foreground", children: [_jsx(IconChevronDown, { className: cn("h-3.5 w-3.5 transition-transform", expanded && "rotate-180") }), expanded ? "Collapse" : "Expand"] })), timestamp && (_jsx("div", { className: "mt-1 flex justify-end", children: _jsx(MessageTimestamp, { timestamp: timestamp, className: "opacity-0 transition-opacity duration-150 group-hover:opacity-100 group-focus-within:opacity-100" }) }))] }) }));
|
|
622
685
|
}
|
|
623
686
|
const CheckpointContext = React.createContext(null);
|
|
624
687
|
const MessageActionsContext = React.createContext(null);
|
|
@@ -627,6 +690,7 @@ function MessageActionsMenu({ showRevert, onRevert, } = {}) {
|
|
|
627
690
|
const [copied, setCopied] = useState(null);
|
|
628
691
|
const messageRuntime = useMessageRuntime();
|
|
629
692
|
const actionsCtx = React.useContext(MessageActionsContext);
|
|
693
|
+
const timestamp = formatMessageTimestamp(messageRuntime.getState().createdAt);
|
|
630
694
|
const handleCopyMessage = useCallback(() => {
|
|
631
695
|
const m = messageRuntime.getState();
|
|
632
696
|
const text = m.content
|
|
@@ -668,13 +732,13 @@ function MessageActionsMenu({ showRevert, onRevert, } = {}) {
|
|
|
668
732
|
setOpen(false);
|
|
669
733
|
onRevert?.();
|
|
670
734
|
}, [onRevert]);
|
|
671
|
-
return (_jsxs(DropdownMenu, { open: open, onOpenChange: setOpen, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { className: cn("flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground/70 hover:bg-accent hover:text-foreground", open && "bg-accent text-foreground"), children: _jsx(IconDots, { className: "h-3.5 w-3.5" }) }) }), _jsxs(DropdownMenuContent, { align: "start", sideOffset:
|
|
735
|
+
return (_jsxs(DropdownMenu, { open: open, onOpenChange: setOpen, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { "aria-label": "Message actions", className: cn("flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors duration-150 hover:bg-accent hover:text-foreground", open && "bg-accent text-foreground"), children: _jsx(IconDots, { className: "h-3.5 w-3.5" }) }) }), _jsxs(DropdownMenuContent, { align: "start", sideOffset: 6, className: "w-48 rounded-lg border-border p-1.5 shadow-xl", children: [actionsCtx?.onForkChat && (_jsxs(DropdownMenuItem, { onSelect: handleForkChat, children: [_jsx(IconGitFork, { className: "h-3.5 w-3.5" }), "Fork Chat"] })), _jsxs(DropdownMenuItem, { onSelect: (e) => {
|
|
672
736
|
e.preventDefault();
|
|
673
737
|
handleCopyMessage();
|
|
674
738
|
}, children: [copied === "message" ? (_jsx(IconCheck, { className: "h-3.5 w-3.5" })) : (_jsx(IconCopy, { className: "h-3.5 w-3.5" })), copied === "message" ? "Copied!" : "Copy Message"] }), _jsxs(DropdownMenuItem, { onSelect: (e) => {
|
|
675
739
|
e.preventDefault();
|
|
676
740
|
handleCopyRequestId();
|
|
677
|
-
}, children: [copied === "id" ? (_jsx(IconCheck, { className: "h-3.5 w-3.5" })) : (_jsx(IconId, { className: "h-3.5 w-3.5" })), copied === "id" ? "Copied!" : "Copy Request ID"] }), showRevert && (_jsxs(DropdownMenuItem, { onSelect: handleRevert, children: [_jsx(IconArrowBackUp, { className: "h-3.5 w-3.5" }), "Revert to here"] }))] })] }));
|
|
741
|
+
}, children: [copied === "id" ? (_jsx(IconCheck, { className: "h-3.5 w-3.5" })) : (_jsx(IconId, { className: "h-3.5 w-3.5" })), copied === "id" ? "Copied!" : "Copy Request ID"] }), showRevert && (_jsxs(DropdownMenuItem, { onSelect: handleRevert, children: [_jsx(IconArrowBackUp, { className: "h-3.5 w-3.5" }), "Revert to here"] })), timestamp && (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuLabel, { className: "px-2 py-1 text-[11px] font-normal text-muted-foreground", children: ["Sent ", timestamp.short] })] }))] })] }));
|
|
678
742
|
}
|
|
679
743
|
function AssistantMessage() {
|
|
680
744
|
const [restoreState, setRestoreState] = useState("idle");
|
|
@@ -682,6 +746,7 @@ function AssistantMessage() {
|
|
|
682
746
|
const thread = useThread();
|
|
683
747
|
const chatRunning = React.useContext(ChatRunningContext);
|
|
684
748
|
const msg = messageRuntime.getState();
|
|
749
|
+
const timestamp = formatMessageTimestamp(msg.createdAt);
|
|
685
750
|
const isLast = thread.messages.length > 0 &&
|
|
686
751
|
thread.messages[thread.messages.length - 1].id === msg.id;
|
|
687
752
|
const isComplete = !isLast || !chatRunning;
|
|
@@ -737,7 +802,7 @@ function AssistantMessage() {
|
|
|
737
802
|
tools: {
|
|
738
803
|
Fallback: ToolCallFallback,
|
|
739
804
|
},
|
|
740
|
-
} }) }), isComplete && (_jsxs("div", { className: "mt-1 flex items-center justify-between", children: [_jsx(MessageActionsMenu, { showRevert: showRestore && restoreState === "idle", onRevert: handleRestore }), showRestore && restoreState === "confirming" ? (_jsxs("div", { className: "flex items-center gap-1 text-xs", children: [_jsx("button", { onClick: handleRestore, className: "rounded-md bg-destructive px-1.5 py-0.5 text-destructive-foreground hover:bg-destructive/90", children: "Restore to here?" }), _jsx("button", { onClick: cancelRestore, className: "rounded-md px-1.5 py-0.5 text-muted-foreground hover:bg-accent", children: "Cancel" })] })) : showRestore && restoreState === "restoring" ? (_jsxs("span", { className: "flex items-center gap-1 text-xs text-muted-foreground", children: [_jsx(IconLoader2, { className: "h-3 w-3 animate-spin" }), "Restoring..."] })) : (_jsx(React.Suspense, { fallback: null, children: _jsx(ThumbsFeedbackLazy, { threadId: cpCtx?.threadId ?? "", runId: (() => {
|
|
805
|
+
} }) }), isComplete && (_jsxs("div", { className: "mt-1 flex items-center justify-between", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [_jsx(MessageActionsMenu, { showRevert: showRestore && restoreState === "idle", onRevert: handleRestore }), timestamp && (_jsx(MessageTimestamp, { timestamp: timestamp, className: "opacity-0 transition-opacity duration-150 group-hover:opacity-100 group-focus-within:opacity-100" }))] }), showRestore && restoreState === "confirming" ? (_jsxs("div", { className: "flex items-center gap-1 text-xs", children: [_jsx("button", { onClick: handleRestore, className: "rounded-md bg-destructive px-1.5 py-0.5 text-destructive-foreground hover:bg-destructive/90", children: "Restore to here?" }), _jsx("button", { onClick: cancelRestore, className: "rounded-md px-1.5 py-0.5 text-muted-foreground hover:bg-accent", children: "Cancel" })] })) : showRestore && restoreState === "restoring" ? (_jsxs("span", { className: "flex items-center gap-1 text-xs text-muted-foreground", children: [_jsx(IconLoader2, { className: "h-3 w-3 animate-spin" }), "Restoring..."] })) : (_jsx(React.Suspense, { fallback: null, children: _jsx(ThumbsFeedbackLazy, { threadId: cpCtx?.threadId ?? "", runId: (() => {
|
|
741
806
|
const meta = messageRuntime.getState().metadata;
|
|
742
807
|
return ((typeof meta?.custom?.runId === "string" &&
|
|
743
808
|
meta.custom.runId) ||
|