@itphx/synth-shared 0.11.3 → 0.12.3

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 (92) hide show
  1. package/dist/config/defaults.js +126 -3
  2. package/dist/config/env-overrides.d.ts +29 -0
  3. package/dist/config/env-overrides.js +155 -2
  4. package/dist/config/execution.d.ts +66 -0
  5. package/dist/config/execution.js +146 -0
  6. package/dist/config/index.d.ts +1 -0
  7. package/dist/config/index.js +1 -0
  8. package/dist/config/proxy.js +3 -1
  9. package/dist/config/resolve.d.ts +8 -8
  10. package/dist/config/resolve.js +7 -7
  11. package/dist/config/types.d.ts +1287 -4037
  12. package/dist/config/types.js +461 -68
  13. package/dist/i18n/index.d.ts +1 -1
  14. package/dist/i18n/index.js +277 -0
  15. package/dist/index.d.ts +14 -2
  16. package/dist/index.js +16 -2
  17. package/dist/model-metadata.d.ts +10 -0
  18. package/dist/schemas/index.d.ts +980 -2322
  19. package/dist/schemas/index.js +183 -22
  20. package/dist/types/analytics.d.ts +6 -6
  21. package/dist/types/analytics.js +4 -4
  22. package/dist/types/authority.d.ts +464 -0
  23. package/dist/types/authority.js +445 -0
  24. package/dist/types/background.d.ts +96 -0
  25. package/dist/types/background.js +24 -0
  26. package/dist/types/bus-events.d.ts +23 -1
  27. package/dist/types/catalog.d.ts +349 -0
  28. package/dist/types/catalog.js +393 -0
  29. package/dist/types/decision.d.ts +28 -337
  30. package/dist/types/egress.d.ts +1 -1
  31. package/dist/types/egress.js +1 -1
  32. package/dist/types/events.d.ts +54 -1
  33. package/dist/types/external-credentials.d.ts +352 -0
  34. package/dist/types/external-credentials.js +200 -0
  35. package/dist/types/hooks.d.ts +33 -12
  36. package/dist/types/index.d.ts +20 -0
  37. package/dist/types/index.js +50 -1
  38. package/dist/types/llm-filters.d.ts +150 -0
  39. package/dist/types/llm-filters.js +54 -0
  40. package/dist/types/mcp.d.ts +33 -2
  41. package/dist/types/mcp.js +44 -1
  42. package/dist/types/message.d.ts +45 -1
  43. package/dist/types/pack.d.ts +1102 -0
  44. package/dist/types/pack.js +1003 -0
  45. package/dist/types/permission.d.ts +25 -11
  46. package/dist/types/permission.js +1 -1
  47. package/dist/types/pipeline-engine.d.ts +453 -0
  48. package/dist/types/pipeline-engine.js +440 -0
  49. package/dist/types/pipeline.d.ts +275 -0
  50. package/dist/types/pipeline.js +212 -0
  51. package/dist/types/plugin-audit.d.ts +110 -0
  52. package/dist/types/plugin-audit.js +185 -0
  53. package/dist/types/plugin-hybrid.d.ts +85 -0
  54. package/dist/types/plugin-hybrid.js +68 -0
  55. package/dist/types/plugin-lock.d.ts +95 -0
  56. package/dist/types/plugin-lock.js +1 -0
  57. package/dist/types/plugin-protocol.d.ts +221 -0
  58. package/dist/types/plugin-protocol.js +322 -0
  59. package/dist/types/plugin-runtime.d.ts +25 -0
  60. package/dist/types/plugin-runtime.js +11 -0
  61. package/dist/types/plugin-scan.d.ts +159 -0
  62. package/dist/types/plugin-scan.js +166 -0
  63. package/dist/types/plugin-tools.d.ts +51 -0
  64. package/dist/types/plugin-tools.js +72 -0
  65. package/dist/types/project.d.ts +14 -0
  66. package/dist/types/prompt-blocks.d.ts +102 -0
  67. package/dist/types/prompt-blocks.js +24 -0
  68. package/dist/types/prompt.d.ts +45 -3
  69. package/dist/types/provider.d.ts +11 -0
  70. package/dist/types/question.d.ts +153 -0
  71. package/dist/types/question.js +65 -0
  72. package/dist/types/schedules.d.ts +26 -3
  73. package/dist/types/semver.d.ts +48 -0
  74. package/dist/types/semver.js +218 -0
  75. package/dist/types/service-keys.d.ts +41 -3
  76. package/dist/types/service-keys.js +44 -2
  77. package/dist/types/session.d.ts +54 -0
  78. package/dist/types/steering.d.ts +74 -0
  79. package/dist/types/steering.js +75 -0
  80. package/dist/types/tools.d.ts +125 -5
  81. package/dist/types/tools.js +75 -0
  82. package/dist/types/trust.d.ts +31 -0
  83. package/dist/types/trust.js +27 -0
  84. package/dist/types/worktree.d.ts +170 -0
  85. package/dist/types/worktree.js +101 -0
  86. package/dist/utils/index.d.ts +31 -1
  87. package/dist/utils/index.js +92 -12
  88. package/dist/utils/reasoning.d.ts +16 -0
  89. package/dist/utils/reasoning.js +37 -0
  90. package/dist/version.d.ts +1 -1
  91. package/dist/version.js +1 -1
  92. package/package.json +2 -2
