feat: 新增 agentfx 任务深链与研判报告入库流程
支持 goPath=agentfx 的 iframe 嵌入问答、内置研判助手种子与报告导入协助卡,并完善深度研究流式报告能力。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
6e9e89a6cb
commit
52b9cbf707
34 files changed
+4488
-392
No files matched your search
@@ -24,6 +24,10 @@ import type { UploadedFileInfo } from "../uploads";
|
||||
import { promptInputFilePartToFile, uploadFiles } from "../uploads";
|
||||
|
||||
import type { AgentThread, AgentThreadState } from "./types";
|
||||
import {
|
||||
finalizeResearchReportStream,
|
||||
ingestResearchReportEvent,
|
||||
} from "./use-research-report-stream";
|
||||
import {
|
||||
collectHumanMessageIds,
|
||||
hasServerEchoedOptimisticHuman,
|
||||
@@ -774,6 +778,25 @@ export function useThreadStream({
|
||||
},
|
||||
onCustomEvent(event: unknown) {
|
||||
markStreamActivity();
|
||||
// 写作模式内联深度研究的进度帧(deep_research_report 工具经
|
||||
// get_stream_writer 转发):归约进 per-thread 状态,聊天页据此注入
|
||||
// 进度步骤条与 report.md 流式预览。
|
||||
if (
|
||||
typeof event === "object" &&
|
||||
event !== null &&
|
||||
"type" in event &&
|
||||
event.type === "deep_research_report" &&
|
||||
"event" in event &&
|
||||
typeof (event as { event?: unknown }).event === "object" &&
|
||||
(event as { event?: unknown }).event !== null
|
||||
) {
|
||||
const tid = threadIdRef.current ?? onStreamThreadId ?? null;
|
||||
const frame = (event as { event: Record<string, unknown> }).event;
|
||||
if (tid && typeof frame.type === "string") {
|
||||
ingestResearchReportEvent(tid, frame as Parameters<typeof ingestResearchReportEvent>[1]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (
|
||||
typeof event === "object" &&
|
||||
event !== null &&
|
||||
@@ -912,6 +935,10 @@ export function useThreadStream({
|
||||
return;
|
||||
}
|
||||
setStreamHoldOpen(false);
|
||||
// run 真正终结(非 rejoin):若深度研究报告流仍 active(tool_finished
|
||||
// 帧丢失/被取消),标记中断,避免进度条永久转圈。
|
||||
const finThreadId = threadIdRef.current ?? onStreamThreadId ?? null;
|
||||
if (finThreadId) finalizeResearchReportStream(finThreadId);
|
||||
listeners.current.onFinish?.(state.values);
|
||||
void queryClient.invalidateQueries({ queryKey: ["threads", "search"] });
|
||||
});
|
||||
@@ -1618,8 +1645,10 @@ export function useThreadStream({
|
||||
activeRunIdRef.current ?? (tid ? readActiveRunId(tid) : null);
|
||||
setStreamHoldOpen(false);
|
||||
activeRunIdRef.current = null;
|
||||
if (tid && runId) {
|
||||
persistActiveRunId(tid, runId);
|
||||
if (tid) {
|
||||
// 用户显式停止:深度研究报告流立即定格为中断。
|
||||
finalizeResearchReportStream(tid);
|
||||
if (runId) persistActiveRunId(tid, runId);
|
||||
}
|
||||
try {
|
||||
await Promise.resolve(threadStreamRef.current?.stop());
|
||||
|
||||
Reference in new issue
Block a user