import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
import { type AAuthRequestContext, type AgentIdentity, type AttributionDecisionDiagnostics } from "./crypto/agent_identity.js";
export declare const MCP_INTERACTION_INSTRUCTIONS_FALLBACK: string;
/**
 * Same operational contract as {@link MCP_INTERACTION_INSTRUCTIONS_FALLBACK}, without the
 * “unreadable file” framing. Returned when NEOTOMA_MCP_COMPACT_INSTRUCTIONS=1 so agents that
 * already load full Neotoma workspace rules can omit the huge fenced MCP block from context.
 */
export declare const MCP_INTERACTION_INSTRUCTIONS_COMPACT_DUAL_HOST: string;
export declare class NeotomaServer {
    private readonly mcpServer;
    private autoEnhancementCleanup?;
    private authenticatedUserId;
    private sessionToken;
    private requestAuth;
    /** Connection ID set from HTTP layer so handlers get auth even when SDK does not pass requestInfo */
    private sessionConnectionId;
    /** AAuth-verified agent context propagated from the HTTP middleware (Phase 1). */
    private sessionAAuth;
    /** Client self-report from MCP initialize `clientInfo` (fallback attribution). */
    private sessionClientInfo;
    /** Tool descriptions loaded from docs/developer/mcp/tool_descriptions.yaml; empty Map if file missing */
    private toolDescriptions;
    /** In-memory cache for npm registry dist-tags: key = "packageName:distTag", value = { version, until } */
    private registryCache;
    private static REGISTRY_CACHE_TTL_MS;
    private static INIT_UPDATE_NOTICE_TIMEOUT_MS;
    private static RUNTIME_UPDATE_NOTICE_TIMEOUT_MS;
    private static RUNTIME_UPDATE_CHECK_INTERVAL_MS;
    private isHTTPTransportSession;
    private nextRuntimeUpdateCheckAt;
    private lastNotifiedUpdateVersion;
    constructor();
    private mcpDocsPath;
    private getMcpInteractionInstructions;
    private getUnauthenticatedInstructions;
    private loadToolDescriptionsMap;
    /**
     * Setup MCP initialize request handler for authentication
     * Supports both OAuth connections (recommended) and session tokens (deprecated)
     * Works with both stdio (env vars) and HTTP (request context) transports
     */
    private setupInitializeHandler;
    /**
     * Returns initialize response when authentication is missing
     * Declares OAuth capabilities so Cursor shows "Connect" button and "Authentication needed" message
     */
    private getUnauthenticatedResponse;
    /**
     * Set connection ID for this session from the HTTP layer.
     * Ensures listTools/listResources get auth when the SDK does not pass requestInfo to handlers.
     */
    setSessionConnectionId(connectionId: string): void;
    /**
     * Stash the AAuth verification result from the HTTP middleware so the
     * write-path services can attribute rows to the signing agent (Phase 1).
     * Called by actions.ts before the transport handles the MCP request. Pass
     * `null` to clear (e.g. for unsigned requests).
     */
    setSessionAgentIdentity(ctx: AAuthRequestContext | null): void;
    /**
     * Return the current session's fully-resolved {@link AgentIdentity},
     * combining AAuth verification with clientInfo and connection id
     * fallback attribution. Returns `null` when nothing attributable is
     * available (stdio without env identity, etc.).
     */
    getAgentIdentity(): AgentIdentity | null;
    /**
     * Synthesise an {@link AttributionDecisionDiagnostics} for the active
     * MCP session. HTTP `/mcp` requests receive a middleware-stamped
     * decision via `req.aauth`; stdio and CLI-over-MCP callers never hit
     * Express, so we derive the equivalent shape from `sessionAAuth` +
     * `sessionClientInfo`. The resulting object is safe to put on the
     * request context so `/session`-equivalent replies via stdio match the
     * HTTP response shape (see docs/subsystems/agent_attribution_integration.md).
     */
    getSessionAttributionDecision(): AttributionDecisionDiagnostics | null;
    private buildAuthenticatedInitializeResponse;
    private markUpdateNoticeDelivered;
    private getInstalledPackageMetadata;
    private getLatestCachedPackageVersion;
    private getPackageUpdateNotice;
    private getInitializeUpdateNotice;
    private consumeRuntimeUpdateNotice;
    private withRuntimeUpdateNotice;
    /**
     * Get authenticated user ID and validate against provided user_id
     * @param providedUserId - Optional user_id parameter from action call
     * @returns Authenticated user_id
     * @throws McpError if not authenticated or user_id mismatch
     */
    private getAuthenticatedUserId;
    /**
     * Get authenticated user information
     * Returns the user_id that is automatically used for all authenticated actions
     */
    private getAuthenticatedUser;
    /**
     * Resolve the current session's attribution and the active policy.
     * Mirrors the HTTP `GET /session` endpoint; see
     * `src/services/session_info.ts`. Read-only.
     */
    private getSessionIdentity;
    /**
     * Health check for entity snapshots
     * Detects stale snapshots (observation_count=0 but observations exist)
     */
    private healthCheckSnapshots;
    private listRecentChanges;
    private npmCheckUpdate;
    private handleSubmitIssue;
    private handleSubmitEntity;
    private handleAddEntityMessage;
    private handleGetEntitySubmissionStatus;
    private handleListEntitySubmissions;
    private handleSyncEntitySubmissions;
    private handleAddIssueMessage;
    private handleGetIssueStatus;
    private handleSyncIssues;
    private handleSubscribe;
    private handleUnsubscribe;
    private handleListSubscriptions;
    private handleGetSubscriptionStatus;
    private handleAddPeer;
    private handleRemovePeer;
    private handleListPeers;
    private handleGetPeerStatus;
    private handleSyncPeer;
    private handleResolveSyncConflict;
    /**
     * Validate session token and extract user_id
     * @param token - access_token (JWT)
     * @returns user_id extracted from token
     * @throws McpError if token is invalid
     */
    private validateSessionToken;
    private setupToolHandlers;
    executeToolForCli(name: string, args: unknown, userId: string): Promise<{
        content: Array<{
            type: string;
            text: string;
        }>;
    }>;
    private executeTool;
    /**
     * Setup resource handlers for MCP resources capability
     */
    private setupResourceHandlers;
    private retrieveFileUrl;
    private buildTextResponse;
    private readUnstructuredInput;
    private parseFile;
    private buildTimelineWidgetHtml;
    private retrieveEntitySnapshot;
    private listObservations;
    private retrieveFieldProvenance;
    private createRelationship;
    private createRelationships;
    private listRelationships;
    private getRelationshipSnapshot;
    private retrieveEntities;
    private listTimelineEvents;
    private retrieveEntityByIdentifier;
    private retrieveRelatedEntities;
    private retrieveGraphNeighborhood;
    private getEntityTypeCounts;
    private listEntityTypes;
    /**
     * Analyze raw_fragments to identify schema candidates
     */
    private analyzeSchemaCandidates;
    /**
     * Get schema recommendations
     */
    private getSchemaRecommendations;
    /**
     * Incrementally update schema by adding or removing fields
     */
    private updateSchemaIncremental;
    /**
     * Register a new schema
     */
    private registerSchema;
    private listInterpretations;
    private createInterpretation;
    private store;
    private getAssetEntityType;
    private ensureUnstructuredAssetEntity;
    private getEntityIdsFromSource;
    private getRelatedEntitiesAndRelationships;
    private storeStructuredInternal;
    private correct;
    private mergeEntities;
    /**
     * MCP list_potential_duplicates: read-only fuzzy duplicate detector (R5).
     * Never auto-merges; returns ranked candidate pairs so an operator or agent
     * can invoke `merge_entities`.
     */
    private listPotentialDuplicates;
    /** MCP delete_entity: delete an entity via deletion observation (immutable, reversible for audit) */
    private deleteEntity;
    /** MCP delete_relationship: delete a relationship via deletion observation (immutable, reversible for audit) */
    private deleteRelationship;
    /** MCP restore_entity: restore a deleted entity via restoration observation (priority 1001, overrides deletion) */
    private restoreEntity;
    /** MCP restore_relationship: restore a deleted relationship via restoration observation (priority 1001, overrides deletion) */
    private restoreRelationship;
    /**
     * Parse resource URI into structured resource identifier with query parameters
     */
    private parseResourceUri;
    /**
     * Resource handler: Get all entities (generic collection)
     */
    private handleEntityCollectionAll;
    /**
     * Resource handler: Get entity collection by type
     */
    private handleEntityCollection;
    /**
     * Resource handler: Get individual entity
     */
    private handleIndividualEntity;
    /**
     * Resource handler: Get entity observations
     */
    private handleEntityObservations;
    /**
     * Resource handler: Get entity relationships
     */
    private handleEntityRelationships;
    /**
     * Resource handler: Get timeline events for a year
     */
    private handleTimelineYear;
    /**
     * Resource handler: Get timeline events for a specific month
     */
    private handleTimelineMonth;
    /**
     * Resource handler: Get source
     */
    private handleSource;
    /**
     * Resource handler: Get all sources
     */
    private handleSourceCollection;
    /**
     * Resource handler: Get all relationships (generic collection)
     */
    private handleRelationshipCollectionAll;
    /**
     * Resource handler: Get relationships by type
     */
    private handleRelationshipCollection;
    /**
     * Resource handler: Get all entity types (schema-level discovery resource)
     */
    private handleEntityTypes;
    private setupErrorHandler;
    run(): Promise<void>;
    /**
     * Run MCP server with StreamableHTTP transport (HTTP-based)
     * Used when MCP server is integrated into Express HTTP server
     */
    runHTTP(transport: StreamableHTTPServerTransport): Promise<void>;
    /**
     * Start auto-enhancement processor (shared by both transports)
     */
    private startAutoEnhancement;
}
//# sourceMappingURL=server.d.ts.map