@slack/radar-mcp 1.26.0 → 1.27.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 +9 -2
- package/dist/mcp/api-paths.d.ts +25 -1
- package/dist/mcp/api-paths.js +85 -9
- package/dist/mcp/index.js +23 -4
- package/dist/mcp/snapshot-cli.d.ts +1 -1
- package/dist/mcp/snapshot-cli.js +16 -1
- package/dist/mcp/snapshot.js +46 -24
- package/dist/mcp/test-runs-tools.d.ts +2 -0
- package/dist/mcp/test-runs-tools.js +58 -5
- package/dist/mcp/tools.js +25 -3
- package/dist/shared/android.d.ts +15 -4
- package/dist/shared/android.js +102 -12
- package/dist/shared/constants.d.ts +6 -5
- package/dist/shared/constants.js +6 -5
- package/dist/shared/switchboard-note.js +2 -1
- package/dist/shared/switchboard-report.js +1 -1
- package/dist/shared/test-case-capture.d.ts +15 -0
- package/dist/shared/test-case-capture.js +235 -0
- package/dist/shared/test-case-store.d.ts +54 -0
- package/dist/shared/test-case-store.js +208 -0
- package/dist/shared/transport.d.ts +9 -1
- package/dist/web/install-app.js +1 -1
- package/dist/web/public/index.html +1 -0
- package/dist/web/public/next/app.js +12 -1
- package/dist/web/public/next/feed.js +17 -2
- package/dist/web/public/next/filters.js +5 -5
- package/dist/web/public/next/registry.js +3 -2
- package/dist/web/public/next/save-case.js +92 -0
- package/dist/web/public/next/store.js +3 -1
- package/dist/web/public/next/switchboard-note.js +2 -1
- package/dist/web/public/next/test-cases.js +328 -0
- package/dist/web/public/next/voice.js +1 -1
- package/dist/web/server.d.ts +1 -0
- package/dist/web/server.js +214 -2
- package/dist/web/spec.d.ts +3 -2
- package/dist/web/spec.js +10 -9
- package/package.json +1 -1
- package/dist/mcp/test-cases.d.ts +0 -14
- package/dist/mcp/test-cases.js +0 -77
- /package/dist/web/public/icons/{radar-1024.png → icon-1024.png} +0 -0
- /package/dist/web/public/icons/{radar.svg → icon.svg} +0 -0
package/README.md
CHANGED
|
@@ -54,6 +54,7 @@ Opens `http://localhost:8100` automatically. Set `SLACK_RADAR_WEB_PORT` to use a
|
|
|
54
54
|
* **Database** — read-only browser for the on-device SQLite stores (pick a database, then a table, or run a read-only query). See the data-handling note below.
|
|
55
55
|
* **Preferences** — read-only browser for the on-device SharedPreferences files (pick a file, browse its keys, or search across every file at once).
|
|
56
56
|
* **Feature Flags** — live view of every feature flag and experiment the Slack app knows about, with its current effective value (ON/OFF for toggles, group name for experiments), its scope, and whether it is locally overridden; updates as they change on the device. Filter by name.
|
|
57
|
+
* **Test cases** — pick a built-in or saved case, set repeat and rate, Run it on the device and Stop it, read the per-type counts with p50, p90, p99 and max times, copy the settled summary as JSON, and delete a saved case. Shown on builds that serve `test_runs`.
|
|
57
58
|
* **Custom** — a tab Claude builds on request. Ask a Claude Code session in your terminal for a view the pre-built tabs do not cover (e.g. "graph calls per second and flag the slow ones"); it authors the view via the `open_radar_dashboard` tool and it appears here. A Custom view can carry `exclude` terms to hide noisy rows; add more with the **exclude…** control on the feed toolbar or the Filters panel (comma-separated there), or have the agent set them in the spec (one phrase per term, no commas or line breaks). A log view narrowed to one tag is the same kind of ask: "show me only the `<Tag>` logs, DEBUG and up, without the noisy lines" becomes a spec with `source: log`, `match: {package, tag}`, `minLevel` and `exclude`, opened as a Custom tab. Persists until you refresh the page; exclude terms are remembered in the browser only on the pre-built tabs.
|
|
58
59
|
|
|
59
60
|
Each tab has a filter / sort / pause / clear feed and a payload inspector, most a live rate, Network and Traces a graph. **Clear** empties the dashboard's own view only, so the device keeps its buffers and a reconnect or a source switch backfills recent records again (ask a Claude Code session for `clear_buffers` to wipe the device too). The filter box takes space-separated terms that must all match, `-term` to exclude, `/pattern/` for regex, and `"quoted phrases"` for spaces or a literal `-` or `/` (curly quotes count too, and pasting text with spaces quotes it for you, unless you are mid-word or the text starts in filter syntax). `-term` is page-wide and gone on reload; to keep an exclusion, use the **exclude…** control on the feed toolbar (one term, then Enter), the **exclude** row in the Filters panel (comma separated) or an agent's `exclude` on the spec: the terms show above the feed as removable chips, are saved with the tab, and on a pre-built tab are remembered in the browser when you come back; a spec an agent pushes lands as written and does not touch that memory. An exclude term written `field:value` (say `kind:frame`, the Switchboard record's own kind field; no space after the colon) hides rows whose field equals the value, case-insensitive, and a field no row carries hides nothing; plain terms match by substring, and the Switchboard tab's kind chips toggle those `kind:` terms for you. The `?` at the right edge of the box opens a short legend under it. A phrase that itself contains a quote character goes in `/regex/` form instead, where quotes are plain text. Committed terms turn into removable pills; a leading `-` is now the exclude operator (the old box matched it as plain text), and quoting restores the literal. Regex flags are optional and short (i/m/s/g, 1-2 letters only, so an ambiguous tail like `/api/im` reads as flags, noted in the tooltip); typos like `/error/x` become part of the pattern and match literally, and quoting any `/…/` term matches it literally. Invalid regexes and incomplete typing (e.g. `/foo(`) are ignored (the term turns amber) instead of blanking the feed. On the Live tab a row type name (`log`, `clog`, `trace`, `rtm`, `network`, `switchboard`) also matches rows of that type, and the `-log` form excludes by row type only, so it hides logcat lines without touching a `logout` clog (quote it, `-"log"`, to exclude by text instead). Switching tabs replays what you have already seen this session (the browser caches it, bounded by count and age) so the view does not reset to empty. ADB forwarding and device activation are handled for you; a reconnect control re-arms after a device sleep. The device-side session shuts down after its idle timeout, and an open dashboard tab now recovers that on its own: the header says there is no radar session on the device and re-enables it, once right away (or on the minute, if the session just came back and died again) and then at most once a minute, giving up after three failed attempts (a session that dies again within a minute of coming back counts as a failed attempt), or at once if the attached device changed, so the next press is yours. Only a tab you are looking at does this (a background tab never arms a device you let idle out), never a dashboard an agent opened, and **✋ stop auto re-enable** in the header turns it off for dashboards at this address if you would rather do it by hand (`SLACK_RADAR_NO_ARM=1` on the process turns it off for that process, along with the arm at launch). The dashboard follows your system light/dark setting by default; the theme toggle in the header overrides it and is remembered. A form-encoded request body is shown decoded, field by field, JSON fields expanded; Copy cURL still carries the raw bytes. A field whose JSON nests too deep stays as text with a note saying so, and a request body the device cap cut shows a truncation banner.
|
|
@@ -145,7 +146,7 @@ Radar starts **disabled** each session. All tools except `ping` return an error
|
|
|
145
146
|
| `get_recent_traces` | Performance trace/span summaries: trace name, span name, duration. Filterable by name substring. |
|
|
146
147
|
| `get_trace_detail` | Full trace/span detail for a specific trace, including tags. |
|
|
147
148
|
| `get_switchboard_sessions` | Slackbot voice (switchboard) sessions the device still holds, newest first: `session_id`, `team_id`, `began_at`, `ended_at`, record and frame counts, the newest state and audio levels, `server_session_id` (the server's own name for the session, null until it names one; absent on an older build), `turns` (turn count, the newest response time and its clock, null before the first turn; absent on an older build), and `saved_turn_counts` (saved turns per outcome; absent on an older build means not counted, not zero). Ids restart with the app process. |
|
|
148
|
-
| `get_switchboard_session` | One voice session's summary plus its records, oldest first: `state` transitions, control frames (`frame`) in and out, `player` stutter events, `phase` startup timings, `session` begin/end/ready (`ready` carries `server_session_id`), `levels` (batched mic/playback meter ticks), `turn` (one timed voice turn: `response_ms` and `clock`), and `saved_turn` (whether a spoken turn got saved to the DM: `outcome` (`applied`, `no_line`, `missing_field`, `other_session`) and `has_thread`; the summary's `saved_turn_counts` counts each outcome, and absent on an older device build means not counted, not zero). Narrow with `kind`; `limit` is how many of the newest records come back (default 50, max 2000 per request; the device may hold more, paged with before_id), filtered by kind first, so a kind page is the newest `limit` records of that kind. `reconnect_try` (one voice reconnect try: `trigger` (`restart`, `drop`, `settings`), `try` and `outcome` (`ready`, `retry`, `refused`, `gave_up`)); a Reconnecting state's cause is its trigger, and the summary's `server_session_ids` lists every ready id. `card` (one move of a voice card the server is waiting on: `card_kind`, `event`, `by`, `card_id`; a card shown or carried
|
|
149
|
+
| `get_switchboard_session` | One voice session's summary plus its records, oldest first: `state` transitions, control frames (`frame`) in and out, `player` stutter events, `phase` startup timings, `session` begin/end/ready (`ready` carries `server_session_id`), `levels` (batched mic/playback meter ticks), `turn` (one timed voice turn: `response_ms` and `clock`), and `saved_turn` (whether a spoken turn got saved to the DM: `outcome` (`applied`, `no_line`, `missing_field`, `other_session`) and `has_thread`; the summary's `saved_turn_counts` counts each outcome, and absent on an older device build means not counted, not zero). Narrow with `kind`; `limit` is how many of the newest records come back (default 50, max 2000 per request; the device may hold more, paged with before_id), filtered by kind first, so a kind page is the newest `limit` records of that kind. `reconnect_try` (one voice reconnect try: `trigger` (`restart`, `drop`, `settings`), `try` and `outcome` (`ready`, `retry`, `refused`, `gave_up`)); a Reconnecting state's cause is its trigger, and the summary's `server_session_ids` lists every ready id. `card` (one move of a voice card the server is waiting on: `card_kind`, `event`, `by`, `card_id`; a card shown or carried and not taken down since was still up at the session's last record). |
|
|
149
150
|
| `export_switchboard_session` | Write one voice session's summary and its records to a plain-text report under `~/.slack-radar/exports/`, permissions 0700/0600 like `capture_snapshot`. Pages the device, then merges in the live stream copy; the export can stop early (for example an old build, the 32 MB size cap, the page limit, or the device stopping answering), and the report notes say why anything is missing. An unknown id (404, unreachable, or 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. Defaults to newest when `id` is omitted; returns the file path and a summary. |
|
|
150
151
|
| `wait_for_events` | Block until matching events arrive via SSE stream. Idle-timeout based, not polling. |
|
|
151
152
|
| `search` | Full-text search across network, RTM, clog, and trace buffers. |
|
|
@@ -168,6 +169,8 @@ Radar starts **disabled** each session. All tools except `ping` return an error
|
|
|
168
169
|
| `run_test_case` | Replay a built-in or hand-written case. Pass `case`, optional `repeat` and `rate_per_second` (null for burst). Requires a debug build serving `test_runs`. |
|
|
169
170
|
| `get_test_run` | Read `run_id`, or list the last ten when omitted. Optional `wait_seconds` (max 45) polls until settled. It bounds when the last read may start; every read then gets 3 seconds. |
|
|
170
171
|
| `stop_test_run` | Stop `run_id`. Its counts stay readable with `get_test_run`. |
|
|
172
|
+
| `save_test_case` | Save captured RTM events as a replay case. Pass `name` and `ids` from `get_recent_rtm_events`, optional `repeat`, `rate_per_second` and `overwrite`. |
|
|
173
|
+
| `list_test_cases` | List built-in and saved cases with repeat, rate, event count and type counts. A file that cannot load shows its error. |
|
|
171
174
|
| `clear_buffers` | Clear all captured buffers (network, RTM, clog, trace, settled test runs) on the device and locally, and the switchboard copy `export_switchboard_session` falls back to. The session event spool `query_session` reads is kept. |
|
|
172
175
|
| `open_radar_dashboard` | Author or refine a custom live dashboard tab from a spec (source, filters, widgets, alerts). Suggested when a request is not covered by the pre-built tabs; not auto-invoked. Returns the dashboard URL; debug builds only, local only. |
|
|
173
176
|
| `_radar_session_enable` | Enable radar for the session. A repeat on a live session checks the device first. |
|
|
@@ -175,12 +178,16 @@ Radar starts **disabled** each session. All tools except `ping` return an error
|
|
|
175
178
|
|
|
176
179
|
### Test cases
|
|
177
180
|
|
|
181
|
+
The dashboard's Test cases tab runs the built-in and saved cases below.
|
|
182
|
+
|
|
178
183
|
Replay frames go into the app's own message handler on the device, not over the socket. Use a quiet workspace and a debug build that serves the `test_runs` source. Open a screen in a signed-in team first.
|
|
179
184
|
|
|
180
185
|
`message_changed` and `message_replied` seed a message, then edit it or update its reply count. Each event carries about 4 KB of made-up text. Both default to `repeat: 100`, `rate_per_second: 10`, so they send 200 frames over about 20 seconds. The rate counts every frame, including the seed. Frames per run = repeat × events.
|
|
181
186
|
|
|
182
187
|
Write custom cases to `~/.slack-radar/test-cases/<name>.json`, then pass the name or name.json. A file named like a built-in replaces it. Names use 1 to 64 letters, digits, underscores or hyphens. The file must be regular, at most 256 KB, and contain an object with an `events` array and a required `rate_per_second` key. Null means burst. Repeat defaults to 1. Call arguments override repeat and rate, including a null rate, but cannot rescue a file missing the rate key.
|
|
183
188
|
|
|
189
|
+
Save a case from traffic with `save_test_case`. Only server-sent `message`, `message_changed` and `message_replied` frames are kept. The file holds test channel, user, timestamp and file ids and same-length filler text, so it carries none of the real ones. Every iteration replays the updates against one seeded message, so edits to several different messages share that one message. The dashboard's RTM tab does the same for the rows you select (Save as test case), into the same folder, so the case runs with `run_test_case`.
|
|
190
|
+
|
|
184
191
|
| Placeholder | Device fills it with |
|
|
185
192
|
|---|---|
|
|
186
193
|
| `{{test_channel}}` | The test channel |
|
|
@@ -291,7 +298,7 @@ Redaction blanks the value of `Authorization`, `Cookie` and `Set-Cookie` headers
|
|
|
291
298
|
|
|
292
299
|
On a shared host:
|
|
293
300
|
|
|
294
|
-
*
|
|
301
|
+
* Each run forwards its own free port, so parallel emulators need nothing extra; `SLACK_RADAR_DEVICE_PORT` still forces one. Pass `--serial` when several devices are attached.
|
|
295
302
|
* The Radar token is one per OS user, not per run, and Radar stays on until its idle timeout after the end snapshot.
|
|
296
303
|
|
|
297
304
|
## Data Capture
|
package/dist/mcp/api-paths.d.ts
CHANGED
|
@@ -9,4 +9,28 @@ export declare function switchboardSessionQuery(args: Record<string, unknown>):
|
|
|
9
9
|
error: string;
|
|
10
10
|
};
|
|
11
11
|
export declare function clampSwitchboardLimit(limit: unknown): number;
|
|
12
|
-
export declare
|
|
12
|
+
export declare const FILTERED_LIST_LIMIT = 2000;
|
|
13
|
+
export declare const LIST_TOOLS: Record<string, {
|
|
14
|
+
key: string;
|
|
15
|
+
filters: string[];
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Keep only the newest `limit` rows of a filtered list reply. When every row has a numeric id,
|
|
19
|
+
* the newest rows are picked by id but returned in the order the device sent them, so a
|
|
20
|
+
* newest-first device stays newest first. Otherwise the device order is kept and the tail wins.
|
|
21
|
+
* Anything else (unfiltered call, other tool, error, odd envelope) is returned as is.
|
|
22
|
+
*/
|
|
23
|
+
export declare function trimListResult<T extends {
|
|
24
|
+
error?: string;
|
|
25
|
+
}>(name: string, args: Record<string, unknown>, result: T): T;
|
|
26
|
+
/**
|
|
27
|
+
* The note for a reply retried at the caller's own limit, or null when the retry is complete.
|
|
28
|
+
* Only iOS is known to filter its whole ring, so every other platform keeps the note.
|
|
29
|
+
*/
|
|
30
|
+
export declare function retryShortNote(platform: string): string | null;
|
|
31
|
+
export declare function buildApiPath(name: string, args: Record<string, unknown>, wholeRing?: boolean): string | null;
|
|
32
|
+
/**
|
|
33
|
+
* The path a filtered list call would have used without the whole-ring bump, for a retry when the
|
|
34
|
+
* 2000-row reply is over the response size cap. Null for unfiltered calls and other tools.
|
|
35
|
+
*/
|
|
36
|
+
export declare function callerLimitPath(name: string, args: Record<string, unknown>): string | null;
|
package/dist/mcp/api-paths.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// Extracted from index.ts (where it was nested inside runMcpServer, so unreachable by a unit
|
|
3
3
|
// test) into its own module so the device-route contract for EVERY proxied tool -- network,
|
|
4
4
|
// rtm, clog, trace, search, and the detail-by-id variants -- is pinned by a table test
|
|
5
|
-
// (tests/api-paths.test.mjs).
|
|
5
|
+
// (tests/api-paths.test.mjs). It also trims filtered list replies back to the caller's limit.
|
|
6
|
+
// Pure: no I/O, no device, just string building.
|
|
6
7
|
//
|
|
7
8
|
// The arg shapes here are the query-param subset each tool sends; they intentionally duplicate
|
|
8
9
|
// the (wider) handler arg interfaces in index.ts rather than couple this pure module to them.
|
|
@@ -61,13 +62,76 @@ function detailPath(resource, id) {
|
|
|
61
62
|
const n = nonNegativeIntArg(id);
|
|
62
63
|
return n === null ? null : `/api/${resource}/${n}`;
|
|
63
64
|
}
|
|
64
|
-
|
|
65
|
+
// 2000 is the biggest device ring, so asking for that many covers any ring. The Android device scans
|
|
66
|
+
// only 3x the limit of newest rows before it filters, which is why a small limit missed matches under
|
|
67
|
+
// a flood of other rows; the iOS device already filters its whole ring. The host trims back to the
|
|
68
|
+
// caller's limit (trimListResult).
|
|
69
|
+
export const FILTERED_LIST_LIMIT = 2000;
|
|
70
|
+
const DEFAULT_LIST_LIMIT = 50;
|
|
71
|
+
// Per list tool: the envelope array on the device reply and which args count as a filter.
|
|
72
|
+
export const LIST_TOOLS = {
|
|
73
|
+
get_recent_network_calls: { key: "calls", filters: ["url_filter", "status_code"] },
|
|
74
|
+
get_recent_rtm_events: { key: "events", filters: ["event_type", "direction", "channel"] },
|
|
75
|
+
get_recent_clogs: { key: "clogs", filters: ["name"] },
|
|
76
|
+
get_recent_traces: { key: "traces", filters: ["name"] },
|
|
77
|
+
};
|
|
78
|
+
function isFilteredListCall(name, args) {
|
|
79
|
+
const tool = LIST_TOOLS[name];
|
|
80
|
+
return !!tool && tool.filters.some((f) => !!args?.[f]);
|
|
81
|
+
}
|
|
82
|
+
function requestedLimit(args) {
|
|
83
|
+
const n = Number(args?.limit);
|
|
84
|
+
return Number.isFinite(n) && n >= 1 ? Math.floor(n) : DEFAULT_LIST_LIMIT;
|
|
85
|
+
}
|
|
86
|
+
// The limit to send: the whole-ring limit when a filter is set, else what the caller asked for.
|
|
87
|
+
function sentLimit(name, args, fallback, wholeRing) {
|
|
88
|
+
return wholeRing && isFilteredListCall(name, args) ? FILTERED_LIST_LIMIT : fallback;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Keep only the newest `limit` rows of a filtered list reply. When every row has a numeric id,
|
|
92
|
+
* the newest rows are picked by id but returned in the order the device sent them, so a
|
|
93
|
+
* newest-first device stays newest first. Otherwise the device order is kept and the tail wins.
|
|
94
|
+
* Anything else (unfiltered call, other tool, error, odd envelope) is returned as is.
|
|
95
|
+
*/
|
|
96
|
+
export function trimListResult(name, args, result) {
|
|
97
|
+
if (!isFilteredListCall(name, args) || result.error)
|
|
98
|
+
return result;
|
|
99
|
+
const key = LIST_TOOLS[name].key;
|
|
100
|
+
const rows = result[key];
|
|
101
|
+
if (!Array.isArray(rows))
|
|
102
|
+
return result;
|
|
103
|
+
const limit = requestedLimit(args);
|
|
104
|
+
const ids = rows.map((row) => {
|
|
105
|
+
const id = typeof row === "object" && row !== null ? row.id : undefined;
|
|
106
|
+
return typeof id === "number" ? id : undefined;
|
|
107
|
+
});
|
|
108
|
+
if (!ids.every((id) => id !== undefined))
|
|
109
|
+
return { ...result, [key]: rows.slice(-limit) };
|
|
110
|
+
const keep = rows
|
|
111
|
+
.map((_, i) => i)
|
|
112
|
+
.sort((a, b) => ids[b] - ids[a])
|
|
113
|
+
.slice(0, limit)
|
|
114
|
+
.sort((a, b) => a - b);
|
|
115
|
+
return { ...result, [key]: keep.map((i) => rows[i]) };
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The note for a reply retried at the caller's own limit, or null when the retry is complete.
|
|
119
|
+
* Only iOS is known to filter its whole ring, so every other platform keeps the note.
|
|
120
|
+
*/
|
|
121
|
+
export function retryShortNote(platform) {
|
|
122
|
+
if (platform === "ios")
|
|
123
|
+
return null;
|
|
124
|
+
return "The whole-ring reply was over the response size cap, so only the newest rows were searched and older matches may be missing. Narrow the filter or use capture_snapshot.";
|
|
125
|
+
}
|
|
126
|
+
// wholeRing=false skips the 2000-row bump, giving the caller's own limit (see callerLimitPath).
|
|
127
|
+
export function buildApiPath(name, args, wholeRing = true) {
|
|
65
128
|
switch (name) {
|
|
66
129
|
case "get_recent_network_calls": {
|
|
67
130
|
const a = args;
|
|
68
131
|
const params = new URLSearchParams();
|
|
69
|
-
|
|
70
|
-
|
|
132
|
+
const netLimit = sentLimit(name, args, a?.limit, wholeRing);
|
|
133
|
+
if (netLimit)
|
|
134
|
+
params.set("limit", String(netLimit));
|
|
71
135
|
if (a?.url_filter)
|
|
72
136
|
params.set("url_filter", a.url_filter);
|
|
73
137
|
if (a?.status_code)
|
|
@@ -82,8 +146,9 @@ export function buildApiPath(name, args) {
|
|
|
82
146
|
case "get_recent_rtm_events": {
|
|
83
147
|
const a = args;
|
|
84
148
|
const params = new URLSearchParams();
|
|
85
|
-
|
|
86
|
-
|
|
149
|
+
const rtmLimit = sentLimit(name, args, a?.limit, wholeRing);
|
|
150
|
+
if (rtmLimit)
|
|
151
|
+
params.set("limit", String(rtmLimit));
|
|
87
152
|
if (a?.event_type)
|
|
88
153
|
params.set("event_type", a.event_type);
|
|
89
154
|
if (a?.direction)
|
|
@@ -100,8 +165,9 @@ export function buildApiPath(name, args) {
|
|
|
100
165
|
case "get_recent_clogs": {
|
|
101
166
|
const a = args;
|
|
102
167
|
const params = new URLSearchParams();
|
|
103
|
-
|
|
104
|
-
|
|
168
|
+
const clogLimit = sentLimit(name, args, a?.limit, wholeRing);
|
|
169
|
+
if (clogLimit)
|
|
170
|
+
params.set("limit", String(clogLimit));
|
|
105
171
|
if (a?.name)
|
|
106
172
|
params.set("name", a.name);
|
|
107
173
|
const qs = params.toString();
|
|
@@ -117,7 +183,7 @@ export function buildApiPath(name, args) {
|
|
|
117
183
|
// Default the limit when absent: traces can be large and an omitted limit would otherwise
|
|
118
184
|
// rely on an unverified device-side default and stream an unbounded result into the model
|
|
119
185
|
// context. 50 matches the other recent-* tools' practical page size.
|
|
120
|
-
params.set("limit", String(a?.limit && a.limit > 0 ? a.limit : 50));
|
|
186
|
+
params.set("limit", String(sentLimit(name, args, a?.limit && a.limit > 0 ? a.limit : 50, wholeRing)));
|
|
121
187
|
if (a?.name)
|
|
122
188
|
params.set("name", a.name);
|
|
123
189
|
return `/api/traces?${params.toString()}`;
|
|
@@ -144,3 +210,13 @@ export function buildApiPath(name, args) {
|
|
|
144
210
|
return null;
|
|
145
211
|
}
|
|
146
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* The path a filtered list call would have used without the whole-ring bump, for a retry when the
|
|
215
|
+
* 2000-row reply is over the response size cap. Null for unfiltered calls and other tools.
|
|
216
|
+
*/
|
|
217
|
+
export function callerLimitPath(name, args) {
|
|
218
|
+
// At or above the ring size the retry would ask for as many rows and hit the cap again.
|
|
219
|
+
if (!isFilteredListCall(name, args) || requestedLimit(args) >= FILTERED_LIST_LIMIT)
|
|
220
|
+
return null;
|
|
221
|
+
return buildApiPath(name, args, false);
|
|
222
|
+
}
|
package/dist/mcp/index.js
CHANGED
|
@@ -37,13 +37,13 @@ import { listFeatureFlags, searchFeatureFlags, getFeatureFlag, normalizeOverridd
|
|
|
37
37
|
import { cleanupPulledDatabases, initializeDatabasePath, resetDbState, } from "../shared/db.js";
|
|
38
38
|
import { TOOL_DEFINITIONS, serverInstructions, sessionGate } from "./tools.js";
|
|
39
39
|
import { dashboardDebugPackageError, dashboardMatchesDevice } from "./dashboard-identity.js";
|
|
40
|
-
import { buildApiPath } from "./api-paths.js";
|
|
40
|
+
import { buildApiPath, callerLimitPath, retryShortNote, trimListResult } from "./api-paths.js";
|
|
41
41
|
import { dispatchExportSwitchboardSession, handleGetSwitchboardSession, handleGetSwitchboardSessions, sessionDisabledLine, shouldExportSwitchboardOffline, } from "./switchboard-tools.js";
|
|
42
42
|
import { getSpoolSwitchboardRecords, markSwitchboardSpoolCleared, newestSpoolSwitchboardSessionId } from "./switchboard-spool.js";
|
|
43
43
|
import { nonNegativeIntArg, SWITCHBOARD_EXPORT_SAFETY_CAP_BYTES, SWITCHBOARD_EXPORT_IDLE_MS, SWITCHBOARD_EXPORT_OVERALL_MS } from "../shared/switchboard.js";
|
|
44
44
|
import { unauthorizedResponse } from "./radar-response.js";
|
|
45
45
|
import { DEFAULT_TIMEOUT_MS, radarHttpRequest, REQUEST_LOST_PREFIX, REQUEST_TIMED_OUT } from "./radar-http.js";
|
|
46
|
-
import { handleRunTestCase, handleGetTestRun, handleStopTestRun } from "./test-runs-tools.js";
|
|
46
|
+
import { handleRunTestCase, handleGetTestRun, handleStopTestRun, handleSaveTestCase, handleListTestCases } from "./test-runs-tools.js";
|
|
47
47
|
import { buildOpenDashboardResult, readDashboardFingerprint } from "./stale-dashboard.js";
|
|
48
48
|
// --- Subcommand + bin-name dispatch ---
|
|
49
49
|
// See computeDispatch's own comment (dispatch.ts) for the full front-door table and rationale;
|
|
@@ -887,7 +887,7 @@ async function runMcpServer() {
|
|
|
887
887
|
}
|
|
888
888
|
}
|
|
889
889
|
// --- MCP Server ---
|
|
890
|
-
const server = new Server({ name: "slack-radar", version: "1.
|
|
890
|
+
const server = new Server({ name: "slack-radar", version: "1.27.0" }, { capabilities: { tools: {} }, instructions: serverInstructions(device.platform) });
|
|
891
891
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
892
892
|
tools: TOOL_DEFINITIONS,
|
|
893
893
|
}));
|
|
@@ -1015,6 +1015,14 @@ async function runMcpServer() {
|
|
|
1015
1015
|
const { data, isError } = await handleRunTestCase(toolArgs, callRadar);
|
|
1016
1016
|
return textResult(data, isError);
|
|
1017
1017
|
}
|
|
1018
|
+
if (name === "save_test_case") {
|
|
1019
|
+
const { data, isError } = await handleSaveTestCase(toolArgs, callRadar);
|
|
1020
|
+
return textResult(data, isError);
|
|
1021
|
+
}
|
|
1022
|
+
if (name === "list_test_cases") {
|
|
1023
|
+
const { data, isError } = handleListTestCases();
|
|
1024
|
+
return textResult(data, isError);
|
|
1025
|
+
}
|
|
1018
1026
|
if (name === "get_test_run") {
|
|
1019
1027
|
const { data, isError } = await handleGetTestRun(toolArgs, callRadar);
|
|
1020
1028
|
return textResult(data, isError);
|
|
@@ -1041,7 +1049,18 @@ async function runMcpServer() {
|
|
|
1041
1049
|
if (apiPath === null) {
|
|
1042
1050
|
return textResult(`Unknown tool: ${name}`, true);
|
|
1043
1051
|
}
|
|
1044
|
-
|
|
1052
|
+
let raw = await callRadar(apiPath);
|
|
1053
|
+
// The whole-ring ask can top the response size cap where the caller's own limit would not.
|
|
1054
|
+
// A disable during the first read means no more device work, so the retry is skipped then.
|
|
1055
|
+
const fallbackPath = raw._truncated === true && sessionEnabled ? callerLimitPath(name, toolArgs) : null;
|
|
1056
|
+
if (fallbackPath !== null) {
|
|
1057
|
+
raw = await callRadar(fallbackPath);
|
|
1058
|
+
// Outside iOS the retry may only scan the newest rows, so the model is told the answer may be short.
|
|
1059
|
+
const note = retryShortNote(device.platform);
|
|
1060
|
+
if (!raw.error && note)
|
|
1061
|
+
raw = { ...raw, note };
|
|
1062
|
+
}
|
|
1063
|
+
const result = trimListResult(name, toolArgs, raw);
|
|
1045
1064
|
return textResult(decorateToolResult(name, result), !!result.error);
|
|
1046
1065
|
});
|
|
1047
1066
|
const transport = new StdioServerTransport();
|
|
@@ -2,7 +2,7 @@ import type { DeviceTransport } from "../shared/transport.js";
|
|
|
2
2
|
import { type RadarResponse } from "./radar-response.js";
|
|
3
3
|
import { type EnableOutcome } from "./session-enable.js";
|
|
4
4
|
import { type SnapshotOptions, type SnapshotResult } from "./snapshot.js";
|
|
5
|
-
export declare const SNAPSHOT_USAGE = "Usage: radar-mcp snapshot [options]\n\nSave a Radar snapshot without an MCP client. Run it with --start when a test run\nbegins and without --start when it ends.\n\nAndroid only: it needs adb and a debug build on a device or emulator. Other platforms are\nnot supported.\n\nOptions:\n --serial <id> Device to use (default: the only attached device)\n --out <dir> Directory to write the snapshot under (default: ~/.slack-radar/snapshots)\n --start Only record the start of a run; no snapshot is written\n --since <epoch-ms> Keep events from this time on. Device clock, the same clock as the\n since_ms that --start prints. Beats the start marker\n --detail-url <text> Also keep the details of calls whose URL contains this text\n (repeatable); failed calls are always kept\n --timeout-minutes <n> How long Radar stays on with no calls, 1-1440 (default 60)\n --no-redact Keep tokens and auth headers as the device sent them\n --help Show this text\n\nPrints one JSON line on stdout. Exit codes: 0 done, 1 failed, 2 bad usage.\n";
|
|
5
|
+
export declare const SNAPSHOT_USAGE = "Usage: radar-mcp snapshot [options]\n\nSave a Radar snapshot without an MCP client. Run it with --start when a test run\nbegins and without --start when it ends.\n\nAndroid only: it needs adb and a debug build on a device or emulator. Other platforms are\nnot supported.\n\nOptions:\n --serial <id> Device to use (default: the only attached device)\n --out <dir> Directory to write the snapshot under (default: ~/.slack-radar/snapshots)\n --start Only record the start of a run; no snapshot is written\n --since <epoch-ms> Keep events from this time on. Device clock, the same clock as the\n since_ms that --start prints. Beats the start marker\n --detail-url <text> Also keep the details of calls whose URL contains this text\n (repeatable); failed calls are always kept\n --timeout-minutes <n> How long Radar stays on with no calls, 1-1440 (default 60)\n --no-redact Keep tokens and auth headers as the device sent them\n --help Show this text\n\nEach run forwards its own free host port; set SLACK_RADAR_DEVICE_PORT to pin a fixed one.\n\nPrints one JSON line on stdout. Exit codes: 0 done, 1 failed, 2 bad usage.\n";
|
|
6
6
|
export interface SnapshotCliArgs {
|
|
7
7
|
serial: string | null;
|
|
8
8
|
out: string | null;
|
package/dist/mcp/snapshot-cli.js
CHANGED
|
@@ -40,6 +40,8 @@ Options:
|
|
|
40
40
|
--no-redact Keep tokens and auth headers as the device sent them
|
|
41
41
|
--help Show this text
|
|
42
42
|
|
|
43
|
+
Each run forwards its own free host port; set SLACK_RADAR_DEVICE_PORT to pin a fixed one.
|
|
44
|
+
|
|
43
45
|
Prints one JSON line on stdout. Exit codes: 0 done, 1 failed, 2 bad usage.
|
|
44
46
|
`;
|
|
45
47
|
export function parseSnapshotArgs(argv) {
|
|
@@ -167,7 +169,7 @@ export function cliFetchJson(device, send) {
|
|
|
167
169
|
};
|
|
168
170
|
}
|
|
169
171
|
function defaultDeps() {
|
|
170
|
-
const device = new AndroidTransport();
|
|
172
|
+
const device = new AndroidTransport({ ownForwardPort: true });
|
|
171
173
|
const ping = () => radarHttpRequest({
|
|
172
174
|
host: RADAR_HOST,
|
|
173
175
|
port: RADAR_PORT,
|
|
@@ -224,6 +226,14 @@ export async function runSnapshotCli(argv, deps = defaultDeps()) {
|
|
|
224
226
|
deps.stdout(`${JSON.stringify({ error: message, warnings })}\n`);
|
|
225
227
|
return 1;
|
|
226
228
|
};
|
|
229
|
+
// The log capture's own signal handlers call process.exit, which skips the finally below.
|
|
230
|
+
// Our handlers exit with the same codes, so the exit hook always gets to drop the forward.
|
|
231
|
+
const onExit = () => device.releaseForward?.();
|
|
232
|
+
const onSigint = () => process.exit(130);
|
|
233
|
+
const onSigterm = () => process.exit(143);
|
|
234
|
+
process.once("exit", onExit);
|
|
235
|
+
process.on("SIGINT", onSigint);
|
|
236
|
+
process.on("SIGTERM", onSigterm);
|
|
227
237
|
try {
|
|
228
238
|
const outcome = await deps.enable(args.timeoutMinutes, args.serial);
|
|
229
239
|
if (!outcome.enabled) {
|
|
@@ -306,6 +316,11 @@ export async function runSnapshotCli(argv, deps = defaultDeps()) {
|
|
|
306
316
|
return fail(`snapshot failed: ${e.message}`);
|
|
307
317
|
}
|
|
308
318
|
finally {
|
|
319
|
+
// Release first, so a throwing stopLogCapture cannot skip it.
|
|
320
|
+
device.releaseForward?.();
|
|
321
|
+
process.off("exit", onExit);
|
|
322
|
+
process.off("SIGINT", onSigint);
|
|
323
|
+
process.off("SIGTERM", onSigterm);
|
|
309
324
|
device.stopLogCapture?.();
|
|
310
325
|
}
|
|
311
326
|
}
|
package/dist/mcp/snapshot.js
CHANGED
|
@@ -294,7 +294,10 @@ export async function createSnapshot(device, fetchJson, opts = {}, now = Date.no
|
|
|
294
294
|
? Math.floor(opts.logTailLines)
|
|
295
295
|
: DEFAULT_LOG_TAIL_LINES;
|
|
296
296
|
const dir = buildSnapshotDir(now, snapshotRoot);
|
|
297
|
-
fs.mkdirSync(
|
|
297
|
+
fs.mkdirSync(snapshotRoot, { recursive: true, mode: DIR_MODE });
|
|
298
|
+
// The leaf is not recursive: in a shared --out root someone else could plant this name first,
|
|
299
|
+
// and an existing folder or symlink must fail with EEXIST instead of being written into.
|
|
300
|
+
fs.mkdirSync(dir, { mode: DIR_MODE });
|
|
298
301
|
// `mkdirSync({ recursive: true, mode })` only applies the mode to
|
|
299
302
|
// directories it CREATES. Only the default root (and its parent) get
|
|
300
303
|
// tightened: a root the caller picked is theirs, and chmodding it or its
|
|
@@ -553,31 +556,50 @@ const ZIP_TOOLS = [
|
|
|
553
556
|
function zipSnapshotDir(dir, errors) {
|
|
554
557
|
const out = `${dir}.zip`;
|
|
555
558
|
const failures = [];
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
559
|
+
// A caller --out root keeps its umask, so the archive must never appear
|
|
560
|
+
// there before it is 0600. mkdtemp makes a 0700 dir on the same filesystem,
|
|
561
|
+
// so the final rename is atomic.
|
|
562
|
+
let staging;
|
|
563
|
+
try {
|
|
564
|
+
staging = fs.mkdtempSync(path.join(path.dirname(dir), ".zip-"));
|
|
565
|
+
}
|
|
566
|
+
catch (e) {
|
|
567
|
+
errors.push(`zip failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
568
|
+
return null;
|
|
569
|
+
}
|
|
570
|
+
const staged = path.join(staging, "snapshot.zip");
|
|
571
|
+
try {
|
|
572
|
+
for (const tool of ZIP_TOOLS) {
|
|
573
|
+
const result = spawnSync(tool.cmd, tool.args(staged), {
|
|
574
|
+
cwd: dir,
|
|
575
|
+
timeout: 10000,
|
|
576
|
+
});
|
|
577
|
+
if (result.error?.code === "ENOENT") {
|
|
578
|
+
continue;
|
|
567
579
|
}
|
|
568
|
-
|
|
569
|
-
|
|
580
|
+
if (result.status === 0) {
|
|
581
|
+
try {
|
|
582
|
+
fs.chmodSync(staged, FILE_MODE);
|
|
583
|
+
fs.renameSync(staged, out);
|
|
584
|
+
}
|
|
585
|
+
catch (e) {
|
|
586
|
+
failures.push(`${tool.cmd} wrote the archive but moving it failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
587
|
+
break;
|
|
588
|
+
}
|
|
589
|
+
return out;
|
|
570
590
|
}
|
|
571
|
-
|
|
591
|
+
// A timeout or kill leaves status null, so say why instead.
|
|
592
|
+
const why = result.error?.message ?? result.signal ?? result.stderr?.toString().trim();
|
|
593
|
+
failures.push(`${tool.cmd} exited with status ${result.status ?? "null"}${why ? ": " + why : ""}`);
|
|
594
|
+
// A half-written archive would look like a good one to the user.
|
|
595
|
+
fs.rmSync(staged, { force: true });
|
|
572
596
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
597
|
+
errors.push(failures.length > 0
|
|
598
|
+
? `zip failed: ${failures.join("; ")}`
|
|
599
|
+
: `zip not available: no ${ZIP_TOOLS.map((t) => t.cmd).join(" or ")} on PATH`);
|
|
600
|
+
return null;
|
|
601
|
+
}
|
|
602
|
+
finally {
|
|
603
|
+
fs.rmSync(staging, { recursive: true, force: true });
|
|
578
604
|
}
|
|
579
|
-
errors.push(failures.length > 0
|
|
580
|
-
? `zip failed: ${failures.join("; ")}`
|
|
581
|
-
: `zip not available: no ${ZIP_TOOLS.map((t) => t.cmd).join(" or ")} on PATH`);
|
|
582
|
-
return null;
|
|
583
605
|
}
|
|
@@ -5,4 +5,6 @@ type RadarCall = (path: string, init?: RadarRequestInit) => Promise<RadarRespons
|
|
|
5
5
|
export declare function handleRunTestCase(args: Record<string, unknown>, call: RadarCall, dir?: string, newRunId?: () => string, now?: () => number): Promise<HandlerResult>;
|
|
6
6
|
export declare function handleGetTestRun(args: Record<string, unknown>, call: RadarCall, sleep?: (ms: number) => Promise<void>, now?: () => number): Promise<HandlerResult>;
|
|
7
7
|
export declare function handleStopTestRun(args: Record<string, unknown>, call: RadarCall): Promise<HandlerResult>;
|
|
8
|
+
export declare function handleListTestCases(dir?: string): HandlerResult;
|
|
9
|
+
export declare function handleSaveTestCase(args: Record<string, unknown>, call: RadarCall, dir?: string): Promise<HandlerResult>;
|
|
8
10
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from "crypto";
|
|
2
|
-
import { buildRunBody, CASE_NAME, loadCase, testCaseDir } from "
|
|
2
|
+
import { buildRunBody, CASE_NAME, checkCaseName, listCases, loadCase, saveCase, testCaseDir } from "../shared/test-case-store.js";
|
|
3
|
+
import { captureCase } from "../shared/test-case-capture.js";
|
|
3
4
|
const TEST_RUNS_PATH = "/api/test_runs";
|
|
4
5
|
const POST_TIMEOUT_MS = 15_000;
|
|
5
6
|
const POST_DEADLINE_MS = 50_000;
|
|
@@ -23,9 +24,9 @@ async function readBack(runId, post, call, now) {
|
|
|
23
24
|
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
25
|
if (found.http_status === 404)
|
|
25
26
|
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 };
|
|
27
|
+
? { error: FRAME_CHECK_ERROR, http_status: 404, reason: "frame_check" }
|
|
28
|
+
: { error: `the device holds no run ${runId}: ${trimTail(String(post.error))}. Call run_test_case again`, run_id: runId, reason: "not_listed" };
|
|
29
|
+
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, reason: "may_have_started" };
|
|
29
30
|
}
|
|
30
31
|
export async function handleRunTestCase(args, call, dir = testCaseDir(), newRunId = randomUUID, now = Date.now) {
|
|
31
32
|
if (typeof args.case !== "string" || !args.case)
|
|
@@ -71,7 +72,7 @@ export async function handleGetTestRun(args, call, sleep = (ms) => new Promise((
|
|
|
71
72
|
for (;;) {
|
|
72
73
|
data = notFound(await call(runPath(id), { timeoutMs: POLL_TIMEOUT_MS, deadlineMs: now() + POLL_TIMEOUT_MS, reportLost: true }), id);
|
|
73
74
|
if (isRequestFailure(data)) {
|
|
74
|
-
return result(data.http_status === 404 && lastState === "starting" ? { ...data, error: FRAME_CHECK_ERROR } : data);
|
|
75
|
+
return result(data.http_status === 404 && lastState === "starting" ? { ...data, error: FRAME_CHECK_ERROR, reason: "frame_check" } : data);
|
|
75
76
|
}
|
|
76
77
|
lastState = data.state;
|
|
77
78
|
if (data.settled === true)
|
|
@@ -93,3 +94,55 @@ export async function handleStopTestRun(args, call) {
|
|
|
93
94
|
const id = args.run_id;
|
|
94
95
|
return result(notFound(await call(runPath(id), { method: "DELETE" }), id));
|
|
95
96
|
}
|
|
97
|
+
const IDS_ERROR = "ids is required, 1 to 200 RTM event ids from get_recent_rtm_events";
|
|
98
|
+
const fail = (error, extra = {}) => ({ data: { error, ...extra }, isError: true });
|
|
99
|
+
export function handleListTestCases(dir = testCaseDir()) {
|
|
100
|
+
return { data: listCases(dir), isError: false };
|
|
101
|
+
}
|
|
102
|
+
export async function handleSaveTestCase(args, call, dir = testCaseDir()) {
|
|
103
|
+
const { ids } = args;
|
|
104
|
+
if (!Array.isArray(ids) || ids.length < 1 || ids.length > 200 || !ids.every((id) => Number.isInteger(id) && id >= 0))
|
|
105
|
+
return fail(IDS_ERROR, { reason: "bad_ids" });
|
|
106
|
+
const repeat = args.repeat ?? 1;
|
|
107
|
+
if (typeof repeat !== "number" || !Number.isInteger(repeat) || repeat < 1)
|
|
108
|
+
return fail("repeat must be a whole number, 1 or more");
|
|
109
|
+
const rate = "rate_per_second" in args ? args.rate_per_second : 10;
|
|
110
|
+
if (rate !== null && (typeof rate !== "number" || !Number.isInteger(rate) || rate < 1 || rate > 1000))
|
|
111
|
+
return fail("rate_per_second must be a whole number from 1 to 1000, or null for a burst");
|
|
112
|
+
if (typeof args.name !== "string" || !args.name)
|
|
113
|
+
return fail("name is required: letters, digits, _ or -, up to 64");
|
|
114
|
+
const problem = checkCaseName(args.name, args.overwrite === true, dir);
|
|
115
|
+
if (problem)
|
|
116
|
+
return fail(problem.error, { reason: problem.reason });
|
|
117
|
+
const records = [];
|
|
118
|
+
const missing = [];
|
|
119
|
+
for (const id of [...new Set(ids)]) {
|
|
120
|
+
const data = await call(`/api/rtm/${id}`);
|
|
121
|
+
if (data.http_status === 404) {
|
|
122
|
+
missing.push(id);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (isRequestFailure(data))
|
|
126
|
+
return { data, isError: true };
|
|
127
|
+
records.push({ ...data, id });
|
|
128
|
+
}
|
|
129
|
+
const captured = captureCase(records);
|
|
130
|
+
if (captured.events.length === 0) {
|
|
131
|
+
return fail("none of these events can be replayed", { kept: captured.kept, dropped: captured.dropped, missing });
|
|
132
|
+
}
|
|
133
|
+
const caseDef = { repeat, rate_per_second: rate, events: captured.events };
|
|
134
|
+
const saved = saveCase(args.name, caseDef, args.overwrite === true, dir);
|
|
135
|
+
if ("error" in saved)
|
|
136
|
+
return fail(saved.error, saved.reason ? { reason: saved.reason } : {});
|
|
137
|
+
return {
|
|
138
|
+
isError: false,
|
|
139
|
+
data: {
|
|
140
|
+
saved: saved.path, events: captured.events.length, repeat, rate_per_second: rate, kept: captured.kept,
|
|
141
|
+
...(Object.keys(captured.dropped).length ? { dropped: captured.dropped } : {}),
|
|
142
|
+
...(Object.keys(captured.removed).length ? { removed_block_fields: captured.removed } : {}),
|
|
143
|
+
...(missing.length ? { missing } : {}),
|
|
144
|
+
...(captured.seeded ? { seeded: true } : {}),
|
|
145
|
+
...(captured.targets > 1 ? { note: `the updates edited ${captured.targets} different messages; the case replays them all against one seeded message per iteration` } : {}),
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
}
|
package/dist/mcp/tools.js
CHANGED
|
@@ -131,7 +131,7 @@ export const TOOL_DEFINITIONS = [
|
|
|
131
131
|
},
|
|
132
132
|
{
|
|
133
133
|
name: "get_recent_rtm_events",
|
|
134
|
-
description: "Get recent RTM (Real Time Messaging) event summaries. Use when the user asks 'what just happened' / 'what's going on' (with get_recent_network_calls). Event types use subtypes when there is one (message_changed, not message).",
|
|
134
|
+
description: "Get recent RTM (Real Time Messaging) event summaries. Use when the user asks 'what just happened' / 'what's going on' (with get_recent_network_calls). Event types use subtypes when there is one (message_changed, not message). Pass ids to save_test_case to keep them as a replay case.",
|
|
135
135
|
inputSchema: {
|
|
136
136
|
type: "object",
|
|
137
137
|
properties: {
|
|
@@ -239,7 +239,7 @@ export const TOOL_DEFINITIONS = [
|
|
|
239
239
|
},
|
|
240
240
|
{
|
|
241
241
|
name: "get_switchboard_session",
|
|
242
|
-
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, speaking and user_speaking transitions (state_kind, from, to, cause) with Server:<code> and SwipedAway causes; 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, hold_refuse, reply_hold, reply_unhold, read_stall, pre_ready_drop with gap_ms, bytes_queued, dropped_chunks; phase = startup phase durations (phase, duration_ms); session = begin, end, ready (server_session_id), config (mic_encoding); 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; reconnect_try = trigger (restart, drop, settings), try, outcome (ready, retry, refused, gave_up, where try counts tries made and 0 means the budget was already spent); a Reconnecting state's cause is its trigger; card = card_kind (tool_approval, auth_prompt), event (shown, answered, refused, declined, closed, replaced, expired, cleared, carried), by (tap, server), card_id; a card shown or carried
|
|
242
|
+
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, speaking and user_speaking transitions (state_kind, from, to, cause) with Server:<code> and SwipedAway causes; 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, hold_refuse, reply_hold, reply_unhold, read_stall, pre_ready_drop with gap_ms, bytes_queued, dropped_chunks; phase = startup phase durations (phase, duration_ms); session = begin, end, ready (server_session_id), config (mic_encoding); 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; reconnect_try = trigger (restart, drop, settings), try, outcome (ready, retry, refused, gave_up, where try counts tries made and 0 means the budget was already spent); a Reconnecting state's cause is its trigger; card = card_kind (tool_approval, auth_prompt), event (shown, answered, refused, answer_failed, declined, closed, replaced, expired, cleared, carried), by (tap, server), card_id; a card shown or carried and not taken down since was still up at the session's last record. Summary server_session_ids lists ready ids. For saved_turn, no_line means no subtitle line still held the item and the turn is still kept; 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). Pass kind to narrow (player for stutter, state for mic and connection, phase for slow start, levels for meter history); the limit applies after the kind filter; total_captured counts every kind. For the whole session use export_switchboard_session or query_session under source switchboard.",
|
|
243
243
|
inputSchema: {
|
|
244
244
|
type: "object",
|
|
245
245
|
properties: {
|
|
@@ -398,7 +398,7 @@ export const TOOL_DEFINITIONS = [
|
|
|
398
398
|
{
|
|
399
399
|
name: "open_radar_dashboard",
|
|
400
400
|
description: "Build or refine a custom live dashboard tab in the Slack Radar web UI from a spec YOU author. " +
|
|
401
|
-
"Suggest this when the user describes a live view the pre-built tabs (Live/Network/RTM/Clogs/Traces/Logs/Switchboard, plus the Database, Preferences
|
|
401
|
+
"Suggest this when the user describes a live view the pre-built tabs (Live/Network/RTM/Clogs/Traces/Logs/Switchboard, plus the Database, Preferences, Feature Flags and Test cases browsers) do not cover " +
|
|
402
402
|
"(e.g. 'graph calls per second vs response time and flag slow ones', 'beep when I get a DM'); invoke it once they agree. " +
|
|
403
403
|
"Translate the request into the spec fields below and call this tool; it ensures the web dashboard is " +
|
|
404
404
|
"running (default http://localhost:8100, or the port set in SLACK_RADAR_WEB_PORT) and renders your spec as a 'Custom' tab, then returns the URL to share. " +
|
|
@@ -668,6 +668,28 @@ export const TOOL_DEFINITIONS = [
|
|
|
668
668
|
inputSchema: { type: "object", properties: { run_id: { type: "string" } }, required: ["run_id"] },
|
|
669
669
|
annotations: { readOnlyHint: false, idempotentHint: true },
|
|
670
670
|
},
|
|
671
|
+
{
|
|
672
|
+
name: "save_test_case",
|
|
673
|
+
description: "Save RTM events you captured as a replay case under ~/.slack-radar/test-cases/<name>.json. ids come from get_recent_rtm_events. Only message, message_changed and message_replied frames from the server are kept. Channel, ts, user, client and file ids become test values and all text becomes filler of the same length, so the file holds no real ids or text. Every iteration replays the updates against one seeded message. Pass overwrite to replace a file or a built-in name. Then call run_test_case with the name.",
|
|
674
|
+
inputSchema: {
|
|
675
|
+
type: "object",
|
|
676
|
+
properties: {
|
|
677
|
+
name: { type: "string", description: "Case name, letters, digits, _ or -, up to 64." },
|
|
678
|
+
ids: { type: "array", items: { type: "integer", minimum: 0 }, minItems: 1, maxItems: 200, description: "RTM event ids from get_recent_rtm_events." },
|
|
679
|
+
repeat: { type: "integer", minimum: 1, description: "Times the events are sent. Default 1." },
|
|
680
|
+
rate_per_second: { type: ["integer", "null"], minimum: 1, maximum: 1000, description: "Frames a second, 1 to 1000, or null for a burst. Default 10." },
|
|
681
|
+
overwrite: { type: "boolean", description: "Replace an existing file or a built-in name. Default false." },
|
|
682
|
+
},
|
|
683
|
+
required: ["name", "ids"],
|
|
684
|
+
},
|
|
685
|
+
annotations: { readOnlyHint: false },
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
name: "list_test_cases",
|
|
689
|
+
description: "List the built-in and saved replay cases with repeat, rate, event count and counts by type. A file that cannot load shows its error.",
|
|
690
|
+
inputSchema: { type: "object", properties: {} },
|
|
691
|
+
annotations: { readOnlyHint: true },
|
|
692
|
+
},
|
|
671
693
|
];
|
|
672
694
|
/**
|
|
673
695
|
* Check whether a tool call should be blocked by the session gate.
|