@use-lattice/litmus 0.121.3

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 (199) hide show
  1. package/LICENSE +19 -0
  2. package/dist/src/accounts-Bt1oJb1Z.cjs +219 -0
  3. package/dist/src/accounts-DjOU8Rm3.js +178 -0
  4. package/dist/src/agentic-utils-D03IiXQc.js +153 -0
  5. package/dist/src/agentic-utils-Dh7xaMQM.cjs +180 -0
  6. package/dist/src/agents-C6BIMlZa.js +231 -0
  7. package/dist/src/agents-DvIpNX1L.cjs +666 -0
  8. package/dist/src/agents-ZP0RP9vV.cjs +231 -0
  9. package/dist/src/agents-maJXdjbR.js +665 -0
  10. package/dist/src/aimlapi-BTbQjG2E.cjs +30 -0
  11. package/dist/src/aimlapi-CwMxqfXP.js +30 -0
  12. package/dist/src/audio-BBUdvsde.cjs +97 -0
  13. package/dist/src/audio-D5DPZ7I-.js +97 -0
  14. package/dist/src/base-BEysXrkq.cjs +222 -0
  15. package/dist/src/base-C451JQfq.js +193 -0
  16. package/dist/src/blobs-BY8MDmpo.js +230 -0
  17. package/dist/src/blobs-BgcNn97m.cjs +256 -0
  18. package/dist/src/cache-BBE_lsTA.cjs +4 -0
  19. package/dist/src/cache-BkrqU5Ba.js +237 -0
  20. package/dist/src/cache-DsCxFlsZ.cjs +297 -0
  21. package/dist/src/chat-CPJWDP6a.cjs +289 -0
  22. package/dist/src/chat-CXX3xzkk.cjs +811 -0
  23. package/dist/src/chat-CcDgZFJ4.js +787 -0
  24. package/dist/src/chat-Dz5ZeGO2.js +289 -0
  25. package/dist/src/chatkit-Dw0mKkML.cjs +1158 -0
  26. package/dist/src/chatkit-swAIVuea.js +1157 -0
  27. package/dist/src/chunk-DEq-mXcV.js +15 -0
  28. package/dist/src/claude-agent-sdk-BXZJtOg6.js +379 -0
  29. package/dist/src/claude-agent-sdk-CkfyjDoG.cjs +383 -0
  30. package/dist/src/cloudflare-ai-BzpJcqUH.js +161 -0
  31. package/dist/src/cloudflare-ai-Cmy_R1y2.cjs +161 -0
  32. package/dist/src/cloudflare-gateway-B9tVQKok.cjs +272 -0
  33. package/dist/src/cloudflare-gateway-DrD3ew3H.js +272 -0
  34. package/dist/src/codex-sdk-Dezj9Nwm.js +1056 -0
  35. package/dist/src/codex-sdk-Dl9D4k5B.cjs +1060 -0
  36. package/dist/src/cometapi-C-9YvCHC.js +54 -0
  37. package/dist/src/cometapi-DHgDKoO2.cjs +54 -0
  38. package/dist/src/completion-B8Ctyxpr.js +120 -0
  39. package/dist/src/completion-Cxrt08sj.cjs +131 -0
  40. package/dist/src/createHash-BwgE13yv.cjs +27 -0
  41. package/dist/src/createHash-DmPQkvBh.js +15 -0
  42. package/dist/src/docker-BiqcTwLv.js +80 -0
  43. package/dist/src/docker-C7tEJnP-.cjs +80 -0
  44. package/dist/src/esm-C62Zofr1.cjs +409 -0
  45. package/dist/src/esm-DMVc93eh.js +379 -0
  46. package/dist/src/evalResult-C3NJPQOo.cjs +301 -0
  47. package/dist/src/evalResult-C7JJAPBb.js +295 -0
  48. package/dist/src/evalResult-DoVTZZWI.cjs +2 -0
  49. package/dist/src/extractor-DnMD3fwt.cjs +391 -0
  50. package/dist/src/extractor-DtlL28vL.js +374 -0
  51. package/dist/src/fetch-BTxakTSg.cjs +1133 -0
  52. package/dist/src/fetch-DQckpUFz.js +928 -0
  53. package/dist/src/fileExtensions-DnqA1y9x.js +85 -0
  54. package/dist/src/fileExtensions-bYh77CN8.cjs +114 -0
  55. package/dist/src/genaiTracer-CyZrmaK0.cjs +268 -0
  56. package/dist/src/genaiTracer-D3fD9dNV.js +256 -0
  57. package/dist/src/graders-BNscxFrU.js +13644 -0
  58. package/dist/src/graders-D2oE9Msq.js +2 -0
  59. package/dist/src/graders-c0Ez_w-9.cjs +2 -0
  60. package/dist/src/graders-d0F2M3e9.cjs +14056 -0
  61. package/dist/src/image-0ZhE0VlR.cjs +280 -0
  62. package/dist/src/image-CWE1pdNv.js +257 -0
  63. package/dist/src/image-D9ZK6hwL.js +163 -0
  64. package/dist/src/image-DKZgZITg.cjs +163 -0
  65. package/dist/src/index.cjs +11366 -0
  66. package/dist/src/index.d.cts +19640 -0
  67. package/dist/src/index.d.ts +19641 -0
  68. package/dist/src/index.js +11306 -0
  69. package/dist/src/invariant-Ddh24eXh.js +25 -0
  70. package/dist/src/invariant-kfQ8Bu82.cjs +30 -0
  71. package/dist/src/knowledgeBase-BgPyGFUd.cjs +122 -0
  72. package/dist/src/knowledgeBase-DyHilYaP.js +122 -0
  73. package/dist/src/litellm-CyMeneHS.js +135 -0
  74. package/dist/src/litellm-DWDF73yF.cjs +135 -0
  75. package/dist/src/logger-C40ZGil9.js +717 -0
  76. package/dist/src/logger-DyfK9PBt.cjs +917 -0
  77. package/dist/src/luma-ray-BAU9X_ep.cjs +315 -0
  78. package/dist/src/luma-ray-nwVseBbv.js +313 -0
  79. package/dist/src/messages-B5ADWTTv.js +245 -0
  80. package/dist/src/messages-BCnZfqrS.cjs +257 -0
  81. package/dist/src/meteor-DLZZ3osF.cjs +134 -0
  82. package/dist/src/meteor-DUiCJRC-.js +134 -0
  83. package/dist/src/modelslab-00cveB8L.cjs +163 -0
  84. package/dist/src/modelslab-D9sCU_L7.js +163 -0
  85. package/dist/src/nova-reel-CTapvqYH.js +276 -0
  86. package/dist/src/nova-reel-DlWuuroF.cjs +278 -0
  87. package/dist/src/nova-sonic-5UPWfeMv.cjs +363 -0
  88. package/dist/src/nova-sonic-BhSwQNym.js +363 -0
  89. package/dist/src/openai-BWrJK9d8.cjs +52 -0
  90. package/dist/src/openai-DumO8WQn.js +47 -0
  91. package/dist/src/openclaw-B8brrjC_.cjs +577 -0
  92. package/dist/src/openclaw-Bkayww9q.js +571 -0
  93. package/dist/src/opencode-sdk-7xjoDNiM.cjs +562 -0
  94. package/dist/src/opencode-sdk-SGwAPxht.js +558 -0
  95. package/dist/src/otlpReceiver-CoAHfAN9.cjs +15 -0
  96. package/dist/src/otlpReceiver-oO3EQwI9.js +14 -0
  97. package/dist/src/providerRegistry-4yjhaEM8.js +45 -0
  98. package/dist/src/providerRegistry-DhV4rJIc.cjs +50 -0
  99. package/dist/src/providers-B5RJVG-7.cjs +33609 -0
  100. package/dist/src/providers-BdmZCLzV.js +33262 -0
  101. package/dist/src/providers-CxtRxn8e.js +2 -0
  102. package/dist/src/providers-DnQLNbx1.cjs +3 -0
  103. package/dist/src/pythonUtils-BD0druiM.cjs +275 -0
  104. package/dist/src/pythonUtils-IBhn5YGR.js +249 -0
  105. package/dist/src/quiverai-BDOwZBsM.cjs +213 -0
  106. package/dist/src/quiverai-D3JTF5lD.js +213 -0
  107. package/dist/src/responses-B2LCDCXZ.js +667 -0
  108. package/dist/src/responses-BvNm4Xv9.cjs +685 -0
  109. package/dist/src/rubyUtils-B0NwnfpY.cjs +245 -0
  110. package/dist/src/rubyUtils-BroxzZ7c.cjs +2 -0
  111. package/dist/src/rubyUtils-hqVw5UvJ.js +222 -0
  112. package/dist/src/sagemaker-Cno2V-Sx.js +689 -0
  113. package/dist/src/sagemaker-fV_KUgs5.cjs +691 -0
  114. package/dist/src/server-BOuAXb06.cjs +238 -0
  115. package/dist/src/server-CtI-EWzm.cjs +2 -0
  116. package/dist/src/server-Cy3DZymt.js +189 -0
  117. package/dist/src/slack-CP8xBePa.js +135 -0
  118. package/dist/src/slack-DSQ1yXVb.cjs +135 -0
  119. package/dist/src/store-BwDDaBjb.cjs +246 -0
  120. package/dist/src/store-DcbLC593.cjs +2 -0
  121. package/dist/src/store-IGpqMIkv.js +240 -0
  122. package/dist/src/tables-3Q2cL7So.cjs +373 -0
  123. package/dist/src/tables-Bi2fjr4W.js +288 -0
  124. package/dist/src/telemetry-Bg2WqF79.js +161 -0
  125. package/dist/src/telemetry-D0x6u5kX.cjs +166 -0
  126. package/dist/src/telemetry-DXNimrI0.cjs +2 -0
  127. package/dist/src/text-B_UCRPp2.js +22 -0
  128. package/dist/src/text-CW1cyrwj.cjs +33 -0
  129. package/dist/src/tokenUsageUtils-NYT-WKS6.js +138 -0
  130. package/dist/src/tokenUsageUtils-bVa1ga6f.cjs +173 -0
  131. package/dist/src/transcription-Cl_W16Pr.js +122 -0
  132. package/dist/src/transcription-yt1EecY8.cjs +124 -0
  133. package/dist/src/transform-BCtGrl_W.cjs +228 -0
  134. package/dist/src/transform-Bv6gG2MJ.cjs +1688 -0
  135. package/dist/src/transform-CY1wbpRy.js +1507 -0
  136. package/dist/src/transform-DU8rUL9P.cjs +2 -0
  137. package/dist/src/transform-yWaShiKr.js +216 -0
  138. package/dist/src/transformersAvailability-BGkzavwb.js +35 -0
  139. package/dist/src/transformersAvailability-DKoRtQLy.cjs +35 -0
  140. package/dist/src/types-5aqHpBwE.cjs +3769 -0
  141. package/dist/src/types-Bn6D9c4U.js +3300 -0
  142. package/dist/src/util-BkKlTkI2.js +293 -0
  143. package/dist/src/util-CTh0bfOm.cjs +1119 -0
  144. package/dist/src/util-D17oBwo7.cjs +328 -0
  145. package/dist/src/util-DsS_-v4p.js +613 -0
  146. package/dist/src/util-DuntT1Ga.js +951 -0
  147. package/dist/src/util-aWjdCYMI.cjs +667 -0
  148. package/dist/src/utils-CisQwpjA.js +94 -0
  149. package/dist/src/utils-yWamDvmz.cjs +123 -0
  150. package/dist/tsconfig.tsbuildinfo +1 -0
  151. package/drizzle/0000_lush_hellion.sql +36 -0
  152. package/drizzle/0001_wide_calypso.sql +3 -0
  153. package/drizzle/0002_tidy_juggernaut.sql +1 -0
  154. package/drizzle/0003_lively_naoko.sql +8 -0
  155. package/drizzle/0004_minor_peter_quill.sql +19 -0
  156. package/drizzle/0005_silky_millenium_guard.sql +2 -0
  157. package/drizzle/0006_harsh_caretaker.sql +42 -0
  158. package/drizzle/0007_cloudy_wong.sql +1 -0
  159. package/drizzle/0008_broad_boomer.sql +2 -0
  160. package/drizzle/0009_strong_marten_broadcloak.sql +19 -0
  161. package/drizzle/0010_needy_bishop.sql +11 -0
  162. package/drizzle/0011_moaning_millenium_guard.sql +1 -0
  163. package/drizzle/0012_late_marten_broadcloak.sql +2 -0
  164. package/drizzle/0013_previous_dormammu.sql +9 -0
  165. package/drizzle/0014_lazy_captain_universe.sql +2 -0
  166. package/drizzle/0015_zippy_wallop.sql +29 -0
  167. package/drizzle/0016_jazzy_zemo.sql +2 -0
  168. package/drizzle/0017_reflective_praxagora.sql +4 -0
  169. package/drizzle/0018_fat_vanisher.sql +22 -0
  170. package/drizzle/0019_new_clint_barton.sql +8 -0
  171. package/drizzle/0020_skinny_maverick.sql +1 -0
  172. package/drizzle/0021_mysterious_madelyne_pryor.sql +13 -0
  173. package/drizzle/0022_sleepy_ultimo.sql +25 -0
  174. package/drizzle/0023_wooden_mandrill.sql +2 -0
  175. package/drizzle/AGENTS.md +68 -0
  176. package/drizzle/CLAUDE.md +1 -0
  177. package/drizzle/meta/0000_snapshot.json +221 -0
  178. package/drizzle/meta/0001_snapshot.json +214 -0
  179. package/drizzle/meta/0002_snapshot.json +221 -0
  180. package/drizzle/meta/0005_snapshot.json +369 -0
  181. package/drizzle/meta/0006_snapshot.json +638 -0
  182. package/drizzle/meta/0007_snapshot.json +640 -0
  183. package/drizzle/meta/0008_snapshot.json +649 -0
  184. package/drizzle/meta/0009_snapshot.json +554 -0
  185. package/drizzle/meta/0010_snapshot.json +619 -0
  186. package/drizzle/meta/0011_snapshot.json +627 -0
  187. package/drizzle/meta/0012_snapshot.json +639 -0
  188. package/drizzle/meta/0013_snapshot.json +717 -0
  189. package/drizzle/meta/0014_snapshot.json +717 -0
  190. package/drizzle/meta/0015_snapshot.json +897 -0
  191. package/drizzle/meta/0016_snapshot.json +1031 -0
  192. package/drizzle/meta/0018_snapshot.json +1210 -0
  193. package/drizzle/meta/0019_snapshot.json +1165 -0
  194. package/drizzle/meta/0020_snapshot.json +1232 -0
  195. package/drizzle/meta/0021_snapshot.json +1311 -0
  196. package/drizzle/meta/0022_snapshot.json +1481 -0
  197. package/drizzle/meta/0023_snapshot.json +1496 -0
  198. package/drizzle/meta/_journal.json +174 -0
  199. package/package.json +240 -0
