@winstonsayno/mcp-gateway 7.3.0 → 7.5.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.
Files changed (39) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +14 -0
  3. package/dist/config/loader.d.ts +6 -6
  4. package/dist/config/loader.d.ts.map +1 -1
  5. package/dist/config/loader.js +4 -0
  6. package/dist/config/loader.js.map +1 -1
  7. package/dist/features/api-upstreams.d.ts +4 -4
  8. package/dist/features/identity.d.ts +4 -4
  9. package/dist/features/index.d.ts +2 -0
  10. package/dist/features/index.d.ts.map +1 -1
  11. package/dist/features/index.js +2 -0
  12. package/dist/features/index.js.map +1 -1
  13. package/dist/features/rollouts.d.ts +264 -0
  14. package/dist/features/rollouts.d.ts.map +1 -0
  15. package/dist/features/rollouts.js +216 -0
  16. package/dist/features/rollouts.js.map +1 -0
  17. package/dist/features/sanitize.d.ts +6 -6
  18. package/dist/features/semantic-cache.d.ts +158 -0
  19. package/dist/features/semantic-cache.d.ts.map +1 -0
  20. package/dist/features/semantic-cache.js +303 -0
  21. package/dist/features/semantic-cache.js.map +1 -0
  22. package/dist/gateway/control-plane.d.ts +2 -2
  23. package/dist/gateway/features.d.ts +1 -1
  24. package/dist/gateway/features.d.ts.map +1 -1
  25. package/dist/gateway/features.js +1 -1
  26. package/dist/gateway/features.js.map +1 -1
  27. package/dist/gateway/hooks.d.ts +3 -0
  28. package/dist/gateway/hooks.d.ts.map +1 -1
  29. package/dist/gateway/hooks.js.map +1 -1
  30. package/dist/gateway/invoker.d.ts.map +1 -1
  31. package/dist/gateway/invoker.js +14 -1
  32. package/dist/gateway/invoker.js.map +1 -1
  33. package/dist/index.d.ts +4 -0
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +2 -0
  36. package/dist/index.js.map +1 -1
  37. package/dist/utils/types.d.ts +4 -0
  38. package/dist/utils/types.d.ts.map +1 -1
  39. package/package.json +1 -1
