@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.
Files changed (2) hide show
  1. package/dist/cli.js +1225 -931
  2. 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 = 4;
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 z28 } from "zod";
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 z13 } from "zod";
1152
+ import { z as z14 } from "zod";
1153
1153
 
1154
1154
  // ../src/shared/contracts/notifications.ts
1155
- import { z as z12 } from "zod";
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 z11 } from "zod";
1214
+ import { z as z12 } from "zod";
1215
1215
 
1216
- // ../src/shared/contracts/monitors.ts
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 = z10.object({
1290
- type: z10.literal("crontab"),
1291
- value: z10.string().refine(crontabShapeOk, "crontab")
1457
+ var crontabScheduleSchema = z11.object({
1458
+ type: z11.literal("crontab"),
1459
+ value: z11.string().refine(crontabShapeOk, "crontab")
1292
1460
  });
1293
- var intervalScheduleSchema = z10.object({
1294
- type: z10.literal("interval"),
1295
- value: z10.number().int().min(1).max(MONITOR_LIMITS.intervalValueMax),
1296
- unit: z10.enum(INTERVAL_UNITS)
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 = z10.discriminatedUnion("type", [
1466
+ var scheduleSchema = z11.discriminatedUnion("type", [
1299
1467
  crontabScheduleSchema,
1300
1468
  intervalScheduleSchema
1301
1469
  ]);
1302
- var monitorSettingsSchema = z10.object({
1470
+ var monitorSettingsSchema = z11.object({
1303
1471
  schedule: scheduleSchema.nullable(),
1304
- timezone: z10.string().min(1).max(64),
1305
- checkin_margin: z10.number().int().min(MONITOR_LIMITS.checkinMarginMin).max(MONITOR_LIMITS.checkinMarginMax),
1306
- max_runtime: z10.number().int().min(MONITOR_LIMITS.maxRuntimeMin).max(MONITOR_LIMITS.maxRuntimeMax),
1307
- failure_issue_threshold: z10.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax),
1308
- recovery_threshold: z10.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax)
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 = z10.string().datetime();
1311
- var projectId3 = z10.number().int().positive();
1312
- var envName = z10.string().min(1).max(MONITOR_LIMITS.environmentMax);
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: z10.guid(),
1482
+ id: z11.guid(),
1315
1483
  project_id: projectId3,
1316
- slug: z10.string().regex(SLUG_RE),
1317
- kind: z10.enum(MONITOR_KINDS),
1318
- expected_environments: z10.array(envName).max(MONITOR_LIMITS.expectedEnvironmentsMax),
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: z10.enum(CONFIG_SOURCES),
1322
- config_hash: z10.string().regex(/^[0-9a-f]{64}$/).nullable()
1489
+ config_source: z11.enum(CONFIG_SOURCES),
1490
+ config_hash: z11.string().regex(/^[0-9a-f]{64}$/).nullable()
1323
1491
  });
1324
- var outcomeCounts = z10.object({
1325
- ok: z10.number().int().nonnegative(),
1326
- skipped: z10.number().int().nonnegative(),
1327
- error: z10.number().int().nonnegative(),
1328
- timeout: z10.number().int().nonnegative(),
1329
- missed: z10.number().int().nonnegative(),
1330
- unknown: z10.number().int().nonnegative()
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 signalStatusSchema = z10.object({
1333
- type: z10.enum(SIGNAL_MONITOR_TYPES),
1334
- value: z10.number().int().nonnegative().max(1e9).nullable(),
1335
- threshold: z10.number().int().nonnegative().max(1e9).nullable(),
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: z10.number().int().nonnegative().max(1e6).nullable(),
1338
- stalled: z10.number().int().nonnegative().max(1e6).nullable(),
1339
- refused_24h: z10.number().int().nonnegative().max(1e9).nullable()
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 = z10.object({
1342
- monitor_id: z10.guid(),
1511
+ var monitorStatusSchema = z11.object({
1512
+ monitor_id: z11.guid(),
1343
1513
  project_id: projectId3,
1344
1514
  environment: envName,
1345
- open_failure: z10.enum(FAILURE_INCIDENT_CODES).nullable(),
1346
- open_unknown: z10.boolean(),
1347
- unobservable: z10.enum(UNOBSERVABLE_REASONS).nullable(),
1348
- last_outcome: z10.enum(RUN_OUTCOMES).nullable(),
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: z10.boolean(),
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 = z10.object({
1359
- incident_id: z10.guid(),
1360
- monitor_id: z10.guid(),
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: z10.enum(MONITOR_INCIDENT_CODES),
1364
- event: z10.enum(INCIDENT_EVENTS),
1533
+ code: z11.enum(MONITOR_INCIDENT_CODES),
1534
+ event: z11.enum(INCIDENT_EVENTS),
1365
1535
  occurred_at: iso3,
1366
- detected_late: z10.boolean(),
1367
- reason: z10.string().regex(REASON_RE).nullable(),
1368
- duration_ms: z10.number().int().nonnegative().nullable(),
1369
- consecutive: z10.number().int().min(1).max(1e5),
1370
- reviewed_by: z10.guid().nullable(),
1371
- observed: z10.number().int().min(0).max(1e9).nullable().optional(),
1372
- threshold: z10.number().int().min(0).max(1e9).nullable().optional()
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 = z10.object({
1544
+ var monitorDiscoverySchema = z11.object({
1375
1545
  project_id: projectId3,
1376
- slug: z10.string().regex(SLUG_RE),
1546
+ slug: z11.string().regex(SLUG_RE),
1377
1547
  settings: monitorSettingsSchema.nullable(),
1378
- config_hash: z10.string().regex(/^[0-9a-f]{64}$/).nullable(),
1379
- check_ins: z10.number().int().nonnegative(),
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 = z10.string().trim().min(1).max(MONITOR_LIMITS.environmentMax).regex(/^[A-Za-z0-9._-]+$/);
1384
- var monitorInputSchema = z10.object({
1385
- name: z10.string().trim().min(1).max(MONITOR_LIMITS.nameMax),
1386
- mode: z10.enum(MONITOR_MODES).default("check_in"),
1387
- kind: z10.enum(MONITOR_KINDS),
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: z10.string().trim().min(1).max(64),
1390
- checkinMarginMin: z10.number().int().min(MONITOR_LIMITS.checkinMarginMin).max(MONITOR_LIMITS.checkinMarginMax),
1391
- maxRuntimeMin: z10.number().int().min(MONITOR_LIMITS.maxRuntimeMin).max(MONITOR_LIMITS.maxRuntimeMax),
1392
- failureThreshold: z10.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax),
1393
- recoveryThreshold: z10.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax),
1394
- expectedEnvironments: z10.array(environmentName).min(1).max(MONITOR_LIMITS.expectedEnvironmentsMax)
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 = z10.enum(RUN_OUTCOMES);
1410
- var runFlags = z10.array(z10.string().max(32)).max(16);
1411
- var monitorRunSchema = z10.object({
1412
- id: z10.number().int().positive(),
1413
- kind: z10.enum(["run", "missed"]),
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: z10.number().int().nonnegative(),
1418
- duration_ms: z10.number().int().nonnegative().nullable(),
1419
- reason: z10.string().max(64).nullable(),
1420
- check_in_id: z10.string().max(64).nullable(),
1421
- trace_id: z10.string().max(32).nullable(),
1422
- release: z10.string().max(MONITOR_LIMITS.releaseMax).nullable(),
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 = z10.object({
1426
- check_in_id: z10.string().max(64),
1427
- run_key: z10.string().max(64),
1428
- attempt: z10.number().int().nonnegative(),
1429
- state: z10.string().max(16),
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 = z10.object({
1434
- open: z10.array(openAttemptSchema).max(100),
1435
- runs: z10.array(monitorRunSchema).max(MONITOR_LIMITS.runsPageSize),
1436
- next_cursor: z10.string().max(32).nullable()
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 = z10.object({
1439
- id: z10.number().int().positive(),
1440
- kind: z10.enum(["run", "missed"]),
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 = z10.object({
1446
- runs: z10.array(timelineRunSchema).max(MONITOR_LIMITS.timelineRuns)
1615
+ var monitorTimelineResponseSchema = z11.object({
1616
+ runs: z11.array(timelineRunSchema).max(MONITOR_LIMITS.timelineRuns)
1447
1617
  });
1448
- var monitorStripsResponseSchema = z10.object({
1449
- strips: z10.array(z10.object({
1450
- monitor_id: z10.guid(),
1618
+ var monitorStripsResponseSchema = z11.object({
1619
+ strips: z11.array(z11.object({
1620
+ monitor_id: z11.guid(),
1451
1621
  environment: envName,
1452
- runs: z10.array(timelineRunSchema).max(MONITOR_LIMITS.listStripRuns)
1622
+ runs: z11.array(timelineRunSchema).max(MONITOR_LIMITS.listStripRuns)
1453
1623
  })).max(5000)
1454
1624
  });
1455
- var monitorDiagnosticSchema = z10.object({
1456
- id: z10.string().regex(/^\d{1,19}$/),
1457
- check_in_id: z10.string().max(64).nullable(),
1458
- signal: z10.string().max(16),
1459
- exit_code: z10.number().int().min(0).max(255).nullable(),
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: z10.string().max(MONITOR_LIMITS.diagnosticMaxBytes * 2)
1631
+ body: z11.string().max(MONITOR_LIMITS.diagnosticMaxBytes * 2)
1462
1632
  });
1463
- var monitorDiagnosticsResponseSchema = z10.object({
1464
- diagnostics: z10.array(monitorDiagnosticSchema).max(50),
1465
- next_cursor: z10.string().regex(/^\d{1,19}$/).nullable()
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 = z10.object({
1468
- run_key: z10.string().max(64),
1469
- attempts: z10.array(z10.object({
1470
- check_in_id: z10.string().max(64),
1471
- attempt: z10.number().int().nonnegative(),
1472
- result: z10.string().max(16),
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: z10.number().int().nonnegative().nullable(),
1476
- reason: z10.string().max(64).nullable(),
1477
- trace_id: z10.string().max(32).nullable(),
1478
- release: z10.string().max(MONITOR_LIMITS.releaseMax).nullable()
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: z10.array(z10.object({
1481
- event_id: z10.string().max(64),
1482
- issue_id: z10.number().int().nonnegative(),
1483
- title: z10.string().max(1024),
1484
- level: z10.string().max(16),
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: z10.boolean()
1656
+ same_trace: z11.boolean()
1487
1657
  })).max(50),
1488
- diagnostics: z10.array(monitorDiagnosticSchema).max(20).default([])
1658
+ diagnostics: z11.array(monitorDiagnosticSchema).max(20).default([])
1489
1659
  });
1490
- var incidentReviewSchema = z10.object({ incident_id: z10.guid() });
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 = z11.union([z11.string().max(SIGNAL_LIMITS.valueMax), z11.number().finite(), z11.boolean()]);
1544
- var selectorConditionSchema = z11.object({
1545
- key: z11.string().min(1).max(SIGNAL_LIMITS.keyMax).regex(SELECTOR_KEY_RE),
1546
- op: z11.enum(SELECTOR_OPS),
1547
- value: z11.union([scalar, z11.array(z11.string().max(SIGNAL_LIMITS.valueMax)).min(1).max(SIGNAL_LIMITS.inValuesMax)]).optional()
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 = z11.array(z11.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");
1570
- var selectorSchema = z11.object({
1571
- signal: z11.enum(SIGNAL_KINDS),
1572
- match: z11.array(selectorConditionSchema).max(SIGNAL_LIMITS.matchMax)
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) => z11.number().int().min(min).max(max);
1584
- var threshold = z11.number().int().min(0).max(SIGNAL_LIMITS.thresholdMax);
1585
- var recovery = z11.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax);
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: z11.enum(SEVERITIES),
1759
+ severity: z12.enum(SEVERITIES),
1589
1760
  recovery_threshold: recovery
1590
1761
  };
1591
- var countSettingsSchema = z11.object({
1592
- type: z11.literal("count"),
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: z11.enum(COMPARATORS),
1766
+ comparator: z12.enum(COMPARATORS),
1596
1767
  threshold,
1597
1768
  threshold_high: threshold.nullable(),
1598
- missing_data: z11.enum(MISSING_DATA_POLICIES),
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 = z11.object({
1612
- type: z11.literal("assertion"),
1782
+ var assertionSettingsSchema = z12.object({
1783
+ type: z12.literal("assertion"),
1613
1784
  selector: selectorSchema,
1614
- assert: z11.array(selectorConditionSchema).min(1).max(SIGNAL_LIMITS.assertMax),
1785
+ assert: z12.array(selectorConditionSchema).min(1).max(SIGNAL_LIMITS.assertMax),
1615
1786
  window_minutes: minutes(SIGNAL_LIMITS.windowMinutesMin, SIGNAL_LIMITS.windowMinutesMax),
1616
- threshold: z11.number().int().min(1).max(SIGNAL_LIMITS.thresholdMax),
1617
- missing_data: z11.enum(MISSING_DATA_POLICIES),
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 = z11.object({
1621
- type: z11.literal("deadline"),
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 = z11.object({
1627
- type: z11.literal("progress"),
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 signalSettingsSchema = z11.discriminatedUnion("type", [
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 = z11.object({
1650
- name: z11.string().trim().min(1).max(MONITOR_LIMITS.nameMax),
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 = z11.object({
1654
- id: z11.guid(),
1655
- project_id: z11.number().int().positive(),
1656
- slug: z11.string().regex(SLUG_RE),
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: z11.string().datetime().nullable(),
1659
- created_at: z11.string().datetime(),
1660
- revision: z11.number().int().nonnegative()
1846
+ paused_until: z12.string().datetime().nullable(),
1847
+ created_at: z12.string().datetime(),
1848
+ revision: z12.number().int().nonnegative()
1661
1849
  });
1662
- var signalLimitsConfigSchema = z11.object({
1663
- pending_occurrences_per_monitor: z11.number().int().min(1).max(1e6),
1664
- pending_occurrences_per_project: z11.number().int().min(1).max(1e7)
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 = z11.object({
1668
- monitor_slug: z11.string().regex(SLUG_RE),
1669
- occurrence_id: z11.string().regex(OCCURRENCE_ID_RE),
1670
- due_at: z11.string().datetime({ offset: true }),
1671
- environment: z11.string().trim().min(1).max(MONITOR_LIMITS.environmentMax).regex(/^[A-Za-z0-9._-]+$/).optional()
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 = z11.object({
1676
- occurrence_id: z11.string().max(SIGNAL_LIMITS.occurrenceIdMax),
1677
- environment: z11.string().max(MONITOR_LIMITS.environmentMax),
1678
- state: z11.enum(OCCURRENCE_STATES),
1679
- due_at: z11.string().datetime(),
1680
- deadline_at: z11.string().datetime(),
1681
- registered_at: z11.string().datetime(),
1682
- started_at: z11.string().datetime().nullable(),
1683
- last_signal_at: z11.string().datetime().nullable(),
1684
- ended_at: z11.string().datetime().nullable(),
1685
- stalled: z11.boolean()
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 = z11.object({
1688
- occurrences: z11.array(occurrenceRowSchema).max(SIGNAL_LIMITS.occurrencesPageSize),
1689
- pending: z11.number().int().nonnegative(),
1690
- next_due_at: z11.string().datetime().nullable(),
1691
- next_cursor: z11.string().max(64).nullable(),
1692
- refused_24h: z11.number().int().nonnegative()
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 = z11.object({
1695
- environment: z11.string().max(MONITOR_LIMITS.environmentMax),
1696
- buckets: z11.array(z11.object({ minute: z11.string().datetime(), matched: z11.number().int().nonnegative(), violations: z11.number().int().nonnegative(), lossy: z11.boolean() })).max(1440),
1697
- counted_through: z11.string().datetime().nullable()
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 = z11.object({
1700
- series: z11.array(signalSeriesSchema).max(SIGNAL_LIMITS.environmentsMax),
1701
- runs: z11.array(z11.object({
1702
- run_id: z11.string().max(SIGNAL_LIMITS.occurrenceIdMax),
1703
- environment: z11.string().max(MONITOR_LIMITS.environmentMax),
1704
- started_at: z11.string().datetime(),
1705
- last_signal_at: z11.string().datetime(),
1706
- stalled: z11.boolean()
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 = z11.union([countSettingsSchema, assertionSettingsSchema]);
1710
- var backtestResponseSchema = z11.object({
1711
- alerts: z11.number().int().nonnegative(),
1712
- windows: z11.number().int().nonnegative(),
1713
- violated_windows: z11.number().int().nonnegative(),
1714
- first_at: z11.string().datetime().nullable(),
1715
- last_at: z11.string().datetime().nullable(),
1716
- days: z11.number().nonnegative(),
1717
- matched_total: z11.number().int().nonnegative(),
1718
- violations_total: z11.number().int().nonnegative()
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 = z12.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/);
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 = z12.object({
1736
- days: z12.array(weekdaySchema).min(1).max(7).refine(unique),
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 = z12.object({
1741
- name: z12.string().trim().min(1).max(NOTIFY_LIMITS.nameMax).regex(/^[^\p{Cc}]*$/u),
1742
- timezone: z12.string().trim().min(1).max(64).refine(validTimeZone),
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: z12.array(z12.enum(HOLDABLE_SEVERITIES)).max(2).refine(unique),
1745
- digest: z12.enum(DIGEST_MODES),
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: z12.array(z12.enum(HOLDABLE_SEVERITIES)).max(2).refine(unique),
1748
- fallback: z12.array(z12.guid()).max(NOTIFY_LIMITS.chainMax).refine(unique),
1749
- escalateAfterMinutes: z12.number().int().min(NOTIFY_LIMITS.escalateMinutesMin).max(NOTIFY_LIMITS.escalateMinutesMax).nullable(),
1750
- escalation: z12.array(z12.guid()).max(NOTIFY_LIMITS.chainMax).refine(unique)
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 = z13.object({ workspaceId: uuid, incidentId: uuid });
1763
- var note2 = z13.string().trim().min(1).max(2000).regex(/^[^\u0000-\u0008\u000b\u000c\u000e-\u001f]*$/);
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 = z13.object({
1767
- name: z13.string().trim().min(1).max(80).regex(/^[^\p{Cc}]*$/u),
1768
- isEnabled: z13.boolean(),
1769
- position: z13.number().int().min(0).max(1000).default(0),
1770
- projectIds: z13.array(z13.number().int().positive()).max(50),
1771
- environments: z13.array(z13.string().trim().min(1).max(64)).max(20),
1772
- kinds: z13.array(z13.enum(INCIDENT_KINDS)).min(1).max(4),
1773
- minSeverity: z13.enum(SEVERITIES),
1774
- groupBy: z13.enum(INCIDENT_GROUP_BY),
1775
- windowMinutes: z13.number().int().min(5).max(240),
1776
- recoveryHoldMinutes: z13.number().int().min(0).max(1440)
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: z13.object({
1967
+ list: z14.object({
1780
1968
  workspaceId: uuid,
1781
1969
  limit: pageLimit,
1782
1970
  cursor,
1783
- state: z13.enum(["active", "resolved", "all"]).default("all")
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: z13.string().trim().min(1).max(120).regex(/^[^\p{Cc}]*$/u).optional(),
1977
+ title: z14.string().trim().min(1).max(120).regex(/^[^\p{Cc}]*$/u).optional(),
1790
1978
  ownerUserId: uuid.nullable().optional()
1791
1979
  }),
1792
- workspace: z13.object({ workspaceId: uuid }),
1793
- saveRule: z13.object({ workspaceId: uuid, ruleId: uuid.nullable(), input: incidentRuleInputSchema }),
1794
- ruleOnly: z13.object({ workspaceId: uuid, ruleId: uuid }),
1795
- savePolicy: z13.object({
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: z13.boolean(),
1986
+ isDefault: z14.boolean(),
1799
1987
  input: policyInputSchema
1800
1988
  }),
1801
- policyOnly: z13.object({ workspaceId: uuid, policyId: uuid })
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 z18 } from "zod";
2178
+ import { z as z19 } from "zod";
1991
2179
 
1992
2180
  // ../src/shared/contracts/heartbeat.ts
1993
- import { z as z15 } from "zod";
2181
+ import { z as z16 } from "zod";
1994
2182
 
1995
2183
  // ../src/shared/contracts/signed-message.ts
1996
- import { z as z14 } from "zod";
1997
- var nodeIdSchema = z14.guid();
1998
- var signedEnvelopeSchema = z14.object({
2184
+ import { z as z15 } from "zod";
2185
+ var nodeIdSchema = z15.guid();
2186
+ var signedEnvelopeSchema = z15.object({
1999
2187
  node_id: nodeIdSchema,
2000
- ts: z14.number().int().positive(),
2001
- nonce: z14.string().regex(/^[A-Za-z0-9_-]{16,64}$/),
2002
- payload: z14.record(z14.string(), z14.unknown()),
2003
- sig: z14.string().regex(/^[A-Za-z0-9_-]{86}$/)
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 = z15.guid();
2042
- var ms = z15.number().int().nonnegative();
2043
- var hex64 = z15.string().regex(/^[0-9a-f]{64}$/);
2044
- var envName2 = z15.string().min(1).max(MONITOR_LIMITS.environmentMax);
2045
- var heartbeatMonitorConfigSchema = z15.object({
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: z15.number().int().positive(),
2048
- slug: z15.string().regex(SLUG_RE),
2235
+ project_id: z16.number().int().positive(),
2236
+ slug: z16.string().regex(SLUG_RE),
2049
2237
  environment: envName2,
2050
2238
  schedule: scheduleSchema,
2051
- timezone: z15.string().min(1).max(64),
2052
- grace_min: z15.number().int().min(MONITOR_LIMITS.checkinMarginMin).max(MONITOR_LIMITS.checkinMarginMax),
2053
- max_runtime_min: z15.number().int().min(MONITOR_LIMITS.maxRuntimeMin).max(MONITOR_LIMITS.maxRuntimeMax),
2054
- failure_threshold: z15.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax),
2055
- recovery_threshold: z15.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax),
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 = z15.object({
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 = z15.object({
2066
- v: z15.literal(1),
2253
+ var heartbeatSyncSchema = z16.object({
2254
+ v: z16.literal(1),
2067
2255
  workspace_id: uuid2,
2068
- route: z15.string().regex(PING_ROUTE_RE),
2069
- revision: z15.number().int().positive(),
2070
- workspace_status: z15.enum(["active", "suspended", "deleting"]),
2071
- ingest_kill: z15.boolean(),
2072
- limits: z15.object({
2073
- check_in_rate_per_sec: z15.number().int().positive(),
2074
- check_in_burst: z15.number().int().positive(),
2075
- monthly_check_in_cap: z15.number().int().positive()
2076
- }),
2077
- projects: z15.array(z15.object({ id: z15.number().int().positive(), node_id: nodeIdSchema.nullable() })).max(1000),
2078
- monitors: z15.array(heartbeatMonitorConfigSchema).max(HEARTBEAT_LIMITS.maxMonitorsPerWorkspace),
2079
- tokens: z15.array(heartbeatTokenConfigSchema).max(HEARTBEAT_LIMITS.maxMonitorsPerWorkspace * 2)
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 = z15.object({
2082
- body: z15.string().min(2).max(4 * 1024 * 1024),
2083
- ts: z15.number().int().positive(),
2084
- kid: z15.string().regex(/^[A-Za-z0-9_-]{1,40}$/),
2085
- sig: z15.string().regex(/^[A-Za-z0-9_-]{86}$/)
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 = z15.object({
2275
+ var heartbeatHourSchema = z16.object({
2088
2276
  monitor_id: uuid2,
2089
- hour: z15.string().datetime(),
2090
- ok: z15.number().int().nonnegative(),
2091
- failed: z15.number().int().nonnegative(),
2092
- started: z15.number().int().nonnegative(),
2093
- missed: z15.number().int().nonnegative(),
2094
- logs: z15.number().int().nonnegative()
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 = z15.object({
2097
- v: z15.literal(1),
2284
+ var heartbeatReportSchema = z16.object({
2285
+ v: z16.literal(1),
2098
2286
  workspace_id: uuid2,
2099
- route: z15.string().regex(PING_ROUTE_RE),
2100
- revision: z15.number().int().nonnegative(),
2101
- sent_at: z15.string().datetime(),
2102
- incidents: z15.array(monitorIncidentSchema).max(HEARTBEAT_LIMITS.reportMaxIncidents),
2103
- statuses: z15.array(monitorStatusSchema).max(HEARTBEAT_LIMITS.reportMaxStatuses),
2104
- hours: z15.array(heartbeatHourSchema).max(HEARTBEAT_LIMITS.reportMaxHours),
2105
- token_uses: z15.array(z15.object({ token_id: uuid2, last_used_at: z15.string().datetime() })).max(HEARTBEAT_LIMITS.maxMonitorsPerWorkspace * 2)
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 z16 } from "zod";
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 = z16.object({
2145
- slo_id: z16.guid(),
2146
- project_id: z16.number().int().positive(),
2147
- source: z16.enum(["monitor", "spans"]),
2148
- sli: z16.enum(SLO_SLIS),
2149
- monitor_id: z16.guid().optional(),
2150
- environment: z16.string().min(1).max(SLO_LIMITS.environmentMaxChars).optional(),
2151
- service: z16.string().min(1).max(128).optional(),
2152
- operation: z16.string().min(1).max(256).optional(),
2153
- latency_threshold_ms: z16.number().int().min(1).max(60000).optional(),
2154
- public_sources: z16.boolean()
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 = z16.object({
2164
- minute: z16.string().datetime(),
2165
- items: z16.array(z16.object({ slo_id: z16.guid(), good: z16.number().int().min(0), total: z16.number().int().min(0) }).refine((x) => x.good <= x.total, { message: "INVALID_INPUT" })).max(SLO_LIMITS.sliItemsPerMessage)
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 = z16.object({
2168
- name: z16.string().trim().min(1).max(SLO_LIMITS.nameMaxChars),
2169
- description: z16.string().max(SLO_LIMITS.descriptionMaxChars).default(""),
2170
- source: z16.enum(SLO_SOURCES),
2171
- sourceRef: z16.object({
2172
- id: z16.guid().optional(),
2173
- projectId: z16.number().int().positive().optional(),
2174
- service: z16.string().max(128).optional(),
2175
- operation: z16.string().max(256).optional(),
2176
- environment: z16.string().max(SLO_LIMITS.environmentMaxChars).optional()
2177
- }),
2178
- sli: z16.enum(SLO_SLIS),
2179
- latencyThresholdMs: z16.number().int().min(1).max(60000).nullable(),
2180
- objective: z16.number().min(SLO_LIMITS.objectiveMin).max(SLO_LIMITS.objectiveMax),
2181
- windowDays: z16.union([z16.literal(7), z16.literal(28), z16.literal(30)]),
2182
- alertPolicy: z16.enum(SLO_ALERT_POLICIES),
2183
- allowPublicSources: z16.boolean().default(false)
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 z17 } from "zod";
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 = z17.string().min(1).max(UPTIME_LIMITS.assertionTextMax);
2272
- var statusRange = z17.string().regex(/^[1-5][0-9]{2}(-[1-5][0-9]{2})?$/);
2273
- var assertionSchema = z17.discriminatedUnion("type", [
2274
- z17.object({ type: z17.literal("status"), in: z17.array(statusRange).min(1).max(10) }),
2275
- z17.object({ type: z17.literal("body_contains"), value: text, case_sensitive: z17.boolean().default(true) }),
2276
- z17.object({ type: z17.literal("body_not_contains"), value: text, case_sensitive: z17.boolean().default(true) }),
2277
- z17.object({
2278
- type: z17.literal("json_pointer"),
2279
- pointer: z17.string().max(256).regex(/^(\/([^~/]|~0|~1)*)*$/),
2280
- op: z17.enum(["exists", "equals", "type"]),
2281
- value: z17.string().max(UPTIME_LIMITS.assertionTextMax).optional()
2282
- }),
2283
- z17.object({
2284
- type: z17.literal("header"),
2285
- name: z17.string().min(1).max(UPTIME_LIMITS.headerNameMax).regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/),
2286
- op: z17.enum(["equals", "contains", "exists"]),
2287
- value: z17.string().max(UPTIME_LIMITS.assertionTextMax).optional()
2288
- }),
2289
- z17.object({ type: z17.literal("latency_ms"), lt: z17.number().int().min(1).max(60000) }),
2290
- z17.object({ type: z17.literal("tls_valid") })
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 = z17.object({
2293
- name: z17.string().min(1).max(UPTIME_LIMITS.headerNameMax).regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/),
2294
- value: z17.string().max(UPTIME_LIMITS.headerValueMax).regex(/^[^\r\n\u0000]*$/)
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 = z17.object({
2297
- projectId: z17.number().int().positive(),
2298
- name: z17.string().trim().min(1).max(UPTIME_LIMITS.nameMaxChars),
2299
- kind: z17.enum(UPTIME_KINDS),
2300
- url: z17.string().max(UPTIME_LIMITS.urlMaxChars).nullable(),
2301
- host: z17.string().max(253).nullable(),
2302
- port: z17.number().int().min(1).max(65535).nullable(),
2303
- method: z17.enum(UPTIME_METHODS).default("GET"),
2304
- headers: z17.array(header).max(UPTIME_LIMITS.headersMax).default([]),
2305
- followRedirects: z17.boolean().default(false),
2306
- timeoutMs: z17.number().int().min(UPTIME_LIMITS.timeoutMs.min).max(UPTIME_LIMITS.timeoutMs.max),
2307
- intervalSeconds: z17.number().int().refine((n) => UPTIME_INTERVALS.includes(n)),
2308
- regions: z17.array(z17.enum(UPTIME_REGIONS)).min(UPTIME_LIMITS.minRegions).max(UPTIME_REGIONS.length),
2309
- assertions: z17.array(assertionSchema).max(UPTIME_LIMITS.assertionsMax).default([]),
2310
- failureThreshold: z17.number().int().min(1).max(5),
2311
- recoveryThreshold: z17.number().int().min(1).max(5),
2312
- certWarningDays: z17.number().int().min(1).max(60),
2313
- environment: z17.string().trim().max(64).default(""),
2314
- strictMetadata: z17.boolean().default(false),
2315
- evidenceOnFailure: z17.boolean().default(true)
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 = z17.object({
2327
- check_id: z17.guid(),
2328
- workspace_id: z17.guid(),
2329
- project_id: z17.number().int().positive(),
2330
- revision: z17.number().int().nonnegative(),
2331
- kind: z17.enum(UPTIME_KINDS),
2332
- url: z17.string().max(UPTIME_LIMITS.urlMaxChars).nullable(),
2333
- host: z17.string().max(253).nullable(),
2334
- port: z17.number().int().min(1).max(65535).nullable(),
2335
- method: z17.enum(UPTIME_METHODS),
2336
- headers: z17.array(header).max(UPTIME_LIMITS.headersMax),
2337
- follow_redirects: z17.boolean(),
2338
- timeout_ms: z17.number().int().min(UPTIME_LIMITS.timeoutMs.min).max(UPTIME_LIMITS.timeoutMs.max),
2339
- interval_seconds: z17.number().int().positive(),
2340
- regions: z17.array(z17.enum(UPTIME_REGIONS)).min(1).max(3),
2341
- assertions: z17.array(assertionSchema).max(UPTIME_LIMITS.assertionsMax),
2342
- failure_threshold: z17.number().int().min(1).max(5),
2343
- recovery_threshold: z17.number().int().min(1).max(5),
2344
- cert_warning_days: z17.number().int().min(1).max(60),
2345
- strict_metadata: z17.boolean(),
2346
- evidence_on_failure: z17.boolean(),
2347
- paused_until: z17.string().nullable(),
2348
- muted_until: z17.string().nullable()
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 = z17.object({
2351
- dns_ms: z17.number().nonnegative().max(60000).nullable(),
2352
- connect_ms: z17.number().nonnegative().max(60000).nullable(),
2353
- tls_ms: z17.number().nonnegative().max(60000).nullable(),
2354
- ttfb_ms: z17.number().nonnegative().max(60000).nullable(),
2355
- download_ms: z17.number().nonnegative().max(60000).nullable(),
2356
- total_ms: z17.number().nonnegative().max(60000)
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 = z17.object({
2359
- check_id: z17.guid(),
2360
- revision: z17.number().int().nonnegative(),
2361
- slot: z17.number().int().nonnegative(),
2362
- region: z17.enum(UPTIME_REGIONS),
2363
- run_now: z17.string().max(64).optional(),
2364
- scheduled_at: z17.number().int().positive(),
2365
- started_at: z17.number().int().positive(),
2366
- outcome: z17.enum(UPTIME_OUTCOMES),
2367
- reason: z17.enum(UPTIME_REASONS).nullable(),
2368
- reason_group: z17.enum(UPTIME_REASON_GROUPS).nullable(),
2369
- status_code: z17.number().int().min(100).max(599).nullable(),
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: z17.enum(["v4", "v6"]).nullable(),
2372
- http_version: z17.string().max(8).nullable(),
2373
- cert_not_after: z17.number().int().positive().nullable(),
2374
- cert_issuer: z17.string().max(200).nullable(),
2375
- cert_expiring: z17.boolean(),
2376
- evidence_sealed: z17.string().max(16384).nullable()
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 = z17.string().regex(/^probe-(eu|us|ap)-[a-z0-9]{4,16}$/);
2379
- var resultBatchSchema = z17.object({
2380
- v: z17.literal(1),
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: z17.enum(UPTIME_REGIONS),
2383
- version: z17.string().max(40),
2384
- sent_at: z17.number().int().positive(),
2385
- results: z17.array(probeResultSchema).max(UPTIME_LIMITS.resultsBatchMax),
2386
- stats: z17.object({ lag_p99_ms: z17.number().nonnegative(), checks_per_min: z17.number().nonnegative() })
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: z17.string().regex(/^[A-Za-z0-9_-]{43}$/).nullable()
2577
+ seal_public_key: z18.string().regex(/^[A-Za-z0-9_-]{43}$/).nullable()
2390
2578
  });
2391
- var assignmentsSchema = z17.object({
2392
- v: z17.literal(1),
2393
- region: z17.enum(UPTIME_REGIONS),
2394
- revision: z17.number().int().nonnegative(),
2395
- issued_at: z17.number().int().positive(),
2396
- checks: z17.array(assignmentSchema).max(50000),
2397
- denied_hosts: z17.array(z17.string().max(253)).max(1e4),
2398
- run_now: z17.array(z17.object({ id: z17.string().max(64), check_id: z17.guid(), expires_at: z17.number().int() })).max(500)
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 = z17.guid();
2401
- var b64key = z17.string().regex(/^[A-Za-z0-9_-]{43}$/);
2402
- var iso4 = z17.string().datetime();
2403
- var uptimeSyncSchema = z17.object({
2404
- v: z17.literal(1),
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: z17.number().int().positive(),
2407
- workspace_status: z17.enum(["active", "suspended", "deleting"]),
2408
- suspended: z17.boolean(),
2409
- checks: z17.array(uptimeDefinitionSchema).max(UPTIME_LIMITS.maxChecksPerWorkspace),
2410
- projects: z17.array(z17.object({ id: z17.number().int().positive(), node_id: z17.guid().nullable(), seal_public_key: b64key.nullable() })).max(1000)
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 = z17.object({
2413
- v: z17.literal(1),
2414
- as_of: z17.number().int().positive(),
2415
- workspace_ids: z17.array(uuid3).max(UPTIME_LIMITS.reconcileMaxWorkspaces),
2416
- heartbeat_routes: z17.array(z17.string().regex(PING_ROUTE_RE)).max(UPTIME_LIMITS.reconcileMaxWorkspaces).optional()
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 = z17.object({
2419
- v: z17.literal(1),
2420
- revision: z17.number().int().positive(),
2421
- probes: z17.array(z17.object({ probe_id: probeIdSchema, region: z17.enum(UPTIME_REGIONS), public_key: b64key, status: z17.enum(["active", "revoked"]) })).max(30),
2422
- denied_hosts: z17.array(z17.string().min(1).max(253)).max(1e4)
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 = z17.object({ v: z17.literal(1), workspace_id: uuid3, check_id: uuid3, run_id: z17.string().regex(/^[A-Za-z0-9_-]{8,64}$/) });
2425
- var signedAssignmentsSchema = z17.object({ assignments: assignmentsSchema, sig: z17.string().regex(/^[A-Za-z0-9_-]{86}$/) });
2426
- var uptimeRegionStateSchema = z17.object({
2427
- region: z17.enum(UPTIME_REGIONS),
2428
- outcome: z17.enum(UPTIME_OUTCOMES),
2429
- reason: z17.enum(UPTIME_REASONS).nullable(),
2430
- status_code: z17.number().int().min(100).max(599).nullable(),
2431
- total_ms: z17.number().nonnegative().max(60000).nullable(),
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 = z17.object({
2623
+ var uptimeStatusReportSchema = z18.object({
2436
2624
  check_id: uuid3,
2437
- revision: z17.number().int().nonnegative(),
2438
- status: z17.enum(UPTIME_STATUSES),
2439
- last_verdict: z17.enum(SLOT_VERDICTS).nullable(),
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: z17.number().int().nonnegative(),
2443
- up_streak: z17.number().int().nonnegative(),
2444
- regions: z17.array(uptimeRegionStateSchema).max(3),
2445
- unobserved_regions: z17.array(z17.enum(UPTIME_REGIONS)).max(3),
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: z17.boolean(),
2448
- run_now: z17.object({ run_id: z17.string().max(64), results: z17.array(uptimeRegionStateSchema).max(3) }).nullable()
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 = z17.object({
2452
- event_id: z17.string().regex(/^[A-Za-z0-9:_-]{8,96}$/),
2639
+ var uptimeEventSchema = z18.object({
2640
+ event_id: z18.string().regex(/^[A-Za-z0-9:_-]{8,96}$/),
2453
2641
  check_id: uuid3,
2454
- kind: z17.enum(UPTIME_EVENT_KINDS),
2642
+ kind: z18.enum(UPTIME_EVENT_KINDS),
2455
2643
  incident_id: uuid3.nullable(),
2456
2644
  at: iso4,
2457
- reason: z17.enum(UPTIME_REASONS).nullable(),
2458
- regions: z17.array(z17.enum(UPTIME_REGIONS)).max(3),
2459
- cert_days_left: z17.number().int().nullable()
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 = z17.object({
2649
+ var uptimeMinuteSchema = z18.object({
2462
2650
  check_id: uuid3,
2463
2651
  minute: iso4,
2464
- up: z17.number().int().nonnegative(),
2465
- degraded: z17.number().int().nonnegative(),
2466
- down: z17.number().int().nonnegative(),
2467
- unknown: z17.number().int().nonnegative(),
2468
- latency: z17.array(z17.object({ region: z17.enum(UPTIME_REGIONS), n: z17.number().int().positive(), p50_ms: z17.number().nonnegative(), p95_ms: z17.number().nonnegative() })).max(3)
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 = z17.object({
2471
- v: z17.literal(1),
2658
+ var uptimeReportSchema = z18.object({
2659
+ v: z18.literal(1),
2472
2660
  workspace_id: uuid3,
2473
- revision: z17.number().int().nonnegative(),
2661
+ revision: z18.number().int().nonnegative(),
2474
2662
  sent_at: iso4,
2475
- events: z17.array(uptimeEventSchema).max(UPTIME_LIMITS.reportMaxEvents),
2476
- statuses: z17.array(uptimeStatusReportSchema).max(UPTIME_LIMITS.reportMaxStatuses),
2477
- minutes: z17.array(uptimeMinuteSchema).max(UPTIME_LIMITS.reportMaxMinutes)
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 = z17.object({
2480
- v: z17.literal(1),
2667
+ var probeFleetReportSchema = z18.object({
2668
+ v: z18.literal(1),
2481
2669
  sent_at: iso4,
2482
- probes: z17.array(z17.object({
2670
+ probes: z18.array(z18.object({
2483
2671
  probe_id: probeIdSchema,
2484
- region: z17.enum(UPTIME_REGIONS),
2485
- version: z17.string().max(40).nullable(),
2672
+ region: z18.enum(UPTIME_REGIONS),
2673
+ version: z18.string().max(40).nullable(),
2486
2674
  last_seen_at: iso4.nullable(),
2487
- lag_p99_ms: z17.number().nonnegative().nullable(),
2488
- checks_per_min: z17.number().nonnegative().nullable()
2675
+ lag_p99_ms: z18.number().nonnegative().nullable(),
2676
+ checks_per_min: z18.number().nonnegative().nullable()
2489
2677
  })).max(30),
2490
- regions_alive: z17.array(z17.enum(UPTIME_REGIONS)).max(3)
2678
+ regions_alive: z18.array(z18.enum(UPTIME_REGIONS)).max(3)
2491
2679
  });
2492
- var probeEnrollSchema = z17.object({
2493
- v: z17.literal(1),
2680
+ var probeEnrollSchema = z18.object({
2681
+ v: z18.literal(1),
2494
2682
  probe_id: probeIdSchema,
2495
- public_key: z17.string().regex(/^[A-Za-z0-9_-]{43}$/),
2496
- code: z17.string().regex(/^[A-Za-z0-9_-]{43}$/),
2497
- ts: z17.number().int().positive(),
2498
- sig: z17.string().regex(/^[A-Za-z0-9_-]{86}$/)
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 = z17.object({
2501
- v: z17.literal(1),
2502
- check_id: z17.guid(),
2503
- slot: z17.number().int().nonnegative(),
2504
- region: z17.enum(UPTIME_REGIONS),
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: z17.number().int().positive(),
2507
- sealed: z17.string().regex(/^[A-Za-z0-9_-]+$/).max(16384)
2694
+ at: z18.number().int().positive(),
2695
+ sealed: z18.string().regex(/^[A-Za-z0-9_-]+$/).max(16384)
2508
2696
  }).strict();
2509
- var uptimeEvidenceSchema = z17.object({
2510
- v: z17.literal(1),
2511
- check_id: z17.guid(),
2512
- slot: z17.number().int().nonnegative(),
2513
- region: z17.enum(UPTIME_REGIONS),
2514
- at: z17.number().int().positive(),
2515
- reason: z17.enum(UPTIME_REASONS).nullable(),
2516
- status_line: z17.string().max(200).nullable(),
2517
- headers: z17.record(z17.string().max(64), z17.string().max(512)).refine((h) => Object.keys(h).length <= 20),
2518
- body: z17.string().max(UPTIME_LIMITS.evidenceMaxBytes * 4).nullable(),
2519
- body_truncated: z17.boolean(),
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: z17.string().max(64).nullable(),
2522
- error: z17.string().max(300).nullable()
2709
+ ip: z18.string().max(64).nullable(),
2710
+ error: z18.string().max(300).nullable()
2523
2711
  }).strict();
2524
- var uptimeEvidenceListSchema = z17.object({
2525
- items: z17.array(uptimeEvidenceSchema.extend({ received_at: z17.number().int().positive() })).max(UPTIME_LIMITS.evidenceKeepPerCheck)
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 = z18.union([monitorInputSchema, signalMonitorInputSchema]);
2717
+ var anyMonitorInputSchema = z19.union([monitorInputSchema, signalMonitorInputSchema]);
2530
2718
  var MAINTENANCE_INPUTS = {
2531
- create: z18.object({ workspaceId: uuid, input: maintenanceInputSchema }),
2532
- update: z18.object({ workspaceId: uuid, windowId: uuid, input: maintenanceInputSchema }),
2533
- delete: z18.object({ workspaceId: uuid, windowId: uuid })
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: z18.object({ projectId, slug: z18.string().regex(SLUG_RE), input: anyMonitorInputSchema }),
2537
- update: z18.object({ monitorId: uuid, input: anyMonitorInputSchema }),
2538
- delete: z18.object({ monitorId: uuid, confirmSlug: z18.string().max(64) }),
2539
- setPause: z18.object({ monitorId: uuid, until: holdUntil }),
2540
- setMuted: z18.object({ monitorId: uuid, muted: z18.boolean() }),
2541
- dismissDiscovery: z18.object({ discoveryId: uuid }),
2542
- rotatePing: z18.object({
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: z18.number().int().refine((h) => HEARTBEAT_LIMITS.rotationGraceHoursChoices.includes(h))
2732
+ graceHours: z19.number().int().refine((h) => HEARTBEAT_LIMITS.rotationGraceHoursChoices.includes(h))
2545
2733
  }),
2546
- monitorOnly: z18.object({ monitorId: uuid })
2734
+ monitorOnly: z19.object({ monitorId: uuid })
2547
2735
  };
2548
2736
  var UPTIME_INPUTS = {
2549
2737
  create: uptimeCheckInputSchema,
2550
- update: z18.object({ checkId: uuid, input: uptimeCheckInputSchema }),
2551
- checkOnly: z18.object({ checkId: uuid }),
2552
- setHold: z18.object({ checkId: uuid, kind: z18.enum(["pause", "mute"]), until: holdUntil })
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: z18.object({ workspaceId: uuid, input: sloInputSchema }),
2556
- update: z18.object({ sloId: uuid, input: sloInputSchema }),
2557
- sloOnly: z18.object({ sloId: uuid }),
2558
- setHold: z18.object({ sloId: uuid, kind: z18.enum(["pause", "mute"]), until: holdUntil }),
2559
- import: z18.object({
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: z18.string().max(SLO_LIMITS.openSloMaxBytes * 2),
2562
- dryRun: z18.boolean()
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 z19 } from "zod";
2905
- var issueId = z19.number().int().positive();
2906
- var csv = z19.string().min(1).max(2000);
2907
- var name2 = z19.string().min(1).max(256);
2908
- var period = z19.enum(["1h", "24h", "7d", "14d", "30d"]);
2909
- var nodeCursor = z19.string().min(1).max(600).optional();
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: z19.string().max(40).optional(),
2912
- end: z19.string().max(40).optional()
3099
+ start: z20.string().max(40).optional(),
3100
+ end: z20.string().max(40).optional()
2913
3101
  };
2914
- var traceId = z19.string().regex(/^[0-9a-fA-F]{32}$/);
2915
- var spanId = z19.string().regex(/^[0-9a-fA-F]{16}$/);
2916
- var attrs = z19.string().max(2000).optional();
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 = z19.union([
2925
- z19.object({ action: z19.literal("resolve"), inNextRelease: z19.boolean().optional() }),
2926
- z19.object({ action: z19.literal("unresolve") }),
2927
- z19.object({ action: z19.literal("archive"), mode: z19.enum(["until_escalating", "forever"]) }),
2928
- z19.object({
2929
- action: z19.literal("archive"),
2930
- mode: z19.literal("until_condition"),
2931
- events: z19.number().int().min(1).max(1e6).optional(),
2932
- users: z19.number().int().min(1).max(1e5).optional(),
2933
- until: z19.string().datetime().optional()
2934
- }),
2935
- z19.object({ action: z19.literal("assign"), userId: z19.guid().nullable() }),
2936
- z19.object({ action: z19.literal("priority"), priority: z19.enum(["low", "medium", "high"]) })
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: z19.object({
3127
+ issuesList: z20.object({
2940
3128
  project: csv.optional(),
2941
- status: z19.enum(["unresolved", "resolved", "archived", "all"]).optional(),
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: z19.string().max(64).optional(),
3134
+ assignee: z20.string().max(64).optional(),
2947
3135
  period: period.optional(),
2948
- q: z19.string().max(200).optional(),
2949
- sort: z19.enum(["last_seen", "first_seen", "events", "users", "priority"]).optional(),
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: z19.number().int().min(1).max(100).optional()
3139
+ limit: z20.number().int().min(1).max(100).optional()
2952
3140
  }),
2953
- issue: z19.object({ issueId }),
2954
- issueStats: z19.object({ issueId, range: z19.enum(["24h", "30d"]).optional() }),
2955
- issueEvents: z19.object({ issueId, cursor: nodeCursor }),
2956
- issueEvent: z19.object({
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: z19.string().regex(/^([0-9a-f]{32}|latest|oldest)$/)
3146
+ eventId: z20.string().regex(/^([0-9a-f]{32}|latest|oldest)$/)
2959
3147
  }),
2960
- issueUpdate: z19.object({ issueId, change: issueChange }),
2961
- issuesBulk: z19.object({
2962
- issueIds: z19.array(issueId).min(1).max(100),
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: z19.object({
3153
+ spansList: z20.object({
2966
3154
  ...telemetryCommon,
2967
- operation: z19.string().min(1).max(1024).optional(),
2968
- status: z19.enum(["unset", "ok", "error"]).optional(),
2969
- kind: z19.enum(["internal", "server", "client", "producer", "consumer"]).optional(),
2970
- minDurationMs: z19.number().min(0).max(86400000).optional(),
2971
- maxDurationMs: z19.number().min(0).max(86400000).optional(),
2972
- mode: z19.enum(["spans", "traces"]).optional(),
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: z19.object({
3163
+ spansHistogram: z20.object({
2976
3164
  ...telemetryCommon,
2977
- operation: z19.string().min(1).max(1024).optional(),
2978
- status: z19.enum(["unset", "ok", "error"]).optional()
3165
+ operation: z20.string().min(1).max(1024).optional(),
3166
+ status: z20.enum(["unset", "ok", "error"]).optional()
2979
3167
  }),
2980
- trace: z19.object({ traceId }),
2981
- traceSpans: z19.object({ traceId, errorsOnly: z19.enum(["1"]).optional(), ...windowFields }),
2982
- span: z19.object({ traceId, spanId, ...windowFields }),
2983
- logsList: z19.object({
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: z19.enum(["trace", "debug", "info", "warn", "error", "fatal"]).optional(),
3173
+ severityMin: z20.enum(["trace", "debug", "info", "warn", "error", "fatal"]).optional(),
2986
3174
  traceId: traceId.optional(),
2987
3175
  spanId: spanId.optional(),
2988
- q: z19.string().max(500).optional(),
2989
- order: z19.enum(["asc", "desc"]).optional(),
3176
+ q: z20.string().max(500).optional(),
3177
+ order: z20.enum(["asc", "desc"]).optional(),
2990
3178
  cursor: nodeCursor
2991
3179
  }),
2992
- logsFacets: z19.object({
3180
+ logsFacets: z20.object({
2993
3181
  ...telemetryCommon,
2994
- severityMin: z19.enum(["trace", "debug", "info", "warn", "error", "fatal"]).optional(),
2995
- q: z19.string().max(500).optional()
3182
+ severityMin: z20.enum(["trace", "debug", "info", "warn", "error", "fatal"]).optional(),
3183
+ q: z20.string().max(500).optional()
2996
3184
  }),
2997
- logAround: z19.object({
3185
+ logAround: z20.object({
2998
3186
  logId: name2,
2999
- at: z19.string().max(40),
3000
- same: z19.enum(["service", "trace"]).optional(),
3001
- before: z19.number().int().min(0).max(200).optional(),
3002
- after: z19.number().int().min(0).max(200).optional()
3003
- }),
3004
- telemetryUsage: z19.object({ project: csv.optional(), days: z19.number().int().min(1).max(31).optional() }),
3005
- monitorSignal: z19.object({ monitorId: z19.guid(), hours: z19.number().int().min(1).max(24).optional() }),
3006
- monitorOccurrences: z19.object({
3007
- monitorId: z19.guid(),
3008
- state: z19.enum(["open", "finished", "all"]).optional(),
3009
- environment: z19.string().min(1).max(64).optional(),
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: z19.object({ project: z19.number().int().positive(), settings: backtestSettingsSchema }),
3013
- occurrenceCreate: z19.object({
3014
- project: z19.number().int().positive(),
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: z19.object({
3021
- project: z19.number().int().positive(),
3022
- monitorSlug: z19.string().regex(SLUG_RE),
3023
- occurrenceId: z19.string().regex(OCCURRENCE_ID_RE),
3024
- environment: z19.string().min(1).max(64).optional()
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: z19.object({
3027
- scope: z19.enum(["read", "write"]).default("read"),
3028
- project: z19.number().int().positive().optional(),
3029
- environment: z19.string().min(1).max(64).optional()
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 z21 } from "zod";
3529
+ import { z as z22 } from "zod";
3292
3530
 
3293
3531
  // ../src/shared/contracts/privacy.ts
3294
- import { z as z20 } from "zod";
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 = z20.string().regex(/^[A-Za-z0-9_-]{1,64}$/);
3325
- var privacyRuleInputSchema = z20.object({
3562
+ var ruleId = z21.string().regex(/^[A-Za-z0-9_-]{1,64}$/);
3563
+ var privacyRuleInputSchema = z21.object({
3326
3564
  id: ruleId,
3327
- selector: z20.string().min(1).max(PRIVACY_LIMITS.selector),
3328
- type: z20.enum(PRIVACY_RULE_TYPES),
3329
- method: z20.enum(PRIVACY_METHODS),
3330
- pattern: z20.string().min(1).max(PRIVACY_LIMITS.pattern).optional(),
3331
- ignoreCase: z20.boolean().optional(),
3332
- replaceWith: z20.string().max(PRIVACY_LIMITS.replaceWith).optional(),
3333
- enabled: z20.boolean().optional()
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 = z20.object({
3336
- mode: z20.enum(PRIVACY_MODES),
3337
- rules: z20.array(privacyRuleInputSchema).max(PRIVACY_LIMITS.rules),
3338
- allowlist: z20.array(z20.string().min(1).max(PRIVACY_LIMITS.selector)).max(PRIVACY_LIMITS.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 = z20.object({
3341
- schema: z20.literal(PRIVACY_SCHEMA),
3342
- version: z20.number().int().min(0),
3343
- mode: z20.enum(PRIVACY_MODES),
3344
- rules: z20.array(z20.record(z20.string(), z20.unknown())).max(PRIVACY_LIMITS.rules),
3345
- allowlist: z20.array(z20.string()).max(PRIVACY_LIMITS.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 = z20.array(z20.object({ project_id: z20.number().int().positive(), policy: z20.unknown() })).max(1000);
3348
- var privacyRollupSchema = z20.object({
3349
- applied_version: z20.number().int().min(0).nullable(),
3350
- policy_missing_24h: z20.number().int().nonnegative(),
3351
- budget_exceeded_24h: z20.number().int().nonnegative(),
3352
- sdk_versions: z20.array(z20.object({ version: z20.number().int().min(0), last_seen_at: z20.string().datetime() })).max(5)
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: z21.object({ workspaceId: uuid, projectId }),
3358
- set: z21.object({
3595
+ get: z22.object({ workspaceId: uuid, projectId }),
3596
+ set: z22.object({
3359
3597
  workspaceId: uuid,
3360
3598
  projectId,
3361
- expectedVersion: z21.number().int().min(0),
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 z25 } from "zod";
3639
+ import { z as z26 } from "zod";
3402
3640
 
3403
3641
  // ../src/shared/contracts/ingest-keys.ts
3404
- import { z as z22 } from "zod";
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 = z22.object({
3415
- v: z22.literal(1),
3416
- key_id: z22.guid(),
3417
- project_public_id: z22.number().int().positive(),
3418
- project_id: z22.number().int().positive(),
3419
- workspace_id: z22.guid(),
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: z22.array(z22.enum(INGEST_KEY_SCOPES)).min(1).max(INGEST_KEY_SCOPES.length),
3422
- environments: z22.array(z22.string().max(INGEST_KEY_LIMITS.environmentMaxChars)).max(INGEST_KEY_LIMITS.environmentsMax),
3423
- expires_at: z22.string().datetime({ offset: true }).nullable(),
3424
- state: z22.enum(INGEST_KEY_STATES),
3425
- workspace_status: z22.enum(["active", "suspended", "deleting"]),
3426
- ingest_kill: z22.boolean(),
3427
- telemetry_kill: z22.boolean(),
3428
- telemetry_rate_bytes_per_sec: z22.number().int().positive(),
3429
- telemetry_burst_bytes: z22.number().int().positive(),
3430
- traces_monthly_bytes: z22.number().int().positive(),
3431
- logs_monthly_bytes: z22.number().int().positive(),
3432
- telemetry_buffer_minutes: z22.number().int().min(1).max(1440),
3433
- revision: z22.number().int().nonnegative()
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 = z22.object({
3436
- projectId: z22.number().int().positive(),
3437
- name: z22.string().trim().min(1).max(INGEST_KEY_LIMITS.nameMaxChars).refine((s) => !/[\u0000-\u001f\u007f]/.test(s)),
3438
- scopes: z22.array(z22.enum(INGEST_KEY_SCOPES)).min(1).max(INGEST_KEY_SCOPES.length),
3439
- environments: z22.array(z22.string().trim().min(1).max(INGEST_KEY_LIMITS.environmentMaxChars).regex(/^[^\s/\u0000-\u001f]+$/)).max(INGEST_KEY_LIMITS.environmentsMax),
3440
- expiresAt: z22.string().datetime({ offset: true }).nullable()
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 = z22.object({
3443
- id: z22.guid(),
3444
- project_id: z22.number().int().positive(),
3445
- name: z22.string(),
3446
- prefix: z22.string(),
3447
- scopes: z22.array(z22.enum(INGEST_KEY_SCOPES)),
3448
- environments: z22.array(z22.string()),
3449
- expires_at: z22.string().nullable(),
3450
- state: z22.enum(INGEST_KEY_STATES),
3451
- created_by: z22.guid().nullable(),
3452
- created_at: z22.string(),
3453
- revoked_at: z22.string().nullable(),
3454
- last_used_at: z22.string().nullable()
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 z24 } from "zod";
3697
+ import { z as z25 } from "zod";
3459
3698
 
3460
3699
  // ../src/shared/contracts/backup.ts
3461
- import { z as z23 } from "zod";
3700
+ import { z as z24 } from "zod";
3462
3701
  var BACKUP_KINDS = ["daily", "weekly", "manual", "pre_upgrade"];
3463
- var ageRecipient = z23.string().regex(/^age1[02-9ac-hj-np-z]{58}$/);
3464
- var backupIdSchema = z23.string().regex(/^[a-z0-9-]{8,64}$/);
3465
- var nodeBackupConfigSchema = z23.object({
3466
- enabled: z23.boolean(),
3467
- hour_utc: z23.number().int().min(0).max(23),
3468
- weekly_day: z23.number().int().min(1).max(7),
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 = z23.object({
3472
- mode: z23.enum(["upload", "download"]),
3710
+ var backupCredentialsRequestSchema = z24.object({
3711
+ mode: z24.enum(["upload", "download"]),
3473
3712
  backup_id: backupIdSchema,
3474
- source_node_id: z23.guid().optional()
3713
+ source_node_id: z24.guid().optional()
3475
3714
  });
3476
- var backupCredentialsSchema = z23.object({
3477
- endpoint: z23.string().url(),
3478
- bucket: z23.string().regex(/^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/),
3479
- prefix: z23.string().regex(/^backups\/[0-9a-f-]{36}\/$/),
3480
- access_key_id: z23.string().min(8).max(200),
3481
- secret_access_key: z23.string().min(8).max(200),
3482
- session_token: z23.string().min(8).max(4000),
3483
- expires_at: z23.string().datetime()
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 = z23.record(z23.string().regex(/^[a-z_][a-z0-9_]{0,63}$/), z23.number().int().nonnegative());
3486
- var backupManifestSchema = z23.object({
3487
- v: z23.literal(1),
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: z23.guid(),
3490
- kind: z23.enum(BACKUP_KINDS),
3491
- created_at: z23.string().datetime(),
3492
- object_key: z23.string(),
3493
- size_bytes: z23.number().int().nonnegative(),
3494
- sha256: z23.string().regex(/^[0-9a-f]{64}$/),
3495
- clickhouse_version: z23.string().max(40),
3496
- schema_version: z23.number().int().nonnegative(),
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: z23.array(z23.string().regex(/^[0-9a-f]{8}$/)).min(1).max(4)
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 = z23.object({
3751
+ var backupReportSchema = z24.object({
3513
3752
  backup_id: backupIdSchema,
3514
- kind: z23.enum(BACKUP_KINDS),
3515
- status: z23.enum(["succeeded", "failed"]),
3516
- started_at: z23.string().datetime(),
3517
- finished_at: z23.string().datetime(),
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: z23.enum(BACKUP_ERROR_CODES).nullable()
3758
+ error_code: z24.enum(BACKUP_ERROR_CODES).nullable()
3520
3759
  });
3521
- var drillReportSchema = z23.object({
3760
+ var drillReportSchema = z24.object({
3522
3761
  backup_id: backupIdSchema,
3523
- kind: z23.enum(["weekly_local", "monthly_new_machine"]),
3524
- status: z23.enum(["passed", "failed"]),
3525
- finished_at: z23.string().datetime(),
3526
- detail: z23.string().max(300),
3527
- error_code: z23.enum(BACKUP_ERROR_CODES).nullable()
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 = z23.object({
3530
- v: z23.literal(1),
3531
- node_id: z23.guid(),
3532
- seal: z23.object({
3533
- publicKey: z23.string().regex(/^[A-Za-z0-9_-]{43}$/),
3534
- privateKey: z23.string().regex(/^[A-Za-z0-9_-]{43}$/)
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: z23.string().datetime()
3775
+ created_at: z24.string().datetime()
3537
3776
  });
3538
- var restoreArgsSchema = z23.object({
3539
- job_id: z23.guid(),
3540
- workspace_id: z23.guid(),
3541
- source_node_id: z23.guid(),
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: z23.string().regex(/^[A-Za-z0-9_-]{40,2000}$/),
3544
- mode: z23.enum(["rebuild", "drill"])
3782
+ sealed_identity: z24.string().regex(/^[A-Za-z0-9_-]{40,2000}$/),
3783
+ mode: z24.enum(["rebuild", "drill"])
3545
3784
  });
3546
- var restoreReportSchema = z23.object({
3547
- job_id: z23.guid(),
3785
+ var restoreReportSchema = z24.object({
3786
+ job_id: z24.guid(),
3548
3787
  backup_id: backupIdSchema,
3549
- mode: z23.enum(["rebuild", "drill"]),
3550
- status: z23.enum(["succeeded", "failed"]),
3551
- finished_at: z23.string().datetime(),
3552
- detail: z23.string().max(300),
3553
- error_code: z23.enum(BACKUP_ERROR_CODES).nullable()
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 = z24.string().regex(/^[A-Za-z0-9_-]{1,40}$/);
3568
- var publicKey = z24.string().regex(/^[A-Za-z0-9_-]{43}$/);
3569
- var nodeConfigSchema = z24.object({
3570
- v: z24.literal(1),
3571
- config_version: z24.number().int().positive(),
3572
- node_id: z24.guid(),
3573
- workspace_id: z24.guid(),
3574
- workspace_status: z24.enum(["active", "suspended"]),
3575
- issued_at: z24.string().datetime(),
3576
- retention_days: z24.number().int().min(1).max(3650),
3577
- channel: z24.enum(["stable", "canary"]).optional(),
3578
- projects: z24.array(z24.object({
3579
- project_id: z24.number().int().positive(),
3580
- slug: z24.string().max(64),
3581
- short_prefix: z24.string().regex(/^[A-Z0-9]{1,12}$/),
3582
- user_id_salt: z24.string().regex(/^[A-Za-z0-9_-]{22,64}$/),
3583
- scrub_disabled: z24.array(z24.enum(SCRUB_GROUPS)).max(SCRUB_GROUPS.length),
3584
- upload_tokens: z24.array(z24.object({
3585
- hash: z24.string().regex(/^[a-f0-9]{64}$/),
3586
- expires_at: z24.string().datetime()
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: z24.array(z24.object({ kid, public_key: publicKey, not_after: z24.string().datetime() })).min(1).max(5),
3590
- control_ops_keys: z24.array(z24.object({ kid, public_key: publicKey })).min(1).max(5),
3591
- kill_switches: z24.object({ ingest: z24.boolean(), alerts: z24.boolean() }),
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: z24.array(z24.number().int().positive()).max(1000).optional(),
3594
- monitors: z24.array(monitorDefinitionSchema).max(MAX_NODE_MONITORS).optional(),
3595
- purged_monitors: z24.array(z24.guid()).max(5000).optional(),
3596
- telemetry: z24.object({
3597
- traces_retention_days: z24.number().int().min(1).max(90),
3598
- logs_retention_days: z24.number().int().min(1).max(90),
3599
- traces_disk_share: z24.number().min(0.2).max(0.8)
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
- slos: z24.array(nodeSloSchema).max(SLO_LIMITS.maxNodeSlos).optional(),
3602
- signal_monitors: z24.array(signalMonitorDefinitionSchema).max(MAX_NODE_MONITORS).optional(),
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 = z24.object({ config: nodeConfigSchema, kid, sig: z24.string() });
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 = z25.string().regex(/^[a-z0-9][a-z0-9-]{1,38}[a-z0-9]$/);
3610
- var name3 = z25.string().trim().min(1).max(60);
3611
- var label = z25.string().trim().min(1).max(40);
3612
- var platform = z25.enum(PLATFORMS);
3613
- var origin = z25.string().trim().toLowerCase().regex(/^https?:\/\/[a-z0-9.-]+(:[0-9]{1,5})?$/).max(200);
3614
- var keyId = z25.number().int().positive();
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: z25.object({ workspaceId: uuid, name: name3, slug, platform }),
3617
- update: z25.object({ projectId, name: name3, platform, isPinned: z25.boolean() }),
3618
- updateIntake: z25.object({
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: z25.number().int().positive().nullable(),
3621
- burst: z25.number().int().positive().nullable(),
3622
- allowedOrigins: z25.array(origin).max(50)
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: z25.object({
3864
+ updateObservability: z26.object({
3625
3865
  projectId,
3626
- primaryEnvironment: z25.string().trim().min(1).max(64).refine((v) => v !== "*" && ENVIRONMENT_RE.test(v)),
3627
- allowCodeMonitors: z25.boolean()
3866
+ primaryEnvironment: z26.string().trim().min(1).max(64).refine((v) => v !== "*" && ENVIRONMENT_RE.test(v)),
3867
+ allowCodeMonitors: z26.boolean()
3628
3868
  }),
3629
- setScrub: z25.object({ projectId, group: z25.enum(SCRUB_GROUPS), enabled: z25.boolean() }),
3630
- setCheckinAuth: z25.object({ projectId, mode: z25.enum(CHECKIN_AUTH_MODES) }),
3631
- setEnvironmentHidden: z25.object({
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: z25.string().min(1).max(64),
3634
- hidden: z25.boolean()
3635
- }),
3636
- scheduleDeletion: z25.object({ projectId, confirmSlug: slug }),
3637
- projectOnly: z25.object({ projectId }),
3638
- labelled: z25.object({ projectId, label }),
3639
- keyOnly: z25.object({ keyId }),
3640
- tokenOnly: z25.object({ tokenId: keyId }),
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: z25.object({ keyId: uuid })
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 z26 } from "zod";
3898
- var list = z26.object({ workspaceId: uuid, limit: pageLimit, cursor });
4137
+ import { z as z27 } from "zod";
4138
+ var list = z27.object({ workspaceId: uuid, limit: pageLimit, cursor });
3899
4139
  var READ_INPUTS = {
3900
- workspace: z26.object({ workspaceId: uuid }),
4140
+ workspace: z27.object({ workspaceId: uuid }),
3901
4141
  list,
3902
- projectsGet: z26.object({ workspaceId: uuid, projectId }),
4142
+ projectsGet: z27.object({ workspaceId: uuid, projectId }),
3903
4143
  monitorsList: list.extend({ projectId: projectId.optional() }),
3904
- monitorsGet: z26.object({ workspaceId: uuid, monitorId: uuid }),
3905
- uptimeGet: z26.object({ workspaceId: uuid, checkId: uuid }),
3906
- slosGet: z26.object({ workspaceId: uuid, sloId: uuid }),
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: z26.enum(["open", "resolved", "all"]).default("all"),
4148
+ state: z27.enum(["open", "resolved", "all"]).default("all"),
3909
4149
  monitorId: uuid.optional()
3910
4150
  }),
3911
- approvalsGet: z26.object({ workspaceId: uuid, approvalId: uuid }),
4151
+ approvalsGet: z27.object({ workspaceId: uuid, approvalId: uuid }),
3912
4152
  monitorsListTyped: list.extend({
3913
4153
  projectId: projectId.optional(),
3914
- type: z26.enum(MONITOR_TYPES).optional()
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 z27 } from "zod";
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 = z27.toJSONSchema(op.input, { io: "input", unrepresentable: "any" });
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 z28.object(shape);
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 = z28.object({
4510
- untrusted: z28.object({
4511
- data: z28.unknown(),
4512
- provenance: z28.object({
4513
- source: z28.enum(["node", "control_plane", "docs"]),
4514
- operations: z28.array(z28.string())
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: z28.object({ slug: z28.string(), locale: z28.enum(["en", "vi"]), url: z28.string(), markdown: z28.string(), truncated: z28.boolean() }).optional(),
4518
- results: z28.array(z28.object({ slug: z28.string(), title: z28.string(), description: z28.string(), section: z28.string(), url: z28.string() })).optional(),
4519
- next_cursor: z28.string().nullable().optional(),
4520
- complete: z28.boolean().optional(),
4521
- omitted: z28.array(z28.object({ part: z28.string(), reason: z28.string(), scope: z28.string().optional() })).optional(),
4522
- truncated: z28.literal(true).optional(),
4523
- suspicious_unicode: z28.literal(true).optional(),
4524
- error: z28.object({
4525
- code: z28.string(),
4526
- status: z28.number(),
4527
- detail: z28.string().optional(),
4528
- scope: z28.string().optional(),
4529
- retry_after: z28.number().optional()
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: z28.array(z28.record(z28.string(), z28.unknown())).optional(),
4532
- operation: z28.record(z28.string(), z28.unknown()).optional(),
4533
- plan: z28.record(z28.string(), z28.unknown()).optional(),
4534
- status: z28.enum(["done", "approval_required", "approval_pending", ...APPROVAL_STATES]).optional(),
4535
- approval: z28.object({
4536
- approval_id: z28.string(),
4537
- approval_url: z28.string(),
4538
- expires_at: z28.string(),
4539
- state: z28.enum(APPROVAL_STATES),
4540
- result_code: z28.string().nullable().optional(),
4541
- result: z28.record(z28.string(), z28.unknown()).optional(),
4542
- next: z28.string().optional()
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: z28.string().max(40).describe("RFC 3339 start of the window, e.g. 2026-10-26T00:00:00Z. Required with end."),
4589
- end: z28.string().max(40).describe("RFC 3339 end of the window. The plan limits its length.")
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 = z28.string().regex(/^[0-9a-fA-F]{32}$/);
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 = z28.record(z28.string(), z28.unknown()).default({}).describe("Operation fields in wire names (snake_case), as describe_operation's args_schema shows.");
4656
- var operationIdArg = z28.string().min(3).max(80).describe("An operation id from search_operations, e.g. `monitors.update`.");
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: z28.object({}),
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: z28.object({
4695
- issue_id: z28.number().int().positive().describe("Issue id from search_issues."),
4696
- include_latest_event: z28.boolean().default(true)
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: z28.object({
4964
+ input: z29.object({
4725
4965
  trace_id: traceIdSchema.describe("W3C trace id, 32 hex characters."),
4726
- spans: z28.enum(["none", "errors", "all"]).default("none")
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: z28.object({
5048
+ input: z29.object({
4755
5049
  trace_id: traceIdSchema.optional(),
4756
- run_id: z28.string().min(1).max(128).optional(),
5050
+ run_id: z29.string().min(1).max(128).optional(),
4757
5051
  ...isoWindow,
4758
- project: z28.string().max(2000).optional().describe("Comma-separated project ids.")
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: z28.object({
4804
- kind: z28.enum(["all", "cron", "uptime", "slo"]).default("all"),
4805
- project_id: z28.number().int().positive().optional(),
4806
- limit: z28.number().int().min(1).max(200).default(50)
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: z28.object({
4835
- kind: z28.enum(["cron", "uptime", "slo"]),
4836
- id: z28.guid(),
4837
- backtest: z28.boolean().default(false)
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: z28.object({
4894
- project_id: z28.number().int().positive(),
4895
- idempotency_key: z28.string().min(8).max(255).optional()
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: z28.object({
4910
- query: z28.string().min(1).max(200).describe("Words such as `rotate dsn key`, `heartbeat monitor`, `slack alert`."),
4911
- limit: z28.number().int().min(1).max(20).default(10)
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: z28.object({ operation_id: operationIdArg }),
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: z28.object({ operation_id: operationIdArg, params }),
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: z28.object({
5311
+ input: z29.object({
5018
5312
  operation_id: operationIdArg,
5019
5313
  params,
5020
- idempotency_key: z28.string().min(8).max(255).describe("Unique per change; reuse it to retry or to fetch the result."),
5021
- if_match: z28.string().max(200).optional().describe("ETag from plan_change, for operations that need it.")
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: z28.object({ approval_id: z28.guid().describe("approval_id from apply_change.") }),
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: z28.object({
5093
- query: z28.string().min(1).max(200),
5094
- locale: z28.enum(["en", "vi"]).default("en"),
5095
- limit: z28.number().int().min(1).max(10).default(5)
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: z28.object({
5112
- slug: z28.string().regex(/^[a-z0-9][a-z0-9/-]{0,120}$/),
5113
- locale: z28.enum(["en", "vi"]).default("en")
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.4.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(",")}]