@scuffi/gardener 0.1.1

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 (21) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +17 -0
  3. package/assets/apps/gardener/dist/gardener_runtime/assets/anthropic-messages-CpAYOexF.js +6431 -0
  4. package/assets/apps/gardener/dist/gardener_runtime/assets/deferred-tools-BwNJSp7E.js +31 -0
  5. package/assets/apps/gardener/dist/gardener_runtime/assets/error-body-D8mmocwO.js +6744 -0
  6. package/assets/apps/gardener/dist/gardener_runtime/assets/hash-DAk4mnwB.js +18 -0
  7. package/assets/apps/gardener/dist/gardener_runtime/assets/json-parse-DCA_fvRV.js +1094 -0
  8. package/assets/apps/gardener/dist/gardener_runtime/assets/mimetext.node.es-XQfmuX2L.js +8403 -0
  9. package/assets/apps/gardener/dist/gardener_runtime/assets/openai-completions-Dg9BYhy-.js +907 -0
  10. package/assets/apps/gardener/dist/gardener_runtime/assets/openai-prompt-cache-IAZGhS1U.js +12 -0
  11. package/assets/apps/gardener/dist/gardener_runtime/assets/openai-responses-shared-BptkVdeL.js +560 -0
  12. package/assets/apps/gardener/dist/gardener_runtime/assets/openai-responses-vjbR2NOB.js +240 -0
  13. package/assets/apps/gardener/dist/gardener_runtime/assets/rolldown-runtime-7_rZTKki.js +42 -0
  14. package/assets/apps/gardener/dist/gardener_runtime/assets/simple-options-tFhuCUzS.js +300 -0
  15. package/assets/apps/gardener/dist/gardener_runtime/assets/transform-messages-B41ICucH.js +246 -0
  16. package/assets/apps/gardener/dist/gardener_runtime/index.js +80307 -0
  17. package/assets/apps/gardener/migrations/0001_actions_baseline.sql +116 -0
  18. package/assets/gardener-distribution.json +5 -0
  19. package/dist/cli.js +24719 -0
  20. package/dist/cli.js.map +7 -0
  21. package/package.json +45 -0
