@sentrial/sdk 0.4.5 → 0.6.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.
@@ -0,0 +1,612 @@
1
+ /**
2
+ * PII Redaction Module
3
+ *
4
+ * Automatically detects and redacts personally identifiable information (PII)
5
+ * from SDK payloads before they are sent to the Sentrial API.
6
+ */
7
+
8
+ /** How redacted values are replaced */
9
+ type PiiMode = 'label' | 'hash' | 'remove';
10
+ /** Fields that can be redacted in SDK payloads */
11
+ type PiiField = 'userInput' | 'assistantOutput' | 'toolInput' | 'toolOutput' | 'metadata' | 'reasoning' | 'name' | 'failureReason';
12
+ /** A custom regex pattern with a human-readable label */
13
+ interface PiiCustomPattern {
14
+ pattern: RegExp;
15
+ label: string;
16
+ }
17
+ /** Toggle individual builtin pattern categories */
18
+ interface PiiBuiltinPatterns {
19
+ emails?: boolean;
20
+ phones?: boolean;
21
+ ssns?: boolean;
22
+ creditCards?: boolean;
23
+ ipAddresses?: boolean;
24
+ }
25
+ /** Full PII redaction configuration */
26
+ interface PiiConfig {
27
+ /** Enable PII redaction (default: false) */
28
+ enabled: boolean;
29
+ /** Which payload fields to redact (default: DEFAULT_FIELDS) */
30
+ fields?: PiiField[];
31
+ /** Replacement mode (default: 'label') */
32
+ mode?: PiiMode;
33
+ /** Toggle builtin patterns (default: all enabled) */
34
+ builtinPatterns?: PiiBuiltinPatterns;
35
+ /** Additional custom patterns to apply */
36
+ customPatterns?: PiiCustomPattern[];
37
+ }
38
+ /**
39
+ * Hash a value using SHA-256 and return the first 6 hex characters.
40
+ * Used in 'hash' mode to produce a short, deterministic pseudonym.
41
+ */
42
+ declare function hashValue(value: string): string;
43
+ /**
44
+ * Produce the replacement string for a matched PII value.
45
+ *
46
+ * - 'label' mode: [LABEL]
47
+ * - 'hash' mode: [PII:abcdef]
48
+ * - 'remove' mode: '' (empty string)
49
+ */
50
+ declare function replaceMatch(match: string, label: string, mode: PiiMode): string;
51
+ /**
52
+ * Run all enabled builtin and custom patterns against a single string,
53
+ * replacing every match according to the specified mode.
54
+ */
55
+ declare function redactString(value: string, mode: PiiMode, builtinPatterns: Required<PiiBuiltinPatterns>, customPatterns: PiiCustomPattern[]): string;
56
+ /**
57
+ * Recursively redact PII from a value. Handles strings, arrays, plain objects,
58
+ * and passes through primitives (numbers, booleans, null, undefined) unchanged.
59
+ */
60
+ declare function redactValue(value: unknown, mode: PiiMode, builtinPatterns: Required<PiiBuiltinPatterns>, customPatterns: PiiCustomPattern[]): unknown;
61
+ /**
62
+ * Main entry point: redact configured fields in a payload object.
63
+ *
64
+ * Only fields listed in the PiiConfig (or DEFAULT_FIELDS) are redacted.
65
+ * Other fields are returned unchanged.
66
+ *
67
+ * @param payload - The data payload (e.g., session params, tool call params)
68
+ * @param config - PII configuration from the client
69
+ * @returns A new payload object with PII redacted from the configured fields
70
+ */
71
+ declare function redactPayload(payload: Record<string, unknown>, config: PiiConfig): Record<string, unknown>;
72
+
73
+ /**
74
+ * EventBatcher — fire-and-forget event queue with periodic flushing.
75
+ *
76
+ * Buffers tracking events (tool calls, decisions, errors, generic events)
77
+ * and drains them off the caller's hot path. Each event is still delivered
78
+ * as its own HTTP request today (the drain loop sends per-event), so this
79
+ * trades caller latency for throughput, not request count. NOTE: the OTLP
80
+ * endpoint (/api/otel/v1/traces) is a batch protocol and the server accepts
81
+ * multi-span batches, so coalescing a flush's queued spans into ONE OTLP
82
+ * request (one round-trip + one advisory-lock ingest txn per session) is a
83
+ * viable follow-up — deferred, not blocked by a missing bulk endpoint.
84
+ * Session lifecycle calls (createSession, completeSession) bypass the batcher
85
+ * entirely because they need synchronous responses.
86
+ *
87
+ * Events are delivered in enqueue order so server-assigned sequence numbers
88
+ * match the order an agent actually executed steps.
89
+ *
90
+ * Flush triggers:
91
+ * 1. Timer — every `flushIntervalMs` (default 1 000 ms)
92
+ * 2. Queue size — when queue reaches `flushThreshold` (default 10)
93
+ * 3. Manual — `flush()` or `shutdown()`
94
+ * 4. Process exit — `beforeExit` handler
95
+ *
96
+ * Back-pressure: queue is capped at `maxQueueSize` (default 1 000).
97
+ * When full, oldest events are dropped and a warning is logged.
98
+ */
99
+ interface BatcherConfig {
100
+ /** Whether batching is enabled (default: false — all calls are immediate) */
101
+ enabled?: boolean;
102
+ /** Milliseconds between automatic flushes (default: 1000) */
103
+ flushIntervalMs?: number;
104
+ /** Flush when the queue reaches this many items (default: 10) */
105
+ flushThreshold?: number;
106
+ /** Maximum queue size before dropping oldest events (default: 1000) */
107
+ maxQueueSize?: number;
108
+ }
109
+ /** Signature for the function that actually sends an event to the API. */
110
+ type SendFn = (method: string, url: string, body: unknown) => Promise<unknown>;
111
+ /** Request counts for this batcher instance, never a trace-completeness claim. */
112
+ interface DeliveryDiagnostics {
113
+ enqueued: number;
114
+ delivered: number;
115
+ failed: number;
116
+ dropped: number;
117
+ rejectedAfterShutdown: number;
118
+ queued: number;
119
+ inFlight: number;
120
+ }
121
+ declare class EventBatcher {
122
+ private readonly queue;
123
+ private readonly flushIntervalMs;
124
+ private readonly flushThreshold;
125
+ private readonly maxQueueSize;
126
+ private timer;
127
+ private sendFn;
128
+ private flushPromise;
129
+ private shutdownCalled;
130
+ private counters;
131
+ private readonly exitHandler;
132
+ constructor(sendFn: SendFn, config?: BatcherConfig);
133
+ /**
134
+ * Enqueue an event for batched delivery.
135
+ *
136
+ * If the queue hits `flushThreshold`, an automatic flush is triggered.
137
+ * If the queue is full (`maxQueueSize`), the oldest event is dropped.
138
+ */
139
+ enqueue(method: string, url: string, body: unknown): void;
140
+ /**
141
+ * Flush all queued events to the API.
142
+ *
143
+ * Drains the queue and sends requests in enqueue order. Safe to call
144
+ * concurrently — only one flush runs at a time.
145
+ */
146
+ flush(): Promise<void>;
147
+ /** Drain the queue completely, including events enqueued while sending. */
148
+ private drainAll;
149
+ /**
150
+ * Stop the batcher: clear the timer, flush remaining events, remove exit handler.
151
+ */
152
+ shutdown(): Promise<void>;
153
+ /** Number of events currently queued. */
154
+ get size(): number;
155
+ get diagnostics(): Readonly<DeliveryDiagnostics>;
156
+ }
157
+
158
+ interface LargeToolContentConfig {
159
+ /** Explicit opt-in. The server and workspace must also enable uploads. */
160
+ enabled: boolean;
161
+ /** Identifies the caller's redaction policy, not proof that it was applied correctly. */
162
+ redactionRevision: string;
163
+ /** Per-field upload deadline, 1–60 seconds. Default: 20 seconds. */
164
+ timeoutMs?: number;
165
+ }
166
+
167
+ /**
168
+ * Type definitions for the Sentrial TypeScript SDK
169
+ */
170
+
171
+ /**
172
+ * Event types that can be tracked in a session
173
+ */
174
+ declare enum EventType {
175
+ TOOL_CALL = "tool_call",
176
+ LLM_DECISION = "llm_decision",
177
+ STATE_CHANGE = "state_change",
178
+ ERROR = "error"
179
+ }
180
+ /**
181
+ * Session status values
182
+ */
183
+ type SessionStatus = 'running' | 'completed' | 'failed' | 'cancelled';
184
+ /**
185
+ * Configuration options for SentrialClient
186
+ */
187
+ interface SentrialClientConfig {
188
+ /** API key for authentication (defaults to SENTRIAL_API_KEY env var) */
189
+ apiKey?: string;
190
+ /** URL of the Sentrial API server (defaults to SENTRIAL_API_URL env var or production) */
191
+ apiUrl?: string;
192
+ /**
193
+ * If true (default), SDK errors are logged but won't crash your app.
194
+ * Set to false during development to see full errors.
195
+ */
196
+ failSilently?: boolean;
197
+ /**
198
+ * PII redaction configuration.
199
+ * - Pass a PiiConfig object for full control.
200
+ * - Pass `true` to fetch the org's PII config from the server automatically.
201
+ * NOTE: the server-config auto-fetch requires an API key with the elevated
202
+ * `pii-config:read` scope, which product-issued keys do NOT carry by default.
203
+ * Without that scope the fetch returns 403 and the SDK falls back to the
204
+ * built-in default (label-mode) redaction rather than the org's configured
205
+ * policy. Pass an explicit PiiConfig object if you need guaranteed redaction.
206
+ */
207
+ pii?: PiiConfig | boolean;
208
+ /**
209
+ * Event batching configuration.
210
+ * When enabled, fire-and-forget tracking calls (trackToolCall, trackDecision,
211
+ * trackError, trackEvent) are queued and flushed periodically instead of
212
+ * being sent immediately. Session lifecycle calls (createSession,
213
+ * completeSession) always bypass the batcher.
214
+ */
215
+ batching?: BatcherConfig;
216
+ /** Opt-in bounded uploads of already-redacted tool input/output over 64 KiB.
217
+ * Requires an enabled server/workspace. Failures retain an explicit loss marker. */
218
+ largeToolContent?: LargeToolContentConfig;
219
+ }
220
+ /**
221
+ * Parameters for creating a new session
222
+ */
223
+ interface CreateSessionParams {
224
+ /** Name of the session */
225
+ name: string;
226
+ /** Identifier for the agent type (used for grouping) */
227
+ agentName: string;
228
+ /** External user ID (for grouping sessions by end-user) */
229
+ userId: string;
230
+ /** Optional parent session ID for multi-agent hierarchies */
231
+ parentSessionId?: string;
232
+ /** Optional conversation ID to group related sessions into a thread */
233
+ convoId?: string;
234
+ /** Optional metadata */
235
+ metadata?: Record<string, unknown>;
236
+ /** Production experiment assignment ids to link to this session */
237
+ experimentAssignmentIds?: string[];
238
+ /**
239
+ * Optional input captured at session creation. Emitted on the root span as the structured
240
+ * gen_ai.input.messages (this SDK is OTLP-only).
241
+ */
242
+ input?: string;
243
+ /** The (primary) requested model for the run, when known at creation (→ gen_ai.request.model). */
244
+ model?: string;
245
+ }
246
+ /**
247
+ * Parameters for completing a session
248
+ */
249
+ interface CompleteSessionParams {
250
+ /** Session ID */
251
+ sessionId: string;
252
+ /** Whether the session successfully completed its goal (default: true) */
253
+ success?: boolean;
254
+ /** If success=false, why did it fail? */
255
+ failureReason?: string;
256
+ /** Total estimated cost in USD for this session */
257
+ estimatedCost?: number;
258
+ /** Custom metrics (e.g., { customer_satisfaction: 4.5, steps_taken: 3 }) */
259
+ customMetrics?: Record<string, number>;
260
+ /** Duration in milliseconds (auto-calculated if not provided) */
261
+ durationMs?: number;
262
+ /** Number of prompt/input tokens used */
263
+ promptTokens?: number;
264
+ /** Number of completion/output tokens used */
265
+ completionTokens?: number;
266
+ /** Total tokens used (prompt + completion) */
267
+ totalTokens?: number;
268
+ /** The user's original query/input for this session */
269
+ userInput?: string;
270
+ /** The final assistant response for this session */
271
+ assistantOutput?: string;
272
+ /** Alias for assistantOutput - the final output text */
273
+ output?: string;
274
+ /** The resolved model for the run, when only known at completion (overrides createSession's). */
275
+ model?: string;
276
+ }
277
+ /**
278
+ * Session data returned from the API
279
+ */
280
+ interface Session {
281
+ id: string;
282
+ agentId?: string;
283
+ parentSessionId?: string;
284
+ convoId?: string;
285
+ name: string;
286
+ agentName: string;
287
+ userId: string;
288
+ status: SessionStatus;
289
+ totalEvents: number;
290
+ userInput?: string;
291
+ assistantOutput?: string;
292
+ success?: boolean;
293
+ failureReason?: string;
294
+ estimatedCost?: number;
295
+ customMetrics?: Record<string, unknown>;
296
+ score?: number;
297
+ metricScores?: Record<string, unknown>;
298
+ metricReasonings?: Record<string, string>;
299
+ promptTokens?: number;
300
+ completionTokens?: number;
301
+ totalTokens?: number;
302
+ durationMs?: number;
303
+ metadata?: Record<string, unknown>;
304
+ createdAt: string;
305
+ updatedAt: string;
306
+ completedAt?: string;
307
+ }
308
+ /**
309
+ * Parameters for tracking a tool call event
310
+ */
311
+ interface TrackToolCallParams {
312
+ /** Session ID */
313
+ sessionId: string;
314
+ /** Name of the tool */
315
+ toolName: string;
316
+ /** Tool input data */
317
+ toolInput: Record<string, unknown>;
318
+ /** Tool output data */
319
+ toolOutput: Record<string, unknown>;
320
+ /** Optional reasoning for why this tool was called */
321
+ reasoning?: string;
322
+ /** Estimated cost in USD for this tool call */
323
+ estimatedCost?: number;
324
+ /**
325
+ * Error details if the tool failed. Recognized keys persisted under the OTLP transport:
326
+ * `message`, `type` (alias `name`), `stack_trace` (alias `stackTrace`) — other keys are
327
+ * not persisted.
328
+ */
329
+ toolError?: Record<string, unknown>;
330
+ /** Number of tokens used by this tool call (for LLM-based tools) */
331
+ tokenCount?: number;
332
+ /** Per-call prompt/completion token split (for LLM-based tools) — emitted as first-class fields. */
333
+ promptTokens?: number;
334
+ completionTokens?: number;
335
+ /** The model used for this call (for LLM-based tools) — emitted as gen_ai.request.model. */
336
+ model?: string;
337
+ /** Why generation stopped for this call (e.g. 'stop', 'length', 'tool_calls'). */
338
+ finishReason?: string;
339
+ /** How long the tool call took (ms). Sets the event span's real duration (otherwise the event
340
+ * is recorded as instantaneous). */
341
+ durationMs?: number;
342
+ /** When the tool call started (Date or ms epoch). Defaults to now − durationMs when only the
343
+ * duration is known. */
344
+ startedAt?: Date | number;
345
+ /** Deprecated: accepted for backward compatibility but ignored — this SDK is OTLP-only. */
346
+ traceId?: string;
347
+ /** Deprecated: accepted for backward compatibility but ignored — this SDK is OTLP-only. */
348
+ spanId?: string;
349
+ /** Additional metadata */
350
+ metadata?: Record<string, unknown>;
351
+ }
352
+ /**
353
+ * Parameters for tracking an LLM decision event
354
+ */
355
+ interface TrackDecisionParams {
356
+ /** Session ID */
357
+ sessionId: string;
358
+ /** Decision reasoning */
359
+ reasoning: string;
360
+ /** Alternative options considered */
361
+ alternatives?: string[];
362
+ /** Confidence score (0.0 to 1.0) */
363
+ confidence?: number;
364
+ /** Estimated cost in USD for this decision */
365
+ estimatedCost?: number;
366
+ /** Number of tokens used */
367
+ tokenCount?: number;
368
+ /** How long the decision took (ms). Sets the event span's real duration. */
369
+ durationMs?: number;
370
+ /** When the decision started (Date or ms epoch). */
371
+ startedAt?: Date | number;
372
+ /** Deprecated: accepted for backward compatibility but ignored — this SDK is OTLP-only. */
373
+ traceId?: string;
374
+ /** Deprecated: accepted for backward compatibility but ignored — this SDK is OTLP-only. */
375
+ spanId?: string;
376
+ /** Additional metadata */
377
+ metadata?: Record<string, unknown>;
378
+ }
379
+ /**
380
+ * Parameters for tracking an error event
381
+ */
382
+ interface TrackErrorParams {
383
+ /** Session ID */
384
+ sessionId: string;
385
+ /** Error message */
386
+ errorMessage: string;
387
+ /** Type of error (e.g., "ValueError", "APIError") */
388
+ errorType?: string;
389
+ /** Name of the tool that caused the error (if applicable) */
390
+ toolName?: string;
391
+ /** Stack trace for debugging */
392
+ stackTrace?: string;
393
+ /** How long the failed operation ran before erroring (ms). Sets the event span's real duration. */
394
+ durationMs?: number;
395
+ /** When the failed operation started (Date or ms epoch). */
396
+ startedAt?: Date | number;
397
+ /** Deprecated: accepted for backward compatibility but ignored — this SDK is OTLP-only. */
398
+ traceId?: string;
399
+ /** Deprecated: accepted for backward compatibility but ignored — this SDK is OTLP-only. */
400
+ spanId?: string;
401
+ /** Additional metadata */
402
+ metadata?: Record<string, unknown>;
403
+ }
404
+ /**
405
+ * Event data returned from the API
406
+ */
407
+ interface Event {
408
+ id: string;
409
+ sessionId: string;
410
+ eventType: EventType;
411
+ timestamp: string;
412
+ sequenceNumber: number;
413
+ toolName?: string;
414
+ toolInput?: Record<string, unknown>;
415
+ toolOutput?: Record<string, unknown>;
416
+ toolError?: Record<string, unknown>;
417
+ reasoning?: string;
418
+ alternativesConsidered?: string[];
419
+ confidence?: number;
420
+ stateBefore?: Record<string, unknown>;
421
+ stateAfter?: Record<string, unknown>;
422
+ stateDiff?: Record<string, unknown>;
423
+ estimatedCost?: number;
424
+ tokenCount?: number;
425
+ metadata?: Record<string, unknown>;
426
+ traceId?: string;
427
+ spanId?: string;
428
+ }
429
+ /** A session object as returned by `GET /api/v1/sessions` (raw wire shape). */
430
+ interface SessionResponse {
431
+ id: string;
432
+ name?: string | null;
433
+ agentName?: string | null;
434
+ agentSlug?: string | null;
435
+ convoId?: string | null;
436
+ userId?: string | null;
437
+ status?: string | null;
438
+ success?: boolean | null;
439
+ failureReason?: string | null;
440
+ totalEvents?: number | null;
441
+ durationMs?: number | null;
442
+ estimatedCost?: number | null;
443
+ promptTokens?: number | null;
444
+ completionTokens?: number | null;
445
+ totalTokens?: number | null;
446
+ score?: number | null;
447
+ metricScores?: unknown;
448
+ metricReasonings?: unknown;
449
+ customMetrics?: unknown;
450
+ userInput?: string | null;
451
+ assistantOutput?: string | null;
452
+ metadata?: unknown;
453
+ detectedIssues?: unknown;
454
+ createdAt?: string | null;
455
+ completedAt?: string | null;
456
+ }
457
+ /** An event object as returned by `GET /api/v1/sessions/:id/events` (raw wire shape). */
458
+ interface EventResponse {
459
+ id: string;
460
+ sessionId: string;
461
+ eventType: string;
462
+ sequenceNumber?: number | null;
463
+ timestamp?: string | null;
464
+ toolName?: string | null;
465
+ toolInput?: unknown;
466
+ toolOutput?: unknown;
467
+ toolError?: unknown;
468
+ reasoning?: string | null;
469
+ alternativesConsidered?: unknown;
470
+ confidence?: number | null;
471
+ estimatedCost?: number | null;
472
+ tokenCount?: number | null;
473
+ metadata?: unknown;
474
+ traceId?: string | null;
475
+ spanId?: string | null;
476
+ }
477
+ /**
478
+ * Parameters for beginning an interaction
479
+ */
480
+ interface BeginParams {
481
+ /** Parent session from a validated worker handoff. */
482
+ parentSessionId?: string;
483
+ /** External user ID for grouping sessions */
484
+ userId: string;
485
+ /** Event type/name (e.g., "chat_message", "search_query") */
486
+ event: string;
487
+ /** Optional input data for the interaction */
488
+ input?: string;
489
+ /** Optional custom event ID (auto-generated UUID if not provided) */
490
+ eventId?: string;
491
+ /** Optional conversation ID to group related interactions */
492
+ convoId?: string;
493
+ /** Optional additional metadata */
494
+ metadata?: Record<string, unknown>;
495
+ /**
496
+ * Optional session title override. Defaults to the auto-generated `{event}:{eventId[:8]}` when
497
+ * omitted. Redacted like the input before emission (→ sentrial.session.name).
498
+ */
499
+ name?: string;
500
+ /** The (primary) requested model for the run, when known at begin (→ gen_ai.request.model). */
501
+ model?: string;
502
+ }
503
+ /**
504
+ * Parameters for finishing an interaction
505
+ */
506
+ interface FinishParams {
507
+ /** Output/response from the interaction */
508
+ output?: string;
509
+ /** Whether the interaction succeeded (default: true) */
510
+ success?: boolean;
511
+ /** Reason for failure if success=false */
512
+ failureReason?: string;
513
+ /** Total estimated cost in USD */
514
+ estimatedCost?: number;
515
+ /** Custom metrics */
516
+ customMetrics?: Record<string, number>;
517
+ /** Number of prompt/input tokens used */
518
+ promptTokens?: number;
519
+ /** Number of completion/output tokens used */
520
+ completionTokens?: number;
521
+ /** Total tokens used */
522
+ totalTokens?: number;
523
+ /** Duration in milliseconds (auto-calculated from begin/finish if not provided) */
524
+ durationMs?: number;
525
+ }
526
+ interface ProductionVariantConfig {
527
+ name: string;
528
+ weight?: number;
529
+ prompt?: string;
530
+ systemPrompt?: string;
531
+ model?: string;
532
+ promptVersion?: string;
533
+ toolConfig?: Record<string, unknown>;
534
+ metadata?: Record<string, unknown>;
535
+ }
536
+ interface GetVariantParams {
537
+ /** Production experiment name configured in Sentrial */
538
+ experimentName: string;
539
+ /** Agent name this variant is for */
540
+ agentName?: string;
541
+ /** Required when the experiment assigns by user. Other IDs are not substitutes. */
542
+ userId?: string;
543
+ /** Required when the experiment assigns by conversation. */
544
+ convoId?: string;
545
+ /** Required when the experiment assigns by stable anonymous identity. */
546
+ anonymousId?: string;
547
+ /** Optional existing Sentrial session id */
548
+ sessionId?: string;
549
+ /** Variant to use when no active live experiment matches */
550
+ defaultVariant?: string;
551
+ /** Prompt version currently running in the customer app */
552
+ promptVersion?: string;
553
+ /** Model currently running in the customer app */
554
+ model?: string;
555
+ /** Extra assignment metadata */
556
+ metadata?: Record<string, unknown>;
557
+ }
558
+ interface VariantAssignment {
559
+ active: boolean;
560
+ reason: 'assigned' | 'holdout' | 'not_found' | 'missing_identity';
561
+ /** Declared unit, or the required unit when reason is missing_identity. */
562
+ assignmentUnit?: 'user' | 'convo' | 'anonymous';
563
+ /** Historical fallback identities remain unknown; retries do not certify them. */
564
+ identityProvenance?: 'declared' | 'legacy_unknown';
565
+ experimentId?: string;
566
+ assignmentId?: string;
567
+ /** Frozen configuration digest; absent on legacy assignments. */
568
+ configurationHash?: string;
569
+ variant: string;
570
+ variantConfig?: ProductionVariantConfig;
571
+ prompt?: string;
572
+ systemPrompt?: string;
573
+ model?: string;
574
+ promptVersion?: string;
575
+ toolConfig?: Record<string, unknown>;
576
+ }
577
+ /** Explicit application report after using the returned configuration. */
578
+ interface RecordExperimentExposureParams {
579
+ assignmentId: string;
580
+ sessionId: string;
581
+ variant: string;
582
+ configurationHash: string;
583
+ }
584
+ interface ExperimentExposureReceipt extends RecordExperimentExposureParams {
585
+ /** Server arrival time, not provider invocation time. */
586
+ recordedAt: string;
587
+ source: 'sdk_reported';
588
+ }
589
+ /**
590
+ * Parameters for cost calculation
591
+ */
592
+ interface CostParams {
593
+ /** Model name (e.g., "gpt-4", "claude-3-sonnet") */
594
+ model: string;
595
+ /** Number of input tokens */
596
+ inputTokens: number;
597
+ /** Number of output tokens */
598
+ outputTokens: number;
599
+ }
600
+ /**
601
+ * Standard API response wrapper
602
+ */
603
+ interface ApiResponse<T> {
604
+ data?: T;
605
+ error?: {
606
+ code: string;
607
+ message: string;
608
+ details?: Record<string, unknown>;
609
+ };
610
+ }
611
+
612
+ export { type ApiResponse as A, type BeginParams as B, type CostParams as C, type DeliveryDiagnostics as D, type EventResponse as E, type FinishParams as F, type GetVariantParams as G, type LargeToolContentConfig as L, type PiiBuiltinPatterns as P, type RecordExperimentExposureParams as R, type SessionResponse as S, type TrackToolCallParams as T, type VariantAssignment as V, type SentrialClientConfig as a, type CreateSessionParams as b, type ExperimentExposureReceipt as c, type Event as d, type TrackDecisionParams as e, type TrackErrorParams as f, type Session as g, type CompleteSessionParams as h, type BatcherConfig as i, EventBatcher as j, EventType as k, type PiiConfig as l, type PiiCustomPattern as m, type PiiField as n, type PiiMode as o, type ProductionVariantConfig as p, type SessionStatus as q, hashValue as r, redactPayload as s, redactString as t, redactValue as u, replaceMatch as v };