@h-ai/ai 1.0.0-beta.35 → 1.0.0-beta.36

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.
@@ -1,17 +1,23 @@
1
+ import { McpServer as McpServer$2 } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { SSEServerTransport as SSEServerTransport$1 } from '@modelcontextprotocol/sdk/server/sse.js';
3
+ import { StdioServerTransport as StdioServerTransport$1 } from '@modelcontextprotocol/sdk/server/stdio.js';
4
+ import { StreamableHTTPServerTransport as StreamableHTTPServerTransport$1 } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
5
+ import * as _a2a_js_sdk_server from '@a2a-js/sdk/server';
6
+ import { AgentExecutor, AgentEvent } from '@a2a-js/sdk/server';
7
+ import * as _a2a_js_sdk from '@a2a-js/sdk';
8
+ import { TaskState, Message as Message$1, Part as Part$1, SendMessageRequest as SendMessageRequest$1, Task as Task$1, TaskArtifactUpdateEvent as TaskArtifactUpdateEvent$1, TaskStatus as TaskStatus$1, TaskStatusUpdateEvent as TaskStatusUpdateEvent$1 } from '@a2a-js/sdk';
1
9
  import * as _h_ai_core from '@h-ai/core';
2
10
  import { HaiResult, HaiError } from '@h-ai/core';
11
+ import { a as AudioContent, P as PlayableAudio, e as AudioOperations, b as AudioFormat } from './ai-audio-types-C4n15IHq.js';
3
12
  import * as _h_ai_runner from '@h-ai/runner';
4
13
  import { RunnerJson, RunnerScope, RunnerFunctions } from '@h-ai/runner';
5
- import { TaskState } from '@a2a-js/sdk';
6
- import { AgentExecutor } from '@a2a-js/sdk/server';
7
14
  import * as zod from 'zod';
8
15
  import { z, ZodType } from 'zod';
9
16
  import { F as FileOperations } from './ai-file-types-BMfnQU4W.js';
10
17
  import { CleanOptionsInput, ChunkOptionsInput } from '@h-ai/datapipe';
11
- import { e as AudioOperations, a as AudioContent, P as PlayableAudio, b as AudioFormat } from './ai-audio-types-4R5yUAVl.js';
12
18
  import * as zod_v4_core from 'zod/v4/core';
13
19
  import * as _agentclientprotocol_sdk from '@agentclientprotocol/sdk';
14
- import { McpServer, ContentBlock, RequestPermissionRequest, SessionNotification, ClientRequestHandlersByMethod, ClientCapabilities } from '@agentclientprotocol/sdk';
20
+ import { McpServer as McpServer$1, ContentBlock, RequestPermissionRequest, SessionNotification, ClientRequestHandlersByMethod, ClientCapabilities } from '@agentclientprotocol/sdk';
15
21
  import { ToolDefinition as ToolDefinition$1, ToolRegistryOperations as ToolRegistryOperations$1, ToolExecutionOptions } from '@h-ai/tools';
16
22
  import OpenAI from 'openai';
17
23
  import { ToolServiceContext, ToolSet, ToolArtifactAccess, ToolSubmitRequest, ToolService, ToolArtifact, ToolArtifactReference } from '@h-ai/tools/server';
