@h-ai/ai 1.0.0-beta.2 → 1.0.0-beta.21
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 +399 -74
- package/README.ja.md +400 -75
- package/README.md +405 -76
- package/dist/{ai-audio-ws-protocol-nfhO0tOo.d.ts → ai-acp-types-BNeA1j0P.d.ts} +2492 -229
- package/dist/browser.d.ts +5 -4
- package/dist/browser.js +3 -3
- package/dist/{chunk-HEVXR252.js → chunk-55A3S4AH.js} +424 -57
- package/dist/chunk-55A3S4AH.js.map +1 -0
- package/dist/{chunk-HYMP57AC.js → chunk-M77C3VAP.js} +23 -2
- package/dist/chunk-M77C3VAP.js.map +1 -0
- package/dist/{chunk-GMQFIWND.js → chunk-WSH2246H.js} +51 -12
- package/dist/chunk-WSH2246H.js.map +1 -0
- package/dist/client/index.d.ts +3 -2
- package/dist/client/index.js +2 -2
- package/dist/index.d.ts +7 -13
- package/dist/index.js +6805 -1513
- package/dist/index.js.map +1 -1
- package/models/agents/README.md +107 -0
- package/models/agents/build.mjs +74 -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 +24 -31
- package/dist/chunk-GMQFIWND.js.map +0 -1
- package/dist/chunk-HEVXR252.js.map +0 -1
- package/dist/chunk-HYMP57AC.js.map +0 -1
|
@@ -1,15 +1,249 @@
|
|
|
1
1
|
import * as _h_ai_core from '@h-ai/core';
|
|
2
2
|
import { HaiResult, HaiError } from '@h-ai/core';
|
|
3
|
-
import {
|
|
3
|
+
import { TaskState } from '@a2a-js/sdk';
|
|
4
4
|
import { AgentExecutor } from '@a2a-js/sdk/server';
|
|
5
5
|
import * as zod from 'zod';
|
|
6
|
-
import {
|
|
7
|
-
import { e as AudioOperations, a as AudioContent, P as PlayableAudio, b as AudioFormat } from './ai-audio-types-4R5yUAVl.js';
|
|
8
|
-
import OpenAI from 'openai';
|
|
6
|
+
import { z, ZodType } from 'zod';
|
|
9
7
|
import { Buffer } from 'node:buffer';
|
|
10
8
|
import { CleanOptionsInput, ChunkOptionsInput } from '@h-ai/datapipe';
|
|
11
|
-
import {
|
|
9
|
+
import { e as AudioOperations, a as AudioContent, P as PlayableAudio, b as AudioFormat } from './ai-audio-types-4R5yUAVl.js';
|
|
12
10
|
import * as zod_v4_core from 'zod/v4/core';
|
|
11
|
+
import * as _agentclientprotocol_sdk from '@agentclientprotocol/sdk';
|
|
12
|
+
import { McpServer, ContentBlock, SessionNotification, ClientRequestHandlersByMethod, ClientCapabilities } from '@agentclientprotocol/sdk';
|
|
13
|
+
import OpenAI from 'openai';
|
|
14
|
+
import { PromptMessage } from '@modelcontextprotocol/sdk/types.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 工程主分支必须显式填写。
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { ACPRepositorySchema } from '@h-ai/ai'
|
|
21
|
+
* const repository = ACPRepositorySchema.parse({ id: 'api', url: 'https://example.com/api.git', mainBranch: 'trunk' })
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
declare const ACPRepositorySchema: z.ZodObject<{
|
|
25
|
+
id: z.ZodString;
|
|
26
|
+
url: z.ZodString;
|
|
27
|
+
mainBranch: z.ZodString;
|
|
28
|
+
remote: z.ZodDefault<z.ZodString>;
|
|
29
|
+
}, z.core.$strict>;
|
|
30
|
+
/**
|
|
31
|
+
* 工作区持久目录或容器卷。
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { ACPWorkspaceSchema } from '@h-ai/ai'
|
|
35
|
+
* const workspace = ACPWorkspaceSchema.parse({ id: 'project', storage: { type: 'directory', path: '/srv/project' }, repositories: [] })
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare const ACPWorkspaceSchema: z.ZodObject<{
|
|
39
|
+
id: z.ZodString;
|
|
40
|
+
storage: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
41
|
+
type: z.ZodLiteral<"directory">;
|
|
42
|
+
path: z.ZodString;
|
|
43
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
44
|
+
type: z.ZodLiteral<"volume">;
|
|
45
|
+
name: z.ZodString;
|
|
46
|
+
engine: z.ZodDefault<z.ZodEnum<{
|
|
47
|
+
auto: "auto";
|
|
48
|
+
podman: "podman";
|
|
49
|
+
docker: "docker";
|
|
50
|
+
}>>;
|
|
51
|
+
image: z.ZodString;
|
|
52
|
+
}, z.core.$strict>], "type">;
|
|
53
|
+
repositories: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
54
|
+
id: z.ZodString;
|
|
55
|
+
url: z.ZodString;
|
|
56
|
+
mainBranch: z.ZodString;
|
|
57
|
+
remote: z.ZodDefault<z.ZodString>;
|
|
58
|
+
}, z.core.$strict>>>;
|
|
59
|
+
environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
60
|
+
gitEnvironmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
61
|
+
}, z.core.$strict>;
|
|
62
|
+
/**
|
|
63
|
+
* Agent 定义,仅保存凭据引用。
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* import { ACPAgentSchema } from '@h-ai/ai'
|
|
67
|
+
* const agent = ACPAgentSchema.parse({ id: 'coder', name: 'Coder', mode: 'embedded', adapter: 'codex', modelIds: ['coding'], defaultModelId: 'coding' })
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
declare const ACPAgentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
71
|
+
mode: z.ZodLiteral<"custom-service">;
|
|
72
|
+
transport: z.ZodEnum<{
|
|
73
|
+
http: "http";
|
|
74
|
+
ws: "ws";
|
|
75
|
+
}>;
|
|
76
|
+
url: z.ZodURL;
|
|
77
|
+
headerEnv: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
78
|
+
supportedTransports: z.ZodArray<z.ZodEnum<{
|
|
79
|
+
http: "http";
|
|
80
|
+
ws: "ws";
|
|
81
|
+
}>>;
|
|
82
|
+
id: z.ZodString;
|
|
83
|
+
name: z.ZodString;
|
|
84
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
85
|
+
adapter: z.ZodDefault<z.ZodString>;
|
|
86
|
+
modelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
87
|
+
defaultModelId: z.ZodOptional<z.ZodString>;
|
|
88
|
+
environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
89
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
90
|
+
mode: z.ZodLiteral<"embedded">;
|
|
91
|
+
transport: z.ZodDefault<z.ZodLiteral<"stdio">>;
|
|
92
|
+
command: z.ZodOptional<z.ZodString>;
|
|
93
|
+
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
94
|
+
id: z.ZodString;
|
|
95
|
+
name: z.ZodString;
|
|
96
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
97
|
+
adapter: z.ZodDefault<z.ZodString>;
|
|
98
|
+
modelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
99
|
+
defaultModelId: z.ZodOptional<z.ZodString>;
|
|
100
|
+
environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
101
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
102
|
+
mode: z.ZodLiteral<"builtin-service">;
|
|
103
|
+
transport: z.ZodDefault<z.ZodLiteral<"stdio">>;
|
|
104
|
+
image: z.ZodString;
|
|
105
|
+
engine: z.ZodDefault<z.ZodEnum<{
|
|
106
|
+
auto: "auto";
|
|
107
|
+
podman: "podman";
|
|
108
|
+
docker: "docker";
|
|
109
|
+
}>>;
|
|
110
|
+
command: z.ZodOptional<z.ZodString>;
|
|
111
|
+
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
112
|
+
id: z.ZodString;
|
|
113
|
+
name: z.ZodString;
|
|
114
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
115
|
+
adapter: z.ZodDefault<z.ZodString>;
|
|
116
|
+
modelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
117
|
+
defaultModelId: z.ZodOptional<z.ZodString>;
|
|
118
|
+
environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
119
|
+
}, z.core.$strict>], "mode">;
|
|
120
|
+
/**
|
|
121
|
+
* 会话 Git 发布请求。
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* import { ACPPublishSchema } from '@h-ai/ai'
|
|
125
|
+
* const request = ACPPublishSchema.parse({ mode: 'push-branch', message: 'Implement task', author: { name: 'Developer', email: 'developer@example.com' } })
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
declare const ACPPublishSchema: z.ZodObject<{
|
|
129
|
+
mode: z.ZodEnum<{
|
|
130
|
+
"merge-main": "merge-main";
|
|
131
|
+
"push-branch": "push-branch";
|
|
132
|
+
}>;
|
|
133
|
+
message: z.ZodString;
|
|
134
|
+
author: z.ZodObject<{
|
|
135
|
+
name: z.ZodString;
|
|
136
|
+
email: z.ZodEmail;
|
|
137
|
+
}, z.core.$strict>;
|
|
138
|
+
}, z.core.$strict>;
|
|
139
|
+
/**
|
|
140
|
+
* ACP 执行限制。
|
|
141
|
+
* @example
|
|
142
|
+
* ```ts
|
|
143
|
+
* import { ACPConfigSchema } from '@h-ai/ai'
|
|
144
|
+
* const config = ACPConfigSchema.parse({ promptTimeout: 300000 })
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
declare const ACPConfigSchema: z.ZodObject<{
|
|
148
|
+
agents: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
149
|
+
mode: z.ZodLiteral<"custom-service">;
|
|
150
|
+
transport: z.ZodEnum<{
|
|
151
|
+
http: "http";
|
|
152
|
+
ws: "ws";
|
|
153
|
+
}>;
|
|
154
|
+
url: z.ZodURL;
|
|
155
|
+
headerEnv: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
156
|
+
supportedTransports: z.ZodArray<z.ZodEnum<{
|
|
157
|
+
http: "http";
|
|
158
|
+
ws: "ws";
|
|
159
|
+
}>>;
|
|
160
|
+
id: z.ZodString;
|
|
161
|
+
name: z.ZodString;
|
|
162
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
163
|
+
adapter: z.ZodDefault<z.ZodString>;
|
|
164
|
+
modelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
165
|
+
defaultModelId: z.ZodOptional<z.ZodString>;
|
|
166
|
+
environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
167
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
168
|
+
mode: z.ZodLiteral<"embedded">;
|
|
169
|
+
transport: z.ZodDefault<z.ZodLiteral<"stdio">>;
|
|
170
|
+
command: z.ZodOptional<z.ZodString>;
|
|
171
|
+
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
172
|
+
id: z.ZodString;
|
|
173
|
+
name: z.ZodString;
|
|
174
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
175
|
+
adapter: z.ZodDefault<z.ZodString>;
|
|
176
|
+
modelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
177
|
+
defaultModelId: z.ZodOptional<z.ZodString>;
|
|
178
|
+
environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
179
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
180
|
+
mode: z.ZodLiteral<"builtin-service">;
|
|
181
|
+
transport: z.ZodDefault<z.ZodLiteral<"stdio">>;
|
|
182
|
+
image: z.ZodString;
|
|
183
|
+
engine: z.ZodDefault<z.ZodEnum<{
|
|
184
|
+
auto: "auto";
|
|
185
|
+
podman: "podman";
|
|
186
|
+
docker: "docker";
|
|
187
|
+
}>>;
|
|
188
|
+
command: z.ZodOptional<z.ZodString>;
|
|
189
|
+
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
190
|
+
id: z.ZodString;
|
|
191
|
+
name: z.ZodString;
|
|
192
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
193
|
+
adapter: z.ZodDefault<z.ZodString>;
|
|
194
|
+
modelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
195
|
+
defaultModelId: z.ZodOptional<z.ZodString>;
|
|
196
|
+
environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
197
|
+
}, z.core.$strict>], "mode">>>;
|
|
198
|
+
workspaces: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
199
|
+
id: z.ZodString;
|
|
200
|
+
storage: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
201
|
+
type: z.ZodLiteral<"directory">;
|
|
202
|
+
path: z.ZodString;
|
|
203
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
204
|
+
type: z.ZodLiteral<"volume">;
|
|
205
|
+
name: z.ZodString;
|
|
206
|
+
engine: z.ZodDefault<z.ZodEnum<{
|
|
207
|
+
auto: "auto";
|
|
208
|
+
podman: "podman";
|
|
209
|
+
docker: "docker";
|
|
210
|
+
}>>;
|
|
211
|
+
image: z.ZodString;
|
|
212
|
+
}, z.core.$strict>], "type">;
|
|
213
|
+
repositories: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
214
|
+
id: z.ZodString;
|
|
215
|
+
url: z.ZodString;
|
|
216
|
+
mainBranch: z.ZodString;
|
|
217
|
+
remote: z.ZodDefault<z.ZodString>;
|
|
218
|
+
}, z.core.$strict>>>;
|
|
219
|
+
environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
220
|
+
gitEnvironmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
221
|
+
}, z.core.$strict>>>;
|
|
222
|
+
requestTimeout: z.ZodDefault<z.ZodNumber>;
|
|
223
|
+
promptTimeout: z.ZodDefault<z.ZodNumber>;
|
|
224
|
+
cancelTimeout: z.ZodDefault<z.ZodNumber>;
|
|
225
|
+
maxContentBytes: z.ZodDefault<z.ZodNumber>;
|
|
226
|
+
maxPendingEvents: z.ZodDefault<z.ZodNumber>;
|
|
227
|
+
}, z.core.$strict>;
|
|
228
|
+
/**
|
|
229
|
+
* ACP 初始化配置,已填充超时和只读清单默认值。
|
|
230
|
+
* @example
|
|
231
|
+
* ```ts
|
|
232
|
+
* import { ACPConfigSchema } from '@h-ai/ai'
|
|
233
|
+
* import type { ACPConfig } from '@h-ai/ai'
|
|
234
|
+
* const config: ACPConfig = ACPConfigSchema.parse({ promptTimeout: 300000 })
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
type ACPConfig = z.output<typeof ACPConfigSchema>;
|
|
238
|
+
/**
|
|
239
|
+
* ACP 初始化输入,省略字段采用 Schema 默认值。
|
|
240
|
+
* @example
|
|
241
|
+
* ```ts
|
|
242
|
+
* import type { ACPConfigInput } from '@h-ai/ai'
|
|
243
|
+
* const config: ACPConfigInput = { promptTimeout: 300000 }
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
type ACPConfigInput = z.input<typeof ACPConfigSchema>;
|
|
13
247
|
|
|
14
248
|
/**
|
|
15
249
|
* @h-ai/ai — Store 存储抽象类型
|
|
@@ -590,7 +824,7 @@ interface KnowledgeStore {
|
|
|
590
824
|
/**
|
|
591
825
|
* 向量库后端连接信息
|
|
592
826
|
*
|
|
593
|
-
* 由 Provider
|
|
827
|
+
* 由 Provider 暴露底层向量库的原始连接,供需要复用同一后端的格式适配器(如 Mem0 数据格式存储)
|
|
594
828
|
* 直连。字段按后端类型填充;包含凭证,仅供同进程内集成使用。
|
|
595
829
|
*
|
|
596
830
|
* @example
|
|
@@ -651,7 +885,7 @@ interface AIStoreProvider {
|
|
|
651
885
|
/**
|
|
652
886
|
* 暴露底层向量库后端连接(可选)
|
|
653
887
|
*
|
|
654
|
-
*
|
|
888
|
+
* 供需要直连同一向量库的格式适配器(如 Mem0 数据格式存储)复用后端。未初始化或不支持时返回
|
|
655
889
|
* `undefined`。返回值含凭证,仅供同进程内集成使用,禁止写入日志。
|
|
656
890
|
*/
|
|
657
891
|
getVectorBackend?: () => AIVectorBackend | undefined;
|
|
@@ -837,14 +1071,14 @@ type ToolDefinition = OpenAI.Chat.Completions.ChatCompletionTool;
|
|
|
837
1071
|
* ```ts
|
|
838
1072
|
* import type { TempModelConfig } from '@h-ai/ai'
|
|
839
1073
|
*
|
|
840
|
-
* const value: TempModelConfig = { model: 'gpt-4o-mini',
|
|
1074
|
+
* const value: TempModelConfig = { model: 'gpt-4o-mini', protocol: 'chat', timeout: 15_000 }
|
|
841
1075
|
* ```
|
|
842
1076
|
*/
|
|
843
1077
|
interface TempModelConfig {
|
|
844
1078
|
/** 模型名称(传给 API 的实际模型名) */
|
|
845
1079
|
model: string;
|
|
846
|
-
/** API 协议(未指定时回退全局 `
|
|
847
|
-
|
|
1080
|
+
/** API 协议(未指定时回退全局 `protocol`,再回退 `chat`;决定走 Chat Completions / Responses / Anthropic) */
|
|
1081
|
+
protocol?: ApiType;
|
|
848
1082
|
/** API Key(未指定时回退全局配置 / 环境变量) */
|
|
849
1083
|
apiKey?: string;
|
|
850
1084
|
/** API 基础 URL(未指定时回退全局配置 / 环境变量 / 默认 OpenAI) */
|
|
@@ -1812,12 +2046,12 @@ interface RetrievalOperations {
|
|
|
1812
2046
|
* ```
|
|
1813
2047
|
*/
|
|
1814
2048
|
declare const EntityTypeSchema: z.ZodEnum<{
|
|
1815
|
-
event: "event";
|
|
1816
2049
|
person: "person";
|
|
1817
2050
|
project: "project";
|
|
1818
2051
|
concept: "concept";
|
|
1819
2052
|
organization: "organization";
|
|
1820
2053
|
location: "location";
|
|
2054
|
+
event: "event";
|
|
1821
2055
|
other: "other";
|
|
1822
2056
|
}>;
|
|
1823
2057
|
/**
|
|
@@ -2521,9 +2755,9 @@ interface KnowledgeOperations {
|
|
|
2521
2755
|
* ```
|
|
2522
2756
|
*/
|
|
2523
2757
|
declare const MemoryTypeSchema: z.ZodEnum<{
|
|
2758
|
+
event: "event";
|
|
2524
2759
|
fact: "fact";
|
|
2525
2760
|
preference: "preference";
|
|
2526
|
-
event: "event";
|
|
2527
2761
|
entity: "entity";
|
|
2528
2762
|
instruction: "instruction";
|
|
2529
2763
|
}>;
|
|
@@ -3075,19 +3309,13 @@ interface MemoryOperations extends MemoryCoreOperations {
|
|
|
3075
3309
|
*
|
|
3076
3310
|
* @param binding - 作用域绑定(objectId + 可选 scope)
|
|
3077
3311
|
* @returns 所有操作自动携带该作用域的记忆实例
|
|
3312
|
+
* @throws objectId 缺失、为空或只有空白时抛 TypeError;工厂不创建未绑定的实例。
|
|
3078
3313
|
*/
|
|
3079
3314
|
scoped: (binding: ScopedMemoryBinding) => ScopedMemoryOperations;
|
|
3080
3315
|
/** 管理接口(危险的全局操作,需显式确认) */
|
|
3081
3316
|
admin: MemoryAdminOperations;
|
|
3082
3317
|
}
|
|
3083
3318
|
|
|
3084
|
-
/**
|
|
3085
|
-
* @h-ai/ai — 错误码 + 配置 Schema
|
|
3086
|
-
*
|
|
3087
|
-
* 定义 AI 模块的错误码常量、Zod Schema 和配置类型。
|
|
3088
|
-
* @module ai-config
|
|
3089
|
-
*/
|
|
3090
|
-
|
|
3091
3319
|
/**
|
|
3092
3320
|
* 可选密钥 Schema。
|
|
3093
3321
|
*
|
|
@@ -3139,16 +3367,16 @@ declare const OptionalSecretSchema: z.ZodOptional<z.ZodPipe<z.ZodNullable<z.ZodS
|
|
|
3139
3367
|
* ```
|
|
3140
3368
|
*/
|
|
3141
3369
|
declare const ModelScenarioSchema: z.ZodEnum<{
|
|
3370
|
+
default: "default";
|
|
3142
3371
|
chat: "chat";
|
|
3143
|
-
summary: "summary";
|
|
3144
|
-
plan: "plan";
|
|
3145
3372
|
reasoning: "reasoning";
|
|
3146
|
-
|
|
3147
|
-
default: "default";
|
|
3373
|
+
plan: "plan";
|
|
3148
3374
|
execute: "execute";
|
|
3149
3375
|
extraction: "extraction";
|
|
3376
|
+
summary: "summary";
|
|
3150
3377
|
embedding: "embedding";
|
|
3151
3378
|
rerank: "rerank";
|
|
3379
|
+
ocr: "ocr";
|
|
3152
3380
|
fast: "fast";
|
|
3153
3381
|
}>;
|
|
3154
3382
|
/**
|
|
@@ -3202,6 +3430,35 @@ declare const ApiTypeSchema: z.ZodEnum<{
|
|
|
3202
3430
|
* ```
|
|
3203
3431
|
*/
|
|
3204
3432
|
type ApiType = z.infer<typeof ApiTypeSchema>;
|
|
3433
|
+
/**
|
|
3434
|
+
* 模型能力元数据;缺省字段表示未知,不从调用预算推断容量。
|
|
3435
|
+
* @example
|
|
3436
|
+
* ```ts
|
|
3437
|
+
* import { ModelCapabilitiesSchema } from '@h-ai/ai'
|
|
3438
|
+
* const capabilities = ModelCapabilitiesSchema.parse({ contextWindow: 128000, toolCalling: true })
|
|
3439
|
+
* ```
|
|
3440
|
+
*/
|
|
3441
|
+
declare const ModelCapabilitiesSchema: z.ZodObject<{
|
|
3442
|
+
contextWindow: z.ZodOptional<z.ZodNumber>;
|
|
3443
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
3444
|
+
inputModalities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
3445
|
+
image: "image";
|
|
3446
|
+
text: "text";
|
|
3447
|
+
audio: "audio";
|
|
3448
|
+
video: "video";
|
|
3449
|
+
}>>>;
|
|
3450
|
+
outputModalities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
3451
|
+
image: "image";
|
|
3452
|
+
text: "text";
|
|
3453
|
+
audio: "audio";
|
|
3454
|
+
video: "video";
|
|
3455
|
+
}>>>;
|
|
3456
|
+
toolCalling: z.ZodOptional<z.ZodBoolean>;
|
|
3457
|
+
reasoning: z.ZodOptional<z.ZodObject<{
|
|
3458
|
+
supported: z.ZodBoolean;
|
|
3459
|
+
efforts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
3460
|
+
}, z.core.$strict>>;
|
|
3461
|
+
}, z.core.$strict>;
|
|
3205
3462
|
/**
|
|
3206
3463
|
* 模型条目 Schema
|
|
3207
3464
|
*
|
|
@@ -3222,8 +3479,29 @@ type ApiType = z.infer<typeof ApiTypeSchema>;
|
|
|
3222
3479
|
*/
|
|
3223
3480
|
declare const ModelEntrySchema: z.ZodObject<{
|
|
3224
3481
|
id: z.ZodString;
|
|
3482
|
+
capabilities: z.ZodOptional<z.ZodObject<{
|
|
3483
|
+
contextWindow: z.ZodOptional<z.ZodNumber>;
|
|
3484
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
3485
|
+
inputModalities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
3486
|
+
image: "image";
|
|
3487
|
+
text: "text";
|
|
3488
|
+
audio: "audio";
|
|
3489
|
+
video: "video";
|
|
3490
|
+
}>>>;
|
|
3491
|
+
outputModalities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
3492
|
+
image: "image";
|
|
3493
|
+
text: "text";
|
|
3494
|
+
audio: "audio";
|
|
3495
|
+
video: "video";
|
|
3496
|
+
}>>>;
|
|
3497
|
+
toolCalling: z.ZodOptional<z.ZodBoolean>;
|
|
3498
|
+
reasoning: z.ZodOptional<z.ZodObject<{
|
|
3499
|
+
supported: z.ZodBoolean;
|
|
3500
|
+
efforts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
3501
|
+
}, z.core.$strict>>;
|
|
3502
|
+
}, z.core.$strict>>;
|
|
3225
3503
|
model: z.ZodString;
|
|
3226
|
-
|
|
3504
|
+
protocol: z.ZodOptional<z.ZodEnum<{
|
|
3227
3505
|
chat: "chat";
|
|
3228
3506
|
responses: "responses";
|
|
3229
3507
|
anthropic: "anthropic";
|
|
@@ -3233,7 +3511,7 @@ declare const ModelEntrySchema: z.ZodObject<{
|
|
|
3233
3511
|
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
3234
3512
|
temperature: z.ZodOptional<z.ZodNumber>;
|
|
3235
3513
|
timeout: z.ZodOptional<z.ZodNumber>;
|
|
3236
|
-
}, z.core.$
|
|
3514
|
+
}, z.core.$strict>;
|
|
3237
3515
|
/**
|
|
3238
3516
|
* 模型条目类型
|
|
3239
3517
|
*
|
|
@@ -3273,7 +3551,7 @@ declare const LLMConfigSchema: z.ZodObject<{
|
|
|
3273
3551
|
apiKey: z.ZodOptional<z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<string | undefined, string | null>>>;
|
|
3274
3552
|
baseUrl: z.ZodOptional<z.ZodURL>;
|
|
3275
3553
|
model: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
3276
|
-
|
|
3554
|
+
protocol: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
3277
3555
|
chat: "chat";
|
|
3278
3556
|
responses: "responses";
|
|
3279
3557
|
anthropic: "anthropic";
|
|
@@ -3284,8 +3562,29 @@ declare const LLMConfigSchema: z.ZodObject<{
|
|
|
3284
3562
|
tempModelCacheTtl: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
3285
3563
|
models: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
3286
3564
|
id: z.ZodString;
|
|
3565
|
+
capabilities: z.ZodOptional<z.ZodObject<{
|
|
3566
|
+
contextWindow: z.ZodOptional<z.ZodNumber>;
|
|
3567
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
3568
|
+
inputModalities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
3569
|
+
image: "image";
|
|
3570
|
+
text: "text";
|
|
3571
|
+
audio: "audio";
|
|
3572
|
+
video: "video";
|
|
3573
|
+
}>>>;
|
|
3574
|
+
outputModalities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
3575
|
+
image: "image";
|
|
3576
|
+
text: "text";
|
|
3577
|
+
audio: "audio";
|
|
3578
|
+
video: "video";
|
|
3579
|
+
}>>>;
|
|
3580
|
+
toolCalling: z.ZodOptional<z.ZodBoolean>;
|
|
3581
|
+
reasoning: z.ZodOptional<z.ZodObject<{
|
|
3582
|
+
supported: z.ZodBoolean;
|
|
3583
|
+
efforts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
3584
|
+
}, z.core.$strict>>;
|
|
3585
|
+
}, z.core.$strict>>;
|
|
3287
3586
|
model: z.ZodString;
|
|
3288
|
-
|
|
3587
|
+
protocol: z.ZodOptional<z.ZodEnum<{
|
|
3289
3588
|
chat: "chat";
|
|
3290
3589
|
responses: "responses";
|
|
3291
3590
|
anthropic: "anthropic";
|
|
@@ -3295,21 +3594,21 @@ declare const LLMConfigSchema: z.ZodObject<{
|
|
|
3295
3594
|
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
3296
3595
|
temperature: z.ZodOptional<z.ZodNumber>;
|
|
3297
3596
|
timeout: z.ZodOptional<z.ZodNumber>;
|
|
3298
|
-
}, z.core.$
|
|
3597
|
+
}, z.core.$strict>>>;
|
|
3299
3598
|
scenarios: z.ZodOptional<z.ZodObject<{
|
|
3599
|
+
default: z.ZodOptional<z.ZodString>;
|
|
3300
3600
|
chat: z.ZodOptional<z.ZodString>;
|
|
3301
|
-
summary: z.ZodOptional<z.ZodString>;
|
|
3302
|
-
plan: z.ZodOptional<z.ZodString>;
|
|
3303
3601
|
reasoning: z.ZodOptional<z.ZodString>;
|
|
3304
|
-
|
|
3305
|
-
default: z.ZodOptional<z.ZodString>;
|
|
3602
|
+
plan: z.ZodOptional<z.ZodString>;
|
|
3306
3603
|
execute: z.ZodOptional<z.ZodString>;
|
|
3307
3604
|
extraction: z.ZodOptional<z.ZodString>;
|
|
3605
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
3308
3606
|
embedding: z.ZodOptional<z.ZodString>;
|
|
3309
3607
|
rerank: z.ZodOptional<z.ZodString>;
|
|
3608
|
+
ocr: z.ZodOptional<z.ZodString>;
|
|
3310
3609
|
fast: z.ZodOptional<z.ZodString>;
|
|
3311
3610
|
}, z.core.$strip>>;
|
|
3312
|
-
}, z.core.$
|
|
3611
|
+
}, z.core.$strict>;
|
|
3313
3612
|
/**
|
|
3314
3613
|
* LLM 配置类型
|
|
3315
3614
|
*
|
|
@@ -3333,15 +3632,17 @@ type LLMConfig = z.infer<typeof LLMConfigSchema>;
|
|
|
3333
3632
|
*
|
|
3334
3633
|
* // 展示模型选择,不输出配置中的 apiKey。
|
|
3335
3634
|
* function label(config: ResolvedModelConfig): string {
|
|
3336
|
-
* return `${config.
|
|
3635
|
+
* return `${config.protocol}/${config.model}, timeout=${config.timeout}ms`
|
|
3337
3636
|
* }
|
|
3338
3637
|
* ```
|
|
3339
3638
|
*/
|
|
3340
3639
|
interface ResolvedModelConfig {
|
|
3640
|
+
/** 已确认的模型能力 */
|
|
3641
|
+
capabilities?: z.infer<typeof ModelCapabilitiesSchema>;
|
|
3341
3642
|
/** 模型名称(传给 API 的实际模型名) */
|
|
3342
3643
|
model: string;
|
|
3343
3644
|
/** API 协议(模型条目 > 全局配置 > `chat`) */
|
|
3344
|
-
|
|
3645
|
+
protocol: ApiType;
|
|
3345
3646
|
/** API Key(模型条目 > 全局配置 > 环境变量) */
|
|
3346
3647
|
apiKey: string | undefined;
|
|
3347
3648
|
/** API 基础 URL(模型条目 > 全局配置 > 环境变量 > 默认 OpenAI) */
|
|
@@ -3394,8 +3695,8 @@ declare function resolveModelEntry(llmConfig: LLMConfig, scenario: ModelScenario
|
|
|
3394
3695
|
/**
|
|
3395
3696
|
* 解析某次 chat 请求应使用的 API 协议(不校验 API Key)
|
|
3396
3697
|
*
|
|
3397
|
-
* 供 LLM Provider 路由层选择底层实现使用:优先取显式模型条目的 `
|
|
3398
|
-
* 其次全局 `
|
|
3698
|
+
* 供 LLM Provider 路由层选择底层实现使用:优先取显式模型条目的 `protocol`,
|
|
3699
|
+
* 其次全局 `protocol`,最后回退 `chat`。临时模型的 `protocol` 由调用方单独传入优先。
|
|
3399
3700
|
*
|
|
3400
3701
|
* @param llmConfig - LLM 配置
|
|
3401
3702
|
* @param explicitModel - 显式指定的模型名/ID(可选)
|
|
@@ -3406,7 +3707,7 @@ declare function resolveModelEntry(llmConfig: LLMConfig, scenario: ModelScenario
|
|
|
3406
3707
|
* ```ts
|
|
3407
3708
|
* import { LLMConfigSchema, resolveModelApi } from '@h-ai/ai'
|
|
3408
3709
|
*
|
|
3409
|
-
* const config = LLMConfigSchema.parse({ models: [{ id: 'claude', model: 'claude-sonnet-4',
|
|
3710
|
+
* const config = LLMConfigSchema.parse({ models: [{ id: 'claude', model: 'claude-sonnet-4', protocol: 'anthropic' }] })
|
|
3410
3711
|
* const protocol = resolveModelApi(config, 'claude')
|
|
3411
3712
|
* ```
|
|
3412
3713
|
*/
|
|
@@ -3481,6 +3782,37 @@ declare const MCPServerConfigSchema: z.ZodObject<{
|
|
|
3481
3782
|
* ```
|
|
3482
3783
|
*/
|
|
3483
3784
|
type MCPServerConfig = z.infer<typeof MCPServerConfigSchema>;
|
|
3785
|
+
/**
|
|
3786
|
+
* 外部 MCP 服务清单项;凭据仅保存环境变量引用,可供 ACP 会话选择。
|
|
3787
|
+
* @example
|
|
3788
|
+
* ```ts
|
|
3789
|
+
* import { MCPExternalServerSchema } from '@h-ai/ai'
|
|
3790
|
+
* const server = MCPExternalServerSchema.parse({ id: 'docs', name: 'Docs', transport: 'http', url: 'https://mcp.example.com' })
|
|
3791
|
+
* ```
|
|
3792
|
+
*/
|
|
3793
|
+
declare const MCPExternalServerSchema: z.ZodObject<{
|
|
3794
|
+
id: z.ZodString;
|
|
3795
|
+
name: z.ZodString;
|
|
3796
|
+
transport: z.ZodEnum<{
|
|
3797
|
+
http: "http";
|
|
3798
|
+
stdio: "stdio";
|
|
3799
|
+
sse: "sse";
|
|
3800
|
+
}>;
|
|
3801
|
+
command: z.ZodOptional<z.ZodString>;
|
|
3802
|
+
args: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
3803
|
+
url: z.ZodOptional<z.ZodURL>;
|
|
3804
|
+
environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
3805
|
+
headerEnv: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
3806
|
+
}, z.core.$strict>;
|
|
3807
|
+
/**
|
|
3808
|
+
* 外部 MCP 服务配置。
|
|
3809
|
+
* @example
|
|
3810
|
+
* ```ts
|
|
3811
|
+
* import type { MCPExternalServer } from '@h-ai/ai'
|
|
3812
|
+
* function serverId(server: MCPExternalServer) { return server.id }
|
|
3813
|
+
* ```
|
|
3814
|
+
*/
|
|
3815
|
+
type MCPExternalServer = z.infer<typeof MCPExternalServerSchema>;
|
|
3484
3816
|
/**
|
|
3485
3817
|
* MCP 配置 Schema
|
|
3486
3818
|
*
|
|
@@ -3500,6 +3832,20 @@ type MCPServerConfig = z.infer<typeof MCPServerConfigSchema>;
|
|
|
3500
3832
|
* ```
|
|
3501
3833
|
*/
|
|
3502
3834
|
declare const MCPConfigSchema: z.ZodObject<{
|
|
3835
|
+
servers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
3836
|
+
id: z.ZodString;
|
|
3837
|
+
name: z.ZodString;
|
|
3838
|
+
transport: z.ZodEnum<{
|
|
3839
|
+
http: "http";
|
|
3840
|
+
stdio: "stdio";
|
|
3841
|
+
sse: "sse";
|
|
3842
|
+
}>;
|
|
3843
|
+
command: z.ZodOptional<z.ZodString>;
|
|
3844
|
+
args: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
3845
|
+
url: z.ZodOptional<z.ZodURL>;
|
|
3846
|
+
environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
3847
|
+
headerEnv: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
3848
|
+
}, z.core.$strict>>>;
|
|
3503
3849
|
server: z.ZodOptional<z.ZodObject<{
|
|
3504
3850
|
name: z.ZodString;
|
|
3505
3851
|
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
@@ -4468,11 +4814,92 @@ declare function resolveImageModel(imageConfig: ImageConfig, explicit?: string):
|
|
|
4468
4814
|
* ```
|
|
4469
4815
|
*/
|
|
4470
4816
|
declare const AIConfigSchema: z.ZodObject<{
|
|
4817
|
+
acp: z.ZodOptional<z.ZodObject<{
|
|
4818
|
+
agents: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4819
|
+
mode: z.ZodLiteral<"custom-service">;
|
|
4820
|
+
transport: z.ZodEnum<{
|
|
4821
|
+
http: "http";
|
|
4822
|
+
ws: "ws";
|
|
4823
|
+
}>;
|
|
4824
|
+
url: z.ZodURL;
|
|
4825
|
+
headerEnv: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
4826
|
+
supportedTransports: z.ZodArray<z.ZodEnum<{
|
|
4827
|
+
http: "http";
|
|
4828
|
+
ws: "ws";
|
|
4829
|
+
}>>;
|
|
4830
|
+
id: z.ZodString;
|
|
4831
|
+
name: z.ZodString;
|
|
4832
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
4833
|
+
adapter: z.ZodDefault<z.ZodString>;
|
|
4834
|
+
modelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
4835
|
+
defaultModelId: z.ZodOptional<z.ZodString>;
|
|
4836
|
+
environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
4837
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4838
|
+
mode: z.ZodLiteral<"embedded">;
|
|
4839
|
+
transport: z.ZodDefault<z.ZodLiteral<"stdio">>;
|
|
4840
|
+
command: z.ZodOptional<z.ZodString>;
|
|
4841
|
+
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
4842
|
+
id: z.ZodString;
|
|
4843
|
+
name: z.ZodString;
|
|
4844
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
4845
|
+
adapter: z.ZodDefault<z.ZodString>;
|
|
4846
|
+
modelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
4847
|
+
defaultModelId: z.ZodOptional<z.ZodString>;
|
|
4848
|
+
environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
4849
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4850
|
+
mode: z.ZodLiteral<"builtin-service">;
|
|
4851
|
+
transport: z.ZodDefault<z.ZodLiteral<"stdio">>;
|
|
4852
|
+
image: z.ZodString;
|
|
4853
|
+
engine: z.ZodDefault<z.ZodEnum<{
|
|
4854
|
+
auto: "auto";
|
|
4855
|
+
podman: "podman";
|
|
4856
|
+
docker: "docker";
|
|
4857
|
+
}>>;
|
|
4858
|
+
command: z.ZodOptional<z.ZodString>;
|
|
4859
|
+
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
4860
|
+
id: z.ZodString;
|
|
4861
|
+
name: z.ZodString;
|
|
4862
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
4863
|
+
adapter: z.ZodDefault<z.ZodString>;
|
|
4864
|
+
modelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
4865
|
+
defaultModelId: z.ZodOptional<z.ZodString>;
|
|
4866
|
+
environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
4867
|
+
}, z.core.$strict>], "mode">>>;
|
|
4868
|
+
workspaces: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
4869
|
+
id: z.ZodString;
|
|
4870
|
+
storage: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4871
|
+
type: z.ZodLiteral<"directory">;
|
|
4872
|
+
path: z.ZodString;
|
|
4873
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4874
|
+
type: z.ZodLiteral<"volume">;
|
|
4875
|
+
name: z.ZodString;
|
|
4876
|
+
engine: z.ZodDefault<z.ZodEnum<{
|
|
4877
|
+
auto: "auto";
|
|
4878
|
+
podman: "podman";
|
|
4879
|
+
docker: "docker";
|
|
4880
|
+
}>>;
|
|
4881
|
+
image: z.ZodString;
|
|
4882
|
+
}, z.core.$strict>], "type">;
|
|
4883
|
+
repositories: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
4884
|
+
id: z.ZodString;
|
|
4885
|
+
url: z.ZodString;
|
|
4886
|
+
mainBranch: z.ZodString;
|
|
4887
|
+
remote: z.ZodDefault<z.ZodString>;
|
|
4888
|
+
}, z.core.$strict>>>;
|
|
4889
|
+
environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
4890
|
+
gitEnvironmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
4891
|
+
}, z.core.$strict>>>;
|
|
4892
|
+
requestTimeout: z.ZodDefault<z.ZodNumber>;
|
|
4893
|
+
promptTimeout: z.ZodDefault<z.ZodNumber>;
|
|
4894
|
+
cancelTimeout: z.ZodDefault<z.ZodNumber>;
|
|
4895
|
+
maxContentBytes: z.ZodDefault<z.ZodNumber>;
|
|
4896
|
+
maxPendingEvents: z.ZodDefault<z.ZodNumber>;
|
|
4897
|
+
}, z.core.$strict>>;
|
|
4471
4898
|
llm: z.ZodDefault<z.ZodObject<{
|
|
4472
4899
|
apiKey: z.ZodOptional<z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<string | undefined, string | null>>>;
|
|
4473
4900
|
baseUrl: z.ZodOptional<z.ZodURL>;
|
|
4474
4901
|
model: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
4475
|
-
|
|
4902
|
+
protocol: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
4476
4903
|
chat: "chat";
|
|
4477
4904
|
responses: "responses";
|
|
4478
4905
|
anthropic: "anthropic";
|
|
@@ -4483,8 +4910,29 @@ declare const AIConfigSchema: z.ZodObject<{
|
|
|
4483
4910
|
tempModelCacheTtl: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
4484
4911
|
models: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
4485
4912
|
id: z.ZodString;
|
|
4913
|
+
capabilities: z.ZodOptional<z.ZodObject<{
|
|
4914
|
+
contextWindow: z.ZodOptional<z.ZodNumber>;
|
|
4915
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
4916
|
+
inputModalities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
4917
|
+
image: "image";
|
|
4918
|
+
text: "text";
|
|
4919
|
+
audio: "audio";
|
|
4920
|
+
video: "video";
|
|
4921
|
+
}>>>;
|
|
4922
|
+
outputModalities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
4923
|
+
image: "image";
|
|
4924
|
+
text: "text";
|
|
4925
|
+
audio: "audio";
|
|
4926
|
+
video: "video";
|
|
4927
|
+
}>>>;
|
|
4928
|
+
toolCalling: z.ZodOptional<z.ZodBoolean>;
|
|
4929
|
+
reasoning: z.ZodOptional<z.ZodObject<{
|
|
4930
|
+
supported: z.ZodBoolean;
|
|
4931
|
+
efforts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
4932
|
+
}, z.core.$strict>>;
|
|
4933
|
+
}, z.core.$strict>>;
|
|
4486
4934
|
model: z.ZodString;
|
|
4487
|
-
|
|
4935
|
+
protocol: z.ZodOptional<z.ZodEnum<{
|
|
4488
4936
|
chat: "chat";
|
|
4489
4937
|
responses: "responses";
|
|
4490
4938
|
anthropic: "anthropic";
|
|
@@ -4494,22 +4942,36 @@ declare const AIConfigSchema: z.ZodObject<{
|
|
|
4494
4942
|
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
4495
4943
|
temperature: z.ZodOptional<z.ZodNumber>;
|
|
4496
4944
|
timeout: z.ZodOptional<z.ZodNumber>;
|
|
4497
|
-
}, z.core.$
|
|
4945
|
+
}, z.core.$strict>>>;
|
|
4498
4946
|
scenarios: z.ZodOptional<z.ZodObject<{
|
|
4947
|
+
default: z.ZodOptional<z.ZodString>;
|
|
4499
4948
|
chat: z.ZodOptional<z.ZodString>;
|
|
4500
|
-
summary: z.ZodOptional<z.ZodString>;
|
|
4501
|
-
plan: z.ZodOptional<z.ZodString>;
|
|
4502
4949
|
reasoning: z.ZodOptional<z.ZodString>;
|
|
4503
|
-
|
|
4504
|
-
default: z.ZodOptional<z.ZodString>;
|
|
4950
|
+
plan: z.ZodOptional<z.ZodString>;
|
|
4505
4951
|
execute: z.ZodOptional<z.ZodString>;
|
|
4506
4952
|
extraction: z.ZodOptional<z.ZodString>;
|
|
4953
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
4507
4954
|
embedding: z.ZodOptional<z.ZodString>;
|
|
4508
4955
|
rerank: z.ZodOptional<z.ZodString>;
|
|
4956
|
+
ocr: z.ZodOptional<z.ZodString>;
|
|
4509
4957
|
fast: z.ZodOptional<z.ZodString>;
|
|
4510
4958
|
}, z.core.$strip>>;
|
|
4511
|
-
}, z.core.$
|
|
4959
|
+
}, z.core.$strict>>;
|
|
4512
4960
|
mcp: z.ZodOptional<z.ZodObject<{
|
|
4961
|
+
servers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
4962
|
+
id: z.ZodString;
|
|
4963
|
+
name: z.ZodString;
|
|
4964
|
+
transport: z.ZodEnum<{
|
|
4965
|
+
http: "http";
|
|
4966
|
+
stdio: "stdio";
|
|
4967
|
+
sse: "sse";
|
|
4968
|
+
}>;
|
|
4969
|
+
command: z.ZodOptional<z.ZodString>;
|
|
4970
|
+
args: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
4971
|
+
url: z.ZodOptional<z.ZodURL>;
|
|
4972
|
+
environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
4973
|
+
headerEnv: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
4974
|
+
}, z.core.$strict>>>;
|
|
4513
4975
|
server: z.ZodOptional<z.ZodObject<{
|
|
4514
4976
|
name: z.ZodString;
|
|
4515
4977
|
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
@@ -4713,6 +5175,48 @@ type AIConfigInput = z.input<typeof AIConfigSchema>;
|
|
|
4713
5175
|
* @module ai-a2a-types
|
|
4714
5176
|
*/
|
|
4715
5177
|
|
|
5178
|
+
/**
|
|
5179
|
+
* 可直接用于 HTTP 发现响应的 A2A 1.0 ProtoJSON 文档;不暴露 SDK 内部 oneof 结构。
|
|
5180
|
+
* @example
|
|
5181
|
+
* ```ts
|
|
5182
|
+
* import { ai } from '@h-ai/ai'
|
|
5183
|
+
* const card = ai.a2a.getAgentCard()
|
|
5184
|
+
* if (card.success) Response.json(card.data)
|
|
5185
|
+
* ```
|
|
5186
|
+
*/
|
|
5187
|
+
interface A2AAgentCardDocument {
|
|
5188
|
+
name: string;
|
|
5189
|
+
description: string;
|
|
5190
|
+
version: string;
|
|
5191
|
+
supportedInterfaces: Array<{
|
|
5192
|
+
url: string;
|
|
5193
|
+
protocolBinding: string;
|
|
5194
|
+
protocolVersion: string;
|
|
5195
|
+
}>;
|
|
5196
|
+
defaultInputModes: string[];
|
|
5197
|
+
defaultOutputModes: string[];
|
|
5198
|
+
capabilities: {
|
|
5199
|
+
streaming: boolean;
|
|
5200
|
+
pushNotifications: boolean;
|
|
5201
|
+
};
|
|
5202
|
+
skills: Array<{
|
|
5203
|
+
id: string;
|
|
5204
|
+
name: string;
|
|
5205
|
+
description: string;
|
|
5206
|
+
tags: string[];
|
|
5207
|
+
}>;
|
|
5208
|
+
securitySchemes?: Record<string, {
|
|
5209
|
+
apiKeySecurityScheme: {
|
|
5210
|
+
location: string;
|
|
5211
|
+
name: string;
|
|
5212
|
+
};
|
|
5213
|
+
}>;
|
|
5214
|
+
securityRequirements?: Array<{
|
|
5215
|
+
schemes: Record<string, {
|
|
5216
|
+
list: string[];
|
|
5217
|
+
}>;
|
|
5218
|
+
}>;
|
|
5219
|
+
}
|
|
4716
5220
|
/**
|
|
4717
5221
|
* A2A 调用方身份信息
|
|
4718
5222
|
*
|
|
@@ -4868,9 +5372,9 @@ interface A2AOperations {
|
|
|
4868
5372
|
*
|
|
4869
5373
|
* 配置了 a2a 后即可使用,无需注册 executor。
|
|
4870
5374
|
*
|
|
4871
|
-
* @returns
|
|
5375
|
+
* @returns 可直接用于 HTTP 发现响应的 A2A 1.0 ProtoJSON Agent Card(含能力与安全方案)
|
|
4872
5376
|
*/
|
|
4873
|
-
getAgentCard: () => HaiResult<
|
|
5377
|
+
getAgentCard: () => HaiResult<A2AAgentCardDocument>;
|
|
4874
5378
|
/**
|
|
4875
5379
|
* 处理入站 JSON-RPC 请求
|
|
4876
5380
|
*
|
|
@@ -4957,7 +5461,7 @@ interface A2AAgentCardConfig {
|
|
|
4957
5461
|
description?: string;
|
|
4958
5462
|
tags?: string[];
|
|
4959
5463
|
}>;
|
|
4960
|
-
/** 安全认证配置(体现在 Agent Card 的 securitySchemes /
|
|
5464
|
+
/** 安全认证配置(体现在 Agent Card 的 securitySchemes / securityRequirements 字段) */
|
|
4961
5465
|
security?: A2ASecurityConfig;
|
|
4962
5466
|
}
|
|
4963
5467
|
/**
|
|
@@ -5001,7 +5505,7 @@ interface A2AHandleResult {
|
|
|
5001
5505
|
interface A2ACallOptions {
|
|
5002
5506
|
/** 超时时间(毫秒),默认 60 秒。 */
|
|
5003
5507
|
timeout?: number;
|
|
5004
|
-
/**
|
|
5508
|
+
/** 额外请求头,按大小写不敏感的同名字段覆盖;远端 HTTP 重定向被拒绝。 */
|
|
5005
5509
|
headers?: Record<string, string>;
|
|
5006
5510
|
}
|
|
5007
5511
|
/**
|
|
@@ -5019,7 +5523,7 @@ interface A2ACallResult {
|
|
|
5019
5523
|
/** 远端任务 ID */
|
|
5020
5524
|
taskId?: string;
|
|
5021
5525
|
/** 任务最终状态 */
|
|
5022
|
-
taskState?:
|
|
5526
|
+
taskState?: TaskState;
|
|
5023
5527
|
/** 响应消息文本 */
|
|
5024
5528
|
responseText?: string;
|
|
5025
5529
|
/** 响应消息 Part 数组 */
|
|
@@ -6300,7 +6804,7 @@ interface FileParseRequest {
|
|
|
6300
6804
|
* ```
|
|
6301
6805
|
*/
|
|
6302
6806
|
interface FileParseResult {
|
|
6303
|
-
/** 提取的文本内容(当 `outputFormat` 为 `'markdown'` 时为 Markdown
|
|
6807
|
+
/** 提取的文本内容(当 `outputFormat` 为 `'markdown'` 时为 Markdown 格式);不是可直接执行的可信 HTML。 */
|
|
6304
6808
|
text: string;
|
|
6305
6809
|
/** 解析方法 */
|
|
6306
6810
|
method: FileParseMethod;
|
|
@@ -6359,61 +6863,238 @@ interface FileOperations {
|
|
|
6359
6863
|
}
|
|
6360
6864
|
|
|
6361
6865
|
/**
|
|
6362
|
-
* @h-ai/ai —
|
|
6866
|
+
* @h-ai/ai — Persona 子功能类型
|
|
6363
6867
|
*
|
|
6364
|
-
*
|
|
6365
|
-
*
|
|
6366
|
-
*
|
|
6868
|
+
* 定义「AI 角色人格」的持久化与组合接口。Persona 解决的是「AI 是谁」的问题:
|
|
6869
|
+
* 多智能体场景(如多位专家同台访谈)中,每个 AI 有稳定的系统提示词、性格特征与
|
|
6870
|
+
* 长期人格。它与 Memory 正交——Memory 用 `objectId` / `scope` 回答「谁的记忆」,
|
|
6871
|
+
* Persona 回答「这个 AI 的身份与人设」,二者通过 `scope: { personaId }` 关联。
|
|
6872
|
+
* @module ai-persona-types
|
|
6367
6873
|
*/
|
|
6368
6874
|
|
|
6369
6875
|
/**
|
|
6370
|
-
*
|
|
6876
|
+
* Persona 档案输入(创建 / 覆盖保存时使用)
|
|
6371
6877
|
*
|
|
6372
6878
|
* @example
|
|
6373
6879
|
* ```ts
|
|
6374
|
-
* import type {
|
|
6880
|
+
* import type { PersonaProfileInput } from '@h-ai/ai'
|
|
6375
6881
|
*
|
|
6376
|
-
* const value:
|
|
6882
|
+
* const value: PersonaProfileInput = { id: 'support', objectId: 'tenant-1', name: '客服助手', systemPrompt: '根据已验证的订单信息回答。', traits: ['简洁', '先核对证据'] }
|
|
6377
6883
|
* ```
|
|
6378
6884
|
*/
|
|
6379
|
-
interface
|
|
6380
|
-
/**
|
|
6381
|
-
|
|
6382
|
-
/**
|
|
6383
|
-
|
|
6885
|
+
interface PersonaProfileInput {
|
|
6886
|
+
/** 角色唯一标识(业务侧稳定 ID,如 `xiaop`) */
|
|
6887
|
+
id: string;
|
|
6888
|
+
/**
|
|
6889
|
+
* 所属主体 ID(多租户隔离)
|
|
6890
|
+
*
|
|
6891
|
+
* 不同主体可创建同名角色而互不覆盖;不传时归为平台内置角色 `system`。
|
|
6892
|
+
*/
|
|
6893
|
+
objectId?: string;
|
|
6894
|
+
/** 角色显示名(如「小P」) */
|
|
6895
|
+
name?: string;
|
|
6896
|
+
/** 角色系统提示词(定义身份、职责、语气) */
|
|
6897
|
+
systemPrompt: string;
|
|
6898
|
+
/** 性格 / 风格特征(组合进系统提示词,如「谨慎」「喜欢引用案例」) */
|
|
6899
|
+
traits?: string[];
|
|
6900
|
+
/** 附加元数据 */
|
|
6901
|
+
metadata?: Record<string, unknown>;
|
|
6384
6902
|
}
|
|
6385
6903
|
/**
|
|
6386
|
-
*
|
|
6904
|
+
* 完整的 Persona 档案
|
|
6387
6905
|
*
|
|
6388
6906
|
* @example
|
|
6389
6907
|
* ```ts
|
|
6390
|
-
* import type {
|
|
6391
|
-
* import { readFile } from 'node:fs/promises'
|
|
6908
|
+
* import type { PersonaProfile } from '@h-ai/ai'
|
|
6392
6909
|
*
|
|
6393
|
-
*
|
|
6910
|
+
* function label(profile: PersonaProfile): string {
|
|
6911
|
+
* return `${profile.objectId}/${profile.id}: ${profile.name ?? profile.id}`
|
|
6912
|
+
* }
|
|
6394
6913
|
* ```
|
|
6395
6914
|
*/
|
|
6396
|
-
interface
|
|
6397
|
-
/**
|
|
6398
|
-
|
|
6399
|
-
/**
|
|
6400
|
-
|
|
6915
|
+
interface PersonaProfile {
|
|
6916
|
+
/** 角色唯一标识 */
|
|
6917
|
+
id: string;
|
|
6918
|
+
/** 所属主体 ID(多租户隔离;平台内置角色为 `system`) */
|
|
6919
|
+
objectId: string;
|
|
6920
|
+
/** 角色显示名 */
|
|
6921
|
+
name?: string;
|
|
6922
|
+
/** 角色系统提示词 */
|
|
6923
|
+
systemPrompt: string;
|
|
6924
|
+
/** 性格 / 风格特征 */
|
|
6925
|
+
traits: string[];
|
|
6926
|
+
/** 附加元数据 */
|
|
6927
|
+
metadata?: Record<string, unknown>;
|
|
6928
|
+
/** 创建时间(Unix 毫秒) */
|
|
6929
|
+
createdAt: number;
|
|
6930
|
+
/** 更新时间(Unix 毫秒) */
|
|
6931
|
+
updatedAt: number;
|
|
6401
6932
|
}
|
|
6402
6933
|
/**
|
|
6403
|
-
*
|
|
6934
|
+
* Persona 档案更新输入
|
|
6935
|
+
*
|
|
6936
|
+
* 所有字段可选,仅更新传入的字段。
|
|
6404
6937
|
*
|
|
6405
6938
|
* @example
|
|
6406
6939
|
* ```ts
|
|
6407
|
-
* import type {
|
|
6940
|
+
* import type { PersonaProfileUpdate } from '@h-ai/ai'
|
|
6408
6941
|
*
|
|
6409
|
-
* const value:
|
|
6942
|
+
* const value: PersonaProfileUpdate = { traits: ['简洁', '引用来源'] }
|
|
6410
6943
|
* ```
|
|
6411
6944
|
*/
|
|
6412
|
-
interface
|
|
6413
|
-
/**
|
|
6414
|
-
|
|
6415
|
-
/**
|
|
6416
|
-
|
|
6945
|
+
interface PersonaProfileUpdate {
|
|
6946
|
+
/** 更新显示名 */
|
|
6947
|
+
name?: string;
|
|
6948
|
+
/** 更新系统提示词 */
|
|
6949
|
+
systemPrompt?: string;
|
|
6950
|
+
/** 更新特征列表(整体替换) */
|
|
6951
|
+
traits?: string[];
|
|
6952
|
+
/** 更新元数据 */
|
|
6953
|
+
metadata?: Record<string, unknown>;
|
|
6954
|
+
}
|
|
6955
|
+
/**
|
|
6956
|
+
* Persona 操作接口(通过 `ai.persona` 访问)
|
|
6957
|
+
*
|
|
6958
|
+
* 管理 AI 角色人格的持久化与系统提示词组合。需要先调用 `ai.init()` 初始化后使用。
|
|
6959
|
+
*
|
|
6960
|
+
* @example
|
|
6961
|
+
* ```ts
|
|
6962
|
+
* import { ai } from '@h-ai/ai'
|
|
6963
|
+
*
|
|
6964
|
+
* // 应用启动已成功初始化 ai;这里是业务服务函数。
|
|
6965
|
+
* async function run() {
|
|
6966
|
+
* const result = await ai.persona.save({ id: 'support', objectId: 'tenant-1', systemPrompt: '先核对订单状态再回答。' })
|
|
6967
|
+
* if (!result.success)
|
|
6968
|
+
* return result
|
|
6969
|
+
* const composed = await ai.persona.compose(result.data.id, { objectId: result.data.objectId })
|
|
6970
|
+
* if (!composed.success)
|
|
6971
|
+
* return composed
|
|
6972
|
+
* return composed.data
|
|
6973
|
+
* }
|
|
6974
|
+
* ```
|
|
6975
|
+
*/
|
|
6976
|
+
interface PersonaOperations {
|
|
6977
|
+
/**
|
|
6978
|
+
* 创建或覆盖保存一个角色档案(upsert 语义)
|
|
6979
|
+
*
|
|
6980
|
+
* @param profile - 角色档案输入
|
|
6981
|
+
* @returns 保存后的完整档案
|
|
6982
|
+
*/
|
|
6983
|
+
save: (profile: PersonaProfileInput) => Promise<HaiResult<PersonaProfile>>;
|
|
6984
|
+
/**
|
|
6985
|
+
* 按 ID 获取角色档案
|
|
6986
|
+
*
|
|
6987
|
+
* @param id - 角色 ID
|
|
6988
|
+
* @returns 角色档案,不存在时返回 PERSONA_NOT_FOUND
|
|
6989
|
+
*/
|
|
6990
|
+
get: (id: string, options?: PersonaScopeOptions) => Promise<HaiResult<PersonaProfile>>;
|
|
6991
|
+
/**
|
|
6992
|
+
* 更新角色档案(仅更新传入字段)
|
|
6993
|
+
*
|
|
6994
|
+
* @param id - 角色 ID
|
|
6995
|
+
* @param updates - 需要更新的字段
|
|
6996
|
+
* @param options - 主体作用域(默认 `system`)
|
|
6997
|
+
* @returns 更新后的完整档案
|
|
6998
|
+
*/
|
|
6999
|
+
update: (id: string, updates: PersonaProfileUpdate, options?: PersonaScopeOptions) => Promise<HaiResult<PersonaProfile>>;
|
|
7000
|
+
/**
|
|
7001
|
+
* 删除角色档案
|
|
7002
|
+
*
|
|
7003
|
+
* @param id - 角色 ID
|
|
7004
|
+
* @param options - 主体作用域(默认 `system`)
|
|
7005
|
+
* @returns 成功返回 ok(undefined)
|
|
7006
|
+
*/
|
|
7007
|
+
remove: (id: string, options?: PersonaScopeOptions) => Promise<HaiResult<void>>;
|
|
7008
|
+
/**
|
|
7009
|
+
* 列出指定主体的角色档案
|
|
7010
|
+
*
|
|
7011
|
+
* @param options - 主体作用域(默认 `system`)
|
|
7012
|
+
* @returns 角色档案列表
|
|
7013
|
+
*/
|
|
7014
|
+
list: (options?: PersonaScopeOptions) => Promise<HaiResult<PersonaProfile[]>>;
|
|
7015
|
+
/**
|
|
7016
|
+
* 组合角色的完整系统提示词
|
|
7017
|
+
*
|
|
7018
|
+
* 将 `systemPrompt` 与 `traits` 拼装为一段可直接作为 system 消息的文本,
|
|
7019
|
+
* 供 `ai.context.createManager({ scope, systemPrompt })` 使用。
|
|
7020
|
+
*
|
|
7021
|
+
* @param id - 角色 ID
|
|
7022
|
+
* @param options - 主体作用域(默认 `system`)
|
|
7023
|
+
* @returns 组合后的系统提示词,角色不存在时返回 PERSONA_NOT_FOUND
|
|
7024
|
+
*/
|
|
7025
|
+
compose: (id: string, options?: PersonaScopeOptions) => Promise<HaiResult<string>>;
|
|
7026
|
+
}
|
|
7027
|
+
/**
|
|
7028
|
+
* Persona 操作的主体作用域选项
|
|
7029
|
+
*
|
|
7030
|
+
* @example
|
|
7031
|
+
* ```ts
|
|
7032
|
+
* import type { PersonaScopeOptions } from '@h-ai/ai'
|
|
7033
|
+
*
|
|
7034
|
+
* const value: PersonaScopeOptions = { objectId: 'tenant-1' }
|
|
7035
|
+
* ```
|
|
7036
|
+
*/
|
|
7037
|
+
interface PersonaScopeOptions {
|
|
7038
|
+
/** 所属主体 ID(不传时归为平台内置角色 `system`) */
|
|
7039
|
+
objectId?: string;
|
|
7040
|
+
}
|
|
7041
|
+
|
|
7042
|
+
/**
|
|
7043
|
+
* @h-ai/ai — 文生图公共类型
|
|
7044
|
+
*
|
|
7045
|
+
* 公共契约只暴露业务需要的提示词、尺寸和标准化图片字节。
|
|
7046
|
+
* 厂商请求字段、临时 URL 与响应中间态由 Provider 内部处理。
|
|
7047
|
+
* @module image/ai-image-types
|
|
7048
|
+
*/
|
|
7049
|
+
|
|
7050
|
+
/**
|
|
7051
|
+
* 图片像素尺寸
|
|
7052
|
+
*
|
|
7053
|
+
* @example
|
|
7054
|
+
* ```ts
|
|
7055
|
+
* import type { ImageSize } from '@h-ai/ai'
|
|
7056
|
+
*
|
|
7057
|
+
* const value: ImageSize = { width: 1024, height: 1024 }
|
|
7058
|
+
* ```
|
|
7059
|
+
*/
|
|
7060
|
+
interface ImageSize {
|
|
7061
|
+
/** 宽度(像素) */
|
|
7062
|
+
width: number;
|
|
7063
|
+
/** 高度(像素) */
|
|
7064
|
+
height: number;
|
|
7065
|
+
}
|
|
7066
|
+
/**
|
|
7067
|
+
* 可选参考图;Provider 会转换为对应厂商的传输格式
|
|
7068
|
+
*
|
|
7069
|
+
* @example
|
|
7070
|
+
* ```ts
|
|
7071
|
+
* import type { ReferenceImage } from '@h-ai/ai'
|
|
7072
|
+
* import { readFile } from 'node:fs/promises'
|
|
7073
|
+
*
|
|
7074
|
+
* const reference: ReferenceImage = { data: await readFile('reference.png'), mimeType: 'image/png' }
|
|
7075
|
+
* ```
|
|
7076
|
+
*/
|
|
7077
|
+
interface ReferenceImage {
|
|
7078
|
+
/** 图片二进制内容 */
|
|
7079
|
+
data: Uint8Array;
|
|
7080
|
+
/** 图片 MIME 类型,例如 `image/png`、`image/jpeg` */
|
|
7081
|
+
mimeType: string;
|
|
7082
|
+
}
|
|
7083
|
+
/**
|
|
7084
|
+
* 文生图请求
|
|
7085
|
+
*
|
|
7086
|
+
* @example
|
|
7087
|
+
* ```ts
|
|
7088
|
+
* import type { GenerateImageRequest } from '@h-ai/ai'
|
|
7089
|
+
*
|
|
7090
|
+
* const value: GenerateImageRequest = { prompt: '水墨山水,留白构图', size: { width: 1024, height: 1024 }, signal: new AbortController().signal }
|
|
7091
|
+
* ```
|
|
7092
|
+
*/
|
|
7093
|
+
interface GenerateImageRequest {
|
|
7094
|
+
/** 图片内容与风格提示词 */
|
|
7095
|
+
prompt: string;
|
|
7096
|
+
/** 模型 ID;不传时使用配置中的默认文生图模型 */
|
|
7097
|
+
model?: string;
|
|
6417
7098
|
/** 输出像素尺寸;不传时由模型决定 */
|
|
6418
7099
|
size?: ImageSize;
|
|
6419
7100
|
/** 用于图生图、编辑或风格参考的一张或多张图片 */
|
|
@@ -6690,180 +7371,159 @@ interface MCPOperations {
|
|
|
6690
7371
|
}
|
|
6691
7372
|
|
|
6692
7373
|
/**
|
|
6693
|
-
*
|
|
6694
|
-
*
|
|
6695
|
-
*
|
|
6696
|
-
*
|
|
6697
|
-
*
|
|
6698
|
-
*
|
|
6699
|
-
* @module ai-persona-types
|
|
7374
|
+
* 清单项与来源;配置来源不可修改,version 仅用于数据库乐观并发更新。
|
|
7375
|
+
* @example
|
|
7376
|
+
* ```ts
|
|
7377
|
+
* import type { AIResourceEntry, ModelEntry } from '@h-ai/ai'
|
|
7378
|
+
* function editable(entry: AIResourceEntry<ModelEntry>) { return entry.source === 'database' }
|
|
7379
|
+
* ```
|
|
6700
7380
|
*/
|
|
6701
|
-
|
|
7381
|
+
interface AIResourceEntry<T> {
|
|
7382
|
+
/** 原始配置;返回独立副本,修改副本不会修改清单。 */
|
|
7383
|
+
value: T;
|
|
7384
|
+
/** config 来自初始化配置,database 来自 AIStoreProvider。 */
|
|
7385
|
+
source: 'config' | 'database';
|
|
7386
|
+
/** get 返回的数据库版本;更新/删除时可传回以拒绝过期写入。 */
|
|
7387
|
+
version?: string;
|
|
7388
|
+
}
|
|
6702
7389
|
/**
|
|
6703
|
-
*
|
|
6704
|
-
*
|
|
7390
|
+
* 配置与数据库合并的资源清单。相同 ID 配置优先,配置记录永不写回数据库。
|
|
6705
7391
|
* @example
|
|
6706
7392
|
* ```ts
|
|
6707
|
-
* import
|
|
6708
|
-
*
|
|
6709
|
-
* const value: PersonaProfileInput = { id: 'support', objectId: 'tenant-1', name: '客服助手', systemPrompt: '根据已验证的订单信息回答。', traits: ['简洁', '先核对证据'] }
|
|
7393
|
+
* import { ai } from '@h-ai/ai'
|
|
7394
|
+
* async function listModels() { const result = await ai.llm.models.list(); if (!result.success) return result; return result.data.map(item => ({ id: item.value.id, source: item.source })) }
|
|
6710
7395
|
* ```
|
|
6711
7396
|
*/
|
|
6712
|
-
interface
|
|
6713
|
-
/** 角色唯一标识(业务侧稳定 ID,如 `xiaop`) */
|
|
6714
|
-
id: string;
|
|
7397
|
+
interface AIResourceRegistry<T, Input = T> {
|
|
6715
7398
|
/**
|
|
6716
|
-
*
|
|
6717
|
-
*
|
|
6718
|
-
*
|
|
7399
|
+
* 读取合并清单;保留配置顺序,追加未被遮蔽的数据库项。
|
|
7400
|
+
* @returns 包含 value/source 的去重列表;列表项无数据库版本。
|
|
7401
|
+
* @example
|
|
7402
|
+
* ```ts
|
|
7403
|
+
* import { ai } from '@h-ai/ai'
|
|
7404
|
+
* const result = await ai.llm.models.list()
|
|
7405
|
+
* if (result.success) { const entries = result.data }
|
|
7406
|
+
* ```
|
|
6719
7407
|
*/
|
|
6720
|
-
|
|
6721
|
-
/**
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
7408
|
+
list: () => Promise<HaiResult<AIResourceEntry<T>[]>>;
|
|
7409
|
+
/**
|
|
7410
|
+
* 按 ID 读取来源、配置和数据库版本。
|
|
7411
|
+
* @param id - 资源 ID。
|
|
7412
|
+
* @returns 包含 value/source/version 的资源条目,未找到时返回失败。
|
|
7413
|
+
* @example
|
|
7414
|
+
* ```ts
|
|
7415
|
+
* import { ai } from '@h-ai/ai'
|
|
7416
|
+
* const result = await ai.llm.models.get('coding')
|
|
7417
|
+
* if (result.success) { const source = result.data.source }
|
|
7418
|
+
* ```
|
|
7419
|
+
*/
|
|
7420
|
+
get: (id: string) => Promise<HaiResult<AIResourceEntry<T>>>;
|
|
7421
|
+
/**
|
|
7422
|
+
* 新建数据库记录;ID 已存在或属于配置时拒绝。
|
|
7423
|
+
* @param input - 完整资源配置。
|
|
7424
|
+
* @returns 新建条目及版本的 HaiResult,配置同 ID 返回只读错误。
|
|
7425
|
+
* @example
|
|
7426
|
+
* ```ts
|
|
7427
|
+
* import { ai } from '@h-ai/ai'
|
|
7428
|
+
* const result = await ai.llm.models.register({ id: 'coding', model: 'example-model', protocol: 'responses' })
|
|
7429
|
+
* if (!result.success) { const code = result.error.code }
|
|
7430
|
+
* ```
|
|
7431
|
+
*/
|
|
7432
|
+
register: (input: Input) => Promise<HaiResult<AIResourceEntry<T>>>;
|
|
7433
|
+
/**
|
|
7434
|
+
* 完整替换数据库记录;配置来源只读。版本不匹配时不写入。
|
|
7435
|
+
* @param input - 同 ID 的完整新配置。
|
|
7436
|
+
* @param expectedVersion - 可选的 get 版本。
|
|
7437
|
+
* @returns 替换后的条目及版本;过期版本返回资源冲突。
|
|
7438
|
+
* @example
|
|
7439
|
+
* ```ts
|
|
7440
|
+
* import { ai } from '@h-ai/ai'
|
|
7441
|
+
* const current = await ai.llm.models.get('coding')
|
|
7442
|
+
* if (current.success && current.data.source === 'database') {
|
|
7443
|
+
* const result = await ai.llm.models.update({ ...current.data.value, temperature: 0.2 }, current.data.version)
|
|
7444
|
+
* if (!result.success) { const code = result.error.code }
|
|
7445
|
+
* }
|
|
7446
|
+
* ```
|
|
7447
|
+
*/
|
|
7448
|
+
update: (input: Input, expectedVersion?: string) => Promise<HaiResult<AIResourceEntry<T>>>;
|
|
7449
|
+
/**
|
|
7450
|
+
* 删除数据库记录,采用 CAS 墓碑避免与并发更新相互覆盖;不删除外部文件。
|
|
7451
|
+
* @param id - 资源 ID。
|
|
7452
|
+
* @param expectedVersion - 可选的 get 版本。
|
|
7453
|
+
* @returns 删除完成的 HaiResult;配置只读、版本冲突或记录不存在时失败。
|
|
7454
|
+
* @example
|
|
7455
|
+
* ```ts
|
|
7456
|
+
* import { ai } from '@h-ai/ai'
|
|
7457
|
+
* const result = await ai.llm.models.remove('temporary')
|
|
7458
|
+
* if (!result.success) { const code = result.error.code }
|
|
7459
|
+
* ```
|
|
7460
|
+
*/
|
|
7461
|
+
remove: (id: string, expectedVersion?: string) => Promise<HaiResult<void>>;
|
|
6729
7462
|
}
|
|
6730
7463
|
/**
|
|
6731
|
-
*
|
|
6732
|
-
*
|
|
7464
|
+
* 包含配置/数据库资源维护的 llm 操作接口。
|
|
6733
7465
|
* @example
|
|
6734
7466
|
* ```ts
|
|
6735
|
-
* import
|
|
6736
|
-
*
|
|
6737
|
-
*
|
|
6738
|
-
* return `${profile.objectId}/${profile.id}: ${profile.name ?? profile.id}`
|
|
6739
|
-
* }
|
|
7467
|
+
* import { ai } from '@h-ai/ai'
|
|
7468
|
+
* const result = await ai.llm.models.list()
|
|
7469
|
+
* if (result.success) { const resources = result.data }
|
|
6740
7470
|
* ```
|
|
6741
7471
|
*/
|
|
6742
|
-
interface
|
|
6743
|
-
/**
|
|
6744
|
-
|
|
6745
|
-
/** 所属主体 ID(多租户隔离;平台内置角色为 `system`) */
|
|
6746
|
-
objectId: string;
|
|
6747
|
-
/** 角色显示名 */
|
|
6748
|
-
name?: string;
|
|
6749
|
-
/** 角色系统提示词 */
|
|
6750
|
-
systemPrompt: string;
|
|
6751
|
-
/** 性格 / 风格特征 */
|
|
6752
|
-
traits: string[];
|
|
6753
|
-
/** 附加元数据 */
|
|
6754
|
-
metadata?: Record<string, unknown>;
|
|
6755
|
-
/** 创建时间(Unix 毫秒) */
|
|
6756
|
-
createdAt: number;
|
|
6757
|
-
/** 更新时间(Unix 毫秒) */
|
|
6758
|
-
updatedAt: number;
|
|
7472
|
+
interface ManagedLLMOperations extends LLMOperations {
|
|
7473
|
+
/** 配置只读、数据库可维护的合并清单。 */
|
|
7474
|
+
models: AIResourceRegistry<z.output<typeof ModelEntrySchema>, z.input<typeof ModelEntrySchema>>;
|
|
6759
7475
|
}
|
|
6760
7476
|
/**
|
|
6761
|
-
*
|
|
6762
|
-
*
|
|
6763
|
-
* 所有字段可选,仅更新传入的字段。
|
|
6764
|
-
*
|
|
7477
|
+
* 包含配置/数据库资源维护的 audio 操作接口。
|
|
6765
7478
|
* @example
|
|
6766
7479
|
* ```ts
|
|
6767
|
-
* import
|
|
6768
|
-
*
|
|
6769
|
-
*
|
|
7480
|
+
* import { ai } from '@h-ai/ai'
|
|
7481
|
+
* const result = await ai.audio.models.list()
|
|
7482
|
+
* if (result.success) { const resources = result.data }
|
|
6770
7483
|
* ```
|
|
6771
7484
|
*/
|
|
6772
|
-
interface
|
|
6773
|
-
/**
|
|
6774
|
-
|
|
6775
|
-
/** 更新系统提示词 */
|
|
6776
|
-
systemPrompt?: string;
|
|
6777
|
-
/** 更新特征列表(整体替换) */
|
|
6778
|
-
traits?: string[];
|
|
6779
|
-
/** 更新元数据 */
|
|
6780
|
-
metadata?: Record<string, unknown>;
|
|
7485
|
+
interface ManagedAudioOperations extends AudioOperations {
|
|
7486
|
+
/** 配置只读、数据库可维护的合并清单。 */
|
|
7487
|
+
models: AIResourceRegistry<z.output<typeof AudioModelEntrySchema>, z.input<typeof AudioModelEntrySchema>>;
|
|
6781
7488
|
}
|
|
6782
7489
|
/**
|
|
6783
|
-
*
|
|
6784
|
-
*
|
|
6785
|
-
* 管理 AI 角色人格的持久化与系统提示词组合。需要先调用 `ai.init()` 初始化后使用。
|
|
6786
|
-
*
|
|
7490
|
+
* 包含配置/数据库资源维护的 image 操作接口。
|
|
6787
7491
|
* @example
|
|
6788
7492
|
* ```ts
|
|
6789
7493
|
* import { ai } from '@h-ai/ai'
|
|
6790
|
-
*
|
|
6791
|
-
*
|
|
6792
|
-
* async function run() {
|
|
6793
|
-
* const result = await ai.persona.save({ id: 'support', objectId: 'tenant-1', systemPrompt: '先核对订单状态再回答。' })
|
|
6794
|
-
* if (!result.success)
|
|
6795
|
-
* return result
|
|
6796
|
-
* const composed = await ai.persona.compose(result.data.id, { objectId: result.data.objectId })
|
|
6797
|
-
* if (!composed.success)
|
|
6798
|
-
* return composed
|
|
6799
|
-
* return composed.data
|
|
6800
|
-
* }
|
|
7494
|
+
* const result = await ai.image.models.list()
|
|
7495
|
+
* if (result.success) { const resources = result.data }
|
|
6801
7496
|
* ```
|
|
6802
7497
|
*/
|
|
6803
|
-
interface
|
|
6804
|
-
/**
|
|
6805
|
-
|
|
6806
|
-
*
|
|
6807
|
-
* @param profile - 角色档案输入
|
|
6808
|
-
* @returns 保存后的完整档案
|
|
6809
|
-
*/
|
|
6810
|
-
save: (profile: PersonaProfileInput) => Promise<HaiResult<PersonaProfile>>;
|
|
6811
|
-
/**
|
|
6812
|
-
* 按 ID 获取角色档案
|
|
6813
|
-
*
|
|
6814
|
-
* @param id - 角色 ID
|
|
6815
|
-
* @returns 角色档案,不存在时返回 PERSONA_NOT_FOUND
|
|
6816
|
-
*/
|
|
6817
|
-
get: (id: string, options?: PersonaScopeOptions) => Promise<HaiResult<PersonaProfile>>;
|
|
6818
|
-
/**
|
|
6819
|
-
* 更新角色档案(仅更新传入字段)
|
|
6820
|
-
*
|
|
6821
|
-
* @param id - 角色 ID
|
|
6822
|
-
* @param updates - 需要更新的字段
|
|
6823
|
-
* @param options - 主体作用域(默认 `system`)
|
|
6824
|
-
* @returns 更新后的完整档案
|
|
6825
|
-
*/
|
|
6826
|
-
update: (id: string, updates: PersonaProfileUpdate, options?: PersonaScopeOptions) => Promise<HaiResult<PersonaProfile>>;
|
|
6827
|
-
/**
|
|
6828
|
-
* 删除角色档案
|
|
6829
|
-
*
|
|
6830
|
-
* @param id - 角色 ID
|
|
6831
|
-
* @param options - 主体作用域(默认 `system`)
|
|
6832
|
-
* @returns 成功返回 ok(undefined)
|
|
6833
|
-
*/
|
|
6834
|
-
remove: (id: string, options?: PersonaScopeOptions) => Promise<HaiResult<void>>;
|
|
6835
|
-
/**
|
|
6836
|
-
* 列出指定主体的角色档案
|
|
6837
|
-
*
|
|
6838
|
-
* @param options - 主体作用域(默认 `system`)
|
|
6839
|
-
* @returns 角色档案列表
|
|
6840
|
-
*/
|
|
6841
|
-
list: (options?: PersonaScopeOptions) => Promise<HaiResult<PersonaProfile[]>>;
|
|
6842
|
-
/**
|
|
6843
|
-
* 组合角色的完整系统提示词
|
|
6844
|
-
*
|
|
6845
|
-
* 将 `systemPrompt` 与 `traits` 拼装为一段可直接作为 system 消息的文本,
|
|
6846
|
-
* 供 `ai.context.createManager({ scope, systemPrompt })` 使用。
|
|
6847
|
-
*
|
|
6848
|
-
* @param id - 角色 ID
|
|
6849
|
-
* @param options - 主体作用域(默认 `system`)
|
|
6850
|
-
* @returns 组合后的系统提示词,角色不存在时返回 PERSONA_NOT_FOUND
|
|
6851
|
-
*/
|
|
6852
|
-
compose: (id: string, options?: PersonaScopeOptions) => Promise<HaiResult<string>>;
|
|
7498
|
+
interface ManagedImageOperations extends ImageOperations {
|
|
7499
|
+
/** 配置只读、数据库可维护的合并清单。 */
|
|
7500
|
+
models: AIResourceRegistry<z.output<typeof ImageModelEntrySchema>, z.input<typeof ImageModelEntrySchema>>;
|
|
6853
7501
|
}
|
|
6854
7502
|
/**
|
|
6855
|
-
*
|
|
6856
|
-
*
|
|
7503
|
+
* 包含配置/数据库资源维护的 mcp 操作接口。
|
|
6857
7504
|
* @example
|
|
6858
7505
|
* ```ts
|
|
6859
|
-
* import
|
|
6860
|
-
*
|
|
6861
|
-
*
|
|
7506
|
+
* import { ai } from '@h-ai/ai'
|
|
7507
|
+
* const result = await ai.mcp.servers.list()
|
|
7508
|
+
* if (result.success) { const resources = result.data }
|
|
6862
7509
|
* ```
|
|
6863
7510
|
*/
|
|
6864
|
-
interface
|
|
6865
|
-
/**
|
|
6866
|
-
|
|
7511
|
+
interface ManagedMCPOperations extends MCPOperations {
|
|
7512
|
+
/** 配置只读、数据库可维护的合并清单。 */
|
|
7513
|
+
servers: AIResourceRegistry<z.output<typeof MCPExternalServerSchema>, z.input<typeof MCPExternalServerSchema>>;
|
|
7514
|
+
}
|
|
7515
|
+
/**
|
|
7516
|
+
* 包含配置/数据库资源维护的 retrieval 操作接口。
|
|
7517
|
+
* @example
|
|
7518
|
+
* ```ts
|
|
7519
|
+
* import { ai } from '@h-ai/ai'
|
|
7520
|
+
* const result = await ai.retrieval.sources.list()
|
|
7521
|
+
* if (result.success) { const resources = result.data }
|
|
7522
|
+
* ```
|
|
7523
|
+
*/
|
|
7524
|
+
interface ManagedRetrievalOperations extends RetrievalOperations {
|
|
7525
|
+
/** 配置只读、数据库可维护的合并清单。 */
|
|
7526
|
+
sources: AIResourceRegistry<z.output<typeof RetrievalSourceSchema>, z.input<typeof RetrievalSourceSchema>>;
|
|
6867
7527
|
}
|
|
6868
7528
|
|
|
6869
7529
|
/**
|
|
@@ -7046,6 +7706,21 @@ interface TokenOperations {
|
|
|
7046
7706
|
*/
|
|
7047
7707
|
declare const HaiAIError: {
|
|
7048
7708
|
readonly INTERNAL_ERROR: _h_ai_core.HaiErrorDef;
|
|
7709
|
+
readonly ACP_GIT_NOT_FOUND: _h_ai_core.HaiErrorDef;
|
|
7710
|
+
readonly ACP_OPERATION_FAILED: _h_ai_core.HaiErrorDef;
|
|
7711
|
+
readonly ACP_INVALID_REQUEST: _h_ai_core.HaiErrorDef;
|
|
7712
|
+
readonly ACP_NOT_FOUND: _h_ai_core.HaiErrorDef;
|
|
7713
|
+
readonly ACP_BUSY: _h_ai_core.HaiErrorDef;
|
|
7714
|
+
readonly ACP_UNSUPPORTED: _h_ai_core.HaiErrorDef;
|
|
7715
|
+
readonly ACP_CANCELLED: _h_ai_core.HaiErrorDef;
|
|
7716
|
+
readonly ACP_TIMEOUT: _h_ai_core.HaiErrorDef;
|
|
7717
|
+
readonly ACP_OUTPUT_INVALID: _h_ai_core.HaiErrorDef;
|
|
7718
|
+
readonly ACP_CONFLICT: _h_ai_core.HaiErrorDef;
|
|
7719
|
+
readonly ACP_PARTIAL_FAILURE: _h_ai_core.HaiErrorDef;
|
|
7720
|
+
readonly ACP_CLOSED: _h_ai_core.HaiErrorDef;
|
|
7721
|
+
readonly ACP_RUNTIME_UNAVAILABLE: _h_ai_core.HaiErrorDef;
|
|
7722
|
+
readonly ACP_MODEL_INCOMPATIBLE: _h_ai_core.HaiErrorDef;
|
|
7723
|
+
readonly ACP_CLEANUP_FAILED: _h_ai_core.HaiErrorDef;
|
|
7049
7724
|
readonly NOT_INITIALIZED: _h_ai_core.HaiErrorDef;
|
|
7050
7725
|
readonly CONFIGURATION_ERROR: _h_ai_core.HaiErrorDef;
|
|
7051
7726
|
readonly INIT_IN_PROGRESS: _h_ai_core.HaiErrorDef;
|
|
@@ -7118,6 +7793,11 @@ declare const HaiAIError: {
|
|
|
7118
7793
|
readonly IMAGE_DOWNLOAD_BLOCKED: _h_ai_core.HaiErrorDef;
|
|
7119
7794
|
readonly IMAGE_TOO_LARGE: _h_ai_core.HaiErrorDef;
|
|
7120
7795
|
readonly IMAGE_TIMEOUT: _h_ai_core.HaiErrorDef;
|
|
7796
|
+
readonly RESOURCE_READ_ONLY: _h_ai_core.HaiErrorDef;
|
|
7797
|
+
readonly RESOURCE_NOT_FOUND: _h_ai_core.HaiErrorDef;
|
|
7798
|
+
readonly RESOURCE_CONFLICT: _h_ai_core.HaiErrorDef;
|
|
7799
|
+
readonly RESOURCE_INVALID: _h_ai_core.HaiErrorDef;
|
|
7800
|
+
readonly RESOURCE_OPERATION_FAILED: _h_ai_core.HaiErrorDef;
|
|
7121
7801
|
readonly CONTEXT_COMPRESS_FAILED: _h_ai_core.HaiErrorDef;
|
|
7122
7802
|
readonly CONTEXT_SUMMARIZE_FAILED: _h_ai_core.HaiErrorDef;
|
|
7123
7803
|
readonly CONTEXT_TOKEN_ESTIMATE_FAILED: _h_ai_core.HaiErrorDef;
|
|
@@ -7152,6 +7832,8 @@ declare const HaiAIError: {
|
|
|
7152
7832
|
* ```
|
|
7153
7833
|
*/
|
|
7154
7834
|
interface AIInitOptions {
|
|
7835
|
+
/** 可信服务端扩展:为其他 ACP 智能体生成原生配置。 */
|
|
7836
|
+
acpAdapters?: Record<string, ACPAgentAdapter>;
|
|
7155
7837
|
/**
|
|
7156
7838
|
* 自定义存储 Provider
|
|
7157
7839
|
*
|
|
@@ -7208,9 +7890,11 @@ interface AIFunctions {
|
|
|
7208
7890
|
/** 是否已初始化(`init()` 成功后为 `true`,`close()` 后为 `false`) */
|
|
7209
7891
|
readonly isInitialized: boolean;
|
|
7210
7892
|
/** LLM 操作(聊天、流式、模型列表),需要先调用 `init()` */
|
|
7211
|
-
readonly llm:
|
|
7212
|
-
/**
|
|
7213
|
-
readonly
|
|
7893
|
+
readonly llm: ManagedLLMOperations;
|
|
7894
|
+
/** ACP 智能体、工作区与原生会话,需要先调用 `init()`。 */
|
|
7895
|
+
readonly acp: ACPOperations;
|
|
7896
|
+
/** MCP 本地函数注册及配置/数据库外部服务清单,需要先调用 `init()`。 */
|
|
7897
|
+
readonly mcp: ManagedMCPOperations;
|
|
7214
7898
|
/** 工具操作(定义工具与注册表),纯函数,无需初始化 */
|
|
7215
7899
|
readonly tools: ToolsOperations;
|
|
7216
7900
|
/** 流处理操作(流处理器、SSE 编解码),纯函数,无需初始化 */
|
|
@@ -7220,7 +7904,7 @@ interface AIFunctions {
|
|
|
7220
7904
|
/** 推理操作(ReAct / CoT / Plan-Execute),需要先调用 `init()` */
|
|
7221
7905
|
readonly reasoning: ReasoningOperations;
|
|
7222
7906
|
/** 检索操作(向量检索),需要先调用 `init()` */
|
|
7223
|
-
readonly retrieval:
|
|
7907
|
+
readonly retrieval: ManagedRetrievalOperations;
|
|
7224
7908
|
/** RAG 操作(检索增强生成),需要先调用 `init()` */
|
|
7225
7909
|
readonly rag: RagOperations;
|
|
7226
7910
|
/** Knowledge 操作(知识库管理与检索),需要先调用 `init()` 和 `knowledge.setup()` */
|
|
@@ -7244,9 +7928,9 @@ interface AIFunctions {
|
|
|
7244
7928
|
/** A2A 操作(Agent-to-Agent 协议),需要先调用 `init()` 并配置 `a2a` */
|
|
7245
7929
|
readonly a2a: A2AOperations;
|
|
7246
7930
|
/** Audio 操作(语音识别 / 语音合成),需要先调用 `init()` 并配置 `audio` */
|
|
7247
|
-
readonly audio:
|
|
7931
|
+
readonly audio: ManagedAudioOperations;
|
|
7248
7932
|
/** Image 操作(文生图),需要先调用 `init()` 并配置 `image` */
|
|
7249
|
-
readonly image:
|
|
7933
|
+
readonly image: ManagedImageOperations;
|
|
7250
7934
|
}
|
|
7251
7935
|
|
|
7252
7936
|
/** @h-ai/ai — 音频播放负载序列化 */
|
|
@@ -7602,4 +8286,1583 @@ interface AudioWsEndMessage {
|
|
|
7602
8286
|
*/
|
|
7603
8287
|
type AudioWsServerMessage = AudioWsSpeechMessage | AudioWsTranscriptMessage | AudioWsSegmentStartedMessage | AudioWsSegmentDoneMessage | AudioWsErrorMessage | AudioWsEndMessage;
|
|
7604
8288
|
|
|
7605
|
-
|
|
8289
|
+
/**
|
|
8290
|
+
* ACP 子系统;资源占用通过 CAS 持久化,不以超时推断失联进程已停止。
|
|
8291
|
+
* @param provider - 与 AI 模块共享的持久存储;工厂创建表后由调用方统一初始化。
|
|
8292
|
+
* @param config - 经 AIConfigSchema 校验的模块配置,包括只读智能体和工作区。
|
|
8293
|
+
* @param extensions - 可信原生配置适配器,可覆盖同名内置适配器。
|
|
8294
|
+
* @param modelConfig - 获取包含数据库模型的实时配置;默认使用初始化配置。
|
|
8295
|
+
* @param mcpLookup - 将合并清单 ID 解析为原生 MCP 定义,启动时解析环境变量。
|
|
8296
|
+
* @returns 智能体、工作区、会话管理器和低层连接入口;业务失败返回 HaiResult。
|
|
8297
|
+
* @example
|
|
8298
|
+
* ```ts
|
|
8299
|
+
* // 模块内部上下文;存储在工厂创建所有表后统一初始化。
|
|
8300
|
+
* async function assemble(provider: AIStoreProvider, config: AIConfig) { const acp = createACPOperations(provider, config); await provider.initialize(); return acp }
|
|
8301
|
+
* ```
|
|
8302
|
+
*/
|
|
8303
|
+
declare function createACPOperations(provider: AIStoreProvider, config: AIConfig, extensions?: Record<string, ACPAgentAdapter>, modelConfig?: () => Promise<AIConfig>, mcpLookup?: (ids: string[]) => Promise<McpServer[]>): {
|
|
8304
|
+
agents: {
|
|
8305
|
+
/**
|
|
8306
|
+
* 校验模型与适配器后新增数据库智能体;配置同名条目只读。
|
|
8307
|
+
* @param input - 完整智能体定义,必须引用已有 Hai 模型 ID。
|
|
8308
|
+
* @returns 带 source/version 的新增条目;配置同 ID 返回只读错误。
|
|
8309
|
+
* @example
|
|
8310
|
+
* ```ts
|
|
8311
|
+
* import { ai } from '@h-ai/ai'
|
|
8312
|
+
* // 前提:ai 已成功初始化。
|
|
8313
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8314
|
+
* const result = await ai.acp.agents.register({ id: 'coder', name: 'Coder', mode: 'embedded', adapter: 'codex', modelIds: ['coding'] })
|
|
8315
|
+
* ```
|
|
8316
|
+
*/
|
|
8317
|
+
register: (input: z.input<typeof ACPAgentSchema>) => Promise<HaiResult<AIResourceEntry<{
|
|
8318
|
+
mode: "custom-service";
|
|
8319
|
+
transport: "http" | "ws";
|
|
8320
|
+
url: string;
|
|
8321
|
+
headerEnv: Record<string, string>;
|
|
8322
|
+
supportedTransports: ("http" | "ws")[];
|
|
8323
|
+
id: string;
|
|
8324
|
+
name: string;
|
|
8325
|
+
enabled: boolean;
|
|
8326
|
+
adapter: string;
|
|
8327
|
+
modelIds: string[];
|
|
8328
|
+
environmentRefs: Record<string, string>;
|
|
8329
|
+
defaultModelId?: string | undefined;
|
|
8330
|
+
} | {
|
|
8331
|
+
mode: "embedded";
|
|
8332
|
+
transport: "stdio";
|
|
8333
|
+
id: string;
|
|
8334
|
+
name: string;
|
|
8335
|
+
enabled: boolean;
|
|
8336
|
+
adapter: string;
|
|
8337
|
+
modelIds: string[];
|
|
8338
|
+
environmentRefs: Record<string, string>;
|
|
8339
|
+
command?: string | undefined;
|
|
8340
|
+
args?: string[] | undefined;
|
|
8341
|
+
defaultModelId?: string | undefined;
|
|
8342
|
+
} | {
|
|
8343
|
+
mode: "builtin-service";
|
|
8344
|
+
transport: "stdio";
|
|
8345
|
+
image: string;
|
|
8346
|
+
engine: "auto" | "podman" | "docker";
|
|
8347
|
+
id: string;
|
|
8348
|
+
name: string;
|
|
8349
|
+
enabled: boolean;
|
|
8350
|
+
adapter: string;
|
|
8351
|
+
modelIds: string[];
|
|
8352
|
+
environmentRefs: Record<string, string>;
|
|
8353
|
+
command?: string | undefined;
|
|
8354
|
+
args?: string[] | undefined;
|
|
8355
|
+
defaultModelId?: string | undefined;
|
|
8356
|
+
}>>>;
|
|
8357
|
+
/**
|
|
8358
|
+
* 按 ID 读取合并清单条目;source 区分配置与数据库,数据库 get 返回 version。
|
|
8359
|
+
* @param id - 智能体 ID。
|
|
8360
|
+
* @returns 合并后的资源条目;未找到时返回资源不存在错误。
|
|
8361
|
+
* @example
|
|
8362
|
+
* ```ts
|
|
8363
|
+
* import { ai } from '@h-ai/ai'
|
|
8364
|
+
* // 前提:ai 已成功初始化。
|
|
8365
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8366
|
+
* const result = await ai.acp.agents.get('coder')
|
|
8367
|
+
* ```
|
|
8368
|
+
*/
|
|
8369
|
+
get: (id: string) => Promise<HaiResult<AIResourceEntry<{
|
|
8370
|
+
mode: "custom-service";
|
|
8371
|
+
transport: "http" | "ws";
|
|
8372
|
+
url: string;
|
|
8373
|
+
headerEnv: Record<string, string>;
|
|
8374
|
+
supportedTransports: ("http" | "ws")[];
|
|
8375
|
+
id: string;
|
|
8376
|
+
name: string;
|
|
8377
|
+
enabled: boolean;
|
|
8378
|
+
adapter: string;
|
|
8379
|
+
modelIds: string[];
|
|
8380
|
+
environmentRefs: Record<string, string>;
|
|
8381
|
+
defaultModelId?: string | undefined;
|
|
8382
|
+
} | {
|
|
8383
|
+
mode: "embedded";
|
|
8384
|
+
transport: "stdio";
|
|
8385
|
+
id: string;
|
|
8386
|
+
name: string;
|
|
8387
|
+
enabled: boolean;
|
|
8388
|
+
adapter: string;
|
|
8389
|
+
modelIds: string[];
|
|
8390
|
+
environmentRefs: Record<string, string>;
|
|
8391
|
+
command?: string | undefined;
|
|
8392
|
+
args?: string[] | undefined;
|
|
8393
|
+
defaultModelId?: string | undefined;
|
|
8394
|
+
} | {
|
|
8395
|
+
mode: "builtin-service";
|
|
8396
|
+
transport: "stdio";
|
|
8397
|
+
image: string;
|
|
8398
|
+
engine: "auto" | "podman" | "docker";
|
|
8399
|
+
id: string;
|
|
8400
|
+
name: string;
|
|
8401
|
+
enabled: boolean;
|
|
8402
|
+
adapter: string;
|
|
8403
|
+
modelIds: string[];
|
|
8404
|
+
environmentRefs: Record<string, string>;
|
|
8405
|
+
command?: string | undefined;
|
|
8406
|
+
args?: string[] | undefined;
|
|
8407
|
+
defaultModelId?: string | undefined;
|
|
8408
|
+
}>>>;
|
|
8409
|
+
/**
|
|
8410
|
+
* 列出配置与数据库合并后的智能体;同 ID 配置优先。
|
|
8411
|
+
* @returns 去重后的智能体条目列表;列表项不带数据库 version。
|
|
8412
|
+
* @example
|
|
8413
|
+
* ```ts
|
|
8414
|
+
* import { ai } from '@h-ai/ai'
|
|
8415
|
+
* // 前提:ai 已成功初始化。
|
|
8416
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8417
|
+
* const result = await ai.acp.agents.list()
|
|
8418
|
+
* ```
|
|
8419
|
+
*/
|
|
8420
|
+
list: () => Promise<HaiResult<AIResourceEntry<{
|
|
8421
|
+
mode: "custom-service";
|
|
8422
|
+
transport: "http" | "ws";
|
|
8423
|
+
url: string;
|
|
8424
|
+
headerEnv: Record<string, string>;
|
|
8425
|
+
supportedTransports: ("http" | "ws")[];
|
|
8426
|
+
id: string;
|
|
8427
|
+
name: string;
|
|
8428
|
+
enabled: boolean;
|
|
8429
|
+
adapter: string;
|
|
8430
|
+
modelIds: string[];
|
|
8431
|
+
environmentRefs: Record<string, string>;
|
|
8432
|
+
defaultModelId?: string | undefined;
|
|
8433
|
+
} | {
|
|
8434
|
+
mode: "embedded";
|
|
8435
|
+
transport: "stdio";
|
|
8436
|
+
id: string;
|
|
8437
|
+
name: string;
|
|
8438
|
+
enabled: boolean;
|
|
8439
|
+
adapter: string;
|
|
8440
|
+
modelIds: string[];
|
|
8441
|
+
environmentRefs: Record<string, string>;
|
|
8442
|
+
command?: string | undefined;
|
|
8443
|
+
args?: string[] | undefined;
|
|
8444
|
+
defaultModelId?: string | undefined;
|
|
8445
|
+
} | {
|
|
8446
|
+
mode: "builtin-service";
|
|
8447
|
+
transport: "stdio";
|
|
8448
|
+
image: string;
|
|
8449
|
+
engine: "auto" | "podman" | "docker";
|
|
8450
|
+
id: string;
|
|
8451
|
+
name: string;
|
|
8452
|
+
enabled: boolean;
|
|
8453
|
+
adapter: string;
|
|
8454
|
+
modelIds: string[];
|
|
8455
|
+
environmentRefs: Record<string, string>;
|
|
8456
|
+
command?: string | undefined;
|
|
8457
|
+
args?: string[] | undefined;
|
|
8458
|
+
defaultModelId?: string | undefined;
|
|
8459
|
+
}>[]>>;
|
|
8460
|
+
/**
|
|
8461
|
+
* 整体替换数据库智能体;可传入 get 返回的版本防止覆盖并发修改,配置条目不可改。
|
|
8462
|
+
* @param input - 包含原 ID 的完整替换定义。
|
|
8463
|
+
* @param version - get 返回的数据库版本;传入时校验并发修改。
|
|
8464
|
+
* @returns 更新后的资源条目;配置只读、版本冲突均返回失败。
|
|
8465
|
+
* @example
|
|
8466
|
+
* ```ts
|
|
8467
|
+
* import { ai } from '@h-ai/ai'
|
|
8468
|
+
* // 前提:ai 已成功初始化。
|
|
8469
|
+
* // definition 为完整替换定义;entry 为 get 成功返回的条目。
|
|
8470
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8471
|
+
* const result = await ai.acp.agents.update(definition, entry.version)
|
|
8472
|
+
* ```
|
|
8473
|
+
*/
|
|
8474
|
+
update: (input: z.input<typeof ACPAgentSchema>, version?: string) => Promise<HaiResult<AIResourceEntry<{
|
|
8475
|
+
mode: "custom-service";
|
|
8476
|
+
transport: "http" | "ws";
|
|
8477
|
+
url: string;
|
|
8478
|
+
headerEnv: Record<string, string>;
|
|
8479
|
+
supportedTransports: ("http" | "ws")[];
|
|
8480
|
+
id: string;
|
|
8481
|
+
name: string;
|
|
8482
|
+
enabled: boolean;
|
|
8483
|
+
adapter: string;
|
|
8484
|
+
modelIds: string[];
|
|
8485
|
+
environmentRefs: Record<string, string>;
|
|
8486
|
+
defaultModelId?: string | undefined;
|
|
8487
|
+
} | {
|
|
8488
|
+
mode: "embedded";
|
|
8489
|
+
transport: "stdio";
|
|
8490
|
+
id: string;
|
|
8491
|
+
name: string;
|
|
8492
|
+
enabled: boolean;
|
|
8493
|
+
adapter: string;
|
|
8494
|
+
modelIds: string[];
|
|
8495
|
+
environmentRefs: Record<string, string>;
|
|
8496
|
+
command?: string | undefined;
|
|
8497
|
+
args?: string[] | undefined;
|
|
8498
|
+
defaultModelId?: string | undefined;
|
|
8499
|
+
} | {
|
|
8500
|
+
mode: "builtin-service";
|
|
8501
|
+
transport: "stdio";
|
|
8502
|
+
image: string;
|
|
8503
|
+
engine: "auto" | "podman" | "docker";
|
|
8504
|
+
id: string;
|
|
8505
|
+
name: string;
|
|
8506
|
+
enabled: boolean;
|
|
8507
|
+
adapter: string;
|
|
8508
|
+
modelIds: string[];
|
|
8509
|
+
environmentRefs: Record<string, string>;
|
|
8510
|
+
command?: string | undefined;
|
|
8511
|
+
args?: string[] | undefined;
|
|
8512
|
+
defaultModelId?: string | undefined;
|
|
8513
|
+
}>>>;
|
|
8514
|
+
/**
|
|
8515
|
+
* 删除无会话引用的数据库智能体定义;不删除镜像或外部服务。
|
|
8516
|
+
* @param id - 数据库智能体 ID。
|
|
8517
|
+
* @param version - 可选的期望版本。
|
|
8518
|
+
* @returns 删除完成的 HaiResult;存在会话引用时返回 ACP_BUSY。
|
|
8519
|
+
* @example
|
|
8520
|
+
* ```ts
|
|
8521
|
+
* import { ai } from '@h-ai/ai'
|
|
8522
|
+
* // 前提:ai 已成功初始化。
|
|
8523
|
+
* // entry 为 get 成功返回的数据库条目。
|
|
8524
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8525
|
+
* const result = await ai.acp.agents.remove('coder', entry.version)
|
|
8526
|
+
* ```
|
|
8527
|
+
*/
|
|
8528
|
+
remove: (id: string, version?: string) => Promise<HaiResult<void>>;
|
|
8529
|
+
/**
|
|
8530
|
+
* 解析模型和原生配置,验证适配器是否兼容;不持久保存模型凭据。
|
|
8531
|
+
* @param id - 已登记智能体 ID。
|
|
8532
|
+
* @param modelId - 可选模型 ID,须在智能体 modelIds 中。
|
|
8533
|
+
* @returns 智能体模式与绑定模型摘要;不返回凭据或原生配置内容。
|
|
8534
|
+
* @example
|
|
8535
|
+
* ```ts
|
|
8536
|
+
* import { ai } from '@h-ai/ai'
|
|
8537
|
+
* // 前提:ai 已成功初始化。
|
|
8538
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8539
|
+
* const result = await ai.acp.agents.initialize('coder')
|
|
8540
|
+
* ```
|
|
8541
|
+
*/
|
|
8542
|
+
initialize: (id: string, modelId?: string) => Promise<{
|
|
8543
|
+
success: false;
|
|
8544
|
+
error: _h_ai_core.HaiError;
|
|
8545
|
+
} | {
|
|
8546
|
+
success: true;
|
|
8547
|
+
data: {
|
|
8548
|
+
agentId: string;
|
|
8549
|
+
mode: "custom-service";
|
|
8550
|
+
modelIds: never[];
|
|
8551
|
+
} | {
|
|
8552
|
+
agentId: string;
|
|
8553
|
+
mode: "embedded" | "builtin-service";
|
|
8554
|
+
modelIds: string[];
|
|
8555
|
+
};
|
|
8556
|
+
}>;
|
|
8557
|
+
/**
|
|
8558
|
+
* 实际启动并握手后关闭连接,返回智能体能力;托管模式需指定工作区。
|
|
8559
|
+
* @param id - 已登记智能体 ID。
|
|
8560
|
+
* @param options - 回调、能力及工作区;托管模式必须传 workspaceId。
|
|
8561
|
+
* @returns 原生初始化结果(智能体能力、认证方法等)的 HaiResult。
|
|
8562
|
+
* @example
|
|
8563
|
+
* ```ts
|
|
8564
|
+
* import { ai } from '@h-ai/ai'
|
|
8565
|
+
* // 前提:ai 已成功初始化。
|
|
8566
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8567
|
+
* const result = await ai.acp.agents.check('coder', { workspaceId: 'project' })
|
|
8568
|
+
* ```
|
|
8569
|
+
*/
|
|
8570
|
+
check: (id: string, options?: ACPClientOptions & {
|
|
8571
|
+
workspaceId?: string;
|
|
8572
|
+
}) => Promise<{
|
|
8573
|
+
success: false;
|
|
8574
|
+
error: _h_ai_core.HaiError;
|
|
8575
|
+
} | {
|
|
8576
|
+
success: true;
|
|
8577
|
+
data: _agentclientprotocol_sdk.InitializeResponse;
|
|
8578
|
+
}>;
|
|
8579
|
+
};
|
|
8580
|
+
workspaces: {
|
|
8581
|
+
/**
|
|
8582
|
+
* 新增数据库工作区并归一化存储位置;拒绝目录重叠或同一 volume 重复登记。
|
|
8583
|
+
* @param input - 工作区存储位置、显式 Git 主分支和环境变量引用。
|
|
8584
|
+
* @returns 带来源和版本的工作区条目;重叠位置返回冲突错误。
|
|
8585
|
+
* @example
|
|
8586
|
+
* ```ts
|
|
8587
|
+
* import { ai } from '@h-ai/ai'
|
|
8588
|
+
* // 前提:ai 已成功初始化。
|
|
8589
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8590
|
+
* const result = await ai.acp.workspaces.register({ id: 'project', storage: { type: 'directory', path: '/srv/project' } })
|
|
8591
|
+
* ```
|
|
8592
|
+
*/
|
|
8593
|
+
register: (input: z.input<typeof ACPWorkspaceSchema>) => Promise<HaiResult<AIResourceEntry<{
|
|
8594
|
+
id: string;
|
|
8595
|
+
storage: {
|
|
8596
|
+
type: "directory";
|
|
8597
|
+
path: string;
|
|
8598
|
+
} | {
|
|
8599
|
+
type: "volume";
|
|
8600
|
+
name: string;
|
|
8601
|
+
engine: "auto" | "podman" | "docker";
|
|
8602
|
+
image: string;
|
|
8603
|
+
};
|
|
8604
|
+
repositories: {
|
|
8605
|
+
id: string;
|
|
8606
|
+
url: string;
|
|
8607
|
+
mainBranch: string;
|
|
8608
|
+
remote: string;
|
|
8609
|
+
}[];
|
|
8610
|
+
environmentRefs: Record<string, string>;
|
|
8611
|
+
gitEnvironmentRefs: Record<string, string>;
|
|
8612
|
+
}>>>;
|
|
8613
|
+
/**
|
|
8614
|
+
* 读取工作区定义及来源;配置条目无数据库版本。
|
|
8615
|
+
* @param id - 工作区 ID。
|
|
8616
|
+
* @returns 工作区资源条目;未找到时返回资源不存在错误。
|
|
8617
|
+
* @example
|
|
8618
|
+
* ```ts
|
|
8619
|
+
* import { ai } from '@h-ai/ai'
|
|
8620
|
+
* // 前提:ai 已成功初始化。
|
|
8621
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8622
|
+
* const result = await ai.acp.workspaces.get('project')
|
|
8623
|
+
* ```
|
|
8624
|
+
*/
|
|
8625
|
+
get: (id: string) => Promise<HaiResult<AIResourceEntry<{
|
|
8626
|
+
id: string;
|
|
8627
|
+
storage: {
|
|
8628
|
+
type: "directory";
|
|
8629
|
+
path: string;
|
|
8630
|
+
} | {
|
|
8631
|
+
type: "volume";
|
|
8632
|
+
name: string;
|
|
8633
|
+
engine: "auto" | "podman" | "docker";
|
|
8634
|
+
image: string;
|
|
8635
|
+
};
|
|
8636
|
+
repositories: {
|
|
8637
|
+
id: string;
|
|
8638
|
+
url: string;
|
|
8639
|
+
mainBranch: string;
|
|
8640
|
+
remote: string;
|
|
8641
|
+
}[];
|
|
8642
|
+
environmentRefs: Record<string, string>;
|
|
8643
|
+
gitEnvironmentRefs: Record<string, string>;
|
|
8644
|
+
}>>>;
|
|
8645
|
+
/**
|
|
8646
|
+
* 列出配置与数据库合并后的工作区;不创建路径或克隆工程。
|
|
8647
|
+
* @returns 去重后的工作区列表;列表项不含数据库 version。
|
|
8648
|
+
* @example
|
|
8649
|
+
* ```ts
|
|
8650
|
+
* import { ai } from '@h-ai/ai'
|
|
8651
|
+
* // 前提:ai 已成功初始化。
|
|
8652
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8653
|
+
* const result = await ai.acp.workspaces.list()
|
|
8654
|
+
* ```
|
|
8655
|
+
*/
|
|
8656
|
+
list: () => Promise<HaiResult<AIResourceEntry<{
|
|
8657
|
+
id: string;
|
|
8658
|
+
storage: {
|
|
8659
|
+
type: "directory";
|
|
8660
|
+
path: string;
|
|
8661
|
+
} | {
|
|
8662
|
+
type: "volume";
|
|
8663
|
+
name: string;
|
|
8664
|
+
engine: "auto" | "podman" | "docker";
|
|
8665
|
+
image: string;
|
|
8666
|
+
};
|
|
8667
|
+
repositories: {
|
|
8668
|
+
id: string;
|
|
8669
|
+
url: string;
|
|
8670
|
+
mainBranch: string;
|
|
8671
|
+
remote: string;
|
|
8672
|
+
}[];
|
|
8673
|
+
environmentRefs: Record<string, string>;
|
|
8674
|
+
gitEnvironmentRefs: Record<string, string>;
|
|
8675
|
+
}>[]>>;
|
|
8676
|
+
/**
|
|
8677
|
+
* 整体替换无会话引用的数据库工作区,重新检查存储位置重叠;配置条目不可修改。
|
|
8678
|
+
* @param input - 包含原 ID 的完整替换定义。
|
|
8679
|
+
* @param version - 可选的数据库期望版本。
|
|
8680
|
+
* @returns 更新后的工作区;有会话引用、位置冲突或版本冲突时失败。
|
|
8681
|
+
* @example
|
|
8682
|
+
* ```ts
|
|
8683
|
+
* import { ai } from '@h-ai/ai'
|
|
8684
|
+
* // 前提:ai 已成功初始化。
|
|
8685
|
+
* // definition 为完整替换定义;entry 为 get 成功返回的条目。
|
|
8686
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8687
|
+
* const result = await ai.acp.workspaces.update(definition, entry.version)
|
|
8688
|
+
* ```
|
|
8689
|
+
*/
|
|
8690
|
+
update: (input: z.input<typeof ACPWorkspaceSchema>, version?: string) => Promise<HaiResult<AIResourceEntry<{
|
|
8691
|
+
id: string;
|
|
8692
|
+
storage: {
|
|
8693
|
+
type: "directory";
|
|
8694
|
+
path: string;
|
|
8695
|
+
} | {
|
|
8696
|
+
type: "volume";
|
|
8697
|
+
name: string;
|
|
8698
|
+
engine: "auto" | "podman" | "docker";
|
|
8699
|
+
image: string;
|
|
8700
|
+
};
|
|
8701
|
+
repositories: {
|
|
8702
|
+
id: string;
|
|
8703
|
+
url: string;
|
|
8704
|
+
mainBranch: string;
|
|
8705
|
+
remote: string;
|
|
8706
|
+
}[];
|
|
8707
|
+
environmentRefs: Record<string, string>;
|
|
8708
|
+
gitEnvironmentRefs: Record<string, string>;
|
|
8709
|
+
}>>>;
|
|
8710
|
+
/**
|
|
8711
|
+
* 创建目录并克隆缺失工程;已有内容不自动 pull 或覆盖,Git 不存在时返回明确错误。
|
|
8712
|
+
* @param id - 已登记工作区 ID。
|
|
8713
|
+
* @returns 准备后的 main 绝对目录;克隆失败保留现场供检查。
|
|
8714
|
+
* @example
|
|
8715
|
+
* ```ts
|
|
8716
|
+
* import { ai } from '@h-ai/ai'
|
|
8717
|
+
* // 前提:ai 已成功初始化。
|
|
8718
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8719
|
+
* const result = await ai.acp.workspaces.prepare('project')
|
|
8720
|
+
* ```
|
|
8721
|
+
*/
|
|
8722
|
+
prepare: (id: string) => Promise<{
|
|
8723
|
+
success: false;
|
|
8724
|
+
error: _h_ai_core.HaiError;
|
|
8725
|
+
} | {
|
|
8726
|
+
success: true;
|
|
8727
|
+
data: string;
|
|
8728
|
+
}>;
|
|
8729
|
+
/**
|
|
8730
|
+
* 将有限大小的文件写入 main/files,拒绝覆盖、路径逃逸和符号链接;失败前已写入文件会保留。
|
|
8731
|
+
* @param id - 已登记工作区 ID。
|
|
8732
|
+
* @param files - 相对路径和 UTF-8 文本或二进制;不允许覆盖或路径逃逸。
|
|
8733
|
+
* @returns 已导入相对路径列表;写入中途失败不回滚已有文件。
|
|
8734
|
+
* @example
|
|
8735
|
+
* ```ts
|
|
8736
|
+
* import { ai } from '@h-ai/ai'
|
|
8737
|
+
* // 前提:ai 已成功初始化。
|
|
8738
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8739
|
+
* const result = await ai.acp.workspaces.importFiles('project', [{ path: 'notes.txt', content: '需求' }])
|
|
8740
|
+
* ```
|
|
8741
|
+
*/
|
|
8742
|
+
importFiles: (id: string, files: Array<{
|
|
8743
|
+
path: string;
|
|
8744
|
+
content: string | Uint8Array;
|
|
8745
|
+
}>) => Promise<{
|
|
8746
|
+
success: false;
|
|
8747
|
+
error: _h_ai_core.HaiError;
|
|
8748
|
+
} | {
|
|
8749
|
+
success: true;
|
|
8750
|
+
data: {
|
|
8751
|
+
imported: string[];
|
|
8752
|
+
};
|
|
8753
|
+
}>;
|
|
8754
|
+
/**
|
|
8755
|
+
* 移除无会话引用的数据库定义,保留磁盘目录、Git 检出和 volume。
|
|
8756
|
+
* @param id - 数据库工作区 ID。
|
|
8757
|
+
* @param version - 可选的数据库期望版本。
|
|
8758
|
+
* @returns 删除定义的 HaiResult;引用存在时失败,文件始终保留。
|
|
8759
|
+
* @example
|
|
8760
|
+
* ```ts
|
|
8761
|
+
* import { ai } from '@h-ai/ai'
|
|
8762
|
+
* // 前提:ai 已成功初始化。
|
|
8763
|
+
* // entry 为 get 成功返回的数据库条目。
|
|
8764
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8765
|
+
* const result = await ai.acp.workspaces.remove('project', entry.version)
|
|
8766
|
+
* ```
|
|
8767
|
+
*/
|
|
8768
|
+
remove: (id: string, version?: string) => Promise<HaiResult<void>>;
|
|
8769
|
+
};
|
|
8770
|
+
sessions: {
|
|
8771
|
+
/**
|
|
8772
|
+
* 绑定模型、工作区和 MCP,准备目录后建立原生会话;newWorktree 可选择独立工程分支。
|
|
8773
|
+
* @param options - 智能体、工作区、可选会话仓库、模型、MCP 及可信回调;newWorktree 默认 false。
|
|
8774
|
+
* @returns 可用于 prompt/stream/publish 的会话句柄;启动失败保留失败记录。
|
|
8775
|
+
* @example
|
|
8776
|
+
* ```ts
|
|
8777
|
+
* import { ai } from '@h-ai/ai'
|
|
8778
|
+
* // 前提:ai 已成功初始化。
|
|
8779
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8780
|
+
* const result = await ai.acp.sessions.create({ agentId: 'coder', workspaceId: 'project', repositoryId: 'api', newWorktree: true })
|
|
8781
|
+
* ```
|
|
8782
|
+
*/
|
|
8783
|
+
create: (options: ACPCreateSessionOptions) => Promise<{
|
|
8784
|
+
success: false;
|
|
8785
|
+
error: _h_ai_core.HaiError;
|
|
8786
|
+
} | {
|
|
8787
|
+
success: true;
|
|
8788
|
+
data: {
|
|
8789
|
+
id: string;
|
|
8790
|
+
/**
|
|
8791
|
+
* 读取持久会话信息,包括状态、原生 ID 和当前容器。
|
|
8792
|
+
* @returns 包含 ACPSessionInfo 的 HaiResult;记录不存在时返回失败。
|
|
8793
|
+
* @example
|
|
8794
|
+
* ```ts
|
|
8795
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
8796
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8797
|
+
* const result = await session.info()
|
|
8798
|
+
* ```
|
|
8799
|
+
*/
|
|
8800
|
+
info: () => Promise<{
|
|
8801
|
+
success: false;
|
|
8802
|
+
error: _h_ai_core.HaiError;
|
|
8803
|
+
} | {
|
|
8804
|
+
success: true;
|
|
8805
|
+
data: ACPSessionInfo;
|
|
8806
|
+
}>;
|
|
8807
|
+
/**
|
|
8808
|
+
* 发送一轮内容,等待最终停止原因、最终消息文本和完整事件;同一会话不允许并发轮次。
|
|
8809
|
+
* @param content - 原生 ACP 内容块,不允许同一会话并发执行。
|
|
8810
|
+
* @param signal - 本轮取消信号;取消超时会关闭连接。
|
|
8811
|
+
* @returns 最终文本、停止原因和事件的 HaiResult。
|
|
8812
|
+
* @example
|
|
8813
|
+
* ```ts
|
|
8814
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
8815
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8816
|
+
* const result = await session.prompt([{ type: 'text', text: '检查工程' }])
|
|
8817
|
+
* ```
|
|
8818
|
+
*/
|
|
8819
|
+
prompt: (content: ContentBlock[], signal?: AbortSignal) => Promise<{
|
|
8820
|
+
success: false;
|
|
8821
|
+
error: _h_ai_core.HaiError;
|
|
8822
|
+
} | {
|
|
8823
|
+
success: true;
|
|
8824
|
+
data: {
|
|
8825
|
+
text: string;
|
|
8826
|
+
events: SessionNotification[];
|
|
8827
|
+
stopReason: _agentclientprotocol_sdk.StopReason;
|
|
8828
|
+
_meta?: {
|
|
8829
|
+
[key: string]: unknown;
|
|
8830
|
+
} | null;
|
|
8831
|
+
};
|
|
8832
|
+
}>;
|
|
8833
|
+
/**
|
|
8834
|
+
* 仅接受正常结束的一份 JSON(允许完整 JSON 代码围栏),再按 schema 校验;前后夹杂文本视为失败。
|
|
8835
|
+
* @param content - 要求返回结构化 JSON 的原生内容块。
|
|
8836
|
+
* @param schema - 最终 JSON 的 Zod 校验器。
|
|
8837
|
+
* @param signal - 可选的本轮取消信号。
|
|
8838
|
+
* @returns 经过 schema 校验的数据;输出不合法时返回 ACP_OUTPUT_INVALID。
|
|
8839
|
+
* @example
|
|
8840
|
+
* ```ts
|
|
8841
|
+
* import { z } from 'zod'
|
|
8842
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
8843
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8844
|
+
* const result = await session.promptStructured([{ type: 'text', text: '返回 JSON' }], z.object({ ok: z.boolean() }))
|
|
8845
|
+
* ```
|
|
8846
|
+
*/
|
|
8847
|
+
promptStructured: <T>(content: ContentBlock[], schema: z.ZodType<T>, signal?: AbortSignal) => Promise<{
|
|
8848
|
+
success: false;
|
|
8849
|
+
error: _h_ai_core.HaiError;
|
|
8850
|
+
} | {
|
|
8851
|
+
success: true;
|
|
8852
|
+
data: Awaited<T>;
|
|
8853
|
+
}>;
|
|
8854
|
+
/**
|
|
8855
|
+
* 迭代本轮 ACP 事件;中途退出迭代会取消本轮,失败会抛错,调用方需 try/finally 清理。
|
|
8856
|
+
* @param content - 本轮原生内容块。
|
|
8857
|
+
* @param signal - 可选取消信号;结束迭代同样会取消本轮。
|
|
8858
|
+
* @returns 异步事件迭代器;流式失败抛出异常,需在调用方捕获。
|
|
8859
|
+
* @throws 连接关闭、取消超时、输出超限或原生请求失败。
|
|
8860
|
+
* @example
|
|
8861
|
+
* ```ts
|
|
8862
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
8863
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8864
|
+
* for await (const event of session.stream([{ type: 'text', text: '检查工程' }])) { const update = event.update }
|
|
8865
|
+
* ```
|
|
8866
|
+
*/
|
|
8867
|
+
stream(content: ContentBlock[], signal?: AbortSignal): AsyncGenerator<SessionNotification>;
|
|
8868
|
+
/**
|
|
8869
|
+
* 请求取消正在执行的一轮;超时未停止时关闭所拥有的传输。
|
|
8870
|
+
* @returns 取消完成的 HaiResult;超时或清理失败返回错误。
|
|
8871
|
+
* @example
|
|
8872
|
+
* ```ts
|
|
8873
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
8874
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8875
|
+
* const result = await session.cancel()
|
|
8876
|
+
* ```
|
|
8877
|
+
*/
|
|
8878
|
+
cancel: () => Promise<{
|
|
8879
|
+
success: false;
|
|
8880
|
+
error: _h_ai_core.HaiError;
|
|
8881
|
+
} | {
|
|
8882
|
+
success: true;
|
|
8883
|
+
data: void;
|
|
8884
|
+
}>;
|
|
8885
|
+
/**
|
|
8886
|
+
* 选择智能体公布的原生模式 ID;不兼容时返回协议失败。
|
|
8887
|
+
* @param mode - 握手或事件中公布的原生模式 ID。
|
|
8888
|
+
* @returns 原生模式设置结果的 HaiResult。
|
|
8889
|
+
* @example
|
|
8890
|
+
* ```ts
|
|
8891
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
8892
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8893
|
+
* const result = await session.setMode('code')
|
|
8894
|
+
* ```
|
|
8895
|
+
*/
|
|
8896
|
+
setMode: (mode: string) => Promise<{
|
|
8897
|
+
success: false;
|
|
8898
|
+
error: _h_ai_core.HaiError;
|
|
8899
|
+
} | {
|
|
8900
|
+
success: true;
|
|
8901
|
+
data: _agentclientprotocol_sdk.SetSessionModeResponse;
|
|
8902
|
+
}>;
|
|
8903
|
+
/**
|
|
8904
|
+
* 设置智能体公布的原生配置选项;值必须符合该智能体的选项定义。
|
|
8905
|
+
* @param key - 原生配置选项 ID。
|
|
8906
|
+
* @param value - 该选项允许的值。
|
|
8907
|
+
* @returns 原生配置更新结果的 HaiResult。
|
|
8908
|
+
* @example
|
|
8909
|
+
* ```ts
|
|
8910
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
8911
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8912
|
+
* const result = await session.setConfigOption('model', 'coding')
|
|
8913
|
+
* ```
|
|
8914
|
+
*/
|
|
8915
|
+
setConfigOption: (key: string, value: string) => Promise<{
|
|
8916
|
+
success: false;
|
|
8917
|
+
error: _h_ai_core.HaiError;
|
|
8918
|
+
} | {
|
|
8919
|
+
success: true;
|
|
8920
|
+
data: _agentclientprotocol_sdk.SetSessionConfigOptionResponse;
|
|
8921
|
+
}>;
|
|
8922
|
+
/**
|
|
8923
|
+
* 先关闭会话执行环境,再 fetch 并仅快进各工程明确配置的主分支;不修改会话分支。
|
|
8924
|
+
* @returns 各仓更新报告;部分失败时报告位于 error.cause.reports。
|
|
8925
|
+
* @example
|
|
8926
|
+
* ```ts
|
|
8927
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
8928
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8929
|
+
* const result = await session.updateMain()
|
|
8930
|
+
* ```
|
|
8931
|
+
*/
|
|
8932
|
+
updateMain: () => Promise<{
|
|
8933
|
+
success: false;
|
|
8934
|
+
error: _h_ai_core.HaiError;
|
|
8935
|
+
} | {
|
|
8936
|
+
success: true;
|
|
8937
|
+
data: ACPGitReport[];
|
|
8938
|
+
}>;
|
|
8939
|
+
/**
|
|
8940
|
+
* 关闭执行环境后逐仓提交并推送;仅支持受管理的独立会话,部分失败保留各仓报告,禁止强推。
|
|
8941
|
+
* @param request - 发布模式、提交说明和作者;仅支持受管理的独立会话。
|
|
8942
|
+
* @returns 各仓提交/推送报告;部分失败时报告位于 error.cause.reports。
|
|
8943
|
+
* @example
|
|
8944
|
+
* ```ts
|
|
8945
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
8946
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8947
|
+
* const result = await session.publish({ mode: 'merge-main', message: '完成任务', author: { name: 'Developer', email: 'dev@example.com' } })
|
|
8948
|
+
* ```
|
|
8949
|
+
*/
|
|
8950
|
+
publish: (request: z.input<typeof ACPPublishSchema>) => Promise<{
|
|
8951
|
+
success: false;
|
|
8952
|
+
error: _h_ai_core.HaiError;
|
|
8953
|
+
} | {
|
|
8954
|
+
success: true;
|
|
8955
|
+
data: ACPGitReport[];
|
|
8956
|
+
}>;
|
|
8957
|
+
/**
|
|
8958
|
+
* 停止拥有的进程或容器,释放占用;保留工作目录和原生状态,供后续显式恢复。
|
|
8959
|
+
* @returns 关闭完成的 HaiResult;清理失败时不释放仍在占用的资源。
|
|
8960
|
+
* @example
|
|
8961
|
+
* ```ts
|
|
8962
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
8963
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8964
|
+
* const result = await session.close()
|
|
8965
|
+
* ```
|
|
8966
|
+
*/
|
|
8967
|
+
close: () => Promise<{
|
|
8968
|
+
success: false;
|
|
8969
|
+
error: _h_ai_core.HaiError;
|
|
8970
|
+
} | {
|
|
8971
|
+
success: true;
|
|
8972
|
+
data: void;
|
|
8973
|
+
}>;
|
|
8974
|
+
};
|
|
8975
|
+
}>;
|
|
8976
|
+
/**
|
|
8977
|
+
* 获取持久会话的管理句柄;已关闭会话需要 resume 后才能执行 prompt。
|
|
8978
|
+
* @param id - 框架会话 ID,不是智能体原生 ID。
|
|
8979
|
+
* @returns 管理句柄的 HaiResult;不会自动重新启动智能体。
|
|
8980
|
+
* @example
|
|
8981
|
+
* ```ts
|
|
8982
|
+
* import { ai } from '@h-ai/ai'
|
|
8983
|
+
* // 前提:ai 已成功初始化。
|
|
8984
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
8985
|
+
* const result = await ai.acp.sessions.get('task-1')
|
|
8986
|
+
* ```
|
|
8987
|
+
*/
|
|
8988
|
+
get: (id: string) => Promise<{
|
|
8989
|
+
success: false;
|
|
8990
|
+
error: _h_ai_core.HaiError;
|
|
8991
|
+
} | {
|
|
8992
|
+
success: true;
|
|
8993
|
+
data: {
|
|
8994
|
+
id: string;
|
|
8995
|
+
/**
|
|
8996
|
+
* 读取持久会话信息,包括状态、原生 ID 和当前容器。
|
|
8997
|
+
* @returns 包含 ACPSessionInfo 的 HaiResult;记录不存在时返回失败。
|
|
8998
|
+
* @example
|
|
8999
|
+
* ```ts
|
|
9000
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
9001
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9002
|
+
* const result = await session.info()
|
|
9003
|
+
* ```
|
|
9004
|
+
*/
|
|
9005
|
+
info: () => Promise<{
|
|
9006
|
+
success: false;
|
|
9007
|
+
error: _h_ai_core.HaiError;
|
|
9008
|
+
} | {
|
|
9009
|
+
success: true;
|
|
9010
|
+
data: ACPSessionInfo;
|
|
9011
|
+
}>;
|
|
9012
|
+
/**
|
|
9013
|
+
* 发送一轮内容,等待最终停止原因、最终消息文本和完整事件;同一会话不允许并发轮次。
|
|
9014
|
+
* @param content - 原生 ACP 内容块,不允许同一会话并发执行。
|
|
9015
|
+
* @param signal - 本轮取消信号;取消超时会关闭连接。
|
|
9016
|
+
* @returns 最终文本、停止原因和事件的 HaiResult。
|
|
9017
|
+
* @example
|
|
9018
|
+
* ```ts
|
|
9019
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
9020
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9021
|
+
* const result = await session.prompt([{ type: 'text', text: '检查工程' }])
|
|
9022
|
+
* ```
|
|
9023
|
+
*/
|
|
9024
|
+
prompt: (content: ContentBlock[], signal?: AbortSignal) => Promise<{
|
|
9025
|
+
success: false;
|
|
9026
|
+
error: _h_ai_core.HaiError;
|
|
9027
|
+
} | {
|
|
9028
|
+
success: true;
|
|
9029
|
+
data: {
|
|
9030
|
+
text: string;
|
|
9031
|
+
events: SessionNotification[];
|
|
9032
|
+
stopReason: _agentclientprotocol_sdk.StopReason;
|
|
9033
|
+
_meta?: {
|
|
9034
|
+
[key: string]: unknown;
|
|
9035
|
+
} | null;
|
|
9036
|
+
};
|
|
9037
|
+
}>;
|
|
9038
|
+
/**
|
|
9039
|
+
* 仅接受正常结束的一份 JSON(允许完整 JSON 代码围栏),再按 schema 校验;前后夹杂文本视为失败。
|
|
9040
|
+
* @param content - 要求返回结构化 JSON 的原生内容块。
|
|
9041
|
+
* @param schema - 最终 JSON 的 Zod 校验器。
|
|
9042
|
+
* @param signal - 可选的本轮取消信号。
|
|
9043
|
+
* @returns 经过 schema 校验的数据;输出不合法时返回 ACP_OUTPUT_INVALID。
|
|
9044
|
+
* @example
|
|
9045
|
+
* ```ts
|
|
9046
|
+
* import { z } from 'zod'
|
|
9047
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
9048
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9049
|
+
* const result = await session.promptStructured([{ type: 'text', text: '返回 JSON' }], z.object({ ok: z.boolean() }))
|
|
9050
|
+
* ```
|
|
9051
|
+
*/
|
|
9052
|
+
promptStructured: <T>(content: ContentBlock[], schema: z.ZodType<T>, signal?: AbortSignal) => Promise<{
|
|
9053
|
+
success: false;
|
|
9054
|
+
error: _h_ai_core.HaiError;
|
|
9055
|
+
} | {
|
|
9056
|
+
success: true;
|
|
9057
|
+
data: Awaited<T>;
|
|
9058
|
+
}>;
|
|
9059
|
+
/**
|
|
9060
|
+
* 迭代本轮 ACP 事件;中途退出迭代会取消本轮,失败会抛错,调用方需 try/finally 清理。
|
|
9061
|
+
* @param content - 本轮原生内容块。
|
|
9062
|
+
* @param signal - 可选取消信号;结束迭代同样会取消本轮。
|
|
9063
|
+
* @returns 异步事件迭代器;流式失败抛出异常,需在调用方捕获。
|
|
9064
|
+
* @throws 连接关闭、取消超时、输出超限或原生请求失败。
|
|
9065
|
+
* @example
|
|
9066
|
+
* ```ts
|
|
9067
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
9068
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9069
|
+
* for await (const event of session.stream([{ type: 'text', text: '检查工程' }])) { const update = event.update }
|
|
9070
|
+
* ```
|
|
9071
|
+
*/
|
|
9072
|
+
stream(content: ContentBlock[], signal?: AbortSignal): AsyncGenerator<SessionNotification>;
|
|
9073
|
+
/**
|
|
9074
|
+
* 请求取消正在执行的一轮;超时未停止时关闭所拥有的传输。
|
|
9075
|
+
* @returns 取消完成的 HaiResult;超时或清理失败返回错误。
|
|
9076
|
+
* @example
|
|
9077
|
+
* ```ts
|
|
9078
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
9079
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9080
|
+
* const result = await session.cancel()
|
|
9081
|
+
* ```
|
|
9082
|
+
*/
|
|
9083
|
+
cancel: () => Promise<{
|
|
9084
|
+
success: false;
|
|
9085
|
+
error: _h_ai_core.HaiError;
|
|
9086
|
+
} | {
|
|
9087
|
+
success: true;
|
|
9088
|
+
data: void;
|
|
9089
|
+
}>;
|
|
9090
|
+
/**
|
|
9091
|
+
* 选择智能体公布的原生模式 ID;不兼容时返回协议失败。
|
|
9092
|
+
* @param mode - 握手或事件中公布的原生模式 ID。
|
|
9093
|
+
* @returns 原生模式设置结果的 HaiResult。
|
|
9094
|
+
* @example
|
|
9095
|
+
* ```ts
|
|
9096
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
9097
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9098
|
+
* const result = await session.setMode('code')
|
|
9099
|
+
* ```
|
|
9100
|
+
*/
|
|
9101
|
+
setMode: (mode: string) => Promise<{
|
|
9102
|
+
success: false;
|
|
9103
|
+
error: _h_ai_core.HaiError;
|
|
9104
|
+
} | {
|
|
9105
|
+
success: true;
|
|
9106
|
+
data: _agentclientprotocol_sdk.SetSessionModeResponse;
|
|
9107
|
+
}>;
|
|
9108
|
+
/**
|
|
9109
|
+
* 设置智能体公布的原生配置选项;值必须符合该智能体的选项定义。
|
|
9110
|
+
* @param key - 原生配置选项 ID。
|
|
9111
|
+
* @param value - 该选项允许的值。
|
|
9112
|
+
* @returns 原生配置更新结果的 HaiResult。
|
|
9113
|
+
* @example
|
|
9114
|
+
* ```ts
|
|
9115
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
9116
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9117
|
+
* const result = await session.setConfigOption('model', 'coding')
|
|
9118
|
+
* ```
|
|
9119
|
+
*/
|
|
9120
|
+
setConfigOption: (key: string, value: string) => Promise<{
|
|
9121
|
+
success: false;
|
|
9122
|
+
error: _h_ai_core.HaiError;
|
|
9123
|
+
} | {
|
|
9124
|
+
success: true;
|
|
9125
|
+
data: _agentclientprotocol_sdk.SetSessionConfigOptionResponse;
|
|
9126
|
+
}>;
|
|
9127
|
+
/**
|
|
9128
|
+
* 先关闭会话执行环境,再 fetch 并仅快进各工程明确配置的主分支;不修改会话分支。
|
|
9129
|
+
* @returns 各仓更新报告;部分失败时报告位于 error.cause.reports。
|
|
9130
|
+
* @example
|
|
9131
|
+
* ```ts
|
|
9132
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
9133
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9134
|
+
* const result = await session.updateMain()
|
|
9135
|
+
* ```
|
|
9136
|
+
*/
|
|
9137
|
+
updateMain: () => Promise<{
|
|
9138
|
+
success: false;
|
|
9139
|
+
error: _h_ai_core.HaiError;
|
|
9140
|
+
} | {
|
|
9141
|
+
success: true;
|
|
9142
|
+
data: ACPGitReport[];
|
|
9143
|
+
}>;
|
|
9144
|
+
/**
|
|
9145
|
+
* 关闭执行环境后逐仓提交并推送;仅支持受管理的独立会话,部分失败保留各仓报告,禁止强推。
|
|
9146
|
+
* @param request - 发布模式、提交说明和作者;仅支持受管理的独立会话。
|
|
9147
|
+
* @returns 各仓提交/推送报告;部分失败时报告位于 error.cause.reports。
|
|
9148
|
+
* @example
|
|
9149
|
+
* ```ts
|
|
9150
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
9151
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9152
|
+
* const result = await session.publish({ mode: 'merge-main', message: '完成任务', author: { name: 'Developer', email: 'dev@example.com' } })
|
|
9153
|
+
* ```
|
|
9154
|
+
*/
|
|
9155
|
+
publish: (request: z.input<typeof ACPPublishSchema>) => Promise<{
|
|
9156
|
+
success: false;
|
|
9157
|
+
error: _h_ai_core.HaiError;
|
|
9158
|
+
} | {
|
|
9159
|
+
success: true;
|
|
9160
|
+
data: ACPGitReport[];
|
|
9161
|
+
}>;
|
|
9162
|
+
/**
|
|
9163
|
+
* 停止拥有的进程或容器,释放占用;保留工作目录和原生状态,供后续显式恢复。
|
|
9164
|
+
* @returns 关闭完成的 HaiResult;清理失败时不释放仍在占用的资源。
|
|
9165
|
+
* @example
|
|
9166
|
+
* ```ts
|
|
9167
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
9168
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9169
|
+
* const result = await session.close()
|
|
9170
|
+
* ```
|
|
9171
|
+
*/
|
|
9172
|
+
close: () => Promise<{
|
|
9173
|
+
success: false;
|
|
9174
|
+
error: _h_ai_core.HaiError;
|
|
9175
|
+
} | {
|
|
9176
|
+
success: true;
|
|
9177
|
+
data: void;
|
|
9178
|
+
}>;
|
|
9179
|
+
};
|
|
9180
|
+
}>;
|
|
9181
|
+
/**
|
|
9182
|
+
* 列出持久会话,可按工作区 ID 过滤。
|
|
9183
|
+
* @param workspaceId - 可选工作区筛选条件;省略返回全部会话。
|
|
9184
|
+
* @returns 持久 ACPSessionInfo 列表的 HaiResult。
|
|
9185
|
+
* @example
|
|
9186
|
+
* ```ts
|
|
9187
|
+
* import { ai } from '@h-ai/ai'
|
|
9188
|
+
* // 前提:ai 已成功初始化。
|
|
9189
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9190
|
+
* const result = await ai.acp.sessions.list('project')
|
|
9191
|
+
* ```
|
|
9192
|
+
*/
|
|
9193
|
+
list: (workspaceId?: string) => Promise<{
|
|
9194
|
+
success: false;
|
|
9195
|
+
error: _h_ai_core.HaiError;
|
|
9196
|
+
} | {
|
|
9197
|
+
success: true;
|
|
9198
|
+
data: ACPSessionInfo[];
|
|
9199
|
+
}>;
|
|
9200
|
+
/**
|
|
9201
|
+
* 使用原生会话 ID 和保留状态恢复;智能体定义或模型能力已改变时拒绝恢复。
|
|
9202
|
+
* @param id - 已关闭或失败的框架会话 ID。
|
|
9203
|
+
* @param options - 本次连接的回调、能力和取消信号,不从数据库恢复回调。
|
|
9204
|
+
* @returns 恢复后的会话句柄;原生服务不支持恢复或配置变化时失败。
|
|
9205
|
+
* @example
|
|
9206
|
+
* ```ts
|
|
9207
|
+
* import { ai } from '@h-ai/ai'
|
|
9208
|
+
* // 前提:ai 已成功初始化。
|
|
9209
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9210
|
+
* const result = await ai.acp.sessions.resume('task-1')
|
|
9211
|
+
* ```
|
|
9212
|
+
*/
|
|
9213
|
+
resume: (id: string, options?: ACPClientOptions) => Promise<{
|
|
9214
|
+
success: false;
|
|
9215
|
+
error: _h_ai_core.HaiError;
|
|
9216
|
+
} | {
|
|
9217
|
+
success: true;
|
|
9218
|
+
data: {
|
|
9219
|
+
id: string;
|
|
9220
|
+
/**
|
|
9221
|
+
* 读取持久会话信息,包括状态、原生 ID 和当前容器。
|
|
9222
|
+
* @returns 包含 ACPSessionInfo 的 HaiResult;记录不存在时返回失败。
|
|
9223
|
+
* @example
|
|
9224
|
+
* ```ts
|
|
9225
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
9226
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9227
|
+
* const result = await session.info()
|
|
9228
|
+
* ```
|
|
9229
|
+
*/
|
|
9230
|
+
info: () => Promise<{
|
|
9231
|
+
success: false;
|
|
9232
|
+
error: _h_ai_core.HaiError;
|
|
9233
|
+
} | {
|
|
9234
|
+
success: true;
|
|
9235
|
+
data: ACPSessionInfo;
|
|
9236
|
+
}>;
|
|
9237
|
+
/**
|
|
9238
|
+
* 发送一轮内容,等待最终停止原因、最终消息文本和完整事件;同一会话不允许并发轮次。
|
|
9239
|
+
* @param content - 原生 ACP 内容块,不允许同一会话并发执行。
|
|
9240
|
+
* @param signal - 本轮取消信号;取消超时会关闭连接。
|
|
9241
|
+
* @returns 最终文本、停止原因和事件的 HaiResult。
|
|
9242
|
+
* @example
|
|
9243
|
+
* ```ts
|
|
9244
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
9245
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9246
|
+
* const result = await session.prompt([{ type: 'text', text: '检查工程' }])
|
|
9247
|
+
* ```
|
|
9248
|
+
*/
|
|
9249
|
+
prompt: (content: ContentBlock[], signal?: AbortSignal) => Promise<{
|
|
9250
|
+
success: false;
|
|
9251
|
+
error: _h_ai_core.HaiError;
|
|
9252
|
+
} | {
|
|
9253
|
+
success: true;
|
|
9254
|
+
data: {
|
|
9255
|
+
text: string;
|
|
9256
|
+
events: SessionNotification[];
|
|
9257
|
+
stopReason: _agentclientprotocol_sdk.StopReason;
|
|
9258
|
+
_meta?: {
|
|
9259
|
+
[key: string]: unknown;
|
|
9260
|
+
} | null;
|
|
9261
|
+
};
|
|
9262
|
+
}>;
|
|
9263
|
+
/**
|
|
9264
|
+
* 仅接受正常结束的一份 JSON(允许完整 JSON 代码围栏),再按 schema 校验;前后夹杂文本视为失败。
|
|
9265
|
+
* @param content - 要求返回结构化 JSON 的原生内容块。
|
|
9266
|
+
* @param schema - 最终 JSON 的 Zod 校验器。
|
|
9267
|
+
* @param signal - 可选的本轮取消信号。
|
|
9268
|
+
* @returns 经过 schema 校验的数据;输出不合法时返回 ACP_OUTPUT_INVALID。
|
|
9269
|
+
* @example
|
|
9270
|
+
* ```ts
|
|
9271
|
+
* import { z } from 'zod'
|
|
9272
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
9273
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9274
|
+
* const result = await session.promptStructured([{ type: 'text', text: '返回 JSON' }], z.object({ ok: z.boolean() }))
|
|
9275
|
+
* ```
|
|
9276
|
+
*/
|
|
9277
|
+
promptStructured: <T>(content: ContentBlock[], schema: z.ZodType<T>, signal?: AbortSignal) => Promise<{
|
|
9278
|
+
success: false;
|
|
9279
|
+
error: _h_ai_core.HaiError;
|
|
9280
|
+
} | {
|
|
9281
|
+
success: true;
|
|
9282
|
+
data: Awaited<T>;
|
|
9283
|
+
}>;
|
|
9284
|
+
/**
|
|
9285
|
+
* 迭代本轮 ACP 事件;中途退出迭代会取消本轮,失败会抛错,调用方需 try/finally 清理。
|
|
9286
|
+
* @param content - 本轮原生内容块。
|
|
9287
|
+
* @param signal - 可选取消信号;结束迭代同样会取消本轮。
|
|
9288
|
+
* @returns 异步事件迭代器;流式失败抛出异常,需在调用方捕获。
|
|
9289
|
+
* @throws 连接关闭、取消超时、输出超限或原生请求失败。
|
|
9290
|
+
* @example
|
|
9291
|
+
* ```ts
|
|
9292
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
9293
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9294
|
+
* for await (const event of session.stream([{ type: 'text', text: '检查工程' }])) { const update = event.update }
|
|
9295
|
+
* ```
|
|
9296
|
+
*/
|
|
9297
|
+
stream(content: ContentBlock[], signal?: AbortSignal): AsyncGenerator<SessionNotification>;
|
|
9298
|
+
/**
|
|
9299
|
+
* 请求取消正在执行的一轮;超时未停止时关闭所拥有的传输。
|
|
9300
|
+
* @returns 取消完成的 HaiResult;超时或清理失败返回错误。
|
|
9301
|
+
* @example
|
|
9302
|
+
* ```ts
|
|
9303
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
9304
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9305
|
+
* const result = await session.cancel()
|
|
9306
|
+
* ```
|
|
9307
|
+
*/
|
|
9308
|
+
cancel: () => Promise<{
|
|
9309
|
+
success: false;
|
|
9310
|
+
error: _h_ai_core.HaiError;
|
|
9311
|
+
} | {
|
|
9312
|
+
success: true;
|
|
9313
|
+
data: void;
|
|
9314
|
+
}>;
|
|
9315
|
+
/**
|
|
9316
|
+
* 选择智能体公布的原生模式 ID;不兼容时返回协议失败。
|
|
9317
|
+
* @param mode - 握手或事件中公布的原生模式 ID。
|
|
9318
|
+
* @returns 原生模式设置结果的 HaiResult。
|
|
9319
|
+
* @example
|
|
9320
|
+
* ```ts
|
|
9321
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
9322
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9323
|
+
* const result = await session.setMode('code')
|
|
9324
|
+
* ```
|
|
9325
|
+
*/
|
|
9326
|
+
setMode: (mode: string) => Promise<{
|
|
9327
|
+
success: false;
|
|
9328
|
+
error: _h_ai_core.HaiError;
|
|
9329
|
+
} | {
|
|
9330
|
+
success: true;
|
|
9331
|
+
data: _agentclientprotocol_sdk.SetSessionModeResponse;
|
|
9332
|
+
}>;
|
|
9333
|
+
/**
|
|
9334
|
+
* 设置智能体公布的原生配置选项;值必须符合该智能体的选项定义。
|
|
9335
|
+
* @param key - 原生配置选项 ID。
|
|
9336
|
+
* @param value - 该选项允许的值。
|
|
9337
|
+
* @returns 原生配置更新结果的 HaiResult。
|
|
9338
|
+
* @example
|
|
9339
|
+
* ```ts
|
|
9340
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
9341
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9342
|
+
* const result = await session.setConfigOption('model', 'coding')
|
|
9343
|
+
* ```
|
|
9344
|
+
*/
|
|
9345
|
+
setConfigOption: (key: string, value: string) => Promise<{
|
|
9346
|
+
success: false;
|
|
9347
|
+
error: _h_ai_core.HaiError;
|
|
9348
|
+
} | {
|
|
9349
|
+
success: true;
|
|
9350
|
+
data: _agentclientprotocol_sdk.SetSessionConfigOptionResponse;
|
|
9351
|
+
}>;
|
|
9352
|
+
/**
|
|
9353
|
+
* 先关闭会话执行环境,再 fetch 并仅快进各工程明确配置的主分支;不修改会话分支。
|
|
9354
|
+
* @returns 各仓更新报告;部分失败时报告位于 error.cause.reports。
|
|
9355
|
+
* @example
|
|
9356
|
+
* ```ts
|
|
9357
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
9358
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9359
|
+
* const result = await session.updateMain()
|
|
9360
|
+
* ```
|
|
9361
|
+
*/
|
|
9362
|
+
updateMain: () => Promise<{
|
|
9363
|
+
success: false;
|
|
9364
|
+
error: _h_ai_core.HaiError;
|
|
9365
|
+
} | {
|
|
9366
|
+
success: true;
|
|
9367
|
+
data: ACPGitReport[];
|
|
9368
|
+
}>;
|
|
9369
|
+
/**
|
|
9370
|
+
* 关闭执行环境后逐仓提交并推送;仅支持受管理的独立会话,部分失败保留各仓报告,禁止强推。
|
|
9371
|
+
* @param request - 发布模式、提交说明和作者;仅支持受管理的独立会话。
|
|
9372
|
+
* @returns 各仓提交/推送报告;部分失败时报告位于 error.cause.reports。
|
|
9373
|
+
* @example
|
|
9374
|
+
* ```ts
|
|
9375
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
9376
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9377
|
+
* const result = await session.publish({ mode: 'merge-main', message: '完成任务', author: { name: 'Developer', email: 'dev@example.com' } })
|
|
9378
|
+
* ```
|
|
9379
|
+
*/
|
|
9380
|
+
publish: (request: z.input<typeof ACPPublishSchema>) => Promise<{
|
|
9381
|
+
success: false;
|
|
9382
|
+
error: _h_ai_core.HaiError;
|
|
9383
|
+
} | {
|
|
9384
|
+
success: true;
|
|
9385
|
+
data: ACPGitReport[];
|
|
9386
|
+
}>;
|
|
9387
|
+
/**
|
|
9388
|
+
* 停止拥有的进程或容器,释放占用;保留工作目录和原生状态,供后续显式恢复。
|
|
9389
|
+
* @returns 关闭完成的 HaiResult;清理失败时不释放仍在占用的资源。
|
|
9390
|
+
* @example
|
|
9391
|
+
* ```ts
|
|
9392
|
+
* // session 为 sessions.create/get/resume 成功返回的 data。
|
|
9393
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9394
|
+
* const result = await session.close()
|
|
9395
|
+
* ```
|
|
9396
|
+
*/
|
|
9397
|
+
close: () => Promise<{
|
|
9398
|
+
success: false;
|
|
9399
|
+
error: _h_ai_core.HaiError;
|
|
9400
|
+
} | {
|
|
9401
|
+
success: true;
|
|
9402
|
+
data: void;
|
|
9403
|
+
}>;
|
|
9404
|
+
};
|
|
9405
|
+
}>;
|
|
9406
|
+
/**
|
|
9407
|
+
* 关闭本进程拥有的会话并释放锁,不删除历史和工程内容。
|
|
9408
|
+
* @param id - 框架会话 ID。
|
|
9409
|
+
* @returns 关闭完成的 HaiResult;不允许关闭其他进程拥有的执行环境。
|
|
9410
|
+
* @example
|
|
9411
|
+
* ```ts
|
|
9412
|
+
* import { ai } from '@h-ai/ai'
|
|
9413
|
+
* // 前提:ai 已成功初始化。
|
|
9414
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9415
|
+
* const result = await ai.acp.sessions.close('task-1')
|
|
9416
|
+
* ```
|
|
9417
|
+
*/
|
|
9418
|
+
close: (id: string) => Promise<{
|
|
9419
|
+
success: false;
|
|
9420
|
+
error: _h_ai_core.HaiError;
|
|
9421
|
+
} | {
|
|
9422
|
+
success: true;
|
|
9423
|
+
data: void;
|
|
9424
|
+
}>;
|
|
9425
|
+
/**
|
|
9426
|
+
* 回收停止后由框架登记的干净工作树;调用方须先停止独立预览。
|
|
9427
|
+
* @param id - 框架会话 ID;仅支持记录了归属的独立 Git 会话。
|
|
9428
|
+
* @returns 回收完成的 HaiResult;可重试,保留分支、普通文件及原生历史。
|
|
9429
|
+
* @example
|
|
9430
|
+
* ```ts
|
|
9431
|
+
* import { ai } from '@h-ai/ai'
|
|
9432
|
+
* // 前提:已关闭 Agent,已停止预览并提交或另存修改。
|
|
9433
|
+
* const result = await ai.acp.sessions.reclaimWorktree('task-1')
|
|
9434
|
+
* if (!result.success) throw new Error(result.error.message)
|
|
9435
|
+
* ```
|
|
9436
|
+
*/
|
|
9437
|
+
reclaimWorktree: (id: string) => Promise<{
|
|
9438
|
+
success: false;
|
|
9439
|
+
error: _h_ai_core.HaiError;
|
|
9440
|
+
} | {
|
|
9441
|
+
success: true;
|
|
9442
|
+
data: void;
|
|
9443
|
+
}>;
|
|
9444
|
+
/**
|
|
9445
|
+
* 仅删除已关闭或失败的会话记录;不删除工作树及原生文件,不替代 Git worktree 清理。
|
|
9446
|
+
* @param id - 框架会话 ID。
|
|
9447
|
+
* @returns 删除完成的 HaiResult;活动会话返回忙碌错误。
|
|
9448
|
+
* @example
|
|
9449
|
+
* ```ts
|
|
9450
|
+
* import { ai } from '@h-ai/ai'
|
|
9451
|
+
* // 前提:ai 已成功初始化。
|
|
9452
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9453
|
+
* const result = await ai.acp.sessions.remove('task-1')
|
|
9454
|
+
* ```
|
|
9455
|
+
*/
|
|
9456
|
+
remove: (id: string) => Promise<{
|
|
9457
|
+
success: false;
|
|
9458
|
+
error: _h_ai_core.HaiError;
|
|
9459
|
+
} | {
|
|
9460
|
+
success: true;
|
|
9461
|
+
data: void;
|
|
9462
|
+
}>;
|
|
9463
|
+
};
|
|
9464
|
+
/**
|
|
9465
|
+
* 连接原生 stdio/HTTP/WS 服务;不创建工作区或提供传输兼容桥。
|
|
9466
|
+
* @param transport - 智能体实际支持的原生传输与命令或地址。
|
|
9467
|
+
* @param options - 可信回调、声明能力和初始化取消信号。
|
|
9468
|
+
* @returns 低层连接句柄的 HaiResult;连接失败不自动转换传输。
|
|
9469
|
+
* @example
|
|
9470
|
+
* ```ts
|
|
9471
|
+
* import { ai } from '@h-ai/ai'
|
|
9472
|
+
* // 前提:ai 已成功初始化。
|
|
9473
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9474
|
+
* const result = await ai.acp.connect({ type: 'http', url: 'https://agent.example.com/acp' })
|
|
9475
|
+
* ```
|
|
9476
|
+
*/
|
|
9477
|
+
connect: (transport: ACPTransport, options?: ACPClientOptions) => Promise<{
|
|
9478
|
+
success: false;
|
|
9479
|
+
error: _h_ai_core.HaiError;
|
|
9480
|
+
} | {
|
|
9481
|
+
success: true;
|
|
9482
|
+
data: {
|
|
9483
|
+
info: _agentclientprotocol_sdk.InitializeResponse;
|
|
9484
|
+
/**
|
|
9485
|
+
* 选择对端握手公布的认证方法,返回 HaiResult。
|
|
9486
|
+
* @param method - initialize 返回的认证方法 ID。
|
|
9487
|
+
* @returns 认证响应的 HaiResult。
|
|
9488
|
+
* @example
|
|
9489
|
+
* ```ts
|
|
9490
|
+
* // connection/session 为已成功连接或创建的句柄,先检查 result.success。
|
|
9491
|
+
* const result = await connection.authenticate('api-key')
|
|
9492
|
+
* ```
|
|
9493
|
+
*/
|
|
9494
|
+
authenticate: (method: string) => Promise<{
|
|
9495
|
+
success: false;
|
|
9496
|
+
error: _h_ai_core.HaiError;
|
|
9497
|
+
} | {
|
|
9498
|
+
success: true;
|
|
9499
|
+
data: _agentclientprotocol_sdk.AuthenticateResponse;
|
|
9500
|
+
}>;
|
|
9501
|
+
/**
|
|
9502
|
+
* 在对端可见的绝对 cwd 创建原生会话,返回 prompt/cancel 句柄。
|
|
9503
|
+
* @param cwd - 对端文件系统可见的绝对工作目录。
|
|
9504
|
+
* @param mcpServers - 可选原生 MCP 定义;调用方负责凭据与授权。
|
|
9505
|
+
* @returns 原生会话句柄;不创建框架持久会话记录。
|
|
9506
|
+
* @example
|
|
9507
|
+
* ```ts
|
|
9508
|
+
* // connection/session 为已成功连接或创建的句柄,先检查 result.success。
|
|
9509
|
+
* const result = await connection.createSession('/srv/project', [])
|
|
9510
|
+
* ```
|
|
9511
|
+
*/
|
|
9512
|
+
createSession: (cwd: string, mcpServers?: McpServer[]) => Promise<{
|
|
9513
|
+
success: false;
|
|
9514
|
+
error: _h_ai_core.HaiError;
|
|
9515
|
+
} | {
|
|
9516
|
+
success: true;
|
|
9517
|
+
data: {
|
|
9518
|
+
id: string;
|
|
9519
|
+
/**
|
|
9520
|
+
* 发送一轮原生内容,返回最终文本、停止原因和事件。
|
|
9521
|
+
* @param content - 原生 ACP 内容块。
|
|
9522
|
+
* @param signal - 可选本轮取消信号。
|
|
9523
|
+
* @returns 最终文本、停止原因和事件的 HaiResult。
|
|
9524
|
+
* @example
|
|
9525
|
+
* ```ts
|
|
9526
|
+
* // connection/session 为已成功连接或创建的句柄,先检查 result.success。
|
|
9527
|
+
* const result = await session.prompt([{ type: 'text', text: '检查工程' }])
|
|
9528
|
+
* ```
|
|
9529
|
+
*/
|
|
9530
|
+
prompt: (content: ContentBlock[], signal?: AbortSignal) => Promise<{
|
|
9531
|
+
success: false;
|
|
9532
|
+
error: _h_ai_core.HaiError;
|
|
9533
|
+
} | {
|
|
9534
|
+
success: true;
|
|
9535
|
+
data: {
|
|
9536
|
+
text: string;
|
|
9537
|
+
events: SessionNotification[];
|
|
9538
|
+
stopReason: _agentclientprotocol_sdk.StopReason;
|
|
9539
|
+
_meta?: {
|
|
9540
|
+
[key: string]: unknown;
|
|
9541
|
+
} | null;
|
|
9542
|
+
};
|
|
9543
|
+
}>;
|
|
9544
|
+
/**
|
|
9545
|
+
* 取消当前轮次,超时则关闭连接。
|
|
9546
|
+
* @returns 取消完成的 HaiResult。
|
|
9547
|
+
* @example
|
|
9548
|
+
* ```ts
|
|
9549
|
+
* // connection/session 为已成功连接或创建的句柄,先检查 result.success。
|
|
9550
|
+
* const result = await session.cancel()
|
|
9551
|
+
* ```
|
|
9552
|
+
*/
|
|
9553
|
+
cancel: () => Promise<{
|
|
9554
|
+
success: false;
|
|
9555
|
+
error: _h_ai_core.HaiError;
|
|
9556
|
+
} | {
|
|
9557
|
+
success: true;
|
|
9558
|
+
data: void;
|
|
9559
|
+
}>;
|
|
9560
|
+
};
|
|
9561
|
+
}>;
|
|
9562
|
+
/**
|
|
9563
|
+
* 读取对端原生会话列表;未声明相应能力时返回错误。
|
|
9564
|
+
* @param cursor - 上一次原生列表响应中的分页游标。
|
|
9565
|
+
* @returns 原生分页响应的 HaiResult。
|
|
9566
|
+
* @example
|
|
9567
|
+
* ```ts
|
|
9568
|
+
* // connection/session 为已成功连接或创建的句柄,先检查 result.success。
|
|
9569
|
+
* const result = await connection.listSessions()
|
|
9570
|
+
* ```
|
|
9571
|
+
*/
|
|
9572
|
+
listSessions: (cursor?: string) => Promise<{
|
|
9573
|
+
success: false;
|
|
9574
|
+
error: _h_ai_core.HaiError;
|
|
9575
|
+
} | {
|
|
9576
|
+
success: true;
|
|
9577
|
+
data: _agentclientprotocol_sdk.ListSessionsResponse;
|
|
9578
|
+
}>;
|
|
9579
|
+
/**
|
|
9580
|
+
* 按原生 ID 删除远端会话;不会删除框架数据库会话记录。
|
|
9581
|
+
* @param id - 对端返回的原生会话 ID。
|
|
9582
|
+
* @returns 原生删除响应的 HaiResult;不支持时返回协议错误。
|
|
9583
|
+
* @example
|
|
9584
|
+
* ```ts
|
|
9585
|
+
* // connection/session 为已成功连接或创建的句柄,先检查 result.success。
|
|
9586
|
+
* const result = await connection.deleteSession('native-id')
|
|
9587
|
+
* ```
|
|
9588
|
+
*/
|
|
9589
|
+
deleteSession: (id: string) => Promise<{
|
|
9590
|
+
success: false;
|
|
9591
|
+
error: _h_ai_core.HaiError;
|
|
9592
|
+
} | {
|
|
9593
|
+
success: true;
|
|
9594
|
+
data: _agentclientprotocol_sdk.DeleteSessionResponse;
|
|
9595
|
+
}>;
|
|
9596
|
+
/**
|
|
9597
|
+
* 关闭连接和拥有的子进程;不删除远端文件或持久状态。
|
|
9598
|
+
* @returns 关闭完成的 HaiResult;可重复关闭。
|
|
9599
|
+
* @example
|
|
9600
|
+
* ```ts
|
|
9601
|
+
* // connection/session 为已成功连接或创建的句柄,先检查 result.success。
|
|
9602
|
+
* const result = await connection.close()
|
|
9603
|
+
* ```
|
|
9604
|
+
*/
|
|
9605
|
+
close: () => Promise<{
|
|
9606
|
+
success: false;
|
|
9607
|
+
error: _h_ai_core.HaiError;
|
|
9608
|
+
} | {
|
|
9609
|
+
success: true;
|
|
9610
|
+
data: void;
|
|
9611
|
+
}>;
|
|
9612
|
+
};
|
|
9613
|
+
}>;
|
|
9614
|
+
/**
|
|
9615
|
+
* 关闭子系统及拥有的资源;由 ai.close 生命周期调用。
|
|
9616
|
+
* @returns 所有已接受操作结束和拥有资源完成清理后的 Promise。
|
|
9617
|
+
* @throws 清理进程或容器失败时抛出 ACPFailure,由 ai.close 统一处理。
|
|
9618
|
+
* @example
|
|
9619
|
+
* ```ts
|
|
9620
|
+
* import { ai } from '@h-ai/ai'
|
|
9621
|
+
* // 前提:ai 已成功初始化。
|
|
9622
|
+
* // 普通 API 先检查 result.success,再读取 data 或 error。
|
|
9623
|
+
* await ai.close()
|
|
9624
|
+
* ```
|
|
9625
|
+
*/
|
|
9626
|
+
close(): Promise<void>;
|
|
9627
|
+
};
|
|
9628
|
+
|
|
9629
|
+
/**
|
|
9630
|
+
* 原生传输参数;HTTP/WS 使用锁定版本的官方实验传输,不进行隐式转换。
|
|
9631
|
+
* @example
|
|
9632
|
+
* ```ts
|
|
9633
|
+
* import type { ACPTransport } from '@h-ai/ai'
|
|
9634
|
+
* const transport: ACPTransport = { type: 'stdio', command: 'codex-acp' }
|
|
9635
|
+
* ```
|
|
9636
|
+
*/
|
|
9637
|
+
type ACPTransport = {
|
|
9638
|
+
/** 通过独占子进程 stdin/stdout 传输 ACP。 */
|
|
9639
|
+
type: 'stdio';
|
|
9640
|
+
/** 直接执行的程序路径,不通过 shell。 */
|
|
9641
|
+
command: string;
|
|
9642
|
+
/** 原生参数数组。 */
|
|
9643
|
+
args?: string[];
|
|
9644
|
+
/** 子进程工作目录。 */
|
|
9645
|
+
cwd?: string;
|
|
9646
|
+
/** 传给子进程的环境变量,与最小宿主环境合并。 */
|
|
9647
|
+
env?: Record<string, string>;
|
|
9648
|
+
} | {
|
|
9649
|
+
/** 原生远程传输;对端必须支持相同 SDK 协议版本。 */
|
|
9650
|
+
type: 'http' | 'ws';
|
|
9651
|
+
/** ACP 服务地址,协议应与 type 一致。 */
|
|
9652
|
+
url: string;
|
|
9653
|
+
/** 当前连接的认证请求头,仅保存在内存。 */
|
|
9654
|
+
headers?: Record<string, string>;
|
|
9655
|
+
};
|
|
9656
|
+
/**
|
|
9657
|
+
* 可信宿主回调。声明能力必须提供对应实现;默认拒绝权限请求。
|
|
9658
|
+
* @example
|
|
9659
|
+
* ```ts
|
|
9660
|
+
* import type { ACPClientOptions } from '@h-ai/ai'
|
|
9661
|
+
* const options: ACPClientOptions = { handlers: { 'session/request_permission': () => ({ outcome: { outcome: 'cancelled' } }) } }
|
|
9662
|
+
* ```
|
|
9663
|
+
*/
|
|
9664
|
+
interface ACPClientOptions {
|
|
9665
|
+
/** 接收原生会话事件,包括 session/new 完成前的事件;抛错将关闭连接。 */
|
|
9666
|
+
onEvent?: (event: SessionNotification) => void;
|
|
9667
|
+
/** 可信客户端回调实现;未提供权限回调时默认拒绝。 */
|
|
9668
|
+
handlers?: Partial<ClientRequestHandlersByMethod>;
|
|
9669
|
+
/** 向智能体声明的能力;声明的文件、终端和 elicitation 能力必须配齐回调。 */
|
|
9670
|
+
capabilities?: ClientCapabilities;
|
|
9671
|
+
/** 初始化连接的取消信号;每轮 prompt 的取消信号独立传入。 */
|
|
9672
|
+
signal?: AbortSignal;
|
|
9673
|
+
}
|
|
9674
|
+
/**
|
|
9675
|
+
* 可信原生配置扩展;返回值只传给进程,不写入 Agent 定义存储。
|
|
9676
|
+
* @example
|
|
9677
|
+
* ```ts
|
|
9678
|
+
* import type { ACPAgentAdapter } from '@h-ai/ai'
|
|
9679
|
+
* const adapter: ACPAgentAdapter = { configure: () => ({ command: 'my-agent', args: ['--acp'], env: {} }) }
|
|
9680
|
+
* ```
|
|
9681
|
+
*/
|
|
9682
|
+
interface ACPAgentAdapter {
|
|
9683
|
+
/**
|
|
9684
|
+
* 生成当前会话的原生启动参数;实现可以异步,不应在此启动进程或持久保存密钥。
|
|
9685
|
+
* @param input - 智能体、已解析模型与独立状态目录。
|
|
9686
|
+
* @returns 原生可执行文件、参数、临时环境和可选配置文件。
|
|
9687
|
+
* @example
|
|
9688
|
+
* ```ts
|
|
9689
|
+
* const adapter: ACPAgentAdapter = { configure: ({ statePath }) => ({ command: 'my-agent', args: ['--acp'], env: { AGENT_HOME: statePath } }) }
|
|
9690
|
+
* ```
|
|
9691
|
+
*/
|
|
9692
|
+
configure: (input: ACPAgentAdapterInput) => ACPAgentLaunch | Promise<ACPAgentLaunch>;
|
|
9693
|
+
}
|
|
9694
|
+
/**
|
|
9695
|
+
* 原生适配器输入;模型来源由框架统一解析,适配器不维护独立模型清单。
|
|
9696
|
+
* @example
|
|
9697
|
+
* ```ts
|
|
9698
|
+
* import type { ACPAgentAdapterInput } from '@h-ai/ai'
|
|
9699
|
+
* function selected(input: ACPAgentAdapterInput) { return input.models.find(model => model.id === input.modelId) }
|
|
9700
|
+
* ```
|
|
9701
|
+
*/
|
|
9702
|
+
interface ACPAgentAdapterInput {
|
|
9703
|
+
/** 合并清单中的智能体定义。 */
|
|
9704
|
+
agent: z.infer<typeof ACPAgentSchema>;
|
|
9705
|
+
/** 智能体绑定的全部模型及已解析协议、凭据、容量和模态信息。 */
|
|
9706
|
+
models: Array<{
|
|
9707
|
+
id: string;
|
|
9708
|
+
config: ResolvedModelConfig;
|
|
9709
|
+
}>;
|
|
9710
|
+
/** 本次会话选择的模型 ID。 */
|
|
9711
|
+
modelId?: string;
|
|
9712
|
+
/** 已创建的专属状态目录;托管容器内使用 /state/<会话 ID>。 */
|
|
9713
|
+
statePath: string;
|
|
9714
|
+
}
|
|
9715
|
+
/**
|
|
9716
|
+
* 单次启动的原生配置;env 可能含凭据,不可向浏览器或日志直接公开。
|
|
9717
|
+
* @example
|
|
9718
|
+
* ```ts
|
|
9719
|
+
* import type { ACPAgentLaunch } from '@h-ai/ai'
|
|
9720
|
+
* const launch: ACPAgentLaunch = { command: 'my-agent', args: ['--acp'], env: {} }
|
|
9721
|
+
* ```
|
|
9722
|
+
*/
|
|
9723
|
+
interface ACPAgentLaunch {
|
|
9724
|
+
/** 直接执行的程序,禁止拼接 shell 命令。 */
|
|
9725
|
+
command: string;
|
|
9726
|
+
/** 原生参数数组。 */
|
|
9727
|
+
args: string[];
|
|
9728
|
+
/** 仅向当前执行环境注入的变量。 */
|
|
9729
|
+
env: Record<string, string>;
|
|
9730
|
+
/** 状态目录下的普通配置文件,文件名不允许路径分隔符。 */
|
|
9731
|
+
files?: Record<string, string>;
|
|
9732
|
+
}
|
|
9733
|
+
/**
|
|
9734
|
+
* 已准备的工程位置,供同一节点上的可信预览或检查进程使用。
|
|
9735
|
+
* @example
|
|
9736
|
+
* ```ts
|
|
9737
|
+
* import type { ACPSessionWorkspace } from '@h-ai/ai'
|
|
9738
|
+
* function webPath(workspace: ACPSessionWorkspace) { return workspace.repositories.find(repo => repo.id === 'web')?.path }
|
|
9739
|
+
* ```
|
|
9740
|
+
*/
|
|
9741
|
+
interface ACPSessionWorkspace {
|
|
9742
|
+
/** 本机真实目录,或实际使用的引擎、源码卷和容器挂载点。 */
|
|
9743
|
+
storage: {
|
|
9744
|
+
type: 'directory';
|
|
9745
|
+
path: string;
|
|
9746
|
+
} | {
|
|
9747
|
+
type: 'volume';
|
|
9748
|
+
engine: 'podman' | 'docker';
|
|
9749
|
+
name: string;
|
|
9750
|
+
mountPath: string;
|
|
9751
|
+
};
|
|
9752
|
+
/** 当前会话的聚合目录,位于上述宿主目录或容器挂载点内。 */
|
|
9753
|
+
path: string;
|
|
9754
|
+
/** 登记仓库在同一文件系统中的绝对路径。 */
|
|
9755
|
+
repositories: Array<{
|
|
9756
|
+
id: string;
|
|
9757
|
+
path: string;
|
|
9758
|
+
}>;
|
|
9759
|
+
}
|
|
9760
|
+
/**
|
|
9761
|
+
* 持久会话绑定;原生 ID 不等于框架 ID,工作目录只能由登记信息生成。
|
|
9762
|
+
* @example
|
|
9763
|
+
* ```ts
|
|
9764
|
+
* import type { ACPSessionInfo } from '@h-ai/ai'
|
|
9765
|
+
* function sessionStatus(session: ACPSessionInfo) { return session.status }
|
|
9766
|
+
* ```
|
|
9767
|
+
*/
|
|
9768
|
+
interface ACPSessionInfo {
|
|
9769
|
+
/** 框架会话 ID,与智能体返回的 nativeId 分开维护。 */
|
|
9770
|
+
id: string;
|
|
9771
|
+
/** 合并清单中的智能体 ID。 */
|
|
9772
|
+
agentId: string;
|
|
9773
|
+
/** 受管理工作区 ID;远程自定义服务可省略。 */
|
|
9774
|
+
workspaceId?: string;
|
|
9775
|
+
/** 作为会话工作目录的已登记仓库;省略时使用聚合目录。 */
|
|
9776
|
+
repositoryId?: string;
|
|
9777
|
+
/** 智能体实际可见的绝对工作目录。 */
|
|
9778
|
+
cwd: string;
|
|
9779
|
+
/** 是否使用独立检出目录;false 表示共享工作区主目录。 */
|
|
9780
|
+
newWorktree: boolean;
|
|
9781
|
+
/** 独立会话中所有工程共用的分支名。 */
|
|
9782
|
+
branch?: string;
|
|
9783
|
+
/** 受管目录交接信息;创建失败时可能只有部分工作树,旧记录或远程会话可能没有该字段。 */
|
|
9784
|
+
workspace?: ACPSessionWorkspace;
|
|
9785
|
+
/** 显式回收已开始或完成。此时 workspace 仅供历史追溯,不可恢复会话或发布工作树。 */
|
|
9786
|
+
worktreeStatus?: 'reclaiming' | 'reclaimed';
|
|
9787
|
+
/** 启动时选定的 Hai 模型 ID。 */
|
|
9788
|
+
modelId?: string;
|
|
9789
|
+
/** 模型非密钥配置的摘要;用于阻止不兼容的会话恢复。 */
|
|
9790
|
+
modelSignature?: string;
|
|
9791
|
+
/** 智能体原生会话 ID,恢复时原样传回。 */
|
|
9792
|
+
nativeId?: string;
|
|
9793
|
+
/** 打开中、运行中、已关闭或打开失败。 */
|
|
9794
|
+
status: 'opening' | 'active' | 'closed' | 'failed';
|
|
9795
|
+
/** 创建会话时的智能体定义快照。 */
|
|
9796
|
+
agent: z.infer<typeof ACPAgentSchema>;
|
|
9797
|
+
/** 直接绑定的原生 MCP 参数;可能含凭据,仅供可信服务端管理。 */
|
|
9798
|
+
mcpServers: McpServer[];
|
|
9799
|
+
/** 从 MCP 合并清单选择的服务 ID;凭据在启动时解析。 */
|
|
9800
|
+
mcpServerIds?: string[];
|
|
9801
|
+
/** 当前拥有的容器;关闭后清空,volume 内容仍保留。 */
|
|
9802
|
+
resource?: {
|
|
9803
|
+
engine?: 'podman' | 'docker';
|
|
9804
|
+
container: string;
|
|
9805
|
+
};
|
|
9806
|
+
}
|
|
9807
|
+
/**
|
|
9808
|
+
* 创建会话参数;远程服务使用它自身可见的绝对路径。
|
|
9809
|
+
* @example
|
|
9810
|
+
* ```ts
|
|
9811
|
+
* import type { ACPCreateSessionOptions } from '@h-ai/ai'
|
|
9812
|
+
* const options: ACPCreateSessionOptions = { agentId: 'coder', workspaceId: 'project', newWorktree: true }
|
|
9813
|
+
* ```
|
|
9814
|
+
*/
|
|
9815
|
+
interface ACPCreateSessionOptions extends ACPClientOptions {
|
|
9816
|
+
/** 可选业务会话 ID;省略时生成 UUID。 */
|
|
9817
|
+
id?: string;
|
|
9818
|
+
/** 合并清单中的智能体 ID。 */
|
|
9819
|
+
agentId: string;
|
|
9820
|
+
/** 托管模式必填的工作区 ID。 */
|
|
9821
|
+
workspaceId?: string;
|
|
9822
|
+
/** 以已登记仓库的根目录启动与恢复;不改变 worktree 和 Git 发布的仓库范围。 */
|
|
9823
|
+
repositoryId?: string;
|
|
9824
|
+
/** 自定义远程服务可见的绝对路径;托管模式由工作区计算。 */
|
|
9825
|
+
cwd?: string;
|
|
9826
|
+
/** 默认 false;true 时从每个工程当前本地主分支创建 worktree。 */
|
|
9827
|
+
newWorktree?: boolean;
|
|
9828
|
+
/** 独立会话分支名;默认 acp/<会话 ID>。 */
|
|
9829
|
+
branch?: string;
|
|
9830
|
+
/** 本次会话的模型 ID,必须在智能体 modelIds 内。 */
|
|
9831
|
+
modelId?: string;
|
|
9832
|
+
/** 直接传给智能体的 MCP 定义;与 mcpServerIds 合并。 */
|
|
9833
|
+
mcpServers?: McpServer[];
|
|
9834
|
+
/** 从 ai.mcp.servers 选择的登记服务。 */
|
|
9835
|
+
mcpServerIds?: string[];
|
|
9836
|
+
}
|
|
9837
|
+
/**
|
|
9838
|
+
* 每个工程分别报告,保留失败前已发生的提交和推送结果。
|
|
9839
|
+
* @example
|
|
9840
|
+
* ```ts
|
|
9841
|
+
* import type { ACPGitReport } from '@h-ai/ai'
|
|
9842
|
+
* function failedRepositories(reports: ACPGitReport[]) { return reports.filter(report => !report.success).map(report => report.repositoryId) }
|
|
9843
|
+
* ```
|
|
9844
|
+
*/
|
|
9845
|
+
interface ACPGitReport {
|
|
9846
|
+
/** 工作区中声明的工程 ID。 */
|
|
9847
|
+
repositoryId: string;
|
|
9848
|
+
/** 该工程是否完成全部请求操作。 */
|
|
9849
|
+
success: boolean;
|
|
9850
|
+
/** 成功时为 done;失败时标明停止阶段。 */
|
|
9851
|
+
phase: 'check' | 'commit' | 'fetch' | 'merge' | 'push' | 'done';
|
|
9852
|
+
/** 已创建或发布的提交 SHA;失败前可能已经产生提交。 */
|
|
9853
|
+
commit?: string;
|
|
9854
|
+
/** 脱敏的失败原因,不包含 Git stderr 或认证资料。 */
|
|
9855
|
+
error?: string;
|
|
9856
|
+
}
|
|
9857
|
+
/**
|
|
9858
|
+
* ACP 操作入口。
|
|
9859
|
+
* @example
|
|
9860
|
+
* ```ts
|
|
9861
|
+
* import { ai } from '@h-ai/ai'
|
|
9862
|
+
* async function listAgents() { const result = await ai.acp.agents.list(); if (!result.success) return result; return result.data }
|
|
9863
|
+
* ```
|
|
9864
|
+
*/
|
|
9865
|
+
type ACPOperations = ReturnType<typeof createACPOperations>;
|
|
9866
|
+
|
|
9867
|
+
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 _, EntityTypeSchema as a$, AudioModelEntrySchema as a1, AudioOperationSchema as a3, AudioOperationsSchema as a4, AudioProviderSchema as a6, AudioWsClientMessageSchema as a8, CompressionStrategySchema as aC, EmbeddingConfigSchema as aR, AudioWsDoneMessageSchema as aa, AudioWsStartMessageSchema as ai, AudioWsTextMessageSchema as ak, CompressConfigSchema as ax, FileConfigSchema as b1, 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, MCPServerConfigSchema as c0, MemoryConfigSchema as ce, MemoryTypeSchema as cp, ModelCapabilitiesSchema as ct, ModelEntrySchema as cv, ModelScenarioSchema as cx, OptionalSecretSchema as cz, RetrievalConfigSchema as d1, RetrievalSourceSchema as d8, ensureAudioCredential as dN, resolveAudioModel as dO, resolveImageModel as dP, resolveModelApi as dQ, resolveModelEntry as dR, serializePlayableAudio as dS, SummaryConfigSchema as dl, TokenConfigSchema as du, A2AConfigSchema as h, A2ASkillConfigSchema as n, ACPAgentSchema as s, ACPConfigSchema as w };
|
|
9868
|
+
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, 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, DefineToolOptions as aO, DeveloperMessage as aP, EmbeddingConfig as aQ, EmbeddingItem as aS, EmbeddingOperations as aT, EmbeddingRequest as aU, EmbeddingResponse as aV, EntityDocumentRelation as aW, EntityDocumentResult as aX, EntityListOptions as aY, EntityQueryOptions as aZ, EntityType as a_, 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, MCPServerConfig as b$, FileConfig as b0, FileOperations as b2, FileParseMethod as b3, FileParseOptions as b4, FileParseRequest as b5, FileParseResult as b6, 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, A2AAuthenticator as c, ResolvedModelConfig 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, OutputFormat as cA, PersonaOperations as cB, PersonaProfile as cC, PersonaProfileInput as cD, PersonaProfileUpdate as cE, PersonaScopeOptions as cF, RagContextItem as cG, RagOperations as cH, RagOptions as cI, RagResult as cJ, RagStreamEvent as cK, ReasoningOperations as cL, ReasoningOptions as cM, ReasoningResult as cN, ReasoningStep as cO, ReasoningStepType as cP, ReasoningStrategy as cQ, ReasoningStreamEvent as cR, ReferenceImage as cS, RerankDocument as cT, RerankItem as cU, RerankOperations as cV, RerankRequest as cW, RerankResponse as cX, ResolveRequiredModelEntryOptions as cY, ResolvedAudioModel as cZ, ResolvedImageModel 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, MessageContent as cr, MessageRole as cs, ModelEntry as cu, ModelScenario as cw, ObjectRef as cy, A2ACallOptions as d, RetrievalConfig as d0, RetrievalOperations as d2, RetrievalRequest as d3, RetrievalResult as d4, RetrievalResultItem as d5, RetrievalSource as d6, RetrievalSourceConfig as d7, SSEDecoder as d9, ToolCall as dA, ToolDefinition as dB, ToolErrorType as dC, ToolExecutionContext as dD, ToolExecutionOptions as dE, ToolMessage as dF, ToolRegistryOperations as dG, ToolRegistryOptions as dH, ToolsOperations as dI, UserMessage as dJ, WhereClause as dK, WhereOperator as dL, WhereValue as dM, ACPSessionWorkspace as dT, SSEEvent as da, ScopedMemoryBinding as db, ScopedMemoryOperations as dc, SessionInfo as dd, StoreFilter as de, StorePage as df, StoreScope as dg, StreamOperations as dh, StreamProcessor as di, StreamResult as dj, SummaryConfig as dk, SummaryOperations as dm, SummaryOptions as dn, SummaryResult as dp, SystemMessage as dq, TempModelConfig as dr, TextContent as ds, TokenConfig as dt, TokenOperations as dv, TokenUsage as dw, Tool as dx, ToolAuthorizationRequest as dy, ToolAuthorizer as dz, A2ACallResult as e, 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 };
|