@neuroverseos/governance 0.3.0 → 0.3.3
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/.well-known/ai-plugin.json +34 -9
- package/AGENTS.md +72 -24
- package/README.md +352 -237
- package/dist/adapters/autoresearch.cjs +1152 -3
- package/dist/adapters/autoresearch.d.cts +11 -3
- package/dist/adapters/autoresearch.d.ts +11 -3
- package/dist/adapters/autoresearch.js +9 -4
- package/dist/adapters/deep-agents.cjs +1528 -0
- package/dist/adapters/deep-agents.d.cts +181 -0
- package/dist/adapters/deep-agents.d.ts +181 -0
- package/dist/adapters/deep-agents.js +17 -0
- package/dist/adapters/express.cjs +171 -32
- package/dist/adapters/express.d.cts +1 -1
- package/dist/adapters/express.d.ts +1 -1
- package/dist/adapters/express.js +5 -5
- package/dist/adapters/index.cjs +564 -121
- package/dist/adapters/index.d.cts +3 -1
- package/dist/adapters/index.d.ts +3 -1
- package/dist/adapters/index.js +38 -16
- package/dist/adapters/langchain.cjs +217 -57
- package/dist/adapters/langchain.d.cts +5 -5
- package/dist/adapters/langchain.d.ts +5 -5
- package/dist/adapters/langchain.js +6 -5
- package/dist/adapters/openai.cjs +219 -59
- package/dist/adapters/openai.d.cts +5 -5
- package/dist/adapters/openai.d.ts +5 -5
- package/dist/adapters/openai.js +6 -5
- package/dist/adapters/openclaw.cjs +217 -57
- package/dist/adapters/openclaw.d.cts +6 -6
- package/dist/adapters/openclaw.d.ts +6 -6
- package/dist/adapters/openclaw.js +6 -5
- package/dist/add-ROOZLU62.js +314 -0
- package/dist/behavioral-MJO34S6Q.js +118 -0
- package/dist/{bootstrap-GXVDZNF7.js → bootstrap-CQRZVOXK.js} +6 -4
- package/dist/bootstrap-emitter-Q7UIJZ2O.js +7 -0
- package/dist/bootstrap-parser-EEF36XDU.js +7 -0
- package/dist/browser.global.js +941 -0
- package/dist/{build-P42YFKQV.js → build-QKOBBC23.js} +7 -5
- package/dist/{chunk-COT5XS4V.js → chunk-3WQLXYTP.js} +17 -35
- package/dist/{chunk-ER62HNGF.js → chunk-4FLICVVA.js} +17 -37
- package/dist/chunk-5TPFNWRU.js +215 -0
- package/dist/chunk-5U2MQO5P.js +57 -0
- package/dist/{chunk-NF5POFCI.js → chunk-6S5CFQXY.js} +6 -4
- package/dist/{chunk-QPASI2BR.js → chunk-A7GKPPU7.js} +49 -10
- package/dist/{chunk-OGL7QXZS.js → chunk-B6OXJLJ5.js} +17 -3
- package/dist/{chunk-2PQU3VAN.js → chunk-BNKJPUPQ.js} +17 -35
- package/dist/chunk-BQZMOEML.js +43 -0
- package/dist/chunk-CNSO6XW5.js +207 -0
- package/dist/{chunk-JZPQGIKR.js → chunk-CTZHONLA.js} +65 -9
- package/dist/chunk-D2UCV5AK.js +326 -0
- package/dist/{chunk-XPDMYECO.js → chunk-EMQDLDAF.js} +1 -185
- package/dist/{chunk-GR6DGCZ2.js → chunk-F66BVUYB.js} +3 -3
- package/dist/{chunk-2NICNKOM.js → chunk-G7DJ6VOD.js} +5 -4
- package/dist/{chunk-4A7LISES.js → chunk-IS4WUH6Y.js} +45 -6
- package/dist/{chunk-MWDQ4MJB.js → chunk-MH7BT4VH.js} +5 -1
- package/dist/chunk-O5ABKEA7.js +304 -0
- package/dist/chunk-PVTQQS3Y.js +186 -0
- package/dist/{chunk-4QXB6PEO.js → chunk-QLPTHTVB.js} +37 -16
- package/dist/chunk-QWGCMQQD.js +16 -0
- package/dist/{chunk-T5EUJQE5.js → chunk-QXBFT7NI.js} +31 -2
- package/dist/{chunk-PDOZHZWL.js → chunk-TG6SEF24.js} +25 -4
- package/dist/chunk-U6U7EJZL.js +177 -0
- package/dist/{chunk-4JRYGIO7.js → chunk-W7LLXRGY.js} +110 -7
- package/dist/{chunk-BUWWN2NX.js → chunk-ZJTDUCC2.js} +9 -7
- package/dist/{chunk-FYS2CBUW.js → chunk-ZWI3NIXK.js} +10 -0
- package/dist/cli/neuroverse.cjs +5091 -2348
- package/dist/cli/neuroverse.js +52 -21
- package/dist/cli/plan.cjs +881 -41
- package/dist/cli/plan.js +7 -15
- package/dist/cli/run.cjs +289 -34
- package/dist/cli/run.js +4 -4
- package/dist/{configure-ai-TK67ZWZL.js → configure-ai-6TZ3MCSI.js} +1 -1
- package/dist/decision-flow-M63D47LO.js +61 -0
- package/dist/demo-G43RLCPK.js +469 -0
- package/dist/{derive-TLIV4OOU.js → derive-FJZVIPUZ.js} +5 -4
- package/dist/{doctor-XPDLEYXN.js → doctor-6BC6X2VO.js} +6 -4
- package/dist/equity-penalties-SG5IZQ7I.js +244 -0
- package/dist/{explain-IDCRWMPX.js → explain-RHBU2GBR.js} +6 -25
- package/dist/{guard-RV65TT4L.js → guard-AJCCGZMF.js} +8 -12
- package/dist/{guard-contract-WZx__PmU.d.cts → guard-contract-DqFcTScd.d.cts} +117 -5
- package/dist/{guard-contract-WZx__PmU.d.ts → guard-contract-DqFcTScd.d.ts} +117 -5
- package/dist/{guard-engine-JLTUARGU.js → guard-engine-PNR6MHCM.js} +3 -3
- package/dist/{impact-XPECYRLH.js → impact-3XVDSCBU.js} +5 -5
- package/dist/{improve-GPUBKTEA.js → improve-TQP4ECSY.js} +7 -26
- package/dist/index.cjs +5597 -4279
- package/dist/index.d.cts +597 -18
- package/dist/index.d.ts +597 -18
- package/dist/index.js +134 -41
- package/dist/{infer-world-7GVZWFX4.js → infer-world-IFXCACJ5.js} +1 -1
- package/dist/{init-PKPIYHYE.js → init-FYPV4SST.js} +1 -1
- package/dist/{init-world-VWMQZQC7.js → init-world-TI7ARHBT.js} +1 -1
- package/dist/mcp-server-5Y3ZM7TV.js +13 -0
- package/dist/{model-adapter-BB7G4MFI.js → model-adapter-VXEKB4LS.js} +1 -1
- package/dist/{playground-E664U4T6.js → playground-VZBNPPBO.js} +29 -19
- package/dist/{redteam-Z7WREJ44.js → redteam-MZPZD3EF.js} +4 -4
- package/dist/session-JYOARW54.js +15 -0
- package/dist/shared-7RLUHNMU.js +16 -0
- package/dist/shared-B8dvUUD8.d.cts +60 -0
- package/dist/shared-Dr5Wiay8.d.ts +60 -0
- package/dist/{simulate-VDOYQFRO.js → simulate-LJXYBC6M.js} +8 -33
- package/dist/{test-OGXJK4QU.js → test-BOOR4A5F.js} +4 -4
- package/dist/{trace-JVF67VR3.js → trace-PKV4KX56.js} +4 -4
- package/dist/{validate-LLBWVPGV.js → validate-RALX7CZS.js} +2 -2
- package/dist/{validate-engine-UIABSIHD.js → validate-engine-7ZXFVGF2.js} +1 -1
- package/dist/viz/assets/index-B8SaeJZZ.js +23 -0
- package/dist/viz/index.html +23 -0
- package/dist/{world-LAXO6DOX.js → world-BIP4GZBZ.js} +9 -11
- package/dist/world-loader-Y6HMQH2D.js +13 -0
- package/dist/worlds/coding-agent.nv-world.md +211 -0
- package/dist/worlds/research-agent.nv-world.md +169 -0
- package/dist/worlds/social-media.nv-world.md +198 -0
- package/dist/worlds/trading-agent.nv-world.md +218 -0
- package/examples/social-media-sim/bridge.py +209 -0
- package/examples/social-media-sim/simulation.py +927 -0
- package/package.json +30 -4
- 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 +1567 -0
- package/dist/chunk-YZFATT7X.js +0 -9
- package/dist/mcp-server-FPVSU32Z.js +0 -13
- package/dist/session-EKTRSR7C.js +0 -14
- package/dist/world-loader-HMPTOEA2.js +0 -9
package/dist/index.js
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
actionToGuardEvent,
|
|
3
|
+
createGovernor,
|
|
4
|
+
govern,
|
|
5
|
+
handleCreateCapsule,
|
|
6
|
+
handleHealthCheck,
|
|
7
|
+
handleListPresets,
|
|
8
|
+
handleReasonRequest,
|
|
9
|
+
writeTempWorld
|
|
10
|
+
} from "./chunk-U6U7EJZL.js";
|
|
1
11
|
import {
|
|
2
12
|
generateImpactReport,
|
|
3
13
|
generateImpactReportFromFile,
|
|
4
14
|
renderImpactReport
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import {
|
|
7
|
-
VALIDATE_EXIT_CODES
|
|
8
|
-
} from "./chunk-I3RRAYK2.js";
|
|
15
|
+
} from "./chunk-TG6SEF24.js";
|
|
9
16
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
17
|
+
adaptationFromVerdict,
|
|
18
|
+
classifyAdaptation,
|
|
19
|
+
detectBehavioralPatterns,
|
|
20
|
+
generateAdaptationNarrative
|
|
21
|
+
} from "./chunk-CNSO6XW5.js";
|
|
12
22
|
import {
|
|
13
23
|
CompositeAuditLogger,
|
|
14
24
|
ConsoleAuditLogger,
|
|
@@ -17,53 +27,60 @@ import {
|
|
|
17
27
|
readAuditLog,
|
|
18
28
|
summarizeAuditEvents,
|
|
19
29
|
verdictToAuditEvent
|
|
20
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-A7GKPPU7.js";
|
|
31
|
+
import {
|
|
32
|
+
improveWorld,
|
|
33
|
+
renderImproveText
|
|
34
|
+
} from "./chunk-F66BVUYB.js";
|
|
35
|
+
import {
|
|
36
|
+
BOOTSTRAP_EXIT_CODES
|
|
37
|
+
} from "./chunk-4NGDRRQH.js";
|
|
38
|
+
import {
|
|
39
|
+
VALIDATE_EXIT_CODES
|
|
40
|
+
} from "./chunk-I3RRAYK2.js";
|
|
41
|
+
import {
|
|
42
|
+
GUARD_EXIT_CODES
|
|
43
|
+
} from "./chunk-MH7BT4VH.js";
|
|
44
|
+
import {
|
|
45
|
+
ModelAdapter,
|
|
46
|
+
PROVIDERS,
|
|
47
|
+
resolveProvider
|
|
48
|
+
} from "./chunk-A5W4GNQO.js";
|
|
49
|
+
import {
|
|
50
|
+
McpGovernanceServer
|
|
51
|
+
} from "./chunk-B6OXJLJ5.js";
|
|
52
|
+
import {
|
|
53
|
+
addGuard,
|
|
54
|
+
addInvariant,
|
|
55
|
+
addRule,
|
|
56
|
+
classifyIntent,
|
|
57
|
+
parseGuardDescription
|
|
58
|
+
} from "./chunk-5TPFNWRU.js";
|
|
21
59
|
import {
|
|
22
60
|
deriveWorld,
|
|
23
61
|
extractWorldMarkdown,
|
|
24
62
|
normalizeWorldMarkdown
|
|
25
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-6S5CFQXY.js";
|
|
26
64
|
import {
|
|
27
65
|
CONFIGURE_AI_EXIT_CODES,
|
|
28
66
|
DERIVE_EXIT_CODES
|
|
29
67
|
} from "./chunk-Q6O7ZLO2.js";
|
|
30
68
|
import "./chunk-OT6PXH54.js";
|
|
69
|
+
import {
|
|
70
|
+
validateWorld
|
|
71
|
+
} from "./chunk-7P3S7MAY.js";
|
|
31
72
|
import {
|
|
32
73
|
explainWorld,
|
|
33
74
|
renderExplainText
|
|
34
|
-
} from "./chunk-
|
|
35
|
-
import {
|
|
36
|
-
improveWorld,
|
|
37
|
-
renderImproveText
|
|
38
|
-
} from "./chunk-GR6DGCZ2.js";
|
|
75
|
+
} from "./chunk-ZJTDUCC2.js";
|
|
39
76
|
import {
|
|
40
77
|
renderSimulateText,
|
|
41
78
|
simulateWorld
|
|
42
|
-
} from "./chunk-
|
|
43
|
-
import {
|
|
44
|
-
BOOTSTRAP_EXIT_CODES
|
|
45
|
-
} from "./chunk-4NGDRRQH.js";
|
|
46
|
-
import {
|
|
47
|
-
emitWorldDefinition,
|
|
48
|
-
parseWorldMarkdown
|
|
49
|
-
} from "./chunk-XPDMYECO.js";
|
|
79
|
+
} from "./chunk-ZWI3NIXK.js";
|
|
50
80
|
import {
|
|
51
81
|
PLAN_EXIT_CODES,
|
|
52
82
|
parsePlanMarkdown
|
|
53
83
|
} 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
84
|
import {
|
|
68
85
|
describeActiveWorld,
|
|
69
86
|
getActiveWorldName,
|
|
@@ -72,29 +89,49 @@ import {
|
|
|
72
89
|
setActiveWorld
|
|
73
90
|
} from "./chunk-AKW5YVCE.js";
|
|
74
91
|
import {
|
|
75
|
-
|
|
76
|
-
} from "./chunk-
|
|
92
|
+
parseWorldMarkdown
|
|
93
|
+
} from "./chunk-EMQDLDAF.js";
|
|
94
|
+
import {
|
|
95
|
+
emitWorldDefinition
|
|
96
|
+
} from "./chunk-PVTQQS3Y.js";
|
|
97
|
+
import {
|
|
98
|
+
SessionManager,
|
|
99
|
+
runInteractiveMode,
|
|
100
|
+
runPipeMode
|
|
101
|
+
} from "./chunk-IS4WUH6Y.js";
|
|
102
|
+
import {
|
|
103
|
+
applyConsequence,
|
|
104
|
+
applyReward,
|
|
105
|
+
createAgentState,
|
|
106
|
+
generateDecisionFlow,
|
|
107
|
+
renderDecisionFlow,
|
|
108
|
+
tickAgentStates
|
|
109
|
+
} from "./chunk-D2UCV5AK.js";
|
|
77
110
|
import {
|
|
78
111
|
evaluateGuard,
|
|
79
112
|
eventToAllowlistKey
|
|
80
|
-
} from "./chunk-
|
|
113
|
+
} from "./chunk-W7LLXRGY.js";
|
|
81
114
|
import {
|
|
82
115
|
advancePlan,
|
|
83
116
|
buildPlanCheck,
|
|
84
117
|
evaluatePlan,
|
|
85
118
|
getPlanProgress
|
|
86
|
-
} from "./chunk-
|
|
119
|
+
} from "./chunk-QLPTHTVB.js";
|
|
87
120
|
import {
|
|
88
121
|
loadWorld,
|
|
89
122
|
loadWorldFromDirectory
|
|
90
|
-
} from "./chunk-
|
|
91
|
-
import "./chunk-
|
|
123
|
+
} from "./chunk-CTZHONLA.js";
|
|
124
|
+
import "./chunk-QWGCMQQD.js";
|
|
92
125
|
|
|
93
126
|
// src/engine/verdict-formatter.ts
|
|
94
127
|
var ANSI = {
|
|
95
128
|
red: "\x1B[31m",
|
|
96
129
|
green: "\x1B[32m",
|
|
97
130
|
yellow: "\x1B[33m",
|
|
131
|
+
blue: "\x1B[34m",
|
|
132
|
+
magenta: "\x1B[35m",
|
|
133
|
+
cyan: "\x1B[36m",
|
|
134
|
+
gray: "\x1B[90m",
|
|
98
135
|
bold: "\x1B[1m",
|
|
99
136
|
dim: "\x1B[2m",
|
|
100
137
|
reset: "\x1B[0m"
|
|
@@ -138,6 +175,31 @@ function formatFull(verdict, opts) {
|
|
|
138
175
|
if (verdict.reason) {
|
|
139
176
|
lines.push(` Reason: ${verdict.reason}`);
|
|
140
177
|
}
|
|
178
|
+
if (verdict.consequence) {
|
|
179
|
+
const label = opts.color ? c("Consequence:", ANSI.red) : "Consequence:";
|
|
180
|
+
lines.push(` ${label} ${verdict.consequence.description}`);
|
|
181
|
+
if (verdict.consequence.rounds) {
|
|
182
|
+
lines.push(` Freeze: ${verdict.consequence.rounds} round(s)`);
|
|
183
|
+
}
|
|
184
|
+
if (verdict.consequence.magnitude) {
|
|
185
|
+
lines.push(` Magnitude: ${(verdict.consequence.magnitude * 100).toFixed(0)}%`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (verdict.reward) {
|
|
189
|
+
const label = opts.color ? c("Reward:", ANSI.blue) : "Reward:";
|
|
190
|
+
lines.push(` ${label} ${verdict.reward.description}`);
|
|
191
|
+
if (verdict.reward.rounds) {
|
|
192
|
+
lines.push(` Duration: ${verdict.reward.rounds} round(s)`);
|
|
193
|
+
}
|
|
194
|
+
if (verdict.reward.magnitude) {
|
|
195
|
+
lines.push(` Boost: ${(verdict.reward.magnitude * 100).toFixed(0)}%`);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (verdict.intentRecord) {
|
|
199
|
+
const ir = verdict.intentRecord;
|
|
200
|
+
const label = opts.color ? c("Intent Flow:", ANSI.cyan) : "Intent Flow:";
|
|
201
|
+
lines.push(` ${label} ${ir.originalIntent} \u2192 ${ir.finalAction}`);
|
|
202
|
+
}
|
|
141
203
|
if (opts.showWarning && verdict.warning) {
|
|
142
204
|
const label = opts.color ? c("Warning:", ANSI.yellow) : "Warning:";
|
|
143
205
|
lines.push(` ${label} ${verdict.warning}`);
|
|
@@ -164,6 +226,14 @@ function formatStatus(status, color) {
|
|
|
164
226
|
return color ? c("BLOCKED", ANSI.red, ANSI.bold) : "BLOCKED";
|
|
165
227
|
case "PAUSE":
|
|
166
228
|
return color ? c("PAUSED", ANSI.yellow, ANSI.bold) : "PAUSED";
|
|
229
|
+
case "MODIFY":
|
|
230
|
+
return color ? c("MODIFIED", ANSI.yellow, ANSI.bold) : "MODIFIED";
|
|
231
|
+
case "PENALIZE":
|
|
232
|
+
return color ? c("PENALIZED", ANSI.red, ANSI.bold) : "PENALIZED";
|
|
233
|
+
case "REWARD":
|
|
234
|
+
return color ? c("REWARDED", ANSI.blue, ANSI.bold) : "REWARDED";
|
|
235
|
+
case "NEUTRAL":
|
|
236
|
+
return color ? c("NEUTRAL", ANSI.gray, ANSI.bold) : "NEUTRAL";
|
|
167
237
|
default:
|
|
168
238
|
return status;
|
|
169
239
|
}
|
|
@@ -337,11 +407,23 @@ export {
|
|
|
337
407
|
PROVIDERS,
|
|
338
408
|
SessionManager,
|
|
339
409
|
VALIDATE_EXIT_CODES,
|
|
410
|
+
actionToGuardEvent,
|
|
411
|
+
adaptationFromVerdict,
|
|
412
|
+
addGuard,
|
|
413
|
+
addInvariant,
|
|
414
|
+
addRule,
|
|
340
415
|
advancePlan,
|
|
416
|
+
applyConsequence,
|
|
417
|
+
applyReward,
|
|
341
418
|
buildPlanCheck,
|
|
419
|
+
classifyAdaptation,
|
|
420
|
+
classifyIntent,
|
|
421
|
+
createAgentState,
|
|
342
422
|
createGovernanceEngine,
|
|
423
|
+
createGovernor,
|
|
343
424
|
deriveWorld,
|
|
344
425
|
describeActiveWorld,
|
|
426
|
+
detectBehavioralPatterns,
|
|
345
427
|
emitWorldDefinition,
|
|
346
428
|
evaluateCondition,
|
|
347
429
|
evaluateGuard,
|
|
@@ -351,18 +433,27 @@ export {
|
|
|
351
433
|
extractWorldMarkdown,
|
|
352
434
|
formatVerdict,
|
|
353
435
|
formatVerdictOneLine,
|
|
436
|
+
generateAdaptationNarrative,
|
|
437
|
+
generateDecisionFlow,
|
|
354
438
|
generateImpactReport,
|
|
355
439
|
generateImpactReportFromFile,
|
|
356
440
|
getActiveWorldName,
|
|
357
441
|
getPlanProgress,
|
|
442
|
+
govern,
|
|
443
|
+
handleCreateCapsule,
|
|
444
|
+
handleHealthCheck,
|
|
445
|
+
handleListPresets,
|
|
446
|
+
handleReasonRequest,
|
|
358
447
|
improveWorld,
|
|
359
448
|
listWorlds,
|
|
360
449
|
loadWorld,
|
|
361
450
|
loadWorldFromDirectory,
|
|
362
451
|
normalizeWorldMarkdown,
|
|
452
|
+
parseGuardDescription,
|
|
363
453
|
parsePlanMarkdown,
|
|
364
454
|
parseWorldMarkdown,
|
|
365
455
|
readAuditLog,
|
|
456
|
+
renderDecisionFlow,
|
|
366
457
|
renderExplainText,
|
|
367
458
|
renderImpactReport,
|
|
368
459
|
renderImproveText,
|
|
@@ -374,6 +465,8 @@ export {
|
|
|
374
465
|
setActiveWorld,
|
|
375
466
|
simulateWorld,
|
|
376
467
|
summarizeAuditEvents,
|
|
468
|
+
tickAgentStates,
|
|
377
469
|
validateWorld,
|
|
378
|
-
verdictToAuditEvent
|
|
470
|
+
verdictToAuditEvent,
|
|
471
|
+
writeTempWorld
|
|
379
472
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
McpGovernanceServer,
|
|
3
|
+
startMcpServer
|
|
4
|
+
} from "./chunk-B6OXJLJ5.js";
|
|
5
|
+
import "./chunk-AKW5YVCE.js";
|
|
6
|
+
import "./chunk-W7LLXRGY.js";
|
|
7
|
+
import "./chunk-QLPTHTVB.js";
|
|
8
|
+
import "./chunk-CTZHONLA.js";
|
|
9
|
+
import "./chunk-QWGCMQQD.js";
|
|
10
|
+
export {
|
|
11
|
+
McpGovernanceServer,
|
|
12
|
+
startMcpServer
|
|
13
|
+
};
|
|
@@ -3,12 +3,14 @@ import {
|
|
|
3
3
|
} from "./chunk-7P3S7MAY.js";
|
|
4
4
|
import {
|
|
5
5
|
evaluateGuard
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-W7LLXRGY.js";
|
|
7
|
+
import "./chunk-QLPTHTVB.js";
|
|
8
8
|
import {
|
|
9
|
+
DEFAULT_BUNDLED_WORLD,
|
|
10
|
+
loadBundledWorld,
|
|
9
11
|
loadWorld
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-CTZHONLA.js";
|
|
13
|
+
import "./chunk-QWGCMQQD.js";
|
|
12
14
|
|
|
13
15
|
// src/cli/playground.ts
|
|
14
16
|
import { createServer } from "http";
|
|
@@ -18,7 +20,7 @@ function buildPlaygroundHtml(world, healthSummary) {
|
|
|
18
20
|
const invariantCount = (world.invariants ?? []).length;
|
|
19
21
|
const guardCount = (world.guards?.guards ?? []).length;
|
|
20
22
|
const ruleCount = (world.rules ?? []).length;
|
|
21
|
-
const kernelForbidden = world.kernel?.
|
|
23
|
+
const kernelForbidden = (world.kernel?.input_boundaries?.forbidden_patterns?.length ?? 0) + (world.kernel?.output_boundaries?.forbidden_patterns?.length ?? 0);
|
|
22
24
|
return `<!DOCTYPE html>
|
|
23
25
|
<html lang="en">
|
|
24
26
|
<head>
|
|
@@ -324,7 +326,7 @@ async function doEvaluate(event) {
|
|
|
324
326
|
const data = await res.json();
|
|
325
327
|
renderTrace(data, event);
|
|
326
328
|
} catch (e) {
|
|
327
|
-
resultsEl.innerHTML = '<div class="trace" style="color:var(--red)">Error: ' + e.message + '</div>' + resultsEl.innerHTML;
|
|
329
|
+
resultsEl.innerHTML = '<div class="trace" style="color:var(--red)">Error: ' + esc(e.message || String(e)) + '</div>' + resultsEl.innerHTML;
|
|
328
330
|
}
|
|
329
331
|
}
|
|
330
332
|
|
|
@@ -448,22 +450,23 @@ function parseArgs(argv) {
|
|
|
448
450
|
}
|
|
449
451
|
async function main(argv) {
|
|
450
452
|
const args = parseArgs(argv);
|
|
451
|
-
if (!args.worldPath) {
|
|
452
|
-
process.stderr.write("Usage: neuroverse playground --world <dir> [--port N]\n");
|
|
453
|
-
process.exit(1);
|
|
454
|
-
return;
|
|
455
|
-
}
|
|
456
453
|
let world;
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
454
|
+
if (args.worldPath) {
|
|
455
|
+
try {
|
|
456
|
+
world = await loadWorld(args.worldPath);
|
|
457
|
+
} catch (e) {
|
|
458
|
+
process.stderr.write(`Failed to load world: ${e}
|
|
459
|
+
`);
|
|
460
|
+
process.exit(1);
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
} else {
|
|
464
|
+
world = await loadBundledWorld(DEFAULT_BUNDLED_WORLD);
|
|
465
|
+
process.stderr.write(` Using default world: ${DEFAULT_BUNDLED_WORLD}
|
|
461
466
|
`);
|
|
462
|
-
process.exit(1);
|
|
463
|
-
return;
|
|
464
467
|
}
|
|
465
468
|
const validation = validateWorld(world);
|
|
466
|
-
const health = validation.governanceHealth;
|
|
469
|
+
const health = validation.summary.governanceHealth;
|
|
467
470
|
let healthSummary = "GOVERNANCE HEALTH\n";
|
|
468
471
|
if (health) {
|
|
469
472
|
healthSummary += ` Coverage: ${health.surfacesCovered} / ${health.surfacesTotal} surfaces
|
|
@@ -478,7 +481,7 @@ async function main(argv) {
|
|
|
478
481
|
`;
|
|
479
482
|
healthSummary += ` Risk level: ${health.riskLevel}`;
|
|
480
483
|
} else {
|
|
481
|
-
healthSummary += ` Score: ${validation.completenessScore}%`;
|
|
484
|
+
healthSummary += ` Score: ${validation.summary.completenessScore}%`;
|
|
482
485
|
}
|
|
483
486
|
const html = buildPlaygroundHtml(world, healthSummary);
|
|
484
487
|
const server = createServer((req, res) => {
|
|
@@ -489,8 +492,15 @@ async function main(argv) {
|
|
|
489
492
|
}
|
|
490
493
|
if (req.method === "POST" && req.url === "/api/guard") {
|
|
491
494
|
let body = "";
|
|
495
|
+
const MAX_BODY = 1024 * 1024;
|
|
492
496
|
req.on("data", (chunk) => {
|
|
493
497
|
body += chunk;
|
|
498
|
+
if (body.length > MAX_BODY) {
|
|
499
|
+
res.writeHead(413, { "Content-Type": "application/json" });
|
|
500
|
+
res.end(JSON.stringify({ error: "Request body too large" }));
|
|
501
|
+
req.destroy();
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
494
504
|
});
|
|
495
505
|
req.on("end", () => {
|
|
496
506
|
try {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
evaluateGuard
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-W7LLXRGY.js";
|
|
4
|
+
import "./chunk-QLPTHTVB.js";
|
|
5
5
|
import {
|
|
6
6
|
loadWorld
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-CTZHONLA.js";
|
|
8
|
+
import "./chunk-QWGCMQQD.js";
|
|
9
9
|
|
|
10
10
|
// src/cli/redteam.ts
|
|
11
11
|
var ATTACKS = [
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SessionManager,
|
|
3
|
+
runInteractiveMode,
|
|
4
|
+
runPipeMode
|
|
5
|
+
} from "./chunk-IS4WUH6Y.js";
|
|
6
|
+
import "./chunk-D2UCV5AK.js";
|
|
7
|
+
import "./chunk-W7LLXRGY.js";
|
|
8
|
+
import "./chunk-QLPTHTVB.js";
|
|
9
|
+
import "./chunk-CTZHONLA.js";
|
|
10
|
+
import "./chunk-QWGCMQQD.js";
|
|
11
|
+
export {
|
|
12
|
+
SessionManager,
|
|
13
|
+
runInteractiveMode,
|
|
14
|
+
runPipeMode
|
|
15
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GovernanceBlockedError,
|
|
3
|
+
buildEngineOptions,
|
|
4
|
+
defaultBlockMessage,
|
|
5
|
+
extractScope,
|
|
6
|
+
trackPlanProgress
|
|
7
|
+
} from "./chunk-5U2MQO5P.js";
|
|
8
|
+
import "./chunk-QLPTHTVB.js";
|
|
9
|
+
import "./chunk-QWGCMQQD.js";
|
|
10
|
+
export {
|
|
11
|
+
GovernanceBlockedError,
|
|
12
|
+
buildEngineOptions,
|
|
13
|
+
defaultBlockMessage,
|
|
14
|
+
extractScope,
|
|
15
|
+
trackPlanProgress
|
|
16
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { a as GuardVerdict, P as PlanDefinition, c as PlanProgress, b as GuardEngineOptions, G as GuardEvent } from './guard-contract-DqFcTScd.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared Adapter Utilities
|
|
5
|
+
*
|
|
6
|
+
* Consolidates duplicated logic across adapters:
|
|
7
|
+
* - Plan progress tracking (was in openai, langchain, openclaw, deep-agents)
|
|
8
|
+
* - GovernanceBlockedError base class (was duplicated 4x)
|
|
9
|
+
* - Scope extraction from tool args (was in 3+ adapters)
|
|
10
|
+
* - Engine options initialization
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Base error thrown when governance blocks an action.
|
|
15
|
+
* Each adapter extends this with framework-specific context fields.
|
|
16
|
+
*/
|
|
17
|
+
declare class GovernanceBlockedError extends Error {
|
|
18
|
+
readonly verdict: GuardVerdict;
|
|
19
|
+
constructor(verdict: GuardVerdict, message?: string);
|
|
20
|
+
}
|
|
21
|
+
interface PlanTrackingCallbacks {
|
|
22
|
+
onPlanProgress?: (progress: PlanProgress) => void;
|
|
23
|
+
onPlanComplete?: () => void;
|
|
24
|
+
}
|
|
25
|
+
interface PlanTrackingState {
|
|
26
|
+
activePlan?: PlanDefinition;
|
|
27
|
+
engineOptions: GuardEngineOptions;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Track plan progress after a successful (ALLOW) evaluation.
|
|
31
|
+
* Mutates the plan tracking state in-place.
|
|
32
|
+
*
|
|
33
|
+
* Previously duplicated identically in:
|
|
34
|
+
* - deep-agents.ts:429-445
|
|
35
|
+
* - openai.ts:150-164
|
|
36
|
+
* - langchain.ts:152-166
|
|
37
|
+
* - openclaw.ts:147-161
|
|
38
|
+
*/
|
|
39
|
+
declare function trackPlanProgress(event: GuardEvent, state: PlanTrackingState, callbacks: PlanTrackingCallbacks): void;
|
|
40
|
+
/**
|
|
41
|
+
* Extract the most relevant "scope" (file path, URL, or command)
|
|
42
|
+
* from tool arguments.
|
|
43
|
+
*
|
|
44
|
+
* Previously duplicated in deep-agents.ts:189-195, langchain.ts:75-79,
|
|
45
|
+
* openclaw.ts:85-89, openai.ts:90-94.
|
|
46
|
+
*/
|
|
47
|
+
declare function extractScope(args: Record<string, unknown>): string | undefined;
|
|
48
|
+
interface BaseAdapterOptions {
|
|
49
|
+
trace?: boolean;
|
|
50
|
+
level?: 'basic' | 'standard' | 'strict';
|
|
51
|
+
plan?: PlanDefinition;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Build GuardEngineOptions from common adapter options.
|
|
55
|
+
* Previously duplicated in every adapter constructor.
|
|
56
|
+
*/
|
|
57
|
+
declare function buildEngineOptions(options: BaseAdapterOptions, plan?: PlanDefinition): GuardEngineOptions;
|
|
58
|
+
declare function defaultBlockMessage(verdict: GuardVerdict): string;
|
|
59
|
+
|
|
60
|
+
export { type BaseAdapterOptions as B, GovernanceBlockedError as G, type PlanTrackingCallbacks as P, type PlanTrackingState as a, buildEngineOptions as b, defaultBlockMessage as d, extractScope as e, trackPlanProgress as t };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { a as GuardVerdict, P as PlanDefinition, c as PlanProgress, b as GuardEngineOptions, G as GuardEvent } from './guard-contract-DqFcTScd.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared Adapter Utilities
|
|
5
|
+
*
|
|
6
|
+
* Consolidates duplicated logic across adapters:
|
|
7
|
+
* - Plan progress tracking (was in openai, langchain, openclaw, deep-agents)
|
|
8
|
+
* - GovernanceBlockedError base class (was duplicated 4x)
|
|
9
|
+
* - Scope extraction from tool args (was in 3+ adapters)
|
|
10
|
+
* - Engine options initialization
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Base error thrown when governance blocks an action.
|
|
15
|
+
* Each adapter extends this with framework-specific context fields.
|
|
16
|
+
*/
|
|
17
|
+
declare class GovernanceBlockedError extends Error {
|
|
18
|
+
readonly verdict: GuardVerdict;
|
|
19
|
+
constructor(verdict: GuardVerdict, message?: string);
|
|
20
|
+
}
|
|
21
|
+
interface PlanTrackingCallbacks {
|
|
22
|
+
onPlanProgress?: (progress: PlanProgress) => void;
|
|
23
|
+
onPlanComplete?: () => void;
|
|
24
|
+
}
|
|
25
|
+
interface PlanTrackingState {
|
|
26
|
+
activePlan?: PlanDefinition;
|
|
27
|
+
engineOptions: GuardEngineOptions;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Track plan progress after a successful (ALLOW) evaluation.
|
|
31
|
+
* Mutates the plan tracking state in-place.
|
|
32
|
+
*
|
|
33
|
+
* Previously duplicated identically in:
|
|
34
|
+
* - deep-agents.ts:429-445
|
|
35
|
+
* - openai.ts:150-164
|
|
36
|
+
* - langchain.ts:152-166
|
|
37
|
+
* - openclaw.ts:147-161
|
|
38
|
+
*/
|
|
39
|
+
declare function trackPlanProgress(event: GuardEvent, state: PlanTrackingState, callbacks: PlanTrackingCallbacks): void;
|
|
40
|
+
/**
|
|
41
|
+
* Extract the most relevant "scope" (file path, URL, or command)
|
|
42
|
+
* from tool arguments.
|
|
43
|
+
*
|
|
44
|
+
* Previously duplicated in deep-agents.ts:189-195, langchain.ts:75-79,
|
|
45
|
+
* openclaw.ts:85-89, openai.ts:90-94.
|
|
46
|
+
*/
|
|
47
|
+
declare function extractScope(args: Record<string, unknown>): string | undefined;
|
|
48
|
+
interface BaseAdapterOptions {
|
|
49
|
+
trace?: boolean;
|
|
50
|
+
level?: 'basic' | 'standard' | 'strict';
|
|
51
|
+
plan?: PlanDefinition;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Build GuardEngineOptions from common adapter options.
|
|
55
|
+
* Previously duplicated in every adapter constructor.
|
|
56
|
+
*/
|
|
57
|
+
declare function buildEngineOptions(options: BaseAdapterOptions, plan?: PlanDefinition): GuardEngineOptions;
|
|
58
|
+
declare function defaultBlockMessage(verdict: GuardVerdict): string;
|
|
59
|
+
|
|
60
|
+
export { type BaseAdapterOptions as B, GovernanceBlockedError as G, type PlanTrackingCallbacks as P, type PlanTrackingState as a, buildEngineOptions as b, defaultBlockMessage as d, extractScope as e, trackPlanProgress as t };
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseCliValue,
|
|
3
|
+
resolveWorldPath
|
|
4
|
+
} from "./chunk-BQZMOEML.js";
|
|
1
5
|
import {
|
|
2
6
|
renderSimulateText,
|
|
3
7
|
simulateWorld
|
|
4
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ZWI3NIXK.js";
|
|
5
9
|
import {
|
|
6
10
|
loadWorld
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-CTZHONLA.js";
|
|
12
|
+
import "./chunk-QWGCMQQD.js";
|
|
9
13
|
|
|
10
14
|
// src/cli/simulate.ts
|
|
11
15
|
function parseArgs(argv) {
|
|
@@ -30,7 +34,7 @@ function parseArgs(argv) {
|
|
|
30
34
|
if (eqIdx > 0) {
|
|
31
35
|
const key = pair.slice(0, eqIdx);
|
|
32
36
|
const rawValue = pair.slice(eqIdx + 1);
|
|
33
|
-
stateOverrides[key] =
|
|
37
|
+
stateOverrides[key] = parseCliValue(rawValue);
|
|
34
38
|
}
|
|
35
39
|
} else if (!arg.startsWith("--") && !worldPath) {
|
|
36
40
|
worldPath = arg;
|
|
@@ -41,35 +45,6 @@ function parseArgs(argv) {
|
|
|
41
45
|
}
|
|
42
46
|
return { worldPath, steps, stateOverrides, profile, json };
|
|
43
47
|
}
|
|
44
|
-
function parseValue(raw) {
|
|
45
|
-
if (raw === "true") return true;
|
|
46
|
-
if (raw === "false") return false;
|
|
47
|
-
const num = Number(raw);
|
|
48
|
-
if (!isNaN(num) && raw.trim() !== "") return num;
|
|
49
|
-
return raw;
|
|
50
|
-
}
|
|
51
|
-
async function resolveWorldPath(input) {
|
|
52
|
-
const { stat } = await import("fs/promises");
|
|
53
|
-
try {
|
|
54
|
-
const info = await stat(input);
|
|
55
|
-
if (info.isDirectory()) return input;
|
|
56
|
-
} catch {
|
|
57
|
-
}
|
|
58
|
-
const neuroversePath = `.neuroverse/worlds/${input}`;
|
|
59
|
-
try {
|
|
60
|
-
const info = await stat(neuroversePath);
|
|
61
|
-
if (info.isDirectory()) return neuroversePath;
|
|
62
|
-
} catch {
|
|
63
|
-
}
|
|
64
|
-
throw new Error(
|
|
65
|
-
`World not found: "${input}"
|
|
66
|
-
Tried:
|
|
67
|
-
${input}
|
|
68
|
-
${neuroversePath}
|
|
69
|
-
|
|
70
|
-
Build a world first: neuroverse build <input.md>`
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
48
|
async function main(argv = process.argv.slice(2)) {
|
|
74
49
|
try {
|
|
75
50
|
const args = parseArgs(argv);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
evaluateGuard
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-W7LLXRGY.js";
|
|
4
|
+
import "./chunk-QLPTHTVB.js";
|
|
5
5
|
import {
|
|
6
6
|
loadWorld
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-CTZHONLA.js";
|
|
8
|
+
import "./chunk-QWGCMQQD.js";
|
|
9
9
|
|
|
10
10
|
// src/cli/test.ts
|
|
11
11
|
var STANDARD_TESTS = [
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
readAuditLog,
|
|
3
3
|
summarizeAuditEvents
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-A7GKPPU7.js";
|
|
5
|
+
import "./chunk-W7LLXRGY.js";
|
|
6
|
+
import "./chunk-QLPTHTVB.js";
|
|
7
|
+
import "./chunk-QWGCMQQD.js";
|
|
8
8
|
|
|
9
9
|
// src/cli/trace.ts
|
|
10
10
|
function parseArgs(argv) {
|