@neuroverseos/governance 0.3.0 → 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 (105) hide show
  1. package/README.md +20 -0
  2. package/package.json +16 -3
  3. package/policies/content-moderation-rules.txt +8 -0
  4. package/policies/marketing-rules.txt +8 -0
  5. package/policies/science-research-rules.txt +11 -0
  6. package/policies/social-media-rules.txt +7 -0
  7. package/policies/strict-rules.txt +8 -0
  8. package/policies/trading-rules.txt +8 -0
  9. package/simulate.html +1899 -0
  10. package/dist/adapters/autoresearch.cjs +0 -196
  11. package/dist/adapters/autoresearch.d.cts +0 -103
  12. package/dist/adapters/autoresearch.d.ts +0 -103
  13. package/dist/adapters/autoresearch.js +0 -7
  14. package/dist/adapters/express.cjs +0 -1114
  15. package/dist/adapters/express.d.cts +0 -66
  16. package/dist/adapters/express.d.ts +0 -66
  17. package/dist/adapters/express.js +0 -12
  18. package/dist/adapters/index.cjs +0 -1669
  19. package/dist/adapters/index.d.cts +0 -6
  20. package/dist/adapters/index.d.ts +0 -6
  21. package/dist/adapters/index.js +0 -46
  22. package/dist/adapters/langchain.cjs +0 -1155
  23. package/dist/adapters/langchain.d.cts +0 -89
  24. package/dist/adapters/langchain.d.ts +0 -89
  25. package/dist/adapters/langchain.js +0 -16
  26. package/dist/adapters/openai.cjs +0 -1185
  27. package/dist/adapters/openai.d.cts +0 -99
  28. package/dist/adapters/openai.d.ts +0 -99
  29. package/dist/adapters/openai.js +0 -16
  30. package/dist/adapters/openclaw.cjs +0 -1177
  31. package/dist/adapters/openclaw.d.cts +0 -99
  32. package/dist/adapters/openclaw.d.ts +0 -99
  33. package/dist/adapters/openclaw.js +0 -16
  34. package/dist/bootstrap-GXVDZNF7.js +0 -114
  35. package/dist/build-P42YFKQV.js +0 -339
  36. package/dist/chunk-2NICNKOM.js +0 -100
  37. package/dist/chunk-2PQU3VAN.js +0 -131
  38. package/dist/chunk-4A7LISES.js +0 -324
  39. package/dist/chunk-4JRYGIO7.js +0 -727
  40. package/dist/chunk-4NGDRRQH.js +0 -10
  41. package/dist/chunk-4QXB6PEO.js +0 -232
  42. package/dist/chunk-6CZSKEY5.js +0 -164
  43. package/dist/chunk-7P3S7MAY.js +0 -1090
  44. package/dist/chunk-A5W4GNQO.js +0 -130
  45. package/dist/chunk-AKW5YVCE.js +0 -96
  46. package/dist/chunk-BUWWN2NX.js +0 -192
  47. package/dist/chunk-COT5XS4V.js +0 -109
  48. package/dist/chunk-ER62HNGF.js +0 -139
  49. package/dist/chunk-FYS2CBUW.js +0 -304
  50. package/dist/chunk-GR6DGCZ2.js +0 -340
  51. package/dist/chunk-I3RRAYK2.js +0 -11
  52. package/dist/chunk-JZPQGIKR.js +0 -79
  53. package/dist/chunk-MWDQ4MJB.js +0 -11
  54. package/dist/chunk-NF5POFCI.js +0 -622
  55. package/dist/chunk-OGL7QXZS.js +0 -608
  56. package/dist/chunk-OT6PXH54.js +0 -61
  57. package/dist/chunk-PDOZHZWL.js +0 -225
  58. package/dist/chunk-Q6O7ZLO2.js +0 -62
  59. package/dist/chunk-QPASI2BR.js +0 -187
  60. package/dist/chunk-T5EUJQE5.js +0 -172
  61. package/dist/chunk-XPDMYECO.js +0 -642
  62. package/dist/chunk-YZFATT7X.js +0 -9
  63. package/dist/cli/neuroverse.cjs +0 -11448
  64. package/dist/cli/neuroverse.d.cts +0 -1
  65. package/dist/cli/neuroverse.d.ts +0 -1
  66. package/dist/cli/neuroverse.js +0 -196
  67. package/dist/cli/plan.cjs +0 -1599
  68. package/dist/cli/plan.d.cts +0 -20
  69. package/dist/cli/plan.d.ts +0 -20
  70. package/dist/cli/plan.js +0 -361
  71. package/dist/cli/run.cjs +0 -1746
  72. package/dist/cli/run.d.cts +0 -20
  73. package/dist/cli/run.d.ts +0 -20
  74. package/dist/cli/run.js +0 -143
  75. package/dist/configure-ai-TK67ZWZL.js +0 -132
  76. package/dist/derive-TLIV4OOU.js +0 -152
  77. package/dist/doctor-XPDLEYXN.js +0 -171
  78. package/dist/explain-IDCRWMPX.js +0 -70
  79. package/dist/guard-RV65TT4L.js +0 -96
  80. package/dist/guard-contract-WZx__PmU.d.cts +0 -709
  81. package/dist/guard-contract-WZx__PmU.d.ts +0 -709
  82. package/dist/guard-engine-JLTUARGU.js +0 -10
  83. package/dist/impact-XPECYRLH.js +0 -59
  84. package/dist/improve-GPUBKTEA.js +0 -85
  85. package/dist/index.cjs +0 -6273
  86. package/dist/index.d.cts +0 -1616
  87. package/dist/index.d.ts +0 -1616
  88. package/dist/index.js +0 -379
  89. package/dist/infer-world-7GVZWFX4.js +0 -543
  90. package/dist/init-PKPIYHYE.js +0 -144
  91. package/dist/init-world-VWMQZQC7.js +0 -223
  92. package/dist/mcp-server-FPVSU32Z.js +0 -13
  93. package/dist/model-adapter-BB7G4MFI.js +0 -11
  94. package/dist/playground-E664U4T6.js +0 -550
  95. package/dist/redteam-Z7WREJ44.js +0 -357
  96. package/dist/session-EKTRSR7C.js +0 -14
  97. package/dist/simulate-VDOYQFRO.js +0 -108
  98. package/dist/test-OGXJK4QU.js +0 -217
  99. package/dist/trace-JVF67VR3.js +0 -166
  100. package/dist/validate-LLBWVPGV.js +0 -81
  101. package/dist/validate-engine-UIABSIHD.js +0 -7
  102. package/dist/world-LAXO6DOX.js +0 -378
  103. package/dist/world-loader-HMPTOEA2.js +0 -9
  104. package/dist/worlds/autoresearch.nv-world.md +0 -230
  105. package/dist/worlds/derivation-world.nv-world.md +0 -278
