@h-ai/ai 1.0.0-beta.23 → 1.0.0-beta.25

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.
Files changed (41) hide show
  1. package/README.en.md +308 -141
  2. package/README.ja.md +308 -141
  3. package/README.md +306 -141
  4. package/dist/{ai-acp-types-BNeA1j0P.d.ts → ai-acp-types-Bwp6PcL8.d.ts} +2265 -230
  5. package/dist/browser.d.ts +3 -1
  6. package/dist/browser.js +3 -3
  7. package/dist/{chunk-WSH2246H.js → chunk-3R5SMLSJ.js} +3 -3
  8. package/dist/{chunk-WSH2246H.js.map → chunk-3R5SMLSJ.js.map} +1 -1
  9. package/dist/{chunk-M77C3VAP.js → chunk-NRDLMUSY.js} +4 -2
  10. package/dist/chunk-NRDLMUSY.js.map +1 -0
  11. package/dist/{chunk-CCXG2S7O.js → chunk-VEWBD2J4.js} +157 -9
  12. package/dist/chunk-VEWBD2J4.js.map +1 -0
  13. package/dist/client/index.js +2 -2
  14. package/dist/index.d.ts +4 -2
  15. package/dist/index.js +3088 -879
  16. package/dist/index.js.map +1 -1
  17. package/models/agents/README.md +30 -18
  18. package/models/agents/build.mjs +158 -55
  19. package/models/agents/codex-acp/Dockerfile +8 -13
  20. package/models/agents/deepseek-harness/Dockerfile +8 -13
  21. package/models/agents/goose/Dockerfile +8 -13
  22. package/models/agents/goose/agent.json +1 -1
  23. package/package.json +11 -8
  24. package/tools/.dockerignore +4 -0
  25. package/tools/README.md +111 -0
  26. package/tools/archives.py +56 -0
  27. package/tools/browser/Dockerfile +19 -0
  28. package/tools/browser/operation.py +50 -0
  29. package/tools/browser/render.mjs +40 -0
  30. package/tools/documents/Dockerfile +20 -0
  31. package/tools/documents/operation.py +80 -0
  32. package/tools/ocr/Dockerfile +19 -0
  33. package/tools/ocr/operation.py +18 -0
  34. package/tools/office/Dockerfile +21 -0
  35. package/tools/office/office_job.py +65 -0
  36. package/tools/office/operation.py +43 -0
  37. package/tools/tests/image-smoke.mjs +83 -0
  38. package/tools/tests/test_hai_tool.py +82 -0
  39. package/tools/tool.py +145 -0
  40. package/dist/chunk-CCXG2S7O.js.map +0 -1
  41. package/dist/chunk-M77C3VAP.js.map +0 -1
@@ -1,5 +1,7 @@
1
1
  import * as _h_ai_core from '@h-ai/core';
2
2
  import { HaiResult, HaiError } from '@h-ai/core';
3
+ import * as _h_ai_runner from '@h-ai/runner';
4
+ import { RunnerScope, RunnerJson, RunnerFunctions } from '@h-ai/runner';
3
5
  import { TaskState } from '@a2a-js/sdk';
4
6
  import { AgentExecutor } from '@a2a-js/sdk/server';
5
7
  import * as zod from 'zod';
@@ -9,9 +11,10 @@ import { CleanOptionsInput, ChunkOptionsInput } from '@h-ai/datapipe';
9
11
  import { e as AudioOperations, a as AudioContent, P as PlayableAudio, b as AudioFormat } from './ai-audio-types-4R5yUAVl.js';
10
12
  import * as zod_v4_core from 'zod/v4/core';
11
13
  import * as _agentclientprotocol_sdk from '@agentclientprotocol/sdk';
12
- import { McpServer, ContentBlock, SessionNotification, ClientRequestHandlersByMethod, ClientCapabilities } from '@agentclientprotocol/sdk';
14
+ import { McpServer, ContentBlock, RequestPermissionRequest, SessionNotification, ClientRequestHandlersByMethod, ClientCapabilities } from '@agentclientprotocol/sdk';
13
15
  import OpenAI from 'openai';
14
- import { PromptMessage } from '@modelcontextprotocol/sdk/types.js';
16
+ import { CallToolRequest, PromptMessage, CallToolResult } from '@modelcontextprotocol/sdk/types.js';
17
+ import { IncomingMessage, ServerResponse } from 'node:http';
15
18
 
16
19
  /**
17
20
  * 工程主分支必须显式填写。
@@ -86,6 +89,82 @@ declare const ACPAgentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
86
89
  modelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
87
90
  defaultModelId: z.ZodOptional<z.ZodString>;
88
91
  environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
92
+ environmentIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
93
+ allowedCapabilities: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodString]>>>;
94
+ defaults: z.ZodOptional<z.ZodObject<{
95
+ model: z.ZodOptional<z.ZodObject<{
96
+ id: z.ZodOptional<z.ZodString>;
97
+ reasoningEffort: z.ZodOptional<z.ZodString>;
98
+ temperature: z.ZodOptional<z.ZodNumber>;
99
+ maxOutputTokens: z.ZodOptional<z.ZodNumber>;
100
+ }, z.core.$strict>>;
101
+ execution: z.ZodOptional<z.ZodObject<{
102
+ mode: z.ZodOptional<z.ZodEnum<{
103
+ auto: "auto";
104
+ shared: "shared";
105
+ user: "user";
106
+ task: "task";
107
+ }>>;
108
+ environmentId: z.ZodOptional<z.ZodString>;
109
+ resources: z.ZodOptional<z.ZodObject<{
110
+ cpu: z.ZodOptional<z.ZodNumber>;
111
+ memoryMiB: z.ZodOptional<z.ZodNumber>;
112
+ }, z.core.$strict>>;
113
+ }, z.core.$strict>>;
114
+ workspaceId: z.ZodOptional<z.ZodString>;
115
+ context: z.ZodOptional<z.ZodObject<{
116
+ fileIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
117
+ knowledgeBaseIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
118
+ skillIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
119
+ memory: z.ZodOptional<z.ZodObject<{
120
+ scope: z.ZodEnum<{
121
+ user: "user";
122
+ none: "none";
123
+ space: "space";
124
+ }>;
125
+ spaceId: z.ZodOptional<z.ZodString>;
126
+ write: z.ZodOptional<z.ZodEnum<{
127
+ none: "none";
128
+ confirm: "confirm";
129
+ "on-success": "on-success";
130
+ }>>;
131
+ }, z.core.$strict>>;
132
+ }, z.core.$strict>>;
133
+ tools: z.ZodOptional<z.ZodObject<{
134
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
135
+ }, z.core.$strict>>;
136
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodString>>;
137
+ permissions: z.ZodOptional<z.ZodObject<{
138
+ profile: z.ZodOptional<z.ZodEnum<{
139
+ "read-only": "read-only";
140
+ workspace: "workspace";
141
+ "full-access": "full-access";
142
+ }>>;
143
+ approval: z.ZodOptional<z.ZodEnum<{
144
+ never: "never";
145
+ "on-request": "on-request";
146
+ }>>;
147
+ ruleIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
148
+ }, z.core.$strict>>;
149
+ limits: z.ZodOptional<z.ZodObject<{
150
+ queueTimeoutMs: z.ZodOptional<z.ZodNumber>;
151
+ runTimeoutMs: z.ZodOptional<z.ZodNumber>;
152
+ approvalTimeoutMs: z.ZodOptional<z.ZodNumber>;
153
+ maxOutputBytes: z.ZodOptional<z.ZodNumber>;
154
+ }, z.core.$strict>>;
155
+ output: z.ZodOptional<z.ZodObject<{
156
+ format: z.ZodEnum<{
157
+ text: "text";
158
+ json: "json";
159
+ }>;
160
+ schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
161
+ }, z.core.$strict>>;
162
+ native: z.ZodOptional<z.ZodObject<{
163
+ adapter: z.ZodString;
164
+ options: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
165
+ }, z.core.$strict>>;
166
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
167
+ }, z.core.$strict>>;
89
168
  }, z.core.$strict>, z.ZodObject<{
90
169
  mode: z.ZodLiteral<"embedded">;
91
170
  transport: z.ZodDefault<z.ZodLiteral<"stdio">>;
@@ -98,6 +177,82 @@ declare const ACPAgentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
98
177
  modelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
99
178
  defaultModelId: z.ZodOptional<z.ZodString>;
100
179
  environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
180
+ environmentIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
181
+ allowedCapabilities: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodString]>>>;
182
+ defaults: z.ZodOptional<z.ZodObject<{
183
+ model: z.ZodOptional<z.ZodObject<{
184
+ id: z.ZodOptional<z.ZodString>;
185
+ reasoningEffort: z.ZodOptional<z.ZodString>;
186
+ temperature: z.ZodOptional<z.ZodNumber>;
187
+ maxOutputTokens: z.ZodOptional<z.ZodNumber>;
188
+ }, z.core.$strict>>;
189
+ execution: z.ZodOptional<z.ZodObject<{
190
+ mode: z.ZodOptional<z.ZodEnum<{
191
+ auto: "auto";
192
+ shared: "shared";
193
+ user: "user";
194
+ task: "task";
195
+ }>>;
196
+ environmentId: z.ZodOptional<z.ZodString>;
197
+ resources: z.ZodOptional<z.ZodObject<{
198
+ cpu: z.ZodOptional<z.ZodNumber>;
199
+ memoryMiB: z.ZodOptional<z.ZodNumber>;
200
+ }, z.core.$strict>>;
201
+ }, z.core.$strict>>;
202
+ workspaceId: z.ZodOptional<z.ZodString>;
203
+ context: z.ZodOptional<z.ZodObject<{
204
+ fileIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
205
+ knowledgeBaseIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
206
+ skillIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
207
+ memory: z.ZodOptional<z.ZodObject<{
208
+ scope: z.ZodEnum<{
209
+ user: "user";
210
+ none: "none";
211
+ space: "space";
212
+ }>;
213
+ spaceId: z.ZodOptional<z.ZodString>;
214
+ write: z.ZodOptional<z.ZodEnum<{
215
+ none: "none";
216
+ confirm: "confirm";
217
+ "on-success": "on-success";
218
+ }>>;
219
+ }, z.core.$strict>>;
220
+ }, z.core.$strict>>;
221
+ tools: z.ZodOptional<z.ZodObject<{
222
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
223
+ }, z.core.$strict>>;
224
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodString>>;
225
+ permissions: z.ZodOptional<z.ZodObject<{
226
+ profile: z.ZodOptional<z.ZodEnum<{
227
+ "read-only": "read-only";
228
+ workspace: "workspace";
229
+ "full-access": "full-access";
230
+ }>>;
231
+ approval: z.ZodOptional<z.ZodEnum<{
232
+ never: "never";
233
+ "on-request": "on-request";
234
+ }>>;
235
+ ruleIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
236
+ }, z.core.$strict>>;
237
+ limits: z.ZodOptional<z.ZodObject<{
238
+ queueTimeoutMs: z.ZodOptional<z.ZodNumber>;
239
+ runTimeoutMs: z.ZodOptional<z.ZodNumber>;
240
+ approvalTimeoutMs: z.ZodOptional<z.ZodNumber>;
241
+ maxOutputBytes: z.ZodOptional<z.ZodNumber>;
242
+ }, z.core.$strict>>;
243
+ output: z.ZodOptional<z.ZodObject<{
244
+ format: z.ZodEnum<{
245
+ text: "text";
246
+ json: "json";
247
+ }>;
248
+ schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
249
+ }, z.core.$strict>>;
250
+ native: z.ZodOptional<z.ZodObject<{
251
+ adapter: z.ZodString;
252
+ options: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
253
+ }, z.core.$strict>>;
254
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
255
+ }, z.core.$strict>>;
101
256
  }, z.core.$strict>, z.ZodObject<{
102
257
  mode: z.ZodLiteral<"builtin-service">;
103
258
  transport: z.ZodDefault<z.ZodLiteral<"stdio">>;
@@ -116,6 +271,82 @@ declare const ACPAgentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
116
271
  modelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
117
272
  defaultModelId: z.ZodOptional<z.ZodString>;
118
273
  environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
274
+ environmentIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
275
+ allowedCapabilities: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodString]>>>;
276
+ defaults: z.ZodOptional<z.ZodObject<{
277
+ model: z.ZodOptional<z.ZodObject<{
278
+ id: z.ZodOptional<z.ZodString>;
279
+ reasoningEffort: z.ZodOptional<z.ZodString>;
280
+ temperature: z.ZodOptional<z.ZodNumber>;
281
+ maxOutputTokens: z.ZodOptional<z.ZodNumber>;
282
+ }, z.core.$strict>>;
283
+ execution: z.ZodOptional<z.ZodObject<{
284
+ mode: z.ZodOptional<z.ZodEnum<{
285
+ auto: "auto";
286
+ shared: "shared";
287
+ user: "user";
288
+ task: "task";
289
+ }>>;
290
+ environmentId: z.ZodOptional<z.ZodString>;
291
+ resources: z.ZodOptional<z.ZodObject<{
292
+ cpu: z.ZodOptional<z.ZodNumber>;
293
+ memoryMiB: z.ZodOptional<z.ZodNumber>;
294
+ }, z.core.$strict>>;
295
+ }, z.core.$strict>>;
296
+ workspaceId: z.ZodOptional<z.ZodString>;
297
+ context: z.ZodOptional<z.ZodObject<{
298
+ fileIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
299
+ knowledgeBaseIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
300
+ skillIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
301
+ memory: z.ZodOptional<z.ZodObject<{
302
+ scope: z.ZodEnum<{
303
+ user: "user";
304
+ none: "none";
305
+ space: "space";
306
+ }>;
307
+ spaceId: z.ZodOptional<z.ZodString>;
308
+ write: z.ZodOptional<z.ZodEnum<{
309
+ none: "none";
310
+ confirm: "confirm";
311
+ "on-success": "on-success";
312
+ }>>;
313
+ }, z.core.$strict>>;
314
+ }, z.core.$strict>>;
315
+ tools: z.ZodOptional<z.ZodObject<{
316
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
317
+ }, z.core.$strict>>;
318
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodString>>;
319
+ permissions: z.ZodOptional<z.ZodObject<{
320
+ profile: z.ZodOptional<z.ZodEnum<{
321
+ "read-only": "read-only";
322
+ workspace: "workspace";
323
+ "full-access": "full-access";
324
+ }>>;
325
+ approval: z.ZodOptional<z.ZodEnum<{
326
+ never: "never";
327
+ "on-request": "on-request";
328
+ }>>;
329
+ ruleIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
330
+ }, z.core.$strict>>;
331
+ limits: z.ZodOptional<z.ZodObject<{
332
+ queueTimeoutMs: z.ZodOptional<z.ZodNumber>;
333
+ runTimeoutMs: z.ZodOptional<z.ZodNumber>;
334
+ approvalTimeoutMs: z.ZodOptional<z.ZodNumber>;
335
+ maxOutputBytes: z.ZodOptional<z.ZodNumber>;
336
+ }, z.core.$strict>>;
337
+ output: z.ZodOptional<z.ZodObject<{
338
+ format: z.ZodEnum<{
339
+ text: "text";
340
+ json: "json";
341
+ }>;
342
+ schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
343
+ }, z.core.$strict>>;
344
+ native: z.ZodOptional<z.ZodObject<{
345
+ adapter: z.ZodString;
346
+ options: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
347
+ }, z.core.$strict>>;
348
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
349
+ }, z.core.$strict>>;
119
350
  }, z.core.$strict>], "mode">;
120
351
  /**
121
352
  * 会话 Git 发布请求。
@@ -164,6 +395,82 @@ declare const ACPConfigSchema: z.ZodObject<{
164
395
  modelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
165
396
  defaultModelId: z.ZodOptional<z.ZodString>;
166
397
  environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
398
+ environmentIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
399
+ allowedCapabilities: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodString]>>>;
400
+ defaults: z.ZodOptional<z.ZodObject<{
401
+ model: z.ZodOptional<z.ZodObject<{
402
+ id: z.ZodOptional<z.ZodString>;
403
+ reasoningEffort: z.ZodOptional<z.ZodString>;
404
+ temperature: z.ZodOptional<z.ZodNumber>;
405
+ maxOutputTokens: z.ZodOptional<z.ZodNumber>;
406
+ }, z.core.$strict>>;
407
+ execution: z.ZodOptional<z.ZodObject<{
408
+ mode: z.ZodOptional<z.ZodEnum<{
409
+ auto: "auto";
410
+ shared: "shared";
411
+ user: "user";
412
+ task: "task";
413
+ }>>;
414
+ environmentId: z.ZodOptional<z.ZodString>;
415
+ resources: z.ZodOptional<z.ZodObject<{
416
+ cpu: z.ZodOptional<z.ZodNumber>;
417
+ memoryMiB: z.ZodOptional<z.ZodNumber>;
418
+ }, z.core.$strict>>;
419
+ }, z.core.$strict>>;
420
+ workspaceId: z.ZodOptional<z.ZodString>;
421
+ context: z.ZodOptional<z.ZodObject<{
422
+ fileIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
423
+ knowledgeBaseIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
424
+ skillIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
425
+ memory: z.ZodOptional<z.ZodObject<{
426
+ scope: z.ZodEnum<{
427
+ user: "user";
428
+ none: "none";
429
+ space: "space";
430
+ }>;
431
+ spaceId: z.ZodOptional<z.ZodString>;
432
+ write: z.ZodOptional<z.ZodEnum<{
433
+ none: "none";
434
+ confirm: "confirm";
435
+ "on-success": "on-success";
436
+ }>>;
437
+ }, z.core.$strict>>;
438
+ }, z.core.$strict>>;
439
+ tools: z.ZodOptional<z.ZodObject<{
440
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
441
+ }, z.core.$strict>>;
442
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodString>>;
443
+ permissions: z.ZodOptional<z.ZodObject<{
444
+ profile: z.ZodOptional<z.ZodEnum<{
445
+ "read-only": "read-only";
446
+ workspace: "workspace";
447
+ "full-access": "full-access";
448
+ }>>;
449
+ approval: z.ZodOptional<z.ZodEnum<{
450
+ never: "never";
451
+ "on-request": "on-request";
452
+ }>>;
453
+ ruleIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
454
+ }, z.core.$strict>>;
455
+ limits: z.ZodOptional<z.ZodObject<{
456
+ queueTimeoutMs: z.ZodOptional<z.ZodNumber>;
457
+ runTimeoutMs: z.ZodOptional<z.ZodNumber>;
458
+ approvalTimeoutMs: z.ZodOptional<z.ZodNumber>;
459
+ maxOutputBytes: z.ZodOptional<z.ZodNumber>;
460
+ }, z.core.$strict>>;
461
+ output: z.ZodOptional<z.ZodObject<{
462
+ format: z.ZodEnum<{
463
+ text: "text";
464
+ json: "json";
465
+ }>;
466
+ schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
467
+ }, z.core.$strict>>;
468
+ native: z.ZodOptional<z.ZodObject<{
469
+ adapter: z.ZodString;
470
+ options: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
471
+ }, z.core.$strict>>;
472
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
473
+ }, z.core.$strict>>;
167
474
  }, z.core.$strict>, z.ZodObject<{
168
475
  mode: z.ZodLiteral<"embedded">;
169
476
  transport: z.ZodDefault<z.ZodLiteral<"stdio">>;
@@ -176,6 +483,82 @@ declare const ACPConfigSchema: z.ZodObject<{
176
483
  modelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
177
484
  defaultModelId: z.ZodOptional<z.ZodString>;
178
485
  environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
486
+ environmentIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
487
+ allowedCapabilities: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodString]>>>;
488
+ defaults: z.ZodOptional<z.ZodObject<{
489
+ model: z.ZodOptional<z.ZodObject<{
490
+ id: z.ZodOptional<z.ZodString>;
491
+ reasoningEffort: z.ZodOptional<z.ZodString>;
492
+ temperature: z.ZodOptional<z.ZodNumber>;
493
+ maxOutputTokens: z.ZodOptional<z.ZodNumber>;
494
+ }, z.core.$strict>>;
495
+ execution: z.ZodOptional<z.ZodObject<{
496
+ mode: z.ZodOptional<z.ZodEnum<{
497
+ auto: "auto";
498
+ shared: "shared";
499
+ user: "user";
500
+ task: "task";
501
+ }>>;
502
+ environmentId: z.ZodOptional<z.ZodString>;
503
+ resources: z.ZodOptional<z.ZodObject<{
504
+ cpu: z.ZodOptional<z.ZodNumber>;
505
+ memoryMiB: z.ZodOptional<z.ZodNumber>;
506
+ }, z.core.$strict>>;
507
+ }, z.core.$strict>>;
508
+ workspaceId: z.ZodOptional<z.ZodString>;
509
+ context: z.ZodOptional<z.ZodObject<{
510
+ fileIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
511
+ knowledgeBaseIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
512
+ skillIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
513
+ memory: z.ZodOptional<z.ZodObject<{
514
+ scope: z.ZodEnum<{
515
+ user: "user";
516
+ none: "none";
517
+ space: "space";
518
+ }>;
519
+ spaceId: z.ZodOptional<z.ZodString>;
520
+ write: z.ZodOptional<z.ZodEnum<{
521
+ none: "none";
522
+ confirm: "confirm";
523
+ "on-success": "on-success";
524
+ }>>;
525
+ }, z.core.$strict>>;
526
+ }, z.core.$strict>>;
527
+ tools: z.ZodOptional<z.ZodObject<{
528
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
529
+ }, z.core.$strict>>;
530
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodString>>;
531
+ permissions: z.ZodOptional<z.ZodObject<{
532
+ profile: z.ZodOptional<z.ZodEnum<{
533
+ "read-only": "read-only";
534
+ workspace: "workspace";
535
+ "full-access": "full-access";
536
+ }>>;
537
+ approval: z.ZodOptional<z.ZodEnum<{
538
+ never: "never";
539
+ "on-request": "on-request";
540
+ }>>;
541
+ ruleIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
542
+ }, z.core.$strict>>;
543
+ limits: z.ZodOptional<z.ZodObject<{
544
+ queueTimeoutMs: z.ZodOptional<z.ZodNumber>;
545
+ runTimeoutMs: z.ZodOptional<z.ZodNumber>;
546
+ approvalTimeoutMs: z.ZodOptional<z.ZodNumber>;
547
+ maxOutputBytes: z.ZodOptional<z.ZodNumber>;
548
+ }, z.core.$strict>>;
549
+ output: z.ZodOptional<z.ZodObject<{
550
+ format: z.ZodEnum<{
551
+ text: "text";
552
+ json: "json";
553
+ }>;
554
+ schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
555
+ }, z.core.$strict>>;
556
+ native: z.ZodOptional<z.ZodObject<{
557
+ adapter: z.ZodString;
558
+ options: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
559
+ }, z.core.$strict>>;
560
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
561
+ }, z.core.$strict>>;
179
562
  }, z.core.$strict>, z.ZodObject<{
180
563
  mode: z.ZodLiteral<"builtin-service">;
181
564
  transport: z.ZodDefault<z.ZodLiteral<"stdio">>;
@@ -194,6 +577,82 @@ declare const ACPConfigSchema: z.ZodObject<{
194
577
  modelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
195
578
  defaultModelId: z.ZodOptional<z.ZodString>;
196
579
  environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
580
+ environmentIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
581
+ allowedCapabilities: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodString]>>>;
582
+ defaults: z.ZodOptional<z.ZodObject<{
583
+ model: z.ZodOptional<z.ZodObject<{
584
+ id: z.ZodOptional<z.ZodString>;
585
+ reasoningEffort: z.ZodOptional<z.ZodString>;
586
+ temperature: z.ZodOptional<z.ZodNumber>;
587
+ maxOutputTokens: z.ZodOptional<z.ZodNumber>;
588
+ }, z.core.$strict>>;
589
+ execution: z.ZodOptional<z.ZodObject<{
590
+ mode: z.ZodOptional<z.ZodEnum<{
591
+ auto: "auto";
592
+ shared: "shared";
593
+ user: "user";
594
+ task: "task";
595
+ }>>;
596
+ environmentId: z.ZodOptional<z.ZodString>;
597
+ resources: z.ZodOptional<z.ZodObject<{
598
+ cpu: z.ZodOptional<z.ZodNumber>;
599
+ memoryMiB: z.ZodOptional<z.ZodNumber>;
600
+ }, z.core.$strict>>;
601
+ }, z.core.$strict>>;
602
+ workspaceId: z.ZodOptional<z.ZodString>;
603
+ context: z.ZodOptional<z.ZodObject<{
604
+ fileIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
605
+ knowledgeBaseIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
606
+ skillIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
607
+ memory: z.ZodOptional<z.ZodObject<{
608
+ scope: z.ZodEnum<{
609
+ user: "user";
610
+ none: "none";
611
+ space: "space";
612
+ }>;
613
+ spaceId: z.ZodOptional<z.ZodString>;
614
+ write: z.ZodOptional<z.ZodEnum<{
615
+ none: "none";
616
+ confirm: "confirm";
617
+ "on-success": "on-success";
618
+ }>>;
619
+ }, z.core.$strict>>;
620
+ }, z.core.$strict>>;
621
+ tools: z.ZodOptional<z.ZodObject<{
622
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
623
+ }, z.core.$strict>>;
624
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodString>>;
625
+ permissions: z.ZodOptional<z.ZodObject<{
626
+ profile: z.ZodOptional<z.ZodEnum<{
627
+ "read-only": "read-only";
628
+ workspace: "workspace";
629
+ "full-access": "full-access";
630
+ }>>;
631
+ approval: z.ZodOptional<z.ZodEnum<{
632
+ never: "never";
633
+ "on-request": "on-request";
634
+ }>>;
635
+ ruleIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
636
+ }, z.core.$strict>>;
637
+ limits: z.ZodOptional<z.ZodObject<{
638
+ queueTimeoutMs: z.ZodOptional<z.ZodNumber>;
639
+ runTimeoutMs: z.ZodOptional<z.ZodNumber>;
640
+ approvalTimeoutMs: z.ZodOptional<z.ZodNumber>;
641
+ maxOutputBytes: z.ZodOptional<z.ZodNumber>;
642
+ }, z.core.$strict>>;
643
+ output: z.ZodOptional<z.ZodObject<{
644
+ format: z.ZodEnum<{
645
+ text: "text";
646
+ json: "json";
647
+ }>;
648
+ schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
649
+ }, z.core.$strict>>;
650
+ native: z.ZodOptional<z.ZodObject<{
651
+ adapter: z.ZodString;
652
+ options: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
653
+ }, z.core.$strict>>;
654
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
655
+ }, z.core.$strict>>;
197
656
  }, z.core.$strict>], "mode">>>;
198
657
  workspaces: z.ZodDefault<z.ZodArray<z.ZodObject<{
199
658
  id: z.ZodString;
@@ -224,6 +683,7 @@ declare const ACPConfigSchema: z.ZodObject<{
224
683
  cancelTimeout: z.ZodDefault<z.ZodNumber>;
225
684
  maxContentBytes: z.ZodDefault<z.ZodNumber>;
226
685
  maxPendingEvents: z.ZodDefault<z.ZodNumber>;
686
+ workerIdleTimeoutMs: z.ZodDefault<z.ZodNumber>;
227
687
  }, z.core.$strict>;
228
688
  /**
229
689
  * ACP 初始化配置,已填充超时和只读清单默认值。
@@ -289,6 +749,8 @@ interface StoreScope {
289
749
  interface WhereOperator<V> {
290
750
  /** 值在给定列表中(IN 语义) */
