Files
Genarrative/packages/shared/src/contracts/puzzleAgentActions.ts
2026-05-13 00:28:07 +08:00

123 lines
3.1 KiB
TypeScript

import type { PuzzleAgentSessionSnapshot } from './puzzleAgentSession';
export type PuzzleAgentSuggestedActionType =
| 'request_summary'
| 'compile_puzzle_draft'
| 'generate_puzzle_images'
| 'generate_puzzle_ui_background'
| 'generate_puzzle_tags'
| 'publish_puzzle_work';
export interface PuzzleAgentSuggestedAction {
id: string;
actionType: PuzzleAgentSuggestedActionType;
label: string;
}
export type PuzzleAgentActionType =
| 'save_puzzle_form_draft'
| 'compile_puzzle_draft'
| 'generate_puzzle_images'
| 'generate_puzzle_ui_background'
| 'generate_puzzle_tags'
| 'select_puzzle_image'
| 'publish_puzzle_work';
export type PuzzleAgentOperationType =
| 'process_message'
| PuzzleAgentActionType;
export type PuzzleAgentOperationStatus =
| 'queued'
| 'running'
| 'completed'
| 'failed';
export interface PuzzleAgentOperationRecord {
operationId: string;
type: PuzzleAgentOperationType;
status: PuzzleAgentOperationStatus;
phaseLabel: string;
phaseDetail: string;
progress: number;
error?: string | null;
}
export type PuzzleAgentActionRequest =
| {
action: 'save_puzzle_form_draft';
promptText?: string | null;
workTitle?: string;
workDescription?: string;
pictureDescription?: string;
referenceImageSrc?: string | null;
imageModel?: string | null;
aiRedraw?: boolean;
}
| {
action: 'compile_puzzle_draft';
promptText?: string | null;
workTitle?: string;
workDescription?: string;
pictureDescription?: string;
referenceImageSrc?: string | null;
imageModel?: string | null;
aiRedraw?: boolean;
candidateCount?: number;
}
| {
action: 'generate_puzzle_images';
levelId?: string | null;
promptText?: string | null;
referenceImageSrc?: string | null;
imageModel?: string | null;
aiRedraw?: boolean;
candidateCount?: number;
workTitle?: string;
workDescription?: string;
summary?: string;
themeTags?: string[];
levelsJson?: string;
}
| {
action: 'generate_puzzle_ui_background';
levelId?: string | null;
promptText: string;
workTitle?: string;
workDescription?: string;
summary?: string;
themeTags?: string[];
levelsJson?: string;
}
| {
action: 'generate_puzzle_tags';
workTitle: string;
workDescription: string;
levelName?: string;
summary?: string;
themeTags?: string[];
levelsJson?: string;
}
| {
action: 'select_puzzle_image';
levelId?: string | null;
candidateId: string;
}
| {
action: 'publish_puzzle_work';
workTitle?: string;
workDescription?: string;
levelName?: string;
summary?: string;
themeTags?: string[];
levelsJson?: string;
};
/**
* 拼图操作接口直接返回最新会话,避免前端在选图等轻操作后再额外 GET 大体积快照。
*/
export interface PuzzleAgentActionResponse {
operation: PuzzleAgentOperationRecord;
session: PuzzleAgentSessionSnapshot;
}