@neuroverseos/governance 0.3.4 → 0.4.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.
Files changed (98) hide show
  1. package/README.md +280 -405
  2. package/dist/adapters/autoresearch.cjs +63 -9
  3. package/dist/adapters/autoresearch.d.cts +1 -1
  4. package/dist/adapters/autoresearch.d.ts +1 -1
  5. package/dist/adapters/autoresearch.js +3 -3
  6. package/dist/adapters/deep-agents.cjs +63 -9
  7. package/dist/adapters/deep-agents.d.cts +2 -2
  8. package/dist/adapters/deep-agents.d.ts +2 -2
  9. package/dist/adapters/deep-agents.js +3 -3
  10. package/dist/adapters/express.cjs +63 -9
  11. package/dist/adapters/express.d.cts +1 -1
  12. package/dist/adapters/express.d.ts +1 -1
  13. package/dist/adapters/express.js +3 -3
  14. package/dist/adapters/index.cjs +896 -9
  15. package/dist/adapters/index.d.cts +278 -2
  16. package/dist/adapters/index.d.ts +278 -2
  17. package/dist/adapters/index.js +45 -8
  18. package/dist/adapters/langchain.cjs +63 -9
  19. package/dist/adapters/langchain.d.cts +2 -2
  20. package/dist/adapters/langchain.d.ts +2 -2
  21. package/dist/adapters/langchain.js +3 -3
  22. package/dist/adapters/openai.cjs +63 -9
  23. package/dist/adapters/openai.d.cts +2 -2
  24. package/dist/adapters/openai.d.ts +2 -2
  25. package/dist/adapters/openai.js +3 -3
  26. package/dist/adapters/openclaw.cjs +63 -9
  27. package/dist/adapters/openclaw.d.cts +2 -2
  28. package/dist/adapters/openclaw.d.ts +2 -2
  29. package/dist/adapters/openclaw.js +3 -3
  30. package/dist/{add-ROOZLU62.js → add-LYHDZ5RL.js} +1 -1
  31. package/dist/{behavioral-MJO34S6Q.js → behavioral-SPWPGYXL.js} +2 -2
  32. package/dist/{bootstrap-CQRZVOXK.js → bootstrap-IP5QMC3Q.js} +2 -2
  33. package/dist/{bootstrap-emitter-Q7UIJZ2O.js → bootstrap-emitter-GIMOJFOC.js} +1 -1
  34. package/dist/{bootstrap-parser-EEF36XDU.js → bootstrap-parser-LBLGVEMU.js} +1 -1
  35. package/dist/browser.global.js +149 -5
  36. package/dist/{build-ZHPMX5AZ.js → build-THUEYMVT.js} +3 -3
  37. package/dist/{chunk-G7DJ6VOD.js → chunk-25XHSTPT.js} +2 -2
  38. package/dist/{chunk-A7GKPPU7.js → chunk-2VAWP6FI.js} +1 -1
  39. package/dist/{chunk-EMQDLDAF.js → chunk-3NZMMSOW.js} +80 -2
  40. package/dist/{chunk-B6OXJLJ5.js → chunk-5JUZ4HL7.js} +2 -2
  41. package/dist/{chunk-VXHSMA3I.js → chunk-6CV4XG3J.js} +1 -1
  42. package/dist/{chunk-5TPFNWRU.js → chunk-7D7PZLB7.js} +3 -3
  43. package/dist/{chunk-ZWI3NIXK.js → chunk-7QIAF377.js} +54 -3
  44. package/dist/chunk-APU4OZIP.js +828 -0
  45. package/dist/{chunk-CTZHONLA.js → chunk-BXLTEUS4.js} +2 -2
  46. package/dist/{chunk-O5ABKEA7.js → chunk-DWHUZUEY.js} +2 -2
  47. package/dist/{chunk-U6U7EJZL.js → chunk-JKGPSFGH.js} +2 -2
  48. package/dist/{chunk-3WQLXYTP.js → chunk-MFKHTE5R.js} +2 -2
  49. package/dist/{chunk-TG6SEF24.js → chunk-OQU65525.js} +1 -1
  50. package/dist/{chunk-YEKMVDWK.js → chunk-QZ666FCV.js} +2 -2
  51. package/dist/{chunk-4FLICVVA.js → chunk-TD5GKIHP.js} +2 -2
  52. package/dist/{chunk-IS4WUH6Y.js → chunk-UTH7OXTM.js} +2 -2
  53. package/dist/{chunk-BNKJPUPQ.js → chunk-V4FZHJQX.js} +2 -2
  54. package/dist/{chunk-F66BVUYB.js → chunk-Y6WXAPKY.js} +3 -3
  55. package/dist/{chunk-QXBFT7NI.js → chunk-YNYCQECH.js} +2 -2
  56. package/dist/{chunk-PVTQQS3Y.js → chunk-YPCVY4GS.js} +31 -0
  57. package/dist/{chunk-W7LLXRGY.js → chunk-ZAF6JH23.js} +65 -10
  58. package/dist/cli/neuroverse.cjs +3031 -182
  59. package/dist/cli/neuroverse.js +39 -23
  60. package/dist/cli/plan.cjs +176 -12
  61. package/dist/cli/plan.js +2 -2
  62. package/dist/cli/run.cjs +63 -9
  63. package/dist/cli/run.js +2 -2
  64. package/dist/configure-world-XU2COHOZ.js +705 -0
  65. package/dist/{decision-flow-M63D47LO.js → decision-flow-3K4D72G4.js} +2 -2
  66. package/dist/{demo-G43RLCPK.js → demo-66MMJTEH.js} +3 -3
  67. package/dist/{derive-LMDUTXDD.js → derive-5LOMN7GO.js} +4 -4
  68. package/dist/{doctor-6BC6X2VO.js → doctor-WIO4FLA3.js} +2 -1
  69. package/dist/{equity-penalties-SG5IZQ7I.js → equity-penalties-WWC7UDQD.js} +3 -3
  70. package/dist/{explain-RHBU2GBR.js → explain-MUSGDT67.js} +1 -1
  71. package/dist/{guard-AEEJNWLD.js → guard-W3BMQPBJ.js} +3 -3
  72. package/dist/{guard-contract-B7lplwm9.d.ts → guard-contract-CLBbTGK_.d.cts} +91 -1
  73. package/dist/{guard-contract-B7lplwm9.d.cts → guard-contract-CLBbTGK_.d.ts} +91 -1
  74. package/dist/{guard-engine-PNR6MHCM.js → guard-engine-N7TUIUU7.js} +5 -3
  75. package/dist/{impact-3XVDSCBU.js → impact-WIAM66IH.js} +3 -3
  76. package/dist/{improve-TQP4ECSY.js → improve-PJDAWW4Q.js} +3 -3
  77. package/dist/index.cjs +230 -14
  78. package/dist/index.d.cts +72 -3
  79. package/dist/index.d.ts +72 -3
  80. package/dist/index.js +24 -22
  81. package/dist/{init-FYPV4SST.js → init-TKIJDR7I.js} +5 -1
  82. package/dist/lens-IP6GIZ2Q.js +1017 -0
  83. package/dist/{mcp-server-5Y3ZM7TV.js → mcp-server-OG3PPVD2.js} +3 -3
  84. package/dist/mentraos-YFS7FMJH.js +48 -0
  85. package/dist/{playground-VZBNPPBO.js → playground-4BK2XQ47.js} +2 -2
  86. package/dist/{redteam-MZPZD3EF.js → redteam-BRZALBPP.js} +2 -2
  87. package/dist/{session-JYOARW54.js → session-SGRUT2UH.js} +3 -3
  88. package/dist/{shared-C_zpdvBm.d.cts → shared-BGzmYP5g.d.cts} +1 -1
  89. package/dist/{shared-Cf7yxx4-.d.ts → shared-CwGpPheR.d.ts} +1 -1
  90. package/dist/{simulate-LJXYBC6M.js → simulate-FGXKIH7V.js} +17 -4
  91. package/dist/{test-BOOR4A5F.js → test-PT44BSYG.js} +2 -2
  92. package/dist/{trace-PKV4KX56.js → trace-2YDNAXMK.js} +2 -2
  93. package/dist/{validate-RALX7CZS.js → validate-Q5O5TGLT.js} +1 -1
  94. package/dist/{world-BIP4GZBZ.js → world-V52ZMH26.js} +1 -1
  95. package/dist/{world-loader-Y6HMQH2D.js → world-loader-C4D3VPP3.js} +1 -1
  96. package/dist/worlds/mentraos-smartglasses.nv-world.md +423 -0
  97. package/dist/worlds/user-rules.nv-world.md +328 -0
  98. package/package.json +1 -1
