@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
@@ -0,0 +1,93 @@
1
+ // GENERATED by scripts/mirror-shared.mjs from src/shared/switchboard-note.ts. Do not edit; edit the source.
2
+ // Kept free of imports: scripts/mirror-shared.mjs mirrors it into the browser bundle, which could
3
+ // not resolve switchboard-report.ts's Node-side import chain.
4
+ // NOTE lines are lowercase inline in the report; a caller opening a sentence with one needs this.
5
+ export function capitalizeSwitchboardNote(note) {
6
+ return note ? note.charAt(0).toUpperCase() + note.slice(1) : note;
7
+ }
8
+ // A peak at or above this is clipping. Shared here so the report and the dashboard sparkline use
9
+ // the same threshold.
10
+ export const CLIP_PEAK = 0.99;
11
+ // A turn record's `clock` in words. Shared here so the feed row and the report read the same.
12
+ // An unknown value is the device's to add, so it shows as sent rather than throwing.
13
+ const TURN_CLOCK_LABELS = {
14
+ no_card: "no card",
15
+ resumed_from_tap: "after tap",
16
+ resumed_from_server_answer: "after server answer",
17
+ };
18
+ export function switchboardClockLabel(clock) {
19
+ return Object.hasOwn(TURN_CLOCK_LABELS, clock) ? TURN_CLOCK_LABELS[clock] : clock;
20
+ }
21
+ // The saved_turn outcomes, the one list the feed row, the panel and the report read. `applied`
22
+ // (a subtitle line still held the frame's item) and `no_line` (no line held it any more, a normal
23
+ // late save, still kept) keep the turn; the drop reasons lose it. The words are the row's and the
24
+ // panel's. A server resend counts again under `applied` while its line still holds the slot, then
25
+ // under `no_line` once the line has moved on; no counting code needs the resend as its own name.
26
+ const SAVED_TURN_KEPT = { applied: "saved", no_line: "saved (line moved on)" };
27
+ const SAVED_TURN_DROPS = { missing_field: "missing field", other_session: "other session" };
28
+ const DROP_PREFIX = "dropped";
29
+ const THREAD_FLAG = "thread";
30
+ const NO_THREAD_FLAG = "no thread";
31
+ export const SAVED_TURN_DROP_OUTCOMES = Object.keys(SAVED_TURN_DROPS);
32
+ // Only these keep the turn. The panel warns on anything else, so a drop reason the device adds
33
+ // later fails closed instead of reading as a clean session.
34
+ export const SAVED_TURN_KEPT_OUTCOMES = Object.keys(SAVED_TURN_KEPT);
35
+ // The four a revision 3 build always counts, in the order the panel and the report list them.
36
+ export const SAVED_TURN_OUTCOMES = [...Object.keys(SAVED_TURN_KEPT), ...SAVED_TURN_DROP_OUTCOMES];
37
+ // Code points a free-form device string could use to fake a line break, a report boundary, or a
38
+ // hidden direction override: controls, bidi marks, zero-width characters, U+2028/2029 (a newline
39
+ // to a browser), and the BOM. Here rather than in the report so the panel strips the same set.
40
+ export const SWITCHBOARD_CONTROL_CHARS = new RegExp("[\\u0000-\\u001f\\u007f-\\u009f\\u061c\\u200b-\\u200f\\u2028\\u2029\\u202a-\\u202e\\u2066-\\u2069\\ufeff]", "g");
41
+ export function stripSwitchboardControlChars(s) {
42
+ return s.replace(SWITCHBOARD_CONTROL_CHARS, "");
43
+ }
44
+ // The words a device name could be misread by: the kept marker "saved", the retired "replaced",
45
+ // the drop prefix, the thread flag, and the known outcome names. A name is matched on its letters
46
+ // alone, lowercased, so Saved, saved_again, savedAgain, saved2 and noLine all hit, while a name
47
+ // that only shares a filler word with a label (session_closed, line_busy) stays bare.
48
+ const letters = (s) => s.toLowerCase().replace(/[^a-z]/g, "");
49
+ const SAVED_TURN_MARKERS = [...SAVED_TURN_OUTCOMES, "saved", "replaced", DROP_PREFIX, THREAD_FLAG].map(letters);
50
+ // A device-added name (an outcome, a counts key) as the panel, the feed row and the report print
51
+ // it: bare only when it is a plain token with none of the marker words in it, quoted otherwise, so
52
+ // it cannot pass for a built-in word or a count of its own. The quoted form escapes the raw name,
53
+ // anything outside printable ASCII as \uXXXX, rather than stripping it first: the escape already
54
+ // makes a control or invisible character harmless, and stripping would print two names that differ
55
+ // only by one the same.
56
+ export function switchboardDeviceToken(name) {
57
+ if (/^[A-Za-z0-9_.-]+$/.test(name) && !SAVED_TURN_MARKERS.some((m) => letters(name).includes(m)))
58
+ return name;
59
+ return JSON.stringify(name).replace(/[^\x20-\x7e]/g, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, "0")}`);
60
+ }
61
+ // An outcome in words: "saved", "saved (line moved on)", "dropped: missing field", decided on the
62
+ // raw outcome. An unknown outcome is the device's to add and prints as a device token (above).
63
+ export function savedTurnCountWord(outcome) {
64
+ if (Object.hasOwn(SAVED_TURN_KEPT, outcome))
65
+ return SAVED_TURN_KEPT[outcome];
66
+ return Object.hasOwn(SAVED_TURN_DROPS, outcome) ? `${DROP_PREFIX}: ${SAVED_TURN_DROPS[outcome]}` : switchboardDeviceToken(outcome);
67
+ }
68
+ // A saved_turn record in words, shared by the feed row and the report like the clock above. A kept
69
+ // turn reads with its thread flag; a drop reads its reason alone; an unknown outcome reads as its
70
+ // token and never gets a thread flag, so it cannot read as a kept turn. A non-string outcome reads "".
71
+ export function savedTurnLabel(outcome, hasThread) {
72
+ if (typeof outcome !== "string")
73
+ return "";
74
+ const word = savedTurnCountWord(outcome);
75
+ return Object.hasOwn(SAVED_TURN_KEPT, outcome) ? `${word}, ${hasThread === true ? THREAD_FLAG : NO_THREAD_FLAG}` : word;
76
+ }
77
+ // A summary's `saved_turn_counts` as ordered entries: the four known outcomes first, then any key
78
+ // the device added, as sent. A count reads null when nothing counted it: absent (a revision 2 build
79
+ // counts nothing, which is not zero), a known key missing from a present object (revision 3 always
80
+ // sends all four), or a value that is not a non-negative safe integer. The caller prints "?" rather
81
+ // than a count nobody sent.
82
+ export function savedTurnCountEntries(counts) {
83
+ const obj = counts !== null && typeof counts === "object" && !Array.isArray(counts) ? counts : {};
84
+ const read = (k) => {
85
+ const v = obj[k];
86
+ return typeof v === "number" && Number.isSafeInteger(v) && v >= 0 ? v : null;
87
+ };
88
+ const out = SAVED_TURN_OUTCOMES.map((k) => ({ outcome: k, count: read(k) }));
89
+ for (const k of Object.keys(obj))
90
+ if (!SAVED_TURN_OUTCOMES.includes(k))
91
+ out.push({ outcome: k, count: read(k) });
92
+ return out;
93
+ }
@@ -62,6 +62,7 @@ export function isCaptureDownloadMatch(downloadedPath, expectedFile) {
62
62
  const middle = base.slice(stem.length, base.length - ext.length);
63
63
  return /^-\d+$/.test(middle);
64
64
  }
65
+ const TOAST_DEFAULT_MS = 4000;
65
66
  let toastTimer = null;
66
67
  // The capture the toast on screen is waiting on, or null when it is not waiting on one. Holding
67
68
  // the FILE rather than a boolean is what lets the listener below tell "this save's download
@@ -72,8 +73,8 @@ let awaitedFile = null;
72
73
  * toast unclickable and shuts the reveal gate, so a late download-finished path from an earlier
73
74
  * save cannot attach itself to this message.
74
75
  */
75
- export function showToast(message) {
76
- paint(message);
76
+ export function showToast(message, durationMs = TOAST_DEFAULT_MS) {
77
+ paint(message, durationMs);
77
78
  awaitedFile = null;
78
79
  }
79
80
  /**
@@ -81,14 +82,17 @@ export function showToast(message) {
81
82
  * server reported for THIS save.
82
83
  */
83
84
  export function showSaveToast(message, file) {
84
- paint(message);
85
+ paint(message, TOAST_DEFAULT_MS);
85
86
  awaitedFile = file;
86
87
  }
87
- function paint(message) {
88
+ function paint(message, durationMs) {
88
89
  let el = document.getElementById("radartoast");
89
90
  if (!el) {
90
91
  el = document.createElement("div");
91
92
  el.id = "radartoast";
93
+ // polite: a confirmation should wait for a pause, not interrupt the screen reader.
94
+ el.setAttribute("role", "status");
95
+ el.setAttribute("aria-live", "polite");
92
96
  document.body.appendChild(el);
93
97
  }
94
98
  el.textContent = message;
@@ -108,7 +112,7 @@ function paint(message) {
108
112
  // A toast that has faded is no longer waiting on anything, so a path arriving after it must
109
113
  // not re-arm a toast a later message has since taken over.
110
114
  awaitedFile = null;
111
- }, 4000);
115
+ }, durationMs);
112
116
  }
113
117
  // Single persistent listener: the toast on screen becomes clickable once the download IT is
114
118
  // waiting on actually finishes. Registered once at module load rather than per paint() call, since