1
This commit is contained in:
@@ -2,6 +2,19 @@ import type { CustomWorldAgentSessionSnapshot } from '../../../packages/shared/s
|
||||
import { normalizeCustomWorldProfileRecord } from '../../data/customWorldLibrary';
|
||||
import type { CustomWorldProfile } from '../../types';
|
||||
|
||||
function buildCustomWorldProfileFromDraftLegacyResult(
|
||||
draftProfile: CustomWorldAgentSessionSnapshot['draftProfile'],
|
||||
): CustomWorldProfile | null {
|
||||
if (!draftProfile || typeof draftProfile !== 'object') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return normalizeCustomWorldProfileRecord(
|
||||
(draftProfile as { legacyResultProfile?: unknown }).legacyResultProfile ??
|
||||
null,
|
||||
);
|
||||
}
|
||||
|
||||
export function buildCustomWorldProfileFromResultPreview(
|
||||
resultPreview:
|
||||
| CustomWorldAgentSessionSnapshot['resultPreview']
|
||||
@@ -15,14 +28,14 @@ export function buildCustomWorldProfileFromAgentSession(
|
||||
session: CustomWorldAgentSessionSnapshot | null | undefined,
|
||||
): CustomWorldProfile | null {
|
||||
return (
|
||||
normalizeCustomWorldProfileRecord(session?.draftProfile ?? null) ??
|
||||
buildCustomWorldProfileFromResultPreview(session?.resultPreview)
|
||||
buildCustomWorldProfileFromResultPreview(session?.resultPreview) ??
|
||||
buildCustomWorldProfileFromDraftLegacyResult(session?.draftProfile ?? null)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 这是工作包 A 提供的新命名兼容层。
|
||||
* 主入口保持命名稳定,优先消费 Agent 草稿真相源,缺失时才回退到 resultPreview。
|
||||
* 主入口保持命名稳定,只消费结果页运行态快照,避免作品测试读到旧草稿骨架。
|
||||
*/
|
||||
export const rpgCreationPreviewAdapter = {
|
||||
buildPreviewFromSession: buildCustomWorldProfileFromAgentSession,
|
||||
@@ -30,6 +43,6 @@ export const rpgCreationPreviewAdapter = {
|
||||
};
|
||||
|
||||
export {
|
||||
buildCustomWorldProfileFromAgentSession as buildRpgCreationPreviewFromSession,
|
||||
buildCustomWorldProfileFromResultPreview as buildRpgCreationPreviewFromResultPreview,
|
||||
buildCustomWorldProfileFromAgentSession as buildRpgCreationPreviewFromSession,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user