@kernl-sdk/protocol 0.2.8 → 0.3.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +9 -0
- package/README.md +48 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/realtime/events.d.ts +313 -0
- package/dist/realtime/events.d.ts.map +1 -0
- package/dist/realtime/index.d.ts +4 -0
- package/dist/realtime/index.d.ts.map +1 -0
- package/dist/realtime/index.js +3 -0
- package/dist/realtime/model.d.ts +99 -0
- package/dist/realtime/model.d.ts.map +1 -0
- package/dist/realtime/types.d.ts +229 -0
- package/dist/realtime/types.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/realtime/events.ts +397 -0
- package/src/realtime/index.ts +3 -0
- package/src/realtime/model.ts +121 -0
- package/src/realtime/types.ts +276 -0
- package/.turbo/turbo-check-types.log +0 -4
- package/dist/codec.d.ts +0 -22
- package/dist/codec.d.ts.map +0 -1
- package/dist/embedding-model/embedding-model.d.ts +0 -57
- package/dist/embedding-model/embedding-model.d.ts.map +0 -1
- package/dist/embedding-model/embedding-model.js +0 -6
- package/dist/language-model/content.d.ts +0 -141
- package/dist/language-model/content.d.ts.map +0 -1
- package/dist/language-model/language-model.d.ts +0 -114
- package/dist/language-model/language-model.d.ts.map +0 -1
- package/dist/language-model/settings.d.ts +0 -99
- package/dist/language-model/settings.d.ts.map +0 -1
- package/dist/language-model/settings.js +0 -1
- package/dist/provider/metadata.d.ts +0 -21
- package/dist/provider/metadata.d.ts.map +0 -1
- package/dist/provider/metadata.js +0 -1
- /package/dist/{codec.js → realtime/events.js} +0 -0
- /package/dist/{language-model/content.js → realtime/model.js} +0 -0
- /package/dist/{language-model/language-model.js → realtime/types.js} +0 -0
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @kernl/protocol
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 572ae80: Add realtime voice agent support with memory capabilities.
|
|
8
|
+
- **protocol**: Add realtime model and event types for voice agents
|
|
9
|
+
- **kernl**: Extract BaseAgent class shared by Agent and RealtimeAgent, enabling memory support for realtime agents. Add `kind` discriminator for type narrowing.
|
|
10
|
+
- **openai**: Add OpenAI realtime voice provider with WebSocket-based streaming
|
|
11
|
+
|
|
3
12
|
## 0.2.8
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1 +1,49 @@
|
|
|
1
1
|
# kernl - Protocol Specification
|
|
2
|
+
|
|
3
|
+
## Realtime :: Protocol
|
|
4
|
+
|
|
5
|
+
### Client Events
|
|
6
|
+
|
|
7
|
+
| Event | Purpose | Key Fields |
|
|
8
|
+
|-----------------------|--------------------------------|------------------------------------------|
|
|
9
|
+
| session.update | Configure session | config: SessionConfig |
|
|
10
|
+
| item.create | Add item to conversation | item: LanguageModelItem, previousItemId? |
|
|
11
|
+
| item.delete | Remove item | itemId |
|
|
12
|
+
| item.truncate | Truncate assistant audio | itemId, audioEndMs |
|
|
13
|
+
| audio.input.append | Stream audio chunk to buffer | audio: string (base64) |
|
|
14
|
+
| audio.input.commit | Commit buffer as user message | — |
|
|
15
|
+
| audio.input.clear | Discard buffered audio | — |
|
|
16
|
+
| activity.start | User started speaking | — |
|
|
17
|
+
| activity.end | User stopped speaking | — |
|
|
18
|
+
| response.create | Trigger response (manual mode) | config?: ResponseConfig |
|
|
19
|
+
| response.cancel | Cancel in-progress response | responseId? |
|
|
20
|
+
|
|
21
|
+
### Server Events
|
|
22
|
+
|
|
23
|
+
| Event | Purpose | Key Fields |
|
|
24
|
+
|-----------------------------------|------------------------------|----------------------------|
|
|
25
|
+
| session.created | Session ready | session: Session |
|
|
26
|
+
| session.updated | Config updated | session: Session |
|
|
27
|
+
| session.error | Session error | error: Error |
|
|
28
|
+
| item.created | Item added | item: LanguageModelItem |
|
|
29
|
+
| item.deleted | Item removed | itemId |
|
|
30
|
+
| item.truncated | Audio truncated | itemId, audioEndMs |
|
|
31
|
+
| audio.input.committed | Buffer committed | itemId |
|
|
32
|
+
| audio.input.cleared | Buffer cleared | — |
|
|
33
|
+
| speech.started | VAD: speech detected | audioStartMs, itemId |
|
|
34
|
+
| speech.stopped | VAD: speech ended | audioEndMs, itemId |
|
|
35
|
+
| audio.output.delta | Agent audio chunk | responseId, itemId, delta |
|
|
36
|
+
| audio.output.done | Agent audio complete | responseId, itemId |
|
|
37
|
+
| text.output.delta | Agent text chunk | responseId, itemId, delta |
|
|
38
|
+
| text.output | Agent text complete | responseId, itemId, text |
|
|
39
|
+
| transcript.input.delta | User speech → text chunk | itemId, delta |
|
|
40
|
+
| transcript.input | User speech → text complete | itemId, text |
|
|
41
|
+
| transcript.output.delta | Agent speech → text chunk | responseId, itemId, delta |
|
|
42
|
+
| transcript.output | Agent speech → text complete | responseId, itemId, text |
|
|
43
|
+
| response.created | Response started | responseId |
|
|
44
|
+
| response.interrupted | Response interrupted | responseId |
|
|
45
|
+
| response.done | Response complete | responseId, status, usage |
|
|
46
|
+
| tool.start | Tool call started | responseId, callId, toolId |
|
|
47
|
+
| tool.delta | Tool arguments streaming | callId, delta |
|
|
48
|
+
| tool.call | Tool call ready | callId, toolId, arguments |
|
|
49
|
+
| tool.cancelled | Tool call cancelled | callId |
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
export * from "./constants.js";
|
|
7
7
|
export * from "./language-model/index.js";
|
|
8
8
|
export * from "./embedding-model/index.js";
|
|
9
|
+
export * from "./realtime/index.js";
|
|
9
10
|
export * from "./provider/index.js";
|
|
10
11
|
export * from "./json.js";
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { SharedProviderMetadata } from "../provider/index.js";
|
|
2
|
+
import { LanguageModelItem } from "../language-model/index.js";
|
|
3
|
+
import { RealtimeSession, RealtimeSessionConfig, RealtimeResponseConfig, RealtimeError, RealtimeUsage, ResponseStatus } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Base interface for all realtime events.
|
|
6
|
+
*/
|
|
7
|
+
export interface RealtimeEventBase {
|
|
8
|
+
/**
|
|
9
|
+
* Unique identifier for this event.
|
|
10
|
+
*/
|
|
11
|
+
id?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Provider-specific metadata.
|
|
14
|
+
*/
|
|
15
|
+
providerMetadata?: SharedProviderMetadata;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Union of all client → server events.
|
|
19
|
+
*/
|
|
20
|
+
export type RealtimeClientEvent = SessionUpdateEvent | ItemCreateEvent | ItemDeleteEvent | ItemTruncateEvent | AudioInputAppendEvent | AudioInputCommitEvent | AudioInputClearEvent | ActivityStartEvent | ActivityEndEvent | ResponseCreateEvent | ResponseCancelEvent | ToolResultEvent;
|
|
21
|
+
/**
|
|
22
|
+
* Union of all server → client events.
|
|
23
|
+
*/
|
|
24
|
+
export type RealtimeServerEvent = SessionCreatedEvent | SessionUpdatedEvent | SessionErrorEvent | ItemCreatedEvent | ItemDeletedEvent | ItemTruncatedEvent | AudioInputCommittedEvent | AudioInputClearedEvent | SpeechStartedEvent | SpeechStoppedEvent | AudioOutputDeltaEvent | AudioOutputDoneEvent | TextOutputDeltaEvent | TextOutputEvent | TranscriptInputDeltaEvent | TranscriptInputEvent | TranscriptOutputDeltaEvent | TranscriptOutputEvent | ResponseCreatedEvent | ResponseInterruptedEvent | ResponseDoneEvent | ToolStartEvent | ToolDeltaEvent | ToolCallEvent | ToolCancelledEvent;
|
|
25
|
+
/**
|
|
26
|
+
* Client event to update session configuration.
|
|
27
|
+
*/
|
|
28
|
+
export interface SessionUpdateEvent extends RealtimeEventBase {
|
|
29
|
+
readonly kind: "session.update";
|
|
30
|
+
config: RealtimeSessionConfig;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Client event to add an item to the conversation.
|
|
34
|
+
*/
|
|
35
|
+
export interface ItemCreateEvent extends RealtimeEventBase {
|
|
36
|
+
readonly kind: "item.create";
|
|
37
|
+
item: LanguageModelItem;
|
|
38
|
+
previousItemId?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Client event to delete an item from the conversation.
|
|
42
|
+
*/
|
|
43
|
+
export interface ItemDeleteEvent extends RealtimeEventBase {
|
|
44
|
+
readonly kind: "item.delete";
|
|
45
|
+
itemId: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Client event to truncate assistant audio at a specific timestamp.
|
|
49
|
+
*/
|
|
50
|
+
export interface ItemTruncateEvent extends RealtimeEventBase {
|
|
51
|
+
readonly kind: "item.truncate";
|
|
52
|
+
itemId: string;
|
|
53
|
+
audioEndMs: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Client event to append audio to the input buffer.
|
|
57
|
+
*/
|
|
58
|
+
export interface AudioInputAppendEvent extends RealtimeEventBase {
|
|
59
|
+
readonly kind: "audio.input.append";
|
|
60
|
+
/**
|
|
61
|
+
* Base64-encoded audio data.
|
|
62
|
+
*/
|
|
63
|
+
audio: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Client event to commit the audio input buffer as a user message.
|
|
67
|
+
*/
|
|
68
|
+
export interface AudioInputCommitEvent extends RealtimeEventBase {
|
|
69
|
+
readonly kind: "audio.input.commit";
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Client event to clear the audio input buffer.
|
|
73
|
+
*/
|
|
74
|
+
export interface AudioInputClearEvent extends RealtimeEventBase {
|
|
75
|
+
readonly kind: "audio.input.clear";
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Client event to signal start of user activity (manual VAD).
|
|
79
|
+
*/
|
|
80
|
+
export interface ActivityStartEvent extends RealtimeEventBase {
|
|
81
|
+
readonly kind: "activity.start";
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Client event to signal end of user activity (manual VAD).
|
|
85
|
+
*/
|
|
86
|
+
export interface ActivityEndEvent extends RealtimeEventBase {
|
|
87
|
+
readonly kind: "activity.end";
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Client event to trigger a model response.
|
|
91
|
+
*/
|
|
92
|
+
export interface ResponseCreateEvent extends RealtimeEventBase {
|
|
93
|
+
readonly kind: "response.create";
|
|
94
|
+
config?: RealtimeResponseConfig;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Client event to cancel an in-progress response.
|
|
98
|
+
*/
|
|
99
|
+
export interface ResponseCancelEvent extends RealtimeEventBase {
|
|
100
|
+
readonly kind: "response.cancel";
|
|
101
|
+
responseId?: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Server event indicating the session has been created.
|
|
105
|
+
*/
|
|
106
|
+
export interface SessionCreatedEvent extends RealtimeEventBase {
|
|
107
|
+
readonly kind: "session.created";
|
|
108
|
+
session: RealtimeSession;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Server event indicating the session configuration has been updated.
|
|
112
|
+
*/
|
|
113
|
+
export interface SessionUpdatedEvent extends RealtimeEventBase {
|
|
114
|
+
readonly kind: "session.updated";
|
|
115
|
+
session: RealtimeSession;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Server event indicating a session error.
|
|
119
|
+
*/
|
|
120
|
+
export interface SessionErrorEvent extends RealtimeEventBase {
|
|
121
|
+
readonly kind: "session.error";
|
|
122
|
+
error: RealtimeError;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Server event indicating an item has been added to the conversation.
|
|
126
|
+
*/
|
|
127
|
+
export interface ItemCreatedEvent extends RealtimeEventBase {
|
|
128
|
+
readonly kind: "item.created";
|
|
129
|
+
item: LanguageModelItem;
|
|
130
|
+
previousItemId?: string;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Server event indicating an item has been deleted.
|
|
134
|
+
*/
|
|
135
|
+
export interface ItemDeletedEvent extends RealtimeEventBase {
|
|
136
|
+
readonly kind: "item.deleted";
|
|
137
|
+
itemId: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Server event indicating an item has been truncated.
|
|
141
|
+
*/
|
|
142
|
+
export interface ItemTruncatedEvent extends RealtimeEventBase {
|
|
143
|
+
readonly kind: "item.truncated";
|
|
144
|
+
itemId: string;
|
|
145
|
+
audioEndMs: number;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Server event confirming the audio input buffer has been committed.
|
|
149
|
+
*/
|
|
150
|
+
export interface AudioInputCommittedEvent extends RealtimeEventBase {
|
|
151
|
+
readonly kind: "audio.input.committed";
|
|
152
|
+
itemId: string;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Server event confirming the audio input buffer has been cleared.
|
|
156
|
+
*/
|
|
157
|
+
export interface AudioInputClearedEvent extends RealtimeEventBase {
|
|
158
|
+
readonly kind: "audio.input.cleared";
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Server event indicating speech has been detected (VAD).
|
|
162
|
+
*/
|
|
163
|
+
export interface SpeechStartedEvent extends RealtimeEventBase {
|
|
164
|
+
readonly kind: "speech.started";
|
|
165
|
+
audioStartMs: number;
|
|
166
|
+
itemId: string;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Server event indicating speech has stopped (VAD).
|
|
170
|
+
*/
|
|
171
|
+
export interface SpeechStoppedEvent extends RealtimeEventBase {
|
|
172
|
+
readonly kind: "speech.stopped";
|
|
173
|
+
audioEndMs: number;
|
|
174
|
+
itemId: string;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Server event containing an audio output chunk.
|
|
178
|
+
*/
|
|
179
|
+
export interface AudioOutputDeltaEvent extends RealtimeEventBase {
|
|
180
|
+
readonly kind: "audio.output.delta";
|
|
181
|
+
responseId: string;
|
|
182
|
+
itemId: string;
|
|
183
|
+
/**
|
|
184
|
+
* Base64-encoded audio chunk.
|
|
185
|
+
*/
|
|
186
|
+
audio: string;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Server event indicating audio output is complete.
|
|
190
|
+
*/
|
|
191
|
+
export interface AudioOutputDoneEvent extends RealtimeEventBase {
|
|
192
|
+
readonly kind: "audio.output.done";
|
|
193
|
+
responseId: string;
|
|
194
|
+
itemId: string;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Server event containing a text output chunk.
|
|
198
|
+
*/
|
|
199
|
+
export interface TextOutputDeltaEvent extends RealtimeEventBase {
|
|
200
|
+
readonly kind: "text.output.delta";
|
|
201
|
+
responseId: string;
|
|
202
|
+
itemId: string;
|
|
203
|
+
delta: string;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Server event containing the complete text output.
|
|
207
|
+
*/
|
|
208
|
+
export interface TextOutputEvent extends RealtimeEventBase {
|
|
209
|
+
readonly kind: "text.output";
|
|
210
|
+
responseId: string;
|
|
211
|
+
itemId: string;
|
|
212
|
+
text: string;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Server event containing an input transcription chunk.
|
|
216
|
+
*/
|
|
217
|
+
export interface TranscriptInputDeltaEvent extends RealtimeEventBase {
|
|
218
|
+
readonly kind: "transcript.input.delta";
|
|
219
|
+
itemId: string;
|
|
220
|
+
delta: string;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Server event containing the complete input transcription.
|
|
224
|
+
*/
|
|
225
|
+
export interface TranscriptInputEvent extends RealtimeEventBase {
|
|
226
|
+
readonly kind: "transcript.input";
|
|
227
|
+
itemId: string;
|
|
228
|
+
text: string;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Server event containing an output transcription chunk.
|
|
232
|
+
*/
|
|
233
|
+
export interface TranscriptOutputDeltaEvent extends RealtimeEventBase {
|
|
234
|
+
readonly kind: "transcript.output.delta";
|
|
235
|
+
responseId: string;
|
|
236
|
+
itemId: string;
|
|
237
|
+
delta: string;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Server event containing the complete output transcription.
|
|
241
|
+
*/
|
|
242
|
+
export interface TranscriptOutputEvent extends RealtimeEventBase {
|
|
243
|
+
readonly kind: "transcript.output";
|
|
244
|
+
responseId: string;
|
|
245
|
+
itemId: string;
|
|
246
|
+
text: string;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Server event indicating a response has been created.
|
|
250
|
+
*/
|
|
251
|
+
export interface ResponseCreatedEvent extends RealtimeEventBase {
|
|
252
|
+
readonly kind: "response.created";
|
|
253
|
+
responseId: string;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Server event indicating a response has been interrupted.
|
|
257
|
+
*/
|
|
258
|
+
export interface ResponseInterruptedEvent extends RealtimeEventBase {
|
|
259
|
+
readonly kind: "response.interrupted";
|
|
260
|
+
responseId: string;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Server event indicating a response is complete.
|
|
264
|
+
*/
|
|
265
|
+
export interface ResponseDoneEvent extends RealtimeEventBase {
|
|
266
|
+
readonly kind: "response.done";
|
|
267
|
+
responseId: string;
|
|
268
|
+
status: ResponseStatus;
|
|
269
|
+
usage?: RealtimeUsage;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Server event indicating a tool call has started.
|
|
273
|
+
*/
|
|
274
|
+
export interface ToolStartEvent extends RealtimeEventBase {
|
|
275
|
+
readonly kind: "tool.start";
|
|
276
|
+
responseId: string;
|
|
277
|
+
callId: string;
|
|
278
|
+
toolId: string;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Server event containing a tool call arguments chunk.
|
|
282
|
+
*/
|
|
283
|
+
export interface ToolDeltaEvent extends RealtimeEventBase {
|
|
284
|
+
readonly kind: "tool.delta";
|
|
285
|
+
callId: string;
|
|
286
|
+
delta: string;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Server event indicating the model wants to call a tool.
|
|
290
|
+
*/
|
|
291
|
+
export interface ToolCallEvent extends RealtimeEventBase {
|
|
292
|
+
readonly kind: "tool.call";
|
|
293
|
+
callId: string;
|
|
294
|
+
toolId: string;
|
|
295
|
+
arguments: string;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Server event indicating a tool call has been cancelled.
|
|
299
|
+
*/
|
|
300
|
+
export interface ToolCancelledEvent extends RealtimeEventBase {
|
|
301
|
+
readonly kind: "tool.cancelled";
|
|
302
|
+
callId: string;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Client event to submit a tool result.
|
|
306
|
+
*/
|
|
307
|
+
export interface ToolResultEvent extends RealtimeEventBase {
|
|
308
|
+
readonly kind: "tool.result";
|
|
309
|
+
callId: string;
|
|
310
|
+
result?: string;
|
|
311
|
+
error?: string;
|
|
312
|
+
}
|
|
313
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/realtime/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,aAAa,EACb,aAAa,EACb,cAAc,EACf,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAC3B,kBAAkB,GAClB,eAAe,GACf,eAAe,GACf,iBAAiB,GACjB,qBAAqB,GACrB,qBAAqB,GACrB,oBAAoB,GACpB,kBAAkB,GAClB,gBAAgB,GAChB,mBAAmB,GACnB,mBAAmB,GACnB,eAAe,CAAC;AAEpB;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAC3B,mBAAmB,GACnB,mBAAmB,GACnB,iBAAiB,GACjB,gBAAgB,GAChB,gBAAgB,GAChB,kBAAkB,GAClB,wBAAwB,GACxB,sBAAsB,GACtB,kBAAkB,GAClB,kBAAkB,GAClB,qBAAqB,GACrB,oBAAoB,GACpB,oBAAoB,GACpB,eAAe,GACf,yBAAyB,GACzB,oBAAoB,GACpB,0BAA0B,GAC1B,qBAAqB,GACrB,oBAAoB,GACpB,wBAAwB,GACxB,iBAAiB,GACjB,cAAc,GACd,cAAc,GACd,aAAa,GACb,kBAAkB,CAAC;AAEvB;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,MAAM,EAAE,qBAAqB,CAAC;CAC/B;AAED;;GAEG;AACH,MAA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AiB;IACvD,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,iBAAiB;IACtD,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;IACxD,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/realtime/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { SharedProviderMetadata } from "../provider/index.js";
|
|
2
|
+
import { RealtimeClientEvent, RealtimeServerEvent } from "./events.js";
|
|
3
|
+
import { RealtimeConnectOptions, TransportStatus } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* A realtime model that can establish bidirectional streaming connections.
|
|
6
|
+
*
|
|
7
|
+
* Models are reusable - each call to connect() creates a new connection.
|
|
8
|
+
* Providers implement this interface.
|
|
9
|
+
*/
|
|
10
|
+
export interface RealtimeModel {
|
|
11
|
+
/**
|
|
12
|
+
* The realtime model spec version.
|
|
13
|
+
*/
|
|
14
|
+
readonly spec: "1.0";
|
|
15
|
+
/**
|
|
16
|
+
* Provider ID (e.g., "openai", "google", "elevenlabs").
|
|
17
|
+
*/
|
|
18
|
+
readonly provider: string;
|
|
19
|
+
/**
|
|
20
|
+
* Model ID (e.g., "gpt-4o-realtime", "gemini-2.0-flash").
|
|
21
|
+
*/
|
|
22
|
+
readonly modelId: string;
|
|
23
|
+
/**
|
|
24
|
+
* Establish a connection and return a connection instance.
|
|
25
|
+
*/
|
|
26
|
+
connect(options?: RealtimeConnectOptions): Promise<RealtimeConnection>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* An active bidirectional connection to a realtime model.
|
|
30
|
+
*
|
|
31
|
+
* One connection per session. Providers implement this interface.
|
|
32
|
+
*/
|
|
33
|
+
export interface RealtimeConnection {
|
|
34
|
+
/**
|
|
35
|
+
* Current connection status.
|
|
36
|
+
*/
|
|
37
|
+
readonly status: TransportStatus;
|
|
38
|
+
/**
|
|
39
|
+
* Whether input audio is muted.
|
|
40
|
+
* null if muting is not handled by the connection.
|
|
41
|
+
*/
|
|
42
|
+
readonly muted: boolean | null;
|
|
43
|
+
/**
|
|
44
|
+
* Session ID once connected.
|
|
45
|
+
*/
|
|
46
|
+
readonly sessionId: string | null;
|
|
47
|
+
/**
|
|
48
|
+
* Provider-specific metadata.
|
|
49
|
+
*/
|
|
50
|
+
readonly providerMetadata?: SharedProviderMetadata;
|
|
51
|
+
/**
|
|
52
|
+
* Send a client event to the model.
|
|
53
|
+
*/
|
|
54
|
+
send(event: RealtimeClientEvent): void;
|
|
55
|
+
/**
|
|
56
|
+
* Close the connection.
|
|
57
|
+
*/
|
|
58
|
+
close(): void;
|
|
59
|
+
/**
|
|
60
|
+
* Mute input audio.
|
|
61
|
+
*/
|
|
62
|
+
mute(): void;
|
|
63
|
+
/**
|
|
64
|
+
* Unmute input audio.
|
|
65
|
+
*/
|
|
66
|
+
unmute(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Interrupt the current response.
|
|
69
|
+
* Convenience for sending response.cancel event.
|
|
70
|
+
*/
|
|
71
|
+
interrupt(): void;
|
|
72
|
+
on(event: "event", listener: (event: RealtimeServerEvent) => void): this;
|
|
73
|
+
on(event: "status", listener: (status: TransportStatus) => void): this;
|
|
74
|
+
on(event: "error", listener: (error: Error) => void): this;
|
|
75
|
+
off(event: "event", listener: (event: RealtimeServerEvent) => void): this;
|
|
76
|
+
off(event: "status", listener: (status: TransportStatus) => void): this;
|
|
77
|
+
off(event: "error", listener: (error: Error) => void): this;
|
|
78
|
+
once(event: "event", listener: (event: RealtimeServerEvent) => void): this;
|
|
79
|
+
once(event: "status", listener: (status: TransportStatus) => void): this;
|
|
80
|
+
once(event: "error", listener: (error: Error) => void): this;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* A transport factory for custom connection mechanisms (e.g., WebRTC).
|
|
84
|
+
*
|
|
85
|
+
* Pass to RealtimeSession when you need to handle audio via media tracks
|
|
86
|
+
* instead of base64 events.
|
|
87
|
+
*/
|
|
88
|
+
export interface RealtimeTransport {
|
|
89
|
+
/**
|
|
90
|
+
* Whether this transport handles audio I/O internally (e.g., WebRTC).
|
|
91
|
+
* If true, cannot use a channel with this transport.
|
|
92
|
+
*/
|
|
93
|
+
readonly handlesAudio: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Create a connection using this transport.
|
|
96
|
+
*/
|
|
97
|
+
connect(model: RealtimeModel, options?: RealtimeConnectOptions): Promise<RealtimeConnection>;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/realtime/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,SAAS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