@@ -44,6 +44,20 @@ function getSessionsSendTool(): SessionSendTool {
|
44 | 44 | return cachedSessionsSendTool; |
45 | 45 | } |
46 | 46 | |
| 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 | + |
47 | 61 | async function emitLifecycleAssistantReply(params: { |
48 | 62 | opts: unknown; |
49 | 63 | defaultSessionId: string; |
@@ -159,14 +173,7 @@ describe("sessions_send gateway loopback", () => {
|
159 | 173 | message: "ping", |
160 | 174 | timeoutSeconds: 5, |
161 | 175 | }); |
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" }); |
170 | 177 | |
171 | 178 | const firstCall = spy.mock.calls.at(0)?.[0] as |
172 | 179 | | { lane?: string; inputProvenance?: { kind?: string; sourceTool?: string } } |
@@ -338,14 +345,10 @@ describe("sessions_send label lookup", () => {
|
338 | 345 | message: "hello labeled session", |
339 | 346 | timeoutSeconds: 5, |
340 | 347 | }); |
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 | +}); |
349 | 352 | }, |
350 | 353 | ); |
351 | 354 | }); |
@@ -411,14 +414,10 @@ describe("sessions_send agent targeting", () => {
|
411 | 414 | message: "hello orion", |
412 | 415 | timeoutSeconds: 5, |
413 | 416 | }); |
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 | +}); |
422 | 421 | |
423 | 422 | const orionCall = spy.mock.calls |
424 | 423 | .map(([opts]) => opts as { sessionId?: string; sessionKey?: string }) |
|