@opencode/ai 0.0.0-dev-466 → 0.0.0-dev-469
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 +27 -16
- package/dist/cache-policy.d.ts +1 -1
- package/dist/cache-policy.js +2 -2
- package/dist/decision-client.d.ts +3 -3
- package/dist/decision.d.ts +13 -120
- package/dist/decision.js +17 -13
- package/dist/effect.d.ts +8 -6
- package/dist/effect.js +4 -3
- package/dist/effort-updates.d.ts +1 -1
- package/dist/effort-updates.js +2 -2
- package/dist/experimental/cloudflare-run-extraction.d.ts +7 -3
- package/dist/experimental/cloudflare-run-extraction.js +4 -1
- package/dist/experimental/extraction.d.ts +12 -38
- package/dist/experimental/extraction.js +13 -11
- package/dist/experimental.d.ts +8 -8
- package/dist/experimental.js +4 -4
- package/dist/image-client.d.ts +11 -5
- package/dist/image-client.js +1 -1
- package/dist/image.d.ts +21 -62
- package/dist/image.js +16 -13
- package/dist/index.d.ts +20 -14
- package/dist/index.js +6 -3
- package/dist/llm.d.ts +60 -25
- package/dist/llm.js +126 -38
- package/dist/protocols/alibaba-images.d.ts +2 -2
- package/dist/protocols/alibaba-messages.js +3 -3
- package/dist/protocols/anthropic-messages.d.ts +1 -1
- package/dist/protocols/anthropic-messages.js +4 -3
- package/dist/protocols/assemblyai-transcription.d.ts +2 -2
- package/dist/protocols/cartesia-speech.d.ts +2 -2
- package/dist/protocols/cloudflare-workers-ai-images.d.ts +2 -2
- package/dist/protocols/deepgram-speech.d.ts +2 -2
- package/dist/protocols/deepgram-transcription.d.ts +2 -2
- package/dist/protocols/elevenlabs-speech.d.ts +2 -2
- package/dist/protocols/elevenlabs-transcription.d.ts +2 -2
- package/dist/protocols/gemini.js +2 -8
- package/dist/protocols/google-images.d.ts +2 -2
- package/dist/protocols/google-speech.d.ts +2 -2
- package/dist/protocols/google-transcription.d.ts +2 -2
- package/dist/protocols/google-video.d.ts +2 -2
- package/dist/protocols/meta-images.d.ts +2 -2
- package/dist/protocols/meta-responses.js +4 -3
- package/dist/protocols/minimax-images.d.ts +2 -2
- package/dist/protocols/open-responses.d.ts +1 -21
- package/dist/protocols/openai-chat.d.ts +1 -21
- package/dist/protocols/openai-chat.js +7 -9
- package/dist/protocols/openai-decisions.js +1 -1
- package/dist/protocols/openai-images.d.ts +2 -2
- package/dist/protocols/openai-responses.js +0 -1
- package/dist/protocols/openai-speech.d.ts +2 -2
- package/dist/protocols/openai-transcription.d.ts +2 -2
- package/dist/protocols/runway-video.d.ts +2 -2
- package/dist/protocols/shared.d.ts +1 -1
- package/dist/protocols/shared.js +2 -2
- package/dist/protocols/system-one.d.ts +4 -4
- package/dist/protocols/utils/responses-checkpoint.js +1 -1
- package/dist/protocols/utils/responses-compaction.d.ts +1 -1
- package/dist/protocols/utils/responses-compaction.js +4 -3
- package/dist/protocols/utils/tool-stream.d.ts +3 -63
- package/dist/protocols/xai-images.d.ts +2 -2
- package/dist/protocols/xai-video.d.ts +2 -2
- package/dist/protocols/zai-images.d.ts +2 -2
- package/dist/protocols/zai-messages.js +3 -3
- package/dist/provider-error.js +4 -4
- package/dist/providers/vercel-ai-gateway.js +4 -3
- package/dist/route/client.d.ts +43 -19
- package/dist/route/client.js +30 -18
- package/dist/route/decision.d.ts +6 -6
- package/dist/schema/errors.d.ts +1 -2
- package/dist/schema/errors.js +1 -2
- package/dist/schema/events.d.ts +61 -769
- package/dist/schema/events.js +3 -30
- package/dist/schema/messages.d.ts +20 -92
- package/dist/schema/messages.js +1 -52
- package/dist/speech-client.d.ts +5 -5
- package/dist/speech.d.ts +17 -19
- package/dist/speech.js +16 -12
- package/dist/testing.d.ts +8 -168
- package/dist/tool-runtime.js +12 -30
- package/dist/transcription-client.d.ts +5 -5
- package/dist/transcription.d.ts +17 -19
- package/dist/transcription.js +16 -12
- package/dist/video-client.d.ts +5 -5
- package/dist/video-client.js +1 -1
- package/dist/video.d.ts +18 -20
- package/dist/video.js +16 -12
- package/package.json +3 -3
package/dist/experimental.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export { VideoClient } from "./video-client.js";
|
|
2
|
-
export { VideoAspectRatio, VideoEvent, VideoFrames, VideoModel, VideoModelSchema,
|
|
3
|
-
export type { VideoModelOptions, VideoOptions,
|
|
2
|
+
export { VideoAspectRatio, VideoEvent, VideoFrames, VideoModel, VideoModelSchema, VideoResponse } from "./video.js";
|
|
3
|
+
export type { VideoModelOptions, VideoOptions, VideoRequest, VideoRequestInput, VideoResolution, VideoRoute, } from "./video.js";
|
|
4
4
|
export { Video } from "./video.js";
|
|
5
5
|
export { SpeechClient } from "./speech-client.js";
|
|
6
|
-
export { SpeechEvent, SpeechModel, SpeechModelSchema,
|
|
7
|
-
export type { SpeechFormat, SpeechModelOptions, SpeechOptions,
|
|
6
|
+
export { SpeechEvent, SpeechModel, SpeechModelSchema, SpeechResponse, SpeechTimestamp, SpeechVoice } from "./speech.js";
|
|
7
|
+
export type { SpeechFormat, SpeechModelOptions, SpeechOptions, SpeechRequest, SpeechRequestInput, SpeechRoute, } from "./speech.js";
|
|
8
8
|
export { Speech } from "./speech.js";
|
|
9
9
|
export { TranscriptionClient } from "./transcription-client.js";
|
|
10
|
-
export { TranscriptionEvent, TranscriptionModel, TranscriptionModelSchema,
|
|
11
|
-
export type { TranscriptionModelOptions, TranscriptionOptions,
|
|
10
|
+
export { TranscriptionEvent, TranscriptionModel, TranscriptionModelSchema, TranscriptionResponse, TranscriptionSegment, TranscriptionTimestamps, TranscriptionWord, } from "./transcription.js";
|
|
11
|
+
export type { TranscriptionModelOptions, TranscriptionOptions, TranscriptionRequest, TranscriptionRequestInput, TranscriptionRoute, } from "./transcription.js";
|
|
12
12
|
export { Transcription } from "./transcription.js";
|
|
13
|
-
export { Extraction, ExtractionModel,
|
|
14
|
-
export type { ExtractionAnswerFor, ExtractionAnswersFor, ExtractionField, ExtractionFields, ExtractionModelOptions, ExtractionOptions,
|
|
13
|
+
export { Extraction, ExtractionModel, ExtractionResponse } from "./experimental/extraction.js";
|
|
14
|
+
export type { ExtractionAnswerFor, ExtractionAnswersFor, ExtractionField, ExtractionFields, ExtractionModelOptions, ExtractionOptions, ExtractionRequest, ExtractionRequestInput, ExtractionResponseFor, ExtractionRoute, } from "./experimental/extraction.js";
|
|
15
15
|
export { Realtime } from "./experimental/realtime.js";
|
|
16
16
|
export type { RealtimeConnectInput, RealtimeSession, RealtimeTransport, RealtimeTransportInput, RealtimeTransportType, } from "./experimental/realtime.js";
|
package/dist/experimental.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { VideoClient } from "./video-client.js";
|
|
2
|
-
export { VideoAspectRatio, VideoEvent, VideoFrames, VideoModel, VideoModelSchema,
|
|
2
|
+
export { VideoAspectRatio, VideoEvent, VideoFrames, VideoModel, VideoModelSchema, VideoResponse } from "./video.js";
|
|
3
3
|
export { Video } from "./video.js";
|
|
4
4
|
export { SpeechClient } from "./speech-client.js";
|
|
5
|
-
export { SpeechEvent, SpeechModel, SpeechModelSchema,
|
|
5
|
+
export { SpeechEvent, SpeechModel, SpeechModelSchema, SpeechResponse, SpeechTimestamp, SpeechVoice } from "./speech.js";
|
|
6
6
|
export { Speech } from "./speech.js";
|
|
7
7
|
export { TranscriptionClient } from "./transcription-client.js";
|
|
8
|
-
export { TranscriptionEvent, TranscriptionModel, TranscriptionModelSchema,
|
|
8
|
+
export { TranscriptionEvent, TranscriptionModel, TranscriptionModelSchema, TranscriptionResponse, TranscriptionSegment, TranscriptionTimestamps, TranscriptionWord, } from "./transcription.js";
|
|
9
9
|
export { Transcription } from "./transcription.js";
|
|
10
|
-
export { Extraction, ExtractionModel,
|
|
10
|
+
export { Extraction, ExtractionModel, ExtractionResponse } from "./experimental/extraction.js";
|
|
11
11
|
export { Realtime } from "./experimental/realtime.js";
|
package/dist/image-client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context } from "effect";
|
|
2
2
|
import { MediaClient } from "./media-client.js";
|
|
3
|
-
import { type ImageEvent, type
|
|
4
|
-
export type Interface = MediaClient.Interface<
|
|
3
|
+
import { type ImageEvent, type ImageRequest, type ImageResponse } from "./image.js";
|
|
4
|
+
export type Interface = MediaClient.Interface<ImageRequest, ImageEvent, ImageResponse>;
|
|
5
5
|
declare const ImageClientService_base: Context.ServiceClass<ImageClientService, "@opencode/ImageClient", Interface>;
|
|
6
6
|
export declare class ImageClientService extends ImageClientService_base {
|
|
7
7
|
}
|
|
@@ -54,8 +54,12 @@ export declare const ImageClient: {
|
|
|
54
54
|
} | undefined;
|
|
55
55
|
})[];
|
|
56
56
|
readonly layer: import("effect/Layer").Layer<ImageClientService, never, import("./route.js").RequestExecutorService>;
|
|
57
|
-
readonly generate: (request:
|
|
58
|
-
|
|
57
|
+
readonly generate: (request: ImageRequest<import("./image.js").ImageModel<{
|
|
58
|
+
readonly [x: string]: unknown;
|
|
59
|
+
}>>, options?: import("./generation.js").AwaitOptions) => import("effect/Effect").Effect<ImageResponse, import("./effect.js").AIError, ImageClientService>;
|
|
60
|
+
readonly stream: (request: ImageRequest<import("./image.js").ImageModel<{
|
|
61
|
+
readonly [x: string]: unknown;
|
|
62
|
+
}>>, options?: import("./generation.js").AwaitOptions) => import("effect/Stream").Stream<{
|
|
59
63
|
readonly type: "image-partial";
|
|
60
64
|
readonly index: number;
|
|
61
65
|
readonly image: import("./media.js").Asset;
|
|
@@ -92,7 +96,9 @@ export declare const ImageClient: {
|
|
|
92
96
|
};
|
|
93
97
|
} | undefined;
|
|
94
98
|
} | import("./generation.js").Observation, import("./effect.js").AIError, ImageClientService>;
|
|
95
|
-
readonly start: (request:
|
|
99
|
+
readonly start: (request: ImageRequest<import("./image.js").ImageModel<{
|
|
100
|
+
readonly [x: string]: unknown;
|
|
101
|
+
}>>) => import("effect/Effect").Effect<import("./generation.js").Generation<ImageResponse>, import("./effect.js").AIError, ImageClientService>;
|
|
96
102
|
readonly resume: (model: import("./image.js").ImageModel<{
|
|
97
103
|
readonly [x: string]: unknown;
|
|
98
104
|
}>, token: unknown) => import("effect/Effect").Effect<import("./generation.js").Generation<ImageResponse>, import("./effect.js").AIError, ImageClientService>;
|
package/dist/image-client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context } from "effect";
|
|
2
2
|
import { MediaClient } from "./media-client.js";
|
|
3
|
-
import { ImageOutputEvent, ImageFinishEvent
|
|
3
|
+
import { ImageOutputEvent, ImageFinishEvent } from "./image.js";
|
|
4
4
|
export class ImageClientService extends Context.Service()("@opencode/ImageClient") {
|
|
5
5
|
}
|
|
6
6
|
export const Service = ImageClientService;
|
package/dist/image.d.ts
CHANGED
|
@@ -6,13 +6,13 @@ import { MediaRoute } from "./route/media.js";
|
|
|
6
6
|
import { AIError, HttpOptions, type OpenString } from "./schema/index.js";
|
|
7
7
|
import { Service } from "./image-client.js";
|
|
8
8
|
export type ImageOptions = MediaModel.Options;
|
|
9
|
-
export type ImageRoute = MediaRoute.AnyRoute<
|
|
9
|
+
export type ImageRoute = MediaRoute.AnyRoute<ImageRequest, ImageEvent, ImageResponse>;
|
|
10
10
|
export declare class ImageModel<Options extends ImageOptions = ImageOptions> extends MediaModel<ImageRoute, Options> {
|
|
11
11
|
protected readonly _ImageModel: void;
|
|
12
12
|
/** The number of type arguments selects the kind: `<Options>`, `<Options, Frame, State>`, or `<Options, Token>`. */
|
|
13
|
-
static fromRoute<Options extends ImageOptions>(route: MediaModel.InlineRouteInput<
|
|
14
|
-
static fromRoute<Options extends ImageOptions, Frame, State>(route: MediaModel.StreamRouteInput<
|
|
15
|
-
static fromRoute<Options extends ImageOptions, Token>(route: MediaModel.QueuedRouteInput<
|
|
13
|
+
static fromRoute<Options extends ImageOptions>(route: MediaModel.InlineRouteInput<ImageRequest<ImageModel<Options>>, ImageResponse>, input: MediaRoute.ModelInput): ImageModel<Options>;
|
|
14
|
+
static fromRoute<Options extends ImageOptions, Frame, State>(route: MediaModel.StreamRouteInput<ImageRequest<ImageModel<Options>>, ImageEvent, Frame, State>, input: MediaRoute.ModelInput): ImageModel<Options>;
|
|
15
|
+
static fromRoute<Options extends ImageOptions, Token>(route: MediaModel.QueuedRouteInput<ImageRequest<ImageModel<Options>>, ImageResponse, Token>, input: MediaRoute.ModelInput): ImageModel<Options>;
|
|
16
16
|
}
|
|
17
17
|
export declare const ImageModelSchema: Schema.declare<ImageModel<{
|
|
18
18
|
readonly [x: string]: unknown;
|
|
@@ -23,62 +23,21 @@ export type ImageAspectRatio = Media.AspectRatio;
|
|
|
23
23
|
export declare const ImageAspectRatio: Schema.declare<`${number}:${number}`, `${number}:${number}`>;
|
|
24
24
|
/** Size tier: `1K` is about as many pixels as 1024×1024 at the requested aspect, `2K` as 2048×2048. */
|
|
25
25
|
export type ImageResolution = OpenString<"1K" | "2K" | "4K">;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
readonly [x: string]: unknown;
|
|
31
|
-
}>>;
|
|
32
|
-
readonly prompt: Schema.String;
|
|
26
|
+
/** A normalized image request, the plain object `ai.image.request(...)` returns. */
|
|
27
|
+
export interface ImageRequest<Model extends ImageModel = ImageModel> {
|
|
28
|
+
readonly model: Model;
|
|
29
|
+
readonly prompt: string;
|
|
33
30
|
/** Edit sources or style/subject references, in order. */
|
|
34
|
-
readonly images
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
readonly type: Schema.Literal<"base64">;
|
|
41
|
-
readonly data: Schema.String;
|
|
42
|
-
readonly mediaType: Schema.String;
|
|
43
|
-
}>, Schema.Struct<{
|
|
44
|
-
readonly type: Schema.Literal<"url">;
|
|
45
|
-
readonly url: Schema.String;
|
|
46
|
-
readonly mediaType: Schema.optional<Schema.String>;
|
|
47
|
-
readonly expiresAt: Schema.optional<Schema.Number>;
|
|
48
|
-
}>, Schema.Struct<{
|
|
49
|
-
readonly type: Schema.Literal<"ref">;
|
|
50
|
-
readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
|
|
51
|
-
readonly id: Schema.String;
|
|
52
|
-
readonly mediaType: Schema.optional<Schema.String>;
|
|
53
|
-
}>]>;
|
|
54
|
-
readonly info: Schema.optional<Schema.Struct<{
|
|
55
|
-
readonly width: Schema.optional<Schema.Number>;
|
|
56
|
-
readonly height: Schema.optional<Schema.Number>;
|
|
57
|
-
readonly durationSeconds: Schema.optional<Schema.Number>;
|
|
58
|
-
readonly sampleRate: Schema.optional<Schema.Number>;
|
|
59
|
-
readonly channels: Schema.optional<Schema.Number>;
|
|
60
|
-
readonly encoding: Schema.optional<Schema.String>;
|
|
61
|
-
readonly format: Schema.optional<Schema.String>;
|
|
62
|
-
}>>;
|
|
63
|
-
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
64
|
-
}>, never, never>>>;
|
|
65
|
-
readonly n: Schema.optional<Schema.Int>;
|
|
66
|
-
readonly aspect: Schema.optional<Schema.declare<`${number}:${number}`, `${number}:${number}`>>;
|
|
67
|
-
readonly resolution: Schema.optional<Schema.String>;
|
|
68
|
-
readonly providerOptions: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
69
|
-
readonly http: Schema.optional<typeof HttpOptions>;
|
|
70
|
-
}>, {}>;
|
|
71
|
-
export declare class ImageRequest extends ImageRequest_base {
|
|
72
|
-
protected readonly _ImageRequest: void;
|
|
31
|
+
readonly images?: ReadonlyArray<Media.Asset>;
|
|
32
|
+
readonly n?: number;
|
|
33
|
+
readonly aspect?: ImageAspectRatio;
|
|
34
|
+
readonly resolution?: ImageResolution;
|
|
35
|
+
readonly providerOptions?: ImageModelOptions<Model>;
|
|
36
|
+
readonly http?: HttpOptions;
|
|
73
37
|
}
|
|
74
|
-
export type ImageRequestFor<Options extends ImageOptions = ImageOptions> = Omit<ImageRequest, "model" | "providerOptions"> & {
|
|
75
|
-
readonly model: ImageModel<Options>;
|
|
76
|
-
readonly providerOptions?: Options;
|
|
77
|
-
};
|
|
78
38
|
export type ImageModelOptions<Model> = Model extends ImageModel<infer Options> ? Options : never;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
readonly resolution?: ImageResolution;
|
|
39
|
+
/** Input accepted by `ai.image.request`, `generate`, `stream` and `start`. An `ImageRequest` is also a valid input. */
|
|
40
|
+
export type ImageRequestInput<Model extends ImageModel = ImageModel> = Omit<ImageRequest<Model>, "providerOptions" | "http"> & {
|
|
82
41
|
readonly providerOptions?: NoInfer<ImageModelOptions<Model>>;
|
|
83
42
|
readonly http?: HttpOptions.Input;
|
|
84
43
|
};
|
|
@@ -1341,12 +1300,12 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
1341
1300
|
};
|
|
1342
1301
|
};
|
|
1343
1302
|
export type ImageEvent = Schema.Schema.Type<typeof imageEventTagged>;
|
|
1344
|
-
|
|
1345
|
-
export declare
|
|
1346
|
-
export declare function generate<const Model extends ImageModel>(input:
|
|
1347
|
-
export declare function stream<const Model extends ImageModel>(input:
|
|
1303
|
+
/** Normalize image request input into a plain `ImageRequest`. */
|
|
1304
|
+
export declare const request: <const Model extends ImageModel>(input: ImageRequestInput<Model>) => ImageRequest<Model>;
|
|
1305
|
+
export declare function generate<const Model extends ImageModel>(input: ImageRequestInput<Model>, options?: AwaitOptions): Effect.Effect<ImageResponse, AIError, Service>;
|
|
1306
|
+
export declare function stream<const Model extends ImageModel>(input: ImageRequestInput<Model>, options?: AwaitOptions): Stream.Stream<ImageEvent, AIError, Service>;
|
|
1348
1307
|
/** Inline and streaming routes fail with `UnsupportedOperation`. */
|
|
1349
|
-
export declare function start<const Model extends ImageModel>(input:
|
|
1308
|
+
export declare function start<const Model extends ImageModel>(input: ImageRequestInput<Model>): Effect.Effect<Generation<ImageResponse>, AIError, Service>;
|
|
1350
1309
|
export declare const resume: (model: ImageModel, token: unknown) => Effect.Effect<Generation<ImageResponse>, AIError, Service>;
|
|
1351
1310
|
export declare const Image: {
|
|
1352
1311
|
readonly request: typeof request;
|
package/dist/image.js
CHANGED
|
@@ -20,18 +20,16 @@ export const ImageModelSchema = Schema.declare((value) => value instanceof Image
|
|
|
20
20
|
expected: "Image.Model",
|
|
21
21
|
});
|
|
22
22
|
export const ImageAspectRatio = Media.AspectRatio;
|
|
23
|
-
|
|
23
|
+
const ImageRequestSchema = Schema.Struct({
|
|
24
24
|
model: ImageModelSchema,
|
|
25
25
|
prompt: Schema.String,
|
|
26
|
-
/** Edit sources or style/subject references, in order. */
|
|
27
26
|
images: Schema.optional(Schema.Array(Media.AssetSchema)),
|
|
28
27
|
n: Schema.optional(Schema.Int),
|
|
29
28
|
aspect: Schema.optional(ImageAspectRatio),
|
|
30
29
|
resolution: Schema.optional(Schema.String),
|
|
31
30
|
providerOptions: Schema.optional(ProviderOptions),
|
|
32
31
|
http: Schema.optional(HttpOptions),
|
|
33
|
-
})
|
|
34
|
-
}
|
|
32
|
+
});
|
|
35
33
|
// ---------------------------------------------------------------------------
|
|
36
34
|
// Response and events
|
|
37
35
|
// ---------------------------------------------------------------------------
|
|
@@ -87,15 +85,20 @@ const collectResponse = (events) => {
|
|
|
87
85
|
providerMetadata: finish.providerMetadata,
|
|
88
86
|
}));
|
|
89
87
|
};
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
const
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
// Request-shaped call API
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
/** Normalize image request input into a plain `ImageRequest`. */
|
|
92
|
+
export const request = (input) => ({
|
|
93
|
+
...input,
|
|
94
|
+
http: HttpOptions.make(input.http),
|
|
95
|
+
});
|
|
96
|
+
const validate = Schema.decodeUnknownSync(ImageRequestSchema);
|
|
97
|
+
const requestEffect = (input) => tryRequest(() => {
|
|
98
|
+
const normalized = request(input);
|
|
99
|
+
validate(normalized);
|
|
100
|
+
return normalized;
|
|
101
|
+
});
|
|
99
102
|
export function generate(input, options) {
|
|
100
103
|
return requestEffect(input).pipe(Effect.flatMap((request) => ImageClient.generate(request, options)));
|
|
101
104
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ import { LLM } from "./llm.js";
|
|
|
7
7
|
import { Media } from "./media.js";
|
|
8
8
|
import { type CheckpointRequest, type CompactionRequest, type EndpointCompactOptions, type StreamOptions, type TriggerCompactOptions } from "./route/client.js";
|
|
9
9
|
import { RequestExecutor } from "./route/executor.js";
|
|
10
|
-
import { LanguageModel, type CompactionCheckpointResponse, type CompactionResponse, type LLMEvent, type
|
|
11
|
-
import type {
|
|
10
|
+
import { LanguageModel, type CompactionCheckpointResponse, type CompactionResponse, type LLMEvent, type LLMResponse } from "./schema/index.js";
|
|
11
|
+
import type { LoopObjectEvent, ObjectEvent, ObjectResponse, OutputSchema, OutputType, LLMLoopInput, LLMRequestInput } from "./llm.js";
|
|
12
12
|
import { type SpeechModel, type SpeechRequest, type SpeechRequestInput } from "./speech.js";
|
|
13
13
|
import { type TranscriptionModel, type TranscriptionRequest, type TranscriptionRequestInput } from "./transcription.js";
|
|
14
14
|
import type { NoExecute, ToolExecuteContext, ToolInput, ToolInputType, ToolOptions, ToolSchema } from "./tool.js";
|
|
@@ -56,20 +56,25 @@ export declare const make: (options?: Options) => {
|
|
|
56
56
|
write: (asset: Media.Asset, path: string, options?: RunOptions) => Promise<void>;
|
|
57
57
|
request: typeof LLM.request;
|
|
58
58
|
generate: {
|
|
59
|
-
<const Model extends LanguageModel, S extends OutputSchema>(input:
|
|
60
|
-
|
|
59
|
+
<const Model extends LanguageModel, S extends OutputSchema>(input: LLMRequestInput<Model> & {
|
|
60
|
+
readonly schema: S;
|
|
61
|
+
}, options?: StreamOptions & RunOptions): Promise<ObjectResponse<OutputType<S>>>;
|
|
62
|
+
<const Model extends LanguageModel>(input: LLMRequestInput<Model>, options?: StreamOptions & RunOptions): Promise<LLMResponse>;
|
|
61
63
|
};
|
|
62
64
|
stream: {
|
|
63
|
-
<const Model extends LanguageModel, S extends OutputSchema>(input:
|
|
64
|
-
|
|
65
|
+
<const Model extends LanguageModel, S extends OutputSchema>(input: LLMRequestInput<Model> & {
|
|
66
|
+
readonly schema: S;
|
|
67
|
+
}, options?: StreamOptions & RunOptions): AsyncIterable<ObjectEvent<OutputType<S>>>;
|
|
68
|
+
<const Model extends LanguageModel>(input: LLMRequestInput<Model>, options?: StreamOptions & RunOptions): AsyncIterable<LLMEvent>;
|
|
65
69
|
};
|
|
66
70
|
/** Stream model calls, running their tool calls, until the model stops calling tools or `until` is true. */
|
|
67
71
|
loop: {
|
|
68
|
-
<const Model extends LanguageModel, S extends OutputSchema>(input:
|
|
72
|
+
<const Model extends LanguageModel, S extends OutputSchema>(input: LLMLoopInput<Model> & {
|
|
69
73
|
readonly schema: S;
|
|
70
74
|
}, options?: StreamOptions & RunOptions): AsyncIterable<LoopObjectEvent<OutputType<S>>>;
|
|
71
|
-
<const Model extends LanguageModel>(input:
|
|
75
|
+
<const Model extends LanguageModel>(input: LLMLoopInput<Model>, options?: StreamOptions & RunOptions): AsyncIterable<LLMEvent>;
|
|
72
76
|
};
|
|
77
|
+
collect: <Event extends LLMEvent>(events: AsyncIterable<Event>, options?: RunOptions) => Promise<LLM.CollectResult<Event>>;
|
|
73
78
|
/** Compact a Responses request: a replacement window, or a checkpoint with `mechanism: "trigger"`. */
|
|
74
79
|
compact: {
|
|
75
80
|
(request: CheckpointRequest, options: TriggerCompactOptions & RunOptions): Promise<CompactionCheckpointResponse>;
|
|
@@ -314,13 +319,14 @@ export declare const tool: <Input extends ToolInput = typeof Schema.Unknown, Suc
|
|
|
314
319
|
export declare const ai: Omit<Client, "dispose">;
|
|
315
320
|
export * as AI from "./index.js";
|
|
316
321
|
export { isContextOverflow, isContextOverflowFailure, isRetryable } from "./provider-error.js";
|
|
317
|
-
export { ProtocolID, RouteID, ModelID, ProviderID, ResponseID, ContentBlockID, ToolCallID, JsonSchema, ProviderOptions, ProviderMetadata, HttpTimeout, RequestEncoding, HttpOptions, GenerationOptions, LanguageModelDefaults, ReasoningEfforts, ReasoningEffort, LanguageModelCompatibility, LanguageModel, LanguageModelSchema, CacheTTL, CacheHint, CachePolicyObject, CachePolicy, MessageRole, SystemPart, TextPart, MediaPart, ToolResultValue, ToolOutput, ToolCallPart, ToolResultPart, ReasoningPart, CompactionPart, EffortPart, ContentPart, Message, Freeform, ToolDefinition, ToolNamespace, ToolEntry, ToolChoice,
|
|
318
|
-
export type { GenerationOptionsFields, GenerationOptionsInput, LanguageModelInput, LanguageModelProviderOptions, ToolDefinitionInput, ToolNamespaceInput, ToolNamespaceEntryInput, ToolEntryInput, UsageInput, } from "./schema/index.js";
|
|
319
|
-
export { ImageAspectRatio, ImageEvent, ImageModel, ImageModelSchema,
|
|
320
|
-
export type { ImageModelOptions, ImageOptions,
|
|
321
|
-
export { ChoiceAnswer, ChoiceQuestion, ChoiceValue, DecisionAnswer, DecisionJsonPart, DecisionMediaPart, DecisionModel, DecisionModelCompatibility, DecisionModelSchema, DecisionPart, DecisionQuestion,
|
|
322
|
-
export type { AnswerFor, AnswersFor, DecisionInput, DecisionModelOptions, DecisionOptions, DecisionQuestions,
|
|
322
|
+
export { ProtocolID, RouteID, ModelID, ProviderID, ResponseID, ContentBlockID, ToolCallID, JsonSchema, ProviderOptions, ProviderMetadata, HttpTimeout, RequestEncoding, HttpOptions, GenerationOptions, LanguageModelDefaults, ReasoningEfforts, ReasoningEffort, LanguageModelCompatibility, LanguageModel, LanguageModelSchema, CacheTTL, CacheHint, CachePolicyObject, CachePolicy, MessageRole, SystemPart, TextPart, MediaPart, ToolResultValue, ToolOutput, ToolCallPart, ToolResultPart, ReasoningPart, CompactionPart, EffortPart, ContentPart, Message, Freeform, ToolDefinition, ToolNamespace, ToolEntry, ToolChoice, FinishReason, Usage, MediaUsage, CompactionResponse, CompactionCheckpointResponse, StepStart, TextStart, TextDelta, TextEnd, ReasoningStart, ReasoningDelta, ReasoningEnd, ToolInputStart, ToolInputDelta, ToolInputEnd, ToolInputError, ToolCall, ToolResult, FinishReasonDetails, StepFinish, Finish, MediaEvent, RawEvent, LLMEvent, LLMResponse, HttpContext, HttpRateLimitDetails, InvalidRequestError, UnsupportedOperationError, ProviderConfigurationError, AuthenticationError, RateLimitError, QuotaExceededError, ContentPolicyError, ProviderInternalError, TransportType, TransportOperation, TransportError, InvalidProviderOutputError, UnknownProviderError, TimeoutError, AIErrorReason, AIError, } from "./schema/index.js";
|
|
323
|
+
export type { GenerationOptionsFields, GenerationOptionsInput, LanguageModelInput, LanguageModelProviderOptions, LLMRequest, ToolDefinitionInput, ToolNamespaceInput, ToolNamespaceEntryInput, ToolEntryInput, UsageInput, } from "./schema/index.js";
|
|
324
|
+
export { ImageAspectRatio, ImageEvent, ImageModel, ImageModelSchema, ImageResponse } from "./image.js";
|
|
325
|
+
export type { ImageModelOptions, ImageOptions, ImageRequest, ImageRequestInput, ImageResolution, ImageRoute, } from "./image.js";
|
|
326
|
+
export { ChoiceAnswer, ChoiceQuestion, ChoiceValue, DecisionAnswer, DecisionJsonPart, DecisionMediaPart, DecisionModel, DecisionModelCompatibility, DecisionModelSchema, DecisionPart, DecisionQuestion, DecisionResponse, DecisionTextPart, DecisionUsage, ErrorAnswer, ErrorReason, PredicateAnswer, PredicateQuestion, ScoreAnswer, ScoreQuestion, } from "./decision.js";
|
|
327
|
+
export type { AnswerFor, AnswersFor, DecisionInput, DecisionModelOptions, DecisionOptions, DecisionQuestions, DecisionRequest, DecisionRequestInput, DecisionResponseFor, DecisionModelRoute, } from "./decision.js";
|
|
323
328
|
export { Media } from "./media.js";
|
|
324
329
|
export type { AwaitOptions as GenerationAwaitOptions, Event as GenerationEvent, Poll, Route as GenerationRoute, Snapshot as GenerationSnapshot, Status as GenerationStatus, } from "./generation.js";
|
|
325
330
|
export type { ExecutableTool, Tool, ToolExecute, ToolExecuteContext, ToolInput, ToolInputType, ToolModelOutputInput, ToolOptions, ToolSchema, ToolToModelOutput, } from "./tool.js";
|
|
326
331
|
export type { LLM } from "./llm.js";
|
|
332
|
+
export type { LLMLoopInput, LLMRequestInput } from "./llm.js";
|
package/dist/index.js
CHANGED
|
@@ -38,6 +38,8 @@ export const make = (options = {}) => {
|
|
|
38
38
|
function loop(input, options) {
|
|
39
39
|
return iterate(LLM.loop(input, options), options);
|
|
40
40
|
}
|
|
41
|
+
/** Read `events` from `stream` or `loop` to the end and fold them into the final result. */
|
|
42
|
+
const collect = (events, options) => run(LLM.collect(Stream.fromAsyncIterable(events, (error) => error)), options);
|
|
41
43
|
// The overloads pair each request type with its mechanism; `LLM.compact` checks the route's capability at runtime.
|
|
42
44
|
function compact(request, options) {
|
|
43
45
|
return options?.mechanism === "trigger"
|
|
@@ -86,6 +88,7 @@ export const make = (options = {}) => {
|
|
|
86
88
|
stream,
|
|
87
89
|
/** Stream model calls, running their tool calls, until the model stops calling tools or `until` is true. */
|
|
88
90
|
loop,
|
|
91
|
+
collect,
|
|
89
92
|
/** Compact a Responses request: a replacement window, or a checkpoint with `mechanism: "trigger"`. */
|
|
90
93
|
compact,
|
|
91
94
|
canCompact: LLM.canCompact,
|
|
@@ -139,7 +142,7 @@ export const tool = (config) => {
|
|
|
139
142
|
export const ai = make();
|
|
140
143
|
export * as AI from "./index.js";
|
|
141
144
|
export { isContextOverflow, isContextOverflowFailure, isRetryable } from "./provider-error.js";
|
|
142
|
-
export { ProtocolID, RouteID, ModelID, ProviderID, ResponseID, ContentBlockID, ToolCallID, JsonSchema, ProviderOptions, ProviderMetadata, HttpTimeout, RequestEncoding, HttpOptions, GenerationOptions, LanguageModelDefaults, ReasoningEfforts, ReasoningEffort, LanguageModelCompatibility, LanguageModel, LanguageModelSchema, CacheTTL, CacheHint, CachePolicyObject, CachePolicy, MessageRole, SystemPart, TextPart, MediaPart, ToolResultValue, ToolOutput, ToolCallPart, ToolResultPart, ReasoningPart, CompactionPart, EffortPart, ContentPart, Message, Freeform, ToolDefinition, ToolNamespace, ToolEntry, ToolChoice,
|
|
143
|
-
export { ImageAspectRatio, ImageEvent, ImageModel, ImageModelSchema,
|
|
144
|
-
export { ChoiceAnswer, ChoiceQuestion, ChoiceValue, DecisionAnswer, DecisionJsonPart, DecisionMediaPart, DecisionModel, DecisionModelCompatibility, DecisionModelSchema, DecisionPart, DecisionQuestion,
|
|
145
|
+
export { ProtocolID, RouteID, ModelID, ProviderID, ResponseID, ContentBlockID, ToolCallID, JsonSchema, ProviderOptions, ProviderMetadata, HttpTimeout, RequestEncoding, HttpOptions, GenerationOptions, LanguageModelDefaults, ReasoningEfforts, ReasoningEffort, LanguageModelCompatibility, LanguageModel, LanguageModelSchema, CacheTTL, CacheHint, CachePolicyObject, CachePolicy, MessageRole, SystemPart, TextPart, MediaPart, ToolResultValue, ToolOutput, ToolCallPart, ToolResultPart, ReasoningPart, CompactionPart, EffortPart, ContentPart, Message, Freeform, ToolDefinition, ToolNamespace, ToolEntry, ToolChoice, FinishReason, Usage, MediaUsage, CompactionResponse, CompactionCheckpointResponse, StepStart, TextStart, TextDelta, TextEnd, ReasoningStart, ReasoningDelta, ReasoningEnd, ToolInputStart, ToolInputDelta, ToolInputEnd, ToolInputError, ToolCall, ToolResult, FinishReasonDetails, StepFinish, Finish, MediaEvent, RawEvent, LLMEvent, LLMResponse, HttpContext, HttpRateLimitDetails, InvalidRequestError, UnsupportedOperationError, ProviderConfigurationError, AuthenticationError, RateLimitError, QuotaExceededError, ContentPolicyError, ProviderInternalError, TransportType, TransportOperation, TransportError, InvalidProviderOutputError, UnknownProviderError, TimeoutError, AIErrorReason, AIError, } from "./schema/index.js";
|
|
146
|
+
export { ImageAspectRatio, ImageEvent, ImageModel, ImageModelSchema, ImageResponse } from "./image.js";
|
|
147
|
+
export { ChoiceAnswer, ChoiceQuestion, ChoiceValue, DecisionAnswer, DecisionJsonPart, DecisionMediaPart, DecisionModel, DecisionModelCompatibility, DecisionModelSchema, DecisionPart, DecisionQuestion, DecisionResponse, DecisionTextPart, DecisionUsage, ErrorAnswer, ErrorReason, PredicateAnswer, PredicateQuestion, ScoreAnswer, ScoreQuestion, } from "./decision.js";
|
|
145
148
|
export { Media } from "./media.js";
|
package/dist/llm.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Effect, JsonSchema, Schema, Stream } from "effect";
|
|
2
|
-
import { Service, type StreamOptions } from "./route/client.js";
|
|
3
|
-
import { GenerationOptions, HttpOptions, AIError, LLMEvent,
|
|
2
|
+
import { Service, canCompact, type CheckpointRequest, type CompactionRequest, type EndpointCompactOptions, type StreamOptions, type TriggerCompactOptions } from "./route/client.js";
|
|
3
|
+
import { GenerationOptions, HttpOptions, AIError, LLMEvent, LLMResponse, Message, LanguageModel, SystemPart, type CachePolicy, type CompactionCheckpointResponse, type CompactionResponse, type Finish, type FinishReasonDetails, ToolChoice, Usage, type ContentPart, type LanguageModelProviderOptions, type LLMRequest, type ToolEntryInput } from "./schema/index.js";
|
|
4
4
|
import { type ExecutableTool, type Tool, type ToolSchema } from "./tool.js";
|
|
5
|
-
/** Input accepted by `
|
|
6
|
-
export type
|
|
5
|
+
/** Input accepted by `ai.request`, `ai.generate`, `ai.stream` and `ai.compact`. An `LLMRequest` is also a valid input. */
|
|
6
|
+
export type LLMRequestInput<Model extends LanguageModel = LanguageModel> = TextRequestFields<Model> & PromptOrMessages;
|
|
7
7
|
/** Exactly one of `prompt`, a single user message, or `messages`, the full conversation. */
|
|
8
8
|
export type PromptOrMessages = {
|
|
9
9
|
readonly prompt: string | ContentPart | ReadonlyArray<ContentPart>;
|
|
@@ -12,22 +12,26 @@ export type PromptOrMessages = {
|
|
|
12
12
|
readonly messages: ReadonlyArray<Message | Message.Input>;
|
|
13
13
|
readonly prompt?: never;
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
readonly
|
|
15
|
+
interface TextRequestFields<Model extends LanguageModel> {
|
|
16
|
+
readonly id?: string;
|
|
17
|
+
readonly model: Model;
|
|
17
18
|
readonly system?: string | SystemPart | ReadonlyArray<SystemPart>;
|
|
18
19
|
/** Sent in array order. Pass `tool(...)` values or wire entries such as hosted provider tools. */
|
|
19
20
|
readonly tools?: ReadonlyArray<Tool | ToolEntryInput>;
|
|
20
21
|
readonly toolChoice?: ToolChoice.Input;
|
|
21
22
|
readonly generation?: GenerationOptions.Input;
|
|
22
|
-
readonly providerOptions?: NoInfer<LanguageModelProviderOptions<
|
|
23
|
+
readonly providerOptions?: NoInfer<LanguageModelProviderOptions<Model>>;
|
|
23
24
|
readonly http?: HttpOptions.Input;
|
|
24
|
-
|
|
25
|
+
readonly cache?: CachePolicy;
|
|
26
|
+
/** Stable cache affinity for protocols that support provider-managed prompt caching. */
|
|
27
|
+
readonly promptCacheKey?: string;
|
|
28
|
+
readonly metadata?: Record<string, unknown>;
|
|
29
|
+
/** Emit a `raw` event with each provider frame before the events parsed from it. */
|
|
30
|
+
readonly includeRaw?: boolean;
|
|
31
|
+
}
|
|
25
32
|
/** An Effect Schema decodes and types `object`; a raw JSON Schema leaves it `unknown`. */
|
|
26
33
|
export type OutputSchema = ToolSchema<any> | JsonSchema.JsonSchema;
|
|
27
34
|
export type OutputType<S extends OutputSchema> = S extends Schema.Top ? Schema.Schema.Type<S> : unknown;
|
|
28
|
-
export type ObjectInput<S extends OutputSchema, SelectedLanguageModel extends LanguageModel = LanguageModel> = RequestInput<SelectedLanguageModel> & {
|
|
29
|
-
readonly schema: S;
|
|
30
|
-
};
|
|
31
35
|
export type ObjectResponse<T> = LLMResponse & {
|
|
32
36
|
readonly object: T;
|
|
33
37
|
};
|
|
@@ -35,17 +39,24 @@ export type ObjectResponse<T> = LLMResponse & {
|
|
|
35
39
|
export type ObjectEvent<T> = Exclude<LLMEvent, Finish> | (Finish & {
|
|
36
40
|
readonly object: T;
|
|
37
41
|
});
|
|
38
|
-
/** Loop events for a request with `schema`: the
|
|
42
|
+
/** Loop events for a request with `schema`: the loop's `finish` event carries the decoded `object`. */
|
|
39
43
|
export type LoopObjectEvent<T> = Exclude<LLMEvent, Finish> | (Finish & {
|
|
40
44
|
readonly object?: T;
|
|
41
45
|
});
|
|
42
46
|
/** Run one model call. With `schema`, the model must answer through a forced tool call decoded into `object`. */
|
|
43
|
-
export declare function generate<const Model extends LanguageModel, S extends OutputSchema>(input:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
export declare function
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
export declare function generate<const Model extends LanguageModel, S extends OutputSchema>(input: LLMRequestInput<Model> & {
|
|
48
|
+
readonly schema: S;
|
|
49
|
+
}, options?: StreamOptions): Effect.Effect<ObjectResponse<OutputType<S>>, AIError, Service>;
|
|
50
|
+
export declare function generate<const Model extends LanguageModel>(input: LLMRequestInput<Model>, options?: StreamOptions): Effect.Effect<LLMResponse, AIError, Service>;
|
|
51
|
+
/**
|
|
52
|
+
* Stream one model call. The `finish` event carries the assistant `message` and `usage`; with `schema`, also the
|
|
53
|
+
* decoded `object`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function stream<const Model extends LanguageModel, S extends OutputSchema>(input: LLMRequestInput<Model> & {
|
|
56
|
+
readonly schema: S;
|
|
57
|
+
}, options?: StreamOptions): Stream.Stream<ObjectEvent<OutputType<S>>, AIError, Service>;
|
|
58
|
+
export declare function stream<const Model extends LanguageModel>(input: LLMRequestInput<Model>, options?: StreamOptions): Stream.Stream<LLMEvent, AIError, Service>;
|
|
59
|
+
export type LLMLoopInput<Model extends LanguageModel = LanguageModel> = Omit<TextRequestFields<Model>, "tools"> & PromptOrMessages & {
|
|
49
60
|
readonly tools: ReadonlyArray<ExecutableTool>;
|
|
50
61
|
/** Called after each step that has tool calls; returning `true` ends the loop without running them. */
|
|
51
62
|
readonly until?: (state: {
|
|
@@ -53,14 +64,38 @@ export type LoopInput<SelectedLanguageModel extends LanguageModel = LanguageMode
|
|
|
53
64
|
}) => boolean;
|
|
54
65
|
};
|
|
55
66
|
/**
|
|
56
|
-
* Stream model calls, running the model's tool calls between them, until a step has no client-executed tool calls
|
|
57
|
-
*
|
|
58
|
-
*
|
|
67
|
+
* Stream model calls, running the model's tool calls between them, until a step has no client-executed tool calls or
|
|
68
|
+
* `until` returns `true`. Each step's `step-start` and `step-finish` carry its step index and usage; one `finish` ends
|
|
69
|
+
* the loop with the final step's reason and `message` and the usage summed across steps. With `schema`, the model ends
|
|
70
|
+
* by calling the hidden answer tool, decoded into `object` on the `finish`.
|
|
59
71
|
*/
|
|
60
|
-
export declare function loop<const Model extends LanguageModel, S extends OutputSchema>(input:
|
|
72
|
+
export declare function loop<const Model extends LanguageModel, S extends OutputSchema>(input: LLMLoopInput<Model> & {
|
|
61
73
|
readonly schema: S;
|
|
62
74
|
}, options?: StreamOptions): Stream.Stream<LoopObjectEvent<OutputType<S>>, AIError, Service>;
|
|
63
|
-
export declare function loop<const Model extends LanguageModel>(input:
|
|
64
|
-
|
|
65
|
-
export
|
|
75
|
+
export declare function loop<const Model extends LanguageModel>(input: LLMLoopInput<Model>, options?: StreamOptions): Stream.Stream<LLMEvent, AIError, Service>;
|
|
76
|
+
/** The result of `collect`: every step of a stream from `stream` or `loop`, folded into one value. */
|
|
77
|
+
export interface Collected {
|
|
78
|
+
/** Text of the final step. */
|
|
79
|
+
readonly text: string;
|
|
80
|
+
/** One response per model call, in order. */
|
|
81
|
+
readonly steps: ReadonlyArray<LLMResponse>;
|
|
82
|
+
/** Each step's assistant message followed by its tool results, ready to append to the request's messages. */
|
|
83
|
+
readonly messages: ReadonlyArray<Message>;
|
|
84
|
+
/** Usage from the terminal `finish`, summed across steps for a loop. */
|
|
85
|
+
readonly usage?: Usage;
|
|
86
|
+
readonly finishReason: FinishReasonDetails;
|
|
87
|
+
}
|
|
88
|
+
type FinishOf<Event> = Extract<Event, {
|
|
89
|
+
readonly type: "finish";
|
|
90
|
+
}>;
|
|
91
|
+
/** `Collected`, plus `object` when the stream was started with `schema`. */
|
|
92
|
+
export type CollectResult<Event> = "object" extends keyof FinishOf<Event> ? Collected & Pick<FinishOf<Event>, "object"> : Collected;
|
|
93
|
+
/** Run a stream from `stream` or `loop` to the end and fold its events into the final result. */
|
|
94
|
+
export declare function collect<Event extends LLMEvent, E, R>(events: Stream.Stream<Event, E, R>): Effect.Effect<CollectResult<Event>, E | AIError, R>;
|
|
95
|
+
/** Normalize text request input into a plain `LLMRequest`, with `prompt` turned into the one user message. */
|
|
96
|
+
export declare const request: <const Model extends LanguageModel>(input: LLMRequestInput<Model>) => LLMRequest<Model>;
|
|
97
|
+
/** Compact a text request: a replacement window, or a checkpoint with `mechanism: "trigger"`. */
|
|
98
|
+
export declare function compact(input: CheckpointRequest, options: TriggerCompactOptions): Effect.Effect<CompactionCheckpointResponse, AIError, Service>;
|
|
99
|
+
export declare function compact(input: CompactionRequest, options?: EndpointCompactOptions): Effect.Effect<CompactionResponse, AIError, Service>;
|
|
100
|
+
export { canCompact };
|
|
66
101
|
export * as LLM from "./llm.js";
|