@@ -1382,7 +1388,7 @@ interface AIVectorBackend {
1382
1388
  *
1383
1389
  * @example
1384
1390
  * ```ts
1385
- * import { ai, type AIStoreProvider, type AIConfigInput } from '@h-ai/ai'
1391
+ * import { type AIStoreProvider, type AIConfigInput, ai } from '@h-ai/ai'
1386
1392
  * // provider 的 shared 声明必须由真实共享后端支撑;AI 关闭时调用其 close。
1387
1393
  * async function start(config: AIConfigInput, provider: AIStoreProvider) {
1388
1394
  * const result = await ai.init(config, { storeProvider: provider })
@@ -1435,7 +1441,7 @@ interface AIStoreProvider {
1435
1441
  *
1436
1442
  * @example
1437
1443
  * ```ts
1438
- * import { ai, type MCPToolDefinition } from '@h-ai/ai'
1444
+ * import { type MCPToolDefinition, ai } from '@h-ai/ai'
1439
1445
  * // 应用启动已成功初始化 ai;echo 为无外部副作用的示例工具。
1440
1446
  * const definition: MCPToolDefinition = { name: 'echo', description: '返回输入', inputSchema: { type: 'object', properties: { text: { type: 'string' } }, required: ['text'], additionalProperties: false } }
1441
1447
  * const registered = ai.mcp.registerTool(definition, (input: { text: string }) => ({ text: input.text }))
@@ -1586,9 +1592,9 @@ type MCPPromptContent = PromptMessage['content'];
1586
1592
  *
1587
1593
  * @example
1588
1594
  * ```ts
1589
- * import { createMcpServer, type McpServerOptions } from '@h-ai/ai'
1595
+ * import { type McpServerOptions, ai } from '@h-ai/ai'
1590
1596
  * const options: McpServerOptions = { name: 'public-tools', version: '1.0.0' }
1591
- * const server = createMcpServer(options)
1597
+ * const server = ai.createMcpServer(options)
1592
1598
  * // 应用停止接入请求后关闭 SDK server。
1593
1599
  * await server.close()
1594
1600
  * ```
@@ -1606,7 +1612,7 @@ interface McpServerOptions {
1606
1612
  *
1607
1613
  * @example
1608
1614
  * ```ts
1609
- * import { ai, type MCPOperations } from '@h-ai/ai'
1615
+ * import { type MCPOperations, ai } from '@h-ai/ai'
1610
1616
  * // 应用启动已成功初始化 ai。
1611
1617
  * const mcp: MCPOperations = ai.mcp
1612
1618
  * const registered = mcp.registerTool({ name: 'echo', description: '返回输入', inputSchema: { type: 'string' } }, (input: string) => input)
@@ -1687,9 +1693,9 @@ interface MCPJobFileContext {
1687
1693
  * 应用提供对象 ACL 与存储接入。文件内容只在作业节点暂存,队列仅保存对象 ID。
1688
1694
  * @example
1689
1695
  * ```ts
1690
- * import { err, type HaiResult } from '@h-ai/core'
1696
+ * import { type HaiResult, core } from '@h-ai/core'
1691
1697
  * import { HaiAIError, type MCPJobFiles } from '@h-ai/ai'
1692
- * function denied<T>(): HaiResult<T> { return err(HaiAIError.MCP_TOOL_FORBIDDEN, 'File is not authorized') }
1698
+ * function denied<T>(): HaiResult<T> { return core.err(HaiAIError.MCP_TOOL_FORBIDDEN, 'File is not authorized') }
1693
1699
  * const files: MCPJobFiles = { read: async () => denied(), publish: async () => denied() }
1694
1700
  * ```
1695
1701
  */
@@ -1713,7 +1719,7 @@ interface MCPJobFiles {
1713
1719
  * 通过现有合并目录调用受控的第三方 Streamable HTTP 工具。
1714
1720
  * @example
1715
1721
  * ```ts
1716
- * import { ai, type MCPServiceAuthorization } from '@h-ai/ai'
1722
+ * import { type MCPServiceAuthorization, ai } from '@h-ai/ai'
1717
1723
  * async function search(context: MCPServiceAuthorization) {
1718
1724
  * const result = await ai.mcp.services.invoke({ serviceId: 'docs', tool: 'search', arguments: { query: 'manual' } }, context)
1719
1725
  * if (!result.success) return result
@@ -1783,7 +1789,7 @@ interface MCPServiceBindingRequest {
1783
1789
  */
1784
1790
  interface MCPServiceBinding {
1785
1791
  /** 仅传给当前 Agent,含短期 Bearer。 */
1786
- servers: Array<Extract<McpServer, {
1792
+ servers: Array<Extract<McpServer$1, {
1787
1793
  type: 'http';
1788
1794
  }>>;
1789
1795
  revoke: () => void;
@@ -2615,7 +2621,7 @@ type CompressionStrategy = z.infer<typeof CompressionStrategySchema>;
2615
2621
  *
2616
2622
  * @example
2617
2623
  * ```ts
2618
- * import { ai, type CompressOptions } from '@h-ai/ai'
2624
+ * import { type CompressOptions, ai } from '@h-ai/ai'
2619
2625
  * // 应用启动已成功初始化 ai。
2620
2626
  * async function run(options: CompressOptions) {
2621
2627
  * const result = await ai.compress.tryCompress([{ role: 'user', content: '你好' }], options)
@@ -2668,7 +2674,7 @@ interface CompressResult {
2668
2674
  *
2669
2675
  * @example
2670
2676
  * ```ts
2671
- * import { ai, type CompressOperations } from '@h-ai/ai'
2677
+ * import { type CompressOperations, ai } from '@h-ai/ai'
2672
2678
  * // 应用启动已成功初始化 ai。
2673
2679
  * const operations: CompressOperations = ai.compress
2674
2680
  * const result = await operations.tryCompress([{ role: 'user', content: '你好' }], { strategy: 'sliding-window', maxTokens: 100 })
@@ -2729,7 +2735,7 @@ interface Citation {
2729
2735
  *
2730
2736
  * @example
2731
2737
  * ```ts
2732
- * import { ai, type RetrievalSource } from '@h-ai/ai'
2738
+ * import { type RetrievalSource, ai } from '@h-ai/ai'
2733
2739
  * // 应用启动已成功初始化 ai,且目标知识集合已 setup。
2734
2740
  * async function run(options: RetrievalSource) {
2735
2741
  * const result = await ai.retrieval.addSource(options)
@@ -2759,7 +2765,7 @@ interface RetrievalSource {
2759
2765
  *
2760
2766
  * @example
2761
2767
  * ```ts
2762
- * import { ai, type RetrievalRequest } from '@h-ai/ai'
2768
+ * import { type RetrievalRequest, ai } from '@h-ai/ai'
2763
2769
  * // 应用启动已成功初始化 ai,且目标知识集合已 setup。
2764
2770
  * async function run(options: RetrievalRequest) {
2765
2771
  * const result = await ai.retrieval.retrieve(options)
@@ -2829,7 +2835,7 @@ interface RetrievalResult {
2829
2835
  *
2830
2836
  * @example
2831
2837
  * ```ts
2832
- * import { ai, type RetrievalOperations } from '@h-ai/ai'
2838
+ * import { type RetrievalOperations, ai } from '@h-ai/ai'
2833
2839
  * // 应用启动已成功初始化 ai,docs 为已注册检索源。
2834
2840
  * const operations: RetrievalOperations = ai.retrieval
2835
2841
  * const result = await operations.retrieve({ query: '部署要求', sources: ['docs'], topK: 3 })
@@ -2965,7 +2971,7 @@ interface EntityDocumentRelation {
2965
2971
  *
2966
2972
  * @example
2967
2973
  * ```ts
2968
- * import { ai, type KnowledgeSetupOptions } from '@h-ai/ai'
2974
+ * import { type KnowledgeSetupOptions, ai } from '@h-ai/ai'
2969
2975
  * // 应用启动已成功初始化 ai,且目标知识集合已 setup。
2970
2976
  * async function run(options: KnowledgeSetupOptions) {
2971
2977
  * const result = await ai.knowledge.setup(options)
@@ -2985,7 +2991,7 @@ interface KnowledgeSetupOptions {
2985
2991
  *
2986
2992
  * @example
2987
2993
  * ```ts
2988
- * import { ai, type KnowledgeIngestInput } from '@h-ai/ai'
2994
+ * import { type KnowledgeIngestInput, ai } from '@h-ai/ai'
2989
2995
  * // 应用启动已成功初始化 ai,且目标知识集合已 setup。
2990
2996
  * async function run(options: KnowledgeIngestInput) {
2991
2997
  * const result = await ai.knowledge.ingest(options)
@@ -3062,7 +3068,7 @@ interface KnowledgeIngestResult {
3062
3068
  *
3063
3069
  * @example
3064
3070
  * ```ts
3065
- * import { ai, type KnowledgeRepairOptions } from '@h-ai/ai'
3071
+ * import { type KnowledgeRepairOptions, ai } from '@h-ai/ai'
3066
3072
  * // 应用启动已成功初始化 ai,且目标知识集合已 setup。
3067
3073
  * async function run(options: KnowledgeRepairOptions) {
3068
3074
  * const result = await ai.knowledge.repair(options)
@@ -3100,7 +3106,7 @@ interface KnowledgeRepairResult {
3100
3106
  *
3101
3107
  * @example
3102
3108
  * ```ts
3103
- * import { ai, type KnowledgeRetrieveOptions } from '@h-ai/ai'
3109
+ * import { type KnowledgeRetrieveOptions, ai } from '@h-ai/ai'
3104
3110
  * // 应用启动已成功初始化 ai,且目标知识集合已 setup。
3105
3111
  * async function run(options: KnowledgeRetrieveOptions) {
3106
3112
  * const result = await ai.knowledge.retrieve('部署要求', options)
@@ -3173,7 +3179,7 @@ interface KnowledgeRetrieveResult {
3173
3179
  *
3174
3180
  * @example
3175
3181
  * ```ts
3176
- * import { ai, type KnowledgeAskOptions } from '@h-ai/ai'
3182
+ * import { type KnowledgeAskOptions, ai } from '@h-ai/ai'
3177
3183
  * // 应用启动已成功初始化 ai,且目标知识集合已 setup。
3178
3184
  * async function run(options: KnowledgeAskOptions) {
3179
3185
  * const result = await ai.knowledge.ask('如何部署?', options)
@@ -3225,7 +3231,7 @@ interface KnowledgeAskResult {
3225
3231
  *
3226
3232
  * @example
3227
3233
  * ```ts
3228
- * import { ai, type EntityQueryOptions } from '@h-ai/ai'
3234
+ * import { type EntityQueryOptions, ai } from '@h-ai/ai'
3229
3235
  * // 应用启动已成功初始化 ai,且目标知识集合已 setup。
3230
3236
  * async function run(options: EntityQueryOptions) {
3231
3237
  * const result = await ai.knowledge.findByEntity('HAI', options)
@@ -3267,7 +3273,7 @@ interface EntityDocumentResult {
3267
3273
  *
3268
3274
  * @example
3269
3275
  * ```ts
3270
- * import { ai, type EntityListOptions } from '@h-ai/ai'
3276
+ * import { type EntityListOptions, ai } from '@h-ai/ai'
3271
3277
  * // 应用启动已成功初始化 ai,且目标知识集合已 setup。
3272
3278
  * async function run(options: EntityListOptions) {
3273
3279
  * const result = await ai.knowledge.listEntities(options)
@@ -3293,7 +3299,7 @@ interface EntityListOptions {
3293
3299
  *
3294
3300
  * @example
3295
3301
  * ```ts
3296
- * import { ai, type KnowledgeIngestFileInput } from '@h-ai/ai'
3302
+ * import { type KnowledgeIngestFileInput, ai } from '@h-ai/ai'
3297
3303
  * // 应用启动已成功初始化 ai,且目标知识集合已 setup。
3298
3304
  * async function run(options: KnowledgeIngestFileInput) {
3299
3305
  * const result = await ai.knowledge.ingestFile(options)
@@ -3353,7 +3359,7 @@ interface KnowledgeDocumentInfo {
3353
3359
  *
3354
3360
  * @example
3355
3361
  * ```ts
3356
- * import { ai, type KnowledgeDocumentListOptions } from '@h-ai/ai'
3362
+ * import { type KnowledgeDocumentListOptions, ai } from '@h-ai/ai'
3357
3363
  * // 应用启动已成功初始化 ai,且目标知识集合已 setup。
3358
3364
  * async function run(options: KnowledgeDocumentListOptions) {
3359
3365
  * const result = await ai.knowledge.listDocuments(options)
@@ -3375,7 +3381,7 @@ interface KnowledgeDocumentListOptions {
3375
3381
  *
3376
3382
  * @example
3377
3383
  * ```ts
3378
- * import { ai, type KnowledgeDocumentRemoveOptions } from '@h-ai/ai'
3384
+ * import { type KnowledgeDocumentRemoveOptions, ai } from '@h-ai/ai'
3379
3385
  * // 应用启动已成功初始化 ai,且目标知识集合已 setup。
3380
3386
  * async function run(options: KnowledgeDocumentRemoveOptions) {
3381
3387
  * const result = await ai.knowledge.removeDocument('guide', options)
@@ -3616,7 +3622,7 @@ type MemoryType = z.infer<typeof MemoryTypeSchema>;
3616
3622
  *
3617
3623
  * @example
3618
3624
  * ```ts
3619
- * import { ai, type MemoryEntryInput } from '@h-ai/ai'
3625
+ * import { type MemoryEntryInput, ai } from '@h-ai/ai'
3620
3626
  * // 应用启动已成功初始化 ai。
3621
3627
  * async function run(options: MemoryEntryInput) {
3622
3628
  * const result = await ai.memory.add(options)
@@ -3678,7 +3684,7 @@ interface MemoryEntry {
3678
3684
  *
3679
3685
  * @example
3680
3686
  * ```ts
3681
- * import { ai, type MemoryExtractOptions } from '@h-ai/ai'
3687
+ * import { type MemoryExtractOptions, ai } from '@h-ai/ai'
3682
3688
  * // 应用启动已成功初始化 ai。
3683
3689
  * async function run(options: MemoryExtractOptions) {
3684
3690
  * const result = await ai.memory.extract([{ role: 'user', content: '以后请用中文' }], options)
@@ -3715,7 +3721,7 @@ interface MemoryExtractOptions {
3715
3721
  *
3716
3722
  * @example
3717
3723
  * ```ts
3718
- * import { ai, type MemoryRecallOptions } from '@h-ai/ai'
3724
+ * import { type MemoryRecallOptions, ai } from '@h-ai/ai'
3719
3725
  * // 应用启动已成功初始化 ai。
3720
3726
  * async function run(options: MemoryRecallOptions) {
3721
3727
  * const result = await ai.memory.recall('语言偏好', options)
@@ -3752,7 +3758,7 @@ interface MemoryRecallOptions {
3752
3758
  *
3753
3759
  * @example
3754
3760
  * ```ts
3755
- * import { ai, type MemoryInjectionOptions } from '@h-ai/ai'
3761
+ * import { type MemoryInjectionOptions, ai } from '@h-ai/ai'
3756
3762
  * // 应用启动已成功初始化 ai。
3757
3763
  * async function run(options: MemoryInjectionOptions) {
3758
3764
  * const result = await ai.memory.injectMemories([{ role: 'user', content: '你好' }], options)
@@ -3788,7 +3794,7 @@ interface MemoryInjectionOptions {
3788
3794
  *
3789
3795
  * @example
3790
3796
  * ```ts
3791
- * import { ai, type MemoryListOptions } from '@h-ai/ai'
3797
+ * import { type MemoryListOptions, ai } from '@h-ai/ai'
3792
3798
  * // 应用启动已成功初始化 ai。
3793
3799
  * async function run(options: MemoryListOptions) {
3794
3800
  * const result = await ai.memory.list(options)
@@ -3812,7 +3818,7 @@ interface MemoryListOptions {
3812
3818
  *
3813
3819
  * @example
3814
3820
  * ```ts
3815
- * import { ai, type MemoryListPageOptions } from '@h-ai/ai'
3821
+ * import { type MemoryListPageOptions, ai } from '@h-ai/ai'
3816
3822
  * // 应用启动已成功初始化 ai。
3817
3823
  * async function run(options: MemoryListPageOptions) {
3818
3824
  * const result = await ai.memory.listPage(options)
@@ -3841,7 +3847,7 @@ interface MemoryListPageOptions {
3841
3847
  *
3842
3848
  * @example
3843
3849
  * ```ts
3844
- * import { ai, type MemoryClearOptions } from '@h-ai/ai'
3850
+ * import { type MemoryClearOptions, ai } from '@h-ai/ai'
3845
3851
  * // 应用启动已成功初始化 ai。
3846
3852
  * async function run(options: MemoryClearOptions) {
3847
3853
  * const result = await ai.memory.clear(options)
@@ -3865,7 +3871,7 @@ interface MemoryClearOptions {
3865
3871
  *
3866
3872
  * @example
3867
3873
  * ```ts
3868
- * import { ai, type MemoryUpdateInput } from '@h-ai/ai'
3874
+ * import { type MemoryUpdateInput, ai } from '@h-ai/ai'
3869
3875
  * async function updateOwnedMemory(memoryId: string, userId: string) {
3870
3876
  * const input: MemoryUpdateInput = { importance: 0.9, metadata: { source: 'confirmed' } }
3871
3877
  * const result = await ai.memory.update(memoryId, input, { objectId: userId })
@@ -3893,7 +3899,7 @@ interface MemoryUpdateInput {
3893
3899
  *
3894
3900
  * @example
3895
3901
  * ```ts
3896
- * import { ai, type MemoryAccessScope } from '@h-ai/ai'
3902
+ * import { type MemoryAccessScope, ai } from '@h-ai/ai'
3897
3903
  * async function readOwnedMemory(memoryId: string, trustedUserId: string) {
3898
3904
  * const scope: MemoryAccessScope = { objectId: trustedUserId, scope: { topicId: 'profile' } }
3899
3905
  * const result = await ai.memory.get(memoryId, scope)
@@ -3916,7 +3922,7 @@ interface MemoryAccessScope {
3916
3922
  *
3917
3923
  * @example
3918
3924
  * ```ts
3919
- * import { ai, type ScopedMemoryBinding } from '@h-ai/ai'
3925
+ * import { type ScopedMemoryBinding, ai } from '@h-ai/ai'
3920
3926
  * const binding: ScopedMemoryBinding = { objectId: 'user-1', scope: { topicId: 'profile' } }
3921
3927
  * const memory = ai.memory.scoped(binding)
3922
3928
  * const result = await memory.list({ limit: 10 })
@@ -4097,7 +4103,7 @@ interface MemoryCoreOperations {
4097
4103
  *
4098
4104
  * @example
4099
4105
  * ```ts
4100
- * import { ai, type ScopedMemoryOperations } from '@h-ai/ai'
4106
+ * import { type ScopedMemoryOperations, ai } from '@h-ai/ai'
4101
4107
  * const memory: ScopedMemoryOperations = ai.memory.scoped({ objectId: 'user-1', scope: { topicId: 'profile' } })
4102
4108
  * const result = await memory.add({ content: '偏好中文', type: 'preference' })
4103
4109
  * if (!result.success) throw new Error(result.error.message)
@@ -4135,7 +4141,7 @@ interface ScopedMemoryOperations {
4135
4141
  *
4136
4142
  * @example
4137
4143
  * ```ts
4138
- * import { ai, type MemoryOperations } from '@h-ai/ai'
4144
+ * import { type MemoryOperations, ai } from '@h-ai/ai'
4139
4145
  * const operations: MemoryOperations = ai.memory
4140
4146
  * const result = await operations.scoped({ objectId: 'user-1' }).recall('语言偏好', { topK: 3 })
4141
4147
  * if (!result.success) throw new Error(result.error.message)
@@ -4155,6 +4161,13 @@ interface MemoryOperations extends MemoryCoreOperations {
4155
4161
  admin: MemoryAdminOperations;
4156
4162
  }
4157
4163
 
4164
+ /**
4165
+ * @h-ai/ai — 错误码 + 配置 Schema
4166
+ *
4167
+ * 定义 AI 模块的错误码常量、Zod Schema 和配置类型。
4168
+ * @module ai-config
4169
+ */
4170
+
4158
4171
  /**
4159
4172
  * 可选密钥 Schema。
4160
4173
  *
@@ -4207,8 +4220,8 @@ declare const OptionalSecretSchema: z.ZodOptional<z.ZodPipe<z.ZodNullable<z.ZodS
4207
4220
  */
4208
4221
  declare const ModelScenarioSchema: z.ZodEnum<{
4209
4222
  default: "default";
4210
- chat: "chat";
4211
4223
  reasoning: "reasoning";
4224
+ chat: "chat";
4212
4225
  plan: "plan";
4213
4226
  execute: "execute";
4214
4227
  extraction: "extraction";
@@ -4436,8 +4449,8 @@ declare const LLMConfigSchema: z.ZodObject<{
4436
4449
  }, z.core.$strict>>>;
4437
4450
  scenarios: z.ZodOptional<z.ZodObject<{
4438
4451
  default: z.ZodOptional<z.ZodString>;
4439
- chat: z.ZodOptional<z.ZodString>;
4440
4452
  reasoning: z.ZodOptional<z.ZodString>;
4453
+ chat: z.ZodOptional<z.ZodString>;
4441
4454
  plan: z.ZodOptional<z.ZodString>;
4442
4455
  execute: z.ZodOptional<z.ZodString>;
4443
4456
  extraction: z.ZodOptional<z.ZodString>;
@@ -4521,10 +4534,10 @@ interface ResolveRequiredModelEntryOptions {
4521
4534
  *
4522
4535
  * @example
4523
4536
  * ```ts
4524
- * import { LLMConfigSchema, resolveModelEntry } from '@h-ai/ai'
4537
+ * import { LLMConfigSchema, ai } from '@h-ai/ai'
4525
4538
  *
4526
4539
  * const config = LLMConfigSchema.parse({ apiKey: process.env.HAI_AI_LLM_APIKEY, models: [{ id: 'fast', model: 'gpt-4o-mini' }], scenarios: { summary: 'fast' } })
4527
- * const result = resolveModelEntry(config, 'summary')
4540
+ * const result = ai.resolveModelEntry(config, 'summary')
4528
4541
  * if (result.success) {
4529
4542
  * const modelName = result.data.model
4530
4543
  * }
@@ -4544,10 +4557,10 @@ declare function resolveModelEntry(llmConfig: LLMConfig, scenario: ModelScenario
4544
4557
  *
4545
4558
  * @example
4546
4559
  * ```ts
4547
- * import { LLMConfigSchema, resolveModelApi } from '@h-ai/ai'
4560
+ * import { LLMConfigSchema, ai } from '@h-ai/ai'
4548
4561
  *
4549
4562
  * const config = LLMConfigSchema.parse({ models: [{ id: 'claude', model: 'claude-sonnet-4', protocol: 'anthropic' }] })
4550
- * const protocol = resolveModelApi(config, 'claude')
4563
+ * const protocol = ai.resolveModelApi(config, 'claude')
4551
4564
  * ```
4552
4565
  */
4553
4566
  declare function resolveModelApi(llmConfig: LLMConfig, explicitModel?: string, tempApi?: ApiType): ApiType;
@@ -5445,10 +5458,10 @@ interface ResolvedAudioModel {
5445
5458
  *
5446
5459
  * @example
5447
5460
  * ```ts
5448
- * import { AudioConfigSchema, resolveAudioModel } from '@h-ai/ai'
5461
+ * import { AudioConfigSchema, ai } from '@h-ai/ai'
5449
5462
  *
5450
5463
  * const config = AudioConfigSchema.parse({ models: [{ id: 'tts', provider: 'indextts', model: 'indextts2', operations: ['synthesize'], baseUrl: 'http://127.0.0.1:8000' }], synthesizeModel: 'tts' })
5451
- * const result = resolveAudioModel(config, 'synthesize')
5464
+ * const result = ai.resolveAudioModel(config, 'synthesize')
5452
5465
  * if (result.success) {
5453
5466
  * const endpoint = result.data.baseUrl
5454
5467
  * }
@@ -5467,12 +5480,12 @@ declare function resolveAudioModel(audioConfig: AudioConfig, operation: 'transcr
5467
5480
  *
5468
5481
  * @example
5469
5482
  * ```ts
5470
- * import { AudioConfigSchema, ensureAudioCredential, resolveAudioModel } from '@h-ai/ai'
5483
+ * import { AudioConfigSchema, ai } from '@h-ai/ai'
5471
5484
  *
5472
5485
  * const config = AudioConfigSchema.parse({ models: [{ id: 'asr', provider: 'openai', model: 'whisper-1', operations: ['transcribe'] }], transcribeModel: 'asr' })
5473
- * const result = resolveAudioModel(config, 'transcribe')
5486
+ * const result = ai.resolveAudioModel(config, 'transcribe')
5474
5487
  * if (result.success) {
5475
- * const missingCredential = ensureAudioCredential(result.data)
5488
+ * const missingCredential = ai.ensureAudioCredential(result.data)
5476
5489
  * if (missingCredential) {
5477
5490
  * const code = missingCredential.code
5478
5491
  * }
@@ -5642,10 +5655,10 @@ interface ResolvedImageModel {
5642
5655
  *
5643
5656
  * @example
5644
5657
  * ```ts
5645
- * import { ImageConfigSchema, resolveImageModel } from '@h-ai/ai'
5658
+ * import { ImageConfigSchema, ai } from '@h-ai/ai'
5646
5659
  *
5647
5660
  * const config = ImageConfigSchema.parse({ models: [{ id: 'image', provider: 'openai', model: 'gpt-image-1', apiKey: process.env.HAI_AI_IMAGE_OPENAI_APIKEY }], generateModel: 'image' })
5648
- * const result = resolveImageModel(config)
5661
+ * const result = ai.resolveImageModel(config)
5649
5662
  * if (result.success) {
5650
5663
  * const modelName = result.data.model
5651
5664
  * }
@@ -6035,8 +6048,8 @@ declare const AIConfigSchema: z.ZodObject<{
6035
6048
  }, z.core.$strict>>>;
6036
6049
  scenarios: z.ZodOptional<z.ZodObject<{
6037
6050
  default: z.ZodOptional<z.ZodString>;
6038
- chat: z.ZodOptional<z.ZodString>;
6039
6051
  reasoning: z.ZodOptional<z.ZodString>;
6052
+ chat: z.ZodOptional<z.ZodString>;
6040
6053
  plan: z.ZodOptional<z.ZodString>;
6041
6054
  execute: z.ZodOptional<z.ZodString>;
6042
6055
  extraction: z.ZodOptional<z.ZodString>;
@@ -6336,6 +6349,31 @@ declare function publishSnapshot(input: ACPPublishSnapshot, signal?: AbortSignal
6336
6349
  commit: string;
6337
6350
  }>;
6338
6351
 
6352
+ /**
6353
+ * @h-ai/ai — MCP Server 创建与传输层
6354
+ *
6355
+ * 基于 `@modelcontextprotocol/sdk` 封装,提供便捷的 MCP 服务器创建。
6356
+ * @module ai-mcp-server
6357
+ */
6358
+
6359
+ /**
6360
+ * 创建 MCP 服务器
6361
+ *
6362
+ * @param options - 服务器选项(名称、版本)
6363
+ * @returns McpServer 实例
6364
+ *
6365
+ * @example
6366
+ * ```ts
6367
+ * import { ai } from '@h-ai/ai'
6368
+ *
6369
+ * const server = ai.createMcpServer({ name: 'my-server', version: '1.0.0' })
6370
+ * // 注册工具 / 资源 ...
6371
+ * const transport = new ai.StdioServerTransport()
6372
+ * await server.connect(transport)
6373
+ * ```
6374
+ */
6375
+ declare function createMcpServer(options: McpServerOptions): McpServer$2;
6376
+
6339
6377
  /**
6340
6378
  * @h-ai/ai — A2A(Agent-to-Agent)子功能类型
6341
6379
  *
@@ -6483,8 +6521,8 @@ interface A2AAuthenticator {
6483
6521
  *
6484
6522
  * @example
6485
6523
  * ```ts
6486
- * import { ai } from '@h-ai/ai'
6487
- * import type { A2ATaskFilter } from '@h-ai/ai'
6524
+ * import { type A2ATaskFilter, ai } from '@h-ai/ai'
6525
+ *
6488
6526
  * const filter: A2ATaskFilter = { callerId: 'agent-1', contextId: 'context-1', status: 'user', limit: 20 }
6489
6527
  * const result = await ai.a2a.listMessages(filter)
6490
6528
  * if (result.success) {
@@ -6513,8 +6551,8 @@ interface A2ATaskFilter {
6513
6551
  *
6514
6552
  * @example
6515
6553
  * ```ts
6516
- * import { ai } from '@h-ai/ai'
6517
- * import type { AgentExecutor } from '@h-ai/ai'
6554
+ * import { type AgentExecutor, ai } from '@h-ai/ai'
6555
+ *
6518
6556
  * function register(executor: AgentExecutor) {
6519
6557
  * const registered = ai.a2a.registerExecutor(executor)
6520
6558
  * if (!registered.success) return registered
@@ -6661,8 +6699,8 @@ interface A2AHandleResult {
6661
6699
  *
6662
6700
  * @example
6663
6701
  * ```ts
6664
- * import { ai } from '@h-ai/ai'
6665
- * import type { A2ACallOptions } from '@h-ai/ai'
6702
+ * import { type A2ACallOptions, ai } from '@h-ai/ai'
6703
+ *
6666
6704
  * const options: A2ACallOptions = { timeout: 30_000 }
6667
6705
  * const result = await ai.a2a.callRemoteAgent('https://trusted-agent.example.com/a2a', '项目介绍', options)
6668
6706
  * if (result.success) {
@@ -6833,7 +6871,7 @@ interface ACPPlatformPolicy {
6833
6871
  allowTools?: (scope: RunnerScope, agentId: string, toolIds: readonly string[]) => boolean | Promise<boolean>;
6834
6872
  /** 创建应用控制的 HTTP MCP 入口。传入 Worker 生命周期,返回 signal 通知绑定到期或撤销。 */
6835
6873
  bindTools?: (scope: RunnerScope, sessionId: string, toolIds: readonly string[], signal: AbortSignal) => Promise<{
6836
- servers: McpServer[];
6874
+ servers: McpServer$1[];
6837
6875
  revoke: () => void | Promise<void>;
6838
6876
  signal?: AbortSignal;
6839
6877
  }>;
@@ -6955,6 +6993,25 @@ type ACPTurnOptions = ACPRunObserver & Pick<ACPPlatformRequest, 'context' | 'lim
6955
6993
  */
6956
6994
  type ACPSubmitTurn = z.input<typeof submitTurnSchema>;
6957
6995
 
6996
+ /** @h-ai/ai — 音频播放负载序列化 */
6997
+
6998
+ /**
6999
+ * 将标准音频内容转换为浏览器可直接播放的 Base64 负载。
7000
+ *
7001
+ * `synthesize` 只负责统一供应商输出的字节与格式;裸 PCM 没有容器头,
7002
+ * 因此这里负责补齐 WAV 头。MP3/WAV 则只进行 Base64 编码,不重新封装。
7003
+ *
7004
+ * @example
7005
+ * ```ts
7006
+ * import { ai } from '@h-ai/ai'
7007
+ * const result = ai.serializePlayableAudio({ data: new Uint8Array(320), format: 'pcm16', sampleRate: 16000, channels: 1 })
7008
+ * if (result.success) {
7009
+ * const source = 'data:' + result.data.mimeType + ';base64,' + result.data.audioBase64
7010
+ * }
7011
+ * ```
7012
+ */
7013
+ declare function serializePlayableAudio(audio: AudioContent): HaiResult<PlayableAudio>;
7014
+
6958
7015
  /**
6959
7016
  * @h-ai/ai — RAG(Retrieval-Augmented Generation)子功能类型
6960
7017
  *
@@ -6967,7 +7024,7 @@ type ACPSubmitTurn = z.input<typeof submitTurnSchema>;
6967
7024
  *
6968
7025
  * @example
6969
7026
  * ```ts
6970
- * import { ai, type RagOptions } from '@h-ai/ai'
7027
+ * import { type RagOptions, ai } from '@h-ai/ai'
6971
7028
  * // 应用启动已成功初始化 ai。
6972
7029
  * async function run(options: RagOptions) {
6973
7030
  * const result = await ai.rag.query('如何部署?', options)
@@ -7094,7 +7151,7 @@ type RagStreamEvent = {
7094
7151
  *
7095
7152
  * @example
7096
7153
  * ```ts
7097
- * import { ai, type RagOperations } from '@h-ai/ai'
7154
+ * import { type RagOperations, ai } from '@h-ai/ai'
7098
7155
  * // 应用启动已成功初始化 ai,并注册 docs 检索源。
7099
7156
  * const operations: RagOperations = ai.rag
7100
7157
  * const result = await operations.query('如何部署?', { objectId: 'user-1', sources: ['docs'], topK: 3 })
@@ -7156,7 +7213,7 @@ type ReasoningStrategy = 'react' | 'cot' | 'plan-execute';
7156
7213
  *
7157
7214
  * @example
7158
7215
  * ```ts
7159
- * import { ai, type ReasoningOptions } from '@h-ai/ai'
7216
+ * import { type ReasoningOptions, ai } from '@h-ai/ai'
7160
7217
  * // 应用启动已成功初始化 ai。
7161
7218
  * async function run(options: ReasoningOptions) {
7162
7219
  * const result = await ai.reasoning.run('解释这项设计的权衡', options)
@@ -7300,7 +7357,7 @@ type ReasoningStreamEvent = {
7300
7357
  *
7301
7358
  * @example
7302
7359
  * ```ts
7303
- * import { ai, type ReasoningOperations } from '@h-ai/ai'
7360
+ * import { type ReasoningOperations, ai } from '@h-ai/ai'
7304
7361
  * // 应用启动已成功初始化 ai。
7305
7362
  * const operations: ReasoningOperations = ai.reasoning
7306
7363
  * const result = await operations.run('解释为何需要共享状态', { strategy: 'cot', maxRounds: 3 })
@@ -7545,7 +7602,7 @@ interface CommitTurnInput {
7545
7602
  *
7546
7603
  * @example
7547
7604
  * ```ts
7548
- * import { ai, type ContextManagerOptions } from '@h-ai/ai'
7605
+ * import { type ContextManagerOptions, ai } from '@h-ai/ai'
7549
7606
  * // 应用启动已成功初始化 ai;身份来自可信认证会话。
7550
7607
  * const options: ContextManagerOptions = { scope: { objectId: 'user-1', sessionId: 'session-1' }, turnCommit: 'manual', concurrency: 'reject' }
7551
7608
  * const result = ai.context.createManager(options)
@@ -7968,7 +8025,7 @@ interface ContextManager {
7968
8025
  *
7969
8026
  * @example
7970
8027
  * ```ts
7971
- * import { ai, type ContextOperations } from '@h-ai/ai'
8028
+ * import { type ContextOperations, ai } from '@h-ai/ai'
7972
8029
  * // 应用启动已成功初始化 ai;跨节点读取使用 restore/reload。
7973
8030
  * const operations: ContextOperations = ai.context
7974
8031
  * const restored = await operations.restoreManager({ objectId: 'user-1', sessionId: 'session-1' })
@@ -8753,8 +8810,8 @@ interface TokenOperations {
8753
8810
  * @example
8754
8811
  * ```ts
8755
8812
  * import { HaiAIError } from '@h-ai/ai'
8756
- * import { err } from '@h-ai/core'
8757
- * const result = err(HaiAIError.NOT_INITIALIZED, 'AI is not initialized')
8813
+ * import { core } from '@h-ai/core'
8814
+ * const result = core.err(HaiAIError.NOT_INITIALIZED, 'AI is not initialized')
8758
8815
  * if (!result.success) {
8759
8816
  * const status = result.error.httpStatus
8760
8817
  * const code = result.error.code
@@ -8881,7 +8938,7 @@ declare const HaiAIError: {
8881
8938
  *
8882
8939
  * @example
8883
8940
  * ```ts
8884
- * import { ai, type AIConfigInput, type AIInitOptions, type AIStoreProvider } from '@h-ai/ai'
8941
+ * import { type AIConfigInput, type AIInitOptions, type AIStoreProvider, ai } from '@h-ai/ai'
8885
8942
  * async function start(config: AIConfigInput, storeProvider: AIStoreProvider) {
8886
8943
  * const options: AIInitOptions = { storeProvider }
8887
8944
  * const result = await ai.init(config, options)
@@ -8914,7 +8971,7 @@ interface AIInitOptions {
8914
8971
  *
8915
8972
  * @example
8916
8973
  * ```ts
8917
- * import { ai, type AIConfigInput, type AIInitOptions } from '@h-ai/ai'
8974
+ * import { type AIConfigInput, type AIInitOptions, ai } from '@h-ai/ai'
8918
8975
  * // 一次性脚本示例;服务应用在启动阶段 init,在停止接入请求后 close。
8919
8976
  * async function run(config: AIConfigInput, options: AIInitOptions) {
8920
8977
  * const ready = await ai.init(config, options)
@@ -8931,6 +8988,44 @@ interface AIInitOptions {
8931
8988
  * ```
8932
8989
  */
8933
8990
  interface AIFunctions {
8991
+ /** A2A 协议对象构建器;无需初始化。 */
8992
+ AgentEvent: typeof AgentEvent;
8993
+ /** A2A 消息构建器;无需初始化。 */
8994
+ Message: typeof Message$1;
8995
+ /** A2A 消息部分构建器;无需初始化。 */
8996
+ Part: typeof Part$1;
8997
+ /** A2A 发送请求构建器;无需初始化。 */
8998
+ SendMessageRequest: typeof SendMessageRequest$1;
8999
+ /** A2A 任务构建器;无需初始化。 */
9000
+ Task: typeof Task$1;
9001
+ /** A2A 任务产物事件构建器;无需初始化。 */
9002
+ TaskArtifactUpdateEvent: typeof TaskArtifactUpdateEvent$1;
9003
+ /** A2A 任务状态构建器;无需初始化。 */
9004
+ TaskStatus: typeof TaskStatus$1;
9005
+ /** A2A 任务状态事件构建器;无需初始化。 */
9006
+ TaskStatusUpdateEvent: typeof TaskStatusUpdateEvent$1;
9007
+ /** MCP SDK 扩展构造器;无需初始化。 */
9008
+ McpServer: typeof McpServer$2;
9009
+ /** MCP SDK 扩展构造器;无需初始化。 */
9010
+ SSEServerTransport: typeof SSEServerTransport$1;
9011
+ /** MCP SDK 扩展构造器;无需初始化。 */
9012
+ StdioServerTransport: typeof StdioServerTransport$1;
9013
+ /** MCP SDK 扩展构造器;无需初始化。 */
9014
+ StreamableHTTPServerTransport: typeof StreamableHTTPServerTransport$1;
9015
+ /** resolveModelEntry 的公开工具入口;按原签名执行。 */
9016
+ resolveModelEntry: typeof resolveModelEntry;
9017
+ /** resolveModelApi 的公开工具入口;按原签名执行。 */
9018
+ resolveModelApi: typeof resolveModelApi;
9019
+ /** resolveAudioModel 的公开工具入口;按原签名执行。 */
9020
+ resolveAudioModel: typeof resolveAudioModel;
9021
+ /** ensureAudioCredential 的公开工具入口;按原签名执行。 */
9022
+ ensureAudioCredential: typeof ensureAudioCredential;
9023
+ /** resolveImageModel 的公开工具入口;按原签名执行。 */
9024
+ resolveImageModel: typeof resolveImageModel;
9025
+ /** serializePlayableAudio 的公开工具入口;按原签名执行。 */
9026
+ serializePlayableAudio: typeof serializePlayableAudio;
9027
+ /** createMcpServer 的公开工具入口;按原签名执行。 */
9028
+ createMcpServer: typeof createMcpServer;
8934
9029
  /**
8935
9030
  * 初始化 AI 服务
8936
9031
  *
@@ -8997,24 +9092,27 @@ interface AIFunctions {
8997
9092
  readonly image: ManagedImageOperations;
8998
9093
  }
8999
9094
 
9000
- /** @h-ai/ai — 音频播放负载序列化 */
9001
-
9002
9095
  /**
9003
- * 将标准音频内容转换为浏览器可直接播放的 Base64 负载。
9004
- *
9005
- * `synthesize` 只负责统一供应商输出的字节与格式;裸 PCM 没有容器头,
9006
- * 因此这里负责补齐 WAV 头。MP3/WAV 则只进行 Base64 编码,不重新封装。
9096
+ * AI 服务对象,统一的 AI 访问入口
9007
9097
  *
9008
9098
  * @example
9009
9099
  * ```ts
9010
- * import { serializePlayableAudio } from '@h-ai/ai'
9011
- * const result = serializePlayableAudio({ data: new Uint8Array(320), format: 'pcm16', sampleRate: 16000, channels: 1 })
9012
- * if (result.success) {
9013
- * const source = 'data:' + result.data.mimeType + ';base64,' + result.data.audioBase64
9100
+ * import { type AIConfigInput, type AIInitOptions, ai } from '@h-ai/ai'
9101
+ *
9102
+ * async function run(config: AIConfigInput, options: AIInitOptions) {
9103
+ * // 默认 Store 所需 reldb/vecdb 已由应用初始化;显式测试 Store 通过 options 注入。
9104
+ * const initialized = await ai.init(config, options)
9105
+ * if (!initialized.success) return initialized
9106
+ * try {
9107
+ * const result = await ai.llm.chat({ messages: [{ role: 'user', content: '你好' }] })
9108
+ * if (!result.success) return result
9109
+ * return result.data.choices[0]?.message.content
9110
+ * }
9111
+ * finally { await ai.close() }
9014
9112
  * }
9015
9113
  * ```
9016
9114
  */
9017
- declare function serializePlayableAudio(audio: AudioContent): HaiResult<PlayableAudio>;
9115
+ declare const ai: AIFunctions;
9018
9116
 
9019
9117
  /**
9020
9118
  * 统一语音入口的默认路径(相对 API 前缀)
@@ -9350,6 +9448,124 @@ interface AudioWsEndMessage {
9350
9448
  */
9351
9449
  type AudioWsServerMessage = AudioWsSpeechMessage | AudioWsTranscriptMessage | AudioWsSegmentStartedMessage | AudioWsSegmentDoneMessage | AudioWsErrorMessage | AudioWsEndMessage;
9352
9450
 
9451
+ /**
9452
+ * A2A 消息。
9453
+ * @example
9454
+ * ```ts
9455
+ * import { type Message, ai } from '@h-ai/ai'
9456
+ * const message: Message = ai.Message.fromJSON({ role: 'ROLE_USER', messageId: 'message-1', parts: [{ text: '你好' }] })
9457
+ * ```
9458
+ */
9459
+ type Message = _a2a_js_sdk.Message;
9460
+ /**
9461
+ * A2A 消息里的文本、文件或结构化数据。
9462
+ * @example
9463
+ * ```ts
9464
+ * import { type Part, ai } from '@h-ai/ai'
9465
+ * const part: Part = ai.Part.fromJSON({ text: '你好' })
9466
+ * ```
9467
+ */
9468
+ type Part = _a2a_js_sdk.Part;
9469
+ /**
9470
+ * A2A 发送消息请求。
9471
+ * @example
9472
+ * ```ts
9473
+ * import type { SendMessageRequest } from '@h-ai/ai'
9474
+ * function messageFrom(request: SendMessageRequest) { return request.message }
9475
+ * ```
9476
+ */
9477
+ type SendMessageRequest = _a2a_js_sdk.SendMessageRequest;
9478
+ /**
9479
+ * A2A 任务及其状态。
9480
+ * @example
9481
+ * ```ts
9482
+ * import type { Task } from '@h-ai/ai'
9483
+ * function stateOf(task: Task) { return task.status?.state }
9484
+ * ```
9485
+ */
9486
+ type Task = _a2a_js_sdk.Task;
9487
+ /**
9488
+ * A2A 任务产物更新事件。
9489
+ * @example
9490
+ * ```ts
9491
+ * import type { TaskArtifactUpdateEvent } from '@h-ai/ai'
9492
+ * function artifactOf(event: TaskArtifactUpdateEvent) { return event.artifact }
9493
+ * ```
9494
+ */
9495
+ type TaskArtifactUpdateEvent = _a2a_js_sdk.TaskArtifactUpdateEvent;
9496
+ /**
9497
+ * A2A 任务状态。
9498
+ * @example
9499
+ * ```ts
9500
+ * import type { TaskStatus } from '@h-ai/ai'
9501
+ * function stateOf(status: TaskStatus) { return status.state }
9502
+ * ```
9503
+ */
9504
+ type TaskStatus = _a2a_js_sdk.TaskStatus;
9505
+ /**
9506
+ * A2A 任务状态更新事件。
9507
+ * @example
9508
+ * ```ts
9509
+ * import type { TaskStatusUpdateEvent } from '@h-ai/ai'
9510
+ * function statusOf(event: TaskStatusUpdateEvent) { return event.status }
9511
+ * ```
9512
+ */
9513
+ type TaskStatusUpdateEvent = _a2a_js_sdk.TaskStatusUpdateEvent;
9514
+ /**
9515
+ * A2A 执行器收到的请求上下文。
9516
+ * @example
9517
+ * ```ts
9518
+ * import type { RequestContext } from '@h-ai/ai'
9519
+ * function taskIdOf(context: RequestContext) { return context.taskId }
9520
+ * ```
9521
+ */
9522
+ type RequestContext = _a2a_js_sdk_server.RequestContext;
9523
+ /**
9524
+ * A2A 服务端的调用上下文。
9525
+ * @example
9526
+ * ```ts
9527
+ * import type { ServerCallContext } from '@h-ai/ai'
9528
+ * function tenantOf(context: ServerCallContext) { return context.tenant }
9529
+ * ```
9530
+ */
9531
+ type ServerCallContext = _a2a_js_sdk_server.ServerCallContext;
9532
+ /**
9533
+ * MCP SDK 服务器实例。
9534
+ * @example
9535
+ * ```ts
9536
+ * import { type McpServer, ai } from '@h-ai/ai'
9537
+ * const server: McpServer = ai.createMcpServer({ name: 'example', version: '1.0.0' })
9538
+ * ```
9539
+ */
9540
+ type McpServer = McpServer$2;
9541
+ /**
9542
+ * MCP SSE 服务端传输实例。
9543
+ * @example
9544
+ * ```ts
9545
+ * import type { SSEServerTransport } from '@h-ai/ai'
9546
+ * async function shutdown(transport: SSEServerTransport) { await transport.close() }
9547
+ * ```
9548
+ */
9549
+ type SSEServerTransport = SSEServerTransport$1;
9550
+ /**
9551
+ * MCP 标准输入输出传输实例。
9552
+ * @example
9553
+ * ```ts
9554
+ * import { type StdioServerTransport, ai } from '@h-ai/ai'
9555
+ * const transport: StdioServerTransport = new ai.StdioServerTransport()
9556
+ * ```
9557
+ */
9558
+ type StdioServerTransport = StdioServerTransport$1;
9559
+ /**
9560
+ * MCP 流式 HTTP 服务端传输实例。
9561
+ * @example
9562
+ * ```ts
9563
+ * import { type StreamableHTTPServerTransport, ai } from '@h-ai/ai'
9564
+ * const transport: StreamableHTTPServerTransport = new ai.StreamableHTTPServerTransport({ sessionIdGenerator: undefined })
9565
+ * ```
9566
+ */
9567
+ type StreamableHTTPServerTransport = StreamableHTTPServerTransport$1;
9568
+
9353
9569
  /**
9354
9570
  * ACP 子系统;资源占用通过 CAS 持久化,不以超时推断失联进程已停止。
9355
9571
  * @param provider - 与 AI 模块共享的持久存储;工厂创建表后由调用方统一初始化。
@@ -9364,7 +9580,7 @@ type AudioWsServerMessage = AudioWsSpeechMessage | AudioWsTranscriptMessage | Au
9364
9580
  * async function assemble(provider: AIStoreProvider, config: AIConfig) { const acp = createACPOperations(provider, config); await provider.initialize(); return acp }
9365
9581
  * ```
9366
9582
  */
9367
- declare function createACPOperations(provider: AIStoreProvider, config: AIConfig, extensions?: Record<string, ACPAgentAdapter>, modelConfig?: () => Promise<AIConfig>, mcpLookup?: (ids: string[]) => Promise<McpServer[]>, runner?: RunnerFunctions, policy?: ACPPlatformPolicy): {
9583
+ declare function createACPOperations(provider: AIStoreProvider, config: AIConfig, extensions?: Record<string, ACPAgentAdapter>, modelConfig?: () => Promise<AIConfig>, mcpLookup?: (ids: string[]) => Promise<McpServer$1[]>, runner?: RunnerFunctions, policy?: ACPPlatformPolicy): {
9368
9584
  scoped: (rawScope: _h_ai_runner.RunnerScope) => {
9369
9585
  plan: (request: ACPPlatformRequest) => Promise<HaiResult<{
9370
9586
  readonly image: string;
@@ -11606,7 +11822,7 @@ declare function createACPOperations(provider: AIStoreProvider, config: AIConfig
11606
11822
  * const result = await connection.createSession('/srv/project', [])
11607
11823
  * ```
11608
11824
  */
11609
- createSession: (cwd: string, mcpServers?: McpServer[]) => Promise<{
11825
+ createSession: (cwd: string, mcpServers?: McpServer$1[]) => Promise<{
11610
11826
  success: false;
11611
11827
  error: _h_ai_core.HaiError;
11612
11828
  } | {
@@ -11904,7 +12120,7 @@ interface ACPSessionInfo {
11904
12120
  /** 创建会话时的智能体定义快照。 */
11905
12121
  agent: z.infer<typeof ACPAgentSchema>;
11906
12122
  /** 直接绑定的原生 MCP 参数;可能含凭据,仅供可信服务端管理。 */
11907
- mcpServers: McpServer[];
12123
+ mcpServers: McpServer$1[];
11908
12124
  /** 从 MCP 合并清单选择的服务 ID;凭据在启动时解析。 */
11909
12125
  mcpServerIds?: string[];
11910
12126
  /** 当前拥有的容器;关闭后清空,volume 内容仍保留。 */
@@ -11939,7 +12155,7 @@ interface ACPCreateSessionOptions extends ACPClientOptions {
11939
12155
  /** 本次会话的模型 ID,必须在智能体 modelIds 内。 */
11940
12156
  modelId?: string;
11941
12157
  /** 直接传给智能体的 MCP 定义;与 mcpServerIds 合并。 */
11942
- mcpServers?: McpServer[];
12158
+ mcpServers?: McpServer$1[];
11943
12159
  /** 从 ai.mcp.servers 选择的登记服务。 */
11944
12160
  mcpServerIds?: string[];
11945
12161
  }
@@ -11973,5 +12189,5 @@ interface ACPGitReport {
11973
12189
  */
11974
12190
  type ACPOperations = ReturnType<typeof createACPOperations>;
11975
12191
 
11976
- export { AudioFormatSchema as $, ACPPublishSchema as B, ACPRepositorySchema as C, ACPWorkspaceSchema as F, AIConfigSchema as I, AUDIO_WS_PATH as U, ApiTypeSchema as W, AudioConfigSchema as _, AudioModelEntrySchema as a1, AudioOperationSchema as a3, AudioOperationsSchema as a4, AudioProviderSchema as a6, AudioWsClientMessageSchema as a8, CompressionStrategySchema as aC, EmbeddingConfigSchema as aQ, EntityTypeSchema as a_, AudioWsDoneMessageSchema as aa, AudioWsStartMessageSchema as ai, AudioWsTextMessageSchema as ak, CompressConfigSchema as ax, FileConfigSchema as b0, HaiAIError as b5, ImageConfigSchema as b7, LLMConfigSchema as bF, MCPConfigSchema as bI, MCPExternalServerSchema as bL, MCPServerCapabilitiesSchema as bU, MCPServerConfigSchema as bW, ImageModelEntrySchema as ba, ImageProviderSchema as bd, KnowledgeConfigSchema as bj, MemoryConfigSchema as c8, RetrievalConfigSchema as cW, MemoryTypeSchema as cj, ModelCapabilitiesSchema as cn, ModelEntrySchema as cp, ModelScenarioSchema as cr, OptionalSecretSchema as ct, RetrievalSourceSchema as d1, resolveAudioModel as dA, resolveImageModel as dB, resolveModelApi as dC, resolveModelEntry as dD, serializePlayableAudio as dE, SummaryConfigSchema as de, TokenConfigSchema as dm, ensureAudioCredential as dz, A2AConfigSchema as h, A2ASkillConfigSchema as n, ACPAgentSchema as s, ACPConfigSchema as w };
11977
- export type { A2AAgentCardConfig as A, ACPSessionInfo as D, ACPTransport as E, AIConfig as G, AIConfigInput as H, AIFunctions as J, AIInitOptions as K, AIRelStore as L, AIRelStoreCompareAndSwap as M, AIRelStoreOptions as N, AIResourceEntry as O, AIResourceRegistry as P, AIStoreProvider as Q, AIVectorBackend as R, AIVectorStore as S, AIVersionedRecord as T, ApiType as V, AskOptions as X, AssistantMessage as Y, AudioConfig as Z, A2AAgentCardDocument as a, FileConfig as a$, AudioModelEntry as a0, AudioOperation as a2, AudioProviderName as a5, AudioWsClientMessage as a7, AudioWsDoneMessage as a9, CompressResult as aA, CompressionStrategy as aB, ConsolidateOptions as aD, ConsolidateResult as aE, ContextChatOptions as aF, ContextChatResult as aG, ContextManager as aH, ContextManagerOptions as aI, ContextOperations as aJ, ContextResetOptions as aK, ContextStreamEvent as aL, ConversationTurn as aM, ConversationTurnStatus as aN, DeveloperMessage as aO, EmbeddingConfig as aP, EmbeddingItem as aR, EmbeddingOperations as aS, EmbeddingRequest as aT, EmbeddingResponse as aU, EntityDocumentRelation as aV, EntityDocumentResult as aW, EntityListOptions as aX, EntityQueryOptions as aY, EntityType as aZ, AudioWsEndMessage as ab, AudioWsErrorMessage as ac, AudioWsSegmentDoneMessage as ad, AudioWsSegmentStartedMessage as ae, AudioWsServerMessage as af, AudioWsSpeechMessage as ag, AudioWsStartMessage as ah, AudioWsTextMessage as aj, AudioWsTranscriptMessage as al, ChatCompletionChoice as am, ChatCompletionChunk as an, ChatCompletionDelta as ao, ChatCompletionRequest as ap, ChatCompletionResponse as aq, ChatHistoryOptions as ar, ChatMessage as as, ChatRecord as at, Citation as au, CommitTurnInput as av, CompressConfig as aw, CompressOperations as ay, CompressOptions as az, A2AApiKeySecurity as b, ManagedLLMOperations as b$, GenerateImageRequest as b1, GenerateImageResult as b2, GenerateObjectRequest as b3, GeneratedImage as b4, ImageConfig as b6, ImageContent as b8, ImageModelEntry as b9, KnowledgeRetrieveOptions as bA, KnowledgeRetrieveResult as bB, KnowledgeSetupOptions as bC, KnowledgeStore as bD, LLMConfig as bE, LLMOperations as bG, MCPConfig as bH, MCPContext as bJ, MCPExternalServer as bK, MCPOperations as bM, MCPPrompt as bN, MCPPromptArgument as bO, MCPPromptContent as bP, MCPPromptMessage as bQ, MCPResource as bR, MCPResourceContent as bS, MCPServerCapabilities as bT, MCPServerConfig as bV, MCPToolDefinition as bX, MCPToolHandler as bY, ManagedAudioOperations as bZ, ManagedImageOperations as b_, ImageOperations as bb, ImageProviderName as bc, ImageSize as be, InteractionScope as bf, KnowledgeAskOptions as bg, KnowledgeAskResult as bh, KnowledgeConfig as bi, KnowledgeDocumentInfo as bk, KnowledgeDocumentListOptions as bl, KnowledgeDocumentMetadata as bm, KnowledgeDocumentRemoveOptions as bn, KnowledgeDocumentRevision as bo, KnowledgeEntity as bp, KnowledgeIngestBatchProgress as bq, KnowledgeIngestBatchResult as br, KnowledgeIngestFileInput as bs, KnowledgeIngestInput as bt, KnowledgeIngestResult as bu, KnowledgeOperations as bv, KnowledgeRepairOptions as bw, KnowledgeRepairProgress as bx, KnowledgeRepairResult as by, KnowledgeRetrieveItem as bz, A2AAuthenticator as c, RetrievalSource as c$, ManagedMCPOperations as c0, ManagedRetrievalOperations as c1, McpServerOptions as c2, MemoryAccessScope as c3, MemoryAdminOperations as c4, MemoryClearAllOptions as c5, MemoryClearOptions as c6, MemoryConfig as c7, MemoryCoreOperations as c9, RagOperations as cA, RagOptions as cB, RagResult as cC, RagStreamEvent as cD, ReasoningOperations as cE, ReasoningOptions as cF, ReasoningResult as cG, ReasoningStep as cH, ReasoningStepType as cI, ReasoningStrategy as cJ, ReasoningStreamEvent as cK, ReferenceImage as cL, RerankDocument as cM, RerankItem as cN, RerankOperations as cO, RerankRequest as cP, RerankResponse as cQ, ResolveRequiredModelEntryOptions as cR, ResolvedAudioModel as cS, ResolvedImageModel as cT, ResolvedModelConfig as cU, RetrievalConfig as cV, RetrievalOperations as cX, RetrievalRequest as cY, RetrievalResult as cZ, RetrievalResultItem as c_, MemoryEntry as ca, MemoryEntryInput as cb, MemoryExtractOptions as cc, MemoryInjectionOptions as cd, MemoryListOptions as ce, MemoryListPageOptions as cf, MemoryOperations as cg, MemoryRecallOptions as ch, MemoryType as ci, MemoryUpdateInput as ck, MessageContent as cl, MessageRole as cm, ModelEntry as co, ModelScenario as cq, ObjectRef as cs, PersonaOperations as cu, PersonaProfile as cv, PersonaProfileInput as cw, PersonaProfileUpdate as cx, PersonaScopeOptions as cy, RagContextItem as cz, A2ACallOptions as d, MCPJobFileContext as d$, RetrievalSourceConfig as d0, SSEDecoder as d2, SSEEvent as d3, ScopedMemoryBinding as d4, ScopedMemoryOperations as d5, SessionInfo as d6, StoreFilter as d7, StorePage as d8, StoreScope as d9, ACPApprovalDecision as dF, ACPCitation as dG, ACPPlatformPolicy as dH, ACPPlatformRequest as dI, ACPProjectChanges as dJ, ACPProjectSnapshot as dK, ACPPublishSnapshot as dL, ACPRunObserver as dM, ACPRunRequest as dN, ACPSessionWorkspace as dO, ACPSubmitTurn as dP, ACPTurnOptions as dQ, BuiltinArtifact as dR, BuiltinArtifactAccess as dS, BuiltinArtifactReference as dT, BuiltinToolBinding as dU, BuiltinToolBroker as dV, BuiltinToolBrokerOptions as dW, BuiltinToolOptions as dX, CreateBuiltinTools as dY, JsonFieldPreview as dZ, JsonFieldPreviewOptions as d_, StreamOperations as da, StreamProcessor as db, StreamResult as dc, SummaryConfig as dd, SummaryOperations as df, SummaryOptions as dg, SummaryResult as dh, SystemMessage as di, TempModelConfig as dj, TextContent as dk, TokenConfig as dl, TokenOperations as dn, TokenUsage as dp, ToolCall as dq, ToolDefinition as dr, ToolMessage as ds, ToolRegistryOperations as dt, ToolsOperations as du, UserMessage as dv, WhereClause as dw, WhereOperator as dx, WhereValue as dy, A2ACallResult as e, MCPJobFiles as e0, MCPServiceAuthorization as e1, MCPServiceBinding as e2, MCPServiceBindingRequest as e3, MCPServiceBroker as e4, MCPServiceBrokerOptions as e5, MCPServiceOperations as e6, MCPServiceRequest as e7, McpToolOptions as e8, A2ACallerIdentity as f, A2AConfig as g, A2AContextInfo as i, A2AHandleResult as j, A2AMessageRecord as k, A2AOperations as l, A2ASecurityConfig as m, A2ATaskFilter as o, ACPAgentAdapter as p, ACPAgentAdapterInput as q, ACPAgentLaunch as r, ACPClientOptions as t, ACPConfig as u, ACPConfigInput as v, ACPCreateSessionOptions as x, ACPGitReport as y, ACPOperations as z };
12192
+ export { ACPConfigSchema as D, ACPPublishSchema as H, ACPRepositorySchema as I, ACPWorkspaceSchema as L, AIConfigSchema as O, AUDIO_WS_PATH as _, resolveModelApi as a, ApiTypeSchema as a0, AudioConfigSchema as a4, AudioFormatSchema as a5, AudioModelEntrySchema as a7, AudioOperationSchema as a9, CompressConfigSchema as aD, CompressionStrategySchema as aI, EmbeddingConfigSchema as aW, AudioOperationsSchema as aa, AudioProviderSchema as ac, AudioWsClientMessageSchema as ae, AudioWsDoneMessageSchema as ag, AudioWsStartMessageSchema as ao, AudioWsTextMessageSchema as aq, resolveAudioModel as b, EntityTypeSchema as b4, FileConfigSchema as b6, LLMConfigSchema as bL, MCPConfigSchema as bO, MCPExternalServerSchema as bR, MCPServerCapabilitiesSchema as b_, HaiAIError as bb, ImageConfigSchema as bd, ImageModelEntrySchema as bg, ImageProviderSchema as bj, KnowledgeConfigSchema as bp, resolveImageModel as c, MCPServerConfigSchema as c0, OptionalSecretSchema as cA, MemoryConfigSchema as ce, MemoryTypeSchema as cp, ModelCapabilitiesSchema as cu, ModelEntrySchema as cw, ModelScenarioSchema as cy, RetrievalConfigSchema as d2, RetrievalSourceSchema as d9, TokenConfigSchema as dA, SummaryConfigSchema as dn, ensureAudioCredential as e, ai as em, A2AConfigSchema as l, resolveModelEntry as r, serializePlayableAudio as s, A2ASkillConfigSchema as t, ACPAgentSchema as y };
12193
+ export type { ApiType as $, A2AAgentCardConfig as A, ACPConfig as B, ACPConfigInput as C, ACPCreateSessionOptions as E, ACPGitReport as F, ACPOperations as G, ACPSessionInfo as J, ACPTransport as K, AIConfig as M, AIConfigInput as N, AIFunctions as P, AIInitOptions as Q, AIRelStore as R, AIRelStoreCompareAndSwap as S, AIRelStoreOptions as T, AIResourceEntry as U, AIResourceRegistry as V, AIStoreProvider as W, AIVectorBackend as X, AIVectorStore as Y, AIVersionedRecord as Z, EntityDocumentRelation as a$, AskOptions as a1, AssistantMessage as a2, AudioConfig as a3, AudioModelEntry as a6, AudioOperation as a8, Citation as aA, CommitTurnInput as aB, CompressConfig as aC, CompressOperations as aE, CompressOptions as aF, CompressResult as aG, CompressionStrategy as aH, ConsolidateOptions as aJ, ConsolidateResult as aK, ContextChatOptions as aL, ContextChatResult as aM, ContextManager as aN, ContextManagerOptions as aO, ContextOperations as aP, ContextResetOptions as aQ, ContextStreamEvent as aR, ConversationTurn as aS, ConversationTurnStatus as aT, DeveloperMessage as aU, EmbeddingConfig as aV, EmbeddingItem as aX, EmbeddingOperations as aY, EmbeddingRequest as aZ, EmbeddingResponse as a_, AudioProviderName as ab, AudioWsClientMessage as ad, AudioWsDoneMessage as af, AudioWsEndMessage as ah, AudioWsErrorMessage as ai, AudioWsSegmentDoneMessage as aj, AudioWsSegmentStartedMessage as ak, AudioWsServerMessage as al, AudioWsSpeechMessage as am, AudioWsStartMessage as an, AudioWsTextMessage as ap, AudioWsTranscriptMessage as ar, ChatCompletionChoice as as, ChatCompletionChunk as at, ChatCompletionDelta as au, ChatCompletionRequest as av, ChatCompletionResponse as aw, ChatHistoryOptions as ax, ChatMessage as ay, ChatRecord as az, MCPServerConfig as b$, EntityDocumentResult as b0, EntityListOptions as b1, EntityQueryOptions as b2, EntityType as b3, FileConfig as b5, GenerateImageRequest as b7, GenerateImageResult as b8, GenerateObjectRequest as b9, KnowledgeIngestResult as bA, KnowledgeOperations as bB, KnowledgeRepairOptions as bC, KnowledgeRepairProgress as bD, KnowledgeRepairResult as bE, KnowledgeRetrieveItem as bF, KnowledgeRetrieveOptions as bG, KnowledgeRetrieveResult as bH, KnowledgeSetupOptions as bI, KnowledgeStore as bJ, LLMConfig as bK, LLMOperations as bM, MCPConfig as bN, MCPContext as bP, MCPExternalServer as bQ, MCPOperations as bS, MCPPrompt as bT, MCPPromptArgument as bU, MCPPromptContent as bV, MCPPromptMessage as bW, MCPResource as bX, MCPResourceContent as bY, MCPServerCapabilities as bZ, GeneratedImage as ba, ImageConfig as bc, ImageContent as be, ImageModelEntry as bf, ImageOperations as bh, ImageProviderName as bi, ImageSize as bk, InteractionScope as bl, KnowledgeAskOptions as bm, KnowledgeAskResult as bn, KnowledgeConfig as bo, KnowledgeDocumentInfo as bq, KnowledgeDocumentListOptions as br, KnowledgeDocumentMetadata as bs, KnowledgeDocumentRemoveOptions as bt, KnowledgeDocumentRevision as bu, KnowledgeEntity as bv, KnowledgeIngestBatchProgress as bw, KnowledgeIngestBatchResult as bx, KnowledgeIngestFileInput as by, KnowledgeIngestInput as bz, ResolvedImageModel as c$, MCPToolDefinition as c1, MCPToolHandler as c2, ManagedAudioOperations as c3, ManagedImageOperations as c4, ManagedLLMOperations as c5, ManagedMCPOperations as c6, ManagedRetrievalOperations as c7, McpServerOptions as c8, MemoryAccessScope as c9, Part as cB, PersonaOperations as cC, PersonaProfile as cD, PersonaProfileInput as cE, PersonaProfileUpdate as cF, PersonaScopeOptions as cG, RagContextItem as cH, RagOperations as cI, RagOptions as cJ, RagResult as cK, RagStreamEvent as cL, ReasoningOperations as cM, ReasoningOptions as cN, ReasoningResult as cO, ReasoningStep as cP, ReasoningStepType as cQ, ReasoningStrategy as cR, ReasoningStreamEvent as cS, ReferenceImage as cT, RerankDocument as cU, RerankItem as cV, RerankOperations as cW, RerankRequest as cX, RerankResponse as cY, ResolveRequiredModelEntryOptions as cZ, ResolvedAudioModel as c_, MemoryAdminOperations as ca, MemoryClearAllOptions as cb, MemoryClearOptions as cc, MemoryConfig as cd, MemoryCoreOperations as cf, MemoryEntry as cg, MemoryEntryInput as ch, MemoryExtractOptions as ci, MemoryInjectionOptions as cj, MemoryListOptions as ck, MemoryListPageOptions as cl, MemoryOperations as cm, MemoryRecallOptions as cn, MemoryType as co, MemoryUpdateInput as cq, Message as cr, MessageContent as cs, MessageRole as ct, ModelEntry as cv, ModelScenario as cx, ObjectRef as cz, A2AAgentCardDocument as d, BuiltinToolBinding as d$, ResolvedModelConfig as d0, RetrievalConfig as d1, RetrievalOperations as d3, RetrievalRequest as d4, RetrievalResult as d5, RetrievalResultItem as d6, RetrievalSource as d7, RetrievalSourceConfig as d8, TokenOperations as dB, TokenUsage as dC, ToolCall as dD, ToolDefinition as dE, ToolMessage as dF, ToolRegistryOperations as dG, ToolsOperations as dH, UserMessage as dI, WhereClause as dJ, WhereOperator as dK, WhereValue as dL, ACPApprovalDecision as dM, ACPCitation as dN, ACPPlatformPolicy as dO, ACPPlatformRequest as dP, ACPProjectChanges as dQ, ACPProjectSnapshot as dR, ACPPublishSnapshot as dS, ACPRunObserver as dT, ACPRunRequest as dU, ACPSessionWorkspace as dV, ACPSubmitTurn as dW, ACPTurnOptions as dX, BuiltinArtifact as dY, BuiltinArtifactAccess as dZ, BuiltinArtifactReference as d_, SSEDecoder as da, SSEEvent as db, ScopedMemoryBinding as dc, ScopedMemoryOperations as dd, SendMessageRequest as de, SessionInfo as df, StoreFilter as dg, StorePage as dh, StoreScope as di, StreamOperations as dj, StreamProcessor as dk, StreamResult as dl, SummaryConfig as dm, SummaryOperations as dp, SummaryOptions as dq, SummaryResult as dr, SystemMessage as ds, Task as dt, TaskArtifactUpdateEvent as du, TaskStatus as dv, TaskStatusUpdateEvent as dw, TempModelConfig as dx, TextContent as dy, TokenConfig as dz, BuiltinToolBroker as e0, BuiltinToolBrokerOptions as e1, BuiltinToolOptions as e2, CreateBuiltinTools as e3, JsonFieldPreview as e4, JsonFieldPreviewOptions as e5, MCPJobFileContext as e6, MCPJobFiles as e7, MCPServiceAuthorization as e8, MCPServiceBinding as e9, MCPServiceBindingRequest as ea, MCPServiceBroker as eb, MCPServiceBrokerOptions as ec, MCPServiceOperations as ed, MCPServiceRequest as ee, McpServer as ef, McpToolOptions as eg, RequestContext as eh, SSEServerTransport as ei, ServerCallContext as ej, StdioServerTransport as ek, StreamableHTTPServerTransport as el, A2AApiKeySecurity as f, A2AAuthenticator as g, A2ACallOptions as h, A2ACallResult as i, A2ACallerIdentity as j, A2AConfig as k, A2AContextInfo as m, A2AHandleResult as n, A2AMessageRecord as o, A2AOperations as p, A2ASecurityConfig as q, A2ATaskFilter as u, ACPAgentAdapter as v, ACPAgentAdapterInput as w, ACPAgentLaunch as x, ACPClientOptions as z };