@itphx/synth-shared 0.10.1 → 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 (104) hide show
  1. package/dist/config/defaults.js +172 -3
  2. package/dist/config/env-overrides.d.ts +33 -1
  3. package/dist/config/env-overrides.js +191 -5
  4. package/dist/config/execution.d.ts +66 -0
  5. package/dist/config/execution.js +146 -0
  6. package/dist/config/index.d.ts +4 -0
  7. package/dist/config/index.js +4 -0
  8. package/dist/config/loader.js +19 -0
  9. package/dist/config/proxy.d.ts +415 -0
  10. package/dist/config/proxy.js +1567 -0
  11. package/dist/config/resolve.d.ts +67 -0
  12. package/dist/config/resolve.js +187 -1
  13. package/dist/config/tls-runtime.d.ts +78 -0
  14. package/dist/config/tls-runtime.js +356 -0
  15. package/dist/config/tls.d.ts +215 -0
  16. package/dist/config/tls.js +394 -0
  17. package/dist/config/types.d.ts +1571 -2835
  18. package/dist/config/types.js +717 -58
  19. package/dist/i18n/index.d.ts +1 -1
  20. package/dist/i18n/index.js +279 -0
  21. package/dist/index.d.ts +24 -3
  22. package/dist/index.js +25 -2
  23. package/dist/model-metadata.d.ts +10 -0
  24. package/dist/protocols/index.d.ts +0 -1
  25. package/dist/schemas/index.d.ts +1014 -2231
  26. package/dist/schemas/index.js +222 -14
  27. package/dist/types/analytics.d.ts +113 -0
  28. package/dist/types/analytics.js +61 -0
  29. package/dist/types/authority.d.ts +464 -0
  30. package/dist/types/authority.js +445 -0
  31. package/dist/types/background.d.ts +96 -0
  32. package/dist/types/background.js +24 -0
  33. package/dist/types/bus-events.d.ts +23 -1
  34. package/dist/types/catalog.d.ts +349 -0
  35. package/dist/types/catalog.js +393 -0
  36. package/dist/types/decision.d.ts +28 -337
  37. package/dist/types/egress.d.ts +114 -0
  38. package/dist/types/egress.js +68 -0
  39. package/dist/types/events.d.ts +54 -2
  40. package/dist/types/external-credentials.d.ts +352 -0
  41. package/dist/types/external-credentials.js +200 -0
  42. package/dist/types/fs.d.ts +11 -0
  43. package/dist/types/fs.js +11 -0
  44. package/dist/types/hooks.d.ts +50 -9
  45. package/dist/types/index.d.ts +23 -0
  46. package/dist/types/index.js +55 -0
  47. package/dist/types/llm-filters.d.ts +150 -0
  48. package/dist/types/llm-filters.js +54 -0
  49. package/dist/types/maintenance.d.ts +39 -0
  50. package/dist/types/maintenance.js +11 -0
  51. package/dist/types/mcp.d.ts +101 -5
  52. package/dist/types/mcp.js +127 -5
  53. package/dist/types/message.d.ts +45 -1
  54. package/dist/types/pack.d.ts +1102 -0
  55. package/dist/types/pack.js +1003 -0
  56. package/dist/types/permission.d.ts +31 -15
  57. package/dist/types/permission.js +1 -1
  58. package/dist/types/pipeline-engine.d.ts +453 -0
  59. package/dist/types/pipeline-engine.js +440 -0
  60. package/dist/types/pipeline.d.ts +275 -0
  61. package/dist/types/pipeline.js +212 -0
  62. package/dist/types/plugin-audit.d.ts +110 -0
  63. package/dist/types/plugin-audit.js +185 -0
  64. package/dist/types/plugin-hybrid.d.ts +85 -0
  65. package/dist/types/plugin-hybrid.js +68 -0
  66. package/dist/types/plugin-lock.d.ts +95 -0
  67. package/dist/types/plugin-lock.js +1 -0
  68. package/dist/types/plugin-protocol.d.ts +221 -0
  69. package/dist/types/plugin-protocol.js +322 -0
  70. package/dist/types/plugin-runtime.d.ts +25 -0
  71. package/dist/types/plugin-runtime.js +11 -0
  72. package/dist/types/plugin-scan.d.ts +159 -0
  73. package/dist/types/plugin-scan.js +166 -0
  74. package/dist/types/plugin-tools.d.ts +51 -0
  75. package/dist/types/plugin-tools.js +72 -0
  76. package/dist/types/project.d.ts +14 -0
  77. package/dist/types/prompt-blocks.d.ts +102 -0
  78. package/dist/types/prompt-blocks.js +24 -0
  79. package/dist/types/prompt.d.ts +47 -4
  80. package/dist/types/provider.d.ts +11 -0
  81. package/dist/types/question.d.ts +153 -0
  82. package/dist/types/question.js +65 -0
  83. package/dist/types/schedules.d.ts +26 -3
  84. package/dist/types/semver.d.ts +48 -0
  85. package/dist/types/semver.js +218 -0
  86. package/dist/types/service-keys.d.ts +41 -3
  87. package/dist/types/service-keys.js +44 -2
  88. package/dist/types/session.d.ts +54 -1
  89. package/dist/types/steering.d.ts +74 -0
  90. package/dist/types/steering.js +75 -0
  91. package/dist/types/tools.d.ts +125 -5
  92. package/dist/types/tools.js +75 -0
  93. package/dist/types/trust.d.ts +31 -0
  94. package/dist/types/trust.js +27 -0
  95. package/dist/types/webhooks.d.ts +1 -1
  96. package/dist/types/worktree.d.ts +170 -0
  97. package/dist/types/worktree.js +101 -0
  98. package/dist/utils/index.d.ts +46 -1
  99. package/dist/utils/index.js +145 -12
  100. package/dist/utils/reasoning.d.ts +16 -0
  101. package/dist/utils/reasoning.js +37 -0
  102. package/dist/version.d.ts +1 -1
  103. package/dist/version.js +1 -1
  104. 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>;
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Egress-политика исходящих запросов (web/инструкции/скиллы/webhooks/providers/MCP).
3
+ *
4
+ * Единый формат политики (`mode` + `list` + `exceptions`) используется всеми
5
+ * потребителями; `webhooks` дополнительно поддерживает `mode: 'off'` (dev, без
6
+ * проверок и без требования https). Семантика:
7
+ * - `exceptions` — allow-правила, проверяются **первыми** (точный hostname,
8
+ * `*.suffix`, CIDR/IP); hostname-правило разрешает сразу, CIDR — по резолву;
9
+ * - `deny` + `list` — блок, если хотя бы один resolved-адрес в `list`;
10
+ * - `allow` + `list` — разрешено, если ВСЕ resolved-адреса в `list` (или exception);
11
+ * - `off` (только webhooks) — проверок нет, `requireHttps = false`.
12
+ *
13
+ * Литеральные `localhost`/`*.localhost`/`*.local`/`*.internal` и приватные IP
14
+ * блокируются самой политикой (дефолтный `list`), а не отдельным зашитым списком;
15
+ * exception может их разрешить.
16
+ *
17
+ * Дефолтный `list` — **общий канонический список** `DEFAULT_MCP_PRIVATE_CIDRS`
18
+ * (`types/mcp.ts`): он же — дефолт `mcp.networkPolicy` и встроенный fallback
19
+ * `engine/net/egress-guard.ts`. Списков «заблокированных адресов» в коде больше
20
+ * нет, поэтому расширять блокировки нужно только этот список.
21
+ */
22
+ export declare const EGRESS_POLICY_MODES: readonly ["deny", "allow"];
23
+ export type EgressPolicyMode = (typeof EGRESS_POLICY_MODES)[number];
24
+ export declare const WEBHOOKS_EGRESS_POLICY_MODES: readonly ["deny", "allow", "off"];
25
+ export type WebhooksEgressPolicyMode = (typeof WEBHOOKS_EGRESS_POLICY_MODES)[number];
26
+ /** Скоупы настраиваемой egress-политики (settings/egress). */
27
+ export declare const EGRESS_POLICY_SCOPES: readonly ["tools", "webhooks"];
28
+ export type EgressPolicyScope = (typeof EGRESS_POLICY_SCOPES)[number];
29
+ /** Политика egress для встроенных инструментов (web_fetch/web_search/…). */
30
+ export interface EgressPolicy {
31
+ mode: EgressPolicyMode;
32
+ /** CIDR/IP/hostname-правила основного списка. */
33
+ list: string[];
34
+ /** Allow-правила-исключения (проверяются первыми). */
35
+ exceptions: string[];
36
+ }
37
+ /** Политика egress для исходящих webhooks (доп. режим `off` — dev). */
38
+ export interface WebhooksEgressPolicy {
39
+ mode: WebhooksEgressPolicyMode;
40
+ list: string[];
41
+ exceptions: string[];
42
+ }
43
+ /** Настройки журнала внешних запросов (аудит egress). */
44
+ export interface EgressLogConfig {
45
+ enabled: boolean;
46
+ /** Срок хранения в днях; `0` — не чистить. */
47
+ retentionDays: number;
48
+ }
49
+ /**
50
+ * Дефолтная политика встроенных инструментов: deny служебных диапазонов
51
+ * (`DEFAULT_MCP_PRIVATE_CIDRS` — общий канонический список, см. `types/mcp.ts`).
52
+ */
53
+ export declare const DEFAULT_EGRESS_TOOLS_POLICY: EgressPolicy;
54
+ /**
55
+ * Дефолтная политика webhooks: deny служебных диапазонов (тот же общий список)
56
+ * + обязательный https.
57
+ */
58
+ export declare const DEFAULT_EGRESS_WEBHOOKS_POLICY: WebhooksEgressPolicy;
59
+ /** Дефолт журнала внешних запросов: включён, хранить 7 дней. */
60
+ export declare const DEFAULT_EGRESS_LOG: EgressLogConfig;
61
+ /** Скоупы (источники) внешних запросов в журнале egress. */
62
+ export declare const EGRESS_REQUEST_SCOPES: readonly ["web_fetch", "web_search", "skills", "instructions", "webhooks", "providers", "mcp"];
63
+ export type EgressRequestScope = (typeof EGRESS_REQUEST_SCOPES)[number];
64
+ export declare const EGRESS_REQUEST_STATUSES: readonly ["allowed", "blocked", "error"];
65
+ export type EgressRequestStatus = (typeof EGRESS_REQUEST_STATUSES)[number];
66
+ /**
67
+ * ADR-099 (D1): фактический маршрут запроса — через прокси, напрямую либо
68
+ * direct-фоллбек после недоступного прокси (`proxy.fallbackDirect`).
69
+ */
70
+ export declare const EGRESS_REQUEST_VIAS: readonly ["proxy", "direct", "fallback"];
71
+ export type EgressRequestVia = (typeof EGRESS_REQUEST_VIAS)[number];
72
+ /**
73
+ * Запись журнала внешних запросов (append-only, без тел/заголовков).
74
+ * `url` хранится без query/userinfo и обрезается до 2048 символов.
75
+ */
76
+ export interface EgressRequestLogEntry {
77
+ id: string;
78
+ ts: string;
79
+ scope: EgressRequestScope;
80
+ host: string;
81
+ url: string;
82
+ method?: string;
83
+ status: EgressRequestStatus;
84
+ /** Маршрут запроса (ADR-099 D1): proxy/direct/fallback. */
85
+ via?: EgressRequestVia;
86
+ httpStatus?: number;
87
+ bytes?: number;
88
+ durationMs?: number;
89
+ reason?: string;
90
+ matchedRule?: string;
91
+ sessionId?: string;
92
+ projectId?: string;
93
+ actor?: string;
94
+ }
95
+ /** Скоупы изменений egress-политик/прокси в security-аудите. */
96
+ export declare const SECURITY_AUDIT_SCOPES: readonly ["tools", "webhooks", "mcp", "proxy", "tls", "attachments"];
97
+ export type SecurityAuditScope = (typeof SECURITY_AUDIT_SCOPES)[number];
98
+ export declare const SECURITY_AUDIT_ACTIONS: readonly ["update", "reset"];
99
+ export type SecurityAuditAction = (typeof SECURITY_AUDIT_ACTIONS)[number];
100
+ /**
101
+ * Запись аудита изменений security-политик (append-only). `before`/`after` —
102
+ * снимки политики до/после операции (`null` для reset — значение не задано).
103
+ */
104
+ export interface SecurityAuditEntry {
105
+ id: string;
106
+ ts: string;
107
+ actor: string;
108
+ scope: SecurityAuditScope;
109
+ action: SecurityAuditAction;
110
+ source: 'runtime';
111
+ before: unknown;
112
+ after: unknown;
113
+ version: number;
114
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Egress-политика исходящих запросов (web/инструкции/скиллы/webhooks/providers/MCP).
3
+ *
4
+ * Единый формат политики (`mode` + `list` + `exceptions`) используется всеми
5
+ * потребителями; `webhooks` дополнительно поддерживает `mode: 'off'` (dev, без
6
+ * проверок и без требования https). Семантика:
7
+ * - `exceptions` — allow-правила, проверяются **первыми** (точный hostname,
8
+ * `*.suffix`, CIDR/IP); hostname-правило разрешает сразу, CIDR — по резолву;
9
+ * - `deny` + `list` — блок, если хотя бы один resolved-адрес в `list`;
10
+ * - `allow` + `list` — разрешено, если ВСЕ resolved-адреса в `list` (или exception);
11
+ * - `off` (только webhooks) — проверок нет, `requireHttps = false`.
12
+ *
13
+ * Литеральные `localhost`/`*.localhost`/`*.local`/`*.internal` и приватные IP
14
+ * блокируются самой политикой (дефолтный `list`), а не отдельным зашитым списком;
15
+ * exception может их разрешить.
16
+ *
17
+ * Дефолтный `list` — **общий канонический список** `DEFAULT_MCP_PRIVATE_CIDRS`
18
+ * (`types/mcp.ts`): он же — дефолт `mcp.networkPolicy` и встроенный fallback
19
+ * `engine/net/egress-guard.ts`. Списков «заблокированных адресов» в коде больше
20
+ * нет, поэтому расширять блокировки нужно только этот список.
21
+ */
22
+ import { DEFAULT_MCP_PRIVATE_CIDRS } from './mcp.js';
23
+ export const EGRESS_POLICY_MODES = ['deny', 'allow'];
24
+ export const WEBHOOKS_EGRESS_POLICY_MODES = ['deny', 'allow', 'off'];
25
+ /** Скоупы настраиваемой egress-политики (settings/egress). */
26
+ export const EGRESS_POLICY_SCOPES = ['tools', 'webhooks'];
27
+ /**
28
+ * Дефолтная политика встроенных инструментов: deny служебных диапазонов
29
+ * (`DEFAULT_MCP_PRIVATE_CIDRS` — общий канонический список, см. `types/mcp.ts`).
30
+ */
31
+ export const DEFAULT_EGRESS_TOOLS_POLICY = {
32
+ mode: 'deny',
33
+ list: [...DEFAULT_MCP_PRIVATE_CIDRS],
34
+ exceptions: [],
35
+ };
36
+ /**
37
+ * Дефолтная политика webhooks: deny служебных диапазонов (тот же общий список)
38
+ * + обязательный https.
39
+ */
40
+ export const DEFAULT_EGRESS_WEBHOOKS_POLICY = {
41
+ mode: 'deny',
42
+ list: [...DEFAULT_MCP_PRIVATE_CIDRS],
43
+ exceptions: [],
44
+ };
45
+ /** Дефолт журнала внешних запросов: включён, хранить 7 дней. */
46
+ export const DEFAULT_EGRESS_LOG = {
47
+ enabled: true,
48
+ retentionDays: 7,
49
+ };
50
+ /** Скоупы (источники) внешних запросов в журнале egress. */
51
+ export const EGRESS_REQUEST_SCOPES = [
52
+ 'web_fetch',
53
+ 'web_search',
54
+ 'skills',
55
+ 'instructions',
56
+ 'webhooks',
57
+ 'providers',
58
+ 'mcp',
59
+ ];
60
+ export const EGRESS_REQUEST_STATUSES = ['allowed', 'blocked', 'error'];
61
+ /**
62
+ * ADR-099 (D1): фактический маршрут запроса — через прокси, напрямую либо
63
+ * direct-фоллбек после недоступного прокси (`proxy.fallbackDirect`).
64
+ */
65
+ export const EGRESS_REQUEST_VIAS = ['proxy', 'direct', 'fallback'];
66
+ /** Скоупы изменений egress-политик/прокси в security-аудите. */
67
+ export const SECURITY_AUDIT_SCOPES = ['tools', 'webhooks', 'mcp', 'proxy', 'tls', 'attachments'];
68
+ export const SECURITY_AUDIT_ACTIONS = ['update', 'reset'];