@neuroverseos/governance 0.2.2 → 0.2.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 +26 -0
- package/.well-known/mcp.json +68 -0
- package/AGENTS.md +219 -0
- package/README.md +84 -4
- package/dist/adapters/autoresearch.cjs +196 -0
- package/dist/adapters/autoresearch.d.cts +103 -0
- package/dist/adapters/autoresearch.d.ts +103 -0
- package/dist/adapters/autoresearch.js +7 -0
- package/dist/adapters/deep-agents.cjs +1472 -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 +103 -21
- package/dist/adapters/express.d.cts +1 -1
- package/dist/adapters/express.d.ts +1 -1
- package/dist/adapters/express.js +3 -3
- package/dist/adapters/index.cjs +649 -109
- package/dist/adapters/index.d.cts +4 -1
- package/dist/adapters/index.d.ts +4 -1
- package/dist/adapters/index.js +39 -13
- package/dist/adapters/langchain.cjs +152 -48
- package/dist/adapters/langchain.d.cts +5 -5
- package/dist/adapters/langchain.d.ts +5 -5
- package/dist/adapters/langchain.js +4 -3
- package/dist/adapters/openai.cjs +154 -50
- package/dist/adapters/openai.d.cts +5 -5
- package/dist/adapters/openai.d.ts +5 -5
- package/dist/adapters/openai.js +4 -3
- package/dist/adapters/openclaw.cjs +152 -48
- package/dist/adapters/openclaw.d.cts +5 -5
- package/dist/adapters/openclaw.d.ts +5 -5
- package/dist/adapters/openclaw.js +4 -3
- package/dist/{build-P42YFKQV.js → build-X5MZY4IA.js} +2 -2
- package/dist/{chunk-2NICNKOM.js → chunk-4L6OPKMQ.js} +1 -1
- package/dist/chunk-5U2MQO5P.js +57 -0
- package/dist/{chunk-SKU3GAPD.js → chunk-6BB55YJI.js} +16 -34
- package/dist/{chunk-KEST3MWO.js → chunk-AF2VX4AL.js} +47 -8
- package/dist/chunk-BQZMOEML.js +43 -0
- package/dist/chunk-D2UCV5AK.js +326 -0
- package/dist/{chunk-RWXVAH6P.js → chunk-EVDJUSZ2.js} +16 -34
- package/dist/{chunk-4JRYGIO7.js → chunk-IZSO75NZ.js} +72 -7
- package/dist/chunk-JCKSW2PZ.js +304 -0
- package/dist/{chunk-PDOZHZWL.js → chunk-KTFTTLTP.js} +25 -4
- package/dist/{chunk-MWDQ4MJB.js → chunk-MH7BT4VH.js} +5 -1
- package/dist/{chunk-4QXB6PEO.js → chunk-QLPTHTVB.js} +37 -16
- package/dist/{chunk-QPASI2BR.js → chunk-REXY4LUL.js} +49 -10
- package/dist/chunk-T5EUJQE5.js +172 -0
- package/dist/{chunk-DPVS43ZT.js → chunk-TTBKTF3P.js} +5 -5
- package/dist/{chunk-OHAC6HJE.js → chunk-ZIVQNSZU.js} +16 -36
- package/dist/{chunk-BUWWN2NX.js → chunk-ZJTDUCC2.js} +9 -7
- package/dist/cli/neuroverse.cjs +2582 -493
- package/dist/cli/neuroverse.js +39 -15
- package/dist/cli/plan.cjs +119 -32
- package/dist/cli/plan.js +5 -13
- package/dist/cli/run.cjs +223 -24
- package/dist/cli/run.js +2 -2
- package/dist/decision-flow-LETV5NWY.js +61 -0
- package/dist/{derive-TLIV4OOU.js → derive-7365SUFU.js} +2 -2
- package/dist/{doctor-QV6HELS5.js → doctor-QYISMKEL.js} +5 -2
- package/dist/equity-penalties-63FGB3I2.js +244 -0
- package/dist/{explain-IDCRWMPX.js → explain-A2EWI2OL.js} +4 -23
- package/dist/{guard-GFLQZY6U.js → guard-3BWL3IGH.js} +6 -10
- package/dist/{guard-contract-Cm91Kp4j.d.ts → guard-contract-C9_zKbzd.d.cts} +117 -5
- package/dist/{guard-contract-Cm91Kp4j.d.cts → guard-contract-C9_zKbzd.d.ts} +117 -5
- package/dist/{guard-engine-JLTUARGU.js → guard-engine-QFMIBWJY.js} +2 -2
- package/dist/{impact-XPECYRLH.js → impact-UB6DXKSX.js} +4 -4
- package/dist/{improve-GPUBKTEA.js → improve-XZA57GER.js} +5 -24
- package/dist/index.cjs +592 -44
- package/dist/index.d.cts +218 -5
- package/dist/index.d.ts +218 -5
- package/dist/index.js +92 -41
- package/dist/infer-world-7GVZWFX4.js +543 -0
- package/dist/init-world-VWMQZQC7.js +223 -0
- package/dist/{mcp-server-LZVJHBT5.js → mcp-server-XWQZXNW7.js} +3 -3
- package/dist/{playground-FGOMASHN.js → playground-ADWZORNV.js} +2 -2
- package/dist/{redteam-SK7AMIG3.js → redteam-JRQ7FD2F.js} +2 -2
- package/dist/{session-VISISNWJ.js → session-MMYX5YCF.js} +4 -3
- package/dist/shared--Q8wPBVN.d.ts +60 -0
- package/dist/shared-HpAG90PX.d.cts +60 -0
- package/dist/shared-U2QFV7JH.js +16 -0
- package/dist/{simulate-VDOYQFRO.js → simulate-GMIFFXYV.js} +5 -30
- package/dist/{test-75AVHC3R.js → test-JBBZ65X4.js} +2 -2
- package/dist/{trace-JVF67VR3.js → trace-3MYWIDEF.js} +3 -3
- package/dist/worlds/autoresearch.nv-world.md +230 -0
- package/dist/worlds/coding-agent.nv-world.md +211 -0
- package/llms.txt +79 -0
- package/openapi.yaml +230 -0
- package/package.json +26 -4
- package/dist/{chunk-GR6DGCZ2.js → chunk-BMOXICAB.js} +3 -3
- package/dist/{chunk-NF5POFCI.js → chunk-ORJ3NOE6.js} +3 -3
- package/dist/{world-LAXO6DOX.js → world-BFJCIQSH.js} +3 -3
package/dist/adapters/openai.cjs
CHANGED
|
@@ -30,24 +30,34 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/adapters/openai.ts
|
|
31
31
|
var openai_exports = {};
|
|
32
32
|
__export(openai_exports, {
|
|
33
|
-
GovernanceBlockedError: () =>
|
|
33
|
+
GovernanceBlockedError: () => GovernanceBlockedError2,
|
|
34
34
|
GovernedToolExecutor: () => GovernedToolExecutor,
|
|
35
35
|
createGovernedToolExecutor: () => createGovernedToolExecutor,
|
|
36
36
|
createGovernedToolExecutorFromWorld: () => createGovernedToolExecutorFromWorld
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(openai_exports);
|
|
39
39
|
|
|
40
|
-
// src/engine/
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
// src/engine/text-utils.ts
|
|
41
|
+
function normalizeEventText(event) {
|
|
42
|
+
return [
|
|
43
|
+
event.intent,
|
|
44
|
+
event.tool ?? "",
|
|
45
|
+
event.scope ?? ""
|
|
46
46
|
].join(" ").toLowerCase();
|
|
47
|
-
|
|
47
|
+
}
|
|
48
|
+
function extractKeywords(text, minLength = 3) {
|
|
49
|
+
return text.toLowerCase().split(/\s+/).filter((w) => w.length > minLength);
|
|
50
|
+
}
|
|
51
|
+
function matchesAllKeywords(eventText, ruleText) {
|
|
52
|
+
const keywords = extractKeywords(ruleText);
|
|
53
|
+
if (keywords.length === 0) return false;
|
|
54
|
+
return keywords.every((kw) => eventText.includes(kw));
|
|
55
|
+
}
|
|
56
|
+
function matchesKeywordThreshold(eventText, ruleText, threshold = 0.5) {
|
|
57
|
+
const keywords = extractKeywords(ruleText);
|
|
48
58
|
if (keywords.length === 0) return false;
|
|
49
59
|
const matched = keywords.filter((kw) => eventText.includes(kw));
|
|
50
|
-
return matched.length >= Math.ceil(keywords.length *
|
|
60
|
+
return matched.length >= Math.ceil(keywords.length * threshold);
|
|
51
61
|
}
|
|
52
62
|
function tokenSimilarity(a, b) {
|
|
53
63
|
const tokensA = new Set(a.toLowerCase().split(/\s+/).filter((w) => w.length > 2));
|
|
@@ -60,6 +70,19 @@ function tokenSimilarity(a, b) {
|
|
|
60
70
|
const union = (/* @__PURE__ */ new Set([...tokensA, ...tokensB])).size;
|
|
61
71
|
return union > 0 ? intersection / union : 0;
|
|
62
72
|
}
|
|
73
|
+
|
|
74
|
+
// src/engine/plan-engine.ts
|
|
75
|
+
function keywordMatch(eventText, step) {
|
|
76
|
+
const stepText = [
|
|
77
|
+
step.label,
|
|
78
|
+
step.description ?? "",
|
|
79
|
+
...step.tags ?? []
|
|
80
|
+
].join(" ");
|
|
81
|
+
return matchesKeywordThreshold(eventText, stepText, 0.5);
|
|
82
|
+
}
|
|
83
|
+
function tokenSimilarity2(a, b) {
|
|
84
|
+
return tokenSimilarity(a, b);
|
|
85
|
+
}
|
|
63
86
|
function findMatchingStep(eventText, event, steps) {
|
|
64
87
|
const pendingOrActive = steps.filter((s) => s.status === "pending" || s.status === "active");
|
|
65
88
|
if (pendingOrActive.length === 0) {
|
|
@@ -78,7 +101,7 @@ function findMatchingStep(eventText, event, steps) {
|
|
|
78
101
|
let bestScore = 0;
|
|
79
102
|
for (const step of pendingOrActive) {
|
|
80
103
|
const stepText = [step.label, step.description ?? "", ...step.tags ?? []].join(" ");
|
|
81
|
-
const score =
|
|
104
|
+
const score = tokenSimilarity2(intentText, stepText);
|
|
82
105
|
if (score > bestScore) {
|
|
83
106
|
bestScore = score;
|
|
84
107
|
bestStep = step;
|
|
@@ -119,7 +142,7 @@ function checkConstraints(event, eventText, constraints) {
|
|
|
119
142
|
continue;
|
|
120
143
|
}
|
|
121
144
|
if (constraint.type === "scope" && constraint.trigger) {
|
|
122
|
-
const keywords = constraint.trigger
|
|
145
|
+
const keywords = extractKeywords(constraint.trigger);
|
|
123
146
|
const violated = keywords.length > 0 && keywords.every((kw) => eventText.includes(kw));
|
|
124
147
|
checks.push({
|
|
125
148
|
constraintId: constraint.id,
|
|
@@ -200,11 +223,7 @@ function evaluatePlan(event, plan) {
|
|
|
200
223
|
progress
|
|
201
224
|
};
|
|
202
225
|
}
|
|
203
|
-
const eventText =
|
|
204
|
-
event.intent,
|
|
205
|
-
event.tool ?? "",
|
|
206
|
-
event.scope ?? ""
|
|
207
|
-
].join(" ").toLowerCase();
|
|
226
|
+
const eventText = normalizeEventText(event);
|
|
208
227
|
const { matched, closest, closestScore } = findMatchingStep(eventText, event, plan.steps);
|
|
209
228
|
if (!matched) {
|
|
210
229
|
return {
|
|
@@ -245,7 +264,7 @@ function evaluatePlan(event, plan) {
|
|
|
245
264
|
};
|
|
246
265
|
}
|
|
247
266
|
function buildPlanCheck(event, plan, verdict) {
|
|
248
|
-
const eventText =
|
|
267
|
+
const eventText = normalizeEventText(event);
|
|
249
268
|
const { matched, closest, closestScore } = findMatchingStep(eventText, event, plan.steps);
|
|
250
269
|
const { checks: constraintChecks } = checkConstraints(event, eventText, plan.constraints);
|
|
251
270
|
const progress = getPlanProgress(plan);
|
|
@@ -351,7 +370,7 @@ function evaluateGuard(event, world, options = {}) {
|
|
|
351
370
|
const startTime = performance.now();
|
|
352
371
|
const level = options.level ?? "standard";
|
|
353
372
|
const includeTrace = options.trace ?? false;
|
|
354
|
-
const eventText = (event
|
|
373
|
+
const eventText = normalizeEventText(event);
|
|
355
374
|
const invariantChecks = [];
|
|
356
375
|
const safetyChecks = [];
|
|
357
376
|
let planCheckResult;
|
|
@@ -364,6 +383,43 @@ function evaluateGuard(event, world, options = {}) {
|
|
|
364
383
|
const guardsMatched = [];
|
|
365
384
|
const rulesMatched = [];
|
|
366
385
|
checkInvariantCoverage(world, invariantChecks);
|
|
386
|
+
if (event.roleId && options.agentStates) {
|
|
387
|
+
const agentState = options.agentStates.get(event.roleId);
|
|
388
|
+
if (agentState && agentState.cooldownRemaining > 0) {
|
|
389
|
+
decidingLayer = "safety";
|
|
390
|
+
decidingId = `penalize-cooldown-${event.roleId}`;
|
|
391
|
+
const verdict = buildVerdict(
|
|
392
|
+
"PENALIZE",
|
|
393
|
+
`Agent "${event.roleId}" is frozen for ${agentState.cooldownRemaining} more round(s) due to prior penalty.`,
|
|
394
|
+
`penalize-cooldown-${event.roleId}`,
|
|
395
|
+
void 0,
|
|
396
|
+
world,
|
|
397
|
+
level,
|
|
398
|
+
invariantChecks,
|
|
399
|
+
guardsMatched,
|
|
400
|
+
rulesMatched,
|
|
401
|
+
includeTrace ? buildTrace(
|
|
402
|
+
invariantChecks,
|
|
403
|
+
safetyChecks,
|
|
404
|
+
planCheckResult,
|
|
405
|
+
roleChecks,
|
|
406
|
+
guardChecks,
|
|
407
|
+
kernelRuleChecks,
|
|
408
|
+
levelChecks,
|
|
409
|
+
decidingLayer,
|
|
410
|
+
decidingId,
|
|
411
|
+
startTime
|
|
412
|
+
) : void 0
|
|
413
|
+
);
|
|
414
|
+
verdict.intentRecord = {
|
|
415
|
+
originalIntent: event.intent,
|
|
416
|
+
finalAction: "blocked (agent frozen)",
|
|
417
|
+
enforcement: "PENALIZE",
|
|
418
|
+
consequence: { type: "freeze", rounds: agentState.cooldownRemaining, description: "Agent still in cooldown from prior penalty" }
|
|
419
|
+
};
|
|
420
|
+
return verdict;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
367
423
|
if (options.sessionAllowlist) {
|
|
368
424
|
const key = eventToAllowlistKey(event);
|
|
369
425
|
if (options.sessionAllowlist.has(key)) {
|
|
@@ -491,7 +547,16 @@ function evaluateGuard(event, world, options = {}) {
|
|
|
491
547
|
if (guardVerdict.status !== "ALLOW") {
|
|
492
548
|
decidingLayer = "guard";
|
|
493
549
|
decidingId = guardVerdict.ruleId;
|
|
494
|
-
|
|
550
|
+
const intentRecord = {
|
|
551
|
+
originalIntent: event.intent,
|
|
552
|
+
finalAction: guardVerdict.status === "MODIFY" ? guardVerdict.modifiedTo ?? "modified" : guardVerdict.status === "PENALIZE" ? "blocked + penalized" : guardVerdict.status === "REWARD" ? event.intent : guardVerdict.status === "NEUTRAL" ? event.intent : guardVerdict.status === "BLOCK" ? "blocked" : "paused",
|
|
553
|
+
ruleApplied: guardVerdict.ruleId,
|
|
554
|
+
enforcement: guardVerdict.status,
|
|
555
|
+
modifiedTo: guardVerdict.modifiedTo,
|
|
556
|
+
consequence: guardVerdict.consequence,
|
|
557
|
+
reward: guardVerdict.reward
|
|
558
|
+
};
|
|
559
|
+
const verdict = buildVerdict(
|
|
495
560
|
guardVerdict.status,
|
|
496
561
|
guardVerdict.reason,
|
|
497
562
|
guardVerdict.ruleId,
|
|
@@ -514,6 +579,10 @@ function evaluateGuard(event, world, options = {}) {
|
|
|
514
579
|
startTime
|
|
515
580
|
) : void 0
|
|
516
581
|
);
|
|
582
|
+
verdict.intentRecord = intentRecord;
|
|
583
|
+
if (guardVerdict.consequence) verdict.consequence = guardVerdict.consequence;
|
|
584
|
+
if (guardVerdict.reward) verdict.reward = guardVerdict.reward;
|
|
585
|
+
return verdict;
|
|
517
586
|
}
|
|
518
587
|
}
|
|
519
588
|
const kernelVerdict = checkKernelRules(eventText, world, kernelRuleChecks, rulesMatched);
|
|
@@ -808,6 +877,21 @@ function checkGuards(event, eventText, world, checks, guardsMatched) {
|
|
|
808
877
|
if (actionMode === "pause") {
|
|
809
878
|
return { status: "PAUSE", reason, ruleId: `guard-${guard.id}` };
|
|
810
879
|
}
|
|
880
|
+
if (actionMode === "penalize") {
|
|
881
|
+
const consequence = guard.consequence ? { ...guard.consequence } : { type: "freeze", rounds: 1, description: `Penalized for violating: ${guard.label}` };
|
|
882
|
+
return { status: "PENALIZE", reason, ruleId: `guard-${guard.id}`, consequence };
|
|
883
|
+
}
|
|
884
|
+
if (actionMode === "reward") {
|
|
885
|
+
const reward = guard.reward ? { ...guard.reward } : { type: "boost_influence", magnitude: 0.1, description: `Rewarded for: ${guard.label}` };
|
|
886
|
+
return { status: "REWARD", reason, ruleId: `guard-${guard.id}`, reward };
|
|
887
|
+
}
|
|
888
|
+
if (actionMode === "modify") {
|
|
889
|
+
const modifiedTo = guard.modify_to ?? guard.redirect ?? "hold";
|
|
890
|
+
return { status: "MODIFY", reason: `${reason} \u2192 Modified to: ${modifiedTo}`, ruleId: `guard-${guard.id}`, modifiedTo };
|
|
891
|
+
}
|
|
892
|
+
if (actionMode === "neutral") {
|
|
893
|
+
return { status: "NEUTRAL", reason, ruleId: `guard-${guard.id}` };
|
|
894
|
+
}
|
|
811
895
|
if (actionMode === "warn" && !warnResult) {
|
|
812
896
|
warnResult = { status: "ALLOW", warning: reason, ruleId: `guard-${guard.id}` };
|
|
813
897
|
}
|
|
@@ -917,9 +1001,7 @@ function checkLevelConstraints(event, level, checks) {
|
|
|
917
1001
|
return null;
|
|
918
1002
|
}
|
|
919
1003
|
function matchesKeywords(eventText, ruleText) {
|
|
920
|
-
|
|
921
|
-
if (keywords.length === 0) return false;
|
|
922
|
-
return keywords.every((kw) => eventText.includes(kw));
|
|
1004
|
+
return matchesAllKeywords(eventText, ruleText);
|
|
923
1005
|
}
|
|
924
1006
|
function eventToAllowlistKey(event) {
|
|
925
1007
|
return `${(event.tool ?? "*").toLowerCase()}::${event.intent.toLowerCase().trim()}`;
|
|
@@ -1056,14 +1138,55 @@ async function loadWorld(worldPath) {
|
|
|
1056
1138
|
throw new Error(`Cannot load world from: ${worldPath} \u2014 expected a directory or .nv-world.zip`);
|
|
1057
1139
|
}
|
|
1058
1140
|
|
|
1059
|
-
// src/adapters/
|
|
1141
|
+
// src/adapters/shared.ts
|
|
1060
1142
|
var GovernanceBlockedError = class extends Error {
|
|
1061
1143
|
verdict;
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
super(`[NeuroVerse] BLOCKED: ${verdict.reason ?? verdict.ruleId ?? "governance rule"}`);
|
|
1144
|
+
constructor(verdict, message) {
|
|
1145
|
+
super(message ?? `[NeuroVerse] BLOCKED: ${verdict.reason ?? verdict.ruleId ?? "governance rule"}`);
|
|
1065
1146
|
this.name = "GovernanceBlockedError";
|
|
1066
1147
|
this.verdict = verdict;
|
|
1148
|
+
}
|
|
1149
|
+
};
|
|
1150
|
+
function trackPlanProgress(event, state, callbacks) {
|
|
1151
|
+
if (!state.activePlan) return;
|
|
1152
|
+
const planVerdict = evaluatePlan(event, state.activePlan);
|
|
1153
|
+
if (planVerdict.matchedStep) {
|
|
1154
|
+
const advResult = advancePlan(state.activePlan, planVerdict.matchedStep);
|
|
1155
|
+
if (advResult.success && advResult.plan) {
|
|
1156
|
+
state.activePlan = advResult.plan;
|
|
1157
|
+
state.engineOptions.plan = state.activePlan;
|
|
1158
|
+
}
|
|
1159
|
+
const progress = getPlanProgress(state.activePlan);
|
|
1160
|
+
callbacks.onPlanProgress?.(progress);
|
|
1161
|
+
if (progress.completed === progress.total) {
|
|
1162
|
+
callbacks.onPlanComplete?.();
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
function extractScope(args) {
|
|
1167
|
+
if (typeof args.path === "string") return args.path;
|
|
1168
|
+
if (typeof args.file_path === "string") return args.file_path;
|
|
1169
|
+
if (typeof args.filename === "string") return args.filename;
|
|
1170
|
+
if (typeof args.url === "string") return args.url;
|
|
1171
|
+
if (typeof args.command === "string") return args.command;
|
|
1172
|
+
return void 0;
|
|
1173
|
+
}
|
|
1174
|
+
function buildEngineOptions(options, plan) {
|
|
1175
|
+
return {
|
|
1176
|
+
trace: options.trace ?? false,
|
|
1177
|
+
level: options.level,
|
|
1178
|
+
plan: plan ?? options.plan
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
function defaultBlockMessage(verdict) {
|
|
1182
|
+
return `Action blocked by governance policy: ${verdict.reason ?? "rule violation"}. Rule: ${verdict.ruleId ?? "unknown"}.`;
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
// src/adapters/openai.ts
|
|
1186
|
+
var GovernanceBlockedError2 = class extends GovernanceBlockedError {
|
|
1187
|
+
toolCallId;
|
|
1188
|
+
constructor(verdict, toolCallId) {
|
|
1189
|
+
super(verdict);
|
|
1067
1190
|
this.toolCallId = toolCallId;
|
|
1068
1191
|
}
|
|
1069
1192
|
};
|
|
@@ -1071,14 +1194,11 @@ function defaultMapFunctionCall(name, args) {
|
|
|
1071
1194
|
return {
|
|
1072
1195
|
intent: name,
|
|
1073
1196
|
tool: name,
|
|
1074
|
-
scope:
|
|
1197
|
+
scope: extractScope(args),
|
|
1075
1198
|
args,
|
|
1076
1199
|
direction: "input"
|
|
1077
1200
|
};
|
|
1078
1201
|
}
|
|
1079
|
-
function defaultBlockMessage(verdict) {
|
|
1080
|
-
return `Action blocked by governance policy: ${verdict.reason ?? "rule violation"}. Rule: ${verdict.ruleId ?? "unknown"}.`;
|
|
1081
|
-
}
|
|
1082
1202
|
var GovernedToolExecutor = class {
|
|
1083
1203
|
world;
|
|
1084
1204
|
options;
|
|
@@ -1090,11 +1210,7 @@ var GovernedToolExecutor = class {
|
|
|
1090
1210
|
this.world = world;
|
|
1091
1211
|
this.options = options;
|
|
1092
1212
|
this.activePlan = options.plan;
|
|
1093
|
-
this.engineOptions =
|
|
1094
|
-
trace: options.trace ?? false,
|
|
1095
|
-
level: options.level,
|
|
1096
|
-
plan: this.activePlan
|
|
1097
|
-
};
|
|
1213
|
+
this.engineOptions = buildEngineOptions(options, this.activePlan);
|
|
1098
1214
|
this.mapFn = options.mapFunctionCall ?? defaultMapFunctionCall;
|
|
1099
1215
|
this.blockMsg = options.blockMessage ?? defaultBlockMessage;
|
|
1100
1216
|
}
|
|
@@ -1113,20 +1229,8 @@ var GovernedToolExecutor = class {
|
|
|
1113
1229
|
this.engineOptions.plan = this.activePlan;
|
|
1114
1230
|
const verdict = evaluateGuard(event, this.world, this.engineOptions);
|
|
1115
1231
|
this.options.onEvaluate?.(verdict, event);
|
|
1116
|
-
if (verdict.status === "ALLOW"
|
|
1117
|
-
|
|
1118
|
-
if (planVerdict.matchedStep) {
|
|
1119
|
-
const advResult = advancePlan(this.activePlan, planVerdict.matchedStep);
|
|
1120
|
-
if (advResult.success && advResult.plan) {
|
|
1121
|
-
this.activePlan = advResult.plan;
|
|
1122
|
-
this.engineOptions.plan = this.activePlan;
|
|
1123
|
-
}
|
|
1124
|
-
const progress = getPlanProgress(this.activePlan);
|
|
1125
|
-
this.options.onPlanProgress?.(progress);
|
|
1126
|
-
if (progress.completed === progress.total) {
|
|
1127
|
-
this.options.onPlanComplete?.();
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1232
|
+
if (verdict.status === "ALLOW") {
|
|
1233
|
+
trackPlanProgress(event, this, this.options);
|
|
1130
1234
|
}
|
|
1131
1235
|
return verdict;
|
|
1132
1236
|
}
|
|
@@ -1152,7 +1256,7 @@ var GovernedToolExecutor = class {
|
|
|
1152
1256
|
};
|
|
1153
1257
|
}
|
|
1154
1258
|
if (verdict.status === "PAUSE") {
|
|
1155
|
-
throw new
|
|
1259
|
+
throw new GovernanceBlockedError2(verdict, toolCall.id);
|
|
1156
1260
|
}
|
|
1157
1261
|
let args;
|
|
1158
1262
|
try {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as GuardVerdict, G as GuardEvent, P as PlanDefinition, c as PlanProgress, b as GuardEngineOptions, W as WorldDefinition } from '../guard-contract-C9_zKbzd.cjs';
|
|
2
|
+
import { G as GovernanceBlockedError$1 } from '../shared-HpAG90PX.cjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* NeuroVerse Adapter — OpenAI
|
|
@@ -52,8 +53,7 @@ interface GovernedExecutorOptions {
|
|
|
52
53
|
/** Called when all plan steps are completed. */
|
|
53
54
|
onPlanComplete?: () => void;
|
|
54
55
|
}
|
|
55
|
-
declare class GovernanceBlockedError extends
|
|
56
|
-
readonly verdict: GuardVerdict;
|
|
56
|
+
declare class GovernanceBlockedError extends GovernanceBlockedError$1 {
|
|
57
57
|
readonly toolCallId: string;
|
|
58
58
|
constructor(verdict: GuardVerdict, toolCallId: string);
|
|
59
59
|
}
|
|
@@ -64,10 +64,10 @@ declare class GovernanceBlockedError extends Error {
|
|
|
64
64
|
declare class GovernedToolExecutor {
|
|
65
65
|
private world;
|
|
66
66
|
private options;
|
|
67
|
-
|
|
67
|
+
engineOptions: GuardEngineOptions;
|
|
68
68
|
private mapFn;
|
|
69
69
|
private blockMsg;
|
|
70
|
-
|
|
70
|
+
activePlan?: PlanDefinition;
|
|
71
71
|
constructor(world: WorldDefinition, options?: GovernedExecutorOptions);
|
|
72
72
|
/**
|
|
73
73
|
* Evaluate a single tool call against governance rules.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as GuardVerdict, G as GuardEvent, P as PlanDefinition, c as PlanProgress, b as GuardEngineOptions, W as WorldDefinition } from '../guard-contract-C9_zKbzd.js';
|
|
2
|
+
import { G as GovernanceBlockedError$1 } from '../shared--Q8wPBVN.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* NeuroVerse Adapter — OpenAI
|
|
@@ -52,8 +53,7 @@ interface GovernedExecutorOptions {
|
|
|
52
53
|
/** Called when all plan steps are completed. */
|
|
53
54
|
onPlanComplete?: () => void;
|
|
54
55
|
}
|
|
55
|
-
declare class GovernanceBlockedError extends
|
|
56
|
-
readonly verdict: GuardVerdict;
|
|
56
|
+
declare class GovernanceBlockedError extends GovernanceBlockedError$1 {
|
|
57
57
|
readonly toolCallId: string;
|
|
58
58
|
constructor(verdict: GuardVerdict, toolCallId: string);
|
|
59
59
|
}
|
|
@@ -64,10 +64,10 @@ declare class GovernanceBlockedError extends Error {
|
|
|
64
64
|
declare class GovernedToolExecutor {
|
|
65
65
|
private world;
|
|
66
66
|
private options;
|
|
67
|
-
|
|
67
|
+
engineOptions: GuardEngineOptions;
|
|
68
68
|
private mapFn;
|
|
69
69
|
private blockMsg;
|
|
70
|
-
|
|
70
|
+
activePlan?: PlanDefinition;
|
|
71
71
|
constructor(world: WorldDefinition, options?: GovernedExecutorOptions);
|
|
72
72
|
/**
|
|
73
73
|
* Evaluate a single tool call against governance rules.
|
package/dist/adapters/openai.js
CHANGED
|
@@ -3,10 +3,11 @@ import {
|
|
|
3
3
|
GovernedToolExecutor,
|
|
4
4
|
createGovernedToolExecutor,
|
|
5
5
|
createGovernedToolExecutorFromWorld
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-ZIVQNSZU.js";
|
|
7
|
+
import "../chunk-5U2MQO5P.js";
|
|
8
|
+
import "../chunk-IZSO75NZ.js";
|
|
9
|
+
import "../chunk-QLPTHTVB.js";
|
|
8
10
|
import "../chunk-JZPQGIKR.js";
|
|
9
|
-
import "../chunk-4QXB6PEO.js";
|
|
10
11
|
import "../chunk-YZFATT7X.js";
|
|
11
12
|
export {
|
|
12
13
|
GovernanceBlockedError,
|