@slack/radar-mcp 1.21.0 → 1.23.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 (87) hide show
  1. package/README.md +114 -18
  2. package/dist/mcp/api-paths.d.ts +2 -2
  3. package/dist/mcp/api-paths.js +4 -19
  4. package/dist/mcp/dashboard-identity.d.ts +6 -0
  5. package/dist/mcp/dashboard-identity.js +11 -0
  6. package/dist/mcp/index.js +210 -145
  7. package/dist/mcp/logs-result.d.ts +1 -0
  8. package/dist/mcp/logs-result.js +1 -0
  9. package/dist/mcp/radar-export-get.d.ts +30 -0
  10. package/dist/mcp/radar-export-get.js +49 -0
  11. package/dist/mcp/radar-http.d.ts +22 -0
  12. package/dist/mcp/radar-http.js +61 -0
  13. package/dist/mcp/radar-response.d.ts +5 -1
  14. package/dist/mcp/radar-response.js +8 -3
  15. package/dist/mcp/session-backfill.js +3 -4
  16. package/dist/mcp/session-enable.d.ts +15 -0
  17. package/dist/mcp/session-enable.js +268 -19
  18. package/dist/mcp/snapshot.js +42 -26
  19. package/dist/mcp/sources-gate.js +6 -0
  20. package/dist/mcp/stale-dashboard.d.ts +23 -0
  21. package/dist/mcp/stale-dashboard.js +122 -0
  22. package/dist/mcp/switchboard-spool.d.ts +12 -0
  23. package/dist/mcp/switchboard-spool.js +107 -0
  24. package/dist/mcp/switchboard-tools.d.ts +9 -0
  25. package/dist/mcp/switchboard-tools.js +144 -6
  26. package/dist/mcp/test-cases.d.ts +14 -0
  27. package/dist/mcp/test-cases.js +77 -0
  28. package/dist/mcp/test-runs-tools.d.ts +8 -0
  29. package/dist/mcp/test-runs-tools.js +95 -0
  30. package/dist/mcp/tools.d.ts +4 -1
  31. package/dist/mcp/tools.js +101 -21
  32. package/dist/mcp/web-child-env.d.ts +4 -1
  33. package/dist/mcp/web-child-env.js +4 -1
  34. package/dist/shared/android.d.ts +44 -0
  35. package/dist/shared/android.js +234 -24
  36. package/dist/shared/constants.d.ts +9 -4
  37. package/dist/shared/constants.js +9 -4
  38. package/dist/shared/feature-flags.d.ts +1 -0
  39. package/dist/shared/feature-flags.js +1 -0
  40. package/dist/shared/ios-logs.d.ts +10 -0
  41. package/dist/shared/ios-logs.js +91 -0
  42. package/dist/shared/ios.d.ts +25 -2
  43. package/dist/shared/ios.js +157 -3
  44. package/dist/{web → shared}/log-session.d.ts +45 -31
  45. package/dist/shared/log-session.js +300 -0
  46. package/dist/shared/logcat-capture.js +17 -1
  47. package/dist/shared/radar-request-raw.d.ts +7 -0
  48. package/dist/shared/radar-request-raw.js +89 -0
  49. package/dist/shared/radar-token.d.ts +25 -0
  50. package/dist/shared/radar-token.js +164 -0
  51. package/dist/shared/stream.d.ts +3 -0
  52. package/dist/shared/stream.js +107 -15
  53. package/dist/shared/switchboard-host-store.d.ts +21 -0
  54. package/dist/shared/switchboard-host-store.js +166 -0
  55. package/dist/shared/switchboard-note.d.ts +15 -0
  56. package/dist/shared/switchboard-note.js +92 -0
  57. package/dist/shared/switchboard-report-file.d.ts +5 -0
  58. package/dist/shared/switchboard-report-file.js +26 -0
  59. package/dist/shared/switchboard-report.d.ts +20 -0
  60. package/dist/shared/switchboard-report.js +406 -0
  61. package/dist/shared/switchboard.d.ts +111 -2
  62. package/dist/shared/switchboard.js +436 -3
  63. package/dist/shared/transport.d.ts +49 -3
  64. package/dist/shared/version.d.ts +2 -0
  65. package/dist/shared/version.js +18 -0
  66. package/dist/shared/wire.d.ts +14 -1
  67. package/dist/web/install-app.d.ts +75 -8
  68. package/dist/web/install-app.js +330 -67
  69. package/dist/web/macapp/RadarApp.swift +487 -23
  70. package/dist/web/public/index.html +51 -9
  71. package/dist/web/public/next/app.js +33 -18
  72. package/dist/web/public/next/feed.js +102 -15
  73. package/dist/web/public/next/flags.js +3 -0
  74. package/dist/web/public/next/inspector.js +69 -3
  75. package/dist/web/public/next/prefs.js +5 -2
  76. package/dist/web/public/next/registry.js +18 -5
  77. package/dist/web/public/next/store.js +455 -29
  78. package/dist/web/public/next/switchboard-note.js +93 -0
  79. package/dist/web/public/next/toast.js +9 -5
  80. package/dist/web/public/next/voice-model.js +215 -35
  81. package/dist/web/public/next/voice.js +173 -18
  82. package/dist/web/server.d.ts +15 -11
  83. package/dist/web/server.js +690 -168
  84. package/dist/web/spec.d.ts +2 -1
  85. package/dist/web/spec.js +2 -1
  86. package/package.json +2 -2
  87. package/dist/web/log-session.js +0 -166
