@featureflip/mcp 0.11.1 → 0.12.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 +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/client.d.ts +1 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/generated/api-types.d.ts +1189 -80
- package/dist/generated/api-types.d.ts.map +1 -1
- package/dist/generated/output-schemas.json.d.ts +492 -1
- package/dist/index.mjs +1 -1
- package/dist/org-D-wxVFsh.js +2340 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/tools/flag-versions.d.ts +4 -0
- package/dist/tools/flag-versions.d.ts.map +1 -0
- package/dist/tools/segments.d.ts.map +1 -1
- package/dist/tools/variations.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/org-CBTP0gMs.js +0 -2264
|
@@ -0,0 +1,2340 @@
|
|
|
1
|
+
import { McpServer as e, fromJsonSchema as t } from "@modelcontextprotocol/server";
|
|
2
|
+
import * as n from "zod/v4";
|
|
3
|
+
// src/version.ts
|
|
4
|
+
var r = {
|
|
5
|
+
name: "@featureflip/mcp",
|
|
6
|
+
version: "0.12.0",
|
|
7
|
+
mcpName: "io.github.canopy-labs/featureflip",
|
|
8
|
+
description: "MCP server for managing Featureflip feature flags from AI agents and editors",
|
|
9
|
+
keywords: [
|
|
10
|
+
"feature-flags",
|
|
11
|
+
"feature-toggles",
|
|
12
|
+
"feature-management",
|
|
13
|
+
"featureflip",
|
|
14
|
+
"mcp",
|
|
15
|
+
"mcp-server",
|
|
16
|
+
"model-context-protocol",
|
|
17
|
+
"ai-agents",
|
|
18
|
+
"claude",
|
|
19
|
+
"cursor"
|
|
20
|
+
],
|
|
21
|
+
license: "Apache-2.0",
|
|
22
|
+
repository: {
|
|
23
|
+
type: "git",
|
|
24
|
+
url: "https://github.com/canopy-labs/featureflip-mcp.git"
|
|
25
|
+
},
|
|
26
|
+
homepage: "https://featureflip.io/docs/integrations/mcp/",
|
|
27
|
+
type: "module",
|
|
28
|
+
bin: { "featureflip-mcp": "bin/featureflip-mcp.mjs" },
|
|
29
|
+
exports: { ".": {
|
|
30
|
+
types: "./dist/index.d.ts",
|
|
31
|
+
import: "./dist/index.mjs"
|
|
32
|
+
} },
|
|
33
|
+
types: "./dist/index.d.ts",
|
|
34
|
+
files: ["dist", "bin"],
|
|
35
|
+
publishConfig: { access: "public" },
|
|
36
|
+
scripts: {
|
|
37
|
+
build: "vite build",
|
|
38
|
+
typecheck: "tsc --noEmit -p tsconfig.json",
|
|
39
|
+
"generate:api": "npx --yes openapi-typescript@7.13.0 ../../apps/management-api/public-v1-openapi.json -o src/generated/api-types.ts && node scripts/generate-output-schemas.mjs",
|
|
40
|
+
test: "vitest run",
|
|
41
|
+
"test:watch": "vitest",
|
|
42
|
+
"smoke:docker": "node scripts/docker-smoke.mjs",
|
|
43
|
+
"build:mcpb": "node scripts/build-mcpb.mjs"
|
|
44
|
+
},
|
|
45
|
+
dependencies: {
|
|
46
|
+
"@modelcontextprotocol/server": "2.4.0",
|
|
47
|
+
zod: "^4.6.7"
|
|
48
|
+
},
|
|
49
|
+
devDependencies: {
|
|
50
|
+
"@modelcontextprotocol/client": "2.4.0",
|
|
51
|
+
"@typescript/typescript6": "^6.0.2",
|
|
52
|
+
"@types/node": "^26.6.6",
|
|
53
|
+
typescript: "^7.0.2",
|
|
54
|
+
vite: "^8.3.8",
|
|
55
|
+
"vite-plugin-dts": "^5.1.2",
|
|
56
|
+
vitest: "^5.1.0"
|
|
57
|
+
},
|
|
58
|
+
engines: { node: ">=20.19.0" }
|
|
59
|
+
}.version, i = class extends Error {
|
|
60
|
+
status;
|
|
61
|
+
envelope;
|
|
62
|
+
constructor(e, t) {
|
|
63
|
+
super(t.message), this.status = e, this.envelope = t, this.name = "ApiError";
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
function a(e) {
|
|
67
|
+
return /^(W\/)?".*"$/.test(e) ? e : `"${e}"`;
|
|
68
|
+
}
|
|
69
|
+
function o(e) {
|
|
70
|
+
return encodeURIComponent(e);
|
|
71
|
+
}
|
|
72
|
+
var s = /* @__PURE__ */ new Set([
|
|
73
|
+
502,
|
|
74
|
+
503,
|
|
75
|
+
504
|
|
76
|
+
]), c = /* @__PURE__ */ new Set([
|
|
77
|
+
"GET",
|
|
78
|
+
"HEAD",
|
|
79
|
+
"PUT",
|
|
80
|
+
"DELETE"
|
|
81
|
+
]), l = [250, 1e3], u = `featureflip-mcp/${r}`, d = `mcp/${r}`, f = class {
|
|
82
|
+
opts;
|
|
83
|
+
fetchImpl;
|
|
84
|
+
sleep;
|
|
85
|
+
constructor(e) {
|
|
86
|
+
this.opts = e, this.fetchImpl = e.fetchImpl ?? fetch, this.sleep = e.sleep ?? ((e) => new Promise((t) => setTimeout(t, e)));
|
|
87
|
+
}
|
|
88
|
+
async request(e, t, n = {}) {
|
|
89
|
+
return (await this.requestWithEtag(e, t, n)).data;
|
|
90
|
+
}
|
|
91
|
+
async requestWithEtag(e, t, n = {}) {
|
|
92
|
+
let r = new URL(this.opts.baseUrl + t);
|
|
93
|
+
for (let [e, t] of Object.entries(n.query ?? {})) t !== void 0 && r.searchParams.set(e, String(t));
|
|
94
|
+
let o = {
|
|
95
|
+
Authorization: `Bearer ${this.opts.token}`,
|
|
96
|
+
Accept: "application/json",
|
|
97
|
+
"User-Agent": u,
|
|
98
|
+
"X-Featureflip-Client": d
|
|
99
|
+
}, f;
|
|
100
|
+
n.body !== void 0 && (o["Content-Type"] = "application/json", f = JSON.stringify(n.body)), n.idempotencyKey && (o["Idempotency-Key"] = n.idempotencyKey), n.ifMatch && (o["If-Match"] = a(n.ifMatch)), n.reason?.trim() && (o["X-Intent-Reason"] = encodeURIComponent(n.reason)), n.freezeOverride && (o["X-Freeze-Override"] = "true");
|
|
101
|
+
let p = c.has(e) && !n.ifMatch || n.idempotencyKey !== void 0, m;
|
|
102
|
+
for (let t = 0;; t++) {
|
|
103
|
+
let n = t < l.length;
|
|
104
|
+
try {
|
|
105
|
+
m = await this.fetchImpl(r.toString(), {
|
|
106
|
+
method: e,
|
|
107
|
+
headers: o,
|
|
108
|
+
body: f
|
|
109
|
+
});
|
|
110
|
+
} catch (e) {
|
|
111
|
+
if (!p || !n) throw e;
|
|
112
|
+
await this.sleep(l[t]);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (!(p ? s.has(m.status) : m.status === 503) || !n) break;
|
|
116
|
+
await m.body?.cancel(), await this.sleep(l[t]);
|
|
117
|
+
}
|
|
118
|
+
let h = m.headers.get("etag") ?? void 0;
|
|
119
|
+
if (m.status === 204) return {
|
|
120
|
+
data: void 0,
|
|
121
|
+
etag: h
|
|
122
|
+
};
|
|
123
|
+
if (!m.ok) {
|
|
124
|
+
let e;
|
|
125
|
+
try {
|
|
126
|
+
if (e = await m.json(), typeof e?.error != "string") throw Error("not an envelope");
|
|
127
|
+
} catch {
|
|
128
|
+
e = {
|
|
129
|
+
error: `http_${m.status}`,
|
|
130
|
+
message: `HTTP ${m.status} from ${r.pathname}`
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
throw new i(m.status, e);
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
data: await m.json(),
|
|
137
|
+
etag: h
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
// src/errors.ts
|
|
142
|
+
function p(e) {
|
|
143
|
+
let t = [{
|
|
144
|
+
type: "text",
|
|
145
|
+
text: JSON.stringify(e, null, 2)
|
|
146
|
+
}];
|
|
147
|
+
return typeof e == "object" && e && !Array.isArray(e) ? {
|
|
148
|
+
content: t,
|
|
149
|
+
structuredContent: e
|
|
150
|
+
} : { content: t };
|
|
151
|
+
}
|
|
152
|
+
function m(e, t = {}) {
|
|
153
|
+
if (e instanceof i) {
|
|
154
|
+
let n = e.envelope, r = [`Featureflip API error ${e.status} (${n.error}): ${n.message}`];
|
|
155
|
+
if (n.fields && r.push(`Field errors: ${JSON.stringify(n.fields)}`), n.did_you_mean?.length && r.push(`Did you mean: ${n.did_you_mean.join(", ")}`), n.next_actions?.length && r.push(`Next actions: ${n.next_actions.map((e) => `${e.method} ${e.path}`).join("; ")}`), n.retry_after != null && r.push(`Rate limited — retry after ${n.retry_after}s.`), e.status === 404 && r.push("Note: 404 can also mean the public Management API is not enabled for this organization yet, or a service token does not include this project."), e.status === 412 && r.push(t.preconditionFailedHint ?? "The resource changed since it was read. If you passed ifMatch, re-read it (get_flag / get_targeting / get_segment), re-apply your change to what you read, and retry with the new etag. Otherwise the tool read it itself and lost a race: call it again."), n.error === "change_reason_required" && r.push("Retry this tool call with the `reason` argument explaining why you are making the change."), n.error === "change_frozen" && n.change_freeze) {
|
|
156
|
+
let e = n.change_freeze, t = e.ends_at ? `until ${e.ends_at}` : "until it is ended";
|
|
157
|
+
r.push(`Change freeze "${e.name}" covers environment ${e.environment_key} ${t}.` + (e.can_override ? " You can break it for this one change: retry with `reason` and `freeze_override: true`." : " Your token cannot override it: ask an Owner or Admin to make the change or end the freeze."));
|
|
158
|
+
}
|
|
159
|
+
return n.docs_url && r.push(`Docs: ${n.docs_url}`), {
|
|
160
|
+
content: [{
|
|
161
|
+
type: "text",
|
|
162
|
+
text: r.join("\n")
|
|
163
|
+
}],
|
|
164
|
+
isError: !0
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
content: [{
|
|
169
|
+
type: "text",
|
|
170
|
+
text: `Error: ${e instanceof Error ? e.message : String(e)}`
|
|
171
|
+
}],
|
|
172
|
+
isError: !0
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
async function h(e) {
|
|
176
|
+
try {
|
|
177
|
+
return await e();
|
|
178
|
+
} catch (e) {
|
|
179
|
+
return m(e);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
var g = {
|
|
183
|
+
endpoints: {
|
|
184
|
+
"GET /api/v1/orgs/{org}/change-freezes": "PublicChangeFreezeResponsePagedResult",
|
|
185
|
+
"POST /api/v1/orgs/{org}/change-freezes": "PublicChangeFreezeResponse",
|
|
186
|
+
"GET /api/v1/orgs/{org}/change-freezes/{id}": "PublicChangeFreezeResponse",
|
|
187
|
+
"PATCH /api/v1/orgs/{org}/change-freezes/{id}": "PublicChangeFreezeResponse",
|
|
188
|
+
"POST /api/v1/orgs/{org}/change-freezes/{id}/end": "PublicChangeFreezeResponse",
|
|
189
|
+
"POST /api/v1/orgs/{org}/change-freezes/{id}/approvals": "PublicFreezeApprovalResponse",
|
|
190
|
+
"POST /api/v1/orgs/{org}/projects/{project}/environments": "PublicEnvironmentResponse",
|
|
191
|
+
"GET /api/v1/orgs/{org}/projects/{project}/environments": "PublicEnvironmentResponsePagedResult",
|
|
192
|
+
"GET /api/v1/orgs/{org}/projects/{project}/environments/{env}": "PublicEnvironmentResponse",
|
|
193
|
+
"POST /api/v1/orgs/{org}/projects/{project}/flags": "PublicFlagResponse",
|
|
194
|
+
"GET /api/v1/orgs/{org}/projects/{project}/flags": "PublicFlagListItemPagedResult",
|
|
195
|
+
"GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}/compare": "PublicFlagComparison",
|
|
196
|
+
"GET /api/v1/orgs/{org}/projects/{project}/flags/removal-candidates": "PublicFlagRemovalCandidatePagedResult",
|
|
197
|
+
"GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}": "PublicFlagResponse",
|
|
198
|
+
"GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}": "PublicFlagEnvConfigResponse",
|
|
199
|
+
"POST /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/copy": "PublicCopyResult",
|
|
200
|
+
"GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/evaluations": "PublicFlagEvaluationsResponse",
|
|
201
|
+
"GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/targeting": "PublicTargetingConfigResponse",
|
|
202
|
+
"POST /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/rules": "PublicTargetingRuleResponse",
|
|
203
|
+
"GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/rules/{ruleId}": "PublicTargetingRuleResponse",
|
|
204
|
+
"POST /api/v1/orgs/{org}/projects/{project}/flags/{flag}/variations": "PublicVariationResponse",
|
|
205
|
+
"GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/versions": "PublicFlagVersionSummaryPagedResult",
|
|
206
|
+
"GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/versions/{number}": "PublicFlagVersion",
|
|
207
|
+
"GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/versions/{number}/diff": "PublicFlagVersionDiff",
|
|
208
|
+
"POST /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/versions/{number}/restore": "PublicRestoreFlagVersionResult",
|
|
209
|
+
"POST /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/triggers": "PublicFlagTriggerWithUrlResponse",
|
|
210
|
+
"GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/triggers": "PublicFlagTriggerResponsePagedResult",
|
|
211
|
+
"GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/triggers/{trigger}": "PublicFlagTriggerResponse",
|
|
212
|
+
"PUT /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/triggers/{trigger}": "PublicFlagTriggerResponse",
|
|
213
|
+
"POST /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/triggers/{trigger}/rotate": "PublicFlagTriggerWithUrlResponse",
|
|
214
|
+
"GET /api/v1/me": "MeResponse",
|
|
215
|
+
"GET /api/v1/orgs": "OrganizationResponsePagedResult",
|
|
216
|
+
"GET /api/v1/orgs/{org}": "OrganizationResponse",
|
|
217
|
+
"POST /api/v1/orgs/{org}/projects": "ProjectResponse",
|
|
218
|
+
"GET /api/v1/orgs/{org}/projects": "ProjectResponsePagedResult",
|
|
219
|
+
"GET /api/v1/orgs/{org}/projects/{project}": "ProjectResponse",
|
|
220
|
+
"GET /api/v1/orgs/{org}/projects/{project}/compare": "PublicFlagComparisonRowPagedResult",
|
|
221
|
+
"GET /api/v1/orgs/{org}/projects/{project}/default-flag-lifetime/impact": "PublicDefaultFlagLifetimeImpact",
|
|
222
|
+
"GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/ramps": "PublicRolloutRampResponsePagedResult",
|
|
223
|
+
"GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/ramps/{rampId}": "PublicRolloutRampResponse",
|
|
224
|
+
"POST /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/rules/{ruleId}/ramp": "PublicRolloutRampResponse",
|
|
225
|
+
"POST /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/default-rule/ramp": "PublicRolloutRampResponse",
|
|
226
|
+
"POST /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/ramps/{rampId}/pause": "PublicRolloutRampResponse",
|
|
227
|
+
"POST /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/ramps/{rampId}/resume": "PublicRolloutRampResponse",
|
|
228
|
+
"POST /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/ramps/{rampId}/advance": "PublicRolloutRampResponse",
|
|
229
|
+
"POST /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/ramps/{rampId}/abort": "PublicRolloutRampResponse",
|
|
230
|
+
"POST /api/v1/orgs/{org}/projects/{project}/environments/{env}/sdk-keys": "PublicCreateSdkKeyResponse",
|
|
231
|
+
"GET /api/v1/orgs/{org}/projects/{project}/environments/{env}/sdk-keys": "PublicSdkKeyResponsePagedResult",
|
|
232
|
+
"GET /api/v1/orgs/{org}/projects/{project}/environments/{env}/sdk-keys/{sdkKey}": "PublicSdkKeyResponse",
|
|
233
|
+
"POST /api/v1/orgs/{org}/projects/{project}/segments": "PublicSegmentResponse",
|
|
234
|
+
"GET /api/v1/orgs/{org}/projects/{project}/segments": "PublicSegmentResponsePagedResult",
|
|
235
|
+
"GET /api/v1/orgs/{org}/projects/{project}/segments/{segment}": "PublicSegmentResponse",
|
|
236
|
+
"GET /api/v1/orgs/{org}/webhooks": "PublicWebhookSubscriptionResponsePagedResult",
|
|
237
|
+
"POST /api/v1/orgs/{org}/webhooks": "PublicCreateWebhookSubscriptionResponse",
|
|
238
|
+
"GET /api/v1/orgs/{org}/webhooks/{id}": "PublicWebhookSubscriptionResponse",
|
|
239
|
+
"POST /api/v1/orgs/{org}/webhooks/{id}/secrets": "PublicRotateWebhookSecretResponse",
|
|
240
|
+
"POST /api/v1/orgs/{org}/webhooks/{id}/test": "PublicTestWebhookSubscriptionResponse",
|
|
241
|
+
"GET /api/v1/orgs/{org}/webhooks/{id}/deliveries": "PublicWebhookDeliveryResponsePagedResult"
|
|
242
|
+
},
|
|
243
|
+
$defs: /* @__PURE__ */ JSON.parse("{\"ActionCapability\":{\"type\":[\"object\",\"null\"],\"properties\":{\"allowed\":{\"type\":[\"boolean\",\"null\"]},\"reason\":{\"type\":[\"string\",\"null\"]}},\"description\":\"One entry in a resource's `_actions` block: may the caller perform it, and if not, why.\"},\"MeResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"type\":{\"type\":[\"string\",\"null\"]},\"id\":{\"type\":[\"string\",\"null\"]},\"name\":{\"type\":[\"string\",\"null\"]},\"email\":{\"type\":[\"string\",\"null\"]},\"emailVerified\":{\"type\":[\"boolean\",\"null\"]},\"organizationId\":{\"type\":[\"string\",\"null\"]},\"role\":{\"type\":[\"string\",\"null\"]},\"projectScope\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}}},\"description\":\"The authenticated caller's identity, returned by `GET /api/v1/me`. The public API\\nauthenticates two kinds of principal, so this is a `type`-discriminated shape.\\nA `\\\"user\\\"` caller (a session/JWT user or a personal access token, `ffp_...`) carries\\n`email` + `emailVerified`. A `\\\"service_token\\\"` caller (`ffs_...`) has no\\nbacking user row, so it carries `organizationId` + `role` + `projectScope` (the\\ntoken's org, its role in that org, and its project allowlist) instead. The type-inapplicable\\nfields are omitted from the response body. `projectScope` is omitted for an unrestricted\\nservice token (access to every project), never an empty list.\"},\"NextAction\":{\"type\":[\"object\",\"null\"],\"properties\":{\"method\":{\"type\":[\"string\",\"null\"]},\"path\":{\"type\":[\"string\",\"null\"]}}},\"OrganizationResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"id\":{\"type\":[\"string\",\"null\"]},\"name\":{\"type\":[\"string\",\"null\"]},\"slug\":{\"type\":[\"string\",\"null\"]},\"plan\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: Solo, Team, Pro, Business, Enterprise.\"},\"isActive\":{\"type\":[\"boolean\",\"null\"]},\"createdAt\":{\"type\":[\"string\",\"null\"]},\"limits\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicPlanLimits\"},{\"type\":\"null\"}]}},\"description\":\"Public representation of an organization, returned by both `GET /api/v1/orgs` (list) and\\n`GET /api/v1/orgs/{org}` (detail). Drops dashboard-only fields (`BillingEmail` is\\nbilling-contact PII, `UpdatedAt` is dashboard audit trivia) from the dashboard's\\nOrganizationDto/OrganizationListItemDto.\"},\"OrganizationResponsePagedResult\":{\"type\":[\"object\",\"null\"],\"properties\":{\"items\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/OrganizationResponse\"},{\"type\":\"null\"}]}},\"next_cursor\":{\"type\":[\"string\",\"null\"]},\"_actions\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#/$defs/ActionCapability\"},{\"type\":\"null\"}]},\"description\":\"Capability hints: which operations the authenticated caller may perform on this resource, each with allowed + optional reason. Computed from the caller's role and the resource's state. Injected at runtime; safe to ignore. Present only on top-level resource responses — nested occurrences (e.g. a rule inside a targeting-config response) do not carry it.\"}},\"description\":\"A page of results plus an opaque cursor for the next page, or null when this is the last\\npage. Wire keys are frozen: `items` (already lowercase under the camelCase policy) and\\n`next_cursor` (pinned explicitly — the policy alone would emit `nextCursor`).\"},\"ProjectResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"id\":{\"type\":[\"string\",\"null\"]},\"key\":{\"type\":[\"string\",\"null\"]},\"name\":{\"type\":[\"string\",\"null\"]},\"description\":{\"type\":[\"string\",\"null\"]},\"createdAt\":{\"type\":[\"string\",\"null\"]},\"updatedAt\":{\"type\":[\"string\",\"null\"]},\"defaultFlagLifetimeDays\":{\"type\":[\"integer\",\"null\"]},\"_actions\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#/$defs/ActionCapability\"},{\"type\":\"null\"}]},\"description\":\"Capability hints: which operations the authenticated caller may perform on this resource, each with allowed + optional reason. Computed from the caller's role and the resource's state. Injected at runtime; safe to ignore. Present only on top-level resource responses — nested occurrences (e.g. a rule inside a targeting-config response) do not carry it.\"}},\"description\":\"Public representation of a project, returned by `GET /api/v1/orgs/{org}/projects` (list),\\n`GET .../projects/{project}` (detail), and the body of a successful create/update. Drops\\nthe dashboard-only nested `Environments` collection from ProjectDto — the\\npublic API surfaces environments via their own endpoint (Task 6), not embedded here.\\nUpdatedAt is only populated from ProjectDto (the detail/create\\nshape); ProjectListItemDto doesn't carry it, so list rows leave it `null`.\\nDefaultFlagLifetimeDays is the project's default flag lifetime in days, or null (#3194).\"},\"ProjectResponsePagedResult\":{\"type\":[\"object\",\"null\"],\"properties\":{\"items\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/ProjectResponse\"},{\"type\":\"null\"}]}},\"next_cursor\":{\"type\":[\"string\",\"null\"]},\"_actions\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#/$defs/ActionCapability\"},{\"type\":\"null\"}]},\"description\":\"Capability hints: which operations the authenticated caller may perform on this resource, each with allowed + optional reason. Computed from the caller's role and the resource's state. Injected at runtime; safe to ignore. Present only on top-level resource responses — nested occurrences (e.g. a rule inside a targeting-config response) do not carry it.\"}},\"description\":\"A page of results plus an opaque cursor for the next page, or null when this is the last\\npage. Wire keys are frozen: `items` (already lowercase under the camelCase policy) and\\n`next_cursor` (pinned explicitly — the policy alone would emit `nextCursor`).\"},\"PublicAbortRolloutRampRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"percent\":{\"type\":[\"integer\",\"null\"]}},\"description\":\"Request body for `POST …/ramps/{rampId}/abort`: the percentage (0-100) to leave the rule at. Required, so\\na missing value is a 400 rather than an abort to 0%.\"},\"PublicAddVariationRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"key\":{\"type\":[\"string\",\"null\"]},\"name\":{\"type\":[\"string\",\"null\"]},\"value\":{\"type\":[\"string\",\"null\"]},\"description\":{\"type\":[\"string\",\"null\"]}},\"description\":\"Request body for\\n`POST /api/v1/orgs/{org}/projects/{project}/flags/{flag}/variations`. Named distinctly\\nfrom the dashboard's own `AddVariationRequest` —\\nsee PublicCreateEnvironmentRequest for the schemaId-collision rationale (both\\ncontrollers share one Swagger document).\"},\"PublicAdvanceRolloutRampRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"expectedStepIndex\":{\"type\":[\"integer\",\"null\"]}},\"description\":\"Request body for `POST …/ramps/{rampId}/advance`: the `currentStepIndex` the caller last saw. If the\\nramp has moved on since, the advance is a 409, so two racing advances can't skip a step.\"},\"PublicApiErrorEnvelope\":{\"type\":[\"object\",\"null\"],\"properties\":{\"error\":{\"type\":[\"string\",\"null\"]},\"message\":{\"type\":[\"string\",\"null\"]},\"docs_url\":{\"type\":[\"string\",\"null\"]},\"fields\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}}},\"retry_after\":{\"type\":[\"integer\",\"null\"]},\"did_you_mean\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"next_actions\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/NextAction\"},{\"type\":\"null\"}]}},\"connection_id\":{\"type\":[\"string\",\"null\"]},\"plan_limit\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicPlanLimit\"},{\"type\":\"null\"}]},\"change_freeze\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicChangeFreeze\"},{\"type\":\"null\"}]}},\"description\":\"The frozen public-API error contract. `error` codes are stable snake_case strings. Wire keys\\nare frozen snake_case too (`error`, `message`, `docs_url`, `fields`,\\n`retry_after`) — the global camelCase naming policy would otherwise emit\\n`docsUrl`/`retryAfter`, breaking the published spec. !:JsonPropertyName\\nalways wins over the policy, so these are pinned explicitly rather than relying on the\\nproperty names already being lowercase for the single-word ones.\\n`did_you_mean`, `next_actions` and `connection_id` are ADDITIVE optional keys\\n(null → omitted via the global `DefaultIgnoreCondition = WhenWritingNull`), so\\npre-existing error bodies are byte-for-byte unchanged when they're absent.\\n\\n`connection_id` is present only on the `sso_required` error: the organization\\nrequires single sign-on, and this credential didn't come through its identity provider.\\n`connection_id` identifies which SSO connection to sign in with.\\n`plan_limit` is present only on the `plan_limit_reached` error: which plan cap the\\nrequest would have exceeded, so a client can branch on it without parsing `message`.\\n`change_freeze` is present only on the `change_frozen` error (#4645): the change freeze that refused the\\nwrite, so a client can show when it ends and whether the caller may break it, without parsing `message`.\"},\"PublicChangeFreeze\":{\"type\":[\"object\",\"null\"],\"properties\":{\"id\":{\"type\":[\"string\",\"null\"]},\"name\":{\"type\":[\"string\",\"null\"]},\"environment_key\":{\"type\":[\"string\",\"null\"]},\"ends_at\":{\"type\":[\"string\",\"null\"]},\"can_override\":{\"type\":[\"boolean\",\"null\"]}},\"description\":\"The freeze behind a `change_frozen` error: `id` and `name` of the window, the environment's\\n`environment_key`, `ends_at` (UTC; always present, null for an open-ended window) and whether the caller's role may\\nbreak it (`can_override`, with `X-Freeze-Override: true` and an `X-Intent-Reason`).\"},\"PublicChangeFreezeResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"id\":{\"type\":[\"string\",\"null\"]},\"project\":{\"type\":[\"string\",\"null\"]},\"name\":{\"type\":[\"string\",\"null\"]},\"reason\":{\"type\":[\"string\",\"null\"]},\"allEnvironments\":{\"type\":[\"boolean\",\"null\"]},\"environmentKeys\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"environmentIds\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"startsAt\":{\"type\":[\"string\",\"null\"]},\"endsAt\":{\"type\":[\"string\",\"null\"]},\"endedAt\":{\"type\":[\"string\",\"null\"]},\"scheduledChangePolicy\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: Hold, Fail.\"},\"status\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: Upcoming, Active, Ended.\"},\"enforcing\":{\"type\":[\"boolean\",\"null\"]},\"wontStartReason\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: Plan.\"},\"approvals\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicFreezeApprovalResponse\"},{\"type\":\"null\"}]}},\"createdByEmail\":{\"type\":[\"string\",\"null\"]},\"_actions\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#/$defs/ActionCapability\"},{\"type\":\"null\"}]},\"description\":\"Capability hints: which operations the authenticated caller may perform on this resource, each with allowed + optional reason. Computed from the caller's role and the resource's state. Injected at runtime; safe to ignore. Present only on top-level resource responses — nested occurrences (e.g. a rule inside a targeting-config response) do not carry it.\"}},\"description\":\"A change freeze window. `project` is the project's key, or null for an organization-wide window.\\nAn organization-wide window names its environments by key (`environmentKeys`, matched in every project);\\na project window names them by id, and returns both `environmentIds` and the current\\n`environmentKeys` of those environments. `status` is time-based only: `Upcoming`, `Active`\\nor `Ended`. `enforcing` is true when the window is `Active` and is actually in force: it has\\nstarted enforcing, or the organization's plan includes change freezes. `wontStartReason` is `Plan`\\nwhen the window has not started enforcing and the organization's plan no longer includes change freezes, so it\\nwill not enforce. `approvals` lists the scheduled changes approved to land inside the window.\"},\"PublicChangeFreezeResponsePagedResult\":{\"type\":[\"object\",\"null\"],\"properties\":{\"items\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicChangeFreezeResponse\"},{\"type\":\"null\"}]}},\"next_cursor\":{\"type\":[\"string\",\"null\"]},\"_actions\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#/$defs/ActionCapability\"},{\"type\":\"null\"}]},\"description\":\"Capability hints: which operations the authenticated caller may perform on this resource, each with allowed + optional reason. Computed from the caller's role and the resource's state. Injected at runtime; safe to ignore. Present only on top-level resource responses — nested occurrences (e.g. a rule inside a targeting-config response) do not carry it.\"}},\"description\":\"A page of results plus an opaque cursor for the next page, or null when this is the last\\npage. Wire keys are frozen: `items` (already lowercase under the camelCase policy) and\\n`next_cursor` (pinned explicitly — the policy alone would emit `nextCursor`).\"},\"PublicConditionGroupRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"operator\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: And, Or.\"},\"conditions\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicConditionRequest\"},{\"type\":\"null\"}]}}},\"description\":\"Request-side condition group, symmetric with PublicConditionGroupResponse.\"},\"PublicConditionGroupResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"operator\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: And, Or.\"},\"conditions\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicConditionResponse\"},{\"type\":\"null\"}]}}},\"description\":\"A condition group within a PublicTargetingRuleResponse. Maps 1:1 onto\\nConditionGroupDto. Operator is a bare wire string naming one of\\nthe `ConditionGroupOperator` members (`\\\"And\\\"`/`\\\"Or\\\"`) —\\ngroups are ANDed together at the rule level; within a group, its conditions combine using\\nthis operator.\"},\"PublicConditionRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"attribute\":{\"type\":[\"string\",\"null\"]},\"operator\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: Equals, NotEquals, Contains, NotContains, GreaterThan, LessThan, GreaterThanOrEqual, LessThanOrEqual, In, NotIn, MatchesRegex, StartsWith, EndsWith, Before, After, SemverEquals, SemverGreaterThan, SemverGreaterThanOrEqual, SemverLessThan, SemverLessThanOrEqual.\"},\"values\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"negate\":{\"type\":[\"boolean\",\"null\"]}},\"description\":\"Request-side condition, symmetric with PublicConditionResponse.\"},\"PublicConditionResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"attribute\":{\"type\":[\"string\",\"null\"]},\"operator\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: Equals, NotEquals, Contains, NotContains, GreaterThan, LessThan, GreaterThanOrEqual, LessThanOrEqual, In, NotIn, MatchesRegex, StartsWith, EndsWith, Before, After, SemverEquals, SemverGreaterThan, SemverGreaterThanOrEqual, SemverLessThan, SemverLessThanOrEqual.\"},\"values\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"negate\":{\"type\":[\"boolean\",\"null\"]}},\"description\":\"A single condition within a PublicConditionGroupResponse. Maps 1:1 onto\\nConditionDto. Operator is a bare wire string naming one of the\\n`OperatorType` members (e.g. `\\\"Equals\\\"`, `\\\"In\\\"`).\"},\"PublicConfiguredWeight\":{\"type\":[\"object\",\"null\"],\"properties\":{\"variationKey\":{\"type\":[\"string\",\"null\"],\"description\":\"The variation's key.\"},\"name\":{\"type\":[\"string\",\"null\"],\"description\":\"The variation's name, or null when the key no longer matches one of the flag's variations.\"},\"weight\":{\"type\":[\"integer\",\"null\"],\"description\":\"Percent of the rule's traffic.\"}},\"description\":\"A variation's configured share of a rollout rule.\"},\"PublicCopyFlagConfigRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"source\":{\"type\":[\"string\",\"null\"]},\"includeState\":{\"type\":[\"boolean\",\"null\"]},\"dryRun\":{\"type\":[\"boolean\",\"null\"]},\"expectedSourceETag\":{\"type\":[\"string\",\"null\"]},\"expectedTargetETag\":{\"type\":[\"string\",\"null\"]}},\"description\":\"Request body for `POST .../flags/{flag}/environments/{env}/copy`. `source` is the environment to copy\\nfrom (key or id) and is required; the rest are optional. `dryRun: true` previews without writing and ignores\\nthe ETags.\"},\"PublicCopyResult\":{\"type\":[\"object\",\"null\"],\"properties\":{\"changed\":{\"type\":[\"boolean\",\"null\"]},\"changedSections\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"before\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicEnvironmentSnapshot\"},{\"type\":\"null\"}]},\"after\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicEnvironmentSnapshot\"},{\"type\":\"null\"}]},\"sourceETag\":{\"type\":[\"string\",\"null\"]},\"targetETag\":{\"type\":[\"string\",\"null\"]},\"warnings\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicCopyWarning\"},{\"type\":\"null\"}]}}},\"description\":\"Response of `POST .../flags/{flag}/environments/{env}/copy`, for a dry run and an apply alike.\\n`targetETag` is the target's tag after an apply and before it on a dry run, so a dry run's tags are\\nwhat the apply sends back as `expectedSourceETag` / `expectedTargetETag`.\"},\"PublicCopyWarning\":{\"type\":[\"object\",\"null\"],\"properties\":{\"code\":{\"type\":[\"string\",\"null\"]},\"message\":{\"type\":[\"string\",\"null\"]}},\"description\":\"A non-blocking note about a copy.\"},\"PublicCreateChangeFreezeRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"name\":{\"type\":[\"string\",\"null\"]},\"reason\":{\"type\":[\"string\",\"null\"]},\"project\":{\"type\":[\"string\",\"null\"]},\"allEnvironments\":{\"type\":[\"boolean\",\"null\"]},\"environmentKeys\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"environmentIds\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"startsAt\":{\"type\":[\"string\",\"null\"]},\"endsAt\":{\"type\":[\"string\",\"null\"]},\"scheduledChangePolicy\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: Hold, Fail.\"}},\"description\":\"Creates a change freeze. `project` (key or id) makes it a project window; omit it for an\\norganization-wide one. Omit `startsAt` to freeze now (then `endsAt` may be omitted for an\\nopen-ended freeze); a scheduled freeze needs both. Times are UTC and must carry an offset (`Z`).\\nName the environments with `environmentKeys` (a project window accepts keys too, resolved within\\nthe project) and/or `environmentIds`, or set `allEnvironments`.\\n`scheduledChangePolicy` is `Hold` (the default) or `Fail`.\"},\"PublicCreateEnvironmentRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"key\":{\"type\":[\"string\",\"null\"],\"description\":\"The environment's key.\"},\"name\":{\"type\":[\"string\",\"null\"],\"description\":\"The environment's display name.\"},\"color\":{\"type\":[\"string\",\"null\"],\"description\":\"The environment's display color, or null.\"},\"sortOrder\":{\"type\":[\"integer\",\"null\"],\"description\":\"Position among the project's environments.\"},\"requireChangeReason\":{\"type\":[\"boolean\",\"null\"],\"description\":\"Require a change reason (X-Intent-Reason) on every change to flags in this environment. Business plan and above.\"},\"requireConfirmation\":{\"type\":[\"boolean\",\"null\"],\"description\":\"Ask dashboard users to type the environment key before a change lands. Dashboard only; not enforced by the API.\"}},\"description\":\"Request body for `POST /api/v1/orgs/{org}/projects/{project}/environments`. Named\\ndistinctly from the dashboard's own `CreateEnvironmentRequest`\\n— both controllers share one Swagger document (see `Program.cs`'s `AddSwaggerGen``DocInclusionPredicate` override), and Swashbuckle's default schemaId is the bare type\\nname, so an identical name in either namespace throws a schemaId collision at\\n`--export-openapi` time.\"},\"PublicCreateFeatureFlagRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"key\":{\"type\":[\"string\",\"null\"]},\"name\":{\"type\":[\"string\",\"null\"]},\"type\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: Boolean, String, Number, Json.\"},\"description\":{\"type\":[\"string\",\"null\"]},\"tags\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"initialVariations\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicCreateVariationDto\"},{\"type\":\"null\"}]}},\"clientSideVisible\":{\"type\":[\"boolean\",\"null\"]},\"expiresAtUtc\":{\"type\":[\"string\",\"null\"]},\"ownerEmail\":{\"type\":[\"string\",\"null\"]},\"isPermanent\":{\"type\":[\"boolean\",\"null\"]}},\"description\":\"Request body for `POST /api/v1/orgs/{org}/projects/{project}/flags`. Named distinctly\\nfrom the dashboard's own `CreateFeatureFlagRequest`\\n— see PublicCreateEnvironmentRequest for the\\nschemaId-collision rationale (both controllers share one Swagger document). Type\\nis passed through verbatim to Type, which itself takes a\\nbare string (Boolean/String/Number/Json) rather than the domain enum — invalid values surface\\nas the handler's own validation failure, not a controller-level 400. ExpiresAtUtc is\\noptional and advisory; a bare date (`2026-12-01`) means the end of that day in UTC, and a full\\ntimestamp is stored exactly. It must be in the future and requires the flag-expiration feature\\n(400 `EXPIRY_IN_PAST` / `FEATURE_NOT_ENABLED`). OwnerEmail optionally names\\nthe owner (an active member, matched case-insensitively; requires a plan that includes flag owners,\\nPro and above — 400 `OWNER_NOT_MEMBER` / `PLAN_FEATURE_UNAVAILABLE`). Omitted, the owner is the caller when\\nthe caller is a member, so a service token creates an unowned flag. IsPermanent marks\\nthe flag permanent (a kill switch, ops toggle or entitlement that is meant to stay; never reported for\\ncleanup). It requires the flag-permanence feature and can't be combined with ExpiresAtUtc\\n(400 `FEATURE_NOT_ENABLED` / `PERMANENT_FLAG_HAS_EXPIRY`).\"},\"PublicCreateFlagTriggerRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"name\":{\"type\":[\"string\",\"null\"]},\"action\":{\"type\":[\"string\",\"null\"]},\"description\":{\"type\":[\"string\",\"null\"]}},\"description\":\"Request body for `POST .../triggers`. Action is `\\\"Enable\\\"` or\\n`\\\"Disable\\\"`, parsed against the names only. Named apart from the dashboard's\\n`CreateFlagTriggerRequest`: both controllers share one Swagger document.\"},\"PublicCreateProjectRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"key\":{\"type\":[\"string\",\"null\"]},\"name\":{\"type\":[\"string\",\"null\"]},\"description\":{\"type\":[\"string\",\"null\"]}},\"description\":\"Request body for `POST /api/v1/orgs/{org}/projects`. Named distinctly from the\\ndashboard's own `CreateProjectRequest` — both\\ncontrollers share one Swagger document (see `Program.cs`'s `AddSwaggerGen``DocInclusionPredicate` override), and Swashbuckle's default schemaId is the bare type\\nname, so an identical name in either namespace throws a schemaId collision at\\n`--export-openapi` time.\"},\"PublicCreateSdkKeyRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"name\":{\"type\":[\"string\",\"null\"]},\"description\":{\"type\":[\"string\",\"null\"]},\"type\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: ClientSide, ServerSide.\"}},\"description\":\"Request body for `POST /api/v1/orgs/{org}/projects/{project}/environments/{env}/sdk-keys`.\\nType is a bare string (\\\"ClientSide\\\" or \\\"ServerSide\\\") — the controller parses it\\nagainst a NAME allowlist (not a bare TryParse``1(ReadOnlySpan{Char},Boolean,``0@), which would\\nsilently accept a numeric string like `\\\"0\\\"`) before dispatching. Named distinctly from\\nthe dashboard's own `CreateSdkKeyRequest` — both\\ncontrollers share one Swagger document, and an identical type name in either namespace throws\\na schemaId collision at `--export-openapi` time.\"},\"PublicCreateSdkKeyResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"id\":{\"type\":[\"string\",\"null\"]},\"key\":{\"type\":[\"string\",\"null\"]},\"lastFourCharacters\":{\"type\":[\"string\",\"null\"]},\"type\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: ClientSide, ServerSide.\"},\"name\":{\"type\":[\"string\",\"null\"]},\"createdAt\":{\"type\":[\"string\",\"null\"]},\"warning\":{\"type\":[\"string\",\"null\"]}},\"description\":\"Response body for a successful `POST .../sdk-keys`. The ONLY place the plaintext\\nKey is ever returned — PublicSdkKeyResponse (list/get) carries just\\n`LastFourCharacters`. Built directly from CreateSdkKeyResult rather than a\\nre-fetch (unlike `FeatureFlagsController.Create`'s re-fetch pattern) because the\\nplaintext key only ever exists on the create result — a subsequent\\nGetSdkKeyQuery can't recover it.\"},\"PublicCreateSegmentRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"key\":{\"type\":[\"string\",\"null\"]},\"name\":{\"type\":[\"string\",\"null\"]},\"description\":{\"type\":[\"string\",\"null\"]},\"conditions\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicSegmentConditionDto\"},{\"type\":\"null\"}]}}},\"description\":\"Request body for `POST /api/v1/orgs/{org}/projects/{project}/segments`. Named distinctly\\nfrom the dashboard's own `CreateUserSegmentRequest` — see\\nPublicCreateEnvironmentRequest for the schemaId-collision rationale (both\\ncontrollers share one Swagger document).\"},\"PublicCreateTargetingRuleRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"description\":{\"type\":[\"string\",\"null\"]},\"variationId\":{\"type\":[\"string\",\"null\"]},\"rolloutPercentage\":{\"type\":[\"integer\",\"null\"]},\"userSegmentId\":{\"type\":[\"string\",\"null\"]},\"conditionGroups\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicConditionGroupRequest\"},{\"type\":\"null\"}]}},\"bucketBy\":{\"type\":[\"string\",\"null\"],\"description\":\"Context attribute the rollout hashes on (default `user_id`; `userId` is accepted as an alias). A context without it skips this rule, even at 100%. Changing it reshuffles who is in the rollout. A fixed rule (no `rolloutPercentage`) never hashes and always stores `user_id`. When omitted on `PUT .../targeting`, a rollout keeps the value of the existing rollout it edits: the existing rule with the same targeting, told apart from others with that targeting by its variation, then its description, then its position. Any other rule gets `user_id`. The request is refused with 400 until it sends `bucketBy` for a rollout whose edited rule it can't tell when the answer changes its attribute: the rollout shares only its targeting with several rules that bucket differently, or it matches no existing rule while the request removes a rollout bucketed by another attribute. On create, omitting it gives `user_id`.\"}},\"description\":\"Request body for `POST .../rules`. The Application-side\\n`CreateTargetingRuleDto`/`CreateConditionGroupDto`/`CreateConditionDto` all take\\ntheir `Operator` as a bare string, re-parsed CASE-SENSITIVELY inside\\n`CreateTargetingRuleCommandHandler` — `FlagTargetingController`'s mapping helpers\\nvalidate every operator against the enum's member-name allowlist AND canonicalize the casing\\n(e.g. `\\\"in\\\"` → `\\\"In\\\"`) before building the command DTO, so a valid\\ncase-insensitive match never trips the handler's strict re-parse.\"},\"PublicCreateVariationDto\":{\"type\":[\"object\",\"null\"],\"properties\":{\"key\":{\"type\":[\"string\",\"null\"]},\"name\":{\"type\":[\"string\",\"null\"]},\"value\":{\"type\":[\"string\",\"null\"]},\"description\":{\"type\":[\"string\",\"null\"]}},\"description\":\"A variation supplied at flag-creation time. Maps 1:1 onto\\nCreateVariationDto.\"},\"PublicCreateWebhookSubscriptionRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"name\":{\"type\":[\"string\",\"null\"]},\"url\":{\"type\":[\"string\",\"null\"]},\"provider\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: GenericHttp, Slack, Datadog, Grafana.\"},\"eventTypes\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"projectIds\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"environmentIds\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"credential\":{\"type\":[\"string\",\"null\"]}},\"description\":\"Creates a webhook subscription. `provider` is `GenericHttp`, `Slack` (an incoming\\nwebhook url), `Datadog` (your site's Events API url) or `Grafana` (your Grafana's\\n`/api/annotations` url). Datadog and Grafana also need `credential`: a Datadog API key\\nor a Grafana service account token. It is stored encrypted and never returned. Omit `eventTypes`,\\n`projectIds` or `environmentIds` (or send an empty list) to receive every event,\\nproject or environment. A token restricted to specific projects must list at least one project,\\nall of them within its allowlist.\"},\"PublicCreateWebhookSubscriptionResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"id\":{\"type\":[\"string\",\"null\"]},\"secret\":{\"type\":[\"string\",\"null\"]},\"warning\":{\"type\":[\"string\",\"null\"]}},\"description\":\"The created subscription's id and its signing secret. The secret is shown only here.\"},\"PublicDefaultFlagLifetimeImpact\":{\"type\":[\"object\",\"null\"],\"properties\":{\"newlyPastExpiry\":{\"type\":[\"integer\",\"null\"]},\"noLongerPastExpiry\":{\"type\":[\"integer\",\"null\"]}},\"description\":\"Response of `GET .../default-flag-lifetime/impact`: how many temporary flags with no expiry\\ndate of their own would newly be past expiry, and how many would stop being past it.\"},\"PublicEnvironmentResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"id\":{\"type\":[\"string\",\"null\"],\"description\":\"The environment's id.\"},\"key\":{\"type\":[\"string\",\"null\"],\"description\":\"The environment's key.\"},\"name\":{\"type\":[\"string\",\"null\"],\"description\":\"The environment's display name.\"},\"color\":{\"type\":[\"string\",\"null\"],\"description\":\"The environment's display color, or null.\"},\"sortOrder\":{\"type\":[\"integer\",\"null\"],\"description\":\"Position among the project's environments.\"},\"requireChangeReason\":{\"type\":[\"boolean\",\"null\"],\"description\":\"Require a change reason (X-Intent-Reason) on every change to flags in this environment. Business plan and above.\"},\"requireConfirmation\":{\"type\":[\"boolean\",\"null\"],\"description\":\"Ask dashboard users to type the environment key before a change lands. Dashboard only; not enforced by the API.\"},\"_actions\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#/$defs/ActionCapability\"},{\"type\":\"null\"}]},\"description\":\"Capability hints: which operations the authenticated caller may perform on this resource, each with allowed + optional reason. Computed from the caller's role and the resource's state. Injected at runtime; safe to ignore. Present only on top-level resource responses — nested occurrences (e.g. a rule inside a targeting-config response) do not carry it.\"}},\"description\":\"Public representation of an environment, returned by\\n`GET /api/v1/orgs/{org}/projects/{project}/environments` (list),\\n`GET .../environments/{env}` (detail), and the body of a successful create/update. Drops\\ninternal fields (e.g. `ProjectId` is implicit in the route) — mirrors\\n`ProjectResponse`'s minimal shape. Named `PublicEnvironmentResponse` rather than\\n`EnvironmentResponse` (unlike the sibling `ProjectResponse`, which didn't collide)\\nbecause the dashboard already has its own\\n`EnvironmentResponse` — see\\nPublicCreateEnvironmentRequest for the schemaId-collision rationale.\"},\"PublicEnvironmentResponsePagedResult\":{\"type\":[\"object\",\"null\"],\"properties\":{\"items\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicEnvironmentResponse\"},{\"type\":\"null\"}]}},\"next_cursor\":{\"type\":[\"string\",\"null\"]},\"_actions\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#/$defs/ActionCapability\"},{\"type\":\"null\"}]},\"description\":\"Capability hints: which operations the authenticated caller may perform on this resource, each with allowed + optional reason. Computed from the caller's role and the resource's state. Injected at runtime; safe to ignore. Present only on top-level resource responses — nested occurrences (e.g. a rule inside a targeting-config response) do not carry it.\"}},\"description\":\"A page of results plus an opaque cursor for the next page, or null when this is the last\\npage. Wire keys are frozen: `items` (already lowercase under the camelCase policy) and\\n`next_cursor` (pinned explicitly — the policy alone would emit `nextCursor`).\"},\"PublicEnvironmentSideSummary\":{\"type\":[\"object\",\"null\"],\"properties\":{\"isEnabled\":{\"type\":[\"boolean\",\"null\"]},\"ruleCount\":{\"type\":[\"integer\",\"null\"]},\"prerequisiteCount\":{\"type\":[\"integer\",\"null\"]}},\"description\":\"One side's headline numbers in a project-level comparison row.\"},\"PublicEnvironmentSnapshot\":{\"type\":[\"object\",\"null\"],\"properties\":{\"isEnabled\":{\"type\":[\"boolean\",\"null\"]},\"defaultVariation\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicKeyedRef\"},{\"type\":\"null\"}]},\"strategy\":{\"type\":[\"string\",\"null\"]},\"fallthroughRolloutVariation\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicKeyedRef\"},{\"type\":\"null\"}]},\"fallthroughRolloutPercentage\":{\"type\":[\"integer\",\"null\"]},\"fallthroughBucketBy\":{\"type\":[\"string\",\"null\"]},\"rules\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicSnapshotRule\"},{\"type\":\"null\"}]}},\"prerequisites\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicPrerequisiteDto\"},{\"type\":\"null\"}]}}},\"description\":\"A flag's configuration in one environment, as a comparison, copy or version result reports it. The\\n`fallthroughRollout*` fields describe the default rule's rollout and are null unless it rolls out\\n(`fallthroughBucketBy` is then the attribute it hashes on, otherwise `user_id`).\"},\"PublicEvaluationSource\":{\"type\":[\"object\",\"null\"],\"properties\":{\"source\":{\"type\":[\"string\",\"null\"],\"description\":\"One of rule, fallthrough, off, prerequisite, error, notFound or unknown (an SDK that reports no reason, or evaluations recorded before sources were). Allowed values: rule, fallthrough, off, prerequisite, error, notFound, unknown.\"},\"ruleId\":{\"type\":[\"string\",\"null\"],\"description\":\"For a rule, its id (rules have no key). Null otherwise, or when the SDK didn't say which rule.\"},\"ruleLabel\":{\"type\":[\"string\",\"null\"],\"description\":\"For a live rule, its description or a generated label. Null otherwise.\"},\"ruleExists\":{\"type\":[\"boolean\",\"null\"],\"description\":\"False when the rule is no longer in the environment's targeting.\"},\"count\":{\"type\":[\"integer\",\"null\"],\"description\":\"Evaluations this source served.\"},\"share\":{\"type\":[\"number\",\"null\"],\"description\":\"Count as a fraction (0 to 1) of all sources' counts combined.\"},\"variations\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicEvaluationVariation\"},{\"type\":\"null\"}]},\"description\":\"What this source served, with shares of this source's count.\"},\"rollout\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicRolloutCheck\"},{\"type\":\"null\"}]}},\"description\":\"The evaluations one part of the targeting served.\"},\"PublicEvaluationVariation\":{\"type\":[\"object\",\"null\"],\"properties\":{\"variationKey\":{\"type\":[\"string\",\"null\"],\"description\":\"The variation served, or null for evaluations recorded without one.\"},\"name\":{\"type\":[\"string\",\"null\"],\"description\":\"The variation's name, or null when the key no longer matches one of the flag's variations.\"},\"exists\":{\"type\":[\"boolean\",\"null\"],\"description\":\"False when the key no longer matches one of the flag's variations.\"},\"count\":{\"type\":[\"integer\",\"null\"],\"description\":\"Evaluations that served this variation.\"},\"share\":{\"type\":[\"number\",\"null\"],\"description\":\"Count as a fraction (0 to 1) of the parent total: the window's total, or for a source's variations that source's count. 0 when the parent total is 0.\"}},\"description\":\"One variation's evaluations.\"},\"PublicFlagComparison\":{\"type\":[\"object\",\"null\"],\"properties\":{\"flagKey\":{\"type\":[\"string\",\"null\"]},\"differences\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"base\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicFlagComparisonSide\"},{\"type\":\"null\"}]},\"other\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicFlagComparisonSide\"},{\"type\":\"null\"}]}},\"description\":\"Response of `GET .../flags/{flag}/compare`.\"},\"PublicFlagComparisonRow\":{\"type\":[\"object\",\"null\"],\"properties\":{\"flagKey\":{\"type\":[\"string\",\"null\"]},\"flagName\":{\"type\":[\"string\",\"null\"]},\"tags\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"ownerUserId\":{\"type\":[\"string\",\"null\"]},\"status\":{\"type\":[\"string\",\"null\"]},\"differences\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"base\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicEnvironmentSideSummary\"},{\"type\":\"null\"}]},\"other\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicEnvironmentSideSummary\"},{\"type\":\"null\"}]}},\"description\":\"One flag in `GET .../projects/{project}/compare`. `differences` lists the sections that differ\\n(`state`, `defaultVariation`, `strategy`, `rules`, `prerequisites`). A side is null when\\nthe flag has no configuration in that environment.\"},\"PublicFlagComparisonRowPagedResult\":{\"type\":[\"object\",\"null\"],\"properties\":{\"items\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicFlagComparisonRow\"},{\"type\":\"null\"}]}},\"next_cursor\":{\"type\":[\"string\",\"null\"]}},\"description\":\"A page of results plus an opaque cursor for the next page, or null when this is the last\\npage. Wire keys are frozen: `items` (already lowercase under the camelCase policy) and\\n`next_cursor` (pinned explicitly — the policy alone would emit `nextCursor`).\"},\"PublicFlagComparisonSide\":{\"type\":[\"object\",\"null\"],\"properties\":{\"config\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicFlagEnvConfigResponse\"},{\"type\":\"null\"}]},\"targeting\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicTargetingConfigResponse\"},{\"type\":\"null\"}]},\"snapshot\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicEnvironmentSnapshot\"},{\"type\":\"null\"}]},\"ruleHasMatchInOther\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"boolean\",\"null\"]},\"description\":\"Per rule in evaluation order: whether the other environment has an equal rule.\"}},\"description\":\"One environment's side of a per-flag comparison.\"},\"PublicFlagEnvConfigResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"environmentId\":{\"type\":[\"string\",\"null\"]},\"environmentKey\":{\"type\":[\"string\",\"null\"]},\"isEnabled\":{\"type\":[\"boolean\",\"null\"]},\"defaultVariationId\":{\"type\":[\"string\",\"null\"]},\"strategy\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: SingleVariation, PercentageRollout, TargetedRollout.\"},\"prerequisites\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicPrerequisiteDto\"},{\"type\":\"null\"}]}},\"_actions\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#/$defs/ActionCapability\"},{\"type\":\"null\"}]},\"description\":\"Capability hints: which operations the authenticated caller may perform on this resource, each with allowed + optional reason. Computed from the caller's role and the resource's state. Injected at runtime; safe to ignore. Present only on top-level resource responses — nested occurrences (e.g. a rule inside a targeting-config response) do not carry it.\"}},\"description\":\"Public representation of a flag's config within a single environment, returned by\\n`GET .../flags/{flag}/environments` and `GET .../flags/{flag}/environments/{env}`.\\nDrops internal/dashboard-only fields present on FlagEnvironmentConfigurationDto\\n— Id (an internal row id, not part of the public\\ncontract; EnvironmentId is the addressable key), `FeatureFlagId` (implicit\\nin the route), the environment's name/color/sort-order (dashboard display fields — the public\\ncontract only needs the addressable EnvironmentKey), and `Staleness` (an\\ninternal analytics signal).\"},\"PublicFlagEvaluationsResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"environmentKey\":{\"type\":[\"string\",\"null\"],\"description\":\"The environment's key.\"},\"days\":{\"type\":[\"integer\",\"null\"],\"description\":\"The window requested: 7, 30 or 90.\"},\"fromUtc\":{\"type\":[\"string\",\"null\"],\"description\":\"Start of the window: UTC midnight `days - 1` days ago, or the flag's creation day if later.\"},\"toUtc\":{\"type\":[\"string\",\"null\"],\"description\":\"When the counts were read.\"},\"totalCount\":{\"type\":[\"integer\",\"null\"],\"description\":\"Evaluations in the window. Evaluation counts, not unique users.\"},\"lastEvaluatedAtUtc\":{\"type\":[\"string\",\"null\"],\"description\":\"The last reported evaluation, or null if none was reported.\"},\"variations\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicEvaluationVariation\"},{\"type\":\"null\"}]},\"description\":\"Evaluations per variation over the window.\"},\"sources\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicEvaluationSource\"},{\"type\":\"null\"}]},\"description\":\"Evaluations per part of the targeting that served them: live rules in evaluation order, then deleted rules, then fallthrough, off, prerequisite, error, notFound and unknown. A live percentage-rollout rule is always listed, with a count of 0 and no variations when it served nothing in the window, so its rollout check (and rollout.unreached) has a row.\"}},\"description\":\"What a flag served in one environment over the window, returned by\\n`GET .../flags/{flag}/environments/{env}/evaluations` (#4225). These are evaluation\\ncounts, not unique users. They come from SDK-reported events, so an environment whose SDKs\\nreport none reads zero: no evaluations reported, not necessarily no traffic. The public\\ncounterpart of FlagEvaluationAnalyticsDto, keyed by environment key instead of\\nid and without the dashboard's daily series.\"},\"PublicFlagListItem\":{\"type\":[\"object\",\"null\"],\"properties\":{\"id\":{\"type\":[\"string\",\"null\"]},\"key\":{\"type\":[\"string\",\"null\"]},\"name\":{\"type\":[\"string\",\"null\"]},\"type\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: Boolean, String, Number, Json.\"},\"isArchived\":{\"type\":[\"boolean\",\"null\"]},\"clientSideVisible\":{\"type\":[\"boolean\",\"null\"]},\"tags\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"createdAt\":{\"type\":[\"string\",\"null\"]},\"updatedAt\":{\"type\":[\"string\",\"null\"]},\"expiresAtUtc\":{\"type\":[\"string\",\"null\"]},\"owner\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicFlagOwner\"},{\"type\":\"null\"}]},\"removalPrUrl\":{\"type\":[\"string\",\"null\"]},\"isPermanent\":{\"type\":[\"boolean\",\"null\"]},\"effectiveExpiresAtUtc\":{\"type\":[\"string\",\"null\"]},\"expirySource\":{\"type\":[\"string\",\"null\"]}},\"description\":\"Public list-item representation of a feature flag, returned by\\n`GET .../flags`. Narrower than PublicFlagResponse — drops\\nVariations (a summary-only shape upstream) and\\nStaleness, matching the \\\"list is narrower than detail\\\"\\nsplit already present on the Application-layer DTOs.\\nEffectiveExpiresAtUtc is when the flag counts as past expiry, from its own ExpiresAtUtc\\nor its project's default lifetime; ExpirySource says which (`explicit` / `project-default`),\\nboth null when neither applies.\"},\"PublicFlagListItemPagedResult\":{\"type\":[\"object\",\"null\"],\"properties\":{\"items\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicFlagListItem\"},{\"type\":\"null\"}]}},\"next_cursor\":{\"type\":[\"string\",\"null\"]},\"_actions\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#/$defs/ActionCapability\"},{\"type\":\"null\"}]},\"description\":\"Capability hints: which operations the authenticated caller may perform on this resource, each with allowed + optional reason. Computed from the caller's role and the resource's state. Injected at runtime; safe to ignore. Present only on top-level resource responses — nested occurrences (e.g. a rule inside a targeting-config response) do not carry it.\"}},\"description\":\"A page of results plus an opaque cursor for the next page, or null when this is the last\\npage. Wire keys are frozen: `items` (already lowercase under the camelCase policy) and\\n`next_cursor` (pinned explicitly — the policy alone would emit `nextCursor`).\"},\"PublicFlagOwner\":{\"type\":[\"object\",\"null\"],\"properties\":{\"id\":{\"type\":[\"string\",\"null\"]},\"email\":{\"type\":[\"string\",\"null\"]},\"name\":{\"type\":[\"string\",\"null\"]}},\"description\":\"A flag's owner as returned on flag reads. Null means the flag is unowned.\"},\"PublicFlagRemovalCandidate\":{\"type\":[\"object\",\"null\"],\"properties\":{\"key\":{\"type\":[\"string\",\"null\"]},\"reason\":{\"type\":[\"string\",\"null\"]},\"treatment\":{\"type\":[\"boolean\",\"null\"]},\"status\":{\"type\":[\"string\",\"null\"]},\"blockedBy\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}}},\"description\":\"One dead flag the Featureflip Flag Cleanup Action should remove, returned by\\n`GET .../flags/removal-candidates`. `Treatment` is the kill decision: true → keep the\\nflag's on-branch, false → keep the off-branch. `Status` is the flag's staleness tier\\n(`\\\"Stale\\\"` or `\\\"Dead\\\"`, never `\\\"Active\\\"`) — lets a caller distinguish the two when\\n`?staleness=stale` widens the response to include both tiers. This is the ONLY public\\nprojection of staleness — PublicFlagResponse and PublicFlagListItem\\nstill omit it by design. `BlockedBy` names the live flags that still list this one as a\\nprerequisite, sorted by key; while it is non-empty the flag cannot be archived\\n(`FLAG_HAS_DEPENDENTS`), so a caller should remove those dependents first.\"},\"PublicFlagRemovalCandidatePagedResult\":{\"type\":[\"object\",\"null\"],\"properties\":{\"items\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicFlagRemovalCandidate\"},{\"type\":\"null\"}]}},\"next_cursor\":{\"type\":[\"string\",\"null\"]}},\"description\":\"A page of results plus an opaque cursor for the next page, or null when this is the last\\npage. Wire keys are frozen: `items` (already lowercase under the camelCase policy) and\\n`next_cursor` (pinned explicitly — the policy alone would emit `nextCursor`).\"},\"PublicFlagResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"id\":{\"type\":[\"string\",\"null\"]},\"key\":{\"type\":[\"string\",\"null\"]},\"name\":{\"type\":[\"string\",\"null\"]},\"description\":{\"type\":[\"string\",\"null\"]},\"type\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: Boolean, String, Number, Json.\"},\"isArchived\":{\"type\":[\"boolean\",\"null\"]},\"clientSideVisible\":{\"type\":[\"boolean\",\"null\"]},\"tags\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"variations\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicVariationResponse\"},{\"type\":\"null\"}]}},\"createdAt\":{\"type\":[\"string\",\"null\"]},\"updatedAt\":{\"type\":[\"string\",\"null\"]},\"expiresAtUtc\":{\"type\":[\"string\",\"null\"]},\"owner\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicFlagOwner\"},{\"type\":\"null\"}]},\"removalPrUrl\":{\"type\":[\"string\",\"null\"]},\"isPermanent\":{\"type\":[\"boolean\",\"null\"]},\"effectiveExpiresAtUtc\":{\"type\":[\"string\",\"null\"]},\"expirySource\":{\"type\":[\"string\",\"null\"]},\"_actions\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#/$defs/ActionCapability\"},{\"type\":\"null\"}]},\"description\":\"Capability hints: which operations the authenticated caller may perform on this resource, each with allowed + optional reason. Computed from the caller's role and the resource's state. Injected at runtime; safe to ignore. Present only on top-level resource responses — nested occurrences (e.g. a rule inside a targeting-config response) do not carry it.\"}},\"description\":\"Public detail representation of a feature flag, returned by\\n`GET .../flags/{flag}` and the body of a successful create. Drops internal/dashboard-only\\nfields present on FeatureFlagDto — notably `ProjectId` (implicit in the\\nroute) and `Staleness` (an internal analytics signal, not part of the public contract).\\nEffectiveExpiresAtUtc is when the flag counts as past expiry, from its own ExpiresAtUtc\\nor its project's default lifetime; ExpirySource says which (`explicit` / `project-default`),\\nboth null when neither applies.\"},\"PublicFlagTriggerResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"id\":{\"type\":[\"string\",\"null\"]},\"name\":{\"type\":[\"string\",\"null\"]},\"description\":{\"type\":[\"string\",\"null\"]},\"action\":{\"type\":[\"string\",\"null\"]},\"enabled\":{\"type\":[\"boolean\",\"null\"]},\"secretLastFour\":{\"type\":[\"string\",\"null\"]},\"createdAt\":{\"type\":[\"string\",\"null\"]},\"updatedAt\":{\"type\":[\"string\",\"null\"]},\"lastFiredAt\":{\"type\":[\"string\",\"null\"]}},\"description\":\"A flag trigger (#4651) as `/api/v1` returns it. Carries only the secret's last four characters:\\nthe URL is returned once, by PublicFlagTriggerWithUrlResponse. Flag and environment are\\nimplicit in the route.\"},\"PublicFlagTriggerResponsePagedResult\":{\"type\":[\"object\",\"null\"],\"properties\":{\"items\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicFlagTriggerResponse\"},{\"type\":\"null\"}]}},\"next_cursor\":{\"type\":[\"string\",\"null\"]},\"_actions\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#/$defs/ActionCapability\"},{\"type\":\"null\"}]},\"description\":\"Capability hints: which operations the authenticated caller may perform on this resource, each with allowed + optional reason. Computed from the caller's role and the resource's state. Injected at runtime; safe to ignore. Present only on top-level resource responses — nested occurrences (e.g. a rule inside a targeting-config response) do not carry it.\"}},\"description\":\"A page of results plus an opaque cursor for the next page, or null when this is the last\\npage. Wire keys are frozen: `items` (already lowercase under the camelCase policy) and\\n`next_cursor` (pinned explicitly — the policy alone would emit `nextCursor`).\"},\"PublicFlagTriggerWithUrlResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"trigger\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicFlagTriggerResponse\"},{\"type\":\"null\"}]},\"url\":{\"type\":[\"string\",\"null\"]},\"endpoint\":{\"type\":[\"string\",\"null\"]},\"secret\":{\"type\":[\"string\",\"null\"]},\"warning\":{\"type\":[\"string\",\"null\"]}},\"description\":\"The only response that carries a trigger's secret: create and rotate. Fire it by POSTing to\\nUrl, or to Endpoint with `Authorization: Bearer {Secret}`, which keeps\\nthe secret out of the URL. Anyone holding either can fire the trigger, so store it as a secret in the\\nmonitoring tool.\"},\"PublicFlagVersion\":{\"type\":[\"object\",\"null\"],\"properties\":{\"version\":{\"type\":[\"integer\",\"null\"]},\"createdAt\":{\"type\":[\"string\",\"null\"]},\"isEnabled\":{\"type\":[\"boolean\",\"null\"]},\"userName\":{\"type\":[\"string\",\"null\"]},\"userEmail\":{\"type\":[\"string\",\"null\"]},\"systemActor\":{\"type\":[\"string\",\"null\"]},\"source\":{\"type\":[\"string\",\"null\"]},\"intentReason\":{\"type\":[\"string\",\"null\"]},\"changeFreezeId\":{\"type\":[\"string\",\"null\"]},\"changeFreezeMode\":{\"type\":[\"string\",\"null\"]},\"restoredFromVersion\":{\"type\":[\"integer\",\"null\"]},\"isBaseline\":{\"type\":[\"boolean\",\"null\"]},\"config\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicEnvironmentSnapshot\"},{\"type\":\"null\"}]}},\"description\":\"One version in full: its summary fields and the configuration it captured.\"},\"PublicFlagVersionDiff\":{\"type\":[\"object\",\"null\"],\"properties\":{\"version\":{\"type\":[\"integer\",\"null\"]},\"against\":{\"type\":[\"integer\",\"null\"]},\"changedSections\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"from\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicEnvironmentSnapshot\"},{\"type\":\"null\"}]},\"to\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicEnvironmentSnapshot\"},{\"type\":\"null\"}]},\"fromRuleMatched\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"boolean\",\"null\"]}},\"toRuleMatched\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"boolean\",\"null\"]}}},\"description\":\"`version` compared with `against`: `to` is `version`'s configuration, `from` is\\n `against`'s. `changedSections` names what differs (`state`, `defaultVariation`,\\n `strategy`, `rules`, `prerequisites`). The two rule lists say, per rule in evaluation order,\\n whether the other side has an equal rule.\"},\"PublicFlagVersionSummary\":{\"type\":[\"object\",\"null\"],\"properties\":{\"version\":{\"type\":[\"integer\",\"null\"]},\"createdAt\":{\"type\":[\"string\",\"null\"]},\"isEnabled\":{\"type\":[\"boolean\",\"null\"]},\"userName\":{\"type\":[\"string\",\"null\"]},\"userEmail\":{\"type\":[\"string\",\"null\"]},\"systemActor\":{\"type\":[\"string\",\"null\"]},\"source\":{\"type\":[\"string\",\"null\"]},\"intentReason\":{\"type\":[\"string\",\"null\"]},\"changeFreezeId\":{\"type\":[\"string\",\"null\"]},\"changeFreezeMode\":{\"type\":[\"string\",\"null\"]},\"restoredFromVersion\":{\"type\":[\"integer\",\"null\"]},\"isBaseline\":{\"type\":[\"boolean\",\"null\"]}},\"description\":\"One entry in a flag environment's version history. `source` is lowercase: `dashboard`, `api`,\\n`mcp`, `schedule` and so on. `userName`/`userEmail` are as captured with the version;\\n`systemActor` names a non-user author instead. `restoredFromVersion` is set on a restore.\"},\"PublicFlagVersionSummaryPagedResult\":{\"type\":[\"object\",\"null\"],\"properties\":{\"items\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicFlagVersionSummary\"},{\"type\":\"null\"}]}},\"next_cursor\":{\"type\":[\"string\",\"null\"]}},\"description\":\"A page of results plus an opaque cursor for the next page, or null when this is the last\\npage. Wire keys are frozen: `items` (already lowercase under the camelCase policy) and\\n`next_cursor` (pinned explicitly — the policy alone would emit `nextCursor`).\"},\"PublicFreezeApprovalResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"scheduledChangeId\":{\"type\":[\"string\",\"null\"]},\"flagId\":{\"type\":[\"string\",\"null\"]},\"flagKey\":{\"type\":[\"string\",\"null\"]},\"environmentId\":{\"type\":[\"string\",\"null\"]},\"scheduledAtUtc\":{\"type\":[\"string\",\"null\"]},\"reason\":{\"type\":[\"string\",\"null\"]},\"approvedByEmail\":{\"type\":[\"string\",\"null\"]},\"approvedAt\":{\"type\":[\"string\",\"null\"]},\"stands\":{\"type\":[\"boolean\",\"null\"]}},\"description\":\"A scheduled change that a person approved to land inside a change freeze. `stands` is whether the approval\\ncounts right now: false once the approver is no longer an active Owner or Admin, and the window then holds or fails\\nthe change as if it were not approved.\"},\"PublicGrantFreezeApprovalRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"scheduledChangeId\":{\"type\":[\"string\",\"null\"]},\"reason\":{\"type\":[\"string\",\"null\"]}},\"description\":\"Approves one Pending scheduled change to apply inside the change freeze when it comes due, with a required\\n`reason`. The change must be in an environment the window covers. `scheduledChangeId` is required: a\\nmissing or empty one is a 400 naming the field.\"},\"PublicKeyedRef\":{\"type\":[\"object\",\"null\"],\"properties\":{\"id\":{\"type\":[\"string\",\"null\"]},\"key\":{\"type\":[\"string\",\"null\"]},\"name\":{\"type\":[\"string\",\"null\"]}},\"description\":\"An id with its key and name beside it, as the other v1 responses pair them. Key and name are null only for a deleted target.\"},\"PublicPlanLimit\":{\"type\":[\"object\",\"null\"],\"properties\":{\"resource\":{\"type\":[\"string\",\"null\"]},\"plan\":{\"type\":[\"string\",\"null\"]},\"max\":{\"type\":[\"integer\",\"null\"]}},\"description\":\"The cap behind a `plan_limit_reached` error. `resource` is the capped collection\\n(`projects`, `environments`, `flags`, `webhooks`, `members`);\\n`plan` is the plan's wire name, as `GET /api/v1/orgs/{org}` returns it; `max` is\\nthe cap. The environment and flag caps are per project.\"},\"PublicPlanLimits\":{\"type\":[\"object\",\"null\"],\"properties\":{\"projects\":{\"type\":[\"integer\",\"null\"]},\"environmentsPerProject\":{\"type\":[\"integer\",\"null\"]},\"flagsPerProject\":{\"type\":[\"integer\",\"null\"]},\"members\":{\"type\":[\"integer\",\"null\"]},\"webhooks\":{\"type\":[\"integer\",\"null\"]}},\"description\":\"A plan's caps. Null means unlimited. The environment and flag caps are per project, and an\\narchived flag does not count against the flag cap. These are the same caps a write is refused\\nby with a 403 `plan_limit_reached`, whose `plan_limit.resource` names the same\\ncollections.\"},\"PublicPrerequisiteDto\":{\"type\":[\"object\",\"null\"],\"properties\":{\"prerequisiteFlagKey\":{\"type\":[\"string\",\"null\"]},\"expectedVariationKey\":{\"type\":[\"string\",\"null\"]}},\"description\":\"A single prerequisite entry on a flag's per-environment config. Maps 1:1 onto\\nPrerequisiteDto (read side) and PrerequisiteInput (write side).\"},\"PublicPutTargetingRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"rules\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicCreateTargetingRuleRequest\"},{\"type\":\"null\"}]}}},\"description\":\"Request body for `PUT .../targeting` — a declarative full replace of the environment's\\nordered targeting rule set. Rules are applied in array order (index = priority, so the array\\norder IS the evaluation order). Rules is nullable so that an OMITTED `rules`\\nfield (a body of `{}`) binds successfully instead of failing ASP.NET Core's implicit\\nrequired-property check on non-nullable reference types — both an omitted `rules` field\\nand an explicit empty list (`{ \\\"rules\\\": [] }`) clear all targeting rules for the\\nenvironment. Each element is a PublicCreateTargetingRuleRequest (identical to the\\n`POST .../rules` body), so `UserSegmentId` is supported — segment-scoped rules can be\\nsubmitted through this endpoint. The replace is atomic (all-or-nothing): the whole rule set is\\nswapped in one transaction, or nothing changes.\"},\"PublicRampStep\":{\"type\":[\"object\",\"null\"],\"properties\":{\"percent\":{\"type\":[\"integer\",\"null\"]},\"holdMinutes\":{\"type\":[\"integer\",\"null\"]}},\"description\":\"One rung of a rollout ramp: the percentage served, then how long it holds before the next rung. Both fields\\nare required.\"},\"PublicReorderRulesRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"ruleIds\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}}},\"description\":\"Request body for `PUT .../rules/reorder`. Must include every existing rule id exactly\\nonce — `ReorderTargetingRulesCommandHandler` rejects duplicate, omitted, or unknown rule\\nids with `BadRequestException`, surfaced as an HTTP 400 `bad_request` envelope\\ncarrying the handler's message.\"},\"PublicRestoreFlagVersionRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"dryRun\":{\"type\":[\"boolean\",\"null\"]},\"includeState\":{\"type\":[\"boolean\",\"null\"]},\"expectedETag\":{\"type\":[\"string\",\"null\"]}},\"description\":\"Request body for `POST .../versions/{number}/restore`. Every field is optional, and so is the body: no\\nbody at all previews, the same as `{}`. `dryRun` defaults to\\ntrue: the restore only previews unless it is `false`. `includeState` restores on/off too.\\n`expectedETag` is the preview's `targetETag`; an apply sending it is refused with 412\\n`precondition_failed` if the environment changed since.\"},\"PublicRestoreFlagVersionResult\":{\"type\":[\"object\",\"null\"],\"properties\":{\"changed\":{\"type\":[\"boolean\",\"null\"]},\"changedSections\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"before\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicEnvironmentSnapshot\"},{\"type\":\"null\"}]},\"after\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicEnvironmentSnapshot\"},{\"type\":\"null\"}]},\"targetETag\":{\"type\":[\"string\",\"null\"]},\"warnings\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicCopyWarning\"},{\"type\":\"null\"}]}},\"newVersion\":{\"type\":[\"integer\",\"null\"]}},\"description\":\"Response of `POST .../versions/{number}/restore`, for a dry run and an apply alike. `before` is the\\nconfiguration as it is (as it was, on an apply) and `after` as the restore leaves it. `targetETag` is the\\nconfiguration's before a dry run and after an apply, so a dry run's is what the apply sends back as\\n`expectedETag`. `newVersion` is the version the apply wrote, null on a dry run and when nothing changed.\"},\"PublicRolloutCheck\":{\"type\":[\"object\",\"null\"],\"properties\":{\"configured\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicConfiguredWeight\"},{\"type\":\"null\"}]},\"description\":\"The configured weights, in percent; they sum to 100.\"},\"splitChangedAtUtc\":{\"type\":[\"string\",\"null\"],\"description\":\"The last time the split may have changed (the rule was edited, or a variation was added), or null if it hasn't since the rule was created. A change inside the window mixes two splits.\"},\"evaluable\":{\"type\":[\"boolean\",\"null\"],\"description\":\"Whether the check could run. See NotEvaluableReason when false.\"},\"pValue\":{\"type\":[\"number\",\"null\"],\"description\":\"The sample-ratio test's p-value, or null when not evaluable.\"},\"flagged\":{\"type\":[\"boolean\",\"null\"],\"description\":\"True only when the served split is both unlikely under the configured weights (p < 0.001) and at least 2 percentage points off for some variation.\"},\"notEvaluableReason\":{\"type\":[\"string\",\"null\"],\"description\":\"too-little-traffic or unexpected-variation when the check couldn't run; null otherwise. Allowed values: too-little-traffic, unexpected-variation.\"},\"bucketBy\":{\"type\":[\"string\",\"null\"],\"description\":\"The context attribute the rollout hashes on. A context without it skips the rule, even at 100%.\"},\"unreached\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicRolloutUnreached\"},{\"type\":\"null\"}]}},\"description\":\"A percentage-rollout rule's configured split beside a sample-ratio check of what it served.\"},\"PublicRolloutRampResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"id\":{\"type\":[\"string\",\"null\"]},\"ruleId\":{\"type\":[\"string\",\"null\"]},\"isDefaultRule\":{\"type\":[\"boolean\",\"null\"]},\"targetVariationId\":{\"type\":[\"string\",\"null\"]},\"status\":{\"type\":[\"string\",\"null\"]},\"steps\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicRampStep\"},{\"type\":\"null\"}]}},\"currentStepIndex\":{\"type\":[\"integer\",\"null\"]},\"nextStepAt\":{\"type\":[\"string\",\"null\"]},\"pausedReason\":{\"type\":[\"string\",\"null\"]},\"pausedDetail\":{\"type\":[\"string\",\"null\"]},\"startedByName\":{\"type\":[\"string\",\"null\"]},\"createdAt\":{\"type\":[\"string\",\"null\"]},\"completedAt\":{\"type\":[\"string\",\"null\"]},\"abortedAt\":{\"type\":[\"string\",\"null\"]}},\"description\":\"A rollout ramp (#4653, #5180) as `/api/v1` returns it. Flag and environment are implicit in the route.\\nA ramp drives either a targeting rule (RuleId set) or the default rule\\n(IsDefaultRule true, TargetVariationId the variation it rolls out).\\nStatus is `Running`, `Paused`, `Completed` or `Aborted`.\\nCurrentStepIndex is the step last applied, -1 before the first. NextStepAt is\\nset only while running and not yet on the last step.\"},\"PublicRolloutRampResponsePagedResult\":{\"type\":[\"object\",\"null\"],\"properties\":{\"items\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicRolloutRampResponse\"},{\"type\":\"null\"}]}},\"next_cursor\":{\"type\":[\"string\",\"null\"]},\"_actions\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#/$defs/ActionCapability\"},{\"type\":\"null\"}]},\"description\":\"Capability hints: which operations the authenticated caller may perform on this resource, each with allowed + optional reason. Computed from the caller's role and the resource's state. Injected at runtime; safe to ignore. Present only on top-level resource responses — nested occurrences (e.g. a rule inside a targeting-config response) do not carry it.\"}},\"description\":\"A page of results plus an opaque cursor for the next page, or null when this is the last\\npage. Wire keys are frozen: `items` (already lowercase under the camelCase policy) and\\n`next_cursor` (pinned explicitly — the policy alone would emit `nextCursor`).\"},\"PublicRolloutUnreached\":{\"type\":[\"object\",\"null\"],\"properties\":{\"eligibleEvaluations\":{\"type\":[\"integer\",\"null\"],\"description\":\"Evaluations that reached the flag's rules or fallthrough since SinceUtc, while this rule served none.\"},\"sinceUtc\":{\"type\":[\"string\",\"null\"],\"description\":\"The window start, or the first UTC midnight after the rule last changed when that is later.\"}},\"description\":\"A live rollout rule that no evaluations reached.\"},\"PublicRotateWebhookSecretResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"secretId\":{\"type\":[\"string\",\"null\"]},\"secret\":{\"type\":[\"string\",\"null\"]},\"warning\":{\"type\":[\"string\",\"null\"]}},\"description\":\"A newly added signing secret. The secret is shown only here.\"},\"PublicSdkKeyResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"id\":{\"type\":[\"string\",\"null\"]},\"name\":{\"type\":[\"string\",\"null\"]},\"description\":{\"type\":[\"string\",\"null\"]},\"type\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: ClientSide, ServerSide.\"},\"lastFourCharacters\":{\"type\":[\"string\",\"null\"]},\"isActive\":{\"type\":[\"boolean\",\"null\"]},\"createdAt\":{\"type\":[\"string\",\"null\"]},\"lastUsedAt\":{\"type\":[\"string\",\"null\"]},\"revokedAt\":{\"type\":[\"string\",\"null\"]},\"_actions\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#/$defs/ActionCapability\"},{\"type\":\"null\"}]},\"description\":\"Capability hints: which operations the authenticated caller may perform on this resource, each with allowed + optional reason. Computed from the caller's role and the resource's state. Injected at runtime; safe to ignore. Present only on top-level resource responses — nested occurrences (e.g. a rule inside a targeting-config response) do not carry it.\"}},\"description\":\"Public representation of an SDK key, returned by\\n`GET /api/v1/orgs/{org}/projects/{project}/environments/{env}/sdk-keys` (list) and\\n`GET .../sdk-keys/{sdkKey}` (detail). Deliberately narrower than\\nSdkKeyDto — drops `RevokedBy` (an internal user id) and\\n`EnvironmentId` (implicit in the route), and carries no plaintext key field: only\\nLastFourCharacters is ever exposed once the key has been created. The plaintext\\nkey is a one-time value that appears solely in PublicCreateSdkKeyResponse.\"},\"PublicSdkKeyResponsePagedResult\":{\"type\":[\"object\",\"null\"],\"properties\":{\"items\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicSdkKeyResponse\"},{\"type\":\"null\"}]}},\"next_cursor\":{\"type\":[\"string\",\"null\"]},\"_actions\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#/$defs/ActionCapability\"},{\"type\":\"null\"}]},\"description\":\"Capability hints: which operations the authenticated caller may perform on this resource, each with allowed + optional reason. Computed from the caller's role and the resource's state. Injected at runtime; safe to ignore. Present only on top-level resource responses — nested occurrences (e.g. a rule inside a targeting-config response) do not carry it.\"}},\"description\":\"A page of results plus an opaque cursor for the next page, or null when this is the last\\npage. Wire keys are frozen: `items` (already lowercase under the camelCase policy) and\\n`next_cursor` (pinned explicitly — the policy alone would emit `nextCursor`).\"},\"PublicSegmentConditionDto\":{\"type\":[\"object\",\"null\"],\"properties\":{\"attribute\":{\"type\":[\"string\",\"null\"]},\"operator\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: Equals, NotEquals, Contains, NotContains, GreaterThan, LessThan, GreaterThanOrEqual, LessThanOrEqual, In, NotIn, MatchesRegex, StartsWith, EndsWith, Before, After, SemverEquals, SemverGreaterThan, SemverGreaterThanOrEqual, SemverLessThan, SemverLessThanOrEqual.\"},\"values\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"negate\":{\"type\":[\"boolean\",\"null\"]}},\"description\":\"A single targeting condition on a segment, used both as input (create/update) and output\\n(Conditions). Operator is a bare string on\\nboth sides of the wire — on write it's parsed to\\nOperatorType by `SegmentsController` (an unknown\\nvalue fails closed with a 400, never silently dropped or defaulted); on read it's mapped\\nstraight through from Operator, which is already a string.\"},\"PublicSegmentResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"id\":{\"type\":[\"string\",\"null\"]},\"key\":{\"type\":[\"string\",\"null\"]},\"name\":{\"type\":[\"string\",\"null\"]},\"description\":{\"type\":[\"string\",\"null\"]},\"conditions\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicSegmentConditionDto\"},{\"type\":\"null\"}]}},\"createdAt\":{\"type\":[\"string\",\"null\"]},\"updatedAt\":{\"type\":[\"string\",\"null\"]},\"_actions\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#/$defs/ActionCapability\"},{\"type\":\"null\"}]},\"description\":\"Capability hints: which operations the authenticated caller may perform on this resource, each with allowed + optional reason. Computed from the caller's role and the resource's state. Injected at runtime; safe to ignore. Present only on top-level resource responses — nested occurrences (e.g. a rule inside a targeting-config response) do not carry it.\"}},\"description\":\"Public representation of a user segment, returned by `GET .../segments`,\\n`GET .../segments/{segment}`, and the body of a successful create.\"},\"PublicSegmentResponsePagedResult\":{\"type\":[\"object\",\"null\"],\"properties\":{\"items\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicSegmentResponse\"},{\"type\":\"null\"}]}},\"next_cursor\":{\"type\":[\"string\",\"null\"]},\"_actions\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#/$defs/ActionCapability\"},{\"type\":\"null\"}]},\"description\":\"Capability hints: which operations the authenticated caller may perform on this resource, each with allowed + optional reason. Computed from the caller's role and the resource's state. Injected at runtime; safe to ignore. Present only on top-level resource responses — nested occurrences (e.g. a rule inside a targeting-config response) do not carry it.\"}},\"description\":\"A page of results plus an opaque cursor for the next page, or null when this is the last\\npage. Wire keys are frozen: `items` (already lowercase under the camelCase policy) and\\n`next_cursor` (pinned explicitly — the policy alone would emit `nextCursor`).\"},\"PublicSetDefaultFlagLifetimeRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"days\":{\"type\":[\"integer\",\"null\"]}},\"description\":\"Request body for `PUT /api/v1/orgs/{org}/projects/{project}/default-flag-lifetime`. `days`\\nis 1–3650, or an explicit null to remove the default. `days` is required: a body without it\\n(`{}`, or a misspelled field) is a `validation_failed` 400, never a removal, so a typo\\ncan't silently wipe the setting (#3788). A request with no body is rejected too.\"},\"PublicSetFlagExpiryRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"expiresAtUtc\":{\"type\":[\"string\",\"null\"]}},\"description\":\"Request body for `PUT /api/v1/orgs/{org}/projects/{project}/flags/{flag}/expiry`. Expiry is a\\ndedicated sub-resource, deliberately NOT a field on PublicUpdateFeatureFlagRequest: that\\nPUT is a full replace, so a new nullable field there would let any client that doesn't know about\\nexpiry (the Terraform provider included) wipe it on every update. A bare date means the end of that\\nUTC day; a full timestamp is stored exactly.\"},\"PublicSetFlagOwnerRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"email\":{\"type\":[\"string\",\"null\"]}},\"description\":\"Request body for `PUT /api/v1/orgs/{org}/projects/{project}/flags/{flag}/owner`. A dedicated\\nsub-resource for the same reason as expiry: the main flag PUT is a full replace, so an owner field\\nthere would let every client that doesn't know about owners wipe one. `email` must belong\\nto an active member of the organization (case-insensitive).\"},\"PublicSetFlagRemovalPrRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"url\":{\"type\":[\"string\",\"null\"]}},\"description\":\"Request body for `PUT /api/v1/orgs/{org}/projects/{project}/flags/{flag}/removal-pr`: the\\npull request that removes this flag from code, as opened by the Featureflip Flag Cleanup Action.\\nA dedicated sub-resource for the same reason as expiry and owner. `url` must be an https\\npull or merge request URL (`https://{host}/{owner}/{repo}/pull/{number}`, a GitLab\\n`https://{host}/{group}/{project}/-/merge_requests/{number}` or a Bitbucket Cloud\\n`https://{host}/{workspace}/{repo}/pull-requests/{number}`).\"},\"PublicSnapshotRule\":{\"type\":[\"object\",\"null\"],\"properties\":{\"description\":{\"type\":[\"string\",\"null\"]},\"variation\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicKeyedRef\"},{\"type\":\"null\"}]},\"segment\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicKeyedRef\"},{\"type\":\"null\"}]},\"rolloutPercentage\":{\"type\":[\"integer\",\"null\"]},\"bucketBy\":{\"type\":[\"string\",\"null\"]},\"conditionGroups\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicConditionGroupResponse\"},{\"type\":\"null\"}]}}},\"description\":\"A targeting rule as a comparison or copy shows it: the variation and segment with key and name, and the\\ncondition groups in the shape the targeting endpoints return.\"},\"PublicStartDefaultRuleRolloutRampRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"steps\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicRampStep\"},{\"type\":\"null\"}]}},\"variationId\":{\"type\":[\"string\",\"null\"]},\"bucketBy\":{\"type\":[\"string\",\"null\"]}},\"description\":\"Request body for `POST …/default-rule/ramp`. VariationId (and optionally\\nBucketBy) set the rollout up when the default rule has none; with one configured they may be\\nomitted, or must match it. A ladder ending at 100% finalises: the variation becomes the default variation.\"},\"PublicStartRolloutRampRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"steps\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicRampStep\"},{\"type\":\"null\"}]}}},\"description\":\"Request body for `POST …/rules/{ruleId}/ramp`. Between 1 and 20 steps, each percentage above the last and\\nthe first not below the rule's current rollout; every hold but the last is 5 minutes to 30 days, and the last\\none 0 minutes to 30 days. Elements are\\nnullable so a null step is a field error, not a 500.\"},\"PublicTargetingConfigResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"isEnabled\":{\"type\":[\"boolean\",\"null\"]},\"rules\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicTargetingRuleResponse\"},{\"type\":\"null\"}]}},\"_actions\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#/$defs/ActionCapability\"},{\"type\":\"null\"}]},\"description\":\"Capability hints: which operations the authenticated caller may perform on this resource, each with allowed + optional reason. Computed from the caller's role and the resource's state. Injected at runtime; safe to ignore. Present only on top-level resource responses — nested occurrences (e.g. a rule inside a targeting-config response) do not carry it.\"}},\"description\":\"The full targeting configuration for a flag in a single environment, returned by\\n`GET .../targeting`. Maps 1:1 onto TargetingConfigurationDto — including\\nits IsEnabled field, which reflects the parent\\n`FlagEnvironmentConfiguration.IsEnabled` (whether the flag is on in this environment at\\nall), not anything specific to targeting itself.\"},\"PublicTargetingRuleResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"id\":{\"type\":[\"string\",\"null\"]},\"priority\":{\"type\":[\"integer\",\"null\"]},\"description\":{\"type\":[\"string\",\"null\"]},\"variationId\":{\"type\":[\"string\",\"null\"]},\"rolloutPercentage\":{\"type\":[\"integer\",\"null\"]},\"bucketBy\":{\"type\":[\"string\",\"null\"],\"description\":\"Context attribute the rollout hashes on (default `user_id`; `userId` is accepted as an alias). A context without it skips this rule, even at 100%. Lookup is exact and case-sensitive, except `user_id`/`userId`, which both read the user id.\"},\"userSegmentId\":{\"type\":[\"string\",\"null\"]},\"conditionGroups\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicConditionGroupResponse\"},{\"type\":\"null\"}]}},\"_actions\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#/$defs/ActionCapability\"},{\"type\":\"null\"}]},\"description\":\"Capability hints: which operations the authenticated caller may perform on this resource, each with allowed + optional reason. Computed from the caller's role and the resource's state. Injected at runtime; safe to ignore. Present only on top-level resource responses — nested occurrences (e.g. a rule inside a targeting-config response) do not carry it.\"}},\"description\":\"A single targeting rule, returned by `GET .../rules/{ruleId}`,\\n`POST .../rules` (201 body), and nested within PublicTargetingConfigResponse.\\nMaps 1:1 onto TargetingRuleDto, dropping nothing — every field on the\\nApplication DTO is part of the public contract.\"},\"PublicTestWebhookSubscriptionResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"webhookEventId\":{\"type\":[\"string\",\"null\"]},\"webhookDeliveryId\":{\"type\":[\"string\",\"null\"]}},\"description\":\"The queued test event and its delivery. Poll the delivery log for the outcome.\"},\"PublicToggleFlagRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"enabled\":{\"type\":[\"boolean\",\"null\"]}},\"description\":\"Request body for `POST .../flags/{flag}/environments/{env}/toggle`. Named distinctly from\\nthe dashboard's own `ToggleFlagInEnvironmentRequest`\\n(which uses `IsEnabled`) — the public field is named Enabled per the phase-3c\\ncontract. Enabled is a NULLABLE `bool?` deliberately: a non-nullable value\\ntype would bind an omitted/empty body to `false` with no validation error (ASP.NET's\\nimplicit-required only covers non-nullable reference types, not value types), silently disabling\\nthe flag. The controller rejects a null Enabled with a `validation_failed` 400\\nso the intent is never ambiguous (#1806).\"},\"PublicUpdateChangeFreezeRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"name\":{\"type\":[\"string\",\"null\"]},\"reason\":{\"type\":[\"string\",\"null\"]},\"allEnvironments\":{\"type\":[\"boolean\",\"null\"]},\"environmentKeys\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"environmentIds\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"startsAt\":{\"type\":[\"string\",\"null\"]},\"endsAt\":{\"type\":[\"string\",\"null\"]},\"scheduledChangePolicy\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: Hold, Fail.\"}},\"description\":\"Edits a change freeze; a field left out is left as it was. An ended window cannot be edited, and the\\nstart of an active window cannot move. Send `If-Match` with the ETag from the last read to\\nguard against a concurrent edit.\"},\"PublicUpdateEnvironmentRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"name\":{\"type\":[\"string\",\"null\"],\"description\":\"The environment's display name.\"},\"color\":{\"type\":[\"string\",\"null\"],\"description\":\"The environment's display color, or null.\"},\"sortOrder\":{\"type\":[\"integer\",\"null\"],\"description\":\"Position among the project's environments.\"},\"requireChangeReason\":{\"type\":[\"boolean\",\"null\"],\"description\":\"Require a change reason (X-Intent-Reason) on every change to flags in this environment. Business plan and above. Omit on update to leave unchanged. Turning it off needs Admin or Owner and an X-Intent-Reason.\"},\"requireConfirmation\":{\"type\":[\"boolean\",\"null\"],\"description\":\"Ask dashboard users to type the environment key before a change lands. Dashboard only; not enforced by the API. Omit on update to leave unchanged. Turning it off needs Admin or Owner and an X-Intent-Reason.\"}},\"description\":\"Request body for `PUT /api/v1/orgs/{org}/projects/{project}/environments/{env}`. See\\nPublicCreateEnvironmentRequest for why this is named distinctly from the\\ndashboard's `UpdateEnvironmentRequest`.\"},\"PublicUpdateFeatureFlagRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"name\":{\"type\":[\"string\",\"null\"]},\"description\":{\"type\":[\"string\",\"null\"]},\"tags\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"clientSideVisible\":{\"type\":[\"boolean\",\"null\"]}},\"description\":\"Request body for `PUT /api/v1/orgs/{org}/projects/{project}/flags/{flag}`. See\\nPublicCreateFeatureFlagRequest for why this is named distinctly from the\\ndashboard's `UpdateFeatureFlagRequest`. The flag's key and type are immutable via this\\nendpoint (mirrors `UpdateFeatureFlagCommand`, which has no `Key`/`Type`).\"},\"PublicUpdateFlagEnvConfigRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"defaultVariationId\":{\"type\":[\"string\",\"null\"]},\"strategy\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: SingleVariation, PercentageRollout, TargetedRollout.\"},\"prerequisites\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicPrerequisiteDto\"},{\"type\":\"null\"}]}}},\"description\":\"Request body for `PUT .../flags/{flag}/environments/{env}`. Named distinctly from the\\ndashboard's own `UpdateFlagEnvironmentConfigurationRequest`\\n— see PublicCreateEnvironmentRequest for the schemaId-collision rationale (both\\ncontrollers share one Swagger document). Strategy is passed through verbatim to\\nStrategy\\n— the existing command validator name-allowlists it (SingleVariation/PercentageRollout/\\nTargetedRollout or null), so an invalid value surfaces as the handler's own 400, not a\\ncontroller-level guard. A null Prerequisites leaves prerequisites untouched; a\\nnon-null list replaces them wholesale (mirrors UpdateFlagPrerequisitesCommand's\\nreplace-all semantics).\"},\"PublicUpdateFlagTriggerRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"name\":{\"type\":[\"string\",\"null\"]},\"description\":{\"type\":[\"string\",\"null\"]},\"enabled\":{\"type\":[\"boolean\",\"null\"]}},\"description\":\"Request body for `PUT .../triggers/{trigger}`. The action is fixed at creation. Enabled is\\nnullable so leaving it out is a 400 rather than a bound `false` that silently turns the trigger off.\"},\"PublicUpdateProjectRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"name\":{\"type\":[\"string\",\"null\"]},\"description\":{\"type\":[\"string\",\"null\"]}},\"description\":\"Request body for `PUT /api/v1/orgs/{org}/projects/{project}`. See\\nPublicCreateProjectRequest for why this is named distinctly from the\\ndashboard's `UpdateProjectRequest`.\"},\"PublicUpdateSdkKeyRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"name\":{\"type\":[\"string\",\"null\"]},\"description\":{\"type\":[\"string\",\"null\"]}},\"description\":\"Request body for `PUT /api/v1/orgs/{org}/projects/{project}/environments/{env}/sdk-keys/{sdkKey}`.\\nType and key material are immutable via this endpoint (mirrors\\nUpdateSdkKeyCommand, which\\ncarries no `Type`).\"},\"PublicUpdateSegmentRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"name\":{\"type\":[\"string\",\"null\"]},\"description\":{\"type\":[\"string\",\"null\"]},\"conditions\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicSegmentConditionDto\"},{\"type\":\"null\"}]}}},\"description\":\"Request body for `PUT /api/v1/orgs/{org}/projects/{project}/segments/{segment}`. The\\nsegment's key is immutable via this endpoint (mirrors `UpdateUserSegmentCommand`, which\\ncarries no `Key`).\"},\"PublicUpdateTargetingRuleRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"description\":{\"type\":[\"string\",\"null\"]},\"variationId\":{\"type\":[\"string\",\"null\"]},\"rolloutPercentage\":{\"type\":[\"integer\",\"null\"]},\"userSegmentId\":{\"type\":[\"string\",\"null\"]},\"conditionGroups\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicConditionGroupRequest\"},{\"type\":\"null\"}]}},\"bucketBy\":{\"type\":[\"string\",\"null\"],\"description\":\"Context attribute the rollout hashes on (default `user_id`; `userId` is accepted as an alias). Omit to keep the current value. A fixed rule (no `rolloutPercentage`) never hashes and always stores `user_id`, so one made a rollout without `bucketBy` gets `user_id`. A context without it skips this rule, even at 100%. Changing it reshuffles who is in the rollout.\"}},\"description\":\"Request body for `PUT .../rules/{ruleId}`. Same shape as\\nPublicCreateTargetingRuleRequest — see its remarks on operator\\nvalidation/canonicalization, which applies identically here.\"},\"PublicUpdateVariationRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"name\":{\"type\":[\"string\",\"null\"]},\"value\":{\"type\":[\"string\",\"null\"]},\"description\":{\"type\":[\"string\",\"null\"]}},\"description\":\"Request body for\\n`PUT /api/v1/orgs/{org}/projects/{project}/flags/{flag}/variations/{variationId}`. The\\nvariation's key is immutable via this endpoint (mirrors\\n`UpdateVariationCommand`, which\\ncarries no `Key`).\"},\"PublicUpdateWebhookSubscriptionRequest\":{\"type\":[\"object\",\"null\"],\"properties\":{\"name\":{\"type\":[\"string\",\"null\"]},\"url\":{\"type\":[\"string\",\"null\"]},\"eventTypes\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"projectIds\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"environmentIds\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"isEnabled\":{\"type\":[\"boolean\",\"null\"]},\"credential\":{\"type\":[\"string\",\"null\"]}},\"description\":\"Replaces a subscription's configuration (full replace — omitted lists become empty, meaning\\n\\\"all\\\"). `isEnabled` is required. The provider cannot be changed. `credential`\\nreplaces a Datadog or Grafana subscription's stored credential; omit it to keep the current\\none, unless the `url` changes, which needs the credential sent again.\"},\"PublicVariationResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"id\":{\"type\":[\"string\",\"null\"]},\"key\":{\"type\":[\"string\",\"null\"]},\"name\":{\"type\":[\"string\",\"null\"]},\"value\":{\"type\":[\"string\",\"null\"]},\"description\":{\"type\":[\"string\",\"null\"]},\"_actions\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#/$defs/ActionCapability\"},{\"type\":\"null\"}]},\"description\":\"Capability hints: which operations the authenticated caller may perform on this resource, each with allowed + optional reason. Computed from the caller's role and the resource's state. Injected at runtime; safe to ignore. Present only on top-level resource responses — nested occurrences (e.g. a rule inside a targeting-config response) do not carry it.\"}},\"description\":\"A single variation on a flag, as returned in Variations.\"},\"PublicWebhookDeliveryResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"id\":{\"type\":[\"string\",\"null\"]},\"webhookEventId\":{\"type\":[\"string\",\"null\"]},\"status\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: Pending, Succeeded, DeadLettered.\"},\"attemptCount\":{\"type\":[\"integer\",\"null\"]},\"nextAttemptAt\":{\"type\":[\"string\",\"null\"]},\"lastResponseStatusCode\":{\"type\":[\"integer\",\"null\"]},\"lastError\":{\"type\":[\"string\",\"null\"]},\"completedAt\":{\"type\":[\"string\",\"null\"]},\"createdAt\":{\"type\":[\"string\",\"null\"]}},\"description\":\"One delivery attempt record. `status` is `Pending` (awaiting its first attempt,\\nbacking off, or in flight), `Succeeded` or `DeadLettered`.\"},\"PublicWebhookDeliveryResponsePagedResult\":{\"type\":[\"object\",\"null\"],\"properties\":{\"items\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicWebhookDeliveryResponse\"},{\"type\":\"null\"}]}},\"next_cursor\":{\"type\":[\"string\",\"null\"]}},\"description\":\"A page of results plus an opaque cursor for the next page, or null when this is the last\\npage. Wire keys are frozen: `items` (already lowercase under the camelCase policy) and\\n`next_cursor` (pinned explicitly — the policy alone would emit `nextCursor`).\"},\"PublicWebhookSecretResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"id\":{\"type\":[\"string\",\"null\"]},\"createdAt\":{\"type\":[\"string\",\"null\"]},\"retiredAt\":{\"type\":[\"string\",\"null\"]}},\"description\":\"A signing secret's id and lifecycle. A secret with no `retiredAt` is active and signs every delivery.\"},\"PublicWebhookSubscriptionResponse\":{\"type\":[\"object\",\"null\"],\"properties\":{\"id\":{\"type\":[\"string\",\"null\"]},\"name\":{\"type\":[\"string\",\"null\"]},\"url\":{\"type\":[\"string\",\"null\"]},\"provider\":{\"type\":[\"string\",\"null\"],\"description\":\"Allowed values: GenericHttp, Slack, Datadog, Grafana.\"},\"isEnabled\":{\"type\":[\"boolean\",\"null\"]},\"eventTypes\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"projectIds\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"environmentIds\":{\"type\":[\"array\",\"null\"],\"items\":{\"type\":[\"string\",\"null\"]}},\"consecutiveFailureCount\":{\"type\":[\"integer\",\"null\"]},\"autoDisabledAt\":{\"type\":[\"string\",\"null\"]},\"createdAt\":{\"type\":[\"string\",\"null\"]},\"updatedAt\":{\"type\":[\"string\",\"null\"]},\"secrets\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicWebhookSecretResponse\"},{\"type\":\"null\"}]}},\"overPlanLimit\":{\"type\":[\"boolean\",\"null\"]},\"_actions\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#/$defs/ActionCapability\"},{\"type\":\"null\"}]},\"description\":\"Capability hints: which operations the authenticated caller may perform on this resource, each with allowed + optional reason. Computed from the caller's role and the resource's state. Injected at runtime; safe to ignore. Present only on top-level resource responses — nested occurrences (e.g. a rule inside a targeting-config response) do not carry it.\"}},\"description\":\"A webhook subscription. Never carries secret material: signing secrets are listed by id and\\nlifecycle only — the value itself is returned once, when it is created or rotated.\\n`overPlanLimit` is true when the organization has more subscriptions than its plan\\nallows, which happens after a downgrade. The oldest subscriptions up to the limit keep\\ndelivering. The rest receive nothing and cannot be re-enabled, tested or redelivered to until\\nthe plan is upgraded or older subscriptions are deleted.\"},\"PublicWebhookSubscriptionResponsePagedResult\":{\"type\":[\"object\",\"null\"],\"properties\":{\"items\":{\"type\":[\"array\",\"null\"],\"items\":{\"anyOf\":[{\"$ref\":\"#/$defs/PublicWebhookSubscriptionResponse\"},{\"type\":\"null\"}]}},\"next_cursor\":{\"type\":[\"string\",\"null\"]},\"_actions\":{\"type\":[\"object\",\"null\"],\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#/$defs/ActionCapability\"},{\"type\":\"null\"}]},\"description\":\"Capability hints: which operations the authenticated caller may perform on this resource, each with allowed + optional reason. Computed from the caller's role and the resource's state. Injected at runtime; safe to ignore. Present only on top-level resource responses — nested occurrences (e.g. a rule inside a targeting-config response) do not carry it.\"}},\"description\":\"A page of results plus an opaque cursor for the next page, or null when this is the last\\npage. Wire keys are frozen: `items` (already lowercase under the camelCase policy) and\\n`next_cursor` (pinned explicitly — the policy alone would emit `nextCursor`).\"}}")
|
|
244
|
+
}, _ = g.$defs, v = g.endpoints, y = (e) => ({ type: [e, "null"] });
|
|
245
|
+
function b(e) {
|
|
246
|
+
if (!_[e]) throw Error(`no API schema named ${e}`);
|
|
247
|
+
return { $ref: `#/$defs/${e}` };
|
|
248
|
+
}
|
|
249
|
+
function x(e) {
|
|
250
|
+
let t = v[e];
|
|
251
|
+
if (!t) throw Error(`the public API spec has no JSON response for ${e}`);
|
|
252
|
+
return b(t);
|
|
253
|
+
}
|
|
254
|
+
function S(e, t = /* @__PURE__ */ new Set()) {
|
|
255
|
+
if (Array.isArray(e)) for (let n of e) S(n, t);
|
|
256
|
+
else if (e && typeof e == "object") for (let [n, r] of Object.entries(e)) if (n === "$ref" && typeof r == "string" && r.startsWith("#/$defs/")) {
|
|
257
|
+
let e = r.slice(8);
|
|
258
|
+
t.has(e) || (t.add(e), S(_[e], t));
|
|
259
|
+
} else S(r, t);
|
|
260
|
+
return t;
|
|
261
|
+
}
|
|
262
|
+
function C(e) {
|
|
263
|
+
let n = [...S(e)].sort(), r = {
|
|
264
|
+
...e,
|
|
265
|
+
type: "object"
|
|
266
|
+
};
|
|
267
|
+
return n.length && (r.$defs = Object.fromEntries(n.map((e) => [e, _[e]]))), t(r);
|
|
268
|
+
}
|
|
269
|
+
function w(e) {
|
|
270
|
+
let t = v[e];
|
|
271
|
+
if (!t) throw Error(`the public API spec has no JSON response for ${e}`);
|
|
272
|
+
return C({
|
|
273
|
+
..._[t],
|
|
274
|
+
type: "object"
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
function T(e, t) {
|
|
278
|
+
let n = v[e];
|
|
279
|
+
if (!n) throw Error(`the public API spec has no JSON response for ${e}`);
|
|
280
|
+
let r = _[n];
|
|
281
|
+
return C({
|
|
282
|
+
...r,
|
|
283
|
+
properties: {
|
|
284
|
+
...r.properties,
|
|
285
|
+
...t
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
function E(e, t = [], n) {
|
|
290
|
+
return C({
|
|
291
|
+
properties: e,
|
|
292
|
+
...t.length ? { required: t } : {},
|
|
293
|
+
...n ? { description: n } : {}
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
function D(...e) {
|
|
297
|
+
return C({ anyOf: e });
|
|
298
|
+
}
|
|
299
|
+
function O(e, t = []) {
|
|
300
|
+
return {
|
|
301
|
+
type: "object",
|
|
302
|
+
properties: e,
|
|
303
|
+
...t.length ? { required: t } : {}
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
// src/tools/params.ts
|
|
307
|
+
var k = n.string().describe("Project key"), A = n.string().describe("Flag key or id"), j = n.string().describe("Environment key, e.g. production"), M = n.string().optional().describe("Why you are making this change. Recorded in the audit log, and required when the environment (or, for project-wide changes, any environment in the project) is marked critical."), N = {
|
|
308
|
+
limit: n.number().int().min(1).max(100).optional().describe("Page size (default 20)"),
|
|
309
|
+
cursor: n.string().optional().describe("next_cursor from a previous response")
|
|
310
|
+
}, P = n.boolean().optional().describe("Owner/Admin only: break an active change freeze for this one change. Requires `reason`. Use it only after a change_frozen error says can_override is true.");
|
|
311
|
+
function F(e, t) {
|
|
312
|
+
if (e && !t?.trim()) return {
|
|
313
|
+
content: [{
|
|
314
|
+
type: "text",
|
|
315
|
+
text: "Error: freeze_override requires reason: say why this change must break the freeze."
|
|
316
|
+
}],
|
|
317
|
+
isError: !0
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
// src/tools/projects.ts
|
|
321
|
+
function ee(e, t) {
|
|
322
|
+
e.registerTool("list_projects", {
|
|
323
|
+
title: "List projects",
|
|
324
|
+
description: "List projects in the Featureflip organization. Paginated: pass cursor from next_cursor to continue.",
|
|
325
|
+
inputSchema: n.object({ ...N }),
|
|
326
|
+
outputSchema: w("GET /api/v1/orgs/{org}/projects"),
|
|
327
|
+
annotations: { readOnlyHint: !0 }
|
|
328
|
+
}, async ({ limit: e, cursor: n }) => h(async () => p(await t.api.request("GET", `/api/v1/orgs/${o(t.org)}/projects`, { query: {
|
|
329
|
+
limit: e,
|
|
330
|
+
cursor: n
|
|
331
|
+
} }))));
|
|
332
|
+
let r = `/api/v1/orgs/${o(t.org)}/projects`;
|
|
333
|
+
e.registerTool("manage_project", {
|
|
334
|
+
title: "Create or update a project",
|
|
335
|
+
description: "Create a project, or change its name/description. action=create needs key + name; action=update needs project and changes only the fields you pass (description: \"\" clears it). The key is immutable. Projects cannot be deleted from here.",
|
|
336
|
+
inputSchema: n.object({
|
|
337
|
+
action: n.enum(["create", "update"]).describe("create needs key + name; update needs project"),
|
|
338
|
+
project: k.optional().describe("Project key to update; required for update"),
|
|
339
|
+
key: n.string().optional().describe("New project key, required for create; immutable afterwards"),
|
|
340
|
+
name: n.string().optional().describe("Display name; required for create"),
|
|
341
|
+
description: n.string().optional().describe("What the project is for; \"\" clears it")
|
|
342
|
+
}),
|
|
343
|
+
outputSchema: D(x("POST /api/v1/orgs/{org}/projects"), O({
|
|
344
|
+
project: { type: "string" },
|
|
345
|
+
updated: { type: "boolean" },
|
|
346
|
+
name: y("string"),
|
|
347
|
+
description: y("string")
|
|
348
|
+
}, ["project", "updated"])),
|
|
349
|
+
annotations: { destructiveHint: !0 }
|
|
350
|
+
}, async ({ action: e, project: n, key: i, name: a, description: s }) => h(async () => {
|
|
351
|
+
if (e === "create") return !i || !a ? m(/* @__PURE__ */ Error("action=create requires key and name")) : p(await t.api.request("POST", r, { body: {
|
|
352
|
+
key: i,
|
|
353
|
+
name: a,
|
|
354
|
+
description: s
|
|
355
|
+
} }));
|
|
356
|
+
if (!n) return m(/* @__PURE__ */ Error("action=update requires project (see list_projects)"));
|
|
357
|
+
let c = `${r}/${o(n)}`, l = await t.api.request("GET", c), u = {
|
|
358
|
+
name: a ?? l.name,
|
|
359
|
+
description: s ?? l.description
|
|
360
|
+
};
|
|
361
|
+
return await t.api.request("PUT", c, { body: u }), p({
|
|
362
|
+
project: n,
|
|
363
|
+
updated: !0,
|
|
364
|
+
...u
|
|
365
|
+
});
|
|
366
|
+
})), e.registerTool("set_default_flag_lifetime", {
|
|
367
|
+
title: "Set or remove a project's default flag lifetime",
|
|
368
|
+
description: "Set how many days a temporary flag with no expiry date of its own lives before it counts as expired, or pass days: null to remove the default. Advisory only: evaluation never changes. Pass preview: true first to see how many flags would newly be, or stop being, past expiry without changing anything. Setting a value is refused with FEATURE_NOT_ENABLED when the organization's plan lacks it; removal is always allowed. The current value is defaultFlagLifetimeDays in list_projects.",
|
|
369
|
+
inputSchema: n.object({
|
|
370
|
+
project: k,
|
|
371
|
+
days: n.number().int().min(1).max(3650).nullable().describe("Lifetime in days (1–3650), or null to remove the default"),
|
|
372
|
+
preview: n.boolean().optional().default(!1).describe("true: only report the impact; nothing is changed")
|
|
373
|
+
}),
|
|
374
|
+
outputSchema: E({
|
|
375
|
+
project: { type: "string" },
|
|
376
|
+
defaultFlagLifetimeDays: y("integer"),
|
|
377
|
+
applied: {
|
|
378
|
+
type: "boolean",
|
|
379
|
+
description: "false for a preview"
|
|
380
|
+
},
|
|
381
|
+
newlyPastExpiry: {
|
|
382
|
+
type: "integer",
|
|
383
|
+
description: "Flags this would put past expiry"
|
|
384
|
+
},
|
|
385
|
+
noLongerPastExpiry: {
|
|
386
|
+
type: "integer",
|
|
387
|
+
description: "Flags this would take back out of expiry"
|
|
388
|
+
}
|
|
389
|
+
}, [
|
|
390
|
+
"project",
|
|
391
|
+
"defaultFlagLifetimeDays",
|
|
392
|
+
"applied",
|
|
393
|
+
"newlyPastExpiry",
|
|
394
|
+
"noLongerPastExpiry"
|
|
395
|
+
]),
|
|
396
|
+
annotations: {
|
|
397
|
+
destructiveHint: !1,
|
|
398
|
+
idempotentHint: !0
|
|
399
|
+
}
|
|
400
|
+
}, async ({ project: e, days: n, preview: i }) => h(async () => {
|
|
401
|
+
let a = `${r}/${o(e)}/default-flag-lifetime`, s = await t.api.request("GET", `${a}/impact`, { query: { days: n ?? void 0 } });
|
|
402
|
+
return i || await t.api.request("PUT", a, { body: { days: n } }), p({
|
|
403
|
+
project: e,
|
|
404
|
+
defaultFlagLifetimeDays: n,
|
|
405
|
+
applied: !i,
|
|
406
|
+
newlyPastExpiry: s.newlyPastExpiry,
|
|
407
|
+
noLongerPastExpiry: s.noLongerPastExpiry
|
|
408
|
+
});
|
|
409
|
+
}));
|
|
410
|
+
}
|
|
411
|
+
// src/tools/environments.ts
|
|
412
|
+
function te(e, t) {
|
|
413
|
+
e.registerTool("list_environments", {
|
|
414
|
+
title: "List environments",
|
|
415
|
+
description: "List the environments of a project (e.g. development, staging, production).",
|
|
416
|
+
inputSchema: n.object({
|
|
417
|
+
project: k,
|
|
418
|
+
...N
|
|
419
|
+
}),
|
|
420
|
+
outputSchema: w("GET /api/v1/orgs/{org}/projects/{project}/environments"),
|
|
421
|
+
annotations: { readOnlyHint: !0 }
|
|
422
|
+
}, async ({ project: e, limit: n, cursor: r }) => h(async () => p(await t.api.request("GET", `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/environments`, { query: {
|
|
423
|
+
limit: n,
|
|
424
|
+
cursor: r
|
|
425
|
+
} })))), e.registerTool("manage_environment", {
|
|
426
|
+
title: "Create or update an environment",
|
|
427
|
+
description: "Create an environment in a project, or change its name, color or sort order. action=create needs key + name; action=update needs environment and changes only the fields you pass. The key is immutable. Environments cannot be deleted from here. require_change_reason makes every write to the environment need a reason, and require_confirmation makes the dashboard ask for confirmation first; omit either on update to leave it unchanged. Turning either off needs an Admin or Owner token and a reason. A new environment needs an SDK key before apps can use it (manage_sdk_key).",
|
|
428
|
+
inputSchema: n.object({
|
|
429
|
+
action: n.enum(["create", "update"]).describe("create needs key + name; update needs environment"),
|
|
430
|
+
project: k,
|
|
431
|
+
environment: j.optional().describe("Environment key to update; required for update"),
|
|
432
|
+
key: n.string().optional().describe("New environment key, required for create; immutable afterwards"),
|
|
433
|
+
name: n.string().optional().describe("Display name; required for create"),
|
|
434
|
+
color: n.string().optional().describe("Hex color shown in the dashboard, e.g. #22c55e"),
|
|
435
|
+
sortOrder: n.number().int().optional().describe("Position in environment lists, lowest first"),
|
|
436
|
+
require_change_reason: n.boolean().optional().describe("Mark the environment critical: every change to it must carry a reason. Omit on update to leave unchanged"),
|
|
437
|
+
require_confirmation: n.boolean().optional().describe("Require explicit confirmation in the dashboard before changes to this environment. Omit on update to leave unchanged"),
|
|
438
|
+
reason: M
|
|
439
|
+
}),
|
|
440
|
+
outputSchema: D(x("POST /api/v1/orgs/{org}/projects/{project}/environments"), O({
|
|
441
|
+
environment: { type: "string" },
|
|
442
|
+
updated: { type: "boolean" },
|
|
443
|
+
name: y("string"),
|
|
444
|
+
color: y("string"),
|
|
445
|
+
sortOrder: y("integer"),
|
|
446
|
+
requireChangeReason: { type: "boolean" },
|
|
447
|
+
requireConfirmation: { type: "boolean" }
|
|
448
|
+
}, ["environment", "updated"])),
|
|
449
|
+
annotations: { destructiveHint: !0 }
|
|
450
|
+
}, async ({ action: e, project: n, environment: r, key: i, name: a, color: s, sortOrder: c, require_change_reason: l, require_confirmation: u, reason: d }) => h(async () => {
|
|
451
|
+
let f = {
|
|
452
|
+
requireChangeReason: l,
|
|
453
|
+
requireConfirmation: u
|
|
454
|
+
}, h = `/api/v1/orgs/${o(t.org)}/projects/${o(n)}/environments`;
|
|
455
|
+
if (e === "create") return !i || !a ? m(/* @__PURE__ */ Error("action=create requires key and name")) : p(await t.api.request("POST", h, {
|
|
456
|
+
body: {
|
|
457
|
+
key: i,
|
|
458
|
+
name: a,
|
|
459
|
+
color: s,
|
|
460
|
+
sortOrder: c,
|
|
461
|
+
...f
|
|
462
|
+
},
|
|
463
|
+
reason: d
|
|
464
|
+
}));
|
|
465
|
+
if (!r) return m(/* @__PURE__ */ Error("action=update requires environment (see list_environments)"));
|
|
466
|
+
let g = `${h}/${o(r)}`, { data: _, etag: v } = await t.api.requestWithEtag("GET", g), y = {
|
|
467
|
+
name: a ?? _.name,
|
|
468
|
+
color: s ?? _.color,
|
|
469
|
+
sortOrder: c ?? _.sortOrder,
|
|
470
|
+
...f
|
|
471
|
+
};
|
|
472
|
+
return await t.api.request("PUT", g, {
|
|
473
|
+
body: y,
|
|
474
|
+
ifMatch: v,
|
|
475
|
+
reason: d
|
|
476
|
+
}), p({
|
|
477
|
+
environment: r,
|
|
478
|
+
updated: !0,
|
|
479
|
+
...y
|
|
480
|
+
});
|
|
481
|
+
}));
|
|
482
|
+
}
|
|
483
|
+
// src/tools/sdk-keys.ts
|
|
484
|
+
var ne = "This is the only time the full key is returned; it cannot be shown again. Store it in a secret or an untracked .env file, never in source control or a chat log.";
|
|
485
|
+
function re(e, t) {
|
|
486
|
+
let r = (e, n) => `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/environments/${o(n)}/sdk-keys`;
|
|
487
|
+
e.registerTool("list_sdk_keys", {
|
|
488
|
+
title: "List SDK keys",
|
|
489
|
+
description: "List the SDK keys of one environment: id, name, type, last four characters, and whether each is active. The full key is never listed; it is shown once, when manage_sdk_key creates it.",
|
|
490
|
+
inputSchema: n.object({
|
|
491
|
+
project: k,
|
|
492
|
+
environment: j,
|
|
493
|
+
...N
|
|
494
|
+
}),
|
|
495
|
+
outputSchema: w("GET /api/v1/orgs/{org}/projects/{project}/environments/{env}/sdk-keys"),
|
|
496
|
+
annotations: { readOnlyHint: !0 }
|
|
497
|
+
}, async ({ project: e, environment: n, limit: i, cursor: a }) => h(async () => p(await t.api.request("GET", r(e, n), { query: {
|
|
498
|
+
limit: i,
|
|
499
|
+
cursor: a
|
|
500
|
+
} })))), e.registerTool("manage_sdk_key", {
|
|
501
|
+
title: "Create, rename, or revoke an SDK key",
|
|
502
|
+
description: "Manage an environment's SDK keys. action=create needs name + type and returns the full key ONCE (ServerSide for backend SDKs, ClientSide for browser/mobile). action=rename needs sdkKey and changes only the fields you pass. action=revoke needs sdkKey and stops the key working immediately; apps still using it lose flag updates; revoking a critical environment's key needs a reason. To rotate: create a new key, deploy it, then revoke the old one.",
|
|
503
|
+
inputSchema: n.object({
|
|
504
|
+
action: n.enum([
|
|
505
|
+
"create",
|
|
506
|
+
"rename",
|
|
507
|
+
"revoke"
|
|
508
|
+
]).describe("create needs name + type; rename and revoke need sdkKey"),
|
|
509
|
+
project: k,
|
|
510
|
+
environment: j,
|
|
511
|
+
sdkKey: n.string().optional().describe("SDK key id (see list_sdk_keys); required for rename and revoke"),
|
|
512
|
+
name: n.string().optional().describe("Key name; required for create"),
|
|
513
|
+
description: n.string().optional().describe("What the key is used for; \"\" clears it"),
|
|
514
|
+
type: n.enum(["ServerSide", "ClientSide"]).optional().describe("Required for create: ServerSide for backend SDKs, ClientSide for browser/mobile SDKs"),
|
|
515
|
+
reason: M
|
|
516
|
+
}),
|
|
517
|
+
outputSchema: D(O({
|
|
518
|
+
id: { type: "string" },
|
|
519
|
+
key: y("string"),
|
|
520
|
+
warning: { type: "string" }
|
|
521
|
+
}, ["warning"]), O({
|
|
522
|
+
sdkKey: { type: "string" },
|
|
523
|
+
renamed: { type: "boolean" },
|
|
524
|
+
name: y("string"),
|
|
525
|
+
description: y("string")
|
|
526
|
+
}, ["sdkKey", "renamed"]), O({ revoked: { type: "string" } }, ["revoked"])),
|
|
527
|
+
annotations: { destructiveHint: !0 }
|
|
528
|
+
}, async ({ action: e, project: n, environment: i, sdkKey: a, name: s, description: c, type: l, reason: u }) => h(async () => {
|
|
529
|
+
let d = r(n, i);
|
|
530
|
+
if (e === "create") {
|
|
531
|
+
if (!s || !l) return m(/* @__PURE__ */ Error("action=create requires name and type"));
|
|
532
|
+
let e = await t.api.request("POST", d, { body: {
|
|
533
|
+
name: s,
|
|
534
|
+
description: c,
|
|
535
|
+
type: l
|
|
536
|
+
} });
|
|
537
|
+
return p({
|
|
538
|
+
...e,
|
|
539
|
+
warning: e.warning ? `${e.warning} ${ne}` : ne
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
if (!a) return m(/* @__PURE__ */ Error(`action=${e} requires sdkKey (see list_sdk_keys)`));
|
|
543
|
+
let f = `${d}/${o(a)}`;
|
|
544
|
+
if (e === "rename") {
|
|
545
|
+
let e = await t.api.request("GET", f), n = {
|
|
546
|
+
name: s ?? e.name,
|
|
547
|
+
description: c ?? e.description
|
|
548
|
+
};
|
|
549
|
+
return await t.api.request("PUT", f, { body: n }), p({
|
|
550
|
+
sdkKey: a,
|
|
551
|
+
renamed: !0,
|
|
552
|
+
...n
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
return await t.api.request("POST", `${f}/revoke`, { reason: u }), p({ revoked: a });
|
|
556
|
+
}));
|
|
557
|
+
}
|
|
558
|
+
// src/tools/etag.ts
|
|
559
|
+
var I = {
|
|
560
|
+
type: "string",
|
|
561
|
+
description: "ETag of what was read. Pass it as ifMatch on the matching update so the write is refused (412) instead of overwriting a change made since."
|
|
562
|
+
}, L = {
|
|
563
|
+
type: "string",
|
|
564
|
+
description: "ETag of what this write left behind. Pass it as ifMatch on the next update to chain writes without re-reading. Absent when the API sent none; read the resource again before the next conditional write."
|
|
565
|
+
};
|
|
566
|
+
function R(e) {
|
|
567
|
+
return n.string().optional().describe(`etag from ${e}. The write is refused with 412 if the resource changed since that read; re-read and re-apply. Omit to write unconditionally.`);
|
|
568
|
+
}
|
|
569
|
+
function z({ data: e, etag: t }) {
|
|
570
|
+
return t ? {
|
|
571
|
+
...e,
|
|
572
|
+
etag: t
|
|
573
|
+
} : e;
|
|
574
|
+
}
|
|
575
|
+
// src/tools/segments.ts
|
|
576
|
+
function ie(e, t) {
|
|
577
|
+
e.registerTool("list_segments", {
|
|
578
|
+
title: "List user segments",
|
|
579
|
+
description: "List reusable user segments in a project. Segments are referenced from targeting rules via userSegmentId.",
|
|
580
|
+
inputSchema: n.object({
|
|
581
|
+
project: n.string().describe("Project key"),
|
|
582
|
+
...N
|
|
583
|
+
}),
|
|
584
|
+
outputSchema: w("GET /api/v1/orgs/{org}/projects/{project}/segments"),
|
|
585
|
+
annotations: { readOnlyHint: !0 }
|
|
586
|
+
}, async ({ project: e, limit: n, cursor: r }) => h(async () => p(await t.api.request("GET", `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/segments`, { query: {
|
|
587
|
+
limit: n,
|
|
588
|
+
cursor: r
|
|
589
|
+
} })))), e.registerTool("get_segment", {
|
|
590
|
+
title: "Get user segment",
|
|
591
|
+
description: "Get one user segment (its conditions, id, and metadata) by key or id.",
|
|
592
|
+
inputSchema: n.object({
|
|
593
|
+
project: n.string().describe("Project key"),
|
|
594
|
+
segment: n.string().describe("Segment key or id")
|
|
595
|
+
}),
|
|
596
|
+
outputSchema: T("GET /api/v1/orgs/{org}/projects/{project}/segments/{segment}", { etag: I }),
|
|
597
|
+
annotations: { readOnlyHint: !0 }
|
|
598
|
+
}, async ({ project: e, segment: n }) => h(async () => p(z(await t.api.requestWithEtag("GET", `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/segments/${o(n)}`)))));
|
|
599
|
+
let r = n.object({
|
|
600
|
+
attribute: n.string().describe("Context attribute name, e.g. plan, country, user_id"),
|
|
601
|
+
operator: n.string().describe("Case-sensitive: Equals, NotEquals, Contains, NotContains, GreaterThan, LessThan, GreaterThanOrEqual, LessThanOrEqual, In, NotIn, MatchesRegex, StartsWith, EndsWith, Before, After, SemverEquals, SemverGreaterThan, SemverGreaterThanOrEqual, SemverLessThan, SemverLessThanOrEqual"),
|
|
602
|
+
values: n.array(n.string()).describe("Values compared against the attribute"),
|
|
603
|
+
negate: n.boolean().optional().default(!1).describe("Invert the match")
|
|
604
|
+
}), i = (e) => ({
|
|
605
|
+
attribute: e.attribute,
|
|
606
|
+
operator: e.operator,
|
|
607
|
+
values: e.values,
|
|
608
|
+
negate: e.negate
|
|
609
|
+
});
|
|
610
|
+
e.registerTool("manage_segment", {
|
|
611
|
+
title: "Create, update, or delete a user segment",
|
|
612
|
+
description: "Manage reusable user segments, which targeting rules reference by userSegmentId. action=create needs key + name (+ conditions); action=update needs segment and changes only the fields you pass (conditions replaces the whole list; description: \"\" clears it); action=delete needs segment. On update, pass ifMatch (the etag from get_segment) so a change someone made since you read it is not overwritten. ifMatch is rejected on create and delete: the API cannot make those conditional. A conditions change is refused with change_frozen while a change freeze covers an environment where a live, enabled flag uses the segment; an Owner/Admin can pass freeze_override + reason (update only) to break it.",
|
|
613
|
+
inputSchema: n.object({
|
|
614
|
+
action: n.enum([
|
|
615
|
+
"create",
|
|
616
|
+
"update",
|
|
617
|
+
"delete"
|
|
618
|
+
]).describe("create needs key + name; update and delete need segment"),
|
|
619
|
+
project: k,
|
|
620
|
+
segment: n.string().optional().describe("Segment key or id; required for update and delete"),
|
|
621
|
+
key: n.string().optional().describe("New segment key, required for create; immutable afterwards"),
|
|
622
|
+
name: n.string().optional().describe("Display name; required for create"),
|
|
623
|
+
description: n.string().optional().describe("What the segment means; \"\" clears it"),
|
|
624
|
+
conditions: n.array(r).optional().describe("Conditions a user must match to be in the segment; on update, replaces the whole list"),
|
|
625
|
+
ifMatch: R("get_segment"),
|
|
626
|
+
reason: M,
|
|
627
|
+
freeze_override: P
|
|
628
|
+
}),
|
|
629
|
+
outputSchema: D(x("POST /api/v1/orgs/{org}/projects/{project}/segments"), O({
|
|
630
|
+
segment: { type: "string" },
|
|
631
|
+
updated: { type: "boolean" },
|
|
632
|
+
name: y("string"),
|
|
633
|
+
description: y("string"),
|
|
634
|
+
conditions: {
|
|
635
|
+
type: ["array", "null"],
|
|
636
|
+
items: { type: "object" }
|
|
637
|
+
},
|
|
638
|
+
etag: L
|
|
639
|
+
}, ["segment", "updated"]), O({ deleted: { type: "string" } }, ["deleted"])),
|
|
640
|
+
annotations: { destructiveHint: !0 }
|
|
641
|
+
}, async ({ action: e, project: n, segment: r, key: a, name: s, description: c, conditions: l, ifMatch: u, reason: d, freeze_override: f }) => h(async () => {
|
|
642
|
+
let h = F(f, d);
|
|
643
|
+
if (h) return h;
|
|
644
|
+
let g = `/api/v1/orgs/${o(t.org)}/projects/${o(n)}/segments`;
|
|
645
|
+
if (u !== void 0 && e !== "update") return m(/* @__PURE__ */ Error(`ifMatch is only supported on action=update; action=${e} cannot be made conditional`));
|
|
646
|
+
if (e === "create") return !a || !s ? m(/* @__PURE__ */ Error("action=create requires key and name")) : p(await t.api.request("POST", g, {
|
|
647
|
+
body: {
|
|
648
|
+
key: a,
|
|
649
|
+
name: s,
|
|
650
|
+
description: c,
|
|
651
|
+
conditions: l ?? []
|
|
652
|
+
},
|
|
653
|
+
reason: d
|
|
654
|
+
}));
|
|
655
|
+
if (!r) return m(/* @__PURE__ */ Error(`action=${e} requires segment (see list_segments)`));
|
|
656
|
+
let _ = `${g}/${o(r)}`;
|
|
657
|
+
if (e === "update") {
|
|
658
|
+
let { data: e, etag: n } = await t.api.requestWithEtag("GET", _), a = {
|
|
659
|
+
name: s ?? e.name,
|
|
660
|
+
description: c ?? e.description,
|
|
661
|
+
conditions: l ?? (e.conditions ?? []).map(i)
|
|
662
|
+
}, { etag: o } = await t.api.requestWithEtag("PUT", _, {
|
|
663
|
+
body: a,
|
|
664
|
+
ifMatch: u ?? n,
|
|
665
|
+
reason: d,
|
|
666
|
+
freezeOverride: f
|
|
667
|
+
});
|
|
668
|
+
return p(z({
|
|
669
|
+
data: {
|
|
670
|
+
segment: r,
|
|
671
|
+
updated: !0,
|
|
672
|
+
...a
|
|
673
|
+
},
|
|
674
|
+
etag: o
|
|
675
|
+
}));
|
|
676
|
+
}
|
|
677
|
+
return await t.api.request("DELETE", _, { reason: d }), p({ deleted: r });
|
|
678
|
+
}));
|
|
679
|
+
}
|
|
680
|
+
// src/tools/owner.ts
|
|
681
|
+
var ae = n.string().optional().describe("Only flags with this owner: an email, \"me\" for the token's own user, or \"none\" for unowned flags");
|
|
682
|
+
async function B(e, t) {
|
|
683
|
+
let n = t?.trim();
|
|
684
|
+
if (!n) return;
|
|
685
|
+
if (n.toLowerCase() !== "me") return n;
|
|
686
|
+
let r = await e.api.request("GET", "/api/v1/me");
|
|
687
|
+
if (r.type !== "user" || !r.email) throw Error("owner \"me\" needs a personal access token (ffp_...). A service token has no user, so it owns no flags; pass an owner email instead.");
|
|
688
|
+
return r.email;
|
|
689
|
+
}
|
|
690
|
+
// src/tools/flags.ts
|
|
691
|
+
var oe = n.enum([
|
|
692
|
+
"Boolean",
|
|
693
|
+
"String",
|
|
694
|
+
"Number",
|
|
695
|
+
"Json"
|
|
696
|
+
]);
|
|
697
|
+
function se(e, t) {
|
|
698
|
+
let r = (e) => `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/flags`;
|
|
699
|
+
e.registerTool("list_flags", {
|
|
700
|
+
title: "List feature flags",
|
|
701
|
+
description: "List feature flags in a project. Filter with search (key/name substring), tag, type, archived, owner. Each flag carries its owner ({id, email, name}, or null when unowned). Paginated via cursor.",
|
|
702
|
+
inputSchema: n.object({
|
|
703
|
+
project: k,
|
|
704
|
+
search: n.string().optional().describe("Substring of the flag key or name"),
|
|
705
|
+
tag: n.string().optional().describe("Only flags carrying this tag"),
|
|
706
|
+
type: oe.optional().describe("Only flags of this type"),
|
|
707
|
+
archived: n.boolean().optional().describe("true = only archived, false = only active"),
|
|
708
|
+
owner: ae,
|
|
709
|
+
...N
|
|
710
|
+
}),
|
|
711
|
+
outputSchema: w("GET /api/v1/orgs/{org}/projects/{project}/flags"),
|
|
712
|
+
annotations: { readOnlyHint: !0 }
|
|
713
|
+
}, async ({ project: e, owner: n, ...i }) => h(async () => p(await t.api.request("GET", r(e), { query: {
|
|
714
|
+
...i,
|
|
715
|
+
owner: await B(t, n)
|
|
716
|
+
} })))), e.registerTool("get_flag", {
|
|
717
|
+
title: "Get feature flag",
|
|
718
|
+
description: "Get one feature flag with its variations and metadata, including its owner (null when unowned). Address by flag key or id.",
|
|
719
|
+
inputSchema: n.object({
|
|
720
|
+
project: k,
|
|
721
|
+
flag: A
|
|
722
|
+
}),
|
|
723
|
+
outputSchema: T("GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}", { etag: I }),
|
|
724
|
+
annotations: { readOnlyHint: !0 }
|
|
725
|
+
}, async ({ project: e, flag: n }) => h(async () => p(z(await t.api.requestWithEtag("GET", `${r(e)}/${o(n)}`))))), e.registerTool("create_flag", {
|
|
726
|
+
title: "Create feature flag",
|
|
727
|
+
description: "Create a feature flag. type is one of Boolean|String|Number|Json. Boolean flags get true/false variations automatically; for other types pass initialVariations. The flag is created in every environment of the project (disabled).",
|
|
728
|
+
inputSchema: n.object({
|
|
729
|
+
project: k,
|
|
730
|
+
key: n.string().describe("Unique flag key, e.g. checkout-v2"),
|
|
731
|
+
name: n.string().describe("Display name"),
|
|
732
|
+
type: oe.describe("Value type; Boolean gets true/false variations automatically"),
|
|
733
|
+
description: n.string().optional().describe("What the flag controls"),
|
|
734
|
+
tags: n.array(n.string()).optional().describe("Tags for filtering, e.g. team or area"),
|
|
735
|
+
clientSideVisible: n.boolean().optional().describe("Expose to client-side SDKs (browser/mobile)"),
|
|
736
|
+
initialVariations: n.array(n.object({
|
|
737
|
+
key: n.string(),
|
|
738
|
+
name: n.string().optional(),
|
|
739
|
+
value: n.string().describe("Variation value serialized as a string"),
|
|
740
|
+
description: n.string().optional()
|
|
741
|
+
})).optional().describe("Variations for a String, Number or Json flag (Boolean flags get true/false automatically)"),
|
|
742
|
+
expiresAtUtc: n.string().optional().describe("Optional date (YYYY-MM-DD, end of that UTC day) or ISO-8601 timestamp the flag is expected to be removed by (see set_flag_expiry)"),
|
|
743
|
+
ownerEmail: n.string().optional().describe("Optional owner: the email of an active member (Pro plan and above, see set_flag_owner). Omitted, a personal access token makes its own user the owner and a service token leaves the flag unowned"),
|
|
744
|
+
isPermanent: n.boolean().optional().describe("Mark the flag permanent: a kill switch, ops toggle or entitlement gate that is meant to stay. Permanent flags are never listed as removal candidates or by find_stale_flags. Cannot be combined with expiresAtUtc"),
|
|
745
|
+
idempotency_key: n.string().optional().describe("Idempotency-Key header for safe retries")
|
|
746
|
+
}),
|
|
747
|
+
outputSchema: w("POST /api/v1/orgs/{org}/projects/{project}/flags"),
|
|
748
|
+
annotations: { destructiveHint: !1 }
|
|
749
|
+
}, async ({ project: e, idempotency_key: n, ...i }) => h(async () => p(await t.api.request("POST", r(e), {
|
|
750
|
+
body: i,
|
|
751
|
+
idempotencyKey: n
|
|
752
|
+
})))), e.registerTool("update_flag", {
|
|
753
|
+
title: "Update feature flag metadata",
|
|
754
|
+
description: "Update flag name/description/tags/clientSideVisible. Changes only the fields you pass and keeps the rest; changing clientSideVisible needs a reason when any environment of the project is critical. pass description: \"\" to clear it. Key and type are immutable. Use toggle_flag / update_targeting for behavior changes. Pass ifMatch (the etag from get_flag) to refuse the write if the flag changed since you read it.",
|
|
755
|
+
inputSchema: n.object({
|
|
756
|
+
project: k,
|
|
757
|
+
flag: A,
|
|
758
|
+
name: n.string().optional().describe("New display name"),
|
|
759
|
+
description: n.string().optional().describe("New description; \"\" clears it"),
|
|
760
|
+
tags: n.array(n.string()).optional().describe("Replaces the whole tag list"),
|
|
761
|
+
clientSideVisible: n.boolean().optional().describe("Expose to client-side SDKs (browser/mobile); false hides the flag from them entirely"),
|
|
762
|
+
ifMatch: R("get_flag"),
|
|
763
|
+
reason: M
|
|
764
|
+
}),
|
|
765
|
+
outputSchema: E({
|
|
766
|
+
project: { type: "string" },
|
|
767
|
+
flag: { type: "string" },
|
|
768
|
+
updated: { type: "boolean" },
|
|
769
|
+
etag: L
|
|
770
|
+
}, [
|
|
771
|
+
"project",
|
|
772
|
+
"flag",
|
|
773
|
+
"updated"
|
|
774
|
+
]),
|
|
775
|
+
annotations: { destructiveHint: !0 }
|
|
776
|
+
}, async ({ project: e, flag: n, name: i, description: a, tags: s, clientSideVisible: c, ifMatch: l, reason: u }) => h(async () => {
|
|
777
|
+
let d = `${r(e)}/${o(n)}`, f = i === void 0 || a === void 0 ? await t.api.requestWithEtag("GET", d) : void 0, m = f?.data, h = {
|
|
778
|
+
name: i ?? m?.name,
|
|
779
|
+
description: a ?? m?.description,
|
|
780
|
+
tags: s,
|
|
781
|
+
clientSideVisible: c
|
|
782
|
+
}, { etag: g } = await t.api.requestWithEtag("PUT", d, {
|
|
783
|
+
body: h,
|
|
784
|
+
ifMatch: l ?? f?.etag,
|
|
785
|
+
reason: u
|
|
786
|
+
});
|
|
787
|
+
return p(z({
|
|
788
|
+
data: {
|
|
789
|
+
project: e,
|
|
790
|
+
flag: n,
|
|
791
|
+
updated: !0
|
|
792
|
+
},
|
|
793
|
+
etag: g
|
|
794
|
+
}));
|
|
795
|
+
})), e.registerTool("set_flag_expiry", {
|
|
796
|
+
title: "Set or clear flag expiry",
|
|
797
|
+
description: "Set the date a flag is expected to be removed by, or pass expiresAtUtc: null to clear it. Expiry is advisory: evaluation never changes. Once the date passes, find_stale_flags reports the flag as expired. expiresAtUtc takes a date (2026-12-31), which means the end of that day in UTC, the same as picking it in the dashboard, or a full ISO-8601 timestamp, which is stored exactly. Refused with EXPIRY_IN_PAST for a time that has already passed (today's date is allowed), with FEATURE_NOT_ENABLED while flag expiration is not enabled for the organization, and with PERMANENT_FLAG_HAS_EXPIRY on a permanent flag (make it temporary first with set_flag_permanent). Clearing is always allowed.",
|
|
798
|
+
inputSchema: n.object({
|
|
799
|
+
project: k,
|
|
800
|
+
flag: A,
|
|
801
|
+
expiresAtUtc: n.string().nullable().describe("Date (YYYY-MM-DD, end of that UTC day) or ISO-8601 timestamp, or null to clear the expiry")
|
|
802
|
+
}),
|
|
803
|
+
outputSchema: E({
|
|
804
|
+
project: { type: "string" },
|
|
805
|
+
flag: { type: "string" },
|
|
806
|
+
expiresAtUtc: y("string")
|
|
807
|
+
}, [
|
|
808
|
+
"project",
|
|
809
|
+
"flag",
|
|
810
|
+
"expiresAtUtc"
|
|
811
|
+
]),
|
|
812
|
+
annotations: {
|
|
813
|
+
destructiveHint: !1,
|
|
814
|
+
idempotentHint: !0
|
|
815
|
+
}
|
|
816
|
+
}, async ({ project: e, flag: n, expiresAtUtc: i }) => h(async () => {
|
|
817
|
+
let a = `${r(e)}/${o(n)}/expiry`;
|
|
818
|
+
return i === null ? await t.api.request("DELETE", a) : await t.api.request("PUT", a, { body: { expiresAtUtc: i } }), p({
|
|
819
|
+
project: e,
|
|
820
|
+
flag: n,
|
|
821
|
+
expiresAtUtc: i
|
|
822
|
+
});
|
|
823
|
+
})), e.registerTool("set_flag_permanent", {
|
|
824
|
+
title: "Mark a flag permanent or temporary",
|
|
825
|
+
description: "Mark a flag permanent (a kill switch, ops toggle or entitlement gate that is meant to stay), or pass permanent: false to make it temporary again. Permanent flags are never listed as removal candidates or by find_stale_flags; evaluation never changes. Marking is refused with PERMANENT_FLAG_HAS_EXPIRY while the flag has an expiry date (clear it first with set_flag_expiry and expiresAtUtc: null), with FEATURE_NOT_ENABLED while permanent flags are not enabled for the organization, and on an archived flag. Making a flag temporary is always allowed.",
|
|
826
|
+
inputSchema: n.object({
|
|
827
|
+
project: k,
|
|
828
|
+
flag: A,
|
|
829
|
+
permanent: n.boolean().describe("true to mark the flag permanent, false to make it temporary")
|
|
830
|
+
}),
|
|
831
|
+
outputSchema: E({
|
|
832
|
+
project: { type: "string" },
|
|
833
|
+
flag: { type: "string" },
|
|
834
|
+
permanent: { type: "boolean" }
|
|
835
|
+
}, [
|
|
836
|
+
"project",
|
|
837
|
+
"flag",
|
|
838
|
+
"permanent"
|
|
839
|
+
]),
|
|
840
|
+
annotations: {
|
|
841
|
+
destructiveHint: !1,
|
|
842
|
+
idempotentHint: !0
|
|
843
|
+
}
|
|
844
|
+
}, async ({ project: e, flag: n, permanent: i }) => h(async () => {
|
|
845
|
+
let a = `${r(e)}/${o(n)}/permanent`;
|
|
846
|
+
return await t.api.request(i ? "PUT" : "DELETE", a), p({
|
|
847
|
+
project: e,
|
|
848
|
+
flag: n,
|
|
849
|
+
permanent: i
|
|
850
|
+
});
|
|
851
|
+
})), e.registerTool("set_flag_owner", {
|
|
852
|
+
title: "Set or clear flag owner",
|
|
853
|
+
description: "Name the person responsible for a flag, or pass owner: null to leave it unowned. owner is the email of an active member of the organization, or \"me\" for the token's own user (needs a personal access token). The owner gets the flag's cleanup notices; evaluation never changes. Refused with OWNER_NOT_MEMBER for an email that is not an active member, and with PLAN_FEATURE_UNAVAILABLE below the Pro plan. Clearing is always allowed.",
|
|
854
|
+
inputSchema: n.object({
|
|
855
|
+
project: k,
|
|
856
|
+
flag: A,
|
|
857
|
+
owner: n.string().nullable().describe("Owner email, \"me\" for the token's own user, or null (or \"none\") to clear the owner")
|
|
858
|
+
}),
|
|
859
|
+
outputSchema: E({
|
|
860
|
+
project: { type: "string" },
|
|
861
|
+
flag: { type: "string" },
|
|
862
|
+
owner: {
|
|
863
|
+
...y("string"),
|
|
864
|
+
description: "Owner email now set, or null when unowned"
|
|
865
|
+
}
|
|
866
|
+
}, [
|
|
867
|
+
"project",
|
|
868
|
+
"flag",
|
|
869
|
+
"owner"
|
|
870
|
+
]),
|
|
871
|
+
annotations: {
|
|
872
|
+
destructiveHint: !1,
|
|
873
|
+
idempotentHint: !0
|
|
874
|
+
}
|
|
875
|
+
}, async ({ project: e, flag: n, owner: i }) => h(async () => {
|
|
876
|
+
let a = `${r(e)}/${o(n)}/owner`, s = i?.trim().toLowerCase() === "none" ? void 0 : await B(t, i ?? void 0);
|
|
877
|
+
return s === void 0 ? await t.api.request("DELETE", a) : await t.api.request("PUT", a, { body: { email: s } }), p({
|
|
878
|
+
project: e,
|
|
879
|
+
flag: n,
|
|
880
|
+
owner: s ?? null
|
|
881
|
+
});
|
|
882
|
+
})), e.registerTool("delete_flag", {
|
|
883
|
+
title: "Delete feature flag",
|
|
884
|
+
description: "PERMANENTLY delete a flag across all environments. Fails with FLAG_HAS_DEPENDENTS if other flags use it as a prerequisite. Prefer archive_flag unless the flag must be fully removed.",
|
|
885
|
+
inputSchema: n.object({
|
|
886
|
+
project: k,
|
|
887
|
+
flag: A,
|
|
888
|
+
reason: M
|
|
889
|
+
}),
|
|
890
|
+
outputSchema: E({ deleted: { type: "string" } }, ["deleted"]),
|
|
891
|
+
annotations: { destructiveHint: !0 }
|
|
892
|
+
}, async ({ project: e, flag: n, reason: i }) => h(async () => (await t.api.request("DELETE", `${r(e)}/${o(n)}`, { reason: i }), p({ deleted: n })))), e.registerTool("archive_flag", {
|
|
893
|
+
title: "Archive feature flag",
|
|
894
|
+
description: "Archive a flag (soft-hide, evaluation stops serving it). Reversible with restore_flag. Archive dependents first: refused with FLAG_HAS_DEPENDENTS while another live flag lists this one as a prerequisite, so archive those flags (blockedBy in find_stale_flags / list_removal_candidates) first. Refused with FLAG_RECENTLY_EVALUATED while live traffic is still evaluating the flag, because archiving makes every caller fall back to its own hardcoded default — normally that means the code removal has merged but not deployed yet, and the refusal clears itself once it has.",
|
|
895
|
+
inputSchema: n.object({
|
|
896
|
+
project: k,
|
|
897
|
+
flag: A,
|
|
898
|
+
force: n.boolean().optional().describe("Archive even though traffic is still evaluating the flag. Only for clients that can never be updated (old mobile app versions), where traffic will never drain on its own."),
|
|
899
|
+
reason: M
|
|
900
|
+
}),
|
|
901
|
+
outputSchema: E({
|
|
902
|
+
flag: { type: "string" },
|
|
903
|
+
archived: { type: "boolean" }
|
|
904
|
+
}, ["flag", "archived"]),
|
|
905
|
+
annotations: { destructiveHint: !0 }
|
|
906
|
+
}, async ({ project: e, flag: n, force: i, reason: a }) => h(async () => (await t.api.request("POST", `${r(e)}/${o(n)}/archive`, {
|
|
907
|
+
query: i ? { force: !0 } : {},
|
|
908
|
+
reason: a
|
|
909
|
+
}), p({
|
|
910
|
+
flag: n,
|
|
911
|
+
archived: !0
|
|
912
|
+
})))), e.registerTool("restore_flag", {
|
|
913
|
+
title: "Restore archived flag",
|
|
914
|
+
description: "Restore a previously archived flag.",
|
|
915
|
+
inputSchema: n.object({
|
|
916
|
+
project: k,
|
|
917
|
+
flag: A,
|
|
918
|
+
reason: M
|
|
919
|
+
}),
|
|
920
|
+
outputSchema: E({
|
|
921
|
+
flag: { type: "string" },
|
|
922
|
+
archived: { type: "boolean" }
|
|
923
|
+
}, ["flag", "archived"]),
|
|
924
|
+
annotations: { destructiveHint: !1 }
|
|
925
|
+
}, async ({ project: e, flag: n, reason: i }) => h(async () => (await t.api.request("POST", `${r(e)}/${o(n)}/restore`, { reason: i }), p({
|
|
926
|
+
flag: n,
|
|
927
|
+
archived: !1
|
|
928
|
+
}))));
|
|
929
|
+
}
|
|
930
|
+
// src/tools/flag-environments.ts
|
|
931
|
+
var ce = n.enum([
|
|
932
|
+
"SingleVariation",
|
|
933
|
+
"PercentageRollout",
|
|
934
|
+
"TargetedRollout"
|
|
935
|
+
]);
|
|
936
|
+
function le(e, t) {
|
|
937
|
+
let r = (e, n) => `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/flags/${o(n)}`;
|
|
938
|
+
e.registerTool("toggle_flag", {
|
|
939
|
+
title: "Toggle flag in environment",
|
|
940
|
+
description: "Enable or disable a flag in ONE environment. Affects live evaluation immediately — double-check the environment.",
|
|
941
|
+
inputSchema: n.object({
|
|
942
|
+
project: k,
|
|
943
|
+
flag: A,
|
|
944
|
+
environment: j,
|
|
945
|
+
enabled: n.boolean().describe("true to turn the flag on in this environment, false to turn it off"),
|
|
946
|
+
reason: M,
|
|
947
|
+
freeze_override: P
|
|
948
|
+
}),
|
|
949
|
+
outputSchema: E({
|
|
950
|
+
project: { type: "string" },
|
|
951
|
+
flag: { type: "string" },
|
|
952
|
+
environment: { type: "string" },
|
|
953
|
+
enabled: { type: "boolean" }
|
|
954
|
+
}, [
|
|
955
|
+
"project",
|
|
956
|
+
"flag",
|
|
957
|
+
"environment",
|
|
958
|
+
"enabled"
|
|
959
|
+
]),
|
|
960
|
+
annotations: { destructiveHint: !0 }
|
|
961
|
+
}, async ({ project: e, flag: n, environment: i, enabled: a, reason: s, freeze_override: c }) => F(c, s) || h(async () => (await t.api.request("POST", `${r(e, n)}/environments/${o(i)}/toggle`, {
|
|
962
|
+
body: { enabled: a },
|
|
963
|
+
reason: s,
|
|
964
|
+
freezeOverride: c
|
|
965
|
+
}), p({
|
|
966
|
+
project: e,
|
|
967
|
+
flag: n,
|
|
968
|
+
environment: i,
|
|
969
|
+
enabled: a
|
|
970
|
+
})))), e.registerTool("update_flag_environment_config", {
|
|
971
|
+
title: "Update flag environment config",
|
|
972
|
+
description: "Update a flag's per-environment serving config: defaultVariationId (served on fallthrough, required), strategy (SingleVariation | PercentageRollout | TargetedRollout — only SingleVariation is currently supported at the environment level), and prerequisites. Percentage rollouts are configured on targeting rules via update_targeting.",
|
|
973
|
+
inputSchema: n.object({
|
|
974
|
+
project: k,
|
|
975
|
+
flag: A,
|
|
976
|
+
environment: j,
|
|
977
|
+
defaultVariationId: n.string().describe("Variation id to serve on fallthrough — required by the API"),
|
|
978
|
+
strategy: ce.optional().describe("Serving strategy; only SingleVariation is currently supported here"),
|
|
979
|
+
prerequisites: n.array(n.object({
|
|
980
|
+
prerequisiteFlagKey: n.string(),
|
|
981
|
+
expectedVariationKey: n.string()
|
|
982
|
+
})).optional().describe("Flags that must evaluate to the expected variation before this flag serves. Omit to leave existing prerequisites untouched; pass a list (possibly empty) to replace them wholesale."),
|
|
983
|
+
reason: M,
|
|
984
|
+
freeze_override: P
|
|
985
|
+
}),
|
|
986
|
+
outputSchema: E({
|
|
987
|
+
project: { type: "string" },
|
|
988
|
+
flag: { type: "string" },
|
|
989
|
+
environment: { type: "string" },
|
|
990
|
+
defaultVariationId: { type: "string" },
|
|
991
|
+
strategy: { type: "string" },
|
|
992
|
+
prerequisites: {
|
|
993
|
+
type: "array",
|
|
994
|
+
items: O({
|
|
995
|
+
prerequisiteFlagKey: { type: "string" },
|
|
996
|
+
expectedVariationKey: { type: "string" }
|
|
997
|
+
})
|
|
998
|
+
}
|
|
999
|
+
}, [
|
|
1000
|
+
"project",
|
|
1001
|
+
"flag",
|
|
1002
|
+
"environment",
|
|
1003
|
+
"defaultVariationId"
|
|
1004
|
+
]),
|
|
1005
|
+
annotations: { destructiveHint: !0 }
|
|
1006
|
+
}, async ({ project: e, flag: n, environment: i, reason: a, freeze_override: s, ...c }) => F(s, a) || h(async () => (await t.api.request("PUT", `${r(e, n)}/environments/${o(i)}`, {
|
|
1007
|
+
body: c,
|
|
1008
|
+
reason: a,
|
|
1009
|
+
freezeOverride: s
|
|
1010
|
+
}), p({
|
|
1011
|
+
project: e,
|
|
1012
|
+
flag: n,
|
|
1013
|
+
environment: i,
|
|
1014
|
+
...c
|
|
1015
|
+
})))), e.registerTool("flag_status", {
|
|
1016
|
+
title: "Flag status across environments",
|
|
1017
|
+
description: "Compact cross-environment view of one flag: enabled state, strategy, default variation, and prerequisites per environment.",
|
|
1018
|
+
inputSchema: n.object({
|
|
1019
|
+
project: k,
|
|
1020
|
+
flag: A
|
|
1021
|
+
}),
|
|
1022
|
+
outputSchema: E({
|
|
1023
|
+
key: y("string"),
|
|
1024
|
+
name: y("string"),
|
|
1025
|
+
type: y("string"),
|
|
1026
|
+
archived: { type: "boolean" },
|
|
1027
|
+
updatedAt: y("string"),
|
|
1028
|
+
environments: {
|
|
1029
|
+
type: "array",
|
|
1030
|
+
items: O({
|
|
1031
|
+
environment: y("string"),
|
|
1032
|
+
enabled: { type: "boolean" },
|
|
1033
|
+
strategy: y("string"),
|
|
1034
|
+
defaultVariation: {
|
|
1035
|
+
...y("string"),
|
|
1036
|
+
description: "Variation key served on fallthrough"
|
|
1037
|
+
},
|
|
1038
|
+
prerequisites: { type: "array" }
|
|
1039
|
+
})
|
|
1040
|
+
}
|
|
1041
|
+
}, [
|
|
1042
|
+
"key",
|
|
1043
|
+
"name",
|
|
1044
|
+
"type",
|
|
1045
|
+
"archived",
|
|
1046
|
+
"updatedAt",
|
|
1047
|
+
"environments"
|
|
1048
|
+
]),
|
|
1049
|
+
annotations: { readOnlyHint: !0 }
|
|
1050
|
+
}, async ({ project: e, flag: n }) => h(async () => {
|
|
1051
|
+
let [i, a] = await Promise.all([t.api.request("GET", r(e, n)), t.api.request("GET", `${r(e, n)}/environments`)]), o = (e) => (i.variations ?? []).find((t) => t.id === e)?.key ?? e ?? null;
|
|
1052
|
+
return p({
|
|
1053
|
+
key: i.key ?? null,
|
|
1054
|
+
name: i.name ?? null,
|
|
1055
|
+
type: i.type ?? null,
|
|
1056
|
+
archived: i.isArchived ?? !1,
|
|
1057
|
+
updatedAt: i.updatedAt ?? null,
|
|
1058
|
+
environments: a.map((e) => ({
|
|
1059
|
+
environment: e.environmentKey ?? null,
|
|
1060
|
+
enabled: e.isEnabled ?? !1,
|
|
1061
|
+
strategy: e.strategy ?? null,
|
|
1062
|
+
defaultVariation: o(e.defaultVariationId),
|
|
1063
|
+
prerequisites: e.prerequisites ?? []
|
|
1064
|
+
}))
|
|
1065
|
+
});
|
|
1066
|
+
})), e.registerTool("flag_evaluations", {
|
|
1067
|
+
title: "Flag evaluations in environment",
|
|
1068
|
+
description: "What a flag actually served in ONE environment over the last 7, 30 or 90 days: total evaluations, the split by variation, and which rule (or fallthrough, off, prerequisite, error) served what. Percentage-rollout rules include their configured weights and a sample-ratio check; rollout.flagged=true means the served split is statistically off the configured weights. A live rollout rule is always listed, with count 0 and no variations when it served nothing. rollout.unreached is set when a live rollout rule got no evaluations while the flag's rules got 100 or more: usually the context lacks rollout.bucketBy, or an earlier rule or the conditions catch the traffic. These are evaluation counts, NOT unique users. Counts come from SDK-reported events, so zero means no evaluations were reported, not necessarily no traffic.",
|
|
1069
|
+
inputSchema: n.object({
|
|
1070
|
+
project: k,
|
|
1071
|
+
flag: A,
|
|
1072
|
+
environment: j,
|
|
1073
|
+
days: n.union([
|
|
1074
|
+
n.literal(7),
|
|
1075
|
+
n.literal(30),
|
|
1076
|
+
n.literal(90)
|
|
1077
|
+
]).optional().describe("Window in UTC days: 7 (default), 30 or 90")
|
|
1078
|
+
}),
|
|
1079
|
+
outputSchema: w("GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/evaluations"),
|
|
1080
|
+
annotations: { readOnlyHint: !0 }
|
|
1081
|
+
}, async ({ project: e, flag: n, environment: i, days: a }) => h(async () => p(await t.api.request("GET", `${r(e, n)}/environments/${o(i)}/evaluations`, { query: { days: a ?? 7 } }))));
|
|
1082
|
+
}
|
|
1083
|
+
// src/tools/flag-triggers.ts
|
|
1084
|
+
var V = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, H = "GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/triggers", ue = "Relay the url (or endpoint + secret) to the user verbatim so they can paste it into their monitoring tool, where it should be stored as a secret. Never write it to source control or a chat log. If it leaks, rotate it.", de = "The old URL stopped working the moment this returned: update the monitoring tool now.", fe = [["PLAN_FEATURE_UNAVAILABLE", "Flag triggers need the Team plan or above. On a lower plan you can still list, rename, disable and delete existing triggers, but not create, re-enable or rotate one. An organization Owner can upgrade in Billing."], ["FEATURE_NOT_ENABLED", "Flag triggers are not enabled for this organization yet. Nothing in the request is wrong, and retrying will not help until they are."]];
|
|
1085
|
+
function pe(e) {
|
|
1086
|
+
if (!(e instanceof i)) return;
|
|
1087
|
+
let t = [e.envelope.message, ...Object.values(e.envelope.fields ?? {}).flat()].join("\n");
|
|
1088
|
+
return fe.find(([e]) => t.includes(e))?.[1];
|
|
1089
|
+
}
|
|
1090
|
+
async function U(e) {
|
|
1091
|
+
try {
|
|
1092
|
+
return await e();
|
|
1093
|
+
} catch (e) {
|
|
1094
|
+
let t = m(e), n = pe(e);
|
|
1095
|
+
return n && (t.content[0].text += `\n${n}`), t;
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
var W = (e) => m(/* @__PURE__ */ Error(`trigger must be a trigger id, not "${e}": triggers have no key. See list_flag_triggers.`));
|
|
1099
|
+
function me(e, t) {
|
|
1100
|
+
let r = (e, n, r) => `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/flags/${o(n)}/environments/${o(r)}/triggers`;
|
|
1101
|
+
e.registerTool("list_flag_triggers", {
|
|
1102
|
+
title: "List flag triggers",
|
|
1103
|
+
description: "List a flag's triggers in one environment, or get one by passing trigger: id, name, action (Enable or Disable), whether each is enabled, the last four characters of its secret, and when it last fired. A trigger is a secret URL that a monitoring tool (a Grafana alert, a Datadog monitor) calls to turn the flag on or off. The URL is never listed; it is shown once, when manage_flag_trigger creates or rotates it.",
|
|
1104
|
+
inputSchema: n.object({
|
|
1105
|
+
project: k,
|
|
1106
|
+
flag: A,
|
|
1107
|
+
environment: j,
|
|
1108
|
+
trigger: n.string().optional().describe("Trigger id: get just that trigger instead of listing"),
|
|
1109
|
+
...N
|
|
1110
|
+
}),
|
|
1111
|
+
outputSchema: D(x(H), x(`${H}/{trigger}`)),
|
|
1112
|
+
annotations: { readOnlyHint: !0 }
|
|
1113
|
+
}, async ({ project: e, flag: n, environment: i, trigger: a, limit: s, cursor: c }) => U(async () => {
|
|
1114
|
+
let l = r(e, n, i);
|
|
1115
|
+
return a === void 0 ? p(await t.api.request("GET", l, { query: {
|
|
1116
|
+
limit: s,
|
|
1117
|
+
cursor: c
|
|
1118
|
+
} })) : V.test(a) ? p(await t.api.request("GET", `${l}/${o(a)}`)) : W(a);
|
|
1119
|
+
})), e.registerTool("manage_flag_trigger", {
|
|
1120
|
+
title: "Create, update, rotate, or delete a flag trigger",
|
|
1121
|
+
description: "Manage a flag's triggers in one environment. A trigger is a secret URL a monitoring tool POSTs to (no body) to turn the flag on (Enable) or off (Disable); calling it when the flag is already in that state changes nothing. action=create needs name + triggerAction and returns the URL ONCE. action=update needs trigger and changes only the fields you pass (name, description, enabled; enabled=false stops the URL working until re-enabled). action=rotate needs trigger: the old URL stops working at once and the new one is returned ONCE. action=delete needs trigger. The action (Enable/Disable) is fixed at creation. Creating, re-enabling and rotating need the Team plan or above; every write needs a Member token; at most 10 per flag per environment. To change the flag yourself, use toggle_flag instead.",
|
|
1122
|
+
inputSchema: n.object({
|
|
1123
|
+
action: n.enum([
|
|
1124
|
+
"create",
|
|
1125
|
+
"update",
|
|
1126
|
+
"rotate",
|
|
1127
|
+
"delete"
|
|
1128
|
+
]).describe("create needs name + triggerAction; update, rotate and delete need trigger"),
|
|
1129
|
+
project: k,
|
|
1130
|
+
flag: A,
|
|
1131
|
+
environment: j,
|
|
1132
|
+
trigger: n.string().optional().describe("Trigger id (see list_flag_triggers); required for update, rotate and delete"),
|
|
1133
|
+
name: n.string().optional().describe("Trigger name, e.g. \"Grafana: checkout error rate\"; required for create"),
|
|
1134
|
+
triggerAction: n.enum(["Enable", "Disable"]).optional().describe("Required for create: Disable turns the flag off (a kill switch), Enable turns it on"),
|
|
1135
|
+
description: n.string().optional().describe("What calls the trigger and why; \"\" clears it"),
|
|
1136
|
+
enabled: n.boolean().optional().describe("update only: false stops the URL working, true turns it back on"),
|
|
1137
|
+
reason: M,
|
|
1138
|
+
idempotency_key: n.string().optional().describe("Idempotency-Key header for create")
|
|
1139
|
+
}),
|
|
1140
|
+
outputSchema: D(x("POST /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/triggers"), x("PUT /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/triggers/{trigger}"), O({ deleted: { type: "string" } }, ["deleted"])),
|
|
1141
|
+
annotations: { destructiveHint: !0 }
|
|
1142
|
+
}, async ({ action: e, project: n, flag: i, environment: a, trigger: s, name: c, triggerAction: l, description: u, enabled: d, reason: f, idempotency_key: h }) => U(async () => {
|
|
1143
|
+
let g = r(n, i, a), _ = (e, ...t) => p({
|
|
1144
|
+
...e,
|
|
1145
|
+
warning: [
|
|
1146
|
+
...t,
|
|
1147
|
+
e.warning,
|
|
1148
|
+
ue
|
|
1149
|
+
].filter(Boolean).join(" ")
|
|
1150
|
+
});
|
|
1151
|
+
if (e === "create") return !c || !l ? m(/* @__PURE__ */ Error("action=create requires name and triggerAction")) : _(await t.api.request("POST", g, {
|
|
1152
|
+
body: {
|
|
1153
|
+
name: c,
|
|
1154
|
+
action: l,
|
|
1155
|
+
description: u
|
|
1156
|
+
},
|
|
1157
|
+
idempotencyKey: h,
|
|
1158
|
+
reason: f
|
|
1159
|
+
}));
|
|
1160
|
+
if (!s) return m(/* @__PURE__ */ Error(`action=${e} requires trigger (see list_flag_triggers)`));
|
|
1161
|
+
if (!V.test(s)) return W(s);
|
|
1162
|
+
let v = `${g}/${o(s)}`;
|
|
1163
|
+
if (e === "update") {
|
|
1164
|
+
if (c === void 0 && u === void 0 && d === void 0) return m(/* @__PURE__ */ Error("action=update needs at least one of name, description or enabled"));
|
|
1165
|
+
let e = await t.api.request("GET", v), n = {
|
|
1166
|
+
name: c ?? e.name,
|
|
1167
|
+
description: u === "" ? null : u ?? e.description ?? null,
|
|
1168
|
+
enabled: d ?? e.enabled
|
|
1169
|
+
};
|
|
1170
|
+
return p(await t.api.request("PUT", v, {
|
|
1171
|
+
body: n,
|
|
1172
|
+
reason: f
|
|
1173
|
+
}));
|
|
1174
|
+
}
|
|
1175
|
+
return e === "rotate" ? _(await t.api.request("POST", `${v}/rotate`, { reason: f }), de) : (await t.api.request("DELETE", v, { reason: f }), p({ deleted: s }));
|
|
1176
|
+
}));
|
|
1177
|
+
}
|
|
1178
|
+
// src/tools/change-freezes.ts
|
|
1179
|
+
var G = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, K = "GET /api/v1/orgs/{org}/change-freezes", q = (e, t) => m(/* @__PURE__ */ Error(`${e} must be a UUID, not "${t}". See list_change_freezes.`));
|
|
1180
|
+
function he(e, t) {
|
|
1181
|
+
let r = () => `/api/v1/orgs/${o(t.org)}/change-freezes`;
|
|
1182
|
+
e.registerTool("list_change_freezes", {
|
|
1183
|
+
title: "List change freezes",
|
|
1184
|
+
description: "List change freeze windows, or get one by passing freeze_id. A freeze blocks flag changes in the environments it covers (toggles, targeting, ramps, copies) until it ends; scheduled changes due inside it are held or failed per its policy. Filter by status (Upcoming, Active, Ended) and project. Each window shows its environments, end time, scheduledChangePolicy and the approvals that let scheduled changes through. A single get also returns an etag for manage_change_freeze action=update. Listing and getting work on any plan.",
|
|
1185
|
+
inputSchema: n.object({
|
|
1186
|
+
freeze_id: n.string().optional().describe("Freeze id: get just that window instead of listing"),
|
|
1187
|
+
status: n.enum([
|
|
1188
|
+
"Upcoming",
|
|
1189
|
+
"Active",
|
|
1190
|
+
"Ended"
|
|
1191
|
+
]).optional().describe("Only windows in this state"),
|
|
1192
|
+
project: k.optional().describe("Only windows for this project key (project windows)"),
|
|
1193
|
+
...N
|
|
1194
|
+
}),
|
|
1195
|
+
outputSchema: D(x(K), x(`${K}/{id}`)),
|
|
1196
|
+
annotations: { readOnlyHint: !0 }
|
|
1197
|
+
}, async ({ freeze_id: e, status: n, project: i, limit: a, cursor: s }) => h(async () => e !== void 0 && (n !== void 0 || i !== void 0) ? m(/* @__PURE__ */ Error("freeze_id gets one window and cannot be combined with status or project filters")) : e === void 0 ? p(await t.api.request("GET", r(), { query: {
|
|
1198
|
+
status: n,
|
|
1199
|
+
project: i,
|
|
1200
|
+
limit: a,
|
|
1201
|
+
cursor: s
|
|
1202
|
+
} })) : G.test(e) ? p(z(await t.api.requestWithEtag("GET", `${r()}/${o(e)}`))) : q("freeze_id", e))), e.registerTool("manage_change_freeze", {
|
|
1203
|
+
title: "Create, edit, end, or delete a change freeze",
|
|
1204
|
+
description: "Manage change freeze windows. action=create makes a window: name + reason + environments (keys) or all_environments. Give starts_at and ends_at to schedule it; omit starts_at to start at once, and omit ends_at for an open-ended freeze (a scheduled window with starts_at needs ends_at). action=freeze_now starts at once and never takes starts_at; it may leave ends_at open until you end it. Pass project for a project window; omit it for an organization-wide one. scheduled_change_policy: Hold (default) keeps scheduled changes pending until the freeze ends, Fail fails them. action=update needs freeze_id and changes only the fields you pass (accepts ifMatch). action=end stops an active window now. action=delete removes an UPCOMING window. action=approve_scheduled_change (freeze_id + scheduled_change_id + reason) lets one pending scheduled change apply inside the freeze; revoke_approval withdraws it. Creating a window or approving a change needs the Business plan or above (below it, update can only rename, change the reason or shorten); ending, deleting and revoking work on any plan. All need an Admin token.",
|
|
1205
|
+
inputSchema: n.object({
|
|
1206
|
+
action: n.enum([
|
|
1207
|
+
"create",
|
|
1208
|
+
"freeze_now",
|
|
1209
|
+
"update",
|
|
1210
|
+
"end",
|
|
1211
|
+
"delete",
|
|
1212
|
+
"approve_scheduled_change",
|
|
1213
|
+
"revoke_approval"
|
|
1214
|
+
]).describe("create and freeze_now need name + reason + environments or all_environments; update, end and delete need freeze_id; approve_scheduled_change needs freeze_id + scheduled_change_id + reason; revoke_approval needs freeze_id + scheduled_change_id"),
|
|
1215
|
+
freeze_id: n.string().optional().describe("Freeze id (see list_change_freezes)"),
|
|
1216
|
+
name: n.string().optional().describe("Window name, e.g. \"Black Friday code freeze\""),
|
|
1217
|
+
reason: n.string().optional().describe("Why the freeze exists (shown to people it blocks); for approve_scheduled_change, why the change may proceed"),
|
|
1218
|
+
project: k.optional().describe("Project key for a project window; omit for organization-wide"),
|
|
1219
|
+
environments: n.array(n.string()).optional().describe("Environment keys the window covers, e.g. [\"production\"]"),
|
|
1220
|
+
all_environments: n.boolean().optional().describe("Cover every environment instead of listing them"),
|
|
1221
|
+
starts_at: n.string().optional().describe("ISO 8601 UTC start. create only: omit (or use freeze_now) to freeze immediately"),
|
|
1222
|
+
ends_at: n.string().optional().describe("ISO 8601 UTC end. On create: required when scheduling (with starts_at); omitting it with no starts_at makes an open-ended freeze. On update: omitting it leaves the end unchanged."),
|
|
1223
|
+
scheduled_change_policy: n.enum(["Hold", "Fail"]).optional().describe("What happens to scheduled changes that come due inside the window (default Hold)"),
|
|
1224
|
+
scheduled_change_id: n.string().optional().describe("Scheduled change id, for approve_scheduled_change and revoke_approval"),
|
|
1225
|
+
ifMatch: R("list_change_freezes with freeze_id"),
|
|
1226
|
+
idempotency_key: n.string().uuid().optional().describe("Idempotency-Key (a UUID) for create, freeze_now, end and approve_scheduled_change")
|
|
1227
|
+
}),
|
|
1228
|
+
outputSchema: D(x("POST /api/v1/orgs/{org}/change-freezes"), x("PATCH /api/v1/orgs/{org}/change-freezes/{id}"), x("POST /api/v1/orgs/{org}/change-freezes/{id}/approvals"), O({
|
|
1229
|
+
deleted: { type: "string" },
|
|
1230
|
+
etag: L
|
|
1231
|
+
}, ["deleted"])),
|
|
1232
|
+
annotations: { destructiveHint: !0 }
|
|
1233
|
+
}, async (e) => h(async () => {
|
|
1234
|
+
let { action: n, freeze_id: i, name: a, reason: s, project: c, environments: l, all_environments: u, starts_at: d, ends_at: f } = e, h = (e) => m(Error(e));
|
|
1235
|
+
if (n === "create" || n === "freeze_now") {
|
|
1236
|
+
if (n === "freeze_now" && d) return h("freeze_now starts at once; use action=create with starts_at to schedule");
|
|
1237
|
+
if (!a || !s) return h(`action=${n} requires name and reason`);
|
|
1238
|
+
if (!l?.length && !u) return h(`action=${n} requires environments (keys) or all_environments: true`);
|
|
1239
|
+
if (n === "create" && d && !f) return h("a scheduled freeze (starts_at set) requires ends_at; only freeze_now may be open-ended");
|
|
1240
|
+
let i = {
|
|
1241
|
+
name: a,
|
|
1242
|
+
reason: s,
|
|
1243
|
+
project: c,
|
|
1244
|
+
allEnvironments: u ?? (!l?.length && void 0),
|
|
1245
|
+
environmentKeys: l,
|
|
1246
|
+
startsAt: n === "create" ? d : void 0,
|
|
1247
|
+
endsAt: f,
|
|
1248
|
+
scheduledChangePolicy: e.scheduled_change_policy
|
|
1249
|
+
};
|
|
1250
|
+
return p(await t.api.request("POST", r(), {
|
|
1251
|
+
body: ge(i),
|
|
1252
|
+
idempotencyKey: e.idempotency_key
|
|
1253
|
+
}));
|
|
1254
|
+
}
|
|
1255
|
+
if (!i) return h(`action=${n} requires freeze_id (see list_change_freezes)`);
|
|
1256
|
+
if (!G.test(i)) return q("freeze_id", i);
|
|
1257
|
+
let g = `${r()}/${o(i)}`;
|
|
1258
|
+
if (n === "update") {
|
|
1259
|
+
if (c !== void 0) return h("a window's project cannot be changed; create a new window instead");
|
|
1260
|
+
let n = ge({
|
|
1261
|
+
name: a,
|
|
1262
|
+
reason: s,
|
|
1263
|
+
allEnvironments: u,
|
|
1264
|
+
environmentKeys: l,
|
|
1265
|
+
startsAt: d,
|
|
1266
|
+
endsAt: f,
|
|
1267
|
+
scheduledChangePolicy: e.scheduled_change_policy
|
|
1268
|
+
});
|
|
1269
|
+
return Object.keys(n).length === 0 ? h("action=update needs at least one field to change") : p(z(await t.api.requestWithEtag("PATCH", g, {
|
|
1270
|
+
body: n,
|
|
1271
|
+
ifMatch: e.ifMatch
|
|
1272
|
+
})));
|
|
1273
|
+
}
|
|
1274
|
+
if (n === "end") return p(await t.api.request("POST", `${g}/end`, { idempotencyKey: e.idempotency_key }));
|
|
1275
|
+
if (n === "delete") return await t.api.request("DELETE", g), p({ deleted: i });
|
|
1276
|
+
let _ = e.scheduled_change_id;
|
|
1277
|
+
return _ ? G.test(_) ? n === "approve_scheduled_change" ? s ? p(await t.api.request("POST", `${g}/approvals`, {
|
|
1278
|
+
body: {
|
|
1279
|
+
scheduledChangeId: _,
|
|
1280
|
+
reason: s
|
|
1281
|
+
},
|
|
1282
|
+
idempotencyKey: e.idempotency_key
|
|
1283
|
+
})) : h("action=approve_scheduled_change requires reason") : (await t.api.request("DELETE", `${g}/approvals/${o(_)}`), p({ deleted: _ })) : q("scheduled_change_id", _) : h(`action=${n} requires scheduled_change_id`);
|
|
1284
|
+
}));
|
|
1285
|
+
}
|
|
1286
|
+
function ge(e) {
|
|
1287
|
+
return Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0));
|
|
1288
|
+
}
|
|
1289
|
+
// src/tools/rollout-ramps.ts
|
|
1290
|
+
var J = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, _e = "/api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}", ve = `GET ${_e}/ramps`, ye = `GET ${_e}/ramps/{rampId}`, be = [["PLAN_FEATURE_UNAVAILABLE", "Starting a rollout ramp needs the Team plan or above. A ramp already running keeps running and can still be paused or aborted. An organization Owner can upgrade in Billing."], ["FEATURE_NOT_ENABLED", "Rollout ramps are not enabled for this organization yet. Nothing in the request is wrong, and retrying will not help until they are."]];
|
|
1291
|
+
function xe(e) {
|
|
1292
|
+
if (!(e instanceof i)) return;
|
|
1293
|
+
let t = [e.envelope.message, ...Object.values(e.envelope.fields ?? {}).flat()].join("\n");
|
|
1294
|
+
return be.find(([e]) => t.includes(e))?.[1];
|
|
1295
|
+
}
|
|
1296
|
+
async function Se(e) {
|
|
1297
|
+
try {
|
|
1298
|
+
return await e();
|
|
1299
|
+
} catch (e) {
|
|
1300
|
+
let t = m(e), n = xe(e);
|
|
1301
|
+
return n && (t.content[0].text += `\n${n}`), t;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
var Y = (e, t, n) => m(/* @__PURE__ */ Error(`${e} must be an id, not "${t}". See ${n}.`)), Ce = 5, we = n.object({
|
|
1305
|
+
percent: n.number().int().min(1).max(100).describe("Rollout percentage for this step, 1-100"),
|
|
1306
|
+
holdMinutes: n.number().int().min(0).max(43200).describe("Minutes to hold at this step before the next one: 5 to 43200 (30 days); 0 to 43200 on the last step")
|
|
1307
|
+
});
|
|
1308
|
+
function Te(e, t) {
|
|
1309
|
+
let r = (e, n, r) => `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/flags/${o(n)}/environments/${o(r)}`;
|
|
1310
|
+
e.registerTool("list_rollout_ramps", {
|
|
1311
|
+
title: "List rollout ramps",
|
|
1312
|
+
description: "List a flag's rollout ramps in one environment (the active ones, newest first, then the ten most recently finished), or get one by passing ramp. A ramp raises a percentage rollout one step at a time on a timer. Each ramp shows its status (Running, Paused, Completed, Aborted), its steps, currentStepIndex, nextStepAt, and why it paused. A single ramp comes with an etag to pass as ifMatch to manage_rollout_ramp.",
|
|
1313
|
+
inputSchema: n.object({
|
|
1314
|
+
project: k,
|
|
1315
|
+
flag: A,
|
|
1316
|
+
environment: j,
|
|
1317
|
+
ramp: n.string().optional().describe("Ramp id: get just that ramp (with its etag) instead of listing"),
|
|
1318
|
+
...N
|
|
1319
|
+
}),
|
|
1320
|
+
outputSchema: D(x(ve), x(ye)),
|
|
1321
|
+
annotations: { readOnlyHint: !0 }
|
|
1322
|
+
}, async ({ project: e, flag: n, environment: i, ramp: a, limit: s, cursor: c }) => Se(async () => {
|
|
1323
|
+
let l = `${r(e, n, i)}/ramps`;
|
|
1324
|
+
return a === void 0 ? p(await t.api.request("GET", l, { query: {
|
|
1325
|
+
limit: s,
|
|
1326
|
+
cursor: c
|
|
1327
|
+
} })) : J.test(a) ? p(z(await t.api.requestWithEtag("GET", `${l}/${o(a)}`))) : Y("ramp", a, "list_rollout_ramps");
|
|
1328
|
+
})), e.registerTool("manage_rollout_ramp", {
|
|
1329
|
+
title: "Start, pause, resume, advance, or abort a rollout ramp",
|
|
1330
|
+
description: "Manage a rollout ramp on a flag in one environment. A ramp raises a percentage rollout step by step: it applies the first step at once, then each next step when the previous hold runs out. Every step is an audited rule change that reaches SDKs over the stream. action=start needs rule + steps: rule is a targeting rule id (from get_targeting) whose rule serves a percentage rollout, or \"default\" for the default rule. Steps (1 to 20) must rise, the first not below the rule's current rollout. A default-rule ramp may name the variation to ramp to (variation id; needed when the default rule has no rollout yet) and bucketBy, and on reaching 100% makes that variation the default. The flag must be on in the environment. action=pause keeps the rest of the hold; action=resume continues from the rule as it stands now; action=advance applies the next step now and needs expectedStepIndex (the currentStepIndex you last saw); action=abort stops the ramp and leaves the rule at percent (0-100, at or below the current one). pause, resume, advance and abort need ramp and accept ifMatch. Editing the rule by hand or turning the flag off pauses a ramp. Starting needs the Team plan or above; every write needs a Member token.",
|
|
1331
|
+
inputSchema: n.object({
|
|
1332
|
+
action: n.enum([
|
|
1333
|
+
"start",
|
|
1334
|
+
"pause",
|
|
1335
|
+
"resume",
|
|
1336
|
+
"advance",
|
|
1337
|
+
"abort"
|
|
1338
|
+
]).describe("start needs rule + steps; the others need ramp"),
|
|
1339
|
+
project: k,
|
|
1340
|
+
flag: A,
|
|
1341
|
+
environment: j,
|
|
1342
|
+
rule: n.string().optional().describe("start only: the targeting rule id (see get_targeting), or \"default\" for the default rule"),
|
|
1343
|
+
steps: n.array(we).min(1).max(20).optional().describe("start only: the ladder, in rising order"),
|
|
1344
|
+
variation: n.string().optional().describe("start on rule=\"default\" only: the variation id to ramp to (see get_flag)"),
|
|
1345
|
+
bucketBy: n.string().optional().describe("start on rule=\"default\" only: the context attribute to bucket by (default: key)"),
|
|
1346
|
+
ramp: n.string().optional().describe("Ramp id (see list_rollout_ramps); required for every action but start"),
|
|
1347
|
+
expectedStepIndex: n.number().int().min(0).optional().describe("advance only (required): the currentStepIndex you last saw; a ramp that moved on is refused (409)"),
|
|
1348
|
+
percent: n.number().int().min(0).max(100).optional().describe("abort only (required): the rollout percentage to leave the rule at"),
|
|
1349
|
+
ifMatch: R("list_rollout_ramps with ramp"),
|
|
1350
|
+
reason: M,
|
|
1351
|
+
freeze_override: P,
|
|
1352
|
+
idempotency_key: n.string().optional().describe("Idempotency-Key header for start")
|
|
1353
|
+
}),
|
|
1354
|
+
outputSchema: T(ye, { etag: L }),
|
|
1355
|
+
annotations: { destructiveHint: !0 }
|
|
1356
|
+
}, async ({ action: e, project: n, flag: i, environment: a, rule: s, steps: c, variation: l, bucketBy: u, ramp: d, expectedStepIndex: f, percent: h, ifMatch: g, reason: _, freeze_override: v, idempotency_key: y }) => {
|
|
1357
|
+
let b = F(v, _);
|
|
1358
|
+
if (b) return b;
|
|
1359
|
+
let x = [
|
|
1360
|
+
"start",
|
|
1361
|
+
"resume",
|
|
1362
|
+
"advance"
|
|
1363
|
+
].includes(e) ? v : void 0;
|
|
1364
|
+
return Se(async () => {
|
|
1365
|
+
let v = r(n, i, a);
|
|
1366
|
+
if (e === "start") {
|
|
1367
|
+
if (!s || !c) return m(/* @__PURE__ */ Error("action=start requires rule and steps"));
|
|
1368
|
+
let e = c.findIndex((e, t) => t < c.length - 1 && e.holdMinutes < Ce);
|
|
1369
|
+
if (e >= 0) return m(/* @__PURE__ */ Error(`steps[${e}].holdMinutes must be at least ${Ce}: every step but the last holds 5 minutes to 30 days`));
|
|
1370
|
+
let n = c.map(({ percent: e, holdMinutes: t }) => ({
|
|
1371
|
+
percent: e,
|
|
1372
|
+
holdMinutes: t
|
|
1373
|
+
}));
|
|
1374
|
+
return s === "default" ? p(z(await t.api.requestWithEtag("POST", `${v}/default-rule/ramp`, {
|
|
1375
|
+
body: {
|
|
1376
|
+
steps: n,
|
|
1377
|
+
variationId: l ?? null,
|
|
1378
|
+
bucketBy: u ?? null
|
|
1379
|
+
},
|
|
1380
|
+
idempotencyKey: y,
|
|
1381
|
+
reason: _,
|
|
1382
|
+
freezeOverride: x
|
|
1383
|
+
}))) : l !== void 0 || u !== void 0 ? m(/* @__PURE__ */ Error("variation and bucketBy apply only to rule=\"default\"; a rule ramp keeps the rule's own")) : J.test(s) ? p(z(await t.api.requestWithEtag("POST", `${v}/rules/${o(s)}/ramp`, {
|
|
1384
|
+
body: { steps: n },
|
|
1385
|
+
idempotencyKey: y,
|
|
1386
|
+
reason: _,
|
|
1387
|
+
freezeOverride: x
|
|
1388
|
+
}))) : Y("rule", s, "get_targeting, or pass rule=\"default\"");
|
|
1389
|
+
}
|
|
1390
|
+
if (!d) return m(/* @__PURE__ */ Error(`action=${e} requires ramp (see list_rollout_ramps)`));
|
|
1391
|
+
if (!J.test(d)) return Y("ramp", d, "list_rollout_ramps");
|
|
1392
|
+
let b;
|
|
1393
|
+
if (e === "advance") {
|
|
1394
|
+
if (f === void 0) return m(/* @__PURE__ */ Error("action=advance requires expectedStepIndex: the currentStepIndex from list_rollout_ramps"));
|
|
1395
|
+
b = { expectedStepIndex: f };
|
|
1396
|
+
} else if (e === "abort") {
|
|
1397
|
+
if (h === void 0) return m(/* @__PURE__ */ Error("action=abort requires percent: the rollout percentage to leave the rule at"));
|
|
1398
|
+
b = { percent: h };
|
|
1399
|
+
}
|
|
1400
|
+
return p(z(await t.api.requestWithEtag("POST", `${v}/ramps/${o(d)}/${e}`, {
|
|
1401
|
+
body: b,
|
|
1402
|
+
ifMatch: g,
|
|
1403
|
+
reason: _,
|
|
1404
|
+
freezeOverride: x
|
|
1405
|
+
})));
|
|
1406
|
+
});
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1409
|
+
// src/tools/environment-comparison.ts
|
|
1410
|
+
function Ee(e, t) {
|
|
1411
|
+
let r = (e) => `/api/v1/orgs/${o(t.org)}/projects/${o(e)}`;
|
|
1412
|
+
e.registerTool("compare_environments", {
|
|
1413
|
+
title: "Compare environments",
|
|
1414
|
+
description: "Compare flag configuration between two environments: which flags differ and in which sections (state, defaultVariation, strategy, rules, prerequisites). Returns only differing flags unless different_only is false. To see exactly what would change for one flag, preview copy_flag_config (Team plan and above, Member role).",
|
|
1415
|
+
inputSchema: n.object({
|
|
1416
|
+
project: k,
|
|
1417
|
+
base: n.string().describe("Base environment key"),
|
|
1418
|
+
other: n.string().describe("Environment key to compare against"),
|
|
1419
|
+
different_only: n.boolean().optional().describe("Only flags whose configuration differs (default true)"),
|
|
1420
|
+
tag: n.string().optional().describe("Only flags with this tag"),
|
|
1421
|
+
owner: n.string().optional().describe("Owner email, or \"none\" for unowned flags"),
|
|
1422
|
+
...N
|
|
1423
|
+
}),
|
|
1424
|
+
outputSchema: w("GET /api/v1/orgs/{org}/projects/{project}/compare"),
|
|
1425
|
+
annotations: { readOnlyHint: !0 }
|
|
1426
|
+
}, async ({ project: e, base: n, other: i, different_only: a, tag: o, owner: s, limit: c, cursor: l }) => h(async () => p(await t.api.request("GET", `${r(e)}/compare`, { query: {
|
|
1427
|
+
base: n,
|
|
1428
|
+
other: i,
|
|
1429
|
+
differentOnly: a ?? !0,
|
|
1430
|
+
tag: o,
|
|
1431
|
+
owner: s,
|
|
1432
|
+
limit: c,
|
|
1433
|
+
cursor: l
|
|
1434
|
+
} })))), e.registerTool("copy_flag_config", {
|
|
1435
|
+
title: "Copy flag config between environments",
|
|
1436
|
+
description: "Copy one flag's targeting (default variation, strategy, rules, prerequisites) from one environment into another. On/off is copied only with include_state: true. Previews by default (dry_run: true) and changes nothing; review `before`/`after`, `changedSections` and `warnings`, then call again with dry_run: false plus the preview's sourceETag and targetETag as source_etag/target_etag to apply. If the apply is refused with 412, something changed since the preview: preview again. Applying needs both ETags, and the same `source` and `include_state` as the preview (the ETags record environment state, not the request). Team plan and above.",
|
|
1437
|
+
inputSchema: n.object({
|
|
1438
|
+
project: k,
|
|
1439
|
+
flag: A,
|
|
1440
|
+
source: n.string().describe("Environment key to copy from"),
|
|
1441
|
+
target: n.string().describe("Environment key to copy into"),
|
|
1442
|
+
include_state: n.boolean().optional().describe("Also copy the on/off state (default false). When applying, use the same value as the preview"),
|
|
1443
|
+
dry_run: n.boolean().optional().describe("Preview only, change nothing (default true). Pass false to apply, with both ETags from a preview made with the same source and include_state"),
|
|
1444
|
+
source_etag: n.string().optional().describe("sourceETag from the preview; the apply is refused (412) if the source changed since"),
|
|
1445
|
+
target_etag: n.string().optional().describe("targetETag from the preview; the apply is refused (412) if the target changed since"),
|
|
1446
|
+
reason: M,
|
|
1447
|
+
freeze_override: P
|
|
1448
|
+
}),
|
|
1449
|
+
outputSchema: w("POST /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/copy"),
|
|
1450
|
+
annotations: { destructiveHint: !0 }
|
|
1451
|
+
}, async ({ project: e, flag: n, source: i, target: s, include_state: c, dry_run: l, source_etag: u, target_etag: d, reason: f, freeze_override: h }) => {
|
|
1452
|
+
let g = F(h, f);
|
|
1453
|
+
if (g) return g;
|
|
1454
|
+
if (l === !1 && (!u || !d)) return {
|
|
1455
|
+
content: [{
|
|
1456
|
+
type: "text",
|
|
1457
|
+
text: "Applying needs both source_etag and target_etag from a preview: call copy_flag_config with dry_run: true first, then apply with its sourceETag and targetETag."
|
|
1458
|
+
}],
|
|
1459
|
+
isError: !0
|
|
1460
|
+
};
|
|
1461
|
+
try {
|
|
1462
|
+
return p(await t.api.request("POST", `${r(e)}/flags/${o(n)}/environments/${o(s)}/copy`, {
|
|
1463
|
+
body: {
|
|
1464
|
+
source: i,
|
|
1465
|
+
includeState: c ?? !1,
|
|
1466
|
+
dryRun: l ?? !0,
|
|
1467
|
+
expectedSourceETag: u === void 0 ? void 0 : a(u),
|
|
1468
|
+
expectedTargetETag: d === void 0 ? void 0 : a(d)
|
|
1469
|
+
},
|
|
1470
|
+
reason: f,
|
|
1471
|
+
freezeOverride: h
|
|
1472
|
+
}));
|
|
1473
|
+
} catch (e) {
|
|
1474
|
+
return m(e, { preconditionFailedHint: "The source or target changed since the preview; run copy_flag_config with dry_run: true again, then apply with the new sourceETag/targetETag." });
|
|
1475
|
+
}
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
// src/tools/flag-versions.ts
|
|
1479
|
+
function De(e, t) {
|
|
1480
|
+
let r = (e, n, r) => `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/flags/${o(n)}/environments/${o(r)}/versions`;
|
|
1481
|
+
e.registerTool("list_flag_versions", {
|
|
1482
|
+
title: "List flag versions",
|
|
1483
|
+
description: "List one flag's configuration history in one environment, newest first: each version's number, time, author, source (dashboard, api, mcp, schedule, ...), reason, on/off state and, for a restore, the version it restored. Pass a version to restore_flag_version to put that configuration back.",
|
|
1484
|
+
inputSchema: n.object({
|
|
1485
|
+
project: k,
|
|
1486
|
+
flag: A,
|
|
1487
|
+
environment: j,
|
|
1488
|
+
...N
|
|
1489
|
+
}),
|
|
1490
|
+
outputSchema: w("GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/versions"),
|
|
1491
|
+
annotations: { readOnlyHint: !0 }
|
|
1492
|
+
}, async ({ project: e, flag: n, environment: i, limit: a, cursor: o }) => h(async () => p(await t.api.request("GET", r(e, n, i), { query: {
|
|
1493
|
+
limit: a,
|
|
1494
|
+
cursor: o
|
|
1495
|
+
} })))), e.registerTool("restore_flag_version", {
|
|
1496
|
+
title: "Restore a flag version",
|
|
1497
|
+
description: "Put an earlier version of one flag's configuration in one environment back (default variation, strategy, rules, prerequisites), as a new version. On/off is restored only with include_state: true. Previews by default (dry_run: true) and changes nothing; review `before`/`after`, `changedSections` and `warnings`, then call again with dry_run: false and the preview's targetETag as etag to apply. If the apply is refused with 412, the environment changed since the preview: preview again. Use the same include_state as the preview. A version that names a variation, segment or prerequisite flag that no longer exists cannot be restored. Previewing works on every plan; applying needs the Pro plan or above.",
|
|
1498
|
+
inputSchema: n.object({
|
|
1499
|
+
project: k,
|
|
1500
|
+
flag: A,
|
|
1501
|
+
environment: j,
|
|
1502
|
+
version: n.number().int().min(1).describe("Version number to restore, from list_flag_versions"),
|
|
1503
|
+
include_state: n.boolean().optional().describe("Also restore the on/off state (default false). When applying, use the same value as the preview"),
|
|
1504
|
+
dry_run: n.boolean().optional().describe("Preview only, change nothing (default true). Pass false to apply, with the etag from a preview"),
|
|
1505
|
+
etag: n.string().optional().describe("targetETag from the preview; the apply is refused (412) if the environment changed since"),
|
|
1506
|
+
reason: M,
|
|
1507
|
+
freeze_override: P
|
|
1508
|
+
}),
|
|
1509
|
+
outputSchema: w("POST /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/versions/{number}/restore"),
|
|
1510
|
+
annotations: { destructiveHint: !0 }
|
|
1511
|
+
}, async ({ project: e, flag: n, environment: i, version: o, include_state: s, dry_run: c, etag: l, reason: u, freeze_override: d }) => {
|
|
1512
|
+
let f = F(d, u);
|
|
1513
|
+
if (f) return f;
|
|
1514
|
+
if (c === !1 && !l) return {
|
|
1515
|
+
content: [{
|
|
1516
|
+
type: "text",
|
|
1517
|
+
text: "Applying needs the preview's targetETag as etag: call restore_flag_version with dry_run: true first, then apply with its etag."
|
|
1518
|
+
}],
|
|
1519
|
+
isError: !0
|
|
1520
|
+
};
|
|
1521
|
+
try {
|
|
1522
|
+
return p(await t.api.request("POST", `${r(e, n, i)}/${o}/restore`, {
|
|
1523
|
+
body: {
|
|
1524
|
+
dryRun: c ?? !0,
|
|
1525
|
+
includeState: s ?? !1,
|
|
1526
|
+
expectedETag: l === void 0 ? void 0 : a(l)
|
|
1527
|
+
},
|
|
1528
|
+
reason: u,
|
|
1529
|
+
freezeOverride: d
|
|
1530
|
+
}));
|
|
1531
|
+
} catch (e) {
|
|
1532
|
+
return m(e, { preconditionFailedHint: "The environment changed since the preview; run restore_flag_version with dry_run: true again, then apply with the new targetETag as etag." });
|
|
1533
|
+
}
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1536
|
+
// src/tools/targeting.ts
|
|
1537
|
+
var Oe = n.object({
|
|
1538
|
+
attribute: n.string().describe("Context attribute name, e.g. plan, country, user_id"),
|
|
1539
|
+
operator: n.string().describe("OperatorType member name, case-sensitive — e.g. Equals, NotEquals, Contains, In, GreaterThan"),
|
|
1540
|
+
values: n.array(n.string()),
|
|
1541
|
+
negate: n.boolean().optional().default(!1)
|
|
1542
|
+
}), ke = n.object({
|
|
1543
|
+
description: n.string().optional(),
|
|
1544
|
+
variationId: n.string().optional().describe("Variation served when the rule matches"),
|
|
1545
|
+
rolloutPercentage: n.number().int().min(0).max(100).optional().describe("Percentage rollout for this rule"),
|
|
1546
|
+
bucketBy: n.string().trim().min(1).max(255).optional().describe("Context attribute the rollout hashes on (default `user_id`; `userId` is accepted as an alias). Visitors whose context lacks it skip this rule, even at 100%. Changing it reshuffles who is in the rollout. Omit to keep the current value."),
|
|
1547
|
+
userSegmentId: n.string().optional().describe("Match users in this segment (see list_segments)"),
|
|
1548
|
+
conditionGroups: n.array(n.object({
|
|
1549
|
+
operator: n.enum(["And", "Or"]).describe("How conditions inside this group combine"),
|
|
1550
|
+
conditions: n.array(Oe)
|
|
1551
|
+
})).optional().describe("Groups are ANDed together; conditions inside a group use the group operator")
|
|
1552
|
+
}), Ae = (e) => ({
|
|
1553
|
+
...e,
|
|
1554
|
+
conditionGroups: e.conditionGroups ?? []
|
|
1555
|
+
});
|
|
1556
|
+
function je(e, t) {
|
|
1557
|
+
let r = (e, n, r) => `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/flags/${o(n)}/environments/${o(r)}/targeting`;
|
|
1558
|
+
e.registerTool("get_targeting", {
|
|
1559
|
+
title: "Get targeting rules",
|
|
1560
|
+
description: "Get a flag's current targeting configuration (enabled flag + ordered rules) in one environment.",
|
|
1561
|
+
inputSchema: n.object({
|
|
1562
|
+
project: k,
|
|
1563
|
+
flag: A,
|
|
1564
|
+
environment: j
|
|
1565
|
+
}),
|
|
1566
|
+
outputSchema: T("GET /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/targeting", { etag: I }),
|
|
1567
|
+
annotations: { readOnlyHint: !0 }
|
|
1568
|
+
}, async ({ project: e, flag: n, environment: i }) => h(async () => p(z(await t.api.requestWithEtag("GET", r(e, n, i)))))), e.registerTool("update_targeting", {
|
|
1569
|
+
title: "Replace targeting rules",
|
|
1570
|
+
description: "REPLACE all targeting rules of a flag in one environment (full PUT — rules not included are removed). Rules are evaluated in order. Get the current rules first with get_targeting. Pass ifMatch (the etag from get_targeting) so rules someone else changed meanwhile are not overwritten.",
|
|
1571
|
+
inputSchema: n.object({
|
|
1572
|
+
project: k,
|
|
1573
|
+
flag: A,
|
|
1574
|
+
environment: j,
|
|
1575
|
+
rules: n.array(ke).describe("The complete ordered rule list; rules left out are deleted"),
|
|
1576
|
+
ifMatch: R("get_targeting"),
|
|
1577
|
+
reason: M,
|
|
1578
|
+
freeze_override: P
|
|
1579
|
+
}),
|
|
1580
|
+
outputSchema: E({
|
|
1581
|
+
project: { type: "string" },
|
|
1582
|
+
flag: { type: "string" },
|
|
1583
|
+
environment: { type: "string" },
|
|
1584
|
+
rulesReplaced: { type: "integer" },
|
|
1585
|
+
etag: L
|
|
1586
|
+
}, [
|
|
1587
|
+
"project",
|
|
1588
|
+
"flag",
|
|
1589
|
+
"environment",
|
|
1590
|
+
"rulesReplaced"
|
|
1591
|
+
]),
|
|
1592
|
+
annotations: { destructiveHint: !0 }
|
|
1593
|
+
}, async ({ project: e, flag: n, environment: i, rules: a, ifMatch: o, reason: s, freeze_override: c }) => F(c, s) || h(async () => {
|
|
1594
|
+
let { etag: l } = await t.api.requestWithEtag("PUT", r(e, n, i), {
|
|
1595
|
+
body: { rules: a.map(Ae) },
|
|
1596
|
+
ifMatch: o,
|
|
1597
|
+
reason: s,
|
|
1598
|
+
freezeOverride: c
|
|
1599
|
+
});
|
|
1600
|
+
return p(z({
|
|
1601
|
+
data: {
|
|
1602
|
+
project: e,
|
|
1603
|
+
flag: n,
|
|
1604
|
+
environment: i,
|
|
1605
|
+
rulesReplaced: a.length
|
|
1606
|
+
},
|
|
1607
|
+
etag: l
|
|
1608
|
+
}));
|
|
1609
|
+
})), e.registerTool("manage_targeting_rule", {
|
|
1610
|
+
title: "Add, update, remove, or reorder one targeting rule",
|
|
1611
|
+
description: "Edit a single targeting rule instead of replacing them all with update_targeting. action=add needs rule (appended last); action=update needs ruleId + rule and changes only the fields you pass (conditionGroups replaces the rule's groups; to clear rolloutPercentage or userSegmentId use update_targeting); action=remove needs ruleId; action=reorder needs ruleIds, every existing rule id exactly once, in the new order. Rule ids come from get_targeting.",
|
|
1612
|
+
inputSchema: n.object({
|
|
1613
|
+
action: n.enum([
|
|
1614
|
+
"add",
|
|
1615
|
+
"update",
|
|
1616
|
+
"remove",
|
|
1617
|
+
"reorder"
|
|
1618
|
+
]).describe("add needs rule; update needs ruleId + rule; remove needs ruleId; reorder needs ruleIds"),
|
|
1619
|
+
project: k,
|
|
1620
|
+
flag: A,
|
|
1621
|
+
environment: j,
|
|
1622
|
+
ruleId: n.string().optional().describe("Rule id from get_targeting; required for update and remove"),
|
|
1623
|
+
rule: ke.optional().describe("Rule fields; required for add and update"),
|
|
1624
|
+
ruleIds: n.array(n.string()).optional().describe("Every rule id exactly once, in evaluation order; required for reorder"),
|
|
1625
|
+
reason: M,
|
|
1626
|
+
freeze_override: P
|
|
1627
|
+
}),
|
|
1628
|
+
outputSchema: D(x("POST /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/rules"), O({
|
|
1629
|
+
ruleId: { type: "string" },
|
|
1630
|
+
updated: { type: "boolean" }
|
|
1631
|
+
}, ["ruleId", "updated"]), O({ removed: { type: "string" } }, ["removed"]), O({ reordered: {
|
|
1632
|
+
type: "array",
|
|
1633
|
+
items: { type: "string" }
|
|
1634
|
+
} }, ["reordered"])),
|
|
1635
|
+
annotations: { destructiveHint: !0 }
|
|
1636
|
+
}, async ({ action: e, project: n, flag: r, environment: i, ruleId: a, rule: s, ruleIds: c, reason: l, freeze_override: u }) => {
|
|
1637
|
+
let d = F(u, l);
|
|
1638
|
+
if (d) return d;
|
|
1639
|
+
let f = u;
|
|
1640
|
+
return h(async () => {
|
|
1641
|
+
let u = `/api/v1/orgs/${o(t.org)}/projects/${o(n)}/flags/${o(r)}/environments/${o(i)}/rules`;
|
|
1642
|
+
if (e === "add") return s ? p(await t.api.request("POST", u, {
|
|
1643
|
+
body: Ae(s),
|
|
1644
|
+
reason: l,
|
|
1645
|
+
freezeOverride: f
|
|
1646
|
+
})) : m(/* @__PURE__ */ Error("action=add requires rule"));
|
|
1647
|
+
if (e === "reorder") return c ? (await t.api.request("PUT", `${u}/reorder`, {
|
|
1648
|
+
body: { ruleIds: c },
|
|
1649
|
+
reason: l,
|
|
1650
|
+
freezeOverride: f
|
|
1651
|
+
}), p({ reordered: c })) : m(/* @__PURE__ */ Error("action=reorder requires ruleIds (see get_targeting)"));
|
|
1652
|
+
if (!a) return m(/* @__PURE__ */ Error(`action=${e} requires ruleId (see get_targeting)`));
|
|
1653
|
+
let d = `${u}/${o(a)}`;
|
|
1654
|
+
if (e === "update") {
|
|
1655
|
+
if (!s) return m(/* @__PURE__ */ Error("action=update requires rule"));
|
|
1656
|
+
let { data: e, etag: n } = await t.api.requestWithEtag("GET", d), r = s.bucketBy ?? (e.rolloutPercentage == null ? void 0 : e.bucketBy), i = {
|
|
1657
|
+
description: s.description ?? e.description,
|
|
1658
|
+
variationId: s.variationId ?? e.variationId,
|
|
1659
|
+
rolloutPercentage: s.rolloutPercentage ?? e.rolloutPercentage,
|
|
1660
|
+
...r == null ? {} : { bucketBy: r },
|
|
1661
|
+
userSegmentId: s.userSegmentId ?? e.userSegmentId,
|
|
1662
|
+
conditionGroups: s.conditionGroups ?? (e.conditionGroups ?? []).map((e) => ({
|
|
1663
|
+
operator: e.operator,
|
|
1664
|
+
conditions: (e.conditions ?? []).map((e) => ({
|
|
1665
|
+
attribute: e.attribute,
|
|
1666
|
+
operator: e.operator,
|
|
1667
|
+
values: e.values,
|
|
1668
|
+
negate: e.negate
|
|
1669
|
+
}))
|
|
1670
|
+
}))
|
|
1671
|
+
};
|
|
1672
|
+
return await t.api.request("PUT", d, {
|
|
1673
|
+
body: i,
|
|
1674
|
+
ifMatch: n,
|
|
1675
|
+
reason: l,
|
|
1676
|
+
freezeOverride: f
|
|
1677
|
+
}), p({
|
|
1678
|
+
ruleId: a,
|
|
1679
|
+
updated: !0
|
|
1680
|
+
});
|
|
1681
|
+
}
|
|
1682
|
+
return await t.api.request("DELETE", d, {
|
|
1683
|
+
reason: l,
|
|
1684
|
+
freezeOverride: f
|
|
1685
|
+
}), p({ removed: a });
|
|
1686
|
+
});
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
// src/tools/variations.ts
|
|
1690
|
+
function Me(e, t) {
|
|
1691
|
+
e.registerTool("manage_variation", {
|
|
1692
|
+
title: "Add, update, or remove a variation",
|
|
1693
|
+
description: "Manage a flag's variations. action=add requires key + value; action=update/remove require variationId (get ids via get_flag). Removing a variation fails with VARIATION_HAS_DEPENDENTS if other flags depend on it. A value change, add or remove is refused with change_frozen while a change freeze covers an environment that serves the variation or splits a rule rollout over the flag's variations; an Owner/Admin can pass freeze_override + reason to break it.",
|
|
1694
|
+
inputSchema: n.object({
|
|
1695
|
+
project: k,
|
|
1696
|
+
flag: A,
|
|
1697
|
+
action: n.enum([
|
|
1698
|
+
"add",
|
|
1699
|
+
"update",
|
|
1700
|
+
"remove"
|
|
1701
|
+
]).describe("add needs key + value; update and remove need variationId"),
|
|
1702
|
+
variationId: n.string().optional().describe("Required for update/remove"),
|
|
1703
|
+
key: n.string().optional().describe("Required for add; immutable afterwards"),
|
|
1704
|
+
name: n.string().optional().describe("Display name"),
|
|
1705
|
+
value: n.string().optional().describe("Variation value serialized as a string; required for add"),
|
|
1706
|
+
description: n.string().optional().describe("What this variation means"),
|
|
1707
|
+
reason: M,
|
|
1708
|
+
freeze_override: P
|
|
1709
|
+
}),
|
|
1710
|
+
outputSchema: D(x("POST /api/v1/orgs/{org}/projects/{project}/flags/{flag}/variations"), O({ updated: {
|
|
1711
|
+
type: "string",
|
|
1712
|
+
description: "Id of the updated variation"
|
|
1713
|
+
} }, ["updated"]), O({ removed: {
|
|
1714
|
+
type: "string",
|
|
1715
|
+
description: "Id of the removed variation"
|
|
1716
|
+
} }, ["removed"])),
|
|
1717
|
+
annotations: { destructiveHint: !0 }
|
|
1718
|
+
}, async ({ project: e, flag: n, action: r, variationId: i, key: a, name: s, value: c, description: l, reason: u, freeze_override: d }) => h(async () => {
|
|
1719
|
+
let f = F(d, u);
|
|
1720
|
+
if (f) return f;
|
|
1721
|
+
let h = d, g = `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/flags/${o(n)}/variations`;
|
|
1722
|
+
return r === "add" ? !a || c === void 0 ? m(/* @__PURE__ */ Error("action=add requires key and value")) : p(await t.api.request("POST", g, {
|
|
1723
|
+
body: {
|
|
1724
|
+
key: a,
|
|
1725
|
+
name: s,
|
|
1726
|
+
value: c,
|
|
1727
|
+
description: l
|
|
1728
|
+
},
|
|
1729
|
+
reason: u,
|
|
1730
|
+
freezeOverride: h
|
|
1731
|
+
})) : i ? r === "update" ? (await t.api.request("PUT", `${g}/${o(i)}`, {
|
|
1732
|
+
body: {
|
|
1733
|
+
name: s,
|
|
1734
|
+
value: c,
|
|
1735
|
+
description: l
|
|
1736
|
+
},
|
|
1737
|
+
reason: u,
|
|
1738
|
+
freezeOverride: h
|
|
1739
|
+
}), p({ updated: i })) : (await t.api.request("DELETE", `${g}/${o(i)}`, {
|
|
1740
|
+
reason: u,
|
|
1741
|
+
freezeOverride: h
|
|
1742
|
+
}), p({ removed: i })) : m(/* @__PURE__ */ Error(`action=${r} requires variationId (see get_flag for ids)`));
|
|
1743
|
+
}));
|
|
1744
|
+
}
|
|
1745
|
+
// src/tools/webhooks.ts
|
|
1746
|
+
var Ne = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, X = "Requires an Admin token. A 404 on every webhook call means webhooks are not enabled for the organization.";
|
|
1747
|
+
function Pe(e) {
|
|
1748
|
+
let t;
|
|
1749
|
+
try {
|
|
1750
|
+
t = new URL(e);
|
|
1751
|
+
} catch {
|
|
1752
|
+
return !1;
|
|
1753
|
+
}
|
|
1754
|
+
return t.protocol === "https:" && t.port === "" && !t.username && !t.password && t.hostname === "hooks.slack.com" && t.pathname.startsWith("/services/");
|
|
1755
|
+
}
|
|
1756
|
+
var Fe = "url is a Slack incoming webhook URL. Slack rejects the generic JSON payload, so every delivery would fail. Create the subscription with provider: \"Slack\" instead.";
|
|
1757
|
+
function Ie(e, t) {
|
|
1758
|
+
let r = `/api/v1/orgs/${o(t.org)}/webhooks`, i = (e) => `${r}/${o(e)}`;
|
|
1759
|
+
async function a(e) {
|
|
1760
|
+
let n = [];
|
|
1761
|
+
for (let r of e) {
|
|
1762
|
+
if (Ne.test(r)) {
|
|
1763
|
+
n.push(r);
|
|
1764
|
+
continue;
|
|
1765
|
+
}
|
|
1766
|
+
let e = await t.api.request("GET", `/api/v1/orgs/${o(t.org)}/projects/${o(r)}`);
|
|
1767
|
+
if (!e?.id) throw Error(`Project "${r}" resolved without an id`);
|
|
1768
|
+
n.push(e.id);
|
|
1769
|
+
}
|
|
1770
|
+
return n;
|
|
1771
|
+
}
|
|
1772
|
+
async function s(e) {
|
|
1773
|
+
let n = e.map((e) => {
|
|
1774
|
+
if (Ne.test(e)) return { id: e };
|
|
1775
|
+
let t = e.indexOf("/"), n = e.slice(0, t), r = e.slice(t + 1);
|
|
1776
|
+
if (t < 0 || !n || !r) throw Error(`Environment "${e}" needs its project: pass "<project>/<environment>", e.g. "web/production", or the environment's id.`);
|
|
1777
|
+
return {
|
|
1778
|
+
project: n,
|
|
1779
|
+
env: r
|
|
1780
|
+
};
|
|
1781
|
+
}), r = [];
|
|
1782
|
+
for (let e of n) {
|
|
1783
|
+
if ("id" in e) {
|
|
1784
|
+
r.push(e.id);
|
|
1785
|
+
continue;
|
|
1786
|
+
}
|
|
1787
|
+
let n = await t.api.request("GET", `/api/v1/orgs/${o(t.org)}/projects/${o(e.project)}/environments/${o(e.env)}`);
|
|
1788
|
+
if (!n?.id) throw Error(`Environment "${e.project}/${e.env}" resolved without an id`);
|
|
1789
|
+
r.push(n.id);
|
|
1790
|
+
}
|
|
1791
|
+
return r;
|
|
1792
|
+
}
|
|
1793
|
+
e.registerTool("list_webhooks", {
|
|
1794
|
+
title: "List webhook subscriptions",
|
|
1795
|
+
description: "List the organization's outbound webhook subscriptions (url, event/project/environment filters, enabled state, failure count, signing secret ids — never secret values), plus availableEventTypes: the event types a subscription can filter on. Empty filter lists mean \"all\". Paginated via cursor. " + X,
|
|
1796
|
+
inputSchema: n.object({ ...N }),
|
|
1797
|
+
outputSchema: T("GET /api/v1/orgs/{org}/webhooks", { availableEventTypes: {
|
|
1798
|
+
type: "array",
|
|
1799
|
+
items: { type: "string" },
|
|
1800
|
+
description: "Event types a subscription can filter on"
|
|
1801
|
+
} }),
|
|
1802
|
+
annotations: { readOnlyHint: !0 }
|
|
1803
|
+
}, async ({ limit: e, cursor: n }) => h(async () => {
|
|
1804
|
+
let [i, a] = await Promise.all([t.api.request("GET", r, { query: {
|
|
1805
|
+
limit: e,
|
|
1806
|
+
cursor: n
|
|
1807
|
+
} }), t.api.request("GET", `${r}/event-types`)]);
|
|
1808
|
+
return p({
|
|
1809
|
+
...i,
|
|
1810
|
+
availableEventTypes: a
|
|
1811
|
+
});
|
|
1812
|
+
})), e.registerTool("list_webhook_deliveries", {
|
|
1813
|
+
title: "List webhook deliveries",
|
|
1814
|
+
description: "List one subscription's delivery attempts, most recent first. status is Pending (awaiting an attempt, backing off, or in flight), Succeeded or DeadLettered; lastResponseStatusCode and lastError explain a failure. Paginated via cursor. " + X,
|
|
1815
|
+
inputSchema: n.object({
|
|
1816
|
+
id: n.string().describe("Subscription id (from list_webhooks)"),
|
|
1817
|
+
...N
|
|
1818
|
+
}),
|
|
1819
|
+
outputSchema: w("GET /api/v1/orgs/{org}/webhooks/{id}/deliveries"),
|
|
1820
|
+
annotations: { readOnlyHint: !0 }
|
|
1821
|
+
}, async ({ id: e, limit: n, cursor: r }) => h(async () => p(await t.api.request("GET", `${i(e)}/deliveries`, { query: {
|
|
1822
|
+
limit: n,
|
|
1823
|
+
cursor: r
|
|
1824
|
+
} })))), e.registerTool("manage_webhook", {
|
|
1825
|
+
title: "Create, update, or delete a webhook subscription, or rotate its secret",
|
|
1826
|
+
description: "action=create requires name + url and returns the signing secret. action=update/delete/rotate_secret/retire_secret require id. provider (create only, default GenericHttp) is the destination type: a Slack incoming webhook URL (https://hooks.slack.com/services/...) needs provider: \"Slack\", which posts readable channel messages; provider: \"Datadog\" sends Events API change events (url is your site's https://event-management-intake.<site>/api/v2/events) and provider: \"Grafana\" creates annotations (url is https://<your grafana>/api/annotations). Datadog and Grafana require credential (a Datadog API key, or a Grafana service account token that can create annotations, e.g. Editor); GenericHttp and Slack refuse it. credential is write-only: stored encrypted, never returned, and never echoed in this tool's output. A subscription's provider can never change. update changes only the fields you pass and keeps the rest; pass an empty list to widen that filter back to \"all\". projects take project keys or ids; environments take \"<project>/<environment>\" keys (e.g. \"web/production\") or ids. eventTypes come from list_webhooks → availableEventTypes. create and rotate_secret return a secret that is NEVER shown again: relay it to the user verbatim so they can store it (for a GenericHttp subscription only: Slack, Datadog and Grafana never check it, so skip it there). Slack doesn't verify signatures, so a Slack subscription's secret is unused and rotate_secret is refused for one, and so are Datadog and Grafana ones, which authenticate with credential instead. On update, omit credential to keep the stored one; changing the url of a Datadog or Grafana subscription requires sending credential again. rotate_secret adds a new active secret while the old one keeps signing; retire_secret (secretId from list_webhooks) removes one and is refused for the last active secret. A project-restricted service token must list at least one project, all in its scope. " + X,
|
|
1827
|
+
inputSchema: n.object({
|
|
1828
|
+
action: n.enum([
|
|
1829
|
+
"create",
|
|
1830
|
+
"update",
|
|
1831
|
+
"delete",
|
|
1832
|
+
"rotate_secret",
|
|
1833
|
+
"retire_secret"
|
|
1834
|
+
]).describe("What to do; every action except create needs id"),
|
|
1835
|
+
id: n.string().optional().describe("Subscription id; required for everything except create"),
|
|
1836
|
+
name: n.string().optional().describe("Required for create"),
|
|
1837
|
+
url: n.string().optional().describe("Receiver URL; required for create"),
|
|
1838
|
+
provider: n.enum([
|
|
1839
|
+
"GenericHttp",
|
|
1840
|
+
"Slack",
|
|
1841
|
+
"Datadog",
|
|
1842
|
+
"Grafana"
|
|
1843
|
+
]).optional().describe("create only. Slack for a hooks.slack.com/services/ URL; Datadog or Grafana for those destinations (credential required); GenericHttp (default) for your own endpoint"),
|
|
1844
|
+
credential: n.string().optional().describe("Write-only. Datadog API key or Grafana service account token (permission to create annotations). Required on create for Datadog and Grafana, refused for GenericHttp and Slack. On update, omit to keep the stored one; required again when changing url on a Datadog or Grafana subscription. Never returned."),
|
|
1845
|
+
eventTypes: n.array(n.string()).optional().describe("Event types to send; empty or omitted = all"),
|
|
1846
|
+
projects: n.array(n.string()).optional().describe("Project keys or ids to cover; empty or omitted on create = all"),
|
|
1847
|
+
environments: n.array(n.string()).optional().describe("\"<project>/<environment>\" keys or environment ids; empty or omitted on create = all"),
|
|
1848
|
+
enabled: n.boolean().optional().describe("update only; subscriptions are created enabled"),
|
|
1849
|
+
secretId: n.string().optional().describe("Required for retire_secret"),
|
|
1850
|
+
idempotency_key: n.string().optional().describe("Idempotency-Key header for create / rotate_secret")
|
|
1851
|
+
}),
|
|
1852
|
+
outputSchema: D(x("POST /api/v1/orgs/{org}/webhooks"), O({
|
|
1853
|
+
id: { type: "string" },
|
|
1854
|
+
updated: { type: "boolean" },
|
|
1855
|
+
name: y("string"),
|
|
1856
|
+
url: y("string"),
|
|
1857
|
+
eventTypes: {
|
|
1858
|
+
type: ["array", "null"],
|
|
1859
|
+
items: { type: "string" }
|
|
1860
|
+
},
|
|
1861
|
+
projectIds: {
|
|
1862
|
+
type: ["array", "null"],
|
|
1863
|
+
items: { type: "string" }
|
|
1864
|
+
},
|
|
1865
|
+
environmentIds: {
|
|
1866
|
+
type: ["array", "null"],
|
|
1867
|
+
items: { type: "string" }
|
|
1868
|
+
},
|
|
1869
|
+
isEnabled: y("boolean")
|
|
1870
|
+
}, ["id", "updated"]), O({ deleted: { type: "string" } }, ["deleted"]), x("POST /api/v1/orgs/{org}/webhooks/{id}/secrets"), O({
|
|
1871
|
+
id: { type: "string" },
|
|
1872
|
+
retiredSecretId: { type: "string" }
|
|
1873
|
+
}, ["id", "retiredSecretId"])),
|
|
1874
|
+
annotations: { destructiveHint: !0 }
|
|
1875
|
+
}, async ({ action: e, id: n, name: c, url: l, provider: u, credential: d, eventTypes: f, projects: g, environments: _, enabled: v, secretId: y, idempotency_key: b }) => h(async () => {
|
|
1876
|
+
if (u && e !== "create") return m(/* @__PURE__ */ Error("provider applies only to action=create: a subscription's provider can't change. To switch destination type, create a new subscription and delete this one."));
|
|
1877
|
+
if (e === "create") {
|
|
1878
|
+
if (!c || !l) return m(/* @__PURE__ */ Error("action=create requires name and url"));
|
|
1879
|
+
let e = u ?? "GenericHttp";
|
|
1880
|
+
if (e === "GenericHttp" && Pe(l)) return m(/* @__PURE__ */ Error(Fe));
|
|
1881
|
+
let n = _ && await s(_), i = g && await a(g);
|
|
1882
|
+
return p(await t.api.request("POST", r, {
|
|
1883
|
+
body: {
|
|
1884
|
+
name: c,
|
|
1885
|
+
url: l,
|
|
1886
|
+
provider: e,
|
|
1887
|
+
credential: d,
|
|
1888
|
+
eventTypes: f,
|
|
1889
|
+
projectIds: i,
|
|
1890
|
+
environmentIds: n
|
|
1891
|
+
},
|
|
1892
|
+
idempotencyKey: b
|
|
1893
|
+
}));
|
|
1894
|
+
}
|
|
1895
|
+
if (!n) return m(/* @__PURE__ */ Error(`action=${e} requires id (see list_webhooks)`));
|
|
1896
|
+
if (e === "update") {
|
|
1897
|
+
let e = _ && await s(_), r = g && await a(g), { data: o, etag: u } = await t.api.requestWithEtag("GET", i(n));
|
|
1898
|
+
if (l && o.provider === "GenericHttp" && Pe(l)) return m(/* @__PURE__ */ Error(`${Fe} This subscription is GenericHttp, and a provider can't change.`));
|
|
1899
|
+
let h = {
|
|
1900
|
+
name: c ?? o.name,
|
|
1901
|
+
url: l ?? o.url,
|
|
1902
|
+
eventTypes: f ?? o.eventTypes,
|
|
1903
|
+
projectIds: r ?? o.projectIds,
|
|
1904
|
+
environmentIds: e ?? o.environmentIds,
|
|
1905
|
+
isEnabled: v ?? o.isEnabled
|
|
1906
|
+
};
|
|
1907
|
+
return await t.api.request("PUT", i(n), {
|
|
1908
|
+
body: d ? {
|
|
1909
|
+
...h,
|
|
1910
|
+
credential: d
|
|
1911
|
+
} : h,
|
|
1912
|
+
ifMatch: u
|
|
1913
|
+
}), p({
|
|
1914
|
+
id: n,
|
|
1915
|
+
updated: !0,
|
|
1916
|
+
...h
|
|
1917
|
+
});
|
|
1918
|
+
}
|
|
1919
|
+
if (e === "delete") return await t.api.request("DELETE", i(n)), p({ deleted: n });
|
|
1920
|
+
if (e === "rotate_secret") {
|
|
1921
|
+
let e = await t.api.request("GET", i(n));
|
|
1922
|
+
return e.provider === "Datadog" || e.provider === "Grafana" ? m(/* @__PURE__ */ Error(`This is a ${e.provider} subscription. It authenticates with its credential, not a signing secret, so rotating a secret changes nothing. To replace the credential, update the subscription and pass credential.`)) : e.provider === "Slack" ? m(/* @__PURE__ */ Error("This is a Slack subscription. Slack doesn't verify signatures, so its signing secret is unused and rotating it changes nothing. If the Slack webhook URL leaked, create a new incoming webhook in Slack, update this subscription to the new url, and delete the old webhook in Slack.")) : p(await t.api.request("POST", `${i(n)}/secrets`, { idempotencyKey: b }));
|
|
1923
|
+
}
|
|
1924
|
+
return y ? (await t.api.request("DELETE", `${i(n)}/secrets/${o(y)}`), p({
|
|
1925
|
+
id: n,
|
|
1926
|
+
retiredSecretId: y
|
|
1927
|
+
})) : m(/* @__PURE__ */ Error("action=retire_secret requires secretId (see list_webhooks)"));
|
|
1928
|
+
})), e.registerTool("deliver_webhook", {
|
|
1929
|
+
title: "Send a test event or redeliver",
|
|
1930
|
+
description: "action=test queues one synthetic flag.toggled event to this subscription alone; action=redeliver (deliveryId from list_webhook_deliveries) re-sends a finished delivery, restarting its retry schedule. Delivery is asynchronous: read list_webhook_deliveries for the outcome. Both are refused for a disabled subscription, and redeliver for a delivery that is still Pending. " + X,
|
|
1931
|
+
inputSchema: n.object({
|
|
1932
|
+
action: n.enum(["test", "redeliver"]).describe("test sends a synthetic event; redeliver re-sends deliveryId"),
|
|
1933
|
+
id: n.string().describe("Subscription id (from list_webhooks)"),
|
|
1934
|
+
deliveryId: n.string().optional().describe("Required for redeliver")
|
|
1935
|
+
}),
|
|
1936
|
+
outputSchema: D(x("POST /api/v1/orgs/{org}/webhooks/{id}/test"), O({
|
|
1937
|
+
id: { type: "string" },
|
|
1938
|
+
redelivered: { type: "string" }
|
|
1939
|
+
}, ["id", "redelivered"])),
|
|
1940
|
+
annotations: {
|
|
1941
|
+
destructiveHint: !1,
|
|
1942
|
+
openWorldHint: !0
|
|
1943
|
+
}
|
|
1944
|
+
}, async ({ action: e, id: n, deliveryId: r }) => h(async () => e === "test" ? p(await t.api.request("POST", `${i(n)}/test`)) : r ? (await t.api.request("POST", `${i(n)}/deliveries/${o(r)}/redeliver`), p({
|
|
1945
|
+
id: n,
|
|
1946
|
+
redelivered: r
|
|
1947
|
+
})) : m(/* @__PURE__ */ Error("action=redeliver requires deliveryId (see list_webhook_deliveries)"))));
|
|
1948
|
+
}
|
|
1949
|
+
// src/tools/workflows/stale-flags.ts
|
|
1950
|
+
var Le = n.enum(["dead", "stale"]), Z = 50;
|
|
1951
|
+
function Re(e, t) {
|
|
1952
|
+
e.registerTool("find_stale_flags", {
|
|
1953
|
+
title: "Find stale flags",
|
|
1954
|
+
description: `Find flags that look ready for code cleanup: not updated in N days AND either enabled in every environment (verify rollout is complete before removing — per-rule percentage ramps are not inspected) or disabled in every environment (dead — remove flag and code path). A flag whose expiry date (set_flag_expiry) has passed is always a candidate, however recently it was edited; if it is on in some environments and off in others its reason is past-expiry, meaning the owner has to decide which way to fold it. A project can give its temporary flags a default lifetime, so a flag with no date of its own can still be past expiry. Every result carries expiresAtUtc (the date set on the flag), effectiveExpiresAtUtc (the date in effect, from the flag or its project default), expirySource (explicit, project-default, or null), expired and owner (null when unowned). Flags marked permanent (kill switches, ops toggles) are never listed. Pass owner to see one person's stale flags ("me" for your own) or "none" for the unowned ones. Every result also carries blockedBy: the live flags that still list it as a prerequisite, which have to be removed and archived before it ([] when none). blockedBy is null when the server did not classify the flag as a removal candidate, which means unknown, not unblocked. A flag that other live flags list as a prerequisite has to be removed LAST, dependents first: archiving it while a dependent still names it makes that dependent fail its prerequisite check and serve its off variation, so archive_flag refuses it with FLAG_HAS_DEPENDENTS. Checks at most ${Z} candidates per call, expired flags first.`,
|
|
1955
|
+
inputSchema: n.object({
|
|
1956
|
+
project: k,
|
|
1957
|
+
days: n.number().int().min(1).optional().default(30).describe("Minimum age in days since last update"),
|
|
1958
|
+
owner: ae
|
|
1959
|
+
}),
|
|
1960
|
+
outputSchema: E({
|
|
1961
|
+
project: { type: "string" },
|
|
1962
|
+
olderThanDays: { type: "integer" },
|
|
1963
|
+
owner: { type: "string" },
|
|
1964
|
+
checked: { type: "integer" },
|
|
1965
|
+
truncated: { type: "boolean" },
|
|
1966
|
+
note: { type: "string" },
|
|
1967
|
+
blockedByNote: { type: "string" },
|
|
1968
|
+
stale: {
|
|
1969
|
+
type: "array",
|
|
1970
|
+
items: O({
|
|
1971
|
+
key: { type: "string" },
|
|
1972
|
+
name: { type: "string" },
|
|
1973
|
+
updatedAt: { type: "string" },
|
|
1974
|
+
expiresAtUtc: y("string"),
|
|
1975
|
+
effectiveExpiresAtUtc: y("string"),
|
|
1976
|
+
expirySource: {
|
|
1977
|
+
...y("string"),
|
|
1978
|
+
description: "explicit, project-default, or null"
|
|
1979
|
+
},
|
|
1980
|
+
expired: { type: "boolean" },
|
|
1981
|
+
owner: { anyOf: [b("PublicFlagOwner"), { type: "null" }] },
|
|
1982
|
+
reason: {
|
|
1983
|
+
type: "string",
|
|
1984
|
+
description: "enabled-everywhere, disabled-everywhere or past-expiry"
|
|
1985
|
+
},
|
|
1986
|
+
environments: { type: "integer" },
|
|
1987
|
+
blockedBy: {
|
|
1988
|
+
type: ["array", "null"],
|
|
1989
|
+
items: { type: "string" },
|
|
1990
|
+
description: "null means unknown, not unblocked"
|
|
1991
|
+
}
|
|
1992
|
+
})
|
|
1993
|
+
}
|
|
1994
|
+
}, [
|
|
1995
|
+
"project",
|
|
1996
|
+
"olderThanDays",
|
|
1997
|
+
"checked",
|
|
1998
|
+
"truncated",
|
|
1999
|
+
"stale"
|
|
2000
|
+
]),
|
|
2001
|
+
annotations: { readOnlyHint: !0 }
|
|
2002
|
+
}, async ({ project: e, days: n, owner: r }) => h(async () => {
|
|
2003
|
+
let a = await B(t, r), s = `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/flags`, c = Date.now(), l = c - n * 24 * 60 * 60 * 1e3, u = (e) => e.effectiveExpiresAtUtc ?? e.expiresAtUtc ?? null, d = (e) => e.expirySource ?? (e.expiresAtUtc ? "explicit" : null), f = (e) => {
|
|
2004
|
+
let t = u(e);
|
|
2005
|
+
return !!t && new Date(t).getTime() <= c;
|
|
2006
|
+
}, m = [], h;
|
|
2007
|
+
do {
|
|
2008
|
+
let e = await t.api.request("GET", s, { query: {
|
|
2009
|
+
archived: !1,
|
|
2010
|
+
limit: 100,
|
|
2011
|
+
cursor: h,
|
|
2012
|
+
owner: a,
|
|
2013
|
+
permanent: !1
|
|
2014
|
+
} });
|
|
2015
|
+
m.push(...(e.items ?? []).filter((e) => !!e.key && !!e.name && !!e.updatedAt && (new Date(e.updatedAt).getTime() < l || f(e)))), h = e.next_cursor ?? void 0;
|
|
2016
|
+
} while (h);
|
|
2017
|
+
m.sort((e, t) => Number(f(t)) - Number(f(e)));
|
|
2018
|
+
let g = m.length > Z, _ = m.slice(0, Z), v = [];
|
|
2019
|
+
for (let e of _) {
|
|
2020
|
+
let n = await t.api.request("GET", `${s}/${o(e.key)}/environments`);
|
|
2021
|
+
if (n.length === 0) continue;
|
|
2022
|
+
let r = f(e), i = n.every((e) => e.isEnabled), a = n.every((e) => !e.isEnabled);
|
|
2023
|
+
(i || a || r) && v.push({
|
|
2024
|
+
key: e.key,
|
|
2025
|
+
name: e.name,
|
|
2026
|
+
updatedAt: e.updatedAt,
|
|
2027
|
+
expiresAtUtc: e.expiresAtUtc ?? null,
|
|
2028
|
+
effectiveExpiresAtUtc: u(e),
|
|
2029
|
+
expirySource: d(e),
|
|
2030
|
+
expired: r,
|
|
2031
|
+
owner: e.owner ?? null,
|
|
2032
|
+
reason: i ? "enabled-everywhere" : a ? "disabled-everywhere" : "past-expiry",
|
|
2033
|
+
environments: n.length,
|
|
2034
|
+
blockedBy: null
|
|
2035
|
+
});
|
|
2036
|
+
}
|
|
2037
|
+
let y;
|
|
2038
|
+
if (v.length > 0) try {
|
|
2039
|
+
let e = /* @__PURE__ */ new Map(), n;
|
|
2040
|
+
do {
|
|
2041
|
+
let r = await t.api.request("GET", `${s}/removal-candidates`, { query: {
|
|
2042
|
+
staleness: "stale",
|
|
2043
|
+
limit: 100,
|
|
2044
|
+
cursor: n
|
|
2045
|
+
} });
|
|
2046
|
+
for (let t of r.items ?? []) t.key && t.blockedBy && e.set(t.key, t.blockedBy);
|
|
2047
|
+
n = r.next_cursor ?? void 0;
|
|
2048
|
+
} while (n);
|
|
2049
|
+
for (let t of v) t.blockedBy = e.get(t.key) ?? null;
|
|
2050
|
+
} catch (e) {
|
|
2051
|
+
if (!(e instanceof i)) throw e;
|
|
2052
|
+
y = `Could not read removal-candidates (${e.status} ${e.envelope.error}), so blockedBy is unknown for every flag. archive_flag still refuses any flag that a live flag depends on (FLAG_HAS_DEPENDENTS).`;
|
|
2053
|
+
}
|
|
2054
|
+
return p({
|
|
2055
|
+
project: e,
|
|
2056
|
+
olderThanDays: n,
|
|
2057
|
+
...a ? { owner: a } : {},
|
|
2058
|
+
checked: _.length,
|
|
2059
|
+
truncated: g,
|
|
2060
|
+
...g ? { note: `Only the first ${Z} of ${m.length} candidates were checked.` } : {},
|
|
2061
|
+
...y ? { blockedByNote: y } : {},
|
|
2062
|
+
stale: v
|
|
2063
|
+
});
|
|
2064
|
+
})), e.registerTool("list_removal_candidates", {
|
|
2065
|
+
title: "List removal candidates",
|
|
2066
|
+
description: "List the flags the server is confident can be removed from code, the same list the Featureflip flag cleanup GitHub Action works from. Each item has key, reason, status (Dead or Stale), treatment (true = keep the on-branch, false = keep the off-branch) and blockedBy: the live flags that still list it as a prerequisite. Only remove a flag whose blockedBy is empty. A flag that other live flags list as a prerequisite has to be removed LAST, dependents first: archiving it while a dependent still names it makes that dependent fail its prerequisite check and serve its off variation, so archive_flag refuses it with FLAG_HAS_DEPENDENTS. staleness \"dead\" (the default) returns only dead flags, \"stale\" adds stale ones. Paginated via cursor.",
|
|
2067
|
+
inputSchema: n.object({
|
|
2068
|
+
project: k,
|
|
2069
|
+
staleness: Le.optional().describe("Minimum staleness tier: dead (default) or stale"),
|
|
2070
|
+
...N
|
|
2071
|
+
}),
|
|
2072
|
+
outputSchema: w("GET /api/v1/orgs/{org}/projects/{project}/flags/removal-candidates"),
|
|
2073
|
+
annotations: { readOnlyHint: !0 }
|
|
2074
|
+
}, async ({ project: e, ...n }) => h(async () => p(await t.api.request("GET", `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/flags/removal-candidates`, { query: n }))));
|
|
2075
|
+
}
|
|
2076
|
+
// src/tools/workflows/snippets.ts
|
|
2077
|
+
var ze = [
|
|
2078
|
+
"js",
|
|
2079
|
+
"node",
|
|
2080
|
+
"browser",
|
|
2081
|
+
"react",
|
|
2082
|
+
"python",
|
|
2083
|
+
"csharp",
|
|
2084
|
+
"java",
|
|
2085
|
+
"go",
|
|
2086
|
+
"php",
|
|
2087
|
+
"ruby",
|
|
2088
|
+
"swift"
|
|
2089
|
+
], Be = [
|
|
2090
|
+
"browser",
|
|
2091
|
+
"react",
|
|
2092
|
+
"swift"
|
|
2093
|
+
];
|
|
2094
|
+
function Ve(e) {
|
|
2095
|
+
return Be.includes(e);
|
|
2096
|
+
}
|
|
2097
|
+
var Q = "Uses a SERVER-side SDK key (Featureflip dashboard → environment → SDK keys).", $ = "Uses a CLIENT-side SDK key (safe to ship to browsers/apps).";
|
|
2098
|
+
function He(e, t) {
|
|
2099
|
+
switch (e) {
|
|
2100
|
+
case "js": return {
|
|
2101
|
+
install: "npm install @featureflip/js",
|
|
2102
|
+
code: `import { FeatureflipClient, createNodePlatform } from '@featureflip/js';
|
|
2103
|
+
|
|
2104
|
+
const client = FeatureflipClient.get(
|
|
2105
|
+
{ sdkKey: process.env.FEATUREFLIP_SDK_KEY!, baseUrl: 'https://eval.featureflip.io' },
|
|
2106
|
+
createNodePlatform(),
|
|
2107
|
+
);
|
|
2108
|
+
await client.waitForInitialization();
|
|
2109
|
+
const enabled = client.boolVariation('${t}', { user_id: userId }, false);
|
|
2110
|
+
if (enabled) {
|
|
2111
|
+
// new code path
|
|
2112
|
+
}`,
|
|
2113
|
+
notes: Q
|
|
2114
|
+
};
|
|
2115
|
+
case "node": return {
|
|
2116
|
+
install: "npm install @featureflip/node",
|
|
2117
|
+
code: `import { FeatureflipClient } from '@featureflip/node';
|
|
2118
|
+
|
|
2119
|
+
const client = await FeatureflipClient.create({ sdkKey: process.env.FEATUREFLIP_SDK_KEY! });
|
|
2120
|
+
const enabled = client.boolVariation('${t}', { user_id: userId }, false);
|
|
2121
|
+
if (enabled) {
|
|
2122
|
+
// new code path
|
|
2123
|
+
}`,
|
|
2124
|
+
notes: Q
|
|
2125
|
+
};
|
|
2126
|
+
case "browser": return {
|
|
2127
|
+
install: "npm install @featureflip/browser",
|
|
2128
|
+
code: `import { FeatureflipClient } from '@featureflip/browser';
|
|
2129
|
+
|
|
2130
|
+
const client = FeatureflipClient.get({ clientKey: 'YOUR_CLIENT_SDK_KEY' });
|
|
2131
|
+
await client.initialize();
|
|
2132
|
+
const enabled = client.boolVariation('${t}', false);
|
|
2133
|
+
if (enabled) {
|
|
2134
|
+
// new code path
|
|
2135
|
+
}`,
|
|
2136
|
+
notes: $
|
|
2137
|
+
};
|
|
2138
|
+
case "react": return {
|
|
2139
|
+
install: "npm install @featureflip/react @featureflip/browser",
|
|
2140
|
+
code: `import { FeatureflipProvider, useFeatureFlag } from '@featureflip/react';
|
|
2141
|
+
|
|
2142
|
+
// In your app root:
|
|
2143
|
+
// <FeatureflipProvider clientKey="YOUR_CLIENT_SDK_KEY">...</FeatureflipProvider>
|
|
2144
|
+
|
|
2145
|
+
function MyComponent() {
|
|
2146
|
+
const enabled = useFeatureFlag('${t}', false);
|
|
2147
|
+
return enabled ? <NewExperience /> : <CurrentExperience />;
|
|
2148
|
+
}`,
|
|
2149
|
+
notes: $
|
|
2150
|
+
};
|
|
2151
|
+
case "python": return {
|
|
2152
|
+
install: "pip install featureflip",
|
|
2153
|
+
code: `from featureflip import FeatureflipClient
|
|
2154
|
+
|
|
2155
|
+
client = FeatureflipClient(sdk_key=os.environ["FEATUREFLIP_SDK_KEY"])
|
|
2156
|
+
enabled = client.variation("${t}", {"user_id": user_id}, default=False)
|
|
2157
|
+
if enabled:
|
|
2158
|
+
# new code path
|
|
2159
|
+
...`,
|
|
2160
|
+
notes: Q
|
|
2161
|
+
};
|
|
2162
|
+
case "csharp": return {
|
|
2163
|
+
install: "dotnet add package Featureflip.Client",
|
|
2164
|
+
code: `using Featureflip.Client;
|
|
2165
|
+
|
|
2166
|
+
var client = FeatureflipClient.Get(Environment.GetEnvironmentVariable("FEATUREFLIP_SDK_KEY")!);
|
|
2167
|
+
var enabled = client.BoolVariation("${t}",
|
|
2168
|
+
new EvaluationContext { UserId = userId }, false);
|
|
2169
|
+
if (enabled)
|
|
2170
|
+
{
|
|
2171
|
+
// new code path
|
|
2172
|
+
}`,
|
|
2173
|
+
notes: Q
|
|
2174
|
+
};
|
|
2175
|
+
case "java": return {
|
|
2176
|
+
install: "implementation 'io.featureflip:featureflip-java:2.0.0'",
|
|
2177
|
+
code: `import io.featureflip.client.FeatureflipClient;
|
|
2178
|
+
import io.featureflip.client.EvaluationContext;
|
|
2179
|
+
|
|
2180
|
+
FeatureflipClient client = FeatureflipClient.get(System.getenv("FEATUREFLIP_SDK_KEY"));
|
|
2181
|
+
client.waitForInitialization();
|
|
2182
|
+
boolean enabled = client.boolVariation("${t}",
|
|
2183
|
+
EvaluationContext.builder(userId).build(), false);
|
|
2184
|
+
if (enabled) {
|
|
2185
|
+
// new code path
|
|
2186
|
+
}`,
|
|
2187
|
+
notes: Q
|
|
2188
|
+
};
|
|
2189
|
+
case "go": return {
|
|
2190
|
+
install: "go get github.com/canopy-labs/featureflip-go/v2",
|
|
2191
|
+
code: `import featureflip "github.com/canopy-labs/featureflip-go/v2"
|
|
2192
|
+
|
|
2193
|
+
client, err := featureflip.Get(os.Getenv("FEATUREFLIP_SDK_KEY"))
|
|
2194
|
+
if err != nil {
|
|
2195
|
+
log.Fatal(err)
|
|
2196
|
+
}
|
|
2197
|
+
defer client.Close()
|
|
2198
|
+
|
|
2199
|
+
ctx := featureflip.EvaluationContext{UserID: userID}
|
|
2200
|
+
if client.BoolVariation("${t}", ctx, false) {
|
|
2201
|
+
// new code path
|
|
2202
|
+
}`,
|
|
2203
|
+
notes: Q
|
|
2204
|
+
};
|
|
2205
|
+
case "php": return {
|
|
2206
|
+
install: "composer require featureflip/featureflip-php",
|
|
2207
|
+
code: `use Featureflip\\FeatureflipClient;
|
|
2208
|
+
use Featureflip\\Config;
|
|
2209
|
+
|
|
2210
|
+
$client = FeatureflipClient::get(getenv('FEATUREFLIP_SDK_KEY'), new Config(
|
|
2211
|
+
cache: $psrCache, httpClient: $psrHttpClient,
|
|
2212
|
+
requestFactory: $psrRequestFactory, streamFactory: $psrStreamFactory,
|
|
2213
|
+
));
|
|
2214
|
+
$enabled = $client->boolVariation('${t}', ['user_id' => $userId], false);
|
|
2215
|
+
if ($enabled) {
|
|
2216
|
+
// new code path
|
|
2217
|
+
}`,
|
|
2218
|
+
notes: Q + " Requires PSR-16 cache and PSR-18 HTTP implementations."
|
|
2219
|
+
};
|
|
2220
|
+
case "ruby": return {
|
|
2221
|
+
install: "gem \"featureflip\"",
|
|
2222
|
+
code: `require "featureflip"
|
|
2223
|
+
|
|
2224
|
+
client = Featureflip::Client.get(ENV.fetch("FEATUREFLIP_SDK_KEY"))
|
|
2225
|
+
enabled = client.bool_variation("${t}", { "user_id" => user_id }, false)
|
|
2226
|
+
if enabled
|
|
2227
|
+
# new code path
|
|
2228
|
+
end`,
|
|
2229
|
+
notes: Q
|
|
2230
|
+
};
|
|
2231
|
+
case "swift": return {
|
|
2232
|
+
install: ".package(url: \"https://github.com/canopy-labs/featureflip-swift\", from: \"2.0.0\")",
|
|
2233
|
+
code: `import Featureflip
|
|
2234
|
+
|
|
2235
|
+
let config = FeatureflipConfig(clientKey: "YOUR_CLIENT_SDK_KEY")
|
|
2236
|
+
let client = FeatureflipClient(config: config)
|
|
2237
|
+
await client.initialize()
|
|
2238
|
+
let enabled = client.boolVariation("${t}", default: false)
|
|
2239
|
+
if enabled {
|
|
2240
|
+
// new code path
|
|
2241
|
+
}`,
|
|
2242
|
+
notes: $
|
|
2243
|
+
};
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
// src/tools/workflows/wrap-feature.ts
|
|
2247
|
+
function Ue(e, t) {
|
|
2248
|
+
e.registerTool("wrap_feature", {
|
|
2249
|
+
title: "Wrap a feature in a new flag",
|
|
2250
|
+
description: "Create a Boolean feature flag and get back the SDK code snippet to guard the new code path with it. Returns the snippet only — apply the edit yourself. The flag starts DISABLED in every environment; enable it with toggle_flag when ready.",
|
|
2251
|
+
inputSchema: n.object({
|
|
2252
|
+
project: n.string().describe("Project key"),
|
|
2253
|
+
key: n.string().describe("Flag key, e.g. new-checkout"),
|
|
2254
|
+
name: n.string().optional().describe("Display name; defaults to the key"),
|
|
2255
|
+
description: n.string().optional().describe("What this flag guards"),
|
|
2256
|
+
tags: n.array(n.string()).optional().describe("Tags for filtering, e.g. team or area"),
|
|
2257
|
+
language: n.enum(ze).describe("SDK language of the codebase being edited"),
|
|
2258
|
+
idempotency_key: n.string().optional().describe("Idempotency-Key header for safe retries")
|
|
2259
|
+
}),
|
|
2260
|
+
outputSchema: E({
|
|
2261
|
+
flag: x("POST /api/v1/orgs/{org}/projects/{project}/flags"),
|
|
2262
|
+
integration: O({
|
|
2263
|
+
language: { type: "string" },
|
|
2264
|
+
install: { type: "string" },
|
|
2265
|
+
code: { type: "string" },
|
|
2266
|
+
notes: { type: "string" }
|
|
2267
|
+
}),
|
|
2268
|
+
next_steps: {
|
|
2269
|
+
type: "array",
|
|
2270
|
+
items: { type: "string" }
|
|
2271
|
+
}
|
|
2272
|
+
}, [
|
|
2273
|
+
"flag",
|
|
2274
|
+
"integration",
|
|
2275
|
+
"next_steps"
|
|
2276
|
+
]),
|
|
2277
|
+
annotations: { destructiveHint: !1 }
|
|
2278
|
+
}, async ({ project: e, key: n, name: r, description: i, tags: a, language: s, idempotency_key: c }) => h(async () => {
|
|
2279
|
+
let l = await t.api.request("POST", `/api/v1/orgs/${o(t.org)}/projects/${o(e)}/flags`, {
|
|
2280
|
+
body: {
|
|
2281
|
+
key: n,
|
|
2282
|
+
name: r ?? n,
|
|
2283
|
+
type: "Boolean",
|
|
2284
|
+
description: i,
|
|
2285
|
+
tags: a,
|
|
2286
|
+
...Ve(s) ? { clientSideVisible: !0 } : {}
|
|
2287
|
+
},
|
|
2288
|
+
idempotencyKey: c
|
|
2289
|
+
}), u = He(s, n);
|
|
2290
|
+
return p({
|
|
2291
|
+
flag: l,
|
|
2292
|
+
integration: {
|
|
2293
|
+
language: s,
|
|
2294
|
+
install: u.install,
|
|
2295
|
+
code: u.code,
|
|
2296
|
+
notes: u.notes
|
|
2297
|
+
},
|
|
2298
|
+
next_steps: [
|
|
2299
|
+
"Apply the snippet around the new code path.",
|
|
2300
|
+
`Enable in a non-production environment first: toggle_flag { project: "${e}", flag: "${n}", environment: "<env>", enabled: true }.`,
|
|
2301
|
+
"Ramp with update_targeting (rolloutPercentage) when ready."
|
|
2302
|
+
]
|
|
2303
|
+
});
|
|
2304
|
+
}));
|
|
2305
|
+
}
|
|
2306
|
+
// src/server.ts
|
|
2307
|
+
function We(t) {
|
|
2308
|
+
let n = new e({
|
|
2309
|
+
name: "featureflip",
|
|
2310
|
+
version: r
|
|
2311
|
+
});
|
|
2312
|
+
return ee(n, t), te(n, t), re(n, t), ie(n, t), se(n, t), le(n, t), me(n, t), Te(n, t), he(n, t), Ee(n, t), De(n, t), je(n, t), Me(n, t), Ie(n, t), Re(n, t), Ue(n, t), n;
|
|
2313
|
+
}
|
|
2314
|
+
// src/config.ts
|
|
2315
|
+
var Ge = "FEATUREFLIP_TOKEN is required. Create one in the Featureflip dashboard — Settings → API Tokens (personal token, ffp_...) or Organization Settings → Service Tokens (ffs_...) — and set it in your MCP client config.";
|
|
2316
|
+
function Ke(e = process.env) {
|
|
2317
|
+
let t = e.FEATUREFLIP_TOKEN?.trim();
|
|
2318
|
+
return t ? {
|
|
2319
|
+
token: t,
|
|
2320
|
+
baseUrl: (e.FEATUREFLIP_API_URL?.trim() || "https://api.featureflip.io").replace(/\/+$/, ""),
|
|
2321
|
+
org: e.FEATUREFLIP_ORG?.trim() || void 0
|
|
2322
|
+
} : null;
|
|
2323
|
+
}
|
|
2324
|
+
function qe(e = process.env) {
|
|
2325
|
+
let t = Ke(e);
|
|
2326
|
+
if (!t) throw Error(Ge);
|
|
2327
|
+
return t;
|
|
2328
|
+
}
|
|
2329
|
+
// src/org.ts
|
|
2330
|
+
async function Je(e, t) {
|
|
2331
|
+
if (t) return t;
|
|
2332
|
+
let n = (await e.request("GET", "/api/v1/orgs", { query: { limit: 100 } })).items ?? [];
|
|
2333
|
+
if (n.length === 1) {
|
|
2334
|
+
let e = n[0].slug;
|
|
2335
|
+
if (!e) throw Error("The token can see one organization, but it has no slug set.");
|
|
2336
|
+
return e;
|
|
2337
|
+
}
|
|
2338
|
+
throw n.length === 0 ? Error("The token can see no organizations. Check the token in the Featureflip dashboard.") : Error(`The token can see ${n.length} organizations — set FEATUREFLIP_ORG to one of: ` + n.map((e) => e.slug ?? "?").join(", "));
|
|
2339
|
+
}
|
|
2340
|
+
export { We as a, r as c, Ke as i, Ge as n, i as o, qe as r, f as s, Je as t };
|