@adtl/gateway 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +146 -11
- package/dist/audit.d.ts +3 -1
- package/dist/audit.d.ts.map +1 -1
- package/dist/audit.js.map +1 -1
- package/dist/cedar.d.ts +27 -0
- package/dist/cedar.d.ts.map +1 -0
- package/dist/cedar.js +134 -0
- package/dist/cedar.js.map +1 -0
- package/dist/config.d.ts +235 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +54 -0
- package/dist/config.js.map +1 -1
- package/dist/gateway.d.ts +11 -5
- package/dist/gateway.d.ts.map +1 -1
- package/dist/gateway.js +23 -12
- package/dist/gateway.js.map +1 -1
- package/dist/hooks/agentLinks.d.ts +18 -0
- package/dist/hooks/agentLinks.d.ts.map +1 -0
- package/dist/hooks/agentLinks.js +48 -0
- package/dist/hooks/agentLinks.js.map +1 -0
- package/dist/hooks/claudeCode.d.ts +3 -0
- package/dist/hooks/claudeCode.d.ts.map +1 -1
- package/dist/hooks/claudeCode.js +27 -7
- package/dist/hooks/claudeCode.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/run.d.ts.map +1 -1
- package/dist/hooks/run.js +3 -1
- package/dist/hooks/run.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/init/suggest.d.ts +3 -1
- package/dist/init/suggest.d.ts.map +1 -1
- package/dist/init/suggest.js +8 -0
- package/dist/init/suggest.js.map +1 -1
- package/dist/invoker.d.ts +54 -6
- package/dist/invoker.d.ts.map +1 -1
- package/dist/invoker.js +115 -19
- package/dist/invoker.js.map +1 -1
- package/dist/startup.d.ts +15 -1
- package/dist/startup.d.ts.map +1 -1
- package/dist/startup.js +80 -7
- package/dist/startup.js.map +1 -1
- package/package.json +15 -4
- package/src/audit.ts +3 -1
- package/src/cedar.ts +140 -0
- package/src/config.ts +57 -0
- package/src/gateway.ts +26 -14
- package/src/hooks/agentLinks.ts +58 -0
- package/src/hooks/claudeCode.ts +31 -7
- package/src/hooks/index.ts +1 -0
- package/src/hooks/run.ts +3 -1
- package/src/index.ts +1 -0
- package/src/init/suggest.ts +10 -1
- package/src/invoker.ts +146 -21
- package/src/startup.ts +75 -8
package/dist/config.d.ts
CHANGED
|
@@ -12,10 +12,15 @@
|
|
|
12
12
|
* docs:
|
|
13
13
|
* url: https://example.com/mcp
|
|
14
14
|
* headers: { Authorization: "Bearer ${DOCS_TOKEN}" }
|
|
15
|
+
* interceptorServers: # optional: more interceptor servers, run beside ADTL's
|
|
16
|
+
* pii: { url: https://pii.example.com/mcp }
|
|
17
|
+
* interceptorOverrides: # optional: per-interceptor execution policy (SEP-2624)
|
|
18
|
+
* adtl.label: { timeoutMs: 10000 }
|
|
15
19
|
* principal: { id: "${USER}" } # optional: who runs this gateway (default: anonymous)
|
|
16
20
|
* roles: # optional: who may use which tools (deny by default)
|
|
17
21
|
* maintainers: { members: [alice], tools: ["github.*"] }
|
|
18
22
|
* readers: { members: ["*"], tools: ["github.read_*", "github.get_*"] }
|
|
23
|
+
* cedar: { policies: ./adtl.cedar } # optional: attribute-based rules (see cedar.ts)
|
|
19
24
|
* approvals: # optional: make "ask" really ask
|
|
20
25
|
* timeoutSeconds: 50
|
|
21
26
|
* ntfy: { topic: "${ADTL_NTFY_TOPIC}" }
|
|
@@ -367,6 +372,73 @@ export declare const RoleSchema: z.ZodEffects<z.ZodObject<{
|
|
|
367
372
|
resources?: string[] | undefined;
|
|
368
373
|
}>;
|
|
369
374
|
export type RoleConfig = z.infer<typeof RoleSchema>;
|
|
375
|
+
export declare const CedarConfigSchema: z.ZodObject<{
|
|
376
|
+
/** Cedar policy file. Relative paths are resolved against the config file's directory. */
|
|
377
|
+
policies: z.ZodString;
|
|
378
|
+
/** Optional Cedar entities JSON file: groups (`parents`) and attributes. */
|
|
379
|
+
entities: z.ZodOptional<z.ZodString>;
|
|
380
|
+
/** IANA time zone for `context.time`, e.g. "Europe/Berlin". Default: the gateway's. */
|
|
381
|
+
timeZone: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
382
|
+
}, "strict", z.ZodTypeAny, {
|
|
383
|
+
policies: string;
|
|
384
|
+
entities?: string | undefined;
|
|
385
|
+
timeZone?: string | undefined;
|
|
386
|
+
}, {
|
|
387
|
+
policies: string;
|
|
388
|
+
entities?: string | undefined;
|
|
389
|
+
timeZone?: string | undefined;
|
|
390
|
+
}>;
|
|
391
|
+
export type CedarConfig = z.infer<typeof CedarConfigSchema>;
|
|
392
|
+
/** SEP-2624 InterceptorOverrides, set by the gateway owner for one interceptor. */
|
|
393
|
+
export declare const InterceptorOverridesSchema: z.ZodObject<{
|
|
394
|
+
failOpen: z.ZodOptional<z.ZodBoolean>;
|
|
395
|
+
priorityHint: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodObject<{
|
|
396
|
+
request: z.ZodOptional<z.ZodNumber>;
|
|
397
|
+
response: z.ZodOptional<z.ZodNumber>;
|
|
398
|
+
}, "strict", z.ZodTypeAny, {
|
|
399
|
+
request?: number | undefined;
|
|
400
|
+
response?: number | undefined;
|
|
401
|
+
}, {
|
|
402
|
+
request?: number | undefined;
|
|
403
|
+
response?: number | undefined;
|
|
404
|
+
}>]>>;
|
|
405
|
+
mode: z.ZodOptional<z.ZodEnum<["active", "audit"]>>;
|
|
406
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
407
|
+
hooks: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
408
|
+
events: z.ZodArray<z.ZodString, "many">;
|
|
409
|
+
phase: z.ZodEnum<["request", "response"]>;
|
|
410
|
+
}, "strict", z.ZodTypeAny, {
|
|
411
|
+
events: string[];
|
|
412
|
+
phase: "request" | "response";
|
|
413
|
+
}, {
|
|
414
|
+
events: string[];
|
|
415
|
+
phase: "request" | "response";
|
|
416
|
+
}>, "many">>;
|
|
417
|
+
}, "strict", z.ZodTypeAny, {
|
|
418
|
+
mode?: "active" | "audit" | undefined;
|
|
419
|
+
priorityHint?: number | {
|
|
420
|
+
request?: number | undefined;
|
|
421
|
+
response?: number | undefined;
|
|
422
|
+
} | undefined;
|
|
423
|
+
failOpen?: boolean | undefined;
|
|
424
|
+
timeoutMs?: number | undefined;
|
|
425
|
+
hooks?: {
|
|
426
|
+
events: string[];
|
|
427
|
+
phase: "request" | "response";
|
|
428
|
+
}[] | undefined;
|
|
429
|
+
}, {
|
|
430
|
+
mode?: "active" | "audit" | undefined;
|
|
431
|
+
priorityHint?: number | {
|
|
432
|
+
request?: number | undefined;
|
|
433
|
+
response?: number | undefined;
|
|
434
|
+
} | undefined;
|
|
435
|
+
failOpen?: boolean | undefined;
|
|
436
|
+
timeoutMs?: number | undefined;
|
|
437
|
+
hooks?: {
|
|
438
|
+
events: string[];
|
|
439
|
+
phase: "request" | "response";
|
|
440
|
+
}[] | undefined;
|
|
441
|
+
}>;
|
|
370
442
|
export declare const GatewayConfigSchema: z.ZodObject<{
|
|
371
443
|
upstreams: z.ZodEffects<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
372
444
|
command: z.ZodString;
|
|
@@ -442,6 +514,48 @@ export declare const GatewayConfigSchema: z.ZodObject<{
|
|
|
442
514
|
env?: Record<string, string> | undefined;
|
|
443
515
|
cwd?: string | undefined;
|
|
444
516
|
}>>;
|
|
517
|
+
/** More interceptor servers (stdio or Streamable HTTP) whose interceptors run beside ADTL's. */
|
|
518
|
+
interceptorServers: z.ZodDefault<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
519
|
+
command: z.ZodString;
|
|
520
|
+
args: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
521
|
+
env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
522
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
523
|
+
}, "strict", z.ZodTypeAny, {
|
|
524
|
+
command: string;
|
|
525
|
+
args: string[];
|
|
526
|
+
env: Record<string, string>;
|
|
527
|
+
cwd?: string | undefined;
|
|
528
|
+
}, {
|
|
529
|
+
command: string;
|
|
530
|
+
args?: string[] | undefined;
|
|
531
|
+
env?: Record<string, string> | undefined;
|
|
532
|
+
cwd?: string | undefined;
|
|
533
|
+
}>, z.ZodObject<{
|
|
534
|
+
url: z.ZodString;
|
|
535
|
+
headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
536
|
+
}, "strict", z.ZodTypeAny, {
|
|
537
|
+
url: string;
|
|
538
|
+
headers: Record<string, string>;
|
|
539
|
+
}, {
|
|
540
|
+
url: string;
|
|
541
|
+
headers?: Record<string, string> | undefined;
|
|
542
|
+
}>]>>, Record<string, {
|
|
543
|
+
command: string;
|
|
544
|
+
args: string[];
|
|
545
|
+
env: Record<string, string>;
|
|
546
|
+
cwd?: string | undefined;
|
|
547
|
+
} | {
|
|
548
|
+
url: string;
|
|
549
|
+
headers: Record<string, string>;
|
|
550
|
+
}>, Record<string, {
|
|
551
|
+
command: string;
|
|
552
|
+
args?: string[] | undefined;
|
|
553
|
+
env?: Record<string, string> | undefined;
|
|
554
|
+
cwd?: string | undefined;
|
|
555
|
+
} | {
|
|
556
|
+
url: string;
|
|
557
|
+
headers?: Record<string, string> | undefined;
|
|
558
|
+
}>>>;
|
|
445
559
|
/** Path of a JSONL audit log. Relative paths are resolved against the config file's directory. */
|
|
446
560
|
audit: z.ZodOptional<z.ZodString>;
|
|
447
561
|
/**
|
|
@@ -625,6 +739,56 @@ export declare const GatewayConfigSchema: z.ZodObject<{
|
|
|
625
739
|
}>>;
|
|
626
740
|
/** Timeout for each interceptor invocation, in milliseconds. */
|
|
627
741
|
interceptorTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
742
|
+
/** Per-interceptor overrides of failOpen, priorityHint, mode, timeoutMs and hooks, by interceptor name. */
|
|
743
|
+
interceptorOverrides: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
744
|
+
failOpen: z.ZodOptional<z.ZodBoolean>;
|
|
745
|
+
priorityHint: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodObject<{
|
|
746
|
+
request: z.ZodOptional<z.ZodNumber>;
|
|
747
|
+
response: z.ZodOptional<z.ZodNumber>;
|
|
748
|
+
}, "strict", z.ZodTypeAny, {
|
|
749
|
+
request?: number | undefined;
|
|
750
|
+
response?: number | undefined;
|
|
751
|
+
}, {
|
|
752
|
+
request?: number | undefined;
|
|
753
|
+
response?: number | undefined;
|
|
754
|
+
}>]>>;
|
|
755
|
+
mode: z.ZodOptional<z.ZodEnum<["active", "audit"]>>;
|
|
756
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
757
|
+
hooks: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
758
|
+
events: z.ZodArray<z.ZodString, "many">;
|
|
759
|
+
phase: z.ZodEnum<["request", "response"]>;
|
|
760
|
+
}, "strict", z.ZodTypeAny, {
|
|
761
|
+
events: string[];
|
|
762
|
+
phase: "request" | "response";
|
|
763
|
+
}, {
|
|
764
|
+
events: string[];
|
|
765
|
+
phase: "request" | "response";
|
|
766
|
+
}>, "many">>;
|
|
767
|
+
}, "strict", z.ZodTypeAny, {
|
|
768
|
+
mode?: "active" | "audit" | undefined;
|
|
769
|
+
priorityHint?: number | {
|
|
770
|
+
request?: number | undefined;
|
|
771
|
+
response?: number | undefined;
|
|
772
|
+
} | undefined;
|
|
773
|
+
failOpen?: boolean | undefined;
|
|
774
|
+
timeoutMs?: number | undefined;
|
|
775
|
+
hooks?: {
|
|
776
|
+
events: string[];
|
|
777
|
+
phase: "request" | "response";
|
|
778
|
+
}[] | undefined;
|
|
779
|
+
}, {
|
|
780
|
+
mode?: "active" | "audit" | undefined;
|
|
781
|
+
priorityHint?: number | {
|
|
782
|
+
request?: number | undefined;
|
|
783
|
+
response?: number | undefined;
|
|
784
|
+
} | undefined;
|
|
785
|
+
failOpen?: boolean | undefined;
|
|
786
|
+
timeoutMs?: number | undefined;
|
|
787
|
+
hooks?: {
|
|
788
|
+
events: string[];
|
|
789
|
+
phase: "request" | "response";
|
|
790
|
+
}[] | undefined;
|
|
791
|
+
}>>>;
|
|
628
792
|
/** Who runs this gateway. Passed to the authorizer and the interceptors. Default: anonymous. */
|
|
629
793
|
principal: z.ZodOptional<z.ZodObject<{
|
|
630
794
|
type: z.ZodDefault<z.ZodEnum<["user", "service"]>>;
|
|
@@ -678,6 +842,23 @@ export declare const GatewayConfigSchema: z.ZodObject<{
|
|
|
678
842
|
prompts?: string[] | undefined;
|
|
679
843
|
resources?: string[] | undefined;
|
|
680
844
|
}>>>;
|
|
845
|
+
/** Cedar authorization. With roles as well, both must allow. */
|
|
846
|
+
cedar: z.ZodOptional<z.ZodObject<{
|
|
847
|
+
/** Cedar policy file. Relative paths are resolved against the config file's directory. */
|
|
848
|
+
policies: z.ZodString;
|
|
849
|
+
/** Optional Cedar entities JSON file: groups (`parents`) and attributes. */
|
|
850
|
+
entities: z.ZodOptional<z.ZodString>;
|
|
851
|
+
/** IANA time zone for `context.time`, e.g. "Europe/Berlin". Default: the gateway's. */
|
|
852
|
+
timeZone: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
853
|
+
}, "strict", z.ZodTypeAny, {
|
|
854
|
+
policies: string;
|
|
855
|
+
entities?: string | undefined;
|
|
856
|
+
timeZone?: string | undefined;
|
|
857
|
+
}, {
|
|
858
|
+
policies: string;
|
|
859
|
+
entities?: string | undefined;
|
|
860
|
+
timeZone?: string | undefined;
|
|
861
|
+
}>>;
|
|
681
862
|
}, "strict", z.ZodTypeAny, {
|
|
682
863
|
mode: "active" | "audit";
|
|
683
864
|
upstreams: Record<string, {
|
|
@@ -689,7 +870,29 @@ export declare const GatewayConfigSchema: z.ZodObject<{
|
|
|
689
870
|
url: string;
|
|
690
871
|
headers: Record<string, string>;
|
|
691
872
|
}>;
|
|
873
|
+
interceptorServers: Record<string, {
|
|
874
|
+
command: string;
|
|
875
|
+
args: string[];
|
|
876
|
+
env: Record<string, string>;
|
|
877
|
+
cwd?: string | undefined;
|
|
878
|
+
} | {
|
|
879
|
+
url: string;
|
|
880
|
+
headers: Record<string, string>;
|
|
881
|
+
}>;
|
|
692
882
|
interceptorTimeoutMs: number;
|
|
883
|
+
interceptorOverrides: Record<string, {
|
|
884
|
+
mode?: "active" | "audit" | undefined;
|
|
885
|
+
priorityHint?: number | {
|
|
886
|
+
request?: number | undefined;
|
|
887
|
+
response?: number | undefined;
|
|
888
|
+
} | undefined;
|
|
889
|
+
failOpen?: boolean | undefined;
|
|
890
|
+
timeoutMs?: number | undefined;
|
|
891
|
+
hooks?: {
|
|
892
|
+
events: string[];
|
|
893
|
+
phase: "request" | "response";
|
|
894
|
+
}[] | undefined;
|
|
895
|
+
}>;
|
|
693
896
|
audit?: string | undefined;
|
|
694
897
|
interceptors?: {
|
|
695
898
|
command: string;
|
|
@@ -738,6 +941,11 @@ export declare const GatewayConfigSchema: z.ZodObject<{
|
|
|
738
941
|
prompts: string[];
|
|
739
942
|
resources: string[];
|
|
740
943
|
}> | undefined;
|
|
944
|
+
cedar?: {
|
|
945
|
+
policies: string;
|
|
946
|
+
entities?: string | undefined;
|
|
947
|
+
timeZone?: string | undefined;
|
|
948
|
+
} | undefined;
|
|
741
949
|
}, {
|
|
742
950
|
upstreams: Record<string, {
|
|
743
951
|
command: string;
|
|
@@ -761,6 +969,15 @@ export declare const GatewayConfigSchema: z.ZodObject<{
|
|
|
761
969
|
type?: "user" | "service" | undefined;
|
|
762
970
|
claims?: Record<string, unknown> | undefined;
|
|
763
971
|
} | undefined;
|
|
972
|
+
interceptorServers?: Record<string, {
|
|
973
|
+
command: string;
|
|
974
|
+
args?: string[] | undefined;
|
|
975
|
+
env?: Record<string, string> | undefined;
|
|
976
|
+
cwd?: string | undefined;
|
|
977
|
+
} | {
|
|
978
|
+
url: string;
|
|
979
|
+
headers?: Record<string, string> | undefined;
|
|
980
|
+
}> | undefined;
|
|
764
981
|
approvals?: {
|
|
765
982
|
approvers?: Record<string, {
|
|
766
983
|
ntfy: {
|
|
@@ -792,12 +1009,30 @@ export declare const GatewayConfigSchema: z.ZodObject<{
|
|
|
792
1009
|
elicitation?: boolean | undefined;
|
|
793
1010
|
} | undefined;
|
|
794
1011
|
interceptorTimeoutMs?: number | undefined;
|
|
1012
|
+
interceptorOverrides?: Record<string, {
|
|
1013
|
+
mode?: "active" | "audit" | undefined;
|
|
1014
|
+
priorityHint?: number | {
|
|
1015
|
+
request?: number | undefined;
|
|
1016
|
+
response?: number | undefined;
|
|
1017
|
+
} | undefined;
|
|
1018
|
+
failOpen?: boolean | undefined;
|
|
1019
|
+
timeoutMs?: number | undefined;
|
|
1020
|
+
hooks?: {
|
|
1021
|
+
events: string[];
|
|
1022
|
+
phase: "request" | "response";
|
|
1023
|
+
}[] | undefined;
|
|
1024
|
+
}> | undefined;
|
|
795
1025
|
roles?: Record<string, {
|
|
796
1026
|
members: [string, ...string[]];
|
|
797
1027
|
tools?: string[] | undefined;
|
|
798
1028
|
prompts?: string[] | undefined;
|
|
799
1029
|
resources?: string[] | undefined;
|
|
800
1030
|
}> | undefined;
|
|
1031
|
+
cedar?: {
|
|
1032
|
+
policies: string;
|
|
1033
|
+
entities?: string | undefined;
|
|
1034
|
+
timeZone?: string | undefined;
|
|
1035
|
+
} | undefined;
|
|
801
1036
|
}>;
|
|
802
1037
|
export type GatewayConfig = z.infer<typeof GatewayConfigSchema>;
|
|
803
1038
|
export declare const TOOL_SEPARATOR = "__";
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot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
|
* headers: { Authorization: "Bearer ${DOCS_TOKEN}" }
|
|
15
|
+
* interceptorServers: # optional: more interceptor servers, run beside ADTL's
|
|
16
|
+
* pii: { url: https://pii.example.com/mcp }
|
|
17
|
+
* interceptorOverrides: # optional: per-interceptor execution policy (SEP-2624)
|
|
18
|
+
* adtl.label: { timeoutMs: 10000 }
|
|
15
19
|
* principal: { id: "${USER}" } # optional: who runs this gateway (default: anonymous)
|
|
16
20
|
* roles: # optional: who may use which tools (deny by default)
|
|
17
21
|
* maintainers: { members: [alice], tools: ["github.*"] }
|
|
18
22
|
* readers: { members: ["*"], tools: ["github.read_*", "github.get_*"] }
|
|
23
|
+
* cedar: { policies: ./adtl.cedar } # optional: attribute-based rules (see cedar.ts)
|
|
19
24
|
* approvals: # optional: make "ask" really ask
|
|
20
25
|
* timeoutSeconds: 50
|
|
21
26
|
* ntfy: { topic: "${ADTL_NTFY_TOPIC}" }
|
|
@@ -121,6 +126,44 @@ export const RoleSchema = z
|
|
|
121
126
|
.refine((r) => r.tools.length + r.prompts.length + r.resources.length > 0, {
|
|
122
127
|
message: "A role must grant at least one of tools, prompts or resources",
|
|
123
128
|
});
|
|
129
|
+
export const CedarConfigSchema = z
|
|
130
|
+
.object({
|
|
131
|
+
/** Cedar policy file. Relative paths are resolved against the config file's directory. */
|
|
132
|
+
policies: z.string().min(1),
|
|
133
|
+
/** Optional Cedar entities JSON file: groups (`parents`) and attributes. */
|
|
134
|
+
entities: z.string().min(1).optional(),
|
|
135
|
+
/** IANA time zone for `context.time`, e.g. "Europe/Berlin". Default: the gateway's. */
|
|
136
|
+
timeZone: z
|
|
137
|
+
.string()
|
|
138
|
+
.min(1)
|
|
139
|
+
.refine((tz) => {
|
|
140
|
+
try {
|
|
141
|
+
new Intl.DateTimeFormat("en-US", { timeZone: tz });
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
}, "Unknown time zone")
|
|
148
|
+
.optional(),
|
|
149
|
+
})
|
|
150
|
+
.strict();
|
|
151
|
+
const PhaseSchema = z.enum(["request", "response"]);
|
|
152
|
+
/** SEP-2624 InterceptorOverrides, set by the gateway owner for one interceptor. */
|
|
153
|
+
export const InterceptorOverridesSchema = z
|
|
154
|
+
.object({
|
|
155
|
+
failOpen: z.boolean().optional(),
|
|
156
|
+
priorityHint: z
|
|
157
|
+
.union([z.number().int(), z.object({ request: z.number().int().optional(), response: z.number().int().optional() }).strict()])
|
|
158
|
+
.optional(),
|
|
159
|
+
mode: z.enum(["active", "audit"]).optional(),
|
|
160
|
+
timeoutMs: z.number().int().positive().max(600_000).optional(),
|
|
161
|
+
hooks: z
|
|
162
|
+
.array(z.object({ events: z.array(z.string().min(1)).min(1), phase: PhaseSchema }).strict())
|
|
163
|
+
.min(1, "hooks: list at least one hook, or leave it out to keep the declared hooks")
|
|
164
|
+
.optional(),
|
|
165
|
+
})
|
|
166
|
+
.strict();
|
|
124
167
|
export const GatewayConfigSchema = z
|
|
125
168
|
.object({
|
|
126
169
|
upstreams: z
|
|
@@ -131,6 +174,13 @@ export const GatewayConfigSchema = z
|
|
|
131
174
|
}),
|
|
132
175
|
/** How to start the interceptor server. Default: the bundled adtl-interceptors with this same config file. */
|
|
133
176
|
interceptors: StdioUpstreamSchema.optional(),
|
|
177
|
+
/** More interceptor servers (stdio or Streamable HTTP) whose interceptors run beside ADTL's. */
|
|
178
|
+
interceptorServers: z
|
|
179
|
+
.record(UpstreamSchema)
|
|
180
|
+
.refine((u) => Object.keys(u).every((id) => UPSTREAM_ID.test(id)), {
|
|
181
|
+
message: "Interceptor server ids may only contain letters, digits and '-'",
|
|
182
|
+
})
|
|
183
|
+
.default({}),
|
|
134
184
|
/** Path of a JSONL audit log. Relative paths are resolved against the config file's directory. */
|
|
135
185
|
audit: z.string().min(1).optional(),
|
|
136
186
|
/**
|
|
@@ -142,6 +192,8 @@ export const GatewayConfigSchema = z
|
|
|
142
192
|
approvals: ApprovalsConfigSchema.optional(),
|
|
143
193
|
/** Timeout for each interceptor invocation, in milliseconds. */
|
|
144
194
|
interceptorTimeoutMs: z.number().int().positive().default(5000),
|
|
195
|
+
/** Per-interceptor overrides of failOpen, priorityHint, mode, timeoutMs and hooks, by interceptor name. */
|
|
196
|
+
interceptorOverrides: z.record(InterceptorOverridesSchema).default({}),
|
|
145
197
|
/** Who runs this gateway. Passed to the authorizer and the interceptors. Default: anonymous. */
|
|
146
198
|
principal: PrincipalConfigSchema.optional(),
|
|
147
199
|
/** Role-based authorization: when present, a call no role grants is denied. */
|
|
@@ -149,6 +201,8 @@ export const GatewayConfigSchema = z
|
|
|
149
201
|
.record(RoleSchema)
|
|
150
202
|
.refine((r) => Object.keys(r).length > 0, "roles: needs at least one role (remove it to allow everyone)")
|
|
151
203
|
.optional(),
|
|
204
|
+
/** Cedar authorization. With roles as well, both must allow. */
|
|
205
|
+
cedar: CedarConfigSchema.optional(),
|
|
152
206
|
})
|
|
153
207
|
.strict();
|
|
154
208
|
export const TOOL_SEPARATOR = "__";
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAEtC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC;KACjC,MAAM,CAAC;IACN,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAA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AAC;AACJ,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,eAAe,CAAC,CAAkB,EAAE,GAAsB;IACxE,MAAM,IAAI,GAAG,CAAC,CAAU,EAAE,KAAa,EAAW,EAAE;QAClD,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QAC3D,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;YAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACxE,IAAI,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5H,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;IACF,OAAO,IAAI,CAAC,CAAC,EAAE,mBAAmB,CAAoB,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,CAAW;IACxC,OAAO,KAAK,IAAI,CAAC,CAAC;AACpB,CAAC"}
|
package/dist/gateway.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { ApprovalBroker } from "./approvals.js";
|
|
|
5
5
|
import type { AuditSink } from "./audit.js";
|
|
6
6
|
import { type Authorizer, type Principal } from "./authorizer.js";
|
|
7
7
|
import type { InterceptorInvoker } from "./invoker.js";
|
|
8
|
-
export declare const GATEWAY_VERSION = "0.
|
|
8
|
+
export declare const GATEWAY_VERSION = "0.8.0";
|
|
9
9
|
/** `_meta` key on gateway-generated error results describing why a call was stopped. */
|
|
10
10
|
export declare const GATEWAY_DECISION_KEY = "adtl/gateway";
|
|
11
11
|
export interface GatewayLogger {
|
|
@@ -21,14 +21,19 @@ export interface AdtlGatewayOptions {
|
|
|
21
21
|
logger?: GatewayLogger;
|
|
22
22
|
/** Asks humans about "ask" decisions and sends notices. */
|
|
23
23
|
approvals?: ApprovalBroker;
|
|
24
|
-
/** Decides whether the caller may use a tool, resource or prompt at all, before the policy. */
|
|
25
|
-
authorizer?: Authorizer;
|
|
24
|
+
/** Decides whether the caller may use a tool, resource or prompt at all, before the policy. Several must all allow. */
|
|
25
|
+
authorizer?: Authorizer | Authorizer[];
|
|
26
26
|
/** The caller, passed to the authorizer and the interceptors. Default: anonymous. */
|
|
27
27
|
principal?: Principal;
|
|
28
28
|
/** Members of each role that policy rules name as `approvers:`. */
|
|
29
29
|
approverRoles?: Map<string, string[]>;
|
|
30
30
|
/** Also ask for approval in the MCP client, when it supports elicitation. */
|
|
31
31
|
elicitApprovals?: boolean;
|
|
32
|
+
/** The (sub-)agent this gateway serves, recorded on every audit entry. */
|
|
33
|
+
agent?: {
|
|
34
|
+
id: string;
|
|
35
|
+
type?: string;
|
|
36
|
+
};
|
|
32
37
|
}
|
|
33
38
|
/**
|
|
34
39
|
* Who may answer an "ask" whose rules name approver roles: someone in one of
|
|
@@ -46,8 +51,9 @@ export declare class AdtlGateway {
|
|
|
46
51
|
private readonly audit;
|
|
47
52
|
private readonly log;
|
|
48
53
|
private readonly approvals;
|
|
49
|
-
private readonly
|
|
54
|
+
private readonly authorizers;
|
|
50
55
|
private readonly principal;
|
|
56
|
+
private readonly agent;
|
|
51
57
|
private readonly approverRoles;
|
|
52
58
|
private readonly elicitApprovals;
|
|
53
59
|
/** The server the agent is connected to, for elicitation. */
|
|
@@ -58,7 +64,7 @@ export declare class AdtlGateway {
|
|
|
58
64
|
private resourceRoutes;
|
|
59
65
|
private templateRoutes;
|
|
60
66
|
constructor(opts: AdtlGatewayOptions);
|
|
61
|
-
/** Ask
|
|
67
|
+
/** Ask each authorizer in turn. Returns the first denial; in audit mode the caller logs it and carries on. */
|
|
62
68
|
private authorize;
|
|
63
69
|
/** The downstream MCP server the agent connects to. */
|
|
64
70
|
createServer(): Server;
|
package/dist/gateway.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAEnE,OAAO,EAUL,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,kBAAkB,EACvB,KAAK,QAAQ,EACb,KAAK,gBAAgB,EAErB,KAAK,IAAI,EACV,MAAM,oCAAoC,CAAC;AAG5C,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,gBAAgB,CAAC;AAErE,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAwC,KAAK,UAAU,EAAe,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAErH,OAAO,KAAK,EAAW,kBAAkB,EAAgC,MAAM,cAAc,CAAC;AAE9F,eAAO,MAAM,eAAe,UAAU,CAAC;AAEvC,wFAAwF;AACxF,eAAO,MAAM,oBAAoB,iBAAiB,CAAC;AAuBnD,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAOD,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,OAAO,EAAE,kBAAkB,CAAC;IAC5B,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EA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21
|
* unanswered or undeliverable calls are stopped. Without an approval channel,
|
|
22
22
|
* "ask" blocks.
|
|
23
23
|
*
|
|
24
|
-
*
|
|
25
|
-
* resource or prompt at all;
|
|
26
|
-
* The lists the agent sees leave out what
|
|
24
|
+
* Optional Authorizers decide first whether the caller may use the tool,
|
|
25
|
+
* resource or prompt at all; any denial stops the call before the policy runs.
|
|
26
|
+
* The lists the agent sees leave out what an authorizer would deny, so the
|
|
27
27
|
* agent doesn't try it; hiding is a convenience, and every call is still checked.
|
|
28
28
|
*
|
|
29
29
|
* In audit mode (the invoker runs every interceptor with `mode: "audit"`)
|
|
@@ -38,7 +38,7 @@ import { callBindingHash } from "@adtl/labels";
|
|
|
38
38
|
import { ElicitationChannel, supportsElicitation } from "./elicitation.js";
|
|
39
39
|
import { authorize } from "./authorizer.js";
|
|
40
40
|
import { TOOL_SEPARATOR } from "./config.js";
|
|
41
|
-
export const GATEWAY_VERSION = "0.
|
|
41
|
+
export const GATEWAY_VERSION = "0.8.0";
|
|
42
42
|
/** `_meta` key on gateway-generated error results describing why a call was stopped. */
|
|
43
43
|
export const GATEWAY_DECISION_KEY = "adtl/gateway";
|
|
44
44
|
const stderrLogger = {
|
|
@@ -87,8 +87,9 @@ export class AdtlGateway {
|
|
|
87
87
|
audit;
|
|
88
88
|
log;
|
|
89
89
|
approvals;
|
|
90
|
-
|
|
90
|
+
authorizers;
|
|
91
91
|
principal;
|
|
92
|
+
agent;
|
|
92
93
|
approverRoles;
|
|
93
94
|
elicitApprovals;
|
|
94
95
|
/** The server the agent is connected to, for elicitation. */
|
|
@@ -105,14 +106,20 @@ export class AdtlGateway {
|
|
|
105
106
|
this.audit = opts.audit;
|
|
106
107
|
this.log = opts.logger ?? stderrLogger;
|
|
107
108
|
this.approvals = opts.approvals;
|
|
108
|
-
this.
|
|
109
|
+
this.authorizers = opts.authorizer === undefined ? [] : [opts.authorizer].flat();
|
|
109
110
|
this.principal = opts.principal ?? { type: "anonymous" };
|
|
111
|
+
this.agent = opts.agent ? { agent: opts.agent } : {};
|
|
110
112
|
this.approverRoles = opts.approverRoles ?? new Map();
|
|
111
113
|
this.elicitApprovals = opts.elicitApprovals === true;
|
|
112
114
|
}
|
|
113
|
-
/** Ask
|
|
115
|
+
/** Ask each authorizer in turn. Returns the first denial; in audit mode the caller logs it and carries on. */
|
|
114
116
|
async authorize(request) {
|
|
115
|
-
|
|
117
|
+
for (const a of this.authorizers) {
|
|
118
|
+
const denied = await authorize(a, { principal: this.principal, ...request });
|
|
119
|
+
if (denied)
|
|
120
|
+
return denied;
|
|
121
|
+
}
|
|
122
|
+
return undefined;
|
|
116
123
|
}
|
|
117
124
|
/** The downstream MCP server the agent connects to. */
|
|
118
125
|
createServer() {
|
|
@@ -201,7 +208,7 @@ export class AdtlGateway {
|
|
|
201
208
|
* call: routes are kept, and a call to a hidden item is still authorized.
|
|
202
209
|
*/
|
|
203
210
|
async hideDenied(items, request) {
|
|
204
|
-
if (!this.
|
|
211
|
+
if (!this.authorizers.length || this.invoker.modeOverride === "audit")
|
|
205
212
|
return items;
|
|
206
213
|
const shown = await Promise.all(items.map(async (item) => {
|
|
207
214
|
const r = request(item);
|
|
@@ -327,6 +334,7 @@ export class AdtlGateway {
|
|
|
327
334
|
const finish = (entry) => this.audit?.write({
|
|
328
335
|
ts: context.timestamp,
|
|
329
336
|
sessionId: this.sessionId,
|
|
337
|
+
...this.agent,
|
|
330
338
|
event,
|
|
331
339
|
server: upstream,
|
|
332
340
|
...target,
|
|
@@ -376,7 +384,7 @@ export class AdtlGateway {
|
|
|
376
384
|
}
|
|
377
385
|
const label = infoOf(res, "adtl.label");
|
|
378
386
|
finish({ outcome: "forwarded", ...audit, label: label.label, ...(label.ledger ? { ledger: label.ledger } : {}),
|
|
379
|
-
...(label.records ? { records: label.records } : {}), sessionLabel: label.sessionLabel, warnings });
|
|
387
|
+
...(label.records ? { records: label.records } : {}), ...(label.recordIds ? { recordIds: label.recordIds } : {}), sessionLabel: label.sessionLabel, warnings });
|
|
380
388
|
return res.payload.result;
|
|
381
389
|
}
|
|
382
390
|
async callTool(name, args, opts = {}) {
|
|
@@ -399,7 +407,7 @@ export class AdtlGateway {
|
|
|
399
407
|
server: route.upstream,
|
|
400
408
|
...(route.annotations ? { toolAnnotations: route.annotations } : {}),
|
|
401
409
|
};
|
|
402
|
-
const base = { sessionId: this.sessionId, event: "tools/call", server: route.upstream, tool: route.tool };
|
|
410
|
+
const base = { sessionId: this.sessionId, ...this.agent, event: "tools/call", server: route.upstream, tool: route.tool };
|
|
403
411
|
let denied;
|
|
404
412
|
const ran = [];
|
|
405
413
|
const finish = (entry) => this.audit?.write({
|
|
@@ -500,7 +508,9 @@ export class AdtlGateway {
|
|
|
500
508
|
// 2. Forward to the upstream server.
|
|
501
509
|
let result;
|
|
502
510
|
try {
|
|
503
|
-
|
|
511
|
+
// A mutator may add request _meta (e.g. fides-gateway labels); pass it on.
|
|
512
|
+
const meta = forwarded._meta;
|
|
513
|
+
result = (await client.callTool({ name: forwarded.name, arguments: forwarded.arguments, ...(meta ? { _meta: meta } : {}) }));
|
|
504
514
|
}
|
|
505
515
|
catch (err) {
|
|
506
516
|
const reason = err.message;
|
|
@@ -533,6 +543,7 @@ export class AdtlGateway {
|
|
|
533
543
|
label: label.label,
|
|
534
544
|
...(label.ledger ? { ledger: label.ledger } : {}),
|
|
535
545
|
...(label.records ? { records: label.records } : {}),
|
|
546
|
+
...(label.recordIds ? { recordIds: label.recordIds } : {}),
|
|
536
547
|
sessionLabel: label.sessionLabel,
|
|
537
548
|
warnings: [...req.warnings, ...res.warnings],
|
|
538
549
|
});
|