/** * @license * Copyright 2026 Qwen * SPDX-License-Identifier: Apache-2.0 */ import type { BackendConfig, LiveConfig } from './config.js'; import { type LiveLanguage } from './i18n/messages.js'; import { probePeerSocketVerdict, readLiveSessionRecords } from './vendor/qwen-code-peer/index.js'; type ReadState = 'ready' | 'missing' | 'unreadable' | 'invalid'; type HttpFailure = 'unreachable' | 'auth-rejected' | 'invalid' | 'error'; type RegistryState = ReadState | 'truncated' | 'unsupported'; type ControllerState = 'configured-unverified' | 'missing' | 'invalid'; export interface PeerHomeDiagnostics { /** A local index, rather than a private filesystem path. */ home: number; settings: ReadState | 'enabled' | 'disabled' | 'unset' | 'truncated' | 'unknown'; inbound: 'accept' | 'hold' | 'refuse' | 'unset' | 'unknown'; registry: RegistryState; liveRecords: number; terminals: number; terminalInboxes: number; probed: number; reachable: number; dead: number; unknown: number; omitted: number; versions: string[]; } export interface PeerBackendDiagnostics { name: string; kind: BackendConfig['kind']; serve?: { location: 'local' | 'remote' | 'unknown'; state: HttpFailure | 'ready' | 'missing-features' | 'remote-unverified' | 'managed-unverified'; missingFeatures: string[]; version?: string; }; peers?: PeerHomeDiagnostics & { controller: ControllerState; reports: boolean; }; } export type PeerDiagnosticHint = 'settingsScope' | 'grant' | 'remote' | 'probeOnly' | 'hold' | 'unknownDelivery' | 'callAndMute' | 'serveRequired' | 'managedServe' | 'windows' | 'limits'; export interface PeerDiagnostics { v: 1; hasErrors: boolean; platform: 'supported' | 'unsupported'; backends: PeerBackendDiagnostics[]; omittedBackends: number; daemon: { state: ReadState | HttpFailure | 'protocol-mismatch' | 'stale'; host: 'installed' | 'missing' | 'unknown' | 'unsupported'; /** Existing read-only HTTP interfaces do not expose these states. */ call: 'unknown'; outputMuted: 'unknown'; version?: string; }; hints: PeerDiagnosticHint[]; } export interface PeerDiagnosticsOptions { /** Test seams only. No endpoint, grant mutation, or message-sending dependency. */ platform?: NodeJS.Platform; fetch?: typeof fetch; readRecords?: typeof readLiveSessionRecords; probeSocket?: typeof probePeerSocketVerdict; timeoutMs?: number; } /** Read-only evidence. No probe here proves controller authorization or playback. */ export declare function diagnoseQwenPeers(config: Pick, options?: PeerDiagnosticsOptions): Promise; export declare function formatPeerDiagnostics(result: PeerDiagnostics, language: LiveLanguage): string; export {};