Merge branch 'ji' into master (操作日志 Y-Log 上报)

# Conflicts:
#	CLAUDE.md
This commit is contained in:
Administrator committed 2026-06-23 19:22:53 +08:00
commit 053d3e300e
35 files changed
+1182 -125

No files matched your search

@@ -14,6 +14,7 @@
import { apiFetch } from "@/core/api/fetch-client";
import { getBackendBaseURL } from "@/core/config";
import { OptType, writeYLog } from "@/core/log/y-log";
import type { IntentSummary } from "@/roundtable-planning/api/intent";
import type { ThreadIdMap } from "@/roundtable-planning/api/multi-agent";
@@ -321,7 +322,14 @@ export function fromUpdate(p: DraftUpdatePayload) {
export async function listDrafts(): Promise<DraftMeta[]> {
const res = await apiFetch(BASE(), { method: "GET" });
const data = await readJson<{ drafts: ServerDraftMeta[] }>(res, "list drafts");
return (data.drafts ?? []).map(toMeta);
const metas = (data.drafts ?? []).map(toMeta);
writeYLog({
optType: OptType.search,
optDetail: "B1-CM助手-会商-查询草稿",
url: BASE(),
returnParam: { count: metas.length },
});
return metas;
}
/** Fetch the full draft (incl. step1/step2). Returns null on 404. */
@@ -339,7 +347,15 @@ export async function createDraft(payload: DraftCreatePayload): Promise<DraftRec
body: JSON.stringify(fromCreate(payload)),
});
const data = await readJson<ServerDraftFull>(res, "create draft");
return toRecord(data);
const record = toRecord(data);
writeYLog({
optType: OptType.create,
optDetail: "B1-CM助手-会商-新建草稿",
url: BASE(),
reqParam: { title: payload.title, furthestStep: payload.furthestStep, taskId: payload.taskId ?? null },
returnParam: { id: record.id, title: record.title },
});
return record;
}
export async function updateDraft(id: string, patch: DraftUpdatePayload): Promise<DraftRecord | null> {
@@ -350,7 +366,15 @@ export async function updateDraft(id: string, patch: DraftUpdatePayload): Promis
});
if (res.status === 404) return null;
const data = await readJson<ServerDraftFull>(res, "update draft");
return toRecord(data);
const record = toRecord(data);
writeYLog({
optType: OptType.edit,
optDetail: "B1-CM助手-会商-更新草稿",
url: `${BASE()}/${id}`,
reqParam: { id, ...patch },
returnParam: { id: record.id, title: record.title },
});
return record;
}
export async function deleteDraft(id: string): Promise<void> {
@@ -359,6 +383,12 @@ export async function deleteDraft(id: string): Promise<void> {
const text = await res.text().catch(() => "");
throw new Error(`delete draft failed (${res.status}): ${text}`);
}
writeYLog({
optType: OptType.delete,
optDetail: "B1-CM助手-会商-删除草稿",
url: `${BASE()}/${id}`,
reqParam: { id },
});
}
/**
@@ -13,6 +13,7 @@
import { apiFetch } from "@/core/api/fetch-client";
import { getBackendBaseURL } from "@/core/config";
import { OptType, writeYLog } from "@/core/log/y-log";
import { getAvatarTypeFor } from "../lib/roundtable-constants";
import { reportRoundtableError } from "./diagnostics-report";
@@ -129,7 +130,15 @@ export async function startJob(payload: StartJobPayload): Promise<RoundtableJob>
headers: { "Content-Type": "application/json" },
body: JSON.stringify(toStartBody(payload)),
});
return mapJob(await readJson<Record<string, unknown>>(res, "start job"));
const job = mapJob(await readJson<Record<string, unknown>>(res, "start job"));
writeYLog({
optType: OptType.other,
optDetail: "B1-CM助手-会商-运行",
url: BASE(),
reqParam: { draftId: payload.draftId ?? null, taskId: payload.taskId ?? null, model: payload.model },
returnParam: { id: job.id, status: job.status },
});
return job;
}
/**
@@ -186,7 +195,15 @@ export async function resumeJob(jobId: string, answer: string, taskId?: string |
/** 取消作业。`taskId` 非空 → task 共享取消(不分权)。 */
export async function cancelJob(jobId: string, taskId?: string | null): Promise<RoundtableJob> {
const res = await apiFetch(`${BASE()}/${encodeURIComponent(jobId)}/cancel${taskQuery(taskId, "?")}`, { method: "POST" });
return mapJob(await readJson<Record<string, unknown>>(res, "cancel job"));
const job = mapJob(await readJson<Record<string, unknown>>(res, "cancel job"));
writeYLog({
optType: OptType.edit,
optDetail: "B1-CM助手-会商-取消",
url: `${BASE()}/${jobId}/cancel`,
reqParam: { jobId, taskId: taskId ?? null },
returnParam: { id: job.id, status: job.status },
});
return job;
}
// ── SSE 进度订阅 ─────────────────────────────────────────────────────────────
@@ -12,6 +12,7 @@
import { apiFetch } from "@/core/api/fetch-client";
import { getBackendBaseURL } from "@/core/config";
import { OptType, writeYLog } from "@/core/log/y-log";
import {
fromCreate,
@@ -33,7 +34,15 @@ const BASE = () => `${getBackendBaseURL()}/api/roundtable-task-drafts`;
export async function listTaskDraftsByTask(taskId: string): Promise<DraftMeta[]> {
const res = await apiFetch(`${BASE()}/by-task/${encodeURIComponent(taskId)}`, { method: "GET" });
const data = await readJson<{ drafts: ServerDraftMeta[] }>(res, "list task drafts");
return (data.drafts ?? []).map(toMeta);
const metas = (data.drafts ?? []).map(toMeta);
writeYLog({
optType: OptType.search,
optDetail: "B1-CM助手-会商任务-查询草稿",
url: `${BASE()}/by-task/${taskId}`,
reqParam: { taskId },
returnParam: { count: metas.length },
});
return metas;
}
/** 按外部任务 id 取最新一条聊天记录(不分权)。无则 null(404)。 */
@@ -60,7 +69,15 @@ export async function createTaskDraft(payload: DraftCreatePayload): Promise<Draf
body: JSON.stringify(fromCreate(payload)),
});
const data = await readJson<ServerDraftFull>(res, "create task draft");
return toRecord(data);
const record = toRecord(data);
writeYLog({
optType: OptType.create,
optDetail: "B1-CM助手-会商任务-新建草稿",
url: BASE(),
reqParam: { taskId: payload.taskId ?? null, title: payload.title, furthestStep: payload.furthestStep },
returnParam: { id: record.id, title: record.title },
});
return record;
}
export async function updateTaskDraft(id: string, patch: DraftUpdatePayload): Promise<DraftRecord | null> {
@@ -71,7 +88,15 @@ export async function updateTaskDraft(id: string, patch: DraftUpdatePayload): Pr
});
if (res.status === 404) return null;
const data = await readJson<ServerDraftFull>(res, "update task draft");
return toRecord(data);
const record = toRecord(data);
writeYLog({
optType: OptType.edit,
optDetail: "B1-CM助手-会商任务-更新草稿",
url: `${BASE()}/${id}`,
reqParam: { id, ...patch },
returnParam: { id: record.id, title: record.title },
});
return record;
}
export async function deleteTaskDraft(id: string): Promise<void> {
@@ -80,4 +105,10 @@ export async function deleteTaskDraft(id: string): Promise<void> {
const text = await res.text().catch(() => "");
throw new Error(`delete task draft failed (${res.status}): ${text}`);
}
writeYLog({
optType: OptType.delete,
optDetail: "B1-CM助手-会商任务-删除草稿",
url: `${BASE()}/${id}`,
reqParam: { id },
});
}