@tbox.cn/app-contracts 0.13.2 → 0.13.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,441 @@
1
+ /**
2
+ * Integrations 配置解析(integrations v6:模块所有权模型 + 绑定组整组继承 + catalog 派生 +
3
+ * 部署实例注册表)。zod 单源纯函数:三模板 I/O 壳共用(base/mall 壳展开占位后传入;support 壳
4
+ * 无展开通道直传)。断言顺序固定:assertNoInlineSecrets(防线单点)→ zod strict(拼错键启动即报)
5
+ * ——与既有 loader 链序一致(展开归调用方壳层,本函数只管 断言 → 校验)。
6
+ * 绑定组语义:implementation 需伴随 provider(impl-only 非法——provider 是绑定组头);
7
+ * 内联厂商声明仅槽级且必带 implementation(内联无派生源)。
8
+ * v4 部署实例注册表:instances 非空数组(无表 = 键缺席唯一写法);id 查重 + 禁 '*';
9
+ * defaultInstanceId ∈ ids(无表时独立在场 = env 注入动态默认形态,免 ∈ 校验)。
10
+ * v6:modules 节 = 模块集成位三键 {provider?, config?, resources?}(归属模型——service →
11
+ * owner 归属表由装配期 buildOwnershipMap 注入,本文件只管形状);顶层 domains 键退役
12
+ * (legacy 防线拒收 + migrate 指引)。
13
+ */
14
+ import { z } from 'zod';
1
15
  import type { IntegrationsConfig } from './providers';
