@effect-uai/core 0.11.0 → 0.12.1

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 (288) hide show
  1. package/dist/{AiError-Bf1pq4BB.d.mts → AiError-eLV9t1lU.d.mts} +12 -16
  2. package/dist/AiError-eLV9t1lU.d.mts.map +1 -0
  3. package/dist/{Audio-CR7CSljJ.d.mts → Audio-60lKKHxS.d.mts} +4 -5
  4. package/dist/Audio-60lKKHxS.d.mts.map +1 -0
  5. package/dist/{Image-C4vuBmu0.d.mts → Image-BK8-4H6s.d.mts} +12 -14
  6. package/dist/Image-BK8-4H6s.d.mts.map +1 -0
  7. package/dist/{Items-BWNu6VGp.d.mts → Items-SfUabNuB.d.mts} +92 -81
  8. package/dist/Items-SfUabNuB.d.mts.map +1 -0
  9. package/dist/{Loop-D8nWpowc.d.mts → Loop-B54AB1ME.d.mts} +19 -21
  10. package/dist/Loop-B54AB1ME.d.mts.map +1 -0
  11. package/dist/{Media-D_CpcM1Z.d.mts → Media-DwgpifPD.d.mts} +1 -1
  12. package/dist/Media-DwgpifPD.d.mts.map +1 -0
  13. package/dist/{SandboxError-CIrVDOMV.d.mts → SandboxError-BN8b28Bh.d.mts} +11 -15
  14. package/dist/SandboxError-BN8b28Bh.d.mts.map +1 -0
  15. package/dist/{StructuredFormat-DHaUJBdd.d.mts → StructuredFormat-BlZhyOsi.d.mts} +3 -7
  16. package/dist/StructuredFormat-BlZhyOsi.d.mts.map +1 -0
  17. package/dist/{Tool-CXFHCQrT.d.mts → Tool-DE-rnvkw.d.mts} +5 -8
  18. package/dist/Tool-DE-rnvkw.d.mts.map +1 -0
  19. package/dist/{ToolEvent-nVijCrvm.d.mts → ToolEvent-D99MGQYH.d.mts} +56 -63
  20. package/dist/ToolEvent-D99MGQYH.d.mts.map +1 -0
  21. package/dist/{ToolResult-CQqKkcDa.d.mts → ToolResult-Cj8ChodL.d.mts} +49 -54
  22. package/dist/ToolResult-Cj8ChodL.d.mts.map +1 -0
  23. package/dist/{Toolkit-BYPwwu-j.d.mts → Toolkit-BEZrNPTI.d.mts} +13 -16
  24. package/dist/Toolkit-BEZrNPTI.d.mts.map +1 -0
  25. package/dist/browser/Browser.d.mts +11 -7
  26. package/dist/browser/Browser.d.mts.map +1 -1
  27. package/dist/browser/Browser.mjs +1 -1
  28. package/dist/browser/Browser.mjs.map +1 -1
  29. package/dist/browser/BrowserError.d.mts +9 -13
  30. package/dist/browser/BrowserError.d.mts.map +1 -1
  31. package/dist/browser/BrowserError.mjs +1 -1
  32. package/dist/browser/BrowserError.mjs.map +1 -1
  33. package/dist/browser/BrowserTool.d.mts +33 -36
  34. package/dist/browser/BrowserTool.d.mts.map +1 -1
  35. package/dist/browser/BrowserTool.mjs +1 -1
  36. package/dist/browser/BrowserTool.mjs.map +1 -1
  37. package/dist/capabilities/Capabilities.d.mts +8 -6
  38. package/dist/capabilities/Capabilities.d.mts.map +1 -1
  39. package/dist/capabilities/Capabilities.mjs +1 -1
  40. package/dist/capabilities/Capabilities.mjs.map +1 -1
  41. package/dist/dist-BaenoU1A.mjs +145 -0
  42. package/dist/dist-BaenoU1A.mjs.map +1 -0
  43. package/dist/{dist-C0m0QnUP.mjs → dist-nohcnkD6.mjs} +16 -15
  44. package/dist/dist-nohcnkD6.mjs.map +1 -0
  45. package/dist/domain/AiError.d.mts +1 -1
  46. package/dist/domain/AiError.mjs +1 -1
  47. package/dist/domain/AiError.mjs.map +1 -1
  48. package/dist/domain/Audio.d.mts +1 -1
  49. package/dist/domain/Audio.mjs +1 -1
  50. package/dist/domain/Citation.d.mts +0 -2
  51. package/dist/domain/Citation.d.mts.map +1 -1
  52. package/dist/domain/Citation.mjs +1 -1
  53. package/dist/domain/Image.d.mts +1 -1
  54. package/dist/domain/Image.mjs +1 -1
  55. package/dist/domain/Image.mjs.map +1 -1
  56. package/dist/domain/Items.d.mts +1 -1
  57. package/dist/domain/Items.mjs +16 -2
  58. package/dist/domain/Items.mjs.map +1 -1
  59. package/dist/domain/Media.d.mts +1 -1
  60. package/dist/domain/Media.mjs +1 -1
  61. package/dist/domain/Music.d.mts +18 -11
  62. package/dist/domain/Music.d.mts.map +1 -1
  63. package/dist/domain/Music.mjs +1 -1
  64. package/dist/domain/Music.mjs.map +1 -1
  65. package/dist/domain/Research.d.mts +3 -4
  66. package/dist/domain/Research.d.mts.map +1 -1
  67. package/dist/domain/Research.mjs +1 -1
  68. package/dist/domain/Transcript.d.mts +2 -3
  69. package/dist/domain/Transcript.d.mts.map +1 -1
  70. package/dist/domain/Transcript.mjs +1 -1
  71. package/dist/domain/Turn.d.mts +144 -164
  72. package/dist/domain/Turn.d.mts.map +1 -1
  73. package/dist/domain/Turn.mjs +1 -1
  74. package/dist/domain/Turn.mjs.map +1 -1
  75. package/dist/domain/Turn.test.d.mts +1 -1
  76. package/dist/domain/Turn.test.mjs +28 -18
  77. package/dist/domain/Turn.test.mjs.map +1 -1
  78. package/dist/embedding-model/Embedding.d.mts +1 -3
  79. package/dist/embedding-model/Embedding.d.mts.map +1 -1
  80. package/dist/embedding-model/Embedding.mjs +1 -1
  81. package/dist/embedding-model/EmbeddingModel.d.mts +1 -3
  82. package/dist/embedding-model/EmbeddingModel.d.mts.map +1 -1
  83. package/dist/embedding-model/EmbeddingModel.mjs +1 -1
  84. package/dist/embedding-model/EmbeddingModel.mjs.map +1 -1
  85. package/dist/embedding-model/EmbeddingModel.test.d.mts +1 -1
  86. package/dist/embedding-model/EmbeddingModel.test.mjs +14 -9
  87. package/dist/embedding-model/EmbeddingModel.test.mjs.map +1 -1
  88. package/dist/index.d.mts +12 -12
  89. package/dist/job/Job.d.mts +4 -4
  90. package/dist/job/Job.d.mts.map +1 -1
  91. package/dist/job/Job.mjs +1 -1
  92. package/dist/job/Job.mjs.map +1 -1
  93. package/dist/language-model/LanguageModel.d.mts +4 -6
  94. package/dist/language-model/LanguageModel.d.mts.map +1 -1
  95. package/dist/language-model/LanguageModel.mjs +1 -1
  96. package/dist/language-model/LanguageModel.mjs.map +1 -1
  97. package/dist/language-model/LanguageModel.test.d.mts +1 -1
  98. package/dist/language-model/LanguageModel.test.mjs +6 -3
  99. package/dist/language-model/LanguageModel.test.mjs.map +1 -1
  100. package/dist/loop/Loop.d.mts +1 -1
  101. package/dist/loop/Loop.mjs +1 -1
  102. package/dist/loop/Loop.mjs.map +1 -1
  103. package/dist/loop/Loop.test.d.mts +1 -1
  104. package/dist/loop/Loop.test.mjs +60 -34
  105. package/dist/loop/Loop.test.mjs.map +1 -1
  106. package/dist/{magic-string.es-Dk-MMA0F.mjs → magic-string.es-CB2hOw9v.mjs} +14 -13
  107. package/dist/{magic-string.es-Dk-MMA0F.mjs.map → magic-string.es-CB2hOw9v.mjs.map} +1 -1
  108. package/dist/math/Vector.d.mts +0 -2
  109. package/dist/math/Vector.d.mts.map +1 -1
  110. package/dist/math/Vector.mjs +1 -1
  111. package/dist/math/Vector.mjs.map +1 -1
  112. package/dist/music-generator/MusicGenerator.d.mts +2 -4
  113. package/dist/music-generator/MusicGenerator.d.mts.map +1 -1
  114. package/dist/music-generator/MusicGenerator.mjs +1 -1
  115. package/dist/music-generator/MusicGenerator.mjs.map +1 -1
  116. package/dist/music-generator/MusicGenerator.test.d.mts +1 -1
  117. package/dist/music-generator/MusicGenerator.test.mjs +19 -10
  118. package/dist/music-generator/MusicGenerator.test.mjs.map +1 -1
  119. package/dist/observability/Metrics.d.mts +21 -10
  120. package/dist/observability/Metrics.d.mts.map +1 -1
  121. package/dist/observability/Metrics.mjs +31 -8
  122. package/dist/observability/Metrics.mjs.map +1 -1
  123. package/dist/observability/Metrics.test.d.mts +1 -1
  124. package/dist/observability/Metrics.test.mjs +87 -23
  125. package/dist/observability/Metrics.test.mjs.map +1 -1
  126. package/dist/observability/Telemetry.d.mts +2 -3
  127. package/dist/observability/Telemetry.d.mts.map +1 -1
  128. package/dist/observability/Telemetry.mjs +1 -1
  129. package/dist/observability/Telemetry.mjs.map +1 -1
  130. package/dist/observability/Telemetry.test.d.mts +1 -1
  131. package/dist/observability/Telemetry.test.mjs +15 -7
  132. package/dist/observability/Telemetry.test.mjs.map +1 -1
  133. package/dist/research/DeepResearch.d.mts +1 -3
  134. package/dist/research/DeepResearch.d.mts.map +1 -1
  135. package/dist/research/DeepResearch.mjs +1 -1
  136. package/dist/research/DeepResearch.mjs.map +1 -1
  137. package/dist/retry/Retry.d.mts +4 -8
  138. package/dist/retry/Retry.d.mts.map +1 -1
  139. package/dist/retry/Retry.mjs +31 -2
  140. package/dist/retry/Retry.mjs.map +1 -1
  141. package/dist/retry/Retry.test.d.mts +1 -1
  142. package/dist/retry/Retry.test.mjs +6 -3
  143. package/dist/retry/Retry.test.mjs.map +1 -1
  144. package/dist/sandbox/Memory.d.mts +0 -2
  145. package/dist/sandbox/Memory.d.mts.map +1 -1
  146. package/dist/sandbox/Memory.mjs +4 -4
  147. package/dist/sandbox/Memory.mjs.map +1 -1
  148. package/dist/sandbox/Sandbox.d.mts +144 -156
  149. package/dist/sandbox/Sandbox.d.mts.map +1 -1
  150. package/dist/sandbox/Sandbox.mjs +1 -1
  151. package/dist/sandbox/Sandbox.mjs.map +1 -1
  152. package/dist/sandbox/SandboxError.d.mts +1 -1
  153. package/dist/sandbox/SandboxError.mjs +1 -1
  154. package/dist/sandbox/SandboxError.mjs.map +1 -1
  155. package/dist/sandbox/SandboxImage.d.mts +0 -2
  156. package/dist/sandbox/SandboxImage.d.mts.map +1 -1
  157. package/dist/sandbox/SandboxImage.mjs +1 -1
  158. package/dist/sandbox/SandboxImage.mjs.map +1 -1
  159. package/dist/sandbox/SandboxNetwork.d.mts +0 -2
  160. package/dist/sandbox/SandboxNetwork.d.mts.map +1 -1
  161. package/dist/sandbox/SandboxNetwork.mjs +1 -1
  162. package/dist/sandbox/SandboxNetwork.mjs.map +1 -1
  163. package/dist/speech-synthesizer/SpeechSynthesizer.d.mts +8 -7
  164. package/dist/speech-synthesizer/SpeechSynthesizer.d.mts.map +1 -1
  165. package/dist/speech-synthesizer/SpeechSynthesizer.mjs +1 -1
  166. package/dist/speech-synthesizer/SpeechSynthesizer.mjs.map +1 -1
  167. package/dist/speech-synthesizer/SpeechSynthesizer.test.d.mts +1 -1
  168. package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs +31 -16
  169. package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs.map +1 -1
  170. package/dist/streaming/JSONL.d.mts +1 -5
  171. package/dist/streaming/JSONL.d.mts.map +1 -1
  172. package/dist/streaming/JSONL.mjs +1 -1
  173. package/dist/streaming/JSONL.mjs.map +1 -1
  174. package/dist/streaming/JSONL.test.d.mts +1 -1
  175. package/dist/streaming/JSONL.test.mjs +16 -8
  176. package/dist/streaming/JSONL.test.mjs.map +1 -1
  177. package/dist/streaming/Lines.d.mts +0 -2
  178. package/dist/streaming/Lines.d.mts.map +1 -1
  179. package/dist/streaming/Lines.mjs +1 -1
  180. package/dist/streaming/Lines.mjs.map +1 -1
  181. package/dist/streaming/SSE.d.mts +0 -2
  182. package/dist/streaming/SSE.d.mts.map +1 -1
  183. package/dist/streaming/SSE.mjs +1 -1
  184. package/dist/streaming/SSE.mjs.map +1 -1
  185. package/dist/streaming/SSE.test.d.mts +1 -1
  186. package/dist/streaming/SSE.test.mjs +34 -17
  187. package/dist/streaming/SSE.test.mjs.map +1 -1
  188. package/dist/structured-format/StructuredFormat.d.mts +1 -1
  189. package/dist/structured-format/StructuredFormat.mjs +1 -1
  190. package/dist/structured-format/StructuredFormat.mjs.map +1 -1
  191. package/dist/structured-format/StructuredFormat.test.d.mts +1 -1
  192. package/dist/structured-format/StructuredFormat.test.mjs +7 -4
  193. package/dist/structured-format/StructuredFormat.test.mjs.map +1 -1
  194. package/dist/{dist-CcRV3-A5.mjs → test.DNmyFkvJ-YPzDR0Co.mjs} +1644 -5172
  195. package/dist/test.DNmyFkvJ-YPzDR0Co.mjs.map +1 -0
  196. package/dist/testing/MockMusicGenerator.d.mts +4 -3
  197. package/dist/testing/MockMusicGenerator.d.mts.map +1 -1
  198. package/dist/testing/MockMusicGenerator.mjs.map +1 -1
  199. package/dist/testing/MockProvider.d.mts +1 -2
  200. package/dist/testing/MockProvider.d.mts.map +1 -1
  201. package/dist/testing/MockProvider.mjs.map +1 -1
  202. package/dist/testing/MockSandbox.d.mts +256 -290
  203. package/dist/testing/MockSandbox.d.mts.map +1 -1
  204. package/dist/testing/MockSandbox.mjs.map +1 -1
  205. package/dist/testing/MockSpeechSynthesizer.d.mts +10 -6
  206. package/dist/testing/MockSpeechSynthesizer.d.mts.map +1 -1
  207. package/dist/testing/MockSpeechSynthesizer.mjs.map +1 -1
  208. package/dist/testing/MockTranscriber.d.mts +3 -2
  209. package/dist/testing/MockTranscriber.d.mts.map +1 -1
  210. package/dist/testing/MockTranscriber.mjs.map +1 -1
  211. package/dist/tool/Approval.d.mts +31 -36
  212. package/dist/tool/Approval.d.mts.map +1 -1
  213. package/dist/tool/Approval.mjs +1 -1
  214. package/dist/tool/Approval.mjs.map +1 -1
  215. package/dist/tool/Approval.test.d.mts +1 -1
  216. package/dist/tool/Approval.test.mjs +37 -24
  217. package/dist/tool/Approval.test.mjs.map +1 -1
  218. package/dist/tool/HistoryCheck.d.mts +2 -4
  219. package/dist/tool/HistoryCheck.d.mts.map +1 -1
  220. package/dist/tool/HistoryCheck.mjs +1 -1
  221. package/dist/tool/HistoryCheck.mjs.map +1 -1
  222. package/dist/tool/Tool.d.mts +1 -1
  223. package/dist/tool/Tool.mjs +4 -4
  224. package/dist/tool/Tool.mjs.map +1 -1
  225. package/dist/tool/Tool.test.d.mts +1 -1
  226. package/dist/tool/Tool.test.mjs +23 -11
  227. package/dist/tool/Tool.test.mjs.map +1 -1
  228. package/dist/tool/ToolEvent.d.mts +1 -1
  229. package/dist/tool/ToolEvent.mjs +1 -1
  230. package/dist/tool/ToolEvent.mjs.map +1 -1
  231. package/dist/tool/ToolResult.d.mts +1 -1
  232. package/dist/tool/ToolResult.mjs +1 -1
  233. package/dist/tool/ToolResult.mjs.map +1 -1
  234. package/dist/tool/Toolkit.d.mts +1 -1
  235. package/dist/tool/Toolkit.mjs +4 -3
  236. package/dist/tool/Toolkit.mjs.map +1 -1
  237. package/dist/tool/Toolkit.test.d.mts +1 -1
  238. package/dist/tool/Toolkit.test.mjs +40 -21
  239. package/dist/tool/Toolkit.test.mjs.map +1 -1
  240. package/dist/transcriber/Transcriber.d.mts +6 -6
  241. package/dist/transcriber/Transcriber.d.mts.map +1 -1
  242. package/dist/transcriber/Transcriber.mjs +1 -1
  243. package/dist/transcriber/Transcriber.mjs.map +1 -1
  244. package/dist/transcriber/Transcriber.test.d.mts +1 -1
  245. package/dist/transcriber/Transcriber.test.mjs +20 -10
  246. package/dist/transcriber/Transcriber.test.mjs.map +1 -1
  247. package/dist/utils-CiH_DjFW.mjs +3918 -0
  248. package/dist/utils-CiH_DjFW.mjs.map +1 -0
  249. package/dist/web-read/WebRead.d.mts +15 -9
  250. package/dist/web-read/WebRead.d.mts.map +1 -1
  251. package/dist/web-read/WebRead.mjs +1 -1
  252. package/dist/web-read/WebRead.mjs.map +1 -1
  253. package/dist/web-read/WebReadTool.d.mts +4 -5
  254. package/dist/web-read/WebReadTool.d.mts.map +1 -1
  255. package/dist/web-read/WebReadTool.mjs +1 -1
  256. package/dist/web-read/WebReadTool.mjs.map +1 -1
  257. package/dist/web-search/WebSearch.d.mts +22 -13
  258. package/dist/web-search/WebSearch.d.mts.map +1 -1
  259. package/dist/web-search/WebSearch.mjs +1 -1
  260. package/dist/web-search/WebSearch.mjs.map +1 -1
  261. package/dist/web-search/WebSearchTool.d.mts +6 -6
  262. package/dist/web-search/WebSearchTool.d.mts.map +1 -1
  263. package/dist/web-search/WebSearchTool.mjs +1 -1
  264. package/dist/web-search/WebSearchTool.mjs.map +1 -1
  265. package/package.json +4 -4
  266. package/src/domain/Items.ts +18 -0
  267. package/src/loop/Loop.test.ts +13 -14
  268. package/src/loop/Loop.ts +74 -76
  269. package/src/observability/Metrics.test.ts +65 -0
  270. package/src/observability/Metrics.ts +53 -11
  271. package/src/retry/Retry.ts +44 -3
  272. package/src/testing/MockProvider.ts +8 -9
  273. package/src/tool/Tool.ts +13 -13
  274. package/dist/AiError-Bf1pq4BB.d.mts.map +0 -1
  275. package/dist/Audio-CR7CSljJ.d.mts.map +0 -1
  276. package/dist/Image-C4vuBmu0.d.mts.map +0 -1
  277. package/dist/Items-BWNu6VGp.d.mts.map +0 -1
  278. package/dist/Loop-D8nWpowc.d.mts.map +0 -1
  279. package/dist/Media-D_CpcM1Z.d.mts.map +0 -1
  280. package/dist/SandboxError-CIrVDOMV.d.mts.map +0 -1
  281. package/dist/StructuredFormat-DHaUJBdd.d.mts.map +0 -1
  282. package/dist/Tool-CXFHCQrT.d.mts.map +0 -1
  283. package/dist/ToolEvent-nVijCrvm.d.mts.map +0 -1
  284. package/dist/ToolResult-CQqKkcDa.d.mts.map +0 -1
  285. package/dist/Toolkit-BYPwwu-j.d.mts.map +0 -1
  286. package/dist/dist-C0m0QnUP.mjs.map +0 -1
  287. package/dist/dist-CcRV3-A5.mjs.map +0 -1
  288. /package/dist/{chunk-uyGKjUfl.mjs → rolldown-runtime-EAsCxrDo.mjs} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"Sandbox.mjs","names":[],"sources":["../../src/sandbox/Sandbox.ts"],"sourcesContent":["import { Brand, Context, Data, type Duration, Effect, Redacted, Scope, Stream } from \"effect\"\nimport type * as SandboxError from \"./SandboxError.js\"\n\n// ---------------------------------------------------------------------------\n// Identity\n// ---------------------------------------------------------------------------\n\n/**\n * Sandbox identifier. Branded `string` so providers don't accidentally\n * accept a raw user-supplied id. Each provider mints these per its own\n * naming scheme (uuid for E2B/Vercel, user-supplied name for\n * Microsandbox/Modal, …); the core code treats them opaquely.\n *\n * Mint via the value-level `SandboxId(...)` smart constructor instead\n * of `as SandboxId` casts.\n */\nexport type SandboxId = Brand.Branded<string, \"SandboxId\">\nexport const SandboxId = Brand.nominal<SandboxId>()\n\n/**\n * Reference returned by `list`. Carries just enough to call `attach` —\n * provider-specific metadata (createdAt, region, tags, …) lives on the\n * narrowed per-provider ref.\n */\nexport type SandboxRef = {\n readonly id: SandboxId\n readonly name?: string\n}\n\nexport type VolumeId = Brand.Branded<string, \"VolumeId\">\nexport const VolumeId = Brand.nominal<VolumeId>()\n\nexport type SnapshotId = Brand.Branded<string, \"SnapshotId\">\nexport const SnapshotId = Brand.nominal<SnapshotId>()\n\n// ---------------------------------------------------------------------------\n// Image / runtime selection\n// ---------------------------------------------------------------------------\n\n/**\n * What runtime / filesystem to boot the sandbox from.\n *\n * - `Default` — provider picks its house image (Vercel: Amazon Linux\n * 2023; Microsandbox: requires user image but a builder default may\n * apply, …). Use when you don't care what's pre-installed.\n * - `Registry` — an OCI image reference. Supported by every provider\n * except those with a fixed base (Vercel ignores this and the\n * request-schema rejects at decode).\n * - `Snapshot` — restore from a captured state. Gated by\n * {@link SandboxSnapshots} at the call site — the marker is provided\n * by adapters whose provider supports snapshot-as-image.\n * - `Dockerfile` — provider builds a custom image from a Dockerfile.\n * Gated by {@link SandboxCustomImage}.\n */\nexport type ImageRef = Data.TaggedEnum<{\n Default: {}\n Registry: { readonly ref: string }\n Snapshot: { readonly id: SnapshotId }\n Dockerfile: { readonly contents: string }\n}>\n\nexport const ImageRef = Data.taggedEnum<ImageRef>()\n\n// ---------------------------------------------------------------------------\n// Network policy + secrets\n// ---------------------------------------------------------------------------\n\n/**\n * Outbound network policy for a sandbox.\n *\n * - `Open` — no egress restriction. The provider's defaults apply\n * (e.g. Microsandbox's \"public-only\" still blocks private ranges).\n * - `Blocked` — fully airgapped, no outbound connectivity at all.\n * - `Allowlist` — only the listed hosts / CIDRs may be reached.\n *\n * Providers vary in what they honour: hostname-allowlist requires\n * {@link SandboxHostnameAllowlist}; CIDR-only providers ignore `hosts`\n * and the adapter rejects at decode if `hosts` is non-empty.\n */\nexport type NetworkPolicy = Data.TaggedEnum<{\n Open: {}\n Blocked: {}\n Allowlist: {\n readonly hosts?: ReadonlyArray<string>\n readonly cidrs?: ReadonlyArray<string>\n }\n}>\n\nexport const NetworkPolicy = Data.taggedEnum<NetworkPolicy>()\n\n/**\n * A secret bound to a sandbox at create time. The code inside the\n * sandbox sees only a placeholder (`$MSB_<NAME>` for Microsandbox,\n * `{name}` for Vercel header-injection, etc.); the real `value` lives\n * on the provider's proxy and is substituted on outbound HTTPS to\n * `hosts`.\n *\n * Requires the {@link SandboxSecretInjection} capability marker —\n * provider Layers without proxy-layer secret rewriting do not ship the\n * marker and consumer code fails at `Effect.provide` with a type\n * error.\n *\n * `header` is the request header to inject (default\n * `\"Authorization: Bearer <value>\"`). Providers that do not let\n * callers pick the header (Microsandbox's `secretEnv` shorthand)\n * silently ignore this field; providers that require an explicit\n * header (Vercel's `transform.headers`) fail at decode if it's absent.\n */\nexport type BoundSecret = {\n readonly name: string\n readonly value: Redacted.Redacted<string>\n readonly hosts: ReadonlyArray<string>\n readonly header?: string\n}\n\n// ---------------------------------------------------------------------------\n// Volumes (capability-gated on `SandboxVolumes`)\n// ---------------------------------------------------------------------------\n\nexport type VolumeMount = {\n readonly id: VolumeId\n readonly mountPath: string\n readonly readonly?: boolean\n}\n\n// ---------------------------------------------------------------------------\n// Create / exec request shapes\n// ---------------------------------------------------------------------------\n\n/**\n * Cross-provider create request. Provider-specific knobs (region,\n * cpus, memory, template id, …) live on each provider's narrowed\n * request type which extends this.\n *\n * Fields a provider can't honour fail at **decode time** (per the\n * per-provider request schema), not silently at runtime. The\n * ComputeSDK anti-pattern of \"drop unsupported fields\" is the\n * footgun we're avoiding.\n */\nexport type CommonCreateRequest = {\n /** Image / snapshot to boot from. Omit for the provider's default. */\n readonly image?: ImageRef\n /**\n * Idle / hard timeout. Accepts a number (millis), a string like\n * `\"30 seconds\"`, or a `Duration`. Providers default differently.\n */\n readonly timeout?: Duration.Input\n /**\n * Env vars exposed to the sandbox. NOT for secrets you want hidden\n * from the running code — use {@link BoundSecret} instead.\n */\n readonly env?: Readonly<Record<string, string>>\n /** Outbound network policy. */\n readonly network?: NetworkPolicy\n /**\n * Bound secrets — code inside the sandbox sees a placeholder; the\n * proxy substitutes the real value on outbound HTTPS to listed hosts.\n * Capability-gated on {@link SandboxSecretInjection}.\n */\n readonly secrets?: ReadonlyArray<BoundSecret>\n /**\n * Persistent volumes to mount. Volumes are created via\n * `Sandbox.volumes.create` and survive sandbox lifetime.\n * Capability-gated on {@link SandboxVolumes}.\n */\n readonly volumes?: ReadonlyArray<VolumeMount>\n}\n\n/**\n * Cross-provider exec request. Background / long-running processes\n * use `spawn` instead of `exec`; the semantics differ enough that\n * overloading `exec` with a `detached` flag was rejected during\n * design.\n */\nexport type CommonExecRequest = {\n /**\n * Argv-style command. Pass a string for \"run this through the\n * shell\" semantics (provider-dependent — most use `sh -c`); pass\n * an array for direct argv with no shell parsing.\n */\n readonly cmd: string | ReadonlyArray<string>\n readonly cwd?: string\n readonly env?: Readonly<Record<string, string>>\n readonly stdin?: string | Uint8Array\n /**\n * Per-exec timeout. Accepts a number (millis), a string like\n * `\"5 seconds\"`, or a `Duration`.\n */\n readonly timeout?: Duration.Input\n}\n\n/**\n * Spawn request — extends {@link CommonExecRequest} with the option\n * to provide stdin as a `Stream<Uint8Array>`. The provider takes one\n * chunk at a time and sends EOF when the stream completes. Useful\n * for piping LLM output into a sandboxed process, or feeding stdin\n * from another stream source. `exec` does not accept streams.\n */\nexport type CommonSpawnRequest = Omit<CommonExecRequest, \"stdin\"> & {\n readonly stdin?: string | Uint8Array | Stream.Stream<Uint8Array, never, never>\n}\n\nexport type ExecResult = {\n readonly exitCode: number\n readonly stdout: string\n readonly stderr: string\n readonly durationMs: number\n}\n\n/**\n * Streaming exec output. `Complete` is terminal — the stream\n * completes after emitting it.\n */\nexport type ExecEvent = Data.TaggedEnum<{\n Stdout: { readonly chunk: Uint8Array }\n Stderr: { readonly chunk: Uint8Array }\n Complete: { readonly exitCode: number; readonly durationMs: number }\n}>\n\nexport const ExecEvent = Data.taggedEnum<ExecEvent>()\n\n// ---------------------------------------------------------------------------\n// Filesystem\n// ---------------------------------------------------------------------------\n\nexport type FileEntryKind = \"file\" | \"directory\" | \"symlink\" | \"other\"\n\nexport type FileEntry = {\n readonly path: string\n readonly kind: FileEntryKind\n}\n\nexport type SandboxFilesystem = {\n readonly read: (path: string) => Effect.Effect<Uint8Array, SandboxError.SandboxError>\n readonly write: (\n path: string,\n contents: Uint8Array | string,\n ) => Effect.Effect<void, SandboxError.SandboxError>\n readonly remove: (path: string) => Effect.Effect<void, SandboxError.SandboxError>\n readonly mkdir: (path: string) => Effect.Effect<void, SandboxError.SandboxError>\n readonly list: (\n path: string,\n ) => Effect.Effect<ReadonlyArray<FileEntry>, SandboxError.SandboxError>\n readonly exists: (path: string) => Effect.Effect<boolean, SandboxError.SandboxError>\n}\n\n// ---------------------------------------------------------------------------\n// Process handle (returned by `spawn`)\n// ---------------------------------------------------------------------------\n\n/**\n * Long-running process handle. Returned by `spawn` in a `Scope.Scope`\n * — the process is killed on scope close. To outlive the calling\n * scope, do `Effect.forkScoped` against a wider scope or use\n * `attach`-style reconnection per the provider's escape hatch.\n */\nexport type ProcessHandle = {\n readonly pid: number\n readonly events: Stream.Stream<ExecEvent, SandboxError.SandboxError>\n readonly kill: Effect.Effect<void, SandboxError.SandboxError>\n readonly exit: Effect.Effect<{ readonly exitCode: number }, SandboxError.SandboxError>\n}\n\n// ---------------------------------------------------------------------------\n// SandboxInstance — the live handle returned from `create` / `attach`\n// ---------------------------------------------------------------------------\n\n/**\n * Live sandbox handle. Methods are plain `Effect` / `Stream` values\n * — no nullary thunks (`destroy()`, `pause()`) — to match Effect's\n * `Queue.shutdown` / `Fiber.interrupt` style. Destruction is the\n * scope finalizer, not a method here; for the rare \"kill from\n * another fiber\" case use the service-level escape hatch\n * `Sandbox.destroy(id)`.\n */\nexport type SandboxInstance = {\n readonly id: SandboxId\n readonly exec: (\n request: CommonExecRequest,\n ) => Effect.Effect<ExecResult, SandboxError.SandboxError>\n readonly execStream: (\n request: CommonExecRequest,\n ) => Stream.Stream<ExecEvent, SandboxError.SandboxError>\n /**\n * Spawn a background / long-running process. The returned handle is\n * scoped — the process is killed on scope close. Use this for\n * \"dev server / watcher / tail -f\" workloads. For one-shot\n * commands prefer `exec`.\n */\n readonly spawn: (\n request: CommonSpawnRequest,\n ) => Effect.Effect<ProcessHandle, SandboxError.SandboxError, Scope.Scope>\n readonly files: SandboxFilesystem\n}\n\n// ---------------------------------------------------------------------------\n// Snapshot / volume / port sub-services (capability-gated)\n// ---------------------------------------------------------------------------\n\nexport type SandboxSnapshotsApi = {\n readonly create: (\n from: SandboxInstance,\n name?: string,\n ) => Effect.Effect<SnapshotId, SandboxError.SandboxError>\n readonly destroy: (id: SnapshotId) => Effect.Effect<void, SandboxError.SandboxError>\n readonly list: Effect.Effect<\n ReadonlyArray<{ readonly id: SnapshotId; readonly name?: string }>,\n SandboxError.SandboxError\n >\n}\n\nexport type SandboxVolumesApi = {\n readonly create: (\n name: string,\n options?: { readonly quotaBytes?: number },\n ) => Effect.Effect<VolumeId, SandboxError.SandboxError>\n readonly destroy: (id: VolumeId) => Effect.Effect<void, SandboxError.SandboxError>\n readonly list: Effect.Effect<\n ReadonlyArray<{ readonly id: VolumeId; readonly name: string }>,\n SandboxError.SandboxError\n >\n}\n\nexport type SandboxPortsApi = {\n /**\n * Expose an internal sandbox port as a publicly reachable URL.\n * Gated by {@link SandboxPortExposure} on the free helper; adapters\n * that don't ship the marker leave this sub-API out of the public\n * surface entirely (callers can't construct an Effect against it).\n */\n readonly expose: (\n instance: SandboxInstance,\n port: number,\n ) => Effect.Effect<{ readonly url: string }, SandboxError.SandboxError>\n}\n\n// ---------------------------------------------------------------------------\n// Service definition\n// ---------------------------------------------------------------------------\n\n/**\n * Cross-provider sandbox service.\n *\n * Lifetime model: `create` returns a sandbox handle in `Scope.Scope`.\n * The scope finalizer destroys the sandbox. Use `Effect.scoped` to\n * bound a sandbox's lifetime to a single Effect, or manage the scope\n * explicitly via `Scope.make` for sandboxes that span many calls.\n * This is why there's no `destroy()` method on `SandboxInstance` —\n * the scope is the lifecycle handle.\n *\n * `snapshots` and `volumes` sub-APIs are present on the service but\n * are still capability-gated: provider Layers that don't support\n * them ship implementations that always fail with\n * `SandboxUnsupported`. The free helpers ({@link snapshot},\n * {@link createVolume}) additionally require the corresponding\n * capability marker on R, so misuses surface as type errors at\n * `Effect.provide`, not as runtime failures.\n */\nexport type SandboxService = {\n /**\n * Provision a new sandbox. The returned handle's lifetime is\n * bound to the caller's scope; the sandbox is destroyed on scope\n * close. To survive the scope, use `attach`-style reconnection or\n * promote into a wider scope.\n */\n readonly create: (\n request: CommonCreateRequest,\n ) => Effect.Effect<SandboxInstance, SandboxError.SandboxError, Scope.Scope>\n\n /**\n * Re-acquire an existing sandbox by id. The returned handle is\n * scope-bound but the finalizer is \"detach\" (no destroy) —\n * appropriate for paused / detached / persistent sandboxes that\n * outlive any single agent run.\n */\n readonly attach: (\n id: SandboxId,\n ) => Effect.Effect<SandboxInstance, SandboxError.SandboxError, Scope.Scope>\n\n /**\n * Enumerate sandboxes visible to the configured account / project.\n */\n readonly list: Effect.Effect<ReadonlyArray<SandboxRef>, SandboxError.SandboxError>\n\n /**\n * Escape hatch for destroying a sandbox from outside its owning\n * scope. Most callers should let the scope finalizer handle this.\n */\n readonly destroy: (id: SandboxId) => Effect.Effect<void, SandboxError.SandboxError>\n\n /** Snapshot management. Capability-gated on {@link SandboxSnapshots}. */\n readonly snapshots: SandboxSnapshotsApi\n\n /** Volume management. Capability-gated on {@link SandboxVolumes}. */\n readonly volumes: SandboxVolumesApi\n\n /** Port exposure. Capability-gated on {@link SandboxPortExposure}. */\n readonly ports: SandboxPortsApi\n}\n\nexport class Sandbox extends Context.Service<Sandbox, SandboxService>()(\n \"@betalyra/effect-uai/Sandbox\",\n) {}\n\n// ---------------------------------------------------------------------------\n// Capability markers\n// ---------------------------------------------------------------------------\n\n/**\n * Capability marker — provided by adapter Layers whose provider\n * supports a hostname-level egress allowlist (matching against host\n * names / wildcards, not just CIDRs). Vercel, Cloudflare, Deno,\n * Microsandbox, Runloop, Anthropic srt ship this marker; Modal and\n * Daytona (CIDR-only) do not.\n *\n * Phantom — the value is `void`; adapters register with\n * `Layer.succeed(SandboxHostnameAllowlist, undefined)`.\n */\nexport class SandboxHostnameAllowlist extends Context.Service<SandboxHostnameAllowlist, void>()(\n \"@betalyra/effect-uai/capability/SandboxHostnameAllowlist\",\n) {}\n\n/**\n * Capability marker — adapter's provider supports proxy-layer\n * secret rewriting (header injection on outbound HTTPS to bound\n * hosts; the running code never sees the real value). Deno,\n * Cloudflare, E2B, Vercel (firewall transform), Microsandbox,\n * Runloop (Agent Gateway) ship this. Modal, Daytona, CodeSandbox\n * do not.\n */\nexport class SandboxSecretInjection extends Context.Service<SandboxSecretInjection, void>()(\n \"@betalyra/effect-uai/capability/SandboxSecretInjection\",\n) {}\n\n/**\n * Capability marker — adapter supports snapshot-as-new-sandbox\n * (capture state, restore as a derived sandbox with a fresh id).\n * Distinct from {@link SandboxPauseResume}, which preserves the\n * same id and resumes in place.\n */\nexport class SandboxSnapshots extends Context.Service<SandboxSnapshots, void>()(\n \"@betalyra/effect-uai/capability/SandboxSnapshots\",\n) {}\n\n/**\n * Capability marker — adapter supports in-place pause and resume on\n * the same sandbox id (E2B, CodeSandbox). Memory + processes are\n * preserved across the pause boundary. Most providers without this\n * marker offer {@link SandboxSnapshots} instead.\n */\nexport class SandboxPauseResume extends Context.Service<SandboxPauseResume, void>()(\n \"@betalyra/effect-uai/capability/SandboxPauseResume\",\n) {}\n\n/**\n * Capability marker — adapter manages named persistent volumes\n * outside any single sandbox lifecycle (Modal Volume, Daytona,\n * Microsandbox, BoxLite). Providers without this marker leave\n * `Sandbox.volumes.*` returning `SandboxUnsupported`; the free\n * helpers ({@link createVolume}, {@link destroyVolume}) additionally\n * require this marker on R so misuses become a type error.\n */\nexport class SandboxVolumes extends Context.Service<SandboxVolumes, void>()(\n \"@betalyra/effect-uai/capability/SandboxVolumes\",\n) {}\n\n/**\n * Capability marker — adapter supports a stateful kernel session\n * (Jupyter-style: persistent Python / JS context that returns rich\n * outputs across many `runCode` calls). Cloudflare Code Interpreter\n * and E2B ship this; everyone else expects you to write your own\n * script and `exec` it.\n *\n * The actual `runCode` helper lives separately (not on\n * `SandboxInstance`) because the return shape is different — rich\n * outputs with images/tables, not buffered stdout strings.\n */\nexport class SandboxKernelSession extends Context.Service<SandboxKernelSession, void>()(\n \"@betalyra/effect-uai/capability/SandboxKernelSession\",\n) {}\n\n/**\n * Capability marker — adapter exposes an interactive PTY session\n * (Runloop, Cloudflare terminal). Distinct from `execStream` which\n * is byte-oriented and one-shot.\n */\nexport class SandboxPty extends Context.Service<SandboxPty, void>()(\n \"@betalyra/effect-uai/capability/SandboxPty\",\n) {}\n\n/**\n * Capability marker — adapter accepts a user-supplied Dockerfile (or\n * OCI image build) instead of just a registry reference. Vercel does\n * not ship this (fixed AL2023). Deno does not (snapshots only).\n * Most others do.\n */\nexport class SandboxCustomImage extends Context.Service<SandboxCustomImage, void>()(\n \"@betalyra/effect-uai/capability/SandboxCustomImage\",\n) {}\n\n/**\n * Capability marker — adapter can expose an internal port as a\n * publicly reachable URL. Most cloud providers ship this; local\n * providers (Microsandbox, BoxLite) typically only support\n * host-side port forwarding (handled by ignoring this marker and\n * documenting via the per-provider request type).\n */\nexport class SandboxPortExposure extends Context.Service<SandboxPortExposure, void>()(\n \"@betalyra/effect-uai/capability/SandboxPortExposure\",\n) {}\n\n// ---------------------------------------------------------------------------\n// Free helpers — accept Sandbox via Context, optionally require markers.\n// ---------------------------------------------------------------------------\n\n/**\n * Provision a sandbox bound to the caller's scope. Drop the\n * `Scope.Scope` requirement with `Effect.scoped`.\n */\nexport const create = (\n request: CommonCreateRequest,\n): Effect.Effect<SandboxInstance, SandboxError.SandboxError, Sandbox | Scope.Scope> =>\n Effect.flatMap(Sandbox, (s) => s.create(request))\n\n/**\n * Re-acquire an existing sandbox by id. Same scope semantics as\n * `create`, but the finalizer detaches rather than destroying.\n */\nexport const attach = (\n id: SandboxId,\n): Effect.Effect<SandboxInstance, SandboxError.SandboxError, Sandbox | Scope.Scope> =>\n Effect.flatMap(Sandbox, (s) => s.attach(id))\n\n/** Enumerate sandboxes for the configured account / project. */\nexport const list: Effect.Effect<\n ReadonlyArray<SandboxRef>,\n SandboxError.SandboxError,\n Sandbox\n> = Effect.flatMap(Sandbox, (s) => s.list)\n\n/**\n * Escape hatch for destroying a sandbox from outside its owning\n * scope. Most callers should let the scope finalizer handle this\n * automatically.\n */\nexport const destroy = (id: SandboxId): Effect.Effect<void, SandboxError.SandboxError, Sandbox> =>\n Effect.flatMap(Sandbox, (s) => s.destroy(id))\n\n/**\n * Create a snapshot of a live sandbox. Requires\n * {@link SandboxSnapshots} on the R channel — adapters whose\n * provider doesn't support snapshot-as-new-sandbox don't ship the\n * marker and calls fail at `Effect.provide` with a type error.\n */\nexport const snapshot = (\n from: SandboxInstance,\n name?: string,\n): Effect.Effect<SnapshotId, SandboxError.SandboxError, Sandbox | SandboxSnapshots> =>\n Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxSnapshots\n return yield* s.snapshots.create(from, name)\n })\n\n/**\n * Create a named persistent volume. Requires {@link SandboxVolumes}.\n */\nexport const createVolume = (\n name: string,\n options?: { readonly quotaBytes?: number },\n): Effect.Effect<VolumeId, SandboxError.SandboxError, Sandbox | SandboxVolumes> =>\n Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxVolumes\n return yield* s.volumes.create(name, options)\n })\n\n/** Destroy a named volume. Requires {@link SandboxVolumes}. */\nexport const destroyVolume = (\n id: VolumeId,\n): Effect.Effect<void, SandboxError.SandboxError, Sandbox | SandboxVolumes> =>\n Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxVolumes\n return yield* s.volumes.destroy(id)\n })\n\n/** Enumerate persistent volumes. Requires {@link SandboxVolumes}. */\nexport const listVolumes: Effect.Effect<\n ReadonlyArray<{ readonly id: VolumeId; readonly name: string }>,\n SandboxError.SandboxError,\n Sandbox | SandboxVolumes\n> = Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxVolumes\n return yield* s.volumes.list\n})\n\n/** Destroy a snapshot. Requires {@link SandboxSnapshots}. */\nexport const destroySnapshot = (\n id: SnapshotId,\n): Effect.Effect<void, SandboxError.SandboxError, Sandbox | SandboxSnapshots> =>\n Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxSnapshots\n return yield* s.snapshots.destroy(id)\n })\n\n/** Enumerate snapshots. Requires {@link SandboxSnapshots}. */\nexport const listSnapshots: Effect.Effect<\n ReadonlyArray<{ readonly id: SnapshotId; readonly name?: string }>,\n SandboxError.SandboxError,\n Sandbox | SandboxSnapshots\n> = Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxSnapshots\n return yield* s.snapshots.list\n})\n\n/**\n * Expose an internal port of a live sandbox as a publicly reachable\n * URL. Requires {@link SandboxPortExposure} — adapters whose provider\n * doesn't support runtime port exposure (e.g. Microsandbox, which\n * forwards at create time only) don't ship the marker, and calls\n * fail at `Effect.provide` with a type error.\n */\nexport const exposePort = (\n instance: SandboxInstance,\n port: number,\n): Effect.Effect<\n { readonly url: string },\n SandboxError.SandboxError,\n Sandbox | SandboxPortExposure\n> =>\n Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxPortExposure\n return yield* s.ports.expose(instance, port)\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAa,YAAY,MAAM,SAAoB;AAanD,MAAa,WAAW,MAAM,SAAmB;AAGjD,MAAa,aAAa,MAAM,SAAqB;AA4BrD,MAAa,WAAW,KAAK,YAAsB;AA2BnD,MAAa,gBAAgB,KAAK,YAA2B;AAmI7D,MAAa,YAAY,KAAK,YAAuB;AAqLrD,IAAa,UAAb,cAA6B,QAAQ,SAAkC,CACrE,+BACD,CAAC;;;;;;;;;;;AAgBF,IAAa,2BAAb,cAA8C,QAAQ,SAAyC,CAC7F,2DACD,CAAC;;;;;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AAQ,GAAG;EACnC;;AAGJ,MAAa,cAIT,OAAO,IAAI,aAAa;CAC1B,MAAM,IAAI,OAAO;AACjB,QAAO;AACP,QAAO,OAAO,EAAE,QAAQ;EACxB;;AAGF,MAAa,mBACX,OAEA,OAAO,IAAI,aAAa;CACtB,MAAM,IAAI,OAAO;AACjB,QAAO;AACP,QAAO,OAAO,EAAE,UAAU,QAAQ,GAAG;EACrC;;AAGJ,MAAa,gBAIT,OAAO,IAAI,aAAa;CAC1B,MAAM,IAAI,OAAO;AACjB,QAAO;AACP,QAAO,OAAO,EAAE,UAAU;EAC1B;;;;;;;;AASF,MAAa,cACX,UACA,SAMA,OAAO,IAAI,aAAa;CACtB,MAAM,IAAI,OAAO;AACjB,QAAO;AACP,QAAO,OAAO,EAAE,MAAM,OAAO,UAAU,KAAK;EAC5C"}