@@ -96,8 +96,8 @@ async function loadBundledWorld(name = DEFAULT_BUNDLED_WORLD) {
96
96
  const { join, dirname } = await import("path");
97
97
  const { existsSync } = await import("fs");
98
98
  const { fileURLToPath } = await import("url");
99
- const { parseWorldMarkdown } = await import("./bootstrap-parser-EEF36XDU.js");
100
- const { emitWorldDefinition } = await import("./bootstrap-emitter-Q7UIJZ2O.js");
99
+ const { parseWorldMarkdown } = await import("./bootstrap-parser-LBLGVEMU.js");
100
+ const { emitWorldDefinition } = await import("./bootstrap-emitter-GIMOJFOC.js");
101
101
  const filename = `${name}.nv-world.md`;
102
102
  let packageRoot;
103
103
  try {
@@ -6,10 +6,10 @@ import {
6
6
  } from "./chunk-5U2MQO5P.js";
7
7
  import {
8
8
  evaluateGuard
9
- } from "./chunk-W7LLXRGY.js";
9
+ } from "./chunk-ZAF6JH23.js";
10
10
  import {
11
11
  loadWorld
12
- } from "./chunk-CTZHONLA.js";
12
+ } from "./chunk-BXLTEUS4.js";
13
13
 
14
14
  // src/engine/tool-classifier.ts
