@blade-hq/agent-react 2610.0.6 → 2610.0.8-beta.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/README.md CHANGED
@@ -33,6 +33,8 @@ export function App() {
33
33
  - 不传 `sessionId` 自动创建新会话;未登录时 `ChatView` 自己渲染登录按钮(弹窗授权,见 agent-client 的 `client.auth.login()`)。
34
34
  - 同一 `BladeProvider` 下可以放多个 `ChatView`,各自独立会话、互不干扰。
35
35
 
36
+ 智能体会话的输入框提供「添加附件」按钮。选中的文件会上传到当前会话工作区,发送时随消息附上文件路径。
37
+
36
38
  ## BladeProvider
37
39
 
38
40
  只负责 client 级共享(一条 Socket 连接、一份鉴权),不含任何全局状态。
@@ -1,3 +1,4 @@
1
+ import { type ReactNode } from "react";
1
2
  interface Props {
2
3
  /** 受控输入内容(由 ChatView 持有,便于 attach/insertText 注入)。 */
3
4
  value: string;
@@ -28,11 +29,13 @@ interface Props {
28
29
  toolbarClassName?: string;
29
30
  queueKey?: string;
30
31
  hasAttachments?: boolean;
32
+ attachmentPicker?: ReactNode;
33
+ attachmentsBlocked?: boolean;
31
34
  }
32
35
  /**
33
36
  * 轻量聊天输入框:textarea(Enter 发送 / Shift+Enter 换行)+ 发送/停止按钮。
34
37
  * 不含第一方版本的富文本编辑、@ 补全、技能菜单、语音输入与模型选择。
35
38
  * 内容受控,session.attach() / insertText() 通过 ChatView 注入到这里。
36
39
  */
37
- export declare function ChatInput({ value, onValueChange, onSend, onStop, isStreaming, isStopping, queueWhileRunning, mergesWithPanelAbove, placeholder, className, innerClassName, textareaClassName, toolbarClassName, queueKey, hasAttachments, }: Props): import("react/jsx-runtime").JSX.Element;
40
+ export declare function ChatInput({ value, onValueChange, onSend, onStop, isStreaming, isStopping, queueWhileRunning, mergesWithPanelAbove, placeholder, className, innerClassName, textareaClassName, toolbarClassName, queueKey, hasAttachments, attachmentPicker, attachmentsBlocked, }: Props): import("react/jsx-runtime").JSX.Element;
38
41
  export {};
@@ -1,4 +1,4 @@
1
- import type { AskUserAnswerData, ChatMessage, ConnectionStatus, PostChatFollowup } from "@blade-hq/agent-client";
1
+ import type { AskUserAnswerData, BladeClient, ChatMessage, ConnectionStatus, PostChatFollowup } from "@blade-hq/agent-client";
2
2
  import { type ReactNode } from "react";
3
3
  import type { TurnNavigationSource } from "../hooks/use-turn-navigation";
4
4
  import type { ToolCallRenderer } from "./ToolCallBlock";
@@ -146,7 +146,8 @@ interface ChatSurfaceProps extends ChatPresentationProps {
146
146
  inputText: string;
147
147
  onInputChange: (value: string) => void;
148
148
  onSuggestion?: (value: string) => void;
149
- onSend: (text: string) => Promise<boolean>;
149
+ onSend: (text: string, hasAttachments?: boolean) => Promise<boolean>;
150
+ uploadFiles?: BladeClient["sessions"]["uploadFiles"];
150
151
  onStop: () => void;
151
152
  sessionStatus?: string;
152
153
  askAnswers?: Record<string, AskUserAnswerData>;
@@ -195,5 +196,5 @@ interface ChatSurfaceProps extends ChatPresentationProps {
195
196
  * 这里的 DOM 结构受 tests/chat-view-compat.test.tsx 的快照保护——接入方拿
196
197
  * .blade-chat-* 类名写了自己的样式,结构一动他们的页面就歪。
197
198
  */
198
- export declare function ChatSurface({ theme, classNames, renderers, slots, placeholder, connection, errorMessage, messages, postChatFollowup, isStreaming, isStopping, inputText, onInputChange, onSuggestion, onSend, onStop, sessionStatus, askAnswers, onAnswer, sessionId, isViewer, resultFeedbackByEntry, onResultFeedbackSaved, onFollowupInteraction, beforeInput, queuePanel, queuePanelVisible, showPlanUpdates, planRevealRevision, historyPaging, turnNavigation, banner, onRevealingChange, isReplay, }: ChatSurfaceProps): import("react/jsx-runtime").JSX.Element;
199
+ export declare function ChatSurface({ theme, classNames, renderers, slots, placeholder, connection, errorMessage, messages, postChatFollowup, isStreaming, isStopping, inputText, onInputChange, onSuggestion, onSend, uploadFiles, onStop, sessionStatus, askAnswers, onAnswer, sessionId, isViewer, resultFeedbackByEntry, onResultFeedbackSaved, onFollowupInteraction, beforeInput, queuePanel, queuePanelVisible, showPlanUpdates, planRevealRevision, historyPaging, turnNavigation, banner, onRevealingChange, isReplay, }: ChatSurfaceProps): import("react/jsx-runtime").JSX.Element;
199
200
  export {};
@@ -0,0 +1,2 @@
1
+ /** Embedded chat keeps tool steps visible by default after each turn. */
2
+ export declare const KeepToolStepsOpenContext: import("react").Context<boolean>;
package/dist/index.js CHANGED
@@ -1550,7 +1550,7 @@ var require_react_is_development = __commonJS({
1550
1550
  var ContextProvider = REACT_PROVIDER_TYPE;
1551
1551
  var Element2 = REACT_ELEMENT_TYPE;
1552
1552
  var ForwardRef = REACT_FORWARD_REF_TYPE;
1553
- var Fragment12 = REACT_FRAGMENT_TYPE;
1553
+ var Fragment13 = REACT_FRAGMENT_TYPE;
1554
1554
  var Lazy = REACT_LAZY_TYPE;
1555
1555
  var Memo = REACT_MEMO_TYPE;
1556
1556
  var Portal3 = REACT_PORTAL_TYPE;
@@ -1618,7 +1618,7 @@ var require_react_is_development = __commonJS({
1618
1618
  exports.ContextProvider = ContextProvider;
1619
1619
  exports.Element = Element2;
1620
1620
  exports.ForwardRef = ForwardRef;
1621
- exports.Fragment = Fragment12;
1621
+ exports.Fragment = Fragment13;
1622
1622
  exports.Lazy = Lazy;
1623
1623
  exports.Memo = Memo;
1624
1624
  exports.Portal = Portal3;
@@ -2989,7 +2989,7 @@ function TurnNavRail({
2989
2989
 
2990
2990
  // src/components/AgentChat.tsx
2991
2991
  import {
2992
- BladeApiError as BladeApiError2,
2992
+ BladeApiError as BladeApiError3,
2993
2993
  canEditQueuedMessage as canEditQueuedMessage2,
2994
2994
  EMPTY_SESSION_QUEUE,
2995
2995
  latestPostChatFollowup
@@ -3315,6 +3315,18 @@ var Minimize2 = createLucideIcon("Minimize2", [
3315
3315
  ["line", { x1: "3", x2: "10", y1: "21", y2: "14", key: "1atl0r" }]
3316
3316
  ]);
3317
3317
 
3318
+ // ../../node_modules/.pnpm/lucide-react@0.468.0_react@19.2.4/node_modules/lucide-react/dist/esm/icons/paperclip.js
3319
+ var Paperclip = createLucideIcon("Paperclip", [
3320
+ ["path", { d: "M13.234 20.252 21 12.3", key: "1cbrk9" }],
3321
+ [
3322
+ "path",
3323
+ {
3324
+ d: "m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",
3325
+ key: "1pkts6"
3326
+ }
3327
+ ]
3328
+ ]);
3329
+
3318
3330
  // ../../node_modules/.pnpm/lucide-react@0.468.0_react@19.2.4/node_modules/lucide-react/dist/esm/icons/pencil.js
3319
3331
  var Pencil = createLucideIcon("Pencil", [
3320
3332
  [
@@ -3449,7 +3461,7 @@ var X = createLucideIcon("X", [
3449
3461
  ]);
3450
3462
 
3451
3463
  // src/components/AgentChat.tsx
3452
- import { useCallback as useCallback30, useEffect as useEffect28, useMemo as useMemo18, useRef as useRef30, useState as useState37 } from "react";
3464
+ import { useCallback as useCallback30, useEffect as useEffect28, useMemo as useMemo18, useRef as useRef31, useState as useState37 } from "react";
3453
3465
 
3454
3466
  // src/components/SessionPluginSelector.tsx
3455
3467
  import { useEffect as useEffect15, useState as useState20 } from "react";
@@ -21007,8 +21019,8 @@ function CurrentPlanPanel({
21007
21019
  }
21008
21020
 
21009
21021
  // src/components/ChatSurface.tsx
21010
- import { chatErrorForDisplay as chatErrorForDisplay2 } from "@blade-hq/agent-client";
21011
- import { useMemo as useMemo17, useState as useState36 } from "react";
21022
+ import { BladeApiError as BladeApiError2, buildMessageContent, chatErrorForDisplay as chatErrorForDisplay2, getTextContent as getTextContent4 } from "@blade-hq/agent-client";
21023
+ import { useMemo as useMemo17, useRef as useRef30, useState as useState36 } from "react";
21012
21024
 
21013
21025
  // src/lib/random-id.ts
21014
21026
  function randomId() {
@@ -46244,7 +46256,9 @@ function ChatInput({
46244
46256
  textareaClassName,
46245
46257
  toolbarClassName,
46246
46258
  queueKey,
46247
- hasAttachments = false
46259
+ hasAttachments = false,
46260
+ attachmentPicker,
46261
+ attachmentsBlocked = false
46248
46262
  }) {
46249
46263
  const trimmed = value.trim();
46250
46264
  const latestValue = useRef19(value);
@@ -46252,7 +46266,7 @@ function ChatInput({
46252
46266
  const sending = useRef19(false);
46253
46267
  const [isSending2, setIsSending] = useState25(false);
46254
46268
  void queueKey;
46255
- const canSend = !isSending2 && (trimmed.length > 0 || hasAttachments) && (!isStreaming || queueWhileRunning && !hasAttachments && !isStopping);
46269
+ const canSend = !isSending2 && !attachmentsBlocked && (trimmed.length > 0 || hasAttachments) && (!isStreaming || queueWhileRunning && !hasAttachments && !isStopping);
46256
46270
  const handleSend = async () => {
46257
46271
  if (!canSend || sending.current) return;
46258
46272
  sending.current = true;
@@ -46321,21 +46335,24 @@ function ChatInput({
46321
46335
  )
46322
46336
  }
46323
46337
  ),
46324
- /* @__PURE__ */ jsx14("div", { part: "input-toolbar", className: cn("blade-chat-input-toolbar flex shrink-0 items-center gap-2", toolbarClassName), children: isStreaming ? /* @__PURE__ */ jsxs11(Fragment5, { children: [
46325
- queueWhileRunning ? /* @__PURE__ */ jsx14("button", { type: "button", onClick: handleSend, disabled: !canSend, "aria-label": "\u52A0\u5165\u6392\u961F", title: "\u52A0\u5165\u6392\u961F", className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] disabled:opacity-40", children: /* @__PURE__ */ jsx14(ArrowUp, { size: 15 }) }) : null,
46326
- /* @__PURE__ */ jsx14("button", { type: "button", onClick: onStop, disabled: isStopping, "aria-label": isStopping ? "\u6B63\u5728\u505C\u6B62" : "\u505C\u6B62\u56DE\u590D", title: isStopping ? "\u6B63\u5728\u505C\u6B62" : "\u505C\u6B62\u56DE\u590D", className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-[hsl(var(--muted))] text-[hsl(var(--foreground))] transition-opacity hover:opacity-90 disabled:opacity-60", children: isStopping ? /* @__PURE__ */ jsx14(LoaderCircle, { size: 14, className: "animate-spin" }) : /* @__PURE__ */ jsx14(Square, { size: 12, fill: "currentColor" }) })
46327
- ] }) : /* @__PURE__ */ jsx14(
46328
- "button",
46329
- {
46330
- type: "button",
46331
- onClick: handleSend,
46332
- disabled: !canSend,
46333
- "aria-label": "\u53D1\u9001\u6D88\u606F",
46334
- title: "\u53D1\u9001\u6D88\u606F",
46335
- className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-40",
46336
- children: /* @__PURE__ */ jsx14(ArrowUp, { size: 15 })
46337
- }
46338
- ) })
46338
+ /* @__PURE__ */ jsxs11("div", { part: "input-toolbar", className: cn("blade-chat-input-toolbar flex shrink-0 items-center gap-2", toolbarClassName), children: [
46339
+ attachmentPicker,
46340
+ isStreaming ? /* @__PURE__ */ jsxs11(Fragment5, { children: [
46341
+ queueWhileRunning ? /* @__PURE__ */ jsx14("button", { type: "button", onClick: handleSend, disabled: !canSend, "aria-label": "\u52A0\u5165\u6392\u961F", title: "\u52A0\u5165\u6392\u961F", className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] disabled:opacity-40", children: /* @__PURE__ */ jsx14(ArrowUp, { size: 15 }) }) : null,
46342
+ /* @__PURE__ */ jsx14("button", { type: "button", onClick: onStop, disabled: isStopping, "aria-label": isStopping ? "\u6B63\u5728\u505C\u6B62" : "\u505C\u6B62\u56DE\u590D", title: isStopping ? "\u6B63\u5728\u505C\u6B62" : "\u505C\u6B62\u56DE\u590D", className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-[hsl(var(--muted))] text-[hsl(var(--foreground))] transition-opacity hover:opacity-90 disabled:opacity-60", children: isStopping ? /* @__PURE__ */ jsx14(LoaderCircle, { size: 14, className: "animate-spin" }) : /* @__PURE__ */ jsx14(Square, { size: 12, fill: "currentColor" }) })
46343
+ ] }) : /* @__PURE__ */ jsx14(
46344
+ "button",
46345
+ {
46346
+ type: "button",
46347
+ onClick: handleSend,
46348
+ disabled: !canSend,
46349
+ "aria-label": "\u53D1\u9001\u6D88\u606F",
46350
+ title: "\u53D1\u9001\u6D88\u606F",
46351
+ className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-40",
46352
+ children: /* @__PURE__ */ jsx14(ArrowUp, { size: 15 })
46353
+ }
46354
+ )
46355
+ ] })
46339
46356
  ]
46340
46357
  }
46341
46358
  )
@@ -46947,7 +46964,11 @@ import {
46947
46964
  getTextContent as getTextContent2,
46948
46965
  normalizeMessageContent as normalizeMessageContent2
46949
46966
  } from "@blade-hq/agent-client";
46950
- import { useEffect as useEffect25, useRef as useRef27, useState as useState33 } from "react";
46967
+ import { useContext as useContext6, useEffect as useEffect25, useRef as useRef27, useState as useState33 } from "react";
46968
+
46969
+ // src/components/ExecutionProcessContext.ts
46970
+ import { createContext as createContext6 } from "react";
46971
+ var KeepToolStepsOpenContext = createContext6(false);
46951
46972
 
46952
46973
  // src/components/AgentTaskCard.tsx
46953
46974
  import { useEffect as useEffect22, useState as useState29 } from "react";
@@ -56038,6 +56059,29 @@ var MARKDOWN_COMPONENTS = {
56038
56059
  a: ExternalAnchor
56039
56060
  };
56040
56061
  function MarkdownContent({ children, className, mode, sessionId }) {
56062
+ const client = useOptionalBladeClient();
56063
+ const components = useMemo14(() => {
56064
+ if (!client || !sessionId) return MARKDOWN_COMPONENTS;
56065
+ return {
56066
+ ...MARKDOWN_COMPONENTS,
56067
+ a: (anchorProps) => {
56068
+ const href = anchorProps.href ?? "";
56069
+ const path2 = href.split(/[?#]/, 1)[0];
56070
+ if (!/\.docx$/i.test(path2) || /^(?:[a-z][a-z0-9+.-]*:|[\/#])|\\|(?:^|\/)\.\.(?:\/|$)|%2e|%2f|%5c/i.test(path2)) {
56071
+ return /* @__PURE__ */ jsx20(ExternalAnchor, { ...anchorProps });
56072
+ }
56073
+ let filename = path2.replace(/^\.\//, "");
56074
+ try {
56075
+ filename = decodeURIComponent(filename);
56076
+ } catch {
56077
+ }
56078
+ const fileUrl = client.buildAuthedUrl(
56079
+ `/api/sessions/${encodeURIComponent(sessionId)}/files/${encodeURIComponent(filename)}`
56080
+ );
56081
+ return /* @__PURE__ */ jsx20("a", { ...anchorProps, href: fileUrl, download: true });
56082
+ }
56083
+ };
56084
+ }, [client, sessionId]);
56041
56085
  const resolvedChildren = useMemo14(() => {
56042
56086
  return normalizeAdjacentUrlFormatting(stripSystemReminders(children));
56043
56087
  }, [children]);
@@ -56046,7 +56090,7 @@ function MarkdownContent({ children, className, mode, sessionId }) {
56046
56090
  {
56047
56091
  className: cn("blade-chat-markdown break-words", className),
56048
56092
  mode: mode ?? "static",
56049
- components: MARKDOWN_COMPONENTS,
56093
+ components,
56050
56094
  sessionId,
56051
56095
  children: resolvedChildren
56052
56096
  },
@@ -56978,8 +57022,16 @@ function AssistantTurnBlock({
56978
57022
  (toolCall) => formatToolName(toolCall.name) !== "AskUserQuestion" && !shouldHideToolCall(finalMessage, toolCall)
56979
57023
  )
56980
57024
  ) : [];
56981
- const hasExecutionProcess = messages.some(
56982
- (message) => message.reasoning || (message.tool_calls ?? []).some((toolCall) => !shouldHideToolCall(message, toolCall))
57025
+ const keepToolStepsOpen = useContext6(KeepToolStepsOpenContext);
57026
+ const hasToolSteps = messages.some(
57027
+ (message) => (message.tool_calls ?? []).some(
57028
+ (toolCall) => formatToolName(toolCall.name) !== "AskUserQuestion" && !shouldHideToolCall(message, toolCall)
57029
+ )
57030
+ );
57031
+ const hasExecutionProcess = hasToolSteps || messages.some(
57032
+ (message) => message.reasoning || (message.tool_calls ?? []).some(
57033
+ (toolCall) => formatToolName(toolCall.name) === "AskUserQuestion"
57034
+ )
56983
57035
  );
56984
57036
  const latestReasoningIndex = isStreaming ? findLatestReasoningMessageIndex(messages) : -1;
56985
57037
  const hasActionableToolCall = messages.some(
@@ -56996,15 +57048,18 @@ function AssistantTurnBlock({
56996
57048
  const [displayMode, setDisplayMode] = useState33(
56997
57049
  () => isStreaming || hasActionableToolCall ? "detail" : "compact"
56998
57050
  );
56999
- const userSelectedDisplayModeRef = useRef27(false);
57051
+ const [selectedDisplayMode, setSelectedDisplayMode] = useState33();
57000
57052
  const wasStreamingRef = useRef27(isStreaming);
57001
57053
  useEffect25(() => {
57002
- if (wasStreamingRef.current && !isStreaming && !userSelectedDisplayModeRef.current) {
57054
+ if (wasStreamingRef.current && !isStreaming && selectedDisplayMode === void 0) {
57003
57055
  setDisplayMode(hasActionableToolCall ? "detail" : "compact");
57004
57056
  }
57005
57057
  wasStreamingRef.current = isStreaming;
57006
- }, [hasActionableToolCall, isStreaming]);
57007
- const effectiveMode = resolveTurnDisplayMode({ isStreaming, displayMode });
57058
+ }, [hasActionableToolCall, isStreaming, selectedDisplayMode]);
57059
+ const effectiveMode = resolveTurnDisplayMode({
57060
+ isStreaming,
57061
+ displayMode: selectedDisplayMode ?? (keepToolStepsOpen && hasToolSteps ? "detail" : displayMode)
57062
+ });
57008
57063
  const client = useOptionalBladeClient();
57009
57064
  const clockNow = isStreaming ? sessionId ? getServerTime(client) : Date.now() : null;
57010
57065
  const executionDurationMs = getExecutionDurationMs({
@@ -57084,10 +57139,7 @@ function AssistantTurnBlock({
57084
57139
  "button",
57085
57140
  {
57086
57141
  type: "button",
57087
- onClick: () => {
57088
- userSelectedDisplayModeRef.current = true;
57089
- setDisplayMode(displayMode === "detail" ? "compact" : "detail");
57090
- },
57142
+ onClick: () => setSelectedDisplayMode(effectiveMode === "detail" ? "compact" : "detail"),
57091
57143
  "aria-expanded": effectiveMode === "detail",
57092
57144
  "aria-label": effectiveMode === "detail" ? "\u6536\u8D77\u6267\u884C\u8FC7\u7A0B" : "\u5C55\u5F00\u6267\u884C\u8FC7\u7A0B",
57093
57145
  "data-testid": "assistant-execution-summary",
@@ -58539,7 +58591,7 @@ function StopAutoScrollBridge({ stopRef }) {
58539
58591
  }
58540
58592
 
58541
58593
  // src/components/ChatSurface.tsx
58542
- import { jsx as jsx31, jsxs as jsxs25 } from "react/jsx-runtime";
58594
+ import { Fragment as Fragment9, jsx as jsx31, jsxs as jsxs25 } from "react/jsx-runtime";
58543
58595
  function themeAttr(theme) {
58544
58596
  return theme === "dark" ? "dark" : void 0;
58545
58597
  }
@@ -58559,6 +58611,7 @@ function ChatSurface({
58559
58611
  onInputChange,
58560
58612
  onSuggestion,
58561
58613
  onSend,
58614
+ uploadFiles,
58562
58615
  onStop,
58563
58616
  sessionStatus,
58564
58617
  askAnswers,
@@ -58581,13 +58634,45 @@ function ChatSurface({
58581
58634
  }) {
58582
58635
  const [pending, setPending] = useState36([]);
58583
58636
  const currentPending = pending.filter((item) => item.sessionId === sessionId);
58637
+ const [pendingFiles, setPendingFiles] = useState36([]);
58638
+ const selection = useRef30(null);
58639
+ const currentFiles = pendingFiles.filter((item) => item.sessionId === sessionId);
58640
+ const attachmentsBlocked = currentFiles.some((file2) => !file2.path);
58641
+ const hasAttachments = currentPending.length > 0 || currentFiles.length > 0;
58642
+ async function addFiles(files) {
58643
+ if (!sessionId || !uploadFiles || isViewer || files.length === 0) return;
58644
+ const entries = files.map((file2) => ({ id: randomId(), sessionId, name: file2.name }));
58645
+ const indices = new Map(entries.map((item, index3) => [item.id, index3]));
58646
+ setPendingFiles((items) => [...items, ...entries]);
58647
+ try {
58648
+ const result = await uploadFiles(sessionId, ".", files);
58649
+ const outcomes = new Map(result.results?.map((item) => [item.index, item]));
58650
+ setPendingFiles((items) => items.map((item) => {
58651
+ const index3 = indices.get(item.id);
58652
+ if (index3 === void 0) return item;
58653
+ const outcome = outcomes.get(index3);
58654
+ return outcome?.path ? { ...item, path: outcome.path } : { ...item, error: outcome?.error === "too_large" ? "\u6587\u4EF6\u8D85\u8FC7\u5927\u5C0F\u9650\u5236" : outcome?.error || "\u4E0A\u4F20\u6587\u4EF6\u5931\u8D25" };
58655
+ }));
58656
+ } catch (error61) {
58657
+ const message = error61 instanceof BladeApiError2 ? error61.message : "\u4E0A\u4F20\u6587\u4EF6\u5931\u8D25";
58658
+ setPendingFiles((items) => items.map((item) => indices.has(item.id) ? { ...item, error: message } : item));
58659
+ }
58660
+ }
58584
58661
  const sendWithApps = async (text4) => {
58662
+ if (attachmentsBlocked) return false;
58585
58663
  const content3 = [...currentPending.map((item) => `[${item.label}]
58586
58664
  ${item.content}`), text4].filter(Boolean).join("\n\n");
58587
- const accepted = await onSend(content3);
58665
+ const message = getTextContent4(buildMessageContent(content3, currentFiles.map((file2) => ({
58666
+ kind: "file",
58667
+ name: file2.name,
58668
+ uploadedPath: file2.path
58669
+ }))));
58670
+ const accepted = currentFiles.length > 0 ? await onSend(message, true) : await onSend(message);
58588
58671
  if (accepted) {
58589
58672
  const sent = new Set(currentPending.map((item) => item.id));
58590
58673
  setPending((items) => items.filter((item) => !sent.has(item.id)));
58674
+ const sentFiles = new Set(currentFiles.map((item) => item.id));
58675
+ setPendingFiles((items) => items.filter((item) => !sentFiles.has(item.id)));
58591
58676
  }
58592
58677
  return accepted;
58593
58678
  };
@@ -58661,7 +58746,7 @@ ${item.content}`), text4].filter(Boolean).join("\n\n");
58661
58746
  }
58662
58747
  ) : null,
58663
58748
  beforeInput,
58664
- /* @__PURE__ */ jsx31(QueuePanelAdjacencyContext.Provider, { value: currentPending.length === 0, children: queuePanel }),
58749
+ /* @__PURE__ */ jsx31(QueuePanelAdjacencyContext.Provider, { value: !hasAttachments, children: queuePanel }),
58665
58750
  currentPending.map((item) => /* @__PURE__ */ jsxs25("div", { style: { display: "flex", gap: 8, padding: "8px 16px" }, children: [
58666
58751
  /* @__PURE__ */ jsxs25("details", { style: { flex: 1, minWidth: 0 }, children: [
58667
58752
  /* @__PURE__ */ jsx31("summary", { children: item.label }),
@@ -58669,18 +58754,61 @@ ${item.content}`), text4].filter(Boolean).join("\n\n");
58669
58754
  ] }),
58670
58755
  /* @__PURE__ */ jsx31("button", { type: "button", "aria-label": "\u79FB\u9664\u5F85\u53D1\u9001\u5185\u5BB9", title: "\u79FB\u9664", onClick: () => setPending((items) => items.filter((other) => other.id !== item.id)), children: /* @__PURE__ */ jsx31(X, { size: 16 }) })
58671
58756
  ] }, item.id)),
58757
+ currentFiles.length > 0 && /* @__PURE__ */ jsx31("ul", { "aria-label": "\u5F85\u53D1\u9001\u9644\u4EF6", className: "flex flex-wrap gap-2 px-4 pb-2", children: currentFiles.map((file2) => /* @__PURE__ */ jsxs25("li", { className: "flex min-w-0 items-center gap-2 rounded-md bg-[hsl(var(--muted))] px-2 py-1 text-xs", children: [
58758
+ /* @__PURE__ */ jsx31(Paperclip, { size: 13, "aria-hidden": "true" }),
58759
+ /* @__PURE__ */ jsx31("span", { className: "truncate", title: file2.name, children: file2.name }),
58760
+ file2.error ? /* @__PURE__ */ jsx31("span", { role: "alert", children: file2.error }) : !file2.path ? /* @__PURE__ */ jsx31("span", { role: "status", children: "\u4E0A\u4F20\u4E2D\u2026" }) : null,
58761
+ /* @__PURE__ */ jsx31(
58762
+ "button",
58763
+ {
58764
+ type: "button",
58765
+ "aria-label": `\u79FB\u9664\u9644\u4EF6 ${file2.name}`,
58766
+ onClick: () => setPendingFiles((items) => items.filter((item) => item.id !== file2.id)),
58767
+ children: /* @__PURE__ */ jsx31(X, { size: 14, "aria-hidden": "true" })
58768
+ }
58769
+ )
58770
+ ] }, file2.id)) }),
58672
58771
  /* @__PURE__ */ jsx31(
58673
58772
  ChatInput,
58674
58773
  {
58675
58774
  value: inputText,
58676
58775
  onValueChange: onInputChange,
58677
58776
  onSend: sendWithApps,
58678
- hasAttachments: currentPending.length > 0,
58777
+ hasAttachments,
58778
+ attachmentsBlocked,
58779
+ attachmentPicker: uploadFiles && sessionId && !isViewer ? /* @__PURE__ */ jsxs25(Fragment9, { children: [
58780
+ /* @__PURE__ */ jsx31(
58781
+ "input",
58782
+ {
58783
+ ref: selection,
58784
+ type: "file",
58785
+ multiple: true,
58786
+ hidden: true,
58787
+ "aria-label": "\u9009\u62E9\u9644\u4EF6",
58788
+ onChange: (event) => {
58789
+ const files = Array.from(event.currentTarget.files ?? []);
58790
+ event.currentTarget.value = "";
58791
+ void addFiles(files);
58792
+ }
58793
+ }
58794
+ ),
58795
+ /* @__PURE__ */ jsx31(
58796
+ "button",
58797
+ {
58798
+ type: "button",
58799
+ "aria-label": "\u6DFB\u52A0\u9644\u4EF6",
58800
+ title: "\u6DFB\u52A0\u9644\u4EF6",
58801
+ onClick: () => selection.current?.click(),
58802
+ className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-md hover:bg-[hsl(var(--muted))]",
58803
+ children: /* @__PURE__ */ jsx31(Paperclip, { size: 16, "aria-hidden": "true" })
58804
+ }
58805
+ )
58806
+ ] }) : void 0,
58679
58807
  onStop,
58680
58808
  isStreaming,
58681
58809
  isStopping,
58682
58810
  queueWhileRunning: queuePanel != null,
58683
- mergesWithPanelAbove: (queuePanelVisible ?? queuePanel != null) && currentPending.length === 0,
58811
+ mergesWithPanelAbove: (queuePanelVisible ?? queuePanel != null) && !hasAttachments,
58684
58812
  placeholder,
58685
58813
  queueKey: sessionId,
58686
58814
  className: classNames?.chatInput,
@@ -58696,9 +58824,9 @@ ${item.content}`), text4].filter(Boolean).join("\n\n");
58696
58824
  }
58697
58825
 
58698
58826
  // src/components/AgentChat.tsx
58699
- import { Fragment as Fragment9, jsx as jsx32, jsxs as jsxs26 } from "react/jsx-runtime";
58827
+ import { Fragment as Fragment10, jsx as jsx32, jsxs as jsxs26 } from "react/jsx-runtime";
58700
58828
  function isUnauthorizedError(error61) {
58701
- return error61 instanceof BladeApiError2 && error61.status === 401;
58829
+ return error61 instanceof BladeApiError3 && error61.status === 401;
58702
58830
  }
58703
58831
  function LoginCard({ client, onLoggedIn }) {
58704
58832
  const [loggingIn, setLoggingIn] = useState37(false);
@@ -58806,8 +58934,8 @@ function ChatSessionView({
58806
58934
  const resolvedSessionId = session?.sessionId;
58807
58935
  const isViewer = state?.viewerRole === "viewer";
58808
58936
  const canUseQueue = !isViewer;
58809
- const onSessionReadyRef = useRef30(onSessionReady);
58810
- const readySessionRef = useRef30(null);
58937
+ const onSessionReadyRef = useRef31(onSessionReady);
58938
+ const readySessionRef = useRef31(null);
58811
58939
  const hasOnSessionReady = onSessionReady !== void 0;
58812
58940
  useEffect28(() => {
58813
58941
  onSessionReadyRef.current = onSessionReady;
@@ -58892,11 +59020,11 @@ ${content3}`);
58892
59020
  const isStopping = stopRequested && isStreaming;
58893
59021
  const connectError = error61 && !isUnauthorizedError(error61) ? error61.message || "\u8FDE\u63A5\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5" : null;
58894
59022
  const errorMessage = connectError ?? state?.errorMessage ?? replay.error?.message ?? null;
58895
- const handleSend = (text4) => {
59023
+ const handleSend = (text4, hasAttachments = false) => {
58896
59024
  setStopRequested(false);
58897
59025
  return session?.send(text4, {
58898
59026
  mode: state?.mode ?? void 0,
58899
- queueWhenRunning: canUseQueue
59027
+ queueWhenRunning: canUseQueue && !hasAttachments
58900
59028
  }) ?? Promise.resolve(false);
58901
59029
  };
58902
59030
  const handleStop = () => {
@@ -58954,7 +59082,7 @@ ${content3}`);
58954
59082
  slots,
58955
59083
  placeholder,
58956
59084
  connection: state?.connection ?? "connecting",
58957
- banner: /* @__PURE__ */ jsxs26(Fragment9, { children: [
59085
+ banner: /* @__PURE__ */ jsxs26(Fragment10, { children: [
58958
59086
  resolvedSessionId && !isViewer && (sessionPluginControls ? sessionPluginControls(resolvedSessionId) : /* @__PURE__ */ jsx32(SessionPluginSelector, { client, sessionId: resolvedSessionId })),
58959
59087
  /* @__PURE__ */ jsx32(
58960
59088
  ReplayBar,
@@ -59034,6 +59162,7 @@ ${content3}`);
59034
59162
  onInputChange: setInputText,
59035
59163
  onSuggestion: setInputText,
59036
59164
  onSend: handleSend,
59165
+ uploadFiles: session && !session.isStatic ? ((id, dir, files) => client.sessions.uploadFiles(id, dir, files)) : void 0,
59037
59166
  onStop: handleStop,
59038
59167
  sessionStatus: state?.status ?? void 0,
59039
59168
  askAnswers: state?.askAnswers,
@@ -59271,7 +59400,7 @@ function ChatView(props) {
59271
59400
  }
59272
59401
 
59273
59402
  // src/components/ConnectorPanel.tsx
59274
- import { useCallback as useCallback31, useEffect as useEffect30, useMemo as useMemo20, useRef as useRef31, useState as useState40 } from "react";
59403
+ import { useCallback as useCallback31, useEffect as useEffect30, useMemo as useMemo20, useRef as useRef32, useState as useState40 } from "react";
59275
59404
 
59276
59405
  // src/components/connector-panel-types.ts
59277
59406
  function selectionFromItem(item) {
@@ -59293,7 +59422,7 @@ function triggerSummary(items) {
59293
59422
  }
59294
59423
 
59295
59424
  // src/components/ConnectorPanel.tsx
59296
- import { Fragment as Fragment10, jsx as jsx36, jsxs as jsxs28 } from "react/jsx-runtime";
59425
+ import { Fragment as Fragment11, jsx as jsx36, jsxs as jsxs28 } from "react/jsx-runtime";
59297
59426
  function PanelDivider() {
59298
59427
  return /* @__PURE__ */ jsx36("div", { className: "my-1 border-[hsl(var(--border))] border-t" });
59299
59428
  }
@@ -59371,9 +59500,9 @@ function ConnectorPanel({
59371
59500
  () => items.filter((item) => item.active),
59372
59501
  [items]
59373
59502
  );
59374
- const onSelectedChangeRef = useRef31(onSelectedChange);
59503
+ const onSelectedChangeRef = useRef32(onSelectedChange);
59375
59504
  onSelectedChangeRef.current = onSelectedChange;
59376
- const latestSelected = useRef31(selectedItems);
59505
+ const latestSelected = useRef32(selectedItems);
59377
59506
  latestSelected.current = selectedItems;
59378
59507
  const reportSelected = useCallback31(() => {
59379
59508
  onSelectedChangeRef.current?.(latestSelected.current);
@@ -59395,11 +59524,11 @@ function ConnectorPanel({
59395
59524
  }
59396
59525
  )
59397
59526
  ] }),
59398
- visibleSections.includes("computers") && renderComputerSection ? /* @__PURE__ */ jsxs28(Fragment10, { children: [
59527
+ visibleSections.includes("computers") && renderComputerSection ? /* @__PURE__ */ jsxs28(Fragment11, { children: [
59399
59528
  /* @__PURE__ */ jsx36(PanelTitle, { children: "\u7535\u8111" }),
59400
59529
  renderComputerSection(query)
59401
59530
  ] }) : null,
59402
- visibleSections.includes("plugins") ? /* @__PURE__ */ jsxs28(Fragment10, { children: [
59531
+ visibleSections.includes("plugins") ? /* @__PURE__ */ jsxs28(Fragment11, { children: [
59403
59532
  /* @__PURE__ */ jsx36(PanelDivider, {}),
59404
59533
  /* @__PURE__ */ jsx36(PanelTitle, { children: "\u63D2\u4EF6" }),
59405
59534
  !sessionId ? (
@@ -59442,12 +59571,12 @@ function ConnectorPanel({
59442
59571
  }
59443
59572
  )
59444
59573
  ] }) : null,
59445
- visibleSections.includes("accounts") && renderExternalAccounts ? /* @__PURE__ */ jsxs28(Fragment10, { children: [
59574
+ visibleSections.includes("accounts") && renderExternalAccounts ? /* @__PURE__ */ jsxs28(Fragment11, { children: [
59446
59575
  /* @__PURE__ */ jsx36(PanelDivider, {}),
59447
59576
  /* @__PURE__ */ jsx36(PanelTitle, { children: "\u5916\u90E8\u8D26\u53F7" }),
59448
59577
  renderExternalAccounts(query)
59449
59578
  ] }) : null,
59450
- renderFooterActions ? /* @__PURE__ */ jsxs28(Fragment10, { children: [
59579
+ renderFooterActions ? /* @__PURE__ */ jsxs28(Fragment11, { children: [
59451
59580
  /* @__PURE__ */ jsx36(PanelDivider, {}),
59452
59581
  renderFooterActions()
59453
59582
  ] }) : null
@@ -59593,7 +59722,7 @@ function ContextGroupCard({ contexts, className }) {
59593
59722
  }
59594
59723
 
59595
59724
  // src/components/SessionMemoryToggle.tsx
59596
- import { useCallback as useCallback32, useEffect as useEffect31, useRef as useRef32, useState as useState41, useSyncExternalStore as useSyncExternalStore2 } from "react";
59725
+ import { useCallback as useCallback32, useEffect as useEffect31, useRef as useRef33, useState as useState41, useSyncExternalStore as useSyncExternalStore2 } from "react";
59597
59726
  import { jsx as jsx39, jsxs as jsxs31 } from "react/jsx-runtime";
59598
59727
  var saveStates = /* @__PURE__ */ new WeakMap();
59599
59728
  function getSaveState(client, sessionId) {
@@ -59652,7 +59781,7 @@ function SessionMemoryToggle({
59652
59781
  getSaving
59653
59782
  );
59654
59783
  const [draftEnabled, setDraftEnabled] = useState41(enabled);
59655
- const activeSessionIdRef = useRef32(sessionId);
59784
+ const activeSessionIdRef = useRef33(sessionId);
59656
59785
  activeSessionIdRef.current = sessionId;
59657
59786
  useEffect31(() => {
59658
59787
  setDraftEnabled(enabled);
@@ -63630,6 +63759,7 @@ lucide-react/dist/esm/icons/menu.js:
63630
63759
  lucide-react/dist/esm/icons/message-square-more.js:
63631
63760
  lucide-react/dist/esm/icons/message-square.js:
63632
63761
  lucide-react/dist/esm/icons/minimize-2.js:
63762
+ lucide-react/dist/esm/icons/paperclip.js:
63633
63763
  lucide-react/dist/esm/icons/pencil.js:
63634
63764
  lucide-react/dist/esm/icons/play.js:
63635
63765
  lucide-react/dist/esm/icons/plus.js: