/**
 * Which Claude account produced a transcript.
 *
 * A Claude `.jsonl` records `sessionId`, `cwd`, `version`, `gitBranch` and per-message
 * `usage`, but carries **no account identity** — no `accountUuid`, no
 * `organizationUuid`, no email. What agents-cli does have is the version layout: every
 * installed version gets its own home with its own `.claude.json` (`CLAUDE_CONFIG_DIR`
 * is swapped per version, see lib/exec.ts), so a home identifies an account.
 *
 * This matters because the default run strategy is `balanced` (lib/rotate.ts), which
 * sprays sessions across every signed-in account. Before this module the scanner
 * resolved ONE email process-globally and stamped it on every Claude session, so a
 * machine with several accounts reported all of its history under whichever one
 * happened to resolve first.
 *
 * Grouping is keyed on the **org** (`usageKey`), never the email: two orgs under one
 * email (a Team seat and a personal Max plan) are separate quota buckets and must stay
 * distinct — the same invariant `candidateIdentity` enforces in lib/rotate.ts.
 *
 * ## Evidence tiers
 *
 * Attribution is a pure function of (path, recorded version). It performs no per-file
 * I/O and does not need the transcript to still exist, which is what lets the v33
 * migration backfill already-indexed rows without re-parsing anything.
 *
 * 1. **The path names a home we can identify.** Strongest: the file physically lives in
 *    that home, including a retired `trash/` snapshot, which keeps its `.claude.json`.
 * 1b. **The path names a home that exists but is signed out.** Dark, named after that
 *    home. The location proves which config dir Claude used, so this deliberately beats
 *    a recorded version — attributing it to some other version's account would be a
 *    guess dressed as evidence.
 * 2. **The path is outside every known home, and the row records a version.** Resolve
 *    that version's own home. Covers the mutable `~/.claude` symlink and the routine
 *    archives under `<historyDir>/runs` that `readRoutineArchiveMeta` feeds in. The
 *    symlink's target moves with `agents use`, so "whatever it points at now" is weak
 *    evidence for old rows: on the machine this was developed against only 684 of 1,334
 *    such rows came from the version the symlink currently names, and 322 came from
 *    versions belonging to a *different* org.
 * 3. **Under the symlink with no recorded version at all.** Its current target is the
 *    only evidence there is, and the bucket says so via `evidence`. A version that IS
 *    recorded but resolves to no home stops at tier 2 and stays dark — it never
 *    reaches here.
 * 4. **None of the above.** An explicitly dark bucket, labelled with why. Never folded
 *    into a real account and never dropped.
 *
 * ## Harness scope: Claude only, deliberately
 *
 * Attribution is implemented for Claude and no other harness. It depends on the
 * per-version home carrying an `oauthAccount` in `.claude.json`, which is what makes a
 * home equal an account. The other harnesses do have per-version credential files
 * (`CREDENTIAL_FILE_SEGMENTS` in lib/agents.ts), so the mechanism generalizes — codex
 * stores an `auth.json` JWT, gemini a `google_accounts.json` — but each needs its own
 * identity extractor and its own notion of a quota bucket, and none of them has the
 * two-orgs-one-email problem that motivated keying on the org here.
 *
 * Until that lands, a non-Claude session has a NULL `account_key` and rolls up under
 * `unattributed:<agent>` — named after its harness rather than implying we tried and
 * failed. `--by account` on `agents insights cost` / `agents insights output` therefore reports Claude
 * accounts plus one bucket per other harness.
 */
/** The account a transcript is attributed to. */
export interface ClaudeAccountBucket {
    /**
     * Stable grouping key. For an attributed bucket this is the org-scoped `usageKey`
     * (e.g. `claude:org=<uuid>`). For an unattributed one it is `unattributed:<reason>`
     * so distinct dark sources never merge into each other or into a real account.
     */
    key: string;
    /** True when the key came from a real `oauthAccount`. */
    attributed: boolean;
    email: string | null;
    orgName: string | null;
    /** "Team", "Max", "Pro", … derived from `organizationType`. */
    plan: string | null;
    /** Display string: org and email, or the reason a bucket is dark. */
    label: string;
    /** Which evidence tier produced this attribution. */
    evidence: 'version-home' | 'recorded-version' | 'symlink-target' | 'none';
}
interface HomeEntry {
    /** Literal path prefix a transcript must start with to belong to this home. */
    prefix: string;
    bucket: ClaudeAccountBucket;
}
/** Resolver over the Claude homes present on this machine. */
export interface ClaudeAccountIndex {
    /** Version- and trash-home prefixes, longest first. Excludes the `~/.claude` symlink. */
    entries: HomeEntry[];
    /**
     * Config-dir prefixes of homes that exist but carry no `oauthAccount`. Kept
     * separately from `entries` so a transcript living in a signed-out home is reported
     * against THAT home rather than falling through to its recorded version: the file's
     * location is what proves which config dir Claude was pointed at.
     */
    darkHomes: Array<{
        prefix: string;
        version: string | null;
    }>;
    /**
     * Claude CLI version → the account that version ran as. `'ambiguous'` when retired
     * snapshots of one version disagree and no live home settles it, which is reported
     * as dark rather than guessed.
     */
    byVersion: Map<string, ClaudeAccountBucket | 'ambiguous'>;
    /** Whatever `~/.claude` points at right now; tier-3 evidence only. */
    symlinkBucket: ClaudeAccountBucket | null;
    /** Literal prefix of the live symlinked config dir. */
    symlinkPrefix: string;
}
/**
 * Enumerate every Claude home that could own an indexed transcript. Includes retired
 * `trash/` snapshots: they keep their `.claude.json`, so a transcript indexed before
 * its version was rotated out stays attributable.
 */
export declare function buildClaudeAccountIndex(): ClaudeAccountIndex;
/**
 * The account bucket a transcript belongs to. `recordedVersion` is the Claude CLI
 * version stored on the session row (`sessions.version`), which is what disambiguates
 * rows sitting under the mutable `~/.claude` symlink.
 *
 * Never returns null: a transcript that matches no known home resolves to an
 * explicitly dark bucket rather than being dropped or folded into a real account.
 * Backup mirrors (`<historyDir>/backups/claude/<stamp>/projects/…`) carry no
 * `.claude.json` of their own, so they resolve by recorded version like any other
 * out-of-home path, and go dark only when that version names no home.
 */
export declare function resolveClaudeAccount(index: ClaudeAccountIndex, filePath: string, recordedVersion?: string | null): ClaudeAccountBucket;
export {};
