@blade-hq/agent-kit 0.5.7 → 0.5.11
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/{chunk-K5EE7X2D.js → chunk-G2LJZTPX.js} +80 -50
- package/dist/{chunk-K5EE7X2D.js.map → chunk-G2LJZTPX.js.map} +1 -1
- package/dist/client/index.d.ts +3029 -1632
- package/dist/react/components/chat/index.js +1 -1
- package/dist/react/index.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
resolveSessionFilePreviewTarget
|
|
17
17
|
} from "./chunk-X3S36RR2.js";
|
|
18
18
|
import {
|
|
19
|
+
apiFetchResponse,
|
|
19
20
|
buildMessageContent,
|
|
20
21
|
buildToolPreviewKey,
|
|
21
22
|
contentPreview,
|
|
@@ -3780,10 +3781,10 @@ function ConnectionBanner() {
|
|
|
3780
3781
|
import { ChevronDown as ChevronDown3, Lightbulb as Lightbulb2, MessageSquare } from "lucide-react";
|
|
3781
3782
|
import {
|
|
3782
3783
|
useCallback as useCallback12,
|
|
3783
|
-
useEffect as
|
|
3784
|
+
useEffect as useEffect17,
|
|
3784
3785
|
useEffectEvent as useEffectEvent4,
|
|
3785
3786
|
useMemo as useMemo17,
|
|
3786
|
-
useRef as
|
|
3787
|
+
useRef as useRef13,
|
|
3787
3788
|
useState as useState21
|
|
3788
3789
|
} from "react";
|
|
3789
3790
|
|
|
@@ -4213,7 +4214,7 @@ function useStickToBottomContext() {
|
|
|
4213
4214
|
|
|
4214
4215
|
// src/react/components/chat/AssistantTurnBlock.tsx
|
|
4215
4216
|
import { AlertCircle, BookOpen, Check as Check4, ChevronRight as ChevronRight5 } from "lucide-react";
|
|
4216
|
-
import { memo as memo3, useCallback as useCallback11, useEffect as
|
|
4217
|
+
import { memo as memo3, useCallback as useCallback11, useEffect as useEffect15, useMemo as useMemo15, useRef as useRef12, useState as useState18 } from "react";
|
|
4217
4218
|
|
|
4218
4219
|
// src/react/routes.ts
|
|
4219
4220
|
var MEMORIES_ROUTE = "/memories";
|
|
@@ -4495,7 +4496,7 @@ ReasoningContent.displayName = "ReasoningContent";
|
|
|
4495
4496
|
|
|
4496
4497
|
// src/react/components/chat/AgentLoopBlock.tsx
|
|
4497
4498
|
import { Bot, Check as Check3, ChevronRight as ChevronRight4, FileText as FileText6, Loader2 as Loader24, MessageSquareMore as MessageSquareMore2 } from "lucide-react";
|
|
4498
|
-
import { useEffect as
|
|
4499
|
+
import { useEffect as useEffect14, useMemo as useMemo14, useState as useState17 } from "react";
|
|
4499
4500
|
|
|
4500
4501
|
// src/react/components/chat/ResourceIframe.tsx
|
|
4501
4502
|
import { useEffect as useEffect10, useEffectEvent as useEffectEvent3, useRef as useRef9, useState as useState11 } from "react";
|
|
@@ -5781,7 +5782,8 @@ function buildAskUserPayload(argumentsJson) {
|
|
|
5781
5782
|
}
|
|
5782
5783
|
|
|
5783
5784
|
// src/react/components/chat/UserMessageBubble.tsx
|
|
5784
|
-
import {
|
|
5785
|
+
import { useQueries } from "@tanstack/react-query";
|
|
5786
|
+
import { useEffect as useEffect13, useRef as useRef11, useState as useState16 } from "react";
|
|
5785
5787
|
|
|
5786
5788
|
// src/react/lib/preview-dispatch.ts
|
|
5787
5789
|
var IMAGE_EXTS = [
|
|
@@ -6282,29 +6284,47 @@ function UserMessageBubble({ message, className }) {
|
|
|
6282
6284
|
)
|
|
6283
6285
|
] }) });
|
|
6284
6286
|
}
|
|
6285
|
-
const
|
|
6286
|
-
if (!isImageTextAttachment(attachment.name, attachment.uploadedPath))
|
|
6287
|
-
|
|
6288
|
-
}
|
|
6289
|
-
const pathForUrl = attachment.uploadedPath ?? attachment.name;
|
|
6290
|
-
return [
|
|
6291
|
-
{
|
|
6292
|
-
...attachment,
|
|
6293
|
-
url: buildSessionFileUrl(activeSessionId, pathForUrl)
|
|
6294
|
-
}
|
|
6295
|
-
];
|
|
6287
|
+
const imageTextAttachmentMeta = activeSessionId ? textAttachments.flatMap((attachment) => {
|
|
6288
|
+
if (!isImageTextAttachment(attachment.name, attachment.uploadedPath)) return [];
|
|
6289
|
+
return [{ ...attachment, filePath: attachment.uploadedPath ?? attachment.name }];
|
|
6296
6290
|
}) : [];
|
|
6297
6291
|
const nonImageTextAttachments = textAttachments.filter(
|
|
6298
6292
|
(attachment) => !isImageTextAttachment(attachment.name, attachment.uploadedPath)
|
|
6299
6293
|
);
|
|
6294
|
+
const imageAttachmentQueries = useQueries({
|
|
6295
|
+
queries: imageTextAttachmentMeta.map((att) => ({
|
|
6296
|
+
queryKey: ["session-image", activeSessionId, att.filePath],
|
|
6297
|
+
queryFn: async ({ signal }) => {
|
|
6298
|
+
const apiPath = `/api/sessions/${encodeURIComponent(activeSessionId)}/files/${encodeURIComponent(att.filePath)}`;
|
|
6299
|
+
const res = await apiFetchResponse(apiPath, { signal });
|
|
6300
|
+
const blob = await res.blob();
|
|
6301
|
+
return URL.createObjectURL(blob);
|
|
6302
|
+
},
|
|
6303
|
+
enabled: !!activeSessionId
|
|
6304
|
+
}))
|
|
6305
|
+
});
|
|
6306
|
+
const blobUrlMapRef = useRef11(/* @__PURE__ */ new Map());
|
|
6307
|
+
for (let i = 0; i < imageAttachmentQueries.length; i++) {
|
|
6308
|
+
const url = imageAttachmentQueries[i].data;
|
|
6309
|
+
const key = imageTextAttachmentMeta[i]?.filePath ?? String(i);
|
|
6310
|
+
const prev = blobUrlMapRef.current.get(key);
|
|
6311
|
+
if (prev && url && prev !== url) URL.revokeObjectURL(prev);
|
|
6312
|
+
if (url) blobUrlMapRef.current.set(key, url);
|
|
6313
|
+
}
|
|
6314
|
+
useEffect13(() => {
|
|
6315
|
+
const urls = blobUrlMapRef.current;
|
|
6316
|
+
return () => {
|
|
6317
|
+
for (const u of urls.values()) URL.revokeObjectURL(u);
|
|
6318
|
+
};
|
|
6319
|
+
}, []);
|
|
6300
6320
|
const lightboxImages = [
|
|
6301
6321
|
...imageParts.map((part) => ({
|
|
6302
6322
|
src: part.image_url.url,
|
|
6303
6323
|
alt: "\u7528\u6237\u4E0A\u4F20\u7684\u56FE\u7247"
|
|
6304
6324
|
})),
|
|
6305
|
-
...
|
|
6306
|
-
src:
|
|
6307
|
-
alt:
|
|
6325
|
+
...imageAttachmentQueries.map((q, i) => ({
|
|
6326
|
+
src: q.data ?? "",
|
|
6327
|
+
alt: imageTextAttachmentMeta[i]?.name || "\u7528\u6237\u4E0A\u4F20\u7684\u56FE\u7247"
|
|
6308
6328
|
}))
|
|
6309
6329
|
];
|
|
6310
6330
|
const [lightboxIndex, setLightboxIndex] = useState16(null);
|
|
@@ -6328,7 +6348,7 @@ function UserMessageBubble({ message, className }) {
|
|
|
6328
6348
|
setPreview({ filename: attachment.name, url, mode });
|
|
6329
6349
|
};
|
|
6330
6350
|
return /* @__PURE__ */ jsx28("div", { className: cn("flex justify-end", className), children: /* @__PURE__ */ jsxs23("div", { className: "group flex max-w-[72%] flex-col items-end gap-3", children: [
|
|
6331
|
-
(imageParts.length > 0 ||
|
|
6351
|
+
(imageParts.length > 0 || imageTextAttachmentMeta.length > 0) && /* @__PURE__ */ jsxs23("div", { className: "grid gap-2", children: [
|
|
6332
6352
|
imageParts.map((part, idx) => /* @__PURE__ */ jsx28(
|
|
6333
6353
|
"button",
|
|
6334
6354
|
{
|
|
@@ -6347,24 +6367,34 @@ function UserMessageBubble({ message, className }) {
|
|
|
6347
6367
|
},
|
|
6348
6368
|
part.image_url.url
|
|
6349
6369
|
)),
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
"
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6370
|
+
imageTextAttachmentMeta.map((att, idx) => {
|
|
6371
|
+
const blobUrl = imageAttachmentQueries[idx]?.data;
|
|
6372
|
+
return blobUrl ? /* @__PURE__ */ jsx28(
|
|
6373
|
+
"button",
|
|
6374
|
+
{
|
|
6375
|
+
type: "button",
|
|
6376
|
+
onClick: () => setLightboxIndex(imageParts.length + idx),
|
|
6377
|
+
className: "cursor-zoom-in",
|
|
6378
|
+
title: "\u67E5\u770B\u5927\u56FE",
|
|
6379
|
+
children: /* @__PURE__ */ jsx28(
|
|
6380
|
+
"img",
|
|
6381
|
+
{
|
|
6382
|
+
src: blobUrl,
|
|
6383
|
+
alt: att.name || "\u7528\u6237\u4E0A\u4F20\u7684\u56FE\u7247",
|
|
6384
|
+
className: "max-h-64 rounded-xl border border-[hsl(var(--user-msg-border))] object-cover"
|
|
6385
|
+
}
|
|
6386
|
+
)
|
|
6387
|
+
},
|
|
6388
|
+
`${att.uploadedPath}:${att.name}`
|
|
6389
|
+
) : imageAttachmentQueries[idx]?.isError ? null : /* @__PURE__ */ jsx28(
|
|
6390
|
+
"div",
|
|
6391
|
+
{
|
|
6392
|
+
className: "flex h-20 items-center justify-center rounded-xl border border-[hsl(var(--user-msg-border))] bg-[hsl(var(--muted)/0.3)] text-xs text-[hsl(var(--muted-foreground))]",
|
|
6393
|
+
children: "\u52A0\u8F7D\u4E2D..."
|
|
6394
|
+
},
|
|
6395
|
+
`${att.uploadedPath}:${att.name}`
|
|
6396
|
+
);
|
|
6397
|
+
})
|
|
6368
6398
|
] }),
|
|
6369
6399
|
lightboxImages.length > 0 && /* @__PURE__ */ jsx28(
|
|
6370
6400
|
ImageLightbox,
|
|
@@ -6525,7 +6555,7 @@ function AgentLoopBlock({ toolCall, sessionId, reasoning }) {
|
|
|
6525
6555
|
),
|
|
6526
6556
|
[childMessages]
|
|
6527
6557
|
);
|
|
6528
|
-
|
|
6558
|
+
useEffect14(() => {
|
|
6529
6559
|
if (hasAwaitingAnswer) {
|
|
6530
6560
|
setExpanded(true);
|
|
6531
6561
|
}
|
|
@@ -7011,8 +7041,8 @@ function AssistantTurnBlockBase({
|
|
|
7011
7041
|
const [displayMode, setDisplayMode] = useState18(
|
|
7012
7042
|
defaultTurnDisplayMode({ forceExpanded, hasActionableToolCall })
|
|
7013
7043
|
);
|
|
7014
|
-
const wasStreamingRef =
|
|
7015
|
-
|
|
7044
|
+
const wasStreamingRef = useRef12(isStreaming);
|
|
7045
|
+
useEffect15(() => {
|
|
7016
7046
|
if (wasStreamingRef.current && !isStreaming && !forceExpanded) {
|
|
7017
7047
|
setDisplayMode(defaultTurnDisplayMode({ forceExpanded, hasActionableToolCall }));
|
|
7018
7048
|
}
|
|
@@ -7673,7 +7703,7 @@ import {
|
|
|
7673
7703
|
TerminalSquare,
|
|
7674
7704
|
WandSparkles
|
|
7675
7705
|
} from "lucide-react";
|
|
7676
|
-
import { useEffect as
|
|
7706
|
+
import { useEffect as useEffect16, useMemo as useMemo16, useState as useState20 } from "react";
|
|
7677
7707
|
import { jsx as jsx33, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
7678
7708
|
var EMPTY_EVENTS = [];
|
|
7679
7709
|
function formatElapsedDuration(durationMs) {
|
|
@@ -7753,7 +7783,7 @@ function getTurnStartedAt(events) {
|
|
|
7753
7783
|
}
|
|
7754
7784
|
function useElapsedDuration(startedAt, active) {
|
|
7755
7785
|
const [now, setNow] = useState20(() => Date.now());
|
|
7756
|
-
|
|
7786
|
+
useEffect16(() => {
|
|
7757
7787
|
if (!active || startedAt == null) {
|
|
7758
7788
|
return;
|
|
7759
7789
|
}
|
|
@@ -7941,7 +7971,7 @@ function MessageList({
|
|
|
7941
7971
|
const agentLoops = useChatStore((state) => state.agentLoops[sessionId]);
|
|
7942
7972
|
const askAnswers = useChatStore((state) => state.askAnswers[sessionId]);
|
|
7943
7973
|
const agentLoopNameSet = useMemo17(() => new Set(Object.keys(agentLoops ?? {})), [agentLoops]);
|
|
7944
|
-
const assistantMessagesCacheRef =
|
|
7974
|
+
const assistantMessagesCacheRef = useRef13(/* @__PURE__ */ new Map());
|
|
7945
7975
|
const renderBlocks = useMemo17(() => {
|
|
7946
7976
|
const stableAssistantMessages = (key, buffer) => {
|
|
7947
7977
|
const previous = assistantMessagesCacheRef.current.get(key);
|
|
@@ -8053,9 +8083,9 @@ function MessageList({
|
|
|
8053
8083
|
) ?? null,
|
|
8054
8084
|
[lastTurnId, renderBlocks]
|
|
8055
8085
|
);
|
|
8056
|
-
const containerRef =
|
|
8057
|
-
const scrollContainerRef =
|
|
8058
|
-
const frameRef =
|
|
8086
|
+
const containerRef = useRef13(null);
|
|
8087
|
+
const scrollContainerRef = useRef13(null);
|
|
8088
|
+
const frameRef = useRef13(null);
|
|
8059
8089
|
const [activeTurnId, setActiveTurnId] = useState21(lastTurnId);
|
|
8060
8090
|
const layoutSignature = useMemo17(
|
|
8061
8091
|
() => getMessagesMeasureSignature(messages),
|
|
@@ -8097,7 +8127,7 @@ function MessageList({
|
|
|
8097
8127
|
measureActiveTurn();
|
|
8098
8128
|
});
|
|
8099
8129
|
});
|
|
8100
|
-
|
|
8130
|
+
useEffect17(() => {
|
|
8101
8131
|
scrollContainerRef.current = findScrollContainer(containerRef.current);
|
|
8102
8132
|
const sc = scrollContainerRef.current;
|
|
8103
8133
|
if (!sc) return;
|
|
@@ -8113,7 +8143,7 @@ function MessageList({
|
|
|
8113
8143
|
}
|
|
8114
8144
|
};
|
|
8115
8145
|
}, [scheduleMeasure]);
|
|
8116
|
-
|
|
8146
|
+
useEffect17(() => {
|
|
8117
8147
|
scheduleMeasure();
|
|
8118
8148
|
}, [lastTurnId, layoutSignature, scheduleMeasure]);
|
|
8119
8149
|
const handleSelectTurn = useCallback12((turnId) => {
|
|
@@ -8475,4 +8505,4 @@ use-stick-to-bottom/dist/StickToBottom.js:
|
|
|
8475
8505
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
8476
8506
|
*--------------------------------------------------------------------------------------------*)
|
|
8477
8507
|
*/
|
|
8478
|
-
//# sourceMappingURL=chunk-
|
|
8508
|
+
//# sourceMappingURL=chunk-G2LJZTPX.js.map
|