1
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type {
|
||||
CustomWorldAgentOperationRecord,
|
||||
CustomWorldAgentSessionSnapshot,
|
||||
EightAnchorContent,
|
||||
} from '../../packages/shared/src/contracts/customWorldAgent';
|
||||
import type {
|
||||
CustomWorldGenerationProgress,
|
||||
@@ -11,6 +12,187 @@ import {
|
||||
normalizeCustomWorldCreatorIntent,
|
||||
} from './customWorldCreatorIntent';
|
||||
|
||||
export type CustomWorldStructuredAnchorEntry = {
|
||||
id: string;
|
||||
label: string;
|
||||
value: string;
|
||||
};
|
||||
|
||||
function joinText(items: Array<string | null | undefined>) {
|
||||
return items.filter(Boolean).join(';');
|
||||
}
|
||||
|
||||
function buildEightAnchorFoundationText(anchorContent: EightAnchorContent) {
|
||||
return [
|
||||
anchorContent.worldPromise
|
||||
? `世界承诺:${joinText([
|
||||
anchorContent.worldPromise.hook,
|
||||
anchorContent.worldPromise.differentiator,
|
||||
anchorContent.worldPromise.desiredExperience,
|
||||
])}`
|
||||
: '',
|
||||
anchorContent.playerFantasy
|
||||
? `玩家幻想:${joinText([
|
||||
anchorContent.playerFantasy.playerRole,
|
||||
anchorContent.playerFantasy.corePursuit,
|
||||
anchorContent.playerFantasy.fearOfLoss,
|
||||
])}`
|
||||
: '',
|
||||
anchorContent.themeBoundary
|
||||
? `主题边界:${joinText([
|
||||
anchorContent.themeBoundary.toneKeywords.join('、'),
|
||||
anchorContent.themeBoundary.aestheticDirectives.join('、'),
|
||||
anchorContent.themeBoundary.forbiddenDirectives.join('、'),
|
||||
])}`
|
||||
: '',
|
||||
anchorContent.playerEntryPoint
|
||||
? `玩家切入口:${joinText([
|
||||
anchorContent.playerEntryPoint.openingIdentity,
|
||||
anchorContent.playerEntryPoint.openingProblem,
|
||||
anchorContent.playerEntryPoint.entryMotivation,
|
||||
])}`
|
||||
: '',
|
||||
anchorContent.coreConflict
|
||||
? `核心冲突:${joinText([
|
||||
anchorContent.coreConflict.surfaceConflicts.join('、'),
|
||||
anchorContent.coreConflict.hiddenCrisis,
|
||||
anchorContent.coreConflict.firstTouchedConflict,
|
||||
])}`
|
||||
: '',
|
||||
anchorContent.keyRelationships.length > 0
|
||||
? `关键关系:${anchorContent.keyRelationships
|
||||
.map((entry) =>
|
||||
joinText([entry.pairs, entry.relationshipType, entry.secretOrCost]),
|
||||
)
|
||||
.join(';')}`
|
||||
: '',
|
||||
anchorContent.hiddenLines
|
||||
? `暗线与揭示:${joinText([
|
||||
anchorContent.hiddenLines.hiddenTruths.join('、'),
|
||||
anchorContent.hiddenLines.misdirectionHints.join('、'),
|
||||
anchorContent.hiddenLines.revealPacing,
|
||||
])}`
|
||||
: '',
|
||||
anchorContent.iconicElements
|
||||
? `标志元素:${joinText([
|
||||
anchorContent.iconicElements.iconicMotifs.join('、'),
|
||||
anchorContent.iconicElements.institutionsOrArtifacts.join('、'),
|
||||
anchorContent.iconicElements.hardRules.join('、'),
|
||||
])}`
|
||||
: '',
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
export function buildAgentDraftFoundationAnchorEntries(
|
||||
session: CustomWorldAgentSessionSnapshot | null | undefined,
|
||||
): CustomWorldStructuredAnchorEntry[] {
|
||||
if (!session) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const anchorContent = session.anchorContent;
|
||||
|
||||
return [
|
||||
{
|
||||
id: 'world-promise',
|
||||
label: '世界承诺',
|
||||
value: anchorContent.worldPromise
|
||||
? joinText([
|
||||
anchorContent.worldPromise.hook,
|
||||
anchorContent.worldPromise.differentiator,
|
||||
anchorContent.worldPromise.desiredExperience,
|
||||
])
|
||||
: '',
|
||||
},
|
||||
{
|
||||
id: 'player-fantasy',
|
||||
label: '玩家幻想',
|
||||
value: anchorContent.playerFantasy
|
||||
? joinText([
|
||||
anchorContent.playerFantasy.playerRole,
|
||||
anchorContent.playerFantasy.corePursuit,
|
||||
anchorContent.playerFantasy.fearOfLoss,
|
||||
])
|
||||
: '',
|
||||
},
|
||||
{
|
||||
id: 'theme-boundary',
|
||||
label: '主题边界',
|
||||
value: anchorContent.themeBoundary
|
||||
? joinText([
|
||||
anchorContent.themeBoundary.toneKeywords.join('、'),
|
||||
anchorContent.themeBoundary.aestheticDirectives.join('、'),
|
||||
anchorContent.themeBoundary.forbiddenDirectives.length > 0
|
||||
? `避免:${anchorContent.themeBoundary.forbiddenDirectives.join('、')}`
|
||||
: '',
|
||||
])
|
||||
: '',
|
||||
},
|
||||
{
|
||||
id: 'player-entry-point',
|
||||
label: '玩家切入口',
|
||||
value: anchorContent.playerEntryPoint
|
||||
? joinText([
|
||||
anchorContent.playerEntryPoint.openingIdentity,
|
||||
anchorContent.playerEntryPoint.openingProblem,
|
||||
anchorContent.playerEntryPoint.entryMotivation,
|
||||
])
|
||||
: '',
|
||||
},
|
||||
{
|
||||
id: 'core-conflict',
|
||||
label: '核心冲突',
|
||||
value: anchorContent.coreConflict
|
||||
? joinText([
|
||||
anchorContent.coreConflict.surfaceConflicts.join('、'),
|
||||
anchorContent.coreConflict.hiddenCrisis,
|
||||
anchorContent.coreConflict.firstTouchedConflict,
|
||||
])
|
||||
: '',
|
||||
},
|
||||
{
|
||||
id: 'key-relationships',
|
||||
label: '关键关系',
|
||||
value:
|
||||
anchorContent.keyRelationships.length > 0
|
||||
? anchorContent.keyRelationships
|
||||
.map((entry) =>
|
||||
joinText([
|
||||
entry.pairs,
|
||||
entry.relationshipType,
|
||||
entry.secretOrCost ? `代价/秘密:${entry.secretOrCost}` : '',
|
||||
]),
|
||||
)
|
||||
.join('\n')
|
||||
: '',
|
||||
},
|
||||
{
|
||||
id: 'hidden-lines',
|
||||
label: '暗线与揭示',
|
||||
value: anchorContent.hiddenLines
|
||||
? joinText([
|
||||
anchorContent.hiddenLines.hiddenTruths.join('、'),
|
||||
anchorContent.hiddenLines.misdirectionHints.join('、'),
|
||||
anchorContent.hiddenLines.revealPacing,
|
||||
])
|
||||
: '',
|
||||
},
|
||||
{
|
||||
id: 'iconic-elements',
|
||||
label: '标志元素',
|
||||
value: anchorContent.iconicElements
|
||||
? joinText([
|
||||
anchorContent.iconicElements.iconicMotifs.join('、'),
|
||||
anchorContent.iconicElements.institutionsOrArtifacts.join('、'),
|
||||
anchorContent.iconicElements.hardRules.join('、'),
|
||||
])
|
||||
: '',
|
||||
},
|
||||
].filter((entry) => entry.value.trim());
|
||||
}
|
||||
|
||||
const AGENT_DRAFT_FOUNDATION_STEP_DEFINITIONS = [
|
||||
{
|
||||
id: 'queue',
|
||||
@@ -192,5 +374,11 @@ export function buildAgentDraftFoundationSettingText(
|
||||
.reverse()
|
||||
.find((message) => message.role === 'user' && message.text.trim());
|
||||
|
||||
return latestUserMessage?.text.trim() ?? '正在整理当前共创设定。';
|
||||
const anchorSettingText = buildEightAnchorFoundationText(session.anchorContent);
|
||||
|
||||
return (
|
||||
anchorSettingText ||
|
||||
latestUserMessage?.text.trim() ||
|
||||
'正在整理当前共创设定。'
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user