@effect-uai/core 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/dist/{AiError-CBuPHVKA.d.mts → AiError-CAX_48RU.d.mts} +27 -5
  2. package/dist/{AiError-CBuPHVKA.d.mts.map → AiError-CAX_48RU.d.mts.map} +1 -1
  3. package/dist/Audio-BfCTGnH3.d.mts +61 -0
  4. package/dist/Audio-BfCTGnH3.d.mts.map +1 -0
  5. package/dist/{Image-BZmKfIdq.d.mts → Image-HNmMpMTh.d.mts} +1 -1
  6. package/dist/{Image-BZmKfIdq.d.mts.map → Image-HNmMpMTh.d.mts.map} +1 -1
  7. package/dist/{Items-CB8Bo3FI.d.mts → Items-DqbaJoz7.d.mts} +5 -5
  8. package/dist/{Items-CB8Bo3FI.d.mts.map → Items-DqbaJoz7.d.mts.map} +1 -1
  9. package/dist/{StructuredFormat-BWq5Hd1O.d.mts → StructuredFormat-BbN4dosH.d.mts} +11 -4
  10. package/dist/StructuredFormat-BbN4dosH.d.mts.map +1 -0
  11. package/dist/{Tool-DjVufH7i.d.mts → Tool-Y0__Py1H.d.mts} +20 -4
  12. package/dist/Tool-Y0__Py1H.d.mts.map +1 -0
  13. package/dist/Turn-ChbL2foc.d.mts +388 -0
  14. package/dist/Turn-ChbL2foc.d.mts.map +1 -0
  15. package/dist/domain/AiError.d.mts +2 -2
  16. package/dist/domain/AiError.mjs +19 -3
  17. package/dist/domain/AiError.mjs.map +1 -1
  18. package/dist/domain/Audio.d.mts +2 -0
  19. package/dist/domain/Audio.mjs +14 -0
  20. package/dist/domain/Audio.mjs.map +1 -0
  21. package/dist/domain/Image.d.mts +1 -1
  22. package/dist/domain/Items.d.mts +1 -1
  23. package/dist/domain/Items.mjs +1 -1
  24. package/dist/domain/Items.mjs.map +1 -1
  25. package/dist/domain/Music.d.mts +116 -0
  26. package/dist/domain/Music.d.mts.map +1 -0
  27. package/dist/domain/Music.mjs +29 -0
  28. package/dist/domain/Music.mjs.map +1 -0
  29. package/dist/domain/Transcript.d.mts +95 -0
  30. package/dist/domain/Transcript.d.mts.map +1 -0
  31. package/dist/domain/Transcript.mjs +22 -0
  32. package/dist/domain/Transcript.mjs.map +1 -0
  33. package/dist/domain/Turn.d.mts +2 -2
  34. package/dist/domain/Turn.mjs +22 -4
  35. package/dist/domain/Turn.mjs.map +1 -1
  36. package/dist/domain/Turn.test.d.mts +1 -0
  37. package/dist/domain/Turn.test.mjs +136 -0
  38. package/dist/domain/Turn.test.mjs.map +1 -0
  39. package/dist/embedding-model/Embedding.d.mts +15 -3
  40. package/dist/embedding-model/Embedding.d.mts.map +1 -1
  41. package/dist/embedding-model/Embedding.mjs.map +1 -1
  42. package/dist/embedding-model/EmbeddingModel.d.mts +33 -17
  43. package/dist/embedding-model/EmbeddingModel.d.mts.map +1 -1
  44. package/dist/embedding-model/EmbeddingModel.mjs.map +1 -1
  45. package/dist/embedding-model/EmbeddingModel.test.d.mts +1 -0
  46. package/dist/embedding-model/EmbeddingModel.test.mjs +59 -0
  47. package/dist/embedding-model/EmbeddingModel.test.mjs.map +1 -0
  48. package/dist/index.d.mts +13 -7
  49. package/dist/index.mjs +7 -1
  50. package/dist/language-model/LanguageModel.d.mts +30 -8
  51. package/dist/language-model/LanguageModel.d.mts.map +1 -1
  52. package/dist/language-model/LanguageModel.mjs +33 -3
  53. package/dist/language-model/LanguageModel.mjs.map +1 -1
  54. package/dist/language-model/LanguageModel.test.d.mts +1 -0
  55. package/dist/language-model/LanguageModel.test.mjs +143 -0
  56. package/dist/language-model/LanguageModel.test.mjs.map +1 -0
  57. package/dist/loop/Loop.d.mts +94 -11
  58. package/dist/loop/Loop.d.mts.map +1 -1
  59. package/dist/loop/Loop.mjs +92 -26
  60. package/dist/loop/Loop.mjs.map +1 -1
  61. package/dist/loop/Loop.test.mjs +171 -3
  62. package/dist/loop/Loop.test.mjs.map +1 -1
  63. package/dist/music-generator/MusicGenerator.d.mts +77 -0
  64. package/dist/music-generator/MusicGenerator.d.mts.map +1 -0
  65. package/dist/music-generator/MusicGenerator.mjs +51 -0
  66. package/dist/music-generator/MusicGenerator.mjs.map +1 -0
  67. package/dist/music-generator/MusicGenerator.test.d.mts +1 -0
  68. package/dist/music-generator/MusicGenerator.test.mjs +154 -0
  69. package/dist/music-generator/MusicGenerator.test.mjs.map +1 -0
  70. package/dist/observability/Metrics.d.mts +1 -1
  71. package/dist/observability/Metrics.mjs +1 -1
  72. package/dist/observability/Metrics.mjs.map +1 -1
  73. package/dist/speech-synthesizer/SpeechSynthesizer.d.mts +96 -0
  74. package/dist/speech-synthesizer/SpeechSynthesizer.d.mts.map +1 -0
  75. package/dist/speech-synthesizer/SpeechSynthesizer.mjs +48 -0
  76. package/dist/speech-synthesizer/SpeechSynthesizer.mjs.map +1 -0
  77. package/dist/speech-synthesizer/SpeechSynthesizer.test.d.mts +1 -0
  78. package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs +112 -0
  79. package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs.map +1 -0
  80. package/dist/streaming/JSONL.d.mts +10 -3
  81. package/dist/streaming/JSONL.d.mts.map +1 -1
  82. package/dist/streaming/JSONL.mjs +15 -9
  83. package/dist/streaming/JSONL.mjs.map +1 -1
  84. package/dist/structured-format/StructuredFormat.d.mts +2 -2
  85. package/dist/structured-format/StructuredFormat.mjs +9 -1
  86. package/dist/structured-format/StructuredFormat.mjs.map +1 -1
  87. package/dist/structured-format/StructuredFormat.test.d.mts +1 -0
  88. package/dist/structured-format/StructuredFormat.test.mjs +70 -0
  89. package/dist/structured-format/StructuredFormat.test.mjs.map +1 -0
  90. package/dist/testing/MockMusicGenerator.d.mts +39 -0
  91. package/dist/testing/MockMusicGenerator.d.mts.map +1 -0
  92. package/dist/testing/MockMusicGenerator.mjs +96 -0
  93. package/dist/testing/MockMusicGenerator.mjs.map +1 -0
  94. package/dist/testing/MockProvider.d.mts +23 -18
  95. package/dist/testing/MockProvider.d.mts.map +1 -1
  96. package/dist/testing/MockProvider.mjs +56 -72
  97. package/dist/testing/MockProvider.mjs.map +1 -1
  98. package/dist/testing/MockSpeechSynthesizer.d.mts +37 -0
  99. package/dist/testing/MockSpeechSynthesizer.d.mts.map +1 -0
  100. package/dist/testing/MockSpeechSynthesizer.mjs +95 -0
  101. package/dist/testing/MockSpeechSynthesizer.mjs.map +1 -0
  102. package/dist/testing/MockTranscriber.d.mts +37 -0
  103. package/dist/testing/MockTranscriber.d.mts.map +1 -0
  104. package/dist/testing/MockTranscriber.mjs +77 -0
  105. package/dist/testing/MockTranscriber.mjs.map +1 -0
  106. package/dist/tool/HistoryCheck.d.mts +1 -1
  107. package/dist/tool/Outcome.d.mts +1 -1
  108. package/dist/tool/Resolvers.d.mts +65 -8
  109. package/dist/tool/Resolvers.d.mts.map +1 -1
  110. package/dist/tool/Resolvers.mjs +8 -12
  111. package/dist/tool/Resolvers.mjs.map +1 -1
  112. package/dist/tool/Resolvers.test.mjs +6 -5
  113. package/dist/tool/Resolvers.test.mjs.map +1 -1
  114. package/dist/tool/Tool.d.mts +2 -2
  115. package/dist/tool/Tool.mjs +18 -1
  116. package/dist/tool/Tool.mjs.map +1 -1
  117. package/dist/tool/Tool.test.d.mts +1 -0
  118. package/dist/tool/Tool.test.mjs +66 -0
  119. package/dist/tool/Tool.test.mjs.map +1 -0
  120. package/dist/tool/Toolkit.d.mts +4 -6
  121. package/dist/tool/Toolkit.d.mts.map +1 -1
  122. package/dist/tool/Toolkit.mjs +14 -43
  123. package/dist/tool/Toolkit.mjs.map +1 -1
  124. package/dist/transcriber/Transcriber.d.mts +101 -0
  125. package/dist/transcriber/Transcriber.d.mts.map +1 -0
  126. package/dist/transcriber/Transcriber.mjs +49 -0
  127. package/dist/transcriber/Transcriber.mjs.map +1 -0
  128. package/dist/transcriber/Transcriber.test.d.mts +1 -0
  129. package/dist/transcriber/Transcriber.test.mjs +130 -0
  130. package/dist/transcriber/Transcriber.test.mjs.map +1 -0
  131. package/package.json +37 -1
  132. package/src/domain/AiError.ts +22 -1
  133. package/src/domain/Audio.ts +88 -0
  134. package/src/domain/Items.ts +1 -1
  135. package/src/domain/Music.ts +121 -0
  136. package/src/domain/Transcript.ts +83 -0
  137. package/src/domain/Turn.test.ts +141 -0
  138. package/src/domain/Turn.ts +50 -43
  139. package/src/embedding-model/Embedding.ts +23 -0
  140. package/src/embedding-model/EmbeddingModel.test.ts +92 -0
  141. package/src/embedding-model/EmbeddingModel.ts +30 -20
  142. package/src/index.ts +6 -0
  143. package/src/language-model/LanguageModel.test.ts +170 -0
  144. package/src/language-model/LanguageModel.ts +64 -1
  145. package/src/loop/Loop.test.ts +256 -3
  146. package/src/loop/Loop.ts +225 -49
  147. package/src/music-generator/MusicGenerator.test.ts +170 -0
  148. package/src/music-generator/MusicGenerator.ts +123 -0
  149. package/src/observability/Metrics.ts +1 -1
  150. package/src/speech-synthesizer/SpeechSynthesizer.test.ts +141 -0
  151. package/src/speech-synthesizer/SpeechSynthesizer.ts +131 -0
  152. package/src/streaming/JSONL.ts +16 -13
  153. package/src/structured-format/StructuredFormat.test.ts +105 -0
  154. package/src/structured-format/StructuredFormat.ts +14 -1
  155. package/src/testing/MockMusicGenerator.ts +168 -0
  156. package/src/testing/MockProvider.ts +126 -105
  157. package/src/testing/MockSpeechSynthesizer.ts +163 -0
  158. package/src/testing/MockTranscriber.ts +137 -0
  159. package/src/tool/Resolvers.test.ts +8 -5
  160. package/src/tool/Resolvers.ts +17 -19
  161. package/src/tool/Tool.test.ts +105 -0
  162. package/src/tool/Tool.ts +20 -0
  163. package/src/tool/Toolkit.ts +49 -50
  164. package/src/transcriber/Transcriber.test.ts +125 -0
  165. package/src/transcriber/Transcriber.ts +127 -0
  166. package/dist/StructuredFormat-BWq5Hd1O.d.mts.map +0 -1
  167. package/dist/Tool-DjVufH7i.d.mts.map +0 -1
  168. package/dist/Turn-OPaILVIB.d.mts +0 -194
  169. package/dist/Turn-OPaILVIB.d.mts.map +0 -1