1
+ {"version":3,"file":"Sandbox.mjs","names":[],"sources":["../../src/sandbox/Sandbox.ts"],"sourcesContent":["import { Brand, Context, Data, type Duration, Effect, Redacted, Scope, Stream } from \"effect\"\nimport type * as SandboxError from \"./SandboxError.js\"\n\n// ---------------------------------------------------------------------------\n// Identity\n// ---------------------------------------------------------------------------\n\n/**\n * Sandbox identifier. Branded `string` so providers don't accidentally\n * accept a raw user-supplied id. Each provider mints these per its own\n * naming scheme (uuid for E2B/Vercel, user-supplied name for\n * Microsandbox/Modal, …); the core code treats them opaquely.\n *\n * Mint via the value-level `SandboxId(...)` smart constructor instead\n * of `as SandboxId` casts.\n */\nexport type SandboxId = Brand.Branded<string, \"SandboxId\">\nexport const SandboxId = Brand.nominal<SandboxId>()\n\n/**\n * Reference returned by `list`. Carries just enough to call `attach` —\n * provider-specific metadata (createdAt, region, tags, …) lives on the\n * narrowed per-provider ref.\n */\nexport type SandboxRef = {\n readonly id: SandboxId\n readonly name?: string\n}\n\nexport type VolumeId = Brand.Branded<string, \"VolumeId\">\nexport const VolumeId = Brand.nominal<VolumeId>()\n\nexport type SnapshotId = Brand.Branded<string, \"SnapshotId\">\nexport const SnapshotId = Brand.nominal<SnapshotId>()\n\n// ---------------------------------------------------------------------------\n// Image / runtime selection\n// ---------------------------------------------------------------------------\n\n/**\n * What runtime / filesystem to boot the sandbox from.\n *\n * - `Default` — provider picks its house image (Vercel: Amazon Linux\n * 2023; Microsandbox: requires user image but a builder default may\n * apply, …). Use when you don't care what's pre-installed.\n * - `Registry` — an OCI image reference. Supported by every provider\n * except those with a fixed base (Vercel ignores this and the\n * request-schema rejects at decode).\n * - `Snapshot` — restore from a captured state. Gated by\n * {@link SandboxSnapshots} at the call site — the marker is provided\n * by adapters whose provider supports snapshot-as-image.\n * - `Dockerfile` — provider builds a custom image from a Dockerfile.\n * Gated by {@link SandboxCustomImage}.\n */\nexport type ImageRef = Data.TaggedEnum<{\n Default: {}\n Registry: { readonly ref: string }\n Snapshot: { readonly id: SnapshotId }\n Dockerfile: { readonly contents: string }\n}>\n\nexport const ImageRef = Data.taggedEnum<ImageRef>()\n\n// ---------------------------------------------------------------------------\n// Network policy + secrets\n// ---------------------------------------------------------------------------\n\n/**\n * Outbound network policy for a sandbox.\n *\n * - `Open` — no egress restriction. The provider's defaults apply\n * (e.g. Microsandbox's \"public-only\" still blocks private ranges).\n * - `Blocked` — fully airgapped, no outbound connectivity at all.\n * - `Allowlist` — only the listed hosts / CIDRs may be reached.\n *\n * Providers vary in what they honour: hostname-allowlist requires\n * {@link SandboxHostnameAllowlist}; CIDR-only providers ignore `hosts`\n * and the adapter rejects at decode if `hosts` is non-empty.\n */\nexport type NetworkPolicy = Data.TaggedEnum<{\n Open: {}\n Blocked: {}\n Allowlist: {\n readonly hosts?: ReadonlyArray<string>\n readonly cidrs?: ReadonlyArray<string>\n }\n}>\n\nexport const NetworkPolicy = Data.taggedEnum<NetworkPolicy>()\n\n/**\n * A secret bound to a sandbox at create time. The code inside the\n * sandbox sees only a placeholder (`$MSB_<NAME>` for Microsandbox,\n * `{name}` for Vercel header-injection, etc.); the real `value` lives\n * on the provider's proxy and is substituted on outbound HTTPS to\n * `hosts`.\n *\n * Requires the {@link SandboxSecretInjection} capability marker —\n * provider Layers without proxy-layer secret rewriting do not ship the\n * marker and consumer code fails at `Effect.provide` with a type\n * error.\n *\n * `header` is the request header to inject (default\n * `\"Authorization: Bearer <value>\"`). Providers that do not let\n * callers pick the header (Microsandbox's `secretEnv` shorthand)\n * silently ignore this field; providers that require an explicit\n * header (Vercel's `transform.headers`) fail at decode if it's absent.\n */\nexport type BoundSecret = {\n readonly name: string\n readonly value: Redacted.Redacted<string>\n readonly hosts: ReadonlyArray<string>\n readonly header?: string\n}\n\n// ---------------------------------------------------------------------------\n// Volumes (capability-gated on `SandboxVolumes`)\n// ---------------------------------------------------------------------------\n\nexport type VolumeMount = {\n readonly id: VolumeId\n readonly mountPath: string\n readonly readonly?: boolean\n}\n\n// ---------------------------------------------------------------------------\n// Create / exec request shapes\n// ---------------------------------------------------------------------------\n\n/**\n * Cross-provider create request. Provider-specific knobs (region,\n * cpus, memory, template id, …) live on each provider's narrowed\n * request type which extends this.\n *\n * Fields a provider can't honour fail at **decode time** (per the\n * per-provider request schema), not silently at runtime. The\n * ComputeSDK anti-pattern of \"drop unsupported fields\" is the\n * footgun we're avoiding.\n */\nexport type CommonCreateRequest = {\n /** Image / snapshot to boot from. Omit for the provider's default. */\n readonly image?: ImageRef\n /**\n * Idle / hard timeout. Accepts a number (millis), a string like\n * `\"30 seconds\"`, or a `Duration`. Providers default differently.\n */\n readonly timeout?: Duration.Input\n /**\n * Env vars exposed to the sandbox. NOT for secrets you want hidden\n * from the running code — use {@link BoundSecret} instead.\n */\n readonly env?: Readonly<Record<string, string>>\n /** Outbound network policy. */\n readonly network?: NetworkPolicy\n /**\n * Bound secrets — code inside the sandbox sees a placeholder; the\n * proxy substitutes the real value on outbound HTTPS to listed hosts.\n * Capability-gated on {@link SandboxSecretInjection}.\n */\n readonly secrets?: ReadonlyArray<BoundSecret>\n /**\n * Persistent volumes to mount. Volumes are created via\n * `Sandbox.volumes.create` and survive sandbox lifetime.\n * Capability-gated on {@link SandboxVolumes}.\n */\n readonly volumes?: ReadonlyArray<VolumeMount>\n}\n\n/**\n * Cross-provider exec request. Background / long-running processes\n * use `spawn` instead of `exec`; the semantics differ enough that\n * overloading `exec` with a `detached` flag was rejected during\n * design.\n */\nexport type CommonExecRequest = {\n /**\n * Argv-style command. Pass a string for \"run this through the\n * shell\" semantics (provider-dependent — most use `sh -c`); pass\n * an array for direct argv with no shell parsing.\n */\n readonly cmd: string | ReadonlyArray<string>\n readonly cwd?: string\n readonly env?: Readonly<Record<string, string>>\n readonly stdin?: string | Uint8Array\n /**\n * Per-exec timeout. Accepts a number (millis), a string like\n * `\"5 seconds\"`, or a `Duration`.\n */\n readonly timeout?: Duration.Input\n}\n\n/**\n * Spawn request — extends {@link CommonExecRequest} with the option\n * to provide stdin as a `Stream<Uint8Array>`. The provider takes one\n * chunk at a time and sends EOF when the stream completes. Useful\n * for piping LLM output into a sandboxed process, or feeding stdin\n * from another stream source. `exec` does not accept streams.\n */\nexport type CommonSpawnRequest = Omit<CommonExecRequest, \"stdin\"> & {\n readonly stdin?: string | Uint8Array | Stream.Stream<Uint8Array, never, never>\n}\n\nexport type ExecResult = {\n readonly exitCode: number\n readonly stdout: string\n readonly stderr: string\n readonly durationMs: number\n}\n\n/**\n * Streaming exec output. `Complete` is terminal — the stream\n * completes after emitting it.\n */\nexport type ExecEvent = Data.TaggedEnum<{\n Stdout: { readonly chunk: Uint8Array }\n Stderr: { readonly chunk: Uint8Array }\n Complete: { readonly exitCode: number; readonly durationMs: number }\n}>\n\nexport const ExecEvent = Data.taggedEnum<ExecEvent>()\n\n// ---------------------------------------------------------------------------\n// Filesystem\n// ---------------------------------------------------------------------------\n\nexport type FileEntryKind = \"file\" | \"directory\" | \"symlink\" | \"other\"\n\nexport type FileEntry = {\n readonly path: string\n readonly kind: FileEntryKind\n}\n\nexport type SandboxFilesystem = {\n readonly read: (path: string) => Effect.Effect<Uint8Array, SandboxError.SandboxError>\n readonly write: (\n path: string,\n contents: Uint8Array | string,\n ) => Effect.Effect<void, SandboxError.SandboxError>\n readonly remove: (path: string) => Effect.Effect<void, SandboxError.SandboxError>\n readonly mkdir: (path: string) => Effect.Effect<void, SandboxError.SandboxError>\n readonly list: (\n path: string,\n ) => Effect.Effect<ReadonlyArray<FileEntry>, SandboxError.SandboxError>\n readonly exists: (path: string) => Effect.Effect<boolean, SandboxError.SandboxError>\n}\n\n// ---------------------------------------------------------------------------\n// Process handle (returned by `spawn`)\n// ---------------------------------------------------------------------------\n\n/**\n * Long-running process handle. Returned by `spawn` in a `Scope.Scope`\n * — the process is killed on scope close. To outlive the calling\n * scope, do `Effect.forkScoped` against a wider scope or use\n * `attach`-style reconnection per the provider's escape hatch.\n */\nexport type ProcessHandle = {\n readonly pid: number\n readonly events: Stream.Stream<ExecEvent, SandboxError.SandboxError>\n readonly kill: Effect.Effect<void, SandboxError.SandboxError>\n readonly exit: Effect.Effect<{ readonly exitCode: number }, SandboxError.SandboxError>\n}\n\n// ---------------------------------------------------------------------------\n// SandboxInstance — the live handle returned from `create` / `attach`\n// ---------------------------------------------------------------------------\n\n/**\n * Live sandbox handle. Methods are plain `Effect` / `Stream` values\n * — no nullary thunks (`destroy()`, `pause()`) — to match Effect's\n * `Queue.shutdown` / `Fiber.interrupt` style. Destruction is the\n * scope finalizer, not a method here; for the rare \"kill from\n * another fiber\" case use the service-level escape hatch\n * `Sandbox.destroy(id)`.\n */\nexport type SandboxInstance = {\n readonly id: SandboxId\n readonly exec: (\n request: CommonExecRequest,\n ) => Effect.Effect<ExecResult, SandboxError.SandboxError>\n readonly execStream: (\n request: CommonExecRequest,\n ) => Stream.Stream<ExecEvent, SandboxError.SandboxError>\n /**\n * Spawn a background / long-running process. The returned handle is\n * scoped — the process is killed on scope close. Use this for\n * \"dev server / watcher / tail -f\" workloads. For one-shot\n * commands prefer `exec`.\n */\n readonly spawn: (\n request: CommonSpawnRequest,\n ) => Effect.Effect<ProcessHandle, SandboxError.SandboxError, Scope.Scope>\n readonly files: SandboxFilesystem\n}\n\n// ---------------------------------------------------------------------------\n// Snapshot / volume / port sub-services (capability-gated)\n// ---------------------------------------------------------------------------\n\nexport type SandboxSnapshotsApi = {\n readonly create: (\n from: SandboxInstance,\n name?: string,\n ) => Effect.Effect<SnapshotId, SandboxError.SandboxError>\n readonly destroy: (id: SnapshotId) => Effect.Effect<void, SandboxError.SandboxError>\n readonly list: Effect.Effect<\n ReadonlyArray<{ readonly id: SnapshotId; readonly name?: string }>,\n SandboxError.SandboxError\n >\n}\n\nexport type SandboxVolumesApi = {\n readonly create: (\n name: string,\n options?: { readonly quotaBytes?: number },\n ) => Effect.Effect<VolumeId, SandboxError.SandboxError>\n readonly destroy: (id: VolumeId) => Effect.Effect<void, SandboxError.SandboxError>\n readonly list: Effect.Effect<\n ReadonlyArray<{ readonly id: VolumeId; readonly name: string }>,\n SandboxError.SandboxError\n >\n}\n\nexport type SandboxPortsApi = {\n /**\n * Expose an internal sandbox port as a publicly reachable URL.\n * Gated by {@link SandboxPortExposure} on the free helper; adapters\n * that don't ship the marker leave this sub-API out of the public\n * surface entirely (callers can't construct an Effect against it).\n */\n readonly expose: (\n instance: SandboxInstance,\n port: number,\n ) => Effect.Effect<{ readonly url: string }, SandboxError.SandboxError>\n}\n\n// ---------------------------------------------------------------------------\n// Service definition\n// ---------------------------------------------------------------------------\n\n/**\n * Cross-provider sandbox service.\n *\n * Lifetime model: `create` returns a sandbox handle in `Scope.Scope`.\n * The scope finalizer destroys the sandbox. Use `Effect.scoped` to\n * bound a sandbox's lifetime to a single Effect, or manage the scope\n * explicitly via `Scope.make` for sandboxes that span many calls.\n * This is why there's no `destroy()` method on `SandboxInstance` —\n * the scope is the lifecycle handle.\n *\n * `snapshots` and `volumes` sub-APIs are present on the service but\n * are still capability-gated: provider Layers that don't support\n * them ship implementations that always fail with\n * `SandboxUnsupported`. The free helpers ({@link snapshot},\n * {@link createVolume}) additionally require the corresponding\n * capability marker on R, so misuses surface as type errors at\n * `Effect.provide`, not as runtime failures.\n */\nexport type SandboxService = {\n /**\n * Provision a new sandbox. The returned handle's lifetime is\n * bound to the caller's scope; the sandbox is destroyed on scope\n * close. To survive the scope, use `attach`-style reconnection or\n * promote into a wider scope.\n */\n readonly create: (\n request: CommonCreateRequest,\n ) => Effect.Effect<SandboxInstance, SandboxError.SandboxError, Scope.Scope>\n\n /**\n * Re-acquire an existing sandbox by id. The returned handle is\n * scope-bound but the finalizer is \"detach\" (no destroy) —\n * appropriate for paused / detached / persistent sandboxes that\n * outlive any single agent run.\n */\n readonly attach: (\n id: SandboxId,\n ) => Effect.Effect<SandboxInstance, SandboxError.SandboxError, Scope.Scope>\n\n /**\n * Enumerate sandboxes visible to the configured account / project.\n */\n readonly list: Effect.Effect<ReadonlyArray<SandboxRef>, SandboxError.SandboxError>\n\n /**\n * Escape hatch for destroying a sandbox from outside its owning\n * scope. Most callers should let the scope finalizer handle this.\n */\n readonly destroy: (id: SandboxId) => Effect.Effect<void, SandboxError.SandboxError>\n\n /** Snapshot management. Capability-gated on {@link SandboxSnapshots}. */\n readonly snapshots: SandboxSnapshotsApi\n\n /** Volume management. Capability-gated on {@link SandboxVolumes}. */\n readonly volumes: SandboxVolumesApi\n\n /** Port exposure. Capability-gated on {@link SandboxPortExposure}. */\n readonly ports: SandboxPortsApi\n}\n\nexport class Sandbox extends Context.Service<Sandbox, SandboxService>()(\n \"@betalyra/effect-uai/Sandbox\",\n) {}\n\n// ---------------------------------------------------------------------------\n// Capability markers\n// ---------------------------------------------------------------------------\n\n/**\n * Capability marker — provided by adapter Layers whose provider\n * supports a hostname-level egress allowlist (matching against host\n * names / wildcards, not just CIDRs). Vercel, Cloudflare, Deno,\n * Microsandbox, Runloop, Anthropic srt ship this marker; Modal and\n * Daytona (CIDR-only) do not.\n *\n * Phantom — the value is `void`; adapters register with\n * `Layer.succeed(SandboxHostnameAllowlist, undefined)`.\n */\nexport class SandboxHostnameAllowlist extends Context.Service<SandboxHostnameAllowlist, void>()(\n \"@betalyra/effect-uai/capability/SandboxHostnameAllowlist\",\n) {}\n\n/**\n * Capability marker — adapter's provider supports proxy-layer\n * secret rewriting (header injection on outbound HTTPS to bound\n * hosts; the running code never sees the real value). Deno,\n * Cloudflare, E2B, Vercel (firewall transform), Microsandbox,\n * Runloop (Agent Gateway) ship this. Modal, Daytona, CodeSandbox\n * do not.\n */\nexport class SandboxSecretInjection extends Context.Service<SandboxSecretInjection, void>()(\n \"@betalyra/effect-uai/capability/SandboxSecretInjection\",\n) {}\n\n/**\n * Capability marker — adapter supports snapshot-as-new-sandbox\n * (capture state, restore as a derived sandbox with a fresh id).\n * Distinct from {@link SandboxPauseResume}, which preserves the\n * same id and resumes in place.\n */\nexport class SandboxSnapshots extends Context.Service<SandboxSnapshots, void>()(\n \"@betalyra/effect-uai/capability/SandboxSnapshots\",\n) {}\n\n/**\n * Capability marker — adapter supports in-place pause and resume on\n * the same sandbox id (E2B, CodeSandbox). Memory + processes are\n * preserved across the pause boundary. Most providers without this\n * marker offer {@link SandboxSnapshots} instead.\n */\nexport class SandboxPauseResume extends Context.Service<SandboxPauseResume, void>()(\n \"@betalyra/effect-uai/capability/SandboxPauseResume\",\n) {}\n\n/**\n * Capability marker — adapter manages named persistent volumes\n * outside any single sandbox lifecycle (Modal Volume, Daytona,\n * Microsandbox, BoxLite). Providers without this marker leave\n * `Sandbox.volumes.*` returning `SandboxUnsupported`; the free\n * helpers ({@link createVolume}, {@link destroyVolume}) additionally\n * require this marker on R so misuses become a type error.\n */\nexport class SandboxVolumes extends Context.Service<SandboxVolumes, void>()(\n \"@betalyra/effect-uai/capability/SandboxVolumes\",\n) {}\n\n/**\n * Capability marker — adapter supports a stateful kernel session\n * (Jupyter-style: persistent Python / JS context that returns rich\n * outputs across many `runCode` calls). Cloudflare Code Interpreter\n * and E2B ship this; everyone else expects you to write your own\n * script and `exec` it.\n *\n * The actual `runCode` helper lives separately (not on\n * `SandboxInstance`) because the return shape is different — rich\n * outputs with images/tables, not buffered stdout strings.\n */\nexport class SandboxKernelSession extends Context.Service<SandboxKernelSession, void>()(\n \"@betalyra/effect-uai/capability/SandboxKernelSession\",\n) {}\n\n/**\n * Capability marker — adapter exposes an interactive PTY session\n * (Runloop, Cloudflare terminal). Distinct from `execStream` which\n * is byte-oriented and one-shot.\n */\nexport class SandboxPty extends Context.Service<SandboxPty, void>()(\n \"@betalyra/effect-uai/capability/SandboxPty\",\n) {}\n\n/**\n * Capability marker — adapter accepts a user-supplied Dockerfile (or\n * OCI image build) instead of just a registry reference. Vercel does\n * not ship this (fixed AL2023). Deno does not (snapshots only).\n * Most others do.\n */\nexport class SandboxCustomImage extends Context.Service<SandboxCustomImage, void>()(\n \"@betalyra/effect-uai/capability/SandboxCustomImage\",\n) {}\n\n/**\n * Capability marker — adapter can expose an internal port as a\n * publicly reachable URL. Most cloud providers ship this; local\n * providers (Microsandbox, BoxLite) typically only support\n * host-side port forwarding (handled by ignoring this marker and\n * documenting via the per-provider request type).\n */\nexport class SandboxPortExposure extends Context.Service<SandboxPortExposure, void>()(\n \"@betalyra/effect-uai/capability/SandboxPortExposure\",\n) {}\n\n// ---------------------------------------------------------------------------\n// Free helpers — accept Sandbox via Context, optionally require markers.\n// ---------------------------------------------------------------------------\n\n/**\n * Provision a sandbox bound to the caller's scope. Drop the\n * `Scope.Scope` requirement with `Effect.scoped`.\n */\nexport const create = (\n request: CommonCreateRequest,\n): Effect.Effect<SandboxInstance, SandboxError.SandboxError, Sandbox | Scope.Scope> =>\n Effect.flatMap(Sandbox, (s) => s.create(request))\n\n/**\n * Re-acquire an existing sandbox by id. Same scope semantics as\n * `create`, but the finalizer detaches rather than destroying.\n */\nexport const attach = (\n id: SandboxId,\n): Effect.Effect<SandboxInstance, SandboxError.SandboxError, Sandbox | Scope.Scope> =>\n Effect.flatMap(Sandbox, (s) => s.attach(id))\n\n/** Enumerate sandboxes for the configured account / project. */\nexport const list: Effect.Effect<\n ReadonlyArray<SandboxRef>,\n SandboxError.SandboxError,\n Sandbox\n> = Effect.flatMap(Sandbox, (s) => s.list)\n\n/**\n * Escape hatch for destroying a sandbox from outside its owning\n * scope. Most callers should let the scope finalizer handle this\n * automatically.\n */\nexport const destroy = (id: SandboxId): Effect.Effect<void, SandboxError.SandboxError, Sandbox> =>\n Effect.flatMap(Sandbox, (s) => s.destroy(id))\n\n/**\n * Create a snapshot of a live sandbox. Requires\n * {@link SandboxSnapshots} on the R channel — adapters whose\n * provider doesn't support snapshot-as-new-sandbox don't ship the\n * marker and calls fail at `Effect.provide` with a type error.\n */\nexport const snapshot = (\n from: SandboxInstance,\n name?: string,\n): Effect.Effect<SnapshotId, SandboxError.SandboxError, Sandbox | SandboxSnapshots> =>\n Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxSnapshots\n return yield* s.snapshots.create(from, name)\n })\n\n/**\n * Create a named persistent volume. Requires {@link SandboxVolumes}.\n */\nexport const createVolume = (\n name: string,\n options?: { readonly quotaBytes?: number },\n): Effect.Effect<VolumeId, SandboxError.SandboxError, Sandbox | SandboxVolumes> =>\n Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxVolumes\n return yield* s.volumes.create(name, options)\n })\n\n/** Destroy a named volume. Requires {@link SandboxVolumes}. */\nexport const destroyVolume = (\n id: VolumeId,\n): Effect.Effect<void, SandboxError.SandboxError, Sandbox | SandboxVolumes> =>\n Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxVolumes\n return yield* s.volumes.destroy(id)\n })\n\n/** Enumerate persistent volumes. Requires {@link SandboxVolumes}. */\nexport const listVolumes: Effect.Effect<\n ReadonlyArray<{ readonly id: VolumeId; readonly name: string }>,\n SandboxError.SandboxError,\n Sandbox | SandboxVolumes\n> = Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxVolumes\n return yield* s.volumes.list\n})\n\n/** Destroy a snapshot. Requires {@link SandboxSnapshots}. */\nexport const destroySnapshot = (\n id: SnapshotId,\n): Effect.Effect<void, SandboxError.SandboxError, Sandbox | SandboxSnapshots> =>\n Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxSnapshots\n return yield* s.snapshots.destroy(id)\n })\n\n/** Enumerate snapshots. Requires {@link SandboxSnapshots}. */\nexport const listSnapshots: Effect.Effect<\n ReadonlyArray<{ readonly id: SnapshotId; readonly name?: string }>,\n SandboxError.SandboxError,\n Sandbox | SandboxSnapshots\n> = Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxSnapshots\n return yield* s.snapshots.list\n})\n\n/**\n * Expose an internal port of a live sandbox as a publicly reachable\n * URL. Requires {@link SandboxPortExposure} — adapters whose provider\n * doesn't support runtime port exposure (e.g. Microsandbox, which\n * forwards at create time only) don't ship the marker, and calls\n * fail at `Effect.provide` with a type error.\n */\nexport const exposePort = (\n instance: SandboxInstance,\n port: number,\n): Effect.Effect<\n { readonly url: string },\n SandboxError.SandboxError,\n Sandbox | SandboxPortExposure\n> =>\n Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxPortExposure\n return yield* s.ports.expose(instance, port)\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAa,YAAY,MAAM,QAAmB;AAalD,MAAa,WAAW,MAAM,QAAkB;AAGhD,MAAa,aAAa,MAAM,QAAoB;AA4BpD,MAAa,WAAW,KAAK,WAAqB;AA2BlD,MAAa,gBAAgB,KAAK,WAA0B;AAmI5D,MAAa,YAAY,KAAK,WAAsB;AAqLpD,IAAa,UAAb,cAA6B,QAAQ,QAAiC,CAAC,CACrE,8BACF,CAAC,CAAC,CAAC;;;;;;;;;;;AAgBH,IAAa,2BAAb,cAA8C,QAAQ,QAAwC,CAAC,CAC7F,0DACF,CAAC,CAAC,CAAC;;;;;;;;;AAUH,IAAa,yBAAb,cAA4C,QAAQ,QAAsC,CAAC,CACzF,wDACF,CAAC,CAAC,CAAC;;;;;;;AAQH,IAAa,mBAAb,cAAsC,QAAQ,QAAgC,CAAC,CAC7E,kDACF,CAAC,CAAC,CAAC;;;;;;;AAQH,IA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MAAa,cAIT,OAAO,IAAI,aAAa;CAC1B,MAAM,IAAI,OAAO;CACjB,OAAO;CACP,OAAO,OAAO,EAAE,QAAQ;AAC1B,CAAC;;AAGD,MAAa,mBACX,OAEA,OAAO,IAAI,aAAa;CACtB,MAAM,IAAI,OAAO;CACjB,OAAO;CACP,OAAO,OAAO,EAAE,UAAU,QAAQ,EAAE;AACtC,CAAC;;AAGH,MAAa,gBAIT,OAAO,IAAI,aAAa;CAC1B,MAAM,IAAI,OAAO;CACjB,OAAO;CACP,OAAO,OAAO,EAAE,UAAU;AAC5B,CAAC;;;;;;;;AASD,MAAa,cACX,UACA,SAMA,OAAO,IAAI,aAAa;CACtB,MAAM,IAAI,OAAO;CACjB,OAAO;CACP,OAAO,OAAO,EAAE,MAAM,OAAO,UAAU,IAAI;AAC7C,CAAC"}
@@ -1,2 +1,2 @@
1
- import { a as SandboxError, c as SandboxInvalidRequest, d as SandboxQuotaExceeded, f as SandboxTimeout, i as SandboxCreateFailed, l as SandboxNetworkPolicyDenied, n as SandboxAuthFailed, p as SandboxUnsupported, r as SandboxAuthSubtype, s as SandboxExecFailed, t as SandboxAlreadyExists, u as SandboxNotFound } from "../SandboxError-CIrVDOMV.mjs";
1
+ import { a as SandboxError, c as SandboxInvalidRequest, d as SandboxQuotaExceeded, f as SandboxTimeout, i as SandboxCreateFailed, l as SandboxNetworkPolicyDenied, n as SandboxAuthFailed, p as SandboxUnsupported, r as SandboxAuthSubtype, s as SandboxExecFailed, t as SandboxAlreadyExists, u as SandboxNotFound } from "../SandboxError-BN8b28Bh.mjs";
2
2
  export { SandboxAlreadyExists, SandboxAuthFailed, SandboxAuthSubtype, SandboxCreateFailed, SandboxError, SandboxExecFailed, SandboxInvalidRequest, SandboxNetworkPolicyDenied, SandboxNotFound, SandboxQuotaExceeded, SandboxTimeout, SandboxUnsupported };
@@ -1,4 +1,4 @@
1
- import { n as __exportAll } from "../chunk-uyGKjUfl.mjs";
1
+ import { n as __exportAll } from "../rolldown-runtime-EAsCxrDo.mjs";
2
2
  import { Data } from "effect";
3
3
  //#region src/sandbox/SandboxError.ts
4
4
  var SandboxError_exports = /* @__PURE__ */ __exportAll({
@@ -1 +1 @@
1
- {"version":3,"file":"SandboxError.mjs","names":[],"sources":["../../src/sandbox/SandboxError.ts"],"sourcesContent":["import { Data, Duration } from \"effect\"\n\n/**\n * Failed to provision a sandbox. Covers image pull failures, region\n * unavailability, the provider being unreachable, etc. The provider's\n * structured reason (if any) is on `reason`; the raw error from the\n * underlying SDK is on `raw`.\n */\nexport class SandboxCreateFailed extends Data.TaggedError(\"SandboxCreateFailed\")<{\n provider: string\n reason?: string\n raw: unknown\n}> {}\n\n/**\n * The requested sandbox id does not exist (or was already destroyed).\n * Distinct from `SandboxCreateFailed` — this is for `attach` / `destroy` /\n * `get`-style lookups against a stale id.\n */\nexport class SandboxNotFound extends Data.TaggedError(\"SandboxNotFound\")<{\n provider: string\n id: string\n}> {}\n\n/**\n * Caller tried to create a sandbox whose id is already taken. Providers\n * that keyed by name (Microsandbox, Modal) surface this when a previous\n * sandbox with the same name is still alive. Distinct from\n * `SandboxCreateFailed` so callers can retry with `replace` semantics.\n */\nexport class SandboxAlreadyExists extends Data.TaggedError(\"SandboxAlreadyExists\")<{\n provider: string\n id: string\n}> {}\n\n/**\n * A shell exec inside the sandbox failed at the transport / SDK layer —\n * i.e. the SDK couldn't deliver the command to the guest, or the guest\n * agent itself errored. A non-zero exit code from the guest's command\n * is NOT an error; it's an `ExecResult` with `exitCode !== 0`.\n */\nexport class SandboxExecFailed extends Data.TaggedError(\"SandboxExecFailed\")<{\n provider: string\n reason?: string\n raw: unknown\n}> {}\n\n/**\n * A sandbox operation (create, exec, file op) exceeded its time budget.\n * Carries the budget that was breached for observability.\n */\nexport class SandboxTimeout extends Data.TaggedError(\"SandboxTimeout\")<{\n provider: string\n operation: \"create\" | \"exec\" | \"filesystem\" | \"attach\"\n budget?: Duration.Duration\n raw?: unknown\n}> {}\n\n/**\n * Outbound network request from inside the sandbox was blocked by the\n * configured egress policy (host not on allowlist, CIDR mismatch, etc.).\n * Surfaced when the provider's SDK reports the denial back to the host\n * — many providers simply let the request fail inside the guest and\n * never report this to the host, in which case this error is never\n * raised by the adapter.\n */\nexport class SandboxNetworkPolicyDenied extends Data.TaggedError(\"SandboxNetworkPolicyDenied\")<{\n provider: string\n host?: string\n reason?: string\n raw: unknown\n}> {}\n\n/**\n * Provider rejected the create / exec because account / org / project\n * quota or concurrency limit was exceeded. Surfaced separately from\n * `SandboxCreateFailed` so callers can back off and retry intelligently.\n */\nexport class SandboxQuotaExceeded extends Data.TaggedError(\"SandboxQuotaExceeded\")<{\n provider: string\n reason?: string\n raw: unknown\n}> {}\n\n/**\n * Caller's request shape is malformed for the wired provider — e.g. a\n * Dockerfile passed to a provider that only accepts registry refs, a\n * hostname allowlist passed to a CIDR-only provider, etc. Adapters\n * should also reject these at the request-schema layer where possible;\n * this is the runtime fallback.\n */\nexport class SandboxInvalidRequest extends Data.TaggedError(\"SandboxInvalidRequest\")<{\n provider: string\n param?: string\n reason?: string\n raw?: unknown\n}> {}\n\n/**\n * Sandbox SDK could not authenticate against the provider. Subtype\n * mirrors the model-side `AiError.AuthFailed` shape for consistency.\n */\nexport type SandboxAuthSubtype = \"auth\" | \"permission\" | \"billing\" | \"quota\"\n\nexport class SandboxAuthFailed extends Data.TaggedError(\"SandboxAuthFailed\")<{\n provider: string\n subtype: SandboxAuthSubtype\n raw: unknown\n}> {}\n\n/**\n * The wired provider does not implement the requested capability for\n * this specific request. Distinct from `SandboxInvalidRequest` (the\n * request shape is malformed) and from compile-time capability\n * markers (`SandboxSnapshots`, `SandboxSecretInjection`, …) which gate\n * blanket provider-level gaps.\n *\n * Reserved for request-data-dependent gaps where the provider supports\n * the method in general but not for these inputs — e.g. passing\n * `hosts: [...]` to a CIDR-only allowlist provider, or passing\n * `dockerfile: ...` to a provider whose `SandboxCustomImage` marker\n * was provided but which only accepts a flat Dockerfile string.\n */\nexport class SandboxUnsupported extends Data.TaggedError(\"SandboxUnsupported\")<{\n provider: string\n capability: string\n reason?: string\n}> {}\n\nexport type SandboxError =\n | SandboxCreateFailed\n | SandboxNotFound\n | SandboxAlreadyExists\n | SandboxExecFailed\n | SandboxTimeout\n | SandboxNetworkPolicyDenied\n | SandboxQuotaExceeded\n | SandboxInvalidRequest\n | SandboxAuthFailed\n | SandboxUnsupported\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAQA,IAAa,sBAAb,cAAyC,KAAK,YAAY,sBAAsB,CAI7E;;;;;;AAOH,IAAa,kBAAb,cAAqC,KAAK,YAAY,kBAAkB,CAGrE;;;;;;;AAQH,IAAa,uBAAb,cAA0C,KAAK,YAAY,uBAAuB,CAG/E;;;;;;;AAQH,IAAa,oBAAb,cAAuC,KAAK,YAAY,oBAAoB,CAIzE;;;;;AAMH,IAAa,iBAAb,cAAoC,KAAK,YAAY,iBAAiB,CAKnE;;;;;;;;;AAUH,IAAa,6BAAb,cAAgD,KAAK,YAAY,6BAA6B,CAK3F;;;;;;AAOH,IAAa,uBAAb,cAA0C,KAAK,YAAY,uBAAuB,CAI/E;;;;;;;;AASH,IAAa,wBAAb,cAA2C,KAAK,YAAY,wBAAwB,CAKjF;AAQH,IAAa,oBAAb,cAAuC,KAAK,YAAY,oBAAoB,CAIzE;;;;;;;;;;;;;;AAeH,IAAa,qBAAb,cAAwC,KAAK,YAAY,qBAAqB,CAI3E"}
1
+ {"version":3,"file":"SandboxError.mjs","names":[],"sources":["../../src/sandbox/SandboxError.ts"],"sourcesContent":["import { Data, Duration } from \"effect\"\n\n/**\n * Failed to provision a sandbox. Covers image pull failures, region\n * unavailability, the provider being unreachable, etc. The provider's\n * structured reason (if any) is on `reason`; the raw error from the\n * underlying SDK is on `raw`.\n */\nexport class SandboxCreateFailed extends Data.TaggedError(\"SandboxCreateFailed\")<{\n provider: string\n reason?: string\n raw: unknown\n}> {}\n\n/**\n * The requested sandbox id does not exist (or was already destroyed).\n * Distinct from `SandboxCreateFailed` — this is for `attach` / `destroy` /\n * `get`-style lookups against a stale id.\n */\nexport class SandboxNotFound extends Data.TaggedError(\"SandboxNotFound\")<{\n provider: string\n id: string\n}> {}\n\n/**\n * Caller tried to create a sandbox whose id is already taken. Providers\n * that keyed by name (Microsandbox, Modal) surface this when a previous\n * sandbox with the same name is still alive. Distinct from\n * `SandboxCreateFailed` so callers can retry with `replace` semantics.\n */\nexport class SandboxAlreadyExists extends Data.TaggedError(\"SandboxAlreadyExists\")<{\n provider: string\n id: string\n}> {}\n\n/**\n * A shell exec inside the sandbox failed at the transport / SDK layer —\n * i.e. the SDK couldn't deliver the command to the guest, or the guest\n * agent itself errored. A non-zero exit code from the guest's command\n * is NOT an error; it's an `ExecResult` with `exitCode !== 0`.\n */\nexport class SandboxExecFailed extends Data.TaggedError(\"SandboxExecFailed\")<{\n provider: string\n reason?: string\n raw: unknown\n}> {}\n\n/**\n * A sandbox operation (create, exec, file op) exceeded its time budget.\n * Carries the budget that was breached for observability.\n */\nexport class SandboxTimeout extends Data.TaggedError(\"SandboxTimeout\")<{\n provider: string\n operation: \"create\" | \"exec\" | \"filesystem\" | \"attach\"\n budget?: Duration.Duration\n raw?: unknown\n}> {}\n\n/**\n * Outbound network request from inside the sandbox was blocked by the\n * configured egress policy (host not on allowlist, CIDR mismatch, etc.).\n * Surfaced when the provider's SDK reports the denial back to the host\n * — many providers simply let the request fail inside the guest and\n * never report this to the host, in which case this error is never\n * raised by the adapter.\n */\nexport class SandboxNetworkPolicyDenied extends Data.TaggedError(\"SandboxNetworkPolicyDenied\")<{\n provider: string\n host?: string\n reason?: string\n raw: unknown\n}> {}\n\n/**\n * Provider rejected the create / exec because account / org / project\n * quota or concurrency limit was exceeded. Surfaced separately from\n * `SandboxCreateFailed` so callers can back off and retry intelligently.\n */\nexport class SandboxQuotaExceeded extends Data.TaggedError(\"SandboxQuotaExceeded\")<{\n provider: string\n reason?: string\n raw: unknown\n}> {}\n\n/**\n * Caller's request shape is malformed for the wired provider — e.g. a\n * Dockerfile passed to a provider that only accepts registry refs, a\n * hostname allowlist passed to a CIDR-only provider, etc. Adapters\n * should also reject these at the request-schema layer where possible;\n * this is the runtime fallback.\n */\nexport class SandboxInvalidRequest extends Data.TaggedError(\"SandboxInvalidRequest\")<{\n provider: string\n param?: string\n reason?: string\n raw?: unknown\n}> {}\n\n/**\n * Sandbox SDK could not authenticate against the provider. Subtype\n * mirrors the model-side `AiError.AuthFailed` shape for consistency.\n */\nexport type SandboxAuthSubtype = \"auth\" | \"permission\" | \"billing\" | \"quota\"\n\nexport class SandboxAuthFailed extends Data.TaggedError(\"SandboxAuthFailed\")<{\n provider: string\n subtype: SandboxAuthSubtype\n raw: unknown\n}> {}\n\n/**\n * The wired provider does not implement the requested capability for\n * this specific request. Distinct from `SandboxInvalidRequest` (the\n * request shape is malformed) and from compile-time capability\n * markers (`SandboxSnapshots`, `SandboxSecretInjection`, …) which gate\n * blanket provider-level gaps.\n *\n * Reserved for request-data-dependent gaps where the provider supports\n * the method in general but not for these inputs — e.g. passing\n * `hosts: [...]` to a CIDR-only allowlist provider, or passing\n * `dockerfile: ...` to a provider whose `SandboxCustomImage` marker\n * was provided but which only accepts a flat Dockerfile string.\n */\nexport class SandboxUnsupported extends Data.TaggedError(\"SandboxUnsupported\")<{\n provider: string\n capability: string\n reason?: string\n}> {}\n\nexport type SandboxError =\n | SandboxCreateFailed\n | SandboxNotFound\n | SandboxAlreadyExists\n | SandboxExecFailed\n | SandboxTimeout\n | SandboxNetworkPolicyDenied\n | SandboxQuotaExceeded\n | SandboxInvalidRequest\n | SandboxAuthFailed\n | SandboxUnsupported\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAQA,IAAa,sBAAb,cAAyC,KAAK,YAAY,qBAAqB,CAAC,CAI7E,CAAC;;;;;;AAOJ,IAAa,kBAAb,cAAqC,KAAK,YAAY,iBAAiB,CAAC,CAGrE,CAAC;;;;;;;AAQJ,IAAa,uBAAb,cAA0C,KAAK,YAAY,sBAAsB,CAAC,CAG/E,CAAC;;;;;;;AAQJ,IAAa,oBAAb,cAAuC,KAAK,YAAY,mBAAmB,CAAC,CAIzE,CAAC;;;;;AAMJ,IAAa,iBAAb,cAAoC,KAAK,YAAY,gBAAgB,CAAC,CAKnE,CAAC;;;;;;;;;AAUJ,IAAa,6BAAb,cAAgD,KAAK,YAAY,4BAA4B,CAAC,CAK3F,CAAC;;;;;;AAOJ,IAAa,uBAAb,cAA0C,KAAK,YAAY,sBAAsB,CAAC,CAI/E,CAAC;;;;;;;;AASJ,IAAa,wBAAb,cAA2C,KAAK,YAAY,uBAAuB,CAAC,CAKjF,CAAC;AAQJ,IAAa,oBAAb,cAAuC,KAAK,YAAY,mBAAmB,CAAC,CAIzE,CAAC;;;;;;;;;;;;;;AAeJ,IAAa,qBAAb,cAAwC,KAAK,YAAY,oBAAoB,CAAC,CAI3E,CAAC"}
@@ -1,6 +1,4 @@
1
1
  import { ImageRef, SnapshotId } from "./Sandbox.mjs";
2
-
3
- //#region src/sandbox/SandboxImage.d.ts
4
2
  declare namespace SandboxImage_d_exports {
5
3
  export { auto, dockerfile, registry, snapshot };
6
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SandboxImage.d.mts","names":[],"sources":["../../src/sandbox/SandboxImage.ts"],"mappings":";;;;;;;;;;;;;;;AAkBA;;;;;AAEA;cAFa,IAAA,EAAM,QAAA;AAAA,cAEN,QAAA,GAAY,GAAA,aAAc,QAAA;AAAA,cAE1B,QAAA,GAAY,EAAA,EAAI,UAAA,cAAsB,QAAA;AAAA,cAGtC,UAAA,GAAc,QAAA,aAAmB,QAAA"}
1
+ {"version":3,"file":"SandboxImage.d.mts","names":[],"sources":["../../src/sandbox/SandboxImage.ts"],"mappings":";;;;;;;;;;;;;;;;;;;cAkBa,MAAM;cAEN,WAAQ,gBAAkB;cAE1B,WAAQ,IAAQ,wBAAsB;cAGtC,aAAU,qBAAuB"}
@@ -1,4 +1,4 @@
1
- import { n as __exportAll } from "../chunk-uyGKjUfl.mjs";
1
+ import { n as __exportAll } from "../rolldown-runtime-EAsCxrDo.mjs";
2
2
  import { ImageRef, SnapshotId } from "./Sandbox.mjs";
3
3
  //#region src/sandbox/SandboxImage.ts
4
4
  var SandboxImage_exports = /* @__PURE__ */ __exportAll({
@@ -1 +1 @@
1
- {"version":3,"file":"SandboxImage.mjs","names":[],"sources":["../../src/sandbox/SandboxImage.ts"],"sourcesContent":["import { ImageRef, SnapshotId } from \"./Sandbox.js\"\n\n/**\n * Ergonomic constructors for {@link ImageRef}. `ImageRef.*` tagged\n * constructors still exist (and are what pattern-matching code uses);\n * these helpers are what end users reach for at the call site.\n *\n * @example\n * ```ts\n * import * as Image from \"@effect-uai/core/SandboxImage\"\n *\n * Image.auto // provider's house image\n * Image.registry(\"python:3.12\") // OCI registry ref\n * Image.snapshot(\"ml-warm-1\") // restore captured state (gated)\n * Image.dockerfile(\"FROM ubuntu...\") // build custom (gated)\n * ```\n */\n\nexport const auto: ImageRef = ImageRef.Default()\n\nexport const registry = (ref: string): ImageRef => ImageRef.Registry({ ref })\n\nexport const snapshot = (id: SnapshotId | string): ImageRef =>\n ImageRef.Snapshot({ id: SnapshotId(id) })\n\nexport const dockerfile = (contents: string): ImageRef => ImageRef.Dockerfile({ contents })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAa,OAAiB,SAAS,SAAS;AAEhD,MAAa,YAAY,QAA0B,SAAS,SAAS,EAAE,KAAK,CAAC;AAE7E,MAAa,YAAY,OACvB,SAAS,SAAS,EAAE,IAAI,WAAW,GAAG,EAAE,CAAC;AAE3C,MAAa,cAAc,aAA+B,SAAS,WAAW,EAAE,UAAU,CAAC"}
1
+ {"version":3,"file":"SandboxImage.mjs","names":[],"sources":["../../src/sandbox/SandboxImage.ts"],"sourcesContent":["import { ImageRef, SnapshotId } from \"./Sandbox.js\"\n\n/**\n * Ergonomic constructors for {@link ImageRef}. `ImageRef.*` tagged\n * constructors still exist (and are what pattern-matching code uses);\n * these helpers are what end users reach for at the call site.\n *\n * @example\n * ```ts\n * import * as Image from \"@effect-uai/core/SandboxImage\"\n *\n * Image.auto // provider's house image\n * Image.registry(\"python:3.12\") // OCI registry ref\n * Image.snapshot(\"ml-warm-1\") // restore captured state (gated)\n * Image.dockerfile(\"FROM ubuntu...\") // build custom (gated)\n * ```\n */\n\nexport const auto: ImageRef = ImageRef.Default()\n\nexport const registry = (ref: string): ImageRef => ImageRef.Registry({ ref })\n\nexport const snapshot = (id: SnapshotId | string): ImageRef =>\n ImageRef.Snapshot({ id: SnapshotId(id) })\n\nexport const dockerfile = (contents: string): ImageRef => ImageRef.Dockerfile({ contents })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAa,OAAiB,SAAS,QAAQ;AAE/C,MAAa,YAAY,QAA0B,SAAS,SAAS,EAAE,IAAI,CAAC;AAE5E,MAAa,YAAY,OACvB,SAAS,SAAS,EAAE,IAAI,WAAW,EAAE,EAAE,CAAC;AAE1C,MAAa,cAAc,aAA+B,SAAS,WAAW,EAAE,SAAS,CAAC"}
@@ -1,6 +1,4 @@
1
1
  import { NetworkPolicy } from "./Sandbox.mjs";
2
-
3
- //#region src/sandbox/SandboxNetwork.d.ts
4
2
  declare namespace SandboxNetwork_d_exports {
5
3
  export { allow, allowCidrs, allowHosts, blocked, open };
6
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SandboxNetwork.d.mts","names":[],"sources":["../../src/sandbox/SandboxNetwork.ts"],"mappings":";;;;;;;;;;;;;;;;AAoBA;;;;;AAEA;;cAFa,IAAA,EAAM,aAAA;AAAA,cAEN,OAAA,EAAS,aAAA;AAAA,cAET,UAAA,MAAiB,KAAA,EAAO,aAAA,aAAwB,aAAA;AAAA,cAGhD,UAAA,MAAiB,KAAA,EAAO,aAAA,aAAwB,aAAA;AAAA,cAGhD,KAAA,GAAS,IAAA;EAAA,SACX,KAAA,GAAQ,aAAA;EAAA,SACR,KAAA,GAAQ,aAAA;AAAA,MACf,aAAA"}
1
+ {"version":3,"file":"SandboxNetwork.d.mts","names":[],"sources":["../../src/sandbox/SandboxNetwork.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;cAoBa,MAAM;cAEN,SAAS;cAET,gBAAU,OAAc,0BAAwB;cAGhD,gBAAU,OAAc,0BAAwB;cAGhD,QAAK;WACP,QAAQ;WACR,QAAQ;MACf"}
@@ -1,4 +1,4 @@
1
- import { n as __exportAll } from "../chunk-uyGKjUfl.mjs";
1
+ import { n as __exportAll } from "../rolldown-runtime-EAsCxrDo.mjs";
2
2
  import { NetworkPolicy } from "./Sandbox.mjs";
3
3
  //#region src/sandbox/SandboxNetwork.ts
4
4
  var SandboxNetwork_exports = /* @__PURE__ */ __exportAll({
@@ -1 +1 @@
1
- {"version":3,"file":"SandboxNetwork.mjs","names":[],"sources":["../../src/sandbox/SandboxNetwork.ts"],"sourcesContent":["import { NetworkPolicy } from \"./Sandbox.js\"\n\n/**\n * Ergonomic constructors for {@link NetworkPolicy}. The tagged\n * constructors under `Sandbox.NetworkPolicy.*` still exist (and are\n * what pattern-matching code uses); these helpers are what end users\n * reach for at the call site.\n *\n * @example\n * ```ts\n * import * as Network from \"@effect-uai/core/SandboxNetwork\"\n *\n * Network.open // provider defaults apply\n * Network.blocked // airgapped — no egress\n * Network.allowHosts(\"api.openai.com\", \"github.com\")\n * Network.allowCidrs(\"10.0.0.0/8\")\n * Network.allow({ hosts: [...], cidrs: [...] }) // combined allowlist\n * ```\n */\n\nexport const open: NetworkPolicy = NetworkPolicy.Open()\n\nexport const blocked: NetworkPolicy = NetworkPolicy.Blocked()\n\nexport const allowHosts = (...hosts: ReadonlyArray<string>): NetworkPolicy =>\n NetworkPolicy.Allowlist({ hosts })\n\nexport const allowCidrs = (...cidrs: ReadonlyArray<string>): NetworkPolicy =>\n NetworkPolicy.Allowlist({ cidrs })\n\nexport const allow = (opts: {\n readonly hosts?: ReadonlyArray<string>\n readonly cidrs?: ReadonlyArray<string>\n}): NetworkPolicy => NetworkPolicy.Allowlist(opts)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,OAAsB,cAAc,MAAM;AAEvD,MAAa,UAAyB,cAAc,SAAS;AAE7D,MAAa,cAAc,GAAG,UAC5B,cAAc,UAAU,EAAE,OAAO,CAAC;AAEpC,MAAa,cAAc,GAAG,UAC5B,cAAc,UAAU,EAAE,OAAO,CAAC;AAEpC,MAAa,SAAS,SAGD,cAAc,UAAU,KAAK"}
1
+ {"version":3,"file":"SandboxNetwork.mjs","names":[],"sources":["../../src/sandbox/SandboxNetwork.ts"],"sourcesContent":["import { NetworkPolicy } from \"./Sandbox.js\"\n\n/**\n * Ergonomic constructors for {@link NetworkPolicy}. The tagged\n * constructors under `Sandbox.NetworkPolicy.*` still exist (and are\n * what pattern-matching code uses); these helpers are what end users\n * reach for at the call site.\n *\n * @example\n * ```ts\n * import * as Network from \"@effect-uai/core/SandboxNetwork\"\n *\n * Network.open // provider defaults apply\n * Network.blocked // airgapped — no egress\n * Network.allowHosts(\"api.openai.com\", \"github.com\")\n * Network.allowCidrs(\"10.0.0.0/8\")\n * Network.allow({ hosts: [...], cidrs: [...] }) // combined allowlist\n * ```\n */\n\nexport const open: NetworkPolicy = NetworkPolicy.Open()\n\nexport const blocked: NetworkPolicy = NetworkPolicy.Blocked()\n\nexport const allowHosts = (...hosts: ReadonlyArray<string>): NetworkPolicy =>\n NetworkPolicy.Allowlist({ hosts })\n\nexport const allowCidrs = (...cidrs: ReadonlyArray<string>): NetworkPolicy =>\n NetworkPolicy.Allowlist({ cidrs })\n\nexport const allow = (opts: {\n readonly hosts?: ReadonlyArray<string>\n readonly cidrs?: ReadonlyArray<string>\n}): NetworkPolicy => NetworkPolicy.Allowlist(opts)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,OAAsB,cAAc,KAAK;AAEtD,MAAa,UAAyB,cAAc,QAAQ;AAE5D,MAAa,cAAc,GAAG,UAC5B,cAAc,UAAU,EAAE,MAAM,CAAC;AAEnC,MAAa,cAAc,GAAG,UAC5B,cAAc,UAAU,EAAE,MAAM,CAAC;AAEnC,MAAa,SAAS,SAGD,cAAc,UAAU,IAAI"}
@@ -1,8 +1,6 @@
1
- import { t as AiError } from "../AiError-Bf1pq4BB.mjs";
2
- import { n as AudioChunk, r as AudioFormat, t as AudioBlob } from "../Audio-CR7CSljJ.mjs";
1
+ import { t as AiError } from "../AiError-eLV9t1lU.mjs";
2
+ import { n as AudioChunk, r as AudioFormat, t as AudioBlob } from "../Audio-60lKKHxS.mjs";
3
3
  import { Context, Effect, Stream } from "effect";
4
-
5
- //#region src/speech-synthesizer/SpeechSynthesizer.d.ts
6
4
  declare namespace SpeechSynthesizer_d_exports {
7
5
  export { CommonStreamSynthesizeRequest, CommonSynthesizeDialogueRequest, CommonSynthesizeRequest, CustomPronunciation, DialogueTurn, MultiSpeakerTts, SpeechSynthesizer, SpeechSynthesizerService, TtsIncrementalText, streamSynthesis, streamSynthesisFrom, streamSynthesizeDialogue, synthesize, synthesizeDialogue };
8
6
  }
@@ -18,7 +16,8 @@ declare namespace SpeechSynthesizer_d_exports {
18
16
  * with `AiError.Unsupported` rather than silently degrading.
19
17
  */
20
18
  type CustomPronunciation = {
21
- readonly phrase: string; /** IPA notation, e.g. `"ænˈθrɒpɪk"`. */
19
+ readonly phrase: string;
20
+ /** IPA notation, e.g. `"ænˈθrɒpɪk"`. */
22
21
  readonly pronunciation: string;
23
22
  };
24
23
  /**
@@ -29,7 +28,8 @@ type CustomPronunciation = {
29
28
  * `voiceId`.
30
29
  */
31
30
  type CommonSynthesizeRequest = {
32
- readonly text: string; /** Model identifier. Each provider narrows. */
31
+ readonly text: string;
32
+ /** Model identifier. Each provider narrows. */
33
33
  readonly model: string;
34
34
  /**
35
35
  * Voice identifier. Per-provider request types narrow this to a
@@ -83,7 +83,8 @@ type CommonSynthesizeDialogueRequest = {
83
83
  readonly pronunciations?: ReadonlyArray<CustomPronunciation>;
84
84
  };
85
85
  type SpeechSynthesizerService = {
86
- /** One-shot. Full text in, full audio bytes out. Universally supported. */readonly synthesize: (request: CommonSynthesizeRequest) => Effect.Effect<AudioBlob, AiError>;
86
+ /** One-shot. Full text in, full audio bytes out. Universally supported. */
87
+ readonly synthesize: (request: CommonSynthesizeRequest) => Effect.Effect<AudioBlob, AiError>;
87
88
  /**
88
89
  * Full text in, audio chunks streamed out (chunked HTTP). Universally
89
90
  * supported across providers that offer any streaming TTS at all.
@@ -1 +1 @@
1
- {"version":3,"file":"SpeechSynthesizer.d.mts","names":[],"sources":["../../src/speech-synthesizer/SpeechSynthesizer.ts"],"mappings":";;;;;;;;;;;;;;;;;;;KAeY,mBAAA;EAAA,SACD,MAAA;WAEA,aAAA;AAAA;;;;AAHX;;;;KAaY,uBAAA;EAAA,SACD,IAAA,UADwB;EAAA,SAGxB,KAAA;EAQe;;;;;;EAAA,SADf,OAAA;EAAA,SACA,YAAA,GAAe,WAAA;EAAA,SACf,KAAA;EAAA,SACA,YAAA;EADA;;;;;;EAAA,SAQA,cAAA,GAAiB,aAAA,CAAc,mBAAA;AAAA;;;;;AAqB1C;;;;;KATY,6BAAA,GAAgC,IAAA,CAAK,uBAAA;;;;;;;;KASrC,YAAA;EAAA,SACD,OAAA;EAAA,SACA,IAAA;AAAA;;;;;;KAQC,+BAAA;EAAA,SACD,KAAA;EAAA,SACA,KAAA,EAAO,aAAA,CAAc,YAAA;EAAA,SACrB,YAAA,GAAe,WAAA;EAAA,SACf,YAAA;EAAA,SACA,cAAA,GAAiB,aAAA,CAAc,mBAAA;AAAA;AAAA,KAG9B,wBAAA;EAGC,oFADF,UAAA,GACP,OAAA,EAAS,uBAAA,KACN,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW,OAAA;EAAA;;;;EAAA,SAKrB,eAAA,GACP,OAAA,EAAS,uBAAA,KACN,MAAA,CAAO,MAAA,CAAO,UAAA,EAAY,OAAA;EAA1B;;;;;;;;;;EAAA,SAWI,mBAAA,SACP,MAAA,EAAQ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;;cAiB/D,qBAAkB,SACpB,oCACR,OAAO,OAAO,WAAW,SAAiB,oBAAoB;;;;cAUpD,2BAAwB,SAC1B,oCACR,OAAO,OAAO,YAAY,SAAiB,oBAAoB"}
@@ -1,4 +1,4 @@
1
- import { n as __exportAll } from "../chunk-uyGKjUfl.mjs";
1
+ import { n as __exportAll } from "../rolldown-runtime-EAsCxrDo.mjs";
2
2
  import { Context, Effect, Function, Stream } from "effect";
3
3
  //#region src/speech-synthesizer/SpeechSynthesizer.ts
4
4
  var SpeechSynthesizer_exports = /* @__PURE__ */ __exportAll({
@@ -1 +1 @@
1
- {"version":3,"file":"SpeechSynthesizer.mjs","names":[],"sources":["../../src/speech-synthesizer/SpeechSynthesizer.ts"],"sourcesContent":["import { Context, Effect, Function, Stream } from \"effect\"\nimport * as AiError from \"../domain/AiError.js\"\nimport type { AudioBlob, AudioChunk, AudioFormat } from \"../domain/Audio.js\"\n\n/**\n * Per-phrase pronunciation override. `pronunciation` is always IPA, the\n * universal phonetic interchange format. Adapters translate to the\n * provider's wire form (inline `/ipa/` token, SSML `<phoneme>`, or a\n * structured field), converting IPA to X-SAMPA internally where the wire\n * requires it (Google, Azure).\n *\n * Pronunciations are load-bearing (the configured word is mispronounced\n * if dropped), so a provider with no stateless IPA path fails the call\n * with `AiError.Unsupported` rather than silently degrading.\n */\nexport type CustomPronunciation = {\n readonly phrase: string\n /** IPA notation, e.g. `\"ænˈθrɒpɪk\"`. */\n readonly pronunciation: string\n}\n\n/**\n * Cross-provider synthesis request. Provider-specific extensions\n * (ElevenLabs `stability` / `similarity_boost`, Cartesia `emotion`,\n * MiniMax `vol` / `pitch`, Azure SSML style tags) live on each\n * provider's typed request which extends this and narrows `model` and\n * `voiceId`.\n */\nexport type CommonSynthesizeRequest = {\n readonly text: string\n /** Model identifier. Each provider narrows. */\n readonly model: string\n /**\n * Voice identifier. Per-provider request types narrow this to a\n * typed literal union of stock voices + `(string & {})` escape for\n * custom cloned voice IDs. Providers without custom-voice support\n * (OpenAI, Deepgram Aura, AWS Polly) narrow to the stock-only union.\n */\n readonly voiceId: string\n readonly outputFormat?: AudioFormat\n readonly speed?: number\n readonly languageCode?: string\n /**\n * IPA phoneme overrides for specific phrases. Adapters render them to\n * the provider's wire form (inline token, SSML `<phoneme>`, structured\n * field). Load-bearing: a provider with no stateless IPA path fails\n * the call with `AiError.Unsupported` rather than mispronouncing.\n */\n readonly pronunciations?: ReadonlyArray<CustomPronunciation>\n}\n\n/**\n * Incremental-synthesis request — text arrives as `Stream<string>`.\n * Gated by the `TtsIncrementalText` capability marker; only providers\n * that ship the marker can be used.\n *\n * Multi-context features (Cartesia `context_id`, ElevenLabs `multi-\n * stream-input`) are NOT exposed here — one logical utterance per\n * call. Provider extensions can expose `forkContext` for that.\n */\nexport type CommonStreamSynthesizeRequest = Omit<CommonSynthesizeRequest, \"text\">\n\n/**\n * One turn in a multi-speaker dialogue. Just a voice and its line; the\n * only in-tree dialogue endpoint (ElevenLabs `/v1/text-to-dialogue`)\n * accepts `{ voice_id, text }` per turn. Per-turn styling knobs\n * (Hume Octave-2 `styleDescription` / `speed`) are provider-specific\n * and belong on a provider-typed turn extension, not here.\n */\nexport type DialogueTurn = {\n readonly voiceId: string\n readonly text: string\n}\n\n/**\n * Cross-provider dialogue request. Same return type as `synthesize` —\n * one continuous `AudioBlob`. Per-turn timing metadata is not exposed\n * in the common shape (only Hume returns it natively).\n */\nexport type CommonSynthesizeDialogueRequest = {\n readonly model: string\n readonly turns: ReadonlyArray<DialogueTurn>\n readonly outputFormat?: AudioFormat\n readonly languageCode?: string\n readonly pronunciations?: ReadonlyArray<CustomPronunciation>\n}\n\nexport type SpeechSynthesizerService = {\n /** One-shot. Full text in, full audio bytes out. Universally supported. */\n readonly synthesize: (\n request: CommonSynthesizeRequest,\n ) => Effect.Effect<AudioBlob, AiError.AiError>\n /**\n * Full text in, audio chunks streamed out (chunked HTTP). Universally\n * supported across providers that offer any streaming TTS at all.\n */\n readonly streamSynthesis: (\n request: CommonSynthesizeRequest,\n ) => Stream.Stream<AudioChunk, AiError.AiError>\n /**\n * Incremental text in (as a Stream), audio chunks streamed out. The\n * underlying WS connection is acquired on first pull and released\n * when the output stream is finalized via `Stream.scoped`.\n *\n * Gated by the `TtsIncrementalText` capability marker on the top-\n * level helper — providers without WS-style incremental input don't\n * ship the marker, so calls fail at `Effect.provide` with a type\n * error.\n */\n readonly streamSynthesisFrom: <E, R>(\n textIn: Stream.Stream<string, E, R>,\n request: CommonStreamSynthesizeRequest,\n ) => Stream.Stream<AudioChunk, AiError.AiError | E, R>\n /**\n * One-shot multi-speaker dialogue. Turn array in, single `AudioBlob`\n * out. Providers without native dialogue support return\n * `AiError.Unsupported` and do NOT ship the `MultiSpeakerTts` marker\n * — calls via the top-level helper become a compile-time error.\n */\n readonly synthesizeDialogue: (\n request: CommonSynthesizeDialogueRequest,\n ) => Effect.Effect<AudioBlob, AiError.AiError>\n /**\n * Chunked-streaming variant of `synthesizeDialogue`. Same input,\n * audio chunks emitted as the wire delivers them. Providers that\n * synthesize the whole dialogue server-side may fall back to a\n * single-chunk wrap of the sync result.\n *\n * Gated by `MultiSpeakerTts` at the top-level helper.\n */\n readonly streamSynthesizeDialogue: (\n request: CommonSynthesizeDialogueRequest,\n ) => Stream.Stream<AudioChunk, AiError.AiError>\n}\n\nexport class SpeechSynthesizer extends Context.Service<\n SpeechSynthesizer,\n SpeechSynthesizerService\n>()(\"@betalyra/effect-uai/SpeechSynthesizer\") {}\n\n/**\n * Capability marker — provided by provider layers whose\n * `streamSynthesisFrom` is wired up at the wire level. OpenAI, Azure\n * (wire), and AWS Polly non-Generative do not ship it. Calling\n * `streamSynthesisFrom` while only one of those Layers is in scope\n * fails at `Effect.provide` with a type error.\n *\n * Phantom — the value is `void`; providers register with\n * `Layer.succeed(TtsIncrementalText, undefined)`.\n */\nexport class TtsIncrementalText extends Context.Service<TtsIncrementalText, void>()(\n \"@betalyra/effect-uai/capability/TtsIncrementalText\",\n) {}\n\n/**\n * Capability marker for multi-speaker dialogue. Shipped by provider\n * Layers whose `synthesizeDialogue` is wired to a native multi-speaker\n * endpoint (ElevenLabs `/v1/text-to-dialogue`, Hume `/v0/tts` with\n * `utterances[]`, Google Cloud TTS Gemini TTS `multiSpeakerMarkup`).\n * Other providers leave the marker unregistered so the top-level\n * `synthesizeDialogue` / `streamSynthesizeDialogue` helpers fail to\n * satisfy R against those Layers — compile-time error.\n */\nexport class MultiSpeakerTts extends Context.Service<MultiSpeakerTts, void>()(\n \"@betalyra/effect-uai/capability/MultiSpeakerTts\",\n) {}\n\n/** One-shot synthesis. */\nexport const synthesize = (\n request: CommonSynthesizeRequest,\n): Effect.Effect<AudioBlob, AiError.AiError, SpeechSynthesizer> =>\n Effect.flatMap(SpeechSynthesizer, (s) => s.synthesize(request))\n\n/** Full text in, audio chunks out. */\nexport const streamSynthesis = (\n request: CommonSynthesizeRequest,\n): Stream.Stream<AudioChunk, AiError.AiError, SpeechSynthesizer> =>\n Stream.unwrap(Effect.map(SpeechSynthesizer, (s) => s.streamSynthesis(request)))\n\n/**\n * Incremental synthesis. Dual-arity: pipeable (data-last) and direct\n * (data-first). Requires `TtsIncrementalText` in R — providers without\n * incremental-text-in support are a type error at provide time.\n *\n * @example\n * ```ts\n * const audio = LanguageModel.streamTurn(turnReq).pipe(\n * Stream.filterMap(Turn.toTextDelta),\n * SpeechSynthesizer.streamSynthesisFrom(synthReq),\n * )\n * ```\n */\nexport const streamSynthesisFrom: {\n (\n request: CommonStreamSynthesizeRequest,\n ): <E, R>(\n textIn: Stream.Stream<string, E, R>,\n ) => Stream.Stream<AudioChunk, AiError.AiError | E, R | SpeechSynthesizer | TtsIncrementalText>\n <E, R>(\n textIn: Stream.Stream<string, E, R>,\n request: CommonStreamSynthesizeRequest,\n ): Stream.Stream<AudioChunk, AiError.AiError | E, R | SpeechSynthesizer | TtsIncrementalText>\n} = Function.dual(\n 2,\n <E, R>(textIn: Stream.Stream<string, E, R>, request: CommonStreamSynthesizeRequest) =>\n Stream.unwrap(\n Effect.gen(function* () {\n const s = yield* SpeechSynthesizer\n yield* TtsIncrementalText\n return s.streamSynthesisFrom(textIn, request)\n }),\n ),\n)\n\n/**\n * One-shot multi-speaker dialogue. Requires `MultiSpeakerTts` in R —\n * providers without dialogue support are a compile-time error.\n */\nexport const synthesizeDialogue = (\n request: CommonSynthesizeDialogueRequest,\n): Effect.Effect<AudioBlob, AiError.AiError, SpeechSynthesizer | MultiSpeakerTts> =>\n Effect.gen(function* () {\n const s = yield* SpeechSynthesizer\n yield* MultiSpeakerTts\n return yield* s.synthesizeDialogue(request)\n })\n\n/**\n * Chunked-streaming variant. Same R requirement as `synthesizeDialogue`.\n */\nexport const streamSynthesizeDialogue = (\n request: CommonSynthesizeDialogueRequest,\n): Stream.Stream<AudioChunk, AiError.AiError, SpeechSynthesizer | MultiSpeakerTts> =>\n Stream.unwrap(\n Effect.gen(function* () {\n const s = yield* SpeechSynthesizer\n yield* MultiSpeakerTts\n return s.streamSynthesizeDialogue(request)\n }),\n )\n"],"mappings":";;;;;;;;;;;;;AAuIA,IAAa,oBAAb,cAAuC,QAAQ,SAG5C,CAAC,yCAAyC,CAAC;;;;;;;;;;;AAY9C,IAAa,qBAAb,cAAwC,QAAQ,SAAmC,CACjF,qDACD,CAAC;;;;;;;;;;AAWF,IAAa,kBAAb,cAAqC,QAAQ,SAAgC,CAC3E,kDACD,CAAC;;AAGF,MAAa,cACX,YAEA,OAAO,QAAQ,oBAAoB,MAAM,EAAE,WAAW,QAAQ,CAAC;;AAGjE,MAAa,mBACX,YAEA,OAAO,OAAO,OAAO,IAAI,oBAAoB,MAAM,EAAE,gBAAgB,QAAQ,CAAC,CAAC;;;;;;;;;;;;;;AAejF,MAAa,sBAUT,SAAS,KACX,IACO,QAAqC,YAC1C,OAAO,OACL,OAAO,IAAI,aAAa;CACtB,MAAM,IAAI,OAAO;AACjB,QAAO;AACP,QAAO,EAAE,oBAAoB,QAAQ,QAAQ;EAC7C,CACH,CACJ;;;;;AAMD,MAAa,sBACX,YAEA,OAAO,IAAI,aAAa;CACtB,MAAM,IAAI,OAAO;AACjB,QAAO;AACP,QAAO,OAAO,EAAE,mBAAmB,QAAQ;EAC3C;;;;AAKJ,MAAa,4BACX,YAEA,OAAO,OACL,OAAO,IAAI,aAAa;CACtB,MAAM,IAAI,OAAO;AACjB,QAAO;AACP,QAAO,EAAE,yBAAyB,QAAQ;EAC1C,CACH"}
1
+ {"version":3,"file":"SpeechSynthesizer.mjs","names":[],"sources":["../../src/speech-synthesizer/SpeechSynthesizer.ts"],"sourcesContent":["import { Context, Effect, Function, Stream } from \"effect\"\nimport * as AiError from \"../domain/AiError.js\"\nimport type { AudioBlob, AudioChunk, AudioFormat } from \"../domain/Audio.js\"\n\n/**\n * Per-phrase pronunciation override. `pronunciation` is always IPA, the\n * universal phonetic interchange format. Adapters translate to the\n * provider's wire form (inline `/ipa/` token, SSML `<phoneme>`, or a\n * structured field), converting IPA to X-SAMPA internally where the wire\n * requires it (Google, Azure).\n *\n * Pronunciations are load-bearing (the configured word is mispronounced\n * if dropped), so a provider with no stateless IPA path fails the call\n * with `AiError.Unsupported` rather than silently degrading.\n */\nexport type CustomPronunciation = {\n readonly phrase: string\n /** IPA notation, e.g. `\"ænˈθrɒpɪk\"`. */\n readonly pronunciation: string\n}\n\n/**\n * Cross-provider synthesis request. Provider-specific extensions\n * (ElevenLabs `stability` / `similarity_boost`, Cartesia `emotion`,\n * MiniMax `vol` / `pitch`, Azure SSML style tags) live on each\n * provider's typed request which extends this and narrows `model` and\n * `voiceId`.\n */\nexport type CommonSynthesizeRequest = {\n readonly text: string\n /** Model identifier. Each provider narrows. */\n readonly model: string\n /**\n * Voice identifier. Per-provider request types narrow this to a\n * typed literal union of stock voices + `(string & {})` escape for\n * custom cloned voice IDs. Providers without custom-voice support\n * (OpenAI, Deepgram Aura, AWS Polly) narrow to the stock-only union.\n */\n readonly voiceId: string\n readonly outputFormat?: AudioFormat\n readonly speed?: number\n readonly languageCode?: string\n /**\n * IPA phoneme overrides for specific phrases. Adapters render them to\n * the provider's wire form (inline token, SSML `<phoneme>`, structured\n * field). Load-bearing: a provider with no stateless IPA path fails\n * the call with `AiError.Unsupported` rather than mispronouncing.\n */\n readonly pronunciations?: ReadonlyArray<CustomPronunciation>\n}\n\n/**\n * Incremental-synthesis request — text arrives as `Stream<string>`.\n * Gated by the `TtsIncrementalText` capability marker; only providers\n * that ship the marker can be used.\n *\n * Multi-context features (Cartesia `context_id`, ElevenLabs `multi-\n * stream-input`) are NOT exposed here — one logical utterance per\n * call. Provider extensions can expose `forkContext` for that.\n */\nexport type CommonStreamSynthesizeRequest = Omit<CommonSynthesizeRequest, \"text\">\n\n/**\n * One turn in a multi-speaker dialogue. Just a voice and its line; the\n * only in-tree dialogue endpoint (ElevenLabs `/v1/text-to-dialogue`)\n * accepts `{ voice_id, text }` per turn. Per-turn styling knobs\n * (Hume Octave-2 `styleDescription` / `speed`) are provider-specific\n * and belong on a provider-typed turn extension, not here.\n */\nexport type DialogueTurn = {\n readonly voiceId: string\n readonly text: string\n}\n\n/**\n * Cross-provider dialogue request. Same return type as `synthesize` —\n * one continuous `AudioBlob`. Per-turn timing metadata is not exposed\n * in the common shape (only Hume returns it natively).\n */\nexport type CommonSynthesizeDialogueRequest = {\n readonly model: string\n readonly turns: ReadonlyArray<DialogueTurn>\n readonly outputFormat?: AudioFormat\n readonly languageCode?: string\n readonly pronunciations?: ReadonlyArray<CustomPronunciation>\n}\n\nexport type SpeechSynthesizerService = {\n /** One-shot. Full text in, full audio bytes out. Universally supported. */\n readonly synthesize: (\n request: CommonSynthesizeRequest,\n ) => Effect.Effect<AudioBlob, AiError.AiError>\n /**\n * Full text in, audio chunks streamed out (chunked HTTP). Universally\n * supported across providers that offer any streaming TTS at all.\n */\n readonly streamSynthesis: (\n request: CommonSynthesizeRequest,\n ) => Stream.Stream<AudioChunk, AiError.AiError>\n /**\n * Incremental text in (as a Stream), audio chunks streamed out. The\n * underlying WS connection is acquired on first pull and released\n * when the output stream is finalized via `Stream.scoped`.\n *\n * Gated by the `TtsIncrementalText` capability marker on the top-\n * level helper — providers without WS-style incremental input don't\n * ship the marker, so calls fail at `Effect.provide` with a type\n * error.\n */\n readonly streamSynthesisFrom: <E, R>(\n textIn: Stream.Stream<string, E, R>,\n request: CommonStreamSynthesizeRequest,\n ) => Stream.Stream<AudioChunk, AiError.AiError | E, R>\n /**\n * One-shot multi-speaker dialogue. Turn array in, single `AudioBlob`\n * out. Providers without native dialogue support return\n * `AiError.Unsupported` and do NOT ship the `MultiSpeakerTts` marker\n * — calls via the top-level helper become a compile-time error.\n */\n readonly synthesizeDialogue: (\n request: CommonSynthesizeDialogueRequest,\n ) => Effect.Effect<AudioBlob, AiError.AiError>\n /**\n * Chunked-streaming variant of `synthesizeDialogue`. Same input,\n * audio chunks emitted as the wire delivers them. Providers that\n * synthesize the whole dialogue server-side may fall back to a\n * single-chunk wrap of the sync result.\n *\n * Gated by `MultiSpeakerTts` at the top-level helper.\n */\n readonly streamSynthesizeDialogue: (\n request: CommonSynthesizeDialogueRequest,\n ) => Stream.Stream<AudioChunk, AiError.AiError>\n}\n\nexport class SpeechSynthesizer extends Context.Service<\n SpeechSynthesizer,\n SpeechSynthesizerService\n>()(\"@betalyra/effect-uai/SpeechSynthesizer\") {}\n\n/**\n * Capability marker — provided by provider layers whose\n * `streamSynthesisFrom` is wired up at the wire level. OpenAI, Azure\n * (wire), and AWS Polly non-Generative do not ship it. Calling\n * `streamSynthesisFrom` while only one of those Layers is in scope\n * fails at `Effect.provide` with a type error.\n *\n * Phantom — the value is `void`; providers register with\n * `Layer.succeed(TtsIncrementalText, undefined)`.\n */\nexport class TtsIncrementalText extends Context.Service<TtsIncrementalText, void>()(\n \"@betalyra/effect-uai/capability/TtsIncrementalText\",\n) {}\n\n/**\n * Capability marker for multi-speaker dialogue. Shipped by provider\n * Layers whose `synthesizeDialogue` is wired to a native multi-speaker\n * endpoint (ElevenLabs `/v1/text-to-dialogue`, Hume `/v0/tts` with\n * `utterances[]`, Google Cloud TTS Gemini TTS `multiSpeakerMarkup`).\n * Other providers leave the marker unregistered so the top-level\n * `synthesizeDialogue` / `streamSynthesizeDialogue` helpers fail to\n * satisfy R against those Layers — compile-time error.\n */\nexport class MultiSpeakerTts extends Context.Service<MultiSpeakerTts, void>()(\n \"@betalyra/effect-uai/capability/MultiSpeakerTts\",\n) {}\n\n/** One-shot synthesis. */\nexport const synthesize = (\n request: CommonSynthesizeRequest,\n): Effect.Effect<AudioBlob, AiError.AiError, SpeechSynthesizer> =>\n Effect.flatMap(SpeechSynthesizer, (s) => s.synthesize(request))\n\n/** Full text in, audio chunks out. */\nexport const streamSynthesis = (\n request: CommonSynthesizeRequest,\n): Stream.Stream<AudioChunk, AiError.AiError, SpeechSynthesizer> =>\n Stream.unwrap(Effect.map(SpeechSynthesizer, (s) => s.streamSynthesis(request)))\n\n/**\n * Incremental synthesis. Dual-arity: pipeable (data-last) and direct\n * (data-first). Requires `TtsIncrementalText` in R — providers without\n * incremental-text-in support are a type error at provide time.\n *\n * @example\n * ```ts\n * const audio = LanguageModel.streamTurn(turnReq).pipe(\n * Stream.filterMap(Turn.toTextDelta),\n * SpeechSynthesizer.streamSynthesisFrom(synthReq),\n * )\n * ```\n */\nexport const streamSynthesisFrom: {\n (\n request: CommonStreamSynthesizeRequest,\n ): <E, R>(\n textIn: Stream.Stream<string, E, R>,\n ) => Stream.Stream<AudioChunk, AiError.AiError | E, R | SpeechSynthesizer | TtsIncrementalText>\n <E, R>(\n textIn: Stream.Stream<string, E, R>,\n request: CommonStreamSynthesizeRequest,\n ): Stream.Stream<AudioChunk, AiError.AiError | E, R | SpeechSynthesizer | TtsIncrementalText>\n} = Function.dual(\n 2,\n <E, R>(textIn: Stream.Stream<string, E, R>, request: CommonStreamSynthesizeRequest) =>\n Stream.unwrap(\n Effect.gen(function* () {\n const s = yield* SpeechSynthesizer\n yield* TtsIncrementalText\n return s.streamSynthesisFrom(textIn, request)\n }),\n ),\n)\n\n/**\n * One-shot multi-speaker dialogue. Requires `MultiSpeakerTts` in R —\n * providers without dialogue support are a compile-time error.\n */\nexport const synthesizeDialogue = (\n request: CommonSynthesizeDialogueRequest,\n): Effect.Effect<AudioBlob, AiError.AiError, SpeechSynthesizer | MultiSpeakerTts> =>\n Effect.gen(function* () {\n const s = yield* SpeechSynthesizer\n yield* MultiSpeakerTts\n return yield* s.synthesizeDialogue(request)\n })\n\n/**\n * Chunked-streaming variant. Same R requirement as `synthesizeDialogue`.\n */\nexport const streamSynthesizeDialogue = (\n request: CommonSynthesizeDialogueRequest,\n): Stream.Stream<AudioChunk, AiError.AiError, SpeechSynthesizer | MultiSpeakerTts> =>\n Stream.unwrap(\n Effect.gen(function* () {\n const s = yield* SpeechSynthesizer\n yield* MultiSpeakerTts\n return s.streamSynthesizeDialogue(request)\n }),\n )\n"],"mappings":";;;;;;;;;;;;;AAuIA,IAAa,oBAAb,cAAuC,QAAQ,QAG7C,CAAC,CAAC,wCAAwC,CAAC,CAAC,CAAC;;;;;;;;;;;AAY/C,IAAa,qBAAb,cAAwC,QAAQ,QAAkC,CAAC,CACjF,oDACF,CAAC,CAAC,CAAC;;;;;;;;;;AAWH,IAAa,kBAAb,cAAqC,QAAQ,QAA+B,CAAC,CAC3E,iDACF,CAAC,CAAC,CAAC;;AAGH,MAAa,cACX,YAEA,OAAO,QAAQ,oBAAoB,MAAM,EAAE,WAAW,OAAO,CAAC;;AAGhE,MAAa,mBACX,YAEA,OAAO,OAAO,OAAO,IAAI,oBAAoB,MAAM,EAAE,gBAAgB,OAAO,CAAC,CAAC;;;;;;;;;;;;;;AAehF,MAAa,sBAUT,SAAS,KACX,IACO,QAAqC,YAC1C,OAAO,OACL,OAAO,IAAI,aAAa;CACtB,MAAM,IAAI,OAAO;CACjB,OAAO;CACP,OAAO,EAAE,oBAAoB,QAAQ,OAAO;AAC9C,CAAC,CACH,CACJ;;;;;AAMA,MAAa,sBACX,YAEA,OAAO,IAAI,aAAa;CACtB,MAAM,IAAI,OAAO;CACjB,OAAO;CACP,OAAO,OAAO,EAAE,mBAAmB,OAAO;AAC5C,CAAC;;;;AAKH,MAAa,4BACX,YAEA,OAAO,OACL,OAAO,IAAI,aAAa;CACtB,MAAM,IAAI,OAAO;CACjB,OAAO;CACP,OAAO,EAAE,yBAAyB,OAAO;AAC3C,CAAC,CACH"}
@@ -1 +1 @@
1
- export { };
1
+ export {}
@@ -1,5 +1,7 @@
1
1
  import { streamSynthesis, streamSynthesisFrom, streamSynthesizeDialogue, synthesize, synthesizeDialogue } from "./SpeechSynthesizer.mjs";
2
- import { c as it, n as globalExpect, o as describe, t as import_dist } from "../dist-CcRV3-A5.mjs";
2
+ import { m as it, o as describe } from "../utils-CiH_DjFW.mjs";
3
+ import { n as globalExpect } from "../test.DNmyFkvJ-YPzDR0Co.mjs";
4
+ import { t as import_dist } from "../dist-BaenoU1A.mjs";
3
5
  import { layer, layerWithoutIncremental, layerWithoutMultiSpeaker } from "../testing/MockSpeechSynthesizer.mjs";
4
6
  import { Duration, Effect, Stream } from "effect";
5
7
  //#region src/speech-synthesizer/SpeechSynthesizer.test.ts
@@ -43,7 +45,8 @@ describe("SpeechSynthesizer.streamSynthesis", () => {
43
45
  model: "mock-tts",
44
46
  voiceId: "stock-voice"
45
47
  }));
46
- globalExpect((await Effect.runPromise(program.pipe(Effect.provide(mock.layer)))).map((c) => Array.from(c.bytes))).toEqual([
48
+ const out = await Effect.runPromise(program.pipe(Effect.provide(mock.layer)));
49
+ globalExpect(out.map((c) => Array.from(c.bytes))).toEqual([
47
50
  [1],
48
51
  [2],
49
52
  [3]
@@ -56,31 +59,36 @@ describe("SpeechSynthesizer capability marker (compile-time)", () => {
56
59
  voiceId: "v"
57
60
  };
58
61
  it("requires `TtsIncrementalText` on the R channel of streamSynthesisFrom", () => {
59
- (0, import_dist.expectTypeOf)(Stream.fromIterable(["a"]).pipe(streamSynthesisFrom(ssfReq))).toEqualTypeOf();
62
+ const audio = Stream.fromIterable(["a"]).pipe(streamSynthesisFrom(ssfReq));
63
+ (0, import_dist.expectTypeOf)(audio).toEqualTypeOf();
60
64
  });
61
65
  it("does NOT require `TtsIncrementalText` for sync `synthesize`", () => {
62
- (0, import_dist.expectTypeOf)(synthesize({
66
+ const eff = synthesize({
63
67
  text: "hi",
64
68
  model: "m",
65
69
  voiceId: "v"
66
- })).toEqualTypeOf();
70
+ });
71
+ (0, import_dist.expectTypeOf)(eff).toEqualTypeOf();
67
72
  });
68
73
  it("does NOT require `TtsIncrementalText` for full-text `streamSynthesis`", () => {
69
- (0, import_dist.expectTypeOf)(streamSynthesis({
74
+ const audio = streamSynthesis({
70
75
  text: "hi",
71
76
  model: "m",
72
77
  voiceId: "v"
73
- })).toEqualTypeOf();
78
+ });
79
+ (0, import_dist.expectTypeOf)(audio).toEqualTypeOf();
74
80
  });
75
81
  it("a layer without the marker leaves `TtsIncrementalText` unsatisfied in R", () => {
76
82
  const noMarker = layerWithoutIncremental({});
77
83
  const audio = Stream.fromIterable(["a"]).pipe(streamSynthesisFrom(ssfReq));
78
- (0, import_dist.expectTypeOf)(Stream.runDrain(audio).pipe(Effect.provide(noMarker.layer))).toEqualTypeOf();
84
+ const program = Stream.runDrain(audio).pipe(Effect.provide(noMarker.layer));
85
+ (0, import_dist.expectTypeOf)(program).toEqualTypeOf();
79
86
  });
80
87
  it("a full layer (with marker) clears R to never", () => {
81
88
  const fullMock = layer({ streamSynthesisFromChunks: [[]] });
82
89
  const audio = Stream.fromIterable(["a"]).pipe(streamSynthesisFrom(ssfReq));
83
- (0, import_dist.expectTypeOf)(Stream.runDrain(audio).pipe(Effect.provide(fullMock.layer))).toEqualTypeOf();
90
+ const program = Stream.runDrain(audio).pipe(Effect.provide(fullMock.layer));
91
+ (0, import_dist.expectTypeOf)(program).toEqualTypeOf();
84
92
  });
85
93
  });
86
94
  describe("SpeechSynthesizer.synthesizeDialogue", () => {
@@ -96,7 +104,8 @@ describe("SpeechSynthesizer.synthesizeDialogue", () => {
96
104
  };
97
105
  it("returns the scripted AudioBlob", async () => {
98
106
  const mock = layer({ dialogueBlobs: [blob] });
99
- globalExpect((await Effect.runPromise(synthesizeDialogue(dialogueReq).pipe(Effect.provide(mock.layer)))).bytes).toEqual(blob.bytes);
107
+ const result = await Effect.runPromise(synthesizeDialogue(dialogueReq).pipe(Effect.provide(mock.layer)));
108
+ globalExpect(result.bytes).toEqual(blob.bytes);
100
109
  });
101
110
  it("records the request on the synthesizeDialogue call channel", async () => {
102
111
  const mock = layer({ dialogueBlobs: [blob] });
@@ -111,7 +120,8 @@ describe("SpeechSynthesizer.synthesizeDialogue", () => {
111
120
  });
112
121
  it("emits scripted chunks for streamSynthesizeDialogue", async () => {
113
122
  const mock = layer({ streamSynthesizeDialogueChunks: [[chunk(7), chunk(8)]] });
114
- globalExpect((await Effect.runPromise(Stream.runCollect(streamSynthesizeDialogue(dialogueReq)).pipe(Effect.provide(mock.layer)))).map((c) => Array.from(c.bytes))).toEqual([[7], [8]]);
123
+ const out = await Effect.runPromise(Stream.runCollect(streamSynthesizeDialogue(dialogueReq)).pipe(Effect.provide(mock.layer)));
124
+ globalExpect(out.map((c) => Array.from(c.bytes))).toEqual([[7], [8]]);
115
125
  });
116
126
  });
117
127
  describe("MultiSpeakerTts capability marker (compile-time)", () => {
@@ -123,18 +133,22 @@ describe("MultiSpeakerTts capability marker (compile-time)", () => {
123
133
  }]
124
134
  };
125
135
  it("requires `MultiSpeakerTts` on the R channel of synthesizeDialogue", () => {
126
- (0, import_dist.expectTypeOf)(synthesizeDialogue(dialogueReq)).toEqualTypeOf();
136
+ const eff = synthesizeDialogue(dialogueReq);
137
+ (0, import_dist.expectTypeOf)(eff).toEqualTypeOf();
127
138
  });
128
139
  it("requires `MultiSpeakerTts` on the R channel of streamSynthesizeDialogue", () => {
129
- (0, import_dist.expectTypeOf)(streamSynthesizeDialogue(dialogueReq)).toEqualTypeOf();
140
+ const s = streamSynthesizeDialogue(dialogueReq);
141
+ (0, import_dist.expectTypeOf)(s).toEqualTypeOf();
130
142
  });
131
143
  it("a layer without the marker leaves `MultiSpeakerTts` unsatisfied in R", () => {
132
144
  const noMarker = layerWithoutMultiSpeaker({});
133
- (0, import_dist.expectTypeOf)(synthesizeDialogue(dialogueReq).pipe(Effect.provide(noMarker.layer))).toEqualTypeOf();
145
+ const program = synthesizeDialogue(dialogueReq).pipe(Effect.provide(noMarker.layer));
146
+ (0, import_dist.expectTypeOf)(program).toEqualTypeOf();
134
147
  });
135
148
  it("a full layer (with marker) clears R to never", () => {
136
149
  const fullMock = layer({ dialogueBlobs: [blob] });
137
- (0, import_dist.expectTypeOf)(synthesizeDialogue(dialogueReq).pipe(Effect.provide(fullMock.layer))).toEqualTypeOf();
150
+ const program = synthesizeDialogue(dialogueReq).pipe(Effect.provide(fullMock.layer));
151
+ (0, import_dist.expectTypeOf)(program).toEqualTypeOf();
138
152
  });
139
153
  });
140
154
  describe("SpeechSynthesizer.streamSynthesisFrom", () => {
@@ -145,7 +159,8 @@ describe("SpeechSynthesizer.streamSynthesisFrom", () => {
145
159
  it("pipes an LLM-style text stream into audio chunks", async () => {
146
160
  const mock = layer({ streamSynthesisFromChunks: [[chunk(10), chunk(20)]] });
147
161
  const audio = Stream.fromIterable(["Hello, ", "world."]).pipe(streamSynthesisFrom(ssfReq));
148
- globalExpect((await Effect.runPromise(Stream.runCollect(audio).pipe(Effect.provide(mock.layer)))).map((c) => Array.from(c.bytes))).toEqual([[10], [20]]);
162
+ const out = await Effect.runPromise(Stream.runCollect(audio).pipe(Effect.provide(mock.layer)));
163
+ globalExpect(out.map((c) => Array.from(c.bytes))).toEqual([[10], [20]]);
149
164
  });
150
165
  it("records the request on the streamSynthesisFrom call channel", async () => {
151
166
  const mock = layer({ streamSynthesisFromChunks: [[chunk(42)]] });
@@ -1 +1 @@
1
- {"version":3,"file":"SpeechSynthesizer.test.mjs","names":["MockSpeechSynthesizer.layer","SpeechSynthesizer.synthesize","SpeechSynthesizer.streamSynthesis","SpeechSynthesizer.streamSynthesisFrom","MockSpeechSynthesizer.layerWithoutIncremental","SpeechSynthesizer.synthesizeDialogue","SpeechSynthesizer.streamSynthesizeDialogue","MockSpeechSynthesizer.layerWithoutMultiSpeaker"],"sources":["../../src/speech-synthesizer/SpeechSynthesizer.test.ts"],"sourcesContent":["import { Duration, Effect, Stream } from \"effect\"\nimport { describe, expect, expectTypeOf, it } from \"vitest\"\nimport type * as AiError from \"../domain/AiError.js\"\nimport type { AudioBlob, AudioChunk, AudioFormat } from \"../domain/Audio.js\"\nimport * as MockSpeechSynthesizer from \"../testing/MockSpeechSynthesizer.js\"\nimport * as SpeechSynthesizer from \"./SpeechSynthesizer.js\"\n\nconst pcmFormat: AudioFormat = {\n container: \"raw\",\n encoding: \"pcm_s16le\",\n sampleRate: 24000,\n}\n\nconst blob: AudioBlob = {\n format: pcmFormat,\n bytes: new Uint8Array([0xde, 0xad, 0xbe, 0xef]),\n duration: Duration.millis(500),\n}\n\nconst chunk = (n: number): AudioChunk => ({ bytes: new Uint8Array([n]) })\n\ndescribe(\"SpeechSynthesizer.synthesize\", () => {\n it(\"returns the scripted AudioBlob\", async () => {\n const mock = MockSpeechSynthesizer.layer({ blobs: [blob] })\n const program = SpeechSynthesizer.synthesize({\n text: \"hi\",\n model: \"mock-tts\",\n voiceId: \"stock-voice\",\n })\n const result = await Effect.runPromise(program.pipe(Effect.provide(mock.layer)))\n expect(result.bytes).toEqual(blob.bytes)\n expect(result.duration).toEqual(Duration.millis(500))\n })\n})\n\ndescribe(\"SpeechSynthesizer.streamSynthesis\", () => {\n it(\"emits scripted chunks for full-text-in streaming\", async () => {\n const mock = MockSpeechSynthesizer.layer({\n streamSynthesisChunks: [[chunk(1), chunk(2), chunk(3)]],\n })\n const program = Stream.runCollect(\n SpeechSynthesizer.streamSynthesis({\n text: \"hi\",\n model: \"mock-tts\",\n voiceId: \"stock-voice\",\n }),\n )\n const out = await Effect.runPromise(program.pipe(Effect.provide(mock.layer)))\n expect(out.map((c) => Array.from(c.bytes))).toEqual([[1], [2], [3]])\n })\n})\n\ndescribe(\"SpeechSynthesizer capability marker (compile-time)\", () => {\n const ssfReq: SpeechSynthesizer.CommonStreamSynthesizeRequest = {\n model: \"mock-tts\",\n voiceId: \"v\",\n }\n\n it(\"requires `TtsIncrementalText` on the R channel of streamSynthesisFrom\", () => {\n const tokens: Stream.Stream<string> = Stream.fromIterable([\"a\"])\n const audio = tokens.pipe(SpeechSynthesizer.streamSynthesisFrom(ssfReq))\n expectTypeOf(audio).toEqualTypeOf<\n Stream.Stream<\n AudioChunk,\n AiError.AiError,\n SpeechSynthesizer.SpeechSynthesizer | SpeechSynthesizer.TtsIncrementalText\n >\n >()\n })\n\n it(\"does NOT require `TtsIncrementalText` for sync `synthesize`\", () => {\n const eff = SpeechSynthesizer.synthesize({ text: \"hi\", model: \"m\", voiceId: \"v\" })\n expectTypeOf(eff).toEqualTypeOf<\n Effect.Effect<AudioBlob, AiError.AiError, SpeechSynthesizer.SpeechSynthesizer>\n >()\n })\n\n it(\"does NOT require `TtsIncrementalText` for full-text `streamSynthesis`\", () => {\n const audio = SpeechSynthesizer.streamSynthesis({ text: \"hi\", model: \"m\", voiceId: \"v\" })\n expectTypeOf(audio).toEqualTypeOf<\n Stream.Stream<AudioChunk, AiError.AiError, SpeechSynthesizer.SpeechSynthesizer>\n >()\n })\n\n it(\"a layer without the marker leaves `TtsIncrementalText` unsatisfied in R\", () => {\n const noMarker = MockSpeechSynthesizer.layerWithoutIncremental({})\n const tokens: Stream.Stream<string> = Stream.fromIterable([\"a\"])\n const audio = tokens.pipe(SpeechSynthesizer.streamSynthesisFrom(ssfReq))\n const program = Stream.runDrain(audio).pipe(Effect.provide(noMarker.layer))\n // `SpeechSynthesizer` is provided by the layer; `TtsIncrementalText` is not,\n // so it remains in R — calling `Effect.runPromise(program)` would be a type\n // error because runPromise requires `R = never`.\n expectTypeOf(program).toEqualTypeOf<\n Effect.Effect<void, AiError.AiError, SpeechSynthesizer.TtsIncrementalText>\n >()\n })\n\n it(\"a full layer (with marker) clears R to never\", () => {\n const fullMock = MockSpeechSynthesizer.layer({\n streamSynthesisFromChunks: [[]],\n })\n const tokens: Stream.Stream<string> = Stream.fromIterable([\"a\"])\n const audio = tokens.pipe(SpeechSynthesizer.streamSynthesisFrom(ssfReq))\n const program = Stream.runDrain(audio).pipe(Effect.provide(fullMock.layer))\n expectTypeOf(program).toEqualTypeOf<Effect.Effect<void, AiError.AiError, never>>()\n })\n})\n\ndescribe(\"SpeechSynthesizer.synthesizeDialogue\", () => {\n const dialogueReq: SpeechSynthesizer.CommonSynthesizeDialogueRequest = {\n model: \"mock-tts\",\n turns: [\n { voiceId: \"voice-a\", text: \"Hi\" },\n { voiceId: \"voice-b\", text: \"Hello\" },\n ],\n }\n\n it(\"returns the scripted AudioBlob\", async () => {\n const mock = MockSpeechSynthesizer.layer({ dialogueBlobs: [blob] })\n const result = await Effect.runPromise(\n SpeechSynthesizer.synthesizeDialogue(dialogueReq).pipe(Effect.provide(mock.layer)),\n )\n expect(result.bytes).toEqual(blob.bytes)\n })\n\n it(\"records the request on the synthesizeDialogue call channel\", async () => {\n const mock = MockSpeechSynthesizer.layer({ dialogueBlobs: [blob] })\n const program = Effect.gen(function* () {\n yield* SpeechSynthesizer.synthesizeDialogue(dialogueReq)\n return yield* mock.recorder\n })\n const rec = await Effect.runPromise(program.pipe(Effect.provide(mock.layer)))\n expect(rec.synthesizeDialogueCalls.length).toBe(1)\n expect(rec.synthesizeDialogueCalls[0]!.turns.length).toBe(2)\n expect(rec.synthesizeCalls.length).toBe(0)\n })\n\n it(\"emits scripted chunks for streamSynthesizeDialogue\", async () => {\n const mock = MockSpeechSynthesizer.layer({\n streamSynthesizeDialogueChunks: [[chunk(7), chunk(8)]],\n })\n const out = await Effect.runPromise(\n Stream.runCollect(SpeechSynthesizer.streamSynthesizeDialogue(dialogueReq)).pipe(\n Effect.provide(mock.layer),\n ),\n )\n expect(out.map((c) => Array.from(c.bytes))).toEqual([[7], [8]])\n })\n})\n\ndescribe(\"MultiSpeakerTts capability marker (compile-time)\", () => {\n const dialogueReq: SpeechSynthesizer.CommonSynthesizeDialogueRequest = {\n model: \"mock-tts\",\n turns: [{ voiceId: \"a\", text: \"Hi\" }],\n }\n\n it(\"requires `MultiSpeakerTts` on the R channel of synthesizeDialogue\", () => {\n const eff = SpeechSynthesizer.synthesizeDialogue(dialogueReq)\n expectTypeOf(eff).toEqualTypeOf<\n Effect.Effect<\n AudioBlob,\n AiError.AiError,\n SpeechSynthesizer.SpeechSynthesizer | SpeechSynthesizer.MultiSpeakerTts\n >\n >()\n })\n\n it(\"requires `MultiSpeakerTts` on the R channel of streamSynthesizeDialogue\", () => {\n const s = SpeechSynthesizer.streamSynthesizeDialogue(dialogueReq)\n expectTypeOf(s).toEqualTypeOf<\n Stream.Stream<\n AudioChunk,\n AiError.AiError,\n SpeechSynthesizer.SpeechSynthesizer | SpeechSynthesizer.MultiSpeakerTts\n >\n >()\n })\n\n it(\"a layer without the marker leaves `MultiSpeakerTts` unsatisfied in R\", () => {\n const noMarker = MockSpeechSynthesizer.layerWithoutMultiSpeaker({})\n const program = SpeechSynthesizer.synthesizeDialogue(dialogueReq).pipe(\n Effect.provide(noMarker.layer),\n )\n expectTypeOf(program).toEqualTypeOf<\n Effect.Effect<AudioBlob, AiError.AiError, SpeechSynthesizer.MultiSpeakerTts>\n >()\n })\n\n it(\"a full layer (with marker) clears R to never\", () => {\n const fullMock = MockSpeechSynthesizer.layer({ dialogueBlobs: [blob] })\n const program = SpeechSynthesizer.synthesizeDialogue(dialogueReq).pipe(\n Effect.provide(fullMock.layer),\n )\n expectTypeOf(program).toEqualTypeOf<Effect.Effect<AudioBlob, AiError.AiError, never>>()\n })\n})\n\ndescribe(\"SpeechSynthesizer.streamSynthesisFrom\", () => {\n const ssfReq: SpeechSynthesizer.CommonStreamSynthesizeRequest = {\n model: \"mock-tts\",\n voiceId: \"stock-voice\",\n }\n\n it(\"pipes an LLM-style text stream into audio chunks\", async () => {\n const mock = MockSpeechSynthesizer.layer({\n streamSynthesisFromChunks: [[chunk(10), chunk(20)]],\n })\n const tokens = Stream.fromIterable([\"Hello, \", \"world.\"])\n const audio = tokens.pipe(SpeechSynthesizer.streamSynthesisFrom(ssfReq))\n const out = await Effect.runPromise(Stream.runCollect(audio).pipe(Effect.provide(mock.layer)))\n expect(out.map((c) => Array.from(c.bytes))).toEqual([[10], [20]])\n })\n\n it(\"records the request on the streamSynthesisFrom call channel\", async () => {\n const mock = MockSpeechSynthesizer.layer({\n streamSynthesisFromChunks: [[chunk(42)]],\n })\n const program = Effect.gen(function* () {\n yield* Stream.runDrain(\n Stream.fromIterable([\"x\"]).pipe(SpeechSynthesizer.streamSynthesisFrom(ssfReq)),\n )\n return yield* mock.recorder\n })\n const rec = await Effect.runPromise(program.pipe(Effect.provide(mock.layer)))\n expect(rec.streamSynthesisFromCalls.length).toBe(1)\n expect(rec.streamSynthesisFromCalls[0]!.voiceId).toBe(\"stock-voice\")\n expect(rec.synthesizeCalls.length).toBe(0)\n expect(rec.streamSynthesisCalls.length).toBe(0)\n })\n})\n"],"mappings":";;;;;AAaA,MAAM,OAAkB;CACtB,QAAQ;EANR,WAAW;EACX,UAAU;EACV,YAAY;EAIK;CACjB,OAAO,IAAI,WAAW;EAAC;EAAM;EAAM;EAAM;EAAK,CAAC;CAC/C,UAAU,SAAS,OAAO,IAAI;CAC/B;AAED,MAAM,SAAS,OAA2B,EAAE,OAAO,IAAI,WAAW,CAAC,EAAE,CAAC,EAAE;AAExE,SAAS,sCAAsC;AAC7C,IAAG,kCAAkC,YAAY;EAC/C,MAAM,OAAOA,MAA4B,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;EAC3D,MAAM,UAAUC,WAA6B;GAC3C,MAAM;GACN,OAAO;GACP,SAAS;GACV,CAAC;EACF,MAAM,SAAS,MAAM,OAAO,WAAW,QAAQ,KAAK,OAAO,QAAQ,KAAK,MAAM,CAAC,CAAC;AAChF,eAAO,OAAO,MAAM,CAAC,QAAQ,KAAK,MAAM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C,CAAC,KAAKG,oBAAsC,OAAO,CAAC;AAExE,gBAAO,MADW,OAAO,WAAW,OAAO,WAAW,MAAM,CAAC,KAAK,OAAO,QAAQ,KAAK,MAAM,CAAC,CAAC,EACnF,KAAK,MAAM,MAAM,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;GACjE;AAEF,IAAG,+DAA+D,YAAY;EAC5E,MAAM,OAAOH,MAA4B,EACvC,2BAA2B,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,EACzC,CAAC;EACF,MAAM,UAAU,OAAO,IAAI,aAAa;AACtC,UAAO,OAAO,SACZ,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC,KAAKG,oBAAsC,OAAO,CAAC,CAC/E;AACD,UAAO,OAAO,KAAK;IACnB;EACF,MAAM,MAAM,MAAM,OAAO,WAAW,QAAQ,KAAK,OAAO,QAAQ,KAAK,MAAM,CAAC,CAAC;AAC7E,eAAO,IAAI,yBAAyB,OAAO,CAAC,KAAK,EAAE;AACnD,eAAO,IAAI,yBAAyB,GAAI,QAAQ,CAAC,KAAK,cAAc;AACpE,eAAO,IAAI,gBAAgB,OAAO,CAAC,KAAK,EAAE;AAC1C,eAAO,IAAI,qBAAqB,OAAO,CAAC,KAAK,EAAE;GAC/C;EACF"}
1
+ {"version":3,"file":"SpeechSynthesizer.test.mjs","names":["MockSpeechSynthesizer.layer","SpeechSynthesizer.synthesize","SpeechSynthesizer.streamSynthesis","SpeechSynthesizer.streamSynthesisFrom","MockSpeechSynthesizer.layerWithoutIncremental","SpeechSynthesizer.synthesizeDialogue","SpeechSynthesizer.streamSynthesizeDialogue","MockSpeechSynthesizer.layerWithoutMultiSpeaker"],"sources":["../../src/speech-synthesizer/SpeechSynthesizer.test.ts"],"sourcesContent":["import { Duration, Effect, Stream } from \"effect\"\nimport { describe, expect, expectTypeOf, it } from \"vitest\"\nimport type * as AiError from \"../domain/AiError.js\"\nimport type { AudioBlob, AudioChunk, AudioFormat } from \"../domain/Audio.js\"\nimport * as MockSpeechSynthesizer from \"../testing/MockSpeechSynthesizer.js\"\nimport * as SpeechSynthesizer from \"./SpeechSynthesizer.js\"\n\nconst pcmFormat: AudioFormat = {\n container: \"raw\",\n encoding: \"pcm_s16le\",\n sampleRate: 24000,\n}\n\nconst blob: AudioBlob = {\n format: pcmFormat,\n bytes: new Uint8Array([0xde, 0xad, 0xbe, 0xef]),\n duration: Duration.millis(500),\n}\n\nconst chunk = (n: number): AudioChunk => ({ bytes: new Uint8Array([n]) })\n\ndescribe(\"SpeechSynthesizer.synthesize\", () => {\n it(\"returns the scripted AudioBlob\", async () => {\n const mock = MockSpeechSynthesizer.layer({ blobs: [blob] })\n const program = SpeechSynthesizer.synthesize({\n text: \"hi\",\n model: \"mock-tts\",\n voiceId: \"stock-voice\",\n })\n const result = await Effect.runPromise(program.pipe(Effect.provide(mock.layer)))\n expect(result.bytes).toEqual(blob.bytes)\n expect(result.duration).toEqual(Duration.millis(500))\n })\n})\n\ndescribe(\"SpeechSynthesizer.streamSynthesis\", () => {\n it(\"emits scripted chunks for full-text-in streaming\", async () => {\n const mock = MockSpeechSynthesizer.layer({\n streamSynthesisChunks: [[chunk(1), chunk(2), chunk(3)]],\n })\n const program = Stream.runCollect(\n SpeechSynthesizer.streamSynthesis({\n text: \"hi\",\n model: \"mock-tts\",\n voiceId: \"stock-voice\",\n }),\n )\n const out = await Effect.runPromise(program.pipe(Effect.provide(mock.layer)))\n expect(out.map((c) => Array.from(c.bytes))).toEqual([[1], [2], [3]])\n })\n})\n\ndescribe(\"SpeechSynthesizer capability marker (compile-time)\", () => {\n const ssfReq: SpeechSynthesizer.CommonStreamSynthesizeRequest = {\n model: \"mock-tts\",\n voiceId: \"v\",\n }\n\n it(\"requires `TtsIncrementalText` on the R channel of streamSynthesisFrom\", () => {\n const tokens: Stream.Stream<string> = Stream.fromIterable([\"a\"])\n const audio = tokens.pipe(SpeechSynthesizer.streamSynthesisFrom(ssfReq))\n expectTypeOf(audio).toEqualTypeOf<\n Stream.Stream<\n AudioChunk,\n AiError.AiError,\n SpeechSynthesizer.SpeechSynthesizer | SpeechSynthesizer.TtsIncrementalText\n >\n >()\n })\n\n it(\"does NOT require `TtsIncrementalText` for sync `synthesize`\", () => {\n const eff = SpeechSynthesizer.synthesize({ text: \"hi\", model: \"m\", voiceId: \"v\" })\n expectTypeOf(eff).toEqualTypeOf<\n Effect.Effect<AudioBlob, AiError.AiError, SpeechSynthesizer.SpeechSynthesizer>\n >()\n })\n\n it(\"does NOT require `TtsIncrementalText` for full-text `streamSynthesis`\", () => {\n const audio = SpeechSynthesizer.streamSynthesis({ text: \"hi\", model: \"m\", voiceId: \"v\" })\n expectTypeOf(audio).toEqualTypeOf<\n Stream.Stream<AudioChunk, AiError.AiError, SpeechSynthesizer.SpeechSynthesizer>\n >()\n })\n\n it(\"a layer without the marker leaves `TtsIncrementalText` unsatisfied in R\", () => {\n const noMarker = MockSpeechSynthesizer.layerWithoutIncremental({})\n const tokens: Stream.Stream<string> = Stream.fromIterable([\"a\"])\n const audio = tokens.pipe(SpeechSynthesizer.streamSynthesisFrom(ssfReq))\n const program = Stream.runDrain(audio).pipe(Effect.provide(noMarker.layer))\n // `SpeechSynthesizer` is provided by the layer; `TtsIncrementalText` is not,\n // so it remains in R — calling `Effect.runPromise(program)` would be a type\n // error because runPromise requires `R = never`.\n expectTypeOf(program).toEqualTypeOf<\n Effect.Effect<void, AiError.AiError, SpeechSynthesizer.TtsIncrementalText>\n >()\n })\n\n it(\"a full layer (with marker) clears R to never\", () => {\n const fullMock = MockSpeechSynthesizer.layer({\n streamSynthesisFromChunks: [[]],\n })\n const tokens: Stream.Stream<string> = Stream.fromIterable([\"a\"])\n const audio = tokens.pipe(SpeechSynthesizer.streamSynthesisFrom(ssfReq))\n const program = Stream.runDrain(audio).pipe(Effect.provide(fullMock.layer))\n expectTypeOf(program).toEqualTypeOf<Effect.Effect<void, AiError.AiError, never>>()\n })\n})\n\ndescribe(\"SpeechSynthesizer.synthesizeDialogue\", () => {\n const dialogueReq: SpeechSynthesizer.CommonSynthesizeDialogueRequest = {\n model: \"mock-tts\",\n turns: [\n { voiceId: \"voice-a\", text: \"Hi\" },\n { voiceId: \"voice-b\", text: \"Hello\" },\n ],\n }\n\n it(\"returns the scripted AudioBlob\", async () => {\n const mock = MockSpeechSynthesizer.layer({ dialogueBlobs: [blob] })\n const result = await Effect.runPromise(\n SpeechSynthesizer.synthesizeDialogue(dialogueReq).pipe(Effect.provide(mock.layer)),\n )\n expect(result.bytes).toEqual(blob.bytes)\n })\n\n it(\"records the request on the synthesizeDialogue call channel\", async () => {\n const mock = MockSpeechSynthesizer.layer({ dialogueBlobs: [blob] })\n const program = Effect.gen(function* () {\n yield* SpeechSynthesizer.synthesizeDialogue(dialogueReq)\n return yield* mock.recorder\n })\n const rec = await Effect.runPromise(program.pipe(Effect.provide(mock.layer)))\n expect(rec.synthesizeDialogueCalls.length).toBe(1)\n expect(rec.synthesizeDialogueCalls[0]!.turns.length).toBe(2)\n expect(rec.synthesizeCalls.length).toBe(0)\n })\n\n it(\"emits scripted chunks for streamSynthesizeDialogue\", async () => {\n const mock = MockSpeechSynthesizer.layer({\n streamSynthesizeDialogueChunks: [[chunk(7), chunk(8)]],\n })\n const out = await Effect.runPromise(\n Stream.runCollect(SpeechSynthesizer.streamSynthesizeDialogue(dialogueReq)).pipe(\n Effect.provide(mock.layer),\n ),\n )\n expect(out.map((c) => Array.from(c.bytes))).toEqual([[7], [8]])\n })\n})\n\ndescribe(\"MultiSpeakerTts capability marker (compile-time)\", () => {\n const dialogueReq: SpeechSynthesizer.CommonSynthesizeDialogueRequest = {\n model: \"mock-tts\",\n turns: [{ voiceId: \"a\", text: \"Hi\" }],\n }\n\n it(\"requires `MultiSpeakerTts` on the R channel of synthesizeDialogue\", () => {\n const eff = SpeechSynthesizer.synthesizeDialogue(dialogueReq)\n expectTypeOf(eff).toEqualTypeOf<\n Effect.Effect<\n AudioBlob,\n AiError.AiError,\n SpeechSynthesizer.SpeechSynthesizer | SpeechSynthesizer.MultiSpeakerTts\n >\n >()\n })\n\n it(\"requires `MultiSpeakerTts` on the R channel of streamSynthesizeDialogue\", () => {\n const s = SpeechSynthesizer.streamSynthesizeDialogue(dialogueReq)\n expectTypeOf(s).toEqualTypeOf<\n Stream.Stream<\n AudioChunk,\n AiError.AiError,\n SpeechSynthesizer.SpeechSynthesizer | SpeechSynthesizer.MultiSpeakerTts\n >\n >()\n })\n\n it(\"a layer without the marker leaves `MultiSpeakerTts` unsatisfied in R\", () => {\n const noMarker = MockSpeechSynthesizer.layerWithoutMultiSpeaker({})\n const program = SpeechSynthesizer.synthesizeDialogue(dialogueReq).pipe(\n Effect.provide(noMarker.layer),\n )\n expectTypeOf(program).toEqualTypeOf<\n Effect.Effect<AudioBlob, AiError.AiError, SpeechSynthesizer.MultiSpeakerTts>\n >()\n })\n\n it(\"a full layer (with marker) clears R to never\", () => {\n const fullMock = MockSpeechSynthesizer.layer({ dialogueBlobs: [blob] })\n const program = SpeechSynthesizer.synthesizeDialogue(dialogueReq).pipe(\n Effect.provide(fullMock.layer),\n )\n expectTypeOf(program).toEqualTypeOf<Effect.Effect<AudioBlob, AiError.AiError, never>>()\n })\n})\n\ndescribe(\"SpeechSynthesizer.streamSynthesisFrom\", () => {\n const ssfReq: SpeechSynthesizer.CommonStreamSynthesizeRequest = {\n model: \"mock-tts\",\n voiceId: \"stock-voice\",\n }\n\n it(\"pipes an LLM-style text stream into audio chunks\", async () => {\n const mock = MockSpeechSynthesizer.layer({\n streamSynthesisFromChunks: [[chunk(10), chunk(20)]],\n })\n const tokens = Stream.fromIterable([\"Hello, \", \"world.\"])\n const audio = tokens.pipe(SpeechSynthesizer.streamSynthesisFrom(ssfReq))\n const out = await Effect.runPromise(Stream.runCollect(audio).pipe(Effect.provide(mock.layer)))\n expect(out.map((c) => Array.from(c.bytes))).toEqual([[10], [20]])\n })\n\n it(\"records the request on the streamSynthesisFrom call channel\", async () => {\n const mock = MockSpeechSynthesizer.layer({\n streamSynthesisFromChunks: [[chunk(42)]],\n })\n const program = Effect.gen(function* () {\n yield* Stream.runDrain(\n Stream.fromIterable([\"x\"]).pipe(SpeechSynthesizer.streamSynthesisFrom(ssfReq)),\n )\n return yield* mock.recorder\n })\n const rec = await Effect.runPromise(program.pipe(Effect.provide(mock.layer)))\n expect(rec.streamSynthesisFromCalls.length).toBe(1)\n expect(rec.streamSynthesisFromCalls[0]!.voiceId).toBe(\"stock-voice\")\n expect(rec.synthesizeCalls.length).toBe(0)\n expect(rec.streamSynthesisCalls.length).toBe(0)\n })\n})\n"],"mappings":";;;;;;;AAaA,MAAM,OAAkB;CACtB,QAAQ;EANR,WAAW;EACX,UAAU;EACV,YAAY;CAII;CAChB,OAAO,IAAI,WAAW;EAAC;EAAM;EAAM;EAAM;CAAI,CAAC;CAC9C,UAAU,SAAS,OAAO,GAAG;AAC/B;AAEA,MAAM,SAAS,OAA2B,EAAE,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE;AAEvE,SAAS,sCAAsC;CAC7C,GAAG,kCAAkC,YAAY;EAC/C,MAAM,OAAOA,MAA4B,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;EAC1D,MAAM,UAAUC,WAA6B;GAC3C,MAAM;GACN,OAAO;GACP,SAAS;EACX,CAAC;EACD,MAAM,SAAS,MAAM,OAAO,WAAW,QAAQ,KAAK,OAAO,QAAQ,KAAK,KAAK,CAAC,CAAC;EAC/E,aAAO,OAAO,KAAK,CAAC,CAAC,QAAQ,KAAK,KAAK;EACvC,aAAO,OAAO,QAAQ,CAAC,CAAC,QAAQ,SAAS,OAAO,GAAG,CAAC;CACtD,CAAC;AACH,CAAC;AAED,SAAS,2CAA2C;CAClD,GAAG,oDAAoD,YAAY;EACjE,MAAM,OAAOD,MAA4B,EACvC,uBAAuB,CAAC;GAAC,MAAM,CAAC;GAAG,MAAM,CAAC;GAAG,MAAM,CAAC;EAAC,C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 -1,12 +1,8 @@
1
1
  import { Effect, Schema, Stream } from "effect";
2
- import * as _$effect_Cause0 from "effect/Cause";
3
- import * as _$effect_Types0 from "effect/Types";
4
-
5
- //#region src/streaming/JSONL.d.ts
6
2
  declare namespace JSONL_d_exports {
7
3
  export { JsonParseError, fromBytes, parse, parseSafe, toBytes };
8
4
  }
9
- declare const JsonParseError_base: new <A extends Record<string, any> = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & {
5
+ declare const JsonParseError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
10
6
  readonly _tag: "JsonParseError";
11
7
  } & Readonly<A>;
12
8
  declare class JsonParseError extends JsonParseError_base<{
@@ -1 +1 @@
1
- {"version":3,"file":"JSONL.d.mts","names":[],"sources":["../../src/streaming/JSONL.ts"],"mappings":";;;;;;;;cAA8D,mBAAA;;;cAEjD,cAAA,SAAuB,mBAAA;EAAA,SACzB,IAAA;EAAA,SACA,KAAA;AAAA;;;;;AAJmD;;cAiBjD,SAAA,SACX,IAAA,EAAM,MAAA,CAAO,MAAA,CAAO,UAAA,EAAY,CAAA,EAAG,CAAA,MAClC,MAAA,CAAO,MAAA,SAAe,CAAA,EAAG,CAAA;;;;;;cAYf,KAAA,SAAe,MAAA,EAAQ,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,CAAA,aAEpC,IAAA,EAAM,MAAA,CAAO,MAAA,SAAe,CAAA,EAAG,CAAA,MAAK,MAAA,CAAO,MAAA,CAAO,CAAA,EAAG,cAAA,GAAiB,CAAA,EAAG,CAAA;;;;;;;cAgB5E,SAAA,GAAa,GAAA,aAAc,MAAA,CAAO,MAAA;;;;;cASlC,OAAA,SACJ,MAAA,EAAQ,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,CAAA,aACxB,IAAA,EAAM,MAAA,CAAO,MAAA,CAAO,CAAA,EAAG,CAAA,EAAG,CAAA,MAAK,MAAA,CAAO,MAAA,CAAO,UAAA,EAAY,CAAA,EAAG,CAAA"}
1
+ {"version":3,"file":"JSONL.d.mts","names":[],"sources":["../../src/streaming/JSONL.ts"],"mappings":";;;;;;;cAEa,uBAAuB;WACzB;WACA;;;;;;;;cAaE,YAAa,GAAG,GAAC,MACtB,OAAO,OAAO,YAAY,GAAG,OAClC,OAAO,eAAe,GAAG;;;;;;cAYf,QAAS,GAAG,GAAC,QAAU,OAAO,MAAM,GAAG,QAE1C,GAAG,GAAC,MAAQ,OAAO,eAAe,GAAG,OAAK,OAAO,OAAO,GAAG,iBAAiB,GAAG;;;;;;;cAgB5E,YAAS,gBAAkB,OAAO;;;;;cASlC,UACV,GAAG,GAAC,QAAU,OAAO,MAAM,GAAG,QAC9B,GAAG,GAAC,MAAQ,OAAO,OAAO,GAAG,GAAG,OAAK,OAAO,OAAO,YAAY,GAAG"}
@@ -1,4 +1,4 @@
1
- import { n as __exportAll } from "../chunk-uyGKjUfl.mjs";
1
+ import { n as __exportAll } from "../rolldown-runtime-EAsCxrDo.mjs";
2
2
  import { Channel, Data, Effect, Schema, Stream } from "effect";
3
3
  //#region src/streaming/JSONL.ts
4
4
  var JSONL_exports = /* @__PURE__ */ __exportAll({