Merge remote-tracking branch 'origin/pr-589' into codex/pr-557-589-security-integration

# Conflicts:
#	docs/content/docs/backend/http-api.mdx
This commit is contained in:
ddCat
2026-09-22 11:20:54 +08:00
20 changed files with 2036 additions and 34 deletions

View File

@@ -1102,7 +1102,7 @@ function ApprovalCard({ approval, theme, submitting, onFocusNode, onReasonChange
}
function ApprovalPreviewItemView({ item, theme, onFocusNode }: { item: ReturnType<typeof agentApprovalPresentation>["items"][number]; theme: CanvasTheme; onFocusNode?: (nodeId: string) => void }) {
const operationLabel = item.operation === "add_node" ? "新增" : item.operation === "update_node" ? "修改" : item.operation === "connect_nodes" ? "连线" : item.operation === "create_storyboard" ? "创建分镜" : item.operation === "edit_storyboard" ? "修改分镜" : item.operation === "plan_step" ? "计划" : "生成";
const operationLabel = item.operation === "add_node" ? "新增" : item.operation === "update_node" ? "修改" : item.operation === "connect_nodes" ? "连线" : item.operation === "arrange_nodes" ? "整理" : item.operation === "create_storyboard" ? "创建分镜" : item.operation === "edit_storyboard" ? "修改分镜" : item.operation === "plan_step" ? "计划" : "生成";
const renderNode = (title: string | undefined, id: string | undefined, typeLabel: string | undefined, role: "source" | "target" | "node") => {
if (!title) return null;
const content = <><span className="canvas-agent-approval-node-title">{title}</span>{typeLabel ? <span className="canvas-agent-approval-node-type">{typeLabel}</span> : null}</>;

View File

@@ -931,6 +931,7 @@
.canvas-agent-approval-operation-add_node { background: #dcfce7; color: #166534; }
.canvas-agent-approval-operation-update_node { background: #dbeafe; color: #1d4ed8; }
.canvas-agent-approval-operation-connect_nodes { background: #fef3c7; color: #92400e; }
.canvas-agent-approval-operation-arrange_nodes { background: #ccfbf1; color: #115e59; }
.canvas-agent-approval-operation-generate_media { background: #f3e8ff; color: #7e22ce; }
.canvas-agent-approval-node,

View File

@@ -41,7 +41,7 @@ function fieldLabel(key: string, nodeType: string): string {
}
function operation(value: unknown): AgentApprovalPreviewOperation | null {
return value === "add_node" || value === "update_node" || value === "connect_nodes" || value === "generate_media" || value === "create_storyboard" || value === "edit_storyboard" || value === "plan_step" ? value : null;
return value === "add_node" || value === "update_node" || value === "connect_nodes" || value === "arrange_nodes" || value === "generate_media" || value === "create_storyboard" || value === "edit_storyboard" || value === "plan_step" ? value : null;
}
function normalizeServerPreview(value: unknown): AgentApprovalPresentation | null {

View File

@@ -27,7 +27,7 @@ export type AgentProfileView = {
layers: AgentProfileLayer[];
};
export type AgentApprovalPreviewOperation = "add_node" | "update_node" | "connect_nodes" | "generate_media" | "create_storyboard" | "edit_storyboard" | "plan_step";
export type AgentApprovalPreviewOperation = "add_node" | "update_node" | "connect_nodes" | "arrange_nodes" | "generate_media" | "create_storyboard" | "edit_storyboard" | "plan_step";
export type AgentApprovalPreviewItem = {
operation: AgentApprovalPreviewOperation;

View File

@@ -64,6 +64,20 @@ describe("Agent approval presentation", () => {
expect(JSON.stringify(view)).not.toContain("private");
});
it("keeps an arrange_nodes preview item instead of dropping it as an unknown operation", () => {
// 未知 operation 会被 operation() 判成 null 并丢掉整条预览项,因此新增的
// arrange_nodes 必须同时进联合类型与判据,否则审批卡只剩"生成"这个兜底标签。
const view = agentApprovalPresentation({ preview: {
kind: "canvas_mutation",
title: "确认整理画布",
description: "请确认要整理的节点。",
items: [{ operation: "arrange_nodes", nodeId: "text-1", nodeTitle: "开场分镜", nodeTypeLabel: "文本", summary: "整理《开场分镜》" }],
} });
expect(view.items).toHaveLength(1);
expect(view.items[0].operation).toBe("arrange_nodes");
expect(view.items[0].nodeTitle).toBe("开场分镜");
});
it("states when an unknown approval cannot identify a target", () => {
const view = agentApprovalPresentation({ toolName: "unknown_tool", arguments: {} });
expect(view.items).toHaveLength(0);