@h-ai/ai 0.1.0-alpha.67 → 0.1.0-alpha.69

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,10 +1,5 @@
1
- import { ao as TranscriptionRequest, ap as TranscriptionResult, ar as TranscriptionStreamRequest, am as TranscriptionEvent, ag as SynthesisRequest, ah as SynthesisResult, ai as SynthesisStreamRequest, ae as SynthesisEvent, aX as ChatCompletionRequest, aY as ChatCompletionResponse, aV as ChatCompletionChunk, bn as KnowledgeRetrieveResult, ba as KnowledgeAskResult, bj as KnowledgeIngestResult, bb as KnowledgeDocumentInfo, bx as MemoryEntry, c4 as StorePage, by as MemoryEntryInput, bF as MemoryUpdateInput, c2 as SessionInfo, a$ as ChatRecord, bM as RagResult, bQ as ReasoningResult, aI as A2AMessageRecord, aE as A2ACallResult } from '../ai-reasoning-types-DZd_6Umd.js';
2
- import { HaiResult } from '@h-ai/core';
3
- import { AgentCard } from '@a2a-js/sdk';
4
- import '@h-ai/datapipe';
5
- import 'zod';
6
- import '@a2a-js/sdk/server';
7
- import 'openai';
1
+ import { m as TranscriptionRequest, n as TranscriptionResult, p as TranscriptionStreamRequest, T as TranscriptionEvent, h as SynthesisRequest, i as SynthesisResult, j as SynthesisStreamRequest, S as SynthesisEvent } from '../ai-audio-types-4R5yUAVl.js';
2
+ import '@h-ai/core';
8
3
 
9
4
  /**
10
5
  * @h-ai/ai/client — 浏览器语音客户端
@@ -20,6 +15,14 @@ import 'openai';
20
15
  *
21
16
  * 供应用签发与本次操作严格绑定的能力票据(如 `iam.ticket.issue({ grant })`),
22
17
  * 使票据只能用于本次操作 / 模型 / 会话,降低票据被重放的风险。
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import type { AudioTicketRequest } from '@h-ai/ai/client'
22
+ * function grant(request: AudioTicketRequest) {
23
+ * return { operation: request.operation, model: request.model } // 经已登录 HTTP 接口签发并在服务端原子消费。
24
+ * }
25
+ * ```
23
26
  */