@@ -0,0 +1,264 @@
1
+ /**
2
+ * Tool versioning and gradual rollout (7.5): send a share of a tool's traffic to a new upstream version.
3
+ *
4
+ * A rollout names a **stable** server and a **canary** server (the new version, same tool names). Calls to the stable
5
+ * server's matching tools go to the canary for `percent` % of callers (sticky per client: the same client always gets
6
+ * the same version), for every client matching `clients`, and never for clients matching `exclude`. The canary's
7
+ * error rate is watched: above `autoRollback.maxErrorRate` (after `minCalls` canary calls in the window) the rollout
8
+ * is rolled back automatically.
9
+ *
10
+ * ```yaml
11
+ * rollouts:
12
+ * - id: search-v2
13
+ * stable: search # server id clients call
14
+ * canary: search-v2 # server id of the new version
15
+ * tools: ["*"] # tool globs on the stable server (default all)
16
+ * percent: 10
17
+ * clients: ["key:beta-*"] # always canary
18
+ * autoRollback: { maxErrorRate: 0.2, minCalls: 20, window: 200 }
19
+ * ```
20
+ *
21
+ * Results routed to the canary carry `_meta["mcp-gateway/rollout"]` (`id`, `version: canary`).
22
+ *
23
+ * - `GET /admin/rollouts` — each rollout: effective percent, state (`active` | `promoted` | `rolled-back`), calls and
24
+ * error rates per version.
25
+ * - `POST /admin/rollouts/:id/percent` `{ percent }`, `/promote` (100 %), `/rollback` (0 %), `/reset` (back to config).
26
+ * Runtime overrides; `?persist=true` also writes `percent` into the config (`controlPlane.configApi: true`).
27
+ *
28
+ * @module features/rollouts
29
+ */
30
+ import { z } from 'zod';
31
+ declare const RolloutSchema: z.ZodEffects<z.ZodObject<{
32
+ id: z.ZodString;
33
+ stable: z.ZodString;
34
+ canary: z.ZodString;
35
+ tools: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
36
+ percent: z.ZodDefault<z.ZodNumber>;
37
+ clients: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
38
+ exclude: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
39
+ autoRollback: z.ZodOptional<z.ZodObject<{
40
+ maxErrorRate: z.ZodDefault<z.ZodNumber>;
41
+ minCalls: z.ZodDefault<z.ZodNumber>;
42
+ window: z.ZodDefault<z.ZodNumber>;
43
+ }, "strict", z.ZodTypeAny, {
44
+ maxErrorRate: number;
45
+ minCalls: number;
46
+ window: number;
47
+ }, {
48
+ maxErrorRate?: number | undefined;
49
+ minCalls?: number | undefined;
50
+ window?: number | undefined;
51
+ }>>;
52
+ }, "strict", z.ZodTypeAny, {
53
+ id: string;
54
+ tools: string[];
55
+ stable: string;
56
+ canary: string;
57
+ percent: number;
58
+ clients: string[];
59
+ exclude: string[];
60
+ autoRollback?: {
61
+ maxErrorRate: number;
62
+ minCalls: number;
63
+ window: number;
64
+ } | undefined;
65
+ }, {
66
+ id: string;
67
+ stable: string;
68
+ canary: string;
69
+ tools?: string[] | undefined;
70
+ percent?: number | undefined;
71
+ clients?: string[] | undefined;
72
+ exclude?: string[] | undefined;
73
+ autoRollback?: {
74
+ maxErrorRate?: number | undefined;
75
+ minCalls?: number | undefined;
76
+ window?: number | undefined;
77
+ } | undefined;
78
+ }>, {
79
+ id: string;
80
+ tools: string[];
81
+ stable: string;
82
+ canary: string;
83
+ percent: number;
84
+ clients: string[];
85
+ exclude: string[];
86
+ autoRollback?: {
87
+ maxErrorRate: number;
88
+ minCalls: number;
89
+ window: number;
90
+ } | undefined;
91
+ }, {
92
+ id: string;
93
+ stable: string;
94
+ canary: string;
95
+ tools?: string[] | undefined;
96
+ percent?: number | undefined;
97
+ clients?: string[] | undefined;
98
+ exclude?: string[] | undefined;
99
+ autoRollback?: {
100
+ maxErrorRate?: number | undefined;
101
+ minCalls?: number | undefined;
102
+ window?: number | undefined;
103
+ } | undefined;
104
+ }>;
105
+ export declare const RolloutsSchema: z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodObject<{
106
+ id: z.ZodString;
107
+ stable: z.ZodString;
108
+ canary: z.ZodString;
109
+ tools: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
110
+ percent: z.ZodDefault<z.ZodNumber>;
111
+ clients: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
112
+ exclude: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
113
+ autoRollback: z.ZodOptional<z.ZodObject<{
114
+ maxErrorRate: z.ZodDefault<z.ZodNumber>;
115
+ minCalls: z.ZodDefault<z.ZodNumber>;
116
+ window: z.ZodDefault<z.ZodNumber>;
117
+ }, "strict", z.ZodTypeAny, {
118
+ maxErrorRate: number;
119
+ minCalls: number;
120
+ window: number;
121
+ }, {
122
+ maxErrorRate?: number | undefined;
123
+ minCalls?: number | undefined;
124
+ window?: number | undefined;
125
+ }>>;
126
+ }, "strict", z.ZodTypeAny, {
127
+ id: string;
128
+ tools: string[];
129
+ stable: string;
130
+ canary: string;
131
+ percent: number;
132
+ clients: string[];
133
+ exclude: string[];
134
+ autoRollback?: {
135
+ maxErrorRate: number;
136
+ minCalls: number;
137
+ window: number;
138
+ } | undefined;
139
+ }, {
140
+ id: string;
141
+ stable: string;
142
+ canary: string;
143
+ tools?: string[] | undefined;
144
+ percent?: number | undefined;
145
+ clients?: string[] | undefined;
146
+ exclude?: string[] | undefined;
147
+ autoRollback?: {
148
+ maxErrorRate?: number | undefined;
149
+ minCalls?: number | undefined;
150
+ window?: number | undefined;
151
+ } | undefined;
152
+ }>, {
153
+ id: string;
154
+ tools: string[];
155
+ stable: string;
156
+ canary: string;
157
+ percent: number;
158
+ clients: string[];
159
+ exclude: string[];
160
+ autoRollback?: {
161
+ maxErrorRate: number;
162
+ minCalls: number;
163
+ window: number;
164
+ } | undefined;
165
+ }, {
166
+ id: string;
167
+ stable: string;
168
+ canary: string;
169
+ tools?: string[] | undefined;
170
+ percent?: number | undefined;
171
+ clients?: string[] | undefined;
172
+ exclude?: string[] | undefined;
173
+ autoRollback?: {
174
+ maxErrorRate?: number | undefined;
175
+ minCalls?: number | undefined;
176
+ window?: number | undefined;
177
+ } | undefined;
178
+ }>, "many">, {
179
+ id: string;
180
+ tools: string[];
181
+ stable: string;
182
+ canary: string;
183
+ percent: number;
184
+ clients: string[];
185
+ exclude: string[];
186
+ autoRollback?: {
187
+ maxErrorRate: number;
188
+ minCalls: number;
189
+ window: number;
190
+ } | undefined;
191
+ }[], {
192
+ id: string;
193
+ stable: string;
194
+ canary: string;
195
+ tools?: string[] | undefined;
196
+ percent?: number | undefined;
197
+ clients?: string[] | undefined;
198
+ exclude?: string[] | undefined;
199
+ autoRollback?: {
200
+ maxErrorRate?: number | undefined;
201
+ minCalls?: number | undefined;
202
+ window?: number | undefined;
203
+ } | undefined;
204
+ }[]>;
205
+ export type RolloutsConfig = z.input<typeof RolloutsSchema>;
206
+ type Rollout = z.output<typeof RolloutSchema>;
207
+ /** Sticky bucket 0..99.99 for a client in a rollout. */
208
+ export declare const bucketOf: (rolloutId: string, client: string) => number;
209
+ interface Arm {
210
+ calls: number;
211
+ errors: number;
212
+ recent: boolean[];
213
+ }
214
+ interface State {
215
+ override?: number;
216
+ state: 'active' | 'promoted' | 'rolled-back';
217
+ reason?: string;
218
+ stable: Arm;
219
+ canary: Arm;
220
+ }
221
+ export declare class RolloutManager {
222
+ readonly states: Map<string, State>;
223
+ private st;
224
+ percent(r: Rollout): number;
225
+ /** Version for a call by `client`. */
226
+ pick(r: Rollout, client: string): 'stable' | 'canary';
227
+ record(r: Rollout, version: 'stable' | 'canary', error: boolean): void;
228
+ set(id: string, percent: number, state: State['state'], reason?: string): void;
229
+ reset(id: string): void;
230
+ view(r: Rollout): {
231
+ versions: {
232
+ stable: {
233
+ calls: number;
234
+ errors: number;
235
+ errorRate: number;
236
+ windowErrorRate: number;
237
+ };
238
+ canary: {
239
+ calls: number;
240
+ errors: number;
241
+ errorRate: number;
242
+ windowErrorRate: number;
243
+ };
244
+ };
245
+ reason?: string | undefined;
246
+ configuredPercent: number;
247
+ percent: number;
248
+ state: "active" | "promoted" | "rolled-back";
249
+ id: string;
250
+ tools: string[];
251
+ stable: string;
252
+ canary: string;
253
+ clients: string[];
254
+ exclude: string[];
255
+ autoRollback?: {
256
+ maxErrorRate: number;
257
+ minCalls: number;
258
+ window: number;
259
+ } | undefined;
260
+ };
261
+ }
262
+ export declare const rolloutManager: RolloutManager;
263
+ export {};
264
+ //# sourceMappingURL=rollouts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rollouts.d.ts","sourceRoot":"","sources":["../../src/features/rollouts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYoF,CAAC;AACxG,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IASzB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAC5D,KAAK,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AAO9C,wDAAwD;AACxD,eAAO,MAAM,QAAQ,GAAI,WAAW,MAAM,EAAE,QAAQ,MAAM,WAAwD,CAAC;AAEnH,UAAU,GAAG;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,EAAE,CAAC;CACnB;AACD,UAAU,KAAK;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,QAAQ,GAAG,UAAU,GAAG,aAAa,CAAC;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,GAAG,CAAC;CACb;AAED,qBAAa,cAAc;IACzB,QAAQ,CAAC,MAAM,qBAA4B;IAC3C,OAAO,CAAC,EAAE;IAKV,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM;IAI3B,sCAAsC;IACtC,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ;IAMrD,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,GAAG,QAAQ,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAmBtE,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAO9E,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAOvB,IAAI,CAAC,CAAC,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKhB;AAED,eAAO,MAAM,cAAc,gBAAuB,CAAC"}
@@ -0,0 +1,216 @@
1
+ /**
2
+ * Tool versioning and gradual rollout (7.5): send a share of a tool's traffic to a new upstream version.
3
+ *
4
+ * A rollout names a **stable** server and a **canary** server (the new version, same tool names). Calls to the stable
5
+ * server's matching tools go to the canary for `percent` % of callers (sticky per client: the same client always gets
6
+ * the same version), for every client matching `clients`, and never for clients matching `exclude`. The canary's
7
+ * error rate is watched: above `autoRollback.maxErrorRate` (after `minCalls` canary calls in the window) the rollout
8
+ * is rolled back automatically.
9
+ *
10
+ * ```yaml
11
+ * rollouts:
12
+ * - id: search-v2
13
+ * stable: search # server id clients call
14
+ * canary: search-v2 # server id of the new version
15
+ * tools: ["*"] # tool globs on the stable server (default all)
16
+ * percent: 10
17
+ * clients: ["key:beta-*"] # always canary
18
+ * autoRollback: { maxErrorRate: 0.2, minCalls: 20, window: 200 }
19
+ * ```
20
+ *
21
+ * Results routed to the canary carry `_meta["mcp-gateway/rollout"]` (`id`, `version: canary`).
22
+ *
23
+ * - `GET /admin/rollouts` — each rollout: effective percent, state (`active` | `promoted` | `rolled-back`), calls and
24
+ * error rates per version.
25
+ * - `POST /admin/rollouts/:id/percent` `{ percent }`, `/promote` (100 %), `/rollback` (0 %), `/reset` (back to config).
26
+ * Runtime overrides; `?persist=true` also writes `percent` into the config (`controlPlane.configApi: true`).
27
+ *
28
+ * @module features/rollouts
29
+ */
30
+ import { z } from 'zod';
31
+ import { registerFeature, objectBody, badRequest } from '../gateway/features.js';
32
+ import { registerCallHook } from '../gateway/hooks.js';
33
+ import { portableConfig } from '../gateway/admin.js';
34
+ import { globToRegExp } from '../utils/tool-filter.js';
35
+ import { logger } from '../utils/logger.js';
36
+ const RolloutSchema = z
37
+ .object({
38
+ id: z.string().min(1).regex(/^[A-Za-z0-9._-]+$/),
39
+ stable: z.string().min(1),
40
+ canary: z.string().min(1),
41
+ tools: z.array(z.string().min(1)).default(['*']),
42
+ percent: z.number().min(0).max(100).default(0),
43
+ clients: z.array(z.string().min(1)).default([]),
44
+ exclude: z.array(z.string().min(1)).default([]),
45
+ autoRollback: z.object({ maxErrorRate: z.number().min(0).max(1).default(0.2), minCalls: z.number().int().min(1).default(20), window: z.number().int().min(10).max(100_000).default(200) }).strict().optional(),
46
+ })
47
+ .strict()
48
+ .refine((r) => r.stable !== r.canary, { message: '`stable` and `canary` must be different servers' });
49
+ export const RolloutsSchema = z.array(RolloutSchema).superRefine((rs, ctx) => {
50
+ const ids = new Set();
51
+ const stables = new Set();
52
+ for (const r of rs) {
53
+ if (ids.has(r.id))
54
+ ctx.addIssue({ code: 'custom', message: `duplicate rollout id "${r.id}"` });
55
+ if (stables.has(r.stable))
56
+ ctx.addIssue({ code: 'custom', message: `server "${r.stable}" has more than one rollout` });
57
+ ids.add(r.id);
58
+ stables.add(r.stable);
59
+ }
60
+ });
61
+ const fnv = (s) => {
62
+ let h = 0x811c9dc5;
63
+ for (let i = 0; i < s.length; i++)
64
+ h = Math.imul(h ^ s.charCodeAt(i), 0x01000193);
65
+ return h >>> 0;
66
+ };
67
+ /** Sticky bucket 0..99.99 for a client in a rollout. */
68
+ export const bucketOf = (rolloutId, client) => (fnv(`${rolloutId}\u0000${client}`) % 10_000) / 100;
69
+ export class RolloutManager {
70
+ states = new Map();
71
+ st(id) {
72
+ let s = this.states.get(id);
73
+ if (!s)
74
+ this.states.set(id, (s = { state: 'active', stable: { calls: 0, errors: 0, recent: [] }, canary: { calls: 0, errors: 0, recent: [] } }));
75
+ return s;
76
+ }
77
+ percent(r) {
78
+ const s = this.st(r.id);
79
+ return s.override ?? r.percent;
80
+ }
81
+ /** Version for a call by `client`. */
82
+ pick(r, client) {
83
+ if (r.exclude.some((p) => globToRegExp(p).test(client)))
84
+ return 'stable';
85
+ if (this.st(r.id).state === 'rolled-back')
86
+ return 'stable';
87
+ if (r.clients.some((p) => globToRegExp(p).test(client)))
88
+ return 'canary';
89
+ return bucketOf(r.id, client) < this.percent(r) ? 'canary' : 'stable';
90
+ }
91
+ record(r, version, error) {
92
+ const s = this.st(r.id);
93
+ const arm = s[version];
94
+ arm.calls++;
95
+ if (error)
96
+ arm.errors++;
97
+ arm.recent.push(error);
98
+ const win = r.autoRollback?.window ?? 200;
99
+ if (arm.recent.length > win)
100
+ arm.recent.splice(0, arm.recent.length - win);
101
+ const ar = r.autoRollback;
102
+ if (ar && version === 'canary' && s.state !== 'rolled-back' && arm.recent.length >= ar.minCalls) {
103
+ const rate = arm.recent.filter(Boolean).length / arm.recent.length;
104
+ if (rate > ar.maxErrorRate) {
105
+ s.state = 'rolled-back';
106
+ s.override = 0;
107
+ s.reason = `canary error rate ${(rate * 100).toFixed(1)}% > ${(ar.maxErrorRate * 100).toFixed(1)}% over ${arm.recent.length} calls`;
108
+ logger.warn(`Rollout ${r.id}: rolled back automatically (${s.reason})`);
109
+ }
110
+ }
111
+ }
112
+ set(id, percent, state, reason) {
113
+ const s = this.st(id);
114
+ s.override = percent;
115
+ s.state = state;
116
+ s.reason = reason;
117
+ for (const arm of [s.stable, s.canary])
118
+ arm.recent = [];
119
+ }
120
+ reset(id) {
121
+ const s = this.st(id);
122
+ delete s.override;
123
+ delete s.reason;
124
+ s.state = 'active';
125
+ for (const arm of [s.stable, s.canary])
126
+ arm.recent = [];
127
+ }
128
+ view(r) {
129
+ const s = this.st(r.id);
130
+ const arm = (a) => ({ calls: a.calls, errors: a.errors, errorRate: a.calls ? Math.round((a.errors / a.calls) * 1000) / 1000 : 0, windowErrorRate: a.recent.length ? Math.round((a.recent.filter(Boolean).length / a.recent.length) * 1000) / 1000 : 0 });
131
+ return { ...r, configuredPercent: r.percent, percent: this.percent(r), state: s.state, ...(s.reason ? { reason: s.reason } : {}), versions: { stable: arm(s.stable), canary: arm(s.canary) } };
132
+ }
133
+ }
134
+ export const rolloutManager = new RolloutManager();
135
+ const list = (cfg) => (cfg.rollouts ? RolloutsSchema.parse(cfg.rollouts) : []);
136
+ const MARK = 'mcp-gateway/rollout';
137
+ registerCallHook({
138
+ id: 'rollouts',
139
+ before: (call, cfg) => {
140
+ const r = list(cfg).find((x) => x.stable === call.serverId && x.tools.some((p) => globToRegExp(p).test(call.tool)));
141
+ if (!r)
142
+ return;
143
+ if (rolloutManager.pick(r, call.clientId ?? 'anonymous') === 'canary')
144
+ return { serverId: r.canary };
145
+ },
146
+ after: (call, result, cfg) => {
147
+ const rs = list(cfg);
148
+ const canary = rs.find((x) => x.canary === call.serverId && x.tools.some((p) => globToRegExp(p).test(call.tool)));
149
+ const stable = canary ? undefined : rs.find((x) => x.stable === call.serverId && x.tools.some((p) => globToRegExp(p).test(call.tool)));
150
+ const r = canary ?? stable;
151
+ if (!r)
152
+ return;
153
+ const isError = !result.success || result.result?.isError === true;
154
+ rolloutManager.record(r, canary ? 'canary' : 'stable', isError);
155
+ if (canary && result.success && result.result && typeof result.result === 'object' && !Array.isArray(result.result)) {
156
+ const o = result.result;
157
+ return { ...result, result: { ...o, _meta: { ...(o._meta ?? {}), [MARK]: { id: r.id, version: 'canary', server: r.canary } } } };
158
+ }
159
+ },
160
+ });
161
+ registerFeature({
162
+ id: 'rollouts',
163
+ since: '7.5.0',
164
+ summary: 'Tool versioning and gradual rollout: sticky percentage canaries per server with automatic rollback',
165
+ mount: (router, ctx) => {
166
+ const find = (id) => list(ctx.config()).find((r) => r.id === id);
167
+ router.get('/', (_req, res) => {
168
+ res.json({ rollouts: list(ctx.config()).map((r) => rolloutManager.view(r)) });
169
+ });
170
+ router.get('/:id', (req, res) => {
171
+ const r = find(req.params.id);
172
+ if (!r)
173
+ return void res.status(404).json({ error: 'Not Found', message: `No rollout "${req.params.id}"` });
174
+ res.json(rolloutManager.view(r));
175
+ });
176
+ const action = (name) => router.post(`/:id/${name}`, async (req, res) => {
177
+ const r = find(req.params.id);
178
+ if (!r)
179
+ return void res.status(404).json({ error: 'Not Found', message: `No rollout "${req.params.id}"` });
180
+ let percent;
181
+ if (name === 'percent') {
182
+ const b = objectBody(req, res);
183
+ if (!b)
184
+ return;
185
+ if (typeof b.percent !== 'number' || b.percent < 0 || b.percent > 100)
186
+ return badRequest(res, 'Body must be { "percent": 0..100 }');
187
+ percent = b.percent;
188
+ rolloutManager.set(r.id, percent, 'active', 'set over the admin API');
189
+ }
190
+ else if (name === 'promote')
191
+ rolloutManager.set(r.id, (percent = 100), 'promoted', 'promoted over the admin API');
192
+ else if (name === 'rollback')
193
+ rolloutManager.set(r.id, (percent = 0), 'rolled-back', 'rolled back over the admin API');
194
+ else
195
+ rolloutManager.reset(r.id);
196
+ if (req.query.persist === 'true' && percent !== undefined) {
197
+ if (ctx.config().controlPlane?.configApi !== true || !ctx.applyConfig)
198
+ return void res.status(403).json({ error: 'Forbidden', message: 'persist=true needs controlPlane.configApi: true' });
199
+ const p = portableConfig(ctx.config());
200
+ const next = (p.rollouts ?? []).map((x) => (x.id === r.id ? { ...x, percent } : x));
201
+ try {
202
+ await ctx.applyConfig({ ...p, rollouts: next });
203
+ }
204
+ catch (err) {
205
+ return badRequest(res, err instanceof Error ? err.message : String(err));
206
+ }
207
+ }
208
+ res.json(rolloutManager.view(find(r.id)));
209
+ });
210
+ action('percent');
211
+ action('promote');
212
+ action('rollback');
213
+ action('reset');
214
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,CAAC;gBACxH,IAAI,CAAC;oBACH,MAAM,GAAG,CAAC,WAAW,CAAC,EAAE,GAAG,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;gBAClD,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,OAAO,UAAU,CAAC,GAAG,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC3E,CAAC;YACH,CAAC;YACD,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAE,CAAC,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QACL,MAAM,CAAC,SAAS,CAAC,CAAC;QAClB,MAAM,CAAC,SAAS,CAAC,CAAC;QAClB,MAAM,CAAC,UAAU,CAAC,CAAC;QACnB,MAAM,CAAC,OAAO,CAAC,CAAC;IAClB,CAAC;CACF,CAAC,CAAC"}
@@ -46,11 +46,11 @@ export declare const SanitizeSchema: z.ZodObject<{
46
46
  action: z.ZodDefault<z.ZodEnum<["off", "flag", "mark", "block"]>>;
47
47
  threshold: z.ZodDefault<z.ZodNumber>;
48
48
  }, "strict", z.ZodTypeAny, {
49
- action: "off" | "flag" | "mark" | "block";
50
49
  threshold: number;
50
+ action: "off" | "flag" | "mark" | "block";
51
51
  }, {
52
- action?: "off" | "flag" | "mark" | "block" | undefined;
53
52
  threshold?: number | undefined;
53
+ action?: "off" | "flag" | "mark" | "block" | undefined;
54
54
  }>>;
55
55
  inbound: z.ZodDefault<z.ZodEnum<["off", "block"]>>;
56
56
  spotlight: z.ZodDefault<z.ZodBoolean>;
@@ -61,11 +61,11 @@ export declare const SanitizeSchema: z.ZodObject<{
61
61
  invisible: boolean;
62
62
  ansi: boolean;
63
63
  html: boolean;
64
- images: "keep" | "strip";
64
+ images: "strip" | "keep";
65
65
  allowedImageHosts: string[];
66
66
  injection: {
67
- action: "off" | "flag" | "mark" | "block";
68
67
  threshold: number;
68
+ action: "off" | "flag" | "mark" | "block";
69
69
  };
70
70
  inbound: "off" | "block";
71
71
  spotlight: boolean;
@@ -77,12 +77,12 @@ export declare const SanitizeSchema: z.ZodObject<{
77
77
  invisible?: boolean | undefined;
78
78
  ansi?: boolean | undefined;
79
79
  html?: boolean | undefined;
80
- images?: "keep" | "strip" | undefined;
80
+ images?: "strip" | "keep" | undefined;
81
81
  allowedImageHosts?: string[] | undefined;
82
82
  maxChars?: number | undefined;
83
83
  injection?: {
84
- action?: "off" | "flag" | "mark" | "block" | undefined;
85
84
  threshold?: number | undefined;
85
+ action?: "off" | "flag" | "mark" | "block" | undefined;
86
86
  } | undefined;
87
87
  inbound?: "off" | "block" | undefined;
88
88
  spotlight?: boolean | undefined;