@blade-hq/agent-react 2612.0.0-beta.113 → 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.
@@ -5,14 +5,14 @@ import {
5
5
  catalogToConnectorItems,
6
6
  filterConnectorItems,
7
7
  useSessionPluginActivation
8
- } from "./chunk-M6SNZHK3.js";
8
+ } from "./chunk-HV3NKRZ2.js";
9
9
  import {
10
10
  ConnectorConnection
11
11
  } from "./chunk-22JUW3EQ.js";
12
12
  import {
13
13
  AccountConnectorRules,
14
14
  BrowserConnectionDialog
15
- } from "./chunk-AZVPNN6K.js";
15
+ } from "./chunk-AMWLYUD7.js";
16
16
  import {
17
17
  ConfigConnection,
18
18
  Dialog,
@@ -804,4 +804,4 @@ export {
804
804
  ConnectorPanel,
805
805
  PluginTriggerStack
806
806
  };
807
- //# sourceMappingURL=chunk-VYTLF6JE.js.map
807
+ //# sourceMappingURL=chunk-C3G6F7UG.js.map
@@ -16,16 +16,16 @@ import {
16
16
  useEffectEvent,
17
17
  useSessionPluginActivation,
18
18
  useSessionSkills
19
- } from "./chunk-M6SNZHK3.js";
19
+ } from "./chunk-HV3NKRZ2.js";
20
20
  import {
21
21
  ImageLightbox,
22
22
  MessageImage,
23
23
  ToolUiCardView,
24
24
  getRenderer
25
- } from "./chunk-XLG3BTUA.js";
25
+ } from "./chunk-7UQ3RWAU.js";
26
26
  import {
27
27
  MarkdownContent
28
- } from "./chunk-5JDQG2JJ.js";
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-AZVPNN6K.js";
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,
@@ -3025,12 +3028,14 @@ function useAutoResizeTextarea(value) {
3025
3028
  }, []);
3026
3029
  return textareaRef;
3027
3030
  }
