@meshagent/meshagent-tailwind 0.57.1 → 0.57.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/CHANGELOG.md +4 -7
- package/README.md +0 -61
- package/dist/cjs/chat/agent-thread.d.ts +2 -4
- package/dist/cjs/chat/agent-thread.js +44 -79
- package/dist/cjs/chat/chat-input.js +74 -104
- package/dist/cjs/chat/chat-thread-timeline.js +4 -13
- package/dist/cjs/chat/composer-action-button.js +2 -10
- package/dist/cjs/chat/tool-call-status-accumulator.js +48 -57
- package/dist/esm/chat/agent-thread.d.ts +2 -4
- package/dist/esm/chat/agent-thread.js +45 -83
- package/dist/esm/chat/chat-input.js +74 -104
- package/dist/esm/chat/chat-thread-timeline.js +4 -13
- package/dist/esm/chat/composer-action-button.js +2 -10
- package/dist/esm/chat/tool-call-status-accumulator.js +48 -57
- package/dist/index.css +2 -2
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
+
## [0.57.2]
|
|
2
|
+
- Stability
|
|
3
|
+
|
|
1
4
|
## [0.57.1]
|
|
2
|
-
- Added
|
|
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.
|
|
5
|
+
- Added optional ETag matching to TypeScript file uploads, including validation that the ETag is non-empty.
|
|
9
6
|
|
|
10
7
|
## [0.57.0]
|
|
11
8
|
- Added TypeScript support for registering existing external Lance datasets as read-only room tables without transferring credentials.
|
package/README.md
CHANGED
|
@@ -182,64 +182,3 @@ 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
|
|
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,8 +104,6 @@ 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;
|
|
109
107
|
/** Show the built-in progress overlay and reserve its bottom spacing. Defaults to true. */
|
|
110
108
|
showStatusIndicator?: boolean;
|
|
111
109
|
/** Renders application-owned content after a visible feed item without sending it to the agent. */
|
|
@@ -113,7 +111,7 @@ export interface AgentThreadFeedProps {
|
|
|
113
111
|
/** Renders local content before the oldest item, or in place of the empty state. */
|
|
114
112
|
renderUnanchored?: () => ReactNode;
|
|
115
113
|
}
|
|
116
|
-
export declare function AgentThreadFeed({ renderAfterItem, renderUnanchored, showStatusIndicator,
|
|
114
|
+
export declare function AgentThreadFeed({ renderAfterItem, renderUnanchored, showStatusIndicator, }?: AgentThreadFeedProps): ReactElement;
|
|
117
115
|
export interface AgentThreadInputProps extends Pick<ChatInputProps, "className" | "inputRowClassName" | "textareaClassName" | "leadingButton"> {
|
|
118
116
|
showSubmitButton?: boolean;
|
|
119
117
|
submitButtonComponent?: ChatInputProps["submitButtonComponent"];
|
|
@@ -321,10 +321,9 @@ 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",
|
|
325
324
|
className: (0, import_utils.cn)(
|
|
326
|
-
"
|
|
327
|
-
mine ? "
|
|
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"
|
|
328
327
|
),
|
|
329
328
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MarkdownBlock, { text })
|
|
330
329
|
}
|
|
@@ -334,16 +333,7 @@ function ReasoningTrace({ text, className }) {
|
|
|
334
333
|
if (text.trim() === "") {
|
|
335
334
|
return null;
|
|
336
335
|
}
|
|
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
|
-
);
|
|
336
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_utils.cn)("mr-[50px] ml-1.5 px-4 py-1 text-sm leading-6 text-muted-foreground", className), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MarkdownBlock, { text }) });
|
|
347
337
|
}
|
|
348
338
|
function trimShellText(value) {
|
|
349
339
|
if (value == null) {
|
|
@@ -654,8 +644,7 @@ function ThreadMessageView({
|
|
|
654
644
|
agentName,
|
|
655
645
|
chatFeedWidgetsByName,
|
|
656
646
|
onSendMessage,
|
|
657
|
-
forceHideHeader = false
|
|
658
|
-
userDisplayName
|
|
647
|
+
forceHideHeader = false
|
|
659
648
|
}) {
|
|
660
649
|
if (message.kind === "error") {
|
|
661
650
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "px-6 py-1 text-center text-sm text-destructive", children: message.text });
|
|
@@ -703,59 +692,43 @@ function ThreadMessageView({
|
|
|
703
692
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolCallLine, { message });
|
|
704
693
|
}
|
|
705
694
|
const mine = message.role === "user";
|
|
706
|
-
const authorName =
|
|
707
|
-
const previousAuthor = previous?.role === "user" ?
|
|
695
|
+
const authorName = message.authorName ?? (mine ? localParticipantName : displayParticipantName(agentName));
|
|
696
|
+
const previousAuthor = previous?.authorName ?? (previous?.role === "user" ? localParticipantName : displayParticipantName(agentName));
|
|
708
697
|
const shouldShowHeader = !forceHideHeader && (previous?.kind !== "message" || previousAuthor !== authorName);
|
|
709
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
710
|
-
"div",
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
"
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
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",
|
|
698
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
699
|
+
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)(
|
|
700
|
+
"div",
|
|
701
|
+
{
|
|
702
|
+
className: (0, import_utils.cn)(
|
|
703
|
+
"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",
|
|
704
|
+
mine ? "justify-end" : "justify-start"
|
|
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,
|
|
740
722
|
{
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
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
|
-
);
|
|
723
|
+
room,
|
|
724
|
+
path: attachment
|
|
725
|
+
},
|
|
726
|
+
`${message.id}:attachment:${attachment}:${index}`
|
|
727
|
+
))
|
|
728
|
+
}
|
|
729
|
+
) }) : null,
|
|
730
|
+
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
|
|
731
|
+
] });
|
|
759
732
|
}
|
|
760
733
|
function EmptyState({ title, description }) {
|
|
761
734
|
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: [
|
|
@@ -841,9 +814,7 @@ function processClientToolRequests({
|
|
|
841
814
|
}
|
|
842
815
|
replayingClientToolSessions.delete(session);
|
|
843
816
|
const completedRequestIds = new Set(
|
|
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)
|
|
817
|
+
(0, import_chat_thread_timeline.buildChatThreadTimeline)(session.messages).items.filter((item) => item.kind === "tool_call" && item.toolkit === "client" && (item.state === "completed" || item.state === "failed")).map((item) => item.clientToolRequestId ?? item.id)
|
|
847
818
|
);
|
|
848
819
|
for (const request of requests) {
|
|
849
820
|
if (completedRequestIds.has(request.requestId)) {
|
|
@@ -889,9 +860,7 @@ function processClientToolRequests({
|
|
|
889
860
|
});
|
|
890
861
|
session.finishClientToolCall(request.requestId, { responseSent: true });
|
|
891
862
|
} catch (error) {
|
|
892
|
-
session.finishClientToolCall(request.requestId, {
|
|
893
|
-
responseSent: false
|
|
894
|
-
});
|
|
863
|
+
session.finishClientToolCall(request.requestId, { responseSent: false });
|
|
895
864
|
updateCall(clientToolCallKey(session.threadPath, request.requestId), {
|
|
896
865
|
status: "failed",
|
|
897
866
|
output: new import_meshagent.ErrorContent({ text: describeError(error) })
|
|
@@ -1207,9 +1176,7 @@ function AgentThreadProvider({
|
|
|
1207
1176
|
}, [deferLiveEvents, persistedEvents, session, version]);
|
|
1208
1177
|
const timelineItems = (0, import_react.useMemo)(
|
|
1209
1178
|
() => (timeline?.items ?? []).map((item) => {
|
|
1210
|
-
const override = session == null ? void 0 : clientToolCallOverrides.get(
|
|
1211
|
-
clientToolCallKey(session.threadPath, item.clientToolRequestId ?? item.id)
|
|
1212
|
-
);
|
|
1179
|
+
const override = session == null ? void 0 : clientToolCallOverrides.get(clientToolCallKey(session.threadPath, item.clientToolRequestId ?? item.id));
|
|
1213
1180
|
if (override == null || item.kind !== "tool_call" || item.state === "completed" || item.state === "failed") {
|
|
1214
1181
|
return item;
|
|
1215
1182
|
}
|
|
@@ -1438,8 +1405,7 @@ function useAgentThreadStatus() {
|
|
|
1438
1405
|
function AgentThreadFeed({
|
|
1439
1406
|
renderAfterItem,
|
|
1440
1407
|
renderUnanchored,
|
|
1441
|
-
showStatusIndicator = true
|
|
1442
|
-
userDisplayName
|
|
1408
|
+
showStatusIndicator = true
|
|
1443
1409
|
} = {}) {
|
|
1444
1410
|
const {
|
|
1445
1411
|
room,
|
|
@@ -1478,7 +1444,7 @@ function AgentThreadFeed({
|
|
|
1478
1444
|
"div",
|
|
1479
1445
|
{
|
|
1480
1446
|
className: (0, import_utils.cn)(
|
|
1481
|
-
"
|
|
1447
|
+
"mx-auto w-full max-w-[912px] px-1 py-3",
|
|
1482
1448
|
item.id === firstRenderedItemId ? "pt-6" : null,
|
|
1483
1449
|
item.id === lastRenderedItemId ? showStatusIndicator && statusText ? "pb-24" : "pb-6" : null
|
|
1484
1450
|
),
|
|
@@ -1489,7 +1455,6 @@ function AgentThreadFeed({
|
|
|
1489
1455
|
{
|
|
1490
1456
|
room,
|
|
1491
1457
|
message: item,
|
|
1492
|
-
userDisplayName,
|
|
1493
1458
|
previous: previousItemById.get(item.id) ?? null,
|
|
1494
1459
|
localParticipantName,
|
|
1495
1460
|
agentName,
|
|
@@ -83,16 +83,13 @@ 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
|
-
|
|
93
|
-
},
|
|
94
|
-
[controlledValue, onTextChange, onValueChange]
|
|
95
|
-
);
|
|
86
|
+
const setValue = (0, import_react.useCallback)((nextValue) => {
|
|
87
|
+
if (controlledValue === void 0) {
|
|
88
|
+
setUncontrolledValue(nextValue);
|
|
89
|
+
}
|
|
90
|
+
onValueChange?.(nextValue);
|
|
91
|
+
onTextChange?.(nextValue);
|
|
92
|
+
}, [controlledValue, onTextChange, onValueChange]);
|
|
96
93
|
useAutoResizingTextarea(textareaRef, value);
|
|
97
94
|
const allAttachmentsUploaded = (0, import_react.useMemo)(
|
|
98
95
|
() => attachments.every((attachment) => attachment.status === import_file_attachment.UploadStatus.Completed),
|
|
@@ -105,108 +102,81 @@ function ChatInput({
|
|
|
105
102
|
if (!canSend) {
|
|
106
103
|
return;
|
|
107
104
|
}
|
|
108
|
-
void onSubmit(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
})
|
|
114
|
-
);
|
|
105
|
+
void onSubmit(new import_chat_message.ChatMessage({
|
|
106
|
+
id: (0, import_uuid.v4)(),
|
|
107
|
+
text: trimmed,
|
|
108
|
+
attachments: attachments.map((attachment) => attachment.path)
|
|
109
|
+
}));
|
|
115
110
|
if (!clearOnSubmit) {
|
|
116
111
|
return;
|
|
117
112
|
}
|
|
118
113
|
setValue("");
|
|
119
114
|
setAttachments([]);
|
|
120
115
|
}, [attachments, canSend, clearOnSubmit, onSubmit, setAttachments, setValue, value]);
|
|
121
|
-
const handleKeyDown = (0, import_react.useCallback)(
|
|
122
|
-
(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
onCancelRequest?.();
|
|
130
|
-
return;
|
|
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) {
|
|
116
|
+
const handleKeyDown = (0, import_react.useCallback)((event) => {
|
|
117
|
+
if (disabled) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
if (showCancelButton) {
|
|
123
|
+
onCancelRequest?.();
|
|
148
124
|
return;
|
|
149
125
|
}
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
)
|
|
126
|
+
handleSend();
|
|
127
|
+
}
|
|
128
|
+
}, [disabled, handleSend, onCancelRequest, showCancelButton]);
|
|
129
|
+
const handleChange = (0, import_react.useCallback)((event) => {
|
|
130
|
+
const nextValue = event.currentTarget.value;
|
|
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]);
|
|
154
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;
|
|
155
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
156
|
-
"
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
|
177
|
+
}
|
|
163
178
|
),
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
-
);
|
|
179
|
+
trailingButton
|
|
180
|
+
] })
|
|
181
|
+
] });
|
|
212
182
|
}
|
|
@@ -642,23 +642,14 @@ class AgentUsageSnapshot {
|
|
|
642
642
|
this.usage = Object.freeze({ ...params.usage });
|
|
643
643
|
}
|
|
644
644
|
static fromMessage(message) {
|
|
645
|
-
|
|
646
|
-
return AgentUsageSnapshot.fromPayload(message.toJson());
|
|
647
|
-
}
|
|
648
|
-
return null;
|
|
645
|
+
return isTypedMessage(message, import_meshagent_agents.AgentUsageUpdated) ? AgentUsageSnapshot.fromPayload(message.toJson()) : null;
|
|
649
646
|
}
|
|
650
647
|
static fromPayload(payload) {
|
|
651
|
-
if (payload.type !== "meshagent.agent.usage.updated" || typeof payload.thread_id !== "string" || payload.thread_id.trim() === "")
|
|
652
|
-
|
|
653
|
-
}
|
|
654
|
-
if (payload.context_window == null || typeof payload.context_window !== "object") {
|
|
655
|
-
return null;
|
|
656
|
-
}
|
|
648
|
+
if (payload.type !== "meshagent.agent.usage.updated" || typeof payload.thread_id !== "string" || payload.thread_id.trim() === "") return null;
|
|
649
|
+
if (payload.context_window == null || typeof payload.context_window !== "object") return null;
|
|
657
650
|
const context = payload.context_window;
|
|
658
651
|
const usedTokens = integerNumber(context.used_tokens);
|
|
659
|
-
if (usedTokens == null)
|
|
660
|
-
return null;
|
|
661
|
-
}
|
|
652
|
+
if (usedTokens == null) return null;
|
|
662
653
|
const rawUsage = payload.usage != null && typeof payload.usage === "object" ? payload.usage : {};
|
|
663
654
|
return new AgentUsageSnapshot({
|
|
664
655
|
threadPath: payload.thread_id.trim(),
|
|
@@ -41,11 +41,7 @@ function ComposerActionButton({
|
|
|
41
41
|
type: "button",
|
|
42
42
|
size: "icon",
|
|
43
43
|
variant: "ghost",
|
|
44
|
-
className: (0, import_utils.cn)(
|
|
45
|
-
"chat-composer__action relative size-9 rounded-full",
|
|
46
|
-
disabled ? "opacity-55" : "cursor-pointer",
|
|
47
|
-
className
|
|
48
|
-
),
|
|
44
|
+
className: (0, import_utils.cn)("relative size-9 rounded-full", disabled ? "opacity-55" : "cursor-pointer", className),
|
|
49
45
|
disabled,
|
|
50
46
|
onClick,
|
|
51
47
|
title: disabled ? "Cancelling" : "Stop",
|
|
@@ -61,11 +57,7 @@ function ComposerActionButton({
|
|
|
61
57
|
{
|
|
62
58
|
type: "button",
|
|
63
59
|
size: "icon",
|
|
64
|
-
className: (0, import_utils.cn)(
|
|
65
|
-
"chat-composer__action size-9 rounded-full shadow-xs",
|
|
66
|
-
!disabled && "cursor-pointer",
|
|
67
|
-
className
|
|
68
|
-
),
|
|
60
|
+
className: (0, import_utils.cn)("size-9 rounded-full shadow-xs", !disabled && "cursor-pointer", className),
|
|
69
61
|
disabled,
|
|
70
62
|
onClick,
|
|
71
63
|
title,
|