@adtl/gateway 0.7.0 → 0.8.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.
Files changed (80) hide show
  1. package/README.md +143 -11
  2. package/dist/audit.d.ts +3 -1
  3. package/dist/audit.d.ts.map +1 -1
  4. package/dist/audit.js.map +1 -1
  5. package/dist/cli.js +10 -1
  6. package/dist/cli.js.map +1 -1
  7. package/dist/config.d.ts +167 -713
  8. package/dist/config.d.ts.map +1 -1
  9. package/dist/config.js +64 -7
  10. package/dist/config.js.map +1 -1
  11. package/dist/elicitation.d.ts +7 -1
  12. package/dist/elicitation.d.ts.map +1 -1
  13. package/dist/elicitation.js +21 -14
  14. package/dist/elicitation.js.map +1 -1
  15. package/dist/gateway.d.ts +11 -1
  16. package/dist/gateway.d.ts.map +1 -1
  17. package/dist/gateway.js +13 -5
  18. package/dist/gateway.js.map +1 -1
  19. package/dist/hooks/agentLinks.d.ts +18 -0
  20. package/dist/hooks/agentLinks.d.ts.map +1 -0
  21. package/dist/hooks/agentLinks.js +48 -0
  22. package/dist/hooks/agentLinks.js.map +1 -0
  23. package/dist/hooks/claudeCode.d.ts +4 -0
  24. package/dist/hooks/claudeCode.d.ts.map +1 -1
  25. package/dist/hooks/claudeCode.js +35 -8
  26. package/dist/hooks/claudeCode.js.map +1 -1
  27. package/dist/hooks/index.d.ts +1 -0
  28. package/dist/hooks/index.d.ts.map +1 -1
  29. package/dist/hooks/index.js +1 -0
  30. package/dist/hooks/index.js.map +1 -1
  31. package/dist/hooks/run.d.ts.map +1 -1
  32. package/dist/hooks/run.js +5 -2
  33. package/dist/hooks/run.js.map +1 -1
  34. package/dist/index.d.ts +3 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +3 -0
  37. package/dist/index.js.map +1 -1
  38. package/dist/init/suggest.d.ts +3 -1
  39. package/dist/init/suggest.d.ts.map +1 -1
  40. package/dist/init/suggest.js +8 -0
  41. package/dist/init/suggest.js.map +1 -1
  42. package/dist/invoker.d.ts +56 -6
  43. package/dist/invoker.d.ts.map +1 -1
  44. package/dist/invoker.js +121 -19
  45. package/dist/invoker.js.map +1 -1
  46. package/dist/openfga.d.ts +13 -0
  47. package/dist/openfga.d.ts.map +1 -0
  48. package/dist/openfga.js +101 -0
  49. package/dist/openfga.js.map +1 -0
  50. package/dist/startup.d.ts +10 -1
  51. package/dist/startup.d.ts.map +1 -1
  52. package/dist/startup.js +82 -11
  53. package/dist/startup.js.map +1 -1
  54. package/dist/totp.d.ts +42 -0
  55. package/dist/totp.d.ts.map +1 -0
  56. package/dist/totp.js +176 -0
  57. package/dist/totp.js.map +1 -0
  58. package/dist/totpCli.d.ts +11 -0
  59. package/dist/totpCli.d.ts.map +1 -0
  60. package/dist/totpCli.js +46 -0
  61. package/dist/totpCli.js.map +1 -0
  62. package/package.json +8 -7
  63. package/playground/server.mjs +13 -3
  64. package/src/audit.ts +3 -1
  65. package/src/cli.ts +10 -1
  66. package/src/config.ts +71 -7
  67. package/src/elicitation.ts +35 -17
  68. package/src/gateway.ts +18 -5
  69. package/src/hooks/agentLinks.ts +58 -0
  70. package/src/hooks/claudeCode.ts +40 -9
  71. package/src/hooks/index.ts +1 -0
  72. package/src/hooks/run.ts +5 -2
  73. package/src/index.ts +3 -0
  74. package/src/init/suggest.ts +10 -1
  75. package/src/invoker.ts +153 -21
  76. package/src/openfga.ts +101 -0
  77. package/src/startup.ts +79 -11
  78. package/src/totp.ts +191 -0
  79. package/src/totpCli.ts +52 -0
  80. package/src/types/qrcode-terminal.d.ts +4 -0
package/dist/config.d.ts CHANGED
@@ -12,11 +12,16 @@
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_*"] }
19
23
  * cedar: { policies: ./adtl.cedar } # optional: attribute-based rules (see cedar.ts)