15
15
  var TOOL_CATEGORY_MAP = {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  evaluateGuard
3
- } from "./chunk-W7LLXRGY.js";
3
+ } from "./chunk-ZAF6JH23.js";
4
4
  import {
5
5
  loadWorld
6
- } from "./chunk-CTZHONLA.js";
6
+ } from "./chunk-BXLTEUS4.js";
7
7
 
8
8
  // src/runtime/govern.ts
9
9
  function actionToGuardEvent(action) {
@@ -6,10 +6,10 @@ import {
6
6
  } from "./chunk-5U2MQO5P.js";
7
7
  import {
8
8
  evaluateGuard
9
- } from "./chunk-W7LLXRGY.js";
9
+ } from "./chunk-ZAF6JH23.js";
10
10
  import {
11
11
  loadWorld
12
- } from "./chunk-CTZHONLA.js";
12
+ } from "./chunk-BXLTEUS4.js";
13
13
 
14
14
  // src/adapters/langchain.ts
15
15
  var GovernanceBlockedError2 = class extends GovernanceBlockedError {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  readAuditLog
3
- } from "./chunk-A7GKPPU7.js";
3
+ } from "./chunk-2VAWP6FI.js";
4
4
 
5
5
  // src/engine/impact-report.ts
6
6
  function generateImpactReport(events) {
@@ -9,10 +9,10 @@ import {
9
9
  } from "./chunk-7P3S7MAY.js";
10
10
  import {
11
11
  parseWorldMarkdown
12
- } from "./chunk-EMQDLDAF.js";
12
+ } from "./chunk-3NZMMSOW.js";
13
13
  import {
14
14
  emitWorldDefinition
15
- } from "./chunk-PVTQQS3Y.js";
15
+ } from "./chunk-YPCVY4GS.js";
16
16
 
17
17
  // src/engine/derive-normalizer.ts
18
18
  function findSections(lines) {
@@ -7,10 +7,10 @@ import {
7
7
  } from "./chunk-5U2MQO5P.js";
8
8
  import {
9
9
  evaluateGuard
10
- } from "./chunk-W7LLXRGY.js";
10
+ } from "./chunk-ZAF6JH23.js";
11
11
  import {
12
12
  loadWorld
13
- } from "./chunk-CTZHONLA.js";
13
+ } from "./chunk-BXLTEUS4.js";
14
14
 
15
15
  // src/adapters/openai.ts
16
16
  var GovernanceBlockedError2 = class extends GovernanceBlockedError {
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-D2UCV5AK.js";
7
7
  import {
8
8
  evaluateGuard
9
- } from "./chunk-W7LLXRGY.js";
9
+ } from "./chunk-ZAF6JH23.js";
10
10
  import {
11
11
  advancePlan,
12
12
  evaluatePlan,
@@ -14,7 +14,7 @@ import {
14
14
  } from "./chunk-QLPTHTVB.js";
15
15
  import {
16
16
  loadWorld
17
- } from "./chunk-CTZHONLA.js";
17
+ } from "./chunk-BXLTEUS4.js";
18
18
 
19
19
  // src/runtime/session.ts
20
20
  async function defaultToolExecutor(name, args) {
@@ -6,10 +6,10 @@ import {
6
6
  } from "./chunk-5U2MQO5P.js";
7
7
  import {
8
8
  evaluateGuard
9
- } from "./chunk-W7LLXRGY.js";
9
+ } from "./chunk-ZAF6JH23.js";
10
10
  import {
11
11
  loadWorld
12
- } from "./chunk-CTZHONLA.js";
12
+ } from "./chunk-BXLTEUS4.js";
13
13
 
