@effect-uai/core 0.5.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/README.md +1 -1
  2. package/dist/{Audio-BfCTGnH3.d.mts → Audio-DPlTsNdz.d.mts} +3 -2
  3. package/dist/Audio-DPlTsNdz.d.mts.map +1 -0
  4. package/dist/{Items-BH8xUkoR.d.mts → Items-D8UaXQx_.d.mts} +15 -15
  5. package/dist/Items-D8UaXQx_.d.mts.map +1 -0
  6. package/dist/SandboxError-BvKypkJm.d.mts +158 -0
  7. package/dist/SandboxError-BvKypkJm.d.mts.map +1 -0
  8. package/dist/{Tool-87ViKCCO.d.mts → Tool-CiFXYjmR.d.mts} +11 -11
  9. package/dist/{Tool-87ViKCCO.d.mts.map → Tool-CiFXYjmR.d.mts.map} +1 -1
  10. package/dist/capabilities/Capabilities.d.mts +78 -0
  11. package/dist/capabilities/Capabilities.d.mts.map +1 -0
  12. package/dist/capabilities/Capabilities.mjs +65 -0
  13. package/dist/capabilities/Capabilities.mjs.map +1 -0
  14. package/dist/domain/Audio.d.mts +1 -1
  15. package/dist/domain/Audio.mjs.map +1 -1
  16. package/dist/domain/Items.d.mts +2 -2
  17. package/dist/domain/Items.mjs +15 -15
  18. package/dist/domain/Items.mjs.map +1 -1
  19. package/dist/domain/Music.d.mts +131 -72
  20. package/dist/domain/Music.d.mts.map +1 -1
  21. package/dist/domain/Music.mjs +36 -9
  22. package/dist/domain/Music.mjs.map +1 -1
  23. package/dist/domain/Transcript.d.mts +8 -2
  24. package/dist/domain/Transcript.d.mts.map +1 -1
  25. package/dist/domain/Transcript.mjs.map +1 -1
  26. package/dist/domain/Turn.d.mts +388 -2
  27. package/dist/domain/Turn.d.mts.map +1 -0
  28. package/dist/domain/Turn.mjs +13 -13
  29. package/dist/domain/Turn.mjs.map +1 -1
  30. package/dist/embedding-model/Embedding.d.mts +12 -2
  31. package/dist/embedding-model/Embedding.d.mts.map +1 -1
  32. package/dist/embedding-model/Embedding.mjs.map +1 -1
  33. package/dist/embedding-model/EmbeddingModel.d.mts +36 -23
  34. package/dist/embedding-model/EmbeddingModel.d.mts.map +1 -1
  35. package/dist/embedding-model/EmbeddingModel.mjs +20 -1
  36. package/dist/embedding-model/EmbeddingModel.mjs.map +1 -1
  37. package/dist/embedding-model/EmbeddingModel.test.mjs +15 -3
  38. package/dist/embedding-model/EmbeddingModel.test.mjs.map +1 -1
  39. package/dist/index.d.mts +13 -7
  40. package/dist/index.mjs +9 -3
  41. package/dist/language-model/LanguageModel.d.mts +5 -5
  42. package/dist/language-model/LanguageModel.d.mts.map +1 -1
  43. package/dist/language-model/LanguageModel.mjs.map +1 -1
  44. package/dist/loop/Loop.d.mts +37 -90
  45. package/dist/loop/Loop.d.mts.map +1 -1
  46. package/dist/loop/Loop.mjs +39 -93
  47. package/dist/loop/Loop.mjs.map +1 -1
  48. package/dist/loop/Loop.test.mjs +46 -54
  49. package/dist/loop/Loop.test.mjs.map +1 -1
  50. package/dist/music-generator/MusicGenerator.d.mts +48 -25
  51. package/dist/music-generator/MusicGenerator.d.mts.map +1 -1
  52. package/dist/music-generator/MusicGenerator.mjs +17 -9
  53. package/dist/music-generator/MusicGenerator.mjs.map +1 -1
  54. package/dist/music-generator/MusicGenerator.test.mjs +81 -56
  55. package/dist/music-generator/MusicGenerator.test.mjs.map +1 -1
  56. package/dist/sandbox/Memory.d.mts +53 -0
  57. package/dist/sandbox/Memory.d.mts.map +1 -0
  58. package/dist/sandbox/Memory.mjs +68 -0
  59. package/dist/sandbox/Memory.mjs.map +1 -0
  60. package/dist/sandbox/Sandbox.d.mts +717 -0
  61. package/dist/sandbox/Sandbox.d.mts.map +1 -0
  62. package/dist/sandbox/Sandbox.mjs +192 -0
  63. package/dist/sandbox/Sandbox.mjs.map +1 -0
  64. package/dist/sandbox/SandboxError.d.mts +2 -0
  65. package/dist/sandbox/SandboxError.mjs +89 -0
  66. package/dist/sandbox/SandboxError.mjs.map +1 -0
  67. package/dist/sandbox/SandboxImage.d.mts +28 -0
  68. package/dist/sandbox/SandboxImage.d.mts.map +1 -0
  69. package/dist/sandbox/SandboxImage.mjs +32 -0
  70. package/dist/sandbox/SandboxImage.mjs.map +1 -0
  71. package/dist/sandbox/SandboxNetwork.d.mts +34 -0
  72. package/dist/sandbox/SandboxNetwork.d.mts.map +1 -0
  73. package/dist/sandbox/SandboxNetwork.mjs +36 -0
  74. package/dist/sandbox/SandboxNetwork.mjs.map +1 -0
  75. package/dist/speech-synthesizer/SpeechSynthesizer.d.mts +84 -3
  76. package/dist/speech-synthesizer/SpeechSynthesizer.d.mts.map +1 -1
  77. package/dist/speech-synthesizer/SpeechSynthesizer.mjs +32 -2
  78. package/dist/speech-synthesizer/SpeechSynthesizer.mjs.map +1 -1
  79. package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs +59 -5
  80. package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs.map +1 -1
  81. package/dist/testing/MockMusicGenerator.d.mts +12 -7
  82. package/dist/testing/MockMusicGenerator.d.mts.map +1 -1
  83. package/dist/testing/MockMusicGenerator.mjs +4 -3
  84. package/dist/testing/MockMusicGenerator.mjs.map +1 -1
  85. package/dist/testing/MockProvider.d.mts +3 -3
  86. package/dist/testing/MockProvider.d.mts.map +1 -1
  87. package/dist/testing/MockProvider.mjs.map +1 -1
  88. package/dist/testing/MockSandbox.d.mts +604 -0
  89. package/dist/testing/MockSandbox.d.mts.map +1 -0
  90. package/dist/testing/MockSandbox.mjs +160 -0
  91. package/dist/testing/MockSandbox.mjs.map +1 -0
  92. package/dist/testing/MockSpeechSynthesizer.d.mts +27 -12
  93. package/dist/testing/MockSpeechSynthesizer.d.mts.map +1 -1
  94. package/dist/testing/MockSpeechSynthesizer.mjs +75 -51
  95. package/dist/testing/MockSpeechSynthesizer.mjs.map +1 -1
  96. package/dist/tool/{Resolvers.d.mts → Approval.d.mts} +27 -27
  97. package/dist/tool/Approval.d.mts.map +1 -0
  98. package/dist/tool/{Resolvers.mjs → Approval.mjs} +18 -18
  99. package/dist/tool/Approval.mjs.map +1 -0
  100. package/dist/tool/{Resolvers.test.mjs → Approval.test.mjs} +40 -40
  101. package/dist/tool/Approval.test.mjs.map +1 -0
  102. package/dist/tool/HistoryCheck.d.mts +6 -6
  103. package/dist/tool/HistoryCheck.d.mts.map +1 -1
  104. package/dist/tool/HistoryCheck.mjs +5 -5
  105. package/dist/tool/HistoryCheck.mjs.map +1 -1
  106. package/dist/tool/Tool.d.mts +2 -2
  107. package/dist/tool/Tool.mjs +4 -4
  108. package/dist/tool/Tool.mjs.map +1 -1
  109. package/dist/tool/ToolEvent.d.mts +19 -19
  110. package/dist/tool/ToolEvent.d.mts.map +1 -1
  111. package/dist/tool/ToolEvent.mjs +8 -8
  112. package/dist/tool/ToolEvent.mjs.map +1 -1
  113. package/dist/tool/{Outcome.d.mts → ToolResult.d.mts} +29 -29
  114. package/dist/tool/ToolResult.d.mts.map +1 -0
  115. package/dist/tool/ToolResult.mjs +61 -0
  116. package/dist/tool/ToolResult.mjs.map +1 -0
  117. package/dist/tool/Toolkit.d.mts +58 -26
  118. package/dist/tool/Toolkit.d.mts.map +1 -1
  119. package/dist/tool/Toolkit.mjs +62 -34
  120. package/dist/tool/Toolkit.mjs.map +1 -1
  121. package/dist/tool/Toolkit.test.mjs +13 -13
  122. package/dist/tool/Toolkit.test.mjs.map +1 -1
  123. package/dist/transcriber/Transcriber.d.mts +11 -10
  124. package/dist/transcriber/Transcriber.d.mts.map +1 -1
  125. package/dist/transcriber/Transcriber.mjs.map +1 -1
  126. package/dist/transcriber/Transcriber.test.mjs +3 -3
  127. package/dist/transcriber/Transcriber.test.mjs.map +1 -1
  128. package/package.json +35 -7
  129. package/src/capabilities/Capabilities.ts +81 -0
  130. package/src/domain/Audio.ts +2 -1
  131. package/src/domain/Items.ts +9 -9
  132. package/src/domain/Music.ts +142 -68
  133. package/src/domain/Transcript.ts +7 -1
  134. package/src/domain/Turn.ts +16 -16
  135. package/src/embedding-model/Embedding.ts +11 -0
  136. package/src/embedding-model/EmbeddingModel.test.ts +15 -4
  137. package/src/embedding-model/EmbeddingModel.ts +48 -21
  138. package/src/index.ts +8 -2
  139. package/src/language-model/LanguageModel.ts +3 -3
  140. package/src/loop/Loop.test.ts +93 -91
  141. package/src/loop/Loop.ts +72 -170
  142. package/src/music-generator/MusicGenerator.test.ts +78 -53
  143. package/src/music-generator/MusicGenerator.ts +65 -24
  144. package/src/sandbox/Memory.ts +128 -0
  145. package/src/sandbox/Sandbox.ts +639 -0
  146. package/src/sandbox/SandboxError.ts +140 -0
  147. package/src/sandbox/SandboxImage.ts +26 -0
  148. package/src/sandbox/SandboxNetwork.ts +34 -0
  149. package/src/speech-synthesizer/SpeechSynthesizer.test.ts +92 -3
  150. package/src/speech-synthesizer/SpeechSynthesizer.ts +109 -0
  151. package/src/testing/MockMusicGenerator.ts +28 -18
  152. package/src/testing/MockProvider.ts +21 -20
  153. package/src/testing/MockSandbox.ts +342 -0
  154. package/src/testing/MockSpeechSynthesizer.ts +137 -77
  155. package/src/tool/{Resolvers.test.ts → Approval.test.ts} +45 -54
  156. package/src/tool/{Resolvers.ts → Approval.ts} +25 -25
  157. package/src/tool/HistoryCheck.ts +10 -13
  158. package/src/tool/Tool.ts +13 -15
  159. package/src/tool/ToolEvent.ts +7 -7
  160. package/src/tool/{Outcome.ts → ToolResult.ts} +20 -20
  161. package/src/tool/Toolkit.test.ts +13 -13
  162. package/src/tool/Toolkit.ts +97 -73
  163. package/src/transcriber/Transcriber.test.ts +3 -3
  164. package/src/transcriber/Transcriber.ts +10 -7
  165. package/dist/Audio-BfCTGnH3.d.mts.map +0 -1
  166. package/dist/Items-BH8xUkoR.d.mts.map +0 -1
  167. package/dist/Turn-0CwCAyVe.d.mts +0 -388
  168. package/dist/Turn-0CwCAyVe.d.mts.map +0 -1
  169. package/dist/tool/Outcome.d.mts.map +0 -1
  170. package/dist/tool/Outcome.mjs +0 -61
  171. package/dist/tool/Outcome.mjs.map +0 -1
  172. package/dist/tool/Resolvers.d.mts.map +0 -1
  173. package/dist/tool/Resolvers.mjs.map +0 -1
  174. package/dist/tool/Resolvers.test.mjs.map +0 -1
  175. /package/dist/tool/{Resolvers.test.d.mts → Approval.test.d.mts} +0 -0
