/** * ThinkHive SDK v3.0 - Ticket Linking * * Deterministic linking between runs and support tickets * 7 link methods with explicit confidence scores */ import type { LinkMethod } from '../core/types'; /** * Generate a Zendesk marker to embed in agent responses * * @example * ```typescript * const runId = 'run_abc123'; * const marker = generateZendeskMarker(runId); * // Returns: '[THID:run_abc123]' * * // Append to your agent response: * const response = `I've found your order. ${marker}`; * ``` */ export declare function generateZendeskMarker(runId: string): string; /** * Parse a Zendesk marker from text * * @example * ```typescript * const text = 'Thank you for contacting us. [THID:run_abc123]'; * const runId = parseZendeskMarker(text); * // Returns: 'run_abc123' * ``` */ export declare function parseZendeskMarker(text: string): string | null; /** * Check if text contains a Zendesk marker */ export declare function hasZendeskMarker(text: string): boolean; /** * Remove Zendesk marker from text (for clean display) * * @example * ```typescript * const text = 'Thank you! [THID:run_abc123]'; * const clean = removeZendeskMarker(text); * // Returns: 'Thank you!' * ``` */ export declare function removeZendeskMarker(text: string): string; /** * Confidence scores for each link method * Based on deterministic linking principles from v3 spec */ export declare const LINK_METHOD_CONFIDENCE: Record; /** * Link evidence structure */ export interface LinkEvidence { method: LinkMethod; confidence: number; timestamp: string; details: { runId?: string; ticketId?: string; externalTicketId?: string; platform?: string; sessionId?: string; email?: string; timeWindowMinutes?: number; customFieldName?: string; customFieldValue?: string; }; } /** * Create link input */ export interface CreateLinkInput { runId: string; ticketId?: string; externalTicketId?: string; platform?: 'zendesk' | 'intercom' | 'salesforce' | 'freshdesk'; method: LinkMethod; evidence?: Partial; } /** * Link response */ export interface LinkResponse { id: string; runId: string; ticketId?: string; externalTicketId?: string; platform?: string; method: LinkMethod; confidence: number; evidence: LinkEvidence; createdAt: string; } /** * Linking API client */ export declare const linking: { /** * Create a link between a run and a ticket * * @example * ```typescript * // SDK explicit linking (highest confidence) * const link = await linking.create({ * runId: 'run_abc123', * ticketId: 'ticket_xyz', * method: 'sdk_explicit', * }); * * // Zendesk marker linking * const link = await linking.create({ * runId: 'run_abc123', * externalTicketId: '12345', * platform: 'zendesk', * method: 'zendesk_marker', * }); * ``` */ create(input: CreateLinkInput): Promise; /** * Get links for a run * * @example * ```typescript * const links = await linking.getForRun('run_abc123'); * ``` */ getForRun(runId: string): Promise; /** * Get links for a ticket * * @example * ```typescript * const links = await linking.getForTicket('ticket_xyz'); * ``` */ getForTicket(ticketId: string): Promise; /** * Verify a link (confirm or reject) * * @example * ```typescript * await linking.verify('link_abc123', { * verified: true, * notes: 'Confirmed by support agent', * }); * ``` */ verify(linkId: string, options: { verified: boolean; notes?: string; }): Promise; /** * Delete a link * * @example * ```typescript * await linking.delete('link_abc123'); * ``` */ delete(linkId: string): Promise; /** * Auto-link a run to a ticket based on available evidence * * @example * ```typescript * const link = await linking.autoLink('run_abc123'); * if (link) { * console.log(`Linked to ${link.ticketId} via ${link.method}`); * } * ``` */ autoLink(runId: string): Promise; stats(): Promise<{ totalLinks: number; byMethod: Record; avgConfidence: number; verifiedCount: number; unverifiedCount: number; }>; generateMarker(options: { traceId: string; runId?: string; format?: "html_comment" | "base64" | "custom"; customTemplate?: string; }): Promise<{ marker: string; format: string; traceId: string; runId: string | null; instructions: string; }>; }; /** * Create SDK explicit link (convenience function) */ export declare function linkRunToTicket(runId: string, ticketId: string): Promise; /** * Create Zendesk link via marker */ export declare function linkRunToZendeskTicket(runId: string, zendeskTicketId: string): Promise; /** * Get the best link method for a given scenario */ export declare function getBestLinkMethod(available: { hasTicketId: boolean; hasMarker: boolean; hasCustomField: boolean; hasMiddlewareStamp: boolean; hasSessionId: boolean; hasEmail: boolean; }): LinkMethod | null; /** * Format link confidence for display */ export declare function formatLinkConfidence(confidence: number): string; /** * Get confidence level label */ export declare function getConfidenceLevel(confidence: number): 'definitive' | 'high' | 'medium' | 'low';