@@ -0,0 +1,907 @@
1
+ import { c as AssistantMessageEventStream, i as clampThinkingLevel, n as parseStreamingJson, r as calculateCost } from "./json-parse-DCA_fvRV.js";
2
+ import { a as hasCopilotVisionInput, c as getProviderEnvValue, i as buildCopilotDynamicHeaders, n as buildBaseOptions, o as retryProviderRequest, s as headersToRecord } from "./simple-options-tFhuCUzS.js";
3
+ import { a as resolveGrammarConstrainedSampling, i as getGrammarToolInput, n as appendGrammarToolInputJsonDelta, o as resolveJsonSchemaStrictSampling, r as createGrammarToolInputProperties, s as sanitizeSurrogates, t as transformMessages } from "./transform-messages-B41ICucH.js";
4
+ import { n as normalizeProviderError, r as OpenAI, t as formatProviderError } from "./error-body-D8mmocwO.js";
5
+ import { clampOpenAIPromptCacheKey } from "./openai-prompt-cache-IAZGhS1U.js";
6
+ import { t as shortHash } from "./hash-DAk4mnwB.js";
7
+ //#region ../../node_modules/.pnpm/@earendil-works+pi-ai@0.83.0_@modelcontextprotocol+sdk@1.30.0_@cfworker+json-schema@4.1_c038161535a4cc121d37390bb491fb78/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js
8
+ /**
9
+ * Check if conversation messages contain tool calls or tool results.
10
+ * This is needed because Anthropic (via proxy) requires the tools param
11
+ * to be present when messages include tool_calls or tool role messages.
12
+ */
13
+ function hasHeader(headers, name) {
14
+ if (!headers) return false;
15
+ const expected = name.toLowerCase();
16
+ for (const [key, value] of Object.entries(headers)) if (key.toLowerCase() === expected && value !== null && value.trim().length > 0) return true;
17
+ return false;
18
+ }
19
+ function getClientApiKey(provider, apiKey, headers) {
20
+ if (apiKey) return apiKey;
21
+ if (hasHeader(headers, "authorization") || hasHeader(headers, "cf-aig-authorization")) return "unused";
22
+ throw new Error(`No API key for provider: ${provider}`);
23
+ }
24
+ function hasToolHistory(messages) {
25
+ for (const msg of messages) {
26
+ if (msg.role === "toolResult") return true;
27
+ if (msg.role === "assistant") {
28
+ if (msg.content.some((block) => block.type === "toolCall")) return true;
29
+ }
30
+ }
31
+ return false;
32
+ }
33
+ function getDeferredToolNames(messages) {
34
+ const names = /* @__PURE__ */ new Set();
35
+ for (const message of messages) if (message.role === "toolResult") for (const name of message.addedToolNames ?? []) names.add(name);
36
+ return names;
37
+ }
38
+ function getToolsByName(tools, names) {
39
+ if (!tools) return [];
40
+ const toolsByName = new Map(tools.map((tool) => [tool.name, tool]));
41
+ return Array.from(names).map((name) => toolsByName.get(name)).filter((tool) => tool !== void 0);
42
+ }
43
+ function isTextContentBlock(block) {
44
+ return block.type === "text";
45
+ }
46
+ function isThinkingContentBlock(block) {
47
+ return block.type === "thinking";
48
+ }
49
+ function isToolCallBlock(block) {
50
+ return block.type === "toolCall";
51
+ }
52
+ function isImageContentBlock(block) {
53
+ return block.type === "image";
54
+ }
55
+ function isEncryptedReasoningDetail(detail) {
56
+ if (typeof detail !== "object" || detail === null) return false;
57
+ const candidate = detail;
58
+ return candidate.type === "reasoning.encrypted" && typeof candidate.id === "string" && candidate.id.length > 0 && typeof candidate.data === "string" && candidate.data.length > 0;
59
+ }
60
+ function resolveCacheRetention(cacheRetention, env) {
61
+ if (cacheRetention) return cacheRetention;
62
+ if (getProviderEnvValue("PI_CACHE_RETENTION", env) === "long") return "long";
63
+ return "short";
64
+ }
65
+ var stream = (model, context, options) => {
66
+ const stream = new AssistantMessageEventStream();
67
+ (async () => {
68
+ const output = {
69
+ role: "assistant",
70
+ content: [],
71
+ api: model.api,
72
+ provider: model.provider,
73
+ model: model.id,
74
+ usage: {
75
+ input: 0,
76
+ output: 0,
77
+ cacheRead: 0,
78
+ cacheWrite: 0,
79
+ totalTokens: 0,
80
+ cost: {
81
+ input: 0,
82
+ output: 0,
83
+ cacheRead: 0,
84
+ cacheWrite: 0,
85
+ total: 0
86
+ }
87
+ },
88
+ stopReason: "pending",
89
+ timestamp: Date.now()
90
+ };
91
+ try {
92
+ const apiKey = getClientApiKey(model.provider, options?.apiKey, options?.headers);
93
+ const compat = getCompat(model);
94
+ const grammarToolInputProperties = createGrammarToolInputProperties(context.tools, compat.supportsOpenAIGrammarTools);
95
+ const cacheRetention = resolveCacheRetention(options?.cacheRetention, options?.env);
96
+ const cacheSessionId = cacheRetention === "none" ? void 0 : options?.sessionId;
97
+ const client = createClient(model, context, apiKey, options?.headers, options?.fetch, cacheSessionId, compat);
98
+ let params = buildParams(model, context, options, compat, cacheRetention, grammarToolInputProperties);
99
+ const nextParams = await options?.onPayload?.(params, model);
100
+ if (nextParams !== void 0) params = nextParams;
101
+ const requestOptions = {
102
+ ...options?.signal ? { signal: options.signal } : {},
103
+ ...options?.timeoutMs !== void 0 ? { timeout: options.timeoutMs } : {},
104
+ maxRetries: 0
105
+ };
106
+ const { data: openaiStream, response } = await retryProviderRequest(() => client.chat.completions.create(params, requestOptions).withResponse(), {
107
+ maxRetries: options?.maxRetries,
108
+ maxRetryDelayMs: options?.maxRetryDelayMs,
109
+ signal: options?.signal
110
+ });
111
+ await options?.onResponse?.({
112
+ status: response.status,
113
+ headers: headersToRecord(response.headers)
114
+ }, model);
115
+ stream.push({
116
+ type: "start",
117
+ partial: output
118
+ });
119
+ let textBlock = null;
120
+ let thinkingBlock = null;
121
+ let hasFinishReason = false;
122
+ const toolCallBlocksByIndex = /* @__PURE__ */ new Map();
123
+ const toolCallBlocksById = /* @__PURE__ */ new Map();
124
+ const pendingReasoningDetailsByToolCallId = /* @__PURE__ */ new Map();
125
+ const blocks = output.content;
126
+ const getContentIndex = (block) => blocks.indexOf(block);
127
+ const getCustomToolCallInput = (block) => {
128
+ const property = block.customInput?.property;
129
+ if (property === void 0) return "";
130
+ const value = block.arguments[property];
131
+ return typeof value === "string" ? value : "";
132
+ };
133
+ const appendCustomToolCallInput = (block, nextInput, close) => {
134
+ const customInput = block.customInput;
135
+ if (!customInput) return void 0;
136
+ const delta = appendGrammarToolInputJsonDelta(customInput.jsonBuffer, customInput.property, nextInput, close);
137
+ block.arguments = { [customInput.property]: nextInput };
138
+ return delta;
139
+ };
140
+ const finishBlock = (block) => {
141
+ const contentIndex = getContentIndex(block);
142
+ if (contentIndex === -1) return;
143
+ if (block.type === "text") stream.push({
144
+ type: "text_end",
145
+ contentIndex,
146
+ content: block.text,
147
+ partial: output
148
+ });
149
+ else if (block.type === "thinking") stream.push({
150
+ type: "thinking_end",
151
+ contentIndex,
152
+ content: block.thinking,
153
+ partial: output
154
+ });
155
+ else if (block.type === "toolCall") {
156
+ if (block.customInput) {
157
+ const delta = appendCustomToolCallInput(block, getCustomToolCallInput(block), true);
158
+ if (delta !== void 0) stream.push({
159
+ type: "toolcall_delta",
160
+ contentIndex,
161
+ delta,
162
+ partial: output
163
+ });
164
+ } else block.arguments = parseStreamingJson(block.partialArgs);
165
+ delete block.partialArgs;
166
+ delete block.customInput;
167
+ delete block.streamIndex;
168
+ stream.push({
169
+ type: "toolcall_end",
170
+ contentIndex,
171
+ toolCall: block,
172
+ partial: output
173
+ });
174
+ }
175
+ };
176
+ const ensureTextBlock = () => {
177
+ if (!textBlock) {
178
+ textBlock = {
179
+ type: "text",
180
+ text: ""
181
+ };
182
+ blocks.push(textBlock);
183
+ stream.push({
184
+ type: "text_start",
185
+ contentIndex: getContentIndex(textBlock),
186
+ partial: output
187
+ });
188
+ }
189
+ return textBlock;
190
+ };
191
+ const ensureThinkingBlock = (thinkingSignature) => {
192
+ if (!thinkingBlock) {
193
+ thinkingBlock = {
194
+ type: "thinking",
195
+ thinking: "",
196
+ thinkingSignature
197
+ };
198
+ blocks.push(thinkingBlock);
199
+ stream.push({
200
+ type: "thinking_start",
201
+ contentIndex: getContentIndex(thinkingBlock),
202
+ partial: output
203
+ });
204
+ }
205
+ return thinkingBlock;
206
+ };
207
+ const applyPendingReasoningDetail = (block) => {
208
+ if (!block.id) return;
209
+ const pendingReasoningDetail = pendingReasoningDetailsByToolCallId.get(block.id);
210
+ if (pendingReasoningDetail) {
211
+ block.thoughtSignature = pendingReasoningDetail;
212
+ pendingReasoningDetailsByToolCallId.delete(block.id);
213
+ }
214
+ };
215
+ const ensureToolCallBlock = (toolCall) => {
216
+ const streamIndex = typeof toolCall.index === "number" ? toolCall.index : void 0;
217
+ const name = toolCall.function?.name ?? toolCall.custom?.name ?? "";
218
+ let block = streamIndex !== void 0 ? toolCallBlocksByIndex.get(streamIndex) : void 0;
219
+ if (!block && toolCall.id) block = toolCallBlocksById.get(toolCall.id);
220
+ if (!block) {
221
+ const customInputProperty = toolCall.custom && !toolCall.function ? grammarToolInputProperties.get(name) ?? "input" : void 0;
222
+ const hasCustomInput = customInputProperty !== void 0;
223
+ block = {
224
+ type: "toolCall",
225
+ id: toolCall.id || "",
226
+ name,
227
+ arguments: hasCustomInput ? { [customInputProperty]: "" } : {},
228
+ partialArgs: hasCustomInput ? void 0 : "",
229
+ customInput: hasCustomInput ? {
230
+ property: customInputProperty,
231
+ jsonBuffer: {
232
+ input: "",
233
+ started: false,
234
+ closed: false
235
+ }
236
+ } : void 0,
237
+ streamIndex
238
+ };
239
+ if (streamIndex !== void 0) toolCallBlocksByIndex.set(streamIndex, block);
240
+ if (toolCall.id) toolCallBlocksById.set(toolCall.id, block);
241
+ blocks.push(block);
242
+ stream.push({
243
+ type: "toolcall_start",
244
+ contentIndex: getContentIndex(block),
245
+ partial: output
246
+ });
247
+ }
248
+ if (streamIndex !== void 0 && block.streamIndex === void 0) {
249
+ block.streamIndex = streamIndex;
250
+ toolCallBlocksByIndex.set(streamIndex, block);
251
+ }
252
+ if (toolCall.id) toolCallBlocksById.set(toolCall.id, block);
253
+ if (!block.name && name) block.name = name;
254
+ if (toolCall.custom && !toolCall.function && !block.customInput) {
255
+ const customInputProperty = grammarToolInputProperties.get(block.name) ?? "input";
256
+ block.arguments = { [customInputProperty]: "" };
257
+ block.customInput = {
258
+ property: customInputProperty,
259
+ jsonBuffer: {
260
+ input: "",
261
+ started: false,
262
+ closed: false
263
+ }
264
+ };
265
+ delete block.partialArgs;
266
+ }
267
+ applyPendingReasoningDetail(block);
268
+ return block;
269
+ };
270
+ for await (const chunk of openaiStream) {
271
+ if (!chunk || typeof chunk !== "object") continue;
272
+ output.responseId ||= chunk.id;
273
+ if (typeof chunk.model === "string" && chunk.model.length > 0 && chunk.model !== model.id) output.responseModel ||= chunk.model;
274
+ if (chunk.usage) output.usage = parseChunkUsage(chunk.usage, model);
275
+ const choice = Array.isArray(chunk.choices) ? chunk.choices[0] : void 0;
276
+ if (!choice) continue;
277
+ if (!chunk.usage && choice.usage) output.usage = parseChunkUsage(choice.usage, model);
278
+ if (choice.finish_reason) {
279
+ output.rawStopReason = choice.finish_reason;
280
+ const finishReasonResult = mapStopReason(choice.finish_reason);
281
+ output.stopReason = finishReasonResult.stopReason;
282
+ if (finishReasonResult.errorMessage) output.errorMessage = finishReasonResult.errorMessage;
283
+ hasFinishReason = true;
284
+ }
285
+ if (choice.delta) {
286
+ if (choice.delta.content !== null && choice.delta.content !== void 0 && choice.delta.content.length > 0) {
287
+ const block = ensureTextBlock();
288
+ block.text += choice.delta.content;
289
+ stream.push({
290
+ type: "text_delta",
291
+ contentIndex: getContentIndex(block),
292
+ delta: choice.delta.content,
293
+ partial: output
294
+ });
295
+ }
296
+ const reasoningFields = [
297
+ "reasoning_content",
298
+ "reasoning",
299
+ "reasoning_text"
300
+ ];
301
+ const deltaFields = choice.delta;
302
+ let foundReasoningField = null;
303
+ for (const field of reasoningFields) {
304
+ const value = deltaFields[field];
305
+ if (typeof value === "string" && value.length > 0) {
306
+ foundReasoningField = field;
307
+ break;
308
+ }
309
+ }
310
+ if (foundReasoningField) {
311
+ const delta = deltaFields[foundReasoningField];
312
+ if (typeof delta === "string" && delta.length > 0) {
313
+ const block = ensureThinkingBlock(model.provider === "opencode-go" && foundReasoningField === "reasoning" ? "reasoning_content" : foundReasoningField);
314
+ block.thinking += delta;
315
+ stream.push({
316
+ type: "thinking_delta",
317
+ contentIndex: getContentIndex(block),
318
+ delta,
319
+ partial: output
320
+ });
321
+ }
322
+ }
323
+ if (choice?.delta?.tool_calls) for (const toolCall of choice.delta.tool_calls) {
324
+ const block = ensureToolCallBlock(toolCall);
325
+ if (!block.id && toolCall.id) {
326
+ block.id = toolCall.id;
327
+ toolCallBlocksById.set(toolCall.id, block);
328
+ }
329
+ const name = toolCall.function?.name ?? toolCall.custom?.name;
330
+ if (!block.name && name) block.name = name;
331
+ let delta = "";
332
+ if (toolCall.function?.arguments) {
333
+ delta = toolCall.function.arguments;
334
+ block.partialArgs = (block.partialArgs ?? "") + toolCall.function.arguments;
335
+ block.arguments = parseStreamingJson(block.partialArgs);
336
+ } else if (toolCall.custom?.input) delta = appendCustomToolCallInput(block, getCustomToolCallInput(block) + toolCall.custom.input, false) ?? "";
337
+ stream.push({
338
+ type: "toolcall_delta",
339
+ contentIndex: getContentIndex(block),
340
+ delta,
341
+ partial: output
342
+ });
343
+ }
344
+ const reasoningDetails = choice.delta.reasoning_details;
345
+ if (Array.isArray(reasoningDetails)) {
346
+ for (const detail of reasoningDetails) if (isEncryptedReasoningDetail(detail)) {
347
+ const serializedDetail = JSON.stringify(detail);
348
+ const matchingToolCall = toolCallBlocksById.get(detail.id);
349
+ if (matchingToolCall) matchingToolCall.thoughtSignature = serializedDetail;
350
+ else pendingReasoningDetailsByToolCallId.set(detail.id, serializedDetail);
351
+ }
352
+ }
353
+ }
354
+ }
355
+ for (const block of blocks) finishBlock(block);
356
+ if (options?.signal?.aborted) throw new Error("Request was aborted");
357
+ if (output.stopReason === "aborted") throw new Error("Request was aborted");
358
+ if (output.stopReason === "error") throw new Error(output.errorMessage || "Provider returned an error stop reason");
359
+ if (!hasFinishReason || output.stopReason === "pending") throw new Error("Stream ended without finish_reason");
360
+ stream.push({
361
+ type: "done",
362
+ reason: output.stopReason,
363
+ message: output
364
+ });
365
+ stream.end();
366
+ } catch (error) {
367
+ for (const block of output.content) {
368
+ delete block.index;
369
+ delete block.partialArgs;
370
+ delete block.customInput;
371
+ delete block.streamIndex;
372
+ }
373
+ output.stopReason = options?.signal?.aborted ? "aborted" : "error";
374
+ output.errorMessage = formatProviderError(normalizeProviderError(error));
375
+ const rawMetadata = error?.error?.metadata?.raw;
376
+ if (rawMetadata && !output.errorMessage.includes(String(rawMetadata))) output.errorMessage += `\n${rawMetadata}`;
377
+ stream.push({
378
+ type: "error",
379
+ reason: output.stopReason,
380
+ error: output
381
+ });
382
+ stream.end();
383
+ }
384
+ })();
385
+ return stream;
386
+ };
387
+ var streamSimple = (model, context, options) => {
388
+ getClientApiKey(model.provider, options?.apiKey, options?.headers);
389
+ const base = buildBaseOptions(model, context, options, options?.apiKey);
390
+ const clampedReasoning = options?.reasoning ? clampThinkingLevel(model, options.reasoning) : void 0;
391
+ const reasoningEffort = clampedReasoning === "off" ? void 0 : clampedReasoning;
392
+ const toolChoice = options?.toolChoice;
393
+ return stream(model, context, {
394
+ ...base,
395
+ reasoningEffort,
396
+ toolChoice
397
+ });
398
+ };
399
+ function createClient(model, context, apiKey, optionsHeaders, fetch, sessionId, compat = getCompat(model)) {
400
+ const headers = { ...model.headers };
401
+ if (model.provider === "github-copilot") {
402
+ const hasImages = hasCopilotVisionInput(context.messages);
403
+ const copilotHeaders = buildCopilotDynamicHeaders({
404
+ messages: context.messages,
405
+ hasImages
406
+ });
407
+ Object.assign(headers, copilotHeaders);
408
+ }
409
+ if (sessionId && compat.sendSessionAffinityHeaders) {
410
+ if (compat.sessionAffinityFormat === "openrouter") headers["x-session-id"] = sessionId;
411
+ else {
412
+ if (compat.sessionAffinityFormat === "openai") headers.session_id = sessionId;
413
+ headers["x-client-request-id"] = sessionId;
414
+ headers["x-session-affinity"] = sessionId;
415
+ }
416
+ }
417
+ if (optionsHeaders) Object.assign(headers, optionsHeaders);
418
+ return new OpenAI({
419
+ apiKey,
420
+ baseURL: model.baseUrl,
421
+ dangerouslyAllowBrowser: true,
422
+ fetch,
423
+ defaultHeaders: headers
424
+ });
425
+ }
426
+ function buildParams(model, context, options, compat = getCompat(model), cacheRetention = resolveCacheRetention(options?.cacheRetention, options?.env), grammarToolInputProperties = createGrammarToolInputProperties(context.tools, compat.supportsOpenAIGrammarTools)) {
427
+ const messages = convertMessages(model, context, compat, { grammarToolInputProperties });
428
+ const cacheControl = getCompatCacheControl(compat, cacheRetention);
429
+ const params = {
430
+ model: model.id,
431
+ messages,
432
+ stream: true,
433
+ prompt_cache_key: model.baseUrl.includes("api.openai.com") && cacheRetention !== "none" || cacheRetention === "long" && compat.supportsLongCacheRetention ? clampOpenAIPromptCacheKey(options?.sessionId) : void 0,
434
+ prompt_cache_retention: cacheRetention === "long" && compat.supportsLongCacheRetention ? "24h" : void 0
435
+ };
436
+ if (compat.supportsUsageInStreaming !== false) params.stream_options = { include_usage: true };
437
+ if (compat.supportsStore) params.store = false;
438
+ if (options?.maxTokens) {
439
+ if (compat.maxTokensField === "max_tokens") params.max_tokens = options.maxTokens;
440
+ else params.max_completion_tokens = options.maxTokens;
441
+ }
442
+ if (options?.temperature !== void 0) params.temperature = options.temperature;
443
+ const deferredToolNames = compat.deferredToolsMode === "kimi" ? getDeferredToolNames(context.messages) : /* @__PURE__ */ new Set();
444
+ const activeTools = context.tools?.filter((tool) => !deferredToolNames.has(tool.name));
445
+ if (activeTools && activeTools.length > 0) {
446
+ params.tools = convertTools(activeTools, compat);
447
+ if (compat.zaiToolStream) params.tool_stream = true;
448
+ } else if (hasToolHistory(context.messages)) params.tools = [];
449
+ if (cacheControl) applyAnthropicCacheControl(messages, params.tools, cacheControl);
450
+ if (options?.toolChoice) params.tool_choice = options.toolChoice;
451
+ if (compat.thinkingFormat === "zai" && model.reasoning) {
452
+ const zaiParams = params;
453
+ zaiParams.thinking = options?.reasoningEffort ? {
454
+ type: "enabled",
455
+ clear_thinking: false
456
+ } : { type: "disabled" };
457
+ if (options?.reasoningEffort && compat.supportsReasoningEffort) {
458
+ const mappedEffort = model.thinkingLevelMap?.[options.reasoningEffort];
459
+ const effort = mappedEffort === void 0 ? options.reasoningEffort : mappedEffort;
460
+ if (typeof effort === "string") zaiParams.reasoning_effort = effort;
461
+ }
462
+ } else if (compat.thinkingFormat === "qwen" && model.reasoning) {
463
+ params.enable_thinking = !!options?.reasoningEffort;
464
+ if (options?.reasoningEffort && compat.supportsReasoningEffort) {
465
+ const effort = model.thinkingLevelMap?.[options.reasoningEffort] ?? options.reasoningEffort;
466
+ if (typeof effort === "string") params.reasoning_effort = effort;
467
+ }
468
+ } else if (compat.thinkingFormat === "qwen-chat-template" && model.reasoning) params.chat_template_kwargs = {
469
+ enable_thinking: !!options?.reasoningEffort,
470
+ preserve_thinking: true
471
+ };
472
+ else if (compat.thinkingFormat === "chat-template" && model.reasoning) {
473
+ const chatTemplateKwargs = buildChatTemplateKwargs(model, options, compat);
474
+ if (chatTemplateKwargs) params.chat_template_kwargs = chatTemplateKwargs;
475
+ } else if (compat.thinkingFormat === "deepseek" && model.reasoning) {
476
+ if (options?.reasoningEffort) params.thinking = { type: "enabled" };
477
+ else if (model.thinkingLevelMap?.off !== null) params.thinking = { type: "disabled" };
478
+ if (options?.reasoningEffort && compat.supportsReasoningEffort) params.reasoning_effort = model.thinkingLevelMap?.[options.reasoningEffort] ?? options.reasoningEffort;
479
+ } else if (compat.thinkingFormat === "openrouter" && model.reasoning) {
480
+ const openRouterParams = params;
481
+ if (options?.reasoningEffort) openRouterParams.reasoning = { effort: model.thinkingLevelMap?.[options.reasoningEffort] ?? options.reasoningEffort };
482
+ else if (model.thinkingLevelMap?.off !== null) openRouterParams.reasoning = { effort: model.thinkingLevelMap?.off ?? "none" };
483
+ } else if (compat.thinkingFormat === "ant-ling" && model.reasoning && options?.reasoningEffort) {
484
+ const effort = model.thinkingLevelMap?.[options.reasoningEffort];
485
+ if (typeof effort === "string") params.reasoning = { effort };
486
+ } else if (compat.thinkingFormat === "together" && model.reasoning) {
487
+ const togetherParams = params;
488
+ togetherParams.reasoning = { enabled: !!options?.reasoningEffort };
489
+ if (options?.reasoningEffort && compat.supportsReasoningEffort) togetherParams.reasoning_effort = model.thinkingLevelMap?.[options.reasoningEffort] ?? options.reasoningEffort;
490
+ } else if (compat.thinkingFormat === "string-thinking" && model.reasoning) {
491
+ const stringThinkingParams = params;
492
+ if (options?.reasoningEffort) stringThinkingParams.thinking = model.thinkingLevelMap?.[options.reasoningEffort] ?? options.reasoningEffort;
493
+ else if (model.thinkingLevelMap?.off !== null) stringThinkingParams.thinking = model.thinkingLevelMap?.off ?? "none";
494
+ } else if (options?.reasoningEffort && model.reasoning && compat.supportsReasoningEffort) params.reasoning_effort = model.thinkingLevelMap?.[options.reasoningEffort] ?? options.reasoningEffort;
495
+ else if (!options?.reasoningEffort && model.reasoning && compat.supportsReasoningEffort) {
496
+ const offValue = model.thinkingLevelMap?.off;
497
+ if (typeof offValue === "string") params.reasoning_effort = offValue;
498
+ }
499
+ if (model.compat?.openRouterRouting) params.provider = model.compat.openRouterRouting;
500
+ if (model.compat?.vercelGatewayRouting) {
501
+ const routing = model.compat.vercelGatewayRouting;
502
+ if (routing.only || routing.order) {
503
+ const gatewayOptions = {};
504
+ if (routing.only) gatewayOptions.only = routing.only;
505
+ if (routing.order) gatewayOptions.order = routing.order;
506
+ params.providerOptions = { gateway: gatewayOptions };
507
+ }
508
+ }
509
+ return params;
510
+ }
511
+ function buildChatTemplateKwargs(model, options, compat) {
512
+ const kwargs = {};
513
+ for (const [key, value] of Object.entries(compat.chatTemplateKwargs)) {
514
+ const resolved = resolveChatTemplateKwargValue(model, options, value);
515
+ if (resolved !== void 0) kwargs[key] = resolved;
516
+ }
517
+ return Object.keys(kwargs).length > 0 ? kwargs : void 0;
518
+ }
519
+ function resolveChatTemplateKwargValue(model, options, value) {
520
+ if (typeof value !== "object" || value === null) return value;
521
+ const reasoningEffort = options?.reasoningEffort;
522
+ if (!reasoningEffort && value.omitWhenOff) return;
523
+ if (value.$var === "thinking.enabled") return !!reasoningEffort;
524
+ const mappedValue = reasoningEffort ? model.thinkingLevelMap?.[reasoningEffort] : model.thinkingLevelMap?.off;
525
+ return mappedValue === void 0 ? reasoningEffort : typeof mappedValue === "string" ? mappedValue : void 0;
526
+ }
527
+ function getCompatCacheControl(compat, cacheRetention) {
528
+ if (compat.cacheControlFormat !== "anthropic" || cacheRetention === "none") return;
529
+ const ttl = cacheRetention === "long" && compat.supportsLongCacheRetention ? "1h" : void 0;
530
+ return {
531
+ type: "ephemeral",
532
+ ...ttl ? { ttl } : {}
533
+ };
534
+ }
535
+ function applyAnthropicCacheControl(messages, tools, cacheControl) {
536
+ addCacheControlToSystemPrompt(messages, cacheControl);
537
+ addCacheControlToLastTool(tools, cacheControl);
538
+ addCacheControlToLastConversationMessage(messages, cacheControl);
539
+ }
540
+ function addCacheControlToSystemPrompt(messages, cacheControl) {
541
+ for (const message of messages) if (message.role === "system" || message.role === "developer") {
542
+ addCacheControlToInstructionMessage(message, cacheControl);
543
+ return;
544
+ }
545
+ }
546
+ function addCacheControlToLastConversationMessage(messages, cacheControl) {
547
+ for (let i = messages.length - 1; i >= 0; i--) {
548
+ const message = messages[i];
549
+ if (message.role === "user" || message.role === "assistant" || message.role === "tool") {
550
+ if (addCacheControlToMessage(message, cacheControl)) return;
551
+ }
552
+ }
553
+ }
554
+ function addCacheControlToLastTool(tools, cacheControl) {
555
+ if (!tools || tools.length === 0) return;
556
+ const lastTool = tools[tools.length - 1];
557
+ lastTool.cache_control = cacheControl;
558
+ }
559
+ function addCacheControlToInstructionMessage(message, cacheControl) {
560
+ return addCacheControlToTextContent(message, cacheControl);
561
+ }
562
+ function addCacheControlToMessage(message, cacheControl) {
563
+ if (message.role === "user" || message.role === "assistant" || message.role === "tool") return addCacheControlToTextContent(message, cacheControl);
564
+ return false;
565
+ }
566
+ function addCacheControlToTextContent(message, cacheControl) {
567
+ const content = message.content;
568
+ if (typeof content === "string") {
569
+ if (content.length === 0) return false;
570
+ message.content = [{
571
+ type: "text",
572
+ text: content,
573
+ cache_control: cacheControl
574
+ }];
575
+ return true;
576
+ }
577
+ if (!Array.isArray(content)) return false;
578
+ for (let i = content.length - 1; i >= 0; i--) {
579
+ const part = content[i];
580
+ if (part?.type === "text") {
581
+ const textPart = part;
582
+ textPart.cache_control = cacheControl;
583
+ return true;
584
+ }
585
+ }
586
+ return false;
587
+ }
588
+ function convertMessages(model, context, compat, options) {
589
+ const params = [];
590
+ const normalizeToolCallId = (id) => {
591
+ if (id.includes("|")) {
592
+ const separatorIndex = id.indexOf("|");
593
+ const callId = id.slice(0, separatorIndex).replace(/[^a-zA-Z0-9_-]/g, "_");
594
+ const itemId = id.slice(separatorIndex + 1).replace(/[^a-zA-Z0-9_-]/g, "_");
595
+ const combinedId = itemId.length > 0 ? `${callId}_${itemId}` : callId;
596
+ if (combinedId.length <= 40) return combinedId;
597
+ const hash = shortHash(id).slice(0, 8);
598
+ return `${callId.slice(0, Math.max(1, 40 - hash.length - 1))}_${hash}`;
599
+ }
600
+ if (model.provider === "openai") return id.length > 40 ? id.slice(0, 40) : id;
601
+ return id;
602
+ };
603
+ const transformedMessages = transformMessages(context.messages, model, (id) => normalizeToolCallId(id));
604
+ if (context.systemPrompt) {
605
+ const role = model.reasoning && compat.supportsDeveloperRole ? "developer" : "system";
606
+ params.push({
607
+ role,
608
+ content: sanitizeSurrogates(context.systemPrompt)
609
+ });
610
+ }
611
+ let lastRole = null;
612
+ for (let i = 0; i < transformedMessages.length; i++) {
613
+ const msg = transformedMessages[i];
614
+ if (compat.requiresAssistantAfterToolResult && lastRole === "toolResult" && msg.role === "user") params.push({
615
+ role: "assistant",
616
+ content: "I have processed the tool results."
617
+ });
618
+ if (msg.role === "user") {
619
+ if (typeof msg.content === "string") params.push({
620
+ role: "user",
621
+ content: sanitizeSurrogates(msg.content)
622
+ });
623
+ else {
624
+ const content = msg.content.map((item) => {
625
+ if (item.type === "text") return {
626
+ type: "text",
627
+ text: sanitizeSurrogates(item.text)
628
+ };
629
+ else return {
630
+ type: "image_url",
631
+ image_url: { url: `data:${item.mimeType};base64,${item.data}` }
632
+ };
633
+ });
634
+ if (content.length === 0) continue;
635
+ params.push({
636
+ role: "user",
637
+ content
638
+ });
639
+ }
640
+ } else if (msg.role === "assistant") {
641
+ const assistantMsg = {
642
+ role: "assistant",
643
+ content: compat.requiresAssistantAfterToolResult ? "" : null
644
+ };
645
+ const assistantTextParts = msg.content.filter(isTextContentBlock).filter((block) => block.text.trim().length > 0).map((block) => ({
646
+ type: "text",
647
+ text: sanitizeSurrogates(block.text)
648
+ }));
649
+ const assistantText = assistantTextParts.map((part) => part.text).join("");
650
+ const nonEmptyThinkingBlocks = msg.content.filter(isThinkingContentBlock).filter((block) => block.thinking.trim().length > 0);
651
+ if (nonEmptyThinkingBlocks.length > 0) {
652
+ if (compat.requiresThinkingAsText) assistantMsg.content = [{
653
+ type: "text",
654
+ text: nonEmptyThinkingBlocks.map((block) => sanitizeSurrogates(block.thinking)).join("\n\n")
655
+ }, ...assistantTextParts];
656
+ else {
657
+ if (assistantText.length > 0) assistantMsg.content = assistantText;
658
+ let signature = nonEmptyThinkingBlocks[0].thinkingSignature;
659
+ if (model.provider === "opencode-go" && signature === "reasoning") signature = "reasoning_content";
660
+ if (signature && signature.length > 0) assistantMsg[signature] = nonEmptyThinkingBlocks.map((block) => block.thinking).join("\n");
661
+ }
662
+ } else if (assistantText.length > 0) assistantMsg.content = assistantText;
663
+ const toolCalls = msg.content.filter(isToolCallBlock);
664
+ if (toolCalls.length > 0) {
665
+ assistantMsg.tool_calls = toolCalls.map((tc) => {
666
+ const customInputProperty = options?.grammarToolInputProperties?.get(tc.name);
667
+ if (customInputProperty !== void 0) return {
668
+ id: tc.id,
669
+ type: "custom",
670
+ custom: {
671
+ name: tc.name,
672
+ input: sanitizeSurrogates(getGrammarToolInput(tc.name, tc.arguments, customInputProperty))
673
+ }
674
+ };
675
+ return {
676
+ id: tc.id,
677
+ type: "function",
678
+ function: {
679
+ name: tc.name,
680
+ arguments: JSON.stringify(tc.arguments)
681
+ }
682
+ };
683
+ });
684
+ const reasoningDetails = toolCalls.filter((tc) => tc.thoughtSignature).map((tc) => {
685
+ try {
686
+ return JSON.parse(tc.thoughtSignature);
687
+ } catch {
688
+ return null;
689
+ }
690
+ }).filter(Boolean);
691
+ if (reasoningDetails.length > 0) assistantMsg.reasoning_details = reasoningDetails;
692
+ }
693
+ if (compat.requiresReasoningContentOnAssistantMessages && model.reasoning && assistantMsg.reasoning_content === void 0) assistantMsg.reasoning_content = "";
694
+ const content = assistantMsg.content;
695
+ if (!(content !== null && content !== void 0 && (typeof content === "string" ? content.length > 0 : content.length > 0)) && !assistantMsg.tool_calls) continue;
696
+ params.push(assistantMsg);
697
+ } else if (msg.role === "toolResult") {
698
+ const imageBlocks = [];
699
+ const deferredToolNames = /* @__PURE__ */ new Set();
700
+ let j = i;
701
+ for (; j < transformedMessages.length && transformedMessages[j].role === "toolResult"; j++) {
702
+ const toolMsg = transformedMessages[j];
703
+ const textResult = toolMsg.content.filter(isTextContentBlock).map((block) => block.text).join("\n");
704
+ const hasImages = toolMsg.content.some((c) => c.type === "image");
705
+ const toolResultText = textResult.length > 0 ? textResult : hasImages ? "(see attached image)" : "(no tool output)";
706
+ const toolResultMsg = {
707
+ role: "tool",
708
+ content: sanitizeSurrogates(toolResultText),
709
+ tool_call_id: toolMsg.toolCallId
710
+ };
711
+ if (compat.requiresToolResultName && toolMsg.toolName) toolResultMsg.name = toolMsg.toolName;
712
+ params.push(toolResultMsg);
713
+ if (compat.deferredToolsMode === "kimi") for (const name of toolMsg.addedToolNames ?? []) deferredToolNames.add(name);
714
+ if (hasImages && model.input.includes("image")) {
715
+ for (const block of toolMsg.content) if (isImageContentBlock(block)) imageBlocks.push({
716
+ type: "image_url",
717
+ image_url: { url: `data:${block.mimeType};base64,${block.data}` }
718
+ });
719
+ }
720
+ }
721
+ i = j - 1;
722
+ if (imageBlocks.length > 0) {
723
+ if (compat.requiresAssistantAfterToolResult) params.push({
724
+ role: "assistant",
725
+ content: "I have processed the tool results."
726
+ });
727
+ params.push({
728
+ role: "user",
729
+ content: [{
730
+ type: "text",
731
+ text: "Attached image(s) from tool result:"
732
+ }, ...imageBlocks]
733
+ });
734
+ lastRole = "user";
735
+ } else lastRole = "toolResult";
736
+ if (deferredToolNames.size > 0) {
737
+ const deferredTools = getToolsByName(context.tools, deferredToolNames);
738
+ if (deferredTools.length > 0) {
739
+ const kimiToolMessage = {
740
+ role: "system",
741
+ tools: convertTools(deferredTools, compat)
742
+ };
743
+ params.push(kimiToolMessage);
744
+ }
745
+ }
746
+ continue;
747
+ }
748
+ lastRole = msg.role;
749
+ }
750
+ return params;
751
+ }
752
+ function convertTools(tools, compat) {
753
+ return tools.map((tool) => {
754
+ const grammar = resolveGrammarConstrainedSampling(tool, compat.supportsOpenAIGrammarTools);
755
+ if (grammar) return {
756
+ type: "custom",
757
+ custom: {
758
+ name: tool.name,
759
+ description: tool.description,
760
+ format: {
761
+ type: "grammar",
762
+ grammar: {
763
+ syntax: grammar.format,
764
+ definition: grammar.definition
765
+ }
766
+ }
767
+ }
768
+ };
769
+ const strict = resolveJsonSchemaStrictSampling(tool, compat.supportsStrictMode !== false);
770
+ return {
771
+ type: "function",
772
+ function: {
773
+ name: tool.name,
774
+ description: tool.description,
775
+ parameters: tool.parameters,
776
+ ...compat.supportsStrictMode !== false && { strict: strict ?? false }
777
+ }
778
+ };
779
+ });
780
+ }
781
+ function parseChunkUsage(rawUsage, model) {
782
+ const promptTokens = rawUsage.prompt_tokens || 0;
783
+ const cacheReadTokens = rawUsage.prompt_tokens_details?.cached_tokens ?? rawUsage.prompt_cache_hit_tokens ?? 0;
784
+ const cacheWriteTokens = rawUsage.prompt_tokens_details?.cache_write_tokens || 0;
785
+ const input = Math.max(0, promptTokens - cacheReadTokens - cacheWriteTokens);
786
+ const outputTokens = rawUsage.completion_tokens || 0;
787
+ const usage = {
788
+ input,
789
+ output: outputTokens,
790
+ cacheRead: cacheReadTokens,
791
+ cacheWrite: cacheWriteTokens,
792
+ reasoning: rawUsage.completion_tokens_details?.reasoning_tokens || 0,
793
+ totalTokens: input + outputTokens + cacheReadTokens + cacheWriteTokens,
794
+ cost: {
795
+ input: 0,
796
+ output: 0,
797
+ cacheRead: 0,
798
+ cacheWrite: 0,
799
+ total: 0
800
+ }
801
+ };
802
+ calculateCost(model, usage);
803
+ return usage;
804
+ }
805
+ function mapStopReason(reason) {
806
+ if (reason === null) return { stopReason: "stop" };
807
+ switch (reason) {
808
+ case "stop":
809
+ case "end": return { stopReason: "stop" };
810
+ case "length": return { stopReason: "length" };
811
+ case "function_call":
812
+ case "tool_calls": return { stopReason: "toolUse" };
813
+ case "content_filter": return {
814
+ stopReason: "error",
815
+ errorMessage: "Provider finish_reason: content_filter"
816
+ };
817
+ case "network_error": return {
818
+ stopReason: "error",
819
+ errorMessage: "Provider finish_reason: network_error"
820
+ };
821
+ default: return {
822
+ stopReason: "error",
823
+ errorMessage: `Provider finish_reason: ${reason}`
824
+ };
825
+ }
826
+ }
827
+ /**
828
+ * Auto-detect compatibility settings from provider name and baseUrl.
829
+ * Used as the base when model.compat is not set; explicit model.compat
830
+ * entries override these detected values.
831
+ */
832
+ function detectCompat(model) {
833
+ const provider = model.provider;
834
+ const baseUrl = model.baseUrl;
835
+ const isZai = provider === "zai" || provider === "zai-coding-cn" || baseUrl.includes("api.z.ai") || baseUrl.includes("open.bigmodel.cn");
836
+ const isTogether = provider === "together" || baseUrl.includes("api.together.ai") || baseUrl.includes("api.together.xyz");
837
+ const isMoonshot = provider === "moonshotai" || provider === "moonshotai-cn" || baseUrl.includes("api.moonshot.");
838
+ const isOpenRouter = provider === "openrouter" || baseUrl.includes("openrouter.ai");
839
+ const isCloudflareWorkersAI = provider === "cloudflare-workers-ai" || baseUrl.includes("api.cloudflare.com");
840
+ const isCloudflareAiGateway = provider === "cloudflare-ai-gateway" || baseUrl.includes("gateway.ai.cloudflare.com");
841
+ const isNvidia = provider === "nvidia" || baseUrl.includes("integrate.api.nvidia.com");
842
+ const isAntLing = provider === "ant-ling" || baseUrl.includes("api.ant-ling.com");
843
+ const isNonStandard = isNvidia || provider === "cerebras" || baseUrl.includes("cerebras.ai") || provider === "xai" || baseUrl.includes("api.x.ai") || isTogether || baseUrl.includes("chutes.ai") || baseUrl.includes("deepseek.com") || isZai || isMoonshot || provider === "opencode" || baseUrl.includes("opencode.ai") || isCloudflareWorkersAI || isCloudflareAiGateway || isAntLing;
844
+ const useMaxTokens = baseUrl.includes("chutes.ai") || isMoonshot || isCloudflareAiGateway || isTogether || isNvidia || isAntLing || isZai;
845
+ const isGrok = provider === "xai" || baseUrl.includes("api.x.ai");
846
+ const isDeepSeek = provider === "deepseek" || baseUrl.includes("deepseek.com");
847
+ const isOpenRouterDeveloperRoleModel = isOpenRouter && (model.id.startsWith("anthropic/") || model.id.startsWith("openai/"));
848
+ const cacheControlFormat = provider === "openrouter" && model.id.startsWith("anthropic/") ? "anthropic" : void 0;
849
+ return {
850
+ supportsStore: !isNonStandard,
851
+ supportsDeveloperRole: isOpenRouterDeveloperRoleModel || !isNonStandard && !isOpenRouter,
852
+ supportsReasoningEffort: !isGrok && !isZai && !isMoonshot && !isTogether && !isCloudflareAiGateway && !isNvidia && !isAntLing,
853
+ supportsUsageInStreaming: true,
854
+ maxTokensField: useMaxTokens ? "max_tokens" : "max_completion_tokens",
855
+ requiresToolResultName: false,
856
+ requiresAssistantAfterToolResult: false,
857
+ requiresThinkingAsText: false,
858
+ requiresReasoningContentOnAssistantMessages: isDeepSeek,
859
+ thinkingFormat: isDeepSeek ? "deepseek" : isZai ? "zai" : isTogether ? "together" : isAntLing ? "ant-ling" : isOpenRouter ? "openrouter" : "openai",
860
+ openRouterRouting: {},
861
+ vercelGatewayRouting: {},
862
+ chatTemplateKwargs: {},
863
+ zaiToolStream: false,
864
+ supportsStrictMode: !isMoonshot && !isTogether && !isCloudflareAiGateway && !isNvidia,
865
+ supportsOpenAIGrammarTools: false,
866
+ cacheControlFormat,
867
+ sendSessionAffinityHeaders: false,
868
+ deferredToolsMode: void 0,
869
+ sessionAffinityFormat: isOpenRouter ? "openrouter" : "openai",
870
+ supportsLongCacheRetention: !(isTogether || isCloudflareWorkersAI || isCloudflareAiGateway || isNvidia || isAntLing)
871
+ };
872
+ }
873
+ /**
874
+ * Get resolved compatibility settings for a model.
875
+ * Auto-detects from provider/URL then overrides with explicit model.compat.
876
+ */
877
+ function getCompat(model) {
878
+ const detected = detectCompat(model);
879
+ if (!model.compat) return detected;
880
+ return {
881
+ supportsStore: model.compat.supportsStore ?? detected.supportsStore,
882
+ supportsDeveloperRole: model.compat.supportsDeveloperRole ?? detected.supportsDeveloperRole,
883
+ supportsReasoningEffort: model.compat.supportsReasoningEffort ?? detected.supportsReasoningEffort,
884
+ supportsUsageInStreaming: model.compat.supportsUsageInStreaming ?? detected.supportsUsageInStreaming,
885
+ maxTokensField: model.compat.maxTokensField ?? detected.maxTokensField,
886
+ requiresToolResultName: model.compat.requiresToolResultName ?? detected.requiresToolResultName,
887
+ requiresAssistantAfterToolResult: model.compat.requiresAssistantAfterToolResult ?? detected.requiresAssistantAfterToolResult,
888
+ requiresThinkingAsText: model.compat.requiresThinkingAsText ?? detected.requiresThinkingAsText,
889
+ requiresReasoningContentOnAssistantMessages: model.compat.requiresReasoningContentOnAssistantMessages ?? detected.requiresReasoningContentOnAssistantMessages,
890
+ thinkingFormat: model.compat.thinkingFormat ?? detected.thinkingFormat,
891
+ openRouterRouting: model.compat.openRouterRouting ?? {},
892
+ vercelGatewayRouting: model.compat.vercelGatewayRouting ?? detected.vercelGatewayRouting,
893
+ chatTemplateKwargs: model.compat.chatTemplateKwargs ?? detected.chatTemplateKwargs,
894
+ zaiToolStream: model.compat.zaiToolStream ?? detected.zaiToolStream,
895
+ supportsStrictMode: model.compat.supportsStrictMode ?? detected.supportsStrictMode,
896
+ supportsOpenAIGrammarTools: model.compat.supportsOpenAIGrammarTools ?? detected.supportsOpenAIGrammarTools,
897
+ cacheControlFormat: model.compat.cacheControlFormat ?? detected.cacheControlFormat,
898
+ sendSessionAffinityHeaders: model.compat.sendSessionAffinityHeaders ?? detected.sendSessionAffinityHeaders,
899
+ deferredToolsMode: model.compat.deferredToolsMode ?? detected.deferredToolsMode,
900
+ sessionAffinityFormat: model.compat.sessionAffinityFormat ?? detected.sessionAffinityFormat,
901
+ supportsLongCacheRetention: model.compat.supportsLongCacheRetention ?? detected.supportsLongCacheRetention
902
+ };
903
+ }
904
+ //#endregion
905
+ export { convertMessages, stream, streamSimple };
906
+
907
+ //# sourceMappingURL=openai-completions-Dg9BYhy-.js.map