@opencode/ai 0.0.0-dev-21801 → 0.0.0-dev-21803
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 +45 -37
- package/dist/effect.d.ts +39 -0
- package/dist/effect.js +28 -0
- package/dist/effort-updates.d.ts +2 -2
- package/dist/image-client.d.ts +4 -4
- package/dist/index.d.ts +1030 -39
- package/dist/index.js +106 -28
- package/dist/protocols/alibaba-responses.d.ts +3 -3
- package/dist/protocols/openai-compatible-chat.d.ts +1 -1
- package/dist/protocols/openai-compatible-responses.d.ts +5 -5
- package/dist/protocols/utils/image-sizing.d.ts +1 -1
- package/dist/speech-client.d.ts +4 -4
- package/dist/transcription-client.d.ts +4 -4
- package/dist/video-client.d.ts +4 -4
- package/package.json +6 -6
- package/dist/promise.d.ts +0 -1030
- package/dist/promise.js +0 -106
package/dist/index.d.ts
CHANGED
|
@@ -1,39 +1,1030 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
1
|
+
import { Effect, Layer } from "effect";
|
|
2
|
+
import { AIClient } from "./ai-client.js";
|
|
3
|
+
import { type DecisionModel, type DecisionQuestions, type DecisionRequestInput } from "./decision.js";
|
|
4
|
+
import type { AwaitOptions, Event, Snapshot } from "./generation.js";
|
|
5
|
+
import { type ImageModel, type ImageRequest, type ImageRequestInput } from "./image.js";
|
|
6
|
+
import { LLM } from "./effect.js";
|
|
7
|
+
import { Media } from "./media.js";
|
|
8
|
+
import { RequestExecutor } from "./route/executor.js";
|
|
9
|
+
import { LanguageModel, type LLMRequest } from "./schema/index.js";
|
|
10
|
+
import type { RequestInput } from "./llm.js";
|
|
11
|
+
import { type SpeechModel, type SpeechRequest, type SpeechRequestInput } from "./speech.js";
|
|
12
|
+
import { type TranscriptionModel, type TranscriptionRequest, type TranscriptionRequestInput } from "./transcription.js";
|
|
13
|
+
import { type VideoModel, type VideoRequest, type VideoRequestInput } from "./video.js";
|
|
14
|
+
/**
|
|
15
|
+
* Promise-first entrypoint for scripts and non-Effect callers. One `ManagedRuntime` hosts the LLM, image, video, speech,
|
|
16
|
+
* transcription and decision clients over a request executor; every method runs the corresponding Effect API and rethrows
|
|
17
|
+
* `AIError` unchanged. `file` and `write` load `node:fs/promises` on first use, so importing this module does not.
|
|
18
|
+
*/
|
|
19
|
+
export interface Options {
|
|
20
|
+
/** Executor layer; defaults to `RequestExecutor.fetchLayer`. Inject a recorder or `RequestExecutor.middleware(fn)` here. */
|
|
21
|
+
readonly layer?: Layer.Layer<RequestExecutor.Service>;
|
|
22
|
+
}
|
|
23
|
+
export interface RunOptions {
|
|
24
|
+
readonly signal?: AbortSignal;
|
|
25
|
+
}
|
|
26
|
+
export type Services = AIClient.Services;
|
|
27
|
+
/**
|
|
28
|
+
* Promise view of a `Generation`. Its fields are a snapshot taken when the handle was created; `refresh()` resolves to a
|
|
29
|
+
* new handle rather than updating this one.
|
|
30
|
+
*/
|
|
31
|
+
export type GenerationHandle<Response> = Snapshot & {
|
|
32
|
+
/** Serializable JSON; pass it back to `resume` from another process. */
|
|
33
|
+
readonly token: unknown;
|
|
34
|
+
readonly await: (options?: AwaitOptions & RunOptions) => Promise<Response>;
|
|
35
|
+
/** Status observations until the first terminal one, polling like `await`; abort throws `signal.reason`. */
|
|
36
|
+
readonly events: (options?: AwaitOptions & RunOptions) => AsyncIterable<Event>;
|
|
37
|
+
/** The result without polling; fails when the generation has not completed. */
|
|
38
|
+
readonly result: (options?: RunOptions) => Promise<Response>;
|
|
39
|
+
readonly refresh: (options?: RunOptions) => Promise<GenerationHandle<Response>>;
|
|
40
|
+
readonly cancel: (options?: RunOptions) => Promise<void>;
|
|
41
|
+
};
|
|
42
|
+
export declare const make: (options?: Options) => {
|
|
43
|
+
run: <A, E>(effect: Effect.Effect<A, E, Services>, options?: RunOptions) => Promise<A>;
|
|
44
|
+
/** Decoded asset bytes, downloading `url` sources through the executor. */
|
|
45
|
+
bytes: (asset: Media.Asset, options?: RunOptions) => Promise<Uint8Array<ArrayBufferLike>>;
|
|
46
|
+
base64: (asset: Media.Asset, options?: RunOptions) => Promise<string>;
|
|
47
|
+
/** Pull a `url` asset into owned bytes before the provider URL expires. */
|
|
48
|
+
materialize: (asset: Media.Asset, options?: RunOptions) => Promise<Media.Asset>;
|
|
49
|
+
/** Read a file into an asset like `Media.file`: sniffed media type, then the extension's. */
|
|
50
|
+
file: (path: string, options?: Media.AssetOptions & RunOptions) => Promise<Media.Asset>;
|
|
51
|
+
/** Write an asset's bytes like `Media.write`, downloading `url` sources through the executor. */
|
|
52
|
+
write: (asset: Media.Asset, path: string, options?: RunOptions) => Promise<void>;
|
|
53
|
+
llm: {
|
|
54
|
+
request: typeof LLM.request;
|
|
55
|
+
generate: <const Model extends LanguageModel>(input: RequestInput<Model> | LLMRequest, options?: RunOptions) => Promise<import("./effect.js").LLMResponse>;
|
|
56
|
+
stream: <const Model extends LanguageModel>(input: RequestInput<Model> | LLMRequest, options?: RunOptions) => AsyncIterable<{
|
|
57
|
+
readonly type: "step-start";
|
|
58
|
+
readonly index: number;
|
|
59
|
+
} | {
|
|
60
|
+
readonly type: "text-start";
|
|
61
|
+
readonly id: string;
|
|
62
|
+
readonly providerMetadata?: {
|
|
63
|
+
readonly [x: string]: {
|
|
64
|
+
readonly [x: string]: unknown;
|
|
65
|
+
};
|
|
66
|
+
} | undefined;
|
|
67
|
+
} | {
|
|
68
|
+
readonly type: "text-delta";
|
|
69
|
+
readonly id: string;
|
|
70
|
+
readonly text: string;
|
|
71
|
+
readonly providerMetadata?: {
|
|
72
|
+
readonly [x: string]: {
|
|
73
|
+
readonly [x: string]: unknown;
|
|
74
|
+
};
|
|
75
|
+
} | undefined;
|
|
76
|
+
} | {
|
|
77
|
+
readonly type: "text-end";
|
|
78
|
+
readonly id: string;
|
|
79
|
+
readonly text?: string | undefined;
|
|
80
|
+
readonly providerMetadata?: {
|
|
81
|
+
readonly [x: string]: {
|
|
82
|
+
readonly [x: string]: unknown;
|
|
83
|
+
};
|
|
84
|
+
} | undefined;
|
|
85
|
+
} | {
|
|
86
|
+
readonly type: "reasoning-start";
|
|
87
|
+
readonly id: string;
|
|
88
|
+
readonly providerMetadata?: {
|
|
89
|
+
readonly [x: string]: {
|
|
90
|
+
readonly [x: string]: unknown;
|
|
91
|
+
};
|
|
92
|
+
} | undefined;
|
|
93
|
+
} | {
|
|
94
|
+
readonly type: "reasoning-delta";
|
|
95
|
+
readonly id: string;
|
|
96
|
+
readonly text: string;
|
|
97
|
+
readonly providerMetadata?: {
|
|
98
|
+
readonly [x: string]: {
|
|
99
|
+
readonly [x: string]: unknown;
|
|
100
|
+
};
|
|
101
|
+
} | undefined;
|
|
102
|
+
} | {
|
|
103
|
+
readonly type: "reasoning-end";
|
|
104
|
+
readonly id: string;
|
|
105
|
+
readonly text?: string | undefined;
|
|
106
|
+
readonly providerMetadata?: {
|
|
107
|
+
readonly [x: string]: {
|
|
108
|
+
readonly [x: string]: unknown;
|
|
109
|
+
};
|
|
110
|
+
} | undefined;
|
|
111
|
+
} | {
|
|
112
|
+
readonly type: "tool-input-start";
|
|
113
|
+
readonly id: string;
|
|
114
|
+
readonly name: string;
|
|
115
|
+
readonly namespace?: string | undefined;
|
|
116
|
+
readonly providerExecuted?: boolean | undefined;
|
|
117
|
+
readonly providerMetadata?: {
|
|
118
|
+
readonly [x: string]: {
|
|
119
|
+
readonly [x: string]: unknown;
|
|
120
|
+
};
|
|
121
|
+
} | undefined;
|
|
122
|
+
} | {
|
|
123
|
+
readonly type: "tool-input-delta";
|
|
124
|
+
readonly id: string;
|
|
125
|
+
readonly name: string;
|
|
126
|
+
readonly namespace?: string | undefined;
|
|
127
|
+
readonly text: string;
|
|
128
|
+
readonly input?: unknown;
|
|
129
|
+
} | {
|
|
130
|
+
readonly type: "tool-input-end";
|
|
131
|
+
readonly id: string;
|
|
132
|
+
readonly name: string;
|
|
133
|
+
readonly namespace?: string | undefined;
|
|
134
|
+
readonly providerMetadata?: {
|
|
135
|
+
readonly [x: string]: {
|
|
136
|
+
readonly [x: string]: unknown;
|
|
137
|
+
};
|
|
138
|
+
} | undefined;
|
|
139
|
+
} | {
|
|
140
|
+
readonly type: "tool-input-error";
|
|
141
|
+
readonly id: string;
|
|
142
|
+
readonly name: string;
|
|
143
|
+
readonly namespace?: string | undefined;
|
|
144
|
+
readonly raw: string;
|
|
145
|
+
} | {
|
|
146
|
+
readonly type: "tool-call";
|
|
147
|
+
readonly id: string;
|
|
148
|
+
readonly name: string;
|
|
149
|
+
readonly namespace?: string | undefined;
|
|
150
|
+
readonly input: unknown;
|
|
151
|
+
readonly providerExecuted?: boolean | undefined;
|
|
152
|
+
readonly providerMetadata?: {
|
|
153
|
+
readonly [x: string]: {
|
|
154
|
+
readonly [x: string]: unknown;
|
|
155
|
+
};
|
|
156
|
+
} | undefined;
|
|
157
|
+
} | {
|
|
158
|
+
readonly type: "tool-result";
|
|
159
|
+
readonly id: string;
|
|
160
|
+
readonly name: string;
|
|
161
|
+
readonly namespace?: string | undefined;
|
|
162
|
+
readonly result: {
|
|
163
|
+
readonly type: "json";
|
|
164
|
+
readonly value: unknown;
|
|
165
|
+
} | {
|
|
166
|
+
readonly type: "text";
|
|
167
|
+
readonly value: unknown;
|
|
168
|
+
} | {
|
|
169
|
+
readonly type: "error";
|
|
170
|
+
readonly value: unknown;
|
|
171
|
+
} | {
|
|
172
|
+
readonly type: "content";
|
|
173
|
+
readonly value: readonly ({
|
|
174
|
+
readonly type: "text";
|
|
175
|
+
readonly text: string;
|
|
176
|
+
} | {
|
|
177
|
+
readonly type: "file";
|
|
178
|
+
readonly uri: string;
|
|
179
|
+
readonly mime: string;
|
|
180
|
+
readonly name?: string | undefined;
|
|
181
|
+
})[];
|
|
182
|
+
};
|
|
183
|
+
readonly output?: {
|
|
184
|
+
readonly structured: unknown;
|
|
185
|
+
readonly content: readonly ({
|
|
186
|
+
readonly type: "text";
|
|
187
|
+
readonly text: string;
|
|
188
|
+
} | {
|
|
189
|
+
readonly type: "file";
|
|
190
|
+
readonly uri: string;
|
|
191
|
+
readonly mime: string;
|
|
192
|
+
readonly name?: string | undefined;
|
|
193
|
+
})[];
|
|
194
|
+
} | undefined;
|
|
195
|
+
readonly providerExecuted?: boolean | undefined;
|
|
196
|
+
readonly providerMetadata?: {
|
|
197
|
+
readonly [x: string]: {
|
|
198
|
+
readonly [x: string]: unknown;
|
|
199
|
+
};
|
|
200
|
+
} | undefined;
|
|
201
|
+
} | {
|
|
202
|
+
readonly type: "tool-error";
|
|
203
|
+
readonly id: string;
|
|
204
|
+
readonly name: string;
|
|
205
|
+
readonly namespace?: string | undefined;
|
|
206
|
+
readonly message: string;
|
|
207
|
+
readonly error?: unknown;
|
|
208
|
+
readonly providerMetadata?: {
|
|
209
|
+
readonly [x: string]: {
|
|
210
|
+
readonly [x: string]: unknown;
|
|
211
|
+
};
|
|
212
|
+
} | undefined;
|
|
213
|
+
} | {
|
|
214
|
+
readonly type: "step-finish";
|
|
215
|
+
readonly index: number;
|
|
216
|
+
readonly reason: {
|
|
217
|
+
readonly normalized: "content-filter" | "error" | "length" | "stop" | "tool-calls" | "unknown";
|
|
218
|
+
readonly raw?: string | undefined;
|
|
219
|
+
readonly category?: string | undefined;
|
|
220
|
+
readonly explanation?: string | undefined;
|
|
221
|
+
};
|
|
222
|
+
readonly usage?: import("./effect.js").Usage | undefined;
|
|
223
|
+
readonly providerMetadata?: {
|
|
224
|
+
readonly [x: string]: {
|
|
225
|
+
readonly [x: string]: unknown;
|
|
226
|
+
};
|
|
227
|
+
} | undefined;
|
|
228
|
+
} | {
|
|
229
|
+
readonly type: "finish";
|
|
230
|
+
readonly reason: {
|
|
231
|
+
readonly normalized: "content-filter" | "error" | "length" | "stop" | "tool-calls" | "unknown";
|
|
232
|
+
readonly raw?: string | undefined;
|
|
233
|
+
readonly category?: string | undefined;
|
|
234
|
+
readonly explanation?: string | undefined;
|
|
235
|
+
};
|
|
236
|
+
readonly usage?: import("./effect.js").Usage | undefined;
|
|
237
|
+
readonly providerMetadata?: {
|
|
238
|
+
readonly [x: string]: {
|
|
239
|
+
readonly [x: string]: unknown;
|
|
240
|
+
};
|
|
241
|
+
} | undefined;
|
|
242
|
+
} | {
|
|
243
|
+
readonly type: "media";
|
|
244
|
+
readonly media: Media.Asset;
|
|
245
|
+
readonly providerMetadata?: {
|
|
246
|
+
readonly [x: string]: {
|
|
247
|
+
readonly [x: string]: unknown;
|
|
248
|
+
};
|
|
249
|
+
} | undefined;
|
|
250
|
+
} | {
|
|
251
|
+
readonly type: "provider-error";
|
|
252
|
+
readonly message: string;
|
|
253
|
+
readonly classification?: "context-overflow" | "payload-too-large" | undefined;
|
|
254
|
+
readonly providerMetadata?: {
|
|
255
|
+
readonly [x: string]: {
|
|
256
|
+
readonly [x: string]: unknown;
|
|
257
|
+
};
|
|
258
|
+
} | undefined;
|
|
259
|
+
} | ({
|
|
260
|
+
readonly type: "compaction";
|
|
261
|
+
readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
262
|
+
readonly id?: string | undefined;
|
|
263
|
+
readonly encrypted?: string | undefined;
|
|
264
|
+
readonly text?: string | null | undefined;
|
|
265
|
+
} & ({
|
|
266
|
+
readonly encrypted: string;
|
|
267
|
+
readonly text?: never;
|
|
268
|
+
} | {
|
|
269
|
+
readonly text: string | null;
|
|
270
|
+
readonly encrypted?: never;
|
|
271
|
+
}))>;
|
|
272
|
+
};
|
|
273
|
+
image: {
|
|
274
|
+
request: typeof import("./image.js").request;
|
|
275
|
+
generate: <const Model extends ImageModel>(input: ImageRequestInput<Model> | ImageRequest, options?: AwaitOptions & RunOptions) => Promise<import("./image.js").ImageResponse>;
|
|
276
|
+
stream: <const Model extends ImageModel>(input: ImageRequestInput<Model> | ImageRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
|
|
277
|
+
readonly type: "image-partial";
|
|
278
|
+
readonly index: number;
|
|
279
|
+
readonly image: Media.Asset;
|
|
280
|
+
} | {
|
|
281
|
+
readonly type: "image";
|
|
282
|
+
readonly index: number;
|
|
283
|
+
readonly image: Media.Asset;
|
|
284
|
+
} | {
|
|
285
|
+
readonly type: "generation-queued";
|
|
286
|
+
readonly id: string;
|
|
287
|
+
readonly position?: number | undefined;
|
|
288
|
+
} | {
|
|
289
|
+
readonly type: "generation-progress";
|
|
290
|
+
readonly id: string;
|
|
291
|
+
readonly progress?: number | undefined;
|
|
292
|
+
} | {
|
|
293
|
+
readonly type: "finish";
|
|
294
|
+
readonly usage?: {
|
|
295
|
+
readonly type: "seconds";
|
|
296
|
+
readonly seconds: number;
|
|
297
|
+
} | {
|
|
298
|
+
readonly type: "characters";
|
|
299
|
+
readonly characters: number;
|
|
300
|
+
} | {
|
|
301
|
+
readonly type: "credits";
|
|
302
|
+
readonly credits: number;
|
|
303
|
+
} | {
|
|
304
|
+
readonly type: "compute";
|
|
305
|
+
readonly seconds: number;
|
|
306
|
+
} | {
|
|
307
|
+
readonly type: "tokens";
|
|
308
|
+
readonly input?: number | undefined;
|
|
309
|
+
readonly output?: number | undefined;
|
|
310
|
+
readonly total?: number | undefined;
|
|
311
|
+
readonly details?: {
|
|
312
|
+
readonly [x: string]: unknown;
|
|
313
|
+
} | undefined;
|
|
314
|
+
} | undefined;
|
|
315
|
+
readonly notices?: readonly {
|
|
316
|
+
readonly type: "filtered" | "moderated" | "other";
|
|
317
|
+
readonly message: string;
|
|
318
|
+
readonly providerMetadata?: {
|
|
319
|
+
readonly [x: string]: {
|
|
320
|
+
readonly [x: string]: unknown;
|
|
321
|
+
};
|
|
322
|
+
} | undefined;
|
|
323
|
+
}[] | undefined;
|
|
324
|
+
readonly providerMetadata?: {
|
|
325
|
+
readonly [x: string]: {
|
|
326
|
+
readonly [x: string]: unknown;
|
|
327
|
+
};
|
|
328
|
+
} | undefined;
|
|
329
|
+
}>;
|
|
330
|
+
start: <const Model extends ImageModel>(input: ImageRequestInput<Model> | ImageRequest, options?: RunOptions) => Promise<GenerationHandle<import("./image.js").ImageResponse>>;
|
|
331
|
+
resume: (model: ImageModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./image.js").ImageResponse>>;
|
|
332
|
+
};
|
|
333
|
+
video: {
|
|
334
|
+
request: typeof import("./video.js").request;
|
|
335
|
+
start: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: RunOptions) => Promise<GenerationHandle<import("./video.js").VideoResponse>>;
|
|
336
|
+
generate: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: AwaitOptions & RunOptions) => Promise<import("./video.js").VideoResponse>;
|
|
337
|
+
resume: (model: VideoModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./video.js").VideoResponse>>;
|
|
338
|
+
stream: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
|
|
339
|
+
readonly type: "video";
|
|
340
|
+
readonly index: number;
|
|
341
|
+
readonly video: Media.Asset;
|
|
342
|
+
} | {
|
|
343
|
+
readonly type: "generation-queued";
|
|
344
|
+
readonly id: string;
|
|
345
|
+
readonly position?: number | undefined;
|
|
346
|
+
} | {
|
|
347
|
+
readonly type: "generation-progress";
|
|
348
|
+
readonly id: string;
|
|
349
|
+
readonly progress?: number | undefined;
|
|
350
|
+
} | {
|
|
351
|
+
readonly type: "finish";
|
|
352
|
+
readonly usage?: {
|
|
353
|
+
readonly type: "seconds";
|
|
354
|
+
readonly seconds: number;
|
|
355
|
+
} | {
|
|
356
|
+
readonly type: "characters";
|
|
357
|
+
readonly characters: number;
|
|
358
|
+
} | {
|
|
359
|
+
readonly type: "credits";
|
|
360
|
+
readonly credits: number;
|
|
361
|
+
} | {
|
|
362
|
+
readonly type: "compute";
|
|
363
|
+
readonly seconds: number;
|
|
364
|
+
} | {
|
|
365
|
+
readonly type: "tokens";
|
|
366
|
+
readonly input?: number | undefined;
|
|
367
|
+
readonly output?: number | undefined;
|
|
368
|
+
readonly total?: number | undefined;
|
|
369
|
+
readonly details?: {
|
|
370
|
+
readonly [x: string]: unknown;
|
|
371
|
+
} | undefined;
|
|
372
|
+
} | undefined;
|
|
373
|
+
readonly notices?: readonly {
|
|
374
|
+
readonly type: "filtered" | "moderated" | "other";
|
|
375
|
+
readonly message: string;
|
|
376
|
+
readonly providerMetadata?: {
|
|
377
|
+
readonly [x: string]: {
|
|
378
|
+
readonly [x: string]: unknown;
|
|
379
|
+
};
|
|
380
|
+
} | undefined;
|
|
381
|
+
}[] | undefined;
|
|
382
|
+
readonly providerMetadata?: {
|
|
383
|
+
readonly [x: string]: {
|
|
384
|
+
readonly [x: string]: unknown;
|
|
385
|
+
};
|
|
386
|
+
} | undefined;
|
|
387
|
+
}>;
|
|
388
|
+
};
|
|
389
|
+
speech: {
|
|
390
|
+
request: typeof import("./speech.js").request;
|
|
391
|
+
generate: <const Model extends SpeechModel>(input: SpeechRequestInput<Model> | SpeechRequest, options?: RunOptions) => Promise<import("./speech.js").SpeechResponse>;
|
|
392
|
+
stream: <const Model extends SpeechModel>(input: SpeechRequestInput<Model> | SpeechRequest, options?: RunOptions) => AsyncIterable<{
|
|
393
|
+
readonly type: "audio-delta";
|
|
394
|
+
readonly chunk: Uint8Array<ArrayBufferLike>;
|
|
395
|
+
} | {
|
|
396
|
+
readonly type: "timestamps";
|
|
397
|
+
readonly items: readonly {
|
|
398
|
+
readonly text: string;
|
|
399
|
+
readonly startSeconds: number;
|
|
400
|
+
readonly endSeconds: number;
|
|
401
|
+
}[];
|
|
402
|
+
} | {
|
|
403
|
+
readonly type: "generation-queued";
|
|
404
|
+
readonly id: string;
|
|
405
|
+
readonly position?: number | undefined;
|
|
406
|
+
} | {
|
|
407
|
+
readonly type: "generation-progress";
|
|
408
|
+
readonly id: string;
|
|
409
|
+
readonly progress?: number | undefined;
|
|
410
|
+
} | {
|
|
411
|
+
readonly type: "finish";
|
|
412
|
+
readonly audio: Media.Asset;
|
|
413
|
+
readonly usage?: {
|
|
414
|
+
readonly type: "seconds";
|
|
415
|
+
readonly seconds: number;
|
|
416
|
+
} | {
|
|
417
|
+
readonly type: "characters";
|
|
418
|
+
readonly characters: number;
|
|
419
|
+
} | {
|
|
420
|
+
readonly type: "credits";
|
|
421
|
+
readonly credits: number;
|
|
422
|
+
} | {
|
|
423
|
+
readonly type: "compute";
|
|
424
|
+
readonly seconds: number;
|
|
425
|
+
} | {
|
|
426
|
+
readonly type: "tokens";
|
|
427
|
+
readonly input?: number | undefined;
|
|
428
|
+
readonly output?: number | undefined;
|
|
429
|
+
readonly total?: number | undefined;
|
|
430
|
+
readonly details?: {
|
|
431
|
+
readonly [x: string]: unknown;
|
|
432
|
+
} | undefined;
|
|
433
|
+
} | undefined;
|
|
434
|
+
readonly notices?: readonly {
|
|
435
|
+
readonly type: "filtered" | "moderated" | "other";
|
|
436
|
+
readonly message: string;
|
|
437
|
+
readonly providerMetadata?: {
|
|
438
|
+
readonly [x: string]: {
|
|
439
|
+
readonly [x: string]: unknown;
|
|
440
|
+
};
|
|
441
|
+
} | undefined;
|
|
442
|
+
}[] | undefined;
|
|
443
|
+
readonly providerMetadata?: {
|
|
444
|
+
readonly [x: string]: {
|
|
445
|
+
readonly [x: string]: unknown;
|
|
446
|
+
};
|
|
447
|
+
} | undefined;
|
|
448
|
+
}>;
|
|
449
|
+
};
|
|
450
|
+
transcription: {
|
|
451
|
+
request: typeof import("./transcription.js").request;
|
|
452
|
+
generate: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: AwaitOptions & RunOptions) => Promise<import("./transcription.js").TranscriptionResponse>;
|
|
453
|
+
stream: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
|
|
454
|
+
readonly type: "text-delta";
|
|
455
|
+
readonly delta: string;
|
|
456
|
+
} | {
|
|
457
|
+
readonly type: "segment";
|
|
458
|
+
readonly segment: {
|
|
459
|
+
readonly text: string;
|
|
460
|
+
readonly startSeconds: number;
|
|
461
|
+
readonly endSeconds: number;
|
|
462
|
+
readonly speaker?: string | undefined;
|
|
463
|
+
};
|
|
464
|
+
} | {
|
|
465
|
+
readonly type: "generation-queued";
|
|
466
|
+
readonly id: string;
|
|
467
|
+
readonly position?: number | undefined;
|
|
468
|
+
} | {
|
|
469
|
+
readonly type: "generation-progress";
|
|
470
|
+
readonly id: string;
|
|
471
|
+
readonly progress?: number | undefined;
|
|
472
|
+
} | {
|
|
473
|
+
readonly text: string;
|
|
474
|
+
readonly segments?: readonly {
|
|
475
|
+
readonly text: string;
|
|
476
|
+
readonly startSeconds: number;
|
|
477
|
+
readonly endSeconds: number;
|
|
478
|
+
readonly speaker?: string | undefined;
|
|
479
|
+
}[] | undefined;
|
|
480
|
+
readonly words?: readonly {
|
|
481
|
+
readonly text: string;
|
|
482
|
+
readonly startSeconds: number;
|
|
483
|
+
readonly endSeconds: number;
|
|
484
|
+
readonly speaker?: string | undefined;
|
|
485
|
+
readonly confidence?: number | undefined;
|
|
486
|
+
}[] | undefined;
|
|
487
|
+
readonly language?: string | undefined;
|
|
488
|
+
readonly durationSeconds?: number | undefined;
|
|
489
|
+
readonly usage?: {
|
|
490
|
+
readonly type: "seconds";
|
|
491
|
+
readonly seconds: number;
|
|
492
|
+
} | {
|
|
493
|
+
readonly type: "characters";
|
|
494
|
+
readonly characters: number;
|
|
495
|
+
} | {
|
|
496
|
+
readonly type: "credits";
|
|
497
|
+
readonly credits: number;
|
|
498
|
+
} | {
|
|
499
|
+
readonly type: "compute";
|
|
500
|
+
readonly seconds: number;
|
|
501
|
+
} | {
|
|
502
|
+
readonly type: "tokens";
|
|
503
|
+
readonly input?: number | undefined;
|
|
504
|
+
readonly output?: number | undefined;
|
|
505
|
+
readonly total?: number | undefined;
|
|
506
|
+
readonly details?: {
|
|
507
|
+
readonly [x: string]: unknown;
|
|
508
|
+
} | undefined;
|
|
509
|
+
} | undefined;
|
|
510
|
+
readonly notices?: readonly {
|
|
511
|
+
readonly type: "filtered" | "moderated" | "other";
|
|
512
|
+
readonly message: string;
|
|
513
|
+
readonly providerMetadata?: {
|
|
514
|
+
readonly [x: string]: {
|
|
515
|
+
readonly [x: string]: unknown;
|
|
516
|
+
};
|
|
517
|
+
} | undefined;
|
|
518
|
+
}[] | undefined;
|
|
519
|
+
readonly providerMetadata?: {
|
|
520
|
+
readonly [x: string]: {
|
|
521
|
+
readonly [x: string]: unknown;
|
|
522
|
+
};
|
|
523
|
+
} | undefined;
|
|
524
|
+
readonly type: "finish";
|
|
525
|
+
}>;
|
|
526
|
+
start: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: RunOptions) => Promise<GenerationHandle<import("./transcription.js").TranscriptionResponse>>;
|
|
527
|
+
resume: (model: TranscriptionModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./transcription.js").TranscriptionResponse>>;
|
|
528
|
+
};
|
|
529
|
+
decision: {
|
|
530
|
+
request: typeof import("./decision.js").request;
|
|
531
|
+
generate: <const Model extends DecisionModel, const Questions extends DecisionQuestions>(input: DecisionRequestInput<Model, Questions>, options?: RunOptions) => Promise<import("./decision.js").DecisionResponseFor<Questions>>;
|
|
532
|
+
};
|
|
533
|
+
dispose: () => Promise<void>;
|
|
534
|
+
};
|
|
535
|
+
export type Client = ReturnType<typeof make>;
|
|
536
|
+
/** Default client over `RequestExecutor.fetchLayer` for scripts; the runtime builds its layer on first use. */
|
|
537
|
+
export declare const ai: {
|
|
538
|
+
run: <A, E>(effect: Effect.Effect<A, E, Services>, options?: RunOptions) => Promise<A>;
|
|
539
|
+
/** Decoded asset bytes, downloading `url` sources through the executor. */
|
|
540
|
+
bytes: (asset: Media.Asset, options?: RunOptions) => Promise<Uint8Array<ArrayBufferLike>>;
|
|
541
|
+
base64: (asset: Media.Asset, options?: RunOptions) => Promise<string>;
|
|
542
|
+
/** Pull a `url` asset into owned bytes before the provider URL expires. */
|
|
543
|
+
materialize: (asset: Media.Asset, options?: RunOptions) => Promise<Media.Asset>;
|
|
544
|
+
/** Read a file into an asset like `Media.file`: sniffed media type, then the extension's. */
|
|
545
|
+
file: (path: string, options?: Media.AssetOptions & RunOptions) => Promise<Media.Asset>;
|
|
546
|
+
/** Write an asset's bytes like `Media.write`, downloading `url` sources through the executor. */
|
|
547
|
+
write: (asset: Media.Asset, path: string, options?: RunOptions) => Promise<void>;
|
|
548
|
+
llm: {
|
|
549
|
+
request: typeof LLM.request;
|
|
550
|
+
generate: <const Model extends LanguageModel>(input: RequestInput<Model> | LLMRequest, options?: RunOptions) => Promise<import("./effect.js").LLMResponse>;
|
|
551
|
+
stream: <const Model extends LanguageModel>(input: RequestInput<Model> | LLMRequest, options?: RunOptions) => AsyncIterable<{
|
|
552
|
+
readonly type: "step-start";
|
|
553
|
+
readonly index: number;
|
|
554
|
+
} | {
|
|
555
|
+
readonly type: "text-start";
|
|
556
|
+
readonly id: string;
|
|
557
|
+
readonly providerMetadata?: {
|
|
558
|
+
readonly [x: string]: {
|
|
559
|
+
readonly [x: string]: unknown;
|
|
560
|
+
};
|
|
561
|
+
} | undefined;
|
|
562
|
+
} | {
|
|
563
|
+
readonly type: "text-delta";
|
|
564
|
+
readonly id: string;
|
|
565
|
+
readonly text: string;
|
|
566
|
+
readonly providerMetadata?: {
|
|
567
|
+
readonly [x: string]: {
|
|
568
|
+
readonly [x: string]: unknown;
|
|
569
|
+
};
|
|
570
|
+
} | undefined;
|
|
571
|
+
} | {
|
|
572
|
+
readonly type: "text-end";
|
|
573
|
+
readonly id: string;
|
|
574
|
+
readonly text?: string | undefined;
|
|
575
|
+
readonly providerMetadata?: {
|
|
576
|
+
readonly [x: string]: {
|
|
577
|
+
readonly [x: string]: unknown;
|
|
578
|
+
};
|
|
579
|
+
} | undefined;
|
|
580
|
+
} | {
|
|
581
|
+
readonly type: "reasoning-start";
|
|
582
|
+
readonly id: string;
|
|
583
|
+
readonly providerMetadata?: {
|
|
584
|
+
readonly [x: string]: {
|
|
585
|
+
readonly [x: string]: unknown;
|
|
586
|
+
};
|
|
587
|
+
} | undefined;
|
|
588
|
+
} | {
|
|
589
|
+
readonly type: "reasoning-delta";
|
|
590
|
+
readonly id: string;
|
|
591
|
+
readonly text: string;
|
|
592
|
+
readonly providerMetadata?: {
|
|
593
|
+
readonly [x: string]: {
|
|
594
|
+
readonly [x: string]: unknown;
|
|
595
|
+
};
|
|
596
|
+
} | undefined;
|
|
597
|
+
} | {
|
|
598
|
+
readonly type: "reasoning-end";
|
|
599
|
+
readonly id: string;
|
|
600
|
+
readonly text?: string | undefined;
|
|
601
|
+
readonly providerMetadata?: {
|
|
602
|
+
readonly [x: string]: {
|
|
603
|
+
readonly [x: string]: unknown;
|
|
604
|
+
};
|
|
605
|
+
} | undefined;
|
|
606
|
+
} | {
|
|
607
|
+
readonly type: "tool-input-start";
|
|
608
|
+
readonly id: string;
|
|
609
|
+
readonly name: string;
|
|
610
|
+
readonly namespace?: string | undefined;
|
|
611
|
+
readonly providerExecuted?: boolean | undefined;
|
|
612
|
+
readonly providerMetadata?: {
|
|
613
|
+
readonly [x: string]: {
|
|
614
|
+
readonly [x: string]: unknown;
|
|
615
|
+
};
|
|
616
|
+
} | undefined;
|
|
617
|
+
} | {
|
|
618
|
+
readonly type: "tool-input-delta";
|
|
619
|
+
readonly id: string;
|
|
620
|
+
readonly name: string;
|
|
621
|
+
readonly namespace?: string | undefined;
|
|
622
|
+
readonly text: string;
|
|
623
|
+
readonly input?: unknown;
|
|
624
|
+
} | {
|
|
625
|
+
readonly type: "tool-input-end";
|
|
626
|
+
readonly id: string;
|
|
627
|
+
readonly name: string;
|
|
628
|
+
readonly namespace?: string | undefined;
|
|
629
|
+
readonly providerMetadata?: {
|
|
630
|
+
readonly [x: string]: {
|
|
631
|
+
readonly [x: string]: unknown;
|
|
632
|
+
};
|
|
633
|
+
} | undefined;
|
|
634
|
+
} | {
|
|
635
|
+
readonly type: "tool-input-error";
|
|
636
|
+
readonly id: string;
|
|
637
|
+
readonly name: string;
|
|
638
|
+
readonly namespace?: string | undefined;
|
|
639
|
+
readonly raw: string;
|
|
640
|
+
} | {
|
|
641
|
+
readonly type: "tool-call";
|
|
642
|
+
readonly id: string;
|
|
643
|
+
readonly name: string;
|
|
644
|
+
readonly namespace?: string | undefined;
|
|
645
|
+
readonly input: unknown;
|
|
646
|
+
readonly providerExecuted?: boolean | undefined;
|
|
647
|
+
readonly providerMetadata?: {
|
|
648
|
+
readonly [x: string]: {
|
|
649
|
+
readonly [x: string]: unknown;
|
|
650
|
+
};
|
|
651
|
+
} | undefined;
|
|
652
|
+
} | {
|
|
653
|
+
readonly type: "tool-result";
|
|
654
|
+
readonly id: string;
|
|
655
|
+
readonly name: string;
|
|
656
|
+
readonly namespace?: string | undefined;
|
|
657
|
+
readonly result: {
|
|
658
|
+
readonly type: "json";
|
|
659
|
+
readonly value: unknown;
|
|
660
|
+
} | {
|
|
661
|
+
readonly type: "text";
|
|
662
|
+
readonly value: unknown;
|
|
663
|
+
} | {
|
|
664
|
+
readonly type: "error";
|
|
665
|
+
readonly value: unknown;
|
|
666
|
+
} | {
|
|
667
|
+
readonly type: "content";
|
|
668
|
+
readonly value: readonly ({
|
|
669
|
+
readonly type: "text";
|
|
670
|
+
readonly text: string;
|
|
671
|
+
} | {
|
|
672
|
+
readonly type: "file";
|
|
673
|
+
readonly uri: string;
|
|
674
|
+
readonly mime: string;
|
|
675
|
+
readonly name?: string | undefined;
|
|
676
|
+
})[];
|
|
677
|
+
};
|
|
678
|
+
readonly output?: {
|
|
679
|
+
readonly structured: unknown;
|
|
680
|
+
readonly content: readonly ({
|
|
681
|
+
readonly type: "text";
|
|
682
|
+
readonly text: string;
|
|
683
|
+
} | {
|
|
684
|
+
readonly type: "file";
|
|
685
|
+
readonly uri: string;
|
|
686
|
+
readonly mime: string;
|
|
687
|
+
readonly name?: string | undefined;
|
|
688
|
+
})[];
|
|
689
|
+
} | undefined;
|
|
690
|
+
readonly providerExecuted?: boolean | undefined;
|
|
691
|
+
readonly providerMetadata?: {
|
|
692
|
+
readonly [x: string]: {
|
|
693
|
+
readonly [x: string]: unknown;
|
|
694
|
+
};
|
|
695
|
+
} | undefined;
|
|
696
|
+
} | {
|
|
697
|
+
readonly type: "tool-error";
|
|
698
|
+
readonly id: string;
|
|
699
|
+
readonly name: string;
|
|
700
|
+
readonly namespace?: string | undefined;
|
|
701
|
+
readonly message: string;
|
|
702
|
+
readonly error?: unknown;
|
|
703
|
+
readonly providerMetadata?: {
|
|
704
|
+
readonly [x: string]: {
|
|
705
|
+
readonly [x: string]: unknown;
|
|
706
|
+
};
|
|
707
|
+
} | undefined;
|
|
708
|
+
} | {
|
|
709
|
+
readonly type: "step-finish";
|
|
710
|
+
readonly index: number;
|
|
711
|
+
readonly reason: {
|
|
712
|
+
readonly normalized: "content-filter" | "error" | "length" | "stop" | "tool-calls" | "unknown";
|
|
713
|
+
readonly raw?: string | undefined;
|
|
714
|
+
readonly category?: string | undefined;
|
|
715
|
+
readonly explanation?: string | undefined;
|
|
716
|
+
};
|
|
717
|
+
readonly usage?: import("./effect.js").Usage | undefined;
|
|
718
|
+
readonly providerMetadata?: {
|
|
719
|
+
readonly [x: string]: {
|
|
720
|
+
readonly [x: string]: unknown;
|
|
721
|
+
};
|
|
722
|
+
} | undefined;
|
|
723
|
+
} | {
|
|
724
|
+
readonly type: "finish";
|
|
725
|
+
readonly reason: {
|
|
726
|
+
readonly normalized: "content-filter" | "error" | "length" | "stop" | "tool-calls" | "unknown";
|
|
727
|
+
readonly raw?: string | undefined;
|
|
728
|
+
readonly category?: string | undefined;
|
|
729
|
+
readonly explanation?: string | undefined;
|
|
730
|
+
};
|
|
731
|
+
readonly usage?: import("./effect.js").Usage | undefined;
|
|
732
|
+
readonly providerMetadata?: {
|
|
733
|
+
readonly [x: string]: {
|
|
734
|
+
readonly [x: string]: unknown;
|
|
735
|
+
};
|
|
736
|
+
} | undefined;
|
|
737
|
+
} | {
|
|
738
|
+
readonly type: "media";
|
|
739
|
+
readonly media: Media.Asset;
|
|
740
|
+
readonly providerMetadata?: {
|
|
741
|
+
readonly [x: string]: {
|
|
742
|
+
readonly [x: string]: unknown;
|
|
743
|
+
};
|
|
744
|
+
} | undefined;
|
|
745
|
+
} | {
|
|
746
|
+
readonly type: "provider-error";
|
|
747
|
+
readonly message: string;
|
|
748
|
+
readonly classification?: "context-overflow" | "payload-too-large" | undefined;
|
|
749
|
+
readonly providerMetadata?: {
|
|
750
|
+
readonly [x: string]: {
|
|
751
|
+
readonly [x: string]: unknown;
|
|
752
|
+
};
|
|
753
|
+
} | undefined;
|
|
754
|
+
} | ({
|
|
755
|
+
readonly type: "compaction";
|
|
756
|
+
readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
757
|
+
readonly id?: string | undefined;
|
|
758
|
+
readonly encrypted?: string | undefined;
|
|
759
|
+
readonly text?: string | null | undefined;
|
|
760
|
+
} & ({
|
|
761
|
+
readonly encrypted: string;
|
|
762
|
+
readonly text?: never;
|
|
763
|
+
} | {
|
|
764
|
+
readonly text: string | null;
|
|
765
|
+
readonly encrypted?: never;
|
|
766
|
+
}))>;
|
|
767
|
+
};
|
|
768
|
+
image: {
|
|
769
|
+
request: typeof import("./image.js").request;
|
|
770
|
+
generate: <const Model extends ImageModel>(input: ImageRequestInput<Model> | ImageRequest, options?: AwaitOptions & RunOptions) => Promise<import("./image.js").ImageResponse>;
|
|
771
|
+
stream: <const Model extends ImageModel>(input: ImageRequestInput<Model> | ImageRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
|
|
772
|
+
readonly type: "image-partial";
|
|
773
|
+
readonly index: number;
|
|
774
|
+
readonly image: Media.Asset;
|
|
775
|
+
} | {
|
|
776
|
+
readonly type: "image";
|
|
777
|
+
readonly index: number;
|
|
778
|
+
readonly image: Media.Asset;
|
|
779
|
+
} | {
|
|
780
|
+
readonly type: "generation-queued";
|
|
781
|
+
readonly id: string;
|
|
782
|
+
readonly position?: number | undefined;
|
|
783
|
+
} | {
|
|
784
|
+
readonly type: "generation-progress";
|
|
785
|
+
readonly id: string;
|
|
786
|
+
readonly progress?: number | undefined;
|
|
787
|
+
} | {
|
|
788
|
+
readonly type: "finish";
|
|
789
|
+
readonly usage?: {
|
|
790
|
+
readonly type: "seconds";
|
|
791
|
+
readonly seconds: number;
|
|
792
|
+
} | {
|
|
793
|
+
readonly type: "characters";
|
|
794
|
+
readonly characters: number;
|
|
795
|
+
} | {
|
|
796
|
+
readonly type: "credits";
|
|
797
|
+
readonly credits: number;
|
|
798
|
+
} | {
|
|
799
|
+
readonly type: "compute";
|
|
800
|
+
readonly seconds: number;
|
|
801
|
+
} | {
|
|
802
|
+
readonly type: "tokens";
|
|
803
|
+
readonly input?: number | undefined;
|
|
804
|
+
readonly output?: number | undefined;
|
|
805
|
+
readonly total?: number | undefined;
|
|
806
|
+
readonly details?: {
|
|
807
|
+
readonly [x: string]: unknown;
|
|
808
|
+
} | undefined;
|
|
809
|
+
} | undefined;
|
|
810
|
+
readonly notices?: readonly {
|
|
811
|
+
readonly type: "filtered" | "moderated" | "other";
|
|
812
|
+
readonly message: string;
|
|
813
|
+
readonly providerMetadata?: {
|
|
814
|
+
readonly [x: string]: {
|
|
815
|
+
readonly [x: string]: unknown;
|
|
816
|
+
};
|
|
817
|
+
} | undefined;
|
|
818
|
+
}[] | undefined;
|
|
819
|
+
readonly providerMetadata?: {
|
|
820
|
+
readonly [x: string]: {
|
|
821
|
+
readonly [x: string]: unknown;
|
|
822
|
+
};
|
|
823
|
+
} | undefined;
|
|
824
|
+
}>;
|
|
825
|
+
start: <const Model extends ImageModel>(input: ImageRequestInput<Model> | ImageRequest, options?: RunOptions) => Promise<GenerationHandle<import("./image.js").ImageResponse>>;
|
|
826
|
+
resume: (model: ImageModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./image.js").ImageResponse>>;
|
|
827
|
+
};
|
|
828
|
+
video: {
|
|
829
|
+
request: typeof import("./video.js").request;
|
|
830
|
+
start: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: RunOptions) => Promise<GenerationHandle<import("./video.js").VideoResponse>>;
|
|
831
|
+
generate: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: AwaitOptions & RunOptions) => Promise<import("./video.js").VideoResponse>;
|
|
832
|
+
resume: (model: VideoModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./video.js").VideoResponse>>;
|
|
833
|
+
stream: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
|
|
834
|
+
readonly type: "video";
|
|
835
|
+
readonly index: number;
|
|
836
|
+
readonly video: Media.Asset;
|
|
837
|
+
} | {
|
|
838
|
+
readonly type: "generation-queued";
|
|
839
|
+
readonly id: string;
|
|
840
|
+
readonly position?: number | undefined;
|
|
841
|
+
} | {
|
|
842
|
+
readonly type: "generation-progress";
|
|
843
|
+
readonly id: string;
|
|
844
|
+
readonly progress?: number | undefined;
|
|
845
|
+
} | {
|
|
846
|
+
readonly type: "finish";
|
|
847
|
+
readonly usage?: {
|
|
848
|
+
readonly type: "seconds";
|
|
849
|
+
readonly seconds: number;
|
|
850
|
+
} | {
|
|
851
|
+
readonly type: "characters";
|
|
852
|
+
readonly characters: number;
|
|
853
|
+
} | {
|
|
854
|
+
readonly type: "credits";
|
|
855
|
+
readonly credits: number;
|
|
856
|
+
} | {
|
|
857
|
+
readonly type: "compute";
|
|
858
|
+
readonly seconds: number;
|
|
859
|
+
} | {
|
|
860
|
+
readonly type: "tokens";
|
|
861
|
+
readonly input?: number | undefined;
|
|
862
|
+
readonly output?: number | undefined;
|
|
863
|
+
readonly total?: number | undefined;
|
|
864
|
+
readonly details?: {
|
|
865
|
+
readonly [x: string]: unknown;
|
|
866
|
+
} | undefined;
|
|
867
|
+
} | undefined;
|
|
868
|
+
readonly notices?: readonly {
|
|
869
|
+
readonly type: "filtered" | "moderated" | "other";
|
|
870
|
+
readonly message: string;
|
|
871
|
+
readonly providerMetadata?: {
|
|
872
|
+
readonly [x: string]: {
|
|
873
|
+
readonly [x: string]: unknown;
|
|
874
|
+
};
|
|
875
|
+
} | undefined;
|
|
876
|
+
}[] | undefined;
|
|
877
|
+
readonly providerMetadata?: {
|
|
878
|
+
readonly [x: string]: {
|
|
879
|
+
readonly [x: string]: unknown;
|
|
880
|
+
};
|
|
881
|
+
} | undefined;
|
|
882
|
+
}>;
|
|
883
|
+
};
|
|
884
|
+
speech: {
|
|
885
|
+
request: typeof import("./speech.js").request;
|
|
886
|
+
generate: <const Model extends SpeechModel>(input: SpeechRequestInput<Model> | SpeechRequest, options?: RunOptions) => Promise<import("./speech.js").SpeechResponse>;
|
|
887
|
+
stream: <const Model extends SpeechModel>(input: SpeechRequestInput<Model> | SpeechRequest, options?: RunOptions) => AsyncIterable<{
|
|
888
|
+
readonly type: "audio-delta";
|
|
889
|
+
readonly chunk: Uint8Array<ArrayBufferLike>;
|
|
890
|
+
} | {
|
|
891
|
+
readonly type: "timestamps";
|
|
892
|
+
readonly items: readonly {
|
|
893
|
+
readonly text: string;
|
|
894
|
+
readonly startSeconds: number;
|
|
895
|
+
readonly endSeconds: number;
|
|
896
|
+
}[];
|
|
897
|
+
} | {
|
|
898
|
+
readonly type: "generation-queued";
|
|
899
|
+
readonly id: string;
|
|
900
|
+
readonly position?: number | undefined;
|
|
901
|
+
} | {
|
|
902
|
+
readonly type: "generation-progress";
|
|
903
|
+
readonly id: string;
|
|
904
|
+
readonly progress?: number | undefined;
|
|
905
|
+
} | {
|
|
906
|
+
readonly type: "finish";
|
|
907
|
+
readonly audio: Media.Asset;
|
|
908
|
+
readonly usage?: {
|
|
909
|
+
readonly type: "seconds";
|
|
910
|
+
readonly seconds: number;
|
|
911
|
+
} | {
|
|
912
|
+
readonly type: "characters";
|
|
913
|
+
readonly characters: number;
|
|
914
|
+
} | {
|
|
915
|
+
readonly type: "credits";
|
|
916
|
+
readonly credits: number;
|
|
917
|
+
} | {
|
|
918
|
+
readonly type: "compute";
|
|
919
|
+
readonly seconds: number;
|
|
920
|
+
} | {
|
|
921
|
+
readonly type: "tokens";
|
|
922
|
+
readonly input?: number | undefined;
|
|
923
|
+
readonly output?: number | undefined;
|
|
924
|
+
readonly total?: number | undefined;
|
|
925
|
+
readonly details?: {
|
|
926
|
+
readonly [x: string]: unknown;
|
|
927
|
+
} | undefined;
|
|
928
|
+
} | undefined;
|
|
929
|
+
readonly notices?: readonly {
|
|
930
|
+
readonly type: "filtered" | "moderated" | "other";
|
|
931
|
+
readonly message: string;
|
|
932
|
+
readonly providerMetadata?: {
|
|
933
|
+
readonly [x: string]: {
|
|
934
|
+
readonly [x: string]: unknown;
|
|
935
|
+
};
|
|
936
|
+
} | undefined;
|
|
937
|
+
}[] | undefined;
|
|
938
|
+
readonly providerMetadata?: {
|
|
939
|
+
readonly [x: string]: {
|
|
940
|
+
readonly [x: string]: unknown;
|
|
941
|
+
};
|
|
942
|
+
} | undefined;
|
|
943
|
+
}>;
|
|
944
|
+
};
|
|
945
|
+
transcription: {
|
|
946
|
+
request: typeof import("./transcription.js").request;
|
|
947
|
+
generate: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: AwaitOptions & RunOptions) => Promise<import("./transcription.js").TranscriptionResponse>;
|
|
948
|
+
stream: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
|
|
949
|
+
readonly type: "text-delta";
|
|
950
|
+
readonly delta: string;
|
|
951
|
+
} | {
|
|
952
|
+
readonly type: "segment";
|
|
953
|
+
readonly segment: {
|
|
954
|
+
readonly text: string;
|
|
955
|
+
readonly startSeconds: number;
|
|
956
|
+
readonly endSeconds: number;
|
|
957
|
+
readonly speaker?: string | undefined;
|
|
958
|
+
};
|
|
959
|
+
} | {
|
|
960
|
+
readonly type: "generation-queued";
|
|
961
|
+
readonly id: string;
|
|
962
|
+
readonly position?: number | undefined;
|
|
963
|
+
} | {
|
|
964
|
+
readonly type: "generation-progress";
|
|
965
|
+
readonly id: string;
|
|
966
|
+
readonly progress?: number | undefined;
|
|
967
|
+
} | {
|
|
968
|
+
readonly text: string;
|
|
969
|
+
readonly segments?: readonly {
|
|
970
|
+
readonly text: string;
|
|
971
|
+
readonly startSeconds: number;
|
|
972
|
+
readonly endSeconds: number;
|
|
973
|
+
readonly speaker?: string | undefined;
|
|
974
|
+
}[] | undefined;
|
|
975
|
+
readonly words?: readonly {
|
|
976
|
+
readonly text: string;
|
|
977
|
+
readonly startSeconds: number;
|
|
978
|
+
readonly endSeconds: number;
|
|
979
|
+
readonly speaker?: string | undefined;
|
|
980
|
+
readonly confidence?: number | undefined;
|
|
981
|
+
}[] | undefined;
|
|
982
|
+
readonly language?: string | undefined;
|
|
983
|
+
readonly durationSeconds?: number | undefined;
|
|
984
|
+
readonly usage?: {
|
|
985
|
+
readonly type: "seconds";
|
|
986
|
+
readonly seconds: number;
|
|
987
|
+
} | {
|
|
988
|
+
readonly type: "characters";
|
|
989
|
+
readonly characters: number;
|
|
990
|
+
} | {
|
|
991
|
+
readonly type: "credits";
|
|
992
|
+
readonly credits: number;
|
|
993
|
+
} | {
|
|
994
|
+
readonly type: "compute";
|
|
995
|
+
readonly seconds: number;
|
|
996
|
+
} | {
|
|
997
|
+
readonly type: "tokens";
|
|
998
|
+
readonly input?: number | undefined;
|
|
999
|
+
readonly output?: number | undefined;
|
|
1000
|
+
readonly total?: number | undefined;
|
|
1001
|
+
readonly details?: {
|
|
1002
|
+
readonly [x: string]: unknown;
|
|
1003
|
+
} | undefined;
|
|
1004
|
+
} | undefined;
|
|
1005
|
+
readonly notices?: readonly {
|
|
1006
|
+
readonly type: "filtered" | "moderated" | "other";
|
|
1007
|
+
readonly message: string;
|
|
1008
|
+
readonly providerMetadata?: {
|
|
1009
|
+
readonly [x: string]: {
|
|
1010
|
+
readonly [x: string]: unknown;
|
|
1011
|
+
};
|
|
1012
|
+
} | undefined;
|
|
1013
|
+
}[] | undefined;
|
|
1014
|
+
readonly providerMetadata?: {
|
|
1015
|
+
readonly [x: string]: {
|
|
1016
|
+
readonly [x: string]: unknown;
|
|
1017
|
+
};
|
|
1018
|
+
} | undefined;
|
|
1019
|
+
readonly type: "finish";
|
|
1020
|
+
}>;
|
|
1021
|
+
start: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: RunOptions) => Promise<GenerationHandle<import("./transcription.js").TranscriptionResponse>>;
|
|
1022
|
+
resume: (model: TranscriptionModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./transcription.js").TranscriptionResponse>>;
|
|
1023
|
+
};
|
|
1024
|
+
decision: {
|
|
1025
|
+
request: typeof import("./decision.js").request;
|
|
1026
|
+
generate: <const Model extends DecisionModel, const Questions extends DecisionQuestions>(input: DecisionRequestInput<Model, Questions>, options?: RunOptions) => Promise<import("./decision.js").DecisionResponseFor<Questions>>;
|
|
1027
|
+
};
|
|
1028
|
+
dispose: () => Promise<void>;
|
|
1029
|
+
};
|
|
1030
|
+
export * as AI from "./index.js";
|