@slack/radar-mcp 1.20.0 → 1.22.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 (91) hide show
  1. package/README.md +75 -17
  2. package/dist/mcp/api-paths.d.ts +11 -0
  3. package/dist/mcp/api-paths.js +56 -20
  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 +138 -36
  7. package/dist/mcp/logs-result.d.ts +1 -0
  8. package/dist/mcp/logs-result.js +1 -0
  9. package/dist/mcp/network-detail.d.ts +5 -0
  10. package/dist/mcp/network-detail.js +86 -0
  11. package/dist/mcp/radar-export-get.d.ts +30 -0
  12. package/dist/mcp/radar-export-get.js +49 -0
  13. package/dist/mcp/radar-response.d.ts +11 -1
  14. package/dist/mcp/radar-response.js +23 -3
  15. package/dist/mcp/session-backfill.d.ts +9 -3
  16. package/dist/mcp/session-backfill.js +76 -17
  17. package/dist/mcp/session-detail.js +54 -2
  18. package/dist/mcp/session-enable.d.ts +1 -0
  19. package/dist/mcp/session-enable.js +146 -15
  20. package/dist/mcp/session-query.js +53 -11
  21. package/dist/mcp/snapshot.js +42 -26
  22. package/dist/mcp/sources-gate.js +5 -0
  23. package/dist/mcp/stale-dashboard.d.ts +23 -0
  24. package/dist/mcp/stale-dashboard.js +122 -0
  25. package/dist/mcp/switchboard-spool.d.ts +12 -0
  26. package/dist/mcp/switchboard-spool.js +107 -0
  27. package/dist/mcp/switchboard-tools.d.ts +18 -0
  28. package/dist/mcp/switchboard-tools.js +178 -0
  29. package/dist/mcp/tools.d.ts +4 -1
  30. package/dist/mcp/tools.js +114 -23
  31. package/dist/mcp/web-child-env.d.ts +4 -1
  32. package/dist/mcp/web-child-env.js +4 -1
  33. package/dist/shared/android.d.ts +43 -0
  34. package/dist/shared/android.js +227 -19
  35. package/dist/shared/constants.d.ts +19 -4
  36. package/dist/shared/constants.js +19 -4
  37. package/dist/shared/event-spool.js +3 -2
  38. package/dist/shared/feature-flags.d.ts +1 -0
  39. package/dist/shared/feature-flags.js +1 -0
  40. package/dist/shared/form-body.d.ts +18 -0
  41. package/dist/shared/form-body.js +251 -0
  42. package/dist/shared/ios-logs.d.ts +10 -0
  43. package/dist/shared/ios-logs.js +91 -0
  44. package/dist/shared/ios.d.ts +25 -2
  45. package/dist/shared/ios.js +157 -3
  46. package/dist/{web → shared}/log-session.d.ts +45 -31
  47. package/dist/shared/log-session.js +300 -0
  48. package/dist/shared/radar-request-raw.d.ts +7 -0
  49. package/dist/shared/radar-request-raw.js +89 -0
  50. package/dist/shared/radar-token.d.ts +25 -0
  51. package/dist/shared/radar-token.js +164 -0
  52. package/dist/shared/stream.d.ts +4 -1
  53. package/dist/shared/stream.js +107 -15
  54. package/dist/shared/switchboard-host-store.d.ts +21 -0
  55. package/dist/shared/switchboard-host-store.js +166 -0
  56. package/dist/shared/switchboard-note.d.ts +15 -0
  57. package/dist/shared/switchboard-note.js +92 -0
  58. package/dist/shared/switchboard-report-file.d.ts +5 -0
  59. package/dist/shared/switchboard-report-file.js +26 -0
  60. package/dist/shared/switchboard-report.d.ts +20 -0
  61. package/dist/shared/switchboard-report.js +406 -0
  62. package/dist/shared/switchboard.d.ts +118 -0
  63. package/dist/shared/switchboard.js +487 -0
  64. package/dist/shared/transport.d.ts +43 -3
  65. package/dist/shared/version.d.ts +2 -0
  66. package/dist/shared/version.js +18 -0
  67. package/dist/shared/wire.d.ts +46 -1
  68. package/dist/web/install-app.d.ts +57 -8
  69. package/dist/web/install-app.js +270 -60
  70. package/dist/web/macapp/RadarApp.swift +340 -22
  71. package/dist/web/public/index.html +216 -12
  72. package/dist/web/public/next/app.js +43 -22
  73. package/dist/web/public/next/db.js +4 -1
  74. package/dist/web/public/next/feed.js +604 -59
  75. package/dist/web/public/next/filters.js +158 -40
  76. package/dist/web/public/next/flags.js +3 -0
  77. package/dist/web/public/next/form-body.js +252 -0
  78. package/dist/web/public/next/inspector.js +171 -14
  79. package/dist/web/public/next/prefs.js +5 -2
  80. package/dist/web/public/next/registry.js +35 -3
  81. package/dist/web/public/next/store.js +947 -69
  82. package/dist/web/public/next/switchboard-note.js +93 -0
  83. package/dist/web/public/next/toast.js +9 -5
  84. package/dist/web/public/next/voice-model.js +712 -0
  85. package/dist/web/public/next/voice.js +552 -0
  86. package/dist/web/server.d.ts +20 -9
  87. package/dist/web/server.js +834 -174
  88. package/dist/web/spec.d.ts +11 -6
  89. package/dist/web/spec.js +62 -6
  90. package/package.json +4 -4
  91. package/dist/web/log-session.js +0 -166
