types.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. export type ModelRef = {
  2. /** Provider/model string (e.g. "openai/gpt-4o-mini"). */
  3. id: string;
  4. /** Optional model variant annotation. */
  5. variant?: string;
  6. };
  7. export type SmartfetchOptions = {
  8. binaryDir?: string;
  9. /**
  10. * Dedicated model(s) for secondary-model summarization.
  11. * Each entry is tried in order; the first to return usable text is used.
  12. */
  13. webfetchModels?: ModelRef[];
  14. };
  15. export type SecondaryModel = {
  16. providerID: string;
  17. modelID: string;
  18. /** Optional model variant passed at the body level. */
  19. variant?: string;
  20. };
  21. export type RedirectStep = {
  22. from: string;
  23. to: string;
  24. status: number;
  25. };
  26. export type CachedFetch = {
  27. requestedUrl: string;
  28. finalUrl: string;
  29. statusCode: number;
  30. contentType: string;
  31. charset?: string;
  32. etag?: string;
  33. lastModified?: string;
  34. contentLength?: number;
  35. filename?: string;
  36. canonicalUrl?: string;
  37. headings?: string[];
  38. title?: string;
  39. rawContent: string;
  40. markdown: string;
  41. text: string;
  42. html: string;
  43. extractedMain: boolean;
  44. usedLlmsTxt: boolean;
  45. sourceKind: 'llms_txt' | 'html' | 'text';
  46. upgradedToHttps: boolean;
  47. redirectChain: RedirectStep[];
  48. truncated: boolean;
  49. wordCount: number;
  50. qualitySignals?: string[];
  51. llmsProbeError?: string;
  52. llmsProbeTruncated?: boolean;
  53. cacheRevalidated?: boolean;
  54. upstreamStatusCode?: number;
  55. cacheHit?: boolean;
  56. decodedCharset?: string;
  57. decodeFallback?: boolean;
  58. decodeWarning?: string;
  59. secondaryModelInputTruncated?: boolean;
  60. secondaryModelInputChars?: number;
  61. secondaryModelSourceChars?: number;
  62. };
  63. export type BinaryFetch = {
  64. requestedUrl: string;
  65. finalUrl: string;
  66. statusCode: number;
  67. contentType: string;
  68. charset?: string;
  69. etag?: string;
  70. lastModified?: string;
  71. contentLength?: number;
  72. filename?: string;
  73. canonicalUrl?: string;
  74. redirectChain: RedirectStep[];
  75. upgradedToHttps: boolean;
  76. truncated: boolean;
  77. binary: true;
  78. binaryKind: 'image' | 'audio' | 'video' | 'pdf' | 'binary';
  79. downloadLimitBytes?: number;
  80. metadataOnly?: boolean;
  81. data?: Uint8Array;
  82. llmsProbeError?: string;
  83. llmsProbeTruncated?: boolean;
  84. cacheRevalidated?: boolean;
  85. upstreamStatusCode?: number;
  86. cacheHit?: boolean;
  87. };
  88. export type FetchResult = CachedFetch | BinaryFetch;
  89. export type DecodedBody = {
  90. text: string;
  91. decodedCharset: string;
  92. decodeFallback: boolean;
  93. decodeWarning?: string;
  94. };
  95. export type ExtractedContent = {
  96. title?: string;
  97. rawContent: string;
  98. markdown: string;
  99. text: string;
  100. html: string;
  101. extractedMain: boolean;
  102. canonicalUrl?: string;
  103. headings?: string[];
  104. };
  105. export type FetchWithRedirectsResult =
  106. | {
  107. blockedRedirect: true;
  108. redirectUrl: string;
  109. statusCode: number;
  110. redirectChain: RedirectStep[];
  111. }
  112. | {
  113. response: Response;
  114. finalUrl: string;
  115. redirectChain: RedirectStep[];
  116. };
  117. export type LlmsProbeResult =
  118. | {
  119. url: string;
  120. statusCode: number;
  121. redirectChain: RedirectStep[];
  122. text: string;
  123. headers: {
  124. contentType?: string;
  125. charset?: string;
  126. etag?: string;
  127. lastModified?: string;
  128. contentLength?: number;
  129. filename?: string;
  130. };
  131. truncated: boolean;
  132. decodedCharset: string;
  133. decodeFallback: boolean;
  134. decodeWarning?: string;
  135. upgradedToHttps: boolean;
  136. }
  137. | {
  138. error?: string;
  139. };