16
+ /** integrations.json 根形状(唯一 ByInstance 层 = root 四字段;v4 实例注册表;v6 modules 集成位)。
17
+ * 元键($comment/$schema):类型可选、行为惰性——供 CLI/文档写入 schema 指针;求值路径零消费,
18
+ * 根级 `$comment` 子树不参与机密形态检查(注释里的普通词不误触 boot;嵌套 `$comment` 照常扫描)。
19
+ * 其他文件(strictObject 的 agent.jsonc / 外部插件面)不种入元键——避免 fail-soft 静默回退或外部包拒收。 */
20
+ export declare const integrationsSchema: z.ZodEffects<z.ZodObject<{
21
+ $comment: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
22
+ $schema: z.ZodOptional<z.ZodString>;
23
+ provider: z.ZodOptional<z.ZodString>;
24
+ config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
25
+ configByInstance: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
26
+ credentialRef: z.ZodOptional<z.ZodString>;
27
+ credentialRefByInstance: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
28
+ instances: z.ZodOptional<z.ZodArray<z.ZodObject<{
29
+ id: z.ZodString;
30
+ name: z.ZodString;
31
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
32
+ }, "strict", z.ZodTypeAny, {
33
+ name: string;
34
+ id: string;
35
+ attributes?: Record<string, unknown> | undefined;
36
+ }, {
37
+ name: string;
38
+ id: string;
39
+ attributes?: Record<string, unknown> | undefined;
40
+ }>, "many">>;
41
+ defaultInstanceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
42
+ modules: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodObject<{
43
+ provider: z.ZodOptional<z.ZodString>;
44
+ config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
45
+ credentialRef: z.ZodOptional<z.ZodString>;
46
+ resources: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
47
+ type: z.ZodLiteral<"knowledge">;
48
+ datasetId: z.ZodOptional<z.ZodString>;
49
+ ref: z.ZodOptional<z.ZodString>;
50
+ topK: z.ZodOptional<z.ZodNumber>;
51
+ scoreThreshold: z.ZodOptional<z.ZodNumber>;
52
+ }, "strict", z.ZodTypeAny, {
53
+ type: "knowledge";
54
+ topK?: number | undefined;
55
+ datasetId?: string | undefined;
56
+ ref?: string | undefined;
57
+ scoreThreshold?: number | undefined;
58
+ }, {
59
+ type: "knowledge";
60
+ topK?: number | undefined;
61
+ datasetId?: string | undefined;
62
+ ref?: string | undefined;
63
+ scoreThreshold?: number | undefined;
64
+ }>]>, {
65
+ type: "knowledge";
66
+ topK?: number | undefined;
67
+ datasetId?: string | undefined;
68
+ ref?: string | undefined;
69
+ scoreThreshold?: number | undefined;
70
+ }, {
71
+ type: "knowledge";
72
+ topK?: number | undefined;
73
+ datasetId?: string | undefined;
74
+ ref?: string | undefined;
75
+ scoreThreshold?: number | undefined;
76
+ }>>>;
77
+ }, "strict", z.ZodTypeAny, {
78
+ provider?: string | undefined;
79
+ credentialRef?: string | undefined;
80
+ config?: Record<string, unknown> | undefined;
81
+ resources?: Record<string, {
82
+ type: "knowledge";
83
+ topK?: number | undefined;
84
+ datasetId?: string | undefined;
85
+ ref?: string | undefined;
86
+ scoreThreshold?: number | undefined;
87
+ }> | undefined;
88
+ }, {
89
+ provider?: string | undefined;
90
+ credentialRef?: string | undefined;
91
+ config?: Record<string, unknown> | undefined;
92
+ resources?: Record<string, {
93
+ type: "knowledge";
94
+ topK?: number | undefined;
95
+ datasetId?: string | undefined;
96
+ ref?: string | undefined;
97
+ scoreThreshold?: number | undefined;
98
+ }> | undefined;
99
+ }>, {
100
+ provider?: string | undefined;
101
+ credentialRef?: string | undefined;
102
+ config?: Record<string, unknown> | undefined;
103
+ resources?: Record<string, {
104
+ type: "knowledge";
105
+ topK?: number | undefined;
106
+ datasetId?: string | undefined;
107
+ ref?: string | undefined;
108
+ scoreThreshold?: number | undefined;
109
+ }> | undefined;
110
+ }, {
111
+ provider?: string | undefined;
112
+ credentialRef?: string | undefined;
113
+ config?: Record<string, unknown> | undefined;
114
+ resources?: Record<string, {
115
+ type: "knowledge";
116
+ topK?: number | undefined;
117
+ datasetId?: string | undefined;
118
+ ref?: string | undefined;
119
+ scoreThreshold?: number | undefined;
120
+ }> | undefined;
121
+ }>>>;
122
+ services: z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodEffects<z.ZodObject<{
123
+ provider: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
124
+ provider: z.ZodString;
125
+ credentialType: z.ZodString;
126
+ configSchema: z.ZodOptional<z.ZodString>;
127
+ }, "strict", z.ZodTypeAny, {
128
+ provider: string;
129
+ credentialType: string;
130
+ configSchema?: string | undefined;
131
+ }, {
132
+ provider: string;
133
+ credentialType: string;
134
+ configSchema?: string | undefined;
135
+ }>]>>;
136
+ implementation: z.ZodOptional<z.ZodString>;
137
+ config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
138
+ credentialRef: z.ZodOptional<z.ZodString>;
139
+ instances: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodObject<{
140
+ provider: z.ZodOptional<z.ZodString>;
141
+ implementation: z.ZodOptional<z.ZodString>;
142
+ config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
143
+ credentialRef: z.ZodOptional<z.ZodString>;
144
+ enabled: z.ZodOptional<z.ZodBoolean>;
145
+ }, "strict", z.ZodTypeAny, {
146
+ provider?: string | undefined;
147
+ credentialRef?: string | undefined;
148
+ config?: Record<string, unknown> | undefined;
149
+ implementation?: string | undefined;
150
+ enabled?: boolean | undefined;
151
+ }, {
152
+ provider?: string | undefined;
153
+ credentialRef?: string | undefined;
154
+ config?: Record<string, unknown> | undefined;
155
+ implementation?: string | undefined;
156
+ enabled?: boolean | undefined;
157
+ }>, {
158
+ provider?: string | undefined;
159
+ credentialRef?: string | undefined;
160
+ config?: Record<string, unknown> | undefined;
161
+ implementation?: string | undefined;
162
+ enabled?: boolean | undefined;
163
+ }, {
164
+ provider?: string | undefined;
165
+ credentialRef?: string | undefined;
166
+ config?: Record<string, unknown> | undefined;
167
+ implementation?: string | undefined;
168
+ enabled?: boolean | undefined;
169
+ }>>>;
170
+ }, "strict", z.ZodTypeAny, {
171
+ provider?: string | {
172
+ provider: string;
173
+ credentialType: string;
174
+ configSchema?: string | undefined;
175
+ } | undefined;
176
+ credentialRef?: string | undefined;
177
+ instances?: Record<string, {
178
+ provider?: string | undefined;
179
+ credentialRef?: string | undefined;
180
+ config?: Record<string, unknown> | undefined;
181
+ implementation?: string | undefined;
182
+ enabled?: boolean | undefined;
183
+ }> | undefined;
184
+ config?: Record<string, unknown> | undefined;
185
+ implementation?: string | undefined;
186
+ }, {
187
+ provider?: string | {
188
+ provider: string;
189
+ credentialType: string;
190
+ configSchema?: string | undefined;
191
+ } | undefined;
192
+ credentialRef?: string | undefined;
193
+ instances?: Record<string, {
194
+ provider?: string | undefined;
195
+ credentialRef?: string | undefined;
196
+ config?: Record<string, unknown> | undefined;
197
+ implementation?: string | undefined;
198
+ enabled?: boolean | undefined;
199
+ }> | undefined;
200
+ config?: Record<string, unknown> | undefined;
201
+ implementation?: string | undefined;
202
+ }>, {
203
+ provider?: string | {
204
+ provider: string;
205
+ credentialType: string;
206
+ configSchema?: string | undefined;
207
+ } | undefined;
208
+ credentialRef?: string | undefined;
209
+ instances?: Record<string, {
210
+ provider?: string | undefined;
211
+ credentialRef?: string | undefined;
212
+ config?: Record<string, unknown> | undefined;
213
+ implementation?: string | undefined;
214
+ enabled?: boolean | undefined;
215
+ }> | undefined;
216
+ config?: Record<string, unknown> | undefined;
217
+ implementation?: string | undefined;
218
+ }, {
219
+ provider?: string | {
220
+ provider: string;
221
+ credentialType: string;
222
+ configSchema?: string | undefined;
223
+ } | undefined;
224
+ credentialRef?: string | undefined;
225
+ instances?: Record<string, {
226
+ provider?: string | undefined;
227
+ credentialRef?: string | undefined;
228
+ config?: Record<string, unknown> | undefined;
229
+ implementation?: string | undefined;
230
+ enabled?: boolean | undefined;
231
+ }> | undefined;
232
+ config?: Record<string, unknown> | undefined;
233
+ implementation?: string | undefined;
234
+ }>, {
235
+ provider?: string | {
236
+ provider: string;
237
+ credentialType: string;
238
+ configSchema?: string | undefined;
239
+ } | undefined;
240
+ credentialRef?: string | undefined;
241
+ instances?: Record<string, {
242
+ provider?: string | undefined;
243
+ credentialRef?: string | undefined;
244
+ config?: Record<string, unknown> | undefined;
245
+ implementation?: string | undefined;
246
+ enabled?: boolean | undefined;
247
+ }> | undefined;
248
+ config?: Record<string, unknown> | undefined;
249
+ implementation?: string | undefined;
250
+ }, {
251
+ provider?: string | {
252
+ provider: string;
253
+ credentialType: string;
254
+ configSchema?: string | undefined;
255
+ } | undefined;
256
+ credentialRef?: string | undefined;
257
+ instances?: Record<string, {
258
+ provider?: string | undefined;
259
+ credentialRef?: string | undefined;
260
+ config?: Record<string, unknown> | undefined;
261
+ implementation?: string | undefined;
262
+ enabled?: boolean | undefined;
263
+ }> | undefined;
264
+ config?: Record<string, unknown> | undefined;
265
+ implementation?: string | undefined;
266
+ }>>;
267
+ }, "strict", z.ZodTypeAny, {
268
+ services: Record<string, {
269
+ provider?: string | {
270
+ provider: string;
271
+ credentialType: string;
272
+ configSchema?: string | undefined;
273
+ } | undefined;
274
+ credentialRef?: string | undefined;
275
+ instances?: Record<string, {
276
+ provider?: string | undefined;
277
+ credentialRef?: string | undefined;
278
+ config?: Record<string, unknown> | undefined;
279
+ implementation?: string | undefined;
280
+ enabled?: boolean | undefined;
281
+ }> | undefined;
282
+ config?: Record<string, unknown> | undefined;
283
+ implementation?: string | undefined;
284
+ }>;
285
+ provider?: string | undefined;
286
+ credentialRef?: string | undefined;
287
+ instances?: {
288
+ name: string;
289
+ id: string;
290
+ attributes?: Record<string, unknown> | undefined;
291
+ }[] | undefined;
292
+ defaultInstanceId?: string | null | undefined;
293
+ config?: Record<string, unknown> | undefined;
294
+ configByInstance?: Record<string, Record<string, unknown>> | undefined;
295
+ credentialRefByInstance?: Record<string, string> | undefined;
296
+ modules?: Record<string, {
297
+ provider?: string | undefined;
298
+ credentialRef?: string | undefined;
299
+ config?: Record<string, unknown> | undefined;
300
+ resources?: Record<string, {
301
+ type: "knowledge";
302
+ topK?: number | undefined;
303
+ datasetId?: string | undefined;
304
+ ref?: string | undefined;
305
+ scoreThreshold?: number | undefined;
306
+ }> | undefined;
307
+ }> | undefined;
308
+ $comment?: string | Record<string, unknown> | undefined;
309
+ $schema?: string | undefined;
310
+ }, {
311
+ services: Record<string, {
312
+ provider?: string | {
313
+ provider: string;
314
+ credentialType: string;
315
+ configSchema?: string | undefined;
316
+ } | undefined;
317
+ credentialRef?: string | undefined;
318
+ instances?: Record<string, {
319
+ provider?: string | undefined;
320
+ credentialRef?: string | undefined;
321
+ config?: Record<string, unknown> | undefined;
322
+ implementation?: string | undefined;
323
+ enabled?: boolean | undefined;
324
+ }> | undefined;
325
+ config?: Record<string, unknown> | undefined;
326
+ implementation?: string | undefined;
327
+ }>;
328
+ provider?: string | undefined;
329
+ credentialRef?: string | undefined;
330
+ instances?: {
331
+ name: string;
332
+ id: string;
333
+ attributes?: Record<string, unknown> | undefined;
334
+ }[] | undefined;
335
+ defaultInstanceId?: string | null | undefined;
336
+ config?: Record<string, unknown> | undefined;
337
+ configByInstance?: Record<string, Record<string, unknown>> | undefined;
338
+ credentialRefByInstance?: Record<string, string> | undefined;
339
+ modules?: Record<string, {
340
+ provider?: string | undefined;
341
+ credentialRef?: string | undefined;
342
+ config?: Record<string, unknown> | undefined;
343
+ resources?: Record<string, {
344
+ type: "knowledge";
345
+ topK?: number | undefined;
346
+ datasetId?: string | undefined;
347
+ ref?: string | undefined;
348
+ scoreThreshold?: number | undefined;
349
+ }> | undefined;
350
+ }> | undefined;
351
+ $comment?: string | Record<string, unknown> | undefined;
352
+ $schema?: string | undefined;
353
+ }>, {
354
+ services: Record<string, {
355
+ provider?: string | {
356
+ provider: string;
357
+ credentialType: string;
358
+ configSchema?: string | undefined;
359
+ } | undefined;
360
+ credentialRef?: string | undefined;
361
+ instances?: Record<string, {
362
+ provider?: string | undefined;
363
+ credentialRef?: string | undefined;
364
+ config?: Record<string, unknown> | undefined;
365
+ implementation?: string | undefined;
366
+ enabled?: boolean | undefined;
367
+ }> | undefined;
368
+ config?: Record<string, unknown> | undefined;
369
+ implementation?: string | undefined;
370
+ }>;
371
+ provider?: string | undefined;
372
+ credentialRef?: string | undefined;
373
+ instances?: {
374
+ name: string;
375
+ id: string;
376
+ attributes?: Record<string, unknown> | undefined;
377
+ }[] | undefined;
378
+ defaultInstanceId?: string | null | undefined;
379
+ config?: Record<string, unknown> | undefined;
380
+ configByInstance?: Record<string, Record<string, unknown>> | undefined;
381
+ credentialRefByInstance?: Record<string, string> | undefined;
382
+ modules?: Record<string, {
383
+ provider?: string | undefined;
384
+ credentialRef?: string | undefined;
385
+ config?: Record<string, unknown> | undefined;
386
+ resources?: Record<string, {
387
+ type: "knowledge";
388
+ topK?: number | undefined;
389
+ datasetId?: string | undefined;
390
+ ref?: string | undefined;
391
+ scoreThreshold?: number | undefined;
392
+ }> | undefined;
393
+ }> | undefined;
394
+ $comment?: string | Record<string, unknown> | undefined;
395
+ $schema?: string | undefined;
396
+ }, {
397
+ services: Record<string, {
398
+ provider?: string | {
399
+ provider: string;
400
+ credentialType: string;
401
+ configSchema?: string | undefined;
402
+ } | undefined;
403
+ credentialRef?: string | undefined;
404
+ instances?: Record<string, {
405
+ provider?: string | undefined;
406
+ credentialRef?: string | undefined;
407
+ config?: Record<string, unknown> | undefined;
408
+ implementation?: string | undefined;
409
+ enabled?: boolean | undefined;
410
+ }> | undefined;
411
+ config?: Record<string, unknown> | undefined;
412
+ implementation?: string | undefined;
413
+ }>;
414
+ provider?: string | undefined;
415
+ credentialRef?: string | undefined;
416
+ instances?: {
417
+ name: string;
418
+ id: string;
419
+ attributes?: Record<string, unknown> | undefined;
420
+ }[] | undefined;
421
+ defaultInstanceId?: string | null | undefined;
422
+ config?: Record<string, unknown> | undefined;
423
+ configByInstance?: Record<string, Record<string, unknown>> | undefined;
424
+ credentialRefByInstance?: Record<string, string> | undefined;
425
+ modules?: Record<string, {
426
+ provider?: string | undefined;
427
+ credentialRef?: string | undefined;
428
+ config?: Record<string, unknown> | undefined;
429
+ resources?: Record<string, {
430
+ type: "knowledge";
431
+ topK?: number | undefined;
432
+ datasetId?: string | undefined;
433
+ ref?: string | undefined;
434
+ scoreThreshold?: number | undefined;
435
+ }> | undefined;
436
+ }> | undefined;
437
+ $comment?: string | Record<string, unknown> | undefined;
438
+ $schema?: string | undefined;
439
+ }>;
2
440
  /** 断言无内联密钥 → 旧键直切防线 → zod strict 校验(调用方负责占位展开先行) */
