@effect-uai/core 0.5.2 → 0.7.0

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 (175) hide show
  1. package/README.md +1 -1
  2. package/dist/{Audio-BfCTGnH3.d.mts → Audio-DPlTsNdz.d.mts} +3 -2
  3. package/dist/Audio-DPlTsNdz.d.mts.map +1 -0
  4. package/dist/{Items-BH8xUkoR.d.mts → Items-D8UaXQx_.d.mts} +15 -15
  5. package/dist/Items-D8UaXQx_.d.mts.map +1 -0
  6. package/dist/SandboxError-BvKypkJm.d.mts +158 -0
  7. package/dist/SandboxError-BvKypkJm.d.mts.map +1 -0
  8. package/dist/{Tool-87ViKCCO.d.mts → Tool-CiFXYjmR.d.mts} +11 -11
  9. package/dist/{Tool-87ViKCCO.d.mts.map → Tool-CiFXYjmR.d.mts.map} +1 -1
  10. package/dist/capabilities/Capabilities.d.mts +78 -0
  11. package/dist/capabilities/Capabilities.d.mts.map +1 -0
  12. package/dist/capabilities/Capabilities.mjs +65 -0
  13. package/dist/capabilities/Capabilities.mjs.map +1 -0
  14. package/dist/domain/Audio.d.mts +1 -1
  15. package/dist/domain/Audio.mjs.map +1 -1
  16. package/dist/domain/Items.d.mts +2 -2
  17. package/dist/domain/Items.mjs +15 -15
  18. package/dist/domain/Items.mjs.map +1 -1
  19. package/dist/domain/Music.d.mts +131 -72
  20. package/dist/domain/Music.d.mts.map +1 -1
  21. package/dist/domain/Music.mjs +36 -9
  22. package/dist/domain/Music.mjs.map +1 -1
  23. package/dist/domain/Transcript.d.mts +8 -2
  24. package/dist/domain/Transcript.d.mts.map +1 -1
  25. package/dist/domain/Transcript.mjs.map +1 -1
  26. package/dist/domain/Turn.d.mts +388 -2
  27. package/dist/domain/Turn.d.mts.map +1 -0
  28. package/dist/domain/Turn.mjs +13 -13
  29. package/dist/domain/Turn.mjs.map +1 -1
  30. package/dist/embedding-model/Embedding.d.mts +12 -2
  31. package/dist/embedding-model/Embedding.d.mts.map +1 -1
  32. package/dist/embedding-model/Embedding.mjs.map +1 -1
  33. package/dist/embedding-model/EmbeddingModel.d.mts +36 -23
  34. package/dist/embedding-model/EmbeddingModel.d.mts.map +1 -1
  35. package/dist/embedding-model/EmbeddingModel.mjs +20 -1
  36. package/dist/embedding-model/EmbeddingModel.mjs.map +1 -1
  37. package/dist/embedding-model/EmbeddingModel.test.mjs +15 -3
  38. package/dist/embedding-model/EmbeddingModel.test.mjs.map +1 -1
  39. package/dist/index.d.mts +13 -7
  40. package/dist/index.mjs +9 -3
  41. package/dist/language-model/LanguageModel.d.mts +5 -5
  42. package/dist/language-model/LanguageModel.d.mts.map +1 -1
  43. package/dist/language-model/LanguageModel.mjs.map +1 -1
  44. package/dist/loop/Loop.d.mts +37 -90
  45. package/dist/loop/Loop.d.mts.map +1 -1
  46. package/dist/loop/Loop.mjs +39 -93
  47. package/dist/loop/Loop.mjs.map +1 -1
  48. package/dist/loop/Loop.test.mjs +46 -54
  49. package/dist/loop/Loop.test.mjs.map +1 -1
  50. package/dist/music-generator/MusicGenerator.d.mts +48 -25
  51. package/dist/music-generator/MusicGenerator.d.mts.map +1 -1
  52. package/dist/music-generator/MusicGenerator.mjs +17 -9
  53. package/dist/music-generator/MusicGenerator.mjs.map +1 -1
  54. package/dist/music-generator/MusicGenerator.test.mjs +81 -56
  55. package/dist/music-generator/MusicGenerator.test.mjs.map +1 -1
  56. package/dist/sandbox/Memory.d.mts +53 -0
  57. package/dist/sandbox/Memory.d.mts.map +1 -0
  58. package/dist/sandbox/Memory.mjs +68 -0
  59. package/dist/sandbox/Memory.mjs.map +1 -0
  60. package/dist/sandbox/Sandbox.d.mts +717 -0
  61. package/dist/sandbox/Sandbox.d.mts.map +1 -0
  62. package/dist/sandbox/Sandbox.mjs +192 -0
  63. package/dist/sandbox/Sandbox.mjs.map +1 -0
  64. package/dist/sandbox/SandboxError.d.mts +2 -0
  65. package/dist/sandbox/SandboxError.mjs +89 -0
  66. package/dist/sandbox/SandboxError.mjs.map +1 -0
  67. package/dist/sandbox/SandboxImage.d.mts +28 -0
  68. package/dist/sandbox/SandboxImage.d.mts.map +1 -0
  69. package/dist/sandbox/SandboxImage.mjs +32 -0
  70. package/dist/sandbox/SandboxImage.mjs.map +1 -0
  71. package/dist/sandbox/SandboxNetwork.d.mts +34 -0
  72. package/dist/sandbox/SandboxNetwork.d.mts.map +1 -0
  73. package/dist/sandbox/SandboxNetwork.mjs +36 -0
  74. package/dist/sandbox/SandboxNetwork.mjs.map +1 -0
  75. package/dist/speech-synthesizer/SpeechSynthesizer.d.mts +84 -3
  76. package/dist/speech-synthesizer/SpeechSynthesizer.d.mts.map +1 -1
  77. package/dist/speech-synthesizer/SpeechSynthesizer.mjs +32 -2
  78. package/dist/speech-synthesizer/SpeechSynthesizer.mjs.map +1 -1
  79. package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs +59 -5
  80. package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs.map +1 -1
  81. package/dist/testing/MockMusicGenerator.d.mts +12 -7
  82. package/dist/testing/MockMusicGenerator.d.mts.map +1 -1
  83. package/dist/testing/MockMusicGenerator.mjs +4 -3
  84. package/dist/testing/MockMusicGenerator.mjs.map +1 -1
  85. package/dist/testing/MockProvider.d.mts +3 -3
  86. package/dist/testing/MockProvider.d.mts.map +1 -1
  87. package/dist/testing/MockProvider.mjs.map +1 -1
  88. package/dist/testing/MockSandbox.d.mts +604 -0
  89. package/dist/testing/MockSandbox.d.mts.map +1 -0
  90. package/dist/testing/MockSandbox.mjs +160 -0
  91. package/dist/testing/MockSandbox.mjs.map +1 -0
  92. package/dist/testing/MockSpeechSynthesizer.d.mts +27 -12
  93. package/dist/testing/MockSpeechSynthesizer.d.mts.map +1 -1
  94. package/dist/testing/MockSpeechSynthesizer.mjs +75 -51
  95. package/dist/testing/MockSpeechSynthesizer.mjs.map +1 -1
  96. package/dist/tool/{Resolvers.d.mts → Approval.d.mts} +27 -27
  97. package/dist/tool/Approval.d.mts.map +1 -0
  98. package/dist/tool/{Resolvers.mjs → Approval.mjs} +18 -18
  99. package/dist/tool/Approval.mjs.map +1 -0
  100. package/dist/tool/{Resolvers.test.mjs → Approval.test.mjs} +40 -40
  101. package/dist/tool/Approval.test.mjs.map +1 -0
  102. package/dist/tool/HistoryCheck.d.mts +6 -6
  103. package/dist/tool/HistoryCheck.d.mts.map +1 -1
  104. package/dist/tool/HistoryCheck.mjs +5 -5
  105. package/dist/tool/HistoryCheck.mjs.map +1 -1
  106. package/dist/tool/Tool.d.mts +2 -2
  107. package/dist/tool/Tool.mjs +4 -4
  108. package/dist/tool/Tool.mjs.map +1 -1
  109. package/dist/tool/ToolEvent.d.mts +19 -19
  110. package/dist/tool/ToolEvent.d.mts.map +1 -1
  111. package/dist/tool/ToolEvent.mjs +8 -8
  112. package/dist/tool/ToolEvent.mjs.map +1 -1
  113. package/dist/tool/{Outcome.d.mts → ToolResult.d.mts} +29 -29
  114. package/dist/tool/ToolResult.d.mts.map +1 -0
  115. package/dist/tool/ToolResult.mjs +61 -0
  116. package/dist/tool/ToolResult.mjs.map +1 -0
  117. package/dist/tool/Toolkit.d.mts +58 -26
  118. package/dist/tool/Toolkit.d.mts.map +1 -1
  119. package/dist/tool/Toolkit.mjs +62 -34
  120. package/dist/tool/Toolkit.mjs.map +1 -1
  121. package/dist/tool/Toolkit.test.mjs +13 -13
  122. package/dist/tool/Toolkit.test.mjs.map +1 -1
  123. package/dist/transcriber/Transcriber.d.mts +11 -10
  124. package/dist/transcriber/Transcriber.d.mts.map +1 -1
  125. package/dist/transcriber/Transcriber.mjs.map +1 -1
  126. package/dist/transcriber/Transcriber.test.mjs +3 -3
  127. package/dist/transcriber/Transcriber.test.mjs.map +1 -1
  128. package/package.json +35 -7
  129. package/src/capabilities/Capabilities.ts +81 -0
  130. package/src/domain/Audio.ts +2 -1
  131. package/src/domain/Items.ts +9 -9
  132. package/src/domain/Music.ts +142 -68
  133. package/src/domain/Transcript.ts +7 -1
  134. package/src/domain/Turn.ts +16 -16
  135. package/src/embedding-model/Embedding.ts +11 -0
  136. package/src/embedding-model/EmbeddingModel.test.ts +15 -4
  137. package/src/embedding-model/EmbeddingModel.ts +48 -21
  138. package/src/index.ts +8 -2
  139. package/src/language-model/LanguageModel.ts +3 -3
  140. package/src/loop/Loop.test.ts +93 -91
  141. package/src/loop/Loop.ts +72 -170
  142. package/src/music-generator/MusicGenerator.test.ts +78 -53
  143. package/src/music-generator/MusicGenerator.ts +65 -24
  144. package/src/sandbox/Memory.ts +128 -0
  145. package/src/sandbox/Sandbox.ts +639 -0
  146. package/src/sandbox/SandboxError.ts +140 -0
  147. package/src/sandbox/SandboxImage.ts +26 -0
  148. package/src/sandbox/SandboxNetwork.ts +34 -0
  149. package/src/speech-synthesizer/SpeechSynthesizer.test.ts +92 -3
  150. package/src/speech-synthesizer/SpeechSynthesizer.ts +109 -0
  151. package/src/testing/MockMusicGenerator.ts +28 -18
  152. package/src/testing/MockProvider.ts +21 -20
  153. package/src/testing/MockSandbox.ts +342 -0
  154. package/src/testing/MockSpeechSynthesizer.ts +137 -77
  155. package/src/tool/{Resolvers.test.ts → Approval.test.ts} +45 -54
  156. package/src/tool/{Resolvers.ts → Approval.ts} +25 -25
  157. package/src/tool/HistoryCheck.ts +10 -13
  158. package/src/tool/Tool.ts +13 -15
  159. package/src/tool/ToolEvent.ts +7 -7
  160. package/src/tool/{Outcome.ts → ToolResult.ts} +20 -20
  161. package/src/tool/Toolkit.test.ts +13 -13
  162. package/src/tool/Toolkit.ts +97 -73
  163. package/src/transcriber/Transcriber.test.ts +3 -3
  164. package/src/transcriber/Transcriber.ts +10 -7
  165. package/dist/Audio-BfCTGnH3.d.mts.map +0 -1
  166. package/dist/Items-BH8xUkoR.d.mts.map +0 -1
  167. package/dist/Turn-0CwCAyVe.d.mts +0 -388
  168. package/dist/Turn-0CwCAyVe.d.mts.map +0 -1
  169. package/dist/tool/Outcome.d.mts.map +0 -1
  170. package/dist/tool/Outcome.mjs +0 -61
  171. package/dist/tool/Outcome.mjs.map +0 -1
  172. package/dist/tool/Resolvers.d.mts.map +0 -1
  173. package/dist/tool/Resolvers.mjs.map +0 -1
  174. package/dist/tool/Resolvers.test.mjs.map +0 -1
  175. /package/dist/tool/{Resolvers.test.d.mts → Approval.test.d.mts} +0 -0
