@decionis/mcp 0.1.0
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/LICENSE +13 -0
- package/README.md +233 -0
- package/dist/AgentHookCli.d.ts +2 -0
- package/dist/AgentHookCli.js +17 -0
- package/dist/AgentHookCli.js.map +1 -0
- package/dist/ManagedAgentHookCli.d.ts +2 -0
- package/dist/ManagedAgentHookCli.js +53678 -0
- package/dist/agent/AgentIndex.d.ts +226 -0
- package/dist/agent/AgentIndex.js +36 -0
- package/dist/agent/AgentIndex.js.map +1 -0
- package/dist/chunk-QSCP7MRQ.js +16944 -0
- package/dist/chunk-QSCP7MRQ.js.map +1 -0
- package/dist/chunk-UN67W5FH.js +479 -0
- package/dist/chunk-UN67W5FH.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +310 -0
- package/dist/index.js.map +1 -0
- package/package.json +80 -0
- package/templates/ClaudeSettings.json +17 -0
- package/templates/CodexHooks.json +18 -0
- package/templates/CopilotHooks.json +12 -0
- package/templates/managed/AgentGateConfig.example.json +6 -0
- package/templates/managed/AgentPolicyBundle.json +417 -0
- package/templates/managed/ClaudeManagedSettings.Windows.json +18 -0
- package/templates/managed/ClaudeManagedSettings.json +18 -0
- package/templates/managed/CodexRequirements.toml +18 -0
- package/templates/managed/CopilotPolicyHooks.Windows.json +12 -0
- package/templates/managed/CopilotPolicyHooks.json +12 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { Readable, Writable } from 'node:stream';
|
|
2
|
+
|
|
3
|
+
type AgentHost = "codex" | "copilot" | "claude";
|
|
4
|
+
type AgentGateVerdict = "allow" | "block" | "review" | "escalate" | "error";
|
|
5
|
+
type AgentGateSource = "local" | "remote";
|
|
6
|
+
interface AgentToolCall {
|
|
7
|
+
host: AgentHost;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
toolUseId: string | null;
|
|
10
|
+
toolName: string;
|
|
11
|
+
toolInput: Record<string, unknown>;
|
|
12
|
+
cwd: string;
|
|
13
|
+
model: string | null;
|
|
14
|
+
permissionMode: string | null;
|
|
15
|
+
}
|
|
16
|
+
interface AgentGateDecision {
|
|
17
|
+
verdict: AgentGateVerdict;
|
|
18
|
+
reason: string;
|
|
19
|
+
source: AgentGateSource;
|
|
20
|
+
outcome: string | null;
|
|
21
|
+
policyVersion: string | null;
|
|
22
|
+
matchedRule: string | null;
|
|
23
|
+
reasonCodes: string[];
|
|
24
|
+
}
|
|
25
|
+
interface AgentGateEvaluator {
|
|
26
|
+
readonly source: AgentGateSource;
|
|
27
|
+
evaluate(toolCall: AgentToolCall): Promise<AgentGateDecision>;
|
|
28
|
+
close?(): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
interface AgentHostAdapter {
|
|
31
|
+
readonly host: AgentHost;
|
|
32
|
+
parse(input: unknown): AgentToolCall;
|
|
33
|
+
format(decision: AgentGateDecision, input?: unknown): Record<string, unknown>;
|
|
34
|
+
}
|
|
35
|
+
declare class AgentHookInputError extends Error {
|
|
36
|
+
constructor(message: string);
|
|
37
|
+
}
|
|
38
|
+
declare class AgentGateConfigurationError extends Error {
|
|
39
|
+
constructor(message: string);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
declare class AgentDecisionMapper {
|
|
43
|
+
static fromProtocol(body: Record<string, unknown>, source: AgentGateSource, fallbackPolicyVersion?: string | null): AgentGateDecision;
|
|
44
|
+
static error(message: string, source: AgentGateSource): AgentGateDecision;
|
|
45
|
+
private static toVerdict;
|
|
46
|
+
private static reason;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare class AgentGateFactory {
|
|
50
|
+
static create(env?: NodeJS.ProcessEnv): AgentGateEvaluator;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface AgentHookCommandOptions {
|
|
54
|
+
input?: Readable;
|
|
55
|
+
output?: Writable;
|
|
56
|
+
errorOutput?: Writable;
|
|
57
|
+
env?: NodeJS.ProcessEnv;
|
|
58
|
+
}
|
|
59
|
+
declare class AgentHookCommand {
|
|
60
|
+
static run(args: string[], options?: AgentHookCommandOptions): Promise<number>;
|
|
61
|
+
private static hostArgument;
|
|
62
|
+
private static readInput;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
declare class AgentHookRunner {
|
|
66
|
+
private readonly adapter;
|
|
67
|
+
private readonly evaluator;
|
|
68
|
+
constructor(adapter: AgentHostAdapter, evaluator: AgentGateEvaluator);
|
|
69
|
+
run(input: unknown): Promise<Record<string, unknown>>;
|
|
70
|
+
close(): Promise<void>;
|
|
71
|
+
static shouldBlock(decision: AgentGateDecision): boolean;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
declare class AgentHostRegistry {
|
|
75
|
+
static resolve(host: string): AgentHostAdapter;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
declare class AgentPolicyPayload {
|
|
79
|
+
static build(toolCall: AgentToolCall): Record<string, unknown>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface BundleRule {
|
|
83
|
+
rule_id: string;
|
|
84
|
+
name: string;
|
|
85
|
+
decision_domain: string;
|
|
86
|
+
when: Record<string, unknown>;
|
|
87
|
+
then: {
|
|
88
|
+
action: string;
|
|
89
|
+
};
|
|
90
|
+
priority: number;
|
|
91
|
+
enabled: boolean;
|
|
92
|
+
rationale?: string;
|
|
93
|
+
}
|
|
94
|
+
interface CompileResult {
|
|
95
|
+
rules: BundleRule[];
|
|
96
|
+
errors: string[];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Local Decionis gateway: boots the REAL protocol service (@decionis/protocol)
|
|
101
|
+
* with an in-memory store and evaluates decisions through fastify's inject()
|
|
102
|
+
* — the genuine platform evaluator, with zero network, zero database, and
|
|
103
|
+
* zero credentials. The repo's DECIONIS_POLICY.md is compiled and published
|
|
104
|
+
* through the protocol's own bundle-ingestion route (schema-validated), so a
|
|
105
|
+
* policy that misbehaves locally would misbehave identically in production.
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
type PublishResult = {
|
|
109
|
+
ok: true;
|
|
110
|
+
version: string;
|
|
111
|
+
sha256: string;
|
|
112
|
+
ruleCount: number;
|
|
113
|
+
republished: boolean;
|
|
114
|
+
} | {
|
|
115
|
+
ok: false;
|
|
116
|
+
reason: "no_rules_block" | "compile_error" | "bundle_rejected";
|
|
117
|
+
errors: string[];
|
|
118
|
+
};
|
|
119
|
+
interface EvaluateResult {
|
|
120
|
+
status: number;
|
|
121
|
+
body: Record<string, unknown>;
|
|
122
|
+
}
|
|
123
|
+
declare class LocalDecionisGateway {
|
|
124
|
+
private app;
|
|
125
|
+
private publishedVersion;
|
|
126
|
+
private ready;
|
|
127
|
+
close(): Promise<void>;
|
|
128
|
+
/** Compile the policy source; does not publish. */
|
|
129
|
+
compile(source: string, opts?: {
|
|
130
|
+
workflowKey?: string | null;
|
|
131
|
+
}): CompileResult | null;
|
|
132
|
+
/**
|
|
133
|
+
* Compile + publish the policy as the active local bundle. Idempotent by
|
|
134
|
+
* content hash — republished only when the file content changes.
|
|
135
|
+
*/
|
|
136
|
+
publishPolicy(source: string, opts?: {
|
|
137
|
+
workflowKey?: string | null;
|
|
138
|
+
}): Promise<PublishResult>;
|
|
139
|
+
/**
|
|
140
|
+
* Evaluate a candidate action through POST /v1/protocol/evaluate-decision,
|
|
141
|
+
* applying the same request normalization the public API performs
|
|
142
|
+
* (apps/api/src/services/protocolAdapter/normalizeEvaluateBody.ts): the
|
|
143
|
+
* payload becomes `context`, and decision_type derives from the action
|
|
144
|
+
* label, then the workflow key, then a stable fallback.
|
|
145
|
+
*/
|
|
146
|
+
evaluate(input: {
|
|
147
|
+
payload: Record<string, unknown>;
|
|
148
|
+
workflowKey?: string | null;
|
|
149
|
+
mode?: "shadow" | "enforce";
|
|
150
|
+
}): Promise<EvaluateResult>;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
type PolicyFileResult = {
|
|
154
|
+
ok: true;
|
|
155
|
+
path: string;
|
|
156
|
+
content: string;
|
|
157
|
+
} | {
|
|
158
|
+
ok: false;
|
|
159
|
+
path: string;
|
|
160
|
+
message: string;
|
|
161
|
+
};
|
|
162
|
+
declare class PolicyFileRepository {
|
|
163
|
+
private readonly env;
|
|
164
|
+
constructor(env?: NodeJS.ProcessEnv);
|
|
165
|
+
resolvePath(pathOverride: unknown, cwd?: string): string;
|
|
166
|
+
read(pathOverride: unknown, cwd?: string): Promise<PolicyFileResult>;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
interface LocalAgentGateOptions {
|
|
170
|
+
gateway?: LocalDecionisGateway;
|
|
171
|
+
policyFiles?: PolicyFileRepository;
|
|
172
|
+
workflowKey?: string;
|
|
173
|
+
}
|
|
174
|
+
declare class LocalAgentGate implements AgentGateEvaluator {
|
|
175
|
+
readonly source: "local";
|
|
176
|
+
private readonly gateway;
|
|
177
|
+
private readonly policyFiles;
|
|
178
|
+
private readonly workflowKey;
|
|
179
|
+
constructor(options?: LocalAgentGateOptions);
|
|
180
|
+
evaluate(toolCall: AgentToolCall): Promise<AgentGateDecision>;
|
|
181
|
+
close(): Promise<void>;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
type FetchLike = typeof fetch;
|
|
185
|
+
interface RemoteAgentGateOptions {
|
|
186
|
+
endpoint: string;
|
|
187
|
+
apiKey: string;
|
|
188
|
+
orgId: string;
|
|
189
|
+
fetchImpl?: FetchLike;
|
|
190
|
+
timeoutMs?: number;
|
|
191
|
+
workflowKey?: string;
|
|
192
|
+
}
|
|
193
|
+
declare class RemoteAgentGate implements AgentGateEvaluator {
|
|
194
|
+
private readonly options;
|
|
195
|
+
readonly source: "remote";
|
|
196
|
+
private readonly endpoint;
|
|
197
|
+
private readonly fetchImpl;
|
|
198
|
+
private readonly timeoutMs;
|
|
199
|
+
private readonly workflowKey;
|
|
200
|
+
constructor(options: RemoteAgentGateOptions);
|
|
201
|
+
evaluate(toolCall: AgentToolCall): Promise<AgentGateDecision>;
|
|
202
|
+
private idempotencyKey;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
declare abstract class SnakeCaseHookAdapter implements AgentHostAdapter {
|
|
206
|
+
abstract readonly host: AgentHost;
|
|
207
|
+
parse(input: unknown): AgentToolCall;
|
|
208
|
+
format(decision: AgentGateDecision, _input?: unknown): Record<string, unknown>;
|
|
209
|
+
protected reason(decision: AgentGateDecision): string;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
declare class ClaudeHookAdapter extends SnakeCaseHookAdapter {
|
|
213
|
+
readonly host: "claude";
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
declare class CodexHookAdapter extends SnakeCaseHookAdapter {
|
|
217
|
+
readonly host: "codex";
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
declare class CopilotHookAdapter implements AgentHostAdapter {
|
|
221
|
+
readonly host: "copilot";
|
|
222
|
+
parse(input: unknown): AgentToolCall;
|
|
223
|
+
format(decision: AgentGateDecision, input?: unknown): Record<string, unknown>;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export { AgentDecisionMapper, AgentGateConfigurationError, type AgentGateDecision, type AgentGateEvaluator, AgentGateFactory, type AgentGateSource, type AgentGateVerdict, AgentHookCommand, type AgentHookCommandOptions, AgentHookInputError, AgentHookRunner, type AgentHost, type AgentHostAdapter, AgentHostRegistry, AgentPolicyPayload, type AgentToolCall, ClaudeHookAdapter, CodexHookAdapter, CopilotHookAdapter, LocalAgentGate, type LocalAgentGateOptions, PolicyFileRepository, type PolicyFileResult, RemoteAgentGate, type RemoteAgentGateOptions };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
AgentDecisionMapper,
|
|
4
|
+
AgentGateConfigurationError,
|
|
5
|
+
AgentGateFactory,
|
|
6
|
+
AgentHookCommand,
|
|
7
|
+
AgentHookInputError,
|
|
8
|
+
AgentHookRunner,
|
|
9
|
+
AgentHostRegistry,
|
|
10
|
+
AgentPolicyPayload,
|
|
11
|
+
ClaudeHookAdapter,
|
|
12
|
+
CodexHookAdapter,
|
|
13
|
+
CopilotHookAdapter,
|
|
14
|
+
LocalAgentGate,
|
|
15
|
+
RemoteAgentGate
|
|
16
|
+
} from "../chunk-UN67W5FH.js";
|
|
17
|
+
import {
|
|
18
|
+
PolicyFileRepository
|
|
19
|
+
} from "../chunk-QSCP7MRQ.js";
|
|
20
|
+
export {
|
|
21
|
+
AgentDecisionMapper,
|
|
22
|
+
AgentGateConfigurationError,
|
|
23
|
+
AgentGateFactory,
|
|
24
|
+
AgentHookCommand,
|
|
25
|
+
AgentHookInputError,
|
|
26
|
+
AgentHookRunner,
|
|
27
|
+
AgentHostRegistry,
|
|
28
|
+
AgentPolicyPayload,
|
|
29
|
+
ClaudeHookAdapter,
|
|
30
|
+
CodexHookAdapter,
|
|
31
|
+
CopilotHookAdapter,
|
|
32
|
+
LocalAgentGate,
|
|
33
|
+
PolicyFileRepository,
|
|
34
|
+
RemoteAgentGate
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=AgentIndex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|