vidspotai-shared 1.0.100 → 1.0.101

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 (169) hide show
  1. package/lib/globals/aiModels/enums.d.ts +1 -0
  2. package/lib/globals/aiModels/enums.d.ts.map +1 -1
  3. package/lib/globals/aiModels/enums.js +3 -0
  4. package/lib/globals/aiModels/extendCapability.d.ts +26 -0
  5. package/lib/globals/aiModels/extendCapability.d.ts.map +1 -0
  6. package/lib/globals/aiModels/extendCapability.js +42 -0
  7. package/lib/globals/aiModels/index.d.ts +1 -0
  8. package/lib/globals/aiModels/index.d.ts.map +1 -1
  9. package/lib/globals/aiModels/index.js +1 -0
  10. package/lib/globals/aiModels/providers/hostedAvatars.js +10 -10
  11. package/lib/globals/types.d.ts +34 -2
  12. package/lib/globals/types.d.ts.map +1 -1
  13. package/lib/globals/types.js +37 -0
  14. package/lib/models/demoVideoProject.model.d.ts +213 -0
  15. package/lib/models/demoVideoProject.model.d.ts.map +1 -1
  16. package/lib/models/index.d.ts +2 -0
  17. package/lib/models/index.d.ts.map +1 -1
  18. package/lib/models/index.js +2 -0
  19. package/lib/models/mediaUpload.model.d.ts +25 -0
  20. package/lib/models/mediaUpload.model.d.ts.map +1 -1
  21. package/lib/models/productConnection.model.d.ts +57 -0
  22. package/lib/models/productConnection.model.d.ts.map +1 -0
  23. package/lib/models/productConnection.model.js +7 -0
  24. package/lib/models/video.model.d.ts +11 -0
  25. package/lib/models/video.model.d.ts.map +1 -1
  26. package/lib/models/videoQaJob.model.d.ts +61 -0
  27. package/lib/models/videoQaJob.model.d.ts.map +1 -0
  28. package/lib/models/videoQaJob.model.js +16 -0
  29. package/lib/schemas/brandKit.schema.d.ts +3 -1
  30. package/lib/schemas/brandKit.schema.d.ts.map +1 -1
  31. package/lib/schemas/brandKit.schema.js +9 -0
  32. package/lib/schemas/brief.schema.d.ts +5 -4
  33. package/lib/schemas/brief.schema.d.ts.map +1 -1
  34. package/lib/schemas/brief.schema.js +23 -1
  35. package/lib/schemas/demoQuestion.schema.d.ts +24 -4
  36. package/lib/schemas/demoQuestion.schema.d.ts.map +1 -1
  37. package/lib/schemas/demoQuestion.schema.js +8 -2
  38. package/lib/schemas/demoSpec.schema.d.ts +40 -6
  39. package/lib/schemas/demoSpec.schema.d.ts.map +1 -1
  40. package/lib/schemas/demoSpec.schema.js +46 -1
  41. package/lib/schemas/project.schema.d.ts +33 -3
  42. package/lib/schemas/project.schema.d.ts.map +1 -1
  43. package/lib/schemas/project.schema.js +22 -0
  44. package/lib/schemas/social.schema.d.ts +1 -1
  45. package/lib/schemas/videoPlan.schema.d.ts +22 -20
  46. package/lib/schemas/videoPlan.schema.d.ts.map +1 -1
  47. package/lib/schemas/videoPlan.schema.js +19 -0
  48. package/lib/services/agent/editClassifier.d.ts +10 -10
  49. package/lib/services/agent/eval/types.d.ts +3 -2
  50. package/lib/services/agent/eval/types.d.ts.map +1 -1
  51. package/lib/services/agent/executor/core.d.ts.map +1 -1
  52. package/lib/services/agent/executor/core.js +11 -0
  53. package/lib/services/agent/planner/Planner.d.ts.map +1 -1
  54. package/lib/services/agent/planner/Planner.js +5 -0
  55. package/lib/services/agent/planner/overlayRegen.d.ts.map +1 -1
  56. package/lib/services/agent/planner/overlayRegen.js +5 -0
  57. package/lib/services/agent/planner/plannerMessages.d.ts.map +1 -1
  58. package/lib/services/agent/planner/plannerMessages.js +10 -1
  59. package/lib/services/agent/planner/scriptFirstPlanner.d.ts.map +1 -1
  60. package/lib/services/agent/planner/scriptFirstPlanner.js +2 -0
  61. package/lib/services/agent/regenCore.d.ts.map +1 -1
  62. package/lib/services/agent/regenCore.js +11 -1
  63. package/lib/services/agent/runHelpers.d.ts +8 -0
  64. package/lib/services/agent/runHelpers.d.ts.map +1 -1
  65. package/lib/services/agent/runHelpers.js +5 -1
  66. package/lib/services/agent/tools/chapterOutline.tool.d.ts +8 -0
  67. package/lib/services/agent/tools/chapterOutline.tool.d.ts.map +1 -1
  68. package/lib/services/agent/tools/chapterOutline.tool.js +21 -8
  69. package/lib/services/agent/tools/composeScene.tool.d.ts +32 -2
  70. package/lib/services/agent/tools/composeScene.tool.d.ts.map +1 -1
  71. package/lib/services/agent/tools/estimateCost.tool.d.ts +11 -1
  72. package/lib/services/agent/tools/estimateCost.tool.d.ts.map +1 -1
  73. package/lib/services/agent/tools/extendVideo.tool.d.ts +9 -3
  74. package/lib/services/agent/tools/extendVideo.tool.d.ts.map +1 -1
  75. package/lib/services/agent/tools/extendVideo.tool.js +12 -27
  76. package/lib/services/agent/tools/generateAvatarVideo.tool.d.ts +1 -1
  77. package/lib/services/agent/tools/generateScript.tool.d.ts +3 -2
  78. package/lib/services/agent/tools/generateScript.tool.d.ts.map +1 -1
  79. package/lib/services/agent/tools/generateScript.tool.js +16 -7
  80. package/lib/services/agent/tools/generateVoiceover.tool.d.ts +1 -1
  81. package/lib/services/agent/tools/planVideo.tool.d.ts +11 -8
  82. package/lib/services/agent/tools/planVideo.tool.d.ts.map +1 -1
  83. package/lib/services/agent/tools/render.tool.d.ts +11 -1
  84. package/lib/services/agent/tools/render.tool.d.ts.map +1 -1
  85. package/lib/services/agent/tools/searchStock.tool.d.ts +1 -1
  86. package/lib/services/agent/tools/searchUserLibrary.tool.d.ts +4 -4
  87. package/lib/services/aiGen/providers/kling/kling.service.d.ts.map +1 -1
  88. package/lib/services/aiGen/providers/kling/kling.service.js +22 -3
  89. package/lib/services/aiGen/providers/kling/klingStatus.d.ts +7 -0
  90. package/lib/services/aiGen/providers/kling/klingStatus.d.ts.map +1 -1
  91. package/lib/services/aiGen/providers/kling/klingStatus.js +41 -4
  92. package/lib/services/aiGen/providers/pixverse/pixverse.service.d.ts.map +1 -1
  93. package/lib/services/aiGen/providers/pixverse/pixverse.service.js +25 -0
  94. package/lib/services/aiGen/providers/types.d.ts +20 -0
  95. package/lib/services/aiGen/providers/types.d.ts.map +1 -1
  96. package/lib/services/avatarGen/avatarProviderFactory.d.ts.map +1 -1
  97. package/lib/services/avatarGen/avatarProviderFactory.js +3 -0
  98. package/lib/services/avatarGen/index.d.ts +1 -0
  99. package/lib/services/avatarGen/index.d.ts.map +1 -1
  100. package/lib/services/avatarGen/index.js +1 -0
  101. package/lib/services/avatarGen/providers/synthesiaAvatarProvider.d.ts +53 -0
  102. package/lib/services/avatarGen/providers/synthesiaAvatarProvider.d.ts.map +1 -0
  103. package/lib/services/avatarGen/providers/synthesiaAvatarProvider.js +176 -0
  104. package/lib/services/demo/demoAuthor.d.ts +7 -0
  105. package/lib/services/demo/demoAuthor.d.ts.map +1 -1
  106. package/lib/services/demo/demoAuthor.js +2 -0
  107. package/lib/services/demo/demoAuthorPrompt.d.ts +6 -0
  108. package/lib/services/demo/demoAuthorPrompt.d.ts.map +1 -1
  109. package/lib/services/demo/demoAuthorPrompt.js +24 -2
  110. package/lib/services/demo/demoCaptions.d.ts +69 -0
  111. package/lib/services/demo/demoCaptions.d.ts.map +1 -0
  112. package/lib/services/demo/demoCaptions.js +152 -0
  113. package/lib/services/demo/demoMusic.d.ts +8 -1
  114. package/lib/services/demo/demoMusic.d.ts.map +1 -1
  115. package/lib/services/demo/demoMusic.js +32 -16
  116. package/lib/services/demo/demoScriptPrompt.d.ts +2 -1
  117. package/lib/services/demo/demoScriptPrompt.d.ts.map +1 -1
  118. package/lib/services/demo/demoScriptPrompt.js +29 -2
  119. package/lib/services/demo/demoStockAssets.d.ts +29 -0
  120. package/lib/services/demo/demoStockAssets.d.ts.map +1 -0
  121. package/lib/services/demo/demoStockAssets.js +107 -0
  122. package/lib/services/demo/index.d.ts +3 -0
  123. package/lib/services/demo/index.d.ts.map +1 -1
  124. package/lib/services/demo/index.js +3 -0
  125. package/lib/services/demo/productConnection.service.d.ts +78 -0
  126. package/lib/services/demo/productConnection.service.d.ts.map +1 -0
  127. package/lib/services/demo/productConnection.service.js +125 -0
  128. package/lib/services/editor/planToProject.d.ts.map +1 -1
  129. package/lib/services/editor/planToProject.helpers.d.ts +1 -0
  130. package/lib/services/editor/planToProject.helpers.d.ts.map +1 -1
  131. package/lib/services/editor/planToProject.helpers.js +3 -0
  132. package/lib/services/editor/planToProject.js +39 -0
  133. package/lib/services/editor/projectToDesign.js +13 -1
  134. package/lib/services/firestore.service.d.ts +14 -0
  135. package/lib/services/firestore.service.d.ts.map +1 -1
  136. package/lib/services/firestore.service.js +16 -0
  137. package/lib/services/translation/index.d.ts +1 -0
  138. package/lib/services/translation/index.d.ts.map +1 -1
  139. package/lib/services/translation/index.js +8 -1
  140. package/lib/services/translation/outputLanguage.d.ts +75 -0
  141. package/lib/services/translation/outputLanguage.d.ts.map +1 -0
  142. package/lib/services/translation/outputLanguage.js +190 -0
  143. package/lib/services/translation/translation.service.d.ts +13 -2
  144. package/lib/services/translation/translation.service.d.ts.map +1 -1
  145. package/lib/services/translation/translation.service.js +66 -5
  146. package/lib/services/tts/index.d.ts +1 -0
  147. package/lib/services/tts/index.d.ts.map +1 -1
  148. package/lib/services/tts/index.js +1 -0
  149. package/lib/services/tts/providers/elevenlabs.service.d.ts +7 -0
  150. package/lib/services/tts/providers/elevenlabs.service.d.ts.map +1 -1
  151. package/lib/services/tts/providers/elevenlabs.service.js +69 -13
  152. package/lib/services/tts/types.d.ts +29 -0
  153. package/lib/services/tts/types.d.ts.map +1 -1
  154. package/lib/services/tts/wordTimings.d.ts +27 -0
  155. package/lib/services/tts/wordTimings.d.ts.map +1 -0
  156. package/lib/services/tts/wordTimings.js +57 -0
  157. package/lib/utils/billableDuration.d.ts +11 -0
  158. package/lib/utils/billableDuration.d.ts.map +1 -0
  159. package/lib/utils/billableDuration.js +91 -0
  160. package/lib/utils/index.d.ts +3 -0
  161. package/lib/utils/index.d.ts.map +1 -1
  162. package/lib/utils/index.js +3 -0
  163. package/lib/utils/mp4Duration.d.ts +38 -0
  164. package/lib/utils/mp4Duration.d.ts.map +1 -0
  165. package/lib/utils/mp4Duration.js +164 -0
  166. package/lib/utils/socialEntitlements.d.ts +51 -0
  167. package/lib/utils/socialEntitlements.d.ts.map +1 -0
  168. package/lib/utils/socialEntitlements.js +65 -0
  169. package/package.json +1 -1
