feat: upgrade investigation and presentation runtime
This commit is contained in:
@@ -36,10 +36,10 @@ export const answerUiSpecSchema = z.object({ root: key, elements: z.record(z.obj
|
||||
if (!visit(spec.root, 0) || visited.size !== names.length) fail();
|
||||
});
|
||||
|
||||
export const answerUiInputSchema = z.object({ block_id: key, fallback_text: z.string().min(1).max(4000), spec: answerUiSpecSchema }).strict();
|
||||
export const answerUiInputSchema = z.object({ block_id: key, phase: z.enum(["process", "final"]).optional(), fallback_text: z.string().min(1).max(4000), spec: answerUiSpecSchema }).strict();
|
||||
export const answerUiBlockSchema = answerUiInputSchema.extend({ version: z.literal("answer-ui@1") })
|
||||
.refine((block) => JSON.stringify(block).length <= 100000, "界面块过大");
|
||||
export const parseAnswerUiInput = (value: unknown) => {
|
||||
const parsed = answerUiInputSchema.safeParse(value);
|
||||
return parsed.success ? { version: "answer-ui@1" as const, ...parsed.data } : null;
|
||||
return parsed.success ? { version: "answer-ui@1" as const, ...parsed.data, phase: parsed.data.phase ?? "process" } : null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user