@@ -0,0 +1,388 @@
1
+ import { i as ImageSource } from "./Image-HNmMpMTh.mjs";
2
+ import { d as Item, g as Reasoning, o as FunctionCall, p as Message, s as FunctionCallOutput, x as Usage } from "./Items-DqbaJoz7.mjs";
3
+ import { i as StructuredFormat, n as JsonParseError, r as StructuredDecodeError } from "./StructuredFormat-BbN4dosH.mjs";
4
+ import { Data, Effect, Schema, Stream } from "effect";
5
+ import * as _$effect_Types0 from "effect/Types";
6
+ import * as _$effect_Cause0 from "effect/Cause";
7
+ import * as _$effect_Unify0 from "effect/Unify";
8
+
9
+ //#region src/domain/Turn.d.ts
10
+ declare namespace Turn_d_exports {
11
+ export { InteractionEvent, RefusalRejected, Turn, TurnEvent, appendTurn, assistantMessages, assistantText, assistantTexts, functionCalls, isTurnComplete, reasonings, textDeltas, toStructured };
12
+ }
13
+ /**
14
+ * The result of a single LLM generation. A turn produces zero or more items
15
+ * (typically one assistant message and zero or more function_call items)
16
+ * and reports usage + a stop reason.
17
+ */
18
+ declare const Turn: Schema.Struct<{
19
+ readonly items: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
20
+ readonly type: Schema.Literal<"message">;
21
+ readonly role: Schema.Literals<readonly ["user", "assistant", "system"]>;
22
+ readonly content: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
23
+ readonly type: Schema.Literal<"input_text">;
24
+ readonly text: Schema.String;
25
+ }>, Schema.Struct<{
26
+ readonly type: Schema.Literal<"input_image">;
27
+ readonly source: Schema.Schema<ImageSource>;
28
+ }>, Schema.Struct<{
29
+ readonly type: Schema.Literal<"output_text">;
30
+ readonly text: Schema.String;
31
+ readonly annotations: Schema.optional<Schema.$Array<Schema.Union<readonly [Schema.Struct<{
32
+ readonly type: Schema.Literal<"url_citation">;
33
+ readonly url: Schema.String;
34
+ readonly start_index: Schema.Number;
35
+ readonly end_index: Schema.Number;
36
+ readonly title: Schema.String;
37
+ }>, Schema.Struct<{
38
+ readonly type: Schema.Literal<"file_citation">;
39
+ readonly file_id: Schema.String;
40
+ readonly index: Schema.Number;
41
+ }>, Schema.Struct<{
42
+ readonly type: Schema.Literal<"container_file_citation">;
43
+ readonly container_id: Schema.String;
44
+ readonly file_id: Schema.String;
45
+ readonly start_index: Schema.Number;
46
+ readonly end_index: Schema.Number;
47
+ }>, Schema.Struct<{
48
+ readonly type: Schema.Literal<"file_path">;
49
+ readonly file_id: Schema.String;
50
+ readonly index: Schema.Number;
51
+ }>]>>>;
52
+ }>, Schema.Struct<{
53
+ readonly type: Schema.Literal<"refusal">;
54
+ readonly text: Schema.String;
55
+ }>]>>;
56
+ readonly providerData: Schema.optional<Schema.Unknown>;
57
+ }>, Schema.Struct<{
58
+ readonly type: Schema.Literal<"function_call">;
59
+ readonly call_id: Schema.String;
60
+ readonly name: Schema.String;
61
+ readonly arguments: Schema.String;
62
+ readonly providerData: Schema.optional<Schema.Unknown>;
63
+ }>, Schema.Struct<{
64
+ readonly type: Schema.Literal<"function_call_output">;
65
+ readonly call_id: Schema.String;
66
+ readonly output: Schema.String;
67
+ readonly providerData: Schema.optional<Schema.Unknown>;
68
+ }>, Schema.Struct<{
69
+ readonly type: Schema.Literal<"reasoning">;
70
+ readonly id: Schema.optional<Schema.String>;
71
+ readonly summary: Schema.optional<Schema.String>;
72
+ readonly signature: Schema.optional<Schema.String>;
73
+ readonly providerData: Schema.optional<Schema.Unknown>;
74
+ }>]>>;
75
+ readonly usage: Schema.Struct<{
76
+ readonly input_tokens: Schema.optional<Schema.Number>;
77
+ readonly output_tokens: Schema.optional<Schema.Number>;
78
+ readonly total_tokens: Schema.optional<Schema.Number>;
79
+ readonly input_tokens_details: Schema.optional<Schema.Struct<{
80
+ readonly cached_tokens: Schema.optional<Schema.Number>;
81
+ }>>;
82
+ readonly output_tokens_details: Schema.optional<Schema.Struct<{
83
+ readonly reasoning_tokens: Schema.optional<Schema.Number>;
84
+ }>>;
85
+ }>;
86
+ readonly stop_reason: Schema.Literals<readonly ["stop", "tool_calls", "max_tokens", "refusal", "content_filter", "max_tool_calls"]>;
87
+ }>;
88
+ type Turn = typeof Turn.Type;
89
+ /**
90
+ * Canonical events emitted while a single turn is being generated. Most
91
+ * variants are streaming deltas (text, reasoning, tool-call args); the
92
+ * terminal `TurnComplete` carries the assembled `Turn`. Lifecycle members
93
+ * aren't deltas, hence the union name.
94
+ *
95
+ * `ReasoningDelta.kind`: `trace` is the model's raw chain-of-thought;
96
+ * `summary` is a model-written summary intended for display. OpenAI
97
+ * Responses emits both; Anthropic and Gemini only emit `trace`.
98
+ *
99
+ * `RefusalDelta`: the model declined to answer. OpenAI Responses emits
100
+ * this as its own event; Anthropic surfaces refusals via `stop_reason`
101
+ * and Gemini collapses them into `finishReason: SAFETY` — both go
102
+ * without a `RefusalDelta`.
103
+ *
104
+ * `UsageUpdate`: mid-stream cumulative usage. Anthropic emits this on
105
+ * `message_start` and `message_delta`; other providers may only deliver
106
+ * usage via `TurnComplete.turn.usage`.
107
+ */
108
+ type TurnEvent = Data.TaggedEnum<{
109
+ TextDelta: {
110
+ readonly text: string;
111
+ };
112
+ ReasoningDelta: {
113
+ readonly text: string;
114
+ readonly kind: "trace" | "summary";
115
+ };
116
+ RefusalDelta: {
117
+ readonly text: string;
118
+ };
119
+ ToolCallStart: {
120
+ readonly call_id: string;
121
+ readonly name: string;
122
+ };
123
+ ToolCallArgsDelta: {
124
+ readonly call_id: string;
125
+ readonly delta: string;
126
+ };
127
+ UsageUpdate: {
128
+ readonly usage: Usage;
129
+ };
130
+ TurnComplete: {
131
+ readonly turn: Turn;
132
+ };
133
+ }>;
134
+ declare const TurnEvent: {
135
+ readonly TextDelta: Data.TaggedEnum.ConstructorFrom<{
136
+ readonly _tag: "TextDelta";
137
+ readonly text: string;
138
+ }, "_tag">;
139
+ readonly ReasoningDelta: Data.TaggedEnum.ConstructorFrom<{
140
+ readonly _tag: "ReasoningDelta";
141
+ readonly text: string;
142
+ readonly kind: "trace" | "summary";
143
+ }, "_tag">;
144
+ readonly RefusalDelta: Data.TaggedEnum.ConstructorFrom<{
145
+ readonly _tag: "RefusalDelta";
146
+ readonly text: string;
147
+ }, "_tag">;
148
+ readonly ToolCallStart: Data.TaggedEnum.ConstructorFrom<{
149
+ readonly _tag: "ToolCallStart";
150
+ readonly call_id: string;
151
+ readonly name: string;
152
+ }, "_tag">;
153
+ readonly ToolCallArgsDelta: Data.TaggedEnum.ConstructorFrom<{
154
+ readonly _tag: "ToolCallArgsDelta";
155
+ readonly call_id: string;
156
+ readonly delta: string;
157
+ }, "_tag">;
158
+ readonly UsageUpdate: Data.TaggedEnum.ConstructorFrom<{
159
+ readonly _tag: "UsageUpdate";
160
+ readonly usage: Usage;
161
+ }, "_tag">;
162
+ readonly TurnComplete: Data.TaggedEnum.ConstructorFrom<{
163
+ readonly _tag: "TurnComplete";
164
+ readonly turn: Turn;
165
+ }, "_tag">;
166
+ readonly $is: <Tag extends "TextDelta" | "ReasoningDelta" | "RefusalDelta" | "ToolCallStart" | "ToolCallArgsDelta" | "UsageUpdate" | "TurnComplete">(tag: Tag) => (u: unknown) => u is Extract<{
167
+ readonly _tag: "TextDelta";
168
+ readonly text: string;
169
+ }, {
170
+ readonly _tag: Tag;
171
+ }> | Extract<{
172
+ readonly _tag: "ReasoningDelta";
173
+ readonly text: string;
174
+ readonly kind: "trace" | "summary";
175
+ }, {
176
+ readonly _tag: Tag;
177
+ }> | Extract<{
178
+ readonly _tag: "RefusalDelta";
179
+ readonly text: string;
180
+ }, {
181
+ readonly _tag: Tag;
182
+ }> | Extract<{
183
+ readonly _tag: "ToolCallStart";
184
+ readonly call_id: string;
185
+ readonly name: string;
186
+ }, {
187
+ readonly _tag: Tag;
188
+ }> | Extract<{
189
+ readonly _tag: "ToolCallArgsDelta";
190
+ readonly call_id: string;
191
+ readonly delta: string;
192
+ }, {
193
+ readonly _tag: Tag;
194
+ }> | Extract<{
195
+ readonly _tag: "UsageUpdate";
196
+ readonly usage: Usage;
197
+ }, {
198
+ readonly _tag: Tag;
199
+ }> | Extract<{
200
+ readonly _tag: "TurnComplete";
201
+ readonly turn: Turn;
202
+ }, {
203
+ readonly _tag: Tag;
204
+ }>;
205
+ readonly $match: {
206
+ <Cases extends {
207
+ readonly TextDelta: (args: {
208
+ readonly _tag: "TextDelta";
209
+ readonly text: string;
210
+ }) => any;
211
+ readonly ReasoningDelta: (args: {
212
+ readonly _tag: "ReasoningDelta";
213
+ readonly text: string;
214
+ readonly kind: "trace" | "summary";
215
+ }) => any;
216
+ readonly RefusalDelta: (args: {
217
+ readonly _tag: "RefusalDelta";
218
+ readonly text: string;
219
+ }) => any;
220
+ readonly ToolCallStart: (args: {
221
+ readonly _tag: "ToolCallStart";
222
+ readonly call_id: string;
223
+ readonly name: string;
224
+ }) => any;
225
+ readonly ToolCallArgsDelta: (args: {
226
+ readonly _tag: "ToolCallArgsDelta";
227
+ readonly call_id: string;
228
+ readonly delta: string;
229
+ }) => any;
230
+ readonly UsageUpdate: (args: {
231
+ readonly _tag: "UsageUpdate";
232
+ readonly usage: Usage;
233
+ }) => any;
234
+ readonly TurnComplete: (args: {
235
+ readonly _tag: "TurnComplete";
236
+ readonly turn: Turn;
237
+ }) => any;
238
+ }>(cases: Cases): (value: {
239
+ readonly _tag: "TextDelta";
240
+ readonly text: string;
241
+ } | {
242
+ readonly _tag: "ReasoningDelta";
243
+ readonly text: string;
244
+ readonly kind: "trace" | "summary";
245
+ } | {
246
+ readonly _tag: "RefusalDelta";
247
+ readonly text: string;
248
+ } | {
249
+ readonly _tag: "ToolCallStart";
250
+ readonly call_id: string;
251
+ readonly name: string;
252
+ } | {
253
+ readonly _tag: "ToolCallArgsDelta";
254
+ readonly call_id: string;
255
+ readonly delta: string;
256
+ } | {
257
+ readonly _tag: "UsageUpdate";
258
+ readonly usage: Usage;
259
+ } | {
260
+ readonly _tag: "TurnComplete";
261
+ readonly turn: Turn;
262
+ }) => _$effect_Unify0.Unify<ReturnType<Cases["TextDelta" | "ReasoningDelta" | "RefusalDelta" | "ToolCallStart" | "ToolCallArgsDelta" | "UsageUpdate" | "TurnComplete"]>>;
263
+ <Cases extends {
264
+ readonly TextDelta: (args: {
265
+ readonly _tag: "TextDelta";
266
+ readonly text: string;
267
+ }) => any;
268
+ readonly ReasoningDelta: (args: {
269
+ readonly _tag: "ReasoningDelta";
270
+ readonly text: string;
271
+ readonly kind: "trace" | "summary";
272
+ }) => any;
273
+ readonly RefusalDelta: (args: {
274
+ readonly _tag: "RefusalDelta";
275
+ readonly text: string;
276
+ }) => any;
277
+ readonly ToolCallStart: (args: {
278
+ readonly _tag: "ToolCallStart";
279
+ readonly call_id: string;
280
+ readonly name: string;
281
+ }) => any;
282
+ readonly ToolCallArgsDelta: (args: {
283
+ readonly _tag: "ToolCallArgsDelta";
284
+ readonly call_id: string;
285
+ readonly delta: string;
286
+ }) => any;
287
+ readonly UsageUpdate: (args: {
288
+ readonly _tag: "UsageUpdate";
289
+ readonly usage: Usage;
290
+ }) => any;
291
+ readonly TurnComplete: (args: {
292
+ readonly _tag: "TurnComplete";
293
+ readonly turn: Turn;
294
+ }) => any;
295
+ }>(value: {
296
+ readonly _tag: "TextDelta";
297
+ readonly text: string;
298
+ } | {
299
+ readonly _tag: "ReasoningDelta";
300
+ readonly text: string;
301
+ readonly kind: "trace" | "summary";
302
+ } | {
303
+ readonly _tag: "RefusalDelta";
304
+ readonly text: string;
305
+ } | {
306
+ readonly _tag: "ToolCallStart";
307
+ readonly call_id: string;
308
+ readonly name: string;
309
+ } | {
310
+ readonly _tag: "ToolCallArgsDelta";
311
+ readonly call_id: string;
312
+ readonly delta: string;
313
+ } | {
314
+ readonly _tag: "UsageUpdate";
315
+ readonly usage: Usage;
316
+ } | {
317
+ readonly _tag: "TurnComplete";
318
+ readonly turn: Turn;
319
+ }, cases: Cases): _$effect_Unify0.Unify<ReturnType<Cases["TextDelta" | "ReasoningDelta" | "RefusalDelta" | "ToolCallStart" | "ToolCallArgsDelta" | "UsageUpdate" | "TurnComplete"]>>;
320
+ };
321
+ };
322
+ /**
323
+ * What flows out of an agent loop body to its consumer per turn: every
324
+ * `TurnEvent` the provider emits (including the terminal `TurnComplete`
325
+ * carrying the assembled `Turn`), plus the output of any tool the loop ran.
326
+ * Both variants carry a `_tag` discriminator.
327
+ */
328
+ type InteractionEvent = TurnEvent | FunctionCallOutput;
329
+ declare const isTurnComplete: (u: unknown) => u is {
330
+ readonly _tag: "TurnComplete";
331
+ readonly turn: Turn;
332
+ };
333
+ declare const functionCalls: (turn: Turn) => ReadonlyArray<FunctionCall>;
334
+ declare const reasonings: (turn: Turn) => ReadonlyArray<Reasoning>;
335
+ declare const assistantMessages: (turn: Turn) => ReadonlyArray<Message>;
336
+ /**
337
+ * Every `output_text` payload across every assistant message in the turn,
338
+ * preserving order. Refusals and other content blocks are dropped — use
339
+ * `assistantMessages` if you need to inspect them. The primitive for
340
+ * "give me the assistant's text"; callers decide how to combine
341
+ * (typically `.join("")` for prose or `.join(" ")` for log strings).
342
+ */
343
+ declare const assistantTexts: (turn: Turn) => ReadonlyArray<string>;
344
+ /**
345
+ * Sugar over `assistantTexts(turn).join("")` — the common case for
346
+ * summarizers, classifiers, judge calls, and structured-output backstops
347
+ * that want one concatenated string.
348
+ */
349
+ declare const assistantText: (turn: Turn) => string;
350
+ /**
351
+ * Append a completed turn and optional follow-up items to a state record's
352
+ * history. Recipes use this at the point where structured tool results are
353
+ * converted to model-facing `FunctionCallOutput`s.
354
+ */
355
+ declare const appendTurn: <S extends {
356
+ readonly history: ReadonlyArray<Item>;
357
+ }>(state: S, turn: Turn, items?: ReadonlyArray<Item>) => S;
358
+ /**
359
+ * Project a `TurnEvent` stream onto its `TextDelta` payloads. Other
360
+ * variants are dropped. Composes with `Lines.lines` +
361
+ * `decodeJsonLines` for prompted-JSONL streaming.
362
+ */
363
+ declare const textDeltas: <E, R>(self: Stream.Stream<TurnEvent, E, R>) => Stream.Stream<string, E, R>;
364
+ declare const RefusalRejected_base: new <A extends Record<string, any> = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & {
365
+ readonly _tag: "RefusalRejected";
366
+ } & Readonly<A>;
367
+ /**
368
+ * The assistant message on the just-completed turn was a refusal block,
369
+ * not an `output_text` payload. Returned by `toStructured` to short-circuit
370
+ * decoding before `JSON.parse` / schema validation runs.
371
+ */
372
+ declare class RefusalRejected extends RefusalRejected_base<{
373
+ readonly turn: Turn;
374
+ }> {}
375
+ /**
376
+ * Validate a completed `Turn` against a `StructuredFormat`. Concatenates
377
+ * `output_text` blocks on the last assistant message, then runs
378
+ * `JSON.parse` + the format's schema validation.
379
+ *
380
+ * Three failure modes:
381
+ * - `RefusalRejected` — the assistant emitted a refusal block.
382
+ * - `JsonParseError` — the assembled text wasn't valid JSON.
383
+ * - `StructuredDecodeError` — the JSON didn't match the schema.
384
+ */
385
+ declare const toStructured: <A>(turn: Turn, format: StructuredFormat<A>) => Effect.Effect<A, RefusalRejected | JsonParseError | StructuredDecodeError>;
386
+ //#endregion
387
+ export { Turn_d_exports as a, assistantText as c, isTurnComplete as d, reasonings as f, TurnEvent as i, assistantTexts as l, toStructured as m, RefusalRejected as n, appendTurn as o, textDeltas as p, Turn as r, assistantMessages as s, InteractionEvent as t, functionCalls as u };
388
+ //# sourceMappingURL=Turn-ChbL2foc.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Turn-ChbL2foc.d.mts","names":[],"sources":["../src/domain/Turn.ts"],"mappings":";;;;;;;;;;;;;;;;;cAmBa,IAAA,EAAI,MAAA,CAAA,MAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAKL,IAAA,UAAc,IAAA,CAAK,IAAA;;;;;;;;;;;;;;;;;;;;KAqBnB,SAAA,GAAY,IAAA,CAAK,UAAA;EAC3B,SAAA;IAAA,SAAsB,IAAA;EAAA;EACtB,cAAA;IAAA,SAA2B,IAAA;IAAA,SAAuB,IAAA;EAAA;E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IAAA;AAAA,GACrE,KAAA,EAAO,CAAA,EACP,IAAA,EAAM,IAAA,EACN,KAAA,GAAO,aAAA,CAAc,IAAA,MACpB,CAAA;;;;;;cAcU,UAAA,SACX,IAAA,EAAM,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW,CAAA,EAAG,CAAA,MACjC,MAAA,CAAO,MAAA,SAAe,CAAA,EAAG,CAAA;AAAA,cAGzB,oBAAA;;;;;;;;cAWU,eAAA,SAAwB,oBAAA;EAAA,SAC1B,IAAA,EAAM,IAAA;AAAA;;;;;;;;;;AAjFjB;cA0Ga,YAAA,MACX,IAAA,EAAM,IAAA,EACN,MAAA,EAAQ,gBAAA,CAAkC,CAAA,MACzC,MAAA,CAAO,MAAA,CACR,CAAA,EACA,eAAA,GAAkB,cAAA,GAAkC,qBAAA"}
@@ -1,2 +1,2 @@
1
- import { a as Cancelled, c as GenerationFailed, d as RateLimited, f as Scope, i as AuthSubtype, l as IncompleteTurn, m as Unavailable, o as ContentFiltered, p as Timeout, r as AuthFailed, s as ContextLengthExceeded, t as AiError, u as InvalidRequest } from "../AiError-CBuPHVKA.mjs";
2
- export { AiError, AuthFailed, AuthSubtype, Cancelled, ContentFiltered, ContextLengthExceeded, GenerationFailed, IncompleteTurn, InvalidRequest, RateLimited, Scope, Timeout, Unavailable };
1
+ import { a as Cancelled, c as GenerationFailed, d as RateLimited, f as Scope, h as Unsupported, i as AuthSubtype, l as IncompleteTurn, m as Unavailable, o as ContentFiltered, p as Timeout, r as AuthFailed, s as ContextLengthExceeded, t as AiError, u as InvalidRequest } from "../AiError-CAX_48RU.mjs";
2
+ export { AiError, AuthFailed, AuthSubtype, Cancelled, ContentFiltered, ContextLengthExceeded, GenerationFailed, IncompleteTurn, InvalidRequest, RateLimited, Scope, Timeout, Unavailable, Unsupported };
@@ -11,7 +11,8 @@ var AiError_exports = /* @__PURE__ */ __exportAll({
11
11
  InvalidRequest: () => InvalidRequest,
12
12
  RateLimited: () => RateLimited,
13
13
  Timeout: () => Timeout,
14
- Unavailable: () => Unavailable
14
+ Unavailable: () => Unavailable,
15
+ Unsupported: () => Unsupported
15
16
  });
