teckel-ai 0.3.6 → 0.7.1

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.mts CHANGED
@@ -1,214 +1,141 @@
1
+ import { T as TeckelConfig, a as TraceData, F as FeedbackData } from './types-c7iVpo4d.mjs';
2
+ export { B as BatchConfig, D as Document, g as FeedbackResult, e as FeedbackType, S as SpanData, d as SpanStatus, c as SpanType, b as TokenUsage, f as TraceResult } from './types-c7iVpo4d.mjs';
1
3
  import { z } from 'zod';
2
4
 
3
5
  /**
4
- * Type definitions for teckel-ai SDK v0.3.6
5
- * Simple, clean types matching existing database schema
6
- */
7
- /**
8
- * SDK Configuration
9
- */
10
- interface TeckelConfig {
11
- apiKey: string;
12
- endpoint?: string;
13
- debug?: boolean;
14
- timeoutMs?: number;
15
- }
16
- /**
17
- * Conversation options
18
- * sessionRef IS the conversation identifier
6
+ * TeckelTracer - Fire-and-forget trace collection for AI applications
19
7
  *
20
- * Naming convention:
21
- * - *Ref = Client-provided identifier (TEXT)
22
- * - *Id = Server-generated internal ID (UUID)
23
- */
24
- interface ConversationOptions {
25
- sessionRef?: string;
26
- userRef?: string;
27
- metadata?: Record<string, unknown>;
28
- }
29
- /**
30
- * Document structure for RAG systems
31
- * Matches existing documents + chunk_events schema
32
- */
33
- interface Document {
34
- documentRef: string;
35
- documentName: string;
36
- documentText: string;
37
- documentLastUpdated?: string;
38
- sourceUri?: string;
39
- sourceType?: string;
40
- similarity?: number;
41
- rank?: number;
42
- ownerEmail?: string;
43
- documentType?: string;
44
- }
45
- /**
46
- * Token usage tracking
47
- */
48
- interface TokenUsage {
49
- prompt: number;
50
- completion: number;
51
- total: number;
52
- }
53
- /**
54
- * Trace data for a single query-response interaction
55
- * Matches existing traces table schema
56
- */
57
- interface TraceData {
58
- query: string;
59
- response: string;
60
- model?: string;
61
- responseTimeMs?: number;
62
- documents?: Document[];
63
- tokens?: TokenUsage;
64
- metadata?: Record<string, unknown>;
65
- traceRef?: string;
66
- userRef?: string;
67
- }
68
- /**
69
- * Feedback types
70
- */
71
- type FeedbackType = 'thumbs_up' | 'thumbs_down' | 'flag' | 'rating';
72
- /**
73
- * User feedback signal
74
- */
75
- interface FeedbackData {
76
- type: FeedbackType;
77
- value?: string;
78
- comment?: string;
79
- traceRef?: string;
80
- }
81
- /**
82
- * Result returned when a trace is created
83
- */
84
- interface TraceResult {
85
- traceRef: string;
86
- turnNumber: number;
87
- }
88
-
89
- /**
90
- * Conversation class for teckel-ai SDK v0.3.6
91
- * Manages a single conversation with fire-and-forget semantics
8
+ * v0.6.0: Added batch ingestion for high-throughput scenarios (100x improvement)
92
9
  */
93
10
 
