@slack/radar-mcp 1.23.0 → 1.25.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 +14 -7
- package/dist/mcp/dashboard-identity.d.ts +10 -0
- package/dist/mcp/dashboard-identity.js +20 -0
- package/dist/mcp/debug-package-reset.d.ts +5 -0
- package/dist/mcp/debug-package-reset.js +28 -0
- package/dist/mcp/flags-tools.d.ts +2 -0
- package/dist/mcp/flags-tools.js +10 -2
- package/dist/mcp/index.js +74 -54
- package/dist/mcp/radar-http.js +3 -1
- package/dist/mcp/session-enable.d.ts +1 -0
- package/dist/mcp/session-enable.js +52 -8
- package/dist/mcp/switchboard-tools.d.ts +5 -2
- package/dist/mcp/switchboard-tools.js +18 -12
- package/dist/mcp/tools.js +69 -169
- package/dist/mcp/web-child-env.js +2 -1
- package/dist/shared/android.d.ts +74 -10
- package/dist/shared/android.js +344 -103
- package/dist/shared/constants.d.ts +17 -5
- package/dist/shared/constants.js +59 -5
- package/dist/shared/db.d.ts +1 -1
- package/dist/shared/db.js +21 -14
- package/dist/shared/debug-log.js +2 -4
- package/dist/shared/enable-diagnosis.d.ts +27 -1
- package/dist/shared/enable-diagnosis.js +73 -0
- package/dist/shared/feature-flags.d.ts +11 -0
- package/dist/shared/feature-flags.js +18 -4
- package/dist/shared/log-session.d.ts +2 -1
- package/dist/shared/prefs.js +4 -5
- package/dist/shared/radar-request-raw.js +3 -1
- package/dist/shared/switchboard-note.d.ts +19 -0
- package/dist/shared/switchboard-note.js +76 -0
- package/dist/shared/switchboard-report.js +40 -4
- package/dist/shared/switchboard.d.ts +2 -1
- package/dist/shared/switchboard.js +17 -3
- package/dist/shared/transport.d.ts +24 -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 +4 -2
- package/dist/web/public/next/feature-flags.js +33 -0
- package/dist/web/public/next/feed.js +13 -2
- package/dist/web/public/next/flags.js +15 -3
- package/dist/web/public/next/registry.js +4 -4
- package/dist/web/public/next/store.js +89 -3
- package/dist/web/public/next/switchboard-note.js +76 -0
- package/dist/web/public/next/voice-model.js +196 -14
- package/dist/web/public/next/voice.js +68 -10
- package/dist/web/server.d.ts +17 -0
- package/dist/web/server.js +180 -35
- package/dist/web/spec.d.ts +1 -1
- package/dist/web/spec.js +1 -1
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// an adb-level broadcast failure (previously swallowed entirely), and a broadcast
|
|
9
9
|
// that exits 0 with no receiver (radar modules missing, wrong profile), which the
|
|
10
10
|
// old code reported as enabled:true with a failing ping.
|
|
11
|
-
import { deviceServerSilentError, readProcessState, } from "../shared/enable-diagnosis.js";
|
|
11
|
+
import { deviceServerSilentError, foreignRadarOwnerMessage, readProcessState, tokenViaArgvField, } from "../shared/enable-diagnosis.js";
|
|
12
12
|
import { ENABLE_PING_WAITS_MS } from "../shared/constants.js";
|
|
13
13
|
import { clearRadarTokenCache, openModeWarningAfterEnable, tokenFileMessage, unauthorizedMessageFor, } from "../shared/radar-token.js";
|
|
14
14
|
// The device answered the ping with HTTP 401: the token is refused, the app is not down.
|
|
@@ -30,6 +30,16 @@ async function verifiedPing(device, ping) {
|
|
|
30
30
|
}
|
|
31
31
|
return status;
|
|
32
32
|
}
|
|
33
|
+
function foreignOwnerOutcome(device, owner) {
|
|
34
|
+
return {
|
|
35
|
+
enabled: false,
|
|
36
|
+
body: {
|
|
37
|
+
error: foreignRadarOwnerMessage(device.logPackage ?? "the armed build", owner),
|
|
38
|
+
enabled: false,
|
|
39
|
+
platform: device.platform,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
33
43
|
function isArmed(status) {
|
|
34
44
|
return status.http_status === undefined && (status.status === "ok" || status.ok === true);
|
|
35
45
|
}
|
|
@@ -140,6 +150,9 @@ export async function refreshEnabledSession(timeoutMinutes, deviceSerial, deps)
|
|
|
140
150
|
const activeUserId = device.getActiveUserId?.();
|
|
141
151
|
if (status.android_user_id != null && activeUserId != null && String(status.android_user_id) !== String(activeUserId))
|
|
142
152
|
return null;
|
|
153
|
+
// Another build holding the socket answers healthy, so only the full flow can refuse it.
|
|
154
|
+
if (device.foreignRadarOwner?.(status) != null)
|
|
155
|
+
return null;
|
|
143
156
|
// The caller starts the capture after confirming the session is still current.
|
|
144
157
|
return {
|
|
145
158
|
enabled: true,
|
|
@@ -172,6 +185,8 @@ async function enableSession(timeoutMinutes, deviceSerial, deps) {
|
|
|
172
185
|
// always reset for the same reason; the MCP path was missing it.
|
|
173
186
|
destroyStream();
|
|
174
187
|
device.resetState();
|
|
188
|
+
// A fresh enable decides the build again, so drop the one a past arm held.
|
|
189
|
+
device.releaseDebugBuild?.();
|
|
175
190
|
// A re-enable may be a different device or a re-armed profile, so drop the cached DB
|
|
176
191
|
// user set + sqlite path; the next DB tool call re-detects the profiles fresh.
|
|
177
192
|
resetDbState();
|
|
@@ -285,11 +300,7 @@ async function enableSession(timeoutMinutes, deviceSerial, deps) {
|
|
|
285
300
|
};
|
|
286
301
|
}
|
|
287
302
|
if (activateError) {
|
|
288
|
-
//
|
|
289
|
-
// (armed by a prior session, or the broadcast timed out on a loaded device
|
|
290
|
-
// after landing), so probe before failing: a working server beats a pedantic
|
|
291
|
-
// error, and a dead one gets a real error instead of the old silent
|
|
292
|
-
// enabled:true + failing tools.
|
|
303
|
+
// A prior server may still answer despite the failed enable.
|
|
293
304
|
try {
|
|
294
305
|
await verifiedPing(device, ping);
|
|
295
306
|
}
|
|
@@ -297,7 +308,7 @@ async function enableSession(timeoutMinutes, deviceSerial, deps) {
|
|
|
297
308
|
return {
|
|
298
309
|
enabled: false,
|
|
299
310
|
body: {
|
|
300
|
-
error: error instanceof PingRefused
|
|
311
|
+
error: device.getLastActivateBareError?.() ? activateError : error instanceof PingRefused
|
|
301
312
|
? `Radar activation broadcast failed: ${activateError}. ${unauthorizedMessageFor(device)}`
|
|
302
313
|
: device.radarListenerHint
|
|
303
314
|
? `Radar activation failed: ${activateError}. ${device.radarListenerHint}`
|
|
@@ -308,6 +319,23 @@ async function enableSession(timeoutMinutes, deviceSerial, deps) {
|
|
|
308
319
|
};
|
|
309
320
|
}
|
|
310
321
|
}
|
|
322
|
+
// The broadcast cannot move a socket another build already holds. Ask before any spool or
|
|
323
|
+
// stream work so nothing is written under the wrong build. No answer yet is fine, the verify
|
|
324
|
+
// loop below asks again.
|
|
325
|
+
if (device.foreignRadarOwner) {
|
|
326
|
+
let early = null;
|
|
327
|
+
try {
|
|
328
|
+
early = await ping();
|
|
329
|
+
}
|
|
330
|
+
catch {
|
|
331
|
+
// Nothing bound yet.
|
|
332
|
+
}
|
|
333
|
+
const owner = early ? device.foreignRadarOwner(early) : null;
|
|
334
|
+
if (owner !== null) {
|
|
335
|
+
destroyStream();
|
|
336
|
+
return foreignOwnerOutcome(device, owner);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
311
339
|
// Open the session event spool, then backfill the device rings into it. The live
|
|
312
340
|
// SSE push can start DURING the backfill (the backfill pulls via the injected
|
|
313
341
|
// fetch, which opens the stream on its first call), so the trailing
|
|
@@ -325,10 +353,18 @@ async function enableSession(timeoutMinutes, deviceSerial, deps) {
|
|
|
325
353
|
// declaring it dead.
|
|
326
354
|
let status = null;
|
|
327
355
|
let saw401 = false;
|
|
356
|
+
let foreignOwner = null;
|
|
328
357
|
for (const waitMs of ENABLE_PING_WAITS_MS) {
|
|
329
358
|
await sleep(waitMs);
|
|
330
359
|
try {
|
|
331
|
-
|
|
360
|
+
const answer = await verifiedPing(device, ping);
|
|
361
|
+
// A foreign owner does not go away by waiting, so stop at once.
|
|
362
|
+
foreignOwner = device.foreignRadarOwner?.(answer) ?? null;
|
|
363
|
+
if (foreignOwner === null) {
|
|
364
|
+
status = answer;
|
|
365
|
+
// Holds the build that answered even when this enable's own broadcast failed.
|
|
366
|
+
device.adoptRadarOwner?.(answer);
|
|
367
|
+
}
|
|
332
368
|
break;
|
|
333
369
|
}
|
|
334
370
|
catch (error) {
|
|
@@ -336,6 +372,11 @@ async function enableSession(timeoutMinutes, deviceSerial, deps) {
|
|
|
336
372
|
saw401 = true;
|
|
337
373
|
}
|
|
338
374
|
}
|
|
375
|
+
if (foreignOwner !== null) {
|
|
376
|
+
destroyStream();
|
|
377
|
+
deps.onForeignOwnerAfterBackfill?.();
|
|
378
|
+
return foreignOwnerOutcome(device, foreignOwner);
|
|
379
|
+
}
|
|
339
380
|
if (status === null) {
|
|
340
381
|
destroyStream();
|
|
341
382
|
if (saw401) {
|
|
@@ -345,6 +386,7 @@ async function enableSession(timeoutMinutes, deviceSerial, deps) {
|
|
|
345
386
|
error: unauthorizedMessageFor(device),
|
|
346
387
|
enabled: false,
|
|
347
388
|
platform: device.platform,
|
|
389
|
+
...tokenViaArgvField(device),
|
|
348
390
|
},
|
|
349
391
|
};
|
|
350
392
|
}
|
|
@@ -361,6 +403,7 @@ async function enableSession(timeoutMinutes, deviceSerial, deps) {
|
|
|
361
403
|
error,
|
|
362
404
|
enabled: false,
|
|
363
405
|
platform: device.platform,
|
|
406
|
+
...tokenViaArgvField(device),
|
|
364
407
|
},
|
|
365
408
|
};
|
|
366
409
|
}
|
|
@@ -392,6 +435,7 @@ async function enableSession(timeoutMinutes, deviceSerial, deps) {
|
|
|
392
435
|
}
|
|
393
436
|
: {}),
|
|
394
437
|
...status,
|
|
438
|
+
...tokenViaArgvField(device),
|
|
395
439
|
...(openModeWarning ? { warning: openModeWarning } : {}),
|
|
396
440
|
},
|
|
397
441
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RadarTokenSender } from "../shared/radar-token.js";
|
|
2
|
+
import type { DeviceTransport } from "../shared/transport.js";
|
|
2
3
|
import { type SwitchboardExportGet } from "../shared/switchboard.js";
|
|
3
4
|
import { type RadarResponse } from "./radar-response.js";
|
|
4
5
|
export interface HandlerResult {
|
|
@@ -10,9 +11,11 @@ export declare const SWITCHBOARD_BUDGET_HINT = "Pass kind or lower limit; for th
|
|
|
10
11
|
export declare function handleGetSwitchboardSessions(fetch: RadarFetch): Promise<HandlerResult>;
|
|
11
12
|
export declare function handleGetSwitchboardSession(args: Record<string, unknown>, fetch: RadarFetch): Promise<HandlerResult>;
|
|
12
13
|
export declare const SESSION_DISABLED_SUFFIX_LINE = "Session disabled. Use /radar-enable to reconnect.";
|
|
14
|
+
type EnableErrorSource = Partial<Pick<DeviceTransport, "getLastActivateBareError">>;
|
|
15
|
+
export declare function sessionDisabledLine(transport?: EnableErrorSource, fallback?: string): string;
|
|
13
16
|
export declare const RECONNECT_ONLY_SUFFIX_LINE = "Use /radar-enable to reconnect.";
|
|
14
|
-
export declare function appendSessionDisabledSuffix(message: string, sessionJustDisabled: boolean): string;
|
|
15
17
|
export declare function handleExportSwitchboardSession(args: Record<string, unknown>, get: SwitchboardExportGet, sender: RadarTokenSender, now?: number, exportRoot?: string): Promise<HandlerResult>;
|
|
16
18
|
export declare function shouldExportSwitchboardOffline(requestedId: number | null, getHostRecords: (sessionId: number) => Record<string, unknown>[], getNewestHostSessionId: () => number | null): boolean;
|
|
17
19
|
export declare function handleExportSwitchboardSessionOffline(args: Record<string, unknown>, now?: number, exportRoot?: string): HandlerResult;
|
|
18
|
-
export declare function dispatchExportSwitchboardSession(args: Record<string, unknown>, isSessionEnabled: () => boolean, get: SwitchboardExportGet, sender: RadarTokenSender, now?: number, exportRoot?: string): Promise<HandlerResult>;
|
|
20
|
+
export declare function dispatchExportSwitchboardSession(args: Record<string, unknown>, isSessionEnabled: () => boolean, get: SwitchboardExportGet, sender: (RadarTokenSender & EnableErrorSource) | undefined, now?: number, exportRoot?: string): Promise<HandlerResult>;
|
|
21
|
+
export {};
|
|
@@ -8,7 +8,7 @@ import { MAX_RADAR_RESPONSE_BYTES } from "../shared/constants.js";
|
|
|
8
8
|
import { buildSwitchboardReport, capitalizeSwitchboardNote, stripSwitchboardControlChars, switchboardReportNotes } from "../shared/switchboard-report.js";
|
|
9
9
|
import { writeSwitchboardReportFile } from "../shared/switchboard-report-file.js";
|
|
10
10
|
import { getSpoolSwitchboardRecords, newestSpoolSwitchboardSessionId } from "./switchboard-spool.js";
|
|
11
|
-
import { assembleSwitchboardExport, hostOnlyGapCount, hostOnlySwitchboardDetail, nonNegativeIntArg, } from "../shared/switchboard.js";
|
|
11
|
+
import { assembleSwitchboardExport, hostOnlyGapCount, hostOnlySwitchboardDetail, nonNegativeIntArg, SWITCHBOARD_DEVICE_UNREACHABLE_ERROR, } from "../shared/switchboard.js";
|
|
12
12
|
import { buildApiPath, switchboardSessionQuery } from "./api-paths.js";
|
|
13
13
|
import { responseBudgetError } from "./radar-response.js";
|
|
14
14
|
export const SWITCHBOARD_BUDGET_HINT = "Pass kind or lower limit; for the whole session use query_session with source switchboard, which pages with a cursor.";
|
|
@@ -53,13 +53,14 @@ function parseSwitchboardExportId(args) {
|
|
|
53
53
|
return { ok: true, id: parsed };
|
|
54
54
|
}
|
|
55
55
|
export const SESSION_DISABLED_SUFFIX_LINE = "Session disabled. Use /radar-enable to reconnect.";
|
|
56
|
+
// An enable error that already names its fix wins over the fallback, same rule as session-enable.
|
|
57
|
+
export function sessionDisabledLine(transport, fallback) {
|
|
58
|
+
const bare = transport?.getLastActivateBareError?.()?.message.replace(/\.+$/, "");
|
|
59
|
+
const sentence = bare === undefined ? fallback : `${bare}.`;
|
|
60
|
+
return sentence === undefined ? SESSION_DISABLED_SUFFIX_LINE : `${sentence} ${SESSION_DISABLED_SUFFIX_LINE}`;
|
|
61
|
+
}
|
|
56
62
|
// For a session already off before the call: the report notes already say the session is off.
|
|
57
63
|
export const RECONNECT_ONLY_SUFFIX_LINE = "Use /radar-enable to reconnect.";
|
|
58
|
-
// switchboard.ts's messages are shared with the web export route, which has no session concept,
|
|
59
|
-
// so the MCP appends this itself when the export call is what disabled the session.
|
|
60
|
-
export function appendSessionDisabledSuffix(message, sessionJustDisabled) {
|
|
61
|
-
return sessionJustDisabled ? `${message} ${SESSION_DISABLED_SUFFIX_LINE}` : message;
|
|
62
|
-
}
|
|
63
64
|
export async function handleExportSwitchboardSession(args, get, sender, now = Date.now(), exportRoot = SWITCHBOARD_EXPORT_DIR) {
|
|
64
65
|
const parsedId = parseSwitchboardExportId(args);
|
|
65
66
|
if (!parsedId.ok)
|
|
@@ -112,22 +113,27 @@ export async function dispatchExportSwitchboardSession(args, isSessionEnabled, g
|
|
|
112
113
|
return handleExportSwitchboardSessionOffline(args, now, exportRoot);
|
|
113
114
|
}
|
|
114
115
|
const result = await handleExportSwitchboardSession(args, get, sender, now, exportRoot);
|
|
115
|
-
|
|
116
|
+
if (isSessionEnabled())
|
|
117
|
+
return result;
|
|
118
|
+
// The retry resets state before its re-arm, so only the re-arm's own enable can leave a bare error here.
|
|
119
|
+
return withSessionDisabledSuffix(result, sender);
|
|
116
120
|
}
|
|
117
|
-
//
|
|
118
|
-
|
|
121
|
+
// switchboard.ts's messages are shared with the web export route, which has no session concept,
|
|
122
|
+
// so the MCP adds this line itself. Touches only the returned data, never the file already on disk.
|
|
123
|
+
function withSessionDisabledSuffix(result, sender) {
|
|
119
124
|
const data = result.data;
|
|
120
125
|
if (data === null || typeof data !== "object" || Array.isArray(data))
|
|
121
126
|
return result;
|
|
122
127
|
const d = { ...data };
|
|
123
128
|
if (typeof d.error === "string") {
|
|
124
|
-
|
|
129
|
+
// Only the unreachable text gives way to the enable error; a build or write failure keeps its own message.
|
|
130
|
+
d.error = d.error === SWITCHBOARD_DEVICE_UNREACHABLE_ERROR ? sessionDisabledLine(sender, d.error) : `${d.error} ${sessionDisabledLine(sender)}`;
|
|
125
131
|
}
|
|
126
132
|
else {
|
|
127
133
|
if (Array.isArray(d.notes))
|
|
128
|
-
d.notes = [...d.notes,
|
|
134
|
+
d.notes = [...d.notes, sessionDisabledLine(sender)];
|
|
129
135
|
if (typeof d.summary === "string")
|
|
130
|
-
d.summary =
|
|
136
|
+
d.summary = `${d.summary} ${sessionDisabledLine(sender)}`;
|
|
131
137
|
}
|
|
132
138
|
return { data: d, isError: result.isError };
|
|
133
139
|
}
|