import { type ToolDiscoveryConfig } from './tool-discovery.js';
import z from '@deepseek-ai/schemastery';
import type { Context } from '@deepseek-ai/cordis';
import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
import { type ContentBlock } from '@deepseek-ai/dsh-llm';
type JsonValue = null | boolean | number | string | JsonValue[] | {
    [key: string]: JsonValue;
};
import type { McpReconnectPolicy, McpServerRecord } from '@zerowall/research-store/types';
import type { CreateMcpServerRequest, McpSchemaObject, McpServerDto, UpdateMcpServerRequest } from '../shared/types.js';
export type { CreateMcpServerRequest, McpRuntimeState, McpServerDto, McpToolDetail, UpdateMcpServerChanges, UpdateMcpServerRequest } from '../shared/types.js';
export declare const SCIMASTER_API_KEY_CREDENTIAL = "zerowall.mcp.scimaster_api_key";
export declare const SCIMASTER_API_KEY_URL = "https://scimaster.bohrium.com/vibe-write/home";
export declare const HUAGONGSHE_URL = "https://huagongshe.com/mcp";
export declare const HUAGONGSHE_CREDENTIAL = "zerowall.mcp.huagongshe_token";
export declare const HUAGONGSHE_AUTH_ENV = "HUAGONGSHE_MCP_AUTHORIZATION";
export declare const GPSADB_MCP_URL = "https://gpsadb.gzdlab.com/mcp";
export declare const GPSADB_SERVER_NAME = "gpsadb";
export declare const RDATALINUX_R_MCP_URL = "https://rmcp.chengxunkeji.cn/r-platform/mcp";
export declare const RDATALINUX_SERVER_NAME = "zerowallrmcp";
export declare const RDATALINUX_BIOMNI_SERVER_NAME = "rbioagent";
export declare const RDATALINUX_R_PLATFORM_SERVER_NAME = "rplatform";
export declare const RDATALINUX_RPLOTFIGURE_SERVER_NAME = "rplotfigure";
export declare const RDATALINUX_R_MCP_AUTHORIZATION_CREDENTIAL = "zerowall.mcp.rdatalinux_authorization";
export declare const RDATALINUX_R_MCP_AUTHORIZATION_ENV = "R_PLATFORM_MCP_AUTHORIZATION";
export declare function hasEnvironmentCredential(name: string, getCredential: (key: string) => Promise<string | undefined>, environment?: NodeJS.ProcessEnv): Promise<boolean>;
/** Resolve the AI Cloud group secret key without accepting arbitrary providers. */
export declare function aiCloudCredentialKey(provider: string): string | undefined;
type RuntimeMcpConfig = {
    serverName: string;
    toolCallTimeoutMs: number;
    failOnStartupError: boolean;
    reconnect: McpReconnectPolicy;
    enabledTools?: string[];
} & ({
    transport: 'stdio';
    command: string;
    args: string[];
    env: Record<string, string>;
    cwd: string;
} | {
    transport: 'streamable-http';
    url: string;
    headers: Record<string, string>;
});
export interface ResolvedMcpConfig {
    config?: RuntimeMcpConfig;
    missingEnvironmentVariables: string[];
}
/**
 * Resolve a model provider's API key without exposing it to the model or
 * persisting it in an MCP request. Environment credentials are stored by the
 * environment plugin under lowercase names, while hydrate() also mirrors
 * them into process.env for providers that use native discovery.
 */
