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.
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Type definitions for teckel-ai SDK
3
+ */
4
+ /**
5
+ * Configuration for batch trace ingestion
6
+ * Batching dramatically improves throughput (100x for high-volume scenarios)
7
+ */
8
+ interface BatchConfig {
9
+ /** Maximum traces per batch (default: 100) */
10
+ maxSize?: number;
11
+ /** Maximum batch size in bytes (default: 5MB) */
12
+ maxBytes?: number;
13
+ /** Auto-flush interval in ms (default: 100ms) */
14
+ flushIntervalMs?: number;
15
+ }
16
+ interface TeckelConfig {
17
+ /** Teckel API key (tk_live_...) */
18
+ apiKey: string;
19
+ /** API endpoint (default: https://app.teckel.ai/api) */
20
+ endpoint?: string;
21
+ /** Enable debug logging */
22
+ debug?: boolean;
23
+ /** Network timeout in ms (default: 5000) */
24
+ timeoutMs?: number;
25
+ /** Batch configuration for high-throughput ingestion */
26
+ batch?: BatchConfig;
27
+ }
28
+ /**
29
+ * Document/chunk from your RAG pipeline.
30
+ * The `id` field is your stable identifier - server generates internal UUIDs via deterministic hashing.
31
+ */
32
+ interface Document {
33
+ /** Your document identifier (any format: "overview.md", "doc-123", etc.) */
34
+ id: string;
35
+ /** Human-readable document name */
36
+ name: string;
37
+ /** The actual text/chunk content */
38
+ text: string;
39
+ /** ISO 8601 timestamp - enables version tracking */
40
+ lastUpdated?: string;
41
+ /** Link to source (URL, intranet, file://) */
42
+ url?: string;
43
+ /** Storage platform: confluence, slack, gdrive, etc. */
44
+ source?: string;
45
+ /** File format: pdf, docx, md, etc. */
46
+ fileFormat?: string;
47
+ /** Vector similarity score (0-1) */
48
+ similarity?: number;
49
+ /** Position in results */
50
+ rank?: number;
51
+ /** Document owner email */
52
+ ownerEmail?: string;
53
+ }
54
+ interface TokenUsage {
55
+ prompt: number;
56
+ completion: number;
57
+ total: number;
58
+ }
59
+ /**
60
+ * Span type for tracing operations.
61
+ * Simplified to 6 meaningful operation types:
62
+ * - llm_call: LLM inference
63
+ * - tool_call: Tool/function execution
64
+ * - retrieval: RAG/knowledge retrieval
65
+ * - agent: Container for nested agent work
66
+ * - guardrail: Safety/validation checks
67
+ * - custom: Catch-all (default if not specified)
68
+ */
69
+ type SpanType = 'llm_call' | 'tool_call' | 'retrieval' | 'agent' | 'guardrail' | 'custom';
70
+ type SpanStatus = 'running' | 'completed' | 'error';
71
+ /**
72
+ * Span data for tracing tool calls, LLM calls, and other operations.
73
+ * Enables waterfall visualization and detailed observability.
74
+ */
75
+ interface SpanData {
76
+ /** Client-provided span ID (UUID, auto-generated if omitted) */
77
+ spanId?: string;
78
+ /** Parent span ID for nesting (references another span's spanId) */
79
+ parentSpanId?: string | null;
80
+ /** Span name (e.g., tool name, step description) */
81
+ name: string;
82
+ /** Type of span (optional, defaults to 'custom') */
83
+ type?: SpanType;
84
+ /** ISO 8601 start timestamp */
85
+ startedAt: string;
86
+ /** ISO 8601 end timestamp */
87
+ endedAt?: string | null;
88
+ /** Duration in milliseconds (auto-calculated if startedAt/endedAt provided) */
89
+ durationMs?: number;
90
+ /** Span status */
91
+ status?: SpanStatus;
92
+ /** Error message if status is 'error' */
93
+ statusMessage?: string | null;
94
+ /** Tool name (required for tool_call type) */
95
+ toolName?: string | null;
96
+ /** Tool arguments (max 500KB) */
97
+ toolArguments?: Record<string, unknown> | null;
98
+ /** Tool result (max 500KB) */
99
+ toolResult?: Record<string, unknown> | null;
100
+ /** Model name for llm_call type */
101
+ model?: string | null;
102
+ /** Prompt tokens for llm_call type */
103
+ promptTokens?: number | null;
104
+ /** Completion tokens for llm_call type */
105
+ completionTokens?: number | null;
106
+ /** Cost in USD for this span (optional: provide your own cost or let us calculate) */
107
+ costUsd?: number | null;
108
+ /** Generic input (max 500KB) */
109
+ input?: Record<string, unknown> | null;
110
+ /** Generic output (max 500KB) */
111
+ output?: Record<string, unknown> | null;
112
+ /** Custom metadata */
113
+ metadata?: Record<string, unknown> | null;
114
+ }
115
+ /**
116
+ * Trace data for a single query-response interaction.
117
+ * Sessions are created implicitly when traces share the same sessionId.
118
+ */
119
+ interface TraceData {
120
+ /** User's question/prompt */
121
+ query: string;
122
+ /** LLM's response */
123
+ response: string;
124
+ /** Agent/function/workflow identifier (max 200 chars) */
125
+ agentName?: string | null;
126
+ /** Model name (e.g., 'gpt-5-mini') */
127
+ model?: string;
128
+ /** Response time in milliseconds */
129
+ latencyMs?: number;
130
+ /** Token usage */
131
+ tokens?: TokenUsage;
132
+ /** Cost in USD for this trace (optional: provide your own cost or let us calculate) */
133
+ costUsd?: number;
134
+ /** Source documents used in RAG */
135
+ documents?: Document[];
136
+ /** Spans for detailed tracing (tool calls, LLM calls, etc.) */
137
+ spans?: SpanData[];
138
+ /** Groups traces into a session (any string up to 200 chars, OTEL compatible) */
139
+ sessionId?: string;
140
+ /** User identifier */
141
+ userId?: string;
142
+ /** Client-provided trace ID (UUID, auto-generated if omitted) */
143
+ traceId?: string;
144
+ /** LLM system prompt/instructions */
145
+ systemPrompt?: string;
146
+ /** Custom metadata (max 10KB) */
147
+ metadata?: Record<string, unknown>;
148
+ }
149
+ type FeedbackType = 'thumbs_up' | 'thumbs_down' | 'flag' | 'rating';
150
+ /**
151
+ * User feedback signal. Target either a specific trace or an entire session.
152
+ */
153
+ interface FeedbackData {
154
+ /** Target trace (UUID) */
155
+ traceId?: string;
156
+ /** Target session (any string up to 200 chars) */
157
+ sessionId?: string;
158
+ /** Feedback type */
159
+ type: FeedbackType;
160
+ /** For ratings: '1'-'5' */
161
+ value?: string;
162
+ /** Optional comment */
163
+ comment?: string;
164
+ }
165
+ interface TraceResult {
166
+ traceId: string;
167
+ sessionId?: string;
168
+ chunkCount: number;
169
+ }
170
+ interface FeedbackResult {
171
+ feedbackId: string;
172
+ type: FeedbackType;
173
+ traceId?: string;
174
+ sessionId?: string;
175
+ }
176
+
177
+ export type { BatchConfig as B, Document as D, FeedbackData as F, SpanData as S, TeckelConfig as T, TraceData as a, TokenUsage as b, SpanType as c, SpanStatus as d, FeedbackType as e, TraceResult as f, FeedbackResult as g };
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Type definitions for teckel-ai SDK
3
+ */
4
+ /**
5
+ * Configuration for batch trace ingestion
6
+ * Batching dramatically improves throughput (100x for high-volume scenarios)
7
+ */
8
+ interface BatchConfig {
9
+ /** Maximum traces per batch (default: 100) */
10
+ maxSize?: number;
11
+ /** Maximum batch size in bytes (default: 5MB) */
12
+ maxBytes?: number;
13
+ /** Auto-flush interval in ms (default: 100ms) */
14
+ flushIntervalMs?: number;
15
+ }
16
+ interface TeckelConfig {
17
+ /** Teckel API key (tk_live_...) */
18
+ apiKey: string;
19
+ /** API endpoint (default: https://app.teckel.ai/api) */
20
+ endpoint?: string;
21
+ /** Enable debug logging */
22
+ debug?: boolean;
23
+ /** Network timeout in ms (default: 5000) */
24
+ timeoutMs?: number;
25
+ /** Batch configuration for high-throughput ingestion */
26
+ batch?: BatchConfig;
27
+ }
28
+ /**
29
+ * Document/chunk from your RAG pipeline.
30
+ * The `id` field is your stable identifier - server generates internal UUIDs via deterministic hashing.
31
+ */
32
+ interface Document {
33
+ /** Your document identifier (any format: "overview.md", "doc-123", etc.) */
34
+ id: string;
35
+ /** Human-readable document name */
36
+ name: string;
37
+ /** The actual text/chunk content */
38
+ text: string;
39
+ /** ISO 8601 timestamp - enables version tracking */
40
+ lastUpdated?: string;
41
+ /** Link to source (URL, intranet, file://) */
42
+ url?: string;
43
+ /** Storage platform: confluence, slack, gdrive, etc. */
44
+ source?: string;
45
+ /** File format: pdf, docx, md, etc. */
46
+ fileFormat?: string;
47
+ /** Vector similarity score (0-1) */
48
+ similarity?: number;
49
+ /** Position in results */
50
+ rank?: number;
51
+ /** Document owner email */
52
+ ownerEmail?: string;
53
+ }
54
+ interface TokenUsage {
55
+ prompt: number;
56
+ completion: number;
57
+ total: number;
58
+ }
59
+ /**
60
+ * Span type for tracing operations.
61
+ * Simplified to 6 meaningful operation types:
62
+ * - llm_call: LLM inference
63
+ * - tool_call: Tool/function execution
64
+ * - retrieval: RAG/knowledge retrieval
65
+ * - agent: Container for nested agent work
66
+ * - guardrail: Safety/validation checks
67
+ * - custom: Catch-all (default if not specified)
68
+ */
69
+ type SpanType = 'llm_call' | 'tool_call' | 'retrieval' | 'agent' | 'guardrail' | 'custom';
70
+ type SpanStatus = 'running' | 'completed' | 'error';
71
+ /**
72
+ * Span data for tracing tool calls, LLM calls, and other operations.
73
+ * Enables waterfall visualization and detailed observability.
74
+ */
75
+ interface SpanData {
76
+ /** Client-provided span ID (UUID, auto-generated if omitted) */
77
+ spanId?: string;
78
+ /** Parent span ID for nesting (references another span's spanId) */
79
+ parentSpanId?: string | null;
80
+ /** Span name (e.g., tool name, step description) */
81
+ name: string;
82
+ /** Type of span (optional, defaults to 'custom') */
83
+ type?: SpanType;
84
+ /** ISO 8601 start timestamp */
85
+ startedAt: string;
86
+ /** ISO 8601 end timestamp */
87
+ endedAt?: string | null;
88
+ /** Duration in milliseconds (auto-calculated if startedAt/endedAt provided) */
89
+ durationMs?: number;
90
+ /** Span status */
91
+ status?: SpanStatus;
92
+ /** Error message if status is 'error' */
93
+ statusMessage?: string | null;
94
+ /** Tool name (required for tool_call type) */
95
+ toolName?: string | null;
96
+ /** Tool arguments (max 500KB) */
97
+ toolArguments?: Record<string, unknown> | null;
98
+ /** Tool result (max 500KB) */
99
+ toolResult?: Record<string, unknown> | null;
100
+ /** Model name for llm_call type */
101
+ model?: string | null;
102
+ /** Prompt tokens for llm_call type */
103
+ promptTokens?: number | null;
104
+ /** Completion tokens for llm_call type */
105
+ completionTokens?: number | null;
106
+ /** Cost in USD for this span (optional: provide your own cost or let us calculate) */
107
+ costUsd?: number | null;
108
+ /** Generic input (max 500KB) */
109
+ input?: Record<string, unknown> | null;
110
+ /** Generic output (max 500KB) */
111
+ output?: Record<string, unknown> | null;
112
+ /** Custom metadata */
113
+ metadata?: Record<string, unknown> | null;
114
+ }
115
+ /**
116
+ * Trace data for a single query-response interaction.
117
+ * Sessions are created implicitly when traces share the same sessionId.
118
+ */
119
+ interface TraceData {
120
+ /** User's question/prompt */
121
+ query: string;
122
+ /** LLM's response */
123
+ response: string;
124
+ /** Agent/function/workflow identifier (max 200 chars) */
125
+ agentName?: string | null;
126
+ /** Model name (e.g., 'gpt-5-mini') */
127
+ model?: string;
128
+ /** Response time in milliseconds */
129
+ latencyMs?: number;
130
+ /** Token usage */
131
+ tokens?: TokenUsage;
132
+ /** Cost in USD for this trace (optional: provide your own cost or let us calculate) */
133
+ costUsd?: number;
134
+ /** Source documents used in RAG */
135
+ documents?: Document[];
136
+ /** Spans for detailed tracing (tool calls, LLM calls, etc.) */
137
+ spans?: SpanData[];
138
+ /** Groups traces into a session (any string up to 200 chars, OTEL compatible) */
139
+ sessionId?: string;
140
+ /** User identifier */
141
+ userId?: string;
142
+ /** Client-provided trace ID (UUID, auto-generated if omitted) */
143
+ traceId?: string;
144
+ /** LLM system prompt/instructions */
145
+ systemPrompt?: string;
146
+ /** Custom metadata (max 10KB) */
147
+ metadata?: Record<string, unknown>;
148
+ }
149
+ type FeedbackType = 'thumbs_up' | 'thumbs_down' | 'flag' | 'rating';
150
+ /**
151
+ * User feedback signal. Target either a specific trace or an entire session.
152
+ */
153
+ interface FeedbackData {
154
+ /** Target trace (UUID) */
155
+ traceId?: string;
156
+ /** Target session (any string up to 200 chars) */
157
+ sessionId?: string;
158
+ /** Feedback type */
159
+ type: FeedbackType;
160
+ /** For ratings: '1'-'5' */
161
+ value?: string;
162
+ /** Optional comment */
163
+ comment?: string;
164
+ }
165
+ interface TraceResult {
166
+ traceId: string;
167
+ sessionId?: string;
168
+ chunkCount: number;
169
+ }
170
+ interface FeedbackResult {
171
+ feedbackId: string;
172
+ type: FeedbackType;
173
+ traceId?: string;
174
+ sessionId?: string;
175
+ }
176
+
177
+ export type { BatchConfig as B, Document as D, FeedbackData as F, SpanData as S, TeckelConfig as T, TraceData as a, TokenUsage as b, SpanType as c, SpanStatus as d, FeedbackType as e, TraceResult as f, FeedbackResult as g };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "teckel-ai",
3
- "version": "0.3.6",
4
- "description": "Simple SDK for AI conversation tracking and RAG observability",
3
+ "version": "0.7.1",
4
+ "description": "Simple SDK for AI trace tracking and RAG observability",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
@@ -15,6 +15,16 @@
15
15
  "types": "./dist/index.d.ts",