@@ -97,406 +97,97 @@ export interface DecisionResponse {
97
97
  * проверяются отдельно — иначе `discriminatedUnion` не принимает
98
98
  * `ZodEffects`-обёртки внутри вариантов.
99
99
  */
100
- export declare const decisionQuestionSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
100
+ export declare const decisionQuestionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
101
101
  type: z.ZodLiteral<"noul">;
102
102
  instructions: z.ZodOptional<z.ZodString>;
103
103
  criteria: z.ZodOptional<z.ZodObject<{
104
104
  true: z.ZodOptional<z.ZodString>;
105
105
  false: z.ZodOptional<z.ZodString>;
106
- }, "strip", z.ZodTypeAny, {
107
- true?: string | undefined;
108
- false?: string | undefined;
109
- }, {
110
- true?: string | undefined;
111
- false?: string | undefined;
112
- }>>;
113
- }, "strip", z.ZodTypeAny, {
114
- type: "noul";
115
- instructions?: string | undefined;
116
- criteria?: {
117
- true?: string | undefined;
118
- false?: string | undefined;
119
- } | undefined;
120
- }, {
121
- type: "noul";
122
- instructions?: string | undefined;
123
- criteria?: {
124
- true?: string | undefined;
125
- false?: string | undefined;
126
- } | undefined;
127
- }>, z.ZodObject<{
106
+ }, z.core.$strip>>;
107
+ }, z.core.$strip>, z.ZodObject<{
128
108
  type: z.ZodLiteral<"choice">;
129
109
  instructions: z.ZodString;
130
110
  criteria: z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>;
131
- }, "strip", z.ZodTypeAny, {
132
- type: "choice";
133
- instructions: string;
134
- criteria: Record<string, string | null>;
135
- }, {
136
- type: "choice";
137
- instructions: string;
138
- criteria: Record<string, string | null>;
139
- }>, z.ZodObject<{
111
+ }, z.core.$strip>, z.ZodObject<{
140
112
  type: z.ZodLiteral<"score">;
141
113
  instructions: z.ZodString;
142
- criteria: z.ZodArray<z.ZodString, "many">;
143
- }, "strip", z.ZodTypeAny, {
144
- type: "score";
145
- instructions: string;
146
- criteria: string[];
147
- }, {
148
- type: "score";
149
- instructions: string;
150
- criteria: string[];
151
- }>]>, {
152
- type: "noul";
153
- instructions?: string | undefined;
154
- criteria?: {
155
- true?: string | undefined;
156
- false?: string | undefined;
157
- } | undefined;
158
- } | {
159
- type: "choice";
160
- instructions: string;
161
- criteria: Record<string, string | null>;
162
- } | {
163
- type: "score";
164
- instructions: string;
165
- criteria: string[];
166
- }, {
167
- type: "noul";
168
- instructions?: string | undefined;
169
- criteria?: {
170
- true?: string | undefined;
171
- false?: string | undefined;
172
- } | undefined;
173
- } | {
174
- type: "choice";
175
- instructions: string;
176
- criteria: Record<string, string | null>;
177
- } | {
178
- type: "score";
179
- instructions: string;
180
- criteria: string[];
181
- }>;
114
+ criteria: z.ZodArray<z.ZodString>;
115
+ }, z.core.$strip>], "type">;
182
116
  export declare const decisionNoulAnswerSchema: z.ZodObject<{
183
117
  type: z.ZodLiteral<"noul">;
184
118
  noul: z.ZodNumber;
185
- }, "strip", z.ZodTypeAny, {
186
- type: "noul";
187
- noul: number;
188
- }, {
189
- type: "noul";
190
- noul: number;
191
- }>;
119
+ }, z.core.$strip>;
192
120
  export declare const decisionChoiceAnswerSchema: z.ZodObject<{
193
121
  type: z.ZodLiteral<"choice">;
194
122
  choice: z.ZodString;
195
123
  confidence: z.ZodNumber;
196
124
  probabilities: z.ZodRecord<z.ZodString, z.ZodNumber>;
197
- }, "strip", z.ZodTypeAny, {
198
- type: "choice";
199
- choice: string;
200
- confidence: number;
201
- probabilities: Record<string, number>;
202
- }, {
203
- type: "choice";
204
- choice: string;
205
- confidence: number;
206
- probabilities: Record<string, number>;
207
- }>;
125
+ }, z.core.$strip>;
208
126
  export declare const decisionScoreAnswerSchema: z.ZodObject<{
209
127
  type: z.ZodLiteral<"score">;
210
128
  score: z.ZodNumber;
211
129
  confidence: z.ZodNumber;
212
130
  probabilities: z.ZodRecord<z.ZodString, z.ZodNumber>;
213
131
  legend: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
214
- }, "strip", z.ZodTypeAny, {
215
- type: "score";
216
- score: number;
217
- confidence: number;
218
- probabilities: Record<string, number>;
219
- legend?: Record<string, string> | undefined;
220
- }, {
221
- type: "score";
222
- score: number;
223
- confidence: number;
224
- probabilities: Record<string, number>;
225
- legend?: Record<string, string> | undefined;
226
- }>;
132
+ }, z.core.$strip>;
227
133
  /** ADR-084: схема ответа decision-модели. */
