snapshot.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /** Session-owned observable state excluding Conversation target data. */
  2. import type { ContentBlock } from '@deepseek-ai/dsh-llm/types'
  3. import type { MessageId } from '@deepseek-ai/dsh-llm/brand'
  4. import type { SessionId } from '@deepseek-ai/dsh-session/types'
  5. import type { SubagentAddress } from '@deepseek-ai/dsh-subagent/client'
  6. import type { ClientFailure } from './result.ts'
  7. /** One transient inbox occurrence from the authoritative queue snapshot. */
  8. export interface QueuedMessage {
  9. readonly id: MessageId
  10. readonly messageId: MessageId
  11. readonly placement: 'queued' | 'steering' | 'context'
  12. readonly content: readonly ContentBlock[]
  13. readonly preview: string
  14. readonly text: string | null
  15. }
  16. /** History-open lifecycle of a Session event window. */
  17. export type OpenState = 'cold' | 'loading' | 'open' | 'error'
  18. /** Send/stop failure surfaced by Session consumers. */
  19. export interface PromptError {
  20. readonly op: 'send' | 'stop'
  21. readonly error: ClientFailure
  22. }
  23. /** Immutable Session lifecycle and control snapshot. */
  24. export interface SessionSnapshot {
  25. readonly sessionId: SessionId
  26. readonly queue: readonly QueuedMessage[]
  27. readonly running: boolean
  28. readonly subagent: {
  29. readonly address: SubagentAddress
  30. /** Absent until the direct-parent catalog resolves. */
  31. readonly parentAvailable?: boolean
  32. } | null
  33. readonly removed: boolean
  34. readonly openState: OpenState
  35. readonly openError: ClientFailure | null
  36. readonly hasMore: boolean
  37. readonly loadingOlder: boolean
  38. readonly promptError: PromptError | null
  39. readonly blank: boolean
  40. readonly lastAgentError: string | null
  41. /** A prompt call has begun on this Client Session object. */
  42. readonly promptAttempted: boolean
  43. /** The first accepted prompt has not reached a durable `turn/start` event. */
  44. readonly awaitingFirstTurn: boolean
  45. }