@@ -44,6 +44,20 @@ function getSessionsSendTool(): SessionSendTool {
4444 return cachedSessionsSendTool ;
4545}
4646
47+ function expectSessionsSendDetails (
48+ result : { details ?: unknown } ,
49+ expected : { reply : string ; sessionKey : string } ,
50+ ) : void {
51+ const details = result . details as {
52+ status ?: string ;
53+ reply ?: string ;
54+ sessionKey ?: string ;
55+ } ;
56+ expect ( details . status ) . toBe ( "ok" ) ;
57+ expect ( details . reply ) . toBe ( expected . reply ) ;
58+ expect ( details . sessionKey ) . toBe ( expected . sessionKey ) ;
59+ }
60+
4761async function emitLifecycleAssistantReply ( params : {
4862 opts : unknown ;
4963 defaultSessionId : string ;
@@ -159,14 +173,7 @@ describe("sessions_send gateway loopback", () => {
159173 message : "ping" ,
160174 timeoutSeconds : 5 ,
161175 } ) ;
162- const details = result . details as {
163- status ?: string ;
164- reply ?: string ;
165- sessionKey ?: string ;
166- } ;
167- expect ( details . status ) . toBe ( "ok" ) ;
168- expect ( details . reply ) . toBe ( "pong" ) ;
169- expect ( details . sessionKey ) . toBe ( "main" ) ;
176+ expectSessionsSendDetails ( result , { reply : "pong" , sessionKey : "main" } ) ;
170177
171178 const firstCall = spy . mock . calls . at ( 0 ) ?. [ 0 ] as
172179 | { lane ?: string ; inputProvenance ?: { kind ?: string ; sourceTool ?: string } }
@@ -338,14 +345,10 @@ describe("sessions_send label lookup", () => {
338345 message : "hello labeled session" ,
339346 timeoutSeconds : 5 ,
340347 } ) ;
341- const details = result . details as {
342- status ?: string ;
343- reply ?: string ;
344- sessionKey ?: string ;
345- } ;
346- expect ( details . status ) . toBe ( "ok" ) ;
347- expect ( details . reply ) . toBe ( "labeled response" ) ;
348- expect ( details . sessionKey ) . toBe ( "agent:main:test-labeled-session" ) ;
348+ expectSessionsSendDetails ( result , {
349+ reply : "labeled response" ,
350+ sessionKey : "agent:main:test-labeled-session" ,
351+ } ) ;
349352 } ,
350353 ) ;
351354} ) ;
@@ -411,14 +414,10 @@ describe("sessions_send agent targeting", () => {
411414 message : "hello orion" ,
412415 timeoutSeconds : 5 ,
413416 } ) ;
414- const details = result . details as {
415- status ?: string ;
416- reply ?: string ;
417- sessionKey ?: string ;
418- } ;
419- expect ( details . status ) . toBe ( "ok" ) ;
420- expect ( details . reply ) . toBe ( "orion response" ) ;
421- expect ( details . sessionKey ) . toBe ( "agent:orion:main" ) ;
417+ expectSessionsSendDetails ( result , {
418+ reply : "orion response" ,
419+ sessionKey : "agent:orion:main" ,
420+ } ) ;
422421
423422 const orionCall = spy . mock . calls
424423 . map ( ( [ opts ] ) => opts as { sessionId ?: string ; sessionKey ?: string } )
0 commit comments