cerevox 3.0.0-beta.24 → 3.0.0-beta.26

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.
@@ -513,7 +513,7 @@ server.registerTool('project-close', {
513
513
  .min(0)
514
514
  .max(20)
515
515
  .default(5)
516
- .describe('Close the session after the specified number of minutes. Default is 5 minutes. 如果用户要求立即关闭会话,请将该参数设置为0'),
516
+ .describe('Close the session after the specified number of minutes. Default is 5 minutes. 除非用户要求立即关闭会话,将该参数设置为0,否则应默认设为5'),
517
517
  },
518
518
  }, async ({ inMinutes }) => {
519
519
  try {
@@ -662,69 +662,6 @@ server.registerTool('retrieve-rules-context', {
662
662
  return createErrorResponse(`Failed to load rules context prompt for ${prompt}: ${error}`, 'retrieve-rules-context');
663
663
  }
664
664
  });
665
- // 列出项目下的所有文件
666
- server.registerTool('list-project-files', {
667
- title: 'List Project Files',
668
- description: 'List all files in the materials directory.',
669
- inputSchema: {},
670
- }, async () => {
671
- try {
672
- // 验证session状态
673
- const currentSession = await validateSession('list-project-files');
674
- console.log('Listing project files...');
675
- const terminal = currentSession.terminal;
676
- if (!terminal) {
677
- throw new Error('Terminal not available in current session');
678
- }
679
- let cwd;
680
- try {
681
- cwd = await terminal.getCwd();
682
- }
683
- catch (cwdError) {
684
- console.error('Failed to get current working directory:', cwdError);
685
- throw new Error('Failed to get current working directory');
686
- }
687
- console.log(`Current working directory: ${cwd}`);
688
- // 安全地列出各目录文件,失败时返回空数组
689
- const listFilesWithFallback = async (path, dirName) => {
690
- try {
691
- const files = await currentSession.files.listFiles(path);
692
- console.log(`Found ${files?.length || 0} files in ${dirName}`);
693
- return files || [];
694
- }
695
- catch (error) {
696
- console.warn(`Failed to list files in ${dirName} (${path}):`, error);
697
- return [];
698
- }
699
- };
700
- const [rootFiles, materialsFiles, outputFiles] = await Promise.all([
701
- listFilesWithFallback(cwd, 'root'),
702
- listFilesWithFallback(`${cwd}/materials`, 'materials'),
703
- listFilesWithFallback(`${cwd}/output`, 'output'),
704
- ]);
705
- const result = {
706
- success: true,
707
- cwd,
708
- root: rootFiles,
709
- materials: materialsFiles,
710
- output: outputFiles,
711
- totalFiles: rootFiles.length + materialsFiles.length + outputFiles.length,
712
- timestamp: new Date().toISOString(),
713
- };
714
- console.log(`Total files found: ${result.totalFiles}`);
715
- return {
716
- content: [
717
- {
718
- type: 'text',
719
- text: JSON.stringify(result),
720
- },
721
- ],
722
- };
723
- }
724
- catch (error) {
725
- return createErrorResponse(error, 'list-project-files');
726
- }
727
- });
728
665
  server.registerTool('generate-character-image', {
729
666
  title: 'Generate Character Image',
730
667
  description: 'Generate a turnaround image or portrait for any character.',
@@ -931,49 +868,6 @@ ${roleDescriptionPrompt}
931
868
  return createErrorResponse(error, 'generate-character-image');
932
869
  }
933
870
  });
