feat(y-log): 操作日志上报(前端直连 + 后端公开只读下发地址)
- 后端新增 y_log 公开只读配置:YLogConfig + AppConfig.y_log + GET /api/public/config/y-log,地址写在 config.yaml(mtime 热重载) - 前端核心 src/core/log/:writeYLog(双门控/异步即发即忘/永不抛错/ 去ip-host/对象序列化裁剪/optResult恒0)+ 配置加载 + token1 隔离存取 - 登录(token)持久化 token1 并报登录、登出先报后清;启动预热配置 - 各 API client 成功路径埋点:敏感词/菜单/按钮/技能地址/轻应用、 会商草稿+任务草稿+后台任务、智能体/定时任务/知识库、Word导出, 以及问答完成钩子(ChatPage/AgentChatPage onFinish) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
dd942cdd60
commit
d2be3b206d
26 files changed
+808
-40
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";
|
||||
@@ -314,7 +315,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. */
|
||||
@@ -332,7 +340,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> {
|
||||
@@ -343,7 +359,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> {
|
||||
@@ -352,6 +376,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 { seatModeToRunParams } from "../lib/seat-mode";
|
||||
@@ -111,7 +112,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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,7 +177,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 },
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user