@decionis/mcp 0.1.2 → 0.1.4
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/.claude-plugin/plugin.json +15 -0
- package/README.md +67 -5
- package/commands/init.md +23 -0
- package/dist/AgentHookCli.js +2 -2
- package/dist/ManagedAgentHookCli.js +18440 -8210
- package/dist/agent/AgentIndex.d.ts +37 -2
- package/dist/agent/AgentIndex.js +2 -2
- package/dist/{chunk-2C62WFX2.js → chunk-MJVKY7PZ.js} +28 -6
- package/dist/chunk-MJVKY7PZ.js.map +1 -0
- package/dist/{chunk-KY5AVRL6.js → chunk-YVRIRS6H.js} +13505 -2577
- package/dist/chunk-YVRIRS6H.js.map +1 -0
- package/dist/index.js +2233 -8
- package/dist/index.js.map +1 -1
- package/hooks/hooks.json +17 -0
- package/package.json +8 -3
- package/templates/ClaudeSettings.json +1 -1
- package/templates/DECIONIS_POLICY.starter.md +108 -0
- package/templates/managed/ClaudeManagedSettings.Windows.json +1 -1
- package/templates/managed/ClaudeManagedSettings.json +1 -1
- package/dist/chunk-2C62WFX2.js.map +0 -1
- package/dist/chunk-KY5AVRL6.js.map +0 -1
|
@@ -46,8 +46,16 @@ declare class AgentDecisionMapper {
|
|
|
46
46
|
private static reason;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
interface AgentGateFactoryOptions {
|
|
50
|
+
/**
|
|
51
|
+
* Passed through to LocalAgentGate. The plugin install sets this, because a
|
|
52
|
+
* plugin hook runs in every repository the user opens — not only one they
|
|
53
|
+
* deliberately wired a gate into.
|
|
54
|
+
*/
|
|
55
|
+
ungovernedRepository?: "deny" | "allow";
|
|
56
|
+
}
|
|
49
57
|
declare class AgentGateFactory {
|
|
50
|
-
static create(env?: NodeJS.ProcessEnv): AgentGateEvaluator;
|
|
58
|
+
static create(env?: NodeJS.ProcessEnv, options?: AgentGateFactoryOptions): AgentGateEvaluator;
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
interface AgentHookCommandOptions {
|
|
@@ -158,6 +166,15 @@ type PolicyFileResult = {
|
|
|
158
166
|
ok: false;
|
|
159
167
|
path: string;
|
|
160
168
|
message: string;
|
|
169
|
+
/**
|
|
170
|
+
* True only when the file does not exist.
|
|
171
|
+
*
|
|
172
|
+
* Callers must treat this differently from a file that exists and cannot
|
|
173
|
+
* be read: "there is no policy here" describes a repository that never
|
|
174
|
+
* opted in to governance, whereas an unreadable or malformed policy is a
|
|
175
|
+
* misconfiguration that has to fail closed.
|
|
176
|
+
*/
|
|
177
|
+
absent: boolean;
|
|
161
178
|
};
|
|
162
179
|
declare class PolicyFileRepository {
|
|
163
180
|
private readonly env;
|
|
@@ -170,12 +187,30 @@ interface LocalAgentGateOptions {
|
|
|
170
187
|
gateway?: LocalDecionisGateway;
|
|
171
188
|
policyFiles?: PolicyFileRepository;
|
|
172
189
|
workflowKey?: string;
|
|
190
|
+
/**
|
|
191
|
+
* What to do in a repository that has no policy file at all.
|
|
192
|
+
*
|
|
193
|
+
* Default `"deny"` — unchanged, and correct for a gate someone wired into
|
|
194
|
+
* one repository on purpose: they meant to govern it, so a missing policy is
|
|
195
|
+
* a misconfiguration.
|
|
196
|
+
*
|
|
197
|
+
* `"allow"` is for the plugin install, which by its nature is active in
|
|
198
|
+
* EVERY repository the user opens. Denying every tool call in every project
|
|
199
|
+
* that has not opted in is not safety; it is a broken install, and it
|
|
200
|
+
* teaches people to remove the thing that was supposed to protect them. A
|
|
201
|
+
* repository with no policy file has simply not opted in.
|
|
202
|
+
*
|
|
203
|
+
* This never relaxes the case that matters: a policy that EXISTS and cannot
|
|
204
|
+
* be read or compiled still fails closed, on either setting.
|
|
205
|
+
*/
|
|
206
|
+
ungovernedRepository?: "deny" | "allow";
|
|
173
207
|
}
|
|
174
208
|
declare class LocalAgentGate implements AgentGateEvaluator {
|
|
175
209
|
readonly source: "local";
|
|
176
210
|
private readonly gateway;
|
|
177
211
|
private readonly policyFiles;
|
|
178
212
|
private readonly workflowKey;
|
|
213
|
+
private readonly ungovernedRepository;
|
|
179
214
|
constructor(options?: LocalAgentGateOptions);
|
|
180
215
|
evaluate(toolCall: AgentToolCall): Promise<AgentGateDecision>;
|
|
181
216
|
close(): Promise<void>;
|
|
@@ -223,4 +258,4 @@ declare class CopilotHookAdapter implements AgentHostAdapter {
|
|
|
223
258
|
format(decision: AgentGateDecision, input?: unknown): Record<string, unknown>;
|
|
224
259
|
}
|
|
225
260
|
|
|
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 };
|
|
261
|
+
export { AgentDecisionMapper, AgentGateConfigurationError, type AgentGateDecision, type AgentGateEvaluator, AgentGateFactory, type AgentGateFactoryOptions, 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 };
|
package/dist/agent/AgentIndex.js
CHANGED
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
CopilotHookAdapter,
|
|
14
14
|
LocalAgentGate,
|
|
15
15
|
RemoteAgentGate
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-MJVKY7PZ.js";
|
|
17
17
|
import {
|
|
18
18
|
PolicyFileRepository
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-YVRIRS6H.js";
|
|
20
20
|
export {
|
|
21
21
|
AgentDecisionMapper,
|
|
22
22
|
AgentGateConfigurationError,
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
LocalDecionisGateway,
|
|
4
4
|
PolicyFileRepository,
|
|
5
5
|
normalizeVerdict
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YVRIRS6H.js";
|
|
7
7
|
|
|
8
8
|
// src/agent/AgentContracts.ts
|
|
9
9
|
var AgentHookInputError = class extends Error {
|
|
@@ -131,14 +131,29 @@ var LocalAgentGate = class {
|
|
|
131
131
|
gateway;
|
|
132
132
|
policyFiles;
|
|
133
133
|
workflowKey;
|
|
134
|
+
ungovernedRepository;
|
|
134
135
|
constructor(options = {}) {
|
|
135
136
|
this.gateway = options.gateway ?? new LocalDecionisGateway();
|
|
136
137
|
this.policyFiles = options.policyFiles ?? new PolicyFileRepository();
|
|
137
138
|
this.workflowKey = options.workflowKey ?? "agent_execution_gate";
|
|
139
|
+
this.ungovernedRepository = options.ungovernedRepository ?? "deny";
|
|
138
140
|
}
|
|
139
141
|
async evaluate(toolCall) {
|
|
140
142
|
const policyFile = await this.policyFiles.read(void 0, toolCall.cwd);
|
|
141
|
-
if (!policyFile.ok)
|
|
143
|
+
if (!policyFile.ok) {
|
|
144
|
+
if (policyFile.absent && this.ungovernedRepository === "allow") {
|
|
145
|
+
return {
|
|
146
|
+
verdict: "allow",
|
|
147
|
+
reason: `No Decionis policy in this repository (looked for ${policyFile.path}), so nothing is gated here. Add DECIONIS_POLICY.md to govern it.`,
|
|
148
|
+
source: "local",
|
|
149
|
+
outcome: null,
|
|
150
|
+
policyVersion: null,
|
|
151
|
+
matchedRule: null,
|
|
152
|
+
reasonCodes: ["UNGOVERNED_REPOSITORY"]
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
throw new Error(policyFile.message);
|
|
156
|
+
}
|
|
142
157
|
const published = await this.gateway.publishPolicy(policyFile.content, {
|
|
143
158
|
workflowKey: this.workflowKey
|
|
144
159
|
});
|
|
@@ -231,7 +246,7 @@ var RemoteAgentGate = class {
|
|
|
231
246
|
|
|
232
247
|
// src/agent/AgentGateFactory.ts
|
|
233
248
|
var AgentGateFactory = class {
|
|
234
|
-
static create(env = process.env) {
|
|
249
|
+
static create(env = process.env, options = {}) {
|
|
235
250
|
const mode = (AgentHookValues.optionalString(env.DECIONIS_AGENT_GATE_MODE) ?? "auto").toLowerCase();
|
|
236
251
|
const endpoint = AgentHookValues.optionalString(env.DECIONIS_AGENT_GATE_URL);
|
|
237
252
|
const apiKey = AgentHookValues.optionalString(env.DECIONIS_API_KEY);
|
|
@@ -243,7 +258,10 @@ var AgentGateFactory = class {
|
|
|
243
258
|
);
|
|
244
259
|
}
|
|
245
260
|
if (mode === "local" || mode === "auto" && !hasRemoteConfiguration) {
|
|
246
|
-
|
|
261
|
+
const ungovernedFromEnv = AgentHookValues.optionalString(env.DECIONIS_UNGOVERNED_REPOSITORY)?.toLowerCase() === "allow";
|
|
262
|
+
return new LocalAgentGate({
|
|
263
|
+
ungovernedRepository: options.ungovernedRepository ?? (ungovernedFromEnv ? "allow" : "deny")
|
|
264
|
+
});
|
|
247
265
|
}
|
|
248
266
|
if (!endpoint || !apiKey || !orgId) {
|
|
249
267
|
throw new AgentGateConfigurationError(
|
|
@@ -419,7 +437,11 @@ var AgentHookCommand = class _AgentHookCommand {
|
|
|
419
437
|
}
|
|
420
438
|
let evaluator;
|
|
421
439
|
try {
|
|
422
|
-
evaluator = AgentGateFactory.create(options.env
|
|
440
|
+
evaluator = AgentGateFactory.create(options.env, {
|
|
441
|
+
// A flag rather than an env var so the plugin's hook command is one
|
|
442
|
+
// portable string — `VAR=x cmd` is not valid on Windows shells.
|
|
443
|
+
...args.includes("--allow-ungoverned") ? { ungovernedRepository: "allow" } : {}
|
|
444
|
+
});
|
|
423
445
|
} catch (error) {
|
|
424
446
|
const denial = adapter.format(
|
|
425
447
|
{
|
|
@@ -476,4 +498,4 @@ export {
|
|
|
476
498
|
AgentHostRegistry,
|
|
477
499
|
AgentHookCommand
|
|
478
500
|
};
|
|
479
|
-
//# sourceMappingURL=chunk-
|
|
501
|
+
//# sourceMappingURL=chunk-MJVKY7PZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/agent/AgentContracts.ts","../src/agent/AgentHookValues.ts","../src/agent/AgentDecisionMapper.ts","../src/agent/AgentPolicyPayload.ts","../src/agent/LocalAgentGate.ts","../src/agent/RemoteAgentGate.ts","../src/agent/AgentGateFactory.ts","../src/agent/AgentHookRunner.ts","../src/agent/providers/SnakeCaseHookAdapter.ts","../src/agent/providers/ClaudeHookAdapter.ts","../src/agent/providers/CodexHookAdapter.ts","../src/agent/providers/CopilotHookAdapter.ts","../src/agent/AgentHostRegistry.ts","../src/agent/AgentHookCommand.ts"],"sourcesContent":["export type AgentHost = \"codex\" | \"copilot\" | \"claude\";\n\nexport type AgentGateVerdict = \"allow\" | \"block\" | \"review\" | \"escalate\" | \"error\";\n\nexport type AgentGateSource = \"local\" | \"remote\";\n\nexport interface AgentToolCall {\n host: AgentHost;\n sessionId: string;\n toolUseId: string | null;\n toolName: string;\n toolInput: Record<string, unknown>;\n cwd: string;\n model: string | null;\n permissionMode: string | null;\n}\n\nexport interface AgentGateDecision {\n verdict: AgentGateVerdict;\n reason: string;\n source: AgentGateSource;\n outcome: string | null;\n policyVersion: string | null;\n matchedRule: string | null;\n reasonCodes: string[];\n}\n\nexport interface AgentGateEvaluator {\n readonly source: AgentGateSource;\n evaluate(toolCall: AgentToolCall): Promise<AgentGateDecision>;\n close?(): Promise<void>;\n}\n\nexport interface AgentHostAdapter {\n readonly host: AgentHost;\n parse(input: unknown): AgentToolCall;\n format(decision: AgentGateDecision, input?: unknown): Record<string, unknown>;\n}\n\nexport class AgentHookInputError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"AgentHookInputError\";\n }\n}\n\nexport class AgentGateConfigurationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"AgentGateConfigurationError\";\n }\n}\n","import { AgentHookInputError } from \"./AgentContracts.js\";\n\nexport class AgentHookValues {\n static asRecord(value: unknown): Record<string, unknown> {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return {};\n return value as Record<string, unknown>;\n }\n\n static requireRecord(value: unknown): Record<string, unknown> {\n const record = AgentHookValues.asRecord(value);\n if (Object.keys(record).length === 0) {\n throw new AgentHookInputError(\"The hook input must be a non-empty JSON object.\");\n }\n return record;\n }\n\n static optionalString(value: unknown): string | null {\n return typeof value === \"string\" && value.trim() ? value.trim() : null;\n }\n\n static requireString(value: unknown, field: string): string {\n const parsed = AgentHookValues.optionalString(value);\n if (!parsed) throw new AgentHookInputError(`The hook input is missing \\`${field}\\`.`);\n return parsed;\n }\n\n static parseToolInput(value: unknown): Record<string, unknown> {\n if (typeof value !== \"string\") return AgentHookValues.asRecord(value);\n try {\n return AgentHookValues.asRecord(JSON.parse(value));\n } catch {\n throw new AgentHookInputError(\"The hook input contains invalid JSON tool arguments.\");\n }\n }\n}\n","import { normalizeVerdict } from \"../Gateway.js\";\nimport { AgentHookValues } from \"./AgentHookValues.js\";\nimport type { AgentGateDecision, AgentGateSource, AgentGateVerdict } from \"./AgentContracts.js\";\n\nexport class AgentDecisionMapper {\n static fromProtocol(\n body: Record<string, unknown>,\n source: AgentGateSource,\n fallbackPolicyVersion: string | null = null,\n ): AgentGateDecision {\n const outcome = AgentHookValues.optionalString(body.outcome);\n const verdict = AgentDecisionMapper.toVerdict(outcome);\n const policyEvaluation = AgentHookValues.asRecord(body.policy_evaluation);\n const selectedRule = AgentHookValues.optionalString(policyEvaluation.selected_rule_name);\n const rationale = AgentHookValues.optionalString(policyEvaluation.selected_rule_rationale);\n const resolution = AgentHookValues.optionalString(policyEvaluation.resolution);\n const policyVersion =\n AgentHookValues.optionalString(body.policy_version) ??\n AgentHookValues.optionalString(policyEvaluation.bundle_version) ??\n fallbackPolicyVersion;\n const reasonCodes = Array.isArray(body.reason_codes)\n ? body.reason_codes.filter((value): value is string => typeof value === \"string\")\n : [];\n\n return {\n verdict,\n reason: AgentDecisionMapper.reason(verdict, {\n selectedRule,\n rationale,\n resolution,\n reasonCodes,\n }),\n source,\n outcome,\n policyVersion,\n matchedRule: selectedRule,\n reasonCodes,\n };\n }\n\n static error(message: string, source: AgentGateSource): AgentGateDecision {\n return {\n verdict: \"error\",\n reason: message,\n source,\n outcome: null,\n policyVersion: null,\n matchedRule: null,\n reasonCodes: [\"AGENT_GATE_ERROR\"],\n };\n }\n\n private static toVerdict(outcome: string | null): AgentGateVerdict {\n const normalized = normalizeVerdict(outcome);\n if (\n normalized === \"allow\" ||\n normalized === \"block\" ||\n normalized === \"review\" ||\n normalized === \"escalate\"\n ) {\n return normalized;\n }\n return \"error\";\n }\n\n private static reason(\n verdict: AgentGateVerdict,\n context: {\n selectedRule: string | null;\n rationale: string | null;\n resolution: string | null;\n reasonCodes: string[];\n },\n ): string {\n if (context.rationale) return context.rationale;\n if (context.selectedRule) {\n return `Policy rule \"${context.selectedRule}\" returned ${verdict}.`;\n }\n if (context.reasonCodes.length > 0) {\n return `Policy returned ${verdict}: ${context.reasonCodes.join(\", \")}.`;\n }\n if (context.resolution) return `Policy returned ${verdict} (${context.resolution}).`;\n return `Policy returned ${verdict}.`;\n }\n}\n","import type { AgentToolCall } from \"./AgentContracts.js\";\n\nexport class AgentPolicyPayload {\n static build(toolCall: AgentToolCall): Record<string, unknown> {\n return {\n action: `agent_tool:${toolCall.toolName}`,\n agent_generated: true,\n agent_provider: toolCall.host,\n agent_session_id: toolCall.sessionId,\n tool_name: toolCall.toolName,\n tool_input: toolCall.toolInput,\n working_directory: toolCall.cwd,\n ...(toolCall.toolUseId ? { tool_use_id: toolCall.toolUseId } : {}),\n ...(toolCall.model ? { model: toolCall.model } : {}),\n ...(toolCall.permissionMode ? { permission_mode: toolCall.permissionMode } : {}),\n };\n }\n}\n","import { LocalDecionisGateway } from \"../Gateway.js\";\nimport type { AgentGateDecision, AgentGateEvaluator, AgentToolCall } from \"./AgentContracts.js\";\nimport { AgentDecisionMapper } from \"./AgentDecisionMapper.js\";\nimport { AgentPolicyPayload } from \"./AgentPolicyPayload.js\";\nimport { PolicyFileRepository } from \"./PolicyFileRepository.js\";\n\nexport interface LocalAgentGateOptions {\n gateway?: LocalDecionisGateway;\n policyFiles?: PolicyFileRepository;\n workflowKey?: string;\n /**\n * What to do in a repository that has no policy file at all.\n *\n * Default `\"deny\"` — unchanged, and correct for a gate someone wired into\n * one repository on purpose: they meant to govern it, so a missing policy is\n * a misconfiguration.\n *\n * `\"allow\"` is for the plugin install, which by its nature is active in\n * EVERY repository the user opens. Denying every tool call in every project\n * that has not opted in is not safety; it is a broken install, and it\n * teaches people to remove the thing that was supposed to protect them. A\n * repository with no policy file has simply not opted in.\n *\n * This never relaxes the case that matters: a policy that EXISTS and cannot\n * be read or compiled still fails closed, on either setting.\n */\n ungovernedRepository?: \"deny\" | \"allow\";\n}\n\nexport class LocalAgentGate implements AgentGateEvaluator {\n readonly source = \"local\" as const;\n private readonly gateway: LocalDecionisGateway;\n private readonly policyFiles: PolicyFileRepository;\n private readonly workflowKey: string;\n private readonly ungovernedRepository: \"deny\" | \"allow\";\n\n constructor(options: LocalAgentGateOptions = {}) {\n this.gateway = options.gateway ?? new LocalDecionisGateway();\n this.policyFiles = options.policyFiles ?? new PolicyFileRepository();\n this.workflowKey = options.workflowKey ?? \"agent_execution_gate\";\n this.ungovernedRepository = options.ungovernedRepository ?? \"deny\";\n }\n\n async evaluate(toolCall: AgentToolCall): Promise<AgentGateDecision> {\n const policyFile = await this.policyFiles.read(undefined, toolCall.cwd);\n if (!policyFile.ok) {\n // Absent is not the same as broken. Only a genuinely missing file can\n // take the \"not governed here\" path, and only when the caller asked for\n // it; anything else still throws, and the hook turns that into a denial.\n if (policyFile.absent && this.ungovernedRepository === \"allow\") {\n return {\n verdict: \"allow\",\n reason:\n `No Decionis policy in this repository (looked for ${policyFile.path}), so nothing is ` +\n \"gated here. Add DECIONIS_POLICY.md to govern it.\",\n source: \"local\",\n outcome: null,\n policyVersion: null,\n matchedRule: null,\n reasonCodes: [\"UNGOVERNED_REPOSITORY\"],\n };\n }\n throw new Error(policyFile.message);\n }\n\n const published = await this.gateway.publishPolicy(policyFile.content, {\n workflowKey: this.workflowKey,\n });\n if (!published.ok) {\n throw new Error(\n `The Decionis policy could not be enforced (${published.reason}): ${published.errors.join(\n \"; \",\n )}`,\n );\n }\n\n const evaluated = await this.gateway.evaluate({\n payload: AgentPolicyPayload.build(toolCall),\n workflowKey: this.workflowKey,\n mode: \"enforce\",\n });\n if (evaluated.status !== 200) {\n throw new Error(`The local Decionis evaluator returned HTTP ${evaluated.status}.`);\n }\n return AgentDecisionMapper.fromProtocol(evaluated.body, \"local\", published.version);\n }\n\n close(): Promise<void> {\n return this.gateway.close();\n }\n}\n","import { createHash } from \"node:crypto\";\n\nimport type { AgentGateDecision, AgentGateEvaluator, AgentToolCall } from \"./AgentContracts.js\";\nimport { AgentDecisionMapper } from \"./AgentDecisionMapper.js\";\nimport { AgentHookValues } from \"./AgentHookValues.js\";\nimport { AgentPolicyPayload } from \"./AgentPolicyPayload.js\";\n\ntype FetchLike = typeof fetch;\n\nexport interface RemoteAgentGateOptions {\n endpoint: string;\n apiKey: string;\n orgId: string;\n fetchImpl?: FetchLike;\n timeoutMs?: number;\n workflowKey?: string;\n}\n\nexport class RemoteAgentGate implements AgentGateEvaluator {\n readonly source = \"remote\" as const;\n private readonly endpoint: string;\n private readonly fetchImpl: FetchLike;\n private readonly timeoutMs: number;\n private readonly workflowKey: string;\n\n constructor(private readonly options: RemoteAgentGateOptions) {\n this.endpoint = options.endpoint.trim();\n this.fetchImpl = options.fetchImpl ?? fetch;\n this.timeoutMs = options.timeoutMs ?? 4000;\n this.workflowKey = options.workflowKey ?? \"agent_execution_gate\";\n }\n\n async evaluate(toolCall: AgentToolCall): Promise<AgentGateDecision> {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), this.timeoutMs);\n try {\n const idempotencyKey = this.idempotencyKey(toolCall);\n const response = await this.fetchImpl(this.endpoint, {\n method: \"POST\",\n headers: {\n authorization: `Bearer ${this.options.apiKey}`,\n \"content-type\": \"application/json\",\n \"idempotency-key\": idempotencyKey,\n },\n body: JSON.stringify({\n org_id: this.options.orgId,\n decision_type: `agent_tool:${toolCall.toolName}`.slice(0, 120),\n channel: toolCall.host,\n mode: \"ENFORCEMENT\",\n workflow_key: this.workflowKey,\n idempotency_key: idempotencyKey,\n context: AgentPolicyPayload.build(toolCall),\n }),\n signal: controller.signal,\n });\n const body = AgentHookValues.asRecord(await response.json().catch(() => null));\n if (!response.ok) {\n const message =\n AgentHookValues.optionalString(body.message) ??\n AgentHookValues.optionalString(body.error) ??\n \"unknown error\";\n throw new Error(\n `The remote Decionis evaluator returned HTTP ${response.status}: ${message}`,\n );\n }\n if (!AgentHookValues.optionalString(body.outcome)) {\n throw new Error(\"The remote Decionis evaluator returned no outcome.\");\n }\n return AgentDecisionMapper.fromProtocol(body, \"remote\");\n } finally {\n clearTimeout(timeout);\n }\n }\n\n private idempotencyKey(toolCall: AgentToolCall): string {\n const source = JSON.stringify({\n host: toolCall.host,\n sessionId: toolCall.sessionId,\n toolUseId: toolCall.toolUseId,\n toolName: toolCall.toolName,\n toolInput: toolCall.toolInput,\n });\n return `agent-hook-${createHash(\"sha256\").update(source).digest(\"hex\")}`;\n }\n}\n","import { AgentGateConfigurationError, type AgentGateEvaluator } from \"./AgentContracts.js\";\nimport { AgentHookValues } from \"./AgentHookValues.js\";\nimport { LocalAgentGate } from \"./LocalAgentGate.js\";\nimport { RemoteAgentGate } from \"./RemoteAgentGate.js\";\n\nexport interface AgentGateFactoryOptions {\n /**\n * Passed through to LocalAgentGate. The plugin install sets this, because a\n * plugin hook runs in every repository the user opens — not only one they\n * deliberately wired a gate into.\n */\n ungovernedRepository?: \"deny\" | \"allow\";\n}\n\nexport class AgentGateFactory {\n static create(\n env: NodeJS.ProcessEnv = process.env,\n options: AgentGateFactoryOptions = {},\n ): AgentGateEvaluator {\n const mode = (\n AgentHookValues.optionalString(env.DECIONIS_AGENT_GATE_MODE) ?? \"auto\"\n ).toLowerCase();\n const endpoint = AgentHookValues.optionalString(env.DECIONIS_AGENT_GATE_URL);\n const apiKey = AgentHookValues.optionalString(env.DECIONIS_API_KEY);\n const orgId = AgentHookValues.optionalString(env.DECIONIS_ORG_ID);\n const hasRemoteConfiguration = Boolean(endpoint || apiKey || orgId);\n\n if (mode !== \"auto\" && mode !== \"local\" && mode !== \"remote\") {\n throw new AgentGateConfigurationError(\n \"DECIONIS_AGENT_GATE_MODE must be `auto`, `local`, or `remote`.\",\n );\n }\n if (mode === \"local\" || (mode === \"auto\" && !hasRemoteConfiguration)) {\n const ungovernedFromEnv =\n AgentHookValues.optionalString(env.DECIONIS_UNGOVERNED_REPOSITORY)?.toLowerCase() ===\n \"allow\";\n return new LocalAgentGate({\n ungovernedRepository:\n options.ungovernedRepository ?? (ungovernedFromEnv ? \"allow\" : \"deny\"),\n });\n }\n if (!endpoint || !apiKey || !orgId) {\n throw new AgentGateConfigurationError(\n \"Remote agent gating requires DECIONIS_AGENT_GATE_URL, DECIONIS_API_KEY, and DECIONIS_ORG_ID.\",\n );\n }\n\n const configuredTimeout = Number.parseInt(env.DECIONIS_AGENT_GATE_TIMEOUT_MS ?? \"\", 10);\n return new RemoteAgentGate({\n endpoint,\n apiKey,\n orgId,\n timeoutMs:\n Number.isFinite(configuredTimeout) && configuredTimeout > 0 ? configuredTimeout : 4000,\n });\n }\n}\n","import type { AgentGateDecision, AgentGateEvaluator, AgentHostAdapter } from \"./AgentContracts.js\";\nimport { AgentDecisionMapper } from \"./AgentDecisionMapper.js\";\n\nexport class AgentHookRunner {\n constructor(\n private readonly adapter: AgentHostAdapter,\n private readonly evaluator: AgentGateEvaluator,\n ) {}\n\n async run(input: unknown): Promise<Record<string, unknown>> {\n try {\n const toolCall = this.adapter.parse(input);\n const decision = await this.evaluator.evaluate(toolCall);\n return this.adapter.format(decision, input);\n } catch (error) {\n return this.adapter.format(\n AgentDecisionMapper.error(\n error instanceof Error ? error.message : String(error),\n this.evaluator.source,\n ),\n input,\n );\n }\n }\n\n close(): Promise<void> {\n return this.evaluator.close?.() ?? Promise.resolve();\n }\n\n static shouldBlock(decision: AgentGateDecision): boolean {\n return decision.verdict !== \"allow\";\n }\n}\n","import type {\n AgentGateDecision,\n AgentHost,\n AgentHostAdapter,\n AgentToolCall,\n} from \"../AgentContracts.js\";\nimport { AgentHookRunner } from \"../AgentHookRunner.js\";\nimport { AgentHookValues } from \"../AgentHookValues.js\";\n\nexport abstract class SnakeCaseHookAdapter implements AgentHostAdapter {\n abstract readonly host: AgentHost;\n\n parse(input: unknown): AgentToolCall {\n const event = AgentHookValues.requireRecord(input);\n return {\n host: this.host,\n sessionId: AgentHookValues.requireString(event.session_id, \"session_id\"),\n toolUseId: AgentHookValues.optionalString(event.tool_use_id),\n toolName: AgentHookValues.requireString(event.tool_name, \"tool_name\"),\n toolInput: AgentHookValues.parseToolInput(event.tool_input),\n cwd: AgentHookValues.requireString(event.cwd, \"cwd\"),\n model: AgentHookValues.optionalString(event.model),\n permissionMode: AgentHookValues.optionalString(event.permission_mode),\n };\n }\n\n format(decision: AgentGateDecision, _input?: unknown): Record<string, unknown> {\n if (!AgentHookRunner.shouldBlock(decision)) return {};\n return {\n hookSpecificOutput: {\n hookEventName: \"PreToolUse\",\n permissionDecision: \"deny\",\n permissionDecisionReason: this.reason(decision),\n },\n };\n }\n\n protected reason(decision: AgentGateDecision): string {\n const label = decision.verdict === \"error\" ? \"gate error\" : decision.verdict;\n return `Decionis ${label}: ${decision.reason}`;\n }\n}\n","import { SnakeCaseHookAdapter } from \"./SnakeCaseHookAdapter.js\";\n\nexport class ClaudeHookAdapter extends SnakeCaseHookAdapter {\n readonly host = \"claude\" as const;\n}\n","import { SnakeCaseHookAdapter } from \"./SnakeCaseHookAdapter.js\";\n\nexport class CodexHookAdapter extends SnakeCaseHookAdapter {\n readonly host = \"codex\" as const;\n}\n","import type { AgentGateDecision, AgentHostAdapter, AgentToolCall } from \"../AgentContracts.js\";\nimport { AgentHookRunner } from \"../AgentHookRunner.js\";\nimport { AgentHookValues } from \"../AgentHookValues.js\";\n\nexport class CopilotHookAdapter implements AgentHostAdapter {\n readonly host = \"copilot\" as const;\n\n parse(input: unknown): AgentToolCall {\n const event = AgentHookValues.requireRecord(input);\n const usesCompatibleShape = AgentHookValues.optionalString(event.tool_name) !== null;\n const toolInput = usesCompatibleShape ? event.tool_input : event.toolArgs;\n return {\n host: this.host,\n sessionId:\n AgentHookValues.optionalString(usesCompatibleShape ? event.session_id : event.sessionId) ??\n \"unknown-session\",\n toolUseId: AgentHookValues.optionalString(\n usesCompatibleShape ? event.tool_use_id : event.toolUseId,\n ),\n toolName: AgentHookValues.requireString(\n usesCompatibleShape ? event.tool_name : event.toolName,\n usesCompatibleShape ? \"tool_name\" : \"toolName\",\n ),\n toolInput: AgentHookValues.parseToolInput(toolInput),\n cwd: AgentHookValues.optionalString(event.cwd) ?? process.cwd(),\n model: AgentHookValues.optionalString(event.model),\n permissionMode: AgentHookValues.optionalString(\n usesCompatibleShape ? event.permission_mode : event.permissionMode,\n ),\n };\n }\n\n format(decision: AgentGateDecision, input?: unknown): Record<string, unknown> {\n if (!AgentHookRunner.shouldBlock(decision)) return {};\n const label = decision.verdict === \"error\" ? \"gate error\" : decision.verdict;\n const reason = `Decionis ${label}: ${decision.reason}`;\n const event = AgentHookValues.asRecord(input);\n if (\n AgentHookValues.optionalString(event.tool_name) ||\n AgentHookValues.optionalString(event.hook_event_name) === \"PreToolUse\"\n ) {\n return {\n hookSpecificOutput: {\n hookEventName: \"PreToolUse\",\n permissionDecision: \"deny\",\n permissionDecisionReason: reason,\n },\n };\n }\n return {\n permissionDecision: \"deny\",\n permissionDecisionReason: reason,\n };\n }\n}\n","import {\n AgentGateConfigurationError,\n type AgentHost,\n type AgentHostAdapter,\n} from \"./AgentContracts.js\";\nimport { ClaudeHookAdapter } from \"./providers/ClaudeHookAdapter.js\";\nimport { CodexHookAdapter } from \"./providers/CodexHookAdapter.js\";\nimport { CopilotHookAdapter } from \"./providers/CopilotHookAdapter.js\";\n\nexport class AgentHostRegistry {\n static resolve(host: string): AgentHostAdapter {\n const normalized = host.trim().toLowerCase() as AgentHost;\n switch (normalized) {\n case \"codex\":\n return new CodexHookAdapter();\n case \"copilot\":\n return new CopilotHookAdapter();\n case \"claude\":\n return new ClaudeHookAdapter();\n default:\n throw new AgentGateConfigurationError(\n \"Choose an agent host with `decionis-agent-hook codex|copilot|claude`.\",\n );\n }\n }\n}\n","import type { Readable, Writable } from \"node:stream\";\n\nimport type { AgentGateEvaluator, AgentHostAdapter } from \"./AgentContracts.js\";\nimport { AgentGateFactory } from \"./AgentGateFactory.js\";\nimport { AgentHookRunner } from \"./AgentHookRunner.js\";\nimport { AgentHostRegistry } from \"./AgentHostRegistry.js\";\n\nexport interface AgentHookCommandOptions {\n input?: Readable;\n output?: Writable;\n errorOutput?: Writable;\n env?: NodeJS.ProcessEnv;\n}\n\nexport class AgentHookCommand {\n static async run(args: string[], options: AgentHookCommandOptions = {}): Promise<number> {\n const input = options.input ?? process.stdin;\n const output = options.output ?? process.stdout;\n const errorOutput = options.errorOutput ?? process.stderr;\n const host = AgentHookCommand.hostArgument(args);\n\n let adapter: AgentHostAdapter;\n try {\n adapter = AgentHostRegistry.resolve(host);\n } catch (error) {\n errorOutput.write(`${error instanceof Error ? error.message : String(error)}\\n`);\n return 2;\n }\n\n const raw = await AgentHookCommand.readInput(input);\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n parsed = null;\n }\n\n let evaluator: AgentGateEvaluator;\n try {\n evaluator = AgentGateFactory.create(options.env, {\n // A flag rather than an env var so the plugin's hook command is one\n // portable string — `VAR=x cmd` is not valid on Windows shells.\n ...(args.includes(\"--allow-ungoverned\") ? { ungovernedRepository: \"allow\" as const } : {}),\n });\n } catch (error) {\n const denial = adapter.format(\n {\n verdict: \"error\",\n reason: error instanceof Error ? error.message : String(error),\n source: \"local\",\n outcome: null,\n policyVersion: null,\n matchedRule: null,\n reasonCodes: [\"AGENT_GATE_CONFIGURATION_ERROR\"],\n },\n parsed,\n );\n output.write(`${JSON.stringify(denial)}\\n`);\n return 0;\n }\n\n const runner = new AgentHookRunner(adapter, evaluator);\n try {\n const result = await runner.run(parsed);\n output.write(`${JSON.stringify(result)}\\n`);\n return 0;\n } finally {\n await runner.close();\n }\n }\n\n private static hostArgument(args: string[]): string {\n const providerIndex = args.indexOf(\"--provider\");\n if (providerIndex >= 0) return args[providerIndex + 1] ?? \"\";\n return args.find((value) => !value.startsWith(\"-\")) ?? \"\";\n }\n\n private static async readInput(input: Readable): Promise<string> {\n const chunks: Buffer[] = [];\n for await (const chunk of input) {\n chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)));\n }\n return Buffer.concat(chunks).toString(\"utf8\").trim();\n }\n}\n"],"mappings":";;;;;;;;AAuCO,IAAM,sBAAN,cAAkC,MAAM;AAAA,EAC7C,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,8BAAN,cAA0C,MAAM;AAAA,EACrD,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;;;ACjDO,IAAM,kBAAN,MAAM,iBAAgB;AAAA,EAC3B,OAAO,SAAS,OAAyC;AACvD,QAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,EAAG,QAAO,CAAC;AACjF,WAAO;AAAA,EACT;AAAA,EAEA,OAAO,cAAc,OAAyC;AAC5D,UAAM,SAAS,iBAAgB,SAAS,KAAK;AAC7C,QAAI,OAAO,KAAK,MAAM,EAAE,WAAW,GAAG;AACpC,YAAM,IAAI,oBAAoB,iDAAiD;AAAA,IACjF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,OAAO,eAAe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