1212import { create } from '@bufbuild/protobuf' ;
1313import { durationFromMs , timestampFromMs } from '@bufbuild/protobuf/wkt' ;
1414import {
15- type AIAgentTranscript ,
16- AIAgentTranscriptSchema ,
17- AIAgentTranscriptStatus ,
18- type AIAgentTranscriptSummary ,
19- AIAgentTranscriptSummarySchema ,
20- AIAgentTranscriptToolCallStatus ,
21- AIAgentTranscriptTurnRole ,
22- } from 'protogen/redpanda/api/dataplane/v1alpha3/ai_agent_pb ' ;
15+ type GetTranscriptResponse ,
16+ GetTranscriptResponseSchema ,
17+ TranscriptStatus ,
18+ type TranscriptSummary ,
19+ TranscriptSummarySchema ,
20+ TranscriptToolCallStatus ,
21+ TranscriptTurnRole ,
22+ } from 'protogen/redpanda/api/dataplane/v1alpha3/transcript_pb ' ;
2323import type { MessageInit } from 'react-query/react-query.utils' ;
2424
2525const now = Date . now ( ) ;
@@ -34,50 +34,47 @@ const usage = (inputTokens: number, outputTokens: number, totalTokens: number, e
3434
3535const summaries = [
3636 {
37- transcriptId : 'conv_001' ,
37+ conversationId : 'conv_001' ,
3838 title : 'Billing issue classification' ,
3939 offsetMs : 5 * 60 * 1000 ,
4040 durationMs : 87 * 1000 ,
41- status : AIAgentTranscriptStatus . AI_AGENT_TRANSCRIPT_STATUS_COMPLETED ,
41+ status : TranscriptStatus . COMPLETED ,
4242 turnCount : 3 ,
4343 usage : usage ( 596 , 544 , 1140 , 0.12 ) ,
4444 userId : 'user_abc123' ,
4545 hasErrors : false ,
46- traceId : 'trace_001' ,
4746 } ,
4847 {
49- transcriptId : 'conv_002' ,
48+ conversationId : 'conv_002' ,
5049 title : 'Password reset triage' ,
5150 offsetMs : 27 * 60 * 1000 ,
5251 durationMs : 26 * 1000 ,
53- status : AIAgentTranscriptStatus . AI_AGENT_TRANSCRIPT_STATUS_COMPLETED ,
52+ status : TranscriptStatus . COMPLETED ,
5453 turnCount : 2 ,
5554 usage : usage ( 208 , 312 , 520 , 0.04 ) ,
5655 userId : 'user_def456' ,
5756 hasErrors : false ,
58- traceId : 'trace_002' ,
5957 } ,
6058 {
61- transcriptId : 'conv_003' ,
59+ conversationId : 'conv_003' ,
6260 title : 'Long context failure' ,
6361 offsetMs : 71 * 60 * 1000 ,
6462 durationMs : 40 * 1000 ,
65- status : AIAgentTranscriptStatus . AI_AGENT_TRANSCRIPT_STATUS_ERROR ,
63+ status : TranscriptStatus . ERROR ,
6664 turnCount : 2 ,
6765 usage : usage ( 1205 , 0 , 1205 , 0.06 ) ,
6866 userId : 'user_ghi789' ,
6967 hasErrors : true ,
70- traceId : 'trace_003' ,
7168 } ,
7269] as const ;
7370
74- const buildSummary = ( agentId : string , summary : ( typeof summaries ) [ number ] ) : AIAgentTranscriptSummary => {
71+ const buildSummary = ( agentId : string , summary : ( typeof summaries ) [ number ] ) : TranscriptSummary => {
7572 const startMs = now - summary . offsetMs ;
7673 const endMs = startMs + summary . durationMs ;
7774
7875 const init = {
7976 agentId,
80- transcriptId : summary . transcriptId ,
77+ conversationId : summary . conversationId ,
8178 title : summary . title ,
8279 startTime : timestampFromMs ( startMs ) ,
8380 endTime : timestampFromMs ( endMs ) ,
@@ -87,17 +84,16 @@ const buildSummary = (agentId: string, summary: (typeof summaries)[number]): AIA
8784 usage : summary . usage ,
8885 userId : summary . userId ,
8986 hasErrors : summary . hasErrors ,
90- traceId : summary . traceId ,
91- } satisfies MessageInit < AIAgentTranscriptSummary > ;
87+ } satisfies MessageInit < TranscriptSummary > ;
9288
93- return create ( AIAgentTranscriptSummarySchema , init ) ;
89+ return create ( TranscriptSummarySchema , init ) ;
9490} ;
9591
96- export const getMockAIAgentTranscriptSummaries = ( agentId : string ) : AIAgentTranscriptSummary [ ] =>
92+ export const getMockAIAgentTranscriptSummaries = ( agentId : string ) : TranscriptSummary [ ] =>
9793 summaries . map ( ( summary ) => buildSummary ( agentId , summary ) ) ;
9894
99- export const getMockAIAgentTranscript = ( agentId : string , transcriptId : string ) : AIAgentTranscript | null => {
100- const summary = getMockAIAgentTranscriptSummaries ( agentId ) . find ( ( item ) => item . transcriptId === transcriptId ) ;
95+ export const getMockAIAgentTranscript = ( agentId : string , transcriptId : string ) : GetTranscriptResponse | null => {
96+ const summary = getMockAIAgentTranscriptSummaries ( agentId ) . find ( ( item ) => item . conversationId === transcriptId ) ;
10197
10298 if ( ! summary ) {
10399 return null ;
@@ -111,14 +107,14 @@ export const getMockAIAgentTranscript = (agentId: string, transcriptId: string):
111107 turns : [
112108 {
113109 turnId : 'turn_001_1' ,
114- role : AIAgentTranscriptTurnRole . AI_AGENT_TRANSCRIPT_TURN_ROLE_USER ,
110+ role : TranscriptTurnRole . USER ,
115111 timestamp : timestampFromMs ( now - 5 * 60 * 1000 ) ,
116112 content :
117113 'Customer complaint about billing issue with invoice #45892. They claim they were double charged and want an immediate refund.' ,
118114 } ,
119115 {
120116 turnId : 'turn_001_2' ,
121- role : AIAgentTranscriptTurnRole . AI_AGENT_TRANSCRIPT_TURN_ROLE_ASSISTANT ,
117+ role : TranscriptTurnRole . ASSISTANT ,
122118 timestamp : timestampFromMs ( now - 5 * 60 * 1000 + 2 * 1000 ) ,
123119 content : '' ,
124120 model : 'gpt-4o' ,
@@ -128,22 +124,22 @@ export const getMockAIAgentTranscript = (agentId: string, transcriptId: string):
128124 {
129125 toolCallId : 'tool_001_1' ,
130126 name : 'analyze_sentiment' ,
131- status : AIAgentTranscriptToolCallStatus . AI_AGENT_TRANSCRIPT_TOOL_CALL_STATUS_COMPLETED ,
127+ status : TranscriptToolCallStatus . COMPLETED ,
132128 latency : durationFromMs ( 120 ) ,
133129 output : '{"sentiment":"negative","confidence":0.97}' ,
134130 } ,
135131 {
136132 toolCallId : 'tool_001_2' ,
137133 name : 'categorize_ticket' ,
138- status : AIAgentTranscriptToolCallStatus . AI_AGENT_TRANSCRIPT_TOOL_CALL_STATUS_COMPLETED ,
134+ status : TranscriptToolCallStatus . COMPLETED ,
139135 latency : durationFromMs ( 95 ) ,
140136 output : '{"category":"billing","priority":"high"}' ,
141137 } ,
142138 ] ,
143139 } ,
144140 {
145141 turnId : 'turn_001_3' ,
146- role : AIAgentTranscriptTurnRole . AI_AGENT_TRANSCRIPT_TURN_ROLE_ASSISTANT ,
142+ role : TranscriptTurnRole . ASSISTANT ,
147143 timestamp : timestampFromMs ( now - 5 * 60 * 1000 + 4 * 1000 ) ,
148144 content :
149145 '{\n "category": "billing",\n "priority": "high",\n "sentiment": "negative",\n "confidence": 0.94,\n "suggested_action": "escalate_to_billing_team"\n}' ,
@@ -152,9 +148,9 @@ export const getMockAIAgentTranscript = (agentId: string, transcriptId: string):
152148 usage : usage ( 312 , 544 , 856 , 0.09 ) ,
153149 } ,
154150 ] ,
155- } satisfies MessageInit < AIAgentTranscript > ;
151+ } satisfies MessageInit < GetTranscriptResponse > ;
156152
157- return create ( AIAgentTranscriptSchema , init ) ;
153+ return create ( GetTranscriptResponseSchema , init ) ;
158154 }
159155
160156 if ( transcriptId === 'conv_002' ) {
@@ -165,13 +161,13 @@ export const getMockAIAgentTranscript = (agentId: string, transcriptId: string):
165161 turns : [
166162 {
167163 turnId : 'turn_002_1' ,
168- role : AIAgentTranscriptTurnRole . AI_AGENT_TRANSCRIPT_TURN_ROLE_USER ,
164+ role : TranscriptTurnRole . USER ,
169165 timestamp : timestampFromMs ( now - 27 * 60 * 1000 ) ,
170166 content : 'How do I reset my password?' ,
171167 } ,
172168 {
173169 turnId : 'turn_002_2' ,
174- role : AIAgentTranscriptTurnRole . AI_AGENT_TRANSCRIPT_TURN_ROLE_ASSISTANT ,
170+ role : TranscriptTurnRole . ASSISTANT ,
175171 timestamp : timestampFromMs ( now - 27 * 60 * 1000 + 26 * 1000 ) ,
176172 content :
177173 '{\n "category": "account",\n "priority": "low",\n "sentiment": "neutral",\n "suggested_action": "send_password_reset_link"\n}' ,
@@ -180,9 +176,9 @@ export const getMockAIAgentTranscript = (agentId: string, transcriptId: string):
180176 usage : usage ( 208 , 312 , 520 , 0.04 ) ,
181177 } ,
182178 ] ,
183- } satisfies MessageInit < AIAgentTranscript > ;
179+ } satisfies MessageInit < GetTranscriptResponse > ;
184180
185- return create ( AIAgentTranscriptSchema , init ) ;
181+ return create ( GetTranscriptResponseSchema , init ) ;
186182 }
187183
188184 const init = {
@@ -192,13 +188,13 @@ export const getMockAIAgentTranscript = (agentId: string, transcriptId: string):
192188 turns : [
193189 {
194190 turnId : 'turn_003_1' ,
195- role : AIAgentTranscriptTurnRole . AI_AGENT_TRANSCRIPT_TURN_ROLE_USER ,
191+ role : TranscriptTurnRole . USER ,
196192 timestamp : timestampFromMs ( now - 71 * 60 * 1000 ) ,
197193 content : 'Here is our entire conversation history from the past year and all attached artifacts...' ,
198194 } ,
199195 {
200196 turnId : 'turn_003_2' ,
201- role : AIAgentTranscriptTurnRole . AI_AGENT_TRANSCRIPT_TURN_ROLE_ASSISTANT ,
197+ role : TranscriptTurnRole . ASSISTANT ,
202198 timestamp : timestampFromMs ( now - 71 * 60 * 1000 + 40 * 1000 ) ,
203199 content : '' ,
204200 model : 'gpt-4o' ,
@@ -208,7 +204,7 @@ export const getMockAIAgentTranscript = (agentId: string, transcriptId: string):
208204 {
209205 toolCallId : 'tool_003_1' ,
210206 name : 'analyze_sentiment' ,
211- status : AIAgentTranscriptToolCallStatus . AI_AGENT_TRANSCRIPT_TOOL_CALL_STATUS_ERROR ,
207+ status : TranscriptToolCallStatus . ERROR ,
212208 latency : durationFromMs ( 38 * 1000 ) ,
213209 error : { code : 'context_window_exceeded' , message : 'Context window exceeded while processing input' } ,
214210 } ,
@@ -217,9 +213,9 @@ export const getMockAIAgentTranscript = (agentId: string, transcriptId: string):
217213 } ,
218214 ] ,
219215 error : { code : 'context_window_exceeded' , message : 'Context window exceeded while processing input' } ,
220- } satisfies MessageInit < AIAgentTranscript > ;
216+ } satisfies MessageInit < GetTranscriptResponse > ;
221217
222- return create ( AIAgentTranscriptSchema , init ) ;
218+ return create ( GetTranscriptResponseSchema , init ) ;
223219} ;
224220
225221export const isMockAIAgentTranscriptsEnabled = ( ) => {
0 commit comments