Files
Genarrative/packages/shared/src/contracts/puzzleAgentActions.ts
kdletters 951caac32d 扩展外部生成Worker队列
新增外部生成队列概览和单任务状态契约

将跳一跳、拼消消、敲木鱼图片生成动作接入worker队列

前端生成等待页展示当前任务和队列数量

更新外部生成worker运维文档和团队决策记录
2026-06-12 23:15:55 +08:00

135 lines
3.6 KiB
TypeScript

import type { PuzzleAgentSessionSnapshot } from './puzzleAgentSession';
import type { ExternalGenerationJobStatusRecord } from './externalGeneration';
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;
queueState?: ExternalGenerationJobStatusRecord | null;
}
export type PuzzleAgentActionRequest =
| {
action: 'save_puzzle_form_draft';
promptText?: string | null;
workTitle?: string;
workDescription?: string;
pictureDescription?: string;
referenceImageSrc?: string | null;
referenceImageSrcs?: string[];
referenceImageAssetObjectId?: string | null;
referenceImageAssetObjectIds?: string[];
imageModel?: string | null;
aiRedraw?: boolean;
}
| {
action: 'compile_puzzle_draft';
promptText?: string | null;
workTitle?: string;
workDescription?: string;
pictureDescription?: string;
referenceImageSrc?: string | null;
referenceImageSrcs?: string[];
referenceImageAssetObjectId?: string | null;
referenceImageAssetObjectIds?: string[];
imageModel?: string | null;
aiRedraw?: boolean;
candidateCount?: number;
}
| {
action: 'generate_puzzle_images';
levelId?: string | null;
promptText?: string | null;
referenceImageSrc?: string | null;
referenceImageSrcs?: string[];
referenceImageAssetObjectId?: string | null;
referenceImageAssetObjectIds?: string[];
imageModel?: string | null;
aiRedraw?: boolean;
candidateCount?: number;
shouldAutoNameLevel?: boolean;
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;
}