context-usage.ts 744 B

12345678910111213141516171819202122232425262728
  1. export const CONTEXT_USAGE_COMPONENT_KINDS = [
  2. 'SYSTEM_PROMPT',
  3. 'MEMORY',
  4. 'TOOLS',
  5. 'SKILLS',
  6. 'MESSAGES',
  7. 'OTHER',
  8. ] as const;
  9. export type ContextUsageComponentKind = (typeof CONTEXT_USAGE_COMPONENT_KINDS)[number];
  10. export interface ContextUsageComponent {
  11. readonly kind: ContextUsageComponentKind;
  12. readonly tokens: number;
  13. }
  14. export interface ContextUsageSnapshot {
  15. readonly contextWindowTokens: number;
  16. readonly usedTokens: number;
  17. readonly totalCountSource: 'LOCAL_ESTIMATE' | 'PROVIDER_USAGE_ANCHORED';
  18. readonly components: readonly ContextUsageComponent[];
  19. }
  20. export interface ContextUsagePromptRange {
  21. readonly kind: 'MEMORY' | 'SKILLS' | 'OTHER';
  22. readonly startOffset: number;
  23. readonly endOffset: number;
  24. }