/** * Host detection — which agent shell is this CLI running inside, and what is * its conversation id? * * The id is used as the *grouping key* for takes: every render fired from the * same host conversation lands in one VideoProject as successive takes. The * creative loop ("generate → watch → shorten the intro → re-render") spans * multiple skill invocations and multiple render jobs, so the conversation — * not the render job — is its natural boundary. * * Everything here reads the **child process environment only**. We deliberately * do not speak any host's private IPC (Codex exposes its thread id through an * App Server JSON-RPC channel, and finding "the current thread" there means * matching on cwd + status + recency — a heuristic, not an identity lookup, * which would silently group takes wrong). A host that hands us nothing simply * degrades one rung; see resolveTakeKey(). * * See docs/cli-project-binding-design.md §5.1 and appendix A. */ export interface HostSessionProvider { /** Host identifier; becomes the namespace of the grouping key. */ host: string; /** First provider whose detect() passes wins — ORDER MATTERS, see below. */ detect: (env: NodeJS.ProcessEnv) => boolean; /** Session-level id candidates, most-preferred first. */ sessionVars: string[]; } /** * Adding a host is a data-only change: append a row, touch nothing else. * Run `remixmate host probe` inside the new host to discover its variable names. * * ⚠️ ORDER IS LOAD-BEARING. CodeBuddy also sets `CLAUDE_SESSION_ID` (same value * as its own id), while real Claude Code uses the longer `CLAUDE_CODE_*` prefix. * Detecting Claude Code first — or matching on a bare `CLAUDE_` prefix — would * mislabel every CodeBuddy session. * * ⚠️ Prefer the ROOT session over a child/sub-agent one. Claude Code exposes * both (`CLAUDE_CODE_HOST_SESSION_ID` alongside a per-subagent * `CLAUDE_CODE_SESSION_ID`); grouping must follow the root so a render fired * from a subagent still joins the main take. */ export declare const HOST_PROVIDERS: HostSessionProvider[]; export interface HostSession { host: string; sessionId: string; } /** Identify the host and its root session id, or null when unrecognised. */ export declare function detectHostSession(env?: NodeJS.ProcessEnv): HostSession | null; /** * Normalise a declared host label. * * `video_project.client_host` is `varchar(32)`, and the value is rendered as a * badge, so free-form input gets slugified rather than trusted: lowercase, * non-alphanumerics collapsed to `-`, capped at 32. Anything that normalises to * empty is treated as absent — an unusable label should degrade to "no badge", * never to a garbage one. */ export declare function normaliseHostLabel(raw: string | undefined): string; /** * Host label for provenance, even when no session id could be read. * * Declaration wins over detection: the declaring party knows, the table guesses. */ export declare function detectHostLabel(env?: NodeJS.ProcessEnv): string; export interface TakeKey { /** `:`, or '' when nothing groups this invocation. */ key: string; host: string; /** Which rung produced the key — surfaced by `doctor` / `host probe`. */ source: 'host' | 'env-override' | 'render-job' | 'none'; } /** * Resolve the take grouping key. * * 1. a recognised host's root session id → ":" * 2. REMIXMATE_TAKE_KEY → "custom:" * 3. the render job id → "job:" * * Rung 2 is the escape hatch that matters: an unsupported host (or a user on * Codex) can export one variable and get correct grouping without waiting for a * CLI release. Rung 3 keeps the feature working everywhere, at the cost of * splitting one video's iterations across takes — acceptable as a floor, not as * a default. */ export declare function resolveTakeKey(jobId: number | undefined, env?: NodeJS.ProcessEnv): TakeKey; /** * Environment variable names that look like a session/thread identifier. * Used by `remixmate host probe` to onboard an unknown host in a minute. * Returns NAMES ONLY — values may carry tokens and are never printed. */ export declare function probeSessionVarNames(env?: NodeJS.ProcessEnv): string[];