16
17
  var RateLimited = class extends Data.TaggedError("RateLimited") {};
17
18
  var Unavailable = class extends Data.TaggedError("Unavailable") {};
@@ -29,12 +30,27 @@ var Cancelled = class extends Data.TaggedError("Cancelled") {};
29
30
  */
30
31
  var GenerationFailed = class extends Data.TaggedError("GenerationFailed") {};
31
32
  /**
32
- * The provider's delta stream ended without a terminal `turn_complete`.
33
+ * The provider's delta stream ended without a terminal `TurnComplete`.
33
34
  * Indicates a misbehaving provider or a connection that dropped mid-flight.
34
35
  * Non-terminal deltas seen so far have already been emitted downstream.
35
36
  */
36
37
  var IncompleteTurn = class extends Data.TaggedError("IncompleteTurn") {};
38
+ /**
39
+ * The provider does not implement the requested capability for this
40
+ * specific request. Distinct from `InvalidRequest` (the request shape is
41
+ * malformed) and `AuthFailed` (the request was rejected).
42
+ *
43
+ * Reserved for request-data-dependent gaps where the provider supports
44
+ * the method in general but not for these inputs — e.g. Google's
45
+ * `streamSynthesisFrom` works only for Chirp 3 HD voices; calling it
46
+ * with a Neural2 voice ID fails `Unsupported`.
47
+ *
48
+ * Blanket provider-level gaps (e.g. OpenAI has no incremental-text-in
49
+ * TTS at all) are gated at compile time via capability marker tags
50
+ * (`TtsIncrementalText`, `SttStreaming`) on the R channel instead.
51
+ */
52
+ var Unsupported = class extends Data.TaggedError("Unsupported") {};
37
53
  //#endregion
