@opencode/ai 0.0.0-beta-19275

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 (252) hide show
  1. package/README.md +682 -0
  2. package/dist/cache-policy.d.ts +2 -0
  3. package/dist/cache-policy.js +129 -0
  4. package/dist/image-client.d.ts +19 -0
  5. package/dist/image-client.js +28 -0
  6. package/dist/image.d.ts +110 -0
  7. package/dist/image.js +103 -0
  8. package/dist/index.d.ts +18 -0
  9. package/dist/index.js +12 -0
  10. package/dist/llm.d.ts +252 -0
  11. package/dist/llm.js +74 -0
  12. package/dist/protocols/anthropic-messages.d.ts +957 -0
  13. package/dist/protocols/anthropic-messages.js +1414 -0
  14. package/dist/protocols/bedrock-converse.d.ts +499 -0
  15. package/dist/protocols/bedrock-converse.js +643 -0
  16. package/dist/protocols/bedrock-event-stream.d.ts +9 -0
  17. package/dist/protocols/bedrock-event-stream.js +97 -0
  18. package/dist/protocols/gemini.d.ts +285 -0
  19. package/dist/protocols/gemini.js +671 -0
  20. package/dist/protocols/google-images.d.ts +30 -0
  21. package/dist/protocols/google-images.js +181 -0
  22. package/dist/protocols/index.d.ts +12 -0
  23. package/dist/protocols/index.js +12 -0
  24. package/dist/protocols/meta-images.d.ts +26 -0
  25. package/dist/protocols/meta-images.js +89 -0
  26. package/dist/protocols/meta-messages.d.ts +350 -0
  27. package/dist/protocols/meta-messages.js +41 -0
  28. package/dist/protocols/meta-responses.d.ts +473 -0
  29. package/dist/protocols/meta-responses.js +173 -0
  30. package/dist/protocols/mistral-chat.d.ts +540 -0
  31. package/dist/protocols/mistral-chat.js +624 -0
  32. package/dist/protocols/open-responses-channel.d.ts +23 -0
  33. package/dist/protocols/open-responses-channel.js +141 -0
  34. package/dist/protocols/open-responses-continuation.d.ts +12 -0
  35. package/dist/protocols/open-responses-continuation.js +161 -0
  36. package/dist/protocols/open-responses.d.ts +1583 -0
  37. package/dist/protocols/open-responses.js +1206 -0
  38. package/dist/protocols/openai-chat.d.ts +860 -0
  39. package/dist/protocols/openai-chat.js +966 -0
  40. package/dist/protocols/openai-compatible-chat.d.ts +109 -0
  41. package/dist/protocols/openai-compatible-chat.js +19 -0
  42. package/dist/protocols/openai-compatible-responses.d.ts +172 -0
  43. package/dist/protocols/openai-compatible-responses.js +18 -0
  44. package/dist/protocols/openai-images.d.ts +32 -0
  45. package/dist/protocols/openai-images.js +183 -0
  46. package/dist/protocols/openai-responses.d.ts +1389 -0
  47. package/dist/protocols/openai-responses.js +260 -0
  48. package/dist/protocols/shared.d.ts +193 -0
  49. package/dist/protocols/shared.js +290 -0
  50. package/dist/protocols/utils/bedrock-auth.d.ts +60 -0
  51. package/dist/protocols/utils/bedrock-auth.js +85 -0
  52. package/dist/protocols/utils/bedrock-cache.d.ts +19 -0
  53. package/dist/protocols/utils/bedrock-cache.js +49 -0
  54. package/dist/protocols/utils/bedrock-media.d.ts +55 -0
  55. package/dist/protocols/utils/bedrock-media.js +73 -0
  56. package/dist/protocols/utils/cache.d.ts +6 -0
  57. package/dist/protocols/utils/cache.js +5 -0
  58. package/dist/protocols/utils/gemini-tool-schema.d.ts +2 -0
  59. package/dist/protocols/utils/gemini-tool-schema.js +103 -0
  60. package/dist/protocols/utils/image-input.d.ts +21 -0
  61. package/dist/protocols/utils/image-input.js +20 -0
  62. package/dist/protocols/utils/lifecycle.d.ts +24 -0
  63. package/dist/protocols/utils/lifecycle.js +72 -0
  64. package/dist/protocols/utils/meta-image.d.ts +2 -0
  65. package/dist/protocols/utils/meta-image.js +13 -0
  66. package/dist/protocols/utils/open-responses-options.d.ts +56 -0
  67. package/dist/protocols/utils/open-responses-options.js +61 -0
  68. package/dist/protocols/utils/openai-image.d.ts +5 -0
  69. package/dist/protocols/utils/openai-image.js +18 -0
  70. package/dist/protocols/utils/openai-options.d.ts +16 -0
  71. package/dist/protocols/utils/openai-options.js +14 -0
  72. package/dist/protocols/utils/partial-json-options.d.ts +62 -0
  73. package/dist/protocols/utils/partial-json-options.js +52 -0
  74. package/dist/protocols/utils/partial-json.d.ts +8 -0
  75. package/dist/protocols/utils/partial-json.js +279 -0
  76. package/dist/protocols/utils/responses-checkpoint.d.ts +4 -0
  77. package/dist/protocols/utils/responses-checkpoint.js +107 -0
  78. package/dist/protocols/utils/responses-compaction.d.ts +4 -0
  79. package/dist/protocols/utils/responses-compaction.js +129 -0
  80. package/dist/protocols/utils/responses-hosted-tools.d.ts +26 -0
  81. package/dist/protocols/utils/responses-hosted-tools.js +32 -0
  82. package/dist/protocols/utils/tool-schema.d.ts +8 -0
  83. package/dist/protocols/utils/tool-schema.js +54 -0
  84. package/dist/protocols/utils/tool-stream.d.ts +710 -0
  85. package/dist/protocols/utils/tool-stream.js +155 -0
  86. package/dist/protocols/xai-images.d.ts +26 -0
  87. package/dist/protocols/xai-images.js +106 -0
  88. package/dist/protocols/xai-responses.d.ts +250 -0
  89. package/dist/protocols/xai-responses.js +81 -0
  90. package/dist/protocols/zai-images.d.ts +22 -0
  91. package/dist/protocols/zai-images.js +79 -0
  92. package/dist/protocols.d.ts +1 -0
  93. package/dist/protocols.js +1 -0
  94. package/dist/provider-error.d.ts +15 -0
  95. package/dist/provider-error.js +125 -0
  96. package/dist/provider-package.d.ts +11 -0
  97. package/dist/provider-package.js +1 -0
  98. package/dist/provider.d.ts +23 -0
  99. package/dist/provider.js +2 -0
  100. package/dist/providers/amazon-bedrock/mantle/chat.d.ts +2 -0
  101. package/dist/providers/amazon-bedrock/mantle/chat.js +1 -0
  102. package/dist/providers/amazon-bedrock/mantle/responses.d.ts +2 -0
  103. package/dist/providers/amazon-bedrock/mantle/responses.js +1 -0
  104. package/dist/providers/amazon-bedrock/mantle.d.ts +2 -0
  105. package/dist/providers/amazon-bedrock/mantle.js +1 -0
  106. package/dist/providers/amazon-bedrock-mantle.d.ts +371 -0
  107. package/dist/providers/amazon-bedrock-mantle.js +76 -0
  108. package/dist/providers/amazon-bedrock.d.ts +173 -0
  109. package/dist/providers/amazon-bedrock.js +41 -0
  110. package/dist/providers/anthropic-compatible.d.ts +304 -0
  111. package/dist/providers/anthropic-compatible.js +44 -0
  112. package/dist/providers/anthropic.d.ts +302 -0
  113. package/dist/providers/anthropic.js +39 -0
  114. package/dist/providers/azure/chat.d.ts +2 -0
  115. package/dist/providers/azure/chat.js +1 -0
  116. package/dist/providers/azure/responses.d.ts +2 -0
  117. package/dist/providers/azure/responses.js +1 -0
  118. package/dist/providers/azure.d.ts +599 -0
  119. package/dist/providers/azure.js +115 -0
  120. package/dist/providers/baseten.d.ts +229 -0
  121. package/dist/providers/baseten.js +38 -0
  122. package/dist/providers/cerebras.d.ts +228 -0
  123. package/dist/providers/cerebras.js +40 -0
  124. package/dist/providers/cloudflare-ai-gateway.d.ts +238 -0
  125. package/dist/providers/cloudflare-ai-gateway.js +59 -0
  126. package/dist/providers/cloudflare-workers-ai.d.ts +232 -0
  127. package/dist/providers/cloudflare-workers-ai.js +45 -0
  128. package/dist/providers/deepinfra.d.ts +228 -0
  129. package/dist/providers/deepinfra.js +43 -0
  130. package/dist/providers/deepseek.d.ts +229 -0
  131. package/dist/providers/deepseek.js +41 -0
  132. package/dist/providers/fireworks.d.ts +229 -0
  133. package/dist/providers/fireworks.js +38 -0
  134. package/dist/providers/google-vertex/chat.d.ts +2 -0
  135. package/dist/providers/google-vertex/chat.js +1 -0
  136. package/dist/providers/google-vertex/gemini.d.ts +2 -0
  137. package/dist/providers/google-vertex/gemini.js +1 -0
  138. package/dist/providers/google-vertex/messages.d.ts +2 -0
  139. package/dist/providers/google-vertex/messages.js +1 -0
  140. package/dist/providers/google-vertex/responses.d.ts +2 -0
  141. package/dist/providers/google-vertex/responses.js +1 -0
  142. package/dist/providers/google-vertex-chat.d.ts +133 -0
  143. package/dist/providers/google-vertex-chat.js +55 -0
  144. package/dist/providers/google-vertex-messages.d.ts +301 -0
  145. package/dist/providers/google-vertex-messages.js +75 -0
  146. package/dist/providers/google-vertex-responses.d.ts +198 -0
  147. package/dist/providers/google-vertex-responses.js +56 -0
  148. package/dist/providers/google-vertex-shared.d.ts +22 -0
  149. package/dist/providers/google-vertex-shared.js +61 -0
  150. package/dist/providers/google-vertex.d.ts +120 -0
  151. package/dist/providers/google-vertex.js +92 -0
  152. package/dist/providers/google.d.ts +115 -0
  153. package/dist/providers/google.js +42 -0
  154. package/dist/providers/groq.d.ts +315 -0
  155. package/dist/providers/groq.js +81 -0
  156. package/dist/providers/index.d.ts +28 -0
  157. package/dist/providers/index.js +28 -0
  158. package/dist/providers/meta/chat.d.ts +2 -0
  159. package/dist/providers/meta/chat.js +1 -0
  160. package/dist/providers/meta/messages.d.ts +2 -0
  161. package/dist/providers/meta/messages.js +1 -0
  162. package/dist/providers/meta/responses.d.ts +2 -0
  163. package/dist/providers/meta/responses.js +1 -0
  164. package/dist/providers/meta.d.ts +631 -0
  165. package/dist/providers/meta.js +113 -0
  166. package/dist/providers/minimax/chat.d.ts +4 -0
  167. package/dist/providers/minimax/chat.js +8 -0
  168. package/dist/providers/minimax/messages.d.ts +1 -0
  169. package/dist/providers/minimax/messages.js +1 -0
  170. package/dist/providers/minimax/responses.d.ts +4 -0
  171. package/dist/providers/minimax/responses.js +8 -0
  172. package/dist/providers/minimax.d.ts +593 -0
  173. package/dist/providers/minimax.js +89 -0
  174. package/dist/providers/mistral.d.ts +208 -0
  175. package/dist/providers/mistral.js +28 -0
  176. package/dist/providers/open-responses-options.d.ts +6 -0
  177. package/dist/providers/open-responses-options.js +1 -0
  178. package/dist/providers/openai/chat.d.ts +2 -0
  179. package/dist/providers/openai/chat.js +1 -0
  180. package/dist/providers/openai/responses.d.ts +2 -0
  181. package/dist/providers/openai/responses.js +1 -0
  182. package/dist/providers/openai-compatible/responses.d.ts +1 -0
  183. package/dist/providers/openai-compatible/responses.js +1 -0
  184. package/dist/providers/openai-compatible-responses.d.ts +196 -0
  185. package/dist/providers/openai-compatible-responses.js +32 -0
  186. package/dist/providers/openai-compatible.d.ts +131 -0
  187. package/dist/providers/openai-compatible.js +33 -0
  188. package/dist/providers/openai-options.d.ts +26 -0
  189. package/dist/providers/openai-options.js +41 -0
  190. package/dist/providers/openai.d.ts +405 -0
  191. package/dist/providers/openai.js +82 -0
  192. package/dist/providers/openrouter.d.ts +564 -0
  193. package/dist/providers/openrouter.js +114 -0
  194. package/dist/providers/togetherai.d.ts +228 -0
  195. package/dist/providers/togetherai.js +40 -0
  196. package/dist/providers/xai.d.ts +164 -0
  197. package/dist/providers/xai.js +84 -0
  198. package/dist/providers/zai.d.ts +24 -0
  199. package/dist/providers/zai.js +21 -0
  200. package/dist/providers.d.ts +1 -0
  201. package/dist/providers.js +1 -0
  202. package/dist/route/auth-options.d.ts +34 -0
  203. package/dist/route/auth-options.js +14 -0
  204. package/dist/route/auth.d.ts +51 -0
  205. package/dist/route/auth.js +87 -0
  206. package/dist/route/client.d.ts +430 -0
  207. package/dist/route/client.js +304 -0
  208. package/dist/route/endpoint.d.ts +28 -0
  209. package/dist/route/endpoint.js +21 -0
  210. package/dist/route/executor.d.ts +27 -0
  211. package/dist/route/executor.js +183 -0
  212. package/dist/route/framing.d.ts +29 -0
  213. package/dist/route/framing.js +14 -0
  214. package/dist/route/index.d.ts +16 -0
  215. package/dist/route/index.js +9 -0
  216. package/dist/route/protocol.d.ts +76 -0
  217. package/dist/route/protocol.js +16 -0
  218. package/dist/route/transport/http.d.ts +34 -0
  219. package/dist/route/transport/http.js +68 -0
  220. package/dist/route/transport/index.d.ts +41 -0
  221. package/dist/route/transport/index.js +4 -0
  222. package/dist/route/transport/websocket-channel.d.ts +57 -0
  223. package/dist/route/transport/websocket-channel.js +1 -0
  224. package/dist/route/transport/websocket.d.ts +56 -0
  225. package/dist/route/transport/websocket.js +366 -0
  226. package/dist/route.d.ts +1 -0
  227. package/dist/route.js +1 -0
  228. package/dist/schema/errors.d.ts +158 -0
  229. package/dist/schema/errors.js +120 -0
  230. package/dist/schema/events.d.ts +8123 -0
  231. package/dist/schema/events.js +550 -0
  232. package/dist/schema/ids.d.ts +17 -0
  233. package/dist/schema/ids.js +10 -0
  234. package/dist/schema/index.d.ts +5 -0
  235. package/dist/schema/index.js +5 -0
  236. package/dist/schema/messages.d.ts +646 -0
  237. package/dist/schema/messages.js +301 -0
  238. package/dist/schema/options.d.ts +157 -0
  239. package/dist/schema/options.js +187 -0
  240. package/dist/testing.d.ts +1693 -0
  241. package/dist/testing.js +129 -0
  242. package/dist/tool-history.d.ts +2 -0
  243. package/dist/tool-history.js +84 -0
  244. package/dist/tool-runtime.d.ts +15 -0
  245. package/dist/tool-runtime.js +62 -0
  246. package/dist/tool.d.ts +136 -0
  247. package/dist/tool.js +66 -0
  248. package/dist/utils/record.d.ts +2 -0
  249. package/dist/utils/record.js +2 -0
  250. package/dist/utils/sanitize.d.ts +1 -0
  251. package/dist/utils/sanitize.js +12 -0
  252. package/package.json +48 -0
