@effect-uai/core 0.17.0 → 0.19.0-dev-20261109183959

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 (218) hide show
  1. package/README.md +5 -5
  2. package/dist/Content-D_Qfn8Ja.d.mts +48 -0
  3. package/dist/Content-D_Qfn8Ja.d.mts.map +1 -0
  4. package/dist/File-B923KvZ9.d.mts +46 -0
  5. package/dist/File-B923KvZ9.d.mts.map +1 -0
  6. package/dist/{Image-Cv6iBLTy.d.mts → Image-Bzc1H_UK.d.mts} +19 -8
  7. package/dist/Image-Bzc1H_UK.d.mts.map +1 -0
  8. package/dist/{Items-C7MyrYPX.d.mts → Items-Bvx8s9QH.d.mts} +109 -16
  9. package/dist/Items-Bvx8s9QH.d.mts.map +1 -0
  10. package/dist/{Loop-ChpaO-ya.d.mts → Loop-CeA0AelN.d.mts} +7 -6
  11. package/dist/Loop-CeA0AelN.d.mts.map +1 -0
  12. package/dist/Tool-Bkryw6-h.d.mts +206 -0
  13. package/dist/Tool-Bkryw6-h.d.mts.map +1 -0
  14. package/dist/ToolEvent-9inLx5cI.d.mts +22 -0
  15. package/dist/ToolEvent-9inLx5cI.d.mts.map +1 -0
  16. package/dist/ToolOutput-BNTIQgGB.d.mts +151 -0
  17. package/dist/ToolOutput-BNTIQgGB.d.mts.map +1 -0
  18. package/dist/Toolkit-D2VGeD5R.d.mts +212 -0
  19. package/dist/Toolkit-D2VGeD5R.d.mts.map +1 -0
  20. package/dist/browser/BrowserTool.d.mts +84 -22
  21. package/dist/browser/BrowserTool.d.mts.map +1 -1
  22. package/dist/browser/BrowserTool.mjs +5 -0
  23. package/dist/browser/BrowserTool.mjs.map +1 -1
  24. package/dist/capabilities/Capabilities.d.mts +1 -1
  25. package/dist/decision-model/Decision.test.mjs +4 -4
  26. package/dist/dist-B5K-y4Be.mjs +191 -0
  27. package/dist/dist-B5K-y4Be.mjs.map +1 -0
  28. package/dist/dist-CorQTQL-.mjs +1533 -0
  29. package/dist/dist-CorQTQL-.mjs.map +1 -0
  30. package/dist/dist-DNeuh84d.mjs +7 -0
  31. package/dist/dist-DNeuh84d.mjs.map +1 -0
  32. package/dist/dist-DzeSyeYF.mjs +10253 -0
  33. package/dist/dist-DzeSyeYF.mjs.map +1 -0
  34. package/dist/domain/File.d.mts +2 -0
  35. package/dist/domain/File.mjs +51 -0
  36. package/dist/domain/File.mjs.map +1 -0
  37. package/dist/domain/Image.d.mts +2 -2
  38. package/dist/domain/Image.mjs +12 -2
  39. package/dist/domain/Image.mjs.map +1 -1
  40. package/dist/domain/Items.d.mts +2 -2
  41. package/dist/domain/Items.mjs +65 -4
  42. package/dist/domain/Items.mjs.map +1 -1
  43. package/dist/domain/Realtime.d.mts +72 -490
  44. package/dist/domain/Realtime.d.mts.map +1 -1
  45. package/dist/domain/Research.d.mts +1 -1
  46. package/dist/domain/Transcript.test.mjs +3 -3
  47. package/dist/domain/Turn.d.mts +57 -262
  48. package/dist/domain/Turn.d.mts.map +1 -1
  49. package/dist/domain/Turn.mjs +1 -1
  50. package/dist/domain/Turn.test.mjs +2 -2
  51. package/dist/embedding-model/Embedding.d.mts +1 -1
  52. package/dist/embedding-model/EmbeddingModel.test.mjs +2 -2
  53. package/dist/embedding-model/EmbeddingModel.test.mjs.map +1 -1
  54. package/dist/image-generator/ImageGenerator.d.mts +10 -66
  55. package/dist/image-generator/ImageGenerator.d.mts.map +1 -1
  56. package/dist/index.C4tKZ0yW-LuFnBtmu.mjs +7042 -0
  57. package/dist/index.C4tKZ0yW-LuFnBtmu.mjs.map +1 -0
  58. package/dist/index.d.mts +10 -9
  59. package/dist/index.mjs +7 -6
  60. package/dist/language-model/LanguageModel.d.mts +2 -2
  61. package/dist/language-model/LanguageModel.test.mjs +2 -2
  62. package/dist/loop/Loop.d.mts +1 -1
  63. package/dist/loop/Loop.mjs.map +1 -1
  64. package/dist/loop/Loop.test.mjs +3 -3
  65. package/dist/math/Probability.test.mjs +2 -2
  66. package/dist/messenger/Messenger.d.mts +43 -289
  67. package/dist/messenger/Messenger.d.mts.map +1 -1
  68. package/dist/messenger/MessengerAdapter.test.mjs +3 -3
  69. package/dist/music-generator/MusicGenerator.test.mjs +3 -3
  70. package/dist/observability/Metrics.d.mts +1 -1
  71. package/dist/observability/Metrics.test.mjs +3 -3
  72. package/dist/observability/Telemetry.d.mts +1 -1
  73. package/dist/observability/Telemetry.mjs +1 -1
  74. package/dist/observability/Telemetry.mjs.map +1 -1
  75. package/dist/observability/Telemetry.test.mjs +4 -4
  76. package/dist/observability/Telemetry.test.mjs.map +1 -1
  77. package/dist/realtime/RealtimeSession.d.mts +1 -1
  78. package/dist/realtime/RealtimeSession.test.mjs +4 -4
  79. package/dist/retry/Retry.test.mjs +2 -2
  80. package/dist/sandbox/Sandbox.d.mts +32 -237
  81. package/dist/sandbox/Sandbox.d.mts.map +1 -1
  82. package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs +3 -3
  83. package/dist/streaming/JSONL.test.mjs +2 -2
  84. package/dist/streaming/Multipart.d.mts +1 -1
  85. package/dist/streaming/Multipart.mjs +3 -2
  86. package/dist/streaming/Multipart.mjs.map +1 -1
  87. package/dist/streaming/Multipart.test.mjs +28 -0
  88. package/dist/streaming/Multipart.test.mjs.map +1 -0
  89. package/dist/streaming/SSE.d.mts +1 -1
  90. package/dist/streaming/SSE.mjs +2 -2
  91. package/dist/streaming/SSE.mjs.map +1 -1
  92. package/dist/streaming/SSE.test.mjs +2 -2
  93. package/dist/streaming/Settle.test.mjs +3 -3
  94. package/dist/streaming/WebSocketSession.d.mts +5 -3
  95. package/dist/streaming/WebSocketSession.d.mts.map +1 -1
  96. package/dist/streaming/WebSocketSession.mjs +22 -10
  97. package/dist/streaming/WebSocketSession.mjs.map +1 -1
  98. package/dist/streaming/WebSocketSession.test.mjs +41 -5
  99. package/dist/streaming/WebSocketSession.test.mjs.map +1 -1
  100. package/dist/structured-format/StructuredFormat.mjs.map +1 -1
  101. package/dist/structured-format/StructuredFormat.test.mjs +2 -2
  102. package/dist/testing/FakeWebSocket.d.mts +5 -1
  103. package/dist/testing/FakeWebSocket.d.mts.map +1 -1
  104. package/dist/testing/FakeWebSocket.mjs +12 -6
  105. package/dist/testing/FakeWebSocket.mjs.map +1 -1
  106. package/dist/testing/MockMessenger.d.mts +19 -134
  107. package/dist/testing/MockMessenger.d.mts.map +1 -1
  108. package/dist/testing/MockProvider.d.mts +1 -1
  109. package/dist/testing/MockSandbox.d.mts +65 -446
  110. package/dist/testing/MockSandbox.d.mts.map +1 -1
  111. package/dist/tool/Content.d.mts +2 -0
  112. package/dist/tool/Content.mjs +46 -0
  113. package/dist/tool/Content.mjs.map +1 -0
  114. package/dist/tool/Content.test.d.mts +1 -0
  115. package/dist/tool/Content.test.mjs +48 -0
  116. package/dist/tool/Content.test.mjs.map +1 -0
  117. package/dist/tool/HistoryCheck.d.mts +6 -15
  118. package/dist/tool/HistoryCheck.d.mts.map +1 -1
  119. package/dist/tool/HistoryCheck.mjs +10 -24
  120. package/dist/tool/HistoryCheck.mjs.map +1 -1
  121. package/dist/tool/Tool.d.mts +2 -2
  122. package/dist/tool/Tool.mjs +55 -130
  123. package/dist/tool/Tool.mjs.map +1 -1
  124. package/dist/tool/Tool.test.mjs +222 -178
  125. package/dist/tool/Tool.test.mjs.map +1 -1
  126. package/dist/tool/ToolDecision.d.mts +164 -0
  127. package/dist/tool/ToolDecision.d.mts.map +1 -0
  128. package/dist/tool/ToolDecision.mjs +146 -0
  129. package/dist/tool/ToolDecision.mjs.map +1 -0
  130. package/dist/tool/ToolDecision.test.d.mts +1 -0
  131. package/dist/tool/ToolDecision.test.mjs +330 -0
  132. package/dist/tool/ToolDecision.test.mjs.map +1 -0
  133. package/dist/tool/ToolEvent.d.mts +2 -2
  134. package/dist/tool/ToolEvent.mjs +2 -34
  135. package/dist/tool/ToolEvent.mjs.map +1 -1
  136. package/dist/tool/ToolOutput.d.mts +2 -0
  137. package/dist/tool/ToolOutput.mjs +128 -0
  138. package/dist/tool/ToolOutput.mjs.map +1 -0
  139. package/dist/tool/ToolOutput.test.d.mts +1 -0
  140. package/dist/tool/ToolOutput.test.mjs +153 -0
  141. package/dist/tool/ToolOutput.test.mjs.map +1 -0
  142. package/dist/tool/Toolkit.d.mts +2 -2
  143. package/dist/tool/Toolkit.mjs +230 -165
  144. package/dist/tool/Toolkit.mjs.map +1 -1
  145. package/dist/tool/Toolkit.test.mjs +433 -391
  146. package/dist/tool/Toolkit.test.mjs.map +1 -1
  147. package/dist/transcriber/Transcriber.test.mjs +3 -3
  148. package/dist/web-read/WebReadTool.d.mts +2 -2
  149. package/dist/web-read/WebReadTool.mjs +1 -0
  150. package/dist/web-read/WebReadTool.mjs.map +1 -1
  151. package/dist/web-search/WebSearchTool.d.mts +2 -2
  152. package/dist/web-search/WebSearchTool.mjs +1 -0
  153. package/dist/web-search/WebSearchTool.mjs.map +1 -1
  154. package/package.json +18 -10
  155. package/src/browser/BrowserTool.ts +5 -0
  156. package/src/domain/File.ts +79 -0
  157. package/src/domain/Image.ts +14 -4
  158. package/src/domain/Items.ts +39 -3
  159. package/src/embedding-model/EmbeddingModel.test.ts +2 -2
  160. package/src/index.ts +3 -2
  161. package/src/loop/Loop.ts +25 -14
  162. package/src/observability/Telemetry.test.ts +1 -1
  163. package/src/observability/Telemetry.ts +2 -2
  164. package/src/streaming/Multipart.test.ts +26 -0
  165. package/src/streaming/Multipart.ts +6 -5
  166. package/src/streaming/SSE.ts +2 -2
  167. package/src/streaming/WebSocketSession.test.ts +54 -2
  168. package/src/streaming/WebSocketSession.ts +27 -6
  169. package/src/structured-format/StructuredFormat.ts +1 -1
  170. package/src/testing/FakeWebSocket.ts +21 -6
  171. package/src/tool/Content.test.ts +40 -0
  172. package/src/tool/Content.ts +38 -0
  173. package/src/tool/HistoryCheck.ts +21 -26
  174. package/src/tool/Tool.test.ts +240 -241
  175. package/src/tool/Tool.ts +204 -309
  176. package/src/tool/ToolDecision.test.ts +301 -0
  177. package/src/tool/ToolDecision.ts +360 -0
  178. package/src/tool/ToolEvent.ts +21 -41
  179. package/src/tool/ToolOutput.test.ts +132 -0
  180. package/src/tool/ToolOutput.ts +198 -0
  181. package/src/tool/Toolkit.test.ts +594 -454
  182. package/src/tool/Toolkit.ts +631 -356
  183. package/src/web-read/WebReadTool.ts +2 -1
  184. package/src/web-search/WebSearchTool.ts +2 -1
  185. package/dist/Image-Cv6iBLTy.d.mts.map +0 -1
  186. package/dist/Items-C7MyrYPX.d.mts.map +0 -1
  187. package/dist/Loop-ChpaO-ya.d.mts.map +0 -1
  188. package/dist/Tool-BF78QWtn.d.mts +0 -314
  189. package/dist/Tool-BF78QWtn.d.mts.map +0 -1
  190. package/dist/ToolEvent-Di4a723B.d.mts +0 -144
  191. package/dist/ToolEvent-Di4a723B.d.mts.map +0 -1
  192. package/dist/ToolResult-BsYQRjmW.d.mts +0 -152
  193. package/dist/ToolResult-BsYQRjmW.d.mts.map +0 -1
  194. package/dist/Toolkit-tlL0F2YR.d.mts +0 -193
  195. package/dist/Toolkit-tlL0F2YR.d.mts.map +0 -1
  196. package/dist/dist-BaenoU1A.mjs +0 -145
  197. package/dist/dist-BaenoU1A.mjs.map +0 -1
  198. package/dist/dist-nohcnkD6.mjs +0 -182
  199. package/dist/dist-nohcnkD6.mjs.map +0 -1
  200. package/dist/magic-string.es-CB2hOw9v.mjs +0 -1014
  201. package/dist/magic-string.es-CB2hOw9v.mjs.map +0 -1
  202. package/dist/test.DNmyFkvJ-YPzDR0Co.mjs +0 -10254
  203. package/dist/test.DNmyFkvJ-YPzDR0Co.mjs.map +0 -1
  204. package/dist/tool/Approval.d.mts +0 -113
  205. package/dist/tool/Approval.d.mts.map +0 -1
  206. package/dist/tool/Approval.mjs +0 -80
  207. package/dist/tool/Approval.mjs.map +0 -1
  208. package/dist/tool/Approval.test.mjs +0 -371
  209. package/dist/tool/Approval.test.mjs.map +0 -1
  210. package/dist/tool/ToolResult.d.mts +0 -2
  211. package/dist/tool/ToolResult.mjs +0 -85
  212. package/dist/tool/ToolResult.mjs.map +0 -1
  213. package/dist/utils-CiH_DjFW.mjs +0 -3918
  214. package/dist/utils-CiH_DjFW.mjs.map +0 -1
  215. package/src/tool/Approval.test.ts +0 -400
  216. package/src/tool/Approval.ts +0 -181
  217. package/src/tool/ToolResult.ts +0 -114
  218. /package/dist/{tool/Approval.test.d.mts → streaming/Multipart.test.d.mts} +0 -0
