@plolink/sdk 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,562 @@
1
+ import { P as PlolinkClient } from '../../client-CwNikk7i.js';
2
+ import { P as Poller } from '../../poller-DWKZjuSw.js';
3
+ import '../../core-77EbLgbp.js';
4
+ import 'axios';
5
+
6
+ /**
7
+ * 视频人物心理分析模块类型
8
+ */
9
+ /**
10
+ * 视频人物心理分析状态枚举
11
+ */
12
+ type VideoPsychAnalysisStatus = 'PENDING' | 'SUBMITTING' | 'SUBMITTED' | 'PROCESSING' | 'SYNCING_RESULTS' | 'GENERATING_REPORT' | 'COMPLETED' | 'FAILED';
13
+ /**
14
+ * 创建视频心理分析任务参数
15
+ */
16
+ interface CreateVideoPsychAnalysisParams {
17
+ /** 任务名称(可选,用于用户识别) */
18
+ name?: string;
19
+ /** 视频文件ID数组 */
20
+ videoFileIds: string[];
21
+ /** 人物参考图文件ID */
22
+ referenceImageFileId: string;
23
+ /** 用户Prompt(如:心理分析专家的专业风格) */
24
+ prompt: string;
25
+ /** 切帧FPS(1-30,默认3) */
26
+ frameFps?: number;
27
+ /** 分析语言(默认zh) */
28
+ language?: string;
29
+ }
30
+ /**
31
+ * 视频元数据信息
32
+ */
33
+ interface VideoInfo {
34
+ /** 视频宽度 */
35
+ width: number;
36
+ /** 视频高度 */
37
+ height: number;
38
+ /** 视频时长(秒) */
39
+ duration: number;
40
+ /** 文件大小(字节) */
41
+ file_size: number;
42
+ /** 帧率 */
43
+ fps: number;
44
+ /** 视频编码 */
45
+ video_codec: string;
46
+ /** 音频编码 */
47
+ audio_codec: string | null;
48
+ /** 视频比特率 */
49
+ video_bitrate: number;
50
+ /** 音频比特率 */
51
+ audio_bitrate: number | null;
52
+ }
53
+ /**
54
+ * 进度信息
55
+ */
56
+ interface AnalysisProgress {
57
+ /** 已完成步骤数 */
58
+ done: number;
59
+ /** 总步骤数 */
60
+ total: number;
61
+ /** 当前阶段 */
62
+ stage: string;
63
+ }
64
+ /**
65
+ * 创建分析任务响应
66
+ */
67
+ interface CreateVideoPsychAnalysisResponse {
68
+ /** 分析任务ID */
69
+ id: string;
70
+ /** 当前状态 */
71
+ status: VideoPsychAnalysisStatus;
72
+ /** 提示消息 */
73
+ message: string;
74
+ }
75
+ /**
76
+ * 视频心理分析详情
77
+ */
78
+ interface VideoPsychAnalysisDetail {
79
+ /** 分析任务ID */
80
+ id: string;
81
+ /** 任务名称 */
82
+ name: string;
83
+ /** 当前状态 */
84
+ status: VideoPsychAnalysisStatus;
85
+ /** 进度信息 */
86
+ progress: AnalysisProgress;
87
+ /** 错误信息 */
88
+ errorMessage: string;
89
+ /** 视频元数据信息 */
90
+ videoInfo: VideoInfo | null;
91
+ /** AI生成的最终报告(Markdown格式) */
92
+ reportContent: string;
93
+ /** 报告生成时间 */
94
+ reportGeneratedAt: string | null;
95
+ /** 创建时间 */
96
+ createdAt: string;
97
+ /** 更新时间 */
98
+ updatedAt: string;
99
+ }
100
+ /**
101
+ * 同步任务状态响应
102
+ */
103
+ interface SyncStatusResponse {
104
+ /** 当前状态 */
105
+ status: string;
106
+ /** 进度信息 */
107
+ progress: AnalysisProgress;
108
+ /** 提示消息 */
109
+ message: string;
110
+ }
111
+ /**
112
+ * 文本维度分析项
113
+ */
114
+ interface TextAnalysisItem {
115
+ /** 文本ID */
116
+ id: string;
117
+ /** 文本内容 */
118
+ text: string;
119
+ /** 开始时间(秒) */
120
+ start_time: number;
121
+ /** 结束时间(秒) */
122
+ end_time: number;
123
+ /** NLP分析结果 */
124
+ nlp_result?: {
125
+ /** 说话人情绪 */
126
+ speaker_emotion?: string;
127
+ /** 真实态度 */
128
+ real_attitude?: string;
129
+ /** 其他NLP字段 */
130
+ [key: string]: unknown;
131
+ };
132
+ /** 其他字段 */
133
+ [key: string]: unknown;
134
+ }
135
+ /**
136
+ * 文本维度结果
137
+ */
138
+ interface TextsData {
139
+ /** 总数 */
140
+ total: number;
141
+ /** 文本项列表 */
142
+ items: TextAnalysisItem[];
143
+ }
144
+ /**
145
+ * 帧维度分析项
146
+ */
147
+ interface FrameAnalysisItem {
148
+ /** 帧ID */
149
+ id: string;
150
+ /** 帧图片URL */
151
+ image_url: string;
152
+ /** 时间戳(秒) */
153
+ timestamp: number;
154
+ /** 视觉分析结果 */
155
+ vision_result?: {
156
+ /** 表情 */
157
+ expression?: string;
158
+ /** 动作 */
159
+ action?: string;
160
+ /** 其他视觉字段 */
161
+ [key: string]: unknown;
162
+ };
163
+ /** 其他字段 */
164
+ [key: string]: unknown;
165
+ }
166
+ /**
167
+ * 帧维度结果
168
+ */
169
+ interface FramesData {
170
+ /** 总数 */
171
+ total: number;
172
+ /** 帧项列表 */
173
+ items: FrameAnalysisItem[];
174
+ }
175
+ /**
176
+ * 段落分析项
177
+ */
178
+ interface ParagraphAnalysisItem {
179
+ /** 段落ID */
180
+ id: string;
181
+ /** 段落文本 */
182
+ text: string;
183
+ /** 段落摘要 */
184
+ summary: string;
185
+ /** 开始时间(秒) */
186
+ start_time: number;
187
+ /** 结束时间(秒) */
188
+ end_time: number;
189
+ /** NLP分析结果 */
190
+ nlp_result?: {
191
+ /** 说话人情绪 */
192
+ speaker_emotion?: string;
193
+ /** 真实态度 */
194
+ real_attitude?: string;
195
+ /** 其他NLP字段 */
196
+ [key: string]: unknown;
197
+ };
198
+ /** 其他字段 */
199
+ [key: string]: unknown;
200
+ }
201
+ /**
202
+ * 段落结果
203
+ */
204
+ interface ParagraphsData {
205
+ /** 总数 */
206
+ total: number;
207
+ /** 段落项列表 */
208
+ items: ParagraphAnalysisItem[];
209
+ }
210
+ /**
211
+ * 列表查询参数
212
+ */
213
+ interface ListVideoPsychAnalysesParams {
214
+ /** 页码(默认1) */
215
+ page?: number;
216
+ /** 每页数量(默认20) */
217
+ pageSize?: number;
218
+ /** 关键词搜索(搜索任务名称) */
219
+ keyword?: string;
220
+ /** 状态筛选 */
221
+ status?: VideoPsychAnalysisStatus;
222
+ /** 排序字段(默认createdAt) */
223
+ sortBy?: 'createdAt' | 'updatedAt';
224
+ /** 排序方向(默认desc) */
225
+ sortOrder?: 'asc' | 'desc';
226
+ }
227
+ /**
228
+ * 分析任务摘要(列表项)
229
+ */
230
+ interface VideoPsychAnalysisSummary {
231
+ /** 分析任务ID */
232
+ id: string;
233
+ /** 任务名称 */
234
+ name: string;
235
+ /** 当前状态 */
236
+ status: VideoPsychAnalysisStatus;
237
+ /** 进度信息 */
238
+ progress: AnalysisProgress;
239
+ /** 错误信息 */
240
+ errorMessage: string;
241
+ /** 报告生成时间 */
242
+ reportGeneratedAt: string | null;
243
+ /** 创建时间 */
244
+ createdAt: string;
245
+ /** 更新时间 */
246
+ updatedAt: string;
247
+ }
248
+ /**
249
+ * 列表查询响应
250
+ */
251
+ interface ListVideoPsychAnalysesResponse {
252
+ /** 任务列表 */
253
+ list: VideoPsychAnalysisSummary[];
254
+ /** 总数 */
255
+ total: number;
256
+ /** 当前页码 */
257
+ page: number;
258
+ /** 每页数量 */
259
+ pageSize: number;
260
+ }
261
+ /**
262
+ * 更新分析任务参数
263
+ */
264
+ interface UpdateVideoPsychAnalysisParams {
265
+ /** 任务名称 */
266
+ name?: string;
267
+ /** 用户Prompt */
268
+ prompt?: string;
269
+ }
270
+ /**
271
+ * 更新分析任务响应
272
+ */
273
+ interface UpdateVideoPsychAnalysisResponse {
274
+ /** 分析任务ID */
275
+ id: string;
276
+ /** 任务名称 */
277
+ name: string;
278
+ /** 用户Prompt */
279
+ prompt: string;
280
+ /** 当前状态 */
281
+ status: VideoPsychAnalysisStatus;
282
+ /** 更新时间 */
283
+ updatedAt: string;
284
+ }
285
+
286
+ /**
287
+ * 视频人物心理分析模块
288
+ *
289
+ * @description
290
+ * 提供视频人物心理分析相关功能,包括:
291
+ * - 创建分析任务
292
+ * - 查询任务详情和状态
293
+ * - 同步任务状态(轮询)
294
+ * - 获取分析结果(文本/帧/段落维度)
295
+ * - 生成心理分析报告
296
+ *
297
+ * @example
298
+ * ```typescript
299
+ * import { PlolinkClient } from '@plolink/sdk';
300
+ * import { VideoPsychAnalysis } from '@plolink/sdk/video-psych-analysis';
301
+ *
302
+ * const client = new PlolinkClient({
303
+ * mode: 'apiKey',
304
+ * apiKey: 'your-api-key'
305
+ * });
306
+ *
307
+ * const videoPsych = new VideoPsychAnalysis(client);
308
+ *
309
+ * // 创建分析任务
310
+ * const result = await videoPsych.create({
311
+ * name: '候选人A面试分析',
312
+ * videoFileIds: ['file1', 'file2'],
313
+ * referenceImageFileId: 'refImage1',
314
+ * prompt: '请以专业心理分析师的视角进行分析',
315
+ * frameFps: 3,
316
+ * language: 'zh'
317
+ * });
318
+ * console.log(`任务已创建: ${result.id}`);
319
+ *
320
+ * // 轮询任务状态
321
+ * const poller = videoPsych.watchAnalysisStatus(result.id, (detail) => {
322
+ * console.log(`分析进度: ${detail.progress.done}/${detail.progress.total}`);
323
+ * if (detail.status === 'COMPLETED') {
324
+ * console.log('分析完成,报告已生成!');
325
+ * console.log(detail.reportContent);
326
+ * }
327
+ * });
328
+ * ```
329
+ *
330
+ * @module video-psych-analysis
331
+ */
332
+
333
+ /**
334
+ * 视频人物心理分析模块
335
+ */
336
+ declare class VideoPsychAnalysis {
337
+ private client;
338
+ constructor(client: PlolinkClient);
339
+ /**
340
+ * 查询分析任务列表
341
+ *
342
+ * @param params - 查询参数(可选)
343
+ * @returns 任务列表
344
+ * @throws {PlolinkError} 当查询失败时抛出
345
+ *
346
+ * @example
347
+ * ```typescript
348
+ * // 查询所有已完成的任务
349
+ * const result = await videoPsych.list({
350
+ * status: 'COMPLETED',
351
+ * page: 1,
352
+ * pageSize: 20
353
+ * });
354
+ * console.log(`共 ${result.total} 个任务`);
355
+ * result.list.forEach(item => {
356
+ * console.log(`${item.name}: ${item.status}`);
357
+ * });
358
+ * ```
359
+ */
360
+ list(params?: ListVideoPsychAnalysesParams): Promise<ListVideoPsychAnalysesResponse>;
361
+ /**
362
+ * 创建视频心理分析任务
363
+ *
364
+ * @param params - 创建参数
365
+ * @returns 创建结果,包含任务ID和初始状态
366
+ * @throws {PlolinkError} 当参数验证失败或创建失败时抛出
367
+ *
368
+ * @example
369
+ * ```typescript
370
+ * const result = await videoPsych.create({
371
+ * name: '候选人A面试分析',
372
+ * videoFileIds: ['file1', 'file2', 'file3'],
373
+ * referenceImageFileId: 'refImage1',
374
+ * prompt: '请以专业心理分析师的视角,分析候选人的情绪、态度和心理状态',
375
+ * frameFps: 3,
376
+ * language: 'zh'
377
+ * });
378
+ * console.log(`任务ID: ${result.id}, 状态: ${result.status}`);
379
+ * ```
380
+ */
381
+ create(params: CreateVideoPsychAnalysisParams): Promise<CreateVideoPsychAnalysisResponse>;
382
+ /**
383
+ * 获取分析任务详情
384
+ *
385
+ * @param id - 任务ID
386
+ * @returns 任务详情信息
387
+ * @throws {PlolinkError} 当任务不存在或无权访问时抛出
388
+ *
389
+ * @example
390
+ * ```typescript
391
+ * const detail = await videoPsych.getDetail('analysis_123');
392
+ * console.log(`任务: ${detail.name}`);
393
+ * console.log(`状态: ${detail.status}`);
394
+ * console.log(`进度: ${detail.progress.done}/${detail.progress.total}`);
395
+ *
396
+ * if (detail.reportContent) {
397
+ * console.log('报告已生成');
398
+ * }
399
+ * ```
400
+ */
401
+ getDetail(id: string): Promise<VideoPsychAnalysisDetail>;
402
+ /**
403
+ * 更新分析任务
404
+ *
405
+ * @description
406
+ * 更新分析任务的基本信息(仅限 PENDING 和 FAILED 状态的任务)。
407
+ *
408
+ * @param id - 任务ID
409
+ * @param params - 更新参数
410
+ * @returns 更新后的任务信息
411
+ * @throws {PlolinkError} 当任务不存在、状态不允许更新或更新失败时抛出
412
+ *
413
+ * @example
414
+ * ```typescript
415
+ * const updated = await videoPsych.update('analysis_123', {
416
+ * name: '李四的心理分析',
417
+ * prompt: '请以临床心理学专家的视角进行分析'
418
+ * });
419
+ * console.log(`已更新: ${updated.name}`);
420
+ * ```
421
+ */
422
+ update(id: string, params: UpdateVideoPsychAnalysisParams): Promise<UpdateVideoPsychAnalysisResponse>;
423
+ /**
424
+ * 删除分析任务
425
+ *
426
+ * @description
427
+ * 删除分析任务(软删除)。
428
+ *
429
+ * @param id - 任务ID
430
+ * @throws {PlolinkError} 当任务不存在或删除失败时抛出
431
+ *
432
+ * @example
433
+ * ```typescript
434
+ * await videoPsych.delete('analysis_123');
435
+ * console.log('任务已删除');
436
+ * ```
437
+ */
438
+ delete(id: string): Promise<{
439
+ message: string;
440
+ }>;
441
+ /**
442
+ * 同步任务状态
443
+ *
444
+ * @description
445
+ * 主动触发后端从 AI TOOLS API 同步最新状态和中间结果。
446
+ *
447
+ * **注意**:通常不需要手动调用此方法,系统会每30秒自动轮询同步所有非完成态的任务。
448
+ *
449
+ * @param id - 任务ID
450
+ * @returns 同步后的状态信息
451
+ * @throws {PlolinkError} 当任务不存在或同步失败时抛出
452
+ *
453
+ * @example
454
+ * ```typescript
455
+ * const status = await videoPsych.syncStatus('analysis_123');
456
+ * console.log(`当前状态: ${status.status}`);
457
+ * console.log(`进度: ${status.progress.done}/${status.progress.total}`);
458
+ * ```
459
+ */
460
+ syncStatus(id: string): Promise<SyncStatusResponse>;
461
+ /**
462
+ * 轮询分析任务状态
463
+ *
464
+ * @description
465
+ * 创建一个轮询器持续监听任务状态变化,直到任务达到终态(COMPLETED/FAILED)。
466
+ * 使用指数退避策略,初始间隔5秒,最大间隔30秒。
467
+ *
468
+ * @param id - 任务ID
469
+ * @param onStatusChange - 状态变化回调函数
470
+ * @returns Poller实例,可用于手动停止轮询
471
+ *
472
+ * @example
473
+ * ```typescript
474
+ * const poller = videoPsych.watchAnalysisStatus('analysis_123', (detail) => {
475
+ * console.log(`状态: ${detail.status}`);
476
+ * console.log(`进度: ${detail.progress.done}/${detail.progress.total} (${detail.progress.stage})`);
477
+ *
478
+ * if (detail.status === 'COMPLETED') {
479
+ * console.log('分析完成,报告已生成!');
480
+ * console.log(detail.reportContent);
481
+ * } else if (detail.status === 'FAILED') {
482
+ * console.error(`分析失败: ${detail.errorMessage}`);
483
+ * }
484
+ * });
485
+ *
486
+ * // 开始轮询
487
+ * poller.start();
488
+ *
489
+ * // 需要时可以手动停止
490
+ * // poller.stop();
491
+ * ```
492
+ */
493
+ watchAnalysisStatus(id: string, onStatusChange: (detail: VideoPsychAnalysisDetail) => void): Poller<VideoPsychAnalysisDetail>;
494
+ /**
495
+ * 获取文本维度分析结果
496
+ *
497
+ * @param id - 任务ID
498
+ * @returns 文本维度分析数据
499
+ * @throws {PlolinkError} 当任务不存在或分析未完成时抛出
500
+ *
501
+ * @example
502
+ * ```typescript
503
+ * const texts = await videoPsych.getTexts('analysis_123');
504
+ * console.log(`共 ${texts.total} 条文本`);
505
+ * texts.items.forEach(item => {
506
+ * console.log(`${item.start_time}s: ${item.text}`);
507
+ * if (item.nlp_result) {
508
+ * console.log(` 情绪: ${item.nlp_result.speaker_emotion}`);
509
+ * console.log(` 态度: ${item.nlp_result.real_attitude}`);
510
+ * }
511
+ * });
512
+ * ```
513
+ */
514
+ getTexts(id: string): Promise<TextsData>;
515
+ /**
516
+ * 获取帧维度分析结果
517
+ *
518
+ * @param id - 任务ID
519
+ * @returns 帧维度分析数据
520
+ * @throws {PlolinkError} 当任务不存在或分析未完成时抛出
521
+ *
522
+ * @example
523
+ * ```typescript
524
+ * const frames = await videoPsych.getFrames('analysis_123');
525
+ * console.log(`共 ${frames.total} 帧`);
526
+ * frames.items.forEach(item => {
527
+ * console.log(`${item.timestamp}s: ${item.image_url}`);
528
+ * if (item.vision_result) {
529
+ * console.log(` 表情: ${item.vision_result.expression}`);
530
+ * console.log(` 动作: ${item.vision_result.action}`);
531
+ * }
532
+ * });
533
+ * ```
534
+ */
535
+ getFrames(id: string): Promise<FramesData>;
536
+ /**
537
+ * 获取段落分析结果
538
+ *
539
+ * @param id - 任务ID
540
+ * @returns 段落分析数据
541
+ * @throws {PlolinkError} 当任务不存在或分析未完成时抛出
542
+ *
543
+ * @example
544
+ * ```typescript
545
+ * const paragraphs = await videoPsych.getParagraphs('analysis_123');
546
+ * console.log(`共 ${paragraphs.total} 段`);
547
+ * paragraphs.items.forEach(item => {
548
+ * console.log(`段落 ${item.id}:`);
549
+ * console.log(` 时间: ${item.start_time}s - ${item.end_time}s`);
550
+ * console.log(` 内容: ${item.text}`);
551
+ * console.log(` 摘要: ${item.summary}`);
552
+ * if (item.nlp_result) {
553
+ * console.log(` 情绪: ${item.nlp_result.speaker_emotion}`);
554
+ * console.log(` 态度: ${item.nlp_result.real_attitude}`);
555
+ * }
556
+ * });
557
+ * ```
558
+ */
559
+ getParagraphs(id: string): Promise<ParagraphsData>;
560
+ }
561
+
562
+ export { type AnalysisProgress, type CreateVideoPsychAnalysisParams, type CreateVideoPsychAnalysisResponse, type FrameAnalysisItem, type FramesData, type ListVideoPsychAnalysesParams, type ListVideoPsychAnalysesResponse, type ParagraphAnalysisItem, type ParagraphsData, type SyncStatusResponse, type TextAnalysisItem, type TextsData, type UpdateVideoPsychAnalysisParams, type UpdateVideoPsychAnalysisResponse, type VideoInfo, VideoPsychAnalysis, type VideoPsychAnalysisDetail, type VideoPsychAnalysisStatus, type VideoPsychAnalysisSummary };