@belvador/mcp 0.2.0 → 0.3.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 +1620 -827
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -178,7 +178,7 @@ function cleanUntrustedText(raw, maxBytes = MCP_LIMITS.untrustedStringMaxBytes)
178
178
  const { text, cut } = cutUtf8(escaped, maxBytes);
179
179
  return { text, cut, suspicious };
180
180
  }
181
- var MCP_TOOLS_VERSION = 2;
181
+ var MCP_TOOLS_VERSION = 3;
182
182
  var MCP_TOOLS = [
183
183
  { name: "get_workspace", toolset: "investigate", scope: "org:read", readOnly: true, destructive: false, idempotent: true },
184
184
  { name: "list_projects", toolset: "investigate", scope: "projects:read", readOnly: true, destructive: false, idempotent: true },
@@ -210,8 +210,6 @@ var MCP_TOOLS = [
210
210
  var MCP_TOOLS_PENDING = {
211
211
  query_metrics: "P14",
212
212
  release_health: "P15",
213
- list_incidents: "P9",
214
- get_incident: "P9",
215
213
  get_coverage: "P10"
216
214
  };
217
215
 
@@ -257,7 +255,7 @@ function docsFetcher(siteUrl, fetcher = fetch, now = () => Date.now()) {
257
255
  import { CLIENT_CAPABILITIES_META_KEY, inputRequired, McpServer } from "@modelcontextprotocol/server";
258
256
 
259
257
  // ../src/shared/contracts/mcp-tools.ts
260
- import { z as z20 } from "zod";
258
+ import { z as z24 } from "zod";
261
259
 
262
260
  // ../src/shared/contracts/api-ops/access.ts
263
261
  import { z as z3 } from "zod";
@@ -637,7 +635,16 @@ var UPTIME_TRIGGER = "uptime_problem";
637
635
  var SLO_TRIGGER = "slo_burn";
638
636
  var RULE_TRIGGERS = [...ALERT_TRIGGERS, INTEGRATION_TRIGGER, MONITOR_TRIGGER, UPTIME_TRIGGER, SLO_TRIGGER];
639
637
  var SOLO_TRIGGERS = [INTEGRATION_TRIGGER, MONITOR_TRIGGER, UPTIME_TRIGGER, SLO_TRIGGER];
640
- var MONITOR_RULE_KINDS = ["missed", "failed", "timeout", "unknown"];
638
+ var MONITOR_RULE_KINDS = [
639
+ "missed",
640
+ "failed",
641
+ "timeout",
642
+ "unknown",
643
+ "count",
644
+ "assertion",
645
+ "deadline",
646
+ "stalled"
647
+ ];
641
648
  var SLO_RULE_SEVERITIES = ["page", "ticket"];
642
649
  function validRuleTriggers(triggers) {
643
650
  if (triggers.length === 1 && SOLO_TRIGGERS.includes(triggers[0]))
@@ -658,8 +665,9 @@ var ruleInputSchema = z4.object({
658
665
  isEnabled: z4.boolean(),
659
666
  notifyAll: z4.boolean(),
660
667
  destinationIds: z4.array(z4.guid()).max(20),
661
- monitorKinds: z4.array(z4.enum(MONITOR_RULE_KINDS)).min(1).max(4).default([...MONITOR_RULE_KINDS]),
662
- sloSeverities: z4.array(z4.enum(SLO_RULE_SEVERITIES)).min(1).max(2).default([...SLO_RULE_SEVERITIES])
668
+ monitorKinds: z4.array(z4.enum(MONITOR_RULE_KINDS)).min(1).max(MONITOR_RULE_KINDS.length).default([...MONITOR_RULE_KINDS]),
669
+ sloSeverities: z4.array(z4.enum(SLO_RULE_SEVERITIES)).min(1).max(2).default([...SLO_RULE_SEVERITIES]),
670
+ policyId: z4.guid().nullable().default(null)
663
671
  });
664
672
 
665
673
  // ../src/shared/contracts/api-ops/alerts.ts
@@ -676,7 +684,7 @@ var ALERT_INPUTS = {
676
684
  destinationOnly: z5.object({ destinationId: uuid }),
677
685
  createDestination: z5.object({
678
686
  workspaceId: uuid,
679
- provider: z5.enum(["telegram", "slack", "email", "webhook"]),
687
+ provider: z5.enum(["telegram", "slack", "email", "webhook", "pagerduty", "incident_io"]),
680
688
  name,
681
689
  projectIds,
682
690
  locale
@@ -758,12 +766,14 @@ var ALERT_OPERATIONS = [
758
766
  idempotency: "required",
759
767
  status: 201,
760
768
  mcp: "configure",
761
- summary: "Start adding a Telegram, Slack, email or webhook destination; a person enters its secrets.",
769
+ summary: "Start adding a Telegram, Slack, email, webhook, PagerDuty or incident.io destination; a person enters its secrets.",
762
770
  ui: [
763
771
  "alerts#createSlackDestination",
764
772
  "alerts#createWebhookDestination",
765
773
  "alerts#createTelegramDestination",
766
- "alerts#createEmailDestination"
774
+ "alerts#createEmailDestination",
775
+ "alerts#createPagerDutyDestination",
776
+ "alerts#createIncidentIoDestination"
767
777
  ]
768
778
  }),
769
779
  op({
@@ -852,17 +862,78 @@ var ALERT_OPERATIONS = [
852
862
  })
853
863
  ];
854
864
 
855
- // ../src/shared/contracts/api-ops/monitors.ts
856
- import { z as z11 } from "zod";
865
+ // ../src/shared/contracts/api-ops/incidents.ts
866
+ import { z as z10 } from "zod";
857
867
 
858
- // ../src/shared/contracts/heartbeat.ts
868
+ // ../src/shared/contracts/notifications.ts
869
+ import { z as z9 } from "zod";
870
+
871
+ // ../src/shared/contracts/maintenance.ts
872
+ import { z as z6 } from "zod";
873
+ var MAINTENANCE_SCOPES = ["workspace", "project", "monitor"];
874
+ var MAINTENANCE_LIMITS = {
875
+ durationMinutesMin: 5,
876
+ durationMinutesMax: 1440,
877
+ reasonMax: 200,
878
+ idsMax: 50,
879
+ onceAheadDays: 366,
880
+ previewStarts: 3
881
+ };
882
+ var weekdaySchema = z6.number().int().min(1).max(7);
883
+ var timeOfDay = z6.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/);
884
+ var base = {
885
+ scope: z6.enum(MAINTENANCE_SCOPES),
886
+ projectIds: z6.array(z6.number().int().positive()).max(MAINTENANCE_LIMITS.idsMax),
887
+ monitorIds: z6.array(z6.guid()).max(MAINTENANCE_LIMITS.idsMax),
888
+ timezone: z6.string().trim().min(1).max(64),
889
+ durationMinutes: z6.number().int().min(MAINTENANCE_LIMITS.durationMinutesMin).max(MAINTENANCE_LIMITS.durationMinutesMax),
890
+ reason: z6.string().trim().max(MAINTENANCE_LIMITS.reasonMax).regex(/^[^\p{Cc}]*$/u)
891
+ };
892
+ var maintenanceInputSchema = z6.discriminatedUnion("kind", [
893
+ z6.object({ kind: z6.literal("once"), startsAt: z6.string().datetime({ offset: true }), ...base }),
894
+ z6.object({
895
+ kind: z6.literal("weekly"),
896
+ weekdays: z6.array(weekdaySchema).min(1).max(7),
897
+ startTime: timeOfDay,
898
+ ...base
899
+ })
900
+ ]).superRefine((w, ctx) => {
901
+ const bad = (path) => ctx.addIssue({ code: "custom", path: [path], message: "MAINTENANCE_INVALID" });
902
+ if (w.scope === "workspace" && (w.projectIds.length || w.monitorIds.length))
903
+ bad("scope");
904
+ if (w.scope === "project" && (!w.projectIds.length || w.monitorIds.length))
905
+ bad("projectIds");
906
+ if (w.scope === "monitor" && (!w.monitorIds.length || w.projectIds.length))
907
+ bad("monitorIds");
908
+ if (new Set(w.projectIds).size !== w.projectIds.length)
909
+ bad("projectIds");
910
+ if (new Set(w.monitorIds).size !== w.monitorIds.length)
911
+ bad("monitorIds");
912
+ if (w.kind === "weekly" && new Set(w.weekdays).size !== w.weekdays.length)
913
+ bad("weekdays");
914
+ if (!validTimeZone(w.timezone))
915
+ bad("timezone");
916
+ });
917
+ function validTimeZone(tz) {
918
+ try {
919
+ new Intl.DateTimeFormat("en-US", { timeZone: tz });
920
+ return true;
921
+ } catch {
922
+ return false;
923
+ }
924
+ }
925
+ var fmtCache = new Map;
926
+
927
+ // ../src/shared/contracts/signal-monitors.ts
859
928
  import { z as z8 } from "zod";
860
929
 
861
930
  // ../src/shared/contracts/monitors.ts
862
- import { z as z6 } from "zod";
931
+ import { z as z7 } from "zod";
863
932
 
864
933
  // ../src/shared/contracts/vocab/monitors.ts
865
934
  var MONITOR_MODES = ["check_in", "heartbeat"];
935
+ var MONITOR_TYPES = ["job", "count", "assertion", "deadline", "progress"];
936
+ var SIGNAL_MONITOR_TYPES = ["count", "assertion", "deadline", "progress"];
866
937
 
867
938
  // ../src/shared/contracts/monitors.ts
868
939
  var MONITOR_KINDS = ["crontab", "interval", "on_demand"];
@@ -872,8 +943,13 @@ var MONITOR_INCIDENT_CODES = [
872
943
  "MONITOR_MISSED",
873
944
  "MONITOR_FAILED",
874
945
  "MONITOR_TIMEOUT",
875
- "MONITOR_UNKNOWN"
946
+ "MONITOR_UNKNOWN",
947
+ "MONITOR_COUNT",
948
+ "MONITOR_ASSERTION",
949
+ "MONITOR_DEADLINE_MISSED",
950
+ "MONITOR_STALLED"
876
951
  ];
952
+ var FAILURE_INCIDENT_CODES = MONITOR_INCIDENT_CODES.filter((c) => c !== "MONITOR_UNKNOWN");
877
953
  var INCIDENT_EVENTS = ["opened", "updated", "resolved"];
878
954
  var UNOBSERVABLE_REASONS = [
879
955
  "node_offline",
@@ -924,100 +1000,112 @@ function crontabShapeOk(value) {
924
1000
  const fields = value.trim().split(/\s+/);
925
1001
  return value.length <= 120 && fields.length === 5 && fields.every((f) => /^[0-9A-Za-z*,/?#LW-]+$/.test(f));
926
1002
  }
927
- var crontabScheduleSchema = z6.object({
928
- type: z6.literal("crontab"),
929
- value: z6.string().refine(crontabShapeOk, "crontab")
1003
+ var crontabScheduleSchema = z7.object({
1004
+ type: z7.literal("crontab"),
1005
+ value: z7.string().refine(crontabShapeOk, "crontab")
930
1006
  });
931
- var intervalScheduleSchema = z6.object({
932
- type: z6.literal("interval"),
933
- value: z6.number().int().min(1).max(MONITOR_LIMITS.intervalValueMax),
934
- unit: z6.enum(INTERVAL_UNITS)
1007
+ var intervalScheduleSchema = z7.object({
1008
+ type: z7.literal("interval"),
1009
+ value: z7.number().int().min(1).max(MONITOR_LIMITS.intervalValueMax),
1010
+ unit: z7.enum(INTERVAL_UNITS)
935
1011
  });
936
- var scheduleSchema = z6.discriminatedUnion("type", [
1012
+ var scheduleSchema = z7.discriminatedUnion("type", [
937
1013
  crontabScheduleSchema,
938
1014
  intervalScheduleSchema
939
1015
  ]);
940
- var monitorSettingsSchema = z6.object({
1016
+ var monitorSettingsSchema = z7.object({
941
1017
  schedule: scheduleSchema.nullable(),
942
- timezone: z6.string().min(1).max(64),
943
- checkin_margin: z6.number().int().min(MONITOR_LIMITS.checkinMarginMin).max(MONITOR_LIMITS.checkinMarginMax),
944
- max_runtime: z6.number().int().min(MONITOR_LIMITS.maxRuntimeMin).max(MONITOR_LIMITS.maxRuntimeMax),
945
- failure_issue_threshold: z6.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax),
946
- recovery_threshold: z6.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax)
1018
+ timezone: z7.string().min(1).max(64),
1019
+ checkin_margin: z7.number().int().min(MONITOR_LIMITS.checkinMarginMin).max(MONITOR_LIMITS.checkinMarginMax),
1020
+ max_runtime: z7.number().int().min(MONITOR_LIMITS.maxRuntimeMin).max(MONITOR_LIMITS.maxRuntimeMax),
1021
+ failure_issue_threshold: z7.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax),
1022
+ recovery_threshold: z7.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax)
947
1023
  });
948
- var iso = z6.string().datetime();
949
- var projectId2 = z6.number().int().positive();
950
- var envName = z6.string().min(1).max(MONITOR_LIMITS.environmentMax);
1024
+ var iso = z7.string().datetime();
1025
+ var projectId2 = z7.number().int().positive();
1026
+ var envName = z7.string().min(1).max(MONITOR_LIMITS.environmentMax);
951
1027
  var monitorDefinitionSchema = monitorSettingsSchema.extend({
952
- id: z6.guid(),
1028
+ id: z7.guid(),
953
1029
  project_id: projectId2,
954
- slug: z6.string().regex(SLUG_RE),
955
- kind: z6.enum(MONITOR_KINDS),
956
- expected_environments: z6.array(envName).max(MONITOR_LIMITS.expectedEnvironmentsMax),
1030
+ slug: z7.string().regex(SLUG_RE),
1031
+ kind: z7.enum(MONITOR_KINDS),
1032
+ expected_environments: z7.array(envName).max(MONITOR_LIMITS.expectedEnvironmentsMax),
957
1033
  paused_until: iso.nullable(),
958
1034
  created_at: iso,
959
- config_source: z6.enum(CONFIG_SOURCES),
960
- config_hash: z6.string().regex(/^[0-9a-f]{64}$/).nullable()
1035
+ config_source: z7.enum(CONFIG_SOURCES),
1036
+ config_hash: z7.string().regex(/^[0-9a-f]{64}$/).nullable()
1037
+ });
1038
+ var outcomeCounts = z7.object({
1039
+ ok: z7.number().int().nonnegative(),
1040
+ skipped: z7.number().int().nonnegative(),
1041
+ error: z7.number().int().nonnegative(),
1042
+ timeout: z7.number().int().nonnegative(),
1043
+ missed: z7.number().int().nonnegative(),
1044
+ unknown: z7.number().int().nonnegative()
961
1045
  });
962
- var outcomeCounts = z6.object({
963
- ok: z6.number().int().nonnegative(),
964
- skipped: z6.number().int().nonnegative(),
965
- error: z6.number().int().nonnegative(),
966
- timeout: z6.number().int().nonnegative(),
967
- missed: z6.number().int().nonnegative(),
968
- unknown: z6.number().int().nonnegative()
1046
+ var signalStatusSchema = z7.object({
1047
+ type: z7.enum(SIGNAL_MONITOR_TYPES),
1048
+ value: z7.number().int().nonnegative().max(1e9).nullable(),
1049
+ threshold: z7.number().int().nonnegative().max(1e9).nullable(),
1050
+ window_end: iso.nullable(),
1051
+ pending: z7.number().int().nonnegative().max(1e6).nullable(),
1052
+ stalled: z7.number().int().nonnegative().max(1e6).nullable(),
1053
+ refused_24h: z7.number().int().nonnegative().max(1e9).nullable()
969
1054
  });
970
- var monitorStatusSchema = z6.object({
971
- monitor_id: z6.guid(),
1055
+ var monitorStatusSchema = z7.object({
1056
+ monitor_id: z7.guid(),
972
1057
  project_id: projectId2,
973
1058
  environment: envName,
974
- open_failure: z6.enum(["MONITOR_MISSED", "MONITOR_FAILED", "MONITOR_TIMEOUT"]).nullable(),
975
- open_unknown: z6.boolean(),
976
- unobservable: z6.enum(UNOBSERVABLE_REASONS).nullable(),
977
- last_outcome: z6.enum(RUN_OUTCOMES).nullable(),
1059
+ open_failure: z7.enum(FAILURE_INCIDENT_CODES).nullable(),
1060
+ open_unknown: z7.boolean(),
1061
+ unobservable: z7.enum(UNOBSERVABLE_REASONS).nullable(),
1062
+ last_outcome: z7.enum(RUN_OUTCOMES).nullable(),
978
1063
  last_check_in_at: iso.nullable(),
979
1064
  last_healthy_at: iso.nullable(),
980
1065
  next_deadline_at: iso.nullable(),
981
1066
  next_due_at: iso.nullable().optional(),
982
- in_progress: z6.boolean(),
1067
+ in_progress: z7.boolean(),
983
1068
  counts_24h: outcomeCounts,
1069
+ signal: signalStatusSchema.optional(),
984
1070
  evaluated_at: iso
985
1071
  });
986
- var monitorIncidentSchema = z6.object({
987
- incident_id: z6.guid(),
988
- monitor_id: z6.guid(),
1072
+ var monitorIncidentSchema = z7.object({
1073
+ incident_id: z7.guid(),
1074
+ monitor_id: z7.guid(),
989
1075
  project_id: projectId2,
990
1076
  environment: envName,
991
- code: z6.enum(MONITOR_INCIDENT_CODES),
992
- event: z6.enum(INCIDENT_EVENTS),
1077
+ code: z7.enum(MONITOR_INCIDENT_CODES),
1078
+ event: z7.enum(INCIDENT_EVENTS),
993
1079
  occurred_at: iso,
994
- detected_late: z6.boolean(),
995
- reason: z6.string().regex(REASON_RE).nullable(),
996
- duration_ms: z6.number().int().nonnegative().nullable(),
997
- consecutive: z6.number().int().min(1).max(1e5),
998
- reviewed_by: z6.guid().nullable()
1080
+ detected_late: z7.boolean(),
1081
+ reason: z7.string().regex(REASON_RE).nullable(),
1082
+ duration_ms: z7.number().int().nonnegative().nullable(),
1083
+ consecutive: z7.number().int().min(1).max(1e5),
1084
+ reviewed_by: z7.guid().nullable(),
1085
+ observed: z7.number().int().min(0).max(1e9).nullable().optional(),
1086
+ threshold: z7.number().int().min(0).max(1e9).nullable().optional()
999
1087
  });
1000
- var monitorDiscoverySchema = z6.object({
1088
+ var monitorDiscoverySchema = z7.object({
1001
1089
  project_id: projectId2,
1002
- slug: z6.string().regex(SLUG_RE),
1090
+ slug: z7.string().regex(SLUG_RE),
1003
1091
  settings: monitorSettingsSchema.nullable(),
1004
- config_hash: z6.string().regex(/^[0-9a-f]{64}$/).nullable(),
1005
- check_ins: z6.number().int().nonnegative(),
1092
+ config_hash: z7.string().regex(/^[0-9a-f]{64}$/).nullable(),
1093
+ check_ins: z7.number().int().nonnegative(),
1006
1094
  last_seen_at: iso
1007
1095
  });
1008
1096
  var MONITOR_NAME_MAX = MONITOR_LIMITS.nameMax;
1009
- var environmentName = z6.string().trim().min(1).max(MONITOR_LIMITS.environmentMax).regex(/^[A-Za-z0-9._-]+$/);
1010
- var monitorInputSchema = z6.object({
1011
- name: z6.string().trim().min(1).max(MONITOR_LIMITS.nameMax),
1012
- mode: z6.enum(MONITOR_MODES).default("check_in"),
1013
- kind: z6.enum(MONITOR_KINDS),
1097
+ var environmentName = z7.string().trim().min(1).max(MONITOR_LIMITS.environmentMax).regex(/^[A-Za-z0-9._-]+$/);
1098
+ var monitorInputSchema = z7.object({
1099
+ name: z7.string().trim().min(1).max(MONITOR_LIMITS.nameMax),
1100
+ mode: z7.enum(MONITOR_MODES).default("check_in"),
1101
+ kind: z7.enum(MONITOR_KINDS),
1014
1102
  schedule: scheduleSchema.nullable(),
1015
- timezone: z6.string().trim().min(1).max(64),
1016
- checkinMarginMin: z6.number().int().min(MONITOR_LIMITS.checkinMarginMin).max(MONITOR_LIMITS.checkinMarginMax),
1017
- maxRuntimeMin: z6.number().int().min(MONITOR_LIMITS.maxRuntimeMin).max(MONITOR_LIMITS.maxRuntimeMax),
1018
- failureThreshold: z6.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax),
1019
- recoveryThreshold: z6.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax),
1020
- expectedEnvironments: z6.array(environmentName).min(1).max(MONITOR_LIMITS.expectedEnvironmentsMax)
1103
+ timezone: z7.string().trim().min(1).max(64),
1104
+ checkinMarginMin: z7.number().int().min(MONITOR_LIMITS.checkinMarginMin).max(MONITOR_LIMITS.checkinMarginMax),
1105
+ maxRuntimeMin: z7.number().int().min(MONITOR_LIMITS.maxRuntimeMin).max(MONITOR_LIMITS.maxRuntimeMax),
1106
+ failureThreshold: z7.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax),
1107
+ recoveryThreshold: z7.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax),
1108
+ expectedEnvironments: z7.array(environmentName).min(1).max(MONITOR_LIMITS.expectedEnvironmentsMax)
1021
1109
  }).refine((v) => v.kind === "on_demand" ? v.schedule === null : v.schedule?.type === v.kind, {
1022
1110
  path: ["schedule"],
1023
1111
  message: "schedule"
@@ -1032,98 +1120,601 @@ var MONITOR_INPUT_DEFAULTS = {
1032
1120
  recoveryThreshold: MONITOR_LIMITS.recoveryThresholdDefault,
1033
1121
  expectedEnvironments: [DEFAULT_CHECK_IN_ENVIRONMENT]
1034
1122
  };
1035
- var runOutcome = z6.enum(RUN_OUTCOMES);
1036
- var runFlags = z6.array(z6.string().max(32)).max(16);
1037
- var monitorRunSchema = z6.object({
1038
- id: z6.number().int().positive(),
1039
- kind: z6.enum(["run", "missed"]),
1123
+ var runOutcome = z7.enum(RUN_OUTCOMES);
1124
+ var runFlags = z7.array(z7.string().max(32)).max(16);
1125
+ var monitorRunSchema = z7.object({
1126
+ id: z7.number().int().positive(),
1127
+ kind: z7.enum(["run", "missed"]),
1040
1128
  outcome: runOutcome,
1041
1129
  started_at: iso,
1042
1130
  ended_at: iso,
1043
- attempts: z6.number().int().nonnegative(),
1044
- duration_ms: z6.number().int().nonnegative().nullable(),
1045
- reason: z6.string().max(64).nullable(),
1046
- check_in_id: z6.string().max(64).nullable(),
1047
- trace_id: z6.string().max(32).nullable(),
1048
- release: z6.string().max(MONITOR_LIMITS.releaseMax).nullable(),
1131
+ attempts: z7.number().int().nonnegative(),
1132
+ duration_ms: z7.number().int().nonnegative().nullable(),
1133
+ reason: z7.string().max(64).nullable(),
1134
+ check_in_id: z7.string().max(64).nullable(),
1135
+ trace_id: z7.string().max(32).nullable(),
1136
+ release: z7.string().max(MONITOR_LIMITS.releaseMax).nullable(),
1049
1137
  flags: runFlags
1050
1138
  });
1051
- var openAttemptSchema = z6.object({
1052
- check_in_id: z6.string().max(64),
1053
- run_key: z6.string().max(64),
1054
- attempt: z6.number().int().nonnegative(),
1055
- state: z6.string().max(16),
1139
+ var openAttemptSchema = z7.object({
1140
+ check_in_id: z7.string().max(64),
1141
+ run_key: z7.string().max(64),
1142
+ attempt: z7.number().int().nonnegative(),
1143
+ state: z7.string().max(16),
1056
1144
  started_at: iso,
1057
1145
  deadline_at: iso
1058
1146
  });
1059
- var monitorRunsResponseSchema = z6.object({
1060
- open: z6.array(openAttemptSchema).max(100),
1061
- runs: z6.array(monitorRunSchema).max(MONITOR_LIMITS.runsPageSize),
1062
- next_cursor: z6.string().max(32).nullable()
1147
+ var monitorRunsResponseSchema = z7.object({
1148
+ open: z7.array(openAttemptSchema).max(100),
1149
+ runs: z7.array(monitorRunSchema).max(MONITOR_LIMITS.runsPageSize),
1150
+ next_cursor: z7.string().max(32).nullable()
1063
1151
  });
1064
- var timelineRunSchema = z6.object({
1065
- id: z6.number().int().positive(),
1066
- kind: z6.enum(["run", "missed"]),
1152
+ var timelineRunSchema = z7.object({
1153
+ id: z7.number().int().positive(),
1154
+ kind: z7.enum(["run", "missed"]),
1067
1155
  outcome: runOutcome,
1068
1156
  ended_at: iso,
1069
1157
  flags: runFlags
1070
1158
  });
1071
- var monitorTimelineResponseSchema = z6.object({
1072
- runs: z6.array(timelineRunSchema).max(MONITOR_LIMITS.timelineRuns)
1159
+ var monitorTimelineResponseSchema = z7.object({
1160
+ runs: z7.array(timelineRunSchema).max(MONITOR_LIMITS.timelineRuns)
1073
1161
  });
1074
- var monitorStripsResponseSchema = z6.object({
1075
- strips: z6.array(z6.object({
1076
- monitor_id: z6.guid(),
1162
+ var monitorStripsResponseSchema = z7.object({
1163
+ strips: z7.array(z7.object({
1164
+ monitor_id: z7.guid(),
1077
1165
  environment: envName,
1078
- runs: z6.array(timelineRunSchema).max(MONITOR_LIMITS.listStripRuns)
1166
+ runs: z7.array(timelineRunSchema).max(MONITOR_LIMITS.listStripRuns)
1079
1167
  })).max(5000)
1080
1168
  });
1081
- var monitorDiagnosticSchema = z6.object({
1082
- id: z6.string().regex(/^\d{1,19}$/),
1083
- check_in_id: z6.string().max(64).nullable(),
1084
- signal: z6.string().max(16),
1085
- exit_code: z6.number().int().min(0).max(255).nullable(),
1169
+ var monitorDiagnosticSchema = z7.object({
1170
+ id: z7.string().regex(/^\d{1,19}$/),
1171
+ check_in_id: z7.string().max(64).nullable(),
1172
+ signal: z7.string().max(16),
1173
+ exit_code: z7.number().int().min(0).max(255).nullable(),
1086
1174
  received_at: iso,
1087
- body: z6.string().max(MONITOR_LIMITS.diagnosticMaxBytes * 2)
1175
+ body: z7.string().max(MONITOR_LIMITS.diagnosticMaxBytes * 2)
1088
1176
  });
1089
- var monitorDiagnosticsResponseSchema = z6.object({
1090
- diagnostics: z6.array(monitorDiagnosticSchema).max(50),
1091
- next_cursor: z6.string().regex(/^\d{1,19}$/).nullable()
1177
+ var monitorDiagnosticsResponseSchema = z7.object({
1178
+ diagnostics: z7.array(monitorDiagnosticSchema).max(50),
1179
+ next_cursor: z7.string().regex(/^\d{1,19}$/).nullable()
1092
1180
  });
1093
- var checkInDetailSchema = z6.object({
1094
- run_key: z6.string().max(64),
1095
- attempts: z6.array(z6.object({
1096
- check_in_id: z6.string().max(64),
1097
- attempt: z6.number().int().nonnegative(),
1098
- result: z6.string().max(16),
1181
+ var checkInDetailSchema = z7.object({
1182
+ run_key: z7.string().max(64),
1183
+ attempts: z7.array(z7.object({
1184
+ check_in_id: z7.string().max(64),
1185
+ attempt: z7.number().int().nonnegative(),
1186
+ result: z7.string().max(16),
1099
1187
  started_at: iso,
1100
1188
  ended_at: iso.nullable(),
1101
- duration_ms: z6.number().int().nonnegative().nullable(),
1102
- reason: z6.string().max(64).nullable(),
1103
- trace_id: z6.string().max(32).nullable(),
1104
- release: z6.string().max(MONITOR_LIMITS.releaseMax).nullable()
1189
+ duration_ms: z7.number().int().nonnegative().nullable(),
1190
+ reason: z7.string().max(64).nullable(),
1191
+ trace_id: z7.string().max(32).nullable(),
1192
+ release: z7.string().max(MONITOR_LIMITS.releaseMax).nullable()
1105
1193
  })).max(1000),
1106
- errors: z6.array(z6.object({
1107
- event_id: z6.string().max(64),
1108
- issue_id: z6.number().int().nonnegative(),
1109
- title: z6.string().max(1024),
1110
- level: z6.string().max(16),
1194
+ errors: z7.array(z7.object({
1195
+ event_id: z7.string().max(64),
1196
+ issue_id: z7.number().int().nonnegative(),
1197
+ title: z7.string().max(1024),
1198
+ level: z7.string().max(16),
1111
1199
  timestamp: iso,
1112
- same_trace: z6.boolean()
1200
+ same_trace: z7.boolean()
1113
1201
  })).max(50),
1114
- diagnostics: z6.array(monitorDiagnosticSchema).max(20).default([])
1202
+ diagnostics: z7.array(monitorDiagnosticSchema).max(20).default([])
1203
+ });
1204
+ var incidentReviewSchema = z7.object({ incident_id: z7.guid() });
1205
+
1206
+ // ../src/shared/contracts/signal-monitors.ts
1207
+ var isSignalMonitorType = (t) => SIGNAL_MONITOR_TYPES.includes(t);
1208
+ var SIGNAL_KINDS = ["event", "check_in", "span", "log"];
1209
+ var SELECTOR_OPS = ["eq", "ne", "lt", "le", "gt", "ge", "in", "exists", "not_exists", "prefix"];
1210
+ var NUMERIC_OPS = new Set(["lt", "le", "gt", "ge"]);
1211
+ var VALUELESS_OPS = new Set(["exists", "not_exists"]);
1212
+ var COMPARATORS = ["lt", "gt", "outside"];
1213
+ var MISSING_DATA_POLICIES = ["alert", "keep", "resolve", "treat_as_zero"];
1214
+ var SEVERITIES = ["critical", "high", "medium", "low"];
1215
+ var OCCURRENCE_STATES = [
1216
+ "pending",
1217
+ "in_progress",
1218
+ "success",
1219
+ "late_success",
1220
+ "missed",
1221
+ "failed",
1222
+ "cancelled"
1223
+ ];
1224
+ var OCCURRENCE_OPEN = new Set(["pending", "in_progress"]);
1225
+ var SIGNAL_LIMITS = {
1226
+ matchMax: 5,
1227
+ assertMax: 5,
1228
+ inValuesMax: 20,
1229
+ valueMax: 256,
1230
+ keyMax: 128,
1231
+ environmentsMax: MONITOR_LIMITS.expectedEnvironmentsMax,
1232
+ windowMinutesMin: 1,
1233
+ windowMinutesMax: 1440,
1234
+ thresholdMax: 1e6,
1235
+ graceMinutesMax: 1440,
1236
+ progressMinutesMin: 1,
1237
+ progressMinutesMax: 1440,
1238
+ occurrenceIdMax: 128,
1239
+ occurrenceDueMaxDays: 35,
1240
+ lateSuccessDays: 7,
1241
+ evaluateEverySeconds: 15,
1242
+ settleSeconds: 20,
1243
+ countMaxDelayMinutes: 10,
1244
+ countMinutesPerTick: 60,
1245
+ windowsPerTick: 120,
1246
+ monitorsPerQuery: 50,
1247
+ bucketRowsPerQuery: 9000,
1248
+ backtestDays: 30,
1249
+ bucketRetentionMinutes: 2 * 1440 + 60,
1250
+ occurrencesKeptFinished: 1000,
1251
+ occurrencesPageSize: 50,
1252
+ runIdsPerQuery: 500,
1253
+ dueJudgedPerTick: 5000,
1254
+ queryMaxSeconds: 5
1255
+ };
1256
+ var SELECTOR_KEY_RE = /^(?:tags\.[A-Za-z0-9_.:-]{1,100}|[A-Za-z_][A-Za-z0-9_.:-]{0,127})$/;
1257
+ var scalar = z8.union([z8.string().max(SIGNAL_LIMITS.valueMax), z8.number().finite(), z8.boolean()]);
1258
+ var selectorConditionSchema = z8.object({
1259
+ key: z8.string().min(1).max(SIGNAL_LIMITS.keyMax).regex(SELECTOR_KEY_RE),
1260
+ op: z8.enum(SELECTOR_OPS),
1261
+ value: z8.union([scalar, z8.array(z8.string().max(SIGNAL_LIMITS.valueMax)).min(1).max(SIGNAL_LIMITS.inValuesMax)]).optional()
1262
+ }).superRefine((c, ctx) => {
1263
+ const bad = (message) => ctx.addIssue({ code: "custom", path: ["value"], message });
1264
+ if (VALUELESS_OPS.has(c.op)) {
1265
+ if (c.value !== undefined)
1266
+ bad("no_value");
1267
+ return;
1268
+ }
1269
+ if (c.value === undefined)
1270
+ return bad("value");
1271
+ if (c.op === "in") {
1272
+ if (!Array.isArray(c.value))
1273
+ bad("list");
1274
+ return;
1275
+ }
1276
+ if (Array.isArray(c.value))
1277
+ return bad("scalar");
1278
+ if (NUMERIC_OPS.has(c.op) && toNumber(c.value) === null)
1279
+ bad("number");
1280
+ if (c.op === "prefix" && (typeof c.value !== "string" || c.value.length === 0))
1281
+ bad("text");
1282
+ });
1283
+ var environmentListSchema = z8.array(z8.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");
1284
+ var selectorSchema = z8.object({
1285
+ signal: z8.enum(SIGNAL_KINDS),
1286
+ match: z8.array(selectorConditionSchema).max(SIGNAL_LIMITS.matchMax)
1287
+ });
1288
+ function toNumber(v) {
1289
+ if (typeof v === "number")
1290
+ return Number.isFinite(v) ? v : null;
1291
+ if (typeof v === "string" && v.trim() !== "" && v.length <= 64) {
1292
+ const n = Number(v);
1293
+ return Number.isFinite(n) ? n : null;
1294
+ }
1295
+ return null;
1296
+ }
1297
+ var minutes = (min, max) => z8.number().int().min(min).max(max);
1298
+ var threshold = z8.number().int().min(0).max(SIGNAL_LIMITS.thresholdMax);
1299
+ var recovery = z8.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax);
1300
+ var common = {
1301
+ environments: environmentListSchema,
1302
+ severity: z8.enum(SEVERITIES),
1303
+ recovery_threshold: recovery
1304
+ };
1305
+ var countSettingsSchema = z8.object({
1306
+ type: z8.literal("count"),
1307
+ selector: selectorSchema,
1308
+ window_minutes: minutes(SIGNAL_LIMITS.windowMinutesMin, SIGNAL_LIMITS.windowMinutesMax),
1309
+ comparator: z8.enum(COMPARATORS),
1310
+ threshold,
1311
+ threshold_high: threshold.nullable(),
1312
+ missing_data: z8.enum(MISSING_DATA_POLICIES),
1313
+ ...common
1314
+ }).superRefine((s, ctx) => {
1315
+ if (s.comparator === "outside" && (s.threshold_high === null || s.threshold_high <= s.threshold)) {
1316
+ ctx.addIssue({ code: "custom", path: ["threshold_high"], message: "threshold_high" });
1317
+ }
1318
+ if (s.comparator !== "outside" && s.threshold_high !== null) {
1319
+ ctx.addIssue({ code: "custom", path: ["threshold_high"], message: "threshold_high" });
1320
+ }
1321
+ if (s.comparator === "lt" && s.threshold === 0) {
1322
+ ctx.addIssue({ code: "custom", path: ["threshold"], message: "threshold" });
1323
+ }
1324
+ });
1325
+ var assertionSettingsSchema = z8.object({
1326
+ type: z8.literal("assertion"),
1327
+ selector: selectorSchema,
1328
+ assert: z8.array(selectorConditionSchema).min(1).max(SIGNAL_LIMITS.assertMax),
1329
+ window_minutes: minutes(SIGNAL_LIMITS.windowMinutesMin, SIGNAL_LIMITS.windowMinutesMax),
1330
+ threshold: z8.number().int().min(1).max(SIGNAL_LIMITS.thresholdMax),
1331
+ missing_data: z8.enum(MISSING_DATA_POLICIES),
1332
+ ...common
1333
+ });
1334
+ var deadlineSettingsSchema = z8.object({
1335
+ type: z8.literal("deadline"),
1336
+ occurrence_grace_minutes: minutes(0, SIGNAL_LIMITS.graceMinutesMax),
1337
+ progress_timeout_minutes: minutes(SIGNAL_LIMITS.progressMinutesMin, SIGNAL_LIMITS.progressMinutesMax).nullable(),
1338
+ ...common
1339
+ });
1340
+ var progressSettingsSchema = z8.object({
1341
+ type: z8.literal("progress"),
1342
+ progress_timeout_minutes: minutes(SIGNAL_LIMITS.progressMinutesMin, SIGNAL_LIMITS.progressMinutesMax),
1343
+ ...common
1344
+ });
1345
+ var signalSettingsSchema = z8.discriminatedUnion("type", [
1346
+ countSettingsSchema,
1347
+ assertionSettingsSchema,
1348
+ deadlineSettingsSchema,
1349
+ progressSettingsSchema
1350
+ ]);
1351
+ function settingsFromRow(row) {
1352
+ if (!isSignalMonitorType(row.type) || !row.signal_settings || typeof row.signal_settings !== "object")
1353
+ return null;
1354
+ const r = signalSettingsSchema.safeParse({
1355
+ ...row.signal_settings,
1356
+ type: row.type,
1357
+ environments: [...row.expected_environments],
1358
+ severity: row.severity,
1359
+ recovery_threshold: row.recovery_threshold
1360
+ });
1361
+ return r.success ? r.data : null;
1362
+ }
1363
+ var signalMonitorInputSchema = z8.object({
1364
+ name: z8.string().trim().min(1).max(MONITOR_LIMITS.nameMax),
1365
+ settings: signalSettingsSchema
1366
+ });
1367
+ var signalMonitorDefinitionSchema = z8.object({
1368
+ id: z8.guid(),
1369
+ project_id: z8.number().int().positive(),
1370
+ slug: z8.string().regex(SLUG_RE),
1371
+ settings: signalSettingsSchema,
1372
+ paused_until: z8.string().datetime().nullable(),
1373
+ created_at: z8.string().datetime(),
1374
+ revision: z8.number().int().nonnegative()
1375
+ });
1376
+ var signalLimitsConfigSchema = z8.object({
1377
+ pending_occurrences_per_monitor: z8.number().int().min(1).max(1e6),
1378
+ pending_occurrences_per_project: z8.number().int().min(1).max(1e7)
1379
+ });
1380
+ var OCCURRENCE_ID_RE = /^[A-Za-z0-9._:-]{1,128}$/;
1381
+ var occurrenceInputSchema = z8.object({
1382
+ monitor_slug: z8.string().regex(SLUG_RE),
1383
+ occurrence_id: z8.string().regex(OCCURRENCE_ID_RE),
1384
+ due_at: z8.string().datetime({ offset: true }),
1385
+ environment: z8.string().trim().min(1).max(MONITOR_LIMITS.environmentMax).regex(/^[A-Za-z0-9._-]+$/).optional()
1386
+ });
1387
+ var occurrenceCancelSchema = occurrenceInputSchema.pick({ monitor_slug: true, occurrence_id: true, environment: true });
1388
+ var OCCURRENCE_PAST_SKEW_MS = 5 * 60000;
1389
+ var occurrenceRowSchema = z8.object({
1390
+ occurrence_id: z8.string().max(SIGNAL_LIMITS.occurrenceIdMax),
1391
+ environment: z8.string().max(MONITOR_LIMITS.environmentMax),
1392
+ state: z8.enum(OCCURRENCE_STATES),
1393
+ due_at: z8.string().datetime(),
1394
+ deadline_at: z8.string().datetime(),
1395
+ registered_at: z8.string().datetime(),
1396
+ started_at: z8.string().datetime().nullable(),
1397
+ last_signal_at: z8.string().datetime().nullable(),
1398
+ ended_at: z8.string().datetime().nullable(),
1399
+ stalled: z8.boolean()
1115
1400
  });
1116
- var incidentReviewSchema = z6.object({ incident_id: z6.guid() });
1401
+ var occurrencesResponseSchema = z8.object({
1402
+ occurrences: z8.array(occurrenceRowSchema).max(SIGNAL_LIMITS.occurrencesPageSize),
1403
+ pending: z8.number().int().nonnegative(),
1404
+ next_due_at: z8.string().datetime().nullable(),
1405
+ next_cursor: z8.string().max(64).nullable(),
1406
+ refused_24h: z8.number().int().nonnegative()
1407
+ });
1408
+ var signalSeriesSchema = z8.object({
1409
+ environment: z8.string().max(MONITOR_LIMITS.environmentMax),
1410
+ buckets: z8.array(z8.object({ minute: z8.string().datetime(), matched: z8.number().int().nonnegative(), violations: z8.number().int().nonnegative(), lossy: z8.boolean() })).max(1440),
1411
+ counted_through: z8.string().datetime().nullable()
1412
+ });
1413
+ var signalResponseSchema = z8.object({
1414
+ series: z8.array(signalSeriesSchema).max(SIGNAL_LIMITS.environmentsMax),
1415
+ runs: z8.array(z8.object({
1416
+ run_id: z8.string().max(SIGNAL_LIMITS.occurrenceIdMax),
1417
+ environment: z8.string().max(MONITOR_LIMITS.environmentMax),
1418
+ started_at: z8.string().datetime(),
1419
+ last_signal_at: z8.string().datetime(),
1420
+ stalled: z8.boolean()
1421
+ })).max(SIGNAL_LIMITS.occurrencesPageSize)
1422
+ });
1423
+ var backtestSettingsSchema = z8.union([countSettingsSchema, assertionSettingsSchema]);
1424
+ var backtestResponseSchema = z8.object({
1425
+ alerts: z8.number().int().nonnegative(),
1426
+ windows: z8.number().int().nonnegative(),
1427
+ violated_windows: z8.number().int().nonnegative(),
1428
+ first_at: z8.string().datetime().nullable(),
1429
+ last_at: z8.string().datetime().nullable(),
1430
+ days: z8.number().nonnegative(),
1431
+ matched_total: z8.number().int().nonnegative(),
1432
+ violations_total: z8.number().int().nonnegative()
1433
+ });
1434
+
1435
+ // ../src/shared/contracts/notifications.ts
1436
+ var NOTIFY_LIMITS = {
1437
+ policiesMax: 20,
1438
+ nameMax: 80,
1439
+ chainMax: 5,
1440
+ escalateMinutesMin: 5,
1441
+ escalateMinutesMax: 240,
1442
+ digestRowsMax: 50,
1443
+ slotSearchDays: 8
1444
+ };
1445
+ var HOLDABLE_SEVERITIES = ["medium", "low"];
1446
+ var DIGEST_MODES = ["off", "hourly", "daily"];
1447
+ var timeOfDay2 = z9.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/);
1448
+ var unique = (xs) => new Set(xs).size === xs.length;
1449
+ var quietHoursSchema = z9.object({
1450
+ days: z9.array(weekdaySchema).min(1).max(7).refine(unique),
1451
+ start: timeOfDay2,
1452
+ end: timeOfDay2
1453
+ }).refine((q) => q.start !== q.end, { path: ["end"] });
1454
+ var policyInputSchema = z9.object({
1455
+ name: z9.string().trim().min(1).max(NOTIFY_LIMITS.nameMax).regex(/^[^\p{Cc}]*$/u),
1456
+ timezone: z9.string().trim().min(1).max(64).refine(validTimeZone),
1457
+ quietHours: quietHoursSchema.nullable(),
1458
+ quietSeverities: z9.array(z9.enum(HOLDABLE_SEVERITIES)).max(2).refine(unique),
1459
+ digest: z9.enum(DIGEST_MODES),
1460
+ digestAt: timeOfDay2.nullable(),
1461
+ digestSeverities: z9.array(z9.enum(HOLDABLE_SEVERITIES)).max(2).refine(unique),
1462
+ fallback: z9.array(z9.guid()).max(NOTIFY_LIMITS.chainMax).refine(unique),
1463
+ escalateAfterMinutes: z9.number().int().min(NOTIFY_LIMITS.escalateMinutesMin).max(NOTIFY_LIMITS.escalateMinutesMax).nullable(),
1464
+ escalation: z9.array(z9.guid()).max(NOTIFY_LIMITS.chainMax).refine(unique)
1465
+ }).superRefine((p, ctx) => {
1466
+ if (p.digest === "daily" !== (p.digestAt !== null))
1467
+ ctx.addIssue({ code: "custom", path: ["digestAt"], message: "digest_at" });
1468
+ if (p.escalateAfterMinutes !== null !== p.escalation.length > 0)
1469
+ ctx.addIssue({ code: "custom", path: ["escalation"], message: "escalation" });
1470
+ });
1471
+ var MIN = 60000;
1472
+ var HOUR = 60 * MIN;
1473
+ var DAY = 24 * HOUR;
1474
+
1475
+ // ../src/shared/contracts/api-ops/incidents.ts
1476
+ var incidentOnly = z10.object({ workspaceId: uuid, incidentId: uuid });
1477
+ var note = z10.string().trim().min(1).max(2000).regex(/^[^\u0000-\u0008\u000b\u000c\u000e-\u001f]*$/);
1478
+ var INCIDENT_KINDS = ["monitor", "uptime", "slo", "issue"];
1479
+ var INCIDENT_GROUP_BY = ["monitor", "project_env"];
1480
+ var incidentRuleInputSchema = z10.object({
1481
+ name: z10.string().trim().min(1).max(80).regex(/^[^\p{Cc}]*$/u),
1482
+ isEnabled: z10.boolean(),
1483
+ position: z10.number().int().min(0).max(1000).default(0),
1484
+ projectIds: z10.array(z10.number().int().positive()).max(50),
1485
+ environments: z10.array(z10.string().trim().min(1).max(64)).max(20),
1486
+ kinds: z10.array(z10.enum(INCIDENT_KINDS)).min(1).max(4),
1487
+ minSeverity: z10.enum(SEVERITIES),
1488
+ groupBy: z10.enum(INCIDENT_GROUP_BY),
1489
+ windowMinutes: z10.number().int().min(5).max(240),
1490
+ recoveryHoldMinutes: z10.number().int().min(0).max(1440)
1491
+ });
1492
+ var INCIDENT_INPUTS = {
1493
+ list: z10.object({
1494
+ workspaceId: uuid,
1495
+ limit: pageLimit,
1496
+ cursor,
1497
+ state: z10.enum(["active", "resolved", "all"]).default("all")
1498
+ }),
1499
+ incidentOnly,
1500
+ resolve: incidentOnly.extend({ note: note.max(500) }),
1501
+ note: incidentOnly.extend({ note }),
1502
+ update: incidentOnly.extend({
1503
+ title: z10.string().trim().min(1).max(120).regex(/^[^\p{Cc}]*$/u).optional(),
1504
+ ownerUserId: uuid.nullable().optional()
1505
+ }),
1506
+ workspace: z10.object({ workspaceId: uuid }),
1507
+ saveRule: z10.object({ workspaceId: uuid, ruleId: uuid.nullable(), input: incidentRuleInputSchema }),
1508
+ ruleOnly: z10.object({ workspaceId: uuid, ruleId: uuid }),
1509
+ savePolicy: z10.object({
1510
+ workspaceId: uuid,
1511
+ policyId: uuid.nullable(),
1512
+ isDefault: z10.boolean(),
1513
+ input: policyInputSchema
1514
+ }),
1515
+ policyOnly: z10.object({ workspaceId: uuid, policyId: uuid })
1516
+ };
1517
+ var I = INCIDENT_INPUTS;
1518
+ var w = "incidents:write";
1519
+ var INCIDENT_OPERATIONS = [
1520
+ op({
1521
+ id: "incidents.list",
1522
+ method: "GET",
1523
+ path: "/v1/incidents",
1524
+ scope: "incidents:read",
1525
+ sensitivity: "normal",
1526
+ kind: "read",
1527
+ rpcs: ["api_read_incidents"],
1528
+ input: I.list,
1529
+ workspace: true,
1530
+ idempotency: "none",
1531
+ paged: true,
1532
+ mcp: "reliability",
1533
+ summary: "Incidents (INC-n): state, severity and peak, owner, linked alert count; newest first.",
1534
+ ui: []
1535
+ }),
1536
+ op({
1537
+ id: "incidents.get",
1538
+ method: "GET",
1539
+ path: "/v1/incidents/{incident_id}",
1540
+ scope: "incidents:read",
1541
+ sensitivity: "normal",
1542
+ kind: "read",
1543
+ rpcs: ["api_read_incident"],
1544
+ input: I.incidentOnly,
1545
+ workspace: true,
1546
+ idempotency: "none",
1547
+ mcp: "reliability",
1548
+ summary: "One incident with its linked alerts, timeline (notes included) and message deliveries (`accepted` = the provider took it; only a person acknowledges).",
1549
+ ui: []
1550
+ }),
1551
+ op({
1552
+ id: "incidents.acknowledge",
1553
+ method: "POST",
1554
+ path: "/v1/incidents/{incident_id}/ack",
1555
+ scope: w,
1556
+ sensitivity: "normal",
1557
+ kind: "write",
1558
+ rpcs: ["acknowledge_incident"],
1559
+ input: I.incidentOnly,
1560
+ workspace: true,
1561
+ idempotency: "optional",
1562
+ mcp: "configure",
1563
+ summary: "Take ownership of an open incident; stops its escalation. Members and up.",
1564
+ ui: ["incidents#acknowledgeIncident"]
1565
+ }),
1566
+ op({
1567
+ id: "incidents.resolve",
1568
+ method: "POST",
1569
+ path: "/v1/incidents/{incident_id}/resolve",
1570
+ scope: w,
1571
+ sensitivity: "normal",
1572
+ kind: "write",
1573
+ rpcs: ["resolve_incident"],
1574
+ input: I.resolve,
1575
+ workspace: true,
1576
+ idempotency: "optional",
1577
+ mcp: "configure",
1578
+ summary: 'Close an incident by hand with a reason (1–500 characters); it is labelled "not verified".',
1579
+ ui: ["incidents#resolveIncident"]
1580
+ }),
1581
+ op({
1582
+ id: "incidents.note",
1583
+ method: "POST",
1584
+ path: "/v1/incidents/{incident_id}/notes",
1585
+ scope: w,
1586
+ sensitivity: "normal",
1587
+ kind: "write",
1588
+ rpcs: ["add_incident_note"],
1589
+ input: I.note,
1590
+ workspace: true,
1591
+ idempotency: "optional",
1592
+ mcp: "configure",
1593
+ summary: "Add a note to the incident timeline (plain text, ≤ 2,000 characters).",
1594
+ ui: ["incidents#addIncidentNote"]
1595
+ }),
1596
+ op({
1597
+ id: "incidents.update",
1598
+ method: "PATCH",
1599
+ path: "/v1/incidents/{incident_id}",
1600
+ scope: w,
1601
+ sensitivity: "normal",
1602
+ kind: "write",
1603
+ rpcs: ["update_incident"],
1604
+ input: I.update,
1605
+ workspace: true,
1606
+ idempotency: "none",
1607
+ mcp: "configure",
1608
+ summary: "Rename an incident or assign it to a member (`owner_user_id: null` clears it).",
1609
+ ui: ["incidents#updateIncident"]
1610
+ }),
1611
+ op({
1612
+ id: "incident_rules.list",
1613
+ method: "GET",
1614
+ path: "/v1/incident-rules",
1615
+ scope: "alerts:read",
1616
+ sensitivity: "normal",
1617
+ kind: "read",
1618
+ rpcs: ["api_read_incident_rules"],
1619
+ input: I.workspace,
1620
+ workspace: true,
1621
+ idempotency: "none",
1622
+ mcp: "investigate",
1623
+ summary: "Rules that turn alerts into incidents: match, grouping, window and recovery wait.",
1624
+ ui: []
1625
+ }),
1626
+ op({
1627
+ id: "incident_rules.save",
1628
+ method: "POST",
1629
+ path: "/v1/incident-rules",
1630
+ scope: "alerts:write",
1631
+ sensitivity: "normal",
1632
+ kind: "write",
1633
+ rpcs: ["save_incident_rule"],
1634
+ input: I.saveRule,
1635
+ workspace: true,
1636
+ idempotency: "optional",
1637
+ mcp: "configure",
1638
+ summary: "Create (`rule_id` null) or replace an incident rule. Admins.",
1639
+ ui: ["incidents#saveIncidentRule"]
1640
+ }),
1641
+ op({
1642
+ id: "incident_rules.delete",
1643
+ method: "DELETE",
1644
+ path: "/v1/incident-rules/{rule_id}",
1645
+ scope: "alerts:write",
1646
+ sensitivity: "normal",
1647
+ kind: "write",
1648
+ rpcs: ["delete_incident_rule"],
1649
+ input: I.ruleOnly,
1650
+ workspace: true,
1651
+ idempotency: "none",
1652
+ mcp: "configure",
1653
+ summary: "Delete an incident rule; open incidents stay as they are.",
1654
+ ui: ["incidents#deleteIncidentRule"]
1655
+ }),
1656
+ op({
1657
+ id: "notification_policies.list",
1658
+ method: "GET",
1659
+ path: "/v1/notification-policies",
1660
+ scope: "alerts:read",
1661
+ sensitivity: "normal",
1662
+ kind: "read",
1663
+ rpcs: ["api_read_notification_policies"],
1664
+ input: I.workspace,
1665
+ workspace: true,
1666
+ idempotency: "none",
1667
+ mcp: "investigate",
1668
+ summary: "Notification policies: quiet hours, digest, fallback chain and escalation.",
1669
+ ui: []
1670
+ }),
1671
+ op({
1672
+ id: "notification_policies.save",
1673
+ method: "POST",
1674
+ path: "/v1/notification-policies",
1675
+ scope: "alerts:write",
1676
+ sensitivity: "normal",
1677
+ kind: "write",
1678
+ rpcs: ["save_notification_policy"],
1679
+ input: I.savePolicy,
1680
+ workspace: true,
1681
+ idempotency: "optional",
1682
+ mcp: "configure",
1683
+ summary: "Create (`policy_id` null) or replace a policy. Critical and high are never held; chains use existing destinations only. Admins.",
1684
+ ui: ["incidents#saveNotificationPolicy"]
1685
+ }),
1686
+ op({
1687
+ id: "notification_policies.delete",
1688
+ method: "DELETE",
1689
+ path: "/v1/notification-policies/{policy_id}",
1690
+ scope: "alerts:write",
1691
+ sensitivity: "normal",
1692
+ kind: "write",
1693
+ rpcs: ["delete_notification_policy"],
1694
+ input: I.policyOnly,
1695
+ workspace: true,
1696
+ idempotency: "none",
1697
+ mcp: "configure",
1698
+ summary: "Delete a policy (not the default); its rules fall back to the default policy.",
1699
+ ui: ["incidents#deleteNotificationPolicy"]
1700
+ })
1701
+ ];
1702
+
1703
+ // ../src/shared/contracts/api-ops/monitors.ts
1704
+ import { z as z15 } from "zod";
1705
+
1706
+ // ../src/shared/contracts/heartbeat.ts
1707
+ import { z as z12 } from "zod";
1117
1708
 
1118
1709
  // ../src/shared/contracts/signed-message.ts
1119
- import { z as z7 } from "zod";
1120
- var nodeIdSchema = z7.guid();
1121
- var signedEnvelopeSchema = z7.object({
1710
+ import { z as z11 } from "zod";
1711
+ var nodeIdSchema = z11.guid();
1712
+ var signedEnvelopeSchema = z11.object({
1122
1713
  node_id: nodeIdSchema,
1123
- ts: z7.number().int().positive(),
1124
- nonce: z7.string().regex(/^[A-Za-z0-9_-]{16,64}$/),
1125
- payload: z7.record(z7.string(), z7.unknown()),
1126
- sig: z7.string().regex(/^[A-Za-z0-9_-]{86}$/)
1714
+ ts: z11.number().int().positive(),
1715
+ nonce: z11.string().regex(/^[A-Za-z0-9_-]{16,64}$/),
1716
+ payload: z11.record(z11.string(), z11.unknown()),
1717
+ sig: z11.string().regex(/^[A-Za-z0-9_-]{86}$/)
1127
1718
  });
1128
1719
 
1129
1720
  // ../src/shared/contracts/heartbeat.ts
@@ -1161,78 +1752,78 @@ var HEARTBEAT_LIMITS = {
1161
1752
  diagnosticsPerRun: 5
1162
1753
  };
1163
1754
  var PAUSED_FOREVER_MS = Date.parse("9999-12-31T00:00:00.000Z");
1164
- var uuid2 = z8.guid();
1165
- var ms = z8.number().int().nonnegative();
1166
- var hex64 = z8.string().regex(/^[0-9a-f]{64}$/);
1167
- var envName2 = z8.string().min(1).max(MONITOR_LIMITS.environmentMax);
1168
- var heartbeatMonitorConfigSchema = z8.object({
1755
+ var uuid2 = z12.guid();
1756
+ var ms = z12.number().int().nonnegative();
1757
+ var hex64 = z12.string().regex(/^[0-9a-f]{64}$/);
1758
+ var envName2 = z12.string().min(1).max(MONITOR_LIMITS.environmentMax);
1759
+ var heartbeatMonitorConfigSchema = z12.object({
1169
1760
  id: uuid2,
1170
- project_id: z8.number().int().positive(),
1171
- slug: z8.string().regex(SLUG_RE),
1761
+ project_id: z12.number().int().positive(),
1762
+ slug: z12.string().regex(SLUG_RE),
1172
1763
  environment: envName2,
1173
1764
  schedule: scheduleSchema,
1174
- timezone: z8.string().min(1).max(64),
1175
- grace_min: z8.number().int().min(MONITOR_LIMITS.checkinMarginMin).max(MONITOR_LIMITS.checkinMarginMax),
1176
- max_runtime_min: z8.number().int().min(MONITOR_LIMITS.maxRuntimeMin).max(MONITOR_LIMITS.maxRuntimeMax),
1177
- failure_threshold: z8.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax),
1178
- recovery_threshold: z8.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax),
1765
+ timezone: z12.string().min(1).max(64),
1766
+ grace_min: z12.number().int().min(MONITOR_LIMITS.checkinMarginMin).max(MONITOR_LIMITS.checkinMarginMax),
1767
+ max_runtime_min: z12.number().int().min(MONITOR_LIMITS.maxRuntimeMin).max(MONITOR_LIMITS.maxRuntimeMax),
1768
+ failure_threshold: z12.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax),
1769
+ recovery_threshold: z12.number().int().min(MONITOR_LIMITS.thresholdMin).max(MONITOR_LIMITS.thresholdMax),
1179
1770
  paused_until: ms.nullable(),
1180
1771
  created_at: ms
1181
1772
  });
1182
- var heartbeatTokenConfigSchema = z8.object({
1773
+ var heartbeatTokenConfigSchema = z12.object({
1183
1774
  id: uuid2,
1184
1775
  monitor_id: uuid2,
1185
1776
  hash: hex64,
1186
1777
  expires_at: ms.nullable()
1187
1778
  });
1188
- var heartbeatSyncSchema = z8.object({
1189
- v: z8.literal(1),
1779
+ var heartbeatSyncSchema = z12.object({
1780
+ v: z12.literal(1),
1190
1781
  workspace_id: uuid2,
1191
- route: z8.string().regex(PING_ROUTE_RE),
1192
- revision: z8.number().int().positive(),
1193
- workspace_status: z8.enum(["active", "suspended", "deleting"]),
1194
- ingest_kill: z8.boolean(),
1195
- limits: z8.object({
1196
- check_in_rate_per_sec: z8.number().int().positive(),
1197
- check_in_burst: z8.number().int().positive(),
1198
- monthly_check_in_cap: z8.number().int().positive()
1199
- }),
1200
- projects: z8.array(z8.object({ id: z8.number().int().positive(), node_id: nodeIdSchema.nullable() })).max(1000),
1201
- monitors: z8.array(heartbeatMonitorConfigSchema).max(HEARTBEAT_LIMITS.maxMonitorsPerWorkspace),
1202
- tokens: z8.array(heartbeatTokenConfigSchema).max(HEARTBEAT_LIMITS.maxMonitorsPerWorkspace * 2)
1782
+ route: z12.string().regex(PING_ROUTE_RE),
1783
+ revision: z12.number().int().positive(),
1784
+ workspace_status: z12.enum(["active", "suspended", "deleting"]),
1785
+ ingest_kill: z12.boolean(),
1786
+ limits: z12.object({
1787
+ check_in_rate_per_sec: z12.number().int().positive(),
1788
+ check_in_burst: z12.number().int().positive(),
1789
+ monthly_check_in_cap: z12.number().int().positive()
1790
+ }),
1791
+ projects: z12.array(z12.object({ id: z12.number().int().positive(), node_id: nodeIdSchema.nullable() })).max(1000),
1792
+ monitors: z12.array(heartbeatMonitorConfigSchema).max(HEARTBEAT_LIMITS.maxMonitorsPerWorkspace),
1793
+ tokens: z12.array(heartbeatTokenConfigSchema).max(HEARTBEAT_LIMITS.maxMonitorsPerWorkspace * 2)
1203
1794
  });
1204
- var signedHeartbeatSyncSchema = z8.object({
1205
- body: z8.string().min(2).max(4 * 1024 * 1024),
1206
- ts: z8.number().int().positive(),
1207
- kid: z8.string().regex(/^[A-Za-z0-9_-]{1,40}$/),
1208
- sig: z8.string().regex(/^[A-Za-z0-9_-]{86}$/)
1795
+ var signedHeartbeatSyncSchema = z12.object({
1796
+ body: z12.string().min(2).max(4 * 1024 * 1024),
1797
+ ts: z12.number().int().positive(),
1798
+ kid: z12.string().regex(/^[A-Za-z0-9_-]{1,40}$/),
1799
+ sig: z12.string().regex(/^[A-Za-z0-9_-]{86}$/)
1209
1800
  });
1210
- var heartbeatHourSchema = z8.object({
1801
+ var heartbeatHourSchema = z12.object({
1211
1802
  monitor_id: uuid2,
1212
- hour: z8.string().datetime(),
1213
- ok: z8.number().int().nonnegative(),
1214
- failed: z8.number().int().nonnegative(),
1215
- started: z8.number().int().nonnegative(),
1216
- missed: z8.number().int().nonnegative(),
1217
- logs: z8.number().int().nonnegative()
1803
+ hour: z12.string().datetime(),
1804
+ ok: z12.number().int().nonnegative(),
1805
+ failed: z12.number().int().nonnegative(),
1806
+ started: z12.number().int().nonnegative(),
1807
+ missed: z12.number().int().nonnegative(),
1808
+ logs: z12.number().int().nonnegative()
1218
1809
  });
1219
- var heartbeatReportSchema = z8.object({
1220
- v: z8.literal(1),
1810
+ var heartbeatReportSchema = z12.object({
1811
+ v: z12.literal(1),
1221
1812
  workspace_id: uuid2,
1222
- route: z8.string().regex(PING_ROUTE_RE),
1223
- revision: z8.number().int().nonnegative(),
1224
- sent_at: z8.string().datetime(),
1225
- incidents: z8.array(monitorIncidentSchema).max(HEARTBEAT_LIMITS.reportMaxIncidents),
1226
- statuses: z8.array(monitorStatusSchema).max(HEARTBEAT_LIMITS.reportMaxStatuses),
1227
- hours: z8.array(heartbeatHourSchema).max(HEARTBEAT_LIMITS.reportMaxHours),
1228
- token_uses: z8.array(z8.object({ token_id: uuid2, last_used_at: z8.string().datetime() })).max(HEARTBEAT_LIMITS.maxMonitorsPerWorkspace * 2)
1813
+ route: z12.string().regex(PING_ROUTE_RE),
1814
+ revision: z12.number().int().nonnegative(),
1815
+ sent_at: z12.string().datetime(),
1816
+ incidents: z12.array(monitorIncidentSchema).max(HEARTBEAT_LIMITS.reportMaxIncidents),
1817
+ statuses: z12.array(monitorStatusSchema).max(HEARTBEAT_LIMITS.reportMaxStatuses),
1818
+ hours: z12.array(heartbeatHourSchema).max(HEARTBEAT_LIMITS.reportMaxHours),
1819
+ token_uses: z12.array(z12.object({ token_id: uuid2, last_used_at: z12.string().datetime() })).max(HEARTBEAT_LIMITS.maxMonitorsPerWorkspace * 2)
1229
1820
  });
1230
1821
  var ENCODER = new TextEncoder;
1231
1822
  var UTF8 = new TextDecoder("utf-8", { fatal: false, ignoreBOM: false });
1232
1823
  var TOKEN_IN_TEXT = new RegExp(PING_TOKEN_PATTERN, "g");
1233
1824
 
1234
1825
  // ../src/shared/contracts/slo.ts
1235
- import { z as z9 } from "zod";
1826
+ import { z as z13 } from "zod";
1236
1827
 
1237
1828
  // ../src/shared/contracts/vocab/slo.ts
1238
1829
  var SLO_SOURCES = ["uptime", "monitor", "heartbeat", "spans"];
@@ -1264,17 +1855,17 @@ var SLO_SOURCE_META = {
1264
1855
  heartbeat: { provenance: "ping_token", estimated: false, slis: ["availability"], budgeting: "Occurrences" },
1265
1856
  spans: { provenance: "ingest_key", estimated: true, slis: ["availability", "latency"], budgeting: "Occurrences" }
1266
1857
  };
1267
- var nodeSloSchema = z9.object({
1268
- slo_id: z9.guid(),
1269
- project_id: z9.number().int().positive(),
1270
- source: z9.enum(["monitor", "spans"]),
1271
- sli: z9.enum(SLO_SLIS),
1272
- monitor_id: z9.guid().optional(),
1273
- environment: z9.string().min(1).max(SLO_LIMITS.environmentMaxChars).optional(),
1274
- service: z9.string().min(1).max(128).optional(),
1275
- operation: z9.string().min(1).max(256).optional(),
1276
- latency_threshold_ms: z9.number().int().min(1).max(60000).optional(),
1277
- public_sources: z9.boolean()
1858
+ var nodeSloSchema = z13.object({
1859
+ slo_id: z13.guid(),
1860
+ project_id: z13.number().int().positive(),
1861
+ source: z13.enum(["monitor", "spans"]),
1862
+ sli: z13.enum(SLO_SLIS),
1863
+ monitor_id: z13.guid().optional(),
1864
+ environment: z13.string().min(1).max(SLO_LIMITS.environmentMaxChars).optional(),
1865
+ service: z13.string().min(1).max(128).optional(),
1866
+ operation: z13.string().min(1).max(256).optional(),
1867
+ latency_threshold_ms: z13.number().int().min(1).max(60000).optional(),
1868
+ public_sources: z13.boolean()
1278
1869
  }).superRefine((v, ctx) => {
1279
1870
  if (v.source === "monitor" && (!v.monitor_id || v.sli !== "availability"))
1280
1871
  ctx.addIssue({ code: "custom", path: ["monitor_id"], message: "INVALID_INPUT" });
@@ -1283,27 +1874,27 @@ var nodeSloSchema = z9.object({
1283
1874
  if (v.sli === "latency" !== (v.latency_threshold_ms !== undefined))
1284
1875
  ctx.addIssue({ code: "custom", path: ["latency_threshold_ms"], message: "INVALID_INPUT" });
1285
1876
  });
1286
- var sliCountsSchema = z9.object({
1287
- minute: z9.string().datetime(),
1288
- items: z9.array(z9.object({ slo_id: z9.guid(), good: z9.number().int().min(0), total: z9.number().int().min(0) }).refine((x) => x.good <= x.total, { message: "INVALID_INPUT" })).max(SLO_LIMITS.sliItemsPerMessage)
1877
+ var sliCountsSchema = z13.object({
1878
+ minute: z13.string().datetime(),
1879
+ items: z13.array(z13.object({ slo_id: z13.guid(), good: z13.number().int().min(0), total: z13.number().int().min(0) }).refine((x) => x.good <= x.total, { message: "INVALID_INPUT" })).max(SLO_LIMITS.sliItemsPerMessage)
1289
1880
  });
1290
- var sloInputSchema = z9.object({
1291
- name: z9.string().trim().min(1).max(SLO_LIMITS.nameMaxChars),
1292
- description: z9.string().max(SLO_LIMITS.descriptionMaxChars).default(""),
1293
- source: z9.enum(SLO_SOURCES),
1294
- sourceRef: z9.object({
1295
- id: z9.guid().optional(),
1296
- projectId: z9.number().int().positive().optional(),
1297
- service: z9.string().max(128).optional(),
1298
- operation: z9.string().max(256).optional(),
1299
- environment: z9.string().max(SLO_LIMITS.environmentMaxChars).optional()
1300
- }),
1301
- sli: z9.enum(SLO_SLIS),
1302
- latencyThresholdMs: z9.number().int().min(1).max(60000).nullable(),
1303
- objective: z9.number().min(SLO_LIMITS.objectiveMin).max(SLO_LIMITS.objectiveMax),
1304
- windowDays: z9.union([z9.literal(7), z9.literal(28), z9.literal(30)]),
1305
- alertPolicy: z9.enum(SLO_ALERT_POLICIES),
1306
- allowPublicSources: z9.boolean().default(false)
1881
+ var sloInputSchema = z13.object({
1882
+ name: z13.string().trim().min(1).max(SLO_LIMITS.nameMaxChars),
1883
+ description: z13.string().max(SLO_LIMITS.descriptionMaxChars).default(""),
1884
+ source: z13.enum(SLO_SOURCES),
1885
+ sourceRef: z13.object({
1886
+ id: z13.guid().optional(),
1887
+ projectId: z13.number().int().positive().optional(),
1888
+ service: z13.string().max(128).optional(),
1889
+ operation: z13.string().max(256).optional(),
1890
+ environment: z13.string().max(SLO_LIMITS.environmentMaxChars).optional()
1891
+ }),
1892
+ sli: z13.enum(SLO_SLIS),
1893
+ latencyThresholdMs: z13.number().int().min(1).max(60000).nullable(),
1894
+ objective: z13.number().min(SLO_LIMITS.objectiveMin).max(SLO_LIMITS.objectiveMax),
1895
+ windowDays: z13.union([z13.literal(7), z13.literal(28), z13.literal(30)]),
1896
+ alertPolicy: z13.enum(SLO_ALERT_POLICIES),
1897
+ allowPublicSources: z13.boolean().default(false)
1307
1898
  }).superRefine((v, ctx) => {
1308
1899
  if (!SLO_SOURCE_META[v.source].slis.includes(v.sli))
1309
1900
  ctx.addIssue({ code: "custom", path: ["sli"], message: "INVALID_INPUT" });
@@ -1318,7 +1909,7 @@ var sloInputSchema = z9.object({
1318
1909
  });
1319
1910
 
1320
1911
  // ../src/shared/contracts/uptime.ts
1321
- import { z as z10 } from "zod";
1912
+ import { z as z14 } from "zod";
1322
1913
 
1323
1914
  // ../src/shared/contracts/vocab/uptime.ts
1324
1915
  var UPTIME_STATUSES = ["up", "degraded", "down", "unknown", "paused", "pending"];
@@ -1391,51 +1982,51 @@ function isForbiddenHeader(name) {
1391
1982
  const n = name.trim().toLowerCase();
1392
1983
  return UPTIME_FORBIDDEN_HEADERS.includes(n) || n.startsWith("proxy-") || n.startsWith("sec-");
1393
1984
  }
1394
- var text = z10.string().min(1).max(UPTIME_LIMITS.assertionTextMax);
1395
- var statusRange = z10.string().regex(/^[1-5][0-9]{2}(-[1-5][0-9]{2})?$/);
1396
- var assertionSchema = z10.discriminatedUnion("type", [
1397
- z10.object({ type: z10.literal("status"), in: z10.array(statusRange).min(1).max(10) }),
1398
- z10.object({ type: z10.literal("body_contains"), value: text, case_sensitive: z10.boolean().default(true) }),
1399
- z10.object({ type: z10.literal("body_not_contains"), value: text, case_sensitive: z10.boolean().default(true) }),
1400
- z10.object({
1401
- type: z10.literal("json_pointer"),
1402
- pointer: z10.string().max(256).regex(/^(\/([^~/]|~0|~1)*)*$/),
1403
- op: z10.enum(["exists", "equals", "type"]),
1404
- value: z10.string().max(UPTIME_LIMITS.assertionTextMax).optional()
1405
- }),
1406
- z10.object({
1407
- type: z10.literal("header"),
1408
- name: z10.string().min(1).max(UPTIME_LIMITS.headerNameMax).regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/),
1409
- op: z10.enum(["equals", "contains", "exists"]),
1410
- value: z10.string().max(UPTIME_LIMITS.assertionTextMax).optional()
1411
- }),
1412
- z10.object({ type: z10.literal("latency_ms"), lt: z10.number().int().min(1).max(60000) }),
1413
- z10.object({ type: z10.literal("tls_valid") })
1985
+ var text = z14.string().min(1).max(UPTIME_LIMITS.assertionTextMax);
1986
+ var statusRange = z14.string().regex(/^[1-5][0-9]{2}(-[1-5][0-9]{2})?$/);
1987
+ var assertionSchema = z14.discriminatedUnion("type", [
1988
+ z14.object({ type: z14.literal("status"), in: z14.array(statusRange).min(1).max(10) }),
1989
+ z14.object({ type: z14.literal("body_contains"), value: text, case_sensitive: z14.boolean().default(true) }),
1990
+ z14.object({ type: z14.literal("body_not_contains"), value: text, case_sensitive: z14.boolean().default(true) }),
1991
+ z14.object({
1992
+ type: z14.literal("json_pointer"),
1993
+ pointer: z14.string().max(256).regex(/^(\/([^~/]|~0|~1)*)*$/),
1994
+ op: z14.enum(["exists", "equals", "type"]),
1995
+ value: z14.string().max(UPTIME_LIMITS.assertionTextMax).optional()
1996
+ }),
1997
+ z14.object({
1998
+ type: z14.literal("header"),
1999
+ name: z14.string().min(1).max(UPTIME_LIMITS.headerNameMax).regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/),
2000
+ op: z14.enum(["equals", "contains", "exists"]),
2001
+ value: z14.string().max(UPTIME_LIMITS.assertionTextMax).optional()
2002
+ }),
2003
+ z14.object({ type: z14.literal("latency_ms"), lt: z14.number().int().min(1).max(60000) }),
2004
+ z14.object({ type: z14.literal("tls_valid") })
1414
2005
  ]);
1415
- var header = z10.object({
1416
- name: z10.string().min(1).max(UPTIME_LIMITS.headerNameMax).regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/),
1417
- value: z10.string().max(UPTIME_LIMITS.headerValueMax).regex(/^[^\r\n\u0000]*$/)
2006
+ var header = z14.object({
2007
+ name: z14.string().min(1).max(UPTIME_LIMITS.headerNameMax).regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/),
2008
+ value: z14.string().max(UPTIME_LIMITS.headerValueMax).regex(/^[^\r\n\u0000]*$/)
1418
2009
  });
1419
- var uptimeCheckInputSchema = z10.object({
1420
- projectId: z10.number().int().positive(),
1421
- name: z10.string().trim().min(1).max(UPTIME_LIMITS.nameMaxChars),
1422
- kind: z10.enum(UPTIME_KINDS),
1423
- url: z10.string().max(UPTIME_LIMITS.urlMaxChars).nullable(),
1424
- host: z10.string().max(253).nullable(),
1425
- port: z10.number().int().min(1).max(65535).nullable(),
1426
- method: z10.enum(UPTIME_METHODS).default("GET"),
1427
- headers: z10.array(header).max(UPTIME_LIMITS.headersMax).default([]),
1428
- followRedirects: z10.boolean().default(false),
1429
- timeoutMs: z10.number().int().min(UPTIME_LIMITS.timeoutMs.min).max(UPTIME_LIMITS.timeoutMs.max),
1430
- intervalSeconds: z10.number().int().refine((n) => UPTIME_INTERVALS.includes(n)),
1431
- regions: z10.array(z10.enum(UPTIME_REGIONS)).min(UPTIME_LIMITS.minRegions).max(UPTIME_REGIONS.length),
1432
- assertions: z10.array(assertionSchema).max(UPTIME_LIMITS.assertionsMax).default([]),
1433
- failureThreshold: z10.number().int().min(1).max(5),
1434
- recoveryThreshold: z10.number().int().min(1).max(5),
1435
- certWarningDays: z10.number().int().min(1).max(60),
1436
- environment: z10.string().trim().max(64).default(""),
1437
- strictMetadata: z10.boolean().default(false),
1438
- evidenceOnFailure: z10.boolean().default(true)
2010
+ var uptimeCheckInputSchema = z14.object({
2011
+ projectId: z14.number().int().positive(),
2012
+ name: z14.string().trim().min(1).max(UPTIME_LIMITS.nameMaxChars),
2013
+ kind: z14.enum(UPTIME_KINDS),
2014
+ url: z14.string().max(UPTIME_LIMITS.urlMaxChars).nullable(),
2015
+ host: z14.string().max(253).nullable(),
2016
+ port: z14.number().int().min(1).max(65535).nullable(),
2017
+ method: z14.enum(UPTIME_METHODS).default("GET"),
2018
+ headers: z14.array(header).max(UPTIME_LIMITS.headersMax).default([]),
2019
+ followRedirects: z14.boolean().default(false),
2020
+ timeoutMs: z14.number().int().min(UPTIME_LIMITS.timeoutMs.min).max(UPTIME_LIMITS.timeoutMs.max),
2021
+ intervalSeconds: z14.number().int().refine((n) => UPTIME_INTERVALS.includes(n)),
2022
+ regions: z14.array(z14.enum(UPTIME_REGIONS)).min(UPTIME_LIMITS.minRegions).max(UPTIME_REGIONS.length),
2023
+ assertions: z14.array(assertionSchema).max(UPTIME_LIMITS.assertionsMax).default([]),
2024
+ failureThreshold: z14.number().int().min(1).max(5),
2025
+ recoveryThreshold: z14.number().int().min(1).max(5),
2026
+ certWarningDays: z14.number().int().min(1).max(60),
2027
+ environment: z14.string().trim().max(64).default(""),
2028
+ strictMetadata: z14.boolean().default(false),
2029
+ evidenceOnFailure: z14.boolean().default(true)
1439
2030
  }).superRefine((v, ctx) => {
1440
2031
  if (v.kind === "http" && !v.url)
1441
2032
  ctx.addIssue({ code: "custom", path: ["url"], message: "INVALID_INPUT" });
@@ -1446,237 +2037,243 @@ var uptimeCheckInputSchema = z10.object({
1446
2037
  if (v.headers.some((h) => isForbiddenHeader(h.name)))
1447
2038
  ctx.addIssue({ code: "custom", path: ["headers"], message: "UPTIME_HEADER_FORBIDDEN" });
1448
2039
  });
1449
- var uptimeDefinitionSchema = z10.object({
1450
- check_id: z10.guid(),
1451
- workspace_id: z10.guid(),
1452
- project_id: z10.number().int().positive(),
1453
- revision: z10.number().int().nonnegative(),
1454
- kind: z10.enum(UPTIME_KINDS),
1455
- url: z10.string().max(UPTIME_LIMITS.urlMaxChars).nullable(),
1456
- host: z10.string().max(253).nullable(),
1457
- port: z10.number().int().min(1).max(65535).nullable(),
1458
- method: z10.enum(UPTIME_METHODS),
1459
- headers: z10.array(header).max(UPTIME_LIMITS.headersMax),
1460
- follow_redirects: z10.boolean(),
1461
- timeout_ms: z10.number().int().min(UPTIME_LIMITS.timeoutMs.min).max(UPTIME_LIMITS.timeoutMs.max),
1462
- interval_seconds: z10.number().int().positive(),
1463
- regions: z10.array(z10.enum(UPTIME_REGIONS)).min(1).max(3),
1464
- assertions: z10.array(assertionSchema).max(UPTIME_LIMITS.assertionsMax),
1465
- failure_threshold: z10.number().int().min(1).max(5),
1466
- recovery_threshold: z10.number().int().min(1).max(5),
1467
- cert_warning_days: z10.number().int().min(1).max(60),
1468
- strict_metadata: z10.boolean(),
1469
- evidence_on_failure: z10.boolean(),
1470
- paused_until: z10.string().nullable(),
1471
- muted_until: z10.string().nullable()
2040
+ var uptimeDefinitionSchema = z14.object({
2041
+ check_id: z14.guid(),
2042
+ workspace_id: z14.guid(),
2043
+ project_id: z14.number().int().positive(),
2044
+ revision: z14.number().int().nonnegative(),
2045
+ kind: z14.enum(UPTIME_KINDS),
2046
+ url: z14.string().max(UPTIME_LIMITS.urlMaxChars).nullable(),
2047
+ host: z14.string().max(253).nullable(),
2048
+ port: z14.number().int().min(1).max(65535).nullable(),
2049
+ method: z14.enum(UPTIME_METHODS),
2050
+ headers: z14.array(header).max(UPTIME_LIMITS.headersMax),
2051
+ follow_redirects: z14.boolean(),
2052
+ timeout_ms: z14.number().int().min(UPTIME_LIMITS.timeoutMs.min).max(UPTIME_LIMITS.timeoutMs.max),
2053
+ interval_seconds: z14.number().int().positive(),
2054
+ regions: z14.array(z14.enum(UPTIME_REGIONS)).min(1).max(3),
2055
+ assertions: z14.array(assertionSchema).max(UPTIME_LIMITS.assertionsMax),
2056
+ failure_threshold: z14.number().int().min(1).max(5),
2057
+ recovery_threshold: z14.number().int().min(1).max(5),
2058
+ cert_warning_days: z14.number().int().min(1).max(60),
2059
+ strict_metadata: z14.boolean(),
2060
+ evidence_on_failure: z14.boolean(),
2061
+ paused_until: z14.string().nullable(),
2062
+ muted_until: z14.string().nullable()
1472
2063
  });
1473
- var timingsSchema = z10.object({
1474
- dns_ms: z10.number().nonnegative().max(60000).nullable(),
1475
- connect_ms: z10.number().nonnegative().max(60000).nullable(),
1476
- tls_ms: z10.number().nonnegative().max(60000).nullable(),
1477
- ttfb_ms: z10.number().nonnegative().max(60000).nullable(),
1478
- download_ms: z10.number().nonnegative().max(60000).nullable(),
1479
- total_ms: z10.number().nonnegative().max(60000)
2064
+ var timingsSchema = z14.object({
2065
+ dns_ms: z14.number().nonnegative().max(60000).nullable(),
2066
+ connect_ms: z14.number().nonnegative().max(60000).nullable(),
2067
+ tls_ms: z14.number().nonnegative().max(60000).nullable(),
2068
+ ttfb_ms: z14.number().nonnegative().max(60000).nullable(),
2069
+ download_ms: z14.number().nonnegative().max(60000).nullable(),
2070
+ total_ms: z14.number().nonnegative().max(60000)
1480
2071
  });
1481
- var probeResultSchema = z10.object({
1482
- check_id: z10.guid(),
1483
- revision: z10.number().int().nonnegative(),
1484
- slot: z10.number().int().nonnegative(),
1485
- region: z10.enum(UPTIME_REGIONS),
1486
- run_now: z10.string().max(64).optional(),
1487
- scheduled_at: z10.number().int().positive(),
1488
- started_at: z10.number().int().positive(),
1489
- outcome: z10.enum(UPTIME_OUTCOMES),
1490
- reason: z10.enum(UPTIME_REASONS).nullable(),
1491
- reason_group: z10.enum(UPTIME_REASON_GROUPS).nullable(),
1492
- status_code: z10.number().int().min(100).max(599).nullable(),
2072
+ var probeResultSchema = z14.object({
2073
+ check_id: z14.guid(),
2074
+ revision: z14.number().int().nonnegative(),
2075
+ slot: z14.number().int().nonnegative(),
2076
+ region: z14.enum(UPTIME_REGIONS),
2077
+ run_now: z14.string().max(64).optional(),
2078
+ scheduled_at: z14.number().int().positive(),
2079
+ started_at: z14.number().int().positive(),
2080
+ outcome: z14.enum(UPTIME_OUTCOMES),
2081
+ reason: z14.enum(UPTIME_REASONS).nullable(),
2082
+ reason_group: z14.enum(UPTIME_REASON_GROUPS).nullable(),
2083
+ status_code: z14.number().int().min(100).max(599).nullable(),
1493
2084
  timings: timingsSchema.nullable(),
1494
- ip_family: z10.enum(["v4", "v6"]).nullable(),
1495
- http_version: z10.string().max(8).nullable(),
1496
- cert_not_after: z10.number().int().positive().nullable(),
1497
- cert_issuer: z10.string().max(200).nullable(),
1498
- cert_expiring: z10.boolean(),
1499
- evidence_sealed: z10.string().max(16384).nullable()
2085
+ ip_family: z14.enum(["v4", "v6"]).nullable(),
2086
+ http_version: z14.string().max(8).nullable(),
2087
+ cert_not_after: z14.number().int().positive().nullable(),
2088
+ cert_issuer: z14.string().max(200).nullable(),
2089
+ cert_expiring: z14.boolean(),
2090
+ evidence_sealed: z14.string().max(16384).nullable()
1500
2091
  });
1501
- var probeIdSchema = z10.string().regex(/^probe-(eu|us|ap)-[a-z0-9]{4,16}$/);
1502
- var resultBatchSchema = z10.object({
1503
- v: z10.literal(1),
2092
+ var probeIdSchema = z14.string().regex(/^probe-(eu|us|ap)-[a-z0-9]{4,16}$/);
2093
+ var resultBatchSchema = z14.object({
2094
+ v: z14.literal(1),
1504
2095
  probe_id: probeIdSchema,
1505
- region: z10.enum(UPTIME_REGIONS),
1506
- version: z10.string().max(40),
1507
- sent_at: z10.number().int().positive(),
1508
- results: z10.array(probeResultSchema).max(UPTIME_LIMITS.resultsBatchMax),
1509
- stats: z10.object({ lag_p99_ms: z10.number().nonnegative(), checks_per_min: z10.number().nonnegative() })
2096
+ region: z14.enum(UPTIME_REGIONS),
2097
+ version: z14.string().max(40),
2098
+ sent_at: z14.number().int().positive(),
2099
+ results: z14.array(probeResultSchema).max(UPTIME_LIMITS.resultsBatchMax),
2100
+ stats: z14.object({ lag_p99_ms: z14.number().nonnegative(), checks_per_min: z14.number().nonnegative() })
1510
2101
  });
1511
2102
  var assignmentSchema = uptimeDefinitionSchema.omit({ workspace_id: true, paused_until: true, muted_until: true }).extend({
1512
- seal_public_key: z10.string().regex(/^[A-Za-z0-9_-]{43}$/).nullable()
2103
+ seal_public_key: z14.string().regex(/^[A-Za-z0-9_-]{43}$/).nullable()
1513
2104
  });
1514
- var assignmentsSchema = z10.object({
1515
- v: z10.literal(1),
1516
- region: z10.enum(UPTIME_REGIONS),
1517
- revision: z10.number().int().nonnegative(),
1518
- issued_at: z10.number().int().positive(),
1519
- checks: z10.array(assignmentSchema).max(50000),
1520
- denied_hosts: z10.array(z10.string().max(253)).max(1e4),
1521
- run_now: z10.array(z10.object({ id: z10.string().max(64), check_id: z10.guid(), expires_at: z10.number().int() })).max(500)
2105
+ var assignmentsSchema = z14.object({
2106
+ v: z14.literal(1),
2107
+ region: z14.enum(UPTIME_REGIONS),
2108
+ revision: z14.number().int().nonnegative(),
2109
+ issued_at: z14.number().int().positive(),
2110
+ checks: z14.array(assignmentSchema).max(50000),
2111
+ denied_hosts: z14.array(z14.string().max(253)).max(1e4),
2112
+ run_now: z14.array(z14.object({ id: z14.string().max(64), check_id: z14.guid(), expires_at: z14.number().int() })).max(500)
1522
2113
  });
1523
- var uuid3 = z10.guid();
1524
- var b64key = z10.string().regex(/^[A-Za-z0-9_-]{43}$/);
1525
- var iso2 = z10.string().datetime();
1526
- var uptimeSyncSchema = z10.object({
1527
- v: z10.literal(1),
2114
+ var uuid3 = z14.guid();
2115
+ var b64key = z14.string().regex(/^[A-Za-z0-9_-]{43}$/);
2116
+ var iso2 = z14.string().datetime();
2117
+ var uptimeSyncSchema = z14.object({
2118
+ v: z14.literal(1),
1528
2119
  workspace_id: uuid3,
1529
- revision: z10.number().int().positive(),
1530
- workspace_status: z10.enum(["active", "suspended", "deleting"]),
1531
- suspended: z10.boolean(),
1532
- checks: z10.array(uptimeDefinitionSchema).max(UPTIME_LIMITS.maxChecksPerWorkspace),
1533
- projects: z10.array(z10.object({ id: z10.number().int().positive(), node_id: z10.guid().nullable(), seal_public_key: b64key.nullable() })).max(1000)
2120
+ revision: z14.number().int().positive(),
2121
+ workspace_status: z14.enum(["active", "suspended", "deleting"]),
2122
+ suspended: z14.boolean(),
2123
+ checks: z14.array(uptimeDefinitionSchema).max(UPTIME_LIMITS.maxChecksPerWorkspace),
2124
+ projects: z14.array(z14.object({ id: z14.number().int().positive(), node_id: z14.guid().nullable(), seal_public_key: b64key.nullable() })).max(1000)
1534
2125
  });
1535
- var uptimeReconcileSchema = z10.object({
1536
- v: z10.literal(1),
1537
- as_of: z10.number().int().positive(),
1538
- workspace_ids: z10.array(uuid3).max(UPTIME_LIMITS.reconcileMaxWorkspaces),
1539
- heartbeat_routes: z10.array(z10.string().regex(PING_ROUTE_RE)).max(UPTIME_LIMITS.reconcileMaxWorkspaces).optional()
2126
+ var uptimeReconcileSchema = z14.object({
2127
+ v: z14.literal(1),
2128
+ as_of: z14.number().int().positive(),
2129
+ workspace_ids: z14.array(uuid3).max(UPTIME_LIMITS.reconcileMaxWorkspaces),
2130
+ heartbeat_routes: z14.array(z14.string().regex(PING_ROUTE_RE)).max(UPTIME_LIMITS.reconcileMaxWorkspaces).optional()
1540
2131
  });
1541
- var probeDirectorySyncSchema = z10.object({
1542
- v: z10.literal(1),
1543
- revision: z10.number().int().positive(),
1544
- probes: z10.array(z10.object({ probe_id: probeIdSchema, region: z10.enum(UPTIME_REGIONS), public_key: b64key, status: z10.enum(["active", "revoked"]) })).max(30),
1545
- denied_hosts: z10.array(z10.string().min(1).max(253)).max(1e4)
2132
+ var probeDirectorySyncSchema = z14.object({
2133
+ v: z14.literal(1),
2134
+ revision: z14.number().int().positive(),
2135
+ probes: z14.array(z14.object({ probe_id: probeIdSchema, region: z14.enum(UPTIME_REGIONS), public_key: b64key, status: z14.enum(["active", "revoked"]) })).max(30),
2136
+ denied_hosts: z14.array(z14.string().min(1).max(253)).max(1e4)
1546
2137
  });
1547
- var runNowRequestSchema = z10.object({ v: z10.literal(1), workspace_id: uuid3, check_id: uuid3, run_id: z10.string().regex(/^[A-Za-z0-9_-]{8,64}$/) });
1548
- var signedAssignmentsSchema = z10.object({ assignments: assignmentsSchema, sig: z10.string().regex(/^[A-Za-z0-9_-]{86}$/) });
1549
- var uptimeRegionStateSchema = z10.object({
1550
- region: z10.enum(UPTIME_REGIONS),
1551
- outcome: z10.enum(UPTIME_OUTCOMES),
1552
- reason: z10.enum(UPTIME_REASONS).nullable(),
1553
- status_code: z10.number().int().min(100).max(599).nullable(),
1554
- total_ms: z10.number().nonnegative().max(60000).nullable(),
2138
+ var runNowRequestSchema = z14.object({ v: z14.literal(1), workspace_id: uuid3, check_id: uuid3, run_id: z14.string().regex(/^[A-Za-z0-9_-]{8,64}$/) });
2139
+ var signedAssignmentsSchema = z14.object({ assignments: assignmentsSchema, sig: z14.string().regex(/^[A-Za-z0-9_-]{86}$/) });
2140
+ var uptimeRegionStateSchema = z14.object({
2141
+ region: z14.enum(UPTIME_REGIONS),
2142
+ outcome: z14.enum(UPTIME_OUTCOMES),
2143
+ reason: z14.enum(UPTIME_REASONS).nullable(),
2144
+ status_code: z14.number().int().min(100).max(599).nullable(),
2145
+ total_ms: z14.number().nonnegative().max(60000).nullable(),
1555
2146
  timings: timingsSchema.nullable().optional(),
1556
2147
  at: iso2
1557
2148
  });
1558
- var uptimeStatusReportSchema = z10.object({
2149
+ var uptimeStatusReportSchema = z14.object({
1559
2150
  check_id: uuid3,
1560
- revision: z10.number().int().nonnegative(),
1561
- status: z10.enum(UPTIME_STATUSES),
1562
- last_verdict: z10.enum(SLOT_VERDICTS).nullable(),
2151
+ revision: z14.number().int().nonnegative(),
2152
+ status: z14.enum(UPTIME_STATUSES),
2153
+ last_verdict: z14.enum(SLOT_VERDICTS).nullable(),
1563
2154
  last_slot_at: iso2.nullable(),
1564
2155
  incident_id: uuid3.nullable(),
1565
- down_streak: z10.number().int().nonnegative(),
1566
- up_streak: z10.number().int().nonnegative(),
1567
- regions: z10.array(uptimeRegionStateSchema).max(3),
1568
- unobserved_regions: z10.array(z10.enum(UPTIME_REGIONS)).max(3),
2156
+ down_streak: z14.number().int().nonnegative(),
2157
+ up_streak: z14.number().int().nonnegative(),
2158
+ regions: z14.array(uptimeRegionStateSchema).max(3),
2159
+ unobserved_regions: z14.array(z14.enum(UPTIME_REGIONS)).max(3),
1569
2160
  cert_not_after: iso2.nullable(),
1570
- cert_expiring: z10.boolean(),
1571
- run_now: z10.object({ run_id: z10.string().max(64), results: z10.array(uptimeRegionStateSchema).max(3) }).nullable()
2161
+ cert_expiring: z14.boolean(),
2162
+ run_now: z14.object({ run_id: z14.string().max(64), results: z14.array(uptimeRegionStateSchema).max(3) }).nullable()
1572
2163
  });
1573
2164
  var UPTIME_EVENT_KINDS = ["opened", "resolved", "cert_expiring"];
1574
- var uptimeEventSchema = z10.object({
1575
- event_id: z10.string().regex(/^[A-Za-z0-9:_-]{8,96}$/),
2165
+ var uptimeEventSchema = z14.object({
2166
+ event_id: z14.string().regex(/^[A-Za-z0-9:_-]{8,96}$/),
1576
2167
  check_id: uuid3,
1577
- kind: z10.enum(UPTIME_EVENT_KINDS),
2168
+ kind: z14.enum(UPTIME_EVENT_KINDS),
1578
2169
  incident_id: uuid3.nullable(),
1579
2170
  at: iso2,
1580
- reason: z10.enum(UPTIME_REASONS).nullable(),
1581
- regions: z10.array(z10.enum(UPTIME_REGIONS)).max(3),
1582
- cert_days_left: z10.number().int().nullable()
2171
+ reason: z14.enum(UPTIME_REASONS).nullable(),
2172
+ regions: z14.array(z14.enum(UPTIME_REGIONS)).max(3),
2173
+ cert_days_left: z14.number().int().nullable()
1583
2174
  });
1584
- var uptimeMinuteSchema = z10.object({
2175
+ var uptimeMinuteSchema = z14.object({
1585
2176
  check_id: uuid3,
1586
2177
  minute: iso2,
1587
- up: z10.number().int().nonnegative(),
1588
- degraded: z10.number().int().nonnegative(),
1589
- down: z10.number().int().nonnegative(),
1590
- unknown: z10.number().int().nonnegative(),
1591
- latency: z10.array(z10.object({ region: z10.enum(UPTIME_REGIONS), n: z10.number().int().positive(), p50_ms: z10.number().nonnegative(), p95_ms: z10.number().nonnegative() })).max(3)
2178
+ up: z14.number().int().nonnegative(),
2179
+ degraded: z14.number().int().nonnegative(),
2180
+ down: z14.number().int().nonnegative(),
2181
+ unknown: z14.number().int().nonnegative(),
2182
+ latency: z14.array(z14.object({ region: z14.enum(UPTIME_REGIONS), n: z14.number().int().positive(), p50_ms: z14.number().nonnegative(), p95_ms: z14.number().nonnegative() })).max(3)
1592
2183
  });
1593
- var uptimeReportSchema = z10.object({
1594
- v: z10.literal(1),
2184
+ var uptimeReportSchema = z14.object({
2185
+ v: z14.literal(1),
1595
2186
  workspace_id: uuid3,
1596
- revision: z10.number().int().nonnegative(),
2187
+ revision: z14.number().int().nonnegative(),
1597
2188
  sent_at: iso2,
1598
- events: z10.array(uptimeEventSchema).max(UPTIME_LIMITS.reportMaxEvents),
1599
- statuses: z10.array(uptimeStatusReportSchema).max(UPTIME_LIMITS.reportMaxStatuses),
1600
- minutes: z10.array(uptimeMinuteSchema).max(UPTIME_LIMITS.reportMaxMinutes)
2189
+ events: z14.array(uptimeEventSchema).max(UPTIME_LIMITS.reportMaxEvents),
2190
+ statuses: z14.array(uptimeStatusReportSchema).max(UPTIME_LIMITS.reportMaxStatuses),
2191
+ minutes: z14.array(uptimeMinuteSchema).max(UPTIME_LIMITS.reportMaxMinutes)
1601
2192
  });
1602
- var probeFleetReportSchema = z10.object({
1603
- v: z10.literal(1),
2193
+ var probeFleetReportSchema = z14.object({
2194
+ v: z14.literal(1),
1604
2195
  sent_at: iso2,
1605
- probes: z10.array(z10.object({
2196
+ probes: z14.array(z14.object({
1606
2197
  probe_id: probeIdSchema,
1607
- region: z10.enum(UPTIME_REGIONS),
1608
- version: z10.string().max(40).nullable(),
2198
+ region: z14.enum(UPTIME_REGIONS),
2199
+ version: z14.string().max(40).nullable(),
1609
2200
  last_seen_at: iso2.nullable(),
1610
- lag_p99_ms: z10.number().nonnegative().nullable(),
1611
- checks_per_min: z10.number().nonnegative().nullable()
2201
+ lag_p99_ms: z14.number().nonnegative().nullable(),
2202
+ checks_per_min: z14.number().nonnegative().nullable()
1612
2203
  })).max(30),
1613
- regions_alive: z10.array(z10.enum(UPTIME_REGIONS)).max(3)
2204
+ regions_alive: z14.array(z14.enum(UPTIME_REGIONS)).max(3)
1614
2205
  });
1615
- var probeEnrollSchema = z10.object({
1616
- v: z10.literal(1),
2206
+ var probeEnrollSchema = z14.object({
2207
+ v: z14.literal(1),
1617
2208
  probe_id: probeIdSchema,
1618
- public_key: z10.string().regex(/^[A-Za-z0-9_-]{43}$/),
1619
- code: z10.string().regex(/^[A-Za-z0-9_-]{43}$/),
1620
- ts: z10.number().int().positive(),
1621
- sig: z10.string().regex(/^[A-Za-z0-9_-]{86}$/)
2209
+ public_key: z14.string().regex(/^[A-Za-z0-9_-]{43}$/),
2210
+ code: z14.string().regex(/^[A-Za-z0-9_-]{43}$/),
2211
+ ts: z14.number().int().positive(),
2212
+ sig: z14.string().regex(/^[A-Za-z0-9_-]{86}$/)
1622
2213
  });
1623
- var uptimeEvidenceEnvelopeSchema = z10.object({
1624
- v: z10.literal(1),
1625
- check_id: z10.guid(),
1626
- slot: z10.number().int().nonnegative(),
1627
- region: z10.enum(UPTIME_REGIONS),
2214
+ var uptimeEvidenceEnvelopeSchema = z14.object({
2215
+ v: z14.literal(1),
2216
+ check_id: z14.guid(),
2217
+ slot: z14.number().int().nonnegative(),
2218
+ region: z14.enum(UPTIME_REGIONS),
1628
2219
  probe_id: probeIdSchema,
1629
- at: z10.number().int().positive(),
1630
- sealed: z10.string().regex(/^[A-Za-z0-9_-]+$/).max(16384)
2220
+ at: z14.number().int().positive(),
2221
+ sealed: z14.string().regex(/^[A-Za-z0-9_-]+$/).max(16384)
1631
2222
  }).strict();
1632
- var uptimeEvidenceSchema = z10.object({
1633
- v: z10.literal(1),
1634
- check_id: z10.guid(),
1635
- slot: z10.number().int().nonnegative(),
1636
- region: z10.enum(UPTIME_REGIONS),
1637
- at: z10.number().int().positive(),
1638
- reason: z10.enum(UPTIME_REASONS).nullable(),
1639
- status_line: z10.string().max(200).nullable(),
1640
- headers: z10.record(z10.string().max(64), z10.string().max(512)).refine((h) => Object.keys(h).length <= 20),
1641
- body: z10.string().max(UPTIME_LIMITS.evidenceMaxBytes * 4).nullable(),
1642
- body_truncated: z10.boolean(),
2223
+ var uptimeEvidenceSchema = z14.object({
2224
+ v: z14.literal(1),
2225
+ check_id: z14.guid(),
2226
+ slot: z14.number().int().nonnegative(),
2227
+ region: z14.enum(UPTIME_REGIONS),
2228
+ at: z14.number().int().positive(),
2229
+ reason: z14.enum(UPTIME_REASONS).nullable(),
2230
+ status_line: z14.string().max(200).nullable(),
2231
+ headers: z14.record(z14.string().max(64), z14.string().max(512)).refine((h) => Object.keys(h).length <= 20),
2232
+ body: z14.string().max(UPTIME_LIMITS.evidenceMaxBytes * 4).nullable(),
2233
+ body_truncated: z14.boolean(),
1643
2234
  timings: timingsSchema.nullable(),
1644
- ip: z10.string().max(64).nullable(),
1645
- error: z10.string().max(300).nullable()
2235
+ ip: z14.string().max(64).nullable(),
2236
+ error: z14.string().max(300).nullable()
1646
2237
  }).strict();
1647
- var uptimeEvidenceListSchema = z10.object({
1648
- items: z10.array(uptimeEvidenceSchema.extend({ received_at: z10.number().int().positive() })).max(UPTIME_LIMITS.evidenceKeepPerCheck)
2238
+ var uptimeEvidenceListSchema = z14.object({
2239
+ items: z14.array(uptimeEvidenceSchema.extend({ received_at: z14.number().int().positive() })).max(UPTIME_LIMITS.evidenceKeepPerCheck)
1649
2240
  });
1650
2241
 
1651
2242
  // ../src/shared/contracts/api-ops/monitors.ts
2243
+ var anyMonitorInputSchema = z15.union([monitorInputSchema, signalMonitorInputSchema]);
2244
+ var MAINTENANCE_INPUTS = {
2245
+ create: z15.object({ workspaceId: uuid, input: maintenanceInputSchema }),
2246
+ update: z15.object({ workspaceId: uuid, windowId: uuid, input: maintenanceInputSchema }),
2247
+ delete: z15.object({ workspaceId: uuid, windowId: uuid })
2248
+ };
1652
2249
  var MONITOR_INPUTS = {
1653
- create: z11.object({ projectId, slug: z11.string().regex(SLUG_RE), input: monitorInputSchema }),
1654
- update: z11.object({ monitorId: uuid, input: monitorInputSchema }),
1655
- delete: z11.object({ monitorId: uuid, confirmSlug: z11.string().max(64) }),
1656
- setPause: z11.object({ monitorId: uuid, until: holdUntil }),
1657
- setMuted: z11.object({ monitorId: uuid, muted: z11.boolean() }),
1658
- dismissDiscovery: z11.object({ discoveryId: uuid }),
1659
- rotatePing: z11.object({
2250
+ create: z15.object({ projectId, slug: z15.string().regex(SLUG_RE), input: anyMonitorInputSchema }),
2251
+ update: z15.object({ monitorId: uuid, input: anyMonitorInputSchema }),
2252
+ delete: z15.object({ monitorId: uuid, confirmSlug: z15.string().max(64) }),
2253
+ setPause: z15.object({ monitorId: uuid, until: holdUntil }),
2254
+ setMuted: z15.object({ monitorId: uuid, muted: z15.boolean() }),
2255
+ dismissDiscovery: z15.object({ discoveryId: uuid }),
2256
+ rotatePing: z15.object({
1660
2257
  monitorId: uuid,
1661
- graceHours: z11.number().int().refine((h) => HEARTBEAT_LIMITS.rotationGraceHoursChoices.includes(h))
2258
+ graceHours: z15.number().int().refine((h) => HEARTBEAT_LIMITS.rotationGraceHoursChoices.includes(h))
1662
2259
  }),
1663
- monitorOnly: z11.object({ monitorId: uuid })
2260
+ monitorOnly: z15.object({ monitorId: uuid })
1664
2261
  };
1665
2262
  var UPTIME_INPUTS = {
1666
2263
  create: uptimeCheckInputSchema,
1667
- update: z11.object({ checkId: uuid, input: uptimeCheckInputSchema }),
1668
- checkOnly: z11.object({ checkId: uuid }),
1669
- setHold: z11.object({ checkId: uuid, kind: z11.enum(["pause", "mute"]), until: holdUntil })
2264
+ update: z15.object({ checkId: uuid, input: uptimeCheckInputSchema }),
2265
+ checkOnly: z15.object({ checkId: uuid }),
2266
+ setHold: z15.object({ checkId: uuid, kind: z15.enum(["pause", "mute"]), until: holdUntil })
1670
2267
  };
1671
2268
  var SLO_INPUTS = {
1672
- create: z11.object({ workspaceId: uuid, input: sloInputSchema }),
1673
- update: z11.object({ sloId: uuid, input: sloInputSchema }),
1674
- sloOnly: z11.object({ sloId: uuid }),
1675
- setHold: z11.object({ sloId: uuid, kind: z11.enum(["pause", "mute"]), until: holdUntil }),
1676
- import: z11.object({
2269
+ create: z15.object({ workspaceId: uuid, input: sloInputSchema }),
2270
+ update: z15.object({ sloId: uuid, input: sloInputSchema }),
2271
+ sloOnly: z15.object({ sloId: uuid }),
2272
+ setHold: z15.object({ sloId: uuid, kind: z15.enum(["pause", "mute"]), until: holdUntil }),
2273
+ import: z15.object({
1677
2274
  workspaceId: uuid,
1678
- text: z11.string().max(SLO_LIMITS.openSloMaxBytes * 2),
1679
- dryRun: z11.boolean()
2275
+ text: z15.string().max(SLO_LIMITS.openSloMaxBytes * 2),
2276
+ dryRun: z15.boolean()
1680
2277
  })
1681
2278
  };
1682
2279
  var m = "monitors:write";
@@ -1688,13 +2285,13 @@ var MONITOR_OPERATIONS = [
1688
2285
  scope: m,
1689
2286
  sensitivity: "normal",
1690
2287
  kind: "write",
1691
- rpcs: ["create_monitor", "create_heartbeat_monitor"],
2288
+ rpcs: ["create_monitor", "create_heartbeat_monitor", "create_signal_monitor"],
1692
2289
  input: MONITOR_INPUTS.create,
1693
2290
  bodyField: "input",
1694
2291
  idempotency: "required",
1695
2292
  status: 201,
1696
2293
  mcp: "configure",
1697
- summary: "Create a cron or heartbeat monitor. A heartbeat monitor returns its ping token once.",
2294
+ summary: "Create a cron or heartbeat monitor, or a signal monitor (`settings.type`: count, assertion, deadline, progress). A heartbeat monitor returns its ping token once.",
1698
2295
  secretOutput: ["ping_token"],
1699
2296
  ui: ["monitors#createMonitor"]
1700
2297
  }),
@@ -1705,13 +2302,13 @@ var MONITOR_OPERATIONS = [
1705
2302
  scope: m,
1706
2303
  sensitivity: "normal",
1707
2304
  kind: "write",
1708
- rpcs: ["update_monitor"],
2305
+ rpcs: ["update_monitor", "update_signal_monitor"],
1709
2306
  input: MONITOR_INPUTS.update,
1710
2307
  bodyField: "input",
1711
2308
  ifMatch: true,
1712
2309
  idempotency: "none",
1713
2310
  mcp: "configure",
1714
- summary: "Replace a monitor's schedule, margins and thresholds.",
2311
+ summary: "Replace a monitor's schedule, margins and thresholds, or a signal monitor's settings (the type stays).",
1715
2312
  ui: ["monitors#updateMonitor"]
1716
2313
  }),
1717
2314
  op({
@@ -1966,23 +2563,71 @@ var MONITOR_OPERATIONS = [
1966
2563
  mcp: "configure",
1967
2564
  summary: "Import OpenSLO YAML, all or nothing; `dry_run` returns the plan without applying it.",
1968
2565
  ui: ["slos#importOpenSlo"]
2566
+ }),
2567
+ op({
2568
+ id: "maintenance.create",
2569
+ method: "POST",
2570
+ path: "/v1/maintenance-windows",
2571
+ scope: m,
2572
+ sensitivity: "normal",
2573
+ kind: "write",
2574
+ rpcs: ["create_maintenance_window"],
2575
+ input: MAINTENANCE_INPUTS.create,
2576
+ bodyField: "input",
2577
+ workspace: true,
2578
+ idempotency: "required",
2579
+ status: 201,
2580
+ mcp: "configure",
2581
+ summary: "Hold back monitor notifications during a one-off or weekly window (workspace, projects or monitors); monitors keep evaluating and recording.",
2582
+ ui: ["maintenance#createMaintenanceWindow"]
2583
+ }),
2584
+ op({
2585
+ id: "maintenance.update",
2586
+ method: "PATCH",
2587
+ path: "/v1/maintenance-windows/{window_id}",
2588
+ scope: m,
2589
+ sensitivity: "normal",
2590
+ kind: "write",
2591
+ rpcs: ["update_maintenance_window"],
2592
+ input: MAINTENANCE_INPUTS.update,
2593
+ bodyField: "input",
2594
+ workspace: true,
2595
+ idempotency: "none",
2596
+ mcp: "configure",
2597
+ summary: "Replace a maintenance window's scope, times and reason.",
2598
+ ui: ["maintenance#updateMaintenanceWindow"]
2599
+ }),
2600
+ op({
2601
+ id: "maintenance.delete",
2602
+ method: "DELETE",
2603
+ path: "/v1/maintenance-windows/{window_id}",
2604
+ scope: m,
2605
+ sensitivity: "normal",
2606
+ kind: "write",
2607
+ rpcs: ["delete_maintenance_window"],
2608
+ input: MAINTENANCE_INPUTS.delete,
2609
+ workspace: true,
2610
+ idempotency: "none",
2611
+ mcp: "configure",
2612
+ summary: "Delete a maintenance window; notifications resume at once.",
2613
+ ui: ["maintenance#deleteMaintenanceWindow"]
1969
2614
  })
1970
2615
  ];
1971
2616
 
1972
2617
  // ../src/shared/contracts/api-ops/node-data.ts
1973
- import { z as z12 } from "zod";
1974
- var issueId = z12.number().int().positive();
1975
- var csv = z12.string().min(1).max(2000);
1976
- var name2 = z12.string().min(1).max(256);
1977
- var period = z12.enum(["1h", "24h", "7d", "14d", "30d"]);
1978
- var nodeCursor = z12.string().min(1).max(600).optional();
2618
+ import { z as z16 } from "zod";
2619
+ var issueId = z16.number().int().positive();
2620
+ var csv = z16.string().min(1).max(2000);
2621
+ var name2 = z16.string().min(1).max(256);
2622
+ var period = z16.enum(["1h", "24h", "7d", "14d", "30d"]);
2623
+ var nodeCursor = z16.string().min(1).max(600).optional();
1979
2624
  var windowFields = {
1980
- start: z12.string().max(40).optional(),
1981
- end: z12.string().max(40).optional()
2625
+ start: z16.string().max(40).optional(),
2626
+ end: z16.string().max(40).optional()
1982
2627
  };
1983
- var traceId = z12.string().regex(/^[0-9a-fA-F]{32}$/);
1984
- var spanId = z12.string().regex(/^[0-9a-fA-F]{16}$/);
1985
- var attrs = z12.string().max(2000).optional();
2628
+ var traceId = z16.string().regex(/^[0-9a-fA-F]{32}$/);
2629
+ var spanId = z16.string().regex(/^[0-9a-fA-F]{16}$/);
2630
+ var attrs = z16.string().max(2000).optional();
1986
2631
  var telemetryCommon = {
1987
2632
  ...windowFields,
1988
2633
  project: csv.optional(),
@@ -1990,91 +2635,112 @@ var telemetryCommon = {
1990
2635
  service: csv.optional(),
1991
2636
  attrs
1992
2637
  };
1993
- var issueChange = z12.union([
1994
- z12.object({ action: z12.literal("resolve"), inNextRelease: z12.boolean().optional() }),
1995
- z12.object({ action: z12.literal("unresolve") }),
1996
- z12.object({ action: z12.literal("archive"), mode: z12.enum(["until_escalating", "forever"]) }),
1997
- z12.object({
1998
- action: z12.literal("archive"),
1999
- mode: z12.literal("until_condition"),
2000
- events: z12.number().int().min(1).max(1e6).optional(),
2001
- users: z12.number().int().min(1).max(1e5).optional(),
2002
- until: z12.string().datetime().optional()
2003
- }),
2004
- z12.object({ action: z12.literal("assign"), userId: z12.guid().nullable() }),
2005
- z12.object({ action: z12.literal("priority"), priority: z12.enum(["low", "medium", "high"]) })
2638
+ var issueChange = z16.union([
2639
+ z16.object({ action: z16.literal("resolve"), inNextRelease: z16.boolean().optional() }),
2640
+ z16.object({ action: z16.literal("unresolve") }),
2641
+ z16.object({ action: z16.literal("archive"), mode: z16.enum(["until_escalating", "forever"]) }),
2642
+ z16.object({
2643
+ action: z16.literal("archive"),
2644
+ mode: z16.literal("until_condition"),
2645
+ events: z16.number().int().min(1).max(1e6).optional(),
2646
+ users: z16.number().int().min(1).max(1e5).optional(),
2647
+ until: z16.string().datetime().optional()
2648
+ }),
2649
+ z16.object({ action: z16.literal("assign"), userId: z16.guid().nullable() }),
2650
+ z16.object({ action: z16.literal("priority"), priority: z16.enum(["low", "medium", "high"]) })
2006
2651
  ]);
2007
2652
  var NODE_INPUTS = {
2008
- issuesList: z12.object({
2653
+ issuesList: z16.object({
2009
2654
  project: csv.optional(),
2010
- status: z12.enum(["unresolved", "resolved", "archived", "all"]).optional(),
2655
+ status: z16.enum(["unresolved", "resolved", "archived", "all"]).optional(),
2011
2656
  level: csv.optional(),
2012
2657
  priority: csv.optional(),
2013
2658
  environment: csv.optional(),
2014
2659
  release: csv.optional(),
2015
- assignee: z12.string().max(64).optional(),
2660
+ assignee: z16.string().max(64).optional(),
2016
2661
  period: period.optional(),
2017
- q: z12.string().max(200).optional(),
2018
- sort: z12.enum(["last_seen", "first_seen", "events", "users", "priority"]).optional(),
2662
+ q: z16.string().max(200).optional(),
2663
+ sort: z16.enum(["last_seen", "first_seen", "events", "users", "priority"]).optional(),
2019
2664
  cursor: nodeCursor,
2020
- limit: z12.number().int().min(1).max(100).optional()
2665
+ limit: z16.number().int().min(1).max(100).optional()
2021
2666
  }),
2022
- issue: z12.object({ issueId }),
2023
- issueStats: z12.object({ issueId, range: z12.enum(["24h", "30d"]).optional() }),
2024
- issueEvents: z12.object({ issueId, cursor: nodeCursor }),
2025
- issueEvent: z12.object({
2667
+ issue: z16.object({ issueId }),
2668
+ issueStats: z16.object({ issueId, range: z16.enum(["24h", "30d"]).optional() }),
2669
+ issueEvents: z16.object({ issueId, cursor: nodeCursor }),
2670
+ issueEvent: z16.object({
2026
2671
  issueId,
2027
- eventId: z12.string().regex(/^([0-9a-f]{32}|latest|oldest)$/)
2672
+ eventId: z16.string().regex(/^([0-9a-f]{32}|latest|oldest)$/)
2028
2673
  }),
2029
- issueUpdate: z12.object({ issueId, change: issueChange }),
2030
- issuesBulk: z12.object({
2031
- issueIds: z12.array(issueId).min(1).max(100),
2674
+ issueUpdate: z16.object({ issueId, change: issueChange }),
2675
+ issuesBulk: z16.object({
2676
+ issueIds: z16.array(issueId).min(1).max(100),
2032
2677
  action: issueChange
2033
2678
  }),
2034
- spansList: z12.object({
2679
+ spansList: z16.object({
2035
2680
  ...telemetryCommon,
2036
- operation: z12.string().min(1).max(1024).optional(),
2037
- status: z12.enum(["unset", "ok", "error"]).optional(),
2038
- kind: z12.enum(["internal", "server", "client", "producer", "consumer"]).optional(),
2039
- minDurationMs: z12.number().min(0).max(86400000).optional(),
2040
- maxDurationMs: z12.number().min(0).max(86400000).optional(),
2041
- mode: z12.enum(["spans", "traces"]).optional(),
2681
+ operation: z16.string().min(1).max(1024).optional(),
2682
+ status: z16.enum(["unset", "ok", "error"]).optional(),
2683
+ kind: z16.enum(["internal", "server", "client", "producer", "consumer"]).optional(),
2684
+ minDurationMs: z16.number().min(0).max(86400000).optional(),
2685
+ maxDurationMs: z16.number().min(0).max(86400000).optional(),
2686
+ mode: z16.enum(["spans", "traces"]).optional(),
2042
2687
  cursor: nodeCursor
2043
2688
  }),
2044
- spansHistogram: z12.object({
2689
+ spansHistogram: z16.object({
2045
2690
  ...telemetryCommon,
2046
- operation: z12.string().min(1).max(1024).optional(),
2047
- status: z12.enum(["unset", "ok", "error"]).optional()
2691
+ operation: z16.string().min(1).max(1024).optional(),
2692
+ status: z16.enum(["unset", "ok", "error"]).optional()
2048
2693
  }),
2049
- trace: z12.object({ traceId }),
2050
- traceSpans: z12.object({ traceId, errorsOnly: z12.enum(["1"]).optional(), ...windowFields }),
2051
- span: z12.object({ traceId, spanId, ...windowFields }),
2052
- logsList: z12.object({
2694
+ trace: z16.object({ traceId }),
2695
+ traceSpans: z16.object({ traceId, errorsOnly: z16.enum(["1"]).optional(), ...windowFields }),
2696
+ span: z16.object({ traceId, spanId, ...windowFields }),
2697
+ logsList: z16.object({
2053
2698
  ...telemetryCommon,
2054
- severityMin: z12.enum(["trace", "debug", "info", "warn", "error", "fatal"]).optional(),
2699
+ severityMin: z16.enum(["trace", "debug", "info", "warn", "error", "fatal"]).optional(),
2055
2700
  traceId: traceId.optional(),
2056
2701
  spanId: spanId.optional(),
2057
- q: z12.string().max(500).optional(),
2058
- order: z12.enum(["asc", "desc"]).optional(),
2702
+ q: z16.string().max(500).optional(),
2703
+ order: z16.enum(["asc", "desc"]).optional(),
2059
2704
  cursor: nodeCursor
2060
2705
  }),
2061
- logsFacets: z12.object({
2706
+ logsFacets: z16.object({
2062
2707
  ...telemetryCommon,
2063
- severityMin: z12.enum(["trace", "debug", "info", "warn", "error", "fatal"]).optional(),
2064
- q: z12.string().max(500).optional()
2708
+ severityMin: z16.enum(["trace", "debug", "info", "warn", "error", "fatal"]).optional(),
2709
+ q: z16.string().max(500).optional()
2065
2710
  }),
2066
- logAround: z12.object({
2711
+ logAround: z16.object({
2067
2712
  logId: name2,
2068
- at: z12.string().max(40),
2069
- same: z12.enum(["service", "trace"]).optional(),
2070
- before: z12.number().int().min(0).max(200).optional(),
2071
- after: z12.number().int().min(0).max(200).optional()
2072
- }),
2073
- telemetryUsage: z12.object({ project: csv.optional(), days: z12.number().int().min(1).max(31).optional() }),
2074
- ticket: z12.object({
2075
- scope: z12.enum(["read", "write"]).default("read"),
2076
- project: z12.number().int().positive().optional(),
2077
- environment: z12.string().min(1).max(64).optional()
2713
+ at: z16.string().max(40),
2714
+ same: z16.enum(["service", "trace"]).optional(),
2715
+ before: z16.number().int().min(0).max(200).optional(),
2716
+ after: z16.number().int().min(0).max(200).optional()
2717
+ }),
2718
+ telemetryUsage: z16.object({ project: csv.optional(), days: z16.number().int().min(1).max(31).optional() }),
2719
+ monitorSignal: z16.object({ monitorId: z16.guid(), hours: z16.number().int().min(1).max(24).optional() }),
2720
+ monitorOccurrences: z16.object({
2721
+ monitorId: z16.guid(),
2722
+ state: z16.enum(["open", "finished", "all"]).optional(),
2723
+ environment: z16.string().min(1).max(64).optional(),
2724
+ cursor: nodeCursor
2725
+ }),
2726
+ monitorBacktest: z16.object({ project: z16.number().int().positive(), settings: backtestSettingsSchema }),
2727
+ occurrenceCreate: z16.object({
2728
+ project: z16.number().int().positive(),
2729
+ monitorSlug: occurrenceInputSchema.shape.monitor_slug,
2730
+ occurrenceId: occurrenceInputSchema.shape.occurrence_id,
2731
+ dueAt: occurrenceInputSchema.shape.due_at,
2732
+ environment: occurrenceInputSchema.shape.environment
2733
+ }),
2734
+ occurrenceCancel: z16.object({
2735
+ project: z16.number().int().positive(),
2736
+ monitorSlug: z16.string().regex(SLUG_RE),
2737
+ occurrenceId: z16.string().regex(OCCURRENCE_ID_RE),
2738
+ environment: z16.string().min(1).max(64).optional()
2739
+ }),
2740
+ ticket: z16.object({
2741
+ scope: z16.enum(["read", "write"]).default("read"),
2742
+ project: z16.number().int().positive().optional(),
2743
+ environment: z16.string().min(1).max(64).optional()
2078
2744
  })
2079
2745
  };
2080
2746
  var N = NODE_INPUTS;
@@ -2245,6 +2911,60 @@ var NODE_OPERATIONS = [
2245
2911
  node: { path: "q/telemetry/usage" },
2246
2912
  summary: "Stored spans and logs per day and project on the node."
2247
2913
  }),
2914
+ op({
2915
+ ...read,
2916
+ id: "monitors.signal",
2917
+ path: "/v1/monitors/{monitor_id}/signal",
2918
+ scope: "monitors:read",
2919
+ input: N.monitorSignal,
2920
+ node: { path: "q/monitors/{monitor_id}/signal" },
2921
+ mcp: "reliability",
2922
+ summary: "A signal monitor's minute counts (count/assertion) for up to 24 h per environment, and its open runs (progress, deadline)."
2923
+ }),
2924
+ op({
2925
+ ...read,
2926
+ id: "monitors.occurrences",
2927
+ path: "/v1/monitors/{monitor_id}/occurrences",
2928
+ scope: "monitors:read",
2929
+ input: N.monitorOccurrences,
2930
+ node: { path: "q/monitors/{monitor_id}/occurrences", list: "occurrences" },
2931
+ paged: true,
2932
+ mcp: "reliability",
2933
+ summary: "Occurrences of a deadline monitor (pending, on time, late, missed, failed, cancelled), newest due first."
2934
+ }),
2935
+ op({
2936
+ ...read,
2937
+ id: "monitors.backtest",
2938
+ method: "POST",
2939
+ path: "/v1/monitors/backtest",
2940
+ scope: "monitors:read",
2941
+ input: N.monitorBacktest,
2942
+ node: { path: "q/monitors/backtest" },
2943
+ mcp: "reliability",
2944
+ summary: "How often count/assertion settings would have alerted over the last 30 days of stored data (same rule as the live evaluator)."
2945
+ }),
2946
+ op({
2947
+ ...read,
2948
+ id: "occurrences.create",
2949
+ method: "POST",
2950
+ path: "/v1/occurrences",
2951
+ scope: "monitors:write",
2952
+ input: N.occurrenceCreate,
2953
+ node: { path: "w/monitors/occurrences", body: "*" },
2954
+ mcp: "configure",
2955
+ summary: "Register one run a deadline monitor expects (`due_at` within 35 days); the same id again moves its due time while it is pending."
2956
+ }),
2957
+ op({
2958
+ ...read,
2959
+ id: "occurrences.cancel",
2960
+ method: "DELETE",
2961
+ path: "/v1/occurrences/{monitor_slug}/{occurrence_id}",
2962
+ scope: "monitors:write",
2963
+ input: N.occurrenceCancel,
2964
+ node: { path: "w/monitors/occurrences/cancel", body: "*" },
2965
+ mcp: "configure",
2966
+ summary: "Cancel a pending occurrence (the app moved or dropped the job); a cancelled occurrence never alerts."
2967
+ }),
2248
2968
  op({
2249
2969
  ...read,
2250
2970
  id: "issues.update",
@@ -2282,10 +3002,10 @@ var NODE_OPERATIONS = [
2282
3002
  ];
2283
3003
 
2284
3004
  // ../src/shared/contracts/api-ops/projects.ts
2285
- import { z as z17 } from "zod";
3005
+ import { z as z21 } from "zod";
2286
3006
 
2287
3007
  // ../src/shared/contracts/ingest-keys.ts
2288
- import { z as z13 } from "zod";
3008
+ import { z as z17 } from "zod";
2289
3009
  var INGEST_KEY_SCOPES = ["traces", "logs", "errors", "monitors"];
2290
3010
  var INGEST_KEY_STATES = ["active", "revoked"];
2291
3011
  var INGEST_KEY_LIMITS = {
@@ -2295,51 +3015,51 @@ var INGEST_KEY_LIMITS = {
2295
3015
  edgeCacheSeconds: 60
2296
3016
  };
2297
3017
  var CHECKIN_AUTH_MODES = ["public_or_key", "key_only"];
2298
- var ingestKeyConfigSchema = z13.object({
2299
- v: z13.literal(1),
2300
- key_id: z13.guid(),
2301
- project_public_id: z13.number().int().positive(),
2302
- project_id: z13.number().int().positive(),
2303
- workspace_id: z13.guid(),
3018
+ var ingestKeyConfigSchema = z17.object({
3019
+ v: z17.literal(1),
3020
+ key_id: z17.guid(),
3021
+ project_public_id: z17.number().int().positive(),
3022
+ project_id: z17.number().int().positive(),
3023
+ workspace_id: z17.guid(),
2304
3024
  node_id: nodeIdSchema,
2305
- scopes: z13.array(z13.enum(INGEST_KEY_SCOPES)).min(1).max(INGEST_KEY_SCOPES.length),
2306
- environments: z13.array(z13.string().max(INGEST_KEY_LIMITS.environmentMaxChars)).max(INGEST_KEY_LIMITS.environmentsMax),
2307
- expires_at: z13.string().datetime({ offset: true }).nullable(),
2308
- state: z13.enum(INGEST_KEY_STATES),
2309
- workspace_status: z13.enum(["active", "suspended", "deleting"]),
2310
- ingest_kill: z13.boolean(),
2311
- telemetry_kill: z13.boolean(),
2312
- telemetry_rate_bytes_per_sec: z13.number().int().positive(),
2313
- telemetry_burst_bytes: z13.number().int().positive(),
2314
- traces_monthly_bytes: z13.number().int().positive(),
2315
- logs_monthly_bytes: z13.number().int().positive(),
2316
- telemetry_buffer_minutes: z13.number().int().min(1).max(1440),
2317
- revision: z13.number().int().nonnegative()
3025
+ scopes: z17.array(z17.enum(INGEST_KEY_SCOPES)).min(1).max(INGEST_KEY_SCOPES.length),
3026
+ environments: z17.array(z17.string().max(INGEST_KEY_LIMITS.environmentMaxChars)).max(INGEST_KEY_LIMITS.environmentsMax),
3027
+ expires_at: z17.string().datetime({ offset: true }).nullable(),
3028
+ state: z17.enum(INGEST_KEY_STATES),
3029
+ workspace_status: z17.enum(["active", "suspended", "deleting"]),
3030
+ ingest_kill: z17.boolean(),
3031
+ telemetry_kill: z17.boolean(),
3032
+ telemetry_rate_bytes_per_sec: z17.number().int().positive(),
3033
+ telemetry_burst_bytes: z17.number().int().positive(),
3034
+ traces_monthly_bytes: z17.number().int().positive(),
3035
+ logs_monthly_bytes: z17.number().int().positive(),
3036
+ telemetry_buffer_minutes: z17.number().int().min(1).max(1440),
3037
+ revision: z17.number().int().nonnegative()
2318
3038
  });
2319
- var createIngestKeyInputSchema = z13.object({
2320
- projectId: z13.number().int().positive(),
2321
- name: z13.string().trim().min(1).max(INGEST_KEY_LIMITS.nameMaxChars).refine((s) => !/[\u0000-\u001f\u007f]/.test(s)),
2322
- scopes: z13.array(z13.enum(INGEST_KEY_SCOPES)).min(1).max(INGEST_KEY_SCOPES.length),
2323
- environments: z13.array(z13.string().trim().min(1).max(INGEST_KEY_LIMITS.environmentMaxChars).regex(/^[^\s/\u0000-\u001f]+$/)).max(INGEST_KEY_LIMITS.environmentsMax),
2324
- expiresAt: z13.string().datetime({ offset: true }).nullable()
3039
+ var createIngestKeyInputSchema = z17.object({
3040
+ projectId: z17.number().int().positive(),
3041
+ name: z17.string().trim().min(1).max(INGEST_KEY_LIMITS.nameMaxChars).refine((s) => !/[\u0000-\u001f\u007f]/.test(s)),
3042
+ scopes: z17.array(z17.enum(INGEST_KEY_SCOPES)).min(1).max(INGEST_KEY_SCOPES.length),
3043
+ environments: z17.array(z17.string().trim().min(1).max(INGEST_KEY_LIMITS.environmentMaxChars).regex(/^[^\s/\u0000-\u001f]+$/)).max(INGEST_KEY_LIMITS.environmentsMax),
3044
+ expiresAt: z17.string().datetime({ offset: true }).nullable()
2325
3045
  });
2326
- var ingestKeyRowSchema = z13.object({
2327
- id: z13.guid(),
2328
- project_id: z13.number().int().positive(),
2329
- name: z13.string(),
2330
- prefix: z13.string(),
2331
- scopes: z13.array(z13.enum(INGEST_KEY_SCOPES)),
2332
- environments: z13.array(z13.string()),
2333
- expires_at: z13.string().nullable(),
2334
- state: z13.enum(INGEST_KEY_STATES),
2335
- created_by: z13.guid().nullable(),
2336
- created_at: z13.string(),
2337
- revoked_at: z13.string().nullable(),
2338
- last_used_at: z13.string().nullable()
3046
+ var ingestKeyRowSchema = z17.object({
3047
+ id: z17.guid(),
3048
+ project_id: z17.number().int().positive(),
3049
+ name: z17.string(),
3050
+ prefix: z17.string(),
3051
+ scopes: z17.array(z17.enum(INGEST_KEY_SCOPES)),
3052
+ environments: z17.array(z17.string()),
3053
+ expires_at: z17.string().nullable(),
3054
+ state: z17.enum(INGEST_KEY_STATES),
3055
+ created_by: z17.guid().nullable(),
3056
+ created_at: z17.string(),
3057
+ revoked_at: z17.string().nullable(),
3058
+ last_used_at: z17.string().nullable()
2339
3059
  });
2340
3060
 
2341
3061
  // ../src/shared/contracts/integration-health.ts
2342
- import { z as z14 } from "zod";
3062
+ import { z as z18 } from "zod";
2343
3063
 
2344
3064
  // ../src/shared/contracts/platforms.ts
2345
3065
  var PLATFORMS = [
@@ -2353,116 +3073,116 @@ var PLATFORMS = [
2353
3073
 
2354
3074
  // ../src/shared/contracts/integration-health.ts
2355
3075
  var VERIFICATION_ID_RE = /^bv1_[0-9a-f]{32}$/;
2356
- var verificationIdSchema = z14.string().regex(VERIFICATION_ID_RE);
3076
+ var verificationIdSchema = z18.string().regex(VERIFICATION_ID_RE);
2357
3077
  var SURFACES = ["browser", "server"];
2358
3078
  var RECEIPT_SURFACES = ["browser", "server", "belvador"];
2359
3079
  var CHECKS = ["delivery", "uncaught", "pipeline"];
2360
3080
  var HOOK_STATES = ["ok", "missing", "unknown"];
2361
- var verificationContextSchema = z14.object({
2362
- v: z14.literal(1),
2363
- surface: z14.enum(RECEIPT_SURFACES),
2364
- check: z14.enum(CHECKS),
2365
- hook: z14.enum(HOOK_STATES).optional(),
2366
- uncaught_expected: z14.boolean().optional()
3081
+ var verificationContextSchema = z18.object({
3082
+ v: z18.literal(1),
3083
+ surface: z18.enum(RECEIPT_SURFACES),
3084
+ check: z18.enum(CHECKS),
3085
+ hook: z18.enum(HOOK_STATES).optional(),
3086
+ uncaught_expected: z18.boolean().optional()
2367
3087
  });
2368
- var iso3 = z14.string().datetime();
2369
- var projectId3 = z14.number().int().positive();
2370
- var verificationReceiptSchema = z14.object({
3088
+ var iso3 = z18.string().datetime();
3089
+ var projectId3 = z18.number().int().positive();
3090
+ var verificationReceiptSchema = z18.object({
2371
3091
  project_id: projectId3,
2372
3092
  verification_id: verificationIdSchema,
2373
- surface: z14.enum(RECEIPT_SURFACES),
2374
- check: z14.enum(CHECKS),
2375
- hook: z14.enum(HOOK_STATES),
2376
- uncaught_expected: z14.boolean(),
2377
- sdk_name: z14.string().max(80),
2378
- sdk_version: z14.string().max(40),
2379
- environment: z14.string().max(64),
2380
- release: z14.string().max(200),
2381
- source_host: z14.string().max(253),
3093
+ surface: z18.enum(RECEIPT_SURFACES),
3094
+ check: z18.enum(CHECKS),
3095
+ hook: z18.enum(HOOK_STATES),
3096
+ uncaught_expected: z18.boolean(),
3097
+ sdk_name: z18.string().max(80),
3098
+ sdk_version: z18.string().max(40),
3099
+ environment: z18.string().max(64),
3100
+ release: z18.string().max(200),
3101
+ source_host: z18.string().max(253),
2382
3102
  received_at: iso3
2383
3103
  });
2384
3104
  var SDK_DELIVERY_DROP_REASONS = ["network_error", "queue_overflow", "send_error"];
2385
- var clientDiscardSchema = z14.object({
3105
+ var clientDiscardSchema = z18.object({
2386
3106
  hour: iso3,
2387
- reason: z14.enum(SDK_DELIVERY_DROP_REASONS),
2388
- n: z14.number().int().nonnegative()
3107
+ reason: z18.enum(SDK_DELIVERY_DROP_REASONS),
3108
+ n: z18.number().int().nonnegative()
2389
3109
  });
2390
- var edgeVerificationRequestSchema = z14.object({
2391
- v: z14.literal(1),
3110
+ var edgeVerificationRequestSchema = z18.object({
3111
+ v: z18.literal(1),
2392
3112
  project_id: projectId3,
2393
3113
  verification_id: verificationIdSchema
2394
3114
  });
2395
- var readbackCheckSchema = z14.object({
2396
- surface: z14.enum(RECEIPT_SURFACES),
2397
- check: z14.enum(CHECKS),
2398
- hook: z14.enum(HOOK_STATES),
3115
+ var readbackCheckSchema = z18.object({
3116
+ surface: z18.enum(RECEIPT_SURFACES),
3117
+ check: z18.enum(CHECKS),
3118
+ hook: z18.enum(HOOK_STATES),
2399
3119
  received_at: iso3
2400
3120
  });
2401
- var edgeVerificationResponseSchema = z14.object({
2402
- checks: z14.array(readbackCheckSchema).max(8)
3121
+ var edgeVerificationResponseSchema = z18.object({
3122
+ checks: z18.array(readbackCheckSchema).max(8)
2403
3123
  });
2404
- var readbackResponseSchema = z14.object({
2405
- v: z14.literal(1),
3124
+ var readbackResponseSchema = z18.object({
3125
+ v: z18.literal(1),
2406
3126
  verification_id: verificationIdSchema,
2407
- node: z14.enum(["connected", "offline"]),
2408
- checks: z14.array(readbackCheckSchema).max(8)
3127
+ node: z18.enum(["connected", "offline"]),
3128
+ checks: z18.array(readbackCheckSchema).max(8)
2409
3129
  });
2410
3130
  var ENVIRONMENT_RE = /^[^\u0000-\u001f]{1,64}$/;
2411
- var projectRuntimeSchema = z14.object({
3131
+ var projectRuntimeSchema = z18.object({
2412
3132
  project_id: projectId3,
2413
- environment: z14.string().max(64),
2414
- surface: z14.enum(SURFACES),
2415
- sdk_name: z14.string().max(80),
2416
- sdk_version: z14.string().max(40),
2417
- latest_release: z14.string().max(200),
3133
+ environment: z18.string().max(64),
3134
+ surface: z18.enum(SURFACES),
3135
+ sdk_name: z18.string().max(80),
3136
+ sdk_version: z18.string().max(40),
3137
+ latest_release: z18.string().max(200),
2418
3138
  first_seen: iso3,
2419
3139
  last_seen: iso3,
2420
- events_24h: z14.number().int().nonnegative(),
2421
- check_ins_24h: z14.number().int().nonnegative()
3140
+ events_24h: z18.number().int().nonnegative(),
3141
+ check_ins_24h: z18.number().int().nonnegative()
2422
3142
  });
2423
3143
 
2424
3144
  // ../src/shared/contracts/node-config.ts
2425
- import { z as z16 } from "zod";
3145
+ import { z as z20 } from "zod";
2426
3146
 
2427
3147
  // ../src/shared/contracts/backup.ts
2428
- import { z as z15 } from "zod";
3148
+ import { z as z19 } from "zod";
2429
3149
  var BACKUP_KINDS = ["daily", "weekly", "manual", "pre_upgrade"];
2430
- var ageRecipient = z15.string().regex(/^age1[02-9ac-hj-np-z]{58}$/);
2431
- var backupIdSchema = z15.string().regex(/^[a-z0-9-]{8,64}$/);
2432
- var nodeBackupConfigSchema = z15.object({
2433
- enabled: z15.boolean(),
2434
- hour_utc: z15.number().int().min(0).max(23),
2435
- weekly_day: z15.number().int().min(1).max(7),
3150
+ var ageRecipient = z19.string().regex(/^age1[02-9ac-hj-np-z]{58}$/);
3151
+ var backupIdSchema = z19.string().regex(/^[a-z0-9-]{8,64}$/);
3152
+ var nodeBackupConfigSchema = z19.object({
3153
+ enabled: z19.boolean(),
3154
+ hour_utc: z19.number().int().min(0).max(23),
3155
+ weekly_day: z19.number().int().min(1).max(7),
2436
3156
  workspace_recipient: ageRecipient
2437
3157
  });
2438
- var backupCredentialsRequestSchema = z15.object({
2439
- mode: z15.enum(["upload", "download"]),
3158
+ var backupCredentialsRequestSchema = z19.object({
3159
+ mode: z19.enum(["upload", "download"]),
2440
3160
  backup_id: backupIdSchema,
2441
- source_node_id: z15.guid().optional()
3161
+ source_node_id: z19.guid().optional()
2442
3162
  });
2443
- var backupCredentialsSchema = z15.object({
2444
- endpoint: z15.string().url(),
2445
- bucket: z15.string().regex(/^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/),
2446
- prefix: z15.string().regex(/^backups\/[0-9a-f-]{36}\/$/),
2447
- access_key_id: z15.string().min(8).max(200),
2448
- secret_access_key: z15.string().min(8).max(200),
2449
- session_token: z15.string().min(8).max(4000),
2450
- expires_at: z15.string().datetime()
3163
+ var backupCredentialsSchema = z19.object({
3164
+ endpoint: z19.string().url(),
3165
+ bucket: z19.string().regex(/^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/),
3166
+ prefix: z19.string().regex(/^backups\/[0-9a-f-]{36}\/$/),
3167
+ access_key_id: z19.string().min(8).max(200),
3168
+ secret_access_key: z19.string().min(8).max(200),
3169
+ session_token: z19.string().min(8).max(4000),
3170
+ expires_at: z19.string().datetime()
2451
3171
  });
2452
- var rowCountsSchema = z15.record(z15.string().regex(/^[a-z_][a-z0-9_]{0,63}$/), z15.number().int().nonnegative());
2453
- var backupManifestSchema = z15.object({
2454
- v: z15.literal(1),
3172
+ var rowCountsSchema = z19.record(z19.string().regex(/^[a-z_][a-z0-9_]{0,63}$/), z19.number().int().nonnegative());
3173
+ var backupManifestSchema = z19.object({
3174
+ v: z19.literal(1),
2455
3175
  backup_id: backupIdSchema,
2456
- node_id: z15.guid(),
2457
- kind: z15.enum(BACKUP_KINDS),
2458
- created_at: z15.string().datetime(),
2459
- object_key: z15.string(),
2460
- size_bytes: z15.number().int().nonnegative(),
2461
- sha256: z15.string().regex(/^[0-9a-f]{64}$/),
2462
- clickhouse_version: z15.string().max(40),
2463
- schema_version: z15.number().int().nonnegative(),
3176
+ node_id: z19.guid(),
3177
+ kind: z19.enum(BACKUP_KINDS),
3178
+ created_at: z19.string().datetime(),
3179
+ object_key: z19.string(),
3180
+ size_bytes: z19.number().int().nonnegative(),
3181
+ sha256: z19.string().regex(/^[0-9a-f]{64}$/),
3182
+ clickhouse_version: z19.string().max(40),
3183
+ schema_version: z19.number().int().nonnegative(),
2464
3184
  row_counts: rowCountsSchema,
2465
- recipients: z15.array(z15.string().regex(/^[0-9a-f]{8}$/)).min(1).max(4)
3185
+ recipients: z19.array(z19.string().regex(/^[0-9a-f]{8}$/)).min(1).max(4)
2466
3186
  });
2467
3187
  var BACKUP_ERROR_CODES = [
2468
3188
  "CLICKHOUSE_BACKUP_FAILED",
@@ -2476,48 +3196,48 @@ var BACKUP_ERROR_CODES = [
2476
3196
  "RESTORE_FAILED",
2477
3197
  "ROW_COUNT_MISMATCH"
2478
3198
  ];
2479
- var backupReportSchema = z15.object({
3199
+ var backupReportSchema = z19.object({
2480
3200
  backup_id: backupIdSchema,
2481
- kind: z15.enum(BACKUP_KINDS),
2482
- status: z15.enum(["succeeded", "failed"]),
2483
- started_at: z15.string().datetime(),
2484
- finished_at: z15.string().datetime(),
3201
+ kind: z19.enum(BACKUP_KINDS),
3202
+ status: z19.enum(["succeeded", "failed"]),
3203
+ started_at: z19.string().datetime(),
3204
+ finished_at: z19.string().datetime(),
2485
3205
  manifest: backupManifestSchema.nullable(),
2486
- error_code: z15.enum(BACKUP_ERROR_CODES).nullable()
3206
+ error_code: z19.enum(BACKUP_ERROR_CODES).nullable()
2487
3207
  });
2488
- var drillReportSchema = z15.object({
3208
+ var drillReportSchema = z19.object({
2489
3209
  backup_id: backupIdSchema,
2490
- kind: z15.enum(["weekly_local", "monthly_new_machine"]),
2491
- status: z15.enum(["passed", "failed"]),
2492
- finished_at: z15.string().datetime(),
2493
- detail: z15.string().max(300),
2494
- error_code: z15.enum(BACKUP_ERROR_CODES).nullable()
3210
+ kind: z19.enum(["weekly_local", "monthly_new_machine"]),
3211
+ status: z19.enum(["passed", "failed"]),
3212
+ finished_at: z19.string().datetime(),
3213
+ detail: z19.string().max(300),
3214
+ error_code: z19.enum(BACKUP_ERROR_CODES).nullable()
2495
3215
  });
2496
- var nodeIdentityEscrowSchema = z15.object({
2497
- v: z15.literal(1),
2498
- node_id: z15.guid(),
2499
- seal: z15.object({
2500
- publicKey: z15.string().regex(/^[A-Za-z0-9_-]{43}$/),
2501
- privateKey: z15.string().regex(/^[A-Za-z0-9_-]{43}$/)
2502
- }),
2503
- created_at: z15.string().datetime()
3216
+ var nodeIdentityEscrowSchema = z19.object({
3217
+ v: z19.literal(1),
3218
+ node_id: z19.guid(),
3219
+ seal: z19.object({
3220
+ publicKey: z19.string().regex(/^[A-Za-z0-9_-]{43}$/),
3221
+ privateKey: z19.string().regex(/^[A-Za-z0-9_-]{43}$/)
3222
+ }),
3223
+ created_at: z19.string().datetime()
2504
3224
  });
2505
- var restoreArgsSchema = z15.object({
2506
- job_id: z15.guid(),
2507
- workspace_id: z15.guid(),
2508
- source_node_id: z15.guid(),
3225
+ var restoreArgsSchema = z19.object({
3226
+ job_id: z19.guid(),
3227
+ workspace_id: z19.guid(),
3228
+ source_node_id: z19.guid(),
2509
3229
  manifest: backupManifestSchema,
2510
- sealed_identity: z15.string().regex(/^[A-Za-z0-9_-]{40,2000}$/),
2511
- mode: z15.enum(["rebuild", "drill"])
3230
+ sealed_identity: z19.string().regex(/^[A-Za-z0-9_-]{40,2000}$/),
3231
+ mode: z19.enum(["rebuild", "drill"])
2512
3232
  });
2513
- var restoreReportSchema = z15.object({
2514
- job_id: z15.guid(),
3233
+ var restoreReportSchema = z19.object({
3234
+ job_id: z19.guid(),
2515
3235
  backup_id: backupIdSchema,
2516
- mode: z15.enum(["rebuild", "drill"]),
2517
- status: z15.enum(["succeeded", "failed"]),
2518
- finished_at: z15.string().datetime(),
2519
- detail: z15.string().max(300),
2520
- error_code: z15.enum(BACKUP_ERROR_CODES).nullable()
3236
+ mode: z19.enum(["rebuild", "drill"]),
3237
+ status: z19.enum(["succeeded", "failed"]),
3238
+ finished_at: z19.string().datetime(),
3239
+ detail: z19.string().max(300),
3240
+ error_code: z19.enum(BACKUP_ERROR_CODES).nullable()
2521
3241
  });
2522
3242
 
2523
3243
  // ../src/shared/contracts/node-config.ts
@@ -2531,79 +3251,81 @@ var SCRUB_GROUPS = [
2531
3251
  "headers"
2532
3252
  ];
2533
3253
  var MAX_NODE_MONITORS = 5000;
2534
- var kid = z16.string().regex(/^[A-Za-z0-9_-]{1,40}$/);
2535
- var publicKey = z16.string().regex(/^[A-Za-z0-9_-]{43}$/);
2536
- var nodeConfigSchema = z16.object({
2537
- v: z16.literal(1),
2538
- config_version: z16.number().int().positive(),
2539
- node_id: z16.guid(),
2540
- workspace_id: z16.guid(),
2541
- workspace_status: z16.enum(["active", "suspended"]),
2542
- issued_at: z16.string().datetime(),
2543
- retention_days: z16.number().int().min(1).max(3650),
2544
- channel: z16.enum(["stable", "canary"]).optional(),
2545
- projects: z16.array(z16.object({
2546
- project_id: z16.number().int().positive(),
2547
- slug: z16.string().max(64),
2548
- short_prefix: z16.string().regex(/^[A-Z0-9]{1,12}$/),
2549
- user_id_salt: z16.string().regex(/^[A-Za-z0-9_-]{22,64}$/),
2550
- scrub_disabled: z16.array(z16.enum(SCRUB_GROUPS)).max(SCRUB_GROUPS.length),
2551
- upload_tokens: z16.array(z16.object({
2552
- hash: z16.string().regex(/^[a-f0-9]{64}$/),
2553
- expires_at: z16.string().datetime()
3254
+ var kid = z20.string().regex(/^[A-Za-z0-9_-]{1,40}$/);
3255
+ var publicKey = z20.string().regex(/^[A-Za-z0-9_-]{43}$/);
3256
+ var nodeConfigSchema = z20.object({
3257
+ v: z20.literal(1),
3258
+ config_version: z20.number().int().positive(),
3259
+ node_id: z20.guid(),
3260
+ workspace_id: z20.guid(),
3261
+ workspace_status: z20.enum(["active", "suspended"]),
3262
+ issued_at: z20.string().datetime(),
3263
+ retention_days: z20.number().int().min(1).max(3650),
3264
+ channel: z20.enum(["stable", "canary"]).optional(),
3265
+ projects: z20.array(z20.object({
3266
+ project_id: z20.number().int().positive(),
3267
+ slug: z20.string().max(64),
3268
+ short_prefix: z20.string().regex(/^[A-Z0-9]{1,12}$/),
3269
+ user_id_salt: z20.string().regex(/^[A-Za-z0-9_-]{22,64}$/),
3270
+ scrub_disabled: z20.array(z20.enum(SCRUB_GROUPS)).max(SCRUB_GROUPS.length),
3271
+ upload_tokens: z20.array(z20.object({
3272
+ hash: z20.string().regex(/^[a-f0-9]{64}$/),
3273
+ expires_at: z20.string().datetime()
2554
3274
  })).max(10).optional()
2555
3275
  })).max(1000),
2556
- ticket_keys: z16.array(z16.object({ kid, public_key: publicKey, not_after: z16.string().datetime() })).min(1).max(5),
2557
- control_ops_keys: z16.array(z16.object({ kid, public_key: publicKey })).min(1).max(5),
2558
- kill_switches: z16.object({ ingest: z16.boolean(), alerts: z16.boolean() }),
3276
+ ticket_keys: z20.array(z20.object({ kid, public_key: publicKey, not_after: z20.string().datetime() })).min(1).max(5),
3277
+ control_ops_keys: z20.array(z20.object({ kid, public_key: publicKey })).min(1).max(5),
3278
+ kill_switches: z20.object({ ingest: z20.boolean(), alerts: z20.boolean() }),
2559
3279
  backup: nodeBackupConfigSchema.optional(),
2560
- purged_projects: z16.array(z16.number().int().positive()).max(1000).optional(),
2561
- monitors: z16.array(monitorDefinitionSchema).max(MAX_NODE_MONITORS).optional(),
2562
- purged_monitors: z16.array(z16.guid()).max(5000).optional(),
2563
- telemetry: z16.object({
2564
- traces_retention_days: z16.number().int().min(1).max(90),
2565
- logs_retention_days: z16.number().int().min(1).max(90),
2566
- traces_disk_share: z16.number().min(0.2).max(0.8)
3280
+ purged_projects: z20.array(z20.number().int().positive()).max(1000).optional(),
3281
+ monitors: z20.array(monitorDefinitionSchema).max(MAX_NODE_MONITORS).optional(),
3282
+ purged_monitors: z20.array(z20.guid()).max(5000).optional(),
3283
+ telemetry: z20.object({
3284
+ traces_retention_days: z20.number().int().min(1).max(90),
3285
+ logs_retention_days: z20.number().int().min(1).max(90),
3286
+ traces_disk_share: z20.number().min(0.2).max(0.8)
2567
3287
  }).optional(),
2568
- slos: z16.array(nodeSloSchema).max(SLO_LIMITS.maxNodeSlos).optional()
3288
+ slos: z20.array(nodeSloSchema).max(SLO_LIMITS.maxNodeSlos).optional(),
3289
+ signal_monitors: z20.array(signalMonitorDefinitionSchema).max(MAX_NODE_MONITORS).optional(),
3290
+ signal_limits: signalLimitsConfigSchema.optional()
2569
3291
  });
2570
- var signedNodeConfigSchema = z16.object({ config: nodeConfigSchema, kid, sig: z16.string() });
3292
+ var signedNodeConfigSchema = z20.object({ config: nodeConfigSchema, kid, sig: z20.string() });
2571
3293
 
2572
3294
  // ../src/shared/contracts/api-ops/projects.ts
2573
- var slug = z17.string().regex(/^[a-z0-9][a-z0-9-]{1,38}[a-z0-9]$/);
2574
- var name3 = z17.string().trim().min(1).max(60);
2575
- var label = z17.string().trim().min(1).max(40);
2576
- var platform = z17.enum(PLATFORMS);
2577
- var origin = z17.string().trim().toLowerCase().regex(/^https?:\/\/[a-z0-9.-]+(:[0-9]{1,5})?$/).max(200);
2578
- var keyId = z17.number().int().positive();
3295
+ var slug = z21.string().regex(/^[a-z0-9][a-z0-9-]{1,38}[a-z0-9]$/);
3296
+ var name3 = z21.string().trim().min(1).max(60);
3297
+ var label = z21.string().trim().min(1).max(40);
3298
+ var platform = z21.enum(PLATFORMS);
3299
+ var origin = z21.string().trim().toLowerCase().regex(/^https?:\/\/[a-z0-9.-]+(:[0-9]{1,5})?$/).max(200);
3300
+ var keyId = z21.number().int().positive();
2579
3301
  var PROJECT_INPUTS = {
2580
- create: z17.object({ workspaceId: uuid, name: name3, slug, platform }),
2581
- update: z17.object({ projectId, name: name3, platform, isPinned: z17.boolean() }),
2582
- updateIntake: z17.object({
3302
+ create: z21.object({ workspaceId: uuid, name: name3, slug, platform }),
3303
+ update: z21.object({ projectId, name: name3, platform, isPinned: z21.boolean() }),
3304
+ updateIntake: z21.object({
2583
3305
  projectId,
2584
- rateLimit: z17.number().int().positive().nullable(),
2585
- burst: z17.number().int().positive().nullable(),
2586
- allowedOrigins: z17.array(origin).max(50)
3306
+ rateLimit: z21.number().int().positive().nullable(),
3307
+ burst: z21.number().int().positive().nullable(),
3308
+ allowedOrigins: z21.array(origin).max(50)
2587
3309
  }),
2588
- updateObservability: z17.object({
3310
+ updateObservability: z21.object({
2589
3311
  projectId,
2590
- primaryEnvironment: z17.string().trim().min(1).max(64).refine((v) => v !== "*" && ENVIRONMENT_RE.test(v)),
2591
- allowCodeMonitors: z17.boolean()
3312
+ primaryEnvironment: z21.string().trim().min(1).max(64).refine((v) => v !== "*" && ENVIRONMENT_RE.test(v)),
3313
+ allowCodeMonitors: z21.boolean()
2592
3314
  }),
2593
- setScrub: z17.object({ projectId, group: z17.enum(SCRUB_GROUPS), enabled: z17.boolean() }),
2594
- setCheckinAuth: z17.object({ projectId, mode: z17.enum(CHECKIN_AUTH_MODES) }),
2595
- setEnvironmentHidden: z17.object({
3315
+ setScrub: z21.object({ projectId, group: z21.enum(SCRUB_GROUPS), enabled: z21.boolean() }),
3316
+ setCheckinAuth: z21.object({ projectId, mode: z21.enum(CHECKIN_AUTH_MODES) }),
3317
+ setEnvironmentHidden: z21.object({
2596
3318
  projectId,
2597
- name: z17.string().min(1).max(64),
2598
- hidden: z17.boolean()
2599
- }),
2600
- scheduleDeletion: z17.object({ projectId, confirmSlug: slug }),
2601
- projectOnly: z17.object({ projectId }),
2602
- labelled: z17.object({ projectId, label }),
2603
- keyOnly: z17.object({ keyId }),
2604
- tokenOnly: z17.object({ tokenId: keyId }),
3319
+ name: z21.string().min(1).max(64),
3320
+ hidden: z21.boolean()
3321
+ }),
3322
+ scheduleDeletion: z21.object({ projectId, confirmSlug: slug }),
3323
+ projectOnly: z21.object({ projectId }),
3324
+ labelled: z21.object({ projectId, label }),
3325
+ keyOnly: z21.object({ keyId }),
3326
+ tokenOnly: z21.object({ tokenId: keyId }),
2605
3327
  createIngestKey: createIngestKeyInputSchema,
2606
- ingestKeyOnly: z17.object({ keyId: uuid })
3328
+ ingestKeyOnly: z21.object({ keyId: uuid })
2607
3329
  };
2608
3330
  var P = PROJECT_INPUTS;
2609
3331
  var PROJECT_OPERATIONS = [
@@ -2858,24 +3580,28 @@ var PROJECT_OPERATIONS = [
2858
3580
  ];
2859
3581
 
2860
3582
  // ../src/shared/contracts/api-ops/reads.ts
2861
- import { z as z18 } from "zod";
2862
- var list = z18.object({ workspaceId: uuid, limit: pageLimit, cursor });
3583
+ import { z as z22 } from "zod";
3584
+ var list = z22.object({ workspaceId: uuid, limit: pageLimit, cursor });
2863
3585
  var READ_INPUTS = {
2864
- workspace: z18.object({ workspaceId: uuid }),
3586
+ workspace: z22.object({ workspaceId: uuid }),
2865
3587
  list,
2866
- projectsGet: z18.object({ workspaceId: uuid, projectId }),
3588
+ projectsGet: z22.object({ workspaceId: uuid, projectId }),
2867
3589
  monitorsList: list.extend({ projectId: projectId.optional() }),
2868
- monitorsGet: z18.object({ workspaceId: uuid, monitorId: uuid }),
2869
- uptimeGet: z18.object({ workspaceId: uuid, checkId: uuid }),
2870
- slosGet: z18.object({ workspaceId: uuid, sloId: uuid }),
3590
+ monitorsGet: z22.object({ workspaceId: uuid, monitorId: uuid }),
3591
+ uptimeGet: z22.object({ workspaceId: uuid, checkId: uuid }),
3592
+ slosGet: z22.object({ workspaceId: uuid, sloId: uuid }),
2871
3593
  alertsList: list.extend({
2872
- state: z18.enum(["open", "resolved", "all"]).default("all"),
3594
+ state: z22.enum(["open", "resolved", "all"]).default("all"),
2873
3595
  monitorId: uuid.optional()
2874
3596
  }),
2875
- approvalsGet: z18.object({ workspaceId: uuid, approvalId: uuid })
3597
+ approvalsGet: z22.object({ workspaceId: uuid, approvalId: uuid }),
3598
+ monitorsListTyped: list.extend({
3599
+ projectId: projectId.optional(),
3600
+ type: z22.enum(MONITOR_TYPES).optional()
3601
+ })
2876
3602
  };
2877
3603
  var R = READ_INPUTS;
2878
- var base = {
3604
+ var base2 = {
2879
3605
  sensitivity: "normal",
2880
3606
  kind: "read",
2881
3607
  method: "GET",
@@ -2885,7 +3611,7 @@ var base = {
2885
3611
  };
2886
3612
  var READ_OPERATIONS = [
2887
3613
  op({
2888
- ...base,
3614
+ ...base2,
2889
3615
  id: "workspace.get",
2890
3616
  path: "/v1/workspace",
2891
3617
  scope: "org:read",
@@ -2895,7 +3621,7 @@ var READ_OPERATIONS = [
2895
3621
  summary: "The token's workspace, plan and the caller's role."
2896
3622
  }),
2897
3623
  op({
2898
- ...base,
3624
+ ...base2,
2899
3625
  id: "members.list",
2900
3626
  path: "/v1/members",
2901
3627
  scope: "members:read",
@@ -2906,7 +3632,7 @@ var READ_OPERATIONS = [
2906
3632
  summary: "Workspace members and their roles."
2907
3633
  }),
2908
3634
  op({
2909
- ...base,
3635
+ ...base2,
2910
3636
  id: "projects.list",
2911
3637
  path: "/v1/projects",
2912
3638
  scope: "projects:read",
@@ -2917,7 +3643,7 @@ var READ_OPERATIONS = [
2917
3643
  summary: "Projects the token can see."
2918
3644
  }),
2919
3645
  op({
2920
- ...base,
3646
+ ...base2,
2921
3647
  id: "projects.get",
2922
3648
  path: "/v1/projects/{project_id}",
2923
3649
  scope: "projects:read",
@@ -2927,18 +3653,18 @@ var READ_OPERATIONS = [
2927
3653
  summary: "One project."
2928
3654
  }),
2929
3655
  op({
2930
- ...base,
3656
+ ...base2,
2931
3657
  id: "monitors.list",
2932
3658
  path: "/v1/monitors",
2933
3659
  scope: "monitors:read",
2934
3660
  rpcs: ["api_read_monitors"],
2935
- input: R.monitorsList,
3661
+ input: R.monitorsListTyped,
2936
3662
  paged: true,
2937
3663
  mcp: "investigate",
2938
- summary: "Cron and heartbeat monitors."
3664
+ summary: "Monitors of every type (cron, heartbeat, count, assertion, deadline, progress); `type` narrows the list."
2939
3665
  }),
2940
3666
  op({
2941
- ...base,
3667
+ ...base2,
2942
3668
  id: "monitors.get",
2943
3669
  path: "/v1/monitors/{monitor_id}",
2944
3670
  scope: "monitors:read",
@@ -2948,7 +3674,7 @@ var READ_OPERATIONS = [
2948
3674
  summary: "One monitor with its ETag."
2949
3675
  }),
2950
3676
  op({
2951
- ...base,
3677
+ ...base2,
2952
3678
  id: "uptime.list",
2953
3679
  path: "/v1/uptime-checks",
2954
3680
  scope: "monitors:read",
@@ -2959,7 +3685,7 @@ var READ_OPERATIONS = [
2959
3685
  summary: "Uptime checks (header values are never returned)."
2960
3686
  }),
2961
3687
  op({
2962
- ...base,
3688
+ ...base2,
2963
3689
  id: "uptime.get",
2964
3690
  path: "/v1/uptime-checks/{check_id}",
2965
3691
  scope: "monitors:read",
@@ -2969,7 +3695,7 @@ var READ_OPERATIONS = [
2969
3695
  summary: "One uptime check."
2970
3696
  }),
2971
3697
  op({
2972
- ...base,
3698
+ ...base2,
2973
3699
  id: "slos.list",
2974
3700
  path: "/v1/slos",
2975
3701
  scope: "monitors:read",
@@ -2980,7 +3706,7 @@ var READ_OPERATIONS = [
2980
3706
  summary: "SLO definitions."
2981
3707
  }),
2982
3708
  op({
2983
- ...base,
3709
+ ...base2,
2984
3710
  id: "slos.get",
2985
3711
  path: "/v1/slos/{slo_id}",
2986
3712
  scope: "monitors:read",
@@ -2990,7 +3716,7 @@ var READ_OPERATIONS = [
2990
3716
  summary: "One SLO definition."
2991
3717
  }),
2992
3718
  op({
2993
- ...base,
3719
+ ...base2,
2994
3720
  id: "alert_rules.list",
2995
3721
  path: "/v1/alert-rules",
2996
3722
  scope: "alerts:read",
@@ -3001,7 +3727,7 @@ var READ_OPERATIONS = [
3001
3727
  summary: "Alert rules."
3002
3728
  }),
3003
3729
  op({
3004
- ...base,
3730
+ ...base2,
3005
3731
  id: "destinations.list",
3006
3732
  path: "/v1/destinations",
3007
3733
  scope: "alerts:read",
@@ -3012,7 +3738,7 @@ var READ_OPERATIONS = [
3012
3738
  summary: "Alert destinations with a masked hint; secrets never leave the server."
3013
3739
  }),
3014
3740
  op({
3015
- ...base,
3741
+ ...base2,
3016
3742
  id: "alerts.list",
3017
3743
  path: "/v1/alerts",
3018
3744
  scope: "alerts:read",
@@ -3023,7 +3749,18 @@ var READ_OPERATIONS = [
3023
3749
  summary: "Alerts: one row per violation episode of a monitor, open or resolved."
3024
3750
  }),
3025
3751
  op({
3026
- ...base,
3752
+ ...base2,
3753
+ id: "maintenance.list",
3754
+ path: "/v1/maintenance-windows",
3755
+ scope: "monitors:read",
3756
+ rpcs: ["api_read_maintenance_windows"],
3757
+ input: R.list,
3758
+ paged: true,
3759
+ mcp: "reliability",
3760
+ summary: "Maintenance windows and whether each is active now."
3761
+ }),
3762
+ op({
3763
+ ...base2,
3027
3764
  id: "node.get",
3028
3765
  path: "/v1/node",
3029
3766
  scope: "org:read",
@@ -3033,7 +3770,7 @@ var READ_OPERATIONS = [
3033
3770
  summary: "The node's state, versions and last heartbeat (null before provisioning)."
3034
3771
  }),
3035
3772
  op({
3036
- ...base,
3773
+ ...base2,
3037
3774
  id: "usage.get",
3038
3775
  path: "/v1/usage",
3039
3776
  scope: "usage:read",
@@ -3043,7 +3780,7 @@ var READ_OPERATIONS = [
3043
3780
  summary: "The workspace's plan and limits."
3044
3781
  }),
3045
3782
  op({
3046
- ...base,
3783
+ ...base2,
3047
3784
  id: "audit.list",
3048
3785
  path: "/v1/audit-log",
3049
3786
  scope: "audit:read",
@@ -3054,7 +3791,7 @@ var READ_OPERATIONS = [
3054
3791
  summary: "Audit log, newest first (admins)."
3055
3792
  }),
3056
3793
  op({
3057
- ...base,
3794
+ ...base2,
3058
3795
  id: "approvals.get",
3059
3796
  path: "/v1/approvals/{approval_id}",
3060
3797
  scope: "org:read",
@@ -3071,6 +3808,7 @@ var API_OPERATIONS = [
3071
3808
  ...PROJECT_OPERATIONS,
3072
3809
  ...MONITOR_OPERATIONS,
3073
3810
  ...ALERT_OPERATIONS,
3811
+ ...INCIDENT_OPERATIONS,
3074
3812
  ...ACCESS_OPERATIONS,
3075
3813
  ...NODE_OPERATIONS
3076
3814
  ];
@@ -3139,14 +3877,14 @@ function approvalRequestSchema(operationId, input) {
3139
3877
  }
3140
3878
 
3141
3879
  // ../src/shared/contracts/api-ops/wire.ts
3142
- import { z as z19 } from "zod";
3880
+ import { z as z23 } from "zod";
3143
3881
  var toSnake = (s) => s.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`);
3144
3882
  var toCamel = (s) => s.replace(/_([a-z0-9])/g, (_, c) => c.toUpperCase());
3145
3883
  var schemaCache = new WeakMap;
3146
3884
  function inputJsonSchema(op) {
3147
3885
  let js = schemaCache.get(op.input);
3148
3886
  if (!js) {
3149
- js = z19.toJSONSchema(op.input, { io: "input", unrepresentable: "any" });
3887
+ js = z23.toJSONSchema(op.input, { io: "input", unrepresentable: "any" });
3150
3888
  schemaCache.set(op.input, js);
3151
3889
  }
3152
3890
  return js;
@@ -3271,6 +4009,18 @@ function wirePointer(op, path) {
3271
4009
  segs.shift();
3272
4010
  return `/${segs.map((s) => s.replace(/~/g, "~0").replace(/\//g, "~1")).join("/")}`;
3273
4011
  }
4012
+ var WIRE_ERRORS_MAX = 20;
4013
+ function wireErrors(op, error) {
4014
+ const flat = (issues, prefix) => issues.flatMap((i) => {
4015
+ if (i.code === "invalid_union" && i.errors && i.errors.length > 0) {
4016
+ const best = i.errors.reduce((a, b) => b.length < a.length ? b : a);
4017
+ if (best.length > 0)
4018
+ return flat(best, [...prefix, ...i.path]);
4019
+ }
4020
+ return [{ ...i, path: [...prefix, ...i.path] }];
4021
+ });
4022
+ return flat(error.issues, []).slice(0, WIRE_ERRORS_MAX).map((i) => ({ pointer: wirePointer(op, i.path), code: i.code }));
4023
+ }
3274
4024
 
3275
4025
  // ../src/shared/contracts/api-ops/openapi.ts
3276
4026
  function clean(js) {
@@ -3348,7 +4098,7 @@ function wireInput(operationId, opts = {}) {
3348
4098
  for (const [k, v] of Object.entries(op.input.shape))
3349
4099
  if (!omit.has(k))
3350
4100
  shape[toSnake(k)] = v;
3351
- return z20.object(shape);
4101
+ return z24.object(shape);
3352
4102
  }
3353
4103
  var BUDGETS = [
3354
4104
  { stringBytes: MCP_LIMITS.untrustedStringMaxBytes, listMax: MCP_LIMITS.listMax },
@@ -3438,40 +4188,40 @@ function errorResult(o) {
3438
4188
  }
3439
4189
  };
3440
4190
  }
3441
- var TOOL_OUTPUT_SCHEMA = z20.object({
3442
- untrusted: z20.object({
3443
- data: z20.unknown(),
3444
- provenance: z20.object({
3445
- source: z20.enum(["node", "control_plane", "docs"]),
3446
- operations: z20.array(z20.string())
4191
+ var TOOL_OUTPUT_SCHEMA = z24.object({
4192
+ untrusted: z24.object({
4193
+ data: z24.unknown(),
4194
+ provenance: z24.object({
4195
+ source: z24.enum(["node", "control_plane", "docs"]),
4196
+ operations: z24.array(z24.string())
3447
4197
  })
3448
4198
  }).optional(),
3449
- doc: z20.object({ slug: z20.string(), locale: z20.enum(["en", "vi"]), url: z20.string(), markdown: z20.string(), truncated: z20.boolean() }).optional(),
3450
- results: z20.array(z20.object({ slug: z20.string(), title: z20.string(), description: z20.string(), section: z20.string(), url: z20.string() })).optional(),
3451
- next_cursor: z20.string().nullable().optional(),
3452
- complete: z20.boolean().optional(),
3453
- omitted: z20.array(z20.object({ part: z20.string(), reason: z20.string(), scope: z20.string().optional() })).optional(),
3454
- truncated: z20.literal(true).optional(),
3455
- suspicious_unicode: z20.literal(true).optional(),
3456
- error: z20.object({
3457
- code: z20.string(),
3458
- status: z20.number(),
3459
- detail: z20.string().optional(),
3460
- scope: z20.string().optional(),
3461
- retry_after: z20.number().optional()
4199
+ doc: z24.object({ slug: z24.string(), locale: z24.enum(["en", "vi"]), url: z24.string(), markdown: z24.string(), truncated: z24.boolean() }).optional(),
4200
+ results: z24.array(z24.object({ slug: z24.string(), title: z24.string(), description: z24.string(), section: z24.string(), url: z24.string() })).optional(),
4201
+ next_cursor: z24.string().nullable().optional(),
4202
+ complete: z24.boolean().optional(),
4203
+ omitted: z24.array(z24.object({ part: z24.string(), reason: z24.string(), scope: z24.string().optional() })).optional(),
4204
+ truncated: z24.literal(true).optional(),
4205
+ suspicious_unicode: z24.literal(true).optional(),
4206
+ error: z24.object({
4207
+ code: z24.string(),
4208
+ status: z24.number(),
4209
+ detail: z24.string().optional(),
4210
+ scope: z24.string().optional(),
4211
+ retry_after: z24.number().optional()
3462
4212
  }).optional(),
3463
- operations: z20.array(z20.record(z20.string(), z20.unknown())).optional(),
3464
- operation: z20.record(z20.string(), z20.unknown()).optional(),
3465
- plan: z20.record(z20.string(), z20.unknown()).optional(),
3466
- status: z20.enum(["done", "approval_required", "approval_pending", ...APPROVAL_STATES]).optional(),
3467
- approval: z20.object({
3468
- approval_id: z20.string(),
3469
- approval_url: z20.string(),
3470
- expires_at: z20.string(),
3471
- state: z20.enum(APPROVAL_STATES),
3472
- result_code: z20.string().nullable().optional(),
3473
- result: z20.record(z20.string(), z20.unknown()).optional(),
3474
- next: z20.string().optional()
4213
+ operations: z24.array(z24.record(z24.string(), z24.unknown())).optional(),
4214
+ operation: z24.record(z24.string(), z24.unknown()).optional(),
4215
+ plan: z24.record(z24.string(), z24.unknown()).optional(),
4216
+ status: z24.enum(["done", "approval_required", "approval_pending", ...APPROVAL_STATES]).optional(),
4217
+ approval: z24.object({
4218
+ approval_id: z24.string(),
4219
+ approval_url: z24.string(),
4220
+ expires_at: z24.string(),
4221
+ state: z24.enum(APPROVAL_STATES),
4222
+ result_code: z24.string().nullable().optional(),
4223
+ result: z24.record(z24.string(), z24.unknown()).optional(),
4224
+ next: z24.string().optional()
3475
4225
  }).optional()
3476
4226
  });
3477
4227
  var spec = (name) => {
@@ -3517,10 +4267,10 @@ var has = (rt, operationId) => {
3517
4267
  return !!op && rt.scopes.includes(op.scope);
3518
4268
  };
3519
4269
  var isoWindow = {
3520
- start: z20.string().max(40).describe("RFC 3339 start of the window, e.g. 2026-10-26T00:00:00Z. Required with end."),
3521
- end: z20.string().max(40).describe("RFC 3339 end of the window. The plan limits its length.")
4270
+ start: z24.string().max(40).describe("RFC 3339 start of the window, e.g. 2026-10-26T00:00:00Z. Required with end."),
4271
+ end: z24.string().max(40).describe("RFC 3339 end of the window. The plan limits its length.")
3522
4272
  };
3523
- var traceIdSchema = z20.string().regex(/^[0-9a-fA-F]{32}$/);
4273
+ var traceIdSchema = z24.string().regex(/^[0-9a-fA-F]{32}$/);
3524
4274
  var MONITOR_KINDS2 = {
3525
4275
  cron: { list: "monitors.list", get: "monitors.get", idField: "monitor_id" },
3526
4276
  uptime: { list: "uptime.list", get: "uptime.get", idField: "check_id" },
@@ -3569,7 +4319,7 @@ function validateConfigure(op, params) {
3569
4319
  return { ok: true };
3570
4320
  return {
3571
4321
  ok: false,
3572
- errors: r.error.issues.slice(0, 20).map((i) => ({ pointer: wirePointer(op, i.path), code: i.code }))
4322
+ errors: wireErrors(op, r.error)
3573
4323
  };
3574
4324
  }
3575
4325
  function describe(op, scopes) {
@@ -3584,8 +4334,8 @@ function describe(op, scopes) {
3584
4334
  destructive: isDestructiveOperation(op)
3585
4335
  };
3586
4336
  }
3587
- var params = z20.record(z20.string(), z20.unknown()).default({}).describe("Operation fields in wire names (snake_case), as describe_operation's args_schema shows.");
3588
- var operationIdArg = z20.string().min(3).max(80).describe("An operation id from search_operations, e.g. `monitors.update`.");
4337
+ var params = z24.record(z24.string(), z24.unknown()).default({}).describe("Operation fields in wire names (snake_case), as describe_operation's args_schema shows.");
4338
+ var operationIdArg = z24.string().min(3).max(80).describe("An operation id from search_operations, e.g. `monitors.update`.");
3589
4339
  function approvalBlock(t, next) {
3590
4340
  return {
3591
4341
  approval_id: t.approval_id,
@@ -3605,7 +4355,7 @@ var MCP_TOOL_DEFS = [
3605
4355
  title: "Workspace and node",
3606
4356
  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.",
3607
4357
  operations: ["workspace.get", "node.get"],
3608
- input: z20.object({}),
4358
+ input: z24.object({}),
3609
4359
  async run(_args, rt) {
3610
4360
  const [ws, node] = await Promise.all([rt.call("workspace.get", {}), rt.call("node.get", {})]);
3611
4361
  if (!ws.ok)
@@ -3623,9 +4373,9 @@ var MCP_TOOL_DEFS = [
3623
4373
  title: "Get an issue",
3624
4374
  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).",
3625
4375
  operations: ["issues.get", "events.get"],
3626
- input: z20.object({
3627
- issue_id: z20.number().int().positive().describe("Issue id from search_issues."),
3628
- include_latest_event: z20.boolean().default(true)
4376
+ input: z24.object({
4377
+ issue_id: z24.number().int().positive().describe("Issue id from search_issues."),
4378
+ include_latest_event: z24.boolean().default(true)
3629
4379
  }),
3630
4380
  async run(args, rt) {
3631
4381
  const omitted = [];
@@ -3653,9 +4403,9 @@ var MCP_TOOL_DEFS = [
3653
4403
  title: "Get a trace",
3654
4404
  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).",
3655
4405
  operations: ["traces.get", "traces.spans"],
3656
- input: z20.object({
4406
+ input: z24.object({
3657
4407
  trace_id: traceIdSchema.describe("W3C trace id, 32 hex characters."),
3658
- spans: z20.enum(["none", "errors", "all"]).default("none")
4408
+ spans: z24.enum(["none", "errors", "all"]).default("none")
3659
4409
  }),
3660
4410
  async run(args, rt) {
3661
4411
  const sum = await rt.call("traces.get", { trace_id: args["trace_id"] });
@@ -3683,11 +4433,11 @@ var MCP_TOOL_DEFS = [
3683
4433
  title: "Correlate by trace or run",
3684
4434
  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.",
3685
4435
  operations: ["traces.get", "traces.spans", "spans.list", "logs.list"],
3686
- input: z20.object({
4436
+ input: z24.object({
3687
4437
  trace_id: traceIdSchema.optional(),
3688
- run_id: z20.string().min(1).max(128).optional(),
4438
+ run_id: z24.string().min(1).max(128).optional(),
3689
4439
  ...isoWindow,
3690
- project: z20.string().max(2000).optional().describe("Comma-separated project ids.")
4440
+ project: z24.string().max(2000).optional().describe("Comma-separated project ids.")
3691
4441
  }),
3692
4442
  async run(args, rt) {
3693
4443
  const trace = args["trace_id"];
@@ -3730,12 +4480,12 @@ var MCP_TOOL_DEFS = [
3730
4480
  {
3731
4481
  ...spec("list_monitors"),
3732
4482
  title: "List monitors",
3733
- description: "Cron/heartbeat monitors, uptime checks and SLOs with their current status. `kind` narrows to one family; `project_id` to one project (cron and uptime).",
4483
+ 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).",
3734
4484
  operations: ["monitors.list", "uptime.list", "slos.list"],
3735
- input: z20.object({
3736
- kind: z20.enum(["all", "cron", "uptime", "slo"]).default("all"),
3737
- project_id: z20.number().int().positive().optional(),
3738
- limit: z20.number().int().min(1).max(200).default(50)
4485
+ input: z24.object({
4486
+ kind: z24.enum(["all", "cron", "uptime", "slo"]).default("all"),
4487
+ project_id: z24.number().int().positive().optional(),
4488
+ limit: z24.number().int().min(1).max(200).default(50)
3739
4489
  }),
3740
4490
  async run(args, rt) {
3741
4491
  const kinds = args["kind"] && args["kind"] !== "all" ? [args["kind"]] : ["cron", "uptime", "slo"];
@@ -3761,26 +4511,69 @@ var MCP_TOOL_DEFS = [
3761
4511
  {
3762
4512
  ...spec("get_monitor_status"),
3763
4513
  title: "Get a monitor",
3764
- description: "One cron monitor, uptime check or SLO by id: settings, current status and recent results.",
3765
- operations: ["monitors.get", "uptime.get", "slos.get"],
3766
- input: z20.object({ kind: z20.enum(["cron", "uptime", "slo"]), id: z20.guid() }),
4514
+ 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.",
4515
+ operations: ["monitors.get", "uptime.get", "slos.get", "monitors.signal", "monitors.occurrences", "monitors.backtest"],
4516
+ input: z24.object({
4517
+ kind: z24.enum(["cron", "uptime", "slo"]),
4518
+ id: z24.guid(),
4519
+ backtest: z24.boolean().default(false)
4520
+ }),
3767
4521
  async run(args, rt) {
3768
4522
  const k = MONITOR_KINDS2[args["kind"]];
3769
4523
  const r = await rt.call(k.get, { [k.idField]: args["id"] });
3770
4524
  if (!r.ok)
3771
4525
  return errorResult(r);
3772
- return wrapResult({ data: r.body, operations: [k.get], source: "control_plane" });
4526
+ const row = r.body ?? {};
4527
+ const type = typeof row["type"] === "string" ? row["type"] : "job";
4528
+ if (k.get !== "monitors.get" || !isSignalMonitorType(type)) {
4529
+ return wrapResult({ data: r.body, operations: [k.get], source: "control_plane" });
4530
+ }
4531
+ const ops = [k.get, "monitors.signal"];
4532
+ const calls = [
4533
+ rt.call("monitors.signal", { monitor_id: args["id"], hours: 24 })
4534
+ ];
4535
+ const parts = ["signal"];
4536
+ if (type === "deadline") {
4537
+ ops.push("monitors.occurrences");
4538
+ parts.push("occurrences");
4539
+ calls.push(rt.call("monitors.occurrences", { monitor_id: args["id"], state: "all" }));
4540
+ }
4541
+ const settings = args["backtest"] === true && (type === "count" || type === "assertion") ? settingsFromRow({
4542
+ type,
4543
+ signal_settings: row["signal_settings"],
4544
+ expected_environments: Array.isArray(row["expected_environments"]) ? row["expected_environments"] : [],
4545
+ severity: String(row["severity"] ?? "medium"),
4546
+ recovery_threshold: Number(row["recovery_threshold"] ?? 1)
4547
+ }) : null;
4548
+ if (settings) {
4549
+ ops.push("monitors.backtest");
4550
+ parts.push("backtest");
4551
+ calls.push(rt.call("monitors.backtest", { project: row["project_id"], settings }));
4552
+ }
4553
+ const answers = await Promise.all(calls);
4554
+ const data = { monitor: r.body };
4555
+ const omitted = [];
4556
+ for (const [i, part] of parts.entries()) {
4557
+ const a = answers[i];
4558
+ if (a.ok)
4559
+ data[part] = part === "occurrences" ? withoutPaging(a.body) : a.body;
4560
+ else
4561
+ omitted.push({ part, reason: a.code });
4562
+ }
4563
+ return wrapResult({ data, operations: ops, source: omitted.length === parts.length ? "control_plane" : "node" }, { omitted });
3773
4564
  }
3774
4565
  },
3775
4566
  single("list_alerts", "alerts.list", "List alerts", "Alerts Belvador raised (open, resolved or all), newest first, optionally for one monitor."),
4567
+ single("list_incidents", "incidents.list", "List incidents", "Incidents (INC-n): related alerts grouped into one piece of work. State (open, acknowledged, monitoring, resolved), severity and peak, owner, linked and still-firing alert counts; newest first. `state` = active, resolved or all. Returns ids for get_incident."),
4568
+ single("get_incident", "incidents.get", "Get an incident", "One incident by id: its linked alerts (monitor, uptime, SLO, issue) with ids for get_monitor_status or get_issue, the timeline (opened, joined, acknowledged, notes, escalation, resolution) and each message's delivery state. `accepted` means the service took the message; only `acknowledged: true` means a person took the incident."),
3776
4569
  {
3777
4570
  ...spec("verify_integration"),
3778
4571
  title: "Send a test event",
3779
4572
  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).",
3780
4573
  operations: ["projects.send_test_event"],
3781
- input: z20.object({
3782
- project_id: z20.number().int().positive(),
3783
- idempotency_key: z20.string().min(8).max(255).optional()
4574
+ input: z24.object({
4575
+ project_id: z24.number().int().positive(),
4576
+ idempotency_key: z24.string().min(8).max(255).optional()
3784
4577
  }),
3785
4578
  async run(args, rt) {
3786
4579
  const r = await rt.call("projects.send_test_event", { project_id: args["project_id"] }, { idempotencyKey: args["idempotency_key"] ?? rt.newKey() });
@@ -3792,11 +4585,11 @@ var MCP_TOOL_DEFS = [
3792
4585
  {
3793
4586
  ...spec("search_operations"),
3794
4587
  title: "Find a configuration change",
3795
- description: "Searches what this token can change in its Belvador workspace: projects, keys and tokens, monitors, 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.",
4588
+ 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.",
3796
4589
  operations: [],
3797
- input: z20.object({
3798
- query: z20.string().min(1).max(200).describe("Words such as `rotate dsn key`, `heartbeat monitor`, `slack alert`."),
3799
- limit: z20.number().int().min(1).max(20).default(10)
4590
+ input: z24.object({
4591
+ query: z24.string().min(1).max(200).describe("Words such as `rotate dsn key`, `heartbeat monitor`, `slack alert`."),
4592
+ limit: z24.number().int().min(1).max(20).default(10)
3800
4593
  }),
3801
4594
  async run(args, rt) {
3802
4595
  const q = words(String(args["query"]));
@@ -3824,7 +4617,7 @@ var MCP_TOOL_DEFS = [
3824
4617
  title: "Describe a configuration change",
3825
4618
  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.",
3826
4619
  operations: [],
3827
- input: z20.object({ operation_id: operationIdArg }),
4620
+ input: z24.object({ operation_id: operationIdArg }),
3828
4621
  async run(args, rt) {
3829
4622
  const op = configureOp(args["operation_id"]);
3830
4623
  if (!op || op.method === "GET")
@@ -3853,7 +4646,7 @@ var MCP_TOOL_DEFS = [
3853
4646
  title: "Check a change before applying it",
3854
4647
  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.",
3855
4648
  operations: [],
3856
- input: z20.object({ operation_id: operationIdArg, params }),
4649
+ input: z24.object({ operation_id: operationIdArg, params }),
3857
4650
  async run(args, rt) {
3858
4651
  const op = configureOp(args["operation_id"]);
3859
4652
  if (!op || op.method === "GET")
@@ -3902,11 +4695,11 @@ var MCP_TOOL_DEFS = [
3902
4695
  title: "Apply a configuration change",
3903
4696
  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.",
3904
4697
  operations: [],
3905
- input: z20.object({
4698
+ input: z24.object({
3906
4699
  operation_id: operationIdArg,
3907
4700
  params,
3908
- idempotency_key: z20.string().min(8).max(255).describe("Unique per change; reuse it to retry or to fetch the result."),
3909
- if_match: z20.string().max(200).optional().describe("ETag from plan_change, for operations that need it.")
4701
+ idempotency_key: z24.string().min(8).max(255).describe("Unique per change; reuse it to retry or to fetch the result."),
4702
+ if_match: z24.string().max(200).optional().describe("ETag from plan_change, for operations that need it.")
3910
4703
  }),
3911
4704
  async run(args, rt) {
3912
4705
  const op = configureOp(args["operation_id"]);
@@ -3957,7 +4750,7 @@ var MCP_TOOL_DEFS = [
3957
4750
  title: "Follow an approval",
3958
4751
  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).",
3959
4752
  operations: ["approvals.get"],
3960
- input: z20.object({ approval_id: z20.guid().describe("approval_id from apply_change.") }),
4753
+ input: z24.object({ approval_id: z24.guid().describe("approval_id from apply_change.") }),
3961
4754
  async run(args, rt) {
3962
4755
  const r = await rt.call("approvals.get", { approval_id: args["approval_id"] });
3963
4756
  if (!r.ok)
@@ -3977,10 +4770,10 @@ var MCP_TOOL_DEFS = [
3977
4770
  title: "Search Belvador docs",
3978
4771
  description: "Searches the public Belvador documentation (titles and summaries) and returns the best pages with their slugs for get_doc.",
3979
4772
  operations: [],
3980
- input: z20.object({
3981
- query: z20.string().min(1).max(200),
3982
- locale: z20.enum(["en", "vi"]).default("en"),
3983
- limit: z20.number().int().min(1).max(10).default(5)
4773
+ input: z24.object({
4774
+ query: z24.string().min(1).max(200),
4775
+ locale: z24.enum(["en", "vi"]).default("en"),
4776
+ limit: z24.number().int().min(1).max(10).default(5)
3984
4777
  }),
3985
4778
  async run(args, rt) {
3986
4779
  const locale = args["locale"] ?? "en";
@@ -3996,9 +4789,9 @@ var MCP_TOOL_DEFS = [
3996
4789
  title: "Read a docs page",
3997
4790
  description: "The Markdown of one public Belvador docs page by slug (e.g. `quickstart`, `sdk/react`, `reference/api`).",
3998
4791
  operations: [],
3999
- input: z20.object({
4000
- slug: z20.string().regex(/^[a-z0-9][a-z0-9/-]{0,120}$/),
4001
- locale: z20.enum(["en", "vi"]).default("en")
4792
+ input: z24.object({
4793
+ slug: z24.string().regex(/^[a-z0-9][a-z0-9/-]{0,120}$/),
4794
+ locale: z24.enum(["en", "vi"]).default("en")
4002
4795
  }),
4003
4796
  async run(args, rt) {
4004
4797
  const locale = args["locale"] ?? "en";
@@ -4180,7 +4973,7 @@ function findToken(env = process.env, keychain = keychainToken) {
4180
4973
  }
4181
4974
 
4182
4975
  // packages/mcp/src/cli.ts
4183
- var PACKAGE_VERSION = "0.2.0";
4976
+ var PACKAGE_VERSION = "0.3.0";
4184
4977
  var HELP = `belvador-mcp ${PACKAGE_VERSION} — Belvador MCP server (stdio)
4185
4978
 
4186
4979
  Usage: npx -y @belvador/mcp [--toolsets=${MCP_DEFAULT_TOOLSETS.join(",")}]