@graphext/cuery 0.4.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/esm/browser.d.ts +1 -1
  2. package/esm/browser.d.ts.map +1 -1
  3. package/esm/browser.js +1 -1
  4. package/esm/mod.d.ts +5 -2
  5. package/esm/mod.d.ts.map +1 -1
  6. package/esm/mod.js +7 -2
  7. package/esm/src/api.d.ts +36 -5
  8. package/esm/src/api.d.ts.map +1 -1
  9. package/esm/src/api.js +84 -37
  10. package/esm/src/apis/chatgptScraper/brightdata.js +1 -1
  11. package/esm/src/apis/chatgptScraper/oxy.js +1 -1
  12. package/esm/src/apis/chatgptScraper/scraper.js +2 -2
  13. package/esm/src/apis/hasdata/aim.js +1 -1
  14. package/esm/src/apis/hasdata/aio.js +1 -1
  15. package/esm/src/apis/hasdata/helpers.d.ts +1 -1
  16. package/esm/src/apis/hasdata/helpers.d.ts.map +1 -1
  17. package/esm/src/apis/hasdata/helpers.js +2 -2
  18. package/esm/src/assets/models.d.ts +60725 -0
  19. package/esm/src/assets/models.d.ts.map +1 -0
  20. package/esm/src/assets/models.js +71915 -0
  21. package/esm/src/helpers/async.d.ts.map +1 -0
  22. package/esm/src/{async.js → helpers/async.js} +1 -1
  23. package/esm/src/helpers/seedKeywords.d.ts.map +1 -0
  24. package/esm/src/helpers/urls.d.ts.map +1 -0
  25. package/esm/src/helpers/utils.d.ts.map +1 -0
  26. package/esm/src/llm.d.ts +35 -0
  27. package/esm/src/llm.d.ts.map +1 -0
  28. package/esm/src/llm.js +59 -0
  29. package/esm/src/providers/google.d.ts +12 -0
  30. package/esm/src/providers/google.d.ts.map +1 -0
  31. package/esm/src/providers/google.js +111 -0
  32. package/esm/src/providers/index.d.ts +13 -0
  33. package/esm/src/providers/index.d.ts.map +1 -0
  34. package/esm/src/providers/index.js +14 -0
  35. package/esm/src/providers/openai.d.ts +12 -0
  36. package/esm/src/providers/openai.d.ts.map +1 -0
  37. package/esm/src/providers/openai.js +141 -0
  38. package/esm/src/providers/pricing.d.ts +72 -0
  39. package/esm/src/providers/pricing.d.ts.map +1 -0
  40. package/esm/src/providers/pricing.js +88 -0
  41. package/esm/src/providers/registry.d.ts +20 -0
  42. package/esm/src/providers/registry.d.ts.map +1 -0
  43. package/esm/src/providers/registry.js +35 -0
  44. package/esm/src/providers/types.d.ts +49 -0
  45. package/esm/src/providers/types.d.ts.map +1 -0
  46. package/esm/src/providers/types.js +7 -0
  47. package/esm/src/response.d.ts +74 -0
  48. package/esm/src/response.d.ts.map +1 -0
  49. package/esm/src/response.js +110 -0
  50. package/esm/src/tool.d.ts +58 -0
  51. package/esm/src/tool.d.ts.map +1 -0
  52. package/esm/src/tool.js +91 -0
  53. package/esm/src/tools/brands.js +6 -6
  54. package/esm/src/tools/classifier.d.ts +80 -17
  55. package/esm/src/tools/classifier.d.ts.map +1 -1
  56. package/esm/src/tools/classifier.js +68 -80
  57. package/esm/src/tools/entities.d.ts +23 -12
  58. package/esm/src/tools/entities.d.ts.map +1 -1
  59. package/esm/src/tools/entities.js +27 -47
  60. package/esm/src/tools/funnel.js +7 -7
  61. package/esm/src/tools/generic.d.ts +17 -4
  62. package/esm/src/tools/generic.d.ts.map +1 -1
  63. package/esm/src/tools/generic.js +39 -14
  64. package/esm/src/tools/keywords.js +5 -5
  65. package/esm/src/tools/personas.d.ts +49 -2
  66. package/esm/src/tools/personas.d.ts.map +1 -1
  67. package/esm/src/tools/personas.js +59 -35
  68. package/esm/src/tools/scorer.d.ts +24 -6
  69. package/esm/src/tools/scorer.d.ts.map +1 -1
  70. package/esm/src/tools/scorer.js +27 -22
  71. package/esm/src/tools/search.d.ts.map +1 -1
  72. package/esm/src/tools/search.js +33 -9
  73. package/esm/src/tools/sentiment.d.ts +30 -8
  74. package/esm/src/tools/sentiment.d.ts.map +1 -1
  75. package/esm/src/tools/sentiment.js +33 -28
  76. package/esm/src/tools/sources.d.ts +5 -5
  77. package/esm/src/tools/sources.d.ts.map +1 -1
  78. package/esm/src/tools/sources.js +5 -6
  79. package/esm/src/tools/topics.d.ts +44 -16
  80. package/esm/src/tools/topics.d.ts.map +1 -1
  81. package/esm/src/tools/topics.js +77 -68
  82. package/esm/src/tools/translate.d.ts +22 -31
  83. package/esm/src/tools/translate.d.ts.map +1 -1
  84. package/esm/src/tools/translate.js +40 -36
  85. package/package.json +2 -1
  86. package/script/browser.d.ts +1 -1
  87. package/script/browser.d.ts.map +1 -1
  88. package/script/browser.js +1 -1
  89. package/script/mod.d.ts +5 -2
  90. package/script/mod.d.ts.map +1 -1
  91. package/script/mod.js +14 -2
  92. package/script/src/api.d.ts +36 -5
  93. package/script/src/api.d.ts.map +1 -1
  94. package/script/src/api.js +84 -35
  95. package/script/src/apis/chatgptScraper/brightdata.js +1 -1
  96. package/script/src/apis/chatgptScraper/oxy.js +1 -1
  97. package/script/src/apis/chatgptScraper/scraper.js +2 -2
  98. package/script/src/apis/hasdata/aim.js +1 -1
  99. package/script/src/apis/hasdata/aio.js +1 -1
  100. package/script/src/apis/hasdata/helpers.d.ts +1 -1
  101. package/script/src/apis/hasdata/helpers.d.ts.map +1 -1
  102. package/script/src/apis/hasdata/helpers.js +2 -2
  103. package/script/src/assets/models.d.ts +60725 -0
  104. package/script/src/assets/models.d.ts.map +1 -0
  105. package/script/src/assets/models.js +71917 -0
  106. package/script/src/helpers/async.d.ts.map +1 -0
  107. package/script/src/{async.js → helpers/async.js} +1 -1
  108. package/script/src/helpers/seedKeywords.d.ts.map +1 -0
  109. package/script/src/helpers/urls.d.ts.map +1 -0
  110. package/script/src/helpers/utils.d.ts.map +1 -0
  111. package/script/src/llm.d.ts +35 -0
  112. package/script/src/llm.d.ts.map +1 -0
  113. package/script/src/llm.js +65 -0
  114. package/script/src/providers/google.d.ts +12 -0
  115. package/script/src/providers/google.d.ts.map +1 -0
  116. package/script/src/providers/google.js +148 -0
  117. package/script/src/providers/index.d.ts +13 -0
  118. package/script/src/providers/index.d.ts.map +1 -0
  119. package/script/src/providers/index.js +24 -0
  120. package/script/src/providers/openai.d.ts +12 -0
  121. package/script/src/providers/openai.d.ts.map +1 -0
  122. package/script/src/providers/openai.js +181 -0
  123. package/script/src/providers/pricing.d.ts +72 -0
  124. package/script/src/providers/pricing.d.ts.map +1 -0
  125. package/script/src/providers/pricing.js +97 -0
  126. package/script/src/providers/registry.d.ts +20 -0
  127. package/script/src/providers/registry.d.ts.map +1 -0
  128. package/script/src/providers/registry.js +39 -0
  129. package/script/src/providers/types.d.ts +49 -0
  130. package/script/src/providers/types.d.ts.map +1 -0
  131. package/script/src/providers/types.js +8 -0
  132. package/script/src/response.d.ts +74 -0
  133. package/script/src/response.d.ts.map +1 -0
  134. package/script/src/response.js +114 -0
  135. package/script/src/tool.d.ts +58 -0
  136. package/script/src/tool.d.ts.map +1 -0
  137. package/script/src/tool.js +95 -0
  138. package/script/src/tools/brands.js +6 -6
  139. package/script/src/tools/classifier.d.ts +80 -17
  140. package/script/src/tools/classifier.d.ts.map +1 -1
  141. package/script/src/tools/classifier.js +72 -85
  142. package/script/src/tools/entities.d.ts +23 -12
  143. package/script/src/tools/entities.d.ts.map +1 -1
  144. package/script/src/tools/entities.js +29 -51
  145. package/script/src/tools/funnel.js +7 -7
  146. package/script/src/tools/generic.d.ts +17 -4
  147. package/script/src/tools/generic.d.ts.map +1 -1
  148. package/script/src/tools/generic.js +39 -14
  149. package/script/src/tools/keywords.js +5 -5
  150. package/script/src/tools/personas.d.ts +49 -2
  151. package/script/src/tools/personas.d.ts.map +1 -1
  152. package/script/src/tools/personas.js +63 -36
  153. package/script/src/tools/scorer.d.ts +24 -6
  154. package/script/src/tools/scorer.d.ts.map +1 -1
  155. package/script/src/tools/scorer.js +28 -24
  156. package/script/src/tools/search.d.ts.map +1 -1
  157. package/script/src/tools/search.js +69 -9
  158. package/script/src/tools/sentiment.d.ts +30 -8
  159. package/script/src/tools/sentiment.d.ts.map +1 -1
  160. package/script/src/tools/sentiment.js +37 -30
  161. package/script/src/tools/sources.d.ts +5 -5
  162. package/script/src/tools/sources.d.ts.map +1 -1
  163. package/script/src/tools/sources.js +4 -5
  164. package/script/src/tools/topics.d.ts +44 -16
  165. package/script/src/tools/topics.d.ts.map +1 -1
  166. package/script/src/tools/topics.js +80 -72
  167. package/script/src/tools/translate.d.ts +22 -31
  168. package/script/src/tools/translate.d.ts.map +1 -1
  169. package/script/src/tools/translate.js +43 -40
  170. package/esm/src/async.d.ts.map +0 -1
  171. package/esm/src/models.d.ts +0 -18
  172. package/esm/src/models.d.ts.map +0 -1
  173. package/esm/src/models.js +0 -48
  174. package/esm/src/openai.d.ts +0 -17
  175. package/esm/src/openai.d.ts.map +0 -1
  176. package/esm/src/openai.js +0 -136
  177. package/esm/src/tools/seedKeywords.d.ts.map +0 -1
  178. package/esm/src/urls.d.ts.map +0 -1
  179. package/esm/src/utils.d.ts.map +0 -1
  180. package/script/src/async.d.ts.map +0 -1
  181. package/script/src/models.d.ts +0 -18
  182. package/script/src/models.d.ts.map +0 -1
  183. package/script/src/models.js +0 -52
  184. package/script/src/openai.d.ts +0 -17
  185. package/script/src/openai.d.ts.map +0 -1
  186. package/script/src/openai.js +0 -175
  187. package/script/src/tools/seedKeywords.d.ts.map +0 -1
  188. package/script/src/urls.d.ts.map +0 -1
  189. package/script/src/utils.d.ts.map +0 -1
  190. /package/esm/src/{async.d.ts → helpers/async.d.ts} +0 -0
  191. /package/esm/src/{tools → helpers}/seedKeywords.d.ts +0 -0
  192. /package/esm/src/{tools → helpers}/seedKeywords.js +0 -0
  193. /package/esm/src/{urls.d.ts → helpers/urls.d.ts} +0 -0
  194. /package/esm/src/{urls.js → helpers/urls.js} +0 -0
  195. /package/esm/src/{utils.d.ts → helpers/utils.d.ts} +0 -0
  196. /package/esm/src/{utils.js → helpers/utils.js} +0 -0
  197. /package/script/src/{async.d.ts → helpers/async.d.ts} +0 -0
  198. /package/script/src/{tools → helpers}/seedKeywords.d.ts +0 -0
  199. /package/script/src/{tools → helpers}/seedKeywords.js +0 -0
  200. /package/script/src/{urls.d.ts → helpers/urls.d.ts} +0 -0
  201. /package/script/src/{urls.js → helpers/urls.js} +0 -0
  202. /package/script/src/{utils.d.ts → helpers/utils.d.ts} +0 -0
  203. /package/script/src/{utils.js → helpers/utils.js} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../../src/src/helpers/async.ts"],"names":[],"mappings":"AAAA;;GAEG;AAYH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAyB1E;AAMD,MAAM,WAAW,WAAW;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC5B;AAED,eAAO,MAAM,cAAc;;;;;;CAM1B,CAAC;AAEF;;;GAGG;AACH,wBAAsB,WAAW,CAChC,EAAE,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,EAC3B,EACC,UAAsC,EACtC,YAA0C,EAC1C,QAAkC,EAClC,iBAAoD,EACpD,WAAwC,EACxC,GAAE,WAAgB,GACjB,OAAO,CAAC,QAAQ,CAAC,CA+CnB;AAMD;;;GAGG;AACH,wBAAsB,WAAW,CAAC,CAAC,EAAE,CAAC,EACrC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,EACzC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GAC/C,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CA0BnB"}
