@h-ai/ai 0.1.0-alpha.49 → 0.1.0-alpha.50

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.
package/README.md CHANGED
@@ -213,6 +213,8 @@ if (setup.success) {
213
213
 
214
214
  先在 `ai.init()` 中注册语音模型并映射默认识别/合成模型。凭据默认回退到平台环境变量;只有 LLM 与语音模型确认使用同一凭据时,才显式启用 `inheritLlmApiKey`:
215
215
 
216
+ 平台(`provider`)表示调用协议而非部署位置:`openai` / `mimo` / `qwen` / `doubao` 为云服务;`whisper`(ASR)/ `indextts`(TTS)为可自托管协议,无 canonical 端点,必须显式配置 `baseUrl`,同一协议可切换多个 Endpoint(云 / 内网 / 本地)而不改业务代码。云平台缺少凭据返回 `CONFIGURATION_ERROR`;自托管平台可无凭据(配置 `apiKey` 后按 `Authorization: Bearer` 发送)。
217
+
216
218
  ```ts
217
219
  await ai.init({
218
220
  llm: {
@@ -223,18 +225,42 @@ await ai.init({
223
225
  models: [
224
226
  { id: 'asr', provider: 'qwen', model: 'qwen3-asr-flash-realtime', operations: ['transcribe'] },
225
227
  { id: 'tts', provider: 'qwen', model: 'qwen3-tts-flash-realtime', operations: ['synthesize'] },
228
+ // 自托管:whisper / indextts 必须显式配置 baseUrl
229
+ { id: 'whisper', provider: 'whisper', model: 'faster-whisper-large-v3', operations: ['transcribe'], baseUrl: 'http://127.0.0.1:8101/v1' },
230
+ { id: 'indextts', provider: 'indextts', model: 'indextts-2.5', operations: ['synthesize'], baseUrl: 'http://127.0.0.1:8102/v1' },
226
231
  ],
227
232
  transcribeModel: 'asr',
228
233
  synthesizeModel: 'tts',
229
234
  },
230
235
  })
231
236
 
232
- // 完整识别(可选热词提示提升专有名词识别率)
233
- const result = await ai.audio.transcribe({ audio: { data: wavBytes, format: 'wav' }, language: 'zh', contextHints: ['专有名词'] })
237
+ // 完整识别(可选热词、时间戳粒度与 VAD;strictCapabilities 要求模型真实支持所请求能力)
238
+ const result = await ai.audio.transcribe({
239
+ audio: { data: wavBytes, format: 'wav' },
240
+ language: 'zh',
241
+ contextHints: ['专有名词'],
242
+ timestampGranularities: ['segment', 'word'],
243
+ vad: true,
244
+ model: 'whisper',
245
+ })
234
246
  if (result.success) {
235
247
  const text = result.data.text
248
+ const language = result.data.language // 实际检测语言
249
+ const words = result.data.segments?.[0]?.words // 词级时间轴(毫秒整数)
236
250
  }
237
251
 
252
+ // 说话人 / 风格参考合成(IndexTTS):speakerReference 表达“谁在说”,styleReference 表达“怎么说”
253
+ const cloned = await ai.audio.synthesize({
254
+ text: '我们下午三点出发。',
255
+ language: 'zh',
256
+ model: 'indextts',
257
+ speakerReference: { audio: speakerWav, language: 'ja' },
258
+ styleReference: { audio: styleWav },
259
+ styleStrength: 0.8,
260
+ targetDurationMs: 3280, // 目标时长(与 speed 互斥),metadata.durationMatched 反馈是否达标
261
+ durationToleranceMs: 120,
262
+ })
263
+
238
264
  // 实时识别(持续音频输入 → 领域事件流:speech_started / transcript / speech_stopped)
239
265
  for await (const event of ai.audio.transcribeStream({
240
266
  audio: { chunks: microphoneChunks, format: 'pcm16', sampleRate: 16000 },
@@ -290,6 +316,8 @@ return playable.data
290
316
 
291
317
  浏览器 / 移动端通过 `@h-ai/serv` 暴露的统一语音 WebSocket 入口访问,`@h-ai/ai/client` 提供与 Node 端一致的 `audio.*` API(传输细节内部隐藏)。浏览器客户端严格区分正常结束、取消(`AUDIO_CANCELLED`)与异常断连(`AUDIO_CONNECTION_FAILED`):取消或在 `end` 前断连会抛出对应领域错误码,`synthesize` 不会把未完成的部分音频当作成功结果返回。
292
318
 
319
+ > 自托管模型服务(faster-whisper / IndexTTS / Qwen3-4B 的 CPU/GPU Docker 镜像、权重下载与离线打包)见 [`models/`](./models/README.md)。镜像与权重下载优先使用 ModelScope(中国网络友好),自动回退 HuggingFace 镜像。
320
+
293
321
  ### 文生图(Image)
294
322
 
295
323
  在 `ai.init()` 注册模型后,调用方只接收标准化图片字节,不感知厂商 Base64、内联数据或临时 URL:
@@ -1,6 +1,6 @@
1
1
  import * as _h_ai_core from '@h-ai/core';
2
2
  import { HaiResult } from '@h-ai/core';
3
- import { aQ as ChatMessage, ap as InteractionScope, U as MemoryType, bB as RagOptions, bF as ReasoningOptions, cc as ToolRegistryOperations, bn as MemoryEntry, bU as SessionInfo, bg as LLMOperations, bt as MemoryOperations, bA as RagOperations, bE as ReasoningOperations, c as AIConfig, d as AIConfigInput, aF as AIStoreProvider, ce as ToolsOperations, bY as StreamOperations, bL as RetrievalOperations, ba as KnowledgeOperations, az as A2AOperations, q as AudioOperations, k as AudioContent, $ as PlayableAudio, l as AudioFormat } from './ai-reasoning-types-DwxulYKu.js';
3
+ import { a_ as ChatMessage, az as InteractionScope, Y as MemoryType, bL as RagOptions, bP as ReasoningOptions, cm as ToolRegistryOperations, bx as MemoryEntry, c2 as SessionInfo, bq as LLMOperations, bD as MemoryOperations, bK as RagOperations, bO as ReasoningOperations, c as AIConfig, d as AIConfigInput, aP as AIStoreProvider, co as ToolsOperations, c6 as StreamOperations, bV as RetrievalOperations, bk as KnowledgeOperations, aJ as A2AOperations, s as AudioOperations, k as AudioContent, a3 as PlayableAudio, l as AudioFormat } from './ai-reasoning-types-CuITylkA.js';
4
4
  import * as zod from 'zod';
5
5
  import { z } from 'zod';
6
6
  import { Buffer } from 'node:buffer';
@@ -2759,21 +2759,43 @@ type A2AConfig = z.infer<typeof A2AConfigSchema>;
2759
2759
  /**
2760
2760
  * 语音平台枚举
2761
2761
  *
2762
- * 决定 `ai.audio` 底层调用哪个厂商(对使用方透明,公共请求/响应形状保持一致):
2762
+ * 决定 `ai.audio` 底层调用哪个厂商 / 协议(对使用方透明,公共请求/响应形状保持一致):
2763
2763
  *
2764
2764
  * - `openai` — OpenAI Audio API(transcriptions / speech)
2765
2765
  * - `mimo` — 小米 MiMo(Chat Completions 风格 ASR / TTS)
2766
2766
  * - `qwen` — 阿里云百炼 Qwen Realtime(DashScope WebSocket ASR / TTS)
2767
2767
  * - `doubao` — 火山引擎豆包语音(二进制 WebSocket ASR / TTS)
2768
+ * - `whisper` — hai-framework Whisper Service 协议(HTTP 文件识别,可自托管)
2769
+ * - `indextts` — hai-framework IndexTTS Service 协议(HTTP 合成,可自托管)
2770
+ *
2771
+ * 平台仅表示「用哪种协议调用」,不表示服务部署在哪里;`whisper` / `indextts` 需显式配置 `baseUrl`。
2768
2772
  */
2769
2773
  declare const AudioProviderSchema: z.ZodEnum<{
2770
2774
  openai: "openai";
2771
2775
  mimo: "mimo";
2772
2776
  qwen: "qwen";
2773
2777
  doubao: "doubao";
2778
+ whisper: "whisper";
2779
+ indextts: "indextts";
2774
2780
  }>;
2775
2781
  /** 语音平台类型 */
2776
2782
  type AudioProviderName = z.infer<typeof AudioProviderSchema>;
2783
+ /** 单个语音操作类型 */
2784
+ declare const AudioOperationSchema: z.ZodEnum<{
2785
+ transcribe: "transcribe";
2786
+ synthesize: "synthesize";
2787
+ }>;
2788
+ /** 语音操作类型 */
2789
+ type AudioOperation = z.infer<typeof AudioOperationSchema>;
2790
+ /**
2791
+ * 语音模型允许的操作列表
2792
+ *
2793
+ * 至少一项,且不允许重复。
2794
+ */
2795
+ declare const AudioOperationsSchema: z.ZodArray<z.ZodEnum<{
2796
+ transcribe: "transcribe";
2797
+ synthesize: "synthesize";
2798
+ }>>;
2777
2799
  /**
2778
2800
  * 语音模型条目 Schema
2779
2801
  *
@@ -2791,9 +2813,14 @@ declare const AudioModelEntrySchema: z.ZodObject<{
2791
2813
  mimo: "mimo";
2792
2814
  qwen: "qwen";
2793
2815
  doubao: "doubao";
2816
+ whisper: "whisper";
2817
+ indextts: "indextts";
2794
2818
  }>;
2795
2819
  model: z.ZodString;
2796
- operations: z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<"transcribe">], null>, z.ZodTuple<[z.ZodLiteral<"synthesize">], null>, z.ZodTuple<[z.ZodLiteral<"transcribe">, z.ZodLiteral<"synthesize">], null>]>;
2820
+ operations: z.ZodArray<z.ZodEnum<{
2821
+ transcribe: "transcribe";
2822
+ synthesize: "synthesize";
2823
+ }>>;
2797
2824
  apiKey: z.ZodOptional<z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<string | undefined, string | null>>>;
2798
2825
  baseUrl: z.ZodOptional<z.ZodString>;
2799
2826
  appKey: z.ZodOptional<z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<string | undefined, string | null>>>;
@@ -2831,9 +2858,14 @@ declare const AudioConfigSchema: z.ZodObject<{
2831
2858
  mimo: "mimo";
2832
2859
  qwen: "qwen";
2833
2860
  doubao: "doubao";
2861
+ whisper: "whisper";
2862
+ indextts: "indextts";
2834
2863
  }>;
2835
2864
  model: z.ZodString;
2836
- operations: z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<"transcribe">], null>, z.ZodTuple<[z.ZodLiteral<"synthesize">], null>, z.ZodTuple<[z.ZodLiteral<"transcribe">, z.ZodLiteral<"synthesize">], null>]>;
2865
+ operations: z.ZodArray<z.ZodEnum<{
2866
+ transcribe: "transcribe";
2867
+ synthesize: "synthesize";
2868
+ }>>;
2837
2869
  apiKey: z.ZodOptional<z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<string | undefined, string | null>>>;
2838
2870
  baseUrl: z.ZodOptional<z.ZodString>;
2839
2871
  appKey: z.ZodOptional<z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<string | undefined, string | null>>>;
@@ -2890,6 +2922,17 @@ interface ResolvedAudioModel {
2890
2922
  * @returns 成功返回已解析模型;无匹配模型返回 `AUDIO_MODEL_NOT_FOUND`;缺少凭据返回 `CONFIGURATION_ERROR`
2891
2923
  */
2892
2924
  declare function resolveAudioModel(audioConfig: AudioConfig, operation: 'transcribe' | 'synthesize', explicit?: string, llmApiKey?: string): HaiResult<ResolvedAudioModel>;
2925
+ /**
2926
+ * 校验已解析模型是否具备该平台协议所需的凭据
2927
+ *
2928
+ * 凭据是否必需由平台协议决定:自托管的 `whisper` / `indextts` 可无凭据;豆包允许 API Key
2929
+ * 或 App/Access Key 组合;其余云平台必须提供 API Key。仅在真正发起识别 / 合成前调用,
2930
+ * 能力查询(`getCapabilities`)不需要凭据。
2931
+ *
2932
+ * @param model - 已解析模型
2933
+ * @returns 缺少必需凭据时返回 `CONFIGURATION_ERROR`,否则返回 `null`
2934
+ */
2935
+ declare function ensureAudioCredential(model: ResolvedAudioModel): HaiError | null;
2893
2936
  /**
2894
2937
  * 文生图平台枚举
2895
2938
  *
@@ -3175,9 +3218,14 @@ declare const AIConfigSchema: z.ZodObject<{
3175
3218
  mimo: "mimo";
3176
3219
  qwen: "qwen";
3177
3220
  doubao: "doubao";
3221
+ whisper: "whisper";
3222
+ indextts: "indextts";
3178
3223
  }>;
3179
3224
  model: z.ZodString;
3180
- operations: z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<"transcribe">], null>, z.ZodTuple<[z.ZodLiteral<"synthesize">], null>, z.ZodTuple<[z.ZodLiteral<"transcribe">, z.ZodLiteral<"synthesize">], null>]>;
3225
+ operations: z.ZodArray<z.ZodEnum<{
3226
+ transcribe: "transcribe";
3227
+ synthesize: "synthesize";
3228
+ }>>;
3181
3229
  apiKey: z.ZodOptional<z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<string | undefined, string | null>>>;
3182
3230
  baseUrl: z.ZodOptional<z.ZodString>;
3183
3231
  appKey: z.ZodOptional<z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<string | undefined, string | null>>>;
@@ -3274,10 +3322,46 @@ interface AudioInputStream {
3274
3322
  /** 声道数(默认单声道) */
3275
3323
  channels?: 1 | 2;
3276
3324
  }
3277
- /** 完整语音识别请求 */
3278
- interface TranscriptionRequest {
3279
- /** 待识别的完整音频 */
3280
- audio: AudioContent;
3325
+ /**
3326
+ * ASR 时间戳粒度
3327
+ *
3328
+ * - `segment` — 语义段 / 句级时间轴
3329
+ * - `word` — 词级时间轴
3330
+ */
3331
+ type TranscriptionTimestampGranularity = 'segment' | 'word';
3332
+ /** 单个 ASR 词级识别结果 */
3333
+ interface TranscriptionWord {
3334
+ /** 识别出的文字、单词或 Token */
3335
+ text: string;
3336
+ /** 起始时间(毫秒) */
3337
+ startMs: number;
3338
+ /** 结束时间(毫秒) */
3339
+ endMs: number;
3340
+ /** 置信度(仅 Provider 能提供明确概率语义时返回) */
3341
+ confidence?: number;
3342
+ }
3343
+ /** ASR 分段结果 */
3344
+ interface TranscriptionSegment {
3345
+ /** Provider 返回或 Framework 生成的 Segment ID */
3346
+ id?: string;
3347
+ /** 当前 Segment 完整文本 */
3348
+ text: string;
3349
+ /** Segment 起始位置(毫秒) */
3350
+ startMs: number;
3351
+ /** Segment 结束位置(毫秒) */
3352
+ endMs: number;
3353
+ /** 当前 Segment 下的词级时间轴 */
3354
+ words?: TranscriptionWord[];
3355
+ /** 为后续 Speaker Diarization 预留的说话人 ID */
3356
+ speakerId?: string;
3357
+ }
3358
+ /**
3359
+ * ASR 公共请求选项
3360
+ *
3361
+ * 完整识别与流式识别共用;所有高级能力字段均为可选,不支持的平台会忽略或(在
3362
+ * `strictCapabilities` 为真时)提前失败。
3363
+ */
3364
+ interface TranscriptionOptions {
3281
3365
  /** 语言提示(如 `zh` / `en`;不传时由模型自动检测) */
3282
3366
  language?: string;
3283
3367
  /**
@@ -3286,32 +3370,41 @@ interface TranscriptionRequest {
3286
3370
  * Provider 按能力映射为热词表 / phrase list / vocabulary / 提示词;不支持的平台会忽略。
3287
3371
  */
3288
3372
  contextHints?: string[];
3373
+ /** 请求返回的时间戳粒度(`segment` / `word`) */
3374
+ timestampGranularities?: TranscriptionTimestampGranularity[];
3375
+ /** 是否启用模型 / 服务端 VAD */
3376
+ vad?: boolean;
3377
+ /** 是否严格要求高级能力全部被支持(true 时不支持则提前失败,false 为 best effort) */
3378
+ strictCapabilities?: boolean;
3289
3379
  /** 模型 ID(不传时使用配置中的默认识别模型) */
3290
3380
  model?: string;
3291
3381
  /** 取消信号 */
3292
3382
  signal?: AbortSignal;
3293
3383
  }
3384
+ /** 完整语音识别请求 */
3385
+ interface TranscriptionRequest extends TranscriptionOptions {
3386
+ /** 待识别的完整音频 */
3387
+ audio: AudioContent;
3388
+ }
3294
3389
  /** 流式语音识别请求(支持完整音频或持续音频输入) */
3295
- interface TranscriptionStreamRequest {
3390
+ interface TranscriptionStreamRequest extends TranscriptionOptions {
3296
3391
  /** 完整音频,或持续到达的音频输入流 */
3297
3392
  audio: AudioContent | AudioInputStream;
3298
- /** 语言提示(如 `zh` / `en`;不传时由模型自动检测) */
3299
- language?: string;
3300
- /**
3301
- * 领域提示词 / 热词(如角色名、专有名词、当前主题关键词)
3302
- *
3303
- * Provider 按能力映射为热词表 / phrase list / vocabulary / 提示词;不支持的平台会忽略。
3304
- */
3305
- contextHints?: string[];
3306
- /** 模型 ID(不传时使用配置中的默认识别模型) */
3307
- model?: string;
3308
- /** 取消信号 */
3309
- signal?: AbortSignal;
3310
3393
  }
3311
3394
  /** 完整语音识别结果 */
3312
3395
  interface TranscriptionResult {
3313
3396
  /** 识别文本 */
3314
3397
  text: string;
3398
+ /** 实际检测或使用的语言 */
3399
+ language?: string;
3400
+ /** 输入音频总时长(毫秒) */
3401
+ durationMs?: number;
3402
+ /**
3403
+ * 结构化识别时间轴
3404
+ *
3405
+ * Word Timestamp 统一存储在 `segments[].words`,不在顶层重复。
3406
+ */
3407
+ segments?: TranscriptionSegment[];
3315
3408
  }
3316
3409
  /**
3317
3410
  * 流式语音识别领域事件
@@ -3330,30 +3423,79 @@ type TranscriptionEvent = {
3330
3423
  type: 'transcript';
3331
3424
  text: string;
3332
3425
  final: boolean;
3426
+ startMs?: number;
3427
+ endMs?: number;
3428
+ words?: TranscriptionWord[];
3333
3429
  } | {
3334
3430
  type: 'speech_stopped';
3335
3431
  };
3336
- /** 完整语音合成请求 */
3337
- interface SynthesisRequest {
3338
- /** 待合成文本 */
3339
- text: string;
3432
+ /**
3433
+ * TTS 通用参考音频
3434
+ *
3435
+ * 不绑定任何具体 TTS 模型。既可表达「谁在说话」(说话人参考),也可表达「怎么说」(风格参考),
3436
+ * 由 `SynthesisOptions.speakerReference` / `styleReference` 决定用途。
3437
+ */
3438
+ interface AudioReference {
3439
+ /** 参考音频 */
3440
+ audio: AudioContent;
3441
+ /** 参考音频对应文本(仅需要参考 Transcript 的 Provider 使用) */
3442
+ transcript?: string;
3443
+ /** 参考音频语言 */
3444
+ language?: string;
3445
+ }
3446
+ /**
3447
+ * TTS 公共请求选项
3448
+ *
3449
+ * 完整合成与流式合成共用;所有高级能力字段均为可选,不支持的平台会忽略或(在
3450
+ * `strictCapabilities` 为真时)提前失败。
3451
+ */
3452
+ interface SynthesisOptions {
3453
+ /** 目标语言 */
3454
+ language?: string;
3340
3455
  /** 音色(厂商音色名,不传时使用模型默认音色) */
3341
3456
  voice?: string;
3457
+ /** 说话人 / 音色参考(表达「谁在说话」) */
3458
+ speakerReference?: AudioReference;
3459
+ /** 风格、情绪、韵律参考(表达「怎么说」) */
3460
+ styleReference?: AudioReference;
3461
+ /** 风格参考影响强度,统一为 `[0, 1]` */
3462
+ styleStrength?: number;
3342
3463
  /**
3343
3464
  * 自然语言风格指令(如语速、情绪、角色语气)
3344
3465
  *
3345
3466
  * Provider 按能力映射(如 MiMo 放入 user 消息、Qwen instructions);不支持的平台会忽略。
3346
3467
  */
3347
3468
  instruction?: string;
3469
+ /**
3470
+ * 语速倍数
3471
+ *
3472
+ * `1.0` 正常、`>1` 更快、`<1` 更慢。
3473
+ */
3474
+ speed?: number;
3348
3475
  /** 输出音频格式(不传时使用模型默认格式) */
3349
3476
  format?: AudioFormat;
3350
3477
  /** 输出采样率(Hz) */
3351
3478
  sampleRate?: number;
3352
3479
  /** 模型 ID(不传时使用配置中的默认合成模型) */
3353
3480
  model?: string;
3481
+ /** 是否严格要求高级能力全部被支持(true 时不支持则提前失败,false 为 best effort) */
3482
+ strictCapabilities?: boolean;
3354
3483
  /** 取消信号 */
3355
3484
  signal?: AbortSignal;
3356
3485
  }
3486
+ /** 完整语音合成请求 */
3487
+ interface SynthesisRequest extends SynthesisOptions {
3488
+ /** 待合成文本 */
3489
+ text: string;
3490
+ /**
3491
+ * 最终音频目标时长(毫秒)
3492
+ *
3493
+ * 表达 Framework 业务目标,不对应某个模型私有参数;由支持的 Provider / Model Service 闭环逼近。
3494
+ */
3495
+ targetDurationMs?: number;
3496
+ /** 目标时长允许误差(毫秒) */
3497
+ durationToleranceMs?: number;
3498
+ }
3357
3499
  /** 带稳定 ID 的合成文本段 */
3358
3500
  interface SynthesisTextSegment {
3359
3501
  /** 调用方分配的稳定 ID,用于关联文本、音频与播放完成状态 */
@@ -3362,28 +3504,21 @@ interface SynthesisTextSegment {
3362
3504
  text: string;
3363
3505
  }
3364
3506
  /** 流式语音合成请求(支持单段或持续文本段输入) */
3365
- interface SynthesisStreamRequest {
3507
+ interface SynthesisStreamRequest extends SynthesisOptions {
3366
3508
  /** 单个文本段,或持续到达的文本段流 */
3367
3509
  text: SynthesisTextSegment | AsyncIterable<SynthesisTextSegment>;
3368
- /** 音色(厂商音色名,不传时使用模型默认音色) */
3369
- voice?: string;
3370
- /**
3371
- * 自然语言风格指令(如语速、情绪、角色语气)
3372
- *
3373
- * Provider 按能力映射(如 MiMo 放入 user 消息、Qwen instructions);不支持的平台会忽略。
3374
- */
3375
- instruction?: string;
3376
- /** 输出音频格式(不传时使用模型默认格式) */
3377
- format?: AudioFormat;
3378
- /** 输出采样率(Hz) */
3379
- sampleRate?: number;
3380
- /** 模型 ID(不传时使用配置中的默认合成模型) */
3381
- model?: string;
3382
- /** 取消信号 */
3383
- signal?: AbortSignal;
3384
3510
  }
3385
3511
  /** 完整语音合成结果 */
3386
3512
  interface SynthesisResult extends AudioContent {
3513
+ /** 实际输出音频时长(毫秒) */
3514
+ durationMs?: number;
3515
+ /** 通用生成元数据 */
3516
+ metadata?: {
3517
+ /** 是否满足调用方指定的时长容差(无法判断时保持 undefined) */
3518
+ durationMatched?: boolean;
3519
+ /** Provider 最终使用的 Framework speed */
3520
+ speed?: number;
3521
+ };
3387
3522
  }
3388
3523
  /**
3389
3524
  * 流式语音合成领域事件
@@ -3420,16 +3555,55 @@ type SynthesisEvent = {
3420
3555
  interface AudioModelCapabilities {
3421
3556
  /** 语音识别能力;模型未声明识别操作时不返回 */
3422
3557
  transcribe?: {
3558
+ /** 是否支持 ASR */
3423
3559
  supported: boolean;
3560
+ /** 是否原生支持持续实时音频输入 */
3424
3561
  realtimeAudioInput: boolean;
3562
+ /** 是否产生语音边界事件(speech_started / speech_stopped) */
3425
3563
  speechBoundaryEvents: boolean;
3564
+ /** 是否原生输出增量 Transcript */
3426
3565
  streamingTranscriptOutput: boolean;
3566
+ /** 是否接受 Language Hint */
3567
+ languageHint?: boolean;
3568
+ /** 是否支持自动语言检测 */
3569
+ languageDetection?: boolean;
3570
+ /** 是否支持 Segment Timestamp */
3571
+ segmentTimestamps?: boolean;
3572
+ /** 是否支持 Word Timestamp */
3573
+ wordTimestamps?: boolean;
3574
+ /** 是否支持 Context Hints */
3575
+ contextHints?: boolean;
3576
+ /** 是否支持 VAD */
3577
+ vad?: boolean;
3578
+ /** 是否支持 Speaker Diarization */
3579
+ speakerDiarization?: boolean;
3427
3580
  };
3428
3581
  /** 语音合成能力;模型未声明合成操作时不返回 */
3429
3582
  synthesize?: {
3583
+ /** 是否支持 TTS */
3430
3584
  supported: boolean;
3585
+ /** 是否原生支持增量文本输入 */
3431
3586
  incrementalTextInput: boolean;
3587
+ /** 是否原生支持流式音频输出 */
3432
3588
  streamingAudioOutput: boolean;
3589
+ /** 是否支持指定目标语言 */
3590
+ languageSelection?: boolean;
3591
+ /** 是否支持预置 Voice */
3592
+ presetVoice?: boolean;
3593
+ /** 是否支持 Speaker Reference */
3594
+ speakerReference?: boolean;
3595
+ /** 是否必须提供 Speaker Reference */
3596
+ speakerReferenceRequired?: boolean;
3597
+ /** 是否支持 Style Reference */
3598
+ styleReference?: boolean;
3599
+ /** 是否支持通用自然语言 Instruction */
3600
+ instruction?: boolean;
3601
+ /** 是否支持 Framework Speed */
3602
+ speedControl?: boolean;
3603
+ /** 是否支持 Framework Target Duration */
3604
+ targetDuration?: boolean;
3605
+ /** 已知支持语言 */
3606
+ supportedLanguages?: string[];
3433
3607
  };
3434
3608
  }
3435
3609
  /** 查询语音模型能力的参数 */
@@ -3756,4 +3930,4 @@ interface ReasoningOperations {
3756
3930
  runStream: (query: string, options?: ReasoningOptions) => AsyncIterable<ReasoningStreamEvent>;
3757
3931
  }
3758
3932
 
3759
- export { type PlayableAudio as $, type A2AConfig as A, ImageModelEntrySchema as B, type CompressConfig as C, type ImageProviderName as D, type EmbeddingConfig as E, type FileConfig as F, ImageProviderSchema as G, KnowledgeConfigSchema as H, type ImageConfig as I, LLMConfigSchema as J, type KnowledgeConfig as K, type LLMConfig as L, type MCPConfig as M, MCPConfigSchema as N, type MCPServerCapabilities as O, MCPServerCapabilitiesSchema as P, type MCPServerConfig as Q, MCPServerConfigSchema as R, type MemoryConfig as S, MemoryConfigSchema as T, type MemoryType as U, MemoryTypeSchema as V, type ModelEntry as W, ModelEntrySchema as X, type ModelScenario as Y, ModelScenarioSchema as Z, OptionalSecretSchema as _, A2AConfigSchema as a, type KnowledgeAskOptions as a$, type ResolveRequiredModelEntryOptions as a0, type ResolvedAudioModel as a1, type ResolvedImageModel as a2, type ResolvedModelConfig as a3, type RetrievalConfig as a4, RetrievalConfigSchema as a5, type RetrievalSourceConfig as a6, RetrievalSourceSchema as a7, type SummaryConfig as a8, SummaryConfigSchema as a9, type A2ASecurityConfig as aA, type A2ATaskFilter as aB, type AILLMFunctionsDeps as aC, type AIRelStore as aD, type AIRelStoreOptions as aE, type AIStoreProvider as aF, type AIVectorBackend as aG, type AIVectorStore as aH, type AskOptions as aI, type AssistantMessage as aJ, type ChatCompletionChoice as aK, type ChatCompletionChunk as aL, type ChatCompletionDelta as aM, type ChatCompletionRequest as aN, type ChatCompletionResponse as aO, type ChatHistoryOptions as aP, type ChatMessage as aQ, type ChatRecord as aR, type Citation as aS, type DefineToolOptions as aT, type DeveloperMessage as aU, type EntityDocumentRelation as aV, type EntityDocumentResult as aW, type EntityListOptions as aX, type EntityQueryOptions as aY, type GenerateObjectRequest as aZ, type ImageContent as a_, type SynthesisEvent as aa, type SynthesisRequest as ab, type SynthesisResult as ac, type SynthesisStreamRequest as ad, type SynthesisTextSegment as ae, type TokenConfig as af, TokenConfigSchema as ag, type TranscriptionEvent as ah, type TranscriptionRequest as ai, type TranscriptionResult as aj, type TranscriptionStreamRequest as ak, resolveAudioModel as al, resolveImageModel as am, resolveModelApi as an, resolveModelEntry as ao, type InteractionScope as ap, type A2AAgentCardConfig as aq, type A2AApiKeySecurity as ar, type A2AAuthenticator as as, type A2ACallOptions as at, type A2ACallResult as au, type A2ACallerIdentity as av, type A2AContextInfo as aw, type A2AHandleResult as ax, type A2AMessageRecord as ay, type A2AOperations as az, A2ASkillConfigSchema as b, type SystemMessage as b$, type KnowledgeAskResult as b0, type KnowledgeDocumentInfo as b1, type KnowledgeDocumentListOptions as b2, type KnowledgeDocumentRemoveOptions as b3, type KnowledgeEntity as b4, type KnowledgeIngestBatchProgress as b5, type KnowledgeIngestBatchResult as b6, type KnowledgeIngestFileInput as b7, type KnowledgeIngestInput as b8, type KnowledgeIngestResult as b9, type RagOperations as bA, type RagOptions as bB, type RagResult as bC, type RagStreamEvent as bD, type ReasoningOperations as bE, type ReasoningOptions as bF, type ReasoningResult as bG, type ReasoningStep as bH, type ReasoningStepType as bI, type ReasoningStrategy as bJ, type ReasoningStreamEvent as bK, type RetrievalOperations as bL, type RetrievalRequest as bM, type RetrievalResult as bN, type RetrievalResultItem as bO, type RetrievalSource as bP, type SSEDecoder as bQ, type SSEEvent as bR, type ScopedMemoryBinding as bS, type ScopedMemoryOperations as bT, type SessionInfo as bU, type StoreFilter as bV, type StorePage as bW, type StoreScope as bX, type StreamOperations as bY, type StreamProcessor as bZ, type StreamResult as b_, type KnowledgeOperations as ba, type KnowledgeRetrieveItem as bb, type KnowledgeRetrieveOptions as bc, type KnowledgeRetrieveResult as bd, type KnowledgeSetupOptions as be, type KnowledgeStore as bf, type LLMOperations as bg, type LLMProvider as bh, type MemoryAccessScope as bi, type MemoryAdminOperations as bj, type MemoryClearAllOptions as bk, type MemoryClearOptions as bl, type MemoryCoreOperations as bm, type MemoryEntry as bn, type MemoryEntryInput as bo, type MemoryExtractOptions as bp, type MemoryInjectionOptions as bq, type MemoryListOptions as br, type MemoryListPageOptions as bs, type MemoryOperations as bt, type MemoryRecallOptions as bu, type MemoryUpdateInput as bv, type MessageContent as bw, type MessageRole as bx, type ObjectRef as by, type RagContextItem as bz, type AIConfig as c, type TempModelConfig as c0, type TextContent as c1, type TokenUsage as c2, type Tool as c3, type ToolAuthorizationRequest as c4, type ToolAuthorizer as c5, type ToolCall as c6, type ToolDefinition as c7, type ToolErrorType as c8, type ToolExecutionContext as c9, type ToolExecutionOptions as ca, type ToolMessage as cb, type ToolRegistryOperations as cc, type ToolRegistryOptions as cd, type ToolsOperations as ce, type UserMessage as cf, type WhereClause as cg, type WhereOperator as ch, type WhereValue as ci, type AIConfigInput as d, AIConfigSchema as e, type ApiType as f, ApiTypeSchema as g, type AudioCapabilitiesRequest as h, type AudioConfig as i, AudioConfigSchema as j, type AudioContent as k, type AudioFormat as l, type AudioInputStream as m, type AudioModelCapabilities as n, type AudioModelEntry as o, AudioModelEntrySchema as p, type AudioOperations as q, type AudioProviderName as r, AudioProviderSchema as s, CompressConfigSchema as t, EmbeddingConfigSchema as u, type EntityType as v, EntityTypeSchema as w, FileConfigSchema as x, ImageConfigSchema as y, type ImageModelEntry as z };
3933
+ export { ModelEntrySchema as $, type A2AConfig as A, EntityTypeSchema as B, type CompressConfig as C, FileConfigSchema as D, type EmbeddingConfig as E, type FileConfig as F, ImageConfigSchema as G, type ImageModelEntry as H, type ImageConfig as I, ImageModelEntrySchema as J, type ImageProviderName as K, ImageProviderSchema as L, type KnowledgeConfig as M, KnowledgeConfigSchema as N, type LLMConfig as O, LLMConfigSchema as P, type MCPConfig as Q, MCPConfigSchema as R, type MCPServerCapabilities as S, MCPServerCapabilitiesSchema as T, type MCPServerConfig as U, MCPServerConfigSchema as V, type MemoryConfig as W, MemoryConfigSchema as X, type MemoryType as Y, MemoryTypeSchema as Z, type ModelEntry as _, A2AConfigSchema as a, type ChatRecord as a$, type ModelScenario as a0, ModelScenarioSchema as a1, OptionalSecretSchema as a2, type PlayableAudio as a3, type ResolveRequiredModelEntryOptions as a4, type ResolvedAudioModel as a5, type ResolvedImageModel as a6, type ResolvedModelConfig as a7, type RetrievalConfig as a8, RetrievalConfigSchema as a9, type A2AAgentCardConfig as aA, type A2AApiKeySecurity as aB, type A2AAuthenticator as aC, type A2ACallOptions as aD, type A2ACallResult as aE, type A2ACallerIdentity as aF, type A2AContextInfo as aG, type A2AHandleResult as aH, type A2AMessageRecord as aI, type A2AOperations as aJ, type A2ASecurityConfig as aK, type A2ATaskFilter as aL, type AILLMFunctionsDeps as aM, type AIRelStore as aN, type AIRelStoreOptions as aO, type AIStoreProvider as aP, type AIVectorBackend as aQ, type AIVectorStore as aR, type AskOptions as aS, type AssistantMessage as aT, type ChatCompletionChoice as aU, type ChatCompletionChunk as aV, type ChatCompletionDelta as aW, type ChatCompletionRequest as aX, type ChatCompletionResponse as aY, type ChatHistoryOptions as aZ, type ChatMessage as a_, type RetrievalSourceConfig as aa, RetrievalSourceSchema as ab, type SummaryConfig as ac, SummaryConfigSchema as ad, type SynthesisEvent as ae, type SynthesisOptions as af, type SynthesisRequest as ag, type SynthesisResult as ah, type SynthesisStreamRequest as ai, type SynthesisTextSegment as aj, type TokenConfig as ak, TokenConfigSchema as al, type TranscriptionEvent as am, type TranscriptionOptions as an, type TranscriptionRequest as ao, type TranscriptionResult as ap, type TranscriptionSegment as aq, type TranscriptionStreamRequest as ar, type TranscriptionTimestampGranularity as as, type TranscriptionWord as at, ensureAudioCredential as au, resolveAudioModel as av, resolveImageModel as aw, resolveModelApi as ax, resolveModelEntry as ay, type InteractionScope as az, A2ASkillConfigSchema as b, type SSEEvent as b$, type Citation as b0, type DefineToolOptions as b1, type DeveloperMessage as b2, type EntityDocumentRelation as b3, type EntityDocumentResult as b4, type EntityListOptions as b5, type EntityQueryOptions as b6, type GenerateObjectRequest as b7, type ImageContent as b8, type KnowledgeAskOptions as b9, type MemoryInjectionOptions as bA, type MemoryListOptions as bB, type MemoryListPageOptions as bC, type MemoryOperations as bD, type MemoryRecallOptions as bE, type MemoryUpdateInput as bF, type MessageContent as bG, type MessageRole as bH, type ObjectRef as bI, type RagContextItem as bJ, type RagOperations as bK, type RagOptions as bL, type RagResult as bM, type RagStreamEvent as bN, type ReasoningOperations as bO, type ReasoningOptions as bP, type ReasoningResult as bQ, type ReasoningStep as bR, type ReasoningStepType as bS, type ReasoningStrategy as bT, type ReasoningStreamEvent as bU, type RetrievalOperations as bV, type RetrievalRequest as bW, type RetrievalResult as bX, type RetrievalResultItem as bY, type RetrievalSource as bZ, type SSEDecoder as b_, type KnowledgeAskResult as ba, type KnowledgeDocumentInfo as bb, type KnowledgeDocumentListOptions as bc, type KnowledgeDocumentRemoveOptions as bd, type KnowledgeEntity as be, type KnowledgeIngestBatchProgress as bf, type KnowledgeIngestBatchResult as bg, type KnowledgeIngestFileInput as bh, type KnowledgeIngestInput as bi, type KnowledgeIngestResult as bj, type KnowledgeOperations as bk, type KnowledgeRetrieveItem as bl, type KnowledgeRetrieveOptions as bm, type KnowledgeRetrieveResult as bn, type KnowledgeSetupOptions as bo, type KnowledgeStore as bp, type LLMOperations as bq, type LLMProvider as br, type MemoryAccessScope as bs, type MemoryAdminOperations as bt, type MemoryClearAllOptions as bu, type MemoryClearOptions as bv, type MemoryCoreOperations as bw, type MemoryEntry as bx, type MemoryEntryInput as by, type MemoryExtractOptions as bz, type AIConfig as c, type ScopedMemoryBinding as c0, type ScopedMemoryOperations as c1, type SessionInfo as c2, type StoreFilter as c3, type StorePage as c4, type StoreScope as c5, type StreamOperations as c6, type StreamProcessor as c7, type StreamResult as c8, type SystemMessage as c9, type TempModelConfig as ca, type TextContent as cb, type TokenUsage as cc, type Tool as cd, type ToolAuthorizationRequest as ce, type ToolAuthorizer as cf, type ToolCall as cg, type ToolDefinition as ch, type ToolErrorType as ci, type ToolExecutionContext as cj, type ToolExecutionOptions as ck, type ToolMessage as cl, type ToolRegistryOperations as cm, type ToolRegistryOptions as cn, type ToolsOperations as co, type UserMessage as cp, type WhereClause as cq, type WhereOperator as cr, type WhereValue as cs, type AIConfigInput as d, AIConfigSchema as e, type ApiType as f, ApiTypeSchema as g, type AudioCapabilitiesRequest as h, type AudioConfig as i, AudioConfigSchema as j, type AudioContent as k, type AudioFormat as l, type AudioInputStream as m, type AudioModelCapabilities as n, type AudioModelEntry as o, AudioModelEntrySchema as p, type AudioOperation as q, AudioOperationSchema as r, type AudioOperations as s, AudioOperationsSchema as t, type AudioProviderName as u, AudioProviderSchema as v, type AudioReference as w, CompressConfigSchema as x, EmbeddingConfigSchema as y, type EntityType as z };
package/dist/browser.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { A as A2AConfig, a as A2AConfigSchema, b as A2ASkillConfigSchema, c as AIConfig, d as AIConfigInput, e as AIConfigSchema, f as ApiType, g as ApiTypeSchema, h as AudioCapabilitiesRequest, i as AudioConfig, j as AudioConfigSchema, k as AudioContent, l as AudioFormat, m as AudioInputStream, n as AudioModelCapabilities, o as AudioModelEntry, p as AudioModelEntrySchema, q as AudioOperations, r as AudioProviderName, s as AudioProviderSchema, C as CompressConfig, t as CompressConfigSchema, E as EmbeddingConfig, u as EmbeddingConfigSchema, v as EntityType, w as EntityTypeSchema, F as FileConfig, x as FileConfigSchema, I as ImageConfig, y as ImageConfigSchema, z as ImageModelEntry, B as ImageModelEntrySchema, D as ImageProviderName, G as ImageProviderSchema, K as KnowledgeConfig, H as KnowledgeConfigSchema, L as LLMConfig, J as LLMConfigSchema, M as MCPConfig, N as MCPConfigSchema, O as MCPServerCapabilities, P as MCPServerCapabilitiesSchema, Q as MCPServerConfig, R as MCPServerConfigSchema, S as MemoryConfig, T as MemoryConfigSchema, U as MemoryType, V as MemoryTypeSchema, W as ModelEntry, X as ModelEntrySchema, Y as ModelScenario, Z as ModelScenarioSchema, _ as OptionalSecretSchema, $ as PlayableAudio, a0 as ResolveRequiredModelEntryOptions, a1 as ResolvedAudioModel, a2 as ResolvedImageModel, a3 as ResolvedModelConfig, a4 as RetrievalConfig, a5 as RetrievalConfigSchema, a6 as RetrievalSourceConfig, a7 as RetrievalSourceSchema, a8 as SummaryConfig, a9 as SummaryConfigSchema, aa as SynthesisEvent, ab as SynthesisRequest, ac as SynthesisResult, ad as SynthesisStreamRequest, ae as SynthesisTextSegment, af as TokenConfig, ag as TokenConfigSchema, ah as TranscriptionEvent, ai as TranscriptionRequest, aj as TranscriptionResult, ak as TranscriptionStreamRequest, al as resolveAudioModel, am as resolveImageModel, an as resolveModelApi, ao as resolveModelEntry } from './ai-reasoning-types-DwxulYKu.js';
2
- export { A as AIFunctions, a as AIInitOptions, b as AUDIO_WS_PATH, c as AudioFormatSchema, d as AudioWsClientMessage, e as AudioWsClientMessageSchema, f as AudioWsDoneMessage, g as AudioWsDoneMessageSchema, h as AudioWsEndMessage, i as AudioWsErrorMessage, j as AudioWsSegmentDoneMessage, k as AudioWsSegmentStartedMessage, l as AudioWsServerMessage, m as AudioWsSpeechMessage, n as AudioWsStartMessage, o as AudioWsStartMessageSchema, p as AudioWsTextMessage, q as AudioWsTextMessageSchema, r as AudioWsTranscriptMessage, C as CompressionStrategy, s as CompressionStrategySchema, G as GenerateImageRequest, t as GenerateImageResult, u as GeneratedImage, H as HaiAIError, I as ImageOperations, v as ImageSize, R as ReferenceImage, w as serializePlayableAudio } from './ai-audio-ws-protocol-BAOyKbBU.js';
1
+ export { A as A2AConfig, a as A2AConfigSchema, b as A2ASkillConfigSchema, c as AIConfig, d as AIConfigInput, e as AIConfigSchema, f as ApiType, g as ApiTypeSchema, h as AudioCapabilitiesRequest, i as AudioConfig, j as AudioConfigSchema, k as AudioContent, l as AudioFormat, m as AudioInputStream, n as AudioModelCapabilities, o as AudioModelEntry, p as AudioModelEntrySchema, q as AudioOperation, r as AudioOperationSchema, s as AudioOperations, t as AudioOperationsSchema, u as AudioProviderName, v as AudioProviderSchema, w as AudioReference, C as CompressConfig, x as CompressConfigSchema, E as EmbeddingConfig, y as EmbeddingConfigSchema, z as EntityType, B as EntityTypeSchema, F as FileConfig, D as FileConfigSchema, I as ImageConfig, G as ImageConfigSchema, H as ImageModelEntry, J as ImageModelEntrySchema, K as ImageProviderName, L as ImageProviderSchema, M as KnowledgeConfig, N as KnowledgeConfigSchema, O as LLMConfig, P as LLMConfigSchema, Q as MCPConfig, R as MCPConfigSchema, S as MCPServerCapabilities, T as MCPServerCapabilitiesSchema, U as MCPServerConfig, V as MCPServerConfigSchema, W as MemoryConfig, X as MemoryConfigSchema, Y as MemoryType, Z as MemoryTypeSchema, _ as ModelEntry, $ as ModelEntrySchema, a0 as ModelScenario, a1 as ModelScenarioSchema, a2 as OptionalSecretSchema, a3 as PlayableAudio, a4 as ResolveRequiredModelEntryOptions, a5 as ResolvedAudioModel, a6 as ResolvedImageModel, a7 as ResolvedModelConfig, a8 as RetrievalConfig, a9 as RetrievalConfigSchema, aa as RetrievalSourceConfig, ab as RetrievalSourceSchema, ac as SummaryConfig, ad as SummaryConfigSchema, ae as SynthesisEvent, af as SynthesisOptions, ag as SynthesisRequest, ah as SynthesisResult, ai as SynthesisStreamRequest, aj as SynthesisTextSegment, ak as TokenConfig, al as TokenConfigSchema, am as TranscriptionEvent, an as TranscriptionOptions, ao as TranscriptionRequest, ap as TranscriptionResult, aq as TranscriptionSegment, ar as TranscriptionStreamRequest, as as TranscriptionTimestampGranularity, at as TranscriptionWord, au as ensureAudioCredential, av as resolveAudioModel, aw as resolveImageModel, ax as resolveModelApi, ay as resolveModelEntry } from './ai-reasoning-types-CuITylkA.js';
2
+ export { A as AIFunctions, a as AIInitOptions, b as AUDIO_WS_PATH, c as AudioFormatSchema, d as AudioWsClientMessage, e as AudioWsClientMessageSchema, f as AudioWsDoneMessage, g as AudioWsDoneMessageSchema, h as AudioWsEndMessage, i as AudioWsErrorMessage, j as AudioWsSegmentDoneMessage, k as AudioWsSegmentStartedMessage, l as AudioWsServerMessage, m as AudioWsSpeechMessage, n as AudioWsStartMessage, o as AudioWsStartMessageSchema, p as AudioWsTextMessage, q as AudioWsTextMessageSchema, r as AudioWsTranscriptMessage, C as CompressionStrategy, s as CompressionStrategySchema, G as GenerateImageRequest, t as GenerateImageResult, u as GeneratedImage, H as HaiAIError, I as ImageOperations, v as ImageSize, R as ReferenceImage, w as serializePlayableAudio } from './ai-audio-ws-protocol-COIRfUFF.js';
3
3
  export { A2AClientOperations, AIApiAdapter, AIClient, AIClientConfig, AudioClientConfig, AudioClientOperations, AudioTicketRequest, StreamOptions, StreamProgress, collectStreamContent, createA2AClient, createAIClient, createAudioClient, createUnconfiguredAudioClient, parseSSE } from './client/index.js';
4
4
  import '@a2a-js/sdk/server';
5
5
  import '@h-ai/core';
package/dist/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- export { A2AConfigSchema, A2ASkillConfigSchema, AIConfigSchema, AUDIO_WS_PATH, ApiTypeSchema, AudioConfigSchema, AudioFormatSchema, AudioModelEntrySchema, AudioProviderSchema, AudioWsClientMessageSchema, AudioWsDoneMessageSchema, AudioWsStartMessageSchema, AudioWsTextMessageSchema, CompressConfigSchema, CompressionStrategySchema, EmbeddingConfigSchema, EntityTypeSchema, FileConfigSchema, ImageConfigSchema, ImageModelEntrySchema, ImageProviderSchema, KnowledgeConfigSchema, LLMConfigSchema, MCPConfigSchema, MCPServerCapabilitiesSchema, MCPServerConfigSchema, MemoryConfigSchema, MemoryTypeSchema, ModelEntrySchema, ModelScenarioSchema, OptionalSecretSchema, RetrievalConfigSchema, RetrievalSourceSchema, SummaryConfigSchema, TokenConfigSchema, resolveAudioModel, resolveImageModel, resolveModelApi, resolveModelEntry, serializePlayableAudio } from './chunk-4FDOGXIS.js';
1
+ export { A2AConfigSchema, A2ASkillConfigSchema, AIConfigSchema, AUDIO_WS_PATH, ApiTypeSchema, AudioConfigSchema, AudioFormatSchema, AudioModelEntrySchema, AudioOperationSchema, AudioOperationsSchema, AudioProviderSchema, AudioWsClientMessageSchema, AudioWsDoneMessageSchema, AudioWsStartMessageSchema, AudioWsTextMessageSchema, CompressConfigSchema, CompressionStrategySchema, EmbeddingConfigSchema, EntityTypeSchema, FileConfigSchema, ImageConfigSchema, ImageModelEntrySchema, ImageProviderSchema, KnowledgeConfigSchema, LLMConfigSchema, MCPConfigSchema, MCPServerCapabilitiesSchema, MCPServerConfigSchema, MemoryConfigSchema, MemoryTypeSchema, ModelEntrySchema, ModelScenarioSchema, OptionalSecretSchema, RetrievalConfigSchema, RetrievalSourceSchema, SummaryConfigSchema, TokenConfigSchema, ensureAudioCredential, resolveAudioModel, resolveImageModel, resolveModelApi, resolveModelEntry, serializePlayableAudio } from './chunk-PLNY4UUT.js';
2
2
  export { collectStreamContent, createA2AClient, createAIClient, createAudioClient, createUnconfiguredAudioClient, parseSSE } from './chunk-6RWS5OWJ.js';
3
3
  export { HaiAIError } from './chunk-JC7QBT3C.js';
4
4
  //# sourceMappingURL=browser.js.map
@@ -83,6 +83,7 @@ var en_US_default = {
83
83
  ai_audioInvalidRequest: "Invalid audio request: {reason}",
84
84
  ai_audioModelNotFound: "Audio model '{model}' not found. Register it in audio.models of ai.init().",
85
85
  ai_audioMissingApiKey: "Audio provider '{provider}' is missing credentials (API Key or App/Access Key).",
86
+ ai_audioMissingBaseUrl: "Audio provider '{provider}' is missing an endpoint. Configure baseUrl in the model entry.",
86
87
  ai_audioUnsupportedInput: "Provider '{provider}' does not support this input mode: {reason}",
87
88
  ai_audioUpstreamError: "Audio upstream service error: {error}",
88
89
  ai_audioProtocolError: "Audio protocol error: {error}",
@@ -183,6 +184,7 @@ var zh_CN_default = {
183
184
  ai_audioInvalidRequest: "\u8BED\u97F3\u8BF7\u6C42\u53C2\u6570\u65E0\u6548\uFF1A{reason}",
184
185
  ai_audioModelNotFound: "\u8BED\u97F3\u6A21\u578B '{model}' \u672A\u627E\u5230\uFF0C\u8BF7\u5728 ai.init() \u7684 audio.models \u4E2D\u6CE8\u518C",
185
186
  ai_audioMissingApiKey: "\u8BED\u97F3\u5E73\u53F0 '{provider}' \u7F3A\u5C11\u51ED\u636E\uFF08API Key \u6216 App/Access Key\uFF09",
187
+ ai_audioMissingBaseUrl: "\u8BED\u97F3\u5E73\u53F0 '{provider}' \u7F3A\u5C11\u7AEF\u70B9\u5730\u5740\uFF0C\u8BF7\u5728\u6A21\u578B\u6761\u76EE\u4E2D\u914D\u7F6E baseUrl",
186
188
  ai_audioUnsupportedInput: "\u5E73\u53F0 '{provider}' \u4E0D\u652F\u6301\u6B64\u8F93\u5165\u65B9\u5F0F\uFF1A{reason}",
187
189
  ai_audioUpstreamError: "\u8BED\u97F3\u4E0A\u6E38\u670D\u52A1\u9519\u8BEF\uFF1A{error}",
188
190
  ai_audioProtocolError: "\u8BED\u97F3\u534F\u8BAE\u9519\u8BEF\uFF1A{error}",
@@ -475,7 +477,11 @@ var A2AConfigSchema = z.object({
475
477
  }).optional()
476
478
  }).optional()
477
479
  });
478
- var AudioProviderSchema = z.enum(["openai", "mimo", "qwen", "doubao"]);
480
+ var AudioProviderSchema = z.enum(["openai", "mimo", "qwen", "doubao", "whisper", "indextts"]);
481
+ var AudioOperationSchema = z.enum(["transcribe", "synthesize"]);
482
+ var AudioOperationsSchema = z.array(AudioOperationSchema).min(1).refine((operations) => new Set(operations).size === operations.length, {
483
+ message: "audio model operations must be unique"
484
+ });
479
485
  var AudioModelEntrySchema = z.object({
480
486
  /** 模型唯一标识(用于场景解析与请求显式指定) */
481
487
  id: z.string(),
@@ -484,14 +490,10 @@ var AudioModelEntrySchema = z.object({
484
490
  /** 厂商模型名(传给厂商 API 的实际模型名) */
485
491
  model: z.string(),
486
492
  /** 模型允许执行的操作;解析模型时会在调用厂商前校验 */
487
- operations: z.union([
488
- z.tuple([z.literal("transcribe")]),
489
- z.tuple([z.literal("synthesize")]),
490
- z.tuple([z.literal("transcribe"), z.literal("synthesize")])
491
- ]),
493
+ operations: AudioOperationsSchema,
492
494
  /** API Key 覆盖(未提供时可按 Audio 配置继承 LLM 密钥,最后回退对应平台环境变量) */
493
495
  apiKey: OptionalSecretSchema,
494
- /** HTTP / WebSocket 端点覆盖(未提供时使用平台默认端点) */
496
+ /** HTTP / WebSocket 端点覆盖(`whisper` / `indextts` 无默认端点,必须显式配置) */
495
497
  baseUrl: z.string().optional(),
496
498
  /** 火山引擎 App Key(`X-Api-App-Key`,旧版控制台 ASR 需要) */
497
499
  appKey: OptionalSecretSchema,
@@ -524,6 +526,7 @@ var AUDIO_PROVIDER_DEFAULT_BASE_URL = {
524
526
  qwen: "wss://dashscope.aliyuncs.com/api-ws/v1/realtime",
525
527
  doubao: "wss://openspeech.bytedance.com"
526
528
  };
529
+ var AUDIO_PROVIDER_CREDENTIAL_OPTIONAL = /* @__PURE__ */ new Set(["whisper", "indextts"]);
527
530
  function doubaoDefaultResourceId(operation) {
528
531
  return operation === "transcribe" ? "volc.bigasr.sauc.duration" : "seed-tts-2.0";
529
532
  }
@@ -537,6 +540,10 @@ function audioProviderEnvApiKey(provider) {
537
540
  return process.env.HAI_AI_AUDIO_QWEN_API_KEY ?? process.env.DASHSCOPE_API_KEY;
538
541
  case "doubao":
539
542
  return process.env.HAI_AI_AUDIO_DOUBAO_API_KEY ?? process.env.VOLC_API_KEY;
543
+ case "whisper":
544
+ return process.env.HAI_AI_AUDIO_WHISPER_API_KEY;
545
+ case "indextts":
546
+ return process.env.HAI_AI_AUDIO_INDEXTTS_API_KEY;
540
547
  }
541
548
  }
542
549
  function resolveAudioModel(audioConfig, operation, explicit, llmApiKey) {
@@ -554,15 +561,15 @@ function resolveAudioModel(audioConfig, operation, explicit, llmApiKey) {
554
561
  );
555
562
  }
556
563
  const apiKey = entry.apiKey ?? (audioConfig.inheritLlmApiKey ? llmApiKey : void 0) ?? audioProviderEnvApiKey(entry.provider);
557
- const hasDoubaoLegacy = Boolean(entry.appKey && entry.accessKey);
558
- if (!apiKey && !(entry.provider === "doubao" && hasDoubaoLegacy))
559
- return err(HaiAIError.CONFIGURATION_ERROR, aiM("ai_audioMissingApiKey", { params: { provider: entry.provider } }));
564
+ const baseUrl = entry.baseUrl ?? AUDIO_PROVIDER_DEFAULT_BASE_URL[entry.provider];
565
+ if (!baseUrl)
566
+ return err(HaiAIError.CONFIGURATION_ERROR, aiM("ai_audioMissingBaseUrl", { params: { provider: entry.provider } }));
560
567
  return ok({
561
568
  id: entry.id,
562
569
  provider: entry.provider,
563
570
  model: entry.model,
564
571
  apiKey,
565
- baseUrl: entry.baseUrl ?? AUDIO_PROVIDER_DEFAULT_BASE_URL[entry.provider],
572
+ baseUrl,
566
573
  appKey: entry.appKey ?? process.env.VOLC_APP_KEY,
567
574
  accessKey: entry.accessKey ?? process.env.VOLC_ACCESS_KEY,
568
575
  resourceId: entry.resourceId ?? (entry.provider === "doubao" ? doubaoDefaultResourceId(operation) : ""),
@@ -570,6 +577,14 @@ function resolveAudioModel(audioConfig, operation, explicit, llmApiKey) {
570
577
  timeout: entry.timeout ?? 6e4
571
578
  });
572
579
  }
580
+ function ensureAudioCredential(model) {
581
+ if (AUDIO_PROVIDER_CREDENTIAL_OPTIONAL.has(model.provider))
582
+ return null;
583
+ const hasDoubaoLegacy = model.provider === "doubao" && Boolean(model.appKey && model.accessKey);
584
+ if (model.apiKey || hasDoubaoLegacy)
585
+ return null;
586
+ return core.error.buildHaiErrorInst(HaiAIError.CONFIGURATION_ERROR, aiM("ai_audioMissingApiKey", { params: { provider: model.provider } }));
587
+ }
573
588
  var ImageProviderSchema = z.enum(["openai", "google", "qwen", "seedream", "pollinations"]);
574
589
  var ImageModelEntrySchema = z.object({
575
590
  /** 模型唯一标识(供请求选择) */
@@ -716,6 +731,6 @@ var AudioWsTextMessageSchema = AudioWsTextMessageSchema$1;
716
731
  var AudioWsDoneMessageSchema = AudioWsDoneMessageSchema$1;
717
732
  var AudioWsClientMessageSchema = AudioWsClientMessageSchema$1;
718
733
 
719
- export { A2AConfigSchema, A2ASkillConfigSchema, AIConfigSchema, AUDIO_WS_PATH, ApiTypeSchema, AudioConfigSchema, AudioFormatSchema, AudioModelEntrySchema, AudioProviderSchema, AudioWsClientMessageSchema, AudioWsDoneMessageSchema, AudioWsStartMessageSchema, AudioWsTextMessageSchema, CompressConfigSchema, CompressionStrategySchema, EmbeddingConfigSchema, EntityTypeSchema, FileConfigSchema, ImageConfigSchema, ImageModelEntrySchema, ImageProviderSchema, KnowledgeConfigSchema, LLMConfigSchema, MCPConfigSchema, MCPServerCapabilitiesSchema, MCPServerConfigSchema, MemoryConfigSchema, MemoryTypeSchema, ModelEntrySchema, ModelScenarioSchema, OptionalSecretSchema, RetrievalConfigSchema, RetrievalSourceSchema, SummaryConfigSchema, TokenConfigSchema, aiM, resolveAudioModel, resolveImageModel, resolveModelApi, resolveModelEntry, serializePlayableAudio };
720
- //# sourceMappingURL=chunk-4FDOGXIS.js.map
721
- //# sourceMappingURL=chunk-4FDOGXIS.js.map
734
+ export { A2AConfigSchema, A2ASkillConfigSchema, AIConfigSchema, AUDIO_WS_PATH, ApiTypeSchema, AudioConfigSchema, AudioFormatSchema, AudioModelEntrySchema, AudioOperationSchema, AudioOperationsSchema, AudioProviderSchema, AudioWsClientMessageSchema, AudioWsDoneMessageSchema, AudioWsStartMessageSchema, AudioWsTextMessageSchema, CompressConfigSchema, CompressionStrategySchema, EmbeddingConfigSchema, EntityTypeSchema, FileConfigSchema, ImageConfigSchema, ImageModelEntrySchema, ImageProviderSchema, KnowledgeConfigSchema, LLMConfigSchema, MCPConfigSchema, MCPServerCapabilitiesSchema, MCPServerConfigSchema, MemoryConfigSchema, MemoryTypeSchema, ModelEntrySchema, ModelScenarioSchema, OptionalSecretSchema, RetrievalConfigSchema, RetrievalSourceSchema, SummaryConfigSchema, TokenConfigSchema, aiM, ensureAudioCredential, resolveAudioModel, resolveImageModel, resolveModelApi, resolveModelEntry, serializePlayableAudio };
735
+ //# sourceMappingURL=chunk-PLNY4UUT.js.map
736
+ //# sourceMappingURL=chunk-PLNY4UUT.js.map