16
16
  "default": "./dist/index.js"
17
17
  }
18
+ },
19
+ "./otel": {
20
+ "import": {
21
+ "types": "./dist/otel/index.d.mts",
22
+ "default": "./dist/otel/index.mjs"
23
+ },
24
+ "require": {
25
+ "types": "./dist/otel/index.d.ts",
26
+ "default": "./dist/otel/index.js"
27
+ }
18
28
  }
19
29
  },
20
30
  "files": [
@@ -25,7 +35,10 @@
25
35
  "build": "tsup",
26
36
  "clean": "rm -rf dist",
27
37
  "prepublishOnly": "npm run clean && npm run build",
28
- "type-check": "tsc --noEmit"
38
+ "type-check": "tsc --noEmit",
39
+ "test": "vitest run --exclude tests/integration.test.ts",
40
+ "test:watch": "vitest --exclude tests/integration.test.ts",
41
+ "test:integration": "vitest run tests/integration.test.ts"
29
42
  },
30
43
  "keywords": [
31
44
  "llm",
@@ -35,7 +48,9 @@
35
48
  "audit",
36
49
  "trace",
37
50
  "observability",
38
- "teckel"
51
+ "teckel",
52
+ "opentelemetry",
53
+ "otel"
39
54
  ],
40
55
  "author": "Teckel AI",
41
56
  "license": "MIT",
@@ -46,9 +61,24 @@
46
61
  "dependencies": {
47
62
  "zod": "^3.23.8"
48
63
  },
64
+ "peerDependencies": {
65
+ "@opentelemetry/api": "^1.9.0",
66
+ "@opentelemetry/sdk-trace-base": "^1.25.0 || ^2.0.0"
67
+ },
68
+ "peerDependenciesMeta": {
69
+ "@opentelemetry/api": {
70
+ "optional": true
71
+ },
72
+ "@opentelemetry/sdk-trace-base": {
73
+ "optional": true
74
+ }
75
+ },
49
76
  "devDependencies": {
50
- "tsup": "^8.3.5",
51
- "typescript": "^5.0.0"
77
+ "@opentelemetry/api": "^1.9.0",
78
+ "@opentelemetry/sdk-trace-base": "^2.5.0",
79
+ "tsup": "^8.5.1",
80
+ "typescript": "^5.0.0",
81
+ "vitest": "^2.1.0"
52
82
  },
53
83
  "homepage": "https://teckel.ai",
54
84
  "bugs": {