24
+ * openfga: { url: http://localhost:8080, storeId: "${FGA_STORE_ID}" } # optional: relationship rules (see openfga.ts)
20
25
  * approvals: # optional: make "ask" really ask
21
26
  * timeoutSeconds: 50
22
27
  * ntfy: { topic: "${ADTL_NTFY_TOPIC}" }
@@ -27,823 +32,272 @@
27
32
  * from: adtl@example.com
28
33
  * to: you@example.com
29
34
  *
30
- * `${VAR}` in command, args, env, cwd, url, headers, approval settings and principal.id is
35
+ * `${VAR}` in command, args, env, cwd, url, headers, approval settings, openfga settings and principal.id is
31
36
  * replaced from the gateway's environment. A missing variable is a config error,
32
37
  * unless a default is given: `${VAR:-default}`.
33
38
  */
34
39
  import { z } from "zod";
35
40
  export declare const StdioUpstreamSchema: z.ZodObject<{
36
41
  command: z.ZodString;
37
- args: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
42
+ args: z.ZodDefault<z.ZodArray<z.ZodString>>;
38
43
  env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
39
44
  cwd: z.ZodOptional<z.ZodString>;
40
- }, "strict", z.ZodTypeAny, {
41
- command: string;
42
- args: string[];
43
- env: Record<string, string>;
44
- cwd?: string | undefined;
45
- }, {
46
- command: string;
47
- args?: string[] | undefined;
48
- env?: Record<string, string> | undefined;
49
- cwd?: string | undefined;
50
- }>;
45
+ }, z.core.$strict>;
51
46
  export declare const HttpUpstreamSchema: z.ZodObject<{
52
47
  url: z.ZodString;
53
48
  headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
54
- }, "strict", z.ZodTypeAny, {
55
- url: string;
56
- headers: Record<string, string>;
57
- }, {
58
- url: string;
59
- headers?: Record<string, string> | undefined;
60
- }>;
61
- export declare const UpstreamSchema: z.ZodUnion<[z.ZodObject<{
49
+ }, z.core.$strict>;
50
+ export declare const UpstreamSchema: z.ZodUnion<readonly [z.ZodObject<{
62
51
  command: z.ZodString;
63
- args: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
52
+ args: z.ZodDefault<z.ZodArray<z.ZodString>>;
64
53
  env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
65
54
  cwd: z.ZodOptional<z.ZodString>;
66
- }, "strict", z.ZodTypeAny, {
67
- command: string;
68
- args: string[];
69
- env: Record<string, string>;
70
- cwd?: string | undefined;
71
- }, {
72
- command: string;
73
- args?: string[] | undefined;
74
- env?: Record<string, string> | undefined;
75
- cwd?: string | undefined;
76
- }>, z.ZodObject<{
55
+ }, z.core.$strict>, z.ZodObject<{
77
56
  url: z.ZodString;
78
57
  headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
79
- }, "strict", z.ZodTypeAny, {
80
- url: string;
81
- headers: Record<string, string>;
82
- }, {
83
- url: string;
84
- headers?: Record<string, string> | undefined;
85
- }>]>;
58
+ }, z.core.$strict>]>;
86
59
  export type StdioUpstream = z.infer<typeof StdioUpstreamSchema>;
87
60
  export type HttpUpstream = z.infer<typeof HttpUpstreamSchema>;
88
61
  export type Upstream = z.infer<typeof UpstreamSchema>;
89
62
  export declare const NtfyConfigSchema: z.ZodObject<{
90
63
  server: z.ZodDefault<z.ZodString>;
91
- /** Topic approval requests are sent to. Anyone who can read it can approve: keep it secret. */
92
64
  topic: z.ZodString;
93
- /** Topic answers are posted to. Default: `<topic>-reply`. */
94
65
  replyTopic: z.ZodOptional<z.ZodString>;
95
66
  token: z.ZodOptional<z.ZodString>;
96
- }, "strict", z.ZodTypeAny, {
97
- server: string;
98
- topic: string;
99
- replyTopic?: string | undefined;
100
- token?: string | undefined;
101
- }, {
102
- topic: string;
103
- server?: string | undefined;
104
- replyTopic?: string | undefined;
105
- token?: string | undefined;
106
- }>;
67
+ }, z.core.$strict>;
107
68
  export declare const EmailConfigSchema: z.ZodObject<{
108
69
  smtp: z.ZodObject<{
109
70
  host: z.ZodString;
110
71
  port: z.ZodDefault<z.ZodNumber>;
111
- /** TLS from the start. Default: true on port 465, otherwise STARTTLS. */
112
72
  secure: z.ZodOptional<z.ZodBoolean>;
113
73
  user: z.ZodOptional<z.ZodString>;
114
74
  pass: z.ZodOptional<z.ZodString>;
115
- }, "strict", z.ZodTypeAny, {
116
- host: string;
117
- port: number;
118
- user?: string | undefined;
119
- secure?: boolean | undefined;
120
- pass?: string | undefined;
121
- }, {
122
- host: string;
123
- user?: string | undefined;
124
- port?: number | undefined;
125
- secure?: boolean | undefined;
126
- pass?: string | undefined;
127
- }>;
75
+ }, z.core.$strict>;
128
76
  from: z.ZodString;