38
- export { AuthFailed, Cancelled, ContentFiltered, ContextLengthExceeded, GenerationFailed, IncompleteTurn, InvalidRequest, RateLimited, Timeout, Unavailable, AiError_exports as t };
54
+ export { AuthFailed, Cancelled, ContentFiltered, ContextLengthExceeded, GenerationFailed, IncompleteTurn, InvalidRequest, RateLimited, Timeout, Unavailable, Unsupported, AiError_exports as t };
39
55
 
40
56
  //# sourceMappingURL=AiError.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"AiError.mjs","names":[],"sources":["../../src/domain/AiError.ts"],"sourcesContent":["import { Data, Duration } from \"effect\"\n\nexport type Scope = \"rpm\" | \"tpm\" | \"rpd\" | \"tpd\"\n\nexport class RateLimited extends Data.TaggedError(\"RateLimited\")<{\n provider: string\n retryAfter?: Duration.Duration\n scope?: Scope\n requestId?: string\n raw: unknown\n}> {}\n\nexport class Unavailable extends Data.TaggedError(\"Unavailable\")<{\n provider: string\n retryAfter?: Duration.Duration\n status?: number\n requestId?: string\n raw: unknown\n}> {}\n\nexport class Timeout extends Data.TaggedError(\"Timeout\")<{\n provider: string\n requestId?: string\n raw: unknown\n}> {}\n\nexport class ContentFiltered extends Data.TaggedError(\"ContentFiltered\")<{\n provider: string\n reason?: string\n requestId?: string\n raw: unknown\n}> {}\n\nexport class ContextLengthExceeded extends Data.TaggedError(\"ContextLengthExceeded\")<{\n provider: string\n modelLimit?: number\n requested?: number\n raw: unknown\n}> {}\n\nexport class InvalidRequest extends Data.TaggedError(\"InvalidRequest\")<{\n provider: string\n param?: string\n requestId?: string\n raw: unknown\n}> {}\n\nexport type AuthSubtype = \"auth\" | \"permission\" | \"billing\" | \"quota\"\n\nexport class AuthFailed extends Data.TaggedError(\"AuthFailed\")<{\n provider: string\n subtype: AuthSubtype\n raw: unknown\n}> {}\n\nexport class Cancelled extends Data.TaggedError(\"Cancelled\")<{\n provider: string\n}> {}\n\n/**\n * The model errored mid-generation. Distinct from `Unavailable` (transport\n * problem before generation started) and from `IncompleteTurn` (provider\n * stream ended without a terminal event). The provider's own error message,\n * if any, is on `message`.\n */\nexport class GenerationFailed extends Data.TaggedError(\"GenerationFailed\")<{\n provider: string\n code?: string\n message?: string\n requestId?: string\n raw: unknown\n}> {}\n\n/**\n * The provider's delta stream ended without a terminal `turn_complete`.\n * Indicates a misbehaving provider or a connection that dropped mid-flight.\n * Non-terminal deltas seen so far have already been emitted downstream.\n */\nexport class IncompleteTurn extends Data.TaggedError(\"IncompleteTurn\")<{\n raw?: unknown\n}> {}\n\nexport type AiError =\n | RateLimited\n | Unavailable\n | Timeout\n | ContentFiltered\n | ContextLengthExceeded\n | InvalidRequest\n | AuthFailed\n | Cancelled\n | IncompleteTurn\n | GenerationFailed\n"],"mappings":";;;;;;;;;;;;;;;AAIA,IAAa,cAAb,cAAiC,KAAK,YAAY,cAAc,CAM7D;AAEH,IAAa,cAAb,cAAiC,KAAK,YAAY,cAAc,CAM7D;AAEH,IAAa,UAAb,cAA6B,KAAK,YAAY,UAAU,CAIrD;AAEH,IAAa,kBAAb,cAAqC,KAAK,YAAY,kBAAkB,CAKrE;AAEH,IAAa,wBAAb,cAA2C,KAAK,YAAY,wBAAwB,CAKjF;AAEH,IAAa,iBAAb,cAAoC,KAAK,YAAY,iBAAiB,CAKnE;AAIH,IAAa,aAAb,cAAgC,KAAK,YAAY,aAAa,CAI3D;AAEH,IAAa,YAAb,cAA+B,KAAK,YAAY,YAAY,CAEzD;;;;;;;AAQH,IAAa,mBAAb,cAAsC,KAAK,YAAY,mBAAmB,CAMvE;;;;;;AAOH,IAAa,iBAAb,cAAoC,KAAK,YAAY,iBAAiB,CAEnE"}
