吸收数字员工日报产物闭环
This commit is contained in:
@@ -392,6 +392,31 @@ export interface DigitalEmployeeRuntimeEventRecord {
|
||||
payload?: unknown;
|
||||
}
|
||||
|
||||
export interface DigitalEmployeeDailyReportRecordInput {
|
||||
reportId?: string | null;
|
||||
date: string;
|
||||
title: string;
|
||||
summary: string;
|
||||
totals: Record<string, unknown>;
|
||||
detailLines: string[];
|
||||
artifactSources?: unknown[];
|
||||
filename: string;
|
||||
textContent: string;
|
||||
generatedAt?: string | null;
|
||||
reportScheduleTime?: string | null;
|
||||
source?: string | null;
|
||||
model?: string | null;
|
||||
}
|
||||
|
||||
export interface DigitalEmployeeDailyReportRecordResult {
|
||||
reportId: string;
|
||||
planId: string;
|
||||
taskId: string;
|
||||
runId: string;
|
||||
artifactId: string;
|
||||
eventId: string;
|
||||
}
|
||||
|
||||
export interface DigitalEmployeeGovernanceCommandRecord {
|
||||
commandKind: string;
|
||||
commandId: string;
|
||||
@@ -1451,6 +1476,89 @@ export function recordDigitalEmployeeRuntimeEvent(
|
||||
tx();
|
||||
}
|
||||
|
||||
export function recordDigitalEmployeeDailyReport(
|
||||
input: DigitalEmployeeDailyReportRecordInput,
|
||||
): DigitalEmployeeDailyReportRecordResult | null {
|
||||
const db = getDigitalEmployeeDb();
|
||||
if (!db) return null;
|
||||
|
||||
const now = input.generatedAt || new Date().toISOString();
|
||||
const date = input.date || now.slice(0, 10);
|
||||
const planId = `daily-report:${date}`;
|
||||
const taskId = `${planId}:generate`;
|
||||
const reportId = input.reportId || `${planId}:${safeId(now)}`;
|
||||
const runId = reportId;
|
||||
const artifactId = `${reportId}:artifact:text`;
|
||||
const eventId = `${reportId}:event:generated`;
|
||||
const payload = {
|
||||
report_id: reportId,
|
||||
date,
|
||||
title: input.title,
|
||||
summary: input.summary,
|
||||
totals: input.totals ?? {},
|
||||
detail_lines: input.detailLines ?? [],
|
||||
artifact_sources: input.artifactSources ?? [],
|
||||
filename: input.filename,
|
||||
format: "text",
|
||||
text_content: input.textContent,
|
||||
generated_at: now,
|
||||
report_schedule_time: input.reportScheduleTime ?? null,
|
||||
source: input.source ?? "qimingclaw-adapter",
|
||||
model: input.model ?? "qimingclaw-adapter",
|
||||
};
|
||||
|
||||
const tx = db.transaction(() => {
|
||||
upsertPlan({
|
||||
id: planId,
|
||||
title: `${date} 数字员工日报`,
|
||||
objective: "沉淀数字员工日报产物与同步事实。",
|
||||
status: "completed",
|
||||
payload: { date, latest_report_id: reportId, source: "daily_report" },
|
||||
now,
|
||||
});
|
||||
upsertTask({
|
||||
id: taskId,
|
||||
planId,
|
||||
title: "生成数字员工日报",
|
||||
status: "completed",
|
||||
assignedSkillId: "qimingclaw-artifact-report",
|
||||
payload: { date, latest_report_id: reportId, source: "daily_report" },
|
||||
now,
|
||||
});
|
||||
upsertRun({
|
||||
id: runId,
|
||||
planId,
|
||||
taskId,
|
||||
status: "completed",
|
||||
payload,
|
||||
now,
|
||||
});
|
||||
finishRun(runId, "completed", now);
|
||||
upsertArtifact({
|
||||
id: artifactId,
|
||||
planId,
|
||||
taskId,
|
||||
runId,
|
||||
kind: "daily_report",
|
||||
name: input.filename,
|
||||
uri: null,
|
||||
payload,
|
||||
now,
|
||||
});
|
||||
insertEvent({
|
||||
event_id: eventId,
|
||||
kind: "daily_report_generated",
|
||||
occurred_at: now,
|
||||
message: `数字员工日报已生成:${date}`,
|
||||
plan_id: planId,
|
||||
task_id: taskId,
|
||||
}, runId, payload);
|
||||
});
|
||||
tx();
|
||||
|
||||
return { reportId, planId, taskId, runId, artifactId, eventId };
|
||||
}
|
||||
|
||||
export function recordDigitalEmployeeGovernanceCommand(
|
||||
command: DigitalEmployeeGovernanceCommandRecord,
|
||||
): { planId: string; taskId: string; runId: string } {
|
||||
|
||||
Reference in New Issue
Block a user