24
27
  interface AudioTicketRequest {
25
28
  /** 本次操作类型 */
@@ -27,7 +30,18 @@ interface AudioTicketRequest {
27
30
  /** 本次使用的模型 ID(如有指定) */
28
31
  model?: string;
29
32
  }
30
- /** 浏览器语音客户端配置 */
33
+ /**
34
+ * 浏览器语音客户端配置
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * import { createAudioClient } from '@h-ai/ai/client'
39
+ * import type { AudioTicketRequest } from '@h-ai/ai/client'
40
+ * function connect(issueTicket: (request: AudioTicketRequest) => Promise<string>) {
41
+ * return createAudioClient({ url: 'wss://example.com/api/v1/ai/audio', getTicket: issueTicket })
42
+ * }
43
+ * ```
44
+ */
31
45
  interface AudioClientConfig {
32
46
  /** 语音 WebSocket 完整 URL(如 `wss://host/api/v1/ai/audio`) */
33
47
  url: string;
@@ -43,6 +57,16 @@ interface AudioClientConfig {
43
57
  * 浏览器语音操作接口
44
58
  *
45
59
  * 与 Node 端 `AudioOperations` 业务形态一致;出错时抛出异常(浏览器 Client 约定)。
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * import type { AudioClientOperations } from '@h-ai/ai/client'
64
+ * async function speak(audio: AudioClientOperations) {
65
+ * // 浏览器 AudioClient 普通方法也显式抛错,由应用交互边界处理。
66
+ * const result = await audio.synthesize({ text: '你好', format: 'mp3' })
67
+ * return result.data
68
+ * }
69
+ * ```
46
70
  */
47
71
  interface AudioClientOperations {
48
72
  /** 将完整音频识别为完整文本 */
@@ -59,276 +83,16 @@ interface AudioClientOperations {
59
83
  *
60
84
  * @param config - 语音客户端配置
61
85
  * @returns 浏览器语音操作接口
62
- */
63
- declare function createAudioClient(config: AudioClientConfig): AudioClientOperations;
64
- /** 未配置语音入口时的占位实现(调用即抛出,提示需配置 audio) */
65
- declare function createUnconfiguredAudioClient(): AudioClientOperations;
66
-
67
- /**
68
- * @h-ai/ai — 前端 AI 客户端
69
- *
70
- * 基于 @h-ai/api-client 的 AI 领域客户端。
71
- * 通过 `createAIClient()` 工厂函数创建,消除自建 HTTP 层,
72
- * 复用 api-client 提供的 Token 管理、超时、拦截器等基础能力。
73
- * @module ai-client
74
- */
75
-
76
- /**
77
- * AI 客户端所需的 API 调用能力
78
- *
79
- * 结构兼容 `@h-ai/api-client` 的 `apiClient` 默认单例(鸭子类型)。
80
- * 传入 `apiClient` 默认单例即可,无需额外适配。
81
- */
82
- interface AIApiAdapter {
83
- /** POST 请求(返回 HaiResult) */
84
- post: <T>(path: string, body?: unknown) => Promise<HaiResult<T>>;
85
- /** 流式请求(返回 SSE data 行的 AsyncIterable) */
86
- stream: (path: string, body?: unknown) => AsyncIterable<string>;
87
- }
88
- /**
89
- * AI 客户端配置
90
86
  *
91
87
  * @example
92
88
  * ```ts
93
- * import { apiClient } from '@h-ai/api-client'
94
- * import { createAIClient } from '@h-ai/ai/client'
95
- *
96
- * await apiClient.init({ baseUrl: '/api', auth: { ... } })
97
- * const aiClient = createAIClient({ api: apiClient })
98
- * ```
99
- */
100
- interface AIClientConfig {
101
- /**
102
- * API 调用适配器
103
- *
104
- * 传入 `apiClient` 默认单例(初始化后)。
105
- * baseUrl、Token 管理、超时等通过 api-client 配置。
106
- */
107
- api: AIApiAdapter;
108
- /**
109
- * 语音 WebSocket 配置(可选)
110
- *
111
- * 提供后 `client.audio.*` 通过统一 WebSocket 连接 `@h-ai/serv` 语音入口;
112
- * 未提供时调用 `client.audio.*` 抛出「未配置」错误。
113
- */
114
- audio?: AudioClientConfig;
115
- }
116
- /** 流式响应进度(`onProgress` 回调参数) */
117
- interface StreamProgress {
118
- /** 当前累积的文本内容 */
119
- content: string;
120
- /** 是否已完成 */
121
- done: boolean;
122
- /** 完成原因(仅 `done=true` 时有值,如 `'stop'`) */
123
- finishReason?: string;
124
- }
125
- /** 流式响应选项 */
126
- interface StreamOptions {
127
- /** 进度回调(每次收到 chunk 时触发) */
128
- onProgress?: (progress: StreamProgress) => void;
129
- }
130
- /**
131
- * AI 客户端接口
132
- *
133
- * 提供浏览器端调用 AI API 的能力,HTTP 基础设施委托给 @h-ai/api-client。
134
- */
135
- interface AIClient {
136
- /** 发送对话请求(非流式) */
137
- chat: (request: ChatCompletionRequest) => Promise<ChatCompletionResponse>;
138
- /** 发送流式对话请求,返回异步迭代器 */
139
- chatStream: (request: ChatCompletionRequest, options?: StreamOptions) => AsyncIterable<ChatCompletionChunk>;
140
- /** 便捷方法:发送纯文本消息并返回回复文本 */
141
- sendMessage: (message: string, systemPrompt?: string) => Promise<string>;
142
- /** 便捷方法:流式发送纯文本消息并返回完整回复 */
143
- sendMessageStream: (message: string, options?: StreamOptions, systemPrompt?: string) => Promise<string>;
144
- /** 简单问答(单轮,自动构造 messages) */
145
- ask: (question: string, options?: {
146
- systemPrompt?: string;
147
- model?: string;
148
- }) => Promise<string>;
149
- /** 流式简单问答,返回异步文本流 */
150
- askStream: (question: string, options?: {
151
- systemPrompt?: string;
152
- model?: string;
153
- }) => AsyncIterable<string>;
154
- /** 知识检索(向量 + 实体增强) */
155
- knowledgeRetrieve: (query: string, options?: {
156
- topK?: number;
157
- collection?: string;
158
- }) => Promise<KnowledgeRetrieveResult>;
159
- /** 知识问答(RAG + 信源) */
160
- knowledgeAsk: (query: string, options?: {
161
- model?: string;
162
- collection?: string;
163
- }) => Promise<KnowledgeAskResult>;
164
- /** 导入文档 */
165
- knowledgeIngest: (input: {
166
- documentId: string;
167
- content: string;
168
- title?: string;
169
- collection?: string;
170
- metadata?: Record<string, unknown>;
171
- }) => Promise<KnowledgeIngestResult>;
172
- /** 列出已导入文档 */
173
- knowledgeListDocuments: (options?: {
174
- collection?: string;
175
- offset?: number;
176
- limit?: number;
177
- }) => Promise<KnowledgeDocumentInfo[]>;
178
- /** 删除已导入文档 */
179
- knowledgeRemoveDocument: (documentId: string, options?: {
180
- collection?: string;
181
- }) => Promise<void>;
182
- /** 检索相关记忆 */
183
- recallMemories: (query: string, options?: {
184
- topK?: number;
185
- types?: string[];
186
- minImportance?: number;
187
- objectId?: string;
188
- }) => Promise<MemoryEntry[]>;
189
- /** 列出记忆(分页) */
190
- listMemories: (options?: {
191
- types?: string[];
192
- objectId?: string;
193
- offset?: number;
194
- limit?: number;
195
- }) => Promise<StorePage<MemoryEntry>>;
196
- /** 添加记忆 */
197
- addMemory: (entry: MemoryEntryInput) => Promise<MemoryEntry>;
198
- /** 更新记忆 */
199
- updateMemory: (memoryId: string, updates: MemoryUpdateInput) => Promise<MemoryEntry>;
200
- /** 删除记忆 */
201
- removeMemory: (memoryId: string) => Promise<void>;
202
- /** 列出会话 */
203
- listSessions: (objectId: string) => Promise<SessionInfo[]>;
204
- /** 重命名会话 */
205
- renameSession: (sessionId: string, title: string) => Promise<void>;
206
- /** 删除会话 */
207
- removeSession: (sessionId: string) => Promise<void>;
208
- /** 获取对话历史 */
209
- chatHistory: (objectId: string, sessionId: string, options?: {
210
- limit?: number;
211
- order?: 'asc' | 'desc';
212
- }) => Promise<ChatRecord[]>;
213
- /** RAG 查询(检索 + 生成) */
214
- ragQuery: (query: string, options?: {
215
- collection?: string;
216
- topK?: number;
217
- model?: string;
218
- }) => Promise<RagResult>;
219
- /** RAG 流式查询,返回 SSE 数据行 */
220
- ragQueryStream: (query: string, options?: {
221
- collection?: string;
222
- topK?: number;
223
- model?: string;
224
- }) => AsyncIterable<string>;
225
- /** 推理(多步思考) */
226
- reasoningRun: (query: string, options?: {
227
- model?: string;
228
- maxSteps?: number;
229
- }) => Promise<ReasoningResult>;
230
- /** 推理流式,返回 SSE 数据行 */
231
- reasoningRunStream: (query: string, options?: {
232
- model?: string;
233
- maxSteps?: number;
234
- }) => AsyncIterable<string>;
235
- /** 估算文本的 Token 数 */
236
- estimateTokens: (text: string) => Promise<{
237
- tokens: number;
238
- }>;
239
- /** 语音操作(识别 / 合成),需在 createAIClient 配置 `audio` */
240
- audio: AudioClientOperations;
241
- }
242
- /**
243
- * 创建 AI 客户端
244
- *
245
- * 通过 @h-ai/api-client 的 ApiClient 实例调用后端 AI API。
246
- * HTTP 层(Token、超时、拦截器)全部复用 api-client,本模块仅负责:
247
- * - 非流式 / 流式 ChatCompletion 协议适配
248
- * - SSE 解析与 ChatCompletionChunk 类型化
249
- * - onProgress 进度回调
250
- *
251
- * @param config - 客户端配置
252
- * @returns AI 客户端实例
253
- *
254
- * @example
255
- * ```ts
256
- * import { apiClient } from '@h-ai/api-client'
257
- * import { createAIClient } from '@h-ai/ai/client'
258
- *
259
- * await apiClient.init({ baseUrl: '/api' })
260
- * const client = createAIClient({ api: apiClient })
261
- * const reply = await client.sendMessage('你好')
262
- * ```
263
- */
264
- declare function createAIClient(config: AIClientConfig): AIClient;
265
- /**
266
- * 从 fetch Response 中解析 SSE data 字段
267
- *
268
- * 自动处理分片缓冲和 `[DONE]` 结束标记。
269
- *
270
- * @param response - fetch 响应对象
271
- * @yields SSE data 字符串(不含 `[DONE]`)
272
- *
273
- * @example
274
- * ```ts
275
- * const resp = await fetch('/api/chat', { method: 'POST', body })
276
- * for await (const data of parseSSE(resp)) {
277
- * const chunk = JSON.parse(data) // ChatCompletionChunk
89
+ * import { createAudioClient } from '@h-ai/ai/client'
90
+ * import type { AudioTicketRequest } from '@h-ai/ai/client'
91
+ * function connect(issueTicket: (request: AudioTicketRequest) => Promise<string>) {
92
+ * return createAudioClient({ url: 'wss://example.com/api/v1/ai/audio', getTicket: issueTicket })
278
93
  * }
279
94
  * ```
280
95
  */
281
- declare function parseSSE(response: Response): AsyncIterable<string>;
282
- /**
283
- * 收集流式响应的完整文本内容
284
- *
285
- * 完整消费流并拼接所有 `delta.content` 片段。
286
- *
287
- * @param stream - 聊天响应块流
288
- * @returns 完整文本
289
- *
290
- * @example
291
- * ```ts
292
- * const client = createAIClient({ api })
293
- * const stream = client.chatStream({ messages })
294
- * const fullText = await collectStreamContent(stream)
295
- * ```
296
- */
297
- declare function collectStreamContent(stream: AsyncIterable<ChatCompletionChunk>): Promise<string>;
298
-
299
- /**
300
- * @h-ai/ai — 前端 A2A 客户端
301
- *
302
- * 浏览器端 A2A 操作客户端,通过 API 服务调用后端 A2A 能力。
303
- * @module ai-a2a-client
304
- */
305
-
306
- /**
307
- * A2A 客户端接口
308
- *
309
- * 提供浏览器端调用后端 A2A API 的能力。
310
- */
311
- interface A2AClientOperations {
312
- /** 获取完整 A2A Agent Card;传输失败时抛出异常 */
313
- getAgentCard: () => Promise<AgentCard>;
314
- /** 查询 A2A 消息记录 */
315
- listMessages: (filter?: {
316
- contextId?: string;
317
- status?: string;
318
- limit?: number;
319
- offset?: number;
320
- }) => Promise<StorePage<A2AMessageRecord>>;
321
- /** 作为客户端调用远端 Agent */
322
- callRemoteAgent: (remoteUrl: string, message: string, options?: {
323
- timeout?: number;
324
- }) => Promise<A2ACallResult>;
325
- }
326
- /**
327
- * 创建 A2A 客户端
328
- *
329
- * @param api - API 适配器(来自 @h-ai/api-client)
330
- * @returns A2A 客户端操作实例
331
- */
332
- declare function createA2AClient(api: AIApiAdapter): A2AClientOperations;
96
+ declare function createAudioClient(config: AudioClientConfig): AudioClientOperations;
333
97
 
334
- export { type A2AClientOperations, type AIApiAdapter, type AIClient, type AIClientConfig, type AudioClientConfig, type AudioClientOperations, type AudioTicketRequest, type StreamOptions, type StreamProgress, collectStreamContent, createA2AClient, createAIClient, createAudioClient, createUnconfiguredAudioClient, parseSSE };
98
+ export { type AudioClientConfig, type AudioClientOperations, type AudioTicketRequest, createAudioClient };
@@ -1,4 +1,4 @@
1
- export { collectStreamContent, createA2AClient, createAIClient, createAudioClient, createUnconfiguredAudioClient, parseSSE } from '../chunk-7SMQSE4S.js';
2
- import '../chunk-JC7QBT3C.js';
1
+ export { createAudioClient } from '../chunk-GMQFIWND.js';
2
+ import '../chunk-HYMP57AC.js';
3
3
  //# sourceMappingURL=index.js.map
4
4
  //# sourceMappingURL=index.js.map
package/dist/index.d.ts CHANGED
@@ -1,19 +1,18 @@
1
- import { az as InteractionScope } from './ai-reasoning-types-DZd_6Umd.js';
2
- export { aA as A2AAgentCardConfig, aB as A2AApiKeySecurity, aC as A2AAuthenticator, aD as A2ACallOptions, aE as A2ACallResult, aF as A2ACallerIdentity, A as A2AConfig, a as A2AConfigSchema, aG as A2AContextInfo, aH as A2AHandleResult, aI as A2AMessageRecord, aJ as A2AOperations, aK as A2ASecurityConfig, b as A2ASkillConfigSchema, aL as A2ATaskFilter, c as AIConfig, d as AIConfigInput, e as AIConfigSchema, aM as AILLMFunctionsDeps, aN as AIRelStore, aO as AIRelStoreOptions, aP as AIStoreProvider, aQ as AIVectorBackend, aR as AIVectorStore, f as ApiType, g as ApiTypeSchema, aS as AskOptions, aT as AssistantMessage, h as AudioCapabilitiesRequest, i as AudioConfig, j as AudioConfigSchema, k as AudioContent, l as AudioFormat, m as AudioInputStream, n as AudioModelCapabilities, o as AudioModelEntry, p as AudioModelEntrySchema, q as AudioOperation, r as AudioOperationSchema, s as AudioOperations, t as AudioOperationsSchema, u as AudioProviderName, v as AudioProviderSchema, w as AudioReference, aU as ChatCompletionChoice, aV as ChatCompletionChunk, aW as ChatCompletionDelta, aX as ChatCompletionRequest, aY as ChatCompletionResponse, aZ as ChatHistoryOptions, a_ as ChatMessage, a$ as ChatRecord, b0 as Citation, C as CompressConfig, x as CompressConfigSchema, b1 as DefineToolOptions, b2 as DeveloperMessage, E as EmbeddingConfig, y as EmbeddingConfigSchema, b3 as EntityDocumentRelation, b4 as EntityDocumentResult, b5 as EntityListOptions, b6 as EntityQueryOptions, z as EntityType, B as EntityTypeSchema, F as FileConfig, D as FileConfigSchema, b7 as GenerateObjectRequest, I as ImageConfig, G as ImageConfigSchema, b8 as ImageContent, H as ImageModelEntry, J as ImageModelEntrySchema, K as ImageProviderName, L as ImageProviderSchema, b9 as KnowledgeAskOptions, ba as KnowledgeAskResult, M as KnowledgeConfig, N as KnowledgeConfigSchema, bb as KnowledgeDocumentInfo, bc as KnowledgeDocumentListOptions, bd as KnowledgeDocumentRemoveOptions, be as KnowledgeEntity, bf as KnowledgeIngestBatchProgress, bg as KnowledgeIngestBatchResult, bh as KnowledgeIngestFileInput, bi as KnowledgeIngestInput, bj as KnowledgeIngestResult, bk as KnowledgeOperations, bl as KnowledgeRetrieveItem, bm as KnowledgeRetrieveOptions, bn as KnowledgeRetrieveResult, bo as KnowledgeSetupOptions, bp as KnowledgeStore, O as LLMConfig, P as LLMConfigSchema, bq as LLMOperations, br as LLMProvider, Q as MCPConfig, R as MCPConfigSchema, S as MCPServerCapabilities, T as MCPServerCapabilitiesSchema, U as MCPServerConfig, V as MCPServerConfigSchema, bs as MemoryAccessScope, bt as MemoryAdminOperations, bu as MemoryClearAllOptions, bv as MemoryClearOptions, W as MemoryConfig, X as MemoryConfigSchema, bw as MemoryCoreOperations, bx as MemoryEntry, by as MemoryEntryInput, bz as MemoryExtractOptions, bA as MemoryInjectionOptions, bB as MemoryListOptions, bC as MemoryListPageOptions, bD as MemoryOperations, bE as MemoryRecallOptions, Y as MemoryType, Z as MemoryTypeSchema, bF as MemoryUpdateInput, bG as MessageContent, bH as MessageRole, _ as ModelEntry, $ as ModelEntrySchema, a0 as ModelScenario, a1 as ModelScenarioSchema, bI as ObjectRef, a2 as OptionalSecretSchema, a3 as PlayableAudio, bJ as RagContextItem, bK as RagOperations, bL as RagOptions, bM as RagResult, bN as RagStreamEvent, bO as ReasoningOperations, bP as ReasoningOptions, bQ as ReasoningResult, bR as ReasoningStep, bS as ReasoningStepType, bT as ReasoningStrategy, bU as ReasoningStreamEvent, a4 as ResolveRequiredModelEntryOptions, a5 as ResolvedAudioModel, a6 as ResolvedImageModel, a7 as ResolvedModelConfig, a8 as RetrievalConfig, a9 as RetrievalConfigSchema, bV as RetrievalOperations, bW as RetrievalRequest, bX as RetrievalResult, bY as RetrievalResultItem, bZ as RetrievalSource, aa as RetrievalSourceConfig, ab as RetrievalSourceSchema, b_ as SSEDecoder, b$ as SSEEvent, c0 as ScopedMemoryBinding, c1 as ScopedMemoryOperations, c2 as SessionInfo, c3 as StoreFilter, c4 as StorePage, c5 as StoreScope, c6 as StreamOperations, c7 as StreamProcessor, c8 as StreamResult, ac as SummaryConfig, ad as SummaryConfigSchema, ae as SynthesisEvent, af as SynthesisOptions, ag as SynthesisRequest, ah as SynthesisResult, ai as SynthesisStreamRequest, aj as SynthesisTextSegment, c9 as SystemMessage, ca as TempModelConfig, cb as TextContent, ak as TokenConfig, al as TokenConfigSchema, cc as TokenUsage, cd as Tool, ce as ToolAuthorizationRequest, cf as ToolAuthorizer, cg as ToolCall, ch as ToolDefinition, ci as ToolErrorType, cj as ToolExecutionContext, ck as ToolExecutionOptions, cl as ToolMessage, cm as ToolRegistryOperations, cn as ToolRegistryOptions, co as ToolsOperations, am as TranscriptionEvent, an as TranscriptionOptions, ao as TranscriptionRequest, ap as TranscriptionResult, aq as TranscriptionSegment, ar as TranscriptionStreamRequest, as as TranscriptionTimestampGranularity, at as TranscriptionWord, cp as UserMessage, cq as WhereClause, cr as WhereOperator, cs as WhereValue, au as ensureAudioCredential, av as resolveAudioModel, aw as resolveImageModel, ax as resolveModelApi, ay as resolveModelEntry } from './ai-reasoning-types-DZd_6Umd.js';
3
- import { A as AIFunctions, M as McpServerOptions } from './ai-audio-ws-protocol-S4N8-LBa.js';
4
- export { a as AIInitOptions, b as AUDIO_WS_PATH, c as AudioFormatSchema, d as AudioWsClientMessage, e as AudioWsClientMessageSchema, f as AudioWsDoneMessage, g as AudioWsDoneMessageSchema, h as AudioWsEndMessage, i as AudioWsErrorMessage, j as AudioWsSegmentDoneMessage, k as AudioWsSegmentStartedMessage, l as AudioWsServerMessage, m as AudioWsSpeechMessage, n as AudioWsStartMessage, o as AudioWsStartMessageSchema, p as AudioWsTextMessage, q as AudioWsTextMessageSchema, r as AudioWsTranscriptMessage, x as CommitTurnInput, y as CompressOperations, z as CompressOptions, B as CompressResult, C as CompressionStrategy, s as CompressionStrategySchema, D as ConsolidateOptions, E as ConsolidateResult, F as ContextChatOptions, J as ContextChatResult, K as ContextDeps, L as ContextManager, N as ContextManagerOptions, O as ContextOperations, P as ContextResetOptions, Q as ContextStreamEvent, S as ConversationTurn, T as ConversationTurnStatus, U as EmbeddingItem, V as EmbeddingOperations, W as EmbeddingProvider, X as EmbeddingRequest, Y as EmbeddingResponse, Z as FileOperations, _ as FileParseMethod, $ as FileParseOptions, a0 as FileParseRequest, a1 as FileParseResult, G as GenerateImageRequest, t as GenerateImageResult, u as GeneratedImage, H as HaiAIError, I as ImageOperations, v as ImageSize, a2 as MCPContext, a3 as MCPOperations, a4 as MCPPrompt, a5 as MCPPromptArgument, a6 as MCPPromptContent, a7 as MCPPromptMessage, a8 as MCPResource, a9 as MCPResourceContent, aa as MCPToolDefinition, ab as MCPToolHandler, ac as OutputFormat, ad as PersonaOperations, ae as PersonaProfile, af as PersonaProfileInput, ag as PersonaProfileUpdate, ah as PersonaScopeOptions, R as ReferenceImage, ai as RerankDocument, aj as RerankItem, ak as RerankOperations, al as RerankRequest, am as RerankResponse, an as SummaryOperations, ao as SummaryOptions, ap as SummaryResult, aq as TokenOperations, w as serializePlayableAudio } from './ai-audio-ws-protocol-S4N8-LBa.js';
1
+ import { r as AIFunctions, bK as McpServerOptions } from './ai-audio-ws-protocol-nfhO0tOo.js';
2
+ 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, 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, 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';
3
+ 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';
5
4
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
5
  export { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
7
- export { TaskStore as A2ATaskStore, AgentExecutor, ExecutionEventBus, RequestContext, ServerCallContext } from '@a2a-js/sdk/server';
8
6
  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';
7
+ export { AgentExecutor, ExecutionEventBus, RequestContext, ServerCallContext } from '@a2a-js/sdk/server';
9
8
  export { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
10
9
  export { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
11
10
  export { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
12
11
  import '@h-ai/core';
13
- import '@h-ai/datapipe';
14
12
  import 'zod';
15
13
  import 'openai';
16
14
  import 'node:buffer';
15
+ import '@h-ai/datapipe';
17
16
  import '@modelcontextprotocol/sdk/types.js';
18
17
  import 'zod/v4/core';
19
18
 
@@ -30,17 +29,18 @@ import 'zod/v4/core';
30
29
  * @example
31
30
  * ```ts
32
31
  * import { ai } from '@h-ai/ai'
33
- *
34
- * // 初始化
35
- * await ai.init({ llm: { model: 'gpt-4o-mini', apiKey: process.env.HAI_AI_LLM_APIKEY } })
36
- *
37
- * // LLM 调用
38
- * const result = await ai.llm.chat({
39
- * messages: [{ role: 'user', content: '你好' }],
40
- * })
41
- *
42
- * // 关闭
43
- * await ai.close()
32
+ * import type { AIConfigInput, AIInitOptions } from '@h-ai/ai'
33
+ * async function run(config: AIConfigInput, options: AIInitOptions) {
34
+ * // 默认 Store 所需 reldb/vecdb 已由应用初始化;显式测试 Store 通过 options 注入。
35
+ * const initialized = await ai.init(config, options)
36
+ * if (!initialized.success) return initialized
37
+ * try {
38
+ * const result = await ai.llm.chat({ messages: [{ role: 'user', content: '你好' }] })
39
+ * if (!result.success) return result
40
+ * return result.data.choices[0]?.message.content
41
+ * }
42
+ * finally { await ai.close() }
43
+ * }
44
44
  * ```
45
45
  */
46
46
  declare const ai: AIFunctions;
@@ -70,26 +70,4 @@ declare const ai: AIFunctions;
70
70
  */
71
71
  declare function createMcpServer(options: McpServerOptions): McpServer;
72
72
 
73
- /**
74
- * @h-ai/ai — 会话存储键
75
- *
76
- * 提供 LLM / Context / SessionStore 共用的复合存储键构造,确保不同交互主体
77
- * 使用相同 sessionId 时不会在会话目录(SessionInfo)与上下文正文上互相覆盖。
78
- * @module store/ai-store-key
79
- */
80
-
81
- /**
82
- * 构造会话存储的复合主键
83
- *
84
- * 用 JSON 数组序列化 `[objectId, sessionId]`,避免朴素拼接 `${objectId}:${sessionId}`
85
- * 在 id 本身含分隔符时产生碰撞(如 `a` + `b:c` 与 `a:b` + `c` 得到同一键),
86
- * 也避免不同主体相同 sessionId 因裸 sessionId 作主键而互相覆盖。
87
- *
88
- * LLM、Context 与 SessionStore 必须共用此实现。
89
- *
90
- * @param scope - 交互作用域(主体 ID + 会话 ID)
91
- * @returns 复合存储键
92
- */
93
- declare function sessionStoreKey(scope: InteractionScope): string;
94
-
95
- export { AIFunctions, InteractionScope, McpServerOptions, ai, createMcpServer, sessionStoreKey };
73
+ export { AIFunctions, McpServerOptions, ai, createMcpServer };