@policystrata/agent-trust-gateway 0.1.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Raintree Technology
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # PolicyStrata Agent Trust Gateway
2
+
3
+ Customer-hosted runtime gateway for governed-data agents. The gateway evaluates redacted runtime
4
+ events locally with `policystrata/runtime`, blocks deny/quarantine/approval-required decisions in
5
+ enforce mode, and uploads only decision envelopes to the PolicyStrata control plane by default.
6
+ It is an application-side enforcement and telemetry helper, not a replacement for `policystrata
7
+ scan`, `policystrata doctor`, application authorization, or database controls.
8
+
9
+ ```bash
10
+ npm install @policystrata/agent-trust-gateway
11
+ ```
12
+
13
+ ```bash
14
+ agent-trust-gateway serve --manifest runtime-manifest.json --port 8787 \
15
+ --api-url https://policystrata.example
16
+ ```
17
+
18
+ Loopback bindings are intended for same-host sidecars. If you bind beyond
19
+ loopback, set `POLICYSTRATA_GATEWAY_TOKEN` or pass `--gateway-token`; callers
20
+ must send `authorization: Bearer <token>` to `/v1/decide`.
21
+
22
+ POST one event or `{ "events": [...] }` to `/v1/decide`:
23
+
24
+ ```bash
25
+ curl -s http://127.0.0.1:8787/v1/decide \
26
+ -H 'content-type: application/json' \
27
+ --data @runtime-event.json
28
+ ```
29
+
30
+ The same evaluator is available in-process:
31
+
32
+ ```ts
33
+ import { decideRuntimeEvent } from "@policystrata/agent-trust-gateway";
34
+
35
+ const result = decideRuntimeEvent(runtimeManifest, runtimeEvent);
36
+ if (!result.ok) {
37
+ throw new Error(result.decisions.map((decision) => decision.reason).join("; "));
38
+ }
39
+ ```
40
+
41
+ ## Runtime Modes
42
+
43
+ Use `enforce` for production gates that should fail closed on deny, quarantine, or approval-required
44
+ decisions. Use `shadow` to observe decisions without blocking the caller. For tenant, PII, SQL,
45
+ egress, and tool controls, production examples should default to fail-closed behavior and rely on
46
+ explicit approvals or allowlists for exceptions.
47
+
48
+ The evaluator supports:
49
+
50
+ - auth-context required fields
51
+ - retrieval tenant and entitlement checks
52
+ - SQL tenant predicate detection, query-risk classification, and row-limit checks
53
+ - RLS drift events through the `database_rule` layer
54
+ - runtime kill-switch deny behavior
55
+ - memory tenant isolation
56
+ - egress destination allowlists, approval requirements, and destination classes
57
+ - data-class deny/redaction policies
58
+
59
+ See `docs/runtime-controls.md` for PII, MCP schema, browser action, code execution, human approval,
60
+ and kill-switch event examples.
61
+ See `docs/gateway-deployment-examples.md` for generic Docker, Terraform, and Helm deployment
62
+ sketches that avoid hosted-app assumptions.
63
+
64
+ ## Upload Boundary
65
+
66
+ `payload` is stripped before upload unless `includePayload` or `--include-payload` is set.
67
+ Fixture-only `expectedDecision` metadata is always stripped before upload. Keep raw prompts, rows,
68
+ documents, tool payloads, connector payloads, and test expectations local; send hashes, witness
69
+ refs, policy refs, redaction classes, query risk, and the runtime decision envelope to the control
70
+ plane.
71
+
72
+ Uploads fail closed by default if the redacted envelope still contains sensitive field names or
73
+ common secret/PII value patterns in summaries, refs, or other metadata. Use
74
+ `allowBoundaryViolations` only for local negative tests.
75
+
76
+ Uploads send `x-clearance-organization-id` and the legacy
77
+ `x-assurance-organization-id` header while hosted control planes migrate. Uploads also support an
78
+ idempotency key and enforce a 1 MB default upload-body limit before opening the network request.
79
+
80
+ ## Deployment Guidance
81
+
82
+ Keep the gateway close to the application or agent runtime. For production:
83
+
84
+ - bind to loopback or require a gateway token for non-loopback bindings;
85
+ - terminate TLS and rate-limit requests at the platform edge, service mesh, or reverse proxy;
86
+ - keep request bodies small and metadata-only;
87
+ - default tenant, PII, SQL, egress, and tool controls to fail closed;
88
+ - use `shadow` mode only while validating policy coverage before an enforcement rollout.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env node
2
+ import { readFile, writeFile } from "node:fs/promises";
3
+ import { decideRuntimePayload, startAgentTrustGateway, } from "./index.js";
4
+ async function main(argv) {
5
+ const command = argv[0];
6
+ const flags = parseFlags(argv.slice(1));
7
+ if (!command || flags.help === true || flags.h === true) {
8
+ printHelp();
9
+ return command ? 0 : 2;
10
+ }
11
+ if (command === "decide") {
12
+ const manifest = await readJson(requiredString(flags, "manifest"));
13
+ const eventPayload = await readJson(requiredString(flags, "event"));
14
+ const mode = modeFlag(flags);
15
+ const result = decideRuntimePayload(manifest, eventPayload, mode);
16
+ const body = `${JSON.stringify(result, null, 2)}\n`;
17
+ const out = optionalString(flags, "out");
18
+ if (out) {
19
+ await writeFile(out, body, "utf8");
20
+ }
21
+ else {
22
+ process.stdout.write(body);
23
+ }
24
+ return result.ok || mode === "shadow" ? 0 : 1;
25
+ }
26
+ if (command === "serve") {
27
+ const manifest = await readJson(requiredString(flags, "manifest"));
28
+ const upload = uploadOptions(flags);
29
+ const gateway = await startAgentTrustGateway({
30
+ manifest,
31
+ host: optionalString(flags, "host"),
32
+ port: numberFlag(flags, "port") ?? 8787,
33
+ mode: modeFlag(flags),
34
+ upload,
35
+ gatewayToken: optionalString(flags, "gateway-token") ?? process.env.POLICYSTRATA_GATEWAY_TOKEN,
36
+ failOnUploadError: flags["fail-on-upload-error"] === true,
37
+ });
38
+ process.stderr.write(`PolicyStrata Agent Trust Gateway listening at ${gateway.url}\n`);
39
+ await waitForShutdown(gateway.close);
40
+ return 0;
41
+ }
42
+ throw new Error(`unknown command: ${command}`);
43
+ }
44
+ function parseFlags(argv) {
45
+ const flags = {};
46
+ for (let index = 0; index < argv.length; index += 1) {
47
+ const item = argv[index];
48
+ if (!item.startsWith("--")) {
49
+ throw new Error(`unexpected argument: ${item}`);
50
+ }
51
+ const key = item.slice(2);
52
+ const next = argv[index + 1];
53
+ if (!next || next.startsWith("--")) {
54
+ flags[key] = true;
55
+ continue;
56
+ }
57
+ flags[key] = next;
58
+ index += 1;
59
+ }
60
+ return flags;
61
+ }
62
+ function uploadOptions(flags) {
63
+ const apiUrl = optionalString(flags, "api-url");
64
+ if (!apiUrl)
65
+ return undefined;
66
+ return {
67
+ apiUrl,
68
+ token: optionalString(flags, "token") ?? process.env.POLICYSTRATA_CONTROL_PLANE_TOKEN,
69
+ organizationId: optionalString(flags, "organization-id"),
70
+ includePayload: flags["include-payload"] === true,
71
+ };
72
+ }
73
+ function modeFlag(flags) {
74
+ if (flags.shadow === true)
75
+ return "shadow";
76
+ const raw = optionalString(flags, "mode");
77
+ if (raw === "shadow" || raw === "enforce")
78
+ return raw;
79
+ if (raw) {
80
+ throw new Error("--mode must be shadow or enforce");
81
+ }
82
+ return "enforce";
83
+ }
84
+ function numberFlag(flags, key) {
85
+ const raw = optionalString(flags, key);
86
+ if (!raw)
87
+ return undefined;
88
+ const parsed = Number(raw);
89
+ if (!Number.isInteger(parsed) || parsed < 0) {
90
+ throw new Error(`--${key} must be a non-negative integer`);
91
+ }
92
+ return parsed;
93
+ }
94
+ function requiredString(flags, key) {
95
+ const value = optionalString(flags, key);
96
+ if (!value) {
97
+ throw new Error(`missing --${key}`);
98
+ }
99
+ return value;
100
+ }
101
+ function optionalString(flags, key) {
102
+ const value = flags[key];
103
+ return typeof value === "string" && value.length > 0 ? value : undefined;
104
+ }
105
+ async function readJson(path) {
106
+ return JSON.parse(await readFile(path, "utf8"));
107
+ }
108
+ function waitForShutdown(close) {
109
+ return new Promise((resolve, reject) => {
110
+ const stop = () => {
111
+ close().then(resolve, reject);
112
+ };
113
+ process.once("SIGINT", stop);
114
+ process.once("SIGTERM", stop);
115
+ });
116
+ }
117
+ function printHelp() {
118
+ process.stdout.write(`PolicyStrata Agent Trust Gateway
119
+
120
+ Usage:
121
+ agent-trust-gateway decide --manifest manifest.json --event event.json [--out decisions.json] [--mode enforce|shadow]
122
+ agent-trust-gateway serve --manifest manifest.json [--host 127.0.0.1] [--port 8787] [--api-url http://localhost:3000]
123
+
124
+ Options:
125
+ --shadow Alias for --mode shadow.
126
+ --api-url PolicyStrata control-plane base URL for redacted event uploads.
127
+ --token Control-plane bearer token. Defaults to POLICYSTRATA_CONTROL_PLANE_TOKEN.
128
+ --organization-id Optional organization header for the control plane.
129
+ --include-payload Upload event payloads instead of stripping them. Off by default.
130
+ --gateway-token Bearer token required by /v1/decide. Defaults to POLICYSTRATA_GATEWAY_TOKEN.
131
+ --fail-on-upload-error Return 502 when the control-plane upload fails.
132
+ `);
133
+ }
134
+ main(process.argv.slice(2)).then((code) => {
135
+ process.exitCode = code;
136
+ }, (error) => {
137
+ process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
138
+ process.exitCode = 1;
139
+ });
140
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,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AAC;QACF,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC7B,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,SAAS;IAChB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;;;;;;;;;;;;;;CActB,CAAC,CAAC;AACH,CAAC;AAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAC9B,CAAC,IAAI,EAAE,EAAE;IACP,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;AAC1B,CAAC,EACD,CAAC,KAAc,EAAE,EAAE;IACjB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACpF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CACF,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { type IncomingMessage, type Server, type ServerResponse } from "node:http";
2
+ import { type PolicyStrataRuntimeEventDecision, type PolicyStrataRuntimeEventEvaluation, type PolicyStrataRuntimeEventInput, type PolicyStrataRuntimeManifest } from "policystrata/runtime";
3
+ export declare const POLICYSTRATA_GATEWAY_VERSION = "0.1.1";
4
+ export type AgentTrustGatewayMode = "shadow" | "enforce";
5
+ export interface RuntimeEventBatchPayload {
6
+ events: readonly PolicyStrataRuntimeEventInput[];
7
+ }
8
+ export type NativeIntegrationProvider = "github" | "vercel" | "datadog" | "snowflake" | "slack" | "jira" | "aws" | "gcp" | "azure";
9
+ export interface NativeIntegrationEvidenceInput {
10
+ provider: NativeIntegrationProvider;
11
+ project: string;
12
+ connectionId: string;
13
+ eventType?: string;
14
+ observedAt?: string;
15
+ decision?: PolicyStrataRuntimeEventDecision["action"];
16
+ summary?: string;
17
+ evidenceRefs?: readonly string[];
18
+ payload?: Record<string, unknown>;
19
+ }
20
+ export type RuntimeEventPayload = PolicyStrataRuntimeEventInput | RuntimeEventBatchPayload;
21
+ export type RuntimeEventWithDecision = PolicyStrataRuntimeEventInput & {
22
+ decision: PolicyStrataRuntimeEventDecision;
23
+ };
24
+ export interface GatewayDecisionResult {
25
+ ok: boolean;
26
+ mode: AgentTrustGatewayMode;
27
+ events: RuntimeEventWithDecision[];
28
+ decisions: PolicyStrataRuntimeEventEvaluation[];
29
+ }
30
+ export interface RuntimeEventUploadOptions {
31
+ apiUrl: string;
32
+ token?: string;
33
+ organizationId?: string;
34
+ path?: string;
35
+ idempotencyKey?: string;
36
+ maxBodyBytes?: number;
37
+ includePayload?: boolean;
38
+ allowBoundaryViolations?: boolean;
39
+ fetch?: typeof fetch;
40
+ }
41
+ export interface RuntimeEventUploadResult {
42
+ ok: boolean;
43
+ status: number;
44
+ body: unknown;
45
+ }
46
+ export interface AgentTrustGatewayOptions {
47
+ manifest: PolicyStrataRuntimeManifest;
48
+ mode?: AgentTrustGatewayMode;
49
+ upload?: RuntimeEventUploadOptions;
50
+ gatewayToken?: string;
51
+ failOnUploadError?: boolean;
52
+ maxBodyBytes?: number;
53
+ }
54
+ export interface StartedAgentTrustGateway {
55
+ server: Server;
56
+ url: string;
57
+ close(): Promise<void>;
58
+ }
59
+ export interface MetadataBoundaryFinding {
60
+ path: string;
61
+ reason: string;
62
+ severity: "high" | "critical";
63
+ }
64
+ export declare class PolicyStrataGatewayBlockedError extends Error {
65
+ readonly result: GatewayDecisionResult;
66
+ constructor(result: GatewayDecisionResult);
67
+ }
68
+ export declare function nativeIntegrationRuntimeEvent(input: NativeIntegrationEvidenceInput): PolicyStrataRuntimeEventInput;
69
+ export declare function decideRuntimeEvent(manifest: PolicyStrataRuntimeManifest, event: PolicyStrataRuntimeEventInput, mode?: AgentTrustGatewayMode): GatewayDecisionResult;
70
+ export declare function decideRuntimeEvents(manifest: PolicyStrataRuntimeManifest, events: readonly PolicyStrataRuntimeEventInput[], mode?: AgentTrustGatewayMode): GatewayDecisionResult;
71
+ export declare function decideRuntimePayload(manifest: PolicyStrataRuntimeManifest, payload: unknown, mode?: AgentTrustGatewayMode): GatewayDecisionResult;
72
+ export declare function guardRuntimePayload(manifest: PolicyStrataRuntimeManifest, payload: unknown, mode?: AgentTrustGatewayMode): Promise<GatewayDecisionResult>;
73
+ export declare function runtimeEventsFromPayload(payload: unknown): PolicyStrataRuntimeEventInput[];
74
+ export declare function redactRuntimeEventForUpload(event: RuntimeEventWithDecision): RuntimeEventWithDecision;
75
+ export declare function scanMetadataBoundary(payload: unknown): MetadataBoundaryFinding[];
76
+ export declare function assertMetadataBoundary(payload: unknown): void;
77
+ export declare function uploadRuntimeEvents(options: RuntimeEventUploadOptions & {
78
+ events: readonly RuntimeEventWithDecision[];
79
+ }): Promise<RuntimeEventUploadResult>;
80
+ export declare function createAgentTrustGatewayHandler(options: AgentTrustGatewayOptions): (request: IncomingMessage, response: ServerResponse) => void;
81
+ export declare function createAgentTrustGatewayServer(options: AgentTrustGatewayOptions): Server;
82
+ export declare function startAgentTrustGateway(options: AgentTrustGatewayOptions & {
83
+ host?: string;
84
+ port?: number;
85
+ }): Promise<StartedAgentTrustGateway>;
@@ -0,0 +1,410 @@
1
+ import { createHash, timingSafeEqual } from "node:crypto";
2
+ import { createServer } from "node:http";
3
+ import { evaluateRuntimeEvent, evaluateRuntimeEvents, } from "policystrata/runtime";
4
+ export const POLICYSTRATA_GATEWAY_VERSION = "0.1.1";
5
+ export class PolicyStrataGatewayBlockedError extends Error {
6
+ result;
7
+ constructor(result) {
8
+ super(result.decisions.map((decision) => decision.reason).join("; ") || "runtime policy blocked event");
9
+ this.name = "PolicyStrataGatewayBlockedError";
10
+ this.result = result;
11
+ }
12
+ }
13
+ export function nativeIntegrationRuntimeEvent(input) {
14
+ const eventType = input.eventType ?? defaultIntegrationEventType(input.provider);
15
+ const evidenceRefs = input.evidenceRefs ?? [`integration://${input.provider}/${input.connectionId}`];
16
+ const payload = {
17
+ storageMode: "metadata_only",
18
+ provider: input.provider,
19
+ connectionId: input.connectionId,
20
+ ...(input.payload ?? {}),
21
+ };
22
+ return {
23
+ schemaVersion: "0.2.0",
24
+ eventId: `integration-${input.provider}-${input.connectionId}-${sha256Json(payload).slice(0, 16)}`,
25
+ project: input.project,
26
+ observedAt: input.observedAt ?? new Date().toISOString(),
27
+ agent: {
28
+ key: `${input.provider}-integration`,
29
+ name: `${input.provider} integration`,
30
+ kind: "integration",
31
+ },
32
+ layer: defaultIntegrationLayer(input.provider),
33
+ operation: eventType,
34
+ summary: input.summary ?? `${input.provider} evidence synchronized for ${input.project}`,
35
+ decision: {
36
+ action: input.decision ?? defaultIntegrationDecision(input.provider),
37
+ reason: `${input.provider} provider evidence`,
38
+ control: {
39
+ id: `${input.provider}.native_integration`,
40
+ mode: "release_gate",
41
+ objective: "Use native provider evidence in Clearance gates",
42
+ },
43
+ },
44
+ provider: input.provider,
45
+ integrationConnectionId: input.connectionId,
46
+ externalRefs: evidenceRefs.map((ref) => ({
47
+ provider: input.provider,
48
+ ref,
49
+ kind: "evidence",
50
+ connectionId: input.connectionId,
51
+ })),
52
+ artifactRefs: [...evidenceRefs],
53
+ payloadHash: sha256Json(payload),
54
+ };
55
+ }
56
+ export function decideRuntimeEvent(manifest, event, mode = "enforce") {
57
+ const decision = evaluateRuntimeEvent(manifest, event);
58
+ return decisionResult([decision], mode);
59
+ }
60
+ export function decideRuntimeEvents(manifest, events, mode = "enforce") {
61
+ return decisionResult(evaluateRuntimeEvents(manifest, events), mode);
62
+ }
63
+ export function decideRuntimePayload(manifest, payload, mode = "enforce") {
64
+ return decideRuntimeEvents(manifest, runtimeEventsFromPayload(payload), mode);
65
+ }
66
+ export async function guardRuntimePayload(manifest, payload, mode = "enforce") {
67
+ const result = decideRuntimePayload(manifest, payload, mode);
68
+ if (mode === "enforce" && !result.ok) {
69
+ throw new PolicyStrataGatewayBlockedError(result);
70
+ }
71
+ return result;
72
+ }
73
+ export function runtimeEventsFromPayload(payload) {
74
+ if (Array.isArray(payload)) {
75
+ return payload.map(assertRuntimeEvent);
76
+ }
77
+ const record = recordValue(payload);
78
+ if (Array.isArray(record.events)) {
79
+ return record.events.map(assertRuntimeEvent);
80
+ }
81
+ return [assertRuntimeEvent(payload)];
82
+ }
83
+ export function redactRuntimeEventForUpload(event) {
84
+ const { expectedDecision: _expectedDecision, expected_decision: _expectedDecisionSnake, payload: _payload, ...redacted } = event;
85
+ return redacted;
86
+ }
87
+ export function scanMetadataBoundary(payload) {
88
+ const findings = [];
89
+ for (const [path, value] of walkPayload(payload)) {
90
+ const key = path.split(".").at(-1) ?? path;
91
+ if (SENSITIVE_KEY_PATTERN.test(key)) {
92
+ findings.push({
93
+ path,
94
+ reason: `sensitive field name: ${key}`,
95
+ severity: "critical",
96
+ });
97
+ }
98
+ if (typeof value === "string") {
99
+ for (const [pattern, label] of SECRET_VALUE_PATTERNS) {
100
+ if (pattern.test(value)) {
101
+ findings.push({
102
+ path,
103
+ reason: `possible ${label}`,
104
+ severity: "critical",
105
+ });
106
+ }
107
+ }
108
+ }
109
+ }
110
+ return findings;
111
+ }
112
+ export function assertMetadataBoundary(payload) {
113
+ const findings = scanMetadataBoundary(payload);
114
+ if (findings.length > 0) {
115
+ const first = findings[0];
116
+ throw new Error(`metadata-only boundary violation at ${first.path}: ${first.reason}`);
117
+ }
118
+ }
119
+ function runtimeEventForUpload(event, includePayload) {
120
+ const { expectedDecision: _expectedDecision, ...withoutExpectation } = event;
121
+ if (includePayload)
122
+ return withoutExpectation;
123
+ return redactRuntimeEventForUpload(event);
124
+ }
125
+ export async function uploadRuntimeEvents(options) {
126
+ const client = options.fetch ?? fetch;
127
+ const events = options.events.map((event) => runtimeEventForUpload(event, options.includePayload === true));
128
+ const uploadBody = JSON.stringify({
129
+ gateway: {
130
+ name: "@policystrata/agent-trust-gateway",
131
+ version: POLICYSTRATA_GATEWAY_VERSION,
132
+ },
133
+ events,
134
+ });
135
+ const maxBodyBytes = options.maxBodyBytes ?? 1_000_000;
136
+ if (Buffer.byteLength(uploadBody, "utf8") > maxBodyBytes) {
137
+ throw new Error(`runtime event upload payload is too large: exceeds ${maxBodyBytes} bytes`);
138
+ }
139
+ if (options.allowBoundaryViolations !== true) {
140
+ assertMetadataBoundary({ events });
141
+ }
142
+ const response = await client(runtimeEventsEndpoint(options), {
143
+ method: "POST",
144
+ headers: uploadHeaders(options),
145
+ body: uploadBody,
146
+ });
147
+ const body = await responseBody(response);
148
+ return {
149
+ ok: response.ok,
150
+ status: response.status,
151
+ body,
152
+ };
153
+ }
154
+ export function createAgentTrustGatewayHandler(options) {
155
+ const mode = options.mode ?? "enforce";
156
+ const maxBodyBytes = options.maxBodyBytes ?? 1_000_000;
157
+ const gatewayToken = resolveGatewayToken(options.gatewayToken);
158
+ return (request, response) => {
159
+ void handleRequest(request, response, options, mode, maxBodyBytes, gatewayToken);
160
+ };
161
+ }
162
+ export function createAgentTrustGatewayServer(options) {
163
+ return createServer(createAgentTrustGatewayHandler(options));
164
+ }
165
+ export async function startAgentTrustGateway(options) {
166
+ const server = createAgentTrustGatewayServer(options);
167
+ const host = options.host ?? "127.0.0.1";
168
+ const port = options.port ?? 8787;
169
+ if (!isLoopbackHost(host) && !resolveGatewayToken(options.gatewayToken)) {
170
+ throw new Error("POLICYSTRATA_GATEWAY_TOKEN or --gateway-token is required when binding beyond loopback");
171
+ }
172
+ await new Promise((resolve, reject) => {
173
+ server.once("error", reject);
174
+ server.listen(port, host, () => {
175
+ server.off("error", reject);
176
+ resolve();
177
+ });
178
+ });
179
+ const address = server.address();
180
+ return {
181
+ server,
182
+ url: `http://${address.address}:${address.port}`,
183
+ close: () => new Promise((resolve, reject) => {
184
+ server.close((error) => (error ? reject(error) : resolve()));
185
+ }),
186
+ };
187
+ }
188
+ async function handleRequest(request, response, options, mode, maxBodyBytes, gatewayToken) {
189
+ try {
190
+ const url = new URL(request.url ?? "/", "http://localhost");
191
+ if (request.method === "GET" && url.pathname === "/healthz") {
192
+ sendJson(response, 200, { ok: true, service: "policystrata-agent-trust-gateway" });
193
+ return;
194
+ }
195
+ if (request.method !== "POST" || url.pathname !== "/v1/decide") {
196
+ sendJson(response, 404, { ok: false, error: "not_found" });
197
+ return;
198
+ }
199
+ if (gatewayToken && !isAuthorizedGatewayRequest(request, gatewayToken)) {
200
+ sendJson(response, 401, { ok: false, error: "unauthorized" });
201
+ return;
202
+ }
203
+ const payload = await readJsonBody(request, maxBodyBytes);
204
+ const result = decideRuntimePayload(options.manifest, payload, mode);
205
+ let upload;
206
+ if (options.upload) {
207
+ upload = await uploadRuntimeEvents({ ...options.upload, events: result.events });
208
+ }
209
+ const uploadFailed = Boolean(upload && !upload.ok && options.failOnUploadError);
210
+ const status = uploadFailed ? 502 : !result.ok && mode === "enforce" ? 403 : 200;
211
+ sendJson(response, status, {
212
+ ...result,
213
+ upload: upload ? { ok: upload.ok, status: upload.status, body: upload.body } : undefined,
214
+ });
215
+ }
216
+ catch (error) {
217
+ sendJson(response, 400, {
218
+ ok: false,
219
+ error: error instanceof Error ? error.message : "invalid runtime gateway request",
220
+ });
221
+ }
222
+ }
223
+ function decisionResult(decisions, mode) {
224
+ return {
225
+ ok: decisions.every((decision) => decision.allowed),
226
+ mode,
227
+ events: decisions.map((decision) => decision.event),
228
+ decisions: [...decisions],
229
+ };
230
+ }
231
+ function assertRuntimeEvent(value) {
232
+ const event = recordValue(value);
233
+ for (const key of ["schemaVersion", "eventId", "project", "observedAt", "agent", "layer", "operation", "summary"]) {
234
+ if (event[key] === undefined) {
235
+ throw new Error(`runtime event is missing ${key}`);
236
+ }
237
+ }
238
+ return event;
239
+ }
240
+ function runtimeEventsEndpoint(options) {
241
+ return new URL(options.path ?? "/api/v1/runtime-events", options.apiUrl).toString();
242
+ }
243
+ function uploadHeaders(options) {
244
+ const headers = {
245
+ "content-type": "application/json",
246
+ };
247
+ if (options.token) {
248
+ headers.authorization = `Bearer ${options.token}`;
249
+ }
250
+ if (options.organizationId) {
251
+ headers["x-clearance-organization-id"] = options.organizationId;
252
+ headers["x-assurance-organization-id"] = options.organizationId;
253
+ }
254
+ if (options.idempotencyKey) {
255
+ headers["idempotency-key"] = options.idempotencyKey;
256
+ }
257
+ return headers;
258
+ }
259
+ function resolveGatewayToken(explicitToken) {
260
+ return explicitToken || process.env.POLICYSTRATA_GATEWAY_TOKEN;
261
+ }
262
+ function isLoopbackHost(host) {
263
+ const normalized = host.trim().toLowerCase();
264
+ return (normalized === "localhost" ||
265
+ normalized === "127.0.0.1" ||
266
+ normalized === "::1" ||
267
+ normalized === "[::1]");
268
+ }
269
+ function isAuthorizedGatewayRequest(request, gatewayToken) {
270
+ const authorization = request.headers.authorization ?? "";
271
+ const credential = authorization.toLowerCase().startsWith("bearer ")
272
+ ? authorization.slice(7).trim()
273
+ : "";
274
+ if (!credential)
275
+ return false;
276
+ const left = Buffer.from(credential);
277
+ const right = Buffer.from(gatewayToken);
278
+ return left.length === right.length && timingSafeEqual(left, right);
279
+ }
280
+ async function responseBody(response) {
281
+ const text = await response.text();
282
+ if (!text)
283
+ return null;
284
+ try {
285
+ return JSON.parse(text);
286
+ }
287
+ catch {
288
+ return text;
289
+ }
290
+ }
291
+ async function readJsonBody(request, maxBodyBytes) {
292
+ const chunks = [];
293
+ let total = 0;
294
+ for await (const chunk of request) {
295
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
296
+ total += buffer.byteLength;
297
+ if (total > maxBodyBytes) {
298
+ throw new Error("runtime gateway request body is too large");
299
+ }
300
+ chunks.push(buffer);
301
+ }
302
+ const raw = Buffer.concat(chunks).toString("utf8");
303
+ if (!raw.trim()) {
304
+ throw new Error("runtime gateway request body is empty");
305
+ }
306
+ return JSON.parse(raw);
307
+ }
308
+ function sendJson(response, status, payload) {
309
+ response.writeHead(status, { "content-type": "application/json" });
310
+ response.end(`${JSON.stringify(payload)}\n`);
311
+ }
312
+ function recordValue(value) {
313
+ return value && typeof value === "object" && !Array.isArray(value)
314
+ ? value
315
+ : {};
316
+ }
317
+ const SENSITIVE_KEY_PATTERN = /(?:^|[_\-.])(api[_\-.]?key|authorization|bearer|cookie|credential|customer[_\-.]?rows|doc[_\-.]?text|documents?|full[_\-.]?trace|input[_\-.]?schema|output[_\-.]?schema|password|passwd|private[_\-.]?schema|prompt|raw[_\-.]?docs?|raw[_\-.]?documents?|raw[_\-.]?payload|raw[_\-.]?prompt|rows|sampled[_\-.]?rows|secret|source[_\-.]?credentials|token|tool[_\-.]?(?:input|output|payload|request|response))(?:$|[_\-.])/i;
318
+ const SECRET_VALUE_PATTERNS = [
319
+ [/\bBearer\s+[A-Za-z0-9._~+/=-]{8,}\b/i, "bearer token"],
320
+ [/\b(?:api[_-]?key|password|passwd|secret|token)\s*[:=]\s*[^\s,;]+/i, "secret assignment"],
321
+ [/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/, "JWT"],
322
+ [/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i, "email address"],
323
+ [/\b(?:\d[ -]*?){13,19}\b/, "possible payment card"],
324
+ [/\bsk-[A-Za-z0-9_-]{16,}\b/, "API key"],
325
+ [/\bgh[pousr]_[A-Za-z0-9_]{20,}\b/, "API key"],
326
+ [/\bAKIA[0-9A-Z]{16}\b/, "API key"],
327
+ [/https?:\/\/[^\s?#]+[^\s]*[?&](?:api[_-]?key|token|secret|password)=[^&\s]+/i, "secret in URL"],
328
+ ];
329
+ function* walkPayload(value, prefix = "$") {
330
+ yield [prefix, value];
331
+ if (Array.isArray(value)) {
332
+ for (let index = 0; index < value.length; index += 1) {
333
+ yield* walkPayload(value[index], `${prefix}[${index}]`);
334
+ }
335
+ return;
336
+ }
337
+ if (!value || typeof value !== "object")
338
+ return;
339
+ for (const [key, child] of Object.entries(value)) {
340
+ yield* walkPayload(child, `${prefix}.${key}`);
341
+ }
342
+ }
343
+ function defaultIntegrationEventType(provider) {
344
+ switch (provider) {
345
+ case "github":
346
+ return "github.check_gate";
347
+ case "vercel":
348
+ return "vercel.deployment_gate";
349
+ case "datadog":
350
+ return "datadog.monitor_signal";
351
+ case "snowflake":
352
+ return "snowflake.data_policy_signal";
353
+ case "slack":
354
+ return "slack.approval_channel";
355
+ case "jira":
356
+ return "jira.workflow_gate";
357
+ case "aws":
358
+ return "aws.control_plane_signal";
359
+ case "gcp":
360
+ return "gcp.control_plane_signal";
361
+ case "azure":
362
+ return "azure.control_plane_signal";
363
+ default:
364
+ return exhaustiveProvider(provider);
365
+ }
366
+ }
367
+ function defaultIntegrationLayer(provider) {
368
+ switch (provider) {
369
+ case "snowflake":
370
+ return "sql";
371
+ case "aws":
372
+ case "gcp":
373
+ case "azure":
374
+ case "vercel":
375
+ return "egress";
376
+ case "datadog":
377
+ case "github":
378
+ case "slack":
379
+ case "jira":
380
+ return "trace";
381
+ default:
382
+ return exhaustiveProvider(provider);
383
+ }
384
+ }
385
+ function defaultIntegrationDecision(provider) {
386
+ switch (provider) {
387
+ case "github":
388
+ case "vercel":
389
+ return "allow";
390
+ case "datadog":
391
+ case "snowflake":
392
+ case "slack":
393
+ case "jira":
394
+ case "aws":
395
+ case "gcp":
396
+ case "azure":
397
+ return "require_approval";
398
+ default:
399
+ return exhaustiveProvider(provider);
400
+ }
401
+ }
402
+ function sha256Json(value) {
403
+ return createHash("sha256")
404
+ .update(JSON.stringify(value, Object.keys(recordValue(value)).sort()))
405
+ .digest("hex");
406
+ }
407
+ function exhaustiveProvider(provider) {
408
+ throw new Error(`Unsupported native integration provider: ${provider}`);
409
+ }
410
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,YAAY,EAA0D,MAAM,WAAW,CAAC;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OAAO,CAAC;QACb,KAAK,MAAM;YACT,OAAO,OAAO,CAAC;QACjB;YACE,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;AACH,CAAC;AAED,SAAS,0BAA0B,CAAC,QAAmC;IACrE,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ;YACX,OAAO,OAAO,CAAC;QACjB,KAAK,SAAS,CAAC;QACf,KAAK,WAAW,CAAC;QACjB,KAAK,OAAO,CAAC;QACb,KAAK,MAAM,CAAC;QACZ,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,OAAO;YACV,OAAO,kBAAkB,CAAC;QAC5B;YACE,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,UAAU,CAAC,QAAQ,CAAC;SACxB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;SACrE,MAAM,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC;AAED,SAAS,kBAAkB,CAAC,QAAe;IACzC,MAAM,IAAI,KAAK,CAAC,4CAA4C,QAAQ,EAAE,CAAC,CAAC;AAC1E,CAAC"}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@policystrata/agent-trust-gateway",
3
+ "version": "0.1.1",
4
+ "description": "Customer-hosted runtime gateway for PolicyStrata governed-data agents",
5
+ "type": "module",
6
+ "main": "./dist/src/index.js",
7
+ "types": "./dist/src/index.d.ts",
8
+ "bin": {
9
+ "agent-trust-gateway": "dist/src/cli.js"
10
+ },
11
+ "license": "MIT",
12
+ "sideEffects": false,
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/raintree-technology/policystrata.git",
16
+ "directory": "packages/gateway"
17
+ },
18
+ "publishConfig": {
19
+ "registry": "https://registry.npmjs.org/",
20
+ "access": "public"
21
+ },
22
+ "keywords": [
23
+ "llm",
24
+ "data-agents",
25
+ "runtime-security",
26
+ "agent-governance",
27
+ "policystrata"
28
+ ],
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/src/index.d.ts",
32
+ "default": "./dist/src/index.js"
33
+ }
34
+ },
35
+ "files": [
36
+ "dist/src",
37
+ "README.md",
38
+ "LICENSE"
39
+ ],
40
+ "scripts": {
41
+ "build": "bun run --cwd ../node build && tsc -p tsconfig.json",
42
+ "test": "bun run build && node --test dist/test/*.test.js",
43
+ "prepack": "bun run build"
44
+ },
45
+ "engines": {
46
+ "node": "24.x"
47
+ },
48
+ "dependencies": {
49
+ "policystrata": "^0.1.3"
50
+ },
51
+ "devDependencies": {
52
+ "@types/node": "^22.0.0",
53
+ "typescript": "^5.0.0"
54
+ }
55
+ }