@slack/radar-mcp 1.19.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 (44) hide show
  1. package/README.md +48 -8
  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 +69 -18
  17. package/dist/shared/constants.d.ts +14 -3
  18. package/dist/shared/constants.js +14 -3
  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/install-app.d.ts +64 -1
  27. package/dist/web/install-app.js +174 -24
  28. package/dist/web/macapp/RadarApp.swift +1287 -71
  29. package/dist/web/public/index.html +216 -11
  30. package/dist/web/public/next/app.js +22 -12
  31. package/dist/web/public/next/db.js +180 -18
  32. package/dist/web/public/next/feed.js +571 -53
  33. package/dist/web/public/next/filters.js +160 -34
  34. package/dist/web/public/next/form-body.js +252 -0
  35. package/dist/web/public/next/inspector.js +103 -12
  36. package/dist/web/public/next/registry.js +33 -3
  37. package/dist/web/public/next/store.js +577 -53
  38. package/dist/web/public/next/voice-model.js +532 -0
  39. package/dist/web/public/next/voice.js +397 -0
  40. package/dist/web/server.d.ts +110 -6
  41. package/dist/web/server.js +436 -40
  42. package/dist/web/spec.d.ts +13 -6
  43. package/dist/web/spec.js +89 -6
  44. package/package.json +3 -3
@@ -5,25 +5,30 @@
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"];
25
26
  export type SeriesMetric = (typeof SERIES_METRICS)[number];
26
27
  declare const HIGHLIGHT_OPS: readonly [">", ">=", "<", "<=", "=="];
28
+ export declare const LOG_LEVELS: readonly ["VERBOSE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL"];
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;
27
32
  export type HighlightOp = (typeof HIGHLIGHT_OPS)[number];
28
33
  export interface GraphSeries {
29
34
  label?: string;
@@ -61,6 +66,8 @@ export interface Spec {
61
66
  source?: Source;
62
67
  match?: Record<string, string>;
63
68
  bodyContains?: string;
69
+ minLevel?: LogLevel;
70
+ exclude?: string[];
64
71
  viz?: Viz[];
65
72
  rateWindowSec?: number;
66
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 = [
@@ -33,6 +36,14 @@ export const SERIES_METRICS = [
33
36
  "errorRate",
34
37
  ];
35
38
  const HIGHLIGHT_OPS = [">", ">=", "<", "<=", "=="];
39
+ // Logcat priorities, lowest first. `minLevel` on a log-carrying spec keeps rows at that priority
40
+ // or above, and this order is what "or above" means.
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;
36
47
  /** The empty dashboard. Rendered until a spec is pushed. */
37
48
  export const BLANK_SPEC = { title: "", blank: true, viz: [] };
38
49
  function isRecord(v) {
@@ -50,6 +61,34 @@ export function coerceSpec(input) {
50
61
  if (!isRecord(input))
51
62
  return BLANK_SPEC;
52
63
  const s = input;
64
+ // Ahead of the browser-source return below, so a lowercase level on those sources is refused
65
+ // for the reason that applies (the source), not for its spelling. VERBOSE is the floor, and the
66
+ // floor is spelled as no field: with the field present it would hide a log row whose priority
67
+ // levelRank cannot place, and the page would show a "level ≥ VERBOSE" chip for what the UI treats
68
+ // as no filter. The UI never sends it (changeLevel drops the field), but the MCP enum offers it,
69
+ // and both wire entry points (/setspec and the SLACK_RADAR_INITIAL_SPEC seed) come through here.
70
+ if (typeof s.minLevel === "string") {
71
+ const up = s.minLevel.toUpperCase();
72
+ if (up === LOG_LEVELS[0])
73
+ delete s.minLevel;
74
+ else
75
+ s.minLevel = up;
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
+ }
53
92
  // The DB, Prefs, and feature-flags browsers have no match/viz/series to repair; leave as-is.
54
93
  if (s.source === "db" || s.source === "prefs" || s.source === "flags")
55
94
  return s;
@@ -67,10 +106,21 @@ export function coerceSpec(input) {
67
106
  ? "event_name"
68
107
  : s.source === "trace"
69
108
  ? "trace_name"
70
- : "url";
109
+ : s.source === "switchboard"
110
+ ? "kind"
111
+ : "url";
71
112
  s.match = { [field]: s.match };
72
113
  }
73
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
+ }
74
124
  // graph series repair: fill if missing/empty, trim to the validator's 1-2 cap,
75
125
  // and drop entries with an unusable metric so the dashboard never hard-rejects.
76
126
  if (Array.isArray(s.viz) && s.viz.includes("graph")) {
@@ -100,6 +150,39 @@ export function validateSpec(s) {
100
150
  if (!spec.source || !SOURCES.includes(spec.source)) {
101
151
  return `source must be one of ${SOURCES.join("|")}`;
102
152
  }
153
+ // Checked ahead of the per-source returns below so a browser source cannot carry the field
154
+ // through unexamined. Only log rows have a priority, so accepting it anywhere but log and all
155
+ // would store a filter that can never act, which reads as "the level is set" while changing
156
+ // nothing.
157
+ if (spec.minLevel !== undefined) {
158
+ if (!LOG_LEVELS.includes(spec.minLevel)) {
159
+ return `minLevel must be one of ${LOG_LEVELS.join("|")}`;
160
+ }
161
+ if (spec.source !== "log" && spec.source !== "all") {
162
+ return "minLevel applies to the log and all sources only";
163
+ }
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
+ }
103
186
  // The DB browser is a distinct view: no viz/series/match. Only its optional deep-link
104
187
  // fields are constrained (each must be a string when present).
105
188
  if (spec.source === "db") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slack/radar-mcp",
3
- "version": "1.19.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",