934
- server.registerTool('generate-line-sketch', {
935
- title: 'Generate Line Sketch',
936
- description: 'Generate line sketch material based on user prompt.',
937
- inputSchema: {
938
- prompt: zod_1.z.string().describe('The prompt to generate line sketch.'),
939
- saveToFileName: zod_1.z
940
- .string()
941
- .describe('The filename to save the generated line sketch. 应该是png文件'),
942
- },
943
- }, async ({ prompt, saveToFileName }) => {
944
- try {
945
- // 验证session状态
946
- await validateSession('generate-line-sketch');
947
- // 验证文件名
948
- validateFileName(saveToFileName);
949
- // 调用AI生成线稿
950
- const res = await session.ai.generateLineSketch({ prompt });
951
- if (res && res.url) {
952
- // 保存到本地
953
- await saveMaterial(session, res.url, saveToFileName);
954
- const result = {
955
- success: true,
956
- url: res.url,
957
- localPath: getMaterialUri(session, saveToFileName),
958
- timestamp: new Date().toISOString(),
959
- };
960
- return {
961
- content: [
962
- {
963
- type: 'text',
964
- text: JSON.stringify(result),
965
- },
966
- ],
967
- };
968
- }
969
- else {
970
- throw new Error('No URL returned from AI service');
971
- }
972
- }
973
- catch (error) {
974
- return createErrorResponse(error, 'generate-line-sketch');
975
- }
976
- });
977
871
  server.registerTool('upload-custom-material', {
978
872
  title: 'Upload Custom Material',
979
873
  description: 'Upload material files (images: jpeg/png, videos: mp4, audio: mp3) from the local filesystem to the materials directory. For video and audio files, duration information will be included in the response.',
@@ -1065,12 +959,18 @@ server.registerTool('generate-image', {
1065
959
  description: `生成图片`,
1066
960
  inputSchema: {
1067
961
  type: zod_1.z
1068
- .enum(['banana', 'banana-pro', 'seedream', 'seedream-pro'])
962
+ .enum([
963
+ 'banana',
964
+ 'banana-pro',
965
+ 'seedream',
966
+ 'seedream-pro',
967
+ 'line-sketch',
968
+ ])
1069
969
  .optional()
1070
970
  .default('seedream'),
1071
971
  prompt: zod_1.z
1072
972
  .string()
1073
- .describe('The prompt to generate. 一般要严格对应 storyboard 中当前场景的 start_frame 或 end_frame 中的字段描述'),
973
+ .describe('The prompt to generate. 一般要严格对应 storyboard 中当前场景的 start_frame 或 end_frame 中的字段描述,如果是生成线稿,则 type 使用 line-sketch'),
1074
974
  sceneIndex: zod_1.z
1075
975
  .number()
1076
976
  .min(1)
@@ -2108,7 +2008,7 @@ server.registerTool('generate-video', {
2108
2008
  }
2109
2009
  });
2110
2010
  server.registerTool('wait-for-task-finish', {
2111
- title: 'Wait Workflow or VideoTask Done',
2011
+ title: 'Wait Workflow or VideoTask Done;只有正在运行Coze工作流或者有异步生成视频任务时才需要执行这个工具',
2112
2012
  description: 'Wait for a workflow to complete.',
2113
2013
  inputSchema: {
2114
2014
  taskUrl: zod_1.z
@@ -3268,206 +3168,6 @@ server.registerTool('media-analyzer', {
3268
3168
  return createErrorResponse(error, 'media-analyzer');
3269
3169
  }
3270
3170
  });
3271
- // server.registerTool(
3272
- // 'image-aligner',
3273
- // {
3274
- // title: 'Image Aligner',
3275
- // description:
3276
- // 'Analyze image quality and alignment with prompt using AI Image Quality Inspector.',
3277
- // inputSchema: {
3278
- // imageFileName: z
3279
- // .string()
3280
- // .describe('The image file name in materials directory to analyze.'),
3281
- // sceneIndex: z.number().min(1).describe('场景索引,从1开始的下标'),
3282
- // storyBoardFile: z
3283
- // .string()
3284
- // .optional()
3285
- // .default('storyboard.json')
3286
- // .describe('故事板文件路径'),
3287
- // imagePrompt: z
3288
- // .string()
3289
- // .optional()
3290
- // .describe('可选的图片提示词,如果提供则覆盖storyboard中的提示词'),
3291
- // customPrompt: z
3292
- // .string()
3293
- // .optional()
3294
- // .describe('可选的额外用户要求,用于补充图片质量评估的特定需求'),
3295
- // },
3296
- // },
3297
- // async ({
3298
- // imageFileName,
3299
- // sceneIndex,
3300
- // storyBoardFile = 'storyboard.json',
3301
- // imagePrompt,
3302
- // customPrompt,
3303
- // }) => {
3304
- // try {
3305
- // const currentSession = await validateSession('image-aligner');
3306
- // // 验证图片文件
3307
- // validateImageFile(imageFileName);
3308
- // // 获取图片 URL
3309
- // const imageUrl = getMaterialUri(currentSession, imageFileName);
3310
- // // 确定要使用的提示词
3311
- // let finalPrompt = imagePrompt;
3312
- // // 如果没有提供imagePrompt,则从storyboard中获取
3313
- // if (!imagePrompt) {
3314
- // try {
3315
- // const storyBoardPath = resolve(
3316
- // process.env.ZEROCUT_PROJECT_CWD || process.cwd(),
3317
- // projectLocalDir,
3318
- // storyBoardFile
3319
- // );
3320
- // if (existsSync(storyBoardPath)) {
3321
- // const storyBoardContent = await readFile(storyBoardPath, 'utf8');
3322
- // const storyBoard = JSON.parse(storyBoardContent);
3323
- // if (storyBoard.scenes && Array.isArray(storyBoard.scenes)) {
3324
- // const scene = storyBoard.scenes[sceneIndex - 1]; // sceneIndex 从1开始,数组从0开始
3325
- // if (scene) {
3326
- // // 根据文件名判断优先级:若end_frame存在且imageFileName包含"_end"则优先取end_frame,否则取start_frame
3327
- // if (scene.end_frame && imageFileName.includes('_end')) {
3328
- // finalPrompt = scene.end_frame;
3329
- // } else {
3330
- // finalPrompt = scene.start_frame || scene.end_frame;
3331
- // }
3332
- // if (!finalPrompt) {
3333
- // return createErrorResponse(
3334
- // `场景 ${sceneIndex} 中未找到 start_frame 或 end_frame 提示词`,
3335
- // 'image-aligner'
3336
- // );
3337
- // }
3338
- // } else {
3339
- // return createErrorResponse(
3340
- // `在 ${storyBoardFile} 中未找到场景索引 ${sceneIndex}`,
3341
- // 'image-aligner'
3342
- // );
3343
- // }
3344
- // } else {
3345
- // return createErrorResponse(
3346
- // `${storyBoardFile} 文件格式不正确,缺少 scenes 数组`,
3347
- // 'image-aligner'
3348
- // );
3349
- // }
3350
- // } else {
3351
- // return createErrorResponse(
3352
- // `故事板文件不存在: ${storyBoardPath}`,
3353
- // 'image-aligner'
3354
- // );
3355
- // }
3356
- // } catch (error) {
3357
- // return createErrorResponse(
3358
- // `读取或解析故事板文件失败: ${error}`,
3359
- // 'image-aligner'
3360
- // );
3361
- // }
3362
- // }
3363
- // // 如果仍然没有提示词,返回错误
3364
- // if (!finalPrompt) {
3365
- // return createErrorResponse(
3366
- // '未提供 imagePrompt 且无法从故事板中获取提示词',
3367
- // 'image-aligner'
3368
- // );
3369
- // }
3370
- // // 读取图片质量检查指南
3371
- // const alignerGuidelinePath = resolve(
3372
- // __dirname,
3373
- // './prompts/reasonings/image_aligner.md'
3374
- // );
3375
- // let alignerGuideline = '';
3376
- // try {
3377
- // alignerGuideline = await readFile(alignerGuidelinePath, 'utf8');
3378
- // } catch (error) {
3379
- // console.warn('无法读取图片质量检查指南:', error);
3380
- // alignerGuideline =
3381
- // '请对图片质量进行评估,包括构图、色彩、清晰度等方面。';
3382
- // }
3383
- // // 构建系统提示
3384
- // const systemPrompt = `你是一个专业的AI图片质量检查员。请根据以下指南对图片进行评估:
3385
- // ${alignerGuideline}
3386
- // 请严格按照指南中的JSON格式返回评估结果。`;
3387
- // // 构建用户提示
3388
- // const userPrompt = `请对这张图片进行质量评估。
3389
- // 原始提示词:${finalPrompt}${
3390
- // customPrompt
3391
- // ? `
3392
- // 额外要求:${customPrompt}`
3393
- // : ''
3394
- // }
3395
- // 请按照指南要求,返回包含评分、问题列表和优化建议的JSON格式结果。`;
3396
- // // 调用AI模型进行图片质量评估
3397
- // const ai = currentSession.ai;
3398
- // const completion = await ai.getCompletions({
3399
- // model: 'Doubao-Seed-1.6',
3400
- // messages: [
3401
- // {
3402
- // role: 'system',
3403
- // content: systemPrompt,
3404
- // },
3405
- // {
3406
- // role: 'user',
3407
- // content: [
3408
- // {
3409
- // type: 'image_url',
3410
- // image_url: {
3411
- // url: imageUrl,
3412
- // },
3413
- // },
3414
- // {
3415
- // type: 'text',
3416
- // text: userPrompt,
3417
- // },
3418
- // ],
3419
- // },
3420
- // ],
3421
- // });
3422
- // const result = completion.choices[0]?.message?.content;
3423
- // if (!result) {
3424
- // throw new Error('No response from AI model');
3425
- // }
3426
- // // 解析AI响应
3427
- // let alignmentResult;
3428
- // try {
3429
- // // 尝试从响应中提取JSON
3430
- // const jsonMatch =
3431
- // result.match(/```json\s*([\s\S]*?)\s*```/) ||
3432
- // result.match(/\{[\s\S]*\}/);
3433
- // if (jsonMatch) {
3434
- // alignmentResult = JSON.parse(jsonMatch[1] || jsonMatch[0]);
3435
- // } else {
3436
- // // 如果没有找到JSON格式,尝试直接解析整个响应
3437
- // alignmentResult = JSON.parse(result);
3438
- // }
3439
- // } catch (error) {
3440
- // // 如果解析失败,返回原始响应
3441
- // alignmentResult = {
3442
- // error: 'JSON解析失败',
3443
- // raw_response: result,
3444
- // };
3445
- // }
3446
- // return {
3447
- // content: [
3448
- // {
3449
- // type: 'text',
3450
- // text: JSON.stringify({
3451
- // success: true,
3452
- // imageFileName,
3453
- // sceneIndex,
3454
- // storyBoardFile,
3455
- // imagePrompt: finalPrompt,
3456
- // customPrompt,
3457
- // promptSource: imagePrompt ? 'manual_override' : 'storyboard',
3458
- // analysis: alignmentResult,
3459
- // imageUrl,
3460
- // nextActionSuggest:
3461
- // '可根据分析结果调整提示词,修改storyboard后,重新生成图片。',
3462
- // }),
3463
- // },
3464
- // ],
3465
- // };
3466
- // } catch (error) {
3467
- // return createErrorResponse(error, 'image-aligner');
3468
- // }
3469
- // }
3470
- // );
3471
3171
  server.registerTool('audio-video-sync', {
3472
3172
  title: 'Audio Video Sync',
3473
3173
  description: 'Generate audio-video-synced video by matching video with audio. 还可以对口型。',
@@ -4399,6 +4099,69 @@ server.registerTool('search-context', {
4399
4099
  return createErrorResponse(error, 'search-context');
4400
4100
  }
4401
4101
  });
4102
+ // 列出项目下的所有文件
4103
+ server.registerTool('list-project-files', {
4104
+ title: 'List Project Files',
4105
+ description: 'List all files in the materials directory.',
4106
+ inputSchema: {},
4107
+ }, async () => {
4108
+ try {
4109
+ // 验证session状态
4110
+ const currentSession = await validateSession('list-project-files');
4111
+ console.log('Listing project files...');
4112
+ const terminal = currentSession.terminal;
4113
+ if (!terminal) {
4114
+ throw new Error('Terminal not available in current session');
4115
+ }
4116
+ let cwd;
4117
+ try {
4118
+ cwd = await terminal.getCwd();
4119
+ }
4120
+ catch (cwdError) {
4121
+ console.error('Failed to get current working directory:', cwdError);
4122
+ throw new Error('Failed to get current working directory');
4123
+ }
4124
+ console.log(`Current working directory: ${cwd}`);
4125
+ // 安全地列出各目录文件,失败时返回空数组
4126
+ const listFilesWithFallback = async (path, dirName) => {
4127
+ try {
4128
+ const files = await currentSession.files.listFiles(path);
4129
+ console.log(`Found ${files?.length || 0} files in ${dirName}`);
4130
+ return files || [];
4131
+ }
4132
+ catch (error) {
4133
+ console.warn(`Failed to list files in ${dirName} (${path}):`, error);
4134
+ return [];
4135
+ }
4136
+ };
4137
+ const [rootFiles, materialsFiles, outputFiles] = await Promise.all([
4138
+ listFilesWithFallback(cwd, 'root'),
4139
+ listFilesWithFallback(`${cwd}/materials`, 'materials'),
4140
+ listFilesWithFallback(`${cwd}/output`, 'output'),
4141
+ ]);
4142
+ const result = {
4143
+ success: true,
4144
+ cwd,
4145
+ root: rootFiles,
4146
+ materials: materialsFiles,
4147
+ output: outputFiles,
4148
+ totalFiles: rootFiles.length + materialsFiles.length + outputFiles.length,
4149
+ timestamp: new Date().toISOString(),
4150
+ };
4151
+ console.log(`Total files found: ${result.totalFiles}`);
4152
+ return {
4153
+ content: [
4154
+ {
4155
+ type: 'text',
4156
+ text: JSON.stringify(result),
4157
+ },
4158
+ ],
4159
+ };
4160
+ }
4161
+ catch (error) {
4162
+ return createErrorResponse(error, 'list-project-files');
4163
+ }
4164
+ });
4402
4165
  server.registerTool('build-capcat-draft', {
4403
4166
  title: 'Build CapCut Draft',
4404
4167
  description: 'Read draft_content.json file, parse JSON and generate URIs for all assets in timeline tracks, then output the processed JSON string.',