@opencode/ai 2.2.5 → 2.2.7

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 (306) hide show
  1. package/README.md +228 -72
  2. package/dist/ai-client.d.ts +2 -2
  3. package/dist/ai-client.js +2 -1
  4. package/dist/cache-policy.d.ts +1 -1
  5. package/dist/cache-policy.js +16 -4
  6. package/dist/decision-client.d.ts +3 -3
  7. package/dist/decision.d.ts +30 -125
  8. package/dist/decision.js +27 -15
  9. package/dist/effect.d.ts +10 -15
  10. package/dist/effect.js +6 -6
  11. package/dist/effort-updates.d.ts +3 -3
  12. package/dist/effort-updates.js +2 -2
  13. package/dist/embedding-client.d.ts +21 -0
  14. package/dist/embedding-client.js +30 -0
  15. package/dist/embedding.d.ts +111 -0
  16. package/dist/embedding.js +75 -0
  17. package/dist/experimental/cloudflare-run-extraction.d.ts +7 -3
  18. package/dist/experimental/cloudflare-run-extraction.js +4 -1
  19. package/dist/experimental/extraction.d.ts +10 -40
  20. package/dist/experimental/extraction.js +14 -13
  21. package/dist/experimental.d.ts +8 -8
  22. package/dist/experimental.js +4 -4
  23. package/dist/generation.d.ts +0 -2
  24. package/dist/generation.js +2 -2
  25. package/dist/image-client.d.ts +13 -7
  26. package/dist/image-client.js +1 -1
  27. package/dist/image.d.ts +357 -465
  28. package/dist/image.js +17 -18
  29. package/dist/index.d.ts +35 -467
  30. package/dist/index.js +23 -17
  31. package/dist/llm.d.ts +65 -266
  32. package/dist/llm.js +101 -92
  33. package/dist/loop.d.ts +38 -0
  34. package/dist/loop.js +136 -0
  35. package/dist/media-model.d.ts +1 -1
  36. package/dist/media-model.js +8 -6
  37. package/dist/media.d.ts +9 -0
  38. package/dist/media.js +37 -2
  39. package/dist/protocols/alibaba-chat.d.ts +9 -1
  40. package/dist/protocols/alibaba-chat.js +3 -3
  41. package/dist/protocols/alibaba-images.d.ts +2 -2
  42. package/dist/protocols/alibaba-messages.js +3 -3
  43. package/dist/protocols/alibaba-responses.js +8 -20
  44. package/dist/protocols/anthropic-messages.d.ts +1 -1
  45. package/dist/protocols/anthropic-messages.js +57 -176
  46. package/dist/protocols/assemblyai-transcription.d.ts +2 -2
  47. package/dist/protocols/bedrock-converse.js +10 -16
  48. package/dist/protocols/cartesia-speech.d.ts +2 -2
  49. package/dist/protocols/cloudflare-workers-ai-images.d.ts +2 -2
  50. package/dist/protocols/cohere-chat.js +9 -12
  51. package/dist/protocols/deepgram-speech.d.ts +2 -2
  52. package/dist/protocols/deepgram-transcription.d.ts +2 -2
  53. package/dist/protocols/elevenlabs-speech.d.ts +2 -2
  54. package/dist/protocols/elevenlabs-transcription.d.ts +2 -2
  55. package/dist/protocols/gemini.d.ts +3 -0
  56. package/dist/protocols/gemini.js +54 -72
  57. package/dist/protocols/google-embed-content.d.ts +34 -0
  58. package/dist/protocols/google-embed-content.js +110 -0
  59. package/dist/protocols/google-images.d.ts +2 -2
  60. package/dist/protocols/google-interactions.d.ts +3 -4
  61. package/dist/protocols/google-interactions.js +44 -30
  62. package/dist/protocols/google-speech.d.ts +2 -2
  63. package/dist/protocols/google-transcription.d.ts +2 -2
  64. package/dist/protocols/google-vertex-predict-embeddings.d.ts +18 -0
  65. package/dist/protocols/google-vertex-predict-embeddings.js +74 -0
  66. package/dist/protocols/google-video.d.ts +2 -2
  67. package/dist/protocols/index.d.ts +3 -0
  68. package/dist/protocols/index.js +3 -0
  69. package/dist/protocols/meta-images.d.ts +2 -2
  70. package/dist/protocols/meta-responses.js +26 -23
  71. package/dist/protocols/minimax-images.d.ts +2 -2
  72. package/dist/protocols/mistral-chat.js +7 -10
  73. package/dist/protocols/open-responses-channel.js +6 -19
  74. package/dist/protocols/open-responses-continuation.d.ts +1 -5
  75. package/dist/protocols/open-responses-continuation.js +1 -3
  76. package/dist/protocols/open-responses.d.ts +2 -22
  77. package/dist/protocols/open-responses.js +41 -23
  78. package/dist/protocols/openai-chat.d.ts +27 -23
  79. package/dist/protocols/openai-chat.js +62 -57
  80. package/dist/protocols/openai-compatible-chat.d.ts +2 -1
  81. package/dist/protocols/openai-compatible-responses.d.ts +2 -2
  82. package/dist/protocols/openai-compatible-responses.js +1 -1
  83. package/dist/protocols/openai-decisions.js +15 -2
  84. package/dist/protocols/openai-embeddings.d.ts +16 -0
  85. package/dist/protocols/openai-embeddings.js +76 -0
  86. package/dist/protocols/openai-images.d.ts +2 -2
  87. package/dist/protocols/openai-responses.js +10 -29
  88. package/dist/protocols/openai-speech.d.ts +2 -2
  89. package/dist/protocols/openai-transcription.d.ts +2 -2
  90. package/dist/protocols/runway-video.d.ts +2 -2
  91. package/dist/protocols/shared.d.ts +14 -7
  92. package/dist/protocols/shared.js +40 -15
  93. package/dist/protocols/system-one.d.ts +4 -4
  94. package/dist/protocols/system-one.js +8 -1
  95. package/dist/protocols/utils/bedrock-cache.js +2 -5
  96. package/dist/protocols/utils/bedrock-media.d.ts +0 -3
  97. package/dist/protocols/utils/cache.d.ts +3 -0
  98. package/dist/protocols/utils/cache.js +15 -2
  99. package/dist/protocols/utils/image-sizing.d.ts +1 -1
  100. package/dist/protocols/utils/responses-checkpoint.js +1 -1
  101. package/dist/protocols/utils/responses-compaction.d.ts +1 -1
  102. package/dist/protocols/utils/responses-compaction.js +6 -5
  103. package/dist/protocols/utils/responses-hosted-tools.d.ts +97 -1
  104. package/dist/protocols/utils/responses-hosted-tools.js +31 -0
  105. package/dist/protocols/utils/tool-stream.d.ts +5 -271
  106. package/dist/protocols/utils/tool-stream.js +3 -13
  107. package/dist/protocols/venice-chat.d.ts +7 -1
  108. package/dist/protocols/venice-chat.js +4 -4
  109. package/dist/protocols/xai-images.d.ts +2 -2
  110. package/dist/protocols/xai-responses.js +5 -25
  111. package/dist/protocols/xai-video.d.ts +2 -2
  112. package/dist/protocols/zai-chat.d.ts +9 -1
  113. package/dist/protocols/zai-chat.js +1 -1
  114. package/dist/protocols/zai-images.d.ts +2 -2
  115. package/dist/protocols/zai-messages.js +3 -3
  116. package/dist/provider-error.d.ts +0 -1
  117. package/dist/provider-error.js +7 -80
  118. package/dist/providers/alibaba/embeddings.d.ts +2 -0
  119. package/dist/providers/alibaba/embeddings.js +1 -0
  120. package/dist/providers/alibaba.d.ts +70 -4
  121. package/dist/providers/alibaba.js +20 -2
  122. package/dist/providers/amazon-bedrock-mantle.d.ts +7 -3
  123. package/dist/providers/amazon-bedrock-mantle.js +6 -3
  124. package/dist/providers/amazon-bedrock.d.ts +6 -7
  125. package/dist/providers/amazon-bedrock.js +1 -1
  126. package/dist/providers/anthropic-compatible.d.ts +7 -8
  127. package/dist/providers/anthropic-compatible.js +2 -5
  128. package/dist/providers/anthropic.d.ts +8 -9
  129. package/dist/providers/anthropic.js +2 -7
  130. package/dist/providers/assemblyai.d.ts +2 -2
  131. package/dist/providers/assemblyai.js +2 -7
  132. package/dist/providers/azure/embeddings.d.ts +2 -0
  133. package/dist/providers/azure/embeddings.js +1 -0
  134. package/dist/providers/azure/messages.d.ts +2 -0
  135. package/dist/providers/azure/messages.js +1 -0
  136. package/dist/providers/azure.d.ts +325 -7
  137. package/dist/providers/azure.js +40 -9
  138. package/dist/providers/baseten.d.ts +7 -5
  139. package/dist/providers/baseten.js +7 -21
  140. package/dist/providers/cartesia.d.ts +1 -1
  141. package/dist/providers/cerebras.d.ts +7 -5
  142. package/dist/providers/cerebras.js +4 -15
  143. package/dist/providers/cloudflare-ai-gateway.d.ts +23 -13
  144. package/dist/providers/cloudflare-ai-gateway.js +28 -40
  145. package/dist/providers/cloudflare-shared.d.ts +9 -0
  146. package/dist/providers/cloudflare-shared.js +25 -0
  147. package/dist/providers/cloudflare-workers-ai.d.ts +6 -4
  148. package/dist/providers/cloudflare-workers-ai.js +4 -20
  149. package/dist/providers/cohere/chat.js +2 -7
  150. package/dist/providers/cohere/embeddings.d.ts +2 -0
  151. package/dist/providers/cohere/embeddings.js +1 -0
  152. package/dist/providers/cohere.d.ts +14 -5
  153. package/dist/providers/cohere.js +23 -13
  154. package/dist/providers/deepgram.d.ts +2 -2
  155. package/dist/providers/deepgram.js +2 -7
  156. package/dist/providers/deepinfra/embeddings.d.ts +2 -0
  157. package/dist/providers/deepinfra/embeddings.js +1 -0
  158. package/dist/providers/deepinfra.d.ts +10 -5
  159. package/dist/providers/deepinfra.js +20 -14
  160. package/dist/providers/deepseek.d.ts +7 -5
  161. package/dist/providers/deepseek.js +3 -14
  162. package/dist/providers/digitalocean/embeddings.d.ts +2 -0
  163. package/dist/providers/digitalocean/embeddings.js +1 -0
  164. package/dist/providers/digitalocean.d.ts +18 -5
  165. package/dist/providers/digitalocean.js +28 -14
  166. package/dist/providers/elevenlabs.d.ts +2 -2
  167. package/dist/providers/elevenlabs.js +2 -7
  168. package/dist/providers/fireworks/embeddings.d.ts +2 -0
  169. package/dist/providers/fireworks/embeddings.js +1 -0
  170. package/dist/providers/fireworks.d.ts +10 -5
  171. package/dist/providers/fireworks.js +17 -14
  172. package/dist/providers/google/embeddings.d.ts +2 -0
  173. package/dist/providers/google/embeddings.js +1 -0
  174. package/dist/providers/google/interactions.d.ts +1 -1
  175. package/dist/providers/google/interactions.js +2 -7
  176. package/dist/providers/google-vertex/embeddings.d.ts +2 -0
  177. package/dist/providers/google-vertex/embeddings.js +1 -0
  178. package/dist/providers/google-vertex-chat.d.ts +4 -3
  179. package/dist/providers/google-vertex-chat.js +3 -29
  180. package/dist/providers/google-vertex-interactions.d.ts +3 -3
  181. package/dist/providers/google-vertex-messages.d.ts +3 -3
  182. package/dist/providers/google-vertex-messages.js +3 -29
  183. package/dist/providers/google-vertex-mistral.d.ts +3 -3
  184. package/dist/providers/google-vertex-mistral.js +3 -29
  185. package/dist/providers/google-vertex-responses.d.ts +3 -3
  186. package/dist/providers/google-vertex-responses.js +4 -30
  187. package/dist/providers/google-vertex-shared.d.ts +31 -0
  188. package/dist/providers/google-vertex-shared.js +25 -0
  189. package/dist/providers/google-vertex.d.ts +10 -3
  190. package/dist/providers/google-vertex.js +52 -0
  191. package/dist/providers/google.d.ts +21 -13
  192. package/dist/providers/google.js +23 -19
  193. package/dist/providers/groq.d.ts +10 -5
  194. package/dist/providers/groq.js +4 -15
  195. package/dist/providers/meta.d.ts +6 -5
  196. package/dist/providers/meta.js +10 -23
  197. package/dist/providers/minimax/chat.js +2 -7
  198. package/dist/providers/minimax/responses.js +2 -7
  199. package/dist/providers/minimax.d.ts +6 -5
  200. package/dist/providers/minimax.js +7 -22
  201. package/dist/providers/mistral.d.ts +10 -11
  202. package/dist/providers/mistral.js +3 -14
  203. package/dist/providers/moonshot/messages.js +2 -7
  204. package/dist/providers/moonshot/responses.js +2 -7
  205. package/dist/providers/moonshot.d.ts +6 -5
  206. package/dist/providers/moonshot.js +4 -16
  207. package/dist/providers/openai/embeddings.d.ts +2 -0
  208. package/dist/providers/openai/embeddings.js +1 -0
  209. package/dist/providers/openai-compatible/embeddings.d.ts +2 -0
  210. package/dist/providers/openai-compatible/embeddings.js +1 -0
  211. package/dist/providers/openai-compatible-responses.d.ts +6 -7
  212. package/dist/providers/openai-compatible-responses.js +2 -8
  213. package/dist/providers/openai-compatible.d.ts +10 -7
  214. package/dist/providers/openai-compatible.js +17 -10
  215. package/dist/providers/openai.d.ts +11 -4
  216. package/dist/providers/openai.js +17 -3
  217. package/dist/providers/opencode.d.ts +4 -4
  218. package/dist/providers/opencode.js +6 -2
  219. package/dist/providers/openrouter/embeddings.d.ts +2 -0
  220. package/dist/providers/openrouter/embeddings.js +1 -0
  221. package/dist/providers/openrouter.d.ts +24 -5
  222. package/dist/providers/openrouter.js +31 -24
  223. package/dist/providers/runway.d.ts +1 -1
  224. package/dist/providers/settings.d.ts +40 -0
  225. package/dist/providers/settings.js +19 -0
  226. package/dist/providers/togetherai.d.ts +7 -5
  227. package/dist/providers/togetherai.js +5 -15
  228. package/dist/providers/typesafe-ai.d.ts +4 -4
  229. package/dist/providers/typesafe-ai.js +6 -2
  230. package/dist/providers/venice.d.ts +5 -4
  231. package/dist/providers/venice.js +6 -2
  232. package/dist/providers/vercel-ai-gateway/embeddings.d.ts +2 -0
  233. package/dist/providers/vercel-ai-gateway/embeddings.js +1 -0
  234. package/dist/providers/vercel-ai-gateway.d.ts +9 -5
  235. package/dist/providers/vercel-ai-gateway.js +30 -29
  236. package/dist/providers/xai.d.ts +5 -4
  237. package/dist/providers/xai.js +4 -12
  238. package/dist/providers/zai-coding-plan/messages.js +2 -7
  239. package/dist/providers/zai-coding-plan/responses.js +2 -7
  240. package/dist/providers/zai-coding-plan.d.ts +6 -5
  241. package/dist/providers/zai-coding-plan.js +8 -15
  242. package/dist/providers/zai.d.ts +6 -5
  243. package/dist/providers/zai.js +10 -22
  244. package/dist/public.d.ts +14 -0
  245. package/dist/public.js +6 -0
  246. package/dist/route/auth-options.d.ts +9 -5
  247. package/dist/route/auth-options.js +10 -7
  248. package/dist/route/client.d.ts +50 -37
  249. package/dist/route/client.js +42 -53
  250. package/dist/route/decision.d.ts +8 -8
  251. package/dist/route/decision.js +3 -3
  252. package/dist/route/embedding.d.ts +61 -0
  253. package/dist/route/embedding.js +88 -0
  254. package/dist/route/executor.d.ts +5 -0
  255. package/dist/route/executor.js +10 -0
  256. package/dist/route/index.d.ts +5 -7
  257. package/dist/route/index.js +1 -1
  258. package/dist/route/media.d.ts +7 -11
  259. package/dist/route/media.js +22 -26
  260. package/dist/route/transport/http.js +6 -5
  261. package/dist/route/transport/websocket.js +7 -1
  262. package/dist/schema/errors.d.ts +16 -17
  263. package/dist/schema/errors.js +63 -12
  264. package/dist/schema/events.d.ts +2563 -2954
  265. package/dist/schema/events.js +54 -109
  266. package/dist/schema/messages.d.ts +194 -137
  267. package/dist/schema/messages.js +66 -83
  268. package/dist/schema/options.d.ts +112 -65
  269. package/dist/schema/options.js +52 -101
  270. package/dist/speech-client.d.ts +7 -7
  271. package/dist/speech.d.ts +306 -316
  272. package/dist/speech.js +16 -14
  273. package/dist/testing.d.ts +31 -175
  274. package/dist/testing.js +60 -5
  275. package/dist/tool-history.d.ts +1 -1
  276. package/dist/tool-history.js +3 -10
  277. package/dist/tool-runtime.d.ts +9 -2
  278. package/dist/tool-runtime.js +17 -31
  279. package/dist/tool.d.ts +39 -43
  280. package/dist/tool.js +16 -26
  281. package/dist/transcription-client.d.ts +7 -7
  282. package/dist/transcription.d.ts +314 -265
  283. package/dist/transcription.js +16 -14
  284. package/dist/utils/provider-codes.d.ts +3 -0
  285. package/dist/utils/provider-codes.js +41 -0
  286. package/dist/video-client.d.ts +7 -7
  287. package/dist/video-client.js +1 -1
  288. package/dist/video.d.ts +269 -287
  289. package/dist/video.js +16 -14
  290. package/package.json +309 -257
  291. package/dist/experimental/testing.d.ts +0 -3
  292. package/dist/experimental/testing.js +0 -3
  293. package/dist/testing/decision.d.ts +0 -16
  294. package/dist/testing/decision.js +0 -20
  295. package/dist/testing/image.d.ts +0 -14
  296. package/dist/testing/image.js +0 -12
  297. package/dist/testing/media.d.ts +0 -18
  298. package/dist/testing/media.js +0 -36
  299. package/dist/testing/script.d.ts +0 -28
  300. package/dist/testing/script.js +0 -60
  301. package/dist/testing/speech.d.ts +0 -14
  302. package/dist/testing/speech.js +0 -12
  303. package/dist/testing/transcription.d.ts +0 -14
  304. package/dist/testing/transcription.js +0 -12
  305. package/dist/testing/video.d.ts +0 -14
  306. package/dist/testing/video.js +0 -12
