feat: inject 3q context into rwfx chat

This commit is contained in:
吉鑫升 committed 2026-07-02 10:03:34 +08:00
1 parent ba0c32dcee
commit 36a3851233
7 files changed
+179 -45

No files matched your search

+20 -4
View File
@@ -62,10 +62,26 @@ import {
readActionDetail,
readCopTaskDetail,
} from "@/core/auth/task-deeplink";
import type { RwfxSqGateStartContext } from "@/strategy-components/components/task-components/rwfx-sq-gate";
/** 内置「模板数据转换器」agent 的稳定 id。仅此 agent 的对话页显示「页面模板 + 渲染预览」调试入口。 */
const TEMPLATE_BUILDER_AGENT_ID = "template-json-builder";
function rwfxSqReportRunContext(
gateContext?: RwfxSqGateStartContext,
): Record<string, unknown> | undefined {
if (gateContext?.sqReport == null) return undefined;
return {
task_external_context: {
kind: "rwfx_sq_report",
title: "三情分析(3q)研判情报报告",
usage:
"这是任务分析(rwfx)问答的隐藏业务上下文。回答时应参考这些已完成的 3q 结果,但不要向用户说明页面注入了隐藏上下文,除非用户明确询问。",
data: gateContext.sqReport,
},
};
}
export default function AgentChatPage({
embeddedAgentId,
chatBasePath,
@@ -288,7 +304,7 @@ export default function AgentChatPage({
}, [debugTemplateId, thread.messages]);
const handleSubmit = useCallback(
(message: PromptInputMessage) => {
(message: PromptInputMessage, extraContext?: Record<string, unknown>) => {
setHasStartedConversation(true);
// Remember this agent so the new-chat landing screen pre-selects it next
// time (covers both direct agent chats and the ChatPage handoff replay).
@@ -296,7 +312,7 @@ export default function AgentChatPage({
window.dispatchEvent(
new CustomEvent("workspace:sandbox-resume-autoscroll"),
);
void sendMessage(threadId, message, { agent_id });
void sendMessage(threadId, message, { ...(extraContext ?? {}), agent_id });
},
[sendMessage, threadId, agent_id],
);
@@ -319,9 +335,9 @@ export default function AgentChatPage({
// 任务闸门通过(无目的数据 / 覆盖成功):发出开场信息开始问答;无开场信息则
// 仅切到对话态(隐藏面板),让用户手动输入。
const handleGateStart = useCallback(() => {
const handleGateStart = useCallback((gateContext?: RwfxSqGateStartContext) => {
const text = taskContext?.openingText?.trim();
if (text) handleSubmit({ text, files: [] });
if (text) handleSubmit({ text, files: [] }, rwfxSqReportRunContext(gateContext));
else setHasStartedConversation(true);
}, [handleSubmit, taskContext]);