@slack/radar-mcp 1.20.0 → 1.21.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 (41) hide show
  1. package/README.md +11 -6
  2. package/dist/mcp/api-paths.d.ts +11 -0
  3. package/dist/mcp/api-paths.js +67 -16
  4. package/dist/mcp/index.js +24 -7
  5. package/dist/mcp/network-detail.d.ts +5 -0
  6. package/dist/mcp/network-detail.js +86 -0
  7. package/dist/mcp/radar-response.d.ts +7 -0
  8. package/dist/mcp/radar-response.js +15 -0
  9. package/dist/mcp/session-backfill.d.ts +9 -3
  10. package/dist/mcp/session-backfill.js +77 -17
  11. package/dist/mcp/session-detail.js +54 -2
  12. package/dist/mcp/session-query.js +53 -11
  13. package/dist/mcp/sources-gate.js +4 -0
  14. package/dist/mcp/switchboard-tools.d.ts +9 -0
  15. package/dist/mcp/switchboard-tools.js +40 -0
  16. package/dist/mcp/tools.js +62 -16
  17. package/dist/shared/constants.d.ts +10 -0
  18. package/dist/shared/constants.js +10 -0
  19. package/dist/shared/event-spool.js +3 -2
  20. package/dist/shared/form-body.d.ts +18 -0
  21. package/dist/shared/form-body.js +251 -0
  22. package/dist/shared/stream.d.ts +1 -1
  23. package/dist/shared/switchboard.d.ts +9 -0
  24. package/dist/shared/switchboard.js +54 -0
  25. package/dist/shared/wire.d.ts +32 -0
  26. package/dist/web/public/index.html +172 -10
  27. package/dist/web/public/next/app.js +16 -10
  28. package/dist/web/public/next/db.js +4 -1
  29. package/dist/web/public/next/feed.js +515 -57
  30. package/dist/web/public/next/filters.js +158 -40
  31. package/dist/web/public/next/form-body.js +252 -0
  32. package/dist/web/public/next/inspector.js +103 -12
  33. package/dist/web/public/next/registry.js +21 -2
  34. package/dist/web/public/next/store.js +503 -51
  35. package/dist/web/public/next/voice-model.js +532 -0
  36. package/dist/web/public/next/voice.js +397 -0
  37. package/dist/web/server.d.ts +7 -0
  38. package/dist/web/server.js +154 -16
  39. package/dist/web/spec.d.ts +10 -6
  40. package/dist/web/spec.js +61 -6
  41. package/package.json +3 -3
@@ -5,20 +5,21 @@
5
5
  * and the same validate/coerce pass runs on every push so a malformed spec surfaces
6
6
  * an error instead of rendering silent zeros.
7
7
  *
8
- * Most sources are live STREAMS (network/rtm/clog/trace/log/all). `db` and `prefs` are the
8
+ * Most sources are live STREAMS (network/rtm/clog/trace/log/switchboard/all). `db` and `prefs` are the
9
9
  * odd ones out: read-only, point-in-time BROWSERS (SQLite databases, SharedPreferences files)
10
10
  * with no viz / series / match (each has its own list -> detail view). The coerce and
11
11
  * validate passes short-circuit for both accordingly.
12
12
  */
13
13
  /**
14
- * Sources the dashboard can read. The first six are live streams; "all" is their unified
15
- * timeline. "db", "prefs", and "flags" are read-only point-in-time browsers (not streams) and
16
- * are each handled as a distinct view.
14
+ * Sources the dashboard can read. The first five plus "switchboard" are live streams; "all" is
15
+ * their unified timeline. "db", "prefs", and "flags" are read-only point-in-time browsers (not
16
+ * streams) and are each handled as a distinct view. "switchboard" is the Slackbot voice transport's
17
+ * own event stream (session / state / frame / phase / player records), device-produced like rtm.
17
18
  */
18
- export declare const SOURCES: readonly ["rtm", "network", "clog", "trace", "log", "all", "db", "prefs", "flags"];
19
+ export declare const SOURCES: readonly ["rtm", "network", "clog", "trace", "log", "switchboard", "all", "db", "prefs", "flags"];
19
20
  export type Source = (typeof SOURCES)[number];
20
21
  /** Widgets a spec may compose. */
21
- export declare const VIZ: readonly ["counter", "rate", "sparkline", "feed", "inspector", "graph"];
22
+ export declare const VIZ: readonly ["counter", "rate", "sparkline", "feed", "inspector", "graph", "voice"];
22
23
  export type Viz = (typeof VIZ)[number];
23
24
  /** Metrics a graph series can plot. */
24
25
  export declare const SERIES_METRICS: readonly ["ratePerSec", "count", "avg", "errorRate"];