@@ -8,12 +8,10 @@ var Items_exports = /* @__PURE__ */ __exportAll({
8
8
  ContentBlock: () => ContentBlock,
9
9
  FileCitation: () => FileCitation,
10
10
  FilePath: () => FilePath,
11
- FunctionCall: () => FunctionCall,
12
- FunctionCallOutput: () => FunctionCallOutput,
11
+ HistoryItem: () => HistoryItem,
13
12
  InputImage: () => InputImage,
14
13
  InputText: () => InputText,
15
14
  InputTokensDetails: () => InputTokensDetails,
16
- Item: () => Item,
17
15
  Message: () => Message,
18
16
  OutputText: () => OutputText,
19
17
  OutputTokensDetails: () => OutputTokensDetails,
@@ -21,23 +19,25 @@ var Items_exports = /* @__PURE__ */ __exportAll({
21
19
  Refusal: () => Refusal,
22
20
  Role: () => Role,
23
21
  StopReason: () => StopReason,
22
+ ToolCall: () => ToolCall,
23
+ ToolCallOutput: () => ToolCallOutput,
24
24
  UrlCitation: () => UrlCitation,
25
25
  Usage: () => Usage,
26
26
  assistantText: () => assistantText,
27
- functionCallOutput: () => functionCallOutput,
28
27
  isContainerFileCitation: () => isContainerFileCitation,
29
28
  isFileCitation: () => isFileCitation,
30
29
  isFilePath: () => isFilePath,
31
- isFunctionCall: () => isFunctionCall,
32
- isFunctionCallOutput: () => isFunctionCallOutput,
33
30
  isInputImage: () => isInputImage,
34
31
  isInputText: () => isInputText,
35
32
  isMessage: () => isMessage,
36
33
  isOutputText: () => isOutputText,
37
34
  isReasoning: () => isReasoning,
38
35
  isRefusal: () => isRefusal,
36
+ isToolCall: () => isToolCall,
37
+ isToolCallOutput: () => isToolCallOutput,
39
38
  isUrlCitation: () => isUrlCitation,
40
39
  systemText: () => systemText,
40
+ toolCallOutput: () => toolCallOutput,
41
41
  userText: () => userText
42
42
  });
43
43
  const InputText = Schema.Struct({
@@ -123,14 +123,14 @@ const Message = Schema.Struct({
123
123
  content: Schema.Array(ContentBlock),
124
124
  providerData: ProviderData
125
125
  });
126
- const FunctionCall = Schema.Struct({
126
+ const ToolCall = Schema.Struct({
127
127
  type: Schema.Literal("function_call"),
128
128
  call_id: Schema.String,
129
129
  name: Schema.String,
130
130
  arguments: Schema.String,
131
131
  providerData: ProviderData
132
132
  });
133
- const FunctionCallOutput = Schema.Struct({
133
+ const ToolCallOutput = Schema.Struct({
134
134
  type: Schema.Literal("function_call_output"),
135
135
  call_id: Schema.String,
136
136
  output: Schema.String,
@@ -149,10 +149,10 @@ const Reasoning = Schema.Struct({
149
149
  signature: Schema.optional(Schema.String),
150
150
  providerData: ProviderData
151
151
  });
152
- const Item = Schema.Union([
152
+ const HistoryItem = Schema.Union([
153
153
  Message,
154
- FunctionCall,
155
- FunctionCallOutput,
154
+ ToolCall,
155
+ ToolCallOutput,
156
156
  Reasoning
157
157
  ]);
158
158
  const isInputText = Schema.is(InputText);
@@ -160,8 +160,8 @@ const isInputImage = Schema.is(InputImage);
160
160
  const isOutputText = Schema.is(OutputText);
161
161
  const isRefusal = Schema.is(Refusal);
162
162
  const isMessage = Schema.is(Message);
163
- const isFunctionCall = Schema.is(FunctionCall);
164
- const isFunctionCallOutput = Schema.is(FunctionCallOutput);
163
+ const isToolCall = Schema.is(ToolCall);
164
+ const isToolCallOutput = Schema.is(ToolCallOutput);
165
165
  const isReasoning = Schema.is(Reasoning);
166
166
  const InputTokensDetails = Schema.Struct({ cached_tokens: Schema.optional(Schema.Number) });
167
167
  const OutputTokensDetails = Schema.Struct({ reasoning_tokens: Schema.optional(Schema.Number) });
@@ -204,12 +204,12 @@ const assistantText = (text) => ({
204
204
  text
205
205
  }]
206
206
  });
207
- const functionCallOutput = (call_id, output) => ({
207
+ const toolCallOutput = (call_id, output) => ({
208
208
  type: "function_call_output",
209
209
  call_id,
210
210
  output
211
211
  });
212
212
  //#endregion
213
- export { Annotation, ContainerFileCitation, ContentBlock, FileCitation, FilePath, FunctionCall, FunctionCallOutput, InputImage, InputText, InputTokensDetails, Item, Message, OutputText, OutputTokensDetails, Reasoning, Refusal, Role, StopReason, UrlCitation, Usage, assistantText, functionCallOutput, isContainerFileCitation, isFileCitation, isFilePath, isFunctionCall, isFunctionCallOutput, isInputImage, isInputText, isMessage, isOutputText, isReasoning, isRefusal, isUrlCitation, systemText, Items_exports as t, userText };
213
+ export { Annotation, ContainerFileCitation, ContentBlock, FileCitation, FilePath, HistoryItem, InputImage, InputText, InputTokensDetails, Message, OutputText, OutputTokensDetails, Reasoning, Refusal, Role, StopReason, ToolCall, ToolCallOutput, UrlCitation, Usage, assistantText, isContainerFileCitation, isFileCitation, isFilePath, isInputImage, isInputText, isMessage, isOutputText, isReasoning, isRefusal, isToolCall, isToolCallOutput, isUrlCitation, systemText, Items_exports as t, toolCallOutput, userText };
214
214
 
215
215
  //# sourceMappingURL=Items.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Items.mjs","names":[],"sources":["../../src/domain/Items.ts"],"sourcesContent":["import { Schema } from \"effect\"\nimport { ImageSource } from \"./Image.js\"\n\n// ---------------------------------------------------------------------------\n// Content blocks (inside Message.content)\n// ---------------------------------------------------------------------------\n\nexport const InputText = Schema.Struct({\n type: Schema.Literal(\"input_text\"),\n text: Schema.String,\n})\nexport type InputText = typeof InputText.Type\n\n/**\n * User-provided image content block. Pair with `InputText` inside a\n * `Message.content` array to ask \"what's in this image?\" style questions.\n *\n * `source` is the cross-modality `ImageSource` from `domain/Image.ts` -\n * url, base64, or raw bytes. Provider codecs encode bytes to whatever\n * wire format the provider wants.\n */\nexport const InputImage = Schema.Struct({\n type: Schema.Literal(\"input_image\"),\n source: ImageSource,\n})\nexport type InputImage = typeof InputImage.Type\n\n// ---------------------------------------------------------------------------\n// Annotations - source / citation pointers attached to `output_text` blocks.\n// Mirrors OpenAI Responses API; other providers can omit or map onto these\n// shapes.\n// ---------------------------------------------------------------------------\n\nexport const UrlCitation = Schema.Struct({\n type: Schema.Literal(\"url_citation\"),\n url: Schema.String,\n start_index: Schema.Number,\n end_index: Schema.Number,\n title: Schema.String,\n})\nexport type UrlCitation = typeof UrlCitation.Type\n\nexport const FileCitation = Schema.Struct({\n type: Schema.Literal(\"file_citation\"),\n file_id: Schema.String,\n index: Schema.Number,\n})\nexport type FileCitation = typeof FileCitation.Type\n\nexport const ContainerFileCitation = Schema.Struct({\n type: Schema.Literal(\"container_file_citation\"),\n container_id: Schema.String,\n file_id: Schema.String,\n start_index: Schema.Number,\n end_index: Schema.Number,\n})\nexport type ContainerFileCitation = typeof ContainerFileCitation.Type\n\nexport const FilePath = Schema.Struct({\n type: Schema.Literal(\"file_path\"),\n file_id: Schema.String,\n index: Schema.Number,\n})\nexport type FilePath = typeof FilePath.Type\n\nexport const Annotation = Schema.Union([UrlCitation, FileCitation, ContainerFileCitation, FilePath])\nexport type Annotation = typeof Annotation.Type\n\nexport const isUrlCitation = Schema.is(UrlCitation)\nexport const isFileCitation = Schema.is(FileCitation)\nexport const isContainerFileCitation = Schema.is(ContainerFileCitation)\nexport const isFilePath = Schema.is(FilePath)\n\nexport const OutputText = Schema.Struct({\n type: Schema.Literal(\"output_text\"),\n text: Schema.String,\n annotations: Schema.optional(Schema.Array(Annotation)),\n})\nexport type OutputText = typeof OutputText.Type\n\n/**\n * Model-emitted refusal. Distinct from `output_text`: the model declined\n * to answer rather than producing normal output. Pair with\n * `stop_reason: \"refusal\"` on the surrounding `Turn`. Streamed via the\n * `RefusalDelta` `TurnEvent`.\n */\nexport const Refusal = Schema.Struct({\n type: Schema.Literal(\"refusal\"),\n text: Schema.String,\n})\nexport type Refusal = typeof Refusal.Type\n\nexport const ContentBlock = Schema.Union([InputText, InputImage, OutputText, Refusal])\nexport type ContentBlock = typeof ContentBlock.Type\n\nexport const Role = Schema.Literals([\"user\", \"assistant\", \"system\"])\nexport type Role = typeof Role.Type\n\n// ---------------------------------------------------------------------------\n// Provider passthrough - every Item type carries this opaque slot.\n// The framework never reads or interprets it; provider modules decode\n// their own data via their own typed readers (see e.g.\n// the `@effect-uai/responses` package).\n// ---------------------------------------------------------------------------\n\nconst ProviderData = Schema.optional(Schema.Unknown)\n\n// ---------------------------------------------------------------------------\n// Items\n// ---------------------------------------------------------------------------\n\nexport const Message = Schema.Struct({\n type: Schema.Literal(\"message\"),\n role: Role,\n content: Schema.Array(ContentBlock),\n providerData: ProviderData,\n})\nexport type Message = typeof Message.Type\n\nexport const FunctionCall = Schema.Struct({\n type: Schema.Literal(\"function_call\"),\n call_id: Schema.String,\n name: Schema.String,\n // JSON-encoded arguments string, mirroring OpenAI Responses API\n arguments: Schema.String,\n providerData: ProviderData,\n})\nexport type FunctionCall = typeof FunctionCall.Type\n\nexport const FunctionCallOutput = Schema.Struct({\n type: Schema.Literal(\"function_call_output\"),\n call_id: Schema.String,\n output: Schema.String,\n providerData: ProviderData,\n})\nexport type FunctionCallOutput = typeof FunctionCallOutput.Type\n\n/**\n * Reasoning item - top-level, mirrors OpenAI Responses API. Common shape\n * across providers covers `summary` (human-readable text) and `signature`\n * (opaque round-trip blob - Anthropic's signed thinking, OpenAI's\n * encrypted_content, etc.). Provider-specific fields go in `providerData`.\n */\nexport const Reasoning = Schema.Struct({\n type: Schema.Literal(\"reasoning\"),\n id: Schema.optional(Schema.String),\n summary: Schema.optional(Schema.String),\n signature: Schema.optional(Schema.String),\n providerData: ProviderData,\n})\nexport type Reasoning = typeof Reasoning.Type\n\nexport const Item = Schema.Union([Message, FunctionCall, FunctionCallOutput, Reasoning])\nexport type Item = typeof Item.Type\n\n// ---------------------------------------------------------------------------\n// Type guards\n// ---------------------------------------------------------------------------\n\nexport const isInputText = Schema.is(InputText)\nexport const isInputImage = Schema.is(InputImage)\nexport const isOutputText = Schema.is(OutputText)\nexport const isRefusal = Schema.is(Refusal)\n\nexport const isMessage = Schema.is(Message)\nexport const isFunctionCall = Schema.is(FunctionCall)\nexport const isFunctionCallOutput = Schema.is(FunctionCallOutput)\nexport const isReasoning = Schema.is(Reasoning)\n\n// ---------------------------------------------------------------------------\n// Usage and stop reason\n// ---------------------------------------------------------------------------\n\nexport const InputTokensDetails = Schema.Struct({\n cached_tokens: Schema.optional(Schema.Number),\n})\nexport type InputTokensDetails = typeof InputTokensDetails.Type\n\nexport const OutputTokensDetails = Schema.Struct({\n reasoning_tokens: Schema.optional(Schema.Number),\n})\nexport type OutputTokensDetails = typeof OutputTokensDetails.Type\n\nexport const Usage = Schema.Struct({\n input_tokens: Schema.optional(Schema.Number),\n output_tokens: Schema.optional(Schema.Number),\n total_tokens: Schema.optional(Schema.Number),\n input_tokens_details: Schema.optional(InputTokensDetails),\n output_tokens_details: Schema.optional(OutputTokensDetails),\n})\nexport type Usage = typeof Usage.Type\n\nexport const StopReason = Schema.Literals([\n \"stop\",\n \"tool_calls\",\n \"max_tokens\",\n \"refusal\",\n /** Provider-side safety classifier flagged the output. */\n \"content_filter\",\n /** Server-enforced cap on tool calls per turn was hit. */\n \"max_tool_calls\",\n])\nexport type StopReason = typeof StopReason.Type\n\n// ---------------------------------------------------------------------------\n// Helper constructors\n// ---------------------------------------------------------------------------\n\nexport const userText = (text: string): Message => ({\n type: \"message\",\n role: \"user\",\n content: [{ type: \"input_text\", text }],\n})\n\nexport const systemText = (text: string): Message => ({\n type: \"message\",\n role: \"system\",\n content: [{ type: \"input_text\", text }],\n})\n\nexport const assistantText = (text: string): Message => ({\n type: \"message\",\n role: \"assistant\",\n content: [{ type: \"output_text\", text }],\n})\n\nexport const functionCallOutput = (call_id: string, output: string): FunctionCallOutput => ({\n type: \"function_call_output\",\n call_id,\n output,\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAa,YAAY,OAAO,OAAO;CACrC,MAAM,OAAO,QAAQ,aAAa;CAClC,MAAM,OAAO;CACd,CAAC;;;;;;;;;AAWF,MAAa,aAAa,OAAO,OAAO;CACtC,MAAM,OAAO,QAAQ,cA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B,OAAO,SAAS,mBAAmB;CACzD,uBAAuB,OAAO,SAAS,oBAAoB;CAC5D,CAAC;AAGF,MAAa,aAAa,OAAO,SAAS;CACxC;CACA;CACA;CACA;CAEA;CAEA;CACD,CAAC;AAOF,MAAa,YAAY,UAA2B;CAClD,MAAM;CACN,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAc;EAAM,CAAC;CACxC;AAED,MAAa,cAAc,UAA2B;CACpD,MAAM;CACN,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAc;EAAM,CAAC;CACxC;AAED,MAAa,iBAAiB,UAA2B;CACvD,MAAM;CACN,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAe;EAAM,CAAC;CACzC;AAED,MAAa,sBAAsB,SAAiB,YAAwC;CAC1F,MAAM;CACN;CACA;CACD"}
1
+ {"version":3,"file":"Items.mjs","names":[],"sources":["../../src/domain/Items.ts"],"sourcesContent":["import { Schema } from \"effect\"\nimport { ImageSource } from \"./Image.js\"\n\n// ---------------------------------------------------------------------------\n// Content blocks (inside Message.content)\n// ---------------------------------------------------------------------------\n\nexport const InputText = Schema.Struct({\n type: Schema.Literal(\"input_text\"),\n text: Schema.String,\n})\nexport type InputText = typeof InputText.Type\n\n/**\n * User-provided image content block. Pair with `InputText` inside a\n * `Message.content` array to ask \"what's in this image?\" style questions.\n *\n * `source` is the cross-modality `ImageSource` from `domain/Image.ts` -\n * url, base64, or raw bytes. Provider codecs encode bytes to whatever\n * wire format the provider wants.\n */\nexport const InputImage = Schema.Struct({\n type: Schema.Literal(\"input_image\"),\n source: ImageSource,\n})\nexport type InputImage = typeof InputImage.Type\n\n// ---------------------------------------------------------------------------\n// Annotations - source / citation pointers attached to `output_text` blocks.\n// Mirrors OpenAI Responses API; other providers can omit or map onto these\n// shapes.\n// ---------------------------------------------------------------------------\n\nexport const UrlCitation = Schema.Struct({\n type: Schema.Literal(\"url_citation\"),\n url: Schema.String,\n start_index: Schema.Number,\n end_index: Schema.Number,\n title: Schema.String,\n})\nexport type UrlCitation = typeof UrlCitation.Type\n\nexport const FileCitation = Schema.Struct({\n type: Schema.Literal(\"file_citation\"),\n file_id: Schema.String,\n index: Schema.Number,\n})\nexport type FileCitation = typeof FileCitation.Type\n\nexport const ContainerFileCitation = Schema.Struct({\n type: Schema.Literal(\"container_file_citation\"),\n container_id: Schema.String,\n file_id: Schema.String,\n start_index: Schema.Number,\n end_index: Schema.Number,\n})\nexport type ContainerFileCitation = typeof ContainerFileCitation.Type\n\nexport const FilePath = Schema.Struct({\n type: Schema.Literal(\"file_path\"),\n file_id: Schema.String,\n index: Schema.Number,\n})\nexport type FilePath = typeof FilePath.Type\n\nexport const Annotation = Schema.Union([UrlCitation, FileCitation, ContainerFileCitation, FilePath])\nexport type Annotation = typeof Annotation.Type\n\nexport const isUrlCitation = Schema.is(UrlCitation)\nexport const isFileCitation = Schema.is(FileCitation)\nexport const isContainerFileCitation = Schema.is(ContainerFileCitation)\nexport const isFilePath = Schema.is(FilePath)\n\nexport const OutputText = Schema.Struct({\n type: Schema.Literal(\"output_text\"),\n text: Schema.String,\n annotations: Schema.optional(Schema.Array(Annotation)),\n})\nexport type OutputText = typeof OutputText.Type\n\n/**\n * Model-emitted refusal. Distinct from `output_text`: the model declined\n * to answer rather than producing normal output. Pair with\n * `stop_reason: \"refusal\"` on the surrounding `Turn`. Streamed via the\n * `RefusalDelta` `TurnEvent`.\n */\nexport const Refusal = Schema.Struct({\n type: Schema.Literal(\"refusal\"),\n text: Schema.String,\n})\nexport type Refusal = typeof Refusal.Type\n\nexport const ContentBlock = Schema.Union([InputText, InputImage, OutputText, Refusal])\nexport type ContentBlock = typeof ContentBlock.Type\n\nexport const Role = Schema.Literals([\"user\", \"assistant\", \"system\"])\nexport type Role = typeof Role.Type\n\n// ---------------------------------------------------------------------------\n// Provider passthrough - every Item type carries this opaque slot.\n// The framework never reads or interprets it; provider modules decode\n// their own data via their own typed readers (see e.g.\n// the `@effect-uai/responses` package).\n// ---------------------------------------------------------------------------\n\nconst ProviderData = Schema.optional(Schema.Unknown)\n\n// ---------------------------------------------------------------------------\n// Items\n// ---------------------------------------------------------------------------\n\nexport const Message = Schema.Struct({\n type: Schema.Literal(\"message\"),\n role: Role,\n content: Schema.Array(ContentBlock),\n providerData: ProviderData,\n})\nexport type Message = typeof Message.Type\n\nexport const ToolCall = Schema.Struct({\n type: Schema.Literal(\"function_call\"),\n call_id: Schema.String,\n name: Schema.String,\n // JSON-encoded arguments string, mirroring OpenAI Responses API\n arguments: Schema.String,\n providerData: ProviderData,\n})\nexport type ToolCall = typeof ToolCall.Type\n\nexport const ToolCallOutput = Schema.Struct({\n type: Schema.Literal(\"function_call_output\"),\n call_id: Schema.String,\n output: Schema.String,\n providerData: ProviderData,\n})\nexport type ToolCallOutput = typeof ToolCallOutput.Type\n\n/**\n * Reasoning item - top-level, mirrors OpenAI Responses API. Common shape\n * across providers covers `summary` (human-readable text) and `signature`\n * (opaque round-trip blob - Anthropic's signed thinking, OpenAI's\n * encrypted_content, etc.). Provider-specific fields go in `providerData`.\n */\nexport const Reasoning = Schema.Struct({\n type: Schema.Literal(\"reasoning\"),\n id: Schema.optional(Schema.String),\n summary: Schema.optional(Schema.String),\n signature: Schema.optional(Schema.String),\n providerData: ProviderData,\n})\nexport type Reasoning = typeof Reasoning.Type\n\nexport const HistoryItem = Schema.Union([Message, ToolCall, ToolCallOutput, Reasoning])\nexport type HistoryItem = typeof HistoryItem.Type\n\n// ---------------------------------------------------------------------------\n// Type guards\n// ---------------------------------------------------------------------------\n\nexport const isInputText = Schema.is(InputText)\nexport const isInputImage = Schema.is(InputImage)\nexport const isOutputText = Schema.is(OutputText)\nexport const isRefusal = Schema.is(Refusal)\n\nexport const isMessage = Schema.is(Message)\nexport const isToolCall = Schema.is(ToolCall)\nexport const isToolCallOutput = Schema.is(ToolCallOutput)\nexport const isReasoning = Schema.is(Reasoning)\n\n// ---------------------------------------------------------------------------\n// Usage and stop reason\n// ---------------------------------------------------------------------------\n\nexport const InputTokensDetails = Schema.Struct({\n cached_tokens: Schema.optional(Schema.Number),\n})\nexport type InputTokensDetails = typeof InputTokensDetails.Type\n\nexport const OutputTokensDetails = Schema.Struct({\n reasoning_tokens: Schema.optional(Schema.Number),\n})\nexport type OutputTokensDetails = typeof OutputTokensDetails.Type\n\nexport const Usage = Schema.Struct({\n input_tokens: Schema.optional(Schema.Number),\n output_tokens: Schema.optional(Schema.Number),\n total_tokens: Schema.optional(Schema.Number),\n input_tokens_details: Schema.optional(InputTokensDetails),\n output_tokens_details: Schema.optional(OutputTokensDetails),\n})\nexport type Usage = typeof Usage.Type\n\nexport const StopReason = Schema.Literals([\n \"stop\",\n \"tool_calls\",\n \"max_tokens\",\n \"refusal\",\n /** Provider-side safety classifier flagged the output. */\n \"content_filter\",\n /** Server-enforced cap on tool calls per turn was hit. */\n \"max_tool_calls\",\n])\nexport type StopReason = typeof StopReason.Type\n\n// ---------------------------------------------------------------------------\n// Helper constructors\n// ---------------------------------------------------------------------------\n\nexport const userText = (text: string): Message => ({\n type: \"message\",\n role: \"user\",\n content: [{ type: \"input_text\", text }],\n})\n\nexport const systemText = (text: string): Message => ({\n type: \"message\",\n role: \"system\",\n content: [{ type: \"input_text\", text }],\n})\n\nexport const assistantText = (text: string): Message => ({\n type: \"message\",\n role: \"assistant\",\n content: [{ type: \"output_text\", text }],\n})\n\nexport const toolCallOutput = (call_id: string, output: string): ToolCallOutput => ({\n type: \"function_call_output\",\n call_id,\n output,\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAa,YAAY,OAAO,OAAO;CACrC,MAAM,OAAO,QAAQ,aAAa;CAClC,MAAM,OAAO;CACd,CAAC;;;;;;;;;AAWF,MAAa,aAAa,OAAO,OAAO;CACtC,MAAM,OAAO,QAAQ,cAAc;CACnC,QAAQ;CACT,CAAC;AASF,MAAa,cAAc,OAAO,OAAO;CACvC,MAAM,OAAO,QAAQ,eAAe;CACpC,KAAK,OAAO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ACA;CACA;CACA;CAEA;CAEA;CACD,CAAC;AAOF,MAAa,YAAY,UAA2B;CAClD,MAAM;CACN,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAc;EAAM,CAAC;CACxC;AAED,MAAa,cAAc,UAA2B;CACpD,MAAM;CACN,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAc;EAAM,CAAC;CACxC;AAED,MAAa,iBAAiB,UAA2B;CACvD,MAAM;CACN,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAe;EAAM,CAAC;CACzC;AAED,MAAa,kBAAkB,SAAiB,YAAoC;CAClF,MAAM;CACN;CACA;CACD"}
@@ -1,116 +1,175 @@
1
- import { r as AudioFormat, t as AudioBlob } from "../Audio-BfCTGnH3.mjs";
1
+ import { n as AudioChunk, r as AudioFormat, t as AudioBlob } from "../Audio-DPlTsNdz.mjs";
2
+ import { Duration } from "effect";
2
3
 
3
4
  //#region src/domain/Music.d.ts
4
5
  declare namespace Music_d_exports {
5
- export { CommonGenerateMusicRequest, CommonStreamGenerateMusicRequest, MusicResult, MusicSessionInput, WeightedPrompt, configInput, controlInput, isConfigInput, isControlInput, isPromptsInput, promptsInput };
6
+ export { CommonGenerateMusicRequest, CommonStreamGenerateMusicRequest, GenerateResult, MusicResult, MusicSection, MusicSessionControl, MusicSessionInput, MusicStreamEvent, Watermark, WeightedPrompt, audioEvent, controlInput, filteredPromptEvent, isAudioEvent, isControlInput, isFilteredPromptEvent, isPromptsInput, isWarningEvent, promptsInput, singleVariant, warningEvent };
6
7
  }
7
8
  /**
8
9
  * Prompt fragment with a relative weight. Native to Lyria RealTime
9
- * (`{ text, weight }` pairs blended in the model). Single-prompt
10
- * providers (Suno, Mureka, MiniMax) flatten to text at the adapter
11
- * layer.
10
+ * (`{ text, weight }` pairs blended in the model) and Riffusion compose.
11
+ * Single-prompt providers (the majority) treat a 1-element array with
12
+ * `weight: 1` as a plain prompt.
12
13
  */
13
14
  type WeightedPrompt = {
14
15
  readonly text: string; /** Default `1.0`. Range typically `[0, 1]`; provider-dependent. */
15
16
  readonly weight?: number;
16
17
  };
17
18
  /**
18
- * Cross-provider music-generation request. Provider-specific extras
19
- * (Lyria `mode`, ElevenLabs `composition_plan`, Suno custom-mode `title`,
20
- * MiniMax `lyrics_optimizer`) live on each provider's typed request
21
- * which extends this and narrows `model`.
19
+ * Cross-provider music-generation request. Trimmed to fields the
20
+ * majority of music providers honor structurally; provider-specific
21
+ * extras (Lyria `bpm` / `scale`, ElevenLabs `compositionPlan` /
22
+ * `signWithC2pa`, Suno `style` / `personaId`, MiniMax `lyricsOptimizer`,
23
+ * `instrumental` on providers that ship a wire toggle) live on each
24
+ * provider's typed request which extends this and narrows `model`.
25
+ *
26
+ * Music providers are one-shot text-to-audio, not conversational. No
27
+ * `messages[]` shape applies.
22
28
  */
23
29
  type CommonGenerateMusicRequest = {
24
- /** Model identifier. Each provider narrows. */readonly model: string; /** Single prompt string or weighted-prompt list (blended where supported). */
25
- readonly prompts: string | ReadonlyArray<WeightedPrompt>;
30
+ /** Model identifier. Each provider narrows. */readonly model: string; /** Single prompt string. Weighted blends are provider-typed extras. */
31
+ readonly prompt: string;
26
32
  /**
27
- * Lyrics text, optionally with section tags like `[Verse]` / `[Chorus]` /
28
- * `[Bridge]` / `[Outro]`. Ignored for instrumental-only providers or
29
- * when `instrumental: true`.
33
+ * Lyrics text, optionally with section tags like `[Verse]` /
34
+ * `[Chorus]` / `[Bridge]` / `[Outro]`. Routed to a structured wire
35
+ * field on providers that have one (ElevenLabs `lines`, MiniMax
36
+ * `lyrics`, Mureka `lyrics`, Suno custom-mode `prompt`); embedded in
37
+ * the prompt with a warning on providers without one (Lyria 3,
38
+ * Riffusion).
30
39
  */
31
- readonly lyrics?: string; /** Target duration in seconds. Provider may treat as a hint or hard limit. */
32
- readonly durationSeconds?: number; /** Beats per minute (60–200 typical). */
33
- readonly bpm?: number;
40
+ readonly lyrics?: string; /** Target duration. Provider may treat as a hint or hard limit. */
41
+ readonly duration?: Duration.Duration;
34
42
  /**
35
- * Musical key/mode hint. Provider-specific vocabulary (e.g. Lyria
36
- * RealTime uses enum values like `"C_MAJOR"`, `"A_MINOR"`).
43
+ * Reproducibility seed. Tuning hint (bucket 3): honored where the
44
+ * provider takes one (Lyria 2 Vertex, Lyria RealTime, ElevenLabs
45
+ * with `compositionPlan`, Stable Audio, MusicGen); silently ignored
46
+ * elsewhere.
37
47
  */
38
- readonly scale?: string; /** Skip vocals / lyrics. */
39
- readonly instrumental?: boolean; /** Preferred output format. Provider may override. */
48
+ readonly seed?: number; /** Preferred output format. Provider may override. */
40
49
  readonly outputFormat?: AudioFormat;
41
50
  };
42
51
  /**
43
- * Streamed-output request. Same shape as the sync request — the
52
+ * Streamed-output request. Same shape as the sync request: the
44
53
  * streaming variant only differs in how the response is delivered.
45
54
  */
46
55
  type CommonStreamGenerateMusicRequest = CommonGenerateMusicRequest;
47
56
  /**
48
- * Bidirectional-session input. The user pushes one of these per
49
- * change: a new prompt blend, a config delta, or a playback control.
50
- * Lyria RealTime is the only provider currently surfacing these.
57
+ * Playback-control vocabulary that converges across interactive-media
58
+ * protocols (Web Audio, MIDI sequencer control, music SDK surfaces).
59
+ * Provider-specific control actions (Lyria's `reset_context` and any
60
+ * future provider's extras) live on the provider-typed session-input
61
+ * union.
62
+ */
63
+ type MusicSessionControl = "play" | "pause" | "stop" | "reset";
64
+ /**
65
+ * Bidirectional-session input on the cross-provider surface. Two
66
+ * load-bearing actions every interactive music session needs:
67
+ *
68
+ * - `prompts` — steer the active generation with a (single or
69
+ * weighted) prompt blend.
70
+ * - `control` — play / pause / stop / reset.
71
+ *
72
+ * Provider-typed services extend this union with their own `config`
73
+ * variant for model-specific knobs (Lyria RealTime exposes density /
74
+ * brightness / mute-stems / BPM / scale / etc. via its own
75
+ * `LyriaRealtimeSessionInput`).
51
76
  */
52
77
  type MusicSessionInput = {
53
78
  readonly _tag: "prompts";
54
79
  readonly prompts: ReadonlyArray<WeightedPrompt>;
55
- } | {
56
- readonly _tag: "config";
57
- readonly config: {
58
- readonly bpm?: number;
59
- readonly scale?: string;
60
- readonly density?: number;
61
- readonly brightness?: number;
62
- readonly guidance?: number;
63
- readonly temperature?: number;
64
- readonly topK?: number;
65
- readonly seed?: number;
66
- readonly muteBass?: boolean;
67
- readonly muteDrums?: boolean;
68
- readonly onlyBassAndDrums?: boolean;
69
- };
70
80
  } | {
71
81
  readonly _tag: "control";
72
- readonly action: "play" | "pause" | "stop" | "reset_context";
82
+ readonly action: MusicSessionControl;
73
83
  };
74
84
  declare const promptsInput: (prompts: ReadonlyArray<WeightedPrompt>) => MusicSessionInput;
75
- declare const configInput: (config: (MusicSessionInput & {
76
- _tag: "config";
77
- })["config"]) => MusicSessionInput;
78
- declare const controlInput: (action: (MusicSessionInput & {
79
- _tag: "control";
80
- })["action"]) => MusicSessionInput;
85
+ declare const controlInput: (action: MusicSessionControl) => MusicSessionInput;
81
86
  /**
82
- * Sync-generation result. Extends `AudioBlob` with provider-side
83
- * metadata that's common across music providers:
84
- *
85
- * - `songId` — Suno task id, ElevenLabs `song_id`, etc. Used for
86
- * back-reference (re-download, stem export, follow-up edits).
87
- * - `lyrics` — generated lyrics when the model returned them (Lyria
88
- * text part, Mureka, Suno).
89
- * - `sections` — structured section markers (Lyria optional JSON
90
- * structure response).
91
- * - `watermark` — presence marker (Lyria SynthID is always set).
87
+ * Watermark kind on the response. SynthID is mandatory on Lyria; C2PA
88
+ * is opt-in on ElevenLabs. No provider exposes additional metadata
89
+ * about the watermark itself, so a bare literal-union is enough.
92
90
  */
93
- type MusicResult = AudioBlob & {
94
- readonly songId?: string;
95
- readonly lyrics?: string;
96
- readonly sections?: ReadonlyArray<{
97
- readonly label: string;
98
- readonly startSeconds: number;
99
- readonly endSeconds: number;
100
- }>;
101
- readonly watermark?: {
102
- readonly kind: string;
103
- };
91
+ type Watermark = "synthid" | "c2pa" | (string & {});
92
+ /**
93
+ * Labelled section with absolute timing. Populated when the provider
94
+ * returns structured section metadata (Lyria text part, ElevenLabs
95
+ * `/v1/music/detailed` with `with_timestamps`).
96
+ */
97
+ type MusicSection = {
98
+ readonly label: string;
99
+ readonly startSeconds: number;
100
+ readonly endSeconds: number;
101
+ };
102
+ /**
103
+ * Single generated track. Composes `AudioBlob` rather than extending
104
+ * it — `result.audio` is the raw blob, `result.songId` / `lyrics` /
105
+ * `sections` / `watermark` are provider-side metadata when returned.
106
+ */
107
+ type MusicResult = {
108
+ readonly audio: AudioBlob;
109
+ /**
110
+ * Provider identifier, useful when routing through multiple
111
+ * providers in a single pipeline (`"lyria"`, `"elevenlabs-music"`,
112
+ * etc.).
113
+ */
114
+ readonly provider?: string; /** Provider-side ID for back-reference (re-download, extension, stems). */
115
+ readonly songId?: string; /** Generated or transcribed lyrics when the provider returned them. */
116
+ readonly lyrics?: string; /** Structured section markers when the provider returned them. */
117
+ readonly sections?: ReadonlyArray<MusicSection>; /** Watermark presence indicator when the provider applied one. */
118
+ readonly watermark?: Watermark;
119
+ };
120
+ /**
121
+ * Result of a `generate` call. Suno and Mureka always return 2 tracks
122
+ * per request; every other provider returns 1. `primary` is the
123
+ * caller-friendly convenience; `variants` carries every track the
124
+ * provider produced (length ≥ 1; `primary === variants[0]`).
125
+ */
126
+ type GenerateResult = {
127
+ readonly primary: MusicResult;
128
+ readonly variants: ReadonlyArray<MusicResult>;
129
+ };
130
+ /**
131
+ * In-band event on the bidirectional `streamGenerationFrom` output
132
+ * stream. Audio chunks flow as `audio`; server-side warnings
133
+ * (`warning`) and prompt-filter rejections (`filteredPrompt`) flow
134
+ * alongside rather than going to a side-channel log.
135
+ */
136
+ type MusicStreamEvent = {
137
+ readonly _tag: "audio";
138
+ readonly chunk: AudioChunk;
139
+ } | {
140
+ readonly _tag: "warning";
141
+ readonly message: string;
142
+ } | {
143
+ readonly _tag: "filteredPrompt";
144
+ readonly prompt: string;
145
+ readonly reason: string;
104
146
  };
105
147
  declare const isPromptsInput: (i: MusicSessionInput) => i is MusicSessionInput & {
106
148
  _tag: "prompts";
107
149
  };
108
- declare const isConfigInput: (i: MusicSessionInput) => i is MusicSessionInput & {
109
- _tag: "config";
110
- };
111
150
  declare const isControlInput: (i: MusicSessionInput) => i is MusicSessionInput & {
112
151
  _tag: "control";
113
152
  };
153
+ declare const audioEvent: (chunk: AudioChunk) => MusicStreamEvent;
154
+ declare const warningEvent: (message: string) => MusicStreamEvent;
155
+ declare const filteredPromptEvent: (prompt: string, reason: string) => MusicStreamEvent;
156
+ declare const isAudioEvent: (e: MusicStreamEvent) => e is MusicStreamEvent & {
157
+ _tag: "audio";
158
+ };
159
+ declare const isWarningEvent: (e: MusicStreamEvent) => e is MusicStreamEvent & {
160
+ _tag: "warning";
161
+ };
162
+ declare const isFilteredPromptEvent: (e: MusicStreamEvent) => e is MusicStreamEvent & {
163
+ _tag: "filteredPrompt";
164
+ };
165
+ /**
166
+ * Build a single-variant `GenerateResult` from a `MusicResult`.
167
+ * Convenience for providers that always return exactly one track
168
+ * (Lyria, ElevenLabs, MiniMax, Stable Audio, MusicGen, Riffusion,
169
+ * Tencent). Providers that return multiple tracks (Suno, Mureka)
170
+ * construct the `GenerateResult` directly.
171
+ */
172
+ declare const singleVariant: (result: MusicResult) => GenerateResult;
114
173
  //#endregion
115
- export { CommonGenerateMusicRequest, CommonStreamGenerateMusicRequest, MusicResult, MusicSessionInput, WeightedPrompt, configInput, controlInput, isConfigInput, isControlInput, isPromptsInput, promptsInput, Music_d_exports as t };
174
+ export { CommonGenerateMusicRequest, CommonStreamGenerateMusicRequest, GenerateResult, MusicResult, MusicSection, MusicSessionControl, MusicSessionInput, MusicStreamEvent, Watermark, WeightedPrompt, audioEvent, controlInput, filteredPromptEvent, isAudioEvent, isControlInput, isFilteredPromptEvent, isPromptsInput, isWarningEvent, promptsInput, singleVariant, Music_d_exports as t, warningEvent };
116
175
  //# sourceMappingURL=Music.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Music.d.mts","names":[],"sources":["../../src/domain/Music.ts"],"mappings":";;;;;;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AAA;EAAA,SACD,OAAA,EAAS,WAAA;EAAA,SACT,QAAA,EAAU,aAAA,CAAc,WAAA;AAAA;AAFnC;;;;;;AAAA,KAWY,gBAAA;EAAA,SACG,IAAA;EAAA,SAAwB,KAAA,EAAO,UAAA;AAAA;EAAA,SAC/B,IAAA;EAAA,SAA0B,OAAA;AAAA;EAAA,SAC1B,IAAA;EAAA,SAAiC,MAAA;EAAA,SAAyB,MAAA;AAAA;AAAA,cAE5D,cAAA,GACX,CAAA,EAAG,iBAAA,KACF,CAAA,IAAK,iBAAA;EAAsB,IAAA;AAAA;AAAA,cACjB,cAAA,GACX,CAAA,EAAG,iBAAA,KACF,CAAA,IAAK,iBAAA;EAAsB,IAAA;AAAA;AAAA,cAEjB,UAAA,GAAc,KAAA,EAAO,UAAA,KAAa,gBAAA;AAAA,cAClC,YAAA,GAAgB,OAAA,aAAkB,gBAAA;AAAA,cAIlC,mBAAA,GAAuB,MAAA,UAAgB,MAAA,aAAiB,gBAAA;AAAA,cAMxD,YAAA,GAAgB,CAAA,EAAG,gBAAA,KAAmB,CAAA,IAAK,gBAAA;EAAqB,IAAA;AAAA;AAAA,cAEhE,cAAA,GAAkB,CAAA,EAAG,gBAAA,KAAmB,CAAA,IAAK,gBAAA;EAAqB,IAAA;AAAA;AAAA,cAElE,qBAAA,GACX,CAAA,EAAG,gBAAA,KACF,CAAA,IAAK,gBAAA;EAAqB,IAAA;AAAA;;;;;;AArB7B;;cA8Ba,aAAA,GAAiB,MAAA,EAAQ,WAAA,KAAc,cAAA"}
@@ -1,29 +1,56 @@
1
1
  import { n as __exportAll } from "../chunk-uyGKjUfl.mjs";
2
2
  //#region src/domain/Music.ts
3
3
  var Music_exports = /* @__PURE__ */ __exportAll({
4
- configInput: () => configInput,
4
+ audioEvent: () => audioEvent,
5
5
  controlInput: () => controlInput,
6
- isConfigInput: () => isConfigInput,
6
+ filteredPromptEvent: () => filteredPromptEvent,
7
+ isAudioEvent: () => isAudioEvent,
7
8
  isControlInput: () => isControlInput,
9
+ isFilteredPromptEvent: () => isFilteredPromptEvent,
8
10
  isPromptsInput: () => isPromptsInput,
9
- promptsInput: () => promptsInput
11
+ isWarningEvent: () => isWarningEvent,
12
+ promptsInput: () => promptsInput,
13
+ singleVariant: () => singleVariant,
14
+ warningEvent: () => warningEvent
10
15
  });
11
16
  const promptsInput = (prompts) => ({
12
17
  _tag: "prompts",
13
18
  prompts
14
19
  });
15
- const configInput = (config) => ({
16
- _tag: "config",
17
- config
18
- });
19
20
  const controlInput = (action) => ({
20
21
  _tag: "control",
21
22
  action
22
23
  });
23
24
  const isPromptsInput = (i) => i._tag === "prompts";
24
- const isConfigInput = (i) => i._tag === "config";
25
25
  const isControlInput = (i) => i._tag === "control";
26
+ const audioEvent = (chunk) => ({
27
+ _tag: "audio",
28
+ chunk
29
+ });
30
+ const warningEvent = (message) => ({
31
+ _tag: "warning",
32
+ message
33
+ });
34
+ const filteredPromptEvent = (prompt, reason) => ({
35
+ _tag: "filteredPrompt",
36
+ prompt,
37
+ reason
38
+ });
39
+ const isAudioEvent = (e) => e._tag === "audio";
40
+ const isWarningEvent = (e) => e._tag === "warning";
41
+ const isFilteredPromptEvent = (e) => e._tag === "filteredPrompt";
42
+ /**
43
+ * Build a single-variant `GenerateResult` from a `MusicResult`.
44
+ * Convenience for providers that always return exactly one track
45
+ * (Lyria, ElevenLabs, MiniMax, Stable Audio, MusicGen, Riffusion,
46
+ * Tencent). Providers that return multiple tracks (Suno, Mureka)
47
+ * construct the `GenerateResult` directly.
48
+ */
49
+ const singleVariant = (result) => ({
50
+ primary: result,
51
+ variants: [result]
52
+ });
26
53
  //#endregion
27
- export { configInput, controlInput, isConfigInput, isControlInput, isPromptsInput, promptsInput, Music_exports as t };
54
+ export { audioEvent, controlInput, filteredPromptEvent, isAudioEvent, isControlInput, isFilteredPromptEvent, isPromptsInput, isWarningEvent, promptsInput, singleVariant, Music_exports as t, warningEvent };
28
55
 
29
56
  //# sourceMappingURL=Music.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Music.mjs","names":[],"sources":["../../src/domain/Music.ts"],"sourcesContent":["import type { AudioBlob, AudioFormat } from \"./Audio.js\"\n\n/**\n * Prompt fragment with a relative weight. Native to Lyria RealTime\n * (`{ text, weight }` pairs blended in the model). Single-prompt\n * providers (Suno, Mureka, MiniMax) flatten to text at the adapter\n * layer.\n */\nexport type WeightedPrompt = {\n readonly text: string\n /** Default `1.0`. Range typically `[0, 1]`; provider-dependent. */\n readonly weight?: number\n}\n\n/**\n * Cross-provider music-generation request. Provider-specific extras\n * (Lyria `mode`, ElevenLabs `composition_plan`, Suno custom-mode `title`,\n * MiniMax `lyrics_optimizer`) live on each provider's typed request\n * which extends this and narrows `model`.\n */\nexport type CommonGenerateMusicRequest = {\n /** Model identifier. Each provider narrows. */\n readonly model: string\n /** Single prompt string or weighted-prompt list (blended where supported). */\n readonly prompts: string | ReadonlyArray<WeightedPrompt>\n /**\n * Lyrics text, optionally with section tags like `[Verse]` / `[Chorus]` /\n * `[Bridge]` / `[Outro]`. Ignored for instrumental-only providers or\n * when `instrumental: true`.\n */\n readonly lyrics?: string\n /** Target duration in seconds. Provider may treat as a hint or hard limit. */\n readonly durationSeconds?: number\n /** Beats per minute (60–200 typical). */\n readonly bpm?: number\n /**\n * Musical key/mode hint. Provider-specific vocabulary (e.g. Lyria\n * RealTime uses enum values like `\"C_MAJOR\"`, `\"A_MINOR\"`).\n */\n readonly scale?: string\n /** Skip vocals / lyrics. */\n readonly instrumental?: boolean\n /** Preferred output format. Provider may override. */\n readonly outputFormat?: AudioFormat\n}\n\n/**\n * Streamed-output request. Same shape as the sync request — the\n * streaming variant only differs in how the response is delivered.\n */\nexport type CommonStreamGenerateMusicRequest = CommonGenerateMusicRequest\n\n/**\n * Bidirectional-session input. The user pushes one of these per\n * change: a new prompt blend, a config delta, or a playback control.\n * Lyria RealTime is the only provider currently surfacing these.\n */\nexport type MusicSessionInput =\n | { readonly _tag: \"prompts\"; readonly prompts: ReadonlyArray<WeightedPrompt> }\n | {\n readonly _tag: \"config\"\n readonly config: {\n readonly bpm?: number\n readonly scale?: string\n readonly density?: number\n readonly brightness?: number\n readonly guidance?: number\n readonly temperature?: number\n readonly topK?: number\n readonly seed?: number\n readonly muteBass?: boolean\n readonly muteDrums?: boolean\n readonly onlyBassAndDrums?: boolean\n }\n }\n | { readonly _tag: \"control\"; readonly action: \"play\" | \"pause\" | \"stop\" | \"reset_context\" }\n\nexport const promptsInput = (prompts: ReadonlyArray<WeightedPrompt>): MusicSessionInput => ({\n _tag: \"prompts\",\n prompts,\n})\n\nexport const configInput = (\n config: (MusicSessionInput & { _tag: \"config\" })[\"config\"],\n): MusicSessionInput => ({ _tag: \"config\", config })\n\nexport const controlInput = (\n action: (MusicSessionInput & { _tag: \"control\" })[\"action\"],\n): MusicSessionInput => ({ _tag: \"control\", action })\n\n/**\n * Sync-generation result. Extends `AudioBlob` with provider-side\n * metadata that's common across music providers:\n *\n * - `songId` — Suno task id, ElevenLabs `song_id`, etc. Used for\n * back-reference (re-download, stem export, follow-up edits).\n * - `lyrics` — generated lyrics when the model returned them (Lyria\n * text part, Mureka, Suno).\n * - `sections` — structured section markers (Lyria optional JSON\n * structure response).\n * - `watermark` — presence marker (Lyria SynthID is always set).\n */\nexport type MusicResult = AudioBlob & {\n readonly songId?: string\n readonly lyrics?: string\n readonly sections?: ReadonlyArray<{\n readonly label: string\n readonly startSeconds: number\n readonly endSeconds: number\n }>\n readonly watermark?: { readonly kind: string }\n}\n\nexport const isPromptsInput = (\n i: MusicSessionInput,\n): i is MusicSessionInput & { _tag: \"prompts\" } => i._tag === \"prompts\"\nexport const isConfigInput = (i: MusicSessionInput): i is MusicSessionInput & { _tag: \"config\" } =>\n i._tag === \"config\"\nexport const isControlInput = (\n i: MusicSessionInput,\n): i is MusicSessionInput & { _tag: \"control\" } => i._tag === \"control\"\n"],"mappings":";;;;;;;;;;AA6EA,MAAa,gBAAgB,aAA+D;CAC1F,MAAM;CACN;CACD;AAED,MAAa,eACX,YACuB;CAAE,MAAM;CAAU;CAAQ;AAEnD,MAAa,gBACX,YACuB;CAAE,MAAM;CAAW;CAAQ;AAyBpD,MAAa,kBACX,MACiD,EAAE,SAAS;AAC9D,MAAa,iBAAiB,MAC5B,EAAE,SAAS;AACb,MAAa,kBACX,MACiD,EAAE,SAAS"}
1
+ {"version":3,"file":"Music.mjs","names":[],"sources":["../../src/domain/Music.ts"],"sourcesContent":["import type { Duration } from \"effect\"\nimport type { AudioBlob, AudioChunk, AudioFormat } from \"./Audio.js\"\n\n/**\n * Prompt fragment with a relative weight. Native to Lyria RealTime\n * (`{ text, weight }` pairs blended in the model) and Riffusion compose.\n * Single-prompt providers (the majority) treat a 1-element array with\n * `weight: 1` as a plain prompt.\n */\nexport type WeightedPrompt = {\n readonly text: string\n /** Default `1.0`. Range typically `[0, 1]`; provider-dependent. */\n readonly weight?: number\n}\n\n/**\n * Cross-provider music-generation request. Trimmed to fields the\n * majority of music providers honor structurally; provider-specific\n * extras (Lyria `bpm` / `scale`, ElevenLabs `compositionPlan` /\n * `signWithC2pa`, Suno `style` / `personaId`, MiniMax `lyricsOptimizer`,\n * `instrumental` on providers that ship a wire toggle) live on each\n * provider's typed request which extends this and narrows `model`.\n *\n * Music providers are one-shot text-to-audio, not conversational. No\n * `messages[]` shape applies.\n */\nexport type CommonGenerateMusicRequest = {\n /** Model identifier. Each provider narrows. */\n readonly model: string\n /** Single prompt string. Weighted blends are provider-typed extras. */\n readonly prompt: string\n /**\n * Lyrics text, optionally with section tags like `[Verse]` /\n * `[Chorus]` / `[Bridge]` / `[Outro]`. Routed to a structured wire\n * field on providers that have one (ElevenLabs `lines`, MiniMax\n * `lyrics`, Mureka `lyrics`, Suno custom-mode `prompt`); embedded in\n * the prompt with a warning on providers without one (Lyria 3,\n * Riffusion).\n */\n readonly lyrics?: string\n /** Target duration. Provider may treat as a hint or hard limit. */\n readonly duration?: Duration.Duration\n /**\n * Reproducibility seed. Tuning hint (bucket 3): honored where the\n * provider takes one (Lyria 2 Vertex, Lyria RealTime, ElevenLabs\n * with `compositionPlan`, Stable Audio, MusicGen); silently ignored\n * elsewhere.\n */\n readonly seed?: number\n /** Preferred output format. Provider may override. */\n readonly outputFormat?: AudioFormat\n}\n\n/**\n * Streamed-output request. Same shape as the sync request: the\n * streaming variant only differs in how the response is delivered.\n */\nexport type CommonStreamGenerateMusicRequest = CommonGenerateMusicRequest\n\n/**\n * Playback-control vocabulary that converges across interactive-media\n * protocols (Web Audio, MIDI sequencer control, music SDK surfaces).\n * Provider-specific control actions (Lyria's `reset_context` and any\n * future provider's extras) live on the provider-typed session-input\n * union.\n */\nexport type MusicSessionControl = \"play\" | \"pause\" | \"stop\" | \"reset\"\n\n/**\n * Bidirectional-session input on the cross-provider surface. Two\n * load-bearing actions every interactive music session needs:\n *\n * - `prompts` — steer the active generation with a (single or\n * weighted) prompt blend.\n * - `control` — play / pause / stop / reset.\n *\n * Provider-typed services extend this union with their own `config`\n * variant for model-specific knobs (Lyria RealTime exposes density /\n * brightness / mute-stems / BPM / scale / etc. via its own\n * `LyriaRealtimeSessionInput`).\n */\nexport type MusicSessionInput =\n | { readonly _tag: \"prompts\"; readonly prompts: ReadonlyArray<WeightedPrompt> }\n | { readonly _tag: \"control\"; readonly action: MusicSessionControl }\n\nexport const promptsInput = (prompts: ReadonlyArray<WeightedPrompt>): MusicSessionInput => ({\n _tag: \"prompts\",\n prompts,\n})\n\nexport const controlInput = (action: MusicSessionControl): MusicSessionInput => ({\n _tag: \"control\",\n action,\n})\n\n/**\n * Watermark kind on the response. SynthID is mandatory on Lyria; C2PA\n * is opt-in on ElevenLabs. No provider exposes additional metadata\n * about the watermark itself, so a bare literal-union is enough.\n */\nexport type Watermark = \"synthid\" | \"c2pa\" | (string & {})\n\n/**\n * Labelled section with absolute timing. Populated when the provider\n * returns structured section metadata (Lyria text part, ElevenLabs\n * `/v1/music/detailed` with `with_timestamps`).\n */\nexport type MusicSection = {\n readonly label: string\n readonly startSeconds: number\n readonly endSeconds: number\n}\n\n/**\n * Single generated track. Composes `AudioBlob` rather than extending\n * it — `result.audio` is the raw blob, `result.songId` / `lyrics` /\n * `sections` / `watermark` are provider-side metadata when returned.\n */\nexport type MusicResult = {\n readonly audio: AudioBlob\n /**\n * Provider identifier, useful when routing through multiple\n * providers in a single pipeline (`\"lyria\"`, `\"elevenlabs-music\"`,\n * etc.).\n */\n readonly provider?: string\n /** Provider-side ID for back-reference (re-download, extension, stems). */\n readonly songId?: string\n /** Generated or transcribed lyrics when the provider returned them. */\n readonly lyrics?: string\n /** Structured section markers when the provider returned them. */\n readonly sections?: ReadonlyArray<MusicSection>\n /** Watermark presence indicator when the provider applied one. */\n readonly watermark?: Watermark\n}\n\n/**\n * Result of a `generate` call. Suno and Mureka always return 2 tracks\n * per request; every other provider returns 1. `primary` is the\n * caller-friendly convenience; `variants` carries every track the\n * provider produced (length ≥ 1; `primary === variants[0]`).\n */\nexport type GenerateResult = {\n readonly primary: MusicResult\n readonly variants: ReadonlyArray<MusicResult>\n}\n\n/**\n * In-band event on the bidirectional `streamGenerationFrom` output\n * stream. Audio chunks flow as `audio`; server-side warnings\n * (`warning`) and prompt-filter rejections (`filteredPrompt`) flow\n * alongside rather than going to a side-channel log.\n */\nexport type MusicStreamEvent =\n | { readonly _tag: \"audio\"; readonly chunk: AudioChunk }\n | { readonly _tag: \"warning\"; readonly message: string }\n | { readonly _tag: \"filteredPrompt\"; readonly prompt: string; readonly reason: string }\n\nexport const isPromptsInput = (\n i: MusicSessionInput,\n): i is MusicSessionInput & { _tag: \"prompts\" } => i._tag === \"prompts\"\nexport const isControlInput = (\n i: MusicSessionInput,\n): i is MusicSessionInput & { _tag: \"control\" } => i._tag === \"control\"\n\nexport const audioEvent = (chunk: AudioChunk): MusicStreamEvent => ({ _tag: \"audio\", chunk })\nexport const warningEvent = (message: string): MusicStreamEvent => ({\n _tag: \"warning\",\n message,\n})\nexport const filteredPromptEvent = (prompt: string, reason: string): MusicStreamEvent => ({\n _tag: \"filteredPrompt\",\n prompt,\n reason,\n})\n\nexport const isAudioEvent = (e: MusicStreamEvent): e is MusicStreamEvent & { _tag: \"audio\" } =>\n e._tag === \"audio\"\nexport const isWarningEvent = (e: MusicStreamEvent): e is MusicStreamEvent & { _tag: \"warning\" } =>\n e._tag === \"warning\"\nexport const isFilteredPromptEvent = (\n e: MusicStreamEvent,\n): e is MusicStreamEvent & { _tag: \"filteredPrompt\" } => e._tag === \"filteredPrompt\"\n\n/**\n * Build a single-variant `GenerateResult` from a `MusicResult`.\n * Convenience for providers that always return exactly one track\n * (Lyria, ElevenLabs, MiniMax, Stable Audio, MusicGen, Riffusion,\n * Tencent). Providers that return multiple tracks (Suno, Mureka)\n * construct the `GenerateResult` directly.\n */\nexport const singleVariant = (result: MusicResult): GenerateResult => ({\n primary: result,\n variants: [result],\n})\n"],"mappings":";;;;;;;;;;;;;;;AAqFA,MAAa,gBAAgB,aAA+D;CAC1F,MAAM;CACN;CACD;AAED,MAAa,gBAAgB,YAAoD;CAC/E,MAAM;CACN;CACD;AAiED,MAAa,kBACX,MACiD,EAAE,SAAS;AAC9D,MAAa,kBACX,MACiD,EAAE,SAAS;AAE9D,MAAa,cAAc,WAAyC;CAAE,MAAM;CAAS;CAAO;AAC5F,MAAa,gBAAgB,aAAuC;CAClE,MAAM;CACN;CACD;AACD,MAAa,uBAAuB,QAAgB,YAAsC;CACxF,MAAM;CACN;CACA;CACD;AAED,MAAa,gBAAgB,MAC3B,EAAE,SAAS;AACb,MAAa,kBAAkB,MAC7B,EAAE,SAAS;AACb,MAAa,yBACX,MACuD,EAAE,SAAS;;;;;;;;AASpE,MAAa,iBAAiB,YAAyC;CACrE,SAAS;CACT,UAAU,CAAC,OAAO;CACnB"}
@@ -1,3 +1,6 @@
1
+ import { Duration } from "effect";
2
+
3
+ //#region src/domain/Transcript.d.ts
1
4
  declare namespace Transcript_d_exports {
2
5
  export { TranscriptEvent, TranscriptResult, WordTimestamp, isAudioEvent, isError, isFinal, isMetadata, isPartial, isSpeechStarted, isUtteranceEnded };
3
6
  }
@@ -5,6 +8,9 @@ declare namespace Transcript_d_exports {
5
8
  * Per-word timing + metadata. `confidence` and `speakerId` are optional
6
9
  * because providers vary widely in what they emit and when (some only on
7
10
  * final, some only with diarization enabled, some not at all).
11
+ *
12
+ * `startSeconds` / `endSeconds` stay raw `number` offsets (not `Duration`)
13
+ * — they're positions in the audio, not durations.
8
14
  */
9
15
  type WordTimestamp = {
10
16
  readonly text: string;
@@ -21,8 +27,8 @@ type WordTimestamp = {
21
27
  */
22
28
  type TranscriptResult = {
23
29
  readonly text: string;
24
- readonly languageCode?: string;
25
- readonly durationSeconds?: number;
30
+ readonly languageCode?: string; /** Total audio duration. (Word offsets stay raw seconds on `WordTimestamp`.) */
31
+ readonly duration?: Duration.Duration;
26
32
  readonly words?: ReadonlyArray<WordTimestamp>;
27
33
  readonly raw?: unknown;
28
34
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Transcript.d.mts","names":[],"sources":["../../src/domain/Transcript.ts"],"mappings":";;;;;;;;KAKY,aAAA;EAAA,SACD,IAAA;EAAA,SACA,YAAA;EAAA,SACA,UAAA;EAAA,SACA,UAAA;EAAA,SACA,SAAA;EAAA,SACA,YAAA;AAAA;;;AANX;;;KAcY,gBAAA;EAAA,SACD,IAAA;EAAA,SACA,YAAA;EAAA,SACA,eAAA;EAAA,SACA,KAAA,GAAQ,aAAA,CAAc,aAAA;EAAA,SACtB,GAAA;AAAA;;;AALX;;;;;;;;;;;;KAsBY,eAAA;EAAA,SAEG,IAAA;EAAA,SACA,IAAA;EAAA,SACA,KAAA,GAAQ,aAAA,CAAc,aAAA;EAAA,SACtB,SAAA;AAAA;EAAA,SAGA,IAAA;EAAA,SACA,IAAA;EAAA,SACA,KAAA,GAAQ,aAAA,CAAc,aAAA;EAAA,SACtB,YAAA;AAAA;EAAA,SAEA,IAAA;EAAA,SAAiC,SAAA;AAAA;EAAA,SACjC,IAAA;EAAA,SAAkC,SAAA;AAAA;EA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mjs","names":[],"sources":["../../src/domain/Transcript.ts"],"sourcesContent":["/**\n * Per-word timing + metadata. `confidence` and `speakerId` are optional\n * because providers vary widely in what they emit and when (some only on\n * final, some only with diarization enabled, some not at all).\n */\nexport type WordTimestamp = {\n readonly text: string\n readonly startSeconds: number\n readonly endSeconds: number\n readonly confidence?: number\n readonly speakerId?: string\n readonly languageCode?: string\n}\n\n/**\n * Sync STT result. `raw` preserves the provider-specific response for\n * consumers that need fields the common shape doesn't expose\n * (alternatives, segments, NBest, audio events, etc.).\n */\nexport type TranscriptResult = {\n readonly text: string\n readonly languageCode?: string\n readonly durationSeconds?: number\n readonly words?: ReadonlyArray<WordTimestamp>\n readonly raw?: unknown\n}\n\n/**\n * Streaming STT event union. Collapses every provider's vocabulary into\n * a small set; provider-specific shapes survive on `metadata.raw`.\n *\n * - `partial`: interim hypothesis. `stability` is Google-only.\n * - `final`: committed transcript for the current utterance / segment.\n * - `speech-started` / `utterance-ended`: VAD-derived boundaries. Not\n * all providers emit them (OpenAI Realtime, Google with\n * `voice_activity_events`, Deepgram with `vad_events`, AssemblyAI).\n * - `audio-event`: non-speech label (`(laughter)`, `(music)`) — ElevenLabs only.\n * - `metadata`: opaque server-side bookkeeping (request_id, model info).\n * - `error`: non-fatal provider error mid-stream. Fatal errors surface\n * on the `Stream`'s error channel as `AiError.AiError`.\n */\nexport type TranscriptEvent =\n | {\n readonly _tag: \"partial\"\n readonly text: string\n readonly words?: ReadonlyArray<WordTimestamp>\n readonly stability?: number\n }\n | {\n readonly _tag: \"final\"\n readonly text: string\n readonly words?: ReadonlyArray<WordTimestamp>\n readonly languageCode?: string\n }\n | { readonly _tag: \"speech-started\"; readonly atSeconds: number }\n | { readonly _tag: \"utterance-ended\"; readonly atSeconds: number }\n | {\n readonly _tag: \"audio-event\"\n readonly label: string\n readonly startSeconds: number\n readonly endSeconds: number\n }\n | { readonly _tag: \"metadata\"; readonly raw: unknown }\n | { readonly _tag: \"error\"; readonly code?: string; readonly message: string }\n\nexport const isPartial = (e: TranscriptEvent): e is Extract<TranscriptEvent, { _tag: \"partial\" }> =>\n e._tag === \"partial\"\nexport const isFinal = (e: TranscriptEvent): e is Extract<TranscriptEvent, { _tag: \"final\" }> =>\n e._tag === \"final\"\nexport const isSpeechStarted = (\n e: TranscriptEvent,\n): e is Extract<TranscriptEvent, { _tag: \"speech-started\" }> => e._tag === \"speech-started\"\nexport const isUtteranceEnded = (\n e: TranscriptEvent,\n): e is Extract<TranscriptEvent, { _tag: \"utterance-ended\" }> => e._tag === \"utterance-ended\"\nexport const isAudioEvent = (\n e: TranscriptEvent,\n): e is Extract<TranscriptEvent, { _tag: \"audio-event\" }> => e._tag === \"audio-event\"\nexport const isMetadata = (\n e: TranscriptEvent,\n): e is Extract<TranscriptEvent, { _tag: \"metadata\" }> => e._tag === \"metadata\"\nexport const isError = (e: TranscriptEvent): e is Extract<TranscriptEvent, { _tag: \"error\" }> =>\n e._tag === \"error\"\n"],"mappings":";;;;;;;;;;;AAiEA,MAAa,aAAa,MACxB,EAAE,SAAS;AACb,MAAa,WAAW,MACtB,EAAE,SAAS;AACb,MAAa,mBACX,MAC8D,EAAE,SAAS;AAC3E,MAAa,oBACX,MAC+D,EAAE,SAAS;AAC5E,MAAa,gBACX,MAC2D,EAAE,SAAS;AACxE,MAAa,cACX,MACwD,EAAE,SAAS;AACrE,MAAa,WAAW,MACtB,EAAE,SAAS"}
1
+ {"version":3,"file":"Transcript.mjs","names":[],"sources":["../../src/domain/Transcript.ts"],"sourcesContent":["import type { Duration } from \"effect\"\n\n/**\n * Per-word timing + metadata. `confidence` and `speakerId` are optional\n * because providers vary widely in what they emit and when (some only on\n * final, some only with diarization enabled, some not at all).\n *\n * `startSeconds` / `endSeconds` stay raw `number` offsets (not `Duration`)\n * — they're positions in the audio, not durations.\n */\nexport type WordTimestamp = {\n readonly text: string\n readonly startSeconds: number\n readonly endSeconds: number\n readonly confidence?: number\n readonly speakerId?: string\n readonly languageCode?: string\n}\n\n/**\n * Sync STT result. `raw` preserves the provider-specific response for\n * consumers that need fields the common shape doesn't expose\n * (alternatives, segments, NBest, audio events, etc.).\n */\nexport type TranscriptResult = {\n readonly text: string\n readonly languageCode?: string\n /** Total audio duration. (Word offsets stay raw seconds on `WordTimestamp`.) */\n readonly duration?: Duration.Duration\n readonly words?: ReadonlyArray<WordTimestamp>\n readonly raw?: unknown\n}\n\n/**\n * Streaming STT event union. Collapses every provider's vocabulary into\n * a small set; provider-specific shapes survive on `metadata.raw`.\n *\n * - `partial`: interim hypothesis. `stability` is Google-only.\n * - `final`: committed transcript for the current utterance / segment.\n * - `speech-started` / `utterance-ended`: VAD-derived boundaries. Not\n * all providers emit them (OpenAI Realtime, Google with\n * `voice_activity_events`, Deepgram with `vad_events`, AssemblyAI).\n * - `audio-event`: non-speech label (`(laughter)`, `(music)`) — ElevenLabs only.\n * - `metadata`: opaque server-side bookkeeping (request_id, model info).\n * - `error`: non-fatal provider error mid-stream. Fatal errors surface\n * on the `Stream`'s error channel as `AiError.AiError`.\n */\nexport type TranscriptEvent =\n | {\n readonly _tag: \"partial\"\n readonly text: string\n readonly words?: ReadonlyArray<WordTimestamp>\n readonly stability?: number\n }\n | {\n readonly _tag: \"final\"\n readonly text: string\n readonly words?: ReadonlyArray<WordTimestamp>\n readonly languageCode?: string\n }\n | { readonly _tag: \"speech-started\"; readonly atSeconds: number }\n | { readonly _tag: \"utterance-ended\"; readonly atSeconds: number }\n | {\n readonly _tag: \"audio-event\"\n readonly label: string\n readonly startSeconds: number\n readonly endSeconds: number\n }\n | { readonly _tag: \"metadata\"; readonly raw: unknown }\n | { readonly _tag: \"error\"; readonly code?: string; readonly message: string }\n\nexport const isPartial = (e: TranscriptEvent): e is Extract<TranscriptEvent, { _tag: \"partial\" }> =>\n e._tag === \"partial\"\nexport const isFinal = (e: TranscriptEvent): e is Extract<TranscriptEvent, { _tag: \"final\" }> =>\n e._tag === \"final\"\nexport const isSpeechStarted = (\n e: TranscriptEvent,\n): e is Extract<TranscriptEvent, { _tag: \"speech-started\" }> => e._tag === \"speech-started\"\nexport const isUtteranceEnded = (\n e: TranscriptEvent,\n): e is Extract<TranscriptEvent, { _tag: \"utterance-ended\" }> => e._tag === \"utterance-ended\"\nexport const isAudioEvent = (\n e: TranscriptEvent,\n): e is Extract<TranscriptEvent, { _tag: \"audio-event\" }> => e._tag === \"audio-event\"\nexport const isMetadata = (\n e: TranscriptEvent,\n): e is Extract<TranscriptEvent, { _tag: \"metadata\" }> => e._tag === \"metadata\"\nexport const isError = (e: TranscriptEvent): e is Extract<TranscriptEvent, { _tag: \"error\" }> =>\n e._tag === \"error\"\n"],"mappings":";;;;;;;;;;;AAuEA,MAAa,aAAa,MACxB,EAAE,SAAS;AACb,MAAa,WAAW,MACtB,EAAE,SAAS;AACb,MAAa,mBACX,MAC8D,EAAE,SAAS;AAC3E,MAAa,oBACX,MAC+D,EAAE,SAAS;AAC5E,MAAa,gBACX,MAC2D,EAAE,SAAS;AACxE,MAAa,cACX,MACwD,EAAE,SAAS;AACrE,MAAa,WAAW,MACtB,EAAE,SAAS"}