/** * Host-harness detection. * * Detects whether the current process is itself running *under* one of the * supported harnesses (as a child of that harness process). Useful for tools * like `amux` to distinguish "invoked from a shell" vs "invoked from Claude * Code / Codex / ... as a subprocess". * * Detection is synchronous and purely environmental — it does not spawn * subprocesses or read files. Signals come from: * - env vars set by the enclosing harness * - argv patterns (best-effort) * - ppid heuristics when available * * Adapters contribute their known env signals via `hostEnvSignals`. A default * catalog is embedded here for when the adapters package is not loaded. */ import type { AgentName } from './types.js'; /** Information about a detected host harness. */ export interface HostHarnessInfo { /** The harness the current process is running under. */ agent: AgentName; /** Confidence in the detection. */ confidence: 'high' | 'medium' | 'low'; /** Which signal was strongest. */ source: 'env' | 'ppid' | 'argv'; /** The concrete matched signals, for diagnostics. */ matchedSignals: string[]; /** Adapter-contributed metadata extracted from the host environment. */ metadata?: Record; } /** Map from agent name -> env var names that indicate that harness is the parent. */ export type HostSignalMap = Readonly>; /** Function signature for per-agent metadata extraction from env. */ export type HostMetadataReader = (env: NodeJS.ProcessEnv) => Record; /** Map from agent name -> metadata reader. Used by adapter contributions. */ export type HostMetadataMap = Readonly>; export declare const DEFAULT_HOST_METADATA: HostMetadataMap; /** * Default env-signal catalog for the ten built-in harnesses. * * These are typical env vars known to be set by each harness when it * spawns a child shell/subprocess. Extend via `detectHostHarness({ signals })` * for plugin adapters. */ export declare const DEFAULT_HOST_SIGNALS: HostSignalMap; /** Options for `detectHostHarness`. */ export interface DetectHostHarnessOptions { /** Override or extend the signal catalog. Merged over defaults. */ signals?: HostSignalMap; /** Override or extend the metadata reader catalog. Merged over defaults. */ metadata?: HostMetadataMap; /** Override process.env (for tests). */ env?: NodeJS.ProcessEnv; /** Override process.argv (for tests). */ argv?: readonly string[]; } /** * Detect whether the current process is running inside a supported harness. * * Returns `null` if no signals match. Confidence: * - `high` if 2+ env signals for the same agent matched, or a single * explicit `CLAUDECODE=1`-style flag in addition to other hints. * - `medium` if exactly one env signal matched. * - `low` if only argv heuristics matched. */ export declare function detectHostHarness(opts?: DetectHostHarnessOptions): HostHarnessInfo | null;