litmus-cli 1.5.0 → 1.5.2-beta.1

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.
@@ -902,6 +902,9 @@ function buildDrainFrame(event, hookEventName) {
902
902
  for (const k of ["model", "input_tokens", "output_tokens", "cache_read_tokens", "status"]) {
903
903
  if (event[k] !== undefined) frame[k] = event[k]
904
904
  }
905
+ // ENG-4156: where a prompt's words came from, and a reply whose prompt never arrived.
906
+ if (event.recoveredFrom === "cursor_transcript") frame.recoveredFrom = event.recoveredFrom
907
+ if (event.promptMissing === true) frame.promptMissing = true
905
908
  // ENG-2344: the files Cursor's own `afterFileEdit` hook reported the agent
906
909
  // editing on this turn, in ENG-2191's `file_writes` shape. Carried whole
907
910
  // ahead of the body: the attribution is the part of this record a reader
@@ -929,9 +932,10 @@ function buildDrainFrame(event, hookEventName) {
929
932
  frame.text = body
930
933
  if (!trimEventToBytes(frame, "text", MAX_DRAIN_FRAME_BYTES)) return null
931
934
  }
932
- if (!frame.text) return null // trimmed to nothing: a husk with a turn id and
933
- // no content reads downstream as a captured
934
- // prompt that said nothing. Send no frame.
935
+ // Trimmed to nothing: a husk with a turn id and no content reads downstream as
936
+ // a captured prompt that said nothing. Send no frame. A stopped Cursor turn
937
+ // (ENG-4157) never had a body; its status is the content.
938
+ if (!frame.text && (body || !cursorStopStatus(event))) return null
935
939
  if (frame.text !== body) frame.textTruncated = true
936
940
  return JSON.stringify(frame)
937
941
  }
@@ -1221,6 +1225,7 @@ function readSettledTranscript(transcriptPath, parse, boundary) {
1221
1225
  }
1222
1226
  const text = parse(raw)
1223
1227
  if (text) best = text
1228
+ else if (text === false) best = null // the reader saw the answer withdrawn (ENG-4157)
1224
1229
 