@@ -0,0 +1,95 @@
1
+ import { randomUUID } from "crypto";
2
+ import { buildRunBody, CASE_NAME, loadCase, testCaseDir } from "./test-cases.js";
3
+ const TEST_RUNS_PATH = "/api/test_runs";
4
+ const POST_TIMEOUT_MS = 15_000;
5
+ const POST_DEADLINE_MS = 50_000;
6
+ const POLL_TIMEOUT_MS = 3_000;
7
+ const POLL_GAP_MS = 1_000;
8
+ const WAIT_CAP_S = 45;
9
+ const MAX_BODY_BYTES = 256 * 1024;
10
+ const runPath = (id) => `${TEST_RUNS_PATH}/${id}`;
11
+ const isRequestFailure = (data) => (data.http_status ?? 0) >= 400 || Boolean(data.error) && !("state" in data);
12
+ // the flag steers the read-back only; the model never sees it
13
+ const result = ({ request_lost, ...data }) => ({ data, isError: isRequestFailure(data) });
14
+ const trimTail = (message) => message.replace(/\. Call again\.$/, "").replace(/\.$/, "");
15
+ const FRAME_CHECK_ERROR = "the device refused the run while checking its frames. Call run_test_case again to see the reason";
16
+ const RUN_ID_ERROR = "run_id must match [A-Za-z0-9_-]{1,64}";
17
+ const isRunId = (id) => typeof id === "string" && CASE_NAME.test(id);
18
+ const notFound = (data, id) => data.http_status === 404
19
+ ? { ...data, error: `run ${id} not found. The device keeps the last ten runs, or clear_buffers dropped it; call get_test_run with no run_id to list them` } : data;
20
+ async function readBack(runId, post, call, now) {
21
+ const found = await call(runPath(runId), { timeoutMs: POLL_TIMEOUT_MS, deadlineMs: now() + POLL_TIMEOUT_MS, reportLost: true });
22
+ if ("state" in found)
23
+ return found.state === "starting" ? { ...found, note: "the device is still checking the frames; if a later read answers 404 they were refused, call run_test_case again to see the reason" } : found;
24
+ if (found.http_status === 404)
25
+ return post.http_status === 409
26
+ ? { error: FRAME_CHECK_ERROR, http_status: 404 }
27
+ : { error: `the device holds no run ${runId}: ${trimTail(String(post.error))}. Call run_test_case again`, run_id: runId };
28
+ return { error: `run ${runId} may have started: the device did not answer the start or the read-back (${trimTail(String(found.error))}). Call get_test_run(run_id) before starting another run; a 404 there most likely means it never started, so call run_test_case again`, run_id: runId };
29
+ }
30
+ export async function handleRunTestCase(args, call, dir = testCaseDir(), newRunId = randomUUID, now = Date.now) {
31
+ if (typeof args.case !== "string" || !args.case)
32
+ return result({ error: "case is required: a built-in name (message_changed, message_replied) or a file stem under ~/.slack-radar/test-cases" });
33
+ const deadline = now() + POST_DEADLINE_MS;
34
+ const caseDef = loadCase(args.case, dir);
35
+ if ("error" in caseDef)
36
+ return result(caseDef);
37
+ const runId = newRunId();
38
+ if (!isRunId(runId))
39
+ return result({ error: RUN_ID_ERROR });
40
+ const overrides = {
41
+ ...(typeof args.repeat === "number" ? { repeat: args.repeat } : {}),
42
+ ...("rate_per_second" in args ? { rate_per_second: args.rate_per_second } : {}),
43
+ };
44
+ const body = buildRunBody(caseDef, overrides, runId);
45
+ if (Buffer.byteLength(body) > MAX_BODY_BYTES)
46
+ return result({ error: `the request body is ${Math.ceil(Buffer.byteLength(body) / 1024)} KB, the device takes at most 256 KB. Lower repeat does not help, shrink or split the events` });
47
+ let data = await call(TEST_RUNS_PATH, { method: "POST", body, timeoutMs: POST_TIMEOUT_MS, deadlineMs: deadline, reportLost: true });
48
+ const lost = data.request_lost === true;
49
+ // builds without listed_run_id still answer with the text alone
50
+ const listed = data.http_status === 409 && (data.listed_run_id !== undefined ? data.listed_run_id === runId : data.error === `run_id ${runId} is already listed`);
51
+ if (lost || listed)
52
+ data = await readBack(runId, data, call, now);
53
+ return result(isRequestFailure(data) ? { ...data, run_id: runId } : data);
54
+ }
55
+ export async function handleGetTestRun(args, call, sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)), now = Date.now) {
56
+ const wait = Math.min(WAIT_CAP_S, Math.max(0, typeof args.wait_seconds === "number" ? args.wait_seconds : 0));
57
+ if (args.run_id === undefined) {
58
+ if (wait > 0)
59
+ return result({ error: "wait_seconds needs run_id" });
60
+ return result(await call(TEST_RUNS_PATH));
61
+ }
62
+ if (!isRunId(args.run_id))
63
+ return result({ error: RUN_ID_ERROR });
64
+ const id = args.run_id;
65
+ if (!wait)
66
+ return result(notFound(await call(runPath(id)), id));
67
+ const start = now();
68
+ const deadline = start + wait * 1000;
69
+ let data;
70
+ let lastState;
71
+ for (;;) {
72
+ data = notFound(await call(runPath(id), { timeoutMs: POLL_TIMEOUT_MS, deadlineMs: now() + POLL_TIMEOUT_MS, reportLost: true }), id);
73
+ if (isRequestFailure(data)) {
74
+ return result(data.http_status === 404 && lastState === "starting" ? { ...data, error: FRAME_CHECK_ERROR } : data);
75
+ }
76
+ lastState = data.state;
77
+ if (data.settled === true)
78
+ break;
79
+ if (now() + POLL_GAP_MS >= deadline)
80
+ break;
81
+ await sleep(POLL_GAP_MS);
82
+ if (now() >= deadline)
83
+ break;
84
+ }
85
+ const waited_ms = now() - start;
86
+ return result({ ...data, waited_ms, ...(data.settled === true ? {} : {
87
+ note: `not settled after ${waited_ms / 1000} s (state ${data.state}). Call get_test_run again${args.wait_seconds !== wait ? ". wait_seconds capped at 45 s" : ""}`,
88
+ }) });
89
+ }
90
+ export async function handleStopTestRun(args, call) {
91
+ if (!isRunId(args.run_id))
92
+ return result({ error: RUN_ID_ERROR });
93
+ const id = args.run_id;
94
+ return result(notFound(await call(runPath(id), { method: "DELETE" }), id));
95
+ }
@@ -28,8 +28,11 @@ export declare const TOOL_DEFINITIONS: ToolDefinition[];
28
28
  /**
29
29
  * Check whether a tool call should be blocked by the session gate.
30
30
  * Returns an error response object if blocked, or null if allowed.
31
+ *
32
+ * `allowSwitchboardExportOffline` lets export_switchboard_session through while disabled; the
33
+ * caller sets it only when a host-only report can be built without touching the device.
31
34
  */