@@ -5,8 +5,9 @@
5
5
  import { html } from "./html.js";
6
6
  import { useState, useEffect } from "preact/hooks";
7
7
  import { esc } from "./esc.js";
8
- import { shortUrl, store } from "./store.js";
8
+ import { fmtNum, shortUrl, store } from "./store.js";
9
9
  import { hasDetailEndpoint, SOURCES } from "./registry.js";
10
+ import { decodeFormBody, formBodyLooksTruncated, formContentType, jsonTextLooksCut } from "./form-body.js";
10
11
  function shq(s) {
11
12
  return "'" + String(s).replace(/'/g, "'\\''") + "'";
12
13
  }
@@ -48,7 +49,7 @@ export function highlightJson(value, indent = 0) {
48
49
  if (!value.length)
49
50
  return "[]";
50
51
  const items = value.map((v) => padIn + highlightJson(v, indent + 1));
51
- return "[\n" + items.join(",\n") + "\n" + pad + "]";
52
+ return fold("[", "]", items, pad, plural(items.length, "item"));
52
53
  }
53
54
  if (t === "object") {
54
55
  const obj = value;
@@ -56,10 +57,76 @@ export function highlightJson(value, indent = 0) {
56
57
  if (!keys.length)
57
58
  return "{}";
58
59
  const items = keys.map((k) => padIn + '<span class="j-key">"' + esc(k) + '"</span>: ' + highlightJson(obj[k], indent + 1));
59
- return "{\n" + items.join(",\n") + "\n" + pad + "}";
60
+ return fold("{", "}", items, pad, plural(items.length, "key"));
60
61
  }
61
62
  return esc(String(value));
62
63
  }
64
+ // The caret is drawn by CSS (::before), so selecting and copying the text yields plain JSON.
65
+ function fold(open, close, items, pad, count) {
66
+ return '<span class="j-fold"><button type="button" class="j-tog" aria-expanded="true" title="' + foldTitle(false) + '"></button>' + open +
67
+ '<span class="j-inner">\n' + items.join(",\n") + "\n" + pad + "</span>" +
68
+ '<span class="j-ell"> … ' + count + " </span>" + close + "</span>";
69
+ }
70
+ // Delegated click for every highlightJson <pre>: the markup is raw HTML, so it has no handlers
71
+ // of its own. Alt-click applies the same state to every nested fold.
72
+ export function onJsonFoldClick(e) {
73
+ const target = e.target;
74
+ if (!target?.classList?.contains("j-tog") && !target?.classList?.contains("j-ell"))
75
+ return;
76
+ const node = target.parentElement;
77
+ if (!node)
78
+ return;
79
+ const closed = !node.classList.contains("j-closed");
80
+ setFold(node, closed);
81
+ if (e.altKey)
82
+ node.querySelectorAll(".j-fold").forEach((n) => setFold(n, closed));
83
+ }
84
+ // A collapsed fold's contents are display:none, so the browser copies its "… N keys"
85
+ // placeholder instead. The hidden nodes are still in the selected range: copy them and drop
86
+ // the placeholders. A selection that also takes in other text keeps the browser's own copy.
87
+ export function onJsonCopy(e) {
88
+ const sel = window.getSelection();
89
+ const pre = e.currentTarget;
90
+ if (!sel || sel.isCollapsed || !sel.rangeCount || !e.clipboardData)
91
+ return;
92
+ const range = clampToPre(sel.getRangeAt(0), pre);
93
+ if (!range)
94
+ return;
95
+ e.clipboardData.setData("text/plain", jsonCopyText(range.cloneContents()));
96
+ e.preventDefault();
97
+ }
98
+ // A triple-click, or a drag past a one-line collapsed root, ends the range at the start of the
99
+ // next block, just outside the <pre>. Trim that overshoot when it adds no text.
100
+ function clampToPre(range, pre) {
101
+ const r = range.cloneRange();
102
+ let outside = "";
103
+ if (!pre.contains(r.startContainer)) {
104
+ const before = range.cloneRange();
105
+ before.setEnd(pre, 0);
106
+ outside += before.toString();
107
+ r.setStart(pre, 0);
108
+ }
109
+ if (!pre.contains(r.endContainer)) {
110
+ const after = range.cloneRange();
111
+ after.setStart(pre, pre.childNodes.length);
112
+ outside += after.toString();
113
+ r.setEnd(pre, pre.childNodes.length);
114
+ }
115
+ return outside.trim() ? null : r;
116
+ }
117
+ export function jsonCopyText(root) {
118
+ for (const cls of [".j-ell", ".j-tog"])
119
+ root.querySelectorAll(cls).forEach((n) => n.parentNode?.removeChild(n));
120
+ return root.textContent ?? "";
121
+ }
122
+ function setFold(node, closed) {
123
+ node.classList.toggle("j-closed", closed);
124
+ node.firstElementChild?.setAttribute("aria-expanded", String(!closed));
125
+ node.firstElementChild?.setAttribute("title", foldTitle(closed));
126
+ }
127
+ function foldTitle(closed) {
128
+ return (closed ? "Unfold" : "Fold") + " (Alt-click: all nested)";
129
+ }
63
130
  function Section({ title, sub, children, open }) {
64
131
  const [isOpen, setOpen] = useState(open !== false);
65
132
  return html `
@@ -73,11 +140,57 @@ function Section({ title, sub, children, open }) {
73
140
  </div>
74
141
  `;
75
142
  }
143
+ function JsonPre({ value }) {
144
+ return html `<pre class="json" onClick=${onJsonFoldClick} onCopy=${onJsonCopy} dangerouslySetInnerHTML=${{ __html: highlightJson(value, 0) }}></pre>`;
145
+ }
146
+ // A decoded form body: one row per field, a JSON-valued field in its own collapsible subtree
147
+ // through the same highlighter the JSON body uses, everything else as its decoded text.
148
+ function FormFields({ form, truncated }) {
149
+ return html `
150
+ ${truncated ? html `<div class="trunc">${formTruncationNote(form)}</div>` : null}
151
+ <div class="formnote">form body, decoded; Copy cURL carries the raw bytes</div>
152
+ <div class="kv formkv">
153
+ ${form.fields.map((f) => hasEntries(f.json)
154
+ ? html `<div class="kv-k formkey">${f.key}</div><div class="kv-v"><${Section} title="json" sub=${Array.isArray(f.json) ? plural(f.json.length, "item") : plural(Object.keys(f.json).length, "key")}><${JsonPre} value=${f.json} /><//></div>`
155
+ : formValue(f))}
156
+ </div>
157
+ `;
158
+ }
159
+ function formValue(f) {
160
+ const text = f.json !== undefined ? JSON.stringify(f.json) : f.value;
161
+ // A lone space would render as a blank cell, indistinguishable from a missing value, and the
162
+ // two are different facts about the request.
163
+ const shown = text.length === 0 ? "(empty)" : text.trim() === "" ? "(whitespace only)" : null;
164
+ if (shown !== null)
165
+ return html `<div class="kv-k formkey">${f.key}</div><div class="kv-v formval empty">${shown}</div>`;
166
+ // JSON the decoder left unparsed shows as the string it is, with the reason, so the flat text
167
+ // is not mistaken for a value the request sent flat.
168
+ if (f.unparsedReason)
169
+ return html `<div class="kv-k formkey">${f.key}</div><div class="kv-v formval"><div class="formunparsed">${f.unparsedReason}</div>${text}</div>`;
170
+ return html `<div class="kv-k formkey">${f.key}</div><div class="kv-v formval">${text}</div>`;
171
+ }
172
+ // Name the field the device cap cut. When the cut landed inside a field name that name is gone,
173
+ // so the note points at the last field that survived instead.
174
+ function formTruncationNote(form) {
175
+ const last = form.fields[form.fields.length - 1]?.key;
176
+ if (form.truncated)
177
+ return `⚠ truncated by the device cap; complete through ${last}, the rest is missing`;
178
+ return `⚠ truncated by the device cap; ${last} is partial`;
179
+ }
180
+ function plural(n, noun) {
181
+ return n === 1 ? `1 ${noun}` : `${n} ${noun}s`;
182
+ }
183
+ // An empty {} or [] reads better inline than as a collapsible with nothing in it.
184
+ function hasEntries(v) {
185
+ return typeof v === "object" && v !== null && (Array.isArray(v) ? v.length : Object.keys(v).length) > 0;
186
+ }
76
187
  function Body({ parsed }) {
77
188
  const v = parsed.value;
78
189
  if (v && typeof v === "object") {
79
- return html `<pre class="json" dangerouslySetInnerHTML=${{ __html: highlightJson(v, 0) }}></pre>`;
190
+ return html `<${JsonPre} value=${v} />`;
80
191
  }
192
+ if (parsed.form)
193
+ return html `<${FormFields} form=${parsed.form} truncated=${parsed.truncated} />`;
81
194
  return html `
