@h-ai/ai 0.1.0-alpha9 → 1.0.0-beta.10
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 +676 -0
- package/README.ja.md +676 -0
- package/README.md +491 -1678
- package/dist/ai-acp-types-DQ8jO9Ie.d.ts +9763 -0
- package/dist/ai-audio-types-4R5yUAVl.d.ts +614 -0
- package/dist/browser.d.ts +10 -6
- package/dist/browser.js +3 -2
- package/dist/chunk-HEYVFQC6.js +1232 -0
- package/dist/chunk-HEYVFQC6.js.map +1 -0
- package/dist/chunk-M77C3VAP.js +139 -0
- package/dist/chunk-M77C3VAP.js.map +1 -0
- package/dist/chunk-O6P4P5PC.js +254 -0
- package/dist/chunk-O6P4P5PC.js.map +1 -0
- package/dist/client/index.d.ts +63 -231
- package/dist/client/index.js +2 -1
- package/dist/index.d.ts +50 -23
- package/dist/index.js +9869 -1687
- package/dist/index.js.map +1 -1
- package/models/agents/README.md +48 -0
- package/models/agents/build.mjs +66 -0
- package/models/agents/codex-acp/Dockerfile +25 -0
- package/models/agents/codex-acp/agent.json +16 -0
- package/models/agents/deepseek-harness/Dockerfile +23 -0
- package/models/agents/deepseek-harness/agent.json +14 -0
- package/models/agents/goose/Dockerfile +34 -0
- package/models/agents/goose/agent.json +14 -0
- package/package.json +48 -22
- package/dist/ai-reasoning-types-CGUgkLF7.d.ts +0 -2823
- package/dist/ai-types-CRCjluXI.d.ts +0 -1095
- package/dist/api/index.d.ts +0 -628
- package/dist/api/index.js +0 -243
- package/dist/api/index.js.map +0 -1
- package/dist/chunk-6PPXWQ7I.js +0 -462
- package/dist/chunk-6PPXWQ7I.js.map +0 -1
- package/dist/chunk-ABP7RKIP.js +0 -311
- package/dist/chunk-ABP7RKIP.js.map +0 -1
package/dist/client/index.d.ts
CHANGED
|
@@ -1,266 +1,98 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import '@a2a-js/sdk/server';
|
|
4
|
-
import '@h-ai/datapipe';
|
|
5
|
-
import 'zod';
|
|
6
|
-
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';
|
|
7
3
|
|
|
8
4
|
/**
|
|
9
|
-
* @h-ai/ai —
|
|
5
|
+
* @h-ai/ai/client — 浏览器语音客户端
|
|
10
6
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* @module ai-client
|
|
7
|
+
* 通过统一 WebSocket 连接 `@h-ai/serv` 的语音入口,向浏览器暴露与 Node 端一致的
|
|
8
|
+
* `ai.audio.*` 业务 API。WebSocket 建立、消息编解码等传输细节在此内部完成,
|
|
9
|
+
* 调用方不接触任何厂商原生事件。
|
|
10
|
+
* @module client/ai-audio-client
|
|
15
11
|
*/
|
|
16
12
|
|
|
17
13
|
/**
|
|
18
|
-
*
|
|
14
|
+
* getTicket 收到的当前 Audio 请求摘要
|
|
19
15
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*/
|
|
23
|
-
interface AIApiAdapter {
|
|
24
|
-
/** POST 请求(返回 HaiResult) */
|
|
25
|
-
post: <T>(path: string, body?: unknown) => Promise<HaiResult<T>>;
|
|
26
|
-
/** 流式请求(返回 SSE data 行的 AsyncIterable) */
|
|
27
|
-
stream: (path: string, body?: unknown) => AsyncIterable<string>;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* AI 客户端配置
|
|
16
|
+
* 供应用签发与本次操作严格绑定的能力票据(如 `iam.ticket.issue({ grant })`),
|
|
17
|
+
* 使票据只能用于本次操作 / 模型 / 会话,降低票据被重放的风险。
|
|
31
18
|
*
|
|
32
19
|
* @example
|
|
33
20
|
* ```ts
|
|
34
|
-
* import {
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* const aiClient = createAIClient({ api })
|
|
21
|
+
* import type { AudioTicketRequest } from '@h-ai/ai/client'
|
|
22
|
+
* function grant(request: AudioTicketRequest) {
|
|
23
|
+
* return { operation: request.operation, model: request.model } // 经已登录 HTTP 接口签发并在服务端原子消费。
|
|
24
|
+
* }
|
|
39
25
|
* ```
|
|
40
26
|
*/
|
|
41
|
-
interface
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
* baseUrl、Token 管理、超时等通过 api-client 配置。
|
|
47
|
-
*/
|
|
48
|
-
api: AIApiAdapter;
|
|
49
|
-
}
|
|
50
|
-
/** 流式响应进度(`onProgress` 回调参数) */
|
|
51
|
-
interface StreamProgress {
|
|
52
|
-
/** 当前累积的文本内容 */
|
|
53
|
-
content: string;
|
|
54
|
-
/** 是否已完成 */
|
|
55
|
-
done: boolean;
|
|
56
|
-
/** 完成原因(仅 `done=true` 时有值,如 `'stop'`) */
|
|
57
|
-
finishReason?: string;
|
|
58
|
-
}
|
|
59
|
-
/** 流式响应选项 */
|
|
60
|
-
interface StreamOptions {
|
|
61
|
-
/** 进度回调(每次收到 chunk 时触发) */
|
|
62
|
-
onProgress?: (progress: StreamProgress) => void;
|
|
27
|
+
interface AudioTicketRequest {
|
|
28
|
+
/** 本次操作类型 */
|
|
29
|
+
operation: 'transcribe' | 'synthesize';
|
|
30
|
+
/** 本次使用的模型 ID(如有指定) */
|
|
31
|
+
model?: string;
|
|
63
32
|
}
|
|
64
33
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* 提供浏览器端调用 AI API 的能力,HTTP 基础设施委托给 @h-ai/api-client。
|
|
68
|
-
*/
|
|
69
|
-
interface AIClient {
|
|
70
|
-
/** 发送对话请求(非流式) */
|
|
71
|
-
chat: (request: ChatCompletionRequest) => Promise<ChatCompletionResponse>;
|
|
72
|
-
/** 发送流式对话请求,返回异步迭代器 */
|
|
73
|
-
chatStream: (request: ChatCompletionRequest, options?: StreamOptions) => AsyncIterable<ChatCompletionChunk>;
|
|
74
|
-
/** 便捷方法:发送纯文本消息并返回回复文本 */
|
|
75
|
-
sendMessage: (message: string, systemPrompt?: string) => Promise<string>;
|
|
76
|
-
/** 便捷方法:流式发送纯文本消息并返回完整回复 */
|
|
77
|
-
sendMessageStream: (message: string, options?: StreamOptions, systemPrompt?: string) => Promise<string>;
|
|
78
|
-
/** 简单问答(单轮,自动构造 messages) */
|
|
79
|
-
ask: (question: string, options?: {
|
|
80
|
-
systemPrompt?: string;
|
|
81
|
-
model?: string;
|
|
82
|
-
}) => Promise<string>;
|
|
83
|
-
/** 流式简单问答,返回异步文本流 */
|
|
84
|
-
askStream: (question: string, options?: {
|
|
85
|
-
systemPrompt?: string;
|
|
86
|
-
model?: string;
|
|
87
|
-
}) => AsyncIterable<string>;
|
|
88
|
-
/** 知识检索(向量 + 实体增强) */
|
|
89
|
-
knowledgeRetrieve: (query: string, options?: {
|
|
90
|
-
topK?: number;
|
|
91
|
-
collection?: string;
|
|
92
|
-
}) => Promise<KnowledgeRetrieveResult>;
|
|
93
|
-
/** 知识问答(RAG + 信源) */
|
|
94
|
-
knowledgeAsk: (query: string, options?: {
|
|
95
|
-
model?: string;
|
|
96
|
-
collection?: string;
|
|
97
|
-
}) => Promise<KnowledgeAskResult>;
|
|
98
|
-
/** 导入文档 */
|
|
99
|
-
knowledgeIngest: (input: {
|
|
100
|
-
documentId: string;
|
|
101
|
-
content: string;
|
|
102
|
-
title?: string;
|
|
103
|
-
collection?: string;
|
|
104
|
-
metadata?: Record<string, unknown>;
|
|
105
|
-
}) => Promise<KnowledgeIngestResult>;
|
|
106
|
-
/** 列出已导入文档 */
|
|
107
|
-
knowledgeListDocuments: (options?: {
|
|
108
|
-
collection?: string;
|
|
109
|
-
offset?: number;
|
|
110
|
-
limit?: number;
|
|
111
|
-
}) => Promise<KnowledgeDocumentInfo[]>;
|
|
112
|
-
/** 删除已导入文档 */
|
|
113
|
-
knowledgeRemoveDocument: (documentId: string, options?: {
|
|
114
|
-
collection?: string;
|
|
115
|
-
}) => Promise<void>;
|
|
116
|
-
/** 检索相关记忆 */
|
|
117
|
-
recallMemories: (query: string, options?: {
|
|
118
|
-
topK?: number;
|
|
119
|
-
types?: string[];
|
|
120
|
-
minImportance?: number;
|
|
121
|
-
objectId?: string;
|
|
122
|
-
}) => Promise<MemoryEntry[]>;
|
|
123
|
-
/** 列出记忆(分页) */
|
|
124
|
-
listMemories: (options?: {
|
|
125
|
-
types?: string[];
|
|
126
|
-
objectId?: string;
|
|
127
|
-
offset?: number;
|
|
128
|
-
limit?: number;
|
|
129
|
-
}) => Promise<StorePage<MemoryEntry>>;
|
|
130
|
-
/** 添加记忆 */
|
|
131
|
-
addMemory: (entry: MemoryEntryInput) => Promise<MemoryEntry>;
|
|
132
|
-
/** 更新记忆 */
|
|
133
|
-
updateMemory: (memoryId: string, updates: MemoryUpdateInput) => Promise<MemoryEntry>;
|
|
134
|
-
/** 删除记忆 */
|
|
135
|
-
removeMemory: (memoryId: string) => Promise<void>;
|
|
136
|
-
/** 列出会话 */
|
|
137
|
-
listSessions: (objectId: string) => Promise<SessionInfo[]>;
|
|
138
|
-
/** 重命名会话 */
|
|
139
|
-
renameSession: (sessionId: string, title: string) => Promise<void>;
|
|
140
|
-
/** 删除会话 */
|
|
141
|
-
removeSession: (sessionId: string) => Promise<void>;
|
|
142
|
-
/** 获取对话历史 */
|
|
143
|
-
chatHistory: (objectId: string, sessionId: string, options?: {
|
|
144
|
-
limit?: number;
|
|
145
|
-
order?: 'asc' | 'desc';
|
|
146
|
-
}) => Promise<ChatRecord[]>;
|
|
147
|
-
/** RAG 查询(检索 + 生成) */
|
|
148
|
-
ragQuery: (query: string, options?: {
|
|
149
|
-
collection?: string;
|
|
150
|
-
topK?: number;
|
|
151
|
-
model?: string;
|
|
152
|
-
}) => Promise<RagResult>;
|
|
153
|
-
/** RAG 流式查询,返回 SSE 数据行 */
|
|
154
|
-
ragQueryStream: (query: string, options?: {
|
|
155
|
-
collection?: string;
|
|
156
|
-
topK?: number;
|
|
157
|
-
model?: string;
|
|
158
|
-
}) => AsyncIterable<string>;
|
|
159
|
-
/** 推理(多步思考) */
|
|
160
|
-
reasoningRun: (query: string, options?: {
|
|
161
|
-
model?: string;
|
|
162
|
-
maxSteps?: number;
|
|
163
|
-
}) => Promise<ReasoningResult>;
|
|
164
|
-
/** 推理流式,返回 SSE 数据行 */
|
|
165
|
-
reasoningRunStream: (query: string, options?: {
|
|
166
|
-
model?: string;
|
|
167
|
-
maxSteps?: number;
|
|
168
|
-
}) => AsyncIterable<string>;
|
|
169
|
-
/** 估算文本的 Token 数 */
|
|
170
|
-
estimateTokens: (text: string) => Promise<{
|
|
171
|
-
tokens: number;
|
|
172
|
-
}>;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* 创建 AI 客户端
|
|
176
|
-
*
|
|
177
|
-
* 通过 @h-ai/api-client 的 ApiClient 实例调用后端 AI API。
|
|
178
|
-
* HTTP 层(Token、超时、拦截器)全部复用 api-client,本模块仅负责:
|
|
179
|
-
* - 非流式 / 流式 ChatCompletion 协议适配
|
|
180
|
-
* - SSE 解析与 ChatCompletionChunk 类型化
|
|
181
|
-
* - onProgress 进度回调
|
|
182
|
-
*
|
|
183
|
-
* @param config - 客户端配置
|
|
184
|
-
* @returns AI 客户端实例
|
|
34
|
+
* 浏览器语音客户端配置
|
|
185
35
|
*
|
|
186
36
|
* @example
|
|
187
37
|
* ```ts
|
|
188
|
-
* import {
|
|
189
|
-
* import {
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
* const reply = await client.sendMessage('你好')
|
|
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
|
+
* }
|
|
194
43
|
* ```
|
|
195
44
|
*/
|
|
196
|
-
|
|
45
|
+
interface AudioClientConfig {
|
|
46
|
+
/** 语音 WebSocket 完整 URL(如 `wss://host/api/v1/ai/audio`) */
|
|
47
|
+
url: string;
|
|
48
|
+
/**
|
|
49
|
+
* 获取短期、一次性的 Audio WebSocket ticket
|
|
50
|
+
*
|
|
51
|
+
* ticket 应由已登录 HTTP 请求签发,并在服务端首次校验时原子消费。
|
|
52
|
+
* 收到当前请求摘要(operation / model),可签发与本次操作严格绑定的票据。
|
|
53
|
+
*/
|
|
54
|
+
getTicket: (request: AudioTicketRequest) => string | Promise<string>;
|
|
55
|
+
}
|
|
197
56
|
/**
|
|
198
|
-
*
|
|
57
|
+
* 浏览器语音操作接口
|
|
199
58
|
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
* @param response - fetch 响应对象
|
|
203
|
-
* @yields SSE data 字符串(不含 `[DONE]`)
|
|
59
|
+
* 与 Node 端 `AudioOperations` 业务形态一致;出错时抛出异常(浏览器 Client 约定)。
|
|
204
60
|
*
|
|
205
61
|
* @example
|
|
206
62
|
* ```ts
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
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
|
|
210
68
|
* }
|
|
211
69
|
* ```
|
|
212
70
|
*/
|
|
213
|
-
|
|
71
|
+
interface AudioClientOperations {
|
|
72
|
+
/** 将完整音频识别为完整文本 */
|
|
73
|
+
transcribe: (request: TranscriptionRequest) => Promise<TranscriptionResult>;
|
|
74
|
+
/** 持续输入音频或增量返回识别文本(含语音起止事件) */
|
|
75
|
+
transcribeStream: (request: TranscriptionStreamRequest) => AsyncIterable<TranscriptionEvent>;
|
|
76
|
+
/** 将完整文本合成为完整音频 */
|
|
77
|
+
synthesize: (request: SynthesisRequest) => Promise<SynthesisResult>;
|
|
78
|
+
/** 持续输入文本段并按段输出结构化音频事件 */
|
|
79
|
+
synthesizeStream: (request: SynthesisStreamRequest) => AsyncIterable<SynthesisEvent>;
|
|
80
|
+
}
|
|
214
81
|
/**
|
|
215
|
-
*
|
|
82
|
+
* 创建浏览器语音客户端
|
|
216
83
|
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
* @param stream - 聊天响应块流
|
|
220
|
-
* @returns 完整文本
|
|
84
|
+
* @param config - 语音客户端配置
|
|
85
|
+
* @returns 浏览器语音操作接口
|
|
221
86
|
*
|
|
222
87
|
* @example
|
|
223
88
|
* ```ts
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
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 })
|
|
93
|
+
* }
|
|
227
94
|
* ```
|
|
228
95
|
*/
|
|
229
|
-
declare function
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* @h-ai/ai — 前端 A2A 客户端
|
|
233
|
-
*
|
|
234
|
-
* 浏览器端 A2A 操作客户端,通过 API 服务调用后端 A2A 能力。
|
|
235
|
-
* @module ai-a2a-client
|
|
236
|
-
*/
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* A2A 客户端接口
|
|
240
|
-
*
|
|
241
|
-
* 提供浏览器端调用后端 A2A API 的能力。
|
|
242
|
-
*/
|
|
243
|
-
interface A2AClientOperations {
|
|
244
|
-
/** 获取当前 Agent Card 配置 */
|
|
245
|
-
getAgentCard: () => Promise<A2AAgentCardConfig>;
|
|
246
|
-
/** 查询 A2A 消息记录 */
|
|
247
|
-
listMessages: (filter?: {
|
|
248
|
-
contextId?: string;
|
|
249
|
-
status?: string;
|
|
250
|
-
limit?: number;
|
|
251
|
-
offset?: number;
|
|
252
|
-
}) => Promise<StorePage<A2AMessageRecord>>;
|
|
253
|
-
/** 作为客户端调用远端 Agent */
|
|
254
|
-
callRemoteAgent: (remoteUrl: string, message: string, options?: {
|
|
255
|
-
timeout?: number;
|
|
256
|
-
}) => Promise<A2ACallResult>;
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* 创建 A2A 客户端
|
|
260
|
-
*
|
|
261
|
-
* @param api - API 适配器(来自 @h-ai/api-client)
|
|
262
|
-
* @returns A2A 客户端操作实例
|
|
263
|
-
*/
|
|
264
|
-
declare function createA2AClient(api: AIApiAdapter): A2AClientOperations;
|
|
96
|
+
declare function createAudioClient(config: AudioClientConfig): AudioClientOperations;
|
|
265
97
|
|
|
266
|
-
export { type
|
|
98
|
+
export { type AudioClientConfig, type AudioClientOperations, type AudioTicketRequest, createAudioClient };
|
package/dist/client/index.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export { a as
|
|
4
|
-
|
|
1
|
+
import { I as AIFunctions, c7 as McpServerOptions } from './ai-acp-types-DQ8jO9Ie.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 ACPAgentAdapter, p as ACPAgentAdapterInput, q as ACPAgentLaunch, r as ACPAgentSchema, s as ACPClientOptions, t as ACPConfig, u as ACPConfigInput, v as ACPConfigSchema, w as ACPCreateSessionOptions, x as ACPGitReport, y as ACPOperations, z as ACPPublishSchema, B as ACPRepositorySchema, C as ACPSessionInfo, D as ACPTransport, E as ACPWorkspaceSchema, F as AIConfig, G as AIConfigInput, H as AIConfigSchema, J as AIInitOptions, K as AIRelStore, L as AIRelStoreCompareAndSwap, M as AIRelStoreOptions, N as AIResourceEntry, O as AIResourceRegistry, P as AIStoreProvider, Q as AIVectorBackend, R as AIVectorStore, S as AIVersionedRecord, T as AUDIO_WS_PATH, U as ApiType, V as ApiTypeSchema, W as AskOptions, X as AssistantMessage, Y as AudioConfig, Z as AudioConfigSchema, _ as AudioFormatSchema, $ as AudioModelEntry, a0 as AudioModelEntrySchema, a1 as AudioOperation, a2 as AudioOperationSchema, a3 as AudioOperationsSchema, a4 as AudioProviderName, a5 as AudioProviderSchema, a6 as AudioWsClientMessage, a7 as AudioWsClientMessageSchema, a8 as AudioWsDoneMessage, a9 as AudioWsDoneMessageSchema, aa as AudioWsEndMessage, ab as AudioWsErrorMessage, ac as AudioWsSegmentDoneMessage, ad as AudioWsSegmentStartedMessage, ae as AudioWsServerMessage, af as AudioWsSpeechMessage, ag as AudioWsStartMessage, ah as AudioWsStartMessageSchema, ai as AudioWsTextMessage, aj as AudioWsTextMessageSchema, ak as AudioWsTranscriptMessage, al as ChatCompletionChoice, am as ChatCompletionChunk, an as ChatCompletionDelta, ao as ChatCompletionRequest, ap as ChatCompletionResponse, aq as ChatHistoryOptions, ar as ChatMessage, as as ChatRecord, at as Citation, au as CommitTurnInput, av as CompressConfig, aw as CompressConfigSchema, ax as CompressOperations, ay as CompressOptions, az as CompressResult, aA as CompressionStrategy, aB as CompressionStrategySchema, aC as ConsolidateOptions, aD as ConsolidateResult, aE as ContextChatOptions, aF as ContextChatResult, aG as ContextManager, aH as ContextManagerOptions, aI as ContextOperations, aJ as ContextResetOptions, aK as ContextStreamEvent, aL as ConversationTurn, aM as ConversationTurnStatus, aN as DefineToolOptions, aO as DeveloperMessage, aP as EmbeddingConfig, aQ as EmbeddingConfigSchema, aR as EmbeddingItem, aS as EmbeddingOperations, aT as EmbeddingRequest, aU as EmbeddingResponse, aV as EntityDocumentRelation, aW as EntityDocumentResult, aX as EntityListOptions, aY as EntityQueryOptions, aZ as EntityType, a_ as EntityTypeSchema, a$ as FileConfig, b0 as FileConfigSchema, b1 as FileOperations, b2 as FileParseMethod, b3 as FileParseOptions, b4 as FileParseRequest, b5 as FileParseResult, b6 as GenerateImageRequest, b7 as GenerateImageResult, b8 as GenerateObjectRequest, b9 as GeneratedImage, ba as HaiAIError, bb as ImageConfig, bc as ImageConfigSchema, bd as ImageContent, be as ImageModelEntry, bf as ImageModelEntrySchema, bg as ImageOperations, bh as ImageProviderName, bi as ImageProviderSchema, bj as ImageSize, bk as InteractionScope, bl as KnowledgeAskOptions, bm as KnowledgeAskResult, bn as KnowledgeConfig, bo as KnowledgeConfigSchema, bp as KnowledgeDocumentInfo, bq as KnowledgeDocumentListOptions, br as KnowledgeDocumentMetadata, bs as KnowledgeDocumentRemoveOptions, bt as KnowledgeDocumentRevision, bu as KnowledgeEntity, bv as KnowledgeIngestBatchProgress, bw as KnowledgeIngestBatchResult, bx as KnowledgeIngestFileInput, by as KnowledgeIngestInput, bz as KnowledgeIngestResult, bA as KnowledgeOperations, bB as KnowledgeRepairOptions, bC as KnowledgeRepairProgress, bD as KnowledgeRepairResult, bE as KnowledgeRetrieveItem, bF as KnowledgeRetrieveOptions, bG as KnowledgeRetrieveResult, bH as KnowledgeSetupOptions, bI as KnowledgeStore, bJ as LLMConfig, bK as LLMConfigSchema, bL as LLMOperations, bM as MCPConfig, bN as MCPConfigSchema, bO as MCPContext, bP as MCPExternalServer, bQ as MCPExternalServerSchema, bR as MCPOperations, bS as MCPPrompt, bT as MCPPromptArgument, bU as MCPPromptContent, bV as MCPPromptMessage, bW as MCPResource, bX as MCPResourceContent, bY as MCPServerCapabilities, bZ as MCPServerCapabilitiesSchema, b_ as MCPServerConfig, b$ as MCPServerConfigSchema, c0 as MCPToolDefinition, c1 as MCPToolHandler, c2 as ManagedAudioOperations, c3 as ManagedImageOperations, c4 as ManagedLLMOperations, c5 as ManagedMCPOperations, c6 as ManagedRetrievalOperations, c8 as MemoryAccessScope, c9 as MemoryAdminOperations, ca as MemoryClearAllOptions, cb as MemoryClearOptions, cc as MemoryConfig, cd as MemoryConfigSchema, ce as MemoryCoreOperations, cf as MemoryEntry, cg as MemoryEntryInput, ch as MemoryExtractOptions, ci as MemoryInjectionOptions, cj as MemoryListOptions, ck as MemoryListPageOptions, cl as MemoryOperations, cm as MemoryRecallOptions, cn as MemoryType, co as MemoryTypeSchema, cp as MemoryUpdateInput, cq as MessageContent, cr as MessageRole, cs as ModelCapabilitiesSchema, ct as ModelEntry, cu as ModelEntrySchema, cv as ModelScenario, cw as ModelScenarioSchema, cx as ObjectRef, cy as OptionalSecretSchema, cz 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, c_ as ResolvedModelConfig, c$ as RetrievalConfig, d0 as RetrievalConfigSchema, d1 as RetrievalOperations, d2 as RetrievalRequest, d3 as RetrievalResult, d4 as RetrievalResultItem, d5 as RetrievalSource, d6 as RetrievalSourceConfig, d7 as RetrievalSourceSchema, d8 as SSEDecoder, d9 as SSEEvent, da as ScopedMemoryBinding, db as ScopedMemoryOperations, dc as SessionInfo, dd as StoreFilter, de as StorePage, df as StoreScope, dg as StreamOperations, dh as StreamProcessor, di as StreamResult, dj as SummaryConfig, dk as SummaryConfigSchema, dl as SummaryOperations, dm as SummaryOptions, dn as SummaryResult, dp as SystemMessage, dq as TempModelConfig, dr as TextContent, ds as TokenConfig, dt as TokenConfigSchema, du as TokenOperations, dv as TokenUsage, dw as Tool, dx as ToolAuthorizationRequest, dy as ToolAuthorizer, dz as ToolCall, dA as ToolDefinition, dB as ToolErrorType, dC as ToolExecutionContext, dD as ToolExecutionOptions, dE as ToolMessage, dF as ToolRegistryOperations, dG as ToolRegistryOptions, dH as ToolsOperations, dI as UserMessage, dJ as WhereClause, dK as WhereOperator, dL as WhereValue, dM as ensureAudioCredential, dN as resolveAudioModel, dO as resolveImageModel, dP as resolveModelApi, dQ as resolveModelEntry, dR as serializePlayableAudio } from './ai-acp-types-DQ8jO9Ie.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';
|
|
4
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
|
+
export { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
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';
|
|
8
|
+
export { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
|
|
9
|
+
export { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
10
|
+
export { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
6
11
|
import '@h-ai/core';
|
|
7
|
-
import '@h-ai/datapipe';
|
|
8
12
|
import 'zod';
|
|
9
|
-
import 'openai';
|
|
10
13
|
import 'node:buffer';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* @module ai-main
|
|
17
|
-
*/
|
|
14
|
+
import '@h-ai/datapipe';
|
|
15
|
+
import 'zod/v4/core';
|
|
16
|
+
import '@agentclientprotocol/sdk';
|
|
17
|
+
import 'openai';
|
|
18
|
+
import '@modelcontextprotocol/sdk/types.js';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* AI 服务对象,统一的 AI 访问入口
|
|
@@ -22,19 +23,45 @@ import 'node:buffer';
|
|
|
22
23
|
* @example
|
|
23
24
|
* ```ts
|
|
24
25
|
* import { ai } from '@h-ai/ai'
|
|
26
|
+
* import type { AIConfigInput, AIInitOptions } from '@h-ai/ai'
|
|
27
|
+
* async function run(config: AIConfigInput, options: AIInitOptions) {
|
|
28
|
+
* // 默认 Store 所需 reldb/vecdb 已由应用初始化;显式测试 Store 通过 options 注入。
|
|
29
|
+
* const initialized = await ai.init(config, options)
|
|
30
|
+
* if (!initialized.success) return initialized
|
|
31
|
+
* try {
|
|
32
|
+
* const result = await ai.llm.chat({ messages: [{ role: 'user', content: '你好' }] })
|
|
33
|
+
* if (!result.success) return result
|
|
34
|
+
* return result.data.choices[0]?.message.content
|
|
35
|
+
* }
|
|
36
|
+
* finally { await ai.close() }
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
declare const ai: AIFunctions;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @h-ai/ai — MCP Server 创建与传输层
|
|
44
|
+
*
|
|
45
|
+
* 基于 `@modelcontextprotocol/sdk` 封装,提供便捷的 MCP 服务器创建。
|
|
46
|
+
* @module ai-mcp-server
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 创建 MCP 服务器
|
|
25
51
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
52
|
+
* @param options - 服务器选项(名称、版本)
|
|
53
|
+
* @returns McpServer 实例
|
|
28
54
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* })
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { createMcpServer, StdioServerTransport } from '@h-ai/ai'
|
|
33
58
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
59
|
+
* const server = createMcpServer({ name: 'my-server', version: '1.0.0' })
|
|
60
|
+
* // 注册工具 / 资源 ...
|
|
61
|
+
* const transport = new StdioServerTransport()
|
|
62
|
+
* await server.connect(transport)
|
|
36
63
|
* ```
|
|
37
64
|
*/
|
|
38
|
-
declare
|
|
65
|
+
declare function createMcpServer(options: McpServerOptions): McpServer;
|
|
39
66
|
|
|
40
|
-
export { AIFunctions, ai };
|
|
67
|
+
export { AIFunctions, McpServerOptions, ai, createMcpServer };
|