1
+ {"version":3,"file":"AiError.mjs","names":[],"sources":["../../src/domain/AiError.ts"],"sourcesContent":["import { Data, Duration } from \"effect\"\n\nexport type Scope = \"rpm\" | \"tpm\" | \"rpd\" | \"tpd\"\n\nexport class RateLimited extends Data.TaggedError(\"RateLimited\")<{\n provider: string\n retryAfter?: Duration.Duration\n scope?: Scope\n requestId?: string\n raw: unknown\n}> {}\n\nexport class Unavailable extends Data.TaggedError(\"Unavailable\")<{\n provider: string\n retryAfter?: Duration.Duration\n status?: number\n requestId?: string\n raw: unknown\n}> {}\n\nexport class Timeout extends Data.TaggedError(\"Timeout\")<{\n provider: string\n requestId?: string\n raw: unknown\n}> {}\n\nexport class ContentFiltered extends Data.TaggedError(\"ContentFiltered\")<{\n provider: string\n reason?: string\n requestId?: string\n raw: unknown\n}> {}\n\nexport class ContextLengthExceeded extends Data.TaggedError(\"ContextLengthExceeded\")<{\n provider: string\n modelLimit?: number\n requested?: number\n raw: unknown\n}> {}\n\nexport class InvalidRequest extends Data.TaggedError(\"InvalidRequest\")<{\n provider: string\n param?: string\n requestId?: string\n raw: unknown\n}> {}\n\nexport type AuthSubtype = \"auth\" | \"permission\" | \"billing\" | \"quota\"\n\nexport class AuthFailed extends Data.TaggedError(\"AuthFailed\")<{\n provider: string\n subtype: AuthSubtype\n raw: unknown\n}> {}\n\nexport class Cancelled extends Data.TaggedError(\"Cancelled\")<{\n provider: string\n}> {}\n\n/**\n * The model errored mid-generation. Distinct from `Unavailable` (transport\n * problem before generation started) and from `IncompleteTurn` (provider\n * stream ended without a terminal event). The provider's own error message,\n * if any, is on `message`.\n */\nexport class GenerationFailed extends Data.TaggedError(\"GenerationFailed\")<{\n provider: string\n code?: string\n message?: string\n requestId?: string\n raw: unknown\n}> {}\n\n/**\n * The provider's delta stream ended without a terminal `TurnComplete`.\n * Indicates a misbehaving provider or a connection that dropped mid-flight.\n * Non-terminal deltas seen so far have already been emitted downstream.\n */\nexport class IncompleteTurn extends Data.TaggedError(\"IncompleteTurn\")<{\n raw?: unknown\n}> {}\n\n/**\n * The provider does not implement the requested capability for this\n * specific request. Distinct from `InvalidRequest` (the request shape is\n * malformed) and `AuthFailed` (the request was rejected).\n *\n * Reserved for request-data-dependent gaps where the provider supports\n * the method in general but not for these inputs — e.g. Google's\n * `streamSynthesisFrom` works only for Chirp 3 HD voices; calling it\n * with a Neural2 voice ID fails `Unsupported`.\n *\n * Blanket provider-level gaps (e.g. OpenAI has no incremental-text-in\n * TTS at all) are gated at compile time via capability marker tags\n * (`TtsIncrementalText`, `SttStreaming`) on the R channel instead.\n */\nexport class Unsupported extends Data.TaggedError(\"Unsupported\")<{\n provider: string\n capability: string\n reason?: string\n}> {}\n\nexport type AiError =\n | RateLimited\n | Unavailable\n | Timeout\n | ContentFiltered\n | ContextLengthExceeded\n | InvalidRequest\n | AuthFailed\n | Cancelled\n | IncompleteTurn\n | GenerationFailed\n | Unsupported\n"],"mappings":";;;;;;;;;;;;;;;;AAIA,IAAa,cAAb,cAAiC,KAAK,YAAY,cAAc,CAM7D;AAEH,IAAa,cAAb,cAAiC,KAAK,YAAY,cAAc,CAM7D;AAEH,IAAa,UAAb,cAA6B,KAAK,YAAY,UAAU,CAIrD;AAEH,IAAa,kBAAb,cAAqC,KAAK,YAAY,kBAAkB,CAKrE;AAEH,IAAa,wBAAb,cAA2C,KAAK,YAAY,wBAAwB,CAKjF;AAEH,IAAa,iBAAb,cAAoC,KAAK,YAAY,iBAAiB,CAKnE;AAIH,IAAa,aAAb,cAAgC,KAAK,YAAY,aAAa,CAI3D;AAEH,IAAa,YAAb,cAA+B,KAAK,YAAY,YAAY,CAEzD;;;;;;;AAQH,IAAa,mBAAb,cAAsC,KAAK,YAAY,mBAAmB,CAMvE;;;;;;AAOH,IAAa,iBAAb,cAAoC,KAAK,YAAY,iBAAiB,CAEnE;;;;;;;;;;;;;;;AAgBH,IAAa,cAAb,cAAiC,KAAK,YAAY,cAAc,CAI7D"}
@@ -0,0 +1,2 @@
1
+ import { a as AudioSource, c as isAudioBytes, i as AudioMimeType, l as isAudioUrl, n as AudioChunk, r as AudioFormat, s as isAudioBase64, t as AudioBlob } from "../Audio-BfCTGnH3.mjs";
2
+ export { AudioBlob, AudioChunk, AudioFormat, AudioMimeType, AudioSource, isAudioBase64, isAudioBytes, isAudioUrl };
@@ -0,0 +1,14 @@
1
+ import { n as __exportAll } from "../chunk-uyGKjUfl.mjs";
2
+ //#region src/domain/Audio.ts
3
+ var Audio_exports = /* @__PURE__ */ __exportAll({
4
+ isAudioBase64: () => isAudioBase64,
5
+ isAudioBytes: () => isAudioBytes,
6
+ isAudioUrl: () => isAudioUrl
7
+ });
8
+ const isAudioUrl = (s) => s._tag === "url";
9
+ const isAudioBase64 = (s) => s._tag === "base64";
10
+ const isAudioBytes = (s) => s._tag === "bytes";
11
+ //#endregion
12
+ export { isAudioBase64, isAudioBytes, isAudioUrl, Audio_exports as t };
13
+
14
+ //# sourceMappingURL=Audio.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Audio.mjs","names":[],"sources":["../../src/domain/Audio.ts"],"sourcesContent":["import type { MediaBase64, MediaBytes, MediaUrl } from \"./Media.js\"\n\n/**\n * MIME types we care about across STT input and TTS output. Container-\n * level only — sample rate / encoding flavours live on `AudioFormat`.\n *\n * Per-provider request types narrow this further. The `(string & {})`\n * tail keeps autocomplete on the literals while still accepting any\n * string, so unusual formats work without an SDK update.\n */\nexport type AudioMimeType =\n | \"audio/mpeg\"\n | \"audio/wav\"\n | \"audio/x-wav\"\n | \"audio/ogg\"\n | \"audio/opus\"\n | \"audio/flac\"\n | \"audio/aac\"\n | \"audio/mp4\"\n | \"audio/webm\"\n | \"audio/L16\"\n | \"audio/pcm\"\n | \"audio/mulaw\"\n | \"audio/alaw\"\n // eslint-disable-next-line @typescript-eslint/ban-types\n | (string & {})\n\n/**\n * Audio at rest — instantiates `MediaSource` with the audio MIME union.\n * Used for sync STT input.\n *\n * URL variant is best-effort: some providers (OpenAI, Cartesia, Azure\n * short-audio) reject URL ingestion and the adapter must upload via the\n * `bytes` or `base64` variant instead. Adapter layers reject unsupported\n * shapes up front with `AiError.InvalidRequest`.\n */\nexport type AudioSource =\n | MediaUrl<AudioMimeType>\n | MediaBase64<AudioMimeType>\n | MediaBytes<AudioMimeType>\n\nexport const isAudioUrl = (s: AudioSource): s is MediaUrl<AudioMimeType> => s._tag === \"url\"\nexport const isAudioBase64 = (s: AudioSource): s is MediaBase64<AudioMimeType> =>\n s._tag === \"base64\"\nexport const isAudioBytes = (s: AudioSource): s is MediaBytes<AudioMimeType> => s._tag === \"bytes\"\n\n/**\n * Structural audio format. Used both as TTS output spec and as STT\n * streaming-input declaration. Providers that use compound slugs\n * (`mp3_44100_128`, `audio-16khz-128kbitrate-mono-mp3`,\n * `aura-2-thalia-en`) are encoded at the adapter layer.\n */\nexport type AudioFormat = {\n readonly container: \"mp3\" | \"wav\" | \"ogg\" | \"opus\" | \"flac\" | \"aac\" | \"webm\" | \"raw\"\n readonly encoding:\n | \"pcm_s16le\"\n | \"pcm_f32le\"\n | \"pcm_mulaw\"\n | \"pcm_alaw\"\n | \"mp3\"\n | \"opus\"\n | \"vorbis\"\n | \"flac\"\n | \"aac\"\n readonly sampleRate: 8000 | 16000 | 22050 | 24000 | 32000 | 44100 | 48000\n /** mp3 / opus only. */\n readonly bitRate?: number\n readonly channels?: 1 | 2\n}\n\n/**\n * Streamed audio chunk. `bytes` carries the codec-encoded payload as\n * declared on the stream's `AudioFormat`. No per-chunk timestamp here —\n * providers that emit timing do so via `TranscriptEvent.words[]`.\n */\nexport type AudioChunk = {\n readonly bytes: Uint8Array\n}\n\n/**\n * Full audio result for sync TTS. Format mirrors the request; provider\n * layers normalize.\n */\nexport type AudioBlob = {\n readonly format: AudioFormat\n readonly bytes: Uint8Array\n readonly durationSeconds?: number\n}\n"],"mappings":";;;;;;;AAyCA,MAAa,cAAc,MAAiD,EAAE,SAAS;AACvF,MAAa,iBAAiB,MAC5B,EAAE,SAAS;AACb,MAAa,gBAAgB,MAAmD,EAAE,SAAS"}
@@ -1,2 +1,2 @@
1
- import { a as ImageUrlSource, c as imageBytes, d as isImageBytes, f as isImageUrl, i as ImageSource, l as imageUrl, n as ImageBytesSource, r as ImageMimeType, s as imageBase64, t as ImageBase64Source, u as isImageBase64 } from "../Image-BZmKfIdq.mjs";
1
+ import { a as ImageUrlSource, c as imageBytes, d as isImageBytes, f as isImageUrl, i as ImageSource, l as imageUrl, n as ImageBytesSource, r as ImageMimeType, s as imageBase64, t as ImageBase64Source, u as isImageBase64 } from "../Image-HNmMpMTh.mjs";
2
2
  export { ImageBase64Source, ImageBytesSource, ImageMimeType, ImageSource, ImageUrlSource, imageBase64, imageBytes, imageUrl, isImageBase64, isImageBytes, isImageUrl };
