1
0

model-selection-state.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. /** Durable per-session state for the user-controlled model-selection opt-in. */
  2. import type { Session } from '@deepseek-ai/dsh-session'
  3. declare module '@deepseek-ai/dsh-session/types' {
  4. interface SessionEventMap {
  5. /**
  6. * Records that this session's delegation tool exposes child provider,
  7. * model, and reasoning-effort selection. Appended before the first model
  8. * request; absence means the fixed-route definition. Log-only: it carries
  9. * no `surfaceOp` and never enters model history.
  10. */
  11. 'subagent/model-selection-enabled': Record<string, never>
  12. }
  13. }
  14. /**
  15. * Whether a session log records the enabled model-selection definition.
  16. * @param session - session whose durable decision is read.
  17. * @returns whether model-selectable delegation is enabled for the session.
  18. */
  19. export function hasSubagentModelSelection(session: Session): boolean {
  20. return session.events.some(event => event.type === 'subagent/model-selection-enabled')
  21. }
  22. /**
  23. * Append the enabled decision once, before its definition can reach a model request.
  24. * @param session - session receiving the enabled decision.
  25. */
  26. export function recordSubagentModelSelection(session: Session): void {
  27. if (hasSubagentModelSelection(session)) return
  28. session.append('subagent/model-selection-enabled', {})
  29. }