"use client"; import { useMemo, useState } from "react"; import { useRouter } from "next/navigation"; import clsx from "clsx"; import type { MasterAgentMemory, MasterAgentPromptPolicy, MasterMemoryScope, MasterMemoryType, ProjectAgentControls, UserMasterPrompt, } from "@/lib/boss-data"; import type { MasterAgentChatPageAnchors } from "@/lib/master-agent-chat-menu"; import { getMasterAgentModelOptions } from "@/lib/master-agent-model-options"; import { formatTimestampLabel } from "@/lib/boss-projections"; type MemoryDraft = { scope: MasterMemoryScope; projectId: string; title: string; content: string; memoryType: MasterMemoryType; tags: string; sourceMessageId: string; }; type ClawAvailability = { status: "disabled" | "misconfigured" | "ready"; selectable: boolean; reason: string; reasonLabel: string; }; const memoryScopeOptions: Array<{ value: MasterMemoryScope; label: string }> = [ { value: "global", label: "通用记忆" }, { value: "project", label: "项目记忆" }, ]; const memoryTypeOptions: Array<{ value: MasterMemoryType; label: string }> = [ { value: "user_preference", label: "用户偏好" }, { value: "project_progress", label: "项目进度" }, { value: "decision", label: "决策" }, { value: "risk", label: "风险" }, { value: "blocking_issue", label: "阻塞" }, { value: "research_note", label: "调研" }, { value: "workflow_rule", label: "工作规则" }, ]; function memoryTypeLabel(value: MasterMemoryType) { return memoryTypeOptions.find((item) => item.value === value)?.label ?? value; } function memoryScopeLabel(value: MasterMemoryScope) { return memoryScopeOptions.find((item) => item.value === value)?.label ?? value; } function tagsToText(tags: string[]) { return tags.join(", "); } function textToTags(value: string) { return value .split(/[,,、\n]/) .map((item) => item.trim()) .filter(Boolean); } function draftFromMemory(memory: MasterAgentMemory): MemoryDraft { return { scope: memory.scope, projectId: memory.projectId ?? "master-agent", title: memory.title, content: memory.content, memoryType: memory.memoryType, tags: tagsToText(memory.tags), sourceMessageId: memory.sourceMessageId ?? "", }; } function makeNewMemoryDraft(): MemoryDraft { return { scope: "global", projectId: "", title: "", content: "", memoryType: "user_preference", tags: "", sourceMessageId: "", }; } function Field({ label, value, onChange, placeholder, type = "text", }: { label: string; value: string; onChange: (value: string) => void; placeholder?: string; type?: "text" | "password"; }) { return ( ); } function TextArea({ label, value, onChange, placeholder, readOnly = false, }: { label: string; value: string; onChange: (value: string) => void; placeholder?: string; readOnly?: boolean; }) { return (