@neuroverseos/governance 0.2.3 → 0.3.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 (118) hide show
  1. package/package.json +4 -2
  2. package/policies/content-moderation-rules.txt +8 -0
  3. package/policies/marketing-rules.txt +8 -0
  4. package/policies/science-research-rules.txt +11 -0
  5. package/policies/social-media-rules.txt +7 -0
  6. package/policies/strict-rules.txt +8 -0
  7. package/policies/trading-rules.txt +8 -0
  8. package/simulate.html +1899 -0
  9. package/dist/adapters/autoresearch.cjs +0 -196
  10. package/dist/adapters/autoresearch.d.cts +0 -103
  11. package/dist/adapters/autoresearch.d.ts +0 -103
  12. package/dist/adapters/autoresearch.js +0 -7
  13. package/dist/adapters/deep-agents.cjs +0 -1472
  14. package/dist/adapters/deep-agents.d.cts +0 -181
  15. package/dist/adapters/deep-agents.d.ts +0 -181
  16. package/dist/adapters/deep-agents.js +0 -17
  17. package/dist/adapters/express.cjs +0 -1196
  18. package/dist/adapters/express.d.cts +0 -66
  19. package/dist/adapters/express.d.ts +0 -66
  20. package/dist/adapters/express.js +0 -12
  21. package/dist/adapters/index.cjs +0 -2038
  22. package/dist/adapters/index.d.cts +0 -8
  23. package/dist/adapters/index.d.ts +0 -8
  24. package/dist/adapters/index.js +0 -68
  25. package/dist/adapters/langchain.cjs +0 -1259
  26. package/dist/adapters/langchain.d.cts +0 -89
  27. package/dist/adapters/langchain.d.ts +0 -89
  28. package/dist/adapters/langchain.js +0 -17
  29. package/dist/adapters/openai.cjs +0 -1289
  30. package/dist/adapters/openai.d.cts +0 -99
  31. package/dist/adapters/openai.d.ts +0 -99
  32. package/dist/adapters/openai.js +0 -17
  33. package/dist/adapters/openclaw.cjs +0 -1281
  34. package/dist/adapters/openclaw.d.cts +0 -99
  35. package/dist/adapters/openclaw.d.ts +0 -99
  36. package/dist/adapters/openclaw.js +0 -17
  37. package/dist/bootstrap-GXVDZNF7.js +0 -114
  38. package/dist/build-X5MZY4IA.js +0 -339
  39. package/dist/chunk-4L6OPKMQ.js +0 -100
  40. package/dist/chunk-4NGDRRQH.js +0 -10
  41. package/dist/chunk-5U2MQO5P.js +0 -57
  42. package/dist/chunk-6BB55YJI.js +0 -113
  43. package/dist/chunk-6CZSKEY5.js +0 -164
  44. package/dist/chunk-7P3S7MAY.js +0 -1090
  45. package/dist/chunk-A5W4GNQO.js +0 -130
  46. package/dist/chunk-AF2VX4AL.js +0 -363
  47. package/dist/chunk-AKW5YVCE.js +0 -96
  48. package/dist/chunk-BMOXICAB.js +0 -340
  49. package/dist/chunk-BQZMOEML.js +0 -43
  50. package/dist/chunk-D2UCV5AK.js +0 -326
  51. package/dist/chunk-EVDJUSZ2.js +0 -91
  52. package/dist/chunk-FYS2CBUW.js +0 -304
  53. package/dist/chunk-I3RRAYK2.js +0 -11
  54. package/dist/chunk-IZSO75NZ.js +0 -792
  55. package/dist/chunk-JCKSW2PZ.js +0 -304
  56. package/dist/chunk-JZPQGIKR.js +0 -79
  57. package/dist/chunk-KTFTTLTP.js +0 -246
  58. package/dist/chunk-MH7BT4VH.js +0 -15
  59. package/dist/chunk-ORJ3NOE6.js +0 -622
  60. package/dist/chunk-OT6PXH54.js +0 -61
  61. package/dist/chunk-Q6O7ZLO2.js +0 -62
  62. package/dist/chunk-QLPTHTVB.js +0 -253
  63. package/dist/chunk-REXY4LUL.js +0 -226
  64. package/dist/chunk-T5EUJQE5.js +0 -172
  65. package/dist/chunk-TTBKTF3P.js +0 -608
  66. package/dist/chunk-XPDMYECO.js +0 -642
  67. package/dist/chunk-YZFATT7X.js +0 -9
  68. package/dist/chunk-ZIVQNSZU.js +0 -119
  69. package/dist/chunk-ZJTDUCC2.js +0 -194
  70. package/dist/cli/neuroverse.cjs +0 -12564
  71. package/dist/cli/neuroverse.d.cts +0 -1
  72. package/dist/cli/neuroverse.d.ts +0 -1
  73. package/dist/cli/neuroverse.js +0 -208
  74. package/dist/cli/plan.cjs +0 -1686
  75. package/dist/cli/plan.d.cts +0 -20
  76. package/dist/cli/plan.d.ts +0 -20
  77. package/dist/cli/plan.js +0 -353
  78. package/dist/cli/run.cjs +0 -1945
  79. package/dist/cli/run.d.cts +0 -20
  80. package/dist/cli/run.d.ts +0 -20
  81. package/dist/cli/run.js +0 -143
  82. package/dist/configure-ai-TK67ZWZL.js +0 -132
  83. package/dist/decision-flow-LETV5NWY.js +0 -61
  84. package/dist/derive-7365SUFU.js +0 -152
  85. package/dist/doctor-QYISMKEL.js +0 -173
  86. package/dist/equity-penalties-63FGB3I2.js +0 -244
  87. package/dist/explain-A2EWI2OL.js +0 -51
  88. package/dist/guard-3BWL3IGH.js +0 -92
  89. package/dist/guard-contract-C9_zKbzd.d.cts +0 -821
  90. package/dist/guard-contract-C9_zKbzd.d.ts +0 -821
  91. package/dist/guard-engine-QFMIBWJY.js +0 -10
  92. package/dist/impact-UB6DXKSX.js +0 -59
  93. package/dist/improve-XZA57GER.js +0 -66
  94. package/dist/index.cjs +0 -6821
  95. package/dist/index.d.cts +0 -1829
  96. package/dist/index.d.ts +0 -1829
  97. package/dist/index.js +0 -430
  98. package/dist/infer-world-7GVZWFX4.js +0 -543
  99. package/dist/init-PKPIYHYE.js +0 -144
  100. package/dist/init-world-VWMQZQC7.js +0 -223
  101. package/dist/mcp-server-XWQZXNW7.js +0 -13
  102. package/dist/model-adapter-BB7G4MFI.js +0 -11
  103. package/dist/playground-ADWZORNV.js +0 -550
  104. package/dist/redteam-JRQ7FD2F.js +0 -357
  105. package/dist/session-MMYX5YCF.js +0 -15
  106. package/dist/shared--Q8wPBVN.d.ts +0 -60
  107. package/dist/shared-HpAG90PX.d.cts +0 -60
  108. package/dist/shared-U2QFV7JH.js +0 -16
  109. package/dist/simulate-GMIFFXYV.js +0 -83
  110. package/dist/test-JBBZ65X4.js +0 -217
  111. package/dist/trace-3MYWIDEF.js +0 -166
  112. package/dist/validate-LLBWVPGV.js +0 -81
  113. package/dist/validate-engine-UIABSIHD.js +0 -7
  114. package/dist/world-BFJCIQSH.js +0 -378
  115. package/dist/world-loader-HMPTOEA2.js +0 -9
  116. package/dist/worlds/autoresearch.nv-world.md +0 -230
  117. package/dist/worlds/coding-agent.nv-world.md +0 -211
  118. package/dist/worlds/derivation-world.nv-world.md +0 -278