228
- export declare const decisionAnswerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
134
+ export declare const decisionAnswerSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
229
135
  type: z.ZodLiteral<"noul">;
230
136
  noul: z.ZodNumber;
231
- }, "strip", z.ZodTypeAny, {
232
- type: "noul";
233
- noul: number;
234
- }, {
235
- type: "noul";
236
- noul: number;
237
- }>, z.ZodObject<{
137
+ }, z.core.$strip>, z.ZodObject<{
238
138
  type: z.ZodLiteral<"choice">;
239
139
  choice: z.ZodString;
240
140
  confidence: z.ZodNumber;
241
141
  probabilities: z.ZodRecord<z.ZodString, z.ZodNumber>;
242
- }, "strip", z.ZodTypeAny, {
243
- type: "choice";
244
- choice: string;
245
- confidence: number;
246
- probabilities: Record<string, number>;
247
- }, {
248
- type: "choice";
249
- choice: string;
250
- confidence: number;
251
- probabilities: Record<string, number>;
252
- }>, z.ZodObject<{
142
+ }, z.core.$strip>, z.ZodObject<{
253
143
  type: z.ZodLiteral<"score">;
254
144
  score: z.ZodNumber;
255
145
  confidence: z.ZodNumber;
256
146
  probabilities: z.ZodRecord<z.ZodString, z.ZodNumber>;
257
147
  legend: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
258
- }, "strip", z.ZodTypeAny, {
259
- type: "score";
260
- score: number;
261
- confidence: number;
262
- probabilities: Record<string, number>;
263
- legend?: Record<string, string> | undefined;
264
- }, {
265
- type: "score";
266
- score: number;
267
- confidence: number;
268
- probabilities: Record<string, number>;
269
- legend?: Record<string, string> | undefined;
270
- }>]>;
148
+ }, z.core.$strip>], "type">;
271
149
  export declare const decisionRequestSchema: z.ZodObject<{
272
150
  model: z.ZodString;
273
151
  state: z.ZodUnknown;
274
- questions: z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
152
+ questions: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
275
153
  type: z.ZodLiteral<"noul">;
276
154
  instructions: z.ZodOptional<z.ZodString>;
277
155
  criteria: z.ZodOptional<z.ZodObject<{
278
156
  true: z.ZodOptional<z.ZodString>;
279
157
  false: z.ZodOptional<z.ZodString>;
280
- }, "strip", z.ZodTypeAny, {
281
- true?: string | undefined;
282
- false?: string | undefined;
283
- }, {
284
- true?: string | undefined;
285
- false?: string | undefined;
286
- }>>;
287
- }, "strip", z.ZodTypeAny, {
288
- type: "noul";
289
- instructions?: string | undefined;
290
- criteria?: {
291
- true?: string | undefined;
292
- false?: string | undefined;
293
- } | undefined;
294
- }, {
295
- type: "noul";
296
- instructions?: string | undefined;
297
- criteria?: {
298
- true?: string | undefined;
299
- false?: string | undefined;
300
- } | undefined;
301
- }>, z.ZodObject<{
158
+ }, z.core.$strip>>;
159
+ }, z.core.$strip>, z.ZodObject<{
302
160
  type: z.ZodLiteral<"choice">;
303
161
  instructions: z.ZodString;
304
162
  criteria: z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>;
305
- }, "strip", z.ZodTypeAny, {
306
- type: "choice";
307
- instructions: string;
308
- criteria: Record<string, string | null>;
309
- }, {
310
- type: "choice";
311
- instructions: string;
312
- criteria: Record<string, string | null>;
313
- }>, z.ZodObject<{
163
+ }, z.core.$strip>, z.ZodObject<{
314
164
  type: z.ZodLiteral<"score">;
315
165
  instructions: z.ZodString;
316
- criteria: z.ZodArray<z.ZodString, "many">;
317
- }, "strip", z.ZodTypeAny, {
318
- type: "score";
319
- instructions: string;
320
- criteria: string[];
321
- }, {
322
- type: "score";
323
- instructions: string;
324
- criteria: string[];
325
- }>]>, {
326
- type: "noul";
327
- instructions?: string | undefined;
328
- criteria?: {
329
- true?: string | undefined;
330
- false?: string | undefined;
331
- } | undefined;
332
- } | {
333
- type: "choice";
334
- instructions: string;
335
- criteria: Record<string, string | null>;
336
- } | {
337
- type: "score";
338
- instructions: string;
339
- criteria: string[];
340
- }, {
341
- type: "noul";
342
- instructions?: string | undefined;
343
- criteria?: {
344
- true?: string | undefined;
345
- false?: string | undefined;
346
- } | undefined;
347
- } | {
348
- type: "choice";
349
- instructions: string;
350
- criteria: Record<string, string | null>;
351
- } | {
352
- type: "score";
353
- instructions: string;
354
- criteria: string[];
355
- }>>;
356
- /** ADR-084/PROP-085: медиа-вложения (изображения/видео) — опциональны. */
357
- images: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
358
- videos: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
359
- }, "strip", z.ZodTypeAny, {
360
- model: string;
361
- questions: Record<string, {
362
- type: "noul";
363
- instructions?: string | undefined;
364
- criteria?: {
365
- true?: string | undefined;
366
- false?: string | undefined;
367
- } | undefined;
368
- } | {
369
- type: "choice";
370
- instructions: string;
371
- criteria: Record<string, string | null>;
372
- } | {
373
- type: "score";
374
- instructions: string;
375
- criteria: string[];
376
- }>;
377
- state?: unknown;
378
- images?: string[] | undefined;
379
- videos?: string[] | undefined;
380
- }, {
381
- model: string;
382
- questions: Record<string, {
383
- type: "noul";
384
- instructions?: string | undefined;
385
- criteria?: {
386
- true?: string | undefined;
387
- false?: string | undefined;
388
- } | undefined;
389
- } | {
390
- type: "choice";
391
- instructions: string;
392
- criteria: Record<string, string | null>;
393
- } | {
394
- type: "score";
395
- instructions: string;
396
- criteria: string[];
397
- }>;
398
- state?: unknown;
399
- images?: string[] | undefined;
400
- videos?: string[] | undefined;
401
- }>;
166
+ criteria: z.ZodArray<z.ZodString>;
167
+ }, z.core.$strip>], "type">>;
168
+ images: z.ZodOptional<z.ZodArray<z.ZodString>>;
169
+ videos: z.ZodOptional<z.ZodArray<z.ZodString>>;
170
+ }, z.core.$strip>;
402
171
  export declare const decisionResponseSchema: z.ZodObject<{
403
172
  id: z.ZodOptional<z.ZodString>;
404
173
  model: z.ZodOptional<z.ZodString>;
405
- answers: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
174
+ answers: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
406
175
  type: z.ZodLiteral<"noul">;
407
176
  noul: z.ZodNumber;
408
- }, "strip", z.ZodTypeAny, {
409
- type: "noul";
410
- noul: number;
411
- }, {
412
- type: "noul";
413
- noul: number;
414
- }>, z.ZodObject<{
177
+ }, z.core.$strip>, z.ZodObject<{
415
178
  type: z.ZodLiteral<"choice">;
416
179
  choice: z.ZodString;
417
180
  confidence: z.ZodNumber;
418
181
  probabilities: z.ZodRecord<z.ZodString, z.ZodNumber>;
419
- }, "strip", z.ZodTypeAny, {
420
- type: "choice";
421
- choice: string;
422
- confidence: number;
423
- probabilities: Record<string, number>;
424
- }, {
425
- type: "choice";
426
- choice: string;
427
- confidence: number;
428
- probabilities: Record<string, number>;
429
- }>, z.ZodObject<{
182
+ }, z.core.$strip>, z.ZodObject<{
430
183
  type: z.ZodLiteral<"score">;
431
184
  score: z.ZodNumber;
432
185
  confidence: z.ZodNumber;
433
186
  probabilities: z.ZodRecord<z.ZodString, z.ZodNumber>;
434
187
  legend: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
435
- }, "strip", z.ZodTypeAny, {
436
- type: "score";
437
- score: number;
438
- confidence: number;
439
- probabilities: Record<string, number>;
440
- legend?: Record<string, string> | undefined;
441
- }, {
442
- type: "score";
443
- score: number;
444
- confidence: number;
445
- probabilities: Record<string, number>;
446
- legend?: Record<string, string> | undefined;
447
- }>]>>;
188
+ }, z.core.$strip>], "type">>;
448
189
  usage: z.ZodOptional<z.ZodObject<{
449
190
  input_tokens: z.ZodNumber;
450
191
  output_tokens: z.ZodNumber;
451
- }, "strip", z.ZodTypeAny, {
452
- input_tokens: number;
453
- output_tokens: number;
454
- }, {
455
- input_tokens: number;
456
- output_tokens: number;
457
- }>>;
458
- }, "strip", z.ZodTypeAny, {
459
- answers: Record<string, {
460
- type: "noul";
461
- noul: number;
462
- } | {
463
- type: "choice";
464
- choice: string;
465
- confidence: number;
466
- probabilities: Record<string, number>;
467
- } | {
468
- type: "score";
469
- score: number;
470
- confidence: number;
471
- probabilities: Record<string, number>;
472
- legend?: Record<string, string> | undefined;
473
- }>;
474
- model?: string | undefined;
475
- id?: string | undefined;
476
- usage?: {
477
- input_tokens: number;
478
- output_tokens: number;
479
- } | undefined;
480
- }, {
481
- answers: Record<string, {
482
- type: "noul";
483
- noul: number;
484
- } | {
485
- type: "choice";
486
- choice: string;
487
- confidence: number;
488
- probabilities: Record<string, number>;
489
- } | {
490
- type: "score";
491
- score: number;
492
- confidence: number;
493
- probabilities: Record<string, number>;
494
- legend?: Record<string, string> | undefined;
495
- }>;
496
- model?: string | undefined;
497
- id?: string | undefined;
498
- usage?: {
499
- input_tokens: number;
500
- output_tokens: number;
501
- } | undefined;
502
- }>;
192
+ }, z.core.$strip>>;
193
+ }, z.core.$strip>;
@@ -93,7 +93,7 @@ export interface EgressRequestLogEntry {
93
93
  actor?: string;
94
94
  }