@@ -47,7 +47,7 @@ exports.mapParallel = mapParallel;
47
47
  * Sleeps for a specified duration. If an AbortSignal is provided and triggered,
48
48
  * the promise rejects with the abort reason and the timeout is cleared.
49
49
  */
50
- const dntShim = __importStar(require("../_dnt.shims.js"));
50
+ const dntShim = __importStar(require("../../_dnt.shims.js"));
51
51
  function sleep(ms, abortSignal) {
52
52
  return new Promise((resolve, reject) => {
53
53
  if (abortSignal?.aborted) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seedKeywords.d.ts","sourceRoot":"","sources":["../../../src/src/helpers/seedKeywords.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAGvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAOpE,UAAU,iBAAiB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC7B;AAED,UAAU,WAAW;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC7B;AAED,UAAU,kBAAkB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC7B;AAED,UAAU,eAAe;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC;CACvC;AAED,UAAU,cAAc;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;CACrC;AAMD,MAAM,WAAW,yBAAyB;IACzC,cAAc,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC1C,QAAQ,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC9B,YAAY,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IACtC,WAAW,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACpC,cAAc,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,EACnC,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,cAAc,EACd,EAAE,yBAAyB,GAAG,KAAK,CAAC,WAAW,CAAC,CA+EhD;AAcD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAChC,YAAY,EAAE,KAAK,CAAC,WAAW,CAAC,EAChC,sBAAsB,GAAE,OAAc,GACpC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC,CA8FzC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAClC,YAAY,EAAE,KAAK,CAAC,WAAW,CAAC,EAChC,sBAAsB,GAAE,OAAc,GACpC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAS/B;AAED;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC5C,MAAM,EAAE,yBAAyB,EACjC,sBAAsB,GAAE,OAAc,GACpC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAG/B"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urls.d.ts","sourceRoot":"","sources":["../../../src/src/helpers/urls.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAQzC;AAaD;;;GAGG;AACH,wBAAgB,aAAa,CAC5B,GAAG,EAAE,MAAM,EACX,aAAa,GAAE,OAAe,EAC9B,sBAAsB,GAAE,OAAc,GACpC,MAAM,CA6BR"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/src/helpers/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;;GAGG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA8B3C;AAwCD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMpD;AAMD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,CAoCrF;AAMD;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAYnE;AAMD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5D,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EACjB,KAAK,EAAE,MAAM,CAAC,GACZ,KAAK,CAAC,CAAC,CAAC,CAoBV;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EACjB,KAAK,EAAE,MAAM,CAAC,GACZ,KAAK,CAAC,CAAC,CAAC,CAgBV"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Unified LLM interface - provider-agnostic API for making LLM calls.
3
+ */
4
+ import type { z } from '../deps/jsr.io/@zod/zod/4.3.6/src/index.js';
5
+ import { type Message, type LLMResponse, type ProviderParams } from './providers/index.js';
6
+ export type { Message, LLMResponse, LLMProvider, ProviderParams, LLMConversation } from './providers/index.js';
7
+ export type { TokenUsage, UsageCost, AggregatedUsage } from './response.js';
8
+ export { calculateCost } from './providers/index.js';
9
+ /**
10
+ * Parameters for askLLMSafe.
11
+ */
12
+ export interface AskLLMParams<T = string> {
13
+ /** The prompt (string or message array) */
14
+ prompt: string | Message[];
15
+ /** The model to use (e.g., 'gpt-4.1-mini', 'gemini-2.0-flash') */
16
+ model: string;
17
+ /** Optional Zod schema for structured output */
18
+ schema?: z.ZodType<T> | null;
19
+ /** Provider-specific parameters */
20
+ params?: ProviderParams;
21
+ /** Maximum retry attempts (default: 3) */
22
+ maxRetries?: number;
23
+ /** Error handling mode: 'throw' or 'return' (default: 'throw') */
24
+ onError?: 'throw' | 'return';
25
+ }
26
+ /**
27
+ * Make a single LLM call with retry logic.
28
+ * Returns LLMResponse with raw TokenUsage (no cost calculation).
29
+ */
30
+ export declare function askLLMSafe<T = string>({ prompt, model, schema, params, maxRetries, onError, }: AskLLMParams<T>): Promise<LLMResponse<T>>;
31
+ /**
32
+ * Make a single LLM call without retry logic.
33
+ */
34
+ export declare function askLLM<T = string>(params: Omit<AskLLMParams<T>, 'maxRetries' | 'onError'>): Promise<LLMResponse<T>>;
35
+ //# sourceMappingURL=llm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../src/src/llm.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,4CAA4C,CAAC;AACpE,OAAO,EAAuB,KAAK,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGhH,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG/G,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,MAAM;IACvC,2CAA2C;IAC3C,MAAM,EAAE,MAAM,GAAG,OAAO,EAAE,CAAC;IAC3B,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAC7B,mCAAmC;IACnC,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC7B;AAYD;;;GAGG;AACH,wBAAsB,UAAU,CAAC,CAAC,GAAG,MAAM,EAAE,EAC5C,MAAM,EACN,KAAK,EACL,MAAM,EACN,MAAM,EACN,UAAc,EACd,OAAiB,GACjB,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAwC3C;AAED;;GAEG;AACH,wBAAsB,MAAM,CAAC,CAAC,GAAG,MAAM,EACtC,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC,GACrD,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAEzB"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ /**
3
+ * Unified LLM interface - provider-agnostic API for making LLM calls.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.calculateCost = void 0;
7
+ exports.askLLMSafe = askLLMSafe;
8
+ exports.askLLM = askLLM;
9
+ const index_js_1 = require("./providers/index.js");
10
+ var index_js_2 = require("./providers/index.js");
11
+ Object.defineProperty(exports, "calculateCost", { enumerable: true, get: function () { return index_js_2.calculateCost; } });
12
+ /**
13
+ * Normalize a prompt to a message array.
14
+ */
15
+ function normalizePrompt(prompt) {
16
+ if (Array.isArray(prompt)) {
17
+ return prompt;
18
+ }
19
+ return [{ role: 'user', content: prompt }];
20
+ }
21
+ /**
22
+ * Make a single LLM call with retry logic.
23
+ * Returns LLMResponse with raw TokenUsage (no cost calculation).
24
+ */
25
+ async function askLLMSafe({ prompt, model, schema, params, maxRetries = 3, onError = 'throw', }) {
26
+ const provider = (0, index_js_1.getProviderForModel)(model);
27
+ let messages = normalizePrompt(prompt);
28
+ let lastResponse = null;
29
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
30
+ const response = await provider.complete(messages, model, schema ?? null, params);
31
+ if (response.error === null && response.parsed !== null) {
32
+ return response;
33
+ }
34
+ lastResponse = {
35
+ parsed: null,
36
+ text: response.text,
37
+ usage: response.usage,
38
+ error: response.error ?? new Error('Unknown error'),
39
+ };
40
+ if (attempt < maxRetries && response.error) {
41
+ // Add error context to messages for retry
42
+ const errorMessage = `Previous attempt failed with error: ${response.error.message}`;
43
+ if (response.text) {
44
+ messages = [
45
+ ...messages,
46
+ {
47
+ role: 'system',
48
+ content: `${errorMessage}\nYour raw response was:\n${response.text}`,
49
+ },
50
+ ];
51
+ }
52
+ console.log(`askLLMSafe retrying! Attempt ${attempt + 1} failed: ${response.error.message}`);
53
+ }
54
+ }
55
+ if (onError === 'return') {
56
+ return lastResponse;
57
+ }
58
+ throw lastResponse.error;
59
+ }
60
+ /**
61
+ * Make a single LLM call without retry logic.
62
+ */
63
+ async function askLLM(params) {
64
+ return askLLMSafe({ ...params, maxRetries: 0, onError: 'throw' });
65
+ }
@@ -0,0 +1,12 @@
1
+ import { z } from '../../deps/jsr.io/@zod/zod/4.3.6/src/index.js';
2
+ import type { LLMProvider, LLMResponse, Message, ProviderParams } from './types.js';
3
+ /**
4
+ * Google LLM provider (for Gemini models).
5
+ */
6
+ export declare class GoogleProvider implements LLMProvider {
7
+ readonly name = "google";
8
+ private client;
9
+ constructor(apiKey?: string);
10
+ complete<T>(messages: Message[], model: string, schema: z.ZodType<T> | null, params?: ProviderParams): Promise<LLMResponse<T>>;
11
+ }
12
+ //# sourceMappingURL=google.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../../src/src/providers/google.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,CAAC,EAAE,MAAM,+CAA+C,CAAC;AAElE,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAuCpF;;GAEG;AACH,qBAAa,cAAe,YAAW,WAAW;IACjD,QAAQ,CAAC,IAAI,YAAY;IACzB,OAAO,CAAC,MAAM,CAAc;gBAEhB,MAAM,CAAC,EAAE,MAAM;IAUrB,QAAQ,CAAC,CAAC,EACf,QAAQ,EAAE,OAAO,EAAE,EACnB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,EAC3B,MAAM,CAAC,EAAE,cAAc,GACrB,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;CA8D1B"}
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.GoogleProvider = void 0;
37
+ /**
38
+ * Google provider implementation (for Gemini models).
39
+ */
40
+ const dntShim = __importStar(require("../../_dnt.shims.js"));
41
+ const genai_1 = require("@google/genai");
42
+ const index_js_1 = require("../../deps/jsr.io/@zod/zod/4.3.6/src/index.js");
43
+ /**
44
+ * Convert messages to Gemini content format.
45
+ * Handles system prompts by prepending them as context.
46
+ */
47
+ function convertMessages(messages) {
48
+ // For simple single message, return as string
49
+ if (messages.length === 1 && messages[0].role === 'user') {
50
+ return messages[0].content;
51
+ }
52
+ // Build system instruction and contents separately
53
+ const systemParts = [];
54
+ const contents = [];
55
+ for (const msg of messages) {
56
+ if (msg.role === 'system') {
57
+ systemParts.push(msg.content);
58
+ }
59
+ else {
60
+ contents.push({
61
+ role: msg.role === 'assistant' ? 'model' : 'user',
62
+ parts: [{ text: msg.content }],
63
+ });
64
+ }
65
+ }
66
+ // If we have system prompts, prepend to the first user message
67
+ if (systemParts.length > 0 && contents.length > 0) {
68
+ const systemContext = systemParts.join('\n\n');
69
+ const firstContent = contents[0];
70
+ if (firstContent.role === 'user' && firstContent.parts.length > 0) {
71
+ firstContent.parts[0].text = `${systemContext}\n\n${firstContent.parts[0].text}`;
72
+ }
73
+ }
74
+ return contents;
75
+ }
76
+ /**
77
+ * Google LLM provider (for Gemini models).
78
+ */
79
+ class GoogleProvider {
80
+ name = 'google';
81
+ client;
82
+ constructor(apiKey) {
83
+ const resolvedKey = apiKey ?? dntShim.Deno.env.get('GOOGLE_API_KEY') ?? dntShim.Deno.env.get('GEMINI_API_KEY');
84
+ if (!resolvedKey) {
85
+ throw new Error('GOOGLE_API_KEY or GEMINI_API_KEY environment variable is required');
86
+ }
87
+ this.client = new genai_1.GoogleGenAI({ apiKey: resolvedKey });
88
+ }
89
+ async complete(messages, model, schema, params) {
90
+ try {
91
+ const config = {
92
+ ...(params ?? {}),
93
+ };
94
+ if (schema != null) {
95
+ config.responseMimeType = 'application/json';
96
+ config.responseSchema = index_js_1.z.toJSONSchema(schema, { target: 'draft-7' });
97
+ }
98
+ const response = await this.client.models.generateContent({
99
+ model,
100
+ contents: convertMessages(messages),
101
+ config,
102
+ });
103
+ const text = response.text ?? '';
104
+ const usageMetadata = response.usageMetadata;
105
+ const usage = usageMetadata
106
+ ? {
107
+ inputTokens: usageMetadata.promptTokenCount ?? 0,
108
+ outputTokens: usageMetadata.candidatesTokenCount ?? 0,
109
+ totalTokens: usageMetadata.totalTokenCount ?? 0,
110
+ }
111
+ : null;
112
+ if (schema != null) {
113
+ try {
114
+ const parsed = schema.parse(JSON.parse(text));
115
+ return {
116
+ parsed,
117
+ text,
118
+ usage,
119
+ error: null,
120
+ };
121
+ }
122
+ catch (error) {
123
+ return {
124
+ parsed: null,
125
+ text,
126
+ usage,
127
+ error: error instanceof Error ? error : new Error(String(error)),
128
+ };
129
+ }
130
+ }
131
+ return {
132
+ parsed: text,
133
+ text,
134
+ usage,
135
+ error: null,
136
+ };
137
+ }
138
+ catch (error) {
139
+ return {
140
+ parsed: null,
141
+ text: null,
142
+ usage: null,
143
+ error: error instanceof Error ? error : new Error(String(error)),
144
+ };
145
+ }
146
+ }
147
+ }
148
+ exports.GoogleProvider = GoogleProvider;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Provider registry and pricing.
3
+ *
4
+ * This module consolidates all provider-related functionality:
5
+ * - Provider implementations (OpenAI, Google)
6
+ * - Cost calculation utilities
7
+ */
8
+ export { getProvider, getProviderForModel } from './registry.js';
9
+ export { OpenAIProvider } from './openai.js';
10
+ export { GoogleProvider } from './google.js';
11
+ export { getModelPricing, getModelInfo, calculateCost, type ModelPricing, type ModelInfo, } from './pricing.js';
12
+ export type { Message, LLMResponse, LLMProvider, ProviderParams, LLMConversation, } from './types.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGjE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,EACN,eAAe,EACf,YAAY,EACZ,aAAa,EACb,KAAK,YAAY,EACjB,KAAK,SAAS,GACd,MAAM,cAAc,CAAC;AAGtB,YAAY,EACX,OAAO,EACP,WAAW,EACX,WAAW,EACX,cAAc,EACd,eAAe,GACf,MAAM,YAAY,CAAC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /**
3
+ * Provider registry and pricing.
4
+ *
5
+ * This module consolidates all provider-related functionality:
6
+ * - Provider implementations (OpenAI, Google)
7
+ * - Cost calculation utilities
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.calculateCost = exports.getModelInfo = exports.getModelPricing = exports.GoogleProvider = exports.OpenAIProvider = exports.getProviderForModel = exports.getProvider = void 0;
11
+ // Re-export provider registry functions
12
+ var registry_js_1 = require("./registry.js");
13
+ Object.defineProperty(exports, "getProvider", { enumerable: true, get: function () { return registry_js_1.getProvider; } });
14
+ Object.defineProperty(exports, "getProviderForModel", { enumerable: true, get: function () { return registry_js_1.getProviderForModel; } });
15
+ // Re-export provider implementations
16
+ var openai_js_1 = require("./openai.js");
17
+ Object.defineProperty(exports, "OpenAIProvider", { enumerable: true, get: function () { return openai_js_1.OpenAIProvider; } });
18
+ var google_js_1 = require("./google.js");
19
+ Object.defineProperty(exports, "GoogleProvider", { enumerable: true, get: function () { return google_js_1.GoogleProvider; } });
20
+ // Re-export pricing utilities
21
+ var pricing_js_1 = require("./pricing.js");
22
+ Object.defineProperty(exports, "getModelPricing", { enumerable: true, get: function () { return pricing_js_1.getModelPricing; } });
23
+ Object.defineProperty(exports, "getModelInfo", { enumerable: true, get: function () { return pricing_js_1.getModelInfo; } });
24
+ Object.defineProperty(exports, "calculateCost", { enumerable: true, get: function () { return pricing_js_1.calculateCost; } });
@@ -0,0 +1,12 @@
1
+ import { z } from '../../deps/jsr.io/@zod/zod/4.3.6/src/index.js';
2
+ import type { LLMProvider, LLMResponse, Message, ProviderParams } from './types.js';
3
+ /**
4
+ * OpenAI LLM provider.
5
+ */
6
+ export declare class OpenAIProvider implements LLMProvider {
7
+ readonly name = "openai";
8
+ private client;
9
+ constructor(apiKey?: string);
10
+ complete<T>(messages: Message[], model: string, schema: z.ZodType<T> | null, params?: ProviderParams): Promise<LLMResponse<T>>;
11
+ }
12
+ //# sourceMappingURL=openai.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../src/src/providers/openai.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,CAAC,EAAE,MAAM,+CAA+C,CAAC;AAElE,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAyFpF;;GAEG;AACH,qBAAa,cAAe,YAAW,WAAW;IACjD,QAAQ,CAAC,IAAI,YAAY;IACzB,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,CAAC,EAAE,MAAM;IAarB,QAAQ,CAAC,CAAC,EACf,QAAQ,EAAE,OAAO,EAAE,EACnB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,EAC3B,MAAM,CAAC,EAAE,cAAc,GACrB,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;CAkD1B"}
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.OpenAIProvider = void 0;
40
+ /**
41
+ * OpenAI provider implementation.
42
+ */
43
+ const dntShim = __importStar(require("../../_dnt.shims.js"));
44
+ const openai_1 = __importDefault(require("openai"));
45
+ const index_js_1 = require("../../deps/jsr.io/@zod/zod/4.3.6/src/index.js");
46
+ const zodTextFormatCache = new Map();
47
+ class ZodValidationError extends Error {
48
+ }
49
+ /**
50
+ * Sanitizes a JSON schema for OpenAI compatibility.
51
+ * OpenAI's structured output has strict requirements:
52
+ * - additionalProperties must be false (not empty object or missing)
53
+ * - propertyNames is not permitted
54
+ */
55
+ function sanitizeSchemaForOpenAI(schema) {
56
+ const result = {};
57
+ for (const [key, value] of Object.entries(schema)) {
58
+ // Remove unsupported keys
59
+ if (key === 'propertyNames') {
60
+ continue;
61
+ }
62
+ // Handle additionalProperties - set to false for strict mode
63
+ if (key === 'additionalProperties') {
64
+ result[key] = false;
65
+ continue;
66
+ }
67
+ // Recursively sanitize nested objects
68
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
69
+ result[key] = sanitizeSchemaForOpenAI(value);
70
+ }
71
+ else if (Array.isArray(value)) {
72
+ result[key] = value.map(item => item && typeof item === 'object' && !Array.isArray(item)
73
+ ? sanitizeSchemaForOpenAI(item)
74
+ : item);
75
+ }
76
+ else {
77
+ result[key] = value;
78
+ }
79
+ }
80
+ // For object types without additionalProperties, add it as false
81
+ if (result['type'] === 'object' && !('additionalProperties' in result)) {
82
+ result['additionalProperties'] = false;
83
+ }
84
+ return result;
85
+ }
86
+ function getCachedZodTextFormat(zodObject, name) {
87
+ const cached = zodTextFormatCache.get(zodObject);
88
+ if (cached && cached.name === name) {
89
+ return cached;
90
+ }
91
+ const format = zodTextFormat(zodObject, name);
92
+ zodTextFormatCache.set(zodObject, format);
93
+ return format;
94
+ }
95
+ function zodTextFormat(zodObject, name) {
96
+ const rawSchema = index_js_1.z.toJSONSchema(zodObject, { target: 'draft-7' });
97
+ const sanitizedSchema = sanitizeSchemaForOpenAI(rawSchema);
98
+ return {
99
+ type: 'json_schema',
100
+ name,
101
+ strict: true,
102
+ schema: sanitizedSchema,
103
+ $brand: 'auto-parseable-response-format',
104
+ $parseRaw: (content) => {
105
+ try {
106
+ return zodObject.parse(JSON.parse(content));
107
+ }
108
+ catch (error) {
109
+ return new ZodValidationError(error instanceof Error ? error.message : String(error));
110
+ }
111
+ },
112
+ __output: undefined,
113
+ };
114
+ }
115
+ /**
116
+ * OpenAI LLM provider.
117
+ */
118
+ class OpenAIProvider {
119
+ name = 'openai';
120
+ client;
121
+ constructor(apiKey) {
122
+ const fetchOptions = {};
123
+ const abortSignal = dntShim.dntGlobalThis.abortSignal;
124
+ if (abortSignal) {
125
+ fetchOptions.signal = abortSignal;
126
+ }
127
+ this.client = new openai_1.default({
128
+ apiKey: apiKey ?? dntShim.Deno.env.get('OPENAI_API_KEY'),
129
+ fetchOptions,
130
+ });
131
+ }
132
+ async complete(messages, model, schema, params) {
133
+ try {
134
+ const response = await this.client.responses.parse({
135
+ ...params,
136
+ model,
137
+ input: messages.map((m) => ({
138
+ role: m.role,
139
+ content: m.content,
140
+ })),
141
+ ...(schema != null
142
+ ? {
143
+ text: {
144
+ format: getCachedZodTextFormat(schema, 'response'),
145
+ },
146
+ }
147
+ : {}),
148
+ });
149
+ const usage = response.usage
150
+ ? {
151
+ inputTokens: response.usage.input_tokens,
152
+ outputTokens: response.usage.output_tokens,
153
+ totalTokens: response.usage.total_tokens,
154
+ }
155
+ : null;
156
+ if (response.output_parsed instanceof Error) {
157
+ return {
158
+ parsed: null,
159
+ text: response.output_text,
160
+ usage,
161
+ error: response.output_parsed,
162
+ };
163
+ }
164
+ return {
165
+ parsed: schema != null ? response.output_parsed : response.output_text,
166
+ text: response.output_text,
167
+ usage,
168
+ error: null,
169
+ };
170
+ }
171
+ catch (error) {
172
+ return {
173
+ parsed: null,
174
+ text: null,
175
+ usage: null,
176
+ error: error instanceof Error ? error : new Error(String(error)),
177
+ };
178
+ }
179
+ }
180
+ }
181
+ exports.OpenAIProvider = OpenAIProvider;
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Model pricing lookup and cost calculation.
3
+ *
4
+ * Pricing data is bundled from models.dev at build time.
5
+ * Run `deno task update-models` to refresh the data.
6
+ */
7
+ import type { TokenUsage, UsageCost } from '../response.js';
8
+ /**
9
+ * Pricing information for a model (USD per 1M tokens).
10
+ */
11
+ export interface ModelPricing {
12
+ input: number;
13
+ output: number;
14
+ cacheRead?: number;
15
+ cacheWrite?: number;
16
+ reasoning?: number;
17
+ }
18
+ /**
19
+ * Model information including pricing and limits.
20
+ */
21
+ export interface ModelInfo {
22
+ id: string;
23
+ name: string;
24
+ provider: string;
25
+ pricing: ModelPricing | null;
26
+ contextLimit: number | null;
27
+ outputLimit: number | null;
28
+ capabilities: {
29
+ structuredOutput: boolean;
30
+ toolCall: boolean;
31
+ reasoning: boolean;
32
+ };
33
+ }
34
+ interface ModelEntry {
35
+ id: string;
36
+ name: string;
37
+ cost?: {
38
+ input?: number;
39
+ output?: number;
40
+ cache_read?: number;
41
+ cache_write?: number;
42
+ reasoning?: number;
43
+ };
44
+ limit?: {
45
+ context?: number;
46
+ output?: number;
47
+ };
48
+ structured_output?: boolean;
49
+ tool_call?: boolean;
50
+ reasoning?: boolean;
51
+ }
52
+ /**
53
+ * Look up a model entry by ID (with normalization fallback).
54
+ */
55
+ export declare function lookupModel(modelId: string): {
56
+ provider: string;
57
+ model: ModelEntry;
58
+ } | null;
59
+ /**
60
+ * Get pricing information for a model.
61
+ */
62
+ export declare function getModelPricing(modelId: string): ModelPricing | null;
63
+ /**
64
+ * Get full model information including pricing and capabilities.
65
+ */
66
+ export declare function getModelInfo(modelId: string): ModelInfo | null;
67
+ /**
68
+ * Calculate cost for token usage.
69
+ */
70
+ export declare function calculateCost(modelId: string, usage: TokenUsage): UsageCost | null;
71
+ export {};
72
+ //# sourceMappingURL=pricing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../../../src/src/providers/pricing.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IAC7B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE;QACb,gBAAgB,EAAE,OAAO,CAAC;QAC1B,QAAQ,EAAE,OAAO,CAAC;QAClB,SAAS,EAAE,OAAO,CAAC;KACnB,CAAC;CACF;AAGD,UAAU,UAAU;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE;QACN,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,SAAS,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,KAAK,CAAC,EAAE;QACP,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AA4BD;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,GAAG,IAAI,CAE3F;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAoBpE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAsB9D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI,CAgBlF"}