129
- to: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "atleastone">]>;
130
- on: z.ZodDefault<z.ZodArray<z.ZodEnum<["pending", "blocked", "approved", "denied", "timeout", "undeliverable"]>, "atleastone">>;
131
- }, "strict", z.ZodTypeAny, {
132
- on: ["approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked", ...("approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked")[]];
133
- smtp: {
134
- host: string;
135
- port: number;
136
- user?: string | undefined;
137
- secure?: boolean | undefined;
138
- pass?: string | undefined;
139
- };
140
- from: string;
141
- to: string | [string, ...string[]];
142
- }, {
143
- smtp: {
144
- host: string;
145
- user?: string | undefined;
146
- port?: number | undefined;
147
- secure?: boolean | undefined;
148
- pass?: string | undefined;
149
- };
150
- from: string;
151
- to: string | [string, ...string[]];
152
- on?: ["approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked", ...("approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked")[]] | undefined;
153
- }>;
77
+ to: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
78
+ on: z.ZodDefault<z.ZodArray<z.ZodEnum<{
79
+ approved: "approved";
80
+ denied: "denied";
81
+ timeout: "timeout";
82
+ undeliverable: "undeliverable";
83
+ pending: "pending";
84
+ blocked: "blocked";
85
+ }>>>;
86
+ }, z.core.$strict>;
154
87
  export declare const ApprovalsConfigSchema: z.ZodObject<{
155
- /**
156
- * How long a call waits for an answer; no answer means deny. Many MCP
157
- * clients give up on a request after 60 seconds, hence the default.
158
- */
159
88
  timeoutSeconds: z.ZodDefault<z.ZodNumber>;
160
89
  ntfy: z.ZodOptional<z.ZodObject<{
161
90
  server: z.ZodDefault<z.ZodString>;
162
- /** Topic approval requests are sent to. Anyone who can read it can approve: keep it secret. */
163
91
  topic: z.ZodString;
164
- /** Topic answers are posted to. Default: `<topic>-reply`. */
165
92
  replyTopic: z.ZodOptional<z.ZodString>;
166
93
  token: z.ZodOptional<z.ZodString>;
167
- }, "strict", z.ZodTypeAny, {
168
- server: string;
169
- topic: string;
170
- replyTopic?: string | undefined;
171
- token?: string | undefined;
172
- }, {
173
- topic: string;
174
- server?: string | undefined;
175
- replyTopic?: string | undefined;
176
- token?: string | undefined;
177
- }>>;
94
+ }, z.core.$strict>>;
178
95
  email: z.ZodOptional<z.ZodObject<{
179
96
  smtp: z.ZodObject<{
180
97
  host: z.ZodString;
181
98
  port: z.ZodDefault<z.ZodNumber>;
182
- /** TLS from the start. Default: true on port 465, otherwise STARTTLS. */
183
99
  secure: z.ZodOptional<z.ZodBoolean>;
184
100
  user: z.ZodOptional<z.ZodString>;
185
101
  pass: z.ZodOptional<z.ZodString>;
186
- }, "strict", z.ZodTypeAny, {
187
- host: string;
188
- port: number;
189
- user?: string | undefined;
190
- secure?: boolean | undefined;
191
- pass?: string | undefined;
192
- }, {
193
- host: string;
194
- user?: string | undefined;
195
- port?: number | undefined;
196
- secure?: boolean | undefined;
197
- pass?: string | undefined;
198
- }>;
102
+ }, z.core.$strict>;
199
103
  from: z.ZodString;
200
- to: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "atleastone">]>;
201
- on: z.ZodDefault<z.ZodArray<z.ZodEnum<["pending", "blocked", "approved", "denied", "timeout", "undeliverable"]>, "atleastone">>;
202
- }, "strict", z.ZodTypeAny, {
203
- on: ["approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked", ...("approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked")[]];
204
- smtp: {
205
- host: string;
206
- port: number;
207
- user?: string | undefined;
208
- secure?: boolean | undefined;
209
- pass?: string | undefined;
210
- };
211
- from: string;
212
- to: string | [string, ...string[]];
213
- }, {
214
- smtp: {
215
- host: string;
216
- user?: string | undefined;
217
- port?: number | undefined;
218
- secure?: boolean | undefined;
219
- pass?: string | undefined;
220
- };
221
- from: string;
222
- to: string | [string, ...string[]];
223
- on?: ["approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked", ...("approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked")[]] | undefined;
224
- }>>;
225
- /**
226
- * Also ask in the MCP client (elicitation), when it supports it. Off by
227
- * default: a client that accepts elicitations by itself would approve calls.
228
- */
104
+ to: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
105
+ on: z.ZodDefault<z.ZodArray<z.ZodEnum<{
106
+ approved: "approved";
107
+ denied: "denied";
108
+ timeout: "timeout";
109
+ undeliverable: "undeliverable";
110
+ pending: "pending";
111
+ blocked: "blocked";
112
+ }>>>;
113
+ }, z.core.$strict>>;
229
114
  elicitation: z.ZodDefault<z.ZodBoolean>;
230
- /**
231
- * Each approver's own channel, by principal id. Policy rules with
232
- * `approvers: [role]` ask only these people, so the answer names who approved.
233
- */
115
+ totp: z.ZodDefault<z.ZodBoolean>;
234
116
  approvers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