1225
1230
  if (raw.length === lastSize) {
1226
1231
  stable += 1
@@ -1336,15 +1341,30 @@ function readCopilotTranscriptResponse(transcriptPath) {
1336
1341
  function parseCursorTranscript(raw) {
1337
1342
  let lastAnswer = null
1338
1343
  let tail = null
1344
+ // ENG-4157: Cursor closes every turn with `{type:"turn_ended", status}`, and
1345
+ // writes a stopped turn's marker BEFORE its user line (measured across this
1346
+ // machine's IDE transcripts: `A turn_ended:success turn_ended:error … U U`).
1347
+ // So anything after a closed turn, without a user line, is a new turn.
1348
+ let closed = false
1349
+ let endedEmpty = false
1339
1350
  for (const line of raw.split("\n")) {
1340
1351
  const trimmed = line.trim()
1341
1352
  if (!trimmed) continue
1342
1353
  let entry
1343
1354
  try { entry = JSON.parse(trimmed) } catch { continue }
1355
+ if (entry && entry.type === "turn_ended") {
1356
+ if (closed) { lastAnswer = null; endedEmpty = true } // a turn that ended with nothing in it
1357
+ closed = true
1358
+ continue
1359
+ }
1360
+ endedEmpty = false
1344
1361
  if (!entry || typeof entry !== "object" || !entry.message) continue
1345
1362
  const content = entry.message.content
1346
- if (entry.role === "user") {
1363
+ if (entry.role === "user" || closed) {
1347
1364
  lastAnswer = null // new turn — discard the previous turn's answer
1365
+ closed = false
1366
+ }
1367
+ if (entry.role === "user") {
1348
1368
  tail = "prompt"
1349
1369
  continue
1350
1370
  }
@@ -1360,13 +1380,18 @@ function parseCursorTranscript(raw) {
1360
1380
  tail = "tool"
1361
1381
  }
1362
1382
  }
1363
- return { text: lastAnswer, tailComplete: tail === "text" }
1383
+ return { text: lastAnswer, tailComplete: tail === "text", endedEmpty }
1364
1384
  }
1365
1385
 
1366
1386
  function readCursorTranscriptResponse(transcriptPath, boundary) {
1367
1387
  // Cursor acknowledges `stop` can fire before the turn's last lines are
1368
- // flushed, so wait for quiescence exactly like the Claude reader.
1369
- return readSettledTranscript(transcriptPath, raw => parseCursorTranscript(raw).text, boundary)
1388
+ // flushed, so wait for quiescence exactly like the Claude reader. A read
1389
+ // that ends on a turn closed with nothing in it (a stopped turn's marker
1390
+ // landing mid-wait) withdraws any answer an earlier read found (ENG-4157).
1391
+ return readSettledTranscript(transcriptPath, raw => {
1392
+ const parsed = parseCursorTranscript(raw)
1393
+ return parsed.endedEmpty ? false : parsed.text
1394
+ }, boundary)
1370
1395
  }
1371
1396
 
1372
1397
  /**
@@ -1406,6 +1431,17 @@ function cursorTurnMeta(data) {
1406
1431
  return Object.keys(meta).length ? meta : null
1407
1432
  }
1408
1433
 
1434
+ /** A Cursor `stop` for a turn that did not complete. An absent status is the
1435
+ * older payload and keeps the old reading. */
1436
+ function cursorTurnStopped(data) {
1437
+ return data?.hook_event_name === "stop" && cursorStopStatus(data)
1438
+ }
1439
+
1440
+ /** True for the statuses Cursor gives a turn that did not complete. */
1441
+ function cursorStopStatus(data) {
1442
+ return typeof data?.status === "string" && data.status !== "" && data.status !== "completed"
1443
+ }
1444
+
1409
1445
  /**
1410
1446
  * Extract the assistant response from a post-response hook payload. Returns
1411
1447
  * `{ text, sessionId }` with text=null when the payload carries no capturable
@@ -1475,6 +1511,12 @@ function extractResponse(data, toolName, options = {}) {
1475
1511
  if (data.hook_event_name === "afterAgentResponse") {
1476
1512
  return { ...common, text: typeof data.text === "string" && data.text ? data.text : null }
1477
1513
  }
1514
+ // ENG-4157: a turn the candidate stopped (`aborted`) or that failed
1515
+ // (`error`, e.g. offline) has no answer of its own in the transcript yet,
1516
+ // so reading it returns the previous turn's. Neither takes a reply. A
1517
+ // stopped turn is recorded as stopped; a failed one records nothing, since
1518
+ // Cursor's "Try again" answers it later in the same turn.
1519
+ if (cursorTurnStopped(data)) return { ...common, text: null, stopped: data.status === "aborted" }
1478
1520
  // `stop` is the CLI's only route: read the transcript it points at.
1479
1521
  // Returns null when transcripts are disabled (privacy mode sends
1480
1522
  // transcript_path: null), which is a capture gap, not an error.
@@ -1608,6 +1650,14 @@ function pruneTurns() {
1608
1650
  } catch { /* no dir yet, or unreadable */ }
1609
1651
  }
1610
1652
 
1653
+ // ENG-4156: the turn file also keeps digests of the session's recent prompts,
1654
+ // so a prompt recovered from Cursor's transcript is never one already captured.
1655
+ const RECENT_PROMPT_DIGESTS = 20
1656
+
1657
+ function promptDigest(text) {
1658
+ return crypto.createHash("sha256").update(String(text).replace(/\s+/g, " ").trim()).digest("hex")
1659
+ }
1660
+
1611
1661
  /** Mint + persist a turn id for this session's new prompt. */
1612
1662
  function captureTranscriptBoundary(file) {
1613
1663
  if (typeof file !== "string" || !path.isAbsolute(file)) return null
@@ -1620,13 +1670,16 @@ function captureTranscriptBoundary(file) {
1620
1670
  } catch { return null }
1621
1671
  finally { if (fd !== undefined) fs.closeSync(fd) }
1622
1672
  }
1623
- function startTurn(sessionId, generationId, selectionId, transcriptBoundary) {
1673
+ function startTurn(sessionId, generationId, selectionId, transcriptBoundary, promptText, ts = Date.now()) {
1624
1674
  if (!sessionId) return null
1625
1675
  const turnId = crypto.randomUUID()
1626
1676
  try {
1627
1677
  fs.mkdirSync(TURNS_DIR, { recursive: true })
1628
1678
  pruneTurns()
1629
- fs.writeFileSync(turnFile(sessionId), JSON.stringify({ turnId, ts: Date.now(), ...(typeof generationId === "string" ? { generationId } : {}), ...(typeof selectionId === "string" ? { selectionId } : {}), ...(transcriptBoundary ? { transcriptBoundary } : {}) }))
1679
+ const prompts = typeof promptText === "string"
1680
+ ? [...currentTurnRecord(sessionId).prompts, promptDigest(promptText)].slice(-RECENT_PROMPT_DIGESTS)
1681
+ : currentTurnRecord(sessionId).prompts
1682
+ fs.writeFileSync(turnFile(sessionId), JSON.stringify({ turnId, ts, ...(typeof generationId === "string" ? { generationId } : {}), ...(typeof selectionId === "string" ? { selectionId } : {}), ...(transcriptBoundary ? { transcriptBoundary } : {}), prompts }))
1630
1683
  } catch {
1631
1684
  // Unwritable — the event still gets its id, it just can't be paired with
1632
1685
  // the response. Better an unpaired pair than a dropped prompt.
@@ -1642,7 +1695,7 @@ function currentTurn(sessionId) {
1642
1695
  /** The most recent prompt's turn id AND the instant it was minted, so a
1643
1696
  * ledger keyed on the session can be cut at the turn's start. */
1644
1697
  function currentTurnRecord(sessionId) {
1645
- if (!sessionId) return { turnId: null, ts: null }
1698
+ if (!sessionId) return { turnId: null, ts: null, prompts: [] }
1646
1699
  try {
1647
1700
  const data = JSON.parse(fs.readFileSync(turnFile(sessionId), "utf8"))
1648
1701
  return {
@@ -1653,10 +1706,45 @@ function currentTurnRecord(sessionId) {
1653
1706
  selectionId: typeof data.selectionId === "string" ? data.selectionId : null,
1654
1707
  turnId: typeof data.turnId === "string" ? data.turnId : null,
1655
1708
  ts: typeof data.ts === "number" && Number.isFinite(data.ts) ? data.ts : null,
1709
+ prompts: Array.isArray(data.prompts) ? data.prompts.filter(d => typeof d === "string") : [],
1710
+ // A turn file from a logger before ENG-4156 has no prompt history to compare against.
1711
+ promptHistory: Array.isArray(data.prompts),
1656
1712
  }
1657
1713
  } catch {
1658
- return { turnId: null, ts: null }
1714
+ return { turnId: null, ts: null, prompts: [] }
1715
+ }
1716
+ }
1717
+
1718
+ /** The open turn now answers to `generationId` too: Cursor's "Try again" resends
1719
+ * the same prompt under a new generation (ENG-4156). */
1720
+ function adoptGeneration(sessionId, generationId) {
1721
+ if (!sessionId || typeof generationId !== "string" || !generationId) return
1722
+ try {
1723
+ const data = JSON.parse(fs.readFileSync(turnFile(sessionId), "utf8"))
1724
+ fs.writeFileSync(turnFile(sessionId), JSON.stringify({ ...data, generationId }))
1725
+ } catch { /* no open turn: the reply pairs as it did before */ }
1726
+ }
1727
+
1728
+ /**
1729
+ * The words of the newest user line in a Cursor transcript, or null (ENG-4156).
1730
+ * Cursor writes the typed prompt between `<user_query>` tags; a user line
1731
+ * without them is context Cursor added, not a prompt, so it yields null.
1732
+ */
1733
+ function lastCursorUserQuery(transcriptPath, boundary) {
1734
+ if (typeof transcriptPath !== "string" || !transcriptPath) return null
1735
+ let raw
1736
+ try { raw = readTranscriptRaw(transcriptPath, undefined, boundary?.offset ?? 0, boundary?.identity) } catch { return null }
1737
+ let last = null
1738
+ for (const line of raw.split("\n")) {
1739
+ let entry
1740
+ try { entry = JSON.parse(line) } catch { continue }
1741
+ if (!entry || entry.role !== "user" || !Array.isArray(entry.message?.content)) continue
1742
+ const text = entry.message.content
1743
+ .filter(b => b && b.type === "text" && typeof b.text === "string").map(b => b.text).join("\n")
1744
+ const queries = [...text.matchAll(/<user_query>([\s\S]*?)<\/user_query>/g)]
1745
+ last = queries.length ? queries[queries.length - 1][1].trim() || null : null
1659
1746
  }
1747
+ return last
1660
1748
  }
1661
1749
 
1662
1750
  // ── What a Stop has already sent (ENG-2793) ──────────────────────────
@@ -1960,22 +2048,29 @@ function pruneClaims() {
1960
2048
  */
1961
2049
  const CURSOR_RESPONSE_CLAIM_TTL_MS = 5 * 60 * 1000
1962
2050
 
1963
- function markCursorResponseCaptured(conversationId) {
2051
+ // The claim names the turn it captured (ENG-4157): a stopped turn's `stop` comes
2052
+ // with no `afterAgentResponse` of its own, so the previous turn's claim must not
2053
+ // silence it.
2054
+ function markCursorResponseCaptured(conversationId, turnId) {
1964
2055
  if (!conversationId) return
1965
2056
  try {
1966
2057
  fs.mkdirSync(CLAIM_DIR, { recursive: true })
1967
2058
  const safe = String(conversationId).replace(/[^A-Za-z0-9._-]/g, "_").slice(0, 128)
1968
- fs.writeFileSync(path.join(CLAIM_DIR, `cursor-resp-${safe}`), String(Date.now()))
2059
+ fs.writeFileSync(path.join(CLAIM_DIR, `cursor-resp-${safe}`), JSON.stringify({ turnId: turnId || null }))
1969
2060
  } catch { /* best effort — a duplicate is better than a dropped response */ }
1970
2061
  }
1971
2062
 
1972
- /** True when a `stop` invocation should stand down (the IDE hook already captured). */
1973
- function cursorResponseAlreadyCaptured(conversationId) {
2063
+ /** True when a `stop` invocation should stand down (the IDE hook already captured
2064
+ * this turn). A claim from before the turn field existed counts for any turn. */
2065
+ function cursorResponseAlreadyCaptured(conversationId, turnId) {
1974
2066
  if (!conversationId) return false
1975
2067
  try {
1976
2068
  const safe = String(conversationId).replace(/[^A-Za-z0-9._-]/g, "_").slice(0, 128)
1977
- const age = Date.now() - fs.statSync(path.join(CLAIM_DIR, `cursor-resp-${safe}`)).mtimeMs
1978
- return age < CURSOR_RESPONSE_CLAIM_TTL_MS
2069
+ const file = path.join(CLAIM_DIR, `cursor-resp-${safe}`)
2070
+ if (Date.now() - fs.statSync(file).mtimeMs >= CURSOR_RESPONSE_CLAIM_TTL_MS) return false
2071
+ let claimed
2072
+ try { claimed = JSON.parse(fs.readFileSync(file, "utf8")) } catch { return true }
2073
+ return !claimed || typeof claimed !== "object" || !("turnId" in claimed) || claimed.turnId === (turnId || null)
1979
2074
  } catch {
1980
2075
  return false
1981
2076
  }
@@ -2313,12 +2408,19 @@ async function main() {
2313
2408
  // BEFORE the transcript read so the CLI-only path doesn't pay for a poll it
2314
2409
  // is going to discard.
2315
2410
  const cursorConversation = parsed && (parsed.conversation_id || parsed.session_id)
2411
+ let standDownUnlessNewTurn = false
2316
2412
  if (
2317
2413
  effectiveTool === "cursor"
2318
2414
  && parsed && parsed.hook_event_name === "stop"
2319
- && cursorResponseAlreadyCaptured(selectionAtStart?.selectionId || cursorConversation)
2415
+ && cursorResponseAlreadyCaptured(selectionAtStart?.selectionId || cursorConversation, currentTurn(selectionAtStart?.selectionId || parsed.session_id || parsed.conversation_id))
2320
2416
  ) {
2321
- return
2417
+ // ENG-4156: a stop under a generation the open turn never saw may end a turn
2418
+ // whose prompt hook never fired, and the claim it matched is the previous
2419
+ // turn's. The transcript decides (below) before it stands down.
2420
+ const open = currentTurnRecord(selectionAtStart?.selectionId || parsed.session_id || parsed.conversation_id)
2421
+ if (!(open.promptHistory && open.generationId && typeof parsed.generation_id === "string"
2422
+ && parsed.generation_id && parsed.generation_id !== open.generationId)) return
2423
+ standDownUnlessNewTurn = true
2322
2424
  }
2323
2425
 
2324
2426
  // Cursor's transcript omits results. Its post-tool hooks carry the actual
@@ -2346,6 +2448,7 @@ async function main() {
2346
2448
  let sessionId = null
2347
2449
  let workspaceRoots = []
2348
2450
  let responseMeta = null
2451
+ let stoppedTurn = false
2349
2452
  // ENG-2793: the entry this reply ends on, recorded once the reply is written.
2350
2453
  let repliedEntry = null
2351
2454
  const responseBoundary = selectionAtStart && responseEvent ? currentTurnRecord(selectionAtStart.selectionId).transcriptBoundary : null
@@ -2356,6 +2459,10 @@ async function main() {
2356
2459
  sessionId = extracted.sessionId
2357
2460
  workspaceRoots = extracted.workspaceRoots || []
2358
2461
  responseMeta = extracted.meta || null
2462
+ stoppedTurn = extracted.stopped === true
2463
+ // A failed turn records nothing, and leaves its saved tool results for the
2464
+ // reply its "Try again" brings, instead of sealing them here.
2465
+ if (effectiveTool === "cursor" && cursorTurnStopped(parsed) && !stoppedTurn) return
2359
2466
  const blocks = extracted.blocks
2360
2467
  if (blocks && blocks.length && sessionId && !selftestNonce) {
2361
2468
  const unsent = unsentBlocks(blocks, lastRepliedEntry(selectionAtStart?.selectionId || sessionId))
@@ -2367,6 +2474,13 @@ async function main() {
2367
2474
  content = extracted.prompt
2368
2475
  sessionId = extracted.sessionId
2369
2476
  workspaceRoots = extracted.workspaceRoots || []
2477
+ // ENG-4156: Cursor's "Try again" after a failed turn fires this hook with an
2478
+ // empty prompt under a new generation. Nothing is written (it used to be
2479
+ // recorded as the prompt "null"). Which prompt it resends is decided when
2480
+ // its reply arrives, from the transcript (below): the open turn's own, or
2481
+ // one whose hook never fired.
2482
+ if (effectiveTool === "cursor" && !selftestNonce
2483
+ && !(typeof parsed?.prompt === "string" && parsed.prompt.trim())) return
2370
2484
  // Claude's own plumbing arrives on this hook too. It is not a candidate
2371
2485
  // prompt, so it is dropped rather than recorded as one — see
2372
2486
  // isSystemInjectedPrompt.
@@ -2381,7 +2495,7 @@ async function main() {
2381
2495
  let toolTrace = null
2382
2496
  const cursorResultsDir = responseEvent && effectiveTool === "cursor" && !selftestNonce
2383
2497
  ? cursorResultScope({ session_id: sessionId }, hostedAtStart) : null
2384
- if (responseEvent && !selftestNonce && typeof parsed?.transcript_path === "string"
2498
+ if (responseEvent && !selftestNonce && !stoppedTurn && typeof parsed?.transcript_path === "string"
2385
2499
  && (hostedWorkspaceHome || hostedAtStart?.disclosureVersion === "hosted_local_v2" || (selectionAtStart && matchingBoundary))) {
2386
2500
  try { toolTrace = parseToolEvidence(readTranscriptRaw(parsed.transcript_path, undefined, matchingBoundary?.offset ?? 0, matchingBoundary?.identity), effectiveTool, knownCaptureTokens) }
2387
2501
  catch { toolTrace = { version: 1, records: [], complete: false, reason: "transcript_unavailable", dropped: 0 } }
@@ -2389,7 +2503,7 @@ async function main() {
2389
2503
  if (responseEvent && effectiveTool === "cursor" && !selftestNonce && ["hosted_local_v2", SELECTED_CAPTURE_DISCLOSURE].includes(hostedAtStart?.disclosureVersion)) {
2390
2504
  toolTrace = cursorHookToolTrace(toolTrace, readCursorToolResults(sessionId, hostedAtStart, cursorResultsDir))
2391
2505
  }
2392
- if (!content && !toolTrace?.records?.length) return
2506
+ if (!content && !toolTrace?.records?.length && !stoppedTurn) return
2393
2507
  content = content || ""
2394
2508
 
2395
2509
  // Claim as LATE as possible — only once we know we have content and somewhere
@@ -2419,7 +2533,44 @@ async function main() {
2419
2533
  // same id. See the turn-pairing block above.
2420
2534
  const storageKey = selectionAtStart?.selectionId || sessionId
2421
2535
  const turnRecord = responseEvent && !selftestNonce ? currentTurnRecord(storageKey) : null
2422
- const turnId = selftestNonce ? null : responseEvent ? turnRecord.turnId : startTurn(storageKey, parsed?.generation_id, selectionAtStart?.selectionId, selectionAtStart ? captureTranscriptBoundary(parsed?.transcript_path) : null)
2536
+ let turnId = selftestNonce ? null : responseEvent ? turnRecord.turnId
2537
+ : startTurn(storageKey, parsed?.generation_id, selectionAtStart?.selectionId, selectionAtStart ? captureTranscriptBoundary(parsed?.transcript_path) : null, effectiveTool === "cursor" ? content : undefined)
2538
+
2539
+ // ENG-4156: a Cursor reply whose generation is not the open turn's may answer
2540
+ // a prompt `beforeSubmitPrompt` never delivered. Cursor skips that hook when
2541
+ // its hooks are not loaded yet (a remote window still opening), and the reply
2542
+ // was then filed under the previous prompt. A generation alone proves
2543
+ // nothing (3.21 gave `stop` its own), so the transcript's newest typed prompt
2544
+ // decides: the open turn's own words keep the reply there; words never
2545
+ // captured are recovered; words captured for an earlier turn mean this
2546
+ // reply's prompt is missing. With no typed prompt to read, the reply pairs as
2547
+ // before.
2548
+ let recoveredPrompt = null
2549
+ let promptMissing = false
2550
+ // No open turn at all is the same case for a conversation's first prompt.
2551
+ if (responseEvent && effectiveTool === "cursor" && !selftestNonce
2552
+ && typeof parsed.generation_id === "string" && parsed.generation_id
2553
+ && (!turnRecord.turnId || (turnRecord.promptHistory && turnRecord.generationId && parsed.generation_id !== turnRecord.generationId))
2554
+ && typeof parsed.transcript_path === "string"
2555
+ // A selected chat is read only from its open turn's boundary (ENG-4121).
2556
+ && (!selectionAtStart || matchingBoundary)) {
2557
+ const typed = lastCursorUserQuery(parsed.transcript_path, matchingBoundary)
2558
+ // Redacted like the hooked prompt was, so the digests compare and no secret is recovered.
2559
+ const query = typed ? redactCaptureText(typed, knownCaptureTokens) : null
2560
+ const digest = query ? promptDigest(query) : null
2561
+ if (!digest) {
2562
+ // Nothing typed to read: pair as before.
2563
+ } else if (digest === turnRecord.prompts[turnRecord.prompts.length - 1]) {
2564
+ adoptGeneration(storageKey, parsed.generation_id) // the open turn's own prompt
2565
+ } else {
2566
+ if (!turnRecord.prompts.includes(digest)) recoveredPrompt = query
2567
+ else promptMissing = true
2568
+ // From the open turn's start, so this turn's edits are not called late.
2569
+ turnId = startTurn(storageKey, parsed.generation_id, selectionAtStart?.selectionId, turnRecord.transcriptBoundary, recoveredPrompt ?? undefined, turnRecord.ts ?? Date.now())
2570
+ }
2571
+ }
2572
+ // Still the claimed turn: its reply is already recorded.
2573
+ if (standDownUnlessNewTurn && !recoveredPrompt && !promptMissing) return
2423
2574
 
2424
2575
  const event = selftestNonce
2425
2576
  ? {
@@ -2467,6 +2618,7 @@ async function main() {
2467
2618
  }
2468
2619
  if (sessionId) event.sessionId = sessionId
2469
2620
  if (turnId) event.turnId = turnId
2621
+ if (promptMissing) event.promptMissing = true
2470
2622
  // ENG-2344: the files Cursor's `afterFileEdit` hook reported the agent
2471
2623
  // editing since this turn's prompt, folded onto its reply. Attached BEFORE
2472
2624
  // the byte-cap loop, like the metering, so the body is trimmed around it.
@@ -2504,13 +2656,40 @@ async function main() {
2504
2656
  // Record that this turn's reply is captured, so the sibling `stop` hook
2505
2657
  // doesn't record it a second time (IDE only — see the claim helpers).
2506
2658
  if (responseEvent && effectiveTool === "cursor" && parsed.hook_event_name === "afterAgentResponse") {
2507
- markCursorResponseCaptured(selectionAtStart?.selectionId || cursorConversation)
2659
+ markCursorResponseCaptured(selectionAtStart?.selectionId || cursorConversation, turnId)
2508
2660
  }
2509
2661
 
2510
2662
  // Recheck after transcript reads/settling: teardown may have happened meanwhile.
2511
2663
  if (hostedAtStart && hostedCaptureWindow()?.litmusDir !== litmusDir) return
2512
2664
  if (selectionAtStart && selectedHostedConversation(hostedCaptureWindow(), effectiveTool, sessionId)?.selectionId !== selectionAtStart.selectionId) return
2513
2665
 
2666
+ // ENG-4156: the recovered prompt goes first, down the same lanes a hooked
2667
+ // prompt takes, one millisecond ahead of its reply so it sorts before it.
2668
+ // `recoveredFrom` says where its words came from: Cursor's transcript, a file
2669
+ // under the candidate's home, not the hook payload.
2670
+ if (recoveredPrompt) {
2671
+ const promptEvent = {
2672
+ ts: new Date(Date.parse(event.ts) - 1).toISOString(),
2673
+ type: "ai_prompt",
2674
+ tool: effectiveTool,
2675
+ prompt: recoveredPrompt,
2676
+ recoveredFrom: "cursor_transcript",
2677
+ id: crypto.randomUUID(),
2678
+ ...(hostedAtStart ? { capture_location: "local", capture_receipt: hostedAtStart.receipt } : {}),
2679
+ ...(selectionAtStart ? { capture_selection_id: selectionAtStart.selectionId } : {}),
2680
+ ...(sessionId ? { sessionId } : {}),
2681
+ ...(turnId ? { turnId } : {}),
2682
+ }
2683
+ sanitizeCaptureEvent(promptEvent, captureToken)
2684
+ if (!hostedAtStart || trimEventToBytes(promptEvent, "prompt", 6_010_000)) {
2685
+ try { fs.appendFileSync(path.join(litmusDir, "activity.jsonl"), JSON.stringify(promptEvent) + "\n") } catch { /* Non-critical */ }
2686
+ if (!hostedAtStart) {
2687
+ emitToDrain(promptEvent, "beforeSubmitPrompt")
2688
+ await uploadEvent(readConfig(litmusDir), promptEvent)
2689
+ }
2690
+ }
2691
+ }
2692
+
2514
2693
  // 1. Append to activity.jsonl (for submission ZIP)
2515
2694
  const logPath = path.join(litmusDir, "activity.jsonl")
2516
2695
  let logged = false
@@ -2687,7 +2866,7 @@ function boundedText(value, cap, known = []) {
2687
2866
  /** Only the final genuine user turn is in scope. A bounded tail without its
2688
2867
  * boundary is unavailable, never a license to import historical tool output. */
2689
2868
  function parseToolEvidence(raw, tool, known = []) {
2690
- let records = [], boundary = false, seen = new Set(), dropped = 0
2869
+ let records = [], boundary = false, seen = new Set(), dropped = 0, closed = false
2691
2870
  for (const [lineIndex, line] of raw.split('\n').entries()) {
2692
2871
  let row
2693
2872
  try { row = JSON.parse(line) } catch { continue }
@@ -2701,7 +2880,15 @@ function parseToolEvidence(raw, tool, known = []) {
2701
2880
  if (row.type === 'response_item' && row.payload?.type === 'message' && row.payload.role === 'user'
2702
2881
  && Array.isArray(row.payload.content) && row.payload.content.some(b => b?.type === 'input_text' && isCodexContextualText(b.text))) continue
2703
2882
  const codexPrompt = (row.type === 'event_msg' && row.payload?.type === 'user_message') || (row.type === 'response_item' && row.payload?.type === 'message' && row.payload.role === 'user' && Array.isArray(row.payload.content) && row.payload.content.some(b => b?.type === 'input_text'))
2704
- if (prompt || codexPrompt) { records = []; boundary = true; seen = new Set(); dropped = 0; continue }
2883
+ // ENG-4157: Cursor's turn markers bound a turn like a prompt does; a stopped
2884
+ // turn's marker lands before its user line (see parseCursorTranscript).
2885
+ if (row.type === 'turn_ended') {
2886
+ if (closed) { records = []; boundary = true; seen = new Set(); dropped = 0 }
2887
+ closed = true
2888
+ continue
2889
+ }
2890
+ if (prompt || codexPrompt || closed) { records = []; boundary = true; seen = new Set(); dropped = 0; closed = false }
2891
+ if (prompt || codexPrompt) continue
2705
2892
  if (!boundary) continue
2706
2893
  let candidates = []
2707
2894
  if ((row.type === 'assistant' || row.role === 'assistant') && Array.isArray(content)) {
@@ -2882,6 +3069,7 @@ module.exports = {
2882
3069
  scrubCaptureContent,
2883
3070
  CAPTURE_CREDENTIAL_PATTERNS,
2884
3071
  CAPTURE_CREDENTIAL_KEYS,
3072
+ readCursorTranscriptResponse,
2885
3073
  recordCursorToolResult,
2886
3074
  readCursorToolResults,
2887
3075
  cursorHookToolTrace,
@@ -8,7 +8,7 @@ export interface LaunchOutcome {
8
8
  reason?: "confirmation_required";
9
9
  }
10
10
  export declare function desktopLaunchOutcome(tool: "codex" | "claude", opened: boolean): LaunchResult | LaunchOutcome;
11
- type TimingStage = "cli_started" | "tool_inventory_complete" | "tool_preparation_started" | "tool_preparation_complete" | "launcher_ready" | "command_received" | "os_open_started" | "os_open_finished" | "remote_ready" | "result_acknowledged" | "cleanup_complete" | "cleanup_queued" | "cleanup_retry" | "cleanup_abandoned" | "tool_inventory_cache_hit" | "tool_inventory_cache_miss" | "tool_inventory_cache_rejected" | "tool_inventory_revalidated" | "tool_preparation_cache_hit" | "tool_preparation_cache_miss";
11
+ type TimingStage = "cli_started" | "tool_inventory_complete" | "tool_preparation_started" | "tool_preparation_complete" | "launcher_ready" | "command_received" | "os_open_started" | "os_open_finished" | "remote_ready" | "result_acknowledged" | "cleanup_complete" | "cleanup_queued" | "cleanup_retry" | "cleanup_abandoned" | "tool_inventory_cache_hit" | "tool_inventory_cache_miss" | "tool_inventory_cache_rejected" | "tool_inventory_revalidated" | "tool_preparation_cache_hit" | "tool_preparation_cache_miss" | "connect_started" | "detection_started" | "detection_completed" | "launch_requested" | "local_process_opened" | "remote_connection_ready" | "cleanup_target_attempted" | "cleanup_target_verified";
12
12
  /** Fixed-schema best-effort receipt; observation can never delay the launcher. */
13
13
  export declare function reportLauncherTiming(backendUrl: string, token: string, stage: TimingStage, elapsedMs: number, extra?: {
14
14
  tool?: LaunchTool;
@@ -17,6 +17,7 @@ export declare function reportLauncherTiming(backendUrl: string, token: string,
17
17
  requestId?: string;
18
18
  temperature?: "cold" | "warm" | "unknown";
19
19
  readinessPath?: "event" | "poll";
20
+ cleanupTarget?: "editor_session" | "terminal_window" | "claude_connection" | "terminal_launcher" | "ssh_config" | "browser_tab";
20
21
  }): void;
21
22
  export declare function desktopUrl(tool: "codex" | "claude", alias: string): string;
22
23
  export declare function spawnDetached(command: string, args: string[]): Promise<boolean>;
@@ -29,7 +30,7 @@ export declare function openTerminal(alias: string, terminal: string, requestId?
29
30
  /** Remove only the launcher file created for this exact assessment alias. */
30
31
  export declare function removeTerminalLauncher(alias: string, home?: string): void;
31
32
  /** Isolate existing fatal/exit paths and synchronous probes from the heartbeat process. */
32
- export declare function openNativeEditor(tool: "vscode" | "cursor", token: string, signal?: AbortSignal, forkFn?: typeof fork, onPrepared?: (editor: PreparedEditor) => void, generation?: WorkspaceGeneration, remoteReady?: Promise<boolean>, onRemoteReady?: () => void): Promise<LaunchResult>;
33
+ export declare function openNativeEditor(tool: "vscode" | "cursor", token: string, signal?: AbortSignal, forkFn?: typeof fork, onPrepared?: (editor: PreparedEditor) => void, generation?: WorkspaceGeneration, remoteReady?: Promise<boolean>, onRemoteReady?: () => void, onLocalOpened?: (outcome: "ok" | "failed") => void): Promise<LaunchResult>;
33
34
  /** Announce preparation before skills, key creation and workspace startup.
34
35
  * Older/unavailable launcher APIs must not prevent the assessment connection.
35
36
  * A killed process expires server-side; normal exits remove only this session.
@@ -51,8 +52,12 @@ export interface LauncherOptions {
51
52
  requestId: string;
52
53
  generation?: WorkspaceGeneration;
53
54
  remoteReady?: Promise<boolean>;
55
+ onLocalOpened?: (outcome?: "ok" | "failed") => void;
54
56
  }) => Promise<LaunchResult | LaunchOutcome>;
55
- prepareTools?: (installed: InstalledTool[], signal: AbortSignal, onPrepared: (tool: InstalledTool) => Promise<void>, generation?: unknown) => Promise<InstalledTool[]>;
57
+ prepareTools?: (installed: InstalledTool[], signal: AbortSignal, onPrepared: (tool: InstalledTool) => Promise<void>, generation?: unknown, preference?: {
58
+ tool: LaunchTool | null;
59
+ refresh?: () => Promise<void>;
60
+ }) => Promise<InstalledTool[]>;
56
61
  onReady?: () => void;
57
62
  onRegistered?: (generation: unknown) => void | Promise<void>;
58
63
  onSubmitted?: () => void | Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"portal-launcher.d.ts","sourceRoot":"","sources":["../../src/lib/portal-launcher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAIrD,OAAO,EAAiD,KAAK,mBAAmB,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAGnJ,OAAO,EAAiD,KAAK,mBAAmB,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAMnI,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEhE;AAED,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,iBAAiB,GAAG,QAAQ,CAAA;AACtE,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,YAAY,CAAA;IACpB,MAAM,CAAC,EAAE,uBAAuB,CAAA;CACjC;AACD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAG,YAAY,GAAG,aAAa,CAK5G;AACD,KAAK,WAAW,GAAG,aAAa,GAAG,yBAAyB,GAAG,0BAA0B,GACvF,2BAA2B,GAAG,gBAAgB,GAAG,kBAAkB,GAAG,iBAAiB,GACvF,kBAAkB,GAAG,cAAc,GAAG,qBAAqB,GAAG,kBAAkB,GAC9E,gBAAgB,GAAG,eAAe,GAAG,mBAAmB,GACxD,0BAA0B,GAAG,2BAA2B,GAAG,+BAA+B,GAC5F,4BAA4B,GAAG,4BAA4B,GAAG,6BAA6B,CAAA;AAE7F,kFAAkF;AAClF,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAA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