@peac/policy-kit 0.9.18 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.ts CHANGED
@@ -82,7 +82,7 @@ export declare const PolicyRuleSchema: z.ZodObject<{
82
82
  id?: string | undefined;
83
83
  }>>;
84
84
  /** Purpose(s) this rule applies to - single purpose or array */
85
- purpose: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["crawl", "index", "train", "inference", "ai_input", "ai_index", "search"]>, z.ZodArray<z.ZodEnum<["crawl", "index", "train", "inference", "ai_input", "ai_index", "search"]>, "many">]>>;
85
+ purpose: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["crawl", "index", "train", "inference", "user_action", "ai_input", "ai_index", "search"]>, z.ZodArray<z.ZodEnum<["crawl", "index", "train", "inference", "user_action", "ai_input", "ai_index", "search"]>, "many">]>>;
86
86
  /** Licensing mode(s) this rule applies to */
87
87
  licensing_mode: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["subscription", "pay_per_crawl", "pay_per_inference"]>, z.ZodArray<z.ZodEnum<["subscription", "pay_per_crawl", "pay_per_inference"]>, "many">]>>;
88
88
  /** Decision if rule matches */
@@ -97,7 +97,7 @@ export declare const PolicyRuleSchema: z.ZodObject<{
97
97
  labels?: string[] | undefined;
98
98
  id?: string | undefined;
99
99
  } | undefined;
100
- purpose?: "crawl" | "index" | "train" | "inference" | "ai_input" | "ai_index" | "search" | ("crawl" | "index" | "train" | "inference" | "ai_input" | "ai_index" | "search")[] | undefined;
100
+ purpose?: "crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search" | ("crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search")[] | undefined;
101
101
  licensing_mode?: "subscription" | "pay_per_crawl" | "pay_per_inference" | ("subscription" | "pay_per_crawl" | "pay_per_inference")[] | undefined;
102
102
  reason?: string | undefined;
103
103
  }, {
@@ -108,7 +108,7 @@ export declare const PolicyRuleSchema: z.ZodObject<{
108
108
  labels?: string[] | undefined;
109
109
  id?: string | undefined;
110
110
  } | undefined;
111
- purpose?: "crawl" | "index" | "train" | "inference" | "ai_input" | "ai_index" | "search" | ("crawl" | "index" | "train" | "inference" | "ai_input" | "ai_index" | "search")[] | undefined;
111
+ purpose?: "crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search" | ("crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search")[] | undefined;
112
112
  licensing_mode?: "subscription" | "pay_per_crawl" | "pay_per_inference" | ("subscription" | "pay_per_crawl" | "pay_per_inference")[] | undefined;
113
113
  reason?: string | undefined;
114
114
  }>;
@@ -172,7 +172,7 @@ export declare const PolicyDocumentSchema: z.ZodObject<{
172
172
  id?: string | undefined;
173
173
  }>>;
174
174
  /** Purpose(s) this rule applies to - single purpose or array */
175
- purpose: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["crawl", "index", "train", "inference", "ai_input", "ai_index", "search"]>, z.ZodArray<z.ZodEnum<["crawl", "index", "train", "inference", "ai_input", "ai_index", "search"]>, "many">]>>;
175
+ purpose: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["crawl", "index", "train", "inference", "user_action", "ai_input", "ai_index", "search"]>, z.ZodArray<z.ZodEnum<["crawl", "index", "train", "inference", "user_action", "ai_input", "ai_index", "search"]>, "many">]>>;
176
176
  /** Licensing mode(s) this rule applies to */
177
177
  licensing_mode: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["subscription", "pay_per_crawl", "pay_per_inference"]>, z.ZodArray<z.ZodEnum<["subscription", "pay_per_crawl", "pay_per_inference"]>, "many">]>>;
178
178
  /** Decision if rule matches */
@@ -187,7 +187,7 @@ export declare const PolicyDocumentSchema: z.ZodObject<{
187
187
  labels?: string[] | undefined;
188
188
  id?: string | undefined;
189
189
  } | undefined;
190
- purpose?: "crawl" | "index" | "train" | "inference" | "ai_input" | "ai_index" | "search" | ("crawl" | "index" | "train" | "inference" | "ai_input" | "ai_index" | "search")[] | undefined;
190
+ purpose?: "crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search" | ("crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search")[] | undefined;
191
191
  licensing_mode?: "subscription" | "pay_per_crawl" | "pay_per_inference" | ("subscription" | "pay_per_crawl" | "pay_per_inference")[] | undefined;
