@blade-hq/agent-react 2610.0.0-beta.56 → 2610.0.0-beta.57
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/components/ChatInput.d.ts +6 -3
- package/dist/components/ChatSurface.d.ts +1 -2
- package/dist/index.js +12 -22
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/public-api.md +3 -1
|
@@ -3,11 +3,14 @@ interface Props {
|
|
|
3
3
|
value: string;
|
|
4
4
|
onValueChange: (value: string) => void;
|
|
5
5
|
onSend: (text: string) => boolean | Promise<boolean>;
|
|
6
|
-
/** 运行中提交:把消息交给服务端队列(入队)。 */
|
|
7
|
-
onAppend?: (text: string) => boolean | undefined | Promise<boolean>;
|
|
8
6
|
onStop: () => void;
|
|
9
7
|
isStreaming: boolean;
|
|
10
8
|
isStopping?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* 宿主是否渲染了队列面板。没有面板时不给"运行中提交"入口:消息进了队列却看不见,
|
|
11
|
+
* 比明确提示用户等一等更糟。ChatSurface 按 queuePanel 是否存在传入。
|
|
12
|
+
*/
|
|
13
|
+
queueWhileRunning?: boolean;
|
|
11
14
|
placeholder?: string;
|
|
12
15
|
className?: string;
|
|
13
16
|
queueKey?: string;
|
|
@@ -18,5 +21,5 @@ interface Props {
|
|
|
18
21
|
* 不含第一方版本的富文本编辑、@ 补全、技能菜单、语音输入与模型选择。
|
|
19
22
|
* 内容受控,session.attach() / insertText() 通过 ChatView 注入到这里。
|
|
20
23
|
*/
|
|
21
|
-
export declare function ChatInput({ value, onValueChange, onSend,
|
|
24
|
+
export declare function ChatInput({ value, onValueChange, onSend, onStop, isStreaming, isStopping, queueWhileRunning, placeholder, className, queueKey, hasAttachments, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
22
25
|
export {};
|
|
@@ -45,7 +45,6 @@ interface ChatSurfaceProps extends ChatPresentationProps {
|
|
|
45
45
|
onInputChange: (value: string) => void;
|
|
46
46
|
onSuggestion?: (value: string) => void;
|
|
47
47
|
onSend: (text: string) => Promise<boolean>;
|
|
48
|
-
onAppend?: (text: string) => boolean | undefined | Promise<boolean>;
|
|
49
48
|
onStop: () => void;
|
|
50
49
|
sessionStatus?: string;
|
|
51
50
|
askAnswers?: Record<string, AskUserAnswerData>;
|
|
@@ -77,5 +76,5 @@ interface ChatSurfaceProps extends ChatPresentationProps {
|
|
|
77
76
|
* 这里的 DOM 结构受 tests/chat-view-compat.test.tsx 的快照保护——接入方拿
|
|
78
77
|
* .blade-chat-* 类名写了自己的样式,结构一动他们的页面就歪。
|
|
79
78
|
*/
|
|
80
|
-
export declare function ChatSurface({ theme, classNames, renderers, slots, placeholder, connection, errorMessage, messages, postChatFollowup, isStreaming, isStopping, inputText, onInputChange, onSuggestion, onSend,
|
|
79
|
+
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, showPlanUpdates, planRevealRevision, historyPaging, banner, }: ChatSurfaceProps): import("react/jsx-runtime").JSX.Element;
|
|
81
80
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -42380,10 +42380,10 @@ function ChatInput({
|
|
|
42380
42380
|
value,
|
|
42381
42381
|
onValueChange,
|
|
42382
42382
|
onSend,
|
|
42383
|
-
onAppend,
|
|
42384
42383
|
onStop,
|
|
42385
42384
|
isStreaming,
|
|
42386
42385
|
isStopping = false,
|
|
42386
|
+
queueWhileRunning = false,
|
|
42387
42387
|
placeholder = "\u8F93\u5165\u6D88\u606F\u2026",
|
|
42388
42388
|
className,
|
|
42389
42389
|
queueKey,
|
|
@@ -42395,14 +42395,14 @@ function ChatInput({
|
|
|
42395
42395
|
const sending = useRef14(false);
|
|
42396
42396
|
const [isSending2, setIsSending] = useState20(false);
|
|
42397
42397
|
void queueKey;
|
|
42398
|
-
const canSend = !isSending2 && (trimmed.length > 0 || hasAttachments) && (!isStreaming || !hasAttachments && !isStopping
|
|
42398
|
+
const canSend = !isSending2 && (trimmed.length > 0 || hasAttachments) && (!isStreaming || queueWhileRunning && !hasAttachments && !isStopping);
|
|
42399
42399
|
const handleSend = async () => {
|
|
42400
42400
|
if (!canSend || sending.current) return;
|
|
42401
42401
|
sending.current = true;
|
|
42402
42402
|
setIsSending(true);
|
|
42403
42403
|
const submitted = value;
|
|
42404
42404
|
try {
|
|
42405
|
-
const accepted =
|
|
42405
|
+
const accepted = await onSend(trimmed);
|
|
42406
42406
|
if (accepted === false) return;
|
|
42407
42407
|
if (latestValue.current === submitted) onValueChange("");
|
|
42408
42408
|
} finally {
|
|
@@ -42440,7 +42440,7 @@ function ChatInput({
|
|
|
42440
42440
|
}
|
|
42441
42441
|
),
|
|
42442
42442
|
isStreaming ? /* @__PURE__ */ jsxs10(Fragment5, { children: [
|
|
42443
|
-
/* @__PURE__ */ jsx12("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__ */ jsx12(ArrowUp, { size: 15 }) }),
|
|
42443
|
+
queueWhileRunning ? /* @__PURE__ */ jsx12("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__ */ jsx12(ArrowUp, { size: 15 }) }) : null,
|
|
42444
42444
|
/* @__PURE__ */ jsx12("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__ */ jsx12(LoaderCircle, { size: 14, className: "animate-spin" }) : /* @__PURE__ */ jsx12(Square, { size: 12, fill: "currentColor" }) })
|
|
42445
42445
|
] }) : /* @__PURE__ */ jsx12(
|
|
42446
42446
|
"button",
|
|
@@ -45290,7 +45290,6 @@ function ChatSurface({
|
|
|
45290
45290
|
onInputChange,
|
|
45291
45291
|
onSuggestion,
|
|
45292
45292
|
onSend,
|
|
45293
|
-
onAppend,
|
|
45294
45293
|
onStop,
|
|
45295
45294
|
sessionStatus,
|
|
45296
45295
|
askAnswers,
|
|
@@ -45386,10 +45385,10 @@ ${item.content}`), text].filter(Boolean).join("\n\n");
|
|
|
45386
45385
|
onValueChange: onInputChange,
|
|
45387
45386
|
onSend: sendWithApps,
|
|
45388
45387
|
hasAttachments: currentPending.length > 0,
|
|
45389
|
-
onAppend,
|
|
45390
45388
|
onStop,
|
|
45391
45389
|
isStreaming,
|
|
45392
45390
|
isStopping,
|
|
45391
|
+
queueWhileRunning: queuePanel != null,
|
|
45393
45392
|
placeholder,
|
|
45394
45393
|
queueKey: sessionId,
|
|
45395
45394
|
className: classNames?.chatInput
|
|
@@ -45507,6 +45506,7 @@ function ChatSessionView({
|
|
|
45507
45506
|
const [resultFeedback, setResultFeedback] = useState31([]);
|
|
45508
45507
|
const resolvedSessionId = session?.sessionId;
|
|
45509
45508
|
const isViewer = state?.viewerRole === "viewer";
|
|
45509
|
+
const canUseQueue = !isViewer;
|
|
45510
45510
|
const onSessionReadyRef = useRef23(onSessionReady);
|
|
45511
45511
|
const readySessionRef = useRef23(null);
|
|
45512
45512
|
const hasOnSessionReady = onSessionReady !== void 0;
|
|
@@ -45591,13 +45591,10 @@ ${content}`);
|
|
|
45591
45591
|
const errorMessage = connectError ?? state?.errorMessage ?? replay.error?.message ?? null;
|
|
45592
45592
|
const handleSend = (text) => {
|
|
45593
45593
|
setStopRequested(false);
|
|
45594
|
-
|
|
45595
|
-
|
|
45596
|
-
|
|
45597
|
-
|
|
45598
|
-
}) ?? Promise.resolve(false);
|
|
45599
|
-
}
|
|
45600
|
-
return session?.send(text, { mode: state?.mode ?? void 0 }) ?? Promise.resolve(false);
|
|
45594
|
+
return session?.send(text, {
|
|
45595
|
+
mode: state?.mode ?? void 0,
|
|
45596
|
+
queueWhenRunning: canUseQueue
|
|
45597
|
+
}) ?? Promise.resolve(false);
|
|
45601
45598
|
};
|
|
45602
45599
|
const handleStop = () => {
|
|
45603
45600
|
setStopRequested(true);
|
|
@@ -45621,12 +45618,6 @@ ${content}`);
|
|
|
45621
45618
|
}
|
|
45622
45619
|
);
|
|
45623
45620
|
};
|
|
45624
|
-
const handleAppend = (text) => {
|
|
45625
|
-
return session?.queueMessage(text).then((result) => {
|
|
45626
|
-
setQueueNotice(result.ok ? null : result.message);
|
|
45627
|
-
return result.ok;
|
|
45628
|
-
}) ?? Promise.resolve(false);
|
|
45629
|
-
};
|
|
45630
45621
|
const handleQueueEdit = (item, content) => {
|
|
45631
45622
|
return runQueueCommand(
|
|
45632
45623
|
item.id,
|
|
@@ -45684,7 +45675,7 @@ ${content}`);
|
|
|
45684
45675
|
planRevealRevision,
|
|
45685
45676
|
queuePanel: (
|
|
45686
45677
|
// 只读身份不能操作队列,藏起来免得每个按钮都弹冲突。
|
|
45687
|
-
|
|
45678
|
+
canUseQueue ? /* @__PURE__ */ jsx27(
|
|
45688
45679
|
SessionQueuePanel,
|
|
45689
45680
|
{
|
|
45690
45681
|
snapshot: state?.queue ?? EMPTY_SESSION_QUEUE,
|
|
@@ -45706,7 +45697,7 @@ ${content}`);
|
|
|
45706
45697
|
)
|
|
45707
45698
|
},
|
|
45708
45699
|
resolvedSessionId
|
|
45709
|
-
)
|
|
45700
|
+
) : void 0
|
|
45710
45701
|
),
|
|
45711
45702
|
historyPaging: session && state ? {
|
|
45712
45703
|
hasOlder: session.hasOlderHistory,
|
|
@@ -45722,7 +45713,6 @@ ${content}`);
|
|
|
45722
45713
|
onInputChange: setInputText,
|
|
45723
45714
|
onSuggestion: setInputText,
|
|
45724
45715
|
onSend: handleSend,
|
|
45725
|
-
onAppend: handleAppend,
|
|
45726
45716
|
onStop: handleStop,
|
|
45727
45717
|
sessionStatus: state?.status ?? void 0,
|
|
45728
45718
|
askAnswers: state?.askAnswers,
|