sovr-mcp-proxy 7.0.0 → 7.2.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/auditDashboard.d.mts +208 -0
- package/dist/auditDashboard.d.ts +208 -0
- package/dist/auditDashboard.js +398 -0
- package/dist/auditDashboard.mjs +370 -0
- package/dist/mcpProxyInterceptor.d.mts +256 -0
- package/dist/mcpProxyInterceptor.d.ts +256 -0
- package/dist/mcpProxyInterceptor.js +579 -0
- package/dist/mcpProxyInterceptor.mjs +552 -0
- package/dist/semanticAnalyzer.d.mts +247 -0
- package/dist/semanticAnalyzer.d.ts +247 -0
- package/dist/semanticAnalyzer.js +911 -0
- package/dist/semanticAnalyzer.mjs +874 -0
- package/dist/teamPolicyManager.d.mts +202 -0
- package/dist/teamPolicyManager.d.ts +202 -0
- package/dist/teamPolicyManager.js +529 -0
- package/dist/teamPolicyManager.mjs +502 -0
- package/package.json +2 -2
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SOVR Team Policy Manager — Multi-User Policy Distribution & Role Inheritance
|
|
3
|
+
*
|
|
4
|
+
* P2-2: Enterprise-grade policy management for teams.
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - Role-based policy inheritance (admin > lead > developer > viewer)
|
|
8
|
+
* - YAML/JSON policy DSL with validation
|
|
9
|
+
* - Policy versioning with rollback
|
|
10
|
+
* - Per-user overrides with audit trail
|
|
11
|
+
* - Policy distribution to team members
|
|
12
|
+
* - Canary deployment (gradual policy rollout)
|
|
13
|
+
* - Conflict resolution (most restrictive wins)
|
|
14
|
+
*/
|
|
15
|
+
type RoleLevel = 'admin' | 'lead' | 'developer' | 'viewer' | 'custom';
|
|
16
|
+
interface TeamMember {
|
|
17
|
+
/** Unique member ID */
|
|
18
|
+
id: string;
|
|
19
|
+
/** Display name */
|
|
20
|
+
name: string;
|
|
21
|
+
/** Role level */
|
|
22
|
+
role: RoleLevel;
|
|
23
|
+
/** Custom policy overrides */
|
|
24
|
+
overrides?: PolicyOverride[];
|
|
25
|
+
/** Is member active */
|
|
26
|
+
active: boolean;
|
|
27
|
+
/** Canary group (for gradual rollout) */
|
|
28
|
+
canaryGroup?: string;
|
|
29
|
+
/** Custom tags for filtering */
|
|
30
|
+
tags?: string[];
|
|
31
|
+
}
|
|
32
|
+
interface PolicyRule {
|
|
33
|
+
/** Rule ID */
|
|
34
|
+
id: string;
|
|
35
|
+
/** Human-readable name */
|
|
36
|
+
name: string;
|
|
37
|
+
/** Action type */
|
|
38
|
+
action: 'allow' | 'block' | 'require-approval' | 'transform' | 'log-only';
|
|
39
|
+
/** Target tools (glob patterns) */
|
|
40
|
+
tools: string[];
|
|
41
|
+
/** Conditions (all must match) */
|
|
42
|
+
conditions?: PolicyCondition[];
|
|
43
|
+
/** Priority (higher = evaluated first) */
|
|
44
|
+
priority: number;
|
|
45
|
+
/** Is this rule enabled */
|
|
46
|
+
enabled: boolean;
|
|
47
|
+
/** Description */
|
|
48
|
+
description?: string;
|
|
49
|
+
}
|
|
50
|
+
interface PolicyCondition {
|
|
51
|
+
/** Field to check */
|
|
52
|
+
field: 'risk_score' | 'tool_name' | 'argument' | 'time_of_day' | 'day_of_week' | 'session_age';
|
|
53
|
+
/** Operator */
|
|
54
|
+
operator: 'eq' | 'neq' | 'gt' | 'lt' | 'gte' | 'lte' | 'contains' | 'matches' | 'in';
|
|
55
|
+
/** Value to compare */
|
|
56
|
+
value: string | number | string[];
|
|
57
|
+
}
|
|
58
|
+
interface PolicyOverride {
|
|
59
|
+
/** Rule ID to override */
|
|
60
|
+
ruleId: string;
|
|
61
|
+
/** New action */
|
|
62
|
+
action: PolicyRule['action'];
|
|
63
|
+
/** Reason for override */
|
|
64
|
+
reason: string;
|
|
65
|
+
/** Who approved this override */
|
|
66
|
+
approvedBy?: string;
|
|
67
|
+
/** Expiry (ISO timestamp) */
|
|
68
|
+
expiresAt?: string;
|
|
69
|
+
}
|
|
70
|
+
interface PolicyVersion {
|
|
71
|
+
/** Version number */
|
|
72
|
+
version: number;
|
|
73
|
+
/** ISO timestamp */
|
|
74
|
+
createdAt: string;
|
|
75
|
+
/** Who created this version */
|
|
76
|
+
createdBy: string;
|
|
77
|
+
/** Change description */
|
|
78
|
+
description: string;
|
|
79
|
+
/** The rules in this version */
|
|
80
|
+
rules: PolicyRule[];
|
|
81
|
+
/** Role-specific rule sets */
|
|
82
|
+
roleRules: Record<RoleLevel, string[]>;
|
|
83
|
+
/** Is this the active version */
|
|
84
|
+
active: boolean;
|
|
85
|
+
/** Hash for integrity */
|
|
86
|
+
hash: string;
|
|
87
|
+
}
|
|
88
|
+
interface PolicySet {
|
|
89
|
+
/** Policy set name */
|
|
90
|
+
name: string;
|
|
91
|
+
/** Current active version */
|
|
92
|
+
activeVersion: number;
|
|
93
|
+
/** All versions */
|
|
94
|
+
versions: PolicyVersion[];
|
|
95
|
+
/** Team members */
|
|
96
|
+
members: TeamMember[];
|
|
97
|
+
/** Global settings */
|
|
98
|
+
settings: PolicySettings;
|
|
99
|
+
}
|
|
100
|
+
interface PolicySettings {
|
|
101
|
+
/** Default action when no rule matches */
|
|
102
|
+
defaultAction: 'allow' | 'block' | 'require-approval';
|
|
103
|
+
/** Conflict resolution strategy */
|
|
104
|
+
conflictResolution: 'most-restrictive' | 'least-restrictive' | 'priority-based';
|
|
105
|
+
/** Enable canary deployment */
|
|
106
|
+
enableCanary: boolean;
|
|
107
|
+
/** Canary percentage (0-100) */
|
|
108
|
+
canaryPercentage: number;
|
|
109
|
+
/** Require approval for policy changes */
|
|
110
|
+
requireApprovalForChanges: boolean;
|
|
111
|
+
/** Notification webhook URL */
|
|
112
|
+
notificationWebhook?: string;
|
|
113
|
+
}
|
|
114
|
+
interface PolicyEvaluation {
|
|
115
|
+
/** Final decision */
|
|
116
|
+
decision: 'allow' | 'block' | 'require-approval' | 'transform' | 'log-only';
|
|
117
|
+
/** Matched rules */
|
|
118
|
+
matchedRules: Array<{
|
|
119
|
+
ruleId: string;
|
|
120
|
+
ruleName: string;
|
|
121
|
+
action: string;
|
|
122
|
+
}>;
|
|
123
|
+
/** Applied overrides */
|
|
124
|
+
appliedOverrides: PolicyOverride[];
|
|
125
|
+
/** Effective role */
|
|
126
|
+
effectiveRole: RoleLevel;
|
|
127
|
+
/** Policy version used */
|
|
128
|
+
policyVersion: number;
|
|
129
|
+
/** Evaluation duration (ms) */
|
|
130
|
+
durationMs: number;
|
|
131
|
+
}
|
|
132
|
+
declare class TeamPolicyManager {
|
|
133
|
+
private policySet;
|
|
134
|
+
constructor(name: string, settings?: Partial<PolicySettings>);
|
|
135
|
+
/** Add a team member */
|
|
136
|
+
addMember(member: Omit<TeamMember, 'active'>): void;
|
|
137
|
+
/** Update a team member */
|
|
138
|
+
updateMember(id: string, updates: Partial<TeamMember>): void;
|
|
139
|
+
/** Remove a team member (soft delete) */
|
|
140
|
+
deactivateMember(id: string): void;
|
|
141
|
+
/** Get all active members */
|
|
142
|
+
getMembers(): TeamMember[];
|
|
143
|
+
/** Get member by ID */
|
|
144
|
+
getMember(id: string): TeamMember | undefined;
|
|
145
|
+
/** Create a new policy version */
|
|
146
|
+
createVersion(createdBy: string, description: string, rules: PolicyRule[], roleRules?: Record<RoleLevel, string[]>): PolicyVersion;
|
|
147
|
+
/** Rollback to a previous version */
|
|
148
|
+
rollback(targetVersion: number): PolicyVersion;
|
|
149
|
+
/** Get all versions */
|
|
150
|
+
getVersions(): PolicyVersion[];
|
|
151
|
+
/** Get active version */
|
|
152
|
+
getActiveVersion(): PolicyVersion | undefined;
|
|
153
|
+
/** Compare two versions */
|
|
154
|
+
diffVersions(v1: number, v2: number): {
|
|
155
|
+
added: PolicyRule[];
|
|
156
|
+
removed: PolicyRule[];
|
|
157
|
+
modified: Array<{
|
|
158
|
+
ruleId: string;
|
|
159
|
+
changes: string[];
|
|
160
|
+
}>;
|
|
161
|
+
};
|
|
162
|
+
/** Evaluate a tool call against the policy for a specific member */
|
|
163
|
+
evaluate(memberId: string, toolName: string, context: {
|
|
164
|
+
riskScore: number;
|
|
165
|
+
arguments?: Record<string, unknown>;
|
|
166
|
+
}): PolicyEvaluation;
|
|
167
|
+
/** Check if a member should use the canary policy */
|
|
168
|
+
isInCanaryGroup(memberId: string): boolean;
|
|
169
|
+
/** Assign members to canary group */
|
|
170
|
+
assignCanaryGroup(memberIds: string[]): void;
|
|
171
|
+
/** Promote canary to stable (all members get the canary policy) */
|
|
172
|
+
promoteCanary(): void;
|
|
173
|
+
/** Export policy as YAML-compatible object */
|
|
174
|
+
exportPolicy(): object;
|
|
175
|
+
/** Import policy from object */
|
|
176
|
+
importPolicy(data: {
|
|
177
|
+
rules: PolicyRule[];
|
|
178
|
+
roles?: Record<RoleLevel, string[]>;
|
|
179
|
+
settings?: Partial<PolicySettings>;
|
|
180
|
+
members?: Array<Omit<TeamMember, 'active'>>;
|
|
181
|
+
}, importedBy: string): PolicyVersion;
|
|
182
|
+
/** Export as JSON string */
|
|
183
|
+
toJSON(): string;
|
|
184
|
+
get name(): string;
|
|
185
|
+
get settings(): PolicySettings;
|
|
186
|
+
get memberCount(): number;
|
|
187
|
+
get versionCount(): number;
|
|
188
|
+
private flattenDefaultRules;
|
|
189
|
+
private generateRoleRules;
|
|
190
|
+
private getInheritedRuleIds;
|
|
191
|
+
private matchesTool;
|
|
192
|
+
private matchesConditions;
|
|
193
|
+
private evaluateCondition;
|
|
194
|
+
private resolveConflict;
|
|
195
|
+
private computeHash;
|
|
196
|
+
}
|
|
197
|
+
/** Create a team policy manager with defaults */
|
|
198
|
+
declare function createTeamPolicyManager(name: string, settings?: Partial<PolicySettings>): TeamPolicyManager;
|
|
199
|
+
/** Create a strict enterprise policy manager */
|
|
200
|
+
declare function createEnterprisePolicyManager(name: string): TeamPolicyManager;
|
|
201
|
+
|
|
202
|
+
export { type PolicyCondition, type PolicyEvaluation, type PolicyOverride, type PolicyRule, type PolicySet, type PolicySettings, type PolicyVersion, type RoleLevel, type TeamMember, TeamPolicyManager, createEnterprisePolicyManager, createTeamPolicyManager };
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SOVR Team Policy Manager — Multi-User Policy Distribution & Role Inheritance
|
|
3
|
+
*
|
|
4
|
+
* P2-2: Enterprise-grade policy management for teams.
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - Role-based policy inheritance (admin > lead > developer > viewer)
|
|
8
|
+
* - YAML/JSON policy DSL with validation
|
|
9
|
+
* - Policy versioning with rollback
|
|
10
|
+
* - Per-user overrides with audit trail
|
|
11
|
+
* - Policy distribution to team members
|
|
12
|
+
* - Canary deployment (gradual policy rollout)
|
|
13
|
+
* - Conflict resolution (most restrictive wins)
|
|
14
|
+
*/
|
|
15
|
+
type RoleLevel = 'admin' | 'lead' | 'developer' | 'viewer' | 'custom';
|
|
16
|
+
interface TeamMember {
|
|
17
|
+
/** Unique member ID */
|
|
18
|
+
id: string;
|
|
19
|
+
/** Display name */
|
|
20
|
+
name: string;
|
|
21
|
+
/** Role level */
|
|
22
|
+
role: RoleLevel;
|
|
23
|
+
/** Custom policy overrides */
|
|
24
|
+
overrides?: PolicyOverride[];
|
|
25
|
+
/** Is member active */
|
|
26
|
+
active: boolean;
|
|
27
|
+
/** Canary group (for gradual rollout) */
|
|
28
|
+
canaryGroup?: string;
|
|
29
|
+
/** Custom tags for filtering */
|
|
30
|
+
tags?: string[];
|
|
31
|
+
}
|
|
32
|
+
interface PolicyRule {
|
|
33
|
+
/** Rule ID */
|
|
34
|
+
id: string;
|
|
35
|
+
/** Human-readable name */
|
|
36
|
+
name: string;
|
|
37
|
+
/** Action type */
|
|
38
|
+
action: 'allow' | 'block' | 'require-approval' | 'transform' | 'log-only';
|
|
39
|
+
/** Target tools (glob patterns) */
|
|
40
|
+
tools: string[];
|
|
41
|
+
/** Conditions (all must match) */
|
|
42
|
+
conditions?: PolicyCondition[];
|
|
43
|
+
/** Priority (higher = evaluated first) */
|
|
44
|
+
priority: number;
|
|
45
|
+
/** Is this rule enabled */
|
|
46
|
+
enabled: boolean;
|
|
47
|
+
/** Description */
|
|
48
|
+
description?: string;
|
|
49
|
+
}
|
|
50
|
+
interface PolicyCondition {
|
|
51
|
+
/** Field to check */
|
|
52
|
+
field: 'risk_score' | 'tool_name' | 'argument' | 'time_of_day' | 'day_of_week' | 'session_age';
|
|
53
|
+
/** Operator */
|
|
54
|
+
operator: 'eq' | 'neq' | 'gt' | 'lt' | 'gte' | 'lte' | 'contains' | 'matches' | 'in';
|
|
55
|
+
/** Value to compare */
|
|
56
|
+
value: string | number | string[];
|
|
57
|
+
}
|
|
58
|
+
interface PolicyOverride {
|
|
59
|
+
/** Rule ID to override */
|
|
60
|
+
ruleId: string;
|
|
61
|
+
/** New action */
|
|
62
|
+
action: PolicyRule['action'];
|
|
63
|
+
/** Reason for override */
|
|
64
|
+
reason: string;
|
|
65
|
+
/** Who approved this override */
|
|
66
|
+
approvedBy?: string;
|
|
67
|
+
/** Expiry (ISO timestamp) */
|
|
68
|
+
expiresAt?: string;
|
|
69
|
+
}
|
|
70
|
+
interface PolicyVersion {
|
|
71
|
+
/** Version number */
|
|
72
|
+
version: number;
|
|
73
|
+
/** ISO timestamp */
|
|
74
|
+
createdAt: string;
|
|
75
|
+
/** Who created this version */
|
|
76
|
+
createdBy: string;
|
|
77
|
+
/** Change description */
|
|
78
|
+
description: string;
|
|
79
|
+
/** The rules in this version */
|
|
80
|
+
rules: PolicyRule[];
|
|
81
|
+
/** Role-specific rule sets */
|
|
82
|
+
roleRules: Record<RoleLevel, string[]>;
|
|
83
|
+
/** Is this the active version */
|
|
84
|
+
active: boolean;
|
|
85
|
+
/** Hash for integrity */
|
|
86
|
+
hash: string;
|
|
87
|
+
}
|
|
88
|
+
interface PolicySet {
|
|
89
|
+
/** Policy set name */
|
|
90
|
+
name: string;
|
|
91
|
+
/** Current active version */
|
|
92
|
+
activeVersion: number;
|
|
93
|
+
/** All versions */
|
|
94
|
+
versions: PolicyVersion[];
|
|
95
|
+
/** Team members */
|
|
96
|
+
members: TeamMember[];
|
|
97
|
+
/** Global settings */
|
|
98
|
+
settings: PolicySettings;
|
|
99
|
+
}
|
|
100
|
+
interface PolicySettings {
|
|
101
|
+
/** Default action when no rule matches */
|
|
102
|
+
defaultAction: 'allow' | 'block' | 'require-approval';
|
|
103
|
+
/** Conflict resolution strategy */
|
|
104
|
+
conflictResolution: 'most-restrictive' | 'least-restrictive' | 'priority-based';
|
|
105
|
+
/** Enable canary deployment */
|
|
106
|
+
enableCanary: boolean;
|
|
107
|
+
/** Canary percentage (0-100) */
|
|
108
|
+
canaryPercentage: number;
|
|
109
|
+
/** Require approval for policy changes */
|
|
110
|
+
requireApprovalForChanges: boolean;
|
|
111
|
+
/** Notification webhook URL */
|
|
112
|
+
notificationWebhook?: string;
|
|
113
|
+
}
|
|
114
|
+
interface PolicyEvaluation {
|
|
115
|
+
/** Final decision */
|
|
116
|
+
decision: 'allow' | 'block' | 'require-approval' | 'transform' | 'log-only';
|
|
117
|
+
/** Matched rules */
|
|
118
|
+
matchedRules: Array<{
|
|
119
|
+
ruleId: string;
|
|
120
|
+
ruleName: string;
|
|
121
|
+
action: string;
|
|
122
|
+
}>;
|
|
123
|
+
/** Applied overrides */
|
|
124
|
+
appliedOverrides: PolicyOverride[];
|
|
125
|
+
/** Effective role */
|
|
126
|
+
effectiveRole: RoleLevel;
|
|
127
|
+
/** Policy version used */
|
|
128
|
+
policyVersion: number;
|
|
129
|
+
/** Evaluation duration (ms) */
|
|
130
|
+
durationMs: number;
|
|
131
|
+
}
|
|
132
|
+
declare class TeamPolicyManager {
|
|
133
|
+
private policySet;
|
|
134
|
+
constructor(name: string, settings?: Partial<PolicySettings>);
|
|
135
|
+
/** Add a team member */
|
|
136
|
+
addMember(member: Omit<TeamMember, 'active'>): void;
|
|
137
|
+
/** Update a team member */
|
|
138
|
+
updateMember(id: string, updates: Partial<TeamMember>): void;
|
|
139
|
+
/** Remove a team member (soft delete) */
|
|
140
|
+
deactivateMember(id: string): void;
|
|
141
|
+
/** Get all active members */
|
|
142
|
+
getMembers(): TeamMember[];
|
|
143
|
+
/** Get member by ID */
|
|
144
|
+
getMember(id: string): TeamMember | undefined;
|
|
145
|
+
/** Create a new policy version */
|
|
146
|
+
createVersion(createdBy: string, description: string, rules: PolicyRule[], roleRules?: Record<RoleLevel, string[]>): PolicyVersion;
|
|
147
|
+
/** Rollback to a previous version */
|
|
148
|
+
rollback(targetVersion: number): PolicyVersion;
|
|
149
|
+
/** Get all versions */
|
|
150
|
+
getVersions(): PolicyVersion[];
|
|
151
|
+
/** Get active version */
|
|
152
|
+
getActiveVersion(): PolicyVersion | undefined;
|
|
153
|
+
/** Compare two versions */
|
|
154
|
+
diffVersions(v1: number, v2: number): {
|
|
155
|
+
added: PolicyRule[];
|
|
156
|
+
removed: PolicyRule[];
|
|
157
|
+
modified: Array<{
|
|
158
|
+
ruleId: string;
|
|
159
|
+
changes: string[];
|
|
160
|
+
}>;
|
|
161
|
+
};
|
|
162
|
+
/** Evaluate a tool call against the policy for a specific member */
|
|
163
|
+
evaluate(memberId: string, toolName: string, context: {
|
|
164
|
+
riskScore: number;
|
|
165
|
+
arguments?: Record<string, unknown>;
|
|
166
|
+
}): PolicyEvaluation;
|
|
167
|
+
/** Check if a member should use the canary policy */
|
|
168
|
+
isInCanaryGroup(memberId: string): boolean;
|
|
169
|
+
/** Assign members to canary group */
|
|
170
|
+
assignCanaryGroup(memberIds: string[]): void;
|
|
171
|
+
/** Promote canary to stable (all members get the canary policy) */
|
|
172
|
+
promoteCanary(): void;
|
|
173
|
+
/** Export policy as YAML-compatible object */
|
|
174
|
+
exportPolicy(): object;
|
|
175
|
+
/** Import policy from object */
|
|
176
|
+
importPolicy(data: {
|
|
177
|
+
rules: PolicyRule[];
|
|
178
|
+
roles?: Record<RoleLevel, string[]>;
|
|
179
|
+
settings?: Partial<PolicySettings>;
|
|
180
|
+
members?: Array<Omit<TeamMember, 'active'>>;
|
|
181
|
+
}, importedBy: string): PolicyVersion;
|
|
182
|
+
/** Export as JSON string */
|
|
183
|
+
toJSON(): string;
|
|
184
|
+
get name(): string;
|
|
185
|
+
get settings(): PolicySettings;
|
|
186
|
+
get memberCount(): number;
|
|
187
|
+
get versionCount(): number;
|
|
188
|
+
private flattenDefaultRules;
|
|
189
|
+
private generateRoleRules;
|
|
190
|
+
private getInheritedRuleIds;
|
|
191
|
+
private matchesTool;
|
|
192
|
+
private matchesConditions;
|
|
193
|
+
private evaluateCondition;
|
|
194
|
+
private resolveConflict;
|
|
195
|
+
private computeHash;
|
|
196
|
+
}
|
|
197
|
+
/** Create a team policy manager with defaults */
|
|
198
|
+
declare function createTeamPolicyManager(name: string, settings?: Partial<PolicySettings>): TeamPolicyManager;
|
|
199
|
+
/** Create a strict enterprise policy manager */
|
|
200
|
+
declare function createEnterprisePolicyManager(name: string): TeamPolicyManager;
|
|
201
|
+
|
|
202
|
+
export { type PolicyCondition, type PolicyEvaluation, type PolicyOverride, type PolicyRule, type PolicySet, type PolicySettings, type PolicyVersion, type RoleLevel, type TeamMember, TeamPolicyManager, createEnterprisePolicyManager, createTeamPolicyManager };
|