95
95
  /** Скоупы изменений egress-политик/прокси в security-аудите. */
96
- export declare const SECURITY_AUDIT_SCOPES: readonly ["tools", "webhooks", "mcp", "proxy", "tls"];
96
+ export declare const SECURITY_AUDIT_SCOPES: readonly ["tools", "webhooks", "mcp", "proxy", "tls", "attachments"];
97
97
  export type SecurityAuditScope = (typeof SECURITY_AUDIT_SCOPES)[number];
98
98
  export declare const SECURITY_AUDIT_ACTIONS: readonly ["update", "reset"];
99
99
  export type SecurityAuditAction = (typeof SECURITY_AUDIT_ACTIONS)[number];
@@ -64,5 +64,5 @@ export const EGRESS_REQUEST_STATUSES = ['allowed', 'blocked', 'error'];
64
64
  */
65
65
  export const EGRESS_REQUEST_VIAS = ['proxy', 'direct', 'fallback'];
66
66
  /** Скоупы изменений egress-политик/прокси в security-аудите. */
67
- export const SECURITY_AUDIT_SCOPES = ['tools', 'webhooks', 'mcp', 'proxy', 'tls'];
67
+ export const SECURITY_AUDIT_SCOPES = ['tools', 'webhooks', 'mcp', 'proxy', 'tls', 'attachments'];
68
68
  export const SECURITY_AUDIT_ACTIONS = ['update', 'reset'];
