palaryn 0.1.0 → 0.3.2
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/README.md +243 -588
- package/dist/sdk/typescript/src/client.js +2 -2
- package/dist/sdk/typescript/src/client.js.map +1 -1
- package/dist/src/anomaly/detector.d.ts +7 -4
- package/dist/src/anomaly/detector.d.ts.map +1 -1
- package/dist/src/anomaly/detector.js +22 -12
- package/dist/src/anomaly/detector.js.map +1 -1
- package/dist/src/audit/logger.d.ts +10 -0
- package/dist/src/audit/logger.d.ts.map +1 -1
- package/dist/src/audit/logger.js +52 -38
- package/dist/src/audit/logger.js.map +1 -1
- package/dist/src/auth/routes.d.ts.map +1 -1
- package/dist/src/auth/routes.js +35 -0
- package/dist/src/auth/routes.js.map +1 -1
- package/dist/src/budget/manager.d.ts +5 -0
- package/dist/src/budget/manager.d.ts.map +1 -1
- package/dist/src/budget/manager.js +32 -0
- package/dist/src/budget/manager.js.map +1 -1
- package/dist/src/budget/model-pricing.d.ts +20 -0
- package/dist/src/budget/model-pricing.d.ts.map +1 -0
- package/dist/src/budget/model-pricing.js +107 -0
- package/dist/src/budget/model-pricing.js.map +1 -0
- package/dist/src/budget/usage-extractor.d.ts +3 -1
- package/dist/src/budget/usage-extractor.d.ts.map +1 -1
- package/dist/src/budget/usage-extractor.js +47 -3
- package/dist/src/budget/usage-extractor.js.map +1 -1
- package/dist/src/config/defaults.d.ts.map +1 -1
- package/dist/src/config/defaults.js +65 -13
- package/dist/src/config/defaults.js.map +1 -1
- package/dist/src/dlp/tool-patterns.d.ts +7 -0
- package/dist/src/dlp/tool-patterns.d.ts.map +1 -0
- package/dist/src/dlp/tool-patterns.js +34 -0
- package/dist/src/dlp/tool-patterns.js.map +1 -0
- package/dist/src/executor/filesystem-executor.d.ts +28 -0
- package/dist/src/executor/filesystem-executor.d.ts.map +1 -0
- package/dist/src/executor/filesystem-executor.js +192 -0
- package/dist/src/executor/filesystem-executor.js.map +1 -0
- package/dist/src/executor/http-executor.d.ts.map +1 -1
- package/dist/src/executor/http-executor.js +22 -2
- package/dist/src/executor/http-executor.js.map +1 -1
- package/dist/src/executor/index.d.ts +4 -0
- package/dist/src/executor/index.d.ts.map +1 -1
- package/dist/src/executor/index.js +9 -1
- package/dist/src/executor/index.js.map +1 -1
- package/dist/src/executor/shell-executor.d.ts +22 -0
- package/dist/src/executor/shell-executor.d.ts.map +1 -0
- package/dist/src/executor/shell-executor.js +119 -0
- package/dist/src/executor/shell-executor.js.map +1 -0
- package/dist/src/executor/sql-executor.d.ts +29 -0
- package/dist/src/executor/sql-executor.d.ts.map +1 -0
- package/dist/src/executor/sql-executor.js +114 -0
- package/dist/src/executor/sql-executor.js.map +1 -0
- package/dist/src/executor/websocket-executor.d.ts +26 -0
- package/dist/src/executor/websocket-executor.d.ts.map +1 -0
- package/dist/src/executor/websocket-executor.js +205 -0
- package/dist/src/executor/websocket-executor.js.map +1 -0
- package/dist/src/interceptor/index.d.ts +2 -0
- package/dist/src/interceptor/index.d.ts.map +1 -0
- package/dist/src/interceptor/index.js +6 -0
- package/dist/src/interceptor/index.js.map +1 -0
- package/dist/src/interceptor/provider-interceptor.d.ts +36 -0
- package/dist/src/interceptor/provider-interceptor.d.ts.map +1 -0
- package/dist/src/interceptor/provider-interceptor.js +302 -0
- package/dist/src/interceptor/provider-interceptor.js.map +1 -0
- package/dist/src/mcp/auth-verifier.d.ts.map +1 -1
- package/dist/src/mcp/auth-verifier.js +3 -2
- package/dist/src/mcp/auth-verifier.js.map +1 -1
- package/dist/src/mcp/bridge.d.ts +14 -10
- package/dist/src/mcp/bridge.d.ts.map +1 -1
- package/dist/src/mcp/bridge.js +51 -227
- package/dist/src/mcp/bridge.js.map +1 -1
- package/dist/src/mcp/http-transport.d.ts +2 -0
- package/dist/src/mcp/http-transport.d.ts.map +1 -1
- package/dist/src/mcp/http-transport.js +117 -66
- package/dist/src/mcp/http-transport.js.map +1 -1
- package/dist/src/mcp/internal-auth.d.ts +13 -0
- package/dist/src/mcp/internal-auth.d.ts.map +1 -0
- package/dist/src/mcp/internal-auth.js +12 -0
- package/dist/src/mcp/internal-auth.js.map +1 -0
- package/dist/src/mcp/tool-definitions.d.ts +41 -0
- package/dist/src/mcp/tool-definitions.d.ts.map +1 -0
- package/dist/src/mcp/tool-definitions.js +491 -0
- package/dist/src/mcp/tool-definitions.js.map +1 -0
- package/dist/src/middleware/auth.js.map +1 -1
- package/dist/src/middleware/session.js.map +1 -1
- package/dist/src/middleware/validate.d.ts +8 -0
- package/dist/src/middleware/validate.d.ts.map +1 -1
- package/dist/src/middleware/validate.js +45 -0
- package/dist/src/middleware/validate.js.map +1 -1
- package/dist/src/policy/engine.d.ts +4 -0
- package/dist/src/policy/engine.d.ts.map +1 -1
- package/dist/src/policy/engine.js +117 -0
- package/dist/src/policy/engine.js.map +1 -1
- package/dist/src/saas/routes.d.ts.map +1 -1
- package/dist/src/saas/routes.js +355 -22
- package/dist/src/saas/routes.js.map +1 -1
- package/dist/src/server/app.d.ts.map +1 -1
- package/dist/src/server/app.js +24 -3
- package/dist/src/server/app.js.map +1 -1
- package/dist/src/server/gateway.d.ts.map +1 -1
- package/dist/src/server/gateway.js +17 -0
- package/dist/src/server/gateway.js.map +1 -1
- package/dist/src/server/index.d.ts.map +1 -1
- package/dist/src/server/index.js +18 -0
- package/dist/src/server/index.js.map +1 -1
- package/dist/src/storage/interfaces.d.ts +14 -3
- package/dist/src/storage/interfaces.d.ts.map +1 -1
- package/dist/src/storage/memory.d.ts +2 -0
- package/dist/src/storage/memory.d.ts.map +1 -1
- package/dist/src/storage/memory.js +6 -0
- package/dist/src/storage/memory.js.map +1 -1
- package/dist/src/storage/postgres.d.ts +5 -0
- package/dist/src/storage/postgres.d.ts.map +1 -1
- package/dist/src/storage/postgres.js +16 -0
- package/dist/src/storage/postgres.js.map +1 -1
- package/dist/src/storage/redis.d.ts +10 -0
- package/dist/src/storage/redis.d.ts.map +1 -1
- package/dist/src/storage/redis.js +65 -0
- package/dist/src/storage/redis.js.map +1 -1
- package/dist/src/types/budget.d.ts +4 -0
- package/dist/src/types/budget.d.ts.map +1 -1
- package/dist/src/types/config.d.ts +58 -0
- package/dist/src/types/config.d.ts.map +1 -1
- package/dist/src/types/events.d.ts +1 -0
- package/dist/src/types/events.d.ts.map +1 -1
- package/dist/src/types/policy.d.ts +11 -1
- package/dist/src/types/policy.d.ts.map +1 -1
- package/dist/src/types/tool-result.d.ts +11 -0
- package/dist/src/types/tool-result.d.ts.map +1 -1
- package/dist/tests/unit/app-routes.test.d.ts +2 -0
- package/dist/tests/unit/app-routes.test.d.ts.map +1 -0
- package/dist/tests/unit/app-routes.test.js +715 -0
- package/dist/tests/unit/app-routes.test.js.map +1 -0
- package/dist/tests/unit/audit-logger.test.js +105 -0
- package/dist/tests/unit/audit-logger.test.js.map +1 -1
- package/dist/tests/unit/auth-providers.test.d.ts +2 -0
- package/dist/tests/unit/auth-providers.test.d.ts.map +1 -0
- package/dist/tests/unit/auth-providers.test.js +279 -0
- package/dist/tests/unit/auth-providers.test.js.map +1 -0
- package/dist/tests/unit/auth-routes-extended.test.d.ts +2 -0
- package/dist/tests/unit/auth-routes-extended.test.d.ts.map +1 -0
- package/dist/tests/unit/auth-routes-extended.test.js +993 -0
- package/dist/tests/unit/auth-routes-extended.test.js.map +1 -0
- package/dist/tests/unit/auth-verifier.test.d.ts +2 -0
- package/dist/tests/unit/auth-verifier.test.d.ts.map +1 -0
- package/dist/tests/unit/auth-verifier.test.js +505 -0
- package/dist/tests/unit/auth-verifier.test.js.map +1 -0
- package/dist/tests/unit/billing-routes.test.d.ts +2 -0
- package/dist/tests/unit/billing-routes.test.d.ts.map +1 -0
- package/dist/tests/unit/billing-routes.test.js +432 -0
- package/dist/tests/unit/billing-routes.test.js.map +1 -0
- package/dist/tests/unit/config-defaults.test.d.ts +2 -0
- package/dist/tests/unit/config-defaults.test.d.ts.map +1 -0
- package/dist/tests/unit/config-defaults.test.js +119 -0
- package/dist/tests/unit/config-defaults.test.js.map +1 -0
- package/dist/tests/unit/defaults.test.js +0 -10
- package/dist/tests/unit/defaults.test.js.map +1 -1
- package/dist/tests/unit/filesystem-executor.test.d.ts +2 -0
- package/dist/tests/unit/filesystem-executor.test.d.ts.map +1 -0
- package/dist/tests/unit/filesystem-executor.test.js +280 -0
- package/dist/tests/unit/filesystem-executor.test.js.map +1 -0
- package/dist/tests/unit/gateway-branches.test.d.ts +2 -0
- package/dist/tests/unit/gateway-branches.test.d.ts.map +1 -0
- package/dist/tests/unit/gateway-branches.test.js +1039 -0
- package/dist/tests/unit/gateway-branches.test.js.map +1 -0
- package/dist/tests/unit/http-executor-branches.test.d.ts +2 -0
- package/dist/tests/unit/http-executor-branches.test.d.ts.map +1 -0
- package/dist/tests/unit/http-executor-branches.test.js +495 -0
- package/dist/tests/unit/http-executor-branches.test.js.map +1 -0
- package/dist/tests/unit/logger.test.d.ts +2 -0
- package/dist/tests/unit/logger.test.d.ts.map +1 -0
- package/dist/tests/unit/logger.test.js +97 -0
- package/dist/tests/unit/logger.test.js.map +1 -0
- package/dist/tests/unit/mcp-internal-auth.test.d.ts +2 -0
- package/dist/tests/unit/mcp-internal-auth.test.d.ts.map +1 -0
- package/dist/tests/unit/mcp-internal-auth.test.js +445 -0
- package/dist/tests/unit/mcp-internal-auth.test.js.map +1 -0
- package/dist/tests/unit/metrics.test.js +102 -0
- package/dist/tests/unit/metrics.test.js.map +1 -1
- package/dist/tests/unit/model-pricing.test.d.ts +2 -0
- package/dist/tests/unit/model-pricing.test.d.ts.map +1 -0
- package/dist/tests/unit/model-pricing.test.js +87 -0
- package/dist/tests/unit/model-pricing.test.js.map +1 -0
- package/dist/tests/unit/oauth-stores.test.d.ts +2 -0
- package/dist/tests/unit/oauth-stores.test.d.ts.map +1 -0
- package/dist/tests/unit/oauth-stores.test.js +260 -0
- package/dist/tests/unit/oauth-stores.test.js.map +1 -0
- package/dist/tests/unit/policy-engine.test.js +466 -0
- package/dist/tests/unit/policy-engine.test.js.map +1 -1
- package/dist/tests/unit/provider-interceptor.test.d.ts +2 -0
- package/dist/tests/unit/provider-interceptor.test.d.ts.map +1 -0
- package/dist/tests/unit/provider-interceptor.test.js +472 -0
- package/dist/tests/unit/provider-interceptor.test.js.map +1 -0
- package/dist/tests/unit/saas-routes-branches.test.d.ts +2 -0
- package/dist/tests/unit/saas-routes-branches.test.d.ts.map +1 -0
- package/dist/tests/unit/saas-routes-branches.test.js +2165 -0
- package/dist/tests/unit/saas-routes-branches.test.js.map +1 -0
- package/dist/tests/unit/saas-routes-crud.test.d.ts +2 -0
- package/dist/tests/unit/saas-routes-crud.test.d.ts.map +1 -0
- package/dist/tests/unit/saas-routes-crud.test.js +332 -0
- package/dist/tests/unit/saas-routes-crud.test.js.map +1 -0
- package/dist/tests/unit/saas-routes-data.test.d.ts +2 -0
- package/dist/tests/unit/saas-routes-data.test.d.ts.map +1 -0
- package/dist/tests/unit/saas-routes-data.test.js +405 -0
- package/dist/tests/unit/saas-routes-data.test.js.map +1 -0
- package/dist/tests/unit/saas-routes.test.js +3 -3
- package/dist/tests/unit/saas-routes.test.js.map +1 -1
- package/dist/tests/unit/shell-executor.test.d.ts +2 -0
- package/dist/tests/unit/shell-executor.test.d.ts.map +1 -0
- package/dist/tests/unit/shell-executor.test.js +145 -0
- package/dist/tests/unit/shell-executor.test.js.map +1 -0
- package/dist/tests/unit/sql-executor.test.d.ts +2 -0
- package/dist/tests/unit/sql-executor.test.d.ts.map +1 -0
- package/dist/tests/unit/sql-executor.test.js +177 -0
- package/dist/tests/unit/sql-executor.test.js.map +1 -0
- package/dist/tests/unit/stream-proxy.test.d.ts +2 -0
- package/dist/tests/unit/stream-proxy.test.d.ts.map +1 -0
- package/dist/tests/unit/stream-proxy.test.js +147 -0
- package/dist/tests/unit/stream-proxy.test.js.map +1 -0
- package/dist/tests/unit/tool-definitions.test.d.ts +2 -0
- package/dist/tests/unit/tool-definitions.test.d.ts.map +1 -0
- package/dist/tests/unit/tool-definitions.test.js +184 -0
- package/dist/tests/unit/tool-definitions.test.js.map +1 -0
- package/dist/tests/unit/usage-extractor.test.js +140 -0
- package/dist/tests/unit/usage-extractor.test.js.map +1 -1
- package/dist/tests/unit/webhook-handler.test.d.ts +2 -0
- package/dist/tests/unit/webhook-handler.test.d.ts.map +1 -0
- package/dist/tests/unit/webhook-handler.test.js +453 -0
- package/dist/tests/unit/webhook-handler.test.js.map +1 -0
- package/dist/tests/unit/webhook-routes.test.d.ts +2 -0
- package/dist/tests/unit/webhook-routes.test.d.ts.map +1 -0
- package/dist/tests/unit/webhook-routes.test.js +69 -0
- package/dist/tests/unit/webhook-routes.test.js.map +1 -0
- package/dist/tests/unit/websocket-executor.test.d.ts +2 -0
- package/dist/tests/unit/websocket-executor.test.d.ts.map +1 -0
- package/dist/tests/unit/websocket-executor.test.js +121 -0
- package/dist/tests/unit/websocket-executor.test.js.map +1 -0
- package/package.json +8 -2
- package/policy-packs/demo_fail.yaml +41 -0
- package/policy-packs/full_tools.yaml +136 -0
- package/src/admin/index.ts +1 -0
- package/src/admin/routes.ts +509 -0
- package/src/admin/templates.ts +572 -0
- package/src/anomaly/detector.ts +730 -0
- package/src/anomaly/index.ts +1 -0
- package/src/approval/manager.ts +569 -0
- package/src/approval/webhook.ts +133 -0
- package/src/audit/logger.ts +490 -0
- package/src/auth/index.ts +5 -0
- package/src/auth/password.ts +21 -0
- package/src/auth/pkce.ts +22 -0
- package/src/auth/providers.ts +208 -0
- package/src/auth/routes.ts +561 -0
- package/src/auth/session.ts +84 -0
- package/src/billing/index.ts +6 -0
- package/src/billing/plan-enforcer.ts +135 -0
- package/src/billing/routes.ts +229 -0
- package/src/billing/stripe-client.ts +58 -0
- package/src/billing/webhook-handler.ts +182 -0
- package/src/billing/webhook-routes.ts +28 -0
- package/src/budget/manager.ts +679 -0
- package/src/budget/model-pricing.ts +119 -0
- package/src/budget/usage-extractor.ts +214 -0
- package/src/cli.ts +91 -0
- package/src/config/defaults.ts +261 -0
- package/src/config/validate.ts +88 -0
- package/src/dlp/composite-scanner.ts +213 -0
- package/src/dlp/index.ts +9 -0
- package/src/dlp/interfaces.ts +34 -0
- package/src/dlp/patterns.ts +30 -0
- package/src/dlp/prompt-injection-backend.ts +181 -0
- package/src/dlp/prompt-injection-patterns.ts +302 -0
- package/src/dlp/regex-backend.ts +181 -0
- package/src/dlp/scanner.ts +502 -0
- package/src/dlp/text-normalizer.ts +225 -0
- package/src/dlp/tool-patterns.ts +35 -0
- package/src/dlp/trufflehog-backend.ts +190 -0
- package/src/executor/filesystem-executor.ts +196 -0
- package/src/executor/http-executor.ts +349 -0
- package/src/executor/index.ts +9 -0
- package/src/executor/interfaces.ts +11 -0
- package/src/executor/noop-executor.ts +23 -0
- package/src/executor/registry.ts +64 -0
- package/src/executor/shell-executor.ts +148 -0
- package/src/executor/slack-executor.ts +176 -0
- package/src/executor/sql-executor.ts +146 -0
- package/src/executor/websocket-executor.ts +211 -0
- package/src/index.ts +24 -0
- package/src/interceptor/index.ts +1 -0
- package/src/interceptor/provider-interceptor.ts +315 -0
- package/src/mcp/auth-verifier.ts +152 -0
- package/src/mcp/bridge.ts +703 -0
- package/src/mcp/http-transport.ts +698 -0
- package/src/mcp/index.ts +9 -0
- package/src/mcp/internal-auth.ts +14 -0
- package/src/mcp/oauth-pages.ts +139 -0
- package/src/mcp/oauth-postgres-stores.ts +278 -0
- package/src/mcp/oauth-provider.ts +536 -0
- package/src/mcp/oauth-stores.ts +202 -0
- package/src/mcp/server.ts +55 -0
- package/src/mcp/tool-definitions.ts +562 -0
- package/src/metrics/collector.ts +357 -0
- package/src/metrics/index.ts +1 -0
- package/src/middleware/auth.ts +814 -0
- package/src/middleware/session.ts +85 -0
- package/src/middleware/validate.ts +130 -0
- package/src/policy/engine.ts +815 -0
- package/src/policy/index.ts +2 -0
- package/src/policy/opa-engine.ts +829 -0
- package/src/proxy/forward-proxy.ts +649 -0
- package/src/proxy/index.ts +1 -0
- package/src/ratelimit/limiter.ts +196 -0
- package/src/replay/engine.ts +142 -0
- package/src/replay/index.ts +1 -0
- package/src/saas/index.ts +1 -0
- package/src/saas/routes.ts +2178 -0
- package/src/server/app.ts +985 -0
- package/src/server/errors.ts +49 -0
- package/src/server/gateway.ts +1130 -0
- package/src/server/index.ts +307 -0
- package/src/server/logger.ts +255 -0
- package/src/server/stream-proxy.ts +202 -0
- package/src/storage/file-persistence.ts +315 -0
- package/src/storage/index.ts +4 -0
- package/src/storage/interfaces.ts +287 -0
- package/src/storage/memory.ts +686 -0
- package/src/storage/postgres.ts +1831 -0
- package/src/storage/redis.ts +835 -0
- package/src/tracing/index.ts +1 -0
- package/src/tracing/provider.ts +100 -0
- package/src/trust/calculator.ts +141 -0
- package/src/trust/index.ts +7 -0
- package/src/types/budget.ts +36 -0
- package/src/types/config.ts +278 -0
- package/src/types/events.ts +41 -0
- package/src/types/express.d.ts +14 -0
- package/src/types/index.ts +7 -0
- package/src/types/policy.ts +83 -0
- package/src/types/stripe-config.ts +11 -0
- package/src/types/subscription.ts +59 -0
- package/src/types/tool-call.ts +47 -0
- package/src/types/tool-result.ts +82 -0
- package/src/types/user.ts +125 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export type PolicyDecision = 'allow' | 'deny' | 'transform' | 'require_approval';
|
|
2
|
+
|
|
3
|
+
export type PolicyEffect = 'ALLOW' | 'DENY' | 'TRANSFORM' | 'REQUIRE_APPROVAL';
|
|
4
|
+
|
|
5
|
+
export interface PolicyTransformation {
|
|
6
|
+
type: 'strip_header' | 'redact_field' | 'replace_value' | 'redact_sql_column' | 'sanitize_path' | 'mask_command_arg';
|
|
7
|
+
target: string;
|
|
8
|
+
value?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface PolicyRule {
|
|
12
|
+
name: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
effect: PolicyEffect;
|
|
15
|
+
priority?: number;
|
|
16
|
+
conditions: PolicyConditions;
|
|
17
|
+
transformations?: PolicyTransformation[];
|
|
18
|
+
approval?: {
|
|
19
|
+
scope: string;
|
|
20
|
+
ttl_seconds: number;
|
|
21
|
+
reason?: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface PolicyConditions {
|
|
26
|
+
tools?: string[];
|
|
27
|
+
tool_match?: string; // regex pattern
|
|
28
|
+
capabilities?: ('read' | 'write' | 'delete' | 'admin')[];
|
|
29
|
+
actors?: string[];
|
|
30
|
+
actor_types?: ('agent' | 'user' | 'system')[];
|
|
31
|
+
domains?: string[]; // for HTTP tool - allowed domains
|
|
32
|
+
domain_blocklist?: string[];
|
|
33
|
+
methods?: string[];
|
|
34
|
+
labels?: string[];
|
|
35
|
+
label_match?: string;
|
|
36
|
+
platforms?: string[];
|
|
37
|
+
workspace_ids?: string[];
|
|
38
|
+
// Filesystem conditions
|
|
39
|
+
file_paths?: string[]; // glob patterns to match (e.g., ['*.env', '/etc/**'])
|
|
40
|
+
file_paths_blocklist?: string[]; // glob patterns to block
|
|
41
|
+
file_extensions?: string[]; // file extensions to match (e.g., ['.env', '.key', '.pem'])
|
|
42
|
+
|
|
43
|
+
// SQL conditions
|
|
44
|
+
sql_tables?: string[]; // table names to match
|
|
45
|
+
sql_tables_blocklist?: string[]; // tables to block
|
|
46
|
+
sql_statements?: string[]; // statement types (e.g., ['SELECT', 'INSERT'])
|
|
47
|
+
|
|
48
|
+
// Shell conditions
|
|
49
|
+
shell_commands?: string[]; // allowed commands to match
|
|
50
|
+
shell_commands_blocklist?: string[]; // blocked commands
|
|
51
|
+
|
|
52
|
+
// Provider interception conditions
|
|
53
|
+
providers?: string[]; // provider names (e.g., ['claude', 'openai', 'gemini'])
|
|
54
|
+
provider_tool_types?: string[]; // tool types (e.g., ['computer_use', 'code_interpreter'])
|
|
55
|
+
|
|
56
|
+
/** DLP conditions — evaluated when DLP context is available (after DLP scan) */
|
|
57
|
+
dlp_severity?: string[]; // e.g., ['high', 'critical'] — match if DLP max severity is in this list
|
|
58
|
+
dlp_detected?: boolean; // true = rule matches only when DLP detections exist
|
|
59
|
+
dlp_pattern_names?: string[]; // match if any of these pattern names were detected
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface PolicyPack {
|
|
63
|
+
name: string;
|
|
64
|
+
version: string;
|
|
65
|
+
description?: string;
|
|
66
|
+
rules: PolicyRule[];
|
|
67
|
+
domain_allowlist?: string[];
|
|
68
|
+
domain_blocklist?: string[];
|
|
69
|
+
default_effect?: PolicyEffect;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface PolicyEvalResult {
|
|
73
|
+
decision: PolicyDecision;
|
|
74
|
+
rule_id: string;
|
|
75
|
+
rule_name: string;
|
|
76
|
+
reasons: string[];
|
|
77
|
+
transformations?: PolicyTransformation[];
|
|
78
|
+
approval?: {
|
|
79
|
+
scope: string;
|
|
80
|
+
ttl_seconds: number;
|
|
81
|
+
reason?: string;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export type PlanTier = 'free' | 'pro' | 'business' | 'enterprise';
|
|
2
|
+
|
|
3
|
+
export interface Subscription {
|
|
4
|
+
id: string;
|
|
5
|
+
workspace_id: string;
|
|
6
|
+
stripe_customer_id: string;
|
|
7
|
+
stripe_subscription_id?: string;
|
|
8
|
+
plan: PlanTier;
|
|
9
|
+
status: 'active' | 'past_due' | 'canceled' | 'trialing' | 'incomplete';
|
|
10
|
+
current_period_start?: string; // ISO
|
|
11
|
+
current_period_end?: string; // ISO
|
|
12
|
+
cancel_at_period_end?: boolean;
|
|
13
|
+
created_at: string; // ISO
|
|
14
|
+
updated_at: string; // ISO
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface PlanLimits {
|
|
18
|
+
calls_per_month: number;
|
|
19
|
+
workspaces: number;
|
|
20
|
+
members_per_workspace: number;
|
|
21
|
+
api_keys_per_workspace: number;
|
|
22
|
+
audit_retention_days: number;
|
|
23
|
+
features: string[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const PLAN_LIMITS: Record<PlanTier, PlanLimits> = {
|
|
27
|
+
free: {
|
|
28
|
+
calls_per_month: 10000,
|
|
29
|
+
workspaces: 1,
|
|
30
|
+
members_per_workspace: 3,
|
|
31
|
+
api_keys_per_workspace: 5,
|
|
32
|
+
audit_retention_days: 7,
|
|
33
|
+
features: ['basic_dlp', 'basic_policy'],
|
|
34
|
+
},
|
|
35
|
+
pro: {
|
|
36
|
+
calls_per_month: 100000,
|
|
37
|
+
workspaces: 5,
|
|
38
|
+
members_per_workspace: 10,
|
|
39
|
+
api_keys_per_workspace: 25,
|
|
40
|
+
audit_retention_days: 30,
|
|
41
|
+
features: ['basic_dlp', 'basic_policy', 'prompt_injection', 'anomaly_detection', 'custom_policies'],
|
|
42
|
+
},
|
|
43
|
+
business: {
|
|
44
|
+
calls_per_month: 1000000,
|
|
45
|
+
workspaces: 20,
|
|
46
|
+
members_per_workspace: 50,
|
|
47
|
+
api_keys_per_workspace: 100,
|
|
48
|
+
audit_retention_days: 90,
|
|
49
|
+
features: ['basic_dlp', 'basic_policy', 'prompt_injection', 'anomaly_detection', 'custom_policies', 'sso', 'advanced_dlp'],
|
|
50
|
+
},
|
|
51
|
+
enterprise: {
|
|
52
|
+
calls_per_month: Infinity,
|
|
53
|
+
workspaces: Infinity,
|
|
54
|
+
members_per_workspace: Infinity,
|
|
55
|
+
api_keys_per_workspace: Infinity,
|
|
56
|
+
audit_retention_days: 365,
|
|
57
|
+
features: ['basic_dlp', 'basic_policy', 'prompt_injection', 'anomaly_detection', 'custom_policies', 'sso', 'advanced_dlp', 'dedicated_support', 'custom_integrations'],
|
|
58
|
+
},
|
|
59
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface Actor {
|
|
2
|
+
type: 'agent' | 'user' | 'system';
|
|
3
|
+
id: string;
|
|
4
|
+
display?: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface Source {
|
|
8
|
+
platform: string;
|
|
9
|
+
session_id?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ToolInfo {
|
|
13
|
+
name: string;
|
|
14
|
+
version?: string;
|
|
15
|
+
capability: 'read' | 'write' | 'delete' | 'admin';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface ToolCallArgs {
|
|
19
|
+
method?: string;
|
|
20
|
+
url?: string;
|
|
21
|
+
headers?: Record<string, string>;
|
|
22
|
+
body?: unknown;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface Constraints {
|
|
27
|
+
max_cost_usd?: number;
|
|
28
|
+
timeout_ms?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface CallContext {
|
|
32
|
+
purpose?: string;
|
|
33
|
+
labels?: string[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ToolCall {
|
|
37
|
+
tool_call_id: string;
|
|
38
|
+
task_id: string;
|
|
39
|
+
workspace_id: string;
|
|
40
|
+
actor: Actor;
|
|
41
|
+
source: Source;
|
|
42
|
+
tool: ToolInfo;
|
|
43
|
+
args: ToolCallArgs;
|
|
44
|
+
constraints?: Constraints;
|
|
45
|
+
context?: CallContext;
|
|
46
|
+
timestamp?: string;
|
|
47
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { PolicyDecision } from './policy';
|
|
2
|
+
|
|
3
|
+
export type ToolResultStatus = 'ok' | 'blocked' | 'needs_approval' | 'error';
|
|
4
|
+
export type DLPSeverity = 'low' | 'medium' | 'high';
|
|
5
|
+
export type RedactionMethod = 'mask' | 'hash' | 'drop' | 'tokenize';
|
|
6
|
+
|
|
7
|
+
export interface DLPRedaction {
|
|
8
|
+
path: string;
|
|
9
|
+
method: RedactionMethod;
|
|
10
|
+
original_type?: string;
|
|
11
|
+
/** Masked preview of the matched value, e.g. "AKI***DEF" or "+1-5***234" */
|
|
12
|
+
masked_preview?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface DLPReport {
|
|
16
|
+
detected: string[];
|
|
17
|
+
redactions: DLPRedaction[];
|
|
18
|
+
severity: DLPSeverity;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface UsageData {
|
|
22
|
+
input_tokens?: number;
|
|
23
|
+
output_tokens?: number;
|
|
24
|
+
total_tokens?: number;
|
|
25
|
+
/** Anthropic: tokens written to cache (billed at 1.25x input price) */
|
|
26
|
+
cache_creation_tokens?: number;
|
|
27
|
+
/** Anthropic: tokens read from cache (billed at 0.1x input price) */
|
|
28
|
+
cache_read_tokens?: number;
|
|
29
|
+
/** OpenAI o1/o3: reasoning tokens (billed at output price) */
|
|
30
|
+
reasoning_tokens?: number;
|
|
31
|
+
provider_cost_usd?: number;
|
|
32
|
+
computed_cost_usd?: number;
|
|
33
|
+
source?: string;
|
|
34
|
+
model?: string;
|
|
35
|
+
provider?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface BudgetReport {
|
|
39
|
+
estimated_cost_usd: number;
|
|
40
|
+
spent_cost_usd_task: number;
|
|
41
|
+
remaining_cost_usd_task: number;
|
|
42
|
+
actual_cost_usd?: number;
|
|
43
|
+
usage?: UsageData;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ToolOutput {
|
|
47
|
+
// HTTP output fields
|
|
48
|
+
http_status?: number;
|
|
49
|
+
body?: unknown;
|
|
50
|
+
headers?: Record<string, string>;
|
|
51
|
+
// Filesystem executor: affected paths
|
|
52
|
+
paths?: string[];
|
|
53
|
+
// SQL executor: affected row count
|
|
54
|
+
rows_affected?: number;
|
|
55
|
+
// Shell executor: process exit code
|
|
56
|
+
exit_code?: number;
|
|
57
|
+
// Shell executor: stderr output
|
|
58
|
+
stderr?: string;
|
|
59
|
+
// Generic extensible metadata for any executor
|
|
60
|
+
metadata?: Record<string, unknown>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface TimingInfo {
|
|
64
|
+
started_at: string;
|
|
65
|
+
duration_ms: number;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface ToolResult {
|
|
69
|
+
tool_call_id: string;
|
|
70
|
+
task_id: string;
|
|
71
|
+
status: ToolResultStatus;
|
|
72
|
+
policy: {
|
|
73
|
+
decision: PolicyDecision;
|
|
74
|
+
rule_id?: string;
|
|
75
|
+
reasons: string[];
|
|
76
|
+
};
|
|
77
|
+
dlp: DLPReport;
|
|
78
|
+
budget: BudgetReport;
|
|
79
|
+
output?: ToolOutput;
|
|
80
|
+
error?: string;
|
|
81
|
+
timing: TimingInfo;
|
|
82
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// OAuth & SaaS Types
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
import { PlanTier } from './subscription';
|
|
6
|
+
|
|
7
|
+
export type OAuthProvider = 'google' | 'github';
|
|
8
|
+
|
|
9
|
+
export interface User {
|
|
10
|
+
id: string;
|
|
11
|
+
email: string;
|
|
12
|
+
display_name: string;
|
|
13
|
+
avatar_url?: string;
|
|
14
|
+
password_hash?: string;
|
|
15
|
+
status: 'active' | 'suspended' | 'deleted';
|
|
16
|
+
onboarding_completed: boolean;
|
|
17
|
+
created_at: string; // ISO
|
|
18
|
+
updated_at: string; // ISO
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface OAuthAccount {
|
|
22
|
+
id: string;
|
|
23
|
+
user_id: string;
|
|
24
|
+
provider: OAuthProvider;
|
|
25
|
+
provider_user_id: string;
|
|
26
|
+
provider_email: string;
|
|
27
|
+
access_token_encrypted?: string;
|
|
28
|
+
refresh_token_encrypted?: string;
|
|
29
|
+
token_expires_at?: string; // ISO
|
|
30
|
+
created_at: string; // ISO
|
|
31
|
+
updated_at: string; // ISO
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface Workspace {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
slug: string;
|
|
38
|
+
owner_user_id: string;
|
|
39
|
+
plan: PlanTier;
|
|
40
|
+
settings: Record<string, unknown>;
|
|
41
|
+
created_at: string; // ISO
|
|
42
|
+
updated_at: string; // ISO
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface WorkspaceMember {
|
|
46
|
+
id: string;
|
|
47
|
+
workspace_id: string;
|
|
48
|
+
user_id: string;
|
|
49
|
+
role: 'owner' | 'admin' | 'member' | 'viewer';
|
|
50
|
+
joined_at: string; // ISO
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface Session {
|
|
54
|
+
id: string;
|
|
55
|
+
user_id: string;
|
|
56
|
+
workspace_id?: string;
|
|
57
|
+
ip_address?: string;
|
|
58
|
+
user_agent?: string;
|
|
59
|
+
expires_at: string; // ISO
|
|
60
|
+
last_active_at: string; // ISO
|
|
61
|
+
created_at: string; // ISO
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface UserApiKey {
|
|
65
|
+
id: string;
|
|
66
|
+
key_hash: string; // Format: "salt:hash" (salted) or plain hex (legacy unsalted)
|
|
67
|
+
key_prefix: string; // First 8 chars for identification
|
|
68
|
+
user_id: string;
|
|
69
|
+
workspace_id: string;
|
|
70
|
+
name: string;
|
|
71
|
+
roles: string[];
|
|
72
|
+
tags: string[]; // Freeform labels, e.g. ["project:demo", "env:staging"]
|
|
73
|
+
revoked: boolean;
|
|
74
|
+
last_used_at?: string; // ISO
|
|
75
|
+
created_at: string; // ISO
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
// OAuth flow types
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
|
|
82
|
+
export interface OAuthProfile {
|
|
83
|
+
provider: OAuthProvider;
|
|
84
|
+
provider_user_id: string;
|
|
85
|
+
email: string;
|
|
86
|
+
display_name: string;
|
|
87
|
+
avatar_url?: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface OAuthFlowState {
|
|
91
|
+
provider: OAuthProvider;
|
|
92
|
+
code_verifier?: string; // PKCE (Google)
|
|
93
|
+
nonce: string;
|
|
94
|
+
redirect_uri: string;
|
|
95
|
+
created_at: number; // Unix ms
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
// OAuth configuration types
|
|
100
|
+
// ---------------------------------------------------------------------------
|
|
101
|
+
|
|
102
|
+
export interface GoogleOAuthProvider {
|
|
103
|
+
client_id: string;
|
|
104
|
+
client_secret: string;
|
|
105
|
+
redirect_uri?: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface GitHubOAuthProvider {
|
|
109
|
+
client_id: string;
|
|
110
|
+
client_secret: string;
|
|
111
|
+
redirect_uri?: string;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface OAuthConfig {
|
|
115
|
+
enabled: boolean;
|
|
116
|
+
session_secret: string;
|
|
117
|
+
session_ttl_seconds: number; // Default: 7 days (604800)
|
|
118
|
+
google?: GoogleOAuthProvider;
|
|
119
|
+
github?: GitHubOAuthProvider;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface FrontendConfig {
|
|
123
|
+
enabled: boolean;
|
|
124
|
+
build_path: string; // Path to built frontend assets (default: web/dist)
|
|
125
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"lib": ["ES2020"],
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": ".",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"declarationMap": true,
|
|
15
|
+
"sourceMap": true,
|
|
16
|
+
"moduleResolution": "node",
|
|
17
|
+
"paths": {
|
|
18
|
+
"@/*": ["./src/*"]
|
|
19
|
+
},
|
|
20
|
+
"baseUrl": "."
|
|
21
|
+
},
|
|
22
|
+
"include": ["src/**/*", "tests/**/*", "sdk/**/*"],
|
|
23
|
+
"exclude": ["node_modules", "dist", "tests/e2e"]
|
|
24
|
+
}
|