94
- /** Internal type - sessionRef is guaranteed by TeckelTracer.start() */
95
- interface ResolvedConversationOptions extends ConversationOptions {
96
- sessionRef: string;
97
- }
98
- declare class Conversation {
11
+ declare class TeckelTracer {
99
12
  private readonly apiKey;
100
13
  private readonly endpoint;
101
- private readonly sessionRef;
102
- private readonly userRef?;
103
- private readonly metadata?;
104
- private readonly startedAt;
105
14
  private readonly debug;
106
15
  private readonly timeoutMs;
107
- private turnCount;
108
- private startPromise;
16
+ private readonly batchConfig;
109
17
  private sendQueue;
110
- constructor(apiKey: string, endpoint: string, options: ResolvedConversationOptions, debug?: boolean, extras?: {
111
- timeoutMs: number;
112
- });
18
+ private batchBuffer;
19
+ private batchByteCount;
20
+ private batchFlushTimer;
21
+ private isDestroyed;
22
+ constructor(config: TeckelConfig);
23
+ /**
24
+ * Record a trace. Fire-and-forget - call flush() in serverless before termination.
25
+ *
26
+ * With batching enabled (default), traces are buffered and sent in batches
27
+ * for dramatically improved throughput (100x for high-volume scenarios).
28
+ *
29
+ * Token auto-aggregation: If you provide `spans` but not `tokens`, the tracer
30
+ * automatically aggregates token counts from all spans. OTel spans contain
31
+ * per-span token usage (promptTokens, completionTokens) which are summed to
32
+ * produce the trace-level totals. You can also provide your own `tokens` object
33
+ * to override this behavior.
34
+ *
35
+ * Cost calculation: If you provide `costUsd`, we use your value directly.
36
+ * Otherwise, cost is automatically calculated server-side from token counts.
37
+ * Per-span `costUsd` is also supported for detailed breakdown.
38
+ */
39
+ trace(data: TraceData): void;
113
40
  /**
114
- * Record a trace (single query-response interaction)
115
- * Fire-and-forget by default - never blocks
116
- * For serverless, call flush() before function termination
41
+ * Submit feedback for a trace or session.
42
+ * Feedback is always sent immediately (not batched).
117
43
  */
118
- trace(data: TraceData): TraceResult | void;
44
+ feedback(data: FeedbackData): void;
119
45
  /**
120
- * Add user feedback signal
121
- * Never throws - gracefully handles errors
46
+ * Wait for queued requests to complete. Essential for serverless environments.
47
+ * This will flush any pending batch and wait for all requests to complete.
122
48
  */
123
- feedback(data: FeedbackData): Promise<void>;
49
+ flush(timeoutMs?: number): Promise<void>;
124
50
  /**
125
- * End the conversation
126
- * Flushes all pending traces before sending end signal
127
- * Never throws - gracefully handles errors
51
+ * Cleanup tracer resources. Call when done with the tracer.
52
+ * This flushes pending traces and stops the auto-flush timer.
128
53
  */
129
- end(): Promise<void>;
54
+ destroy(): Promise<void>;
130
55
  /**
131
- * Read-only properties
56
+ * Get current batch buffer size (for testing/debugging)
132
57
  */
133
- get id(): string;
134
- get turns(): number;
135
- get started(): Date;
58
+ get pendingTraceCount(): number;
59
+ /**
60
+ * Start the auto-flush timer
61
+ */
62
+ private startFlushTimer;
63
+ /**
64
+ * Stop the auto-flush timer
65
+ */
66
+ private stopFlushTimer;
67
+ /**
68
+ * Flush the current batch buffer
69
+ */
70
+ private flushBatch;
71
+ /**
72
+ * Send a batch of traces
73
+ */
74
+ private sendBatch;
75
+ private send;
136
76
  private fetchWithRetry;
137
- private _startConversation;
138
- private _sendTrace;
139
- private _sendFeedback;
140
- private _endConversation;
141
- private enqueueSend;
77
+ private enqueue;
142
78
  /**
143
- * Flush queued sends with a bounded timeout.
144
- * Returns when the queue is empty or the timeout elapses (whichever comes first).
79
+ * Log validation errors with actionable hints for common issues.
80
+ * Optionally reports to platform for internal debugging.
145
81
  */
146
- flush(timeoutMs?: number): Promise<void>;
147
- }
148
-
149
- /**
150
- * TeckelTracer - Main SDK class for teckel-ai v0.3.6
151
- * Simple, lightweight SDK for AI conversation tracking
152
- */
153
-
154
- declare class TeckelTracer {
155
- private readonly apiKey;
156
- private readonly endpoint;
157
- private readonly debug;
158
- private readonly timeoutMs;
159
- constructor(config: TeckelConfig);
82
+ private logValidationError;
160
83
  /**
161
- * Start a new conversation
162
- * sessionRef IS the public conversation identifier
163
- * If not provided, auto-generates one as 'auto:{8-char-uuid}'
84
+ * Provide actionable hints for common validation errors.
164
85
  */
165
- start(options?: ConversationOptions): Conversation;
86
+ private getValidationHint;
87
+ /**
88
+ * Report dropped traces to platform for internal debugging.
89
+ * Fire-and-forget - never blocks or throws.
90
+ */
91
+ private reportDropped;
92
+ private logHttpError;
166
93
  }
167
94
 
168
95
  /**
169
- * Zod validation schemas for teckel-ai SDK v0.3.6
96
+ * Zod validation schemas for teckel-ai SDK
170
97
  */
171
98
 
172
- /**
173
- * Document schema
174
- */
99
+ /** Payload size limits */
100
+ declare const TRACE_SIZE_LIMITS: {
101
+ readonly METADATA_MAX_BYTES: 10000;
102
+ readonly TRACE_MAX_BYTES: 3000000;
103
+ readonly MAX_DOCUMENTS: 15;
104
+ };
175
105
  declare const DocumentSchema: z.ZodObject<{
176
- documentRef: z.ZodString;
177
- documentName: z.ZodString;
178
- documentText: z.ZodString;
179
- documentLastUpdated: z.ZodOptional<z.ZodString>;
180
- sourceUri: z.ZodOptional<z.ZodString>;
181
- sourceType: z.ZodOptional<z.ZodString>;
106
+ id: z.ZodString;
107
+ name: z.ZodString;
108
+ text: z.ZodString;
109
+ lastUpdated: z.ZodOptional<z.ZodString>;
110
+ url: z.ZodOptional<z.ZodString>;
111
+ source: z.ZodOptional<z.ZodString>;
112
+ fileFormat: z.ZodOptional<z.ZodString>;
182
113
  similarity: z.ZodOptional<z.ZodNumber>;
183
114
  rank: z.ZodOptional<z.ZodNumber>;
184
115
  ownerEmail: z.ZodOptional<z.ZodString>;
185
- documentType: z.ZodOptional<z.ZodString>;
186
116
  }, "strip", z.ZodTypeAny, {
187
- documentRef: string;
188
- documentName: string;
189
- documentText: string;
190
- documentLastUpdated?: string | undefined;
191
- sourceUri?: string | undefined;
192
- sourceType?: string | undefined;
117
+ id: string;
118
+ name: string;
119
+ text: string;
120
+ lastUpdated?: string | undefined;
121
+ url?: string | undefined;
122
+ source?: string | undefined;
123
+ fileFormat?: string | undefined;
193
124
  similarity?: number | undefined;
194
125
  rank?: number | undefined;
195
126
  ownerEmail?: string | undefined;
196
- documentType?: string | undefined;
197
127
  }, {
198
- documentRef: string;
199
- documentName: string;
200
- documentText: string;
201
- documentLastUpdated?: string | undefined;
202
- sourceUri?: string | undefined;
203
- sourceType?: string | undefined;
128
+ id: string;
129
+ name: string;
130
+ text: string;
131
+ lastUpdated?: string | undefined;
132
+ url?: string | undefined;
133
+ source?: string | undefined;
134
+ fileFormat?: string | undefined;
204
135
  similarity?: number | undefined;
205
136
  rank?: number | undefined;
206
137
  ownerEmail?: string | undefined;
207
- documentType?: string | undefined;
208
138
  }>;
209
- /**
210
- * Token usage schema
211
- */
212
139
  declare const TokenUsageSchema: z.ZodObject<{
213
140
  prompt: z.ZodNumber;
214
141
  completion: z.ZodNumber;
@@ -222,168 +149,561 @@ declare const TokenUsageSchema: z.ZodObject<{
222
149
  completion: number;
223
150
  total: number;
224
151
  }>;
225
- /**
226
- * Trace data schema
227
- */
228
- declare const TraceDataSchema: z.ZodObject<{
152
+ /** Span size limits */
153
+ declare const SPAN_SIZE_LIMITS: {
154
+ readonly MAX_SPANS: 100;
155
+ readonly JSONB_MAX_BYTES: 512000;
156
+ };
157
+ /** Span type enum - 6 meaningful operation types */
158
+ declare const SpanTypeSchema: z.ZodEnum<["llm_call", "tool_call", "retrieval", "agent", "guardrail", "custom"]>;
159
+ /** Span status enum */
160
+ declare const SpanStatusSchema: z.ZodEnum<["running", "completed", "error"]>;
161
+ /** Schema for span data */
162
+ declare const SpanDataSchema: z.ZodEffects<z.ZodObject<{
163
+ spanId: z.ZodOptional<z.ZodString>;
164
+ parentSpanId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
165
+ name: z.ZodString;
166
+ type: z.ZodDefault<z.ZodEnum<["llm_call", "tool_call", "retrieval", "agent", "guardrail", "custom"]>>;
167
+ startedAt: z.ZodString;
168
+ endedAt: z.ZodNullable<z.ZodOptional<z.ZodString>>;
169
+ durationMs: z.ZodOptional<z.ZodNumber>;
170
+ status: z.ZodDefault<z.ZodEnum<["running", "completed", "error"]>>;
171
+ statusMessage: z.ZodNullable<z.ZodOptional<z.ZodString>>;
172
+ toolName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
173
+ toolArguments: z.ZodEffects<z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>, Record<string, unknown> | null | undefined, Record<string, unknown> | null | undefined>;
174
+ toolResult: z.ZodEffects<z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>, Record<string, unknown> | null | undefined, Record<string, unknown> | null | undefined>;
175
+ model: z.ZodNullable<z.ZodOptional<z.ZodString>>;
176
+ promptTokens: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
177
+ completionTokens: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
178
+ costUsd: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
179
+ input: z.ZodEffects<z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>, Record<string, unknown> | null | undefined, Record<string, unknown> | null | undefined>;
180
+ output: z.ZodEffects<z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>, Record<string, unknown> | null | undefined, Record<string, unknown> | null | undefined>;
181
+ metadata: z.ZodEffects<z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>, Record<string, unknown> | null | undefined, Record<string, unknown> | null | undefined>;
182
+ }, "strip", z.ZodTypeAny, {
183
+ name: string;
184
+ type: "llm_call" | "tool_call" | "retrieval" | "agent" | "guardrail" | "custom";
185
+ status: "running" | "completed" | "error";
186
+ startedAt: string;
187
+ spanId?: string | undefined;
188
+ parentSpanId?: string | null | undefined;
189
+ endedAt?: string | null | undefined;
190
+ durationMs?: number | undefined;
191
+ statusMessage?: string | null | undefined;
192
+ toolName?: string | null | undefined;
193
+ toolArguments?: Record<string, unknown> | null | undefined;
194
+ toolResult?: Record<string, unknown> | null | undefined;
195
+ model?: string | null | undefined;
196
+ promptTokens?: number | null | undefined;
197
+ completionTokens?: number | null | undefined;
198
+ costUsd?: number | null | undefined;
199
+ input?: Record<string, unknown> | null | undefined;
200
+ output?: Record<string, unknown> | null | undefined;
201
+ metadata?: Record<string, unknown> | null | undefined;
202
+ }, {
203
+ name: string;
204
+ startedAt: string;
205
+ type?: "llm_call" | "tool_call" | "retrieval" | "agent" | "guardrail" | "custom" | undefined;
206
+ status?: "running" | "completed" | "error" | undefined;
207
+ spanId?: string | undefined;
208
+ parentSpanId?: string | null | undefined;
209
+ endedAt?: string | null | undefined;
210
+ durationMs?: number | undefined;
211
+ statusMessage?: string | null | undefined;
212
+ toolName?: string | null | undefined;
213
+ toolArguments?: Record<string, unknown> | null | undefined;
214
+ toolResult?: Record<string, unknown> | null | undefined;
215
+ model?: string | null | undefined;
216
+ promptTokens?: number | null | undefined;
217
+ completionTokens?: number | null | undefined;
218
+ costUsd?: number | null | undefined;
219
+ input?: Record<string, unknown> | null | undefined;
220
+ output?: Record<string, unknown> | null | undefined;
221
+ metadata?: Record<string, unknown> | null | undefined;
222
+ }>, {
223
+ name: string;
224
+ type: "llm_call" | "tool_call" | "retrieval" | "agent" | "guardrail" | "custom";
225
+ status: "running" | "completed" | "error";
226
+ startedAt: string;
227
+ spanId?: string | undefined;
228
+ parentSpanId?: string | null | undefined;
229
+ endedAt?: string | null | undefined;
230
+ durationMs?: number | undefined;
231
+ statusMessage?: string | null | undefined;
232
+ toolName?: string | null | undefined;
233
+ toolArguments?: Record<string, unknown> | null | undefined;
234
+ toolResult?: Record<string, unknown> | null | undefined;
235
+ model?: string | null | undefined;
236
+ promptTokens?: number | null | undefined;
237
+ completionTokens?: number | null | undefined;
238
+ costUsd?: number | null | undefined;
239
+ input?: Record<string, unknown> | null | undefined;
240
+ output?: Record<string, unknown> | null | undefined;
241
+ metadata?: Record<string, unknown> | null | undefined;
242
+ }, {
243
+ name: string;
244
+ startedAt: string;
245
+ type?: "llm_call" | "tool_call" | "retrieval" | "agent" | "guardrail" | "custom" | undefined;
246
+ status?: "running" | "completed" | "error" | undefined;
247
+ spanId?: string | undefined;
248
+ parentSpanId?: string | null | undefined;
249
+ endedAt?: string | null | undefined;
250
+ durationMs?: number | undefined;
251
+ statusMessage?: string | null | undefined;
252
+ toolName?: string | null | undefined;
253
+ toolArguments?: Record<string, unknown> | null | undefined;
254
+ toolResult?: Record<string, unknown> | null | undefined;
255
+ model?: string | null | undefined;
256
+ promptTokens?: number | null | undefined;
257
+ completionTokens?: number | null | undefined;
258
+ costUsd?: number | null | undefined;
259
+ input?: Record<string, unknown> | null | undefined;
260
+ output?: Record<string, unknown> | null | undefined;
261
+ metadata?: Record<string, unknown> | null | undefined;
262
+ }>;
263
+ declare const TraceDataSchema: z.ZodEffects<z.ZodObject<{
229
264
  query: z.ZodString;
230
265
  response: z.ZodString;
266
+ agentName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
231
267
  model: z.ZodOptional<z.ZodString>;
232
- responseTimeMs: z.ZodOptional<z.ZodNumber>;
268
+ latencyMs: z.ZodOptional<z.ZodNumber>;
269
+ tokens: z.ZodOptional<z.ZodObject<{
270
+ prompt: z.ZodNumber;
271
+ completion: z.ZodNumber;
272
+ total: z.ZodNumber;
273
+ }, "strip", z.ZodTypeAny, {
274
+ prompt: number;
275
+ completion: number;
276
+ total: number;
277
+ }, {
278
+ prompt: number;
279
+ completion: number;
280
+ total: number;
281
+ }>>;
282
+ costUsd: z.ZodOptional<z.ZodNumber>;
233
283
  documents: z.ZodOptional<z.ZodArray<z.ZodObject<{
234
- documentRef: z.ZodString;
235
- documentName: z.ZodString;
236
- documentText: z.ZodString;
237
- documentLastUpdated: z.ZodOptional<z.ZodString>;
238
- sourceUri: z.ZodOptional<z.ZodString>;
239
- sourceType: z.ZodOptional<z.ZodString>;
284
+ id: z.ZodString;
285
+ name: z.ZodString;
286
+ text: z.ZodString;
287
+ lastUpdated: z.ZodOptional<z.ZodString>;
288
+ url: z.ZodOptional<z.ZodString>;
289
+ source: z.ZodOptional<z.ZodString>;
290
+ fileFormat: z.ZodOptional<z.ZodString>;
240
291
  similarity: z.ZodOptional<z.ZodNumber>;
241
292
  rank: z.ZodOptional<z.ZodNumber>;
242
293
  ownerEmail: z.ZodOptional<z.ZodString>;
243
- documentType: z.ZodOptional<z.ZodString>;
244
294
  }, "strip", z.ZodTypeAny, {
245
- documentRef: string;
246
- documentName: string;
247
- documentText: string;
248
- documentLastUpdated?: string | undefined;
249
- sourceUri?: string | undefined;
250
- sourceType?: string | undefined;
295
+ id: string;
296
+ name: string;
297
+ text: string;
298
+ lastUpdated?: string | undefined;
299
+ url?: string | undefined;
300
+ source?: string | undefined;
301
+ fileFormat?: string | undefined;
251
302
  similarity?: number | undefined;
252
303
  rank?: number | undefined;
253
304
  ownerEmail?: string | undefined;
254
- documentType?: string | undefined;
255
305
  }, {
256
- documentRef: string;
257
- documentName: string;
258
- documentText: string;
259
- documentLastUpdated?: string | undefined;
260
- sourceUri?: string | undefined;
261
- sourceType?: string | undefined;
306
+ id: string;
307
+ name: string;
308
+ text: string;
309
+ lastUpdated?: string | undefined;
310
+ url?: string | undefined;
311
+ source?: string | undefined;
312
+ fileFormat?: string | undefined;
262
313
  similarity?: number | undefined;
263
314
  rank?: number | undefined;
264
315
  ownerEmail?: string | undefined;
265
- documentType?: string | undefined;
266
316
  }>, "many">>;
267
- tokens: z.ZodOptional<z.ZodObject<{
268
- prompt: z.ZodNumber;
269
- completion: z.ZodNumber;
270
- total: z.ZodNumber;
317
+ spans: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
318
+ spanId: z.ZodOptional<z.ZodString>;
319
+ parentSpanId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
320
+ name: z.ZodString;
321
+ type: z.ZodDefault<z.ZodEnum<["llm_call", "tool_call", "retrieval", "agent", "guardrail", "custom"]>>;
322
+ startedAt: z.ZodString;
323
+ endedAt: z.ZodNullable<z.ZodOptional<z.ZodString>>;
324
+ durationMs: z.ZodOptional<z.ZodNumber>;
325
+ status: z.ZodDefault<z.ZodEnum<["running", "completed", "error"]>>;
326
+ statusMessage: z.ZodNullable<z.ZodOptional<z.ZodString>>;
327
+ toolName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
328
+ toolArguments: z.ZodEffects<z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>, Record<string, unknown> | null | undefined, Record<string, unknown> | null | undefined>;
329
+ toolResult: z.ZodEffects<z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>, Record<string, unknown> | null | undefined, Record<string, unknown> | null | undefined>;
330
+ model: z.ZodNullable<z.ZodOptional<z.ZodString>>;
331
+ promptTokens: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
332
+ completionTokens: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
333
+ costUsd: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
334
+ input: z.ZodEffects<z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>, Record<string, unknown> | null | undefined, Record<string, unknown> | null | undefined>;
335
+ output: z.ZodEffects<z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>, Record<string, unknown> | null | undefined, Record<string, unknown> | null | undefined>;
336
+ metadata: z.ZodEffects<z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>, Record<string, unknown> | null | undefined, Record<string, unknown> | null | undefined>;
271
337
  }, "strip", z.ZodTypeAny, {
272
- prompt: number;
273
- completion: number;
274
- total: number;
338
+ name: string;
339
+ type: "llm_call" | "tool_call" | "retrieval" | "agent" | "guardrail" | "custom";
340
+ status: "running" | "completed" | "error";
341
+ startedAt: string;
342
+ spanId?: string | undefined;
343
+ parentSpanId?: string | null | undefined;
344
+ endedAt?: string | null | undefined;
345
+ durationMs?: number | undefined;
346
+ statusMessage?: string | null | undefined;
347
+ toolName?: string | null | undefined;
348
+ toolArguments?: Record<string, unknown> | null | undefined;
349
+ toolResult?: Record<string, unknown> | null | undefined;
350
+ model?: string | null | undefined;
351
+ promptTokens?: number | null | undefined;
352
+ completionTokens?: number | null | undefined;
353
+ costUsd?: number | null | undefined;
354
+ input?: Record<string, unknown> | null | undefined;
355
+ output?: Record<string, unknown> | null | undefined;
356
+ metadata?: Record<string, unknown> | null | undefined;
275
357
  }, {
276
- prompt: number;
277
- completion: number;
278
- total: number;
279
- }>>;
280
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
281
- traceRef: z.ZodOptional<z.ZodString>;
282
- userRef: z.ZodOptional<z.ZodString>;
358
+ name: string;
359
+ startedAt: string;
360
+ type?: "llm_call" | "tool_call" | "retrieval" | "agent" | "guardrail" | "custom" | undefined;
361
+ status?: "running" | "completed" | "error" | undefined;
362
+ spanId?: string | undefined;
363
+ parentSpanId?: string | null | undefined;
364
+ endedAt?: string | null | undefined;
365
+ durationMs?: number | undefined;
366
+ statusMessage?: string | null | undefined;
367
+ toolName?: string | null | undefined;
368
+ toolArguments?: Record<string, unknown> | null | undefined;
369
+ toolResult?: Record<string, unknown> | null | undefined;
370
+ model?: string | null | undefined;
371
+ promptTokens?: number | null | undefined;
372
+ completionTokens?: number | null | undefined;
373
+ costUsd?: number | null | undefined;
374
+ input?: Record<string, unknown> | null | undefined;
375
+ output?: Record<string, unknown> | null | undefined;
376
+ metadata?: Record<string, unknown> | null | undefined;
377
+ }>, {
378
+ name: string;
379
+ type: "llm_call" | "tool_call" | "retrieval" | "agent" | "guardrail" | "custom";
380
+ status: "running" | "completed" | "error";
381
+ startedAt: string;
382
+ spanId?: string | undefined;
383
+ parentSpanId?: string | null | undefined;
384
+ endedAt?: string | null | undefined;
385
+ durationMs?: number | undefined;
386
+ statusMessage?: string | null | undefined;
387
+ toolName?: string | null | undefined;
388
+ toolArguments?: Record<string, unknown> | null | undefined;
389
+ toolResult?: Record<string, unknown> | null | undefined;
390
+ model?: string | null | undefined;
391
+ promptTokens?: number | null | undefined;
392
+ completionTokens?: number | null | undefined;
393
+ costUsd?: number | null | undefined;
394
+ input?: Record<string, unknown> | null | undefined;
395
+ output?: Record<string, unknown> | null | undefined;
396
+ metadata?: Record<string, unknown> | null | undefined;
397
+ }, {
398
+ name: string;
399
+ startedAt: string;
400
+ type?: "llm_call" | "tool_call" | "retrieval" | "agent" | "guardrail" | "custom" | undefined;
401
+ status?: "running" | "completed" | "error" | undefined;
402
+ spanId?: string | undefined;
403
+ parentSpanId?: string | null | undefined;
404
+ endedAt?: string | null | undefined;
405
+ durationMs?: number | undefined;
406
+ statusMessage?: string | null | undefined;
407
+ toolName?: string | null | undefined;
408
+ toolArguments?: Record<string, unknown> | null | undefined;
409
+ toolResult?: Record<string, unknown> | null | undefined;
410
+ model?: string | null | undefined;
411
+ promptTokens?: number | null | undefined;
412
+ completionTokens?: number | null | undefined;
413
+ costUsd?: number | null | undefined;
414
+ input?: Record<string, unknown> | null | undefined;
415
+ output?: Record<string, unknown> | null | undefined;
416
+ metadata?: Record<string, unknown> | null | undefined;
417
+ }>, "many">>;
418
+ sessionId: z.ZodOptional<z.ZodString>;
419
+ userId: z.ZodOptional<z.ZodString>;
420
+ traceId: z.ZodOptional<z.ZodString>;
421
+ systemPrompt: z.ZodOptional<z.ZodString>;
422
+ metadata: z.ZodEffects<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>, Record<string, unknown> | undefined, Record<string, unknown> | undefined>;
283
423
  }, "strip", z.ZodTypeAny, {
284
424
  query: string;
285
425
  response: string;
286
426
  model?: string | undefined;
287
- responseTimeMs?: number | undefined;
427
+ costUsd?: number | undefined;
428
+ metadata?: Record<string, unknown> | undefined;
429
+ agentName?: string | null | undefined;
430
+ latencyMs?: number | undefined;
431
+ tokens?: {
432
+ prompt: number;
433
+ completion: number;
434
+ total: number;
435
+ } | undefined;
288
436
  documents?: {
289
- documentRef: string;
290
- documentName: string;
291
- documentText: string;
292
- documentLastUpdated?: string | undefined;
293
- sourceUri?: string | undefined;
294
- sourceType?: string | undefined;
437
+ id: string;
438
+ name: string;
439
+ text: string;
440
+ lastUpdated?: string | undefined;
441
+ url?: string | undefined;
442
+ source?: string | undefined;
443
+ fileFormat?: string | undefined;
295
444
  similarity?: number | undefined;
296
445
  rank?: number | undefined;
297
446
  ownerEmail?: string | undefined;
298
- documentType?: string | undefined;
299
447
  }[] | undefined;
448
+ spans?: {
449
+ name: string;
450
+ type: "llm_call" | "tool_call" | "retrieval" | "agent" | "guardrail" | "custom";
451
+ status: "running" | "completed" | "error";
452
+ startedAt: string;
453
+ spanId?: string | undefined;
454
+ parentSpanId?: string | null | undefined;
455
+ endedAt?: string | null | undefined;
456
+ durationMs?: number | undefined;
457
+ statusMessage?: string | null | undefined;
458
+ toolName?: string | null | undefined;
459
+ toolArguments?: Record<string, unknown> | null | undefined;
460
+ toolResult?: Record<string, unknown> | null | undefined;
461
+ model?: string | null | undefined;
462
+ promptTokens?: number | null | undefined;
463
+ completionTokens?: number | null | undefined;
464
+ costUsd?: number | null | undefined;
465
+ input?: Record<string, unknown> | null | undefined;
466
+ output?: Record<string, unknown> | null | undefined;
467
+ metadata?: Record<string, unknown> | null | undefined;
468
+ }[] | undefined;
469
+ sessionId?: string | undefined;
470
+ userId?: string | undefined;
471
+ traceId?: string | undefined;
472
+ systemPrompt?: string | undefined;
473
+ }, {
474
+ query: string;
475
+ response: string;
476
+ model?: string | undefined;
477
+ costUsd?: number | undefined;
478
+ metadata?: Record<string, unknown> | undefined;
479
+ agentName?: string | null | undefined;
480
+ latencyMs?: number | undefined;
300
481
  tokens?: {
301
482
  prompt: number;
302
483
  completion: number;
303
484
  total: number;
304
485
  } | undefined;
305
- metadata?: Record<string, unknown> | undefined;
306
- traceRef?: string | undefined;
307
- userRef?: string | undefined;
308
- }, {
486
+ documents?: {
487
+ id: string;
488
+ name: string;
489
+ text: string;
490
+ lastUpdated?: string | undefined;
491
+ url?: string | undefined;
492
+ source?: string | undefined;
493
+ fileFormat?: string | undefined;
494
+ similarity?: number | undefined;
495
+ rank?: number | undefined;
496
+ ownerEmail?: string | undefined;
497
+ }[] | undefined;
498
+ spans?: {
499
+ name: string;
500
+ startedAt: string;
501
+ type?: "llm_call" | "tool_call" | "retrieval" | "agent" | "guardrail" | "custom" | undefined;
502
+ status?: "running" | "completed" | "error" | undefined;
503
+ spanId?: string | undefined;
504
+ parentSpanId?: string | null | undefined;
505
+ endedAt?: string | null | undefined;
506
+ durationMs?: number | undefined;
507
+ statusMessage?: string | null | undefined;
508
+ toolName?: string | null | undefined;
509
+ toolArguments?: Record<string, unknown> | null | undefined;
510
+ toolResult?: Record<string, unknown> | null | undefined;
511
+ model?: string | null | undefined;
512
+ promptTokens?: number | null | undefined;
513
+ completionTokens?: number | null | undefined;
514
+ costUsd?: number | null | undefined;
515
+ input?: Record<string, unknown> | null | undefined;
516
+ output?: Record<string, unknown> | null | undefined;
517
+ metadata?: Record<string, unknown> | null | undefined;
518
+ }[] | undefined;
519
+ sessionId?: string | undefined;
520
+ userId?: string | undefined;
521
+ traceId?: string | undefined;
522
+ systemPrompt?: string | undefined;
523
+ }>, {
309
524
  query: string;
310
525
  response: string;
311
526
  model?: string | undefined;
312
- responseTimeMs?: number | undefined;
527
+ costUsd?: number | undefined;
528
+ metadata?: Record<string, unknown> | undefined;
529
+ agentName?: string | null | undefined;
530
+ latencyMs?: number | undefined;
531
+ tokens?: {
532
+ prompt: number;
533
+ completion: number;
534
+ total: number;
535
+ } | undefined;
313
536
  documents?: {
314
- documentRef: string;
315
- documentName: string;
316
- documentText: string;
317
- documentLastUpdated?: string | undefined;
318
- sourceUri?: string | undefined;
319
- sourceType?: string | undefined;
537
+ id: string;
538
+ name: string;
539
+ text: string;
540
+ lastUpdated?: string | undefined;
541
+ url?: string | undefined;
542
+ source?: string | undefined;
543
+ fileFormat?: string | undefined;
320
544
  similarity?: number | undefined;
321
545
  rank?: number | undefined;
322
546
  ownerEmail?: string | undefined;
323
- documentType?: string | undefined;
324
547
  }[] | undefined;
548
+ spans?: {
549
+ name: string;
550
+ type: "llm_call" | "tool_call" | "retrieval" | "agent" | "guardrail" | "custom";
551
+ status: "running" | "completed" | "error";
552
+ startedAt: string;
553
+ spanId?: string | undefined;
554
+ parentSpanId?: string | null | undefined;
555
+ endedAt?: string | null | undefined;
556
+ durationMs?: number | undefined;
557
+ statusMessage?: string | null | undefined;
558
+ toolName?: string | null | undefined;
559
+ toolArguments?: Record<string, unknown> | null | undefined;
560
+ toolResult?: Record<string, unknown> | null | undefined;
561
+ model?: string | null | undefined;
562
+ promptTokens?: number | null | undefined;
563
+ completionTokens?: number | null | undefined;
564
+ costUsd?: number | null | undefined;
565
+ input?: Record<string, unknown> | null | undefined;
566
+ output?: Record<string, unknown> | null | undefined;
567
+ metadata?: Record<string, unknown> | null | undefined;
568
+ }[] | undefined;
569
+ sessionId?: string | undefined;
570
+ userId?: string | undefined;
571
+ traceId?: string | undefined;
572
+ systemPrompt?: string | undefined;
573
+ }, {
574
+ query: string;
575
+ response: string;
576
+ model?: string | undefined;
577
+ costUsd?: number | undefined;
578
+ metadata?: Record<string, unknown> | undefined;
579
+ agentName?: string | null | undefined;
580
+ latencyMs?: number | undefined;
325
581
  tokens?: {
326
582
  prompt: number;
327
583
  completion: number;
328
584
  total: number;
329
585
  } | undefined;
330
- metadata?: Record<string, unknown> | undefined;
331
- traceRef?: string | undefined;
332
- userRef?: string | undefined;
333
- }>;
334
- /**
335
- * Conversation options schema
336
- */
337
- declare const ConversationOptionsSchema: z.ZodObject<{
338
- sessionRef: z.ZodOptional<z.ZodString>;
339
- userRef: z.ZodOptional<z.ZodString>;
340
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
341
- }, "strip", z.ZodTypeAny, {
342
- metadata?: Record<string, unknown> | undefined;
343
- userRef?: string | undefined;
344
- sessionRef?: string | undefined;
345
- }, {
346
- metadata?: Record<string, unknown> | undefined;
347
- userRef?: string | undefined;
348
- sessionRef?: string | undefined;
586
+ documents?: {
587
+ id: string;
588
+ name: string;
589
+ text: string;
590
+ lastUpdated?: string | undefined;
591
+ url?: string | undefined;
592
+ source?: string | undefined;
593
+ fileFormat?: string | undefined;
594
+ similarity?: number | undefined;
595
+ rank?: number | undefined;
596
+ ownerEmail?: string | undefined;
597
+ }[] | undefined;
598
+ spans?: {
599
+ name: string;
600
+ startedAt: string;
601
+ type?: "llm_call" | "tool_call" | "retrieval" | "agent" | "guardrail" | "custom" | undefined;
602
+ status?: "running" | "completed" | "error" | undefined;
603
+ spanId?: string | undefined;
604
+ parentSpanId?: string | null | undefined;
605
+ endedAt?: string | null | undefined;
606
+ durationMs?: number | undefined;
607
+ statusMessage?: string | null | undefined;
608
+ toolName?: string | null | undefined;
609
+ toolArguments?: Record<string, unknown> | null | undefined;
610
+ toolResult?: Record<string, unknown> | null | undefined;
611
+ model?: string | null | undefined;
612
+ promptTokens?: number | null | undefined;
613
+ completionTokens?: number | null | undefined;
614
+ costUsd?: number | null | undefined;
615
+ input?: Record<string, unknown> | null | undefined;
616
+ output?: Record<string, unknown> | null | undefined;
617
+ metadata?: Record<string, unknown> | null | undefined;
618
+ }[] | undefined;
619
+ sessionId?: string | undefined;
620
+ userId?: string | undefined;
621
+ traceId?: string | undefined;
622
+ systemPrompt?: string | undefined;
349
623
  }>;
350
- /**
351
- * Feedback data schema
352
- */
353
- declare const FeedbackDataSchema: z.ZodObject<{
624
+ declare const FeedbackDataSchema: z.ZodEffects<z.ZodObject<{
625
+ traceId: z.ZodOptional<z.ZodString>;
626
+ sessionId: z.ZodOptional<z.ZodString>;
354
627
  type: z.ZodEnum<["thumbs_up", "thumbs_down", "flag", "rating"]>;
355
628
  value: z.ZodOptional<z.ZodString>;
356
629
  comment: z.ZodOptional<z.ZodString>;
357
- traceRef: z.ZodOptional<z.ZodString>;
358
630
  }, "strip", z.ZodTypeAny, {
359
631
  type: "thumbs_up" | "thumbs_down" | "flag" | "rating";
360
632
  value?: string | undefined;
361
- traceRef?: string | undefined;
633
+ sessionId?: string | undefined;
634
+ traceId?: string | undefined;
635
+ comment?: string | undefined;
636
+ }, {
637
+ type: "thumbs_up" | "thumbs_down" | "flag" | "rating";
638
+ value?: string | undefined;
639
+ sessionId?: string | undefined;
640
+ traceId?: string | undefined;
641
+ comment?: string | undefined;
642
+ }>, {
643
+ type: "thumbs_up" | "thumbs_down" | "flag" | "rating";
644
+ value?: string | undefined;
645
+ sessionId?: string | undefined;
646
+ traceId?: string | undefined;
362
647
  comment?: string | undefined;
363
648
  }, {
364
649
  type: "thumbs_up" | "thumbs_down" | "flag" | "rating";
365
650
  value?: string | undefined;
366
- traceRef?: string | undefined;
651
+ sessionId?: string | undefined;
652
+ traceId?: string | undefined;
367
653
  comment?: string | undefined;
368
654
  }>;
369
- /**
370
- * Config schema
371
- */
655
+ /** Batch configuration schema for high-throughput ingestion */
656
+ declare const BatchConfigSchema: z.ZodObject<{
657
+ maxSize: z.ZodOptional<z.ZodNumber>;
658
+ maxBytes: z.ZodOptional<z.ZodNumber>;
659
+ flushIntervalMs: z.ZodOptional<z.ZodNumber>;
660
+ }, "strip", z.ZodTypeAny, {
661
+ maxSize?: number | undefined;
662
+ maxBytes?: number | undefined;
663
+ flushIntervalMs?: number | undefined;
664
+ }, {
665
+ maxSize?: number | undefined;
666
+ maxBytes?: number | undefined;
667
+ flushIntervalMs?: number | undefined;
668
+ }>;
372
669
  declare const TeckelConfigSchema: z.ZodObject<{
373
670
  apiKey: z.ZodString;
374
671
  endpoint: z.ZodOptional<z.ZodString>;
375
672
  debug: z.ZodOptional<z.ZodBoolean>;
376
673
  timeoutMs: z.ZodOptional<z.ZodNumber>;
674
+ batch: z.ZodOptional<z.ZodObject<{
675
+ maxSize: z.ZodOptional<z.ZodNumber>;
676
+ maxBytes: z.ZodOptional<z.ZodNumber>;
677
+ flushIntervalMs: z.ZodOptional<z.ZodNumber>;
678
+ }, "strip", z.ZodTypeAny, {
679
+ maxSize?: number | undefined;
680
+ maxBytes?: number | undefined;
681
+ flushIntervalMs?: number | undefined;
682
+ }, {
683
+ maxSize?: number | undefined;
684
+ maxBytes?: number | undefined;
685
+ flushIntervalMs?: number | undefined;
686
+ }>>;
377
687
  }, "strip", z.ZodTypeAny, {
378
688
  apiKey: string;
379
689
  endpoint?: string | undefined;
380
690
  debug?: boolean | undefined;
381
691
  timeoutMs?: number | undefined;
692
+ batch?: {
693
+ maxSize?: number | undefined;
694
+ maxBytes?: number | undefined;
695
+ flushIntervalMs?: number | undefined;
696
+ } | undefined;
382
697
  }, {
383
698
  apiKey: string;
384
699
  endpoint?: string | undefined;
385
700
  debug?: boolean | undefined;
386
701
  timeoutMs?: number | undefined;
702
+ batch?: {
703
+ maxSize?: number | undefined;
704
+ maxBytes?: number | undefined;
705
+ flushIntervalMs?: number | undefined;
706
+ } | undefined;
387
707
  }>;
388
708
 
389
- export { Conversation, type ConversationOptions, ConversationOptionsSchema, type Document, DocumentSchema, type FeedbackData, FeedbackDataSchema, type FeedbackType, type TeckelConfig, TeckelConfigSchema, TeckelTracer, type TokenUsage, TokenUsageSchema, type TraceData, TraceDataSchema, type TraceResult };
709
+ export { BatchConfigSchema, DocumentSchema, FeedbackData, FeedbackDataSchema, SPAN_SIZE_LIMITS, SpanDataSchema, SpanStatusSchema, SpanTypeSchema, TRACE_SIZE_LIMITS, TeckelConfig, TeckelConfigSchema, TeckelTracer, TokenUsageSchema, TraceData, TraceDataSchema };