235
117
  ntfy: z.ZodObject<{
236
118
  server: z.ZodDefault<z.ZodString>;
237
- /** Topic approval requests are sent to. Anyone who can read it can approve: keep it secret. */
238
119
  topic: z.ZodString;
239
- /** Topic answers are posted to. Default: `<topic>-reply`. */
240
120
  replyTopic: z.ZodOptional<z.ZodString>;
241
121
  token: z.ZodOptional<z.ZodString>;
242
- }, "strict", z.ZodTypeAny, {
243
- server: string;
244
- topic: string;
245
- replyTopic?: string | undefined;
246
- token?: string | undefined;
247
- }, {
248
- topic: string;
249
- server?: string | undefined;
250
- replyTopic?: string | undefined;
251
- token?: string | undefined;
252
- }>;
253
- }, "strict", z.ZodTypeAny, {
254
- ntfy: {
255
- server: string;
256
- topic: string;
257
- replyTopic?: string | undefined;
258
- token?: string | undefined;
259
- };
260
- }, {
261
- ntfy: {
262
- topic: string;
263
- server?: string | undefined;
264
- replyTopic?: string | undefined;
265
- token?: string | undefined;
266
- };
267
- }>>>;
268
- }, "strict", z.ZodTypeAny, {
269
- timeoutSeconds: number;
270
- elicitation: boolean;
271
- approvers?: Record<string, {
272
- ntfy: {
273
- server: string;
274
- topic: string;
275
- replyTopic?: string | undefined;
276
- token?: string | undefined;
277
- };
278
- }> | undefined;
279
- email?: {
280
- on: ["approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked", ...("approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked")[]];
281
- smtp: {
282
- host: string;
283
- port: number;
284
- user?: string | undefined;
285
- secure?: boolean | undefined;
286
- pass?: string | undefined;
287
- };
288
- from: string;
289
- to: string | [string, ...string[]];
290
- } | undefined;
291
- ntfy?: {
292
- server: string;
293
- topic: string;
294
- replyTopic?: string | undefined;
295
- token?: string | undefined;
296
- } | undefined;
297
- }, {
298
- approvers?: Record<string, {
299
- ntfy: {
300
- topic: string;
301
- server?: string | undefined;
302
- replyTopic?: string | undefined;
303
- token?: string | undefined;
304
- };
305
- }> | undefined;
306
- email?: {
307
- smtp: {
308
- host: string;
309
- user?: string | undefined;
310
- port?: number | undefined;
311
- secure?: boolean | undefined;
312
- pass?: string | undefined;
313
- };
314
- from: string;
315
- to: string | [string, ...string[]];
316
- on?: ["approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked", ...("approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked")[]] | undefined;
317
- } | undefined;
318
- timeoutSeconds?: number | undefined;
319
- ntfy?: {
320
- topic: string;
321
- server?: string | undefined;
322
- replyTopic?: string | undefined;
323
- token?: string | undefined;
324
- } | undefined;
325
- elicitation?: boolean | undefined;
326
- }>;
122
+ }, z.core.$strict>;
123
+ }, z.core.$strict>>>;
124
+ }, z.core.$strict>;
327
125
  export type ApprovalsConfig = z.infer<typeof ApprovalsConfigSchema>;
328
126
  export declare const PrincipalConfigSchema: z.ZodObject<{
329
- type: z.ZodDefault<z.ZodEnum<["user", "service"]>>;
127
+ type: z.ZodDefault<z.ZodEnum<{
128
+ user: "user";
129
+ service: "service";
130
+ }>>;
330
131
  id: z.ZodString;
331
132
  claims: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
332
- }, "strict", z.ZodTypeAny, {
333
- id: string;
334
- type: "user" | "service";
335
- claims?: Record<string, unknown> | undefined;
336
- }, {
337
- id: string;
338
- type?: "user" | "service" | undefined;
339
- claims?: Record<string, unknown> | undefined;
340
- }>;
133
+ }, z.core.$strict>;
341
134
  export type PrincipalConfig = z.infer<typeof PrincipalConfigSchema>;
342
- export declare const RoleSchema: z.ZodEffects<z.ZodObject<{
343
- /** Principal ids; "*" means everyone, including an anonymous caller. */
344
- members: z.ZodArray<z.ZodString, "atleastone">;
345
- tools: z.ZodDefault<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
346
- prompts: z.ZodDefault<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
347
- /** Resource URI patterns, e.g. "github://acme/*". */
348
- resources: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
349
- }, "strict", z.ZodTypeAny, {
350
- members: [string, ...string[]];
351
- tools: string[];
352
- prompts: string[];
353
- resources: string[];
354
- }, {
355
- members: [string, ...string[]];
356
- tools?: string[] | undefined;
357
- prompts?: string[] | undefined;
358
- resources?: string[] | undefined;
359
- }>, {
360
- members: [string, ...string[]];
361
- tools: string[];
362
- prompts: string[];
363
- resources: string[];
364
- }, {
365
- members: [string, ...string[]];
366
- tools?: string[] | undefined;
367
- prompts?: string[] | undefined;
368
- resources?: string[] | undefined;
369
- }>;
135
+ export declare const RoleSchema: z.ZodObject<{
136
+ members: z.ZodArray<z.ZodString>;
137
+ tools: z.ZodDefault<z.ZodArray<z.ZodString>>;
138
+ prompts: z.ZodDefault<z.ZodArray<z.ZodString>>;
139
+ resources: z.ZodDefault<z.ZodArray<z.ZodString>>;
140
+ }, z.core.$strict>;
370
141
  export type RoleConfig = z.infer<typeof RoleSchema>;
371
142
  export declare const CedarConfigSchema: z.ZodObject<{
372
- /** Cedar policy file. Relative paths are resolved against the config file's directory. */
373
143
  policies: z.ZodString;
374
- /** Optional Cedar entities JSON file: groups (`parents`) and attributes. */
375
144
  entities: z.ZodOptional<z.ZodString>;
376
- /** IANA time zone for `context.time`, e.g. "Europe/Berlin". Default: the gateway's. */
377
- timeZone: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
378
- }, "strict", z.ZodTypeAny, {
379
- policies: string;
380
- entities?: string | undefined;
381
- timeZone?: string | undefined;
382
- }, {
383
- policies: string;
384
- entities?: string | undefined;
385
- timeZone?: string | undefined;
386
- }>;
145
+ timeZone: z.ZodOptional<z.ZodString>;
146
+ }, z.core.$strict>;
387
147
  export type CedarConfig = z.infer<typeof CedarConfigSchema>;
