@effect-uai/core 0.15.0 → 0.17.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.
- package/README.md +30 -16
- package/dist/{AiError-eLV9t1lU.d.mts → AiError-DvhLIbmd.d.mts} +15 -4
- package/dist/{AiError-eLV9t1lU.d.mts.map → AiError-DvhLIbmd.d.mts.map} +1 -1
- package/dist/{Loop-B54AB1ME.d.mts → Loop-ChpaO-ya.d.mts} +2 -2
- package/dist/{Loop-B54AB1ME.d.mts.map → Loop-ChpaO-ya.d.mts.map} +1 -1
- package/dist/{Toolkit-DAjJ9Tvl.d.mts → Toolkit-tlL0F2YR.d.mts} +2 -2
- package/dist/{Toolkit-DAjJ9Tvl.d.mts.map → Toolkit-tlL0F2YR.d.mts.map} +1 -1
- package/dist/chunker/Chunker.d.mts +1 -1
- package/dist/decision-model/Decision.d.mts +155 -0
- package/dist/decision-model/Decision.d.mts.map +1 -0
- package/dist/decision-model/Decision.mjs +118 -0
- package/dist/decision-model/Decision.mjs.map +1 -0
- package/dist/decision-model/Decision.test.mjs +164 -0
- package/dist/decision-model/Decision.test.mjs.map +1 -0
- package/dist/decision-model/DecisionModel.d.mts +45 -0
- package/dist/decision-model/DecisionModel.d.mts.map +1 -0
- package/dist/decision-model/DecisionModel.mjs +25 -0
- package/dist/decision-model/DecisionModel.mjs.map +1 -0
- package/dist/domain/AiError.d.mts +2 -2
- package/dist/domain/AiError.mjs +9 -2
- package/dist/domain/AiError.mjs.map +1 -1
- package/dist/domain/Realtime.d.mts +616 -0
- package/dist/domain/Realtime.d.mts.map +1 -0
- package/dist/domain/Realtime.mjs +21 -0
- package/dist/domain/Realtime.mjs.map +1 -0
- package/dist/domain/Transcript.d.mts +17 -3
- package/dist/domain/Transcript.d.mts.map +1 -1
- package/dist/domain/Transcript.mjs +30 -1
- package/dist/domain/Transcript.mjs.map +1 -1
- package/dist/domain/Transcript.test.d.mts +1 -0
- package/dist/domain/Transcript.test.mjs +110 -0
- package/dist/domain/Transcript.test.mjs.map +1 -0
- package/dist/embedding-model/EmbeddingModel.d.mts +1 -1
- package/dist/image-generator/ImageGenerator.d.mts +1 -1
- package/dist/index.d.mts +11 -5
- package/dist/index.mjs +9 -3
- package/dist/job/Job.d.mts +1 -1
- package/dist/language-model/LanguageModel.d.mts +2 -2
- package/dist/loop/Loop.d.mts +1 -1
- package/dist/math/Probability.d.mts +21 -0
- package/dist/math/Probability.d.mts.map +1 -0
- package/dist/math/Probability.mjs +31 -0
- package/dist/math/Probability.mjs.map +1 -0
- package/dist/math/Probability.test.d.mts +1 -0
- package/dist/math/Probability.test.mjs +95 -0
- package/dist/math/Probability.test.mjs.map +1 -0
- package/dist/music-generator/MusicGenerator.d.mts +1 -1
- package/dist/realtime/RealtimeSession.d.mts +50 -0
- package/dist/realtime/RealtimeSession.d.mts.map +1 -0
- package/dist/realtime/RealtimeSession.mjs +45 -0
- package/dist/realtime/RealtimeSession.mjs.map +1 -0
- package/dist/realtime/RealtimeSession.test.d.mts +1 -0
- package/dist/realtime/RealtimeSession.test.mjs +95 -0
- package/dist/realtime/RealtimeSession.test.mjs.map +1 -0
- package/dist/reranker/Reranker.d.mts +1 -1
- package/dist/research/DeepResearch.d.mts +1 -1
- package/dist/retry/Retry.d.mts +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.d.mts +1 -1
- package/dist/streaming/Settle.d.mts +45 -0
- package/dist/streaming/Settle.d.mts.map +1 -0
- package/dist/streaming/Settle.mjs +95 -0
- package/dist/streaming/Settle.mjs.map +1 -0
- package/dist/streaming/Settle.test.d.mts +1 -0
- package/dist/streaming/Settle.test.mjs +252 -0
- package/dist/streaming/Settle.test.mjs.map +1 -0
- package/dist/streaming/WebSocketSession.d.mts +36 -0
- package/dist/streaming/WebSocketSession.d.mts.map +1 -0
- package/dist/streaming/WebSocketSession.mjs +89 -0
- package/dist/streaming/WebSocketSession.mjs.map +1 -0
- package/dist/streaming/WebSocketSession.test.d.mts +1 -0
- package/dist/streaming/WebSocketSession.test.mjs +51 -0
- package/dist/streaming/WebSocketSession.test.mjs.map +1 -0
- package/dist/testing/FakeWebSocket.d.mts +25 -0
- package/dist/testing/FakeWebSocket.d.mts.map +1 -0
- package/dist/testing/FakeWebSocket.mjs +79 -0
- package/dist/testing/FakeWebSocket.mjs.map +1 -0
- package/dist/testing/MockRealtimeSession.d.mts +30 -0
- package/dist/testing/MockRealtimeSession.d.mts.map +1 -0
- package/dist/testing/MockRealtimeSession.mjs +52 -0
- package/dist/testing/MockRealtimeSession.mjs.map +1 -0
- package/dist/tool/Toolkit.d.mts +1 -1
- package/dist/transcriber/Transcriber.d.mts +1 -1
- package/dist/web-read/WebRead.d.mts +1 -1
- package/dist/web-read/WebReadTool.d.mts +1 -1
- package/dist/web-search/WebSearch.d.mts +1 -1
- package/dist/web-search/WebSearchTool.d.mts +1 -1
- package/package.json +36 -4
- package/src/decision-model/Decision.test.ts +146 -0
- package/src/decision-model/Decision.ts +273 -0
- package/src/decision-model/DecisionModel.ts +53 -0
- package/src/domain/AiError.ts +11 -0
- package/src/domain/Realtime.ts +101 -0
- package/src/domain/Transcript.test.ts +98 -0
- package/src/domain/Transcript.ts +53 -1
- package/src/index.ts +7 -1
- package/src/math/Probability.test.ts +61 -0
- package/src/math/Probability.ts +44 -0
- package/src/realtime/RealtimeSession.test.ts +100 -0
- package/src/realtime/RealtimeSession.ts +77 -0
- package/src/streaming/Settle.test.ts +344 -0
- package/src/streaming/Settle.ts +196 -0
- package/src/streaming/WebSocketSession.test.ts +52 -0
- package/src/streaming/WebSocketSession.ts +132 -0
- package/src/testing/FakeWebSocket.ts +120 -0
- package/src/testing/MockRealtimeSession.ts +92 -0
- package/dist/inbox/Inbox.d.mts +0 -16
- package/dist/inbox/Inbox.d.mts.map +0 -1
- package/dist/inbox/Inbox.mjs +0 -28
- package/dist/inbox/Inbox.mjs.map +0 -1
- package/dist/inbox/Inbox.test.mjs +0 -42
- package/dist/inbox/Inbox.test.mjs.map +0 -1
- package/src/inbox/Inbox.test.ts +0 -52
- package/src/inbox/Inbox.ts +0 -33
- /package/dist/{inbox/Inbox.test.d.mts → decision-model/Decision.test.d.mts} +0 -0
|
@@ -0,0 +1,616 @@
|
|
|
1
|
+
import { o as ImageSource } from "../Image-Cv6iBLTy.mjs";
|
|
2
|
+
import { S as Usage, b as ToolCallOutput, o as HistoryItem, y as ToolCall } from "../Items-C7MyrYPX.mjs";
|
|
3
|
+
import { u as ToolDescriptor } from "../Tool-BF78QWtn.mjs";
|
|
4
|
+
import { r as AudioFormat } from "../Audio-_nGR4V0X.mjs";
|
|
5
|
+
import { Data, Duration } from "effect";
|
|
6
|
+
declare namespace Realtime_d_exports {
|
|
7
|
+
export { CommonSessionRequest, RealtimeEvent, RealtimeInput };
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* What the caller pushes into a live session.
|
|
11
|
+
*
|
|
12
|
+
* - `Audio`: encoded per `request.inputFormat`. The adapter neither paces nor
|
|
13
|
+
* buffers; send at real time.
|
|
14
|
+
* - `Text`: role `system` maps to a system item where the provider has one and
|
|
15
|
+
* fails `Unsupported` where it does not.
|
|
16
|
+
* - `Interrupt`: cancel the response in flight.
|
|
17
|
+
* - `VideoFrame`: gated by the `RealtimeVideoInput` marker.
|
|
18
|
+
* - `ActivityStart` / `ActivityEnd`: manual turn detection only; `ActivityEnd`
|
|
19
|
+
* also asks for a response. Dropped with a warning on a `"server"` session.
|
|
20
|
+
* - `PlaybackPosition`: how much of a response the user actually heard, so the
|
|
21
|
+
* adapter can trim the rest from context. A no-op where the wire has no
|
|
22
|
+
* truncate.
|
|
23
|
+
*/
|
|
24
|
+
type RealtimeInput = Data.TaggedEnum<{
|
|
25
|
+
Audio: {
|
|
26
|
+
readonly bytes: Uint8Array;
|
|
27
|
+
};
|
|
28
|
+
Text: {
|
|
29
|
+
readonly text: string;
|
|
30
|
+
readonly role?: "user" | "system";
|
|
31
|
+
};
|
|
32
|
+
ToolResult: {
|
|
33
|
+
readonly output: ToolCallOutput;
|
|
34
|
+
};
|
|
35
|
+
Interrupt: {};
|
|
36
|
+
VideoFrame: {
|
|
37
|
+
readonly frame: ImageSource;
|
|
38
|
+
};
|
|
39
|
+
ActivityStart: {};
|
|
40
|
+
ActivityEnd: {};
|
|
41
|
+
PlaybackPosition: {
|
|
42
|
+
readonly responseId: string;
|
|
43
|
+
readonly playedMs: number;
|
|
44
|
+
};
|
|
45
|
+
}>;
|
|
46
|
+
declare const RealtimeInput: {
|
|
47
|
+
readonly $is: <Tag extends "ActivityEnd" | "ActivityStart" | "Audio" | "Interrupt" | "PlaybackPosition" | "Text" | "ToolResult" | "VideoFrame">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
48
|
+
readonly _tag: "ActivityEnd";
|
|
49
|
+
}, {
|
|
50
|
+
readonly _tag: Tag;
|
|
51
|
+
}> | Extract<{
|
|
52
|
+
readonly _tag: "ActivityStart";
|
|
53
|
+
}, {
|
|
54
|
+
readonly _tag: Tag;
|
|
55
|
+
}> | Extract<{
|
|
56
|
+
readonly _tag: "Audio";
|
|
57
|
+
readonly bytes: Uint8Array;
|
|
58
|
+
}, {
|
|
59
|
+
readonly _tag: Tag;
|
|
60
|
+
}> | Extract<{
|
|
61
|
+
readonly _tag: "Interrupt";
|
|
62
|
+
}, {
|
|
63
|
+
readonly _tag: Tag;
|
|
64
|
+
}> | Extract<{
|
|
65
|
+
readonly _tag: "PlaybackPosition";
|
|
66
|
+
readonly responseId: string;
|
|
67
|
+
readonly playedMs: number;
|
|
68
|
+
}, {
|
|
69
|
+
readonly _tag: Tag;
|
|
70
|
+
}> | Extract<{
|
|
71
|
+
readonly _tag: "Text";
|
|
72
|
+
readonly text: string;
|
|
73
|
+
readonly role?: "user" | "system";
|
|
74
|
+
}, {
|
|
75
|
+
readonly _tag: Tag;
|
|
76
|
+
}> | Extract<{
|
|
77
|
+
readonly _tag: "ToolResult";
|
|
78
|
+
readonly output: ToolCallOutput;
|
|
79
|
+
}, {
|
|
80
|
+
readonly _tag: Tag;
|
|
81
|
+
}> | Extract<{
|
|
82
|
+
readonly _tag: "VideoFrame";
|
|
83
|
+
readonly frame: ImageSource;
|
|
84
|
+
}, {
|
|
85
|
+
readonly _tag: Tag;
|
|
86
|
+
}>;
|
|
87
|
+
readonly $match: {
|
|
88
|
+
<Cases extends { readonly [Tag in "ActivityEnd" | "ActivityStart" | "Audio" | "Interrupt" | "PlaybackPosition" | "Text" | "ToolResult" | "VideoFrame"]: (args: Extract<{
|
|
89
|
+
readonly _tag: "ActivityEnd";
|
|
90
|
+
} | {
|
|
91
|
+
readonly _tag: "ActivityStart";
|
|
92
|
+
} | {
|
|
93
|
+
readonly _tag: "Audio";
|
|
94
|
+
readonly bytes: Uint8Array;
|
|
95
|
+
} | {
|
|
96
|
+
readonly _tag: "Interrupt";
|
|
97
|
+
} | {
|
|
98
|
+
readonly _tag: "PlaybackPosition";
|
|
99
|
+
readonly responseId: string;
|
|
100
|
+
readonly playedMs: number;
|
|
101
|
+
} | {
|
|
102
|
+
readonly _tag: "Text";
|
|
103
|
+
readonly text: string;
|
|
104
|
+
readonly role?: "user" | "system";
|
|
105
|
+
} | {
|
|
106
|
+
readonly _tag: "ToolResult";
|
|
107
|
+
readonly output: ToolCallOutput;
|
|
108
|
+
} | {
|
|
109
|
+
readonly _tag: "VideoFrame";
|
|
110
|
+
readonly frame: ImageSource;
|
|
111
|
+
}, {
|
|
112
|
+
readonly _tag: Tag;
|
|
113
|
+
}>) => any; }>(cases: Cases): (value: {
|
|
114
|
+
readonly _tag: "ActivityEnd";
|
|
115
|
+
} | {
|
|
116
|
+
readonly _tag: "ActivityStart";
|
|
117
|
+
} | {
|
|
118
|
+
readonly _tag: "Audio";
|
|
119
|
+
readonly bytes: Uint8Array;
|
|
120
|
+
} | {
|
|
121
|
+
readonly _tag: "Interrupt";
|
|
122
|
+
} | {
|
|
123
|
+
readonly _tag: "PlaybackPosition";
|
|
124
|
+
readonly responseId: string;
|
|
125
|
+
readonly playedMs: number;
|
|
126
|
+
} | {
|
|
127
|
+
readonly _tag: "Text";
|
|
128
|
+
readonly text: string;
|
|
129
|
+
readonly role?: "user" | "system";
|
|
130
|
+
} | {
|
|
131
|
+
readonly _tag: "ToolResult";
|
|
132
|
+
readonly output: ToolCallOutput;
|
|
133
|
+
} | {
|
|
134
|
+
readonly _tag: "VideoFrame";
|
|
135
|
+
readonly frame: ImageSource;
|
|
136
|
+
}) => import("effect/Unify").Unify<ReturnType<Cases["ActivityEnd" | "ActivityStart" | "Audio" | "Interrupt" | "PlaybackPosition" | "Text" | "ToolResult" | "VideoFrame"]>>;
|
|
137
|
+
<Cases extends { readonly [Tag in "ActivityEnd" | "ActivityStart" | "Audio" | "Interrupt" | "PlaybackPosition" | "Text" | "ToolResult" | "VideoFrame"]: (args: Extract<{
|
|
138
|
+
readonly _tag: "ActivityEnd";
|
|
139
|
+
} | {
|
|
140
|
+
readonly _tag: "ActivityStart";
|
|
141
|
+
} | {
|
|
142
|
+
readonly _tag: "Audio";
|
|
143
|
+
readonly bytes: Uint8Array;
|
|
144
|
+
} | {
|
|
145
|
+
readonly _tag: "Interrupt";
|
|
146
|
+
} | {
|
|
147
|
+
readonly _tag: "PlaybackPosition";
|
|
148
|
+
readonly responseId: string;
|
|
149
|
+
readonly playedMs: number;
|
|
150
|
+
} | {
|
|
151
|
+
readonly _tag: "Text";
|
|
152
|
+
readonly text: string;
|
|
153
|
+
readonly role?: "user" | "system";
|
|
154
|
+
} | {
|
|
155
|
+
readonly _tag: "ToolResult";
|
|
156
|
+
readonly output: ToolCallOutput;
|
|
157
|
+
} | {
|
|
158
|
+
readonly _tag: "VideoFrame";
|
|
159
|
+
readonly frame: ImageSource;
|
|
160
|
+
}, {
|
|
161
|
+
readonly _tag: Tag;
|
|
162
|
+
}>) => any; }>(value: {
|
|
163
|
+
readonly _tag: "ActivityEnd";
|
|
164
|
+
} | {
|
|
165
|
+
readonly _tag: "ActivityStart";
|
|
166
|
+
} | {
|
|
167
|
+
readonly _tag: "Audio";
|
|
168
|
+
readonly bytes: Uint8Array;
|
|
169
|
+
} | {
|
|
170
|
+
readonly _tag: "Interrupt";
|
|
171
|
+
} | {
|
|
172
|
+
readonly _tag: "PlaybackPosition";
|
|
173
|
+
readonly responseId: string;
|
|
174
|
+
readonly playedMs: number;
|
|
175
|
+
} | {
|
|
176
|
+
readonly _tag: "Text";
|
|
177
|
+
readonly text: string;
|
|
178
|
+
readonly role?: "user" | "system";
|
|
179
|
+
} | {
|
|
180
|
+
readonly _tag: "ToolResult";
|
|
181
|
+
readonly output: ToolCallOutput;
|
|
182
|
+
} | {
|
|
183
|
+
readonly _tag: "VideoFrame";
|
|
184
|
+
readonly frame: ImageSource;
|
|
185
|
+
}, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["ActivityEnd" | "ActivityStart" | "Audio" | "Interrupt" | "PlaybackPosition" | "Text" | "ToolResult" | "VideoFrame"]>>;
|
|
186
|
+
};
|
|
187
|
+
readonly ActivityEnd: Data.TaggedEnum.ConstructorFrom<{
|
|
188
|
+
readonly _tag: "ActivityEnd";
|
|
189
|
+
}, "_tag">;
|
|
190
|
+
readonly ActivityStart: Data.TaggedEnum.ConstructorFrom<{
|
|
191
|
+
readonly _tag: "ActivityStart";
|
|
192
|
+
}, "_tag">;
|
|
193
|
+
readonly Audio: Data.TaggedEnum.ConstructorFrom<{
|
|
194
|
+
readonly _tag: "Audio";
|
|
195
|
+
readonly bytes: Uint8Array;
|
|
196
|
+
}, "_tag">;
|
|
197
|
+
readonly Interrupt: Data.TaggedEnum.ConstructorFrom<{
|
|
198
|
+
readonly _tag: "Interrupt";
|
|
199
|
+
}, "_tag">;
|
|
200
|
+
readonly PlaybackPosition: Data.TaggedEnum.ConstructorFrom<{
|
|
201
|
+
readonly _tag: "PlaybackPosition";
|
|
202
|
+
readonly responseId: string;
|
|
203
|
+
readonly playedMs: number;
|
|
204
|
+
}, "_tag">;
|
|
205
|
+
readonly Text: Data.TaggedEnum.ConstructorFrom<{
|
|
206
|
+
readonly _tag: "Text";
|
|
207
|
+
readonly text: string;
|
|
208
|
+
readonly role?: "user" | "system";
|
|
209
|
+
}, "_tag">;
|
|
210
|
+
readonly ToolResult: Data.TaggedEnum.ConstructorFrom<{
|
|
211
|
+
readonly _tag: "ToolResult";
|
|
212
|
+
readonly output: ToolCallOutput;
|
|
213
|
+
}, "_tag">;
|
|
214
|
+
readonly VideoFrame: Data.TaggedEnum.ConstructorFrom<{
|
|
215
|
+
readonly _tag: "VideoFrame";
|
|
216
|
+
readonly frame: ImageSource;
|
|
217
|
+
}, "_tag">;
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* What the session emits. Every `AudioDelta` and `OutputTranscriptDelta` is
|
|
221
|
+
* bracketed by `ResponseStarted` and `ResponseDone` carrying the same
|
|
222
|
+
* `responseId`.
|
|
223
|
+
*
|
|
224
|
+
* - `InputTranscript`: transcription of the user's own speech.
|
|
225
|
+
* - `SpeechStarted` / `SpeechStopped`: sparse. OpenAI emits them, Gemini
|
|
226
|
+
* does not.
|
|
227
|
+
* - `Interrupted`: stop and flush playback now. Always precedes the
|
|
228
|
+
* `ResponseDone { reason: "interrupted" }` for that response.
|
|
229
|
+
* - `ToolCallCancelled`: calls of an interrupted response that will never be
|
|
230
|
+
* answered.
|
|
231
|
+
* - `ResumptionHandle`: Gemini only; pass it back as `request.resume`.
|
|
232
|
+
* - `SessionEnding`: the connection is about to close on the server's terms.
|
|
233
|
+
* - `Error`: non-fatal. A fatal error fails the stream instead.
|
|
234
|
+
*/
|
|
235
|
+
type RealtimeEvent = Data.TaggedEnum<{
|
|
236
|
+
ResponseStarted: {
|
|
237
|
+
readonly responseId: string;
|
|
238
|
+
};
|
|
239
|
+
AudioDelta: {
|
|
240
|
+
readonly responseId: string;
|
|
241
|
+
readonly bytes: Uint8Array;
|
|
242
|
+
};
|
|
243
|
+
OutputTranscriptDelta: {
|
|
244
|
+
readonly responseId: string;
|
|
245
|
+
readonly text: string;
|
|
246
|
+
};
|
|
247
|
+
InputTranscript: {
|
|
248
|
+
readonly text: string;
|
|
249
|
+
readonly final: boolean;
|
|
250
|
+
};
|
|
251
|
+
SpeechStarted: {};
|
|
252
|
+
SpeechStopped: {};
|
|
253
|
+
ToolCall: {
|
|
254
|
+
readonly responseId: string;
|
|
255
|
+
readonly call: ToolCall;
|
|
256
|
+
};
|
|
257
|
+
ToolCallCancelled: {
|
|
258
|
+
readonly callIds: ReadonlyArray<string>;
|
|
259
|
+
};
|
|
260
|
+
Interrupted: {
|
|
261
|
+
readonly responseId: string;
|
|
262
|
+
};
|
|
263
|
+
ResponseDone: {
|
|
264
|
+
readonly responseId: string;
|
|
265
|
+
readonly reason: "complete" | "interrupted" | "cancelled" | "error";
|
|
266
|
+
readonly usage?: Usage;
|
|
267
|
+
};
|
|
268
|
+
ResumptionHandle: {
|
|
269
|
+
readonly handle: string;
|
|
270
|
+
};
|
|
271
|
+
SessionEnding: {
|
|
272
|
+
readonly timeLeft?: Duration.Duration;
|
|
273
|
+
};
|
|
274
|
+
Error: {
|
|
275
|
+
readonly code?: string;
|
|
276
|
+
readonly message: string;
|
|
277
|
+
};
|
|
278
|
+
}>;
|
|
279
|
+
declare const RealtimeEvent: {
|
|
280
|
+
readonly $is: <Tag extends "AudioDelta" | "Error" | "InputTranscript" | "Interrupted" | "OutputTranscriptDelta" | "ResponseDone" | "ResponseStarted" | "ResumptionHandle" | "SessionEnding" | "SpeechStarted" | "SpeechStopped" | "ToolCall" | "ToolCallCancelled">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
281
|
+
readonly _tag: "AudioDelta";
|
|
282
|
+
readonly responseId: string;
|
|
283
|
+
readonly bytes: Uint8Array;
|
|
284
|
+
}, {
|
|
285
|
+
readonly _tag: Tag;
|
|
286
|
+
}> | Extract<{
|
|
287
|
+
readonly _tag: "Error";
|
|
288
|
+
readonly code?: string;
|
|
289
|
+
readonly message: string;
|
|
290
|
+
}, {
|
|
291
|
+
readonly _tag: Tag;
|
|
292
|
+
}> | Extract<{
|
|
293
|
+
readonly _tag: "InputTranscript";
|
|
294
|
+
readonly text: string;
|
|
295
|
+
readonly final: boolean;
|
|
296
|
+
}, {
|
|
297
|
+
readonly _tag: Tag;
|
|
298
|
+
}> | Extract<{
|
|
299
|
+
readonly _tag: "Interrupted";
|
|
300
|
+
readonly responseId: string;
|
|
301
|
+
}, {
|
|
302
|
+
readonly _tag: Tag;
|
|
303
|
+
}> | Extract<{
|
|
304
|
+
readonly _tag: "OutputTranscriptDelta";
|
|
305
|
+
readonly responseId: string;
|
|
306
|
+
readonly text: string;
|
|
307
|
+
}, {
|
|
308
|
+
readonly _tag: Tag;
|
|
309
|
+
}> | Extract<{
|
|
310
|
+
readonly _tag: "ResponseDone";
|
|
311
|
+
readonly responseId: string;
|
|
312
|
+
readonly reason: "complete" | "interrupted" | "cancelled" | "error";
|
|
313
|
+
readonly usage?: Usage;
|
|
314
|
+
}, {
|
|
315
|
+
readonly _tag: Tag;
|
|
316
|
+
}> | Extract<{
|
|
317
|
+
readonly _tag: "ResponseStarted";
|
|
318
|
+
readonly responseId: string;
|
|
319
|
+
}, {
|
|
320
|
+
readonly _tag: Tag;
|
|
321
|
+
}> | Extract<{
|
|
322
|
+
readonly _tag: "ResumptionHandle";
|
|
323
|
+
readonly handle: string;
|
|
324
|
+
}, {
|
|
325
|
+
readonly _tag: Tag;
|
|
326
|
+
}> | Extract<{
|
|
327
|
+
readonly _tag: "SessionEnding";
|
|
328
|
+
readonly timeLeft?: Duration.Duration;
|
|
329
|
+
}, {
|
|
330
|
+
readonly _tag: Tag;
|
|
331
|
+
}> | Extract<{
|
|
332
|
+
readonly _tag: "SpeechStarted";
|
|
333
|
+
}, {
|
|
334
|
+
readonly _tag: Tag;
|
|
335
|
+
}> | Extract<{
|
|
336
|
+
readonly _tag: "SpeechStopped";
|
|
337
|
+
}, {
|
|
338
|
+
readonly _tag: Tag;
|
|
339
|
+
}> | Extract<{
|
|
340
|
+
readonly _tag: "ToolCall";
|
|
341
|
+
readonly responseId: string;
|
|
342
|
+
readonly call: ToolCall;
|
|
343
|
+
}, {
|
|
344
|
+
readonly _tag: Tag;
|
|
345
|
+
}> | Extract<{
|
|
346
|
+
readonly _tag: "ToolCallCancelled";
|
|
347
|
+
readonly callIds: ReadonlyArray<string>;
|
|
348
|
+
}, {
|
|
349
|
+
readonly _tag: Tag;
|
|
350
|
+
}>;
|
|
351
|
+
readonly $match: {
|
|
352
|
+
<Cases extends { readonly [Tag in "AudioDelta" | "Error" | "InputTranscript" | "Interrupted" | "OutputTranscriptDelta" | "ResponseDone" | "ResponseStarted" | "ResumptionHandle" | "SessionEnding" | "SpeechStarted" | "SpeechStopped" | "ToolCall" | "ToolCallCancelled"]: (args: Extract<{
|
|
353
|
+
readonly _tag: "AudioDelta";
|
|
354
|
+
readonly responseId: string;
|
|
355
|
+
readonly bytes: Uint8Array;
|
|
356
|
+
} | {
|
|
357
|
+
readonly _tag: "Error";
|
|
358
|
+
readonly code?: string;
|
|
359
|
+
readonly message: string;
|
|
360
|
+
} | {
|
|
361
|
+
readonly _tag: "InputTranscript";
|
|
362
|
+
readonly text: string;
|
|
363
|
+
readonly final: boolean;
|
|
364
|
+
} | {
|
|
365
|
+
readonly _tag: "Interrupted";
|
|
366
|
+
readonly responseId: string;
|
|
367
|
+
} | {
|
|
368
|
+
readonly _tag: "OutputTranscriptDelta";
|
|
369
|
+
readonly responseId: string;
|
|
370
|
+
readonly text: string;
|
|
371
|
+
} | {
|
|
372
|
+
readonly _tag: "ResponseDone";
|
|
373
|
+
readonly responseId: string;
|
|
374
|
+
readonly reason: "complete" | "interrupted" | "cancelled" | "error";
|
|
375
|
+
readonly usage?: Usage;
|
|
376
|
+
} | {
|
|
377
|
+
readonly _tag: "ResponseStarted";
|
|
378
|
+
readonly responseId: string;
|
|
379
|
+
} | {
|
|
380
|
+
readonly _tag: "ResumptionHandle";
|
|
381
|
+
readonly handle: string;
|
|
382
|
+
} | {
|
|
383
|
+
readonly _tag: "SessionEnding";
|
|
384
|
+
readonly timeLeft?: Duration.Duration;
|
|
385
|
+
} | {
|
|
386
|
+
readonly _tag: "SpeechStarted";
|
|
387
|
+
} | {
|
|
388
|
+
readonly _tag: "SpeechStopped";
|
|
389
|
+
} | {
|
|
390
|
+
readonly _tag: "ToolCall";
|
|
391
|
+
readonly responseId: string;
|
|
392
|
+
readonly call: ToolCall;
|
|
393
|
+
} | {
|
|
394
|
+
readonly _tag: "ToolCallCancelled";
|
|
395
|
+
readonly callIds: ReadonlyArray<string>;
|
|
396
|
+
}, {
|
|
397
|
+
readonly _tag: Tag;
|
|
398
|
+
}>) => any; }>(cases: Cases): (value: {
|
|
399
|
+
readonly _tag: "AudioDelta";
|
|
400
|
+
readonly responseId: string;
|
|
401
|
+
readonly bytes: Uint8Array;
|
|
402
|
+
} | {
|
|
403
|
+
readonly _tag: "Error";
|
|
404
|
+
readonly code?: string;
|
|
405
|
+
readonly message: string;
|
|
406
|
+
} | {
|
|
407
|
+
readonly _tag: "InputTranscript";
|
|
408
|
+
readonly text: string;
|
|
409
|
+
readonly final: boolean;
|
|
410
|
+
} | {
|
|
411
|
+
readonly _tag: "Interrupted";
|
|
412
|
+
readonly responseId: string;
|
|
413
|
+
} | {
|
|
414
|
+
readonly _tag: "OutputTranscriptDelta";
|
|
415
|
+
readonly responseId: string;
|
|
416
|
+
readonly text: string;
|
|
417
|
+
} | {
|
|
418
|
+
readonly _tag: "ResponseDone";
|
|
419
|
+
readonly responseId: string;
|
|
420
|
+
readonly reason: "complete" | "interrupted" | "cancelled" | "error";
|
|
421
|
+
readonly usage?: Usage;
|
|
422
|
+
} | {
|
|
423
|
+
readonly _tag: "ResponseStarted";
|
|
424
|
+
readonly responseId: string;
|
|
425
|
+
} | {
|
|
426
|
+
readonly _tag: "ResumptionHandle";
|
|
427
|
+
readonly handle: string;
|
|
428
|
+
} | {
|
|
429
|
+
readonly _tag: "SessionEnding";
|
|
430
|
+
readonly timeLeft?: Duration.Duration;
|
|
431
|
+
} | {
|
|
432
|
+
readonly _tag: "SpeechStarted";
|
|
433
|
+
} | {
|
|
434
|
+
readonly _tag: "SpeechStopped";
|
|
435
|
+
} | {
|
|
436
|
+
readonly _tag: "ToolCall";
|
|
437
|
+
readonly responseId: string;
|
|
438
|
+
readonly call: ToolCall;
|
|
439
|
+
} | {
|
|
440
|
+
readonly _tag: "ToolCallCancelled";
|
|
441
|
+
readonly callIds: ReadonlyArray<string>;
|
|
442
|
+
}) => import("effect/Unify").Unify<ReturnType<Cases["AudioDelta" | "Error" | "InputTranscript" | "Interrupted" | "OutputTranscriptDelta" | "ResponseDone" | "ResponseStarted" | "ResumptionHandle" | "SessionEnding" | "SpeechStarted" | "SpeechStopped" | "ToolCall" | "ToolCallCancelled"]>>;
|
|
443
|
+
<Cases extends { readonly [Tag in "AudioDelta" | "Error" | "InputTranscript" | "Interrupted" | "OutputTranscriptDelta" | "ResponseDone" | "ResponseStarted" | "ResumptionHandle" | "SessionEnding" | "SpeechStarted" | "SpeechStopped" | "ToolCall" | "ToolCallCancelled"]: (args: Extract<{
|
|
444
|
+
readonly _tag: "AudioDelta";
|
|
445
|
+
readonly responseId: string;
|
|
446
|
+
readonly bytes: Uint8Array;
|
|
447
|
+
} | {
|
|
448
|
+
readonly _tag: "Error";
|
|
449
|
+
readonly code?: string;
|
|
450
|
+
readonly message: string;
|
|
451
|
+
} | {
|
|
452
|
+
readonly _tag: "InputTranscript";
|
|
453
|
+
readonly text: string;
|
|
454
|
+
readonly final: boolean;
|
|
455
|
+
} | {
|
|
456
|
+
readonly _tag: "Interrupted";
|
|
457
|
+
readonly responseId: string;
|
|
458
|
+
} | {
|
|
459
|
+
readonly _tag: "OutputTranscriptDelta";
|
|
460
|
+
readonly responseId: string;
|
|
461
|
+
readonly text: string;
|
|
462
|
+
} | {
|
|
463
|
+
readonly _tag: "ResponseDone";
|
|
464
|
+
readonly responseId: string;
|
|
465
|
+
readonly reason: "complete" | "interrupted" | "cancelled" | "error";
|
|
466
|
+
readonly usage?: Usage;
|
|
467
|
+
} | {
|
|
468
|
+
readonly _tag: "ResponseStarted";
|
|
469
|
+
readonly responseId: string;
|
|
470
|
+
} | {
|
|
471
|
+
readonly _tag: "ResumptionHandle";
|
|
472
|
+
readonly handle: string;
|
|
473
|
+
} | {
|
|
474
|
+
readonly _tag: "SessionEnding";
|
|
475
|
+
readonly timeLeft?: Duration.Duration;
|
|
476
|
+
} | {
|
|
477
|
+
readonly _tag: "SpeechStarted";
|
|
478
|
+
} | {
|
|
479
|
+
readonly _tag: "SpeechStopped";
|
|
480
|
+
} | {
|
|
481
|
+
readonly _tag: "ToolCall";
|
|
482
|
+
readonly responseId: string;
|
|
483
|
+
readonly call: ToolCall;
|
|
484
|
+
} | {
|
|
485
|
+
readonly _tag: "ToolCallCancelled";
|
|
486
|
+
readonly callIds: ReadonlyArray<string>;
|
|
487
|
+
}, {
|
|
488
|
+
readonly _tag: Tag;
|
|
489
|
+
}>) => any; }>(value: {
|
|
490
|
+
readonly _tag: "AudioDelta";
|
|
491
|
+
readonly responseId: string;
|
|
492
|
+
readonly bytes: Uint8Array;
|
|
493
|
+
} | {
|
|
494
|
+
readonly _tag: "Error";
|
|
495
|
+
readonly code?: string;
|
|
496
|
+
readonly message: string;
|
|
497
|
+
} | {
|
|
498
|
+
readonly _tag: "InputTranscript";
|
|
499
|
+
readonly text: string;
|
|
500
|
+
readonly final: boolean;
|
|
501
|
+
} | {
|
|
502
|
+
readonly _tag: "Interrupted";
|
|
503
|
+
readonly responseId: string;
|
|
504
|
+
} | {
|
|
505
|
+
readonly _tag: "OutputTranscriptDelta";
|
|
506
|
+
readonly responseId: string;
|
|
507
|
+
readonly text: string;
|
|
508
|
+
} | {
|
|
509
|
+
readonly _tag: "ResponseDone";
|
|
510
|
+
readonly responseId: string;
|
|
511
|
+
readonly reason: "complete" | "interrupted" | "cancelled" | "error";
|
|
512
|
+
readonly usage?: Usage;
|
|
513
|
+
} | {
|
|
514
|
+
readonly _tag: "ResponseStarted";
|
|
515
|
+
readonly responseId: string;
|
|
516
|
+
} | {
|
|
517
|
+
readonly _tag: "ResumptionHandle";
|
|
518
|
+
readonly handle: string;
|
|
519
|
+
} | {
|
|
520
|
+
readonly _tag: "SessionEnding";
|
|
521
|
+
readonly timeLeft?: Duration.Duration;
|
|
522
|
+
} | {
|
|
523
|
+
readonly _tag: "SpeechStarted";
|
|
524
|
+
} | {
|
|
525
|
+
readonly _tag: "SpeechStopped";
|
|
526
|
+
} | {
|
|
527
|
+
readonly _tag: "ToolCall";
|
|
528
|
+
readonly responseId: string;
|
|
529
|
+
readonly call: ToolCall;
|
|
530
|
+
} | {
|
|
531
|
+
readonly _tag: "ToolCallCancelled";
|
|
532
|
+
readonly callIds: ReadonlyArray<string>;
|
|
533
|
+
}, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["AudioDelta" | "Error" | "InputTranscript" | "Interrupted" | "OutputTranscriptDelta" | "ResponseDone" | "ResponseStarted" | "ResumptionHandle" | "SessionEnding" | "SpeechStarted" | "SpeechStopped" | "ToolCall" | "ToolCallCancelled"]>>;
|
|
534
|
+
};
|
|
535
|
+
readonly AudioDelta: Data.TaggedEnum.ConstructorFrom<{
|
|
536
|
+
readonly _tag: "AudioDelta";
|
|
537
|
+
readonly responseId: string;
|
|
538
|
+
readonly bytes: Uint8Array;
|
|
539
|
+
}, "_tag">;
|
|
540
|
+
readonly Error: Data.TaggedEnum.ConstructorFrom<{
|
|
541
|
+
readonly _tag: "Error";
|
|
542
|
+
readonly code?: string;
|
|
543
|
+
readonly message: string;
|
|
544
|
+
}, "_tag">;
|
|
545
|
+
readonly InputTranscript: Data.TaggedEnum.ConstructorFrom<{
|
|
546
|
+
readonly _tag: "InputTranscript";
|
|
547
|
+
readonly text: string;
|
|
548
|
+
readonly final: boolean;
|
|
549
|
+
}, "_tag">;
|
|
550
|
+
readonly Interrupted: Data.TaggedEnum.ConstructorFrom<{
|
|
551
|
+
readonly _tag: "Interrupted";
|
|
552
|
+
readonly responseId: string;
|
|
553
|
+
}, "_tag">;
|
|
554
|
+
readonly OutputTranscriptDelta: Data.TaggedEnum.ConstructorFrom<{
|
|
555
|
+
readonly _tag: "OutputTranscriptDelta";
|
|
556
|
+
readonly responseId: string;
|
|
557
|
+
readonly text: string;
|
|
558
|
+
}, "_tag">;
|
|
559
|
+
readonly ResponseDone: Data.TaggedEnum.ConstructorFrom<{
|
|
560
|
+
readonly _tag: "ResponseDone";
|
|
561
|
+
readonly responseId: string;
|
|
562
|
+
readonly reason: "complete" | "interrupted" | "cancelled" | "error";
|
|
563
|
+
readonly usage?: Usage;
|
|
564
|
+
}, "_tag">;
|
|
565
|
+
readonly ResponseStarted: Data.TaggedEnum.ConstructorFrom<{
|
|
566
|
+
readonly _tag: "ResponseStarted";
|
|
567
|
+
readonly responseId: string;
|
|
568
|
+
}, "_tag">;
|
|
569
|
+
readonly ResumptionHandle: Data.TaggedEnum.ConstructorFrom<{
|
|
570
|
+
readonly _tag: "ResumptionHandle";
|
|
571
|
+
readonly handle: string;
|
|
572
|
+
}, "_tag">;
|
|
573
|
+
readonly SessionEnding: Data.TaggedEnum.ConstructorFrom<{
|
|
574
|
+
readonly _tag: "SessionEnding";
|
|
575
|
+
readonly timeLeft?: Duration.Duration;
|
|
576
|
+
}, "_tag">;
|
|
577
|
+
readonly SpeechStarted: Data.TaggedEnum.ConstructorFrom<{
|
|
578
|
+
readonly _tag: "SpeechStarted";
|
|
579
|
+
}, "_tag">;
|
|
580
|
+
readonly SpeechStopped: Data.TaggedEnum.ConstructorFrom<{
|
|
581
|
+
readonly _tag: "SpeechStopped";
|
|
582
|
+
}, "_tag">;
|
|
583
|
+
readonly ToolCall: Data.TaggedEnum.ConstructorFrom<{
|
|
584
|
+
readonly _tag: "ToolCall";
|
|
585
|
+
readonly responseId: string;
|
|
586
|
+
readonly call: ToolCall;
|
|
587
|
+
}, "_tag">;
|
|
588
|
+
readonly ToolCallCancelled: Data.TaggedEnum.ConstructorFrom<{
|
|
589
|
+
readonly _tag: "ToolCallCancelled";
|
|
590
|
+
readonly callIds: ReadonlyArray<string>;
|
|
591
|
+
}, "_tag">;
|
|
592
|
+
};
|
|
593
|
+
/**
|
|
594
|
+
* Cross-provider session setup. Each adapter extends this, narrowing `model`
|
|
595
|
+
* and adding its own knobs.
|
|
596
|
+
*/
|
|
597
|
+
type CommonSessionRequest = {
|
|
598
|
+
readonly model: string;
|
|
599
|
+
readonly instructions?: string;
|
|
600
|
+
readonly voiceId?: string;
|
|
601
|
+
/** `Toolkit.descriptors(toolkit)`. Immutable for the connection on Gemini. */
|
|
602
|
+
readonly tools?: ReadonlyArray<ToolDescriptor>;
|
|
603
|
+
readonly inputFormat: AudioFormat;
|
|
604
|
+
readonly outputFormat: AudioFormat;
|
|
605
|
+
/** Who decides a turn ended. Defaults to `"server"`. */
|
|
606
|
+
readonly turnDetection?: "server" | "manual";
|
|
607
|
+
/** Transcribe the user's own audio. Defaults to `true`. */
|
|
608
|
+
readonly transcribeInput?: boolean;
|
|
609
|
+
/** Text-only conversation seed. */
|
|
610
|
+
readonly history?: ReadonlyArray<HistoryItem>;
|
|
611
|
+
/** A `ResumptionHandle` from a previous session. `Unsupported` off Gemini. */
|
|
612
|
+
readonly resume?: string;
|
|
613
|
+
};
|
|
614
|
+
//#endregion
|
|
615
|
+
export { CommonSessionRequest, RealtimeEvent, RealtimeInput, Realtime_d_exports as t };
|
|
616
|
+
//# sourceMappingURL=Realtime.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Realtime.d.mts","names":[],"sources":["../../src/domain/Realtime.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;KA6BY,gBAAgB,KAAK;EAC/B;aAAkB,OAAO;;EACzB;aAAiB;aAAuB;;EACxC;aAAuB,QAAQ;;EAC/B;EACA;aAAuB,OAAO;;EAC9B;EACA;EACA;aAA6B;aAA6B;;;cAG/C;;;;;;;;;;;aAVc,OAAA;;;;;;;;;aAOgB;aAA2B;;;;;aAN7C;aAAwB;;;;;aAChB,QAAA;;;;;aAED,OAAA;;;;;;;;;;;eAJL,OAAA;;;;;eAOgB;eAA2B;;;eAN7C;eAAwB;;;eAChB,QAAA;;;eAED,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAJL,OAAA;;;;;eAOgB;eAA2B;;;eAN7C;eAAwB;;;eAChB,QAAA;;;eAED,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAJL,OAAA;;;;;;;aAOgB;aAA2B;;;;aAN7C;aAAwB;;;;aAChB,QAAA;;;;aAED,OAAA;;;;;;;;;;;;;;;;;;;KAwBpB,gBAAgB,KAAK;EAC/B;aAA4B;;EAC5B;aAAuB;aAA6B,OAAO;;EAC3D;aAAkC;aAA6B;;EAC/D;aAA4B;aAAuB;;EACnD;EACA;EACA;aAAqB;aAA6B,MAAM;;EACxD;aAA8B,SAAS;;EACvC;aAAwB;;EACxB;aACW;aACA;aACA,QAAQ;;EAEnB;aAA6B;;EAC7B;aAA0B,WAAW,SAAS;;EAC9C;aAAkB;aAAwB;;;cAG/B;;;aAlBwB;aAAwB,OAAA;;;;;aAelC;aAA0B;;;;;aAbjB;aAAwB;;;;;aAKtB;;;;;aANU;aAAuB;;;;;aAQ9C;aACJ;aACA,QAAA;;;;;aAZqB;;;;;aAcH;;;;;aACA,WAAA,SAAS;;;;;;;;;;;;;aATb;aAAuB,MAAA;;;;;aACjB,SAAA;;;;;;;eANJ;eAAwB,OAAA;;;eAelC;eAA0B;;;eAbjB;eAAwB;;;eAKtB;;;eANU;eAAuB;;;eAQ9C;eACJ;eACA,QAAA;;;eAZqB;;;eAcH;;;eACA,WAAA,SAAS;;;;;;;eATb;eAAuB,MAAA;;;eACjB,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eANJ;eAAwB,OAAA;;;eAelC;eAA0B;;;eAbjB;eAAwB;;;eAKtB;;;eANU;eAAuB;;;eAQ9C;eACJ;eACA,QAAA;;;eAZqB;;;eAcH;;;eACA,WAAA,SAAS;;;;;;;eATb;eAAuB,MAAA;;;eACjB,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aANJ;aAAwB,OAAA;;;;aAelC;aAA0B;;;;aAbjB;aAAwB;;;;aAKtB;;;;aANU;aAAuB;;;;aAQ9C;aACJ;aACA,QAAA;;;;aAZqB;;;;aAcH;;;;aACA,WAAA,SAAS;;;;;;;;;;aATb;aAAuB,MAAA;;;;aACjB,SAAA;;;;;;;KAkB7B;WACD;WACA;WACA;;WAEA,QAAQ,cAAc;WACtB,aAAa;WACb,cAAc;;WAEd;;WAEA;;WAEA,UAAU,cAAc;;WAExB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { n as __exportAll } from "../rolldown-runtime-EAsCxrDo.mjs";
|
|
2
|
+
import { Data } from "effect";
|
|
3
|
+
//#region src/domain/Realtime.ts
|
|
4
|
+
/**
|
|
5
|
+
* Types for a duplex speech-to-speech session: one long-lived connection the
|
|
6
|
+
* server drives, rather than a caller-driven turn.
|
|
7
|
+
*
|
|
8
|
+
* Only what both OpenAI Realtime and Gemini Live do natively lives here. VAD
|
|
9
|
+
* knobs, truncation, resumption, thinking, grounding and noise reduction are
|
|
10
|
+
* provider-typed on each adapter's request.
|
|
11
|
+
*/
|
|
12
|
+
var Realtime_exports = /* @__PURE__ */ __exportAll({
|
|
13
|
+
RealtimeEvent: () => RealtimeEvent,
|
|
14
|
+
RealtimeInput: () => RealtimeInput
|
|
15
|
+
});
|
|
16
|
+
const RealtimeInput = Data.taggedEnum();
|
|
17
|
+
const RealtimeEvent = Data.taggedEnum();
|
|
18
|
+
//#endregion
|
|
19
|
+
export { RealtimeEvent, RealtimeInput, Realtime_exports as t };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=Realtime.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Realtime.mjs","names":[],"sources":["../../src/domain/Realtime.ts"],"sourcesContent":["/**\n * Types for a duplex speech-to-speech session: one long-lived connection the\n * server drives, rather than a caller-driven turn.\n *\n * Only what both OpenAI Realtime and Gemini Live do natively lives here. VAD\n * knobs, truncation, resumption, thinking, grounding and noise reduction are\n * provider-typed on each adapter's request.\n */\nimport { Data, type Duration } from \"effect\"\nimport type { AudioFormat } from \"./Audio.js\"\nimport type { ImageSource } from \"./Image.js\"\nimport type { HistoryItem, ToolCall, ToolCallOutput, Usage } from \"./Items.js\"\nimport type { ToolDescriptor } from \"../tool/Tool.js\"\n\n/**\n * What the caller pushes into a live session.\n *\n * - `Audio`: encoded per `request.inputFormat`. The adapter neither paces nor\n * buffers; send at real time.\n * - `Text`: role `system` maps to a system item where the provider has one and\n * fails `Unsupported` where it does not.\n * - `Interrupt`: cancel the response in flight.\n * - `VideoFrame`: gated by the `RealtimeVideoInput` marker.\n * - `ActivityStart` / `ActivityEnd`: manual turn detection only; `ActivityEnd`\n * also asks for a response. Dropped with a warning on a `\"server\"` session.\n * - `PlaybackPosition`: how much of a response the user actually heard, so the\n * adapter can trim the rest from context. A no-op where the wire has no\n * truncate.\n */\nexport type RealtimeInput = Data.TaggedEnum<{\n Audio: { readonly bytes: Uint8Array }\n Text: { readonly text: string; readonly role?: \"user\" | \"system\" }\n ToolResult: { readonly output: ToolCallOutput }\n Interrupt: {}\n VideoFrame: { readonly frame: ImageSource }\n ActivityStart: {}\n ActivityEnd: {}\n PlaybackPosition: { readonly responseId: string; readonly playedMs: number }\n}>\n\nexport const RealtimeInput = Data.taggedEnum<RealtimeInput>()\n\n/**\n * What the session emits. Every `AudioDelta` and `OutputTranscriptDelta` is\n * bracketed by `ResponseStarted` and `ResponseDone` carrying the same\n * `responseId`.\n *\n * - `InputTranscript`: transcription of the user's own speech.\n * - `SpeechStarted` / `SpeechStopped`: sparse. OpenAI emits them, Gemini\n * does not.\n * - `Interrupted`: stop and flush playback now. Always precedes the\n * `ResponseDone { reason: \"interrupted\" }` for that response.\n * - `ToolCallCancelled`: calls of an interrupted response that will never be\n * answered.\n * - `ResumptionHandle`: Gemini only; pass it back as `request.resume`.\n * - `SessionEnding`: the connection is about to close on the server's terms.\n * - `Error`: non-fatal. A fatal error fails the stream instead.\n */\nexport type RealtimeEvent = Data.TaggedEnum<{\n ResponseStarted: { readonly responseId: string }\n AudioDelta: { readonly responseId: string; readonly bytes: Uint8Array }\n OutputTranscriptDelta: { readonly responseId: string; readonly text: string }\n InputTranscript: { readonly text: string; readonly final: boolean }\n SpeechStarted: {}\n SpeechStopped: {}\n ToolCall: { readonly responseId: string; readonly call: ToolCall }\n ToolCallCancelled: { readonly callIds: ReadonlyArray<string> }\n Interrupted: { readonly responseId: string }\n ResponseDone: {\n readonly responseId: string\n readonly reason: \"complete\" | \"interrupted\" | \"cancelled\" | \"error\"\n readonly usage?: Usage\n }\n ResumptionHandle: { readonly handle: string }\n SessionEnding: { readonly timeLeft?: Duration.Duration }\n Error: { readonly code?: string; readonly message: string }\n}>\n\nexport const RealtimeEvent = Data.taggedEnum<RealtimeEvent>()\n\n/**\n * Cross-provider session setup. Each adapter extends this, narrowing `model`\n * and adding its own knobs.\n */\nexport type CommonSessionRequest = {\n readonly model: string\n readonly instructions?: string\n readonly voiceId?: string\n /** `Toolkit.descriptors(toolkit)`. Immutable for the connection on Gemini. */\n readonly tools?: ReadonlyArray<ToolDescriptor>\n readonly inputFormat: AudioFormat\n readonly outputFormat: AudioFormat\n /** Who decides a turn ended. Defaults to `\"server\"`. */\n readonly turnDetection?: \"server\" | \"manual\"\n /** Transcribe the user's own audio. Defaults to `true`. */\n readonly transcribeInput?: boolean\n /** Text-only conversation seed. */\n readonly history?: ReadonlyArray<HistoryItem>\n /** A `ResumptionHandle` from a previous session. `Unsupported` off Gemini. */\n readonly resume?: string\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwCA,MAAa,gBAAgB,KAAK,WAA0B;AAsC5D,MAAa,gBAAgB,KAAK,WAA0B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Duration } from "effect";
|
|
1
|
+
import { Duration, Stream } from "effect";
|
|
2
2
|
declare namespace Transcript_d_exports {
|
|
3
|
-
export { TranscriptEvent, TranscriptResult, WordTimestamp, isAudioEvent, isError, isFinal, isMetadata, isPartial, isSpeechStarted, isUtteranceEnded };
|
|
3
|
+
export { AccumulatePartialsOptions, TranscriptEvent, TranscriptResult, WordTimestamp, accumulatePartials, isAudioEvent, isError, isFinal, isMetadata, isPartial, isSpeechStarted, isUtteranceEnded };
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
6
|
* Per-word timing + metadata. `confidence` and `speakerId` are optional
|
|
@@ -95,6 +95,20 @@ declare const isMetadata: (e: TranscriptEvent) => e is Extract<TranscriptEvent,
|
|
|
95
95
|
declare const isError: (e: TranscriptEvent) => e is Extract<TranscriptEvent, {
|
|
96
96
|
_tag: "error";
|
|
97
97
|
}>;
|
|
98
|
+
type AccumulatePartialsOptions = {
|
|
99
|
+
/** Silence after the last `partial` before the text so far is committed. */
|
|
100
|
+
readonly silence?: Duration.Input;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Join fragment `partial`s into the running hypothesis and commit it as a
|
|
104
|
+
* `final` after `silence`. For providers that stream token-sized deltas
|
|
105
|
+
* (OpenAI Realtime) or never segment; piping one that already accumulates
|
|
106
|
+
* repeats its text.
|
|
107
|
+
*
|
|
108
|
+
* Partials are forwarded as they arrive; only the synthetic `final` waits.
|
|
109
|
+
* A real `final` resets the accumulator, and the stream end flushes it.
|
|
110
|
+
*/
|
|
111
|
+
declare const accumulatePartials: (options?: AccumulatePartialsOptions) => <E, R>(self: Stream.Stream<TranscriptEvent, E, R>) => Stream.Stream<TranscriptEvent, E, R>;
|
|
98
112
|
//#endregion
|
|
99
|
-
export { TranscriptEvent, TranscriptResult, WordTimestamp, isAudioEvent, isError, isFinal, isMetadata, isPartial, isSpeechStarted, isUtteranceEnded, Transcript_d_exports as t };
|
|
113
|
+
export { AccumulatePartialsOptions, TranscriptEvent, TranscriptResult, WordTimestamp, accumulatePartials, isAudioEvent, isError, isFinal, isMetadata, isPartial, isSpeechStarted, isUtteranceEnded, Transcript_d_exports as t };
|
|
100
114
|
//# sourceMappingURL=Transcript.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transcript.d.mts","names":[],"sources":["../../src/domain/Transcript.ts"],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Transcript.d.mts","names":[],"sources":["../../src/domain/Transcript.ts"],"mappings":";;;;;;;;;;;;KAWY;WACD;WACA;WACA;WACA;WACA;WACA;;;;;;;KAQC;WACD;WACA;;WAEA,WAAW,SAAS;WACpB,QAAQ,cAAc;WACtB;;;;;;;;;;;;;;;;KAiBC;WAEG;WACA;WACA,QAAQ,cAAc;WACtB;;WAGA;WACA;WACA,QAAQ,cAAc;WACtB;;WAEA;WAAiC;;WACjC;WAAkC;;WAElC;WACA;WACA;WACA;;WAEA;WAA2B;;WAC3B;WAAwB;WAAwB;;cAElD,YAAS,GAAO,oBAAkB,KAAK,QAAQ;EAAmB;;cAElE,UAAO,GAAO,oBAAkB,KAAK,QAAQ;EAAmB;;cAEhE,kBAAe,GACvB,oBACF,KAAK,QAAQ;EAAmB;;cACtB,mBAAgB,GACxB,oBACF,KAAK,QAAQ;EAAmB;;cACtB,eAAY,GACpB,oBACF,KAAK,QAAQ;EAAmB;;cACtB,aAAU,GAClB,oBACF,KAAK,QAAQ;EAAmB;;cACtB,UAAO,GAAO,oBAAkB,KAAK,QAAQ;EAAmB;;KAGjE;;WAED,UAAU,SAAS;;;;;;;;;;;cAiBjB,qBAAkB,UAClB,+BACV,GAAG,GAAC,MAAQ,OAAO,OAAO,iBAAiB,GAAG,OAAK,OAAO,OAAO,iBAAiB,GAAG"}
|