bench.client.ts 1.2 KB

12345678910111213141516171819202122232425262728
  1. /** Session objects owned by a client test's explicitly started Gateway assembly. */
  2. import { onTestFinished } from 'vitest'
  3. import type { RemoteMock } from '@deepseek-ai/dsh-remote-mock'
  4. import type { TestClient } from '@deepseek-ai/dsh-client-test-runtime/src/assembly/index.ts'
  5. import type { SessionId } from '@deepseek-ai/dsh-session/types'
  6. import { Session, type SessionOptions } from '../../src/client/sessions/session.ts'
  7. import { sessionWorld } from './session.client.ts'
  8. /**
  9. * Create a Session after installing its default Remote responses.
  10. * @param mock - this case's Remote responses.
  11. * @param start - the fixture's lazy client startup.
  12. * @param sessionId - Session identity.
  13. * @param options - addressed child and parent availability, when applicable.
  14. * @returns the Session, disposed at the end of the case.
  15. */
  16. export async function sessionBench(
  17. mock: RemoteMock,
  18. start: () => Promise<TestClient>,
  19. sessionId: SessionId,
  20. options: SessionOptions = {},
  21. ): Promise<Session> {
  22. mock.load(sessionWorld)
  23. const client = await start()
  24. const session = new Session(sessionId, client.ctx.remote, options)
  25. onTestFinished(() => session.dispose())
  26. return session
  27. }