82
195
  ${parsed.truncated ? html `<div class="trunc">⚠ truncated by the device cap</div>` : null}
83
196
  <pre class="json rawbody">${String(v)}</pre>
@@ -89,20 +202,47 @@ function KV({ map }) {
89
202
  return null;
90
203
  return html `<div class="kv">${keys.map((k) => html `<div class="kv-k">${k}</div><div class="kv-v">${String(map[k])}</div>`)}</div>`;
91
204
  }
92
- // Parse a body. A string that does not parse AND looks cut off (starts like JSON, ends
93
- // mid-token) is flagged truncated -- the on-device interceptor caps bodies (installed build at
94
- // 8KB), so large JSON arrives clipped. We show it as readable text with a banner.
205
+ // Parse a body. A string that does not parse AND looks cut off (starts like JSON, ends inside an
206
+ // open bracket or string) is flagged truncated -- the on-device interceptor caps bodies at 1 MB
207
+ // (NetworkRadarPlugin's MAX_BODY_SIZE), so a very large JSON body arrives clipped. We show it as
208
+ // readable text with a banner. The same rule sets request_body_truncated on the MCP side.
95
209
  export function parseBody(v) {
210
+ return parse(v, false);
211
+ }
212
+ // The request body is the only place a form-encoded string (Slack API POSTs) belongs; it keeps
213
+ // its raw value and carries the decoded fields alongside. A response body, clog payload or trace
214
+ // tags that happen to look like `a=1&b=2` render as the text they are. `contentType` is the
215
+ // record's request_content_type and `deviceCut` its request_body_truncated, when the build emits
216
+ // them: the type settles the form question and the flag settles the banner (shape cannot see a
217
+ // body clipped inside a plain value); an older build without them falls back to the shape rules.
218
+ export function parseRequestBody(v, contentType, deviceCut) {
219
+ const parsed = parse(v, true, contentType);
220
+ if (typeof deviceCut !== "boolean" || typeof v !== "string")
221
+ return parsed;
222
+ // A cut the device reports on a body that parsed as whole JSON is still a cut: show the text.
223
+ if (deviceCut && parsed.value !== v && !parsed.form)
224
+ return { value: v, truncated: true, bytes: v.length };
225
+ return { ...parsed, truncated: deviceCut };
226
+ }
227
+ function parse(v, decodeForm, contentType) {
96
228
  if (typeof v !== "string")
97
229
  return { value: v, truncated: false };
98
230
  const s = v.trim();
231
+ // A declared form body is a form before it is anything else: a body `true` or `123` under a
232
+ // form Content-Type is a field named true, the same answer the MCP gives.
233
+ if (decodeForm && formContentType(contentType) === true) {
234
+ const form = decodeFormBody(v, contentType);
235
+ if (form)
236
+ return { value: v, truncated: formBodyLooksTruncated(form), form };
237
+ }
99
238
  try {
100
239
  return { value: JSON.parse(s), truncated: false };
101
240
  }
102
241
  catch {
103
- const looksJson = s.startsWith("{") || s.startsWith("[");
104
- const looksCut = looksJson && !(s.endsWith("}") || s.endsWith("]"));
105
- return { value: v, truncated: looksCut, bytes: v.length };
242
+ const form = decodeForm ? decodeFormBody(v, contentType) : null;
243
+ if (form)
244
+ return { value: v, truncated: formBodyLooksTruncated(form), form };
245
+ return { value: v, truncated: jsonTextLooksCut(s, contentType), bytes: v.length };
106
246
  }
107
247
  }