192
192
  reason?: string | undefined;
193
193
  }, {
@@ -198,7 +198,7 @@ export declare const PolicyDocumentSchema: z.ZodObject<{
198
198
  labels?: string[] | undefined;
199
199
  id?: string | undefined;
200
200
  } | undefined;
201
- purpose?: "crawl" | "index" | "train" | "inference" | "ai_input" | "ai_index" | "search" | ("crawl" | "index" | "train" | "inference" | "ai_input" | "ai_index" | "search")[] | undefined;
201
+ purpose?: "crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search" | ("crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search")[] | undefined;
202
202
  licensing_mode?: "subscription" | "pay_per_crawl" | "pay_per_inference" | ("subscription" | "pay_per_crawl" | "pay_per_inference")[] | undefined;
203
203
  reason?: string | undefined;
204
204
  }>, "many">;
@@ -216,7 +216,7 @@ export declare const PolicyDocumentSchema: z.ZodObject<{
216
216
  labels?: string[] | undefined;
217
217
  id?: string | undefined;
218
218
  } | undefined;
219
- purpose?: "crawl" | "index" | "train" | "inference" | "ai_input" | "ai_index" | "search" | ("crawl" | "index" | "train" | "inference" | "ai_input" | "ai_index" | "search")[] | undefined;
219
+ purpose?: "crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search" | ("crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search")[] | undefined;
220
220
  licensing_mode?: "subscription" | "pay_per_crawl" | "pay_per_inference" | ("subscription" | "pay_per_crawl" | "pay_per_inference")[] | undefined;
221
221
  reason?: string | undefined;
222
222
  }[];
@@ -235,7 +235,7 @@ export declare const PolicyDocumentSchema: z.ZodObject<{
235
235
  labels?: string[] | undefined;
236
236
  id?: string | undefined;
237
237
  } | undefined;
238
- purpose?: "crawl" | "index" | "train" | "inference" | "ai_input" | "ai_index" | "search" | ("crawl" | "index" | "train" | "inference" | "ai_input" | "ai_index" | "search")[] | undefined;
238
+ purpose?: "crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search" | ("crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search")[] | undefined;
239
239
  licensing_mode?: "subscription" | "pay_per_crawl" | "pay_per_inference" | ("subscription" | "pay_per_crawl" | "pay_per_inference")[] | undefined;
240
240
  reason?: string | undefined;
241
241
  }[];
@@ -273,4 +273,616 @@ export interface EvaluationResult {
273
273
  /** Whether default was applied (no rule matched) */
274
274
  is_default: boolean;
275
275
  }
