@thinkhive/sdk 2.0.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,145 +1,25 @@
1
1
  /**
2
- * ThinkHive TypeScript SDK
3
- * OpenTelemetry-based observability for AI agents with Explainer integration
2
+ * ThinkHive SDK v3.0.0
4
3
  *
5
- * @version 2.0.0
4
+ * Run-centric AI agent observability platform with:
5
+ * - Facts vs Inferences (claims API)
6
+ * - Deterministic ticket linking (7 methods)
7
+ * - Customer context snapshots (time-series)
8
+ * - Calibrated predictions (Brier scores)
9
+ *
10
+ * @version 3.0.0
11
+ * @license MIT
6
12
  */
7
- export interface InitOptions {
8
- /** ThinkHive API key (starts with th_) */
9
- apiKey?: string;
10
- /** Agent ID for legacy authentication */
11
- agentId?: string;
12
- /** ThinkHive API endpoint */
13
- endpoint?: string;
14
- /** Service name for traces */
15
- serviceName?: string;
16
- /** Enable auto-instrumentation */
17
- autoInstrument?: boolean;
18
- /** Frameworks to auto-instrument */
19
- frameworks?: Array<'langchain' | 'openai' | 'anthropic' | 'llamaindex'>;
20
- /** Enable debug logging */
21
- debug?: boolean;
22
- }
23
- export interface TraceOptions {
24
- /** User's message/query */
25
- userMessage: string;
26
- /** Agent's response */
27
- agentResponse: string;
28
- /** User's detected intent */
29
- userIntent?: string;
30
- /** Outcome: success, failure, partial_success */
31
- outcome?: 'success' | 'failure' | 'partial_success';
32
- /** Duration in milliseconds */
33
- duration?: number;
34
- /** Session ID for conversation tracking */
35
- sessionId?: string;
36
- /** Conversation history */
37
- conversationHistory?: Array<{
38
- role: string;
39
- content: string;
40
- }>;
41
- /** Span data for detailed analysis */
42
- spans?: SpanData[];
43
- /** Business context for ROI calculation */
44
- businessContext?: BusinessContext;
45
- /** Custom metadata */
46
- metadata?: Record<string, unknown>;
47
- }
48
- export interface SpanData {
49
- id?: string;
50
- name: string;
51
- type: 'llm' | 'tool' | 'retrieval' | 'embedding' | 'chain' | 'custom';
52
- startTime?: Date;
53
- endTime?: Date;
54
- durationMs?: number;
55
- status?: 'ok' | 'error' | 'timeout';
56
- error?: string;
57
- input?: unknown;
58
- output?: unknown;
59
- model?: string;
60
- provider?: string;
61
- promptTokens?: number;
62
- completionTokens?: number;
63
- toolName?: string;
64
- toolParameters?: Record<string, unknown>;
65
- query?: string;
66
- documentCount?: number;
67
- topScore?: number;
68
- sources?: string[];
69
- children?: SpanData[];
70
- }
71
- export interface BusinessContext {
72
- /** Customer ID */
73
- customerId?: string;
74
- /** Transaction value in dollars */
75
- transactionValue?: number;
76
- /** Priority level */
77
- priority?: 'low' | 'medium' | 'high' | 'critical';
78
- /** Department */
79
- department?: string;
80
- /** Industry vertical */
81
- industry?: string;
82
- /** Custom fields */
83
- custom?: Record<string, unknown>;
84
- }
85
- export interface ExplainabilityResult {
86
- traceId: string;
87
- explainabilityId: string;
88
- summary: string;
89
- outcome: {
90
- verdict: 'success' | 'partial_success' | 'failure';
91
- confidence: number;
92
- reasoning: string;
93
- };
94
- businessImpact: {
95
- impactScore: number;
96
- customerSatisfaction: number;
97
- revenueRisk: string;
98
- };
99
- recommendations: Array<{
100
- priority: string;
101
- category: string;
102
- action: string;
103
- expectedImpact: string;
104
- }>;
105
- ragEvaluation?: {
106
- groundedness: number;
107
- faithfulness: number;
108
- answerRelevance: number;
109
- };
110
- hallucinationReport?: {
111
- detected: boolean;
112
- types: string[];
113
- severity: string;
114
- };
115
- processingTimeMs: number;
116
- }
117
- export interface AnalyzeOptions {
118
- /** Force a specific analysis tier */
119
- tier?: 'rule_based' | 'fast_llm' | 'full_llm' | 'deep';
120
- /** Include RAG evaluation */
121
- includeRagEvaluation?: boolean;
122
- /** Include hallucination detection */
123
- includeHallucinationCheck?: boolean;
124
- /** Wait for analysis to complete (sync mode) */
125
- waitForResult?: boolean;
126
- /** Webhook URL for async notification */
127
- webhookUrl?: string;
128
- }
129
- export interface FeedbackOptions {
130
- /** Trace ID to provide feedback for */
131
- traceId: string;
132
- /** User rating (1-5) */
133
- rating?: number;
134
- /** Was the response helpful */
135
- wasHelpful?: boolean;
136
- /** Specific issues encountered */
137
- issues?: Array<'slow_response' | 'incorrect' | 'unhelpful' | 'hallucination' | 'off_topic' | 'other'>;
138
- /** Free-form comment */
139
- comment?: string;
140
- }
13
+ import { isInitialized, SDK_VERSION, DEFAULT_ENDPOINT } from './core/config';
14
+ import { ThinkHiveApiError, ThinkHiveValidationError } from './core/client';
15
+ import { runs, createRunWithContext, toOpenAIMessages, fromOpenAIMessages } from './api/runs';
16
+ import { claims, isFact, isInference, isComputed, getHighConfidenceClaims, groupClaimsByType, groupClaimsByCategory } from './api/claims';
17
+ import { calibration, calculateBrierScore, calculateECE, isWellCalibrated, getCalibrationQuality } from './api/calibration';
18
+ import { linking, generateZendeskMarker, parseZendeskMarker, hasZendeskMarker, removeZendeskMarker, linkRunToTicket, linkRunToZendeskTicket, getBestLinkMethod, LINK_METHOD_CONFIDENCE } from './integrations/ticket-linking';
19
+ import { customerContext, captureCustomerContext, getContextAsOf, toContextSnapshot, calculateArrChange, calculateHealthTrend } from './integrations/customer-context';
20
+ export type { InitOptions, Framework, RunOptions, RunOutcome, ConversationMessage, CustomerContextSnapshot, TicketLinkingOptions, LinkMethod, TraceOptions, SpanData, BusinessContext, Claim, ClaimType, ClaimCategory, ConfidenceCalibration, EvidenceReference, AnalysisResult, CalibrationStatus, CalibrationBucket, PredictionType, RoiConfig, RoiSummary, ExplainabilityResult, ApiResponse, PaginatedResponse, RunResponse, } from './core/types';
141
21
  /**
142
- * Initialize ThinkHive SDK
22
+ * Initialize ThinkHive SDK v3
143
23
  *
144
24
  * @example
145
25
  * ```typescript
@@ -153,28 +33,17 @@ export interface FeedbackOptions {
153
33
  * });
154
34
  * ```
155
35
  */
