feat: finish master-agent prompt and memory runtime
This commit is contained in:
@@ -72,7 +72,7 @@ function draftFromMemory(memory: MasterAgentMemory): MemoryDraft {
|
||||
function makeNewMemoryDraft(): MemoryDraft {
|
||||
return {
|
||||
scope: "global",
|
||||
projectId: "master-agent",
|
||||
projectId: "",
|
||||
title: "",
|
||||
content: "",
|
||||
memoryType: "user_preference",
|
||||
@@ -174,6 +174,14 @@ export function MasterAgentPromptMemoryClient({
|
||||
});
|
||||
|
||||
const allMemories = useMemo(() => [...projectMemories, ...globalMemories], [projectMemories, globalMemories]);
|
||||
const promptPreview = useMemo(() => {
|
||||
const sections = [
|
||||
globalPrompt.trim() ? `【管理员全局主提示词】\n${globalPrompt.trim()}` : null,
|
||||
userPromptContent.trim() ? `【用户私有主提示词】\n${userPromptContent.trim()}` : null,
|
||||
promptOverride.trim() ? `【当前对话附加提示词】\n${promptOverride.trim()}` : null,
|
||||
].filter(Boolean);
|
||||
return sections.length > 0 ? sections.join("\n\n") : "当前还没有组合后的提示词内容。";
|
||||
}, [globalPrompt, userPromptContent, promptOverride]);
|
||||
|
||||
function updateMemoryDraft(memoryId: string, updater: (draft: MemoryDraft) => MemoryDraft) {
|
||||
setMemoryDrafts((current) => ({
|
||||
@@ -227,10 +235,6 @@ export function MasterAgentPromptMemoryClient({
|
||||
}
|
||||
|
||||
async function saveConversationPrompt() {
|
||||
if (!isAdmin) {
|
||||
setMessage("只有管理员可以修改当前对话附加提示词。");
|
||||
return;
|
||||
}
|
||||
setBusyKey("conversation_prompt");
|
||||
const response = await fetch("/api/v1/projects/master-agent/agent-controls", {
|
||||
method: "POST",
|
||||
@@ -401,7 +405,6 @@ export function MasterAgentPromptMemoryClient({
|
||||
<select
|
||||
value={modelOverride}
|
||||
onChange={(event) => setModelOverride(event.target.value)}
|
||||
disabled={!isAdmin}
|
||||
className="w-full rounded-xl border border-[#E5E5EA] bg-[#F7F8FA] px-3 py-2 text-[13px] text-[#111111] outline-none"
|
||||
>
|
||||
<option value="">默认</option>
|
||||
@@ -415,7 +418,6 @@ export function MasterAgentPromptMemoryClient({
|
||||
<select
|
||||
value={reasoningEffortOverride}
|
||||
onChange={(event) => setReasoningEffortOverride(event.target.value)}
|
||||
disabled={!isAdmin}
|
||||
className="w-full rounded-xl border border-[#E5E5EA] bg-[#F7F8FA] px-3 py-2 text-[13px] text-[#111111] outline-none"
|
||||
>
|
||||
<option value="">默认</option>
|
||||
@@ -430,22 +432,31 @@ export function MasterAgentPromptMemoryClient({
|
||||
value={promptOverride}
|
||||
onChange={setPromptOverride}
|
||||
placeholder="例如:这轮先输出结论,再输出执行计划"
|
||||
readOnly={!isAdmin}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void saveConversationPrompt()}
|
||||
disabled={!isAdmin || busyKey === "conversation_prompt"}
|
||||
disabled={busyKey === "conversation_prompt"}
|
||||
className="rounded-full bg-[#07C160] px-4 py-2 text-[13px] font-semibold text-white disabled:opacity-60"
|
||||
>
|
||||
{busyKey === "conversation_prompt" ? "保存中" : isAdmin ? "保存当前对话设置" : "仅管理员可修改"}
|
||||
{busyKey === "conversation_prompt" ? "保存中" : "保存当前对话设置"}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="space-y-3 rounded-2xl border border-[#E5E5EA] bg-white px-4 py-4">
|
||||
<div className="text-[16px] font-semibold text-[#111111]">组合预览</div>
|
||||
<div className="text-[12px] leading-6 text-[#8C8C8C]">
|
||||
主 Agent 实际读取时会先遵守管理员全局主提示词,再追加你的私有提示词和当前对话附加提示词。
|
||||
</div>
|
||||
<div className="whitespace-pre-wrap rounded-2xl bg-[#F7F8FA] px-4 py-4 text-[13px] leading-6 text-[#57606A]">
|
||||
{promptPreview}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="rounded-2xl border border-[#E5E5EA] bg-white px-4 py-4">
|
||||
<div className="text-[16px] font-semibold text-[#111111]">新增记忆</div>
|
||||
<div className="mt-2 text-[12px] leading-6 text-[#8C8C8C]">
|
||||
支持自动沉淀后的手动增补、编辑和归档。项目记忆默认绑定到当前项目。
|
||||
支持自动沉淀后的手动增补、编辑和归档。项目记忆需要绑定到真实项目,而不是 master-agent 会话本身。
|
||||
</div>
|
||||
<div className="mt-4 space-y-3">
|
||||
<div className="grid gap-3 md:grid-cols-2">
|
||||
@@ -493,7 +504,7 @@ export function MasterAgentPromptMemoryClient({
|
||||
label="projectId"
|
||||
value={newMemory.projectId}
|
||||
onChange={(value) => setNewMemory((current) => ({ ...current, projectId: value }))}
|
||||
placeholder="例如 master-agent"
|
||||
placeholder="例如 boss-console"
|
||||
/>
|
||||
) : null}
|
||||
<Field
|
||||
@@ -533,7 +544,7 @@ export function MasterAgentPromptMemoryClient({
|
||||
|
||||
<div className="space-y-3 rounded-2xl border border-[#E5E5EA] bg-white px-4 py-4">
|
||||
<div className="text-[16px] font-semibold text-[#111111]">项目记忆</div>
|
||||
<div className="text-[12px] text-[#8C8C8C]">当前 master-agent 项目相关记忆。</div>
|
||||
<div className="text-[12px] text-[#8C8C8C]">当前用户在不同项目里沉淀下来的进度、决策、阻塞与调研记忆。</div>
|
||||
{projectMemories.length === 0 ? (
|
||||
<div className="rounded-2xl bg-[#F7F8FA] px-4 py-3 text-[12px] text-[#57606A]">暂无项目记忆。</div>
|
||||
) : null}
|
||||
|
||||
Reference in New Issue
Block a user