3028
- function AskUserQuestionBlock({
3031
+ function AskUserQuestionBlock(props) {
3032
+ return /* @__PURE__ */ jsx15(AskUserQuestionCard, { ...props }, props.toolCallId);
3033
+ }
3034
+ function AskUserQuestionCard({
3029
3035
  data,
3030
3036
  answered,
3031
3037
  readOnly = false,
3032
3038
  toolCallId,
3033
- sessionStatus,
3034
3039
  answerData,
3035
3040
  onAnswer
3036
3041
  }) {
@@ -3039,14 +3044,10 @@ function AskUserQuestionBlock({
3039
3044
  const [usingCustom, setUsingCustom] = useState14(/* @__PURE__ */ new Set());
3040
3045
  const [note, setNote] = useState14("");
3041
3046
  const [submitted, setSubmitted] = useState14(false);
3042
- const locked = answered || readOnly;
3043
- useEffect11(() => {
3044
- if (sessionStatus === "failed" || sessionStatus === "interrupted") {
3045
- setSubmitted(false);
3046
- }
3047
- }, [sessionStatus]);
3047
+ const hasAnswer = answered || Boolean(answerData);
3048
+ const locked = hasAnswer || readOnly || !onAnswer;
3048
3049
  const displayAnswerState = useMemo6(() => {
3049
- if (!(answered && answerData)) {
3050
+ if (!answerData) {
3050
3051
  return {
3051
3052
  selections,
3052
3053
  customTexts,
@@ -3071,7 +3072,7 @@ function AskUserQuestionBlock({
3071
3072
  usingCustom: nextUsingCustom,
3072
3073
  note: answerData.note ?? ""
3073
3074
  };
3074
- }, [answerData, answered, customTexts, note, selections, usingCustom]);
3075
+ }, [answerData, customTexts, note, selections, usingCustom]);
3075
3076
  const displaySelections = displayAnswerState.selections;
3076
3077
  const displayCustomTexts = displayAnswerState.customTexts;
3077
3078
  const displayUsingCustom = displayAnswerState.usingCustom;
@@ -3121,7 +3122,7 @@ function AskUserQuestionBlock({
3121
3122
  return [...sel].sort().map((i) => q.options[i].label).join(", ");
3122
3123
  };
3123
3124
  const allAnswered = data.questions.every((_, i) => getAnswer(i) !== null);
3124
- const handleSubmit = () => {
3125
+ const handleSubmit = async () => {
3125
3126
  if (locked || submitted || !allAnswered || !onAnswer) return;
3126
3127
  const trimmedNote = note.trim();
3127
3128
  const nextAnswerData = {
@@ -3138,7 +3139,22 @@ function AskUserQuestionBlock({
3138
3139
  };
3139
3140
  const text = formatAskUserAnswer(data, nextAnswerData);
3140
3141
  setSubmitted(true);
3141
- onAnswer(text, toolCallId, nextAnswerData);
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
+ }
3142
3158
  };
3143
3159
  return /* @__PURE__ */ jsxs14(
3144
3160
  "div",
@@ -3153,7 +3169,7 @@ function AskUserQuestionBlock({
3153
3169
  "\u5B50\u667A\u80FD\u4F53\u300C",
3154
3170
  data.source_loop.description,
3155
3171
  "\u300D",
3156
- readOnly ? "\u66FE\u53D1\u8D77\u63D0\u95EE" : "\u5728\u7B49\u5F85\u4F60\u7684\u56DE\u7B54"
3172
+ locked ? "\u66FE\u53D1\u8D77\u63D0\u95EE" : "\u5728\u7B49\u5F85\u4F60\u7684\u56DE\u7B54"
3157
3173
  ] }),
3158
3174
  data.questions.map((q, qIdx) => /* @__PURE__ */ jsx15(
3159
3175
  QuestionCard,
@@ -3179,7 +3195,8 @@ function AskUserQuestionBlock({
3179
3195
  onChange: setNote
3180
3196
  }
3181
3197
  ),
3182
- !locked && !submitted && onAnswer && /* @__PURE__ */ jsx15(
3198
+ !readOnly && locked && !hasAnswer && /* @__PURE__ */ jsx15("div", { className: "text-xs", children: "\u5DF2\u7ED3\u675F" }),
3199
+ !locked && !submitted && /* @__PURE__ */ jsx15(
3183
3200
  "button",
3184
3201
  {
3185
3202
  type: "button",
@@ -7359,13 +7376,11 @@ function ToolPreviewAction({
7359
7376
  function resolveAskQuestionState({
7360
7377
  toolStatus,
7361
7378
  hasAnswerData,
7362
- fallbackAnswered,
7363
- fallbackAwaiting
7379
+ fallbackAnswered
7364
7380
  }) {
7365
- const awaitingAnswer = !hasAnswerData && (toolStatus === "awaiting_answer" || toolStatus === "pending" && fallbackAwaiting === true);
7366
7381
  return {
7367
- awaitingAnswer,
7368
- answered: hasAnswerData || !awaitingAnswer && (Boolean(fallbackAnswered) || toolStatus === "done" || toolStatus === "cancelled" || toolStatus === "error")
7382
+ awaitingAnswer: !hasAnswerData && toolStatus === "awaiting_answer",
7383
+ answered: hasAnswerData || toolStatus !== "awaiting_answer" && Boolean(fallbackAnswered)
7369
7384
  };
7370
7385
  }
7371
7386
  function ToolCallBlock({
@@ -7375,7 +7390,6 @@ function ToolCallBlock({
7375
7390
  answerData,
7376
7391
  sessionId: providedSessionId,
7377
7392
  sessionStatus,
7378
- isActiveQuestion,
7379
7393
  level = 1,
7380
7394
  turnBlocks,
7381
7395
  reasoning,
@@ -7392,12 +7406,10 @@ function ToolCallBlock({
7392
7406
  const isSessionReadonly = useSessionState(resolvedSessionId, isReadOnlySession);
7393
7407
  const readOnly = useReadOnlyChat() || isSessionReadonly;
7394
7408
  const answerCallback = useMemo10(
7395
- () => session && !readOnly ? (answer, toolCallId, data) => {
7396
- void sendToSession(session, answer, session.getState().mode ?? void 0, {
7397
- tool_call_id: toolCallId,
7398
- ...data
7399
- });
7400
- } : 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,
7401
7413
  [readOnly, session]
7402
7414
  );
7403
7415
  useEffect13(() => {
@@ -7407,7 +7419,6 @@ function ToolCallBlock({
7407
7419
  }, [shouldAutoExpandWhileStreaming]);
7408
7420
  const resolvedSessionStatus = sessionStatus ?? liveSessionStatus ?? void 0;
7409
7421
  const resolvedAnswerData = answerData ?? storedAnswerData;
7410
- const resolvedAnswered = toolCall.status === "awaiting_answer" ? false : answered ?? (!!resolvedAnswerData && resolvedSessionStatus !== "waiting_for_input");
7411
7422
  const resolvedOnAnswer = readOnly ? void 0 : onAnswer ?? answerCallback;
7412
7423
  if (isWorkflowRunToolName(toolCall.name)) {
7413
7424
  return null;
@@ -7417,8 +7428,7 @@ function ToolCallBlock({
7417
7428
  const questionState = resolveAskQuestionState({
7418
7429
  toolStatus: toolCall.status,
7419
7430
  hasAnswerData: Boolean(resolvedAnswerData),
7420
- fallbackAnswered: resolvedAnswered,
7421
- fallbackAwaiting: isActiveQuestion === true && (resolvedSessionStatus === "paused" || resolvedSessionStatus === "waiting_for_input")
7431
+ fallbackAnswered: answered
7422
7432
  });
7423
7433
  const canAnswer = questionState.awaitingAnswer && Boolean(resolvedOnAnswer);
7424
7434
  const customQuestion = askData ? customization?.renderers?.askUserQuestion?.({
@@ -8901,8 +8911,7 @@ function toolCallAnswered(toolCall, sessionStatus, answerData) {
8901
8911
  if (formatToolName(toolCall.name) !== "AskUserQuestion") {
8902
8912
  return sessionStatus !== "waiting_for_input";
8903
8913
  }
8904
- if (answerData) return true;
8905
- return !(toolCall.status === "awaiting_answer" || toolCall.status === "done" && sessionStatus === "waiting_for_input");
8914
+ return Boolean(answerData);
8906
8915
  }
8907
8916
 
8908
8917
  // src/chat/AssistantTurnBlock.tsx
@@ -9430,14 +9439,13 @@ function PersistentAskUserQuestions({
9430
9439
  level,
9431
9440
  customization
9432
9441
  }) {
9433
- const activeQuestionId = questions.filter(({ toolCall }) => toolCall.status === "pending").at(-1)?.toolCall.id;
9434
9442
  return questions.map(
9435
9443
  ({ toolCall, turnBlocks }) => customization?.components?.ToolCall ? /* @__PURE__ */ jsx31(
9436
9444
  customization.components.ToolCall,
9437
9445
  {
9438
9446
  toolCall,
9439
9447
  answerData: askAnswers?.[toolCall.id],
9440
- onAnswer,
9448
+ onAnswer: toolCall.status === "awaiting_answer" ? onAnswer : void 0,
9441
9449
  answered: toolCallAnswered(toolCall, sessionStatus, askAnswers?.[toolCall.id]),
9442
9450
  sessionId,
9443
9451
  sessionStatus,
@@ -9455,7 +9463,6 @@ function PersistentAskUserQuestions({
9455
9463
  answered: toolCallAnswered(toolCall, sessionStatus, askAnswers?.[toolCall.id]),
9456
9464
  sessionId,
9457
9465
  sessionStatus,
9458
- isActiveQuestion: toolCall.id === activeQuestionId,
9459
9466
  level,
9460
9467
  turnBlocks,
9461
9468
  customization
@@ -12936,13 +12943,8 @@ function ChatPanel({
12936
12943
  [mode, sendUserMessage]
12937
12944
  );
12938
12945
  const answerQuestion = useCallback15(
12939
- (msg, toolCallId, answerData) => {
12940
- void sendUserMessage(msg, mode, {
12941
- tool_call_id: toolCallId,
12942
- ...answerData
12943
- });
12944
- },
12945
- [mode, sendUserMessage]
12946
+ (msg, toolCallId, answerData, signal) => send(msg, mode, { tool_call_id: toolCallId, ...answerData }, { signal }),
12947
+ [mode, send]
12946
12948
  );
12947
12949
  const moveQueuedMessage = useCallback15(
12948
12950
  (item, delta) => {
@@ -13076,7 +13078,7 @@ function ChatPanel({
13076
13078
  postChatFollowup,
13077
13079
  resultFeedbackByEntry,
13078
13080
  onResultFeedbackSaved: handleResultFeedbackSaved,
13079
- onAnswer: isViewer ? void 0 : (msg, toolCallId, answerData) => void send(msg, mode, { tool_call_id: toolCallId, ...answerData }),
13081
+ onAnswer: isViewer ? void 0 : answerQuestion,
13080
13082
  isStopping,
13081
13083
  onRevealingChange: setIsRevealing,
13082
13084
  isReplay
@@ -14292,4 +14294,4 @@ use-stick-to-bottom/dist/StickToBottom.js:
14292
14294
  js-yaml/dist/js-yaml.mjs:
14293
14295
  (*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT *)
14294
14296
  */
14295
- //# sourceMappingURL=chunk-5XLLPGSU.js.map
14297
+ //# sourceMappingURL=chunk-GZWQVVE7.js.map