@@ -0,0 +1,2 @@
1
+ import { a as FileSourceJson, c as fileBytes, i as FileSource, l as fileUrl, n as FileBytesSource, o as FileUrlSource, r as FileMimeType, s as fileBase64, t as FileBase64Source } from "../File-B923KvZ9.mjs";
2
+ export { FileBase64Source, FileBytesSource, FileMimeType, FileSource, FileSourceJson, FileUrlSource, fileBase64, fileBytes, fileUrl };
@@ -0,0 +1,51 @@
1
+ import { Schema } from "effect";
2
+ //#region src/domain/File.ts
3
+ const FileMimeTypeSchema = Schema.String;
4
+ const FileUrlSource = Schema.TaggedStruct("url", {
5
+ url: Schema.String,
6
+ mimeType: Schema.optionalKey(FileMimeTypeSchema)
7
+ });
8
+ const FileBase64Source = Schema.TaggedStruct("base64", {
9
+ base64: Schema.String,
10
+ mimeType: FileMimeTypeSchema
11
+ });
12
+ const FileBytesSource = Schema.TaggedStruct("bytes", {
13
+ bytes: Schema.Uint8Array,
14
+ mimeType: FileMimeTypeSchema
15
+ });
16
+ const FileSource = Schema.Union([
17
+ FileUrlSource,
18
+ FileBase64Source,
19
+ FileBytesSource
20
+ ]);
21
+ /** `FileSource` as JSON: bytes encode as base64 (e.g. tool output on a UI wire). */
22
+ const FileSourceJson = Schema.Union([
23
+ FileUrlSource,
24
+ FileBase64Source,
25
+ Schema.TaggedStruct("bytes", {
26
+ bytes: Schema.Uint8ArrayFromBase64,
27
+ mimeType: FileMimeTypeSchema
28
+ })
29
+ ]);
30
+ const fileUrl = (url, mimeType) => mimeType !== void 0 ? {
31
+ _tag: "url",
32
+ url,
33
+ mimeType
34
+ } : {
35
+ _tag: "url",
36
+ url
37
+ };
38
+ const fileBase64 = (base64, mimeType) => ({
39
+ _tag: "base64",
40
+ base64,
41
+ mimeType
42
+ });
43
+ const fileBytes = (bytes, mimeType) => ({
44
+ _tag: "bytes",
45
+ bytes,
46
+ mimeType
47
+ });
48
+ //#endregion
49
+ export { FileBase64Source, FileBytesSource, FileSource, FileSourceJson, FileUrlSource, fileBase64, fileBytes, fileUrl };
50
+
51
+ //# sourceMappingURL=File.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"File.mjs","names":[],"sources":["../../src/domain/File.ts"],"sourcesContent":["import { Schema } from \"effect\"\nimport type { MediaBase64, MediaBytes, MediaSource, MediaUrl } from \"./Media.js\"\n\n/**\n * MIME types of files a user hands to a model: documents, audio, video. The\n * listed ones are common; the `(string & {})` tail accepts any other, so a\n * newly supported format works without an SDK update. Which types a model\n * reads is the provider's call: an unsupported one is rejected by the\n * provider, not converted here.\n */\nexport type FileMimeType =\n | \"application/pdf\"\n | \"text/plain\"\n | \"text/markdown\"\n | \"text/csv\"\n | \"text/html\"\n | \"application/json\"\n | \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\"\n | \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"\n | \"audio/mpeg\"\n | \"audio/wav\"\n | \"video/mp4\"\n // eslint-disable-next-line @typescript-eslint/ban-types\n | (string & {})\n\nconst FileMimeTypeSchema: Schema.Codec<FileMimeType> = Schema.String\n\nexport type FileUrlSource = MediaUrl<FileMimeType>\nexport type FileBase64Source = MediaBase64<FileMimeType>\nexport type FileBytesSource = MediaBytes<FileMimeType>\n\n/** Where a file lives: a URL the model fetches, inline base64, or raw bytes. */\nexport type FileSource = MediaSource<FileMimeType>\n\nexport const FileUrlSource = Schema.TaggedStruct(\"url\", {\n url: Schema.String,\n mimeType: Schema.optionalKey(FileMimeTypeSchema),\n})\n\nexport const FileBase64Source = Schema.TaggedStruct(\"base64\", {\n base64: Schema.String,\n mimeType: FileMimeTypeSchema,\n})\n\nexport const FileBytesSource = Schema.TaggedStruct(\"bytes\", {\n bytes: Schema.Uint8Array,\n mimeType: FileMimeTypeSchema,\n})\n\nexport const FileSource: Schema.Codec<FileSource> = Schema.Union([\n FileUrlSource,\n FileBase64Source,\n FileBytesSource,\n])\n\n/** `FileSource` as JSON: bytes encode as base64 (e.g. tool output on a UI wire). */\nexport const FileSourceJson = Schema.Union([\n FileUrlSource,\n FileBase64Source,\n Schema.TaggedStruct(\"bytes\", {\n bytes: Schema.Uint8ArrayFromBase64,\n mimeType: FileMimeTypeSchema,\n }),\n])\n\nexport const fileUrl = (url: string, mimeType?: FileMimeType): FileUrlSource =>\n mimeType !== undefined ? { _tag: \"url\", url, mimeType } : { _tag: \"url\", url }\n\nexport const fileBase64 = (base64: string, mimeType: FileMimeType): FileBase64Source => ({\n _tag: \"base64\",\n base64,\n mimeType,\n})\n\nexport const fileBytes = (bytes: Uint8Array, mimeType: FileMimeType): FileBytesSource => ({\n _tag: \"bytes\",\n bytes,\n mimeType,\n})\n"],"mappings":";;AAyBA,MAAM,qBAAiD,OAAO;AAS9D,MAAa,gBAAgB,OAAO,aAAa,OAAO;CACtD,KAAK,OAAO;CACZ,UAAU,OAAO,YAAY,kBAAkB;AACjD,CAAC;AAED,MAAa,mBAAmB,OAAO,aAAa,UAAU;CAC5D,QAAQ,OAAO;CACf,UAAU;AACZ,CAAC;AAED,MAAa,kBAAkB,OAAO,aAAa,SAAS;CAC1D,OAAO,OAAO;CACd,UAAU;AACZ,CAAC;AAED,MAAa,aAAuC,OAAO,MAAM;CAC/D;CACA;CACA;AACF,CAAC;;AAGD,MAAa,iBAAiB,OAAO,MAAM;CACzC;CACA;CACA,OAAO,aAAa,SAAS;EAC3B,OAAO,OAAO;EACd,UAAU;CACZ,CAAC;AACH,CAAC;AAED,MAAa,WAAW,KAAa,aACnC,aAAa,KAAA,IAAY;CAAE,MAAM;CAAO;CAAK;AAAS,IAAI;CAAE,MAAM;CAAO;AAAI;AAE/E,MAAa,cAAc,QAAgB,cAA8C;CACvF,MAAM;CACN;CACA;AACF;AAEA,MAAa,aAAa,OAAmB,cAA6C;CACxF,MAAM;CACN;CACA;AACF"}
@@ -1,3 +1,3 @@
1
1
  import { n as Dimensions, t as AspectRatio } from "../Media-BbX7BAaO.mjs";