276
+ /**
277
+ * Structured rate limit configuration.
278
+ *
279
+ * Uses `window_seconds` for future-proofing (avoids enum lock-in).
280
+ * CLI parses human-friendly strings like "100/hour" to this format.
281
+ *
282
+ * @example
283
+ * ```typescript
284
+ * const limit: RateLimitConfig = {
285
+ * limit: 100,
286
+ * window_seconds: 3600, // 1 hour
287
+ * burst: 10,
288
+ * partition: 'agent',
289
+ * };
290
+ * ```
291
+ */
292
+ export declare const RateLimitConfigSchema: z.ZodObject<{
293
+ /** Maximum requests allowed in the window */
294
+ limit: z.ZodNumber;
295
+ /** Window size in seconds (e.g., 3600 for 1 hour) */
296
+ window_seconds: z.ZodNumber;
297
+ /** Optional burst allowance above the limit */
298
+ burst: z.ZodOptional<z.ZodNumber>;
299
+ /** How to partition rate limits (default: per-agent) */
300
+ partition: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["agent", "ip", "account"]>, z.ZodString]>>;
301
+ }, "strict", z.ZodTypeAny, {
302
+ limit: number;
303
+ window_seconds: number;
304
+ burst?: number | undefined;
305
+ partition?: string | undefined;
306
+ }, {
307
+ limit: number;
308
+ window_seconds: number;
309
+ burst?: number | undefined;
310
+ partition?: string | undefined;
311
+ }>;
312
+ export type RateLimitConfig = z.infer<typeof RateLimitConfigSchema>;
313
+ /**
314
+ * Parse a human-friendly rate limit string to RateLimitConfig.
315
+ *
316
+ * @example
317
+ * ```typescript
318
+ * parseRateLimit('100/hour'); // { limit: 100, window_seconds: 3600 }
319
+ * parseRateLimit('1000/day'); // { limit: 1000, window_seconds: 86400 }
320
+ * parseRateLimit('10/minute'); // { limit: 10, window_seconds: 60 }
321
+ * ```
322
+ */
323
+ export declare function parseRateLimit(input: string): RateLimitConfig;
324
+ /**
325
+ * Format a RateLimitConfig to human-friendly string.
326
+ */
327
+ export declare function formatRateLimit(config: RateLimitConfig): string;
328
+ /**
329
+ * Requirements for 'review' decision (challenge-required semantics).
330
+ *
331
+ * When decision is 'review' and requirements are not met:
332
+ * - Enforcement returns a challenge response (e.g., HTTP 402)
333
+ * - Client provides proof (e.g., PEAC receipt)
334
+ * - On valid proof, access is granted
335
+ *
336
+ * This differs from 'deny' which is unconditional rejection.
337
+ *
338
+ * @example
339
+ * ```typescript
340
+ * const rule: PolicyRule = {
341
+ * name: 'inference-needs-receipt',
342
+ * purpose: 'inference',
343
+ * decision: 'review',
344
+ * requirements: { receipt: true },
345
+ * };
346
+ * ```
347
+ */
348
+ export declare const DecisionRequirementsSchema: z.ZodObject<{
349
+ /** Require a valid PEAC receipt */
350
+ receipt: z.ZodOptional<z.ZodBoolean>;
351
+ }, "strict", z.ZodTypeAny, {
352
+ receipt?: boolean | undefined;
353
+ }, {
354
+ receipt?: boolean | undefined;
355
+ }>;
356
+ export type DecisionRequirements = z.infer<typeof DecisionRequirementsSchema>;
357
+ /**
358
+ * Profile parameter definition.
359
+ *
360
+ * Defines a configurable parameter for a profile.
361
+ */
362
+ export declare const ProfileParameterSchema: z.ZodObject<{
363
+ /** Human-readable description */
364
+ description: z.ZodString;
365
+ /** Whether this parameter is required */
366
+ required: z.ZodOptional<z.ZodBoolean>;
367
+ /** Default value if not provided */
368
+ default: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
369
+ /** Example value for documentation */
370
+ example: z.ZodOptional<z.ZodString>;
371
+ /** Validation type for the parameter */
372
+ validate: z.ZodOptional<z.ZodEnum<["email", "url", "rate_limit"]>>;
373
+ }, "strict", z.ZodTypeAny, {
374
+ description: string;
375
+ required?: boolean | undefined;
376
+ default?: string | number | boolean | undefined;
377
+ example?: string | undefined;
378
+ validate?: "email" | "url" | "rate_limit" | undefined;
379
+ }, {
380
+ description: string;
381
+ required?: boolean | undefined;
382
+ default?: string | number | boolean | undefined;
383
+ example?: string | undefined;
384
+ validate?: "email" | "url" | "rate_limit" | undefined;
385
+ }>;
386
+ export type ProfileParameter = z.infer<typeof ProfileParameterSchema>;
387
+ /**
388
+ * Profile definition.
389
+ *
390
+ * A profile is a pre-configured policy template for a specific use case
391
+ * (e.g., news publisher, SaaS docs, open source project).
392
+ *
393
+ * Profiles are compiled to TypeScript at build time for:
394
+ * - Type safety
395
+ * - No runtime YAML/fs dependencies
396
+ * - Deterministic output
397
+ *
398
+ * @example
399
+ * ```typescript
400
+ * const profile: ProfileDefinition = {
401
+ * id: 'news-media',
402
+ * name: 'News Media Publisher',
403
+ * description: 'Policy for news and media publishers...',
404
+ * policy: { ... },
405
+ * parameters: {
406
+ * contact: { description: 'Contact email', required: true, validate: 'email' },
407
+ * rate_limit: { description: 'Rate limit', default: '100/hour', validate: 'rate_limit' },
408
+ * },
409
+ * defaults: {
410
+ * requirements: { receipt: true },
411
+ * },
412
+ * };
413
+ * ```
414
+ */
415
+ export declare const ProfileDefinitionSchema: z.ZodObject<{
416
+ /** Unique profile identifier (e.g., 'news-media') */
417
+ id: z.ZodString;
418
+ /** Human-readable profile name */
419
+ name: z.ZodString;
420
+ /** Multi-line description of the profile */
421
+ description: z.ZodString;
422
+ /** Base policy document */
423
+ policy: z.ZodObject<{
424
+ /** Policy format version */
425
+ version: z.ZodLiteral<"peac-policy/0.1">;
426
+ /** Policy name/description (optional) */
427
+ name: z.ZodOptional<z.ZodString>;
428
+ /** Default decision (required) */
429
+ defaults: z.ZodObject<{
430
+ /** Default decision when no rule matches */
431
+ decision: z.ZodEnum<["allow", "deny", "review"]>;
432
+ /** Default reason for audit trail */
433
+ reason: z.ZodOptional<z.ZodString>;
434
+ }, "strict", z.ZodTypeAny, {
435
+ decision: "allow" | "deny" | "review";
436
+ reason?: string | undefined;
437
+ }, {
438
+ decision: "allow" | "deny" | "review";
439
+ reason?: string | undefined;
440
+ }>;
441
+ /** Rules evaluated in order (first match wins) */
442
+ rules: z.ZodArray<z.ZodObject<{
443
+ /** Rule name (for debugging/auditing) */
444
+ name: z.ZodString;
445
+ /** Subject matcher (omit for any subject) */
446
+ subject: z.ZodOptional<z.ZodObject<{
447
+ /** Match by subject type(s) - single type or array */
448
+ type: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["human", "org", "agent"]>, z.ZodArray<z.ZodEnum<["human", "org", "agent"]>, "many">]>>;
449
+ /** Match by label(s) - subject must have ALL specified labels */
450
+ labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
451
+ /** Match by subject ID pattern (exact match or prefix with *) */
452
+ id: z.ZodOptional<z.ZodString>;
453
+ }, "strict", z.ZodTypeAny, {
454
+ type?: "human" | "org" | "agent" | ("human" | "org" | "agent")[] | undefined;
455
+ labels?: string[] | undefined;
456
+ id?: string | undefined;
457
+ }, {
458
+ type?: "human" | "org" | "agent" | ("human" | "org" | "agent")[] | undefined;
459
+ labels?: string[] | undefined;
460
+ id?: string | undefined;
461
+ }>>;
462
+ /** Purpose(s) this rule applies to - single purpose or array */
463
+ purpose: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["crawl", "index", "train", "inference", "user_action", "ai_input", "ai_index", "search"]>, z.ZodArray<z.ZodEnum<["crawl", "index", "train", "inference", "user_action", "ai_input", "ai_index", "search"]>, "many">]>>;
464
+ /** Licensing mode(s) this rule applies to */
465
+ licensing_mode: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["subscription", "pay_per_crawl", "pay_per_inference"]>, z.ZodArray<z.ZodEnum<["subscription", "pay_per_crawl", "pay_per_inference"]>, "many">]>>;
466
+ /** Decision if rule matches */
467
+ decision: z.ZodEnum<["allow", "deny", "review"]>;
468
+ /** Reason for decision (for audit trail) */
469
+ reason: z.ZodOptional<z.ZodString>;
470
+ }, "strict", z.ZodTypeAny, {
471
+ name: string;
472
+ decision: "allow" | "deny" | "review";
473
+ subject?: {
474
+ type?: "human" | "org" | "agent" | ("human" | "org" | "agent")[] | undefined;
475
+ labels?: string[] | undefined;
476
+ id?: string | undefined;
477
+ } | undefined;
478
+ purpose?: "crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search" | ("crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search")[] | undefined;
479
+ licensing_mode?: "subscription" | "pay_per_crawl" | "pay_per_inference" | ("subscription" | "pay_per_crawl" | "pay_per_inference")[] | undefined;
480
+ reason?: string | undefined;
481
+ }, {
482
+ name: string;
483
+ decision: "allow" | "deny" | "review";
484
+ subject?: {
485
+ type?: "human" | "org" | "agent" | ("human" | "org" | "agent")[] | undefined;
486
+ labels?: string[] | undefined;
487
+ id?: string | undefined;
488
+ } | undefined;
489
+ purpose?: "crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search" | ("crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search")[] | undefined;
490
+ licensing_mode?: "subscription" | "pay_per_crawl" | "pay_per_inference" | ("subscription" | "pay_per_crawl" | "pay_per_inference")[] | undefined;
491
+ reason?: string | undefined;
492
+ }>, "many">;
493
+ }, "strict", z.ZodTypeAny, {
494
+ version: "peac-policy/0.1";
495
+ defaults: {
496
+ decision: "allow" | "deny" | "review";
497
+ reason?: string | undefined;
498
+ };
499
+ rules: {
500
+ name: string;
501
+ decision: "allow" | "deny" | "review";
502
+ subject?: {
503
+ type?: "human" | "org" | "agent" | ("human" | "org" | "agent")[] | undefined;
504
+ labels?: string[] | undefined;
505
+ id?: string | undefined;
506
+ } | undefined;
507
+ purpose?: "crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search" | ("crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search")[] | undefined;
508
+ licensing_mode?: "subscription" | "pay_per_crawl" | "pay_per_inference" | ("subscription" | "pay_per_crawl" | "pay_per_inference")[] | undefined;
509
+ reason?: string | undefined;
510
+ }[];
511
+ name?: string | undefined;
512
+ }, {
513
+ version: "peac-policy/0.1";
514
+ defaults: {
515
+ decision: "allow" | "deny" | "review";
516
+ reason?: string | undefined;
517
+ };
518
+ rules: {
519
+ name: string;
520
+ decision: "allow" | "deny" | "review";
521
+ subject?: {
522
+ type?: "human" | "org" | "agent" | ("human" | "org" | "agent")[] | undefined;
523
+ labels?: string[] | undefined;
524
+ id?: string | undefined;
525
+ } | undefined;
526
+ purpose?: "crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search" | ("crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search")[] | undefined;
527
+ licensing_mode?: "subscription" | "pay_per_crawl" | "pay_per_inference" | ("subscription" | "pay_per_crawl" | "pay_per_inference")[] | undefined;
528
+ reason?: string | undefined;
529
+ }[];
530
+ name?: string | undefined;
531
+ }>;
532
+ /** Configurable parameters */
533
+ parameters: z.ZodRecord<z.ZodString, z.ZodObject<{
534
+ /** Human-readable description */
535
+ description: z.ZodString;
536
+ /** Whether this parameter is required */
537
+ required: z.ZodOptional<z.ZodBoolean>;
538
+ /** Default value if not provided */
539
+ default: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
540
+ /** Example value for documentation */
541
+ example: z.ZodOptional<z.ZodString>;
542
+ /** Validation type for the parameter */
543
+ validate: z.ZodOptional<z.ZodEnum<["email", "url", "rate_limit"]>>;
544
+ }, "strict", z.ZodTypeAny, {
545
+ description: string;
546
+ required?: boolean | undefined;
547
+ default?: string | number | boolean | undefined;
548
+ example?: string | undefined;
549
+ validate?: "email" | "url" | "rate_limit" | undefined;
550
+ }, {
551
+ description: string;
552
+ required?: boolean | undefined;
553
+ default?: string | number | boolean | undefined;
554
+ example?: string | undefined;
555
+ validate?: "email" | "url" | "rate_limit" | undefined;
556
+ }>>;
557
+ /** Default values for profile instances */
558
+ defaults: z.ZodOptional<z.ZodObject<{
559
+ /** Default requirements for 'review' decisions */
560
+ requirements: z.ZodOptional<z.ZodObject<{
561
+ /** Require a valid PEAC receipt */
562
+ receipt: z.ZodOptional<z.ZodBoolean>;
563
+ }, "strict", z.ZodTypeAny, {
564
+ receipt?: boolean | undefined;
565
+ }, {
566
+ receipt?: boolean | undefined;
567
+ }>>;
568
+ /** Default rate limit */
569
+ rate_limit: z.ZodOptional<z.ZodObject<{
570
+ /** Maximum requests allowed in the window */
571
+ limit: z.ZodNumber;
572
+ /** Window size in seconds (e.g., 3600 for 1 hour) */
573
+ window_seconds: z.ZodNumber;
574
+ /** Optional burst allowance above the limit */
575
+ burst: z.ZodOptional<z.ZodNumber>;
576
+ /** How to partition rate limits (default: per-agent) */
577
+ partition: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["agent", "ip", "account"]>, z.ZodString]>>;
578
+ }, "strict", z.ZodTypeAny, {
579
+ limit: number;
580
+ window_seconds: number;
581
+ burst?: number | undefined;
582
+ partition?: string | undefined;
583
+ }, {
584
+ limit: number;
585
+ window_seconds: number;
586
+ burst?: number | undefined;
587
+ partition?: string | undefined;
588
+ }>>;
589
+ }, "strict", z.ZodTypeAny, {
590
+ rate_limit?: {
591
+ limit: number;
592
+ window_seconds: number;
593
+ burst?: number | undefined;
594
+ partition?: string | undefined;
595
+ } | undefined;
596
+ requirements?: {
597
+ receipt?: boolean | undefined;
598
+ } | undefined;
599
+ }, {
600
+ rate_limit?: {
601
+ limit: number;
602
+ window_seconds: number;
603
+ burst?: number | undefined;
604
+ partition?: string | undefined;
605
+ } | undefined;
606
+ requirements?: {
607
+ receipt?: boolean | undefined;
608
+ } | undefined;
609
+ }>>;
610
+ }, "strict", z.ZodTypeAny, {
611
+ id: string;
612
+ name: string;
613
+ description: string;
614
+ policy: {
615
+ version: "peac-policy/0.1";
616
+ defaults: {
617
+ decision: "allow" | "deny" | "review";
618
+ reason?: string | undefined;
619
+ };
620
+ rules: {
621
+ name: string;
622
+ decision: "allow" | "deny" | "review";
623
+ subject?: {
624
+ type?: "human" | "org" | "agent" | ("human" | "org" | "agent")[] | undefined;
625
+ labels?: string[] | undefined;
626
+ id?: string | undefined;
627
+ } | undefined;
628
+ purpose?: "crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search" | ("crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search")[] | undefined;
629
+ licensing_mode?: "subscription" | "pay_per_crawl" | "pay_per_inference" | ("subscription" | "pay_per_crawl" | "pay_per_inference")[] | undefined;
630
+ reason?: string | undefined;
631
+ }[];
632
+ name?: string | undefined;
633
+ };
634
+ parameters: Record<string, {
635
+ description: string;
636
+ required?: boolean | undefined;
637
+ default?: string | number | boolean | undefined;
638
+ example?: string | undefined;
639
+ validate?: "email" | "url" | "rate_limit" | undefined;
640
+ }>;
641
+ defaults?: {
642
+ rate_limit?: {
643
+ limit: number;
644
+ window_seconds: number;
645
+ burst?: number | undefined;
646
+ partition?: string | undefined;
647
+ } | undefined;
648
+ requirements?: {
649
+ receipt?: boolean | undefined;
650
+ } | undefined;
651
+ } | undefined;
652
+ }, {
653
+ id: string;
654
+ name: string;
655
+ description: string;
656
+ policy: {
657
+ version: "peac-policy/0.1";
658
+ defaults: {
659
+ decision: "allow" | "deny" | "review";
660
+ reason?: string | undefined;
661
+ };
662
+ rules: {
663
+ name: string;
664
+ decision: "allow" | "deny" | "review";
665
+ subject?: {
666
+ type?: "human" | "org" | "agent" | ("human" | "org" | "agent")[] | undefined;
667
+ labels?: string[] | undefined;
668
+ id?: string | undefined;
669
+ } | undefined;
670
+ purpose?: "crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search" | ("crawl" | "index" | "train" | "inference" | "user_action" | "ai_input" | "ai_index" | "search")[] | undefined;
671
+ licensing_mode?: "subscription" | "pay_per_crawl" | "pay_per_inference" | ("subscription" | "pay_per_crawl" | "pay_per_inference")[] | undefined;
672
+ reason?: string | undefined;
673
+ }[];
674
+ name?: string | undefined;
675
+ };
676
+ parameters: Record<string, {
677
+ description: string;
678
+ required?: boolean | undefined;
679
+ default?: string | number | boolean | undefined;
680
+ example?: string | undefined;
681
+ validate?: "email" | "url" | "rate_limit" | undefined;
682
+ }>;
683
+ defaults?: {
684
+ rate_limit?: {
685
+ limit: number;
686
+ window_seconds: number;
687
+ burst?: number | undefined;
688
+ partition?: string | undefined;
689
+ } | undefined;
690
+ requirements?: {
691
+ receipt?: boolean | undefined;
692
+ } | undefined;
693
+ } | undefined;
694
+ }>;
695
+ export type ProfileDefinition = z.infer<typeof ProfileDefinitionSchema>;
696
+ /**
697
+ * Policy constraints for rate limiting and budget control.
698
+ *
699
+ * These constraints are ADVISORY - enforcement happens at the edge/application layer.
700
+ * PEAC receipts capture what constraints were DECLARED, not whether they were enforced.
701
+ *
702
+ * @example
703
+ * ```typescript
704
+ * const constraints: PolicyConstraints = {
705
+ * rate_limit: { window_s: 3600, max: 100 },
706
+ * budget: { max_requests: 1000 },
707
+ * };
708
+ * ```
709
+ */
710
+ export declare const PolicyConstraintsSchema: z.ZodObject<{
711
+ /** Rate limit configuration */
712
+ rate_limit: z.ZodOptional<z.ZodObject<{
713
+ /** Window size in seconds */
714
+ window_s: z.ZodNumber;
715
+ /** Maximum requests allowed in the window */
716
+ max: z.ZodNumber;
717
+ /** Retry-After header value in seconds (optional) */
718
+ retry_after_s: z.ZodOptional<z.ZodNumber>;
719
+ }, "strict", z.ZodTypeAny, {
720
+ window_s: number;
721
+ max: number;
722
+ retry_after_s?: number | undefined;
723
+ }, {
724
+ window_s: number;
725
+ max: number;
726
+ retry_after_s?: number | undefined;
727
+ }>>;
728
+ /** Budget constraints */
729
+ budget: z.ZodOptional<z.ZodObject<{
730
+ /** Maximum tokens allowed */
731
+ max_tokens: z.ZodOptional<z.ZodNumber>;
732
+ /** Maximum requests allowed */
733
+ max_requests: z.ZodOptional<z.ZodNumber>;
734
+ }, "strict", z.ZodTypeAny, {
735
+ max_tokens?: number | undefined;
736
+ max_requests?: number | undefined;
737
+ }, {
738
+ max_tokens?: number | undefined;
739
+ max_requests?: number | undefined;
740
+ }>>;
741
+ }, "strict", z.ZodTypeAny, {
742
+ rate_limit?: {
743
+ window_s: number;
744
+ max: number;
745
+ retry_after_s?: number | undefined;
746
+ } | undefined;
747
+ budget?: {
748
+ max_tokens?: number | undefined;
749
+ max_requests?: number | undefined;
750
+ } | undefined;
751
+ }, {
752
+ rate_limit?: {
753
+ window_s: number;
754
+ max: number;
755
+ retry_after_s?: number | undefined;
756
+ } | undefined;
757
+ budget?: {
758
+ max_tokens?: number | undefined;
759
+ max_requests?: number | undefined;
760
+ } | undefined;
761
+ }>;
762
+ export type PolicyConstraints = z.infer<typeof PolicyConstraintsSchema>;
763
+ /**
764
+ * Enforcement profile for purpose handling.
765
+ *
766
+ * Defines how undeclared or unknown purposes are handled at the enforcement layer.
767
+ * These are distinct from use-case profiles (api-provider, news-media, etc.).
768
+ *
769
+ * Three canonical profiles:
770
+ * - `strict`: Deny undeclared purposes (regulated data, private APIs)
771
+ * - `balanced`: Review + constraints for undeclared purposes (general web, default)
772
+ * - `open`: Allow undeclared purposes with recording (public content, research)
773
+ */
774
+ export type EnforcementProfileId = 'strict' | 'balanced' | 'open';
775
+ /**
776
+ * Enforcement profile definition.
777
+ *
778
+ * Specifies how to handle requests with undeclared, unknown, or missing purposes.
779
+ */
780
+ export declare const EnforcementProfileSchema: z.ZodObject<{
781
+ /** Profile identifier */
782
+ id: z.ZodEnum<["strict", "balanced", "open"]>;
783
+ /** Human-readable name */
784
+ name: z.ZodString;
785
+ /** Description of when to use this profile */
786
+ description: z.ZodString;
787
+ /** Decision for requests with no purpose declared (missing header) */
788
+ undeclared_decision: z.ZodEnum<["allow", "deny", "review"]>;
789
+ /** Decision for requests with unknown purpose tokens */
790
+ unknown_decision: z.ZodEnum<["allow", "deny", "review"]>;
791
+ /** Purpose reason to record when undeclared/unknown is processed */
792
+ purpose_reason: z.ZodEnum<["allowed", "constrained", "denied", "downgraded", "undeclared_default", "unknown_preserved"]>;
793
+ /** Default constraints to apply for 'review' decisions */
794
+ default_constraints: z.ZodOptional<z.ZodObject<{
795
+ /** Rate limit configuration */
796
+ rate_limit: z.ZodOptional<z.ZodObject<{
797
+ /** Window size in seconds */
798
+ window_s: z.ZodNumber;
799
+ /** Maximum requests allowed in the window */
800
+ max: z.ZodNumber;
801
+ /** Retry-After header value in seconds (optional) */
802
+ retry_after_s: z.ZodOptional<z.ZodNumber>;
803
+ }, "strict", z.ZodTypeAny, {
804
+ window_s: number;
805
+ max: number;
806
+ retry_after_s?: number | undefined;
807
+ }, {
808
+ window_s: number;
809
+ max: number;
810
+ retry_after_s?: number | undefined;
811
+ }>>;
812
+ /** Budget constraints */
813
+ budget: z.ZodOptional<z.ZodObject<{
814
+ /** Maximum tokens allowed */
815
+ max_tokens: z.ZodOptional<z.ZodNumber>;
816
+ /** Maximum requests allowed */
817
+ max_requests: z.ZodOptional<z.ZodNumber>;
818
+ }, "strict", z.ZodTypeAny, {
819
+ max_tokens?: number | undefined;
820
+ max_requests?: number | undefined;
821
+ }, {
822
+ max_tokens?: number | undefined;
823
+ max_requests?: number | undefined;
824
+ }>>;
825
+ }, "strict", z.ZodTypeAny, {
826
+ rate_limit?: {
827
+ window_s: number;
828
+ max: number;
829
+ retry_after_s?: number | undefined;
830
+ } | undefined;
831
+ budget?: {
832
+ max_tokens?: number | undefined;
833
+ max_requests?: number | undefined;
834
+ } | undefined;
835
+ }, {
836
+ rate_limit?: {
837
+ window_s: number;
838
+ max: number;
839
+ retry_after_s?: number | undefined;
840
+ } | undefined;
841
+ budget?: {
842
+ max_tokens?: number | undefined;
843
+ max_requests?: number | undefined;
844
+ } | undefined;
845
+ }>>;
846
+ /** Whether receipts are required for allowed requests */
847
+ receipts: z.ZodEnum<["required", "optional", "omit"]>;
848
+ }, "strict", z.ZodTypeAny, {
849
+ id: "strict" | "balanced" | "open";
850
+ name: string;
851
+ description: string;
852
+ undeclared_decision: "allow" | "deny" | "review";
853
+ unknown_decision: "allow" | "deny" | "review";
854
+ purpose_reason: "allowed" | "constrained" | "denied" | "downgraded" | "undeclared_default" | "unknown_preserved";
855
+ receipts: "required" | "omit" | "optional";
856
+ default_constraints?: {
857
+ rate_limit?: {
858
+ window_s: number;
859
+ max: number;
860
+ retry_after_s?: number | undefined;
861
+ } | undefined;
862
+ budget?: {
863
+ max_tokens?: number | undefined;
864
+ max_requests?: number | undefined;
865
+ } | undefined;
866
+ } | undefined;
867
+ }, {
868
+ id: "strict" | "balanced" | "open";
869
+ name: string;
870
+ description: string;
871
+ undeclared_decision: "allow" | "deny" | "review";
872
+ unknown_decision: "allow" | "deny" | "review";
873
+ purpose_reason: "allowed" | "constrained" | "denied" | "downgraded" | "undeclared_default" | "unknown_preserved";
874
+ receipts: "required" | "omit" | "optional";
875
+ default_constraints?: {
876
+ rate_limit?: {
877
+ window_s: number;
878
+ max: number;
879
+ retry_after_s?: number | undefined;
880
+ } | undefined;
881
+ budget?: {
882
+ max_tokens?: number | undefined;
883
+ max_requests?: number | undefined;
884
+ } | undefined;
885
+ } | undefined;
886
+ }>;
887
+ export type EnforcementProfile = z.infer<typeof EnforcementProfileSchema>;
276
888
  //# sourceMappingURL=types.d.ts.map