@h-ai/ai 1.0.0-beta.1 → 1.0.0-beta.3

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.en.md CHANGED
@@ -146,17 +146,17 @@ const controller = new AbortController()
146
146
  const cancellable = ai.llm.chat({ messages, signal: controller.signal })
147
147
  // controller.abort()
148
148
 
149
- // 多协议:模型的 api 决定底层走 Chat Completions / Responses / Anthropic,公共请求响应形状不变
149
+ // 多协议:模型的 protocol 决定底层走 Chat Completions / Responses / Anthropic,公共请求响应形状不变
150
150
  // - chat(默认):OpenAI Chat Completions(兼容绝大多数厂商)
151
151
  // - responses:OpenAI Responses API(/v1/responses)
152
152
  // - anthropic:Anthropic Messages API(Claude 原生协议,环境变量 ANTHROPIC_API_KEY / ANTHROPIC_BASE_URL)
153
- const claude = await ai.llm.chat({ messages, model: 'claude' }) // 该模型配置 api: anthropic
153
+ const claude = await ai.llm.chat({ messages, model: 'claude' }) // 该模型配置 protocol: anthropic
154
154
 
155
155
  // 临时模型:单次请求绕过配置注册模型,直接指定端点与凭据(chat/chatStream/ask/askStream 均支持)
156
156
  // 临时客户端按 TTL 缓存(llm.tempModelCacheTtl,默认 10 分钟),与常驻模型客户端隔离
157
157
  const temp = await ai.llm.chat({
158
158
  messages,
159
- tempModel: { model: 'claude-3-5-sonnet', api: 'anthropic', apiKey: 'sk-temp' },
159
+ tempModel: { model: 'claude-3-5-sonnet', protocol: 'anthropic', apiKey: 'sk-temp' },
160
160
  })
161
161
  ```
162
162
 
@@ -516,18 +516,20 @@ const manager = ai.context.createManager({
516
516
 
517
517
  ### Configuration
518
518
 
519
+ The LLM protocol field is now `protocol` in `llm`, `llm.models[]`, and `tempModel`, replacing `api`. Values remain `chat | responses | anthropic`. Use `HAI_AI_LLM_PROTOCOL` and `HAI_AI_LLM_MODELS_0_PROTOCOL` (adjust the index for other entries). Old fields and protocol variables fail with a migration message; `apiKey` and its variables are unchanged.
520
+
519
521
  ```yaml
520
522
  llm:
521
523
  apiKey: ''
522
524
  baseUrl: https://api.openai.com/v1
523
525
  model: gpt-4o-mini
524
- api: chat # chat(默认)| responses | anthropic —— 底层 API 协议,对使用方透明
526
+ protocol: chat # chat(默认)| responses | anthropic —— 底层 API 协议,对使用方透明
525
527
  timeout: 60000
526
528
  tempModelCacheTtl: 600000 # 临时模型客户端缓存 TTL(毫秒,默认 10 分钟)
527
529
  models: # 可为每个模型单独指定协议
528
530
  - {id: fast, model: gpt-4o-mini}
529
- - {id: strong, model: gpt-4.1, api: responses}
530
- - {id: claude, model: claude-3-5-sonnet-latest, api: anthropic}
531
+ - {id: strong, model: gpt-4.1, protocol: responses}
532
+ - {id: claude, model: claude-3-5-sonnet-latest, protocol: anthropic}
531
533
  scenarios:
532
534
  chat: fast
533
535
  reasoning: strong
package/README.ja.md CHANGED
@@ -146,17 +146,17 @@ const controller = new AbortController()
146
146
  const cancellable = ai.llm.chat({ messages, signal: controller.signal })
147
147
  // controller.abort()
148
148
 
149
- // 多协议:模型的 api 决定底层走 Chat Completions / Responses / Anthropic,公共请求响应形状不变
149
+ // 多协议:模型的 protocol 决定底层走 Chat Completions / Responses / Anthropic,公共请求响应形状不变
150
150
  // - chat(默认):OpenAI Chat Completions(兼容绝大多数厂商)
151
151
  // - responses:OpenAI Responses API(/v1/responses)
152
152
  // - anthropic:Anthropic Messages API(Claude 原生协议,环境变量 ANTHROPIC_API_KEY / ANTHROPIC_BASE_URL)
153
- const claude = await ai.llm.chat({ messages, model: 'claude' }) // 该模型配置 api: anthropic
153
+ const claude = await ai.llm.chat({ messages, model: 'claude' }) // 该模型配置 protocol: anthropic
154
154
 
155
155
  // 临时模型:单次请求绕过配置注册模型,直接指定端点与凭据(chat/chatStream/ask/askStream 均支持)
156
156
  // 临时客户端按 TTL 缓存(llm.tempModelCacheTtl,默认 10 分钟),与常驻模型客户端隔离
157
157
  const temp = await ai.llm.chat({
158
158
  messages,
159
- tempModel: { model: 'claude-3-5-sonnet', api: 'anthropic', apiKey: 'sk-temp' },
159
+ tempModel: { model: 'claude-3-5-sonnet', protocol: 'anthropic', apiKey: 'sk-temp' },
160
160
  })
161
161
  ```
162
162
 
@@ -516,18 +516,20 @@ const manager = ai.context.createManager({
516
516
 
517
517
  ### 設定
518
518
 
519
+ LLM の `llm.api`、`llm.models[].api`、`tempModel.api` は `protocol` に統一されました。値は `chat | responses | anthropic` のままです。環境変数は `HAI_AI_LLM_PROTOCOL`、`HAI_AI_LLM_MODELS_0_PROTOCOL`(他の項目は対応する添字)を使います。旧フィールドと旧プロトコル変数は移行案内付きでエラーになります。`apiKey` とその変数は変更ありません。
520
+
519
521
  ```yaml
520
522
  llm:
521
523
  apiKey: ''
522
524
  baseUrl: https://api.openai.com/v1
523
525
  model: gpt-4o-mini
524
- api: chat # chat(默认)| responses | anthropic —— 底层 API 协议,对使用方透明
526
+ protocol: chat # chat(默认)| responses | anthropic —— 底层 API 协议,对使用方透明
525
527
  timeout: 60000
526
528
  tempModelCacheTtl: 600000 # 临时模型客户端缓存 TTL(毫秒,默认 10 分钟)
527
529
  models: # 可为每个模型单独指定协议
