/** * ThinkHive SDK v3.0 - Customer Context * * Time-series customer metrics snapshots * Captures ARR, health score, segment AS OF the run time (not current values) */ import type { CustomerContextSnapshot } from '../core/types'; export interface CustomerAccount { id: string; companyId: string; externalId?: string; externalSource?: 'salesforce' | 'hubspot' | 'zendesk' | 'intercom' | 'custom'; name: string; domain?: string; segment?: string; industry?: string; employeeCount?: number; createdAt: string; updatedAt: string; } export interface CustomerMetricsSnapshot { id: string; customerAccountId: string; arr?: number; healthScore?: number; nps?: number; segment?: string; churnRisk?: 'low' | 'medium' | 'high'; capturedAt: string; source?: string; createdAt: string; } /** * Customer context API client for time-series metrics */ export declare const customerContext: { /** * Create a customer account * * @example * ```typescript * const account = await customerContext.createAccount({ * name: 'Acme Corp', * externalId: 'sf_001234', * externalSource: 'salesforce', * segment: 'enterprise', * }); * ``` */ createAccount(input: { name: string; externalId?: string; externalSource?: CustomerAccount["externalSource"]; domain?: string; segment?: string; industry?: string; employeeCount?: number; }): Promise; /** * Get a customer account by ID * * @example * ```typescript * const account = await customerContext.getAccount('cust_abc123'); * ``` */ getAccount(customerId: string): Promise; /** * Get a customer account by external ID * * @example * ```typescript * const account = await customerContext.getAccountByExternalId( * 'sf_001234', * 'salesforce' * ); * ``` */ getAccountByExternalId(externalId: string, source: CustomerAccount["externalSource"]): Promise; /** * Capture a metrics snapshot for a customer * This creates a point-in-time record of the customer's metrics * * @example * ```typescript * // Capture current metrics * const snapshot = await customerContext.captureSnapshot('cust_abc123', { * arr: 120000, * healthScore: 85, * nps: 45, * segment: 'enterprise', * }); * * // Use this snapshot in a run * const run = await runs.create({ * agentId: 'agent_123', * customerContext: { * customerId: 'cust_abc123', * arr: snapshot.arr, * healthScore: snapshot.healthScore, * capturedAt: snapshot.capturedAt, * }, * // ... * }); * ``` */ captureSnapshot(customerId: string, metrics: { arr?: number; healthScore?: number; nps?: number; segment?: string; churnRisk?: "low" | "medium" | "high"; source?: string; }): Promise; /** * Get metrics snapshots for a customer (time-series) * * @example * ```typescript * // Get last 30 days of snapshots * const snapshots = await customerContext.getSnapshots('cust_abc123', { * from: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString(), * }); * ``` */ getSnapshots(customerId: string, options?: { from?: string; to?: string; limit?: number; }): Promise; /** * Get the most recent snapshot for a customer * * @example * ```typescript * const latest = await customerContext.getLatestSnapshot('cust_abc123'); * ``` */ getLatestSnapshot(customerId: string): Promise; /** * Get snapshot closest to a specific timestamp * Useful for retroactive analysis * * @example * ```typescript * // Get metrics as of a specific date * const snapshot = await customerContext.getSnapshotAsOf( * 'cust_abc123', * '2024-01-15T10:00:00Z' * ); * ``` */ getSnapshotAsOf(customerId: string, timestamp: string | Date): Promise; /** Alias for captureSnapshot() */ capture(customerId: string, metrics: Record): Promise; }; /** * Create a CustomerContextSnapshot from a metrics snapshot */ export declare function toContextSnapshot(snapshot: CustomerMetricsSnapshot): CustomerContextSnapshot; /** * Capture metrics and create context snapshot in one call * * @example * ```typescript * const context = await captureCustomerContext('cust_abc123', { * arr: 100000, * healthScore: 90, * segment: 'enterprise', * }); * * // Use in run * const run = await runs.create({ * agentId: 'agent_123', * customerContext: context, * // ... * }); * ``` */ export declare function captureCustomerContext(customerId: string, metrics: { arr?: number; healthScore?: number; segment?: string; }): Promise; /** * Get customer context as of a specific time */ export declare function getContextAsOf(customerId: string, timestamp: string | Date): Promise; /** * Calculate ARR change between two snapshots */ export declare function calculateArrChange(older: CustomerMetricsSnapshot, newer: CustomerMetricsSnapshot): { absolute: number; percentage: number; direction: 'increase' | 'decrease' | 'stable'; }; /** * Calculate health score trend */ export declare function calculateHealthTrend(snapshots: CustomerMetricsSnapshot[]): { currentScore: number | null; avgScore: number | null; trend: 'improving' | 'declining' | 'stable'; volatility: 'low' | 'medium' | 'high'; };