148
+ export declare const OpenFgaConfigSchema: z.ZodObject<{
149
+ url: z.ZodString;
150
+ storeId: z.ZodString;
151
+ modelId: z.ZodOptional<z.ZodString>;
152
+ token: z.ZodOptional<z.ZodString>;
153
+ relation: z.ZodDefault<z.ZodString>;
154
+ timeoutMs: z.ZodDefault<z.ZodNumber>;
155
+ tools: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
156
+ relation: z.ZodOptional<z.ZodString>;
157
+ object: z.ZodOptional<z.ZodString>;
158
+ }, z.core.$strict>>>;
159
+ }, z.core.$strict>;
160
+ export type OpenFgaConfig = z.infer<typeof OpenFgaConfigSchema>;
161
+ /** SEP-2624 InterceptorOverrides, set by the gateway owner for one interceptor. */
162
+ export declare const InterceptorOverridesSchema: z.ZodObject<{
163
+ failOpen: z.ZodOptional<z.ZodBoolean>;
164
+ priorityHint: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
165
+ request: z.ZodOptional<z.ZodNumber>;
166
+ response: z.ZodOptional<z.ZodNumber>;
167
+ }, z.core.$strict>]>>;
168
+ mode: z.ZodOptional<z.ZodEnum<{
169
+ active: "active";
170
+ audit: "audit";
171
+ }>>;
172
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
173
+ hooks: z.ZodOptional<z.ZodArray<z.ZodObject<{
174
+ events: z.ZodArray<z.ZodString>;
175
+ phase: z.ZodEnum<{
176
+ request: "request";
177
+ response: "response";
178
+ }>;
179
+ }, z.core.$strict>>>;
180
+ }, z.core.$strict>;
388
181
  export declare const GatewayConfigSchema: z.ZodObject<{
389
- upstreams: z.ZodEffects<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
182
+ upstreams: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
390
183
  command: z.ZodString;
391
- args: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
184
+ args: z.ZodDefault<z.ZodArray<z.ZodString>>;
392
185
  env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
393
186
  cwd: z.ZodOptional<z.ZodString>;
394
- }, "strict", z.ZodTypeAny, {
395
- command: string;
396
- args: string[];
397
- env: Record<string, string>;
398
- cwd?: string | undefined;
399
- }, {
400
- command: string;
401
- args?: string[] | undefined;
402
- env?: Record<string, string> | undefined;
403
- cwd?: string | undefined;
404
- }>, z.ZodObject<{
187
+ }, z.core.$strict>, z.ZodObject<{
405
188
  url: z.ZodString;
406
189
  headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
407
- }, "strict", z.ZodTypeAny, {
408
- url: string;
409
- headers: Record<string, string>;
410
- }, {
411
- url: string;
412
- headers?: Record<string, string> | undefined;
413
- }>]>>, Record<string, {
414
- command: string;
415
- args: string[];
416
- env: Record<string, string>;
417
- cwd?: string | undefined;
418
- } | {
419
- url: string;
420
- headers: Record<string, string>;
421
- }>, Record<string, {
422
- command: string;
423
- args?: string[] | undefined;
424
- env?: Record<string, string> | undefined;
425
- cwd?: string | undefined;
426
- } | {
427
- url: string;
428
- headers?: Record<string, string> | undefined;
429
- }>>, Record<string, {
430
- command: string;
431
- args: string[];
432
- env: Record<string, string>;
433
- cwd?: string | undefined;
434
- } | {
435
- url: string;
436
- headers: Record<string, string>;
437
- }>, Record<string, {
438
- command: string;
439
- args?: string[] | undefined;
440
- env?: Record<string, string> | undefined;
441
- cwd?: string | undefined;
442
- } | {
443
- url: string;
444
- headers?: Record<string, string> | undefined;
445
- }>>;
446
- /** How to start the interceptor server. Default: the bundled adtl-interceptors with this same config file. */
190
+ }, z.core.$strict>]>>;
447
191
  interceptors: z.ZodOptional<z.ZodObject<{
448
192
  command: z.ZodString;
449
- args: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
193
+ args: z.ZodDefault<z.ZodArray<z.ZodString>>;
450
194
  env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
451
195
  cwd: z.ZodOptional<z.ZodString>;
452
- }, "strict", z.ZodTypeAny, {
453
- command: string;
454
- args: string[];
455
- env: Record<string, string>;
456
- cwd?: string | undefined;
457
- }, {
458
- command: string;
459
- args?: string[] | undefined;
460
- env?: Record<string, string> | undefined;
461
- cwd?: string | undefined;
462
- }>>;
463
- /** Path of a JSONL audit log. Relative paths are resolved against the config file's directory. */
196
+ }, z.core.$strict>>;
197
+ interceptorServers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
198
+ command: z.ZodString;
199
+ args: z.ZodDefault<z.ZodArray<z.ZodString>>;
200
+ env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
201
+ cwd: z.ZodOptional<z.ZodString>;
202
+ }, z.core.$strict>, z.ZodObject<{
203
+ url: z.ZodString;
204
+ headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
205
+ }, z.core.$strict>]>>>;
464
206
  audit: z.ZodOptional<z.ZodString>;