export declare function providerCredentialNames(provider: string): string[];
export interface CompactCapabilityRecord {
    id: string;
    publicTool: string;
    summary: string;
    inputSchema?: JsonValue;
    backend: 'zerowallrmcp' | 'bio';
}
declare module '@deepseek-ai/cordis' {
    interface Context {
        zerowallMcp: ZeroWallMcpService;
    }
    interface Events {
        'mcp-client/status'(serverName: string, state: 'starting' | 'active' | 'error', error?: string): void;
    }
}
export declare class ZeroWallMcpService extends TypertRemoteService {
    private readonly discovery;
    static inject: string[];
    private managed;
    private readonly connecting;
    private disposed;
    private backgroundStarted;
    private readonly fibers;
    /** Tools observed after the corresponding Fiber completed its initial sync. */
    private readonly registeredTools;
    /** Reconcile version whose initial connection and tools/list have settled. */
    private readonly readyVersions;
    private readonly statuses;
    private readonly reconcileVersions;
    private readonly recordsReady;
    private operation;
    private environmentPoller;
    private environmentFileSignature;
    private environmentSignature;
    private environmentRefreshInFlight;
    private readonly secrets;
    private readonly internalProjectBootstrapCalls;
    private readonly mcpToolIndex;
    private toolCacheWrite;
    private readonly failureCooldownUntil;
    /** Persistent connections belong to this plugin, never a temporary RPC/agent caller. */
    private readonly connectionContext;
    private readonly includeDiscoveredTools;
    constructor(ctx: Context, discovery?: ToolDiscoveryConfig);
    private compactPayload;
    /**
     * Return only names that still have a live Host schema. The persisted tool
     * index and the connection generation are useful hints, but neither is an
     * execution authority after a remote server changes its tools/list.
     */
    private liveToolNames;
    /**
     * FigureYa is exposed by older zerowallrmcp servers as a compact catalog tool, but
     * newer servers route the same operations through r_runtime. Keep the raw
     * path for compatibility and transparently fall back to the workflow route
     * when the old tool is absent or rejected as unknown.
     */
    private figureyaCatalogRequest;
    private includeToolsForAgent;
    includeConnectedToolsForAgent(agent: unknown, serverName?: string): void;
    private ensureRmcpTool;
    private isUnknownRmcpTool;
    private rmcpWorkflowId;
    private tryRmcpWorkflowFallback;
    private executeRmcpTool;
    workflowRequest(action: string, args: unknown, exec: any): Promise<unknown>;
    searchCompactCapabilities(query: string, detailId: string | undefined, limit: number, exec: any): Promise<CompactCapabilityRecord[]>;
    executeCompactCapability(id: string, args: unknown, exec: any): Promise<{
        target: string;
        content: ContentBlock[];
        value: unknown;
    }>;
    list(): Promise<McpServerDto[]>;
    create(input: CreateMcpServerRequest): Promise<McpServerDto>;
    update(input: UpdateMcpServerRequest): Promise<McpServerDto>;
    deleteConnection(id: string): Promise<void>;
    reload(id: string): Promise<McpServerDto>;
    getSciMasterCredentialStatus(): Promise<{
        configured: boolean;
    }>;
    setSciMasterApiKey(apiKey: string): Promise<McpServerDto | undefined>;
    clearSciMasterApiKey(): Promise<McpServerDto | undefined>;
    getHuagongsheCredentialStatus(): Promise<{
        configured: boolean;
    }>;
    setHuagongsheApiKey(token: string): Promise<McpServerDto>;
    clearHuagongsheApiKey(): Promise<void>;
    getRdatalinuxCredentialStatus(): Promise<{
        configured: boolean;
        endpoint: string;
    }>;
    setRdatalinuxAuthorization(value: string): Promise<McpServerDto | undefined>;
    clearRdatalinuxAuthorization(): Promise<McpServerDto | undefined>;
    private exclusive;
    /** Follow validated Python dependency generations published by this Host. */
    private startEnvironmentRefresh;
    private pollEnvironment;
    pendingEditors(): Array<{
        artifact_id: string;
        url: string;
        sessionId: string;
        cwd: string;
        createdAt: number;
    }>;
    acknowledgeEditor(id: string): void;
    private seedBundledServers;
    private projects;
    private startConnection;
    /** Coalesce demand for one server; inspection and polling never call this method. */
    ensureConnected(serverName: string, refresh?: boolean): Promise<void>;
    /** Dependency preparation stays outside the shared connection-operation queue. */
    private preparePythonConnection;
    private reconcile;
    private dto;
    /**
     * Lifecycle events are deliberately best-effort notifications and can cross
     * Cordis Fiber boundaries. The reconcile operation is authoritative: once
     * its Fiber resolved, the MCP handshake and tools/list synchronization have
     * completed. Re-assert that state before projecting a DTO so a late
     * `starting` event cannot leave the settings UI stuck forever.
     */
    private convergeReadyStatuses;
    private indexMcpTools;
    private cacheSignature;
    private loadMcpToolCache;
    private cacheMcpServer;
    private clearMcpToolIndex;
    private toolNames;
    private toolDetails;
    private disposeOne;
    private disposeAll;
}
/** Keep remotely advertised schemas useful while imposing a strict DTO bound. */
export declare function sanitizeMcpToolSchema(value: unknown): {
    schema: McpSchemaObject;
    truncated: boolean;
};
export declare function resolveMcpConfig(record: McpServerRecord, environment: NodeJS.ProcessEnv, hostCwd?: string, enabledTools?: string[], candidate?: ManagedEnvironmentRecord): ResolvedMcpConfig;
export declare function resolveStdioLaunch(record: Pick<McpServerRecord, 'command' | 'args' | 'cwd'>, hostCwd?: string, candidate?: ManagedEnvironmentRecord): {
    command: string;
    args: string[];
    cwd: string;
};
type ManagedEnvironmentRecord = {
    root: string;
    runtimeExecutable: string;
    runtimeSitePackages: string;
    health: 'ready';
};
export declare function managedBioDependenciesReady(record: ManagedEnvironmentRecord, candidate?: boolean): boolean;
/** Environment identity changes only after dependency validation and publication. */
export declare function managedEnvironmentFileSignature(): string;
/** Read the paths selected by the active dependency service without legacy pointer discovery. */
export declare function managedEnvironmentRecord(_signature?: string): ManagedEnvironmentRecord | undefined;
export declare function redactError(error: unknown): string;
/** Persistent research storage; the legacy environment path remains supported. */
export interface Config extends ToolDiscoveryConfig {
    databasePath?: string;
}
/** Optional database path, resolved once when this plugin loads. */
export declare const Config: z<Config>;
export declare function apply(ctx: Context, config?: Config): Promise<void>;