108
248
  export function statusClass(code) {
@@ -129,7 +269,7 @@ export function Inspector({ ev, onClose }) {
129
269
  if (ev.id == null || !hasDetailEndpoint(kind))
130
270
  return;
131
271
  // read-through the store's shared cache (eager-capture + prior click-fetches land there).
132
- const cached = store.getDetail(kind, ev.id);
272
+ const cached = store.getDetail(kind, ev);
133
273
  if (cached) {
134
274
  setDetail({ ...ev, ...cached, _type: kind });
135
275
  return;
@@ -148,7 +288,7 @@ export function Inspector({ ev, onClose }) {
148
288
  return;
149
289
  }
150
290
  const merged = { ...ev, ...d, _type: kind };
151
- store.cacheDetail(kind, ev.id, merged);
291
+ store.cacheDetail(kind, ev, merged);
152
292
  setDetail(merged);
153
293
  })
154
294
  .catch(() => { })
@@ -159,7 +299,7 @@ export function Inspector({ ev, onClose }) {
159
299
  }, [ev]);
160
300
  const kind = ev._type || "";
161
301
  const isNet = kind === "network" || detail.url != null || detail.method != null;
162
- const title = ev.trace_name || ev.event_name || ev.event_type || shortUrl(ev.url) || kind || "detail";
302
+ const title = kind === "switchboard" ? `switchboard ${ev.kind || ""}`.trim() : ev.trace_name || ev.event_name || ev.event_type || shortUrl(ev.url) || kind || "detail";
163
303
  const copy = (which, e) => {
164
304
  let text = "";
165
305
  if (which === "json")
@@ -215,7 +355,19 @@ export function Inspector({ ev, onClose }) {
215
355
  if (ev.package)
216
356
  badges.push(html `<span class="ibadge">${ev.package}</span>`);
217
357
  }
218
- const reqBody = parseBody(detail.request_body ?? detail.requestBody);
358
+ else if (kind === "switchboard") {
359
+ // The session, (for frames) the direction and (for phases) the duration up top, next to the
360
+ // time badge every kind gets; the kind is already in the title. Every other field of the record
361
+ // lands in "other fields" below. The duration badge exists because duration_ms is omitted from that dump for the
362
+ // network and trace rows, and a phase record's one number must not vanish with it.
363
+ if (ev.session_id != null)
364
+ badges.push(html `<span class="ibadge">session ${String(ev.session_id)}</span>`);
365
+ if (ev.direction)
366
+ badges.push(html `<span class=${"ibadge dir-" + ev.direction}>${ev.direction}</span>`);
367
+ if (ev.duration_ms != null)
368
+ badges.push(html `<span class="ibadge">${fmtNum(Number(ev.duration_ms))} ms</span>`);
369
+ }
370
+ const reqBody = parseRequestBody(detail.request_body ?? detail.requestBody, detail.request_content_type, detail.request_body_truncated);
219
371
  const resBody = parseBody(detail.response_body ?? detail.responseBody);
220
372
  const reqHeaders = (detail.request_headers || detail.requestHeaders);
221
373
  const resHeaders = (detail.response_headers || detail.responseHeaders);
@@ -234,6 +386,11 @@ export function Inspector({ ev, onClose }) {
234
386
  ]);
