@opencode/ai 0.0.0-dev-20120 → 0.0.0-dev-20123

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.
Files changed (128) hide show
  1. package/dist/experimental/evaluation.js +1 -1
  2. package/dist/generation.d.ts +1 -7
  3. package/dist/generation.js +1 -11
  4. package/dist/image.d.ts +2 -2
  5. package/dist/image.js +2 -2
  6. package/dist/llm.js +1 -1
  7. package/dist/media-model.d.ts +0 -2
  8. package/dist/media-model.js +0 -2
  9. package/dist/protocols/alibaba-messages.d.ts +1 -1
  10. package/dist/protocols/anthropic-messages.d.ts +34 -34
  11. package/dist/protocols/assemblyai-transcription.d.ts +2 -1
  12. package/dist/protocols/assemblyai-transcription.js +10 -14
  13. package/dist/protocols/bfl-images.js +15 -31
  14. package/dist/protocols/cartesia-speech.d.ts +2 -2
  15. package/dist/protocols/cartesia-speech.js +10 -16
  16. package/dist/protocols/deepgram-speech.d.ts +3 -3
  17. package/dist/protocols/deepgram-speech.js +7 -11
  18. package/dist/protocols/deepgram-transcription.d.ts +2 -1
  19. package/dist/protocols/deepgram-transcription.js +9 -13
  20. package/dist/protocols/elevenlabs-speech.d.ts +3 -3
  21. package/dist/protocols/elevenlabs-speech.js +9 -13
  22. package/dist/protocols/fal-images.d.ts +2 -1
  23. package/dist/protocols/fal-images.js +16 -29
  24. package/dist/protocols/fal-video.d.ts +2 -2
  25. package/dist/protocols/fal-video.js +9 -24
  26. package/dist/protocols/gemini.d.ts +13 -13
  27. package/dist/protocols/google-images.d.ts +3 -3
  28. package/dist/protocols/google-images.js +11 -21
  29. package/dist/protocols/google-speech.js +7 -13
  30. package/dist/protocols/google-transcription.d.ts +2 -1
  31. package/dist/protocols/google-transcription.js +8 -20
  32. package/dist/protocols/google-video.d.ts +2 -2
  33. package/dist/protocols/google-video.js +14 -30
  34. package/dist/protocols/meta-images.d.ts +3 -4
  35. package/dist/protocols/meta-images.js +12 -21
  36. package/dist/protocols/meta-messages.d.ts +5 -5
  37. package/dist/protocols/meta-responses.js +5 -2
  38. package/dist/protocols/mistral-chat.js +6 -3
  39. package/dist/protocols/openai-images.d.ts +4 -5
  40. package/dist/protocols/openai-images.js +24 -55
  41. package/dist/protocols/openai-responses.js +8 -2
  42. package/dist/protocols/openai-speech.js +7 -11
  43. package/dist/protocols/openai-transcription.js +21 -29
  44. package/dist/protocols/replicate-images.js +11 -17
  45. package/dist/protocols/runway-video.d.ts +3 -3
  46. package/dist/protocols/runway-video.js +10 -16
  47. package/dist/protocols/shared.d.ts +5 -17
  48. package/dist/protocols/shared.js +3 -39
  49. package/dist/protocols/stability-images.d.ts +2 -1
  50. package/dist/protocols/stability-images.js +24 -36
  51. package/dist/protocols/utils/fal-queue.d.ts +1 -3
  52. package/dist/protocols/utils/fal-queue.js +4 -6
  53. package/dist/protocols/utils/media-input.d.ts +15 -1
  54. package/dist/protocols/utils/media-input.js +22 -0
  55. package/dist/protocols/utils/speech-stream.d.ts +3 -3
  56. package/dist/protocols/utils/speech-stream.js +1 -4
  57. package/dist/protocols/utils/tool-schema.js +19 -6
  58. package/dist/protocols/xai-images.d.ts +4 -4
  59. package/dist/protocols/xai-images.js +12 -28
  60. package/dist/protocols/xai-video.js +12 -18
  61. package/dist/protocols/zai-images.d.ts +2 -2
  62. package/dist/protocols/zai-images.js +8 -11
  63. package/dist/protocols/zai-messages.d.ts +1 -1
  64. package/dist/providers/alibaba.d.ts +1 -1
  65. package/dist/providers/anthropic-compatible.d.ts +5 -5
  66. package/dist/providers/anthropic.d.ts +5 -5
  67. package/dist/providers/assemblyai.d.ts +1 -1
  68. package/dist/providers/assemblyai.js +5 -10
  69. package/dist/providers/azure.js +2 -2
  70. package/dist/providers/black-forest-labs.d.ts +1 -1
  71. package/dist/providers/black-forest-labs.js +5 -10
  72. package/dist/providers/cartesia.d.ts +1 -1
  73. package/dist/providers/cartesia.js +5 -10
  74. package/dist/providers/cloudflare-ai-gateway.d.ts +10 -10
  75. package/dist/providers/deepgram.d.ts +1 -1
  76. package/dist/providers/deepgram.js +6 -12
  77. package/dist/providers/elevenlabs.d.ts +1 -1
  78. package/dist/providers/elevenlabs.js +5 -10
  79. package/dist/providers/fal.d.ts +1 -1
  80. package/dist/providers/fal.js +5 -12
  81. package/dist/providers/google-vertex-messages.d.ts +5 -5
  82. package/dist/providers/google-vertex.d.ts +3 -3
  83. package/dist/providers/google.d.ts +3 -3
  84. package/dist/providers/google.js +7 -12
  85. package/dist/providers/meta.d.ts +8 -8
  86. package/dist/providers/meta.js +4 -8
  87. package/dist/providers/minimax.d.ts +5 -5
  88. package/dist/providers/moonshot.d.ts +5 -5
  89. package/dist/providers/openai.d.ts +7 -8
  90. package/dist/providers/openai.js +10 -11
  91. package/dist/providers/opencode-zen.js +1 -1
  92. package/dist/providers/openrouter.d.ts +6 -7
  93. package/dist/providers/openrouter.js +1 -1
  94. package/dist/providers/replicate.d.ts +1 -1
  95. package/dist/providers/replicate.js +5 -10
  96. package/dist/providers/runway.d.ts +1 -1
  97. package/dist/providers/runway.js +5 -10
  98. package/dist/providers/stability.d.ts +1 -1
  99. package/dist/providers/stability.js +6 -11
  100. package/dist/providers/typesafe-ai.js +1 -1
  101. package/dist/providers/vercel-ai-gateway.js +1 -1
  102. package/dist/providers/xai.js +5 -10
  103. package/dist/providers/zai-coding-plan.d.ts +1 -1
  104. package/dist/providers/zai.js +4 -8
  105. package/dist/route/client.d.ts +0 -1
  106. package/dist/route/client.js +1 -6
  107. package/dist/route/endpoint.d.ts +1 -0
  108. package/dist/route/endpoint.js +2 -2
  109. package/dist/route/framing.d.ts +10 -1
  110. package/dist/route/framing.js +45 -5
  111. package/dist/route/media-protocol.d.ts +42 -35
  112. package/dist/route/media-protocol.js +67 -62
  113. package/dist/route/media.d.ts +6 -2
  114. package/dist/route/media.js +40 -29
  115. package/dist/schema/options.d.ts +6 -3
  116. package/dist/schema/options.js +7 -3
  117. package/dist/speech.d.ts +2 -2
  118. package/dist/speech.js +2 -2
  119. package/dist/transcription.js +2 -2
  120. package/dist/utils/json.d.ts +4 -0
  121. package/dist/utils/json.js +4 -0
  122. package/dist/video.d.ts +2 -2
  123. package/dist/video.js +2 -2
  124. package/package.json +3 -3
  125. package/dist/protocols/utils/meta-image.d.ts +0 -2
  126. package/dist/protocols/utils/meta-image.js +0 -13
  127. package/dist/protocols/utils/openai-image.d.ts +0 -5
  128. package/dist/protocols/utils/openai-image.js +0 -18