@@ -0,0 +1,16 @@
1
+ import { EmbeddingRoute } from "../route/embedding.js";
2
+ import { type OpenString } from "../schema/index.js";
3
+ export declare const DEFAULT_BASE_URL = "https://api.openai.com/v1";
4
+ export declare const PATH = "/embeddings";
5
+ /** Sent as given; anything else a host accepts (`input_type`, `truncate`, …) goes alongside. */
6
+ export interface OptionsInput {
7
+ readonly [key: string]: unknown;
8
+ readonly user?: string;
9
+ readonly encoding_format?: OpenString<"float" | "base64">;
10
+ }
11
+ export declare const protocol: EmbeddingRoute.Protocol;
12
+ export declare const route: EmbeddingRoute.Route;
13
+ export declare const OpenAIEmbeddings: {
14
+ readonly protocol: EmbeddingRoute.Protocol;
15
+ readonly route: EmbeddingRoute.Route;
16
+ };
@@ -0,0 +1,76 @@
1
+ import { Effect, Schema } from "effect";
2
+ import { Base64 } from "effect/encoding";
3
+ import { EmbeddingResponse, EmbeddingUsage } from "../embedding.js";
4
+ import { EmbeddingRoute } from "../route/embedding.js";
5
+ import { Endpoint } from "../route/endpoint.js";
6
+ import { MediaProtocol } from "../route/media-protocol.js";
7
+ import { AIError, UnsupportedOperationError, mergeJsonRecords } from "../schema/index.js";
8
+ const ID = "openai-embeddings";
9
+ const NAME = "OpenAI Embeddings";
10
+ export const DEFAULT_BASE_URL = "https://api.openai.com/v1";
11
+ export const PATH = "/embeddings";
12
+ const Response = Schema.Struct({
13
+ data: Schema.Array(Schema.Struct({
14
+ index: Schema.optional(Schema.Int),
15
+ // `base64` encoding returns little-endian float32 bytes instead of a number list.
16
+ embedding: Schema.Union([Schema.Array(Schema.Number), Schema.String]),
17
+ })),
18
+ model: Schema.optional(Schema.String),
19
+ usage: Schema.optional(Schema.StructWithRest(Schema.Struct({ prompt_tokens: Schema.optional(Schema.Number), total_tokens: Schema.optional(Schema.Number) }), [Schema.Record(Schema.String, Schema.Unknown)])),
20
+ });
21
+ // `inputType` has no field here; OpenAI's models embed queries and documents the same way.
22
+ const fromRequest = Effect.fn("OpenAIEmbeddings.fromRequest")(function* (request) {
23
+ const input = request.values.filter((value) => typeof value === "string");
24
+ if (input.length !== request.values.length)
25
+ return yield* new AIError({
26
+ reason: new UnsupportedOperationError({
27
+ operation: "embedding.media",
28
+ provider: request.model.provider,
29
+ route: request.model.route.id,
30
+ message: `${NAME} embeds text only; pass media values to a host with a multimodal embedding API`,
31
+ }),
32
+ });
33
+ return {
34
+ ...mergeJsonRecords({ encoding_format: "float", ...request.providerOptions }, request.http?.body),
35
+ model: request.model.id,
36
+ input,
37
+ ...(request.dimensions === undefined ? {} : { dimensions: request.dimensions }),
38
+ };
39
+ });
40
+ const decodeDocument = MediaProtocol.identity({ id: ID, name: NAME, provider: "openai" }).decodeJson(Response);
41
+ export const protocol = EmbeddingRoute.protocol({
42
+ id: ID,
43
+ name: NAME,
44
+ body: { from: fromRequest },
45
+ response: {
46
+ decode: Effect.fn("OpenAIEmbeddings.decodeResponse")(function* (response, context) {
47
+ const output = yield* decodeDocument(response);
48
+ const embeddings = yield* Effect.forEach(output.value.data
49
+ .map((item, position) => ({ index: item.index ?? position, embedding: item.embedding }))
50
+ .toSorted((a, b) => a.index - b.index), (item) => typeof item.embedding !== "string"
51
+ ? Effect.succeed(item.embedding)
52
+ : Effect.fromResult(Base64.decode(item.embedding)).pipe(Effect.map((bytes) => Array.from(new Float32Array(bytes.slice().buffer))), Effect.mapError((cause) => output.invalid(`${NAME} returned an invalid base64 embedding`, cause))));
53
+ const usage = output.value.usage;
54
+ return new EmbeddingResponse({
55
+ embeddings,
56
+ usage: usage?.prompt_tokens === undefined ? undefined : new EmbeddingUsage({ inputTokens: usage.prompt_tokens }),
57
+ providerMetadata: {
58
+ [context.providerMetadataKey]: {
59
+ ...(output.value.model === undefined ? {} : { model: output.value.model }),
60
+ ...(usage === undefined ? {} : { usage }),
61
+ },
62
+ },
63
+ });
64
+ }),
65
+ },
66
+ });
67
+ export const route = EmbeddingRoute.make({
68
+ id: ID,
69
+ provider: "openai",
70
+ protocol,
71
+ endpoint: Endpoint.path(PATH, { baseURL: DEFAULT_BASE_URL }),
72
+ });
73
+ export const OpenAIEmbeddings = {
74
+ protocol,
75
+ route,
76
+ };
@@ -1,5 +1,5 @@
1
1
  import { Schema } from "effect";
