@slack/radar-mcp 1.24.0 → 1.26.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 +41 -4
- package/dist/mcp/dispatch.d.ts +1 -0
- package/dist/mcp/dispatch.js +4 -2
- package/dist/mcp/flags-tools.d.ts +1 -0
- package/dist/mcp/flags-tools.js +3 -9
- package/dist/mcp/index.js +16 -40
- package/dist/mcp/json-rows.d.ts +6 -0
- package/dist/mcp/json-rows.js +10 -0
- package/dist/mcp/radar-response.d.ts +2 -2
- package/dist/mcp/radar-response.js +2 -2
- package/dist/mcp/redact.d.ts +14 -0
- package/dist/mcp/redact.js +71 -0
- package/dist/mcp/session-enable.d.ts +1 -0
- package/dist/mcp/session-enable.js +8 -6
- package/dist/mcp/snapshot-cli.d.ts +52 -0
- package/dist/mcp/snapshot-cli.js +316 -0
- package/dist/mcp/snapshot-summary.d.ts +1 -0
- package/dist/mcp/snapshot-summary.js +254 -0
- package/dist/mcp/snapshot.d.ts +32 -3
- package/dist/mcp/snapshot.js +347 -102
- package/dist/mcp/tools.js +11 -7
- package/dist/shared/android.d.ts +25 -0
- package/dist/shared/android.js +97 -0
- package/dist/shared/feature-flags.d.ts +20 -0
- package/dist/shared/feature-flags.js +35 -4
- package/dist/shared/radar-token.d.ts +5 -5
- package/dist/shared/radar-token.js +24 -10
- package/dist/shared/switchboard-note.d.ts +19 -0
- package/dist/shared/switchboard-note.js +76 -0
- package/dist/shared/switchboard-report.js +43 -4
- package/dist/shared/switchboard.d.ts +1 -1
- package/dist/shared/switchboard.js +14 -2
- package/dist/shared/transport.d.ts +18 -0
- package/dist/shared/wire.d.ts +2 -0
- package/dist/web/install-app-cli.d.ts +2 -0
- package/dist/web/install-app-cli.js +60 -0
- package/dist/web/install-app.d.ts +16 -7
- package/dist/web/install-app.js +92 -39
- package/dist/web/macapp/RadarApp.swift +12 -11
- package/dist/web/public/index.html +5 -2
- package/dist/web/public/next/feature-flags.js +50 -0
- package/dist/web/public/next/feed.js +15 -4
- package/dist/web/public/next/flags.js +17 -3
- package/dist/web/public/next/registry.js +4 -4
- package/dist/web/public/next/store.js +90 -4
- package/dist/web/public/next/switchboard-note.js +76 -0
- package/dist/web/public/next/voice-model.js +209 -15
- package/dist/web/public/next/voice.js +73 -10
- package/dist/web/spec.d.ts +1 -1
- package/dist/web/spec.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Pure text builder for one switchboard (Slackbot voice) session report. Input is read
|
|
2
2
|
// defensively: it crossed the device wire, and one odd or older-build field must never throw.
|
|
3
3
|
import { SWITCHBOARD_DEVICE_RING_CAP, SWITCHBOARD_EXPORT_SAFETY_CAP_BYTES, SWITCHBOARD_EXPORT_WALK_DEADLINE_MS, switchboardWalkStopNote, } from "./switchboard.js";
|
|
4
|
-
import { CLIP_PEAK, SAVED_TURN_OUTCOMES, savedTurnCountEntries, savedTurnLabel, stripSwitchboardControlChars, switchboardClockLabel, switchboardDeviceToken, } from "./switchboard-note.js";
|
|
4
|
+
import { CLIP_PEAK, micEncodingNote, openCards, SAVED_TURN_OUTCOMES, reconnectTryLabel, savedTurnCountEntries, savedTurnLabel, serverEndedNormally, stripSwitchboardControlChars, switchboardClockLabel, switchboardDeviceToken, } from "./switchboard-note.js";
|
|
5
5
|
const refusedPhrase = (sendsToken) => sendsToken ? "the device refused this Radar session's token" : "the device refused the request (HTTP 401)";
|
|
6
6
|
const againPhrase = (surface) => surface === "dashboard" ? "press Reconnect and export again for the device copy" : "run /radar-enable and export again for the device copy";
|
|
7
7
|
// Re-exported so the existing callers keep their import; the set itself lives in the note.
|
|
@@ -90,14 +90,17 @@ function recordLine(r) {
|
|
|
90
90
|
case "session": {
|
|
91
91
|
const event = str(r.event) ?? "?";
|
|
92
92
|
const serverId = str(r.server_session_id);
|
|
93
|
-
|
|
93
|
+
const micEncoding = str(r.mic_encoding);
|
|
94
|
+
return `${head} ${event}${serverId ? ` server_session_id=${serverId}` : ""}${micEncoding ? ` mic_encoding=${micEncoding}` : ""}`;
|
|
94
95
|
}
|
|
95
96
|
case "state": {
|
|
96
97
|
const stateKind = str(r.state_kind) ?? "?";
|
|
97
98
|
const from = str(r.from) ?? "?";
|
|
98
99
|
const to = str(r.to) ?? "?";
|
|
99
100
|
const cause = str(r.cause);
|
|
100
|
-
|
|
101
|
+
// A goodbye or a limit still reads Failed on the wire; say it was a normal end.
|
|
102
|
+
const normal = stateKind === "connection" && to === "Failed" && serverEndedNormally(cause) ? ", a normal end" : "";
|
|
103
|
+
return `${head} ${stateKind} ${from} -> ${to}${cause ? ` (${cause}${normal})` : ""}`;
|
|
101
104
|
}
|
|
102
105
|
case "frame": {
|
|
103
106
|
const direction = str(r.direction) ?? "?";
|
|
@@ -118,6 +121,9 @@ function recordLine(r) {
|
|
|
118
121
|
parts.push(`gap ${gap} ms`);
|
|
119
122
|
if (queued !== null)
|
|
120
123
|
parts.push(`${queued} B queued`);
|
|
124
|
+
const dropped = num(r.dropped_chunks);
|
|
125
|
+
if (dropped !== null)
|
|
126
|
+
parts.push(`dropped ${dropped} mic chunk${dropped === 1 ? "" : "s"}`);
|
|
121
127
|
return `${head} ${parts.join(", ")}`;
|
|
122
128
|
}
|
|
123
129
|
case "levels": {
|
|
@@ -144,6 +150,16 @@ function recordLine(r) {
|
|
|
144
150
|
const clock = str(r.clock);
|
|
145
151
|
return `${head} ${fmtMs(r.response_ms)}, ${clock ? reportClockLabel(clock) : "?"}`;
|
|
146
152
|
}
|
|
153
|
+
case "reconnect_try": {
|
|
154
|
+
const trigger = str(r.trigger) ?? "?";
|
|
155
|
+
const outcome = str(r.outcome) ?? "?";
|
|
156
|
+
return `${head} ${reconnectTryLabel(trigger, outcome, num(r.try))}`;
|
|
157
|
+
}
|
|
158
|
+
case "card": {
|
|
159
|
+
// The wire labels, not the panel's words, so a reader can grep the export for them.
|
|
160
|
+
const by = str(r.by);
|
|
161
|
+
return `${head} ${str(r.card_kind) ?? "?"} ${str(r.event) ?? "?"}${by ? ` by ${by}` : ""} card_id=${str(r.card_id) ?? "?"}`;
|
|
162
|
+
}
|
|
147
163
|
case "saved_turn": {
|
|
148
164
|
// Raw, not stripped: known or unknown is decided on what the device sent, so "applied" plus a
|
|
149
165
|
// hidden character is an unknown outcome, quoted, and never "saved, thread".
|
|
@@ -220,6 +236,9 @@ export function buildSwitchboardReport(assembly, now = Date.now()) {
|
|
|
220
236
|
const deviceOnlyCount = deviceEventCount !== null ? deviceEventCount : events.length - hostStreamCount;
|
|
221
237
|
const streamedDuringExport = deviceEventCount !== null ? Math.max(0, events.length - hostStreamCount - deviceEventCount) : 0;
|
|
222
238
|
const fetchIncomplete = deviceOnlyCount > 0 && totalCaptured !== null && deviceOnlyCount < totalCaptured;
|
|
239
|
+
// One completeness rule for the cards_open line and the stream-copy note. A short fetch the live
|
|
240
|
+
// stream copy filled is not missing records, and the stream-copy note says so.
|
|
241
|
+
const holdsEveryRecord = !startMissing && gapCount === 0 && (!fetchIncomplete || hostStreamCount > 0);
|
|
223
242
|
// Suggestive, not proof, that the ring lost the start, so it only earns the soft phrasing. The
|
|
224
243
|
// oldest-timestamp signal counts only when the walk reached the end of the device's range.
|
|
225
244
|
const oldestTimestampIsRingEvidence = walkStopReason === null || walkStopReason === "done";
|
|
@@ -231,6 +250,26 @@ export function buildSwitchboardReport(assembly, now = Date.now()) {
|
|
|
231
250
|
// live device connection to promise one.
|
|
232
251
|
const serverSessionIdText = serverSessionId ?? (!deviceGone && live && hasServerSessionIdKey ? "pending" : "(not reported)");
|
|
233
252
|
lines.push(`server_session_id: ${serverSessionIdText}`);
|
|
253
|
+
// A reconnect can bring a new server id; older builds send no list, so they print as before.
|
|
254
|
+
const allServerIds = Array.isArray(d.server_session_ids) ? d.server_session_ids.map(str).filter((x) => x !== null) : [];
|
|
255
|
+
if (allServerIds.length >= 2)
|
|
256
|
+
lines.push(`server_session_ids: ${allServerIds.join(", ")}`);
|
|
257
|
+
// The summary's label outlives the config record's eviction, and a host-only report already
|
|
258
|
+
// gets it from hostOnlySwitchboardDetail. A build that sends no label prints no line.
|
|
259
|
+
const micEncoding = str(d.mic_encoding);
|
|
260
|
+
if (micEncoding !== null) {
|
|
261
|
+
const micNote = micEncodingNote(micEncoding);
|
|
262
|
+
lines.push(`mic_encoding: ${micEncoding}${micNote ? ` (${micNote})` : ""}`);
|
|
263
|
+
}
|
|
264
|
+
// Only rows with a card record get the line; none printed means no card record in these rows, not
|
|
265
|
+
// that no card is up.
|
|
266
|
+
if (events.some((e) => e.kind === "card")) {
|
|
267
|
+
const up = openCards(events).map((c) => `${stripSwitchboardControlChars(c.kind)} ${stripSwitchboardControlChars(c.id)}`);
|
|
268
|
+
// A card shown in a record this report lacks looks closed or never up, so say so.
|
|
269
|
+
const partial = !holdsEveryRecord;
|
|
270
|
+
const note = partial ? "shown or carried with no later record, among the records this report holds" : "shown or carried with no later record";
|
|
271
|
+
lines.push(`cards_open: ${up.length ? `${up.join(", ")} (${note})` : partial ? "none seen (the report does not hold every record)" : "none"}`);
|
|
272
|
+
}
|
|
234
273
|
lines.push(`team_id: ${teamId ?? "(none)"}`);
|
|
235
274
|
lines.push(`began_at: ${isoOrRaw(beganAt)}`);
|
|
236
275
|
// A host-only report with no end record is not evidence the call is still live.
|
|
@@ -285,7 +324,7 @@ export function buildSwitchboardReport(assembly, now = Date.now()) {
|
|
|
285
324
|
}
|
|
286
325
|
lines.push(`exported_at: ${isoOrRaw(now)}`);
|
|
287
326
|
// A host copy with a mid-call gap did not really supply the older records.
|
|
288
|
-
const hostFilledStart =
|
|
327
|
+
const hostFilledStart = holdsEveryRecord && hostStreamCount > 0;
|
|
289
328
|
const hostWalkNote = hostFilledWalkNoteText(walkStopReason, hostFilledStart, refused, again);
|
|
290
329
|
// "up to": ids come from one counter shared across sessions, so gapCount is an upper bound.
|
|
291
330
|
const gapNote = (cause) => `the report reaches the call's start, but up to ${gapCount} record${gapCount === 1 ? "" : "s"} in the middle may be missing: ${cause}`;
|
|
@@ -3,7 +3,7 @@ export declare const SWITCHBOARD_KIND = "switchboard";
|
|
|
3
3
|
export declare const SWITCHBOARD_BACKFILL_SESSIONS = 3;
|
|
4
4
|
export declare const SWITCHBOARD_BACKFILL_DEADLINE_MS: number;
|
|
5
5
|
export declare function switchboardListPath(): string;
|
|
6
|
-
export declare const SWITCHBOARD_KINDS: readonly ["session", "state", "frame", "phase", "player", "levels", "turn", "saved_turn"];
|
|
6
|
+
export declare const SWITCHBOARD_KINDS: readonly ["session", "state", "frame", "phase", "player", "levels", "turn", "saved_turn", "card", "reconnect_try"];
|
|
7
7
|
export type SwitchboardKind = (typeof SWITCHBOARD_KINDS)[number];
|
|
8
8
|
export declare function switchboardSessionPath(sessionId: number, limit: number, kind?: SwitchboardKind, beforeId?: number): string;
|
|
9
9
|
export declare function newestSwitchboardSessionIds(list: unknown): number[];
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// is absent, so the limit is forwarded per session or a talkative session replays as its last few
|
|
8
8
|
// seconds).
|
|
9
9
|
import { lastHeaderBuildFailure, unauthorizedMessageFor, } from "./radar-token.js";
|
|
10
|
+
import { SERVER_SESSION_ID_CAP } from "./switchboard-note.js";
|
|
10
11
|
export const SWITCHBOARD_KIND = "switchboard";
|
|
11
12
|
// Sessions replayed per backfill. Bounds the round trips (one list plus one fetch per session).
|
|
12
13
|
export const SWITCHBOARD_BACKFILL_SESSIONS = 3;
|
|
@@ -20,7 +21,7 @@ export function switchboardListPath() {
|
|
|
20
21
|
}
|
|
21
22
|
// The record kinds the plugin emits, the closed set a `kind` query may name. Shared so the path
|
|
22
23
|
// builder below takes the type and never sees raw input.
|
|
23
|
-
export const SWITCHBOARD_KINDS = ["session", "state", "frame", "phase", "player", "levels", "turn", "saved_turn"];
|
|
24
|
+
export const SWITCHBOARD_KINDS = ["session", "state", "frame", "phase", "player", "levels", "turn", "saved_turn", "card", "reconnect_try"];
|
|
24
25
|
// beforeId asks for records with id < beforeId. An older device ignores it and repeats the newest
|
|
25
26
|
// page; walkSwitchboardExportPages detects that.
|
|
26
27
|
export function switchboardSessionPath(sessionId, limit, kind, beforeId) {
|
|
@@ -382,12 +383,19 @@ export function hostOnlySwitchboardDetail(sessionId, hostRecords) {
|
|
|
382
383
|
: null;
|
|
383
384
|
let teamId = null;
|
|
384
385
|
let serverSessionId = null;
|
|
386
|
+
const serverSessionIds = [];
|
|
385
387
|
let endedAt = null;
|
|
388
|
+
let micEncoding = null;
|
|
386
389
|
for (const e of records) {
|
|
387
390
|
if (teamId === null && typeof e.team_id === "string")
|
|
388
391
|
teamId = e.team_id;
|
|
389
|
-
if (
|
|
392
|
+
if (e.kind === "session" && e.event === "ready" && typeof e.server_session_id === "string") {
|
|
390
393
|
serverSessionId = e.server_session_id;
|
|
394
|
+
if (!serverSessionIds.includes(e.server_session_id))
|
|
395
|
+
serverSessionIds.push(e.server_session_id);
|
|
396
|
+
}
|
|
397
|
+
if (e.kind === "session" && e.event === "config" && typeof e.mic_encoding === "string")
|
|
398
|
+
micEncoding = e.mic_encoding;
|
|
391
399
|
if (endedAt === null && e.kind === "session" && e.event === "end" && typeof e.timestamp === "number" && Number.isFinite(e.timestamp))
|
|
392
400
|
endedAt = e.timestamp;
|
|
393
401
|
}
|
|
@@ -402,6 +410,10 @@ export function hostOnlySwitchboardDetail(sessionId, hostRecords) {
|
|
|
402
410
|
};
|
|
403
411
|
if (serverSessionId !== null)
|
|
404
412
|
detail.server_session_id = serverSessionId;
|
|
413
|
+
if (serverSessionIds.length > 0)
|
|
414
|
+
detail.server_session_ids = serverSessionIds.slice(-SERVER_SESSION_ID_CAP);
|
|
415
|
+
if (micEncoding !== null)
|
|
416
|
+
detail.mic_encoding = micEncoding;
|
|
405
417
|
return detail;
|
|
406
418
|
}
|
|
407
419
|
export function oldestSwitchboardTimestamp(events) {
|
|
@@ -233,6 +233,24 @@ export interface DeviceTransport {
|
|
|
233
233
|
* Optional: omitted by platforms with no device log stream (webapp).
|
|
234
234
|
*/
|
|
235
235
|
getRecentLogs?(tag: string, limit: number, grep?: string): LogResult;
|
|
236
|
+
/**
|
|
237
|
+
* Facts about the attached device and the app under test, for a snapshot header. Each field is
|
|
238
|
+
* read on its own, so one failed read leaves that field null and never throws.
|
|
239
|
+
*
|
|
240
|
+
* Optional: only Android (adb) has these today.
|
|
241
|
+
*/
|
|
242
|
+
getDeviceFacts?(): {
|
|
243
|
+
device: Record<string, string | boolean | null>;
|
|
244
|
+
app: Record<string, string | null>;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* The device's wall clock in epoch milliseconds (whole seconds times 1000), or null when it
|
|
248
|
+
* cannot be read. Event timestamps are device wall clock, so a run window must use this and
|
|
249
|
+
* not the host clock.
|
|
250
|
+
*
|
|
251
|
+
* Optional: only Android (adb) has this today.
|
|
252
|
+
*/
|
|
253
|
+
deviceClockMs?(): number | null;
|
|
236
254
|
/**
|
|
237
255
|
* Returns the currently active user ID, or null if none is set. On Android
|
|
238
256
|
* this is the profile (e.g. "0" for personal, "10" for work); on iOS it
|
package/dist/shared/wire.d.ts
CHANGED
|
@@ -57,12 +57,14 @@ export interface SwitchboardSessionSummary {
|
|
|
57
57
|
total_captured: number;
|
|
58
58
|
levels: SwitchboardLevels | null;
|
|
59
59
|
server_session_id?: string | null;
|
|
60
|
+
server_session_ids?: string[];
|
|
60
61
|
turns?: {
|
|
61
62
|
count: number;
|
|
62
63
|
last_response_ms: number;
|
|
63
64
|
last_clock: string;
|
|
64
65
|
} | null;
|
|
65
66
|
saved_turn_counts?: Record<string, number>;
|
|
67
|
+
mic_encoding?: string | null;
|
|
66
68
|
}
|
|
67
69
|
export interface SwitchboardSessionDetail extends SwitchboardSessionSummary {
|
|
68
70
|
events: Record<string, unknown>[];
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The install-app flag dispatch, pulled out of mcp/index.ts so the app can spawn it without the
|
|
3
|
+
// MCP SDK. Imports only node builtins and ./install-app.js (which imports only from ../shared),
|
|
4
|
+
// so a copy of dist/ plus package.json is enough to run it.
|
|
5
|
+
//
|
|
6
|
+
// The argv shape is what RadarApp.swift spawns: `<bin> install-app [flag]`.
|
|
7
|
+
import { realpathSync } from "fs";
|
|
8
|
+
import { fileURLToPath } from "url";
|
|
9
|
+
export async function runInstallAppCli(argv) {
|
|
10
|
+
// The background rebuild RadarApp.swift runs once the precheck confirms a newer version (see
|
|
11
|
+
// install-app.ts's runSelfHealCheck).
|
|
12
|
+
const wantsSelfHealCheck = argv.includes("--self-heal-check");
|
|
13
|
+
// What RadarApp.swift ACTUALLY spawns now (see install-app.ts's runSelfHealPrecheck): a safe
|
|
14
|
+
// registry-version precheck that only falls through to --self-heal-check once a real upgrade is
|
|
15
|
+
// confirmed. Checked before wantsSelfHealCheck below so the two flags stay mutually exclusive.
|
|
16
|
+
const wantsSelfHealPrecheck = argv.includes("--self-heal-precheck");
|
|
17
|
+
// The two interactive halves of the app's Check for Updates... item: ask whether a newer build is
|
|
18
|
+
// published, then install it. Each prints a single JSON line for the app to read.
|
|
19
|
+
const wantsCheckUpdate = argv.includes("--check-update");
|
|
20
|
+
const wantsUpdateNow = argv.includes("--update-now");
|
|
21
|
+
if (wantsCheckUpdate) {
|
|
22
|
+
const { checkForUpdate } = await import("./install-app.js");
|
|
23
|
+
console.log(JSON.stringify(await checkForUpdate(process.env.RADAR_APP_VERSION)));
|
|
24
|
+
}
|
|
25
|
+
else if (wantsUpdateNow) {
|
|
26
|
+
const { runUpdateNow } = await import("./install-app.js");
|
|
27
|
+
await runUpdateNow();
|
|
28
|
+
}
|
|
29
|
+
else if (wantsSelfHealPrecheck) {
|
|
30
|
+
const { runSelfHealPrecheck } = await import("./install-app.js");
|
|
31
|
+
runSelfHealPrecheck();
|
|
32
|
+
}
|
|
33
|
+
else if (wantsSelfHealCheck) {
|
|
34
|
+
const { runSelfHealCheck } = await import("./install-app.js");
|
|
35
|
+
runSelfHealCheck();
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
const { runInstallApp } = await import("./install-app.js");
|
|
39
|
+
runInstallApp();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// Same bin-vs-import test as bin.ts: realpathSync resolves an npm bin symlink to the real path.
|
|
43
|
+
function invokedDirectly() {
|
|
44
|
+
const arg = process.argv[1];
|
|
45
|
+
if (!arg)
|
|
46
|
+
return false;
|
|
47
|
+
try {
|
|
48
|
+
return fileURLToPath(import.meta.url) === realpathSync(arg);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (invokedDirectly()) {
|
|
55
|
+
if (process.argv[2] !== "install-app") {
|
|
56
|
+
console.error("usage: install-app-cli install-app [--check-update|--update-now|--self-heal-precheck|--self-heal-check]");
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
await runInstallAppCli(process.argv);
|
|
60
|
+
}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { spawn } from "child_process";
|
|
2
|
+
/** Refuses anything that is not a version, so a value like ".." can never aim the swap at ~/.slack-radar itself. */
|
|
3
|
+
export declare function runtimeCopyDirFor(version: string): string;
|
|
4
|
+
/**
|
|
5
|
+
* Copies the package.json and dist the app needs into destRoot. No node_modules: the dashboard
|
|
6
|
+
* and install-app-cli.js import node builtins only. Throws on failure so the install stops before
|
|
7
|
+
* it bakes a path to a file that is not there.
|
|
8
|
+
*/
|
|
9
|
+
export declare function copyRuntime(sourceRoot: string, destRoot: string): void;
|
|
2
10
|
/**
|
|
3
11
|
* Where a stable, version-free name for a node interpreter could live. Homebrew keeps one at
|
|
4
12
|
* `<prefix>/bin/node` (`/opt/homebrew` on Apple silicon, `/usr/local` on Intel) pointing into the
|
|
@@ -153,11 +161,12 @@ export declare function installAppMessage(result: {
|
|
|
153
161
|
}): string;
|
|
154
162
|
/**
|
|
155
163
|
* Entry point for `install-app --self-heal-check`, spawned in the background by RadarApp.swift
|
|
156
|
-
* on every dock launch. install-app bakes the .app's paths and version in ONCE,
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
164
|
+
* on every dock launch. install-app bakes the .app's paths and version in ONCE, and the app runs
|
|
165
|
+
* from its own copy of the package under ~/.slack-radar/app/<version>, so a Radar upgrade via
|
|
166
|
+
* `npx @slack/radar-mcp@latest` (the documented setup) leaves the installed app on the older
|
|
167
|
+
* version with no signal to the user. This rebuilds it in place, copying this process's own
|
|
168
|
+
* version (itself just resolved via the same `@latest` npx call) and pointing the app at that copy
|
|
169
|
+
* when it differs from what is installed, so the fix lands invisibly and takes effect on the NEXT
|
|
161
170
|
* launch. Never throws out of this function, except when the final state write itself fails: a
|
|
162
171
|
* launcher-triggered background process failing loudly would look like a crash, which is exactly
|
|
163
172
|
* what staying invisible rules out. That one throw exits non-zero, which the precheck counts as a failure.
|
|
@@ -178,8 +187,8 @@ export declare function checkLatestPublishedVersion(): Promise<string | null>;
|
|
|
178
187
|
export declare function _setSelfHealSpawnForTest(fn: typeof spawn): void;
|
|
179
188
|
export declare function _setSelfHealRebuildTimeoutForTest(ms: number): void;
|
|
180
189
|
/**
|
|
181
|
-
* Entry point for `install-app --self-heal-precheck`. RadarApp.swift now spawns THIS (
|
|
182
|
-
*
|
|
190
|
+
* Entry point for `install-app --self-heal-precheck`. RadarApp.swift now spawns THIS (install-app-cli.js
|
|
191
|
+
* in the app's own copy of the package, guaranteed self-heal-aware) instead of going straight to `npx
|
|
183
192
|
* -y @slack/radar-mcp@latest install-app --self-heal-check`. The direct-to-npx version had a real
|
|
184
193
|
* bug: nothing guaranteed `@latest` resolved to code that understood `--self-heal-check`, and the
|
|
185
194
|
* already-published old dispatch ignores unknown flags and runs the full INTERACTIVE install
|
package/dist/web/install-app.js
CHANGED
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
// everyone. The shell launcher stays as the fallback for a machine with no Swift toolchain.
|
|
18
18
|
//
|
|
19
19
|
// Either way the app holds NO dashboard logic -- it starts the server and renders localhost -- so it
|
|
20
|
-
// does not go stale when Radar upgrades (the SAME app keeps working against a newer dist).
|
|
20
|
+
// does not go stale when Radar upgrades (the SAME app keeps working against a newer dist). It runs
|
|
21
|
+
// from its own copy of the package under ~/.slack-radar/app/<version>, so the npx cache can change
|
|
22
|
+
// under it without changing what it serves. A self-heal rebuild copies the newer version and points
|
|
23
|
+
// the app at it. A checkout install needs install-app re-run to pick up dist edits.
|
|
21
24
|
import { execFileSync, spawn } from "child_process";
|
|
22
25
|
import fs from "fs";
|
|
23
26
|
import http from "http";
|
|
@@ -49,15 +52,39 @@ function bashQuote(value) {
|
|
|
49
52
|
function appDir() {
|
|
50
53
|
return path.join(os.homedir(), "Applications");
|
|
51
54
|
}
|
|
52
|
-
/** The
|
|
55
|
+
/** The package root this install runs from: two dirs above install-app.js (dist/web). */
|
|
56
|
+
function sourceRootPath() {
|
|
57
|
+
return path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
58
|
+
}
|
|
59
|
+
/** The dashboard entrypoint in the package being installed. Only used to check the install can
|
|
60
|
+
* proceed; the app bakes the copy's path instead (see runtimeCopyDir). */
|
|
53
61
|
function webBinPath() {
|
|
54
|
-
return path.join(
|
|
62
|
+
return path.join(sourceRootPath(), "dist", "web", "bin.js");
|
|
63
|
+
}
|
|
64
|
+
/** Where the app's own copies of the package live, one dir per version. */
|
|
65
|
+
function runtimeRoot() {
|
|
66
|
+
return path.join(os.homedir(), ".slack-radar", "app");
|
|
67
|
+
}
|
|
68
|
+
/** The copy this version's app runs from. Derived from RADAR_VERSION so a test can compute it. */
|
|
69
|
+
function runtimeCopyDir() {
|
|
70
|
+
return runtimeCopyDirFor(RADAR_VERSION);
|
|
71
|
+
}
|
|
72
|
+
/** Refuses anything that is not a version, so a value like ".." can never aim the swap at ~/.slack-radar itself. */
|
|
73
|
+
export function runtimeCopyDirFor(version) {
|
|
74
|
+
if (!/^[0-9][0-9A-Za-z.+-]*$/.test(version)) {
|
|
75
|
+
throw new Error(`refusing to copy the runtime for "${version}", which is not a version`);
|
|
76
|
+
}
|
|
77
|
+
return path.join(runtimeRoot(), version);
|
|
55
78
|
}
|
|
56
|
-
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
|
|
60
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Copies the package.json and dist the app needs into destRoot. No node_modules: the dashboard
|
|
81
|
+
* and install-app-cli.js import node builtins only. Throws on failure so the install stops before
|
|
82
|
+
* it bakes a path to a file that is not there.
|
|
83
|
+
*/
|
|
84
|
+
export function copyRuntime(sourceRoot, destRoot) {
|
|
85
|
+
fs.mkdirSync(destRoot, { recursive: true });
|
|
86
|
+
fs.cpSync(path.join(sourceRoot, "package.json"), path.join(destRoot, "package.json"));
|
|
87
|
+
fs.cpSync(path.join(sourceRoot, "dist"), path.join(destRoot, "dist"), { recursive: true });
|
|
61
88
|
}
|
|
62
89
|
/**
|
|
63
90
|
* A keg-only formula (`brew install node@22`) is not linked into `<prefix>/bin`, so it has no entry
|
|
@@ -414,10 +441,12 @@ export function installPort(env = process.env, installed) {
|
|
|
414
441
|
* bakes execPath. With them, a synthetic Homebrew layout proves the wiring anywhere.
|
|
415
442
|
*/
|
|
416
443
|
export function installConfigValues(execPath, candidates) {
|
|
444
|
+
const copy = runtimeCopyDir();
|
|
417
445
|
return {
|
|
418
446
|
node: stableNodePath(execPath ?? process.execPath, candidates ?? stableNodeCandidates()),
|
|
419
|
-
webBin:
|
|
420
|
-
|
|
447
|
+
webBin: path.join(copy, "dist", "web", "bin.js"),
|
|
448
|
+
// install-app-cli.js, not mcp/index.js: it needs no node_modules, so the copy stays small.
|
|
449
|
+
mcpBin: path.join(copy, "dist", "web", "install-app-cli.js"),
|
|
421
450
|
port: installPort(),
|
|
422
451
|
};
|
|
423
452
|
}
|
|
@@ -578,6 +607,46 @@ function buildIcns(resourcesDir) {
|
|
|
578
607
|
// the finally below. Without this, one crashed install would wedge every self-heal check forever,
|
|
579
608
|
// since nothing else ever removes the lock file.
|
|
580
609
|
const STALE_LOCK_MS = 2 * 60 * 1000;
|
|
610
|
+
/**
|
|
611
|
+
* Puts the package copy at destDir: staged at `.new`, then renamed into place, with any existing
|
|
612
|
+
* same-version dir moved to `.old` first and removed after, the same shape as the bundle swap.
|
|
613
|
+
* When the install is already running from destDir (the app's own copy rebuilding the same
|
|
614
|
+
* version) the copy is skipped, since swapping a dir out from under the code reading it would
|
|
615
|
+
* delete the source.
|
|
616
|
+
*/
|
|
617
|
+
function installRuntimeCopy(sourceRoot, destDir) {
|
|
618
|
+
try {
|
|
619
|
+
if (fs.realpathSync(sourceRoot) === fs.realpathSync(destDir))
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
catch {
|
|
623
|
+
// destDir is not there yet, so the two cannot be the same dir.
|
|
624
|
+
}
|
|
625
|
+
const staging = `${destDir}.new`;
|
|
626
|
+
fs.mkdirSync(path.dirname(destDir), { recursive: true });
|
|
627
|
+
fs.rmSync(staging, { recursive: true, force: true });
|
|
628
|
+
copyRuntime(sourceRoot, staging);
|
|
629
|
+
swapIntoPlace(staging, destDir);
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Renames a fully written staging dir over dest, keeping the old one at `.old` until the new one
|
|
633
|
+
* is in place. Clears a stale `.old` first (a crashed run's leftover) so the first rename cannot
|
|
634
|
+
* fail with ENOTEMPTY. Each rename is atomic, but the pair is not: a crash between them leaves dest
|
|
635
|
+
* at `.old` until a later run or a person moves it back. Node has no rename-exchange to close that.
|
|
636
|
+
*/
|
|
637
|
+
function swapIntoPlace(staging, dest) {
|
|
638
|
+
const backup = `${dest}.old`;
|
|
639
|
+
fs.rmSync(backup, { recursive: true, force: true });
|
|
640
|
+
if (fs.existsSync(dest))
|
|
641
|
+
fs.renameSync(dest, backup);
|
|
642
|
+
fs.renameSync(staging, dest);
|
|
643
|
+
try {
|
|
644
|
+
fs.rmSync(backup, { recursive: true, force: true });
|
|
645
|
+
}
|
|
646
|
+
catch {
|
|
647
|
+
// A leftover .old must not fail an otherwise-good install.
|
|
648
|
+
}
|
|
649
|
+
}
|
|
581
650
|
/**
|
|
582
651
|
* Create (or replace) the launcher app. Returns its path.
|
|
583
652
|
*
|
|
@@ -591,12 +660,12 @@ export function installMacApp() {
|
|
|
591
660
|
const dir = appDir();
|
|
592
661
|
const app = path.join(dir, `${APP_NAME}.app`);
|
|
593
662
|
const staging = `${app}.new`;
|
|
594
|
-
const backup = `${app}.old`;
|
|
595
663
|
// Resolved once, since both build paths below need the same answer.
|
|
596
664
|
const values = installConfigValues();
|
|
597
665
|
const webBin = values.webBin;
|
|
598
|
-
|
|
599
|
-
|
|
666
|
+
const sourceBin = webBinPath();
|
|
667
|
+
if (!fs.existsSync(sourceBin)) {
|
|
668
|
+
throw new Error(`cannot find the dashboard entrypoint at ${sourceBin}`);
|
|
600
669
|
}
|
|
601
670
|
// "wx" is atomic create-if-absent, so there is no check-then-create race on the lock itself.
|
|
602
671
|
// A second caller finding it already there fails immediately rather than racing the same
|
|
@@ -629,6 +698,7 @@ export function installMacApp() {
|
|
|
629
698
|
}
|
|
630
699
|
}
|
|
631
700
|
try {
|
|
701
|
+
installRuntimeCopy(sourceRootPath(), runtimeCopyDir());
|
|
632
702
|
const macos = path.join(staging, "Contents", "MacOS");
|
|
633
703
|
const resources = path.join(staging, "Contents", "Resources");
|
|
634
704
|
fs.rmSync(staging, { recursive: true, force: true });
|
|
@@ -647,25 +717,7 @@ export function installMacApp() {
|
|
|
647
717
|
}
|
|
648
718
|
fs.writeFileSync(path.join(staging, "Contents", "Info.plist"), infoPlist(native ? "SlackRadar" : "radar-launcher", values.port));
|
|
649
719
|
const icon = buildIcns(resources);
|
|
650
|
-
|
|
651
|
-
// step. The pair is not one atomic transaction though: a crash between the two renames leaves
|
|
652
|
-
// no `app` at all (it is sitting at `backup`) until the process resumes and completes the
|
|
653
|
-
// second rename or a person restores it by hand -- Node's fs has no rename-exchange primitive
|
|
654
|
-
// to close that particular gap, so this is close to the best achievable on POSIX, not a full
|
|
655
|
-
// guarantee. Clear any stale `.old` first (a previous run's crash leftover) so the first
|
|
656
|
-
// rename cannot fail with ENOTEMPTY.
|
|
657
|
-
fs.rmSync(backup, { recursive: true, force: true });
|
|
658
|
-
if (fs.existsSync(app)) {
|
|
659
|
-
fs.renameSync(app, backup);
|
|
660
|
-
}
|
|
661
|
-
fs.renameSync(staging, app);
|
|
662
|
-
// Best-effort cleanup on success; a leftover .old must not fail an otherwise-good install.
|
|
663
|
-
try {
|
|
664
|
-
fs.rmSync(backup, { recursive: true, force: true });
|
|
665
|
-
}
|
|
666
|
-
catch {
|
|
667
|
-
// harmless
|
|
668
|
-
}
|
|
720
|
+
swapIntoPlace(staging, app);
|
|
669
721
|
// Nudge Launch Services to notice the new bundle so it appears in Spotlight immediately
|
|
670
722
|
// instead of whenever the system next rescans. Best effort; the app works regardless.
|
|
671
723
|
try {
|
|
@@ -774,11 +826,12 @@ function logNoInstalledVersion(checkedAt, reason) {
|
|
|
774
826
|
}
|
|
775
827
|
/**
|
|
776
828
|
* Entry point for `install-app --self-heal-check`, spawned in the background by RadarApp.swift
|
|
777
|
-
* on every dock launch. install-app bakes the .app's paths and version in ONCE,
|
|
778
|
-
*
|
|
779
|
-
*
|
|
780
|
-
*
|
|
781
|
-
*
|
|
829
|
+
* on every dock launch. install-app bakes the .app's paths and version in ONCE, and the app runs
|
|
830
|
+
* from its own copy of the package under ~/.slack-radar/app/<version>, so a Radar upgrade via
|
|
831
|
+
* `npx @slack/radar-mcp@latest` (the documented setup) leaves the installed app on the older
|
|
832
|
+
* version with no signal to the user. This rebuilds it in place, copying this process's own
|
|
833
|
+
* version (itself just resolved via the same `@latest` npx call) and pointing the app at that copy
|
|
834
|
+
* when it differs from what is installed, so the fix lands invisibly and takes effect on the NEXT
|
|
782
835
|
* launch. Never throws out of this function, except when the final state write itself fails: a
|
|
783
836
|
* launcher-triggered background process failing loudly would look like a crash, which is exactly
|
|
784
837
|
* what staying invisible rules out. That one throw exits non-zero, which the precheck counts as a failure.
|
|
@@ -898,8 +951,8 @@ export function _setSelfHealRebuildTimeoutForTest(ms) {
|
|
|
898
951
|
selfHealRebuildTimeoutMs = ms;
|
|
899
952
|
}
|
|
900
953
|
/**
|
|
901
|
-
* Entry point for `install-app --self-heal-precheck`. RadarApp.swift now spawns THIS (
|
|
902
|
-
*
|
|
954
|
+
* Entry point for `install-app --self-heal-precheck`. RadarApp.swift now spawns THIS (install-app-cli.js
|
|
955
|
+
* in the app's own copy of the package, guaranteed self-heal-aware) instead of going straight to `npx
|
|
903
956
|
* -y @slack/radar-mcp@latest install-app --self-heal-check`. The direct-to-npx version had a real
|
|
904
957
|
* bug: nothing guaranteed `@latest` resolved to code that understood `--self-heal-check`, and the
|
|
905
958
|
* already-published old dispatch ignores unknown flags and runs the full INTERACTIVE install
|
|
@@ -770,11 +770,11 @@ enum QuitStopOutcome {
|
|
|
770
770
|
/// window is what is left after this app's own window is excluded by id.
|
|
771
771
|
case leftForWindow
|
|
772
772
|
/// This app spawned it, and the server said somebody is using it without saying who, so it was left
|
|
773
|
-
/// running. On the quit side that answer
|
|
774
|
-
///
|
|
775
|
-
/// the wire contract says a new kind is to be expected. Stopping a server whose
|
|
776
|
-
/// somebody was on it would be the implicit path costing somebody a page, which is
|
|
777
|
-
/// arm reserves for an explicit request. The cost is one orphaned server, which the launch path reclaims.
|
|
773
|
+
/// running. On the quit side that answer should not come from a server this app spawned, since it
|
|
774
|
+
/// runs RADAR_WEB_BIN, which is this app's own version. If it ever does, it is a kind this binary
|
|
775
|
+
/// has not heard of, and the wire contract says a new kind is to be expected. Stopping a server whose
|
|
776
|
+
/// newer answer said somebody was on it would be the implicit path costing somebody a page, which is
|
|
777
|
+
/// the trade the launch arm reserves for an explicit request. The cost is one orphaned server, which the launch path reclaims.
|
|
778
778
|
case leftUnattributed
|
|
779
779
|
}
|
|
780
780
|
|
|
@@ -853,8 +853,8 @@ final class SpawnedDashboard {
|
|
|
853
853
|
// used to kill the server that tab was reading.
|
|
854
854
|
//
|
|
855
855
|
// someoneUnnamed keeps the server too, and the route in matters. A server THIS app spawned runs
|
|
856
|
-
// RADAR_WEB_BIN, which is this app's version
|
|
857
|
-
// app, see triggerSelfHealCheck), so it understands the exclusion and never produces the OLD-server
|
|
856
|
+
// RADAR_WEB_BIN, which is this app's own version (a self-heal rebuild installs the newer version and
|
|
857
|
+
// points the app at it, see triggerSelfHealCheck), so it understands the exclusion and never produces the OLD-server
|
|
858
858
|
// route into someoneUnnamed. The route it can produce is a kind this binary has not heard of, which
|
|
859
859
|
// is exactly what the wire contract says to expect when the server is ahead, and that answer says
|
|
860
860
|
// somebody is there. A quit is nobody asking, so it may not cost that somebody a page; the launch
|
|
@@ -1396,14 +1396,15 @@ func ensureDashboardRunning(respectInUse: Bool = true, ticket: LaunchTicket? = n
|
|
|
1396
1396
|
}
|
|
1397
1397
|
|
|
1398
1398
|
/// Fire-and-forget check that a newer Radar is available, so a dock app that install-app baked
|
|
1399
|
-
/// paths and a version into ONCE self-heals on the NEXT launch instead of staying
|
|
1400
|
-
///
|
|
1399
|
+
/// paths and a version into ONCE self-heals on the NEXT launch instead of staying on its own copy
|
|
1400
|
+
/// of the older version after an `npx @slack/radar-mcp@latest` upgrade. Never blocks: this must
|
|
1401
1401
|
/// add no delay before the window appears, so there is no waitUntilExit and no exit-status check.
|
|
1402
1402
|
///
|
|
1403
|
-
/// Spawns the ALREADY-INSTALLED
|
|
1403
|
+
/// Spawns the ALREADY-INSTALLED install-app-cli.js (RADAR_MCP_BIN, in the app's own copy of the
|
|
1404
|
+
/// package), not `npx @latest` directly: nothing guarantees
|
|
1404
1405
|
/// `@latest` resolves to code that understands `--self-heal-check`, and the already-published old
|
|
1405
1406
|
/// dispatch ignores that unknown flag and runs the full INTERACTIVE install unconditionally. The
|
|
1406
|
-
/// installed
|
|
1407
|
+
/// installed copy is guaranteed to be from THIS build, so it knows to check the registry
|
|
1407
1408
|
/// itself before ever touching npx -- see install-app.ts's runSelfHealPrecheck().
|
|
1408
1409
|
func triggerSelfHealCheck() {
|
|
1409
1410
|
// Existence-checked, like the dashboard start. It used to be spawned under the baked path whatever
|
|
@@ -395,19 +395,21 @@
|
|
|
395
395
|
:root.light .voice-guide { opacity:.6; }
|
|
396
396
|
.voice-legend { display:flex; gap:8px 14px; font-size:11px; color:var(--muted-2); margin-top:8px; flex-wrap:wrap; }
|
|
397
397
|
.voice-legend span::before { content:""; display:inline-block; width:10px; height:10px; border-radius:2px; margin-right:6px; vertical-align:-1px; background:var(--muted); }
|
|
398
|
-
.voice-legend .m::before { background:var(--blue); } .voice-legend .y::before { background:var(--accent); } .voice-legend .r::before { background:var(--warn); } .voice-legend .s::before { background:var(--purple); } .voice-legend .f::before { background:var(--muted-2); }
|
|
398
|
+
.voice-legend .m::before { background:var(--blue); } .voice-legend .y::before { background:var(--accent); } .voice-legend .r::before { background:var(--warn); } .voice-legend .s::before { background:var(--purple); } .voice-legend .f::before { background:var(--muted-2); } .voice-legend .en::before { background:var(--muted); } .voice-legend .cd::before { background:var(--blue-2); }
|
|
399
399
|
/* Plain swatch, matching the clipped peak rect in voice.ts's levelBars. */
|
|
400
|
+
.voice-legend .hd::before { background:var(--muted-2); opacity:.45; }
|
|
400
401
|
.voice-legend .clip::before { background:var(--error); }
|
|
401
402
|
/* Legend swatches teach the tracks' own shapes, not just their colours: a thin vertical bar
|
|
402
403
|
for the line-tick markers (half height for the focus tick, half width for the stop tick,
|
|
403
404
|
matching their own glyphs), a two-band gradient standing in for the stall's dashed cap, and a
|
|
404
405
|
head-plus-stem shape for the error dot and the mixed glyph's own square-capped shape line. */
|
|
405
|
-
.voice-legend .r::before, .voice-legend .s::before, .voice-legend .st::before, .voice-legend .e::before, .voice-legend .f::before { width:3px; height:11px; border-radius:1.5px; }
|
|
406
|
+
.voice-legend .r::before, .voice-legend .s::before, .voice-legend .st::before, .voice-legend .e::before, .voice-legend .en::before, .voice-legend .f::before, .voice-legend .cd::before { width:3px; height:11px; border-radius:1.5px; }
|
|
406
407
|
.voice-legend .f::before { height:6px; }
|
|
407
408
|
.voice-legend .s::before { width:2px; }
|
|
408
409
|
.voice-legend .st::before { width:3px; height:11px; border:0; border-radius:0; background:repeating-linear-gradient(to bottom, var(--warn-2) 0 4px, transparent 4px 7px); }
|
|
409
410
|
.voice-legend .e::before { width:7px; height:14px; border-radius:0; background:radial-gradient(circle at 50% 3.5px, var(--error) 3.5px, transparent 4px), linear-gradient(var(--error),var(--error)) 50% 100%/3px 10px no-repeat; }
|
|
410
411
|
.voice-legend .mx::before { width:6px; height:14px; border-radius:0; background:linear-gradient(var(--text),var(--text)) 50% 0/6px 6px no-repeat, linear-gradient(var(--text),var(--text)) 50% 100%/3px 6px no-repeat; }
|
|
412
|
+
.voice-legend .ys::before { background:var(--warn-2); height:4px; vertical-align:2px; }
|
|
411
413
|
.voice-legend .mu::before { border:1px dashed var(--purple); background:repeating-linear-gradient(to bottom, var(--purple) 0 1px, transparent 1px 3px); }
|
|
412
414
|
.voice-legend .mb::before { width:7px; height:11px; border-radius:3.5px; background:var(--muted); }
|
|
413
415
|
/* A scale note, not a marker kind: a swatch would imply a marker colour that does not exist. */
|
|
@@ -691,6 +693,7 @@
|
|
|
691
693
|
carry the disagreement signal and the raw accent/muted tokens sat under 4.5:1 in light. */
|
|
692
694
|
.flagval.on { color:var(--accent-text); } .flagval.off { color:var(--text-2); } .flagval.dim { color:var(--muted-2); font-weight:400; }
|
|
693
695
|
.flagval.variant { font-variant-numeric:normal; font-family:ui-monospace,Menlo,Consolas,monospace; font-size:11.5px; }
|
|
696
|
+
.flagrestart { margin-left:6px; font-size:10.5px; white-space:nowrap; color:var(--text-2); }
|
|
694
697
|
.flagsview .dbout tr.overridden td { background:var(--hover); }
|
|
695
698
|
/* live observer patch: briefly highlight a row whose value just changed */
|
|
696
699
|
.flagsview .dbout tr.flash td { animation:flagflash 1.2s ease-out; }
|