32
- export declare function sessionGate(toolName: string, sessionEnabled: boolean): {
35
+ export declare function sessionGate(toolName: string, sessionEnabled: boolean, allowSwitchboardExportOffline?: boolean): {
33
36
  content: Array<{
34
37
  type: string;
35
38
  text: string;
package/dist/mcp/tools.js CHANGED
@@ -4,16 +4,20 @@ export const SERVER_INSTRUCTIONS = [
4
4
  "Slack Radar provides on-device debugging tools for the Slack Android app via ADB.",
5
5
  "",
6
6
  "SESSION STATE:",
7
- "Radar starts DISABLED each session. All tools except ping return an error until enabled.",
7
+ "Radar starts DISABLED each session. ping, list_profiles, and open_radar_dashboard work before enabling; other tools return an error until enabled.",
8
+ "export_switchboard_session also works after an auto-disable if this process streamed the call",
9
+ "live. It builds the report from the live stream copy, no device call needed.",
8
10
  "Use /radar-enable to activate, /radar-disable to deactivate.",
9
11
  "",
10
- "AUTO-ENABLE: When the user asks an obvious device question, invoke the Skill tool with",
11
- 'skill="radar-enable" FIRST, then proceed with the radar tool call. No need to ask.',
12
+ "AUTO-ENABLE: When the user asks an obvious device question, call the radar tool straight away.",
13
+ 'Invoke the Skill tool with skill="radar-enable" only when a tool says Radar is not active or',
14
+ "Session disabled, or when the user asks to connect.",
12
15
  "Obvious device questions include: clogs, network calls, RTM events, screenshots,",
13
16
  "app state, device logs, Slackbot voice sessions, or any reference to what is happening on the connected device.",
17
+ "Enable once without asking, then retry the tool. If the enable or the retry fails, tell the user and stop.",
14
18
  "",
15
19
  "TIMEOUT: The device-side radar auto-shuts down after idle. On tool call failure,",
16
- "the session flips to disabled. Tell the user and offer to re-enable.",
20
+ "the session flips to disabled and the tool says Radar is not active or Session disabled. The AUTO-ENABLE rule applies.",
17
21
  "",
18
22
  "When to use:",
19
23
  '- "what am I looking at" / "what screen is this" -> screenshot',
@@ -26,11 +30,14 @@ export const SERVER_INSTRUCTIONS = [
26
30
  '- "did I get X" / "did X happen" -> search(query="X") across ALL buffers, not just one',
27
31
  '- "everything since I enabled" / "the whole session" / "what did I miss" -> query_session',
28
32
  '- "what happened in the voice session" / "why did playback stutter" / "did the mic open" -> get_switchboard_sessions then get_switchboard_session(id, kind=...): player for stutter, state for mic and connection, phase for slow start',
33
+ '- "did the turns get saved" / "why is a turn missing from the DM" -> get_switchboard_session(id, kind=saved_turn): outcome is applied, no_line (no subtitle line still held the item, still kept), or why a turn was dropped; the summary\'s saved_turn_counts counts each outcome (absent on an older device build means not counted, not zero). A server resend counts again under applied or no_line, so their sum can run above the finals and is not a lost turn. Every turn other_session with a null server_session_id usually means session.ready named no session (a ready record with a null id) or never arrived (no ready record).',
34
+ '- "export this voice session" / "save the switchboard session" / "hand this voice session to someone else" -> export_switchboard_session(id=...)',
29
35
  '- "check the debug logs" -> get_recent_logs (tag is OPTIONAL: pass tag="SlackRadar" to filter, or omit it for all recent lines)',
30
36
  '- "is flag X on?" / "what is the effective value of X" / "what feature flags does the app have" -> get_feature_flag(key="X") / search_feature_flags(query="X") / list_feature_flags. This is the LIVE effective state (override if set, else server value), requires a debug build with the feature-flag Radar plugin.',
31
37
  '- "what feature-flag overrides are set?" / "check debug_features" -> search_prefs(query="X") or get_prefs(file="debug_features_...xml"). This shows MANUAL OVERRIDES only, not effective flag state: debug_features_*.xml holds only flags the debug menu overrode, and an override is deleted once it matches the server value. A flag missing from this file can still be ON server-side -- absence means "no override," never "disabled." Prefer get_feature_flag/list_feature_flags/search_feature_flags for the actual live value; use this route only when the manual-override history itself is what is being asked about.',
32
38
  '- "what did the app remember" / "what is cached in prefs" / "what team_prefs are set" -> list_prefs then get_prefs',
33
39
  '- "save this" / "file this as a bug" / "share this" / "bundle this" / "attach to ticket" / "give me a repro" / "snapshot this" / "preserve this" / "hold this state" / "save what you just saw" -> capture_snapshot',
40
+ '- "how does the app handle N events a second" / "replay RTM" / "stress the message handler" -> run_test_case(case, repeat, rate_per_second) then get_test_run(run_id, wait_seconds) until settled. A 409 with "ms left" means wait that long and retry, a 409 "active" names the run to wait for or stop',
34
41
  "",
35
42
  "Key behaviors:",
36
43
  "- Network/RTM buffers clear on shutdown. Clogs persist from app start.",
@@ -54,9 +61,10 @@ export const SERVER_INSTRUCTIONS = [
54
61
  "- Setup: /slack-radar-setup",
55
62
  "- Manual enable (no skill): adb shell am broadcast -a slack.debug.ENABLE_RADAR --ei timeout_minutes 5 -p com.Slack.internal.debug",
56
63
  " Then: adb forward tcp:8099 localabstract:slack-radar (prefix adb -s <serial> when multiple devices are attached)",
64
+ " This starts Radar in open mode (no radar_token extra, so the device accepts any caller). Use it only when /radar-enable cannot run; /radar-enable sends the token.",
57
65
  "",
58
66
  "WEB DASHBOARD (/radar-ui):",
59
- "A browser-based dashboard (http://localhost:8100) shows the same live device data as",
67
+ "A browser-based dashboard (http://localhost:8100, or the port set in SLACK_RADAR_WEB_PORT) shows the same live device data as",
60
68
  "tabs: Live (everything), Network, RTM, Clogs, Traces, Logs, and Switchboard, each with a",
61
69
  "filterable feed and a payload inspector, a live rate on most, a graph on Network and Traces,",
62
70
  "plus the Database/Preferences/Feature Flags browsers.",
@@ -109,8 +117,8 @@ export const SERVER_INSTRUCTIONS = [
109
117
  "- source is one of network/rtm/clog/trace/log/switchboard/all ('all' = one unified timeline).",
110
118
  "- match filters on SUMMARY fields only, by source: network=url/method/status_code,",
111
119
  " rtm=event_type/direction/channel, clog=event_name, trace=trace_name/span_name,",
112
- " log=tag/level/message/pid/package,",
113
- " switchboard=kind/session_id/direction/frame_type/state_kind/phase/event.",
120
+ " log=tag/level/message/pid/package (iOS also: subsystem/process),",
121
+ " switchboard=kind/session_id/direction/frame_type/state_kind/phase/event/clock/outcome.",
114
122
  " NEVER invent a field; a match on a field the stream does not carry silently matches",
115
123
  " nothing. To filter on body text use bodyContains (network/all only), which fetches detail.",
116
124
  "- viz composes counter/rate/sparkline/feed/inspector/graph/voice. graph needs a series array",
@@ -151,6 +159,24 @@ export const SERVER_INSTRUCTIONS = [
151
159
  export function serverInstructions(platform) {
152
160
  if (platform === "android")
153
161
  return SERVER_INSTRUCTIONS;
162
+ if (platform === "ios") {
163
+ return [
164
+ "PLATFORM: iOS Simulator (NOT Android over adb).",
165
+ "This overrides anything below that assumes Android:",
166
+ "- Radar selects a booted iOS Simulator and enables its app listener directly; ignore adb",
167
+ " broadcasts, Android profiles, package names, and work-profile switching advice.",
168
+ "- Available: ping, network calls, RTM events, clogs, traces, search, query_session,",
169
+ " wait_for_events, clear_buffers, feature flags, capture_snapshot, get_recent_logs,",
170
+ " screenshot, record_screen, and open_radar_dashboard.",
171
+ "- Not available: get_app_state, database tools, preferences tools, list_profiles, and",
172
+ " activate_for_user. Treat their supported-platform error as a capability gap.",
173
+ "- Unified-log capture begins when the Radar session is enabled; it cannot backfill logs",
174
+ " emitted before that point. Leave tag unset for all Slack-authored categories.",
175
+ "- Physical iOS devices are not supported yet.",
176
+ "",
177
+ SERVER_INSTRUCTIONS,
178
+ ].join("\n");
179
+ }
154
180
  if (platform === "webapp") {
155
181
  return [
156
182
  "PLATFORM: webapp (a local Slack webapp dev server, NOT an Android device over adb).",
@@ -179,7 +205,7 @@ export function serverInstructions(platform) {
179
205
  export const TOOL_DEFINITIONS = [
180
206
  {
181
207
  name: "ping",
182
- description: "Check if Slack Radar is running. Returns uptime, buffer sizes, remaining session time, stream status, the Radar MCP tool version (mcp_version), and which app/profile is bound: android_user_id (0 = personal, non-zero = a secondary user such as a work profile), profile ('personal'/'secondary'), and package.",
208
+ description: "Check if Slack Radar is running. Returns uptime, buffer sizes, remaining session time, stream status, the Radar MCP tool version (mcp_version), and which app/profile is bound: android_user_id (0 = personal, non-zero = a secondary user such as a work profile), profile ('personal'/'secondary'), and package. If the result has a warning field, show it to the user verbatim.",
183
209
  inputSchema: {
184
210
  type: "object",
185
211
  properties: {
@@ -320,25 +346,25 @@ export const TOOL_DEFINITIONS = [
320
346
  },
321
347
  {
322
348
  name: "get_switchboard_sessions",
323
- description: "List the Slackbot voice (switchboard) sessions the device still holds, at most 8, newest first. A session is one voice conversation attempt, from the controller starting (before any socket opens) to it ending. Each entry carries session_id, team_id, began_at, ended_at (null while live), total_captured (records held), frames {incoming, outgoing} counts, last_state (the newest connection/mic/speaking state, absent before the first state record) and levels (the newest audio level tick, or null). session_id restarts at 1 with the app process, so a small id can be the newest session; go by began_at. A session already running when radar was enabled lists from its first seen record, with team_id null. Follow with get_switchboard_session(id) for the records.",
349
+ description: "List the Slackbot voice (switchboard) sessions the device still holds, at most 8, newest first. A session is one voice conversation attempt, from the controller starting (before any socket opens) to it ending. Each entry carries session_id, team_id, began_at, ended_at (null live), total_captured, frames {incoming, outgoing}, last_state (newest connection/mic/speaking state, absent before the first state record), levels (newest level tick, or null), server_session_id (null until named), turns ({count, last_response_ms, last_clock}, null before the first timed turn) and saved_turn_counts (per outcome), all absent on an older build. last_response_ms can be a gap between reply chunks when last_clock is resumed_from_server_answer. session_id restarts at 1 with the app process; go by began_at. A session already running when radar was enabled lists from its first seen record, team_id null. get_switchboard_session(id) has the records.",
324
350
  inputSchema: { type: "object", properties: {} },
325
351
  annotations: { readOnlyHint: true },
326
352
  },
327
353
  {
328
354
  name: "get_switchboard_session",
329
- description: "Get one voice session's summary plus the newest `limit` of its records (events), oldest first; events is only the page. Record kinds: state = connection, mic and speaking transitions (state_kind, from, to, cause); frame = control frames in and out (direction, frame_type, bytes), audio frames carry frame_type audio and a byte count, never the audio; player = playback events rearm, jitter_trim, read_stall and pre_ready_drop with gap_ms and bytes_queued; phase = startup phase durations (phase, duration_ms); session = begin and end. Pass kind to narrow (player for stutter); the device filters by kind before taking the limit, so the page is the newest limit of that kind, while total_captured still counts every kind. No older page, raise limit instead. An unknown id is a device 404. The same records are in query_session under source switchboard.",
355
+ description: "Get one voice session's summary plus the newest `limit` of its records (events), oldest first; events is only the page. Record kinds: state = connection, mic and speaking transitions (state_kind, from, to, cause); frame = control frames in and out (direction, frame_type, bytes), audio frames carry frame_type audio and a byte count, never the audio; player = playback events rearm, jitter_trim, read_stall and pre_ready_drop with gap_ms and bytes_queued; phase = startup phase durations (phase, duration_ms); session = begin and end, plus ready (server_session_id); levels = one meter-tick batch (started_at, sample_count, offsets_ms, mic/playback rms+peak arrays, 0..1); turn = response_ms (end of speech to first reply audio) and clock (no_card, resumed_from_tap, resumed_from_server_answer); saved_turn = outcome (applied, no_line, missing_field, other_session), has_thread. Pass kind to narrow (player for stutter, levels for meter history); the device filters by kind before taking the limit, so the page is the newest limit of that kind, while total_captured still counts every kind. This is a single page, not the whole session; for that use export_switchboard_session or query_session under source switchboard. An unknown id is a device 404.",
330
356
  inputSchema: {
331
357
  type: "object",
332
358
  properties: {
333
359
  id: { type: "number", description: "The session_id from get_switchboard_sessions" },
334
360
  kind: {
335
361
  type: "string",
336
- enum: ["session", "state", "frame", "phase", "player"],
362
+ enum: ["session", "state", "frame", "phase", "player", "levels", "turn", "saved_turn"],
337
363
  description: "Only records of this kind (default: every kind)",
338
364
  },
339
365
  limit: {
340
366
  type: "number",
341
- description: "How many of the newest records to return (default: 50, max: 2000, the device's per-session ring)",
367
+ description: "How many of the newest records to return (default: 50, max: 2000 per request; the device may hold more than this single request returns; for the whole session use export_switchboard_session or query_session)",
342
368
  minimum: 1,
343
369
  maximum: 2000,
344
370
  },
@@ -347,6 +373,17 @@ export const TOOL_DEFINITIONS = [
347
373
  },
348
374
  annotations: { readOnlyHint: true },
349
375
  },
376
+ {
377
+ name: "export_switchboard_session",
378
+ description: "Write one Slackbot voice (switchboard) session's summary and its records to a plain-text file. Pages the device (up to 2000 per request, paged with before_id), then merges in this process's own live stream copy (read from its session event spool), so a call the device ring has since evicted can still show up if this MCP was connected while it happened. The export can stop early (for example an old device build that does not page, the 32 MB size cap, the page limit, or the device stopping answering), and the report notes say why anything is missing; the spool itself rotates at 100 MB across every event kind it captures, not just switchboard, so an unusually long or chatty session could in principle rotate away a call's own early records before the device ring would have evicted them. Writes it as a readable report (server_session_id, summary, then one line per record, oldest first) under ~/.slack-radar/exports/<file>, permissions 0700/0600 like capture_snapshot. Defaults to the newest session when id is omitted. Returns the file path, a short summary, and notes. An unknown id (404, unreachable, or a reply too large to read) errors unless this process streamed the call live, then the report comes from the live stream copy alone, whichever process ran the export, since this MCP server and the web dashboard each keep their own. Still works right after Radar auto-disables, from the live stream copy alone with no device call; an explicit /radar-disable or clear_buffers wipes that copy.",
379
+ inputSchema: {
380
+ type: "object",
381
+ properties: {
382
+ id: { type: "number", description: "The session_id from get_switchboard_sessions. Omit to export the newest session." },
383
+ },
384
+ },
385
+ annotations: { readOnlyHint: false },
386
+ },
350
387
  {
351
388
  name: "get_app_state",
352
389
  description: "Get the current app state from the device.",
@@ -355,11 +392,11 @@ export const TOOL_DEFINITIONS = [
355
392
  },
356
393
  {
357
394
  name: "get_recent_logs",
358
- description: "Get recent device logs for the Slack debug build. Reads the app's own log buffer first (the DEBUG-and-above Timber lines the in-app Log Viewer shows, this app only), and falls back to an adb logcat snapshot when that buffer cannot be read. The result includes a `source` field (app_buffer / logcat_capture / logcat_ring) so you can tell a real empty result from a fallback. Leave `tag` out to get all recent lines. For native crashes, VERBOSE lines, or non-Slack processes, use adb logcat directly.",
395
+ description: "Get recent device logs for the Slack debug build. Android reads the app's Timber buffer first and falls back to logcat. iOS returns only Slack-authored unified logs captured since the Radar session was enabled; it cannot backfill earlier lines, and if the capture died it returns what it retained with a `capture_error`. The result's `source` is one of `app_buffer`, `logcat_capture`, `logcat_ring`, or `ios_unified_capture`. Leave `tag` out to get all recent lines. On Android, for native crashes, VERBOSE lines, or non-Slack processes, use adb logcat directly.",
359
396
  inputSchema: {
360
397
  type: "object",
361
398
  properties: {
362
- tag: { type: "string", description: "Optional substring to filter log lines by (matched anywhere in the line, not an exact tag-column match). Omit to return all recent lines." },
399
+ tag: { type: "string", description: "Optional substring filter: Android matches anywhere in the line; iOS matches the category/tag field. Use grep to search message text. Omit to return all recent lines." },
363
400
  limit: { type: "number", description: "Max number of lines to return (default: 50, capped at 1000)" },
364
401
  grep: { type: "string", description: "Optional text to grep within the filtered output" },
365
402
  },
@@ -439,17 +476,17 @@ export const TOOL_DEFINITIONS = [
439
476
  },
440
477
  {
441
478
  name: "clear_buffers",
442
- description: "Clear all captured network calls and RTM events from both device and local buffers.",
479
+ description: "Clear all captured network calls, RTM events and settled test runs from both device and local buffers.",
443
480
  inputSchema: { type: "object", properties: {} },
444
481
  annotations: { destructiveHint: true },
445
482
  },
446
483
  {
447
484
  name: "_radar_session_enable",
448
- description: "Enable Slack Radar for this session. Sets up ADB forwarding, activates the device-side server, and connects the SSE stream. Called by /radar-enable skill.",
485
+ description: "Enable Slack Radar for this session. Sets up ADB forwarding, activates the device-side server, and connects the SSE stream. Called by /radar-enable skill. Safe to repeat: on an already enabled session it checks the device first and returns the current status with already_enabled: true. It runs the full setup again when that check fails or the last activation did not land, the device, token or profile changed, the timeout changes, or Radar is in open mode. For a clean reset run /radar-disable, then /radar-enable. If the result has a warning field, show it to the user verbatim.",
449
486
  inputSchema: {
450
487
  type: "object",
451
488
  properties: {
452
- timeout_minutes: { type: "number", description: "Device-side auto-shutdown timeout in minutes (default: 5)" },
489
+ timeout_minutes: { type: "number", description: "Device-side auto-shutdown timeout in minutes (default 5 on first enable, a repeat keeps the current window)" },
453
490
  device_serial: {
454
491
  type: "string",
455
492
  description: "Target device serial from adb devices. Optional; auto-selected when exactly one device is attached. When multiple devices are attached the enable fails with the list; retry with one of the listed serials.",
@@ -484,12 +521,13 @@ export const TOOL_DEFINITIONS = [
484
521
  source: {
485
522
  type: "string",
486
523
  enum: [...SOURCES],
487
- description: "Which device stream to read. 'all' is a unified timeline mixing network, RTM, clog, trace, log, and switchboard. 'switchboard' is the Slackbot voice transport's own records (kind: session|state|frame|phase|player).",
524
+ description: "Which device stream to read. 'all' is a unified timeline mixing network, RTM, clog, trace, log, and switchboard. 'switchboard' is the Slackbot voice transport's own records (kind: session|state|frame|phase|player|levels|turn|saved_turn).",
488
525
  },
489
526
  match: {
490
527
  type: "object",
491
528
  description: "Case-insensitive substring filter on SUMMARY fields, keyed by source. network: url/method/status_code; " +
492
- "rtm: event_type/direction/channel; clog: event_name; trace: trace_name/span_name; log: tag/level/package; switchboard: kind/session_id/direction/frame_type/state_kind/phase/event. NEVER invent a field " +
529
+ "rtm: event_type/direction/channel; clog: event_name; trace: trace_name/span_name; " +
530
+ "log: tag/level/message/pid/package (iOS also: subsystem/process); switchboard: kind/session_id/direction/frame_type/state_kind/phase/event/clock/outcome. NEVER invent a field " +
493
531
  "(a match on an absent field silently matches nothing). For body text use bodyContains instead; for a log level floor use minLevel, not match.level.",
494
532
  },
495
533
  bodyContains: {
@@ -694,12 +732,47 @@ export const TOOL_DEFINITIONS = [
694
732
  },
695
733
  annotations: { readOnlyHint: true },
696
734
  },
735
+ {
736
+ name: "run_test_case",
737
+ description: "Replay a case of made-up RTM frames into the app's own message handler on the device. case is a built-in name (message_changed, message_replied: a seed message then its update, 100 pairs at 10 frames a second) or the stem of ~/.slack-radar/test-cases/<name>.json, which replaces a built-in of the same name. Frames per run = repeat × events, and the rate counts every frame. Then call get_test_run(run_id, wait_seconds) until settled. A 409 active names active_run_id: get_test_run or stop_test_run it. A 409 settling, N ms left: wait that long and retry. A 400 names the refused frame. Debug builds that serve test_runs only.",
738
+ inputSchema: {
739
+ type: "object",
740
+ properties: {
741
+ case: { type: "string", description: "Built-in name or case file stem." },
742
+ repeat: { type: "integer", minimum: 1, description: "Times the case's events are sent. Default from the case." },
743
+ rate_per_second: { type: ["number", "null"], minimum: 1, maximum: 1000, description: "Frames a second, 1 to 1000, or null for a burst. Default from the case." },
744
+ },
745
+ required: ["case"],
746
+ },
747
+ annotations: { readOnlyHint: false },
748
+ },
749
+ {
750
+ name: "get_test_run",
751
+ description: "Read one replay run, or the last ten with active_run_id when run_id is omitted. wait_seconds (max 45) polls until settled; it bounds when the last read starts and each read gets 3 s; an unsettled answer carries a note, call again. settled turns true 2 quiet s after the later of the run's end and its last counted event; frames still pending hold it up to 10 s after the end, then count as ignored. Trust summary only once settled: ok and failed count handler outcomes. by_type keys can be dotted, read summary.by_type[\"MESSAGE.MESSAGE_CHANGED\"] for sent, ok, failed, max_ms and p50_ms/p90_ms/p99_ms (null under 100 counted events of that type). stop_reason and summary.failed_label say why a run ended early. elapsed_ms, achieved_rate, drain_ms, held_ms and late_sends are null until the run ends. An unknown run_id is a 404. clear_buffers drops settled runs, read them first.",
752
+ inputSchema: {
753
+ type: "object",
754
+ properties: {
755
+ run_id: { type: "string" },
756
+ wait_seconds: { type: "integer", minimum: 0, maximum: 45 },
757
+ },
758
+ },
759
+ annotations: { readOnlyHint: true },
760
+ },
761
+ {
762
+ name: "stop_test_run",
763
+ description: "Stop a replay run. 202 with the run while it stops, 200 once it has already ended, 404 unknown, 409 while still starting (retry in a moment). Its counts stay readable with get_test_run.",
764
+ inputSchema: { type: "object", properties: { run_id: { type: "string" } }, required: ["run_id"] },
765
+ annotations: { readOnlyHint: false, idempotentHint: true },
766
+ },
697
767
  ];
698
768
  /**
699
769
  * Check whether a tool call should be blocked by the session gate.
700
770
  * Returns an error response object if blocked, or null if allowed.
771
+ *
772
+ * `allowSwitchboardExportOffline` lets export_switchboard_session through while disabled; the
773
+ * caller sets it only when a host-only report can be built without touching the device.
701
774
  */
702
- export function sessionGate(toolName, sessionEnabled) {
775
+ export function sessionGate(toolName, sessionEnabled, allowSwitchboardExportOffline = false) {
703
776
  // Session enable/disable are always allowed
704
777
  if (toolName === "_radar_session_enable" || toolName === "_radar_session_disable") {
705
778
  return null;
@@ -708,18 +781,25 @@ export function sessionGate(toolName, sessionEnabled) {
708
781
  if (toolName === "ping") {
709
782
  return null;
710
783
  }
784
+ // Profile discovery is adb-only and is the recovery path named by a refused enable.
785
+ if (toolName === "list_profiles") {
786
+ return null;
787
+ }
711
788
  // open_radar_dashboard launches an independent local web process with its own
712
789
  // device-enable (Reconnect) button, so it does not require the MCP session enabled.
713
790
  if (toolName === "open_radar_dashboard") {
714
791
  return null;
715
792
  }
793
+ if (toolName === "export_switchboard_session" && allowSwitchboardExportOffline) {
794
+ return null;
795
+ }
716
796
  if (!sessionEnabled) {
717
797
  return {
718
798
  content: [
719
799
  {
720
800
  type: "text",
721
801
  text: JSON.stringify({
722
- error: "Radar is not active. Use /radar-enable to connect, or ask about the device to auto-enable.",
802
+ error: "Radar is not active. Run /radar-enable, then retry this call.",
723
803
  }),
724
804
  },
725
805
  ],
@@ -1 +1,4 @@
1
- export declare function webChildEnv(initialSpec?: Record<string, unknown>): NodeJS.ProcessEnv;
1
+ export declare function webChildEnv(initialSpec?: Record<string, unknown>, target?: {
2
+ platform: string;
3
+ serial?: string | null;
4
+ }): NodeJS.ProcessEnv;
@@ -6,9 +6,12 @@
6
6
  // transport at import time, so a test importing it would hang rather than exit. Keeping the builder
7
7
  // here makes the boundary assertable without importing a server.
8
8
  import { RADAR_PORT } from "../shared/constants.js";
9
- export function webChildEnv(initialSpec) {
9
+ export function webChildEnv(initialSpec, target) {
10
10
  return {
11
11
  ...process.env,
12
+ ...(target ? { SLACK_RADAR_PLATFORM: target.platform } : {}),
13
+ ...(target?.platform === "ios" && target.serial
14
+ ? { SLACK_RADAR_IOS_SIMULATOR_UDID: target.serial } : {}),
12
15
  // A bridge-spawned dashboard must not pop a window unbidden: the Claude Code session returns the
13
16
  // URL instead, which is what the /radar-ui server instructions promise.
14
17
  SLACK_RADAR_NO_OPEN: "1",
@@ -1,4 +1,8 @@
1
+ import { type ChildProcess } from "child_process";
2
+ import { TokenFileError } from "./radar-token.js";
3
+ import { LogSession, type LogFrame } from "./log-session.js";
1
4
  import type { DeviceInfo, DeviceTransport, LogResult, ProcessState, DevicePick } from "./transport.js";
5
+ export declare function describeBroadcastFailure(error: Error): string;
2
6
  /**
3
7
  * Resolve the adb binary. MCP servers spawned from GUI launchers (Spotlight,
4
8
  * Raycast, Dock) do not inherit the user's shell PATH, so a bare `adb` call
@@ -10,6 +14,27 @@ import type { DeviceInfo, DeviceTransport, LogResult, ProcessState, DevicePick }
10
14
  * surface a clear error instead of a misleading "device not connected".
11
15
  */
12
16
  export declare function resolveAdbPath(): string | null;
17
+ type SpawnAndroidProcessList = () => ChildProcess | null;
18
+ /**
19
+ * A device-scoped PID -> package snapshot for dashboard log rows.
20
+ *
21
+ * Android reuses PIDs, and a dashboard can switch between devices without restarting its
22
+ * process. Replacing the whole snapshot on refresh, rather than appending to a module-global
23
+ * map, prevents a PID on the new process/device from inheriting the old package label.
24
+ */
25
+ export declare class AndroidPidPackageMap {
26
+ private readonly spawnProcessList;
27
+ private packages;
28
+ private refreshVersion;
29
+ private activeRefresh;
30
+ private lastRefresh;
31
+ constructor(spawnProcessList?: SpawnAndroidProcessList);
32
+ resolve(pid: number): string | undefined;
33
+ refresh(): void;
34
+ reset(): void;
35
+ }
36
+ /** Parse one adb logcat threadtime line into the dashboard's normalized log frame. */
37
+ export declare function parseAndroidLogcat(line: string, resolvePackage?: (pid: number) => string | undefined): LogFrame | null;
13
38
  /**
14
39
  * Parse the output of `ps -A -o USER,NAME` to extract the Android user ID
15
40
  * for the debug build process. When multiple profiles are running, prefers
@@ -31,9 +56,20 @@ export declare function parseAdbDevicesOutput(raw: string): {
31
56
  label: string;
32
57
  state: string;
33
58
  }[];
59
+ /** Seams for AndroidTransport's host log capture, shaped like IosSimulatorTransportDependencies. */
60
+ export interface AndroidTransportDependencies {
61
+ /** Start the dashboard's `adb logcat` child. Defaults to the resolved adb binary. */
62
+ spawnLogcat?: () => ChildProcess;
63
+ /** Start the `ps` listing that labels log rows with their package. */
64
+ spawnProcessList?: SpawnAndroidProcessList;
65
+ }
34
66
  export declare class AndroidTransport implements DeviceTransport {
35
67
  readonly platform = "android";
68
+ readonly logPackage = "com.Slack.internal.debug";
69
+ readonly supportsHostLogs = true;
70
+ readonly logSession: LogSession;
36
71
  readonly supportsRadarHttpTools = true;
72
+ readonly sendsRadarToken = true;
37
73
  readonly supportsLocalFileAccess = true;
38
74
  readonly supportsDeviceDashboard = true;
39
75
  private portForwarded;
@@ -42,7 +78,10 @@ export declare class AndroidTransport implements DeviceTransport {
42
78
  private radarEnabled;
43
79
  private lastForwardError;
44
80
  private lastActivateError;
81
+ private lastActivateTokenFileError;
45
82
  private selectedDevice;
83
+ private readonly dashboardPidPackages;
84
+ constructor(dependencies?: AndroidTransportDependencies);
46
85
  ensureForward(): boolean;
47
86
  private rebuildForward;
48
87
  reassertForward(): boolean;
@@ -76,7 +115,10 @@ export declare class AndroidTransport implements DeviceTransport {
76
115
  radarSocketPresentAsync(): Promise<"present" | "absent" | "unknown">;
77
116
  private recordActivateSuccess;
78
117
  private recordActivateFailure;
118
+ private readArmToken;
79
119
  getLastActivateError(): string | null;
120
+ ensureLogCapture(): void;
121
+ getLastActivateTokenFileError(): TokenFileError | null;
80
122
  resetState(): void;
81
123
  dropForward(): void;
82
124
  isForwarded(): boolean;
@@ -95,6 +137,7 @@ export declare class AndroidTransport implements DeviceTransport {
95
137
  recordScreen(durationS: number): string;
96
138
  getAppState(): string;
97
139
  getRecentLogs(tag: string, limit: number, grep?: string): LogResult;
140
+ stopLogCapture(): void;
98
141
  listProfiles(): {
99
142
  userId: string;
100
143
  label: string;
@@ -165,3 +208,4 @@ export declare class AndroidTransport implements DeviceTransport {
165
208
  */
166
209
  processState(timeoutMs?: number): ProcessState;
167
210
  }
211
+ export {};