@meshagent/meshagent-tailwind 0.56.2 → 0.57.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/CHANGELOG.md +12 -0
- package/README.md +61 -0
- package/dist/cjs/chat/agent-thread.d.ts +4 -2
- package/dist/cjs/chat/agent-thread.js +79 -44
- package/dist/cjs/chat/chat-input.js +104 -74
- package/dist/cjs/chat/chat-thread-timeline.js +13 -4
- package/dist/cjs/chat/composer-action-button.js +10 -2
- package/dist/cjs/chat/tool-call-status-accumulator.js +57 -48
- package/dist/esm/chat/agent-thread.d.ts +4 -2
- package/dist/esm/chat/agent-thread.js +83 -45
- package/dist/esm/chat/chat-input.js +104 -74
- package/dist/esm/chat/chat-thread-timeline.js +13 -4
- package/dist/esm/chat/composer-action-button.js +10 -2
- package/dist/esm/chat/tool-call-status-accumulator.js +57 -48
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## [0.57.1]
|
|
2
|
+
- Added configurable protocol receive limits covering message size, fragments, type size, pending work, and assembly timeouts.
|
|
3
|
+
- Made the local room WebSocket proxy fail closed unless the request originates from the verified local loopback endpoint with a valid same-origin check.
|
|
4
|
+
- Added safe dataset filter serialization that escapes SQL string literals and rejects unsupported values.
|
|
5
|
+
- Added bounded recursive tool-argument searches with cycle, depth, and work limits.
|
|
6
|
+
- Added stable CSS hooks, user display-name support, improved chat composer behavior, attachment cancellation, and client-tool status handling.
|
|
7
|
+
- Added normalized React authentication URL handling and improved trace and usage presentation support.
|
|
8
|
+
- Added `jsdom` version 29.1.1 and `react-dom` version 19.1.8 as React development dependencies.
|
|
9
|
+
|
|
10
|
+
## [0.57.0]
|
|
11
|
+
- Added TypeScript support for registering existing external Lance datasets as read-only room tables without transferring credentials.
|
|
12
|
+
|
|
1
13
|
## [0.56.2]
|
|
2
14
|
- Breaking change: the TypeScript effective-access method now requires a roles array and sends roles separately from capability relations.
|
|
3
15
|
|
package/README.md
CHANGED
|
@@ -182,3 +182,64 @@ Set `PLAYWRIGHT_CHROMIUM_EXECUTABLE` to use an existing Chromium installation.
|
|
|
182
182
|
Widget resize corrections wait for 100 ms without height changes, with a 300 ms
|
|
183
183
|
maximum wait during continuous resizing. The feed preserves the visible message
|
|
184
184
|
or continues following the bottom; manual scrolling updates that choice.
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
## Public chat styling hooks
|
|
188
|
+
|
|
189
|
+
Plugins can style library-rendered chat elements with ordinary CSS using the
|
|
190
|
+
following stable BEM classes. These names are a public compatibility contract;
|
|
191
|
+
Tailwind utilities and DOM nesting are implementation details. Existing
|
|
192
|
+
`data-chat-bubble`, `data-chat-author`, and `chat-scroll` classes remain available.
|
|
193
|
+
|
|
194
|
+
| Element | Classes |
|
|
195
|
+
| --- | --- |
|
|
196
|
+
| AgentThreadFeed item content (immediate child of `chat-scroll__message`) | `chat-scroll__message-content` |
|
|
197
|
+
| Ordinary message container | `chat-message`, `chat-message--user` or `chat-message--assistant` |
|
|
198
|
+
| Text alignment/content container | `chat-message__content` |
|
|
199
|
+
| Author label (when present) | `chat-message__author`, `chat-message__author--user` or `chat-message__author--assistant` |
|
|
200
|
+
| Text bubble | `chat-message__bubble`, `chat-message__bubble--user` or `chat-message__bubble--assistant` |
|
|
201
|
+
| Markdown surface | `chat-message__markdown` (on the existing bubble or reasoning container) |
|
|
202
|
+
| Reasoning | `chat-message__reasoning` |
|
|
203
|
+
| Message attachment collection | `chat-message__attachments` |
|
|
204
|
+
| Composer | `chat-composer` |
|
|
205
|
+
| Input row | `chat-composer__input-row` |
|
|
206
|
+
| Textarea | `chat-composer__input` |
|
|
207
|
+
| Default send/stop/cancelling button | `chat-composer__action` |
|
|
208
|
+
|
|
209
|
+
Role modifiers follow the existing user/assistant presentation classification.
|
|
210
|
+
Empty text, suppressed author labels, and absent attachments do not create extra
|
|
211
|
+
elements. Reasoning, events, errors, and tool widgets are not ordinary message
|
|
212
|
+
containers. Custom renderers own their markup and may opt into these classes;
|
|
213
|
+
the library guarantees hooks only on its own rendered elements.
|
|
214
|
+
|
|
215
|
+
```css
|
|
216
|
+
/* Scope overrides to an individual assistant when sharing a document. */
|
|
217
|
+
.support-chat .chat-message__bubble--user {
|
|
218
|
+
background: #123456;
|
|
219
|
+
color: white;
|
|
220
|
+
padding: 12px 20px;
|
|
221
|
+
margin-block: 8px;
|
|
222
|
+
font-family: Georgia, serif;
|
|
223
|
+
line-height: 1.6;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.support-chat .chat-composer__input {
|
|
227
|
+
padding: 10px 14px;
|
|
228
|
+
font-family: inherit;
|
|
229
|
+
font-size: 16px;
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
No Tailwind compilation is needed for ordinary plugin CSS. The supplied built
|
|
234
|
+
stylesheet places Tailwind utilities in cascade layers, so normal unlayered
|
|
235
|
+
plugin rules override those layered defaults. BEM classes have the same
|
|
236
|
+
specificity as other classes; they do not intrinsically override utilities.
|
|
237
|
+
Applications that rebuild or flatten CSS must preserve layers or manage their
|
|
238
|
+
own specificity and source order. Inline runtime measurements (such as textarea
|
|
239
|
+
height) remain controlled by the component. Do not override virtualizer spacer,
|
|
240
|
+
positioning, or measurement styles.
|
|
241
|
+
|
|
242
|
+
For a Shadow DOM integration, load plugin CSS inside the same shadow root as the
|
|
243
|
+
chat and place the scope class on an ancestor inside that root. Host-page CSS
|
|
244
|
+
cannot style these elements across the shadow boundary. Existing React
|
|
245
|
+
class-name props continue to work alongside the public hooks.
|
|
@@ -2,7 +2,7 @@ import type { ReactElement, ReactNode } from "react";
|
|
|
2
2
|
import type { RoomClient, Tool } from "@meshagent/meshagent";
|
|
3
3
|
import type { AgentMessage, AgentMessageEvent, BaseChatClient, ClientToolkitDescription } from "@meshagent/meshagent-agents";
|
|
4
4
|
import type { AgentUsageSnapshot, ChatThreadItem } from "./chat-thread-timeline.js";
|
|
5
|
-
export { AgentUsageSnapshot, shouldReplaceAgentUsageSnapshot } from "./chat-thread-timeline.js";
|
|
5
|
+
export { AgentUsageSnapshot, shouldReplaceAgentUsageSnapshot, } from "./chat-thread-timeline.js";
|
|
6
6
|
export type { ChatThreadItem } from "./chat-thread-timeline.js";
|
|
7
7
|
import { type ChatInputProps } from "./chat-input.js";
|
|
8
8
|
import { ChatMessage } from "./chat-message.js";
|
|
@@ -104,6 +104,8 @@ export declare function useAgentThreadStatus(): {
|
|
|
104
104
|
interrupt: () => Promise<void>;
|
|
105
105
|
};
|
|
106
106
|
export interface AgentThreadFeedProps {
|
|
107
|
+
/** Presentation-only label for user messages; does not change participant identity. */
|
|
108
|
+
userDisplayName?: string;
|
|
107
109
|
/** Show the built-in progress overlay and reserve its bottom spacing. Defaults to true. */
|
|
108
110
|
showStatusIndicator?: boolean;
|
|
109
111
|
/** Renders application-owned content after a visible feed item without sending it to the agent. */
|
|
@@ -111,7 +113,7 @@ export interface AgentThreadFeedProps {
|
|
|
111
113
|
/** Renders local content before the oldest item, or in place of the empty state. */
|
|
112
114
|
renderUnanchored?: () => ReactNode;
|
|
113
115
|
}
|
|
114
|
-
export declare function AgentThreadFeed({ renderAfterItem, renderUnanchored, showStatusIndicator, }?: AgentThreadFeedProps): ReactElement;
|
|
116
|
+
export declare function AgentThreadFeed({ renderAfterItem, renderUnanchored, showStatusIndicator, userDisplayName, }?: AgentThreadFeedProps): ReactElement;
|
|
115
117
|
export interface AgentThreadInputProps extends Pick<ChatInputProps, "className" | "inputRowClassName" | "textareaClassName" | "leadingButton"> {
|
|
116
118
|
showSubmitButton?: boolean;
|
|
117
119
|
submitButtonComponent?: ChatInputProps["submitButtonComponent"];
|
|
@@ -321,9 +321,10 @@ function ChatBubble({ text, mine }) {
|
|
|
321
321
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
322
322
|
"div",
|
|
323
323
|
{
|
|
324
|
+
"data-chat-bubble": mine ? "user" : "assistant",
|
|
324
325
|
className: (0, import_utils.cn)(
|
|
325
|
-
"w-fit max-w-[85%] rounded-md px-4 py-3 text-sm leading-6 shadow-xs sm:max-w-2xl",
|
|
326
|
-
mine ? "bg-secondary/85 text-foreground" : "bg-muted/70 text-foreground"
|
|
326
|
+
"chat-message__bubble chat-message__markdown w-fit max-w-[85%] rounded-md px-4 py-3 text-sm leading-6 shadow-xs sm:max-w-2xl",
|
|
327
|
+
mine ? "chat-message__bubble--user bg-secondary/85 text-foreground" : "chat-message__bubble--assistant bg-muted/70 text-foreground"
|
|
327
328
|
),
|
|
328
329
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MarkdownBlock, { text })
|
|
329
330
|
}
|
|
@@ -333,7 +334,16 @@ function ReasoningTrace({ text, className }) {
|
|
|
333
334
|
if (text.trim() === "") {
|
|
334
335
|
return null;
|
|
335
336
|
}
|
|
336
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
337
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
338
|
+
"div",
|
|
339
|
+
{
|
|
340
|
+
className: (0, import_utils.cn)(
|
|
341
|
+
"chat-message__reasoning chat-message__markdown mr-[50px] ml-1.5 px-4 py-1 text-sm leading-6 text-muted-foreground",
|
|
342
|
+
className
|
|
343
|
+
),
|
|
344
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MarkdownBlock, { text })
|
|
345
|
+
}
|
|
346
|
+
);
|
|
337
347
|
}
|
|
338
348
|
function trimShellText(value) {
|
|
339
349
|
if (value == null) {
|
|
@@ -644,7 +654,8 @@ function ThreadMessageView({
|
|
|
644
654
|
agentName,
|
|
645
655
|
chatFeedWidgetsByName,
|
|
646
656
|
onSendMessage,
|
|
647
|
-
forceHideHeader = false
|
|
657
|
+
forceHideHeader = false,
|
|
658
|
+
userDisplayName
|
|
648
659
|
}) {
|
|
649
660
|
if (message.kind === "error") {
|
|
650
661
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "px-6 py-1 text-center text-sm text-destructive", children: message.text });
|
|
@@ -692,43 +703,59 @@ function ThreadMessageView({
|
|
|
692
703
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolCallLine, { message });
|
|
693
704
|
}
|
|
694
705
|
const mine = message.role === "user";
|
|
695
|
-
const authorName = message.authorName ??
|
|
696
|
-
const previousAuthor = previous?.
|
|
706
|
+
const authorName = mine ? userDisplayName ?? message.authorName ?? localParticipantName : message.authorName ?? displayParticipantName(agentName);
|
|
707
|
+
const previousAuthor = previous?.role === "user" ? userDisplayName ?? previous.authorName ?? localParticipantName : previous?.authorName ?? displayParticipantName(agentName);
|
|
697
708
|
const shouldShowHeader = !forceHideHeader && (previous?.kind !== "message" || previousAuthor !== authorName);
|
|
698
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
),
|
|
706
|
-
children: [
|
|
707
|
-
authorName.trim() !== "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "font-semibold text-foreground", children: displayParticipantName(authorName) }) : null,
|
|
708
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: timeAgo(message.createdAt) })
|
|
709
|
-
]
|
|
710
|
-
}
|
|
711
|
-
) }) }) : null,
|
|
712
|
-
message.text.trim() !== "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_utils.cn)("flex w-full", mine ? "justify-end" : "justify-start"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChatBubble, { text: message.text, mine }) }) : null,
|
|
713
|
-
message.attachments.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_utils.cn)("flex w-full", mine ? "justify-end" : "justify-start"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
714
|
-
"div",
|
|
715
|
-
{
|
|
716
|
-
className: (0, import_utils.cn)(
|
|
717
|
-
"flex max-w-[85%] flex-wrap gap-3 px-1 sm:max-w-2xl",
|
|
718
|
-
mine ? "justify-end" : "justify-start"
|
|
719
|
-
),
|
|
720
|
-
children: message.attachments.map((attachment, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
721
|
-
AttachmentView,
|
|
709
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
710
|
+
"div",
|
|
711
|
+
{
|
|
712
|
+
className: (0, import_utils.cn)("chat-message flex flex-col gap-2", mine ? "chat-message--user" : "chat-message--assistant"),
|
|
713
|
+
children: [
|
|
714
|
+
shouldShowHeader ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_utils.cn)("flex w-full", mine ? "justify-end" : "justify-start"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_utils.cn)("max-w-[85%] px-1 sm:max-w-2xl", mine ? "text-right" : "text-left"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
715
|
+
"div",
|
|
722
716
|
{
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
717
|
+
className: (0, import_utils.cn)(
|
|
718
|
+
"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",
|
|
719
|
+
mine ? "justify-end" : "justify-start"
|
|
720
|
+
),
|
|
721
|
+
children: [
|
|
722
|
+
authorName.trim() !== "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
723
|
+
"span",
|
|
724
|
+
{
|
|
725
|
+
"data-chat-author": mine ? "user" : "assistant",
|
|
726
|
+
className: (0, import_utils.cn)(
|
|
727
|
+
"chat-message__author font-semibold text-foreground",
|
|
728
|
+
mine ? "chat-message__author--user" : "chat-message__author--assistant"
|
|
729
|
+
),
|
|
730
|
+
children: displayParticipantName(authorName)
|
|
731
|
+
}
|
|
732
|
+
) : null,
|
|
733
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: timeAgo(message.createdAt) })
|
|
734
|
+
]
|
|
735
|
+
}
|
|
736
|
+
) }) }) : null,
|
|
737
|
+
message.text.trim() !== "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_utils.cn)("chat-message__content flex w-full", mine ? "justify-end" : "justify-start"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChatBubble, { text: message.text, mine }) }) : null,
|
|
738
|
+
message.attachments.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_utils.cn)("flex w-full", mine ? "justify-end" : "justify-start"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
739
|
+
"div",
|
|
740
|
+
{
|
|
741
|
+
className: (0, import_utils.cn)(
|
|
742
|
+
"chat-message__attachments flex max-w-[85%] flex-wrap gap-3 px-1 sm:max-w-2xl",
|
|
743
|
+
mine ? "justify-end" : "justify-start"
|
|
744
|
+
),
|
|
745
|
+
children: message.attachments.map((attachment, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
746
|
+
AttachmentView,
|
|
747
|
+
{
|
|
748
|
+
room,
|
|
749
|
+
path: attachment
|
|
750
|
+
},
|
|
751
|
+
`${message.id}:attachment:${attachment}:${index}`
|
|
752
|
+
))
|
|
753
|
+
}
|
|
754
|
+
) }) : null,
|
|
755
|
+
message.image ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex w-full justify-start", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GeneratedImageView, { image: message.image }) }) : null
|
|
756
|
+
]
|
|
757
|
+
}
|
|
758
|
+
);
|
|
732
759
|
}
|
|
733
760
|
function EmptyState({ title, description }) {
|
|
734
761
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mx-auto flex h-full max-w-2xl flex-col items-center justify-center px-6 py-20 text-center", children: [
|
|
@@ -814,7 +841,9 @@ function processClientToolRequests({
|
|
|
814
841
|
}
|
|
815
842
|
replayingClientToolSessions.delete(session);
|
|
816
843
|
const completedRequestIds = new Set(
|
|
817
|
-
(0, import_chat_thread_timeline.buildChatThreadTimeline)(session.messages).items.filter(
|
|
844
|
+
(0, import_chat_thread_timeline.buildChatThreadTimeline)(session.messages).items.filter(
|
|
845
|
+
(item) => item.kind === "tool_call" && item.toolkit === "client" && (item.state === "completed" || item.state === "failed")
|
|
846
|
+
).map((item) => item.clientToolRequestId ?? item.id)
|
|
818
847
|
);
|
|
819
848
|
for (const request of requests) {
|
|
820
849
|
if (completedRequestIds.has(request.requestId)) {
|
|
@@ -860,7 +889,9 @@ function processClientToolRequests({
|
|
|
860
889
|
});
|
|
861
890
|
session.finishClientToolCall(request.requestId, { responseSent: true });
|
|
862
891
|
} catch (error) {
|
|
863
|
-
session.finishClientToolCall(request.requestId, {
|
|
892
|
+
session.finishClientToolCall(request.requestId, {
|
|
893
|
+
responseSent: false
|
|
894
|
+
});
|
|
864
895
|
updateCall(clientToolCallKey(session.threadPath, request.requestId), {
|
|
865
896
|
status: "failed",
|
|
866
897
|
output: new import_meshagent.ErrorContent({ text: describeError(error) })
|
|
@@ -1176,7 +1207,9 @@ function AgentThreadProvider({
|
|
|
1176
1207
|
}, [deferLiveEvents, persistedEvents, session, version]);
|
|
1177
1208
|
const timelineItems = (0, import_react.useMemo)(
|
|
1178
1209
|
() => (timeline?.items ?? []).map((item) => {
|
|
1179
|
-
const override = session == null ? void 0 : clientToolCallOverrides.get(
|
|
1210
|
+
const override = session == null ? void 0 : clientToolCallOverrides.get(
|
|
1211
|
+
clientToolCallKey(session.threadPath, item.clientToolRequestId ?? item.id)
|
|
1212
|
+
);
|
|
1180
1213
|
if (override == null || item.kind !== "tool_call" || item.state === "completed" || item.state === "failed") {
|
|
1181
1214
|
return item;
|
|
1182
1215
|
}
|
|
@@ -1405,7 +1438,8 @@ function useAgentThreadStatus() {
|
|
|
1405
1438
|
function AgentThreadFeed({
|
|
1406
1439
|
renderAfterItem,
|
|
1407
1440
|
renderUnanchored,
|
|
1408
|
-
showStatusIndicator = true
|
|
1441
|
+
showStatusIndicator = true,
|
|
1442
|
+
userDisplayName
|
|
1409
1443
|
} = {}) {
|
|
1410
1444
|
const {
|
|
1411
1445
|
room,
|
|
@@ -1444,7 +1478,7 @@ function AgentThreadFeed({
|
|
|
1444
1478
|
"div",
|
|
1445
1479
|
{
|
|
1446
1480
|
className: (0, import_utils.cn)(
|
|
1447
|
-
"mx-auto w-full max-w-[912px] px-1 py-3",
|
|
1481
|
+
"chat-scroll__message-content mx-auto w-full max-w-[912px] px-1 py-3",
|
|
1448
1482
|
item.id === firstRenderedItemId ? "pt-6" : null,
|
|
1449
1483
|
item.id === lastRenderedItemId ? showStatusIndicator && statusText ? "pb-24" : "pb-6" : null
|
|
1450
1484
|
),
|
|
@@ -1455,6 +1489,7 @@ function AgentThreadFeed({
|
|
|
1455
1489
|
{
|
|
1456
1490
|
room,
|
|
1457
1491
|
message: item,
|
|
1492
|
+
userDisplayName,
|
|
1458
1493
|
previous: previousItemById.get(item.id) ?? null,
|
|
1459
1494
|
localParticipantName,
|
|
1460
1495
|
agentName,
|
|
@@ -83,13 +83,16 @@ function ChatInput({
|
|
|
83
83
|
const textareaRef = (0, import_react.useRef)(null);
|
|
84
84
|
const value = controlledValue ?? uncontrolledValue;
|
|
85
85
|
const attachmentStatusVersion = (0, import_chat_input_state.useAttachmentStatusVersion)(attachments);
|
|
86
|
-
const setValue = (0, import_react.useCallback)(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
const setValue = (0, import_react.useCallback)(
|
|
87
|
+
(nextValue) => {
|
|
88
|
+
if (controlledValue === void 0) {
|
|
89
|
+
setUncontrolledValue(nextValue);
|
|
90
|
+
}
|
|
91
|
+
onValueChange?.(nextValue);
|
|
92
|
+
onTextChange?.(nextValue);
|
|
93
|
+
},
|
|
94
|
+
[controlledValue, onTextChange, onValueChange]
|
|
95
|
+
);
|
|
93
96
|
useAutoResizingTextarea(textareaRef, value);
|
|
94
97
|
const allAttachmentsUploaded = (0, import_react.useMemo)(
|
|
95
98
|
() => attachments.every((attachment) => attachment.status === import_file_attachment.UploadStatus.Completed),
|
|
@@ -102,81 +105,108 @@ function ChatInput({
|
|
|
102
105
|
if (!canSend) {
|
|
103
106
|
return;
|
|
104
107
|
}
|
|
105
|
-
void onSubmit(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
void onSubmit(
|
|
109
|
+
new import_chat_message.ChatMessage({
|
|
110
|
+
id: (0, import_uuid.v4)(),
|
|
111
|
+
text: trimmed,
|
|
112
|
+
attachments: attachments.map((attachment) => attachment.path)
|
|
113
|
+
})
|
|
114
|
+
);
|
|
110
115
|
if (!clearOnSubmit) {
|
|
111
116
|
return;
|
|
112
117
|
}
|
|
113
118
|
setValue("");
|
|
114
119
|
setAttachments([]);
|
|
115
120
|
}, [attachments, canSend, clearOnSubmit, onSubmit, setAttachments, setValue, value]);
|
|
116
|
-
const handleKeyDown = (0, import_react.useCallback)(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
if (event.key === "Enter" && !event.shiftKey) {
|
|
121
|
-
event.preventDefault();
|
|
122
|
-
if (showCancelButton) {
|
|
123
|
-
onCancelRequest?.();
|
|
121
|
+
const handleKeyDown = (0, import_react.useCallback)(
|
|
122
|
+
(event) => {
|
|
123
|
+
if (disabled) {
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
resizeTextarea(event.currentTarget);
|
|
132
|
-
setValue(nextValue);
|
|
133
|
-
}, [setValue]);
|
|
134
|
-
const cancelAttachment = (0, import_react.useCallback)((attachment) => {
|
|
135
|
-
if (disabled) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
setAttachments(attachments.filter((currentAttachment) => currentAttachment !== attachment));
|
|
139
|
-
}, [attachments, disabled, setAttachments]);
|
|
140
|
-
const trailingButton = showCancelButton ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SubmitButton, { onClick: onCancelRequest, showCancelButton: true, title: "Stop", ariaLabel: "Stop" }) : showSubmitButton ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SubmitButton, { onClick: handleSend, disabled: !canSend, title: "Send", ariaLabel: "Send" }) : null;
|
|
141
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_utils.cn)(
|
|
142
|
-
"flex flex-col mx-auto w-full max-w-4xl gap-2",
|
|
143
|
-
"border border-input/70 rounded-md bg-background p-1 shadow-xs",
|
|
144
|
-
"focus-within:border-primary focus-within:[outline:1px_solid_var(--color-primary)]",
|
|
145
|
-
className
|
|
146
|
-
), children: [
|
|
147
|
-
attachments.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex max-w-full flex-wrap gap-2 px-1 pt-1", children: attachments.map((attachment, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
148
|
-
import_upload_pill.UploadPill,
|
|
149
|
-
{
|
|
150
|
-
attachment,
|
|
151
|
-
onCancel: cancelAttachment
|
|
152
|
-
},
|
|
153
|
-
`${attachment.path}-${index}`
|
|
154
|
-
)) }) : null,
|
|
155
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_utils.cn)("flex items-center gap-2", !enableFileUpload && "pl-1", inputRowClassName), children: [
|
|
156
|
-
leadingButton,
|
|
157
|
-
enableFileUpload ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_file_uploader.FileUploader, { onFilesSelected, disabled }) : null,
|
|
158
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
159
|
-
"textarea",
|
|
160
|
-
{
|
|
161
|
-
ref: textareaRef,
|
|
162
|
-
rows: 1,
|
|
163
|
-
autoFocus,
|
|
164
|
-
placeholder,
|
|
165
|
-
className: (0, import_utils.cn)(
|
|
166
|
-
"min-h-5 max-h-40",
|
|
167
|
-
"flex-1 resize-none border-0 bg-transparent p-0 leading-5",
|
|
168
|
-
"shadow-none outline-none ring-0 focus:ring-0 focus-visible:ring-0",
|
|
169
|
-
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
170
|
-
"md:text-sm",
|
|
171
|
-
textareaClassName
|
|
172
|
-
),
|
|
173
|
-
readOnly: disabled,
|
|
174
|
-
value,
|
|
175
|
-
onChange: handleChange,
|
|
176
|
-
onKeyDown: handleKeyDown
|
|
126
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
127
|
+
event.preventDefault();
|
|
128
|
+
if (showCancelButton) {
|
|
129
|
+
onCancelRequest?.();
|
|
130
|
+
return;
|
|
177
131
|
}
|
|
132
|
+
handleSend();
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
[disabled, handleSend, onCancelRequest, showCancelButton]
|
|
136
|
+
);
|
|
137
|
+
const handleChange = (0, import_react.useCallback)(
|
|
138
|
+
(event) => {
|
|
139
|
+
const nextValue = event.currentTarget.value;
|
|
140
|
+
resizeTextarea(event.currentTarget);
|
|
141
|
+
setValue(nextValue);
|
|
142
|
+
},
|
|
143
|
+
[setValue]
|
|
144
|
+
);
|
|
145
|
+
const cancelAttachment = (0, import_react.useCallback)(
|
|
146
|
+
(attachment) => {
|
|
147
|
+
if (disabled) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
setAttachments(attachments.filter((currentAttachment) => currentAttachment !== attachment));
|
|
151
|
+
},
|
|
152
|
+
[attachments, disabled, setAttachments]
|
|
153
|
+
);
|
|
154
|
+
const trailingButton = showCancelButton ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SubmitButton, { onClick: onCancelRequest, showCancelButton: true, title: "Stop", ariaLabel: "Stop" }) : showSubmitButton ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SubmitButton, { onClick: handleSend, disabled: !canSend, title: "Send", ariaLabel: "Send" }) : null;
|
|
155
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
156
|
+
"div",
|
|
157
|
+
{
|
|
158
|
+
className: (0, import_utils.cn)(
|
|
159
|
+
"chat-composer flex flex-col mx-auto w-full max-w-4xl gap-2",
|
|
160
|
+
"border border-input/70 rounded-md bg-background p-1 shadow-xs",
|
|
161
|
+
"focus-within:border-primary focus-within:[outline:1px_solid_var(--color-primary)]",
|
|
162
|
+
className
|
|
178
163
|
),
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
164
|
+
children: [
|
|
165
|
+
attachments.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex max-w-full flex-wrap gap-2 px-1 pt-1", children: attachments.map((attachment, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
166
|
+
import_upload_pill.UploadPill,
|
|
167
|
+
{
|
|
168
|
+
attachment,
|
|
169
|
+
onCancel: cancelAttachment
|
|
170
|
+
},
|
|
171
|
+
`${attachment.path}-${index}`
|
|
172
|
+
)) }) : null,
|
|
173
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
174
|
+
"div",
|
|
175
|
+
{
|
|
176
|
+
className: (0, import_utils.cn)(
|
|
177
|
+
"chat-composer__input-row flex items-center gap-2",
|
|
178
|
+
!enableFileUpload && "pl-1",
|
|
179
|
+
inputRowClassName
|
|
180
|
+
),
|
|
181
|
+
children: [
|
|
182
|
+
leadingButton,
|
|
183
|
+
enableFileUpload ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_file_uploader.FileUploader, { onFilesSelected, disabled }) : null,
|
|
184
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
185
|
+
"textarea",
|
|
186
|
+
{
|
|
187
|
+
ref: textareaRef,
|
|
188
|
+
rows: 1,
|
|
189
|
+
autoFocus,
|
|
190
|
+
placeholder,
|
|
191
|
+
className: (0, import_utils.cn)(
|
|
192
|
+
"chat-composer__input min-h-5 max-h-40",
|
|
193
|
+
"flex-1 resize-none border-0 bg-transparent p-0 leading-5",
|
|
194
|
+
"shadow-none outline-none ring-0 focus:ring-0 focus-visible:ring-0",
|
|
195
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
196
|
+
"md:text-sm",
|
|
197
|
+
textareaClassName
|
|
198
|
+
),
|
|
199
|
+
readOnly: disabled,
|
|
200
|
+
value,
|
|
201
|
+
onChange: handleChange,
|
|
202
|
+
onKeyDown: handleKeyDown
|
|
203
|
+
}
|
|
204
|
+
),
|
|
205
|
+
trailingButton
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
)
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
);
|
|
182
212
|
}
|
|
@@ -642,14 +642,23 @@ class AgentUsageSnapshot {
|
|
|
642
642
|
this.usage = Object.freeze({ ...params.usage });
|
|
643
643
|
}
|
|
644
644
|
static fromMessage(message) {
|
|
645
|
-
|
|
645
|
+
if (isTypedMessage(message, import_meshagent_agents.AgentUsageUpdated)) {
|
|
646
|
+
return AgentUsageSnapshot.fromPayload(message.toJson());
|
|
647
|
+
}
|
|
648
|
+
return null;
|
|
646
649
|
}
|
|
647
650
|
static fromPayload(payload) {
|
|
648
|
-
if (payload.type !== "meshagent.agent.usage.updated" || typeof payload.thread_id !== "string" || payload.thread_id.trim() === "")
|
|
649
|
-
|
|
651
|
+
if (payload.type !== "meshagent.agent.usage.updated" || typeof payload.thread_id !== "string" || payload.thread_id.trim() === "") {
|
|
652
|
+
return null;
|
|
653
|
+
}
|
|
654
|
+
if (payload.context_window == null || typeof payload.context_window !== "object") {
|
|
655
|
+
return null;
|
|
656
|
+
}
|
|
650
657
|
const context = payload.context_window;
|
|
651
658
|
const usedTokens = integerNumber(context.used_tokens);
|
|
652
|
-
if (usedTokens == null)
|
|
659
|
+
if (usedTokens == null) {
|
|
660
|
+
return null;
|
|
661
|
+
}
|
|
653
662
|
const rawUsage = payload.usage != null && typeof payload.usage === "object" ? payload.usage : {};
|
|
654
663
|
return new AgentUsageSnapshot({
|
|
655
664
|
threadPath: payload.thread_id.trim(),
|
|
@@ -41,7 +41,11 @@ function ComposerActionButton({
|
|
|
41
41
|
type: "button",
|
|
42
42
|
size: "icon",
|
|
43
43
|
variant: "ghost",
|
|
44
|
-
className: (0, import_utils.cn)(
|
|
44
|
+
className: (0, import_utils.cn)(
|
|
45
|
+
"chat-composer__action relative size-9 rounded-full",
|
|
46
|
+
disabled ? "opacity-55" : "cursor-pointer",
|
|
47
|
+
className
|
|
48
|
+
),
|
|
45
49
|
disabled,
|
|
46
50
|
onClick,
|
|
47
51
|
title: disabled ? "Cancelling" : "Stop",
|
|
@@ -57,7 +61,11 @@ function ComposerActionButton({
|
|
|
57
61
|
{
|
|
58
62
|
type: "button",
|
|
59
63
|
size: "icon",
|
|
60
|
-
className: (0, import_utils.cn)(
|
|
64
|
+
className: (0, import_utils.cn)(
|
|
65
|
+
"chat-composer__action size-9 rounded-full shadow-xs",
|
|
66
|
+
!disabled && "cursor-pointer",
|
|
67
|
+
className
|
|
68
|
+
),
|
|
61
69
|
disabled,
|
|
62
70
|
onClick,
|
|
63
71
|
title,
|