@neuroverseos/governance 0.4.3 → 0.5.1

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 (68) hide show
  1. package/README.md +189 -0
  2. package/dist/adapters/autoresearch.js +2 -2
  3. package/dist/adapters/deep-agents.js +2 -2
  4. package/dist/adapters/express.js +2 -2
  5. package/dist/adapters/github.js +2 -2
  6. package/dist/adapters/index.js +23 -21
  7. package/dist/adapters/langchain.js +2 -2
  8. package/dist/adapters/mentraos.js +8 -6
  9. package/dist/adapters/openai.js +2 -2
  10. package/dist/adapters/openclaw.js +2 -2
  11. package/dist/{add-XSANI3FK.js → add-JP7TC2K3.js} +1 -1
  12. package/dist/admin/index.cjs +2214 -0
  13. package/dist/admin/index.d.cts +362 -0
  14. package/dist/admin/index.d.ts +362 -0
  15. package/dist/admin/index.js +703 -0
  16. package/dist/{build-EGBGZFIJ.js → build-THUEYMVT.js} +5 -5
  17. package/dist/{chunk-YJ34R5NB.js → chunk-5RAQ5DZW.js} +3 -3
  18. package/dist/{chunk-RDA7ISWC.js → chunk-6UPEUMJ2.js} +3 -3
  19. package/dist/chunk-7UU7V3AD.js +447 -0
  20. package/dist/{chunk-ZEIT2QLM.js → chunk-EK77AJAH.js} +22 -4
  21. package/dist/{chunk-3S5AD4AB.js → chunk-FGOSKQDE.js} +3 -3
  22. package/dist/{chunk-GTPV2XGO.js → chunk-GJ6LM4JZ.js} +1 -441
  23. package/dist/chunk-H3REGQRI.js +107 -0
  24. package/dist/{chunk-J2IZBHXJ.js → chunk-LAKUB76X.js} +3 -3
  25. package/dist/{chunk-FVOGUCB6.js → chunk-R23T5SZG.js} +3 -3
  26. package/dist/{chunk-A7SHG75T.js → chunk-RF2L5SYG.js} +3 -3
  27. package/dist/{chunk-QMVQ6KPL.js → chunk-TL4DLMMW.js} +3 -3
  28. package/dist/{chunk-AV7XJJWK.js → chunk-TZBERHFM.js} +3 -3
  29. package/dist/{chunk-3AYKQHYI.js → chunk-UZBW44KD.js} +3 -3
  30. package/dist/{chunk-FS2UUJJO.js → chunk-XPMZB46F.js} +3 -3
  31. package/dist/cli/neuroverse.cjs +962 -284
  32. package/dist/cli/neuroverse.js +46 -22
  33. package/dist/cli/plan.js +1 -1
  34. package/dist/cli/run.cjs +242 -139
  35. package/dist/cli/run.js +23 -3
  36. package/dist/{demo-6OQYWRR6.js → demo-N5K4VXJW.js} +3 -3
  37. package/dist/{derive-7Y7YWVLU.js → derive-5LOMN7GO.js} +4 -4
  38. package/dist/{equity-penalties-NVBAB5WL.js → equity-penalties-PYCJ3Q4U.js} +6 -6
  39. package/dist/{explain-HDFN4ION.js → explain-42TVC3QD.js} +1 -1
  40. package/dist/{guard-6KSCWT2W.js → guard-TPYDFG6V.js} +16 -4
  41. package/dist/{improve-2PWGGO5B.js → improve-HLZGJ54Z.js} +3 -3
  42. package/dist/index.cjs +19 -1
  43. package/dist/index.d.cts +2 -0
  44. package/dist/index.d.ts +2 -0
  45. package/dist/index.js +27 -27
  46. package/dist/keygen-BSZH3NM2.js +77 -0
  47. package/dist/{lens-MHMUDCMQ.js → lens-NFGZHD76.js} +1 -1
  48. package/dist/{mcp-server-TNIWZ7B5.js → mcp-server-5XXNG6VC.js} +2 -2
  49. package/dist/migrate-NH5PVMX4.js +221 -0
  50. package/dist/{playground-3FLDGBET.js → playground-2EU5CFIH.js} +4 -4
  51. package/dist/{redteam-HV6LMKEH.js → redteam-VK6OVHAE.js} +3 -3
  52. package/dist/{session-XZP2754M.js → session-NGA4DUPL.js} +2 -2
  53. package/dist/sign-RRELHKWM.js +11 -0
  54. package/dist/{simulate-VT437EEL.js → simulate-4YNOBMES.js} +1 -1
  55. package/dist/{test-4WTX6RKQ.js → test-HDBPMQTG.js} +3 -3
  56. package/dist/{validate-M52DX22Y.js → validate-6MFQZ2EG.js} +1 -1
  57. package/dist/verify-6AVTWX75.js +151 -0
  58. package/dist/{world-O4HTQPDP.js → world-H5WVURKU.js} +1 -1
  59. package/dist/{world-loader-YTYFOP7D.js → world-loader-J47PCPDZ.js} +1 -1
  60. package/package.json +22 -10
  61. package/dist/{behavioral-SLW7ALEK.js → behavioral-SPWPGYXL.js} +3 -3
  62. package/dist/{bootstrap-2OW5ZLBL.js → bootstrap-IP5QMC3Q.js} +3 -3
  63. package/dist/{chunk-I4RTIMLX.js → chunk-EQUAWNXW.js} +0 -0
  64. package/dist/{chunk-DA5MHFRR.js → chunk-NTHXZAW4.js} +3 -3
  65. package/dist/{chunk-FHXXD2TI.js → chunk-QZ666FCV.js} +6 -6
  66. package/dist/{configure-ai-LL3VAPQW.js → configure-ai-5MP5DWTT.js} +3 -3
  67. package/dist/{decision-flow-3K4D72G4.js → decision-flow-IJPNMVQK.js} +3 -3
  68. /package/dist/{doctor-EC5OYTI3.js → doctor-Q5APJOTS.js} +0 -0
