import { AuthMode } from './harness/harness-detect.js'; import type { Harness, HarnessSupportCheck } from './harness/harness-spec.js'; export declare const NON_INTERACTIVE_TIMEOUT_MS = 10000; export type AgentClient = Harness; type ConnectStage = 'started' | 'checkpoint' | 'completed' | 'failed' | 'aborted' | 'post_install_failed'; export type ConnectFailureStage = 'prerequisite_check' | 'registration_cleanup' | 'registration' | 'registration_or_authentication' | 'client_oauth' | 'cli_install' | 'skill_install' | 'plugin_install' | 'authentication' | 'walkthrough_launch' | 'cli_verification'; export declare const CONNECT_FAILURE_REASONS: readonly ["harness_not_installed", "harness_command_unsupported", "harness_too_old", "key_auth_unsupported", "command_not_found", "timeout", "spawn_error", "nonzero_exit", "invalid_config", "user_abandoned", "process_terminated", "unexpected_error"]; export type ConnectFailureReason = (typeof CONNECT_FAILURE_REASONS)[number]; export type ConnectAuthMode = Exclude | 'deferred'; export type ConnectCheckpoint = 'prerequisite_ok' | 'registered' | 'oauth_done' | 'cli_installed' | 'skill_installed' | 'plugin_installed' | 'authenticated' | 'cli_verified' | 'walkthrough_launched' | 'walkthrough_prompt_printed'; export type CliFallbackOutcome = 'cli_verified' | 'cli_install_failed' | 'no_credentials' | 'invalid_credentials' | 'authentication_failed' | 'verification_failed' | 'abandoned'; /** Ctrl+C killed a setup child — abandonment, not error. */ export declare class ConnectInterruptedError extends Error { } /** Carried hoisted-install failure an earlier harness already reported. */ export declare class HoistedFailureReportedError extends Error { } /** A classified step failure; runGuarded forwards the reason. */ export declare class ConnectStepError extends Error { readonly failureReason: ConnectFailureReason; readonly harnessVersion?: string; readonly failureDetail?: string; constructor(message: string, failureReason: ConnectFailureReason, opts?: { harnessVersion?: string; cause?: unknown; failureDetail?: string; }); } /** Hoisted install predates this attempt's telemetry; the gap reads ~0 ms. */ export declare function withStageDuration(error: Error, stageDurationMs: number): Error; export declare function stageDurationOf(error: unknown): number | undefined; /** A bounded sign-in wait elapsed — unfinished, not broken. */ export declare class SignInTimeoutError extends ConnectStepError { constructor(message: string, cause?: unknown); } export declare function throwIfInterrupted(result: { signal?: string | null; error?: Error; }): void; export interface SpawnStepResult { status?: number | null; signal?: string | null; error?: Error; /** Inherited stdio leaves this null; only piped runs yield text. */ stderr?: unknown; } /** Bounded removal spawn shared by install cleanup and --uninstall; Ctrl+C throws. */ export declare function spawnRemoval(command: string, args: readonly string[], timeoutMs?: number): import("child_process").SpawnSyncReturns; /** Outcome plus a bounded stderr tail; the route sanitizes and caps the rest. */ export declare function spawnFailureDetail(result: SpawnStepResult): string; /** Classifies a spawn failure; interrupts throw instead. */ export declare function spawnStepError(message: string, result: SpawnStepResult, failureDetail?: string): ConnectStepError; export declare function commandNotFound(error: unknown): boolean; /** One command redoes every post-install step for a client. */ export declare function finishSetupCommand(client: AgentClient): string; export interface ConnectRunState { stage: ConnectFailureStage; settled: boolean; /** On state, not per-call: otherwise degraded installs never appear to fail. */ harnessDegraded?: boolean; /** Resolved after the probe, so callers read real key use rather than key presence. */ authMode?: ConnectAuthMode; } interface ConnectStageDetail { failedStage?: ConnectFailureStage; phase?: ConnectCheckpoint; failureReason?: ConnectFailureReason; harnessVersion?: string; /** The plugin the client pins, not a probe of what landed. */ pluginVersion?: string; authMode?: ConnectAuthMode; /** Orthogonal to `authMode`: a stored key wins over `mcp login` on a healthy client too. */ harnessDegraded?: boolean; /** Overrides the event-gap duration; the hoisted CLI install measures itself. */ stageDurationMs?: number; /** Dropped from the wire unless `failedStage` is set (route refine). */ failureDetail?: string; } export interface ConnectTelemetry { attemptId: string; track(stage: ConnectStage, detail?: ConnectStageDetail): void; setHarnessVersion(version?: string): void; setFallbackOutcome(outcome: CliFallbackOutcome): void; flush(): Promise; } /** Terminal events exactly once, whichever of flow or signal handler wins. */ export declare function settle(state: ConnectRunState, telemetry: ConnectTelemetry, stage: ConnectStage, detail?: ConnectStageDetail): void; /** Shared terminal handling: interrupted → aborted, else failed. */ export declare function runGuarded(state: ConnectRunState, telemetry: ConnectTelemetry, body: () => void | Promise): Promise; export interface SupportedCommand { command: string; displayName: string; supportCheck: HarnessSupportCheck; } /** Refresh paths need the advertised alternative without connect's version probe. */ export declare function probeSupportVariant(client: SupportedCommand): string | undefined; export declare function requireCommandSupport(client: SupportedCommand): { optionalSupported: boolean; keyAuthSupported: boolean; matchedVariant?: string; harnessVersion?: string; }; export declare function createConnectTelemetry(mcpUrl: string, client: AgentClient, opts?: { apiKey?: string; attemptId?: string; fallbackAttemptId?: string; }): ConnectTelemetry; export {};