@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.
- package/package.json +4 -2
- package/policies/content-moderation-rules.txt +8 -0
- package/policies/marketing-rules.txt +8 -0
- package/policies/science-research-rules.txt +11 -0
- package/policies/social-media-rules.txt +7 -0
- package/policies/strict-rules.txt +8 -0
- package/policies/trading-rules.txt +8 -0
- package/simulate.html +1899 -0
- package/dist/adapters/autoresearch.cjs +0 -196
- package/dist/adapters/autoresearch.d.cts +0 -103
- package/dist/adapters/autoresearch.d.ts +0 -103
- package/dist/adapters/autoresearch.js +0 -7
- package/dist/adapters/deep-agents.cjs +0 -1472
- package/dist/adapters/deep-agents.d.cts +0 -181
- package/dist/adapters/deep-agents.d.ts +0 -181
- package/dist/adapters/deep-agents.js +0 -17
- package/dist/adapters/express.cjs +0 -1196
- package/dist/adapters/express.d.cts +0 -66
- package/dist/adapters/express.d.ts +0 -66
- package/dist/adapters/express.js +0 -12
- package/dist/adapters/index.cjs +0 -2038
- package/dist/adapters/index.d.cts +0 -8
- package/dist/adapters/index.d.ts +0 -8
- package/dist/adapters/index.js +0 -68
- package/dist/adapters/langchain.cjs +0 -1259
- package/dist/adapters/langchain.d.cts +0 -89
- package/dist/adapters/langchain.d.ts +0 -89
- package/dist/adapters/langchain.js +0 -17
- package/dist/adapters/openai.cjs +0 -1289
- package/dist/adapters/openai.d.cts +0 -99
- package/dist/adapters/openai.d.ts +0 -99
- package/dist/adapters/openai.js +0 -17
- package/dist/adapters/openclaw.cjs +0 -1281
- package/dist/adapters/openclaw.d.cts +0 -99
- package/dist/adapters/openclaw.d.ts +0 -99
- package/dist/adapters/openclaw.js +0 -17
- package/dist/bootstrap-GXVDZNF7.js +0 -114
- package/dist/build-X5MZY4IA.js +0 -339
- package/dist/chunk-4L6OPKMQ.js +0 -100
- package/dist/chunk-4NGDRRQH.js +0 -10
- package/dist/chunk-5U2MQO5P.js +0 -57
- package/dist/chunk-6BB55YJI.js +0 -113
- package/dist/chunk-6CZSKEY5.js +0 -164
- package/dist/chunk-7P3S7MAY.js +0 -1090
- package/dist/chunk-A5W4GNQO.js +0 -130
- package/dist/chunk-AF2VX4AL.js +0 -363
- package/dist/chunk-AKW5YVCE.js +0 -96
- package/dist/chunk-BMOXICAB.js +0 -340
- package/dist/chunk-BQZMOEML.js +0 -43
- package/dist/chunk-D2UCV5AK.js +0 -326
- package/dist/chunk-EVDJUSZ2.js +0 -91
- package/dist/chunk-FYS2CBUW.js +0 -304
- package/dist/chunk-I3RRAYK2.js +0 -11
- package/dist/chunk-IZSO75NZ.js +0 -792
- package/dist/chunk-JCKSW2PZ.js +0 -304
- package/dist/chunk-JZPQGIKR.js +0 -79
- package/dist/chunk-KTFTTLTP.js +0 -246
- package/dist/chunk-MH7BT4VH.js +0 -15
- package/dist/chunk-ORJ3NOE6.js +0 -622
- package/dist/chunk-OT6PXH54.js +0 -61
- package/dist/chunk-Q6O7ZLO2.js +0 -62
- package/dist/chunk-QLPTHTVB.js +0 -253
- package/dist/chunk-REXY4LUL.js +0 -226
- package/dist/chunk-T5EUJQE5.js +0 -172
- package/dist/chunk-TTBKTF3P.js +0 -608
- package/dist/chunk-XPDMYECO.js +0 -642
- package/dist/chunk-YZFATT7X.js +0 -9
- package/dist/chunk-ZIVQNSZU.js +0 -119
- package/dist/chunk-ZJTDUCC2.js +0 -194
- package/dist/cli/neuroverse.cjs +0 -12564
- package/dist/cli/neuroverse.d.cts +0 -1
- package/dist/cli/neuroverse.d.ts +0 -1
- package/dist/cli/neuroverse.js +0 -208
- package/dist/cli/plan.cjs +0 -1686
- package/dist/cli/plan.d.cts +0 -20
- package/dist/cli/plan.d.ts +0 -20
- package/dist/cli/plan.js +0 -353
- package/dist/cli/run.cjs +0 -1945
- package/dist/cli/run.d.cts +0 -20
- package/dist/cli/run.d.ts +0 -20
- package/dist/cli/run.js +0 -143
- package/dist/configure-ai-TK67ZWZL.js +0 -132
- package/dist/decision-flow-LETV5NWY.js +0 -61
- package/dist/derive-7365SUFU.js +0 -152
- package/dist/doctor-QYISMKEL.js +0 -173
- package/dist/equity-penalties-63FGB3I2.js +0 -244
- package/dist/explain-A2EWI2OL.js +0 -51
- package/dist/guard-3BWL3IGH.js +0 -92
- package/dist/guard-contract-C9_zKbzd.d.cts +0 -821
- package/dist/guard-contract-C9_zKbzd.d.ts +0 -821
- package/dist/guard-engine-QFMIBWJY.js +0 -10
- package/dist/impact-UB6DXKSX.js +0 -59
- package/dist/improve-XZA57GER.js +0 -66
- package/dist/index.cjs +0 -6821
- package/dist/index.d.cts +0 -1829
- package/dist/index.d.ts +0 -1829
- package/dist/index.js +0 -430
- package/dist/infer-world-7GVZWFX4.js +0 -543
- package/dist/init-PKPIYHYE.js +0 -144
- package/dist/init-world-VWMQZQC7.js +0 -223
- package/dist/mcp-server-XWQZXNW7.js +0 -13
- package/dist/model-adapter-BB7G4MFI.js +0 -11
- package/dist/playground-ADWZORNV.js +0 -550
- package/dist/redteam-JRQ7FD2F.js +0 -357
- package/dist/session-MMYX5YCF.js +0 -15
- package/dist/shared--Q8wPBVN.d.ts +0 -60
- package/dist/shared-HpAG90PX.d.cts +0 -60
- package/dist/shared-U2QFV7JH.js +0 -16
- package/dist/simulate-GMIFFXYV.js +0 -83
- package/dist/test-JBBZ65X4.js +0 -217
- package/dist/trace-3MYWIDEF.js +0 -166
- package/dist/validate-LLBWVPGV.js +0 -81
- package/dist/validate-engine-UIABSIHD.js +0 -7
- package/dist/world-BFJCIQSH.js +0 -378
- package/dist/world-loader-HMPTOEA2.js +0 -9
- package/dist/worlds/autoresearch.nv-world.md +0 -230
- package/dist/worlds/coding-agent.nv-world.md +0 -211
- package/dist/worlds/derivation-world.nv-world.md +0 -278
package/dist/chunk-ZIVQNSZU.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GovernanceBlockedError,
|
|
3
|
-
buildEngineOptions,
|
|
4
|
-
defaultBlockMessage,
|
|
5
|
-
extractScope,
|
|
6
|
-
trackPlanProgress
|
|
7
|
-
} from "./chunk-5U2MQO5P.js";
|
|
8
|
-
import {
|
|
9
|
-
evaluateGuard
|
|
10
|
-
} from "./chunk-IZSO75NZ.js";
|
|
11
|
-
import {
|
|
12
|
-
loadWorld
|
|
13
|
-
} from "./chunk-JZPQGIKR.js";
|
|
14
|
-
|
|
15
|
-
// src/adapters/openai.ts
|
|
16
|
-
var GovernanceBlockedError2 = class extends GovernanceBlockedError {
|
|
17
|
-
toolCallId;
|
|
18
|
-
constructor(verdict, toolCallId) {
|
|
19
|
-
super(verdict);
|
|
20
|
-
this.toolCallId = toolCallId;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
function defaultMapFunctionCall(name, args) {
|
|
24
|
-
return {
|
|
25
|
-
intent: name,
|
|
26
|
-
tool: name,
|
|
27
|
-
scope: extractScope(args),
|
|
28
|
-
args,
|
|
29
|
-
direction: "input"
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
var GovernedToolExecutor = class {
|
|
33
|
-
world;
|
|
34
|
-
options;
|
|
35
|
-
engineOptions;
|
|
36
|
-
mapFn;
|
|
37
|
-
blockMsg;
|
|
38
|
-
activePlan;
|
|
39
|
-
constructor(world, options = {}) {
|
|
40
|
-
this.world = world;
|
|
41
|
-
this.options = options;
|
|
42
|
-
this.activePlan = options.plan;
|
|
43
|
-
this.engineOptions = buildEngineOptions(options, this.activePlan);
|
|
44
|
-
this.mapFn = options.mapFunctionCall ?? defaultMapFunctionCall;
|
|
45
|
-
this.blockMsg = options.blockMessage ?? defaultBlockMessage;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Evaluate a single tool call against governance rules.
|
|
49
|
-
* Returns the verdict without executing the tool.
|
|
50
|
-
*/
|
|
51
|
-
evaluate(toolCall) {
|
|
52
|
-
let args;
|
|
53
|
-
try {
|
|
54
|
-
args = JSON.parse(toolCall.function.arguments);
|
|
55
|
-
} catch {
|
|
56
|
-
args = { raw: toolCall.function.arguments };
|
|
57
|
-
}
|
|
58
|
-
const event = this.mapFn(toolCall.function.name, args);
|
|
59
|
-
this.engineOptions.plan = this.activePlan;
|
|
60
|
-
const verdict = evaluateGuard(event, this.world, this.engineOptions);
|
|
61
|
-
this.options.onEvaluate?.(verdict, event);
|
|
62
|
-
if (verdict.status === "ALLOW") {
|
|
63
|
-
trackPlanProgress(event, this, this.options);
|
|
64
|
-
}
|
|
65
|
-
return verdict;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Execute a tool call with governance enforcement.
|
|
69
|
-
*
|
|
70
|
-
* If ALLOW: runs the tool and returns the result.
|
|
71
|
-
* If BLOCK: returns a blocked message (no execution).
|
|
72
|
-
* If PAUSE: throws — caller must handle approval flow.
|
|
73
|
-
*
|
|
74
|
-
* @param toolCall - The OpenAI tool call to evaluate
|
|
75
|
-
* @param runner - The actual tool execution function
|
|
76
|
-
* @returns A tool result message ready for the OpenAI API
|
|
77
|
-
*/
|
|
78
|
-
async execute(toolCall, runner) {
|
|
79
|
-
const verdict = this.evaluate(toolCall);
|
|
80
|
-
if (verdict.status === "BLOCK") {
|
|
81
|
-
return {
|
|
82
|
-
tool_call_id: toolCall.id,
|
|
83
|
-
role: "tool",
|
|
84
|
-
content: this.blockMsg(verdict),
|
|
85
|
-
_verdict: verdict
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
if (verdict.status === "PAUSE") {
|
|
89
|
-
throw new GovernanceBlockedError2(verdict, toolCall.id);
|
|
90
|
-
}
|
|
91
|
-
let args;
|
|
92
|
-
try {
|
|
93
|
-
args = JSON.parse(toolCall.function.arguments);
|
|
94
|
-
} catch {
|
|
95
|
-
args = { raw: toolCall.function.arguments };
|
|
96
|
-
}
|
|
97
|
-
const content = await runner(toolCall.function.name, args);
|
|
98
|
-
return {
|
|
99
|
-
tool_call_id: toolCall.id,
|
|
100
|
-
role: "tool",
|
|
101
|
-
content,
|
|
102
|
-
_verdict: verdict
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
async function createGovernedToolExecutor(worldPath, options) {
|
|
107
|
-
const world = await loadWorld(worldPath);
|
|
108
|
-
return new GovernedToolExecutor(world, options);
|
|
109
|
-
}
|
|
110
|
-
function createGovernedToolExecutorFromWorld(world, options) {
|
|
111
|
-
return new GovernedToolExecutor(world, options);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export {
|
|
115
|
-
GovernanceBlockedError2 as GovernanceBlockedError,
|
|
116
|
-
GovernedToolExecutor,
|
|
117
|
-
createGovernedToolExecutor,
|
|
118
|
-
createGovernedToolExecutorFromWorld
|
|
119
|
-
};
|
package/dist/chunk-ZJTDUCC2.js
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
// src/engine/rule-utils.ts
|
|
2
|
-
function collectAllEffects(rule) {
|
|
3
|
-
const effects = [...rule.effects ?? []];
|
|
4
|
-
for (const ce of rule.effects_conditional ?? []) {
|
|
5
|
-
effects.push(...ce.effects);
|
|
6
|
-
}
|
|
7
|
-
return effects;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
// src/engine/explain-engine.ts
|
|
11
|
-
function detectTensions(rules) {
|
|
12
|
-
const increases = /* @__PURE__ */ new Map();
|
|
13
|
-
const decreases = /* @__PURE__ */ new Map();
|
|
14
|
-
for (const rule of rules) {
|
|
15
|
-
const allEffects = collectAllEffects(rule);
|
|
16
|
-
for (const effect of allEffects) {
|
|
17
|
-
const target = effect.target;
|
|
18
|
-
const isIncrease = effect.operation === "add" || effect.operation === "multiply" && typeof effect.value === "number" && effect.value > 1;
|
|
19
|
-
const isDecrease = effect.operation === "subtract" || effect.operation === "multiply" && typeof effect.value === "number" && effect.value < 1;
|
|
20
|
-
if (isIncrease) {
|
|
21
|
-
if (!increases.has(target)) increases.set(target, []);
|
|
22
|
-
increases.get(target).push(rule.label);
|
|
23
|
-
}
|
|
24
|
-
if (isDecrease) {
|
|
25
|
-
if (!decreases.has(target)) decreases.set(target, []);
|
|
26
|
-
decreases.get(target).push(rule.label);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
const tensions = [];
|
|
31
|
-
for (const [variable, incRules] of increases) {
|
|
32
|
-
const decRules = decreases.get(variable);
|
|
33
|
-
if (decRules && decRules.length > 0) {
|
|
34
|
-
tensions.push({
|
|
35
|
-
variable,
|
|
36
|
-
increasedBy: incRules,
|
|
37
|
-
decreasedBy: decRules
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return tensions;
|
|
42
|
-
}
|
|
43
|
-
function explainWorld(world) {
|
|
44
|
-
const dynamics = [...world.rules].sort((a, b) => a.order - b.order).map((rule) => {
|
|
45
|
-
const allEffects = collectAllEffects(rule);
|
|
46
|
-
return {
|
|
47
|
-
ruleId: rule.id,
|
|
48
|
-
label: rule.label,
|
|
49
|
-
severity: rule.severity,
|
|
50
|
-
triggerDescription: rule.causal_translation?.trigger_text ?? describeTriggers(rule),
|
|
51
|
-
effectDescription: rule.causal_translation?.effect_text ?? describeEffects(allEffects),
|
|
52
|
-
targets: [...new Set(allEffects.map((e) => e.target))]
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
const stateVariables = Object.entries(world.stateSchema.variables ?? {}).map(
|
|
56
|
-
([name, v]) => ({
|
|
57
|
-
name,
|
|
58
|
-
label: v.label || name,
|
|
59
|
-
type: v.type,
|
|
60
|
-
defaultValue: v.default,
|
|
61
|
-
range: v.type === "number" && v.min !== void 0 && v.max !== void 0 ? `${v.min}\u2013${v.max}` : v.type === "enum" && v.options ? v.options.join(", ") : void 0
|
|
62
|
-
})
|
|
63
|
-
);
|
|
64
|
-
const invariants = world.invariants.map((inv) => ({
|
|
65
|
-
id: inv.id,
|
|
66
|
-
label: inv.label,
|
|
67
|
-
enforcement: inv.enforcement
|
|
68
|
-
}));
|
|
69
|
-
const gates = (world.gates.viability_classification ?? []).map((g) => ({
|
|
70
|
-
status: g.status,
|
|
71
|
-
field: g.field,
|
|
72
|
-
threshold: `${g.operator} ${g.value}`
|
|
73
|
-
}));
|
|
74
|
-
const tensions = detectTensions(world.rules);
|
|
75
|
-
const outcomes = (world.outcomes.computed_outcomes ?? []).map((o) => ({
|
|
76
|
-
id: o.id,
|
|
77
|
-
label: o.label,
|
|
78
|
-
type: o.type,
|
|
79
|
-
primary: o.primary ?? false
|
|
80
|
-
}));
|
|
81
|
-
const stats = {
|
|
82
|
-
invariants: world.invariants.length,
|
|
83
|
-
stateVariables: Object.keys(world.stateSchema.variables ?? {}).length,
|
|
84
|
-
rules: world.rules.length,
|
|
85
|
-
gates: (world.gates.viability_classification ?? []).length,
|
|
86
|
-
outcomes: (world.outcomes.computed_outcomes ?? []).length,
|
|
87
|
-
assumptions: Object.keys(world.assumptions.profiles ?? {}).length
|
|
88
|
-
};
|
|
89
|
-
return {
|
|
90
|
-
worldName: world.world.name,
|
|
91
|
-
worldId: world.world.world_id,
|
|
92
|
-
thesis: world.world.thesis,
|
|
93
|
-
dynamics,
|
|
94
|
-
stateVariables,
|
|
95
|
-
invariants,
|
|
96
|
-
gates,
|
|
97
|
-
tensions,
|
|
98
|
-
outcomes,
|
|
99
|
-
stats
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
function describeTriggers(rule) {
|
|
103
|
-
if (!rule.triggers || rule.triggers.length === 0) return "Always active";
|
|
104
|
-
return rule.triggers.map((t) => `${t.field} ${t.operator} ${t.value}`).join(" AND ");
|
|
105
|
-
}
|
|
106
|
-
function describeEffects(effects) {
|
|
107
|
-
if (effects.length === 0) return "No direct effects";
|
|
108
|
-
return effects.map((e) => {
|
|
109
|
-
switch (e.operation) {
|
|
110
|
-
case "multiply":
|
|
111
|
-
return `${e.target} scaled by ${e.value}`;
|
|
112
|
-
case "add":
|
|
113
|
-
return `${e.target} increased by ${e.value}`;
|
|
114
|
-
case "subtract":
|
|
115
|
-
return `${e.target} decreased by ${e.value}`;
|
|
116
|
-
case "set":
|
|
117
|
-
return `${e.target} set to ${e.value}`;
|
|
118
|
-
case "set_boolean":
|
|
119
|
-
return `${e.target} set to ${e.value}`;
|
|
120
|
-
default:
|
|
121
|
-
return `${e.target} ${e.operation} ${e.value}`;
|
|
122
|
-
}
|
|
123
|
-
}).join("; ");
|
|
124
|
-
}
|
|
125
|
-
function renderExplainText(output) {
|
|
126
|
-
const lines = [];
|
|
127
|
-
lines.push(`WORLD: ${output.worldName}`);
|
|
128
|
-
lines.push(`ID: ${output.worldId}`);
|
|
129
|
-
lines.push("");
|
|
130
|
-
if (output.thesis) {
|
|
131
|
-
lines.push("THESIS");
|
|
132
|
-
lines.push(` ${output.thesis}`);
|
|
133
|
-
lines.push("");
|
|
134
|
-
}
|
|
135
|
-
lines.push("STRUCTURE");
|
|
136
|
-
lines.push(` ${output.stats.invariants} invariants, ${output.stats.stateVariables} state variables, ${output.stats.rules} rules`);
|
|
137
|
-
lines.push(` ${output.stats.gates} viability gates, ${output.stats.outcomes} outcomes, ${output.stats.assumptions} assumption profiles`);
|
|
138
|
-
lines.push("");
|
|
139
|
-
if (output.dynamics.length > 0) {
|
|
140
|
-
lines.push("KEY DYNAMICS");
|
|
141
|
-
for (const d of output.dynamics) {
|
|
142
|
-
const severity = d.severity === "structural" ? "[structural]" : d.severity === "advantage" ? "[advantage]" : "[degradation]";
|
|
143
|
-
lines.push(` ${d.label} ${severity}`);
|
|
144
|
-
lines.push(` When: ${d.triggerDescription}`);
|
|
145
|
-
lines.push(` Then: ${d.effectDescription}`);
|
|
146
|
-
}
|
|
147
|
-
lines.push("");
|
|
148
|
-
}
|
|
149
|
-
if (output.tensions.length > 0) {
|
|
150
|
-
lines.push("DRAMATIC TENSIONS");
|
|
151
|
-
for (const t of output.tensions) {
|
|
152
|
-
lines.push(` ${t.variable}:`);
|
|
153
|
-
lines.push(` Increased by: ${t.increasedBy.join(", ")}`);
|
|
154
|
-
lines.push(` Decreased by: ${t.decreasedBy.join(", ")}`);
|
|
155
|
-
}
|
|
156
|
-
lines.push("");
|
|
157
|
-
}
|
|
158
|
-
if (output.stateVariables.length > 0) {
|
|
159
|
-
lines.push("STATE VARIABLES");
|
|
160
|
-
for (const v of output.stateVariables) {
|
|
161
|
-
const range = v.range ? ` (${v.range})` : "";
|
|
162
|
-
lines.push(` ${v.label}: ${v.type}, default ${v.defaultValue}${range}`);
|
|
163
|
-
}
|
|
164
|
-
lines.push("");
|
|
165
|
-
}
|
|
166
|
-
if (output.invariants.length > 0) {
|
|
167
|
-
lines.push("INVARIANTS (cannot change)");
|
|
168
|
-
for (const inv of output.invariants) {
|
|
169
|
-
lines.push(` ${inv.label} [${inv.enforcement}]`);
|
|
170
|
-
}
|
|
171
|
-
lines.push("");
|
|
172
|
-
}
|
|
173
|
-
if (output.gates.length > 0) {
|
|
174
|
-
lines.push("VIABILITY GATES");
|
|
175
|
-
for (const g of output.gates) {
|
|
176
|
-
lines.push(` ${g.status}: ${g.field} ${g.threshold}`);
|
|
177
|
-
}
|
|
178
|
-
lines.push("");
|
|
179
|
-
}
|
|
180
|
-
if (output.outcomes.length > 0) {
|
|
181
|
-
lines.push("OUTCOMES");
|
|
182
|
-
for (const o of output.outcomes) {
|
|
183
|
-
const primary = o.primary ? " [primary]" : "";
|
|
184
|
-
lines.push(` ${o.label} (${o.type})${primary}`);
|
|
185
|
-
}
|
|
186
|
-
lines.push("");
|
|
187
|
-
}
|
|
188
|
-
return lines.join("\n");
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
export {
|
|
192
|
-
explainWorld,
|
|
193
|
-
renderExplainText
|
|
194
|
-
};
|