Merge branch 'master' into dhk-1
Integrate task deeplink/FX workspace updates from master while keeping dhk-1 menu-overrides and sensitive-words documentation in CLAUDE.md. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
commit
e6a41dbc97
26 files changed
+1302
-84
No files matched your search
@@ -5,7 +5,7 @@
|
|||||||
VITE_USE_REAL_DATA=true
|
VITE_USE_REAL_DATA=true
|
||||||
|
|
||||||
# 任务详情(登录深链 cop-task-detail)数据源:默认真实接口;改成 true 走本地假数据(调试用)。
|
# 任务详情(登录深链 cop-task-detail)数据源:默认真实接口;改成 true 走本地假数据(调试用)。
|
||||||
VITE_MOCK_COP_TASK_DETAIL=false
|
VITE_MOCK_COP_TASK_DETAIL=true
|
||||||
|
|
||||||
# Gateway / DeerFlow API
|
# Gateway / DeerFlow API
|
||||||
VITE_BACKEND_BASE_URL=https://ch1.b.uat.4.cn/deerflow
|
VITE_BACKEND_BASE_URL=https://ch1.b.uat.4.cn/deerflow
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { User } from "lucide-react";
|
||||||
|
import { useMemo } from "react";
|
||||||
|
|
||||||
|
import { getStoredAuth } from "@/core/auth";
|
||||||
|
import { useMyPosition } from "@/core/positions";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import { readUserInfo } from "@/strategy-components/lib/light-app";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 名称 + 岗位 用户标识。全量模式由 strategy-components/Header.tsx 顶栏右侧展示;
|
||||||
|
* 紧凑模式(不带全局顶栏)无处承载,故抽成共享组件,复用同一套数据来源
|
||||||
|
* (`readUserInfo().userName` 优先、回退 auth 邮箱前缀;岗位取 `useMyPosition`),
|
||||||
|
* 供页面级顶栏(如 ChatPage)右侧复用,保证两套布局一致。
|
||||||
|
*
|
||||||
|
* 配色按当前内容区前景色(foreground / muted-foreground),适配聊天页浅底顶栏,
|
||||||
|
* 而非 Header 的白字贴 banner 方案。
|
||||||
|
*/
|
||||||
|
export function UserIdentityBadge({ className }: { className?: string }) {
|
||||||
|
const auth = getStoredAuth();
|
||||||
|
const { data: myPosition } = useMyPosition();
|
||||||
|
const positionName = myPosition?.name?.trim() || "";
|
||||||
|
|
||||||
|
// 与 Header.tsx 一致:外部登录写入的真实用户名优先,缺省回退邮箱前缀。
|
||||||
|
const displayName = useMemo(() => {
|
||||||
|
const info = readUserInfo();
|
||||||
|
const name = typeof info.userName === "string" ? info.userName.trim() : "";
|
||||||
|
if (name) return name;
|
||||||
|
const email = auth?.email?.trim();
|
||||||
|
return email ? email.split("@")[0] : "用户";
|
||||||
|
}, [auth?.email]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn("flex shrink-0 items-center gap-2", className)}
|
||||||
|
title={positionName ? `${displayName}·${positionName}` : displayName}
|
||||||
|
>
|
||||||
|
<div className="bg-muted text-muted-foreground flex size-7 shrink-0 items-center justify-center rounded-full">
|
||||||
|
<User className="size-3.5" />
|
||||||
|
</div>
|
||||||
|
<div className="hidden min-w-0 text-left sm:block">
|
||||||
|
<p className="text-foreground truncate text-sm font-medium leading-tight">
|
||||||
|
{displayName}
|
||||||
|
</p>
|
||||||
|
{positionName && (
|
||||||
|
<p className="text-muted-foreground truncate text-[11px] leading-tight">
|
||||||
|
{positionName}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
/**
|
||||||
|
* 任务深链(``goPath=rwfx``)的运行时配置:从后端公开只读接口
|
||||||
|
* ``GET /api/public/config/task-deeplink`` 读取(地址、测试开关、测试假数据全在后端
|
||||||
|
* ``config.yaml`` 的 ``task_deeplink`` 段,改完即时生效,前端无需重建)。
|
||||||
|
*
|
||||||
|
* 两种用法:
|
||||||
|
* - 命令式(登录深链流程,非 React 环境):``fetchTaskDeeplinkConfig()`` 拉取并模块级缓存;
|
||||||
|
* ``getCachedTaskDeeplinkConfig()`` 同步读缓存(拼跳转地址用)。
|
||||||
|
* - React 组件:``useTaskDeeplinkConfig()``(见 [[task-purpose]] 的面板/列表)。
|
||||||
|
*
|
||||||
|
* 拉取失败 → 用内置默认值(``test=false`` + 真实 URL)兜底,功能不整体挂掉。
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { apiFetch } from "@/core/api/fetch-client";
|
||||||
|
import { getBackendBaseURL } from "@/core/config";
|
||||||
|
|
||||||
|
export interface TaskDeeplinkConfig {
|
||||||
|
/** 目的树查询走假数据。 */
|
||||||
|
test: boolean;
|
||||||
|
/** 删除接口走假数据(该接口未开发完时打开)。 */
|
||||||
|
deleteTest: boolean;
|
||||||
|
/** 目的树查询完整 URL(调用追加 ?taskId=)。 */
|
||||||
|
purposeDetailUrl: string;
|
||||||
|
/** 删除完整 URL(调用追加 ?taskId=)。 */
|
||||||
|
deleteUrl: string;
|
||||||
|
/** B 系统树形完整编辑页 URL(跳转追加 ?id=)。 */
|
||||||
|
treemapEditUrl: string;
|
||||||
|
/** B 系统树形下一步页 URL(跳转追加 ?id=)。 */
|
||||||
|
treemapNextUrl: string;
|
||||||
|
/** 测试假数据:purposeDetail = 原始 {state,msg,data};delete = {message,success}。 */
|
||||||
|
mock: {
|
||||||
|
purposeDetail?: unknown;
|
||||||
|
delete?: { message?: string; success?: boolean };
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 内置默认值(后端拿不到时兜底;真实 URL + 关闭测试)。 */
|
||||||
|
export const DEFAULT_TASK_DEEPLINK_CONFIG: TaskDeeplinkConfig = {
|
||||||
|
test: false,
|
||||||
|
deleteTest: false,
|
||||||
|
purposeDetailUrl: "https://ch1.b.uat.4.cn/consumer/taskAnalyseSearch/getTaskPurposeDetail",
|
||||||
|
deleteUrl: "https://ch1.b.uat.4.cn/consumer/taskAnalyseSearch/delete",
|
||||||
|
treemapEditUrl: "https://ch1.b.uat.4.cn/web/#/task/item-aicoh/step-mode-treemap-full-edit",
|
||||||
|
treemapNextUrl: "https://ch1.b.uat.4.cn/web/#/task/item-aicoh/step-mode-treemap-full-next",
|
||||||
|
mock: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 后端 snake_case 响应 → 前端 camelCase;缺字段回退默认值。 */
|
||||||
|
function normalize(body: unknown): TaskDeeplinkConfig {
|
||||||
|
const o = body && typeof body === "object" ? (body as Record<string, unknown>) : {};
|
||||||
|
const d = DEFAULT_TASK_DEEPLINK_CONFIG;
|
||||||
|
const str = (v: unknown, fallback: string) =>
|
||||||
|
typeof v === "string" && v.trim() ? v : fallback;
|
||||||
|
const mock = o.mock && typeof o.mock === "object" ? (o.mock as Record<string, unknown>) : {};
|
||||||
|
return {
|
||||||
|
test: o.test === true,
|
||||||
|
deleteTest: o.delete_test === true,
|
||||||
|
purposeDetailUrl: str(o.purpose_detail_url, d.purposeDetailUrl),
|
||||||
|
deleteUrl: str(o.delete_url, d.deleteUrl),
|
||||||
|
treemapEditUrl: str(o.treemap_edit_url, d.treemapEditUrl),
|
||||||
|
treemapNextUrl: str(o.treemap_next_url, d.treemapNextUrl),
|
||||||
|
mock: {
|
||||||
|
purposeDetail: mock.purpose_detail,
|
||||||
|
delete:
|
||||||
|
mock.delete && typeof mock.delete === "object"
|
||||||
|
? (mock.delete as { message?: string; success?: boolean })
|
||||||
|
: undefined,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let cached: TaskDeeplinkConfig | null = null;
|
||||||
|
let inflight: Promise<TaskDeeplinkConfig> | null = null;
|
||||||
|
|
||||||
|
/** 拉取(带模块级缓存 + 去重);失败回退默认值。 */
|
||||||
|
export async function fetchTaskDeeplinkConfig(): Promise<TaskDeeplinkConfig> {
|
||||||
|
if (cached) return cached;
|
||||||
|
if (inflight) return inflight;
|
||||||
|
inflight = (async () => {
|
||||||
|
try {
|
||||||
|
const res = await apiFetch(`${getBackendBaseURL()}/api/public/config/task-deeplink`);
|
||||||
|
if (!res.ok) throw new Error(`task-deeplink config ${res.status}`);
|
||||||
|
cached = normalize(await res.json());
|
||||||
|
} catch {
|
||||||
|
cached = { ...DEFAULT_TASK_DEEPLINK_CONFIG };
|
||||||
|
} finally {
|
||||||
|
inflight = null;
|
||||||
|
}
|
||||||
|
return cached;
|
||||||
|
})();
|
||||||
|
return inflight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 同步读缓存(未拉取过则返回默认值)。 */
|
||||||
|
export function getCachedTaskDeeplinkConfig(): TaskDeeplinkConfig {
|
||||||
|
return cached ?? DEFAULT_TASK_DEEPLINK_CONFIG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 在完整 URL(可能含 `#` 片段)后追加查询参数,供跳转/调用拼 id/taskId。 */
|
||||||
|
export function appendQueryParam(url: string, key: string, value: string): string {
|
||||||
|
if (!url) return "";
|
||||||
|
const sep = url.includes("?") ? "&" : "?";
|
||||||
|
return `${url}${sep}${key}=${encodeURIComponent(value)}`;
|
||||||
|
}
|
||||||
@@ -16,8 +16,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { requestCrudService } from "@/service/request-axios-service";
|
import { requestCrudService } from "@/service/request-axios-service";
|
||||||
|
import { clearTaskContext, persistTaskContext } from "@/core/auth/task-purpose";
|
||||||
import { listBusinessMappings } from "@/strategy-components/api/business-mapping";
|
import { listBusinessMappings } from "@/strategy-components/api/business-mapping";
|
||||||
|
|
||||||
|
/** rwfx 业务码:单智能体走「任务工作区 + 目的树闸门」(其它业务保持原问答逻辑)。 */
|
||||||
|
const RWFX_BUSINESS_CODE = "6BF";
|
||||||
|
|
||||||
/** consumer 接口返回的任务详情(data 字段)。 */
|
/** consumer 接口返回的任务详情(data 字段)。 */
|
||||||
export interface CopTaskDetail {
|
export interface CopTaskDetail {
|
||||||
id: string | number | null;
|
id: string | number | null;
|
||||||
@@ -132,12 +136,16 @@ function buildOpeningText(detail: CopTaskDetail): string {
|
|||||||
export async function resolveTaskDeeplinkTarget(
|
export async function resolveTaskDeeplinkTarget(
|
||||||
goPath: string,
|
goPath: string,
|
||||||
detail: CopTaskDetail,
|
detail: CopTaskDetail,
|
||||||
|
taskId: string,
|
||||||
): Promise<TaskDeeplinkTarget | null> {
|
): Promise<TaskDeeplinkTarget | null> {
|
||||||
const parsed = parseGoPath(goPath);
|
const parsed = parseGoPath(goPath);
|
||||||
if (!parsed) return null;
|
if (!parsed) return null;
|
||||||
const taskBase = BUSINESS_TASK_BASE[parsed.businessCode];
|
const taskBase = BUSINESS_TASK_BASE[parsed.businessCode];
|
||||||
if (!taskBase) return null;
|
if (!taskBase) return null;
|
||||||
|
|
||||||
|
// 清掉上一次深链可能残留的任务上下文(仅 rwfx 单智能体会重新写入)。
|
||||||
|
clearTaskContext();
|
||||||
|
|
||||||
if (parsed.roundtable) {
|
if (parsed.roundtable) {
|
||||||
// 多智能体会商:嵌进对应业务的「任务管理」布局;businessCode 让会商页自动选用配置的业务链条。
|
// 多智能体会商:嵌进对应业务的「任务管理」布局;businessCode 让会商页自动选用配置的业务链条。
|
||||||
return {
|
return {
|
||||||
@@ -162,6 +170,15 @@ export async function resolveTaskDeeplinkTarget(
|
|||||||
}
|
}
|
||||||
if (!agentId) return null;
|
if (!agentId) return null;
|
||||||
|
|
||||||
|
if (parsed.businessCode === RWFX_BUSINESS_CODE) {
|
||||||
|
// rwfx:走「任务工作区」——暂存任务上下文(taskId + 开场信息),跳到 chats 索引,
|
||||||
|
// 由工作区按 taskId 决定开最新历史对话 / 新建(新建走目的树闸门)。不设 pendingAgentMessage:
|
||||||
|
// 开场信息在闸门通过后由目的树面板发出。
|
||||||
|
persistTaskContext({ taskId, agentId, openingText: buildOpeningText(detail) });
|
||||||
|
return { path: `${taskBase}/agent/${agentId}/chats` };
|
||||||
|
}
|
||||||
|
|
||||||
|
// 其它单智能体问答:保持原逻辑(pendingAgentMessage 自动发出 + chats/new)。
|
||||||
try {
|
try {
|
||||||
sessionStorage.setItem(
|
sessionStorage.setItem(
|
||||||
"pendingAgentMessage",
|
"pendingAgentMessage",
|
||||||
@@ -170,6 +187,5 @@ export async function resolveTaskDeeplinkTarget(
|
|||||||
} catch {
|
} catch {
|
||||||
/* noop */
|
/* noop */
|
||||||
}
|
}
|
||||||
// 单智能体问答:同样嵌进对应业务的「任务管理」布局。
|
|
||||||
return { path: `${taskBase}/agent/${agentId}/chats/new` };
|
return { path: `${taskBase}/agent/${agentId}/chats/new` };
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,225 @@
|
|||||||
|
/**
|
||||||
|
* 任务深链(``goPath=rwfx``)的「目的树闸门 + 任务↔对话绑定」支持。
|
||||||
|
*
|
||||||
|
* 角色区分:
|
||||||
|
* - **目的树数据**:B 系统里的策划结果,走 ``getTaskPurposeDetail`` / ``delete``(地址、测试
|
||||||
|
* 开关、测试假数据都来自 [[task-deeplink-config]] / 后端 config.yaml),与聊天对话无关。
|
||||||
|
* 新建对话(含首次进入)前用它做「已有数据→覆盖确认」闸门。
|
||||||
|
* - **对话(thread)**:聊天会话;通过 thread 的 ``metadata.taskId`` 标签把多个对话挂到同一个
|
||||||
|
* 任务下(1:N),列表用 useThreadsPage({ metadata:{ taskId } }) 过滤。详见 [[task-deeplink]]。
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {
|
||||||
|
appendQueryParam,
|
||||||
|
fetchTaskDeeplinkConfig,
|
||||||
|
getCachedTaskDeeplinkConfig,
|
||||||
|
} from "@/core/auth/task-deeplink-config";
|
||||||
|
import { requestCrudService } from "@/service/request-axios-service";
|
||||||
|
|
||||||
|
/** 归一化后的目的树节点(用于展示,逐层:目的→行为体→预期行为→驱动因素→叙事)。 */
|
||||||
|
export interface PurposeTreeNode {
|
||||||
|
/** 节点类型中文标签。 */
|
||||||
|
label: string;
|
||||||
|
/** 节点主文本(目的/行为体名/预期/因素/叙事内容)。 */
|
||||||
|
text: string;
|
||||||
|
/** 推荐理由(若有)。 */
|
||||||
|
reason?: string;
|
||||||
|
children: PurposeTreeNode[];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 当前 rwfx 任务上下文(深链进入或「新建对话」时暂存,供闸门面板与绑定使用)。 */
|
||||||
|
export interface TaskContext {
|
||||||
|
taskId: string;
|
||||||
|
agentId: string;
|
||||||
|
/** 自动发出的开场信息(任务名称/内容)。 */
|
||||||
|
openingText: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TASK_CONTEXT_STORAGE_KEY = "task.rwfxContext";
|
||||||
|
|
||||||
|
/* --------------------------- 目的树查询/删除 --------------------------- */
|
||||||
|
|
||||||
|
/** 逐层 dto 字段映射:key=childrenList 里出现的 *Dto 字段名。 */
|
||||||
|
const DTO_FIELD_MAP: Record<string, { label: string; textKey: string }> = {
|
||||||
|
purposeDto: { label: "目的", textKey: "zzPurpose" },
|
||||||
|
actorDto: { label: "行为体", textKey: "actorName" },
|
||||||
|
expectedBehaviorDto: { label: "预期行为", textKey: "behavior" },
|
||||||
|
drivingFactorDto: { label: "驱动因素", textKey: "drivingFactor" },
|
||||||
|
narrationDto: { label: "叙事", textKey: "narration" },
|
||||||
|
};
|
||||||
|
|
||||||
|
// 取节点主文本时跳过的字段(id/时间/标记/理由等非展示文本),保证容错。
|
||||||
|
const SKIP_TEXT_KEY = /(^id$|Id$|Time$|Flag$|Type$|Level$|recReason|createBy|updateBy|^mid$)/i;
|
||||||
|
|
||||||
|
/** 从一个 dto 里取展示文本:优先 preferredKey,否则取第一个像「内容」的字符串字段。 */
|
||||||
|
function pickDtoText(dto: Record<string, unknown>, preferredKey?: string): string {
|
||||||
|
if (preferredKey && typeof dto[preferredKey] === "string" && (dto[preferredKey] as string).trim()) {
|
||||||
|
return dto[preferredKey] as string;
|
||||||
|
}
|
||||||
|
for (const [k, v] of Object.entries(dto)) {
|
||||||
|
if (typeof v === "string" && v.trim() && !SKIP_TEXT_KEY.test(k)) return v;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 把一层节点归一化为 {label,text,reason,children}。**容错**:
|
||||||
|
* - 优先匹配已知 dto(目的/行为体/...);未知 ``*Dto`` 字段也兜底(标签取字段名去 Dto);
|
||||||
|
* - 文本字段改名也能取到(pickDtoText 兜底);
|
||||||
|
* - 完全不认识的结构仍递归 childrenList,避免整棵树丢失。
|
||||||
|
*/
|
||||||
|
function normalizeNode(raw: unknown): PurposeTreeNode | null {
|
||||||
|
if (!raw || typeof raw !== "object") return null;
|
||||||
|
const obj = raw as Record<string, unknown>;
|
||||||
|
const isObj = (k: string) => obj[k] && typeof obj[k] === "object" && !Array.isArray(obj[k]);
|
||||||
|
// 先找已知 dto,再兜底任意 `*Dto` 字段。
|
||||||
|
let dtoKey = Object.keys(DTO_FIELD_MAP).find(isObj);
|
||||||
|
if (!dtoKey) dtoKey = Object.keys(obj).find((k) => /Dto$/.test(k) && isObj(k));
|
||||||
|
|
||||||
|
const childrenRaw = Array.isArray(obj.childrenList) ? obj.childrenList : [];
|
||||||
|
const children = childrenRaw
|
||||||
|
.map(normalizeNode)
|
||||||
|
.filter((n): n is PurposeTreeNode => n !== null);
|
||||||
|
|
||||||
|
if (!dtoKey) {
|
||||||
|
// 不认识的结构:仅当有子节点时保留为占位节点,否则丢弃。
|
||||||
|
return children.length ? { label: "节点", text: "", children } : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const mapped = DTO_FIELD_MAP[dtoKey];
|
||||||
|
const dto = obj[dtoKey] as Record<string, unknown>;
|
||||||
|
const label = mapped?.label ?? dtoKey.replace(/Dto$/, "");
|
||||||
|
const text = pickDtoText(dto, mapped?.textKey);
|
||||||
|
const reason =
|
||||||
|
typeof dto.recReason === "string" && (dto.recReason as string).trim()
|
||||||
|
? (dto.recReason as string)
|
||||||
|
: undefined;
|
||||||
|
return { label, text, reason, children };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 表格行:根→叶一条路径上的各层单元格(层级数可变,做了容错)。 */
|
||||||
|
export type PurposeFlatCell = { label: string; text: string; reason?: string };
|
||||||
|
|
||||||
|
/** 把目的树拍平成「一行一条叶子路径」,供表格展示(层级缺失/变动都不崩)。 */
|
||||||
|
export function flattenPurposeTree(nodes: PurposeTreeNode[]): PurposeFlatCell[][] {
|
||||||
|
const rows: PurposeFlatCell[][] = [];
|
||||||
|
const walk = (node: PurposeTreeNode, trail: PurposeFlatCell[]) => {
|
||||||
|
const next = [...trail, { label: node.label, text: node.text, reason: node.reason }];
|
||||||
|
if (!node.children || node.children.length === 0) rows.push(next);
|
||||||
|
else node.children.forEach((c) => walk(c, next));
|
||||||
|
};
|
||||||
|
nodes.forEach((n) => walk(n, []));
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 从接口/假数据的整包 body 里取出 data 数组并归一化成树。 */
|
||||||
|
function bodyToTree(body: unknown): PurposeTreeNode[] {
|
||||||
|
const data =
|
||||||
|
body && typeof body === "object" ? (body as { data?: unknown }).data : null;
|
||||||
|
const arr = Array.isArray(data) ? data : [];
|
||||||
|
return arr.map(normalizeNode).filter((n): n is PurposeTreeNode => n !== null);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TaskPurposeResult {
|
||||||
|
tree: PurposeTreeNode[];
|
||||||
|
/** data 数组里有有效目的节点 = 已有策划数据。 */
|
||||||
|
hasData: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询任务目的树。``test=true`` 时直接用后端配置里的假数据;否则打真实接口
|
||||||
|
* (地址来自配置,``Authorization: Bearer admin`` 由 axios 拦截器统一注入)。
|
||||||
|
* 缺地址 / 返回不合法 → ``{ tree: [], hasData: false }``。
|
||||||
|
*/
|
||||||
|
export async function fetchTaskPurposeDetail(
|
||||||
|
taskId: string,
|
||||||
|
): Promise<TaskPurposeResult> {
|
||||||
|
if (!taskId) return { tree: [], hasData: false };
|
||||||
|
const cfg = await fetchTaskDeeplinkConfig();
|
||||||
|
let body: unknown;
|
||||||
|
if (cfg.test) {
|
||||||
|
body = cfg.mock.purposeDetail;
|
||||||
|
} else if (cfg.purposeDetailUrl) {
|
||||||
|
body = await requestCrudService.get(cfg.purposeDetailUrl, { taskId });
|
||||||
|
} else {
|
||||||
|
return { tree: [], hasData: false };
|
||||||
|
}
|
||||||
|
const tree = bodyToTree(body);
|
||||||
|
return { tree, hasData: tree.length > 0 };
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DeleteTaskPurposeResult {
|
||||||
|
message: string;
|
||||||
|
success: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除任务目的树(覆盖前清空 / 手动清除任务记录都走这里)。``delete_test=true`` 时
|
||||||
|
* 用后端配置里的假数据(接口未开发完时用);否则打真实接口。
|
||||||
|
*/
|
||||||
|
export async function deleteTaskPurpose(
|
||||||
|
taskId: string,
|
||||||
|
): Promise<DeleteTaskPurposeResult> {
|
||||||
|
if (!taskId) return { message: "缺少 taskId", success: false };
|
||||||
|
const cfg = await fetchTaskDeeplinkConfig();
|
||||||
|
if (cfg.deleteTest) {
|
||||||
|
const m = cfg.mock.delete ?? {};
|
||||||
|
return { message: typeof m.message === "string" ? m.message : "", success: m.success === true };
|
||||||
|
}
|
||||||
|
if (!cfg.deleteUrl) return { message: "缺少删除接口地址", success: false };
|
||||||
|
const body = await requestCrudService.get(cfg.deleteUrl, { taskId });
|
||||||
|
const obj =
|
||||||
|
body && typeof body === "object" ? (body as unknown as Record<string, unknown>) : {};
|
||||||
|
return {
|
||||||
|
message: typeof obj.message === "string" ? obj.message : "",
|
||||||
|
success: obj.success === true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------------------------- 跳转地址 ----------------------------- */
|
||||||
|
|
||||||
|
/** B 系统「树形完整编辑」页地址(问答后「编辑」按钮,新标签打开)。用同步缓存配置。 */
|
||||||
|
export function buildTreemapEditUrl(taskId: string): string {
|
||||||
|
const url = getCachedTaskDeeplinkConfig().treemapEditUrl;
|
||||||
|
return url && taskId ? appendQueryParam(url, "id", taskId) : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** B 系统「树形下一步」页地址(问答后「下一步」按钮,新标签打开)。 */
|
||||||
|
export function buildTreemapNextUrl(taskId: string): string {
|
||||||
|
const url = getCachedTaskDeeplinkConfig().treemapNextUrl;
|
||||||
|
return url && taskId ? appendQueryParam(url, "id", taskId) : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------- 任务上下文暂存 --------------------------- */
|
||||||
|
|
||||||
|
export function persistTaskContext(ctx: TaskContext): void {
|
||||||
|
try {
|
||||||
|
sessionStorage.setItem(TASK_CONTEXT_STORAGE_KEY, JSON.stringify(ctx));
|
||||||
|
} catch {
|
||||||
|
/* noop */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function readTaskContext(): TaskContext | null {
|
||||||
|
try {
|
||||||
|
const raw = sessionStorage.getItem(TASK_CONTEXT_STORAGE_KEY);
|
||||||
|
if (!raw) return null;
|
||||||
|
const parsed = JSON.parse(raw) as Partial<TaskContext>;
|
||||||
|
if (!parsed?.taskId || !parsed?.agentId) return null;
|
||||||
|
return {
|
||||||
|
taskId: String(parsed.taskId),
|
||||||
|
agentId: String(parsed.agentId),
|
||||||
|
openingText: typeof parsed.openingText === "string" ? parsed.openingText : "",
|
||||||
|
};
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function clearTaskContext(): void {
|
||||||
|
try {
|
||||||
|
sessionStorage.removeItem(TASK_CONTEXT_STORAGE_KEY);
|
||||||
|
} catch {
|
||||||
|
/* noop */
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,6 +34,9 @@ export type ThreadStreamOptions = {
|
|||||||
context: LocalSettings["context"];
|
context: LocalSettings["context"];
|
||||||
isMock?: boolean;
|
isMock?: boolean;
|
||||||
assistantId?: string;
|
assistantId?: string;
|
||||||
|
/** 额外写到新建 thread 的 metadata(与 agent_id 合并)。
|
||||||
|
* 任务深链用 `{ taskId }` 把对话挂到任务下(1:N),列表按 metadata.taskId 过滤。 */
|
||||||
|
threadMetadata?: Record<string, unknown>;
|
||||||
onStart?: (threadId: string) => void;
|
onStart?: (threadId: string) => void;
|
||||||
onFinish?: (state: AgentThreadState) => void;
|
onFinish?: (state: AgentThreadState) => void;
|
||||||
onToolEnd?: (event: ToolEndEvent) => void;
|
onToolEnd?: (event: ToolEndEvent) => void;
|
||||||
@@ -118,6 +121,39 @@ function getRunMetadataStorage(): {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显式停止某会话「服务端正在跑」的 run。
|
||||||
|
*
|
||||||
|
* 注意:useStream / `thread.stop()` 只中断本地 SSE 监听,服务端 run 仍会继续跑。
|
||||||
|
* 任务流程要求「开启新对话时老对话要停止」,所以这里读出 SDK 存在 sessionStorage
|
||||||
|
* (``lg:stream:{threadId}``)里的 run id,调用 ``runs.cancel`` 真正取消后端 run,
|
||||||
|
* 再清掉本地 reconnect 记录。已结束 / 不存在的 run 取消失败时静默忽略。
|
||||||
|
*/
|
||||||
|
export async function stopThreadRun(
|
||||||
|
threadId: string | null | undefined,
|
||||||
|
): Promise<void> {
|
||||||
|
if (!threadId || typeof window === "undefined") return;
|
||||||
|
let runId: string | null = null;
|
||||||
|
try {
|
||||||
|
runId = normalizeStoredRunId(
|
||||||
|
window.sessionStorage.getItem(`lg:stream:${threadId}`),
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
runId = null;
|
||||||
|
}
|
||||||
|
if (!runId) return;
|
||||||
|
try {
|
||||||
|
await getAPIClient().runs.cancel(threadId, runId);
|
||||||
|
} catch {
|
||||||
|
/* 已结束 / 不存在 / 网络错误等忽略 */
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
window.sessionStorage.removeItem(`lg:stream:${threadId}`);
|
||||||
|
} catch {
|
||||||
|
/* noop */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getStreamErrorMessage(error: unknown): string {
|
function getStreamErrorMessage(error: unknown): string {
|
||||||
if (typeof error === "string" && error.trim()) {
|
if (typeof error === "string" && error.trim()) {
|
||||||
return error;
|
return error;
|
||||||
@@ -200,6 +236,7 @@ export function useThreadStream({
|
|||||||
context,
|
context,
|
||||||
isMock,
|
isMock,
|
||||||
assistantId,
|
assistantId,
|
||||||
|
threadMetadata,
|
||||||
onStart,
|
onStart,
|
||||||
onFinish,
|
onFinish,
|
||||||
onToolEnd,
|
onToolEnd,
|
||||||
@@ -277,11 +314,15 @@ export function useThreadStream({
|
|||||||
handleStreamStart(meta.thread_id);
|
handleStreamStart(meta.thread_id);
|
||||||
setOnStreamThreadId(meta.thread_id);
|
setOnStreamThreadId(meta.thread_id);
|
||||||
const metadataAgentId = context.agent_id ?? context.agent_name;
|
const metadataAgentId = context.agent_id ?? context.agent_name;
|
||||||
if (metadataAgentId && !isMock) {
|
const extraMetadata =
|
||||||
|
threadMetadata && typeof threadMetadata === "object" ? threadMetadata : {};
|
||||||
|
const metadata: Record<string, unknown> = {
|
||||||
|
...(metadataAgentId ? { agent_id: metadataAgentId } : {}),
|
||||||
|
...extraMetadata,
|
||||||
|
};
|
||||||
|
if (Object.keys(metadata).length > 0 && !isMock) {
|
||||||
void getAPIClient()
|
void getAPIClient()
|
||||||
.threads.update(meta.thread_id, {
|
.threads.update(meta.thread_id, { metadata })
|
||||||
metadata: { agent_id: metadataAgentId },
|
|
||||||
})
|
|
||||||
.catch(() => ({}));
|
.catch(() => ({}));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/**
|
||||||
|
* 「一个任务挂多个对话」(1:N):按 thread 的 ``metadata.taskId`` 过滤出某任务下的对话列表。
|
||||||
|
*
|
||||||
|
* 新建对话时由 [[task-purpose]] 流程给 thread 打 ``metadata.taskId`` 标签
|
||||||
|
* (见 useThreadStream 的 ``threadMetadata``);这里复用服务端分页搜索按该标签过滤,
|
||||||
|
* 后端默认按 ``updated_at desc`` 排序,所以 ``threads[0]`` 即最新一条。
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { useThreadsPage } from "@/core/threads/hooks";
|
||||||
|
import type { AgentThread } from "@/core/threads/types";
|
||||||
|
|
||||||
|
export function useTaskThreads(taskId: string | null | undefined) {
|
||||||
|
const enabled = !!taskId;
|
||||||
|
// 任务工作区只在有 taskId 时渲染;无 taskId 时传一个不可能命中的过滤,返回空列表。
|
||||||
|
const query = useThreadsPage({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 100,
|
||||||
|
metadata: enabled ? { taskId } : { taskId: "__none__" },
|
||||||
|
});
|
||||||
|
const threads: AgentThread[] = enabled ? (query.data?.threads ?? []) : [];
|
||||||
|
return {
|
||||||
|
...query,
|
||||||
|
threads,
|
||||||
|
/** 最新对话(按 updated_at desc,列表第一条)。 */
|
||||||
|
latestThreadId: threads[0]?.thread_id ?? null,
|
||||||
|
/** 是否已有历史对话(决定深链进入后默认开最新还是走新建闸门)。 */
|
||||||
|
hasThreads: threads.length > 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -26,14 +26,17 @@ import { useI18n } from "@/core/i18n/hooks";
|
|||||||
import { useModels } from "@/core/models/hooks";
|
import { useModels } from "@/core/models/hooks";
|
||||||
import { useNotification } from "@/core/notification/hooks";
|
import { useNotification } from "@/core/notification/hooks";
|
||||||
import { saveLastAgentId, useThreadSettings } from "@/core/settings";
|
import { saveLastAgentId, useThreadSettings } from "@/core/settings";
|
||||||
import { useThreadStream } from "@/core/threads/hooks";
|
import { stopThreadRun, useThreadStream } from "@/core/threads/hooks";
|
||||||
import { textOfMessage } from "@/core/threads/utils";
|
import { textOfMessage } from "@/core/threads/utils";
|
||||||
import { env } from "@/env";
|
import { env } from "@/env";
|
||||||
|
import { readTaskContext } from "@/core/auth/task-purpose";
|
||||||
|
import { TaskPurposePanel } from "@/strategy-components/components/task-components/TaskPurposePanel";
|
||||||
import { desensitize } from "@/lib/desensitize";
|
import { desensitize } from "@/lib/desensitize";
|
||||||
|
|
||||||
export default function AgentChatPage({
|
export default function AgentChatPage({
|
||||||
embeddedAgentId,
|
embeddedAgentId,
|
||||||
chatBasePath,
|
chatBasePath,
|
||||||
|
taskGate,
|
||||||
}: {
|
}: {
|
||||||
/** 当作为「通用问答右侧嵌入」渲染时由父组件传入的 agent id(替代路由参数)。
|
/** 当作为「通用问答右侧嵌入」渲染时由父组件传入的 agent id(替代路由参数)。
|
||||||
* 传入即视为嵌入态:路由仍停留在 /chats/new,仅右侧问答区换成该智能体的对话。 */
|
* 传入即视为嵌入态:路由仍停留在 /chats/new,仅右侧问答区换成该智能体的对话。 */
|
||||||
@@ -43,6 +46,9 @@ export default function AgentChatPage({
|
|||||||
* 传入如 `/page/strategy/task-management/plan-task-sentiment/agent/${id}/chats`,
|
* 传入如 `/page/strategy/task-management/plan-task-sentiment/agent/${id}/chats`,
|
||||||
* 使开新会话 / 首条消息后的 URL 改写都停留在任务管理上下文(侧边栏保持对应业务高亮)。 */
|
* 使开新会话 / 首条消息后的 URL 改写都停留在任务管理上下文(侧边栏保持对应业务高亮)。 */
|
||||||
chatBasePath?: string;
|
chatBasePath?: string;
|
||||||
|
/** rwfx 任务深链闸门:新建对话时顶部展示目的树面板(覆盖确认后才开始问答),
|
||||||
|
* 并给新建 thread 打 `metadata.taskId` 标签(任务↔对话 1:N)。见 task-purpose。 */
|
||||||
|
taskGate?: boolean;
|
||||||
} = {}) {
|
} = {}) {
|
||||||
const routeBase = useRouteBase();
|
const routeBase = useRouteBase();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
@@ -57,6 +63,16 @@ export default function AgentChatPage({
|
|||||||
// 对话路由前缀:调用方可覆盖(任务深链嵌入态),否则用当前 routeBase 下的独立智能体对话路径。
|
// 对话路由前缀:调用方可覆盖(任务深链嵌入态),否则用当前 routeBase 下的独立智能体对话路径。
|
||||||
const agentChatsBase = chatBasePath ?? `${routeBase}/agents/${agent_id}/chats`;
|
const agentChatsBase = chatBasePath ?? `${routeBase}/agents/${agent_id}/chats`;
|
||||||
|
|
||||||
|
// rwfx 任务闸门:读取登录深链/「新建对话」暂存的任务上下文(taskId + 开场信息)。
|
||||||
|
const taskContext = useMemo(
|
||||||
|
() => (taskGate ? readTaskContext() : null),
|
||||||
|
[taskGate],
|
||||||
|
);
|
||||||
|
const taskId =
|
||||||
|
taskGate && taskContext && taskContext.agentId === agent_id
|
||||||
|
? taskContext.taskId
|
||||||
|
: "";
|
||||||
|
|
||||||
// If ChatPage stashed an opening message for this agent, skip the landing
|
// If ChatPage stashed an opening message for this agent, skip the landing
|
||||||
// screen on first render so the user doesn't see a flash of the welcome UI
|
// screen on first render so the user doesn't see a flash of the welcome UI
|
||||||
// before the auto-sent message takes over.
|
// before the auto-sent message takes over.
|
||||||
@@ -101,6 +117,8 @@ export default function AgentChatPage({
|
|||||||
threadId: isNewThread ? undefined : threadId,
|
threadId: isNewThread ? undefined : threadId,
|
||||||
assistantId: agent_id,
|
assistantId: agent_id,
|
||||||
context: { ...settings.context, agent_id },
|
context: { ...settings.context, agent_id },
|
||||||
|
// 任务闸门:新建 thread 打 metadata.taskId 标签,供任务对话列表(1:N)按任务过滤。
|
||||||
|
threadMetadata: taskId ? { taskId } : undefined,
|
||||||
onStart: (createdThreadId) => {
|
onStart: (createdThreadId) => {
|
||||||
setThreadId(createdThreadId);
|
setThreadId(createdThreadId);
|
||||||
setIsNewThread(false);
|
setIsNewThread(false);
|
||||||
@@ -143,6 +161,30 @@ export default function AgentChatPage({
|
|||||||
[sendMessage, threadId, agent_id],
|
[sendMessage, threadId, agent_id],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 任务流程:切换 / 新建会话时,停掉「上一会话服务端在跑」的 run(老对话要停止)。
|
||||||
|
// 仅 taskGate(rwfx 任务工作区)启用——普通问答页保留后台续跑行为不变。
|
||||||
|
const prevTaskThreadRef = useRef<string | null>(null);
|
||||||
|
useEffect(() => {
|
||||||
|
if (!taskGate) return;
|
||||||
|
const prev = prevTaskThreadRef.current;
|
||||||
|
if (prev && prev !== threadId) void stopThreadRun(prev);
|
||||||
|
prevTaskThreadRef.current = threadId ?? null;
|
||||||
|
}, [taskGate, threadId]);
|
||||||
|
useEffect(() => {
|
||||||
|
// 离开任务问答页(卸载)时也停掉当前会话的服务端 run。
|
||||||
|
return () => {
|
||||||
|
if (taskGate) void stopThreadRun(prevTaskThreadRef.current);
|
||||||
|
};
|
||||||
|
}, [taskGate]);
|
||||||
|
|
||||||
|
// 任务闸门通过(无目的数据 / 覆盖成功):发出开场信息开始问答;无开场信息则
|
||||||
|
// 仅切到对话态(隐藏面板),让用户手动输入。
|
||||||
|
const handleGateStart = useCallback(() => {
|
||||||
|
const text = taskContext?.openingText?.trim();
|
||||||
|
if (text) handleSubmit({ text, files: [] });
|
||||||
|
else setHasStartedConversation(true);
|
||||||
|
}, [handleSubmit, taskContext]);
|
||||||
|
|
||||||
// ChatPage stashes the opening message in sessionStorage when the user picks
|
// ChatPage stashes the opening message in sessionStorage when the user picks
|
||||||
// an agent on the landing screen, then redirects here. Replay it once so the
|
// an agent on the landing screen, then redirects here. Replay it once so the
|
||||||
// user doesn't have to re-type the question on the agent chat page.
|
// user doesn't have to re-type the question on the agent chat page.
|
||||||
@@ -181,6 +223,8 @@ export default function AgentChatPage({
|
|||||||
}, [thread]);
|
}, [thread]);
|
||||||
|
|
||||||
const isLandingState = isNewThread && !hasStartedConversation;
|
const isLandingState = isNewThread && !hasStartedConversation;
|
||||||
|
// 任务闸门面板:仅在新建对话且尚未开始时,于问答页顶部展示目的树 + 覆盖确认。
|
||||||
|
const showTaskGate = !!taskId && isNewThread && !hasStartedConversation;
|
||||||
const isDemoMode = env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY === "true";
|
const isDemoMode = env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY === "true";
|
||||||
|
|
||||||
const status = thread.error
|
const status = thread.error
|
||||||
@@ -245,6 +289,10 @@ export default function AgentChatPage({
|
|||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
{showTaskGate && (
|
||||||
|
<TaskPurposePanel taskId={taskId} onStart={handleGateStart} />
|
||||||
|
)}
|
||||||
|
|
||||||
{isLandingState ? (
|
{isLandingState ? (
|
||||||
/* Home: centered hero, suggested questions, and input.
|
/* Home: centered hero, suggested questions, and input.
|
||||||
Everything lives inside the scrollable main column. No fixed,
|
Everything lives inside the scrollable main column. No fixed,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import { QuestionNavigator } from "@/components/workspace/question-navigator";
|
|||||||
import { ThreadTitle } from "@/components/workspace/thread-title";
|
import { ThreadTitle } from "@/components/workspace/thread-title";
|
||||||
import { TodoList } from "@/components/workspace/todo-list";
|
import { TodoList } from "@/components/workspace/todo-list";
|
||||||
import { TokenUsageIndicator } from "@/components/workspace/token-usage-indicator";
|
import { TokenUsageIndicator } from "@/components/workspace/token-usage-indicator";
|
||||||
|
import { UserIdentityBadge } from "@/components/workspace/user-identity-badge";
|
||||||
import { Welcome } from "@/components/workspace/welcome";
|
import { Welcome } from "@/components/workspace/welcome";
|
||||||
import { CompactWelcome } from "@/components/workspace/compact-welcome";
|
import { CompactWelcome } from "@/components/workspace/compact-welcome";
|
||||||
import { readSidebarEnabled } from "@/core/page-layout/sidebar-enabled";
|
import { readSidebarEnabled } from "@/core/page-layout/sidebar-enabled";
|
||||||
@@ -481,6 +482,17 @@ export default function ChatPage() {
|
|||||||
<ExportTrigger threadId={threadId} />
|
<ExportTrigger threadId={threadId} />
|
||||||
<KnowledgeSaveTrigger threadId={threadId} />
|
<KnowledgeSaveTrigger threadId={threadId} />
|
||||||
<ArtifactTrigger />
|
<ArtifactTrigger />
|
||||||
|
{/* 不带全局顶栏(紧凑模式)时,名称+岗位回落到聊天页顶栏右侧,
|
||||||
|
与全量模式 Header 右上角保持一致。全量模式已有顶栏则不重复展示。 */}
|
||||||
|
{!compactChrome && (
|
||||||
|
<>
|
||||||
|
<div
|
||||||
|
className="bg-border/70 mx-1 h-6 w-px shrink-0"
|
||||||
|
aria-hidden
|
||||||
|
/>
|
||||||
|
<UserIdentityBadge />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<main className="flex min-h-0 max-w-full grow flex-col">
|
<main className="flex min-h-0 max-w-full grow flex-col">
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
import {
|
import {
|
||||||
BookMarkedIcon,
|
BookMarkedIcon,
|
||||||
BrainCircuitIcon,
|
BrainCircuitIcon,
|
||||||
CheckIcon,
|
|
||||||
FileTextIcon,
|
FileTextIcon,
|
||||||
GraduationCapIcon,
|
GraduationCapIcon,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
@@ -23,7 +22,9 @@ import {
|
|||||||
} from "@/components/workspace/messages";
|
} from "@/components/workspace/messages";
|
||||||
import { ThreadContext } from "@/components/workspace/messages/context";
|
import { ThreadContext } from "@/components/workspace/messages/context";
|
||||||
import { TodoList } from "@/components/workspace/todo-list";
|
import { TodoList } from "@/components/workspace/todo-list";
|
||||||
|
import { Tooltip } from "@/components/workspace/tooltip";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { TooltipProvider } from "@/components/ui/tooltip";
|
||||||
import { useAgentSelector } from "@/core/agents";
|
import { useAgentSelector } from "@/core/agents";
|
||||||
import { getAccessToken } from "@/core/auth";
|
import { getAccessToken } from "@/core/auth";
|
||||||
import { useI18n } from "@/core/i18n/hooks";
|
import { useI18n } from "@/core/i18n/hooks";
|
||||||
@@ -369,7 +370,7 @@ export default function IframeChatPage() {
|
|||||||
}, [handleInterrupt, handleSubmit]);
|
}, [handleInterrupt, handleSubmit]);
|
||||||
|
|
||||||
const isLandingState = isNewThread && !hasStartedConversation;
|
const isLandingState = isNewThread && !hasStartedConversation;
|
||||||
const bottomBarHeightClass = "pb-28";
|
const bottomBarHeightClass = "pb-24";
|
||||||
const modeButtons = [
|
const modeButtons = [
|
||||||
{
|
{
|
||||||
key: "writing",
|
key: "writing",
|
||||||
@@ -377,8 +378,7 @@ export default function IframeChatPage() {
|
|||||||
icon: FileTextIcon,
|
icon: FileTextIcon,
|
||||||
active: !!settings.context.writing_mode,
|
active: !!settings.context.writing_mode,
|
||||||
onClick: toggleWritingMode,
|
onClick: toggleWritingMode,
|
||||||
activeClassName:
|
activeClassName: "text-amber-600 hover:text-amber-700",
|
||||||
"border-amber-300 bg-amber-50 text-amber-700 hover:bg-amber-100",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "memory",
|
key: "memory",
|
||||||
@@ -386,8 +386,7 @@ export default function IframeChatPage() {
|
|||||||
icon: BrainCircuitIcon,
|
icon: BrainCircuitIcon,
|
||||||
active: settings.context.memory_injection_enabled ?? true,
|
active: settings.context.memory_injection_enabled ?? true,
|
||||||
onClick: toggleMemoryInjection,
|
onClick: toggleMemoryInjection,
|
||||||
activeClassName:
|
activeClassName: "text-blue-600 hover:text-blue-700",
|
||||||
"border-blue-300 bg-blue-50 text-blue-700 hover:bg-blue-100",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "references",
|
key: "references",
|
||||||
@@ -396,8 +395,7 @@ export default function IframeChatPage() {
|
|||||||
active: ragModeEnabled,
|
active: ragModeEnabled,
|
||||||
onClick: toggleRagMode,
|
onClick: toggleRagMode,
|
||||||
disabled: ragModeLocked,
|
disabled: ragModeLocked,
|
||||||
activeClassName:
|
activeClassName: "text-emerald-600 hover:text-emerald-700",
|
||||||
"border-emerald-300 bg-emerald-50 text-emerald-700 hover:bg-emerald-100",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "pro",
|
key: "pro",
|
||||||
@@ -405,8 +403,7 @@ export default function IframeChatPage() {
|
|||||||
icon: GraduationCapIcon,
|
icon: GraduationCapIcon,
|
||||||
active: proModeEnabled,
|
active: proModeEnabled,
|
||||||
onClick: toggleProMode,
|
onClick: toggleProMode,
|
||||||
activeClassName:
|
activeClassName: "text-violet-600 hover:text-violet-700",
|
||||||
"border-violet-300 bg-violet-50 text-violet-700 hover:bg-violet-100",
|
|
||||||
},
|
},
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
@@ -496,29 +493,32 @@ export default function IframeChatPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="absolute right-0 bottom-0 left-0 z-40 border-t bg-background/95 backdrop-blur">
|
<div className="absolute right-0 bottom-0 left-0 z-40 border-t bg-background/95 backdrop-blur">
|
||||||
<div className="mx-auto flex max-w-(--container-width-lg) flex-wrap items-center justify-center gap-2 px-4 py-4">
|
<TooltipProvider delayDuration={250}>
|
||||||
{modeButtons.map((button) => {
|
<div className="mx-auto flex max-w-(--container-width-lg) flex-wrap items-center justify-center gap-0 px-0 py-1">
|
||||||
const Icon = button.icon;
|
{modeButtons.map((button) => {
|
||||||
return (
|
const Icon = button.icon;
|
||||||
<Button
|
return (
|
||||||
key={button.key}
|
<Tooltip key={button.key} content={button.label}>
|
||||||
type="button"
|
<Button
|
||||||
variant="outline"
|
type="button"
|
||||||
disabled={button.disabled || isUploading}
|
variant="ghost"
|
||||||
onClick={button.onClick}
|
size="icon"
|
||||||
className={cn(
|
aria-label={button.label}
|
||||||
"gap-1.5 rounded-full border border-transparent bg-muted/40 text-muted-foreground shadow-none hover:bg-muted hover:text-foreground",
|
disabled={button.disabled || isUploading}
|
||||||
button.active && button.activeClassName,
|
onClick={button.onClick}
|
||||||
button.disabled && "cursor-not-allowed opacity-80",
|
className={cn(
|
||||||
)}
|
"size-9 rounded-full text-muted-foreground shadow-none hover:bg-muted/60 hover:text-foreground",
|
||||||
>
|
button.active && button.activeClassName,
|
||||||
{button.active && <CheckIcon className="size-3.5" />}
|
button.disabled && "cursor-not-allowed opacity-80",
|
||||||
<Icon className="size-3.5" />
|
)}
|
||||||
<span className="text-xs font-normal">{button.label}</span>
|
>
|
||||||
</Button>
|
<Icon className="size-4" />
|
||||||
);
|
</Button>
|
||||||
})}
|
</Tooltip>
|
||||||
</div>
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</TooltipProvider>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ export default function LoginPage() {
|
|||||||
if (cancelled) return;
|
if (cancelled) return;
|
||||||
if (detail) {
|
if (detail) {
|
||||||
persistCopTaskDetail(detail);
|
persistCopTaskDetail(detail);
|
||||||
const target = await resolveTaskDeeplinkTarget(goPath, detail);
|
const target = await resolveTaskDeeplinkTarget(goPath, detail, taskId);
|
||||||
if (cancelled) return;
|
if (cancelled) return;
|
||||||
if (target) {
|
if (target) {
|
||||||
navigate(target.path, { replace: true, state: target.state });
|
navigate(target.path, { replace: true, state: target.state });
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ import TaskPgFrom from "@/strategy-components/components/task-components/TaskPgF
|
|||||||
import TaskTyFrom from "@/strategy-components/components/task-components/TaskTyFrom";
|
import TaskTyFrom from "@/strategy-components/components/task-components/TaskTyFrom";
|
||||||
import TaskXkFrom from "@/strategy-components/components/task-components/TaskXkFrom";
|
import TaskXkFrom from "@/strategy-components/components/task-components/TaskXkFrom";
|
||||||
import TaskAnalyzes from "@/strategy-components/components/task-components/TaskAnalyzes";
|
import TaskAnalyzes from "@/strategy-components/components/task-components/TaskAnalyzes";
|
||||||
|
import {
|
||||||
|
TaskFxChat,
|
||||||
|
TaskFxIndexResolver,
|
||||||
|
TaskFxWorkspace,
|
||||||
|
} from "@/strategy-components/components/task-components/TaskFxWorkspace";
|
||||||
import { ActionAnalyzes } from "@/strategy-components/components/task-components/ActionAnalyzes";
|
import { ActionAnalyzes } from "@/strategy-components/components/task-components/ActionAnalyzes";
|
||||||
import KnowledgeBaseResourceManagement from "@/strategy-components/components/resource-management/KnowledgeBaseResourceManagement";
|
import KnowledgeBaseResourceManagement from "@/strategy-components/components/resource-management/KnowledgeBaseResourceManagement";
|
||||||
import NetworkActorResourceManagement from "@/strategy-components/components/resource-management/NetworkActorResourceManagement";
|
import NetworkActorResourceManagement from "@/strategy-components/components/resource-management/NetworkActorResourceManagement";
|
||||||
@@ -164,12 +169,26 @@ export default function StrategyRoutes() {
|
|||||||
</ChatRuntime>
|
</ChatRuntime>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
{/* 任务FX:任务工作区(左对话列表 1:N + 右问答;新建对话顶部目的树闸门)。 */}
|
||||||
<Route
|
<Route
|
||||||
path="plan-task/plan-task-fx/agent/:agent_id/chats/:thread_id"
|
path="plan-task/plan-task-fx/agent/:agent_id/chats"
|
||||||
element={
|
element={
|
||||||
<TaskEmbeddedAgentChat taskBase="/page/strategy/task-management/plan-task/plan-task-fx" />
|
<TaskFxWorkspace taskBase="/page/strategy/task-management/plan-task/plan-task-fx" />
|
||||||
}
|
}
|
||||||
/>
|
>
|
||||||
|
<Route
|
||||||
|
index
|
||||||
|
element={
|
||||||
|
<TaskFxIndexResolver taskBase="/page/strategy/task-management/plan-task/plan-task-fx" />
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path=":thread_id"
|
||||||
|
element={
|
||||||
|
<TaskFxChat taskBase="/page/strategy/task-management/plan-task/plan-task-fx" />
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</Route>
|
||||||
<Route
|
<Route
|
||||||
path="plan-task/plan-task-action"
|
path="plan-task/plan-task-action"
|
||||||
element={
|
element={
|
||||||
|
|||||||
@@ -0,0 +1,259 @@
|
|||||||
|
/**
|
||||||
|
* 任务深链(rwfx / 任务FX)的「任务工作区」:一个任务挂多个对话(1:N)。
|
||||||
|
*
|
||||||
|
* 左侧 = 该任务下的对话列表(按 metadata.taskId 过滤)+「新建对话」;
|
||||||
|
* 右下角 = 常驻浮动操作条(编辑 / 下一步 / 清除任务记录),absolute 定位,时刻可见、不被内容挤走;
|
||||||
|
* 右侧 = <Outlet/> 渲染选中的对话(AgentChatPage,新建对话顶部带目的树闸门面板)。
|
||||||
|
*
|
||||||
|
* - 进入 chats 索引:有历史 → 跳最新;无历史 → 跳 new(=新建,走闸门)。
|
||||||
|
* - 新建对话 = 直接跳入:navigate 到 chats/new;切换/新建时 AgentChatPage 会停掉老对话的服务端 run。
|
||||||
|
* - 清除任务记录:仅调 delete 接口(聊天对话保留)。
|
||||||
|
* - 编辑 / 下一步:window.open 配置里的 B 系统地址(?id=taskId)。
|
||||||
|
* 见 [[task-purpose]] / [[task-deeplink-config]]。
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { useEffect, useMemo, useState } from "react";
|
||||||
|
import { Outlet, useLocation, useNavigate, useParams } from "react-router-dom";
|
||||||
|
import { ArrowRight, ExternalLink, Loader2, MessageSquare, PlusSquare, Trash2 } from "lucide-react";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
} from "@/components/ui/dialog";
|
||||||
|
import {
|
||||||
|
buildTreemapEditUrl,
|
||||||
|
buildTreemapNextUrl,
|
||||||
|
deleteTaskPurpose,
|
||||||
|
readTaskContext,
|
||||||
|
} from "@/core/auth/task-purpose";
|
||||||
|
import { fetchTaskDeeplinkConfig } from "@/core/auth/task-deeplink-config";
|
||||||
|
import { useTaskThreads } from "@/core/threads/use-task-threads";
|
||||||
|
import { titleOfThread } from "@/core/threads/utils";
|
||||||
|
import { desensitize } from "@/lib/desensitize";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import AgentChatPage from "@/pages/AgentChatPage";
|
||||||
|
import { ChatRuntime } from "@/pages/WorkspaceRoutes";
|
||||||
|
|
||||||
|
function useChatsBase(taskBase: string): { taskId: string; chatsBase: string } {
|
||||||
|
const { agent_id } = useParams<{ agent_id: string }>();
|
||||||
|
const taskId = readTaskContext()?.taskId ?? "";
|
||||||
|
return { taskId, chatsBase: `${taskBase}/agent/${agent_id}/chats` };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 从路由路径里解析当前打开的会话 id(布局组件读不到子路由的 :thread_id,故从 path 取)。 */
|
||||||
|
function parseThreadId(pathname: string, chatsBase: string): string | null {
|
||||||
|
if (!pathname.startsWith(chatsBase)) return null;
|
||||||
|
const seg = pathname.slice(chatsBase.length).replace(/^\/+/, "").split("/")[0];
|
||||||
|
return seg && seg !== "new" ? seg : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 左侧任务对话列表 +「新建对话」。 */
|
||||||
|
function TaskConversationsList({ taskId, chatsBase }: { taskId: string; chatsBase: string }) {
|
||||||
|
const { pathname } = useLocation();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const { threads, isLoading } = useTaskThreads(taskId);
|
||||||
|
const currentThreadId = useMemo(() => parseThreadId(pathname, chatsBase), [pathname, chatsBase]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="bg-background/85 border-border/70 flex w-64 shrink-0 flex-col border-r shadow-[12px_0_30px_-30px_rgba(15,23,42,0.45)] backdrop-blur-xl dark:border-[#1b477e]/70 dark:bg-[#061b35]/82">
|
||||||
|
<div className="border-border/70 border-b p-3 dark:border-[#1b477e]/70">
|
||||||
|
<div className="mb-2 flex items-center justify-between gap-2">
|
||||||
|
<div className="min-w-0">
|
||||||
|
<div className="text-foreground text-sm font-semibold">任务对话</div>
|
||||||
|
<div className="text-muted-foreground mt-0.5 text-xs tabular-nums">
|
||||||
|
{isLoading ? "同步中" : `${threads.length} 个会话`}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
className="h-9 w-full bg-[var(--color-main)] text-white shadow-sm hover:bg-[var(--brand-950)]"
|
||||||
|
onClick={() => navigate(`${chatsBase}/new`)}
|
||||||
|
>
|
||||||
|
<PlusSquare className="h-4 w-4" /> 新建对话
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="min-h-0 flex-1 overflow-y-auto p-2">
|
||||||
|
{isLoading ? (
|
||||||
|
<div className="text-muted-foreground rounded-md border border-dashed p-3 text-center text-sm dark:border-[#1b477e]/60">
|
||||||
|
加载中…
|
||||||
|
</div>
|
||||||
|
) : threads.length === 0 ? (
|
||||||
|
<div className="text-muted-foreground rounded-md border border-dashed p-3 text-center text-sm dark:border-[#1b477e]/60">
|
||||||
|
暂无对话
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
threads.map((thread) => (
|
||||||
|
<button
|
||||||
|
key={thread.thread_id}
|
||||||
|
onClick={() => navigate(`${chatsBase}/${thread.thread_id}`)}
|
||||||
|
className={cn(
|
||||||
|
"group relative flex w-full items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm transition-colors",
|
||||||
|
"hover:bg-[var(--bg-color)] dark:hover:bg-[#0d2a4d]/85",
|
||||||
|
thread.thread_id === currentThreadId &&
|
||||||
|
"bg-[var(--bg-color)] font-medium text-[var(--color-main)] shadow-sm dark:bg-[#0d2a4d] dark:text-[#9fe3ff]",
|
||||||
|
)}
|
||||||
|
title={desensitize(titleOfThread(thread, "新对话"))}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
"absolute inset-y-2 left-0 w-0.5 rounded-full bg-transparent transition-colors",
|
||||||
|
thread.thread_id === currentThreadId && "bg-[var(--color-main)] dark:bg-[#64cdf5]",
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<MessageSquare className="text-muted-foreground group-hover:text-foreground h-3.5 w-3.5 shrink-0" />
|
||||||
|
<span className="truncate">{desensitize(titleOfThread(thread, "新对话"))}</span>
|
||||||
|
</button>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<TaskActionsPanel taskId={taskId} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 左侧任务栏底部操作区:编辑 / 下一步 / 清除任务记录。
|
||||||
|
* 跟随任务对话面板布局,不再覆盖右侧聊天输入框。
|
||||||
|
*/
|
||||||
|
function TaskActionsPanel({ taskId }: { taskId: string }) {
|
||||||
|
const [clearOpen, setClearOpen] = useState(false);
|
||||||
|
const [clearing, setClearing] = useState(false);
|
||||||
|
|
||||||
|
const openExternal = (url: string, label: string) => {
|
||||||
|
if (url) window.open(url, "_blank", "noopener,noreferrer");
|
||||||
|
else toast.error(`未配置${label}地址`);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleClear = async () => {
|
||||||
|
setClearing(true);
|
||||||
|
try {
|
||||||
|
const r = await deleteTaskPurpose(taskId);
|
||||||
|
if (r.success) toast.success("已清除任务记录");
|
||||||
|
else toast.error(r.message || "清除失败");
|
||||||
|
} catch {
|
||||||
|
toast.error("清除失败,请稍后再试");
|
||||||
|
} finally {
|
||||||
|
setClearing(false);
|
||||||
|
setClearOpen(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="border-border/70 shrink-0 border-t p-3 dark:border-[#1b477e]/70">
|
||||||
|
<div className="rounded-md border border-[var(--card-border)] bg-background/80 p-2 shadow-sm dark:border-[#2b8ffe]/45 dark:bg-[#0b2546]/72">
|
||||||
|
<div className="text-muted-foreground mb-2 px-1 text-xs font-medium">
|
||||||
|
任务操作
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-2 gap-2">
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="outline"
|
||||||
|
className="h-8 border-[var(--card-border)] bg-background/80 text-[var(--color-main)] hover:bg-[var(--bg-color)] hover:text-[var(--color-main)] dark:border-[#2b8ffe]/50 dark:bg-[#0b2546]/80 dark:text-[#bde9ff] dark:hover:bg-[#10375f]"
|
||||||
|
onClick={() => openExternal(buildTreemapEditUrl(taskId), "编辑")}
|
||||||
|
disabled={!taskId}
|
||||||
|
title="编辑任务"
|
||||||
|
>
|
||||||
|
<ExternalLink className="h-3.5 w-3.5" /> 编辑
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
className="h-8 bg-[var(--color-main)] text-white shadow-[0_8px_18px_-12px_var(--color-main)] hover:bg-[var(--brand-950)]"
|
||||||
|
onClick={() => openExternal(buildTreemapNextUrl(taskId), "下一步")}
|
||||||
|
disabled={!taskId}
|
||||||
|
title="进入下一步"
|
||||||
|
>
|
||||||
|
下一步 <ArrowRight className="h-3.5 w-3.5" />
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="ghost"
|
||||||
|
className="col-span-2 h-8 text-muted-foreground hover:bg-destructive/10 hover:text-destructive dark:text-[#ccd2da] dark:hover:bg-[#5c0011]/35"
|
||||||
|
onClick={() => setClearOpen(true)}
|
||||||
|
disabled={!taskId}
|
||||||
|
title="清除任务记录"
|
||||||
|
>
|
||||||
|
<Trash2 className="h-3.5 w-3.5" /> 清除记录
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Dialog open={clearOpen} onOpenChange={(o) => !clearing && setClearOpen(o)}>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>清除任务记录</DialogTitle>
|
||||||
|
<DialogDescription>
|
||||||
|
将清除该任务在 B 系统中的目的策划数据(聊天对话保留),是否确认?
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
<DialogFooter>
|
||||||
|
<Button variant="outline" onClick={() => setClearOpen(false)} disabled={clearing}>
|
||||||
|
取消
|
||||||
|
</Button>
|
||||||
|
<Button variant="destructive" onClick={handleClear} disabled={clearing}>
|
||||||
|
{clearing ? <Loader2 className="h-4 w-4 animate-spin" /> : "确认清除"}
|
||||||
|
</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 任务工作区布局:左列表 + 右 Outlet。 */
|
||||||
|
export function TaskFxWorkspace({ taskBase }: { taskBase: string }) {
|
||||||
|
const { taskId, chatsBase } = useChatsBase(taskBase);
|
||||||
|
// 预拉配置,保证「编辑/下一步」的同步 URL 构造能读到缓存。
|
||||||
|
useEffect(() => {
|
||||||
|
void fetchTaskDeeplinkConfig();
|
||||||
|
}, []);
|
||||||
|
return (
|
||||||
|
<div className="flex size-full min-h-0 overflow-hidden">
|
||||||
|
<TaskConversationsList taskId={taskId} chatsBase={chatsBase} />
|
||||||
|
<div className="relative min-h-0 min-w-0 flex-1">
|
||||||
|
<Outlet />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** chats 索引:有历史对话 → 跳最新;否则 → 跳 new(走闸门)。 */
|
||||||
|
export function TaskFxIndexResolver({ taskBase }: { taskBase: string }) {
|
||||||
|
const { taskId, chatsBase } = useChatsBase(taskBase);
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const { isLoading, hasThreads, latestThreadId } = useTaskThreads(taskId);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isLoading) return;
|
||||||
|
if (hasThreads && latestThreadId) {
|
||||||
|
navigate(`${chatsBase}/${latestThreadId}`, { replace: true });
|
||||||
|
} else {
|
||||||
|
navigate(`${chatsBase}/new`, { replace: true });
|
||||||
|
}
|
||||||
|
}, [isLoading, hasThreads, latestThreadId, chatsBase, navigate]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="text-muted-foreground flex size-full items-center justify-center">
|
||||||
|
<Loader2 className="h-5 w-5 animate-spin" />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 右侧对话宿主:AgentChatPage(taskGate 开启 → 新建对话顶部展示目的树闸门面板 + 老对话停止)。 */
|
||||||
|
export function TaskFxChat({ taskBase }: { taskBase: string }) {
|
||||||
|
const { agent_id } = useParams<{ agent_id: string }>();
|
||||||
|
return (
|
||||||
|
<ChatRuntime>
|
||||||
|
<AgentChatPage chatBasePath={`${taskBase}/agent/${agent_id}/chats`} taskGate />
|
||||||
|
</ChatRuntime>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,208 @@
|
|||||||
|
/**
|
||||||
|
* 任务深链(rwfx)「新建对话」前的目的树闸门面板(嵌在问答页顶部)。
|
||||||
|
*
|
||||||
|
* 展示:目的树拍平成表格(一行一条「目的→行为体→预期→因素→叙事」路径),列数随数据自适应,
|
||||||
|
* 字段/层级变动都不崩(见 flattenPurposeTree / normalizeNode 的容错)。可点「弹框查看」放大。
|
||||||
|
* 流程:点「开始问答」:
|
||||||
|
* - 已有数据 → 弹「将被覆盖,确认?」→ 确认调 delete:success=true 才 onStart();
|
||||||
|
* success=false 提示后端 message(如「行动已经开始策划,不可覆盖」)并停留。
|
||||||
|
* - 无数据 → 直接 onStart()。
|
||||||
|
* onStart 由父组件(AgentChatPage 闸门态)实现:发出开场消息、开始问答。
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { useEffect, useMemo, useState } from "react";
|
||||||
|
import { Loader2, Maximize2 } from "lucide-react";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
} from "@/components/ui/dialog";
|
||||||
|
import {
|
||||||
|
deleteTaskPurpose,
|
||||||
|
fetchTaskPurposeDetail,
|
||||||
|
flattenPurposeTree,
|
||||||
|
type PurposeTreeNode,
|
||||||
|
type TaskPurposeResult,
|
||||||
|
} from "@/core/auth/task-purpose";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
/** 目的树表格:拍平成行,列数随数据自适应;层级缺失补空、字段变动不崩。 */
|
||||||
|
function PurposeTable({ tree, className }: { tree: PurposeTreeNode[]; className?: string }) {
|
||||||
|
const rows = useMemo(() => flattenPurposeTree(tree), [tree]);
|
||||||
|
const headers = useMemo(() => {
|
||||||
|
const maxDepth = rows.reduce((m, r) => Math.max(m, r.length), 0);
|
||||||
|
return Array.from({ length: maxDepth }, (_, i) => {
|
||||||
|
const r = rows.find((row) => row[i]);
|
||||||
|
return r?.[i]?.label ?? `层级${i + 1}`;
|
||||||
|
});
|
||||||
|
}, [rows]);
|
||||||
|
|
||||||
|
if (rows.length === 0) {
|
||||||
|
return <div className="text-muted-foreground py-1 text-sm">暂无目的数据,可直接开始问答。</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={cn("overflow-auto", className)}>
|
||||||
|
<table className="w-full border-collapse text-sm">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
{headers.map((h, i) => (
|
||||||
|
<th
|
||||||
|
key={i}
|
||||||
|
className="bg-muted/60 border-border/60 sticky top-0 border px-3 py-1.5 text-left font-medium whitespace-nowrap"
|
||||||
|
>
|
||||||
|
{h}
|
||||||
|
</th>
|
||||||
|
))}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{rows.map((row, ri) => (
|
||||||
|
<tr key={ri} className="even:bg-muted/30 align-top">
|
||||||
|
{headers.map((_, ci) => {
|
||||||
|
const cell = row[ci];
|
||||||
|
return (
|
||||||
|
<td key={ci} className="border-border/60 border px-3 py-1.5">
|
||||||
|
{cell ? (
|
||||||
|
<>
|
||||||
|
<span>{cell.text || "(空)"}</span>
|
||||||
|
{cell.reason ? (
|
||||||
|
<span className="text-muted-foreground block text-xs">理由:{cell.reason}</span>
|
||||||
|
) : null}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<span className="text-muted-foreground/60">—</span>
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function TaskPurposePanel({
|
||||||
|
taskId,
|
||||||
|
onStart,
|
||||||
|
}: {
|
||||||
|
taskId: string;
|
||||||
|
/** 闸门通过(无数据 / 覆盖成功),开始问答。 */
|
||||||
|
onStart: () => void;
|
||||||
|
}) {
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [result, setResult] = useState<TaskPurposeResult | null>(null);
|
||||||
|
const [confirmOpen, setConfirmOpen] = useState(false);
|
||||||
|
const [working, setWorking] = useState(false);
|
||||||
|
const [zoomOpen, setZoomOpen] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let cancelled = false;
|
||||||
|
setLoading(true);
|
||||||
|
fetchTaskPurposeDetail(taskId)
|
||||||
|
.then((r) => {
|
||||||
|
if (!cancelled) setResult(r);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
if (!cancelled) setResult({ tree: [], hasData: false });
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
if (!cancelled) setLoading(false);
|
||||||
|
});
|
||||||
|
return () => {
|
||||||
|
cancelled = true;
|
||||||
|
};
|
||||||
|
}, [taskId]);
|
||||||
|
|
||||||
|
const handleStart = () => {
|
||||||
|
if (result?.hasData) setConfirmOpen(true); // 有数据 → 先确认覆盖
|
||||||
|
else onStart(); // 无数据 → 直接开始
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleConfirmOverwrite = async () => {
|
||||||
|
setWorking(true);
|
||||||
|
try {
|
||||||
|
const r = await deleteTaskPurpose(taskId);
|
||||||
|
if (r.success) {
|
||||||
|
setConfirmOpen(false);
|
||||||
|
onStart();
|
||||||
|
} else {
|
||||||
|
toast.error(r.message || "无法覆盖,请稍后再试");
|
||||||
|
setConfirmOpen(false);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
toast.error("覆盖失败,请稍后再试");
|
||||||
|
setConfirmOpen(false);
|
||||||
|
} finally {
|
||||||
|
setWorking(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const hasTree = !!result && result.tree.length > 0;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="border-border/70 bg-card/60 shrink-0 border-b px-4 py-3">
|
||||||
|
<div className="mb-2 flex items-center justify-between gap-2">
|
||||||
|
<span className="text-sm font-medium">任务目的(任务 {taskId})</span>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
{hasTree && (
|
||||||
|
<Button size="sm" variant="outline" onClick={() => setZoomOpen(true)}>
|
||||||
|
<Maximize2 className="h-3.5 w-3.5" /> 弹框查看
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<Button size="sm" onClick={handleStart} disabled={loading || working}>
|
||||||
|
{result?.hasData ? "覆盖并开始问答" : "开始问答"}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{loading ? (
|
||||||
|
<div className="text-muted-foreground flex items-center gap-2 py-2 text-sm">
|
||||||
|
<Loader2 className="h-4 w-4 animate-spin" /> 正在查询任务目的…
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<PurposeTable tree={result?.tree ?? []} className="max-h-48 rounded border border-border/60" />
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* 弹框查看:放大显示完整表格 */}
|
||||||
|
<Dialog open={zoomOpen} onOpenChange={setZoomOpen}>
|
||||||
|
<DialogContent className="max-w-4xl">
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>任务目的(任务 {taskId})</DialogTitle>
|
||||||
|
</DialogHeader>
|
||||||
|
<PurposeTable tree={result?.tree ?? []} className="max-h-[70vh] rounded border border-border/60" />
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
|
||||||
|
{/* 覆盖确认 */}
|
||||||
|
<Dialog open={confirmOpen} onOpenChange={(o) => !working && setConfirmOpen(o)}>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>确认覆盖</DialogTitle>
|
||||||
|
<DialogDescription>
|
||||||
|
检测到该任务已有目的数据,继续问答将覆盖原有数据,是否确认?
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
<DialogFooter>
|
||||||
|
<Button variant="outline" onClick={() => setConfirmOpen(false)} disabled={working}>
|
||||||
|
取消
|
||||||
|
</Button>
|
||||||
|
<Button onClick={handleConfirmOverwrite} disabled={working}>
|
||||||
|
{working ? <Loader2 className="h-4 w-4 animate-spin" /> : "确认覆盖"}
|
||||||
|
</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TaskPurposePanel;
|
||||||
@@ -370,7 +370,7 @@ shown to users ARE the **recommended questions** (`recommended_questions` table)
|
|||||||
types into the existing "我的" tables, idempotently:
|
types into the existing "我的" tables, idempotently:
|
||||||
- agents → `agent_favorites` rows with `origin='position'`
|
- agents → `agent_favorites` rows with `origin='position'`
|
||||||
- **skills → `skill_favorites` rows with `origin='position'`** (table
|
- **skills → `skill_favorites` rows with `origin='position'`** (table
|
||||||
`SkillFavoriteRow`, migration `20260616_02`, auto-created by `create_all`)
|
`SkillFavoriteRow`, migration `20260616_04`, auto-created by `create_all`)
|
||||||
- scheduled tasks → `scheduled_task_subscriptions` rows with `origin='position'`
|
- scheduled tasks → `scheduled_task_subscriptions` rows with `origin='position'`
|
||||||
|
|
||||||
Skills behave **exactly like agents**: a position only *adds* its tagged skills
|
Skills behave **exactly like agents**: a position only *adds* its tagged skills
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ from app.gateway.routers import (
|
|||||||
parallel_agent_tasks,
|
parallel_agent_tasks,
|
||||||
parallel_agents,
|
parallel_agents,
|
||||||
positions,
|
positions,
|
||||||
|
public_config,
|
||||||
public_embed,
|
public_embed,
|
||||||
public_leaderboard,
|
public_leaderboard,
|
||||||
public_scheduled_tasks,
|
public_scheduled_tasks,
|
||||||
@@ -1376,6 +1377,7 @@ This gateway provides custom endpoints for models, MCP configuration, skills, an
|
|||||||
|
|
||||||
# Public embed Q&A status polling (/api/public/embed/*)
|
# Public embed Q&A status polling (/api/public/embed/*)
|
||||||
app.include_router(public_embed.router)
|
app.include_router(public_embed.router)
|
||||||
|
app.include_router(public_config.router)
|
||||||
app.include_router(html_page_favorites.router)
|
app.include_router(html_page_favorites.router)
|
||||||
|
|
||||||
# Product knowledge base API is mounted at /api/knowledge
|
# Product knowledge base API is mounted at /api/knowledge
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
"""公开只读配置接口(前端运行时读取 config.yaml 派生值)。
|
||||||
|
|
||||||
|
目前只暴露 ``task_deeplink`` 段(任务深链 rwfx 的目的树闸门地址 + 测试开关 +
|
||||||
|
测试假数据),供前端登录深链流程在运行时读取——无需把这些地址硬编码进前端,
|
||||||
|
改 ``config.yaml`` 即时生效(Gateway mtime 热重载)。
|
||||||
|
|
||||||
|
**无鉴权**:路由挂在 ``/api/public/`` 前缀下,已被
|
||||||
|
``auth_middleware._PUBLIC_PATH_PREFIXES`` 白名单放行。段内只有地址与开关,不含密钥。
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from fastapi import APIRouter
|
||||||
|
|
||||||
|
from deerflow.config import get_app_config
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
router = APIRouter(prefix="/api/public/config", tags=["public-config"])
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/task-deeplink")
|
||||||
|
async def get_task_deeplink_config() -> dict:
|
||||||
|
"""返回 ``config.yaml`` 的 ``task_deeplink`` 段(含 test/delete_test/各 URL/mock)。"""
|
||||||
|
config = get_app_config()
|
||||||
|
return config.task_deeplink.model_dump()
|
||||||
@@ -418,3 +418,40 @@ log_system:
|
|||||||
enabled: true
|
enabled: true
|
||||||
url: 'https://your-log-system.example.com'
|
url: 'https://your-log-system.example.com'
|
||||||
label: '日志系统'
|
label: '日志系统'
|
||||||
|
|
||||||
|
task_deeplink:
|
||||||
|
# 线上接口未通时用假数据;两个开关互相独立。
|
||||||
|
test: true # 目的树查询走 mock.purpose_detail 假数据
|
||||||
|
delete_test: true # 删除接口走 mock.delete 假数据(该接口尚未开发完)
|
||||||
|
purpose_detail_url: "https://ch1.b.uat.4.cn/consumer/taskAnalyseSearch/getTaskPurposeDetail"
|
||||||
|
delete_url: "https://ch1.b.uat.4.cn/consumer/taskAnalyseSearch/delete"
|
||||||
|
treemap_edit_url: "https://ch1.b.uat.4.cn/web/#/task/item-aicoh/step-mode-treemap-full-edit"
|
||||||
|
treemap_next_url: "https://ch1.b.uat.4.cn/web/#/task/item-aicoh/step-mode-treemap-full-next"
|
||||||
|
mock:
|
||||||
|
# test=true 时原样返回给前端(结构同真实 getTaskPurposeDetail 返回)。
|
||||||
|
purpose_detail:
|
||||||
|
state: "200"
|
||||||
|
msg: "操作成功!"
|
||||||
|
data:
|
||||||
|
- purposeDto: { id: 5837, zzPurpose: "目的01", selectedFlag: 1, taskId: 3324, recDetailId: 4271 }
|
||||||
|
childrenList:
|
||||||
|
- actorDto: { id: 9101, taskId: 3324, purposeId: 5837, actorName: "行为体01", actorOrgan: "行为体01", recReason: "行为体01理由", selectedFlag: 1 }
|
||||||
|
childrenList:
|
||||||
|
- expectedBehaviorDto: { id: 6910, taskId: 3324, purposeId: 5837, behavior: "预期01", recReason: "预期01理由", selectedFlag: "1" }
|
||||||
|
childrenList:
|
||||||
|
- drivingFactorDto: { id: 7964, taskId: 3324, purposeId: 5837, drivingFactor: "预期01因素", selectedFlag: 1 }
|
||||||
|
childrenList:
|
||||||
|
- narrationDto: { id: 6500, purposeId: 5837, taskId: 3324, narration: "叙事01", recReason: "叙事01理由", selectedFlag: 1 }
|
||||||
|
childrenList: []
|
||||||
|
- actorDto: { id: 9102, taskId: 3324, purposeId: 5837, actorName: "行为体02", actorOrgan: "行为体02", recReason: "行为体02理由", selectedFlag: 1 }
|
||||||
|
childrenList:
|
||||||
|
- expectedBehaviorDto: { id: 6911, taskId: 3324, purposeId: 5837, behavior: "预期02", recReason: "预期02理由", selectedFlag: "1" }
|
||||||
|
childrenList:
|
||||||
|
- drivingFactorDto: { id: 7965, taskId: 3324, purposeId: 5837, drivingFactor: "预期02因素", selectedFlag: 1 }
|
||||||
|
childrenList:
|
||||||
|
- narrationDto: { id: 6501, purposeId: 5837, taskId: 3324, narration: "叙事02", recReason: "叙事02理由", selectedFlag: 1 }
|
||||||
|
childrenList: []
|
||||||
|
# delete_test=true 时原样返回给前端。改 success 测「成功覆盖 / 不可覆盖」两条分支。
|
||||||
|
delete:
|
||||||
|
message: "行动已经开始策划,不可覆盖"
|
||||||
|
success: true
|
||||||
@@ -15,10 +15,10 @@ from deerflow.config.checkpointer_config import CheckpointerConfig, load_checkpo
|
|||||||
from deerflow.config.database_config import DatabaseConfig
|
from deerflow.config.database_config import DatabaseConfig
|
||||||
from deerflow.config.extensions_config import ExtensionsConfig
|
from deerflow.config.extensions_config import ExtensionsConfig
|
||||||
from deerflow.config.gateway_config import GatewayConfig
|
from deerflow.config.gateway_config import GatewayConfig
|
||||||
from deerflow.config.guardrails_config import GuardrailsConfig, load_guardrails_config_from_dict
|
from deerflow.config.guardrails_config import GuardrailsConfig, load_guardrails_config_from_dict
|
||||||
from deerflow.config.knowledge_config import KnowledgeConfig
|
from deerflow.config.knowledge_config import KnowledgeConfig
|
||||||
from deerflow.config.knowledge_ingest_config import KnowledgeIngestConfig
|
from deerflow.config.knowledge_ingest_config import KnowledgeIngestConfig
|
||||||
from deerflow.config.log_system_config import LogSystemConfig
|
from deerflow.config.log_system_config import LogSystemConfig
|
||||||
from deerflow.config.login_config import AuthLoginConfig
|
from deerflow.config.login_config import AuthLoginConfig
|
||||||
from deerflow.config.memory_config import MemoryConfig, load_memory_config_from_dict
|
from deerflow.config.memory_config import MemoryConfig, load_memory_config_from_dict
|
||||||
from deerflow.config.model_config import ModelConfig
|
from deerflow.config.model_config import ModelConfig
|
||||||
@@ -33,6 +33,7 @@ from deerflow.config.skills_config import SkillsConfig
|
|||||||
from deerflow.config.stream_bridge_config import StreamBridgeConfig, load_stream_bridge_config_from_dict
|
from deerflow.config.stream_bridge_config import StreamBridgeConfig, load_stream_bridge_config_from_dict
|
||||||
from deerflow.config.subagents_config import SubagentsAppConfig, load_subagents_config_from_dict
|
from deerflow.config.subagents_config import SubagentsAppConfig, load_subagents_config_from_dict
|
||||||
from deerflow.config.summarization_config import SummarizationConfig, load_summarization_config_from_dict
|
from deerflow.config.summarization_config import SummarizationConfig, load_summarization_config_from_dict
|
||||||
|
from deerflow.config.task_deeplink_config import TaskDeeplinkConfig
|
||||||
from deerflow.config.title_config import TitleConfig, load_title_config_from_dict
|
from deerflow.config.title_config import TitleConfig, load_title_config_from_dict
|
||||||
from deerflow.config.token_usage_config import TokenUsageConfig
|
from deerflow.config.token_usage_config import TokenUsageConfig
|
||||||
from deerflow.config.tool_config import ToolConfig, ToolGroupConfig
|
from deerflow.config.tool_config import ToolConfig, ToolGroupConfig
|
||||||
@@ -136,9 +137,10 @@ class AppConfig(BaseModel):
|
|||||||
run_events: RunEventsConfig = Field(default_factory=RunEventsConfig, description="Run event storage configuration")
|
run_events: RunEventsConfig = Field(default_factory=RunEventsConfig, description="Run event storage configuration")
|
||||||
checkpointer: CheckpointerConfig | None = Field(default=None, description="Checkpointer configuration")
|
checkpointer: CheckpointerConfig | None = Field(default=None, description="Checkpointer configuration")
|
||||||
stream_bridge: StreamBridgeConfig | None = Field(default=None, description="Stream bridge configuration")
|
stream_bridge: StreamBridgeConfig | None = Field(default=None, description="Stream bridge configuration")
|
||||||
browser_context: BrowserContextConfig = Field(default_factory=BrowserContextConfig, description="Optional browser page capture integration")
|
browser_context: BrowserContextConfig = Field(default_factory=BrowserContextConfig, description="Optional browser page capture integration")
|
||||||
knowledge: KnowledgeConfig = Field(default_factory=KnowledgeConfig, description="Product knowledge base (obsidian-wiki compatible vault) configuration")
|
knowledge: KnowledgeConfig = Field(default_factory=KnowledgeConfig, description="Product knowledge base (obsidian-wiki compatible vault) configuration")
|
||||||
knowledge_ingest: KnowledgeIngestConfig = Field(default_factory=KnowledgeIngestConfig, description="External knowledge-ingest endpoint configuration")
|
knowledge_ingest: KnowledgeIngestConfig = Field(default_factory=KnowledgeIngestConfig, description="External knowledge-ingest endpoint configuration")
|
||||||
|
task_deeplink: TaskDeeplinkConfig = Field(default_factory=TaskDeeplinkConfig, description="任务深链(rwfx)目的树闸门与跳转地址配置(前端经 /api/public/config/task-deeplink 读取)")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def resolve_config_path(cls, config_path: str | None = None) -> Path:
|
def resolve_config_path(cls, config_path: str | None = None) -> Path:
|
||||||
@@ -387,26 +389,26 @@ def _get_config_mtime(config_path: Path) -> float | None:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def _load_and_cache_app_config(config_path: str | None = None) -> AppConfig:
|
def _load_and_cache_app_config(config_path: str | None = None) -> AppConfig:
|
||||||
"""Load config from disk and refresh cache metadata."""
|
"""Load config from disk and refresh cache metadata."""
|
||||||
global _app_config, _app_config_path, _app_config_mtime, _app_config_skill_evolution_overrides_mtime, _app_config_is_custom
|
global _app_config, _app_config_path, _app_config_mtime, _app_config_skill_evolution_overrides_mtime, _app_config_is_custom
|
||||||
|
|
||||||
resolved_path = AppConfig.resolve_config_path(config_path)
|
resolved_path = AppConfig.resolve_config_path(config_path)
|
||||||
_app_config = AppConfig.from_file(str(resolved_path))
|
_app_config = AppConfig.from_file(str(resolved_path))
|
||||||
_app_config_path = resolved_path
|
_app_config_path = resolved_path
|
||||||
_app_config_mtime = _get_config_mtime(resolved_path)
|
_app_config_mtime = _get_config_mtime(resolved_path)
|
||||||
_app_config_skill_evolution_overrides_mtime = _get_skill_evolution_overrides_mtime()
|
_app_config_skill_evolution_overrides_mtime = _get_skill_evolution_overrides_mtime()
|
||||||
_app_config_is_custom = False
|
_app_config_is_custom = False
|
||||||
summarization = _app_config.summarization
|
summarization = _app_config.summarization
|
||||||
logger.info(
|
logger.info(
|
||||||
"Loaded AppConfig from %s; summarization enabled=%s trigger=%s keep=%s trim_tokens_to_summarize=%s",
|
"Loaded AppConfig from %s; summarization enabled=%s trigger=%s keep=%s trim_tokens_to_summarize=%s",
|
||||||
resolved_path,
|
resolved_path,
|
||||||
summarization.enabled,
|
summarization.enabled,
|
||||||
summarization.trigger,
|
summarization.trigger,
|
||||||
summarization.keep,
|
summarization.keep,
|
||||||
summarization.trim_tokens_to_summarize,
|
summarization.trim_tokens_to_summarize,
|
||||||
)
|
)
|
||||||
return _app_config
|
return _app_config
|
||||||
|
|
||||||
|
|
||||||
def get_app_config() -> AppConfig:
|
def get_app_config() -> AppConfig:
|
||||||
|
|||||||
+51
@@ -0,0 +1,51 @@
|
|||||||
|
"""任务深链(``goPath=rwfx``)的「目的树闸门 + 跳转」配置。
|
||||||
|
|
||||||
|
前端(登录深链流程)通过公开只读接口 ``GET /api/public/config/task-deeplink``
|
||||||
|
读取这一段:所有外部地址都是**完整 URL**(调用时仅追加 ``?taskId=`` / ``?id=``),
|
||||||
|
随时改 ``config.yaml`` 即可(Gateway 有 mtime 热重载,无需重新构建前端)。
|
||||||
|
|
||||||
|
测试开关(线上接口未通时用假数据,互相独立):
|
||||||
|
- ``test`` → 目的树查询(``purpose_detail_url``)走 ``mock.purpose_detail`` 假数据。
|
||||||
|
- ``delete_test`` → 删除接口(``delete_url``)走 ``mock.delete`` 假数据(该接口尚未开发完时打开)。
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from pydantic import BaseModel, ConfigDict, Field
|
||||||
|
|
||||||
|
|
||||||
|
class TaskDeeplinkConfig(BaseModel):
|
||||||
|
"""rwfx 任务深链的目的树查询 / 删除接口与跳转页地址。"""
|
||||||
|
|
||||||
|
model_config = ConfigDict(extra="allow")
|
||||||
|
|
||||||
|
test: bool = Field(
|
||||||
|
default=False,
|
||||||
|
description="为真时前端目的树查询走 mock.purpose_detail 假数据(不打真实接口)",
|
||||||
|
)
|
||||||
|
delete_test: bool = Field(
|
||||||
|
default=False,
|
||||||
|
description="为真时前端删除接口走 mock.delete 假数据(删除接口未开发完时打开)",
|
||||||
|
)
|
||||||
|
purpose_detail_url: str = Field(
|
||||||
|
default="",
|
||||||
|
description="目的树查询完整 URL,调用时追加 ?taskId=",
|
||||||
|
)
|
||||||
|
delete_url: str = Field(
|
||||||
|
default="",
|
||||||
|
description="删除完整 URL,调用时追加 ?taskId=",
|
||||||
|
)
|
||||||
|
treemap_edit_url: str = Field(
|
||||||
|
default="",
|
||||||
|
description="B 系统树形完整编辑页 URL,跳转时追加 ?id=",
|
||||||
|
)
|
||||||
|
treemap_next_url: str = Field(
|
||||||
|
default="",
|
||||||
|
description="B 系统树形下一步页 URL,跳转时追加 ?id=",
|
||||||
|
)
|
||||||
|
mock: dict[str, Any] = Field(
|
||||||
|
default_factory=dict,
|
||||||
|
description="test/delete_test 为真时返回的假数据:{purpose_detail: {...}, delete: {message, success}}",
|
||||||
|
)
|
||||||
+10
-4
@@ -7,8 +7,14 @@ draft is keyed/shared by ``task_id`` and is no longer partitioned by ``user_id``
|
|||||||
``create_all`` adds the column for brand-new DBs; this revision patches DBs that
|
``create_all`` adds the column for brand-new DBs; this revision patches DBs that
|
||||||
already have the table.
|
already have the table.
|
||||||
|
|
||||||
Revision ID: 20260611_01
|
Note: this migration originally shared the revision id ``20260611_01`` with
|
||||||
Revises: 20260609_02
|
``20260611_01_agents_skills_square_id`` (both branched off ``20260609_02``),
|
||||||
|
which corrupted the alembic DAG ("present more than once" + phantom heads). It
|
||||||
|
was renumbered to ``20260611_02`` and re-chained after that revision so the
|
||||||
|
history is linear and single-headed.
|
||||||
|
|
||||||
|
Revision ID: 20260611_02
|
||||||
|
Revises: 20260611_01
|
||||||
Create Date: 2026-06-11
|
Create Date: 2026-06-11
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -19,8 +25,8 @@ from alembic import op
|
|||||||
from sqlalchemy import inspect
|
from sqlalchemy import inspect
|
||||||
|
|
||||||
|
|
||||||
revision = "20260611_01"
|
revision = "20260611_02"
|
||||||
down_revision = "20260609_02"
|
down_revision = "20260611_01"
|
||||||
branch_labels = None
|
branch_labels = None
|
||||||
depends_on = None
|
depends_on = None
|
||||||
|
|
||||||
+2
-2
@@ -6,7 +6,7 @@
|
|||||||
LONGTEXT(计划 JSON 可超 64 KB)。
|
LONGTEXT(计划 JSON 可超 64 KB)。
|
||||||
|
|
||||||
Revision ID: 20260612_01
|
Revision ID: 20260612_01
|
||||||
Revises: 20260611_01
|
Revises: 20260611_02
|
||||||
Create Date: 2026-06-12
|
Create Date: 2026-06-12
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ from sqlalchemy.dialects.mysql import LONGTEXT
|
|||||||
|
|
||||||
|
|
||||||
revision = "20260612_01"
|
revision = "20260612_01"
|
||||||
down_revision = "20260611_01"
|
down_revision = "20260611_02"
|
||||||
branch_labels = None
|
branch_labels = None
|
||||||
depends_on = None
|
depends_on = None
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
"""Add always_on (常驻/免压缩) column to skills table.
|
"""Add always_on (常驻/免压缩) column to skills table.
|
||||||
|
|
||||||
Revision ID: 20260616_03
|
Revision ID: 20260616_03
|
||||||
Revises: 20260616_02
|
Revises: 20260616_04
|
||||||
Create Date: 2026-06-16
|
Create Date: 2026-06-16
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ from sqlalchemy import inspect
|
|||||||
|
|
||||||
|
|
||||||
revision = "20260616_03"
|
revision = "20260616_03"
|
||||||
down_revision = "20260616_02"
|
down_revision = "20260616_04"
|
||||||
branch_labels = None
|
branch_labels = None
|
||||||
depends_on = None
|
depends_on = None
|
||||||
|
|
||||||
|
|||||||
+10
-4
@@ -10,8 +10,14 @@ startup (new tables are always created, even on existing DBs); this migration
|
|||||||
keeps the alembic history consistent per the repo convention (see
|
keeps the alembic history consistent per the repo convention (see
|
||||||
backend/CLAUDE.md → Schema Migrations).
|
backend/CLAUDE.md → Schema Migrations).
|
||||||
|
|
||||||
Revision ID: 20260616_02
|
Note: this migration originally shared the revision id ``20260616_02`` with
|
||||||
Revises: 20260616_01
|
``20260616_02_knowledge_folders_templates`` (both branched off ``20260616_01``),
|
||||||
|
which corrupted the alembic DAG ("present more than once" + phantom heads). It
|
||||||
|
was renumbered to ``20260616_04`` and re-chained after that revision so the
|
||||||
|
history is linear and single-headed.
|
||||||
|
|
||||||
|
Revision ID: 20260616_04
|
||||||
|
Revises: 20260616_02
|
||||||
Create Date: 2026-06-16
|
Create Date: 2026-06-16
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -22,8 +28,8 @@ from alembic import op
|
|||||||
from sqlalchemy import inspect
|
from sqlalchemy import inspect
|
||||||
|
|
||||||
|
|
||||||
revision = "20260616_02"
|
revision = "20260616_04"
|
||||||
down_revision = "20260616_01"
|
down_revision = "20260616_02"
|
||||||
branch_labels = None
|
branch_labels = None
|
||||||
depends_on = None
|
depends_on = None
|
||||||
|
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
"""Merge the chain-seat-mode and skill-always-on migration heads.
|
||||||
|
|
||||||
|
Two lineages both descend from ``20260612_01`` (roundtable_jobs orchestration
|
||||||
|
plan): ``20260615_01`` (chain seat mode) branched directly off it, while the
|
||||||
|
``20260616_*`` line (positions → knowledge folders/templates → skill_favorites →
|
||||||
|
skill always_on) is the other branch. That left the graph with two heads
|
||||||
|
(``20260615_01`` and ``20260616_03``) so ``alembic upgrade head`` failed with
|
||||||
|
"Multiple head revisions are present". This no-op merge revision joins both
|
||||||
|
lineages so ``upgrade head`` resolves to a single head again.
|
||||||
|
|
||||||
|
Revision ID: 20260617_01
|
||||||
|
Revises: 20260615_01, 20260616_03
|
||||||
|
Create Date: 2026-06-17
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|
||||||
|
revision = "20260617_01"
|
||||||
|
down_revision = ("20260615_01", "20260616_03")
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
pass
|
||||||
@@ -324,3 +324,44 @@ summarization:
|
|||||||
type: tokens
|
type: tokens
|
||||||
value: 40000
|
value: 40000
|
||||||
trim_tokens_to_summarize: 8000
|
trim_tokens_to_summarize: 8000
|
||||||
|
|
||||||
|
# ───────────────────────────────────────────────────────────────────────────
|
||||||
|
# 任务深链(goPath=rwfx):目的树闸门 + 问答后跳转。前端经公开只读接口
|
||||||
|
# GET /api/public/config/task-deeplink 读取。地址都是完整 URL(调用时仅追加
|
||||||
|
# ?taskId= / ?id=),随时改这里即可(Gateway mtime 热重载,前端无需重建)。
|
||||||
|
task_deeplink:
|
||||||
|
# 线上接口未通时用假数据;两个开关互相独立。
|
||||||
|
test: true # 目的树查询走 mock.purpose_detail 假数据
|
||||||
|
delete_test: true # 删除接口走 mock.delete 假数据(该接口尚未开发完)
|
||||||
|
purpose_detail_url: "https://ch1.b.uat.4.cn/consumer/taskAnalyseSearch/getTaskPurposeDetail"
|
||||||
|
delete_url: "https://ch1.b.uat.4.cn/consumer/taskAnalyseSearch/delete"
|
||||||
|
treemap_edit_url: "https://ch1.b.uat.4.cn/web/#/task/item-aicoh/step-mode-treemap-full-edit"
|
||||||
|
treemap_next_url: "https://ch1.b.uat.4.cn/web/#/task/item-aicoh/step-mode-treemap-full-next"
|
||||||
|
mock:
|
||||||
|
# test=true 时原样返回给前端(结构同真实 getTaskPurposeDetail 返回)。
|
||||||
|
purpose_detail:
|
||||||
|
state: "200"
|
||||||
|
msg: "操作成功!"
|
||||||
|
data:
|
||||||
|
- purposeDto: { id: 5837, zzPurpose: "目的01", selectedFlag: 1, taskId: 3324, recDetailId: 4271 }
|
||||||
|
childrenList:
|
||||||
|
- actorDto: { id: 9101, taskId: 3324, purposeId: 5837, actorName: "行为体01", actorOrgan: "行为体01", recReason: "行为体01理由", selectedFlag: 1 }
|
||||||
|
childrenList:
|
||||||
|
- expectedBehaviorDto: { id: 6910, taskId: 3324, purposeId: 5837, behavior: "预期01", recReason: "预期01理由", selectedFlag: "1" }
|
||||||
|
childrenList:
|
||||||
|
- drivingFactorDto: { id: 7964, taskId: 3324, purposeId: 5837, drivingFactor: "预期01因素", selectedFlag: 1 }
|
||||||
|
childrenList:
|
||||||
|
- narrationDto: { id: 6500, purposeId: 5837, taskId: 3324, narration: "叙事01", recReason: "叙事01理由", selectedFlag: 1 }
|
||||||
|
childrenList: []
|
||||||
|
- actorDto: { id: 9102, taskId: 3324, purposeId: 5837, actorName: "行为体02", actorOrgan: "行为体02", recReason: "行为体02理由", selectedFlag: 1 }
|
||||||
|
childrenList:
|
||||||
|
- expectedBehaviorDto: { id: 6911, taskId: 3324, purposeId: 5837, behavior: "预期02", recReason: "预期02理由", selectedFlag: "1" }
|
||||||
|
childrenList:
|
||||||
|
- drivingFactorDto: { id: 7965, taskId: 3324, purposeId: 5837, drivingFactor: "预期02因素", selectedFlag: 1 }
|
||||||
|
childrenList:
|
||||||
|
- narrationDto: { id: 6501, purposeId: 5837, taskId: 3324, narration: "叙事02", recReason: "叙事02理由", selectedFlag: 1 }
|
||||||
|
childrenList: []
|
||||||
|
# delete_test=true 时原样返回给前端。改 success 测「成功覆盖 / 不可覆盖」两条分支。
|
||||||
|
delete:
|
||||||
|
message: "行动已经开始策划,不可覆盖"
|
||||||
|
success: true
|
||||||
Reference in new issue
Block a user