83 lines
2.4 KiB
TypeScript
83 lines
2.4 KiB
TypeScript
import type {
|
|
CustomWorldAgentStage,
|
|
CustomWorldDraftCardSummary,
|
|
CustomWorldSuggestedAction,
|
|
} from '../../../packages/shared/src/contracts/customWorldAgent.js';
|
|
import {
|
|
getWorldFoundationCardId,
|
|
normalizeFoundationDraftProfile,
|
|
} from './customWorldAgentDraftCompiler.js';
|
|
|
|
export class CustomWorldAgentSuggestedActionService {
|
|
// 统一维护 Agent 草稿阶段的建议动作,避免继续散落在 orchestrator 和 store 的兼容逻辑里。
|
|
buildSuggestedActions(
|
|
params: {
|
|
stage?: CustomWorldAgentStage;
|
|
isReady?: boolean;
|
|
draftProfile?: unknown;
|
|
draftCards?: CustomWorldDraftCardSummary[];
|
|
} = {},
|
|
): CustomWorldSuggestedAction[] {
|
|
const profile = normalizeFoundationDraftProfile(params.draftProfile);
|
|
const actions: CustomWorldSuggestedAction[] = [
|
|
{
|
|
id: 'request_summary',
|
|
type: 'request_summary',
|
|
label:
|
|
params.stage === 'object_refining' ||
|
|
params.stage === 'visual_refining'
|
|
? '总结当前世界底稿'
|
|
: '总结当前设定',
|
|
},
|
|
];
|
|
|
|
if (params.stage === 'foundation_review' && params.isReady) {
|
|
actions.push({
|
|
id: 'draft_foundation',
|
|
type: 'draft_foundation',
|
|
label: '整理一版世界底稿',
|
|
});
|
|
return actions;
|
|
}
|
|
|
|
if (
|
|
(params.stage === 'object_refining' ||
|
|
params.stage === 'visual_refining') &&
|
|
profile
|
|
) {
|
|
const worldCardId =
|
|
params.draftCards?.find((entry) => entry.kind === 'world')?.id ??
|
|
getWorldFoundationCardId();
|
|
const firstCharacter = [...profile.playableNpcs, ...profile.storyNpcs][0];
|
|
const firstLandmark = profile.landmarks[0];
|
|
|
|
actions.push({
|
|
id: 'refine_world',
|
|
type: 'refine_focus_target',
|
|
label: '先看世界总卡',
|
|
targetId: worldCardId,
|
|
});
|
|
|
|
if (firstCharacter) {
|
|
actions.push({
|
|
id: `refine-character-${firstCharacter.id}`,
|
|
type: 'refine_focus_target',
|
|
label: `精修角色:${firstCharacter.name}`,
|
|
targetId: firstCharacter.id,
|
|
});
|
|
}
|
|
|
|
if (firstLandmark) {
|
|
actions.push({
|
|
id: `refine-landmark-${firstLandmark.id}`,
|
|
type: 'refine_focus_target',
|
|
label: `继续补地点:${firstLandmark.name}`,
|
|
targetId: firstLandmark.id,
|
|
});
|
|
}
|
|
}
|
|
|
|
return actions;
|
|
}
|
|
}
|