@@ -0,0 +1,362 @@
1
+ import { WorldRoleDefinition, WorldDefinition } from '../types.cjs';
2
+
3
+ /**
4
+ * Admin Layer — Type Definitions
5
+ *
6
+ * Types for enterprise governance management: roles, zones, authority,
7
+ * assignments, and policy simulation.
8
+ *
9
+ * These types sit on top of the core governance engine. The engine handles
10
+ * evaluation. This layer handles who has what role, where zones are,
11
+ * and who can change what.
12
+ */
13
+
14
+ interface OrgRole {
15
+ /** Unique role identifier (e.g., 'floor-associate', 'shift-supervisor') */
16
+ id: string;
17
+ /** Human-readable name */
18
+ name: string;
19
+ /** Description of what this role is for */
20
+ description: string;
21
+ /** The governance role definition fed to the guard engine */
22
+ definition: WorldRoleDefinition;
23
+ /** Who created this role */
24
+ createdBy: string;
25
+ /** When this role was created */
26
+ createdAt: number;
27
+ /** Last modification */
28
+ updatedAt: number;
29
+ /** Whether this role is currently active */
30
+ active: boolean;
31
+ }
32
+ interface RoleAssignment {
33
+ /** Unique assignment ID */
34
+ id: string;
35
+ /** Device or employee identifier */
36
+ deviceId: string;
37
+ /** Optional human name for readability */
38
+ employeeName?: string;
39
+ /** The role assigned */
40
+ roleId: string;
41
+ /** Who made this assignment */
42
+ assignedBy: string;
43
+ /** When assigned */
44
+ assignedAt: number;
45
+ /** Optional expiration (e.g., vendor visit ends at 5pm) */
46
+ expiresAt?: number;
47
+ /** Why this assignment was made */
48
+ reason?: string;
49
+ }
50
+ type ZoneDiscoveryMethod = {
51
+ type: 'ble_beacon';
52
+ beaconId: string;
53
+ } | {
54
+ type: 'geofence';
55
+ lat: number;
56
+ lng: number;
57
+ radiusMeters: number;
58
+ } | {
59
+ type: 'auki_anchor';
60
+ anchorId: string;
61
+ confidence?: number;
62
+ } | {
63
+ type: 'manual';
64
+ label: string;
65
+ };
66
+ type ZonePolicyLevel = 'allow' | 'confirm_each' | 'block';
67
+ interface ZoneRuleSet {
68
+ camera: ZonePolicyLevel;
69
+ microphone: ZonePolicyLevel;
70
+ aiDataSend: ZonePolicyLevel;
71
+ aiActions: ZonePolicyLevel;
72
+ aiRecommendations: ZonePolicyLevel;
73
+ locationSharing: ZonePolicyLevel;
74
+ dataRetention: ZonePolicyLevel;
75
+ bystanderProtection: 'standard' | 'elevated' | 'maximum';
76
+ /** Custom rules targeting specific intents */
77
+ customRules: CustomZoneRule[];
78
+ }
79
+ interface CustomZoneRule {
80
+ /** Rule identifier */
81
+ id: string;
82
+ /** Human description */
83
+ description: string;
84
+ /** Intent pattern to match (e.g., 'ai_auto_purchase', 'camera_*') */
85
+ intentPattern: string;
86
+ /** What to do */
87
+ action: 'allow' | 'block' | 'confirm';
88
+ /** Why this rule exists */
89
+ rationale: string;
90
+ }
91
+ interface OrgZone {
92
+ /** Unique zone identifier */
93
+ id: string;
94
+ /** Human-readable name (e.g., 'Pharmacy', 'Loading Dock') */
95
+ name: string;
96
+ /** Description */
97
+ description: string;
98
+ /** Location/store this zone belongs to */
99
+ locationId: string;
100
+ /** How devices discover this zone */
101
+ discovery: ZoneDiscoveryMethod;
102
+ /** The governance rules for this zone */
103
+ rules: ZoneRuleSet;
104
+ /** Who created this zone */
105
+ createdBy: string;
106
+ /** When created */
107
+ createdAt: number;
108
+ /** Last modification */
109
+ updatedAt: number;
110
+ /** Whether this zone is currently active */
111
+ active: boolean;
112
+ }
113
+ type AuthorityLevel = 'viewer' | 'operator' | 'supervisor' | 'manager' | 'admin';
114
+ interface AuthorityGrant {
115
+ /** The role this authority applies to */
116
+ roleId: string;
117
+ /** What level of admin authority this role carries */
118
+ authorityLevel: AuthorityLevel;
119
+ /** Optional: restrict authority to specific location(s) */
120
+ locationScope?: string[];
121
+ }
122
+ interface AuthorityChain {
123
+ /** Ordered list of authority grants (highest authority first) */
124
+ grants: AuthorityGrant[];
125
+ /** Can emergency override bypass authority chain? Always true for wearer safety. */
126
+ emergencyOverrideAlwaysAllowed: true;
127
+ }
128
+ type AuditAction = 'role_created' | 'role_updated' | 'role_deleted' | 'role_assigned' | 'role_unassigned' | 'zone_created' | 'zone_updated' | 'zone_deleted' | 'authority_updated' | 'simulation_run' | 'policy_deployed';
129
+ interface AuditEntry {
130
+ /** Unique entry ID */
131
+ id: string;
132
+ /** What happened */
133
+ action: AuditAction;
134
+ /** Who did it */
135
+ actorId: string;
136
+ /** Actor's role at time of action */
137
+ actorRole: string;
138
+ /** When */
139
+ timestamp: number;
140
+ /** What was affected */
141
+ targetType: 'role' | 'zone' | 'assignment' | 'authority' | 'simulation';
142
+ /** Target identifier */
143
+ targetId: string;
144
+ /** What changed (before/after for updates) */
145
+ changes?: {
146
+ before?: Record<string, unknown>;
147
+ after?: Record<string, unknown>;
148
+ };
149
+ /** Human-readable description */
150
+ summary: string;
151
+ }
152
+ interface PolicySimulationRequest {
153
+ /** What are we simulating? */
154
+ type: 'role_change' | 'zone_change' | 'authority_change' | 'full_matrix';
155
+ /** The proposed change (new or modified role/zone) */
156
+ proposed?: {
157
+ role?: OrgRole;
158
+ zone?: OrgZone;
159
+ authority?: AuthorityGrant;
160
+ };
161
+ /** Which role to evaluate against (for zone changes) */
162
+ targetRoleId?: string;
163
+ /** Which zone to evaluate in (for role changes) */
164
+ targetZoneId?: string;
165
+ /** Specific intents to test (defaults to all 61) */
166
+ intents?: string[];
167
+ }
168
+ interface PolicySimulationResult {
169
+ /** Request that produced this result */
170
+ request: PolicySimulationRequest;
171
+ /** When the simulation ran */
172
+ timestamp: number;
173
+ /** Per-intent verdicts */
174
+ verdicts: IntentVerdict[];
175
+ /** Summary stats */
176
+ summary: {
177
+ total: number;
178
+ allowed: number;
179
+ blocked: number;
180
+ paused: number;
181
+ modified: number;
182
+ };
183
+ /** Conflicts detected (things that might break) */
184
+ conflicts: PolicyConflict[];
185
+ /** Comparison with current policy (if this is a change) */
186
+ diff?: PolicyDiff[];
187
+ }
188
+ interface IntentVerdict {
189
+ /** The intent evaluated */
190
+ intent: string;
191
+ /** Human description of the intent */
192
+ description: string;
193
+ /** Current verdict (before proposed change) */
194
+ currentVerdict?: 'allow' | 'block' | 'pause' | 'modify';
195
+ /** Proposed verdict (after change) */
196
+ proposedVerdict: 'allow' | 'block' | 'pause' | 'modify';
197
+ /** Whether this changed */
198
+ changed: boolean;
199
+ /** Why this verdict was reached */
200
+ reason: string;
201
+ }
202
+ interface PolicyConflict {
203
+ /** What's conflicting */
204
+ description: string;
205
+ /** Severity */
206
+ severity: 'warning' | 'error';
207
+ /** Which intent is affected */
208
+ intent: string;
209
+ /** What the admin should consider */
210
+ suggestion: string;
211
+ }
212
+ interface PolicyDiff {
213
+ /** The intent that changed */
214
+ intent: string;
215
+ /** Old verdict */
216
+ from: string;
217
+ /** New verdict */
218
+ to: string;
219
+ /** Human explanation */
220
+ explanation: string;
221
+ }
222
+ /**
223
+ * Pluggable storage backend. Mentra provides the database.
224
+ * We provide the interface.
225
+ */
226
+ interface AdminStorage {
227
+ getRoles(): Promise<OrgRole[]>;
228
+ getRole(id: string): Promise<OrgRole | null>;
229
+ saveRole(role: OrgRole): Promise<void>;
230
+ deleteRole(id: string): Promise<void>;
231
+ getAssignments(): Promise<RoleAssignment[]>;
232
+ getAssignmentsByDevice(deviceId: string): Promise<RoleAssignment[]>;
233
+ getAssignmentsByRole(roleId: string): Promise<RoleAssignment[]>;
234
+ saveAssignment(assignment: RoleAssignment): Promise<void>;
235
+ deleteAssignment(id: string): Promise<void>;
236
+ getZones(): Promise<OrgZone[]>;
237
+ getZone(id: string): Promise<OrgZone | null>;
238
+ getZonesByLocation(locationId: string): Promise<OrgZone[]>;
239
+ saveZone(zone: OrgZone): Promise<void>;
240
+ deleteZone(id: string): Promise<void>;
241
+ getAuthorityChain(): Promise<AuthorityChain>;
242
+ saveAuthorityChain(chain: AuthorityChain): Promise<void>;
243
+ getAuditLog(options?: {
244
+ limit?: number;
245
+ offset?: number;
246
+ action?: AuditAction;
247
+ }): Promise<AuditEntry[]>;
248
+ appendAudit(entry: AuditEntry): Promise<void>;
249
+ }
250
+
251
+ /**
252
+ * Governance Admin Manager
253
+ *
254
+ * The management layer for enterprise governance. Handles CRUD for roles,
255
+ * zones, authority chains, and device assignments. Enforces authority
256
+ * levels — not everyone can change everything.
257
+ *
258
+ * Every mutation is audited. Every change can be simulated before deployment.
259
+ */
260
+
261
+ declare class GovernanceAdmin {
262
+ private storage;
263
+ private platformWorld?;
264
+ constructor(storage: AdminStorage, platformWorld?: WorldDefinition);
265
+ private getActorAuthority;
266
+ private checkAuthority;
267
+ private audit;
268
+ createRole(role: OrgRole, actorId: string, actorRoleId: string): Promise<OrgRole>;
269
+ updateRole(roleId: string, updates: Partial<Pick<OrgRole, 'name' | 'description' | 'definition' | 'active'>>, actorId: string, actorRoleId: string): Promise<OrgRole>;
270
+ deleteRole(roleId: string, actorId: string, actorRoleId: string): Promise<void>;
271
+ listRoles(): Promise<OrgRole[]>;
272
+ getRole(roleId: string): Promise<OrgRole | null>;
273
+ assignRole(assignment: Omit<RoleAssignment, 'id' | 'assignedAt'>, actorId: string, actorRoleId: string): Promise<RoleAssignment>;
274
+ unassignRole(assignmentId: string, actorId: string, actorRoleId: string): Promise<void>;
275
+ getDeviceRole(deviceId: string): Promise<RoleAssignment | null>;
276
+ listAssignments(): Promise<RoleAssignment[]>;
277
+ createZone(zone: OrgZone, actorId: string, actorRoleId: string): Promise<OrgZone>;
278
+ updateZone(zoneId: string, updates: Partial<Pick<OrgZone, 'name' | 'description' | 'rules' | 'discovery' | 'active'>>, actorId: string, actorRoleId: string): Promise<OrgZone>;
279
+ deleteZone(zoneId: string, actorId: string, actorRoleId: string): Promise<void>;
280
+ listZones(locationId?: string): Promise<OrgZone[]>;
281
+ getZone(zoneId: string): Promise<OrgZone | null>;
282
+ updateAuthority(chain: AuthorityChain, actorId: string, actorRoleId: string): Promise<AuthorityChain>;
283
+ getAuthority(): Promise<AuthorityChain>;
284
+ simulate(request: PolicySimulationRequest, actorId: string, actorRoleId: string): Promise<PolicySimulationResult>;
285
+ simulateMatrix(actorId: string, actorRoleId: string): Promise<Map<string, Map<string, IntentVerdict[]>>>;
286
+ /**
287
+ * Simulate a proposed role change and return only what would break.
288
+ * The "measure twice" before deploying.
289
+ */
290
+ simulateRoleChange(roleId: string, proposedDefinitionUpdates: Partial<OrgRole['definition']>, actorId: string, actorRoleId: string): Promise<PolicySimulationResult>;
291
+ /**
292
+ * Simulate a proposed zone rule change and return impact.
293
+ */
294
+ simulateZoneChange(zoneId: string, proposedRuleUpdates: Partial<OrgZone['rules']>, targetRoleId: string, actorId: string, actorRoleId: string): Promise<PolicySimulationResult>;
295
+ getAuditLog(options?: {
296
+ limit?: number;
297
+ offset?: number;
298
+ action?: AuditAction;
299
+ }): Promise<AuditEntry[]>;
300
+ }
301
+ type AdminErrorCode = 'INSUFFICIENT_AUTHORITY' | 'LOCATION_SCOPE_DENIED' | 'ROLE_EXISTS' | 'ROLE_NOT_FOUND' | 'ROLE_IN_USE' | 'ZONE_EXISTS' | 'ZONE_NOT_FOUND';
302
+ declare class GovernanceAdminError extends Error {
303
+ code: AdminErrorCode;
304
+ constructor(message: string, code: AdminErrorCode);
305
+ }
306
+
307
+ /**
308
+ * In-Memory Storage — Reference Implementation
309
+ *
310
+ * Ships with the package for development and testing.
311
+ * Mentra (or any integrator) replaces this with their own database adapter
312
+ * by implementing the AdminStorage interface.
313
+ */
314
+
315
+ declare class InMemoryStorage implements AdminStorage {
316
+ private roles;
317
+ private assignments;
318
+ private zones;
319
+ private authority;
320
+ private audit;
321
+ getRoles(): Promise<OrgRole[]>;
322
+ getRole(id: string): Promise<OrgRole | null>;
323
+ saveRole(role: OrgRole): Promise<void>;
324
+ deleteRole(id: string): Promise<void>;
325
+ getAssignments(): Promise<RoleAssignment[]>;
326
+ getAssignmentsByDevice(deviceId: string): Promise<RoleAssignment[]>;
327
+ getAssignmentsByRole(roleId: string): Promise<RoleAssignment[]>;
328
+ saveAssignment(assignment: RoleAssignment): Promise<void>;
329
+ deleteAssignment(id: string): Promise<void>;
330
+ getZones(): Promise<OrgZone[]>;
331
+ getZone(id: string): Promise<OrgZone | null>;
332
+ getZonesByLocation(locationId: string): Promise<OrgZone[]>;
333
+ saveZone(zone: OrgZone): Promise<void>;
334
+ deleteZone(id: string): Promise<void>;
335
+ getAuthorityChain(): Promise<AuthorityChain>;
336
+ saveAuthorityChain(chain: AuthorityChain): Promise<void>;
337
+ getAuditLog(options?: {
338
+ limit?: number;
339
+ offset?: number;
340
+ action?: AuditAction;
341
+ }): Promise<AuditEntry[]>;
342
+ appendAudit(entry: AuditEntry): Promise<void>;
343
+ }
344
+
345
+ /**
346
+ * Policy Simulator — "What happens if I change this?"
347
+ *
348
+ * Runs the governance engine against proposed policy changes before they deploy.
349
+ * Uses the existing simulateWorld() engine and intent taxonomy to produce
350
+ * a full matrix of what would be allowed, blocked, paused, or modified.
351
+ *
352
+ * This is the enterprise "measure twice, cut once" tool.
353
+ */
354
+
355
+ declare function simulatePolicy(request: PolicySimulationRequest, currentRoles: OrgRole[], currentZones: OrgZone[], platformWorld?: WorldDefinition): PolicySimulationResult;
356
+ /**
357
+ * Generate a complete role × zone × intent matrix.
358
+ * Shows every combination: what each role can do in each zone.
359
+ */
360
+ declare function simulateFullMatrix(roles: OrgRole[], zones: OrgZone[], platformWorld?: WorldDefinition): Map<string, Map<string, IntentVerdict[]>>;
361
+
362
+ export { type AdminErrorCode, type AdminStorage, type AuditAction, type AuditEntry, type AuthorityChain, type AuthorityGrant, type AuthorityLevel, type CustomZoneRule, GovernanceAdmin, GovernanceAdminError, InMemoryStorage, type IntentVerdict, type OrgRole, type OrgZone, type PolicyConflict, type PolicyDiff, type PolicySimulationRequest, type PolicySimulationResult, type RoleAssignment, type ZoneDiscoveryMethod, type ZonePolicyLevel, type ZoneRuleSet, simulateFullMatrix, simulatePolicy };