@grwnd/pi-governance 3.0.2 → 3.1.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/index.d.cts CHANGED
@@ -13,6 +13,26 @@ declare const AuthConfig: _sinclair_typebox.TObject<{
13
13
  }>>;
14
14
  }>;
15
15
  type AuthConfigType = Static<typeof AuthConfig>;
16
+ declare const DependencyGuardianConfig$1: _sinclair_typebox.TObject<{
17
+ enabled: _sinclair_typebox.TBoolean;
18
+ checks: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
19
+ existence: _sinclair_typebox.TBoolean;
20
+ reputation: _sinclair_typebox.TBoolean;
21
+ typosquatting: _sinclair_typebox.TBoolean;
22
+ install_scripts: _sinclair_typebox.TBoolean;
23
+ vulnerabilities: _sinclair_typebox.TBoolean;
24
+ }>>;
25
+ risk_thresholds: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
26
+ min_age_days: _sinclair_typebox.TNumber;
27
+ min_weekly_downloads: _sinclair_typebox.TNumber;
28
+ }>>;
29
+ on_risk: _sinclair_typebox.TOptional<_sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"escalate">, _sinclair_typebox.TLiteral<"block">, _sinclair_typebox.TLiteral<"audit">]>>;
30
+ allowlist: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
31
+ blocklist: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
32
+ blocklist_patterns: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
33
+ custom_registry_bypass: _sinclair_typebox.TBoolean;
34
+ }>;
35
+ type DependencyGuardianConfigType = Static<typeof DependencyGuardianConfig$1>;
16
36
  declare const GovernanceConfigSchema: _sinclair_typebox.TObject<{
17
37
  auth: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
18
38
  provider: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"env">, _sinclair_typebox.TLiteral<"local">, _sinclair_typebox.TLiteral<"oidc">]>;
@@ -89,6 +109,25 @@ declare const GovernanceConfigSchema: _sinclair_typebox.TObject<{
89
109
  on_output: _sinclair_typebox.TOptional<_sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"audit">, _sinclair_typebox.TLiteral<"mask">, _sinclair_typebox.TLiteral<"block">]>>;
90
110
  }>>>;
91
111
  }>>;
112
+ dependency_guardian: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
113
+ enabled: _sinclair_typebox.TBoolean;
114
+ checks: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
115
+ existence: _sinclair_typebox.TBoolean;
116
+ reputation: _sinclair_typebox.TBoolean;
117
+ typosquatting: _sinclair_typebox.TBoolean;
118
+ install_scripts: _sinclair_typebox.TBoolean;
119
+ vulnerabilities: _sinclair_typebox.TBoolean;
120
+ }>>;
121
+ risk_thresholds: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
122
+ min_age_days: _sinclair_typebox.TNumber;
123
+ min_weekly_downloads: _sinclair_typebox.TNumber;
124
+ }>>;
125
+ on_risk: _sinclair_typebox.TOptional<_sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"escalate">, _sinclair_typebox.TLiteral<"block">, _sinclair_typebox.TLiteral<"audit">]>>;
126
+ allowlist: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
127
+ blocklist: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
128
+ blocklist_patterns: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
129
+ custom_registry_bypass: _sinclair_typebox.TBoolean;
130
+ }>>;
92
131
  org_units: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TObject<{
93
132
  hitl: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
94
133
  default_mode: _sinclair_typebox.TOptional<_sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"autonomous">, _sinclair_typebox.TLiteral<"supervised">, _sinclair_typebox.TLiteral<"dry_run">]>>;
@@ -340,6 +379,171 @@ declare class DlpMasker {
340
379
  maskText(text: string, matches: DlpMatch[]): string;
341
380
  }
342
381
 