@@ -26,6 +27,8 @@ export type SeriesMetric = (typeof SERIES_METRICS)[number];
26
27
  declare const HIGHLIGHT_OPS: readonly [">", ">=", "<", "<=", "=="];
27
28
  export declare const LOG_LEVELS: readonly ["VERBOSE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL"];
28
29
  export type LogLevel = (typeof LOG_LEVELS)[number];
30
+ export declare const EXCLUDE_MAX_TERMS = 20;
31
+ export declare const EXCLUDE_MAX_TERM_LENGTH = 200;
29
32
  export type HighlightOp = (typeof HIGHLIGHT_OPS)[number];
30
33
  export interface GraphSeries {
31
34
  label?: string;
@@ -64,6 +67,7 @@ export interface Spec {
64
67
  match?: Record<string, string>;
65
68
  bodyContains?: string;
66
69
  minLevel?: LogLevel;
70
+ exclude?: string[];
67
71
  viz?: Viz[];
68
72
  rateWindowSec?: number;
69
73
  series?: GraphSeries[];
package/dist/web/spec.js CHANGED
@@ -5,17 +5,18 @@
5
5
  * and the same validate/coerce pass runs on every push so a malformed spec surfaces
6
6
  * an error instead of rendering silent zeros.
7
7
  *
8
- * Most sources are live STREAMS (network/rtm/clog/trace/log/all). `db` and `prefs` are the
8
+ * Most sources are live STREAMS (network/rtm/clog/trace/log/switchboard/all). `db` and `prefs` are the
9
9
  * odd ones out: read-only, point-in-time BROWSERS (SQLite databases, SharedPreferences files)
10
10
  * with no viz / series / match (each has its own list -> detail view). The coerce and
11
11
  * validate passes short-circuit for both accordingly.
12
12
  */
13
13
  /**
14
- * Sources the dashboard can read. The first six are live streams; "all" is their unified
15
- * timeline. "db", "prefs", and "flags" are read-only point-in-time browsers (not streams) and
16
- * are each handled as a distinct view.
14
+ * Sources the dashboard can read. The first five plus "switchboard" are live streams; "all" is
15
+ * their unified timeline. "db", "prefs", and "flags" are read-only point-in-time browsers (not
16
+ * streams) and are each handled as a distinct view. "switchboard" is the Slackbot voice transport's
17
+ * own event stream (session / state / frame / phase / player records), device-produced like rtm.
17
18
  */
18
- export const SOURCES = ["rtm", "network", "clog", "trace", "log", "all", "db", "prefs", "flags"];
19
+ export const SOURCES = ["rtm", "network", "clog", "trace", "log", "switchboard", "all", "db", "prefs", "flags"];
19
20
  /** Widgets a spec may compose. */
20
21
  export const VIZ = [
21
22
  "counter",
@@ -24,6 +25,8 @@ export const VIZ = [
24
25
  "feed",
25
26
  "inspector",
26
27
  "graph",
28
+ // The Switchboard tab's voice panel (session strip, tracks, stat cards). Only that source draws it.
29
+ "voice",
27
30
  ];
28
31
  /** Metrics a graph series can plot. */
29
32
  export const SERIES_METRICS = [
@@ -36,6 +39,11 @@ const HIGHLIGHT_OPS = [">", ">=", "<", "<=", "=="];
36
39
  // Logcat priorities, lowest first. `minLevel` on a log-carrying spec keeps rows at that priority
37
40
  // or above, and this order is what "or above" means.
38
41
  export const LOG_LEVELS = ["VERBOSE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL"];
42
+ // Caps on `exclude`: enough for a preset's noise list, small enough that a runaway agent cannot
43
+ // push a spec that costs a substring scan per term per row. The browser build cannot import this
44
+ // file, so src/web/public/next/registry.ts carries a mirror; the two are pinned equal in a test.
45
+ export const EXCLUDE_MAX_TERMS = 20;
46
+ export const EXCLUDE_MAX_TERM_LENGTH = 200;
39
47
  /** The empty dashboard. Rendered until a spec is pushed. */
40
48
  export const BLANK_SPEC = { title: "", blank: true, viz: [] };
41
49
  function isRecord(v) {
@@ -66,6 +74,21 @@ export function coerceSpec(input) {
66
74
  else
67
75
  s.minLevel = up;
68
76
  }
77
+ // Whitespace is not a term. Trim each, drop the empties, and drop the field once nothing is
78
+ // left, so "no exclusions" has one spelling on the wire (no field), the way VERBOSE does above.
79
+ // Matching is case-insensitive, so "Meter" and "meter" are one term: keep the first spelling.
80
+ // Only well-formed arrays of strings are repaired; anything else is left for the validator.
81
+ if (Array.isArray(s.exclude) && s.exclude.every((t) => typeof t === "string")) {
82
+ const seen = new Set();
83
+ s.exclude = s.exclude.map((t) => t.trim()).filter((t) => {
84
+ if (t.length === 0 || seen.has(t.toLowerCase()))
85
+ return false;
86
+ seen.add(t.toLowerCase());
87
+ return true;
88
+ });
89
+ if (s.exclude.length === 0)
90
+ delete s.exclude;
91
+ }
69
92
  // The DB, Prefs, and feature-flags browsers have no match/viz/series to repair; leave as-is.
70
93
  if (s.source === "db" || s.source === "prefs" || s.source === "flags")
71
94
  return s;
@@ -83,10 +106,21 @@ export function coerceSpec(input) {
83
106
  ? "event_name"
84
107
  : s.source === "trace"
85
108
  ? "trace_name"
86
- : "url";
109
+ : s.source === "switchboard"
110
+ ? "kind"
111
+ : "url";
87
112
  s.match = { [field]: s.match };
88
113
  }
89
114
  }
115
+ // The voice panel only draws for the switchboard source: a voice key riding in on any other
116
+ // source's viz array can never draw anything, so drop it rather than store a spec that looks
117
+ // like it asked for a panel it will never get. Falling back when that was the only key left
118
+ // matches the validator's non-empty-viz rule, rather than storing a spec doomed to fail it.
119
+ if (Array.isArray(s.viz) && s.viz.includes("voice") && s.source !== "switchboard") {
120
+ s.viz = s.viz.filter((v) => v !== "voice");
121
+ if (s.viz.length === 0)
122
+ s.viz = ["feed", "inspector"];
123
+ }
90
124
  // graph series repair: fill if missing/empty, trim to the validator's 1-2 cap,
91
125
  // and drop entries with an unusable metric so the dashboard never hard-rejects.
92
126
  if (Array.isArray(s.viz) && s.viz.includes("graph")) {
@@ -128,6 +162,27 @@ export function validateSpec(s) {
128
162
  return "minLevel applies to the log and all sources only";
129
163
  }
130
164
  }
165
+ // Likewise ahead of the per-source returns: the browsers have no rows with searchable text, so
166
+ // an exclusion there would be stored and never act.
167
+ if (spec.exclude !== undefined) {
168
+ if (!Array.isArray(spec.exclude))
169
+ return "exclude must be an array of strings";
170
+ if (spec.source === "db" || spec.source === "prefs" || spec.source === "flags") {
171
+ return "exclude applies to stream sources only (log, all, network, rtm, clog, trace, switchboard)";
172
+ }
173
+ if (spec.exclude.length > EXCLUDE_MAX_TERMS)
174
+ return `exclude takes at most ${EXCLUDE_MAX_TERMS} terms`;
175
+ for (const t of spec.exclude) {
176
+ if (typeof t !== "string" || t.trim().length === 0)
177
+ return "exclude terms must be non-empty strings";
178
+ if (t.length > EXCLUDE_MAX_TERM_LENGTH)
179
+ return `exclude terms must be at most ${EXCLUDE_MAX_TERM_LENGTH} characters`;
180
+ // The Filters panel splits its input on commas and line breaks, so a term holding one would
181
+ // come back as two on the first edit there; refused here so no entry point can store it.
182
+ if (/[,\n]/.test(t))
183
+ return "exclude terms must not contain a comma or a line break";
184
+ }
185
+ }
131
186
  // The DB browser is a distinct view: no viz/series/match. Only its optional deep-link
132
187
  // fields are constrained (each must be a string when present).
133
188
  if (spec.source === "db") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slack/radar-mcp",
3
- "version": "1.20.0",
3
+ "version": "1.21.0",
4
4
  "description": "MCP server and web dashboard for debugging Slack on Android and iOS Simulator",
5
5
  "type": "module",
6
6
  "main": "dist/mcp/index.js",
@@ -15,9 +15,9 @@
15
15
  ],
16
16
  "scripts": {
17
17
  "clean": "rm -rf dist",
18
- "prebuild": "npm run clean",
18
+ "prebuild": "npm run clean && node scripts/mirror-shared.mjs",
19
19
  "copy-vendor": "node scripts/copy-vendor.mjs",
20
- "build:web": "tsc -p tsconfig.web.json",
20
+ "build:web": "node scripts/mirror-shared.mjs && tsc -p tsconfig.web.json",
21
21
  "build": "tsc && npm run build:web && node scripts/copy-public.mjs && npm run copy-vendor && chmod +x dist/mcp/index.js dist/web/bin.js",
22
22
  "start": "node dist/mcp/index.js",
23
23
  "start:web": "node dist/web/bin.js",