Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

protocol.test.ts

739 lines23.0 KB

1import { describe, expect, it, vi } from 'vitest'
2import { z } from 'zod'
3import { defineAgent } from '@tanstack/ai'
4import { memoryPersistence } from '@tanstack/ai-persistence'
5import {
6 createHarnessHost,
7 defineCommand,
8 defineHarness,
9 definePlugin,
10 logIdOf,
11} from '../src'
12import {
13 applyInput,
14 createHarnessHandler,
15 handleHarnessSocket,
16 parseControlFrame,
17 parseHarnessInput,
18} from '../src/server'
19import {
20 after,
21 fakeSocket,
22 gate,
23 mockAdapter,
24 readSse,
25 text,
26 wakeMessages,
27} from './helpers'
28import {
29 HARNESS_PROTOCOL_VERSION,
30 requestIdOf,
31 versionError,
32} from '../src/protocol'
33import type { Receipt } from '../src'
34import type { HostFrame } from '../src/server'
35import type { Reply } from './helpers'
36​
37// Coverage runs in CI are slow, so polled checks wait up to 5 s.
38const waitFor = <T>(
39 check: () => T | Promise<T>,
40 options?: { timeout?: number; interval?: number },
41) => vi.waitFor(check, { timeout: 5_000, ...options })
42​
43const pricer = defineAgent({
44 name: 'pricer',
45 description: 'Prices a vendor',
46 inputSchema: z.object({ vendor: z.string() }),
47 run: async (ctx) => ({ vendor: ctx.input.vendor, cents: 1200 }),
48})
49const secret = defineAgent({
50 name: 'secret',
51 description: 'Not for clients',
52 run: async () => 'hidden',
53})
54​
55function setup(
56 replies: Array<Reply> = [() => text('hello'), () => text('again')],
57) {
58 const { adapter, calls } = mockAdapter(replies)
59 const harness = defineHarness({
60 name: 'test/protocol',
61 adapter,
62 agents: [pricer, secret],
63 expose: { agents: ['pricer'] },
64 })
65 const host = createHarnessHost({
66 persistence: memoryPersistence(),
67 access: {
68 getUser: ({ request }) =>
69 request.headers.get('authorization') === 'Bearer good' ? user : null,
70 // A user may use the threads whose id starts with the user id.
71 rules: {
72 isAllowed: ({ user, session }) => session.threadId.startsWith(user.id),
73 },
74 },
75 })
76 const handler = createHarnessHandler({ host, harness })
77 return { handler, host, harness, calls }
79​
80const auth = { authorization: 'Bearer good' }
81const user = { id: 'user-1' }
82​
83type Handler = ReturnType<typeof setup>['handler']
84​
85/** POST one input to `/control` for `threadId`. Resolves to the JSON body. */
86function controlOf(handler: Handler, threadId: string) {
87 return async (input: unknown): Promise<unknown> =>
88 (
89 await handler(
90 new Request('http://x/api/harness/control', {
91 method: 'POST',
92 headers: { ...auth, 'content-type': 'application/json' },
93 body: JSON.stringify({ threadId, input }),
94 }),
95 )
96 ).json()
98​
99const isTurnEnd = (frame: HostFrame) =>
100 frame.type === 'harness.event' &&
101 frame.event.type === 'CUSTOM' &&
102 frame.event.name === 'harness.operation.finished'
103​
104describe('HTTP handler', () => {
105 it('refuses requests that authorize rejects', async () => {
106 const { handler, host } = setup()
107 const response = await handler(
108 new Request('http://x/api/harness/capabilities'),
109 )
110 expect(response.status).toBe(401)
111 await host.close()
112 })
113​
114 it('refuses threads the user cannot access', async () => {
115 const { handler, host, harness } = setup()
116 await host.open(harness, {
117 threadId: 'other-thread',
118 user: { id: 'user-2' },
119 })
120 const response = await handler(
121 new Request('http://x/api/harness/snapshot?threadId=other-thread', {
122 headers: auth,
123 }),
124 )
125 expect(response.status).toBe(403)
126 await host.close()
127 })
128​
129 it('lists only exposed agents in the capabilities', async () => {
130 const { handler, host } = setup()
131 const response = await handler(
132 new Request('http://x/api/harness/capabilities', { headers: auth }),
133 )
134 const body = await response.json()
135 expect(body.identity.name).toBe('test/protocol')
136 expect(
137 body.custom.tanstack.agents.map((agent: { name: string }) => agent.name),
138 ).toEqual(['pricer'])
139 expect(
140 body.custom.tanstack.agents[0].inputSchema.properties.vendor.type,
141 ).toBe('string')
142 await host.close()
143 })
144​
145 it('serves a standard AG-UI run as SSE', async () => {
146 const { handler, host } = setup()
147 const response = await handler(
148 new Request('http://x/api/harness/run', {
149 method: 'POST',
150 headers: { ...auth, 'content-type': 'application/json' },
151 body: JSON.stringify({
152 threadId: 'user-1-thread',
153 runId: 'client-run',
154 messages: [{ id: 'm1', role: 'user', content: 'hi' }],
155 tools: [],
156 context: [],
157 state: {},
158 forwardedProps: {},
159 }),
160 }),
161 )
162 expect(response.headers.get('content-type')).toContain('text/event-stream')
163 const text = await response.text()
164 expect(text).toContain('"delta":"hello"')
165 expect(text).toContain('RUN_FINISHED')
166 await host.close()
167 })
168​
169 it('takes control inputs, streams session events, and resumes from a cursor', async () => {
170 const { handler, host } = setup()
171 const control = controlOf(handler, 'user-1-t')
172​
173 expect(await control({ op: 'prompt', message: 'hi' })).toMatchObject({
174 status: 'accepted',
175 })
176​
177 const first = await readSse(
178 await handler(
179 new Request('http://x/api/harness/events?threadId=user-1-t', {
180 headers: auth,
181 }),
182 ),
183 isTurnEnd,
184 )
185 // The hello comes first, then the events.
186 expect(first[0]).toEqual({
187 type: 'harness.hello',
188 v: 2,
189 threadId: 'user-1-t',
190 })
191 expect(
192 first.slice(1).every((frame) => frame.type === 'harness.event'),
193 ).toBe(true)
194 const last = first.at(-1)
195 const cursor = last?.type === 'harness.event' ? last.cursor : ''
196​
197 await control({ op: 'prompt', message: 'more' })
198 const second = await readSse(
199 await handler(
200 new Request('http://x/api/harness/events?threadId=user-1-t', {
201 headers: { ...auth, 'Last-Event-ID': cursor },
202 }),
203 ),
204 isTurnEnd,
205 )
206 expect(
207 second
208 .slice(1)
209 .every(
210 (frame) =>
211 frame.type === 'harness.event' &&
212 Number(frame.cursor) > Number(cursor),
213 ),
214 ).toBe(true)
215 expect(JSON.stringify(second)).toContain('again')
216 await host.close()
217 })
218​
219 it('answers a retried prompt with the same inputId with the first receipt', async () => {
220 const { handler, host, calls } = setup()
221 const control = controlOf(handler, 'user-1-retry')
222​
223 const first = await control({ op: 'prompt', message: 'hi', inputId: 'c-1' })
224 const retry = await control({ op: 'prompt', message: 'hi', inputId: 'c-1' })
225​
226 expect(first).toMatchObject({ inputId: 'c-1', status: 'accepted' })
227 expect(retry).toEqual(first)
228 await waitFor(() => expect(calls).toHaveLength(1))
229 expect(
230 await control({ op: 'prompt', message: 'another', inputId: 'c-1' }),
231 ).toMatchObject({ status: 'rejected', reason: 'conflict' })
232 expect(await control({ op: 'prompt', message: 'x', inputId: 7 })).toEqual({
233 error: 'Invalid input: inputId must be a string.',
234 })
235 await host.close()
236 })
237​
238 it('runs a resent command or agent start with the same inputId once', async () => {
239 const runs = { command: 0, agent: 0 }
240 const counter = defineAgent({
241 name: 'counter',
242 description: 'Counts its runs',
243 run: async () => ++runs.agent,
244 })
245 const harness = defineHarness({
246 name: 'test/protocol-resend',
247 adapter: mockAdapter([]).adapter,
248 agents: [counter],
249 plugins: () => [
250 definePlugin({
251 name: 'test/count',
252 setup: () => ({
253 commands: {
254 count: defineCommand({
255 description: 'Counts its runs',
256 run: () => ++runs.command,
257 }),
258 },
259 }),
260 }),
261 ],
262 expose: { agents: ['counter'], commands: ['count'] },
263 })
264 const host = createHarnessHost({ persistence: memoryPersistence() })
265 const session = await host.open(harness, { threadId: 'resend' })
266​
267 // The operation of a receipt ends, also as a duplicate.
268 const settled = (receipt: Receipt) =>
269 receipt.operationId === undefined
270 ? undefined
271 : session.operation(receipt.operationId)?.then(
272 () => {},
273 () => {},
274 )
275 const command = { op: 'command', name: 'count', inputId: 'c-1' } as const
276 const first = await applyInput({ harness, session, input: command })
277 expect(first).toMatchObject({ inputId: 'c-1', status: 'accepted' })
278 await vi.waitFor(() => expect(runs.command).toBe(1), { timeout: 5000 })
279 await settled(await applyInput({ harness, session, input: command }))
280​
281 const agent = { op: 'agent', agent: 'counter', inputId: 'a-1' } as const
282 expect(await applyInput({ harness, session, input: agent })).toMatchObject({
283 inputId: 'a-1',
284 status: 'accepted',
285 })
286 await vi.waitFor(() => expect(runs.agent).toBe(1), { timeout: 5000 })
287 await settled(await applyInput({ harness, session, input: agent }))
288​
289 expect(runs).toEqual({ command: 1, agent: 1 })
290 await host.close()
291 })
292​
293 it('writes the records of a resent append with the same inputId once', async () => {
294 const persistence = memoryPersistence()
295 const harness = defineHarness({
296 name: 'test/protocol-append',
297 adapter: mockAdapter([]).adapter,
298 expose: { records: ['app.signal'] },
299 })
300 const host = createHarnessHost({ persistence })
301 const session = await host.open(harness, { threadId: 'append' })
302 const input = {
303 op: 'append' as const,
304 records: [{ type: 'app.signal', text: 'The build failed.' }],
305 inputId: 'ap-1',
306 }
307​
308 const first = await applyInput({ harness, session, input })
309 const again = await applyInput({ harness, session, input })
310​
311 expect(first).toEqual({ inputId: 'ap-1', status: 'accepted' })
312 expect(again).toEqual(first)
313 const signals = (
314 await persistence.stores.log.read({ logId: logIdOf({ logId: 'append' }) })
315 ).filter(({ record }) => record.type === 'app.signal')
316 expect(signals).toHaveLength(1)
317 await host.close()
318 })
319​
320 it('runs exposed agents from a client and refuses the others', async () => {
321 const { handler, host } = setup()
322 const control = controlOf(handler, 'user-1-a')
323​
324 expect(await control({ op: 'agent', agent: 'secret' })).toMatchObject({
325 status: 'rejected',
326 reason: 'not_exposed',
327 })
328 expect(
329 await control({ op: 'agent', agent: 'pricer', input: { vendor: 'x' } }),
330 ).toMatchObject({
331 status: 'accepted',
332 })
333 expect(await control({ op: 'launch' })).toMatchObject({
334 error: expect.stringContaining('Invalid input'),
335 })
336 await host.close()
337 })
338​
339 it('sends messages to runs of exposed agents only', async () => {
340 const { handler, host, harness } = setup()
341 const control = async (input: unknown) =>
342 (
343 await handler(
344 new Request('http://x/api/harness/control', {
345 method: 'POST',
346 headers: { ...auth, 'content-type': 'application/json' },
347 body: JSON.stringify({ threadId: 'user-1-m', input }),
348 }),
349 )
350 ).json()
351​
352 const started = await control({
353 op: 'agent',
354 agent: 'pricer',
355 input: { vendor: 'x' },
356 })
357 expect(
358 await control({
359 op: 'agentMessage',
360 operationId: started.operationId,
361 message: 'In euros.',
362 mode: 'followUp',
363 }),
364 ).toMatchObject({ status: expect.stringMatching(/^(accepted|queued)$/) })
365​
366 const session = await host.open(harness, {
367 threadId: 'user-1-m',
368 user,
369 })
370 const hidden = session.agent('secret')?.start()
371 expect(
372 await control({
373 op: 'agentMessage',
374 operationId: hidden?.id,
375 message: 'Hello.',
376 }),
377 ).toMatchObject({ status: 'rejected', reason: 'not_exposed' })
378 expect(
379 await control({
380 op: 'agentMessage',
381 operationId: 'op-agent-none',
382 message: 'Hello.',
383 }),
384 ).toMatchObject({ status: 'rejected', reason: 'not_running' })
385 expect(await control({ op: 'agentMessage', message: 'Hello.' })).toEqual({
386 error: 'Invalid input: agentMessage needs an operationId.',
387 })
388 await host.close()
389 })
390​
391 it('moves and cancels a waiting input, and the snapshot lists it', async () => {
392 const release = gate()
393 const { handler, host, calls } = setup([after(release.opened, 'hello')])
394 const control = controlOf(handler, 'user-1-wait')
395 const snapshot = async () =>
396 (
397 await handler(
398 new Request('http://x/api/harness/snapshot?threadId=user-1-wait', {
399 headers: auth,
400 }),
401 )
402 ).json()
403 await control({ op: 'prompt', message: 'hi' })
404 // The model call runs, so a steer can join only at a later call.
405 await waitFor(() => expect(calls).toHaveLength(1))
406 await control({ op: 'followUp', message: 'later', inputId: 'f-1' })
407​
408 expect(
409 await control({ op: 'setDelivery', inputId: 'f-1', delivery: 'steer' }),
410 ).toMatchObject({ status: 'accepted' })
411 expect(await snapshot()).toMatchObject({
412 waitingInputs: [{ inputId: 'f-1', delivery: 'steer', message: 'later' }],
413 })
414 expect(await control({ op: 'cancelInput', inputId: 'f-1' })).toMatchObject({
415 status: 'accepted',
416 })
417 expect(await snapshot()).toMatchObject({ waitingInputs: [] })
418 expect(await control({ op: 'cancelInput', inputId: 'f-1' })).toMatchObject({
419 status: 'rejected',
420 reason: 'not_waiting',
421 })
422 release.open()
423 await host.close()
424 })
425​
426 it('drops the wake mark of a client follow-up', async () => {
427 const { handler, host, harness, calls } = setup([() => text('ok')])
428 const control = controlOf(handler, 'user-1-wake')
429​
430 await control({ op: 'followUp', message: 'I am real', wake: true })
431​
432 await waitFor(() => expect(calls).toHaveLength(1))
433 const session = await host.open(harness, {
434 threadId: 'user-1-wake',
435 user,
436 })
437 await waitFor(() => expect(session.snapshot().status).toBe('idle'))
438 expect(wakeMessages(await session.transcript())).toEqual([])
439 await host.close()
440 })
441})
442​
443describe('parseHarnessInput', () => {
444 it('drops the wake mark of a follow-up, which only the harness sets', () => {
445 expect(
446 parseHarnessInput({ op: 'followUp', message: 'hi', wake: true }),
447 ).toEqual({ op: 'followUp', message: 'hi' })
448 })
449​
450 it('lets a client send background without an expose entry', async () => {
451 const { handler, host } = setup()
452 const control = controlOf(handler, 'user-1-bg')
453 expect(await control({ op: 'background' })).toMatchObject({
454 status: 'rejected',
455 reason: 'not_running',
456 })
457 expect(() =>
458 parseHarnessInput({ op: 'background', toolCallId: 1 }),
459 ).toThrow('Invalid input: the toolCallId of background must be a string.')
460 await host.close()
461 })
462​
463 it('checks the fields of cancelInput and setDelivery', () => {
464 expect(() => parseHarnessInput({ op: 'cancelInput' })).toThrow(
465 'Invalid input: cancelInput needs an inputId.',
466 )
467 expect(() =>
468 parseHarnessInput({ op: 'setDelivery', inputId: 'a', delivery: 'now' }),
469 ).toThrow("Invalid input: setDelivery needs 'steer' or 'queue'.")
470 })
471​
472 it('refuses a message part without the fields the harness reads', () => {
473 // An image with no source, then a data source with no MIME type.
474 for (const part of [
475 { type: 'image' },
476 { type: 'image', source: { type: 'data', value: 'aGVsbG8=' } },
477 ]) {
478 expect(() =>
479 parseHarnessInput({ op: 'prompt', message: [part] }),
480 ).toThrow(
481 'Invalid input: prompt needs a message: text, or content parts.',
482 )
483 }
484 expect(() =>
485 parseHarnessInput({
486 op: 'continue',
487 ephemeral: [{ role: 'user', content: [{ type: 'audio' }] }],
488 }),
489 ).toThrow('Invalid input: ephemeral must be an array of user messages.')
490 })
491​
492 it('reports the WebSocket in capabilities only when the app serves it', async () => {
493 const { host, harness } = setup()
494 const transportOf = async (socket?: boolean) => {
495 const handler = createHarnessHandler({
496 host,
497 harness,
498 ...(socket === undefined ? {} : { socket }),
499 })
500 const response = await handler(
501 new Request('http://x/api/harness/capabilities', { headers: auth }),
502 )
503 const body: unknown = await response.json()
504 return body
505 }
506​
507 expect(await transportOf()).toMatchObject({
508 transport: { streaming: true, websocket: false },
509 })
510 expect(await transportOf(true)).toMatchObject({
511 transport: { streaming: true, websocket: true },
512 })
513 await host.close()
514 })
515​
516 it('checks the ephemeral messages of prompt and continue', () => {
517 const refused =
518 'Invalid input: ephemeral must be an array of user messages.'
519 expect(() =>
520 parseHarnessInput({ op: 'prompt', message: 'hi', ephemeral: 'note' }),
521 ).toThrow(refused)
522 // A client cannot fake an answer or a tool result.
523 for (const role of ['system', 'assistant', 'tool']) {
524 expect(() =>
525 parseHarnessInput({
526 op: 'continue',
527 ephemeral: [{ role, content: 'note' }],
528 }),
529 ).toThrow(refused)
530 }
531 const ephemeral = [{ role: 'user', content: 'note' }]
532 expect(parseHarnessInput({ op: 'continue', ephemeral })).toEqual({
533 op: 'continue',
534 ephemeral,
535 })
536 })
537})
538​
539describe('WebSocket', () => {
540 it('subscribes, applies inputs with receipts, and streams events', async () => {
541 const { host, harness } = setup()
542 const { socket, sent, receive } = fakeSocket()
543 handleHarnessSocket({
544 host,
545 harness,
546 socket,
547 request: new Request('http://x/api/harness/socket', { headers: auth }),
548 })
549​
550 receive({
551 type: 'harness.input',
552 requestId: 'r0',
553 input: { op: 'prompt', message: 'x' },
554 })
555 await waitFor(() => expect(sent.at(-1)?.type).toBe('harness.error'))
556​
557 receive({ type: 'harness.subscribe', threadId: 'user-1-ws' })
558 await waitFor(() =>
559 expect(sent.some((frame) => frame.type === 'harness.hello')).toBe(true),
560 )
561 receive({
562 type: 'harness.input',
563 requestId: 'r1',
564 input: { op: 'prompt', message: 'hi' },
565 })
566​
567 await waitFor(() =>
568 expect(
569 sent.some(
570 (frame) =>
571 frame.type === 'harness.event' &&
572 frame.event.type === 'CUSTOM' &&
573 frame.event.name === 'harness.operation.finished',
574 ),
575 ).toBe(true),
576 )
577 expect(
578 sent.find((frame) => frame.type === 'harness.receipt'),
579 ).toMatchObject({
580 requestId: 'r1',
581 status: 'accepted',
582 })
583 receive({ type: 'harness.snapshot' })
584 await waitFor(() =>
585 expect(sent.at(-1)).toMatchObject({
586 type: 'harness.snapshot',
587 snapshot: { status: 'idle' },
588 }),
589 )
590 socket.close()
591 await host.close()
592 })
593})
594​
595describe('WebSocket frame order', () => {
596 it('applies the inputs of one socket in the order they came', async () => {
597 const { host, harness } = setup()
598 const { socket, sent, receive } = fakeSocket()
599 handleHarnessSocket({
600 host,
601 harness,
602 socket,
603 request: new Request('http://x/api/harness/socket', { headers: auth }),
604 })
605 receive({ type: 'harness.subscribe', threadId: 'user-1-order' })
606 await vi.waitFor(
607 () =>
608 expect(sent.some((frame) => frame.type === 'harness.hello')).toBe(true),
609 { timeout: 5000 },
610 )
611​
612 // The first input stores its image before it reaches the session. The
613 // second is text only, so it is faster on its own.
614 const image = {
615 type: 'image',
616 source: { type: 'data', value: 'aGVsbG8=', mimeType: 'image/png' },
617 }
618 receive({
619 type: 'harness.input',
620 requestId: 'first',
621 input: { op: 'prompt', inputId: 'first', message: [image] },
622 })
623 receive({
624 type: 'harness.input',
625 requestId: 'second',
626 input: { op: 'prompt', inputId: 'second', message: 'B' },
627 })
628​
629 const receipts = () =>
630 sent.flatMap((frame) =>
631 frame.type === 'harness.receipt' ? [frame.requestId] : [],
632 )
633 await vi.waitFor(() => expect(receipts()).toHaveLength(2), {
634 timeout: 5000,
635 })
636 expect(receipts()).toEqual(['first', 'second'])
637 socket.close()
638 await host.close()
639 })
640})
641​
642describe('parseControlFrame', () => {
643 it('rejects unknown frames', () => {
644 expect(() => parseControlFrame('{"type":"nope"}')).toThrow('unknown type')
645 expect(() =>
646 parseControlFrame('{"type":"harness.input","requestId":"1","input":{}}'),
647 ).toThrow('Invalid input')
648 })
649​
650 it('keeps the v of a subscribe, and refuses a v that is not a number', () => {
651 expect(
652 parseControlFrame('{"type":"harness.subscribe","threadId":"t","v":2}'),
653 ).toEqual({ type: 'harness.subscribe', threadId: 't', v: 2 })
654 expect(() =>
655 parseControlFrame('{"type":"harness.subscribe","threadId":"t","v":"2"}'),
656 ).toThrow('v must be a number')
657 })
658​
659 it('keeps a valid traceparent of an input, and drops an invalid one', () => {
660 const traceparent =
661 '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01'
662 const frame = (value: string) =>
663 parseControlFrame(
664 JSON.stringify({
665 type: 'harness.input',
666 requestId: 'r1',
667 input: { op: 'prompt', message: 'hi' },
668 traceparent: value,
669 }),
670 )
671 expect(frame(traceparent)).toMatchObject({ traceparent })
672 expect(frame('not-a-traceparent')).not.toHaveProperty('traceparent')
673 })
674})
675​
676describe('versionError', () => {
677 it('takes the current version, and no version', () => {
678 expect(HARNESS_PROTOCOL_VERSION).toBe(2)
679 expect(versionError(undefined)).toBeUndefined()
680 expect(versionError(2)).toBeUndefined()
681 })
682​
683 it('refuses another version', () => {
684 expect(versionError(1)).toEqual({
685 message:
686 'Protocol version 1 is not supported. This host speaks version 2.',
687 code: 'unsupported_version',
688 })
689 })
690})
691​
692describe('requestIdOf', () => {
693 it('reads the requestId of a frame that fails the full parse', () => {
694 const badInput = '{"type":"harness.input","requestId":"r9","input":{}}'
695 expect(() => parseControlFrame(badInput)).toThrow('Invalid input')
696 expect(requestIdOf(badInput)).toBe('r9')
697 })
698​
699 it('never throws', () => {
700 expect(requestIdOf('{not json')).toBeUndefined()
701 expect(requestIdOf('null')).toBeUndefined()
702 expect(requestIdOf('{"requestId":7}')).toBeUndefined()
703 })
704})
705​
706describe('traceparent on an input', () => {
707 const traceparent = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01'
708​
709 it('applyInput passes the traceparent to the send of a message', async () => {
710 const { host, harness } = setup()
711 const session = await host.open(harness, {
712 threadId: 'user-1-trace',
713 user,
714 })
715 const send = vi.spyOn(session, 'send')
716​
717 await applyInput({
718 harness,
719 session,
720 input: { op: 'prompt', message: 'hi' },
721 user,
722 traceparent,
723 })
724 await applyInput({
725 harness,
726 session,
727 input: { op: 'steer', message: 'more' },
728 user,
729 traceparent,
730 })
731​
732 expect(send.mock.calls.map(([, options]) => options?.traceparent)).toEqual([
733 traceparent,
734 traceparent,
735 ])
736 await session.close()
737 await host.close()
738 })
739})