2
- import { a as ImageResolution, d as imageBytes, f as imageUrl, g as pixelsOf, h as isImageUrl, i as ImageMimeType, l as ProviderData, m as isImageBytes, n as ImageBase64Source, o as ImageSource, p as isImageBase64, r as ImageBytesSource, s as ImageUrlSource, t as GeneratedImage, u as imageBase64 } from "../Image-Cv6iBLTy.mjs";
3
- export { type AspectRatio, type Dimensions, GeneratedImage, ImageBase64Source, ImageBytesSource, ImageMimeType, ImageResolution, ImageSource, ImageUrlSource, ProviderData, imageBase64, imageBytes, imageUrl, isImageBase64, isImageBytes, isImageUrl, pixelsOf };
2
+ import { _ as pixelsOf, a as ImageResolution, c as ImageUrlSource, d as imageBase64, f as imageBytes, g as isImageUrl, h as isImageBytes, i as ImageMimeType, m as isImageBase64, n as ImageBase64Source, o as ImageSource, p as imageUrl, r as ImageBytesSource, s as ImageSourceJson, t as GeneratedImage, u as ProviderData } from "../Image-Bzc1H_UK.mjs";
3
+ export { type AspectRatio, type Dimensions, GeneratedImage, ImageBase64Source, ImageBytesSource, ImageMimeType, ImageResolution, ImageSource, ImageSourceJson, ImageUrlSource, ProviderData, imageBase64, imageBytes, imageUrl, isImageBase64, isImageBytes, isImageUrl, pixelsOf };
@@ -6,6 +6,7 @@ var Image_exports = /* @__PURE__ */ __exportAll({
6
6
  ImageBase64Source: () => ImageBase64Source,
7
7
  ImageBytesSource: () => ImageBytesSource,
8
8
  ImageSource: () => ImageSource,
9
+ ImageSourceJson: () => ImageSourceJson,
9
10
  ImageUrlSource: () => ImageUrlSource,
10
11
  imageBase64: () => imageBase64,
11
12
  imageBytes: () => imageBytes,
@@ -18,7 +19,7 @@ var Image_exports = /* @__PURE__ */ __exportAll({
18
19
  const ImageMimeTypeSchema = Schema.String;
19
20
  const ImageUrlSource = Schema.TaggedStruct("url", {
20
21
  url: Schema.String,
21
- mimeType: Schema.optional(ImageMimeTypeSchema)
22
+ mimeType: Schema.optionalKey(ImageMimeTypeSchema)
22
23
  });
23
24
  const ImageBase64Source = Schema.TaggedStruct("base64", {
24
25
  base64: Schema.String,
@@ -33,6 +34,15 @@ const ImageSource = Schema.Union([
33
34
  ImageBase64Source,
34
35
  ImageBytesSource
35
36
  ]);
37
+ /** `ImageSource` as JSON: bytes encode as base64 (e.g. tool output on a UI wire). */
38
+ const ImageSourceJson = Schema.Union([
39
+ ImageUrlSource,
40
+ ImageBase64Source,
41
+ Schema.TaggedStruct("bytes", {
42
+ bytes: Schema.Uint8ArrayFromBase64,
43
+ mimeType: ImageMimeTypeSchema
44
+ })
45
+ ]);
36
46
  const imageUrl = (url, mimeType) => mimeType !== void 0 ? {
37
47
  _tag: "url",
38
48
  url,
@@ -79,6 +89,6 @@ const isImageUrl = Schema.is(ImageUrlSource);
79
89
  const isImageBase64 = Schema.is(ImageBase64Source);
80
90
  const isImageBytes = Schema.is(ImageBytesSource);
81
91
  //#endregion
82
- export { ImageBase64Source, ImageBytesSource, ImageSource, ImageUrlSource, imageBase64, imageBytes, imageUrl, isImageBase64, isImageBytes, isImageUrl, pixelsOf, Image_exports as t };
92
+ export { ImageBase64Source, ImageBytesSource, ImageSource, ImageSourceJson, ImageUrlSource, imageBase64, imageBytes, imageUrl, isImageBase64, isImageBytes, isImageUrl, pixelsOf, Image_exports as t };
83
93
 
84
94
  //# sourceMappingURL=Image.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Image.mjs","names":[],"sources":["../../src/domain/Image.ts"],"sourcesContent":["import { Result, Schema } from \"effect\"\nimport type {\n AspectRatio,\n Dimensions,\n MediaBase64,\n MediaBytes,\n MediaSource,\n MediaUrl,\n Watermark,\n} from \"./Media.js\"\nimport { parseAspectRatio, round16 } from \"./Media.js\"\n\n/**\n * Image MIME types AI providers typically accept. The first four are the\n * universal subset (Cohere v4, Voyage multimodal, Jina v4, Google\n * `gemini-embedding-2`); HEIC / HEIF are Google-specific. The\n * `(string & {})` tail keeps autocomplete on the literals while still\n * accepting any string, so a newly-supported format works without an\n * SDK update.\n */\nexport type ImageMimeType =\n | \"image/png\"\n | \"image/jpeg\"\n | \"image/webp\"\n | \"image/gif\"\n | \"image/heic\"\n | \"image/heif\"\n // eslint-disable-next-line @typescript-eslint/ban-types\n | (string & {})\n\nconst ImageMimeTypeSchema = Schema.String as unknown as Schema.Schema<ImageMimeType>\n\nexport type ImageUrlSource = MediaUrl<ImageMimeType>\nexport type ImageBase64Source = MediaBase64<ImageMimeType>\nexport type ImageBytesSource = MediaBytes<ImageMimeType>\n\n/**\n * Where an image lives. Provider layers normalize across these:\n * `bytes` becomes a base64 data URI for OpenAI / Anthropic, an\n * `inlineData` part for Gemini, and a separate field for Cohere /\n * Voyage. URL constraints (must be HTTPS, must be public, …) are\n * provider-specific and validated at the layer, not in the type.\n */\nexport type ImageSource = MediaSource<ImageMimeType>\n\nexport const ImageUrlSource = Schema.TaggedStruct(\"url\", {\n url: Schema.String,\n mimeType: Schema.optional(ImageMimeTypeSchema),\n})\n\nexport const ImageBase64Source = Schema.TaggedStruct(\"base64\", {\n base64: Schema.String,\n mimeType: ImageMimeTypeSchema,\n})\n\nexport const ImageBytesSource = Schema.TaggedStruct(\"bytes\", {\n bytes: Schema.Uint8Array,\n mimeType: ImageMimeTypeSchema,\n})\n\nexport const ImageSource: Schema.Schema<ImageSource> = Schema.Union([\n ImageUrlSource,\n ImageBase64Source,\n ImageBytesSource,\n]) as unknown as Schema.Schema<ImageSource>\n\nexport const imageUrl = (url: string, mimeType?: ImageMimeType): ImageUrlSource =>\n mimeType !== undefined ? { _tag: \"url\", url, mimeType } : { _tag: \"url\", url }\n\nexport const imageBase64 = (base64: string, mimeType: ImageMimeType): ImageBase64Source => ({\n _tag: \"base64\",\n base64,\n mimeType,\n})\n\nexport const imageBytes = (bytes: Uint8Array, mimeType: ImageMimeType): ImageBytesSource => ({\n _tag: \"bytes\",\n bytes,\n mimeType,\n})\n\n/** Cross-modality; lives in `Media.ts` because video generation shares it. */\nexport type { AspectRatio, Dimensions } from \"./Media.js\"\n\n/**\n * Resolution tier, roughly the short edge in pixels. A tier rather than\n * a pixel pair: adapters whose wire takes exact dimensions derive them\n * from the tier and the aspect ratio. Image-typed on purpose, video\n * models tier by scan height instead.\n */\nexport type ImageResolution = \"1K\" | \"2K\" | \"4K\"\n\nconst SHORT_EDGE: Record<ImageResolution, number> = { \"1K\": 1024, \"2K\": 2048, \"4K\": 4096 }\n\n/**\n * Turn the portable ratio and tier into pixels: the tier is the short\n * edge, the long edge follows the ratio. `undefined` when neither was\n * asked for, which the caller sends as \"no size\" so the endpoint picks.\n *\n * Adapters whose wire wants `\"WxH\"` format the pair; those wanting an\n * object send it as is. Whether the result is in range for a given model\n * is the server's call: per-model limits churn and we do not table them.\n */\nexport const pixelsOf = (request: {\n readonly aspectRatio?: AspectRatio\n readonly resolution?: ImageResolution\n}): Result.Result<Dimensions | undefined, string> =>\n request.aspectRatio === undefined && request.resolution === undefined\n ? Result.succeed(undefined)\n : Result.map(parseAspectRatio(request.aspectRatio ?? \"1:1\"), ([w, h]) => {\n const short = SHORT_EDGE[request.resolution ?? \"1K\"]\n return w >= h\n ? { width: round16((short * w) / h), height: short }\n : { width: short, height: round16((short * h) / w) }\n })\n\n/**\n * Per-image extras a provider reported and this type has no field for:\n * pixel dimensions, a file name, a revised prompt. Opaque here, and a\n * shared slot, so a provider keys its data under its own name\n * (`{ fal: … }`, `{ openai: … }`) and reads only that key. Each provider\n * package ships a typed reader; the framework never interprets it.\n *\n * Not promoted to real fields because the providers disagree on what\n * they report. Only some fal endpoints return dimensions, and neither\n * OpenAI's Images API nor Gemini returns them at all.\n */\nexport type ProviderData = unknown\n\n/** One image off a generation call, plus what the provider stamped into it. */\nexport type GeneratedImage = {\n readonly image: ImageSource\n /** Set only when the provider applies one. */\n readonly watermark?: Watermark\n /** {@link ProviderData}: per-image extras, keyed by provider name. */\n readonly providerData?: ProviderData\n}\n\nexport const isImageUrl = Schema.is(ImageUrlSource)\nexport const isImageBase64 = Schema.is(ImageBase64Source)\nexport const isImageBytes = Schema.is(ImageBytesSource)\n"],"mappings":";;;;;;;;;;;;;;;;;AA8BA,MAAM,sBAAsB,OAAO;AAenC,MAAa,iBAAiB,OAAO,aAAa,OAAO;CACvD,KAAK,OAAO;CACZ,UAAU,OAAO,SAAS,mBAAmB;AAC/C,CAAC;AAED,MAAa,oBAAoB,OAAO,aAAa,UAAU;CAC7D,QAAQ,OAAO;CACf,UAAU;AACZ,CAAC;AAED,MAAa,mBAAmB,OAAO,aAAa,SAAS;CAC3D,OAAO,OAAO;CACd,UAAU;AACZ,CAAC;AAED,MAAa,cAA0C,OAAO,MAAM;CAClE;CACA;CACA;AACF,CAAC;AAED,MAAa,YAAY,KAAa,aACpC,aAAa,KAAA,IAAY;CAAE,MAAM;CAAO;CAAK;AAAS,IAAI;CAAE,MAAM;CAAO;AAAI;AAE/E,MAAa,eAAe,QAAgB,cAAgD;CAC1F,MAAM;CACN;CACA;AACF;AAEA,MAAa,cAAc,OAAmB,cAA+C;CAC3F,MAAM;CACN;CACA;AACF;AAaA,MAAM,aAA8C;CAAE,MAAM;CAAM,MAAM;CAAM,MAAM;AAAK;;;;;;;;;;AAWzF,MAAa,YAAY,YAIvB,QAAQ,gBAAgB,KAAA,KAAa,QAAQ,eAAe,KAAA,IACxD,OAAO,QAAQ,KAAA,CAAS,IACxB,OAAO,IAAI,iBAAiB,QAAQ,eAAe,KAAK,IAAI,CAAC,GAAG,OAAO;CACrE,MAAM,QAAQ,WAAW,QAAQ,cAAc;CAC/C,OAAO,KAAK,IACR;EAAE,OAAO,QAAS,QAAQ,IAAK,CAAC;EAAG,QAAQ;CAAM,IACjD;EAAE,OAAO;EAAO,QAAQ,QAAS,QAAQ,IAAK,CAAC;CAAE;AACvD,CAAC;AAwBP,MAAa,aAAa,OAAO,GAAG,cAAc;AAClD,MAAa,gBAAgB,OAAO,GAAG,iBAAiB;AACxD,MAAa,eAAe,OAAO,GAAG,gBAAgB"}
1
+ {"version":3,"file":"Image.mjs","names":[],"sources":["../../src/domain/Image.ts"],"sourcesContent":["import { Result, Schema } from \"effect\"\nimport type {\n AspectRatio,\n Dimensions,\n MediaBase64,\n MediaBytes,\n MediaSource,\n MediaUrl,\n Watermark,\n} from \"./Media.js\"\nimport { parseAspectRatio, round16 } from \"./Media.js\"\n\n/**\n * Image MIME types AI providers typically accept. The first four are the\n * universal subset (Cohere v4, Voyage multimodal, Jina v4, Google\n * `gemini-embedding-2`); HEIC / HEIF are Google-specific. The\n * `(string & {})` tail keeps autocomplete on the literals while still\n * accepting any string, so a newly-supported format works without an\n * SDK update.\n */\nexport type ImageMimeType =\n | \"image/png\"\n | \"image/jpeg\"\n | \"image/webp\"\n | \"image/gif\"\n | \"image/heic\"\n | \"image/heif\"\n // eslint-disable-next-line @typescript-eslint/ban-types\n | (string & {})\n\nconst ImageMimeTypeSchema: Schema.Codec<ImageMimeType> = Schema.String\n\nexport type ImageUrlSource = MediaUrl<ImageMimeType>\nexport type ImageBase64Source = MediaBase64<ImageMimeType>\nexport type ImageBytesSource = MediaBytes<ImageMimeType>\n\n/**\n * Where an image lives. Provider layers normalize across these:\n * `bytes` becomes a base64 data URI for OpenAI / Anthropic, an\n * `inlineData` part for Gemini, and a separate field for Cohere /\n * Voyage. URL constraints (must be HTTPS, must be public, …) are\n * provider-specific and validated at the layer, not in the type.\n */\nexport type ImageSource = MediaSource<ImageMimeType>\n\nexport const ImageUrlSource = Schema.TaggedStruct(\"url\", {\n url: Schema.String,\n mimeType: Schema.optionalKey(ImageMimeTypeSchema),\n})\n\nexport const ImageBase64Source = Schema.TaggedStruct(\"base64\", {\n base64: Schema.String,\n mimeType: ImageMimeTypeSchema,\n})\n\nexport const ImageBytesSource = Schema.TaggedStruct(\"bytes\", {\n bytes: Schema.Uint8Array,\n mimeType: ImageMimeTypeSchema,\n})\n\nexport const ImageSource: Schema.Codec<ImageSource> = Schema.Union([\n ImageUrlSource,\n ImageBase64Source,\n ImageBytesSource,\n])\n\n/** `ImageSource` as JSON: bytes encode as base64 (e.g. tool output on a UI wire). */\nexport const ImageSourceJson = Schema.Union([\n ImageUrlSource,\n ImageBase64Source,\n Schema.TaggedStruct(\"bytes\", {\n bytes: Schema.Uint8ArrayFromBase64,\n mimeType: ImageMimeTypeSchema,\n }),\n])\n\nexport const imageUrl = (url: string, mimeType?: ImageMimeType): ImageUrlSource =>\n mimeType !== undefined ? { _tag: \"url\", url, mimeType } : { _tag: \"url\", url }\n\nexport const imageBase64 = (base64: string, mimeType: ImageMimeType): ImageBase64Source => ({\n _tag: \"base64\",\n base64,\n mimeType,\n})\n\nexport const imageBytes = (bytes: Uint8Array, mimeType: ImageMimeType): ImageBytesSource => ({\n _tag: \"bytes\",\n bytes,\n mimeType,\n})\n\n/** Cross-modality; lives in `Media.ts` because video generation shares it. */\nexport type { AspectRatio, Dimensions } from \"./Media.js\"\n\n/**\n * Resolution tier, roughly the short edge in pixels. A tier rather than\n * a pixel pair: adapters whose wire takes exact dimensions derive them\n * from the tier and the aspect ratio. Image-typed on purpose, video\n * models tier by scan height instead.\n */\nexport type ImageResolution = \"1K\" | \"2K\" | \"4K\"\n\nconst SHORT_EDGE: Record<ImageResolution, number> = { \"1K\": 1024, \"2K\": 2048, \"4K\": 4096 }\n\n/**\n * Turn the portable ratio and tier into pixels: the tier is the short\n * edge, the long edge follows the ratio. `undefined` when neither was\n * asked for, which the caller sends as \"no size\" so the endpoint picks.\n *\n * Adapters whose wire wants `\"WxH\"` format the pair; those wanting an\n * object send it as is. Whether the result is in range for a given model\n * is the server's call: per-model limits churn and we do not table them.\n */\nexport const pixelsOf = (request: {\n readonly aspectRatio?: AspectRatio\n readonly resolution?: ImageResolution\n}): Result.Result<Dimensions | undefined, string> =>\n request.aspectRatio === undefined && request.resolution === undefined\n ? Result.succeed(undefined)\n : Result.map(parseAspectRatio(request.aspectRatio ?? \"1:1\"), ([w, h]) => {\n const short = SHORT_EDGE[request.resolution ?? \"1K\"]\n return w >= h\n ? { width: round16((short * w) / h), height: short }\n : { width: short, height: round16((short * h) / w) }\n })\n\n/**\n * Per-image extras a provider reported and this type has no field for:\n * pixel dimensions, a file name, a revised prompt. Opaque here, and a\n * shared slot, so a provider keys its data under its own name\n * (`{ fal: … }`, `{ openai: … }`) and reads only that key. Each provider\n * package ships a typed reader; the framework never interprets it.\n *\n * Not promoted to real fields because the providers disagree on what\n * they report. Only some fal endpoints return dimensions, and neither\n * OpenAI's Images API nor Gemini returns them at all.\n */\nexport type ProviderData = unknown\n\n/** One image off a generation call, plus what the provider stamped into it. */\nexport type GeneratedImage = {\n readonly image: ImageSource\n /** Set only when the provider applies one. */\n readonly watermark?: Watermark\n /** {@link ProviderData}: per-image extras, keyed by provider name. */\n readonly providerData?: ProviderData\n}\n\nexport const isImageUrl = Schema.is(ImageUrlSource)\nexport const isImageBase64 = Schema.is(ImageBase64Source)\nexport const isImageBytes = Schema.is(ImageBytesSource)\n"],"mappings":";;;;;;;;;;;;;;;;;;AA8BA,MAAM,sBAAmD,OAAO;AAehE,MAAa,iBAAiB,OAAO,aAAa,OAAO;CACvD,KAAK,OAAO;CACZ,UAAU,OAAO,YAAY,mBAAmB;AAClD,CAAC;AAED,MAAa,oBAAoB,OAAO,aAAa,UAAU;CAC7D,QAAQ,OAAO;CACf,UAAU;AACZ,CAAC;AAED,MAAa,mBAAmB,OAAO,aAAa,SAAS;CAC3D,OAAO,OAAO;CACd,UAAU;AACZ,CAAC;AAED,MAAa,cAAyC,OAAO,MAAM;CACjE;CACA;CACA;AACF,CAAC;;AAGD,MAAa,kBAAkB,OAAO,MAAM;CAC1C;CACA;CACA,OAAO,aAAa,SAAS;EAC3B,OAAO,OAAO;EACd,UAAU;CACZ,CAAC;AACH,CAAC;AAED,MAAa,YAAY,KAAa,aACpC,aAAa,KAAA,IAAY;CAAE,MAAM;CAAO;CAAK;AAAS,IAAI;CAAE,MAAM;CAAO;AAAI;AAE/E,MAAa,eAAe,QAAgB,cAAgD;CAC1F,MAAM;CACN;CACA;AACF;AAEA,MAAa,cAAc,OAAmB,cAA+C;CAC3F,MAAM;CACN;CACA;AACF;AAaA,MAAM,aAA8C;CAAE,MAAM;CAAM,MAAM;CAAM,MAAM;AAAK;;;;;;;;;;AAWzF,MAAa,YAAY,YAIvB,QAAQ,gBAAgB,KAAA,KAAa,QAAQ,eAAe,KAAA,IACxD,OAAO,QAAQ,KAAA,CAAS,IACxB,OAAO,IAAI,iBAAiB,QAAQ,eAAe,KAAK,IAAI,CAAC,GAAG,OAAO;CACrE,MAAM,QAAQ,WAAW,QAAQ,cAAc;CAC/C,OAAO,KAAK,IACR;EAAE,OAAO,QAAS,QAAQ,IAAK,CAAC;EAAG,QAAQ;CAAM,IACjD;EAAE,OAAO;EAAO,QAAQ,QAAS,QAAQ,IAAK,CAAC;CAAE;AACvD,CAAC;AAwBP,MAAa,aAAa,OAAO,GAAG,cAAc;AAClD,MAAa,gBAAgB,OAAO,GAAG,iBAAiB;AACxD,MAAa,eAAe,OAAO,GAAG,gBAAgB"}
@@ -1,2 +1,2 @@
1
- import { A as isOutputImage, C as assistantText, D as isInputImage, E as isFilePath, F as isToolCallOutput, I as isUrlCitation, L as systemText, M as isReasoning, N as isRefusal, O as isInputText, P as isToolCall, R as toolCallOutput, S as Usage, T as isFileCitation, _ as Role, a as FilePath, b as ToolCallOutput, c as InputText, d as Message, f as OutputImage, g as Refusal, h as Reasoning, i as FileCitation, j as isOutputText, k as isMessage, l as InputTokensDetails, m as OutputTokensDetails, n as ContainerFileCitation, o as HistoryItem, p as OutputText, r as ContentBlock, s as InputImage, t as Annotation, v as StopReason, w as isContainerFileCitation, x as UrlCitation, y as ToolCall, z as userText } from "../Items-C7MyrYPX.mjs";
2
- export { Annotation, ContainerFileCitation, ContentBlock, FileCitation, FilePath, HistoryItem, InputImage, InputText, InputTokensDetails, Message, OutputImage, OutputText, OutputTokensDetails, Reasoning, Refusal, Role, StopReason, ToolCall, ToolCallOutput, UrlCitation, Usage, assistantText, isContainerFileCitation, isFileCitation, isFilePath, isInputImage, isInputText, isMessage, isOutputImage, isOutputText, isReasoning, isRefusal, isToolCall, isToolCallOutput, isUrlCitation, systemText, toolCallOutput, userText };
1
+ import { A as isFileCitation, B as isRefusal, C as ToolOutputContent, D as file, E as assistantText, F as isInputText, G as systemText, H as isToolCallOutput, I as isMessage, J as userText, K as text, L as isOutputImage, M as isInputFile, N as isInputImage, O as image, P as isInputJson, R as isOutputText, S as ToolCallOutput, T as Usage, U as isUrlCitation, V as isToolCall, W as json, _ as Reasoning, a as FilePath, b as StopReason, c as InputImage, d as InputTokensDetails, g as OutputTokensDetails, h as OutputText, i as FileCitation, j as isFilePath, k as isContainerFileCitation, l as InputJson, m as OutputImage, n as ContainerFileCitation, o as HistoryItem, p as Message, q as toolCallOutput, r as ContentBlock, s as InputFile, t as Annotation, u as InputText, v as Refusal, w as UrlCitation, x as ToolCall, y as Role, z as isReasoning } from "../Items-Bvx8s9QH.mjs";
2
+ export { Annotation, ContainerFileCitation, ContentBlock, FileCitation, FilePath, HistoryItem, InputFile, InputImage, InputJson, InputText, InputTokensDetails, Message, OutputImage, OutputText, OutputTokensDetails, Reasoning, Refusal, Role, StopReason, ToolCall, ToolCallOutput, ToolOutputContent, UrlCitation, Usage, assistantText, file, image, isContainerFileCitation, isFileCitation, isFilePath, isInputFile, isInputImage, isInputJson, isInputText, isMessage, isOutputImage, isOutputText, isReasoning, isRefusal, isToolCall, isToolCallOutput, isUrlCitation, json, systemText, text, toolCallOutput, userText };
@@ -1,4 +1,5 @@
1
1
  import { n as __exportAll } from "../rolldown-runtime-EAsCxrDo.mjs";
2
+ import { FileSource } from "./File.mjs";
2
3
  import { ImageSource } from "./Image.mjs";
3
4
  import { Schema } from "effect";
4
5
  //#region src/domain/Items.ts
@@ -9,7 +10,9 @@ var Items_exports = /* @__PURE__ */ __exportAll({
9
10
  FileCitation: () => FileCitation,
10
11
  FilePath: () => FilePath,
11
12
  HistoryItem: () => HistoryItem,
13
+ InputFile: () => InputFile,
12
14
  InputImage: () => InputImage,
15
+ InputJson: () => InputJson,
13
16
  InputText: () => InputText,
14
17
  InputTokensDetails: () => InputTokensDetails,
15
18
  Message: () => Message,
@@ -22,13 +25,18 @@ var Items_exports = /* @__PURE__ */ __exportAll({
22
25
  StopReason: () => StopReason,
23
26
  ToolCall: () => ToolCall,
24
27
  ToolCallOutput: () => ToolCallOutput,
28
+ ToolOutputContent: () => ToolOutputContent,
25
29
  UrlCitation: () => UrlCitation,
26
30
  Usage: () => Usage,
27
31
  assistantText: () => assistantText,
32
+ file: () => file,
33
+ image: () => image,
28
34
  isContainerFileCitation: () => isContainerFileCitation,
29
35
  isFileCitation: () => isFileCitation,
30
36
  isFilePath: () => isFilePath,
37
+ isInputFile: () => isInputFile,
31
38
  isInputImage: () => isInputImage,
39
+ isInputJson: () => isInputJson,
32
40
  isInputText: () => isInputText,
33
41
  isMessage: () => isMessage,
34
42
  isOutputImage: () => isOutputImage,
@@ -38,7 +46,9 @@ var Items_exports = /* @__PURE__ */ __exportAll({
38
46
  isToolCall: () => isToolCall,
39
47
  isToolCallOutput: () => isToolCallOutput,
40
48
  isUrlCitation: () => isUrlCitation,
49
+ json: () => json,
41
50
  systemText: () => systemText,
51
+ text: () => text,
42
52
  toolCallOutput: () => toolCallOutput,
43
53
  userText: () => userText
44
54
  });
@@ -59,6 +69,18 @@ const InputImage = Schema.Struct({
59
69
  source: ImageSource
60
70
  });
61
71
  /**
72
+ * User-provided file: a document (PDF, text, docx), audio or video. The
73
+ * `source` MIME type says which; provider codecs map it to their own file
74
+ * part, and a provider that cannot read a type rejects the request.
75
+ *
76
+ * Not in `ContentBlock` yet: it joins once every provider codec encodes it.
77
+ */
78
+ const InputFile = Schema.Struct({
79
+ type: Schema.Literal("input_file"),
80
+ source: FileSource,
81
+ filename: Schema.optionalKey(Schema.String)
82
+ });
83
+ /**
62
84
  * A cited source. `url` + `title` are the only near-universal fields; the
63
85
  * link from a source to the answer text varies by provider, so it is optional
64
86
  * and expressed three ways: `start_index`/`end_index` (a character span into
@@ -157,10 +179,23 @@ const ToolCall = Schema.Struct({
157
179
  arguments: Schema.String,
158
180
  providerData: ProviderData
159
181
  });
182
+ /** A JSON value in a tool output. Kept as a value; provider codecs serialize it. */
183
+ const InputJson = Schema.Struct({
184
+ type: Schema.Literal("input_json"),
185
+ value: Schema.Json
186
+ });
187
+ const ToolOutputContent = Schema.Union([
188
+ InputText,
189
+ InputJson,
190
+ InputImage,
191
+ InputFile
192
+ ]);
160
193
  const ToolCallOutput = Schema.Struct({
161
194
  type: Schema.Literal("function_call_output"),
162
195
  call_id: Schema.String,
163
- output: Schema.String,
196
+ output: Schema.Array(ToolOutputContent),
197
+ /** The call failed. Native on some providers; others only see the content. */
198
+ isError: Schema.optionalKey(Schema.Boolean),
164
199
  providerData: ProviderData
165
200
  });
166
201
  /**
@@ -184,6 +219,8 @@ const HistoryItem = Schema.Union([
184
219
  ]);
185
220
  const isInputText = Schema.is(InputText);
186
221
  const isInputImage = Schema.is(InputImage);
222
+ const isInputFile = Schema.is(InputFile);
223
+ const isInputJson = Schema.is(InputJson);
187
224
  const isOutputText = Schema.is(OutputText);
188
225
  const isOutputImage = Schema.is(OutputImage);
189
226
  const isRefusal = Schema.is(Refusal);
@@ -246,12 +283,36 @@ const assistantText = (text) => ({
246
283
  text
247
284
  }]
248
285
  });
249
- const toolCallOutput = (call_id, output) => ({
286
+ /** A tool output with one text part. */
287
+ const toolCallOutput = (call_id, text) => ({
250
288
  type: "function_call_output",
251
289
  call_id,
252
- output
290
+ output: [{
291
+ type: "input_text",
292
+ text
293
+ }]
294
+ });
295
+ const text = (text) => ({
296
+ type: "input_text",
297
+ text
298
+ });
299
+ const json = (value) => ({
300
+ type: "input_json",
301
+ value
302
+ });
303
+ const image = (source) => ({
304
+ type: "input_image",
305
+ source
253
306
  });
307
+ const file = (source, filename) => filename === void 0 ? {
308
+ type: "input_file",
309
+ source
310
+ } : {
311
+ type: "input_file",
312
+ source,
313
+ filename
314
+ };
254
315
  //#endregion
255
- export { Annotation, ContainerFileCitation, ContentBlock, FileCitation, FilePath, HistoryItem, InputImage, InputText, InputTokensDetails, Message, OutputImage, OutputText, OutputTokensDetails, Reasoning, Refusal, Role, StopReason, ToolCall, ToolCallOutput, UrlCitation, Usage, assistantText, isContainerFileCitation, isFileCitation, isFilePath, isInputImage, isInputText, isMessage, isOutputImage, isOutputText, isReasoning, isRefusal, isToolCall, isToolCallOutput, isUrlCitation, systemText, Items_exports as t, toolCallOutput, userText };
316
+ export { Annotation, ContainerFileCitation, ContentBlock, FileCitation, FilePath, HistoryItem, InputFile, InputImage, InputJson, InputText, InputTokensDetails, Message, OutputImage, OutputText, OutputTokensDetails, Reasoning, Refusal, Role, StopReason, ToolCall, ToolCallOutput, ToolOutputContent, UrlCitation, Usage, assistantText, file, image, isContainerFileCitation, isFileCitation, isFilePath, isInputFile, isInputImage, isInputJson, isInputText, isMessage, isOutputImage, isOutputText, isReasoning, isRefusal, isToolCall, isToolCallOutput, isUrlCitation, json, systemText, Items_exports as t, text, toolCallOutput, userText };
256
317
 
257
318
  //# sourceMappingURL=Items.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Items.mjs","names":[],"sources":["../../src/domain/Items.ts"],"sourcesContent":["import { Schema } from \"effect\"\nimport { ImageSource } from \"./Image.js\"\n\n// ---------------------------------------------------------------------------\n// Content blocks (inside Message.content)\n// ---------------------------------------------------------------------------\n\nexport const InputText = Schema.Struct({\n type: Schema.Literal(\"input_text\"),\n text: Schema.String,\n})\nexport type InputText = typeof InputText.Type\n\n/**\n * User-provided image content block. Pair with `InputText` inside a\n * `Message.content` array to ask \"what's in this image?\" style questions.\n *\n * `source` is the cross-modality `ImageSource` from `domain/Image.ts` -\n * url, base64, or raw bytes. Provider codecs encode bytes to whatever\n * wire format the provider wants.\n */\nexport const InputImage = Schema.Struct({\n type: Schema.Literal(\"input_image\"),\n source: ImageSource,\n})\nexport type InputImage = typeof InputImage.Type\n\n// ---------------------------------------------------------------------------\n// Annotations - source / citation pointers attached to `output_text` blocks.\n// Provider-agnostic: each provider populates the fields it has (character\n// span, quote, or positional marker) and omits the rest.\n// ---------------------------------------------------------------------------\n\n/**\n * A cited source. `url` + `title` are the only near-universal fields; the\n * link from a source to the answer text varies by provider, so it is optional\n * and expressed three ways: `start_index`/`end_index` (a character span into\n * the answer), `cited_text` (an exact quote of the source, when no offsets are\n * given), or `marker` (a positional `[n]` reference into an ordered list). A\n * provider populates whichever it has; a bare source list sets none.\n */\nexport const UrlCitation = Schema.Struct({\n type: Schema.Literal(\"url_citation\"),\n url: Schema.String,\n title: Schema.String,\n start_index: Schema.optional(Schema.Number),\n end_index: Schema.optional(Schema.Number),\n cited_text: Schema.optional(Schema.String),\n marker: Schema.optional(Schema.Number),\n})\nexport type UrlCitation = typeof UrlCitation.Type\n\nexport const FileCitation = Schema.Struct({\n type: Schema.Literal(\"file_citation\"),\n file_id: Schema.String,\n index: Schema.Number,\n})\nexport type FileCitation = typeof FileCitation.Type\n\nexport const ContainerFileCitation = Schema.Struct({\n type: Schema.Literal(\"container_file_citation\"),\n container_id: Schema.String,\n file_id: Schema.String,\n start_index: Schema.Number,\n end_index: Schema.Number,\n})\nexport type ContainerFileCitation = typeof ContainerFileCitation.Type\n\nexport const FilePath = Schema.Struct({\n type: Schema.Literal(\"file_path\"),\n file_id: Schema.String,\n index: Schema.Number,\n})\nexport type FilePath = typeof FilePath.Type\n\nexport const Annotation = Schema.Union([UrlCitation, FileCitation, ContainerFileCitation, FilePath])\nexport type Annotation = typeof Annotation.Type\n\nexport const isUrlCitation = Schema.is(UrlCitation)\nexport const isFileCitation = Schema.is(FileCitation)\nexport const isContainerFileCitation = Schema.is(ContainerFileCitation)\nexport const isFilePath = Schema.is(FilePath)\n\nexport const OutputText = Schema.Struct({\n type: Schema.Literal(\"output_text\"),\n text: Schema.String,\n annotations: Schema.optional(Schema.Array(Annotation)),\n})\nexport type OutputText = typeof OutputText.Type\n\n/**\n * Model-emitted image. The counterpart to {@link InputImage}: same\n * `ImageSource`, so an image the model drew goes straight back into the\n * next turn with no conversion.\n *\n * How the pixels were produced is not modelled here. A provider may draw\n * them itself, as an image part of the turn, or reach a hosted tool that\n * draws them; either way the fact is the same, and enabling it is\n * provider-specific.\n */\nexport const OutputImage = Schema.Struct({\n type: Schema.Literal(\"output_image\"),\n source: ImageSource,\n})\nexport type OutputImage = typeof OutputImage.Type\n\n/**\n * Model-emitted refusal. Distinct from `output_text`: the model declined\n * to answer rather than producing normal output. Pair with\n * `stop_reason: \"refusal\"` on the surrounding `Turn`. Streamed via the\n * `RefusalDelta` `TurnEvent`.\n */\nexport const Refusal = Schema.Struct({\n type: Schema.Literal(\"refusal\"),\n text: Schema.String,\n})\nexport type Refusal = typeof Refusal.Type\n\nexport const ContentBlock = Schema.Union([InputText, InputImage, OutputText, OutputImage, Refusal])\nexport type ContentBlock = typeof ContentBlock.Type\n\nexport const Role = Schema.Literals([\"user\", \"assistant\", \"system\"])\nexport type Role = typeof Role.Type\n\n// ---------------------------------------------------------------------------\n// Provider passthrough - every Item type carries this opaque slot.\n// The framework never reads or interprets it; provider modules decode\n// their own data via their own typed readers (see e.g.\n// the `@effect-uai/responses` package).\n//\n// The slot is shared, so a provider keys its data under its own name\n// (`{ responses: ... }`, `{ gemini: ... }`) and reads only that key. One item\n// can pass through several providers - falling back from one to another\n// leaves both keys on it - and a provider that finds no key of its own must\n// encode the item normally rather than assume the slot is its own.\n// ---------------------------------------------------------------------------\n\nconst ProviderData = Schema.optional(Schema.Unknown)\n\n// ---------------------------------------------------------------------------\n// Items\n// ---------------------------------------------------------------------------\n\nexport const Message = Schema.Struct({\n type: Schema.Literal(\"message\"),\n role: Role,\n content: Schema.Array(ContentBlock),\n providerData: ProviderData,\n})\nexport type Message = typeof Message.Type\n\nexport const ToolCall = Schema.Struct({\n type: Schema.Literal(\"function_call\"),\n call_id: Schema.String,\n name: Schema.String,\n // JSON-encoded arguments string, mirroring OpenAI Responses API\n arguments: Schema.String,\n providerData: ProviderData,\n})\nexport type ToolCall = typeof ToolCall.Type\n\nexport const ToolCallOutput = Schema.Struct({\n type: Schema.Literal(\"function_call_output\"),\n call_id: Schema.String,\n output: Schema.String,\n providerData: ProviderData,\n})\nexport type ToolCallOutput = typeof ToolCallOutput.Type\n\n/**\n * Reasoning item - top-level, mirrors OpenAI Responses API. Common shape\n * across providers covers `summary` (human-readable text) and `signature`\n * (opaque round-trip blob - Anthropic's signed thinking, OpenAI's\n * encrypted_content, etc.). Provider-specific fields go in `providerData`.\n */\nexport const Reasoning = Schema.Struct({\n type: Schema.Literal(\"reasoning\"),\n id: Schema.optional(Schema.String),\n summary: Schema.optional(Schema.String),\n signature: Schema.optional(Schema.String),\n providerData: ProviderData,\n})\nexport type Reasoning = typeof Reasoning.Type\n\nexport const HistoryItem = Schema.Union([Message, ToolCall, ToolCallOutput, Reasoning])\nexport type HistoryItem = typeof HistoryItem.Type\n\n// ---------------------------------------------------------------------------\n// Type guards\n// ---------------------------------------------------------------------------\n\nexport const isInputText = Schema.is(InputText)\nexport const isInputImage = Schema.is(InputImage)\nexport const isOutputText = Schema.is(OutputText)\nexport const isOutputImage = Schema.is(OutputImage)\nexport const isRefusal = Schema.is(Refusal)\n\nexport const isMessage = Schema.is(Message)\nexport const isToolCall = Schema.is(ToolCall)\nexport const isToolCallOutput = Schema.is(ToolCallOutput)\nexport const isReasoning = Schema.is(Reasoning)\n\n// ---------------------------------------------------------------------------\n// Usage and stop reason\n// ---------------------------------------------------------------------------\n\n/**\n * Prompt-cache token breakdown. `cached_tokens` is cache reads;\n * `cache_write_tokens` is tokens written to the cache this turn (billed at a\n * premium). Field names mirror the OpenAI Responses usage shape.\n *\n * Whether these are a subset of `input_tokens` or a separate bucket is\n * provider-specific: OpenAI counts cache reads inside `input_tokens`, while\n * Anthropic reports `input_tokens` as post-breakpoint tokens only, with reads\n * and writes as separate additive buckets. Read a provider's usage in its own\n * terms; do not assume one relationship holds everywhere.\n */\nexport const InputTokensDetails = Schema.Struct({\n cached_tokens: Schema.optional(Schema.Number),\n cache_write_tokens: Schema.optional(Schema.Number),\n})\nexport type InputTokensDetails = typeof InputTokensDetails.Type\n\nexport const OutputTokensDetails = Schema.Struct({\n reasoning_tokens: Schema.optional(Schema.Number),\n})\nexport type OutputTokensDetails = typeof OutputTokensDetails.Type\n\nexport const Usage = Schema.Struct({\n input_tokens: Schema.optional(Schema.Number),\n output_tokens: Schema.optional(Schema.Number),\n total_tokens: Schema.optional(Schema.Number),\n input_tokens_details: Schema.optional(InputTokensDetails),\n output_tokens_details: Schema.optional(OutputTokensDetails),\n})\nexport type Usage = typeof Usage.Type\n\nexport const StopReason = Schema.Literals([\n \"stop\",\n \"tool_calls\",\n \"max_tokens\",\n \"refusal\",\n /** Provider-side safety classifier flagged the output. */\n \"content_filter\",\n /** Server-enforced cap on tool calls per turn was hit. */\n \"max_tool_calls\",\n])\nexport type StopReason = typeof StopReason.Type\n\n// ---------------------------------------------------------------------------\n// Helper constructors\n// ---------------------------------------------------------------------------\n\nexport const userText = (text: string): Message => ({\n type: \"message\",\n role: \"user\",\n content: [{ type: \"input_text\", text }],\n})\n\nexport const systemText = (text: string): Message => ({\n type: \"message\",\n role: \"system\",\n content: [{ type: \"input_text\", text }],\n})\n\nexport const assistantText = (text: string): Message => ({\n type: \"message\",\n role: \"assistant\",\n content: [{ type: \"output_text\", text }],\n})\n\nexport const toolCallOutput = (call_id: string, output: string): ToolCallOutput => ({\n type: \"function_call_output\",\n call_id,\n output,\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAa,YAAY,OAAO,OAAO;CACrC,MAAM,OAAO,QAAQ,YAAY;CACjC,MAAM,OAAO;AACf,CAAC;;;;;;;;;AAWD,MAAa,aAAa,OAAO,OAAO;CACtC,MAAM,OAAO,QAAQ,aAAa;CAClC,QAAQ;AAC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,MAAM;CAC5C,oBAAoB,OAAO,SAAS,OAAO,MAAM;AACnD,CAAC;AAGD,MAAa,sBAAsB,OAAO,OAAO,EAC/C,kBAAkB,OAAO,SAAS,OAAO,MAAM,EACjD,CAAC;AAGD,MAAa,QAAQ,OAAO,OAAO;CACjC,cAAc,OAAO,SAAS,OAAO,MAAM;CAC3C,eAAe,OAAO,SAAS,OAAO,MAAM;CAC5C,cAAc,OAAO,SAAS,OAAO,MAAM;CAC3C,sBAAsB,OAAO,SAAS,kBAAkB;CACxD,uBAAuB,OAAO,SAAS,mBAAmB;AAC5D,CAAC;AAGD,MAAa,aAAa,OAAO,SAAS;CACxC;CACA;CACA;CACA;CAEA;CAEA;AACF,CAAC;AAOD,MAAa,YAAY,UAA2B;CAClD,MAAM;CACN,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAc;CAAK,CAAC;AACxC;AAEA,MAAa,cAAc,UAA2B;CACpD,MAAM;CACN,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAc;CAAK,CAAC;AACxC;AAEA,MAAa,iBAAiB,UAA2B;CACvD,MAAM;CACN,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAe;CAAK,CAAC;AACzC;AAEA,MAAa,kBAAkB,SAAiB,YAAoC;CAClF,MAAM;CACN;CACA;AACF"}
1
+ {"version":3,"file":"Items.mjs","names":[],"sources":["../../src/domain/Items.ts"],"sourcesContent":["import { Schema } from \"effect\"\nimport { FileSource } from \"./File.js\"\nimport { ImageSource } from \"./Image.js\"\n\n// ---------------------------------------------------------------------------\n// Content blocks (inside Message.content)\n// ---------------------------------------------------------------------------\n\nexport const InputText = Schema.Struct({\n type: Schema.Literal(\"input_text\"),\n text: Schema.String,\n})\nexport type InputText = typeof InputText.Type\n\n/**\n * User-provided image content block. Pair with `InputText` inside a\n * `Message.content` array to ask \"what's in this image?\" style questions.\n *\n * `source` is the cross-modality `ImageSource` from `domain/Image.ts` -\n * url, base64, or raw bytes. Provider codecs encode bytes to whatever\n * wire format the provider wants.\n */\nexport const InputImage = Schema.Struct({\n type: Schema.Literal(\"input_image\"),\n source: ImageSource,\n})\nexport type InputImage = typeof InputImage.Type\n\n/**\n * User-provided file: a document (PDF, text, docx), audio or video. The\n * `source` MIME type says which; provider codecs map it to their own file\n * part, and a provider that cannot read a type rejects the request.\n *\n * Not in `ContentBlock` yet: it joins once every provider codec encodes it.\n */\nexport const InputFile = Schema.Struct({\n type: Schema.Literal(\"input_file\"),\n source: FileSource,\n filename: Schema.optionalKey(Schema.String),\n})\nexport type InputFile = typeof InputFile.Type\n\n// ---------------------------------------------------------------------------\n// Annotations - source / citation pointers attached to `output_text` blocks.\n// Provider-agnostic: each provider populates the fields it has (character\n// span, quote, or positional marker) and omits the rest.\n// ---------------------------------------------------------------------------\n\n/**\n * A cited source. `url` + `title` are the only near-universal fields; the\n * link from a source to the answer text varies by provider, so it is optional\n * and expressed three ways: `start_index`/`end_index` (a character span into\n * the answer), `cited_text` (an exact quote of the source, when no offsets are\n * given), or `marker` (a positional `[n]` reference into an ordered list). A\n * provider populates whichever it has; a bare source list sets none.\n */\nexport const UrlCitation = Schema.Struct({\n type: Schema.Literal(\"url_citation\"),\n url: Schema.String,\n title: Schema.String,\n start_index: Schema.optional(Schema.Number),\n end_index: Schema.optional(Schema.Number),\n cited_text: Schema.optional(Schema.String),\n marker: Schema.optional(Schema.Number),\n})\nexport type UrlCitation = typeof UrlCitation.Type\n\nexport const FileCitation = Schema.Struct({\n type: Schema.Literal(\"file_citation\"),\n file_id: Schema.String,\n index: Schema.Number,\n})\nexport type FileCitation = typeof FileCitation.Type\n\nexport const ContainerFileCitation = Schema.Struct({\n type: Schema.Literal(\"container_file_citation\"),\n container_id: Schema.String,\n file_id: Schema.String,\n start_index: Schema.Number,\n end_index: Schema.Number,\n})\nexport type ContainerFileCitation = typeof ContainerFileCitation.Type\n\nexport const FilePath = Schema.Struct({\n type: Schema.Literal(\"file_path\"),\n file_id: Schema.String,\n index: Schema.Number,\n})\nexport type FilePath = typeof FilePath.Type\n\nexport const Annotation = Schema.Union([UrlCitation, FileCitation, ContainerFileCitation, FilePath])\nexport type Annotation = typeof Annotation.Type\n\nexport const isUrlCitation = Schema.is(UrlCitation)\nexport const isFileCitation = Schema.is(FileCitation)\nexport const isContainerFileCitation = Schema.is(ContainerFileCitation)\nexport const isFilePath = Schema.is(FilePath)\n\nexport const OutputText = Schema.Struct({\n type: Schema.Literal(\"output_text\"),\n text: Schema.String,\n annotations: Schema.optional(Schema.Array(Annotation)),\n})\nexport type OutputText = typeof OutputText.Type\n\n/**\n * Model-emitted image. The counterpart to {@link InputImage}: same\n * `ImageSource`, so an image the model drew goes straight back into the\n * next turn with no conversion.\n *\n * How the pixels were produced is not modelled here. A provider may draw\n * them itself, as an image part of the turn, or reach a hosted tool that\n * draws them; either way the fact is the same, and enabling it is\n * provider-specific.\n */\nexport const OutputImage = Schema.Struct({\n type: Schema.Literal(\"output_image\"),\n source: ImageSource,\n})\nexport type OutputImage = typeof OutputImage.Type\n\n/**\n * Model-emitted refusal. Distinct from `output_text`: the model declined\n * to answer rather than producing normal output. Pair with\n * `stop_reason: \"refusal\"` on the surrounding `Turn`. Streamed via the\n * `RefusalDelta` `TurnEvent`.\n */\nexport const Refusal = Schema.Struct({\n type: Schema.Literal(\"refusal\"),\n text: Schema.String,\n})\nexport type Refusal = typeof Refusal.Type\n\nexport const ContentBlock = Schema.Union([InputText, InputImage, OutputText, OutputImage, Refusal])\nexport type ContentBlock = typeof ContentBlock.Type\n\nexport const Role = Schema.Literals([\"user\", \"assistant\", \"system\"])\nexport type Role = typeof Role.Type\n\n// ---------------------------------------------------------------------------\n// Provider passthrough - every Item type carries this opaque slot.\n// The framework never reads or interprets it; provider modules decode\n// their own data via their own typed readers (see e.g.\n// the `@effect-uai/responses` package).\n//\n// The slot is shared, so a provider keys its data under its own name\n// (`{ responses: ... }`, `{ gemini: ... }`) and reads only that key. One item\n// can pass through several providers - falling back from one to another\n// leaves both keys on it - and a provider that finds no key of its own must\n// encode the item normally rather than assume the slot is its own.\n// ---------------------------------------------------------------------------\n\nconst ProviderData = Schema.optional(Schema.Unknown)\n\n// ---------------------------------------------------------------------------\n// Items\n// ---------------------------------------------------------------------------\n\nexport const Message = Schema.Struct({\n type: Schema.Literal(\"message\"),\n role: Role,\n content: Schema.Array(ContentBlock),\n providerData: ProviderData,\n})\nexport type Message = typeof Message.Type\n\nexport const ToolCall = Schema.Struct({\n type: Schema.Literal(\"function_call\"),\n call_id: Schema.String,\n name: Schema.String,\n // JSON-encoded arguments string, mirroring OpenAI Responses API\n arguments: Schema.String,\n providerData: ProviderData,\n})\nexport type ToolCall = typeof ToolCall.Type\n\n/** A JSON value in a tool output. Kept as a value; provider codecs serialize it. */\nexport const InputJson = Schema.Struct({\n type: Schema.Literal(\"input_json\"),\n value: Schema.Json,\n})\nexport type InputJson = typeof InputJson.Type\n\nexport const ToolOutputContent = Schema.Union([InputText, InputJson, InputImage, InputFile])\nexport type ToolOutputContent = typeof ToolOutputContent.Type\n\nexport const ToolCallOutput = Schema.Struct({\n type: Schema.Literal(\"function_call_output\"),\n call_id: Schema.String,\n output: Schema.Array(ToolOutputContent),\n /** The call failed. Native on some providers; others only see the content. */\n isError: Schema.optionalKey(Schema.Boolean),\n providerData: ProviderData,\n})\nexport type ToolCallOutput = typeof ToolCallOutput.Type\n\n/**\n * Reasoning item - top-level, mirrors OpenAI Responses API. Common shape\n * across providers covers `summary` (human-readable text) and `signature`\n * (opaque round-trip blob - Anthropic's signed thinking, OpenAI's\n * encrypted_content, etc.). Provider-specific fields go in `providerData`.\n */\nexport const Reasoning = Schema.Struct({\n type: Schema.Literal(\"reasoning\"),\n id: Schema.optional(Schema.String),\n summary: Schema.optional(Schema.String),\n signature: Schema.optional(Schema.String),\n providerData: ProviderData,\n})\nexport type Reasoning = typeof Reasoning.Type\n\nexport const HistoryItem = Schema.Union([Message, ToolCall, ToolCallOutput, Reasoning])\nexport type HistoryItem = typeof HistoryItem.Type\n\n// ---------------------------------------------------------------------------\n// Type guards\n// ---------------------------------------------------------------------------\n\nexport const isInputText = Schema.is(InputText)\nexport const isInputImage = Schema.is(InputImage)\nexport const isInputFile = Schema.is(InputFile)\nexport const isInputJson = Schema.is(InputJson)\nexport const isOutputText = Schema.is(OutputText)\nexport const isOutputImage = Schema.is(OutputImage)\nexport const isRefusal = Schema.is(Refusal)\n\nexport const isMessage = Schema.is(Message)\nexport const isToolCall = Schema.is(ToolCall)\nexport const isToolCallOutput = Schema.is(ToolCallOutput)\nexport const isReasoning = Schema.is(Reasoning)\n\n// ---------------------------------------------------------------------------\n// Usage and stop reason\n// ---------------------------------------------------------------------------\n\n/**\n * Prompt-cache token breakdown. `cached_tokens` is cache reads;\n * `cache_write_tokens` is tokens written to the cache this turn (billed at a\n * premium). Field names mirror the OpenAI Responses usage shape.\n *\n * Whether these are a subset of `input_tokens` or a separate bucket is\n * provider-specific: OpenAI counts cache reads inside `input_tokens`, while\n * Anthropic reports `input_tokens` as post-breakpoint tokens only, with reads\n * and writes as separate additive buckets. Read a provider's usage in its own\n * terms; do not assume one relationship holds everywhere.\n */\nexport const InputTokensDetails = Schema.Struct({\n cached_tokens: Schema.optional(Schema.Number),\n cache_write_tokens: Schema.optional(Schema.Number),\n})\nexport type InputTokensDetails = typeof InputTokensDetails.Type\n\nexport const OutputTokensDetails = Schema.Struct({\n reasoning_tokens: Schema.optional(Schema.Number),\n})\nexport type OutputTokensDetails = typeof OutputTokensDetails.Type\n\nexport const Usage = Schema.Struct({\n input_tokens: Schema.optional(Schema.Number),\n output_tokens: Schema.optional(Schema.Number),\n total_tokens: Schema.optional(Schema.Number),\n input_tokens_details: Schema.optional(InputTokensDetails),\n output_tokens_details: Schema.optional(OutputTokensDetails),\n})\nexport type Usage = typeof Usage.Type\n\nexport const StopReason = Schema.Literals([\n \"stop\",\n \"tool_calls\",\n \"max_tokens\",\n \"refusal\",\n /** Provider-side safety classifier flagged the output. */\n \"content_filter\",\n /** Server-enforced cap on tool calls per turn was hit. */\n \"max_tool_calls\",\n])\nexport type StopReason = typeof StopReason.Type\n\n// ---------------------------------------------------------------------------\n// Helper constructors\n// ---------------------------------------------------------------------------\n\nexport const userText = (text: string): Message => ({\n type: \"message\",\n role: \"user\",\n content: [{ type: \"input_text\", text }],\n})\n\nexport const systemText = (text: string): Message => ({\n type: \"message\",\n role: \"system\",\n content: [{ type: \"input_text\", text }],\n})\n\nexport const assistantText = (text: string): Message => ({\n type: \"message\",\n role: \"assistant\",\n content: [{ type: \"output_text\", text }],\n})\n\n/** A tool output with one text part. */\nexport const toolCallOutput = (call_id: string, text: string): ToolCallOutput => ({\n type: \"function_call_output\",\n call_id,\n output: [{ type: \"input_text\", text }],\n})\n\nexport const text = (text: string): InputText => ({ type: \"input_text\", text })\nexport const json = (value: Schema.Json): InputJson => ({ type: \"input_json\", value })\nexport const image = (source: ImageSource): InputImage => ({ type: \"input_image\", source })\nexport const file = (source: FileSource, filename?: string): InputFile =>\n filename === undefined ? { type: \"input_file\", source } : { type: \"input_file\", source, filename }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAa,YAAY,OAAO,OAAO;CACrC,MAAM,OAAO,QAAQ,YAAY;CACjC,MAAM,OAAO;AACf,CAAC;;;;;;;;;AAWD,MAAa,aAAa,OAAO,OAAO;CACtC,MAAM,OAAO,QAAQ,aAAa;CAClC,QAAQ;AACV,CAAC;;;;;;;;AAUD,MAAa,YAAY,OAAO,OAAO;CACrC,MAAM,OAAO,QAAQ,YAAY;CACjC,QAAQ;CACR,UAAU,OAAO,YAAY,OAAO,MAAM;AAC5C,CAAC;;;;;;;;;AAiBD,MAAa,cAAc,OAAO,OAAO;CACvC,MAAM,OAAO,QAAQ,cAAc;CACnC,KAAK,OAAO;CACZ,OAAO,OAAO;CACd,aAAa,OAAO,SAAS,OAAO,MAAM;CAC1C,WAAW,OAAO,SAAS,OAAO,MAAM;CACxC,YAAY,OAAO,SAAS,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