382
+ /**
383
+ * Extracts package names from shell install commands.
384
+ *
385
+ * Supports npm, yarn, pnpm, pip, and cargo.
386
+ */
387
+ type Ecosystem = 'npm' | 'pypi' | 'crates.io';
388
+ type PackageManager = 'npm' | 'yarn' | 'pnpm' | 'pip' | 'cargo';
389
+ interface ParsedPackage {
390
+ name: string;
391
+ version?: string;
392
+ ecosystem: Ecosystem;
393
+ }
394
+ interface ParsedInstall {
395
+ manager: PackageManager;
396
+ packages: ParsedPackage[];
397
+ flags: string[];
398
+ raw: string;
399
+ isLockfileInstall: boolean;
400
+ usesCustomRegistry: boolean;
401
+ }
402
+ /**
403
+ * Attempt to parse an install command and extract package names.
404
+ * Returns undefined if the command is not a recognized install command.
405
+ */
406
+ declare function parseInstallCommand(command: string): ParsedInstall | undefined;
407
+
408
+ /**
409
+ * Registry clients for npm and PyPI.
410
+ *
411
+ * Uses built-in fetch() (Node 22+). Zero dependencies.
412
+ * All endpoints are free and require no authentication.
413
+ */
414
+
415
+ interface RegistryMetadata {
416
+ name: string;
417
+ ecosystem: Ecosystem;
418
+ exists: boolean;
419
+ createdAt?: Date;
420
+ modifiedAt?: Date;
421
+ latestVersion?: string;
422
+ weeklyDownloads?: number;
423
+ maintainerCount?: number;
424
+ hasRepository: boolean;
425
+ hasReadme: boolean;
426
+ hasInstallScripts: boolean;
427
+ description?: string;
428
+ license?: string;
429
+ }
430
+ declare function fetchRegistryMetadata(name: string, ecosystem: Ecosystem): Promise<RegistryMetadata>;
431
+
432
+ /**
433
+ * OSV.dev vulnerability database integration.
434
+ *
435
+ * Free, no auth, supports all major ecosystems.
436
+ * https://osv.dev
437
+ */
438
+
439
+ interface VulnEntry {
440
+ id: string;
441
+ summary: string;
442
+ severity: 'low' | 'medium' | 'high' | 'critical';
443
+ fixedIn?: string;
444
+ aliases: string[];
445
+ }
446
+ interface VulnerabilityResult {
447
+ package: string;
448
+ ecosystem: Ecosystem;
449
+ vulnerabilities: VulnEntry[];
450
+ error?: string;
451
+ }
452
+ /**
453
+ * Query OSV.dev for vulnerabilities affecting a single package.
454
+ */
455
+ declare function queryVulnerabilities(name: string, ecosystem: Ecosystem, version?: string): Promise<VulnerabilityResult>;
456
+ /**
457
+ * Batch query OSV.dev for multiple packages at once.
458
+ */
459
+ declare function queryVulnerabilitiesBatch(packages: Array<{
460
+ name: string;
461
+ ecosystem: Ecosystem;
462
+ version?: string;
463
+ }>): Promise<VulnerabilityResult[]>;
464
+
465
+ /**
466
+ * Levenshtein distance and typosquat detection.
467
+ *
468
+ * Single-row Wagner-Fischer: O(n*m) time, O(min(n,m)) space.
469
+ * Zero dependencies.
470
+ */
471
+ declare function levenshteinDistance(a: string, b: string): number;
472
+ declare function normalizedSimilarity(a: string, b: string): number;
473
+ interface TyposquatMatch {
474
+ target: string;
475
+ distance: number;
476
+ similarity: number;
477
+ }
478
+ /**
479
+ * Check a package name against a corpus of known-good names.
480
+ * Returns the closest match if it looks like a typosquat.
481
+ */
482
+ declare function detectTyposquat(name: string, corpus: string[]): TyposquatMatch | undefined;
483
+
484
+ /**
485
+ * Risk scoring engine for dependency validation.
486
+ *
487
+ * Computes a risk report for a single package based on registry metadata,
488
+ * vulnerability data, and typosquat analysis.
489
+ */
490
+
491
+ type RiskSeverity = 'info' | 'low' | 'medium' | 'high' | 'critical';
492
+ type RiskRecommendation = 'allow' | 'escalate' | 'block';
493
+ interface RiskSignal {
494
+ name: string;
495
+ severity: RiskSeverity;
496
+ detail: string;
497
+ }
498
+ interface RiskReport {
499
+ package: string;
500
+ ecosystem: string;
501
+ overallRisk: RiskSeverity;
502
+ signals: RiskSignal[];
503
+ vulnerabilities: VulnEntry[];
504
+ recommendation: RiskRecommendation;
505
+ metadata: RegistryMetadata;
506
+ }
507
+
508
+ /**
509
+ * Dependency Guardian — orchestrator module.
510
+ *
511
+ * Parses install commands, runs all checks, and returns a risk report.
512
+ */
513
+
514
+ interface DependencyGuardianConfig {
515
+ enabled: boolean;
516
+ checks: {
517
+ existence: boolean;
518
+ reputation: boolean;
519
+ typosquatting: boolean;
520
+ install_scripts: boolean;
521
+ vulnerabilities: boolean;
522
+ };
523
+ risk_thresholds: {
524
+ min_age_days: number;
525
+ min_weekly_downloads: number;
526
+ };
527
+ on_risk: 'escalate' | 'block' | 'audit';
528
+ allowlist: string[];
529
+ blocklist: string[];
530
+ blocklist_patterns: string[];
531
+ custom_registry_bypass: boolean;
532
+ }
533
+ interface GuardianResult {
534
+ command: string;
535
+ packages: RiskReport[];
536
+ overallRecommendation: RiskRecommendation;
537
+ summary: string;
538
+ auditMetadata: Record<string, unknown>;
539
+ skipped: boolean;
540
+ skipReason?: string;
541
+ }
542
+ /**
543
+ * Evaluate an install command and return a risk report for all packages.
544
+ */
545
+ declare function evaluateInstall(command: string, config?: DependencyGuardianConfig): Promise<GuardianResult>;
546
+
343
547
  /**
344
548
  * Tracks tool invocation count as a proxy for token budget.
345
549
  * The budget value represents max invocations per session; -1 means unlimited.
@@ -402,7 +606,7 @@ interface AuditSink {
402
606
  flush(): Promise<void>;
403
607
  }
404
608
 
405
- type AuditEventType = 'session_start' | 'session_end' | 'tool_allowed' | 'tool_denied' | 'tool_dry_run' | 'tool_result' | 'bash_denied' | 'path_denied' | 'approval_requested' | 'approval_granted' | 'approval_denied' | 'budget_exceeded' | 'config_reloaded' | 'dlp_blocked' | 'dlp_detected' | 'dlp_masked' | 'config_tampered';
609
+ type AuditEventType = 'session_start' | 'session_end' | 'tool_allowed' | 'tool_denied' | 'tool_dry_run' | 'tool_result' | 'bash_denied' | 'path_denied' | 'approval_requested' | 'approval_granted' | 'approval_denied' | 'budget_exceeded' | 'config_reloaded' | 'dlp_blocked' | 'dlp_detected' | 'dlp_masked' | 'config_tampered' | 'dep_allowed' | 'dep_blocked' | 'dep_escalated' | 'dep_approved' | 'dep_rejected';
406
610
  interface AuditRecord {
407
611
  id: string;
408
612
  timestamp: string;
@@ -524,4 +728,4 @@ declare function startWizardServer(options: WizardServerOptions): Promise<{
524
728
  close: () => void;
525
729
  }>;
526
730
 
527
- export { type ApprovalFlow, type ApprovalResult, type AuditEventType, AuditLogger, type AuditRecord, type AuditSink, type BashClassification, BashClassifier, type BashOverrides, BudgetTracker, CliApprover, ConfigValidationError, ConfigWatcher, type ConfirmUI, DANGEROUS_PATTERNS, PII_PATTERNS as DLP_PII_PATTERNS, SECRET_PATTERNS as DLP_SECRET_PATTERNS, type DlpAction, type DlpAllowlistEntry, type DlpCategory, type DlpCustomPattern, DlpMasker, type DlpMatch, type DlpPatternDef, type DlpScanResult, DlpScanner, type DlpScannerConfig, type DlpSeverity, EnvIdentityProvider, type ExecutionMode, type FactStore, type GovernanceConfig, type GovernanceToolCall, type HitlConfig, IdentityChain, type IdentityProvider, JsonlAuditSink, LocalIdentityProvider, type MaskingConfig, OsoMemoryFactStore, type PathOperation, type PolicyDecision, type PolicyEngine, type Relation, type ResolvedIdentity, type RoleBinding, SAFE_PATTERNS, TemplateSelector, type TemplateSelectorConfig, WebhookApprover, WebhookAuditSink, type WizardServerOptions, YamlFactStore, YamlPolicyEngine, type YamlRole, type YamlRules, compareSeverity, createApprovalFlow, createIdentityChain, createPolicyEngine, loadConfig, render as renderTemplate, startWizardServer };
731
+ export { type ApprovalFlow, type ApprovalResult, type AuditEventType, AuditLogger, type AuditRecord, type AuditSink, type BashClassification, BashClassifier, type BashOverrides, BudgetTracker, CliApprover, ConfigValidationError, ConfigWatcher, type ConfirmUI, DANGEROUS_PATTERNS, PII_PATTERNS as DLP_PII_PATTERNS, SECRET_PATTERNS as DLP_SECRET_PATTERNS, type DependencyGuardianConfig, type DependencyGuardianConfigType, type DlpAction, type DlpAllowlistEntry, type DlpCategory, type DlpCustomPattern, DlpMasker, type DlpMatch, type DlpPatternDef, type DlpScanResult, DlpScanner, type DlpScannerConfig, type DlpSeverity, EnvIdentityProvider, type ExecutionMode, type FactStore, type GovernanceConfig, type GovernanceToolCall, type GuardianResult, type HitlConfig, IdentityChain, type IdentityProvider, JsonlAuditSink, LocalIdentityProvider, type MaskingConfig, OsoMemoryFactStore, type ParsedInstall, type ParsedPackage, type PathOperation, type PolicyDecision, type PolicyEngine, type RegistryMetadata, type Relation, type ResolvedIdentity, type RoleBinding, SAFE_PATTERNS, TemplateSelector, type TemplateSelectorConfig, type VulnEntry, type VulnerabilityResult, WebhookApprover, WebhookAuditSink, type WizardServerOptions, YamlFactStore, YamlPolicyEngine, type YamlRole, type YamlRules, compareSeverity, createApprovalFlow, createIdentityChain, createPolicyEngine, detectTyposquat, evaluateInstall, fetchRegistryMetadata, levenshteinDistance, loadConfig, normalizedSimilarity, parseInstallCommand, queryVulnerabilities, queryVulnerabilitiesBatch, render as renderTemplate, startWizardServer };
package/dist/index.d.ts CHANGED
@@ -13,6 +13,26 @@ declare const AuthConfig: _sinclair_typebox.TObject<{
13
13
  }>>;
14
14
  }>;
15
15
  type AuthConfigType = Static<typeof AuthConfig>;
16
+ declare const DependencyGuardianConfig$1: _sinclair_typebox.TObject<{
17
+ enabled: _sinclair_typebox.TBoolean;
18
+ checks: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
19
+ existence: _sinclair_typebox.TBoolean;
20
+ reputation: _sinclair_typebox.TBoolean;
21
+ typosquatting: _sinclair_typebox.TBoolean;
22
+ install_scripts: _sinclair_typebox.TBoolean;
23
+ vulnerabilities: _sinclair_typebox.TBoolean;
24
+ }>>;
25
+ risk_thresholds: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
26
+ min_age_days: _sinclair_typebox.TNumber;
27
+ min_weekly_downloads: _sinclair_typebox.TNumber;
28
+ }>>;
29
+ on_risk: _sinclair_typebox.TOptional<_sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"escalate">, _sinclair_typebox.TLiteral<"block">, _sinclair_typebox.TLiteral<"audit">]>>;
30
+ allowlist: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
31
+ blocklist: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
32
+ blocklist_patterns: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
33
+ custom_registry_bypass: _sinclair_typebox.TBoolean;
34
+ }>;
35
+ type DependencyGuardianConfigType = Static<typeof DependencyGuardianConfig$1>;
16
36
  declare const GovernanceConfigSchema: _sinclair_typebox.TObject<{
17
37
  auth: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
18
38
  provider: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"env">, _sinclair_typebox.TLiteral<"local">, _sinclair_typebox.TLiteral<"oidc">]>;
@@ -89,6 +109,25 @@ declare const GovernanceConfigSchema: _sinclair_typebox.TObject<{
89
109
  on_output: _sinclair_typebox.TOptional<_sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"audit">, _sinclair_typebox.TLiteral<"mask">, _sinclair_typebox.TLiteral<"block">]>>;
90
110
  }>>>;
91
111
  }>>;
112
+ dependency_guardian: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
113
+ enabled: _sinclair_typebox.TBoolean;
114
+ checks: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
115
+ existence: _sinclair_typebox.TBoolean;
116
+ reputation: _sinclair_typebox.TBoolean;
117
+ typosquatting: _sinclair_typebox.TBoolean;
118
+ install_scripts: _sinclair_typebox.TBoolean;
119
+ vulnerabilities: _sinclair_typebox.TBoolean;
120
+ }>>;
121
+ risk_thresholds: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
122
+ min_age_days: _sinclair_typebox.TNumber;
123
+ min_weekly_downloads: _sinclair_typebox.TNumber;
124
+ }>>;
125
+ on_risk: _sinclair_typebox.TOptional<_sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"escalate">, _sinclair_typebox.TLiteral<"block">, _sinclair_typebox.TLiteral<"audit">]>>;
126
+ allowlist: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
127
+ blocklist: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
128
+ blocklist_patterns: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
129
+ custom_registry_bypass: _sinclair_typebox.TBoolean;
130
+ }>>;
92
131
  org_units: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TObject<{
93
132
  hitl: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
94
133
  default_mode: _sinclair_typebox.TOptional<_sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"autonomous">, _sinclair_typebox.TLiteral<"supervised">, _sinclair_typebox.TLiteral<"dry_run">]>>;
@@ -340,6 +379,171 @@ declare class DlpMasker {
340
379
  maskText(text: string, matches: DlpMatch[]): string;
341
380
  }
342
381
 
382
+ /**
383
+ * Extracts package names from shell install commands.
384
+ *
385
+ * Supports npm, yarn, pnpm, pip, and cargo.
386
+ */
387
+ type Ecosystem = 'npm' | 'pypi' | 'crates.io';
388
+ type PackageManager = 'npm' | 'yarn' | 'pnpm' | 'pip' | 'cargo';
389
+ interface ParsedPackage {
390
+ name: string;
391
+ version?: string;
392
+ ecosystem: Ecosystem;
393
+ }
394
+ interface ParsedInstall {
395
+ manager: PackageManager;
396
+ packages: ParsedPackage[];
397
+ flags: string[];
398
+ raw: string;
399
+ isLockfileInstall: boolean;
400
+ usesCustomRegistry: boolean;
401
+ }
402
+ /**
403
+ * Attempt to parse an install command and extract package names.
404
+ * Returns undefined if the command is not a recognized install command.
405
+ */
406
+ declare function parseInstallCommand(command: string): ParsedInstall | undefined;
407
+
408
+ /**
409
+ * Registry clients for npm and PyPI.
410
+ *
411
+ * Uses built-in fetch() (Node 22+). Zero dependencies.
412
+ * All endpoints are free and require no authentication.
413
+ */
414
+
415
+ interface RegistryMetadata {
416
+ name: string;
417
+ ecosystem: Ecosystem;
418
+ exists: boolean;
419
+ createdAt?: Date;
420
+ modifiedAt?: Date;
421
+ latestVersion?: string;
422
+ weeklyDownloads?: number;
423
+ maintainerCount?: number;
424
+ hasRepository: boolean;
425
+ hasReadme: boolean;
426
+ hasInstallScripts: boolean;
427
+ description?: string;
428
+ license?: string;
429
+ }
430
+ declare function fetchRegistryMetadata(name: string, ecosystem: Ecosystem): Promise<RegistryMetadata>;
431
+
432
+ /**
433
+ * OSV.dev vulnerability database integration.
434
+ *
435
+ * Free, no auth, supports all major ecosystems.
436
+ * https://osv.dev
437
+ */
438
+
439
+ interface VulnEntry {
440
+ id: string;
441
+ summary: string;
442
+ severity: 'low' | 'medium' | 'high' | 'critical';
443
+ fixedIn?: string;
444
+ aliases: string[];
445
+ }
446
+ interface VulnerabilityResult {
447
+ package: string;
448
+ ecosystem: Ecosystem;
449
+ vulnerabilities: VulnEntry[];
450
+ error?: string;
451
+ }
452
+ /**
453
+ * Query OSV.dev for vulnerabilities affecting a single package.
454
+ */
455
+ declare function queryVulnerabilities(name: string, ecosystem: Ecosystem, version?: string): Promise<VulnerabilityResult>;
456
+ /**
457
+ * Batch query OSV.dev for multiple packages at once.
458
+ */
459
+ declare function queryVulnerabilitiesBatch(packages: Array<{
460
+ name: string;
461
+ ecosystem: Ecosystem;
462
+ version?: string;
463
+ }>): Promise<VulnerabilityResult[]>;
464
+
465
+ /**
466
+ * Levenshtein distance and typosquat detection.
467
+ *
468
+ * Single-row Wagner-Fischer: O(n*m) time, O(min(n,m)) space.
469
+ * Zero dependencies.
470
+ */
471
+ declare function levenshteinDistance(a: string, b: string): number;
472
+ declare function normalizedSimilarity(a: string, b: string): number;
473
+ interface TyposquatMatch {
474
+ target: string;
475
+ distance: number;
476
+ similarity: number;
477
+ }
478
+ /**
479
+ * Check a package name against a corpus of known-good names.
480
+ * Returns the closest match if it looks like a typosquat.
481
+ */
482
+ declare function detectTyposquat(name: string, corpus: string[]): TyposquatMatch | undefined;
483
+
484
+ /**
485
+ * Risk scoring engine for dependency validation.
486
+ *
487
+ * Computes a risk report for a single package based on registry metadata,
488
+ * vulnerability data, and typosquat analysis.
489
+ */
490
+
491
+ type RiskSeverity = 'info' | 'low' | 'medium' | 'high' | 'critical';
492
+ type RiskRecommendation = 'allow' | 'escalate' | 'block';
493
+ interface RiskSignal {
494
+ name: string;
495
+ severity: RiskSeverity;
496
+ detail: string;
497
+ }
498
+ interface RiskReport {
499
+ package: string;
500
+ ecosystem: string;
501
+ overallRisk: RiskSeverity;
502
+ signals: RiskSignal[];
503
+ vulnerabilities: VulnEntry[];
504
+ recommendation: RiskRecommendation;
505
+ metadata: RegistryMetadata;
506
+ }
507
+
508
+ /**
509
+ * Dependency Guardian — orchestrator module.
510
+ *
511
+ * Parses install commands, runs all checks, and returns a risk report.
512
+ */
513
+
514
+ interface DependencyGuardianConfig {
515
+ enabled: boolean;
516
+ checks: {
517
+ existence: boolean;
518
+ reputation: boolean;
519
+ typosquatting: boolean;
520
+ install_scripts: boolean;
521
+ vulnerabilities: boolean;
522
+ };
523
+ risk_thresholds: {
524
+ min_age_days: number;
525
+ min_weekly_downloads: number;
526
+ };
527
+ on_risk: 'escalate' | 'block' | 'audit';
528
+ allowlist: string[];
529
+ blocklist: string[];
530
+ blocklist_patterns: string[];
531
+ custom_registry_bypass: boolean;
532
+ }
533
+ interface GuardianResult {
534
+ command: string;
535
+ packages: RiskReport[];
536
+ overallRecommendation: RiskRecommendation;
537
+ summary: string;
538
+ auditMetadata: Record<string, unknown>;
539
+ skipped: boolean;
540
+ skipReason?: string;
541
+ }
542
+ /**
543
+ * Evaluate an install command and return a risk report for all packages.
544
+ */
545
+ declare function evaluateInstall(command: string, config?: DependencyGuardianConfig): Promise<GuardianResult>;
546
+
343
547
  /**
344
548
  * Tracks tool invocation count as a proxy for token budget.
345
549
  * The budget value represents max invocations per session; -1 means unlimited.
@@ -402,7 +606,7 @@ interface AuditSink {
402
606
  flush(): Promise<void>;
403
607
  }
404
608
 
405
- type AuditEventType = 'session_start' | 'session_end' | 'tool_allowed' | 'tool_denied' | 'tool_dry_run' | 'tool_result' | 'bash_denied' | 'path_denied' | 'approval_requested' | 'approval_granted' | 'approval_denied' | 'budget_exceeded' | 'config_reloaded' | 'dlp_blocked' | 'dlp_detected' | 'dlp_masked' | 'config_tampered';
609
+ type AuditEventType = 'session_start' | 'session_end' | 'tool_allowed' | 'tool_denied' | 'tool_dry_run' | 'tool_result' | 'bash_denied' | 'path_denied' | 'approval_requested' | 'approval_granted' | 'approval_denied' | 'budget_exceeded' | 'config_reloaded' | 'dlp_blocked' | 'dlp_detected' | 'dlp_masked' | 'config_tampered' | 'dep_allowed' | 'dep_blocked' | 'dep_escalated' | 'dep_approved' | 'dep_rejected';
406
610
  interface AuditRecord {
407
611
  id: string;
408
612
  timestamp: string;
@@ -524,4 +728,4 @@ declare function startWizardServer(options: WizardServerOptions): Promise<{
524
728
  close: () => void;
525
729
  }>;
526
730
 
527
- export { type ApprovalFlow, type ApprovalResult, type AuditEventType, AuditLogger, type AuditRecord, type AuditSink, type BashClassification, BashClassifier, type BashOverrides, BudgetTracker, CliApprover, ConfigValidationError, ConfigWatcher, type ConfirmUI, DANGEROUS_PATTERNS, PII_PATTERNS as DLP_PII_PATTERNS, SECRET_PATTERNS as DLP_SECRET_PATTERNS, type DlpAction, type DlpAllowlistEntry, type DlpCategory, type DlpCustomPattern, DlpMasker, type DlpMatch, type DlpPatternDef, type DlpScanResult, DlpScanner, type DlpScannerConfig, type DlpSeverity, EnvIdentityProvider, type ExecutionMode, type FactStore, type GovernanceConfig, type GovernanceToolCall, type HitlConfig, IdentityChain, type IdentityProvider, JsonlAuditSink, LocalIdentityProvider, type MaskingConfig, OsoMemoryFactStore, type PathOperation, type PolicyDecision, type PolicyEngine, type Relation, type ResolvedIdentity, type RoleBinding, SAFE_PATTERNS, TemplateSelector, type TemplateSelectorConfig, WebhookApprover, WebhookAuditSink, type WizardServerOptions, YamlFactStore, YamlPolicyEngine, type YamlRole, type YamlRules, compareSeverity, createApprovalFlow, createIdentityChain, createPolicyEngine, loadConfig, render as renderTemplate, startWizardServer };
731
+ export { type ApprovalFlow, type ApprovalResult, type AuditEventType, AuditLogger, type AuditRecord, type AuditSink, type BashClassification, BashClassifier, type BashOverrides, BudgetTracker, CliApprover, ConfigValidationError, ConfigWatcher, type ConfirmUI, DANGEROUS_PATTERNS, PII_PATTERNS as DLP_PII_PATTERNS, SECRET_PATTERNS as DLP_SECRET_PATTERNS, type DependencyGuardianConfig, type DependencyGuardianConfigType, type DlpAction, type DlpAllowlistEntry, type DlpCategory, type DlpCustomPattern, DlpMasker, type DlpMatch, type DlpPatternDef, type DlpScanResult, DlpScanner, type DlpScannerConfig, type DlpSeverity, EnvIdentityProvider, type ExecutionMode, type FactStore, type GovernanceConfig, type GovernanceToolCall, type GuardianResult, type HitlConfig, IdentityChain, type IdentityProvider, JsonlAuditSink, LocalIdentityProvider, type MaskingConfig, OsoMemoryFactStore, type ParsedInstall, type ParsedPackage, type PathOperation, type PolicyDecision, type PolicyEngine, type RegistryMetadata, type Relation, type ResolvedIdentity, type RoleBinding, SAFE_PATTERNS, TemplateSelector, type TemplateSelectorConfig, type VulnEntry, type VulnerabilityResult, WebhookApprover, WebhookAuditSink, type WizardServerOptions, YamlFactStore, YamlPolicyEngine, type YamlRole, type YamlRules, compareSeverity, createApprovalFlow, createIdentityChain, createPolicyEngine, detectTyposquat, evaluateInstall, fetchRegistryMetadata, levenshteinDistance, loadConfig, normalizedSimilarity, parseInstallCommand, queryVulnerabilities, queryVulnerabilitiesBatch, render as renderTemplate, startWizardServer };