| 1 | import type { CreditsScope } from '../_shared/credits.types' |
| 2 | import type { AgentTaskStatus, MediaType } from './ai.constants' |
| 3 | import type { PlatType } from '@/app/config/platConfig' |
| 4 | |
| 5 | // Source: types/ai.ts |
| 6 | |
| 7 | /** |
| 8 | * ChatModel 类型。 |
| 9 | */ |
| 10 | export interface ChatModel { |
| 11 | name: string |
| 12 | description?: string |
| 13 | logo?: string |
| 14 | channel?: string |
| 15 | scenes?: string[] |
| 16 | inputModalities?: string[] |
| 17 | outputModalities?: string[] |
| 18 | pricing?: ChatModelPricing |
| 19 | fixedImagePricing?: ChatModelFixedImagePricing[] |
| 20 | tags?: string[] |
| 21 | mainTag?: boolean |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * ChatModelPricingTier 类型。 |
| 26 | */ |
| 27 | export interface ChatModelPricingTier { |
| 28 | maxInputTokens?: number |
| 29 | input?: Record<string, string> |
| 30 | output?: Record<string, string> |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * ChatModelPricing 类型。 |
| 35 | */ |
| 36 | export interface ChatModelPricing { |
| 37 | prompt?: string |
| 38 | completion?: string |
| 39 | tiers?: ChatModelPricingTier[] |
| 40 | originPricing?: { |
| 41 | tiers?: ChatModelPricingTier[] |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * ChatModelFixedImagePricing 类型。 |
| 47 | */ |
| 48 | export interface ChatModelFixedImagePricing { |
| 49 | resolution: string |
| 50 | price: number |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * AdaptPlatform 类型。 |
| 55 | */ |
| 56 | export type AdaptPlatform |
| 57 | = | 'douyin' | 'xhs' | 'wxSph' | 'KWAI' | 'youtube' | 'wxGzh' | 'bilibili' | 'twitter' | 'tiktok' | 'facebook' | 'instagram' | 'threads' | 'pinterest' | 'linkedin' |
| 58 | |
| 59 | // Source: types/draftGeneration.ts |
| 60 | |
| 61 | /** |
| 62 | * CreateDraftFromVideoUrlDto 请求参数。 |
| 63 | */ |
| 64 | export interface CreateDraftFromVideoUrlDto { |
| 65 | videoUrl: string |
| 66 | groupId?: string |
| 67 | platforms?: string[] |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * CreateDraftFromVideoUrlVo 响应数据。 |
| 72 | */ |
| 73 | export interface CreateDraftFromVideoUrlVo { |
| 74 | materialId: string |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * ImageModelPricing 类型。 |
| 79 | */ |
| 80 | export interface ImageModelPricing { |
| 81 | resolution: string |
| 82 | pricePerImage: number |
| 83 | originPrice?: number |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * ImageModelInfo 数据结构。 |
| 88 | */ |
| 89 | export interface ImageModelInfo { |
| 90 | model: string |
| 91 | displayName: string |
| 92 | pricing: ImageModelPricing[] |
| 93 | supportedAspectRatios?: string[] |
| 94 | maxInputImages?: number |
| 95 | tags?: string[] |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * VideoModelPricing 类型。 |
| 100 | */ |
| 101 | export interface VideoModelPricing { |
| 102 | duration: number |
| 103 | price: number |
| 104 | mode?: string |
| 105 | resolution?: string |
| 106 | aspectRatio?: string |
| 107 | discount?: string |
| 108 | originPrice?: number |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * VideoModelInputConstraint 类型。 |
| 113 | */ |
| 114 | export interface VideoModelInputConstraint { |
| 115 | maxCount?: number |
| 116 | formats?: string[] |
| 117 | minDuration?: number |
| 118 | maxDuration?: number |
| 119 | maxTotalDuration?: number |
| 120 | maxSizeMb?: number |
| 121 | minAspectRatio?: number |
| 122 | maxAspectRatio?: number |
| 123 | minWidth?: number |
| 124 | maxWidth?: number |
| 125 | minPixels?: number |
| 126 | maxPixels?: number |
| 127 | minFps?: number |
| 128 | maxFps?: number |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * VideoModelInputConstraints 类型。 |
| 133 | */ |
| 134 | export interface VideoModelInputConstraints { |
| 135 | images?: VideoModelInputConstraint |
| 136 | videos?: VideoModelInputConstraint |
| 137 | audios?: VideoModelInputConstraint |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * VideoModelInfo 数据结构。 |
| 142 | */ |
| 143 | export interface VideoModelInfo { |
| 144 | name: string |
| 145 | description: string |
| 146 | channel: string |
| 147 | creditsScope?: CreditsScope |
| 148 | modes: string[] |
| 149 | resolutions: string[] |
| 150 | durations: number[] |
| 151 | maxInputImages: number |
| 152 | inputConstraints?: VideoModelInputConstraints |
| 153 | aspectRatios: string[] |
| 154 | tags: string[] |
| 155 | defaults: { |
| 156 | resolution?: string |
| 157 | aspectRatio?: string |
| 158 | duration?: number |
| 159 | } |
| 160 | pricing: VideoModelPricing[] |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * DraftGenerationPricingVo 响应数据。 |
| 165 | */ |
| 166 | export interface DraftGenerationPricingVo { |
| 167 | imageModels: ImageModelInfo[] |
| 168 | videoModels?: VideoModelInfo[] |
| 169 | } |
| 170 | |
| 171 | // Source: ai/ai.api.ts inline types |
| 172 | // Source: agent.ts |
| 173 | |
| 174 | /** |
| 175 | * Media 类型。 |
| 176 | */ |
| 177 | export interface Media { |
| 178 | type: MediaType |
| 179 | url: string |
| 180 | coverUrl?: string // 视频封面URL(可选) |
| 181 | } |
| 182 | |
| 183 | /** |
| 184 | * TaskDetail 数据结构。 |
| 185 | */ |
| 186 | export interface TaskDetail { |
| 187 | id: string |
| 188 | userId: string |
| 189 | prompt: string |
| 190 | title: string |
| 191 | description: string |
| 192 | tags: string[] |
| 193 | status: AgentTaskStatus |
| 194 | medias: Media[] |
| 195 | errorMessage: string |
| 196 | createdAt: string |
| 197 | updatedAt: string |
| 198 | messages?: TaskMessage[] |
| 199 | rating?: number | null |
| 200 | ratingComment?: string | null |
| 201 | |
| 202 | favoritedAt?: string | null |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * TaskMessage 类型。 |
| 207 | */ |
| 208 | export interface TaskMessage { |
| 209 | type: 'user' | 'assistant' | 'result' | 'system' | 'stream_event' | 'error' |
| 210 | uuid?: string |
| 211 | message?: any |
| 212 | content?: string | any[] |
| 213 | parent_tool_use_id?: string | null |
| 214 | subtype?: string |
| 215 | code?: number |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * TaskListItem 数据结构。 |
| 220 | */ |
| 221 | export interface TaskListItem |
| 222 | { |
| 223 | id: string |
| 224 | userId: string |
| 225 | |
| 226 | title?: string |
| 227 | |
| 228 | createdAt: string |
| 229 | |
| 230 | updatedAt: string |
| 231 | |
| 232 | status?: string |
| 233 | |
| 234 | rating?: number | null |
| 235 | |
| 236 | ratingComment?: string | null |
| 237 | |
| 238 | favoritedAt?: string | null |
| 239 | } |
| 240 | |
| 241 | /** |
| 242 | * TaskListResponse 响应数据。 |
| 243 | */ |
| 244 | export interface TaskListResponse { |
| 245 | |
| 246 | page: number |
| 247 | pageSize: number |
| 248 | totalPages: number |
| 249 | total: number |
| 250 | list: TaskListItem[] |
| 251 | } |
| 252 | |
| 253 | /** |
| 254 | * GetTaskListParams 请求参数。 |
| 255 | */ |
| 256 | export interface GetTaskListParams { |
| 257 | page?: number |
| 258 | pageSize?: number |
| 259 | |
| 260 | keyword?: string |
| 261 | |
| 262 | favoriteOnly?: boolean |
| 263 | } |
| 264 | |
| 265 | /** |
| 266 | * CreateAgentTaskParams 请求参数。 |
| 267 | */ |
| 268 | export interface CreateAgentTaskParams { |
| 269 | prompt: string | any[] // 支持字符串或 Claude Prompt 格式数组 |
| 270 | taskId?: string // 可选,传入则继续上一次对话 |
| 271 | messageUuid?: string // 可选,重置到对应的消息继续 |
| 272 | includePartialMessages?: boolean // 使用流式消息 |
| 273 | } |
| 274 | |
| 275 | /** |
| 276 | * CreateTaskResponse 响应数据。 |
| 277 | */ |
| 278 | export interface CreateTaskResponse { |
| 279 | id: string |
| 280 | } |
| 281 | |
| 282 | /** |
| 283 | * ResultType 类型。 |
| 284 | */ |
| 285 | export type ResultType = 'imageOnly' | 'videoOnly' | 'fullContent' |
| 286 | |
| 287 | /** |
| 288 | * ResultAction 类型。 |
| 289 | */ |
| 290 | export type ResultAction |
| 291 | = | 'draft' | 'publish' | 'createChannel' | 'updateChannel' |
| 292 | | 'loginChannel' | 'platformNotSupported' |
| 293 | |
| 294 | /** |
| 295 | * Platform 类型。 |
| 296 | */ |
| 297 | export type Platform |
| 298 | = | 'douyin' | 'xhs' | 'wxSph' | 'KWAI' | 'youtube' | 'wxGzh' | 'bilibili' | 'twitter' | 'tiktok' | 'facebook' | 'instagram' | 'threads' | 'pinterest' | 'linkedin' |
| 299 | |
| 300 | /** |
| 301 | * ResultData 数据结构。 |
| 302 | */ |
| 303 | export interface ResultData { |
| 304 | taskId: string |
| 305 | title: string |
| 306 | description: string |
| 307 | tags: string[] |
| 308 | medias: Media[] |
| 309 | type?: ResultType // 结果类型 |
| 310 | action?: ResultAction // 操作类型 |
| 311 | platform?: Platform // 平台类型 |
| 312 | accountType?: string[] // 账户类型数组,如 ['douyin', 'xhs'] |
| 313 | } |
| 314 | |
| 315 | /** |
| 316 | * ResultMessage 类型。 |
| 317 | */ |
| 318 | export interface ResultMessage { |
| 319 | type: 'result' |
| 320 | subtype?: string // 保留兼容性 |
| 321 | uuid: string |
| 322 | duration_ms: number |
| 323 | duration_api_ms: number |
| 324 | is_error: boolean |
| 325 | num_turns: number |
| 326 | message: string |
| 327 | result: ResultData |
| 328 | total_cost_usd: number |
| 329 | usage: any |
| 330 | permission_denials: any[] |
| 331 | } |
| 332 | |
| 333 | /** |
| 334 | * StreamEvent 类型。 |
| 335 | */ |
| 336 | export interface StreamEvent { |
| 337 | type: 'stream_event' |
| 338 | uuid: string |
| 339 | event: { |
| 340 | type: |
| 341 | | 'message_start' | 'content_block_start' | 'content_block_delta' | 'content_block_stop' | 'message_delta' | 'message_stop' |
| 342 | index?: number |
| 343 | content_block?: any |
| 344 | delta?: { |
| 345 | type: 'text_delta' | 'input_json_delta' |
| 346 | text?: string |
| 347 | partial_json?: string |
| 348 | } |
| 349 | message?: any |
| 350 | usage?: any |
| 351 | } |
| 352 | parent_tool_use_id?: string | null |
| 353 | } |
| 354 | |
| 355 | /** |
| 356 | * SSEMessage 类型。 |
| 357 | */ |
| 358 | export interface SSEMessage { |
| 359 | type: |
| 360 | | 'init' | 'keep_alive' | 'stream_event' | 'message' | 'status' | 'error' | 'done' | 'text' | 'result' |
| 361 | taskId?: string |
| 362 | message?: string | ResultMessage | StreamEvent |
| 363 | sessionId?: string |
| 364 | status?: AgentTaskStatus |
| 365 | data?: any |
| 366 | } |
| 367 | |
| 368 | /** |
| 369 | * TaskMessagesVo 响应数据。 |
| 370 | */ |
| 371 | export interface TaskMessagesVo { |
| 372 | messages: TaskMessage[] |
| 373 | status?: AgentTaskStatus // 任务状态,可选 |
| 374 | } |
| 375 | |
| 376 | // Source: draftGeneration.ts |
| 377 | // ==================== 类型定义 ==================== |
| 378 | |
| 379 | /** |
| 380 | * 草稿生成任务状态。 |
| 381 | */ |
| 382 | export type DraftTaskStatus = 'generating' | 'success' | 'failed' |
| 383 | |
| 384 | /** |
| 385 | * DraftGenerationResponse 响应数据。 |
| 386 | */ |
| 387 | export interface DraftGenerationResponse { |
| 388 | materialId?: string |
| 389 | mediaId?: string |
| 390 | mediaIds?: string[] |
| 391 | title?: string |
| 392 | description?: string |
| 393 | topics?: string[] |
| 394 | videoUrl?: string |
| 395 | coverUrl?: string |
| 396 | imageUrls?: string[] |
| 397 | requestedImageCount?: number |
| 398 | generatedImageCount?: number |
| 399 | imageGenerationErrors?: Array<Record<string, unknown>> |
| 400 | plan?: Record<string, unknown> |
| 401 | } |
| 402 | |
| 403 | /** |
| 404 | * DraftGenerationRequest 请求参数。 |
| 405 | */ |
| 406 | export interface DraftGenerationRequest { |
| 407 | groupId?: string |
| 408 | model?: string |
| 409 | imageModel?: string |
| 410 | plannerModel?: string |
| 411 | duration?: number |
| 412 | resolution?: string |
| 413 | aspectRatio?: string |
| 414 | prompt?: string |
| 415 | captionPrompt?: string |
| 416 | imageUrls?: string[] |
| 417 | videoUrls?: string[] |
| 418 | audioUrls?: string[] |
| 419 | imageCount?: number |
| 420 | imageSize?: string |
| 421 | platforms?: PlatType[] |
| 422 | draftType?: VideoDraftType | ImageTextDraftType |
| 423 | } |
| 424 | |
| 425 | /** |
| 426 | * DraftGenerationQueue 类型。 |
| 427 | */ |
| 428 | export interface DraftGenerationQueue { |
| 429 | position?: number |
| 430 | waitingCount?: number |
| 431 | } |
| 432 | |
| 433 | /** |
| 434 | * DraftGenerationTask 类型。 |
| 435 | */ |
| 436 | export interface DraftGenerationTask { |
| 437 | id: string |
| 438 | status: DraftTaskStatus |
| 439 | points: number |
| 440 | errorMessage?: string |
| 441 | request?: DraftGenerationRequest |
| 442 | response?: DraftGenerationResponse | string |
| 443 | queue?: DraftGenerationQueue |
| 444 | createdAt: string |
| 445 | updatedAt: string |
| 446 | } |
| 447 | |
| 448 | /** |
| 449 | * DraftGenerationStats 数据结构。 |
| 450 | */ |
| 451 | export interface DraftGenerationStats { |
| 452 | generatingCount: number |
| 453 | } |
| 454 | |
| 455 | /** |
| 456 | * CreateDraftGenerationVo 响应数据。 |
| 457 | */ |
| 458 | export interface CreateDraftGenerationVo { |
| 459 | taskIds: string[] |
| 460 | } |
| 461 | |
| 462 | /** |
| 463 | * DraftGenerationTaskListVo 响应数据。 |
| 464 | */ |
| 465 | export interface DraftGenerationTaskListVo { |
| 466 | page: number |
| 467 | pageSize: number |
| 468 | totalPages: number |
| 469 | total: number |
| 470 | list: DraftGenerationTask[] |
| 471 | } |
| 472 | |
| 473 | // ==================== API 调用 ==================== |
| 474 | |
| 475 | /** |
| 476 | * 视频生成模型类型标识。 |
| 477 | */ |
| 478 | export type VideoModelType = string |
| 479 | |
| 480 | /** |
| 481 | * ImageModelType 类型。 |
| 482 | */ |
| 483 | export type ImageModelType = string |
| 484 | |
| 485 | /** |
| 486 | * DraftContentType 类型。 |
| 487 | */ |
| 488 | export type DraftContentType = 'video' | 'image_text' |
| 489 | |
| 490 | /** |
| 491 | * VideoDraftType 类型。 |
| 492 | */ |
| 493 | export type VideoDraftType = 'draft' | 'video' |
| 494 | |
| 495 | /** |
| 496 | * ImageTextDraftType 类型。 |
| 497 | */ |
| 498 | export type ImageTextDraftType = 'draft' | 'image' |
| 499 | |
| 500 | /** |
| 501 | * Agent 任务评分数据。 |
| 502 | */ |
| 503 | export interface AgentTaskRatingData { |
| 504 | rating?: number | null |
| 505 | comment?: string | null |
| 506 | } |
| 507 | |
| 508 | /** |
| 509 | * Agent 任务评分响应。 |
| 510 | */ |
| 511 | export interface AgentTaskRatingResponse { |
| 512 | data: AgentTaskRatingData |
| 513 | } |
| 514 | |
| 515 | /** |
| 516 | * 提交 Agent 任务评分请求参数。 |
| 517 | */ |
| 518 | export interface SubmitAgentTaskRatingPayload { |
| 519 | rating: number |
| 520 | comment?: string |
| 521 | } |
| 522 | |
| 523 | /** |
| 524 | * Agent 任务公开分享响应。 |
| 525 | */ |
| 526 | export interface AgentTaskShareVo { |
| 527 | token: string |
| 528 | expiresAt: string |
| 529 | urlPath: string |
| 530 | } |
| 531 | |
| 532 | /** |
| 533 | * AI 分页查询参数。 |
| 534 | */ |
| 535 | export interface AiPaginationParams { |
| 536 | page?: number |
| 537 | pageSize?: number |
| 538 | } |
| 539 | |
| 540 | /** |
| 541 | * 视频生成历史时间戳。 |
| 542 | */ |
| 543 | export type VideoGenerationTimestamp = number | string | null | undefined |
| 544 | |
| 545 | /** |
| 546 | * 视频生成历史记录项。 |
| 547 | */ |
| 548 | export interface VideoGenerationHistoryItem { |
| 549 | task_id: string |
| 550 | action: string |
| 551 | status: 'SUCCESS' | 'FAILED' | 'PROCESSING' | string |
| 552 | fail_reason?: string |
| 553 | submit_time?: VideoGenerationTimestamp |
| 554 | start_time?: VideoGenerationTimestamp |
| 555 | finish_time?: VideoGenerationTimestamp |
| 556 | progress: string |
| 557 | prompt: string |
| 558 | data?: { |
| 559 | completed_at?: VideoGenerationTimestamp |
| 560 | created_at?: VideoGenerationTimestamp |
| 561 | error?: string | null |
| 562 | id?: string |
| 563 | model?: string |
| 564 | object?: string |
| 565 | progress?: number |
| 566 | result_url?: string |
| 567 | seconds?: string |
| 568 | size?: string |
| 569 | status?: string |
| 570 | url?: string |
| 571 | video_url?: string |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | /** |
| 576 | * 视频生成历史列表响应数据。 |
| 577 | */ |
| 578 | export interface VideoGenerationHistoryListVo { |
| 579 | list?: VideoGenerationHistoryItem[] |
| 580 | total?: number |
| 581 | page?: number |
| 582 | pageSize?: number |
| 583 | totalPages?: number |
| 584 | } |
| 585 | |
| 586 | /** |
| 587 | * AI 日志查询参数。 |
| 588 | */ |
| 589 | export interface AiLogListParams extends AiPaginationParams { |
| 590 | startDate?: string |
| 591 | endDate?: string |
| 592 | } |
| 593 | |
| 594 | /** |
| 595 | * AI 聊天消息。 |
| 596 | */ |
| 597 | export interface AiChatMessage { |
| 598 | role: string |
| 599 | content: string |
| 600 | } |
| 601 | |
| 602 | /** |
| 603 | * AI 聊天请求参数。 |
| 604 | */ |
| 605 | export interface AiChatStreamParams { |
| 606 | messages: AiChatMessage[] |
| 607 | stream?: boolean |
| 608 | model?: string |
| 609 | temperature?: number |
| 610 | presence_penalty?: number |
| 611 | frequency_penalty?: number |
| 612 | top_p?: number |
| 613 | max_tokens?: number |
| 614 | } |
| 615 | |
| 616 | /** |
| 617 | * AI 视频草稿批量生成请求参数。 |
| 618 | */ |
| 619 | export interface CreateVideoDraftGenerationParams { |
| 620 | quantity: number |
| 621 | groupId: string |
| 622 | model: VideoModelType |
| 623 | prompt?: string |
| 624 | captionPrompt?: string |
| 625 | imageUrls?: string[] |
| 626 | videoUrls?: string[] |
| 627 | audioUrls?: string[] |
| 628 | duration?: number |
| 629 | resolution?: string |
| 630 | aspectRatio?: string |
| 631 | platforms?: PlatType[] |
| 632 | draftType?: VideoDraftType |
| 633 | } |
| 634 | |
| 635 | /** |
| 636 | * AI 图文草稿批量生成请求参数。 |
| 637 | */ |
| 638 | export interface CreateImageTextDraftGenerationParams { |
| 639 | quantity: number |
| 640 | groupId: string |
| 641 | prompt: string |
| 642 | captionPrompt?: string |
| 643 | imageModel: ImageModelType |
| 644 | imageCount?: number |
| 645 | imageUrls?: string[] |
| 646 | aspectRatio?: string |
| 647 | imageSize?: string |
| 648 | platforms?: PlatType[] |
| 649 | draftType?: ImageTextDraftType |
| 650 | } |
| 651 |