@kognitivedev/voice-tracing 0.2.29

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,2 @@
1
+
2
+ $ tsc
@@ -0,0 +1,288 @@
1
+ $ vitest run
2
+
3
+ RUN v3.2.4 /Users/vserifsaglam/work/memory-experiment/packages/voice-tracing
4
+
5
+ stdout | src/__tests__/voice-tracing.test.ts > @kognitivedev/voice-tracing reporter > bootstraps the session run before starting traces and carries backend ids forward
6
+ [VoiceTracing:reporter] initialized {
7
+ sessionId: 'rtc_bootstrap_1',
8
+ agentName: 'voice-demo',
9
+ modelId: 'gpt-realtime-1.5',
10
+ transcriptionModelId: 'gpt-4o-transcribe'
11
+ }
12
+
13
+ stdout | src/__tests__/voice-tracing.test.ts > @kognitivedev/voice-tracing reporter > bootstraps the session run before starting traces and carries backend ids forward
14
+ [VoiceTracing:reporter] session state updated {
15
+ sessionId: 'rtc_bootstrap_1',
16
+ messageCount: 1,
17
+ toolInvocationCount: 0,
18
+ connectionStatus: 'connected',
19
+ agentState: 'listening',
20
+ speechState: 'idle',
21
+ transcriptionStatus: 'completed',
22
+ hasActiveTurn: false
23
+ }
24
+ [VoiceTracing:reporter] turn recovered from state {
25
+ sessionId: 'rtc_bootstrap_1',
26
+ messageId: 'user-msg-1',
27
+ transcriptPreview: 'hello'
28
+ }
29
+ [VoiceTracing:reporter] turn started {
30
+ sessionId: 'rtc_bootstrap_1',
31
+ runId: 'session:voice-demo:rtc_bootstrap_1',
32
+ turnId: '5ef9303b-b12c-495b-bf68-9092008e95cd',
33
+ traceId: 'agent:voice-demo:5ef9303b-b12c-495b-bf68-9092008e95cd',
34
+ turnIndex: 0,
35
+ transcriptPreview: 'hello',
36
+ startMessageId: 'user-msg-1',
37
+ hasUsage: false,
38
+ transcriptionCostCentsOverride: null
39
+ }
40
+
41
+ stdout | src/__tests__/voice-tracing.test.ts > @kognitivedev/voice-tracing reporter > normalizes voice messages for persistence and avoids placeholder trace logs
42
+ [VoiceTracing:reporter] initialized {
43
+ sessionId: 'rtc_test_1',
44
+ agentName: 'voice-demo',
45
+ modelId: 'gpt-realtime-1.5',
46
+ transcriptionModelId: 'gpt-4o-transcribe'
47
+ }
48
+
49
+ stdout | src/__tests__/voice-tracing.test.ts > @kognitivedev/voice-tracing reporter > normalizes voice messages for persistence and avoids placeholder trace logs
50
+ [VoiceTracing:reporter] session state updated {
51
+ sessionId: 'rtc_test_1',
52
+ messageCount: 2,
53
+ toolInvocationCount: 0,
54
+ connectionStatus: 'connected',
55
+ agentState: 'listening',
56
+ speechState: 'idle',
57
+ transcriptionStatus: 'completed',
58
+ hasActiveTurn: false
59
+ }
60
+ [VoiceTracing:reporter] turn recovered from state {
61
+ sessionId: 'rtc_test_1',
62
+ messageId: 'user-msg-1',
63
+ transcriptPreview: 'What is the weather in Paris?'
64
+ }
65
+ [VoiceTracing:reporter] turn started {
66
+ sessionId: 'rtc_test_1',
67
+ runId: 'session:voice-demo:rtc_test_1',
68
+ turnId: '7b3f137b-36ff-406f-9d60-a436fc8e1f8c',
69
+ traceId: 'agent:voice-demo:7b3f137b-36ff-406f-9d60-a436fc8e1f8c',
70
+ turnIndex: 0,
71
+ transcriptPreview: 'What is the weather in Paris?',
72
+ startMessageId: 'user-msg-1',
73
+ hasUsage: false,
74
+ transcriptionCostCentsOverride: null
75
+ }
76
+
77
+ stdout | src/__tests__/voice-tracing.test.ts > @kognitivedev/voice-tracing reporter > normalizes voice messages for persistence and avoids placeholder trace logs
78
+ [VoiceTracing:reporter] telemetry received {
79
+ sessionId: 'rtc_test_1',
80
+ type: 'voice.response.done',
81
+ responseId: 'resp_1',
82
+ itemId: null,
83
+ toolCallId: null,
84
+ hasActiveTurn: true
85
+ }
86
+ [VoiceTracing:reporter] no active turn found from state {
87
+ sessionId: 'rtc_test_1',
88
+ latestMessageCount: 2,
89
+ seenUserMessageCount: 1
90
+ }
91
+
92
+ stdout | src/__tests__/voice-tracing.test.ts > @kognitivedev/voice-tracing reporter > normalizes voice messages for persistence and avoids placeholder trace logs
93
+ [VoiceTracing:reporter] response done rawEvent check {
94
+ sessionId: 'rtc_test_1',
95
+ traceId: 'agent:voice-demo:7b3f137b-36ff-406f-9d60-a436fc8e1f8c',
96
+ hasRawResponse: false,
97
+ rawOutputCount: 0,
98
+ functionCallCount: 0,
99
+ pendingCount: 0
100
+ }
101
+ [VoiceTracing:reporter] response completed {
102
+ sessionId: 'rtc_test_1',
103
+ traceId: 'agent:voice-demo:7b3f137b-36ff-406f-9d60-a436fc8e1f8c',
104
+ runId: 'session:voice-demo:rtc_test_1',
105
+ status: 'completed',
106
+ outputPreview: 'It is 22 degrees.'
107
+ }
108
+ [VoiceTracing:reporter] turn finalized {
109
+ sessionId: 'rtc_test_1',
110
+ traceId: 'agent:voice-demo:7b3f137b-36ff-406f-9d60-a436fc8e1f8c',
111
+ runId: 'session:voice-demo:rtc_test_1',
112
+ status: 'completed',
113
+ nextUserMessageId: null,
114
+ messageCount: 2,
115
+ outputPreview: 'It is 22 degrees.'
116
+ }
117
+
118
+ stdout | src/__tests__/voice-tracing.test.ts > @kognitivedev/voice-tracing reporter > normalizes voice messages for persistence and avoids placeholder trace logs
119
+ [VoiceTracing:reporter] conversation flushed {
120
+ sessionId: 'rtc_test_1',
121
+ traceId: 'agent:voice-demo:7b3f137b-36ff-406f-9d60-a436fc8e1f8c',
122
+ agentRunId: 'session:voice-demo:rtc_test_1',
123
+ messageCount: 2,
124
+ replaySkipped: false
125
+ }
126
+
127
+ stdout | src/__tests__/voice-tracing.test.ts > @kognitivedev/voice-tracing reporter > recovers completed turns from conversation history on disconnect
128
+ [VoiceTracing:reporter] initialized {
129
+ sessionId: 'rtc_test_fallback',
130
+ agentName: 'voice-demo',
131
+ modelId: 'gpt-realtime-1.5',
132
+ transcriptionModelId: 'gpt-4o-transcribe'
133
+ }
134
+
135
+ stdout | src/__tests__/voice-tracing.test.ts > @kognitivedev/voice-tracing reporter > recovers completed turns from conversation history on disconnect
136
+ [VoiceTracing:reporter] session state updated {
137
+ sessionId: 'rtc_test_fallback',
138
+ messageCount: 2,
139
+ toolInvocationCount: 0,
140
+ connectionStatus: 'connected',
141
+ agentState: 'listening',
142
+ speechState: 'idle',
143
+ transcriptionStatus: 'completed',
144
+ hasActiveTurn: false
145
+ }
146
+ [VoiceTracing:reporter] no active turn found from state {
147
+ sessionId: 'rtc_test_fallback',
148
+ latestMessageCount: 2,
149
+ seenUserMessageCount: 0
150
+ }
151
+
152
+ stdout | src/__tests__/voice-tracing.test.ts > @kognitivedev/voice-tracing reporter > recovers completed turns from conversation history on disconnect
153
+ [VoiceTracing:reporter] flush call end {
154
+ sessionId: 'rtc_test_fallback',
155
+ reason: 'disconnect',
156
+ hasActiveTurn: false
157
+ }
158
+ [VoiceTracing:reporter] synthetic turns recovered {
159
+ sessionId: 'rtc_test_fallback',
160
+ reason: 'disconnect',
161
+ turnCount: 1,
162
+ messageCount: 2,
163
+ responseStatus: null
164
+ }
165
+
166
+ stdout | src/__tests__/voice-tracing.test.ts > @kognitivedev/voice-tracing reporter > recovers completed turns from conversation history on disconnect
167
+ [VoiceTracing:reporter] conversation flushed {
168
+ sessionId: 'rtc_test_fallback',
169
+ traceId: 'agent:voice-demo:voice-session-flush',
170
+ agentRunId: 'session:voice-demo:rtc_test_fallback',
171
+ messageCount: 2,
172
+ replaySkipped: false
173
+ }
174
+
175
+ stdout | src/__tests__/voice-tracing.test.ts > @kognitivedev/voice-tracing reporter > does not replay the full transcript again on disconnect flush when nothing changed
176
+ [VoiceTracing:reporter] initialized {
177
+ sessionId: 'rtc_test_flush_dedupe',
178
+ agentName: 'voice-demo',
179
+ modelId: 'gpt-realtime-1.5',
180
+ transcriptionModelId: 'gpt-4o-transcribe'
181
+ }
182
+
183
+ stdout | src/__tests__/voice-tracing.test.ts > @kognitivedev/voice-tracing reporter > does not replay the full transcript again on disconnect flush when nothing changed
184
+ [VoiceTracing:reporter] session state updated {
185
+ sessionId: 'rtc_test_flush_dedupe',
186
+ messageCount: 2,
187
+ toolInvocationCount: 0,
188
+ connectionStatus: 'connected',
189
+ agentState: 'listening',
190
+ speechState: 'idle',
191
+ transcriptionStatus: 'completed',
192
+ hasActiveTurn: false
193
+ }
194
+ [VoiceTracing:reporter] turn recovered from state {
195
+ sessionId: 'rtc_test_flush_dedupe',
196
+ messageId: 'user-msg-1',
197
+ transcriptPreview: 'hello'
198
+ }
199
+ [VoiceTracing:reporter] turn started {
200
+ sessionId: 'rtc_test_flush_dedupe',
201
+ runId: 'session:voice-demo:rtc_test_flush_dedupe',
202
+ turnId: 'ba4ad99f-3dfc-4521-9d1c-829bead7998b',
203
+ traceId: 'agent:voice-demo:ba4ad99f-3dfc-4521-9d1c-829bead7998b',
204
+ turnIndex: 0,
205
+ transcriptPreview: 'hello',
206
+ startMessageId: 'user-msg-1',
207
+ hasUsage: false,
208
+ transcriptionCostCentsOverride: null
209
+ }
210
+
211
+ stdout | src/__tests__/voice-tracing.test.ts > @kognitivedev/voice-tracing reporter > does not replay the full transcript again on disconnect flush when nothing changed
212
+ [VoiceTracing:reporter] telemetry received {
213
+ sessionId: 'rtc_test_flush_dedupe',
214
+ type: 'voice.response.done',
215
+ responseId: 'resp_1',
216
+ itemId: null,
217
+ toolCallId: null,
218
+ hasActiveTurn: true
219
+ }
220
+ [VoiceTracing:reporter] no active turn found from state {
221
+ sessionId: 'rtc_test_flush_dedupe',
222
+ latestMessageCount: 2,
223
+ seenUserMessageCount: 1
224
+ }
225
+
226
+ stdout | src/__tests__/voice-tracing.test.ts > @kognitivedev/voice-tracing reporter > does not replay the full transcript again on disconnect flush when nothing changed
227
+ [VoiceTracing:reporter] response done rawEvent check {
228
+ sessionId: 'rtc_test_flush_dedupe',
229
+ traceId: 'agent:voice-demo:ba4ad99f-3dfc-4521-9d1c-829bead7998b',
230
+ hasRawResponse: false,
231
+ rawOutputCount: 0,
232
+ functionCallCount: 0,
233
+ pendingCount: 0
234
+ }
235
+ [VoiceTracing:reporter] response completed {
236
+ sessionId: 'rtc_test_flush_dedupe',
237
+ traceId: 'agent:voice-demo:ba4ad99f-3dfc-4521-9d1c-829bead7998b',
238
+ runId: 'session:voice-demo:rtc_test_flush_dedupe',
239
+ status: 'completed',
240
+ outputPreview: 'hi there'
241
+ }
242
+ [VoiceTracing:reporter] turn finalized {
243
+ sessionId: 'rtc_test_flush_dedupe',
244
+ traceId: 'agent:voice-demo:ba4ad99f-3dfc-4521-9d1c-829bead7998b',
245
+ runId: 'session:voice-demo:rtc_test_flush_dedupe',
246
+ status: 'completed',
247
+ nextUserMessageId: null,
248
+ messageCount: 2,
249
+ outputPreview: 'hi there'
250
+ }
251
+
252
+ stdout | src/__tests__/voice-tracing.test.ts > @kognitivedev/voice-tracing reporter > does not replay the full transcript again on disconnect flush when nothing changed
253
+ [VoiceTracing:reporter] conversation flushed {
254
+ sessionId: 'rtc_test_flush_dedupe',
255
+ traceId: 'agent:voice-demo:ba4ad99f-3dfc-4521-9d1c-829bead7998b',
256
+ agentRunId: 'session:voice-demo:rtc_test_flush_dedupe',
257
+ messageCount: 2,
258
+ replaySkipped: false
259
+ }
260
+
261
+ stdout | src/__tests__/voice-tracing.test.ts > @kognitivedev/voice-tracing reporter > does not replay the full transcript again on disconnect flush when nothing changed
262
+ [VoiceTracing:reporter] flush call end {
263
+ sessionId: 'rtc_test_flush_dedupe',
264
+ reason: 'disconnect',
265
+ hasActiveTurn: false
266
+ }
267
+ [VoiceTracing:reporter] synthetic turn recovery skipped {
268
+ sessionId: 'rtc_test_flush_dedupe',
269
+ reason: 'disconnect',
270
+ hasReportedRuns: true
271
+ }
272
+
273
+ stdout | src/__tests__/voice-tracing.test.ts > @kognitivedev/voice-tracing reporter > does not replay the full transcript again on disconnect flush when nothing changed
274
+ [VoiceTracing:reporter] conversation flushed {
275
+ sessionId: 'rtc_test_flush_dedupe',
276
+ traceId: 'agent:voice-demo:voice-session-flush',
277
+ agentRunId: 'session:voice-demo:rtc_test_flush_dedupe',
278
+ messageCount: 0,
279
+ replaySkipped: true
280
+ }
281
+
282
+ ✓ src/__tests__/voice-tracing.test.ts (6 tests) 74ms
283
+
284
+ Test Files 1 passed (1)
285
+ Tests 6 passed (6)
286
+ Start at 12:40:06
287
+ Duration 4.42s (transform 467ms, setup 0ms, collect 681ms, tests 74ms, environment 0ms, prepare 672ms)
288
+
package/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # @kognitivedev/voice-tracing
2
+
3
+ ## 0.2.29
4
+
5
+ ### Patch Changes
6
+
7
+ - release
8
+
9
+ - Updated dependencies []:
10
+ - @kognitivedev/shared@0.2.29
@@ -0,0 +1,16 @@
1
+ import type { VoiceTracingAdapter } from "./types";
2
+ type Logger = Pick<Console, "log" | "error" | "warn">;
3
+ export interface KognitiveBackendVoiceTracingAdapterConfig {
4
+ baseUrl: string;
5
+ apiKey?: string;
6
+ getBearerToken?: () => Promise<string | null | undefined> | string | null | undefined;
7
+ fetch?: typeof globalThis.fetch;
8
+ logger?: Logger;
9
+ endpoints?: {
10
+ agentRun?: string;
11
+ log?: string;
12
+ traceEvents?: string;
13
+ };
14
+ }
15
+ export declare function createKognitiveBackendVoiceTracingAdapter(config: KognitiveBackendVoiceTracingAdapterConfig): VoiceTracingAdapter;
16
+ export {};
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createKognitiveBackendVoiceTracingAdapter = createKognitiveBackendVoiceTracingAdapter;
4
+ function trimTrailingSlash(value) {
5
+ return value.endsWith("/") ? value.slice(0, -1) : value;
6
+ }
7
+ function createKognitiveBackendVoiceTracingAdapter(config) {
8
+ var _a, _b, _c, _d, _e, _f, _g;
9
+ const fetchImpl = (_a = config.fetch) !== null && _a !== void 0 ? _a : globalThis.fetch;
10
+ const logger = config.logger;
11
+ const baseUrl = trimTrailingSlash(config.baseUrl);
12
+ const endpoints = {
13
+ agentRun: (_c = (_b = config.endpoints) === null || _b === void 0 ? void 0 : _b.agentRun) !== null && _c !== void 0 ? _c : "/api/kognitive/cognitive/agent-run",
14
+ log: (_e = (_d = config.endpoints) === null || _d === void 0 ? void 0 : _d.log) !== null && _e !== void 0 ? _e : "/api/kognitive/cognitive/log",
15
+ traceEvents: (_g = (_f = config.endpoints) === null || _f === void 0 ? void 0 : _f.traceEvents) !== null && _g !== void 0 ? _g : "/api/kognitive/cognitive/trace-events",
16
+ };
17
+ const post = async (endpoint, payload) => {
18
+ var _a, _b, _c;
19
+ try {
20
+ const bearerToken = await ((_a = config.getBearerToken) === null || _a === void 0 ? void 0 : _a.call(config));
21
+ const response = await fetchImpl(`${baseUrl}${endpoint}`, {
22
+ method: "POST",
23
+ headers: Object.assign({ "Content-Type": "application/json" }, (bearerToken || config.apiKey
24
+ ? { Authorization: `Bearer ${bearerToken !== null && bearerToken !== void 0 ? bearerToken : config.apiKey}` }
25
+ : {})),
26
+ body: JSON.stringify(payload),
27
+ });
28
+ if (!response.ok) {
29
+ const errorText = await response.text().catch(() => "");
30
+ (_b = logger === null || logger === void 0 ? void 0 : logger.warn) === null || _b === void 0 ? void 0 : _b.call(logger, "[VoiceTracing:backend-adapter] request failed", {
31
+ endpoint,
32
+ status: response.status,
33
+ body: errorText.slice(0, 400),
34
+ });
35
+ return null;
36
+ }
37
+ return await response.json().catch(() => null);
38
+ }
39
+ catch (error) {
40
+ (_c = logger === null || logger === void 0 ? void 0 : logger.error) === null || _c === void 0 ? void 0 : _c.call(logger, "[VoiceTracing:backend-adapter] request error", {
41
+ endpoint,
42
+ error: error instanceof Error ? error.message : String(error),
43
+ });
44
+ return null;
45
+ }
46
+ };
47
+ return {
48
+ async reportAgentRun(data) {
49
+ return await post(endpoints.agentRun, data);
50
+ },
51
+ async reportConversationLog(data) {
52
+ return await post(endpoints.log, Object.assign({ type: "voice" }, data));
53
+ },
54
+ async reportTraceEvents(data) {
55
+ return await post(endpoints.traceEvents, data);
56
+ },
57
+ };
58
+ }
@@ -0,0 +1,4 @@
1
+ export type { VoiceTracingAdapter, VoiceTracingReporterConfig, VoiceTracingSessionEvent, VoiceTracingTelemetryEvent, VoiceTracingUsageSnapshot, PersistedConversationMessage, } from "./types";
2
+ export { createVoiceTracingReporter, createVoiceTelemetryReporter } from "./reporter";
3
+ export { createKognitiveBackendVoiceTracingAdapter } from "./backend-adapter";
4
+ export { createKognitiveVoiceTracingAdapter } from "./kognitive-adapter";
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createKognitiveVoiceTracingAdapter = exports.createKognitiveBackendVoiceTracingAdapter = exports.createVoiceTelemetryReporter = exports.createVoiceTracingReporter = void 0;
4
+ var reporter_1 = require("./reporter");
5
+ Object.defineProperty(exports, "createVoiceTracingReporter", { enumerable: true, get: function () { return reporter_1.createVoiceTracingReporter; } });
6
+ Object.defineProperty(exports, "createVoiceTelemetryReporter", { enumerable: true, get: function () { return reporter_1.createVoiceTelemetryReporter; } });
7
+ var backend_adapter_1 = require("./backend-adapter");
8
+ Object.defineProperty(exports, "createKognitiveBackendVoiceTracingAdapter", { enumerable: true, get: function () { return backend_adapter_1.createKognitiveBackendVoiceTracingAdapter; } });
9
+ var kognitive_adapter_1 = require("./kognitive-adapter");
10
+ Object.defineProperty(exports, "createKognitiveVoiceTracingAdapter", { enumerable: true, get: function () { return kognitive_adapter_1.createKognitiveVoiceTracingAdapter; } });
@@ -0,0 +1,8 @@
1
+ import type { VoiceTracingAdapter } from "./types";
2
+ type KognitiveLike = {
3
+ reportAgentRun(data: Record<string, unknown>): Promise<unknown> | unknown;
4
+ reportConversationLog(data: Record<string, unknown>): Promise<unknown> | unknown;
5
+ reportTraceEvents(data: Record<string, unknown>): Promise<unknown> | unknown;
6
+ };
7
+ export declare function createKognitiveVoiceTracingAdapter(kognitive: KognitiveLike): VoiceTracingAdapter;
8
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createKognitiveVoiceTracingAdapter = createKognitiveVoiceTracingAdapter;
4
+ function createKognitiveVoiceTracingAdapter(kognitive) {
5
+ return {
6
+ async reportAgentRun(data) {
7
+ return await kognitive.reportAgentRun(data);
8
+ },
9
+ async reportConversationLog(data) {
10
+ return await kognitive.reportConversationLog(data);
11
+ },
12
+ async reportTraceEvents(data) {
13
+ const result = await kognitive.reportTraceEvents(data);
14
+ return (result !== null && result !== void 0 ? result : null);
15
+ },
16
+ };
17
+ }
@@ -0,0 +1,12 @@
1
+ import type { VoiceTracingAdapter, VoiceTracingReporterConfig, VoiceTracingSessionEvent, VoiceTracingTelemetryEvent, VoiceTracingUsageSnapshot } from "./types";
2
+ export declare function createVoiceTracingReporter(config: VoiceTracingReporterConfig): {
3
+ handleSessionEvent(event: VoiceTracingSessionEvent): void;
4
+ handleTelemetry(event: VoiceTracingTelemetryEvent): Promise<void>;
5
+ flushCallEnd(reason?: string): void;
6
+ };
7
+ export declare const createVoiceTelemetryReporter: typeof createVoiceTracingReporter;
8
+ export type VoiceReportingSink = VoiceTracingAdapter;
9
+ export type VoiceTelemetryReporterConfig = VoiceTracingReporterConfig;
10
+ export type VoiceSessionEvent = VoiceTracingSessionEvent;
11
+ export type VoiceTelemetryEvent = VoiceTracingTelemetryEvent;
12
+ export type VoiceUsageSnapshot = VoiceTracingUsageSnapshot;