@openclaw/ai 2026.8.1 → 2026.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{anthropic-Djj7L1rx.mjs → anthropic-DTGZ4VMY.mjs} +13 -11
- package/dist/{anthropic-compaction-replay-CY4tkD4V.mjs → anthropic-compaction-replay-CKCDrZJv.mjs} +6 -6
- package/dist/{anthropic-payload-policy-i_5_inWe.d.mts → anthropic-payload-policy-BTzmNC14.d.mts} +2 -2
- package/dist/{api-registry-C9-wZd_W.d.mts → api-registry-BbUHEKER.d.mts} +2 -2
- package/dist/{azure-openai-responses-Bj3czHNa.mjs → azure-openai-responses-BmqaDXM1.mjs} +5 -4
- package/dist/diagnostics.mjs +1 -1
- package/dist/{event-stream-UhnxHuqt.d.mts → event-stream-DcvAPSBe.d.mts} +1 -1
- package/dist/event-stream-pXT3FI6X.d.mts +1 -0
- package/dist/event-stream.d.mts +2 -2
- package/dist/{google-0Ca6TYbw.mjs → google-CqjVZMwo.mjs} +7 -5
- package/dist/{google-shared-DVfL9COU.mjs → google-shared-Bnqni5j3.mjs} +25 -23
- package/dist/{google-vertex-5dAMxprN.mjs → google-vertex-D_WREEJi.mjs} +7 -5
- package/dist/{host-D51fmkH6.mjs → host-BIaiBURL.mjs} +2 -2
- package/dist/{host-DoPJJ1KD.d.mts → host-DKFUAmCn.d.mts} +3 -3
- package/dist/{index-N3zr6__t.d.mts → index-CefaUGSS.d.mts} +11 -5
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +4 -4
- package/dist/internal/anthropic.d.mts +5 -5
- package/dist/internal/anthropic.mjs +4 -4
- package/dist/internal/openai-responses-payload-policy.d.mts +1 -1
- package/dist/internal/openai-responses-payload-policy.mjs +1 -1
- package/dist/internal/openai.d.mts +5 -5
- package/dist/internal/openai.mjs +8 -8
- package/dist/internal/runtime.d.mts +5 -5
- package/dist/internal/runtime.mjs +3 -3
- package/dist/internal/shared.d.mts +2 -2
- package/dist/internal/shared.mjs +3 -3
- package/dist/{mistral-BCnrI-kV.mjs → mistral-C24jVd6f.mjs} +18 -13
- package/dist/{openai-chatgpt-responses-CGBGWSqr.mjs → openai-chatgpt-responses-Czum0oXz.mjs} +16 -15
- package/dist/{openai-completions-BaTuwID7.mjs → openai-completions-BfFwac6f.mjs} +16 -13
- package/dist/{openai-completions-compat-DB7FFq7k.d.mts → openai-completions-compat-SZhi0Lf4.d.mts} +3 -3
- package/dist/{openai-completions-stream-Bpns6uNc.mjs → openai-completions-stream-DGOvau4J.mjs} +29 -26
- package/dist/{openai-responses-1GBcQujk.mjs → openai-responses-BAryVEJM.mjs} +9 -7
- package/dist/{openai-responses-compaction-window-DwydGZI8.mjs → openai-responses-compaction-window-DO7yV7az.mjs} +3 -3
- package/dist/{openai-responses-contracts-DgaR3t5T.d.mts → openai-responses-contracts-BthRXano.d.mts} +3 -3
- package/dist/{openai-responses-prompt-observer-internal-_nhGTn2b.mjs → openai-responses-prompt-observer-internal--R0kZLOZ.mjs} +3 -3
- package/dist/{openai-responses-shared-zPmKnhF5.mjs → openai-responses-shared-CxgdGBvm.mjs} +27 -26
- package/dist/{openai-tool-schema-Dgl4H2MU.mjs → openai-tool-schema-CSMh5e9O.mjs} +13 -11
- package/dist/{provider-error-jZP5NMTZ.mjs → provider-error-BI8kIViN.mjs} +11 -11
- package/dist/{provider-options-HvA_slFa.d.mts → provider-options-DJd_9euj.d.mts} +2 -2
- package/dist/{provider-transcript-transform-C01bQ5a3.mjs → provider-transcript-transform-WvJmFUAf.mjs} +1 -1
- package/dist/provider-types.d.mts +6 -6
- package/dist/providers.d.mts +1 -1
- package/dist/providers.mjs +9 -9
- package/dist/{reasoning-tag-text-partitioner-CwzKb0bA.mjs → reasoning-tag-text-partitioner-BsUX44Tq.mjs} +29 -19
- package/dist/{sanitize-unicode-DCkltN94.mjs → sanitize-unicode-S6binQG-.mjs} +2 -8
- package/dist/{simple-options-DKx86yX9.mjs → simple-options-rdOPzr7Z.mjs} +2 -2
- package/dist/{src-Bu3FiFAG.mjs → src-C8U7lkoa.mjs} +75 -2
- package/dist/{tool-schema-json-projection-qvTEs5Am.mjs → tool-schema-json-projection-BtZiml7r.mjs} +21 -31
- package/dist/{transport-stream-shared-NjwWNaRY.d.mts → transport-stream-shared-BbG7PThh.d.mts} +4 -4
- package/dist/{transport-stream-shared-CT5ycdzn.mjs → transport-stream-shared-D8nQWCUo.mjs} +2 -2
- package/dist/{transport-utils-BHx9z8Cl.mjs → transport-utils-CtuS1Upe.mjs} +2 -2
- package/dist/transports.d.mts +12 -9
- package/dist/transports.mjs +61 -50
- package/dist/{types-h38Azne1.d.mts → types-Beemor2E.d.mts} +20 -7
- package/dist/types-COdhCX0U.d.mts +1 -0
- package/dist/types.d.mts +6 -6
- package/dist/types.mjs +3 -3
- package/dist/{validation-C68lP2uy.d.mts → validation-CC6s7Smp.d.mts} +1 -1
- package/dist/{validation-B61OhAio.mjs → validation-CJZtym2g.mjs} +7 -5
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +2 -2
- package/dist/event-stream-C988TSLe.d.mts +0 -1
- package/dist/types-DtGu2d3C.d.mts +0 -1
package/dist/internal/shared.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as sanitizeSurrogates } from "../sanitize-unicode-
|
|
2
|
-
import { a as describeToolResultMediaPlaceholder, c as extractToolResultText, d as isImageWithMediaPayload, i as transformMessages, l as formatToolResultText, o as describeUnsupportedToolResultMedia, s as extractToolResultBlockText, u as hasMediaPayload } from "../host-
|
|
3
|
-
import { c as ensureSystemPromptCacheBoundary, d as stripSystemPromptCacheBoundary, f as normalizePromptCapabilityIds, i as clampReasoning, l as prependSystemPromptAdditionAfterCacheBoundary, m as sortPromptCacheToolsByName, n as buildBaseOptions, p as normalizeStructuredPromptSection, r as clampMaxTokensToModel, s as SYSTEM_PROMPT_CACHE_BOUNDARY, t as adjustMaxTokensForThinking, u as splitSystemPromptCacheBoundary } from "../simple-options-
|
|
1
|
+
import { t as sanitizeSurrogates } from "../sanitize-unicode-S6binQG-.mjs";
|
|
2
|
+
import { a as describeToolResultMediaPlaceholder, c as extractToolResultText, d as isImageWithMediaPayload, i as transformMessages, l as formatToolResultText, o as describeUnsupportedToolResultMedia, s as extractToolResultBlockText, u as hasMediaPayload } from "../host-BIaiBURL.mjs";
|
|
3
|
+
import { c as ensureSystemPromptCacheBoundary, d as stripSystemPromptCacheBoundary, f as normalizePromptCapabilityIds, i as clampReasoning, l as prependSystemPromptAdditionAfterCacheBoundary, m as sortPromptCacheToolsByName, n as buildBaseOptions, p as normalizeStructuredPromptSection, r as clampMaxTokensToModel, s as SYSTEM_PROMPT_CACHE_BOUNDARY, t as adjustMaxTokensForThinking, u as splitSystemPromptCacheBoundary } from "../simple-options-rdOPzr7Z.mjs";
|
|
4
4
|
import { t as inspectTlsCertificateError } from "../tls-certificate-errors-DXSpluKI.mjs";
|
|
5
5
|
export { SYSTEM_PROMPT_CACHE_BOUNDARY, adjustMaxTokensForThinking, buildBaseOptions, clampMaxTokensToModel, clampReasoning, describeToolResultMediaPlaceholder, describeUnsupportedToolResultMedia, ensureSystemPromptCacheBoundary, extractToolResultBlockText, extractToolResultText, formatToolResultText, hasMediaPayload, inspectTlsCertificateError, isImageWithMediaPayload, normalizePromptCapabilityIds, normalizeStructuredPromptSection, prependSystemPromptAdditionAfterCacheBoundary, sanitizeSurrogates, sortPromptCacheToolsByName, splitSystemPromptCacheBoundary, stripSystemPromptCacheBoundary, transformMessages };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { t as AssistantMessageEventStream } from "./event-stream-uSMZJ3FA.mjs";
|
|
2
|
-
import { i as clampThinkingLevel, r as calculateCost, t as sanitizeSurrogates } from "./sanitize-unicode-
|
|
3
|
-
import { a as describeToolResultMediaPlaceholder, c as extractToolResultText, d as isImageWithMediaPayload, l as formatToolResultText, n as getAiTransportHost } from "./host-
|
|
4
|
-
import { n as projectProviderError } from "./provider-error-
|
|
5
|
-
import { d as stripSystemPromptCacheBoundary, m as sortPromptCacheToolsByName, n as buildBaseOptions, r as clampMaxTokensToModel } from "./simple-options-
|
|
2
|
+
import { i as clampThinkingLevel, r as calculateCost, t as sanitizeSurrogates } from "./sanitize-unicode-S6binQG-.mjs";
|
|
3
|
+
import { a as describeToolResultMediaPlaceholder, c as extractToolResultText, d as isImageWithMediaPayload, l as formatToolResultText, n as getAiTransportHost } from "./host-BIaiBURL.mjs";
|
|
4
|
+
import { n as projectProviderError } from "./provider-error-BI8kIViN.mjs";
|
|
5
|
+
import { d as stripSystemPromptCacheBoundary, m as sortPromptCacheToolsByName, n as buildBaseOptions, r as clampMaxTokensToModel } from "./simple-options-rdOPzr7Z.mjs";
|
|
6
6
|
import { n as getEnvApiKey } from "./env-api-keys-bktO00EJ.mjs";
|
|
7
|
-
import { _ as transportAbortError, f as notifyProviderHttpResponse, s as finalizeTerminalToolCallArguments } from "./transport-stream-shared-
|
|
7
|
+
import { _ as transportAbortError, f as notifyProviderHttpResponse, s as finalizeTerminalToolCallArguments } from "./transport-stream-shared-D8nQWCUo.mjs";
|
|
8
8
|
import { r as parseStreamingJson, t as createToolArgumentPreviewSchedule } from "./json-parse-BuAJEbdW.mjs";
|
|
9
9
|
import { t as shortHash } from "./hash-CHgqbJmD.mjs";
|
|
10
|
-
import { t as transformProviderMessages } from "./provider-transcript-transform-
|
|
10
|
+
import { t as transformProviderMessages } from "./provider-transcript-transform-WvJmFUAf.mjs";
|
|
11
11
|
import { t as mapOpenAIStopReason } from "./openai-stop-reason-Drnn_6Qj.mjs";
|
|
12
12
|
import { t as createSseByteGuard } from "./streaming-byte-guard-CC-HMn_u.mjs";
|
|
13
13
|
import { randomUUID } from "node:crypto";
|
|
@@ -15,7 +15,7 @@ import { HTTPClient } from "@mistralai/mistralai/lib/http";
|
|
|
15
15
|
import { Chat } from "@mistralai/mistralai/sdk/chat";
|
|
16
16
|
//#region packages/ai/src/providers/mistral.ts
|
|
17
17
|
const MISTRAL_TOOL_CALL_ID_LENGTH = 9;
|
|
18
|
-
const MISTRAL_STREAM_BODY_MAX_BYTES =
|
|
18
|
+
const MISTRAL_STREAM_BODY_MAX_BYTES = 16777216;
|
|
19
19
|
/**
|
|
20
20
|
* Builds a `Fetcher` that wraps the default `fetch` with a 16 MiB byte cap
|
|
21
21
|
* on streamed response bodies. The wrapped `Response.body` exposes a
|
|
@@ -31,7 +31,8 @@ function createBoundedMistralFetcher(maxBytes = MISTRAL_STREAM_BODY_MAX_BYTES, u
|
|
|
31
31
|
return async (input, init) => {
|
|
32
32
|
const response = init == null ? await upstreamFetch(input) : await upstreamFetch(input, init);
|
|
33
33
|
if (!response.body || typeof response.body.getReader !== "function") return response;
|
|
34
|
-
const
|
|
34
|
+
const reader = response.body.getReader();
|
|
35
|
+
const guard = createSseByteGuard(reader, {
|
|
35
36
|
maxBytes,
|
|
36
37
|
onOverflow: ({ size, maxBytes: cap }) => /* @__PURE__ */ new Error(`mistral: stream body exceeds ${cap} bytes (got ${size})`)
|
|
37
38
|
});
|
|
@@ -198,7 +199,8 @@ function deriveMistralToolCallId(id, attempt) {
|
|
|
198
199
|
const normalized = id.replace(/[^a-zA-Z0-9]/g, "");
|
|
199
200
|
if (attempt === 0 && normalized.length === MISTRAL_TOOL_CALL_ID_LENGTH) return normalized;
|
|
200
201
|
const seedBase = normalized || id;
|
|
201
|
-
|
|
202
|
+
const seed = attempt === 0 ? seedBase : `${seedBase}:${attempt}`;
|
|
203
|
+
return shortHash(seed).replace(/[^a-zA-Z0-9]/g, "").padEnd(MISTRAL_TOOL_CALL_ID_LENGTH, "0").slice(0, MISTRAL_TOOL_CALL_ID_LENGTH);
|
|
202
204
|
}
|
|
203
205
|
function buildChatPayload(model, context, messages, options) {
|
|
204
206
|
const payload = {
|
|
@@ -372,7 +374,8 @@ async function consumeChatStream(model, output, stream, mistralStream) {
|
|
|
372
374
|
continue;
|
|
373
375
|
}
|
|
374
376
|
if (item.type === "thinking") {
|
|
375
|
-
const
|
|
377
|
+
const deltaText = item.thinking.map((part) => "text" in part ? part.text : "").filter((text) => text.length > 0).join("");
|
|
378
|
+
const thinkingDelta = sanitizeSurrogates(deltaText);
|
|
376
379
|
if (!thinkingDelta) continue;
|
|
377
380
|
if (!currentBlock || currentBlock.type !== "thinking") {
|
|
378
381
|
finishCurrentBlock(currentBlock);
|
|
@@ -514,7 +517,7 @@ async function consumeChatStream(model, output, stream, mistralStream) {
|
|
|
514
517
|
}
|
|
515
518
|
}
|
|
516
519
|
function toFunctionTools(tools) {
|
|
517
|
-
|
|
520
|
+
const converted = tools.flatMap((tool) => {
|
|
518
521
|
try {
|
|
519
522
|
const name = tool.name;
|
|
520
523
|
const description = tool.description;
|
|
@@ -534,7 +537,8 @@ function toFunctionTools(tools) {
|
|
|
534
537
|
} catch {
|
|
535
538
|
return [];
|
|
536
539
|
}
|
|
537
|
-
})
|
|
540
|
+
});
|
|
541
|
+
return sortPromptCacheToolsByName(converted).map(({ value }) => value);
|
|
538
542
|
}
|
|
539
543
|
function stripSymbolKeys(value) {
|
|
540
544
|
if (Array.isArray(value)) return value.map((item) => stripSymbolKeys(item));
|
|
@@ -619,10 +623,11 @@ function toChatMessages(messages, supportsImages) {
|
|
|
619
623
|
const toolContent = [];
|
|
620
624
|
const textResult = extractToolResultText(msg.content);
|
|
621
625
|
const mediaPlaceholder = describeToolResultMediaPlaceholder(msg.content);
|
|
626
|
+
const omittedMediaPlaceholder = msg.content.some(isImageWithMediaPayload) && !supportsImages ? textResult.trim() ? "[tool image omitted: model does not support images]" : mediaPlaceholder === "(see attached media)" ? "(media omitted: model does not support images)" : "(image omitted: model does not support images)" : void 0;
|
|
622
627
|
const toolText = formatToolResultText({
|
|
623
628
|
text: textResult,
|
|
624
629
|
mediaPlaceholder,
|
|
625
|
-
omittedMediaPlaceholder
|
|
630
|
+
omittedMediaPlaceholder,
|
|
626
631
|
isError: msg.isError
|
|
627
632
|
});
|
|
628
633
|
toolContent.push({
|
package/dist/{openai-chatgpt-responses-CGBGWSqr.mjs → openai-chatgpt-responses-Czum0oXz.mjs}
RENAMED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { i as formatThrownValue, n as createAssistantMessageDiagnostic, t as appendAssistantMessageDiagnostic } from "./diagnostics-COpOtRwq.mjs";
|
|
2
2
|
import { t as AssistantMessageEventStream } from "./event-stream-uSMZJ3FA.mjs";
|
|
3
|
-
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-
|
|
4
|
-
import { n as projectProviderError } from "./provider-error-
|
|
5
|
-
import { n as toErrorObject, t as createResponsesPromptEgressObserver } from "./openai-responses-prompt-observer-internal
|
|
3
|
+
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-BIaiBURL.mjs";
|
|
4
|
+
import { n as projectProviderError } from "./provider-error-BI8kIViN.mjs";
|
|
5
|
+
import { n as toErrorObject, t as createResponsesPromptEgressObserver } from "./openai-responses-prompt-observer-internal--R0kZLOZ.mjs";
|
|
6
6
|
import { o as clampTimerTimeoutMs, u as resolveTimerTimeoutMs } from "./base64-CEFBpSkN.mjs";
|
|
7
7
|
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-mZTCdRPo.mjs";
|
|
8
|
-
import { d as stripSystemPromptCacheBoundary, n as buildBaseOptions } from "./simple-options-
|
|
8
|
+
import { d as stripSystemPromptCacheBoundary, n as buildBaseOptions } from "./simple-options-rdOPzr7Z.mjs";
|
|
9
9
|
import { parseRetryAfterHttpDateMs } from "./internal/retry-after.mjs";
|
|
10
|
-
import { t as MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE } from "./transport-utils-
|
|
10
|
+
import { t as MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE } from "./transport-utils-CtuS1Upe.mjs";
|
|
11
11
|
import { n as getEnvApiKey } from "./env-api-keys-bktO00EJ.mjs";
|
|
12
|
-
import { C as headersToRecord, _ as transportAbortError, p as notifyProviderStreamOpened, y as withProviderResponseHook } from "./transport-stream-shared-
|
|
13
|
-
import { F as commitResponsesEncryptedContentAttempt, L as isInvalidEncryptedContentError, W as buildOpenAIResponsesReasoningReplayMetadata, a as resolveResponsesReasoningEffort, c as processResponsesStream, i as createResponsesAssistantOutput, n as applyResponsesServiceTierPricing, p as ResponsesStreamFailure, q as suppressOpenAIResponsesCompaction, r as convertResponsesMessages, s as convertResponsesToolPayload, z as resolveNextResponsesEncryptedContentAttempt } from "./openai-responses-shared-
|
|
14
|
-
import { C as createOpenAIProviderAcceptanceHook, w as createOpenAIResponseHook } from "./openai-tool-schema-
|
|
12
|
+
import { C as headersToRecord, _ as transportAbortError, p as notifyProviderStreamOpened, y as withProviderResponseHook } from "./transport-stream-shared-D8nQWCUo.mjs";
|
|
13
|
+
import { F as commitResponsesEncryptedContentAttempt, L as isInvalidEncryptedContentError, W as buildOpenAIResponsesReasoningReplayMetadata, a as resolveResponsesReasoningEffort, c as processResponsesStream, i as createResponsesAssistantOutput, n as applyResponsesServiceTierPricing, p as ResponsesStreamFailure, q as suppressOpenAIResponsesCompaction, r as convertResponsesMessages, s as convertResponsesToolPayload, z as resolveNextResponsesEncryptedContentAttempt } from "./openai-responses-shared-CxgdGBvm.mjs";
|
|
14
|
+
import { C as createOpenAIProviderAcceptanceHook, w as createOpenAIResponseHook } from "./openai-tool-schema-CSMh5e9O.mjs";
|
|
15
15
|
import { a as withFirstStreamEventTimeout, i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-DcNjoFQE.mjs";
|
|
16
|
-
import { A as supportsOpenAITemperature, S as responsesPromptObserver } from "./openai-responses-compaction-window-
|
|
16
|
+
import { A as supportsOpenAITemperature, S as responsesPromptObserver } from "./openai-responses-compaction-window-DO7yV7az.mjs";
|
|
17
17
|
import { t as createSseByteGuard } from "./streaming-byte-guard-CC-HMn_u.mjs";
|
|
18
18
|
import { n as registerSessionResourceCleanup } from "./session-resources-CkR4WWy1.mjs";
|
|
19
19
|
import "./diagnostics.mjs";
|
|
@@ -40,7 +40,7 @@ function sleepWithAbort(ms, signal) {
|
|
|
40
40
|
}
|
|
41
41
|
//#endregion
|
|
42
42
|
//#region packages/ai/src/providers/openai-chatgpt-responses-protocol.ts
|
|
43
|
-
const OPENAI_CHATGPT_RESPONSES_SUCCESS_BODY_MAX_BYTES =
|
|
43
|
+
const OPENAI_CHATGPT_RESPONSES_SUCCESS_BODY_MAX_BYTES = 16777216;
|
|
44
44
|
var CodexProtocolError = class extends Error {
|
|
45
45
|
constructor(message, options) {
|
|
46
46
|
super(message);
|
|
@@ -110,7 +110,7 @@ const REQUEST_COMPRESSION_ZSTD_LEVEL = 3;
|
|
|
110
110
|
const CODEX_TOOL_CALL_PROVIDERS = /* @__PURE__ */ new Set(["openai", "opencode"]);
|
|
111
111
|
const WEBSOCKET_MESSAGE_TOO_BIG_CLOSE_CODE = 1009;
|
|
112
112
|
const WEBSOCKET_CONNECTION_LIMIT_REACHED_CODE = "websocket_connection_limit_reached";
|
|
113
|
-
const OPENAI_CHATGPT_RESPONSES_ERROR_BODY_MAX_BYTES =
|
|
113
|
+
const OPENAI_CHATGPT_RESPONSES_ERROR_BODY_MAX_BYTES = 16384;
|
|
114
114
|
const CODEX_RESPONSE_STATUSES = /* @__PURE__ */ new Set([
|
|
115
115
|
"completed",
|
|
116
116
|
"incomplete",
|
|
@@ -340,7 +340,7 @@ const streamOpenAICodexResponses = (model, context, options) => {
|
|
|
340
340
|
if (!nextSemanticAttempt) throw terminalResponseError ?? /* @__PURE__ */ new Error("Failed after retries");
|
|
341
341
|
semanticAttempt = nextSemanticAttempt;
|
|
342
342
|
}
|
|
343
|
-
|
|
343
|
+
const hookedResponseStream = withProviderResponseHook({
|
|
344
344
|
stream: mapCodexEvents(parseOpenAIChatGptResponsesSse(response)),
|
|
345
345
|
signal: firstEventAbort.signal,
|
|
346
346
|
abort: firstEventAbort.abort,
|
|
@@ -349,7 +349,8 @@ const streamOpenAICodexResponses = (model, context, options) => {
|
|
|
349
349
|
type: "start",
|
|
350
350
|
partial: output
|
|
351
351
|
})
|
|
352
|
-
})
|
|
352
|
+
});
|
|
353
|
+
await processResponsesStream(hookedResponseStream, output, stream, model, {
|
|
353
354
|
serviceTier: options?.serviceTier,
|
|
354
355
|
firstEventTimeoutMs: getFirstStreamEventTimeoutMs(options),
|
|
355
356
|
abortFirstEventStream: firstEventAbort.abort,
|
|
@@ -515,8 +516,8 @@ function normalizeCodexStatus(status) {
|
|
|
515
516
|
return CODEX_RESPONSE_STATUSES.has(status) ? status : void 0;
|
|
516
517
|
}
|
|
517
518
|
const OPENAI_BETA_RESPONSES_WEBSOCKETS = "responses_websockets=2026-02-06";
|
|
518
|
-
const SESSION_WEBSOCKET_CACHE_TTL_MS =
|
|
519
|
-
const SESSION_WEBSOCKET_MAX_AGE_MS =
|
|
519
|
+
const SESSION_WEBSOCKET_CACHE_TTL_MS = 3e5;
|
|
520
|
+
const SESSION_WEBSOCKET_MAX_AGE_MS = 33e5;
|
|
520
521
|
const websocketSessionCache = /* @__PURE__ */ new Map();
|
|
521
522
|
const websocketSseFallbackSessions = /* @__PURE__ */ new Set();
|
|
522
523
|
let cachedWebsocket = null;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
2
|
import { t as AssistantMessageEventStream } from "./event-stream-uSMZJ3FA.mjs";
|
|
3
|
-
import { i as clampThinkingLevel } from "./sanitize-unicode-
|
|
4
|
-
import { n as getAiTransportHost } from "./host-
|
|
5
|
-
import { n as projectProviderError } from "./provider-error-
|
|
3
|
+
import { i as clampThinkingLevel } from "./sanitize-unicode-S6binQG-.mjs";
|
|
4
|
+
import { n as getAiTransportHost } from "./host-BIaiBURL.mjs";
|
|
5
|
+
import { n as projectProviderError } from "./provider-error-BI8kIViN.mjs";
|
|
6
6
|
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-mZTCdRPo.mjs";
|
|
7
7
|
import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
|
|
8
|
-
import { m as sortPromptCacheToolsByName, n as buildBaseOptions, o as reasoningTagTextPolicy, u as splitSystemPromptCacheBoundary } from "./simple-options-
|
|
8
|
+
import { m as sortPromptCacheToolsByName, n as buildBaseOptions, o as reasoningTagTextPolicy, u as splitSystemPromptCacheBoundary } from "./simple-options-rdOPzr7Z.mjs";
|
|
9
9
|
import { n as getEnvApiKey } from "./env-api-keys-bktO00EJ.mjs";
|
|
10
|
-
import { _ as transportAbortError, y as withProviderResponseHook } from "./transport-stream-shared-
|
|
11
|
-
import { E as tagUnresolvedTextAsCommentary, S as shouldOmitOllamaCompatResponseFormat, _ as hasToolCallHistory, b as resolveOpenAICompletionsCompat, g as convertMessages, h as resolveOpenAIReasoningEffortMap, t as processCompletionsStream, v as finalizeOpenAICompletionsToolCalls, w as clearPendingCommentaryText, x as resolveOpenAICompletionsResponseFormat } from "./openai-completions-stream-
|
|
12
|
-
import { C as createOpenAIProviderAcceptanceHook, T as isOpenAICompletionsThinkingEnabled, j as resolveOpenAIClientBaseUrl, v as projectOpenAITools, y as reconcileOpenAICompletionsToolChoice } from "./openai-tool-schema-
|
|
10
|
+
import { _ as transportAbortError, y as withProviderResponseHook } from "./transport-stream-shared-D8nQWCUo.mjs";
|
|
11
|
+
import { E as tagUnresolvedTextAsCommentary, S as shouldOmitOllamaCompatResponseFormat, _ as hasToolCallHistory, b as resolveOpenAICompletionsCompat, g as convertMessages, h as resolveOpenAIReasoningEffortMap, t as processCompletionsStream, v as finalizeOpenAICompletionsToolCalls, w as clearPendingCommentaryText, x as resolveOpenAICompletionsResponseFormat } from "./openai-completions-stream-DGOvau4J.mjs";
|
|
12
|
+
import { C as createOpenAIProviderAcceptanceHook, T as isOpenAICompletionsThinkingEnabled, j as resolveOpenAIClientBaseUrl, v as projectOpenAITools, y as reconcileOpenAICompletionsToolChoice } from "./openai-tool-schema-CSMh5e9O.mjs";
|
|
13
13
|
import { i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-DcNjoFQE.mjs";
|
|
14
14
|
import { i as resolveCloudflareBaseUrl, n as hasCopilotVisionInput, r as isCloudflareProvider, t as buildCopilotDynamicHeaders } from "./github-copilot-headers-NCJtz9i0.mjs";
|
|
15
15
|
import OpenAI from "openai";
|
|
@@ -191,11 +191,13 @@ function createClient(model, context, apiKey, optionsHeaders, sessionId, compat
|
|
|
191
191
|
});
|
|
192
192
|
Object.assign(headers, copilotHeaders);
|
|
193
193
|
}
|
|
194
|
-
if (sessionId && compat.sessionAffinity !== "none")
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
194
|
+
if (sessionId && compat.sessionAffinity !== "none") {
|
|
195
|
+
if (compat.sessionAffinity === "openrouter") headers["x-session-id"] = sessionId;
|
|
196
|
+
else {
|
|
197
|
+
headers.session_id = sessionId;
|
|
198
|
+
headers["x-client-request-id"] = sessionId;
|
|
199
|
+
headers["x-session-affinity"] = sessionId;
|
|
200
|
+
}
|
|
199
201
|
}
|
|
200
202
|
if (optionsHeaders) Object.assign(headers, optionsHeaders);
|
|
201
203
|
const defaultHeaders = model.provider === "cloudflare-ai-gateway" ? {
|
|
@@ -203,9 +205,10 @@ function createClient(model, context, apiKey, optionsHeaders, sessionId, compat
|
|
|
203
205
|
Authorization: headers.Authorization ?? null,
|
|
204
206
|
"cf-aig-authorization": `Bearer ${apiKey}`
|
|
205
207
|
} : headers;
|
|
208
|
+
const baseUrl = isCloudflareProvider(model.provider) ? resolveCloudflareBaseUrl(model) : model.baseUrl;
|
|
206
209
|
return new OpenAI({
|
|
207
210
|
apiKey,
|
|
208
|
-
baseURL: resolveOpenAIClientBaseUrl(model,
|
|
211
|
+
baseURL: resolveOpenAIClientBaseUrl(model, baseUrl),
|
|
209
212
|
dangerouslyAllowBrowser: true,
|
|
210
213
|
defaultHeaders,
|
|
211
214
|
fetch: getAiTransportHost().buildModelFetch(model)
|
package/dist/{openai-completions-compat-DB7FFq7k.d.mts → openai-completions-compat-SZhi0Lf4.d.mts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { D as Model,
|
|
3
|
-
import { a as AiProviderRequestPolicyInput, i as AiProviderRequestCapabilities } from "./host-
|
|
1
|
+
import "./index-CefaUGSS.mjs";
|
|
2
|
+
import { D as Model, j as OpenAICompletionsCompat } from "./types-Beemor2E.mjs";
|
|
3
|
+
import { a as AiProviderRequestPolicyInput, i as AiProviderRequestCapabilities } from "./host-DKFUAmCn.mjs";
|
|
4
4
|
//#region packages/ai/src/transports/openai-completions-compat.d.ts
|
|
5
5
|
type ProviderRequestCapabilities = AiProviderRequestCapabilities;
|
|
6
6
|
type OpenAICompletionsSessionAffinity = "none" | "openai" | "openrouter";
|
package/dist/{openai-completions-stream-Bpns6uNc.mjs → openai-completions-stream-DGOvau4J.mjs}
RENAMED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { c as normalizeLowercaseStringOrEmpty, i as asOptionalObjectRecord, o as isRecord, t as truncateUtf16Safe } from "./utf16-slice-qz3nsy87.mjs";
|
|
2
|
-
import { t as sanitizeSurrogates } from "./sanitize-unicode-
|
|
3
|
-
import { a as describeToolResultMediaPlaceholder, c as extractToolResultText, d as isImageWithMediaPayload, n as getAiTransportHost } from "./host-
|
|
2
|
+
import { t as sanitizeSurrogates } from "./sanitize-unicode-S6binQG-.mjs";
|
|
3
|
+
import { a as describeToolResultMediaPlaceholder, c as extractToolResultText, d as isImageWithMediaPayload, n as getAiTransportHost } from "./host-BIaiBURL.mjs";
|
|
4
4
|
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-mZTCdRPo.mjs";
|
|
5
|
-
import { d as stripSystemPromptCacheBoundary } from "./simple-options-
|
|
6
|
-
import { o as resolveProviderRequestCapabilities, r as resolveModelRequestTimeoutMs, s as resolveProviderRequestPolicyConfig } from "./tool-schema-json-projection-
|
|
7
|
-
import { i as isCodeModeModelVisibleToolName, p as sha256Hex } from "./transport-utils-
|
|
8
|
-
import { s as finalizeTerminalToolCallArguments } from "./transport-stream-shared-
|
|
5
|
+
import { d as stripSystemPromptCacheBoundary } from "./simple-options-rdOPzr7Z.mjs";
|
|
6
|
+
import { o as resolveProviderRequestCapabilities, r as resolveModelRequestTimeoutMs, s as resolveProviderRequestPolicyConfig } from "./tool-schema-json-projection-BtZiml7r.mjs";
|
|
7
|
+
import { i as isCodeModeModelVisibleToolName, p as sha256Hex } from "./transport-utils-CtuS1Upe.mjs";
|
|
8
|
+
import { s as finalizeTerminalToolCallArguments } from "./transport-stream-shared-D8nQWCUo.mjs";
|
|
9
9
|
import { r as parseStreamingJson, t as createToolArgumentPreviewSchedule } from "./json-parse-BuAJEbdW.mjs";
|
|
10
10
|
import { t as notifyLlmRequestActivity } from "./llm-request-activity-BjtkplhG.mjs";
|
|
11
|
-
import { A as readOpenAICompletionsReasoningBatch, D as measureUtf8AppendBytes, N as throwIfModelStreamAborted, O as parseOpenAICompletionsUsage, S as createModelStreamCooperativeScheduler, T as isOpenAICompletionsThinkingEnabled, a as resolveOpenAIProjectedToolsStrictToolFlag, k as readOpenAICompletionsContentDeltas, t as findOpenAIStrictToolProjectionDiagnostics } from "./openai-tool-schema-
|
|
11
|
+
import { A as readOpenAICompletionsReasoningBatch, D as measureUtf8AppendBytes, N as throwIfModelStreamAborted, O as parseOpenAICompletionsUsage, S as createModelStreamCooperativeScheduler, T as isOpenAICompletionsThinkingEnabled, a as resolveOpenAIProjectedToolsStrictToolFlag, k as readOpenAICompletionsContentDeltas, t as findOpenAIStrictToolProjectionDiagnostics } from "./openai-tool-schema-CSMh5e9O.mjs";
|
|
12
12
|
import { a as withFirstStreamEventTimeout } from "./stream-first-event-timeout-DcNjoFQE.mjs";
|
|
13
|
-
import { t as transformProviderMessages } from "./provider-transcript-transform-
|
|
13
|
+
import { t as transformProviderMessages } from "./provider-transcript-transform-WvJmFUAf.mjs";
|
|
14
14
|
import { t as mapOpenAIStopReason } from "./openai-stop-reason-Drnn_6Qj.mjs";
|
|
15
|
-
import { t as createReasoningTagTextPartitioner } from "./reasoning-tag-text-partitioner-
|
|
15
|
+
import { t as createReasoningTagTextPartitioner } from "./reasoning-tag-text-partitioner-BsUX44Tq.mjs";
|
|
16
16
|
import { randomUUID } from "node:crypto";
|
|
17
17
|
//#region packages/ai/src/utils/assistant-text-phase.ts
|
|
18
18
|
const EMPTY_ASSISTANT_TEXT_BLOCK_SET = /* @__PURE__ */ new Set();
|
|
@@ -396,11 +396,13 @@ function createOpenAICompletionsToolCallDeltaNormalizer() {
|
|
|
396
396
|
}];
|
|
397
397
|
const hadPendingLegacyCall = pendingLegacyToolCall !== void 0;
|
|
398
398
|
const leadingDeltas = [];
|
|
399
|
-
if (hasOrdinaryContent(ordinaryDelta))
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
399
|
+
if (hasOrdinaryContent(ordinaryDelta)) {
|
|
400
|
+
if (hadPendingLegacyCall) bufferFollowingDelta(ordinaryDelta);
|
|
401
|
+
else leadingDeltas.push({
|
|
402
|
+
delta: ordinaryDelta,
|
|
403
|
+
toolCalls: []
|
|
404
|
+
});
|
|
405
|
+
}
|
|
404
406
|
if (functionCall && (functionCall.name || functionCall.arguments)) {
|
|
405
407
|
const nextFunctionName = pendingLegacyToolCall?.function?.name ? void 0 : functionCall.name;
|
|
406
408
|
const nextArgumentBytes = Buffer.byteLength(functionCall.arguments ?? "", "utf8") + Buffer.byteLength(nextFunctionName ?? "", "utf8");
|
|
@@ -566,17 +568,18 @@ function convertMessages(model, context, compat, options = {}) {
|
|
|
566
568
|
}));
|
|
567
569
|
const assistantText = assistantTextParts.map((part) => part.text).join("\n");
|
|
568
570
|
const nonEmptyThinkingBlocks = msg.content.filter(isThinkingContentBlock).filter((block) => block.thinking.trim().length > 0);
|
|
569
|
-
if (nonEmptyThinkingBlocks.length > 0)
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
571
|
+
if (nonEmptyThinkingBlocks.length > 0) {
|
|
572
|
+
if (compat.requiresThinkingAsText) assistantMsg.content = [{
|
|
573
|
+
type: "text",
|
|
574
|
+
text: nonEmptyThinkingBlocks.map((block) => sanitizeSurrogates(block.thinking)).join("\n\n")
|
|
575
|
+
}, ...assistantTextParts];
|
|
576
|
+
else {
|
|
577
|
+
if (assistantText.length > 0) assistantMsg.content = assistantText;
|
|
578
|
+
let signature = nonEmptyThinkingBlocks.at(0)?.thinkingSignature;
|
|
579
|
+
if (model.provider === "opencode-go" && signature === "reasoning") signature = "reasoning_content";
|
|
580
|
+
if (signature && signature.length > 0) assistantMsg[signature] = nonEmptyThinkingBlocks.map((block) => block.thinking).join("\n");
|
|
581
|
+
}
|
|
582
|
+
} else if (assistantText.length > 0) assistantMsg.content = assistantText;
|
|
580
583
|
const toolCalls = msg.content.filter(isToolCallBlock);
|
|
581
584
|
if (toolCalls.length > 0) {
|
|
582
585
|
assistantMsg.tool_calls = toolCalls.map((toolCall) => ({
|
|
@@ -912,7 +915,7 @@ const DEEPSEEK_DSML_INVOKE_OPEN_TAG = new RegExp(`^<${DEEPSEEK_DSML_MARKER_PATTE
|
|
|
912
915
|
const DEEPSEEK_DSML_TOOL_MAX_OPEN_TOKEN_LEN = Math.max(...DEEPSEEK_DSML_TOOL_OPEN_TOKENS.map((token) => token.length));
|
|
913
916
|
const DEEPSEEK_DSML_RECOVERY_MAX_BOUNDARY_LEN = Math.max(...DEEPSEEK_DSML_TOOL_OPEN_TOKENS.map((token) => token.length + 1), ...DEEPSEEK_DSML_INVOKE_OPEN_PREFIXES.map((token) => token.length + 2));
|
|
914
917
|
const MAX_DSML_RECOVERY_BUFFER_BYTES = 256e3;
|
|
915
|
-
const DEEPSEEK_DSML_SCAN_BATCH_CHARS =
|
|
918
|
+
const DEEPSEEK_DSML_SCAN_BATCH_CHARS = 65536;
|
|
916
919
|
function createDsmlRecoverer() {
|
|
917
920
|
let buffer = "";
|
|
918
921
|
let bufferBytes = 0;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
2
|
import { t as AssistantMessageEventStream } from "./event-stream-uSMZJ3FA.mjs";
|
|
3
|
-
import { n as getAiTransportHost } from "./host-
|
|
3
|
+
import { n as getAiTransportHost } from "./host-BIaiBURL.mjs";
|
|
4
4
|
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-mZTCdRPo.mjs";
|
|
5
5
|
import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
|
|
6
|
-
import { n as buildBaseOptions } from "./simple-options-
|
|
6
|
+
import { n as buildBaseOptions } from "./simple-options-rdOPzr7Z.mjs";
|
|
7
7
|
import { n as getEnvApiKey } from "./env-api-keys-bktO00EJ.mjs";
|
|
8
|
-
import { a as resolveResponsesReasoningEffort, i as createResponsesAssistantOutput, n as applyResponsesServiceTierPricing, o as runResponsesStreamLifecycle, r as convertResponsesMessages, t as applyCommonResponsesParams } from "./openai-responses-shared-
|
|
9
|
-
import { j as resolveOpenAIClientBaseUrl } from "./openai-tool-schema-
|
|
10
|
-
import { A as supportsOpenAITemperature } from "./openai-responses-compaction-window-
|
|
8
|
+
import { a as resolveResponsesReasoningEffort, i as createResponsesAssistantOutput, n as applyResponsesServiceTierPricing, o as runResponsesStreamLifecycle, r as convertResponsesMessages, t as applyCommonResponsesParams } from "./openai-responses-shared-CxgdGBvm.mjs";
|
|
9
|
+
import { j as resolveOpenAIClientBaseUrl } from "./openai-tool-schema-CSMh5e9O.mjs";
|
|
10
|
+
import { A as supportsOpenAITemperature } from "./openai-responses-compaction-window-DO7yV7az.mjs";
|
|
11
11
|
import { i as resolveCloudflareBaseUrl, n as hasCopilotVisionInput, r as isCloudflareProvider, t as buildCopilotDynamicHeaders } from "./github-copilot-headers-NCJtz9i0.mjs";
|
|
12
12
|
import OpenAI from "openai";
|
|
13
13
|
//#region packages/ai/src/providers/openai-responses.ts
|
|
@@ -30,10 +30,11 @@ function getPromptCacheRetention(compat, cacheRetention) {
|
|
|
30
30
|
*/
|
|
31
31
|
const streamOpenAIResponses = (model, context, options) => {
|
|
32
32
|
const stream = new AssistantMessageEventStream();
|
|
33
|
+
const output = createResponsesAssistantOutput(model);
|
|
33
34
|
runResponsesStreamLifecycle({
|
|
34
35
|
stream,
|
|
35
36
|
model,
|
|
36
|
-
output
|
|
37
|
+
output,
|
|
37
38
|
options,
|
|
38
39
|
createClient: () => {
|
|
39
40
|
const apiKey = options?.apiKey || getEnvApiKey(model.provider) || "";
|
|
@@ -82,9 +83,10 @@ function createClient(model, context, apiKey, optionsHeaders, sessionId) {
|
|
|
82
83
|
Authorization: headers.Authorization ?? null,
|
|
83
84
|
"cf-aig-authorization": `Bearer ${apiKey}`
|
|
84
85
|
} : headers;
|
|
86
|
+
const baseUrl = isCloudflareProvider(model.provider) ? resolveCloudflareBaseUrl(model) : model.baseUrl;
|
|
85
87
|
return new OpenAI({
|
|
86
88
|
apiKey,
|
|
87
|
-
baseURL: resolveOpenAIClientBaseUrl(model,
|
|
89
|
+
baseURL: resolveOpenAIClientBaseUrl(model, baseUrl),
|
|
88
90
|
dangerouslyAllowBrowser: true,
|
|
89
91
|
defaultHeaders,
|
|
90
92
|
fetch: getAiTransportHost().buildModelFetch(model)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "./src-
|
|
1
|
+
import "./src-C8U7lkoa.mjs";
|
|
2
2
|
import { n as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE } from "./types-BDdaOVi2.mjs";
|
|
3
3
|
import { c as normalizeLowercaseStringOrEmpty, o as isRecord, p as readStringValue, u as normalizeOptionalLowercaseString } from "./utf16-slice-qz3nsy87.mjs";
|
|
4
4
|
import { t as canonicalizeBase64 } from "./base64-CEFBpSkN.mjs";
|
|
5
5
|
import { n as uniqueStrings, t as normalizeStringEntries } from "./string-normalization--fwJ4S2q.mjs";
|
|
6
|
-
import { s as parsePositiveInteger } from "./transport-utils-
|
|
6
|
+
import { s as parsePositiveInteger } from "./transport-utils-CtuS1Upe.mjs";
|
|
7
7
|
import { t as createSseByteGuard } from "./streaming-byte-guard-CC-HMn_u.mjs";
|
|
8
8
|
//#region packages/ai/src/providers/openai-reasoning-effort.ts
|
|
9
9
|
/**
|
|
@@ -581,7 +581,7 @@ function sanitizeResponsesImagePayload(params) {
|
|
|
581
581
|
}
|
|
582
582
|
//#endregion
|
|
583
583
|
//#region packages/ai/src/transports/openai-responses-compaction-window.ts
|
|
584
|
-
const COMPACTION_WINDOW_MAX_BYTES =
|
|
584
|
+
const COMPACTION_WINDOW_MAX_BYTES = 16777216;
|
|
585
585
|
function isOptionalCompactionString(value) {
|
|
586
586
|
return value === void 0 || typeof value === "string";
|
|
587
587
|
}
|
package/dist/{openai-responses-contracts-DgaR3t5T.d.mts → openai-responses-contracts-BthRXano.d.mts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { D as Model, n as Api } from "./types-
|
|
3
|
-
import { g as OpenAIReasoningEffort, h as OpenAIApiReasoningEffort, i as BaseOpenAIStreamOptions } from "./provider-options-
|
|
1
|
+
import "./index-CefaUGSS.mjs";
|
|
2
|
+
import { D as Model, n as Api } from "./types-Beemor2E.mjs";
|
|
3
|
+
import { g as OpenAIReasoningEffort, h as OpenAIApiReasoningEffort, i as BaseOpenAIStreamOptions } from "./provider-options-DJd_9euj.mjs";
|
|
4
4
|
import { FunctionTool, ResponseCompactionItem, ResponseCreateParamsStreaming, ResponseInput, ResponseInputItem } from "openai/resources/responses/responses.js";
|
|
5
5
|
//#region packages/ai/src/transports/openai-responses-compaction-window.d.ts
|
|
6
6
|
type OpenAIResponsesCompactionOutput = Array<ResponseInputItem.Message | ReplayableResponseCompactionItem>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { d as stripSystemPromptCacheBoundary } from "./simple-options-
|
|
2
|
-
import { g as sanitizeTransportPayloadText } from "./transport-stream-shared-
|
|
3
|
-
import { S as responsesPromptObserver } from "./openai-responses-compaction-window-
|
|
1
|
+
import { d as stripSystemPromptCacheBoundary } from "./simple-options-rdOPzr7Z.mjs";
|
|
2
|
+
import { g as sanitizeTransportPayloadText } from "./transport-stream-shared-D8nQWCUo.mjs";
|
|
3
|
+
import { S as responsesPromptObserver } from "./openai-responses-compaction-window-DO7yV7az.mjs";
|
|
4
4
|
//#region packages/normalization-core/src/error-coercion.ts
|
|
5
5
|
/**
|
|
6
6
|
* Normalizes an unknown thrown value into an Error. Non-Error objects become
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { c as normalizeLowercaseStringOrEmpty, d as normalizeOptionalString, o as isRecord, t as truncateUtf16Safe } from "./utf16-slice-qz3nsy87.mjs";
|
|
2
|
-
import { i as clampThinkingLevel, r as calculateCost } from "./sanitize-unicode-
|
|
3
|
-
import { a as describeToolResultMediaPlaceholder, c as extractToolResultText, d as isImageWithMediaPayload, n as getAiTransportHost } from "./host-
|
|
4
|
-
import { n as projectProviderError } from "./provider-error-
|
|
2
|
+
import { i as clampThinkingLevel, r as calculateCost } from "./sanitize-unicode-S6binQG-.mjs";
|
|
3
|
+
import { a as describeToolResultMediaPlaceholder, c as extractToolResultText, d as isImageWithMediaPayload, n as getAiTransportHost } from "./host-BIaiBURL.mjs";
|
|
4
|
+
import { n as projectProviderError } from "./provider-error-BI8kIViN.mjs";
|
|
5
5
|
import { r as asFiniteNumber } from "./base64-CEFBpSkN.mjs";
|
|
6
|
-
import { d as stripSystemPromptCacheBoundary, m as sortPromptCacheToolsByName } from "./simple-options-
|
|
7
|
-
import { c as transformTransportMessages } from "./tool-schema-json-projection-
|
|
8
|
-
import { d as redactSensitiveText, u as redactIdentifier } from "./transport-utils-
|
|
9
|
-
import { _ as transportAbortError, g as sanitizeTransportPayloadText, h as sanitizeNonEmptyTransportPayloadText, m as parseTerminalToolCallArguments, y as withProviderResponseHook } from "./transport-stream-shared-
|
|
6
|
+
import { d as stripSystemPromptCacheBoundary, m as sortPromptCacheToolsByName } from "./simple-options-rdOPzr7Z.mjs";
|
|
7
|
+
import { c as transformTransportMessages } from "./tool-schema-json-projection-BtZiml7r.mjs";
|
|
8
|
+
import { d as redactSensitiveText, u as redactIdentifier } from "./transport-utils-CtuS1Upe.mjs";
|
|
9
|
+
import { _ as transportAbortError, g as sanitizeTransportPayloadText, h as sanitizeNonEmptyTransportPayloadText, m as parseTerminalToolCallArguments, y as withProviderResponseHook } from "./transport-stream-shared-D8nQWCUo.mjs";
|
|
10
10
|
import { r as parseStreamingJson, t as createToolArgumentPreviewSchedule } from "./json-parse-BuAJEbdW.mjs";
|
|
11
11
|
import { t as notifyLlmRequestActivity } from "./llm-request-activity-BjtkplhG.mjs";
|
|
12
12
|
import { t as shortHash } from "./hash-CHgqbJmD.mjs";
|
|
13
|
-
import { C as createOpenAIProviderAcceptanceHook, E as log, S as createModelStreamCooperativeScheduler, a as resolveOpenAIProjectedToolsStrictToolFlag, r as normalizeOpenAIStrictToolParameters, t as findOpenAIStrictToolProjectionDiagnostics, v as projectOpenAITools } from "./openai-tool-schema-
|
|
13
|
+
import { C as createOpenAIProviderAcceptanceHook, E as log, S as createModelStreamCooperativeScheduler, a as resolveOpenAIProjectedToolsStrictToolFlag, r as normalizeOpenAIStrictToolParameters, t as findOpenAIStrictToolProjectionDiagnostics, v as projectOpenAITools } from "./openai-tool-schema-CSMh5e9O.mjs";
|
|
14
14
|
import { a as withFirstStreamEventTimeout, i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-DcNjoFQE.mjs";
|
|
15
|
-
import { t as transformProviderMessages } from "./provider-transcript-transform-
|
|
16
|
-
import { A as supportsOpenAITemperature, D as resolveOpenAIReasoningEffortForModel, b as RESPONSE_FAILED_NO_DETAILS_MESSAGE, g as OPENAI_RESPONSES_RETAINED_COMPACTION_REPLAY_TYPE, h as OPENAI_RESPONSES_REASONING_REPLAY_META_KEY, k as supportsOpenAIReasoningEffort, m as OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY, n as isOpenAIResponsesCompactionOutput, p as OPENAI_RESPONSES_COMPACTION_REPLAY_TYPE, r as readOpenAIResponsesCompactionWindow } from "./openai-responses-compaction-window-
|
|
15
|
+
import { t as transformProviderMessages } from "./provider-transcript-transform-WvJmFUAf.mjs";
|
|
16
|
+
import { A as supportsOpenAITemperature, D as resolveOpenAIReasoningEffortForModel, b as RESPONSE_FAILED_NO_DETAILS_MESSAGE, g as OPENAI_RESPONSES_RETAINED_COMPACTION_REPLAY_TYPE, h as OPENAI_RESPONSES_REASONING_REPLAY_META_KEY, k as supportsOpenAIReasoningEffort, m as OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY, n as isOpenAIResponsesCompactionOutput, p as OPENAI_RESPONSES_COMPACTION_REPLAY_TYPE, r as readOpenAIResponsesCompactionWindow } from "./openai-responses-compaction-window-DO7yV7az.mjs";
|
|
17
17
|
import { createHash, randomUUID } from "node:crypto";
|
|
18
18
|
//#region packages/ai/src/transports/model-transport-debug.ts
|
|
19
19
|
/**
|
|
@@ -441,23 +441,24 @@ function convertResponsesMessagesWithStyle(model, context, allowedToolCallProvid
|
|
|
441
441
|
messages.push(msg);
|
|
442
442
|
continue;
|
|
443
443
|
}
|
|
444
|
-
if (msg.role === "user")
|
|
445
|
-
|
|
446
|
-
text: sanitizeTransportPayloadText(msg.content)
|
|
447
|
-
}]));
|
|
448
|
-
else {
|
|
449
|
-
const content = msg.content.map((item) => item.type === "text" ? {
|
|
444
|
+
if (msg.role === "user") {
|
|
445
|
+
if (typeof msg.content === "string") messages.push(buildResponsesInputMessage("user", [{
|
|
450
446
|
type: "input_text",
|
|
451
|
-
text: sanitizeTransportPayloadText(
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
447
|
+
text: sanitizeTransportPayloadText(msg.content)
|
|
448
|
+
}]));
|
|
449
|
+
else {
|
|
450
|
+
const content = msg.content.map((item) => item.type === "text" ? {
|
|
451
|
+
type: "input_text",
|
|
452
|
+
text: sanitizeTransportPayloadText(item.text)
|
|
453
|
+
} : {
|
|
454
|
+
type: "input_image",
|
|
455
|
+
detail: "auto",
|
|
456
|
+
image_url: `data:${item.mimeType};base64,${item.data}`
|
|
457
|
+
}).filter((item) => providerStyle || model.input.includes("image") || item.type !== "input_image");
|
|
458
|
+
if (content.length > 0) messages.push(buildResponsesInputMessage("user", content));
|
|
459
|
+
else if (providerStyle) continue;
|
|
460
|
+
}
|
|
461
|
+
} else if (msg.role === "assistant") {
|
|
461
462
|
const output = [];
|
|
462
463
|
let textFallbackOrdinal = 0;
|
|
463
464
|
let previousReplayItemWasReasoning = false;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { c as normalizeLowercaseStringOrEmpty, o as isRecord } from "./utf16-slice-qz3nsy87.mjs";
|
|
2
|
-
import { n as applyProviderReportedUsageCost, r as calculateCost } from "./sanitize-unicode-
|
|
3
|
-
import { n as getAiTransportHost } from "./host-
|
|
2
|
+
import { n as applyProviderReportedUsageCost, r as calculateCost } from "./sanitize-unicode-S6binQG-.mjs";
|
|
3
|
+
import { n as getAiTransportHost } from "./host-BIaiBURL.mjs";
|
|
4
4
|
import { r as uniqueValues, t as normalizeStringEntries } from "./string-normalization--fwJ4S2q.mjs";
|
|
5
5
|
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-mZTCdRPo.mjs";
|
|
6
|
-
import { t as projectRuntimeToolInputSchema } from "./tool-schema-json-projection-
|
|
7
|
-
import { C as headersToRecord, _ as transportAbortError, f as notifyProviderHttpResponse } from "./transport-stream-shared-
|
|
6
|
+
import { t as projectRuntimeToolInputSchema } from "./tool-schema-json-projection-BtZiml7r.mjs";
|
|
7
|
+
import { C as headersToRecord, _ as transportAbortError, f as notifyProviderHttpResponse } from "./transport-stream-shared-D8nQWCUo.mjs";
|
|
8
8
|
//#region packages/ai/src/transports/openai-transport-shared.ts
|
|
9
9
|
/** Shared options, usage shape, cache identity, ordering, and stream scheduling for OpenAI APIs. */
|
|
10
10
|
const MODEL_STREAM_COOPERATIVE_YIELD_INTERVAL_MS = 12;
|
|
@@ -112,7 +112,7 @@ function readOpenAICompletionsReasoningBatch(delta, visibleReasoningDetailTypes)
|
|
|
112
112
|
}
|
|
113
113
|
function parseOpenAICompletionsUsage(rawUsage, model, options) {
|
|
114
114
|
const cacheRead = rawUsage.prompt_tokens_details?.cached_tokens ?? rawUsage.prompt_cache_hit_tokens ?? 0;
|
|
115
|
-
const cacheWrite = rawUsage.prompt_tokens_details?.cache_write_tokens
|
|
115
|
+
const cacheWrite = rawUsage.prompt_tokens_details?.cache_write_tokens ?? rawUsage.prompt_tokens_details?.cache_creation_input_tokens ?? 0;
|
|
116
116
|
const input = Math.max(0, (rawUsage.prompt_tokens || 0) - cacheRead - cacheWrite);
|
|
117
117
|
const output = rawUsage.completion_tokens || 0;
|
|
118
118
|
const reasoningTokens = rawUsage.completion_tokens_details?.reasoning_tokens;
|
|
@@ -647,12 +647,14 @@ function cleanSchemaForGeminiWithDefs(schema, defs, refStack) {
|
|
|
647
647
|
cleaned.type = types.length === 1 ? types[0] : types;
|
|
648
648
|
continue;
|
|
649
649
|
}
|
|
650
|
-
if (key === "properties")
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
else if (
|
|
654
|
-
|
|
655
|
-
|
|
650
|
+
if (key === "properties") {
|
|
651
|
+
if (value && typeof value === "object" && !Array.isArray(value)) cleaned[key] = Object.fromEntries(Object.entries(value).map(([k, v]) => [k, cleanSchemaForGeminiWithDefs(v, nextDefs, refStack)]));
|
|
652
|
+
else cleaned[key] = {};
|
|
653
|
+
} else if (key === "items" && value) {
|
|
654
|
+
if (Array.isArray(value)) cleaned[key] = value.map((entry) => cleanSchemaForGeminiWithDefs(entry, nextDefs, refStack));
|
|
655
|
+
else if (typeof value === "object") cleaned[key] = cleanSchemaForGeminiWithDefs(value, nextDefs, refStack);
|
|
656
|
+
else cleaned[key] = value;
|
|
657
|
+
} else if (key === "anyOf" && Array.isArray(value)) cleaned[key] = cleanedAnyOf ?? value.map((variant) => cleanSchemaForGeminiWithDefs(variant, nextDefs, refStack));
|
|
656
658
|
else if (key === "oneOf" && Array.isArray(value)) cleaned[key] = cleanedOneOf ?? value.map((variant) => cleanSchemaForGeminiWithDefs(variant, nextDefs, refStack));
|
|
657
659
|
else if (key === "allOf" && Array.isArray(value)) cleaned[key] = value.map((variant) => cleanSchemaForGeminiWithDefs(variant, nextDefs, refStack));
|
|
658
660
|
else cleaned[key] = value;
|
|
@@ -4,10 +4,9 @@ import { n as estimateBase64DecodedBytes } from "./base64-CEFBpSkN.mjs";
|
|
|
4
4
|
function isJsonOpeningDelimiter(char, openers) {
|
|
5
5
|
return (char === "{" || char === "[") && openers.includes(char);
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
function extractBalancedJsonPrefix(raw, opts = {}) {
|
|
7
|
+
function extractBalancedJsonAt(raw, opts, offset) {
|
|
9
8
|
const openers = opts.openers ?? ["{", "["];
|
|
10
|
-
let start =
|
|
9
|
+
let start = offset;
|
|
11
10
|
while (start < raw.length && !isJsonOpeningDelimiter(raw[start], openers)) start += 1;
|
|
12
11
|
const stack = [];
|
|
13
12
|
let inString = false;
|
|
@@ -35,14 +34,10 @@ function extractBalancedJsonPrefix(raw, opts = {}) {
|
|
|
35
34
|
function extractBalancedJsonFragments(raw, opts = {}) {
|
|
36
35
|
const fragments = [];
|
|
37
36
|
for (let offset = 0; offset < raw.length;) {
|
|
38
|
-
const fragment =
|
|
37
|
+
const fragment = extractBalancedJsonAt(raw, opts, offset);
|
|
39
38
|
if (!fragment) break;
|
|
40
|
-
fragments.push(
|
|
41
|
-
|
|
42
|
-
startIndex: offset + fragment.startIndex,
|
|
43
|
-
endIndex: offset + fragment.endIndex
|
|
44
|
-
});
|
|
45
|
-
offset += fragment.endIndex + 1;
|
|
39
|
+
fragments.push(fragment);
|
|
40
|
+
offset = fragment.endIndex + 1;
|
|
46
41
|
}
|
|
47
42
|
return fragments;
|
|
48
43
|
}
|
|
@@ -83,6 +78,11 @@ function stringifyObjectValue(value, stack, normalizeString) {
|
|
|
83
78
|
return `[${serializedEntries.join(",")}]`;
|
|
84
79
|
}
|
|
85
80
|
const record = value;
|
|
81
|
+
if (normalizeString === preserveString) {
|
|
82
|
+
const fields = [];
|
|
83
|
+
for (const key of Object.keys(record).toSorted()) fields.push(`${JSON.stringify(key)}:${stringifyStableValue(record[key], stack, normalizeString)}`);
|
|
84
|
+
return `{${fields.join(",")}}`;
|
|
85
|
+
}
|
|
86
86
|
const entries = Object.keys(record).map((key) => ({
|
|
87
87
|
key,
|
|
88
88
|
normalizedKey: normalizeString(key)
|
|
@@ -124,7 +124,7 @@ const CREDENTIAL_HEADER_RE = /\b((?:[A-Za-z][A-Za-z0-9_.-]*[_.-])?(?:api[_.-]?ke
|
|
|
124
124
|
const LOOSE_QUOTED_CREDENTIAL_PAIR_RE = /\b((?!(?:api|endpoint|method|model|provider|status|type)=)[A-Za-z][A-Za-z0-9_.-]{0,64})=(["'])([A-Za-z0-9+/._~%=-]{16,})\2/giu;
|
|
125
125
|
const LOOSE_CREDENTIAL_PAIR_RE = /\b((?!(?:api|endpoint|method|model|provider|status|type)=)[A-Za-z][A-Za-z0-9_.-]{0,64})=([A-Za-z0-9+/._~%=-]{16,})(?=[;&#'"\s]|$)/giu;
|
|
126
126
|
const MEDIA_DATA_URL_RE = /data:(?:audio|image|video)\/[a-z0-9.+-]+(?:;[^,;\s]+)*;base64,[ \t]*(?:\r?\n[ \t]*)?[a-z0-9+/_=-]+(?:[ \t]*\r?\n[ \t]*[a-z0-9+/_=-]+)*/giu;
|
|
127
|
-
const MAX_DIAGNOSTIC_JSON_LENGTH =
|
|
127
|
+
const MAX_DIAGNOSTIC_JSON_LENGTH = 16384;
|
|
128
128
|
const PLAIN_BRACKET_TAG_RE = /^\[[A-Za-z0-9][A-Za-z0-9 _.-]*\]$/u;
|
|
129
129
|
const JSON_ARRAY_START_RE = /\[\s*(?:[{"\d\]-]|true\b|false\b|null\b)/u;
|
|
130
130
|
const MALFORMED_JSON_RE = /\{|(?:"[^"]+"|\b(?:b64_json|data|(?:input|output)?(?:audio|image|video)[\w-]*))\s*:/iu;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./types-
|
|
1
|
+
import { J as StreamOptions } from "./types-Beemor2E.mjs";
|
|
2
|
+
import "./types-COdhCX0U.mjs";
|
|
3
3
|
import OpenAI from "openai";
|
|
4
4
|
import Anthropic from "@anthropic-ai/sdk";
|
|
5
5
|
import { ResponseCreateParamsStreaming } from "openai/resources/responses/responses.js";
|