@blade-hq/agent-react 2612.0.0-beta.112 → 2612.0.0-beta.114
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/{McpAppCard-PGME4ZPA.js → McpAppCard-NJEKKEEN.js} +2 -2
- package/dist/{McpAppFrame-YKQ7ZZX6.js → McpAppFrame-IQK5AOMD.js} +2 -2
- package/dist/chat/AskUserQuestionBlock.d.ts +3 -2
- package/dist/chat/AssistantTurnBlock.d.ts +3 -2
- package/dist/chat/AttachmentPreviewDialog.d.ts +1 -6
- package/dist/chat/ChatLoadingIndicator.d.ts +2 -1
- package/dist/chat/MessageList.d.ts +2 -2
- package/dist/chat/ToolCallBlock.d.ts +6 -11
- package/dist/chat/chat-run.d.ts +4 -0
- package/dist/chat/customization.d.ts +4 -3
- package/dist/chat/index.d.ts +1 -1
- package/dist/chat/message-list-blocks.d.ts +1 -0
- package/dist/chat/runtime/actions.d.ts +1 -4
- package/dist/chat/runtime/environment.d.ts +2 -2
- package/dist/{chunk-SWYLHUQM.js → chunk-4WFRH7FG.js} +27 -7
- package/dist/{chunk-SWYLHUQM.js.map → chunk-4WFRH7FG.js.map} +1 -1
- package/dist/{chunk-VON7UU2E.js → chunk-7UQ3RWAU.js} +4 -4
- package/dist/{chunk-AZVPNN6K.js → chunk-AMWLYUD7.js} +1 -1
- package/dist/{chunk-AZVPNN6K.js.map → chunk-AMWLYUD7.js.map} +1 -1
- package/dist/{chunk-AOM334QU.js → chunk-C3G6F7UG.js} +9 -10
- package/dist/chunk-C3G6F7UG.js.map +1 -0
- package/dist/{chunk-B27HARE3.js → chunk-GZWQVVE7.js} +125 -77
- package/dist/chunk-GZWQVVE7.js.map +1 -0
- package/dist/{chunk-7TYNY2AX.js → chunk-HV3NKRZ2.js} +14 -13
- package/dist/chunk-HV3NKRZ2.js.map +1 -0
- package/dist/{chunk-5JDQG2JJ.js → chunk-XRNHTA7C.js} +2 -2
- package/dist/components/ChatInput.d.ts +2 -1
- package/dist/components/McpAppFrame.d.ts +2 -0
- package/dist/components/use-session-plugin-activation.d.ts +3 -1
- package/dist/index.js +5 -5
- package/dist/internal.js +7 -7
- package/dist/questions.js +2 -2
- package/dist/rich-input.js +5 -4
- package/dist/rich-input.js.map +1 -1
- package/dist/tool-details.js +3 -3
- package/package.json +2 -2
- package/dist/chunk-7TYNY2AX.js.map +0 -1
- package/dist/chunk-AOM334QU.js.map +0 -1
- package/dist/chunk-B27HARE3.js.map +0 -1
- /package/dist/{McpAppCard-PGME4ZPA.js.map → McpAppCard-NJEKKEEN.js.map} +0 -0
- /package/dist/{McpAppFrame-YKQ7ZZX6.js.map → McpAppFrame-IQK5AOMD.js.map} +0 -0
- /package/dist/{chunk-VON7UU2E.js.map → chunk-7UQ3RWAU.js.map} +0 -0
- /package/dist/{chunk-5JDQG2JJ.js.map → chunk-XRNHTA7C.js.map} +0 -0
|
@@ -16,16 +16,16 @@ import {
|
|
|
16
16
|
useEffectEvent,
|
|
17
17
|
useSessionPluginActivation,
|
|
18
18
|
useSessionSkills
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-HV3NKRZ2.js";
|
|
20
20
|
import {
|
|
21
21
|
ImageLightbox,
|
|
22
22
|
MessageImage,
|
|
23
23
|
ToolUiCardView,
|
|
24
24
|
getRenderer
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-7UQ3RWAU.js";
|
|
26
26
|
import {
|
|
27
27
|
MarkdownContent
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-XRNHTA7C.js";
|
|
29
29
|
import {
|
|
30
30
|
ChatEnvironmentProvider,
|
|
31
31
|
CurrentChatSessionProvider,
|
|
@@ -59,7 +59,7 @@ import {
|
|
|
59
59
|
useSessionSource,
|
|
60
60
|
useSessionState,
|
|
61
61
|
useSingleSessionSource
|
|
62
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-AMWLYUD7.js";
|
|
63
63
|
import {
|
|
64
64
|
BladeProvider,
|
|
65
65
|
useBladeClient,
|
|
@@ -1666,6 +1666,7 @@ function ChatInput({
|
|
|
1666
1666
|
onSend,
|
|
1667
1667
|
onStop,
|
|
1668
1668
|
isStreaming,
|
|
1669
|
+
isWaitingForInput = false,
|
|
1669
1670
|
isStopping = false,
|
|
1670
1671
|
queueWhileRunning = false,
|
|
1671
1672
|
mergesWithPanelAbove = false,
|
|
@@ -1777,7 +1778,7 @@ function ChatInput({
|
|
|
1777
1778
|
]
|
|
1778
1779
|
}
|
|
1779
1780
|
),
|
|
1780
|
-
trimmed && canSend && !hasAttachments && /* @__PURE__ */ jsxs9("div", { className: "mx-auto mt-1 max-w-[var(--blade-chat-width,780px)] text-right text-[11px] text-[hsl(var(--muted-foreground))]", children: [
|
|
1781
|
+
(isStreaming || isWaitingForInput) && queueWhileRunning && !isStopping && trimmed && canSend && !hasAttachments && /* @__PURE__ */ jsxs9("div", { className: "mx-auto mt-1 max-w-[var(--blade-chat-width,780px)] text-right text-[11px] text-[hsl(var(--muted-foreground))]", children: [
|
|
1781
1782
|
queueShortcutLabel(),
|
|
1782
1783
|
" \xB7 \u6392\u961F\u6D88\u606F"
|
|
1783
1784
|
] })
|
|
@@ -1808,6 +1809,7 @@ function LightComposer({
|
|
|
1808
1809
|
initialDraftKey
|
|
1809
1810
|
}) {
|
|
1810
1811
|
const session = useSessionHandle(sessionId);
|
|
1812
|
+
const isWaitingForInput = useSessionState(sessionId, (state2) => state2.status === "waiting_for_input");
|
|
1811
1813
|
const client = useBladeClient();
|
|
1812
1814
|
const [refs, setRefs] = useState9([]);
|
|
1813
1815
|
const [items, setItems] = useState9([]);
|
|
@@ -1999,6 +2001,7 @@ ${content}`);
|
|
|
1999
2001
|
},
|
|
2000
2002
|
onStop: () => void onStop(),
|
|
2001
2003
|
isStreaming,
|
|
2004
|
+
isWaitingForInput,
|
|
2002
2005
|
isStopping,
|
|
2003
2006
|
queueWhileRunning,
|
|
2004
2007
|
mergesWithPanelAbove,
|
|
@@ -2012,6 +2015,7 @@ ${content}`);
|
|
|
2012
2015
|
}
|
|
2013
2016
|
|
|
2014
2017
|
// src/chat/ChatLoadingIndicator.tsx
|
|
2018
|
+
import { getServerTime } from "@blade-hq/agent-client/internal";
|
|
2015
2019
|
import { useEffect as useEffect7, useState as useState10 } from "react";
|
|
2016
2020
|
|
|
2017
2021
|
// src/chat/ai-elements/shimmer.tsx
|
|
@@ -2086,20 +2090,23 @@ function resolveLoadingStageLabel({
|
|
|
2086
2090
|
function ChatLoadingIndicator({
|
|
2087
2091
|
preparing = false,
|
|
2088
2092
|
startedAtMs,
|
|
2089
|
-
activeToolLabel
|
|
2093
|
+
activeToolLabel,
|
|
2094
|
+
useRunClock = false
|
|
2090
2095
|
}) {
|
|
2096
|
+
const client = useOptionalBladeClient();
|
|
2091
2097
|
const [mountTime] = useState10(() => Date.now());
|
|
2092
2098
|
const originMs = typeof startedAtMs === "number" && Number.isFinite(startedAtMs) && startedAtMs > 0 ? startedAtMs : mountTime;
|
|
2093
|
-
const [
|
|
2099
|
+
const [tick, setTick] = useState10(() => ({ wall: Date.now(), monotonic: performance.now() }));
|
|
2100
|
+
const nowMs = (useRunClock ? getServerTime(client, tick.monotonic) : null) ?? tick.wall;
|
|
2094
2101
|
useEffect7(() => {
|
|
2095
2102
|
const elapsed = Math.max(0, nowMs - originMs);
|
|
2096
|
-
if (elapsed >= MAX_LIVE_CLOCK_MS) return;
|
|
2103
|
+
if (!useRunClock && elapsed >= MAX_LIVE_CLOCK_MS) return;
|
|
2097
2104
|
const delayMs = elapsed < 1e4 ? 100 : 1e3;
|
|
2098
2105
|
const timer = window.setTimeout(() => {
|
|
2099
|
-
|
|
2106
|
+
setTick({ wall: Date.now(), monotonic: performance.now() });
|
|
2100
2107
|
}, delayMs);
|
|
2101
2108
|
return () => window.clearTimeout(timer);
|
|
2102
|
-
}, [originMs, nowMs]);
|
|
2109
|
+
}, [originMs, nowMs, useRunClock]);
|
|
2103
2110
|
const elapsedMs = Math.max(0, nowMs - originMs);
|
|
2104
2111
|
const label = resolveLoadingStageLabel({ preparing, elapsedMs, activeToolLabel });
|
|
2105
2112
|
return /* @__PURE__ */ jsxs11(
|
|
@@ -3021,12 +3028,14 @@ function useAutoResizeTextarea(value) {
|
|
|
3021
3028
|
}, []);
|
|
3022
3029
|
return textareaRef;
|
|
3023
3030
|
}
|
|
3024
|
-
function AskUserQuestionBlock({
|
|
3031
|
+
function AskUserQuestionBlock(props) {
|
|
3032
|
+
return /* @__PURE__ */ jsx15(AskUserQuestionCard, { ...props }, props.toolCallId);
|
|
3033
|
+
}
|
|
3034
|
+
function AskUserQuestionCard({
|
|
3025
3035
|
data,
|
|
3026
3036
|
answered,
|
|
3027
3037
|
readOnly = false,
|
|
3028
3038
|
toolCallId,
|
|
3029
|
-
sessionStatus,
|
|
3030
3039
|
answerData,
|
|
3031
3040
|
onAnswer
|
|
3032
3041
|
}) {
|
|
@@ -3035,14 +3044,10 @@ function AskUserQuestionBlock({
|
|
|
3035
3044
|
const [usingCustom, setUsingCustom] = useState14(/* @__PURE__ */ new Set());
|
|
3036
3045
|
const [note, setNote] = useState14("");
|
|
3037
3046
|
const [submitted, setSubmitted] = useState14(false);
|
|
3038
|
-
const
|
|
3039
|
-
|
|
3040
|
-
if (sessionStatus === "failed" || sessionStatus === "interrupted") {
|
|
3041
|
-
setSubmitted(false);
|
|
3042
|
-
}
|
|
3043
|
-
}, [sessionStatus]);
|
|
3047
|
+
const hasAnswer = answered || Boolean(answerData);
|
|
3048
|
+
const locked = hasAnswer || readOnly || !onAnswer;
|
|
3044
3049
|
const displayAnswerState = useMemo6(() => {
|
|
3045
|
-
if (!
|
|
3050
|
+
if (!answerData) {
|
|
3046
3051
|
return {
|
|
3047
3052
|
selections,
|
|
3048
3053
|
customTexts,
|
|
@@ -3067,7 +3072,7 @@ function AskUserQuestionBlock({
|
|
|
3067
3072
|
usingCustom: nextUsingCustom,
|
|
3068
3073
|
note: answerData.note ?? ""
|
|
3069
3074
|
};
|
|
3070
|
-
}, [answerData,
|
|
3075
|
+
}, [answerData, customTexts, note, selections, usingCustom]);
|
|
3071
3076
|
const displaySelections = displayAnswerState.selections;
|
|
3072
3077
|
const displayCustomTexts = displayAnswerState.customTexts;
|
|
3073
3078
|
const displayUsingCustom = displayAnswerState.usingCustom;
|
|
@@ -3117,7 +3122,7 @@ function AskUserQuestionBlock({
|
|
|
3117
3122
|
return [...sel].sort().map((i) => q.options[i].label).join(", ");
|
|
3118
3123
|
};
|
|
3119
3124
|
const allAnswered = data.questions.every((_, i) => getAnswer(i) !== null);
|
|
3120
|
-
const handleSubmit = () => {
|
|
3125
|
+
const handleSubmit = async () => {
|
|
3121
3126
|
if (locked || submitted || !allAnswered || !onAnswer) return;
|
|
3122
3127
|
const trimmedNote = note.trim();
|
|
3123
3128
|
const nextAnswerData = {
|
|
@@ -3134,7 +3139,22 @@ function AskUserQuestionBlock({
|
|
|
3134
3139
|
};
|
|
3135
3140
|
const text = formatAskUserAnswer(data, nextAnswerData);
|
|
3136
3141
|
setSubmitted(true);
|
|
3137
|
-
|
|
3142
|
+
const controller = new AbortController();
|
|
3143
|
+
let timer;
|
|
3144
|
+
try {
|
|
3145
|
+
const timeout = new Promise((resolve) => {
|
|
3146
|
+
timer = setTimeout(() => {
|
|
3147
|
+
controller.abort();
|
|
3148
|
+
resolve(false);
|
|
3149
|
+
}, 3e4);
|
|
3150
|
+
});
|
|
3151
|
+
const accepted = await Promise.race([onAnswer(text, toolCallId, nextAnswerData, controller.signal), timeout]);
|
|
3152
|
+
if (accepted === false) setSubmitted(false);
|
|
3153
|
+
} catch {
|
|
3154
|
+
setSubmitted(false);
|
|
3155
|
+
} finally {
|
|
3156
|
+
clearTimeout(timer);
|
|
3157
|
+
}
|
|
3138
3158
|
};
|
|
3139
3159
|
return /* @__PURE__ */ jsxs14(
|
|
3140
3160
|
"div",
|
|
@@ -3149,7 +3169,7 @@ function AskUserQuestionBlock({
|
|
|
3149
3169
|
"\u5B50\u667A\u80FD\u4F53\u300C",
|
|
3150
3170
|
data.source_loop.description,
|
|
3151
3171
|
"\u300D",
|
|
3152
|
-
|
|
3172
|
+
locked ? "\u66FE\u53D1\u8D77\u63D0\u95EE" : "\u5728\u7B49\u5F85\u4F60\u7684\u56DE\u7B54"
|
|
3153
3173
|
] }),
|
|
3154
3174
|
data.questions.map((q, qIdx) => /* @__PURE__ */ jsx15(
|
|
3155
3175
|
QuestionCard,
|
|
@@ -3175,7 +3195,8 @@ function AskUserQuestionBlock({
|
|
|
3175
3195
|
onChange: setNote
|
|
3176
3196
|
}
|
|
3177
3197
|
),
|
|
3178
|
-
!
|
|
3198
|
+
!readOnly && locked && !hasAnswer && /* @__PURE__ */ jsx15("div", { className: "text-xs", children: "\u5DF2\u7ED3\u675F" }),
|
|
3199
|
+
!locked && !submitted && /* @__PURE__ */ jsx15(
|
|
3179
3200
|
"button",
|
|
3180
3201
|
{
|
|
3181
3202
|
type: "button",
|
|
@@ -6612,12 +6633,31 @@ function extractPlanMessagesForTurn(messages, turnLastMessage) {
|
|
|
6612
6633
|
return extractLatestPlanMessages(messages.slice(enterIndex, endIndex));
|
|
6613
6634
|
}
|
|
6614
6635
|
|
|
6636
|
+
// src/chat/chat-run.ts
|
|
6637
|
+
function lastChatRun(messages) {
|
|
6638
|
+
for (let index = messages.length - 1; index >= 0; index--) {
|
|
6639
|
+
const run = messages[index].chat_run;
|
|
6640
|
+
if (run) return run;
|
|
6641
|
+
}
|
|
6642
|
+
}
|
|
6643
|
+
function formatExecutionDuration(durationMs) {
|
|
6644
|
+
const totalSeconds = Math.max(0, Math.round(durationMs / 1e3));
|
|
6645
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
6646
|
+
const seconds = totalSeconds % 60;
|
|
6647
|
+
return minutes > 0 ? `${minutes}\u5206${seconds}\u79D2` : `${seconds}\u79D2`;
|
|
6648
|
+
}
|
|
6649
|
+
function terminalChatLabel(run) {
|
|
6650
|
+
if (!run || run.status !== "cancelled" && run.status !== "failed") return null;
|
|
6651
|
+
const label = run.status === "failed" ? "\u6267\u884C\u5931\u8D25" : "\u6267\u884C\u5DF2\u4E2D\u65AD";
|
|
6652
|
+
return run.duration_ms == null ? label : `${label} ${formatExecutionDuration(run.duration_ms)}`;
|
|
6653
|
+
}
|
|
6654
|
+
|
|
6615
6655
|
// src/components/ExecutionProcessContext.ts
|
|
6616
6656
|
import { createContext as createContext5 } from "react";
|
|
6617
6657
|
var KeepToolStepsOpenContext = createContext5(false);
|
|
6618
6658
|
|
|
6619
6659
|
// src/chat/AssistantTurnBlock.tsx
|
|
6620
|
-
import { getServerTime } from "@blade-hq/agent-client/internal";
|
|
6660
|
+
import { getServerTime as getServerTime2 } from "@blade-hq/agent-client/internal";
|
|
6621
6661
|
import { memo as memo3, useCallback as useCallback9, useContext as useContext7, useEffect as useEffect18, useMemo as useMemo13, useRef as useRef16, useState as useState25 } from "react";
|
|
6622
6662
|
|
|
6623
6663
|
// src/chat/lib/citations.ts
|
|
@@ -7336,13 +7376,11 @@ function ToolPreviewAction({
|
|
|
7336
7376
|
function resolveAskQuestionState({
|
|
7337
7377
|
toolStatus,
|
|
7338
7378
|
hasAnswerData,
|
|
7339
|
-
fallbackAnswered
|
|
7340
|
-
fallbackAwaiting
|
|
7379
|
+
fallbackAnswered
|
|
7341
7380
|
}) {
|
|
7342
|
-
const awaitingAnswer = !hasAnswerData && (toolStatus === "awaiting_answer" || toolStatus === "pending" && fallbackAwaiting === true);
|
|
7343
7381
|
return {
|
|
7344
|
-
awaitingAnswer,
|
|
7345
|
-
answered: hasAnswerData ||
|
|
7382
|
+
awaitingAnswer: !hasAnswerData && toolStatus === "awaiting_answer",
|
|
7383
|
+
answered: hasAnswerData || toolStatus !== "awaiting_answer" && Boolean(fallbackAnswered)
|
|
7346
7384
|
};
|
|
7347
7385
|
}
|
|
7348
7386
|
function ToolCallBlock({
|
|
@@ -7352,7 +7390,6 @@ function ToolCallBlock({
|
|
|
7352
7390
|
answerData,
|
|
7353
7391
|
sessionId: providedSessionId,
|
|
7354
7392
|
sessionStatus,
|
|
7355
|
-
isActiveQuestion,
|
|
7356
7393
|
level = 1,
|
|
7357
7394
|
turnBlocks,
|
|
7358
7395
|
reasoning,
|
|
@@ -7369,12 +7406,10 @@ function ToolCallBlock({
|
|
|
7369
7406
|
const isSessionReadonly = useSessionState(resolvedSessionId, isReadOnlySession);
|
|
7370
7407
|
const readOnly = useReadOnlyChat() || isSessionReadonly;
|
|
7371
7408
|
const answerCallback = useMemo10(
|
|
7372
|
-
() => session && !readOnly ? (answer, toolCallId, data) => {
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
});
|
|
7377
|
-
} : void 0,
|
|
7409
|
+
() => session && !readOnly ? (answer, toolCallId, data, signal) => sendToSession(session, answer, session.getState().mode ?? void 0, {
|
|
7410
|
+
tool_call_id: toolCallId,
|
|
7411
|
+
...data
|
|
7412
|
+
}, { signal }) : void 0,
|
|
7378
7413
|
[readOnly, session]
|
|
7379
7414
|
);
|
|
7380
7415
|
useEffect13(() => {
|
|
@@ -7384,7 +7419,6 @@ function ToolCallBlock({
|
|
|
7384
7419
|
}, [shouldAutoExpandWhileStreaming]);
|
|
7385
7420
|
const resolvedSessionStatus = sessionStatus ?? liveSessionStatus ?? void 0;
|
|
7386
7421
|
const resolvedAnswerData = answerData ?? storedAnswerData;
|
|
7387
|
-
const resolvedAnswered = toolCall.status === "awaiting_answer" ? false : answered ?? (!!resolvedAnswerData && resolvedSessionStatus !== "waiting_for_input");
|
|
7388
7422
|
const resolvedOnAnswer = readOnly ? void 0 : onAnswer ?? answerCallback;
|
|
7389
7423
|
if (isWorkflowRunToolName(toolCall.name)) {
|
|
7390
7424
|
return null;
|
|
@@ -7394,8 +7428,7 @@ function ToolCallBlock({
|
|
|
7394
7428
|
const questionState = resolveAskQuestionState({
|
|
7395
7429
|
toolStatus: toolCall.status,
|
|
7396
7430
|
hasAnswerData: Boolean(resolvedAnswerData),
|
|
7397
|
-
fallbackAnswered:
|
|
7398
|
-
fallbackAwaiting: isActiveQuestion === true && (resolvedSessionStatus === "paused" || resolvedSessionStatus === "waiting_for_input")
|
|
7431
|
+
fallbackAnswered: answered
|
|
7399
7432
|
});
|
|
7400
7433
|
const canAnswer = questionState.awaitingAnswer && Boolean(resolvedOnAnswer);
|
|
7401
7434
|
const customQuestion = askData ? customization?.renderers?.askUserQuestion?.({
|
|
@@ -7597,13 +7630,11 @@ function useAsyncValue(key, load2) {
|
|
|
7597
7630
|
// src/chat/AttachmentPreviewDialog.tsx
|
|
7598
7631
|
import { jsx as jsx23, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
7599
7632
|
function AttachmentPreviewDialog({ open, onOpenChange, filename, url, mode }) {
|
|
7633
|
+
const client = useOptionalBladeClient();
|
|
7600
7634
|
const enabled = open && url != null && (mode === "markdown" || mode === "text");
|
|
7601
7635
|
const { data: content, error } = useAsyncValue(enabled ? `${mode}:${url}` : null, async (signal) => {
|
|
7602
7636
|
if (!url) return null;
|
|
7603
|
-
const res = await fetch(url, {
|
|
7604
|
-
signal,
|
|
7605
|
-
credentials: "include"
|
|
7606
|
-
});
|
|
7637
|
+
const res = client && !url.startsWith("blob:") ? await client.fetch("GET", url, { signal, expectOk: false }) : await fetch(url, { signal, credentials: "include" });
|
|
7607
7638
|
if (!res.ok) {
|
|
7608
7639
|
const body = await res.text().catch(() => "");
|
|
7609
7640
|
throw new Error(`\u52A0\u8F7D\u5931\u8D25\uFF08HTTP ${res.status}\uFF09${body ? `\uFF1A${body.slice(0, 200)}` : ""}`);
|
|
@@ -8880,8 +8911,7 @@ function toolCallAnswered(toolCall, sessionStatus, answerData) {
|
|
|
8880
8911
|
if (formatToolName(toolCall.name) !== "AskUserQuestion") {
|
|
8881
8912
|
return sessionStatus !== "waiting_for_input";
|
|
8882
8913
|
}
|
|
8883
|
-
|
|
8884
|
-
return !(toolCall.status === "awaiting_answer" || toolCall.status === "done" && sessionStatus === "waiting_for_input");
|
|
8914
|
+
return Boolean(answerData);
|
|
8885
8915
|
}
|
|
8886
8916
|
|
|
8887
8917
|
// src/chat/AssistantTurnBlock.tsx
|
|
@@ -8903,17 +8933,17 @@ function resolveTurnDisplayMode({
|
|
|
8903
8933
|
}) {
|
|
8904
8934
|
return displayMode;
|
|
8905
8935
|
}
|
|
8906
|
-
function formatExecutionDuration(durationMs) {
|
|
8907
|
-
const totalSeconds = Math.max(0, Math.round(durationMs / 1e3));
|
|
8908
|
-
const minutes = Math.floor(totalSeconds / 60);
|
|
8909
|
-
const seconds = totalSeconds % 60;
|
|
8910
|
-
return minutes > 0 ? `${minutes}\u5206${seconds}\u79D2` : `${seconds}\u79D2`;
|
|
8911
|
-
}
|
|
8912
8936
|
function getExecutionDurationMs({
|
|
8913
8937
|
messages,
|
|
8914
8938
|
isStreaming,
|
|
8915
8939
|
now = null
|
|
8916
8940
|
}) {
|
|
8941
|
+
const run = lastChatRun(messages);
|
|
8942
|
+
if (run?.duration_ms != null) return run.duration_ms;
|
|
8943
|
+
if (run?.started_at && isStreaming && now !== null) {
|
|
8944
|
+
const start = Date.parse(run.started_at);
|
|
8945
|
+
if (Number.isFinite(start)) return Math.max(0, now - start);
|
|
8946
|
+
}
|
|
8917
8947
|
const knownDuration = messages.reduce(
|
|
8918
8948
|
(total, message) => {
|
|
8919
8949
|
if (typeof message.duration_ms === "number" && message.duration_ms > 0) {
|
|
@@ -8953,6 +8983,11 @@ function executionSummaryLabel({
|
|
|
8953
8983
|
sessionStatus,
|
|
8954
8984
|
askAnswers
|
|
8955
8985
|
}) {
|
|
8986
|
+
const run = lastChatRun(messages);
|
|
8987
|
+
const runStatus = run?.status;
|
|
8988
|
+
if (runStatus === "incomplete" && !isStreaming) return "\u672C\u8F6E\u4ECD\u5728\u6267\u884C";
|
|
8989
|
+
const terminal = terminalChatLabel(run);
|
|
8990
|
+
if (terminal) return terminal;
|
|
8956
8991
|
if (isStreaming) {
|
|
8957
8992
|
return durationMs > 0 ? `\u6B63\u5728\u6267\u884C ${formatExecutionDuration(durationMs)}` : "\u6B63\u5728\u6267\u884C";
|
|
8958
8993
|
}
|
|
@@ -9180,6 +9215,7 @@ function AssistantTurnBlockBase({
|
|
|
9180
9215
|
() => finalMessage ? getTextContent3(normalizeMessageContent2(finalMessage.content)).trim() : "",
|
|
9181
9216
|
[finalMessage]
|
|
9182
9217
|
);
|
|
9218
|
+
const terminalLabel = terminalChatLabel(lastChatRun(messages));
|
|
9183
9219
|
const hasInterruptedState = messages.some((message) => message.status === "interrupted");
|
|
9184
9220
|
const hasFailedWithoutContent = messages.some(
|
|
9185
9221
|
(message) => message.status === "failed" && !hasRenderableMessageContent(message)
|
|
@@ -9199,7 +9235,7 @@ function AssistantTurnBlockBase({
|
|
|
9199
9235
|
const liveExecutionDurationMs = isStreaming ? getExecutionDurationMs({
|
|
9200
9236
|
messages,
|
|
9201
9237
|
isStreaming,
|
|
9202
|
-
now: sessionId ?
|
|
9238
|
+
now: sessionId ? getServerTime2(client, clock) : Date.now()
|
|
9203
9239
|
}) : executionDurationMs;
|
|
9204
9240
|
const observedMemoryRefs = useMemo13(() => collectMemoryRefs(messages), [messages]);
|
|
9205
9241
|
const [cachedMemoryRefs, setCachedMemoryRefs] = useState25([]);
|
|
@@ -9219,8 +9255,9 @@ function AssistantTurnBlockBase({
|
|
|
9219
9255
|
),
|
|
9220
9256
|
children: [
|
|
9221
9257
|
memoryRefs.length > 0 && /* @__PURE__ */ jsx31(MemoryRefsHint, { refs: memoryRefs }),
|
|
9222
|
-
|
|
9223
|
-
|
|
9258
|
+
!hasExecutionProcess && terminalLabel && /* @__PURE__ */ jsx31("div", { className: "text-xs text-muted-foreground", children: terminalLabel }),
|
|
9259
|
+
hasInterruptedState && !terminalLabel && /* @__PURE__ */ jsx31("div", { className: "w-fit rounded-full border border-[hsl(var(--swf-warning)/0.3)] bg-[hsl(var(--swf-warning-soft))] px-2.5 py-1 text-[10px] font-medium text-[hsl(var(--swf-warning))]", children: "\u5DF2\u4E2D\u65AD" }),
|
|
9260
|
+
hasFailedWithoutContent && !terminalLabel && /* @__PURE__ */ jsx31("div", { className: "w-fit rounded-full border border-[hsl(var(--destructive)/0.3)] bg-[hsl(var(--destructive)/0.1)] px-2.5 py-1 text-[10px] font-medium text-[hsl(var(--destructive))]", children: "\u751F\u6210\u5931\u8D25" }),
|
|
9224
9261
|
hasExecutionProcess && /* @__PURE__ */ jsxs29("div", { className: "flex w-full items-start gap-2.5", children: [
|
|
9225
9262
|
/* @__PURE__ */ jsx31(
|
|
9226
9263
|
"span",
|
|
@@ -9402,14 +9439,13 @@ function PersistentAskUserQuestions({
|
|
|
9402
9439
|
level,
|
|
9403
9440
|
customization
|
|
9404
9441
|
}) {
|
|
9405
|
-
const activeQuestionId = questions.filter(({ toolCall }) => toolCall.status === "pending").at(-1)?.toolCall.id;
|
|
9406
9442
|
return questions.map(
|
|
9407
9443
|
({ toolCall, turnBlocks }) => customization?.components?.ToolCall ? /* @__PURE__ */ jsx31(
|
|
9408
9444
|
customization.components.ToolCall,
|
|
9409
9445
|
{
|
|
9410
9446
|
toolCall,
|
|
9411
9447
|
answerData: askAnswers?.[toolCall.id],
|
|
9412
|
-
onAnswer,
|
|
9448
|
+
onAnswer: toolCall.status === "awaiting_answer" ? onAnswer : void 0,
|
|
9413
9449
|
answered: toolCallAnswered(toolCall, sessionStatus, askAnswers?.[toolCall.id]),
|
|
9414
9450
|
sessionId,
|
|
9415
9451
|
sessionStatus,
|
|
@@ -9427,7 +9463,6 @@ function PersistentAskUserQuestions({
|
|
|
9427
9463
|
answered: toolCallAnswered(toolCall, sessionStatus, askAnswers?.[toolCall.id]),
|
|
9428
9464
|
sessionId,
|
|
9429
9465
|
sessionStatus,
|
|
9430
|
-
isActiveQuestion: toolCall.id === activeQuestionId,
|
|
9431
9466
|
level,
|
|
9432
9467
|
turnBlocks,
|
|
9433
9468
|
customization
|
|
@@ -10791,7 +10826,7 @@ function getAssistantTurnPreview(messages) {
|
|
|
10791
10826
|
return "\u672C\u8F6E\u56DE\u590D";
|
|
10792
10827
|
}
|
|
10793
10828
|
function shouldAppendPendingAssistantTurn(sessionIsStreaming, lastMessage) {
|
|
10794
|
-
return sessionIsStreaming && lastMessage?.role === "user";
|
|
10829
|
+
return sessionIsStreaming && lastMessage?.role === "user" && (!lastMessage.chat_run || lastMessage.chat_run.status === "incomplete");
|
|
10795
10830
|
}
|
|
10796
10831
|
function hasAssistantReply(block) {
|
|
10797
10832
|
return block?.type === "assistant_turn" && block.messages.some((message) => {
|
|
@@ -10816,7 +10851,9 @@ function buildMessageListBlocks({
|
|
|
10816
10851
|
});
|
|
10817
10852
|
const blocks = [];
|
|
10818
10853
|
let contextBuffer = [];
|
|
10854
|
+
const unanswered = /* @__PURE__ */ new Map();
|
|
10819
10855
|
let assistantBuffer = [];
|
|
10856
|
+
let bufferRunId;
|
|
10820
10857
|
let assistantTurnCount = 0;
|
|
10821
10858
|
let lastUserPreview = "";
|
|
10822
10859
|
let pendingUserEntryId = null;
|
|
@@ -10839,6 +10876,7 @@ function buildMessageListBlocks({
|
|
|
10839
10876
|
});
|
|
10840
10877
|
pendingUserEntryId = null;
|
|
10841
10878
|
assistantBuffer = [];
|
|
10879
|
+
bufferRunId = void 0;
|
|
10842
10880
|
};
|
|
10843
10881
|
const flushContexts = () => {
|
|
10844
10882
|
if (contextBuffer.length === 0) return;
|
|
@@ -10910,6 +10948,9 @@ function buildMessageListBlocks({
|
|
|
10910
10948
|
continue;
|
|
10911
10949
|
}
|
|
10912
10950
|
if (message.role === "assistant" && !notice) {
|
|
10951
|
+
if (message.chat_run && bufferRunId && bufferRunId !== message.chat_run.run_id) flushAssistant();
|
|
10952
|
+
if (message.chat_run) bufferRunId = message.chat_run.run_id;
|
|
10953
|
+
if (message.chat_run && terminalChatLabel(message.chat_run)) unanswered.set(message.chat_run.run_id, null);
|
|
10913
10954
|
assistantBuffer.push(message);
|
|
10914
10955
|
continue;
|
|
10915
10956
|
}
|
|
@@ -10919,21 +10960,26 @@ function buildMessageListBlocks({
|
|
|
10919
10960
|
lastUserPreview = getMessagePreview(message);
|
|
10920
10961
|
pendingUserEntryId = persistentId;
|
|
10921
10962
|
}
|
|
10922
|
-
|
|
10963
|
+
const block = {
|
|
10923
10964
|
type: "message",
|
|
10924
10965
|
message,
|
|
10925
10966
|
key: message.render_id ?? persistentId ?? `${message.role}-${blocks.length}`,
|
|
10926
10967
|
persistentId,
|
|
10927
10968
|
anchorId: persistentId ? `chat-entry-${persistentId}` : null,
|
|
10928
10969
|
isStreaming: message.status === "streaming"
|
|
10929
|
-
}
|
|
10970
|
+
};
|
|
10971
|
+
blocks.push(block);
|
|
10972
|
+
if (message.role === "user" && message.chat_run && terminalChatLabel(message.chat_run) && unanswered.get(message.chat_run.run_id) !== null) {
|
|
10973
|
+
unanswered.set(message.chat_run.run_id, block);
|
|
10974
|
+
}
|
|
10930
10975
|
}
|
|
10931
10976
|
flushAssistant();
|
|
10932
10977
|
flushContexts();
|
|
10933
10978
|
if (sessionIsStreaming && completionNotice(visible.at(-1)?.blocks)?.source.source_kind !== "subagent") {
|
|
10934
10979
|
const last = blocks[blocks.length - 1];
|
|
10935
10980
|
if (last?.type === "assistant_turn") {
|
|
10936
|
-
|
|
10981
|
+
const run = lastChatRun(last.messages);
|
|
10982
|
+
last.isStreaming = !run || run.status === "incomplete";
|
|
10937
10983
|
} else if (shouldAppendPendingAssistantTurn(
|
|
10938
10984
|
sessionIsStreaming,
|
|
10939
10985
|
last?.type === "message" ? last.message : void 0
|
|
@@ -10947,6 +10993,7 @@ function buildMessageListBlocks({
|
|
|
10947
10993
|
role: "assistant",
|
|
10948
10994
|
content: "",
|
|
10949
10995
|
entry_id: pendingKey,
|
|
10996
|
+
...last.type === "message" && last.message.chat_run?.status === "incomplete" ? { chat_run: last.message.chat_run } : {},
|
|
10950
10997
|
status: "streaming",
|
|
10951
10998
|
loop_name: "root"
|
|
10952
10999
|
}
|
|
@@ -10960,6 +11007,9 @@ function buildMessageListBlocks({
|
|
|
10960
11007
|
});
|
|
10961
11008
|
}
|
|
10962
11009
|
}
|
|
11010
|
+
for (const block of unanswered.values()) {
|
|
11011
|
+
if (block) block.unansweredLabel = terminalChatLabel(block.message.chat_run) ?? void 0;
|
|
11012
|
+
}
|
|
10963
11013
|
return blocks;
|
|
10964
11014
|
}
|
|
10965
11015
|
function getRenderBlockPersistentId(block) {
|
|
@@ -11204,7 +11254,7 @@ function MessageListBody({
|
|
|
11204
11254
|
}, [agentLoopNameSet, messages, sessionIsStreaming, isRevealingAny]);
|
|
11205
11255
|
const hasInterruptedTurn = useMemo14(
|
|
11206
11256
|
() => renderBlocks.some(
|
|
11207
|
-
(block) => block.type === "assistant_turn" && block.messages.some((message) => message.status === "interrupted")
|
|
11257
|
+
(block) => block.type === "message" && block.unansweredLabel && block.message.chat_run?.status === "cancelled" || block.type === "assistant_turn" && (lastChatRun(block.messages)?.status === "cancelled" || block.messages.some((message) => message.status === "interrupted"))
|
|
11208
11258
|
),
|
|
11209
11259
|
[renderBlocks]
|
|
11210
11260
|
);
|
|
@@ -11240,12 +11290,14 @@ function MessageListBody({
|
|
|
11240
11290
|
}
|
|
11241
11291
|
return null;
|
|
11242
11292
|
}, [renderBlocks]);
|
|
11293
|
+
const preparingRun = latestUserBlock?.message.chat_run ?? (isPreparing && latestUserBlock?.message.entry_id?.startsWith("local-user-") ? lastChatRun(messages) : void 0);
|
|
11294
|
+
const preparingStart = preparingRun?.status === "incomplete" ? preparingRun.started_at : void 0;
|
|
11243
11295
|
const latestUserStartedAtMs = useMemo14(() => {
|
|
11244
|
-
const ts = latestUserBlock?.message.timestamp;
|
|
11296
|
+
const ts = preparingStart ?? latestUserBlock?.message.timestamp;
|
|
11245
11297
|
if (!ts) return null;
|
|
11246
11298
|
const parsed = Date.parse(ts);
|
|
11247
11299
|
return Number.isFinite(parsed) ? parsed : null;
|
|
11248
|
-
}, [latestUserBlock]);
|
|
11300
|
+
}, [latestUserBlock, preparingStart]);
|
|
11249
11301
|
const latestUserAnchorId = latestUserBlock?.anchorId ?? null;
|
|
11250
11302
|
const latestUserStableId = latestUserBlock?.message.render_id ?? latestUserAnchorId;
|
|
11251
11303
|
const latestUserIsOptimistic = latestUserBlock?.message.entry_id?.startsWith("local-user-") ?? false;
|
|
@@ -12166,7 +12218,7 @@ function MessageListBody({
|
|
|
12166
12218
|
emptyState
|
|
12167
12219
|
}
|
|
12168
12220
|
),
|
|
12169
|
-
isPreparing ? /* @__PURE__ */ jsx37("div", { className: "mx-auto mt-3 max-w-[var(--blade-chat-width,780px)] px-4", children: /* @__PURE__ */ jsx37(ChatLoadingIndicator, { preparing: true, startedAtMs: latestUserStartedAtMs }) }) : null,
|
|
12221
|
+
isPreparing ? /* @__PURE__ */ jsx37("div", { className: "mx-auto mt-3 max-w-[var(--blade-chat-width,780px)] px-4", children: /* @__PURE__ */ jsx37(ChatLoadingIndicator, { preparing: true, startedAtMs: latestUserStartedAtMs, useRunClock: Boolean(preparingStart) }) }) : null,
|
|
12170
12222
|
/* @__PURE__ */ jsx37("div", { ref: newTurnSpacerRef, "aria-hidden": "true", className: "pointer-events-none w-full" })
|
|
12171
12223
|
]
|
|
12172
12224
|
}
|
|
@@ -12281,7 +12333,8 @@ function MessageListContent({
|
|
|
12281
12333
|
message: block.message,
|
|
12282
12334
|
className: customization?.classNames?.errorMessage
|
|
12283
12335
|
}
|
|
12284
|
-
) : null
|
|
12336
|
+
) : null,
|
|
12337
|
+
block.unansweredLabel && /* @__PURE__ */ jsx37("div", { className: "mt-2 text-xs text-muted-foreground", children: block.unansweredLabel })
|
|
12285
12338
|
]
|
|
12286
12339
|
}
|
|
12287
12340
|
);
|
|
@@ -12890,13 +12943,8 @@ function ChatPanel({
|
|
|
12890
12943
|
[mode, sendUserMessage]
|
|
12891
12944
|
);
|
|
12892
12945
|
const answerQuestion = useCallback15(
|
|
12893
|
-
(msg, toolCallId, answerData) => {
|
|
12894
|
-
|
|
12895
|
-
tool_call_id: toolCallId,
|
|
12896
|
-
...answerData
|
|
12897
|
-
});
|
|
12898
|
-
},
|
|
12899
|
-
[mode, sendUserMessage]
|
|
12946
|
+
(msg, toolCallId, answerData, signal) => send(msg, mode, { tool_call_id: toolCallId, ...answerData }, { signal }),
|
|
12947
|
+
[mode, send]
|
|
12900
12948
|
);
|
|
12901
12949
|
const moveQueuedMessage = useCallback15(
|
|
12902
12950
|
(item, delta) => {
|
|
@@ -13030,7 +13078,7 @@ function ChatPanel({
|
|
|
13030
13078
|
postChatFollowup,
|
|
13031
13079
|
resultFeedbackByEntry,
|
|
13032
13080
|
onResultFeedbackSaved: handleResultFeedbackSaved,
|
|
13033
|
-
onAnswer: isViewer ? void 0 :
|
|
13081
|
+
onAnswer: isViewer ? void 0 : answerQuestion,
|
|
13034
13082
|
isStopping,
|
|
13035
13083
|
onRevealingChange: setIsRevealing,
|
|
13036
13084
|
isReplay
|
|
@@ -14133,6 +14181,7 @@ export {
|
|
|
14133
14181
|
PlanSummaryCard,
|
|
14134
14182
|
extractLatestPlanMessages,
|
|
14135
14183
|
extractPlanMessagesForTurn,
|
|
14184
|
+
formatExecutionDuration,
|
|
14136
14185
|
buildCitationsFromToolCalls,
|
|
14137
14186
|
LOOPBACK_HOSTS,
|
|
14138
14187
|
isLoopbackUrl,
|
|
@@ -14181,7 +14230,6 @@ export {
|
|
|
14181
14230
|
toolCallAnswered,
|
|
14182
14231
|
defaultTurnDisplayMode,
|
|
14183
14232
|
resolveTurnDisplayMode,
|
|
14184
|
-
formatExecutionDuration,
|
|
14185
14233
|
getExecutionDurationMs,
|
|
14186
14234
|
AssistantTurnBlock,
|
|
14187
14235
|
collectMemoryRefs,
|
|
@@ -14246,4 +14294,4 @@ use-stick-to-bottom/dist/StickToBottom.js:
|
|
|
14246
14294
|
js-yaml/dist/js-yaml.mjs:
|
|
14247
14295
|
(*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT *)
|
|
14248
14296
|
*/
|
|
14249
|
-
//# sourceMappingURL=chunk-
|
|
14297
|
+
//# sourceMappingURL=chunk-GZWQVVE7.js.map
|