291
751
  $in?: V[];
752
+ /** 不等于该值;缺失的字段也匹配。 */
753
+ $ne?: V;
292
754
  /** 大于等于 */
293
755
  $gte?: V;
294
756
  /** 大于 */
@@ -361,6 +823,8 @@ interface StoreFilter<T> {
361
823
  };
362
824
  /** 数量限制 */
363
825
  limit?: number;
826
+ /** 按关系记录最后写入时间过滤,主要用于保留期维护。 */
827
+ updatedBefore?: number;
364
828
  }
365
829
  /**
366
830
  * 分页查询结果
@@ -411,6 +875,10 @@ interface AIRelStoreOptions {
411
875
  * SQLite / MySQL 不建索引,`scope` 过滤退回调用方内存匹配(当前行为不变)。
412
876
  */
413
877
  hasScopeIndex?: boolean;
878
+ /** 为存在全局配额的 Store 启用事务串行写入。 */
879
+ serializeWrites?: boolean;
880
+ /** 为按最后更新时间读取记录键的维护任务建索引。 */
881
+ hasUpdatedAtIndex?: boolean;
414
882
  }
415
883
  /**
416
884
  * 同一次读取的记录及不可复用的存储版本。
@@ -475,6 +943,19 @@ interface AIRelStoreCompareAndSwap<T> {
475
943
  * ```
476
944
  */
