1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! Subagent / nested-transcript discovery, classification, and lifecycle.
//!
//! ## On-disk layout (empirically mapped against `~/.claude/projects`, 2026-06-07)
//!
//! A top-level session `<ENCODED>/<session-uuid>.jsonl` may own a sibling sidecar
//! directory `<ENCODED>/<session-uuid>/` holding its subagent transcripts in THREE
//! distinct shapes:
//!
//! - **(A) built-in Task/Agent-tool subagent** -
//! `subagents/agent-<hex>.jsonl` (+ companion `agent-<hex>.meta.json`). The `.jsonl`
//! uses the identical [`crate::model::Record`] model; its first record has `isSidechain:true`, an
//! `agentId` field (== the `agent-<hex>` filename stem), and `sessionId` == the
//! enclosing `<session-uuid>`. meta.json = `{agentType, description, name?, toolUseId}`.
//! - **(B) workflow / OMC workflow-subagent** -
//! `subagents/workflows/wf_<id>/agent-<hex>.jsonl` (+ `.meta.json`, the dominant
//! kind). Same record model + `isSidechain:true` + `agentId`. meta.json = `{agentType}`.
//! Its `cwd` is often a DEEPER in-session path - never re-encode a subagent cwd to
//! find its project dir.
//! - **(C) workflow journal** - `subagents/workflows/wf_<id>/journal.jsonl`. **NOT a
//! transcript**: records are workflow events `{agentId, key, type}` (`type` ∈
//! {`started`, `result`}) with no `message`/role. Excluded from every transcript
//! list/search; read ONLY to corroborate completion status.
//!
//! ## Kind is determined by PATH LOCATION, not `agentType`
//!
//! `agentType` is NOT a reliable kind discriminator: both (A) and (B) carry the same
//! spread of values (`Explore`, `general-purpose`, `oh-my-claudecode:*`); only the
//! special `workflow-subagent` value is workflow-exclusive. So the authoritative kind
//! is the on-disk location - directly under `subagents/` ⇒ [`SubagentKind::BuiltinTask`];
//! under `subagents/workflows/wf_*/` ⇒ [`SubagentKind::Workflow`] - with `agentType`
//! retained as a descriptive per-row sub-label.
//!
//! ## Linkage back to the parent session
//!
//! Primarily FILESYSTEM (the enclosing `<session-uuid>` dir name), corroborated by the
//! record's `sessionId` field (verified 600/0 mismatches). We use the directory name
//! as the parent-session id (it is the on-disk truth and needs no record parse).
use HashMap;
use ;
use ;
use *;
use crate;
use crate;
use crate;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;