14
14
  // src/adapters/openclaw.ts
15
15
  var GovernanceBlockedError2 = class extends GovernanceBlockedError {
@@ -1,9 +1,9 @@
1
+ import {
2
+ simulateWorld
3
+ } from "./chunk-7QIAF377.js";
1
4
  import {
2
5
  validateWorld
3
6
  } from "./chunk-7P3S7MAY.js";
4
- import {
5
- simulateWorld
6
- } from "./chunk-ZWI3NIXK.js";
7
7
 
8
8
  // src/engine/improve-engine.ts
9
9
  function improveWorld(world) {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  evaluateGuard
3
- } from "./chunk-W7LLXRGY.js";
3
+ } from "./chunk-ZAF6JH23.js";
4
4
  import {
5
5
  loadWorldFromDirectory
6
- } from "./chunk-CTZHONLA.js";
6
+ } from "./chunk-BXLTEUS4.js";
7
7
 
8
8
  // src/adapters/autoresearch.ts
9
9
  var AutoresearchGovernor = class {
@@ -162,6 +162,36 @@ function emitWorldDefinition(parsed) {
162
162
  structural_indicators: rules.filter((r) => r.severity === "structural").map((r) => r.id)
163
163
  }
164
164
  };
165
+ const validScopes = /* @__PURE__ */ new Set(["response_framing", "language_style", "content_filtering", "value_emphasis", "behavior_shaping"]);
166
+ const lensConfigs = parsed.lenses.map((pl) => {
167
+ const directives = pl.directives.map((d) => ({
168
+ id: d.id,
169
+ scope: validScopes.has(d.scope) ? d.scope : "behavior_shaping",
170
+ instruction: d.instruction
171
+ }));
172
+ return {
173
+ id: pl.id,
174
+ name: pl.name,
175
+ tagline: pl.tagline,
176
+ description: pl.description,
177
+ tags: pl.tags,
178
+ tone: {
179
+ formality: pl.formality || "neutral",
180
+ verbosity: pl.verbosity || "balanced",
181
+ emotion: pl.emotion || "neutral",
182
+ confidence: pl.confidence || "balanced"
183
+ },
184
+ directives,
185
+ defaultForRoles: pl.defaultForRoles,
186
+ priority: pl.priority,
187
+ stackable: pl.stackable
188
+ };
189
+ });
190
+ const lensesConfig = lensConfigs.length > 0 ? {
191
+ lenses: lensConfigs,
192
+ ...parsed.lensPolicy ? { policy: parsed.lensPolicy } : {},
193
+ ...parsed.lensLockPin ? { lockPin: parsed.lensLockPin } : {}
194
+ } : void 0;
165
195
  const metadata = {
166
196
  format_version: "1.0.0",
167
197
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -176,6 +206,7 @@ function emitWorldDefinition(parsed) {
176
206
  rules,
177
207
  gates,
178
208
  outcomes,
209
+ ...lensesConfig ? { lenses: lensesConfig } : {},
179
210
  metadata
180
211
  };
181
212
  return { world: worldDefinition, issues };
@@ -143,6 +143,33 @@ function evaluateGuard(event, world, options = {}) {
143
143
  let decidingId;
144
144
  const guardsMatched = [];
145
145
  const rulesMatched = [];
146
+ if (options.emergencyOverride) {
147
+ checkInvariantCoverage(world, invariantChecks);
148
+ return buildVerdict(
149
+ "ALLOW",
150
+ void 0,
151
+ "emergency-override",
152
+ "Emergency override active \u2014 all governance rules suspended. Platform constraints still apply.",
153
+ world,
154
+ level,
155
+ invariantChecks,
156
+ guardsMatched,
157
+ rulesMatched,
158
+ includeTrace ? buildTrace(
159
+ invariantChecks,
160
+ safetyChecks,
161
+ planCheckResult,
162
+ roleChecks,
163
+ guardChecks,
164
+ kernelRuleChecks,
165
+ levelChecks,
166
+ "session-allowlist",
167
+ "emergency-override",
168
+ startTime
169
+ ) : void 0,
170
+ event.intent
171
+ );
172
+ }
146
173
  checkInvariantCoverage(world, invariantChecks);
147
174
  if (event.roleId && options.agentStates) {
148
175
  const agentState = options.agentStates.get(event.roleId);
@@ -207,7 +234,8 @@ function evaluateGuard(event, world, options = {}) {
207
234
  decidingLayer,
208
235
  decidingId,
209
236
  startTime
210
- ) : void 0
237
+ ) : void 0,
238
+ event.intent
211
239
  );
212
240
  }