528
530
  - {id: fast, model: gpt-4o-mini}
529
- - {id: strong, model: gpt-4.1, api: responses}
530
- - {id: claude, model: claude-3-5-sonnet-latest, api: anthropic}
531
+ - {id: strong, model: gpt-4.1, protocol: responses}
532
+ - {id: claude, model: claude-3-5-sonnet-latest, protocol: anthropic}
531
533
  scenarios:
532
534
  chat: fast
533
535
  reasoning: strong
package/README.md CHANGED
@@ -163,17 +163,17 @@ const controller = new AbortController()
163
163
  const cancellable = ai.llm.chat({ messages, signal: controller.signal })
164
164
  // controller.abort()
165
165
 
166
- // 多协议:模型的 api 决定底层走 Chat Completions / Responses / Anthropic,公共请求响应形状不变
166
+ // 多协议:模型的 protocol 决定底层走 Chat Completions / Responses / Anthropic,公共请求响应形状不变
167
167
  // - chat(默认):OpenAI Chat Completions(兼容绝大多数厂商)
168
168
  // - responses:OpenAI Responses API(/v1/responses)
169
169
  // - anthropic:Anthropic Messages API(Claude 原生协议,环境变量 ANTHROPIC_API_KEY / ANTHROPIC_BASE_URL)
170
- const claude = await ai.llm.chat({ messages, model: 'claude' }) // 该模型配置 api: anthropic
170
+ const claude = await ai.llm.chat({ messages, model: 'claude' }) // 该模型配置 protocol: anthropic
171
171
 
172
172
  // 临时模型:单次请求绕过配置注册模型,直接指定端点与凭据(chat/chatStream/ask/askStream 均支持)
173
173
  // 临时客户端按 TTL 缓存(llm.tempModelCacheTtl,默认 10 分钟),与常驻模型客户端隔离
174
174
  const temp = await ai.llm.chat({
175
175
  messages,
176
- tempModel: { model: 'claude-3-5-sonnet', api: 'anthropic', apiKey: 'sk-temp' },
176
+ tempModel: { model: 'claude-3-5-sonnet', protocol: 'anthropic', apiKey: 'sk-temp' },
177
177
  })
178
178
  ```
179
179
 
@@ -539,18 +539,20 @@ const manager = ai.context.createManager({
539
539
 
540
540
  ### 配置
541
541
 
542
+ LLM 协议字段已从 `llm.api` / `llm.models[].api` / `tempModel.api` 统一改为 `protocol`,取值仍为 `chat | responses | anthropic`。环境变量改用 `HAI_AI_LLM_PROTOCOL`、`HAI_AI_LLM_MODELS_0_PROTOCOL`(其他项按索引递增)。旧字段和旧协议变量会明确报错并提示迁移;`apiKey` 及其变量不变。
543
+
542
544
  ```yaml
543
545
  llm:
544
546
  apiKey: ''
545
547
  baseUrl: https://api.openai.com/v1
546
548
  model: gpt-4o-mini
547
- api: chat # chat(默认)| responses | anthropic —— 底层 API 协议,对使用方透明
549
+ protocol: chat # chat(默认)| responses | anthropic —— 底层 API 协议,对使用方透明
548
550
  timeout: 60000
549
551
  tempModelCacheTtl: 600000 # 临时模型客户端缓存 TTL(毫秒,默认 10 分钟)
550
552
  models: # 可为每个模型单独指定协议
551
553
  - {id: fast, model: gpt-4o-mini}
552
- - {id: strong, model: gpt-4.1, api: responses}
553
- - {id: claude, model: claude-3-5-sonnet-latest, api: anthropic}
554
+ - {id: strong, model: gpt-4.1, protocol: responses}
555
+ - {id: claude, model: claude-3-5-sonnet-latest, protocol: anthropic}
554
556
  scenarios:
555
557
  chat: fast
556
558
  reasoning: strong
@@ -837,14 +837,14 @@ type ToolDefinition = OpenAI.Chat.Completions.ChatCompletionTool;
837
837
  * ```ts
838
838
  * import type { TempModelConfig } from '@h-ai/ai'
839
839
  *
840
- * const value: TempModelConfig = { model: 'gpt-4o-mini', api: 'chat', timeout: 15_000 }
840
+ * const value: TempModelConfig = { model: 'gpt-4o-mini', protocol: 'chat', timeout: 15_000 }
841
841
  * ```
842
842
  */