3
441
  export declare function parseIntegrationsConfig(raw: unknown): IntegrationsConfig;
@@ -167,6 +167,9 @@ export interface ModuleConfig {
167
167
  provider?: string;
168
168
  /** 模块级共享配置(config 五层级联第三层:root ByInstance 之后、slot 之前) */
169
169
  config?: Record<string, unknown>;
170
+ /** 模块级共享凭据引用(v6 归属链层:实例 > 槽 > modules[owner] > root——连接三件套
171
+ * (provider/config/credentialRef)共享营业主写位;该模块拥有的全部槽免逐槽重配) */
172
+ credentialRef?: string;
170
173
  /** resourceId → 类型化资源声明(resourceId 词汇真源 = 模块 manifest declare.resources) */
171
174
  resources?: Record<string, ResourceSpec>;
172
175
  }
package/dist/runtime.d.ts CHANGED
@@ -7,7 +7,7 @@ export { EventType } from '@ag-ui/core';
7
7
  export { TBOX_CARD_EVENT_NAME, TBOX_CARD_UPDATE_EVENT_NAME, TBOX_NOTICE_EVENT_NAME, } from './cards';
8
8
  export { AUTH_ERROR_CODES, authCodeToStatus } from './identity';
9
9
  export { stableSerializeScope, PROVIDER_ERROR_CODES, resolveEffectiveService, WILDCARD_INSTANCE_KEY, moduleDomainOf, buildSupplyLookup, normalizeInstances, isExpectedProviderAbsence, RESOURCE_TYPE_IDS, OWNERSHIP_BINDING_V6, } from './providers';