@@ -1,2 +1,2 @@
1
- import { A as isInputText, C as functionCallOutput, D as isFunctionCall, E as isFilePath, F as isUrlCitation, I as systemText, L as userText, M as isOutputText, N as isReasoning, O as isFunctionCallOutput, P as isRefusal, S as assistantText, T as isFileCitation, _ as Refusal, a as FilePath, b as UrlCitation, c as InputImage, d as Item, g as Reasoning, h as OutputTokensDetails, i as FileCitation, j as isMessage, k as isInputImage, l as InputText, m as OutputText, n as ContainerFileCitation, o as FunctionCall, p as Message, r as ContentBlock, s as FunctionCallOutput, t as Annotation, u as InputTokensDetails, v as Role, w as isContainerFileCitation, x as Usage, y as StopReason } from "../Items-CB8Bo3FI.mjs";
1
+ import { A as isInputText, C as functionCallOutput, D as isFunctionCall, E as isFilePath, F as isUrlCitation, I as systemText, L as userText, M as isOutputText, N as isReasoning, O as isFunctionCallOutput, P as isRefusal, S as assistantText, T as isFileCitation, _ as Refusal, a as FilePath, b as UrlCitation, c as InputImage, d as Item, g as Reasoning, h as OutputTokensDetails, i as FileCitation, j as isMessage, k as isInputImage, l as InputText, m as OutputText, n as ContainerFileCitation, o as FunctionCall, p as Message, r as ContentBlock, s as FunctionCallOutput, t as Annotation, u as InputTokensDetails, v as Role, w as isContainerFileCitation, x as Usage, y as StopReason } from "../Items-DqbaJoz7.mjs";
2
2
  export { Annotation, ContainerFileCitation, ContentBlock, FileCitation, FilePath, FunctionCall, FunctionCallOutput, InputImage, InputText, InputTokensDetails, Item, Message, OutputText, OutputTokensDetails, Reasoning, Refusal, Role, StopReason, UrlCitation, Usage, assistantText, functionCallOutput, isContainerFileCitation, isFileCitation, isFilePath, isFunctionCall, isFunctionCallOutput, isInputImage, isInputText, isMessage, isOutputText, isReasoning, isRefusal, isUrlCitation, systemText, userText };