@@ -1,33 +1,33 @@
1
1
  import { t as AiError } from "../AiError-CAX_48RU.mjs";
2
- import { EmbedInput, EmbeddingFor, Usage } from "./Embedding.mjs";
2
+ import { EmbedInput, EmbeddingFor, ResponseEncoding, Usage } from "./Embedding.mjs";
3
3
  import { Context, Effect } from "effect";
4
4
 
5
5
  //#region src/embedding-model/EmbeddingModel.d.ts
6
6
  declare namespace EmbeddingModel_d_exports {
7
- export { CommonEmbedManyRequest, CommonEmbedRequest, EmbedEncoding, EmbedManyResponse, EmbedResponse, EmbeddingModel, EmbeddingModelService, embed, embedMany };
7
+ export { CommonEmbedManyRequest, CommonEmbedRequest, EmbedEncoding, EmbedManyResponse, EmbedResponse, EmbeddingModel, EmbeddingModelService, assertEncoding, embed, embedMany };
8
8
  }
9
9
  /**
10
- * Output representation requested from the provider.
10
+ * Output representation requested from the provider. Cross-provider dense
11
+ * quantization only, the same vector at different storage cost:
12
+ * - `float32`: universal default.
13
+ * - `int8`: ~4x smaller, minimal recall loss on most benchmarks. Supported
14
+ * by Cohere, Voyage, Jina (binary only), Mixedbread.
15
+ * - `binary`: ~32x smaller, meaningful recall loss but pairs well with a
16
+ * float32 reranker pass over a small candidate set.
11
17
  *
12
- * Dense quantizations - same vector at different storage cost:
13
- * - `float32` — universal default.
14
- * - `int8` — ~4x smaller; minimal recall loss on most benchmarks.
15
- * - `binary` — ~32x smaller; meaningful recall loss but pairs well with
16
- * a float32 reranker pass over a small candidate set.
18
+ * Non-dense representations (`sparse`, `multivector`) are a different vector
19
+ * *structure*, not a storage option, and are produced by Jina only. They
20
+ * live on `JinaEncoding`, not here (the same widening pattern `task` uses).
21
+ * The response `Embedding` union still carries all arms, see
22
+ * {@link ResponseEncoding}.
17
23
  *
18
- * Non-dense representations:
19
- * - `sparse` — learned sparse vector for hybrid (dense + lexical) search.
20
- * Currently Jina ELSER only on hosted APIs.
21
- * - `multivector` — one vector per token for late-interaction (ColBERT-
22
- * style) scoring via `Vector.maxSim`. Currently Jina v4 only.
23
- *
24
- * Each provider's typed request narrows this to its supported set at
25
- * compile time (e.g. `JinaEmbedEncoding = "float32" | "binary" | "sparse" |
26
- * "multivector"`). On the generic `EmbeddingModel` path, callers can
27
- * pass any `EmbedEncoding` and the provider's API will reject mismatches at
28
- * runtime.
24
+ * Each provider's typed request narrows this to its supported set. On the
25
+ * generic `EmbeddingModel` path, a provider that emits float32 only (OpenAI,
26
+ * Gemini) rejects a non-float32 encoding with `AiError.Unsupported`
27
+ * (bucket 1) via {@link assertEncoding}, rather than silently returning a
28
+ * mislabeled float32 vector.
29
29
  */
30
- type EmbedEncoding = "float32" | "int8" | "binary" | "sparse" | "multivector";
30
+ type EmbedEncoding = "float32" | "int8" | "binary";
31
31
  /**
32
32
  * Cross-provider single-embed request. Mirrors the shape of
33
33
  * `LanguageModel.CommonRequest`: cross-cutting fields here, vendor
@@ -81,12 +81,12 @@ type CommonEmbedManyRequest = Omit<CommonEmbedRequest, "input"> & {
81
81
  * narrowing. Defaults to `undefined` for back-compat with consumers that
82
82
  * use the bare `EmbedResponse` name.
83
83
  */
