@meshagent/meshagent-tailwind 0.47.0 → 0.48.0
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 +15 -0
- package/dist/cjs/chat/agent-thread.d.ts +24 -24
- package/dist/cjs/chat/agent-thread.js +575 -808
- package/dist/cjs/chat/chat-bot-view.d.ts +18 -6
- package/dist/cjs/chat/chat-bot-view.js +29 -7
- package/dist/cjs/chat/chat-feed-widget-view.d.ts +7 -0
- package/dist/cjs/chat/chat-feed-widget-view.js +50 -0
- package/dist/cjs/chat/chat-feed-widget.d.ts +16 -0
- package/dist/cjs/chat/chat-feed-widget.js +51 -0
- package/dist/cjs/chat/chat-hooks.d.ts +2 -2
- package/dist/cjs/chat/chat-input.d.ts +3 -3
- package/dist/cjs/chat/chat-input.js +9 -4
- package/dist/cjs/chat/chat-scroller.d.ts +21 -0
- package/dist/cjs/chat/chat-scroller.js +139 -0
- package/dist/cjs/chat/chat-thread-timeline.d.ts +66 -0
- package/dist/cjs/chat/chat-thread-timeline.js +595 -0
- package/dist/cjs/chat/dataset-agent-thread.d.ts +16 -4
- package/dist/cjs/chat/dataset-agent-thread.js +112 -292
- package/dist/cjs/chat/multi-thread-view.d.ts +8 -3
- package/dist/cjs/chat/multi-thread-view.js +10 -2
- package/dist/cjs/chat/new-chat-thread.d.ts +8 -3
- package/dist/cjs/chat/new-chat-thread.js +63 -24
- package/dist/cjs/chat/thread-view.d.ts +18 -5
- package/dist/cjs/chat/thread-view.js +67 -9
- package/dist/cjs/chat/use-chat-virtualizer.d.ts +47 -0
- package/dist/cjs/chat/use-chat-virtualizer.js +336 -0
- package/dist/cjs/chat/virtualization.d.ts +44 -0
- package/dist/cjs/chat/virtualization.js +143 -0
- package/dist/cjs/components/ui/button.d.ts +2 -2
- package/dist/cjs/components/ui/dialog.d.ts +1 -1
- package/dist/cjs/components/ui/dialog.js +11 -1
- package/dist/cjs/components/ui/portal-container.d.ts +7 -0
- package/dist/cjs/components/ui/portal-container.js +46 -0
- package/dist/cjs/file-preview/file-preview.js +1 -1
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/meetings/meeting-scope.d.ts +2 -1
- package/dist/cjs/meetings/meeting-scope.js +1 -0
- package/dist/cjs/react-syntax-highlighter.d.js +1 -0
- package/dist/esm/chat/agent-thread.d.ts +24 -24
- package/dist/esm/chat/agent-thread.js +574 -838
- package/dist/esm/chat/chat-bot-view.d.ts +18 -6
- package/dist/esm/chat/chat-bot-view.js +29 -7
- package/dist/esm/chat/chat-feed-widget-view.d.ts +7 -0
- package/dist/esm/chat/chat-feed-widget-view.js +30 -0
- package/dist/esm/chat/chat-feed-widget.d.ts +16 -0
- package/dist/esm/chat/chat-feed-widget.js +31 -0
- package/dist/esm/chat/chat-hooks.d.ts +2 -2
- package/dist/esm/chat/chat-input.d.ts +3 -3
- package/dist/esm/chat/chat-input.js +9 -4
- package/dist/esm/chat/chat-scroller.d.ts +21 -0
- package/dist/esm/chat/chat-scroller.js +122 -0
- package/dist/esm/chat/chat-thread-timeline.d.ts +66 -0
- package/dist/esm/chat/chat-thread-timeline.js +605 -0
- package/dist/esm/chat/dataset-agent-thread.d.ts +16 -4
- package/dist/esm/chat/dataset-agent-thread.js +114 -307
- package/dist/esm/chat/multi-thread-view.d.ts +8 -3
- package/dist/esm/chat/multi-thread-view.js +10 -2
- package/dist/esm/chat/new-chat-thread.d.ts +8 -3
- package/dist/esm/chat/new-chat-thread.js +64 -25
- package/dist/esm/chat/thread-view.d.ts +18 -5
- package/dist/esm/chat/thread-view.js +67 -9
- package/dist/esm/chat/use-chat-virtualizer.d.ts +47 -0
- package/dist/esm/chat/use-chat-virtualizer.js +331 -0
- package/dist/esm/chat/virtualization.d.ts +44 -0
- package/dist/esm/chat/virtualization.js +123 -0
- package/dist/esm/components/ui/button.d.ts +2 -2
- package/dist/esm/components/ui/dialog.d.ts +1 -1
- package/dist/esm/components/ui/dialog.js +11 -1
- package/dist/esm/components/ui/portal-container.d.ts +7 -0
- package/dist/esm/components/ui/portal-container.js +16 -0
- package/dist/esm/file-preview/file-preview.js +1 -1
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/meetings/meeting-scope.d.ts +2 -1
- package/dist/esm/meetings/meeting-scope.js +1 -0
- package/dist/esm/react-syntax-highlighter.d.js +0 -0
- package/dist/index.css +1 -1
- package/package.json +6 -5
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
2
|
import type { Participant, RoomClient } from "@meshagent/meshagent";
|
|
3
|
-
import type { BaseChatClient, ClientToolkitDescription } from "@meshagent/meshagent-agents";
|
|
4
|
-
import type { AgentToolChoice } from "./agent-thread";
|
|
5
|
-
import type { DatasetThreadRowsLoader } from "./dataset-agent-thread";
|
|
6
|
-
import {
|
|
7
|
-
|
|
3
|
+
import type { AgentMessage, AgentMessageEvent, BaseChatClient, ClientToolkitDescription } from "@meshagent/meshagent-agents";
|
|
4
|
+
import type { AgentToolChoice } from "./agent-thread.js";
|
|
5
|
+
import type { DatasetThreadRowsLoader } from "./dataset-agent-thread.js";
|
|
6
|
+
import type { ChatFeedWidget } from "./chat-feed-widget.js";
|
|
7
|
+
import { ChatThreadDisplayMode } from "./conversation-descriptor.js";
|
|
8
|
+
export { ChatThreadDisplayMode, chatDocumentPath, resolvedThreadListPath, } from "./conversation-descriptor.js";
|
|
8
9
|
export interface ChatBotViewProps {
|
|
9
10
|
room: RoomClient;
|
|
10
11
|
chatClient?: BaseChatClient;
|
|
@@ -33,9 +34,20 @@ export interface ChatBotViewProps {
|
|
|
33
34
|
threadListWidth?: number;
|
|
34
35
|
threadListCollapsedHeight?: number;
|
|
35
36
|
clientToolkits?: ClientToolkitDescription[];
|
|
37
|
+
chatFeedWidgets?: ChatFeedWidget[];
|
|
36
38
|
toolChoice?: AgentToolChoice;
|
|
37
39
|
collapseMessages?: boolean;
|
|
40
|
+
enableFileUpload?: boolean;
|
|
38
41
|
threadSource?: "session" | "dataset";
|
|
39
42
|
rowsLoader?: DatasetThreadRowsLoader;
|
|
43
|
+
persistedEvents?: readonly AgentMessageEvent[];
|
|
44
|
+
loadThread?: boolean;
|
|
45
|
+
injectPersistedEvents?: boolean;
|
|
46
|
+
composerDisabled?: boolean;
|
|
47
|
+
closeThreadOnUnmount?: boolean;
|
|
48
|
+
onPersistedEventsInjectionStarted?: () => void;
|
|
49
|
+
onPersistedEventsInjected?: (error: unknown | null) => void;
|
|
50
|
+
onEventsChanged?: (threadId: string, events: readonly AgentMessageEvent[], latestMessage: AgentMessage | null) => void;
|
|
51
|
+
onThreadStarted?: (threadId: string, events: readonly AgentMessageEvent[]) => Promise<void> | void;
|
|
40
52
|
}
|
|
41
|
-
export declare function ChatBotView({ room, chatClient, disposeChatClient, path, documentPath, agentName, threadDisplayMode, threadDir, toolkit, tool, centerComposer, emptyStateTitle, emptyStateDescription, startNewThreadTitle, startNewThreadDescription, selectedThreadPath, selectedThreadDisplayName, onSelectedThreadPathChanged, onSelectedThreadResolved, onThreadResolved, newThreadResetVersion, showThreadList, threadListWidth, threadListCollapsedHeight, clientToolkits, toolChoice, collapseMessages, threadSource, rowsLoader, }: ChatBotViewProps): ReactElement;
|
|
53
|
+
export declare function ChatBotView({ room, chatClient, disposeChatClient, path, documentPath, agentName, threadDisplayMode, threadDir, toolkit, tool, centerComposer, emptyStateTitle, emptyStateDescription, startNewThreadTitle, startNewThreadDescription, selectedThreadPath, selectedThreadDisplayName, onSelectedThreadPathChanged, onSelectedThreadResolved, onThreadResolved, newThreadResetVersion, showThreadList, threadListWidth, threadListCollapsedHeight, clientToolkits, chatFeedWidgets, toolChoice, collapseMessages, enableFileUpload, threadSource, rowsLoader, persistedEvents, loadThread, injectPersistedEvents, composerDisabled, closeThreadOnUnmount, onPersistedEventsInjectionStarted, onPersistedEventsInjected, onEventsChanged, onThreadStarted, }: ChatBotViewProps): ReactElement;
|
|
@@ -27,11 +27,11 @@ module.exports = __toCommonJS(chat_bot_view_exports);
|
|
|
27
27
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
28
|
var import_react = require("react");
|
|
29
29
|
var import_meshagent_agents = require("@meshagent/meshagent-agents");
|
|
30
|
-
var import_conversation_descriptor = require("./conversation-descriptor");
|
|
31
|
-
var import_utils = require("../lib/utils");
|
|
32
|
-
var import_thread_list_view = require("./thread-list-view");
|
|
33
|
-
var import_thread_view = require("./thread-view");
|
|
34
|
-
var import_conversation_descriptor2 = require("./conversation-descriptor");
|
|
30
|
+
var import_conversation_descriptor = require("./conversation-descriptor.js");
|
|
31
|
+
var import_utils = require("../lib/utils.js");
|
|
32
|
+
var import_thread_list_view = require("./thread-list-view.js");
|
|
33
|
+
var import_thread_view = require("./thread-view.js");
|
|
34
|
+
var import_conversation_descriptor2 = require("./conversation-descriptor.js");
|
|
35
35
|
const multiThreadLayoutBreakpointPx = 920;
|
|
36
36
|
function normalizePath(path) {
|
|
37
37
|
const normalized = path?.trim();
|
|
@@ -81,10 +81,21 @@ function ChatBotView({
|
|
|
81
81
|
threadListWidth = 280,
|
|
82
82
|
threadListCollapsedHeight = 220,
|
|
83
83
|
clientToolkits,
|
|
84
|
+
chatFeedWidgets,
|
|
84
85
|
toolChoice,
|
|
85
86
|
collapseMessages = true,
|
|
87
|
+
enableFileUpload = false,
|
|
86
88
|
threadSource = "session",
|
|
87
|
-
rowsLoader
|
|
89
|
+
rowsLoader,
|
|
90
|
+
persistedEvents,
|
|
91
|
+
loadThread = true,
|
|
92
|
+
injectPersistedEvents = false,
|
|
93
|
+
composerDisabled = false,
|
|
94
|
+
closeThreadOnUnmount = false,
|
|
95
|
+
onPersistedEventsInjectionStarted,
|
|
96
|
+
onPersistedEventsInjected,
|
|
97
|
+
onEventsChanged,
|
|
98
|
+
onThreadStarted
|
|
88
99
|
}) {
|
|
89
100
|
const isWideLayout = useIsWideLayout(multiThreadLayoutBreakpointPx);
|
|
90
101
|
const resolvedDocumentPath = (0, import_react.useMemo)(() => normalizePath(documentPath ?? path), [documentPath, path]);
|
|
@@ -171,10 +182,21 @@ function ChatBotView({
|
|
|
171
182
|
onSelectedThreadResolved: emitResolvedThread,
|
|
172
183
|
newThreadResetVersion,
|
|
173
184
|
clientToolkits,
|
|
185
|
+
chatFeedWidgets,
|
|
174
186
|
toolChoice,
|
|
175
187
|
collapseMessages,
|
|
188
|
+
enableFileUpload,
|
|
176
189
|
threadSource,
|
|
177
|
-
rowsLoader
|
|
190
|
+
rowsLoader,
|
|
191
|
+
persistedEvents,
|
|
192
|
+
loadThread,
|
|
193
|
+
injectPersistedEvents,
|
|
194
|
+
composerDisabled,
|
|
195
|
+
closeThreadOnUnmount,
|
|
196
|
+
onPersistedEventsInjectionStarted,
|
|
197
|
+
onPersistedEventsInjected,
|
|
198
|
+
onEventsChanged,
|
|
199
|
+
onThreadStarted
|
|
178
200
|
}
|
|
179
201
|
);
|
|
180
202
|
if (threadDisplayMode !== import_conversation_descriptor.ChatThreadDisplayMode.MultiThreadComposer) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { ChatFeedWidget, ToolCall } from "./chat-feed-widget.js";
|
|
3
|
+
export declare function ChatFeedWidgetView({ widget, toolCall, fallback, }: {
|
|
4
|
+
widget: ChatFeedWidget;
|
|
5
|
+
toolCall: ToolCall;
|
|
6
|
+
fallback: ReactElement;
|
|
7
|
+
}): ReactElement;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var chat_feed_widget_view_exports = {};
|
|
20
|
+
__export(chat_feed_widget_view_exports, {
|
|
21
|
+
ChatFeedWidgetView: () => ChatFeedWidgetView
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(chat_feed_widget_view_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
class ChatFeedWidgetErrorBoundary extends import_react.Component {
|
|
27
|
+
state = { failed: false };
|
|
28
|
+
static getDerivedStateFromError() {
|
|
29
|
+
return { failed: true };
|
|
30
|
+
}
|
|
31
|
+
componentDidCatch(error, info) {
|
|
32
|
+
console.error("ChatFeedWidget render failed", error, info);
|
|
33
|
+
}
|
|
34
|
+
render() {
|
|
35
|
+
return this.state.failed ? this.props.fallback : this.props.children;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function ChatFeedWidgetRenderer({
|
|
39
|
+
widget,
|
|
40
|
+
toolCall
|
|
41
|
+
}) {
|
|
42
|
+
return widget.render(toolCall);
|
|
43
|
+
}
|
|
44
|
+
function ChatFeedWidgetView({
|
|
45
|
+
widget,
|
|
46
|
+
toolCall,
|
|
47
|
+
fallback
|
|
48
|
+
}) {
|
|
49
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChatFeedWidgetErrorBoundary, { fallback, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChatFeedWidgetRenderer, { widget, toolCall }) });
|
|
50
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import { Tool } from "@meshagent/meshagent";
|
|
3
|
+
import type { Content } from "@meshagent/meshagent";
|
|
4
|
+
import { ClientToolkitDescription } from "@meshagent/meshagent-agents";
|
|
5
|
+
import type { AgentThreadSuggestion } from "./agent-thread.js";
|
|
6
|
+
export type ToolCallStatus = "queued" | "in_progress" | "completed" | "failed";
|
|
7
|
+
export interface ToolCall {
|
|
8
|
+
status: ToolCallStatus;
|
|
9
|
+
input: Record<string, unknown>;
|
|
10
|
+
output?: Content;
|
|
11
|
+
}
|
|
12
|
+
export declare abstract class ChatFeedWidget extends Tool {
|
|
13
|
+
abstract render(toolCall: ToolCall): ReactElement;
|
|
14
|
+
getFollowUpSuggestions?(toolCall: ToolCall): readonly AgentThreadSuggestion[];
|
|
15
|
+
}
|
|
16
|
+
export declare function resolveClientToolkitDescriptions(clientToolkits: ClientToolkitDescription[] | undefined, chatFeedWidgets: ChatFeedWidget[] | undefined): ClientToolkitDescription[] | undefined;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var chat_feed_widget_exports = {};
|
|
20
|
+
__export(chat_feed_widget_exports, {
|
|
21
|
+
ChatFeedWidget: () => ChatFeedWidget,
|
|
22
|
+
resolveClientToolkitDescriptions: () => resolveClientToolkitDescriptions
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(chat_feed_widget_exports);
|
|
25
|
+
var import_meshagent = require("@meshagent/meshagent");
|
|
26
|
+
var import_meshagent_agents = require("@meshagent/meshagent-agents");
|
|
27
|
+
class ChatFeedWidget extends import_meshagent.Tool {
|
|
28
|
+
}
|
|
29
|
+
function resolveClientToolkitDescriptions(clientToolkits, chatFeedWidgets) {
|
|
30
|
+
if ((clientToolkits?.length ?? 0) === 0 && (chatFeedWidgets?.length ?? 0) === 0) {
|
|
31
|
+
return void 0;
|
|
32
|
+
}
|
|
33
|
+
const descriptions = [...clientToolkits ?? []];
|
|
34
|
+
const names = new Set(descriptions.map((description) => description.name));
|
|
35
|
+
for (const widget of chatFeedWidgets ?? []) {
|
|
36
|
+
if (names.has(widget.name)) {
|
|
37
|
+
throw new Error(`client tool '${widget.name}' has already been registered`);
|
|
38
|
+
}
|
|
39
|
+
names.add(widget.name);
|
|
40
|
+
descriptions.push(new import_meshagent_agents.ClientToolkitDescription({
|
|
41
|
+
name: widget.name,
|
|
42
|
+
title: widget.title,
|
|
43
|
+
description: widget.description,
|
|
44
|
+
inputSchema: widget.inputSchema ?? {
|
|
45
|
+
type: "object",
|
|
46
|
+
additionalProperties: true
|
|
47
|
+
}
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
return descriptions;
|
|
51
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Element, MeshDocument, Participant, RemoteParticipant, RoomClient } from "@meshagent/meshagent";
|
|
2
|
-
import { ChatMessage } from "./chat-message";
|
|
3
|
-
import type { FileUpload } from "./file-attachment";
|
|
2
|
+
import { ChatMessage } from "./chat-message.js";
|
|
3
|
+
import type { FileUpload } from "./file-attachment.js";
|
|
4
4
|
export interface UseChatThreadProps {
|
|
5
5
|
room: RoomClient;
|
|
6
6
|
path: string;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
2
|
import { ChatMessage } from "./chat-message.js";
|
|
3
3
|
import { type FileUpload } from "./file-attachment.js";
|
|
4
|
-
interface ChatInputProps {
|
|
4
|
+
export interface ChatInputProps {
|
|
5
5
|
onSubmit: (message: ChatMessage) => void | Promise<void>;
|
|
6
6
|
onFilesSelected: (files: File[]) => void;
|
|
7
7
|
attachments: FileUpload[];
|
|
8
8
|
setAttachments: (attachments: FileUpload[]) => void;
|
|
9
|
+
enableFileUpload?: boolean;
|
|
9
10
|
onTextChange?: (text: string) => void;
|
|
10
11
|
onCancelRequest?: () => void;
|
|
11
12
|
showCancelButton?: boolean;
|
|
@@ -17,5 +18,4 @@ interface ChatInputProps {
|
|
|
17
18
|
defaultValue?: string;
|
|
18
19
|
onValueChange?: (value: string) => void;
|
|
19
20
|
}
|
|
20
|
-
export declare function ChatInput({ onSubmit, onFilesSelected, attachments, setAttachments, onTextChange, onCancelRequest, showCancelButton, placeholder, disabled, clearOnSubmit, autoFocus, value: controlledValue, defaultValue, onValueChange, }: ChatInputProps): ReactElement;
|
|
21
|
-
export {};
|
|
21
|
+
export declare function ChatInput({ onSubmit, onFilesSelected, attachments, setAttachments, enableFileUpload, onTextChange, onCancelRequest, showCancelButton, placeholder, disabled, clearOnSubmit, autoFocus, value: controlledValue, defaultValue, onValueChange, }: ChatInputProps): ReactElement;
|
|
@@ -58,12 +58,16 @@ function useAutoResizingTextarea(textareaRef, value) {
|
|
|
58
58
|
}
|
|
59
59
|
if (value === "") {
|
|
60
60
|
element.style.height = `${MIN_TEXTAREA_HEIGHT}px`;
|
|
61
|
+
element.style.overflowY = "hidden";
|
|
61
62
|
} else {
|
|
62
63
|
element.style.height = "0px";
|
|
64
|
+
element.style.overflowY = "hidden";
|
|
65
|
+
const contentHeight = element.scrollHeight;
|
|
63
66
|
element.style.height = `${Math.max(
|
|
64
67
|
MIN_TEXTAREA_HEIGHT,
|
|
65
|
-
Math.min(
|
|
68
|
+
Math.min(contentHeight, MAX_TEXTAREA_HEIGHT)
|
|
66
69
|
)}px`;
|
|
70
|
+
element.style.overflowY = contentHeight > MAX_TEXTAREA_HEIGHT ? "auto" : "hidden";
|
|
67
71
|
}
|
|
68
72
|
}, [textareaRef, value]);
|
|
69
73
|
}
|
|
@@ -108,6 +112,7 @@ function ChatInput({
|
|
|
108
112
|
onFilesSelected,
|
|
109
113
|
attachments,
|
|
110
114
|
setAttachments,
|
|
115
|
+
enableFileUpload = false,
|
|
111
116
|
onTextChange,
|
|
112
117
|
onCancelRequest,
|
|
113
118
|
showCancelButton = false,
|
|
@@ -176,7 +181,7 @@ function ChatInput({
|
|
|
176
181
|
}
|
|
177
182
|
setAttachments(attachments.filter((currentAttachment) => currentAttachment !== attachment));
|
|
178
183
|
}, [attachments, disabled, setAttachments]);
|
|
179
|
-
const trailingButton = showCancelButton ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ComposerActionButton, { onClick: onCancelRequest, showCancelButton: true }) :
|
|
184
|
+
const trailingButton = showCancelButton ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ComposerActionButton, { onClick: onCancelRequest, showCancelButton: true }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ComposerActionButton, { onClick: handleSend, disabled: !canSend });
|
|
180
185
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "px-4 pt-2", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mx-auto flex w-full max-w-4xl flex-col gap-2 rounded-md border border-input/70 bg-background px-2 py-1 shadow-xs focus-within:border-primary focus-within:[outline:1px_solid_var(--color-primary)]", children: [
|
|
181
186
|
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)(
|
|
182
187
|
import_upload_pill.UploadPill,
|
|
@@ -186,8 +191,8 @@ function ChatInput({
|
|
|
186
191
|
},
|
|
187
192
|
`${attachment.path}-${index}`
|
|
188
193
|
)) }) : null,
|
|
189
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
190
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_file_uploader.FileUploader, { onFilesSelected, disabled }),
|
|
194
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_utils.cn)("flex items-center gap-2", !enableFileUpload && "pl-1"), children: [
|
|
195
|
+
enableFileUpload ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_file_uploader.FileUploader, { onFilesSelected, disabled }) : null,
|
|
191
196
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
192
197
|
"textarea",
|
|
193
198
|
{
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from "react";
|
|
2
|
+
export type ChatMessageBase = {
|
|
3
|
+
id: string;
|
|
4
|
+
authorId?: string;
|
|
5
|
+
};
|
|
6
|
+
export type RenderMessageMeta = {
|
|
7
|
+
isCurrentUser: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type ChatScrollerProps<TMessage extends ChatMessageBase> = {
|
|
10
|
+
messages: readonly TMessage[];
|
|
11
|
+
currentUserId: string;
|
|
12
|
+
renderMessage: (message: TMessage, meta: RenderMessageMeta) => ReactNode;
|
|
13
|
+
pageSize?: number;
|
|
14
|
+
overscanPages?: number;
|
|
15
|
+
bottomThresholdPx?: number;
|
|
16
|
+
className?: string;
|
|
17
|
+
style?: CSSProperties;
|
|
18
|
+
getMessageId?: (message: TMessage) => string;
|
|
19
|
+
getMessageAuthorId?: (message: TMessage) => string | undefined;
|
|
20
|
+
};
|
|
21
|
+
export declare function ChatScroller<TMessage extends ChatMessageBase>({ messages, currentUserId, renderMessage, pageSize, overscanPages, bottomThresholdPx, className, style, getMessageId, getMessageAuthorId, }: ChatScrollerProps<TMessage>): import("react").JSX.Element;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var chat_scroller_exports = {};
|
|
20
|
+
__export(chat_scroller_exports, {
|
|
21
|
+
ChatScroller: () => ChatScroller
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(chat_scroller_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var import_virtualization = require("./virtualization.js");
|
|
27
|
+
var import_use_chat_virtualizer = require("./use-chat-virtualizer.js");
|
|
28
|
+
function MeasuredPage({
|
|
29
|
+
pageIndex,
|
|
30
|
+
messages,
|
|
31
|
+
currentUserId,
|
|
32
|
+
renderMessage,
|
|
33
|
+
getMessageId,
|
|
34
|
+
getMessageAuthorId,
|
|
35
|
+
onHeightChange
|
|
36
|
+
}) {
|
|
37
|
+
const pageRef = (0, import_react.useRef)(null);
|
|
38
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
39
|
+
const pageElement = pageRef.current;
|
|
40
|
+
if (!pageElement) {
|
|
41
|
+
return void 0;
|
|
42
|
+
}
|
|
43
|
+
const reportHeight = () => {
|
|
44
|
+
const height = pageElement.getBoundingClientRect().height;
|
|
45
|
+
onHeightChange(pageIndex, height);
|
|
46
|
+
};
|
|
47
|
+
reportHeight();
|
|
48
|
+
const resizeObserver = new ResizeObserver(reportHeight);
|
|
49
|
+
resizeObserver.observe(pageElement);
|
|
50
|
+
return () => {
|
|
51
|
+
resizeObserver.disconnect();
|
|
52
|
+
};
|
|
53
|
+
}, [onHeightChange, pageIndex]);
|
|
54
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
55
|
+
"div",
|
|
56
|
+
{
|
|
57
|
+
className: "chat-scroll__page flex flex-col gap-2 px-3 py-1",
|
|
58
|
+
"data-page-index": pageIndex,
|
|
59
|
+
ref: pageRef,
|
|
60
|
+
children: messages.map((message) => {
|
|
61
|
+
const isCurrentUser = getMessageAuthorId(message) === currentUserId;
|
|
62
|
+
const messageClassName = isCurrentUser ? "chat-scroll__message chat-scroll__message--own flex w-full min-w-0 justify-end" : "chat-scroll__message chat-scroll__message--other flex w-full min-w-0 justify-start";
|
|
63
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
64
|
+
"div",
|
|
65
|
+
{
|
|
66
|
+
className: messageClassName,
|
|
67
|
+
"data-message-id": getMessageId(message),
|
|
68
|
+
children: renderMessage(message, { isCurrentUser })
|
|
69
|
+
},
|
|
70
|
+
getMessageId(message)
|
|
71
|
+
);
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
function ChatScroller({
|
|
77
|
+
messages,
|
|
78
|
+
currentUserId,
|
|
79
|
+
renderMessage,
|
|
80
|
+
pageSize = import_virtualization.DEFAULT_PAGE_SIZE,
|
|
81
|
+
overscanPages = import_virtualization.DEFAULT_OVERSCAN_PAGES,
|
|
82
|
+
bottomThresholdPx = 48,
|
|
83
|
+
className,
|
|
84
|
+
style,
|
|
85
|
+
getMessageId = (message) => message.id,
|
|
86
|
+
getMessageAuthorId = (message) => message.authorId
|
|
87
|
+
}) {
|
|
88
|
+
const {
|
|
89
|
+
scrollRef,
|
|
90
|
+
visiblePages,
|
|
91
|
+
spacerHeight,
|
|
92
|
+
windowBottom,
|
|
93
|
+
handleScroll,
|
|
94
|
+
handlePageHeightChange
|
|
95
|
+
} = (0, import_use_chat_virtualizer.useChatVirtualizer)({
|
|
96
|
+
messages,
|
|
97
|
+
pageSize,
|
|
98
|
+
overscanPages,
|
|
99
|
+
bottomThresholdPx,
|
|
100
|
+
getMessageId
|
|
101
|
+
});
|
|
102
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
103
|
+
"div",
|
|
104
|
+
{
|
|
105
|
+
className: className ? "chat-scroll relative box-border h-full min-h-0 overflow-y-auto overscroll-contain [overflow-anchor:none] " + className : "chat-scroll relative box-border h-full min-h-0 overflow-y-auto overscroll-contain [overflow-anchor:none]",
|
|
106
|
+
onScroll: handleScroll,
|
|
107
|
+
ref: scrollRef,
|
|
108
|
+
style,
|
|
109
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
110
|
+
"div",
|
|
111
|
+
{
|
|
112
|
+
"aria-hidden": visiblePages.length === 0 ? "true" : void 0,
|
|
113
|
+
className: "chat-scroll__spacer relative min-h-full",
|
|
114
|
+
style: { height: spacerHeight },
|
|
115
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
116
|
+
"div",
|
|
117
|
+
{
|
|
118
|
+
className: "chat-scroll__window absolute right-0 left-0 flex flex-col",
|
|
119
|
+
style: { bottom: windowBottom },
|
|
120
|
+
children: visiblePages.map((page) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
121
|
+
MeasuredPage,
|
|
122
|
+
{
|
|
123
|
+
currentUserId,
|
|
124
|
+
getMessageAuthorId,
|
|
125
|
+
getMessageId,
|
|
126
|
+
messages: page.items,
|
|
127
|
+
onHeightChange: handlePageHeightChange,
|
|
128
|
+
pageIndex: page.index,
|
|
129
|
+
renderMessage
|
|
130
|
+
},
|
|
131
|
+
page.index
|
|
132
|
+
))
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Content } from "@meshagent/meshagent";
|
|
2
|
+
import { type AgentMessage, AgentMessageEvent, PendingAgentInput } from "@meshagent/meshagent-agents";
|
|
3
|
+
export type ChatThreadItemRole = "user" | "agent";
|
|
4
|
+
export type ChatThreadItemKind = "message" | "reasoning" | "tool_call" | "image_generation" | "event" | "error";
|
|
5
|
+
export interface ChatThreadGeneratedImage {
|
|
6
|
+
uri?: string;
|
|
7
|
+
status?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ChatThreadItem {
|
|
10
|
+
id: string;
|
|
11
|
+
kind: ChatThreadItemKind;
|
|
12
|
+
role: ChatThreadItemRole;
|
|
13
|
+
text: string;
|
|
14
|
+
attachments: string[];
|
|
15
|
+
createdAt: Date;
|
|
16
|
+
authorName?: string;
|
|
17
|
+
phase?: string;
|
|
18
|
+
turnId?: string;
|
|
19
|
+
toolkit?: string;
|
|
20
|
+
tool?: string;
|
|
21
|
+
command?: string;
|
|
22
|
+
argumentsText?: string;
|
|
23
|
+
input?: Record<string, unknown>;
|
|
24
|
+
output?: Content;
|
|
25
|
+
logs?: string[];
|
|
26
|
+
result?: string;
|
|
27
|
+
stdout?: string;
|
|
28
|
+
stderr?: string;
|
|
29
|
+
state?: string;
|
|
30
|
+
failed?: boolean;
|
|
31
|
+
image?: {
|
|
32
|
+
uri?: string;
|
|
33
|
+
status?: string;
|
|
34
|
+
statusDetail?: string;
|
|
35
|
+
images?: ChatThreadGeneratedImage[];
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export interface ChatThreadTimeline {
|
|
39
|
+
readonly items: readonly ChatThreadItem[];
|
|
40
|
+
readonly usage: AgentUsageSnapshot | null;
|
|
41
|
+
}
|
|
42
|
+
export declare function buildChatThreadTimeline(events: readonly AgentMessageEvent[], pendingInputs?: readonly PendingAgentInput[]): ChatThreadTimeline;
|
|
43
|
+
export declare function buildMergedChatThreadTimeline(persistedEvents: readonly AgentMessageEvent[], liveEvents: readonly AgentMessageEvent[], pendingInputs?: readonly PendingAgentInput[]): ChatThreadTimeline;
|
|
44
|
+
export declare class AgentUsageSnapshot {
|
|
45
|
+
readonly threadPath: string;
|
|
46
|
+
readonly turnId?: string;
|
|
47
|
+
readonly contextUsedTokens: number;
|
|
48
|
+
readonly contextTotalTokens?: number;
|
|
49
|
+
readonly compactionMode?: string;
|
|
50
|
+
readonly compactionThreshold?: number;
|
|
51
|
+
readonly totalTokens?: number;
|
|
52
|
+
readonly usage: Record<string, number>;
|
|
53
|
+
constructor(params: {
|
|
54
|
+
threadPath: string;
|
|
55
|
+
turnId?: string;
|
|
56
|
+
contextUsedTokens: number;
|
|
57
|
+
contextTotalTokens?: number;
|
|
58
|
+
compactionMode?: string;
|
|
59
|
+
compactionThreshold?: number;
|
|
60
|
+
totalTokens?: number;
|
|
61
|
+
usage: Record<string, number>;
|
|
62
|
+
});
|
|
63
|
+
static fromMessage(message: AgentMessage): AgentUsageSnapshot | null;
|
|
64
|
+
static fromPayload(payload: Record<string, unknown>): AgentUsageSnapshot | null;
|
|
65
|
+
}
|
|
66
|
+
export declare function shouldReplaceAgentUsageSnapshot(current: AgentUsageSnapshot | null | undefined, next: AgentUsageSnapshot): boolean;
|