fe87a9ecdb
Mastra intermediate text-delta was published as answer.delta, then set-focus domain errors reset the attempt and replayed evidence. Publish only the terminal no-tool step, persist the next probe on the server, and ground batch quotes in the source turn. Co-authored-by: Cursor <cursoragent@cursor.com>
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import { parseAgentChoiceCopy } from "./choice-card";
|
||
import type { V9CaseDossier } from "./tool-service";
|
||
|
||
export type RectificationNarrationDto = Readonly<{
|
||
acknowledgedFacts: readonly string[];
|
||
nextQuestion: string | null;
|
||
}>;
|
||
|
||
export function publicNarrationDtoFromDossier(dossier: V9CaseDossier): RectificationNarrationDto {
|
||
const acknowledgedFacts = dossier.evidence
|
||
.filter((item) => item.status === "confirmed" || item.status === "draft" || item.status === "pending_confirmation")
|
||
.slice(-4)
|
||
.map((item) => item.summary.trim())
|
||
.filter((item) => item.length >= 2);
|
||
const choice = parseAgentChoiceCopy(dossier.conversationSummary.activeFocus?.expectedAnswerSchema ?? null);
|
||
return {
|
||
acknowledgedFacts,
|
||
nextQuestion: choice?.prompt ?? null,
|
||
};
|
||
}
|
||
|
||
export function composeRectificationTurnNarration(dto: RectificationNarrationDto): string {
|
||
const parts: string[] = [];
|
||
if (dto.acknowledgedFacts.length > 0) {
|
||
parts.push(`已经记下:${dto.acknowledgedFacts.join(";")}。`);
|
||
}
|
||
if (dto.nextQuestion) parts.push(dto.nextQuestion);
|
||
if (parts.length === 0) {
|
||
return "请继续说下一件你记得比较清楚、大概带年份的经历。";
|
||
}
|
||
return parts.join("");
|
||
}
|