235
387
  if (traceTags)
236
388
  omit.add("tags"); // rendered in its own section below
389
+ // The kind is in the title with the record's repeated `type`, the session is a badge, so a
390
+ // switchboard dump carries only the fields the header does not already show.
391
+ if (kind === "switchboard")
392
+ for (const k of ["kind", "session_id", "type"])
393
+ omit.add(k);
237
394
  const rest = {};
238
395
  for (const k of Object.keys(detail))
239
396
  if (!omit.has(k))
@@ -11,7 +11,7 @@
11
11
  import { html } from "./html.js";
12
12
  import { useState, useEffect, useCallback, useRef } from "preact/hooks";
13
13
  import { useLatestRef, useGlobalKeydown } from "./hooks.js";
14
- import { highlightJson } from "./inspector.js";
14
+ import { highlightJson, onJsonCopy, onJsonFoldClick } from "./inspector.js";
15
15
  function profileLabel(u) {
16
16
  return u === "" || u == null ? "device" : u === "0" ? "personal (user 0)" : "secondary (user " + u + ")";
17
17
  }
@@ -153,6 +153,9 @@ export function PrefsBrowser({ spec }) {
153
153
  const t = e.target;
154
154
  if (t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.tagName === "SELECT" || t.isContentEditable))
155
155
  return;
