source-session.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /** Deterministic projected source shared by reference snapshot and Loader tests. */
  2. import type { Context } from '@deepseek-ai/cordis'
  3. import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
  4. import { Session, SessionId } from '@deepseek-ai/dsh-session'
  5. export const name = 'session-reference-source-fixture'
  6. export const inject = ['sessions']
  7. /**
  8. * Create a live source without publishing a persisted agent session.
  9. * @param ctx - fixture composition.
  10. */
  11. export function apply(ctx: Context): void {
  12. const source = Session.create(SessionId('reference-source'))
  13. source.append('user/message', createUserMessage({
  14. content: [{ type: 'text', text: 'EARLY_SOURCE_FACT\n' + 'Historical detail 界.\n'.repeat(30)
  15. + 'x'.repeat(4096) + 'GIANT_LINE_MIDDLE_FACT' + 'y'.repeat(4096) }],
  16. source: { kind: 'user' },
  17. }), { surfaceOp: 'append' })
  18. source.append('user/message', createUserMessage({
  19. content: [{ type: 'text', text: 'NESTED_REFERENCE_MUST_NOT_PROPAGATE' }],
  20. source: { kind: 'session-reference', form: 'recall', version: 1, references: [] },
  21. }), { surfaceOp: 'append' })
  22. source.append('assistant/message', {
  23. turn: 1,
  24. step: 1,
  25. stream: [],
  26. message: createMessage({
  27. role: 'assistant',
  28. content: [
  29. { type: 'reasoning', text: 'PRIVATE_REASONING_MUST_NOT_PROPAGATE' },
  30. { type: 'text', text: 'LATEST_SOURCE_FACT\nThe captured answer is forty-two.' },
  31. ],
  32. source: { kind: 'model', provider: 'fixture', model: 'fixture' },
  33. }),
  34. }, { surfaceOp: 'append' })
  35. ctx.effect(() => ctx.sessions.enter(source))
  36. }