@belvador/mcp 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1225 -931
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -182,7 +182,7 @@ function cleanUntrustedText(raw, maxBytes = MCP_LIMITS.untrustedStringMaxBytes)
|
|
|
182
182
|
const { text, cut } = cutUtf8(escaped, maxBytes);
|
|
183
183
|
return { text, cut, suspicious };
|
|
184
184
|
}
|
|
185
|
-
var MCP_TOOLS_VERSION =
|
|
185
|
+
var MCP_TOOLS_VERSION = 5;
|
|
186
186
|
var MCP_TOOLS = [
|
|
187
187
|
{ name: "get_workspace", toolset: "investigate", scope: "org:read", readOnly: true, destructive: false, idempotent: true },
|
|
188
188
|
{ name: "list_projects", toolset: "investigate", scope: "projects:read", readOnly: true, destructive: false, idempotent: true },
|
|
@@ -212,7 +212,6 @@ var MCP_TOOLS = [
|
|
|
212
212
|
{ name: "get_doc", toolset: "docs", scope: null, readOnly: true, destructive: false, idempotent: true }
|
|
213
213
|
];
|
|
214
214
|
var MCP_TOOLS_PENDING = {
|
|
215
|
-
query_metrics: "P14",
|
|
216
215
|
release_health: "P15"
|
|
217
216
|
};
|
|
218
217
|
|
|
@@ -258,7 +257,7 @@ function docsFetcher(siteUrl, fetcher = fetch, now = () => Date.now()) {
|
|
|
258
257
|
import { CLIENT_CAPABILITIES_META_KEY, inputRequired, McpServer } from "@modelcontextprotocol/server";
|
|
259
258
|
|
|
260
259
|
// ../src/shared/contracts/mcp-tools.ts
|
|
261
|
-
import { z as
|
|
260
|
+
import { z as z29 } from "zod";
|
|
262
261
|
|
|
263
262
|
// ../src/shared/contracts/api-ops/access.ts
|
|
264
263
|
import { z as z3 } from "zod";
|
|
@@ -646,7 +645,8 @@ var MONITOR_RULE_KINDS = [
|
|
|
646
645
|
"count",
|
|
647
646
|
"assertion",
|
|
648
647
|
"deadline",
|
|
649
|
-
"stalled"
|
|
648
|
+
"stalled",
|
|
649
|
+
"metric"
|
|
650
650
|
];
|
|
651
651
|
var SLO_RULE_SEVERITIES = ["page", "ticket"];
|
|
652
652
|
function validRuleTriggers(triggers) {
|
|
@@ -1149,10 +1149,10 @@ var COVERAGE_OPERATIONS = [
|
|
|
1149
1149
|
];
|
|
1150
1150
|
|
|
1151
1151
|
// ../src/shared/contracts/api-ops/incidents.ts
|
|
1152
|
-
import { z as
|
|
1152
|
+
import { z as z14 } from "zod";
|
|
1153
1153
|
|
|
1154
1154
|
// ../src/shared/contracts/notifications.ts
|
|
1155
|
-
import { z as
|
|
1155
|
+
import { z as z13 } from "zod";
|
|
1156
1156
|
|
|
1157
1157
|
// ../src/shared/contracts/maintenance.ts
|
|
1158
1158
|
import { z as z9 } from "zod";
|
|
@@ -1211,15 +1211,182 @@ function validTimeZone(tz) {
|
|
|
1211
1211
|
var fmtCache = new Map;
|
|
1212
1212
|
|
|
1213
1213
|
// ../src/shared/contracts/signal-monitors.ts
|
|
1214
|
-
import { z as
|
|
1214
|
+
import { z as z12 } from "zod";
|
|
1215
1215
|
|
|
1216
|
-
// ../src/shared/contracts/
|
|
1216
|
+
// ../src/shared/contracts/metrics.ts
|
|
1217
1217
|
import { z as z10 } from "zod";
|
|
1218
1218
|
|
|
1219
|
+
// ../src/shared/contracts/vocab/telemetry.ts
|
|
1220
|
+
var TELEMETRY_MAX_WINDOW_MS = 7 * 24 * 3600 * 1000;
|
|
1221
|
+
var ATTR_OPS = ["=", "!=", "exists"];
|
|
1222
|
+
var ATTR_FILTERS_MAX = 5;
|
|
1223
|
+
var TELEMETRY_PLAN_DEFAULTS = {
|
|
1224
|
+
traces_retention_days: 7,
|
|
1225
|
+
logs_retention_days: 7,
|
|
1226
|
+
traces_monthly_bytes: 5 * 1000 ** 3,
|
|
1227
|
+
logs_monthly_bytes: 5 * 1000 ** 3,
|
|
1228
|
+
metrics_retention_days: 14,
|
|
1229
|
+
metrics_monthly_bytes: 2 * 1000 ** 3,
|
|
1230
|
+
metric_series_max: 1e4,
|
|
1231
|
+
metric_names_max: 1000,
|
|
1232
|
+
telemetry_rate_bytes_per_sec: 1024 * 1024,
|
|
1233
|
+
telemetry_burst_bytes: 8 * 1024 * 1024,
|
|
1234
|
+
telemetry_buffer_minutes: 15,
|
|
1235
|
+
max_ingest_keys_per_project: 10
|
|
1236
|
+
};
|
|
1237
|
+
|
|
1238
|
+
// ../src/shared/contracts/vocab/metrics.ts
|
|
1239
|
+
var METRIC_TYPES = ["gauge", "sum", "histogram", "exp_histogram"];
|
|
1240
|
+
var METRIC_KINDS = ["gauge", "counter", "histogram", "exp_histogram"];
|
|
1241
|
+
var METRIC_AGGREGATIONS = ["avg", "sum", "min", "max", "count", "rate", "p50", "p90", "p95", "p99"];
|
|
1242
|
+
var METRIC_NAME_RE = /^[A-Za-z_][A-Za-z0-9_.:\-/]{0,254}$/;
|
|
1243
|
+
var METRIC_ATTR_KEY_RE = /^[A-Za-z0-9_.:\-/@]{1,256}$/;
|
|
1244
|
+
var METRIC_GROUP_BY_MAX = 2;
|
|
1245
|
+
function defaultAggregation(kind) {
|
|
1246
|
+
return kind === "counter" ? "rate" : kind === "histogram" || kind === "exp_histogram" ? "p95" : "avg";
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
// ../src/shared/contracts/metrics.ts
|
|
1250
|
+
var METRIC_TEMPORALITIES = ["unspecified", "delta", "cumulative"];
|
|
1251
|
+
var METRIC_LIMITS = {
|
|
1252
|
+
attributesPerSeries: 32,
|
|
1253
|
+
attributeValueMaxChars: 256,
|
|
1254
|
+
nameMaxChars: 255,
|
|
1255
|
+
unitMaxChars: 63,
|
|
1256
|
+
descriptionMaxChars: 512,
|
|
1257
|
+
bucketsMax: 320,
|
|
1258
|
+
seriesActiveMs: 24 * 3600 * 1000,
|
|
1259
|
+
seriesTouchMs: 3600 * 1000,
|
|
1260
|
+
expMaxStoredScale: 3,
|
|
1261
|
+
expMinScale: -10,
|
|
1262
|
+
expMaxScale: 20,
|
|
1263
|
+
resourceKeys: ["service.name", "service.namespace", "deployment.environment.name", "host.name"],
|
|
1264
|
+
limitedNamesKept: 50
|
|
1265
|
+
};
|
|
1266
|
+
var METRIC_PLAN_DEFAULTS = {
|
|
1267
|
+
metrics_retention_days: TELEMETRY_PLAN_DEFAULTS.metrics_retention_days,
|
|
1268
|
+
metrics_monthly_bytes: TELEMETRY_PLAN_DEFAULTS.metrics_monthly_bytes,
|
|
1269
|
+
metric_series_max: TELEMETRY_PLAN_DEFAULTS.metric_series_max,
|
|
1270
|
+
metric_names_max: TELEMETRY_PLAN_DEFAULTS.metric_names_max
|
|
1271
|
+
};
|
|
1272
|
+
var METRIC_SERIES_MAX_RANGE = { min: 100, max: 1e6 };
|
|
1273
|
+
var METRIC_NAMES_MAX_RANGE = { min: 10, max: 1e5 };
|
|
1274
|
+
var metricsConfigSchema = z10.object({
|
|
1275
|
+
retention_days: z10.number().int().min(1).max(90),
|
|
1276
|
+
series_max: z10.number().int().min(METRIC_SERIES_MAX_RANGE.min).max(METRIC_SERIES_MAX_RANGE.max),
|
|
1277
|
+
names_max: z10.number().int().min(METRIC_NAMES_MAX_RANGE.min).max(METRIC_NAMES_MAX_RANGE.max)
|
|
1278
|
+
});
|
|
1279
|
+
var METRIC_QUERY = {
|
|
1280
|
+
filtersMax: ATTR_FILTERS_MAX,
|
|
1281
|
+
groupByMax: METRIC_GROUP_BY_MAX,
|
|
1282
|
+
minStepSeconds: 60,
|
|
1283
|
+
maxStepSeconds: 86400,
|
|
1284
|
+
maxWindowMs: 7 * 24 * 3600 * 1000,
|
|
1285
|
+
defaultWindowMs: 3600 * 1000,
|
|
1286
|
+
groupsMax: 50,
|
|
1287
|
+
pointsMax: 1e4,
|
|
1288
|
+
namesMax: 1000,
|
|
1289
|
+
seriesPageSize: 100,
|
|
1290
|
+
exemplarsMax: 50,
|
|
1291
|
+
queryMaxSeconds: 3
|
|
1292
|
+
};
|
|
1293
|
+
var metricName = z10.string().min(1).max(METRIC_LIMITS.nameMaxChars).regex(METRIC_NAME_RE);
|
|
1294
|
+
var attrKey = z10.string().regex(METRIC_ATTR_KEY_RE);
|
|
1295
|
+
var metricFilterSchema = z10.object({
|
|
1296
|
+
k: attrKey,
|
|
1297
|
+
op: z10.enum(ATTR_OPS),
|
|
1298
|
+
v: z10.string().max(512).optional()
|
|
1299
|
+
});
|
|
1300
|
+
var metricQuerySchema = z10.object({
|
|
1301
|
+
name: metricName,
|
|
1302
|
+
aggregation: z10.enum(METRIC_AGGREGATIONS),
|
|
1303
|
+
filter: z10.array(metricFilterSchema).max(METRIC_QUERY.filtersMax),
|
|
1304
|
+
group_by: z10.array(attrKey).max(METRIC_QUERY.groupByMax)
|
|
1305
|
+
}).superRefine((q, ctx) => {
|
|
1306
|
+
q.filter.forEach((f, i) => {
|
|
1307
|
+
if (f.op === "exists" !== (f.v === undefined))
|
|
1308
|
+
ctx.addIssue({ code: "custom", path: ["filter", i, "v"], message: "value" });
|
|
1309
|
+
});
|
|
1310
|
+
if (new Set(q.group_by).size !== q.group_by.length)
|
|
1311
|
+
ctx.addIssue({ code: "custom", path: ["group_by"], message: "unique" });
|
|
1312
|
+
});
|
|
1313
|
+
var ts = z10.string().max(40);
|
|
1314
|
+
var count2 = z10.coerce.number().int().nonnegative().catch(0);
|
|
1315
|
+
var label = z10.string().max(METRIC_LIMITS.attributeValueMaxChars);
|
|
1316
|
+
var completeness = {
|
|
1317
|
+
complete: z10.boolean(),
|
|
1318
|
+
reason: z10.enum(["time_budget", "row_cap", "groups", "points"]).optional().catch(undefined)
|
|
1319
|
+
};
|
|
1320
|
+
var metricNameRowSchema = z10.object({
|
|
1321
|
+
name: metricName,
|
|
1322
|
+
type: z10.enum(METRIC_TYPES),
|
|
1323
|
+
kind: z10.enum(METRIC_KINDS),
|
|
1324
|
+
unit: z10.string().max(METRIC_LIMITS.unitMaxChars).catch(""),
|
|
1325
|
+
description: z10.string().max(METRIC_LIMITS.descriptionMaxChars).catch(""),
|
|
1326
|
+
series: count2,
|
|
1327
|
+
last_seen: ts
|
|
1328
|
+
});
|
|
1329
|
+
var metricCardinalitySchema = z10.object({
|
|
1330
|
+
series_active: count2,
|
|
1331
|
+
series_max: count2,
|
|
1332
|
+
names_active: count2,
|
|
1333
|
+
names_max: count2,
|
|
1334
|
+
limited: z10.array(z10.object({ name: z10.string().max(METRIC_LIMITS.nameMaxChars), points: count2 })).max(METRIC_LIMITS.limitedNamesKept).catch([])
|
|
1335
|
+
});
|
|
1336
|
+
var metricNamesSchema = z10.object({
|
|
1337
|
+
names: z10.array(metricNameRowSchema).max(METRIC_QUERY.namesMax),
|
|
1338
|
+
cardinality: metricCardinalitySchema,
|
|
1339
|
+
...completeness
|
|
1340
|
+
});
|
|
1341
|
+
var metricSeriesRowSchema = z10.object({
|
|
1342
|
+
series_id: z10.string().regex(/^[0-9a-f]{16}$/),
|
|
1343
|
+
name: metricName,
|
|
1344
|
+
type: z10.enum(METRIC_TYPES),
|
|
1345
|
+
kind: z10.enum(METRIC_KINDS),
|
|
1346
|
+
temporality: z10.enum(METRIC_TEMPORALITIES).catch("unspecified"),
|
|
1347
|
+
unit: z10.string().max(METRIC_LIMITS.unitMaxChars).catch(""),
|
|
1348
|
+
service: label.catch(""),
|
|
1349
|
+
environment: z10.string().max(64).catch(""),
|
|
1350
|
+
attributes: z10.record(z10.string().max(256), label).catch({}),
|
|
1351
|
+
first_seen: ts,
|
|
1352
|
+
last_seen: ts
|
|
1353
|
+
});
|
|
1354
|
+
var metricSeriesListSchema = z10.object({
|
|
1355
|
+
series: z10.array(metricSeriesRowSchema).max(METRIC_QUERY.seriesPageSize),
|
|
1356
|
+
next_cursor: z10.string().max(64).nullable(),
|
|
1357
|
+
...completeness
|
|
1358
|
+
});
|
|
1359
|
+
var metricExemplarSchema = z10.object({
|
|
1360
|
+
t: ts,
|
|
1361
|
+
value: z10.number(),
|
|
1362
|
+
trace_id: z10.string().regex(/^[0-9a-f]{32}$/),
|
|
1363
|
+
span_id: z10.union([z10.string().regex(/^[0-9a-f]{16}$/), z10.literal("")]),
|
|
1364
|
+
group: z10.number().int().nonnegative()
|
|
1365
|
+
});
|
|
1366
|
+
var metricResultSchema = z10.object({
|
|
1367
|
+
name: metricName,
|
|
1368
|
+
aggregation: z10.enum(METRIC_AGGREGATIONS),
|
|
1369
|
+
kind: z10.enum(METRIC_KINDS),
|
|
1370
|
+
unit: z10.string().max(METRIC_LIMITS.unitMaxChars).catch(""),
|
|
1371
|
+
step_seconds: z10.number().int().positive(),
|
|
1372
|
+
from: ts,
|
|
1373
|
+
to: ts,
|
|
1374
|
+
groups: z10.array(z10.object({
|
|
1375
|
+
key: z10.record(z10.string().max(256), label),
|
|
1376
|
+
points: z10.array(z10.object({ t: ts, v: z10.number().nullable() })).max(METRIC_QUERY.pointsMax)
|
|
1377
|
+
})).max(METRIC_QUERY.groupsMax),
|
|
1378
|
+
exemplars: z10.array(metricExemplarSchema).max(METRIC_QUERY.exemplarsMax).catch([]),
|
|
1379
|
+
...completeness
|
|
1380
|
+
});
|
|
1381
|
+
var HIST_OVERFLOW = Number.MAX_VALUE;
|
|
1382
|
+
|
|
1383
|
+
// ../src/shared/contracts/monitors.ts
|
|
1384
|
+
import { z as z11 } from "zod";
|
|
1385
|
+
|
|
1219
1386
|
// ../src/shared/contracts/vocab/monitors.ts
|
|
1220
1387
|
var MONITOR_MODES = ["check_in", "heartbeat"];
|
|
1221
|
-
var MONITOR_TYPES = ["job", "count", "assertion", "deadline", "progress"];
|
|
1222
|
-
var SIGNAL_MONITOR_TYPES = ["count", "assertion", "deadline", "progress"];
|
|
1388
|
+
var MONITOR_TYPES = ["job", "count", "assertion", "deadline", "progress", "metric"];
|
|
1389
|
+
var SIGNAL_MONITOR_TYPES = ["count", "assertion", "deadline", "progress", "metric"];
|
|
1223
1390
|
|
|
1224
1391
|
// ../src/shared/contracts/monitors.ts
|
|
1225
1392
|
var MONITOR_KINDS = ["crontab", "interval", "on_demand"];
|
|
@@ -1233,7 +1400,8 @@ var MONITOR_INCIDENT_CODES = [
|
|
|
1233
1400
|
"MONITOR_COUNT",
|
|
1234
1401
|
"MONITOR_ASSERTION",
|
|
1235
1402
|
"MONITOR_DEADLINE_MISSED",
|
|
1236
|
-
"MONITOR_STALLED"
|
|
1403
|
+
"MONITOR_STALLED",
|
|
1404
|
+
"MONITOR_METRIC"
|
|
1237
1405
|
];
|
|
1238
1406
|
var FAILURE_INCIDENT_CODES = MONITOR_INCIDENT_CODES.filter((c) => c !== "MONITOR_UNKNOWN");
|
|
1239
1407
|
var INCIDENT_EVENTS = ["opened", "updated", "resolved"];
|
|
@@ -1286,112 +1454,114 @@ function crontabShapeOk(value) {
|
|
|
1286
1454
|
const fields = value.trim().split(/\s+/);
|
|
1287
1455
|
return value.length <= 120 && fields.length === 5 && fields.every((f) => /^[0-9A-Za-z*,/?#LW-]+$/.test(f));
|
|
1288
1456
|
}
|
|
1289
|
-
var crontabScheduleSchema =
|
|
1290
|
-
type:
|
|
1291
|
-
value:
|
|
1457
|
+
var crontabScheduleSchema = z11.object({
|
|
1458
|
+
type: z11.literal("crontab"),
|
|
1459
|
+
value: z11.string().refine(crontabShapeOk, "crontab")
|
|
1292
1460
|
});
|
|
1293
|
-
var intervalScheduleSchema =
|
|
1294
|
-
type:
|
|
1295
|
-
value:
|
|
1296
|
-
unit:
|
|
1461
|
+
var intervalScheduleSchema = z11.object({
|
|
1462
|
+
type: z11.literal("interval"),
|
|
1463
|
+
value: z11.number().int().min(1).max(MONITOR_LIMITS.intervalValueMax),
|
|
1464
|
+
unit: z11.enum(INTERVAL_UNITS)
|
|
1297
1465
|
});
|
|
1298
|
-
var scheduleSchema =
|
|
1466
|
+
var scheduleSchema = z11.discriminatedUnion("type", [
|
|
1299
1467
|
crontabScheduleSchema,
|
|
1300
1468
|
intervalScheduleSchema
|
|
1301
1469
|
]);
|
|
1302
|
-
var monitorSettingsSchema =
|
|
1470
|
+
var monitorSettingsSchema = z11.object({
|
|
1303
1471
|
schedule: scheduleSchema.nullable(),
|
|
1304
|
-
timezone:
|
|
1305
|
-
checkin_margin:
|
|
1306
|
-
max_runtime:
|
|
1307
|
-
failure_issue_threshold:
|
|
1308
|
-
recovery_threshold:
|
|
1472
|
+
timezone: z11.string().min(1).max(64),
|
|
1473
|
+
checkin_margin: z11.number().int().min(MONITOR_LIMITS.checkinMarginMin).max(MONITOR_LIMITS.checkinMarginMax),
|
|
1474
|
+
max_runtime: z11.number().int().min(MONITOR_LIMITS.maxRuntimeMin).max(MONITOR_LIMITS.maxRuntimeMax),
|
|
1475
|
+
failure_issue_threshold: z11.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax),
|
|
1476
|
+
recovery_threshold: z11.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax)
|
|
1309
1477
|
});
|
|
1310
|
-
var iso3 =
|
|
1311
|
-
var projectId3 =
|
|
1312
|
-
var envName =
|
|
1478
|
+
var iso3 = z11.string().datetime();
|
|
1479
|
+
var projectId3 = z11.number().int().positive();
|
|
1480
|
+
var envName = z11.string().min(1).max(MONITOR_LIMITS.environmentMax);
|
|
1313
1481
|
var monitorDefinitionSchema = monitorSettingsSchema.extend({
|
|
1314
|
-
id:
|
|
1482
|
+
id: z11.guid(),
|
|
1315
1483
|
project_id: projectId3,
|
|
1316
|
-
slug:
|
|
1317
|
-
kind:
|
|
1318
|
-
expected_environments:
|
|
1484
|
+
slug: z11.string().regex(SLUG_RE),
|
|
1485
|
+
kind: z11.enum(MONITOR_KINDS),
|
|
1486
|
+
expected_environments: z11.array(envName).max(MONITOR_LIMITS.expectedEnvironmentsMax),
|
|
1319
1487
|
paused_until: iso3.nullable(),
|
|
1320
1488
|
created_at: iso3,
|
|
1321
|
-
config_source:
|
|
1322
|
-
config_hash:
|
|
1489
|
+
config_source: z11.enum(CONFIG_SOURCES),
|
|
1490
|
+
config_hash: z11.string().regex(/^[0-9a-f]{64}$/).nullable()
|
|
1323
1491
|
});
|
|
1324
|
-
var outcomeCounts =
|
|
1325
|
-
ok:
|
|
1326
|
-
skipped:
|
|
1327
|
-
error:
|
|
1328
|
-
timeout:
|
|
1329
|
-
missed:
|
|
1330
|
-
unknown:
|
|
1492
|
+
var outcomeCounts = z11.object({
|
|
1493
|
+
ok: z11.number().int().nonnegative(),
|
|
1494
|
+
skipped: z11.number().int().nonnegative(),
|
|
1495
|
+
error: z11.number().int().nonnegative(),
|
|
1496
|
+
timeout: z11.number().int().nonnegative(),
|
|
1497
|
+
missed: z11.number().int().nonnegative(),
|
|
1498
|
+
unknown: z11.number().int().nonnegative()
|
|
1331
1499
|
});
|
|
1332
|
-
var
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1500
|
+
var MONITOR_NUMBER_MAX = 1000000000000000;
|
|
1501
|
+
var monitorNumber = z11.number().finite().min(-MONITOR_NUMBER_MAX).max(MONITOR_NUMBER_MAX);
|
|
1502
|
+
var signalStatusSchema = z11.object({
|
|
1503
|
+
type: z11.enum(SIGNAL_MONITOR_TYPES),
|
|
1504
|
+
value: monitorNumber.nullable(),
|
|
1505
|
+
threshold: monitorNumber.nullable(),
|
|
1336
1506
|
window_end: iso3.nullable(),
|
|
1337
|
-
pending:
|
|
1338
|
-
stalled:
|
|
1339
|
-
refused_24h:
|
|
1507
|
+
pending: z11.number().int().nonnegative().max(1e6).nullable(),
|
|
1508
|
+
stalled: z11.number().int().nonnegative().max(1e6).nullable(),
|
|
1509
|
+
refused_24h: z11.number().int().nonnegative().max(1e9).nullable()
|
|
1340
1510
|
});
|
|
1341
|
-
var monitorStatusSchema =
|
|
1342
|
-
monitor_id:
|
|
1511
|
+
var monitorStatusSchema = z11.object({
|
|
1512
|
+
monitor_id: z11.guid(),
|
|
1343
1513
|
project_id: projectId3,
|
|
1344
1514
|
environment: envName,
|
|
1345
|
-
open_failure:
|
|
1346
|
-
open_unknown:
|
|
1347
|
-
unobservable:
|
|
1348
|
-
last_outcome:
|
|
1515
|
+
open_failure: z11.enum(FAILURE_INCIDENT_CODES).nullable(),
|
|
1516
|
+
open_unknown: z11.boolean(),
|
|
1517
|
+
unobservable: z11.enum(UNOBSERVABLE_REASONS).nullable(),
|
|
1518
|
+
last_outcome: z11.enum(RUN_OUTCOMES).nullable(),
|
|
1349
1519
|
last_check_in_at: iso3.nullable(),
|
|
1350
1520
|
last_healthy_at: iso3.nullable(),
|
|
1351
1521
|
next_deadline_at: iso3.nullable(),
|
|
1352
1522
|
next_due_at: iso3.nullable().optional(),
|
|
1353
|
-
in_progress:
|
|
1523
|
+
in_progress: z11.boolean(),
|
|
1354
1524
|
counts_24h: outcomeCounts,
|
|
1355
1525
|
signal: signalStatusSchema.optional(),
|
|
1356
1526
|
evaluated_at: iso3
|
|
1357
1527
|
});
|
|
1358
|
-
var monitorIncidentSchema =
|
|
1359
|
-
incident_id:
|
|
1360
|
-
monitor_id:
|
|
1528
|
+
var monitorIncidentSchema = z11.object({
|
|
1529
|
+
incident_id: z11.guid(),
|
|
1530
|
+
monitor_id: z11.guid(),
|
|
1361
1531
|
project_id: projectId3,
|
|
1362
1532
|
environment: envName,
|
|
1363
|
-
code:
|
|
1364
|
-
event:
|
|
1533
|
+
code: z11.enum(MONITOR_INCIDENT_CODES),
|
|
1534
|
+
event: z11.enum(INCIDENT_EVENTS),
|
|
1365
1535
|
occurred_at: iso3,
|
|
1366
|
-
detected_late:
|
|
1367
|
-
reason:
|
|
1368
|
-
duration_ms:
|
|
1369
|
-
consecutive:
|
|
1370
|
-
reviewed_by:
|
|
1371
|
-
observed:
|
|
1372
|
-
threshold:
|
|
1536
|
+
detected_late: z11.boolean(),
|
|
1537
|
+
reason: z11.string().regex(REASON_RE).nullable(),
|
|
1538
|
+
duration_ms: z11.number().int().nonnegative().nullable(),
|
|
1539
|
+
consecutive: z11.number().int().min(1).max(1e5),
|
|
1540
|
+
reviewed_by: z11.guid().nullable(),
|
|
1541
|
+
observed: monitorNumber.nullable().optional(),
|
|
1542
|
+
threshold: monitorNumber.nullable().optional()
|
|
1373
1543
|
});
|
|
1374
|
-
var monitorDiscoverySchema =
|
|
1544
|
+
var monitorDiscoverySchema = z11.object({
|
|
1375
1545
|
project_id: projectId3,
|
|
1376
|
-
slug:
|
|
1546
|
+
slug: z11.string().regex(SLUG_RE),
|
|
1377
1547
|
settings: monitorSettingsSchema.nullable(),
|
|
1378
|
-
config_hash:
|
|
1379
|
-
check_ins:
|
|
1548
|
+
config_hash: z11.string().regex(/^[0-9a-f]{64}$/).nullable(),
|
|
1549
|
+
check_ins: z11.number().int().nonnegative(),
|
|
1380
1550
|
last_seen_at: iso3
|
|
1381
1551
|
});
|
|
1382
1552
|
var MONITOR_NAME_MAX = MONITOR_LIMITS.nameMax;
|
|
1383
|
-
var environmentName =
|
|
1384
|
-
var monitorInputSchema =
|
|
1385
|
-
name:
|
|
1386
|
-
mode:
|
|
1387
|
-
kind:
|
|
1553
|
+
var environmentName = z11.string().trim().min(1).max(MONITOR_LIMITS.environmentMax).regex(/^[A-Za-z0-9._-]+$/);
|
|
1554
|
+
var monitorInputSchema = z11.object({
|
|
1555
|
+
name: z11.string().trim().min(1).max(MONITOR_LIMITS.nameMax),
|
|
1556
|
+
mode: z11.enum(MONITOR_MODES).default("check_in"),
|
|
1557
|
+
kind: z11.enum(MONITOR_KINDS),
|
|
1388
1558
|
schedule: scheduleSchema.nullable(),
|
|
1389
|
-
timezone:
|
|
1390
|
-
checkinMarginMin:
|
|
1391
|
-
maxRuntimeMin:
|
|
1392
|
-
failureThreshold:
|
|
1393
|
-
recoveryThreshold:
|
|
1394
|
-
expectedEnvironments:
|
|
1559
|
+
timezone: z11.string().trim().min(1).max(64),
|
|
1560
|
+
checkinMarginMin: z11.number().int().min(MONITOR_LIMITS.checkinMarginMin).max(MONITOR_LIMITS.checkinMarginMax),
|
|
1561
|
+
maxRuntimeMin: z11.number().int().min(MONITOR_LIMITS.maxRuntimeMin).max(MONITOR_LIMITS.maxRuntimeMax),
|
|
1562
|
+
failureThreshold: z11.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax),
|
|
1563
|
+
recoveryThreshold: z11.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax),
|
|
1564
|
+
expectedEnvironments: z11.array(environmentName).min(1).max(MONITOR_LIMITS.expectedEnvironmentsMax)
|
|
1395
1565
|
}).refine((v) => v.kind === "on_demand" ? v.schedule === null : v.schedule?.type === v.kind, {
|
|
1396
1566
|
path: ["schedule"],
|
|
1397
1567
|
message: "schedule"
|
|
@@ -1406,88 +1576,88 @@ var MONITOR_INPUT_DEFAULTS = {
|
|
|
1406
1576
|
recoveryThreshold: MONITOR_LIMITS.recoveryThresholdDefault,
|
|
1407
1577
|
expectedEnvironments: [DEFAULT_CHECK_IN_ENVIRONMENT]
|
|
1408
1578
|
};
|
|
1409
|
-
var runOutcome =
|
|
1410
|
-
var runFlags =
|
|
1411
|
-
var monitorRunSchema =
|
|
1412
|
-
id:
|
|
1413
|
-
kind:
|
|
1579
|
+
var runOutcome = z11.enum(RUN_OUTCOMES);
|
|
1580
|
+
var runFlags = z11.array(z11.string().max(32)).max(16);
|
|
1581
|
+
var monitorRunSchema = z11.object({
|
|
1582
|
+
id: z11.number().int().positive(),
|
|
1583
|
+
kind: z11.enum(["run", "missed"]),
|
|
1414
1584
|
outcome: runOutcome,
|
|
1415
1585
|
started_at: iso3,
|
|
1416
1586
|
ended_at: iso3,
|
|
1417
|
-
attempts:
|
|
1418
|
-
duration_ms:
|
|
1419
|
-
reason:
|
|
1420
|
-
check_in_id:
|
|
1421
|
-
trace_id:
|
|
1422
|
-
release:
|
|
1587
|
+
attempts: z11.number().int().nonnegative(),
|
|
1588
|
+
duration_ms: z11.number().int().nonnegative().nullable(),
|
|
1589
|
+
reason: z11.string().max(64).nullable(),
|
|
1590
|
+
check_in_id: z11.string().max(64).nullable(),
|
|
1591
|
+
trace_id: z11.string().max(32).nullable(),
|
|
1592
|
+
release: z11.string().max(MONITOR_LIMITS.releaseMax).nullable(),
|
|
1423
1593
|
flags: runFlags
|
|
1424
1594
|
});
|
|
1425
|
-
var openAttemptSchema =
|
|
1426
|
-
check_in_id:
|
|
1427
|
-
run_key:
|
|
1428
|
-
attempt:
|
|
1429
|
-
state:
|
|
1595
|
+
var openAttemptSchema = z11.object({
|
|
1596
|
+
check_in_id: z11.string().max(64),
|
|
1597
|
+
run_key: z11.string().max(64),
|
|
1598
|
+
attempt: z11.number().int().nonnegative(),
|
|
1599
|
+
state: z11.string().max(16),
|
|
1430
1600
|
started_at: iso3,
|
|
1431
1601
|
deadline_at: iso3
|
|
1432
1602
|
});
|
|
1433
|
-
var monitorRunsResponseSchema =
|
|
1434
|
-
open:
|
|
1435
|
-
runs:
|
|
1436
|
-
next_cursor:
|
|
1603
|
+
var monitorRunsResponseSchema = z11.object({
|
|
1604
|
+
open: z11.array(openAttemptSchema).max(100),
|
|
1605
|
+
runs: z11.array(monitorRunSchema).max(MONITOR_LIMITS.runsPageSize),
|
|
1606
|
+
next_cursor: z11.string().max(32).nullable()
|
|
1437
1607
|
});
|
|
1438
|
-
var timelineRunSchema =
|
|
1439
|
-
id:
|
|
1440
|
-
kind:
|
|
1608
|
+
var timelineRunSchema = z11.object({
|
|
1609
|
+
id: z11.number().int().positive(),
|
|
1610
|
+
kind: z11.enum(["run", "missed"]),
|
|
1441
1611
|
outcome: runOutcome,
|
|
1442
1612
|
ended_at: iso3,
|
|
1443
1613
|
flags: runFlags
|
|
1444
1614
|
});
|
|
1445
|
-
var monitorTimelineResponseSchema =
|
|
1446
|
-
runs:
|
|
1615
|
+
var monitorTimelineResponseSchema = z11.object({
|
|
1616
|
+
runs: z11.array(timelineRunSchema).max(MONITOR_LIMITS.timelineRuns)
|
|
1447
1617
|
});
|
|
1448
|
-
var monitorStripsResponseSchema =
|
|
1449
|
-
strips:
|
|
1450
|
-
monitor_id:
|
|
1618
|
+
var monitorStripsResponseSchema = z11.object({
|
|
1619
|
+
strips: z11.array(z11.object({
|
|
1620
|
+
monitor_id: z11.guid(),
|
|
1451
1621
|
environment: envName,
|
|
1452
|
-
runs:
|
|
1622
|
+
runs: z11.array(timelineRunSchema).max(MONITOR_LIMITS.listStripRuns)
|
|
1453
1623
|
})).max(5000)
|
|
1454
1624
|
});
|
|
1455
|
-
var monitorDiagnosticSchema =
|
|
1456
|
-
id:
|
|
1457
|
-
check_in_id:
|
|
1458
|
-
signal:
|
|
1459
|
-
exit_code:
|
|
1625
|
+
var monitorDiagnosticSchema = z11.object({
|
|
1626
|
+
id: z11.string().regex(/^\d{1,19}$/),
|
|
1627
|
+
check_in_id: z11.string().max(64).nullable(),
|
|
1628
|
+
signal: z11.string().max(16),
|
|
1629
|
+
exit_code: z11.number().int().min(0).max(255).nullable(),
|
|
1460
1630
|
received_at: iso3,
|
|
1461
|
-
body:
|
|
1631
|
+
body: z11.string().max(MONITOR_LIMITS.diagnosticMaxBytes * 2)
|
|
1462
1632
|
});
|
|
1463
|
-
var monitorDiagnosticsResponseSchema =
|
|
1464
|
-
diagnostics:
|
|
1465
|
-
next_cursor:
|
|
1633
|
+
var monitorDiagnosticsResponseSchema = z11.object({
|
|
1634
|
+
diagnostics: z11.array(monitorDiagnosticSchema).max(50),
|
|
1635
|
+
next_cursor: z11.string().regex(/^\d{1,19}$/).nullable()
|
|
1466
1636
|
});
|
|
1467
|
-
var checkInDetailSchema =
|
|
1468
|
-
run_key:
|
|
1469
|
-
attempts:
|
|
1470
|
-
check_in_id:
|
|
1471
|
-
attempt:
|
|
1472
|
-
result:
|
|
1637
|
+
var checkInDetailSchema = z11.object({
|
|
1638
|
+
run_key: z11.string().max(64),
|
|
1639
|
+
attempts: z11.array(z11.object({
|
|
1640
|
+
check_in_id: z11.string().max(64),
|
|
1641
|
+
attempt: z11.number().int().nonnegative(),
|
|
1642
|
+
result: z11.string().max(16),
|
|
1473
1643
|
started_at: iso3,
|
|
1474
1644
|
ended_at: iso3.nullable(),
|
|
1475
|
-
duration_ms:
|
|
1476
|
-
reason:
|
|
1477
|
-
trace_id:
|
|
1478
|
-
release:
|
|
1645
|
+
duration_ms: z11.number().int().nonnegative().nullable(),
|
|
1646
|
+
reason: z11.string().max(64).nullable(),
|
|
1647
|
+
trace_id: z11.string().max(32).nullable(),
|
|
1648
|
+
release: z11.string().max(MONITOR_LIMITS.releaseMax).nullable()
|
|
1479
1649
|
})).max(1000),
|
|
1480
|
-
errors:
|
|
1481
|
-
event_id:
|
|
1482
|
-
issue_id:
|
|
1483
|
-
title:
|
|
1484
|
-
level:
|
|
1650
|
+
errors: z11.array(z11.object({
|
|
1651
|
+
event_id: z11.string().max(64),
|
|
1652
|
+
issue_id: z11.number().int().nonnegative(),
|
|
1653
|
+
title: z11.string().max(1024),
|
|
1654
|
+
level: z11.string().max(16),
|
|
1485
1655
|
timestamp: iso3,
|
|
1486
|
-
same_trace:
|
|
1656
|
+
same_trace: z11.boolean()
|
|
1487
1657
|
})).max(50),
|
|
1488
|
-
diagnostics:
|
|
1658
|
+
diagnostics: z11.array(monitorDiagnosticSchema).max(20).default([])
|
|
1489
1659
|
});
|
|
1490
|
-
var incidentReviewSchema =
|
|
1660
|
+
var incidentReviewSchema = z11.object({ incident_id: z11.guid() });
|
|
1491
1661
|
|
|
1492
1662
|
// ../src/shared/contracts/signal-monitors.ts
|
|
1493
1663
|
var isSignalMonitorType = (t) => SIGNAL_MONITOR_TYPES.includes(t);
|
|
@@ -1527,6 +1697,7 @@ var SIGNAL_LIMITS = {
|
|
|
1527
1697
|
evaluateEverySeconds: 15,
|
|
1528
1698
|
settleSeconds: 20,
|
|
1529
1699
|
countMaxDelayMinutes: 10,
|
|
1700
|
+
metricDelaySeconds: 120,
|
|
1530
1701
|
countMinutesPerTick: 60,
|
|
1531
1702
|
windowsPerTick: 120,
|
|
1532
1703
|
monitorsPerQuery: 50,
|
|
@@ -1540,11 +1711,11 @@ var SIGNAL_LIMITS = {
|
|
|
1540
1711
|
queryMaxSeconds: 5
|
|
1541
1712
|
};
|
|
1542
1713
|
var SELECTOR_KEY_RE = /^(?:tags\.[A-Za-z0-9_.:-]{1,100}|[A-Za-z_][A-Za-z0-9_.:-]{0,127})$/;
|
|
1543
|
-
var scalar =
|
|
1544
|
-
var selectorConditionSchema =
|
|
1545
|
-
key:
|
|
1546
|
-
op:
|
|
1547
|
-
value:
|
|
1714
|
+
var scalar = z12.union([z12.string().max(SIGNAL_LIMITS.valueMax), z12.number().finite(), z12.boolean()]);
|
|
1715
|
+
var selectorConditionSchema = z12.object({
|
|
1716
|
+
key: z12.string().min(1).max(SIGNAL_LIMITS.keyMax).regex(SELECTOR_KEY_RE),
|
|
1717
|
+
op: z12.enum(SELECTOR_OPS),
|
|
1718
|
+
value: z12.union([scalar, z12.array(z12.string().max(SIGNAL_LIMITS.valueMax)).min(1).max(SIGNAL_LIMITS.inValuesMax)]).optional()
|
|
1548
1719
|
}).superRefine((c, ctx) => {
|
|
1549
1720
|
const bad = (message) => ctx.addIssue({ code: "custom", path: ["value"], message });
|
|
1550
1721
|
if (VALUELESS_OPS.has(c.op)) {
|
|
@@ -1566,10 +1737,10 @@ var selectorConditionSchema = z11.object({
|
|
|
1566
1737
|
if (c.op === "prefix" && (typeof c.value !== "string" || c.value.length === 0))
|
|
1567
1738
|
bad("text");
|
|
1568
1739
|
});
|
|
1569
|
-
var environmentListSchema =
|
|
1570
|
-
var selectorSchema =
|
|
1571
|
-
signal:
|
|
1572
|
-
match:
|
|
1740
|
+
var environmentListSchema = z12.array(z12.string().trim().min(1).max(MONITOR_LIMITS.environmentMax).regex(/^[A-Za-z0-9._-]+$/)).min(1).max(SIGNAL_LIMITS.environmentsMax).refine((v) => new Set(v).size === v.length, "unique");
|
|
1741
|
+
var selectorSchema = z12.object({
|
|
1742
|
+
signal: z12.enum(SIGNAL_KINDS),
|
|
1743
|
+
match: z12.array(selectorConditionSchema).max(SIGNAL_LIMITS.matchMax)
|
|
1573
1744
|
});
|
|
1574
1745
|
function toNumber(v) {
|
|
1575
1746
|
if (typeof v === "number")
|
|
@@ -1580,22 +1751,22 @@ function toNumber(v) {
|
|
|
1580
1751
|
}
|
|
1581
1752
|
return null;
|
|
1582
1753
|
}
|
|
1583
|
-
var minutes = (min, max) =>
|
|
1584
|
-
var threshold =
|
|
1585
|
-
var recovery =
|
|
1754
|
+
var minutes = (min, max) => z12.number().int().min(min).max(max);
|
|
1755
|
+
var threshold = z12.number().int().min(0).max(SIGNAL_LIMITS.thresholdMax);
|
|
1756
|
+
var recovery = z12.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax);
|
|
1586
1757
|
var common = {
|
|
1587
1758
|
environments: environmentListSchema,
|
|
1588
|
-
severity:
|
|
1759
|
+
severity: z12.enum(SEVERITIES),
|
|
1589
1760
|
recovery_threshold: recovery
|
|
1590
1761
|
};
|
|
1591
|
-
var countSettingsSchema =
|
|
1592
|
-
type:
|
|
1762
|
+
var countSettingsSchema = z12.object({
|
|
1763
|
+
type: z12.literal("count"),
|
|
1593
1764
|
selector: selectorSchema,
|
|
1594
1765
|
window_minutes: minutes(SIGNAL_LIMITS.windowMinutesMin, SIGNAL_LIMITS.windowMinutesMax),
|
|
1595
|
-
comparator:
|
|
1766
|
+
comparator: z12.enum(COMPARATORS),
|
|
1596
1767
|
threshold,
|
|
1597
1768
|
threshold_high: threshold.nullable(),
|
|
1598
|
-
missing_data:
|
|
1769
|
+
missing_data: z12.enum(MISSING_DATA_POLICIES),
|
|
1599
1770
|
...common
|
|
1600
1771
|
}).superRefine((s, ctx) => {
|
|
1601
1772
|
if (s.comparator === "outside" && (s.threshold_high === null || s.threshold_high <= s.threshold)) {
|
|
@@ -1608,31 +1779,48 @@ var countSettingsSchema = z11.object({
|
|
|
1608
1779
|
ctx.addIssue({ code: "custom", path: ["threshold"], message: "threshold" });
|
|
1609
1780
|
}
|
|
1610
1781
|
});
|
|
1611
|
-
var assertionSettingsSchema =
|
|
1612
|
-
type:
|
|
1782
|
+
var assertionSettingsSchema = z12.object({
|
|
1783
|
+
type: z12.literal("assertion"),
|
|
1613
1784
|
selector: selectorSchema,
|
|
1614
|
-
assert:
|
|
1785
|
+
assert: z12.array(selectorConditionSchema).min(1).max(SIGNAL_LIMITS.assertMax),
|
|
1615
1786
|
window_minutes: minutes(SIGNAL_LIMITS.windowMinutesMin, SIGNAL_LIMITS.windowMinutesMax),
|
|
1616
|
-
threshold:
|
|
1617
|
-
missing_data:
|
|
1787
|
+
threshold: z12.number().int().min(1).max(SIGNAL_LIMITS.thresholdMax),
|
|
1788
|
+
missing_data: z12.enum(MISSING_DATA_POLICIES),
|
|
1618
1789
|
...common
|
|
1619
1790
|
});
|
|
1620
|
-
var deadlineSettingsSchema =
|
|
1621
|
-
type:
|
|
1791
|
+
var deadlineSettingsSchema = z12.object({
|
|
1792
|
+
type: z12.literal("deadline"),
|
|
1622
1793
|
occurrence_grace_minutes: minutes(0, SIGNAL_LIMITS.graceMinutesMax),
|
|
1623
1794
|
progress_timeout_minutes: minutes(SIGNAL_LIMITS.progressMinutesMin, SIGNAL_LIMITS.progressMinutesMax).nullable(),
|
|
1624
1795
|
...common
|
|
1625
1796
|
});
|
|
1626
|
-
var progressSettingsSchema =
|
|
1627
|
-
type:
|
|
1797
|
+
var progressSettingsSchema = z12.object({
|
|
1798
|
+
type: z12.literal("progress"),
|
|
1628
1799
|
progress_timeout_minutes: minutes(SIGNAL_LIMITS.progressMinutesMin, SIGNAL_LIMITS.progressMinutesMax),
|
|
1629
1800
|
...common
|
|
1630
1801
|
});
|
|
1631
|
-
var
|
|
1802
|
+
var metricThreshold = z12.number().finite().min(-MONITOR_NUMBER_MAX).max(MONITOR_NUMBER_MAX);
|
|
1803
|
+
var metricSettingsSchema = z12.object({
|
|
1804
|
+
type: z12.literal("metric"),
|
|
1805
|
+
metric_query: metricQuerySchema,
|
|
1806
|
+
window_minutes: minutes(SIGNAL_LIMITS.windowMinutesMin, SIGNAL_LIMITS.windowMinutesMax),
|
|
1807
|
+
comparator: z12.enum(COMPARATORS),
|
|
1808
|
+
threshold: metricThreshold,
|
|
1809
|
+
threshold_high: metricThreshold.nullable(),
|
|
1810
|
+
missing_data: z12.enum(MISSING_DATA_POLICIES),
|
|
1811
|
+
...common
|
|
1812
|
+
}).superRefine((s, ctx) => {
|
|
1813
|
+
if (s.comparator === "outside" && (s.threshold_high === null || s.threshold_high <= s.threshold))
|
|
1814
|
+
ctx.addIssue({ code: "custom", path: ["threshold_high"], message: "threshold_high" });
|
|
1815
|
+
if (s.comparator !== "outside" && s.threshold_high !== null)
|
|
1816
|
+
ctx.addIssue({ code: "custom", path: ["threshold_high"], message: "threshold_high" });
|
|
1817
|
+
});
|
|
1818
|
+
var signalSettingsSchema = z12.discriminatedUnion("type", [
|
|
1632
1819
|
countSettingsSchema,
|
|
1633
1820
|
assertionSettingsSchema,
|
|
1634
1821
|
deadlineSettingsSchema,
|
|
1635
|
-
progressSettingsSchema
|
|
1822
|
+
progressSettingsSchema,
|
|
1823
|
+
metricSettingsSchema
|
|
1636
1824
|
]);
|
|
1637
1825
|
function settingsFromRow(row) {
|
|
1638
1826
|
if (!isSignalMonitorType(row.type) || !row.signal_settings || typeof row.signal_settings !== "object")
|
|
@@ -1646,76 +1834,76 @@ function settingsFromRow(row) {
|
|
|
1646
1834
|
});
|
|
1647
1835
|
return r.success ? r.data : null;
|
|
1648
1836
|
}
|
|
1649
|
-
var signalMonitorInputSchema =
|
|
1650
|
-
name:
|
|
1837
|
+
var signalMonitorInputSchema = z12.object({
|
|
1838
|
+
name: z12.string().trim().min(1).max(MONITOR_LIMITS.nameMax),
|
|
1651
1839
|
settings: signalSettingsSchema
|
|
1652
1840
|
});
|
|
1653
|
-
var signalMonitorDefinitionSchema =
|
|
1654
|
-
id:
|
|
1655
|
-
project_id:
|
|
1656
|
-
slug:
|
|
1841
|
+
var signalMonitorDefinitionSchema = z12.object({
|
|
1842
|
+
id: z12.guid(),
|
|
1843
|
+
project_id: z12.number().int().positive(),
|
|
1844
|
+
slug: z12.string().regex(SLUG_RE),
|
|
1657
1845
|
settings: signalSettingsSchema,
|
|
1658
|
-
paused_until:
|
|
1659
|
-
created_at:
|
|
1660
|
-
revision:
|
|
1846
|
+
paused_until: z12.string().datetime().nullable(),
|
|
1847
|
+
created_at: z12.string().datetime(),
|
|
1848
|
+
revision: z12.number().int().nonnegative()
|
|
1661
1849
|
});
|
|
1662
|
-
var signalLimitsConfigSchema =
|
|
1663
|
-
pending_occurrences_per_monitor:
|
|
1664
|
-
pending_occurrences_per_project:
|
|
1850
|
+
var signalLimitsConfigSchema = z12.object({
|
|
1851
|
+
pending_occurrences_per_monitor: z12.number().int().min(1).max(1e6),
|
|
1852
|
+
pending_occurrences_per_project: z12.number().int().min(1).max(1e7)
|
|
1665
1853
|
});
|
|
1666
1854
|
var OCCURRENCE_ID_RE = /^[A-Za-z0-9._:-]{1,128}$/;
|
|
1667
|
-
var occurrenceInputSchema =
|
|
1668
|
-
monitor_slug:
|
|
1669
|
-
occurrence_id:
|
|
1670
|
-
due_at:
|
|
1671
|
-
environment:
|
|
1855
|
+
var occurrenceInputSchema = z12.object({
|
|
1856
|
+
monitor_slug: z12.string().regex(SLUG_RE),
|
|
1857
|
+
occurrence_id: z12.string().regex(OCCURRENCE_ID_RE),
|
|
1858
|
+
due_at: z12.string().datetime({ offset: true }),
|
|
1859
|
+
environment: z12.string().trim().min(1).max(MONITOR_LIMITS.environmentMax).regex(/^[A-Za-z0-9._-]+$/).optional()
|
|
1672
1860
|
});
|
|
1673
1861
|
var occurrenceCancelSchema = occurrenceInputSchema.pick({ monitor_slug: true, occurrence_id: true, environment: true });
|
|
1674
1862
|
var OCCURRENCE_PAST_SKEW_MS = 5 * 60000;
|
|
1675
|
-
var occurrenceRowSchema =
|
|
1676
|
-
occurrence_id:
|
|
1677
|
-
environment:
|
|
1678
|
-
state:
|
|
1679
|
-
due_at:
|
|
1680
|
-
deadline_at:
|
|
1681
|
-
registered_at:
|
|
1682
|
-
started_at:
|
|
1683
|
-
last_signal_at:
|
|
1684
|
-
ended_at:
|
|
1685
|
-
stalled:
|
|
1863
|
+
var occurrenceRowSchema = z12.object({
|
|
1864
|
+
occurrence_id: z12.string().max(SIGNAL_LIMITS.occurrenceIdMax),
|
|
1865
|
+
environment: z12.string().max(MONITOR_LIMITS.environmentMax),
|
|
1866
|
+
state: z12.enum(OCCURRENCE_STATES),
|
|
1867
|
+
due_at: z12.string().datetime(),
|
|
1868
|
+
deadline_at: z12.string().datetime(),
|
|
1869
|
+
registered_at: z12.string().datetime(),
|
|
1870
|
+
started_at: z12.string().datetime().nullable(),
|
|
1871
|
+
last_signal_at: z12.string().datetime().nullable(),
|
|
1872
|
+
ended_at: z12.string().datetime().nullable(),
|
|
1873
|
+
stalled: z12.boolean()
|
|
1686
1874
|
});
|
|
1687
|
-
var occurrencesResponseSchema =
|
|
1688
|
-
occurrences:
|
|
1689
|
-
pending:
|
|
1690
|
-
next_due_at:
|
|
1691
|
-
next_cursor:
|
|
1692
|
-
refused_24h:
|
|
1875
|
+
var occurrencesResponseSchema = z12.object({
|
|
1876
|
+
occurrences: z12.array(occurrenceRowSchema).max(SIGNAL_LIMITS.occurrencesPageSize),
|
|
1877
|
+
pending: z12.number().int().nonnegative(),
|
|
1878
|
+
next_due_at: z12.string().datetime().nullable(),
|
|
1879
|
+
next_cursor: z12.string().max(64).nullable(),
|
|
1880
|
+
refused_24h: z12.number().int().nonnegative()
|
|
1693
1881
|
});
|
|
1694
|
-
var signalSeriesSchema =
|
|
1695
|
-
environment:
|
|
1696
|
-
buckets:
|
|
1697
|
-
counted_through:
|
|
1882
|
+
var signalSeriesSchema = z12.object({
|
|
1883
|
+
environment: z12.string().max(MONITOR_LIMITS.environmentMax),
|
|
1884
|
+
buckets: z12.array(z12.object({ minute: z12.string().datetime(), matched: z12.number().int().nonnegative(), violations: z12.number().int().nonnegative(), lossy: z12.boolean() })).max(1440),
|
|
1885
|
+
counted_through: z12.string().datetime().nullable()
|
|
1698
1886
|
});
|
|
1699
|
-
var signalResponseSchema =
|
|
1700
|
-
series:
|
|
1701
|
-
runs:
|
|
1702
|
-
run_id:
|
|
1703
|
-
environment:
|
|
1704
|
-
started_at:
|
|
1705
|
-
last_signal_at:
|
|
1706
|
-
stalled:
|
|
1887
|
+
var signalResponseSchema = z12.object({
|
|
1888
|
+
series: z12.array(signalSeriesSchema).max(SIGNAL_LIMITS.environmentsMax),
|
|
1889
|
+
runs: z12.array(z12.object({
|
|
1890
|
+
run_id: z12.string().max(SIGNAL_LIMITS.occurrenceIdMax),
|
|
1891
|
+
environment: z12.string().max(MONITOR_LIMITS.environmentMax),
|
|
1892
|
+
started_at: z12.string().datetime(),
|
|
1893
|
+
last_signal_at: z12.string().datetime(),
|
|
1894
|
+
stalled: z12.boolean()
|
|
1707
1895
|
})).max(SIGNAL_LIMITS.occurrencesPageSize)
|
|
1708
1896
|
});
|
|
1709
|
-
var backtestSettingsSchema =
|
|
1710
|
-
var backtestResponseSchema =
|
|
1711
|
-
alerts:
|
|
1712
|
-
windows:
|
|
1713
|
-
violated_windows:
|
|
1714
|
-
first_at:
|
|
1715
|
-
last_at:
|
|
1716
|
-
days:
|
|
1717
|
-
matched_total:
|
|
1718
|
-
violations_total:
|
|
1897
|
+
var backtestSettingsSchema = z12.union([countSettingsSchema, assertionSettingsSchema]);
|
|
1898
|
+
var backtestResponseSchema = z12.object({
|
|
1899
|
+
alerts: z12.number().int().nonnegative(),
|
|
1900
|
+
windows: z12.number().int().nonnegative(),
|
|
1901
|
+
violated_windows: z12.number().int().nonnegative(),
|
|
1902
|
+
first_at: z12.string().datetime().nullable(),
|
|
1903
|
+
last_at: z12.string().datetime().nullable(),
|
|
1904
|
+
days: z12.number().nonnegative(),
|
|
1905
|
+
matched_total: z12.number().int().nonnegative(),
|
|
1906
|
+
violations_total: z12.number().int().nonnegative()
|
|
1719
1907
|
});
|
|
1720
1908
|
|
|
1721
1909
|
// ../src/shared/contracts/notifications.ts
|
|
@@ -1730,24 +1918,24 @@ var NOTIFY_LIMITS = {
|
|
|
1730
1918
|
};
|
|
1731
1919
|
var HOLDABLE_SEVERITIES = ["medium", "low"];
|
|
1732
1920
|
var DIGEST_MODES = ["off", "hourly", "daily"];
|
|
1733
|
-
var timeOfDay2 =
|
|
1921
|
+
var timeOfDay2 = z13.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/);
|
|
1734
1922
|
var unique = (xs) => new Set(xs).size === xs.length;
|
|
1735
|
-
var quietHoursSchema =
|
|
1736
|
-
days:
|
|
1923
|
+
var quietHoursSchema = z13.object({
|
|
1924
|
+
days: z13.array(weekdaySchema).min(1).max(7).refine(unique),
|
|
1737
1925
|
start: timeOfDay2,
|
|
1738
1926
|
end: timeOfDay2
|
|
1739
1927
|
}).refine((q) => q.start !== q.end, { path: ["end"] });
|
|
1740
|
-
var policyInputSchema =
|
|
1741
|
-
name:
|
|
1742
|
-
timezone:
|
|
1928
|
+
var policyInputSchema = z13.object({
|
|
1929
|
+
name: z13.string().trim().min(1).max(NOTIFY_LIMITS.nameMax).regex(/^[^\p{Cc}]*$/u),
|
|
1930
|
+
timezone: z13.string().trim().min(1).max(64).refine(validTimeZone),
|
|
1743
1931
|
quietHours: quietHoursSchema.nullable(),
|
|
1744
|
-
quietSeverities:
|
|
1745
|
-
digest:
|
|
1932
|
+
quietSeverities: z13.array(z13.enum(HOLDABLE_SEVERITIES)).max(2).refine(unique),
|
|
1933
|
+
digest: z13.enum(DIGEST_MODES),
|
|
1746
1934
|
digestAt: timeOfDay2.nullable(),
|
|
1747
|
-
digestSeverities:
|
|
1748
|
-
fallback:
|
|
1749
|
-
escalateAfterMinutes:
|
|
1750
|
-
escalation:
|
|
1935
|
+
digestSeverities: z13.array(z13.enum(HOLDABLE_SEVERITIES)).max(2).refine(unique),
|
|
1936
|
+
fallback: z13.array(z13.guid()).max(NOTIFY_LIMITS.chainMax).refine(unique),
|
|
1937
|
+
escalateAfterMinutes: z13.number().int().min(NOTIFY_LIMITS.escalateMinutesMin).max(NOTIFY_LIMITS.escalateMinutesMax).nullable(),
|
|
1938
|
+
escalation: z13.array(z13.guid()).max(NOTIFY_LIMITS.chainMax).refine(unique)
|
|
1751
1939
|
}).superRefine((p, ctx) => {
|
|
1752
1940
|
if (p.digest === "daily" !== (p.digestAt !== null))
|
|
1753
1941
|
ctx.addIssue({ code: "custom", path: ["digestAt"], message: "digest_at" });
|
|
@@ -1759,46 +1947,46 @@ var HOUR = 60 * MIN;
|
|
|
1759
1947
|
var DAY = 24 * HOUR;
|
|
1760
1948
|
|
|
1761
1949
|
// ../src/shared/contracts/api-ops/incidents.ts
|
|
1762
|
-
var incidentOnly =
|
|
1763
|
-
var note2 =
|
|
1950
|
+
var incidentOnly = z14.object({ workspaceId: uuid, incidentId: uuid });
|
|
1951
|
+
var note2 = z14.string().trim().min(1).max(2000).regex(/^[^\u0000-\u0008\u000b\u000c\u000e-\u001f]*$/);
|
|
1764
1952
|
var INCIDENT_KINDS = ["monitor", "uptime", "slo", "issue"];
|
|
1765
1953
|
var INCIDENT_GROUP_BY = ["monitor", "project_env"];
|
|
1766
|
-
var incidentRuleInputSchema =
|
|
1767
|
-
name:
|
|
1768
|
-
isEnabled:
|
|
1769
|
-
position:
|
|
1770
|
-
projectIds:
|
|
1771
|
-
environments:
|
|
1772
|
-
kinds:
|
|
1773
|
-
minSeverity:
|
|
1774
|
-
groupBy:
|
|
1775
|
-
windowMinutes:
|
|
1776
|
-
recoveryHoldMinutes:
|
|
1954
|
+
var incidentRuleInputSchema = z14.object({
|
|
1955
|
+
name: z14.string().trim().min(1).max(80).regex(/^[^\p{Cc}]*$/u),
|
|
1956
|
+
isEnabled: z14.boolean(),
|
|
1957
|
+
position: z14.number().int().min(0).max(1000).default(0),
|
|
1958
|
+
projectIds: z14.array(z14.number().int().positive()).max(50),
|
|
1959
|
+
environments: z14.array(z14.string().trim().min(1).max(64)).max(20),
|
|
1960
|
+
kinds: z14.array(z14.enum(INCIDENT_KINDS)).min(1).max(4),
|
|
1961
|
+
minSeverity: z14.enum(SEVERITIES),
|
|
1962
|
+
groupBy: z14.enum(INCIDENT_GROUP_BY),
|
|
1963
|
+
windowMinutes: z14.number().int().min(5).max(240),
|
|
1964
|
+
recoveryHoldMinutes: z14.number().int().min(0).max(1440)
|
|
1777
1965
|
});
|
|
1778
1966
|
var INCIDENT_INPUTS = {
|
|
1779
|
-
list:
|
|
1967
|
+
list: z14.object({
|
|
1780
1968
|
workspaceId: uuid,
|
|
1781
1969
|
limit: pageLimit,
|
|
1782
1970
|
cursor,
|
|
1783
|
-
state:
|
|
1971
|
+
state: z14.enum(["active", "resolved", "all"]).default("all")
|
|
1784
1972
|
}),
|
|
1785
1973
|
incidentOnly,
|
|
1786
1974
|
resolve: incidentOnly.extend({ note: note2.max(500) }),
|
|
1787
1975
|
note: incidentOnly.extend({ note: note2 }),
|
|
1788
1976
|
update: incidentOnly.extend({
|
|
1789
|
-
title:
|
|
1977
|
+
title: z14.string().trim().min(1).max(120).regex(/^[^\p{Cc}]*$/u).optional(),
|
|
1790
1978
|
ownerUserId: uuid.nullable().optional()
|
|
1791
1979
|
}),
|
|
1792
|
-
workspace:
|
|
1793
|
-
saveRule:
|
|
1794
|
-
ruleOnly:
|
|
1795
|
-
savePolicy:
|
|
1980
|
+
workspace: z14.object({ workspaceId: uuid }),
|
|
1981
|
+
saveRule: z14.object({ workspaceId: uuid, ruleId: uuid.nullable(), input: incidentRuleInputSchema }),
|
|
1982
|
+
ruleOnly: z14.object({ workspaceId: uuid, ruleId: uuid }),
|
|
1983
|
+
savePolicy: z14.object({
|
|
1796
1984
|
workspaceId: uuid,
|
|
1797
1985
|
policyId: uuid.nullable(),
|
|
1798
|
-
isDefault:
|
|
1986
|
+
isDefault: z14.boolean(),
|
|
1799
1987
|
input: policyInputSchema
|
|
1800
1988
|
}),
|
|
1801
|
-
policyOnly:
|
|
1989
|
+
policyOnly: z14.object({ workspaceId: uuid, policyId: uuid })
|
|
1802
1990
|
};
|
|
1803
1991
|
var I = INCIDENT_INPUTS;
|
|
1804
1992
|
var w = "incidents:write";
|
|
@@ -1987,20 +2175,20 @@ var INCIDENT_OPERATIONS = [
|
|
|
1987
2175
|
];
|
|
1988
2176
|
|
|
1989
2177
|
// ../src/shared/contracts/api-ops/monitors.ts
|
|
1990
|
-
import { z as
|
|
2178
|
+
import { z as z19 } from "zod";
|
|
1991
2179
|
|
|
1992
2180
|
// ../src/shared/contracts/heartbeat.ts
|
|
1993
|
-
import { z as
|
|
2181
|
+
import { z as z16 } from "zod";
|
|
1994
2182
|
|
|
1995
2183
|
// ../src/shared/contracts/signed-message.ts
|
|
1996
|
-
import { z as
|
|
1997
|
-
var nodeIdSchema =
|
|
1998
|
-
var signedEnvelopeSchema =
|
|
2184
|
+
import { z as z15 } from "zod";
|
|
2185
|
+
var nodeIdSchema = z15.guid();
|
|
2186
|
+
var signedEnvelopeSchema = z15.object({
|
|
1999
2187
|
node_id: nodeIdSchema,
|
|
2000
|
-
ts:
|
|
2001
|
-
nonce:
|
|
2002
|
-
payload:
|
|
2003
|
-
sig:
|
|
2188
|
+
ts: z15.number().int().positive(),
|
|
2189
|
+
nonce: z15.string().regex(/^[A-Za-z0-9_-]{16,64}$/),
|
|
2190
|
+
payload: z15.record(z15.string(), z15.unknown()),
|
|
2191
|
+
sig: z15.string().regex(/^[A-Za-z0-9_-]{86}$/)
|
|
2004
2192
|
});
|
|
2005
2193
|
|
|
2006
2194
|
// ../src/shared/contracts/heartbeat.ts
|
|
@@ -2038,78 +2226,78 @@ var HEARTBEAT_LIMITS = {
|
|
|
2038
2226
|
diagnosticsPerRun: 5
|
|
2039
2227
|
};
|
|
2040
2228
|
var PAUSED_FOREVER_MS = Date.parse("9999-12-31T00:00:00.000Z");
|
|
2041
|
-
var uuid2 =
|
|
2042
|
-
var ms =
|
|
2043
|
-
var hex64 =
|
|
2044
|
-
var envName2 =
|
|
2045
|
-
var heartbeatMonitorConfigSchema =
|
|
2229
|
+
var uuid2 = z16.guid();
|
|
2230
|
+
var ms = z16.number().int().nonnegative();
|
|
2231
|
+
var hex64 = z16.string().regex(/^[0-9a-f]{64}$/);
|
|
2232
|
+
var envName2 = z16.string().min(1).max(MONITOR_LIMITS.environmentMax);
|
|
2233
|
+
var heartbeatMonitorConfigSchema = z16.object({
|
|
2046
2234
|
id: uuid2,
|
|
2047
|
-
project_id:
|
|
2048
|
-
slug:
|
|
2235
|
+
project_id: z16.number().int().positive(),
|
|
2236
|
+
slug: z16.string().regex(SLUG_RE),
|
|
2049
2237
|
environment: envName2,
|
|
2050
2238
|
schedule: scheduleSchema,
|
|
2051
|
-
timezone:
|
|
2052
|
-
grace_min:
|
|
2053
|
-
max_runtime_min:
|
|
2054
|
-
failure_threshold:
|
|
2055
|
-
recovery_threshold:
|
|
2239
|
+
timezone: z16.string().min(1).max(64),
|
|
2240
|
+
grace_min: z16.number().int().min(MONITOR_LIMITS.checkinMarginMin).max(MONITOR_LIMITS.checkinMarginMax),
|
|
2241
|
+
max_runtime_min: z16.number().int().min(MONITOR_LIMITS.maxRuntimeMin).max(MONITOR_LIMITS.maxRuntimeMax),
|
|
2242
|
+
failure_threshold: z16.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax),
|
|
2243
|
+
recovery_threshold: z16.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax),
|
|
2056
2244
|
paused_until: ms.nullable(),
|
|
2057
2245
|
created_at: ms
|
|
2058
2246
|
});
|
|
2059
|
-
var heartbeatTokenConfigSchema =
|
|
2247
|
+
var heartbeatTokenConfigSchema = z16.object({
|
|
2060
2248
|
id: uuid2,
|
|
2061
2249
|
monitor_id: uuid2,
|
|
2062
2250
|
hash: hex64,
|
|
2063
2251
|
expires_at: ms.nullable()
|
|
2064
2252
|
});
|
|
2065
|
-
var heartbeatSyncSchema =
|
|
2066
|
-
v:
|
|
2253
|
+
var heartbeatSyncSchema = z16.object({
|
|
2254
|
+
v: z16.literal(1),
|
|
2067
2255
|
workspace_id: uuid2,
|
|
2068
|
-
route:
|
|
2069
|
-
revision:
|
|
2070
|
-
workspace_status:
|
|
2071
|
-
ingest_kill:
|
|
2072
|
-
limits:
|
|
2073
|
-
check_in_rate_per_sec:
|
|
2074
|
-
check_in_burst:
|
|
2075
|
-
monthly_check_in_cap:
|
|
2076
|
-
}),
|
|
2077
|
-
projects:
|
|
2078
|
-
monitors:
|
|
2079
|
-
tokens:
|
|
2256
|
+
route: z16.string().regex(PING_ROUTE_RE),
|
|
2257
|
+
revision: z16.number().int().positive(),
|
|
2258
|
+
workspace_status: z16.enum(["active", "suspended", "deleting"]),
|
|
2259
|
+
ingest_kill: z16.boolean(),
|
|
2260
|
+
limits: z16.object({
|
|
2261
|
+
check_in_rate_per_sec: z16.number().int().positive(),
|
|
2262
|
+
check_in_burst: z16.number().int().positive(),
|
|
2263
|
+
monthly_check_in_cap: z16.number().int().positive()
|
|
2264
|
+
}),
|
|
2265
|
+
projects: z16.array(z16.object({ id: z16.number().int().positive(), node_id: nodeIdSchema.nullable() })).max(1000),
|
|
2266
|
+
monitors: z16.array(heartbeatMonitorConfigSchema).max(HEARTBEAT_LIMITS.maxMonitorsPerWorkspace),
|
|
2267
|
+
tokens: z16.array(heartbeatTokenConfigSchema).max(HEARTBEAT_LIMITS.maxMonitorsPerWorkspace * 2)
|
|
2080
2268
|
});
|
|
2081
|
-
var signedHeartbeatSyncSchema =
|
|
2082
|
-
body:
|
|
2083
|
-
ts:
|
|
2084
|
-
kid:
|
|
2085
|
-
sig:
|
|
2269
|
+
var signedHeartbeatSyncSchema = z16.object({
|
|
2270
|
+
body: z16.string().min(2).max(4 * 1024 * 1024),
|
|
2271
|
+
ts: z16.number().int().positive(),
|
|
2272
|
+
kid: z16.string().regex(/^[A-Za-z0-9_-]{1,40}$/),
|
|
2273
|
+
sig: z16.string().regex(/^[A-Za-z0-9_-]{86}$/)
|
|
2086
2274
|
});
|
|
2087
|
-
var heartbeatHourSchema =
|
|
2275
|
+
var heartbeatHourSchema = z16.object({
|
|
2088
2276
|
monitor_id: uuid2,
|
|
2089
|
-
hour:
|
|
2090
|
-
ok:
|
|
2091
|
-
failed:
|
|
2092
|
-
started:
|
|
2093
|
-
missed:
|
|
2094
|
-
logs:
|
|
2277
|
+
hour: z16.string().datetime(),
|
|
2278
|
+
ok: z16.number().int().nonnegative(),
|
|
2279
|
+
failed: z16.number().int().nonnegative(),
|
|
2280
|
+
started: z16.number().int().nonnegative(),
|
|
2281
|
+
missed: z16.number().int().nonnegative(),
|
|
2282
|
+
logs: z16.number().int().nonnegative()
|
|
2095
2283
|
});
|
|
2096
|
-
var heartbeatReportSchema =
|
|
2097
|
-
v:
|
|
2284
|
+
var heartbeatReportSchema = z16.object({
|
|
2285
|
+
v: z16.literal(1),
|
|
2098
2286
|
workspace_id: uuid2,
|
|
2099
|
-
route:
|
|
2100
|
-
revision:
|
|
2101
|
-
sent_at:
|
|
2102
|
-
incidents:
|
|
2103
|
-
statuses:
|
|
2104
|
-
hours:
|
|
2105
|
-
token_uses:
|
|
2287
|
+
route: z16.string().regex(PING_ROUTE_RE),
|
|
2288
|
+
revision: z16.number().int().nonnegative(),
|
|
2289
|
+
sent_at: z16.string().datetime(),
|
|
2290
|
+
incidents: z16.array(monitorIncidentSchema).max(HEARTBEAT_LIMITS.reportMaxIncidents),
|
|
2291
|
+
statuses: z16.array(monitorStatusSchema).max(HEARTBEAT_LIMITS.reportMaxStatuses),
|
|
2292
|
+
hours: z16.array(heartbeatHourSchema).max(HEARTBEAT_LIMITS.reportMaxHours),
|
|
2293
|
+
token_uses: z16.array(z16.object({ token_id: uuid2, last_used_at: z16.string().datetime() })).max(HEARTBEAT_LIMITS.maxMonitorsPerWorkspace * 2)
|
|
2106
2294
|
});
|
|
2107
2295
|
var ENCODER = new TextEncoder;
|
|
2108
2296
|
var UTF8 = new TextDecoder("utf-8", { fatal: false, ignoreBOM: false });
|
|
2109
2297
|
var TOKEN_IN_TEXT = new RegExp(PING_TOKEN_PATTERN, "g");
|
|
2110
2298
|
|
|
2111
2299
|
// ../src/shared/contracts/slo.ts
|
|
2112
|
-
import { z as
|
|
2300
|
+
import { z as z17 } from "zod";
|
|
2113
2301
|
|
|
2114
2302
|
// ../src/shared/contracts/vocab/slo.ts
|
|
2115
2303
|
var SLO_SOURCES = ["uptime", "monitor", "heartbeat", "spans"];
|
|
@@ -2141,17 +2329,17 @@ var SLO_SOURCE_META = {
|
|
|
2141
2329
|
heartbeat: { provenance: "ping_token", estimated: false, slis: ["availability"], budgeting: "Occurrences" },
|
|
2142
2330
|
spans: { provenance: "ingest_key", estimated: true, slis: ["availability", "latency"], budgeting: "Occurrences" }
|
|
2143
2331
|
};
|
|
2144
|
-
var nodeSloSchema =
|
|
2145
|
-
slo_id:
|
|
2146
|
-
project_id:
|
|
2147
|
-
source:
|
|
2148
|
-
sli:
|
|
2149
|
-
monitor_id:
|
|
2150
|
-
environment:
|
|
2151
|
-
service:
|
|
2152
|
-
operation:
|
|
2153
|
-
latency_threshold_ms:
|
|
2154
|
-
public_sources:
|
|
2332
|
+
var nodeSloSchema = z17.object({
|
|
2333
|
+
slo_id: z17.guid(),
|
|
2334
|
+
project_id: z17.number().int().positive(),
|
|
2335
|
+
source: z17.enum(["monitor", "spans"]),
|
|
2336
|
+
sli: z17.enum(SLO_SLIS),
|
|
2337
|
+
monitor_id: z17.guid().optional(),
|
|
2338
|
+
environment: z17.string().min(1).max(SLO_LIMITS.environmentMaxChars).optional(),
|
|
2339
|
+
service: z17.string().min(1).max(128).optional(),
|
|
2340
|
+
operation: z17.string().min(1).max(256).optional(),
|
|
2341
|
+
latency_threshold_ms: z17.number().int().min(1).max(60000).optional(),
|
|
2342
|
+
public_sources: z17.boolean()
|
|
2155
2343
|
}).superRefine((v, ctx) => {
|
|
2156
2344
|
if (v.source === "monitor" && (!v.monitor_id || v.sli !== "availability"))
|
|
2157
2345
|
ctx.addIssue({ code: "custom", path: ["monitor_id"], message: "INVALID_INPUT" });
|
|
@@ -2160,27 +2348,27 @@ var nodeSloSchema = z16.object({
|
|
|
2160
2348
|
if (v.sli === "latency" !== (v.latency_threshold_ms !== undefined))
|
|
2161
2349
|
ctx.addIssue({ code: "custom", path: ["latency_threshold_ms"], message: "INVALID_INPUT" });
|
|
2162
2350
|
});
|
|
2163
|
-
var sliCountsSchema =
|
|
2164
|
-
minute:
|
|
2165
|
-
items:
|
|
2351
|
+
var sliCountsSchema = z17.object({
|
|
2352
|
+
minute: z17.string().datetime(),
|
|
2353
|
+
items: z17.array(z17.object({ slo_id: z17.guid(), good: z17.number().int().min(0), total: z17.number().int().min(0) }).refine((x) => x.good <= x.total, { message: "INVALID_INPUT" })).max(SLO_LIMITS.sliItemsPerMessage)
|
|
2166
2354
|
});
|
|
2167
|
-
var sloInputSchema =
|
|
2168
|
-
name:
|
|
2169
|
-
description:
|
|
2170
|
-
source:
|
|
2171
|
-
sourceRef:
|
|
2172
|
-
id:
|
|
2173
|
-
projectId:
|
|
2174
|
-
service:
|
|
2175
|
-
operation:
|
|
2176
|
-
environment:
|
|
2177
|
-
}),
|
|
2178
|
-
sli:
|
|
2179
|
-
latencyThresholdMs:
|
|
2180
|
-
objective:
|
|
2181
|
-
windowDays:
|
|
2182
|
-
alertPolicy:
|
|
2183
|
-
allowPublicSources:
|
|
2355
|
+
var sloInputSchema = z17.object({
|
|
2356
|
+
name: z17.string().trim().min(1).max(SLO_LIMITS.nameMaxChars),
|
|
2357
|
+
description: z17.string().max(SLO_LIMITS.descriptionMaxChars).default(""),
|
|
2358
|
+
source: z17.enum(SLO_SOURCES),
|
|
2359
|
+
sourceRef: z17.object({
|
|
2360
|
+
id: z17.guid().optional(),
|
|
2361
|
+
projectId: z17.number().int().positive().optional(),
|
|
2362
|
+
service: z17.string().max(128).optional(),
|
|
2363
|
+
operation: z17.string().max(256).optional(),
|
|
2364
|
+
environment: z17.string().max(SLO_LIMITS.environmentMaxChars).optional()
|
|
2365
|
+
}),
|
|
2366
|
+
sli: z17.enum(SLO_SLIS),
|
|
2367
|
+
latencyThresholdMs: z17.number().int().min(1).max(60000).nullable(),
|
|
2368
|
+
objective: z17.number().min(SLO_LIMITS.objectiveMin).max(SLO_LIMITS.objectiveMax),
|
|
2369
|
+
windowDays: z17.union([z17.literal(7), z17.literal(28), z17.literal(30)]),
|
|
2370
|
+
alertPolicy: z17.enum(SLO_ALERT_POLICIES),
|
|
2371
|
+
allowPublicSources: z17.boolean().default(false)
|
|
2184
2372
|
}).superRefine((v, ctx) => {
|
|
2185
2373
|
if (!SLO_SOURCE_META[v.source].slis.includes(v.sli))
|
|
2186
2374
|
ctx.addIssue({ code: "custom", path: ["sli"], message: "INVALID_INPUT" });
|
|
@@ -2195,7 +2383,7 @@ var sloInputSchema = z16.object({
|
|
|
2195
2383
|
});
|
|
2196
2384
|
|
|
2197
2385
|
// ../src/shared/contracts/uptime.ts
|
|
2198
|
-
import { z as
|
|
2386
|
+
import { z as z18 } from "zod";
|
|
2199
2387
|
|
|
2200
2388
|
// ../src/shared/contracts/vocab/uptime.ts
|
|
2201
2389
|
var UPTIME_STATUSES = ["up", "degraded", "down", "unknown", "paused", "pending"];
|
|
@@ -2268,51 +2456,51 @@ function isForbiddenHeader(name) {
|
|
|
2268
2456
|
const n = name.trim().toLowerCase();
|
|
2269
2457
|
return UPTIME_FORBIDDEN_HEADERS.includes(n) || n.startsWith("proxy-") || n.startsWith("sec-");
|
|
2270
2458
|
}
|
|
2271
|
-
var text =
|
|
2272
|
-
var statusRange =
|
|
2273
|
-
var assertionSchema =
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
type:
|
|
2279
|
-
pointer:
|
|
2280
|
-
op:
|
|
2281
|
-
value:
|
|
2282
|
-
}),
|
|
2283
|
-
|
|
2284
|
-
type:
|
|
2285
|
-
name:
|
|
2286
|
-
op:
|
|
2287
|
-
value:
|
|
2288
|
-
}),
|
|
2289
|
-
|
|
2290
|
-
|
|
2459
|
+
var text = z18.string().min(1).max(UPTIME_LIMITS.assertionTextMax);
|
|
2460
|
+
var statusRange = z18.string().regex(/^[1-5][0-9]{2}(-[1-5][0-9]{2})?$/);
|
|
2461
|
+
var assertionSchema = z18.discriminatedUnion("type", [
|
|
2462
|
+
z18.object({ type: z18.literal("status"), in: z18.array(statusRange).min(1).max(10) }),
|
|
2463
|
+
z18.object({ type: z18.literal("body_contains"), value: text, case_sensitive: z18.boolean().default(true) }),
|
|
2464
|
+
z18.object({ type: z18.literal("body_not_contains"), value: text, case_sensitive: z18.boolean().default(true) }),
|
|
2465
|
+
z18.object({
|
|
2466
|
+
type: z18.literal("json_pointer"),
|
|
2467
|
+
pointer: z18.string().max(256).regex(/^(\/([^~/]|~0|~1)*)*$/),
|
|
2468
|
+
op: z18.enum(["exists", "equals", "type"]),
|
|
2469
|
+
value: z18.string().max(UPTIME_LIMITS.assertionTextMax).optional()
|
|
2470
|
+
}),
|
|
2471
|
+
z18.object({
|
|
2472
|
+
type: z18.literal("header"),
|
|
2473
|
+
name: z18.string().min(1).max(UPTIME_LIMITS.headerNameMax).regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/),
|
|
2474
|
+
op: z18.enum(["equals", "contains", "exists"]),
|
|
2475
|
+
value: z18.string().max(UPTIME_LIMITS.assertionTextMax).optional()
|
|
2476
|
+
}),
|
|
2477
|
+
z18.object({ type: z18.literal("latency_ms"), lt: z18.number().int().min(1).max(60000) }),
|
|
2478
|
+
z18.object({ type: z18.literal("tls_valid") })
|
|
2291
2479
|
]);
|
|
2292
|
-
var header =
|
|
2293
|
-
name:
|
|
2294
|
-
value:
|
|
2480
|
+
var header = z18.object({
|
|
2481
|
+
name: z18.string().min(1).max(UPTIME_LIMITS.headerNameMax).regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/),
|
|
2482
|
+
value: z18.string().max(UPTIME_LIMITS.headerValueMax).regex(/^[^\r\n\u0000]*$/)
|
|
2295
2483
|
});
|
|
2296
|
-
var uptimeCheckInputSchema =
|
|
2297
|
-
projectId:
|
|
2298
|
-
name:
|
|
2299
|
-
kind:
|
|
2300
|
-
url:
|
|
2301
|
-
host:
|
|
2302
|
-
port:
|
|
2303
|
-
method:
|
|
2304
|
-
headers:
|
|
2305
|
-
followRedirects:
|
|
2306
|
-
timeoutMs:
|
|
2307
|
-
intervalSeconds:
|
|
2308
|
-
regions:
|
|
2309
|
-
assertions:
|
|
2310
|
-
failureThreshold:
|
|
2311
|
-
recoveryThreshold:
|
|
2312
|
-
certWarningDays:
|
|
2313
|
-
environment:
|
|
2314
|
-
strictMetadata:
|
|
2315
|
-
evidenceOnFailure:
|
|
2484
|
+
var uptimeCheckInputSchema = z18.object({
|
|
2485
|
+
projectId: z18.number().int().positive(),
|
|
2486
|
+
name: z18.string().trim().min(1).max(UPTIME_LIMITS.nameMaxChars),
|
|
2487
|
+
kind: z18.enum(UPTIME_KINDS),
|
|
2488
|
+
url: z18.string().max(UPTIME_LIMITS.urlMaxChars).nullable(),
|
|
2489
|
+
host: z18.string().max(253).nullable(),
|
|
2490
|
+
port: z18.number().int().min(1).max(65535).nullable(),
|
|
2491
|
+
method: z18.enum(UPTIME_METHODS).default("GET"),
|
|
2492
|
+
headers: z18.array(header).max(UPTIME_LIMITS.headersMax).default([]),
|
|
2493
|
+
followRedirects: z18.boolean().default(false),
|
|
2494
|
+
timeoutMs: z18.number().int().min(UPTIME_LIMITS.timeoutMs.min).max(UPTIME_LIMITS.timeoutMs.max),
|
|
2495
|
+
intervalSeconds: z18.number().int().refine((n) => UPTIME_INTERVALS.includes(n)),
|
|
2496
|
+
regions: z18.array(z18.enum(UPTIME_REGIONS)).min(UPTIME_LIMITS.minRegions).max(UPTIME_REGIONS.length),
|
|
2497
|
+
assertions: z18.array(assertionSchema).max(UPTIME_LIMITS.assertionsMax).default([]),
|
|
2498
|
+
failureThreshold: z18.number().int().min(1).max(5),
|
|
2499
|
+
recoveryThreshold: z18.number().int().min(1).max(5),
|
|
2500
|
+
certWarningDays: z18.number().int().min(1).max(60),
|
|
2501
|
+
environment: z18.string().trim().max(64).default(""),
|
|
2502
|
+
strictMetadata: z18.boolean().default(false),
|
|
2503
|
+
evidenceOnFailure: z18.boolean().default(true)
|
|
2316
2504
|
}).superRefine((v, ctx) => {
|
|
2317
2505
|
if (v.kind === "http" && !v.url)
|
|
2318
2506
|
ctx.addIssue({ code: "custom", path: ["url"], message: "INVALID_INPUT" });
|
|
@@ -2323,243 +2511,243 @@ var uptimeCheckInputSchema = z17.object({
|
|
|
2323
2511
|
if (v.headers.some((h) => isForbiddenHeader(h.name)))
|
|
2324
2512
|
ctx.addIssue({ code: "custom", path: ["headers"], message: "UPTIME_HEADER_FORBIDDEN" });
|
|
2325
2513
|
});
|
|
2326
|
-
var uptimeDefinitionSchema =
|
|
2327
|
-
check_id:
|
|
2328
|
-
workspace_id:
|
|
2329
|
-
project_id:
|
|
2330
|
-
revision:
|
|
2331
|
-
kind:
|
|
2332
|
-
url:
|
|
2333
|
-
host:
|
|
2334
|
-
port:
|
|
2335
|
-
method:
|
|
2336
|
-
headers:
|
|
2337
|
-
follow_redirects:
|
|
2338
|
-
timeout_ms:
|
|
2339
|
-
interval_seconds:
|
|
2340
|
-
regions:
|
|
2341
|
-
assertions:
|
|
2342
|
-
failure_threshold:
|
|
2343
|
-
recovery_threshold:
|
|
2344
|
-
cert_warning_days:
|
|
2345
|
-
strict_metadata:
|
|
2346
|
-
evidence_on_failure:
|
|
2347
|
-
paused_until:
|
|
2348
|
-
muted_until:
|
|
2514
|
+
var uptimeDefinitionSchema = z18.object({
|
|
2515
|
+
check_id: z18.guid(),
|
|
2516
|
+
workspace_id: z18.guid(),
|
|
2517
|
+
project_id: z18.number().int().positive(),
|
|
2518
|
+
revision: z18.number().int().nonnegative(),
|
|
2519
|
+
kind: z18.enum(UPTIME_KINDS),
|
|
2520
|
+
url: z18.string().max(UPTIME_LIMITS.urlMaxChars).nullable(),
|
|
2521
|
+
host: z18.string().max(253).nullable(),
|
|
2522
|
+
port: z18.number().int().min(1).max(65535).nullable(),
|
|
2523
|
+
method: z18.enum(UPTIME_METHODS),
|
|
2524
|
+
headers: z18.array(header).max(UPTIME_LIMITS.headersMax),
|
|
2525
|
+
follow_redirects: z18.boolean(),
|
|
2526
|
+
timeout_ms: z18.number().int().min(UPTIME_LIMITS.timeoutMs.min).max(UPTIME_LIMITS.timeoutMs.max),
|
|
2527
|
+
interval_seconds: z18.number().int().positive(),
|
|
2528
|
+
regions: z18.array(z18.enum(UPTIME_REGIONS)).min(1).max(3),
|
|
2529
|
+
assertions: z18.array(assertionSchema).max(UPTIME_LIMITS.assertionsMax),
|
|
2530
|
+
failure_threshold: z18.number().int().min(1).max(5),
|
|
2531
|
+
recovery_threshold: z18.number().int().min(1).max(5),
|
|
2532
|
+
cert_warning_days: z18.number().int().min(1).max(60),
|
|
2533
|
+
strict_metadata: z18.boolean(),
|
|
2534
|
+
evidence_on_failure: z18.boolean(),
|
|
2535
|
+
paused_until: z18.string().nullable(),
|
|
2536
|
+
muted_until: z18.string().nullable()
|
|
2349
2537
|
});
|
|
2350
|
-
var timingsSchema =
|
|
2351
|
-
dns_ms:
|
|
2352
|
-
connect_ms:
|
|
2353
|
-
tls_ms:
|
|
2354
|
-
ttfb_ms:
|
|
2355
|
-
download_ms:
|
|
2356
|
-
total_ms:
|
|
2538
|
+
var timingsSchema = z18.object({
|
|
2539
|
+
dns_ms: z18.number().nonnegative().max(60000).nullable(),
|
|
2540
|
+
connect_ms: z18.number().nonnegative().max(60000).nullable(),
|
|
2541
|
+
tls_ms: z18.number().nonnegative().max(60000).nullable(),
|
|
2542
|
+
ttfb_ms: z18.number().nonnegative().max(60000).nullable(),
|
|
2543
|
+
download_ms: z18.number().nonnegative().max(60000).nullable(),
|
|
2544
|
+
total_ms: z18.number().nonnegative().max(60000)
|
|
2357
2545
|
});
|
|
2358
|
-
var probeResultSchema =
|
|
2359
|
-
check_id:
|
|
2360
|
-
revision:
|
|
2361
|
-
slot:
|
|
2362
|
-
region:
|
|
2363
|
-
run_now:
|
|
2364
|
-
scheduled_at:
|
|
2365
|
-
started_at:
|
|
2366
|
-
outcome:
|
|
2367
|
-
reason:
|
|
2368
|
-
reason_group:
|
|
2369
|
-
status_code:
|
|
2546
|
+
var probeResultSchema = z18.object({
|
|
2547
|
+
check_id: z18.guid(),
|
|
2548
|
+
revision: z18.number().int().nonnegative(),
|
|
2549
|
+
slot: z18.number().int().nonnegative(),
|
|
2550
|
+
region: z18.enum(UPTIME_REGIONS),
|
|
2551
|
+
run_now: z18.string().max(64).optional(),
|
|
2552
|
+
scheduled_at: z18.number().int().positive(),
|
|
2553
|
+
started_at: z18.number().int().positive(),
|
|
2554
|
+
outcome: z18.enum(UPTIME_OUTCOMES),
|
|
2555
|
+
reason: z18.enum(UPTIME_REASONS).nullable(),
|
|
2556
|
+
reason_group: z18.enum(UPTIME_REASON_GROUPS).nullable(),
|
|
2557
|
+
status_code: z18.number().int().min(100).max(599).nullable(),
|
|
2370
2558
|
timings: timingsSchema.nullable(),
|
|
2371
|
-
ip_family:
|
|
2372
|
-
http_version:
|
|
2373
|
-
cert_not_after:
|
|
2374
|
-
cert_issuer:
|
|
2375
|
-
cert_expiring:
|
|
2376
|
-
evidence_sealed:
|
|
2559
|
+
ip_family: z18.enum(["v4", "v6"]).nullable(),
|
|
2560
|
+
http_version: z18.string().max(8).nullable(),
|
|
2561
|
+
cert_not_after: z18.number().int().positive().nullable(),
|
|
2562
|
+
cert_issuer: z18.string().max(200).nullable(),
|
|
2563
|
+
cert_expiring: z18.boolean(),
|
|
2564
|
+
evidence_sealed: z18.string().max(16384).nullable()
|
|
2377
2565
|
});
|
|
2378
|
-
var probeIdSchema =
|
|
2379
|
-
var resultBatchSchema =
|
|
2380
|
-
v:
|
|
2566
|
+
var probeIdSchema = z18.string().regex(/^probe-(eu|us|ap)-[a-z0-9]{4,16}$/);
|
|
2567
|
+
var resultBatchSchema = z18.object({
|
|
2568
|
+
v: z18.literal(1),
|
|
2381
2569
|
probe_id: probeIdSchema,
|
|
2382
|
-
region:
|
|
2383
|
-
version:
|
|
2384
|
-
sent_at:
|
|
2385
|
-
results:
|
|
2386
|
-
stats:
|
|
2570
|
+
region: z18.enum(UPTIME_REGIONS),
|
|
2571
|
+
version: z18.string().max(40),
|
|
2572
|
+
sent_at: z18.number().int().positive(),
|
|
2573
|
+
results: z18.array(probeResultSchema).max(UPTIME_LIMITS.resultsBatchMax),
|
|
2574
|
+
stats: z18.object({ lag_p99_ms: z18.number().nonnegative(), checks_per_min: z18.number().nonnegative() })
|
|
2387
2575
|
});
|
|
2388
2576
|
var assignmentSchema = uptimeDefinitionSchema.omit({ workspace_id: true, paused_until: true, muted_until: true }).extend({
|
|
2389
|
-
seal_public_key:
|
|
2577
|
+
seal_public_key: z18.string().regex(/^[A-Za-z0-9_-]{43}$/).nullable()
|
|
2390
2578
|
});
|
|
2391
|
-
var assignmentsSchema =
|
|
2392
|
-
v:
|
|
2393
|
-
region:
|
|
2394
|
-
revision:
|
|
2395
|
-
issued_at:
|
|
2396
|
-
checks:
|
|
2397
|
-
denied_hosts:
|
|
2398
|
-
run_now:
|
|
2579
|
+
var assignmentsSchema = z18.object({
|
|
2580
|
+
v: z18.literal(1),
|
|
2581
|
+
region: z18.enum(UPTIME_REGIONS),
|
|
2582
|
+
revision: z18.number().int().nonnegative(),
|
|
2583
|
+
issued_at: z18.number().int().positive(),
|
|
2584
|
+
checks: z18.array(assignmentSchema).max(50000),
|
|
2585
|
+
denied_hosts: z18.array(z18.string().max(253)).max(1e4),
|
|
2586
|
+
run_now: z18.array(z18.object({ id: z18.string().max(64), check_id: z18.guid(), expires_at: z18.number().int() })).max(500)
|
|
2399
2587
|
});
|
|
2400
|
-
var uuid3 =
|
|
2401
|
-
var b64key =
|
|
2402
|
-
var iso4 =
|
|
2403
|
-
var uptimeSyncSchema =
|
|
2404
|
-
v:
|
|
2588
|
+
var uuid3 = z18.guid();
|
|
2589
|
+
var b64key = z18.string().regex(/^[A-Za-z0-9_-]{43}$/);
|
|
2590
|
+
var iso4 = z18.string().datetime();
|
|
2591
|
+
var uptimeSyncSchema = z18.object({
|
|
2592
|
+
v: z18.literal(1),
|
|
2405
2593
|
workspace_id: uuid3,
|
|
2406
|
-
revision:
|
|
2407
|
-
workspace_status:
|
|
2408
|
-
suspended:
|
|
2409
|
-
checks:
|
|
2410
|
-
projects:
|
|
2594
|
+
revision: z18.number().int().positive(),
|
|
2595
|
+
workspace_status: z18.enum(["active", "suspended", "deleting"]),
|
|
2596
|
+
suspended: z18.boolean(),
|
|
2597
|
+
checks: z18.array(uptimeDefinitionSchema).max(UPTIME_LIMITS.maxChecksPerWorkspace),
|
|
2598
|
+
projects: z18.array(z18.object({ id: z18.number().int().positive(), node_id: z18.guid().nullable(), seal_public_key: b64key.nullable() })).max(1000)
|
|
2411
2599
|
});
|
|
2412
|
-
var uptimeReconcileSchema =
|
|
2413
|
-
v:
|
|
2414
|
-
as_of:
|
|
2415
|
-
workspace_ids:
|
|
2416
|
-
heartbeat_routes:
|
|
2600
|
+
var uptimeReconcileSchema = z18.object({
|
|
2601
|
+
v: z18.literal(1),
|
|
2602
|
+
as_of: z18.number().int().positive(),
|
|
2603
|
+
workspace_ids: z18.array(uuid3).max(UPTIME_LIMITS.reconcileMaxWorkspaces),
|
|
2604
|
+
heartbeat_routes: z18.array(z18.string().regex(PING_ROUTE_RE)).max(UPTIME_LIMITS.reconcileMaxWorkspaces).optional()
|
|
2417
2605
|
});
|
|
2418
|
-
var probeDirectorySyncSchema =
|
|
2419
|
-
v:
|
|
2420
|
-
revision:
|
|
2421
|
-
probes:
|
|
2422
|
-
denied_hosts:
|
|
2606
|
+
var probeDirectorySyncSchema = z18.object({
|
|
2607
|
+
v: z18.literal(1),
|
|
2608
|
+
revision: z18.number().int().positive(),
|
|
2609
|
+
probes: z18.array(z18.object({ probe_id: probeIdSchema, region: z18.enum(UPTIME_REGIONS), public_key: b64key, status: z18.enum(["active", "revoked"]) })).max(30),
|
|
2610
|
+
denied_hosts: z18.array(z18.string().min(1).max(253)).max(1e4)
|
|
2423
2611
|
});
|
|
2424
|
-
var runNowRequestSchema =
|
|
2425
|
-
var signedAssignmentsSchema =
|
|
2426
|
-
var uptimeRegionStateSchema =
|
|
2427
|
-
region:
|
|
2428
|
-
outcome:
|
|
2429
|
-
reason:
|
|
2430
|
-
status_code:
|
|
2431
|
-
total_ms:
|
|
2612
|
+
var runNowRequestSchema = z18.object({ v: z18.literal(1), workspace_id: uuid3, check_id: uuid3, run_id: z18.string().regex(/^[A-Za-z0-9_-]{8,64}$/) });
|
|
2613
|
+
var signedAssignmentsSchema = z18.object({ assignments: assignmentsSchema, sig: z18.string().regex(/^[A-Za-z0-9_-]{86}$/) });
|
|
2614
|
+
var uptimeRegionStateSchema = z18.object({
|
|
2615
|
+
region: z18.enum(UPTIME_REGIONS),
|
|
2616
|
+
outcome: z18.enum(UPTIME_OUTCOMES),
|
|
2617
|
+
reason: z18.enum(UPTIME_REASONS).nullable(),
|
|
2618
|
+
status_code: z18.number().int().min(100).max(599).nullable(),
|
|
2619
|
+
total_ms: z18.number().nonnegative().max(60000).nullable(),
|
|
2432
2620
|
timings: timingsSchema.nullable().optional(),
|
|
2433
2621
|
at: iso4
|
|
2434
2622
|
});
|
|
2435
|
-
var uptimeStatusReportSchema =
|
|
2623
|
+
var uptimeStatusReportSchema = z18.object({
|
|
2436
2624
|
check_id: uuid3,
|
|
2437
|
-
revision:
|
|
2438
|
-
status:
|
|
2439
|
-
last_verdict:
|
|
2625
|
+
revision: z18.number().int().nonnegative(),
|
|
2626
|
+
status: z18.enum(UPTIME_STATUSES),
|
|
2627
|
+
last_verdict: z18.enum(SLOT_VERDICTS).nullable(),
|
|
2440
2628
|
last_slot_at: iso4.nullable(),
|
|
2441
2629
|
incident_id: uuid3.nullable(),
|
|
2442
|
-
down_streak:
|
|
2443
|
-
up_streak:
|
|
2444
|
-
regions:
|
|
2445
|
-
unobserved_regions:
|
|
2630
|
+
down_streak: z18.number().int().nonnegative(),
|
|
2631
|
+
up_streak: z18.number().int().nonnegative(),
|
|
2632
|
+
regions: z18.array(uptimeRegionStateSchema).max(3),
|
|
2633
|
+
unobserved_regions: z18.array(z18.enum(UPTIME_REGIONS)).max(3),
|
|
2446
2634
|
cert_not_after: iso4.nullable(),
|
|
2447
|
-
cert_expiring:
|
|
2448
|
-
run_now:
|
|
2635
|
+
cert_expiring: z18.boolean(),
|
|
2636
|
+
run_now: z18.object({ run_id: z18.string().max(64), results: z18.array(uptimeRegionStateSchema).max(3) }).nullable()
|
|
2449
2637
|
});
|
|
2450
2638
|
var UPTIME_EVENT_KINDS = ["opened", "resolved", "cert_expiring"];
|
|
2451
|
-
var uptimeEventSchema =
|
|
2452
|
-
event_id:
|
|
2639
|
+
var uptimeEventSchema = z18.object({
|
|
2640
|
+
event_id: z18.string().regex(/^[A-Za-z0-9:_-]{8,96}$/),
|
|
2453
2641
|
check_id: uuid3,
|
|
2454
|
-
kind:
|
|
2642
|
+
kind: z18.enum(UPTIME_EVENT_KINDS),
|
|
2455
2643
|
incident_id: uuid3.nullable(),
|
|
2456
2644
|
at: iso4,
|
|
2457
|
-
reason:
|
|
2458
|
-
regions:
|
|
2459
|
-
cert_days_left:
|
|
2645
|
+
reason: z18.enum(UPTIME_REASONS).nullable(),
|
|
2646
|
+
regions: z18.array(z18.enum(UPTIME_REGIONS)).max(3),
|
|
2647
|
+
cert_days_left: z18.number().int().nullable()
|
|
2460
2648
|
});
|
|
2461
|
-
var uptimeMinuteSchema =
|
|
2649
|
+
var uptimeMinuteSchema = z18.object({
|
|
2462
2650
|
check_id: uuid3,
|
|
2463
2651
|
minute: iso4,
|
|
2464
|
-
up:
|
|
2465
|
-
degraded:
|
|
2466
|
-
down:
|
|
2467
|
-
unknown:
|
|
2468
|
-
latency:
|
|
2652
|
+
up: z18.number().int().nonnegative(),
|
|
2653
|
+
degraded: z18.number().int().nonnegative(),
|
|
2654
|
+
down: z18.number().int().nonnegative(),
|
|
2655
|
+
unknown: z18.number().int().nonnegative(),
|
|
2656
|
+
latency: z18.array(z18.object({ region: z18.enum(UPTIME_REGIONS), n: z18.number().int().positive(), p50_ms: z18.number().nonnegative(), p95_ms: z18.number().nonnegative() })).max(3)
|
|
2469
2657
|
});
|
|
2470
|
-
var uptimeReportSchema =
|
|
2471
|
-
v:
|
|
2658
|
+
var uptimeReportSchema = z18.object({
|
|
2659
|
+
v: z18.literal(1),
|
|
2472
2660
|
workspace_id: uuid3,
|
|
2473
|
-
revision:
|
|
2661
|
+
revision: z18.number().int().nonnegative(),
|
|
2474
2662
|
sent_at: iso4,
|
|
2475
|
-
events:
|
|
2476
|
-
statuses:
|
|
2477
|
-
minutes:
|
|
2663
|
+
events: z18.array(uptimeEventSchema).max(UPTIME_LIMITS.reportMaxEvents),
|
|
2664
|
+
statuses: z18.array(uptimeStatusReportSchema).max(UPTIME_LIMITS.reportMaxStatuses),
|
|
2665
|
+
minutes: z18.array(uptimeMinuteSchema).max(UPTIME_LIMITS.reportMaxMinutes)
|
|
2478
2666
|
});
|
|
2479
|
-
var probeFleetReportSchema =
|
|
2480
|
-
v:
|
|
2667
|
+
var probeFleetReportSchema = z18.object({
|
|
2668
|
+
v: z18.literal(1),
|
|
2481
2669
|
sent_at: iso4,
|
|
2482
|
-
probes:
|
|
2670
|
+
probes: z18.array(z18.object({
|
|
2483
2671
|
probe_id: probeIdSchema,
|
|
2484
|
-
region:
|
|
2485
|
-
version:
|
|
2672
|
+
region: z18.enum(UPTIME_REGIONS),
|
|
2673
|
+
version: z18.string().max(40).nullable(),
|
|
2486
2674
|
last_seen_at: iso4.nullable(),
|
|
2487
|
-
lag_p99_ms:
|
|
2488
|
-
checks_per_min:
|
|
2675
|
+
lag_p99_ms: z18.number().nonnegative().nullable(),
|
|
2676
|
+
checks_per_min: z18.number().nonnegative().nullable()
|
|
2489
2677
|
})).max(30),
|
|
2490
|
-
regions_alive:
|
|
2678
|
+
regions_alive: z18.array(z18.enum(UPTIME_REGIONS)).max(3)
|
|
2491
2679
|
});
|
|
2492
|
-
var probeEnrollSchema =
|
|
2493
|
-
v:
|
|
2680
|
+
var probeEnrollSchema = z18.object({
|
|
2681
|
+
v: z18.literal(1),
|
|
2494
2682
|
probe_id: probeIdSchema,
|
|
2495
|
-
public_key:
|
|
2496
|
-
code:
|
|
2497
|
-
ts:
|
|
2498
|
-
sig:
|
|
2683
|
+
public_key: z18.string().regex(/^[A-Za-z0-9_-]{43}$/),
|
|
2684
|
+
code: z18.string().regex(/^[A-Za-z0-9_-]{43}$/),
|
|
2685
|
+
ts: z18.number().int().positive(),
|
|
2686
|
+
sig: z18.string().regex(/^[A-Za-z0-9_-]{86}$/)
|
|
2499
2687
|
});
|
|
2500
|
-
var uptimeEvidenceEnvelopeSchema =
|
|
2501
|
-
v:
|
|
2502
|
-
check_id:
|
|
2503
|
-
slot:
|
|
2504
|
-
region:
|
|
2688
|
+
var uptimeEvidenceEnvelopeSchema = z18.object({
|
|
2689
|
+
v: z18.literal(1),
|
|
2690
|
+
check_id: z18.guid(),
|
|
2691
|
+
slot: z18.number().int().nonnegative(),
|
|
2692
|
+
region: z18.enum(UPTIME_REGIONS),
|
|
2505
2693
|
probe_id: probeIdSchema,
|
|
2506
|
-
at:
|
|
2507
|
-
sealed:
|
|
2694
|
+
at: z18.number().int().positive(),
|
|
2695
|
+
sealed: z18.string().regex(/^[A-Za-z0-9_-]+$/).max(16384)
|
|
2508
2696
|
}).strict();
|
|
2509
|
-
var uptimeEvidenceSchema =
|
|
2510
|
-
v:
|
|
2511
|
-
check_id:
|
|
2512
|
-
slot:
|
|
2513
|
-
region:
|
|
2514
|
-
at:
|
|
2515
|
-
reason:
|
|
2516
|
-
status_line:
|
|
2517
|
-
headers:
|
|
2518
|
-
body:
|
|
2519
|
-
body_truncated:
|
|
2697
|
+
var uptimeEvidenceSchema = z18.object({
|
|
2698
|
+
v: z18.literal(1),
|
|
2699
|
+
check_id: z18.guid(),
|
|
2700
|
+
slot: z18.number().int().nonnegative(),
|
|
2701
|
+
region: z18.enum(UPTIME_REGIONS),
|
|
2702
|
+
at: z18.number().int().positive(),
|
|
2703
|
+
reason: z18.enum(UPTIME_REASONS).nullable(),
|
|
2704
|
+
status_line: z18.string().max(200).nullable(),
|
|
2705
|
+
headers: z18.record(z18.string().max(64), z18.string().max(512)).refine((h) => Object.keys(h).length <= 20),
|
|
2706
|
+
body: z18.string().max(UPTIME_LIMITS.evidenceMaxBytes * 4).nullable(),
|
|
2707
|
+
body_truncated: z18.boolean(),
|
|
2520
2708
|
timings: timingsSchema.nullable(),
|
|
2521
|
-
ip:
|
|
2522
|
-
error:
|
|
2709
|
+
ip: z18.string().max(64).nullable(),
|
|
2710
|
+
error: z18.string().max(300).nullable()
|
|
2523
2711
|
}).strict();
|
|
2524
|
-
var uptimeEvidenceListSchema =
|
|
2525
|
-
items:
|
|
2712
|
+
var uptimeEvidenceListSchema = z18.object({
|
|
2713
|
+
items: z18.array(uptimeEvidenceSchema.extend({ received_at: z18.number().int().positive() })).max(UPTIME_LIMITS.evidenceKeepPerCheck)
|
|
2526
2714
|
});
|
|
2527
2715
|
|
|
2528
2716
|
// ../src/shared/contracts/api-ops/monitors.ts
|
|
2529
|
-
var anyMonitorInputSchema =
|
|
2717
|
+
var anyMonitorInputSchema = z19.union([monitorInputSchema, signalMonitorInputSchema]);
|
|
2530
2718
|
var MAINTENANCE_INPUTS = {
|
|
2531
|
-
create:
|
|
2532
|
-
update:
|
|
2533
|
-
delete:
|
|
2719
|
+
create: z19.object({ workspaceId: uuid, input: maintenanceInputSchema }),
|
|
2720
|
+
update: z19.object({ workspaceId: uuid, windowId: uuid, input: maintenanceInputSchema }),
|
|
2721
|
+
delete: z19.object({ workspaceId: uuid, windowId: uuid })
|
|
2534
2722
|
};
|
|
2535
2723
|
var MONITOR_INPUTS = {
|
|
2536
|
-
create:
|
|
2537
|
-
update:
|
|
2538
|
-
delete:
|
|
2539
|
-
setPause:
|
|
2540
|
-
setMuted:
|
|
2541
|
-
dismissDiscovery:
|
|
2542
|
-
rotatePing:
|
|
2724
|
+
create: z19.object({ projectId, slug: z19.string().regex(SLUG_RE), input: anyMonitorInputSchema }),
|
|
2725
|
+
update: z19.object({ monitorId: uuid, input: anyMonitorInputSchema }),
|
|
2726
|
+
delete: z19.object({ monitorId: uuid, confirmSlug: z19.string().max(64) }),
|
|
2727
|
+
setPause: z19.object({ monitorId: uuid, until: holdUntil }),
|
|
2728
|
+
setMuted: z19.object({ monitorId: uuid, muted: z19.boolean() }),
|
|
2729
|
+
dismissDiscovery: z19.object({ discoveryId: uuid }),
|
|
2730
|
+
rotatePing: z19.object({
|
|
2543
2731
|
monitorId: uuid,
|
|
2544
|
-
graceHours:
|
|
2732
|
+
graceHours: z19.number().int().refine((h) => HEARTBEAT_LIMITS.rotationGraceHoursChoices.includes(h))
|
|
2545
2733
|
}),
|
|
2546
|
-
monitorOnly:
|
|
2734
|
+
monitorOnly: z19.object({ monitorId: uuid })
|
|
2547
2735
|
};
|
|
2548
2736
|
var UPTIME_INPUTS = {
|
|
2549
2737
|
create: uptimeCheckInputSchema,
|
|
2550
|
-
update:
|
|
2551
|
-
checkOnly:
|
|
2552
|
-
setHold:
|
|
2738
|
+
update: z19.object({ checkId: uuid, input: uptimeCheckInputSchema }),
|
|
2739
|
+
checkOnly: z19.object({ checkId: uuid }),
|
|
2740
|
+
setHold: z19.object({ checkId: uuid, kind: z19.enum(["pause", "mute"]), until: holdUntil })
|
|
2553
2741
|
};
|
|
2554
2742
|
var SLO_INPUTS = {
|
|
2555
|
-
create:
|
|
2556
|
-
update:
|
|
2557
|
-
sloOnly:
|
|
2558
|
-
setHold:
|
|
2559
|
-
import:
|
|
2743
|
+
create: z19.object({ workspaceId: uuid, input: sloInputSchema }),
|
|
2744
|
+
update: z19.object({ sloId: uuid, input: sloInputSchema }),
|
|
2745
|
+
sloOnly: z19.object({ sloId: uuid }),
|
|
2746
|
+
setHold: z19.object({ sloId: uuid, kind: z19.enum(["pause", "mute"]), until: holdUntil }),
|
|
2747
|
+
import: z19.object({
|
|
2560
2748
|
workspaceId: uuid,
|
|
2561
|
-
text:
|
|
2562
|
-
dryRun:
|
|
2749
|
+
text: z19.string().max(SLO_LIMITS.openSloMaxBytes * 2),
|
|
2750
|
+
dryRun: z19.boolean()
|
|
2563
2751
|
})
|
|
2564
2752
|
};
|
|
2565
2753
|
var m = "monitors:write";
|
|
@@ -2901,19 +3089,19 @@ var MONITOR_OPERATIONS = [
|
|
|
2901
3089
|
];
|
|
2902
3090
|
|
|
2903
3091
|
// ../src/shared/contracts/api-ops/node-data.ts
|
|
2904
|
-
import { z as
|
|
2905
|
-
var issueId =
|
|
2906
|
-
var csv =
|
|
2907
|
-
var name2 =
|
|
2908
|
-
var period =
|
|
2909
|
-
var nodeCursor =
|
|
3092
|
+
import { z as z20 } from "zod";
|
|
3093
|
+
var issueId = z20.number().int().positive();
|
|
3094
|
+
var csv = z20.string().min(1).max(2000);
|
|
3095
|
+
var name2 = z20.string().min(1).max(256);
|
|
3096
|
+
var period = z20.enum(["1h", "24h", "7d", "14d", "30d"]);
|
|
3097
|
+
var nodeCursor = z20.string().min(1).max(600).optional();
|
|
2910
3098
|
var windowFields = {
|
|
2911
|
-
start:
|
|
2912
|
-
end:
|
|
3099
|
+
start: z20.string().max(40).optional(),
|
|
3100
|
+
end: z20.string().max(40).optional()
|
|
2913
3101
|
};
|
|
2914
|
-
var traceId =
|
|
2915
|
-
var spanId =
|
|
2916
|
-
var attrs =
|
|
3102
|
+
var traceId = z20.string().regex(/^[0-9a-fA-F]{32}$/);
|
|
3103
|
+
var spanId = z20.string().regex(/^[0-9a-fA-F]{16}$/);
|
|
3104
|
+
var attrs = z20.string().max(2000).optional();
|
|
2917
3105
|
var telemetryCommon = {
|
|
2918
3106
|
...windowFields,
|
|
2919
3107
|
project: csv.optional(),
|
|
@@ -2921,112 +3109,134 @@ var telemetryCommon = {
|
|
|
2921
3109
|
service: csv.optional(),
|
|
2922
3110
|
attrs
|
|
2923
3111
|
};
|
|
2924
|
-
var issueChange =
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
action:
|
|
2930
|
-
mode:
|
|
2931
|
-
events:
|
|
2932
|
-
users:
|
|
2933
|
-
until:
|
|
2934
|
-
}),
|
|
2935
|
-
|
|
2936
|
-
|
|
3112
|
+
var issueChange = z20.union([
|
|
3113
|
+
z20.object({ action: z20.literal("resolve"), inNextRelease: z20.boolean().optional() }),
|
|
3114
|
+
z20.object({ action: z20.literal("unresolve") }),
|
|
3115
|
+
z20.object({ action: z20.literal("archive"), mode: z20.enum(["until_escalating", "forever"]) }),
|
|
3116
|
+
z20.object({
|
|
3117
|
+
action: z20.literal("archive"),
|
|
3118
|
+
mode: z20.literal("until_condition"),
|
|
3119
|
+
events: z20.number().int().min(1).max(1e6).optional(),
|
|
3120
|
+
users: z20.number().int().min(1).max(1e5).optional(),
|
|
3121
|
+
until: z20.string().datetime().optional()
|
|
3122
|
+
}),
|
|
3123
|
+
z20.object({ action: z20.literal("assign"), userId: z20.guid().nullable() }),
|
|
3124
|
+
z20.object({ action: z20.literal("priority"), priority: z20.enum(["low", "medium", "high"]) })
|
|
2937
3125
|
]);
|
|
2938
3126
|
var NODE_INPUTS = {
|
|
2939
|
-
issuesList:
|
|
3127
|
+
issuesList: z20.object({
|
|
2940
3128
|
project: csv.optional(),
|
|
2941
|
-
status:
|
|
3129
|
+
status: z20.enum(["unresolved", "resolved", "archived", "all"]).optional(),
|
|
2942
3130
|
level: csv.optional(),
|
|
2943
3131
|
priority: csv.optional(),
|
|
2944
3132
|
environment: csv.optional(),
|
|
2945
3133
|
release: csv.optional(),
|
|
2946
|
-
assignee:
|
|
3134
|
+
assignee: z20.string().max(64).optional(),
|
|
2947
3135
|
period: period.optional(),
|
|
2948
|
-
q:
|
|
2949
|
-
sort:
|
|
3136
|
+
q: z20.string().max(200).optional(),
|
|
3137
|
+
sort: z20.enum(["last_seen", "first_seen", "events", "users", "priority"]).optional(),
|
|
2950
3138
|
cursor: nodeCursor,
|
|
2951
|
-
limit:
|
|
3139
|
+
limit: z20.number().int().min(1).max(100).optional()
|
|
2952
3140
|
}),
|
|
2953
|
-
issue:
|
|
2954
|
-
issueStats:
|
|
2955
|
-
issueEvents:
|
|
2956
|
-
issueEvent:
|
|
3141
|
+
issue: z20.object({ issueId }),
|
|
3142
|
+
issueStats: z20.object({ issueId, range: z20.enum(["24h", "30d"]).optional() }),
|
|
3143
|
+
issueEvents: z20.object({ issueId, cursor: nodeCursor }),
|
|
3144
|
+
issueEvent: z20.object({
|
|
2957
3145
|
issueId,
|
|
2958
|
-
eventId:
|
|
3146
|
+
eventId: z20.string().regex(/^([0-9a-f]{32}|latest|oldest)$/)
|
|
2959
3147
|
}),
|
|
2960
|
-
issueUpdate:
|
|
2961
|
-
issuesBulk:
|
|
2962
|
-
issueIds:
|
|
3148
|
+
issueUpdate: z20.object({ issueId, change: issueChange }),
|
|
3149
|
+
issuesBulk: z20.object({
|
|
3150
|
+
issueIds: z20.array(issueId).min(1).max(100),
|
|
2963
3151
|
action: issueChange
|
|
2964
3152
|
}),
|
|
2965
|
-
spansList:
|
|
3153
|
+
spansList: z20.object({
|
|
2966
3154
|
...telemetryCommon,
|
|
2967
|
-
operation:
|
|
2968
|
-
status:
|
|
2969
|
-
kind:
|
|
2970
|
-
minDurationMs:
|
|
2971
|
-
maxDurationMs:
|
|
2972
|
-
mode:
|
|
3155
|
+
operation: z20.string().min(1).max(1024).optional(),
|
|
3156
|
+
status: z20.enum(["unset", "ok", "error"]).optional(),
|
|
3157
|
+
kind: z20.enum(["internal", "server", "client", "producer", "consumer"]).optional(),
|
|
3158
|
+
minDurationMs: z20.number().min(0).max(86400000).optional(),
|
|
3159
|
+
maxDurationMs: z20.number().min(0).max(86400000).optional(),
|
|
3160
|
+
mode: z20.enum(["spans", "traces"]).optional(),
|
|
2973
3161
|
cursor: nodeCursor
|
|
2974
3162
|
}),
|
|
2975
|
-
spansHistogram:
|
|
3163
|
+
spansHistogram: z20.object({
|
|
2976
3164
|
...telemetryCommon,
|
|
2977
|
-
operation:
|
|
2978
|
-
status:
|
|
3165
|
+
operation: z20.string().min(1).max(1024).optional(),
|
|
3166
|
+
status: z20.enum(["unset", "ok", "error"]).optional()
|
|
2979
3167
|
}),
|
|
2980
|
-
trace:
|
|
2981
|
-
traceSpans:
|
|
2982
|
-
span:
|
|
2983
|
-
logsList:
|
|
3168
|
+
trace: z20.object({ traceId }),
|
|
3169
|
+
traceSpans: z20.object({ traceId, errorsOnly: z20.enum(["1"]).optional(), ...windowFields }),
|
|
3170
|
+
span: z20.object({ traceId, spanId, ...windowFields }),
|
|
3171
|
+
logsList: z20.object({
|
|
2984
3172
|
...telemetryCommon,
|
|
2985
|
-
severityMin:
|
|
3173
|
+
severityMin: z20.enum(["trace", "debug", "info", "warn", "error", "fatal"]).optional(),
|
|
2986
3174
|
traceId: traceId.optional(),
|
|
2987
3175
|
spanId: spanId.optional(),
|
|
2988
|
-
q:
|
|
2989
|
-
order:
|
|
3176
|
+
q: z20.string().max(500).optional(),
|
|
3177
|
+
order: z20.enum(["asc", "desc"]).optional(),
|
|
2990
3178
|
cursor: nodeCursor
|
|
2991
3179
|
}),
|
|
2992
|
-
logsFacets:
|
|
3180
|
+
logsFacets: z20.object({
|
|
2993
3181
|
...telemetryCommon,
|
|
2994
|
-
severityMin:
|
|
2995
|
-
q:
|
|
3182
|
+
severityMin: z20.enum(["trace", "debug", "info", "warn", "error", "fatal"]).optional(),
|
|
3183
|
+
q: z20.string().max(500).optional()
|
|
2996
3184
|
}),
|
|
2997
|
-
logAround:
|
|
3185
|
+
logAround: z20.object({
|
|
2998
3186
|
logId: name2,
|
|
2999
|
-
at:
|
|
3000
|
-
same:
|
|
3001
|
-
before:
|
|
3002
|
-
after:
|
|
3003
|
-
}),
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3187
|
+
at: z20.string().max(40),
|
|
3188
|
+
same: z20.enum(["service", "trace"]).optional(),
|
|
3189
|
+
before: z20.number().int().min(0).max(200).optional(),
|
|
3190
|
+
after: z20.number().int().min(0).max(200).optional()
|
|
3191
|
+
}),
|
|
3192
|
+
metricsNames: z20.object({
|
|
3193
|
+
project: z20.number().int().positive(),
|
|
3194
|
+
environment: csv.optional(),
|
|
3195
|
+
q: z20.string().max(255).optional()
|
|
3196
|
+
}),
|
|
3197
|
+
metricsSeries: z20.object({
|
|
3198
|
+
project: z20.number().int().positive(),
|
|
3199
|
+
name: z20.string().regex(METRIC_NAME_RE),
|
|
3200
|
+
environment: csv.optional(),
|
|
3201
|
+
attrs,
|
|
3202
|
+
cursor: z20.string().regex(/^[0-9a-f]{16}$/).optional()
|
|
3203
|
+
}),
|
|
3204
|
+
metricsQuery: z20.object({
|
|
3205
|
+
project: z20.number().int().positive(),
|
|
3206
|
+
name: z20.string().regex(METRIC_NAME_RE),
|
|
3207
|
+
aggregation: z20.enum(METRIC_AGGREGATIONS),
|
|
3208
|
+
...windowFields,
|
|
3209
|
+
step: z20.number().int().min(METRIC_QUERY.minStepSeconds).max(METRIC_QUERY.maxStepSeconds).multipleOf(60).optional(),
|
|
3210
|
+
attrs,
|
|
3211
|
+
groupBy: z20.string().min(1).max(600).optional(),
|
|
3212
|
+
environment: csv.optional()
|
|
3213
|
+
}),
|
|
3214
|
+
telemetryUsage: z20.object({ project: csv.optional(), days: z20.number().int().min(1).max(31).optional() }),
|
|
3215
|
+
monitorSignal: z20.object({ monitorId: z20.guid(), hours: z20.number().int().min(1).max(24).optional() }),
|
|
3216
|
+
monitorOccurrences: z20.object({
|
|
3217
|
+
monitorId: z20.guid(),
|
|
3218
|
+
state: z20.enum(["open", "finished", "all"]).optional(),
|
|
3219
|
+
environment: z20.string().min(1).max(64).optional(),
|
|
3010
3220
|
cursor: nodeCursor
|
|
3011
3221
|
}),
|
|
3012
|
-
monitorBacktest:
|
|
3013
|
-
occurrenceCreate:
|
|
3014
|
-
project:
|
|
3222
|
+
monitorBacktest: z20.object({ project: z20.number().int().positive(), settings: backtestSettingsSchema }),
|
|
3223
|
+
occurrenceCreate: z20.object({
|
|
3224
|
+
project: z20.number().int().positive(),
|
|
3015
3225
|
monitorSlug: occurrenceInputSchema.shape.monitor_slug,
|
|
3016
3226
|
occurrenceId: occurrenceInputSchema.shape.occurrence_id,
|
|
3017
3227
|
dueAt: occurrenceInputSchema.shape.due_at,
|
|
3018
3228
|
environment: occurrenceInputSchema.shape.environment
|
|
3019
3229
|
}),
|
|
3020
|
-
occurrenceCancel:
|
|
3021
|
-
project:
|
|
3022
|
-
monitorSlug:
|
|
3023
|
-
occurrenceId:
|
|
3024
|
-
environment:
|
|
3230
|
+
occurrenceCancel: z20.object({
|
|
3231
|
+
project: z20.number().int().positive(),
|
|
3232
|
+
monitorSlug: z20.string().regex(SLUG_RE),
|
|
3233
|
+
occurrenceId: z20.string().regex(OCCURRENCE_ID_RE),
|
|
3234
|
+
environment: z20.string().min(1).max(64).optional()
|
|
3025
3235
|
}),
|
|
3026
|
-
ticket:
|
|
3027
|
-
scope:
|
|
3028
|
-
project:
|
|
3029
|
-
environment:
|
|
3236
|
+
ticket: z20.object({
|
|
3237
|
+
scope: z20.enum(["read", "write"]).default("read"),
|
|
3238
|
+
project: z20.number().int().positive().optional(),
|
|
3239
|
+
environment: z20.string().min(1).max(64).optional()
|
|
3030
3240
|
})
|
|
3031
3241
|
};
|
|
3032
3242
|
var N = NODE_INPUTS;
|
|
@@ -3188,6 +3398,34 @@ var NODE_OPERATIONS = [
|
|
|
3188
3398
|
node: { path: "q/logs/{log_id}/around" },
|
|
3189
3399
|
summary: "Log records just before and after one record."
|
|
3190
3400
|
}),
|
|
3401
|
+
op({
|
|
3402
|
+
...read,
|
|
3403
|
+
id: "metrics.names",
|
|
3404
|
+
path: "/v1/metrics/names",
|
|
3405
|
+
scope: "metrics:read",
|
|
3406
|
+
input: N.metricsNames,
|
|
3407
|
+
node: { path: "q/metrics/names" },
|
|
3408
|
+
summary: "The metric catalog of one project (name, type, kind, unit, series count, last seen) and the node's series and name caps with the metrics it is dropping points for."
|
|
3409
|
+
}),
|
|
3410
|
+
op({
|
|
3411
|
+
...read,
|
|
3412
|
+
id: "metrics.series",
|
|
3413
|
+
path: "/v1/metrics/series",
|
|
3414
|
+
scope: "metrics:read",
|
|
3415
|
+
input: N.metricsSeries,
|
|
3416
|
+
node: { path: "q/metrics/series", list: "series" },
|
|
3417
|
+
paged: true,
|
|
3418
|
+
summary: "The time series of one metric (attributes, service, environment, first and last seen), 100 per page."
|
|
3419
|
+
}),
|
|
3420
|
+
op({
|
|
3421
|
+
...read,
|
|
3422
|
+
id: "metrics.query",
|
|
3423
|
+
path: "/v1/metrics/query",
|
|
3424
|
+
scope: "metrics:read",
|
|
3425
|
+
input: N.metricsQuery,
|
|
3426
|
+
node: { path: "q/metrics/query", window: true },
|
|
3427
|
+
summary: "One metric aggregated per step (avg, sum, min, max, count, rate, p50–p99) in a window of at most 7 days, optionally grouped by up to two attributes (≤ 50 groups, ≤ 10,000 points), with exemplar trace ids."
|
|
3428
|
+
}),
|
|
3191
3429
|
op({
|
|
3192
3430
|
...read,
|
|
3193
3431
|
id: "telemetry.usage",
|
|
@@ -3288,10 +3526,10 @@ var NODE_OPERATIONS = [
|
|
|
3288
3526
|
];
|
|
3289
3527
|
|
|
3290
3528
|
// ../src/shared/contracts/api-ops/privacy.ts
|
|
3291
|
-
import { z as
|
|
3529
|
+
import { z as z22 } from "zod";
|
|
3292
3530
|
|
|
3293
3531
|
// ../src/shared/contracts/privacy.ts
|
|
3294
|
-
import { z as
|
|
3532
|
+
import { z as z21 } from "zod";
|
|
3295
3533
|
|
|
3296
3534
|
// ../src/shared/privacy/rules.ts
|
|
3297
3535
|
var PRIVACY_SCHEMA = 1;
|
|
@@ -3321,44 +3559,44 @@ var IPV6_RE = new RegExp(`(^|[^0-9A-Fa-f:])((?:${H}:){7}${H}|(?:${H}:){1,6}:(?:$
|
|
|
3321
3559
|
var REMOVE = Symbol("remove");
|
|
3322
3560
|
|
|
3323
3561
|
// ../src/shared/contracts/privacy.ts
|
|
3324
|
-
var ruleId =
|
|
3325
|
-
var privacyRuleInputSchema =
|
|
3562
|
+
var ruleId = z21.string().regex(/^[A-Za-z0-9_-]{1,64}$/);
|
|
3563
|
+
var privacyRuleInputSchema = z21.object({
|
|
3326
3564
|
id: ruleId,
|
|
3327
|
-
selector:
|
|
3328
|
-
type:
|
|
3329
|
-
method:
|
|
3330
|
-
pattern:
|
|
3331
|
-
ignoreCase:
|
|
3332
|
-
replaceWith:
|
|
3333
|
-
enabled:
|
|
3565
|
+
selector: z21.string().min(1).max(PRIVACY_LIMITS.selector),
|
|
3566
|
+
type: z21.enum(PRIVACY_RULE_TYPES),
|
|
3567
|
+
method: z21.enum(PRIVACY_METHODS),
|
|
3568
|
+
pattern: z21.string().min(1).max(PRIVACY_LIMITS.pattern).optional(),
|
|
3569
|
+
ignoreCase: z21.boolean().optional(),
|
|
3570
|
+
replaceWith: z21.string().max(PRIVACY_LIMITS.replaceWith).optional(),
|
|
3571
|
+
enabled: z21.boolean().optional()
|
|
3334
3572
|
});
|
|
3335
|
-
var privacyPolicyInputSchema =
|
|
3336
|
-
mode:
|
|
3337
|
-
rules:
|
|
3338
|
-
allowlist:
|
|
3573
|
+
var privacyPolicyInputSchema = z21.object({
|
|
3574
|
+
mode: z21.enum(PRIVACY_MODES),
|
|
3575
|
+
rules: z21.array(privacyRuleInputSchema).max(PRIVACY_LIMITS.rules),
|
|
3576
|
+
allowlist: z21.array(z21.string().min(1).max(PRIVACY_LIMITS.selector)).max(PRIVACY_LIMITS.allowlist)
|
|
3339
3577
|
});
|
|
3340
|
-
var storedPolicySchema =
|
|
3341
|
-
schema:
|
|
3342
|
-
version:
|
|
3343
|
-
mode:
|
|
3344
|
-
rules:
|
|
3345
|
-
allowlist:
|
|
3578
|
+
var storedPolicySchema = z21.object({
|
|
3579
|
+
schema: z21.literal(PRIVACY_SCHEMA),
|
|
3580
|
+
version: z21.number().int().min(0),
|
|
3581
|
+
mode: z21.enum(PRIVACY_MODES),
|
|
3582
|
+
rules: z21.array(z21.record(z21.string(), z21.unknown())).max(PRIVACY_LIMITS.rules),
|
|
3583
|
+
allowlist: z21.array(z21.string()).max(PRIVACY_LIMITS.allowlist)
|
|
3346
3584
|
});
|
|
3347
|
-
var nodePrivacyBlockSchema =
|
|
3348
|
-
var privacyRollupSchema =
|
|
3349
|
-
applied_version:
|
|
3350
|
-
policy_missing_24h:
|
|
3351
|
-
budget_exceeded_24h:
|
|
3352
|
-
sdk_versions:
|
|
3585
|
+
var nodePrivacyBlockSchema = z21.array(z21.object({ project_id: z21.number().int().positive(), policy: z21.unknown() })).max(1000);
|
|
3586
|
+
var privacyRollupSchema = z21.object({
|
|
3587
|
+
applied_version: z21.number().int().min(0).nullable(),
|
|
3588
|
+
policy_missing_24h: z21.number().int().nonnegative(),
|
|
3589
|
+
budget_exceeded_24h: z21.number().int().nonnegative(),
|
|
3590
|
+
sdk_versions: z21.array(z21.object({ version: z21.number().int().min(0), last_seen_at: z21.string().datetime() })).max(5)
|
|
3353
3591
|
});
|
|
3354
3592
|
|
|
3355
3593
|
// ../src/shared/contracts/api-ops/privacy.ts
|
|
3356
3594
|
var PRIVACY_INPUTS = {
|
|
3357
|
-
get:
|
|
3358
|
-
set:
|
|
3595
|
+
get: z22.object({ workspaceId: uuid, projectId }),
|
|
3596
|
+
set: z22.object({
|
|
3359
3597
|
workspaceId: uuid,
|
|
3360
3598
|
projectId,
|
|
3361
|
-
expectedVersion:
|
|
3599
|
+
expectedVersion: z22.number().int().min(0),
|
|
3362
3600
|
policy: privacyPolicyInputSchema
|
|
3363
3601
|
})
|
|
3364
3602
|
};
|
|
@@ -3398,11 +3636,11 @@ var PRIVACY_OPERATIONS = [
|
|
|
3398
3636
|
];
|
|
3399
3637
|
|
|
3400
3638
|
// ../src/shared/contracts/api-ops/projects.ts
|
|
3401
|
-
import { z as
|
|
3639
|
+
import { z as z26 } from "zod";
|
|
3402
3640
|
|
|
3403
3641
|
// ../src/shared/contracts/ingest-keys.ts
|
|
3404
|
-
import { z as
|
|
3405
|
-
var INGEST_KEY_SCOPES = ["traces", "logs", "errors", "monitors"];
|
|
3642
|
+
import { z as z23 } from "zod";
|
|
3643
|
+
var INGEST_KEY_SCOPES = ["traces", "logs", "metrics", "errors", "monitors"];
|
|
3406
3644
|
var INGEST_KEY_STATES = ["active", "revoked"];
|
|
3407
3645
|
var INGEST_KEY_LIMITS = {
|
|
3408
3646
|
nameMaxChars: 80,
|
|
@@ -3411,91 +3649,92 @@ var INGEST_KEY_LIMITS = {
|
|
|
3411
3649
|
edgeCacheSeconds: 60
|
|
3412
3650
|
};
|
|
3413
3651
|
var CHECKIN_AUTH_MODES = ["public_or_key", "key_only"];
|
|
3414
|
-
var ingestKeyConfigSchema =
|
|
3415
|
-
v:
|
|
3416
|
-
key_id:
|
|
3417
|
-
project_public_id:
|
|
3418
|
-
project_id:
|
|
3419
|
-
workspace_id:
|
|
3652
|
+
var ingestKeyConfigSchema = z23.object({
|
|
3653
|
+
v: z23.literal(1),
|
|
3654
|
+
key_id: z23.guid(),
|
|
3655
|
+
project_public_id: z23.number().int().positive(),
|
|
3656
|
+
project_id: z23.number().int().positive(),
|
|
3657
|
+
workspace_id: z23.guid(),
|
|
3420
3658
|
node_id: nodeIdSchema,
|
|
3421
|
-
scopes:
|
|
3422
|
-
environments:
|
|
3423
|
-
expires_at:
|
|
3424
|
-
state:
|
|
3425
|
-
workspace_status:
|
|
3426
|
-
ingest_kill:
|
|
3427
|
-
telemetry_kill:
|
|
3428
|
-
telemetry_rate_bytes_per_sec:
|
|
3429
|
-
telemetry_burst_bytes:
|
|
3430
|
-
traces_monthly_bytes:
|
|
3431
|
-
logs_monthly_bytes:
|
|
3432
|
-
|
|
3433
|
-
|
|
3659
|
+
scopes: z23.array(z23.enum(INGEST_KEY_SCOPES)).min(1).max(INGEST_KEY_SCOPES.length),
|
|
3660
|
+
environments: z23.array(z23.string().max(INGEST_KEY_LIMITS.environmentMaxChars)).max(INGEST_KEY_LIMITS.environmentsMax),
|
|
3661
|
+
expires_at: z23.string().datetime({ offset: true }).nullable(),
|
|
3662
|
+
state: z23.enum(INGEST_KEY_STATES),
|
|
3663
|
+
workspace_status: z23.enum(["active", "suspended", "deleting"]),
|
|
3664
|
+
ingest_kill: z23.boolean(),
|
|
3665
|
+
telemetry_kill: z23.boolean(),
|
|
3666
|
+
telemetry_rate_bytes_per_sec: z23.number().int().positive(),
|
|
3667
|
+
telemetry_burst_bytes: z23.number().int().positive(),
|
|
3668
|
+
traces_monthly_bytes: z23.number().int().positive(),
|
|
3669
|
+
logs_monthly_bytes: z23.number().int().positive(),
|
|
3670
|
+
metrics_monthly_bytes: z23.number().int().positive().optional(),
|
|
3671
|
+
telemetry_buffer_minutes: z23.number().int().min(1).max(1440),
|
|
3672
|
+
revision: z23.number().int().nonnegative()
|
|
3434
3673
|
});
|
|
3435
|
-
var createIngestKeyInputSchema =
|
|
3436
|
-
projectId:
|
|
3437
|
-
name:
|
|
3438
|
-
scopes:
|
|
3439
|
-
environments:
|
|
3440
|
-
expiresAt:
|
|
3674
|
+
var createIngestKeyInputSchema = z23.object({
|
|
3675
|
+
projectId: z23.number().int().positive(),
|
|
3676
|
+
name: z23.string().trim().min(1).max(INGEST_KEY_LIMITS.nameMaxChars).refine((s) => !/[\u0000-\u001f\u007f]/.test(s)),
|
|
3677
|
+
scopes: z23.array(z23.enum(INGEST_KEY_SCOPES)).min(1).max(INGEST_KEY_SCOPES.length),
|
|
3678
|
+
environments: z23.array(z23.string().trim().min(1).max(INGEST_KEY_LIMITS.environmentMaxChars).regex(/^[^\s/\u0000-\u001f]+$/)).max(INGEST_KEY_LIMITS.environmentsMax),
|
|
3679
|
+
expiresAt: z23.string().datetime({ offset: true }).nullable()
|
|
3441
3680
|
});
|
|
3442
|
-
var ingestKeyRowSchema =
|
|
3443
|
-
id:
|
|
3444
|
-
project_id:
|
|
3445
|
-
name:
|
|
3446
|
-
prefix:
|
|
3447
|
-
scopes:
|
|
3448
|
-
environments:
|
|
3449
|
-
expires_at:
|
|
3450
|
-
state:
|
|
3451
|
-
created_by:
|
|
3452
|
-
created_at:
|
|
3453
|
-
revoked_at:
|
|
3454
|
-
last_used_at:
|
|
3681
|
+
var ingestKeyRowSchema = z23.object({
|
|
3682
|
+
id: z23.guid(),
|
|
3683
|
+
project_id: z23.number().int().positive(),
|
|
3684
|
+
name: z23.string(),
|
|
3685
|
+
prefix: z23.string(),
|
|
3686
|
+
scopes: z23.array(z23.enum(INGEST_KEY_SCOPES)),
|
|
3687
|
+
environments: z23.array(z23.string()),
|
|
3688
|
+
expires_at: z23.string().nullable(),
|
|
3689
|
+
state: z23.enum(INGEST_KEY_STATES),
|
|
3690
|
+
created_by: z23.guid().nullable(),
|
|
3691
|
+
created_at: z23.string(),
|
|
3692
|
+
revoked_at: z23.string().nullable(),
|
|
3693
|
+
last_used_at: z23.string().nullable()
|
|
3455
3694
|
});
|
|
3456
3695
|
|
|
3457
3696
|
// ../src/shared/contracts/node-config.ts
|
|
3458
|
-
import { z as
|
|
3697
|
+
import { z as z25 } from "zod";
|
|
3459
3698
|
|
|
3460
3699
|
// ../src/shared/contracts/backup.ts
|
|
3461
|
-
import { z as
|
|
3700
|
+
import { z as z24 } from "zod";
|
|
3462
3701
|
var BACKUP_KINDS = ["daily", "weekly", "manual", "pre_upgrade"];
|
|
3463
|
-
var ageRecipient =
|
|
3464
|
-
var backupIdSchema =
|
|
3465
|
-
var nodeBackupConfigSchema =
|
|
3466
|
-
enabled:
|
|
3467
|
-
hour_utc:
|
|
3468
|
-
weekly_day:
|
|
3702
|
+
var ageRecipient = z24.string().regex(/^age1[02-9ac-hj-np-z]{58}$/);
|
|
3703
|
+
var backupIdSchema = z24.string().regex(/^[a-z0-9-]{8,64}$/);
|
|
3704
|
+
var nodeBackupConfigSchema = z24.object({
|
|
3705
|
+
enabled: z24.boolean(),
|
|
3706
|
+
hour_utc: z24.number().int().min(0).max(23),
|
|
3707
|
+
weekly_day: z24.number().int().min(1).max(7),
|
|
3469
3708
|
workspace_recipient: ageRecipient
|
|
3470
3709
|
});
|
|
3471
|
-
var backupCredentialsRequestSchema =
|
|
3472
|
-
mode:
|
|
3710
|
+
var backupCredentialsRequestSchema = z24.object({
|
|
3711
|
+
mode: z24.enum(["upload", "download"]),
|
|
3473
3712
|
backup_id: backupIdSchema,
|
|
3474
|
-
source_node_id:
|
|
3713
|
+
source_node_id: z24.guid().optional()
|
|
3475
3714
|
});
|
|
3476
|
-
var backupCredentialsSchema =
|
|
3477
|
-
endpoint:
|
|
3478
|
-
bucket:
|
|
3479
|
-
prefix:
|
|
3480
|
-
access_key_id:
|
|
3481
|
-
secret_access_key:
|
|
3482
|
-
session_token:
|
|
3483
|
-
expires_at:
|
|
3715
|
+
var backupCredentialsSchema = z24.object({
|
|
3716
|
+
endpoint: z24.string().url(),
|
|
3717
|
+
bucket: z24.string().regex(/^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/),
|
|
3718
|
+
prefix: z24.string().regex(/^backups\/[0-9a-f-]{36}\/$/),
|
|
3719
|
+
access_key_id: z24.string().min(8).max(200),
|
|
3720
|
+
secret_access_key: z24.string().min(8).max(200),
|
|
3721
|
+
session_token: z24.string().min(8).max(4000),
|
|
3722
|
+
expires_at: z24.string().datetime()
|
|
3484
3723
|
});
|
|
3485
|
-
var rowCountsSchema =
|
|
3486
|
-
var backupManifestSchema =
|
|
3487
|
-
v:
|
|
3724
|
+
var rowCountsSchema = z24.record(z24.string().regex(/^[a-z_][a-z0-9_]{0,63}$/), z24.number().int().nonnegative());
|
|
3725
|
+
var backupManifestSchema = z24.object({
|
|
3726
|
+
v: z24.literal(1),
|
|
3488
3727
|
backup_id: backupIdSchema,
|
|
3489
|
-
node_id:
|
|
3490
|
-
kind:
|
|
3491
|
-
created_at:
|
|
3492
|
-
object_key:
|
|
3493
|
-
size_bytes:
|
|
3494
|
-
sha256:
|
|
3495
|
-
clickhouse_version:
|
|
3496
|
-
schema_version:
|
|
3728
|
+
node_id: z24.guid(),
|
|
3729
|
+
kind: z24.enum(BACKUP_KINDS),
|
|
3730
|
+
created_at: z24.string().datetime(),
|
|
3731
|
+
object_key: z24.string(),
|
|
3732
|
+
size_bytes: z24.number().int().nonnegative(),
|
|
3733
|
+
sha256: z24.string().regex(/^[0-9a-f]{64}$/),
|
|
3734
|
+
clickhouse_version: z24.string().max(40),
|
|
3735
|
+
schema_version: z24.number().int().nonnegative(),
|
|
3497
3736
|
row_counts: rowCountsSchema,
|
|
3498
|
-
recipients:
|
|
3737
|
+
recipients: z24.array(z24.string().regex(/^[0-9a-f]{8}$/)).min(1).max(4)
|
|
3499
3738
|
});
|
|
3500
3739
|
var BACKUP_ERROR_CODES = [
|
|
3501
3740
|
"CLICKHOUSE_BACKUP_FAILED",
|
|
@@ -3509,48 +3748,48 @@ var BACKUP_ERROR_CODES = [
|
|
|
3509
3748
|
"RESTORE_FAILED",
|
|
3510
3749
|
"ROW_COUNT_MISMATCH"
|
|
3511
3750
|
];
|
|
3512
|
-
var backupReportSchema =
|
|
3751
|
+
var backupReportSchema = z24.object({
|
|
3513
3752
|
backup_id: backupIdSchema,
|
|
3514
|
-
kind:
|
|
3515
|
-
status:
|
|
3516
|
-
started_at:
|
|
3517
|
-
finished_at:
|
|
3753
|
+
kind: z24.enum(BACKUP_KINDS),
|
|
3754
|
+
status: z24.enum(["succeeded", "failed"]),
|
|
3755
|
+
started_at: z24.string().datetime(),
|
|
3756
|
+
finished_at: z24.string().datetime(),
|
|
3518
3757
|
manifest: backupManifestSchema.nullable(),
|
|
3519
|
-
error_code:
|
|
3758
|
+
error_code: z24.enum(BACKUP_ERROR_CODES).nullable()
|
|
3520
3759
|
});
|
|
3521
|
-
var drillReportSchema =
|
|
3760
|
+
var drillReportSchema = z24.object({
|
|
3522
3761
|
backup_id: backupIdSchema,
|
|
3523
|
-
kind:
|
|
3524
|
-
status:
|
|
3525
|
-
finished_at:
|
|
3526
|
-
detail:
|
|
3527
|
-
error_code:
|
|
3762
|
+
kind: z24.enum(["weekly_local", "monthly_new_machine"]),
|
|
3763
|
+
status: z24.enum(["passed", "failed"]),
|
|
3764
|
+
finished_at: z24.string().datetime(),
|
|
3765
|
+
detail: z24.string().max(300),
|
|
3766
|
+
error_code: z24.enum(BACKUP_ERROR_CODES).nullable()
|
|
3528
3767
|
});
|
|
3529
|
-
var nodeIdentityEscrowSchema =
|
|
3530
|
-
v:
|
|
3531
|
-
node_id:
|
|
3532
|
-
seal:
|
|
3533
|
-
publicKey:
|
|
3534
|
-
privateKey:
|
|
3768
|
+
var nodeIdentityEscrowSchema = z24.object({
|
|
3769
|
+
v: z24.literal(1),
|
|
3770
|
+
node_id: z24.guid(),
|
|
3771
|
+
seal: z24.object({
|
|
3772
|
+
publicKey: z24.string().regex(/^[A-Za-z0-9_-]{43}$/),
|
|
3773
|
+
privateKey: z24.string().regex(/^[A-Za-z0-9_-]{43}$/)
|
|
3535
3774
|
}),
|
|
3536
|
-
created_at:
|
|
3775
|
+
created_at: z24.string().datetime()
|
|
3537
3776
|
});
|
|
3538
|
-
var restoreArgsSchema =
|
|
3539
|
-
job_id:
|
|
3540
|
-
workspace_id:
|
|
3541
|
-
source_node_id:
|
|
3777
|
+
var restoreArgsSchema = z24.object({
|
|
3778
|
+
job_id: z24.guid(),
|
|
3779
|
+
workspace_id: z24.guid(),
|
|
3780
|
+
source_node_id: z24.guid(),
|
|
3542
3781
|
manifest: backupManifestSchema,
|
|
3543
|
-
sealed_identity:
|
|
3544
|
-
mode:
|
|
3782
|
+
sealed_identity: z24.string().regex(/^[A-Za-z0-9_-]{40,2000}$/),
|
|
3783
|
+
mode: z24.enum(["rebuild", "drill"])
|
|
3545
3784
|
});
|
|
3546
|
-
var restoreReportSchema =
|
|
3547
|
-
job_id:
|
|
3785
|
+
var restoreReportSchema = z24.object({
|
|
3786
|
+
job_id: z24.guid(),
|
|
3548
3787
|
backup_id: backupIdSchema,
|
|
3549
|
-
mode:
|
|
3550
|
-
status:
|
|
3551
|
-
finished_at:
|
|
3552
|
-
detail:
|
|
3553
|
-
error_code:
|
|
3788
|
+
mode: z24.enum(["rebuild", "drill"]),
|
|
3789
|
+
status: z24.enum(["succeeded", "failed"]),
|
|
3790
|
+
finished_at: z24.string().datetime(),
|
|
3791
|
+
detail: z24.string().max(300),
|
|
3792
|
+
error_code: z24.enum(BACKUP_ERROR_CODES).nullable()
|
|
3554
3793
|
});
|
|
3555
3794
|
|
|
3556
3795
|
// ../src/shared/contracts/node-config.ts
|
|
@@ -3564,82 +3803,83 @@ var SCRUB_GROUPS = [
|
|
|
3564
3803
|
"headers"
|
|
3565
3804
|
];
|
|
3566
3805
|
var MAX_NODE_MONITORS = 5000;
|
|
3567
|
-
var kid =
|
|
3568
|
-
var publicKey =
|
|
3569
|
-
var nodeConfigSchema =
|
|
3570
|
-
v:
|
|
3571
|
-
config_version:
|
|
3572
|
-
node_id:
|
|
3573
|
-
workspace_id:
|
|
3574
|
-
workspace_status:
|
|
3575
|
-
issued_at:
|
|
3576
|
-
retention_days:
|
|
3577
|
-
channel:
|
|
3578
|
-
projects:
|
|
3579
|
-
project_id:
|
|
3580
|
-
slug:
|
|
3581
|
-
short_prefix:
|
|
3582
|
-
user_id_salt:
|
|
3583
|
-
scrub_disabled:
|
|
3584
|
-
upload_tokens:
|
|
3585
|
-
hash:
|
|
3586
|
-
expires_at:
|
|
3806
|
+
var kid = z25.string().regex(/^[A-Za-z0-9_-]{1,40}$/);
|
|
3807
|
+
var publicKey = z25.string().regex(/^[A-Za-z0-9_-]{43}$/);
|
|
3808
|
+
var nodeConfigSchema = z25.object({
|
|
3809
|
+
v: z25.literal(1),
|
|
3810
|
+
config_version: z25.number().int().positive(),
|
|
3811
|
+
node_id: z25.guid(),
|
|
3812
|
+
workspace_id: z25.guid(),
|
|
3813
|
+
workspace_status: z25.enum(["active", "suspended"]),
|
|
3814
|
+
issued_at: z25.string().datetime(),
|
|
3815
|
+
retention_days: z25.number().int().min(1).max(3650),
|
|
3816
|
+
channel: z25.enum(["stable", "canary"]).optional(),
|
|
3817
|
+
projects: z25.array(z25.object({
|
|
3818
|
+
project_id: z25.number().int().positive(),
|
|
3819
|
+
slug: z25.string().max(64),
|
|
3820
|
+
short_prefix: z25.string().regex(/^[A-Z0-9]{1,12}$/),
|
|
3821
|
+
user_id_salt: z25.string().regex(/^[A-Za-z0-9_-]{22,64}$/),
|
|
3822
|
+
scrub_disabled: z25.array(z25.enum(SCRUB_GROUPS)).max(SCRUB_GROUPS.length),
|
|
3823
|
+
upload_tokens: z25.array(z25.object({
|
|
3824
|
+
hash: z25.string().regex(/^[a-f0-9]{64}$/),
|
|
3825
|
+
expires_at: z25.string().datetime()
|
|
3587
3826
|
})).max(10).optional()
|
|
3588
3827
|
})).max(1000),
|
|
3589
|
-
ticket_keys:
|
|
3590
|
-
control_ops_keys:
|
|
3591
|
-
kill_switches:
|
|
3828
|
+
ticket_keys: z25.array(z25.object({ kid, public_key: publicKey, not_after: z25.string().datetime() })).min(1).max(5),
|
|
3829
|
+
control_ops_keys: z25.array(z25.object({ kid, public_key: publicKey })).min(1).max(5),
|
|
3830
|
+
kill_switches: z25.object({ ingest: z25.boolean(), alerts: z25.boolean() }),
|
|
3592
3831
|
backup: nodeBackupConfigSchema.optional(),
|
|
3593
|
-
purged_projects:
|
|
3594
|
-
monitors:
|
|
3595
|
-
purged_monitors:
|
|
3596
|
-
telemetry:
|
|
3597
|
-
traces_retention_days:
|
|
3598
|
-
logs_retention_days:
|
|
3599
|
-
traces_disk_share:
|
|
3832
|
+
purged_projects: z25.array(z25.number().int().positive()).max(1000).optional(),
|
|
3833
|
+
monitors: z25.array(monitorDefinitionSchema).max(MAX_NODE_MONITORS).optional(),
|
|
3834
|
+
purged_monitors: z25.array(z25.guid()).max(5000).optional(),
|
|
3835
|
+
telemetry: z25.object({
|
|
3836
|
+
traces_retention_days: z25.number().int().min(1).max(90),
|
|
3837
|
+
logs_retention_days: z25.number().int().min(1).max(90),
|
|
3838
|
+
traces_disk_share: z25.number().min(0.2).max(0.8)
|
|
3600
3839
|
}).optional(),
|
|
3601
|
-
|
|
3602
|
-
|
|
3840
|
+
metrics: metricsConfigSchema.optional(),
|
|
3841
|
+
slos: z25.array(nodeSloSchema).max(SLO_LIMITS.maxNodeSlos).optional(),
|
|
3842
|
+
signal_monitors: z25.array(signalMonitorDefinitionSchema).max(MAX_NODE_MONITORS).optional(),
|
|
3603
3843
|
signal_limits: signalLimitsConfigSchema.optional(),
|
|
3604
3844
|
privacy: nodePrivacyBlockSchema.optional()
|
|
3605
3845
|
});
|
|
3606
|
-
var signedNodeConfigSchema =
|
|
3846
|
+
var signedNodeConfigSchema = z25.object({ config: nodeConfigSchema, kid, sig: z25.string() });
|
|
3607
3847
|
|
|
3608
3848
|
// ../src/shared/contracts/api-ops/projects.ts
|
|
3609
|
-
var slug =
|
|
3610
|
-
var name3 =
|
|
3611
|
-
var
|
|
3612
|
-
var platform =
|
|
3613
|
-
var origin =
|
|
3614
|
-
var keyId =
|
|
3849
|
+
var slug = z26.string().regex(/^[a-z0-9][a-z0-9-]{1,38}[a-z0-9]$/);
|
|
3850
|
+
var name3 = z26.string().trim().min(1).max(60);
|
|
3851
|
+
var label2 = z26.string().trim().min(1).max(40);
|
|
3852
|
+
var platform = z26.enum(PLATFORMS);
|
|
3853
|
+
var origin = z26.string().trim().toLowerCase().regex(/^https?:\/\/[a-z0-9.-]+(:[0-9]{1,5})?$/).max(200);
|
|
3854
|
+
var keyId = z26.number().int().positive();
|
|
3615
3855
|
var PROJECT_INPUTS = {
|
|
3616
|
-
create:
|
|
3617
|
-
update:
|
|
3618
|
-
updateIntake:
|
|
3856
|
+
create: z26.object({ workspaceId: uuid, name: name3, slug, platform }),
|
|
3857
|
+
update: z26.object({ projectId, name: name3, platform, isPinned: z26.boolean() }),
|
|
3858
|
+
updateIntake: z26.object({
|
|
3619
3859
|
projectId,
|
|
3620
|
-
rateLimit:
|
|
3621
|
-
burst:
|
|
3622
|
-
allowedOrigins:
|
|
3860
|
+
rateLimit: z26.number().int().positive().nullable(),
|
|
3861
|
+
burst: z26.number().int().positive().nullable(),
|
|
3862
|
+
allowedOrigins: z26.array(origin).max(50)
|
|
3623
3863
|
}),
|
|
3624
|
-
updateObservability:
|
|
3864
|
+
updateObservability: z26.object({
|
|
3625
3865
|
projectId,
|
|
3626
|
-
primaryEnvironment:
|
|
3627
|
-
allowCodeMonitors:
|
|
3866
|
+
primaryEnvironment: z26.string().trim().min(1).max(64).refine((v) => v !== "*" && ENVIRONMENT_RE.test(v)),
|
|
3867
|
+
allowCodeMonitors: z26.boolean()
|
|
3628
3868
|
}),
|
|
3629
|
-
setScrub:
|
|
3630
|
-
setCheckinAuth:
|
|
3631
|
-
setEnvironmentHidden:
|
|
3869
|
+
setScrub: z26.object({ projectId, group: z26.enum(SCRUB_GROUPS), enabled: z26.boolean() }),
|
|
3870
|
+
setCheckinAuth: z26.object({ projectId, mode: z26.enum(CHECKIN_AUTH_MODES) }),
|
|
3871
|
+
setEnvironmentHidden: z26.object({
|
|
3632
3872
|
projectId,
|
|
3633
|
-
name:
|
|
3634
|
-
hidden:
|
|
3635
|
-
}),
|
|
3636
|
-
scheduleDeletion:
|
|
3637
|
-
projectOnly:
|
|
3638
|
-
labelled:
|
|
3639
|
-
keyOnly:
|
|
3640
|
-
tokenOnly:
|
|
3873
|
+
name: z26.string().min(1).max(64),
|
|
3874
|
+
hidden: z26.boolean()
|
|
3875
|
+
}),
|
|
3876
|
+
scheduleDeletion: z26.object({ projectId, confirmSlug: slug }),
|
|
3877
|
+
projectOnly: z26.object({ projectId }),
|
|
3878
|
+
labelled: z26.object({ projectId, label: label2 }),
|
|
3879
|
+
keyOnly: z26.object({ keyId }),
|
|
3880
|
+
tokenOnly: z26.object({ tokenId: keyId }),
|
|
3641
3881
|
createIngestKey: createIngestKeyInputSchema,
|
|
3642
|
-
ingestKeyOnly:
|
|
3882
|
+
ingestKeyOnly: z26.object({ keyId: uuid })
|
|
3643
3883
|
};
|
|
3644
3884
|
var P2 = PROJECT_INPUTS;
|
|
3645
3885
|
var PROJECT_OPERATIONS = [
|
|
@@ -3894,24 +4134,24 @@ var PROJECT_OPERATIONS = [
|
|
|
3894
4134
|
];
|
|
3895
4135
|
|
|
3896
4136
|
// ../src/shared/contracts/api-ops/reads.ts
|
|
3897
|
-
import { z as
|
|
3898
|
-
var list =
|
|
4137
|
+
import { z as z27 } from "zod";
|
|
4138
|
+
var list = z27.object({ workspaceId: uuid, limit: pageLimit, cursor });
|
|
3899
4139
|
var READ_INPUTS = {
|
|
3900
|
-
workspace:
|
|
4140
|
+
workspace: z27.object({ workspaceId: uuid }),
|
|
3901
4141
|
list,
|
|
3902
|
-
projectsGet:
|
|
4142
|
+
projectsGet: z27.object({ workspaceId: uuid, projectId }),
|
|
3903
4143
|
monitorsList: list.extend({ projectId: projectId.optional() }),
|
|
3904
|
-
monitorsGet:
|
|
3905
|
-
uptimeGet:
|
|
3906
|
-
slosGet:
|
|
4144
|
+
monitorsGet: z27.object({ workspaceId: uuid, monitorId: uuid }),
|
|
4145
|
+
uptimeGet: z27.object({ workspaceId: uuid, checkId: uuid }),
|
|
4146
|
+
slosGet: z27.object({ workspaceId: uuid, sloId: uuid }),
|
|
3907
4147
|
alertsList: list.extend({
|
|
3908
|
-
state:
|
|
4148
|
+
state: z27.enum(["open", "resolved", "all"]).default("all"),
|
|
3909
4149
|
monitorId: uuid.optional()
|
|
3910
4150
|
}),
|
|
3911
|
-
approvalsGet:
|
|
4151
|
+
approvalsGet: z27.object({ workspaceId: uuid, approvalId: uuid }),
|
|
3912
4152
|
monitorsListTyped: list.extend({
|
|
3913
4153
|
projectId: projectId.optional(),
|
|
3914
|
-
type:
|
|
4154
|
+
type: z27.enum(MONITOR_TYPES).optional()
|
|
3915
4155
|
})
|
|
3916
4156
|
};
|
|
3917
4157
|
var R = READ_INPUTS;
|
|
@@ -4195,14 +4435,14 @@ function approvalRequestSchema(operationId, input) {
|
|
|
4195
4435
|
}
|
|
4196
4436
|
|
|
4197
4437
|
// ../src/shared/contracts/api-ops/wire.ts
|
|
4198
|
-
import { z as
|
|
4438
|
+
import { z as z28 } from "zod";
|
|
4199
4439
|
var toSnake = (s) => s.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`);
|
|
4200
4440
|
var toCamel = (s) => s.replace(/_([a-z0-9])/g, (_, c) => c.toUpperCase());
|
|
4201
4441
|
var schemaCache = new WeakMap;
|
|
4202
4442
|
function inputJsonSchema(op) {
|
|
4203
4443
|
let js = schemaCache.get(op.input);
|
|
4204
4444
|
if (!js) {
|
|
4205
|
-
js =
|
|
4445
|
+
js = z28.toJSONSchema(op.input, { io: "input", unrepresentable: "any" });
|
|
4206
4446
|
schemaCache.set(op.input, js);
|
|
4207
4447
|
}
|
|
4208
4448
|
return js;
|
|
@@ -4416,7 +4656,7 @@ function wireInput(operationId, opts = {}) {
|
|
|
4416
4656
|
for (const [k, v] of Object.entries(op.input.shape))
|
|
4417
4657
|
if (!omit.has(k))
|
|
4418
4658
|
shape[toSnake(k)] = v;
|
|
4419
|
-
return
|
|
4659
|
+
return z29.object(shape);
|
|
4420
4660
|
}
|
|
4421
4661
|
var BUDGETS = [
|
|
4422
4662
|
{ stringBytes: MCP_LIMITS.untrustedStringMaxBytes, listMax: MCP_LIMITS.listMax },
|
|
@@ -4506,40 +4746,40 @@ function errorResult(o) {
|
|
|
4506
4746
|
}
|
|
4507
4747
|
};
|
|
4508
4748
|
}
|
|
4509
|
-
var TOOL_OUTPUT_SCHEMA =
|
|
4510
|
-
untrusted:
|
|
4511
|
-
data:
|
|
4512
|
-
provenance:
|
|
4513
|
-
source:
|
|
4514
|
-
operations:
|
|
4749
|
+
var TOOL_OUTPUT_SCHEMA = z29.object({
|
|
4750
|
+
untrusted: z29.object({
|
|
4751
|
+
data: z29.unknown(),
|
|
4752
|
+
provenance: z29.object({
|
|
4753
|
+
source: z29.enum(["node", "control_plane", "docs"]),
|
|
4754
|
+
operations: z29.array(z29.string())
|
|
4515
4755
|
})
|
|
4516
4756
|
}).optional(),
|
|
4517
|
-
doc:
|
|
4518
|
-
results:
|
|
4519
|
-
next_cursor:
|
|
4520
|
-
complete:
|
|
4521
|
-
omitted:
|
|
4522
|
-
truncated:
|
|
4523
|
-
suspicious_unicode:
|
|
4524
|
-
error:
|
|
4525
|
-
code:
|
|
4526
|
-
status:
|
|
4527
|
-
detail:
|
|
4528
|
-
scope:
|
|
4529
|
-
retry_after:
|
|
4757
|
+
doc: z29.object({ slug: z29.string(), locale: z29.enum(["en", "vi"]), url: z29.string(), markdown: z29.string(), truncated: z29.boolean() }).optional(),
|
|
4758
|
+
results: z29.array(z29.object({ slug: z29.string(), title: z29.string(), description: z29.string(), section: z29.string(), url: z29.string() })).optional(),
|
|
4759
|
+
next_cursor: z29.string().nullable().optional(),
|
|
4760
|
+
complete: z29.boolean().optional(),
|
|
4761
|
+
omitted: z29.array(z29.object({ part: z29.string(), reason: z29.string(), scope: z29.string().optional() })).optional(),
|
|
4762
|
+
truncated: z29.literal(true).optional(),
|
|
4763
|
+
suspicious_unicode: z29.literal(true).optional(),
|
|
4764
|
+
error: z29.object({
|
|
4765
|
+
code: z29.string(),
|
|
4766
|
+
status: z29.number(),
|
|
4767
|
+
detail: z29.string().optional(),
|
|
4768
|
+
scope: z29.string().optional(),
|
|
4769
|
+
retry_after: z29.number().optional()
|
|
4530
4770
|
}).optional(),
|
|
4531
|
-
operations:
|
|
4532
|
-
operation:
|
|
4533
|
-
plan:
|
|
4534
|
-
status:
|
|
4535
|
-
approval:
|
|
4536
|
-
approval_id:
|
|
4537
|
-
approval_url:
|
|
4538
|
-
expires_at:
|
|
4539
|
-
state:
|
|
4540
|
-
result_code:
|
|
4541
|
-
result:
|
|
4542
|
-
next:
|
|
4771
|
+
operations: z29.array(z29.record(z29.string(), z29.unknown())).optional(),
|
|
4772
|
+
operation: z29.record(z29.string(), z29.unknown()).optional(),
|
|
4773
|
+
plan: z29.record(z29.string(), z29.unknown()).optional(),
|
|
4774
|
+
status: z29.enum(["done", "approval_required", "approval_pending", ...APPROVAL_STATES]).optional(),
|
|
4775
|
+
approval: z29.object({
|
|
4776
|
+
approval_id: z29.string(),
|
|
4777
|
+
approval_url: z29.string(),
|
|
4778
|
+
expires_at: z29.string(),
|
|
4779
|
+
state: z29.enum(APPROVAL_STATES),
|
|
4780
|
+
result_code: z29.string().nullable().optional(),
|
|
4781
|
+
result: z29.record(z29.string(), z29.unknown()).optional(),
|
|
4782
|
+
next: z29.string().optional()
|
|
4543
4783
|
}).optional()
|
|
4544
4784
|
});
|
|
4545
4785
|
var spec = (name) => {
|
|
@@ -4585,10 +4825,10 @@ var has = (rt, operationId) => {
|
|
|
4585
4825
|
return !!op && rt.scopes.includes(op.scope);
|
|
4586
4826
|
};
|
|
4587
4827
|
var isoWindow = {
|
|
4588
|
-
start:
|
|
4589
|
-
end:
|
|
4828
|
+
start: z29.string().max(40).describe("RFC 3339 start of the window, e.g. 2026-10-26T00:00:00Z. Required with end."),
|
|
4829
|
+
end: z29.string().max(40).describe("RFC 3339 end of the window. The plan limits its length.")
|
|
4590
4830
|
};
|
|
4591
|
-
var traceIdSchema =
|
|
4831
|
+
var traceIdSchema = z29.string().regex(/^[0-9a-fA-F]{32}$/);
|
|
4592
4832
|
var MONITOR_KINDS2 = {
|
|
4593
4833
|
cron: { list: "monitors.list", get: "monitors.get", idField: "monitor_id" },
|
|
4594
4834
|
uptime: { list: "uptime.list", get: "uptime.get", idField: "check_id" },
|
|
@@ -4652,8 +4892,8 @@ function describe(op, scopes) {
|
|
|
4652
4892
|
destructive: isDestructiveOperation(op)
|
|
4653
4893
|
};
|
|
4654
4894
|
}
|
|
4655
|
-
var params =
|
|
4656
|
-
var operationIdArg =
|
|
4895
|
+
var params = z29.record(z29.string(), z29.unknown()).default({}).describe("Operation fields in wire names (snake_case), as describe_operation's args_schema shows.");
|
|
4896
|
+
var operationIdArg = z29.string().min(3).max(80).describe("An operation id from search_operations, e.g. `monitors.update`.");
|
|
4657
4897
|
function approvalBlock(t, next) {
|
|
4658
4898
|
return {
|
|
4659
4899
|
approval_id: t.approval_id,
|
|
@@ -4673,7 +4913,7 @@ var MCP_TOOL_DEFS = [
|
|
|
4673
4913
|
title: "Workspace and node",
|
|
4674
4914
|
description: "The workspace this token belongs to (name, plan, limits) and the state of its node, the server that stores errors, traces and logs. Start here to learn what the token can reach.",
|
|
4675
4915
|
operations: ["workspace.get", "node.get"],
|
|
4676
|
-
input:
|
|
4916
|
+
input: z29.object({}),
|
|
4677
4917
|
async run(_args, rt) {
|
|
4678
4918
|
const [ws, node] = await Promise.all([rt.call("workspace.get", {}), rt.call("node.get", {})]);
|
|
4679
4919
|
if (!ws.ok)
|
|
@@ -4691,9 +4931,9 @@ var MCP_TOOL_DEFS = [
|
|
|
4691
4931
|
title: "Get an issue",
|
|
4692
4932
|
description: "One issue with its 24 h and 30 d counts and, when the token can read events, its latest event (stack trace, request, breadcrumbs — scrubbed on the node).",
|
|
4693
4933
|
operations: ["issues.get", "events.get"],
|
|
4694
|
-
input:
|
|
4695
|
-
issue_id:
|
|
4696
|
-
include_latest_event:
|
|
4934
|
+
input: z29.object({
|
|
4935
|
+
issue_id: z29.number().int().positive().describe("Issue id from search_issues."),
|
|
4936
|
+
include_latest_event: z29.boolean().default(true)
|
|
4697
4937
|
}),
|
|
4698
4938
|
async run(args, rt) {
|
|
4699
4939
|
const omitted = [];
|
|
@@ -4721,9 +4961,9 @@ var MCP_TOOL_DEFS = [
|
|
|
4721
4961
|
title: "Get a trace",
|
|
4722
4962
|
description: "Summary of one distributed trace (services, duration, errors) by its 32-hex trace id, and optionally its spans (errors only, or the first page).",
|
|
4723
4963
|
operations: ["traces.get", "traces.spans"],
|
|
4724
|
-
input:
|
|
4964
|
+
input: z29.object({
|
|
4725
4965
|
trace_id: traceIdSchema.describe("W3C trace id, 32 hex characters."),
|
|
4726
|
-
spans:
|
|
4966
|
+
spans: z29.enum(["none", "errors", "all"]).default("none")
|
|
4727
4967
|
}),
|
|
4728
4968
|
async run(args, rt) {
|
|
4729
4969
|
const sum = await rt.call("traces.get", { trace_id: args["trace_id"] });
|
|
@@ -4746,16 +4986,70 @@ var MCP_TOOL_DEFS = [
|
|
|
4746
4986
|
},
|
|
4747
4987
|
single("search_spans", "spans.list", "Search spans", "OpenTelemetry spans in a time window (start and end required): filter by project, environment, service, operation, status, kind, duration or attribute filters (`attrs`, JSON list of {k, op, v}). mode=traces returns one row per trace."),
|
|
4748
4988
|
single("query_logs", "logs.list", "Query logs", "OpenTelemetry logs in a time window (start and end required): filter by project, environment, service, minimum severity, trace or span id, text `q` or attribute filters. Newest first unless order=asc."),
|
|
4989
|
+
{
|
|
4990
|
+
...spec("query_metrics"),
|
|
4991
|
+
title: "Query metrics",
|
|
4992
|
+
description: "OpenTelemetry metrics of one project. Without `name`: the metric catalog (name, type, unit, series count, last seen; `q` narrows by name) and the node's series caps. With `name` plus start and end: the metric aggregated per step — `aggregation` defaults to rate for counters, p95 for histograms and avg for gauges — optionally filtered by attributes (`attrs`, JSON list of {k, op, v}) and grouped by up to two attribute keys (`group_by`, comma-separated). Exemplar trace ids open with get_trace.",
|
|
4993
|
+
operations: ["metrics.names", "metrics.query"],
|
|
4994
|
+
input: z29.object({
|
|
4995
|
+
project: z29.number().int().positive().describe("Numeric project id from list_projects."),
|
|
4996
|
+
name: z29.string().regex(METRIC_NAME_RE).optional().describe("Metric name from the catalog, e.g. http.server.request.duration."),
|
|
4997
|
+
q: z29.string().max(255).optional().describe("Catalog only: part of a metric name."),
|
|
4998
|
+
aggregation: z29.enum(METRIC_AGGREGATIONS).optional(),
|
|
4999
|
+
start: isoWindow.start.optional(),
|
|
5000
|
+
end: isoWindow.end.optional(),
|
|
5001
|
+
step: z29.number().int().min(60).max(86400).multipleOf(60).optional().describe("Seconds per point (whole minutes); picked from the window when absent."),
|
|
5002
|
+
attrs: z29.string().max(2000).optional(),
|
|
5003
|
+
group_by: z29.string().max(600).optional(),
|
|
5004
|
+
environment: z29.string().max(2000).optional().describe("Comma-separated environments.")
|
|
5005
|
+
}),
|
|
5006
|
+
async run(args, rt) {
|
|
5007
|
+
const scope = { project: args["project"], ...args["environment"] ? { environment: args["environment"] } : {} };
|
|
5008
|
+
const name = args["name"];
|
|
5009
|
+
if (!name) {
|
|
5010
|
+
const r = await rt.call("metrics.names", { ...scope, ...args["q"] ? { q: args["q"] } : {} });
|
|
5011
|
+
if (!r.ok)
|
|
5012
|
+
return errorResult(r);
|
|
5013
|
+
return wrapResult({ data: r.body, operations: ["metrics.names"], source: "node" }, listExtra(r.body));
|
|
5014
|
+
}
|
|
5015
|
+
const ops = ["metrics.query"];
|
|
5016
|
+
let aggregation = args["aggregation"];
|
|
5017
|
+
if (!aggregation) {
|
|
5018
|
+
ops.unshift("metrics.names");
|
|
5019
|
+
const cat = await rt.call("metrics.names", { ...scope, q: name });
|
|
5020
|
+
if (!cat.ok)
|
|
5021
|
+
return errorResult(cat);
|
|
5022
|
+
const rows = cat.body?.names ?? [];
|
|
5023
|
+
const kind = rows.find((n) => n.name === name)?.kind;
|
|
5024
|
+
if (!METRIC_KINDS.includes(kind))
|
|
5025
|
+
return errorResult({ ok: false, status: 404, code: "NOT_FOUND", detail: "unknown_metric" });
|
|
5026
|
+
aggregation = defaultAggregation(kind);
|
|
5027
|
+
}
|
|
5028
|
+
const r = await rt.call("metrics.query", {
|
|
5029
|
+
...scope,
|
|
5030
|
+
name,
|
|
5031
|
+
aggregation,
|
|
5032
|
+
start: args["start"],
|
|
5033
|
+
end: args["end"],
|
|
5034
|
+
...args["step"] ? { step: args["step"] } : {},
|
|
5035
|
+
...args["attrs"] ? { attrs: args["attrs"] } : {},
|
|
5036
|
+
...args["group_by"] ? { group_by: args["group_by"] } : {}
|
|
5037
|
+
});
|
|
5038
|
+
if (!r.ok)
|
|
5039
|
+
return errorResult(r);
|
|
5040
|
+
return wrapResult({ data: r.body, operations: ops, source: "node" }, listExtra(r.body));
|
|
5041
|
+
}
|
|
5042
|
+
},
|
|
4749
5043
|
{
|
|
4750
5044
|
...spec("correlate"),
|
|
4751
5045
|
title: "Correlate by trace or run",
|
|
4752
5046
|
description: "Everything that shares one W3C trace id or one Belvador run id (`belvador.run.id`, set by job monitors) in a time window: the trace summary, its error spans and the logs. Give exactly one of trace_id or run_id.",
|
|
4753
5047
|
operations: ["traces.get", "traces.spans", "spans.list", "logs.list"],
|
|
4754
|
-
input:
|
|
5048
|
+
input: z29.object({
|
|
4755
5049
|
trace_id: traceIdSchema.optional(),
|
|
4756
|
-
run_id:
|
|
5050
|
+
run_id: z29.string().min(1).max(128).optional(),
|
|
4757
5051
|
...isoWindow,
|
|
4758
|
-
project:
|
|
5052
|
+
project: z29.string().max(2000).optional().describe("Comma-separated project ids.")
|
|
4759
5053
|
}),
|
|
4760
5054
|
async run(args, rt) {
|
|
4761
5055
|
const trace = args["trace_id"];
|
|
@@ -4800,10 +5094,10 @@ var MCP_TOOL_DEFS = [
|
|
|
4800
5094
|
title: "List monitors",
|
|
4801
5095
|
description: "Monitors (cron, heartbeat, count, assertion, deadline, progress), uptime checks and SLOs with their current status. `kind` narrows to one family; `project_id` to one project (cron and uptime).",
|
|
4802
5096
|
operations: ["monitors.list", "uptime.list", "slos.list"],
|
|
4803
|
-
input:
|
|
4804
|
-
kind:
|
|
4805
|
-
project_id:
|
|
4806
|
-
limit:
|
|
5097
|
+
input: z29.object({
|
|
5098
|
+
kind: z29.enum(["all", "cron", "uptime", "slo"]).default("all"),
|
|
5099
|
+
project_id: z29.number().int().positive().optional(),
|
|
5100
|
+
limit: z29.number().int().min(1).max(200).default(50)
|
|
4807
5101
|
}),
|
|
4808
5102
|
async run(args, rt) {
|
|
4809
5103
|
const kinds = args["kind"] && args["kind"] !== "all" ? [args["kind"]] : ["cron", "uptime", "slo"];
|
|
@@ -4831,10 +5125,10 @@ var MCP_TOOL_DEFS = [
|
|
|
4831
5125
|
title: "Get a monitor",
|
|
4832
5126
|
description: "One monitor (any type), uptime check or SLO by id: settings, current status and recent results. For count, assertion, deadline and progress monitors it adds the last 24 h of minute counts or runs from the node, and for deadline monitors the newest occurrences. `backtest: true` (count/assertion only) also replays the current settings over the last 30 days: how often it would have alerted.",
|
|
4833
5127
|
operations: ["monitors.get", "uptime.get", "slos.get", "monitors.signal", "monitors.occurrences", "monitors.backtest"],
|
|
4834
|
-
input:
|
|
4835
|
-
kind:
|
|
4836
|
-
id:
|
|
4837
|
-
backtest:
|
|
5128
|
+
input: z29.object({
|
|
5129
|
+
kind: z29.enum(["cron", "uptime", "slo"]),
|
|
5130
|
+
id: z29.guid(),
|
|
5131
|
+
backtest: z29.boolean().default(false)
|
|
4838
5132
|
}),
|
|
4839
5133
|
async run(args, rt) {
|
|
4840
5134
|
const k = MONITOR_KINDS2[args["kind"]];
|
|
@@ -4890,9 +5184,9 @@ var MCP_TOOL_DEFS = [
|
|
|
4890
5184
|
title: "Send a test event",
|
|
4891
5185
|
description: "Asks the node to send one tagged test error through the public intake of a project, proving the path real errors take. Not read-only: it creates one test event (reuse idempotency_key to retry without a second one).",
|
|
4892
5186
|
operations: ["projects.send_test_event"],
|
|
4893
|
-
input:
|
|
4894
|
-
project_id:
|
|
4895
|
-
idempotency_key:
|
|
5187
|
+
input: z29.object({
|
|
5188
|
+
project_id: z29.number().int().positive(),
|
|
5189
|
+
idempotency_key: z29.string().min(8).max(255).optional()
|
|
4896
5190
|
}),
|
|
4897
5191
|
async run(args, rt) {
|
|
4898
5192
|
const r = await rt.call("projects.send_test_event", { project_id: args["project_id"] }, { idempotencyKey: args["idempotency_key"] ?? rt.newKey() });
|
|
@@ -4906,9 +5200,9 @@ var MCP_TOOL_DEFS = [
|
|
|
4906
5200
|
title: "Find a configuration change",
|
|
4907
5201
|
description: "Searches what this token can change in its Belvador workspace: projects, keys and tokens, monitors of every type, maintenance windows, occurrences, uptime checks, SLOs, alert rules and destinations, members, service accounts and the node. Returns operation ids for describe_operation and plan_change, whether a person must approve the change, and whether this token holds the scope.",
|
|
4908
5202
|
operations: [],
|
|
4909
|
-
input:
|
|
4910
|
-
query:
|
|
4911
|
-
limit:
|
|
5203
|
+
input: z29.object({
|
|
5204
|
+
query: z29.string().min(1).max(200).describe("Words such as `rotate dsn key`, `heartbeat monitor`, `slack alert`."),
|
|
5205
|
+
limit: z29.number().int().min(1).max(20).default(10)
|
|
4912
5206
|
}),
|
|
4913
5207
|
async run(args, rt) {
|
|
4914
5208
|
const q = words(String(args["query"]));
|
|
@@ -4936,7 +5230,7 @@ var MCP_TOOL_DEFS = [
|
|
|
4936
5230
|
title: "Describe a configuration change",
|
|
4937
5231
|
description: "Everything needed to call one operation: its fields (JSON Schema, wire names), the scope, whether it needs If-Match (call plan_change for the current ETag), an idempotency key, or a person's approval, and which fields the approving person types on belvador.dev instead of the agent.",
|
|
4938
5232
|
operations: [],
|
|
4939
|
-
input:
|
|
5233
|
+
input: z29.object({ operation_id: operationIdArg }),
|
|
4940
5234
|
async run(args, rt) {
|
|
4941
5235
|
const op = configureOp(args["operation_id"]);
|
|
4942
5236
|
if (!op || op.method === "GET")
|
|
@@ -4965,7 +5259,7 @@ var MCP_TOOL_DEFS = [
|
|
|
4965
5259
|
title: "Check a change before applying it",
|
|
4966
5260
|
description: "Validates params for one operation without changing anything: field errors, missing scope, whether a person must approve, and — when the resource can be read — its current state, the fields that would change and the ETag to pass as if_match.",
|
|
4967
5261
|
operations: [],
|
|
4968
|
-
input:
|
|
5262
|
+
input: z29.object({ operation_id: operationIdArg, params }),
|
|
4969
5263
|
async run(args, rt) {
|
|
4970
5264
|
const op = configureOp(args["operation_id"]);
|
|
4971
5265
|
if (!op || op.method === "GET")
|
|
@@ -5014,11 +5308,11 @@ var MCP_TOOL_DEFS = [
|
|
|
5014
5308
|
title: "Apply a configuration change",
|
|
5015
5309
|
description: "Runs one operation with params (validate first with plan_change). Always send idempotency_key: repeating a call with the same key never applies it twice. Sensitive operations answer approval_required with an approval_url a person opens on belvador.dev; nothing changes until they approve with their authenticator code.",
|
|
5016
5310
|
operations: [],
|
|
5017
|
-
input:
|
|
5311
|
+
input: z29.object({
|
|
5018
5312
|
operation_id: operationIdArg,
|
|
5019
5313
|
params,
|
|
5020
|
-
idempotency_key:
|
|
5021
|
-
if_match:
|
|
5314
|
+
idempotency_key: z29.string().min(8).max(255).describe("Unique per change; reuse it to retry or to fetch the result."),
|
|
5315
|
+
if_match: z29.string().max(200).optional().describe("ETag from plan_change, for operations that need it.")
|
|
5022
5316
|
}),
|
|
5023
5317
|
async run(args, rt) {
|
|
5024
5318
|
const op = configureOp(args["operation_id"]);
|
|
@@ -5069,7 +5363,7 @@ var MCP_TOOL_DEFS = [
|
|
|
5069
5363
|
title: "Follow an approval",
|
|
5070
5364
|
description: "State of a change waiting for a person's approval: pending, approved, executed (with the ids it produced), rejected, expired or failed (with the error code).",
|
|
5071
5365
|
operations: ["approvals.get"],
|
|
5072
|
-
input:
|
|
5366
|
+
input: z29.object({ approval_id: z29.guid().describe("approval_id from apply_change.") }),
|
|
5073
5367
|
async run(args, rt) {
|
|
5074
5368
|
const r = await rt.call("approvals.get", { approval_id: args["approval_id"] });
|
|
5075
5369
|
if (!r.ok)
|
|
@@ -5089,10 +5383,10 @@ var MCP_TOOL_DEFS = [
|
|
|
5089
5383
|
title: "Search Belvador docs",
|
|
5090
5384
|
description: "Searches the public Belvador documentation (titles and summaries) and returns the best pages with their slugs for get_doc.",
|
|
5091
5385
|
operations: [],
|
|
5092
|
-
input:
|
|
5093
|
-
query:
|
|
5094
|
-
locale:
|
|
5095
|
-
limit:
|
|
5386
|
+
input: z29.object({
|
|
5387
|
+
query: z29.string().min(1).max(200),
|
|
5388
|
+
locale: z29.enum(["en", "vi"]).default("en"),
|
|
5389
|
+
limit: z29.number().int().min(1).max(10).default(5)
|
|
5096
5390
|
}),
|
|
5097
5391
|
async run(args, rt) {
|
|
5098
5392
|
const locale = args["locale"] ?? "en";
|
|
@@ -5108,9 +5402,9 @@ var MCP_TOOL_DEFS = [
|
|
|
5108
5402
|
title: "Read a docs page",
|
|
5109
5403
|
description: "The Markdown of one public Belvador docs page by slug (e.g. `quickstart`, `sdk/react`, `reference/api`).",
|
|
5110
5404
|
operations: [],
|
|
5111
|
-
input:
|
|
5112
|
-
slug:
|
|
5113
|
-
locale:
|
|
5405
|
+
input: z29.object({
|
|
5406
|
+
slug: z29.string().regex(/^[a-z0-9][a-z0-9/-]{0,120}$/),
|
|
5407
|
+
locale: z29.enum(["en", "vi"]).default("en")
|
|
5114
5408
|
}),
|
|
5115
5409
|
async run(args, rt) {
|
|
5116
5410
|
const locale = args["locale"] ?? "en";
|
|
@@ -5292,7 +5586,7 @@ function findToken(env = process.env, keychain = keychainToken) {
|
|
|
5292
5586
|
}
|
|
5293
5587
|
|
|
5294
5588
|
// packages/mcp/src/cli.ts
|
|
5295
|
-
var PACKAGE_VERSION = "0.
|
|
5589
|
+
var PACKAGE_VERSION = "0.5.0";
|
|
5296
5590
|
var HELP = `belvador-mcp ${PACKAGE_VERSION} — Belvador MCP server (stdio)
|
|
5297
5591
|
|
|
5298
5592
|
Usage: npx -y @belvador/mcp [--toolsets=${MCP_DEFAULT_TOOLSETS.join(",")}]
|