465
- /**
466
- * `active` (default) enforces the policy. `audit` stops and changes nothing, and
467
- * logs what would have been stopped: for trying a policy out safely.
468
- */
469
- mode: z.ZodDefault<z.ZodEnum<["active", "audit"]>>;
470
- /** Human approvals for "ask" decisions. Without an answering channel, "ask" blocks. */
207
+ mode: z.ZodDefault<z.ZodEnum<{
208
+ active: "active";
209
+ audit: "audit";
210
+ }>>;
471
211
  approvals: z.ZodOptional<z.ZodObject<{
472
- /**
473
- * How long a call waits for an answer; no answer means deny. Many MCP
474
- * clients give up on a request after 60 seconds, hence the default.
475
- */
476
212
  timeoutSeconds: z.ZodDefault<z.ZodNumber>;
477
213
  ntfy: z.ZodOptional<z.ZodObject<{
478
214
  server: z.ZodDefault<z.ZodString>;
479
- /** Topic approval requests are sent to. Anyone who can read it can approve: keep it secret. */
480
215
  topic: z.ZodString;
481
- /** Topic answers are posted to. Default: `<topic>-reply`. */
482
216
  replyTopic: z.ZodOptional<z.ZodString>;
483
217
  token: z.ZodOptional<z.ZodString>;
484
- }, "strict", z.ZodTypeAny, {
485
- server: string;
486
- topic: string;
487
- replyTopic?: string | undefined;
488
- token?: string | undefined;
489
- }, {
490
- topic: string;
491
- server?: string | undefined;
492
- replyTopic?: string | undefined;
493
- token?: string | undefined;
494
- }>>;
218
+ }, z.core.$strict>>;
495
219
  email: z.ZodOptional<z.ZodObject<{
496
220
  smtp: z.ZodObject<{
497
221
  host: z.ZodString;
498
222
  port: z.ZodDefault<z.ZodNumber>;
499
- /** TLS from the start. Default: true on port 465, otherwise STARTTLS. */
500
223
  secure: z.ZodOptional<z.ZodBoolean>;
501
224
  user: z.ZodOptional<z.ZodString>;
502
225
  pass: z.ZodOptional<z.ZodString>;
503
- }, "strict", z.ZodTypeAny, {
504
- host: string;
505
- port: number;
506
- user?: string | undefined;
507
- secure?: boolean | undefined;
508
- pass?: string | undefined;
509
- }, {
510
- host: string;
511
- user?: string | undefined;
512
- port?: number | undefined;
513
- secure?: boolean | undefined;
514
- pass?: string | undefined;
515
- }>;
226
+ }, z.core.$strict>;
516
227
  from: z.ZodString;
517
- to: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "atleastone">]>;
518
- on: z.ZodDefault<z.ZodArray<z.ZodEnum<["pending", "blocked", "approved", "denied", "timeout", "undeliverable"]>, "atleastone">>;
519
- }, "strict", z.ZodTypeAny, {
520
- on: ["approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked", ...("approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked")[]];
521
- smtp: {
522
- host: string;
523
- port: number;
524
- user?: string | undefined;
525
- secure?: boolean | undefined;
526
- pass?: string | undefined;
527
- };
528
- from: string;
529
- to: string | [string, ...string[]];
530
- }, {
531
- smtp: {
532
- host: string;
533
- user?: string | undefined;
534
- port?: number | undefined;
535
- secure?: boolean | undefined;
536
- pass?: string | undefined;
537
- };
538
- from: string;
539
- to: string | [string, ...string[]];
540
- on?: ["approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked", ...("approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked")[]] | undefined;
541
- }>>;
542
- /**
543
- * Also ask in the MCP client (elicitation), when it supports it. Off by
544
- * default: a client that accepts elicitations by itself would approve calls.
545
- */
228
+ to: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
229
+ on: z.ZodDefault<z.ZodArray<z.ZodEnum<{
230
+ approved: "approved";
231
+ denied: "denied";
232
+ timeout: "timeout";
233
+ undeliverable: "undeliverable";
234
+ pending: "pending";
235
+ blocked: "blocked";
236
+ }>>>;
237
+ }, z.core.$strict>>;
546
238
  elicitation: z.ZodDefault<z.ZodBoolean>;
547
- /**
548
- * Each approver's own channel, by principal id. Policy rules with
549
- * `approvers: [role]` ask only these people, so the answer names who approved.
550
- */
239
+ totp: z.ZodDefault<z.ZodBoolean>;
551
240
  approvers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
552
241
  ntfy: z.ZodObject<{
553
242
  server: z.ZodDefault<z.ZodString>;
554
- /** Topic approval requests are sent to. Anyone who can read it can approve: keep it secret. */
555
243
  topic: z.ZodString;
556
- /** Topic answers are posted to. Default: `<topic>-reply`. */
557
244
  replyTopic: z.ZodOptional<z.ZodString>;
558
245
  token: z.ZodOptional<z.ZodString>;
559
- }, "strict", z.ZodTypeAny, {
560
- server: string;
561
- topic: string;
562
- replyTopic?: string | undefined;
563
- token?: string | undefined;
564
- }, {
565
- topic: string;
566
- server?: string | undefined;
567
- replyTopic?: string | undefined;
568
- token?: string | undefined;
569
- }>;
570
- }, "strict", z.ZodTypeAny, {
571
- ntfy: {
572
- server: string;
573
- topic: string;
574
- replyTopic?: string | undefined;
575
- token?: string | undefined;
576
- };
577
- }, {
578
- ntfy: {
579
- topic: string;
580
- server?: string | undefined;
581
- replyTopic?: string | undefined;
582
- token?: string | undefined;
583
- };
584
- }>>>;
585
- }, "strict", z.ZodTypeAny, {
586
- timeoutSeconds: number;
587
- elicitation: boolean;
588
- approvers?: Record<string, {
589
- ntfy: {
590
- server: string;
591
- topic: string;
592
- replyTopic?: string | undefined;
593
- token?: string | undefined;
594
- };
595
- }> | undefined;
596
- email?: {
597
- on: ["approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked", ...("approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked")[]];
598
- smtp: {
599
- host: string;
600
- port: number;
601
- user?: string | undefined;
602
- secure?: boolean | undefined;
603
- pass?: string | undefined;
604
- };
605
- from: string;
606
- to: string | [string, ...string[]];
607
- } | undefined;
608
- ntfy?: {
609
- server: string;
610
- topic: string;
611
- replyTopic?: string | undefined;
612
- token?: string | undefined;
613
- } | undefined;
614
- }, {
615
- approvers?: Record<string, {
616
- ntfy: {
617
- topic: string;
618
- server?: string | undefined;
619
- replyTopic?: string | undefined;
620
- token?: string | undefined;
621
- };
622
- }> | undefined;
623
- email?: {
624
- smtp: {
625
- host: string;
626
- user?: string | undefined;
627
- port?: number | undefined;
628
- secure?: boolean | undefined;
629
- pass?: string | undefined;
630
- };
631
- from: string;
632
- to: string | [string, ...string[]];
633
- on?: ["approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked", ...("approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked")[]] | undefined;
634
- } | undefined;
635
- timeoutSeconds?: number | undefined;
636
- ntfy?: {
637
- topic: string;
638
- server?: string | undefined;
639
- replyTopic?: string | undefined;
640
- token?: string | undefined;
641
- } | undefined;
642
- elicitation?: boolean | undefined;
643
- }>>;
644
- /** Timeout for each interceptor invocation, in milliseconds. */
246
+ }, z.core.$strict>;
247
+ }, z.core.$strict>>>;
248
+ }, z.core.$strict>>;
645
249
  interceptorTimeoutMs: z.ZodDefault<z.ZodNumber>;
