This commit is contained in:
2026-05-08 11:44:42 +08:00
parent b08127031c
commit abf1f1ebea
249 changed files with 39411 additions and 887 deletions

View File

@@ -9,6 +9,7 @@ export interface CreationAgentDocumentInputPayload {
contentType?: string | null;
sizeBytes: number;
text: string;
sourceAssetId?: string | null;
}
export interface ParseCreationAgentDocumentInputResponse {

View File

@@ -0,0 +1,244 @@
import type { PuzzleResultDraft } from './puzzleAgentDraft';
import type { PuzzleAgentSessionSnapshot } from './puzzleAgentSession';
import type {
PuzzleCreativeTemplateProtocol,
PuzzleCreativeTemplateSelection,
PuzzleDraftFieldPatch,
PuzzleImageGenerationPlan,
PuzzleTemplateCostRange,
} from './puzzleCreativeTemplate';
export type CreativeAgentStage =
| 'idle'
| 'perceiving'
| 'thinking'
| 'remembering'
| 'selecting_puzzle_template'
| 'waiting_template_confirmation'
| 'planning_puzzle_levels'
| 'acting'
| 'reflecting'
| 'collaborating'
| 'target_ready'
| 'waiting_user'
| 'failed';
export type CreativeAgentEntryContext =
| 'creation_home'
| 'puzzle_workspace'
| 'gallery_remix'
| 'draft_restore';
export type CreativeAgentMessageRole = 'user' | 'assistant' | 'system';
export type CreativeAgentMessageKind =
| 'chat'
| 'stage'
| 'action_result'
| 'warning';
export type CreativeAgentInputPart =
| {
type: 'input_text';
text: string;
}
| {
type: 'input_image';
imageUrl: string;
assetId?: string | null;
thumbnailUrl?: string | null;
};
export interface CreativeImageInput {
assetId: string;
readUrl: string;
thumbnailUrl?: string | null;
width?: number | null;
height?: number | null;
}
export interface CreativeImageSummary {
assetId: string | null;
readUrl: string | null;
thumbnailUrl: string | null;
width: number | null;
height: number | null;
summary: string | null;
}
export type CreativeUnsupportedPlayType =
| 'rpg'
| 'match3d'
| 'big_fish'
| 'square_hole';
export interface CreativeUnsupportedCapability {
playType: CreativeUnsupportedPlayType;
title: string;
status: 'unsupported';
reason: string;
}
export interface CreativeInputSummary {
text: string | null;
entryContext: CreativeAgentEntryContext;
images: CreativeImageSummary[];
materialSummary: string | null;
unsupportedCapabilities: CreativeUnsupportedCapability[];
}
export interface CreativeAgentMessage {
id: string;
role: CreativeAgentMessageRole;
kind: CreativeAgentMessageKind;
text: string;
createdAt: string;
}
export interface CreativeTargetSessionBinding {
playType: 'puzzle';
targetSessionId: string;
targetStage: 'puzzle-agent-workspace' | 'puzzle-result' | 'puzzle-runtime';
resultProfileId: string | null;
}
export interface CreativeAgentSessionSnapshot {
sessionId: string;
stage: CreativeAgentStage;
inputSummary: CreativeInputSummary;
messages: CreativeAgentMessage[];
puzzleTemplateCatalog: PuzzleCreativeTemplateProtocol[];
puzzleTemplateSelection: PuzzleCreativeTemplateSelection | null;
puzzleImageGenerationPlan: PuzzleImageGenerationPlan | null;
targetBinding: CreativeTargetSessionBinding | null;
updatedAt: string;
}
export interface CreateCreativeAgentSessionRequest {
text?: string | null;
images?: CreativeImageInput[];
entryContext?: CreativeAgentEntryContext;
}
export interface CreativeAgentSessionResponse {
session: CreativeAgentSessionSnapshot;
}
export interface StreamCreativeAgentMessageRequest {
clientMessageId: string;
content: CreativeAgentInputPart[];
}
export interface ConfirmCreativePuzzleTemplateRequest {
selection: PuzzleCreativeTemplateSelection;
}
export interface CreativeDraftEditStreamRequest {
clientMessageId: string;
instruction: string;
targetPuzzleSessionId: string;
currentDraft: PuzzleResultDraft;
}
export interface CreativeDraftEditResult {
editInstructions: PuzzleDraftFieldPatch[];
session: CreativeAgentSessionSnapshot;
puzzleSession: PuzzleAgentSessionSnapshot;
}
export interface CreativeAgentStageEvent {
sessionId: string;
stage: CreativeAgentStage;
}
export interface CreativeAgentMessageDeltaEvent {
sessionId: string;
messageId: string;
role: CreativeAgentMessageRole;
kind: CreativeAgentMessageKind;
textDelta: string;
}
export interface CreativeAgentThoughtSummaryDeltaEvent {
sessionId: string;
thoughtId: string;
textDelta: string;
}
export interface CreativeAgentTemplateCatalogEvent {
sessionId: string;
templates: PuzzleCreativeTemplateProtocol[];
}
export interface CreativeAgentTemplateSelectionEvent {
sessionId: string;
selection: PuzzleCreativeTemplateSelection;
}
export interface CreativeAgentCostRangeEvent {
sessionId: string;
costRange: PuzzleTemplateCostRange;
}
export interface CreativeAgentLevelPlanEvent {
sessionId: string;
plan: PuzzleImageGenerationPlan;
}
export interface CreativeAgentToolEvent {
sessionId: string;
toolCallId: string;
toolName: string;
summary: string | null;
}
export interface CreativeAgentReflectionEvent {
sessionId: string;
pass: boolean;
summary: string;
warnings: string[];
}
export interface CreativeAgentTargetSessionEvent {
sessionId: string;
binding: CreativeTargetSessionBinding;
}
export interface CreativeAgentErrorEvent {
sessionId: string | null;
code: string;
message: string;
recoverable: boolean;
}
export interface CreativeAgentDoneEvent {
sessionId: string;
}
export type CreativeAgentSseEvent =
| { event: 'stage'; data: CreativeAgentStageEvent }
| { event: 'agent_message_delta'; data: CreativeAgentMessageDeltaEvent }
| {
event: 'thought_summary_delta';
data: CreativeAgentThoughtSummaryDeltaEvent;
}
| {
event: 'puzzle_template_catalog';
data: CreativeAgentTemplateCatalogEvent;
}
| {
event: 'puzzle_template_selection';
data: CreativeAgentTemplateSelectionEvent;
}
| { event: 'puzzle_cost_range'; data: CreativeAgentCostRangeEvent }
| { event: 'puzzle_level_plan'; data: CreativeAgentLevelPlanEvent }
| { event: 'tool_started'; data: CreativeAgentToolEvent }
| { event: 'tool_completed'; data: CreativeAgentToolEvent }
| { event: 'reflection'; data: CreativeAgentReflectionEvent }
| { event: 'target_session'; data: CreativeAgentTargetSessionEvent }
| {
event: 'session';
data: { session: CreativeAgentSessionSnapshot };
}
| { event: 'error'; data: CreativeAgentErrorEvent }
| { event: 'done'; data: CreativeAgentDoneEvent };

View File

@@ -0,0 +1,3 @@
export type * from './creativeAgent';
export type * from './puzzleCreativeTemplate';
export type * from './visualNovel';

View File

@@ -48,7 +48,9 @@ export type PuzzleAgentActionRequest =
workTitle?: string;
workDescription?: string;
pictureDescription?: string;
referenceImageSrc?: string | null;
imageModel?: string | null;
aiRedraw?: boolean;
}
| {
action: 'compile_puzzle_draft';
@@ -58,6 +60,7 @@ export type PuzzleAgentActionRequest =
pictureDescription?: string;
referenceImageSrc?: string | null;
imageModel?: string | null;
aiRedraw?: boolean;
candidateCount?: number;
}
| {

View File

@@ -46,6 +46,7 @@ export interface PuzzleDraftLevel {
levelId: string;
levelName: string;
pictureDescription: string;
pictureReference?: string | null;
candidates: PuzzleGeneratedImageCandidate[];
selectedCandidateId: string | null;
coverImageSrc: string | null;

View File

@@ -51,6 +51,7 @@ export interface CreatePuzzleAgentSessionRequest {
pictureDescription?: string;
referenceImageSrc?: string | null;
imageModel?: string | null;
aiRedraw?: boolean;
}
export interface CreatePuzzleAgentSessionResponse {

View File

@@ -0,0 +1,103 @@
export type PuzzleTemplatePricingUnit = 'point';
export type PuzzleSupportedLevelMode =
| 'single'
| 'multi'
| 'single_or_multi';
export type PuzzleLevelGenerationMode = 'single_level' | 'multi_level';
export interface PuzzleTemplateCostRange {
minPoints: number;
maxPoints: number;
pricingUnit: PuzzleTemplatePricingUnit;
reason: string;
}
export type PuzzleDraftEditableFieldPath =
| 'workTitle'
| 'workDescription'
| 'workTags'
| 'levels[].levelName'
| 'levels[].pictureDescription'
| 'levels[].pictureReference';
export interface PuzzleTemplateImageGenerationPolicy {
allowUploadedImageDirectly: boolean;
allowGeneratedImages: boolean;
allowPerLevelReferenceImage: boolean;
defaultCandidateCountPerLevel: number;
}
export interface PuzzleCreativeTemplateProtocol {
templateId: string;
title: string;
summary: string;
previewImageSrc: string | null;
supportedLevelMode: PuzzleSupportedLevelMode;
minLevelCount: number;
maxLevelCount: number;
defaultLevelCount: number;
costRange: PuzzleTemplateCostRange;
requiredDraftFields: PuzzleDraftEditableFieldPath[];
imagePolicy: PuzzleTemplateImageGenerationPolicy;
}
export interface PuzzleCreativeTemplateSelection {
templateId: string;
title: string;
reason: string;
costRange: PuzzleTemplateCostRange;
supportedLevelMode: PuzzleSupportedLevelMode;
selectedLevelMode: PuzzleLevelGenerationMode;
plannedLevelCount: number;
requiresUserConfirmation: true;
}
export interface CreativePuzzleLevelDraftInput {
levelName: string;
pictureDescription: string;
/**
* 任务 A 冻结Phase 1 采用正式字段方案,后续拼图草稿落地需补正式 pictureReference 字段。
*/
pictureReference?: string | null;
}
export interface CreativePuzzleDraftToolInput {
templateId: string;
templateCostRange: PuzzleTemplateCostRange;
workTitle: string;
workDescription: string;
workTags: string[];
levels: CreativePuzzleLevelDraftInput[];
}
export interface PuzzleImageGenerationPlanLevel {
levelId: string;
levelName: string;
pictureDescription: string;
imagePrompt: string;
pictureReference?: string | null;
candidateCount: number;
}
export interface PuzzleImageGenerationPlan {
mode: PuzzleLevelGenerationMode;
templateId: string;
estimatedCostRange: PuzzleTemplateCostRange;
levels: PuzzleImageGenerationPlanLevel[];
}
export type PuzzleDraftFieldPatchOperation =
| 'set'
| 'append'
| 'replace'
| 'remove';
export interface PuzzleDraftFieldPatch {
fieldPath: PuzzleDraftEditableFieldPath;
operation: PuzzleDraftFieldPatchOperation;
levelId?: string | null;
value: unknown;
rationale: string;
}

View File

@@ -0,0 +1,410 @@
export type VisualNovelSourceMode = 'idea' | 'document' | 'blank';
export type VisualNovelCharacterRole =
| 'protagonist'
| 'main'
| 'supporting'
| 'antagonist'
| 'background';
export type VisualNovelAssetSource = 'platform_asset' | 'generated' | 'external';
export type VisualNovelSceneAvailability =
| 'opening'
| 'always'
| 'phase_locked';
export type VisualNovelAttributePanelMode =
| 'off'
| 'platform_whitelist'
| 'template_config';
export type VisualNovelValidationSeverity = 'error' | 'warning';
export type VisualNovelAgentStatus =
| 'collecting'
| 'drafting'
| 'ready'
| 'failed';
export type VisualNovelAgentMessageRole = 'user' | 'assistant' | 'system';
export type VisualNovelAgentMessageKind =
| 'chat'
| 'summary'
| 'action_result'
| 'warning';
export type VisualNovelAgentActionKind =
| 'generate_draft'
| 'patch_world'
| 'patch_character'
| 'patch_scene'
| 'patch_story_phase'
| 'generate_scene_image'
| 'generate_character_image'
| 'compile_work_profile';
export type VisualNovelAgentPhase =
| 'perception'
| 'reasoning'
| 'drafting'
| 'reflection'
| 'finalizing';
export type VisualNovelRunMode = 'test' | 'play';
export type VisualNovelRunStatus = 'active' | 'completed' | 'failed';
export type VisualNovelRuntimeActionKind = 'choice' | 'free_text' | 'continue';
export type VisualNovelTransitionKind = 'fade' | 'cut' | 'flash' | 'none';
export type VisualNovelHistorySource = 'player' | 'assistant' | 'system';
export type VisualNovelFlagValue = string | number | boolean;
export interface VisualNovelDraftPatch {
path: string;
op: 'add' | 'replace' | 'remove';
value?: unknown;
}
export interface VisualNovelValidationIssue {
issueId: string;
code: string;
severity: VisualNovelValidationSeverity;
path: string;
message: string;
}
export interface VisualNovelChoiceDraft {
choiceId: string;
text: string;
actionHint?: string | null;
}
export interface VisualNovelCharacterImageAsset {
assetId: string;
imageSrc: string;
expression?: string | null;
source: VisualNovelAssetSource;
}
export interface VisualNovelWorldDraft {
title: string;
summary: string;
background: string;
premise: string;
literaryStyle: string;
playerRole: string;
defaultTone: string;
}
export interface VisualNovelCharacterDraft {
characterId: string;
name: string;
gender: string | null;
role: VisualNovelCharacterRole;
appearance: string;
personality: string;
tone: string;
background: string;
relationshipToPlayer: string;
imageAssets: VisualNovelCharacterImageAsset[];
defaultExpression: string | null;
isPlayerVisible: boolean;
}
export interface VisualNovelSceneDraft {
sceneId: string;
name: string;
description: string;
backgroundImageSrc: string | null;
musicSrc: string | null;
ambientSoundSrc: string | null;
availability: VisualNovelSceneAvailability;
phaseIds: string[];
}
export interface VisualNovelStoryPhaseDraft {
phaseId: string;
title: string;
goal: string;
summary: string;
entryCondition: string;
exitCondition: string;
sceneIds: string[];
characterIds: string[];
suggestedChoices: string[];
}
export interface VisualNovelOpeningDraft {
sceneId: string | null;
narration: string;
speakerCharacterId: string | null;
firstDialogue: string | null;
initialChoices: VisualNovelChoiceDraft[];
}
export interface VisualNovelRuntimeConfigDraft {
textModeEnabled: boolean;
defaultTextMode: boolean;
maxHistoryEntries: number;
maxAssistantStepCountPerTurn: number;
allowFreeTextAction: boolean;
allowHistoryRegeneration: boolean;
attributePanelMode: VisualNovelAttributePanelMode;
saveArchiveEnabled: boolean;
}
export interface VisualNovelResultDraft {
profileId: string | null;
workTitle: string;
workDescription: string;
workTags: string[];
coverImageSrc: string | null;
sourceMode: VisualNovelSourceMode;
sourceAssetIds: string[];
world: VisualNovelWorldDraft;
characters: VisualNovelCharacterDraft[];
scenes: VisualNovelSceneDraft[];
storyPhases: VisualNovelStoryPhaseDraft[];
opening: VisualNovelOpeningDraft;
runtimeConfig: VisualNovelRuntimeConfigDraft;
publishReady: boolean;
validationIssues: VisualNovelValidationIssue[];
updatedAt: string;
}
export interface VisualNovelAgentMessage {
id: string;
role: VisualNovelAgentMessageRole;
kind: VisualNovelAgentMessageKind;
text: string;
createdAt: string;
}
export interface VisualNovelAgentPendingAction {
actionId: string;
kind: VisualNovelAgentActionKind;
label: string;
targetId?: string | null;
payload?: unknown;
}
export interface VisualNovelAgentSessionSnapshot {
sessionId: string;
ownerUserId: string;
sourceMode: VisualNovelSourceMode;
status: VisualNovelAgentStatus;
messages: VisualNovelAgentMessage[];
draft: VisualNovelResultDraft | null;
pendingAction: VisualNovelAgentPendingAction | null;
createdAt: string;
updatedAt: string;
}
export interface CreateVisualNovelSessionRequest {
sourceMode: VisualNovelSourceMode;
seedText?: string | null;
sourceAssetIds?: string[];
}
export interface VisualNovelSessionResponse {
session: VisualNovelAgentSessionSnapshot;
}
export interface VisualNovelWorkSummary {
runtimeKind: 'visual-novel';
profileId: string;
ownerUserId: string;
title: string;
description: string;
coverImageSrc: string | null;
tags: string[];
publishStatus: string;
publishReady: boolean;
playCount: number;
updatedAt: string;
publishedAt: string | null;
}
export interface VisualNovelWorkDetail {
workId: string;
summary: VisualNovelWorkSummary;
sourceSessionId: string | null;
authorDisplayName: string;
sourceAssetIds: string[];
draft: VisualNovelResultDraft;
createdAt: string;
}
export interface VisualNovelWorksResponse {
works: VisualNovelWorkSummary[];
}
export interface VisualNovelWorkResponse {
work: VisualNovelWorkDetail;
}
export interface UpdateVisualNovelWorkRequest {
draft: VisualNovelResultDraft;
}
export interface VisualNovelCompileResponse {
session: VisualNovelAgentSessionSnapshot;
work: VisualNovelWorkDetail;
}
export interface SendVisualNovelMessageRequest {
clientMessageId: string;
text: string;
}
export interface ExecuteVisualNovelAgentActionRequest {
actionId?: string | null;
kind: VisualNovelAgentActionKind;
targetId?: string | null;
payload?: unknown;
}
export interface CompileVisualNovelWorkProfileRequest {
draft: VisualNovelResultDraft;
}
export type VisualNovelAgentStreamEvent =
| { type: 'start'; sessionId: string }
| { type: 'phase'; phase: VisualNovelAgentPhase }
| { type: 'text_delta'; text: string }
| { type: 'draft_patch'; patch: VisualNovelDraftPatch }
| { type: 'action_required'; action: VisualNovelAgentPendingAction }
| { type: 'complete'; session: VisualNovelAgentSessionSnapshot }
| { type: 'error'; message: string; retryable: boolean }
| { type: 'done' };
export interface VisualNovelSceneChangeStep {
type: 'scene_change';
sceneId: string;
backgroundImageSrc: string | null;
musicSrc: string | null;
}
export interface VisualNovelNarrationStep {
type: 'narration';
text: string;
}
export interface VisualNovelDialogueStep {
type: 'dialogue';
characterId: string;
characterName: string;
expression: string | null;
text: string;
}
export interface VisualNovelTransitionStep {
type: 'transition';
transitionKind: VisualNovelTransitionKind;
text: string | null;
}
export interface VisualNovelChoiceStep {
type: 'choice';
choices: VisualNovelChoiceDraft[];
}
export interface VisualNovelFlagStep {
type: 'flag';
key: string;
value: VisualNovelFlagValue;
}
export interface VisualNovelMetricStep {
type: 'metric';
key: string;
delta: number;
}
export type VisualNovelRuntimeStep =
| VisualNovelSceneChangeStep
| VisualNovelNarrationStep
| VisualNovelDialogueStep
| VisualNovelTransitionStep
| VisualNovelChoiceStep
| VisualNovelFlagStep
| VisualNovelMetricStep;
export interface VisualNovelHistoryEntry {
entryId: string;
runId: string;
turnIndex: number;
source: VisualNovelHistorySource;
actionText: string | null;
steps: VisualNovelRuntimeStep[];
snapshotBeforeHash: string | null;
snapshotAfterHash: string | null;
createdAt: string;
}
export interface VisualNovelRunSnapshot {
runId: string;
ownerUserId: string;
profileId: string;
mode: VisualNovelRunMode;
status: VisualNovelRunStatus;
currentSceneId: string | null;
currentPhaseId: string | null;
visibleCharacterIds: string[];
flags: Record<string, VisualNovelFlagValue>;
metrics: Record<string, number>;
history: VisualNovelHistoryEntry[];
availableChoices: VisualNovelChoiceDraft[];
textModeEnabled: boolean;
createdAt: string;
updatedAt: string;
}
export interface VisualNovelRuntimeActionRequest {
actionKind: VisualNovelRuntimeActionKind;
choiceId?: string;
text?: string;
clientEventId: string;
}
export interface VisualNovelStartRunRequest {
profileId: string;
mode: VisualNovelRunMode;
}
export interface VisualNovelRunResponse {
run: VisualNovelRunSnapshot;
}
export interface VisualNovelHistoryResponse {
history: VisualNovelHistoryEntry[];
}
export interface VisualNovelRegenerateRequest {
historyEntryId: string;
clientEventId: string;
}
export interface VisualNovelSaveArchiveState {
runtimeKind: 'visual-novel';
profileId: string;
runId: string;
currentSceneId: string | null;
currentPhaseId: string | null;
historyCursor: number;
snapshotHash: string | null;
}
export type VisualNovelRuntimeStreamEvent =
| { type: 'start'; runId: string }
| { type: 'raw_text'; text: string }
| { type: 'step'; step: VisualNovelRuntimeStep }
| { type: 'snapshot'; run: VisualNovelRunSnapshot }
| { type: 'complete'; run: VisualNovelRunSnapshot }
| { type: 'error'; message: string; retryable: boolean }
| { type: 'done' };

View File

@@ -3,6 +3,7 @@ export * from './contracts/auth';
export type * from './contracts/bigFish';
export * from './contracts/common';
export type * from './contracts/creationAgentDocumentInput';
export type * from './contracts/creativeAgent';
export type * from './contracts/customWorldAgent';
export * from './contracts/match3dAgent';
export * from './contracts/match3dRuntime';
@@ -11,6 +12,7 @@ export * from './contracts/puzzleAgentActions';
export * from './contracts/puzzleAgentDraft';
export * from './contracts/puzzleAgentSession';
export * from './contracts/puzzleOnboarding';
export type * from './contracts/puzzleCreativeTemplate';
export * from './contracts/puzzleResultPreview';
export * from './contracts/puzzleRuntimeSession';
export * from './contracts/puzzleWorkSummary';
@@ -42,6 +44,7 @@ export type {
SquareHoleWorkSummary,
} from './contracts/squareHoleWorks';
export type * from './contracts/story';
export type * from './contracts/visualNovel';
export * from './http';
export * from './llm/narrativeLanguage';
export * from './llm/parsers';