@@ -99,7 +99,7 @@ const OutputText = Schema.Struct({
99
99
  * Model-emitted refusal. Distinct from `output_text`: the model declined
100
100
  * to answer rather than producing normal output. Pair with
101
101
  * `stop_reason: "refusal"` on the surrounding `Turn`. Streamed via the
102
- * `refusal_delta` `TurnEvent`.
102
+ * `RefusalDelta` `TurnEvent`.
103
103
  */
104
104
  const Refusal = Schema.Struct({
105
105
  type: Schema.Literal("refusal"),
@@ -1 +1 @@
1
- {"version":3,"file":"Items.mjs","names":[],"sources":["../../src/domain/Items.ts"],"sourcesContent":["import { Schema } from \"effect\"\nimport { ImageSource } from \"./Image.js\"\n\n// ---------------------------------------------------------------------------\n// Content blocks (inside Message.content)\n// ---------------------------------------------------------------------------\n\nexport const InputText = Schema.Struct({\n type: Schema.Literal(\"input_text\"),\n text: Schema.String,\n})\nexport type InputText = typeof InputText.Type\n\n/**\n * User-provided image content block. Pair with `InputText` inside a\n * `Message.content` array to ask \"what's in this image?\" style questions.\n *\n * `source` is the cross-modality `ImageSource` from `domain/Image.ts` -\n * url, base64, or raw bytes. Provider codecs encode bytes to whatever\n * wire format the provider wants.\n */\nexport const InputImage = Schema.Struct({\n type: Schema.Literal(\"input_image\"),\n source: ImageSource,\n})\nexport type InputImage = typeof InputImage.Type\n\n// ---------------------------------------------------------------------------\n// Annotations - source / citation pointers attached to `output_text` blocks.\n// Mirrors OpenAI Responses API; other providers can omit or map onto these\n// shapes.\n// ---------------------------------------------------------------------------\n\nexport const UrlCitation = Schema.Struct({\n type: Schema.Literal(\"url_citation\"),\n url: Schema.String,\n start_index: Schema.Number,\n end_index: Schema.Number,\n title: Schema.String,\n})\nexport type UrlCitation = typeof UrlCitation.Type\n\nexport const FileCitation = Schema.Struct({\n type: Schema.Literal(\"file_citation\"),\n file_id: Schema.String,\n index: Schema.Number,\n})\nexport type FileCitation = typeof FileCitation.Type\n\nexport const ContainerFileCitation = Schema.Struct({\n type: Schema.Literal(\"container_file_citation\"),\n container_id: Schema.String,\n file_id: Schema.String,\n start_index: Schema.Number,\n end_index: Schema.Number,\n})\nexport type ContainerFileCitation = typeof ContainerFileCitation.Type\n\nexport const FilePath = Schema.Struct({\n type: Schema.Literal(\"file_path\"),\n file_id: Schema.String,\n index: Schema.Number,\n})\nexport type FilePath = typeof FilePath.Type\n\nexport const Annotation = Schema.Union([UrlCitation, FileCitation, ContainerFileCitation, FilePath])\nexport type Annotation = typeof Annotation.Type\n\nexport const isUrlCitation = Schema.is(UrlCitation)\nexport const isFileCitation = Schema.is(FileCitation)\nexport const isContainerFileCitation = Schema.is(ContainerFileCitation)\nexport const isFilePath = Schema.is(FilePath)\n\nexport const OutputText = Schema.Struct({\n type: Schema.Literal(\"output_text\"),\n text: Schema.String,\n annotations: Schema.optional(Schema.Array(Annotation)),\n})\nexport type OutputText = typeof OutputText.Type\n\n/**\n * Model-emitted refusal. Distinct from `output_text`: the model declined\n * to answer rather than producing normal output. Pair with\n * `stop_reason: \"refusal\"` on the surrounding `Turn`. Streamed via the\n * `refusal_delta` `TurnEvent`.\n */\nexport const Refusal = Schema.Struct({\n type: Schema.Literal(\"refusal\"),\n text: Schema.String,\n})\nexport type Refusal = typeof Refusal.Type\n\nexport const ContentBlock = Schema.Union([InputText, InputImage, OutputText, Refusal])\nexport type ContentBlock = typeof ContentBlock.Type\n\nexport const Role = Schema.Literals([\"user\", \"assistant\", \"system\"])\nexport type Role = typeof Role.Type\n\n// ---------------------------------------------------------------------------\n// Provider passthrough - every Item type carries this opaque slot.\n// The framework never reads or interprets it; provider modules decode\n// their own data via their own typed readers (see e.g.\n// the `@effect-uai/responses` package).\n// ---------------------------------------------------------------------------\n\nconst ProviderData = Schema.optional(Schema.Unknown)\n\n// ---------------------------------------------------------------------------\n// Items\n// ---------------------------------------------------------------------------\n\nexport const Message = Schema.Struct({\n type: Schema.Literal(\"message\"),\n role: Role,\n content: Schema.Array(ContentBlock),\n providerData: ProviderData,\n})\nexport type Message = typeof Message.Type\n\nexport const FunctionCall = Schema.Struct({\n type: Schema.Literal(\"function_call\"),\n call_id: Schema.String,\n name: Schema.String,\n // JSON-encoded arguments string, mirroring OpenAI Responses API\n arguments: Schema.String,\n providerData: ProviderData,\n})\nexport type FunctionCall = typeof FunctionCall.Type\n\nexport const FunctionCallOutput = Schema.Struct({\n type: Schema.Literal(\"function_call_output\"),\n call_id: Schema.String,\n output: Schema.String,\n providerData: ProviderData,\n})\nexport type FunctionCallOutput = typeof FunctionCallOutput.Type\n\n/**\n * Reasoning item - top-level, mirrors OpenAI Responses API. Common shape\n * across providers covers `summary` (human-readable text) and `signature`\n * (opaque round-trip blob - Anthropic's signed thinking, OpenAI's\n * encrypted_content, etc.). Provider-specific fields go in `providerData`.\n */\nexport const Reasoning = Schema.Struct({\n type: Schema.Literal(\"reasoning\"),\n id: Schema.optional(Schema.String),\n summary: Schema.optional(Schema.String),\n signature: Schema.optional(Schema.String),\n providerData: ProviderData,\n})\nexport type Reasoning = typeof Reasoning.Type\n\nexport const Item = Schema.Union([Message, FunctionCall, FunctionCallOutput, Reasoning])\nexport type Item = typeof Item.Type\n\n// ---------------------------------------------------------------------------\n// Type guards\n// ---------------------------------------------------------------------------\n\nexport const isInputText = Schema.is(InputText)\nexport const isInputImage = Schema.is(InputImage)\nexport const isOutputText = Schema.is(OutputText)\nexport const isRefusal = Schema.is(Refusal)\n\nexport const isMessage = Schema.is(Message)\nexport const isFunctionCall = Schema.is(FunctionCall)\nexport const isFunctionCallOutput = Schema.is(FunctionCallOutput)\nexport const isReasoning = Schema.is(Reasoning)\n\n// ---------------------------------------------------------------------------\n// Usage and stop reason\n// ---------------------------------------------------------------------------\n\nexport const InputTokensDetails = Schema.Struct({\n cached_tokens: Schema.optional(Schema.Number),\n})\nexport type InputTokensDetails = typeof InputTokensDetails.Type\n\nexport const OutputTokensDetails = Schema.Struct({\n reasoning_tokens: Schema.optional(Schema.Number),\n})\nexport type OutputTokensDetails = typeof OutputTokensDetails.Type\n\nexport const Usage = Schema.Struct({\n input_tokens: Schema.optional(Schema.Number),\n output_tokens: Schema.optional(Schema.Number),\n total_tokens: Schema.optional(Schema.Number),\n input_tokens_details: Schema.optional(InputTokensDetails),\n output_tokens_details: Schema.optional(OutputTokensDetails),\n})\nexport type Usage = typeof Usage.Type\n\nexport const StopReason = Schema.Literals([\n \"stop\",\n \"tool_calls\",\n \"max_tokens\",\n \"refusal\",\n /** Provider-side safety classifier flagged the output. */\n \"content_filter\",\n /** Server-enforced cap on tool calls per turn was hit. */\n \"max_tool_calls\",\n])\nexport type StopReason = typeof StopReason.Type\n\n// ---------------------------------------------------------------------------\n// Helper constructors\n// ---------------------------------------------------------------------------\n\nexport const userText = (text: string): Message => ({\n type: \"message\",\n role: \"user\",\n content: [{ type: \"input_text\", text }],\n})\n\nexport const systemText = (text: string): Message => ({\n type: \"message\",\n role: \"system\",\n content: [{ type: \"input_text\", text }],\n})\n\nexport const assistantText = (text: string): Message => ({\n type: \"message\",\n role: \"assistant\",\n content: [{ type: \"output_text\", text }],\n})\n\nexport const functionCallOutput = (call_id: string, output: string): FunctionCallOutput => ({\n type: \"function_call_output\",\n call_id,\n output,\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAa,YAAY,OAAO,OAAO;CACrC,MAAM,OAAO,QAAQ,aAAa;CAClC,MAAM,OAAO;CACd,CAAC;;;;;;;;;AAWF,MAAa,aAAa,OAAO,OAAO;CACtC,MAAM,OAAO,QAAQ,cAAc;CACnC,QAAQ;CACT,CAAC;AASF,MAAa,cAAc,OAAO,OAAO;CACvC,MAAM,OAAO,QAAQ,eAAe;CACpC,KAAK,OAAO;CACZ,aAAa,OAAO;CACpB,WAAW,OAAO;CAClB,OAAO,OAAO;CACf,CAAC;AAGF,MAAa,eAAe,OAAO,OAAO;CACxC,MAAM,OAAO,QAAQ,gBAAgB;CACrC,SAAS,OAAO;CAChB,OAAO,OAAO;CACf,CAAC;AAGF,MAAa,wBAAwB,OAAO,OAAO;CACjD,MAAM,OAAO,QAAQ,0BAA0B;CAC/C,cAAc,OAAO;CACrB,SAAS,OAAO;CAChB,aAAa,OAAO;CACpB,WAAW,OAAO;CACnB,CAAC;AAGF,MAAa,WAAW,OAAO,OAAO;CACpC,MAAM,OAAO,QAAQ,YAAY;CACjC,SAAS,OAAO;CAChB,OAAO,OAAO;CACf,CAAC;AAGF,MAAa,aAAa,OAAO,MAAM;CAAC;CAAa;CAAc;CAAuB;CAAS,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C;AAOxF,MAAa,cAAc,OAAO,GAAG,UAAU;AAC/C,MAAa,eAAe,OAAO,GAAG,WAAW;AACjD,MAAa,eAAe,OAAO,GAAG,WAAW;AACjD,MAAa,YAAY,OAAO,GAAG,QAAQ;AAE3C,MAAa,YAAY,OAAO,GAAG,QAAQ;AAC3C,MAAa,iBAAiB,OAAO,GAAG,aAAa;AACrD,MAAa,uBAAuB,OAAO,GAAG,mBAAmB;AACjE,MAAa,cAAc,OAAO,GAAG,UAAU;AAM/C,MAAa,qBAAqB,OAAO,OAAO,EAC9C,eAAe,OAAO,SAAS,OAAO,OAAO,EAC9C,CAAC;AAGF,MAAa,sBAAsB,OAAO,OAAO,EAC/C,kBAAkB,OAAO,SAAS,OAAO,OAAO,EACjD,CAAC;AAGF,MAAa,QAAQ,OAAO,OAAO;CACjC,cAAc,OAAO,SAAS,OAAO,OAAO;CAC5C,eAAe,OAAO,SAAS,OAAO,OAAO;CAC7C,cAAc,OAAO,SAAS,OAAO,OAAO;CAC5C,sBAAsB,OAAO,SAAS,mBAAmB;CACzD,uBAAuB,OAAO,SAAS,oBAAoB;CAC5D,CAAC;AAGF,MAAa,aAAa,OAAO,SAAS;CACxC;CACA;CACA;CACA;CAEA;CAEA;CACD,CAAC;AAOF,MAAa,YAAY,UAA2B;CAClD,MAAM;CACN,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAc;EAAM,CAAC;CACxC;AAED,MAAa,cAAc,UAA2B;CACpD,MAAM;CACN,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAc;EAAM,CAAC;CACxC;AAED,MAAa,iBAAiB,UAA2B;CACvD,MAAM;CACN,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAe;EAAM,CAAC;CACzC;AAED,MAAa,sBAAsB,SAAiB,YAAwC;CAC1F,MAAM;CACN;CACA;CACD"}
1
+ {"version":3,"file":"Items.mjs","names":[],"sources":["../../src/domain/Items.ts"],"sourcesContent":["import { Schema } from \"effect\"\nimport { ImageSource } from \"./Image.js\"\n\n// ---------------------------------------------------------------------------\n// Content blocks (inside Message.content)\n// ---------------------------------------------------------------------------\n\nexport const InputText = Schema.Struct({\n type: Schema.Literal(\"input_text\"),\n text: Schema.String,\n})\nexport type InputText = typeof InputText.Type\n\n/**\n * User-provided image content block. Pair with `InputText` inside a\n * `Message.content` array to ask \"what's in this image?\" style questions.\n *\n * `source` is the cross-modality `ImageSource` from `domain/Image.ts` -\n * url, base64, or raw bytes. Provider codecs encode bytes to whatever\n * wire format the provider wants.\n */\nexport const InputImage = Schema.Struct({\n type: Schema.Literal(\"input_image\"),\n source: ImageSource,\n})\nexport type InputImage = typeof InputImage.Type\n\n// ---------------------------------------------------------------------------\n// Annotations - source / citation pointers attached to `output_text` blocks.\n// Mirrors OpenAI Responses API; other providers can omit or map onto these\n// shapes.\n// ---------------------------------------------------------------------------\n\nexport const UrlCitation = Schema.Struct({\n type: Schema.Literal(\"url_citation\"),\n url: Schema.String,\n start_index: Schema.Number,\n end_index: Schema.Number,\n title: Schema.String,\n})\nexport type UrlCitation = typeof UrlCitation.Type\n\nexport const FileCitation = Schema.Struct({\n type: Schema.Literal(\"file_citation\"),\n file_id: Schema.String,\n index: Schema.Number,\n})\nexport type FileCitation = typeof FileCitation.Type\n\nexport const ContainerFileCitation = Schema.Struct({\n type: Schema.Literal(\"container_file_citation\"),\n container_id: Schema.String,\n file_id: Schema.String,\n start_index: Schema.Number,\n end_index: Schema.Number,\n})\nexport type ContainerFileCitation = typeof ContainerFileCitation.Type\n\nexport const FilePath = Schema.Struct({\n type: Schema.Literal(\"file_path\"),\n file_id: Schema.String,\n index: Schema.Number,\n})\nexport type FilePath = typeof FilePath.Type\n\nexport const Annotation = Schema.Union([UrlCitation, FileCitation, ContainerFileCitation, FilePath])\nexport type Annotation = typeof Annotation.Type\n\nexport const isUrlCitation = Schema.is(UrlCitation)\nexport const isFileCitation = Schema.is(FileCitation)\nexport const isContainerFileCitation = Schema.is(ContainerFileCitation)\nexport const isFilePath = Schema.is(FilePath)\n\nexport const OutputText = Schema.Struct({\n type: Schema.Literal(\"output_text\"),\n text: Schema.String,\n annotations: Schema.optional(Schema.Array(Annotation)),\n})\nexport type OutputText = typeof OutputText.Type\n\n/**\n * Model-emitted refusal. Distinct from `output_text`: the model declined\n * to answer rather than producing normal output. Pair with\n * `stop_reason: \"refusal\"` on the surrounding `Turn`. Streamed via the\n * `RefusalDelta` `TurnEvent`.\n */\nexport const Refusal = Schema.Struct({\n type: Schema.Literal(\"refusal\"),\n text: Schema.String,\n})\nexport type Refusal = typeof Refusal.Type\n\nexport const ContentBlock = Schema.Union([InputText, InputImage, OutputText, Refusal])\nexport type ContentBlock = typeof ContentBlock.Type\n\nexport const Role = Schema.Literals([\"user\", \"assistant\", \"system\"])\nexport type Role = typeof Role.Type\n\n// ---------------------------------------------------------------------------\n// Provider passthrough - every Item type carries this opaque slot.\n// The framework never reads or interprets it; provider modules decode\n// their own data via their own typed readers (see e.g.\n// the `@effect-uai/responses` package).\n// ---------------------------------------------------------------------------\n\nconst ProviderData = Schema.optional(Schema.Unknown)\n\n// ---------------------------------------------------------------------------\n// Items\n// ---------------------------------------------------------------------------\n\nexport const Message = Schema.Struct({\n type: Schema.Literal(\"message\"),\n role: Role,\n content: Schema.Array(ContentBlock),\n providerData: ProviderData,\n})\nexport type Message = typeof Message.Type\n\nexport const FunctionCall = Schema.Struct({\n type: Schema.Literal(\"function_call\"),\n call_id: Schema.String,\n name: Schema.String,\n // JSON-encoded arguments string, mirroring OpenAI Responses API\n arguments: Schema.String,\n providerData: ProviderData,\n})\nexport type FunctionCall = typeof FunctionCall.Type\n\nexport const FunctionCallOutput = Schema.Struct({\n type: Schema.Literal(\"function_call_output\"),\n call_id: Schema.String,\n output: Schema.String,\n providerData: ProviderData,\n})\nexport type FunctionCallOutput = typeof FunctionCallOutput.Type\n\n/**\n * Reasoning item - top-level, mirrors OpenAI Responses API. Common shape\n * across providers covers `summary` (human-readable text) and `signature`\n * (opaque round-trip blob - Anthropic's signed thinking, OpenAI's\n * encrypted_content, etc.). Provider-specific fields go in `providerData`.\n */\nexport const Reasoning = Schema.Struct({\n type: Schema.Literal(\"reasoning\"),\n id: Schema.optional(Schema.String),\n summary: Schema.optional(Schema.String),\n signature: Schema.optional(Schema.String),\n providerData: ProviderData,\n})\nexport type Reasoning = typeof Reasoning.Type\n\nexport const Item = Schema.Union([Message, FunctionCall, FunctionCallOutput, Reasoning])\nexport type Item = typeof Item.Type\n\n// ---------------------------------------------------------------------------\n// Type guards\n// ---------------------------------------------------------------------------\n\nexport const isInputText = Schema.is(InputText)\nexport const isInputImage = Schema.is(InputImage)\nexport const isOutputText = Schema.is(OutputText)\nexport const isRefusal = Schema.is(Refusal)\n\nexport const isMessage = Schema.is(Message)\nexport const isFunctionCall = Schema.is(FunctionCall)\nexport const isFunctionCallOutput = Schema.is(FunctionCallOutput)\nexport const isReasoning = Schema.is(Reasoning)\n\n// ---------------------------------------------------------------------------\n// Usage and stop reason\n// ---------------------------------------------------------------------------\n\nexport const InputTokensDetails = Schema.Struct({\n cached_tokens: Schema.optional(Schema.Number),\n})\nexport type InputTokensDetails = typeof InputTokensDetails.Type\n\nexport const OutputTokensDetails = Schema.Struct({\n reasoning_tokens: Schema.optional(Schema.Number),\n})\nexport type OutputTokensDetails = typeof OutputTokensDetails.Type\n\nexport const Usage = Schema.Struct({\n input_tokens: Schema.optional(Schema.Number),\n output_tokens: Schema.optional(Schema.Number),\n total_tokens: Schema.optional(Schema.Number),\n input_tokens_details: Schema.optional(InputTokensDetails),\n output_tokens_details: Schema.optional(OutputTokensDetails),\n})\nexport type Usage = typeof Usage.Type\n\nexport const StopReason = Schema.Literals([\n \"stop\",\n \"tool_calls\",\n \"max_tokens\",\n \"refusal\",\n /** Provider-side safety classifier flagged the output. */\n \"content_filter\",\n /** Server-enforced cap on tool calls per turn was hit. */\n \"max_tool_calls\",\n])\nexport type StopReason = typeof StopReason.Type\n\n// ---------------------------------------------------------------------------\n// Helper constructors\n// ---------------------------------------------------------------------------\n\nexport const userText = (text: string): Message => ({\n type: \"message\",\n role: \"user\",\n content: [{ type: \"input_text\", text }],\n})\n\nexport const systemText = (text: string): Message => ({\n type: \"message\",\n role: \"system\",\n content: [{ type: \"input_text\", text }],\n})\n\nexport const assistantText = (text: string): Message => ({\n type: \"message\",\n role: \"assistant\",\n content: [{ type: \"output_text\", text }],\n})\n\nexport const functionCallOutput = (call_id: string, output: string): FunctionCallOutput => ({\n type: \"function_call_output\",\n call_id,\n output,\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAa,YAAY,OAAO,OAAO;CACrC,MAAM,OAAO,QAAQ,aAAa;CAClC,MAAM,OAAO;CACd,CAAC;;;;;;;;;AAWF,MAAa,aAAa,OAAO,OAAO;CACtC,MAAM,OAAO,QAAQ,cAAc;CACnC,QAAQ;CACT,CAAC;AASF,MAAa,cAAc,OAAO,OAAO;CACvC,MAAM,OAAO,QAAQ,eAAe;CACpC,KAAK,OAAO;CACZ,aAAa,OAAO;CACpB,WAAW,OAAO;CAClB,OAAO,OAAO;CACf,CAAC;AAGF,MAAa,eAAe,OAAO,OAAO;CACxC,MAAM,OAAO,QAAQ,gBAAgB;CACrC,SAAS,OAAO;CAChB,OAAO,OAAO;CACf,CAAC;AAGF,MAAa,wBAAwB,OAAO,OAAO;CACjD,MAAM,OAAO,QAAQ,0BAA0B;CAC/C,cAAc,OAAO;CACrB,SAAS,OAAO;CAChB,aAAa,OAAO;CACpB,WAAW,OAAO;CACnB,CAAC;AAGF,MAAa,WAAW,OAAO,OAAO;CACpC,MAAM,OAAO,QAAQ,YAAY;CACjC,SAAS,OAAO;CAChB,OAAO,OAAO;CACf,CAAC;AAGF,MAAa,aAAa,OAAO,MAAM;CAAC;CAAa;CAAc;CAAuB;CAAS,CAAC;AAGpG,MAAa,gBAAgB,OAAO,GAAG,YAAY;AACnD,MAAa,iBAAiB,OAAO,GAAG,aAAa;AACrD,MAAa,0BAA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