84
- type EmbedResponse<E extends EmbedEncoding | undefined = undefined> = {
84
+ type EmbedResponse<E extends ResponseEncoding | undefined = undefined> = {
85
85
  readonly embedding: EmbeddingFor<E>;
86
86
  readonly usage: Usage;
87
87
  };
88
88
  /** Batch-embed response. Same encoding rule as {@link EmbedResponse}. */
89
- type EmbedManyResponse<E extends EmbedEncoding | undefined = undefined> = {
89
+ type EmbedManyResponse<E extends ResponseEncoding | undefined = undefined> = {
90
90
  readonly embeddings: ReadonlyArray<EmbeddingFor<E>>;
91
91
  readonly usage: Usage;
92
92
  };
@@ -108,6 +108,19 @@ declare const embed: <E extends EmbedEncoding | undefined = undefined>(request:
108
108
  declare const embedMany: <E extends EmbedEncoding | undefined = undefined>(request: Omit<CommonEmbedManyRequest, "encoding"> & {
109
109
  readonly encoding?: E;
110
110
  }) => Effect.Effect<EmbedManyResponse<E>, AiError, EmbeddingModel>;
111
+ /**
112
+ * Guard a requested `encoding` against a provider's supported set. Returns
113
+ * `void` when the encoding is unset or supported, and fails
114
+ * `AiError.Unsupported` (bucket 1) otherwise.
115
+ *
116
+ * Used by the generic-tag registration of providers that emit a strict
117
+ * subset of `EmbedEncoding`: OpenAI / Gemini pass `["float32"]`, Jina passes
118
+ * `["float32", "binary"]`. Without this guard, a non-supported encoding on
119
+ * the generic path silently returns a float32 vector mislabeled as the
120
+ * requested type (the `as`-cast lie), which breaks downstream storage and
121
+ * vector math.
122
+ */
123
+ declare const assertEncoding: (encoding: EmbedEncoding | undefined, supported: ReadonlyArray<EmbedEncoding>, provider: string) => Effect.Effect<void, AiError>;
111
124
  //#endregion
112
- export { CommonEmbedManyRequest, CommonEmbedRequest, EmbedEncoding, EmbedManyResponse, EmbedResponse, EmbeddingModel, EmbeddingModelService, embed, embedMany, EmbeddingModel_d_exports as t };
125
+ export { CommonEmbedManyRequest, CommonEmbedRequest, EmbedEncoding, EmbedManyResponse, EmbedResponse, EmbeddingModel, EmbeddingModelService, assertEncoding, embed, embedMany, EmbeddingModel_d_exports as t };
113
126
  //# sourceMappingURL=EmbeddingModel.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EmbeddingModel.d.mts","names":[],"sources":["../../src/embedding-model/EmbeddingModel.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyBA;;;;;AAYA;;KAZY,aAAA;;;;;;;;;;;KAYA,kBAAA;EAAA,SACD,KAAA,EAAO,UAAA;;;;;WAKP,KAAA;EA6BqB;;;;;;;EAAA,SArBrB,IAAA;EAqBgC;AAU3C;;;;EAV2C,SAfhC,UAAA;EA0BW;;;;;EAAA,SApBX,QAAA,GAAW,aAAA;AAAA;;;;;;KAQV,sBAAA,GAAyB,IAAA,CAAK,kBAAA;EAAA,SAC/B,MAAA,EAAQ,aAAA,CAAc,UAAA;AAAA;;;;;;;;KAUrB,aAAA,WAAwB,aAAA;EAAA,SACzB,SAAA,EAAW,YAAA,CAAa,CAAA;EAAA,SACxB,KAAA,EAAO,KAAA;AAAA;;KAIN,iBAAA,WAA4B,aAAA;EAAA,SAC7B,UAAA,EAAY,aAAA,CAAc,YAAA,CAAa,CAAA;EAAA,SACvC,KAAA,EAAO,KAAA;AAAA;AAAA,KAGN,qBAAA;EAAA,SACD,KAAA,aAAkB,aAAA,0BACzB,OAAA,EAAS,IAAA,CAAK,kBAAA;IAAA,SAA6C,QAAA,GAAW,CAAA;EAAA,MACnE,MAAA,CAAO,MAAA,CAAO,aAAA,CAAc,CAAA,GAAI,OAAA;EAAA,SAC5B,SAAA,aAAsB,aAAA,0BAC7B,OAAA,EAAS,IAAA,CAAK,sBAAA;IAAA,SAAiD,QAAA,GAAW,CAAA;EAAA,MACvE,MAAA,CAAO,MAAA,CAAO,iBAAA,CAAkB,CAAA,GAAI,OAAA;AAAA;AAAA,cAC1C,mBAAA;cAEY,cAAA,SAAuB,mBAAA;;cAKvB,KAAA,aAAmB,aAAA,0BAC9B,OAAA,EAAS,IAAA,CAAK,kBAAA;EAAA,SAA6C,QAAA,GAAW,CAAA;AAAA,MACrE,MAAA,CAAO,MAAA,CAAO,aAAA,CAAc,CAAA,GAAI,OAAA,EAAiB,cAAA;;cAIvC,SAAA,aAAuB,aAAA,0BAClC,OAAA,EAAS,IAAA,CAAK,sBAAA;EAAA,SAAiD,QAAA,GAAW,CAAA;AAAA,MACzE,MAAA,CAAO,MAAA,CAAO,iBAAA,CAAkB,CAAA,GAAI,OAAA,EAAiB,cAAA"}
1
+ {"version":3,"file":"EmbeddingModel.d.mts","names":[],"sources":["../../src/embedding-model/EmbeddingModel.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyBA;;;;;AAYA;KAZY,aAAA;;;;;;;;;;;KAYA,kBAAA;EAAA,SACD,KAAA,EAAO,UAAA;EAiCgB;;;;EAAA,SA5BvB,KAAA;EA6BQ;;;;;;;EAAA,SArBR,IAAA;EAqBgC;;AAU3C;;;EAV2C,SAfhC,UAAA;EA0BwB;;;;;EAAA,SApBxB,QAAA,GAAW,aAAA;AAAA;;;;;;KAQV,sBAAA,GAAyB,IAAA,CAAK,kBAAA;EAAA,SAC/B,MAAA,EAAQ,aAAA,CAAc,UAAA;AAAA;;;;;;;;KAUrB,aAAA,WAAwB,gBAAA;EAAA,SACzB,SAAA,EAAW,YAAA,CAAa,CAAA;EAAA,SACxB,KAAA,EAAO,KAAA;AAAA;;KAIN,iBAAA,WAA4B,gBAAA;EAAA,SAC7B,UAAA,EAAY,aAAA,CAAc,YAAA,CAAa,CAAA;EAAA,SACvC,KAAA,EAAO,KAAA;AAAA;AAAA,KAGN,qBAAA;EAAA,SACD,KAAA,aAAkB,aAAA,0BACzB,OAAA,EAAS,IAAA,CAAK,kBAAA;IAAA,SAA6C,QAAA,GAAW,CAAA;EAAA,MACnE,MAAA,CAAO,MAAA,CAAO,aAAA,CAAc,CAAA,GAAI,OAAA;EAAA,SAC5B,SAAA,aAAsB,aAAA,0BAC7B,OAAA,EAAS,IAAA,CAAK,sBAAA;IAAA,SAAiD,QAAA,GAAW,CAAA;EAAA,MACvE,MAAA,CAAO,MAAA,CAAO,iBAAA,CAAkB,CAAA,GAAI,OAAA;AAAA;AAAA,cAC1C,mBAAA;cAEY,cAAA,SAAuB,mBAAA;;cAKvB,KAAA,aAAmB,aAAA,0BAC9B,OAAA,EAAS,IAAA,CAAK,kBAAA;EAAA,SAA6C,QAAA,GAAW,CAAA;AAAA,MACrE,MAAA,CAAO,MAAA,CAAO,aAAA,CAAc,CAAA,GAAI,OAAA,EAAiB,cAAA;;cAIvC,SAAA,aAAuB,aAAA,0BAClC,OAAA,EAAS,IAAA,CAAK,sBAAA;EAAA,SAAiD,QAAA,GAAW,CAAA;AAAA,MACzE,MAAA,CAAO,MAAA,CAAO,iBAAA,CAAkB,CAAA,GAAI,OAAA,EAAiB,cAAA;;;;;;;;;;;;;cAe3C,cAAA,GACX,QAAA,EAAU,aAAA,cACV,SAAA,EAAW,aAAA,CAAc,aAAA,GACzB,QAAA,aACC,MAAA,CAAO,MAAA,OAAa,OAAA"}
@@ -1,8 +1,10 @@
1
1
  import { n as __exportAll } from "../chunk-uyGKjUfl.mjs";
2
+ import { Unsupported } from "../domain/AiError.mjs";
2
3
  import { Context, Effect } from "effect";
3
4
  //#region src/embedding-model/EmbeddingModel.ts
4
5
  var EmbeddingModel_exports = /* @__PURE__ */ __exportAll({
5
6
  EmbeddingModel: () => EmbeddingModel,
7
+ assertEncoding: () => assertEncoding,
6
8
  embed: () => embed,
7
9
  embedMany: () => embedMany
8
10
  });
@@ -11,7 +13,24 @@ var EmbeddingModel = class extends Context.Service()("@betalyra/effect-uai/Embed
11
13
  const embed = (request) => Effect.flatMap(EmbeddingModel.asEffect(), (m) => m.embed(request));
12
14
  /** Embed a batch in one provider call. Same `task` for every input. */
13
15
  const embedMany = (request) => Effect.flatMap(EmbeddingModel.asEffect(), (m) => m.embedMany(request));
16
+ /**
17
+ * Guard a requested `encoding` against a provider's supported set. Returns
18
+ * `void` when the encoding is unset or supported, and fails
19
+ * `AiError.Unsupported` (bucket 1) otherwise.
20
+ *
21
+ * Used by the generic-tag registration of providers that emit a strict
22
+ * subset of `EmbedEncoding`: OpenAI / Gemini pass `["float32"]`, Jina passes
23
+ * `["float32", "binary"]`. Without this guard, a non-supported encoding on
24
+ * the generic path silently returns a float32 vector mislabeled as the
25
+ * requested type (the `as`-cast lie), which breaks downstream storage and
26
+ * vector math.
27
+ */
28
+ const assertEncoding = (encoding, supported, provider) => encoding === void 0 || supported.includes(encoding) ? Effect.void : Effect.fail(new Unsupported({
29
+ provider,
30
+ capability: "encoding",
31
+ reason: `${provider} emits ${supported.join(" / ")} only; encoding="${encoding}" is unavailable.`
32
+ }));
14
33
  //#endregion
15
- export { EmbeddingModel, embed, embedMany, EmbeddingModel_exports as t };
34
+ export { EmbeddingModel, assertEncoding, embed, embedMany, EmbeddingModel_exports as t };
16
35
 
17
36
  //# sourceMappingURL=EmbeddingModel.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"EmbeddingModel.mjs","names":[],"sources":["../../src/embedding-model/EmbeddingModel.ts"],"sourcesContent":["import { Context, Effect } from \"effect\"\nimport * as AiError from \"../domain/AiError.js\"\nimport type { EmbeddingFor, EmbedInput, Usage } from \"./Embedding.js\"\n\n/**\n * Output representation requested from the provider.\n *\n * Dense quantizations - same vector at different storage cost:\n * - `float32` — universal default.\n * - `int8` — ~4x smaller; minimal recall loss on most benchmarks.\n * - `binary` — ~32x smaller; meaningful recall loss but pairs well with\n * a float32 reranker pass over a small candidate set.\n *\n * Non-dense representations:\n * - `sparse` — learned sparse vector for hybrid (dense + lexical) search.\n * Currently Jina ELSER only on hosted APIs.\n * - `multivector` — one vector per token for late-interaction (ColBERT-\n * style) scoring via `Vector.maxSim`. Currently Jina v4 only.\n *\n * Each provider's typed request narrows this to its supported set at\n * compile time (e.g. `JinaEmbedEncoding = \"float32\" | \"binary\" | \"sparse\" |\n * \"multivector\"`). On the generic `EmbeddingModel` path, callers can\n * pass any `EmbedEncoding` and the provider's API will reject mismatches at\n * runtime.\n */\nexport type EmbedEncoding = \"float32\" | \"int8\" | \"binary\" | \"sparse\" | \"multivector\"\n\n/**\n * Cross-provider single-embed request. Mirrors the shape of\n * `LanguageModel.CommonRequest`: cross-cutting fields here, vendor\n * specifics in the provider's typed request.\n *\n * Provider-specific extensions (Cohere widened `task` enum, Jina LoRA\n * tasks, Mixedbread free-form `prompt`, etc.) live in that provider's own\n * request interface, which extends this and narrows `model` / widens\n * `task`.\n */\nexport type CommonEmbedRequest = {\n readonly input: EmbedInput\n /**\n * Model identifier. Each provider narrows this to its typed literal\n * union, so code that yields a typed provider tag gets autocompletion.\n */\n readonly model: string\n /**\n * Retrieval-task hint. Applies to the input. OpenAI ignores this;\n * Mixedbread doesn't have it; Cohere v3+ requires it on the wire (typed\n * as required in `CohereEmbedRequest`). Provider-specific task enums\n * (classification, clustering, code retrieval, …) live on the\n * provider's own request type.\n */\n readonly task?: \"query\" | \"document\"\n /**\n * Matryoshka truncation. Default: provider's native dimension.\n * Discrete-value providers (Cohere, Vertex `multimodalembedding@001`)\n * narrow this to a literal union in their typed request.\n */\n readonly dimensions?: number\n /**\n * Output representation - see {@link EmbedEncoding}. Dense float32 is the\n * default; provider layers reject unsupported values up front with\n * `InvalidRequest`.\n */\n readonly encoding?: EmbedEncoding\n}\n\n/**\n * Cross-provider batch-embed request. One `task` for the whole batch -\n * mixed-task batches aren't a real provider feature (rerankers exist for\n * that).\n */\nexport type CommonEmbedManyRequest = Omit<CommonEmbedRequest, \"input\"> & {\n readonly inputs: ReadonlyArray<EmbedInput>\n}\n\n/**\n * Single-embed response. The `embedding` type is determined by the\n * request's `encoding` field via `EmbeddingFor<E>` — callers that don't\n * specify an encoding get a `Float32Embedding` directly with no runtime\n * narrowing. Defaults to `undefined` for back-compat with consumers that\n * use the bare `EmbedResponse` name.\n */\nexport type EmbedResponse<E extends EmbedEncoding | undefined = undefined> = {\n readonly embedding: EmbeddingFor<E>\n readonly usage: Usage\n}\n\n/** Batch-embed response. Same encoding rule as {@link EmbedResponse}. */\nexport type EmbedManyResponse<E extends EmbedEncoding | undefined = undefined> = {\n readonly embeddings: ReadonlyArray<EmbeddingFor<E>>\n readonly usage: Usage\n}\n\nexport type EmbeddingModelService = {\n readonly embed: <E extends EmbedEncoding | undefined = undefined>(\n request: Omit<CommonEmbedRequest, \"encoding\"> & { readonly encoding?: E },\n ) => Effect.Effect<EmbedResponse<E>, AiError.AiError>\n readonly embedMany: <E extends EmbedEncoding | undefined = undefined>(\n request: Omit<CommonEmbedManyRequest, \"encoding\"> & { readonly encoding?: E },\n ) => Effect.Effect<EmbedManyResponse<E>, AiError.AiError>\n}\n\nexport class EmbeddingModel extends Context.Service<EmbeddingModel, EmbeddingModelService>()(\n \"@betalyra/effect-uai/EmbeddingModel\",\n) {}\n\n/** Embed a single input. */\nexport const embed = <E extends EmbedEncoding | undefined = undefined>(\n request: Omit<CommonEmbedRequest, \"encoding\"> & { readonly encoding?: E },\n): Effect.Effect<EmbedResponse<E>, AiError.AiError, EmbeddingModel> =>\n Effect.flatMap(EmbeddingModel.asEffect(), (m) => m.embed(request))\n\n/** Embed a batch in one provider call. Same `task` for every input. */\nexport const embedMany = <E extends EmbedEncoding | undefined = undefined>(\n request: Omit<CommonEmbedManyRequest, \"encoding\"> & { readonly encoding?: E },\n): Effect.Effect<EmbedManyResponse<E>, AiError.AiError, EmbeddingModel> =>\n Effect.flatMap(EmbeddingModel.asEffect(), (m) => m.embedMany(request))\n"],"mappings":";;;;;;;;AAsGA,IAAa,iBAAb,cAAoC,QAAQ,SAAgD,CAC1F,sCACD,CAAC;;AAGF,MAAa,SACX,YAEA,OAAO,QAAQ,eAAe,UAAU,GAAG,MAAM,EAAE,MAAM,QAAQ,CAAC;;AAGpE,MAAa,aACX,YAEA,OAAO,QAAQ,eAAe,UAAU,GAAG,MAAM,EAAE,UAAU,QAAQ,CAAC"}
1
+ {"version":3,"file":"EmbeddingModel.mjs","names":["AiError.Unsupported"],"sources":["../../src/embedding-model/EmbeddingModel.ts"],"sourcesContent":["import { Context, Effect } from \"effect\"\nimport * as AiError from \"../domain/AiError.js\"\nimport type { EmbeddingFor, EmbedInput, ResponseEncoding, Usage } from \"./Embedding.js\"\n\n/**\n * Output representation requested from the provider. Cross-provider dense\n * quantization only, the same vector at different storage cost:\n * - `float32`: universal default.\n * - `int8`: ~4x smaller, minimal recall loss on most benchmarks. Supported\n * by Cohere, Voyage, Jina (binary only), Mixedbread.\n * - `binary`: ~32x smaller, meaningful recall loss but pairs well with a\n * float32 reranker pass over a small candidate set.\n *\n * Non-dense representations (`sparse`, `multivector`) are a different vector\n * *structure*, not a storage option, and are produced by Jina only. They\n * live on `JinaEncoding`, not here (the same widening pattern `task` uses).\n * The response `Embedding` union still carries all arms, see\n * {@link ResponseEncoding}.\n *\n * Each provider's typed request narrows this to its supported set. On the\n * generic `EmbeddingModel` path, a provider that emits float32 only (OpenAI,\n * Gemini) rejects a non-float32 encoding with `AiError.Unsupported`\n * (bucket 1) via {@link assertEncoding}, rather than silently returning a\n * mislabeled float32 vector.\n */\nexport type EmbedEncoding = \"float32\" | \"int8\" | \"binary\"\n\n/**\n * Cross-provider single-embed request. Mirrors the shape of\n * `LanguageModel.CommonRequest`: cross-cutting fields here, vendor\n * specifics in the provider's typed request.\n *\n * Provider-specific extensions (Cohere widened `task` enum, Jina LoRA\n * tasks, Mixedbread free-form `prompt`, etc.) live in that provider's own\n * request interface, which extends this and narrows `model` / widens\n * `task`.\n */\nexport type CommonEmbedRequest = {\n readonly input: EmbedInput\n /**\n * Model identifier. Each provider narrows this to its typed literal\n * union, so code that yields a typed provider tag gets autocompletion.\n */\n readonly model: string\n /**\n * Retrieval-task hint. Applies to the input. OpenAI ignores this;\n * Mixedbread doesn't have it; Cohere v3+ requires it on the wire (typed\n * as required in `CohereEmbedRequest`). Provider-specific task enums\n * (classification, clustering, code retrieval, …) live on the\n * provider's own request type.\n */\n readonly task?: \"query\" | \"document\"\n /**\n * Matryoshka truncation. Default: provider's native dimension.\n * Discrete-value providers (Cohere, Vertex `multimodalembedding@001`)\n * narrow this to a literal union in their typed request.\n */\n readonly dimensions?: number\n /**\n * Output representation - see {@link EmbedEncoding}. Dense float32 is the\n * default; provider layers reject unsupported values up front with\n * `InvalidRequest`.\n */\n readonly encoding?: EmbedEncoding\n}\n\n/**\n * Cross-provider batch-embed request. One `task` for the whole batch -\n * mixed-task batches aren't a real provider feature (rerankers exist for\n * that).\n */\nexport type CommonEmbedManyRequest = Omit<CommonEmbedRequest, \"input\"> & {\n readonly inputs: ReadonlyArray<EmbedInput>\n}\n\n/**\n * Single-embed response. The `embedding` type is determined by the\n * request's `encoding` field via `EmbeddingFor<E>` — callers that don't\n * specify an encoding get a `Float32Embedding` directly with no runtime\n * narrowing. Defaults to `undefined` for back-compat with consumers that\n * use the bare `EmbedResponse` name.\n */\nexport type EmbedResponse<E extends ResponseEncoding | undefined = undefined> = {\n readonly embedding: EmbeddingFor<E>\n readonly usage: Usage\n}\n\n/** Batch-embed response. Same encoding rule as {@link EmbedResponse}. */\nexport type EmbedManyResponse<E extends ResponseEncoding | undefined = undefined> = {\n readonly embeddings: ReadonlyArray<EmbeddingFor<E>>\n readonly usage: Usage\n}\n\nexport type EmbeddingModelService = {\n readonly embed: <E extends EmbedEncoding | undefined = undefined>(\n request: Omit<CommonEmbedRequest, \"encoding\"> & { readonly encoding?: E },\n ) => Effect.Effect<EmbedResponse<E>, AiError.AiError>\n readonly embedMany: <E extends EmbedEncoding | undefined = undefined>(\n request: Omit<CommonEmbedManyRequest, \"encoding\"> & { readonly encoding?: E },\n ) => Effect.Effect<EmbedManyResponse<E>, AiError.AiError>\n}\n\nexport class EmbeddingModel extends Context.Service<EmbeddingModel, EmbeddingModelService>()(\n \"@betalyra/effect-uai/EmbeddingModel\",\n) {}\n\n/** Embed a single input. */\nexport const embed = <E extends EmbedEncoding | undefined = undefined>(\n request: Omit<CommonEmbedRequest, \"encoding\"> & { readonly encoding?: E },\n): Effect.Effect<EmbedResponse<E>, AiError.AiError, EmbeddingModel> =>\n Effect.flatMap(EmbeddingModel.asEffect(), (m) => m.embed(request))\n\n/** Embed a batch in one provider call. Same `task` for every input. */\nexport const embedMany = <E extends EmbedEncoding | undefined = undefined>(\n request: Omit<CommonEmbedManyRequest, \"encoding\"> & { readonly encoding?: E },\n): Effect.Effect<EmbedManyResponse<E>, AiError.AiError, EmbeddingModel> =>\n Effect.flatMap(EmbeddingModel.asEffect(), (m) => m.embedMany(request))\n\n/**\n * Guard a requested `encoding` against a provider's supported set. Returns\n * `void` when the encoding is unset or supported, and fails\n * `AiError.Unsupported` (bucket 1) otherwise.\n *\n * Used by the generic-tag registration of providers that emit a strict\n * subset of `EmbedEncoding`: OpenAI / Gemini pass `[\"float32\"]`, Jina passes\n * `[\"float32\", \"binary\"]`. Without this guard, a non-supported encoding on\n * the generic path silently returns a float32 vector mislabeled as the\n * requested type (the `as`-cast lie), which breaks downstream storage and\n * vector math.\n */\nexport const assertEncoding = (\n encoding: EmbedEncoding | undefined,\n supported: ReadonlyArray<EmbedEncoding>,\n provider: string,\n): Effect.Effect<void, AiError.AiError> =>\n encoding === undefined || supported.includes(encoding)\n ? Effect.void\n : Effect.fail(\n new AiError.Unsupported({\n provider,\n capability: \"encoding\",\n reason: `${provider} emits ${supported.join(\" / \")} only; encoding=\"${encoding}\" is unavailable.`,\n }),\n )\n"],"mappings":";;;;;;;;;;AAsGA,IAAa,iBAAb,cAAoC,QAAQ,SAAgD,CAC1F,sCACD,CAAC;;AAGF,MAAa,SACX,YAEA,OAAO,QAAQ,eAAe,UAAU,GAAG,MAAM,EAAE,MAAM,QAAQ,CAAC;;AAGpE,MAAa,aACX,YAEA,OAAO,QAAQ,eAAe,UAAU,GAAG,MAAM,EAAE,UAAU,QAAQ,CAAC;;;;;;;;;;;;;AAcxE,MAAa,kBACX,UACA,WACA,aAEA,aAAa,KAAA,KAAa,UAAU,SAAS,SAAS,GAClD,OAAO,OACP,OAAO,KACL,IAAIA,YAAoB;CACtB;CACA,YAAY;CACZ,QAAQ,GAAG,SAAS,SAAS,UAAU,KAAK,MAAM,CAAC,mBAAmB,SAAS;CAChF,CAAC,CACH"}
@@ -5,7 +5,7 @@ describe("EmbedResponse<E> conditional narrowing", () => {
5
5
  it("defaults to Float32Embedding when E is undefined", () => {
6
6
  (0, import_dist.expectTypeOf)().toEqualTypeOf();
7
7
  });
8
- it("maps each EmbedEncoding literal to the matching Embedding variant", () => {
8
+ it("maps each encoding literal to the matching Embedding variant", () => {
9
9
  (0, import_dist.expectTypeOf)().toEqualTypeOf();
10
10
  (0, import_dist.expectTypeOf)().toEqualTypeOf();
11
11
  (0, import_dist.expectTypeOf)().toEqualTypeOf();
@@ -38,13 +38,25 @@ describe("embed / embedMany free exports preserve E in their return type", () =>
38
38
  encoding: "int8"
39
39
  })).toEqualTypeOf();
40
40
  });
41
- it("embedMany with encoding: multivector returns EmbedManyResponse<multivector>", () => {
41
+ it("embedMany with encoding: binary returns EmbedManyResponse<binary>", () => {
42
42
  (0, import_dist.expectTypeOf)(embedMany({
43
43
  inputs: ["x"],
44
44
  model: "m",
45
- encoding: "multivector"
45
+ encoding: "binary"
46
46
  })).toEqualTypeOf();
47
47
  });
48
+ it("rejects non-dense encodings on the generic path (trimmed EmbedEncoding)", () => {
49
+ embedMany({
50
+ inputs: ["x"],
51
+ model: "m",
52
+ encoding: "multivector"
53
+ });
54
+ embed({
55
+ input: "x",
56
+ model: "m",
57
+ encoding: "sparse"
58
+ });
59
+ });
48
60
  it("when the request is widened to CommonEmbedRequest, the response is the open union", () => {
49
61
  (0, import_dist.expectTypeOf)(embed({
50
62
  input: "x",
@@ -1 +1 @@
1
- {"version":3,"file":"EmbeddingModel.test.mjs","names":[],"sources":["../../src/embedding-model/EmbeddingModel.test.ts"],"sourcesContent":["import { Effect } from \"effect\"\nimport { describe, expectTypeOf, it } from \"vitest\"\nimport type * as AiError from \"../domain/AiError.js\"\nimport type {\n BinaryEmbedding,\n Float32Embedding,\n Int8Embedding,\n MultivectorEmbedding,\n SparseEmbedding,\n} from \"./Embedding.js\"\nimport {\n type EmbedEncoding,\n embed,\n embedMany,\n type EmbedManyResponse,\n type EmbedResponse,\n EmbeddingModel,\n} from \"./EmbeddingModel.js\"\n\n// Type-level tests only. The actual narrowing happens at the type system\n// boundary — the runtime impl is exercised in provider-specific test files.\ndescribe(\"EmbedResponse<E> conditional narrowing\", () => {\n it(\"defaults to Float32Embedding when E is undefined\", () => {\n expectTypeOf<EmbedResponse>().toEqualTypeOf<{\n readonly embedding: Float32Embedding\n readonly usage: import(\"./Embedding.js\").Usage\n }>()\n })\n\n it(\"maps each EmbedEncoding literal to the matching Embedding variant\", () => {\n expectTypeOf<EmbedResponse<\"float32\">[\"embedding\"]>().toEqualTypeOf<Float32Embedding>()\n expectTypeOf<EmbedResponse<\"int8\">[\"embedding\"]>().toEqualTypeOf<Int8Embedding>()\n expectTypeOf<EmbedResponse<\"binary\">[\"embedding\"]>().toEqualTypeOf<BinaryEmbedding>()\n expectTypeOf<EmbedResponse<\"sparse\">[\"embedding\"]>().toEqualTypeOf<SparseEmbedding>()\n expectTypeOf<EmbedResponse<\"multivector\">[\"embedding\"]>().toEqualTypeOf<MultivectorEmbedding>()\n })\n\n it(\"falls back to the open Embedding union when E is the full EmbedEncoding\", () => {\n expectTypeOf<EmbedResponse<EmbedEncoding>[\"embedding\"]>().toEqualTypeOf<\n Float32Embedding | Int8Embedding | BinaryEmbedding | SparseEmbedding | MultivectorEmbedding\n >()\n })\n})\n\ndescribe(\"EmbedManyResponse<E> mirrors EmbedResponse<E>\", () => {\n it(\"defaults to ReadonlyArray<Float32Embedding>\", () => {\n expectTypeOf<EmbedManyResponse[\"embeddings\"]>().toEqualTypeOf<ReadonlyArray<Float32Embedding>>()\n })\n\n it(\"narrows per encoding\", () => {\n expectTypeOf<EmbedManyResponse<\"int8\">[\"embeddings\"]>().toEqualTypeOf<\n ReadonlyArray<Int8Embedding>\n >()\n })\n})\n\ndescribe(\"embed / embedMany free exports preserve E in their return type\", () => {\n it(\"embed with no encoding returns EmbedResponse<undefined> = Float32\", () => {\n const result = embed({ input: \"x\", model: \"m\" })\n expectTypeOf(result).toEqualTypeOf<\n Effect.Effect<EmbedResponse<undefined>, AiError.AiError, EmbeddingModel>\n >()\n })\n\n it(\"embed with encoding: int8 returns EmbedResponse<int8>\", () => {\n const result = embed({ input: \"x\", model: \"m\", encoding: \"int8\" })\n expectTypeOf(result).toEqualTypeOf<\n Effect.Effect<EmbedResponse<\"int8\">, AiError.AiError, EmbeddingModel>\n >()\n })\n\n it(\"embedMany with encoding: multivector returns EmbedManyResponse<multivector>\", () => {\n const result = embedMany({ inputs: [\"x\"], model: \"m\", encoding: \"multivector\" })\n expectTypeOf(result).toEqualTypeOf<\n Effect.Effect<EmbedManyResponse<\"multivector\">, AiError.AiError, EmbeddingModel>\n >()\n })\n\n it(\"when the request is widened to CommonEmbedRequest, the response is the open union\", () => {\n // Demonstrates the documented case: annotating the request type erases\n // the literal `encoding` and the response falls back to `Embedding`.\n const req: { input: string; model: string; encoding?: EmbedEncoding } = {\n input: \"x\",\n model: \"m\",\n encoding: \"int8\",\n }\n const result = embed(req)\n expectTypeOf(result).toEqualTypeOf<\n Effect.Effect<EmbedResponse<EmbedEncoding>, AiError.AiError, EmbeddingModel>\n >()\n })\n})\n"],"mappings":";;;AAqBA,SAAS,gDAAgD;AACvD,IAAG,0DAA0D;AAC3D,GAAA,GAAA,YAAA,eAA6B,CAAC,eAG1B;GACJ;AAEF,IAAG,2EAA2E;AAC5E,GAAA,GAAA,YAAA,eAAqD,CAAC,eAAiC;AACvF,GAAA,GAAA,YAAA,eAAkD,CAAC,eAA8B;AACjF,GAAA,GAAA,YAAA,eAAoD,CAAC,eAAgC;AACrF,GAAA,GAAA,YAAA,eAAoD,CAAC,eAAgC;AACrF,GAAA,GAAA,YAAA,eAAyD,CAAC,eAAqC;GAC/F;AAEF,IAAG,iFAAiF;AAClF,GAAA,GAAA,YAAA,eAAyD,CAAC,eAEvD;GACH;EACF;AAEF,SAAS,uDAAuD;AAC9D,IAAG,qDAAqD;AACtD,GAAA,GAAA,YAAA,eAA+C,CAAC,eAAgD;GAChG;AAEF,IAAG,8BAA8B;AAC/B,GAAA,GAAA,YAAA,eAAuD,CAAC,eAErD;GACH;EACF;AAEF,SAAS,wEAAwE;AAC/E,IAAG,2EAA2E;AAE5E,GAAA,GAAA,YAAA,cADe,MAAM;GAAE,OAAO;GAAK,OAAO;GAAK,CAC5B,CAAC,CAAC,eAElB;GACH;AAEF,IAAG,+DAA+D;AAEhE,GAAA,GAAA,YAAA,cADe,MAAM;GAAE,OAAO;GAAK,OAAO;GAAK,UAAU;GAAQ,CAC9C,CAAC,CAAC,eAElB;GACH;AAEF,IAAG,qFAAqF;AAEtF,GAAA,GAAA,YAAA,cADe,UAAU;GAAE,QAAQ,CAAC,IAAI;GAAE,OAAO;GAAK,UAAU;GAAe,CAC5D,CAAC,CAAC,eAElB;GACH;AAEF,IAAG,2FAA2F;AAS5F,GAAA,GAAA,YAAA,cADe,MAAM;GAJnB,OAAO;GACP,OAAO;GACP,UAAU;GAEY,CACL,CAAC,CAAC,eAElB;GACH;EACF"}
1
+ {"version":3,"file":"EmbeddingModel.test.mjs","names":[],"sources":["../../src/embedding-model/EmbeddingModel.test.ts"],"sourcesContent":["import { Effect } from \"effect\"\nimport { describe, expectTypeOf, it } from \"vitest\"\nimport type * as AiError from \"../domain/AiError.js\"\nimport type {\n BinaryEmbedding,\n Float32Embedding,\n Int8Embedding,\n MultivectorEmbedding,\n SparseEmbedding,\n} from \"./Embedding.js\"\nimport {\n type EmbedEncoding,\n embed,\n embedMany,\n type EmbedManyResponse,\n type EmbedResponse,\n EmbeddingModel,\n} from \"./EmbeddingModel.js\"\n\n// Type-level tests only. The actual narrowing happens at the type system\n// boundary — the runtime impl is exercised in provider-specific test files.\ndescribe(\"EmbedResponse<E> conditional narrowing\", () => {\n it(\"defaults to Float32Embedding when E is undefined\", () => {\n expectTypeOf<EmbedResponse>().toEqualTypeOf<{\n readonly embedding: Float32Embedding\n readonly usage: import(\"./Embedding.js\").Usage\n }>()\n })\n\n it(\"maps each encoding literal to the matching Embedding variant\", () => {\n expectTypeOf<EmbedResponse<\"float32\">[\"embedding\"]>().toEqualTypeOf<Float32Embedding>()\n expectTypeOf<EmbedResponse<\"int8\">[\"embedding\"]>().toEqualTypeOf<Int8Embedding>()\n expectTypeOf<EmbedResponse<\"binary\">[\"embedding\"]>().toEqualTypeOf<BinaryEmbedding>()\n expectTypeOf<EmbedResponse<\"sparse\">[\"embedding\"]>().toEqualTypeOf<SparseEmbedding>()\n expectTypeOf<EmbedResponse<\"multivector\">[\"embedding\"]>().toEqualTypeOf<MultivectorEmbedding>()\n })\n\n it(\"falls back to the open Embedding union when E is the full EmbedEncoding\", () => {\n expectTypeOf<EmbedResponse<EmbedEncoding>[\"embedding\"]>().toEqualTypeOf<\n Float32Embedding | Int8Embedding | BinaryEmbedding | SparseEmbedding | MultivectorEmbedding\n >()\n })\n})\n\ndescribe(\"EmbedManyResponse<E> mirrors EmbedResponse<E>\", () => {\n it(\"defaults to ReadonlyArray<Float32Embedding>\", () => {\n expectTypeOf<EmbedManyResponse[\"embeddings\"]>().toEqualTypeOf<ReadonlyArray<Float32Embedding>>()\n })\n\n it(\"narrows per encoding\", () => {\n expectTypeOf<EmbedManyResponse<\"int8\">[\"embeddings\"]>().toEqualTypeOf<\n ReadonlyArray<Int8Embedding>\n >()\n })\n})\n\ndescribe(\"embed / embedMany free exports preserve E in their return type\", () => {\n it(\"embed with no encoding returns EmbedResponse<undefined> = Float32\", () => {\n const result = embed({ input: \"x\", model: \"m\" })\n expectTypeOf(result).toEqualTypeOf<\n Effect.Effect<EmbedResponse<undefined>, AiError.AiError, EmbeddingModel>\n >()\n })\n\n it(\"embed with encoding: int8 returns EmbedResponse<int8>\", () => {\n const result = embed({ input: \"x\", model: \"m\", encoding: \"int8\" })\n expectTypeOf(result).toEqualTypeOf<\n Effect.Effect<EmbedResponse<\"int8\">, AiError.AiError, EmbeddingModel>\n >()\n })\n\n it(\"embedMany with encoding: binary returns EmbedManyResponse<binary>\", () => {\n const result = embedMany({ inputs: [\"x\"], model: \"m\", encoding: \"binary\" })\n expectTypeOf(result).toEqualTypeOf<\n Effect.Effect<EmbedManyResponse<\"binary\">, AiError.AiError, EmbeddingModel>\n >()\n })\n\n it(\"rejects non-dense encodings on the generic path (trimmed EmbedEncoding)\", () => {\n // `sparse` / `multivector` are Jina-only representation kinds, not part\n // of the cross-provider request set. Requesting them on the generic\n // helper is a compile error; they're reachable only via the typed\n // `JinaEmbedding` tag.\n // @ts-expect-error \"multivector\" is not an EmbedEncoding\n embedMany({ inputs: [\"x\"], model: \"m\", encoding: \"multivector\" })\n // @ts-expect-error \"sparse\" is not an EmbedEncoding\n embed({ input: \"x\", model: \"m\", encoding: \"sparse\" })\n })\n\n it(\"when the request is widened to CommonEmbedRequest, the response is the open union\", () => {\n // Demonstrates the documented case: annotating the request type erases\n // the literal `encoding` and the response falls back to `Embedding`.\n const req: { input: string; model: string; encoding?: EmbedEncoding } = {\n input: \"x\",\n model: \"m\",\n encoding: \"int8\",\n }\n const result = embed(req)\n expectTypeOf(result).toEqualTypeOf<\n Effect.Effect<EmbedResponse<EmbedEncoding>, AiError.AiError, EmbeddingModel>\n >()\n })\n})\n"],"mappings":";;;AAqBA,SAAS,gDAAgD;AACvD,IAAG,0DAA0D;AAC3D,GAAA,GAAA,YAAA,eAA6B,CAAC,eAG1B;GACJ;AAEF,IAAG,sEAAsE;AACvE,GAAA,GAAA,YAAA,eAAqD,CAAC,eAAiC;AACvF,GAAA,GAAA,YAAA,eAAkD,CAAC,eAA8B;AACjF,GAAA,GAAA,YAAA,eAAoD,CAAC,eAAgC;AACrF,GAAA,GAAA,YAAA,eAAoD,CAAC,eAAgC;AACrF,GAAA,GAAA,YAAA,eAAyD,CAAC,eAAqC;GAC/F;AAEF,IAAG,iFAAiF;AAClF,GAAA,GAAA,YAAA,eAAyD,CAAC,eAEvD;GACH;EACF;AAEF,SAAS,uDAAuD;AAC9D,IAAG,qDAAqD;AACtD,GAAA,GAAA,YAAA,eAA+C,CAAC,eAAgD;GAChG;AAEF,IAAG,8BAA8B;AAC/B,GAAA,GAAA,YAAA,eAAuD,CAAC,eAErD;GACH;EACF;AAEF,SAAS,wEAAwE;AAC/E,IAAG,2EAA2E;AAE5E,GAAA,GAAA,YAAA,cADe,MAAM;GAAE,OAAO;GAAK,OAAO;GAAK,CAC5B,CAAC,CAAC,eAElB;GACH;AAEF,IAAG,+DAA+D;AAEhE,GAAA,GAAA,YAAA,cADe,MAAM;GAAE,OAAO;GAAK,OAAO;GAAK,UAAU;GAAQ,CAC9C,CAAC,CAAC,eAElB;GACH;AAEF,IAAG,2EAA2E;AAE5E,GAAA,GAAA,YAAA,cADe,UAAU;GAAE,QAAQ,CAAC,IAAI;GAAE,OAAO;GAAK,UAAU;GAAU,CACvD,CAAC,CAAC,eAElB;GACH;AAEF,IAAG,iFAAiF;AAMlF,YAAU;GAAE,QAAQ,CAAC,IAAI;GAAE,OAAO;GAAK,UAAU;GAAe,CAAC;AAEjE,QAAM;GAAE,OAAO;GAAK,OAAO;GAAK,UAAU;GAAU,CAAC;GACrD;AAEF,IAAG,2FAA2F;AAS5F,GAAA,GAAA,YAAA,cADe,MAAM;GAJnB,OAAO;GACP,OAAO;GACP,UAAU;GAEY,CACL,CAAC,CAAC,eAElB;GACH;EACF"}
package/dist/index.d.mts CHANGED
@@ -1,29 +1,35 @@
1
+ import { t as Capabilities_d_exports } from "./capabilities/Capabilities.mjs";
1
2
  import { n as AiError_d_exports } from "./AiError-CAX_48RU.mjs";
2
3
  import { a as Media_d_exports } from "./Media-D_CpcM1Z.mjs";
3
- import { o as Audio_d_exports } from "./Audio-BfCTGnH3.mjs";
4
+ import { o as Audio_d_exports } from "./Audio-DPlTsNdz.mjs";
4
5
  import { o as Image_d_exports } from "./Image-HNmMpMTh.mjs";
5
- import { f as Items_d_exports } from "./Items-BH8xUkoR.mjs";
6
+ import { u as Items_d_exports } from "./Items-D8UaXQx_.mjs";
6
7
  import { t as Music_d_exports } from "./domain/Music.mjs";
7
8
  import { t as Transcript_d_exports } from "./domain/Transcript.mjs";
8
9
  import { a as StructuredFormat_d_exports } from "./StructuredFormat-BbN4dosH.mjs";
9
- import { a as Turn_d_exports } from "./Turn-0CwCAyVe.mjs";
10
+ import { t as Turn_d_exports } from "./domain/Turn.mjs";
10
11
  import { t as Embedding_d_exports } from "./embedding-model/Embedding.mjs";
11
12
  import { t as EmbeddingModel_d_exports } from "./embedding-model/EmbeddingModel.mjs";
12
- import { l as Tool_d_exports } from "./Tool-87ViKCCO.mjs";
13
+ import { l as Tool_d_exports } from "./Tool-CiFXYjmR.mjs";
13
14
  import { t as LanguageModel_d_exports } from "./language-model/LanguageModel.mjs";
14
15
  import { t as MusicGenerator_d_exports } from "./music-generator/MusicGenerator.mjs";
16
+ import { t as Memory_d_exports } from "./sandbox/Memory.mjs";
17
+ import { o as SandboxError_d_exports } from "./SandboxError-BvKypkJm.mjs";
18
+ import { t as Sandbox_d_exports } from "./sandbox/Sandbox.mjs";
19
+ import { t as SandboxImage_d_exports } from "./sandbox/SandboxImage.mjs";
20
+ import { t as SandboxNetwork_d_exports } from "./sandbox/SandboxNetwork.mjs";
15
21
  import { t as SpeechSynthesizer_d_exports } from "./speech-synthesizer/SpeechSynthesizer.mjs";
16
22
  import { t as Transcriber_d_exports } from "./transcriber/Transcriber.mjs";
17
23
  import { t as Vector_d_exports } from "./math/Vector.mjs";
18
24
  import { t as Loop_d_exports } from "./loop/Loop.mjs";
19
25
  import { t as Retry_d_exports } from "./retry/Retry.mjs";
20
- import { t as Outcome_d_exports } from "./tool/Outcome.mjs";
26
+ import { t as ToolResult_d_exports } from "./tool/ToolResult.mjs";
21
27
  import { t as ToolEvent_d_exports } from "./tool/ToolEvent.mjs";
22
28
  import { t as Toolkit_d_exports } from "./tool/Toolkit.mjs";
23
- import { t as Resolvers_d_exports } from "./tool/Resolvers.mjs";
29
+ import { t as Approval_d_exports } from "./tool/Approval.mjs";
24
30
  import { t as HistoryCheck_d_exports } from "./tool/HistoryCheck.mjs";
25
31
  import { t as JSONL_d_exports } from "./streaming/JSONL.mjs";
26
32
  import { t as Lines_d_exports } from "./streaming/Lines.mjs";
27
33
  import { t as SSE_d_exports } from "./streaming/SSE.mjs";
28
34
  import { t as Metrics_d_exports } from "./observability/Metrics.mjs";
29
- export { AiError_d_exports as AiError, Audio_d_exports as Audio, Embedding_d_exports as Embedding, EmbeddingModel_d_exports as EmbeddingModel, HistoryCheck_d_exports as HistoryCheck, Image_d_exports as Image, Items_d_exports as Items, JSONL_d_exports as JSONL, LanguageModel_d_exports as LanguageModel, Lines_d_exports as Lines, Loop_d_exports as Loop, Media_d_exports as Media, Metrics_d_exports as Metrics, Music_d_exports as Music, MusicGenerator_d_exports as MusicGenerator, Outcome_d_exports as Outcome, Resolvers_d_exports as Resolvers, Retry_d_exports as Retry, SSE_d_exports as SSE, SpeechSynthesizer_d_exports as SpeechSynthesizer, StructuredFormat_d_exports as StructuredFormat, Tool_d_exports as Tool, ToolEvent_d_exports as ToolEvent, Toolkit_d_exports as Toolkit, Transcriber_d_exports as Transcriber, Transcript_d_exports as Transcript, Turn_d_exports as Turn, Vector_d_exports as Vector };
35
+ export { AiError_d_exports as AiError, Approval_d_exports as Approval, Audio_d_exports as Audio, Capabilities_d_exports as Capabilities, Embedding_d_exports as Embedding, EmbeddingModel_d_exports as EmbeddingModel, HistoryCheck_d_exports as HistoryCheck, Image_d_exports as Image, Items_d_exports as Items, JSONL_d_exports as JSONL, LanguageModel_d_exports as LanguageModel, Lines_d_exports as Lines, Loop_d_exports as Loop, Media_d_exports as Media, Memory_d_exports as Memory, Metrics_d_exports as Metrics, Music_d_exports as Music, MusicGenerator_d_exports as MusicGenerator, Retry_d_exports as Retry, SSE_d_exports as SSE, Sandbox_d_exports as Sandbox, SandboxError_d_exports as SandboxError, SandboxImage_d_exports as SandboxImage, SandboxNetwork_d_exports as SandboxNetwork, SpeechSynthesizer_d_exports as SpeechSynthesizer, StructuredFormat_d_exports as StructuredFormat, Tool_d_exports as Tool, ToolEvent_d_exports as ToolEvent, ToolResult_d_exports as ToolResult, Toolkit_d_exports as Toolkit, Transcriber_d_exports as Transcriber, Transcript_d_exports as Transcript, Turn_d_exports as Turn, Vector_d_exports as Vector };
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { t as AiError_exports } from "./domain/AiError.mjs";
2
2
  import { t as Audio_exports } from "./domain/Audio.mjs";
3
+ import { t as Capabilities_exports } from "./capabilities/Capabilities.mjs";
3
4
  import { t as Image_exports } from "./domain/Image.mjs";
4
5
  import { t as Items_exports } from "./domain/Items.mjs";
5
6
  import { t as Media_exports } from "./domain/Media.mjs";
@@ -11,19 +12,24 @@ import { t as Embedding_exports } from "./embedding-model/Embedding.mjs";
11
12
  import { t as EmbeddingModel_exports } from "./embedding-model/EmbeddingModel.mjs";
12
13
  import { t as LanguageModel_exports } from "./language-model/LanguageModel.mjs";
13
14
  import { t as MusicGenerator_exports } from "./music-generator/MusicGenerator.mjs";
15
+ import { t as Memory_exports } from "./sandbox/Memory.mjs";
16
+ import { t as Sandbox_exports } from "./sandbox/Sandbox.mjs";
17
+ import { t as SandboxError_exports } from "./sandbox/SandboxError.mjs";
18
+ import { t as SandboxImage_exports } from "./sandbox/SandboxImage.mjs";
19
+ import { t as SandboxNetwork_exports } from "./sandbox/SandboxNetwork.mjs";
14
20
  import { t as SpeechSynthesizer_exports } from "./speech-synthesizer/SpeechSynthesizer.mjs";
15
21
  import { t as Transcriber_exports } from "./transcriber/Transcriber.mjs";
16
22
  import { t as Vector_exports } from "./math/Vector.mjs";
17
23
  import { t as Loop_exports } from "./loop/Loop.mjs";
18
24
  import { t as Retry_exports } from "./retry/Retry.mjs";
19
25
  import { t as Tool_exports } from "./tool/Tool.mjs";
20
- import { t as Outcome_exports } from "./tool/Outcome.mjs";
26
+ import { t as ToolResult_exports } from "./tool/ToolResult.mjs";
21
27
  import { t as ToolEvent_exports } from "./tool/ToolEvent.mjs";
22
28
  import { t as Toolkit_exports } from "./tool/Toolkit.mjs";
23
- import { t as Resolvers_exports } from "./tool/Resolvers.mjs";
29
+ import { t as Approval_exports } from "./tool/Approval.mjs";
24
30
  import { t as HistoryCheck_exports } from "./tool/HistoryCheck.mjs";
25
31
  import { t as JSONL_exports } from "./streaming/JSONL.mjs";
26
32
  import { t as Lines_exports } from "./streaming/Lines.mjs";
27
33
  import { t as SSE_exports } from "./streaming/SSE.mjs";
28
34
  import { t as Metrics_exports } from "./observability/Metrics.mjs";
29
- export { AiError_exports as AiError, Audio_exports as Audio, Embedding_exports as Embedding, EmbeddingModel_exports as EmbeddingModel, HistoryCheck_exports as HistoryCheck, Image_exports as Image, Items_exports as Items, JSONL_exports as JSONL, LanguageModel_exports as LanguageModel, Lines_exports as Lines, Loop_exports as Loop, Media_exports as Media, Metrics_exports as Metrics, Music_exports as Music, MusicGenerator_exports as MusicGenerator, Outcome_exports as Outcome, Resolvers_exports as Resolvers, Retry_exports as Retry, SSE_exports as SSE, SpeechSynthesizer_exports as SpeechSynthesizer, StructuredFormat_exports as StructuredFormat, Tool_exports as Tool, ToolEvent_exports as ToolEvent, Toolkit_exports as Toolkit, Transcriber_exports as Transcriber, Transcript_exports as Transcript, Turn_exports as Turn, Vector_exports as Vector };
35
+ export { AiError_exports as AiError, Approval_exports as Approval, Audio_exports as Audio, Capabilities_exports as Capabilities, Embedding_exports as Embedding, EmbeddingModel_exports as EmbeddingModel, HistoryCheck_exports as HistoryCheck, Image_exports as Image, Items_exports as Items, JSONL_exports as JSONL, LanguageModel_exports as LanguageModel, Lines_exports as Lines, Loop_exports as Loop, Media_exports as Media, Memory_exports as Memory, Metrics_exports as Metrics, Music_exports as Music, MusicGenerator_exports as MusicGenerator, Retry_exports as Retry, SSE_exports as SSE, Sandbox_exports as Sandbox, SandboxError_exports as SandboxError, SandboxImage_exports as SandboxImage, SandboxNetwork_exports as SandboxNetwork, SpeechSynthesizer_exports as SpeechSynthesizer, StructuredFormat_exports as StructuredFormat, Tool_exports as Tool, ToolEvent_exports as ToolEvent, ToolResult_exports as ToolResult, Toolkit_exports as Toolkit, Transcriber_exports as Transcriber, Transcript_exports as Transcript, Turn_exports as Turn, Vector_exports as Vector };
@@ -1,8 +1,8 @@
1
1
  import { t as AiError } from "../AiError-CAX_48RU.mjs";
2
- import { d as Item } from "../Items-BH8xUkoR.mjs";
2
+ import { o as HistoryItem } from "../Items-D8UaXQx_.mjs";
3
3
  import { i as StructuredFormat } from "../StructuredFormat-BbN4dosH.mjs";
4
- import { i as TurnEvent, r as Turn } from "../Turn-0CwCAyVe.mjs";
5
- import { o as ToolDescriptor } from "../Tool-87ViKCCO.mjs";
4
+ import { Turn, TurnEvent } from "../domain/Turn.mjs";
5
+ import { o as ToolDescriptor } from "../Tool-CiFXYjmR.mjs";
6
6
  import { Context, Effect, Stream } from "effect";
7
7
 
8
8
  //#region src/language-model/LanguageModel.d.ts
@@ -16,7 +16,7 @@ declare namespace LanguageModel_d_exports {
16
16
  * ...) lives in that provider's own request interface, which extends this.
17
17
  */
18
18
  type CommonRequest = {
19
- readonly history: ReadonlyArray<Item>;
19
+ readonly history: ReadonlyArray<HistoryItem>;
20
20
  /**
21
21
  * Model identifier. Each provider narrows this to its typed literal union,
22
22
  * so code that yields a typed provider tag gets autocompletion.
@@ -32,7 +32,7 @@ type CommonRequest = {
32
32
  readonly maxOutputTokens?: number;
33
33
  /**
34
34
  * Schema-bound JSON output. The provider constrains the wire to match the
35
- * schema; pair with `Turn.toStructured` for runtime validation. Supported
35
+ * schema; pair with `Turn.decodeStructured` for runtime validation. Supported
36
36
  * across all current providers (OpenAI Responses json_schema, Anthropic
37
37
  * `output_config`, Gemini `responseJsonSchema`).
38
38
  */
@@ -1 +1 @@
1
- {"version":3,"file":"LanguageModel.d.mts","names":[],"sources":["../../src/language-model/LanguageModel.ts"],"mappings":";;;;;;;;;;;;;;;;;KAaY,aAAA;EAAA,SACD,OAAA,EAAS,aAAA,CAAc,IAAA;;;;AADlC;WAMW,KAAA;EAAA,SACA,KAAA,GAAQ,aAAA,CAAc,cAAA;EAAA,SACtB,UAAA;IAAA,SAIM,IAAA;IAAA,SAA2B,IAAA;EAAA;EAAA,SACjC,WAAA;EAAA,SACA,IAAA;EAAA,SACA,eAAA;EAdA;;;;;;EAAA,SAqBA,UAAA,GAAa,gBAAA;AAAA;AAAA,KAGZ,oBAAA;EAAA,SACD,UAAA,GAAa,OAAA,EAAS,aAAA,KAAkB,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW,OAAA;EAbjE;;;;;;;;AAYX;EAZW,SAuBA,IAAA,GAAO,OAAA,EAAS,aAAA,KAAkB,MAAA,CAAO,MAAA,CAAO,IAAA,EAAM,OAAA;AAAA;AAAA,cAChE,kBAAA;cAEY,aAAA,SAAsB,kBAAA;;;;cAOtB,UAAA,GACX,OAAA,EAAS,aAAA,KACR,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW,OAAA,EAAiB,aAAA;;;;;;;cAShC,IAAA,GAAQ,OAAA,EAAS,aAAA,KAAgB,MAAA,CAAO,MAAA,CAAO,IAAA,EAAM,OAAA,EAAiB,aAAA;;;;;;;cAStE,cAAA,QACL,UAAA,GAAa,OAAA,EAAS,GAAA,KAAQ,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW,OAAA,OAC5D,OAAA,EAAS,GAAA,KAAM,MAAA,CAAO,MAAA,CAAO,IAAA,EAAM,OAAA"}
1
+ {"version":3,"file":"LanguageModel.d.mts","names":[],"sources":["../../src/language-model/LanguageModel.ts"],"mappings":";;;;;;;;;;;;;;;;;KAaY,aAAA;EAAA,SACD,OAAA,EAAS,aAAA,CAAc,WAAA;;;;AADlC;WAMW,KAAA;EAAA,SACA,KAAA,GAAQ,aAAA,CAAc,cAAA;EAAA,SACtB,UAAA;IAAA,SAIM,IAAA;IAAA,SAA2B,IAAA;EAAA;EAAA,SACjC,WAAA;EAAA,SACA,IAAA;EAAA,SACA,eAAA;EAdA;;;;;;EAAA,SAqBA,UAAA,GAAa,gBAAA;AAAA;AAAA,KAGZ,oBAAA;EAAA,SACD,UAAA,GAAa,OAAA,EAAS,aAAA,KAAkB,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW,OAAA;EAbjE;;;;;;;;AAYX;EAZW,SAuBA,IAAA,GAAO,OAAA,EAAS,aAAA,KAAkB,MAAA,CAAO,MAAA,CAAO,IAAA,EAAM,OAAA;AAAA;AAAA,cAChE,kBAAA;cAEY,aAAA,SAAsB,kBAAA;;;;cAOtB,UAAA,GACX,OAAA,EAAS,aAAA,KACR,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW,OAAA,EAAiB,aAAA;;;;;;;cAShC,IAAA,GAAQ,OAAA,EAAS,aAAA,KAAgB,MAAA,CAAO,MAAA,CAAO,IAAA,EAAM,OAAA,EAAiB,aAAA;;;;;;;cAStE,cAAA,QACL,UAAA,GAAa,OAAA,EAAS,GAAA,KAAQ,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW,OAAA,OAC5D,OAAA,EAAS,GAAA,KAAM,MAAA,CAAO,MAAA,CAAO,IAAA,EAAM,OAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"LanguageModel.mjs","names":["Arr","AiError.IncompleteTurn"],"sources":["../../src/language-model/LanguageModel.ts"],"sourcesContent":["import { Array as Arr, Context, Effect, Option, Stream } from \"effect\"\nimport * as AiError from \"../domain/AiError.js\"\nimport type { Item } from \"../domain/Items.js\"\nimport type * as StructuredFormat from \"../structured-format/StructuredFormat.js\"\nimport type { ToolDescriptor } from \"../tool/Tool.js\"\nimport { isTurnComplete, type Turn, type TurnEvent } from \"../domain/Turn.js\"\n\n/**\n * Cross-provider request shape. Every call carries its own `history` and\n * `model` - models are not bound at layer construction. Anything specific\n * to a single provider (reasoning effort, prompt caching, store flags,\n * ...) lives in that provider's own request interface, which extends this.\n */\nexport type CommonRequest = {\n readonly history: ReadonlyArray<Item>\n /**\n * Model identifier. Each provider narrows this to its typed literal union,\n * so code that yields a typed provider tag gets autocompletion.\n */\n readonly model: string\n readonly tools?: ReadonlyArray<ToolDescriptor>\n readonly toolChoice?:\n | \"auto\"\n | \"required\"\n | \"none\"\n | { readonly type: \"function\"; readonly name: string }\n readonly temperature?: number\n readonly topP?: number\n readonly maxOutputTokens?: number\n /**\n * Schema-bound JSON output. The provider constrains the wire to match the\n * schema; pair with `Turn.toStructured` for runtime validation. Supported\n * across all current providers (OpenAI Responses json_schema, Anthropic\n * `output_config`, Gemini `responseJsonSchema`).\n */\n readonly structured?: StructuredFormat.StructuredFormat<unknown>\n}\n\nexport type LanguageModelService = {\n readonly streamTurn: (request: CommonRequest) => Stream.Stream<TurnEvent, AiError.AiError>\n /**\n * Drain a single turn and return the assembled `Turn` from the\n * terminal `TurnComplete` event. Fails with `IncompleteTurn` if the\n * stream ends without one.\n *\n * Most providers derive this from `streamTurn` via\n * {@link turnFromStream}; providers with a native non-streaming\n * endpoint may override with a cheaper direct call.\n */\n readonly turn: (request: CommonRequest) => Effect.Effect<Turn, AiError.AiError>\n}\n\nexport class LanguageModel extends Context.Service<LanguageModel, LanguageModelService>()(\n \"@betalyra/effect-uai/LanguageModel\",\n) {}\n\n/**\n * Stream the deltas of a single turn.\n */\nexport const streamTurn = (\n request: CommonRequest,\n): Stream.Stream<TurnEvent, AiError.AiError, LanguageModel> =>\n Stream.unwrap(Effect.map(LanguageModel.asEffect(), (m) => m.streamTurn(request)))\n\n/**\n * Drain a single turn and return the assembled `Turn`. Delegates to the\n * service's `turn` method — providers with a native complete endpoint\n * can override; the rest get the default streamTurn-drain via\n * {@link turnFromStream}.\n */\nexport const turn = (request: CommonRequest): Effect.Effect<Turn, AiError.AiError, LanguageModel> =>\n Effect.flatMap(LanguageModel.asEffect(), (m) => m.turn(request))\n\n/**\n * Build a `turn` implementation from a `streamTurn` implementation.\n * Providers without a native non-streaming endpoint use this to\n * populate the service's `turn` field. Generic over the request type so\n * provider-typed services (with their narrowed request) can reuse it.\n */\nexport const turnFromStream =\n <Req>(streamTurn: (request: Req) => Stream.Stream<TurnEvent, AiError.AiError>) =>\n (request: Req): Effect.Effect<Turn, AiError.AiError> =>\n streamTurn(request).pipe(\n Stream.runCollect,\n Effect.flatMap((events) =>\n Arr.findLast(events, isTurnComplete).pipe(\n Option.match({\n onNone: () => Effect.fail(new AiError.IncompleteTurn({})),\n onSome: (e) => Effect.succeed(e.turn),\n }),\n ),\n ),\n )\n"],"mappings":";;;;;;;;;;;AAoDA,IAAa,gBAAb,cAAmC,QAAQ,SAA8C,CACvF,qCACD,CAAC;;;;AAKF,MAAa,cACX,YAEA,OAAO,OAAO,OAAO,IAAI,cAAc,UAAU,GAAG,MAAM,EAAE,WAAW,QAAQ,CAAC,CAAC;;;;;;;AAQnF,MAAa,QAAQ,YACnB,OAAO,QAAQ,cAAc,UAAU,GAAG,MAAM,EAAE,KAAK,QAAQ,CAAC;;;;;;;AAQlE,MAAa,kBACL,gBACL,YACC,WAAW,QAAQ,CAAC,KAClB,OAAO,YACP,OAAO,SAAS,WACdA,MAAI,SAAS,QAAQ,eAAe,CAAC,KACnC,OAAO,MAAM;CACX,cAAc,OAAO,KAAK,IAAIC,eAAuB,EAAE,CAAC,CAAC;CACzD,SAAS,MAAM,OAAO,QAAQ,EAAE,KAAK;CACtC,CAAC,CACH,CACF,CACF"}
1
+ {"version":3,"file":"LanguageModel.mjs","names":["Arr","AiError.IncompleteTurn"],"sources":["../../src/language-model/LanguageModel.ts"],"sourcesContent":["import { Array as Arr, Context, Effect, Option, Stream } from \"effect\"\nimport * as AiError from \"../domain/AiError.js\"\nimport type { HistoryItem } from \"../domain/Items.js\"\nimport type * as StructuredFormat from \"../structured-format/StructuredFormat.js\"\nimport type { ToolDescriptor } from \"../tool/Tool.js\"\nimport { isTurnComplete, type Turn, type TurnEvent } from \"../domain/Turn.js\"\n\n/**\n * Cross-provider request shape. Every call carries its own `history` and\n * `model` - models are not bound at layer construction. Anything specific\n * to a single provider (reasoning effort, prompt caching, store flags,\n * ...) lives in that provider's own request interface, which extends this.\n */\nexport type CommonRequest = {\n readonly history: ReadonlyArray<HistoryItem>\n /**\n * Model identifier. Each provider narrows this to its typed literal union,\n * so code that yields a typed provider tag gets autocompletion.\n */\n readonly model: string\n readonly tools?: ReadonlyArray<ToolDescriptor>\n readonly toolChoice?:\n | \"auto\"\n | \"required\"\n | \"none\"\n | { readonly type: \"function\"; readonly name: string }\n readonly temperature?: number\n readonly topP?: number\n readonly maxOutputTokens?: number\n /**\n * Schema-bound JSON output. The provider constrains the wire to match the\n * schema; pair with `Turn.decodeStructured` for runtime validation. Supported\n * across all current providers (OpenAI Responses json_schema, Anthropic\n * `output_config`, Gemini `responseJsonSchema`).\n */\n readonly structured?: StructuredFormat.StructuredFormat<unknown>\n}\n\nexport type LanguageModelService = {\n readonly streamTurn: (request: CommonRequest) => Stream.Stream<TurnEvent, AiError.AiError>\n /**\n * Drain a single turn and return the assembled `Turn` from the\n * terminal `TurnComplete` event. Fails with `IncompleteTurn` if the\n * stream ends without one.\n *\n * Most providers derive this from `streamTurn` via\n * {@link turnFromStream}; providers with a native non-streaming\n * endpoint may override with a cheaper direct call.\n */\n readonly turn: (request: CommonRequest) => Effect.Effect<Turn, AiError.AiError>\n}\n\nexport class LanguageModel extends Context.Service<LanguageModel, LanguageModelService>()(\n \"@betalyra/effect-uai/LanguageModel\",\n) {}\n\n/**\n * Stream the deltas of a single turn.\n */\nexport const streamTurn = (\n request: CommonRequest,\n): Stream.Stream<TurnEvent, AiError.AiError, LanguageModel> =>\n Stream.unwrap(Effect.map(LanguageModel.asEffect(), (m) => m.streamTurn(request)))\n\n/**\n * Drain a single turn and return the assembled `Turn`. Delegates to the\n * service's `turn` method — providers with a native complete endpoint\n * can override; the rest get the default streamTurn-drain via\n * {@link turnFromStream}.\n */\nexport const turn = (request: CommonRequest): Effect.Effect<Turn, AiError.AiError, LanguageModel> =>\n Effect.flatMap(LanguageModel.asEffect(), (m) => m.turn(request))\n\n/**\n * Build a `turn` implementation from a `streamTurn` implementation.\n * Providers without a native non-streaming endpoint use this to\n * populate the service's `turn` field. Generic over the request type so\n * provider-typed services (with their narrowed request) can reuse it.\n */\nexport const turnFromStream =\n <Req>(streamTurn: (request: Req) => Stream.Stream<TurnEvent, AiError.AiError>) =>\n (request: Req): Effect.Effect<Turn, AiError.AiError> =>\n streamTurn(request).pipe(\n Stream.runCollect,\n Effect.flatMap((events) =>\n Arr.findLast(events, isTurnComplete).pipe(\n Option.match({\n onNone: () => Effect.fail(new AiError.IncompleteTurn({})),\n onSome: (e) => Effect.succeed(e.turn),\n }),\n ),\n ),\n )\n"],"mappings":";;;;;;;;;;;AAoDA,IAAa,gBAAb,cAAmC,QAAQ,SAA8C,CACvF,qCACD,CAAC;;;;AAKF,MAAa,cACX,YAEA,OAAO,OAAO,OAAO,IAAI,cAAc,UAAU,GAAG,MAAM,EAAE,WAAW,QAAQ,CAAC,CAAC;;;;;;;AAQnF,MAAa,QAAQ,YACnB,OAAO,QAAQ,cAAc,UAAU,GAAG,MAAM,EAAE,KAAK,QAAQ,CAAC;;;;;;;AAQlE,MAAa,kBACL,gBACL,YACC,WAAW,QAAQ,CAAC,KAClB,OAAO,YACP,OAAO,SAAS,WACdA,MAAI,SAAS,QAAQ,eAAe,CAAC,KACnC,OAAO,MAAM;CACX,cAAc,OAAO,KAAK,IAAIC,eAAuB,EAAE,CAAC,CAAC;CACzD,SAAS,MAAM,OAAO,QAAQ,EAAE,KAAK;CACtC,CAAC,CACH,CACF,CACF"}
@@ -1,26 +1,26 @@
1
1
  import { l as IncompleteTurn } from "../AiError-CAX_48RU.mjs";
2
- import { i as TurnEvent, r as Turn } from "../Turn-0CwCAyVe.mjs";
2
+ import { Turn, TurnEvent } from "../domain/Turn.mjs";
3
3
  import { Data, Effect, Stream, SubscriptionRef } from "effect";
4
4
 
5
5
  //#region src/loop/Loop.d.ts
6
6
  declare namespace Loop_d_exports {
7
- export { Event, loop, loopFrom, loopWithState, next, nextAfter, nextAfterFold, onTurnComplete, stop, stopAfter, stopEvent, stopWith, stopWithAfter, value };
7
+ export { Step, loop, loopOver, loopWithState, next, onTurnComplete, stop, value };
8
8
  }
9
9
  /**
10
10
  * The tagged union a body emits per pull. `Value` carries a payload that
11
11
  * flows downstream. `Next` ends the current iteration and continues with a
12
12
  * new state. `Stop` ends the loop entirely with no carried state.
13
- * `StopWith` also ends the loop but carries a final state that `loopFrom`
13
+ * `StopWith` also ends the loop but carries a final state that `loopOver`
14
14
  * will thread to the next input and `loopWithState` will write to its
15
15
  * `SubscriptionRef` before the loop ends. Plain `loop` has no next
16
16
  * iteration to apply it to and treats `StopWith` like `Stop`.
17
17
  *
18
- * `Stop` is intentionally `{}` so the bare `stopEvent` / `stop` helpers
19
- * don't constrain `S` from a body's stream type — every body has a `Stop`
18
+ * `Stop` is intentionally `{}` so the bare `stop()` helper doesn't
19
+ * constrain `S` from a body's stream type — every body has a `Stop`
20
20
  * variant in its union, and forcing `S` to flow through it would break
21
- * inference whenever the body never uses `next` / `stopWith`.
21
+ * inference whenever the body never uses `next` / `stop(state)`.
22
22
  */
23
- type Event<A, S> = Data.TaggedEnum<{
23
+ type Step<A, S> = Data.TaggedEnum<{
24
24
  Value: {
25
25
  readonly value: A;
26
26
  };
@@ -33,80 +33,27 @@ type Event<A, S> = Data.TaggedEnum<{
33
33
  };
34
34
  }>;
35
35
  /** Wrap a value so it flows through the loop to downstream consumers. */
36
- declare const value: <A>(a: A) => Event<A, never>;
37
- /** End the current iteration and continue with a new state. */
38
- declare const next: <S>(state: S) => Event<never, S>;
36
+ declare const value: <A>(a: A) => Step<A, never>;
39
37
  /**
40
- * The terminal `Stop` event with no carried state. Use `stop` (the Stream)
41
- * to end a loop body without communicating a final state.
38
+ * End the current iteration and continue with a new state. Emits a single
39
+ * terminal `Next` step as a one-element stream, so it slots directly into a
40
+ * loop body or after a run of values: `values.pipe(Stream.concat(next(s)))`.
42
41
  */
43
- declare const stopEvent: Event<never, never>;
42
+ declare const next: <S>(state: S) => Stream.Stream<Step<never, S>>;
44
43
  /**
45
- * Terminal event that ends the loop AND carries a final state. For
46
- * `loopFrom` this is the natural "this input is done, here's the state to
47
- * carry forward to the next input" signal — symmetric with `next(s)` but
48
- * ending the inner loop instead of continuing it. For `loopWithState` the
49
- * carried state is written to the `SubscriptionRef` before the loop ends.
44
+ * End the loop. Called with no argument it emits a bare `Stop`; called with
45
+ * a state it emits `StopWith(state)` — `loopOver` threads that final state
46
+ * to the next input and `loopWithState` writes it to its `SubscriptionRef`
47
+ * before the loop ends. Either way it returns a single-element stream, so
48
+ * return it directly from a loop body.
50
49
  */
51
- declare const stopWith: <S>(state: S) => Event<never, S>;
50
+ declare const stop: <S = never>(state?: S) => Stream.Stream<Step<never, S>>;
52
51
  /**
53
- * A single-element stream that ends the loop. Return this from a body when
54
- * there's nothing else to emit; equivalent to `stopAfter(Stream.empty)` but
55
- * named for the common case.
56
- */
57
- declare const stop: Stream.Stream<Event<never, never>>;
58
- /**
59
- * Pipe a raw `Stream<A>` into the loop's emit shape, then terminate the
60
- * iteration with `next(state)`. Common shape for "stream this turn's
61
- * deltas, then continue with updated history."
62
- *
63
- * Dual: data-first `nextAfter(stream, state)` and data-last
64
- * `stream.pipe(nextAfter(state))` both work.
65
- */
66
- declare const nextAfter: {
67
- <S>(state: S): <A, E, R>(stream: Stream.Stream<A, E, R>) => Stream.Stream<Event<A, S>, E, R>;
68
- <S, A, E, R>(stream: Stream.Stream<A, E, R>, state: S): Stream.Stream<Event<A, S>, E, R>;
69
- };
70
- /**
71
- * Pipe a raw `Stream<A>` into the loop's emit shape, then terminate the
72
- * loop. Common shape for "stream this turn's deltas, then we're done."
73
- *
74
- * Unary on the stream — already pipe-compatible via `stream.pipe(stopAfter)`.
75
- */
76
- declare const stopAfter: <A, E, R>(stream: Stream.Stream<A, E, R>) => Stream.Stream<Event<A, never>, E, R>;
77
- /**
78
- * Pipe a raw `Stream<A>` into the loop's emit shape, then terminate with
79
- * `stopWith(state)`. The natural "emit final outputs, advance state, end
80
- * this input's inner loop" shape for `loopFrom`.
81
- *
82
- * Dual: data-first `stopWithAfter(stream, state)` and data-last
83
- * `stream.pipe(stopWithAfter(state))` both work.
84
- */
85
- declare const stopWithAfter: {
86
- <S>(state: S): <A, E, R>(stream: Stream.Stream<A, E, R>) => Stream.Stream<Event<A, S>, E, R>;
87
- <S, A, E, R>(stream: Stream.Stream<A, E, R>, state: S): Stream.Stream<Event<A, S>, E, R>;
88
- };
89
- /**
90
- * General `nextAfter` variant: drain `stream` to the consumer, fold elements
91
- * into an accumulator, and at end-of-stream emit one `next(build(finalAcc))`.
92
- *
93
- * Subsumes `nextAfter` when state is constant (`reduce: (s, _) => s`,
94
- * `build: (s) => s`). Used by `Toolkit.continueWith` to collect tool
95
- * results and build next state without exposing a Ref to recipes.
96
- *
97
- * Dual: data-first `nextAfterFold(stream, initial, reduce, build)` and
98
- * data-last `stream.pipe(nextAfterFold(initial, reduce, build))` both work.
99
- */
100
- declare const nextAfterFold: {
101
- <A, B, S>(initial: B, reduce: (acc: B, a: A) => B, build: (b: B) => S): <E, R>(stream: Stream.Stream<A, E, R>) => Stream.Stream<Event<A, S>, E, R>;
102
- <A, B, S, E, R>(stream: Stream.Stream<A, E, R>, initial: B, reduce: (acc: B, a: A) => B, build: (b: B) => S): Stream.Stream<Event<A, S>, E, R>;
103
- };
104
- /**
105
- * Lift a provider's `Stream<TurnEvent>` into a loop body's `Stream<Event<TurnEvent | A, S>>`.
52
+ * Lift a provider's `Stream<TurnEvent>` into a loop body's `Stream<Step<TurnEvent | A, S>>`.
106
53
  * Each delta passes through as `value(delta)` (including the terminal
107
54
  * `TurnComplete`, so the consumer sees turn boundaries naturally). Once
108
55
  * the terminal arrives, `then(turn)` runs and its returned stream of loop
109
- * events (typically tool outputs followed by `next(state)` or `stop`) is
56
+ * steps (typically tool outputs followed by `next(state)` or `stop()`) is
110
57
  * concatenated.
111
58
  *
112
59
  * Pre-pipe transforms (`Stream.tap` / `Stream.map` / `Stream.filter`) on
@@ -120,14 +67,14 @@ declare const nextAfterFold: {
120
67
  * `deltas.pipe(onTurnComplete(then))` both work.
121
68
  */
122
69
  declare const onTurnComplete: {
123
- <S, A, E2 = never, R2 = never>(then: (turn: Turn) => Effect.Effect<Stream.Stream<Event<A, S>, E2, R2>, E2, R2>): <E, R>(deltas: Stream.Stream<TurnEvent, E, R>) => Stream.Stream<Event<TurnEvent | A, S>, E | E2 | IncompleteTurn, R | R2>;
124
- <S, A, E, R, E2 = never, R2 = never>(deltas: Stream.Stream<TurnEvent, E, R>, then: (turn: Turn) => Effect.Effect<Stream.Stream<Event<A, S>, E2, R2>, E2, R2>): Stream.Stream<Event<TurnEvent | A, S>, E | E2 | IncompleteTurn, R | R2>;
70
+ <S, A, E2 = never, R2 = never>(then: (turn: Turn) => Effect.Effect<Stream.Stream<Step<A, S>, E2, R2>, E2, R2>): <E, R>(deltas: Stream.Stream<TurnEvent, E, R>) => Stream.Stream<Step<TurnEvent | A, S>, E | E2 | IncompleteTurn, R | R2>;
71
+ <S, A, E, R, E2 = never, R2 = never>(deltas: Stream.Stream<TurnEvent, E, R>, then: (turn: Turn) => Effect.Effect<Stream.Stream<Step<A, S>, E2, R2>, E2, R2>): Stream.Stream<Step<TurnEvent | A, S>, E | E2 | IncompleteTurn, R | R2>;
125
72
  };
126
- type LoopBody<S, A, E, R> = (state: S) => Stream.Stream<Event<A, S>, E, R> | Effect.Effect<Stream.Stream<Event<A, S>, E, R>, E, R>;
73
+ type LoopBody<S, A, E, R> = (state: S) => Stream.Stream<Step<A, S>, E, R> | Effect.Effect<Stream.Stream<Step<A, S>, E, R>, E, R>;
127
74
  /**
128
75
  * Drive a state-threaded loop body. Each iteration runs `body(state)` to get
129
- * a `Stream<Event<A, S>>`; values flow downstream, `next(s)` continues with
130
- * a new state, `stop` ends the loop. See the file header for the full
76
+ * a `Stream<Step<A, S>>`; values flow downstream, `next(s)` continues with
77
+ * a new state, `stop()` ends the loop. See the file header for the full
131
78
  * pull-based execution model.
132
79
  *
133
80
  * Dual: data-first `loop(initial, body)` and data-last `loop(body)(initial)`
@@ -137,40 +84,40 @@ declare const loop: {
137
84
  <S, A, E, R>(body: LoopBody<S, A, E, R>): (initial: S) => Stream.Stream<A, E, R>;
138
85
  <S, A, E, R>(initial: S, body: LoopBody<S, A, E, R>): Stream.Stream<A, E, R>;
139
86
  };
140
- type LoopFromBody<S, I, A, E, R> = (state: S, input: I) => Stream.Stream<Event<A, S>, E, R> | Effect.Effect<Stream.Stream<Event<A, S>, E, R>, E, R>;
87
+ type LoopOverBody<S, I, A, E, R> = (state: S, input: I) => Stream.Stream<Step<A, S>, E, R> | Effect.Effect<Stream.Stream<Step<A, S>, E, R>, E, R>;
141
88
  /**
142
89
  * Input-driven sibling of `loop`. For each item pulled from the input
143
90
  * stream, runs an inner seed-driven `loop` whose body is
144
91
  * `(s) => body(s, item)`. State is threaded across input items.
145
92
  *
146
- * **Per-input semantics — the body emits standard `Event<A, S>`:**
93
+ * **Per-input semantics — the body emits standard `Step<A, S>`:**
147
94
  * - `value(a)`: emit `a` downstream
148
95
  * - `next(s)`: re-run the body with the SAME input and new state `s`
149
96
  * (multi-turn within one input — e.g. multiple model turns + tool
150
97
  * calls for one document)
151
- * - `stop`: end this input's inner loop, advance to the next input
98
+ * - `stop()`: end this input's inner loop, advance to the next input
152
99
  * (state preserved)
153
- * - body stream ending without a decision: same as `stop` (advance)
100
+ * - body stream ending without a decision: same as `stop()` (advance)
154
101
  *
155
102
  * **Outer termination:** the input stream ending. To halt programmatically
156
103
  * from within, end the input stream upstream (`Stream.takeWhile`, a
157
- * `SubscriptionRef` gate, etc.). Reserving `stop` for per-item
104
+ * `SubscriptionRef` gate, etc.). Reserving `stop()` for per-item
158
105
  * advancement is what makes the common "stream of documents, multi-turn
159
106
  * conversation per document" shape readable.
160
107
  *
161
- * Dual: data-first `loopFrom(input, initial, body)` and data-last
162
- * `input.pipe(loopFrom(initial, body))` both work.
108
+ * Dual: data-first `loopOver(input, initial, body)` and data-last
109
+ * `input.pipe(loopOver(initial, body))` both work.
163
110
  */
164
- declare const loopFrom: {
165
- <S, I, A, E, R>(initial: S, body: LoopFromBody<S, I, A, E, R>): <EI, RI>(input: Stream.Stream<I, EI, RI>) => Stream.Stream<A, E | EI, R | RI>;
166
- <S, I, A, E, R, EI, RI>(input: Stream.Stream<I, EI, RI>, initial: S, body: LoopFromBody<S, I, A, E, R>): Stream.Stream<A, E | EI, R | RI>;
111
+ declare const loopOver: {
112
+ <S, I, A, E, R>(initial: S, body: LoopOverBody<S, I, A, E, R>): <EI, RI>(input: Stream.Stream<I, EI, RI>) => Stream.Stream<A, E | EI, R | RI>;
113
+ <S, I, A, E, R, EI, RI>(input: Stream.Stream<I, EI, RI>, initial: S, body: LoopOverBody<S, I, A, E, R>): Stream.Stream<A, E | EI, R | RI>;
167
114
  };
168
115
  /**
169
116
  * Like `loop`, but exposes the current loop state as a `SubscriptionRef`
170
117
  * alongside the value stream.
171
118
  *
172
119
  * Allocates one `SubscriptionRef<S>` seeded with `initial`, then runs the
173
- * loop with a wrapped body that taps every `Next(s)` event into the ref
120
+ * loop with a wrapped body that taps every `Next(s)` step into the ref
174
121
  * before forwarding it. The caller decides how to consume both channels:
175
122
  *
176
123
  * - **Final state**: drain the stream, then `SubscriptionRef.get(state)`
@@ -190,5 +137,5 @@ declare const loopWithState: <S, A, E, R>(initial: S, body: LoopBody<S, A, E, R>
190
137
  readonly state: SubscriptionRef.SubscriptionRef<S>;
191
138
  }>;
192
139
  //#endregion
193
- export { Event, loop, loopFrom, loopWithState, next, nextAfter, nextAfterFold, onTurnComplete, stop, stopAfter, stopEvent, stopWith, stopWithAfter, Loop_d_exports as t, value };
140
+ export { Step, loop, loopOver, loopWithState, next, onTurnComplete, stop, Loop_d_exports as t, value };
194
141
  //# sourceMappingURL=Loop.d.mts.map