@@ -0,0 +1,30 @@
1
+ import "./logger-C40ZGil9.js";
2
+ import "./fetch-DQckpUFz.js";
3
+ import "./cache-BkrqU5Ba.js";
4
+ import { t as OpenAiChatCompletionProvider } from "./chat-CcDgZFJ4.js";
5
+ import { n as OpenAiEmbeddingProvider, t as OpenAiCompletionProvider } from "./completion-B8Ctyxpr.js";
6
+ //#region src/providers/aimlapi.ts
7
+ /**
8
+ * Factory for creating AI/ML API providers using OpenAI-compatible endpoints.
9
+ */
10
+ function createAimlApiProvider(providerPath, options = {}) {
11
+ const splits = providerPath.split(":");
12
+ const type = splits[1];
13
+ const modelName = splits.slice(2).join(":");
14
+ const openaiOptions = {
15
+ ...options,
16
+ config: {
17
+ ...options.config || {},
18
+ apiBaseUrl: "https://api.aimlapi.com/v1",
19
+ apiKeyEnvar: "AIML_API_KEY"
20
+ }
21
+ };
22
+ if (type === "chat") return new OpenAiChatCompletionProvider(modelName, openaiOptions);
23
+ else if (type === "completion") return new OpenAiCompletionProvider(modelName, openaiOptions);
24
+ else if (type === "embedding" || type === "embeddings") return new OpenAiEmbeddingProvider(modelName, openaiOptions);
25
+ return new OpenAiChatCompletionProvider(splits.slice(1).join(":"), openaiOptions);
26
+ }
27
+ //#endregion
28
+ export { createAimlApiProvider };
29
+
30
+ //# sourceMappingURL=aimlapi-CwMxqfXP.js.map
@@ -0,0 +1,97 @@
1
+ const require_logger = require("./logger-DyfK9PBt.cjs");
2
+ const require_fetch = require("./fetch-BTxakTSg.cjs");
3
+ const require_cache = require("./cache-DsCxFlsZ.cjs");
4
+ //#region src/providers/hyperbolic/audio.ts
5
+ const HYPERBOLIC_AUDIO_MODELS = [{
6
+ id: "Melo-TTS",
7
+ aliases: ["melo-tts", "melo"],
8
+ cost: .001
9
+ }];
10
+ var HyperbolicAudioProvider = class {
11
+ modelName;
12
+ config;
13
+ env;
14
+ constructor(modelName, options = {}) {
15
+ this.modelName = modelName || "Melo-TTS";
16
+ this.config = options.config || {};
17
+ this.env = options.env;
18
+ }
19
+ getApiKey() {
20
+ if (this.config?.apiKey) return this.config.apiKey;
21
+ return this.env?.HYPERBOLIC_API_KEY || require_logger.getEnvString("HYPERBOLIC_API_KEY");
22
+ }
23
+ getApiUrl() {
24
+ return this.config?.apiBaseUrl || "https://api.hyperbolic.xyz/v1";
25
+ }
26
+ id() {
27
+ return `hyperbolic:audio:${this.modelName}`;
28
+ }
29
+ toString() {
30
+ return `[Hyperbolic Audio Provider ${this.modelName}]`;
31
+ }
32
+ getApiModelName() {
33
+ return HYPERBOLIC_AUDIO_MODELS.find((m) => m.id === this.modelName || m.aliases && m.aliases.includes(this.modelName))?.id || this.modelName;
34
+ }
35
+ calculateAudioCost(textLength) {
36
+ const costPer1000Chars = HYPERBOLIC_AUDIO_MODELS.find((m) => m.id === this.modelName || m.aliases && m.aliases.includes(this.modelName))?.cost || .001;
37
+ return textLength / 1e3 * costPer1000Chars;
38
+ }
39
+ async callApi(prompt, context, _callApiOptions) {
40
+ const apiKey = this.getApiKey();
41
+ if (!apiKey) throw new Error("Hyperbolic API key is not set. Set the HYPERBOLIC_API_KEY environment variable or add `apiKey` to the provider config.");
42
+ const config = {
43
+ ...this.config,
44
+ ...context?.prompt?.config
45
+ };
46
+ const endpoint = "/audio/generation";
47
+ const body = { text: prompt };
48
+ if (config.model) body.model = config.model;
49
+ if (config.voice) body.voice = config.voice;
50
+ if (config.speed !== void 0) body.speed = config.speed;
51
+ if (config.language) body.language = config.language;
52
+ const headers = {
53
+ "Content-Type": "application/json",
54
+ Authorization: `Bearer ${apiKey}`
55
+ };
56
+ let data, status, statusText, latencyMs;
57
+ let cached = false;
58
+ try {
59
+ ({data, cached, status, statusText, latencyMs} = await require_cache.fetchWithCache(`${this.getApiUrl()}${endpoint}`, {
60
+ method: "POST",
61
+ headers,
62
+ body: JSON.stringify(body)
63
+ }, require_fetch.REQUEST_TIMEOUT_MS));
64
+ if (status < 200 || status >= 300) return { error: `API error: ${status} ${statusText}\n${typeof data === "string" ? data : JSON.stringify(data)}` };
65
+ } catch (err) {
66
+ require_logger.logger.error(`API call error: ${String(err)}`);
67
+ return { error: `API call error: ${String(err)}` };
68
+ }
69
+ if (data.error) return { error: typeof data.error === "string" ? data.error : JSON.stringify(data.error) };
70
+ try {
71
+ if (!data.audio) return { error: "No audio data returned from API" };
72
+ const cost = cached ? 0 : this.calculateAudioCost(prompt.length);
73
+ return {
74
+ output: data.audio,
75
+ cached,
76
+ latencyMs,
77
+ cost,
78
+ ...data.audio ? {
79
+ isBase64: true,
80
+ audio: {
81
+ data: data.audio,
82
+ format: "wav"
83
+ }
84
+ } : {}
85
+ };
86
+ } catch (err) {
87
+ return { error: `API error: ${String(err)}: ${JSON.stringify(data)}` };
88
+ }
89
+ }
90
+ };
91
+ function createHyperbolicAudioProvider(providerPath, options = {}) {
92
+ return new HyperbolicAudioProvider(providerPath.split(":").slice(2).join(":") || "Melo-TTS", options);
93
+ }
94
+ //#endregion
95
+ exports.createHyperbolicAudioProvider = createHyperbolicAudioProvider;
96
+
97
+ //# sourceMappingURL=audio-BBUdvsde.cjs.map
@@ -0,0 +1,97 @@
1
+ import { r as logger, x as getEnvString } from "./logger-C40ZGil9.js";
2
+ import { h as REQUEST_TIMEOUT_MS } from "./fetch-DQckpUFz.js";
3
+ import { r as fetchWithCache } from "./cache-BkrqU5Ba.js";
4
+ //#region src/providers/hyperbolic/audio.ts
5
+ const HYPERBOLIC_AUDIO_MODELS = [{
6
+ id: "Melo-TTS",
7
+ aliases: ["melo-tts", "melo"],
8
+ cost: .001
9
+ }];
10
+ var HyperbolicAudioProvider = class {
11
+ modelName;
12
+ config;
13
+ env;
14
+ constructor(modelName, options = {}) {
15
+ this.modelName = modelName || "Melo-TTS";
16
+ this.config = options.config || {};
17
+ this.env = options.env;
18
+ }
19
+ getApiKey() {
20
+ if (this.config?.apiKey) return this.config.apiKey;
21
+ return this.env?.HYPERBOLIC_API_KEY || getEnvString("HYPERBOLIC_API_KEY");
22
+ }
23
+ getApiUrl() {
24
+ return this.config?.apiBaseUrl || "https://api.hyperbolic.xyz/v1";
25
+ }
26
+ id() {
27
+ return `hyperbolic:audio:${this.modelName}`;
28
+ }
29
+ toString() {
30
+ return `[Hyperbolic Audio Provider ${this.modelName}]`;
31
+ }
32
+ getApiModelName() {
33
+ return HYPERBOLIC_AUDIO_MODELS.find((m) => m.id === this.modelName || m.aliases && m.aliases.includes(this.modelName))?.id || this.modelName;
34
+ }
35
+ calculateAudioCost(textLength) {
36
+ const costPer1000Chars = HYPERBOLIC_AUDIO_MODELS.find((m) => m.id === this.modelName || m.aliases && m.aliases.includes(this.modelName))?.cost || .001;
37
+ return textLength / 1e3 * costPer1000Chars;
38
+ }
39
+ async callApi(prompt, context, _callApiOptions) {
40
+ const apiKey = this.getApiKey();
41
+ if (!apiKey) throw new Error("Hyperbolic API key is not set. Set the HYPERBOLIC_API_KEY environment variable or add `apiKey` to the provider config.");
42
+ const config = {
43
+ ...this.config,
44
+ ...context?.prompt?.config
45
+ };
46
+ const endpoint = "/audio/generation";
47
+ const body = { text: prompt };
48
+ if (config.model) body.model = config.model;
49
+ if (config.voice) body.voice = config.voice;
50
+ if (config.speed !== void 0) body.speed = config.speed;
51
+ if (config.language) body.language = config.language;
52
+ const headers = {
53
+ "Content-Type": "application/json",
54
+ Authorization: `Bearer ${apiKey}`
55
+ };
56
+ let data, status, statusText, latencyMs;
57
+ let cached = false;
58
+ try {
59
+ ({data, cached, status, statusText, latencyMs} = await fetchWithCache(`${this.getApiUrl()}${endpoint}`, {
60
+ method: "POST",
61
+ headers,
62
+ body: JSON.stringify(body)
63
+ }, REQUEST_TIMEOUT_MS));
64
+ if (status < 200 || status >= 300) return { error: `API error: ${status} ${statusText}\n${typeof data === "string" ? data : JSON.stringify(data)}` };
65
+ } catch (err) {
66
+ logger.error(`API call error: ${String(err)}`);
67
+ return { error: `API call error: ${String(err)}` };
68
+ }
69
+ if (data.error) return { error: typeof data.error === "string" ? data.error : JSON.stringify(data.error) };
70
+ try {
71
+ if (!data.audio) return { error: "No audio data returned from API" };
72
+ const cost = cached ? 0 : this.calculateAudioCost(prompt.length);
73
+ return {
74
+ output: data.audio,
75
+ cached,
76
+ latencyMs,
77
+ cost,
78
+ ...data.audio ? {
79
+ isBase64: true,
80
+ audio: {
81
+ data: data.audio,
82
+ format: "wav"
83
+ }
84
+ } : {}
85
+ };
86
+ } catch (err) {
87
+ return { error: `API error: ${String(err)}: ${JSON.stringify(data)}` };
88
+ }
89
+ }
90
+ };
91
+ function createHyperbolicAudioProvider(providerPath, options = {}) {
92
+ return new HyperbolicAudioProvider(providerPath.split(":").slice(2).join(":") || "Melo-TTS", options);
93
+ }
94
+ //#endregion
95
+ export { createHyperbolicAudioProvider };
96
+
97
+ //# sourceMappingURL=audio-D5DPZ7I-.js.map
@@ -0,0 +1,222 @@
1
+ const require_logger = require("./logger-DyfK9PBt.cjs");
2
+ const require_telemetry = require("./telemetry-D0x6u5kX.cjs");
3
+ //#region src/providers/bedrock/util.ts
4
+ const REQUEST_TIMEOUT_MS = 3e5;
5
+ function hasProxyEnv() {
6
+ return Boolean(require_logger.getEnvString("HTTP_PROXY") || require_logger.getEnvString("HTTPS_PROXY"));
7
+ }
8
+ /**
9
+ * Creates a NodeHttpHandler (HTTP/1.1) for Bedrock SDK clients.
10
+ *
11
+ * The @aws-sdk/client-bedrock-runtime package defaults to HTTP/2, which causes
12
+ * "http2 request did not get a response" errors in many environments (see #7756).
13
+ * This function forces HTTP/1.1 via NodeHttpHandler.
14
+ *
15
+ * For @aws-sdk/client-bedrock-agent-runtime (which already defaults to HTTP/1.1),
16
+ * this is only needed when proxy or API key authentication is required.
17
+ */
18
+ async function createBedrockRequestHandler(options) {
19
+ const hasProxy = hasProxyEnv();
20
+ try {
21
+ const { NodeHttpHandler } = await import("@smithy/node-http-handler");
22
+ let proxyAgent;
23
+ if (hasProxy) {
24
+ const { ProxyAgent } = await import("proxy-agent");
25
+ proxyAgent = new ProxyAgent();
26
+ }
27
+ const handler = new NodeHttpHandler({
28
+ ...proxyAgent ? { httpsAgent: proxyAgent } : {},
29
+ requestTimeout: REQUEST_TIMEOUT_MS
30
+ });
31
+ if (options?.apiKey) {
32
+ const originalHandle = handler.handle.bind(handler);
33
+ handler.handle = async (request, handlerOptions) => {
34
+ request.headers = {
35
+ ...request.headers,
36
+ Authorization: `Bearer ${options.apiKey}`
37
+ };
38
+ return originalHandle(request, handlerOptions);
39
+ };
40
+ }
41
+ return handler;
42
+ } catch {
43
+ const reason = options?.apiKey ? "API key authentication requires the @smithy/node-http-handler package" : hasProxy ? "Proxy configuration requires the @smithy/node-http-handler package" : "Bedrock provider requires the @smithy/node-http-handler package";
44
+ throw new Error(`${reason}. Please install it in your project or globally.`);
45
+ }
46
+ }
47
+ function novaOutputFromMessage(response) {
48
+ if (response.output?.message?.content.some((block) => block.toolUse?.toolUseId)) return response.output?.message?.content.map((block) => {
49
+ if (block.text) return null;
50
+ return JSON.stringify(block.toolUse);
51
+ }).filter((block) => block).join("\n\n");
52
+ return response.output?.message?.content.map((block) => {
53
+ return block.text;
54
+ }).join("\n\n");
55
+ }
56
+ function novaParseMessages(messages) {
57
+ try {
58
+ const parsed = JSON.parse(messages);
59
+ if (Array.isArray(parsed)) {
60
+ const systemMessage = parsed.find((msg) => msg.role === "system");
61
+ return {
62
+ extractedMessages: parsed.filter((msg) => msg.role !== "system").map((msg) => ({
63
+ role: msg.role,
64
+ content: Array.isArray(msg.content) ? msg.content : [{ text: msg.content }]
65
+ })),
66
+ system: systemMessage ? Array.isArray(systemMessage.content) ? systemMessage.content : [{ text: systemMessage.content }] : void 0
67
+ };
68
+ }
69
+ } catch {}
70
+ const lines = messages.split("\n").map((line) => line.trim()).filter((line) => line);
71
+ let system;
72
+ const extractedMessages = [];
73
+ let currentRole = null;
74
+ let currentContent = [];
75
+ const pushMessage = () => {
76
+ if (currentRole && currentContent.length > 0) {
77
+ extractedMessages.push({
78
+ role: currentRole,
79
+ content: [{ text: currentContent.join("\n") }]
80
+ });
81
+ currentContent = [];
82
+ }
83
+ };
84
+ for (const line of lines) if (line.startsWith("system:")) system = [{ text: line.slice(7).trim() }];
85
+ else if (line.startsWith("user:") || line.startsWith("assistant:")) {
86
+ pushMessage();
87
+ currentRole = line.startsWith("user:") ? "user" : "assistant";
88
+ currentContent.push(line.slice(line.indexOf(":") + 1).trim());
89
+ } else if (currentRole) currentContent.push(line);
90
+ else {
91
+ currentRole = "user";
92
+ currentContent.push(line);
93
+ }
94
+ pushMessage();
95
+ if (extractedMessages.length === 0 && !system) extractedMessages.push({
96
+ role: "user",
97
+ content: [{ text: messages.trim() }]
98
+ });
99
+ return {
100
+ system,
101
+ extractedMessages
102
+ };
103
+ }
104
+ //#endregion
105
+ //#region src/providers/bedrock/base.ts
106
+ /**
107
+ * AWS Bedrock Base Provider
108
+ *
109
+ * Contains the abstract base class for all Bedrock providers.
110
+ * This is extracted to avoid circular dependency issues.
111
+ */
112
+ var AwsBedrockGenericProvider = class {
113
+ modelName;
114
+ env;
115
+ bedrock;
116
+ config;
117
+ constructor(modelName, options = {}) {
118
+ const { config, id, env } = options;
119
+ this.env = env;
120
+ this.modelName = modelName;
121
+ this.config = config || {};
122
+ this.id = id ? () => id : this.id;
123
+ if (this.config.guardrailIdentifier) require_telemetry.telemetry.record("feature_used", {
124
+ feature: "guardrail",
125
+ provider: "bedrock"
126
+ });
127
+ }
128
+ id() {
129
+ return `bedrock:${this.modelName}`;
130
+ }
131
+ toString() {
132
+ return `[Amazon Bedrock Provider ${this.modelName}]`;
133
+ }
134
+ requiresApiKey() {
135
+ return false;
136
+ }
137
+ getApiKey() {
138
+ return this.config.apiKey || require_logger.getEnvString("AWS_BEARER_TOKEN_BEDROCK");
139
+ }
140
+ async getCredentials() {
141
+ if (this.config.accessKeyId && this.config.secretAccessKey) {
142
+ require_logger.logger.debug(`Using credentials from config file`);
143
+ return {
144
+ accessKeyId: this.config.accessKeyId,
145
+ secretAccessKey: this.config.secretAccessKey,
146
+ sessionToken: this.config.sessionToken
147
+ };
148
+ }
149
+ if (this.getApiKey()) {
150
+ require_logger.logger.debug(`Using Bedrock API key authentication`);
151
+ return;
152
+ }
153
+ if (this.config.profile) {
154
+ require_logger.logger.debug(`Using SSO profile: ${this.config.profile}`);
155
+ try {
156
+ const { fromSSO } = await import("@aws-sdk/credential-provider-sso");
157
+ return fromSSO({ profile: this.config.profile });
158
+ } catch (err) {
159
+ require_logger.logger.error(`Error loading @aws-sdk/credential-provider-sso: ${err}`);
160
+ throw new Error("The @aws-sdk/credential-provider-sso package is required for SSO profiles. Please install it: npm install @aws-sdk/credential-provider-sso");
161
+ }
162
+ }
163
+ require_logger.logger.debug(`No explicit credentials in config, falling back to AWS default chain`);
164
+ }
165
+ async getBedrockInstance() {
166
+ if (!this.bedrock) {
167
+ const handler = await createBedrockRequestHandler({ apiKey: this.getApiKey() });
168
+ try {
169
+ const { BedrockRuntime } = await import("@aws-sdk/client-bedrock-runtime");
170
+ const credentials = await this.getCredentials();
171
+ this.bedrock = new BedrockRuntime({
172
+ region: this.getRegion(),
173
+ maxAttempts: require_logger.getEnvInt("AWS_BEDROCK_MAX_RETRIES", 10),
174
+ retryMode: "adaptive",
175
+ requestHandler: handler,
176
+ ...credentials ? { credentials } : {},
177
+ ...this.config.endpoint ? { endpoint: this.config.endpoint } : {}
178
+ });
179
+ } catch (err) {
180
+ require_logger.logger.error(`Error creating BedrockRuntime: ${err}`);
181
+ throw new Error("The @aws-sdk/client-bedrock-runtime package is required as a peer dependency. Please install it in your project or globally.");
182
+ }
183
+ }
184
+ return this.bedrock;
185
+ }
186
+ getRegion() {
187
+ return this.config?.region || this.env?.AWS_BEDROCK_REGION || require_logger.getEnvString("AWS_BEDROCK_REGION") || "us-east-1";
188
+ }
189
+ };
190
+ //#endregion
191
+ Object.defineProperty(exports, "AwsBedrockGenericProvider", {
192
+ enumerable: true,
193
+ get: function() {
194
+ return AwsBedrockGenericProvider;
195
+ }
196
+ });
197
+ Object.defineProperty(exports, "createBedrockRequestHandler", {
198
+ enumerable: true,
199
+ get: function() {
200
+ return createBedrockRequestHandler;
201
+ }
202
+ });
203
+ Object.defineProperty(exports, "hasProxyEnv", {
204
+ enumerable: true,
205
+ get: function() {
206
+ return hasProxyEnv;
207
+ }
208
+ });
209
+ Object.defineProperty(exports, "novaOutputFromMessage", {
210
+ enumerable: true,
211
+ get: function() {
212
+ return novaOutputFromMessage;
213
+ }
214
+ });
215
+ Object.defineProperty(exports, "novaParseMessages", {
216
+ enumerable: true,
217
+ get: function() {
218
+ return novaParseMessages;
219
+ }
220
+ });
221
+
222
+ //# sourceMappingURL=base-BEysXrkq.cjs.map
@@ -0,0 +1,193 @@
1
+ import { b as getEnvInt, r as logger, x as getEnvString } from "./logger-C40ZGil9.js";
2
+ import { t as telemetry } from "./telemetry-Bg2WqF79.js";
3
+ //#region src/providers/bedrock/util.ts
4
+ const REQUEST_TIMEOUT_MS = 3e5;
5
+ function hasProxyEnv() {
6
+ return Boolean(getEnvString("HTTP_PROXY") || getEnvString("HTTPS_PROXY"));
7
+ }
8
+ /**
9
+ * Creates a NodeHttpHandler (HTTP/1.1) for Bedrock SDK clients.
10
+ *
11
+ * The @aws-sdk/client-bedrock-runtime package defaults to HTTP/2, which causes
12
+ * "http2 request did not get a response" errors in many environments (see #7756).
13
+ * This function forces HTTP/1.1 via NodeHttpHandler.
14
+ *
15
+ * For @aws-sdk/client-bedrock-agent-runtime (which already defaults to HTTP/1.1),
16
+ * this is only needed when proxy or API key authentication is required.
17
+ */
18
+ async function createBedrockRequestHandler(options) {
19
+ const hasProxy = hasProxyEnv();
20
+ try {
21
+ const { NodeHttpHandler } = await import("@smithy/node-http-handler");
22
+ let proxyAgent;
23
+ if (hasProxy) {
24
+ const { ProxyAgent } = await import("proxy-agent");
25
+ proxyAgent = new ProxyAgent();
26
+ }
27
+ const handler = new NodeHttpHandler({
28
+ ...proxyAgent ? { httpsAgent: proxyAgent } : {},
29
+ requestTimeout: REQUEST_TIMEOUT_MS
30
+ });
31
+ if (options?.apiKey) {
32
+ const originalHandle = handler.handle.bind(handler);
33
+ handler.handle = async (request, handlerOptions) => {
34
+ request.headers = {
35
+ ...request.headers,
36
+ Authorization: `Bearer ${options.apiKey}`
37
+ };
38
+ return originalHandle(request, handlerOptions);
39
+ };
40
+ }
41
+ return handler;
42
+ } catch {
43
+ const reason = options?.apiKey ? "API key authentication requires the @smithy/node-http-handler package" : hasProxy ? "Proxy configuration requires the @smithy/node-http-handler package" : "Bedrock provider requires the @smithy/node-http-handler package";
44
+ throw new Error(`${reason}. Please install it in your project or globally.`);
45
+ }
46
+ }
47
+ function novaOutputFromMessage(response) {
48
+ if (response.output?.message?.content.some((block) => block.toolUse?.toolUseId)) return response.output?.message?.content.map((block) => {
49
+ if (block.text) return null;
50
+ return JSON.stringify(block.toolUse);
51
+ }).filter((block) => block).join("\n\n");
52
+ return response.output?.message?.content.map((block) => {
53
+ return block.text;
54
+ }).join("\n\n");
55
+ }
56
+ function novaParseMessages(messages) {
57
+ try {
58
+ const parsed = JSON.parse(messages);
59
+ if (Array.isArray(parsed)) {
60
+ const systemMessage = parsed.find((msg) => msg.role === "system");
61
+ return {
62
+ extractedMessages: parsed.filter((msg) => msg.role !== "system").map((msg) => ({
63
+ role: msg.role,
64
+ content: Array.isArray(msg.content) ? msg.content : [{ text: msg.content }]
65
+ })),
66
+ system: systemMessage ? Array.isArray(systemMessage.content) ? systemMessage.content : [{ text: systemMessage.content }] : void 0
67
+ };
68
+ }
69
+ } catch {}
70
+ const lines = messages.split("\n").map((line) => line.trim()).filter((line) => line);
71
+ let system;
72
+ const extractedMessages = [];
73
+ let currentRole = null;
74
+ let currentContent = [];
75
+ const pushMessage = () => {
76
+ if (currentRole && currentContent.length > 0) {
77
+ extractedMessages.push({
78
+ role: currentRole,
79
+ content: [{ text: currentContent.join("\n") }]
80
+ });
81
+ currentContent = [];
82
+ }
83
+ };
84
+ for (const line of lines) if (line.startsWith("system:")) system = [{ text: line.slice(7).trim() }];
85
+ else if (line.startsWith("user:") || line.startsWith("assistant:")) {
86
+ pushMessage();
87
+ currentRole = line.startsWith("user:") ? "user" : "assistant";
88
+ currentContent.push(line.slice(line.indexOf(":") + 1).trim());
89
+ } else if (currentRole) currentContent.push(line);
90
+ else {
91
+ currentRole = "user";
92
+ currentContent.push(line);
93
+ }
94
+ pushMessage();
95
+ if (extractedMessages.length === 0 && !system) extractedMessages.push({
96
+ role: "user",
97
+ content: [{ text: messages.trim() }]
98
+ });
99
+ return {
100
+ system,
101
+ extractedMessages
102
+ };
103
+ }
104
+ //#endregion
105
+ //#region src/providers/bedrock/base.ts
106
+ /**
107
+ * AWS Bedrock Base Provider
108
+ *
109
+ * Contains the abstract base class for all Bedrock providers.
110
+ * This is extracted to avoid circular dependency issues.
111
+ */
112
+ var AwsBedrockGenericProvider = class {
113
+ modelName;
114
+ env;
115
+ bedrock;
116
+ config;
117
+ constructor(modelName, options = {}) {
118
+ const { config, id, env } = options;
119
+ this.env = env;
120
+ this.modelName = modelName;
121
+ this.config = config || {};
122
+ this.id = id ? () => id : this.id;
123
+ if (this.config.guardrailIdentifier) telemetry.record("feature_used", {
124
+ feature: "guardrail",
125
+ provider: "bedrock"
126
+ });
127
+ }
128
+ id() {
129
+ return `bedrock:${this.modelName}`;
130
+ }
131
+ toString() {
132
+ return `[Amazon Bedrock Provider ${this.modelName}]`;
133
+ }
134
+ requiresApiKey() {
135
+ return false;
136
+ }
137
+ getApiKey() {
138
+ return this.config.apiKey || getEnvString("AWS_BEARER_TOKEN_BEDROCK");
139
+ }
140
+ async getCredentials() {
141
+ if (this.config.accessKeyId && this.config.secretAccessKey) {
142
+ logger.debug(`Using credentials from config file`);
143
+ return {
144
+ accessKeyId: this.config.accessKeyId,
145
+ secretAccessKey: this.config.secretAccessKey,
146
+ sessionToken: this.config.sessionToken
147
+ };
148
+ }
149
+ if (this.getApiKey()) {
150
+ logger.debug(`Using Bedrock API key authentication`);
151
+ return;
152
+ }
153
+ if (this.config.profile) {
154
+ logger.debug(`Using SSO profile: ${this.config.profile}`);
155
+ try {
156
+ const { fromSSO } = await import("@aws-sdk/credential-provider-sso");
157
+ return fromSSO({ profile: this.config.profile });
158
+ } catch (err) {
159
+ logger.error(`Error loading @aws-sdk/credential-provider-sso: ${err}`);
160
+ throw new Error("The @aws-sdk/credential-provider-sso package is required for SSO profiles. Please install it: npm install @aws-sdk/credential-provider-sso");
161
+ }
162
+ }
163
+ logger.debug(`No explicit credentials in config, falling back to AWS default chain`);
164
+ }
165
+ async getBedrockInstance() {
166
+ if (!this.bedrock) {
167
+ const handler = await createBedrockRequestHandler({ apiKey: this.getApiKey() });
168
+ try {
169
+ const { BedrockRuntime } = await import("@aws-sdk/client-bedrock-runtime");
170
+ const credentials = await this.getCredentials();
171
+ this.bedrock = new BedrockRuntime({
172
+ region: this.getRegion(),
173
+ maxAttempts: getEnvInt("AWS_BEDROCK_MAX_RETRIES", 10),
174
+ retryMode: "adaptive",
175
+ requestHandler: handler,
176
+ ...credentials ? { credentials } : {},
177
+ ...this.config.endpoint ? { endpoint: this.config.endpoint } : {}
178
+ });
179
+ } catch (err) {
180
+ logger.error(`Error creating BedrockRuntime: ${err}`);
181
+ throw new Error("The @aws-sdk/client-bedrock-runtime package is required as a peer dependency. Please install it in your project or globally.");
182
+ }
183
+ }
184
+ return this.bedrock;
185
+ }
186
+ getRegion() {
187
+ return this.config?.region || this.env?.AWS_BEDROCK_REGION || getEnvString("AWS_BEDROCK_REGION") || "us-east-1";
188
+ }
189
+ };
190
+ //#endregion
191
+ export { novaParseMessages as a, novaOutputFromMessage as i, createBedrockRequestHandler as n, hasProxyEnv as r, AwsBedrockGenericProvider as t };
192
+
193
+ //# sourceMappingURL=base-C451JQfq.js.map