This commit is contained in:
2026-04-14 20:43:46 +08:00
39 changed files with 2971 additions and 940 deletions

View File

@@ -929,14 +929,7 @@ export class CustomWorldAgentDraftCompiler {
]
.filter(Boolean)
.join(' / '),
summary:
assetHeadline.status === 'complete'
? clampText(`${character.summary}(核心动作已就绪)`, 180)
: assetHeadline.status === 'visual_ready'
? clampText(`${character.summary}(主图已就绪)`, 180)
: assetHeadline.status === 'animations_ready'
? clampText(`${character.summary}(动作补齐中)`, 180)
: clampText(`${character.summary}(待生成主图)`, 180),
summary: clampText(character.summary, 180),
linkedIds: [...character.threadIds, ...linkedLandmarks].slice(0, 6),
sections: [
buildSection('name', '角色名', character.name),

View File

@@ -2,7 +2,10 @@ import type {
CustomWorldAgentStage,
CustomWorldWorkSummary,
} from '../../../packages/shared/src/contracts/customWorldAgent.js';
import type { CustomWorldProfileRecord } from '../../../packages/shared/src/contracts/runtime.js';
import type {
CustomWorldLibraryEntry,
CustomWorldProfileRecord,
} from '../../../packages/shared/src/contracts/runtime.js';
import type { RuntimeRepositoryPort } from '../repositories/runtimeRepository.js';
import { normalizeFoundationDraftProfile } from './customWorldAgentDraftCompiler.js';
import {
@@ -139,6 +142,18 @@ function resolvePublishedCover(profile: Record<string, unknown>) {
return toText(camp?.imageSrc) || toText(leadNpc?.imageSrc) || null;
}
function isLibraryEntry(
value: unknown,
): value is CustomWorldLibraryEntry<CustomWorldProfileRecord> {
const record = toRecord(value);
return (
Boolean(record) &&
typeof record.ownerUserId === 'string' &&
typeof record.profileId === 'string' &&
Boolean(toRecord(record.profile))
);
}
export async function listCustomWorldWorkSummaries(
userId: string,
dependencies: {
@@ -182,12 +197,16 @@ export async function listCustomWorldWorkSummaries(
});
const publishedItems: CustomWorldWorkSummary[] = profiles.map((profile) => {
const profileRecord = profile as CustomWorldProfileRecord &
Record<string, unknown>;
const libraryEntry = isLibraryEntry(profile) ? profile : null;
const profileRecord = (
libraryEntry?.profile ?? profile
) as CustomWorldProfileRecord & Record<string, unknown>;
const playableNpcs = toRecordArray(profileRecord.playableNpcs);
const landmarks = toRecordArray(profileRecord.landmarks);
const updatedAt =
toText(profileRecord.updatedAt) || new Date().toISOString();
(libraryEntry ? toText(libraryEntry.updatedAt) : '') ||
toText(profileRecord.updatedAt) ||
new Date().toISOString();
const roleVisualReadyCount = playableNpcs.filter(
(entry) =>
Boolean(toText(entry.imageSrc)) &&
@@ -201,17 +220,36 @@ export async function listCustomWorldWorkSummaries(
workId: `published:${toText(profileRecord.id) || updatedAt}`,
sourceType: 'published_profile',
status: 'published',
title: toText(profileRecord.name) || '未命名世界',
subtitle: toText(profileRecord.subtitle) || '已发布作品',
title:
(libraryEntry ? toText(libraryEntry.worldName) : '') ||
toText(profileRecord.name) ||
'未命名世界',
subtitle:
(libraryEntry ? toText(libraryEntry.subtitle) : '') ||
toText(profileRecord.subtitle) ||
'已保存作品',
summary:
toText(profileRecord.summary) || '这个世界已经可以直接进入体验。',
coverImageSrc: resolvePublishedCover(profileRecord),
(libraryEntry ? toText(libraryEntry.summaryText) : '') ||
toText(profileRecord.summary) ||
'这个世界已经可以直接进入体验。',
coverImageSrc:
(libraryEntry ? libraryEntry.coverImageSrc : null) ||
resolvePublishedCover(profileRecord),
updatedAt,
publishedAt: toText(profileRecord.publishedAt) || updatedAt,
publishedAt:
(libraryEntry ? toText(libraryEntry.publishedAt) : '') ||
toText(profileRecord.publishedAt) ||
updatedAt,
stage: 'published',
stageLabel: '已发布',
playableNpcCount: playableNpcs.length,
landmarkCount: landmarks.length,
playableNpcCount:
(libraryEntry?.playableNpcCount ?? 0) > 0
? libraryEntry!.playableNpcCount
: playableNpcs.length,
landmarkCount:
(libraryEntry?.landmarkCount ?? 0) > 0
? libraryEntry!.landmarkCount
: landmarks.length,
roleVisualReadyCount,
roleAnimationReadyCount,
roleAssetSummaryLabel:
@@ -221,7 +259,10 @@ export async function listCustomWorldWorkSummaries(
? `主图已就绪 ${roleVisualReadyCount}`
: null,
sessionId: null,
profileId: toText(profileRecord.id) || null,
profileId:
(libraryEntry ? toText(libraryEntry.profileId) : '') ||
toText(profileRecord.id) ||
null,
canResume: false,
canEnterWorld: true,
};