package/dist/index.js DELETED
@@ -1,379 +0,0 @@
1
- import {
2
- generateImpactReport,
3
- generateImpactReportFromFile,
4
- renderImpactReport
5
- } from "./chunk-PDOZHZWL.js";
6
- import {
7
- VALIDATE_EXIT_CODES
8
- } from "./chunk-I3RRAYK2.js";
9
- import {
10
- GUARD_EXIT_CODES
11
- } from "./chunk-MWDQ4MJB.js";
12
- import {
13
- CompositeAuditLogger,
14
- ConsoleAuditLogger,
15
- FileAuditLogger,
16
- createGovernanceEngine,
17
- readAuditLog,
18
- summarizeAuditEvents,
19
- verdictToAuditEvent
20
- } from "./chunk-QPASI2BR.js";
21
- import {
22
- deriveWorld,
23
- extractWorldMarkdown,
24
- normalizeWorldMarkdown
25
- } from "./chunk-NF5POFCI.js";
26
- import {
27
- CONFIGURE_AI_EXIT_CODES,
28
- DERIVE_EXIT_CODES
29
- } from "./chunk-Q6O7ZLO2.js";
30
- import "./chunk-OT6PXH54.js";
31
- import {
32
- explainWorld,
33
- renderExplainText
34
- } from "./chunk-BUWWN2NX.js";
35
- import {
36
- improveWorld,
37
- renderImproveText
38
- } from "./chunk-GR6DGCZ2.js";
39
- import {
40
- renderSimulateText,
41
- simulateWorld
42
- } from "./chunk-FYS2CBUW.js";
43
- import {
44
- BOOTSTRAP_EXIT_CODES
45
- } from "./chunk-4NGDRRQH.js";
46
- import {
47
- emitWorldDefinition,
48
- parseWorldMarkdown
49
- } from "./chunk-XPDMYECO.js";
50
- import {
51
- PLAN_EXIT_CODES,
52
- parsePlanMarkdown
53
- } from "./chunk-6CZSKEY5.js";
54
- import {
55
- SessionManager,
56
- runInteractiveMode,
57
- runPipeMode
58
- } from "./chunk-4A7LISES.js";
59
- import {
60
- ModelAdapter,
61
- PROVIDERS,
62
- resolveProvider
63
- } from "./chunk-A5W4GNQO.js";
64
- import {
65
- McpGovernanceServer
66
- } from "./chunk-OGL7QXZS.js";
67
- import {
68
- describeActiveWorld,
69
- getActiveWorldName,
70
- listWorlds,
71
- resolveWorldPath,
72
- setActiveWorld
73
- } from "./chunk-AKW5YVCE.js";
74
- import {
75
- validateWorld
76
- } from "./chunk-7P3S7MAY.js";
77
- import {
78
- evaluateGuard,
79
- eventToAllowlistKey
80
- } from "./chunk-4JRYGIO7.js";
81
- import {
82
- advancePlan,
83
- buildPlanCheck,
84
- evaluatePlan,
85
- getPlanProgress
86
- } from "./chunk-4QXB6PEO.js";
87
- import {
88
- loadWorld,
89
- loadWorldFromDirectory
90
- } from "./chunk-JZPQGIKR.js";
91
- import "./chunk-YZFATT7X.js";
92
-
93
- // src/engine/verdict-formatter.ts
94
- var ANSI = {
95
- red: "\x1B[31m",
96
- green: "\x1B[32m",
97
- yellow: "\x1B[33m",
98
- bold: "\x1B[1m",
99
- dim: "\x1B[2m",
100
- reset: "\x1B[0m"
101
- };
102
- function c(text, ...codes) {
103
- return codes.join("") + text + ANSI.reset;
104
- }
105
- function formatVerdict(verdict, options = {}) {
106
- const {
107
- showRuleId = true,
108
- showEvidence = false,
109
- showWarning = true,
110
- color = false,
111
- compact = false
112
- } = options;
113
- if (compact) {
114
- return formatCompact(verdict, { showRuleId, showWarning, color });
115
- }
116
- return formatFull(verdict, { showRuleId, showEvidence, showWarning, color });
117
- }
118
- function formatCompact(verdict, opts) {
119
- const status = formatStatus(verdict.status, opts.color);
120
- const parts = [status];
121
- if (opts.showRuleId && verdict.ruleId) {
122
- parts.push(verdict.ruleId);
123
- }
124
- if (verdict.reason) {
125
- parts.push(verdict.reason);
126
- }
127
- if (opts.showWarning && verdict.warning) {
128
- parts.push(`warning: ${verdict.warning}`);
129
- }
130
- return parts.join(" \u2014 ");
131
- }
132
- function formatFull(verdict, opts) {
133
- const lines = [];
134
- lines.push(formatStatus(verdict.status, opts.color));
135
- if (opts.showRuleId && verdict.ruleId) {
136
- lines.push(` Rule: ${verdict.ruleId}`);
137
- }
138
- if (verdict.reason) {
139
- lines.push(` Reason: ${verdict.reason}`);
140
- }
141
- if (opts.showWarning && verdict.warning) {
142
- const label = opts.color ? c("Warning:", ANSI.yellow) : "Warning:";
143
- lines.push(` ${label} ${verdict.warning}`);
144
- }
145
- if (opts.showEvidence) {
146
- const ev = verdict.evidence;
147
- lines.push(` World: ${ev.worldName} v${ev.worldVersion}`);
148
- lines.push(` Invariants: ${ev.invariantsSatisfied}/${ev.invariantsTotal} covered`);
149
- if (ev.guardsMatched.length > 0) {
150
- lines.push(` Guards matched: ${ev.guardsMatched.join(", ")}`);
151
- }
152
- if (ev.rulesMatched.length > 0) {
153
- lines.push(` Rules matched: ${ev.rulesMatched.join(", ")}`);
154
- }
155
- lines.push(` Enforcement: ${ev.enforcementLevel}`);
156
- }
157
- return lines.join("\n");
158
- }
159
- function formatStatus(status, color) {
160
- switch (status) {
161
- case "ALLOW":
162
- return color ? c("ALLOWED", ANSI.green, ANSI.bold) : "ALLOWED";
163
- case "BLOCK":
164
- return color ? c("BLOCKED", ANSI.red, ANSI.bold) : "BLOCKED";
165
- case "PAUSE":
166
- return color ? c("PAUSED", ANSI.yellow, ANSI.bold) : "PAUSED";
167
- default:
168
- return status;
169
- }
170
- }
171
- function formatVerdictOneLine(verdict) {
172
- const parts = [verdict.status];
173
- if (verdict.ruleId) {
174
- parts[0] += `: ${verdict.ruleId}`;
175
- }
176
- if (verdict.reason) {
177
- parts.push(verdict.reason);
178
- }
179
- return parts.join(" \u2014 ");
180
- }
181
-
182
- // src/engine/condition-engine.ts
183
- function getFieldValue(event, field) {
184
- if (field.startsWith("args.")) {
185
- const key = field.slice(5);
186
- return event.args?.[key];
187
- }
188
- return event[field];
189
- }
190
- function toString(value) {
191
- if (value === null || value === void 0) return "";
192
- if (typeof value === "string") return value;
193
- if (typeof value === "number" || typeof value === "boolean") return String(value);
194
- return JSON.stringify(value);
195
- }
196
- function evaluateCondition(condition, event) {
197
- const fieldValue = getFieldValue(event, condition.field);
198
- if (fieldValue === void 0 && condition.operator !== "!=") {
199
- return { matched: false, evidence: null };
200
- }
201
- switch (condition.operator) {
202
- case "==":
203
- return evaluateEquals(fieldValue, condition.value);
204
- case "!=":
205
- return evaluateNotEquals(fieldValue, condition.value);
206
- case ">":
207
- return evaluateComparison(fieldValue, condition.value, (a, b) => a > b);
208
- case "<":
209
- return evaluateComparison(fieldValue, condition.value, (a, b) => a < b);
210
- case ">=":
211
- return evaluateComparison(fieldValue, condition.value, (a, b) => a >= b);
212
- case "<=":
213
- return evaluateComparison(fieldValue, condition.value, (a, b) => a <= b);
214
- case "in":
215
- return evaluateIn(fieldValue, condition.value);
216
- case "contains":
217
- return evaluateContains(fieldValue, condition.value);
218
- case "contains_any":
219
- return evaluateContainsAny(fieldValue, condition.value);
220
- case "matches_pattern":
221
- return evaluateMatchesPattern(fieldValue, condition.value);
222
- case "starts_with":
223
- return evaluateStartsWith(fieldValue, condition.value);
224
- case "ends_with":
225
- return evaluateEndsWith(fieldValue, condition.value);
226
- default:
227
- return { matched: false, evidence: null };
228
- }
229
- }
230
- function evaluateEquals(fieldValue, conditionValue) {
231
- const fieldStr = toString(fieldValue);
232
- const condStr = toString(conditionValue);
233
- const matched = fieldStr === condStr;
234
- return {
235
- matched,
236
- evidence: matched ? `${fieldStr} == ${condStr}` : null
237
- };
238
- }
239
- function evaluateNotEquals(fieldValue, conditionValue) {
240
- const fieldStr = toString(fieldValue);
241
- const condStr = toString(conditionValue);
242
- const matched = fieldStr !== condStr;
243
- return {
244
- matched,
245
- evidence: matched ? `${fieldStr} != ${condStr}` : null
246
- };
247
- }
248
- function evaluateComparison(fieldValue, conditionValue, comparator) {
249
- const a = Number(fieldValue);
250
- const b = Number(conditionValue);
251
- if (isNaN(a) || isNaN(b)) return { matched: false, evidence: null };
252
- const matched = comparator(a, b);
253
- return {
254
- matched,
255
- evidence: matched ? `${a} compared to ${b}` : null
256
- };
257
- }
258
- function evaluateIn(fieldValue, conditionValue) {
259
- if (!Array.isArray(conditionValue)) return { matched: false, evidence: null };
260
- const fieldStr = toString(fieldValue);
261
- const matched = conditionValue.some((v) => toString(v) === fieldStr);
262
- return {
263
- matched,
264
- evidence: matched ? `"${fieldStr}" found in [${conditionValue.join(", ")}]` : null
265
- };
266
- }
267
- function evaluateContains(fieldValue, conditionValue) {
268
- const fieldStr = toString(fieldValue).toLowerCase();
269
- const searchStr = toString(conditionValue).toLowerCase();
270
- const matched = fieldStr.includes(searchStr);
271
- return {
272
- matched,
273
- evidence: matched ? `"${searchStr}" found in field` : null
274
- };
275
- }
276
- function evaluateContainsAny(fieldValue, conditionValue) {
277
- if (!Array.isArray(conditionValue)) return { matched: false, evidence: null };
278
- const fieldStr = toString(fieldValue).toLowerCase();
279
- for (const pattern of conditionValue) {
280
- const patternLower = toString(pattern).toLowerCase();
281
- if (fieldStr.includes(patternLower)) {
282
- return {
283
- matched: true,
284
- evidence: `"${patternLower}" found in field`
285
- };
286
- }
287
- }
288
- return { matched: false, evidence: null };
289
- }
290
- function evaluateMatchesPattern(fieldValue, conditionValue) {
291
- const fieldStr = toString(fieldValue);
292
- const patterns = Array.isArray(conditionValue) ? conditionValue : [toString(conditionValue)];
293
- for (const pattern of patterns) {
294
- try {
295
- const regex = new RegExp(toString(pattern), "i");
296
- if (regex.test(fieldStr)) {
297
- return {
298
- matched: true,
299
- evidence: `matched pattern /${pattern}/`
300
- };
301
- }
302
- } catch {
303
- continue;
304
- }
305
- }
306
- return { matched: false, evidence: null };
307
- }
308
- function evaluateStartsWith(fieldValue, conditionValue) {
309
- const fieldStr = toString(fieldValue).toLowerCase();
310
- const prefix = toString(conditionValue).toLowerCase();
311
- const matched = fieldStr.startsWith(prefix);
312
- return {
313
- matched,
314
- evidence: matched ? `field starts with "${prefix}"` : null
315
- };
316
- }
317
- function evaluateEndsWith(fieldValue, conditionValue) {
318
- const fieldStr = toString(fieldValue).toLowerCase();
319
- const suffix = toString(conditionValue).toLowerCase();
320
- const matched = fieldStr.endsWith(suffix);
321
- return {
322
- matched,
323
- evidence: matched ? `field ends with "${suffix}"` : null
324
- };
325
- }
326
- export {
327
- BOOTSTRAP_EXIT_CODES,
328
- CONFIGURE_AI_EXIT_CODES,
329
- CompositeAuditLogger,
330
- ConsoleAuditLogger,
331
- DERIVE_EXIT_CODES,
332
- FileAuditLogger,
333
- GUARD_EXIT_CODES,
334
- McpGovernanceServer,
335
- ModelAdapter,
336
- PLAN_EXIT_CODES,
337
- PROVIDERS,
338
- SessionManager,
339
- VALIDATE_EXIT_CODES,
340
- advancePlan,
341
- buildPlanCheck,
342
- createGovernanceEngine,
343
- deriveWorld,
344
- describeActiveWorld,
345
- emitWorldDefinition,
346
- evaluateCondition,
347
- evaluateGuard,
348
- evaluatePlan,
349
- eventToAllowlistKey,
350
- explainWorld,
351
- extractWorldMarkdown,
352
- formatVerdict,
353
- formatVerdictOneLine,
354
- generateImpactReport,
355
- generateImpactReportFromFile,
356
- getActiveWorldName,
357
- getPlanProgress,
358
- improveWorld,
359
- listWorlds,
360
- loadWorld,
361
- loadWorldFromDirectory,
362
- normalizeWorldMarkdown,
363
- parsePlanMarkdown,
364
- parseWorldMarkdown,
365
- readAuditLog,
366
- renderExplainText,
367
- renderImpactReport,
368
- renderImproveText,
369
- renderSimulateText,
370
- resolveProvider,
371
- resolveWorldPath,
372
- runInteractiveMode,
373
- runPipeMode,
374
- setActiveWorld,
375
- simulateWorld,
376
- summarizeAuditEvents,
377
- validateWorld,
378
- verdictToAuditEvent
379
- };