843
843
  interface TempModelConfig {
844
844
  /** 模型名称(传给 API 的实际模型名) */
845
845
  model: string;
846
- /** API 协议(未指定时回退全局 `api`,再回退 `chat`;决定走 Chat Completions / Responses / Anthropic) */
847
- api?: ApiType;
846
+ /** API 协议(未指定时回退全局 `protocol`,再回退 `chat`;决定走 Chat Completions / Responses / Anthropic) */
847
+ protocol?: ApiType;
848
848
  /** API Key(未指定时回退全局配置 / 环境变量) */
849
849
  apiKey?: string;
850
850
  /** API 基础 URL(未指定时回退全局配置 / 环境变量 / 默认 OpenAI) */
@@ -3223,7 +3223,7 @@ type ApiType = z.infer<typeof ApiTypeSchema>;
3223
3223
  declare const ModelEntrySchema: z.ZodObject<{
3224
3224
  id: z.ZodString;
3225
3225
  model: z.ZodString;
3226
- api: z.ZodOptional<z.ZodEnum<{
3226
+ protocol: z.ZodOptional<z.ZodEnum<{
3227
3227
  chat: "chat";
3228
3228
  responses: "responses";
3229
3229
  anthropic: "anthropic";
@@ -3233,7 +3233,7 @@ declare const ModelEntrySchema: z.ZodObject<{
3233
3233
  maxTokens: z.ZodOptional<z.ZodNumber>;
3234
3234
  temperature: z.ZodOptional<z.ZodNumber>;
3235
3235
  timeout: z.ZodOptional<z.ZodNumber>;
3236
- }, z.core.$strip>;
3236
+ }, z.core.$strict>;
3237
3237
  /**
3238
3238
  * 模型条目类型
3239
3239
  *
@@ -3273,7 +3273,7 @@ declare const LLMConfigSchema: z.ZodObject<{
3273
3273
  apiKey: z.ZodOptional<z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<string | undefined, string | null>>>;
3274
3274
  baseUrl: z.ZodOptional<z.ZodURL>;
3275
3275
  model: z.ZodDefault<z.ZodOptional<z.ZodString>>;
3276
- api: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
3276
+ protocol: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
3277
3277
  chat: "chat";
3278
3278
  responses: "responses";
3279
3279
  anthropic: "anthropic";
@@ -3285,7 +3285,7 @@ declare const LLMConfigSchema: z.ZodObject<{
3285
3285
  models: z.ZodOptional<z.ZodArray<z.ZodObject<{
3286
3286
  id: z.ZodString;
3287
3287
  model: z.ZodString;
3288
- api: z.ZodOptional<z.ZodEnum<{
3288
+ protocol: z.ZodOptional<z.ZodEnum<{
3289
3289
  chat: "chat";
3290
3290
  responses: "responses";
3291
3291
  anthropic: "anthropic";
@@ -3295,7 +3295,7 @@ declare const LLMConfigSchema: z.ZodObject<{
3295
3295
  maxTokens: z.ZodOptional<z.ZodNumber>;
3296
3296
  temperature: z.ZodOptional<z.ZodNumber>;
3297
3297
  timeout: z.ZodOptional<z.ZodNumber>;
3298
- }, z.core.$strip>>>;
3298
+ }, z.core.$strict>>>;
3299
3299
  scenarios: z.ZodOptional<z.ZodObject<{
3300
3300
  chat: z.ZodOptional<z.ZodString>;
3301
3301
  summary: z.ZodOptional<z.ZodString>;
@@ -3309,7 +3309,7 @@ declare const LLMConfigSchema: z.ZodObject<{
3309
3309
  rerank: z.ZodOptional<z.ZodString>;
3310
3310
  fast: z.ZodOptional<z.ZodString>;
3311
3311
  }, z.core.$strip>>;
3312
- }, z.core.$strip>;
3312
+ }, z.core.$strict>;
3313
3313
  /**
3314
3314
  * LLM 配置类型
3315
3315
  *
@@ -3333,7 +3333,7 @@ type LLMConfig = z.infer<typeof LLMConfigSchema>;
3333
3333
  *
3334
3334
  * // 展示模型选择,不输出配置中的 apiKey。
3335
3335
  * function label(config: ResolvedModelConfig): string {
3336
- * return `${config.api}/${config.model}, timeout=${config.timeout}ms`
3336
+ * return `${config.protocol}/${config.model}, timeout=${config.timeout}ms`
3337
3337
  * }
3338
3338
  * ```
3339
3339
  */
@@ -3341,7 +3341,7 @@ interface ResolvedModelConfig {
3341
3341
  /** 模型名称(传给 API 的实际模型名) */
3342
3342
  model: string;
3343
3343
  /** API 协议(模型条目 > 全局配置 > `chat`) */
3344
- api: ApiType;
3344
+ protocol: ApiType;
3345
3345
  /** API Key(模型条目 > 全局配置 > 环境变量) */
3346
3346
  apiKey: string | undefined;
3347
3347
  /** API 基础 URL(模型条目 > 全局配置 > 环境变量 > 默认 OpenAI) */
@@ -3394,8 +3394,8 @@ declare function resolveModelEntry(llmConfig: LLMConfig, scenario: ModelScenario
3394
3394
  /**
3395
3395
  * 解析某次 chat 请求应使用的 API 协议(不校验 API Key)
3396
3396
  *
3397
- * 供 LLM Provider 路由层选择底层实现使用:优先取显式模型条目的 `api`,
3398
- * 其次全局 `api`,最后回退 `chat`。临时模型的 `api` 由调用方单独传入优先。
3397
+ * 供 LLM Provider 路由层选择底层实现使用:优先取显式模型条目的 `protocol`,
3398
+ * 其次全局 `protocol`,最后回退 `chat`。临时模型的 `protocol` 由调用方单独传入优先。
3399
3399
  *
3400
3400
  * @param llmConfig - LLM 配置
3401
3401
  * @param explicitModel - 显式指定的模型名/ID(可选)
@@ -3406,7 +3406,7 @@ declare function resolveModelEntry(llmConfig: LLMConfig, scenario: ModelScenario
3406
3406
  * ```ts
3407
3407
  * import { LLMConfigSchema, resolveModelApi } from '@h-ai/ai'
3408
3408
  *
3409
- * const config = LLMConfigSchema.parse({ models: [{ id: 'claude', model: 'claude-sonnet-4', api: 'anthropic' }] })
3409
+ * const config = LLMConfigSchema.parse({ models: [{ id: 'claude', model: 'claude-sonnet-4', protocol: 'anthropic' }] })
3410
3410
  * const protocol = resolveModelApi(config, 'claude')
3411
3411
  * ```
3412
3412
  */
@@ -4472,7 +4472,7 @@ declare const AIConfigSchema: z.ZodObject<{
4472
4472
  apiKey: z.ZodOptional<z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<string | undefined, string | null>>>;
4473
4473
  baseUrl: z.ZodOptional<z.ZodURL>;
4474
4474
  model: z.ZodDefault<z.ZodOptional<z.ZodString>>;
4475
- api: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
4475
+ protocol: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
4476
4476
  chat: "chat";
4477
4477
  responses: "responses";
4478
4478
  anthropic: "anthropic";
@@ -4484,7 +4484,7 @@ declare const AIConfigSchema: z.ZodObject<{
4484
4484
  models: z.ZodOptional<z.ZodArray<z.ZodObject<{
4485
4485
  id: z.ZodString;
4486
4486
  model: z.ZodString;
4487
- api: z.ZodOptional<z.ZodEnum<{
4487
+ protocol: z.ZodOptional<z.ZodEnum<{
4488
4488
  chat: "chat";
4489
4489
  responses: "responses";
4490
4490
  anthropic: "anthropic";
@@ -4494,7 +4494,7 @@ declare const AIConfigSchema: z.ZodObject<{
4494
4494
  maxTokens: z.ZodOptional<z.ZodNumber>;
4495
4495
  temperature: z.ZodOptional<z.ZodNumber>;
4496
4496
  timeout: z.ZodOptional<z.ZodNumber>;
4497
- }, z.core.$strip>>>;
4497
+ }, z.core.$strict>>>;
4498
4498
  scenarios: z.ZodOptional<z.ZodObject<{
4499
4499
  chat: z.ZodOptional<z.ZodString>;
4500
4500
  summary: z.ZodOptional<z.ZodString>;
@@ -4508,7 +4508,7 @@ declare const AIConfigSchema: z.ZodObject<{
4508
4508
  rerank: z.ZodOptional<z.ZodString>;
4509
4509
  fast: z.ZodOptional<z.ZodString>;
4510
4510
  }, z.core.$strip>>;
4511
- }, z.core.$strip>>;
4511
+ }, z.core.$strict>>;
4512
4512
  mcp: z.ZodOptional<z.ZodObject<{
4513
4513
  server: z.ZodOptional<z.ZodObject<{
4514
4514
  name: z.ZodString;
package/dist/browser.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as A2AAgentCardConfig, a as A2AApiKeySecurity, b as A2AAuthenticator, c as A2ACallOptions, d as A2ACallResult, e as A2ACallerIdentity, f as A2AConfig, g as A2AConfigSchema, h as A2AContextInfo, i as A2AHandleResult, j as A2AMessageRecord, k as A2AOperations, l as A2ASecurityConfig, m as A2ASkillConfigSchema, n as A2ATaskFilter, o as AIConfig, p as AIConfigInput, q as AIConfigSchema, r as AIFunctions, s as AIInitOptions, t as AIRelStore, u as AIRelStoreCompareAndSwap, v as AIRelStoreOptions, w as AIStoreProvider, x as AIVectorBackend, y as AIVectorStore, z as AIVersionedRecord, B as AUDIO_WS_PATH, C as ApiType, D as ApiTypeSchema, E as AskOptions, F as AssistantMessage, G as AudioConfig, H as AudioConfigSchema, I as AudioFormatSchema, J as AudioModelEntry, K as AudioModelEntrySchema, L as AudioOperation, M as AudioOperationSchema, N as AudioOperationsSchema, O as AudioProviderName, P as AudioProviderSchema, Q as AudioWsClientMessage, R as AudioWsClientMessageSchema, S as AudioWsDoneMessage, T as AudioWsDoneMessageSchema, U as AudioWsEndMessage, V as AudioWsErrorMessage, W as AudioWsSegmentDoneMessage, X as AudioWsSegmentStartedMessage, Y as AudioWsServerMessage, Z as AudioWsSpeechMessage, _ as AudioWsStartMessage, $ as AudioWsStartMessageSchema, a0 as AudioWsTextMessage, a1 as AudioWsTextMessageSchema, a2 as AudioWsTranscriptMessage, a3 as ChatCompletionChoice, a4 as ChatCompletionChunk, a5 as ChatCompletionDelta, a6 as ChatCompletionRequest, a7 as ChatCompletionResponse, a8 as ChatHistoryOptions, a9 as ChatMessage, aa as ChatRecord, ab as Citation, ac as CommitTurnInput, ad as CompressConfig, ae as CompressConfigSchema, af as CompressOperations, ag as CompressOptions, ah as CompressResult, ai as CompressionStrategy, aj as CompressionStrategySchema, ak as ConsolidateOptions, al as ConsolidateResult, am as ContextChatOptions, an as ContextChatResult, ao as ContextManager, ap as ContextManagerOptions, aq as ContextOperations, ar as ContextResetOptions, as as ContextStreamEvent, at as ConversationTurn, au as ConversationTurnStatus, av as DefineToolOptions, aw as DeveloperMessage, ax as EmbeddingConfig, ay as EmbeddingConfigSchema, az as EmbeddingItem, aA as EmbeddingOperations, aB as EmbeddingRequest, aC as EmbeddingResponse, aD as EntityDocumentRelation, aE as EntityDocumentResult, aF as EntityListOptions, aG as EntityQueryOptions, aH as EntityType, aI as EntityTypeSchema, aJ as FileConfig, aK as FileConfigSchema, aL as FileOperations, aM as FileParseMethod, aN as FileParseOptions, aO as FileParseRequest, aP as FileParseResult, aQ as GenerateImageRequest, aR as GenerateImageResult, aS as GenerateObjectRequest, aT as GeneratedImage, aU as HaiAIError, aV as ImageConfig, aW as ImageConfigSchema, aX as ImageContent, aY as ImageModelEntry, aZ as ImageModelEntrySchema, a_ as ImageOperations, a$ as ImageProviderName, b0 as ImageProviderSchema, b1 as ImageSize, b2 as InteractionScope, b3 as KnowledgeAskOptions, b4 as KnowledgeAskResult, b5 as KnowledgeConfig, b6 as KnowledgeConfigSchema, b7 as KnowledgeDocumentInfo, b8 as KnowledgeDocumentListOptions, b9 as KnowledgeDocumentMetadata, ba as KnowledgeDocumentRemoveOptions, bb as KnowledgeDocumentRevision, bc as KnowledgeEntity, bd as KnowledgeIngestBatchProgress, be as KnowledgeIngestBatchResult, bf as KnowledgeIngestFileInput, bg as KnowledgeIngestInput, bh as KnowledgeIngestResult, bi as KnowledgeOperations, bj as KnowledgeRepairOptions, bk as KnowledgeRepairProgress, bl as KnowledgeRepairResult, bm as KnowledgeRetrieveItem, bn as KnowledgeRetrieveOptions, bo as KnowledgeRetrieveResult, bp as KnowledgeSetupOptions, bq as KnowledgeStore, br as LLMConfig, bs as LLMConfigSchema, bt as LLMOperations, bu as MCPConfig, bv as MCPConfigSchema, bw as MCPContext, bx as MCPOperations, by as MCPPrompt, bz as MCPPromptArgument, bA as MCPPromptContent, bB as MCPPromptMessage, bC as MCPResource, bD as MCPResourceContent, bE as MCPServerCapabilities, bF as MCPServerCapabilitiesSchema, bG as MCPServerConfig, bH as MCPServerConfigSchema, bI as MCPToolDefinition, bJ as MCPToolHandler, bK as McpServerOptions, bL as MemoryAccessScope, bM as MemoryAdminOperations, bN as MemoryClearAllOptions, bO as MemoryClearOptions, bP as MemoryConfig, bQ as MemoryConfigSchema, bR as MemoryCoreOperations, bS as MemoryEntry, bT as MemoryEntryInput, bU as MemoryExtractOptions, bV as MemoryInjectionOptions, bW as MemoryListOptions, bX as MemoryListPageOptions, bY as MemoryOperations, bZ as MemoryRecallOptions, b_ as MemoryType, b$ as MemoryTypeSchema, c0 as MemoryUpdateInput, c1 as MessageContent, c2 as MessageRole, c3 as ModelEntry, c4 as ModelEntrySchema, c5 as ModelScenario, c6 as ModelScenarioSchema, c7 as ObjectRef, c8 as OptionalSecretSchema, c9 as OutputFormat, ca as PersonaOperations, cb as PersonaProfile, cc as PersonaProfileInput, cd as PersonaProfileUpdate, ce as PersonaScopeOptions, cf as RagContextItem, cg as RagOperations, ch as RagOptions, ci as RagResult, cj as RagStreamEvent, ck as ReasoningOperations, cl as ReasoningOptions, cm as ReasoningResult, cn as ReasoningStep, co as ReasoningStepType, cp as ReasoningStrategy, cq as ReasoningStreamEvent, cr as ReferenceImage, cs as RerankDocument, ct as RerankItem, cu as RerankOperations, cv as RerankRequest, cw as RerankResponse, cx as ResolveRequiredModelEntryOptions, cy as ResolvedAudioModel, cz as ResolvedImageModel, cA as ResolvedModelConfig, cB as RetrievalConfig, cC as RetrievalConfigSchema, cD as RetrievalOperations, cE as RetrievalRequest, cF as RetrievalResult, cG as RetrievalResultItem, cH as RetrievalSource, cI as RetrievalSourceConfig, cJ as RetrievalSourceSchema, cK as SSEDecoder, cL as SSEEvent, cM as ScopedMemoryBinding, cN as ScopedMemoryOperations, cO as SessionInfo, cP as StoreFilter, cQ as StorePage, cR as StoreScope, cS as StreamOperations, cT as StreamProcessor, cU as StreamResult, cV as SummaryConfig, cW as SummaryConfigSchema, cX as SummaryOperations, cY as SummaryOptions, cZ as SummaryResult, c_ as SystemMessage, c$ as TempModelConfig, d0 as TextContent, d1 as TokenConfig, d2 as TokenConfigSchema, d3 as TokenOperations, d4 as TokenUsage, d5 as Tool, d6 as ToolAuthorizationRequest, d7 as ToolAuthorizer, d8 as ToolCall, d9 as ToolDefinition, da as ToolErrorType, db as ToolExecutionContext, dc as ToolExecutionOptions, dd as ToolMessage, de as ToolRegistryOperations, df as ToolRegistryOptions, dg as ToolsOperations, dh as UserMessage, di as WhereClause, dj as WhereOperator, dk as WhereValue, dl as ensureAudioCredential, dm as resolveAudioModel, dn as resolveImageModel, dp as resolveModelApi, dq as resolveModelEntry, dr as serializePlayableAudio } from './ai-audio-ws-protocol-nfhO0tOo.js';
1
+ export { A as A2AAgentCardConfig, a as A2AApiKeySecurity, b as A2AAuthenticator, c as A2ACallOptions, d as A2ACallResult, e as A2ACallerIdentity, f as A2AConfig, g as A2AConfigSchema, h as A2AContextInfo, i as A2AHandleResult, j as A2AMessageRecord, k as A2AOperations, l as A2ASecurityConfig, m as A2ASkillConfigSchema, n as A2ATaskFilter, o as AIConfig, p as AIConfigInput, q as AIConfigSchema, r as AIFunctions, s as AIInitOptions, t as AIRelStore, u as AIRelStoreCompareAndSwap, v as AIRelStoreOptions, w as AIStoreProvider, x as AIVectorBackend, y as AIVectorStore, z as AIVersionedRecord, B as AUDIO_WS_PATH, C as ApiType, D as ApiTypeSchema, E as AskOptions, F as AssistantMessage, G as AudioConfig, H as AudioConfigSchema, I as AudioFormatSchema, J as AudioModelEntry, K as AudioModelEntrySchema, L as AudioOperation, M as AudioOperationSchema, N as AudioOperationsSchema, O as AudioProviderName, P as AudioProviderSchema, Q as AudioWsClientMessage, R as AudioWsClientMessageSchema, S as AudioWsDoneMessage, T as AudioWsDoneMessageSchema, U as AudioWsEndMessage, V as AudioWsErrorMessage, W as AudioWsSegmentDoneMessage, X as AudioWsSegmentStartedMessage, Y as AudioWsServerMessage, Z as AudioWsSpeechMessage, _ as AudioWsStartMessage, $ as AudioWsStartMessageSchema, a0 as AudioWsTextMessage, a1 as AudioWsTextMessageSchema, a2 as AudioWsTranscriptMessage, a3 as ChatCompletionChoice, a4 as ChatCompletionChunk, a5 as ChatCompletionDelta, a6 as ChatCompletionRequest, a7 as ChatCompletionResponse, a8 as ChatHistoryOptions, a9 as ChatMessage, aa as ChatRecord, ab as Citation, ac as CommitTurnInput, ad as CompressConfig, ae as CompressConfigSchema, af as CompressOperations, ag as CompressOptions, ah as CompressResult, ai as CompressionStrategy, aj as CompressionStrategySchema, ak as ConsolidateOptions, al as ConsolidateResult, am as ContextChatOptions, an as ContextChatResult, ao as ContextManager, ap as ContextManagerOptions, aq as ContextOperations, ar as ContextResetOptions, as as ContextStreamEvent, at as ConversationTurn, au as ConversationTurnStatus, av as DefineToolOptions, aw as DeveloperMessage, ax as EmbeddingConfig, ay as EmbeddingConfigSchema, az as EmbeddingItem, aA as EmbeddingOperations, aB as EmbeddingRequest, aC as EmbeddingResponse, aD as EntityDocumentRelation, aE as EntityDocumentResult, aF as EntityListOptions, aG as EntityQueryOptions, aH as EntityType, aI as EntityTypeSchema, aJ as FileConfig, aK as FileConfigSchema, aL as FileOperations, aM as FileParseMethod, aN as FileParseOptions, aO as FileParseRequest, aP as FileParseResult, aQ as GenerateImageRequest, aR as GenerateImageResult, aS as GenerateObjectRequest, aT as GeneratedImage, aU as HaiAIError, aV as ImageConfig, aW as ImageConfigSchema, aX as ImageContent, aY as ImageModelEntry, aZ as ImageModelEntrySchema, a_ as ImageOperations, a$ as ImageProviderName, b0 as ImageProviderSchema, b1 as ImageSize, b2 as InteractionScope, b3 as KnowledgeAskOptions, b4 as KnowledgeAskResult, b5 as KnowledgeConfig, b6 as KnowledgeConfigSchema, b7 as KnowledgeDocumentInfo, b8 as KnowledgeDocumentListOptions, b9 as KnowledgeDocumentMetadata, ba as KnowledgeDocumentRemoveOptions, bb as KnowledgeDocumentRevision, bc as KnowledgeEntity, bd as KnowledgeIngestBatchProgress, be as KnowledgeIngestBatchResult, bf as KnowledgeIngestFileInput, bg as KnowledgeIngestInput, bh as KnowledgeIngestResult, bi as KnowledgeOperations, bj as KnowledgeRepairOptions, bk as KnowledgeRepairProgress, bl as KnowledgeRepairResult, bm as KnowledgeRetrieveItem, bn as KnowledgeRetrieveOptions, bo as KnowledgeRetrieveResult, bp as KnowledgeSetupOptions, bq as KnowledgeStore, br as LLMConfig, bs as LLMConfigSchema, bt as LLMOperations, bu as MCPConfig, bv as MCPConfigSchema, bw as MCPContext, bx as MCPOperations, by as MCPPrompt, bz as MCPPromptArgument, bA as MCPPromptContent, bB as MCPPromptMessage, bC as MCPResource, bD as MCPResourceContent, bE as MCPServerCapabilities, bF as MCPServerCapabilitiesSchema, bG as MCPServerConfig, bH as MCPServerConfigSchema, bI as MCPToolDefinition, bJ as MCPToolHandler, bK as McpServerOptions, bL as MemoryAccessScope, bM as MemoryAdminOperations, bN as MemoryClearAllOptions, bO as MemoryClearOptions, bP as MemoryConfig, bQ as MemoryConfigSchema, bR as MemoryCoreOperations, bS as MemoryEntry, bT as MemoryEntryInput, bU as MemoryExtractOptions, bV as MemoryInjectionOptions, bW as MemoryListOptions, bX as MemoryListPageOptions, bY as MemoryOperations, bZ as MemoryRecallOptions, b_ as MemoryType, b$ as MemoryTypeSchema, c0 as MemoryUpdateInput, c1 as MessageContent, c2 as MessageRole, c3 as ModelEntry, c4 as ModelEntrySchema, c5 as ModelScenario, c6 as ModelScenarioSchema, c7 as ObjectRef, c8 as OptionalSecretSchema, c9 as OutputFormat, ca as PersonaOperations, cb as PersonaProfile, cc as PersonaProfileInput, cd as PersonaProfileUpdate, ce as PersonaScopeOptions, cf as RagContextItem, cg as RagOperations, ch as RagOptions, ci as RagResult, cj as RagStreamEvent, ck as ReasoningOperations, cl as ReasoningOptions, cm as ReasoningResult, cn as ReasoningStep, co as ReasoningStepType, cp as ReasoningStrategy, cq as ReasoningStreamEvent, cr as ReferenceImage, cs as RerankDocument, ct as RerankItem, cu as RerankOperations, cv as RerankRequest, cw as RerankResponse, cx as ResolveRequiredModelEntryOptions, cy as ResolvedAudioModel, cz as ResolvedImageModel, cA as ResolvedModelConfig, cB as RetrievalConfig, cC as RetrievalConfigSchema, cD as RetrievalOperations, cE as RetrievalRequest, cF as RetrievalResult, cG as RetrievalResultItem, cH as RetrievalSource, cI as RetrievalSourceConfig, cJ as RetrievalSourceSchema, cK as SSEDecoder, cL as SSEEvent, cM as ScopedMemoryBinding, cN as ScopedMemoryOperations, cO as SessionInfo, cP as StoreFilter, cQ as StorePage, cR as StoreScope, cS as StreamOperations, cT as StreamProcessor, cU as StreamResult, cV as SummaryConfig, cW as SummaryConfigSchema, cX as SummaryOperations, cY as SummaryOptions, cZ as SummaryResult, c_ as SystemMessage, c$ as TempModelConfig, d0 as TextContent, d1 as TokenConfig, d2 as TokenConfigSchema, d3 as TokenOperations, d4 as TokenUsage, d5 as Tool, d6 as ToolAuthorizationRequest, d7 as ToolAuthorizer, d8 as ToolCall, d9 as ToolDefinition, da as ToolErrorType, db as ToolExecutionContext, dc as ToolExecutionOptions, dd as ToolMessage, de as ToolRegistryOperations, df as ToolRegistryOptions, dg as ToolsOperations, dh as UserMessage, di as WhereClause, dj as WhereOperator, dk as WhereValue, dl as ensureAudioCredential, dm as resolveAudioModel, dn as resolveImageModel, dp as resolveModelApi, dq as resolveModelEntry, dr as serializePlayableAudio } from './ai-audio-ws-protocol-1VhScfis.js';
2
2
  export { A as AudioCapabilitiesRequest, a as AudioContent, b as AudioFormat, c as AudioInputStream, d as AudioModelCapabilities, e as AudioOperations, f as AudioReference, P as PlayableAudio, S as SynthesisEvent, g as SynthesisOptions, h as SynthesisRequest, i as SynthesisResult, j as SynthesisStreamRequest, k as SynthesisTextSegment, T as TranscriptionEvent, l as TranscriptionOptions, m as TranscriptionRequest, n as TranscriptionResult, o as TranscriptionSegment, p as TranscriptionStreamRequest, q as TranscriptionTimestampGranularity, r as TranscriptionWord } from './ai-audio-types-4R5yUAVl.js';
3
3
  export { AudioClientConfig, AudioClientOperations, AudioTicketRequest, createAudioClient } from './client/index.js';
4
4
  export { AgentCapabilities, AgentCard, AgentProvider, AgentSkill, Artifact, DataPart, FilePart, FileWithBytes, FileWithUri, Message, MessageSendParams, Part, PushNotificationConfig, Task, TaskArtifactUpdateEvent, TaskIdParams, TaskQueryParams, TaskState, TaskStatus, TaskStatusUpdateEvent, TextPart } from '@a2a-js/sdk';
package/dist/browser.js CHANGED
@@ -1,4 +1,4 @@
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-HEVXR252.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-GAC5RLAG.js';
2
2
  export { createAudioClient } from './chunk-GMQFIWND.js';
3
3
  export { HaiAIError } from './chunk-HYMP57AC.js';
4
4
  //# sourceMappingURL=browser.js.map
@@ -144,7 +144,8 @@ var en_US_default = {
144
144
  ai_a2aOutputLimit: "A2A output queue limit exceeded",
145
145
  ai_a2aExecutionInterrupted: "A2A execution interrupted",
146
146
  ai_a2aSubscriptionAdvanced: "A later message advanced the subscription",
147
- ai_a2aExecutorAlreadyRegistered: "A2A executor is already registered; close AI before replacing it"
147
+ ai_a2aExecutorAlreadyRegistered: "A2A executor is already registered; close AI before replacing it",
148
+ ai_llmProtocolRenamed: "LLM api was renamed to protocol. Update llm.protocol, models[].protocol, tempModel.protocol and HAI_AI_LLM_PROTOCOL / HAI_AI_LLM_MODELS_<index>_PROTOCOL environment variables."
148
149
  };
149
150
 
150
151
  // messages/ja-JP.json
@@ -282,7 +283,8 @@ var ja_JP_default = {
282
283
  ai_a2aOutputLimit: "A2A \u51FA\u529B\u30AD\u30E5\u30FC\u306E\u5BB9\u91CF\u4E0A\u9650\u3092\u8D85\u3048\u3066\u3044\u307E\u3059",
283
284
  ai_a2aExecutionInterrupted: "A2A \u5B9F\u884C\u304C\u4E2D\u65AD\u3055\u308C\u307E\u3057\u305F\u3002\u5916\u90E8\u3078\u306E\u5F71\u97FF\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044",
284
285
  ai_a2aSubscriptionAdvanced: "\u5F8C\u7D9A\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u30BF\u30B9\u30AF\u3092\u9032\u3081\u3066\u3044\u307E\u3059\u3002\u518D\u5EA6\u8CFC\u8AAD\u3057\u3066\u304F\u3060\u3055\u3044",
285
- ai_a2aExecutorAlreadyRegistered: "A2A \u5B9F\u884C\u5668\u306F\u65E2\u306B\u767B\u9332\u3055\u308C\u3066\u3044\u307E\u3059\u3002\u7F6E\u304D\u63DB\u3048\u308B\u524D\u306B AI \u3092\u7D42\u4E86\u3057\u3066\u304F\u3060\u3055\u3044"
286
+ ai_a2aExecutorAlreadyRegistered: "A2A \u5B9F\u884C\u5668\u306F\u65E2\u306B\u767B\u9332\u3055\u308C\u3066\u3044\u307E\u3059\u3002\u7F6E\u304D\u63DB\u3048\u308B\u524D\u306B AI \u3092\u7D42\u4E86\u3057\u3066\u304F\u3060\u3055\u3044",
287
+ ai_llmProtocolRenamed: "LLM \u306E api \u306F protocol \u306B\u5909\u66F4\u3055\u308C\u307E\u3057\u305F\u3002llm.protocol\u3001models[].protocol\u3001tempModel.protocol \u3068\u74B0\u5883\u5909\u6570 HAI_AI_LLM_PROTOCOL / HAI_AI_LLM_MODELS_<\u756A\u53F7>_PROTOCOL \u3092\u66F4\u65B0\u3057\u3066\u304F\u3060\u3055\u3044\u3002"
286
288
  };
287
289
 
288
290
  // messages/zh-CN.json
@@ -420,7 +422,8 @@ var zh_CN_default = {
420
422
  ai_a2aOutputLimit: "A2A \u8F93\u51FA\u961F\u5217\u5BB9\u91CF\u8D85\u9650",
421
423
  ai_a2aExecutionInterrupted: "A2A \u6267\u884C\u5DF2\u4E2D\u65AD\uFF0C\u987B\u6838\u5BF9\u5916\u90E8\u6548\u679C",
422
424
  ai_a2aSubscriptionAdvanced: "\u540E\u7EED\u6D88\u606F\u5DF2\u63A8\u8FDB\u4EFB\u52A1\uFF0C\u8BF7\u91CD\u65B0\u8BA2\u9605",
423
- ai_a2aExecutorAlreadyRegistered: "A2A \u6267\u884C\u5668\u5DF2\u6CE8\u518C\uFF0C\u66F4\u6362\u524D\u8BF7\u5173\u95ED AI"
425
+ ai_a2aExecutorAlreadyRegistered: "A2A \u6267\u884C\u5668\u5DF2\u6CE8\u518C\uFF0C\u66F4\u6362\u524D\u8BF7\u5173\u95ED AI",
426
+ ai_llmProtocolRenamed: "LLM \u7684 api \u5DF2\u6539\u540D\u4E3A protocol\u3002\u8BF7\u66F4\u65B0 llm.protocol\u3001models[].protocol\u3001tempModel.protocol \u53CA HAI_AI_LLM_PROTOCOL / HAI_AI_LLM_MODELS_<\u7D22\u5F15>_PROTOCOL \u73AF\u5883\u53D8\u91CF\u3002"
424
427
  };
425
428
 
426
429
  // src/ai-i18n.ts
@@ -436,13 +439,13 @@ var OptionalSecretSchema = z.string().nullable().transform(
436
439
  ).optional();
437
440
  var ModelScenarioSchema = z.enum(["default", "chat", "reasoning", "plan", "execute", "extraction", "summary", "embedding", "rerank", "ocr", "fast"]);
438
441
  var ApiTypeSchema = z.enum(["chat", "responses", "anthropic"]);
439
- var ModelEntrySchema = z.object({
442
+ var ModelEntrySchema = z.strictObject({
440
443
  /** 模型唯一标识(用于 ModelResolver 解析) */
441
444
  id: z.string(),
442
445
  /** 模型名称(传给 API 的实际模型名) */
443
446
  model: z.string(),
444
- /** API 协议(可选,未指定时回退全局 `api`,再回退 `chat`;决定走 Chat Completions / Responses / Anthropic) */
445
- api: ApiTypeSchema.optional(),
447
+ /** API 协议(可选,未指定时回退全局 `protocol`,再回退 `chat`;决定走 Chat Completions / Responses / Anthropic) */
448
+ protocol: ApiTypeSchema.optional(),
446
449
  /** API Key 覆盖(可选,未提供时使用全局配置) */
447
450
  apiKey: OptionalSecretSchema,
448
451
  /** Base URL 覆盖(可选) */
@@ -453,21 +456,21 @@ var ModelEntrySchema = z.object({
453
456
  temperature: z.number().min(0).max(2).optional(),
454
457
  /** 超时覆盖(可选,毫秒) */
455
458
  timeout: z.number().positive().optional()
456
- });
457
- var LLMConfigSchema = z.object({
458
- /** 全局 API Key(各模型 fallback;未提供时回退到 `process.env.HAI_AI_LLM_APIKEY` 或 `process.env.OPENAI_API_KEY`) */
459
+ }, { error: (issue) => issue.code === "unrecognized_keys" && issue.keys.includes("api") ? aiM("ai_llmProtocolRenamed") : void 0 });
460
+ var LLMConfigSchema = z.strictObject({
461
+ /** 默认服务密钥;模型项可单独覆盖。未填写时读取 HAI_AI_LLM_APIKEY 或对应供应商密钥变量,真实值只放服务端。 */
459
462
  apiKey: OptionalSecretSchema,
460
- /** 全局 API 基础 URL(各模型 fallback;未提供时回退到 `process.env.HAI_AI_LLM_BASEURL` 或 `process.env.OPENAI_BASE_URL`) */
463
+ /** 默认模型服务地址;使用代理时填写,模型项可覆盖。未填写时按协议读取环境地址或使用供应商默认地址。 */
461
464
  baseUrl: z.url().optional(),
462
465
  /** 默认模型名称(默认 `'gpt-4o-mini'`) */
463
466
  model: z.string().optional().default("gpt-4o-mini"),
464
- /** 全局 API 协议(各模型 fallback,默认 `'chat'`;可选 `chat` / `responses` / `anthropic`) */
465
- api: ApiTypeSchema.optional().default("chat"),
466
- /** 全局最大 Token 数(各模型 fallback,默认 `4096`) */
467
+ /** 默认请求格式:chat 为 Chat Completions,responses 为 OpenAI Responses,anthropic 为 Anthropic Messages;模型项可覆盖。 */
468
+ protocol: ApiTypeSchema.optional().default("chat"),
469
+ /** 单次回答最多生成多少 Token,默认 4096;模型项可覆盖,需符合供应商限制。 */
467
470
  maxTokens: z.number().positive().optional().default(4096),
468
- /** 全局采样温度(各模型 fallback,范围 `[0, 2]`,默认 `0.7`) */
471
+ /** 回答的随机程度,0–2,默认 0.7;较低通常更稳定,模型项可覆盖,部分模型不支持自定义。 */
469
472
  temperature: z.number().min(0).max(2).optional().default(0.7),
470
- /** 全局请求超时时间(各模型 fallback,毫秒,默认 `60000`) */
473
+ /** 一次模型请求最多等待多少毫秒,默认 60000;模型项可覆盖。 */
471
474
  timeout: z.number().positive().optional().default(6e4),
472
475
  /** 临时模型客户端缓存存活时间(毫秒,默认 `600000` = 10 分钟;超时后临时模型客户端实例失效并重建) */
473
476
  tempModelCacheTtl: z.number().positive().optional().default(6e5),
@@ -475,7 +478,7 @@ var LLMConfigSchema = z.object({
475
478
  models: z.array(ModelEntrySchema).optional(),
476
479
  /** 场景模型映射(场景名 → 模型 ID 或直接模型名称,各场景均可选) */
477
480
  scenarios: z.object(Object.fromEntries(ModelScenarioSchema.options.map((k) => [k, z.string().optional()]))).optional()
478
- });
481
+ }, { error: (issue) => issue.code === "unrecognized_keys" && issue.keys.includes("api") ? aiM("ai_llmProtocolRenamed") : void 0 });
479
482
  function resolveModelEntry(llmConfig, scenario, explicit, options) {
480
483
  let entry;
481
484
  let modelName;
@@ -493,7 +496,7 @@ function resolveModelEntry(llmConfig, scenario, explicit, options) {
493
496
  }
494
497
  const resolved = {
495
498
  model: modelName,
496
- api: entry?.api ?? llmConfig.api ?? "chat",
499
+ protocol: entry?.protocol ?? llmConfig.protocol ?? "chat",
497
500
  apiKey: entry?.apiKey ?? llmConfig.apiKey ?? (process.env.HAI_AI_LLM_APIKEY?.trim() || process.env.OPENAI_API_KEY),
498
501
  baseUrl: entry?.baseUrl ?? llmConfig.baseUrl ?? (process.env.HAI_AI_LLM_BASEURL?.trim() || process.env.OPENAI_BASE_URL) ?? "https://api.openai.com/v1",
499
502
  maxTokens: entry?.maxTokens ?? llmConfig.maxTokens ?? 4096,
@@ -509,7 +512,7 @@ function resolveModelApi(llmConfig, explicitModel, tempApi) {
509
512
  if (tempApi)
510
513
  return tempApi;
511
514
  const entry = explicitModel ? llmConfig.models?.find((m) => m.id === explicitModel || m.model === explicitModel) : void 0;
512
- return entry?.api ?? llmConfig.api ?? "chat";
515
+ return entry?.protocol ?? llmConfig.protocol ?? "chat";
513
516
  }
514
517
  var MCPServerCapabilitiesSchema = z.object({
515
518
  /** 是否支持工具调用(默认 `true`) */
@@ -882,7 +885,7 @@ var AIConfigSchema = z.object({
882
885
  /** LLM 配置(可选,所有字段有默认值) */
883
886
  llm: LLMConfigSchema.default({
884
887
  model: "gpt-4o-mini",
885
- api: "chat",
888
+ protocol: "chat",
886
889
  maxTokens: 4096,
887
890
  temperature: 0.7,
888
891
  timeout: 6e4,
@@ -961,5 +964,5 @@ var AudioWsDoneMessageSchema = AudioWsDoneMessageSchema$1;
961
964
  var AudioWsClientMessageSchema = AudioWsClientMessageSchema$1;
962
965
 
963
966
  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 };
964
- //# sourceMappingURL=chunk-HEVXR252.js.map
965
- //# sourceMappingURL=chunk-HEVXR252.js.map
967
+ //# sourceMappingURL=chunk-GAC5RLAG.js.map
968
+ //# sourceMappingURL=chunk-GAC5RLAG.js.map