package/dist/index.js DELETED
@@ -1,430 +0,0 @@
1
- import {
2
- generateImpactReport,
3
- generateImpactReportFromFile,
4
- renderImpactReport
5
- } from "./chunk-KTFTTLTP.js";
6
- import {
7
- CompositeAuditLogger,
8
- ConsoleAuditLogger,
9
- FileAuditLogger,
10
- createGovernanceEngine,
11
- readAuditLog,
12
- summarizeAuditEvents,
13
- verdictToAuditEvent
14
- } from "./chunk-REXY4LUL.js";
15
- import {
16
- BOOTSTRAP_EXIT_CODES
17
- } from "./chunk-4NGDRRQH.js";
18
- import {
19
- VALIDATE_EXIT_CODES
20
- } from "./chunk-I3RRAYK2.js";
21
- import {
22
- GUARD_EXIT_CODES
23
- } from "./chunk-MH7BT4VH.js";
24
- import {
25
- deriveWorld,
26
- extractWorldMarkdown,
27
- normalizeWorldMarkdown
28
- } from "./chunk-ORJ3NOE6.js";
29
- import {
30
- CONFIGURE_AI_EXIT_CODES,
31
- DERIVE_EXIT_CODES
32
- } from "./chunk-Q6O7ZLO2.js";
33
- import {
34
- emitWorldDefinition,
35
- parseWorldMarkdown
36
- } from "./chunk-XPDMYECO.js";
37
- import "./chunk-OT6PXH54.js";
38
- import {
39
- explainWorld,
40
- renderExplainText
41
- } from "./chunk-ZJTDUCC2.js";
42
- import {
43
- improveWorld,
44
- renderImproveText
45
- } from "./chunk-BMOXICAB.js";
46
- import {
47
- validateWorld
48
- } from "./chunk-7P3S7MAY.js";
49
- import {
50
- renderSimulateText,
51
- simulateWorld
52
- } from "./chunk-FYS2CBUW.js";
53
- import {
54
- PLAN_EXIT_CODES,
55
- parsePlanMarkdown
56
- } from "./chunk-6CZSKEY5.js";
57
- import {
58
- SessionManager,
59
- runInteractiveMode,
60
- runPipeMode
61
- } from "./chunk-AF2VX4AL.js";
62
- import {
63
- applyConsequence,
64
- applyReward,
65
- createAgentState,
66
- generateDecisionFlow,
67
- renderDecisionFlow,
68
- tickAgentStates
69
- } from "./chunk-D2UCV5AK.js";
70
- import {
71
- ModelAdapter,
72
- PROVIDERS,
73
- resolveProvider
74
- } from "./chunk-A5W4GNQO.js";
75
- import {
76
- McpGovernanceServer
77
- } from "./chunk-TTBKTF3P.js";
78
- import {
79
- describeActiveWorld,
80
- getActiveWorldName,
81
- listWorlds,
82
- resolveWorldPath,
83
- setActiveWorld
84
- } from "./chunk-AKW5YVCE.js";
85
- import {
86
- evaluateGuard,
87
- eventToAllowlistKey
88
- } from "./chunk-IZSO75NZ.js";
89
- import {
90
- advancePlan,
91
- buildPlanCheck,
92
- evaluatePlan,
93
- getPlanProgress
94
- } from "./chunk-QLPTHTVB.js";
95
- import {
96
- loadWorld,
97
- loadWorldFromDirectory
98
- } from "./chunk-JZPQGIKR.js";
99
- import "./chunk-YZFATT7X.js";
100
-
101
- // src/engine/verdict-formatter.ts
102
- var ANSI = {
103
- red: "\x1B[31m",
104
- green: "\x1B[32m",
105
- yellow: "\x1B[33m",
106
- blue: "\x1B[34m",
107
- magenta: "\x1B[35m",
108
- cyan: "\x1B[36m",
109
- gray: "\x1B[90m",
110
- bold: "\x1B[1m",
111
- dim: "\x1B[2m",
112
- reset: "\x1B[0m"
113
- };
114
- function c(text, ...codes) {
115
- return codes.join("") + text + ANSI.reset;
116
- }
117
- function formatVerdict(verdict, options = {}) {
118
- const {
119
- showRuleId = true,
120
- showEvidence = false,
121
- showWarning = true,
122
- color = false,
123
- compact = false
124
- } = options;
125
- if (compact) {
126
- return formatCompact(verdict, { showRuleId, showWarning, color });
127
- }
128
- return formatFull(verdict, { showRuleId, showEvidence, showWarning, color });
129
- }
130
- function formatCompact(verdict, opts) {
131
- const status = formatStatus(verdict.status, opts.color);
132
- const parts = [status];
133
- if (opts.showRuleId && verdict.ruleId) {
134
- parts.push(verdict.ruleId);
135
- }
136
- if (verdict.reason) {
137
- parts.push(verdict.reason);
138
- }
139
- if (opts.showWarning && verdict.warning) {
140
- parts.push(`warning: ${verdict.warning}`);
141
- }
142
- return parts.join(" \u2014 ");
143
- }
144
- function formatFull(verdict, opts) {
145
- const lines = [];
146
- lines.push(formatStatus(verdict.status, opts.color));
147
- if (opts.showRuleId && verdict.ruleId) {
148
- lines.push(` Rule: ${verdict.ruleId}`);
149
- }
150
- if (verdict.reason) {
151
- lines.push(` Reason: ${verdict.reason}`);
152
- }
153
- if (verdict.consequence) {
154
- const label = opts.color ? c("Consequence:", ANSI.red) : "Consequence:";
155
- lines.push(` ${label} ${verdict.consequence.description}`);
156
- if (verdict.consequence.rounds) {
157
- lines.push(` Freeze: ${verdict.consequence.rounds} round(s)`);
158
- }
159
- if (verdict.consequence.magnitude) {
160
- lines.push(` Magnitude: ${(verdict.consequence.magnitude * 100).toFixed(0)}%`);
161
- }
162
- }
163
- if (verdict.reward) {
164
- const label = opts.color ? c("Reward:", ANSI.blue) : "Reward:";
165
- lines.push(` ${label} ${verdict.reward.description}`);
166
- if (verdict.reward.rounds) {
167
- lines.push(` Duration: ${verdict.reward.rounds} round(s)`);
168
- }
169
- if (verdict.reward.magnitude) {
170
- lines.push(` Boost: ${(verdict.reward.magnitude * 100).toFixed(0)}%`);
171
- }
172
- }
173
- if (verdict.intentRecord) {
174
- const ir = verdict.intentRecord;
175
- const label = opts.color ? c("Intent Flow:", ANSI.cyan) : "Intent Flow:";
176
- lines.push(` ${label} ${ir.originalIntent} \u2192 ${ir.finalAction}`);
177
- }
178
- if (opts.showWarning && verdict.warning) {
179
- const label = opts.color ? c("Warning:", ANSI.yellow) : "Warning:";
180
- lines.push(` ${label} ${verdict.warning}`);
181
- }
182
- if (opts.showEvidence) {
183
- const ev = verdict.evidence;
184
- lines.push(` World: ${ev.worldName} v${ev.worldVersion}`);
185
- lines.push(` Invariants: ${ev.invariantsSatisfied}/${ev.invariantsTotal} covered`);
186
- if (ev.guardsMatched.length > 0) {
187
- lines.push(` Guards matched: ${ev.guardsMatched.join(", ")}`);
188
- }
189
- if (ev.rulesMatched.length > 0) {
190
- lines.push(` Rules matched: ${ev.rulesMatched.join(", ")}`);
191
- }
192
- lines.push(` Enforcement: ${ev.enforcementLevel}`);
193
- }
194
- return lines.join("\n");
195
- }
196
- function formatStatus(status, color) {
197
- switch (status) {
198
- case "ALLOW":
199
- return color ? c("ALLOWED", ANSI.green, ANSI.bold) : "ALLOWED";
200
- case "BLOCK":
201
- return color ? c("BLOCKED", ANSI.red, ANSI.bold) : "BLOCKED";
202
- case "PAUSE":
203
- return color ? c("PAUSED", ANSI.yellow, ANSI.bold) : "PAUSED";
204
- case "MODIFY":
205
- return color ? c("MODIFIED", ANSI.yellow, ANSI.bold) : "MODIFIED";
206
- case "PENALIZE":
207
- return color ? c("PENALIZED", ANSI.red, ANSI.bold) : "PENALIZED";
208
- case "REWARD":
209
- return color ? c("REWARDED", ANSI.blue, ANSI.bold) : "REWARDED";
210
- case "NEUTRAL":
211
- return color ? c("NEUTRAL", ANSI.gray, ANSI.bold) : "NEUTRAL";
212
- default:
213
- return status;
214
- }
215
- }
216
- function formatVerdictOneLine(verdict) {
217
- const parts = [verdict.status];
218
- if (verdict.ruleId) {
219
- parts[0] += `: ${verdict.ruleId}`;
220
- }
221
- if (verdict.reason) {
222
- parts.push(verdict.reason);
223
- }
224
- return parts.join(" \u2014 ");
225
- }
226
-
227
- // src/engine/condition-engine.ts
228
- function getFieldValue(event, field) {
229
- if (field.startsWith("args.")) {
230
- const key = field.slice(5);
231
- return event.args?.[key];
232
- }
233
- return event[field];
234
- }
235
- function toString(value) {
236
- if (value === null || value === void 0) return "";
237
- if (typeof value === "string") return value;
238
- if (typeof value === "number" || typeof value === "boolean") return String(value);
239
- return JSON.stringify(value);
240
- }
241
- function evaluateCondition(condition, event) {
242
- const fieldValue = getFieldValue(event, condition.field);
243
- if (fieldValue === void 0 && condition.operator !== "!=") {
244
- return { matched: false, evidence: null };
245
- }
246
- switch (condition.operator) {
247
- case "==":
248
- return evaluateEquals(fieldValue, condition.value);
249
- case "!=":
250
- return evaluateNotEquals(fieldValue, condition.value);
251
- case ">":
252
- return evaluateComparison(fieldValue, condition.value, (a, b) => a > b);
253
- case "<":
254
- return evaluateComparison(fieldValue, condition.value, (a, b) => a < b);
255
- case ">=":
256
- return evaluateComparison(fieldValue, condition.value, (a, b) => a >= b);
257
- case "<=":
258
- return evaluateComparison(fieldValue, condition.value, (a, b) => a <= b);
259
- case "in":
260
- return evaluateIn(fieldValue, condition.value);
261
- case "contains":
262
- return evaluateContains(fieldValue, condition.value);
263
- case "contains_any":
264
- return evaluateContainsAny(fieldValue, condition.value);
265
- case "matches_pattern":
266
- return evaluateMatchesPattern(fieldValue, condition.value);
267
- case "starts_with":
268
- return evaluateStartsWith(fieldValue, condition.value);
269
- case "ends_with":
270
- return evaluateEndsWith(fieldValue, condition.value);
271
- default:
272
- return { matched: false, evidence: null };
273
- }
274
- }
275
- function evaluateEquals(fieldValue, conditionValue) {
276
- const fieldStr = toString(fieldValue);
277
- const condStr = toString(conditionValue);
278
- const matched = fieldStr === condStr;
279
- return {
280
- matched,
281
- evidence: matched ? `${fieldStr} == ${condStr}` : null
282
- };
283
- }
284
- function evaluateNotEquals(fieldValue, conditionValue) {
285
- const fieldStr = toString(fieldValue);
286
- const condStr = toString(conditionValue);
287
- const matched = fieldStr !== condStr;
288
- return {
289
- matched,
290
- evidence: matched ? `${fieldStr} != ${condStr}` : null
291
- };
292
- }
293
- function evaluateComparison(fieldValue, conditionValue, comparator) {
294
- const a = Number(fieldValue);
295
- const b = Number(conditionValue);
296
- if (isNaN(a) || isNaN(b)) return { matched: false, evidence: null };
297
- const matched = comparator(a, b);
298
- return {
299
- matched,
300
- evidence: matched ? `${a} compared to ${b}` : null
301
- };
302
- }
303
- function evaluateIn(fieldValue, conditionValue) {
304
- if (!Array.isArray(conditionValue)) return { matched: false, evidence: null };
305
- const fieldStr = toString(fieldValue);
306
- const matched = conditionValue.some((v) => toString(v) === fieldStr);
307
- return {
308
- matched,
309
- evidence: matched ? `"${fieldStr}" found in [${conditionValue.join(", ")}]` : null
310
- };
311
- }
312
- function evaluateContains(fieldValue, conditionValue) {
313
- const fieldStr = toString(fieldValue).toLowerCase();
314
- const searchStr = toString(conditionValue).toLowerCase();
315
- const matched = fieldStr.includes(searchStr);
316
- return {
317
- matched,
318
- evidence: matched ? `"${searchStr}" found in field` : null
319
- };
320
- }
321
- function evaluateContainsAny(fieldValue, conditionValue) {
322
- if (!Array.isArray(conditionValue)) return { matched: false, evidence: null };
323
- const fieldStr = toString(fieldValue).toLowerCase();
324
- for (const pattern of conditionValue) {
325
- const patternLower = toString(pattern).toLowerCase();
326
- if (fieldStr.includes(patternLower)) {
327
- return {
328
- matched: true,
329
- evidence: `"${patternLower}" found in field`
330
- };
331
- }
332
- }
333
- return { matched: false, evidence: null };
334
- }
335
- function evaluateMatchesPattern(fieldValue, conditionValue) {
336
- const fieldStr = toString(fieldValue);
337
- const patterns = Array.isArray(conditionValue) ? conditionValue : [toString(conditionValue)];
338
- for (const pattern of patterns) {
339
- try {
340
- const regex = new RegExp(toString(pattern), "i");
341
- if (regex.test(fieldStr)) {
342
- return {
343
- matched: true,
344
- evidence: `matched pattern /${pattern}/`
345
- };
346
- }
347
- } catch {
348
- continue;
349
- }
350
- }
351
- return { matched: false, evidence: null };
352
- }
353
- function evaluateStartsWith(fieldValue, conditionValue) {
354
- const fieldStr = toString(fieldValue).toLowerCase();
355
- const prefix = toString(conditionValue).toLowerCase();
356
- const matched = fieldStr.startsWith(prefix);
357
- return {
358
- matched,
359
- evidence: matched ? `field starts with "${prefix}"` : null
360
- };
361
- }
362
- function evaluateEndsWith(fieldValue, conditionValue) {
363
- const fieldStr = toString(fieldValue).toLowerCase();
364
- const suffix = toString(conditionValue).toLowerCase();
365
- const matched = fieldStr.endsWith(suffix);
366
- return {
367
- matched,
368
- evidence: matched ? `field ends with "${suffix}"` : null
369
- };
370
- }
371
- export {
372
- BOOTSTRAP_EXIT_CODES,
373
- CONFIGURE_AI_EXIT_CODES,
374
- CompositeAuditLogger,
375
- ConsoleAuditLogger,
376
- DERIVE_EXIT_CODES,
377
- FileAuditLogger,
378
- GUARD_EXIT_CODES,
379
- McpGovernanceServer,
380
- ModelAdapter,
381
- PLAN_EXIT_CODES,
382
- PROVIDERS,
383
- SessionManager,
384
- VALIDATE_EXIT_CODES,
385
- advancePlan,
386
- applyConsequence,
387
- applyReward,
388
- buildPlanCheck,
389
- createAgentState,
390
- createGovernanceEngine,
391
- deriveWorld,
392
- describeActiveWorld,
393
- emitWorldDefinition,
394
- evaluateCondition,
395
- evaluateGuard,
396
- evaluatePlan,
397
- eventToAllowlistKey,
398
- explainWorld,
399
- extractWorldMarkdown,
400
- formatVerdict,
401
- formatVerdictOneLine,
402
- generateDecisionFlow,
403
- generateImpactReport,
404
- generateImpactReportFromFile,
405
- getActiveWorldName,
406
- getPlanProgress,
407
- improveWorld,
408
- listWorlds,
409
- loadWorld,
410
- loadWorldFromDirectory,
411
- normalizeWorldMarkdown,
412
- parsePlanMarkdown,
413
- parseWorldMarkdown,
414
- readAuditLog,
415
- renderDecisionFlow,
416
- renderExplainText,
417
- renderImpactReport,
418
- renderImproveText,
419
- renderSimulateText,
420
- resolveProvider,
421
- resolveWorldPath,
422
- runInteractiveMode,
423
- runPipeMode,
424
- setActiveWorld,
425
- simulateWorld,
426
- summarizeAuditEvents,
427
- tickAgentStates,
428
- validateWorld,
429
- verdictToAuditEvent
430
- };