@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
@@ -71,452 +71,71 @@ type Call = Data.TaggedEnum<{
71
71
  readonly id: VolumeId;
72
72
  };
73
73
  }>;
74
- declare const Call: {
75
- readonly $is: <Tag extends "Attach" | "Create" | "Destroy" | "Exec" | "ExecStream" | "ExposePort" | "FileExists" | "FileList" | "FileMkdir" | "FileRead" | "FileRemove" | "FileWrite" | "SnapshotCreate" | "SnapshotDestroy" | "Spawn" | "VolumeCreate" | "VolumeDestroy">(tag: Tag) => (u: unknown) => u is Extract<{
76
- readonly _tag: "Attach";
77
- readonly id: SandboxId;
78
- }, {
79
- readonly _tag: Tag;
80
- }> | Extract<{
81
- readonly _tag: "Create";
82
- readonly request: CommonCreateRequest;
83
- }, {
84
- readonly _tag: Tag;
85
- }> | Extract<{
86
- readonly _tag: "Destroy";
87
- readonly id: SandboxId;
88
- }, {
89
- readonly _tag: Tag;
90
- }> | Extract<{
91
- readonly _tag: "Exec";
92
- readonly id: SandboxId;
93
- readonly request: CommonExecRequest;
94
- }, {
95
- readonly _tag: Tag;
96
- }> | Extract<{
97
- readonly _tag: "ExecStream";
98
- readonly id: SandboxId;
99
- readonly request: CommonExecRequest;
100
- }, {
101
- readonly _tag: Tag;
102
- }> | Extract<{
103
- readonly _tag: "ExposePort";
104
- readonly id: SandboxId;
105
- readonly port: number;
106
- }, {
107
- readonly _tag: Tag;
108
- }> | Extract<{
109
- readonly _tag: "FileExists";
110
- readonly id: SandboxId;
111
- readonly path: string;
112
- }, {
113
- readonly _tag: Tag;
114
- }> | Extract<{
115
- readonly _tag: "FileList";
116
- readonly id: SandboxId;
117
- readonly path: string;
118
- }, {
119
- readonly _tag: Tag;
120
- }> | Extract<{
121
- readonly _tag: "FileMkdir";
122
- readonly id: SandboxId;
123
- readonly path: string;
124
- }, {
125
- readonly _tag: Tag;
126
- }> | Extract<{
127
- readonly _tag: "FileRead";
128
- readonly id: SandboxId;
129
- readonly path: string;
130
- }, {
131
- readonly _tag: Tag;
132
- }> | Extract<{
133
- readonly _tag: "FileRemove";
134
- readonly id: SandboxId;
135
- readonly path: string;
136
- }, {
137
- readonly _tag: Tag;
138
- }> | Extract<{
139
- readonly _tag: "FileWrite";
140
- readonly id: SandboxId;
141
- readonly path: string;
142
- readonly contents: Uint8Array | string;
143
- }, {
144
- readonly _tag: Tag;
145
- }> | Extract<{
146
- readonly _tag: "SnapshotCreate";
147
- readonly id: SandboxId;
148
- readonly name?: string;
149
- }, {
150
- readonly _tag: Tag;
151
- }> | Extract<{
152
- readonly _tag: "SnapshotDestroy";
153
- readonly id: SnapshotId;
154
- }, {
155
- readonly _tag: Tag;
156
- }> | Extract<{
157
- readonly _tag: "Spawn";
158
- readonly id: SandboxId;
159
- readonly request: CommonSpawnRequest;
160
- }, {
161
- readonly _tag: Tag;
162
- }> | Extract<{
163
- readonly _tag: "VolumeCreate";
164
- readonly name: string;
165
- readonly quotaBytes?: number;
166
- }, {
167
- readonly _tag: Tag;
168
- }> | Extract<{
169
- readonly _tag: "VolumeDestroy";
170
- readonly id: VolumeId;
171
- }, {
172
- readonly _tag: Tag;
173
- }>;
174
- readonly $match: {
175
- <Cases extends { readonly [Tag in "Attach" | "Create" | "Destroy" | "Exec" | "ExecStream" | "ExposePort" | "FileExists" | "FileList" | "FileMkdir" | "FileRead" | "FileRemove" | "FileWrite" | "SnapshotCreate" | "SnapshotDestroy" | "Spawn" | "VolumeCreate" | "VolumeDestroy"]: (args: Extract<{
176
- readonly _tag: "Attach";
177
- readonly id: SandboxId;
178
- } | {
179
- readonly _tag: "Create";
180
- readonly request: CommonCreateRequest;
181
- } | {
182
- readonly _tag: "Destroy";
183
- readonly id: SandboxId;
184
- } | {
185
- readonly _tag: "Exec";
186
- readonly id: SandboxId;
187
- readonly request: CommonExecRequest;
188
- } | {
189
- readonly _tag: "ExecStream";
190
- readonly id: SandboxId;
191
- readonly request: CommonExecRequest;
192
- } | {
193
- readonly _tag: "ExposePort";
194
- readonly id: SandboxId;
195
- readonly port: number;
196
- } | {
197
- readonly _tag: "FileExists";
198
- readonly id: SandboxId;
199
- readonly path: string;
200
- } | {
201
- readonly _tag: "FileList";
202
- readonly id: SandboxId;
203
- readonly path: string;
204
- } | {
205
- readonly _tag: "FileMkdir";
206
- readonly id: SandboxId;
207
- readonly path: string;
208
- } | {
209
- readonly _tag: "FileRead";
210
- readonly id: SandboxId;
211
- readonly path: string;
212
- } | {
213
- readonly _tag: "FileRemove";
214
- readonly id: SandboxId;
215
- readonly path: string;
216
- } | {
217
- readonly _tag: "FileWrite";
218
- readonly id: SandboxId;
219
- readonly path: string;
220
- readonly contents: Uint8Array | string;
221
- } | {
222
- readonly _tag: "SnapshotCreate";
223
- readonly id: SandboxId;
224
- readonly name?: string;
225
- } | {
226
- readonly _tag: "SnapshotDestroy";
227
- readonly id: SnapshotId;
228
- } | {
229
- readonly _tag: "Spawn";
230
- readonly id: SandboxId;
231
- readonly request: CommonSpawnRequest;
232
- } | {
233
- readonly _tag: "VolumeCreate";
234
- readonly name: string;
235
- readonly quotaBytes?: number;
236
- } | {
237
- readonly _tag: "VolumeDestroy";
238
- readonly id: VolumeId;
239
- }, {
240
- readonly _tag: Tag;
241
- }>) => any; }>(cases: Cases): (value: {
242
- readonly _tag: "Attach";
243
- readonly id: SandboxId;
244
- } | {
245
- readonly _tag: "Create";
246
- readonly request: CommonCreateRequest;
247
- } | {
248
- readonly _tag: "Destroy";
249
- readonly id: SandboxId;
250
- } | {
251
- readonly _tag: "Exec";
252
- readonly id: SandboxId;
253
- readonly request: CommonExecRequest;
254
- } | {
255
- readonly _tag: "ExecStream";
256
- readonly id: SandboxId;
257
- readonly request: CommonExecRequest;
258
- } | {
259
- readonly _tag: "ExposePort";
260
- readonly id: SandboxId;
261
- readonly port: number;
262
- } | {
263
- readonly _tag: "FileExists";
264
- readonly id: SandboxId;
265
- readonly path: string;
266
- } | {
267
- readonly _tag: "FileList";
268
- readonly id: SandboxId;
269
- readonly path: string;
270
- } | {
271
- readonly _tag: "FileMkdir";
272
- readonly id: SandboxId;
273
- readonly path: string;
274
- } | {
275
- readonly _tag: "FileRead";
276
- readonly id: SandboxId;
277
- readonly path: string;
278
- } | {
279
- readonly _tag: "FileRemove";
280
- readonly id: SandboxId;
281
- readonly path: string;
282
- } | {
283
- readonly _tag: "FileWrite";
284
- readonly id: SandboxId;
285
- readonly path: string;
286
- readonly contents: Uint8Array | string;
287
- } | {
288
- readonly _tag: "SnapshotCreate";
289
- readonly id: SandboxId;
290
- readonly name?: string;
291
- } | {
292
- readonly _tag: "SnapshotDestroy";
293
- readonly id: SnapshotId;
294
- } | {
295
- readonly _tag: "Spawn";
296
- readonly id: SandboxId;
297
- readonly request: CommonSpawnRequest;
298
- } | {
299
- readonly _tag: "VolumeCreate";
300
- readonly name: string;
301
- readonly quotaBytes?: number;
302
- } | {
303
- readonly _tag: "VolumeDestroy";
304
- readonly id: VolumeId;
305
- }) => import("effect/Unify").Unify<ReturnType<Cases["Attach" | "Create" | "Destroy" | "Exec" | "ExecStream" | "ExposePort" | "FileExists" | "FileList" | "FileMkdir" | "FileRead" | "FileRemove" | "FileWrite" | "SnapshotCreate" | "SnapshotDestroy" | "Spawn" | "VolumeCreate" | "VolumeDestroy"]>>;
306
- <Cases extends { readonly [Tag in "Attach" | "Create" | "Destroy" | "Exec" | "ExecStream" | "ExposePort" | "FileExists" | "FileList" | "FileMkdir" | "FileRead" | "FileRemove" | "FileWrite" | "SnapshotCreate" | "SnapshotDestroy" | "Spawn" | "VolumeCreate" | "VolumeDestroy"]: (args: Extract<{
307
- readonly _tag: "Attach";
308
- readonly id: SandboxId;
309
- } | {
310
- readonly _tag: "Create";
311
- readonly request: CommonCreateRequest;
312
- } | {
313
- readonly _tag: "Destroy";
314
- readonly id: SandboxId;
315
- } | {
316
- readonly _tag: "Exec";
317
- readonly id: SandboxId;
318
- readonly request: CommonExecRequest;
319
- } | {
320
- readonly _tag: "ExecStream";
321
- readonly id: SandboxId;
322
- readonly request: CommonExecRequest;
323
- } | {
324
- readonly _tag: "ExposePort";
325
- readonly id: SandboxId;
326
- readonly port: number;
327
- } | {
328
- readonly _tag: "FileExists";
329
- readonly id: SandboxId;
330
- readonly path: string;
331
- } | {
332
- readonly _tag: "FileList";
333
- readonly id: SandboxId;
334
- readonly path: string;
335
- } | {
336
- readonly _tag: "FileMkdir";
337
- readonly id: SandboxId;
338
- readonly path: string;
339
- } | {
340
- readonly _tag: "FileRead";
341
- readonly id: SandboxId;
342
- readonly path: string;
343
- } | {
344
- readonly _tag: "FileRemove";
345
- readonly id: SandboxId;
346
- readonly path: string;
347
- } | {
348
- readonly _tag: "FileWrite";
349
- readonly id: SandboxId;
350
- readonly path: string;
351
- readonly contents: Uint8Array | string;
352
- } | {
353
- readonly _tag: "SnapshotCreate";
354
- readonly id: SandboxId;
355
- readonly name?: string;
356
- } | {
357
- readonly _tag: "SnapshotDestroy";
358
- readonly id: SnapshotId;
359
- } | {
360
- readonly _tag: "Spawn";
361
- readonly id: SandboxId;
362
- readonly request: CommonSpawnRequest;
363
- } | {
364
- readonly _tag: "VolumeCreate";
365
- readonly name: string;
366
- readonly quotaBytes?: number;
367
- } | {
368
- readonly _tag: "VolumeDestroy";
369
- readonly id: VolumeId;
370
- }, {
371
- readonly _tag: Tag;
372
- }>) => any; }>(value: {
373
- readonly _tag: "Attach";
374
- readonly id: SandboxId;
375
- } | {
376
- readonly _tag: "Create";
377
- readonly request: CommonCreateRequest;
378
- } | {
379
- readonly _tag: "Destroy";
380
- readonly id: SandboxId;
381
- } | {
382
- readonly _tag: "Exec";
383
- readonly id: SandboxId;
384
- readonly request: CommonExecRequest;
385
- } | {
386
- readonly _tag: "ExecStream";
387
- readonly id: SandboxId;
388
- readonly request: CommonExecRequest;
389
- } | {
390
- readonly _tag: "ExposePort";
391
- readonly id: SandboxId;
392
- readonly port: number;
393
- } | {
394
- readonly _tag: "FileExists";
395
- readonly id: SandboxId;
396
- readonly path: string;
397
- } | {
398
- readonly _tag: "FileList";
399
- readonly id: SandboxId;
400
- readonly path: string;
401
- } | {
402
- readonly _tag: "FileMkdir";
403
- readonly id: SandboxId;
404
- readonly path: string;
405
- } | {
406
- readonly _tag: "FileRead";
407
- readonly id: SandboxId;
408
- readonly path: string;
409
- } | {
410
- readonly _tag: "FileRemove";
411
- readonly id: SandboxId;
412
- readonly path: string;
413
- } | {
414
- readonly _tag: "FileWrite";
415
- readonly id: SandboxId;
416
- readonly path: string;
417
- readonly contents: Uint8Array | string;
418
- } | {
419
- readonly _tag: "SnapshotCreate";
420
- readonly id: SandboxId;
421
- readonly name?: string;
422
- } | {
423
- readonly _tag: "SnapshotDestroy";
424
- readonly id: SnapshotId;
425
- } | {
426
- readonly _tag: "Spawn";
427
- readonly id: SandboxId;
428
- readonly request: CommonSpawnRequest;
429
- } | {
430
- readonly _tag: "VolumeCreate";
431
- readonly name: string;
432
- readonly quotaBytes?: number;
433
- } | {
434
- readonly _tag: "VolumeDestroy";
435
- readonly id: VolumeId;
436
- }, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["Attach" | "Create" | "Destroy" | "Exec" | "ExecStream" | "ExposePort" | "FileExists" | "FileList" | "FileMkdir" | "FileRead" | "FileRemove" | "FileWrite" | "SnapshotCreate" | "SnapshotDestroy" | "Spawn" | "VolumeCreate" | "VolumeDestroy"]>>;
437
- };
438
- readonly Attach: Data.TaggedEnum.ConstructorFrom<{
439
- readonly _tag: "Attach";
440
- readonly id: SandboxId;
441
- }, "_tag">;
442
- readonly Create: Data.TaggedEnum.ConstructorFrom<{
443
- readonly _tag: "Create";
444
- readonly request: CommonCreateRequest;
445
- }, "_tag">;
446
- readonly Destroy: Data.TaggedEnum.ConstructorFrom<{
447
- readonly _tag: "Destroy";
448
- readonly id: SandboxId;
449
- }, "_tag">;
450
- readonly Exec: Data.TaggedEnum.ConstructorFrom<{
451
- readonly _tag: "Exec";
452
- readonly id: SandboxId;
453
- readonly request: CommonExecRequest;
454
- }, "_tag">;
455
- readonly ExecStream: Data.TaggedEnum.ConstructorFrom<{
456
- readonly _tag: "ExecStream";
457
- readonly id: SandboxId;
458
- readonly request: CommonExecRequest;
459
- }, "_tag">;
460
- readonly ExposePort: Data.TaggedEnum.ConstructorFrom<{
461
- readonly _tag: "ExposePort";
462
- readonly id: SandboxId;
463
- readonly port: number;
464
- }, "_tag">;
465
- readonly FileExists: Data.TaggedEnum.ConstructorFrom<{
466
- readonly _tag: "FileExists";
467
- readonly id: SandboxId;
468
- readonly path: string;
469
- }, "_tag">;
470
- readonly FileList: Data.TaggedEnum.ConstructorFrom<{
471
- readonly _tag: "FileList";
472
- readonly id: SandboxId;
473
- readonly path: string;
474
- }, "_tag">;
475
- readonly FileMkdir: Data.TaggedEnum.ConstructorFrom<{
476
- readonly _tag: "FileMkdir";
477
- readonly id: SandboxId;
478
- readonly path: string;
479
- }, "_tag">;
480
- readonly FileRead: Data.TaggedEnum.ConstructorFrom<{
481
- readonly _tag: "FileRead";
482
- readonly id: SandboxId;
483
- readonly path: string;
484
- }, "_tag">;
485
- readonly FileRemove: Data.TaggedEnum.ConstructorFrom<{
486
- readonly _tag: "FileRemove";
487
- readonly id: SandboxId;
488
- readonly path: string;
489
- }, "_tag">;
490
- readonly FileWrite: Data.TaggedEnum.ConstructorFrom<{
491
- readonly _tag: "FileWrite";
492
- readonly id: SandboxId;
493
- readonly path: string;
494
- readonly contents: Uint8Array | string;
495
- }, "_tag">;
496
- readonly SnapshotCreate: Data.TaggedEnum.ConstructorFrom<{
497
- readonly _tag: "SnapshotCreate";
498
- readonly id: SandboxId;
499
- readonly name?: string;
500
- }, "_tag">;
501
- readonly SnapshotDestroy: Data.TaggedEnum.ConstructorFrom<{
502
- readonly _tag: "SnapshotDestroy";
503
- readonly id: SnapshotId;
504
- }, "_tag">;
505
- readonly Spawn: Data.TaggedEnum.ConstructorFrom<{
506
- readonly _tag: "Spawn";
507
- readonly id: SandboxId;
508
- readonly request: CommonSpawnRequest;
509
- }, "_tag">;
510
- readonly VolumeCreate: Data.TaggedEnum.ConstructorFrom<{
511
- readonly _tag: "VolumeCreate";
512
- readonly name: string;
513
- readonly quotaBytes?: number;
514
- }, "_tag">;
515
- readonly VolumeDestroy: Data.TaggedEnum.ConstructorFrom<{
516
- readonly _tag: "VolumeDestroy";
517
- readonly id: VolumeId;
518
- }, "_tag">;
519
- };
74
+ declare const Call: Data.TaggedEnum.Constructor<{
75
+ readonly _tag: "Attach";
76
+ readonly id: SandboxId;
77
+ } | {
78
+ readonly _tag: "Create";
79
+ readonly request: CommonCreateRequest;
80
+ } | {
81
+ readonly _tag: "Destroy";
82
+ readonly id: SandboxId;
83
+ } | {
84
+ readonly _tag: "Exec";
85
+ readonly id: SandboxId;
86
+ readonly request: CommonExecRequest;
87
+ } | {
88
+ readonly _tag: "ExecStream";
89
+ readonly id: SandboxId;
90
+ readonly request: CommonExecRequest;
91
+ } | {
92
+ readonly _tag: "ExposePort";
93
+ readonly id: SandboxId;
94
+ readonly port: number;
95
+ } | {
96
+ readonly _tag: "FileExists";
97
+ readonly id: SandboxId;
98
+ readonly path: string;
99
+ } | {
100
+ readonly _tag: "FileList";
101
+ readonly id: SandboxId;
102
+ readonly path: string;
103
+ } | {
104
+ readonly _tag: "FileMkdir";
105
+ readonly id: SandboxId;
106
+ readonly path: string;
107
+ } | {
108
+ readonly _tag: "FileRead";
109
+ readonly id: SandboxId;
110
+ readonly path: string;
111
+ } | {
112
+ readonly _tag: "FileRemove";
113
+ readonly id: SandboxId;
114
+ readonly path: string;
115
+ } | {
116
+ readonly _tag: "FileWrite";
117
+ readonly id: SandboxId;
118
+ readonly path: string;
119
+ readonly contents: Uint8Array | string;
120
+ } | {
121
+ readonly _tag: "SnapshotCreate";
122
+ readonly id: SandboxId;
123
+ readonly name?: string;
124
+ } | {
125
+ readonly _tag: "SnapshotDestroy";
126
+ readonly id: SnapshotId;
127
+ } | {
128
+ readonly _tag: "Spawn";
129
+ readonly id: SandboxId;
130
+ readonly request: CommonSpawnRequest;
131
+ } | {
132
+ readonly _tag: "VolumeCreate";
133
+ readonly name: string;
134
+ readonly quotaBytes?: number;
135
+ } | {
136
+ readonly _tag: "VolumeDestroy";
137
+ readonly id: VolumeId;
138
+ }>;
520
139
  type MockSandboxRecorder = {
521
140
  readonly calls: ReadonlyArray<Call>;
522
141
  };
@@ -1 +1 @@
1
- {"version":3,"file":"MockSandbox.d.mts","names":[],"sources":["../../src/testing/MockSandbox.ts"],"mappings":";;;;;;;KAoCY,OAAO,KAAK;EACtB;aAAmB,SAAS;;EAC5B;aAAmB,IAAI;;EACvB;aAAoB,IAAI;;EACxB;aAAiB,IAAI;aAAoB,SAAS;;EAClD;aAAuB,IAAI;aAAoB,SAAS;;EACxD;aAAkB,IAAI;aAAoB,SAAS;;EACnD;aAAqB,IAAI;aAAoB;;EAC7C;aACW,IAAI;aACJ;aACA,UAAU;;EAErB;aAAuB,IAAI;aAAoB;;EAC/C;aAAsB,IAAI;aAAoB;;EAC9C;aAAqB,IAAI;aAAoB;;EAC7C;aAAuB,IAAI;aAAoB;;EAC/C;aAAuB,IAAI;aAAoB;;EAC/C;aAA2B,IAAI;aAAoB;;EACnD;aAA4B,IAAI;;EAChC;aAAyB;aAAuB;;EAChD;aAA0B,IAAI;;;cAGnB;;;aAtBY,IAAA;;;;;aADK,SAAA;;;;;aAEJ,IAAA;;;;;aACH,IAAA;aAA6B,SAAA;;;;;aACvB,IAAA;aAA6B,SAAA;;;;;aAY7B,IAAA;aAA0B;;;;;aAD1B,IAAA;aAA0B;;;;;aAD5B,IAAA;aAA0B;;;;;aADzB,IAAA;aAA0B;;;;;aAP3B,IAAA;aAA0B;;;;;aAMxB,IAAA;aAA0B;;;;;aAJtC,IAAA;aACE;aACI,UAAA;;;;;aAOU,IAAA;aAA2B;;;;;aAC1B,IAAA;;;;;aAbV,IAAA;aAA6B,SAAA;;;;;aAcpB;aAA8B;;;;;aAC/B,IAAA;;;;;;;eAnBP,IAAA;;;eADK,SAAA;;;eAEJ,IAAA;;;eACH,IAAA;eAA6B,SAAA;;;eACvB,IAAA;eAA6B,SAAA;;;eAY7B,IAAA;eAA0B;;;eAD1B,IAAA;eAA0B;;;eAD5B,IAAA;eAA0B;;;eADzB,IAAA;eAA0B;;;eAP3B,IAAA;eAA0B;;;eAMxB,IAAA;eAA0B;;;eAJtC,IAAA;eACE;eACI,UAAA;;;eAOU,IAAA;eAA2B;;;eAC1B,IAAA;;;eAbV,IAAA;eAA6B,SAAA;;;eAcpB;eAA8B;;;eAC/B,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAnBP,IAAA;;;eADK,SAAA;;;eAEJ,IAAA;;;eACH,IAAA;eAA6B,SAAA;;;eACvB,IAAA;eAA6B,SAAA;;;eAY7B,IAAA;eAA0B;;;eAD1B,IAAA;eAA0B;;;eAD5B,IAAA;eAA0B;;;eADzB,IAAA;eAA0B;;;eAP3B,IAAA;eAA0B;;;eAMxB,IAAA;eAA0B;;;eAJtC,IAAA;eACE;eACI,UAAA;;;eAOU,IAAA;eAA2B;;;eAC1B,IAAA;;;eAbV,IAAA;eAA6B,SAAA;;;eAcpB;eAA8B;;;eAC/B,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAnBP,IAAA;;;;aADK,SAAA;;;;aAEJ,IAAA;;;;aACH,IAAA;aAA6B,SAAA;;;;aACvB,IAAA;aAA6B,SAAA;;;;aAY7B,IAAA;aAA0B;;;;aAD1B,IAAA;aAA0B;;;;aAD5B,IAAA;aAA0B;;;;aADzB,IAAA;aAA0B;;;;aAP3B,IAAA;aAA0B;;;;aAMxB,IAAA;aAA0B;;;;aAJtC,IAAA;aACE;aACI,UAAA;;;;aAOU,IAAA;aAA2B;;;;aAC1B,IAAA;;;;aAbV,IAAA;aAA6B,SAAA;;;;aAcpB;aAA8B;;;;aAC/B,IAAA;;;KAKpB;WACD,OAAO,cAAc;;;;;;;KAYpB;WACD;WACA,QAAQ,cAAc;WACtB,UAAU,cAAc,cAAc;WACtC,SAAS,cAAc;WACvB,QAAQ,SAAS,eAAe;WAChC,YAAY,cAAc;WAC1B,YAAY;aAAyB,IAAI;aAAqB;;WAC9D,UAAU;aAAyB,IAAI;aAAmB;;WAC1D,WAAW;;;;;;;cAqOT,QAAK,SAAY;;;;;;;;;cAajB,2BAAwB,SAAY;;;;;cASpC,OAAI,SAAY"}
1
+ {"version":3,"file":"MockSandbox.d.mts","names":[],"sources":["../../src/testing/MockSandbox.ts"],"mappings":";;;;;;;KAoCY,OAAO,KAAK;EACtB;aAAmB,SAAS;;EAC5B;aAAmB,IAAI;;EACvB;aAAoB,IAAI;;EACxB;aAAiB,IAAI;aAAoB,SAAS;;EAClD;aAAuB,IAAI;aAAoB,SAAS;;EACxD;aAAkB,IAAI;aAAoB,SAAS;;EACnD;aAAqB,IAAI;aAAoB;;EAC7C;aACW,IAAI;aACJ;aACA,UAAU;;EAErB;aAAuB,IAAI;aAAoB;;EAC/C;aAAsB,IAAI;aAAoB;;EAC9C;aAAqB,IAAI;aAAoB;;EAC7C;aAAuB,IAAI;aAAoB;;EAC/C;aAAuB,IAAI;aAAoB;;EAC/C;aAA2B,IAAI;aAAoB;;EACnD;aAA4B,IAAI;;EAChC;aAAyB;aAAuB;;EAChD;aAA0B,IAAI;;;cAGnB,MAAI,KAAA,WAAA;;WAtBQ,IAAA;;;WADK,SAAA;;;WAEJ,IAAA;;;WACH,IAAA;WAA6B,SAAA;;;WACvB,IAAA;WAA6B,SAAA;;;WAY7B,IAAA;WAA0B;;;WAD1B,IAAA;WAA0B;;;WAD5B,IAAA;WAA0B;;;WADzB,IAAA;WAA0B;;;WAP3B,IAAA;WAA0B;;;WAMxB,IAAA;WAA0B;;;WAJtC,IAAA;WACE;WACI,UAAA;;;WAOU,IAAA;WAA2B;;;WAC1B,IAAA;;;WAbV,IAAA;WAA6B,SAAA;;;WAcpB;WAA8B;;;WAC/B,IAAA;;KAKpB;WACD,OAAO,cAAc;;;;;;;KAYpB;WACD;WACA,QAAQ,cAAc;WACtB,UAAU,cAAc,cAAc;WACtC,SAAS,cAAc;WACvB,QAAQ,SAAS,eAAe;WAChC,YAAY,cAAc;WAC1B,YAAY;aAAyB,IAAI;aAAqB;;WAC9D,UAAU;aAAyB,IAAI;aAAmB;;WAC1D,WAAW;;;;;;;cAqOT,QAAK,SAAY;;;;;;;;;cAajB,2BAAwB,SAAY;;;;;cASpC,OAAI,SAAY"}
@@ -0,0 +1,2 @@
1
+ import { a as Value, c as isMedia, i as Media, n as File, o as file, r as Image, s as image } from "../Content-D_Qfn8Ja.mjs";
2
+ export { File, Image, Media, Value, file, image, isMedia };
@@ -0,0 +1,46 @@
1
+ import { n as __exportAll } from "../rolldown-runtime-EAsCxrDo.mjs";
2
+ import { FileSourceJson } from "../domain/File.mjs";
3
+ import { ImageSourceJson } from "../domain/Image.mjs";
4
+ import { Schema } from "effect";
5
+ //#region src/tool/Content.ts
6
+ /**
7
+ * What a tool's `run` may return without an `outputSchema`. Plain values stay
8
+ * plain (a string is text, anything else JSON); only media is marked, by class,
9
+ * so it is told apart from JSON by `instanceof`, never by shape.
10
+ */
11
+ var Content_exports = /* @__PURE__ */ __exportAll({
12
+ File: () => File,
13
+ Image: () => Image,
14
+ Media: () => Media,
15
+ Value: () => Value,
16
+ file: () => file,
17
+ image: () => image,
18
+ isMedia: () => isMedia
19
+ });
20
+ var Image = class extends Schema.TaggedClass()("Image", { source: ImageSourceJson }) {};
21
+ var File = class extends Schema.TaggedClass()("File", {
22
+ source: FileSourceJson,
23
+ filename: Schema.optionalKey(Schema.String)
24
+ }) {};
25
+ const Media = Schema.Union([Image, File]);
26
+ const image = (source) => new Image({ source });
27
+ const file = (source, filename) => new File(filename === void 0 ? { source } : {
28
+ source,
29
+ filename
30
+ });
31
+ const isMedia = (u) => u instanceof Image || u instanceof File;
32
+ /**
33
+ * Text, JSON, one medium, or a top-level array mixing JSON and media. Encodes to
34
+ * JSON (bytes as base64), so it also serves as the UI codec for tools without
35
+ * an `outputSchema`.
36
+ */
37
+ const Value = Schema.Union([
38
+ Schema.String,
39
+ Media,
40
+ Schema.Array(Schema.Union([Media, Schema.Json])),
41
+ Schema.Json
42
+ ]);
43
+ //#endregion
44
+ export { File, Image, Media, Value, file, image, isMedia, Content_exports as t };
45
+
46
+ //# sourceMappingURL=Content.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Content.mjs","names":[],"sources":["../../src/tool/Content.ts"],"sourcesContent":["/**\n * What a tool's `run` may return without an `outputSchema`. Plain values stay\n * plain (a string is text, anything else JSON); only media is marked, by class,\n * so it is told apart from JSON by `instanceof`, never by shape.\n */\nimport { Schema } from \"effect\"\nimport { type FileSource, FileSourceJson } from \"../domain/File.js\"\nimport { type ImageSource, ImageSourceJson } from \"../domain/Image.js\"\n\nexport class Image extends Schema.TaggedClass<Image>()(\"Image\", { source: ImageSourceJson }) {}\n\nexport class File extends Schema.TaggedClass<File>()(\"File\", {\n source: FileSourceJson,\n filename: Schema.optionalKey(Schema.String),\n}) {}\n\nexport const Media = Schema.Union([Image, File])\nexport type Media = typeof Media.Type\n\nexport const image = (source: ImageSource): Image => new Image({ source })\n\nexport const file = (source: FileSource, filename?: string): File =>\n new File(filename === undefined ? { source } : { source, filename })\n\nexport const isMedia = (u: unknown): u is Media => u instanceof Image || u instanceof File\n\n/**\n * Text, JSON, one medium, or a top-level array mixing JSON and media. Encodes to\n * JSON (bytes as base64), so it also serves as the UI codec for tools without\n * an `outputSchema`.\n */\nexport const Value = Schema.Union([\n Schema.String,\n Media,\n Schema.Array(Schema.Union([Media, Schema.Json])),\n Schema.Json,\n])\nexport type Value = typeof Value.Type\n"],"mappings":";;;;;;;;;;;;;;;;;;;AASA,IAAa,QAAb,cAA2B,OAAO,YAAmB,CAAC,CAAC,SAAS,EAAE,QAAQ,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAE9F,IAAa,OAAb,cAA0B,OAAO,YAAkB,CAAC,CAAC,QAAQ;CAC3D,QAAQ;CACR,UAAU,OAAO,YAAY,OAAO,MAAM;AAC5C,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAa,QAAQ,OAAO,MAAM,CAAC,OAAO,IAAI,CAAC;AAG/C,MAAa,SAAS,WAA+B,IAAI,MAAM,EAAE,OAAO,CAAC;AAEzE,MAAa,QAAQ,QAAoB,aACvC,IAAI,KAAK,aAAa,KAAA,IAAY,EAAE,OAAO,IAAI;CAAE;CAAQ;AAAS,CAAC;AAErE,MAAa,WAAW,MAA2B,aAAa,SAAS,aAAa;;;;;;AAOtF,MAAa,QAAQ,OAAO,MAAM;CAChC,OAAO;CACP;CACA,OAAO,MAAM,OAAO,MAAM,CAAC,OAAO,OAAO,IAAI,CAAC,CAAC;CAC/C,OAAO;AACT,CAAC"}
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,48 @@
1
+ import { imageBytes } from "../domain/Image.mjs";
2
+ import { Image, Value, file, image, isMedia } from "./Content.mjs";
3
+ import { m as describe } from "../dist-DzeSyeYF.mjs";
4
+ import { n as globalExpect } from "../index.C4tKZ0yW-LuFnBtmu.mjs";
5
+ import { t as import_dist } from "../dist-DNeuh84d.mjs";
6
+ import { t as it } from "../dist-B5K-y4Be.mjs";
7
+ import { Effect, Schema } from "effect";
8
+ //#region src/tool/Content.test.ts
9
+ const bytes = new Uint8Array([
10
+ 137,
11
+ 80,
12
+ 78,
13
+ 71
14
+ ]);
15
+ const encode = Schema.encodeUnknownEffect(Value);
16
+ const decode = Schema.decodeUnknownEffect(Value);
17
+ describe("Content.Value", () => {
18
+ it("encodes to JSON", () => {
19
+ (0, import_dist.expectTypeOf)().toExtend();
20
+ });
21
+ it.effect("round-trips image bytes through JSON as base64", () => Effect.gen(function* () {
22
+ const encoded = yield* encode(image(imageBytes(bytes, "image/png")));
23
+ globalExpect(encoded).toEqual({
24
+ _tag: "Image",
25
+ source: {
26
+ _tag: "bytes",
27
+ bytes: "iVBORw==",
28
+ mimeType: "image/png"
29
+ }
30
+ });
31
+ const decoded = yield* decode(JSON.parse(JSON.stringify(encoded)));
32
+ globalExpect(decoded).toBeInstanceOf(Image);
33
+ globalExpect(decoded).toEqual(image(imageBytes(bytes, "image/png")));
34
+ }));
35
+ it.effect("keeps plain objects plain and media as classes in a mixed array", () => Effect.gen(function* () {
36
+ const value = [{ title: "Home" }, file({
37
+ _tag: "url",
38
+ url: "https://x/a.pdf"
39
+ }, "a.pdf")];
40
+ const decoded = yield* decode(yield* encode(value));
41
+ globalExpect(decoded).toEqual(value);
42
+ globalExpect(Array.isArray(decoded) && decoded.map(isMedia)).toEqual([false, true]);
43
+ }));
44
+ });
45
+ //#endregion
46
+ export {};
47
+
48
+ //# sourceMappingURL=Content.test.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Content.test.mjs","names":["Content.Value","Content.image","Content.Image","Content.file","Content.isMedia"],"sources":["../../src/tool/Content.test.ts"],"sourcesContent":["import { describe, expect, expectTypeOf, it } from \"@effect/vitest\"\nimport { Effect, Schema } from \"effect\"\nimport { imageBytes } from \"../domain/Image.js\"\nimport * as Content from \"./Content.js\"\n\nconst bytes = new Uint8Array([137, 80, 78, 71])\nconst encode = Schema.encodeUnknownEffect(Content.Value)\nconst decode = Schema.decodeUnknownEffect(Content.Value)\n\ndescribe(\"Content.Value\", () => {\n it(\"encodes to JSON\", () => {\n expectTypeOf<typeof Content.Value.Encoded>().toExtend<Schema.Json>()\n })\n\n it.effect(\"round-trips image bytes through JSON as base64\", () =>\n Effect.gen(function* () {\n const encoded = yield* encode(Content.image(imageBytes(bytes, \"image/png\")))\n expect(encoded).toEqual({\n _tag: \"Image\",\n source: { _tag: \"bytes\", bytes: \"iVBORw==\", mimeType: \"image/png\" },\n })\n\n const decoded = yield* decode(JSON.parse(JSON.stringify(encoded)))\n expect(decoded).toBeInstanceOf(Content.Image)\n expect(decoded).toEqual(Content.image(imageBytes(bytes, \"image/png\")))\n }),\n )\n\n it.effect(\"keeps plain objects plain and media as classes in a mixed array\", () =>\n Effect.gen(function* () {\n const value = [\n { title: \"Home\" },\n Content.file({ _tag: \"url\", url: \"https://x/a.pdf\" }, \"a.pdf\"),\n ]\n const decoded = yield* decode(yield* encode(value))\n expect(decoded).toEqual(value)\n expect(Array.isArray(decoded) && decoded.map(Content.isMedia)).toEqual([false, true])\n }),\n )\n})\n"],"mappings":";;;;;;;;AAKA,MAAM,QAAQ,IAAI,WAAW;CAAC;CAAK;CAAI;CAAI;AAAE,CAAC;AAC9C,MAAM,SAAS,OAAO,oBAAoBA,KAAa;AACvD,MAAM,SAAS,OAAO,oBAAoBA,KAAa;AAEvD,SAAS,uBAAuB;CAC9B,GAAG,yBAAyB;EAC1B,CAAA,GAAA,YAAA,aAAA,CAA2C,CAAC,CAAC,SAAsB;CACrE,CAAC;CAED,GAAG,OAAO,wDACR,OAAO,IAAI,aAAa;EACtB,MAAM,UAAU,OAAO,OAAOC,MAAc,WAAW,OAAO,WAAW,CAAC,CAAC;EAC3E,aAAO,OAAO,CAAC,CAAC,QAAQ;GACtB,MAAM;GACN,QAAQ;IAAE,MAAM;IAAS,OAAO;IAAY,UAAU;GAAY;EACpE,CAAC;EAED,MAAM,UAAU,OAAO,OAAO,KAAK,MAAM,KAAK,UAAU,OAAO,CAAC,CAAC;EACjE,aAAO,OAAO,CAAC,CAAC,eAAeC,KAAa;EAC5C,aAAO,OAAO,CAAC,CAAC,QAAQD,MAAc,WAAW,OAAO,WAAW,CAAC,CAAC;CACvE,CAAC,CACH;CAEA,GAAG,OAAO,yEACR,OAAO,IAAI,aAAa;EACtB,MAAM,QAAQ,CACZ,EAAE,OAAO,OAAO,GAChBE,KAAa;GAAE,MAAM;GAAO,KAAK;EAAkB,GAAG,OAAO,CAC/D;EACA,MAAM,UAAU,OAAO,OAAO,OAAO,OAAO,KAAK,CAAC;EAClD,aAAO,OAAO,CAAC,CAAC,QAAQ,KAAK;EAC7B,aAAO,MAAM,QAAQ,OAAO,KAAK,QAAQ,IAAIC,OAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,IAAI,CAAC;CACtF,CAAC,CACH;AACF,CAAC"}