@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.
package/src/types.ts ADDED
@@ -0,0 +1,76 @@
1
+ import type { KognitiveUIMessage, Metadata, ResourceId } from "@kognitivedev/shared";
2
+
3
+ export interface VoiceTracingUsageSnapshot {
4
+ type: "tokens" | "seconds";
5
+ inputTokens?: number;
6
+ outputTokens?: number;
7
+ totalTokens?: number;
8
+ cachedInputTokens?: number;
9
+ inputAudioTokens?: number;
10
+ inputTextTokens?: number;
11
+ outputAudioTokens?: number;
12
+ outputTextTokens?: number;
13
+ cachedAudioTokens?: number;
14
+ cachedTextTokens?: number;
15
+ seconds?: number;
16
+ }
17
+
18
+ export type VoiceTracingTelemetryEvent =
19
+ | { type: "voice.call.started"; at: string; callId: string; modelId: string; voice: string }
20
+ | { type: "voice.call.ended"; at: string; callId?: string; reason?: string }
21
+ | { type: "voice.session.updated"; at: string; callId?: string; session: Record<string, unknown> }
22
+ | { type: "voice.response.created"; at: string; callId?: string; responseId: string }
23
+ | { type: "voice.response.output.completed"; at: string; callId?: string; responseId?: string; itemId?: string; outputText?: string; status?: string; rawEvent: Record<string, unknown> }
24
+ | { type: "voice.response.done"; at: string; callId?: string; responseId: string; status: string; outputText?: string; usage?: VoiceTracingUsageSnapshot; rawEvent: Record<string, unknown> }
25
+ | { type: "voice.user.transcribed"; at: string; callId?: string; itemId?: string; transcript: string; usage?: VoiceTracingUsageSnapshot; rawEvent: Record<string, unknown> }
26
+ | { type: "voice.assistant.started"; at: string; callId?: string; responseId?: string; rawEvent: Record<string, unknown> }
27
+ | { type: "voice.assistant.stopped"; at: string; callId?: string; responseId?: string; rawEvent: Record<string, unknown> }
28
+ | { type: "voice.tool.started"; at: string; callId?: string; responseId?: string; toolCallId: string; toolName: string; input?: unknown; rawEvent: Record<string, unknown> }
29
+ | { type: "voice.tool.completed"; at: string; callId?: string; responseId?: string; toolCallId: string; toolName: string; output?: unknown }
30
+ | { type: "voice.tool.failed"; at: string; callId?: string; responseId?: string; toolCallId: string; toolName: string; error: string }
31
+ | { type: "voice.interrupted"; at: string; callId?: string; responseId?: string; reason?: string; rawEvent?: Record<string, unknown> }
32
+ | { type: "voice.error"; at: string; callId?: string; error: string; rawEvent?: Record<string, unknown> }
33
+ | { type: "voice.raw"; at: string; callId?: string; rawEvent: Record<string, unknown> };
34
+
35
+ type VoiceTracingSessionStateShape = {
36
+ callId?: string;
37
+ messages: KognitiveUIMessage[];
38
+ toolInvocations: unknown[];
39
+ connectionStatus?: string;
40
+ agentState?: string;
41
+ speechState?: string;
42
+ transcriptionStatus?: string;
43
+ };
44
+
45
+ export type VoiceTracingSessionEvent =
46
+ | { type: "state.updated"; state: VoiceTracingSessionStateShape }
47
+ | { type: "tool-call"; toolCall: { toolName: string }; state: VoiceTracingSessionStateShape }
48
+ | { type: "tool-result"; toolResult: { toolName: string; isError?: boolean }; state: VoiceTracingSessionStateShape }
49
+ | { type: "raw"; event: Record<string, unknown>; state: VoiceTracingSessionStateShape }
50
+ | { type: "error"; error: unknown; state: VoiceTracingSessionStateShape };
51
+
52
+ export type PersistedConversationPart = Record<string, unknown>;
53
+
54
+ export type PersistedConversationMessage = {
55
+ role: "system" | "user" | "assistant" | "tool";
56
+ content: string | PersistedConversationPart[];
57
+ metadata?: Metadata;
58
+ };
59
+
60
+ export interface VoiceTracingAdapter {
61
+ reportAgentRun(data: Record<string, unknown>): Promise<unknown> | unknown;
62
+ reportConversationLog(data: Record<string, unknown>): Promise<unknown> | unknown;
63
+ reportTraceEvents(data: Record<string, unknown>): Promise<{ traceDbId?: string | null } | null>;
64
+ }
65
+
66
+ export interface VoiceTracingReporterConfig {
67
+ adapter: VoiceTracingAdapter;
68
+ agentName: string;
69
+ callId: string;
70
+ modelId: string;
71
+ transcriptionModelId?: string;
72
+ voice: string;
73
+ resourceId: ResourceId;
74
+ metadata?: Metadata;
75
+ transport?: string;
76
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "commonjs",
5
+ "rootDir": "src",
6
+ "outDir": "dist",
7
+ "declaration": true,
8
+ "noEmit": false,
9
+ "incremental": false
10
+ },
11
+ "include": [
12
+ "src"
13
+ ],
14
+ "exclude": [
15
+ "src/__tests__"
16
+ ]
17
+ }