litmus-cli 1.5.0-beta.1 → 1.5.0-beta.10
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 +26 -4
- package/dist/commands/connect.d.ts +18 -0
- package/dist/commands/connect.d.ts.map +1 -1
- package/dist/commands/connect.js +245 -49
- package/dist/commands/connect.js.map +1 -1
- package/dist/commands/doctor.d.ts +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +16 -4
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +25 -6
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/pause.d.ts.map +1 -1
- package/dist/commands/pause.js +12 -2
- package/dist/commands/pause.js.map +1 -1
- package/dist/cursor-session/extension.cjs +12 -3
- package/dist/cursor-session/package.json +3 -3
- package/dist/cursor-session/session.cjs +29 -6
- package/dist/index.js +10 -232
- package/dist/index.js.map +1 -1
- package/dist/lib/ai-tracking.d.ts +4 -0
- package/dist/lib/ai-tracking.d.ts.map +1 -1
- package/dist/lib/ai-tracking.js +68 -0
- package/dist/lib/ai-tracking.js.map +1 -1
- package/dist/lib/api.d.ts +2 -0
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/lib/api.js +33 -8
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/capture-notice-ping.d.ts +7 -27
- package/dist/lib/capture-notice-ping.d.ts.map +1 -1
- package/dist/lib/capture-notice-ping.js +10 -42
- package/dist/lib/capture-notice-ping.js.map +1 -1
- package/dist/lib/capture-nudge.d.ts +5 -7
- package/dist/lib/capture-nudge.d.ts.map +1 -1
- package/dist/lib/capture-nudge.js +19 -35
- package/dist/lib/capture-nudge.js.map +1 -1
- package/dist/lib/capture-selftest.d.ts +11 -0
- package/dist/lib/capture-selftest.d.ts.map +1 -1
- package/dist/lib/capture-selftest.js +44 -5
- package/dist/lib/capture-selftest.js.map +1 -1
- package/dist/lib/capture-startup-diagnostics.d.ts +15 -0
- package/dist/lib/capture-startup-diagnostics.d.ts.map +1 -0
- package/dist/lib/capture-startup-diagnostics.js +134 -0
- package/dist/lib/capture-startup-diagnostics.js.map +1 -0
- package/dist/lib/capture-storage-error.d.ts +10 -0
- package/dist/lib/capture-storage-error.d.ts.map +1 -0
- package/dist/lib/capture-storage-error.js +18 -0
- package/dist/lib/capture-storage-error.js.map +1 -0
- package/dist/lib/codex-capture-health.d.ts +21 -0
- package/dist/lib/codex-capture-health.d.ts.map +1 -0
- package/dist/lib/codex-capture-health.js +82 -0
- package/dist/lib/codex-capture-health.js.map +1 -0
- package/dist/lib/cursor-session.d.ts.map +1 -1
- package/dist/lib/cursor-session.js +4 -3
- package/dist/lib/cursor-session.js.map +1 -1
- package/dist/lib/editor-foreground.d.ts +9 -1
- package/dist/lib/editor-foreground.d.ts.map +1 -1
- package/dist/lib/editor-foreground.js +15 -0
- package/dist/lib/editor-foreground.js.map +1 -1
- package/dist/lib/environment-checks.d.ts +1 -3
- package/dist/lib/environment-checks.d.ts.map +1 -1
- package/dist/lib/environment-checks.js +2 -16
- package/dist/lib/environment-checks.js.map +1 -1
- package/dist/lib/errors.d.ts +2 -0
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +7 -0
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/file-monitor.d.ts +18 -0
- package/dist/lib/file-monitor.d.ts.map +1 -0
- package/dist/lib/file-monitor.js +87 -0
- package/dist/lib/file-monitor.js.map +1 -0
- package/dist/lib/hook-logger.cjs +76 -11
- package/dist/lib/hosted-capture.d.ts +4 -2
- package/dist/lib/hosted-capture.d.ts.map +1 -1
- package/dist/lib/hosted-capture.js +121 -26
- package/dist/lib/hosted-capture.js.map +1 -1
- package/dist/lib/hosted-watcher.js +9 -1
- package/dist/lib/hosted-watcher.js.map +1 -1
- package/dist/lib/init-location.d.ts +4 -0
- package/dist/lib/init-location.d.ts.map +1 -0
- package/dist/lib/init-location.js +36 -0
- package/dist/lib/init-location.js.map +1 -0
- package/dist/lib/installed-tools.d.ts +3 -0
- package/dist/lib/installed-tools.d.ts.map +1 -1
- package/dist/lib/installed-tools.js +31 -18
- package/dist/lib/installed-tools.js.map +1 -1
- package/dist/lib/launcher-cleanup-journal.d.ts +44 -0
- package/dist/lib/launcher-cleanup-journal.d.ts.map +1 -0
- package/dist/lib/launcher-cleanup-journal.js +196 -0
- package/dist/lib/launcher-cleanup-journal.js.map +1 -0
- package/dist/lib/launcher-inventory-cache.d.ts +44 -0
- package/dist/lib/launcher-inventory-cache.d.ts.map +1 -0
- package/dist/lib/launcher-inventory-cache.js +126 -0
- package/dist/lib/launcher-inventory-cache.js.map +1 -0
- package/dist/lib/launcher-preparation-cache.d.ts +46 -0
- package/dist/lib/launcher-preparation-cache.d.ts.map +1 -0
- package/dist/lib/launcher-preparation-cache.js +131 -0
- package/dist/lib/launcher-preparation-cache.js.map +1 -0
- package/dist/lib/mac-notifier.d.ts +4 -0
- package/dist/lib/mac-notifier.d.ts.map +1 -0
- package/dist/lib/mac-notifier.js +72 -0
- package/dist/lib/mac-notifier.js.map +1 -0
- package/dist/lib/node-version.d.ts +8 -0
- package/dist/lib/node-version.d.ts.map +1 -0
- package/dist/lib/node-version.js +23 -0
- package/dist/lib/node-version.js.map +1 -0
- package/dist/lib/notify.d.ts +4 -5
- package/dist/lib/notify.d.ts.map +1 -1
- package/dist/lib/notify.js +24 -25
- package/dist/lib/notify.js.map +1 -1
- package/dist/lib/portal-launcher-background.d.ts +2 -0
- package/dist/lib/portal-launcher-background.d.ts.map +1 -1
- package/dist/lib/portal-launcher-background.js.map +1 -1
- package/dist/lib/portal-launcher.d.ts +44 -5
- package/dist/lib/portal-launcher.d.ts.map +1 -1
- package/dist/lib/portal-launcher.js +417 -77
- package/dist/lib/portal-launcher.js.map +1 -1
- package/dist/lib/prepared-editor.d.ts.map +1 -1
- package/dist/lib/prepared-editor.js +20 -5
- package/dist/lib/prepared-editor.js.map +1 -1
- package/dist/lib/session-over.d.ts +2 -0
- package/dist/lib/session-over.d.ts.map +1 -1
- package/dist/lib/session-over.js +71 -12
- package/dist/lib/session-over.js.map +1 -1
- package/dist/lib/ssh-config-file.d.ts +13 -2
- package/dist/lib/ssh-config-file.d.ts.map +1 -1
- package/dist/lib/ssh-config-file.js +32 -27
- package/dist/lib/ssh-config-file.js.map +1 -1
- package/dist/lib/tool-installation-watcher.d.ts +20 -0
- package/dist/lib/tool-installation-watcher.d.ts.map +1 -0
- package/dist/lib/tool-installation-watcher.js +112 -0
- package/dist/lib/tool-installation-watcher.js.map +1 -0
- package/dist/lib/tracker.d.ts +1 -0
- package/dist/lib/tracker.d.ts.map +1 -1
- package/dist/lib/tracker.js +29 -4
- package/dist/lib/tracker.js.map +1 -1
- package/dist/lib/watcher.js +152 -101
- package/dist/lib/watcher.js.map +1 -1
- package/dist/lib/workspace-start-wait.d.ts +3 -1
- package/dist/lib/workspace-start-wait.d.ts.map +1 -1
- package/dist/lib/workspace-start-wait.js +36 -1
- package/dist/lib/workspace-start-wait.js.map +1 -1
- package/dist/notification-assets/litmus.icns +0 -0
- package/dist/notification-assets/litmus.png +0 -0
- package/dist/notification-assets/notifier.js +12 -0
- package/dist/program.d.ts +2 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +244 -0
- package/dist/program.js.map +1 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -8,7 +8,9 @@ Official CLI for [Litmus](https://www.litmushiring.com) engineering assessments.
|
|
|
8
8
|
npm install -g litmus-cli
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
Requires Node.js
|
|
11
|
+
Requires Node.js 24 or newer. If `node --version` reports an older major,
|
|
12
|
+
install Node 24 with your existing Node version manager, then run
|
|
13
|
+
`litmus setup-check` before starting an assessment.
|
|
12
14
|
|
|
13
15
|
### Permission denied while installing or upgrading (macOS / Linux)
|
|
14
16
|
|
|
@@ -300,7 +302,7 @@ Run `litmus init <token>` again to retry a failed AI supervisor startup.
|
|
|
300
302
|
|
|
301
303
|
## Requirements
|
|
302
304
|
|
|
303
|
-
- Node.js
|
|
305
|
+
- Node.js 24 or newer
|
|
304
306
|
- Git (recommended — without it, analysis loses commit history, iteration patterns, and process scoring signals; code quality scoring still works)
|
|
305
307
|
|
|
306
308
|
## Releasing (maintainers)
|
|
@@ -372,7 +374,27 @@ Linux users can opt in with `--cursor-agent-window`.
|
|
|
372
374
|
|
|
373
375
|
The bundled Litmus companion is installed for this handoff. If it is unavailable,
|
|
374
376
|
continue in the IDE and open Agents Window manually. Submission cleanup remains
|
|
375
|
-
opt-in with `--cursor-session-cleanup`; it
|
|
376
|
-
its Open Recent entry, but does not delete saved chats or
|
|
377
|
+
opt-in with `--cursor-session-cleanup`; it closes the exact clean assessment IDE
|
|
378
|
+
window and removes its Open Recent entry, but does not delete saved chats or
|
|
379
|
+
Agents sidebar entries. Dirty or unsupported windows remain open for review.
|
|
377
380
|
|
|
378
381
|
The default portal launcher reports connection preparation before workspace startup. The portal shows an indeterminate progress bar until the workspace is ready; preparation sessions expire if the CLI stops unexpectedly.
|
|
382
|
+
|
|
383
|
+
### Desktop notifications
|
|
384
|
+
|
|
385
|
+
Notifications use the transparent white Litmus mark. On macOS, the CLI builds
|
|
386
|
+
and ad-hoc signs a small Litmus applet with the system's `osacompile` and
|
|
387
|
+
`codesign` tools on first use, caching it under `~/.litmus/notifications/`.
|
|
388
|
+
No additional application or developer toolchain is needed. Windows uses the
|
|
389
|
+
bundled PNG in its toast, and Linux passes it to `notify-send`. Delivery remains
|
|
390
|
+
best effort and respects system notification settings.
|
|
391
|
+
|
|
392
|
+
Setup notifications require a confirmed configuration issue; missing AI
|
|
393
|
+
conversations alone do not trigger one. Hosted capture-risk episodes stay
|
|
394
|
+
diagnostic and produce no candidate setup warning. Notification guidance is no longer
|
|
395
|
+
written into the assessment folder. Existing CLI-owned notices are cleaned up;
|
|
396
|
+
candidate-edited files are preserved.
|
|
397
|
+
|
|
398
|
+
### Capture startup diagnostics
|
|
399
|
+
|
|
400
|
+
Failed local capture setup and `litmus doctor` report fixed diagnostic fields: storage errno/operation and home-versus-assessment location; the latest watcher startup timestamp, exit code/signal, allowlisted error classifications; and recorded session-retirement reason/time when available. Watcher error classifications come from that child’s structured failure receipt; shared stderr logs are not used to infer its cause. Raw stderr, local paths, token hashes and prompt/code contents are not included in these new summaries. Unavailable or legacy evidence remains explicitly unknown. Retirement markers remain terminal; these diagnostics never clear them or restart capture. A startup receipt or diagnostic upload does not prove successful capture.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type PreparedLauncher } from "../lib/portal-launcher-background.js";
|
|
2
|
+
import { prepareCursorSession } from "../lib/cursor-session.js";
|
|
2
3
|
import { ConnectionAttempt } from "../lib/connection-attempt.js";
|
|
4
|
+
import { type InstalledTool } from "../lib/installed-tools.js";
|
|
3
5
|
import { type ResolvedEditorCommand } from "../lib/editor-binary.js";
|
|
4
6
|
import type { NativeIde } from "../lib/editor-ide.js";
|
|
5
7
|
import { type EditorVersion, type SeedVerdict, type VerifyVerdict, type WorkspaceProbe } from "../lib/editor-server.js";
|
|
@@ -758,6 +760,8 @@ export declare function chatConfigActionForIdentity(ide: IdeChoice, state: "conf
|
|
|
758
760
|
*/
|
|
759
761
|
export declare function browserFallback(hasUrl: boolean, ideWasChosen: boolean): "browser" | "vscode" | "unavailable";
|
|
760
762
|
export interface ConnectOptions {
|
|
763
|
+
/** Explicit local-only recovery for a removed Railway preview's capture. */
|
|
764
|
+
forgetUnavailablePreview?: boolean;
|
|
761
765
|
/** ENG-3217: opt-in desktop experiment; never proof of agent attachment. */
|
|
762
766
|
cursorAgentWindow?: boolean;
|
|
763
767
|
cursorSessionCleanup?: boolean;
|
|
@@ -789,6 +793,20 @@ export interface TunnelSession {
|
|
|
789
793
|
attempt: ConnectionAttempt;
|
|
790
794
|
}
|
|
791
795
|
export declare function runConnect(tokenArg: string | undefined, ideOpt?: string, opts?: ConnectOptions): Promise<void>;
|
|
796
|
+
/**
|
|
797
|
+
* Register the local editor window for assessment-scoped teardown. The portal
|
|
798
|
+
* launcher must do this itself: unlike the older interactive editor flow, it
|
|
799
|
+
* never passes through the CLI-option branch that installs the companion.
|
|
800
|
+
*
|
|
801
|
+
* Failure is intentionally best-effort. A missing companion must not prevent a
|
|
802
|
+
* candidate from launching an otherwise usable editor; it only means the
|
|
803
|
+
* launcher cannot close that exact remote window automatically on submission.
|
|
804
|
+
*/
|
|
805
|
+
export declare function preparePortalEditorSession(app: InstalledTool, context: Pick<PreparedLauncher, "alias" | "backendUrl" | "token">, attempted: Set<string>, dependencies?: {
|
|
806
|
+
resolveEditorCommand: typeof resolveEditorCommand;
|
|
807
|
+
identifyEditorCli: typeof identifyEditorCli;
|
|
808
|
+
prepareCursorSession: typeof prepareCursorSession;
|
|
809
|
+
}): Promise<boolean>;
|
|
792
810
|
/** Used only by the detached launcher after the interactive setup has completed. */
|
|
793
811
|
export declare function runPreparedPortalLauncher(context: PreparedLauncher, onReady: () => void, signal: AbortSignal): Promise<void>;
|
|
794
812
|
//# sourceMappingURL=connect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/commands/connect.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2B,KAAK,gBAAgB,EAAE,MAAM,sCAAsC,CAAA;
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/commands/connect.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2B,KAAK,gBAAgB,EAAE,MAAM,sCAAsC,CAAA;AAMrG,OAAO,EAAwB,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAIhE,OAAO,EAA2B,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAoBvF,OAAO,EAA4C,KAAK,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAE9G,OAAO,KAAK,EAAE,SAAS,EAAE,M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, removeClaudeDesktopConnection } from "../lib/ai-tracking.js";
|
|
2
2
|
import { waitForWorkspace } from "../lib/workspace-start-wait.js";
|
|
3
3
|
import { startBackgroundLauncher } from "../lib/portal-launcher-background.js";
|
|
4
|
-
import { desktopRuntimeReady } from "../lib/desktop-readiness.js";
|
|
5
|
-
import { startPortalPreparation, runPortalLauncher, openDesktop, openTerminal, openNativeEditor } from "../lib/portal-launcher.js";
|
|
4
|
+
import { desktopAppProbeCommand, desktopRuntimeReady } from "../lib/desktop-readiness.js";
|
|
5
|
+
import { startPortalPreparation, runPortalLauncher, reportLauncherTiming, openDesktop, openTerminal, openNativeEditor, desktopLaunchOutcome, closeOwnedMacTerminal, removeTerminalLauncher } from "../lib/portal-launcher.js";
|
|
6
6
|
import { startHostedCapture } from "../lib/hosted-capture.js";
|
|
7
7
|
import { installSshForwardHook } from "../lib/install-ssh-forward-hook.js";
|
|
8
8
|
import { runSsh } from "./ssh.js";
|
|
9
9
|
import { cursorSessionOptions, prepareCursorSession } from "../lib/cursor-session.js";
|
|
10
10
|
import { ConnectionAttempt } from "../lib/connection-attempt.js";
|
|
11
|
-
import { editorAppBundle, waitForEditorDispatch } from "../lib/editor-foreground.js";
|
|
11
|
+
import { editorAppBundle, reselectEditorWindow, waitForEditorDispatch } from "../lib/editor-foreground.js";
|
|
12
12
|
import { createPreparedEditorLauncher, parseWorkspaceGeneration } from "../lib/prepared-editor.js";
|
|
13
13
|
import { createPreparedDesktopReadiness } from "../lib/prepared-desktop.js";
|
|
14
14
|
import { findInstalledExecutable } from "../lib/installed-tools.js";
|
|
15
|
+
import { clearLauncherInventoryCache, loadLauncherInventoryCache, saveLauncherInventoryCache } from "../lib/launcher-inventory-cache.js";
|
|
16
|
+
import { clearLauncherPreparationCache, hasLauncherPreparationCache, saveLauncherPreparationCache } from "../lib/launcher-preparation-cache.js";
|
|
17
|
+
import { attemptIndependentCleanup, queueLauncherCleanup, reconcileLauncherCleanup } from "../lib/launcher-cleanup-journal.js";
|
|
15
18
|
import { prepareVscodeServer } from "../lib/vscode-server-preparation.js";
|
|
16
19
|
import { closedState } from "../lib/session-state.js";
|
|
17
|
-
import { updateSshConfig,
|
|
20
|
+
import { updateSshConfig, createSshConfigCleanupPlan, executeSshConfigCleanupPlan } from "../lib/ssh-config-file.js";
|
|
18
21
|
import os from "os";
|
|
19
22
|
import path from "path";
|
|
20
23
|
import readline from "readline";
|
|
21
24
|
import { closeSync, constants, existsSync, mkdirSync, openSync, readFileSync, realpathSync } from "fs";
|
|
22
|
-
import { randomBytes } from "crypto";
|
|
25
|
+
import { createHash, randomBytes } from "crypto";
|
|
23
26
|
import { execFileSync, spawn, spawnSync } from "child_process";
|
|
24
27
|
import chalk from "chalk";
|
|
25
28
|
import ora from "ora";
|
|
@@ -887,6 +890,10 @@ export function launchEditor(ed, command, alias, logPath, foreground = false) {
|
|
|
887
890
|
const dispatched = bundle ? waitForEditorDispatch(child, () => {
|
|
888
891
|
try {
|
|
889
892
|
execFileSync("/usr/bin/open", ["-a", bundle], { timeout: 3000, stdio: "ignore" });
|
|
893
|
+
// App activation is not window selection: macOS can raise a stale window
|
|
894
|
+
// from a previous assessment. Re-issue the exact alias/folder request only
|
|
895
|
+
// after activation so the current assessment window ends in front.
|
|
896
|
+
reselectEditorWindow(spec.command, spec.args, spec.shell);
|
|
890
897
|
}
|
|
891
898
|
catch {
|
|
892
899
|
// Activation is best effort; a successful editor open remains usable.
|
|
@@ -1360,6 +1367,7 @@ export function browserFallback(hasUrl, ideWasChosen) {
|
|
|
1360
1367
|
return ideWasChosen ? "unavailable" : "vscode";
|
|
1361
1368
|
}
|
|
1362
1369
|
export async function runConnect(tokenArg, ideOpt, opts = {}) {
|
|
1370
|
+
const connectStartedAt = Date.now();
|
|
1363
1371
|
// A workspace cannot configure the candidate's local editor. Return before
|
|
1364
1372
|
// reading a token or creating an attempt, whose first checkpoint reports health.
|
|
1365
1373
|
if (isWorkspaceInstall(import.meta.url)) {
|
|
@@ -1376,6 +1384,13 @@ export async function runConnect(tokenArg, ideOpt, opts = {}) {
|
|
|
1376
1384
|
// is lost when a later step fails. The workspace lines follow it, so the candidate's
|
|
1377
1385
|
// last read is where they are and what the session ending looks like.
|
|
1378
1386
|
setErrorContext({ token, apiBase: resolveApiBase(process.env.LITMUS_API_URL) });
|
|
1387
|
+
// A previous worker may have stopped after the server committed submission but
|
|
1388
|
+
// before it removed this assessment's local connection. Reconcile before init,
|
|
1389
|
+
// which can legitimately refuse an already-submitted token.
|
|
1390
|
+
try {
|
|
1391
|
+
await reconcileLauncherCleanup(token, launcherCleanupHandlers(token));
|
|
1392
|
+
}
|
|
1393
|
+
catch { /* Never block a new connection on cleanup. */ }
|
|
1379
1394
|
const attempt = new ConnectionAttempt();
|
|
1380
1395
|
const skillImport = { report: null, footer: [], sshAlias: null, publishedPorts: [], tunnelSession: null };
|
|
1381
1396
|
// Register before entering the flow: a fast fatal report can settle before the
|
|
@@ -1383,7 +1398,7 @@ export async function runConnect(tokenArg, ideOpt, opts = {}) {
|
|
|
1383
1398
|
let releaseExitHold;
|
|
1384
1399
|
holdExitFor(new Promise((resolve) => { releaseExitHold = resolve; }));
|
|
1385
1400
|
try {
|
|
1386
|
-
await connectFlow(token, ideOpt, opts, skillImport, attempt);
|
|
1401
|
+
await connectFlow(token, ideOpt, opts, skillImport, attempt, connectStartedAt);
|
|
1387
1402
|
}
|
|
1388
1403
|
catch (error) {
|
|
1389
1404
|
await skillImport.rollbackCapture?.();
|
|
@@ -1430,7 +1445,7 @@ export async function runConnect(tokenArg, ideOpt, opts = {}) {
|
|
|
1430
1445
|
else
|
|
1431
1446
|
await runSsh(skillImport.sshAlias);
|
|
1432
1447
|
}
|
|
1433
|
-
async function connectFlow(token, ideOpt, opts, skillImport, attempt) {
|
|
1448
|
+
async function connectFlow(token, ideOpt, opts, skillImport, attempt, connectStartedAt) {
|
|
1434
1449
|
const verbose = Boolean(opts.verbose);
|
|
1435
1450
|
const apiBase = resolveApiBase(process.env.LITMUS_API_URL);
|
|
1436
1451
|
setErrorContext({ token, apiBase });
|
|
@@ -1510,7 +1525,7 @@ async function connectFlow(token, ideOpt, opts, skillImport, attempt) {
|
|
|
1510
1525
|
// ENG-3700: complete practice handoff and acknowledge local capture readiness
|
|
1511
1526
|
// before provisioning or connecting. Codespaces starts its clock from host-
|
|
1512
1527
|
// attested connection (or its setup release), not this metadata request.
|
|
1513
|
-
skillImport.rollbackCapture = await startHostedCapture(meta, token, apiBase);
|
|
1528
|
+
skillImport.rollbackCapture = await startHostedCapture(meta, token, apiBase, opts.forgetUnavailablePreview);
|
|
1514
1529
|
// 3. Start the workspace with our public key.
|
|
1515
1530
|
attempt.stage("workspace_start");
|
|
1516
1531
|
skillImport.stopPreparation?.update("starting_workspace");
|
|
@@ -1581,6 +1596,7 @@ async function connectFlow(token, ideOpt, opts, skillImport, attempt) {
|
|
|
1581
1596
|
start: () => startWorkspace(backendUrl, token, pubkey),
|
|
1582
1597
|
connection: () => getConnection(backendUrl, token),
|
|
1583
1598
|
ready: value => Boolean(value.healthy && (ide === "browser" || value.ssh_command)),
|
|
1599
|
+
needsReattach: value => ide !== "browser" && !value.ssh_command,
|
|
1584
1600
|
permanentFailure: error => error instanceof ServerError && Boolean(error.statusCode && error.statusCode >= 400 && error.statusCode < 500 && ![408, 429].includes(error.statusCode)),
|
|
1585
1601
|
keepWaiting: keepWaitingForWorkspace,
|
|
1586
1602
|
progress: (stage, elapsed) => {
|
|
@@ -1746,7 +1762,7 @@ async function connectFlow(token, ideOpt, opts, skillImport, attempt) {
|
|
|
1746
1762
|
return;
|
|
1747
1763
|
attempt.finish("ssh_ready");
|
|
1748
1764
|
skillImport.launcher = async () => {
|
|
1749
|
-
const ready = await startBackgroundLauncher({ backendUrl, token, alias, pageUrl, browserAvailable: Boolean(conn.browser_ide_url), assessmentName: meta.assessmentName });
|
|
1765
|
+
const ready = await startBackgroundLauncher({ backendUrl, token, alias, pageUrl, browserAvailable: Boolean(conn.browser_ide_url), assessmentName: meta.assessmentName, connectStartedAt });
|
|
1750
1766
|
if (ready) {
|
|
1751
1767
|
ora().succeed("Workspace ready · Laptop connected");
|
|
1752
1768
|
console.log("\nLaunch your tools from the assessment page.");
|
|
@@ -2004,22 +2020,27 @@ async function connectFlow(token, ideOpt, opts, skillImport, attempt) {
|
|
|
2004
2020
|
const resend = { done: false };
|
|
2005
2021
|
const launchPlan = editorLaunchPlan(editor, alias);
|
|
2006
2022
|
const launches = resendableLaunch((logPath) => launchEditor(editor, resolved.command, alias, logPath, launcherBetaEnabled));
|
|
2007
|
-
// Local UI extension: it survives a remote-host disconnect
|
|
2008
|
-
//
|
|
2009
|
-
|
|
2010
|
-
|
|
2023
|
+
// Local UI extension: it survives a remote-host disconnect and is registered
|
|
2024
|
+
// against this exact authority + workspace. Cursor also uses it for Agents
|
|
2025
|
+
// handoff; VS Code receives it only when launcher teardown is requested.
|
|
2026
|
+
if (editor.ide === "cursor" || opts.cursorSessionCleanup === true) {
|
|
2027
|
+
const sessionOptions = editor.ide === "cursor"
|
|
2028
|
+
? cursorSessionOptions(opts)
|
|
2029
|
+
: { handoff: false, cleanup: opts.cursorSessionCleanup === true };
|
|
2011
2030
|
const enabled = sessionOptions.handoff || sessionOptions.cleanup;
|
|
2012
2031
|
if (enabled)
|
|
2013
|
-
info(
|
|
2032
|
+
info(`Setting up the Litmus ${editor.label} companion for this workspace.`);
|
|
2014
2033
|
try {
|
|
2015
2034
|
const ready = await prepareCursorSession(resolved.command, alias, backendUrl, token, sessionOptions);
|
|
2016
2035
|
if (enabled)
|
|
2017
2036
|
skillImport.footer.push(ready
|
|
2018
|
-
?
|
|
2019
|
-
|
|
2037
|
+
? sessionOptions.cleanup
|
|
2038
|
+
? `${editor.label} companion enabled. When the assessment ends, it disconnects only this clean assessment workspace and removes its Open Recent entry. Saved chats are not deleted.`
|
|
2039
|
+
: `${editor.label} companion enabled for workspace handoff.`
|
|
2040
|
+
: `${editor.label} companion unavailable. Continue in the IDE; close this assessment window manually when it ends.`);
|
|
2020
2041
|
}
|
|
2021
2042
|
catch {
|
|
2022
|
-
skillImport.footer.push(
|
|
2043
|
+
skillImport.footer.push(`${editor.label} companion setup failed. Your normal IDE connection is unaffected; automatic window cleanup may be unavailable.`);
|
|
2023
2044
|
}
|
|
2024
2045
|
}
|
|
2025
2046
|
const outcome = await attemptEditorLaunch(editor, {
|
|
@@ -2147,60 +2168,228 @@ async function connectFlow(token, ideOpt, opts, skillImport, attempt) {
|
|
|
2147
2168
|
// which also carries why we do not simply close the window.
|
|
2148
2169
|
skillImport.footer.push(...editorEndingForewarning());
|
|
2149
2170
|
}
|
|
2171
|
+
function launcherCleanupHandlers(token, report = (outcome, entry) => {
|
|
2172
|
+
const stage = outcome === "queued" ? "cleanup_queued" : outcome === "retry" ? "cleanup_retry" :
|
|
2173
|
+
outcome === "abandoned" ? "cleanup_abandoned" : "cleanup_complete";
|
|
2174
|
+
reportLauncherTiming(entry.backendOrigin, token, stage, 0, { outcome: outcome === "abandoned" ? "failed" : "ok" });
|
|
2175
|
+
}) {
|
|
2176
|
+
return {
|
|
2177
|
+
cleanup: async (entry) => {
|
|
2178
|
+
const context = { backendUrl: entry.backendOrigin, token, alias: entry.alias };
|
|
2179
|
+
clearLauncherInventoryCache(context);
|
|
2180
|
+
clearLauncherPreparationCache(context);
|
|
2181
|
+
await attemptIndependentCleanup([
|
|
2182
|
+
() => closeOwnedMacTerminal(entry.alias),
|
|
2183
|
+
() => removeClaudeDesktopConnection(entry.alias, entry.assessmentName),
|
|
2184
|
+
() => removeTerminalLauncher(entry.alias),
|
|
2185
|
+
...(entry.ssh ? [() => executeSshConfigCleanupPlan(path.join(os.homedir(), ".ssh", "config"), entry.ssh)] : []),
|
|
2186
|
+
]);
|
|
2187
|
+
},
|
|
2188
|
+
report,
|
|
2189
|
+
};
|
|
2190
|
+
}
|
|
2191
|
+
/**
|
|
2192
|
+
* Register the local editor window for assessment-scoped teardown. The portal
|
|
2193
|
+
* launcher must do this itself: unlike the older interactive editor flow, it
|
|
2194
|
+
* never passes through the CLI-option branch that installs the companion.
|
|
2195
|
+
*
|
|
2196
|
+
* Failure is intentionally best-effort. A missing companion must not prevent a
|
|
2197
|
+
* candidate from launching an otherwise usable editor; it only means the
|
|
2198
|
+
* launcher cannot close that exact remote window automatically on submission.
|
|
2199
|
+
*/
|
|
2200
|
+
export async function preparePortalEditorSession(app, context, attempted, dependencies = { resolveEditorCommand, identifyEditorCli, prepareCursorSession }) {
|
|
2201
|
+
if (app.unavailable || (app.tool !== "vscode" && app.tool !== "cursor"))
|
|
2202
|
+
return false;
|
|
2203
|
+
const key = `${app.tool}:${app.command}`;
|
|
2204
|
+
if (attempted.has(key))
|
|
2205
|
+
return false;
|
|
2206
|
+
attempted.add(key);
|
|
2207
|
+
const editor = NATIVE_EDITORS[app.tool];
|
|
2208
|
+
const resolved = dependencies.resolveEditorCommand(editor);
|
|
2209
|
+
if (!resolved)
|
|
2210
|
+
return false;
|
|
2211
|
+
const command = resolved.command;
|
|
2212
|
+
if (dependencies.identifyEditorCli(editor, command).kind !== "match")
|
|
2213
|
+
return false;
|
|
2214
|
+
try {
|
|
2215
|
+
return await dependencies.prepareCursorSession(command, context.alias, context.backendUrl, context.token, {
|
|
2216
|
+
// The portal owns editor launch and intentionally keeps Cursor in its
|
|
2217
|
+
// assessment window. Handoff is only for the older interactive flow.
|
|
2218
|
+
handoff: false,
|
|
2219
|
+
cleanup: true,
|
|
2220
|
+
});
|
|
2221
|
+
}
|
|
2222
|
+
catch {
|
|
2223
|
+
return false;
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2150
2226
|
/** Used only by the detached launcher after the interactive setup has completed. */
|
|
2151
2227
|
export function runPreparedPortalLauncher(context, onReady, signal) {
|
|
2152
2228
|
const checkedDesktopApps = new Set();
|
|
2153
2229
|
const attemptedVscode = new Set();
|
|
2230
|
+
const attemptedEditorSessions = new Set();
|
|
2231
|
+
const seenPreparation = new Set();
|
|
2154
2232
|
const native = createPreparedEditorLauncher(context.alias);
|
|
2155
2233
|
const desktopReadiness = createPreparedDesktopReadiness(context.alias);
|
|
2156
|
-
const
|
|
2234
|
+
const sshConfig = path.join(os.homedir(), ".ssh", "config");
|
|
2235
|
+
const cleanupSsh = createSshConfigCleanupPlan(sshConfig, context.alias);
|
|
2236
|
+
let cleanupQueued = false;
|
|
2237
|
+
const cachedInventory = loadLauncherInventoryCache(context);
|
|
2238
|
+
const timing = (stage, elapsedMs, extra) => reportLauncherTiming(context.backendUrl, context.token, stage, elapsedMs, extra);
|
|
2239
|
+
const cleanupHandlers = launcherCleanupHandlers(context.token);
|
|
2157
2240
|
return runPortalLauncher({
|
|
2158
|
-
...context, onReady, signal,
|
|
2159
|
-
|
|
2241
|
+
...context, onReady, signal, cachedInventory: cachedInventory ?? undefined,
|
|
2242
|
+
onInventoryCacheRejected: () => {
|
|
2243
|
+
clearLauncherInventoryCache(context);
|
|
2244
|
+
clearLauncherPreparationCache(context);
|
|
2245
|
+
},
|
|
2246
|
+
onInventoryRevalidated: (tools, generationValue) => {
|
|
2247
|
+
const generation = parseWorkspaceGeneration(generationValue);
|
|
2248
|
+
if (generation)
|
|
2249
|
+
saveLauncherInventoryCache(context, generation, tools);
|
|
2250
|
+
},
|
|
2251
|
+
onRegistered: async (generationValue) => {
|
|
2160
2252
|
try {
|
|
2161
|
-
|
|
2253
|
+
await queueLauncherCleanup(context, generationValue, cleanupSsh, cleanupHandlers);
|
|
2254
|
+
cleanupQueued = Boolean(parseWorkspaceGeneration(generationValue));
|
|
2162
2255
|
}
|
|
2163
|
-
catch { /*
|
|
2164
|
-
|
|
2165
|
-
|
|
2256
|
+
catch { /* Cleanup durability must never prevent the launcher from becoming ready. */ }
|
|
2257
|
+
},
|
|
2258
|
+
reportTiming: timing,
|
|
2259
|
+
onSubmitted: async () => {
|
|
2260
|
+
const outcome = cleanupQueued
|
|
2261
|
+
? await reconcileLauncherCleanup(context.token, cleanupHandlers, undefined, true)
|
|
2262
|
+
: "none";
|
|
2263
|
+
// Old launcher backends do not return a generation. Preserve their prior,
|
|
2264
|
+
// exact-region cleanup behavior without putting an unfenced job on disk.
|
|
2265
|
+
if (outcome === "none") {
|
|
2266
|
+
await cleanupHandlers.cleanup({
|
|
2267
|
+
schema: 1, savedAt: Date.now(), backendOrigin: new URL(context.backendUrl).origin,
|
|
2268
|
+
alias: context.alias, assessmentName: context.assessmentName ?? "Assessment",
|
|
2269
|
+
generation: { epoch: 0, container_id: "legacy" }, ssh: cleanupSsh, attempts: 0, nextAttemptAt: 0,
|
|
2270
|
+
});
|
|
2271
|
+
cleanupHandlers.report?.("complete", {
|
|
2272
|
+
schema: 1, savedAt: Date.now(), backendOrigin: new URL(context.backendUrl).origin,
|
|
2273
|
+
alias: context.alias, assessmentName: context.assessmentName ?? "Assessment",
|
|
2274
|
+
generation: { epoch: 0, container_id: "legacy" }, ssh: cleanupSsh, attempts: 0, nextAttemptAt: 0,
|
|
2275
|
+
});
|
|
2166
2276
|
}
|
|
2167
|
-
catch { /* Preserve config if busy or externally edited. */ }
|
|
2168
2277
|
},
|
|
2169
2278
|
openUrl: url => url === context.pageUrl ? Promise.resolve(true) : openBrowser(url),
|
|
2170
|
-
prepareTools: async (installed, signal) => Promise.all(installed.map(async (app) => {
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2279
|
+
prepareTools: async (installed, signal, onPrepared, generationValue) => Promise.all(installed.map(async (app) => {
|
|
2280
|
+
const started = performance.now();
|
|
2281
|
+
const key = `${app.tool}:${app.command}`;
|
|
2282
|
+
const generation = parseWorkspaceGeneration(generationValue);
|
|
2283
|
+
let preparationInput = null;
|
|
2284
|
+
if (generation && !app.unavailable && app.tool === "vscode") {
|
|
2175
2285
|
const resolved = resolveEditorCommand(NATIVE_EDITORS.vscode);
|
|
2176
2286
|
const commit = resolved?.version.commit;
|
|
2177
2287
|
if (resolved && commit && identifyEditorCli(NATIVE_EDITORS.vscode, resolved.command).kind === "match") {
|
|
2178
|
-
|
|
2288
|
+
preparationInput = {
|
|
2289
|
+
generation, tool: app.tool, command: app.command,
|
|
2290
|
+
preparationFingerprint: createHash("sha256").update(`vscode-server:${commit}`).digest("hex"),
|
|
2291
|
+
};
|
|
2179
2292
|
}
|
|
2180
|
-
return app;
|
|
2181
2293
|
}
|
|
2182
|
-
if (app.unavailable
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2294
|
+
else if (generation && !app.unavailable && (app.tool === "codex" || app.tool === "claude")) {
|
|
2295
|
+
preparationInput = {
|
|
2296
|
+
generation, tool: app.tool, command: app.command,
|
|
2297
|
+
preparationFingerprint: createHash("sha256").update(desktopAppProbeCommand(app.tool)).digest("hex"),
|
|
2298
|
+
};
|
|
2299
|
+
}
|
|
2300
|
+
const cacheHit = preparationInput ? hasLauncherPreparationCache(context, preparationInput) : false;
|
|
2301
|
+
if (preparationInput)
|
|
2302
|
+
timing(cacheHit ? "tool_preparation_cache_hit" : "tool_preparation_cache_miss", performance.now() - started, { tool: app.tool });
|
|
2303
|
+
const temperature = cacheHit || seenPreparation.has(key) ? "warm" : "cold";
|
|
2304
|
+
timing("tool_preparation_started", 0, { tool: app.tool, temperature });
|
|
2305
|
+
let outcome = "ok";
|
|
2306
|
+
let prepared = app;
|
|
2307
|
+
let threw = false;
|
|
2308
|
+
try {
|
|
2309
|
+
if (!app.unavailable && (app.tool === "vscode" || app.tool === "cursor")) {
|
|
2310
|
+
// Registration is per assessment, so it must run even when the remote
|
|
2311
|
+
// server preparation itself came from the warm cache.
|
|
2312
|
+
await preparePortalEditorSession(app, context, attemptedEditorSessions);
|
|
2313
|
+
}
|
|
2314
|
+
if (cacheHit) {
|
|
2315
|
+
if (app.tool === "claude") {
|
|
2316
|
+
try {
|
|
2317
|
+
configureClaudeDesktopConnection(context.alias, context.assessmentName ?? "Assessment");
|
|
2318
|
+
}
|
|
2319
|
+
catch {
|
|
2320
|
+
outcome = "failed";
|
|
2321
|
+
prepared = { ...app, unavailable: "desktop_setup_failed" };
|
|
2322
|
+
return prepared;
|
|
2323
|
+
}
|
|
2191
2324
|
}
|
|
2192
|
-
|
|
2193
|
-
|
|
2325
|
+
return prepared;
|
|
2326
|
+
}
|
|
2327
|
+
if (app.tool === "vscode" && !app.unavailable) {
|
|
2328
|
+
if (attemptedVscode.has(app.command))
|
|
2329
|
+
return prepared;
|
|
2330
|
+
const resolved = resolveEditorCommand(NATIVE_EDITORS.vscode);
|
|
2331
|
+
const commit = resolved?.version.commit;
|
|
2332
|
+
if (resolved && commit && identifyEditorCli(NATIVE_EDITORS.vscode, resolved.command).kind === "match") {
|
|
2333
|
+
const ready = await prepareVscodeServer(context.alias, commit, signal);
|
|
2334
|
+
if (!ready) {
|
|
2335
|
+
outcome = "failed";
|
|
2336
|
+
return prepared;
|
|
2337
|
+
}
|
|
2338
|
+
attemptedVscode.add(app.command);
|
|
2339
|
+
}
|
|
2340
|
+
return prepared;
|
|
2341
|
+
}
|
|
2342
|
+
if (app.unavailable) {
|
|
2343
|
+
outcome = "failed";
|
|
2344
|
+
return prepared;
|
|
2345
|
+
}
|
|
2346
|
+
if (app.tool !== "codex" && app.tool !== "claude")
|
|
2347
|
+
return prepared;
|
|
2348
|
+
if (checkedDesktopApps.has(key))
|
|
2349
|
+
return prepared;
|
|
2350
|
+
if (await desktopRuntimeReady(context.alias, app.tool, signal)) {
|
|
2351
|
+
if (app.tool === "claude") {
|
|
2352
|
+
try {
|
|
2353
|
+
configureClaudeDesktopConnection(context.alias, context.assessmentName ?? "Assessment");
|
|
2354
|
+
}
|
|
2355
|
+
catch {
|
|
2356
|
+
outcome = "failed";
|
|
2357
|
+
prepared = { ...app, unavailable: "desktop_setup_failed" };
|
|
2358
|
+
return prepared;
|
|
2359
|
+
}
|
|
2194
2360
|
}
|
|
2361
|
+
checkedDesktopApps.add(key);
|
|
2362
|
+
return prepared;
|
|
2195
2363
|
}
|
|
2196
|
-
|
|
2197
|
-
|
|
2364
|
+
outcome = "failed";
|
|
2365
|
+
prepared = { ...app, unavailable: "workspace_not_ready" };
|
|
2366
|
+
return prepared;
|
|
2367
|
+
}
|
|
2368
|
+
catch (error) {
|
|
2369
|
+
outcome = "failed";
|
|
2370
|
+
threw = true;
|
|
2371
|
+
throw error;
|
|
2372
|
+
}
|
|
2373
|
+
finally {
|
|
2374
|
+
seenPreparation.add(key);
|
|
2375
|
+
if (!threw && !cacheHit && outcome === "ok" && !prepared.unavailable && preparationInput)
|
|
2376
|
+
saveLauncherPreparationCache(context, preparationInput);
|
|
2377
|
+
timing("tool_preparation_complete", performance.now() - started, { tool: app.tool, temperature, outcome });
|
|
2378
|
+
if (!threw)
|
|
2379
|
+
await onPrepared(prepared);
|
|
2198
2380
|
}
|
|
2199
|
-
return { ...app, unavailable: "workspace_not_ready" };
|
|
2200
2381
|
})),
|
|
2201
2382
|
launch: async (tool, installed, signal, launchContext) => {
|
|
2202
2383
|
if (tool === "vscode" || tool === "cursor") {
|
|
2203
|
-
|
|
2384
|
+
const started = performance.now();
|
|
2385
|
+
let verified = false;
|
|
2386
|
+
let readinessPath;
|
|
2387
|
+
const result = await native.launch(tool, launchContext?.generation, remember => openNativeEditor(tool, context.token, signal, undefined, value => { verified = true; readinessPath ?? (readinessPath = "poll"); remember(value); }, launchContext?.generation, launchContext?.remoteReady, () => { verified = true; readinessPath = "event"; }), signal);
|
|
2388
|
+
if (result === "failed")
|
|
2389
|
+
clearLauncherPreparationCache(context);
|
|
2390
|
+
if (verified)
|
|
2391
|
+
timing("remote_ready", performance.now() - started, { tool, requestId: launchContext?.requestId, outcome: "ok", readinessPath });
|
|
2392
|
+
return result;
|
|
2204
2393
|
}
|
|
2205
2394
|
if (tool === "browser") {
|
|
2206
2395
|
const current = await getConnection(context.backendUrl, context.token);
|
|
@@ -2208,13 +2397,16 @@ export function runPreparedPortalLauncher(context, onReady, signal) {
|
|
|
2208
2397
|
}
|
|
2209
2398
|
if (tool === "codex" || tool === "claude") {
|
|
2210
2399
|
const app = installed.find(i => i.tool === tool);
|
|
2211
|
-
if (!app || app.unavailable || !await desktopReadiness.check(tool, app.command, launchContext?.generation, signal))
|
|
2400
|
+
if (!app || app.unavailable || !await desktopReadiness.check(tool, app.command, launchContext?.generation, signal)) {
|
|
2401
|
+
clearLauncherPreparationCache(context);
|
|
2212
2402
|
return "failed";
|
|
2403
|
+
}
|
|
2213
2404
|
if (tool === "claude") {
|
|
2214
2405
|
try {
|
|
2215
2406
|
configureClaudeDesktopConnection(context.alias, context.assessmentName ?? "Assessment");
|
|
2216
2407
|
}
|
|
2217
2408
|
catch {
|
|
2409
|
+
clearLauncherPreparationCache(context);
|
|
2218
2410
|
return "failed";
|
|
2219
2411
|
}
|
|
2220
2412
|
}
|
|
@@ -2223,7 +2415,11 @@ export function runPreparedPortalLauncher(context, onReady, signal) {
|
|
|
2223
2415
|
const opened = await openDesktop(app, context.alias, signal);
|
|
2224
2416
|
if (!opened)
|
|
2225
2417
|
desktopReadiness.invalidate();
|
|
2226
|
-
|
|
2418
|
+
// Claude's deep link carries the exact current alias and assessment
|
|
2419
|
+
// folder, but an accepted OS handoff cannot prove that Claude selected
|
|
2420
|
+
// it. Keep the portal at an explicit confirmation state until the
|
|
2421
|
+
// generation-fenced native hook observes activity in this workspace.
|
|
2422
|
+
return desktopLaunchOutcome(tool, opened);
|
|
2227
2423
|
}
|
|
2228
2424
|
const terminal = installed.find(i => i.tool === "ssh");
|
|
2229
2425
|
return terminal && await openTerminal(context.alias, terminal.command, launchContext?.requestId) ? "dispatched" : "failed";
|