@neuroverseos/governance 0.3.1 → 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 +343 -248
- package/dist/adapters/autoresearch.cjs +1345 -0
- package/dist/adapters/autoresearch.d.cts +111 -0
- package/dist/adapters/autoresearch.d.ts +111 -0
- package/dist/adapters/autoresearch.js +12 -0
- 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 +1253 -0
- package/dist/adapters/express.d.cts +66 -0
- package/dist/adapters/express.d.ts +66 -0
- package/dist/adapters/express.js +12 -0
- package/dist/adapters/index.cjs +2112 -0
- package/dist/adapters/index.d.cts +8 -0
- package/dist/adapters/index.d.ts +8 -0
- package/dist/adapters/index.js +68 -0
- package/dist/adapters/langchain.cjs +1315 -0
- package/dist/adapters/langchain.d.cts +89 -0
- package/dist/adapters/langchain.d.ts +89 -0
- package/dist/adapters/langchain.js +17 -0
- package/dist/adapters/openai.cjs +1345 -0
- package/dist/adapters/openai.d.cts +99 -0
- package/dist/adapters/openai.d.ts +99 -0
- package/dist/adapters/openai.js +17 -0
- package/dist/adapters/openclaw.cjs +1337 -0
- package/dist/adapters/openclaw.d.cts +99 -0
- package/dist/adapters/openclaw.d.ts +99 -0
- package/dist/adapters/openclaw.js +17 -0
- package/dist/add-ROOZLU62.js +314 -0
- package/dist/behavioral-MJO34S6Q.js +118 -0
- package/dist/bootstrap-CQRZVOXK.js +116 -0
- 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-QKOBBC23.js +341 -0
- package/dist/chunk-3WQLXYTP.js +91 -0
- package/dist/chunk-4FLICVVA.js +119 -0
- package/dist/chunk-4NGDRRQH.js +10 -0
- package/dist/chunk-5TPFNWRU.js +215 -0
- package/dist/chunk-5U2MQO5P.js +57 -0
- package/dist/chunk-6CZSKEY5.js +164 -0
- package/dist/chunk-6S5CFQXY.js +624 -0
- package/dist/chunk-7P3S7MAY.js +1090 -0
- package/dist/chunk-A5W4GNQO.js +130 -0
- package/dist/chunk-A7GKPPU7.js +226 -0
- package/dist/chunk-AKW5YVCE.js +96 -0
- package/dist/chunk-B6OXJLJ5.js +622 -0
- package/dist/chunk-BNKJPUPQ.js +113 -0
- package/dist/chunk-BQZMOEML.js +43 -0
- package/dist/chunk-CNSO6XW5.js +207 -0
- package/dist/chunk-CTZHONLA.js +135 -0
- package/dist/chunk-D2UCV5AK.js +326 -0
- package/dist/chunk-EMQDLDAF.js +458 -0
- package/dist/chunk-F66BVUYB.js +340 -0
- package/dist/chunk-G7DJ6VOD.js +101 -0
- package/dist/chunk-I3RRAYK2.js +11 -0
- package/dist/chunk-IS4WUH6Y.js +363 -0
- package/dist/chunk-MH7BT4VH.js +15 -0
- package/dist/chunk-O5ABKEA7.js +304 -0
- package/dist/chunk-OT6PXH54.js +61 -0
- package/dist/chunk-PVTQQS3Y.js +186 -0
- package/dist/chunk-Q6O7ZLO2.js +62 -0
- package/dist/chunk-QLPTHTVB.js +253 -0
- package/dist/chunk-QWGCMQQD.js +16 -0
- package/dist/chunk-QXBFT7NI.js +201 -0
- package/dist/chunk-TG6SEF24.js +246 -0
- package/dist/chunk-U6U7EJZL.js +177 -0
- package/dist/chunk-W7LLXRGY.js +830 -0
- package/dist/chunk-ZJTDUCC2.js +194 -0
- package/dist/chunk-ZWI3NIXK.js +314 -0
- package/dist/cli/neuroverse.cjs +14191 -0
- package/dist/cli/neuroverse.d.cts +1 -0
- package/dist/cli/neuroverse.d.ts +1 -0
- package/dist/cli/neuroverse.js +227 -0
- package/dist/cli/plan.cjs +2439 -0
- package/dist/cli/plan.d.cts +20 -0
- package/dist/cli/plan.d.ts +20 -0
- package/dist/cli/plan.js +353 -0
- package/dist/cli/run.cjs +2001 -0
- package/dist/cli/run.d.cts +20 -0
- package/dist/cli/run.d.ts +20 -0
- package/dist/cli/run.js +143 -0
- package/dist/configure-ai-6TZ3MCSI.js +132 -0
- package/dist/decision-flow-M63D47LO.js +61 -0
- package/dist/demo-G43RLCPK.js +469 -0
- package/dist/derive-FJZVIPUZ.js +153 -0
- package/dist/doctor-6BC6X2VO.js +173 -0
- package/dist/equity-penalties-SG5IZQ7I.js +244 -0
- package/dist/explain-RHBU2GBR.js +51 -0
- package/dist/guard-AJCCGZMF.js +92 -0
- package/dist/guard-contract-DqFcTScd.d.cts +821 -0
- package/dist/guard-contract-DqFcTScd.d.ts +821 -0
- package/dist/guard-engine-PNR6MHCM.js +10 -0
- package/dist/impact-3XVDSCBU.js +59 -0
- package/dist/improve-TQP4ECSY.js +66 -0
- package/dist/index.cjs +7591 -0
- package/dist/index.d.cts +2195 -0
- package/dist/index.d.ts +2195 -0
- package/dist/index.js +472 -0
- package/dist/infer-world-IFXCACJ5.js +543 -0
- package/dist/init-FYPV4SST.js +144 -0
- package/dist/init-world-TI7ARHBT.js +223 -0
- package/dist/mcp-server-5Y3ZM7TV.js +13 -0
- package/dist/model-adapter-VXEKB4LS.js +11 -0
- package/dist/playground-VZBNPPBO.js +560 -0
- package/dist/redteam-MZPZD3EF.js +357 -0
- 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-LJXYBC6M.js +83 -0
- package/dist/test-BOOR4A5F.js +217 -0
- package/dist/trace-PKV4KX56.js +166 -0
- package/dist/validate-RALX7CZS.js +81 -0
- package/dist/validate-engine-7ZXFVGF2.js +7 -0
- package/dist/viz/assets/index-B8SaeJZZ.js +23 -0
- package/dist/viz/index.html +23 -0
- package/dist/world-BIP4GZBZ.js +376 -0
- package/dist/world-loader-Y6HMQH2D.js +13 -0
- package/dist/worlds/autoresearch.nv-world.md +230 -0
- package/dist/worlds/coding-agent.nv-world.md +211 -0
- package/dist/worlds/derivation-world.nv-world.md +278 -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 +16 -3
- package/simulate.html +4 -336
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { b as GuardEngineOptions, P as PlanDefinition, W as WorldDefinition, a as GuardVerdict, G as GuardEvent, c as PlanProgress } from '../guard-contract-DqFcTScd.cjs';
|
|
2
|
+
import { G as GovernanceBlockedError$1 } from '../shared-B8dvUUD8.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Centralized Tool Classification & Risk Pattern Detection
|
|
6
|
+
*
|
|
7
|
+
* Extracted from deep-agents.ts where it was the only adapter
|
|
8
|
+
* with comprehensive tool classification and dangerous command
|
|
9
|
+
* detection. Now available to all adapters and the core engine.
|
|
10
|
+
*/
|
|
11
|
+
type ToolCategory = 'file_read' | 'file_write' | 'file_delete' | 'shell' | 'git' | 'network' | 'sub_agent' | 'context' | 'unknown';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* NeuroVerse Adapter — Deep Agents (LangChain)
|
|
15
|
+
*
|
|
16
|
+
* Intercepts tool execution in LangChain's Deep Agents framework
|
|
17
|
+
* and evaluates every action against a NeuroVerse world definition
|
|
18
|
+
* before allowing it to proceed.
|
|
19
|
+
*
|
|
20
|
+
* Deep Agents exposes a coding-agent loop with tools for file I/O,
|
|
21
|
+
* shell execution, sub-agent spawning, and context management.
|
|
22
|
+
* This adapter sits between the agent and those tools, enforcing
|
|
23
|
+
* governance rules deterministically.
|
|
24
|
+
*
|
|
25
|
+
* Usage:
|
|
26
|
+
* import { createDeepAgentsGuard } from '@neuroverseos/governance/adapters/deep-agents';
|
|
27
|
+
*
|
|
28
|
+
* const guard = await createDeepAgentsGuard('./world/');
|
|
29
|
+
*
|
|
30
|
+
* // Wrap the agent's tool executor:
|
|
31
|
+
* agent.use(guard.middleware());
|
|
32
|
+
*
|
|
33
|
+
* // Or evaluate manually:
|
|
34
|
+
* const verdict = guard.evaluate({ tool: 'shell', command: 'rm -rf /' });
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/** Shape of a Deep Agents tool invocation. */
|
|
38
|
+
interface DeepAgentsToolCall {
|
|
39
|
+
/** Tool name: read_file, write_file, shell, edit_file, sub_agent, etc. */
|
|
40
|
+
tool: string;
|
|
41
|
+
/** Tool arguments as passed by the agent. */
|
|
42
|
+
args: Record<string, unknown>;
|
|
43
|
+
/** Optional run/session identifier. */
|
|
44
|
+
runId?: string;
|
|
45
|
+
}
|
|
46
|
+
/** Categorized tool types recognized by the adapter (re-exported from tool-classifier). */
|
|
47
|
+
type DeepAgentsToolCategory = ToolCategory;
|
|
48
|
+
/** Result of a governed evaluation. */
|
|
49
|
+
interface DeepAgentsGuardResult {
|
|
50
|
+
allowed: boolean;
|
|
51
|
+
verdict: GuardVerdict;
|
|
52
|
+
toolCall: DeepAgentsToolCall;
|
|
53
|
+
category: DeepAgentsToolCategory;
|
|
54
|
+
}
|
|
55
|
+
interface DeepAgentsGuardOptions {
|
|
56
|
+
/** Include full evaluation trace in verdicts. Default: false. */
|
|
57
|
+
trace?: boolean;
|
|
58
|
+
/** Enforcement level override. */
|
|
59
|
+
level?: 'basic' | 'standard' | 'strict';
|
|
60
|
+
/** Called when an action is blocked. */
|
|
61
|
+
onBlock?: (result: DeepAgentsGuardResult) => void;
|
|
62
|
+
/** Called when an action requires approval. Return true to allow. */
|
|
63
|
+
onPause?: (result: DeepAgentsGuardResult) => Promise<boolean> | boolean;
|
|
64
|
+
/** Called for every evaluation (logging hook). */
|
|
65
|
+
onEvaluate?: (result: DeepAgentsGuardResult) => void;
|
|
66
|
+
/** Custom mapping from Deep Agents tool call to GuardEvent. */
|
|
67
|
+
mapToolCall?: (toolCall: DeepAgentsToolCall) => GuardEvent;
|
|
68
|
+
/** Active plan overlay for task-scoped governance. */
|
|
69
|
+
plan?: PlanDefinition;
|
|
70
|
+
/** Called when plan progress changes. */
|
|
71
|
+
onPlanProgress?: (progress: PlanProgress) => void;
|
|
72
|
+
/** Called when all plan steps are completed. */
|
|
73
|
+
onPlanComplete?: () => void;
|
|
74
|
+
}
|
|
75
|
+
declare class GovernanceBlockedError extends GovernanceBlockedError$1 {
|
|
76
|
+
readonly toolCall: DeepAgentsToolCall;
|
|
77
|
+
readonly category: DeepAgentsToolCategory;
|
|
78
|
+
constructor(verdict: GuardVerdict, toolCall: DeepAgentsToolCall, category: DeepAgentsToolCategory);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* NeuroVerse governance guard for LangChain Deep Agents.
|
|
82
|
+
*
|
|
83
|
+
* Evaluates every tool invocation against a world definition before
|
|
84
|
+
* allowing execution. Supports blocking, pausing (approval required),
|
|
85
|
+
* and plan-scoped governance.
|
|
86
|
+
*/
|
|
87
|
+
declare class DeepAgentsGuard {
|
|
88
|
+
readonly name = "neuroverse-deep-agents-guard";
|
|
89
|
+
private world;
|
|
90
|
+
private options;
|
|
91
|
+
engineOptions: GuardEngineOptions;
|
|
92
|
+
private mapToolCall;
|
|
93
|
+
activePlan?: PlanDefinition;
|
|
94
|
+
constructor(world: WorldDefinition, options?: DeepAgentsGuardOptions);
|
|
95
|
+
/**
|
|
96
|
+
* Evaluate a tool call against governance rules.
|
|
97
|
+
* Returns the result without side effects.
|
|
98
|
+
*/
|
|
99
|
+
evaluate(toolCall: DeepAgentsToolCall): DeepAgentsGuardResult;
|
|
100
|
+
/**
|
|
101
|
+
* Evaluate and enforce governance on a tool call.
|
|
102
|
+
*
|
|
103
|
+
* @throws GovernanceBlockedError if BLOCKED
|
|
104
|
+
* @throws GovernanceBlockedError if PAUSED and onPause returns false
|
|
105
|
+
* @returns DeepAgentsGuardResult on ALLOW
|
|
106
|
+
*/
|
|
107
|
+
enforce(toolCall: DeepAgentsToolCall): Promise<DeepAgentsGuardResult>;
|
|
108
|
+
/**
|
|
109
|
+
* Evaluate and execute a tool call with governance enforcement.
|
|
110
|
+
*
|
|
111
|
+
* If ALLOW: runs the executor and returns its result.
|
|
112
|
+
* If BLOCK: returns a governance-blocked message.
|
|
113
|
+
* If PAUSE: calls onPause; blocks if not approved.
|
|
114
|
+
*
|
|
115
|
+
* @param toolCall - The Deep Agents tool call to evaluate
|
|
116
|
+
* @param executor - The actual tool execution function
|
|
117
|
+
* @returns The tool execution result or a blocked message
|
|
118
|
+
*/
|
|
119
|
+
execute<T>(toolCall: DeepAgentsToolCall, executor: (toolCall: DeepAgentsToolCall) => Promise<T>): Promise<{
|
|
120
|
+
result: T;
|
|
121
|
+
verdict: GuardVerdict;
|
|
122
|
+
} | {
|
|
123
|
+
blocked: true;
|
|
124
|
+
verdict: GuardVerdict;
|
|
125
|
+
reason: string;
|
|
126
|
+
}>;
|
|
127
|
+
/**
|
|
128
|
+
* Returns a middleware function compatible with Deep Agents' tool pipeline.
|
|
129
|
+
*
|
|
130
|
+
* The middleware intercepts tool calls before execution:
|
|
131
|
+
* agent.use(guard.middleware());
|
|
132
|
+
*/
|
|
133
|
+
middleware(): (toolCall: DeepAgentsToolCall, next: () => Promise<unknown>) => Promise<unknown>;
|
|
134
|
+
/**
|
|
135
|
+
* Returns a callback-handler-style object for LangChain integration.
|
|
136
|
+
* Compatible with Deep Agents' callback system.
|
|
137
|
+
*/
|
|
138
|
+
callbacks(): {
|
|
139
|
+
handleToolStart: (tool: {
|
|
140
|
+
name: string;
|
|
141
|
+
}, input: string) => Promise<void>;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Check if a shell command contains dangerous patterns.
|
|
145
|
+
* Useful for pre-screening before full governance evaluation.
|
|
146
|
+
*/
|
|
147
|
+
static isDangerousCommand(command: string): {
|
|
148
|
+
dangerous: boolean;
|
|
149
|
+
labels: string[];
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Check if a git command contains dangerous patterns.
|
|
153
|
+
*/
|
|
154
|
+
static isDangerousGitCommand(command: string): {
|
|
155
|
+
dangerous: boolean;
|
|
156
|
+
labels: string[];
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Classify a tool name into a category.
|
|
160
|
+
*/
|
|
161
|
+
static classifyTool(toolName: string): DeepAgentsToolCategory;
|
|
162
|
+
private trackPlanProgressInternal;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Create a Deep Agents guard from a world path.
|
|
166
|
+
*
|
|
167
|
+
* @param worldPath - Path to world directory, .nv-world.md, or .nv-world.zip
|
|
168
|
+
* @param options - Guard configuration
|
|
169
|
+
* @returns A guard ready to plug into Deep Agents
|
|
170
|
+
*/
|
|
171
|
+
declare function createDeepAgentsGuard(worldPath: string, options?: DeepAgentsGuardOptions): Promise<DeepAgentsGuard>;
|
|
172
|
+
/**
|
|
173
|
+
* Create a Deep Agents guard from a pre-loaded world.
|
|
174
|
+
*
|
|
175
|
+
* @param world - A loaded WorldDefinition
|
|
176
|
+
* @param options - Guard configuration
|
|
177
|
+
* @returns A guard ready to plug into Deep Agents
|
|
178
|
+
*/
|
|
179
|
+
declare function createDeepAgentsGuardFromWorld(world: WorldDefinition, options?: DeepAgentsGuardOptions): DeepAgentsGuard;
|
|
180
|
+
|
|
181
|
+
export { DeepAgentsGuard, type DeepAgentsGuardOptions, type DeepAgentsGuardResult, type DeepAgentsToolCall, type DeepAgentsToolCategory, GovernanceBlockedError, createDeepAgentsGuard, createDeepAgentsGuardFromWorld };
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { b as GuardEngineOptions, P as PlanDefinition, W as WorldDefinition, a as GuardVerdict, G as GuardEvent, c as PlanProgress } from '../guard-contract-DqFcTScd.js';
|
|
2
|
+
import { G as GovernanceBlockedError$1 } from '../shared-Dr5Wiay8.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Centralized Tool Classification & Risk Pattern Detection
|
|
6
|
+
*
|
|
7
|
+
* Extracted from deep-agents.ts where it was the only adapter
|
|
8
|
+
* with comprehensive tool classification and dangerous command
|
|
9
|
+
* detection. Now available to all adapters and the core engine.
|
|
10
|
+
*/
|
|
11
|
+
type ToolCategory = 'file_read' | 'file_write' | 'file_delete' | 'shell' | 'git' | 'network' | 'sub_agent' | 'context' | 'unknown';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* NeuroVerse Adapter — Deep Agents (LangChain)
|
|
15
|
+
*
|
|
16
|
+
* Intercepts tool execution in LangChain's Deep Agents framework
|
|
17
|
+
* and evaluates every action against a NeuroVerse world definition
|
|
18
|
+
* before allowing it to proceed.
|
|
19
|
+
*
|
|
20
|
+
* Deep Agents exposes a coding-agent loop with tools for file I/O,
|
|
21
|
+
* shell execution, sub-agent spawning, and context management.
|
|
22
|
+
* This adapter sits between the agent and those tools, enforcing
|
|
23
|
+
* governance rules deterministically.
|
|
24
|
+
*
|
|
25
|
+
* Usage:
|
|
26
|
+
* import { createDeepAgentsGuard } from '@neuroverseos/governance/adapters/deep-agents';
|
|
27
|
+
*
|
|
28
|
+
* const guard = await createDeepAgentsGuard('./world/');
|
|
29
|
+
*
|
|
30
|
+
* // Wrap the agent's tool executor:
|
|
31
|
+
* agent.use(guard.middleware());
|
|
32
|
+
*
|
|
33
|
+
* // Or evaluate manually:
|
|
34
|
+
* const verdict = guard.evaluate({ tool: 'shell', command: 'rm -rf /' });
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/** Shape of a Deep Agents tool invocation. */
|
|
38
|
+
interface DeepAgentsToolCall {
|
|
39
|
+
/** Tool name: read_file, write_file, shell, edit_file, sub_agent, etc. */
|
|
40
|
+
tool: string;
|
|
41
|
+
/** Tool arguments as passed by the agent. */
|
|
42
|
+
args: Record<string, unknown>;
|
|
43
|
+
/** Optional run/session identifier. */
|
|
44
|
+
runId?: string;
|
|
45
|
+
}
|
|
46
|
+
/** Categorized tool types recognized by the adapter (re-exported from tool-classifier). */
|
|
47
|
+
type DeepAgentsToolCategory = ToolCategory;
|
|
48
|
+
/** Result of a governed evaluation. */
|
|
49
|
+
interface DeepAgentsGuardResult {
|
|
50
|
+
allowed: boolean;
|
|
51
|
+
verdict: GuardVerdict;
|
|
52
|
+
toolCall: DeepAgentsToolCall;
|
|
53
|
+
category: DeepAgentsToolCategory;
|
|
54
|
+
}
|
|
55
|
+
interface DeepAgentsGuardOptions {
|
|
56
|
+
/** Include full evaluation trace in verdicts. Default: false. */
|
|
57
|
+
trace?: boolean;
|
|
58
|
+
/** Enforcement level override. */
|
|
59
|
+
level?: 'basic' | 'standard' | 'strict';
|
|
60
|
+
/** Called when an action is blocked. */
|
|
61
|
+
onBlock?: (result: DeepAgentsGuardResult) => void;
|
|
62
|
+
/** Called when an action requires approval. Return true to allow. */
|
|
63
|
+
onPause?: (result: DeepAgentsGuardResult) => Promise<boolean> | boolean;
|
|
64
|
+
/** Called for every evaluation (logging hook). */
|
|
65
|
+
onEvaluate?: (result: DeepAgentsGuardResult) => void;
|
|
66
|
+
/** Custom mapping from Deep Agents tool call to GuardEvent. */
|
|
67
|
+
mapToolCall?: (toolCall: DeepAgentsToolCall) => GuardEvent;
|
|
68
|
+
/** Active plan overlay for task-scoped governance. */
|
|
69
|
+
plan?: PlanDefinition;
|
|
70
|
+
/** Called when plan progress changes. */
|
|
71
|
+
onPlanProgress?: (progress: PlanProgress) => void;
|
|
72
|
+
/** Called when all plan steps are completed. */
|
|
73
|
+
onPlanComplete?: () => void;
|
|
74
|
+
}
|
|
75
|
+
declare class GovernanceBlockedError extends GovernanceBlockedError$1 {
|
|
76
|
+
readonly toolCall: DeepAgentsToolCall;
|
|
77
|
+
readonly category: DeepAgentsToolCategory;
|
|
78
|
+
constructor(verdict: GuardVerdict, toolCall: DeepAgentsToolCall, category: DeepAgentsToolCategory);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* NeuroVerse governance guard for LangChain Deep Agents.
|
|
82
|
+
*
|
|
83
|
+
* Evaluates every tool invocation against a world definition before
|
|
84
|
+
* allowing execution. Supports blocking, pausing (approval required),
|
|
85
|
+
* and plan-scoped governance.
|
|
86
|
+
*/
|
|
87
|
+
declare class DeepAgentsGuard {
|
|
88
|
+
readonly name = "neuroverse-deep-agents-guard";
|
|
89
|
+
private world;
|
|
90
|
+
private options;
|
|
91
|
+
engineOptions: GuardEngineOptions;
|
|
92
|
+
private mapToolCall;
|
|
93
|
+
activePlan?: PlanDefinition;
|
|
94
|
+
constructor(world: WorldDefinition, options?: DeepAgentsGuardOptions);
|
|
95
|
+
/**
|
|
96
|
+
* Evaluate a tool call against governance rules.
|
|
97
|
+
* Returns the result without side effects.
|
|
98
|
+
*/
|
|
99
|
+
evaluate(toolCall: DeepAgentsToolCall): DeepAgentsGuardResult;
|
|
100
|
+
/**
|
|
101
|
+
* Evaluate and enforce governance on a tool call.
|
|
102
|
+
*
|
|
103
|
+
* @throws GovernanceBlockedError if BLOCKED
|
|
104
|
+
* @throws GovernanceBlockedError if PAUSED and onPause returns false
|
|
105
|
+
* @returns DeepAgentsGuardResult on ALLOW
|
|
106
|
+
*/
|
|
107
|
+
enforce(toolCall: DeepAgentsToolCall): Promise<DeepAgentsGuardResult>;
|
|
108
|
+
/**
|
|
109
|
+
* Evaluate and execute a tool call with governance enforcement.
|
|
110
|
+
*
|
|
111
|
+
* If ALLOW: runs the executor and returns its result.
|
|
112
|
+
* If BLOCK: returns a governance-blocked message.
|
|
113
|
+
* If PAUSE: calls onPause; blocks if not approved.
|
|
114
|
+
*
|
|
115
|
+
* @param toolCall - The Deep Agents tool call to evaluate
|
|
116
|
+
* @param executor - The actual tool execution function
|
|
117
|
+
* @returns The tool execution result or a blocked message
|
|
118
|
+
*/
|
|
119
|
+
execute<T>(toolCall: DeepAgentsToolCall, executor: (toolCall: DeepAgentsToolCall) => Promise<T>): Promise<{
|
|
120
|
+
result: T;
|
|
121
|
+
verdict: GuardVerdict;
|
|
122
|
+
} | {
|
|
123
|
+
blocked: true;
|
|
124
|
+
verdict: GuardVerdict;
|
|
125
|
+
reason: string;
|
|
126
|
+
}>;
|
|
127
|
+
/**
|
|
128
|
+
* Returns a middleware function compatible with Deep Agents' tool pipeline.
|
|
129
|
+
*
|
|
130
|
+
* The middleware intercepts tool calls before execution:
|
|
131
|
+
* agent.use(guard.middleware());
|
|
132
|
+
*/
|
|
133
|
+
middleware(): (toolCall: DeepAgentsToolCall, next: () => Promise<unknown>) => Promise<unknown>;
|
|
134
|
+
/**
|
|
135
|
+
* Returns a callback-handler-style object for LangChain integration.
|
|
136
|
+
* Compatible with Deep Agents' callback system.
|
|
137
|
+
*/
|
|
138
|
+
callbacks(): {
|
|
139
|
+
handleToolStart: (tool: {
|
|
140
|
+
name: string;
|
|
141
|
+
}, input: string) => Promise<void>;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Check if a shell command contains dangerous patterns.
|
|
145
|
+
* Useful for pre-screening before full governance evaluation.
|
|
146
|
+
*/
|
|
147
|
+
static isDangerousCommand(command: string): {
|
|
148
|
+
dangerous: boolean;
|
|
149
|
+
labels: string[];
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Check if a git command contains dangerous patterns.
|
|
153
|
+
*/
|
|
154
|
+
static isDangerousGitCommand(command: string): {
|
|
155
|
+
dangerous: boolean;
|
|
156
|
+
labels: string[];
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Classify a tool name into a category.
|
|
160
|
+
*/
|
|
161
|
+
static classifyTool(toolName: string): DeepAgentsToolCategory;
|
|
162
|
+
private trackPlanProgressInternal;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Create a Deep Agents guard from a world path.
|
|
166
|
+
*
|
|
167
|
+
* @param worldPath - Path to world directory, .nv-world.md, or .nv-world.zip
|
|
168
|
+
* @param options - Guard configuration
|
|
169
|
+
* @returns A guard ready to plug into Deep Agents
|
|
170
|
+
*/
|
|
171
|
+
declare function createDeepAgentsGuard(worldPath: string, options?: DeepAgentsGuardOptions): Promise<DeepAgentsGuard>;
|
|
172
|
+
/**
|
|
173
|
+
* Create a Deep Agents guard from a pre-loaded world.
|
|
174
|
+
*
|
|
175
|
+
* @param world - A loaded WorldDefinition
|
|
176
|
+
* @param options - Guard configuration
|
|
177
|
+
* @returns A guard ready to plug into Deep Agents
|
|
178
|
+
*/
|
|
179
|
+
declare function createDeepAgentsGuardFromWorld(world: WorldDefinition, options?: DeepAgentsGuardOptions): DeepAgentsGuard;
|
|
180
|
+
|
|
181
|
+
export { DeepAgentsGuard, type DeepAgentsGuardOptions, type DeepAgentsGuardResult, type DeepAgentsToolCall, type DeepAgentsToolCategory, GovernanceBlockedError, createDeepAgentsGuard, createDeepAgentsGuardFromWorld };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DeepAgentsGuard,
|
|
3
|
+
GovernanceBlockedError,
|
|
4
|
+
createDeepAgentsGuard,
|
|
5
|
+
createDeepAgentsGuardFromWorld
|
|
6
|
+
} from "../chunk-O5ABKEA7.js";
|
|
7
|
+
import "../chunk-5U2MQO5P.js";
|
|
8
|
+
import "../chunk-W7LLXRGY.js";
|
|
9
|
+
import "../chunk-QLPTHTVB.js";
|
|
10
|
+
import "../chunk-CTZHONLA.js";
|
|
11
|
+
import "../chunk-QWGCMQQD.js";
|
|
12
|
+
export {
|
|
13
|
+
DeepAgentsGuard,
|
|
14
|
+
GovernanceBlockedError,
|
|
15
|
+
createDeepAgentsGuard,
|
|
16
|
+
createDeepAgentsGuardFromWorld
|
|
17
|
+
};
|