@kernl-sdk/protocol 0.2.8 → 0.3.1
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 +16 -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 +2 -2
- 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
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { SharedProviderMetadata } from "@/provider";
|
|
2
|
+
import { RealtimeClientEvent, RealtimeServerEvent } from "./events";
|
|
3
|
+
import { RealtimeConnectOptions, TransportStatus } from "./types";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A realtime model that can establish bidirectional streaming connections.
|
|
7
|
+
*
|
|
8
|
+
* Models are reusable - each call to connect() creates a new connection.
|
|
9
|
+
* Providers implement this interface.
|
|
10
|
+
*/
|
|
11
|
+
export interface RealtimeModel {
|
|
12
|
+
/**
|
|
13
|
+
* The realtime model spec version.
|
|
14
|
+
*/
|
|
15
|
+
readonly spec: "1.0";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Provider ID (e.g., "openai", "google", "elevenlabs").
|
|
19
|
+
*/
|
|
20
|
+
readonly provider: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Model ID (e.g., "gpt-4o-realtime", "gemini-2.0-flash").
|
|
24
|
+
*/
|
|
25
|
+
readonly modelId: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Establish a connection and return a connection instance.
|
|
29
|
+
*/
|
|
30
|
+
connect(options?: RealtimeConnectOptions): Promise<RealtimeConnection>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* An active bidirectional connection to a realtime model.
|
|
35
|
+
*
|
|
36
|
+
* One connection per session. Providers implement this interface.
|
|
37
|
+
*/
|
|
38
|
+
export interface RealtimeConnection {
|
|
39
|
+
/**
|
|
40
|
+
* Current connection status.
|
|
41
|
+
*/
|
|
42
|
+
readonly status: TransportStatus;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Whether input audio is muted.
|
|
46
|
+
* null if muting is not handled by the connection.
|
|
47
|
+
*/
|
|
48
|
+
readonly muted: boolean | null;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Session ID once connected.
|
|
52
|
+
*/
|
|
53
|
+
readonly sessionId: string | null;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Provider-specific metadata.
|
|
57
|
+
*/
|
|
58
|
+
readonly providerMetadata?: SharedProviderMetadata;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Send a client event to the model.
|
|
62
|
+
*/
|
|
63
|
+
send(event: RealtimeClientEvent): void;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Close the connection.
|
|
67
|
+
*/
|
|
68
|
+
close(): void;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Mute input audio.
|
|
72
|
+
*/
|
|
73
|
+
mute(): void;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Unmute input audio.
|
|
77
|
+
*/
|
|
78
|
+
unmute(): void;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Interrupt the current response.
|
|
82
|
+
* Convenience for sending response.cancel event.
|
|
83
|
+
*/
|
|
84
|
+
interrupt(): void;
|
|
85
|
+
|
|
86
|
+
// --- event subscription ---
|
|
87
|
+
|
|
88
|
+
on(event: "event", listener: (event: RealtimeServerEvent) => void): this;
|
|
89
|
+
on(event: "status", listener: (status: TransportStatus) => void): this;
|
|
90
|
+
on(event: "error", listener: (error: Error) => void): this;
|
|
91
|
+
|
|
92
|
+
off(event: "event", listener: (event: RealtimeServerEvent) => void): this;
|
|
93
|
+
off(event: "status", listener: (status: TransportStatus) => void): this;
|
|
94
|
+
off(event: "error", listener: (error: Error) => void): this;
|
|
95
|
+
|
|
96
|
+
once(event: "event", listener: (event: RealtimeServerEvent) => void): this;
|
|
97
|
+
once(event: "status", listener: (status: TransportStatus) => void): this;
|
|
98
|
+
once(event: "error", listener: (error: Error) => void): this;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* A transport factory for custom connection mechanisms (e.g., WebRTC).
|
|
103
|
+
*
|
|
104
|
+
* Pass to RealtimeSession when you need to handle audio via media tracks
|
|
105
|
+
* instead of base64 events.
|
|
106
|
+
*/
|
|
107
|
+
export interface RealtimeTransport {
|
|
108
|
+
/**
|
|
109
|
+
* Whether this transport handles audio I/O internally (e.g., WebRTC).
|
|
110
|
+
* If true, cannot use a channel with this transport.
|
|
111
|
+
*/
|
|
112
|
+
readonly handlesAudio: boolean;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Create a connection using this transport.
|
|
116
|
+
*/
|
|
117
|
+
connect(
|
|
118
|
+
model: RealtimeModel,
|
|
119
|
+
options?: RealtimeConnectOptions,
|
|
120
|
+
): Promise<RealtimeConnection>;
|
|
121
|
+
}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { SharedProviderOptions } from "@/provider";
|
|
2
|
+
import { LanguageModelTool } from "@/language-model";
|
|
3
|
+
|
|
4
|
+
export interface RealtimeConnectOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Initial session configuration.
|
|
7
|
+
*/
|
|
8
|
+
sessionConfig?: RealtimeSessionConfig;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Resume a previous session.
|
|
12
|
+
*/
|
|
13
|
+
resume?: SessionResumeConfig;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Abort signal for cancelling connection.
|
|
17
|
+
*/
|
|
18
|
+
abort?: AbortSignal;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Provider-specific options.
|
|
22
|
+
*/
|
|
23
|
+
providerOptions?: SharedProviderOptions;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Configuration for a realtime session.
|
|
28
|
+
*/
|
|
29
|
+
export interface RealtimeSessionConfig {
|
|
30
|
+
/**
|
|
31
|
+
* System instructions for the model.
|
|
32
|
+
*/
|
|
33
|
+
instructions?: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Available tools the model can call.
|
|
37
|
+
*/
|
|
38
|
+
tools?: LanguageModelTool[];
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Tool choice behavior.
|
|
42
|
+
*/
|
|
43
|
+
toolChoice?: RealtimeToolChoice;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Output modalities (text, audio, or both).
|
|
47
|
+
*/
|
|
48
|
+
modalities?: RealtimeModality[];
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Voice configuration for audio output.
|
|
52
|
+
*/
|
|
53
|
+
voice?: VoiceConfig;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Audio format configuration.
|
|
57
|
+
*/
|
|
58
|
+
audio?: AudioConfig;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Turn detection / VAD configuration.
|
|
62
|
+
*/
|
|
63
|
+
turnDetection?: TurnDetectionConfig;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Provider-specific options.
|
|
67
|
+
*/
|
|
68
|
+
providerOptions?: SharedProviderOptions;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Output modality for realtime sessions.
|
|
73
|
+
*/
|
|
74
|
+
export type RealtimeModality = "text" | "audio";
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Tool choice behavior for realtime sessions.
|
|
78
|
+
*/
|
|
79
|
+
export type RealtimeToolChoice =
|
|
80
|
+
| { kind: "auto" }
|
|
81
|
+
| { kind: "none" }
|
|
82
|
+
| { kind: "required" };
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Voice configuration for audio output.
|
|
86
|
+
*/
|
|
87
|
+
export interface VoiceConfig {
|
|
88
|
+
/**
|
|
89
|
+
* Voice ID (provider-specific).
|
|
90
|
+
*/
|
|
91
|
+
voiceId: string;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Playback speed multiplier.
|
|
95
|
+
*/
|
|
96
|
+
speed?: number;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Audio format configuration for input and output.
|
|
101
|
+
*/
|
|
102
|
+
export interface AudioConfig {
|
|
103
|
+
/**
|
|
104
|
+
* Input audio format.
|
|
105
|
+
*/
|
|
106
|
+
inputFormat?: AudioFormat;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Output audio format.
|
|
110
|
+
*/
|
|
111
|
+
outputFormat?: AudioFormat;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Audio format specification.
|
|
116
|
+
*/
|
|
117
|
+
export interface AudioFormat {
|
|
118
|
+
/**
|
|
119
|
+
* MIME type (e.g., "audio/pcm", "audio/wav").
|
|
120
|
+
*/
|
|
121
|
+
mimeType: string;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Sample rate in Hz.
|
|
125
|
+
*/
|
|
126
|
+
sampleRate?: number;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Bits per sample.
|
|
130
|
+
*/
|
|
131
|
+
bitDepth?: number;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Number of channels.
|
|
135
|
+
*/
|
|
136
|
+
channels?: number;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Turn detection / VAD configuration.
|
|
141
|
+
*/
|
|
142
|
+
export interface TurnDetectionConfig {
|
|
143
|
+
/**
|
|
144
|
+
* Detection mode.
|
|
145
|
+
*/
|
|
146
|
+
mode: "server_vad" | "manual";
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* VAD threshold (0-1).
|
|
150
|
+
*/
|
|
151
|
+
threshold?: number;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Silence duration to trigger end of speech (ms).
|
|
155
|
+
*/
|
|
156
|
+
silenceDurationMs?: number;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Audio to include before speech start (ms).
|
|
160
|
+
*/
|
|
161
|
+
prefixPaddingMs?: number;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Auto-create response on speech end.
|
|
165
|
+
*/
|
|
166
|
+
createResponse?: boolean;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Allow interruption of ongoing response.
|
|
170
|
+
*/
|
|
171
|
+
interruptResponse?: boolean;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Configuration for resuming a previous session.
|
|
176
|
+
*/
|
|
177
|
+
export interface SessionResumeConfig {
|
|
178
|
+
/**
|
|
179
|
+
* Handle from a previous session.
|
|
180
|
+
*/
|
|
181
|
+
handle: string;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Configuration for creating a response (for response.create event).
|
|
186
|
+
*/
|
|
187
|
+
export interface RealtimeResponseConfig {
|
|
188
|
+
/**
|
|
189
|
+
* Override session instructions for this response.
|
|
190
|
+
*/
|
|
191
|
+
instructions?: string;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Override tools for this response.
|
|
195
|
+
*/
|
|
196
|
+
tools?: LanguageModelTool[];
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Override modalities for this response.
|
|
200
|
+
*/
|
|
201
|
+
modalities?: RealtimeModality[];
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* A realtime session as returned from the server.
|
|
206
|
+
*/
|
|
207
|
+
export interface RealtimeSession {
|
|
208
|
+
/**
|
|
209
|
+
* Unique session identifier.
|
|
210
|
+
*/
|
|
211
|
+
id: string;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Current session configuration.
|
|
215
|
+
*/
|
|
216
|
+
config: RealtimeSessionConfig;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Error from a realtime session.
|
|
221
|
+
*/
|
|
222
|
+
export interface RealtimeError {
|
|
223
|
+
/**
|
|
224
|
+
* Error code.
|
|
225
|
+
*/
|
|
226
|
+
code: string;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Human-readable error message.
|
|
230
|
+
*/
|
|
231
|
+
message: string;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Additional error details.
|
|
235
|
+
*/
|
|
236
|
+
details?: Record<string, unknown>;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Token usage information for a response.
|
|
241
|
+
*/
|
|
242
|
+
export interface RealtimeUsage {
|
|
243
|
+
/**
|
|
244
|
+
* Number of input tokens.
|
|
245
|
+
*/
|
|
246
|
+
inputTokens?: number;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Number of output tokens.
|
|
250
|
+
*/
|
|
251
|
+
outputTokens?: number;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Total number of tokens.
|
|
255
|
+
*/
|
|
256
|
+
totalTokens?: number;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Status of a response.
|
|
261
|
+
*/
|
|
262
|
+
export type ResponseStatus =
|
|
263
|
+
| "completed"
|
|
264
|
+
| "interrupted"
|
|
265
|
+
| "cancelled"
|
|
266
|
+
| "failed";
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Status of a realtime transport connection.
|
|
270
|
+
*/
|
|
271
|
+
export type TransportStatus =
|
|
272
|
+
| "disconnected"
|
|
273
|
+
| "connecting"
|
|
274
|
+
| "connected"
|
|
275
|
+
| "reconnecting"
|
|
276
|
+
| "closed";
|
package/dist/codec.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bidirectional codec for converting between kernl protocol types and provider-specific types.
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* ```typescript
|
|
6
|
-
* const tools: Codec<LanguageModelTool[], ProviderTool[]> = {
|
|
7
|
-
* encode: (tools: Tool[]) => tools.map(convertToProvider),
|
|
8
|
-
* decode: () => { throw new Error("codec:unimplemented"); },
|
|
9
|
-
* };
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
export interface Codec<TKernl, TProvider> {
|
|
13
|
-
/**
|
|
14
|
-
* Transform from kernl protocol format to provider format.
|
|
15
|
-
*/
|
|
16
|
-
encode: (value: TKernl) => TProvider;
|
|
17
|
-
/**
|
|
18
|
-
* Transform from provider format to kernl protocol format.
|
|
19
|
-
*/
|
|
20
|
-
decode: (value: TProvider) => TKernl;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=codec.d.ts.map
|
package/dist/codec.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,WAAW,KAAK,CAAC,MAAM,EAAE,SAAS;IACtC;;OAEG;IACH,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC;IAErC;;OAEG;IACH,MAAM,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,MAAM,CAAC;CACtC"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Embedding Model Protocol
|
|
3
|
-
*
|
|
4
|
-
* Defines the standard interface for embedding model providers in Kernl.
|
|
5
|
-
*/
|
|
6
|
-
import { Usage } from "../language-model/index.js";
|
|
7
|
-
/**
|
|
8
|
-
* A request to an embedding model.
|
|
9
|
-
*/
|
|
10
|
-
export interface EmbeddingRequest {
|
|
11
|
-
/**
|
|
12
|
-
* The input text(s) to embed.
|
|
13
|
-
* Can be a single string or an array of strings.
|
|
14
|
-
*/
|
|
15
|
-
input: string | string[];
|
|
16
|
-
/**
|
|
17
|
-
* The number of dimensions for the embeddings.
|
|
18
|
-
* Optional - defaults to the model's default dimensionality.
|
|
19
|
-
*/
|
|
20
|
-
dimensions?: number;
|
|
21
|
-
/**
|
|
22
|
-
* Additional provider-specific options.
|
|
23
|
-
*/
|
|
24
|
-
providerData?: Record<string, any>;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* The response from an embedding model.
|
|
28
|
-
*/
|
|
29
|
-
export interface EmbeddingResponse {
|
|
30
|
-
/**
|
|
31
|
-
* The generated embeddings.
|
|
32
|
-
* Each embedding is an array of numbers (the embedding vector).
|
|
33
|
-
*/
|
|
34
|
-
embeddings: number[][];
|
|
35
|
-
/**
|
|
36
|
-
* The usage information for the embedding request.
|
|
37
|
-
*/
|
|
38
|
-
usage: Usage;
|
|
39
|
-
/**
|
|
40
|
-
* Raw response data from the underlying model provider.
|
|
41
|
-
*/
|
|
42
|
-
providerData?: Record<string, any>;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* The base interface for calling an embedding model.
|
|
46
|
-
*
|
|
47
|
-
* All embedding model providers must implement this interface.
|
|
48
|
-
*/
|
|
49
|
-
export interface EmbeddingModel {
|
|
50
|
-
/**
|
|
51
|
-
* Generate embeddings for the given input.
|
|
52
|
-
*
|
|
53
|
-
* @param request - The embedding request.
|
|
54
|
-
*/
|
|
55
|
-
embed(request: EmbeddingRequest): Promise<EmbeddingResponse>;
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=embedding-model.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"embedding-model.d.ts","sourceRoot":"","sources":["../../src/embedding-model/embedding-model.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAM1C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAEzB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC;IAEvB;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;IAEb;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACpC;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,KAAK,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC9D"}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { SharedProviderMetadata } from "../provider/metadata.js";
|
|
2
|
-
import { JSONValue } from "../json.js";
|
|
3
|
-
export type LanguageModelContent = LanguageModelText | LanguageModelReasoning | LanguageModelFile | LanguageModelSource | LanguageModelToolCall | LanguageModelToolResult;
|
|
4
|
-
/**
|
|
5
|
-
* Text that the model has generated.
|
|
6
|
-
*/
|
|
7
|
-
export type LanguageModelText = {
|
|
8
|
-
kind: "text";
|
|
9
|
-
/**
|
|
10
|
-
* The text content.
|
|
11
|
-
*/
|
|
12
|
-
text: string;
|
|
13
|
-
/**
|
|
14
|
-
* Optional provider-specific metadata for the text part.
|
|
15
|
-
*/
|
|
16
|
-
providerMetadata?: SharedProviderMetadata;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Reasoning that the model has generated.
|
|
20
|
-
*/
|
|
21
|
-
export type LanguageModelReasoning = {
|
|
22
|
-
kind: "reasoning";
|
|
23
|
-
/**
|
|
24
|
-
* The reasoning content
|
|
25
|
-
*/
|
|
26
|
-
text: string;
|
|
27
|
-
/**
|
|
28
|
-
* Optional provider-specific metadata for the reasoning part.
|
|
29
|
-
*/
|
|
30
|
-
providerMetadata?: SharedProviderMetadata;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* A file that has been generated by the model.
|
|
34
|
-
*
|
|
35
|
-
* May be base64 encoded strings or binary data.
|
|
36
|
-
*/
|
|
37
|
-
export type LanguageModelFile = {
|
|
38
|
-
kind: "file";
|
|
39
|
-
/**
|
|
40
|
-
* The IANA media type of the file, e.g. `image/png` or `audio/mp3`.
|
|
41
|
-
*
|
|
42
|
-
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
43
|
-
*/
|
|
44
|
-
mime: string;
|
|
45
|
-
/**
|
|
46
|
-
* Generated file data as base64 encoded strings or binary data.
|
|
47
|
-
*/
|
|
48
|
-
data: string | Uint8Array;
|
|
49
|
-
/**
|
|
50
|
-
* Optional filename for the file
|
|
51
|
-
*/
|
|
52
|
-
filename?: string;
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* A source that has been used as input to generate the response.
|
|
56
|
-
*/
|
|
57
|
-
export type LanguageModelSource = {
|
|
58
|
-
kind: "source";
|
|
59
|
-
/**
|
|
60
|
-
* The ID of the source.
|
|
61
|
-
*/
|
|
62
|
-
id: string;
|
|
63
|
-
/**
|
|
64
|
-
* The URI of the source.
|
|
65
|
-
*/
|
|
66
|
-
uri: string;
|
|
67
|
-
/**
|
|
68
|
-
* IANA media type of the document (e.g., 'application/pdf').
|
|
69
|
-
*/
|
|
70
|
-
mime: string;
|
|
71
|
-
/**
|
|
72
|
-
* The title of the source.
|
|
73
|
-
*/
|
|
74
|
-
title?: string;
|
|
75
|
-
/**
|
|
76
|
-
* Additional metadata for the source.
|
|
77
|
-
*/
|
|
78
|
-
metadata?: Record<string, any>;
|
|
79
|
-
/**
|
|
80
|
-
* Additional provider metadata for the source.
|
|
81
|
-
*/
|
|
82
|
-
providerMetadata?: SharedProviderMetadata;
|
|
83
|
-
};
|
|
84
|
-
export type LanguageModelToolCallStatus = "in_progress" | "completed" | "incomplete" | "failed";
|
|
85
|
-
/**
|
|
86
|
-
* Tool calls that the model has generated.
|
|
87
|
-
*/
|
|
88
|
-
export type LanguageModelToolCall = {
|
|
89
|
-
kind: "tool-call";
|
|
90
|
-
/**
|
|
91
|
-
* The identifier of the tool call. It must be unique across all tool calls.
|
|
92
|
-
*/
|
|
93
|
-
callId: string;
|
|
94
|
-
/**
|
|
95
|
-
* The id of the tool that should be called.
|
|
96
|
-
*/
|
|
97
|
-
toolId: string;
|
|
98
|
-
/**
|
|
99
|
-
* The status of the tool call.
|
|
100
|
-
*/
|
|
101
|
-
status: LanguageModelToolCallStatus;
|
|
102
|
-
/**
|
|
103
|
-
* The stringified JSON object with the arguments of the tool call.
|
|
104
|
-
*/
|
|
105
|
-
arguments: string;
|
|
106
|
-
/**
|
|
107
|
-
* Additional provider-specific metadata for the tool call.
|
|
108
|
-
*/
|
|
109
|
-
providerMetadata?: SharedProviderMetadata;
|
|
110
|
-
};
|
|
111
|
-
/**
|
|
112
|
-
* Result of a tool call that has been executed by the provider.
|
|
113
|
-
*/
|
|
114
|
-
export type LanguageModelToolResult = {
|
|
115
|
-
kind: "tool-result";
|
|
116
|
-
/**
|
|
117
|
-
* The ID of the tool call that this result is associated with.
|
|
118
|
-
*/
|
|
119
|
-
callId: string;
|
|
120
|
-
/**
|
|
121
|
-
* Name of the tool that generated this result.
|
|
122
|
-
*/
|
|
123
|
-
toolId: string;
|
|
124
|
-
/**
|
|
125
|
-
* The status of the tool call.
|
|
126
|
-
*/
|
|
127
|
-
status: LanguageModelToolCallStatus;
|
|
128
|
-
/**
|
|
129
|
-
* Result of the tool call. This is a JSON-serializable object.
|
|
130
|
-
*/
|
|
131
|
-
result: NonNullable<JSONValue>;
|
|
132
|
-
/**
|
|
133
|
-
* Error message if the tool call failed
|
|
134
|
-
*/
|
|
135
|
-
error: string | null;
|
|
136
|
-
/**
|
|
137
|
-
* Additional provider-specific metadata for the tool result.
|
|
138
|
-
*/
|
|
139
|
-
providerMetadata?: SharedProviderMetadata;
|
|
140
|
-
};
|
|
141
|
-
//# sourceMappingURL=content.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/language-model/content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,MAA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