@@ -13,7 +13,9 @@ import { IShareModel } from "../models/share.model";
13
13
  import { IUserModel } from "../models/user.model";
14
14
  import { IVideoJobModel } from "../models/video.model";
15
15
  import { IDemoVideoProjectModel } from "../models/demoVideoProject.model";
16
+ import { IVideoQaJobModel } from "../models/videoQaJob.model";
16
17
  import { IGithubConnectionModel } from "../models/githubConnection.model";
18
+ import { IProductConnectionModel } from "../models/productConnection.model";
17
19
  import { IOutreachCampaignModel, IOutreachRecipientModel, IOutreachTemplateModel, IPersonalizedVideoModel, IVideoViewModel } from "../models/outreach.model";
18
20
  /**
19
21
  * FirestoreService
@@ -55,8 +57,20 @@ export declare class FirestoreService {
55
57
  static sharesCol: CollectionReference<IShareModel, DocumentData>;
56
58
  static mediaUploadsCol: CollectionReference<IMediaUploadModel, DocumentData>;
57
59
  static demoVideoProjectsCol: CollectionReference<IDemoVideoProjectModel, DocumentData>;
60
+ /**
61
+ * Output-QA requests against a finished `videoJobs` output (MCP
62
+ * check_video_quality / repair_video). One doc per request; the worker writes
63
+ * the report back and the MCP tool polls it. See videoQaJob.model.ts.
64
+ */
65
+ static videoQaJobsCol: CollectionReference<IVideoQaJobModel, DocumentData>;
58
66
  /** GitHub OAuth connections — one doc per user (doc id = userId). Phase 9. */