@@ -24,6 +24,27 @@ export interface EventIdentity {
24
24
  /** Роли для маппинга на RBAC. */
25
25
  roles?: string[];
26
26
  }
27
+ /**
28
+ * ADR-115 × ADR-089: ссылка на вложение внешнего события.
29
+ *
30
+ * Шлюз (Telegram/VK/…) сначала загружает байты в staging (`POST /api/v2/attachments`)
31
+ * и передаёт в событии **ссылку** на объект blob-хранилища — сами байты через
32
+ * событие не идут. Метаданные дублируются в событии, чтобы адресат мог проверить
33
+ * их совпадение со sidecar объекта (подмена ссылки на чужой/изменённый объект
34
+ * отклоняется на приёме).
35
+ */
36
+ export interface EventAttachmentRef {
37
+ /** Путь объекта в blob-хранилище (`attachments/<sha2>/<sha256>`). */
38
+ blobPath: string;
39
+ /** SHA-256 содержимого (content-addressed). */
40
+ sha256: string;
41
+ /** MIME-тип по содержимому. */
42
+ mime: string;
43
+ /** Размер в байтах. */
44
+ size: number;
45
+ /** Имя файла (санитайз; в `blobPath` не входит). */
46
+ name?: string;
47
+ }
27
48
  /** ADR-089: нормализованное внешнее событие (источник-специфика — в `payload`). */
