/**
 * Skip TypeScript SDK
 *
 * A general-purpose SDK for calling the Skip SaaS API.
 * This module provides a clean, reusable interface for integrating with Skip
 * that can eventually be extracted into a standalone npm package.
 */
import { SkipAPIResponse, SkipMessage, SkipRequestPhase } from '@memberjunction/skip-types';
import { DataContext } from '@memberjunction/data-context';
import { UserInfo } from '@memberjunction/core';
import mssql from 'mssql';
/**
 * Configuration options for Skip SDK
 */
export interface SkipSDKConfig {
    /**
     * Skip API base URL (e.g., 'https://skip.memberjunction.com')
     */
    apiUrl?: string;
    /**
     * Skip API key for authentication
     */
    apiKey?: string;
    /**
     * Organization ID
     */
    organizationId?: string;
    /**
     * Optional organization context information
     */
    organizationInfo?: string;
}
/**
 * Options for making a Skip API call
 */
export interface SkipCallOptions {
    /**
     * Conversation messages (user/assistant)
     */
    messages: SkipMessage[];
    /**
     * Conversation ID for tracking
     */
    conversationId: string;
    /**
     * Data context to provide to Skip
     */
    dataContext?: DataContext;
    /**
     * Request phase (initial_request, clarify_question_response, etc.)
     */
    requestPhase?: SkipRequestPhase;
    /**
     * Context user for permissions and metadata
     */
    contextUser: UserInfo;
    /**
     * Database connection for metadata queries
     */
    dataSource: mssql.ConnectionPool;
    /**
     * Include entity metadata in request
     */
    includeEntities?: boolean;
    /**
     * Include saved queries in request
     */
    includeQueries?: boolean;
    /**
     * Include agent notes in request
     */
    includeNotes?: boolean;
    /**
     * Include agent requests in request
     */
    includeRequests?: boolean;
    /**
     * Force refresh of entity metadata cache
     */
    forceEntityRefresh?: boolean;
    /**
     * Include callback API key and access token for Skip to call back to MJ
     */
    includeCallbackAuth?: boolean;
    /**
     * Callback for streaming status updates during execution
     */
    onStatusUpdate?: (message: string, responsePhase?: string) => void;
    /**
     * Optional payload data from a previous response (e.g., PRD in progress).
     * This enables incremental artifact building where structured data accumulates
     * throughout the conversation. When Skip returns a response with a payload,
     * the client should pass that payload back in the next request.
     */
    payload?: Record<string, any>;
}
/**
 * Result from a Skip API call
 */
export interface SkipCallResult {
    /**
     * Whether the call was successful
     */
    success: boolean;
    /**
     * The final Skip API response
     */
    response?: SkipAPIResponse;
    /**
     * Response phase (analysis_complete, clarifying_question, status_update)
     */
    responsePhase?: string;
    /**
     * Error message if failed
     */
    error?: string;
    /**
     * All streaming responses received (including intermediate status updates)
     */
    allResponses?: any[];
}
/**
 * Skip TypeScript SDK
 * Provides a clean interface for calling the Skip SaaS API
 */
export declare class SkipSDK {
    private config;
    private static __skipEntitiesCache$;
    private static __lastRefreshTime;
    constructor(config?: SkipSDKConfig);
    /**
     * Call the Skip chat API
     */
    chat(options: SkipCallOptions): Promise<SkipCallResult>;
    /**
     * Build the Skip API request object
     */
    private buildSkipRequest;
    /**
     * Build base request with metadata, API keys, and callback auth
     */
    private buildBaseRequest;
    /**
     * Build entity metadata for Skip
     * Copied from AskSkipResolver.BuildSkipEntities - uses cached metadata with refresh logic
     */
    private buildEntities;
    /**
     * Build saved queries for Skip
     */
    private buildQueries;
    /**
     * Recursively build category path for a query
     */
    private buildQueryCategoryPath;
    /**
     * Build agent notes for Skip
     */
    private buildAgentNotes;
    /**
     * Build artifacts for a conversation using optimized query
     * Uses GetConversationArtifactsForAgent query which joins through ConversationDetailArtifact
     * to get artifacts that were outputs from Skip agent's conversation details
     */
    private buildArtifacts;
    /**
     * Build API keys for AI services
     */
    private buildAPIKeys;
    /**
     * Build HTTP headers for Skip API requests
     */
    private buildHeaders;
    /**
     * Send an SSE-aware POST request to the Skip API.
     * Replaces sendPostRequest for SSE format: parses `data: {json}\n\n` events
     * instead of NDJSON `{json}\n` lines. This is required because Azure Container
     * Apps' Envoy proxy buffers NDJSON responses but streams SSE responses.
     */
    private sendSSERequest;
    /**
     * Refreshes the Skip entities cache
     * Rebuilds the entity information that is provided to Skip
     * Copied from AskSkipResolver.refreshSkipEntities
     */
    private refreshSkipEntities;
    /**
     * Packs information about a single entity for Skip
     * Includes fields, relationships, and sample data
     * Copied from AskSkipResolver.PackSingleSkipEntityInfo
     */
    private packSingleSkipEntityInfo;
    /**
     * Packs information about a single entity relationship
     * These relationships help Skip understand the data model
     * Copied from AskSkipResolver.PackSingleSkipEntityRelationship
     */
    private packSingleSkipEntityRelationship;
    /**
     * Packs information about a single entity field
     * Includes metadata and possible values
     * Copied from AskSkipResolver.PackSingleSkipEntityField
     */
    private packSingleSkipEntityField;
    /**
     * Packs possible values for an entity field
     * These values help Skip understand the domain and valid values for fields
     * Copied from AskSkipResolver.PackFieldPossibleValues
     */
    private packFieldPossibleValues;
    /**
     * Gets distinct values for a field from the database
     * Used to provide Skip with information about the possible values
     * Copied from AskSkipResolver.GetFieldDistinctValues
     */
    private getFieldDistinctValues;
    /**
     * Process messages: filter delegation messages and add metadata fields
     * Messages coming in should already have conversationDetailID if they exist in the database
     */
    private processMessages;
    /**
     * Check if a message is a delegation message that should be filtered out
     * Uses flexible pattern matching to detect variations of delegation messages
     */
    private isDelegationMessage;
}
//# sourceMappingURL=skip-sdk.d.ts.map