10
- export { parseIntegrationsConfig } from './integrations-config';
10
+ export { parseIntegrationsConfig, integrationsSchema } from './integrations-config';
11
11
  export { assertNoInlineSecrets } from './no-inline-secrets';
12
12
  export { defineContextSlot } from './context-slot';
13
13
  export * from './skill';
package/dist/runtime.js CHANGED
@@ -94,7 +94,7 @@ function unresolved(service, instanceId, detail) {
94
94
  }
95
95
  function hasModuleBindingNodes(integrations) {
96
96
  return Object.values(integrations.modules ?? {}).some(
97
- (m) => m.provider != null || m.config != null
97
+ (m) => m.provider != null || m.config != null || m.credentialRef != null
98
98
  );
99
99
  }
100
100
  function resolveEffectiveService(integrations, service, instanceId, supplies, ownerOf) {
@@ -157,7 +157,7 @@ function resolveEffectiveService(integrations, service, instanceId, supplies, ow
157
157
  ...slot.config,
158
158
  ...inst.config
159
159
  };
160
- const credentialRef = inst.credentialRef ?? slot.credentialRef ?? integrations.credentialRefByInstance?.[instanceId] ?? integrations.credentialRef;
160
+ const credentialRef = inst.credentialRef ?? slot.credentialRef ?? mod?.credentialRef ?? integrations.credentialRefByInstance?.[instanceId] ?? integrations.credentialRef;
161
161
  return {
162
162
  status: "ok",
163
163
  effective: {
@@ -200,6 +200,7 @@ function assertNoInlineSecrets(config, path = "$") {
200
200
  }
201
201
  if (config && typeof config === "object") {
202
202
  for (const [k, v] of Object.entries(config)) {
203
+ if (k === "$comment" && path === "$") continue;
203
204
  if (SECRET_KEY_PATTERN.test(k) && !SECRET_KEY_ALLOWLIST.has(k)) {
204
205
  throw new Error(`\u90E8\u7F72\u914D\u7F6E\u542B\u7591\u4F3C\u5185\u8054\u5BC6\u94A5\u5B57\u6BB5\uFF1A${path}.${k}\uFF08\u673A\u5BC6\u53EA\u5141\u8BB8\u7ECF credentialRef \u5F15\u7528\u73AF\u5883\u53D8\u91CF\uFF09`);
205
206
  }
@@ -252,11 +253,14 @@ var resourceSpecSchema = z.discriminatedUnion("type", [knowledgeSpecSchema]).ref
252
253
  var moduleConfigSchema = z.strictObject({
253
254
  provider: z.string().min(1).optional(),
254
255
  config: z.record(z.string(), z.unknown()).optional(),
256
+ credentialRef: z.string().optional(),
255
257
  resources: z.record(z.string(), resourceSpecSchema).optional()
256
- }).refine((m) => m.provider !== void 0 || m.config !== void 0 || m.resources !== void 0, {
257
- message: "modules \u8282\u70B9 provider/config/resources \u81F3\u5C11\u5176\u4E00\uFF08\u7A7A\u8282\u70B9\u65E0\u610F\u4E49\u2014\u2014\u5220\u9664\u8BE5\u952E\uFF09"
258
+ }).refine((m) => m.provider !== void 0 || m.config !== void 0 || m.credentialRef !== void 0 || m.resources !== void 0, {
259
+ message: "modules \u8282\u70B9 provider/config/credentialRef/resources \u81F3\u5C11\u5176\u4E00\uFF08\u7A7A\u8282\u70B9\u65E0\u610F\u4E49\u2014\u2014\u5220\u9664\u8BE5\u952E\uFF09"
258
260
  });
259
261
  var integrationsSchema = z.strictObject({
262
+ $comment: z.union([z.string(), z.record(z.string(), z.unknown())]).optional(),
263
+ $schema: z.string().optional(),
260
264
  provider: z.string().min(1).optional(),
261
265
  config: z.record(z.string(), z.unknown()).optional(),
262
266
  configByInstance: z.record(z.string(), z.record(z.string(), z.unknown())).optional(),
@@ -564,6 +568,7 @@ export {
564
568
  buildSkillToolCallPayload,
565
569
  buildSupplyLookup,
566
570
  defineContextSlot,
571
+ integrationsSchema,
567
572
  isExpectedProviderAbsence,
568
573
  moduleDomainOf,
569
574
  nextKeepaliveAction,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tbox.cn/app-contracts",
3
- "version": "0.13.2",
3
+ "version": "0.13.4",
4
4
  "type": "module",
5
5
  "description": "平台契约(TIER0,types-only 为主 + 协议常量运行时值):卡片协议 / SDK adapter / 平台 DTO。",
6
6
  "exports": {
@@ -24,6 +24,25 @@ function base(overrides: Record<string, unknown> = {}): Record<string, unknown>
24
24
  };
25
25
  }
26
26
 
27
+ describe('parseIntegrationsConfig:v6 modules 节 credentialRef(归属层共享连接三件套)', () => {
28
+ it('modules 节 credentialRef 接受(共享连接归属层——连接只配一次写位)', () => {
29
+ const raw = base({
30
+ modules: { 'module-parking': { provider: 'joycity', credentialRef: 'secret://parking-shared' } },
31
+ });
32
+ expect(() => parseIntegrationsConfig(raw)).not.toThrow();
33
+ });
34
+
35
+ it('modules 节仅 credentialRef 合法(provider 绑定可走槽/default 层派生——凭据先行形态)', () => {
36
+ const raw = base({ modules: { 'module-parking': { credentialRef: 'secret://parking-shared' } } });
37
+ expect(() => parseIntegrationsConfig(raw)).not.toThrow();
38
+ });
39
+
40
+ it('modules 空节点仍拒(credentialRef 在场 = 有意义——不触发空节点防线)', () => {
41
+ const raw = base({ modules: { 'module-parking': {} } });
42
+ expect(() => parseIntegrationsConfig(raw)).toThrow(/至少其一/);
43
+ });
44
+ });
45
+
27
46
  describe('parseIntegrationsConfig:v3 回归锁', () => {
28
47
  it('合法基线通过', () => {
29
48
  expect(() => parseIntegrationsConfig(base())).not.toThrow();
@@ -283,3 +302,28 @@ describe('assertNoInlineSecrets(011 L2 迁移;自 component-config.test.ts
283
302
  expect(() => assertNoInlineSecrets({ a: [{ b: { password: 'x' } }] })).toThrow(/\.a\[0\]\.b\.password/);
284
303
  });
285
304
  });
305
+
306
+
307
+ describe('元键($comment / $schema)', () => {
308
+ it('字符串形态 $comment 通过', () => {
309
+ expect(() => parseIntegrationsConfig(base({ $comment: '形状: npx --yes @tbox.cn/app-cli schema config/integrations.json' }))).not.toThrow();
310
+ });
311
+
312
+ it('record 形态 $comment 通过(分文件指针)', () => {
313
+ expect(() => parseIntegrationsConfig(base({ $comment: { services: '槽位绑定' } }))).not.toThrow();
314
+ });
315
+
316
+ it('record 形态 $comment 的内部键不参与机密形态检查(行为惰性)', () => {
317
+ expect(() => parseIntegrationsConfig(base({ $comment: { token: '文档章节名', secret: '说明' } }))).not.toThrow();
318
+ });
319
+
320
+ it('嵌套 $comment(节点级——非容忍面)照常参与机密形态检查', () => {
321
+ expect(() => assertNoInlineSecrets({ config: { $comment: { password: 'x' } } })).toThrow(/config\.\$comment\.password/);
322
+ expect(() => assertNoInlineSecrets({ services: { 'mall.info': { $comment: { apiKey: 'x' } } } })).toThrow(/\$comment\.apiKey/);
323
+ });
324
+
325
+ it('$schema 字符串通过;拼错真键仍拒', () => {
326
+ expect(() => parseIntegrationsConfig(base({ $schema: 'https://example.com/schema.json' }))).not.toThrow();
327
+ expect(() => parseIntegrationsConfig(base({ $coment: 'typo' }))).toThrow();
328
+ });
329
+ });