watchfor 0.1.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -46,10 +46,11 @@ npx watchfor summary
46
46
  npx watchfor incidents --status firing
47
47
  npx watchfor monitors example.com
48
48
  npx watchfor checks <monitor-id> --failed
49
+ npx watchfor report --period 30d
49
50
  ```
50
51
 
51
52
  ## Links
52
53
 
53
54
  - API docs: https://watchfor.io/docs/api
54
- - MCP server for AI agents (37 tools): https://watchfor.io/docs/api/mcp
55
+ - MCP server for AI agents (40 tools): https://watchfor.io/docs/api/mcp
55
56
  - Create an API key: dashboard → Settings → API keys (`read` or `read+write` scope)
package/dist/cli.js CHANGED
@@ -17,6 +17,7 @@ Usage:
17
17
  watchfor monitors [query] List monitors (optional name/target search)
18
18
  watchfor checks <monitor-id> [--failed]
19
19
  Recent probe results for one monitor
20
+ watchfor report [--period 7d|30d] Org report vs the previous period
20
21
  watchfor help
21
22
 
22
23
  Environment:
@@ -49,10 +50,25 @@ async function main() {
49
50
  const s = await wf.summary();
50
51
  const m = s.monitors;
51
52
  const i = s.incidents;
52
- console.log(`monitors: ${m.total} total · ${m.up} up · ${m.down} down · ${m.paused} paused · health ${m.health_score}%`);
53
+ console.log(`monitors: ${m.total} total · ${m.up} up · ${m.degraded ?? 0} degraded · ${m.down} down · ${m.paused} paused · health ${m.health_score}%`);
53
54
  console.log(`incidents: ${i.firing} firing (${i.firing_critical} critical) · ${i.acknowledged} acknowledged · ${i.started_24h} started in 24h`);
54
55
  return 0;
55
56
  }
57
+ case "report": {
58
+ const idx = args.indexOf("--period");
59
+ const period = idx !== -1 && (args[idx + 1] === "30d" || args[idx + 1] === "7d")
60
+ ? args[idx + 1]
61
+ : "7d";
62
+ const r = (await wf.report({ period }));
63
+ const sm = r.summary ?? {};
64
+ const up = sm.uptimePct?.current;
65
+ const inc = sm.incidents?.current;
66
+ console.log(`report ${r.meta?.period?.label ?? period}: uptime ${up !== undefined ? `${up.toFixed(2)}%` : "n/a"} · ${inc ?? 0} incidents`);
67
+ for (const insight of r.insights ?? []) {
68
+ console.log(` [${insight.tone}] ${insight.text}`);
69
+ }
70
+ return 0;
71
+ }
56
72
  case "incidents": {
57
73
  const status = flag(args, "status");
58
74
  const res = await wf.incidents.list({ status, limit: 25 });
package/dist/client.d.ts CHANGED
@@ -55,6 +55,29 @@ export declare class WatchFor {
55
55
  plan(): Promise<Plan>;
56
56
  /** Aggregate incident stats: MTTR, MTBF, most unstable monitors. */
57
57
  incidentStats(period?: "24h" | "7d" | "30d" | "90d"): Promise<IncidentStats>;
58
+ /**
59
+ * Org report for a period vs the previous one: uptime, incidents,
60
+ * MTTR/MTBF, response-time trend, per-monitor rows, type-aware
61
+ * sections and plain-language insights. Custom from/to (ISO 8601)
62
+ * needs the advanced-reports plan capability.
63
+ */
64
+ report(opts?: {
65
+ period?: "7d" | "30d";
66
+ } | {
67
+ from: string | Date;
68
+ to: string | Date;
69
+ }): Promise<Record<string, unknown>>;
70
+ /** The org's two report-email cadences (weekly + monthly). */
71
+ reportSchedules(): Promise<List<Record<string, unknown>>>;
72
+ /**
73
+ * Toggle the weekly/monthly report email and/or replace its
74
+ * recipients (max 5). Enabling needs at least one recipient;
75
+ * clearing the recipients disables the cadence.
76
+ */
77
+ setReportSchedule(frequency: "weekly" | "monthly", body: {
78
+ enabled?: boolean;
79
+ recipients?: string[];
80
+ }): Promise<Record<string, unknown>>;
58
81
  /** Probe locations for monitor creation. */
59
82
  locations(): Promise<List<Record<string, unknown>>>;
60
83
  /** All 25 monitor types with exact alert metrics + config fields. */
@@ -63,7 +86,7 @@ export declare class WatchFor {
63
86
  list: (q?: {
64
87
  q?: string;
65
88
  type?: string;
66
- status?: "up" | "down" | "paused" | "unknown";
89
+ status?: "up" | "degraded" | "down" | "paused" | "unknown";
67
90
  tag?: string;
68
91
  limit?: number;
69
92
  cursor?: string;
package/dist/client.js CHANGED
@@ -74,6 +74,36 @@ export class WatchFor {
74
74
  incidentStats(period) {
75
75
  return this.request("GET", "/incidents/stats", { query: { period } });
76
76
  }
77
+ /**
78
+ * Org report for a period vs the previous one: uptime, incidents,
79
+ * MTTR/MTBF, response-time trend, per-monitor rows, type-aware
80
+ * sections and plain-language insights. Custom from/to (ISO 8601)
81
+ * needs the advanced-reports plan capability.
82
+ */
83
+ report(opts) {
84
+ const query = {};
85
+ if (opts && "from" in opts) {
86
+ query.from =
87
+ opts.from instanceof Date ? opts.from.toISOString() : opts.from;
88
+ query.to = opts.to instanceof Date ? opts.to.toISOString() : opts.to;
89
+ }
90
+ else {
91
+ query.period = opts?.period;
92
+ }
93
+ return this.request("GET", "/reports", { query });
94
+ }
95
+ /** The org's two report-email cadences (weekly + monthly). */
96
+ reportSchedules() {
97
+ return this.request("GET", "/reports/schedules");
98
+ }
99
+ /**
100
+ * Toggle the weekly/monthly report email and/or replace its
101
+ * recipients (max 5). Enabling needs at least one recipient;
102
+ * clearing the recipients disables the cadence.
103
+ */
104
+ setReportSchedule(frequency, body) {
105
+ return this.request("PATCH", `/reports/schedules/${frequency}`, { body });
106
+ }
77
107
  /** Probe locations for monitor creation. */
78
108
  locations() {
79
109
  return this.request("GET", "/locations");