28
49
  export interface SynthEvent {
29
50
  /** `'evt_<uuid>'`, уникален в пределах инстанса. */
@@ -38,6 +59,13 @@ export interface SynthEvent {
38
59
  dedupKey: string;
39
60
  /** Время события, ISO-8601. */
40
61
  ts: string;
62
+ /**
63
+ * ADR-115 × ADR-089: вложения события — ссылки на объекты blob-хранилища.
64
+ * Аддитивное поле: события без вложений его не несут. Если поле непусто,
65
+ * `dedupKey` обязан быть задан явно (иначе ключ идемпотентности менялся бы
66
+ * от содержимого вложений).
67
+ */
68
+ attachments?: EventAttachmentRef[];
41
69
  }
42
70
  /** ADR-089: устойчивая привязка внешнего адреса к сессии/шаблону. */
43
71
  export interface EventBinding {
@@ -93,6 +121,19 @@ export interface EventBindingApiKeyCreated extends EventBindingApiKey {
93
121
  /** Plaintext-секрет; возвращается единственный раз при создании. */
94
122
  key: string;
95
123
  }
124
+ /**
125
+ * ADR-089: ссылка на шаг пайплайна — «эта сессия — шаг `step` пайплайна `id`».
126
+ *
127
+ * Ссылка живёт в цели правила маршрутизации (`ephemeral`/`bind`) и прокидывается
128
+ * в решение Router'а: на ней строится учёт экземпляров пайплайна и гейты
129
+ * (напр. правило по событию `draft_approved` — это гейт «после approve»).
130
+ */
131
+ export interface PipelineRef {
132
+ /** id пайплайна (определения/экземпляра). */
133
+ id: string;
134
+ /** id шага внутри пайплайна. */
135
+ step: string;
136
+ }
96
137
  /**
97
138
  * ADR-089: цель правила маршрутизации (та же семантика, что у
98
139
  * `EventBinding`/`ScheduleTarget`).
@@ -105,6 +146,7 @@ export type EventRouteTarget = {
105
146
  agentTemplate?: string;
106
147
  project?: string;
107
148
  ttl?: string;
149
+ pipeline?: PipelineRef;
108
150
  } | {
109
151
  mode: 'queue';
110
152
  sessionId: string;
@@ -118,6 +160,7 @@ export type EventRouteTarget = {
118
160
  mode: 'bind';
119
161
  agentTemplate?: string;
120
162
  project?: string;
163
+ pipeline?: PipelineRef;
121
164
  };
122
165
  /** ADR-089: условие срабатывания правила (AND по заполненным полям). */
123
166
  export interface EventRouteMatch {
@@ -165,6 +208,7 @@ type RouteDecisionKind = {
165
208
  agentTemplate: string;
166
209
  ttl: string;
167
210
  project?: string;
211
+ pipeline?: PipelineRef;
168
212
  } | {
169
213
  kind: 'queue';
170
214
  owner: string;
@@ -185,8 +229,17 @@ type RouteDecisionKind = {
185
229
  kind: 'bind';
186
230
  agentTemplate: string;
187
231
  project?: string;
232
+ pipeline?: PipelineRef;
188
233
  };
189
- /** ADR-089: решение Router — куда направить событие (или отложить/отбросить). */
234
+ /**
235
+ * ADR-089: решение Router — куда направить событие (или отложить/отбросить).
236
+ *
237
+ * `pipeline` (ссылка на шаг пайплайна) — **семантическое** поле решения, а не
238
+ * диагностическая мета: оно задано только у вариантов `ephemeral`/`bind`
239
+ * (там, где решение порождает сессию) и потому живёт в вариантах
240
+ * `RouteDecisionKind`, а не в `RouteDecisionMeta` (мета — диагностика:
241
+ * `confidence`/`signals`).
242
+ */
190
243
  export type RouteDecision = RouteDecisionKind & RouteDecisionMeta;
191
244
  /** ADR-089: инициатор запроса на сессию. */
192
245
  export type EventInitiator = 'user' | 'agent' | 'external' | 'system';