59
67
  static githubConnectionsCol: CollectionReference<IGithubConnectionModel, DocumentData>;
68
+ /**
69
+ * Product sign-in connections — the encrypted, replayable storageState a user
70
+ * captured for their own SaaS product so the worker can record its
71
+ * authenticated UI (Tier 2 product-footage-capture). Doc id = `${userId}__${host}`.
72
+ */
73
+ static productConnectionsCol: CollectionReference<IProductConnectionModel, DocumentData>;
60
74
  static socialAccountsCol: CollectionReference<ISocialAccountModel, DocumentData>;
61
75
  static socialPostsCol: CollectionReference<ISocialPostModel, DocumentData>;
62
76
  static socialAnalyticsCol: CollectionReference<ISocialAnalyticsModel, DocumentData>;
@@ -1 +1 @@
1
- {"version":3,"file":"firestore.service.d.ts","sourceRoot":"","sources":["../../src/services/firestore.service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,gBAAgB,EAEhB,aAAa,EACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAelC;;;;GAIG;AACH,qBAAa,gBAAgB;IAE3B,MAAM,CAAC,YAAY,oDAEqC;IAExD,MAAM,CA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I,CAAC;IAWhB,OAAO,CAAC,MAAM,CAAC,aAAa;IA2B5B,0CAA0C;WAC7B,cAAc,CACzB,EAAE,EAAE,MAAM,EACV,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,GAClC,OAAO,CAAC,IAAI,CAAC;IAIhB,sBAAsB;WACT,UAAU,CAAC,CAAC,EACvB,aAAa,EAAE,mBAAmB,CAAC,CAAC,CAAC,EACrC,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC;IAKhB,kCAAkC;WACrB,cAAc,CAAC,CAAC,EAC3B,OAAO,EAAE,CAAC,EAAE,EAAE,iBAAiB,CAAC,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GACzD,OAAO,CAAC,CAAC,CAAC;CAGd"}
1
+ {"version":3,"file":"firestore.service.d.ts","sourceRoot":"","sources":["../../src/services/firestore.service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,gBAAgB,EAEhB,aAAa,EACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAC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Col = firebase_1.firestore
169
169
  .collection("demoVideoProjects")
170
170
  .withConverter(collectionConverter());
171
+ /**
172
+ * Output-QA requests against a finished `videoJobs` output (MCP
173
+ * check_video_quality / repair_video). One doc per request; the worker writes
174
+ * the report back and the MCP tool polls it. See videoQaJob.model.ts.
175
+ */
176
+ FirestoreService.videoQaJobsCol = firebase_1.firestore
177
+ .collection("videoQaJobs")
178
+ .withConverter(collectionConverter());
171
179
  /** GitHub OAuth connections — one doc per user (doc id = userId). Phase 9. */
172
180
  FirestoreService.githubConnectionsCol = firebase_1.firestore
173
181
  .collection("githubConnections")
174
182
  .withConverter(collectionConverter());
183
+ /**
184
+ * Product sign-in connections — the encrypted, replayable storageState a user
185
+ * captured for their own SaaS product so the worker can record its
186
+ * authenticated UI (Tier 2 product-footage-capture). Doc id = `${userId}__${host}`.
187
+ */
188
+ FirestoreService.productConnectionsCol = firebase_1.firestore
189
+ .collection("productConnections")
190
+ .withConverter(collectionConverter());
175
191
  // 🔹 X8 Social Suite — see notes/SOCIAL_SUITE_PLAN.md
176
192
  FirestoreService.socialAccountsCol = firebase_1.firestore
177
193
  .collection("socialAccounts")
@@ -1,2 +1,3 @@
1
1
  export { translationService } from "./translation.service";
2
+ export { LANGUAGE_DISPLAY_NAMES, buildOutputLanguageSection, isEnglish, languageDisplayName, normalizeLanguageTag, resolveOutputLanguage, } from "./outputLanguage";
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/translation/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/translation/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,SAAS,EACT,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC"}
@@ -1,9 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.translationService = void 0;
3
+ exports.resolveOutputLanguage = exports.normalizeLanguageTag = exports.languageDisplayName = exports.isEnglish = exports.buildOutputLanguageSection = exports.LANGUAGE_DISPLAY_NAMES = exports.translationService = void 0;
4
4
  // Only the new API is exported from the services barrel. The legacy aliases
5
5
  // (getTranslationWrapper / detectLang / TRANSLATION_FAILED) are re-exported via
6
6
  // utils/helpers instead, so each name reaches the package root through exactly
7
7
  // one star-export path (no ambiguous duplicate re-export).
8
8
  var translation_service_1 = require("./translation.service");
9
9
  Object.defineProperty(exports, "translationService", { enumerable: true, get: function () { return translation_service_1.translationService; } });
10
+ var outputLanguage_1 = require("./outputLanguage");
11
+ Object.defineProperty(exports, "LANGUAGE_DISPLAY_NAMES", { enumerable: true, get: function () { return outputLanguage_1.LANGUAGE_DISPLAY_NAMES; } });
12
+ Object.defineProperty(exports, "buildOutputLanguageSection", { enumerable: true, get: function () { return outputLanguage_1.buildOutputLanguageSection; } });
13
+ Object.defineProperty(exports, "isEnglish", { enumerable: true, get: function () { return outputLanguage_1.isEnglish; } });
14
+ Object.defineProperty(exports, "languageDisplayName", { enumerable: true, get: function () { return outputLanguage_1.languageDisplayName; } });
15
+ Object.defineProperty(exports, "normalizeLanguageTag", { enumerable: true, get: function () { return outputLanguage_1.normalizeLanguageTag; } });
16
+ Object.defineProperty(exports, "resolveOutputLanguage", { enumerable: true, get: function () { return outputLanguage_1.resolveOutputLanguage; } });
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Output language — the language the VIEWER hears and reads.
3
+ *
4
+ * WHY THIS EXISTS
5
+ * ---------------
6
+ * Until now the product had no concept of an output language at all. The brief
7
+ * carried `voice.language` (defaulting to "en") that nothing read, the planner
8
+ * prompt never mentioned language, and the TTS/ASR layers were handed no hint.
9
+ * Net effect: a user could write their whole brief in Spanish and get an
10
+ * English-narrated video back. This module is the single place that decides
11
+ * what language the narration, captions, and on-screen copy should be in.
12
+ *
13
+ * IMPORTANT — output language is NOT prompt language. The visual `prompt` /
14
+ * `intent` fields that feed the image/video models stay English (the providers
15
+ * are tuned on English and degrade noticeably otherwise). Only viewer-facing
16
+ * text follows the output language. `localizePlanText` in
17
+ * `utils/outreachTemplate.ts` draws the same line for the Reach path.
18
+ *
19
+ * RESOLUTION ORDER ("auto" — no user-facing picker)
20
+ * 1. The language the user actually WROTE the brief in. This is the
21
+ * strongest signal of intent and beats the UI chrome: people routinely
22
+ * browse an English UI and then type their brief in their own language.
23
+ * 2. The UI locale they submitted from, when detection is unavailable or
24
+ * says it isn't confident.
25
+ * 3. English, as the terminal fallback.
26
+ */
27
+ /**
28
+ * Display names for the languages the product advertises support for (the set
29
+ * behind the marketing pages' locale switcher). Used to address the model in
30
+ * plain English ("Write in Spanish") rather than by bare ISO code, which
31
+ * measurably improves instruction-following on the smaller planner models.
32
+ *
33
+ * A code missing from this map is NOT an error — `languageDisplayName` falls
34
+ * back to naming the ISO code, and the LLM handles it fine. The map exists to
35
+ * make the common cases read naturally, not to gate-keep a closed set.
36
+ */
37
+ export declare const LANGUAGE_DISPLAY_NAMES: Record<string, string>;
38
+ /**
39
+ * Normalize a BCP-47 locale to the tag we key on: lowercased, and reduced to
40
+ * the primary subtag UNLESS the full tag is one we name distinctly (the
41
+ * Chinese scripts, where "zh-cn" vs "zh-tw" is a real content difference and
42
+ * collapsing to "zh" would lose it).
43
+ *
44
+ * "es-419" → "es", "pt_BR" → "pt", "zh-CN" → "zh-cn". Empty input → undefined.
45
+ */
46
+ export declare function normalizeLanguageTag(locale?: string): string | undefined;
47
+ /** Human-readable language name for prompt injection; falls back to the code. */
48
+ export declare function languageDisplayName(code: string): string;
49
+ /** True when `code` resolves to English (or is absent). */
50
+ export declare function isEnglish(code?: string): boolean;
51
+ /**
52
+ * Decide the output language for a piece of work. See the resolution order in
53
+ * the module docblock.
54
+ *
55
+ * Never throws and never blocks: detection is best-effort and every failure
56
+ * path degrades to the UI locale, then to English. A language lookup must not
57
+ * be able to fail a generation run.
58
+ *
59
+ * @param promptText The user's own words (brief.rawPrompt / video prompt).
60
+ * @param uiLocale The locale the request was submitted from, if the client sent one.
61
+ */
62
+ export declare function resolveOutputLanguage(params: {
63
+ promptText?: string;
64
+ uiLocale?: string;
65
+ }): Promise<string>;
66
+ /**
67
+ * Render the output-language rule for an LLM system prompt. Returns "" for
68
+ * English so the (overwhelmingly common) English path adds zero tokens and
69
+ * behaves exactly as it did before this feature existed.
70
+ *
71
+ * `kinds` names the viewer-facing surfaces the callee actually produces, so
72
+ * each prompt gets a rule about its own output rather than a generic one.
73
+ */
74
+ export declare function buildOutputLanguageSection(outputLanguage: string | undefined, kinds: string): string;
75
+ //# sourceMappingURL=outputLanguage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outputLanguage.d.ts","sourceRoot":"","sources":["../../../src/services/translation/outputLanguage.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAwCzD,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOxE;AAED,iFAAiF;AACjF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIxD;AAED,2DAA2D;AAC3D,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAGhD;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,MAAM,CAAC,CAmClB;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,KAAK,EAAE,MAAM,GACZ,MAAM,CAeR"}
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LANGUAGE_DISPLAY_NAMES = void 0;
4
+ exports.normalizeLanguageTag = normalizeLanguageTag;
5
+ exports.languageDisplayName = languageDisplayName;
6
+ exports.isEnglish = isEnglish;
7
+ exports.resolveOutputLanguage = resolveOutputLanguage;
8
+ exports.buildOutputLanguageSection = buildOutputLanguageSection;
9
+ const types_1 = require("../../globals/types");
10
+ const logger_1 = require("../../utils/logger");
11
+ const translation_service_1 = require("./translation.service");
12
+ /**
13
+ * Output language — the language the VIEWER hears and reads.
14
+ *
15
+ * WHY THIS EXISTS
16
+ * ---------------
17
+ * Until now the product had no concept of an output language at all. The brief
18
+ * carried `voice.language` (defaulting to "en") that nothing read, the planner
19
+ * prompt never mentioned language, and the TTS/ASR layers were handed no hint.
20
+ * Net effect: a user could write their whole brief in Spanish and get an
21
+ * English-narrated video back. This module is the single place that decides
22
+ * what language the narration, captions, and on-screen copy should be in.
23
+ *
24
+ * IMPORTANT — output language is NOT prompt language. The visual `prompt` /
25
+ * `intent` fields that feed the image/video models stay English (the providers
26
+ * are tuned on English and degrade noticeably otherwise). Only viewer-facing
27
+ * text follows the output language. `localizePlanText` in
28
+ * `utils/outreachTemplate.ts` draws the same line for the Reach path.
29
+ *
30
+ * RESOLUTION ORDER ("auto" — no user-facing picker)
31
+ * 1. The language the user actually WROTE the brief in. This is the
32
+ * strongest signal of intent and beats the UI chrome: people routinely
33
+ * browse an English UI and then type their brief in their own language.
34
+ * 2. The UI locale they submitted from, when detection is unavailable or
35
+ * says it isn't confident.
36
+ * 3. English, as the terminal fallback.
37
+ */
38
+ /**
39
+ * Display names for the languages the product advertises support for (the set
40
+ * behind the marketing pages' locale switcher). Used to address the model in
41
+ * plain English ("Write in Spanish") rather than by bare ISO code, which
42
+ * measurably improves instruction-following on the smaller planner models.
43
+ *
44
+ * A code missing from this map is NOT an error — `languageDisplayName` falls
45
+ * back to naming the ISO code, and the LLM handles it fine. The map exists to
46
+ * make the common cases read naturally, not to gate-keep a closed set.
47
+ */
48
+ exports.LANGUAGE_DISPLAY_NAMES = {
49
+ en: "English",
50
+ ar: "Arabic",
51
+ bg: "Bulgarian",
52
+ ca: "Catalan",
53
+ cs: "Czech",
54
+ da: "Danish",
55
+ de: "German",
56
+ el: "Greek",
57
+ es: "Spanish",
58
+ fi: "Finnish",
59
+ fr: "French",
60
+ he: "Hebrew",
61
+ hi: "Hindi",
62
+ hr: "Croatian",
63
+ hu: "Hungarian",
64
+ id: "Indonesian",
65
+ it: "Italian",
66
+ // `iw` is Google's legacy code for Hebrew and is what the detect endpoint
67
+ // still returns; keep both so neither path falls through to the ISO wording.
68
+ iw: "Hebrew",
69
+ ja: "Japanese",
70
+ ko: "Korean",
71
+ ms: "Malay",
72
+ nl: "Dutch",
73
+ no: "Norwegian",
74
+ pl: "Polish",
75
+ pt: "Portuguese",
76
+ ro: "Romanian",
77
+ ru: "Russian",
78
+ sk: "Slovak",
79
+ sv: "Swedish",
80
+ th: "Thai",
81
+ tl: "Filipino",
82
+ tr: "Turkish",
83
+ uk: "Ukrainian",
84
+ vi: "Vietnamese",
85
+ zh: "Chinese",
86
+ "zh-cn": "Chinese (Simplified)",
87
+ "zh-tw": "Chinese (Traditional)",
88
+ };
89
+ /**
90
+ * Normalize a BCP-47 locale to the tag we key on: lowercased, and reduced to
91
+ * the primary subtag UNLESS the full tag is one we name distinctly (the
92
+ * Chinese scripts, where "zh-cn" vs "zh-tw" is a real content difference and
93
+ * collapsing to "zh" would lose it).
94
+ *
95
+ * "es-419" → "es", "pt_BR" → "pt", "zh-CN" → "zh-cn". Empty input → undefined.
96
+ */
97
+ function normalizeLanguageTag(locale) {
98
+ if (!locale)
99
+ return undefined;
100
+ const lower = locale.trim().toLowerCase().replace(/_/g, "-");
101
+ if (!lower)
102
+ return undefined;
103
+ if (exports.LANGUAGE_DISPLAY_NAMES[lower])
104
+ return lower;
105
+ const base = lower.split("-")[0];
106
+ return base || undefined;
107
+ }
108
+ /** Human-readable language name for prompt injection; falls back to the code. */
109
+ function languageDisplayName(code) {
110
+ const tag = normalizeLanguageTag(code);
111
+ if (!tag)
112
+ return "English";
113
+ return exports.LANGUAGE_DISPLAY_NAMES[tag] ?? `the language with ISO code "${tag}"`;
114
+ }
115
+ /** True when `code` resolves to English (or is absent). */
116
+ function isEnglish(code) {
117
+ const tag = normalizeLanguageTag(code);
118
+ return !tag || tag === types_1.ELANGUAGE_CODE.en;
119
+ }
120
+ /**
121
+ * Decide the output language for a piece of work. See the resolution order in
122
+ * the module docblock.
123
+ *
124
+ * Never throws and never blocks: detection is best-effort and every failure
125
+ * path degrades to the UI locale, then to English. A language lookup must not
126
+ * be able to fail a generation run.
127
+ *
128
+ * @param promptText The user's own words (brief.rawPrompt / video prompt).
129
+ * @param uiLocale The locale the request was submitted from, if the client sent one.
130
+ */
131
+ async function resolveOutputLanguage(params) {
132
+ const uiTag = normalizeLanguageTag(params.uiLocale);
133
+ const text = params.promptText?.trim();
134
+ // Too short to detect on. Single words and stock phrases ("make me a video")
135
+ // trip the detector into false positives, so don't even ask — the UI locale
136
+ // is the better signal at this length.
137
+ if (!text || text.length < 12) {
138
+ return uiTag ?? types_1.ELANGUAGE_CODE.en;
139
+ }
140
+ try {
141
+ const detected = await translation_service_1.translationService.detectLanguage(text);
142
+ const top = detected.languages?.[0];
143
+ // `reliable` is the detector's own confidence flag. Historically every
144
+ // caller ignored it, which is precisely how a timed-out detect call (which
145
+ // fails open to en/100%/reliable:false) silently forced English on
146
+ // everyone. Honour it: an unreliable verdict defers to the UI locale.
147
+ if (detected.reliable && top?.code) {
148
+ const tag = normalizeLanguageTag(top.code);
149
+ if (tag)
150
+ return tag;
151
+ }
152
+ logger_1.logger.info("outputLanguage: detection unreliable, using UI locale", {
153
+ uiLocale: uiTag,
154
+ topCode: top?.code,
155
+ reliable: detected.reliable,
156
+ });
157
+ }
158
+ catch (err) {
159
+ logger_1.logger.warn("outputLanguage: detection threw, using UI locale", {
160
+ uiLocale: uiTag,
161
+ err: err instanceof Error ? err.message : String(err),
162
+ });
163
+ }
164
+ return uiTag ?? types_1.ELANGUAGE_CODE.en;
165
+ }
166
+ /**
167
+ * Render the output-language rule for an LLM system prompt. Returns "" for
168
+ * English so the (overwhelmingly common) English path adds zero tokens and
169
+ * behaves exactly as it did before this feature existed.
170
+ *
171
+ * `kinds` names the viewer-facing surfaces the callee actually produces, so
172
+ * each prompt gets a rule about its own output rather than a generic one.
173
+ */
174
+ function buildOutputLanguageSection(outputLanguage, kinds) {
175
+ if (isEnglish(outputLanguage))
176
+ return "";
177
+ const name = languageDisplayName(outputLanguage);
178
+ return [
179
+ "",
180
+ `OUTPUT LANGUAGE — write ${kinds} in ${name}.`,
181
+ ` - This is what the viewer hears and reads. It is NOT optional styling:`,
182
+ ` the user wrote their brief in ${name} and expects a ${name} video.`,
183
+ ` - Keep proper nouns, brand names, product names, and hashtags as-is.`,
184
+ ` - Do NOT translate the visual prompt / intent fields — those feed the`,
185
+ ` image and video models, which are tuned on English. They stay English`,
186
+ ` even though the spoken and on-screen copy is ${name}.`,
187
+ ` - Write natively in ${name}: idiomatic phrasing a native speaker would`,
188
+ ` use, not a word-for-word translation of an English script.`,
189
+ ].join("\n");
190
+ }
@@ -34,8 +34,19 @@ export declare const TRANSLATION_FAILED = "TRANSLATION_FAILED";
34
34
  */
35
35
  declare function translate(text: string, from: ELANGUAGE_CODE, to?: ELANGUAGE_CODE, version?: "v1" | "v2"): Promise<string>;
36
36
  /**
37
- * Detect the language of `text`. Primary CF; on failure fails OPEN to English
38
- * (matches prior behavior — language detection must never block generation).
37
+ * Detect the language of `text`. Primary CF cheap LLM → fail OPEN to English.
38
+ *
39
+ * The LLM layer matters more here than it does for `translate`. The primary
40
+ * endpoint is the same flaky Cloud Function, but detection's failure mode is
41
+ * silent rather than loud: it used to return en/100% with `reliable: false`,
42
+ * and since every caller ignored that flag, a detect timeout quietly forced
43
+ * English on a non-English user. That is one of the ways the product ended up
44
+ * English-only regardless of what the user wrote.
45
+ *
46
+ * The terminal fallback still returns English so detection can never block a
47
+ * generation run — but it keeps `reliable: false`, and callers
48
+ * (`resolveOutputLanguage`) now honour that flag and defer to the UI locale
49
+ * instead of treating the guess as fact.
39
50
  */
40
51
  declare function detectLanguage(text: string): Promise<IDetectLang>;
41
52
  export declare const translationService: {
@@ -1 +1 @@
1
- {"version":3,"file":"translation.service.d.ts","sourceRoot":"","sources":["../../../src/services/translation/translation.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAqGvD;;;;GAIG;AACH,iBAAe,SAAS,CACtB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,cAAc,EACpB,EAAE,GAAE,cAAkC,EACtC,OAAO,GAAE,IAAI,GAAG,IAAW,GAC1B,OAAO,CAAC,MAAM,CAAC,CAsCjB;AAED;;;GAGG;AACH,iBAAe,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAwBhE;AAOD,eAAO,MAAM,kBAAkB;;;CAG9B,CAAC;AAGF,qDAAqD;AACrD,eAAO,MAAM,qBAAqB,kBAAY,CAAC;AAC/C,0DAA0D;AAC1D,eAAO,MAAM,UAAU,uBAAiB,CAAC"}
1
+ {"version":3,"file":"translation.service.d.ts","sourceRoot":"","sources":["../../../src/services/translation/translation.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAqGvD;;;;GAIG;AACH,iBAAe,SAAS,CACtB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,cAAc,EACpB,EAAE,GAAE,cAAkC,EACtC,OAAO,GAAE,IAAI,GAAG,IAAW,GAC1B,OAAO,CAAC,MAAM,CAAC,CAsCjB;AAiCD;;;;;;;;;;;;;;GAcG;AACH,iBAAe,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CA8ChE;AAOD,eAAO,MAAM,kBAAkB;;;CAG9B,CAAC;AAGF,qDAAqD;AACrD,eAAO,MAAM,qBAAqB,kBAAY,CAAC;AAC/C,0DAA0D;AAC1D,eAAO,MAAM,UAAU,uBAAiB,CAAC"}
@@ -189,20 +189,81 @@ async function translate(text, from, to = types_1.ELANGUAGE_CODE.en, version = "
189
189
  }
190
190
  }
191
191
  /**
192
- * Detect the language of `text`. Primary CF; on failure fails OPEN to English
193
- * (matches prior behavior language detection must never block generation).
192
+ * FALLBACK: detect via the same cheap LLM `translate` falls back to. Returns
193
+ * the bare ISO 639-1 code. Throws if the reply doesn't look like a code.
194
+ */
195
+ async function callLlmDetect(text) {
196
+ const { getAiGenProviderService } = await Promise.resolve().then(() => __importStar(require("../aiGen/aiGenFactory.service")));
197
+ const service = getAiGenProviderService(FALLBACK_MODEL);
198
+ const system = "You are a language identification engine. Reply with ONLY the ISO 639-1 " +
199
+ "code of the language the user's text is written in — two lowercase " +
200
+ 'letters, nothing else (e.g. "es", "ja", "ar"). Use "zh-cn" or "zh-tw" ' +
201
+ "for Chinese. No punctuation, no explanation.";
202
+ const { text: out } = await service.generateText({
203
+ // Only the opening slice matters for identification, and capping it keeps
204
+ // this cheap when a long-form brief triggers the fallback.
205
+ input: [
206
+ { role: "system", content: system },
207
+ { role: "user", content: text.slice(0, 1000) },
208
+ ],
209
+ modelKey: FALLBACK_MODEL,
210
+ options: { temperature: 0 },
211
+ });
212
+ const code = (out ?? "").trim().toLowerCase().replace(/[^a-z-]/g, "");
213
+ if (!/^[a-z]{2}(-[a-z]{2})?$/.test(code)) {
214
+ throw new Error(`LLM detect returned a non-code reply: "${out}"`);
215
+ }
216
+ return code;
217
+ }
218
+ /**
219
+ * Detect the language of `text`. Primary CF → cheap LLM → fail OPEN to English.
220
+ *
221
+ * The LLM layer matters more here than it does for `translate`. The primary
222
+ * endpoint is the same flaky Cloud Function, but detection's failure mode is
223
+ * silent rather than loud: it used to return en/100% with `reliable: false`,
224
+ * and since every caller ignored that flag, a detect timeout quietly forced
225
+ * English on a non-English user. That is one of the ways the product ended up
226
+ * English-only regardless of what the user wrote.
227
+ *
228
+ * The terminal fallback still returns English so detection can never block a
229
+ * generation run — but it keeps `reliable: false`, and callers
230
+ * (`resolveOutputLanguage`) now honour that flag and defer to the UI locale
231
+ * instead of treating the guess as fact.
194
232
  */
195
233
  async function detectLanguage(text) {
234
+ let primaryErr;
196
235
  try {
197
236
  const res = await axios_1.default.post(`${PRIMARY_BASE}/detectLang`, { text }, {
198
237
  headers: { "internal-key": process.env.TRANSLATION_SERVICE_KEY || "" },
199
238
  timeout: PRIMARY_TIMEOUT_MS,
200
239
  });
201
- return res.data;
240
+ if (res.data?.languages?.[0]?.code)
241
+ return res.data;
242
+ throw new Error("primary detectLang returned no language");
202
243
  }
203
244
  catch (err) {
204
- logger_1.logger.warn("translation: detectLang failed, defaulting to en", {
205
- err: errMsg(err),
245
+ primaryErr = err;
246
+ }
247
+ try {
248
+ const code = await callLlmDetect(text);
249
+ logger_1.logger.warn("translation: detectLang primary failed, LLM recovered", {
250
+ fallbackModel: FALLBACK_MODEL,
251
+ detected: code,
252
+ err: errMsg(primaryErr),
253
+ });
254
+ return {
255
+ reliable: true,
256
+ textBytes: Buffer.byteLength(text, "utf8"),
257
+ languages: [
258
+ { name: languageLabel(code), code, percent: 100, score: 1 },
259
+ ],
260
+ chunks: [],
261
+ };
262
+ }
263
+ catch (fallbackErr) {
264
+ logger_1.logger.warn("translation: detectLang failed on both layers, defaulting to en", {
265
+ primaryErr: errMsg(primaryErr),
266
+ fallbackErr: errMsg(fallbackErr),
206
267
  });
207
268
  return {
208
269
  reliable: false,
@@ -1,4 +1,5 @@
1
1
  export * from "./types";
2
+ export * from "./wordTimings";
2
3
  export * from "./providers/elevenlabs.service";
3
4
  export * from "./providers/minimax.service";
4
5
  export * from "./providers/openai.service";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/tts/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/tts/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC"}
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./types"), exports);
18
+ __exportStar(require("./wordTimings"), exports);
18
19
  __exportStar(require("./providers/elevenlabs.service"), exports);
19
20
  __exportStar(require("./providers/minimax.service"), exports);
20
21
  __exportStar(require("./providers/openai.service"), exports);
@@ -9,6 +9,13 @@ export declare class ElevenLabsService extends BaseTtsProviderService {
9
9
  * Retries: axios timeout (ECONNABORTED), network errors (ECONNRESET/ETIMEDOUT/etc.),
10
10
  * HTTP 429 (rate limit, longer backoff), HTTP 5xx (server errors).
11
11
  * Does NOT retry: 400/401/403/404 (caller handles 400 language_code separately).
12
+ *
13
+ * Two endpoints, one code path. The plain endpoint streams audio bytes; the
14
+ * `/with-timestamps` endpoint returns JSON carrying base64 audio PLUS character
15
+ * alignment. We keep `responseType: "arraybuffer"` for BOTH and parse the JSON
16
+ * out of the buffer ourselves, so error bodies keep arriving as Buffers and the
17
+ * caller's error-decoding (which reads `err.response.data` as a Buffer) stays
18
+ * correct for both modes.
12
19
  */
13
20
  private postTtsWithRetry;
14
21
  getVoices(): ITtsVoiceOption[];
@@ -1 +1 @@
1
- {"version":3,"file":"elevenlabs.service.d.ts","sourceRoot":"","sources":["../../../../src/services/tts/providers/elevenlabs.service.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAiBzF,qBAAa,iBAAkB,SAAQ,sBAAsB;IAC3D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;IAE1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;;IAW1B,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IA+FrD;;;;;OAKG;YACW,gBAAgB;IAsD9B,SAAS,IAAI,eAAe,EAAE;IAI9B,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAGpD"}
1
+ {"version":3,"file":"elevenlabs.service.d.ts","sourceRoot":"","sources":["../../../../src/services/tts/providers/elevenlabs.service.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,sBAAsB,EACtB,eAAe,EAEf,SAAS,EACT,SAAS,EACV,MAAM,UAAU,CAAC;AAiBlB,qBAAa,iBAAkB,SAAQ,sBAAsB;IAC3D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;IAE1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;;IAW1B,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAuGrD;;;;;;;;;;;;OAYG;YACW,gBAAgB;IAsE9B,SAAS,IAAI,eAAe,EAAE;IAI9B,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAGpD"}