feat(*): 创作工作台 - 完善媒体上传预览与连线交互并修复任务章节及日志筛选

This commit is contained in:
ddCat
2026-09-08 17:26:34 +08:00
parent 95b004ec0f
commit 068a8daea6
56 changed files with 3316 additions and 274 deletions

View File

@@ -132,7 +132,7 @@ function flattenCharacterCandidates(value: unknown): unknown[] | undefined {
return undefined;
}
function extractCharacterBreakdownJson(raw: string) {
export function extractCharacterBreakdownJson(raw: string, allowEmptyCharacters = false) {
for (let start = 0; start < raw.length; start += 1) {
if (raw[start] !== "{" && raw[start] !== "[") continue;
const end = findJsonValueEnd(raw, start);
@@ -144,6 +144,9 @@ function extractCharacterBreakdownJson(raw: string) {
// 模型的推理文字可能包含 aliases: [] 等合法 JSON 片段;角色契约只接受带 characters 字段的对象。
const candidates = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? flattenCharacterCandidates((parsed as { characters?: unknown }).characters) : undefined;
if (Array.isArray(candidates) && candidates.length) return parsed;
// 章节资产允许无人场景;仍交由章节解析器校验三个必填数组。
if (allowEmptyCharacters && parsed && typeof parsed === "object" && !Array.isArray(parsed)
&& Array.isArray((parsed as { characters?: unknown }).characters)) return parsed;
} catch {
// Ignore unrelated braces in model prose and continue to the next complete JSON value.
}