2
- import { ImageModel, type ImageRequestFor } from "../image.js";
2
+ import { ImageModel, type ImageRequest } 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";
@@ -21,7 +21,7 @@ export type OpenAIImageOptions = {
21
21
  /** Previews sent before the final image when streaming (default 2); ignored by `Image.generate`. */
22
22
  readonly partialImages?: number;
23
23
  } & Record<string, unknown>;
24
- export type Request = ImageRequestFor<OpenAIImageOptions>;
24
+ export type Request = ImageRequest<ImageModel<OpenAIImageOptions>>;
25
25
  declare const Usage: Schema.Struct<{
26
26
  readonly input_tokens: Schema.optional<Schema.Number>;
27
27
  readonly output_tokens: Schema.optional<Schema.Number>;
@@ -6,7 +6,6 @@ import { Auth } from "../route/auth.js";
6
6
  import { Endpoint } from "../route/endpoint.js";
7
7
  import { Protocol } from "../route/protocol.js";
8
8
  import { HttpTransport } from "../route/transport/index.js";
9
- import { LLMRequest } from "../schema/index.js";
10
9
  import { requestTTL } from "../cache-policy.js";
11
10
  import { resolveEffortUpdates } from "../effort-updates.js";
12
11
  import { OpenResponses } from "./open-responses.js";
@@ -133,7 +132,7 @@ const supportsEffortUpdates = (request) => {
133
132
  return false;
134
133
  if (Schema.is(Schema.Struct({ mode: Schema.Literal("pro") }))(request.http?.body?.reasoning))
135
134
  return false;
136
- const override = request.model.compatibility?.supportsEffortUpdates;
135
+ const override = request.model.capabilities?.reasoning?.updates;
137
136
  if (override !== undefined)
138
137
  return override;
139
138
  const match = /(?:^|\/)gpt-(\d+)(?:\.\d+)?(?:-|$)/i.exec(request.model.id);
@@ -250,29 +249,10 @@ const hostedToolResult = Effect.fnUntraced(function* (item) {
250
249
  return isError ? { type: "error", value: item.error } : { type: "json", value: item };
251
250
  });
252
251
  const HOSTED_TOOLS = {
253
- web_search_call: { name: "web_search", input: (item) => item.action ?? {} },
252
+ ...ResponsesHostedTools.common,
254
253
  web_search_preview_call: { name: "web_search_preview", input: (item) => item.action ?? {} },
255
- file_search_call: { name: "file_search", input: (item) => ({ queries: item.queries ?? [] }) },
256
- code_interpreter_call: {
257
- name: "code_interpreter",
258
- input: (item) => ({ code: item.code, container_id: item.container_id }),
259
- },
260
254
  computer_call: { name: "computer_use", input: (item) => item.action ?? {} },
261
255
  image_generation_call: { name: "image_generation", input: () => ({}), result: hostedToolResult },
262
- mcp_call: {
263
- name: "mcp",
264
- input: (item) => ({ server_label: item.server_label, name: item.name, arguments: item.arguments }),
265
- },
266
- };
267
- const step = (state, input) => {
268
- const event = OpenResponses.normalize(state, input);
269
- if (event.type === "response.reasoning_text.delta")
270
- return event.item_id !== undefined
271
- ? Effect.succeed(OpenResponses.onReasoningDelta(state, event, event.item_id))
272
- : ProviderShared.eventError(ADAPTER, `${event.type} is missing item_id`);
273
- if (event.type === "response.output_item.done" && event.item && ResponsesHostedTools.isItem(event.item, HOSTED_TOOLS))
274
- return ResponsesHostedTools.onDone(state, event.item, HOSTED_TOOLS);
275
- return OpenResponses.step(state, event);
276
256
  };
277
257
  export const protocol = Protocol.make({
278
258
  id: ADAPTER,
@@ -280,12 +260,13 @@ export const protocol = Protocol.make({
280
260
  schema: OpenAIResponsesBody,
281
261
  from: fromRequest,
282
262
  },
283
- stream: {
284
- event: OpenResponses.protocol.stream.event,
285
- initial: (request) => OpenResponses.initial(request, adapter),
286
- step,
287
- terminal: OpenResponses.terminal,
288
- },
263
+ stream: ResponsesHostedTools.stream(adapter, HOSTED_TOOLS, (state, event) => {
264
+ if (event.type !== "response.reasoning_text.delta")
265
+ return undefined;
266
+ return event.item_id !== undefined
267
+ ? Effect.succeed(OpenResponses.onReasoningDelta(state, event, event.item_id))
268
+ : ProviderShared.eventError(ADAPTER, `${event.type} is missing item_id`);
269
+ }),
289
270
  supportsEffortUpdates,
290
271
  });
291
272
  const endpoint = Endpoint.path(PATH, { baseURL: DEFAULT_BASE_URL });
@@ -310,6 +291,6 @@ export const route = Route.make({
310
291
  endpoint,
311
292
  auth,
312
293
  transport,
313
- defaults: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
294
+ options: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
314
295
  });
315
296
  export * as OpenAIResponses from "./openai-responses.js";
@@ -1,7 +1,7 @@
1
1
  import { MediaProtocol } from "../route/media-protocol.js";
2
2
  import { MediaRoute } from "../route/media.js";
3
3
  import { type MediaUsage } from "../schema/index.js";
4
- import { SpeechModel, type SpeechRequestFor } from "../speech.js";
4
+ import { SpeechModel, type SpeechRequest } from "../speech.js";
5
5
  import { SpeechStream } from "./utils/speech-stream.js";
6
6
  export declare const DEFAULT_BASE_URL = "https://api.openai.com/v1";
7
7
  export declare const PATH = "/audio/speech";
@@ -10,7 +10,7 @@ export type OpenAISpeechOptions = {
10
10
  /** Defaults to `"sse"` in `stream` mode on models that support it; the merged value selects the response framing. */
11
11
  readonly stream_format?: "sse" | "audio";
12
12
  } & Record<string, unknown>;
13
- export type Request = SpeechRequestFor<OpenAISpeechOptions>;
13
+ export type Request = SpeechRequest<SpeechModel<OpenAISpeechOptions>>;
14
14
  interface State extends SpeechStream.Audio {
15
15
  readonly done: boolean;
16
16
  readonly usage?: MediaUsage;
@@ -1,7 +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 { TranscriptionModel, type TranscriptionRequestFor, type TranscriptionSegment } from "../transcription.js";
4
+ import { TranscriptionModel, type TranscriptionRequest, type TranscriptionSegment } from "../transcription.js";
5
5
  export declare const DEFAULT_BASE_URL = "https://api.openai.com/v1";
6
6
  export declare const PATH = "/audio/transcriptions";
7
7
  export type OpenAITranscriptionOptions = {
@@ -17,7 +17,7 @@ export type OpenAITranscriptionOptions = {
17
17
  readonly known_speaker_references?: ReadonlyArray<string>;
18
18
  readonly temperature?: number;
19
19
  } & Record<string, unknown>;
20
- export type Request = TranscriptionRequestFor<OpenAITranscriptionOptions>;
20
+ export type Request = TranscriptionRequest<TranscriptionModel<OpenAITranscriptionOptions>>;
21
21
  declare const Transcript: Schema.Struct<{
22
22
  text: Schema.String;
23
23
  language: Schema.optional<Schema.String>;
@@ -2,7 +2,7 @@ import { Schema } from "effect";
2
2
  import { MediaProtocol } from "../route/media-protocol.js";
3
3
  import { MediaRoute } from "../route/media.js";
4
4
  import { type OpenString } from "../schema/index.js";
5
- import { VideoModel, VideoResponse, type VideoRequestFor } from "../video.js";
5
+ import { VideoModel, VideoResponse, type VideoRequest } from "../video.js";
6
6
  export declare const DEFAULT_BASE_URL = "https://api.dev.runwayml.com/v1";
7
7
  /** Every Runway request must pin the API version. */
8
8
  export declare const API_VERSION = "2024-11-06";
@@ -21,7 +21,7 @@ export type RunwayVideoOptions = {
21
21
  };
22
22
  readonly outputFormat?: OpenString<"mp4" | "prores" | "png_sequence">;
23
23
  } & Record<string, unknown>;
24
- export type Request = VideoRequestFor<RunwayVideoOptions>;
24
+ export type Request = VideoRequest<VideoModel<RunwayVideoOptions>>;
25
25
  export declare const Token: Schema.Struct<{
26
26
  readonly taskID: Schema.String;
27
27
  }>;
@@ -2,7 +2,7 @@ import { Tool } from "@opencode/schema/tool";
2
2
  import { Effect, Schema } from "effect";
3
3
  import { Headers, HttpClientRequest } from "effect/http";
4
4
  import { Media } from "../media.js";
5
- import { AIError, LLMRequest, Message, ToolDefinition, type ContentPart, type MediaPart, type OpenString, type ProviderID, type RequestEncoding, type ToolEntry, type ToolResultPart } from "../schema/index.js";
5
+ import { AIError, type LLMRequest, Message, ToolDefinition, type ContentPart, type MediaPart, type OpenString, type ProviderID, type RequestEncoding, type ToolEntry, type ToolResultPart } from "../schema/index.js";
6
6
  import { Json, decodeJson, encodeJson } from "../utils/json.js";
7
7
  import { isRecord } from "../utils/record.js";
8
8
  export { Json, decodeJson, encodeJson, isRecord };
@@ -17,10 +17,20 @@ export declare const lenient: <const S extends Schema.Top>(schema: S) => Schema.
17
17
  export declare const ReportedBilling: Schema.Struct<{
18
18
  readonly cost: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Finite>, never>>;
19
19
  }>;
20
- /** Reads `ReportedBilling` from a raw usage object, which provider metadata keeps as the endpoint sent it. */
21
- export declare const reportedBilling: (usage: unknown) => {} | {
22
- cost: number | undefined;
20
+ /**
21
+ * Reads `ReportedBilling` from a raw usage object, which provider metadata keeps as the endpoint sent it, or
22
+ * Copilot's billing from the frames that carry the usage.
23
+ */
24
+ export declare const reportedBilling: (usage: unknown, ...frames: ReadonlyArray<unknown>) => {
25
+ cost: number;
26
+ } | {
27
+ cost?: undefined;
23
28
  };
29
+ /**
30
+ * The filter that blocked a response, from maps keyed by filter name: Azure's `content_filter_results`
31
+ * (`{ hate: { filtered: true } }`) or GitHub Copilot's `copilot_annotations` (`{ TextCopyright: [...] }`).
32
+ */
33
+ export declare const contentFilterCategory: (...sources: ReadonlyArray<unknown>) => string | undefined;
24
34
  /**
25
35
  * Accepts stream frames that carry no `type`, alongside the typed event schema. Gateways inject such frames as
26
36
  * keep-alives, so they decode as an ignored event; one with an `error` still decodes as an error event.
@@ -113,9 +123,6 @@ export declare const systemUpdateText: (route: string, message: Message) => Effe
113
123
  readonly type: "text";
114
124
  readonly text: string;
115
125
  readonly cache?: import("../schema/options.js").CacheHint | undefined;
116
- readonly metadata?: {
117
- readonly [x: string]: unknown;
118
- } | undefined;
119
126
  readonly providerMetadata?: {
120
127
  readonly [x: string]: {
121
128
  readonly [x: string]: unknown;
@@ -2,7 +2,7 @@ import { Tool } from "@opencode/schema/tool";
2
2
  import { Effect, Option, Predicate, Schema, SchemaGetter, SchemaTransformation } from "effect";
3
3
  import { Headers, HttpClientRequest } from "effect/http";
4
4
  import { Media } from "../media.js";
5
- import { InvalidProviderOutputError, InvalidRequestError, UnsupportedOperationError, AIError, LLMRequest, Message, ToolDefinition, } from "../schema/index.js";
5
+ import { InvalidProviderOutputError, InvalidRequestError, UnsupportedOperationError, AIError, AssistantMessage, Message, ToolDefinition, ToolMessage, } from "../schema/index.js";
6
6
  import { Json, decodeJson, encodeJson } from "../utils/json.js";
7
7
  import { isRecord } from "../utils/record.js";
8
8
  export { Json, decodeJson, encodeJson, isRecord };
@@ -23,11 +23,34 @@ const billedAmount = lenient(Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0
23
23
  export const ReportedBilling = Schema.Struct({
24
24
  cost: billedAmount,
25
25
  });
26
- /** Reads `ReportedBilling` from a raw usage object, which provider metadata keeps as the endpoint sent it. */
27
- export const reportedBilling = (usage) => Option.match(Schema.decodeUnknownOption(ReportedBilling)(usage), {
28
- onNone: () => ({}),
29
- onSome: (billing) => ({ cost: billing.cost }),
26
+ /**
27
+ * GitHub Copilot reports its charge beside usage on the frame that carries it, as `copilot_usage.total_nano_aiu`:
28
+ * billionths of an AI credit, which costs $0.01.
29
+ */
30
+ const CopilotBilling = Schema.Struct({
31
+ copilot_usage: Schema.Struct({ total_nano_aiu: Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0)) }),
30
32
  });
33
+ const decodeCopilotBilling = Schema.decodeUnknownOption(CopilotBilling);
34
+ /**
35
+ * Reads `ReportedBilling` from a raw usage object, which provider metadata keeps as the endpoint sent it, or
36
+ * Copilot's billing from the frames that carry the usage.
37
+ */
38
+ export const reportedBilling = (usage, ...frames) => {
39
+ const reported = Option.getOrUndefined(Schema.decodeUnknownOption(ReportedBilling)(usage))?.cost;
40
+ if (reported !== undefined)
41
+ return { cost: reported };
42
+ const nanoAiu = frames
43
+ .map((frame) => Option.getOrUndefined(decodeCopilotBilling(frame))?.copilot_usage.total_nano_aiu)
44
+ .find((value) => value !== undefined);
45
+ return nanoAiu === undefined ? {} : { cost: nanoAiu / 100_000_000_000 };
46
+ };
47
+ /**
48
+ * The filter that blocked a response, from maps keyed by filter name: Azure's `content_filter_results`
49
+ * (`{ hate: { filtered: true } }`) or GitHub Copilot's `copilot_annotations` (`{ TextCopyright: [...] }`).
50
+ */
51
+ export const contentFilterCategory = (...sources) => sources
52
+ .flatMap((source) => (isRecord(source) ? Object.entries(source) : []))
53
+ .find(([, value]) => (isRecord(value) && "filtered" in value ? value.filtered === true : Boolean(value)))?.[0];
31
54
  /**
32
55
  * Accepts stream frames that carry no `type`, alongside the typed event schema. Gateways inject such frames as
33
56
  * keep-alives, so they decode as an ignored event; one with an `error` still decodes as an error event.
@@ -46,7 +69,7 @@ export const knownString = () => Schema.declare((value) => typeof value === "str
46
69
  export const OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH = 64;
47
70
  // Body-level `prompt_cache_key` is off when caching is disabled or the model
48
71
  // explicitly rejects the field. Header-based affinity is unaffected.
49
- export const sendsPromptCacheKey = (request) => request.cache !== "none" && request.model.compatibility?.supportsPromptCacheKey !== false;
72
+ export const sendsPromptCacheKey = (request) => request.cache !== "none" && request.model.capabilities?.promptCacheKey !== false;
50
73
  // OpenAI limits `prompt_cache_key` to 64 chars; DeepSeek and Zai inherit the same
51
74
  // limit via their OpenAI-compatible APIs. Clamp with unicode-aware slicing.
52
75
  export const promptCacheKey = (request) => {
@@ -260,22 +283,24 @@ export const flattenTools = (tools, path = []) => {
260
283
  };
261
284
  export const flattenToolRequest = (request) => {
262
285
  const messages = request.messages.map((message) => {
263
- const content = message.content.map((part) => {
264
- if ((part.type !== "tool-call" && part.type !== "tool-result") || part.namespace === undefined)
265
- return part;
266
- return { ...part, name: `${part.namespace}_${part.name}`, namespace: undefined };
267
- });
268
- return content.every((part, index) => part === message.content[index])
269
- ? message
270
- : new Message({ ...message, content });
286
+ if (message.role === "assistant") {
287
+ const content = message.content.map((part) => part.type === "tool-call" || part.type === "tool-result" ? flattenToolName(part) : part);
288
+ return sameParts(content, message.content) ? message : new AssistantMessage({ ...message, content });
289
+ }
290
+ if (message.role !== "tool")
291
+ return message;
292
+ const content = message.content.map(flattenToolName);
293
+ return sameParts(content, message.content) ? message : new ToolMessage({ ...message, content });
271
294
  });
272
295
  return {
273
296
  tools: flattenTools(request.tools),
274
297
  request: messages.every((message, index) => message === request.messages[index])
275
298
  ? request
276
- : LLMRequest.update(request, { messages }),
299
+ : { ...request, messages },
277
300
  };
278
301
  };
302
+ const flattenToolName = (part) => part.namespace === undefined ? part : { ...part, name: `${part.namespace}_${part.name}`, namespace: undefined };
303
+ const sameParts = (next, previous) => next.every((part, index) => part === previous[index]);
279
304
  export const matchToolChoice = (route, toolChoice, cases) => Effect.gen(function* () {
280
305
  if (toolChoice.type === "auto")
281
306
  return cases.auto();
@@ -1,5 +1,5 @@
1
1
  import { Effect, Schema } from "effect";
2
- import { DecisionResponse, type DecisionModelCompatibility, type DecisionRequestFor } from "../decision.js";
2
+ import { DecisionResponse, type DecisionModelCompatibility, type DecisionRequest } from "../decision.js";
3
3
  import { DecisionRoute } from "../route/decision.js";
4
4
  import { AIError } from "../schema/index.js";
5
5
  export declare const DEFAULT_PATH = "/systemone";
@@ -33,7 +33,7 @@ export declare const Response: Schema.Struct<{
33
33
  }>;
34
34
  export type Response = Schema.Schema.Type<typeof Response>;
35
35
  /** The System One body without `model`; media goes where the model's `mediaInput` says, else `fallback`. */
36
- export declare const encodeBody: (request: DecisionRequestFor, fallback: MediaInput) => Effect.Effect<{
36
+ export declare const encodeBody: (request: DecisionRequest<import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>, import("../decision.js").DecisionQuestions>, fallback: MediaInput) => Effect.Effect<{
37
37
  questions: any;
38
38
  state: unknown;
39
39
  assets?: undefined;
@@ -49,7 +49,7 @@ export declare const encodeBody: (request: DecisionRequestFor, fallback: MediaIn
49
49
  };
50
50
  }, AIError, never>;
51
51
  /** Map System One's answers, keyed by question name, back to the request's question order. */
52
- export declare const toResponse: (data: Response, request: DecisionRequestFor, providerMetadataKey: string, invalid: (message: string) => AIError) => Effect.Effect<never, AIError, never> | Effect.Effect<DecisionResponse, never, never>;
52
+ export declare const toResponse: (data: Response, request: DecisionRequest, providerMetadataKey: string, invalid: (message: string) => AIError) => Effect.Effect<never, AIError, never> | Effect.Effect<DecisionResponse, never, never>;
53
53
  export declare const protocol: DecisionRoute.Protocol;
54
54
  /** TypeSafe's API, the reference System One host; other hosts change the endpoint and auth with `route.with(...)`. */
55
55
  export declare const route: DecisionRoute.Route;
@@ -79,7 +79,7 @@ export declare const SystemOne: {
79
79
  readonly provider: Schema.optional<Schema.String>;
80
80
  readonly provider_metadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
81
81
  }>;
82
- readonly encodeBody: (request: DecisionRequestFor, fallback: MediaInput) => Effect.Effect<{
82
+ readonly encodeBody: (request: DecisionRequest<import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>, import("../decision.js").DecisionQuestions>, fallback: MediaInput) => Effect.Effect<{
83
83
  questions: any;
84
84
  state: unknown;
85
85
  assets?: undefined;
@@ -47,7 +47,14 @@ export const encodeBody = Effect.fn("SystemOne.encodeBody")(function* (request,
47
47
  });
48
48
  const encodeQuestions = (questions) => Effect.forEach(questions, (question) => {
49
49
  if (question.type === "predicate")
50
- return Effect.succeed([question.name, { type: "noul", instructions: question.instructions }]);
50
+ return Effect.succeed([
51
+ question.name,
52
+ {
53
+ type: "noul",
54
+ instructions: question.instructions,
55
+ ...(question.criteria === undefined ? {} : { criteria: question.criteria }),
56
+ },
57
+ ]);
51
58
  if (question.type === "score")
52
59
  return Effect.succeed([
53
60
  question.name,
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "effect";
2
2
  import { CacheTTL } from "../../schema/index.js";
3
- import { newBreakpoints } from "./cache.js";
3
+ import { newBreakpoints, take } from "./cache.js";
4
4
  // Bedrock cache markers are positional: emit a `cachePoint` block immediately
5
5
  // after the content the caller wants treated as a cacheable prefix. Bedrock
6
6
  // accepts an optional `ttl` such as "5m" or "1h" on cachePoint.
@@ -40,11 +40,8 @@ export const block = (breakpoints, cache) => {
40
40
  return undefined;
41
41
  if (cache?.type !== "ephemeral" && cache?.type !== "persistent")
42
42
  return undefined;
43
- if (breakpoints.remaining <= 0) {
44
- breakpoints.dropped += 1;
43
+ if (!take(breakpoints))
45
44
  return undefined;
46
- }
47
- breakpoints.remaining -= 1;
48
45
  // Older Claude releases cache for five minutes only, so a one-hour request falls back to the default.
49
46
  const ttl = cache.ttl === "1h" && !breakpoints.ttl1h ? undefined : cache.ttl;
50
47
  return { cachePoint: { type: "default", ...(ttl === undefined ? {} : { ttl }) } };
@@ -27,9 +27,6 @@ export declare const lower: (part: {
27
27
  readonly media: import("../../media.js").Asset;
28
28
  readonly filename?: string | undefined;
29
29
  readonly cache?: import("../../schema/options.js").CacheHint | undefined;
30
- readonly metadata?: {
31
- readonly [x: string]: unknown;
32
- } | undefined;
33
30
  readonly providerMetadata?: {
34
31
  readonly [x: string]: {
35
32
  readonly [x: string]: unknown;
@@ -1,9 +1,12 @@
1
+ import { Effect } from "effect";
1
2
  import type { CacheHint, CacheTTL } from "../../schema/index.js";
2
3
  export interface Breakpoints {
3
4
  remaining: number;
4
5
  dropped: number;
5
6
  }
6
7
  export declare const newBreakpoints: (cap: number) => Breakpoints;
8
+ export declare const take: (breakpoints: Breakpoints) => boolean;
9
+ export declare const warnDropped: (breakpoints: Breakpoints, protocol: string, cap: number) => Effect.Effect<void, never, never>;
7
10
  export declare const cacheControl: () => (cache: CacheHint | undefined) => {
8
11
  type: "ephemeral";
9
12
  ttl: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
@@ -1,10 +1,23 @@
1
+ // Shared counter and lifetime mapping for provider cache lowering.
2
+ import { Effect } from "effect";
1
3
  export const newBreakpoints = (cap) => ({ remaining: cap, dropped: 0 });
4
+ // Spends one breakpoint, or records it as dropped once the budget is gone.
5
+ export const take = (breakpoints) => {
6
+ if (breakpoints.remaining <= 0) {
7
+ breakpoints.dropped += 1;
8
+ return false;
9
+ }
10
+ breakpoints.remaining -= 1;
11
+ return true;
12
+ };
13
+ export const warnDropped = (breakpoints, protocol, cap) => breakpoints.dropped === 0
14
+ ? Effect.void
15
+ : Effect.logWarning(`${protocol}: dropped ${breakpoints.dropped} cache breakpoint(s); the API allows at most ${cap} per request.`);
2
16
  export const cacheControl = () => {
3
17
  const breakpoints = newBreakpoints(4);
4
18
  return (cache) => {
5
- if (cache === undefined || breakpoints.remaining === 0)
19
+ if (cache === undefined || !take(breakpoints))
6
20
  return undefined;
7
- breakpoints.remaining -= 1;
8
21
  return { type: "ephemeral", ttl: cache.ttl };
9
22
  };
10
23
  };
@@ -27,5 +27,5 @@ export declare const fit: (shape: Shape, limits: Limits) => Size;
27
27
  /** The listed size closest to the shape: nearest aspect ratio first, then nearest pixel count. */
28
28
  export declare const nearest: (shape: Shape, sizes: ReadonlyArray<Size>) => Size;
29
29
  /** Free width and height that must honor the shape; a size that misses it fails. */
30
- export declare const exact: (route: MediaProtocol.Identity, shape: Shape, limits: Limits) => Effect.Effect<undefined, never, never> | Effect.Effect<never, import("../../effect.js").AIError, never> | Effect.Effect<Size, never, never>;
30
+ export declare const exact: (route: MediaProtocol.Identity, shape: Shape, limits: Limits) => Effect.Effect<undefined, never, never> | Effect.Effect<never, import("../../public.js").AIError, never> | Effect.Effect<Size, never, never>;
31
31
  export * as ImageSizing from "./image-sizing.js";
@@ -1,7 +1,7 @@
1
1
  import { Effect, Schema, Stream } from "effect";
2
2
  import { Route } from "../../route/client.js";
3
3
  import { Protocol } from "../../route/protocol.js";
4
- import { CompactionCheckpointResponse, LLMEvent, LLMRequest } from "../../schema/index.js";
4
+ import { CompactionCheckpointResponse, LLMEvent } from "../../schema/index.js";
5
5
  import { OpenResponses } from "../open-responses.js";
6
6
  import { ProviderShared } from "../shared.js";
7
7
  const onOutputItem = Effect.fnUntraced(function* (state, input) {
@@ -1,5 +1,5 @@
1
1
  import { Effect } from "effect";
2
- import { AIError, LLMRequest } from "../../schema/index.js";
2
+ import { AIError, type LLMRequest } from "../../schema/index.js";
3
3
  import type { CompactOperation } from "../../route/client.js";
4
4
  import { OpenResponses } from "../open-responses.js";
5
5
  export declare const make: (adapter: OpenResponses.ProviderAdapter, lowerTools: (request: LLMRequest) => Effect.Effect<ReadonlyArray<Record<string, unknown>>, AIError>) => CompactOperation;
@@ -1,5 +1,5 @@
1
1
  import { Effect, Schema, Stream } from "effect";
2
- import { AIError, InvalidProviderOutputError, CompactionPart, CompactionResponse, HttpOptions, LLMRequest, Message, mergeJsonRecords, } from "../../schema/index.js";
2
+ import { AIError, InvalidProviderOutputError, CompactionPart, CompactionResponse, Message, mergeJsonRecords, } from "../../schema/index.js";
3
3
  import { stripEffortUpdates } from "../../effort-updates.js";
4
4
  import { Endpoint } from "../../route/endpoint.js";
5
5
  import { RequestExecutor } from "../../route/executor.js";
@@ -79,9 +79,10 @@ export const make = (adapter, lowerTools) => Effect.fn("ResponsesCompaction.exec
79
79
  const url = Endpoint.render(route.endpoint, { request, body: native });
80
80
  url.pathname = `${url.pathname.replace(/\/$/, "")}/compact`;
81
81
  const parts = yield* HttpTransport.jsonRequestParts({
82
- request: LLMRequest.update(request, {
83
- http: request.http === undefined ? undefined : new HttpOptions({ ...request.http, body: undefined }),
84
- }),
82
+ request: {
83
+ ...request,
84
+ http: request.http === undefined ? undefined : { ...request.http, body: undefined },
85
+ },
85
86
  body,
86
87
  endpoint: Endpoint.path(url.toString()),
87
88
  auth: route.auth,
@@ -92,7 +93,7 @@ export const make = (adapter, lowerTools) => Effect.fn("ResponsesCompaction.exec
92
93
  body: parts.bodyText,
93
94
  headers: parts.headers,
94
95
  encoding: request.http?.encoding,
95
- }), options?.http);
96
+ }), RequestExecutor.withFetch(request.fetch, options?.http));
96
97
  const text = yield* RequestExecutor.responseStream(response).pipe(Stream.decodeText(), Stream.runFold(() => "", (text, chunk) => text + chunk));
97
98
  const invalid = (message, cause) => new AIError({
98
99
  reason: new InvalidProviderOutputError({