477
945
  interface AIRelStore<T> {
946
+ /** 在共享存储事务中串行执行配额读取和写入,回调使用事务内 Store。 */
947
+ withWriteLock?: <R>(write: (store: AIRelStore<T>) => Promise<R>) => Promise<R>;
948
+ /** 按更新时间和主键升序获取小批记录键,避免加载业务 JSON。 */
949
+ queryKeys?: (filter: StoreFilter<T>, cursor?: {
950
+ updatedAt: number;
951
+ id: string;
952
+ }) => Promise<Array<{
953
+ id: string;
954
+ updatedAt: number;
955
+ version: string;
956
+ }>>;
957
+ /** 只删除指定版本,防止过期维护删除同时更新的记录。 */
958
+ removeIfUnchanged?: (id: string, version: string) => Promise<boolean>;
478
959
  /**
479
960
  * 存储端 Unix 毫秒时钟;共享租约以它计算期限,不依赖各节点墙钟同步。
480
961
  */
@@ -1644,7 +2125,7 @@ interface ChatRecord {
1644
2125
  /**
1645
2126
  * 结构化输出请求
1646
2127
  *
1647
- * 给定 Zod schema,让模型返回严格符合结构的 JSON(内部使用 `json_schema` response_format),
2128
+ * 给定 Zod schema,要求模型返回 JSON,并在应用本地验证结构。
1648
2129
  * 解析失败时自动带错误修复重试,避免调用方手写 `JSON.parse` 的不稳定性。
1649
2130
  *
1650
2131
  * @example
@@ -1674,6 +2155,8 @@ interface GenerateObjectRequest<T> {
1674
2155
  tempModel?: TempModelConfig;
1675
2156
  /** schema 名称(用于 json_schema response_format,默认 `result`) */
1676
2157
  schemaName?: string;
2158
+ /** 上游响应格式,默认 `json_schema`。只支持 JSON 模式的 Chat 网关可使用 `json_object`,本地仍会校验 schema。 */
2159
+ responseFormat?: 'json_schema' | 'json_object';
1677
2160
  /** 解析失败时的修复重试次数(默认 1) */
1678
2161
  maxRepairs?: number;
1679
2162
  /** 取消信号 */
@@ -1729,7 +2212,7 @@ interface LLMOperations {
1729
2212
  /**
1730
2213
  * 结构化输出:按 Zod schema 约束模型输出并解析为对象
1731
2214
  *
1732
- * 内部使用 `json_schema` response_format 约束输出,解析/校验失败时自动带错误提示重试。
2215
+ * 默认使用 `json_schema` 约束输出。使用 `json_object` 时由提示提供 Schema,两种模式均本地校验并按配置修复重试。
1733
2216
  *
1734
2217
  * @param request - 包含 schema、messages 及可选模型/修复次数等
1735
2218
  * @returns 符合 schema 的对象;多次重试仍无法解析时返回 `INVALID_REQUEST`
@@ -3368,8 +3851,8 @@ declare const OptionalSecretSchema: z.ZodOptional<z.ZodPipe<z.ZodNullable<z.ZodS
3368
3851
  */
3369
3852
  declare const ModelScenarioSchema: z.ZodEnum<{
3370
3853
  default: "default";
3371
- chat: "chat";
3372
3854
  reasoning: "reasoning";
3855
+ chat: "chat";
3373
3856
  plan: "plan";
3374
3857
  execute: "execute";
3375
3858
  extraction: "extraction";
@@ -3597,8 +4080,8 @@ declare const LLMConfigSchema: z.ZodObject<{
3597
4080
  }, z.core.$strict>>>;
3598
4081
  scenarios: z.ZodOptional<z.ZodObject<{
3599
4082
  default: z.ZodOptional<z.ZodString>;
3600
- chat: z.ZodOptional<z.ZodString>;
3601
4083
  reasoning: z.ZodOptional<z.ZodString>;
4084
+ chat: z.ZodOptional<z.ZodString>;
3602
4085
  plan: z.ZodOptional<z.ZodString>;
3603
4086
  execute: z.ZodOptional<z.ZodString>;
3604
4087
  extraction: z.ZodOptional<z.ZodString>;
@@ -3797,12 +4280,21 @@ declare const MCPExternalServerSchema: z.ZodObject<{
3797
4280
  http: "http";
3798
4281
  stdio: "stdio";
3799
4282
  sse: "sse";
4283
+ job: "job";
3800
4284
  }>;
4285
+ environmentId: z.ZodOptional<z.ZodString>;
3801
4286
  command: z.ZodOptional<z.ZodString>;
3802
4287
  args: z.ZodDefault<z.ZodArray<z.ZodString>>;
3803
4288
  url: z.ZodOptional<z.ZodURL>;
3804
4289
  environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
3805
4290
  headerEnv: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
4291
+ allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
4292
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
4293
+ pool: z.ZodOptional<z.ZodObject<{
4294
+ maxRunning: z.ZodNumber;
4295
+ minReady: z.ZodOptional<z.ZodNumber>;
4296
+ maxTotal: z.ZodOptional<z.ZodNumber>;
4297
+ }, z.core.$strict>>;
3806
4298
  }, z.core.$strict>;
3807
4299
  /**
3808
4300
  * 外部 MCP 服务配置。
@@ -3839,12 +4331,21 @@ declare const MCPConfigSchema: z.ZodObject<{
3839
4331
  http: "http";
3840
4332
  stdio: "stdio";
3841
4333
  sse: "sse";
4334
+ job: "job";
3842
4335
  }>;
4336
+ environmentId: z.ZodOptional<z.ZodString>;
3843
4337
  command: z.ZodOptional<z.ZodString>;
3844
4338
  args: z.ZodDefault<z.ZodArray<z.ZodString>>;
3845
4339
  url: z.ZodOptional<z.ZodURL>;
3846
4340
  environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
3847
4341
  headerEnv: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
4342
+ allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
4343
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
4344
+ pool: z.ZodOptional<z.ZodObject<{
4345
+ maxRunning: z.ZodNumber;
4346
+ minReady: z.ZodOptional<z.ZodNumber>;
4347
+ maxTotal: z.ZodOptional<z.ZodNumber>;
4348
+ }, z.core.$strict>>;
3848
4349
  }, z.core.$strict>>>;
3849
4350
  server: z.ZodOptional<z.ZodObject<{
3850
4351
  name: z.ZodString;
@@ -4834,6 +5335,82 @@ declare const AIConfigSchema: z.ZodObject<{
4834
5335
  modelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
4835
5336
  defaultModelId: z.ZodOptional<z.ZodString>;
4836
5337
  environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
5338
+ environmentIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
5339
+ allowedCapabilities: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodString]>>>;
5340
+ defaults: z.ZodOptional<z.ZodObject<{
5341
+ model: z.ZodOptional<z.ZodObject<{
5342
+ id: z.ZodOptional<z.ZodString>;
5343
+ reasoningEffort: z.ZodOptional<z.ZodString>;
5344
+ temperature: z.ZodOptional<z.ZodNumber>;
5345
+ maxOutputTokens: z.ZodOptional<z.ZodNumber>;
5346
+ }, z.core.$strict>>;
5347
+ execution: z.ZodOptional<z.ZodObject<{
5348
+ mode: z.ZodOptional<z.ZodEnum<{
5349
+ auto: "auto";
5350
+ shared: "shared";
5351
+ user: "user";
5352
+ task: "task";
5353
+ }>>;
5354
+ environmentId: z.ZodOptional<z.ZodString>;
5355
+ resources: z.ZodOptional<z.ZodObject<{
5356
+ cpu: z.ZodOptional<z.ZodNumber>;
5357
+ memoryMiB: z.ZodOptional<z.ZodNumber>;
5358
+ }, z.core.$strict>>;
5359
+ }, z.core.$strict>>;
5360
+ workspaceId: z.ZodOptional<z.ZodString>;
5361
+ context: z.ZodOptional<z.ZodObject<{
5362
+ fileIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
5363
+ knowledgeBaseIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
5364
+ skillIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
5365
+ memory: z.ZodOptional<z.ZodObject<{
5366
+ scope: z.ZodEnum<{
5367
+ user: "user";
5368
+ none: "none";
5369
+ space: "space";
5370
+ }>;
5371
+ spaceId: z.ZodOptional<z.ZodString>;
5372
+ write: z.ZodOptional<z.ZodEnum<{
5373
+ none: "none";
5374
+ confirm: "confirm";
5375
+ "on-success": "on-success";
5376
+ }>>;
5377
+ }, z.core.$strict>>;
5378
+ }, z.core.$strict>>;
5379
+ tools: z.ZodOptional<z.ZodObject<{
5380
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
5381
+ }, z.core.$strict>>;
5382
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodString>>;
5383
+ permissions: z.ZodOptional<z.ZodObject<{
5384
+ profile: z.ZodOptional<z.ZodEnum<{
5385
+ "read-only": "read-only";
5386
+ workspace: "workspace";
5387
+ "full-access": "full-access";
5388
+ }>>;
5389
+ approval: z.ZodOptional<z.ZodEnum<{
5390
+ never: "never";
5391
+ "on-request": "on-request";
5392
+ }>>;
5393
+ ruleIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
5394
+ }, z.core.$strict>>;
5395
+ limits: z.ZodOptional<z.ZodObject<{
5396
+ queueTimeoutMs: z.ZodOptional<z.ZodNumber>;
5397
+ runTimeoutMs: z.ZodOptional<z.ZodNumber>;
5398
+ approvalTimeoutMs: z.ZodOptional<z.ZodNumber>;
5399
+ maxOutputBytes: z.ZodOptional<z.ZodNumber>;
5400
+ }, z.core.$strict>>;
5401
+ output: z.ZodOptional<z.ZodObject<{
5402
+ format: z.ZodEnum<{
5403
+ text: "text";
5404
+ json: "json";
5405
+ }>;
5406
+ schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
5407
+ }, z.core.$strict>>;
5408
+ native: z.ZodOptional<z.ZodObject<{
5409
+ adapter: z.ZodString;
5410
+ options: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
5411
+ }, z.core.$strict>>;
5412
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
5413
+ }, z.core.$strict>>;
4837
5414
  }, z.core.$strict>, z.ZodObject<{
4838
5415
  mode: z.ZodLiteral<"embedded">;
4839
5416
  transport: z.ZodDefault<z.ZodLiteral<"stdio">>;
@@ -4846,6 +5423,82 @@ declare const AIConfigSchema: z.ZodObject<{
4846
5423
  modelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
4847
5424
  defaultModelId: z.ZodOptional<z.ZodString>;
4848
5425
  environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
5426
+ environmentIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
5427
+ allowedCapabilities: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodString]>>>;
5428
+ defaults: z.ZodOptional<z.ZodObject<{
5429
+ model: z.ZodOptional<z.ZodObject<{
5430
+ id: z.ZodOptional<z.ZodString>;
5431
+ reasoningEffort: z.ZodOptional<z.ZodString>;
5432
+ temperature: z.ZodOptional<z.ZodNumber>;
5433
+ maxOutputTokens: z.ZodOptional<z.ZodNumber>;
5434
+ }, z.core.$strict>>;
5435
+ execution: z.ZodOptional<z.ZodObject<{
5436
+ mode: z.ZodOptional<z.ZodEnum<{
5437
+ auto: "auto";
5438
+ shared: "shared";
5439
+ user: "user";
5440
+ task: "task";
5441
+ }>>;
5442
+ environmentId: z.ZodOptional<z.ZodString>;
5443
+ resources: z.ZodOptional<z.ZodObject<{
5444
+ cpu: z.ZodOptional<z.ZodNumber>;
5445
+ memoryMiB: z.ZodOptional<z.ZodNumber>;
5446
+ }, z.core.$strict>>;
5447
+ }, z.core.$strict>>;
5448
+ workspaceId: z.ZodOptional<z.ZodString>;
5449
+ context: z.ZodOptional<z.ZodObject<{
5450
+ fileIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
5451
+ knowledgeBaseIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
5452
+ skillIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
5453
+ memory: z.ZodOptional<z.ZodObject<{
5454
+ scope: z.ZodEnum<{
5455
+ user: "user";
5456
+ none: "none";
5457
+ space: "space";
5458
+ }>;
5459
+ spaceId: z.ZodOptional<z.ZodString>;
5460
+ write: z.ZodOptional<z.ZodEnum<{
5461
+ none: "none";
5462
+ confirm: "confirm";
5463
+ "on-success": "on-success";
5464
+ }>>;
5465
+ }, z.core.$strict>>;
5466
+ }, z.core.$strict>>;
5467
+ tools: z.ZodOptional<z.ZodObject<{
5468
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
5469
+ }, z.core.$strict>>;
5470
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodString>>;
5471
+ permissions: z.ZodOptional<z.ZodObject<{
5472
+ profile: z.ZodOptional<z.ZodEnum<{
5473
+ "read-only": "read-only";
5474
+ workspace: "workspace";
5475
+ "full-access": "full-access";
5476
+ }>>;
5477
+ approval: z.ZodOptional<z.ZodEnum<{
5478
+ never: "never";
5479
+ "on-request": "on-request";
5480
+ }>>;
5481
+ ruleIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
5482
+ }, z.core.$strict>>;
5483
+ limits: z.ZodOptional<z.ZodObject<{
5484
+ queueTimeoutMs: z.ZodOptional<z.ZodNumber>;
5485
+ runTimeoutMs: z.ZodOptional<z.ZodNumber>;
5486
+ approvalTimeoutMs: z.ZodOptional<z.ZodNumber>;
5487
+ maxOutputBytes: z.ZodOptional<z.ZodNumber>;
5488
+ }, z.core.$strict>>;
5489
+ output: z.ZodOptional<z.ZodObject<{
5490
+ format: z.ZodEnum<{
5491
+ text: "text";
5492
+ json: "json";
5493
+ }>;
5494
+ schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
5495
+ }, z.core.$strict>>;
5496
+ native: z.ZodOptional<z.ZodObject<{
5497
+ adapter: z.ZodString;
5498
+ options: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
5499
+ }, z.core.$strict>>;
5500
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
5501
+ }, z.core.$strict>>;
4849
5502
  }, z.core.$strict>, z.ZodObject<{
4850
5503
  mode: z.ZodLiteral<"builtin-service">;
4851
5504
  transport: z.ZodDefault<z.ZodLiteral<"stdio">>;
@@ -4864,6 +5517,82 @@ declare const AIConfigSchema: z.ZodObject<{
4864
5517
  modelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
4865
5518
  defaultModelId: z.ZodOptional<z.ZodString>;
4866
5519
  environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
5520
+ environmentIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
5521
+ allowedCapabilities: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodString]>>>;
5522
+ defaults: z.ZodOptional<z.ZodObject<{
5523
+ model: z.ZodOptional<z.ZodObject<{
5524
+ id: z.ZodOptional<z.ZodString>;
5525
+ reasoningEffort: z.ZodOptional<z.ZodString>;
5526
+ temperature: z.ZodOptional<z.ZodNumber>;
5527
+ maxOutputTokens: z.ZodOptional<z.ZodNumber>;
5528
+ }, z.core.$strict>>;
5529
+ execution: z.ZodOptional<z.ZodObject<{
5530
+ mode: z.ZodOptional<z.ZodEnum<{
5531
+ auto: "auto";
5532
+ shared: "shared";
5533
+ user: "user";
5534
+ task: "task";
5535
+ }>>;
5536
+ environmentId: z.ZodOptional<z.ZodString>;
5537
+ resources: z.ZodOptional<z.ZodObject<{
5538
+ cpu: z.ZodOptional<z.ZodNumber>;
5539
+ memoryMiB: z.ZodOptional<z.ZodNumber>;
5540
+ }, z.core.$strict>>;
5541
+ }, z.core.$strict>>;
5542
+ workspaceId: z.ZodOptional<z.ZodString>;
5543
+ context: z.ZodOptional<z.ZodObject<{
5544
+ fileIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
5545
+ knowledgeBaseIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
5546
+ skillIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
5547
+ memory: z.ZodOptional<z.ZodObject<{
5548
+ scope: z.ZodEnum<{
5549
+ user: "user";
5550
+ none: "none";
5551
+ space: "space";
5552
+ }>;
5553
+ spaceId: z.ZodOptional<z.ZodString>;
5554
+ write: z.ZodOptional<z.ZodEnum<{
5555
+ none: "none";
5556
+ confirm: "confirm";
5557
+ "on-success": "on-success";
5558
+ }>>;
5559
+ }, z.core.$strict>>;
5560
+ }, z.core.$strict>>;
5561
+ tools: z.ZodOptional<z.ZodObject<{
5562
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
5563
+ }, z.core.$strict>>;
5564
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodString>>;
5565
+ permissions: z.ZodOptional<z.ZodObject<{
5566
+ profile: z.ZodOptional<z.ZodEnum<{
5567
+ "read-only": "read-only";
5568
+ workspace: "workspace";
5569
+ "full-access": "full-access";
5570
+ }>>;
5571
+ approval: z.ZodOptional<z.ZodEnum<{
5572
+ never: "never";
5573
+ "on-request": "on-request";
5574
+ }>>;
5575
+ ruleIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
5576
+ }, z.core.$strict>>;
5577
+ limits: z.ZodOptional<z.ZodObject<{
5578
+ queueTimeoutMs: z.ZodOptional<z.ZodNumber>;
5579
+ runTimeoutMs: z.ZodOptional<z.ZodNumber>;
5580
+ approvalTimeoutMs: z.ZodOptional<z.ZodNumber>;
5581
+ maxOutputBytes: z.ZodOptional<z.ZodNumber>;
5582
+ }, z.core.$strict>>;
5583
+ output: z.ZodOptional<z.ZodObject<{
5584
+ format: z.ZodEnum<{
5585
+ text: "text";
5586
+ json: "json";
5587
+ }>;
5588
+ schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
5589
+ }, z.core.$strict>>;
5590
+ native: z.ZodOptional<z.ZodObject<{
5591
+ adapter: z.ZodString;
5592
+ options: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
5593
+ }, z.core.$strict>>;
5594
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
5595
+ }, z.core.$strict>>;
4867
5596
  }, z.core.$strict>], "mode">>>;
4868
5597
  workspaces: z.ZodDefault<z.ZodArray<z.ZodObject<{
4869
5598
  id: z.ZodString;
@@ -4894,6 +5623,7 @@ declare const AIConfigSchema: z.ZodObject<{
4894
5623
  cancelTimeout: z.ZodDefault<z.ZodNumber>;
4895
5624
  maxContentBytes: z.ZodDefault<z.ZodNumber>;
4896
5625
  maxPendingEvents: z.ZodDefault<z.ZodNumber>;
5626
+ workerIdleTimeoutMs: z.ZodDefault<z.ZodNumber>;
4897
5627
  }, z.core.$strict>>;
4898
5628
  llm: z.ZodDefault<z.ZodObject<{
4899
5629
  apiKey: z.ZodOptional<z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<string | undefined, string | null>>>;
@@ -4945,8 +5675,8 @@ declare const AIConfigSchema: z.ZodObject<{
4945
5675
  }, z.core.$strict>>>;
4946
5676
  scenarios: z.ZodOptional<z.ZodObject<{
4947
5677
  default: z.ZodOptional<z.ZodString>;
4948
- chat: z.ZodOptional<z.ZodString>;
4949
5678
  reasoning: z.ZodOptional<z.ZodString>;
5679
+ chat: z.ZodOptional<z.ZodString>;
4950
5680
  plan: z.ZodOptional<z.ZodString>;
4951
5681
  execute: z.ZodOptional<z.ZodString>;
4952
5682
  extraction: z.ZodOptional<z.ZodString>;
@@ -4965,12 +5695,21 @@ declare const AIConfigSchema: z.ZodObject<{
4965
5695
  http: "http";
4966
5696
  stdio: "stdio";
4967
5697
  sse: "sse";
5698
+ job: "job";
4968
5699
  }>;
5700
+ environmentId: z.ZodOptional<z.ZodString>;
4969
5701
  command: z.ZodOptional<z.ZodString>;
4970
5702
  args: z.ZodDefault<z.ZodArray<z.ZodString>>;
4971
5703
  url: z.ZodOptional<z.ZodURL>;
4972
5704
  environmentRefs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
4973
5705
  headerEnv: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
5706
+ allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
5707
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
5708
+ pool: z.ZodOptional<z.ZodObject<{
5709
+ maxRunning: z.ZodNumber;
5710
+ minReady: z.ZodOptional<z.ZodNumber>;
5711
+ maxTotal: z.ZodOptional<z.ZodNumber>;
5712
+ }, z.core.$strict>>;
4974
5713
  }, z.core.$strict>>>;
4975
5714
  server: z.ZodOptional<z.ZodObject<{
4976
5715
  name: z.ZodString;
@@ -5530,6 +6269,189 @@ interface A2ACallResult {
5530
6269
  responseParts?: unknown[];
5531
6270
  }
5532
6271
 
6272
+ /**
6273
+ * 计划或持续会话的参数。
6274
+ * @example 模块内部上下文
6275
+ * ```ts
6276
+ * const request = platformRequestSchema.parse({ agentId: 'assistant' })
6277
+ * ```
6278
+ */
6279
+ declare const platformRequestSchema: z.ZodObject<{
6280
+ model: z.ZodOptional<z.ZodObject<{
6281
+ id: z.ZodOptional<z.ZodString>;
6282
+ reasoningEffort: z.ZodOptional<z.ZodString>;
6283
+ temperature: z.ZodOptional<z.ZodNumber>;
6284
+ maxOutputTokens: z.ZodOptional<z.ZodNumber>;
6285
+ }, z.core.$strict>>;
6286
+ execution: z.ZodOptional<z.ZodObject<{
6287
+ mode: z.ZodOptional<z.ZodEnum<{
6288
+ auto: "auto";
6289
+ shared: "shared";
6290
+ user: "user";
6291
+ task: "task";
6292
+ }>>;
6293
+ environmentId: z.ZodOptional<z.ZodString>;
6294
+ resources: z.ZodOptional<z.ZodObject<{
6295
+ cpu: z.ZodOptional<z.ZodNumber>;
6296
+ memoryMiB: z.ZodOptional<z.ZodNumber>;
6297
+ }, z.core.$strict>>;
6298
+ }, z.core.$strict>>;
6299
+ workspaceId: z.ZodOptional<z.ZodString>;
6300
+ context: z.ZodOptional<z.ZodObject<{
6301
+ fileIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
6302
+ knowledgeBaseIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
6303
+ skillIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
6304
+ memory: z.ZodOptional<z.ZodObject<{
6305
+ scope: z.ZodEnum<{
6306
+ user: "user";
6307
+ none: "none";
6308
+ space: "space";
6309
+ }>;
6310
+ spaceId: z.ZodOptional<z.ZodString>;
6311
+ write: z.ZodOptional<z.ZodEnum<{
6312
+ none: "none";
6313
+ confirm: "confirm";
6314
+ "on-success": "on-success";
6315
+ }>>;
6316
+ }, z.core.$strict>>;
6317
+ }, z.core.$strict>>;
6318
+ tools: z.ZodOptional<z.ZodObject<{
6319
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
6320
+ }, z.core.$strict>>;
6321
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodString>>;
6322
+ permissions: z.ZodOptional<z.ZodObject<{
6323
+ profile: z.ZodOptional<z.ZodEnum<{
6324
+ "read-only": "read-only";
6325
+ workspace: "workspace";
6326
+ "full-access": "full-access";
6327
+ }>>;
6328
+ approval: z.ZodOptional<z.ZodEnum<{
6329
+ never: "never";
6330
+ "on-request": "on-request";
6331
+ }>>;
6332
+ ruleIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
6333
+ }, z.core.$strict>>;
6334
+ limits: z.ZodOptional<z.ZodObject<{
6335
+ queueTimeoutMs: z.ZodOptional<z.ZodNumber>;
6336
+ runTimeoutMs: z.ZodOptional<z.ZodNumber>;
6337
+ approvalTimeoutMs: z.ZodOptional<z.ZodNumber>;
6338
+ maxOutputBytes: z.ZodOptional<z.ZodNumber>;
6339
+ }, z.core.$strict>>;
6340
+ output: z.ZodOptional<z.ZodObject<{
6341
+ format: z.ZodEnum<{
6342
+ text: "text";
6343
+ json: "json";
6344
+ }>;
6345
+ schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
6346
+ }, z.core.$strict>>;
6347
+ native: z.ZodOptional<z.ZodObject<{
6348
+ adapter: z.ZodString;
6349
+ options: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
6350
+ }, z.core.$strict>>;
6351
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
6352
+ agentId: z.ZodString;
6353
+ }, z.core.$strict>;
6354
+
6355
+ /**
6356
+ * 应用核验主体和任务所请求的高权限选项。
6357
+ * @example
6358
+ * ```ts
6359
+ * import type { ACPPlatformPolicy } from '@h-ai/ai'
6360
+ * const policy: ACPPlatformPolicy = { allowFullAccess: scope => scope.userId === 'operator' }
6361
+ * ```
6362
+ */
6363
+ interface ACPPlatformPolicy {
6364
+ /** 只接受已由应用确认的主体和 Agent。默认禁止完全访问。 */
6365
+ allowFullAccess?: (scope: RunnerScope, agentId: string) => boolean | Promise<boolean>;
6366
+ /** 自动模式下明确允许同一用户复用独占 Worker。 */
6367
+ preferUserWorker?: (scope: RunnerScope, agentId: string) => boolean | Promise<boolean>;
6368
+ /** 检查当前主体是否能使用选定工具,每轮重新校验。 */
6369
+ allowTools?: (scope: RunnerScope, agentId: string, toolIds: readonly string[]) => boolean | Promise<boolean>;
6370
+ /** 创建应用控制的 HTTP MCP 入口。传入 Worker 生命周期,返回 signal 通知绑定到期或撤销。 */
6371
+ bindTools?: (scope: RunnerScope, sessionId: string, toolIds: readonly string[], signal: AbortSignal) => Promise<{
6372
+ servers: McpServer[];
6373
+ revoke: () => void | Promise<void>;
6374
+ signal?: AbortSignal;
6375
+ }>;
6376
+ /** 在计划和执行时验证知识库、文件与记忆选择的权限。 */
6377
+ allowContext?: (scope: RunnerScope, agentId: string, context: NonNullable<ACPPlatformRequest['context']>) => boolean | Promise<boolean>;
6378
+ /** 以当前主体检查只读工作区快照的访问权限。 */
6379
+ allowWorkspace?: (scope: RunnerScope, workspaceId: string) => boolean | Promise<boolean>;
6380
+ /** 在执行节点读取已授权的工作区文件。最多 8 个平铺普通文件,总量受执行环境和 16 MiB 上限约束。 */
6381
+ resolveWorkspace?: (scope: RunnerScope, workspaceId: string, signal: AbortSignal) => Promise<Readonly<Record<string, Uint8Array>>>;
6382
+ /** 在当前轮次装配经授权的知识片段、记忆及附件。只读;不共享宿主路径。 */
6383
+ resolveContext?: (scope: RunnerScope, request: ACPPlatformRequest, prompt: readonly ContentBlock[], signal: AbortSignal) => Promise<ContentBlock[]>;
6384
+ /** 提交用户记忆。应用按 turnId 幂等写入,或登记人工确认。 */
6385
+ commitMemory?: (input: {
6386
+ scope: RunnerScope;
6387
+ sessionId: string;
6388
+ turnId: string;
6389
+ context: NonNullable<ACPPlatformRequest['context']>;
6390
+ text: string;
6391
+ }, signal: AbortSignal) => Promise<void>;
6392
+ /** 解析已授权技能的正文或原生指令。 */
6393
+ resolveSkills?: (scope: RunnerScope, agentId: string, skillIds: readonly string[], signal: AbortSignal) => Promise<ContentBlock[]>;
6394
+ /** 核对当前 ACL 和原生操作,返回绑定真实对象与操作的规则键。返回 undefined 时拒绝。 */
6395
+ resolvePermission?: (scope: RunnerScope, sessionId: string, tool: RequestPermissionRequest['toolCall']) => {
6396
+ key: string;
6397
+ summary: string;
6398
+ } | undefined | Promise<{
6399
+ key: string;
6400
+ summary: string;
6401
+ } | undefined>;
6402
+ }
6403
+ /**
6404
+ * 审批有效期或拒绝本次操作。
6405
+ * @example
6406
+ * ```ts
6407
+ * import type { ACPApprovalDecision } from '@h-ai/ai'
6408
+ * const decision: ACPApprovalDecision = 'allow-once'
6409
+ * ```
6410
+ */
6411
+ type ACPApprovalDecision = 'allow-once' | 'allow-session' | 'always-allow' | 'deny';
6412
+ /**
6413
+ * 受管会话及计划的调用参数。
6414
+ * @example
6415
+ * ```ts
6416
+ * import type { ACPPlatformRequest } from '@h-ai/ai'
6417
+ * const request: ACPPlatformRequest = { agentId: 'assistant', execution: { mode: 'auto' } }
6418
+ * ```
6419
+ */
6420
+ type ACPPlatformRequest = z.input<typeof platformRequestSchema>;
6421
+ /**
6422
+ * 一次请求的业务输入。
6423
+ * @example
6424
+ * ```ts
6425
+ * import type { ACPRunRequest } from '@h-ai/ai'
6426
+ * const request: ACPRunRequest = { agentId: 'assistant', prompt: '总结', idempotencyKey: 'message-1' }
6427
+ * ```
6428
+ */
6429
+ type ACPRunRequest = ACPPlatformRequest & {
6430
+ prompt: string | ContentBlock[];
6431
+ idempotencyKey?: string;
6432
+ };
6433
+ /**
6434
+ * API 侧的观察器和显式取消信号。
6435
+ * @example
6436
+ * ```ts
6437
+ * import type { ACPRunObserver } from '@h-ai/ai'
6438
+ * const observer: ACPRunObserver = { signal: new AbortController().signal }
6439
+ * ```
6440
+ */
6441
+ interface ACPRunObserver {
6442
+ signal?: AbortSignal;
6443
+ onEvent?: (event: RunnerJson) => void;
6444
+ }
6445
+ /**
6446
+ * 可在当前轮次调整的时限、输出和事件观察选项。
6447
+ * @example
6448
+ * ```ts
6449
+ * import type { ACPTurnOptions } from '@h-ai/ai'
6450
+ * const options: ACPTurnOptions = { limits: { runTimeoutMs: 10000 }, output: { format: 'json' } }
6451
+ * ```
6452
+ */
6453
+ type ACPTurnOptions = ACPRunObserver & Pick<ACPPlatformRequest, 'limits' | 'output'>;
6454
+
5533
6455
  /**
5534
6456
  * @h-ai/ai — RAG(Retrieval-Augmented Generation)子功能类型
5535
6457
  *
@@ -6863,29 +7785,411 @@ interface FileOperations {
6863
7785
  }
6864
7786
 
6865
7787
  /**
6866
- * @h-ai/ai — Persona 子功能类型
7788
+ * @h-ai/ai — MCP 子功能类型
6867
7789
  *
6868
- * 定义「AI 角色人格」的持久化与组合接口。Persona 解决的是「AI 是谁」的问题:
6869
- * 多智能体场景(如多位专家同台访谈)中,每个 AI 有稳定的系统提示词、性格特征与
6870
- * 长期人格。它与 Memory 正交——Memory 用 `objectId` / `scope` 回答「谁的记忆」,
6871
- * Persona 回答「这个 AI 的身份与人设」,二者通过 `scope: { personaId }` 关联。
6872
- * @module ai-persona-types
7790
+ * 定义 MCP 工具、资源、提示词的注册与调用接口。
7791
+ * @module ai-mcp-types
6873
7792
  */
6874
7793
 
6875
7794
  /**
6876
- * Persona 档案输入(创建 / 覆盖保存时使用)
7795
+ * MCP 工具定义(注册工具时的元数据)
6877
7796
  *
6878
7797
  * @example
6879
7798
  * ```ts
6880
- * import type { PersonaProfileInput } from '@h-ai/ai'
6881
- *
6882
- * const value: PersonaProfileInput = { id: 'support', objectId: 'tenant-1', name: '客服助手', systemPrompt: '根据已验证的订单信息回答。', traits: ['简洁', '先核对证据'] }
7799
+ * import { ai, type MCPToolDefinition } from '@h-ai/ai'
7800
+ * // 应用启动已成功初始化 ai;echo 为无外部副作用的示例工具。
7801
+ * const definition: MCPToolDefinition = { name: 'echo', description: '返回输入', inputSchema: { type: 'object', properties: { text: { type: 'string' } }, required: ['text'], additionalProperties: false } }
7802
+ * const registered = ai.mcp.registerTool(definition, (input: { text: string }) => ({ text: input.text }))
7803
+ * if (!registered.success) throw new Error(registered.error.message)
6883
7804
  * ```
6884
7805
  */
6885
- interface PersonaProfileInput {
6886
- /** 角色唯一标识(业务侧稳定 ID,如 `xiaop`) */
6887
- id: string;
6888
- /**
7806
+ interface MCPToolDefinition {
7807
+ /** 工具名称(需唯一) */
7808
+ name: string;
7809
+ /** 工具功能描述 */
7810
+ description: string;
7811
+ /** 输入参数的 JSON Schema */
7812
+ inputSchema: Record<string, unknown>;
7813
+ }
7814
+ /**
7815
+ * MCP 工具处理器,接收输入参数和执行上下文
7816
+ *
7817
+ * @example
7818
+ * ```ts
7819
+ * import type { MCPToolHandler } from '@h-ai/ai'
7820
+ * const echo: MCPToolHandler<{ text: string }, { text: string }> = (input, context) => ({ text: `${context.requestId ?? 'request'}: ${input.text}` })
7821
+ * const output = await echo({ text: '你好' }, { requestId: 'request-1' })
7822
+ * ```
7823
+ */
7824
+ type MCPToolHandler<TInput = unknown, TOutput = unknown> = (input: TInput, context: MCPContext) => Promise<TOutput> | TOutput;
7825
+ /**
7826
+ * MCP 执行上下文,携带请求元数据
7827
+ *
7828
+ * @example
7829
+ * ```ts
7830
+ * import type { MCPContext } from '@h-ai/ai'
7831
+ * const value: MCPContext = { requestId: 'request-1', clientInfo: { name: 'assistant', version: '1.0.0' } }
7832
+ * const correlationId = value.requestId
7833
+ * ```
7834
+ */
7835
+ interface MCPContext {
7836
+ /** 请求唯一标识(未传入时自动生成 UUID) */
7837
+ requestId?: string;
7838
+ /** 客户端信息(可选) */
7839
+ clientInfo?: {
7840
+ name: string;
7841
+ version: string;
7842
+ };
7843
+ /** 自定义元数据(可选) */
7844
+ metadata?: Record<string, unknown>;
7845
+ }
7846
+ /**
7847
+ * MCP 资源描述(注册资源时的元数据)
7848
+ *
7849
+ * @example
7850
+ * ```ts
7851
+ * import type { MCPResource } from '@h-ai/ai'
7852
+ * const value: MCPResource = { uri: 'config://public/features', name: '公开特性', mimeType: 'application/json' }
7853
+ * const resourceName = value.name
7854
+ * ```
7855
+ */
7856
+ interface MCPResource {
7857
+ /** 资源 URI(唯一标识) */
7858
+ uri: string;
7859
+ /** 资源名称 */
7860
+ name: string;
7861
+ /** 资源描述(可选) */
7862
+ description?: string;
7863
+ /** MIME 类型(可选,如 `'application/json'`) */
7864
+ mimeType?: string;
7865
+ }
7866
+ /**
7867
+ * MCP 资源内容(readResource 的返回值)
7868
+ *
7869
+ * @example
7870
+ * ```ts
7871
+ * import type { MCPResourceContent } from '@h-ai/ai'
7872
+ * const value: MCPResourceContent = { uri: 'config://public/features', mimeType: 'application/json', text: JSON.stringify({ enabled: true }) }
7873
+ * const text = value.text
7874
+ * ```
7875
+ */
7876
+ interface MCPResourceContent {
7877
+ /** 资源 URI */
7878
+ uri: string;
7879
+ /** MIME 类型(可选) */
7880
+ mimeType?: string;
7881
+ /** 文本内容(与 blob 二选一) */
7882
+ text?: string;
7883
+ /** Base64 编码的二进制内容(与 text 二选一) */
7884
+ blob?: string;
7885
+ }
7886
+ /**
7887
+ * MCP 提示词模板描述
7888
+ *
7889
+ * @example
7890
+ * ```ts
7891
+ * import type { MCPPrompt } from '@h-ai/ai'
7892
+ * const value: MCPPrompt = { name: 'explain', description: '解释主题', arguments: [{ name: 'topic', required: true }] }
7893
+ * const required = value.arguments?.filter(argument => argument.required)
7894
+ * ```
7895
+ */
7896
+ interface MCPPrompt {
7897
+ /** 提示词名称(唯一标识) */
7898
+ name: string;
7899
+ /** 提示词描述(可选) */
7900
+ description?: string;
7901
+ /** 参数定义列表(可选) */
7902
+ arguments?: MCPPromptArgument[];
7903
+ }
7904
+ /**
7905
+ * MCP 提示词参数定义
7906
+ *
7907
+ * @example
7908
+ * ```ts
7909
+ * import type { MCPPromptArgument } from '@h-ai/ai'
7910
+ * const value: MCPPromptArgument = { name: 'topic', description: '要解释的主题', required: true }
7911
+ * const field = value.name
7912
+ * ```
7913
+ */
7914
+ interface MCPPromptArgument {
7915
+ /** 参数名称 */
7916
+ name: string;
7917
+ /** 参数描述(可选) */
7918
+ description?: string;
7919
+ /** 是否必填(默认 `false`) */
7920
+ required?: boolean;
7921
+ }
7922
+ /**
7923
+ * MCP 提示词消息,直接复用 SDK 的完整判别联合(含图片、音频与嵌入资源)
7924
+ *
7925
+ * @example
7926
+ * ```ts
7927
+ * import type { MCPPromptMessage } from '@h-ai/ai'
7928
+ * const value: MCPPromptMessage = { role: 'user', content: { type: 'text', text: '请解释共享状态' } }
7929
+ * const role = value.role
7930
+ * ```
7931
+ */
7932
+ type MCPPromptMessage = PromptMessage;
7933
+ /**
7934
+ * MCP 提示词内容;按 type 缩窄后访问对应字段
7935
+ *
7936
+ * @example
7937
+ * ```ts
7938
+ * import type { MCPPromptContent } from '@h-ai/ai'
7939
+ * function textContent(content: MCPPromptContent): string | undefined {
7940
+ * return content.type === 'text' ? content.text : undefined
7941
+ * }
7942
+ * ```
7943
+ */
7944
+ type MCPPromptContent = PromptMessage['content'];
7945
+ /**
7946
+ * MCP 服务器创建选项
7947
+ *
7948
+ * @example
7949
+ * ```ts
7950
+ * import { createMcpServer, type McpServerOptions } from '@h-ai/ai'
7951
+ * const options: McpServerOptions = { name: 'public-tools', version: '1.0.0' }
7952
+ * const server = createMcpServer(options)
7953
+ * // 应用停止接入请求后关闭 SDK server。
7954
+ * await server.close()
7955
+ * ```
7956
+ */
7957
+ interface McpServerOptions {
7958
+ /** 服务器名称 */
7959
+ name: string;
7960
+ /** 服务器版本(默认 `'1.0.0'`) */
7961
+ version?: string;
7962
+ }
7963
+ /**
7964
+ * MCP 操作接口(通过 `ai.mcp` 访问)
7965
+ *
7966
+ * 需要先调用 `ai.init()` 初始化,否则所有方法返回 `NOT_INITIALIZED` 错误。
7967
+ *
7968
+ * @example
7969
+ * ```ts
7970
+ * import { ai, type MCPOperations } from '@h-ai/ai'
7971
+ * // 应用启动已成功初始化 ai。
7972
+ * const mcp: MCPOperations = ai.mcp
7973
+ * const registered = mcp.registerTool({ name: 'echo', description: '返回输入', inputSchema: { type: 'string' } }, (input: string) => input)
7974
+ * if (!registered.success) throw new Error(registered.error.message)
7975
+ * const called = await mcp.callTool('echo', '你好', { requestId: 'request-1' })
7976
+ * if (!called.success) throw new Error(called.error.message)
7977
+ * ```
7978
+ */
7979
+ interface MCPOperations {
7980
+ /** 注册工具并编译 JSON Schema;非法 Schema 返回 MCP_TOOL_ERROR,同名注册覆盖 */
7981
+ registerTool: <TInput, TOutput>(definition: MCPToolDefinition, handler: MCPToolHandler<TInput, TOutput>) => HaiResult<void>;
7982
+ /** 注册资源加载器;读取时校验 text/blob 输出 */
7983
+ registerResource: (resource: MCPResource, handler: () => Promise<MCPResourceContent>) => HaiResult<void>;
7984
+ /** 注册提示词;调用时校验必填参数和 SDK 消息格式 */
7985
+ registerPrompt: (prompt: MCPPrompt, handler: (args: Record<string, string>) => Promise<MCPPromptMessage[]>) => HaiResult<void>;
7986
+ /** 校验输入后执行工具;自动补齐缺失的 requestId */
7987
+ callTool: (name: string, args: unknown, context?: MCPContext) => Promise<HaiResult<unknown>>;
7988
+ /** 读取资源,输出必须恰好含一个有效 text 或 blob */
7989
+ readResource: (uri: string) => Promise<HaiResult<MCPResourceContent>>;
7990
+ /** 渲染提示词;必填参数必须是自身属性,且提供的已声明参数必须是字符串 */
7991
+ getPrompt: (name: string, args: Record<string, string>) => Promise<HaiResult<MCPPromptMessage[]>>;
7992
+ }
7993
+ /**
7994
+ * 按目录 ID 调用工具,连接设置始终由服务端清单提供。
7995
+ * @example
7996
+ * ```ts
7997
+ * import type { MCPServiceRequest } from '@h-ai/ai'
7998
+ * const request: MCPServiceRequest = { serviceId: 'docs', tool: 'search', arguments: { query: 'manual' } }
7999
+ * ```
8000
+ */
8001
+ interface MCPServiceRequest {
8002
+ serviceId: string;
8003
+ tool: string;
8004
+ arguments?: CallToolRequest['params']['arguments'];
8005
+ }
8006
+ /**
8007
+ * 由可信应用从认证态和业务授权构造的调用上下文。
8008
+ * @example
8009
+ * ```ts
8010
+ * import type { MCPServiceAuthorization } from '@h-ai/ai'
8011
+ * const authorization: MCPServiceAuthorization = {
8012
+ * principal: { tenantId: 'team', userId: 'ada' },
8013
+ * authorize: ({ principal, serviceId, tool }) => principal.tenantId === 'team' && serviceId === 'docs' && tool === 'search',
8014
+ * }
8015
+ * ```
8016
+ */
8017
+ interface MCPServiceAuthorization {
8018
+ /** 从 IAM 会话或可信服务身份取得的主体,不能从模型或工具参数构造。 */
8019
+ principal: {
8020
+ tenantId: string;
8021
+ userId: string;
8022
+ };
8023
+ /** 可信调用方绑定的业务任务 ID;通过 Broker 调用时由绑定提供。 */
8024
+ taskId?: string;
8025
+ /** 根据主体、工具和实际参数检查资料访问权限及操作权限。 */
8026
+ authorize: (input: MCPServiceRequest & {
8027
+ principal: MCPServiceAuthorization['principal'];
8028
+ signal: AbortSignal;
8029
+ }) => boolean | Promise<boolean>;
8030
+ /** 在请求开始前或执行中取消;远端已完成的操作由业务核对。 */
8031
+ signal?: AbortSignal;
8032
+ }
8033
+ /**
8034
+ * 作业执行者在读取授权对象或提交暂存产物时使用的可信业务绑定。
8035
+ * @example
8036
+ * ```ts
8037
+ * import type { MCPJobFileContext } from '@h-ai/ai'
8038
+ * function owner(context: MCPJobFileContext) { return context.principal.tenantId }
8039
+ * ```
8040
+ */
8041
+ interface MCPJobFileContext {
8042
+ principal: MCPServiceAuthorization['principal'];
8043
+ taskId?: string;
8044
+ jobId: string;
8045
+ signal: AbortSignal;
8046
+ }
8047
+ /**
8048
+ * 应用提供对象 ACL 与存储接入。文件内容只在作业节点暂存,队列仅保存对象 ID。
8049
+ * @example
8050
+ * ```ts
8051
+ * import { err, type HaiResult } from '@h-ai/core'
8052
+ * import { HaiAIError, type MCPJobFiles } from '@h-ai/ai'
8053
+ * function denied<T>(): HaiResult<T> { return err(HaiAIError.MCP_TOOL_FORBIDDEN, 'File is not authorized') }
8054
+ * const files: MCPJobFiles = { read: async () => denied(), publish: async () => denied() }
8055
+ * ```
8056
+ */
8057
+ interface MCPJobFiles {
8058
+ /** 在读取前验证主体、任务状态、对象归属和读取授权。 */
8059
+ read: (input: MCPJobFileContext & {
8060
+ fileId: string;
8061
+ }) => Promise<HaiResult<{
8062
+ name: string;
8063
+ base64: string;
8064
+ }>>;
8065
+ /** 重新验证主体与任务,提交带归属、可按 jobId 回收的暂存对象。 */
8066
+ publish: (input: MCPJobFileContext & {
8067
+ name: string;
8068
+ base64: string;
8069
+ }) => Promise<HaiResult<{
8070
+ fileId: string;
8071
+ }>>;
8072
+ }
8073
+ /**
8074
+ * 通过现有合并目录调用受控的第三方 Streamable HTTP 工具。
8075
+ * @example
8076
+ * ```ts
8077
+ * import { ai, type MCPServiceAuthorization } from '@h-ai/ai'
8078
+ * async function search(context: MCPServiceAuthorization) {
8079
+ * const result = await ai.mcp.services.invoke({ serviceId: 'docs', tool: 'search', arguments: { query: 'manual' } }, context)
8080
+ * if (!result.success) return result
8081
+ * return result.data.content
8082
+ * }
8083
+ * ```
8084
+ */
8085
+ interface MCPServiceOperations {
8086
+ /** 解析当前清单和授权后连接远端,返回标准 MCP 工具内容或本地化失败。 */
8087
+ invoke: (request: MCPServiceRequest, authorization: MCPServiceAuthorization) => Promise<HaiResult<CallToolResult>>;
8088
+ /** 在执行节点创建受信 HTTP 工具入口。 */
8089
+ createBroker: (options: MCPServiceBrokerOptions) => HaiResult<MCPServiceBroker>;
8090
+ }
8091
+ /**
8092
+ * 工具入口固定地址及每次调用的实时业务授权。
8093
+ * @example
8094
+ * ```ts
8095
+ * import type { MCPServiceBrokerOptions } from '@h-ai/ai'
8096
+ * const broker: MCPServiceBrokerOptions = {
8097
+ * url: 'https://executor.example.com/mcp',
8098
+ * authorize: ({ principal, serviceId, taskId }) => principal.tenantId === 'team' && serviceId === 'docs' && taskId === 'run-1',
8099
+ * }
8100
+ * ```
8101
+ */
8102
+ interface MCPServiceBrokerOptions {
8103
+ /** Agent 容器可访问的固定工具端点。 */
8104
+ url: string;
8105
+ /** 可信应用每次核验任务仍运行、主体和实际参数仍允许。 */
8106
+ authorize: (input: Parameters<MCPServiceAuthorization['authorize']>[0] & {
8107
+ taskId: string;
8108
+ }) => boolean | Promise<boolean>;
8109
+ }
8110
+ /**
8111
+ * 任务授权、模型可见工具名及应用提供的输入契约。
8112
+ * @example
8113
+ * ```ts
8114
+ * import type { MCPServiceBindingRequest } from '@h-ai/ai'
8115
+ * const binding: MCPServiceBindingRequest = {
8116
+ * principal: { tenantId: 'team', userId: 'ada' },
8117
+ * taskId: 'run-1',
8118
+ * tools: [{ id: 'docs_search', serviceId: 'docs', tool: 'search', description: 'Search manuals', inputSchema: { type: 'object' } }],
8119
+ * }
8120
+ * ```
8121
+ */
8122
+ interface MCPServiceBindingRequest {
8123
+ principal: MCPServiceAuthorization['principal'];
8124
+ taskId: string;
8125
+ tools: Array<{
8126
+ id: string;
8127
+ serviceId: string;
8128
+ tool: string;
8129
+ description: string;
8130
+ inputSchema: Record<string, unknown>;
8131
+ }>;
8132
+ /** 有效期,缺省 15 分钟,最多 24 小时。 */
8133
+ ttlMs?: number;
8134
+ /** 执行结束或失租时撤销此绑定。 */
8135
+ signal?: AbortSignal;
8136
+ }
8137
+ /**
8138
+ * 只向当前执行代次提供的 MCP 连接和撤销句柄。
8139
+ * @example
8140
+ * ```ts
8141
+ * import type { MCPServiceBinding } from '@h-ai/ai'
8142
+ * function stop(binding: MCPServiceBinding) { binding.revoke() }
8143
+ * ```
8144
+ */
8145
+ interface MCPServiceBinding {
8146
+ /** 仅传给当前 Agent,含短期 Bearer。 */
8147
+ servers: Array<Extract<McpServer, {
8148
+ type: 'http';
8149
+ }>>;
8150
+ revoke: () => void;
8151
+ /** 此绑定到期、撤销或上层关闭时取消;受管 ACP 用它判定何时结束原生会话。 */
8152
+ signal?: AbortSignal;
8153
+ }
8154
+ /**
8155
+ * 执行节点挂载的任务工具入口。
8156
+ * @example
8157
+ * ```ts
8158
+ * import { createServer } from 'node:http'
8159
+ * import type { MCPServiceBroker } from '@h-ai/ai'
8160
+ * function mount(broker: MCPServiceBroker) { return createServer((req, res) => void broker.handleRequest(req, res)) }
8161
+ * ```
8162
+ */
8163
+ interface MCPServiceBroker {
8164
+ bind: (request: MCPServiceBindingRequest) => Promise<HaiResult<MCPServiceBinding>>;
8165
+ handleRequest: (request: IncomingMessage, response: ServerResponse) => Promise<void>;
8166
+ close: () => void;
8167
+ }
8168
+
8169
+ /**
8170
+ * @h-ai/ai — Persona 子功能类型
8171
+ *
8172
+ * 定义「AI 角色人格」的持久化与组合接口。Persona 解决的是「AI 是谁」的问题:
8173
+ * 多智能体场景(如多位专家同台访谈)中,每个 AI 有稳定的系统提示词、性格特征与
8174
+ * 长期人格。它与 Memory 正交——Memory 用 `objectId` / `scope` 回答「谁的记忆」,
8175
+ * Persona 回答「这个 AI 的身份与人设」,二者通过 `scope: { personaId }` 关联。
8176
+ * @module ai-persona-types
8177
+ */
8178
+
8179
+ /**
8180
+ * Persona 档案输入(创建 / 覆盖保存时使用)
8181
+ *
8182
+ * @example
8183
+ * ```ts
8184
+ * import type { PersonaProfileInput } from '@h-ai/ai'
8185
+ *
8186
+ * const value: PersonaProfileInput = { id: 'support', objectId: 'tenant-1', name: '客服助手', systemPrompt: '根据已验证的订单信息回答。', traits: ['简洁', '先核对证据'] }
8187
+ * ```
8188
+ */
8189
+ interface PersonaProfileInput {
8190
+ /** 角色唯一标识(业务侧稳定 ID,如 `xiaop`) */
8191
+ id: string;
8192
+ /**
6889
8193
  * 所属主体 ID(多租户隔离)
6890
8194
  *
6891
8195
  * 不同主体可创建同名角色而互不覆盖;不传时归为平台内置角色 `system`。
@@ -7163,213 +8467,6 @@ interface ImageOperations {
7163
8467
  generate: (request: GenerateImageRequest) => Promise<HaiResult<GenerateImageResult>>;
7164
8468
  }
7165
8469
 
7166
- /**
7167
- * @h-ai/ai — MCP 子功能类型
7168
- *
7169
- * 定义 MCP 工具、资源、提示词的注册与调用接口。
7170
- * @module ai-mcp-types
7171
- */
7172
-
7173
- /**
7174
- * MCP 工具定义(注册工具时的元数据)
7175
- *
7176
- * @example
7177
- * ```ts
7178
- * import { ai, type MCPToolDefinition } from '@h-ai/ai'
7179
- * // 应用启动已成功初始化 ai;echo 为无外部副作用的示例工具。
7180
- * const definition: MCPToolDefinition = { name: 'echo', description: '返回输入', inputSchema: { type: 'object', properties: { text: { type: 'string' } }, required: ['text'], additionalProperties: false } }
7181
- * const registered = ai.mcp.registerTool(definition, (input: { text: string }) => ({ text: input.text }))
7182
- * if (!registered.success) throw new Error(registered.error.message)
7183
- * ```
7184
- */
7185
- interface MCPToolDefinition {
7186
- /** 工具名称(需唯一) */
7187
- name: string;
7188
- /** 工具功能描述 */
7189
- description: string;
7190
- /** 输入参数的 JSON Schema */
7191
- inputSchema: Record<string, unknown>;
7192
- }
7193
- /**
7194
- * MCP 工具处理器,接收输入参数和执行上下文
7195
- *
7196
- * @example
7197
- * ```ts
7198
- * import type { MCPToolHandler } from '@h-ai/ai'
7199
- * const echo: MCPToolHandler<{ text: string }, { text: string }> = (input, context) => ({ text: `${context.requestId ?? 'request'}: ${input.text}` })
7200
- * const output = await echo({ text: '你好' }, { requestId: 'request-1' })
7201
- * ```
7202
- */
7203
- type MCPToolHandler<TInput = unknown, TOutput = unknown> = (input: TInput, context: MCPContext) => Promise<TOutput> | TOutput;
7204
- /**
7205
- * MCP 执行上下文,携带请求元数据
7206
- *
7207
- * @example
7208
- * ```ts
7209
- * import type { MCPContext } from '@h-ai/ai'
7210
- * const value: MCPContext = { requestId: 'request-1', clientInfo: { name: 'assistant', version: '1.0.0' } }
7211
- * const correlationId = value.requestId
7212
- * ```
7213
- */
7214
- interface MCPContext {
7215
- /** 请求唯一标识(未传入时自动生成 UUID) */
7216
- requestId?: string;
7217
- /** 客户端信息(可选) */
7218
- clientInfo?: {
7219
- name: string;
7220
- version: string;
7221
- };
7222
- /** 自定义元数据(可选) */
7223
- metadata?: Record<string, unknown>;
7224
- }
7225
- /**
7226
- * MCP 资源描述(注册资源时的元数据)
7227
- *
7228
- * @example
7229
- * ```ts
7230
- * import type { MCPResource } from '@h-ai/ai'
7231
- * const value: MCPResource = { uri: 'config://public/features', name: '公开特性', mimeType: 'application/json' }
7232
- * const resourceName = value.name
7233
- * ```
7234
- */
7235
- interface MCPResource {
7236
- /** 资源 URI(唯一标识) */
7237
- uri: string;
7238
- /** 资源名称 */
7239
- name: string;
7240
- /** 资源描述(可选) */
7241
- description?: string;
7242
- /** MIME 类型(可选,如 `'application/json'`) */
7243
- mimeType?: string;
7244
- }
7245
- /**
7246
- * MCP 资源内容(readResource 的返回值)
7247
- *
7248
- * @example
7249
- * ```ts
7250
- * import type { MCPResourceContent } from '@h-ai/ai'
7251
- * const value: MCPResourceContent = { uri: 'config://public/features', mimeType: 'application/json', text: JSON.stringify({ enabled: true }) }
7252
- * const text = value.text
7253
- * ```
7254
- */
7255
- interface MCPResourceContent {
7256
- /** 资源 URI */
7257
- uri: string;
7258
- /** MIME 类型(可选) */
7259
- mimeType?: string;
7260
- /** 文本内容(与 blob 二选一) */
7261
- text?: string;
7262
- /** Base64 编码的二进制内容(与 text 二选一) */
7263
- blob?: string;
7264
- }
7265
- /**
7266
- * MCP 提示词模板描述
7267
- *
7268
- * @example
7269
- * ```ts
7270
- * import type { MCPPrompt } from '@h-ai/ai'
7271
- * const value: MCPPrompt = { name: 'explain', description: '解释主题', arguments: [{ name: 'topic', required: true }] }
7272
- * const required = value.arguments?.filter(argument => argument.required)
7273
- * ```
7274
- */
7275
- interface MCPPrompt {
7276
- /** 提示词名称(唯一标识) */
7277
- name: string;
7278
- /** 提示词描述(可选) */
7279
- description?: string;
7280
- /** 参数定义列表(可选) */
7281
- arguments?: MCPPromptArgument[];
7282
- }
7283
- /**
7284
- * MCP 提示词参数定义
7285
- *
7286
- * @example
7287
- * ```ts
7288
- * import type { MCPPromptArgument } from '@h-ai/ai'
7289
- * const value: MCPPromptArgument = { name: 'topic', description: '要解释的主题', required: true }
7290
- * const field = value.name
7291
- * ```
7292
- */
7293
- interface MCPPromptArgument {
7294
- /** 参数名称 */
7295
- name: string;
7296
- /** 参数描述(可选) */
7297
- description?: string;
7298
- /** 是否必填(默认 `false`) */
7299
- required?: boolean;
7300
- }
7301
- /**
7302
- * MCP 提示词消息,直接复用 SDK 的完整判别联合(含图片、音频与嵌入资源)
7303
- *
7304
- * @example
7305
- * ```ts
7306
- * import type { MCPPromptMessage } from '@h-ai/ai'
7307
- * const value: MCPPromptMessage = { role: 'user', content: { type: 'text', text: '请解释共享状态' } }
7308
- * const role = value.role
7309
- * ```
7310
- */
7311
- type MCPPromptMessage = PromptMessage;
7312
- /**
7313
- * MCP 提示词内容;按 type 缩窄后访问对应字段
7314
- *
7315
- * @example
7316
- * ```ts
7317
- * import type { MCPPromptContent } from '@h-ai/ai'
7318
- * function textContent(content: MCPPromptContent): string | undefined {
7319
- * return content.type === 'text' ? content.text : undefined
7320
- * }
7321
- * ```
7322
- */
7323
- type MCPPromptContent = PromptMessage['content'];
7324
- /**
7325
- * MCP 服务器创建选项
7326
- *
7327
- * @example
7328
- * ```ts
7329
- * import { createMcpServer, type McpServerOptions } from '@h-ai/ai'
7330
- * const options: McpServerOptions = { name: 'public-tools', version: '1.0.0' }
7331
- * const server = createMcpServer(options)
7332
- * // 应用停止接入请求后关闭 SDK server。
7333
- * await server.close()
7334
- * ```
7335
- */
7336
- interface McpServerOptions {
7337
- /** 服务器名称 */
7338
- name: string;
7339
- /** 服务器版本(默认 `'1.0.0'`) */
7340
- version?: string;
7341
- }
7342
- /**
7343
- * MCP 操作接口(通过 `ai.mcp` 访问)
7344
- *
7345
- * 需要先调用 `ai.init()` 初始化,否则所有方法返回 `NOT_INITIALIZED` 错误。
7346
- *
7347
- * @example
7348
- * ```ts
7349
- * import { ai, type MCPOperations } from '@h-ai/ai'
7350
- * // 应用启动已成功初始化 ai。
7351
- * const mcp: MCPOperations = ai.mcp
7352
- * const registered = mcp.registerTool({ name: 'echo', description: '返回输入', inputSchema: { type: 'string' } }, (input: string) => input)
7353
- * if (!registered.success) throw new Error(registered.error.message)
7354
- * const called = await mcp.callTool('echo', '你好', { requestId: 'request-1' })
7355
- * if (!called.success) throw new Error(called.error.message)
7356
- * ```
7357
- */
7358
- interface MCPOperations {
7359
- /** 注册工具并编译 JSON Schema;非法 Schema 返回 MCP_TOOL_ERROR,同名注册覆盖 */
7360
- registerTool: <TInput, TOutput>(definition: MCPToolDefinition, handler: MCPToolHandler<TInput, TOutput>) => HaiResult<void>;
7361
- /** 注册资源加载器;读取时校验 text/blob 输出 */
7362
- registerResource: (resource: MCPResource, handler: () => Promise<MCPResourceContent>) => HaiResult<void>;
7363
- /** 注册提示词;调用时校验必填参数和 SDK 消息格式 */
7364
- registerPrompt: (prompt: MCPPrompt, handler: (args: Record<string, string>) => Promise<MCPPromptMessage[]>) => HaiResult<void>;
7365
- /** 校验输入后执行工具;自动补齐缺失的 requestId */
7366
- callTool: (name: string, args: unknown, context?: MCPContext) => Promise<HaiResult<unknown>>;
7367
- /** 读取资源,输出必须恰好含一个有效 text 或 blob */
7368
- readResource: (uri: string) => Promise<HaiResult<MCPResourceContent>>;
7369
- /** 渲染提示词;必填参数必须是自身属性,且提供的已声明参数必须是字符串 */
7370
- getPrompt: (name: string, args: Record<string, string>) => Promise<HaiResult<MCPPromptMessage[]>>;
7371
- }
7372
-
7373
8470
  /**
7374
8471
  * 清单项与来源;配置来源不可修改,version 仅用于数据库乐观并发更新。
7375
8472
  * @example
@@ -7509,6 +8606,8 @@ interface ManagedImageOperations extends ImageOperations {
7509
8606
  * ```
7510
8607
  */
7511
8608
  interface ManagedMCPOperations extends MCPOperations {
8609
+ /** 按业务身份调用合并清单中已显式开放的工具。 */
8610
+ services: MCPServiceOperations;
7512
8611
  /** 配置只读、数据库可维护的合并清单。 */
7513
8612
  servers: AIResourceRegistry<z.output<typeof MCPExternalServerSchema>, z.input<typeof MCPExternalServerSchema>>;
7514
8613
  }
@@ -7739,6 +8838,8 @@ declare const HaiAIError: {
7739
8838
  readonly MCP_TOOL_ERROR: _h_ai_core.HaiErrorDef;
7740
8839
  readonly MCP_RESOURCE_ERROR: _h_ai_core.HaiErrorDef;
7741
8840
  readonly MCP_SERVER_ERROR: _h_ai_core.HaiErrorDef;
8841
+ readonly MCP_TOOL_FORBIDDEN: _h_ai_core.HaiErrorDef;
8842
+ readonly MCP_TOOL_CANCELLED: _h_ai_core.HaiErrorDef;
7742
8843
  readonly EMBEDDING_API_ERROR: _h_ai_core.HaiErrorDef;
7743
8844
  readonly EMBEDDING_MODEL_NOT_FOUND: _h_ai_core.HaiErrorDef;
7744
8845
  readonly EMBEDDING_INPUT_TOO_LONG: _h_ai_core.HaiErrorDef;
@@ -7832,6 +8933,12 @@ declare const HaiAIError: {
7832
8933
  * ```
7833
8934
  */
7834
8935
  interface AIInitOptions {
8936
+ /** 由应用初始化和关闭的受管执行实例。 */
8937
+ runner?: RunnerFunctions;
8938
+ /** 应用对受管 ACP 请求执行的可信授权。 */
8939
+ acpPolicy?: ACPPlatformPolicy;
8940
+ /** 在作业领取者上验证文件权限、读入对象和暂存结果。 */
8941
+ mcpJobFiles?: MCPJobFiles;
7835
8942
  /** 可信服务端扩展:为其他 ACP 智能体生成原生配置。 */
7836
8943
  acpAdapters?: Record<string, ACPAgentAdapter>;
7837
8944
  /**
@@ -8300,7 +9407,289 @@ type AudioWsServerMessage = AudioWsSpeechMessage | AudioWsTranscriptMessage | Au
8300
9407
  * async function assemble(provider: AIStoreProvider, config: AIConfig) { const acp = createACPOperations(provider, config); await provider.initialize(); return acp }
8301
9408
  * ```
8302
9409
  */
8303
- declare function createACPOperations(provider: AIStoreProvider, config: AIConfig, extensions?: Record<string, ACPAgentAdapter>, modelConfig?: () => Promise<AIConfig>, mcpLookup?: (ids: string[]) => Promise<McpServer[]>): {
9410
+ declare function createACPOperations(provider: AIStoreProvider, config: AIConfig, extensions?: Record<string, ACPAgentAdapter>, modelConfig?: () => Promise<AIConfig>, mcpLookup?: (ids: string[]) => Promise<McpServer[]>, runner?: RunnerFunctions, policy?: ACPPlatformPolicy): {
9411
+ scoped: (rawScope: _h_ai_runner.RunnerScope) => {
9412
+ plan: (request: ACPPlatformRequest) => Promise<HaiResult<{
9413
+ readonly image: string;
9414
+ readonly resources: {
9415
+ cpu: number;
9416
+ memoryMiB: number;
9417
+ pids: number;
9418
+ scratchMiB: number;
9419
+ };
9420
+ readonly modelId: string;
9421
+ readonly model: {
9422
+ id?: string | undefined;
9423
+ reasoningEffort?: string | undefined;
9424
+ temperature?: number | undefined;
9425
+ maxOutputTokens?: number | undefined;
9426
+ };
9427
+ readonly permissions: {
9428
+ profile: "read-only" | "workspace" | "full-access";
9429
+ approval: "never" | "on-request";
9430
+ ruleIds?: string[] | undefined;
9431
+ };
9432
+ readonly limits: {
9433
+ readonly queueTimeoutMs: number;
9434
+ readonly runTimeoutMs: number;
9435
+ readonly approvalTimeoutMs: number;
9436
+ readonly maxOutputBytes: number;
9437
+ };
9438
+ readonly capabilities: string[];
9439
+ readonly reason: "user-policy" | "verified-shared" | "isolated-default" | "explicit";
9440
+ readonly nativeResume: "none" | "load" | "resume";
9441
+ readonly workspaceId?: string | undefined;
9442
+ readonly agentId: string;
9443
+ readonly adapter: string;
9444
+ readonly requestedMode: "auto" | "shared" | "user" | "task";
9445
+ readonly resolvedMode: "shared" | "user" | "task";
9446
+ readonly environmentId: string;
9447
+ }>>;
9448
+ agents: {
9449
+ describe: (id: string) => Promise<HaiResult<{
9450
+ managedTransport: "stdio";
9451
+ protocols: readonly ApiType[];
9452
+ workerModes: readonly ("shared" | "user" | "task")[];
9453
+ nativeResume: "load" | "resume" | "none";
9454
+ id: string;
9455
+ adapter: string;
9456
+ modelIds: string[];
9457
+ environmentIds: string[];
9458
+ }>>;
9459
+ };
9460
+ approvals: {
9461
+ rules: (offset?: number, limit?: number) => Promise<HaiResult<{
9462
+ id: string;
9463
+ summary: string;
9464
+ sessionId: string | undefined;
9465
+ expiresAt: number;
9466
+ }[]>>;
9467
+ revoke: (id: string) => Promise<HaiResult<void>>;
9468
+ respond: (approvalId: string, decision: ACPApprovalDecision) => Promise<HaiResult<void>>;
9469
+ };
9470
+ tasks: {
9471
+ get: (id: string) => Promise<HaiResult<_h_ai_runner.RunnerExecution>>;
9472
+ events: (id: string, after?: number, limit?: number) => Promise<HaiResult<_h_ai_runner.RunnerEvent[]>>;
9473
+ cancel: (id: string) => Promise<HaiResult<_h_ai_runner.RunnerExecution>>;
9474
+ };
9475
+ sessions: {
9476
+ create: (request: ACPPlatformRequest) => Promise<HaiResult<{
9477
+ id: string;
9478
+ prompt: (content: ACPRunRequest["prompt"], observer?: ACPTurnOptions) => Promise<HaiResult<{
9479
+ taskId: string;
9480
+ output: string | number | boolean | z.core.util.JSONType[] | {
9481
+ [key: string]: z.core.util.JSONType;
9482
+ } | null;
9483
+ effectiveOptions: {
9484
+ readonly image: string;
9485
+ readonly resources: {
9486
+ cpu: number;
9487
+ memoryMiB: number;
9488
+ pids: number;
9489
+ scratchMiB: number;
9490
+ };
9491
+ readonly modelId: string;
9492
+ readonly model: {
9493
+ id?: string | undefined;
9494
+ reasoningEffort?: string | undefined;
9495
+ temperature?: number | undefined;
9496
+ maxOutputTokens?: number | undefined;
9497
+ };
9498
+ readonly permissions: {
9499
+ profile: "read-only" | "workspace" | "full-access";
9500
+ approval: "never" | "on-request";
9501
+ ruleIds?: string[] | undefined;
9502
+ };
9503
+ readonly limits: {
9504
+ readonly queueTimeoutMs: number;
9505
+ readonly runTimeoutMs: number;
9506
+ readonly approvalTimeoutMs: number;
9507
+ readonly maxOutputBytes: number;
9508
+ };
9509
+ readonly capabilities: string[];
9510
+ readonly reason: "user-policy" | "verified-shared" | "isolated-default" | "explicit";
9511
+ readonly nativeResume: "none" | "load" | "resume";
9512
+ readonly workspaceId?: string | undefined;
9513
+ readonly agentId: string;
9514
+ readonly adapter: string;
9515
+ readonly requestedMode: "auto" | "shared" | "user" | "task";
9516
+ readonly resolvedMode: "shared" | "user" | "task";
9517
+ readonly environmentId: string;
9518
+ };
9519
+ }>>;
9520
+ close: () => Promise<HaiResult<void>>;
9521
+ stream(content: ACPRunRequest["prompt"], options?: ACPTurnOptions): AsyncGenerator<_h_ai_runner.RunnerJson>;
9522
+ changeExecution: (execution: NonNullable<ACPPlatformRequest["execution"]> & {
9523
+ acceptNewSession: true;
9524
+ historySummary?: string;
9525
+ }) => Promise<HaiResult<{
9526
+ readonly image: string;
9527
+ readonly resources: {
9528
+ cpu: number;
9529
+ memoryMiB: number;
9530
+ pids: number;
9531
+ scratchMiB: number;
9532
+ };
9533
+ readonly modelId: string;
9534
+ readonly model: {
9535
+ id?: string | undefined;
9536
+ reasoningEffort?: string | undefined;
9537
+ temperature?: number | undefined;
9538
+ maxOutputTokens?: number | undefined;
9539
+ };
9540
+ readonly permissions: {
9541
+ profile: "read-only" | "workspace" | "full-access";
9542
+ approval: "never" | "on-request";
9543
+ ruleIds?: string[] | undefined;
9544
+ };
9545
+ readonly limits: {
9546
+ readonly queueTimeoutMs: number;
9547
+ readonly runTimeoutMs: number;
9548
+ readonly approvalTimeoutMs: number;
9549
+ readonly maxOutputBytes: number;
9550
+ };
9551
+ readonly capabilities: string[];
9552
+ readonly reason: "user-policy" | "verified-shared" | "isolated-default" | "explicit";
9553
+ readonly nativeResume: "none" | "load" | "resume";
9554
+ readonly workspaceId?: string | undefined;
9555
+ readonly agentId: string;
9556
+ readonly adapter: string;
9557
+ readonly requestedMode: "auto" | "shared" | "user" | "task";
9558
+ readonly resolvedMode: "shared" | "user" | "task";
9559
+ readonly environmentId: string;
9560
+ }>>;
9561
+ }>>;
9562
+ get: (id: string) => Promise<HaiResult<{
9563
+ id: string;
9564
+ prompt: (content: ACPRunRequest["prompt"], observer?: ACPTurnOptions) => Promise<HaiResult<{
9565
+ taskId: string;
9566
+ output: string | number | boolean | z.core.util.JSONType[] | {
9567
+ [key: string]: z.core.util.JSONType;
9568
+ } | null;
9569
+ effectiveOptions: {
9570
+ readonly image: string;
9571
+ readonly resources: {
9572
+ cpu: number;
9573
+ memoryMiB: number;
9574
+ pids: number;
9575
+ scratchMiB: number;
9576
+ };
9577
+ readonly modelId: string;
9578
+ readonly model: {
9579
+ id?: string | undefined;
9580
+ reasoningEffort?: string | undefined;
9581
+ temperature?: number | undefined;
9582
+ maxOutputTokens?: number | undefined;
9583
+ };
9584
+ readonly permissions: {
9585
+ profile: "read-only" | "workspace" | "full-access";
9586
+ approval: "never" | "on-request";
9587
+ ruleIds?: string[] | undefined;
9588
+ };
9589
+ readonly limits: {
9590
+ readonly queueTimeoutMs: number;
9591
+ readonly runTimeoutMs: number;
9592
+ readonly approvalTimeoutMs: number;
9593
+ readonly maxOutputBytes: number;
9594
+ };
9595
+ readonly capabilities: string[];
9596
+ readonly reason: "user-policy" | "verified-shared" | "isolated-default" | "explicit";
9597
+ readonly nativeResume: "none" | "load" | "resume";
9598
+ readonly workspaceId?: string | undefined;
9599
+ readonly agentId: string;
9600
+ readonly adapter: string;
9601
+ readonly requestedMode: "auto" | "shared" | "user" | "task";
9602
+ readonly resolvedMode: "shared" | "user" | "task";
9603
+ readonly environmentId: string;
9604
+ };
9605
+ }>>;
9606
+ close: () => Promise<HaiResult<void>>;
9607
+ stream(content: ACPRunRequest["prompt"], options?: ACPTurnOptions): AsyncGenerator<_h_ai_runner.RunnerJson>;
9608
+ changeExecution: (execution: NonNullable<ACPPlatformRequest["execution"]> & {
9609
+ acceptNewSession: true;
9610
+ historySummary?: string;
9611
+ }) => Promise<HaiResult<{
9612
+ readonly image: string;
9613
+ readonly resources: {
9614
+ cpu: number;
9615
+ memoryMiB: number;
9616
+ pids: number;
9617
+ scratchMiB: number;
9618
+ };
9619
+ readonly modelId: string;
9620
+ readonly model: {
9621
+ id?: string | undefined;
9622
+ reasoningEffort?: string | undefined;
9623
+ temperature?: number | undefined;
9624
+ maxOutputTokens?: number | undefined;
9625
+ };
9626
+ readonly permissions: {
9627
+ profile: "read-only" | "workspace" | "full-access";
9628
+ approval: "never" | "on-request";
9629
+ ruleIds?: string[] | undefined;
9630
+ };
9631
+ readonly limits: {
9632
+ readonly queueTimeoutMs: number;
9633
+ readonly runTimeoutMs: number;
9634
+ readonly approvalTimeoutMs: number;
9635
+ readonly maxOutputBytes: number;
9636
+ };
9637
+ readonly capabilities: string[];
9638
+ readonly reason: "user-policy" | "verified-shared" | "isolated-default" | "explicit";
9639
+ readonly nativeResume: "none" | "load" | "resume";
9640
+ readonly workspaceId?: string | undefined;
9641
+ readonly agentId: string;
9642
+ readonly adapter: string;
9643
+ readonly requestedMode: "auto" | "shared" | "user" | "task";
9644
+ readonly resolvedMode: "shared" | "user" | "task";
9645
+ readonly environmentId: string;
9646
+ }>>;
9647
+ }>>;
9648
+ };
9649
+ run: (raw: ACPRunRequest, observer?: ACPRunObserver) => Promise<HaiResult<{
9650
+ taskId: string;
9651
+ output: string | number | boolean | z.core.util.JSONType[] | {
9652
+ [key: string]: z.core.util.JSONType;
9653
+ } | null;
9654
+ effectiveOptions: {
9655
+ readonly image: string;
9656
+ readonly resources: {
9657
+ cpu: number;
9658
+ memoryMiB: number;
9659
+ pids: number;
9660
+ scratchMiB: number;
9661
+ };
9662
+ readonly modelId: string;
9663
+ readonly model: {
9664
+ id?: string | undefined;
9665
+ reasoningEffort?: string | undefined;
9666
+ temperature?: number | undefined;
9667
+ maxOutputTokens?: number | undefined;
9668
+ };
9669
+ readonly permissions: {
9670
+ profile: "read-only" | "workspace" | "full-access";
9671
+ approval: "never" | "on-request";
9672
+ ruleIds?: string[] | undefined;
9673
+ };
9674
+ readonly limits: {
9675
+ readonly queueTimeoutMs: number;
9676
+ readonly runTimeoutMs: number;
9677
+ readonly approvalTimeoutMs: number;
9678
+ readonly maxOutputBytes: number;
9679
+ };
9680
+ readonly capabilities: string[];
9681
+ readonly reason: "user-policy" | "verified-shared" | "isolated-default" | "explicit";
9682
+ readonly nativeResume: "none" | "load" | "resume";
9683
+ readonly workspaceId?: string | undefined;
9684
+ readonly agentId: string;
9685
+ readonly adapter: string;
9686
+ readonly requestedMode: "auto" | "shared" | "user" | "task";
9687
+ readonly resolvedMode: "shared" | "user" | "task";
9688
+ readonly environmentId: string;
9689
+ };
9690
+ }>>;
9691
+ };
9692
+ registerManagedExecutors: () => void;
8304
9693
  agents: {
8305
9694
  /**
8306
9695
  * 校验模型与适配器后新增数据库智能体;配置同名条目只读。
@@ -8326,7 +9715,60 @@ declare function createACPOperations(provider: AIStoreProvider, config: AIConfig
8326
9715
  adapter: string;
8327
9716
  modelIds: string[];
8328
9717
  environmentRefs: Record<string, string>;
9718
+ environmentIds: string[];
9719
+ allowedCapabilities: string[];
8329
9720
  defaultModelId?: string | undefined;
9721
+ defaults?: {
9722
+ model?: {
9723
+ id?: string | undefined;
9724
+ reasoningEffort?: string | undefined;
9725
+ temperature?: number | undefined;
9726
+ maxOutputTokens?: number | undefined;
9727
+ } | undefined;
9728
+ execution?: {
9729
+ mode?: "auto" | "shared" | "user" | "task" | undefined;
9730
+ environmentId?: string | undefined;
9731
+ resources?: {
9732
+ cpu?: number | undefined;
9733
+ memoryMiB?: number | undefined;
9734
+ } | undefined;
9735
+ } | undefined;
9736
+ workspaceId?: string | undefined;
9737
+ context?: {
9738
+ fileIds?: string[] | undefined;
9739
+ knowledgeBaseIds?: string[] | undefined;
9740
+ skillIds?: string[] | undefined;
9741
+ memory?: {
9742
+ scope: "user" | "none" | "space";
9743
+ spaceId?: string | undefined;
9744
+ write?: "none" | "confirm" | "on-success" | undefined;
9745
+ } | undefined;
9746
+ } | undefined;
9747
+ tools?: {
9748
+ allow?: string[] | undefined;
9749
+ } | undefined;
9750
+ capabilities?: string[] | undefined;
9751
+ permissions?: {
9752
+ profile?: "read-only" | "workspace" | "full-access" | undefined;
9753
+ approval?: "never" | "on-request" | undefined;
9754
+ ruleIds?: string[] | undefined;
9755
+ } | undefined;
9756
+ limits?: {
9757
+ queueTimeoutMs?: number | undefined;
9758
+ runTimeoutMs?: number | undefined;
9759
+ approvalTimeoutMs?: number | undefined;
9760
+ maxOutputBytes?: number | undefined;
9761
+ } | undefined;
9762
+ output?: {
9763
+ format: "text" | "json";
9764
+ schema?: Record<string, z.core.util.JSONType> | undefined;
9765
+ } | undefined;
9766
+ native?: {
9767
+ adapter: string;
9768
+ options: Record<string, z.core.util.JSONType>;
9769
+ } | undefined;
9770
+ metadata?: Record<string, string> | undefined;
9771
+ } | undefined;
8330
9772
  } | {
8331
9773
  mode: "embedded";
8332
9774
  transport: "stdio";
@@ -8336,9 +9778,62 @@ declare function createACPOperations(provider: AIStoreProvider, config: AIConfig
8336
9778
  adapter: string;
8337
9779
  modelIds: string[];
8338
9780
  environmentRefs: Record<string, string>;
9781
+ environmentIds: string[];
9782
+ allowedCapabilities: string[];
8339
9783
  command?: string | undefined;
8340
9784
  args?: string[] | undefined;
8341
9785
  defaultModelId?: string | undefined;
9786
+ defaults?: {
9787
+ model?: {
9788
+ id?: string | undefined;
9789
+ reasoningEffort?: string | undefined;
9790
+ temperature?: number | undefined;
9791
+ maxOutputTokens?: number | undefined;
9792
+ } | undefined;
9793
+ execution?: {
9794
+ mode?: "auto" | "shared" | "user" | "task" | undefined;
9795
+ environmentId?: string | undefined;
9796
+ resources?: {
9797
+ cpu?: number | undefined;
9798
+ memoryMiB?: number | undefined;
9799
+ } | undefined;
9800
+ } | undefined;
9801
+ workspaceId?: string | undefined;
9802
+ context?: {
9803
+ fileIds?: string[] | undefined;
9804
+ knowledgeBaseIds?: string[] | undefined;
9805
+ skillIds?: string[] | undefined;
9806
+ memory?: {
9807
+ scope: "user" | "none" | "space";
9808
+ spaceId?: string | undefined;
9809
+ write?: "none" | "confirm" | "on-success" | undefined;
9810
+ } | undefined;
9811
+ } | undefined;
9812
+ tools?: {
9813
+ allow?: string[] | undefined;
9814
+ } | undefined;
9815
+ capabilities?: string[] | undefined;
9816
+ permissions?: {
9817
+ profile?: "read-only" | "workspace" | "full-access" | undefined;
9818
+ approval?: "never" | "on-request" | undefined;
9819
+ ruleIds?: string[] | undefined;
9820
+ } | undefined;
9821
+ limits?: {
9822
+ queueTimeoutMs?: number | undefined;
9823
+ runTimeoutMs?: number | undefined;
9824
+ approvalTimeoutMs?: number | undefined;
9825
+ maxOutputBytes?: number | undefined;
9826
+ } | undefined;
9827
+ output?: {
9828
+ format: "text" | "json";
9829
+ schema?: Record<string, z.core.util.JSONType> | undefined;
9830
+ } | undefined;
9831
+ native?: {
9832
+ adapter: string;
9833
+ options: Record<string, z.core.util.JSONType>;
9834
+ } | undefined;
9835
+ metadata?: Record<string, string> | undefined;
9836
+ } | undefined;
8342
9837
  } | {
8343
9838
  mode: "builtin-service";
8344
9839
  transport: "stdio";
@@ -8350,9 +9845,62 @@ declare function createACPOperations(provider: AIStoreProvider, config: AIConfig
8350
9845
  adapter: string;
8351
9846
  modelIds: string[];
8352
9847
  environmentRefs: Record<string, string>;
9848
+ environmentIds: string[];
9849
+ allowedCapabilities: string[];
8353
9850
  command?: string | undefined;
8354
9851
  args?: string[] | undefined;
8355
9852
  defaultModelId?: string | undefined;
9853
+ defaults?: {
9854
+ model?: {
9855
+ id?: string | undefined;
9856
+ reasoningEffort?: string | undefined;
9857
+ temperature?: number | undefined;
9858
+ maxOutputTokens?: number | undefined;
9859
+ } | undefined;
9860
+ execution?: {
9861
+ mode?: "auto" | "shared" | "user" | "task" | undefined;
9862
+ environmentId?: string | undefined;
9863
+ resources?: {
9864
+ cpu?: number | undefined;
9865
+ memoryMiB?: number | undefined;
9866
+ } | undefined;
9867
+ } | undefined;
9868
+ workspaceId?: string | undefined;
9869
+ context?: {
9870
+ fileIds?: string[] | undefined;
9871
+ knowledgeBaseIds?: string[] | undefined;
9872
+ skillIds?: string[] | undefined;
9873
+ memory?: {
9874
+ scope: "user" | "none" | "space";
9875
+ spaceId?: string | undefined;
9876
+ write?: "none" | "confirm" | "on-success" | undefined;
9877
+ } | undefined;
9878
+ } | undefined;
9879
+ tools?: {
9880
+ allow?: string[] | undefined;
9881
+ } | undefined;
9882
+ capabilities?: string[] | undefined;
9883
+ permissions?: {
9884
+ profile?: "read-only" | "workspace" | "full-access" | undefined;
9885
+ approval?: "never" | "on-request" | undefined;
9886
+ ruleIds?: string[] | undefined;
9887
+ } | undefined;
9888
+ limits?: {
9889
+ queueTimeoutMs?: number | undefined;
9890
+ runTimeoutMs?: number | undefined;
9891
+ approvalTimeoutMs?: number | undefined;
9892
+ maxOutputBytes?: number | undefined;
9893
+ } | undefined;
9894
+ output?: {
9895
+ format: "text" | "json";
9896
+ schema?: Record<string, z.core.util.JSONType> | undefined;
9897
+ } | undefined;
9898
+ native?: {
9899
+ adapter: string;
9900
+ options: Record<string, z.core.util.JSONType>;
9901
+ } | undefined;
9902
+ metadata?: Record<string, string> | undefined;
9903
+ } | undefined;
8356
9904
  }>>>;
8357
9905
  /**
8358
9906
  * 按 ID 读取合并清单条目;source 区分配置与数据库,数据库 get 返回 version。
@@ -8378,7 +9926,60 @@ declare function createACPOperations(provider: AIStoreProvider, config: AIConfig
8378
9926
  adapter: string;
8379
9927
  modelIds: string[];
8380
9928
  environmentRefs: Record<string, string>;
9929
+ environmentIds: string[];
9930
+ allowedCapabilities: string[];
8381
9931
  defaultModelId?: string | undefined;
9932
+ defaults?: {
9933
+ model?: {
9934
+ id?: string | undefined;
9935
+ reasoningEffort?: string | undefined;
9936
+ temperature?: number | undefined;
9937
+ maxOutputTokens?: number | undefined;
9938
+ } | undefined;
9939
+ execution?: {
9940
+ mode?: "auto" | "shared" | "user" | "task" | undefined;
9941
+ environmentId?: string | undefined;
9942
+ resources?: {
9943
+ cpu?: number | undefined;
9944
+ memoryMiB?: number | undefined;
9945
+ } | undefined;
9946
+ } | undefined;
9947
+ workspaceId?: string | undefined;
9948
+ context?: {
9949
+ fileIds?: string[] | undefined;
9950
+ knowledgeBaseIds?: string[] | undefined;
9951
+ skillIds?: string[] | undefined;
9952
+ memory?: {
9953
+ scope: "user" | "none" | "space";
9954
+ spaceId?: string | undefined;
9955
+ write?: "none" | "confirm" | "on-success" | undefined;
9956
+ } | undefined;
9957
+ } | undefined;
9958
+ tools?: {
9959
+ allow?: string[] | undefined;
9960
+ } | undefined;
9961
+ capabilities?: string[] | undefined;
9962
+ permissions?: {
9963
+ profile?: "read-only" | "workspace" | "full-access" | undefined;
9964
+ approval?: "never" | "on-request" | undefined;
9965
+ ruleIds?: string[] | undefined;
9966
+ } | undefined;
9967
+ limits?: {
9968
+ queueTimeoutMs?: number | undefined;
9969
+ runTimeoutMs?: number | undefined;
9970
+ approvalTimeoutMs?: number | undefined;
9971
+ maxOutputBytes?: number | undefined;
9972
+ } | undefined;
9973
+ output?: {
9974
+ format: "text" | "json";
9975
+ schema?: Record<string, z.core.util.JSONType> | undefined;
9976
+ } | undefined;
9977
+ native?: {
9978
+ adapter: string;
9979
+ options: Record<string, z.core.util.JSONType>;
9980
+ } | undefined;
9981
+ metadata?: Record<string, string> | undefined;
9982
+ } | undefined;
8382
9983
  } | {
8383
9984
  mode: "embedded";
8384
9985
  transport: "stdio";
@@ -8388,9 +9989,62 @@ declare function createACPOperations(provider: AIStoreProvider, config: AIConfig
8388
9989
  adapter: string;
8389
9990
  modelIds: string[];
8390
9991
  environmentRefs: Record<string, string>;
9992
+ environmentIds: string[];
9993
+ allowedCapabilities: string[];
8391
9994
  command?: string | undefined;
8392
9995
  args?: string[] | undefined;
8393
9996
  defaultModelId?: string | undefined;
9997
+ defaults?: {
9998
+ model?: {
9999
+ id?: string | undefined;
10000
+ reasoningEffort?: string | undefined;
10001
+ temperature?: number | undefined;
10002
+ maxOutputTokens?: number | undefined;
10003
+ } | undefined;
10004
+ execution?: {
10005
+ mode?: "auto" | "shared" | "user" | "task" | undefined;
10006
+ environmentId?: string | undefined;
10007
+ resources?: {
10008
+ cpu?: number | undefined;
10009
+ memoryMiB?: number | undefined;
10010
+ } | undefined;
10011
+ } | undefined;
10012
+ workspaceId?: string | undefined;
10013
+ context?: {
10014
+ fileIds?: string[] | undefined;
10015
+ knowledgeBaseIds?: string[] | undefined;
10016
+ skillIds?: string[] | undefined;
10017
+ memory?: {
10018
+ scope: "user" | "none" | "space";
10019
+ spaceId?: string | undefined;
10020
+ write?: "none" | "confirm" | "on-success" | undefined;
10021
+ } | undefined;
10022
+ } | undefined;
10023
+ tools?: {
10024
+ allow?: string[] | undefined;
10025
+ } | undefined;
10026
+ capabilities?: string[] | undefined;
10027
+ permissions?: {
10028
+ profile?: "read-only" | "workspace" | "full-access" | undefined;
10029
+ approval?: "never" | "on-request" | undefined;
10030
+ ruleIds?: string[] | undefined;
10031
+ } | undefined;
10032
+ limits?: {
10033
+ queueTimeoutMs?: number | undefined;
10034
+ runTimeoutMs?: number | undefined;
10035
+ approvalTimeoutMs?: number | undefined;
10036
+ maxOutputBytes?: number | undefined;
10037
+ } | undefined;
10038
+ output?: {
10039
+ format: "text" | "json";
10040
+ schema?: Record<string, z.core.util.JSONType> | undefined;
10041
+ } | undefined;
10042
+ native?: {
10043
+ adapter: string;
10044
+ options: Record<string, z.core.util.JSONType>;
10045
+ } | undefined;
10046
+ metadata?: Record<string, string> | undefined;
10047
+ } | undefined;
8394
10048
  } | {
8395
10049
  mode: "builtin-service";
8396
10050
  transport: "stdio";
@@ -8402,9 +10056,62 @@ declare function createACPOperations(provider: AIStoreProvider, config: AIConfig
8402
10056
  adapter: string;
8403
10057
  modelIds: string[];
8404
10058
  environmentRefs: Record<string, string>;
10059
+ environmentIds: string[];
10060
+ allowedCapabilities: string[];
8405
10061
  command?: string | undefined;
8406
10062
  args?: string[] | undefined;
8407
10063
  defaultModelId?: string | undefined;
10064
+ defaults?: {
10065
+ model?: {
10066
+ id?: string | undefined;
10067
+ reasoningEffort?: string | undefined;
10068
+ temperature?: number | undefined;
10069
+ maxOutputTokens?: number | undefined;
10070
+ } | undefined;
10071
+ execution?: {
10072
+ mode?: "auto" | "shared" | "user" | "task" | undefined;
10073
+ environmentId?: string | undefined;
10074
+ resources?: {
10075
+ cpu?: number | undefined;
10076
+ memoryMiB?: number | undefined;
10077
+ } | undefined;
10078
+ } | undefined;
10079
+ workspaceId?: string | undefined;
10080
+ context?: {
10081
+ fileIds?: string[] | undefined;
10082
+ knowledgeBaseIds?: string[] | undefined;
10083
+ skillIds?: string[] | undefined;
10084
+ memory?: {
10085
+ scope: "user" | "none" | "space";
10086
+ spaceId?: string | undefined;
10087
+ write?: "none" | "confirm" | "on-success" | undefined;
10088
+ } | undefined;
10089
+ } | undefined;
10090
+ tools?: {
10091
+ allow?: string[] | undefined;
10092
+ } | undefined;
10093
+ capabilities?: string[] | undefined;
10094
+ permissions?: {
10095
+ profile?: "read-only" | "workspace" | "full-access" | undefined;
10096
+ approval?: "never" | "on-request" | undefined;
10097
+ ruleIds?: string[] | undefined;
10098
+ } | undefined;
10099
+ limits?: {
10100
+ queueTimeoutMs?: number | undefined;
10101
+ runTimeoutMs?: number | undefined;
10102
+ approvalTimeoutMs?: number | undefined;
10103
+ maxOutputBytes?: number | undefined;
10104
+ } | undefined;
10105
+ output?: {
10106
+ format: "text" | "json";
10107
+ schema?: Record<string, z.core.util.JSONType> | undefined;
10108
+ } | undefined;
10109
+ native?: {
10110
+ adapter: string;
10111
+ options: Record<string, z.core.util.JSONType>;
10112
+ } | undefined;
10113
+ metadata?: Record<string, string> | undefined;
10114
+ } | undefined;
8408
10115
  }>>>;
8409
10116
  /**
8410
10117
  * 列出配置与数据库合并后的智能体;同 ID 配置优先。
@@ -8429,7 +10136,60 @@ declare function createACPOperations(provider: AIStoreProvider, config: AIConfig
8429
10136
  adapter: string;
8430
10137
  modelIds: string[];
8431
10138
  environmentRefs: Record<string, string>;
10139
+ environmentIds: string[];
10140
+ allowedCapabilities: string[];
8432
10141
  defaultModelId?: string | undefined;
10142
+ defaults?: {
10143
+ model?: {
10144
+ id?: string | undefined;
10145
+ reasoningEffort?: string | undefined;
10146
+ temperature?: number | undefined;
10147
+ maxOutputTokens?: number | undefined;
10148
+ } | undefined;
10149
+ execution?: {
10150
+ mode?: "auto" | "shared" | "user" | "task" | undefined;
10151
+ environmentId?: string | undefined;
10152
+ resources?: {
10153
+ cpu?: number | undefined;
10154
+ memoryMiB?: number | undefined;
10155
+ } | undefined;
10156
+ } | undefined;
10157
+ workspaceId?: string | undefined;
10158
+ context?: {
10159
+ fileIds?: string[] | undefined;
10160
+ knowledgeBaseIds?: string[] | undefined;
10161
+ skillIds?: string[] | undefined;
10162
+ memory?: {
10163
+ scope: "user" | "none" | "space";
10164
+ spaceId?: string | undefined;
10165
+ write?: "none" | "confirm" | "on-success" | undefined;
10166
+ } | undefined;
10167
+ } | undefined;
10168
+ tools?: {
10169
+ allow?: string[] | undefined;
10170
+ } | undefined;
10171
+ capabilities?: string[] | undefined;
10172
+ permissions?: {
10173
+ profile?: "read-only" | "workspace" | "full-access" | undefined;
10174
+ approval?: "never" | "on-request" | undefined;
10175
+ ruleIds?: string[] | undefined;
10176
+ } | undefined;
10177
+ limits?: {
10178
+ queueTimeoutMs?: number | undefined;
10179
+ runTimeoutMs?: number | undefined;
10180
+ approvalTimeoutMs?: number | undefined;
10181
+ maxOutputBytes?: number | undefined;
10182
+ } | undefined;
10183
+ output?: {
10184
+ format: "text" | "json";
10185
+ schema?: Record<string, z.core.util.JSONType> | undefined;
10186
+ } | undefined;
10187
+ native?: {
10188
+ adapter: string;
10189
+ options: Record<string, z.core.util.JSONType>;
10190
+ } | undefined;
10191
+ metadata?: Record<string, string> | undefined;
10192
+ } | undefined;
8433
10193
  } | {
8434
10194
  mode: "embedded";
8435
10195
  transport: "stdio";
@@ -8439,9 +10199,62 @@ declare function createACPOperations(provider: AIStoreProvider, config: AIConfig
8439
10199
  adapter: string;
8440
10200
  modelIds: string[];
8441
10201
  environmentRefs: Record<string, string>;
10202
+ environmentIds: string[];
10203
+ allowedCapabilities: string[];
8442
10204
  command?: string | undefined;
8443
10205
  args?: string[] | undefined;
8444
10206
  defaultModelId?: string | undefined;
10207
+ defaults?: {
10208
+ model?: {
10209
+ id?: string | undefined;
10210
+ reasoningEffort?: string | undefined;
10211
+ temperature?: number | undefined;
10212
+ maxOutputTokens?: number | undefined;
10213
+ } | undefined;
10214
+ execution?: {
10215
+ mode?: "auto" | "shared" | "user" | "task" | undefined;
10216
+ environmentId?: string | undefined;
10217
+ resources?: {
10218
+ cpu?: number | undefined;
10219
+ memoryMiB?: number | undefined;
10220
+ } | undefined;
10221
+ } | undefined;
10222
+ workspaceId?: string | undefined;
10223
+ context?: {
10224
+ fileIds?: string[] | undefined;
10225
+ knowledgeBaseIds?: string[] | undefined;
10226
+ skillIds?: string[] | undefined;
10227
+ memory?: {
10228
+ scope: "user" | "none" | "space";
10229
+ spaceId?: string | undefined;
10230
+ write?: "none" | "confirm" | "on-success" | undefined;
10231
+ } | undefined;
10232
+ } | undefined;
10233
+ tools?: {
10234
+ allow?: string[] | undefined;
10235
+ } | undefined;
10236
+ capabilities?: string[] | undefined;
10237
+ permissions?: {
10238
+ profile?: "read-only" | "workspace" | "full-access" | undefined;
10239
+ approval?: "never" | "on-request" | undefined;
10240
+ ruleIds?: string[] | undefined;
10241
+ } | undefined;
10242
+ limits?: {
10243
+ queueTimeoutMs?: number | undefined;
10244
+ runTimeoutMs?: number | undefined;
10245
+ approvalTimeoutMs?: number | undefined;
10246
+ maxOutputBytes?: number | undefined;
10247
+ } | undefined;
10248
+ output?: {
10249
+ format: "text" | "json";
10250
+ schema?: Record<string, z.core.util.JSONType> | undefined;
10251
+ } | undefined;
10252
+ native?: {
10253
+ adapter: string;
10254
+ options: Record<string, z.core.util.JSONType>;
10255
+ } | undefined;
10256
+ metadata?: Record<string, string> | undefined;
10257
+ } | undefined;
8445
10258
  } | {
8446
10259
  mode: "builtin-service";
8447
10260
  transport: "stdio";
@@ -8453,9 +10266,62 @@ declare function createACPOperations(provider: AIStoreProvider, config: AIConfig
8453
10266
  adapter: string;
8454
10267
  modelIds: string[];
8455
10268
  environmentRefs: Record<string, string>;
10269
+ environmentIds: string[];
10270
+ allowedCapabilities: string[];
8456
10271
  command?: string | undefined;
8457
10272
  args?: string[] | undefined;
8458
10273
  defaultModelId?: string | undefined;
10274
+ defaults?: {
10275
+ model?: {
10276
+ id?: string | undefined;
10277
+ reasoningEffort?: string | undefined;
10278
+ temperature?: number | undefined;
10279
+ maxOutputTokens?: number | undefined;
10280
+ } | undefined;
10281
+ execution?: {
10282
+ mode?: "auto" | "shared" | "user" | "task" | undefined;
10283
+ environmentId?: string | undefined;
10284
+ resources?: {
10285
+ cpu?: number | undefined;
10286
+ memoryMiB?: number | undefined;
10287
+ } | undefined;
10288
+ } | undefined;
10289
+ workspaceId?: string | undefined;
10290
+ context?: {
10291
+ fileIds?: string[] | undefined;
10292
+ knowledgeBaseIds?: string[] | undefined;
10293
+ skillIds?: string[] | undefined;
10294
+ memory?: {
10295
+ scope: "user" | "none" | "space";
10296
+ spaceId?: string | undefined;
10297
+ write?: "none" | "confirm" | "on-success" | undefined;
10298
+ } | undefined;
10299
+ } | undefined;
10300
+ tools?: {
10301
+ allow?: string[] | undefined;
10302
+ } | undefined;
10303
+ capabilities?: string[] | undefined;
10304
+ permissions?: {
10305
+ profile?: "read-only" | "workspace" | "full-access" | undefined;
10306
+ approval?: "never" | "on-request" | undefined;
10307
+ ruleIds?: string[] | undefined;
10308
+ } | undefined;
10309
+ limits?: {
10310
+ queueTimeoutMs?: number | undefined;
10311
+ runTimeoutMs?: number | undefined;
10312
+ approvalTimeoutMs?: number | undefined;
10313
+ maxOutputBytes?: number | undefined;
10314
+ } | undefined;
10315
+ output?: {
10316
+ format: "text" | "json";
10317
+ schema?: Record<string, z.core.util.JSONType> | undefined;
10318
+ } | undefined;
10319
+ native?: {
10320
+ adapter: string;
10321
+ options: Record<string, z.core.util.JSONType>;
10322
+ } | undefined;
10323
+ metadata?: Record<string, string> | undefined;
10324
+ } | undefined;
8459
10325
  }>[]>>;
8460
10326
  /**
8461
10327
  * 整体替换数据库智能体;可传入 get 返回的版本防止覆盖并发修改,配置条目不可改。
@@ -8483,7 +10349,60 @@ declare function createACPOperations(provider: AIStoreProvider, config: AIConfig
8483
10349
  adapter: string;
8484
10350
  modelIds: string[];
8485
10351
  environmentRefs: Record<string, string>;
10352
+ environmentIds: string[];
10353
+ allowedCapabilities: string[];
8486
10354
  defaultModelId?: string | undefined;
10355
+ defaults?: {
10356
+ model?: {
10357
+ id?: string | undefined;
10358
+ reasoningEffort?: string | undefined;
10359
+ temperature?: number | undefined;
10360
+ maxOutputTokens?: number | undefined;
10361
+ } | undefined;
10362
+ execution?: {
10363
+ mode?: "auto" | "shared" | "user" | "task" | undefined;
10364
+ environmentId?: string | undefined;
10365
+ resources?: {
10366
+ cpu?: number | undefined;
10367
+ memoryMiB?: number | undefined;
10368
+ } | undefined;
10369
+ } | undefined;
10370
+ workspaceId?: string | undefined;
10371
+ context?: {
10372
+ fileIds?: string[] | undefined;
10373
+ knowledgeBaseIds?: string[] | undefined;
10374
+ skillIds?: string[] | undefined;
10375
+ memory?: {
10376
+ scope: "user" | "none" | "space";
10377
+ spaceId?: string | undefined;
10378
+ write?: "none" | "confirm" | "on-success" | undefined;
10379
+ } | undefined;
10380
+ } | undefined;
10381
+ tools?: {
10382
+ allow?: string[] | undefined;
10383
+ } | undefined;
10384
+ capabilities?: string[] | undefined;
10385
+ permissions?: {
10386
+ profile?: "read-only" | "workspace" | "full-access" | undefined;
10387
+ approval?: "never" | "on-request" | undefined;
10388
+ ruleIds?: string[] | undefined;
10389
+ } | undefined;
10390
+ limits?: {
10391
+ queueTimeoutMs?: number | undefined;
10392
+ runTimeoutMs?: number | undefined;
10393
+ approvalTimeoutMs?: number | undefined;
10394
+ maxOutputBytes?: number | undefined;
10395
+ } | undefined;
10396
+ output?: {
10397
+ format: "text" | "json";
10398
+ schema?: Record<string, z.core.util.JSONType> | undefined;
10399
+ } | undefined;
10400
+ native?: {
10401
+ adapter: string;
10402
+ options: Record<string, z.core.util.JSONType>;
10403
+ } | undefined;
10404
+ metadata?: Record<string, string> | undefined;
10405
+ } | undefined;
8487
10406
  } | {
8488
10407
  mode: "embedded";
8489
10408
  transport: "stdio";
@@ -8493,9 +10412,62 @@ declare function createACPOperations(provider: AIStoreProvider, config: AIConfig
8493
10412
  adapter: string;
8494
10413
  modelIds: string[];
8495
10414
  environmentRefs: Record<string, string>;
10415
+ environmentIds: string[];
10416
+ allowedCapabilities: string[];
8496
10417
  command?: string | undefined;
8497
10418
  args?: string[] | undefined;
8498
10419
  defaultModelId?: string | undefined;
10420
+ defaults?: {
10421
+ model?: {
10422
+ id?: string | undefined;
10423
+ reasoningEffort?: string | undefined;
10424
+ temperature?: number | undefined;
10425
+ maxOutputTokens?: number | undefined;
10426
+ } | undefined;
10427
+ execution?: {
10428
+ mode?: "auto" | "shared" | "user" | "task" | undefined;
10429
+ environmentId?: string | undefined;
10430
+ resources?: {
10431
+ cpu?: number | undefined;
10432
+ memoryMiB?: number | undefined;
10433
+ } | undefined;
10434
+ } | undefined;
10435
+ workspaceId?: string | undefined;
10436
+ context?: {
10437
+ fileIds?: string[] | undefined;
10438
+ knowledgeBaseIds?: string[] | undefined;
10439
+ skillIds?: string[] | undefined;
10440
+ memory?: {
10441
+ scope: "user" | "none" | "space";
10442
+ spaceId?: string | undefined;
10443
+ write?: "none" | "confirm" | "on-success" | undefined;
10444
+ } | undefined;
10445
+ } | undefined;
10446
+ tools?: {
10447
+ allow?: string[] | undefined;
10448
+ } | undefined;
10449
+ capabilities?: string[] | undefined;
10450
+ permissions?: {
10451
+ profile?: "read-only" | "workspace" | "full-access" | undefined;
10452
+ approval?: "never" | "on-request" | undefined;
10453
+ ruleIds?: string[] | undefined;
10454
+ } | undefined;
10455
+ limits?: {
10456
+ queueTimeoutMs?: number | undefined;
10457
+ runTimeoutMs?: number | undefined;
10458
+ approvalTimeoutMs?: number | undefined;
10459
+ maxOutputBytes?: number | undefined;
10460
+ } | undefined;
10461
+ output?: {
10462
+ format: "text" | "json";
10463
+ schema?: Record<string, z.core.util.JSONType> | undefined;
10464
+ } | undefined;
10465
+ native?: {
10466
+ adapter: string;
10467
+ options: Record<string, z.core.util.JSONType>;
10468
+ } | undefined;
10469
+ metadata?: Record<string, string> | undefined;
10470
+ } | undefined;
8499
10471
  } | {
8500
10472
  mode: "builtin-service";
8501
10473
  transport: "stdio";
@@ -8507,9 +10479,62 @@ declare function createACPOperations(provider: AIStoreProvider, config: AIConfig
8507
10479
  adapter: string;
8508
10480
  modelIds: string[];
8509
10481
  environmentRefs: Record<string, string>;
10482
+ environmentIds: string[];
10483
+ allowedCapabilities: string[];
8510
10484
  command?: string | undefined;
8511
10485
  args?: string[] | undefined;
8512
10486
  defaultModelId?: string | undefined;
10487
+ defaults?: {
10488
+ model?: {
10489
+ id?: string | undefined;
10490
+ reasoningEffort?: string | undefined;
10491
+ temperature?: number | undefined;
10492
+ maxOutputTokens?: number | undefined;
10493
+ } | undefined;
10494
+ execution?: {
10495
+ mode?: "auto" | "shared" | "user" | "task" | undefined;
10496
+ environmentId?: string | undefined;
10497
+ resources?: {
10498
+ cpu?: number | undefined;
10499
+ memoryMiB?: number | undefined;
10500
+ } | undefined;
10501
+ } | undefined;
10502
+ workspaceId?: string | undefined;
10503
+ context?: {
10504
+ fileIds?: string[] | undefined;
10505
+ knowledgeBaseIds?: string[] | undefined;
10506
+ skillIds?: string[] | undefined;
10507
+ memory?: {
10508
+ scope: "user" | "none" | "space";
10509
+ spaceId?: string | undefined;
10510
+ write?: "none" | "confirm" | "on-success" | undefined;
10511
+ } | undefined;
10512
+ } | undefined;
10513
+ tools?: {
10514
+ allow?: string[] | undefined;
10515
+ } | undefined;
10516
+ capabilities?: string[] | undefined;
10517
+ permissions?: {
10518
+ profile?: "read-only" | "workspace" | "full-access" | undefined;
10519
+ approval?: "never" | "on-request" | undefined;
10520
+ ruleIds?: string[] | undefined;
10521
+ } | undefined;
10522
+ limits?: {
10523
+ queueTimeoutMs?: number | undefined;
10524
+ runTimeoutMs?: number | undefined;
10525
+ approvalTimeoutMs?: number | undefined;
10526
+ maxOutputBytes?: number | undefined;
10527
+ } | undefined;
10528
+ output?: {
10529
+ format: "text" | "json";
10530
+ schema?: Record<string, z.core.util.JSONType> | undefined;
10531
+ } | undefined;
10532
+ native?: {
10533
+ adapter: string;
10534
+ options: Record<string, z.core.util.JSONType>;
10535
+ } | undefined;
10536
+ metadata?: Record<string, string> | undefined;
10537
+ } | undefined;
8513
10538
  }>>>;
8514
10539
  /**
8515
10540
  * 删除无会话引用的数据库智能体定义;不删除镜像或外部服务。
@@ -9680,6 +11705,10 @@ interface ACPClientOptions {
9680
11705
  * ```
9681
11706
  */
9682
11707
  interface ACPAgentAdapter {
11708
+ /** 仅已验证无原生越权入口、能安全隔离并关闭会话的适配器可声明。 */
11709
+ sharedSessions?: true;
11710
+ /** 验证原生扩展并返回实际生效的选项。 */
11711
+ nativeOptions?: z.ZodType<Record<string, _h_ai_runner.RunnerJson>>;
9683
11712
  /**
9684
11713
  * 生成当前会话的原生启动参数;实现可以异步,不应在此启动进程或持久保存密钥。
9685
11714
  * @param input - 智能体、已解析模型与独立状态目录。
@@ -9711,6 +11740,12 @@ interface ACPAgentAdapterInput {
9711
11740
  modelId?: string;
9712
11741
  /** 已创建的专属状态目录;托管容器内使用 /state/<会话 ID>。 */
9713
11742
  statePath: string;
11743
+ /** 受管任务请求的权限范围。 */
11744
+ permissionProfile?: 'read-only' | 'workspace' | 'full-access';
11745
+ /** 已由适配器 Schema 校验的原生扩展选项。 */
11746
+ nativeOptions?: Record<string, _h_ai_runner.RunnerJson>;
11747
+ /** 模型声明支持且适配器可落实的推理级别。 */
11748
+ reasoningEffort?: string;
9714
11749
  }
9715
11750
  /**
9716
11751
  * 单次启动的原生配置;env 可能含凭据,不可向浏览器或日志直接公开。
@@ -9865,4 +11900,4 @@ interface ACPGitReport {
9865
11900
  type ACPOperations = ReturnType<typeof createACPOperations>;
9866
11901
 
9867
11902
  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 };
11903
+ 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, MCPJobFiles 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, ACPApprovalDecision as dT, ACPPlatformPolicy as dU, ACPPlatformRequest as dV, ACPRunObserver as dW, ACPRunRequest as dX, ACPSessionWorkspace as dY, ACPTurnOptions as dZ, MCPJobFileContext as d_, 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, MCPServiceAuthorization as e0, MCPServiceBinding as e1, MCPServiceBindingRequest as e2, MCPServiceBroker as e3, MCPServiceBrokerOptions as e4, MCPServiceOperations as e5, MCPServiceRequest as e6, 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 };