213
241
  }
@@ -236,7 +264,8 @@ function evaluateGuard(event, world, options = {}) {
236
264
  decidingLayer,
237
265
  decidingId,
238
266
  startTime
239
- ) : void 0
267
+ ) : void 0,
268
+ event.intent
240
269
  );
241
270
  }
242
271
  if (options.plan) {
@@ -271,7 +300,8 @@ function evaluateGuard(event, world, options = {}) {
271
300
  decidingLayer,
272
301
  decidingId,
273
302
  startTime
274
- ) : void 0
303
+ ) : void 0,
304
+ event.intent
275
305
  );
276
306
  }
277
307
  }
@@ -300,7 +330,8 @@ function evaluateGuard(event, world, options = {}) {
300
330
  decidingLayer,
301
331
  decidingId,
302
332
  startTime
303
- ) : void 0
333
+ ) : void 0,
334
+ event.intent
304
335
  );
305
336
  }
306
337
  const guardVerdict = checkGuards(event, eventText, world, guardChecks, guardsMatched);
@@ -338,7 +369,8 @@ function evaluateGuard(event, world, options = {}) {
338
369
  decidingLayer,
339
370
  decidingId,
340
371
  startTime
341
- ) : void 0
372
+ ) : void 0,
373
+ event.intent
342
374
  );
343
375
  verdict.intentRecord = intentRecord;
344
376
  if (guardVerdict.consequence) verdict.consequence = guardVerdict.consequence;
@@ -371,7 +403,8 @@ function evaluateGuard(event, world, options = {}) {
371
403
  decidingLayer,
372
404
  decidingId,
373
405
  startTime
374
- ) : void 0
406
+ ) : void 0,
407
+ event.intent
375
408
  );
376
409
  }
377
410
  const levelVerdict = checkLevelConstraints(event, level, levelChecks);
@@ -399,7 +432,8 @@ function evaluateGuard(event, world, options = {}) {
399
432
  decidingLayer,
400
433
  decidingId,
401
434
  startTime
402
- ) : void 0
435
+ ) : void 0,
436
+ event.intent
403
437
  );
404
438
  }
405
439
  const warning = guardVerdict?.warning;
@@ -424,7 +458,8 @@ function evaluateGuard(event, world, options = {}) {
424
458
  decidingLayer,
425
459
  decidingId,
426
460
  startTime
427
- ) : void 0
461
+ ) : void 0,
462
+ event.intent
428
463
  );
429
464
  }
430
465
  function checkInvariantCoverage(world, checks) {
@@ -801,7 +836,7 @@ function buildTrace(invariantChecks, safetyChecks, planCheck, roleChecks, guardC
801
836
  }
802
837
  return trace;
803
838
  }
804
- function buildVerdict(status, reason, ruleId, warning, world, level, invariantChecks, guardsMatched, rulesMatched, trace) {
839
+ function buildVerdict(status, reason, ruleId, warning, world, level, invariantChecks, guardsMatched, rulesMatched, trace, eventIntent) {
805
840
  const evidence = {
806
841
  worldId: world.world.world_id,
807
842
  worldName: world.world.name,
@@ -821,10 +856,30 @@ function buildVerdict(status, reason, ruleId, warning, world, level, invariantCh
821
856
  if (ruleId) verdict.ruleId = ruleId;
822
857
  if (warning) verdict.warning = warning;
823
858
  if (trace) verdict.trace = trace;
859
+ verdict.event = verdictToEvent(status, eventIntent);
824
860
  return verdict;
825
861
  }
862
+ function verdictToEvent(status, intent) {
863
+ const statusEventMap = {
864
+ ALLOW: "action_allowed",
865
+ BLOCK: "action_blocked",
866
+ PAUSE: "action_paused",
867
+ MODIFY: "action_modified",
868
+ PENALIZE: "action_penalized",
869
+ REWARD: "action_rewarded",
870
+ NEUTRAL: "action_neutral"
871
+ };
872
+ return {
873
+ type: intent || statusEventMap[status] || "unknown_action",
874
+ actor: "agent",
875
+ source: "guard",
876
+ timestamp: Date.now(),
877
+ guardStatus: status
878
+ };
879
+ }
826
880
 
827
881
  export {
828
882
  evaluateGuard,
829
- eventToAllowlistKey
883
+ eventToAllowlistKey,
884
+ verdictToEvent
830
885
  };