156
+ // A focused button (a JSON fold caret, Copy, Close) owns its Enter and Space, as in the feed.
157
+ if (t?.tagName === "BUTTON" && (e.key === "Enter" || e.key === " "))
158
+ return;
156
159
  if (e.metaKey || e.ctrlKey || e.altKey)
157
160
  return;
158
161
  const s = st.current;
@@ -387,7 +390,7 @@ function PrefsGrid({ rows, rowOffset = 0, expandedIdx = null, onToggleExpanded,
387
390
  <button onClick=${() => onToggleExpanded?.(globalIdx)}>Close</button>
388
391
  </div>
389
392
  ${parsed !== null
390
- ? html `<pre class="valpretty" dangerouslySetInnerHTML=${{ __html: highlightJson(parsed) }}></pre>`
393
+ ? html `<pre class="valpretty" onClick=${onJsonFoldClick} onCopy=${onJsonCopy} dangerouslySetInnerHTML=${{ __html: highlightJson(parsed) }}></pre>`
391
394
  : html `<pre class="valpretty">${valueStr}</pre>`}
392
395
  </td>
393
396
  </tr>`
@@ -2,6 +2,14 @@
2
2
  // edits across many hardcoded conditionals (the vanilla index.html debt). The app reads these
3
3
  // to drive the modebar, the Filters source select + field lists, the feed sort options, the
4
4
  // per-source detail fetch, and which widget components to mount.
5
+ // The caps on `exclude`. Mirrors the server's caps in src/web/spec.ts, which the browser build
6
+ // cannot import; the toolbar, the Filters panel and the view memory all read these.
7
+ export const EXCLUDE_MAX_TERMS = 20;
8
+ export const EXCLUDE_MAX_TERM_LENGTH = 200;
9
+ // Logcat-scale retention window for the store's cache ring. Lives here, not in store.ts, so
10
+ // voice-model.ts (which must stay DOM-free and store-free to run its tests with no runtime) can
11
+ // read it without importing the store itself.
12
+ export const CACHE_TTL_MS = 60 * 60 * 1000;
5
13
  // Match-fields the Filters panel offers per source. `all` is derived as the union below, so a
6
14
  // new source's fields show up in the unified view with no extra edit.
7
15
  export const MATCH_FIELDS = {
@@ -12,14 +20,18 @@ export const MATCH_FIELDS = {
12
20
  // No `level` here: a substring on the level name next to the toolbar's "level ≥" floor was two
13
21
  // controls with one word and different meanings. A spec that already carries match.level still
14
22
  // works and still shows as a row (the row select keeps an unknown field), it is just not offered.
15
- log: ["tag", "message", "pid", "package"],
23
+ log: ["tag", "message", "pid", "package", "subsystem", "process"],
24
+ // The voice transport's records: `kind` picks the record shape, the rest are that shape's key
25
+ // fields (frame: direction/frame_type, state: state_kind, phase: phase, session/player: event,
26
+ // turn: clock, saved_turn: outcome).
27
+ switchboard: ["kind", "session_id", "direction", "frame_type", "state_kind", "phase", "event", "clock", "outcome"],
16
28
  };
17
29
  // `all` = the union of every streaming source's fields (deduped, order-stable). Derived, not
18
30
  // hand-maintained, so adding a source's fields above surfaces them in the unified Live tab too.
19
31
  MATCH_FIELDS.all = (() => {
20
32
  const seen = new Set();
21
33
  const out = [];
22
- for (const src of ["network", "rtm", "clog", "trace", "log"]) {
34
+ for (const src of ["network", "rtm", "clog", "trace", "log", "switchboard"]) {
23
35
  for (const f of MATCH_FIELDS[src])
24
36
  if (!seen.has(f)) {
25
37
  seen.add(f);
@@ -50,6 +62,10 @@ export const SOURCES = {
50
62
  clog: { label: "Clogs", kind: "stream", origin: "device", hasDetailEndpoint: true, eagerCapture: true, ringSize: 1000, detailNoun: "the full payload" },
51
63
  trace: { label: "Traces", kind: "stream", origin: "device", hasDetailEndpoint: true, ringSize: 2000, detailNoun: "the span timing and tag detail" },
52
64
  log: { label: "Logs", kind: "stream", origin: "host", hasDetailEndpoint: false },
65
+ // The Slackbot voice transport's event stream. Device-produced (so a frame is proof the device
66
+ // is answering), but there is no per-record /detail: the device keys its endpoints by session,
67
+ // and every field a record has already rides on the stream row.
68
+ switchboard: { label: "Switchboard", kind: "stream", origin: "device", hasDetailEndpoint: false },
53
69
  all: { label: "Live", kind: "stream", origin: "alias" },
54
70
  db: { label: "Database", kind: "state", origin: "device" },
55
71
  prefs: { label: "Preferences", kind: "state", origin: "device" },
@@ -69,6 +85,18 @@ export const STREAM_KINDS = Object.entries(SOURCES)
69
85
  export const DEVICE_STREAM_KINDS = Object.entries(SOURCES)
70
86
  .filter(([, v]) => v.kind === "stream" && v.origin === "device")
71
87
  .map(([k]) => k);
88
+ // Plugin discovery and some iOS observer builds use route/source names, while the dashboard
89
+ // row model uses singular event kinds. Backfill already performs this conversion through
90
+ // DEVICE_SOURCES; live SSE must do the same or rows appear only after a tab-switch backfill.
91
+ export function normalizeStreamType(type) {
92
+ if (type === "clogs")
93
+ return "clog";
94
+ if (type === "traces")
95
+ return "trace";
96
+ if (type === "feature_flags")
97
+ return "feature_flag";
98
+ return type;
99
+ }
72
100
  // The kinds that have a /detail endpoint (inspector click-fetch). Derived from
73
101
  // hasDetailEndpoint so adding a detailable source is one SOURCES edit.
74
102
  export const DETAILABLE_KINDS = Object.entries(SOURCES)
@@ -94,8 +122,12 @@ export function hasDetailEndpoint(kind) {
94
122
  // see widgets.ts). A new widget = one key here + one component.
95
123
  export const WIDGETS = ["counter", "rate", "sparkline", "graph"];
96
124
  // Source order for the modebar / global tab-switch (matches the MODES preset order).
97
- export const SOURCE_ORDER = ["all", "network", "rtm", "clog", "trace", "log", "db", "prefs", "flags"];
125
+ export const SOURCE_ORDER = ["all", "network", "rtm", "clog", "trace", "log", "switchboard", "db", "prefs", "flags"];
98
126
  // The source options the Filters panel offers: every streaming source (state sources like db/prefs
99
127
  // are their own containers, not feed filters). Derived from SOURCES so adding a streaming source
100
128
  // surfaces it in Filters with no edit there. Ordered by SOURCE_ORDER (the modebar order) for a stable, familiar list.
101
129
  export const FILTER_SOURCES = SOURCE_ORDER.filter((s) => SOURCES[s]?.kind === "stream");
130
+ // The eight switchboard record kinds, in the order the toolbar's kind chips show them. Each chip
131
+ // writes the exclude term `kind:<name>`; a spec listing that term shows the chip off. These are
132
+ // the kinds switchboardFields (store.ts) knows fields for; a test holds the two lists together.
133
+ export const SWITCHBOARD_KINDS = ["session", "state", "frame", "phase", "player", "levels", "turn", "saved_turn"];