ppagent 0.0.6 → 0.0.8

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.
Files changed (3) hide show
  1. package/dist/lib.d.ts +445 -57
  2. package/dist/lib.js +25 -19
  3. package/package.json +121 -115
package/dist/lib.d.ts CHANGED
@@ -11,6 +11,7 @@ import pino, { Level } from 'pino';
11
11
  import Keyv from 'keyv';
12
12
  import { StreamChatReq, CozeAPI, CreateChatData, StreamChatData } from '@coze/api';
13
13
  import OpenAI, { ClientOptions } from 'openai';
14
+ import ffmpeg from 'fluent-ffmpeg';
14
15
  import { ReadStream as ReadStream$1 } from 'fs';
15
16
 
16
17
  interface IAsyncFile {
@@ -66,7 +67,7 @@ declare class AsyncFile implements IAsyncFile {
66
67
  protected setSource({ data, type, name, textEncoding }: IAsyncFileSource): Promise<void>;
67
68
  protected loadBufferFromPath(localPath: string): Promise<Buffer$1>;
68
69
  protected saveFile(): Promise<string>;
69
- getFormat(): "text" | "binary";
70
+ getFormat(): "binary" | "text";
70
71
  asBuffer(): Promise<Buffer$1 | undefined>;
71
72
  asPath(): Promise<string>;
72
73
  asBase64(): Promise<string>;
@@ -1407,7 +1408,7 @@ declare class GlobalEvent extends Emittery<{
1407
1408
  registerGlobalEventNames(name: string): void;
1408
1409
  }
1409
1410
 
1410
- interface IChatMeOptions {
1411
+ interface IPPAgentOptions {
1411
1412
  /**
1412
1413
  * agent服务的构建参数
1413
1414
  */
@@ -1435,7 +1436,7 @@ declare class PPAgent extends Emittery {
1435
1436
  static EventNames: {
1436
1437
  ERROR: string;
1437
1438
  };
1438
- constructor(_options?: IChatMeOptions);
1439
+ constructor(_options?: IPPAgentOptions);
1439
1440
  private _server;
1440
1441
  private _pluginHandlers;
1441
1442
  private _wsRoutes;
@@ -1459,6 +1460,7 @@ declare class PPAgent extends Emittery {
1459
1460
  private _globalEvent;
1460
1461
  private _logger;
1461
1462
  private _onlinePluginInfos;
1463
+ private _services;
1462
1464
  get server(): FastifyInstance<fastify.RawServerDefault, http.IncomingMessage, http.ServerResponse<http.IncomingMessage>, fastify.FastifyBaseLogger, fastify.FastifyTypeProviderDefault>;
1463
1465
  get skillManager(): SkillManager;
1464
1466
  get sourceManager(): SourceManager;
@@ -1470,7 +1472,7 @@ declare class PPAgent extends Emittery {
1470
1472
  get sharedCover(): IAsyncFile;
1471
1473
  get sharedLogo(): IAsyncFile;
1472
1474
  get client(): AuthenticationClient<any> & RestClient<any>;
1473
- get options(): IChatMeOptions;
1475
+ get options(): IPPAgentOptions;
1474
1476
  get taskService(): TaskService;
1475
1477
  get globalEvent(): GlobalEvent;
1476
1478
  get plugins(): IPPAgentPluginHandler[];
@@ -1585,6 +1587,7 @@ declare class PPAgent extends Emittery {
1585
1587
  };
1586
1588
  get onlinePlugins(): IterableIterator<IOnlinePluginInfo>;
1587
1589
  get running(): boolean;
1590
+ get services(): Map<string, any>;
1588
1591
  private _createServer;
1589
1592
  private _initServer;
1590
1593
  private _checkRegister;
@@ -1722,6 +1725,10 @@ interface IAgentOptions {
1722
1725
  * 是否发送消息处理异常的日志到客户端,默认false
1723
1726
  */
1724
1727
  sendErrorLog?: boolean;
1728
+ /**
1729
+ * 正在执行中的问答,执行的超时时间,默认60秒。超过的任务将不再等待,继续执行一个提问(不会被取消回调,有返回后仍然会发送)。
1730
+ */
1731
+ timeoutInSeconds?: number;
1725
1732
  }
1726
1733
  /**
1727
1734
  * 一个智能体,用于连接source和bot。
@@ -2269,40 +2276,32 @@ declare class ZhipuQingyanBot extends BasicBot {
2269
2276
  init(): Promise<void>;
2270
2277
  }
2271
2278
 
2272
- type ImageSize = "1024x1024" | "768x1344" | "864x1152" | "1344x768" | "1152x864" | "1440x720" | "720x1440";
2273
- interface ICogViewDrawOptions {
2274
- apiBase?: string;
2275
- apiKey: string;
2276
- defaultModel: string;
2279
+ declare class SiliconFlowBot extends OpenAIBot {
2280
+ static params: IBotParams;
2281
+ constructor(options: IOpenAIBotOptions);
2282
+ }
2283
+
2284
+ interface IXunfeiBotOptions extends IOpenAIBotOptions {
2277
2285
  /**
2278
- * 自定义的模型,优先级高于默认模型,用于官方推出新模型后的自定义适配
2286
+ * 优先级高于chatOptions中的模型名称
2279
2287
  */
2280
- customModel?: string;
2281
- defaultPrompt: string;
2282
- defaultSize: ImageSize;
2283
- user_id?: string;
2288
+ modelName?: string;
2289
+ }
2290
+ declare class XunfeiBot extends OpenAIBot {
2291
+ static params: IBotParams;
2292
+ constructor(options: IXunfeiBotOptions);
2284
2293
  }
2285
- interface ICogViewSkillOptions extends ISkillOptions {
2286
- drawOptions: ICogViewDrawOptions;
2294
+
2295
+ interface IZhipuBotOptions extends IOpenAIBotOptions {
2287
2296
  /**
2288
- * 绘图触发词,默认画图,画画,画图
2297
+ * 优先级高于chatOptions中的模型名称
2289
2298
  */
2290
- triggerWords?: string;
2291
- replyFormat?: "TEXT" | "IMAGE";
2299
+ modelName?: string;
2292
2300
  }
2293
- declare class CogViewSkill implements ISkill {
2294
- private _app;
2295
- private _options;
2296
- static params: IConfigParams;
2297
- constructor(_app: PPAgent, _options: ICogViewSkillOptions);
2298
- private _logger;
2299
- private _drawer;
2300
- get options(): ISkillOptions;
2301
- get params(): IConfigParams;
2302
- init(): Promise<void>;
2303
- applyOnSource(data: IAgentChatEventData): Promise<void>;
2301
+ declare class ZhipuBot extends OpenAIBot {
2302
+ static params: IBotParams;
2303
+ constructor(options: IZhipuBotOptions);
2304
2304
  }
2305
- declare const cogViewPlugin: IPPAgentPlugin;
2306
2305
 
2307
2306
  interface IPPAgentPluginOptions {
2308
2307
  /**
@@ -2326,7 +2325,34 @@ declare const apiPlugin: IPPAgentPlugin;
2326
2325
 
2327
2326
  declare const defaultPlugin: IPPAgentPlugin;
2328
2327
 
2329
- interface ISenseVoiceSTTSkillOptions extends ISkillOptions {
2328
+ interface IBaseSTTSkillOptions extends ISkillOptions {
2329
+ /**
2330
+ * 是否确保音频格式为百度支持的wav格式。默认true,如果已经对接的渠道确保了是16k或者8k单声道音频,则无需检查。
2331
+ */
2332
+ ensureAudioFormat?: boolean;
2333
+ }
2334
+ /**
2335
+ * 对https://github.com/HG-ha/SenseVoice-Api的技能封装
2336
+ */
2337
+ declare abstract class BaseSTTSkill implements ISkill {
2338
+ protected _options: IBaseSTTSkillOptions;
2339
+ static params: ISkillParams;
2340
+ constructor(_options: IBaseSTTSkillOptions);
2341
+ protected _logger: ILogger;
2342
+ protected _targetFormat: string;
2343
+ get options(): IBaseSTTSkillOptions;
2344
+ get params(): ISkillParams;
2345
+ init(): Promise<void>;
2346
+ protected abstract _getText(file: IAsyncFile): Promise<string>;
2347
+ protected _transpileContent(originContent: SourceChatContent): Promise<void>;
2348
+ applyOnSource(data: IAgentChatEventData): Promise<void>;
2349
+ applyOnReply(content: SourceChatContent, messageType: SourceChatMessageType): Promise<{
2350
+ content: SourceChatContent;
2351
+ messageType: SourceChatMessageType;
2352
+ }>;
2353
+ }
2354
+
2355
+ interface ISenseVoiceSTTSkillOptions extends IBaseSTTSkillOptions {
2330
2356
  /**
2331
2357
  * 如xxx.com,无需带extract_text
2332
2358
  */
@@ -2343,26 +2369,45 @@ interface ISenseVoiceSTTSkillOptions extends ISkillOptions {
2343
2369
  /**
2344
2370
  * basic认证的时候需要提供
2345
2371
  */
2346
- passwrod?: string;
2372
+ password?: string;
2347
2373
  }
2348
2374
  /**
2349
2375
  * 对https://github.com/HG-ha/SenseVoice-Api的技能封装
2350
2376
  */
2351
- declare class SenseVoiceSTTSkill implements ISkill {
2352
- private _options;
2377
+ declare class SenseVoiceSTTSkill extends BaseSTTSkill {
2378
+ protected _options: ISenseVoiceSTTSkillOptions;
2353
2379
  static params: ISkillParams;
2354
2380
  constructor(_options: ISenseVoiceSTTSkillOptions);
2355
2381
  private _headers;
2356
2382
  get options(): ISenseVoiceSTTSkillOptions;
2357
2383
  get params(): ISkillParams;
2384
+ protected _getText(file: IAsyncFile): Promise<string>;
2385
+ }
2386
+
2387
+ interface IBaseTTSSkillOptions extends ISkillOptions {
2388
+ /**
2389
+ * 用语音的概率。默认0.5,即一半。
2390
+ */
2391
+ probability?: number;
2392
+ /**
2393
+ * 当判别使用语音时,如果此值为true,会移除语音可能无法阅读的内容。默认false,即遇到无法阅读的,取消语音转换
2394
+ */
2395
+ deleteUnreadableText?: boolean;
2396
+ }
2397
+ declare abstract class BaseTTSSkill implements ISkill {
2398
+ protected _options: IBaseTTSSkillOptions;
2399
+ static params: ISkillParams;
2400
+ constructor(_options: IBaseTTSSkillOptions);
2401
+ protected _logger: ILogger;
2402
+ protected abstract get _maxToken(): number;
2403
+ get options(): IBaseTTSSkillOptions;
2404
+ get params(): ISkillParams;
2358
2405
  init(): Promise<void>;
2359
- private _transpile;
2360
- private _transpileContent;
2361
- applyOnSource(data: IAgentChatEventData): Promise<void>;
2362
- applyOnReply(content: SourceChatContent, messageType: SourceChatMessageType): Promise<{
2406
+ applyOnReply(content: SourceChatContent, messageType: SourceChatMessageType, sourceData: IAgentChatEventData, allContent?: string): Promise<{
2363
2407
  content: SourceChatContent;
2364
2408
  messageType: SourceChatMessageType;
2365
2409
  }>;
2410
+ protected abstract getAudioBuffer(text: string, sourceData: IAgentChatEventData): Promise<Buffer>;
2366
2411
  }
2367
2412
 
2368
2413
  interface ISoviteRequestOptions {
@@ -2377,7 +2422,7 @@ interface ISoviteRequestOptions {
2377
2422
  speed?: number;
2378
2423
  inp_refs?: string[];
2379
2424
  }
2380
- interface ISoviteTTSSkillOptions extends ISkillOptions {
2425
+ interface ISoviteTTSSkillOptions extends IBaseTTSSkillOptions {
2381
2426
  apiHost: string;
2382
2427
  authType?: "basic" | "jwt" | "none";
2383
2428
  /**
@@ -2391,7 +2436,7 @@ interface ISoviteTTSSkillOptions extends ISkillOptions {
2391
2436
  /**
2392
2437
  * basic认证的时候需要提供
2393
2438
  */
2394
- passwrod?: string;
2439
+ password?: string;
2395
2440
  /**
2396
2441
  * 是否是流式返回,目前不支持流式,请保持为空或者false
2397
2442
  */
@@ -2400,27 +2445,361 @@ interface ISoviteTTSSkillOptions extends ISkillOptions {
2400
2445
  * 调用接口时额外的参数
2401
2446
  */
2402
2447
  customReqOptions?: Omit<ISoviteRequestOptions, "text">;
2448
+ }
2449
+ declare class SoviteTTSSkill extends BaseTTSSkill {
2450
+ protected _options: ISoviteTTSSkillOptions;
2451
+ static params: ISkillParams;
2452
+ constructor(_options: ISoviteTTSSkillOptions);
2453
+ private _headers;
2454
+ protected get _maxToken(): number;
2455
+ get options(): ISoviteTTSSkillOptions;
2456
+ get params(): ISkillParams;
2457
+ init(): Promise<void>;
2458
+ getAudioBuffer(text: string): Promise<Buffer>;
2459
+ }
2460
+
2461
+ interface IBaiduSTTSkillOptions extends IBaseSTTSkillOptions {
2462
+ appId: string;
2463
+ apiKey: string;
2464
+ secretKey: string;
2465
+ }
2466
+ declare class BaiduSTTSkill extends BaseSTTSkill {
2467
+ protected _app: PPAgent;
2468
+ protected _options: IBaiduSTTSkillOptions;
2469
+ static params: ISkillParams;
2470
+ constructor(_app: PPAgent, _options: IBaiduSTTSkillOptions);
2471
+ private _client;
2472
+ get options(): IBaiduSTTSkillOptions;
2473
+ get params(): ISkillParams;
2474
+ protected _getText(file: IAsyncFile): Promise<string>;
2475
+ }
2476
+
2477
+ interface IBaiduTTSSkillOptions extends IBaseTTSSkillOptions {
2478
+ appId: string;
2479
+ apiKey: string;
2480
+ secretKey: string;
2403
2481
  /**
2404
- * 用语音的概率。默认0.5,即一半。
2482
+ * 语速,0-5
2483
+ */
2484
+ spd: number;
2485
+ /**
2486
+ * 音量大小,精品库0-15,其他0-9
2487
+ */
2488
+ vol: number;
2489
+ /**
2490
+ * 度小宇=1,度小美=0,度逍遥(基础)=3,度丫丫=4
2491
+ * 精品发音人选择:度逍遥(精品)=5003,度小鹿=5118,度博文=106,度小童=110,度小萌=111,度米朵=103,度小娇=5
2492
+ * 臻品度逍遥(臻品)=4003,度博文=4106,度小贤=4115,度小鹿=4119,度灵儿=4105,度小乔=4117,度小雯=4100,度米朵=4103,度姗姗=4144,度小贝=4278,度清风=4143,度小新=4140,度小彦=4129,度星河=4149,度小清=4254,度博文=4206,南方=4226
2493
+ */
2494
+ per: number;
2495
+ /**
2496
+ * 音调,取值0-9,默认为5中语调
2497
+ */
2498
+ pit: number;
2499
+ /**
2500
+ * 3为mp3格式(默认); 4为pcm-16k;5为pcm-8k;6为wav(内容同pcm-16k); 注意aue=4或者6是语音识别要求的格式,但是音频内容不是语音识别要求的自然人发音,所以识别效果会受影响。
2501
+ */
2502
+ aue: number;
2503
+ }
2504
+ declare class BaiduTTSSkill extends BaseTTSSkill {
2505
+ private _app;
2506
+ protected _options: IBaiduTTSSkillOptions;
2507
+ static params: ISkillParams;
2508
+ constructor(_app: PPAgent, _options: IBaiduTTSSkillOptions);
2509
+ private _client;
2510
+ protected get _maxToken(): number;
2511
+ get options(): IBaiduTTSSkillOptions;
2512
+ get params(): ISkillParams;
2513
+ protected getAudioBuffer(text: string, sourceData: IAgentChatEventData): Promise<Buffer>;
2514
+ }
2515
+
2516
+ interface IBaseDrawSkillOptions extends ISkillOptions {
2517
+ /**
2518
+ * 绘图触发词,默认画图,画画,画图
2519
+ */
2520
+ triggerWords?: string;
2521
+ replyFormat?: "TEXT" | "IMAGE" | "URL" | "VIDEO" | "FILE";
2522
+ apiBase: string;
2523
+ apiKey: string;
2524
+ model: string;
2525
+ size: string;
2526
+ /**
2527
+ * 优化器的bot的instanceName
2528
+ */
2529
+ optimizer?: string;
2530
+ /**
2531
+ * 是否使用大模型优化。
2532
+ */
2533
+ useLLM?: boolean;
2534
+ }
2535
+ interface IDrawResult {
2536
+ url: string;
2537
+ text?: string;
2538
+ coverUrl?: string;
2539
+ }
2540
+ declare abstract class BaseDrawSkill implements ISkill {
2541
+ protected _app: PPAgent;
2542
+ protected _options: IBaseDrawSkillOptions;
2543
+ static params: ISkillParams;
2544
+ constructor(_app: PPAgent, _options: IBaseDrawSkillOptions);
2545
+ protected _logger: ILogger;
2546
+ get options(): ISkillOptions;
2547
+ get params(): IConfigParams;
2548
+ init(): Promise<void>;
2549
+ protected abstract _draw(text: string, userId: string, data: IAgentChatEventData): Promise<IDrawResult>;
2550
+ applyOnSource(data: IAgentChatEventData): Promise<void>;
2551
+ }
2552
+
2553
+ interface ICogVideoDrawSkillOptions extends IBaseDrawSkillOptions {
2554
+ /**
2555
+ * 视频生成超时时间,避免永久循环查询结果,默认180秒
2556
+ */
2557
+ timeout?: number;
2558
+ /**
2559
+ * 是否生成音频,默认false
2560
+ */
2561
+ withAudio?: boolean;
2562
+ }
2563
+ declare class CogVideoDrawSkill extends BaseDrawSkill {
2564
+ protected _app: PPAgent;
2565
+ protected _options: ICogVideoDrawSkillOptions;
2566
+ static params: ISkillParams;
2567
+ constructor(_app: PPAgent, _options: ICogVideoDrawSkillOptions);
2568
+ protected _draw(prompt: string, userId: string): Promise<IDrawResult>;
2569
+ }
2570
+
2571
+ interface ICogviewDrawSkillOptions extends IBaseDrawSkillOptions {
2572
+ }
2573
+ declare class CogviewDrawSkill extends BaseDrawSkill {
2574
+ protected _app: PPAgent;
2575
+ protected _options: ICogviewDrawSkillOptions;
2576
+ static params: ISkillParams;
2577
+ constructor(_app: PPAgent, _options: ICogviewDrawSkillOptions);
2578
+ protected _draw(prompt: string, userId: string): Promise<IDrawResult>;
2579
+ }
2580
+
2581
+ interface IFishAudioTTSSkillOptions extends IBaseTTSSkillOptions {
2582
+ apiKey: string;
2583
+ baseUrl?: string;
2584
+ referenceId: string;
2585
+ }
2586
+ declare class FishAudioTTSSkill extends BaseTTSSkill {
2587
+ protected _app: PPAgent;
2588
+ protected _options: IFishAudioTTSSkillOptions;
2589
+ static params: ISkillParams;
2590
+ constructor(_app: PPAgent, _options: IFishAudioTTSSkillOptions);
2591
+ protected get _maxToken(): number;
2592
+ get options(): IFishAudioTTSSkillOptions;
2593
+ get params(): ISkillParams;
2594
+ protected getAudioBuffer(text: string): Promise<Buffer>;
2595
+ }
2596
+
2597
+ interface IOpenAIDrawSkillOptions extends IBaseDrawSkillOptions {
2598
+ quality: "standard" | "hd";
2599
+ }
2600
+ declare class OpenAIDrawSkill extends BaseDrawSkill {
2601
+ protected _app: PPAgent;
2602
+ protected _options: IOpenAIDrawSkillOptions;
2603
+ static params: ISkillParams;
2604
+ constructor(_app: PPAgent, _options: IOpenAIDrawSkillOptions);
2605
+ protected _draw(prompt: string, userId: string): Promise<IDrawResult>;
2606
+ }
2607
+
2608
+ interface IOpenAISTTSkillOptions extends IBaseSTTSkillOptions {
2609
+ apiKey: string;
2610
+ baseUrl?: string;
2611
+ model: string;
2612
+ }
2613
+ declare class OpenAISTTSkill extends BaseSTTSkill {
2614
+ protected _app: PPAgent;
2615
+ protected _options: IOpenAISTTSkillOptions;
2616
+ static params: ISkillParams;
2617
+ constructor(_app: PPAgent, _options: IOpenAISTTSkillOptions);
2618
+ protected _client: OpenAI;
2619
+ init(): Promise<void>;
2620
+ get options(): IOpenAISTTSkillOptions;
2621
+ get params(): ISkillParams;
2622
+ protected _getText(file: IAsyncFile): Promise<string>;
2623
+ }
2624
+
2625
+ interface IOpenAITTSSkillOptions extends IBaseTTSSkillOptions {
2626
+ apiKey: string;
2627
+ baseUrl?: string;
2628
+ model: string;
2629
+ voice: string;
2630
+ /**
2631
+ * 语速 0.25-4,默认1
2632
+ */
2633
+ speed?: number;
2634
+ }
2635
+ declare class OpenAITTSSkill extends BaseTTSSkill {
2636
+ protected _app: PPAgent;
2637
+ protected _options: IOpenAITTSSkillOptions;
2638
+ static params: ISkillParams;
2639
+ constructor(_app: PPAgent, _options: IOpenAITTSSkillOptions);
2640
+ protected _format: string;
2641
+ protected get _maxToken(): number;
2642
+ get options(): IOpenAITTSSkillOptions;
2643
+ get params(): ISkillParams;
2644
+ protected _updateBody(body: any): any;
2645
+ protected getAudioBuffer(text: string): Promise<Buffer>;
2646
+ }
2647
+
2648
+ interface ISiliconFlowDrawSkillOptions extends IBaseDrawSkillOptions {
2649
+ customOptions?: any;
2650
+ }
2651
+ declare class SiliconFlowDrawSkill extends BaseDrawSkill {
2652
+ protected _app: PPAgent;
2653
+ protected _options: ISiliconFlowDrawSkillOptions;
2654
+ static params: ISkillParams;
2655
+ constructor(_app: PPAgent, _options: ISiliconFlowDrawSkillOptions);
2656
+ protected _draw(prompt: string): Promise<IDrawResult>;
2657
+ }
2658
+
2659
+ interface ISiliconFlowSTTSkillOptions extends IBaseSTTSkillOptions {
2660
+ apiKey: string;
2661
+ baseUrl?: string;
2662
+ model: string;
2663
+ }
2664
+ declare class SiliconFlowSTTSkill extends OpenAISTTSkill {
2665
+ protected _app: PPAgent;
2666
+ protected _options: ISiliconFlowSTTSkillOptions;
2667
+ static params: ISkillParams;
2668
+ constructor(_app: PPAgent, _options: ISiliconFlowSTTSkillOptions);
2669
+ get options(): ISiliconFlowSTTSkillOptions;
2670
+ get params(): ISkillParams;
2671
+ }
2672
+
2673
+ interface ISiliconFlowTTSSkillOptions extends IOpenAISTTSkillOptions {
2674
+ apiKey: string;
2675
+ baseUrl?: string;
2676
+ model: string;
2677
+ voice: string;
2678
+ /**
2679
+ * 语速 0.25-4,默认1
2680
+ */
2681
+ speed?: number;
2682
+ }
2683
+ declare class SiliconFlowTTSSkill extends OpenAITTSSkill {
2684
+ protected _app: PPAgent;
2685
+ protected _options: ISiliconFlowTTSSkillOptions;
2686
+ static params: ISkillParams;
2687
+ constructor(_app: PPAgent, _options: ISiliconFlowTTSSkillOptions);
2688
+ protected _format: string;
2689
+ get options(): ISiliconFlowTTSSkillOptions;
2690
+ get params(): ISkillParams;
2691
+ protected _updateBody(body: any): any;
2692
+ protected getAudioBuffer(text: string): Promise<Buffer>;
2693
+ }
2694
+
2695
+ interface ITencentSTTSkillOptions extends IBaseSTTSkillOptions {
2696
+ secretId: string;
2697
+ secretKey: string;
2698
+ }
2699
+ declare class TencentSTTSkill extends BaseSTTSkill {
2700
+ protected _app: PPAgent;
2701
+ protected _options: ITencentSTTSkillOptions;
2702
+ static params: ISkillParams;
2703
+ constructor(_app: PPAgent, _options: ITencentSTTSkillOptions);
2704
+ private _client;
2705
+ init(): Promise<void>;
2706
+ get options(): ITencentSTTSkillOptions;
2707
+ get params(): ISkillParams;
2708
+ protected _getText(file: IAsyncFile): Promise<string>;
2709
+ }
2710
+
2711
+ interface ITencentTTSSkillOptions extends IBaseTTSSkillOptions {
2712
+ secretId: string;
2713
+ secretKey: string;
2714
+ /**
2715
+ * 语速,[-2.6],默认0
2716
+ */
2717
+ spd: number;
2718
+ /**
2719
+ * 音量大小,[-10,10],默认0
2720
+ */
2721
+ vol: number;
2722
+ /**
2723
+ * 详见 https://cloud.tencent.com/document/product/1073/92668 的基础语音合成音色
2724
+ */
2725
+ voice?: number;
2726
+ }
2727
+ declare class TencentTTSSkill extends BaseTTSSkill {
2728
+ private _app;
2729
+ protected _options: ITencentTTSSkillOptions;
2730
+ static params: ISkillParams;
2731
+ constructor(_app: PPAgent, _options: ITencentTTSSkillOptions);
2732
+ private _client;
2733
+ protected get _maxToken(): number;
2734
+ init(): Promise<void>;
2735
+ get options(): ITencentTTSSkillOptions;
2736
+ get params(): ISkillParams;
2737
+ protected getAudioBuffer(text: string): Promise<Buffer>;
2738
+ }
2739
+
2740
+ interface IXunfeiSTTSkillOptions extends IBaseSTTSkillOptions {
2741
+ appId: string;
2742
+ apiKey: string;
2743
+ secretKey: string;
2744
+ }
2745
+ declare class XunfeiSTTSkill extends BaseSTTSkill {
2746
+ protected _app: PPAgent;
2747
+ protected _options: IXunfeiSTTSkillOptions;
2748
+ static params: ISkillParams;
2749
+ constructor(_app: PPAgent, _options: IXunfeiSTTSkillOptions);
2750
+ private _hostUrl;
2751
+ private _host;
2752
+ private _uri;
2753
+ private _frame;
2754
+ get options(): IXunfeiSTTSkillOptions;
2755
+ get params(): ISkillParams;
2756
+ private _getAuthStr;
2757
+ private _getFrame;
2758
+ protected _getText(file: IAsyncFile): Promise<string>;
2759
+ }
2760
+
2761
+ interface IXunfeiTTSSkillOptions extends IBaseTTSSkillOptions {
2762
+ appId: string;
2763
+ apiKey: string;
2764
+ secretKey: string;
2765
+ /**
2766
+ * 语速,0-100
2767
+ */
2768
+ speed: number;
2769
+ /**
2770
+ * 0-100
2771
+ */
2772
+ volume: number;
2773
+ /**
2774
+ * 发音人,如 xiaoyan 请在讯飞控制台查看
2775
+ */
2776
+ vcn: string;
2777
+ /**
2778
+ * 音调(音高),取值0-100
2779
+ */
2780
+ pitch: number;
2781
+ /**
2782
+ * 用语音的概率。默认0.5,即一半。增加随机性。
2405
2783
  */
2406
2784
  probability?: number;
2407
2785
  /**
2408
- * 当判别使用语音时,如果此值为true,会移除语音可能无法阅读的内容。默认false,即遇到无法阅读的,取消语音转换
2786
+ * 当判别使用语音时,如果此值为true,会移除语音可能无法阅读的内容。默认false,即遇到无法阅读的,取消语音转换。
2409
2787
  */
2410
2788
  deleteUnreadableText?: boolean;
2411
2789
  }
2412
- declare class SoviteTTSSkill implements ISkill {
2413
- private _options;
2790
+ declare class XunfeiTTSSkill extends BaseTTSSkill {
2791
+ private _app;
2792
+ protected _options: IXunfeiTTSSkillOptions;
2414
2793
  static params: ISkillParams;
2415
- constructor(_options: ISoviteTTSSkillOptions);
2416
- private _headers;
2417
- get options(): ISoviteTTSSkillOptions;
2794
+ constructor(_app: PPAgent, _options: IXunfeiTTSSkillOptions);
2795
+ private _hostUrl;
2796
+ private _host;
2797
+ private _uri;
2798
+ get options(): IXunfeiTTSSkillOptions;
2418
2799
  get params(): ISkillParams;
2419
- init(): Promise<void>;
2420
- applyOnReply(content: SourceChatContent, messageType: SourceChatMessageType): Promise<{
2421
- content: SourceChatContent;
2422
- messageType: SourceChatMessageType;
2423
- }>;
2800
+ protected get _maxToken(): number;
2801
+ private _getAuthStr;
2802
+ protected getAudioBuffer(text: string): Promise<Buffer>;
2424
2803
  }
2425
2804
 
2426
2805
  interface IDingRobotSourceOptions extends ISourceOptions {
@@ -2442,7 +2821,7 @@ interface IDingRobotSourceOptions extends ISourceOptions {
2442
2821
  */
2443
2822
  markdownMsgTitle?: string;
2444
2823
  /**
2445
- * 发送音频时的格式,默认wav,可选amr,amr文件尺寸小,效率略低于wav。
2824
+ * 发送音频时的格式,默认amr,可选wav(部分wav可能手机会播放失败),amr文件尺寸小,效率略低于wav。
2446
2825
  *
2447
2826
  * 目前测试wav格式支持客户端播放,但是转文字会失败。
2448
2827
  */
@@ -2583,6 +2962,14 @@ interface IFeishuSourceOptions extends ISourceOptions {
2583
2962
  * 启用流式回复时,正在思考的提示语,默认是"正在思考中..."
2584
2963
  */
2585
2964
  thinkingTips?: string;
2965
+ /**
2966
+ * 收到的语音转为wav时的通道数,不设置则采用ffmpeg的默认值。
2967
+ */
2968
+ wavChannel?: number;
2969
+ /**
2970
+ * 收到的语音转为wav时的采样率,不设置则使用ffmpeg的默认值。
2971
+ */
2972
+ wavSampleRate?: number;
2586
2973
  }
2587
2974
  /**
2588
2975
  * 飞书的应用消息源,要注意使用了长连接进行监听,不能启动多个参数相同的消息源,只有其中一个会接收到消息
@@ -2997,8 +3384,8 @@ declare function createCacheManager(namespace: string): Keyv;
2997
3384
  declare function getSecret(key: string): string;
2998
3385
  declare function isPhoneNumber(text: string): boolean;
2999
3386
  declare function generateRandomString(length?: number): string;
3000
- declare function transFormat(inputPath: string, outFilePath: string, toFormat: string): Promise<boolean>;
3001
- declare function transFileFormat(inputFile: IAsyncFile, toFormat: string): Promise<IAsyncFile>;
3387
+ declare function transFormat(inputPath: string, outFilePath: string, toFormat: string, preCommand?: (command: ffmpeg.FfmpegCommand) => ffmpeg.FfmpegCommand): Promise<boolean>;
3388
+ declare function transFileFormat(inputFile: IAsyncFile, toFormat: string, preCommand?: (command: ffmpeg.FfmpegCommand) => ffmpeg.FfmpegCommand): Promise<IAsyncFile>;
3002
3389
  declare function extractImageUrls(text: string, onlyMarkdonw?: boolean): string[];
3003
3390
  declare function extractMarkdownImageTags(text: string): string[];
3004
3391
  /**
@@ -3020,6 +3407,7 @@ declare function checkMessageRule(r: IMessageRule, data: ISourceChatMessageEvent
3020
3407
  declare function installAndGetPluginInfo(name: string, version?: string, registry?: string): Promise<IOnlinePluginInfo>;
3021
3408
  declare function uninstallDep(name: string): Promise<IOnlinePluginInfo>;
3022
3409
  declare function getEnvNumber(key: string): number | undefined;
3410
+ declare function extractMessageContentText(content: SourceChatContent): string;
3023
3411
 
3024
3412
  /**
3025
3413
  * 按照进来顺序回调输出
@@ -3030,4 +3418,4 @@ declare class SortedPromise extends Emittery {
3030
3418
  add<T>(p: Promise<T>): Promise<T>;
3031
3419
  }
3032
3420
 
3033
- export { Agent, type AgentChatMessageReplyType, AgentService, AsyncFile, type AsyncFileLoader, BasicBot, type BotCreator, BotManager, CogViewSkill, CozeBot, CozeService, CronTaskTrigger, DifyAgentBot, DingRobotSource, EchoTaskRunner, EventTaskTrigger, FastGPTBot, FeishuSource, GlobalEvent, GlobalEventNames, GlobalEventTaskTrigger, HistoryMessageManager, type IAgentChatEventData, type IAgentModels, type IAgentOptions, type IAgentServiceOptions, type IAsyncFile, type IAsyncFileSource, type IBasicBotOptions, type IBot, type IBotEventData, type IBotFileInfo, type IBotHistoryMessage, type IBotHistoryRecordEventData, type IBotOptions, type IBotParams, type IBotReadyMessage, type IChatMeOptions, type IConfigParams, type IConfigSchema, type ICozeBotOptions, type ICozeServiceOptions, type ICronTaskTriggerOptions, type IDifyAgentBotOptions, type IDingRobotSourceOptions, type IDingRobotSourceParams, type IDisposable, type IEventTaskTriggerOptions, type IFastGPTBotOptions, type IFeishuSourceOptions, type IGlobalEventData, type IGlobalNotifyEventData, type IHisotryMessageManagerOptions, type IInstance, type IInstanceBaseMangerOptions, type IInstanceCreateOptions, type ILastBotMessageInfo, type ILogger, type ILoggerEmitContent, type IMessageContentReceiver, type IMessageContentRule, type IMessageRule, type IModelInfo, type IOllamaBotOptions, type IOnlinePluginInfo, type IOpenAIBotOptions, type IPPAgentPlugin, type IPPAgentPluginHandler, type IPPAgentPluginOptions, type IQAnythingBotOptions, type IQQSourceOptions, type ISenseVoiceSTTSkillOptions, type ISimpleSchemaItem, type ISkill, type ISkillOptions, type ISkillParams, type ISource, type ISourceActionInfo, type ISourceApiAction, type ISourceApiResponseType, type ISourceChatMessage, type ISourceChatMessageEventData, type ISourceEventData, type ISourceEventTaskTriggerOptions, type ISourceGroupChatMessage, type ISourceGroupInfoChangedEventData, type ISourceLoginEventData, type ISourceLogoutEventData, type ISourceOptions, type ISourceParamas, type ISourceSystemEventData, type ISourceTodoEventData, type ISourceUserInfo, type ISourceWSNormalInMessage, type ISourceWSNormalOutMessage, type ISoviteTTSSkillOptions, type ITaskConfig, type ITaskEventTriggerData, type ITaskRunResult, type ITaskRunner, type ITaskRunnerOptions, type ITaskRunnerParams, type ITaskServiceOptions, type ITaskTrigger, type ITaskTriggerData, type ITaskTriggerOptions, type ITaskTriggerParams, type IWCAISourceOptions, type IWCOASourceOptions, type IWeWorkSourceOptions, type IWenxinAgentBotOptions, type IYuanQiBotOptions, type IZhipuQingyanBotOptions, InstanceBaseManager, OllamaBot, OpenAIBot, OpenRouterBot, PPAgent, QAnythingBot, QQSource, SchemaBaseProperties, SenseVoiceSTTSkill, SimpleSchemaType, type SkillCreator, SkillManager, SkillSchemaBaseProperties, SortedPromise, SourceApiMissingParamsError, SourceApiNotFoundError, SourceApiUnAuthorizedError, type SourceChatArticleContent, type SourceChatAudioContent, type SourceChatCardContent, type SourceChatContactContent, type SourceChatContent, type SourceChatEmotionContent, type SourceChatFileContent, type SourceChatImageContent, type SourceChatMPContent, SourceChatMessageType, type SourceChatMusicContent, type SourceChatPatContentType, type SourceChatPhoneContent, type SourceChatPositionContent, type SourceChatRecallContent, type SourceChatRefContent, type SourceChatRichTextContent, type SourceChatSubscribeContent, type SourceChatSystemContent, type SourceChatTextContent, type SourceChatVideoContent, type SourceCreator, SourceEventTaskTrigger, SourceEventType, SourceManager, type SourceWSCustomAction, type SourceWSNormalAction, SoviteTTSSkill, type TaskRunnerCreator, TaskRunnerManager, TaskRunnerSchemaBaseProperties, TaskService, TaskTrigger, type TaskTriggerCreator, TaskTriggerManager, WCAISource, WCOASource, WeWorkSource, WenxinAgentBot, YuanQiBot, ZhipuQingyanBot, addWavHeader, apiPlugin, arm2wav, betterMarkdown, checkMessageRule, cogViewPlugin, config, createCacheManager, createFormilySchema, defaultPlugin, detectName, disposeObjects, extractArticleInfo, extractImageUrls, extractMarkdownImageTags, extractPositionInfo, filterContentRule, generateRandomString, getEnvNumber, getFromMessageSummary, getLogger, getSecret, getToMessageSummary, hasEmoji, hasMarkdown, installAndGetPluginInfo, isPhoneNumber, removeEmoji, removeMarkdown, richText2Markdown, sleep, sse, stream2buffer, transFileFormat, transFormat, uninstallDep, wav2amr };
3421
+ export { Agent, type AgentChatMessageReplyType, AgentService, AsyncFile, type AsyncFileLoader, BaiduSTTSkill, BaiduTTSSkill, BaseDrawSkill, BaseSTTSkill, BaseTTSSkill, BasicBot, type BotCreator, BotManager, CogVideoDrawSkill, CogviewDrawSkill, CozeBot, CozeService, CronTaskTrigger, DifyAgentBot, DingRobotSource, EchoTaskRunner, EventTaskTrigger, FastGPTBot, FeishuSource, FishAudioTTSSkill, GlobalEvent, GlobalEventNames, GlobalEventTaskTrigger, HistoryMessageManager, type IAgentChatEventData, type IAgentModels, type IAgentOptions, type IAgentServiceOptions, type IAsyncFile, type IAsyncFileSource, type IBaiduSTTSkillOptions, type IBaiduTTSSkillOptions, type IBaseDrawSkillOptions, type IBaseSTTSkillOptions, type IBaseTTSSkillOptions, type IBasicBotOptions, type IBot, type IBotEventData, type IBotFileInfo, type IBotHistoryMessage, type IBotHistoryRecordEventData, type IBotOptions, type IBotParams, type IBotReadyMessage, type ICogVideoDrawSkillOptions, type ICogviewDrawSkillOptions, type IConfigParams, type IConfigSchema, type ICozeBotOptions, type ICozeServiceOptions, type ICronTaskTriggerOptions, type IDifyAgentBotOptions, type IDingRobotSourceOptions, type IDingRobotSourceParams, type IDisposable, type IDrawResult, type IEventTaskTriggerOptions, type IFastGPTBotOptions, type IFeishuSourceOptions, type IFishAudioTTSSkillOptions, type IGlobalEventData, type IGlobalNotifyEventData, type IHisotryMessageManagerOptions, type IInstance, type IInstanceBaseMangerOptions, type IInstanceCreateOptions, type ILastBotMessageInfo, type ILogger, type ILoggerEmitContent, type IMessageContentReceiver, type IMessageContentRule, type IMessageRule, type IModelInfo, type IOllamaBotOptions, type IOnlinePluginInfo, type IOpenAIBotOptions, type IOpenAIDrawSkillOptions, type IOpenAISTTSkillOptions, type IOpenAITTSSkillOptions, type IPPAgentOptions, type IPPAgentPlugin, type IPPAgentPluginHandler, type IPPAgentPluginOptions, type IQAnythingBotOptions, type IQQSourceOptions, type ISenseVoiceSTTSkillOptions, type ISiliconFlowDrawSkillOptions, type ISiliconFlowSTTSkillOptions, type ISiliconFlowTTSSkillOptions, type ISimpleSchemaItem, type ISkill, type ISkillOptions, type ISkillParams, type ISource, type ISourceActionInfo, type ISourceApiAction, type ISourceApiResponseType, type ISourceChatMessage, type ISourceChatMessageEventData, type ISourceEventData, type ISourceEventTaskTriggerOptions, type ISourceGroupChatMessage, type ISourceGroupInfoChangedEventData, type ISourceLoginEventData, type ISourceLogoutEventData, type ISourceOptions, type ISourceParamas, type ISourceSystemEventData, type ISourceTodoEventData, type ISourceUserInfo, type ISourceWSNormalInMessage, type ISourceWSNormalOutMessage, type ISoviteTTSSkillOptions, type ITaskConfig, type ITaskEventTriggerData, type ITaskRunResult, type ITaskRunner, type ITaskRunnerOptions, type ITaskRunnerParams, type ITaskServiceOptions, type ITaskTrigger, type ITaskTriggerData, type ITaskTriggerOptions, type ITaskTriggerParams, type ITencentSTTSkillOptions, type ITencentTTSSkillOptions, type IWCAISourceOptions, type IWCOASourceOptions, type IWeWorkSourceOptions, type IWenxinAgentBotOptions, type IXunfeiBotOptions, type IXunfeiSTTSkillOptions, type IXunfeiTTSSkillOptions, type IYuanQiBotOptions, type IZhipuBotOptions, type IZhipuQingyanBotOptions, InstanceBaseManager, OllamaBot, OpenAIBot, OpenAIDrawSkill, OpenAISTTSkill, OpenAITTSSkill, OpenRouterBot, PPAgent, QAnythingBot, QQSource, SchemaBaseProperties, SenseVoiceSTTSkill, SiliconFlowBot, SiliconFlowDrawSkill, SiliconFlowSTTSkill, SiliconFlowTTSSkill, SimpleSchemaType, type SkillCreator, SkillManager, SkillSchemaBaseProperties, SortedPromise, SourceApiMissingParamsError, SourceApiNotFoundError, SourceApiUnAuthorizedError, type SourceChatArticleContent, type SourceChatAudioContent, type SourceChatCardContent, type SourceChatContactContent, type SourceChatContent, type SourceChatEmotionContent, type SourceChatFileContent, type SourceChatImageContent, type SourceChatMPContent, SourceChatMessageType, type SourceChatMusicContent, type SourceChatPatContentType, type SourceChatPhoneContent, type SourceChatPositionContent, type SourceChatRecallContent, type SourceChatRefContent, type SourceChatRichTextContent, type SourceChatSubscribeContent, type SourceChatSystemContent, type SourceChatTextContent, type SourceChatVideoContent, type SourceCreator, SourceEventTaskTrigger, SourceEventType, SourceManager, type SourceWSCustomAction, type SourceWSNormalAction, SoviteTTSSkill, type TaskRunnerCreator, TaskRunnerManager, TaskRunnerSchemaBaseProperties, TaskService, TaskTrigger, type TaskTriggerCreator, TaskTriggerManager, TencentSTTSkill, TencentTTSSkill, WCAISource, WCOASource, WeWorkSource, WenxinAgentBot, XunfeiBot, XunfeiSTTSkill, XunfeiTTSSkill, YuanQiBot, ZhipuBot, ZhipuQingyanBot, addWavHeader, apiPlugin, arm2wav, betterMarkdown, checkMessageRule, config, createCacheManager, createFormilySchema, defaultPlugin, detectName, disposeObjects, extractArticleInfo, extractImageUrls, extractMarkdownImageTags, extractMessageContentText, extractPositionInfo, filterContentRule, generateRandomString, getEnvNumber, getFromMessageSummary, getLogger, getSecret, getToMessageSummary, hasEmoji, hasMarkdown, installAndGetPluginInfo, isPhoneNumber, removeEmoji, removeMarkdown, richText2Markdown, sleep, sse, stream2buffer, transFileFormat, transFormat, uninstallDep, wav2amr };