@@ -94,7 +94,7 @@ export function request(input) {
94
94
  return new EvaluationRequest({
95
95
  ...input,
96
96
  model: input.model,
97
- http: input.http === undefined ? undefined : HttpOptions.make(input.http),
97
+ http: HttpOptions.make(input.http),
98
98
  });
99
99
  }
100
100
  export function run(input) {
@@ -1,4 +1,4 @@
1
- import { Duration, Effect, Schedule, Schema, Stream } from "effect";
1
+ import { Duration, Effect, Schema, Stream } from "effect";
2
2
  import { AIError } from "./schema/errors.js";
3
3
  export declare const Status: Schema.Literals<readonly ["queued", "running", "completed", "failed", "cancelled", "expired"]>;
4
4
  export type Status = Schema.Schema.Type<typeof Status>;
@@ -9,7 +9,6 @@ export interface Snapshot {
9
9
  /** Normalized 0..1 when the provider reports progress. */
10
10
  readonly progress?: number;
11
11
  readonly position?: number;
12
- readonly expiresAt?: number;
13
12
  }
14
13
  /**
15
14
  * Route-owned generation operations for one generation. The media route decodes its serializable token once (from the
@@ -19,14 +18,10 @@ export interface Route<Response> {
19
18
  readonly status: Effect.Effect<Snapshot, AIError>;
20
19
  readonly result: Effect.Effect<Response, AIError>;
21
20
  readonly cancel?: Effect.Effect<void, AIError>;
22
- /** Provider polling hint (e.g. `openai-poll-after-ms`) that overrides the default interval for the next poll. */
23
- readonly pollHint?: (snapshot: Snapshot) => Duration.Duration | undefined;
24
21
  }
25
22
  export interface Poll {
26
23
  readonly interval?: Duration.Input;
27
24
  readonly timeout?: Duration.Input;
28
- /** Full override of the polling schedule; `interval` and `pollHint` are ignored when supplied. */
29
- readonly schedule?: Schedule.Schedule<unknown, Snapshot>;
30
25
  }