646
- /** Who runs this gateway. Passed to the authorizer and the interceptors. Default: anonymous. */
250
+ interceptorOverrides: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
251
+ failOpen: z.ZodOptional<z.ZodBoolean>;
252
+ priorityHint: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
253
+ request: z.ZodOptional<z.ZodNumber>;
254
+ response: z.ZodOptional<z.ZodNumber>;
255
+ }, z.core.$strict>]>>;
256
+ mode: z.ZodOptional<z.ZodEnum<{
257
+ active: "active";
258
+ audit: "audit";
259
+ }>>;
260
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
261
+ hooks: z.ZodOptional<z.ZodArray<z.ZodObject<{
262
+ events: z.ZodArray<z.ZodString>;
263
+ phase: z.ZodEnum<{
264
+ request: "request";
265
+ response: "response";
266
+ }>;
267
+ }, z.core.$strict>>>;
268
+ }, z.core.$strict>>>;
647
269
  principal: z.ZodOptional<z.ZodObject<{
648
- type: z.ZodDefault<z.ZodEnum<["user", "service"]>>;
270
+ type: z.ZodDefault<z.ZodEnum<{
271
+ user: "user";
272
+ service: "service";
273
+ }>>;
649
274
  id: z.ZodString;
650
275
  claims: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
651
- }, "strict", z.ZodTypeAny, {
652
- id: string;
653
- type: "user" | "service";
654
- claims?: Record<string, unknown> | undefined;
655
- }, {
656
- id: string;
657
- type?: "user" | "service" | undefined;
658
- claims?: Record<string, unknown> | undefined;
659
- }>>;
660
- /** Role-based authorization: when present, a call no role grants is denied. */
661
- roles: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodObject<{
662
- /** Principal ids; "*" means everyone, including an anonymous caller. */
663
- members: z.ZodArray<z.ZodString, "atleastone">;
664
- tools: z.ZodDefault<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
665
- prompts: z.ZodDefault<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
666
- /** Resource URI patterns, e.g. "github://acme/*". */
667
- resources: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
668
- }, "strict", z.ZodTypeAny, {
669
- members: [string, ...string[]];
670
- tools: string[];
671
- prompts: string[];
672
- resources: string[];
673
- }, {
674
- members: [string, ...string[]];
675
- tools?: string[] | undefined;
676
- prompts?: string[] | undefined;
677
- resources?: string[] | undefined;
678
- }>, {
679
- members: [string, ...string[]];
680
- tools: string[];
681
- prompts: string[];
682
- resources: string[];
683
- }, {
684
- members: [string, ...string[]];
685
- tools?: string[] | undefined;
686
- prompts?: string[] | undefined;
687
- resources?: string[] | undefined;
688
- }>>, Record<string, {
689
- members: [string, ...string[]];
690
- tools: string[];
691
- prompts: string[];
692
- resources: string[];
693
- }>, Record<string, {
694
- members: [string, ...string[]];
695
- tools?: string[] | undefined;
696
- prompts?: string[] | undefined;
697
- resources?: string[] | undefined;
698
- }>>>;
699
- /** Cedar authorization. With roles as well, both must allow. */
276
+ }, z.core.$strict>>;
277
+ roles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
278
+ members: z.ZodArray<z.ZodString>;
279
+ tools: z.ZodDefault<z.ZodArray<z.ZodString>>;
280
+ prompts: z.ZodDefault<z.ZodArray<z.ZodString>>;
281
+ resources: z.ZodDefault<z.ZodArray<z.ZodString>>;
282
+ }, z.core.$strict>>>;
700
283
  cedar: z.ZodOptional<z.ZodObject<{
701
- /** Cedar policy file. Relative paths are resolved against the config file's directory. */
702
284
  policies: z.ZodString;
703
- /** Optional Cedar entities JSON file: groups (`parents`) and attributes. */
704
285
  entities: z.ZodOptional<z.ZodString>;
705
- /** IANA time zone for `context.time`, e.g. "Europe/Berlin". Default: the gateway's. */
706
- timeZone: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
707
- }, "strict", z.ZodTypeAny, {
708
- policies: string;
709
- entities?: string | undefined;
710
- timeZone?: string | undefined;
711
- }, {
712
- policies: string;
713
- entities?: string | undefined;
714
- timeZone?: string | undefined;
715
- }>>;
716
- }, "strict", z.ZodTypeAny, {
717
- mode: "active" | "audit";
718
- upstreams: Record<string, {
719
- command: string;
720
- args: string[];
721
- env: Record<string, string>;
722
- cwd?: string | undefined;
723
- } | {
724
- url: string;
725
- headers: Record<string, string>;
726
- }>;
727
- interceptorTimeoutMs: number;
728
- audit?: string | undefined;
729
- interceptors?: {
730
- command: string;
731
- args: string[];
732
- env: Record<string, string>;
733
- cwd?: string | undefined;
734
- } | undefined;
735
- principal?: {
736
- id: string;
737
- type: "user" | "service";
738
- claims?: Record<string, unknown> | undefined;
739
- } | undefined;
740
- approvals?: {
741
- timeoutSeconds: number;
742
- elicitation: boolean;
743
- approvers?: Record<string, {
744
- ntfy: {
745
- server: string;
746
- topic: string;
747
- replyTopic?: string | undefined;
748
- token?: string | undefined;
749
- };
750
- }> | undefined;
751
- email?: {
752
- on: ["approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked", ...("approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked")[]];
753
- smtp: {
754
- host: string;
755
- port: number;
756
- user?: string | undefined;
757
- secure?: boolean | undefined;
758
- pass?: string | undefined;
759
- };
760
- from: string;
761
- to: string | [string, ...string[]];
762
- } | undefined;
763
- ntfy?: {
764
- server: string;
765
- topic: string;
766
- replyTopic?: string | undefined;
767
- token?: string | undefined;
768
- } | undefined;
769
- } | undefined;
770
- roles?: Record<string, {
771
- members: [string, ...string[]];
772
- tools: string[];
773
- prompts: string[];
774
- resources: string[];
775
- }> | undefined;
776
- cedar?: {
777
- policies: string;
778
- entities?: string | undefined;
779
- timeZone?: string | undefined;
780
- } | undefined;
781
- }, {
782
- upstreams: Record<string, {
783
- command: string;
784
- args?: string[] | undefined;
785
- env?: Record<string, string> | undefined;
786
- cwd?: string | undefined;
787
- } | {
788
- url: string;
789
- headers?: Record<string, string> | undefined;
790
- }>;
791
- mode?: "active" | "audit" | undefined;
792
- audit?: string | undefined;
793
- interceptors?: {
794
- command: string;
795
- args?: string[] | undefined;
796
- env?: Record<string, string> | undefined;
797
- cwd?: string | undefined;
798
- } | undefined;
799
- principal?: {
800
- id: string;
801
- type?: "user" | "service" | undefined;
802
- claims?: Record<string, unknown> | undefined;
803
- } | undefined;
804
- approvals?: {
805
- approvers?: Record<string, {
806
- ntfy: {
807
- topic: string;
808
- server?: string | undefined;
809
- replyTopic?: string | undefined;
810
- token?: string | undefined;
811
- };
812
- }> | undefined;
813
- email?: {
814
- smtp: {
815
- host: string;
816
- user?: string | undefined;
817
- port?: number | undefined;
818
- secure?: boolean | undefined;
819
- pass?: string | undefined;
820
- };
821
- from: string;
822
- to: string | [string, ...string[]];
823
- on?: ["approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked", ...("approved" | "denied" | "timeout" | "undeliverable" | "pending" | "blocked")[]] | undefined;
824
- } | undefined;
825
- timeoutSeconds?: number | undefined;
826
- ntfy?: {
827
- topic: string;
828
- server?: string | undefined;
829
- replyTopic?: string | undefined;
830
- token?: string | undefined;
831
- } | undefined;
832
- elicitation?: boolean | undefined;
833
- } | undefined;
834
- interceptorTimeoutMs?: number | undefined;
835
- roles?: Record<string, {
836
- members: [string, ...string[]];
837
- tools?: string[] | undefined;
838
- prompts?: string[] | undefined;
839
- resources?: string[] | undefined;
840
- }> | undefined;
841
- cedar?: {
842
- policies: string;
843
- entities?: string | undefined;
844
- timeZone?: string | undefined;
845
- } | undefined;
846
- }>;
286
+ timeZone: z.ZodOptional<z.ZodString>;
287
+ }, z.core.$strict>>;
288
+ openfga: z.ZodOptional<z.ZodObject<{
289
+ url: z.ZodString;
290
+ storeId: z.ZodString;
291
+ modelId: z.ZodOptional<z.ZodString>;
292
+ token: z.ZodOptional<z.ZodString>;
293
+ relation: z.ZodDefault<z.ZodString>;
294
+ timeoutMs: z.ZodDefault<z.ZodNumber>;
295
+ tools: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
296
+ relation: z.ZodOptional<z.ZodString>;
297
+ object: z.ZodOptional<z.ZodString>;
298
+ }, z.core.$strict>>>;
299
+ }, z.core.$strict>>;
300
+ }, z.core.$strict>;
847
301
  export type GatewayConfig = z.infer<typeof GatewayConfigSchema>;
848
302
  export declare const TOOL_SEPARATOR = "__";
849
303
  export declare class EnvExpansionError extends Error {