@apteva/apteva-kit 0.1.32 → 0.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.js +31 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
|
|
6
6
|
// src/components/Chat/Chat.tsx
|
|
7
|
-
import { useState as useState3, useEffect as useEffect4, useRef as useRef5, useMemo as useMemo2 } from "react";
|
|
7
|
+
import { useState as useState3, useEffect as useEffect4, useRef as useRef5, useMemo as useMemo2, forwardRef, useImperativeHandle } from "react";
|
|
8
8
|
|
|
9
9
|
// src/components/Chat/MessageList.tsx
|
|
10
10
|
import { useEffect as useEffect3, useRef as useRef2 } from "react";
|
|
@@ -2256,7 +2256,7 @@ var aptevaClient = new AptevaClient();
|
|
|
2256
2256
|
|
|
2257
2257
|
// src/components/Chat/Chat.tsx
|
|
2258
2258
|
import { Fragment as Fragment4, jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2259
|
-
|
|
2259
|
+
var Chat = forwardRef(function Chat2({
|
|
2260
2260
|
agentId,
|
|
2261
2261
|
threadId,
|
|
2262
2262
|
initialMessages = [],
|
|
@@ -2299,7 +2299,7 @@ function Chat({
|
|
|
2299
2299
|
compactWidgetContext = false,
|
|
2300
2300
|
onWidgetRender,
|
|
2301
2301
|
className
|
|
2302
|
-
}) {
|
|
2302
|
+
}, ref) {
|
|
2303
2303
|
const [messages, setMessages] = useState3(initialMessages);
|
|
2304
2304
|
const [isLoading, setIsLoading] = useState3(false);
|
|
2305
2305
|
const [currentThreadId, setCurrentThreadId] = useState3(threadId || null);
|
|
@@ -2318,6 +2318,21 @@ function Chat({
|
|
|
2318
2318
|
const [internalPlanMode, setInternalPlanMode] = useState3(planMode);
|
|
2319
2319
|
const [showSettingsMenu, setShowSettingsMenu] = useState3(false);
|
|
2320
2320
|
const fileInputRef = useRef5(null);
|
|
2321
|
+
const handleSendMessageRef = useRef5(null);
|
|
2322
|
+
useImperativeHandle(ref, () => ({
|
|
2323
|
+
sendMessage: async (text) => {
|
|
2324
|
+
if (handleSendMessageRef.current) {
|
|
2325
|
+
await handleSendMessageRef.current(text);
|
|
2326
|
+
}
|
|
2327
|
+
},
|
|
2328
|
+
sendSystemMessage: async (text) => {
|
|
2329
|
+
if (handleSendMessageRef.current) {
|
|
2330
|
+
await handleSendMessageRef.current(text, void 0, true);
|
|
2331
|
+
}
|
|
2332
|
+
},
|
|
2333
|
+
getMessages: () => messages,
|
|
2334
|
+
clearMessages: () => setMessages([])
|
|
2335
|
+
}), [messages]);
|
|
2321
2336
|
const effectiveContext = useMemo2(() => {
|
|
2322
2337
|
if (!enableWidgets) return context;
|
|
2323
2338
|
const widgetContext = compactWidgetContext ? generateCompactWidgetContext(availableWidgets) : generateWidgetContext(availableWidgets);
|
|
@@ -2360,19 +2375,21 @@ ${widgetContext}` : widgetContext;
|
|
|
2360
2375
|
}
|
|
2361
2376
|
};
|
|
2362
2377
|
const defaultPlaceholder = mode === "chat" ? "Type a message..." : "Enter your command...";
|
|
2363
|
-
const handleSendMessage = async (text, files) => {
|
|
2378
|
+
const handleSendMessage = async (text, files, isSystem) => {
|
|
2364
2379
|
const hasFiles = files && files.length > 0;
|
|
2365
2380
|
const fileNames = hasFiles ? files.map((f) => f.name) : [];
|
|
2366
2381
|
const displayContent = hasFiles ? `${text}${text ? "\n" : ""}[Attached: ${fileNames.join(", ")}]` : text;
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2382
|
+
if (!isSystem) {
|
|
2383
|
+
const userMessage = {
|
|
2384
|
+
id: `msg-${Date.now()}`,
|
|
2385
|
+
role: "user",
|
|
2386
|
+
content: displayContent,
|
|
2387
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
2388
|
+
metadata: hasFiles ? { attachments: fileNames } : void 0
|
|
2389
|
+
};
|
|
2390
|
+
setMessages((prev) => [...prev, userMessage]);
|
|
2391
|
+
onMessageSent?.(userMessage);
|
|
2392
|
+
}
|
|
2376
2393
|
setIsLoading(true);
|
|
2377
2394
|
try {
|
|
2378
2395
|
const messagePayload = await buildMessageWithAttachments(text, files);
|
|
@@ -2561,6 +2578,7 @@ ${widgetContext}` : widgetContext;
|
|
|
2561
2578
|
setIsLoading(false);
|
|
2562
2579
|
}
|
|
2563
2580
|
};
|
|
2581
|
+
handleSendMessageRef.current = handleSendMessage;
|
|
2564
2582
|
const executeCommand = async (commandOverride, files) => {
|
|
2565
2583
|
const currentCommand = commandOverride || commandInput;
|
|
2566
2584
|
if (!currentCommand.trim() && (!files || files.length === 0)) {
|
|
@@ -2858,7 +2876,7 @@ ${planToExecute}`;
|
|
|
2858
2876
|
`
|
|
2859
2877
|
} })
|
|
2860
2878
|
] });
|
|
2861
|
-
}
|
|
2879
|
+
});
|
|
2862
2880
|
|
|
2863
2881
|
// src/components/Chat/CommandOutput.tsx
|
|
2864
2882
|
import { useState as useState4 } from "react";
|