@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
@@ -1,10 +0,0 @@
1
- // src/contracts/bootstrap-contract.ts
2
- var BOOTSTRAP_EXIT_CODES = {
3
- SUCCESS: 0,
4
- FAIL: 1,
5
- ERROR: 3
6
- };
7
-
8
- export {
9
- BOOTSTRAP_EXIT_CODES
10
- };
@@ -1,232 +0,0 @@
1
- // src/engine/plan-engine.ts
2
- function keywordMatch(eventText, step) {
3
- const stepText = [
4
- step.label,
5
- step.description ?? "",
6
- ...step.tags ?? []
7
- ].join(" ").toLowerCase();
8
- const keywords = stepText.split(/\s+/).filter((w) => w.length > 3);
9
- if (keywords.length === 0) return false;
10
- const matched = keywords.filter((kw) => eventText.includes(kw));
11
- return matched.length >= Math.ceil(keywords.length * 0.5);
12
- }
13
- function tokenSimilarity(a, b) {
14
- const tokensA = new Set(a.toLowerCase().split(/\s+/).filter((w) => w.length > 2));
15
- const tokensB = new Set(b.toLowerCase().split(/\s+/).filter((w) => w.length > 2));
16
- if (tokensA.size === 0 || tokensB.size === 0) return 0;
17
- let intersection = 0;
18
- for (const t of tokensA) {
19
- if (tokensB.has(t)) intersection++;
20
- }
21
- const union = (/* @__PURE__ */ new Set([...tokensA, ...tokensB])).size;
22
- return union > 0 ? intersection / union : 0;
23
- }
24
- function findMatchingStep(eventText, event, steps) {
25
- const pendingOrActive = steps.filter((s) => s.status === "pending" || s.status === "active");
26
- if (pendingOrActive.length === 0) {
27
- return { matched: null, closest: null, closestScore: 0 };
28
- }
29
- for (const step of pendingOrActive) {
30
- if (keywordMatch(eventText, step)) {
31
- if (step.tools && event.tool && !step.tools.includes(event.tool)) {
32
- continue;
33
- }
34
- return { matched: step, closest: step, closestScore: 1 };
35
- }
36
- }
37
- const intentText = [event.intent, event.tool ?? "", event.scope ?? ""].join(" ");
38
- let bestStep = null;
39
- let bestScore = 0;
40
- for (const step of pendingOrActive) {
41
- const stepText = [step.label, step.description ?? "", ...step.tags ?? []].join(" ");
42
- const score = tokenSimilarity(intentText, stepText);
43
- if (score > bestScore) {
44
- bestScore = score;
45
- bestStep = step;
46
- }
47
- }
48
- const SIMILARITY_THRESHOLD = 0.35;
49
- if (bestScore >= SIMILARITY_THRESHOLD && bestStep) {
50
- if (bestStep.tools && event.tool && !bestStep.tools.includes(event.tool)) {
51
- return { matched: null, closest: bestStep, closestScore: bestScore };
52
- }
53
- return { matched: bestStep, closest: bestStep, closestScore: bestScore };
54
- }
55
- return { matched: null, closest: bestStep, closestScore: bestScore };
56
- }
57
- function isSequenceValid(step, plan) {
58
- if (!plan.sequential) return true;
59
- if (!step.requires || step.requires.length === 0) return true;
60
- return step.requires.every((reqId) => {
61
- const reqStep = plan.steps.find((s) => s.id === reqId);
62
- return reqStep?.status === "completed";
63
- });
64
- }
65
- function checkConstraints(event, eventText, constraints) {
66
- const checks = [];
67
- for (const constraint of constraints) {
68
- if (constraint.type === "approval") {
69
- if (constraint.trigger && eventText.includes(constraint.trigger.substring(0, 10).toLowerCase())) {
70
- checks.push({ constraintId: constraint.id, passed: false, reason: constraint.description });
71
- return { violated: constraint, checks };
72
- }
73
- const keywords = constraint.description.toLowerCase().split(/\s+/).filter((w) => w.length > 3);
74
- const relevant = keywords.some((kw) => eventText.includes(kw));
75
- if (relevant) {
76
- checks.push({ constraintId: constraint.id, passed: false, reason: constraint.description });
77
- return { violated: constraint, checks };
78
- }
79
- checks.push({ constraintId: constraint.id, passed: true });
80
- continue;
81
- }
82
- if (constraint.type === "scope" && constraint.trigger) {
83
- const keywords = constraint.trigger.split(/\s+/).filter((w) => w.length > 3);
84
- const violated = keywords.length > 0 && keywords.every((kw) => eventText.includes(kw));
85
- checks.push({
86
- constraintId: constraint.id,
87
- passed: !violated,
88
- reason: violated ? constraint.description : void 0
89
- });
90
- if (violated) {
91
- return { violated: constraint, checks };
92
- }
93
- continue;
94
- }
95
- checks.push({ constraintId: constraint.id, passed: true });
96
- }
97
- return { violated: null, checks };
98
- }
99
- function getPlanProgress(plan) {
100
- const completed = plan.steps.filter((s) => s.status === "completed").length;
101
- const total = plan.steps.length;
102
- return {
103
- completed,
104
- total,
105
- percentage: total > 0 ? Math.round(completed / total * 100) : 0
106
- };
107
- }
108
- function advancePlan(plan, stepId, evidence) {
109
- const step = plan.steps.find((s) => s.id === stepId);
110
- if (!step) {
111
- return { success: false, reason: `Step "${stepId}" not found in plan.` };
112
- }
113
- if (step.status === "completed") {
114
- return { success: false, reason: `Step "${stepId}" is already completed.` };
115
- }
116
- const mode = plan.completion ?? "trust";
117
- if (mode === "verified" && step.verify) {
118
- if (!evidence) {
119
- return {
120
- success: false,
121
- reason: `Step "${step.label}" requires evidence (verify: ${step.verify}). Provide evidence to advance.`
122
- };
123
- }
124
- if (evidence.type !== step.verify) {
125
- return {
126
- success: false,
127
- reason: `Evidence type "${evidence.type}" does not match required verification "${step.verify}".`
128
- };
129
- }
130
- }
131
- const updatedPlan = {
132
- ...plan,
133
- steps: plan.steps.map(
134
- (s) => s.id === stepId ? { ...s, status: "completed" } : s
135
- )
136
- };
137
- return {
138
- success: true,
139
- plan: updatedPlan,
140
- evidence: evidence ?? void 0
141
- };
142
- }
143
- function evaluatePlan(event, plan) {
144
- const progress = getPlanProgress(plan);
145
- if (plan.expires_at) {
146
- const expiresAt = new Date(plan.expires_at).getTime();
147
- if (Date.now() > expiresAt) {
148
- return {
149
- allowed: true,
150
- status: "PLAN_COMPLETE",
151
- reason: "Plan has expired.",
152
- progress
153
- };
154
- }
155
- }
156
- if (progress.completed === progress.total) {
157
- return {
158
- allowed: true,
159
- status: "PLAN_COMPLETE",
160
- reason: "All plan steps are completed.",
161
- progress
162
- };
163
- }
164
- const eventText = [
165
- event.intent,
166
- event.tool ?? "",
167
- event.scope ?? ""
168
- ].join(" ").toLowerCase();
169
- const { matched, closest, closestScore } = findMatchingStep(eventText, event, plan.steps);
170
- if (!matched) {
171
- return {
172
- allowed: false,
173
- status: "OFF_PLAN",
174
- reason: "Action does not match any plan step.",
175
- closestStep: closest?.label,
176
- similarityScore: closestScore,
177
- progress
178
- };
179
- }
180
- if (!isSequenceValid(matched, plan)) {
181
- const pendingDeps = (matched.requires ?? []).filter((reqId) => plan.steps.find((s) => s.id === reqId)?.status !== "completed").join(", ");
182
- return {
183
- allowed: false,
184
- status: "OFF_PLAN",
185
- reason: `Step "${matched.label}" requires completion of: ${pendingDeps}`,
186
- matchedStep: matched.id,
187
- progress
188
- };
189
- }
190
- const { violated } = checkConstraints(event, eventText, plan.constraints);
191
- if (violated) {
192
- return {
193
- allowed: false,
194
- status: "CONSTRAINT_VIOLATED",
195
- reason: violated.description,
196
- matchedStep: matched.id,
197
- progress
198
- };
199
- }
200
- return {
201
- allowed: true,
202
- status: "ON_PLAN",
203
- reason: `Matches step: ${matched.label}`,
204
- matchedStep: matched.id,
205
- progress
206
- };
207
- }
208
- function buildPlanCheck(event, plan, verdict) {
209
- const eventText = [event.intent, event.tool ?? "", event.scope ?? ""].join(" ").toLowerCase();
210
- const { matched, closest, closestScore } = findMatchingStep(eventText, event, plan.steps);
211
- const { checks: constraintChecks } = checkConstraints(event, eventText, plan.constraints);
212
- const progress = getPlanProgress(plan);
213
- return {
214
- planId: plan.plan_id,
215
- matched: !!matched,
216
- matchedStepId: matched?.id,
217
- matchedStepLabel: matched?.label,
218
- closestStepId: !matched ? closest?.id : void 0,
219
- closestStepLabel: !matched ? closest?.label : void 0,
220
- similarityScore: !matched ? closestScore : void 0,
221
- sequenceValid: matched ? isSequenceValid(matched, plan) : void 0,
222
- constraintsChecked: constraintChecks,
223
- progress: { completed: progress.completed, total: progress.total }
224
- };
225
- }
226
-
227
- export {
228
- getPlanProgress,
229
- advancePlan,
230
- evaluatePlan,
231
- buildPlanCheck
232
- };
@@ -1,164 +0,0 @@
1
- // src/engine/plan-parser.ts
2
- function slugify(text) {
3
- return text.toLowerCase().replace(/[^a-z0-9\s]/g, "").trim().replace(/\s+/g, "_");
4
- }
5
- function extractBracketAnnotation(line, key) {
6
- const regex = new RegExp(`\\[${key}:\\s*([^\\]]+)\\]`, "i");
7
- const match = line.match(regex);
8
- if (!match) return null;
9
- return match[1].split(",").map((s) => s.trim()).filter(Boolean);
10
- }
11
- function extractParenAnnotation(line, key) {
12
- const regex = new RegExp(`\\(${key}:\\s*([^)]+)\\)`, "i");
13
- const match = line.match(regex);
14
- if (!match) return null;
15
- return match[1].split(",").map((s) => s.trim()).filter(Boolean);
16
- }
17
- function stripAnnotations(line) {
18
- return line.replace(/\[(?:tools|tag|verify|type):\s*[^\]]+\]/gi, "").replace(/\((?:after):\s*[^)]+\)/gi, "").trim();
19
- }
20
- function parseFrontmatter(content) {
21
- const frontmatter = {};
22
- const fmMatch = content.match(/^---\s*\n([\s\S]*?)\n---\s*\n/);
23
- if (!fmMatch) {
24
- return { frontmatter, body: content };
25
- }
26
- const fmBody = fmMatch[1];
27
- for (const line of fmBody.split("\n")) {
28
- const colonIndex = line.indexOf(":");
29
- if (colonIndex > 0) {
30
- const key = line.slice(0, colonIndex).trim();
31
- const value = line.slice(colonIndex + 1).trim();
32
- frontmatter[key] = value;
33
- }
34
- }
35
- return { frontmatter, body: content.slice(fmMatch[0].length) };
36
- }
37
- function parseSections(body) {
38
- const steps = [];
39
- const constraints = [];
40
- let currentSection = "none";
41
- for (const line of body.split("\n")) {
42
- const trimmed = line.trim();
43
- if (/^#+\s*Steps/i.test(trimmed)) {
44
- currentSection = "steps";
45
- continue;
46
- }
47
- if (/^#+\s*Constraints/i.test(trimmed)) {
48
- currentSection = "constraints";
49
- continue;
50
- }
51
- if (/^#+\s/.test(trimmed) && currentSection !== "none") {
52
- currentSection = "none";
53
- continue;
54
- }
55
- if (trimmed.startsWith("- ")) {
56
- const item = trimmed.slice(2).trim();
57
- if (currentSection === "steps") {
58
- steps.push(item);
59
- } else if (currentSection === "constraints") {
60
- constraints.push(item);
61
- }
62
- }
63
- }
64
- return { steps, constraints };
65
- }
66
- function parseStep(raw) {
67
- const label = stripAnnotations(raw);
68
- const id = slugify(label);
69
- const tools = extractBracketAnnotation(raw, "tools");
70
- const tags = extractBracketAnnotation(raw, "tag");
71
- const verifyArr = extractBracketAnnotation(raw, "verify");
72
- const requires = extractParenAnnotation(raw, "after");
73
- return {
74
- id,
75
- label,
76
- tools: tools ?? void 0,
77
- tags: tags ?? void 0,
78
- verify: verifyArr?.[0] ?? void 0,
79
- requires: requires ?? void 0,
80
- status: "pending"
81
- };
82
- }
83
- function parseConstraint(raw, index) {
84
- const typeAnnotation = extractBracketAnnotation(raw, "type");
85
- const description = stripAnnotations(raw);
86
- const id = `constraint_${index}`;
87
- let type = "custom";
88
- let enforcement = "block";
89
- let limit;
90
- let unit;
91
- if (typeAnnotation?.[0] === "approval") {
92
- type = "approval";
93
- enforcement = "pause";
94
- } else if (/budget|\$|spending|cost/i.test(description)) {
95
- type = "budget";
96
- const amountMatch = description.match(/\$?([\d,]+)/);
97
- if (amountMatch) {
98
- limit = parseInt(amountMatch[1].replace(/,/g, ""), 10);
99
- unit = "USD";
100
- }
101
- } else if (/time|hour|minute|day|deadline/i.test(description)) {
102
- type = "time";
103
- } else if (/scope|access|database|production/i.test(description)) {
104
- type = "scope";
105
- }
106
- const trigger = description.toLowerCase();
107
- return {
108
- id,
109
- type,
110
- description,
111
- enforcement,
112
- limit,
113
- unit,
114
- trigger
115
- };
116
- }
117
- function parsePlanMarkdown(markdown) {
118
- const errors = [];
119
- const { frontmatter, body } = parseFrontmatter(markdown.trim());
120
- const { steps: stepLines, constraints: constraintLines } = parseSections(body);
121
- if (!frontmatter.plan_id) {
122
- errors.push("Missing required field: plan_id");
123
- }
124
- if (stepLines.length === 0) {
125
- errors.push("Plan must have at least one step");
126
- }
127
- if (errors.length > 0) {
128
- return { success: false, errors };
129
- }
130
- const steps = stepLines.map((line) => parseStep(line));
131
- const constraints = constraintLines.map((line, i) => parseConstraint(line, i));
132
- let expires_at;
133
- if (frontmatter.expires) {
134
- expires_at = new Date(frontmatter.expires).toISOString();
135
- }
136
- const completionRaw = frontmatter.completion?.toLowerCase();
137
- const completion = completionRaw === "verified" ? "verified" : "trust";
138
- const plan = {
139
- plan_id: frontmatter.plan_id,
140
- objective: frontmatter.objective ?? "",
141
- sequential: frontmatter.sequential === "true",
142
- completion,
143
- steps,
144
- constraints,
145
- world_id: frontmatter.world ?? void 0,
146
- created_at: (/* @__PURE__ */ new Date()).toISOString(),
147
- expires_at
148
- };
149
- return { success: true, plan, errors: [] };
150
- }
151
-
152
- // src/contracts/plan-contract.ts
153
- var PLAN_EXIT_CODES = {
154
- ON_PLAN: 0,
155
- OFF_PLAN: 1,
156
- CONSTRAINT_VIOLATED: 2,
157
- ERROR: 3,
158
- PLAN_COMPLETE: 4
159
- };
160
-
161
- export {
162
- parsePlanMarkdown,
163
- PLAN_EXIT_CODES
164
- };