156
- export declare function init(options?: InitOptions): void;
36
+ export declare function init(options?: import('./core/types').InitOptions): void;
157
37
  /**
158
38
  * Get the global tracer
159
39
  */
160
40
  export declare function getTracer(): import("@opentelemetry/api").Tracer;
161
41
  /**
162
- * Check if SDK is initialized
42
+ * Shutdown the SDK and flush pending spans
163
43
  */
164
- export declare function isInitialized(): boolean;
44
+ export declare function shutdown(): Promise<void>;
165
45
  /**
166
46
  * Trace an LLM call
167
- *
168
- * @example
169
- * ```typescript
170
- * const response = await traceLLM({
171
- * name: 'chat_completion',
172
- * modelName: 'gpt-4',
173
- * provider: 'openai',
174
- * }, async () => {
175
- * return await openai.chat.completions.create({ ... });
176
- * });
177
- * ```
178
47
  */
179
48
  export declare function traceLLM<T>(options: {
180
49
  name: string;
@@ -184,16 +53,6 @@ export declare function traceLLM<T>(options: {
184
53
  }, fn: () => Promise<T>): Promise<T>;
185
54
  /**
186
55
  * Trace a retrieval operation
187
- *
188
- * @example
189
- * ```typescript
190
- * const docs = await traceRetrieval({
191
- * name: 'vector_search',
192
- * query: 'What is the return policy?',
193
- * }, async () => {
194
- * return await vectorStore.similaritySearch(query, 5);
195
- * });
196
- * ```
197
56
  */
198
57
  export declare function traceRetrieval<T>(options: {
199
58
  name: string;
@@ -202,17 +61,6 @@ export declare function traceRetrieval<T>(options: {
202
61
  }, fn: () => Promise<T>): Promise<T>;
203
62
  /**
204
63
  * Trace a tool call
205
- *
206
- * @example
207
- * ```typescript
208
- * const result = await traceTool({
209
- * name: 'search_orders',
210
- * toolName: 'OrderLookup',
211
- * parameters: { orderId: '12345' },
212
- * }, async () => {
213
- * return await orderService.lookup('12345');
214
- * });
215
- * ```
216
64
  */
217
65
  export declare function traceTool<T>(options: {
218
66
  name: string;
@@ -221,81 +69,40 @@ export declare function traceTool<T>(options: {
221
69
  }, fn: () => Promise<T>): Promise<T>;
222
70
  /**
223
71
  * Trace a chain/workflow
224
- *
225
- * @example
226
- * ```typescript
227
- * const result = await traceChain({
228
- * name: 'customer_support_chain',
229
- * }, async () => {
230
- * // Multiple LLM calls, tools, etc.
231
- * });
232
- * ```
233
72
  */
234
73
  export declare function traceChain<T>(options: {
235
74
  name: string;
236
75
  input?: unknown;
237
76
  }, fn: () => Promise<T>): Promise<T>;
238
77
  /**
239
- * Explainer API client for trace analysis
78
+ * Explainer API client (v2 compatibility)
79
+ * @deprecated Use runs and claims APIs instead
240
80
  */
241
81
  export declare const explainer: {
242
82
  /**
243
- * Analyze a trace and get explainability insights
244
- *
245
- * @example
246
- * ```typescript
247
- * const result = await explainer.analyze({
248
- * userMessage: 'Help me with my order #12345',
249
- * agentResponse: 'I found your order...',
250
- * outcome: 'success',
251
- * spans: [
252
- * { name: 'order_lookup', type: 'tool', durationMs: 150 },
253
- * { name: 'gpt-4', type: 'llm', durationMs: 2500, model: 'gpt-4' },
254
- * ],
255
- * });
256
- * ```
83
+ * Analyze a trace (v2 format)
84
+ * @deprecated Use runs.create() + claims.getRunAnalysis() instead
257
85
  */
258
- analyze(trace: TraceOptions, options?: AnalyzeOptions): Promise<ExplainabilityResult>;
259
- /**
260
- * Batch analyze multiple traces
261
- *
262
- * @example
263
- * ```typescript
264
- * const results = await explainer.analyzeBatch([
265
- * { userMessage: 'Q1', agentResponse: 'A1' },
266
- * { userMessage: 'Q2', agentResponse: 'A2' },
267
- * ]);
268
- * ```
269
- */
270
- analyzeBatch(traces: TraceOptions[], options?: AnalyzeOptions): Promise<{
271
- results: ExplainabilityResult[];
272
- summary: {
273
- total: number;
274
- successCount: number;
275
- failureCount: number;
276
- averageProcessingTime: number;
277
- };
278
- }>;
86
+ analyze(traceData: import("./core/types").TraceOptions, options?: {
87
+ tier?: string;
88
+ includeRagEvaluation?: boolean;
89
+ includeHallucinationCheck?: boolean;
90
+ waitForResult?: boolean;
91
+ webhookUrl?: string;
92
+ }): Promise<import("./core/types").ExplainabilityResult>;
279
93
  /**
280
94
  * Get a previously analyzed trace
95
+ * @deprecated
281
96
  */
282
- get(traceId: string): Promise<ExplainabilityResult>;
97
+ get(traceId: string): Promise<import("./core/types").ExplainabilityResult>;
283
98
  /**
284
99
  * Search traces semantically
285
- *
286
- * @example
287
- * ```typescript
288
- * const results = await explainer.search({
289
- * query: 'order refund issues',
290
- * filters: { outcome: 'failure' },
291
- * limit: 10,
292
- * });
293
- * ```
100
+ * @deprecated
294
101
  */
295
102
  search(params: {
296
103
  query: string;
297
104
  filters?: {
298
- outcome?: "success" | "failure" | "partial_success";
105
+ outcome?: string;
299
106
  minImpactScore?: number;
300
107
  dateRange?: {
301
108
  from: Date;
@@ -304,207 +111,208 @@ export declare const explainer: {
304
111
  };
305
112
  limit?: number;
306
113
  }): Promise<{
307
- results: Array<ExplainabilityResult & {
114
+ results: Array<import("./core/types").ExplainabilityResult & {
308
115
  similarity: number;
309
116
  }>;
310
117
  total: number;
311
118
  }>;
312
119
  };
313
- /**
314
- * Feedback API for improving analysis quality
315
- */
316
- export declare const feedback: {
317
- /**
318
- * Submit feedback for a trace
319
- *
320
- * @example
321
- * ```typescript
322
- * await feedback.submit({
323
- * traceId: 'trace_123',
324
- * rating: 5,
325
- * wasHelpful: true,
326
- * });
327
- * ```
328
- */
329
- submit(options: FeedbackOptions): Promise<{
330
- success: boolean;
331
- }>;
332
- };
333
- /**
334
- * Quality metrics API for RAG evaluation and hallucination detection
335
- */
336
- export declare const quality: {
337
- /**
338
- * Get RAG evaluation scores for a trace
339
- */
340
- getRagScores(traceId: string): Promise<{
341
- contextRelevance: number;
342
- contextPrecision: number;
343
- contextRecall: number;
344
- groundedness: number;
345
- faithfulness: number;
346
- answerRelevance: number;
347
- citationAccuracy: number;
348
- citationCompleteness: number;
349
- overallGrade: string;
350
- }>;
351
- /**
352
- * Get hallucination report for a trace
353
- */
354
- getHallucinationReport(traceId: string): Promise<{
355
- hasHallucinations: boolean;
356
- severity: "none" | "low" | "medium" | "high";
357
- confidence: number;
358
- detectedTypes: Array<{
359
- type: string;
360
- description: string;
361
- evidence: string;
362
- severity: string;
363
- }>;
364
- }>;
365
- /**
366
- * Evaluate RAG quality for custom input
367
- */
368
- evaluateRag(input: {
369
- query: string;
370
- response: string;
371
- contexts: Array<{
372
- content: string;
373
- source?: string;
374
- score?: number;
375
- }>;
376
- }): Promise<{
377
- scores: Record<string, number>;
378
- grade: string;
379
- groundedSpans: string[];
380
- ungroundedSpans: string[];
381
- }>;
382
- };
383
- /**
384
- * ROI analytics API for business impact tracking
385
- */
386
- export declare const analytics: {
387
- /**
388
- * Get ROI summary for the account
389
- */
390
- getRoiSummary(): Promise<{
391
- totalRevenueSaved: number;
392
- supportCostReduction: number;
393
- averageResolutionTime: number;
394
- customerSatisfaction: number;
395
- trends: Array<{
396
- date: string;
397
- revenueSaved: number;
398
- tracesAnalyzed: number;
399
- }>;
400
- }>;
401
- /**
402
- * Get ROI by agent
403
- */
404
- getRoiByAgent(agentId: string): Promise<{
405
- agentId: string;
406
- revenueSaved: number;
407
- tracesAnalyzed: number;
408
- successRate: number;
409
- topIssues: Array<{
410
- issue: string;
411
- count: number;
412
- impact: number;
413
- }>;
414
- }>;
415
- /**
416
- * Get correlation analysis
417
- */
418
- getCorrelations(): Promise<{
419
- correlations: Array<{
420
- type: string;
421
- coefficient: number;
422
- description: string;
423
- actionableInsight: string;
424
- }>;
425
- }>;
426
- };
427
- /**
428
- * Create a trace and analyze it in one call
429
- *
430
- * @example
431
- * ```typescript
432
- * const { trace, analysis } = await createAndAnalyze({
433
- * userMessage: 'Help me track my order',
434
- * agentResponse: 'Your order is on the way...',
435
- * });
436
- * ```
437
- */
438
- export declare function createAndAnalyze(traceData: TraceOptions, options?: AnalyzeOptions): Promise<{
439
- trace: TraceOptions;
440
- analysis: ExplainabilityResult;
441
- }>;
120
+ export { isInitialized, SDK_VERSION, DEFAULT_ENDPOINT };
121
+ export { runs, claims, calibration, linking, customerContext, };
122
+ export { createRunWithContext, toOpenAIMessages, fromOpenAIMessages, isFact, isInference, isComputed, getHighConfidenceClaims, groupClaimsByType, groupClaimsByCategory, calculateBrierScore, calculateECE, isWellCalibrated, getCalibrationQuality, generateZendeskMarker, parseZendeskMarker, hasZendeskMarker, removeZendeskMarker, linkRunToTicket, linkRunToZendeskTicket, getBestLinkMethod, LINK_METHOD_CONFIDENCE, captureCustomerContext, getContextAsOf, toContextSnapshot, calculateArrChange, calculateHealthTrend, };
123
+ export { ThinkHiveApiError, ThinkHiveValidationError };
442
124
  declare const _default: {
443
125
  init: typeof init;
444
126
  getTracer: typeof getTracer;
127
+ shutdown: typeof shutdown;
445
128
  isInitialized: typeof isInitialized;
446
129
  traceLLM: typeof traceLLM;
447
130
  traceRetrieval: typeof traceRetrieval;
448
131
  traceTool: typeof traceTool;
449
132
  traceChain: typeof traceChain;
133
+ runs: {
134
+ create(options: import("./core/types").RunOptions): Promise<import("./core/types").RunResponse>;
135
+ get(runId: string): Promise<import("./core/types").RunResponse>;
136
+ list(options?: import("./api/runs").ListRunsOptions): Promise<{
137
+ items: import("./core/types").RunResponse[];
138
+ limit: number;
139
+ offset: number;
140
+ hasMore: boolean;
141
+ }>;
142
+ update(runId: string, updates: Partial<Pick<import("./core/types").RunOptions, "outcome" | "outcomeReason" | "endedAt" | "metadata">>): Promise<import("./core/types").RunResponse>;
143
+ delete(runId: string): Promise<void>;
144
+ batch(runsData: import("./core/types").RunOptions[]): Promise<{
145
+ created: import("./core/types").RunResponse[];
146
+ failed: Array<{
147
+ index: number;
148
+ error: string;
149
+ }>;
150
+ }>;
151
+ stats(agentId: string, options?: {
152
+ from?: string | Date;
153
+ to?: string | Date;
154
+ }): Promise<import("./api/runs").RunStats>;
155
+ getTraces(runId: string): Promise<unknown[]>;
156
+ addTrace(runId: string, traceData: {
157
+ spans?: unknown[];
158
+ timestamp?: string;
159
+ metadata?: Record<string, unknown>;
160
+ }): Promise<{
161
+ traceId: string;
162
+ }>;
163
+ };
164
+ claims: {
165
+ createAnalysis(options: import("./api/claims").CreateAnalysisOptions): Promise<import("./core/types").AnalysisResult>;
166
+ getAnalysis(analysisId: string): Promise<import("./core/types").AnalysisResult>;
167
+ getRunAnalysis(runId: string): Promise<import("./core/types").AnalysisResult>;
168
+ getAnalysisHistory(runId: string): Promise<{
169
+ runId: string;
170
+ analyses: Array<{
171
+ id: string;
172
+ analysisVersion: string;
173
+ modelUsed: string;
174
+ outcomeVerdict: string;
175
+ isCurrent: boolean;
176
+ supersededBy?: string;
177
+ supersessionReason?: string;
178
+ analyzedAt: string;
179
+ }>;
180
+ }>;
181
+ supersedeAnalysis(analysisId: string, options: {
182
+ reason: string;
183
+ newAnalysis: Omit<import("./api/claims").CreateAnalysisOptions, "runId">;
184
+ }): Promise<{
185
+ supersededAnalysisId: string;
186
+ newAnalysis: import("./core/types").AnalysisResult;
187
+ }>;
188
+ list(options?: import("./api/claims").ListClaimsOptions): Promise<{
189
+ claims: import("./core/types").Claim[];
190
+ limit: number;
191
+ offset: number;
192
+ hasMore: boolean;
193
+ }>;
194
+ get(claimId: string): Promise<import("./core/types").Claim>;
195
+ verify(claimId: string, options: {
196
+ verdict: "confirmed" | "rejected" | "modified";
197
+ notes?: string;
198
+ modifiedText?: string;
199
+ }): Promise<{
200
+ claimId: string;
201
+ verdict: string;
202
+ message: string;
203
+ }>;
204
+ summary(options?: {
205
+ runId?: string;
206
+ analysisIds?: string[];
207
+ }): Promise<import("./api/claims").FactsVsInferencesSummary>;
208
+ };
209
+ calibration: {
210
+ status(agentId: string, predictionType: import("./core/types").PredictionType): Promise<import("./core/types").CalibrationStatus>;
211
+ allMetrics(agentId: string): Promise<import("./api/calibration").CalibrationMetrics[]>;
212
+ recordOutcome(input: import("./api/calibration").RecordOutcomeInput): Promise<{
213
+ recorded: boolean;
214
+ brierContribution: number;
215
+ message: string;
216
+ }>;
217
+ retrain(agentId: string, options?: {
218
+ predictionTypes?: import("./core/types").PredictionType[];
219
+ minSamples?: number;
220
+ }): Promise<{
221
+ success: boolean;
222
+ retrainedTypes: import("./core/types").PredictionType[];
223
+ skippedTypes: Array<{
224
+ type: import("./core/types").PredictionType;
225
+ reason: string;
226
+ }>;
227
+ newMetrics: import("./api/calibration").CalibrationMetrics[];
228
+ }>;
229
+ reliabilityDiagram(agentId: string, predictionType: import("./core/types").PredictionType): Promise<{
230
+ agentId: string;
231
+ predictionType: import("./core/types").PredictionType;
232
+ buckets: import("./core/types").CalibrationBucket[];
233
+ perfectCalibrationLine: Array<{
234
+ x: number;
235
+ y: number;
236
+ }>;
237
+ }>;
238
+ };
239
+ linking: {
240
+ create(input: import("./integrations/ticket-linking").CreateLinkInput): Promise<import("./integrations/ticket-linking").LinkResponse>;
241
+ getForRun(runId: string): Promise<import("./integrations/ticket-linking").LinkResponse[]>;
242
+ getForTicket(ticketId: string): Promise<import("./integrations/ticket-linking").LinkResponse[]>;
243
+ verify(linkId: string, options: {
244
+ verified: boolean;
245
+ notes?: string;
246
+ }): Promise<{
247
+ linkId: string;
248
+ verified: boolean;
249
+ message: string;
250
+ }>;
251
+ delete(linkId: string): Promise<void>;
252
+ autoLink(runId: string): Promise<{
253
+ runId: string;
254
+ created: import("./integrations/ticket-linking").LinkResponse[];
255
+ candidates: Array<{
256
+ ticketId: string;
257
+ method: import("./core/types").LinkMethod;
258
+ confidence: number;
259
+ reason: string;
260
+ }>;
261
+ }>;
262
+ };
263
+ customerContext: {
264
+ createAccount(input: {
265
+ name: string;
266
+ externalId?: string;
267
+ externalSource?: import("./integrations/customer-context").CustomerAccount["externalSource"];
268
+ domain?: string;
269
+ segment?: string;
270
+ industry?: string;
271
+ employeeCount?: number;
272
+ }): Promise<import("./integrations/customer-context").CustomerAccount>;
273
+ getAccount(customerId: string): Promise<import("./integrations/customer-context").CustomerAccount>;
274
+ getAccountByExternalId(externalId: string, source: import("./integrations/customer-context").CustomerAccount["externalSource"]): Promise<import("./integrations/customer-context").CustomerAccount | null>;
275
+ captureSnapshot(customerId: string, metrics: {
276
+ arr?: number;
277
+ healthScore?: number;
278
+ nps?: number;
279
+ segment?: string;
280
+ churnRisk?: "low" | "medium" | "high";
281
+ source?: string;
282
+ }): Promise<import("./integrations/customer-context").CustomerMetricsSnapshot>;
283
+ getSnapshots(customerId: string, options?: {
284
+ from?: string;
285
+ to?: string;
286
+ limit?: number;
287
+ }): Promise<import("./integrations/customer-context").CustomerMetricsSnapshot[]>;
288
+ getLatestSnapshot(customerId: string): Promise<import("./integrations/customer-context").CustomerMetricsSnapshot | null>;
289
+ getSnapshotAsOf(customerId: string, timestamp: string | Date): Promise<import("./integrations/customer-context").CustomerMetricsSnapshot | null>;
290
+ };
450
291
  explainer: {
451
292
  /**
452
- * Analyze a trace and get explainability insights
453
- *
454
- * @example
455
- * ```typescript
456
- * const result = await explainer.analyze({
457
- * userMessage: 'Help me with my order #12345',
458
- * agentResponse: 'I found your order...',
459
- * outcome: 'success',
460
- * spans: [
461
- * { name: 'order_lookup', type: 'tool', durationMs: 150 },
462
- * { name: 'gpt-4', type: 'llm', durationMs: 2500, model: 'gpt-4' },
463
- * ],
464
- * });
465
- * ```
293
+ * Analyze a trace (v2 format)
294
+ * @deprecated Use runs.create() + claims.getRunAnalysis() instead
466
295
  */
467
- analyze(trace: TraceOptions, options?: AnalyzeOptions): Promise<ExplainabilityResult>;
468
- /**
469
- * Batch analyze multiple traces
470
- *
471
- * @example
472
- * ```typescript
473
- * const results = await explainer.analyzeBatch([
474
- * { userMessage: 'Q1', agentResponse: 'A1' },
475
- * { userMessage: 'Q2', agentResponse: 'A2' },
476
- * ]);
477
- * ```
478
- */
479
- analyzeBatch(traces: TraceOptions[], options?: AnalyzeOptions): Promise<{
480
- results: ExplainabilityResult[];
481
- summary: {
482
- total: number;
483
- successCount: number;
484
- failureCount: number;
485
- averageProcessingTime: number;
486
- };
487
- }>;
296
+ analyze(traceData: import("./core/types").TraceOptions, options?: {
297
+ tier?: string;
298
+ includeRagEvaluation?: boolean;
299
+ includeHallucinationCheck?: boolean;
300
+ waitForResult?: boolean;
301
+ webhookUrl?: string;
302
+ }): Promise<import("./core/types").ExplainabilityResult>;
488
303
  /**
489
304
  * Get a previously analyzed trace
305
+ * @deprecated
490
306
  */
491
- get(traceId: string): Promise<ExplainabilityResult>;
307
+ get(traceId: string): Promise<import("./core/types").ExplainabilityResult>;
492
308
  /**
493
309
  * Search traces semantically
494
- *
495
- * @example
496
- * ```typescript
497
- * const results = await explainer.search({
498
- * query: 'order refund issues',
499
- * filters: { outcome: 'failure' },
500
- * limit: 10,
501
- * });
502
- * ```
310
+ * @deprecated
503
311
  */
504
312
  search(params: {
505
313
  query: string;
506
314
  filters?: {
507
- outcome?: "success" | "failure" | "partial_success";
315
+ outcome?: string;
508
316
  minImpactScore?: number;
509
317
  dateRange?: {
510
318
  from: Date;
@@ -513,117 +321,19 @@ declare const _default: {
513
321
  };
514
322
  limit?: number;
515
323
  }): Promise<{
516
- results: Array<ExplainabilityResult & {
324
+ results: Array<import("./core/types").ExplainabilityResult & {
517
325
  similarity: number;
518
326
  }>;
519
327
  total: number;
520
328
  }>;
521
329
  };
522
- feedback: {
523
- /**
524
- * Submit feedback for a trace
525
- *
526
- * @example
527
- * ```typescript
528
- * await feedback.submit({
529
- * traceId: 'trace_123',
530
- * rating: 5,
531
- * wasHelpful: true,
532
- * });
533
- * ```
534
- */
535
- submit(options: FeedbackOptions): Promise<{
536
- success: boolean;
537
- }>;
538
- };
539
- quality: {
540
- /**
541
- * Get RAG evaluation scores for a trace
542
- */
543
- getRagScores(traceId: string): Promise<{
544
- contextRelevance: number;
545
- contextPrecision: number;
546
- contextRecall: number;
547
- groundedness: number;
548
- faithfulness: number;
549
- answerRelevance: number;
550
- citationAccuracy: number;
551
- citationCompleteness: number;
552
- overallGrade: string;
553
- }>;
554
- /**
555
- * Get hallucination report for a trace
556
- */
557
- getHallucinationReport(traceId: string): Promise<{
558
- hasHallucinations: boolean;
559
- severity: "none" | "low" | "medium" | "high";
560
- confidence: number;
561
- detectedTypes: Array<{
562
- type: string;
563
- description: string;
564
- evidence: string;
565
- severity: string;
566
- }>;
567
- }>;
568
- /**
569
- * Evaluate RAG quality for custom input
570
- */
571
- evaluateRag(input: {
572
- query: string;
573
- response: string;
574
- contexts: Array<{
575
- content: string;
576
- source?: string;
577
- score?: number;
578
- }>;
579
- }): Promise<{
580
- scores: Record<string, number>;
581
- grade: string;
582
- groundedSpans: string[];
583
- ungroundedSpans: string[];
584
- }>;
585
- };
586
- analytics: {
587
- /**
588
- * Get ROI summary for the account
589
- */
590
- getRoiSummary(): Promise<{
591
- totalRevenueSaved: number;
592
- supportCostReduction: number;
593
- averageResolutionTime: number;
594
- customerSatisfaction: number;
595
- trends: Array<{
596
- date: string;
597
- revenueSaved: number;
598
- tracesAnalyzed: number;
599
- }>;
600
- }>;
601
- /**
602
- * Get ROI by agent
603
- */
604
- getRoiByAgent(agentId: string): Promise<{
605
- agentId: string;
606
- revenueSaved: number;
607
- tracesAnalyzed: number;
608
- successRate: number;
609
- topIssues: Array<{
610
- issue: string;
611
- count: number;
612
- impact: number;
613
- }>;
614
- }>;
615
- /**
616
- * Get correlation analysis
617
- */
618
- getCorrelations(): Promise<{
619
- correlations: Array<{
620
- type: string;
621
- coefficient: number;
622
- description: string;
623
- actionableInsight: string;
624
- }>;
625
- }>;
626
- };
627
- createAndAnalyze: typeof createAndAnalyze;
330
+ generateZendeskMarker: typeof generateZendeskMarker;
331
+ parseZendeskMarker: typeof parseZendeskMarker;
332
+ linkRunToTicket: typeof linkRunToTicket;
333
+ createRunWithContext: typeof createRunWithContext;
334
+ isFact: typeof isFact;
335
+ isInference: typeof isInference;
336
+ calculateBrierScore: typeof calculateBrierScore;
337
+ isWellCalibrated: typeof isWellCalibrated;
628
338
  };
629
339
  export default _default;