@@ -0,0 +1,304 @@
1
+ import { Cause, Context, Effect, Layer, Schema, Stream } from "effect";
2
+ import { Auth } from "./auth.js";
3
+ import { Endpoint } from "./endpoint.js";
4
+ import { RequestExecutor } from "./executor.js";
5
+ import { Framing } from "./framing.js";
6
+ import { HttpTransport } from "./transport/index.js";
7
+ import { applyCachePolicy } from "../cache-policy.js";
8
+ import { normalizeToolHistory } from "../tool-history.js";
9
+ import { sanitizeSurrogates } from "../utils/sanitize.js";
10
+ import * as ProviderShared from "../protocols/shared.js";
11
+ import { AIError, CompactionResponse, CompactionCheckpointResponse, AIErrorReason, GenerationOptions, HttpOptions, LLMRequest, LLMResponse, LanguageModel, LLMEvent, InvalidProviderOutputError, ProviderID, mergeGenerationOptions, mergeHttpOptions, mergeProviderOptions, } from "../schema/index.js";
12
+ const makeRouteLanguageModel = (route, mapped) => {
13
+ const provider = route.provider ?? ("provider" in mapped ? mapped.provider : undefined);
14
+ if (!provider)
15
+ throw new Error(`Route.model(${route.id}) requires a provider`);
16
+ if (!endpointBaseURL(route.endpoint))
17
+ throw new Error(`Route.model(${route.id}) requires an endpoint baseURL — configure it on the route first`);
18
+ return LanguageModel.make({
19
+ ...mapped,
20
+ provider,
21
+ route,
22
+ });
23
+ };
24
+ const mergeRouteDefaults = (base, patch) => {
25
+ const headers = mergeHeaders(base?.headers, patch.headers);
26
+ return {
27
+ ...base,
28
+ ...patch,
29
+ headers,
30
+ generation: mergeGenerationOptions(generationOptions(base?.generation), generationOptions(patch.generation)),
31
+ providerOptions: mergeProviderOptions(base?.providerOptions, patch.providerOptions),
32
+ http: mergeHttpOptions(base?.http, httpOptions(patch.http), headers === undefined ? undefined : new HttpOptions({ headers })),
33
+ };
34
+ };
35
+ const endpointBaseURL = (endpoint) => typeof endpoint.baseURL === "string" ? endpoint.baseURL : undefined;
36
+ const mergeHeaders = (...items) => {
37
+ const entries = items.flatMap((item) => item === undefined ? [] : Object.entries(item).filter((entry) => entry[1] !== undefined));
38
+ if (entries.length === 0)
39
+ return undefined;
40
+ return Object.fromEntries(entries);
41
+ };
42
+ export const generationOptions = (input) => input === undefined ? undefined : GenerationOptions.make(input);
43
+ export const httpOptions = (input) => {
44
+ if (input === undefined)
45
+ return input;
46
+ return HttpOptions.make(input);
47
+ };
48
+ export function canCompact(request, options) {
49
+ if (options?.mechanism === "trigger")
50
+ return request.model.route.compact?.trigger !== undefined;
51
+ if (options?.mechanism !== undefined && options.mechanism !== "endpoint")
52
+ return false;
53
+ return request.model.route.compact?.endpoint !== undefined;
54
+ }
55
+ const unsupportedCompaction = (request, mechanism) => {
56
+ if (mechanism !== undefined && mechanism !== "endpoint" && mechanism !== "trigger")
57
+ return ProviderShared.invalidRequest(`Unknown compaction mechanism: ${mechanism}`);
58
+ return ProviderShared.unsupportedOperation({
59
+ operation: mechanism === "trigger" ? "compact.trigger" : "compact",
60
+ provider: request.model.provider,
61
+ route: request.model.route.id,
62
+ message: `${request.model.provider}/${request.model.route.id} does not support ${mechanism === "trigger" ? "trigger" : "explicit"} compaction`,
63
+ });
64
+ };
65
+ export class Service extends Context.Service()("@opencode/LLMClient") {
66
+ }
67
+ const resolveRequestOptions = (request) => {
68
+ const messages = normalizeToolHistory(request.messages);
69
+ const normalized = messages === request.messages ? request : LLMRequest.update(request, { messages });
70
+ const routeDefaults = normalized.model.route.defaults;
71
+ const modelDefaults = normalized.model.defaults;
72
+ const generation = mergeGenerationOptions(routeDefaults.generation, modelDefaults?.generation, normalized.generation);
73
+ return LLMRequest.update(normalized, {
74
+ generation: generation ?? new GenerationOptions({}),
75
+ providerOptions: mergeProviderOptions(routeDefaults.providerOptions, modelDefaults?.providerOptions, normalized.providerOptions),
76
+ http: mergeHttpOptions(routeDefaults.http, modelDefaults?.http, normalized.http),
77
+ });
78
+ };
79
+ const streamError = (route, message, cause) => {
80
+ const failed = cause.reasons.find(Cause.isFailReason)?.error;
81
+ if (failed instanceof AIError)
82
+ return failed;
83
+ return ProviderShared.eventError(route, message, undefined, cause);
84
+ };
85
+ const incompleteStreamError = (route) => new AIError({
86
+ reason: new InvalidProviderOutputError({
87
+ message: "The provider response ended unexpectedly.",
88
+ classification: "incomplete-stream",
89
+ route,
90
+ }),
91
+ });
92
+ const requireTerminalEvent = (route) => (events) => Stream.suspend(() => {
93
+ let terminal = false;
94
+ return events.pipe(Stream.mapEffect((event) => {
95
+ if (terminal)
96
+ return Effect.fail(ProviderShared.eventError(route, `Provider emitted ${event.type} after the terminal event`));
97
+ if (LLMEvent.is.finish(event) || LLMEvent.is.providerError(event))
98
+ terminal = true;
99
+ return Effect.succeed(event);
100
+ }), Stream.onEnd(Effect.suspend(() => (terminal ? Effect.void : Effect.fail(incompleteStreamError(route))))));
101
+ });
102
+ function makeFromTransport(input) {
103
+ const protocol = input.protocol;
104
+ const encodeBody = Schema.encodeSync(Schema.fromJsonString(protocol.body.schema));
105
+ const decodeEventEffect = Schema.decodeUnknownEffect(protocol.stream.event);
106
+ const decodeEvent = (route) => (frame) => decodeEventEffect(frame).pipe(Effect.mapError((cause) => ProviderShared.eventError(input.id, `Invalid ${route} stream event`, typeof frame === "string" ? frame : ProviderShared.encodeJson(frame), cause)));
107
+ const build = (routeInput) => {
108
+ const route = {
109
+ compact: routeInput.compact,
110
+ id: routeInput.id,
111
+ provider: routeInput.provider === undefined ? undefined : ProviderID.make(routeInput.provider),
112
+ providerMetadataKey: routeInput.providerMetadataKey,
113
+ protocol: protocol.id,
114
+ endpoint: routeInput.endpoint,
115
+ auth: routeInput.auth ?? Auth.none,
116
+ headers: routeInput.headers,
117
+ transport: routeInput.transport,
118
+ defaults: routeInput.defaults ?? {},
119
+ body: protocol.body,
120
+ with: (patch) => {
121
+ const { compact, id, provider, providerMetadataKey, auth, transport, endpoint, ...defaults } = patch;
122
+ return build({
123
+ ...routeInput,
124
+ compact: "compact" in patch ? compact : routeInput.compact,
125
+ id: id ?? routeInput.id,
126
+ provider: provider ?? routeInput.provider,
127
+ providerMetadataKey: providerMetadataKey ??
128
+ (provider !== undefined && String(provider) !== String(routeInput.provider)
129
+ ? String(provider)
130
+ : routeInput.providerMetadataKey),
131
+ auth: auth ?? routeInput.auth,
132
+ endpoint: endpoint ? Endpoint.merge(routeInput.endpoint, endpoint) : routeInput.endpoint,
133
+ transport: transport ?? routeInput.transport,
134
+ defaults: mergeRouteDefaults(route.defaults, defaults),
135
+ });
136
+ },
137
+ model: (input) => makeRouteLanguageModel(route, input),
138
+ prepareTransport: (body, request, options) => routeInput.transport.prepare({
139
+ body,
140
+ request,
141
+ endpoint: routeInput.endpoint,
142
+ auth: routeInput.auth ?? Auth.none,
143
+ encodeBody,
144
+ middleware: options?.http,
145
+ webSocket: options?.webSocket,
146
+ }),
147
+ streamPrepared: (prepared, request, runtime, options) => {
148
+ const route = `${request.model.provider}/${request.model.route.id}`;
149
+ return Stream.unwrap(routeInput.transport.execute(prepared, request, runtime, options).pipe(Effect.map((execution) => {
150
+ const terminal = protocol.stream.terminal;
151
+ // Preserve assembled inputs; replace only serialized event fallbacks with their original wire data.
152
+ const frameError = (frame, event = frame) => (error) => new AIError({
153
+ reason: AIErrorReason.make({
154
+ ...error.reason,
155
+ message: error.reason.message,
156
+ cause: error.reason.cause,
157
+ body: error.reason.body !== undefined && error.reason.body !== ProviderShared.encodeJson(event)
158
+ ? error.reason.body
159
+ : (execution.body?.(frame) ??
160
+ (typeof frame === "string" ? frame : ProviderShared.encodeJson(frame))),
161
+ }),
162
+ });
163
+ const events = execution.frames.pipe(Stream.mapEffect((frame) => decodeEvent(route)(frame).pipe(Effect.catchCause((cause) => Effect.fail(streamError(route, `Failed to decode ${route} event`, cause))), Effect.map((event) => ({ event, frame })), Effect.mapError(frameError(frame)))), terminal ? Stream.takeUntil(({ event }) => terminal(event)) : (stream) => stream);
164
+ const stream = Stream.suspend(() => {
165
+ let state = protocol.stream.initial(request);
166
+ const parsed = events.pipe(Stream.mapEffect(({ event, frame }) => protocol.stream.step(state, event).pipe(Effect.catchCause((cause) => Effect.fail(streamError(route, `Failed to parse ${route} event`, cause))), Effect.map(([next, output]) => {
167
+ state = next;
168
+ return output;
169
+ }), Effect.mapError(frameError(frame, event)))), Stream.flatMap(Stream.fromIterable));
170
+ const onHalt = protocol.stream.onHalt;
171
+ return onHalt
172
+ ? parsed.pipe(Stream.concat(Stream.suspend(() => Stream.unwrap(onHalt(state).pipe(Effect.map(Stream.fromIterable))))))
173
+ : parsed;
174
+ }).pipe(Stream.catchCause((cause) => Stream.fail(streamError(route, `Failed to read ${route} stream`, cause))), requireTerminalEvent(route), Stream.mapError((error) => new AIError({
175
+ reason: AIErrorReason.make({
176
+ ...error.reason,
177
+ message: error.reason.message,
178
+ cause: error.reason.cause,
179
+ http: error.reason.http ?? execution.http,
180
+ }),
181
+ })));
182
+ return execution.complete ? stream.pipe(Stream.onEnd(execution.complete)) : stream;
183
+ })));
184
+ },
185
+ };
186
+ return route;
187
+ };
188
+ return build({ ...input, defaults: mergeRouteDefaults(undefined, input.defaults ?? {}) });
189
+ }
190
+ export function make(input) {
191
+ if ("transport" in input)
192
+ return makeFromTransport(input);
193
+ const protocol = input.protocol;
194
+ return makeFromTransport({
195
+ compact: input.compact,
196
+ id: input.id,
197
+ provider: input.provider,
198
+ providerMetadataKey: input.providerMetadataKey,
199
+ protocol,
200
+ endpoint: input.endpoint,
201
+ auth: input.auth,
202
+ headers: input.headers,
203
+ transport: HttpTransport.httpJson({ framing: input.framing }),
204
+ defaults: input.defaults,
205
+ });
206
+ }
207
+ const prepareRequest = (request) => {
208
+ const original = resolveRequestOptions(request);
209
+ const sanitized = LLMRequest.update(original, sanitizeSurrogates({ ...LLMRequest.input(original), model: undefined }));
210
+ // Deduplicate per sibling level; a tool and a namespace may share a name.
211
+ const dedupe = (tools) => [...new Map(tools.map((tool) => [`${tool.type}:${tool.name}`, tool])).values()].map((tool) => tool.type === "tool" ? tool : { ...tool, tools: dedupe(tool.tools) });
212
+ const resolved = applyCachePolicy(LLMRequest.update(sanitized, { tools: dedupe(sanitized.tools) }));
213
+ const headers = resolved.model.route.headers?.({ request: resolved });
214
+ return headers === undefined
215
+ ? resolved
216
+ : LLMRequest.update(resolved, { http: mergeHttpOptions(new HttpOptions({ headers }), resolved.http) });
217
+ };
218
+ const compile = Effect.fn("LLM.compile")(function* (request, options) {
219
+ const resolved = prepareRequest(request);
220
+ const route = resolved.model.route;
221
+ const body = yield* route.body
222
+ .from(resolved)
223
+ .pipe(Effect.flatMap(ProviderShared.validateWith(Schema.decodeUnknownEffect(route.body.schema))));
224
+ const prepared = yield* route.prepareTransport(body, resolved, options);
225
+ return {
226
+ request: resolved,
227
+ route,
228
+ body,
229
+ prepared,
230
+ };
231
+ });
232
+ /** @internal Test-only projection of the execution compiler; not exported from package barrels. */
233
+ export const compileRequest = Effect.fn("LLM.compileRequest")(function* (request) {
234
+ const compiled = yield* compile(request);
235
+ return {
236
+ id: compiled.request.id ?? "request",
237
+ route: compiled.route.id,
238
+ protocol: compiled.route.protocol,
239
+ model: compiled.request.model,
240
+ body: compiled.body,
241
+ metadata: { transport: compiled.route.transport.id },
242
+ };
243
+ });
244
+ const streamRequestWith = (runtime) => (request, options) => Stream.unwrap(Effect.gen(function* () {
245
+ const compiled = yield* compile(request, options);
246
+ return compiled.route.streamPrepared(compiled.prepared, compiled.request, runtime, options);
247
+ }));
248
+ const generateWith = (stream) => Effect.fn("LLM.generate")(function* (request, options) {
249
+ const state = yield* stream(request, options).pipe(Stream.runFold(LLMResponse.empty, LLMResponse.reduce));
250
+ const response = LLMResponse.complete(state);
251
+ if (response)
252
+ return response;
253
+ return yield* incompleteStreamError(`${request.model.provider}/${request.model.route.id}`);
254
+ });
255
+ export function stream(request, options) {
256
+ return Stream.unwrap(Effect.gen(function* () {
257
+ return (yield* Service).stream(request, options);
258
+ }));
259
+ }
260
+ export function generate(request, options) {
261
+ return Effect.gen(function* () {
262
+ return yield* (yield* Service).generate(request, options);
263
+ });
264
+ }
265
+ export function compact(request, options) {
266
+ return Effect.gen(function* () {
267
+ const client = yield* Service;
268
+ if (options?.mechanism === "trigger" && canCompact(request, options))
269
+ return yield* client.compact(request, options);
270
+ if ((options?.mechanism === undefined || options.mechanism === "endpoint") && canCompact(request))
271
+ return yield* client.compact(request, options);
272
+ return yield* unsupportedCompaction(request, options?.mechanism);
273
+ });
274
+ }
275
+ export const streamRequest = (request, options) => Stream.unwrap(Effect.gen(function* () {
276
+ return (yield* Service).stream(request, options);
277
+ }));
278
+ export const layer = Layer.effect(Service, Effect.gen(function* () {
279
+ const executor = yield* RequestExecutor.Service;
280
+ const stream = streamRequestWith({ http: executor });
281
+ function compact(request, options) {
282
+ return Effect.suspend(() => {
283
+ if (options?.mechanism === "trigger" && canCompact(request, options))
284
+ return request.model.route.compact.trigger(prepareRequest(request), executor, options);
285
+ if ((options?.mechanism === undefined || options.mechanism === "endpoint") && canCompact(request))
286
+ return request.model.route.compact.endpoint(prepareRequest(request), executor, options);
287
+ return unsupportedCompaction(request, options?.mechanism);
288
+ });
289
+ }
290
+ return Service.of({
291
+ stream,
292
+ generate: generateWith(stream),
293
+ compact,
294
+ });
295
+ }));
296
+ export const Route = { make };
297
+ export const LLMClient = {
298
+ canCompact,
299
+ compact,
300
+ Service,
301
+ layer,
302
+ stream,
303
+ generate,
304
+ };
@@ -0,0 +1,28 @@
1
+ import type { LLMRequest } from "../schema/index.js";
2
+ export interface EndpointInput<Body> {
3
+ readonly request: LLMRequest;
4
+ readonly body: Body;
5
+ }
6
+ export type EndpointPart<Body> = string | ((input: EndpointInput<Body>) => string);
7
+ /**
8
+ * Declarative URL construction for one route.
9
+ *
10
+ * `Endpoint` carries URL construction for one route. Routes with a canonical
11
+ * host put `baseURL` here; provider helpers can override it by configuring the
12
+ * route before selecting a model.
13
+ *
14
+ * `path` may be a string or a function of `EndpointInput`, for routes whose
15
+ * URL embeds the model id, region, or another body field (e.g. Bedrock,
16
+ * Gemini).
17
+ */
18
+ export interface Definition<Body> {
19
+ readonly baseURL?: string;
20
+ readonly path: EndpointPart<Body>;
21
+ readonly query?: Record<string, string>;
22
+ }
23
+ export type EndpointPatch<Body> = Partial<Definition<Body>>;
24
+ /** Construct an `Endpoint` from a path string or path function. */
25
+ export declare const path: <Body>(value: EndpointPart<Body>, options?: Omit<Definition<Body>, "path">) => Definition<Body>;
26
+ export declare const merge: <Body>(base: Definition<Body>, patch: EndpointPatch<Body>) => Definition<Body>;
27
+ export declare const render: <Body>(endpoint: Definition<Body>, input: EndpointInput<Body>) => URL;
28
+ export * as Endpoint from "./endpoint.js";
@@ -0,0 +1,21 @@
1
+ import * as ProviderShared from "../protocols/shared.js";
2
+ /** Construct an `Endpoint` from a path string or path function. */
3
+ export const path = (value, options = {}) => ({
4
+ ...options,
5
+ path: value,
6
+ });
7
+ export const merge = (base, patch) => ({
8
+ ...base,
9
+ ...patch,
10
+ baseURL: patch.baseURL ?? base.baseURL,
11
+ path: patch.path ?? base.path,
12
+ query: patch.query === undefined ? base.query : { ...base.query, ...patch.query },
13
+ });
14
+ const renderPart = (part, input) => typeof part === "function" ? part(input) : part;
15
+ export const render = (endpoint, input) => {
16
+ const url = new URL(`${ProviderShared.trimBaseUrl(endpoint.baseURL ?? "")}${renderPart(endpoint.path, input)}`);
17
+ for (const [key, value] of Object.entries(endpoint.query ?? {}))
18
+ url.searchParams.set(key, value);
19
+ return url;
20
+ };
21
+ export * as Endpoint from "./endpoint.js";
@@ -0,0 +1,27 @@
1
+ import { Context, Effect, Layer, Stream } from "effect";
2
+ import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/unstable/http";
3
+ import { HttpContext, AIError } from "../schema/index.js";
4
+ export interface Interface {
5
+ readonly execute: (request: HttpClientRequest.HttpClientRequest, middleware?: HttpMiddleware) => Effect.Effect<HttpClientResponse.HttpClientResponse, AIError>;
6
+ }
7
+ export type HttpHandler = (request: HttpClientRequest.HttpClientRequest) => Effect.Effect<HttpClientResponse.HttpClientResponse, Error>;
8
+ export type HttpMiddleware = (request: HttpClientRequest.HttpClientRequest, handler: HttpHandler) => Effect.Effect<HttpClientResponse.HttpClientResponse, Error>;
9
+ declare const Service_base: Context.ServiceClass<Service, "@opencode/AI/RequestExecutor", Interface>;
10
+ export declare class Service extends Service_base {
11
+ }
12
+ export declare const responseHttp: (response: HttpClientResponse.HttpClientResponse) => HttpContext;
13
+ /** Preserve HTTP diagnostics for executor and externally captured failures alike. */
14
+ export declare const httpFailure: (input: {
15
+ readonly message: string;
16
+ readonly url?: string | undefined;
17
+ readonly status?: number | undefined;
18
+ readonly data?: unknown;
19
+ readonly responseHeaders?: Record<string, string> | undefined;
20
+ readonly responseBody?: string | undefined;
21
+ readonly cause?: unknown;
22
+ }) => AIError;
23
+ export declare const responseStream: (response: HttpClientResponse.HttpClientResponse) => Stream.Stream<Uint8Array, AIError>;
24
+ export declare const stream: (executor: Interface, request: HttpClientRequest.HttpClientRequest, middleware?: HttpMiddleware) => Stream.Stream<Uint8Array, AIError>;
25
+ export declare const layer: Layer.Layer<Service, never, HttpClient.HttpClient>;
26
+ export declare const fetchLayer: Layer.Layer<Service, never, never>;
27
+ export * as RequestExecutor from "./executor.js";
@@ -0,0 +1,183 @@
1
+ import { Cause, Context, Effect, Layer, Option, Schema, Stream } from "effect";
2
+ import { FetchHttpClient, Headers, HttpClient, HttpClientError, HttpClientRequest, HttpClientResponse, } from "effect/unstable/http";
3
+ import { HttpContext, HttpRateLimitDetails, AIError, TransportError } from "../schema/index.js";
4
+ import { classifyProviderFailure } from "../provider-error.js";
5
+ export class Service extends Context.Service()("@opencode/AI/RequestExecutor") {
6
+ }
7
+ const headerDetails = (headers) => Object.fromEntries(Object.entries(headers).map(([name, value]) => [name, String(value)]));
8
+ const normalizedHeaders = (headers) => Object.fromEntries(Object.entries(headers).map(([key, value]) => [key.toLowerCase(), value]));
9
+ const retryAfterMs = (headers) => {
10
+ const millis = Number(headers["retry-after-ms"]);
11
+ if (Number.isFinite(millis))
12
+ return Math.max(0, millis);
13
+ const value = headers["retry-after"];
14
+ if (!value)
15
+ return undefined;
16
+ const seconds = Number(value);
17
+ if (Number.isFinite(seconds))
18
+ return Math.max(0, seconds * 1000);
19
+ const date = Date.parse(value);
20
+ if (!Number.isNaN(date))
21
+ return Math.max(0, date - Date.now());
22
+ return undefined;
23
+ };
24
+ const addRateLimitValue = (target, key, value) => {
25
+ if (key.length > 0)
26
+ target[key] = value;
27
+ };
28
+ const rateLimitDetails = (headers, retryAfter) => {
29
+ const limit = {};
30
+ const remaining = {};
31
+ const reset = {};
32
+ Object.entries(headers).forEach(([name, value]) => {
33
+ const openaiLimit = /^x-ratelimit-limit-(.+)$/.exec(name)?.[1];
34
+ if (openaiLimit)
35
+ return addRateLimitValue(limit, openaiLimit, value);
36
+ const openaiRemaining = /^x-ratelimit-remaining-(.+)$/.exec(name)?.[1];
37
+ if (openaiRemaining)
38
+ return addRateLimitValue(remaining, openaiRemaining, value);
39
+ const openaiReset = /^x-ratelimit-reset-(.+)$/.exec(name)?.[1];
40
+ if (openaiReset)
41
+ return addRateLimitValue(reset, openaiReset, value);
42
+ const anthropic = /^anthropic-ratelimit-(.+)-(limit|remaining|reset)$/.exec(name);
43
+ if (!anthropic)
44
+ return;
45
+ if (anthropic[2] === "limit")
46
+ return addRateLimitValue(limit, anthropic[1], value);
47
+ if (anthropic[2] === "remaining")
48
+ return addRateLimitValue(remaining, anthropic[1], value);
49
+ return addRateLimitValue(reset, anthropic[1], value);
50
+ });
51
+ if (retryAfter === undefined &&
52
+ Object.keys(limit).length === 0 &&
53
+ Object.keys(remaining).length === 0 &&
54
+ Object.keys(reset).length === 0)
55
+ return undefined;
56
+ return new HttpRateLimitDetails({
57
+ retryAfterMs: retryAfter,
58
+ limit: Object.keys(limit).length === 0 ? undefined : limit,
59
+ remaining: Object.keys(remaining).length === 0 ? undefined : remaining,
60
+ reset: Object.keys(reset).length === 0 ? undefined : reset,
61
+ });
62
+ };
63
+ export const responseHttp = (response) => new HttpContext({
64
+ url: response.request.url,
65
+ status: response.status,
66
+ headers: headerDetails(response.headers),
67
+ });
68
+ const decodeProviderBody = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Struct({
69
+ message: Schema.optionalKey(Schema.String),
70
+ error: Schema.optionalKey(Schema.Struct({ message: Schema.optionalKey(Schema.String) })),
71
+ })));
72
+ const providerMessage = (status, body) => {
73
+ const decoded = body === undefined ? undefined : Option.getOrUndefined(decodeProviderBody(body));
74
+ return ([decoded?.error?.message, decoded?.message].find((message) => message?.trim()) ??
75
+ `Provider request failed with HTTP ${status}`);
76
+ };
77
+ const statusError = (response) => Effect.gen(function* () {
78
+ if (response.status < 400)
79
+ return response;
80
+ const result = yield* response.text.pipe(Effect.result);
81
+ return yield* httpFailure({
82
+ message: providerMessage(response.status, result._tag === "Success" ? result.success : undefined),
83
+ url: response.request.url,
84
+ status: response.status,
85
+ responseHeaders: headerDetails(response.headers),
86
+ responseBody: result._tag === "Success" ? result.success : undefined,
87
+ cause: result._tag === "Failure" ? (result.failure.cause ?? result.failure) : undefined,
88
+ });
89
+ });
90
+ /** Preserve HTTP diagnostics for executor and externally captured failures alike. */
91
+ export const httpFailure = (input) => {
92
+ const headers = normalizedHeaders(Headers.fromInput(input.responseHeaders));
93
+ const retryAfter = retryAfterMs(headers);
94
+ const rateLimit = rateLimitDetails(headers, retryAfter);
95
+ return new AIError({
96
+ reason: classifyProviderFailure({
97
+ message: input.message,
98
+ status: input.status,
99
+ data: input.data,
100
+ rawBody: input.responseBody,
101
+ retryAfterMs: retryAfter,
102
+ rateLimit,
103
+ cause: input.cause,
104
+ http: input.status === undefined || input.url === undefined
105
+ ? undefined
106
+ : new HttpContext({ url: input.url, status: input.status, headers }),
107
+ }),
108
+ });
109
+ };
110
+ const NativeTransportFailure = Schema.Struct({
111
+ message: Schema.String,
112
+ code: Schema.optionalKey(Schema.String),
113
+ cause: Schema.optionalKey(Schema.Unknown),
114
+ });
115
+ const decodeNativeTransportFailure = Schema.decodeUnknownOption(NativeTransportFailure);
116
+ const nativeTransportFailure = (error) => {
117
+ const failure = Option.getOrUndefined(decodeNativeTransportFailure(error));
118
+ if (!failure)
119
+ return undefined;
120
+ if (failure.code !== undefined)
121
+ return failure;
122
+ const cause = Option.getOrUndefined(decodeNativeTransportFailure(failure.cause));
123
+ if (cause?.code !== undefined)
124
+ return cause;
125
+ return failure;
126
+ };
127
+ const httpError = (input) => {
128
+ const request = HttpClientError.isHttpClientError(input.error) ? input.error.request : input.request;
129
+ const transportError = (failure) => new AIError({
130
+ reason: new TransportError({
131
+ message: failure.message,
132
+ cause: source,
133
+ http: input.http,
134
+ transport: "http",
135
+ operation: input.operation,
136
+ code: failure.code,
137
+ url: request.url,
138
+ }),
139
+ });
140
+ const source = HttpClientError.isHttpClientError(input.error) && "cause" in input.error.reason
141
+ ? (input.error.reason.cause ?? input.error)
142
+ : input.error;
143
+ const native = nativeTransportFailure(source);
144
+ const code = native?.code;
145
+ const raw = native?.message ?? (input.error instanceof Error ? input.error.message : undefined);
146
+ const detail = raw;
147
+ const message = code && detail && !detail.includes(code) ? `${code}: ${detail}` : detail;
148
+ if (Cause.isTimeoutError(input.error) || Cause.isTimeoutError(source))
149
+ return transportError({ message: message ?? "HTTP transport timed out", code: code ?? "Timeout" });
150
+ if (!HttpClientError.isHttpClientError(input.error))
151
+ return transportError({ message: message ?? "HTTP transport failed", code });
152
+ if (input.error.reason._tag === "TransportError") {
153
+ return transportError({
154
+ message: message ?? input.error.reason.description ?? "HTTP transport failed",
155
+ code: code ?? input.error.reason._tag,
156
+ });
157
+ }
158
+ return transportError({
159
+ message: message ?? `HTTP transport failed: ${input.error.reason._tag}`,
160
+ code: code ?? input.error.reason._tag,
161
+ });
162
+ };
163
+ export const responseStream = (response) => response.stream.pipe(Stream.mapError((error) => httpError({ error, request: response.request, operation: "read", http: responseHttp(response) })));
164
+ export const stream = (executor, request, middleware) => Stream.unwrap(Effect.gen(function* () {
165
+ const response = yield* executor.execute(request, middleware);
166
+ return responseStream(response);
167
+ }));
168
+ export const layer = Layer.effect(Service, Effect.gen(function* () {
169
+ const http = yield* HttpClient.HttpClient;
170
+ const executeOnce = (request, middleware) => Effect.gen(function* () {
171
+ if (!middleware)
172
+ return yield* http.execute(request).pipe(Effect.mapError((error) => httpError({ error, request, operation: "request" })), Effect.flatMap(statusError));
173
+ const response = yield* middleware(request, (input) => http
174
+ .execute(input)
175
+ .pipe(Effect.mapError((cause) => (cause instanceof Error ? cause : new Error(String(cause)))))).pipe(Effect.mapError((error) => httpError({ error, request, operation: "request" })));
176
+ return yield* statusError(response);
177
+ });
178
+ return Service.of({
179
+ execute: executeOnce,
180
+ });
181
+ }));
182
+ export const fetchLayer = layer.pipe(Layer.provide(FetchHttpClient.layer));
183
+ export * as RequestExecutor from "./executor.js";
@@ -0,0 +1,29 @@
1
+ import type { Stream } from "effect";
2
+ import type { AIError } from "../schema/index.js";
3
+ /**
4
+ * Decode a streaming HTTP response body into provider-protocol frames.
5
+ *
6
+ * `Framing` is the byte-stream-shaped seam between transport and protocol:
7
+ *
8
+ * - SSE (`Framing.sse`) — UTF-8 decode the body, run the SSE channel decoder,
9
+ * and emit the `data:` payload of each non-empty event. The default drops
10
+ * `[DONE]`; protocols that use it as a terminal select `sseWithDone`.
11
+ * - AWS event stream — length-prefixed binary frames with CRC checksums.
12
+ * Each emitted frame is one parsed binary event record.
13
+ *
14
+ * The frame type is opaque to this layer; the protocol's event schema decodes
15
+ * each frame before its state machine handles it.
16
+ */
17
+ export interface Definition<Frame> {
18
+ readonly id: string;
19
+ readonly frame: (bytes: Stream.Stream<Uint8Array, AIError>) => Stream.Stream<Frame, AIError>;
20
+ /** Original wire representation when framing transforms the provider payload. */
21
+ readonly body?: (frame: Frame) => string | undefined;
22
+ }
23
+ /** Server-Sent Events framing. Used by every JSON-streaming HTTP provider. */
24
+ export declare const sse: Definition<string>;
25
+ /** Server-Sent Events framing that retains the conventional `[DONE]` sentinel. */
26
+ export declare const sseWithDone: Definition<string>;
27
+ /** SSE framing restricted to protocol-recognized event names. */
28
+ export declare const sseEvents: (events: ReadonlySet<string>) => Definition<string>;
29
+ export * as Framing from "./framing.js";
@@ -0,0 +1,14 @@
1
+ import * as ProviderShared from "../protocols/shared.js";
2
+ /** Server-Sent Events framing. Used by every JSON-streaming HTTP provider. */
3
+ export const sse = { id: "sse", frame: ProviderShared.sseFraming };
4
+ /** Server-Sent Events framing that retains the conventional `[DONE]` sentinel. */
5
+ export const sseWithDone = {
6
+ id: "sse",
7
+ frame: (bytes) => ProviderShared.sseFraming(bytes, undefined, true),
8
+ };
9
+ /** SSE framing restricted to protocol-recognized event names. */
10
+ export const sseEvents = (events) => ({
11
+ id: "sse",
12
+ frame: (bytes) => ProviderShared.sseFraming(bytes, events),
13
+ });
14
+ export * as Framing from "./framing.js";
@@ -0,0 +1,16 @@
1
+ export { Route, LLMClient } from "./client.js";
2
+ export type { Route as RouteShape, RouteLanguageModelInput, RouteRoutedLanguageModelInput, RouteDefaults, RouteDefaultsInput, AnyRoute, Interface as LLMClientShape, Service as LLMClientService, StreamOptions, CompactMethod, CompactionOperations, CompactionRequest, CheckpointRequest, EndpointCompactOptions, TriggerCompactOptions, } from "./client.js";
3
+ export * from "./executor.js";
4
+ export { Auth } from "./auth.js";
5
+ export { AuthOptions } from "./auth-options.js";
6
+ export { Endpoint } from "./endpoint.js";
7
+ export { Framing } from "./framing.js";
8
+ export { Protocol } from "./protocol.js";
9
+ export { HttpTransport, WebSocketTransport } from "./transport/index.js";
10
+ export * as Transport from "./transport/index.js";
11
+ export type { Definition as AuthShape, AuthInput, Credential, CredentialError } from "./auth.js";
12
+ export type { ApiKeyMode, AuthOverride, ProviderAuthOption } from "./auth-options.js";
13
+ export type { Definition as EndpointFn, EndpointInput } from "./endpoint.js";
14
+ export type { Definition as FramingDef } from "./framing.js";
15
+ export type { Protocol as ProtocolDef } from "./protocol.js";
16
+ export type { ChannelCheckpoint, ChannelCreate, ChannelObservation, HttpHandler, HttpMiddleware, Transport as TransportDef, TransportExecuteOptions, TransportExecution, TransportRuntime, WebSocketConnection, WebSocketChannelDriver, WebSocketChannelExchange, WebSocketChannelExecution, WebSocketChannelExecutor, WebSocketConnector, WebSocketRequest, } from "./transport/index.js";
@@ -0,0 +1,9 @@
1
+ export { Route, LLMClient } from "./client.js";
2
+ export * from "./executor.js";
3
+ export { Auth } from "./auth.js";
4
+ export { AuthOptions } from "./auth-options.js";
5
+ export { Endpoint } from "./endpoint.js";
6
+ export { Framing } from "./framing.js";
7
+ export { Protocol } from "./protocol.js";
8
+ export { HttpTransport, WebSocketTransport } from "./transport/index.js";
9
+ export * as Transport from "./transport/index.js";