Like [`ingest_cursor_transcript_event`], but bounds how many newly-appended bytes a single call will read. Cursor hooks pass byte caps to stay within hook budgets; capped reads still discover subagent transcript files, with each file independently subject to the same cap.
(
event_json: &str,
db: &GlobalDb,
max_new_bytes: Option<u64>,
)
| 393 | /// budgets; capped reads still discover subagent transcript files, with each file |
| 394 | /// independently subject to the same cap. |
| 395 | pub async fn ingest_cursor_transcript_event_capped( |
| 396 | event_json: &str, |
| 397 | db: &GlobalDb, |
| 398 | max_new_bytes: Option<u64>, |
| 399 | ) -> CursorTranscriptIngestStats { |
| 400 | let Ok(event) = serde_json::from_str::<Value>(event_json) else { |
| 401 | return CursorTranscriptIngestStats::default(); |
| 402 | }; |
| 403 | let Some(transcript_path) = event |
| 404 | .get("transcript_path") |
| 405 | .and_then(Value::as_str) |
| 406 | .filter(|path| !path.is_empty()) |
| 407 | .map(PathBuf::from) |
| 408 | else { |
| 409 | return CursorTranscriptIngestStats::default(); |
| 410 | }; |
| 411 | |
| 412 | // Cursor derives its project from the event, so the driver's project_root |
| 413 | // argument is unused by `CursorEventSource`; the transcript path's parent is |
| 414 | // a cheap, side-effect-free placeholder. |
| 415 | let project_root = transcript_path |
| 416 | .parent() |
| 417 | .map_or_else(|| transcript_path.clone(), Path::to_path_buf); |
| 418 | let source = CursorEventSource { |
| 419 | event, |
| 420 | transcript_path, |
| 421 | include_subagents: true, |
| 422 | }; |
| 423 | let stats = ingest_source(db, &source, &project_root, max_new_bytes).await; |
| 424 | CursorTranscriptIngestStats { |
| 425 | sessions_upserted: stats.sessions_upserted, |
| 426 | messages_upserted: stats.messages_upserted, |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | /// `agent-transcripts/<session>/subagents/<child>.jsonl` is the deepest layout |
| 431 | /// Cursor writes; a little headroom tolerates future nesting. |
no test coverage detected