31
26
  export interface AwaitOptions {
32
27
  readonly poll?: Poll;
@@ -57,7 +52,6 @@ export declare class Generation<Response> {
57
52
  readonly status: Status;
58
53
  readonly progress?: number;
59
54
  readonly position?: number;
60
- readonly expiresAt?: number;
61
55
  constructor(route: Route<Response>,
62
56
  /** Route-owned serializable JSON; pass it to the modality's `resume` from another process. */
63
57
  token: unknown, snapshot: Snapshot);
@@ -21,7 +21,6 @@ export class Generation {
21
21
  status;
22
22
  progress;
23
23
  position;
24
- expiresAt;
25
24
  constructor(route,
26
25
  /** Route-owned serializable JSON; pass it to the modality's `resume` from another process. */
27
26
  token, snapshot) {
@@ -31,7 +30,6 @@ export class Generation {
31
30
  this.status = snapshot.status;
32
31
  this.progress = snapshot.progress;
33
32
  this.position = snapshot.position;
34
- this.expiresAt = snapshot.expiresAt;
35
33
  }
36
34
  get snapshot() {
37
35
  return {
@@ -39,7 +37,6 @@ export class Generation {
39
37
  status: this.status,
40
38
  progress: this.progress,
41
39
  position: this.position,
42
- expiresAt: this.expiresAt,
43
40
  };
44
41
  }
45
42
  get terminal() {
@@ -100,14 +97,7 @@ export class Generation {
100
97
  return this.refresh().pipe(Effect.repeat({ schedule: this.schedule(poll), until: (generation) => generation.terminal }));
101
98
  }
102
99
  schedule(poll) {
103
- if (poll?.schedule)
104
- return poll.schedule.pipe(Schedule.setInputType());
105
- const interval = poll?.interval ?? DEFAULT_POLL_INTERVAL;
106
- const pollHint = this.route.pollHint;
107
- const spaced = Schedule.spaced(interval).pipe(Schedule.setInputType());
108
- if (!pollHint)
109
- return spaced;
110
- return spaced.pipe(Schedule.modifyDelay((metadata) => Effect.succeed(pollHint(metadata.input.snapshot) ?? interval)));
100
+ return Schedule.spaced(poll?.interval ?? DEFAULT_POLL_INTERVAL);
111
101
  }
112
102
  }
113
103
  export const resultEvents = (generation, expand, options) => generation.events(options).pipe(Stream.filter((event) => event.type !== "generation-finished"), Stream.concat(Stream.fromIterableEffect(Effect.map(generation.result(), expand))));
package/dist/image.d.ts CHANGED
@@ -4,7 +4,7 @@ import { Media } from "./media.js";
4
4
  import { MediaModel } from "./media-model.js";
5
5
  import { MediaRoute } from "./route/media.js";
6
6
  import type { MediaProtocol } from "./route/media-protocol.js";
7
- import { AIError, HttpOptions } from "./schema/index.js";
7
+ import { AIError, HttpOptions, type OpenString } from "./schema/index.js";
8
8
  import { Service } from "./image-client.js";
9
9
  export type ImageOptions = Record<string, unknown>;
10
10
  export type ImageRoute<Options extends ImageOptions = ImageOptions> = MediaRoute.AnyRoute<ImageRequestFor<Options>, ImageEvent, ImageResponse>;
@@ -27,7 +27,7 @@ export type ImageSize = `${number}x${number}`;
27
27
  export declare const ImageSize: Schema.declare<`${number}x${number}`, `${number}x${number}`>;
28
28
  export type ImageAspectRatio = Media.AspectRatio;
29
29
  export declare const ImageAspectRatio: Schema.declare<`${number}:${number}`, `${number}:${number}`>;
30
- export type ImageFormat = "png" | "jpeg" | "webp" | (string & {});
30
+ export type ImageFormat = OpenString<"png" | "jpeg" | "webp">;
31
31
  declare const ImageRequest_base: Schema.Class<ImageRequest, Schema.Struct<{
32
32
  readonly model: Schema.declare<ImageModel<ImageOptions>, ImageModel<ImageOptions>>;
33
33
  readonly prompt: Schema.String;
package/dist/image.js CHANGED
@@ -12,7 +12,7 @@ export class ImageModel extends MediaModel {
12
12
  static fromRoute(route, input) {
13
13
  return new ImageModel({
14
14
  id: input.id,
15
- provider: route.provider,
15
+ provider: route.protocol.provider,
16
16
  http: input.http,
17
17
  route: composeAnyRoute(route, input, collectResponse),
18
18
  });
@@ -110,7 +110,7 @@ export function request(input) {
110
110
  return input;
111
111
  return new ImageRequest({
112
112
  ...input,
113
- http: input.http === undefined ? undefined : HttpOptions.make(input.http),
113
+ http: HttpOptions.make(input.http),
114
114
  });
115
115
  }
116
116
  const requestEffect = (input) => tryRequest(() => request(input));
package/dist/llm.js CHANGED
@@ -14,7 +14,7 @@ export const request = (input) => {
14
14
  toolChoice: requestToolChoice ? ToolChoice.make(requestToolChoice) : undefined,
15
15
  generation: requestGeneration === undefined ? undefined : GenerationOptions.make(requestGeneration),
16
16
  providerOptions: requestProviderOptions,
17
- http: requestHttp === undefined ? undefined : HttpOptions.make(requestHttp),
17
+ http: HttpOptions.make(requestHttp),
18
18
  });
19
19
  };
20
20
  const GENERATE_OBJECT_TOOL_NAME = "generate_object";
@@ -25,8 +25,6 @@ export declare namespace MediaModel {
25
25
  }
26
26
  /** A protocol plus its canonical start path; `ModelInput.baseURL` overrides `baseURL` per deployment. */
27
27
  interface RouteInput<Request extends MediaRoute.MediaRequest, Protocol> {
28
- readonly id: string;
29
- readonly provider: string | ProviderID;
30
28
  readonly protocol: Protocol;
31
29
  readonly path: Endpoint.EndpointPart<MediaProtocol.Body, Request>;
32
30
  readonly baseURL?: string;
@@ -21,8 +21,6 @@ export class MediaModel {
21
21
  }
22
22
  /** Compose a protocol route input with one deployment through `MediaRoute.inline`, `queued`, or `stream`. */
23
23
  export const composeRoute = (compose, route, input) => compose({
24
- id: route.id,
25
- provider: route.provider,
26
24
  protocol: route.protocol,
27
25
  endpoint: Endpoint.path(route.path, { baseURL: input.baseURL ?? route.baseURL }),
28
26
  auth: input.auth,
@@ -228,7 +228,7 @@ export declare const protocol: Protocol<{
228
228
  readonly type: string;
229
229
  readonly budget_tokens?: number | undefined;
230
230
  } | undefined;
231
- readonly service_tier?: "auto" | (string & {}) | "standard_only" | undefined;
231
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
232
232
  readonly container?: string | {
233
233
  readonly id?: string | null | undefined;
234
234
  readonly skills?: readonly {
@@ -28,33 +28,33 @@ export declare const ContextManagement: Schema.Struct<{
28
28
  }>;
29
29
  export type ContextManagement = typeof ContextManagement.Type;
30
30
  declare const AnthropicThinkingBlockBinding: Schema.Struct<{
31
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
31
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
32
32
  }>;
33
33
  declare const Thinking: Schema.Union<readonly [Schema.decodeTo<Schema.Struct<{
34
- readonly display: Schema.optional<Schema.declare<(string & {}) | "summarized" | "omitted", (string & {}) | "summarized" | "omitted">>;
34
+ readonly display: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"summarized" | "omitted">, import("../schema/options.js").OpenString<"summarized" | "omitted">>>;
35
35
  readonly block_binding: Schema.optional<Schema.Struct<{
36
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
36
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
37
37
  }>>;
38
38
  readonly type: Schema.tag<"enabled">;
39
39
  readonly budget_tokens: Schema.Number;
40
40
  }>, Schema.Union<readonly [Schema.Struct<{
41
- readonly display: Schema.optional<Schema.declare<(string & {}) | "summarized" | "omitted", (string & {}) | "summarized" | "omitted">>;
41
+ readonly display: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"summarized" | "omitted">, import("../schema/options.js").OpenString<"summarized" | "omitted">>>;
42
42
  readonly block_binding: Schema.optional<Schema.Struct<{
43
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
43
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
44
44
  }>>;
45
45
  readonly type: Schema.tag<"enabled">;
46
46
  readonly budgetTokens: Schema.Number;
47
47
  }>, Schema.Struct<{
48
- readonly display: Schema.optional<Schema.declare<(string & {}) | "summarized" | "omitted", (string & {}) | "summarized" | "omitted">>;
48
+ readonly display: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"summarized" | "omitted">, import("../schema/options.js").OpenString<"summarized" | "omitted">>>;
49
49
  readonly block_binding: Schema.optional<Schema.Struct<{
50
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
50
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
51
51
  }>>;
52
52
  readonly type: Schema.tag<"enabled">;
53
53
  readonly budget_tokens: Schema.Number;
54
54
  }>]>, never, never>, Schema.Struct<{
55
- readonly display: Schema.optional<Schema.declare<(string & {}) | "summarized" | "omitted", (string & {}) | "summarized" | "omitted">>;
55
+ readonly display: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"summarized" | "omitted">, import("../schema/options.js").OpenString<"summarized" | "omitted">>>;
56
56
  readonly block_binding: Schema.optional<Schema.Struct<{
57
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
57
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
58
58
  }>>;
59
59
  readonly type: Schema.tag<"adaptive">;
60
60
  }>, Schema.Struct<{
@@ -74,38 +74,38 @@ declare const Options: Schema.Struct<{
74
74
  }>>;
75
75
  }>>;
76
76
  readonly thinking: Schema.optional<Schema.Union<readonly [Schema.decodeTo<Schema.Struct<{
77
- readonly display: Schema.optional<Schema.declare<(string & {}) | "summarized" | "omitted", (string & {}) | "summarized" | "omitted">>;
77
+ readonly display: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"summarized" | "omitted">, import("../schema/options.js").OpenString<"summarized" | "omitted">>>;
78
78
  readonly block_binding: Schema.optional<Schema.Struct<{
79
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
79
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
80
80
  }>>;
81
81
  readonly type: Schema.tag<"enabled">;
82
82
  readonly budget_tokens: Schema.Number;
83
83
  }>, Schema.Union<readonly [Schema.Struct<{
84
- readonly display: Schema.optional<Schema.declare<(string & {}) | "summarized" | "omitted", (string & {}) | "summarized" | "omitted">>;
84
+ readonly display: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"summarized" | "omitted">, import("../schema/options.js").OpenString<"summarized" | "omitted">>>;
85
85
  readonly block_binding: Schema.optional<Schema.Struct<{
86
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
86
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
87
87
  }>>;
88
88
  readonly type: Schema.tag<"enabled">;
89
89
  readonly budgetTokens: Schema.Number;
90
90
  }>, Schema.Struct<{
91
- readonly display: Schema.optional<Schema.declare<(string & {}) | "summarized" | "omitted", (string & {}) | "summarized" | "omitted">>;
91
+ readonly display: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"summarized" | "omitted">, import("../schema/options.js").OpenString<"summarized" | "omitted">>>;
92
92
  readonly block_binding: Schema.optional<Schema.Struct<{
93
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
93
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
94
94
  }>>;
95
95
  readonly type: Schema.tag<"enabled">;
96
96
  readonly budget_tokens: Schema.Number;
97
97
  }>]>, never, never>, Schema.Struct<{
98
- readonly display: Schema.optional<Schema.declare<(string & {}) | "summarized" | "omitted", (string & {}) | "summarized" | "omitted">>;
98
+ readonly display: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"summarized" | "omitted">, import("../schema/options.js").OpenString<"summarized" | "omitted">>>;
99
99
  readonly block_binding: Schema.optional<Schema.Struct<{
100
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
100
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
101
101
  }>>;
102
102
  readonly type: Schema.tag<"adaptive">;
103
103
  }>, Schema.Struct<{
104
104
  readonly type: Schema.tag<"disabled">;
105
105
  }>]>>;
106
106
  readonly effort: Schema.optional<Schema.String>;
107
- readonly service_tier: Schema.optional<Schema.declare<"auto" | (string & {}) | "standard_only", "auto" | (string & {}) | "standard_only">>;
108
- readonly serviceTier: Schema.optional<Schema.declare<"auto" | (string & {}) | "standard_only", "auto" | (string & {}) | "standard_only">>;
107
+ readonly service_tier: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"auto" | "standard_only">, import("../schema/options.js").OpenString<"auto" | "standard_only">>>;
108
+ readonly serviceTier: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"auto" | "standard_only">, import("../schema/options.js").OpenString<"auto" | "standard_only">>>;
109
109
  readonly metadata: Schema.optional<Schema.Struct<{
110
110
  readonly user_id: Schema.optional<Schema.NullOr<Schema.String>>;
111
111
  }>>;
@@ -369,16 +369,16 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
369
369
  top_k: Schema.optional<Schema.Number>;
370
370
  stop_sequences: Schema.optional<Schema.$Array<Schema.String>>;
371
371
  thinking: Schema.optional<Schema.Union<readonly [Schema.Struct<{
372
- readonly display: Schema.optional<Schema.declare<(string & {}) | "summarized" | "omitted", (string & {}) | "summarized" | "omitted">>;
372
+ readonly display: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"summarized" | "omitted">, import("../schema/options.js").OpenString<"summarized" | "omitted">>>;
373
373
  readonly block_binding: Schema.optional<Schema.Struct<{
374
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
374
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
375
375
  }>>;
376
376
  readonly type: Schema.tag<"enabled">;
377
377
  readonly budget_tokens: Schema.Number;
378
378
  }>, Schema.Struct<{
379
- readonly display: Schema.optional<Schema.declare<(string & {}) | "summarized" | "omitted", (string & {}) | "summarized" | "omitted">>;
379
+ readonly display: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"summarized" | "omitted">, import("../schema/options.js").OpenString<"summarized" | "omitted">>>;
380
380
  readonly block_binding: Schema.optional<Schema.Struct<{
381
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
381
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
382
382
  }>>;
383
383
  readonly type: Schema.tag<"adaptive">;
384
384
  }>, Schema.Struct<{
@@ -403,7 +403,7 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
403
403
  metadata: Schema.optional<Schema.Struct<{
404
404
  readonly user_id: Schema.optional<Schema.NullOr<Schema.String>>;
405
405
  }>>;
406
- service_tier: Schema.optional<Schema.declare<"auto" | (string & {}) | "standard_only", "auto" | (string & {}) | "standard_only">>;
406
+ service_tier: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"auto" | "standard_only">, import("../schema/options.js").OpenString<"auto" | "standard_only">>>;
407
407
  }>;
408
408
  export type AnthropicMessagesBody = Schema.Schema.Type<typeof AnthropicMessagesBody>;
409
409
  /**
@@ -627,20 +627,20 @@ export declare const protocol: Protocol<{
627
627
  readonly thinking?: {
628
628
  readonly type: "enabled";
629
629
  readonly budget_tokens: number;
630
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
630
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
631
631
  readonly block_binding?: {
632
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
632
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
633
633
  } | undefined;
634
634
  } | {
635
635
  readonly type: "adaptive";
636
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
636
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
637
637
  readonly block_binding?: {
638
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
638
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
639
639
  } | undefined;
640
640
  } | {
641
641
  readonly type: "disabled";
642
642
  } | undefined;
643
- readonly service_tier?: "auto" | (string & {}) | "standard_only" | undefined;
643
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
644
644
  readonly container?: string | {
645
645
  readonly id?: string | null | undefined;
646
646
  readonly skills?: readonly {
@@ -984,20 +984,20 @@ export declare const route: Route<{
984
984
  readonly thinking?: {
985
985
  readonly type: "enabled";
986
986
  readonly budget_tokens: number;
987
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
987
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
988
988
  readonly block_binding?: {
989
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
989
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
990
990
  } | undefined;
991
991
  } | {
992
992
  readonly type: "adaptive";
993
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
993
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
994
994
  readonly block_binding?: {
995
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
995
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
996
996
  } | undefined;
997
997
  } | {
998
998
  readonly type: "disabled";
999
999
  } | undefined;
1000
- readonly service_tier?: "auto" | (string & {}) | "standard_only" | undefined;
1000
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
1001
1001
  readonly container?: string | {
1002
1002
  readonly id?: string | null | undefined;
1003
1003
  readonly skills?: readonly {
@@ -1,6 +1,7 @@
1
1
  import { Schema } from "effect";
2
2
  import { MediaProtocol } from "../route/media-protocol.js";
3
3
  import { MediaRoute } from "../route/media.js";
4
+ import { type OpenString } from "../schema/index.js";
4
5
  import { TranscriptionModel, TranscriptionResponse, type TranscriptionRequestFor } from "../transcription.js";
5
6
  export declare const DEFAULT_BASE_URL = "https://api.assemblyai.com";
6
7
  export declare const PATH = "/v2/transcript";
@@ -21,7 +22,7 @@ export type AssemblyAITranscriptionOptions = {
21
22
  readonly fallback_language?: string;
22
23
  readonly code_switching?: boolean;
23
24
  };
24
- readonly speech_models?: ReadonlyArray<"universal-3-5-pro" | "universal-2" | (string & {})>;
25
+ readonly speech_models?: ReadonlyArray<OpenString<"universal-3-5-pro" | "universal-2">>;
25
26
  } & Record<string, unknown>;
26
27
  export type Request = TranscriptionRequestFor<AssemblyAITranscriptionOptions>;
27
28
  export declare const Token: Schema.Struct<{
@@ -2,13 +2,11 @@ import { Effect, Schema } from "effect";
2
2
  import { Media } from "../media.js";
3
3
  import { MediaProtocol } from "../route/media-protocol.js";
4
4
  import { MediaRoute } from "../route/media.js";
5
- import { ProviderID, mergeJsonRecords } from "../schema/index.js";
5
+ import { mergeJsonRecords } from "../schema/index.js";
6
6
  import { TranscriptionModel, TranscriptionResponse } from "../transcription.js";
7
7
  import { ProviderShared, optionalNull } from "./shared.js";
8
8
  import { MediaInput } from "./utils/media-input.js";
9
- const ADAPTER = "assemblyai-transcription";
10
- const NAME = "AssemblyAI";
11
- const PROVIDER = ProviderID.make("assemblyai");
9
+ const route = MediaProtocol.identity({ id: "assemblyai-transcription", name: "AssemblyAI", provider: "assemblyai" });
12
10
  export const DEFAULT_BASE_URL = "https://api.assemblyai.com";
13
11
  export const PATH = "/v2/transcript";
14
12
  export const UPLOAD_PATH = "/v2/upload";
@@ -49,17 +47,17 @@ const STATUS = {
49
47
  // ---------------------------------------------------------------------------
50
48
  // 5. Request body construction
51
49
  // ---------------------------------------------------------------------------
52
- const decodeUpload = MediaProtocol.decodeJson(ADAPTER, NAME, Upload);
50
+ const decodeUpload = route.decodeJson(Upload);
53
51
  /** `/v2/transcript` only takes a URL, so inline audio is uploaded to `/v2/upload` first. */
54
52
  const prepare = Effect.fn("AssemblyAITranscription.prepare")(function* (request, send) {
55
53
  if (request.audio.source.type !== "bytes" && request.audio.source.type !== "base64")
56
54
  return request;
57
- const audio = yield* MediaInput.inlineBytes(ADAPTER, request.audio);
55
+ const audio = yield* MediaInput.inlineBytes(route.id, request.audio);
58
56
  const uploaded = yield* send(UPLOAD_PATH, MediaProtocol.binary(audio, "application/octet-stream")).pipe(Effect.flatMap(decodeUpload));
59
57
  return { ...request, audio: Media.url(uploaded.value.upload_url, { mediaType: request.audio.mediaType }) };
60
58
  });
61
59
  const fromRequest = Effect.fn("AssemblyAITranscription.fromRequest")(function* (request) {
62
- const audio = yield* ProviderShared.mediaReference(request.audio, PROVIDER, NAME);
60
+ const audio = yield* ProviderShared.mediaReference(request.audio, route.provider, route.name);
63
61
  return MediaProtocol.json(mergeJsonRecords({
64
62
  audio_url: audio.value,
65
63
  speech_models: [request.model.id],
@@ -74,7 +72,7 @@ const fromRequest = Effect.fn("AssemblyAITranscription.fromRequest")(function* (
74
72
  // ---------------------------------------------------------------------------
75
73
  // 6. Response decoding
76
74
  // ---------------------------------------------------------------------------
77
- const decodeTranscript = MediaProtocol.decodeJson(ADAPTER, NAME, Transcript);
75
+ const decodeTranscript = route.decodeJson(Transcript);
78
76
  const decodeStart = Effect.fn("AssemblyAITranscription.decodeStart")(function* (response) {
79
77
  const output = yield* decodeTranscript(response);
80
78
  const status = yield* MediaProtocol.status(STATUS, output.value.status, output);
@@ -92,9 +90,9 @@ const decodeResult = Effect.fn("AssemblyAITranscription.decodeResult")(function*
92
90
  const status = yield* MediaProtocol.status(STATUS, transcript.status, output);
93
91
  const error = transcript.error ?? undefined;
94
92
  if (status === "failed")
95
- return yield* output.ended("failed", `${NAME} transcription failed${error === undefined ? "" : `: ${error}`}`);
93
+ return yield* output.ended("failed", `${route.name} transcription failed${error === undefined ? "" : `: ${error}`}`);
96
94
  if (status !== "completed")
97
- return yield* output.invalid(`${NAME} transcript ${context.token.transcriptID} has not finished`);
95
+ return yield* output.invalid(`${route.name} transcript ${context.token.transcriptID} has not finished`);
98
96
  const duration = transcript.audio_duration ?? undefined;
99
97
  return new TranscriptionResponse({
100
98
  text: transcript.text ?? "",
@@ -123,15 +121,13 @@ const decodeResult = Effect.fn("AssemblyAITranscription.decodeResult")(function*
123
121
  // 7. Protocol and route
124
122
  // ---------------------------------------------------------------------------
125
123
  const transcriptPath = (token) => `${PATH}/${token.transcriptID}`;
126
- export const protocol = MediaProtocol.queued({
127
- id: ADAPTER,
128
- name: NAME,
124
+ export const protocol = MediaProtocol.queued(route, {
129
125
  token: Token,
130
126
  start: { prepare, body: { from: fromRequest }, decode: decodeStart },
131
127
  status: { path: transcriptPath, decode: decodeStatus },
132
128
  result: { path: transcriptPath, decode: decodeResult },
133
129
  });
134
- export const model = (input) => TranscriptionModel.fromRoute({ id: ADAPTER, provider: PROVIDER, protocol, baseURL: DEFAULT_BASE_URL, path: PATH }, input);
130
+ export const model = (input) => TranscriptionModel.fromRoute({ protocol, baseURL: DEFAULT_BASE_URL, path: PATH }, input);
135
131
  export const AssemblyAITranscription = {
136
132
  protocol,
137
133
  model,
@@ -3,12 +3,10 @@ import { ImageModel, ImageResponse } from "../image.js";
3
3
  import { Media } from "../media.js";
4
4
  import { MediaProtocol } from "../route/media-protocol.js";
5
5
  import { MediaRoute } from "../route/media.js";
6
- import { ProviderID, mergeJsonRecords } from "../schema/index.js";
6
+ import { mergeJsonRecords } from "../schema/index.js";
7
7
  import { ProviderShared, optionalNull } from "./shared.js";
8
8
  import { MediaInput } from "./utils/media-input.js";
9
- const ADAPTER = "bfl-images";
10
- const NAME = "Black Forest Labs";
11
- const PROVIDER = ProviderID.make("black-forest-labs");
9
+ const route = MediaProtocol.identity({ id: "bfl-images", name: "Black Forest Labs", provider: "black-forest-labs" });
12
10
  export const DEFAULT_BASE_URL = "https://api.bfl.ai";
13
11
  // ---------------------------------------------------------------------------
14
12
  // 2. Token and response schemas
@@ -52,31 +50,25 @@ const capabilities = (model) => {
52
50
  return { sizing: "dimensions", imageField: "input_image", maxImages: 4, mask: false };
53
51
  return { sizing: "dimensions", imageField: "input_image", maxImages: 8, mask: false };
54
52
  };
55
- const unsupported = (model, field, message) => ProviderShared.unsupportedOperation({
56
- operation: `media.${field}`,
57
- provider: PROVIDER,
58
- route: ADAPTER,
59
- message: `${model} ${message}`,
60
- });
61
53
  const validate = (request, model) => {
62
54
  const id = request.model.id;
63
55
  const images = request.images?.length ?? 0;
64
56
  if (request.n !== undefined && request.n > 1)
65
- return Effect.fail(unsupported(id, "n", "generates one image per request; call it once per image"));
57
+ return Effect.fail(route.unsupported("media.n", `${id} generates one image per request; call it once per image`));
66
58
  if (request.size !== undefined && model.sizing !== "dimensions")
67
- return Effect.fail(unsupported(id, "size", "does not take size (width and height)"));
59
+ return Effect.fail(route.unsupported("media.size", `${id} does not take size (width and height)`));
68
60
  if (request.aspectRatio !== undefined && model.sizing !== "aspectRatio")
69
- return Effect.fail(unsupported(id, "aspectRatio", "does not take aspectRatio"));
61
+ return Effect.fail(route.unsupported("media.aspectRatio", `${id} does not take aspectRatio`));
70
62
  if (images > model.maxImages)
71
- return Effect.fail(unsupported(id, "images", `takes at most ${model.maxImages} images`));
63
+ return Effect.fail(route.unsupported("media.images", `${id} takes at most ${model.maxImages} images`));
72
64
  if (request.mask !== undefined && !model.mask)
73
- return Effect.fail(unsupported(id, "mask", "does not inpaint; use flux-pro-1.0-fill"));
65
+ return Effect.fail(route.unsupported("media.mask", `${id} does not inpaint; use flux-pro-1.0-fill`));
74
66
  return Effect.void;
75
67
  };
76
68
  const imageInput = (asset) => {
77
69
  const value = asset.inline()?.base64 ?? ProviderShared.mediaUrl(asset);
78
70
  if (value === undefined)
79
- return Effect.fail(ProviderShared.invalidRequest(`${NAME} accepts inline images or https URLs`));
71
+ return Effect.fail(ProviderShared.invalidRequest(`${route.name} accepts inline images or https URLs`));
80
72
  return Effect.succeed(value);
81
73
  };
82
74
  const fromRequest = Effect.fn("BlackForestLabsImages.fromRequest")(function* (request) {
@@ -100,11 +92,11 @@ const fromRequest = Effect.fn("BlackForestLabsImages.fromRequest")(function* (re
100
92
  // ---------------------------------------------------------------------------
101
93
  // 6. Response decoding
102
94
  // ---------------------------------------------------------------------------
103
- const decodeStart = MediaProtocol.decodeStarted(ADAPTER, NAME, StartResponse, (value) => ({
95
+ const decodeStart = route.decodeStarted(StartResponse, (value) => ({
104
96
  token: { id: value.id, pollingURL: value.polling_url },
105
97
  snapshot: { id: value.id, status: "queued" },
106
98
  }));
107
- const decodeDocument = MediaProtocol.decodeJson(ADAPTER, NAME, Result);
99
+ const decodeDocument = route.decodeJson(Result);
108
100
  const decodeStatus = Effect.fn("BlackForestLabsImages.decodeStatus")(function* (response, context) {
109
101
  const output = yield* decodeDocument(response);
110
102
  return { id: context.token.id, status: yield* MediaProtocol.status(STATUS, output.value.status, output) };
@@ -114,11 +106,11 @@ const decodeResult = Effect.fn("BlackForestLabsImages.decodeResult")(function* (
114
106
  const document = output.value;
115
107
  const status = yield* MediaProtocol.status(STATUS, document.status, output);
116
108
  if (isModerated(document.status))
117
- return yield* output.contentPolicy(`${NAME} moderated the generation`);
109
+ return yield* output.contentPolicy(`${route.name} moderated the generation`);
118
110
  if (status === "failed" || status === "expired")
119
- return yield* output.ended(status, `${NAME} generation ${context.token.id} ended with ${document.status}`);
111
+ return yield* output.ended(status, `${route.name} generation ${context.token.id} ended with ${document.status}`);
120
112
  if (status !== "completed" || document.result === undefined || document.result === null)
121
- return yield* output.invalid(`${NAME} generation ${context.token.id} has no result`);
113
+ return yield* output.invalid(`${route.name} generation ${context.token.id} has no result`);
122
114
  const { sample, seed, prompt, ...rest } = document.result;
123
115
  return new ImageResponse({
124
116
  // `sample` is a signed URL that expires 10 minutes after the result is ready, so it is downloaded now.
@@ -132,21 +124,13 @@ const decodeResult = Effect.fn("BlackForestLabsImages.decodeResult")(function* (
132
124
  // ---------------------------------------------------------------------------
133
125
  // 7. Protocol and route
134
126
  // ---------------------------------------------------------------------------
135
- export const protocol = MediaProtocol.queued({
136
- id: ADAPTER,
137
- name: NAME,
127
+ export const protocol = MediaProtocol.queued(route, {
138
128
  token: Token,
139
129
  start: { body: { from: fromRequest }, decode: decodeStart },
140
130
  status: { path: (token) => token.pollingURL, decode: decodeStatus },
141
131
  result: { path: (token) => token.pollingURL, decode: decodeResult },
142
132
  });
143
- export const model = (input) => ImageModel.fromRoute({
144
- id: ADAPTER,
145
- provider: PROVIDER,
146
- protocol,
147
- baseURL: DEFAULT_BASE_URL,
148
- path: ({ request }) => `/v1/${request.model.id}`,
149
- }, input);
133
+ export const model = (input) => ImageModel.fromRoute({ protocol, baseURL: DEFAULT_BASE_URL, path: ({ request }) => `/v1/${request.model.id}` }, input);
150
134
  export const BlackForestLabsImages = {
151
135
  protocol,
152
136
  model,
@@ -1,12 +1,12 @@
1
1
  import { MediaProtocol } from "../route/media-protocol.js";
2
2
  import { MediaRoute } from "../route/media.js";
3
+ import { type OpenString } from "../schema/index.js";
3
4
  import { SpeechModel, type SpeechRequestFor } from "../speech.js";
4
5
  import { SpeechStream } from "./utils/speech-stream.js";
5
6
  export declare const DEFAULT_BASE_URL = "https://api.cartesia.ai";
6
7
  export declare const API_VERSION = "2026-08-14";
7
8
  export declare const BYTES_PATH = "/tts/bytes";
8
9
  export declare const SSE_PATH = "/tts/sse";
9
- export type CartesiaSpeechString<Known extends string> = Known | (string & {});
10
10
  export type CartesiaEncoding = SpeechStream.PcmEncoding;
11
11
  export type CartesiaSpeechOptions = {
12
12
  readonly sampleRate?: 8000 | 16000 | 22050 | 24000 | 44100 | 48000;
@@ -14,7 +14,7 @@ export type CartesiaSpeechOptions = {
14
14
  readonly encoding?: CartesiaEncoding;
15
15
  readonly generation_config?: {
16
16
  readonly volume?: number;
17
- readonly emotion?: CartesiaSpeechString<"neutral" | "calm" | "angry" | "content" | "sad" | "scared">;
17
+ readonly emotion?: OpenString<"neutral" | "calm" | "angry" | "content" | "sad" | "scared">;
18
18
  };
19
19
  readonly pronunciation_dict_id?: string;
20
20
  } & Record<string, unknown>;