@openclaw/ai 2026.9.4 → 2026.9.5
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/README.md +1 -1
- package/dist/{anthropic-C4Qu4H0Z.mjs → anthropic-COtDvgtt.mjs} +10 -11
- package/dist/{anthropic-payload-policy-BZ8umAbk.d.mts → anthropic-payload-policy-5Erq1Nzy.d.mts} +3 -3
- package/dist/{anthropic-stream-reducer-CILWF7JD.mjs → anthropic-stream-reducer-BvdYYWL8.mjs} +47 -43
- package/dist/{api-registry-ByUwIR0e.d.mts → api-registry-Ba2Cv-ut.d.mts} +2 -2
- package/dist/{assistant-output-tLt4H-iQ.mjs → assistant-output-BsEkB-vU.mjs} +1 -1
- package/dist/{azure-openai-responses-BAlqlKKc.mjs → azure-openai-responses-YrgnD583.mjs} +6 -9
- package/dist/{base64-D-su8YVo.mjs → base64-BQOzsvUH.mjs} +4 -4
- package/dist/credential-redaction-BKv49aiv.d.mts +24 -0
- package/dist/{diagnostics-QuErwCIl.mjs → diagnostics-Dm4bisWG.mjs} +89 -2
- package/dist/diagnostics.d.mts +4 -23
- package/dist/diagnostics.mjs +3 -3
- package/dist/{event-stream-Bt5Y4Pav.d.mts → event-stream-CCoa-qSI.d.mts} +1 -1
- package/dist/event-stream-DmSCpi1T.d.mts +1 -0
- package/dist/event-stream.d.mts +2 -2
- package/dist/expect-lbe3Hgrh.mjs +8 -0
- package/dist/{google-DPBAOaOW.mjs → google-BuhpRO9r.mjs} +6 -9
- package/dist/{google-messages-6JkpHrhJ.mjs → google-messages-CyWnYlh0.mjs} +3 -3
- package/dist/{google-shared-BvBeW9aq.mjs → google-shared-BT5ZeNer.mjs} +13 -13
- package/dist/{google-vertex-k-TMCAYD.mjs → google-vertex-C7EplRvt.mjs} +5 -8
- package/dist/{host-B8YfDGd4.mjs → host-B4MeUNBc.mjs} +25 -27
- package/dist/{host-4atIX-2V.d.mts → host-FZ1RA_qD.d.mts} +5 -3
- package/dist/{host-policy-Zcg_cNz8.mjs → host-policy-DUnXSx0I.mjs} +1 -1
- package/dist/{index-DdD3qerf.d.mts → index-DaF2QbwS.d.mts} +4 -9
- package/dist/index.d.mts +6 -7
- package/dist/index.mjs +3 -4
- package/dist/internal/anthropic.d.mts +6 -7
- package/dist/internal/anthropic.mjs +4 -4
- package/dist/internal/openai-completions-compat.d.mts +2 -0
- package/dist/internal/openai-completions-compat.mjs +2 -0
- package/dist/internal/openai-responses-payload-policy.d.mts +2 -2
- package/dist/internal/openai-responses-payload-policy.mjs +2 -2
- package/dist/internal/openai.d.mts +10 -53
- package/dist/internal/openai.mjs +11 -9
- package/dist/internal/runtime.d.mts +6 -8
- package/dist/internal/runtime.mjs +5 -9
- package/dist/internal/shared.d.mts +6 -5
- package/dist/internal/shared.mjs +4 -3
- package/dist/internal/tool-schema.d.mts +3 -3
- package/dist/internal/tool-schema.mjs +2 -2
- package/dist/{mistral-CxUZ1jUb.mjs → mistral-moA-mbwl.mjs} +9 -13
- package/dist/{openai-chatgpt-responses-CgO6kZfo.mjs → openai-chatgpt-responses-DWID3EFO.mjs} +73 -29
- package/dist/{openai-completions-yJuk7eis.mjs → openai-completions-DJ1Vm-CD.mjs} +11 -12
- package/dist/{openai-prompt-cache-Bds-n_9Q.mjs → openai-completions-compat-CkwdxTZx.mjs} +5 -50
- package/dist/{openai-completions-compat-eHgh5UPE.d.mts → openai-completions-compat-JE7gqxb9.d.mts} +4 -4
- package/dist/{openai-completions-stream-Da2vvl-S.mjs → openai-completions-stream-Bu98b0Hv.mjs} +94 -96
- package/dist/openai-prompt-cache-1wfaIszn.mjs +46 -0
- package/dist/{openai-prompt-cache-B4eYo2-I.d.mts → openai-prompt-cache-CJ_xEevu.d.mts} +2 -2
- package/dist/{openai-provider-client-S2gCrM2Z.mjs → openai-provider-client-DPo0Hmak.mjs} +2 -2
- package/dist/openai-reasoning-effort-NlFZmfEu.mjs +235 -0
- package/dist/{openai-responses-DaYwH05E.mjs → openai-responses-BejZzQCP.mjs} +8 -12
- package/dist/{openai-responses-compaction-window-CIhBAkkq.mjs → openai-responses-compaction-window-D6P5oZP5.mjs} +20 -62
- package/dist/openai-responses-contracts-DWrfMODE.mjs +81 -0
- package/dist/{openai-responses-contracts-BjBAqAg_.d.mts → openai-responses-contracts-Dflvrfa8.d.mts} +9 -5
- package/dist/{openai-responses-payload-policy-rLRPsSmB.d.mts → openai-responses-payload-policy-C7GsA1y0.d.mts} +5 -3
- package/dist/openai-responses-prompt-observer-internal-C15_-OwV.mjs +195 -0
- package/dist/{openai-responses-shared-B8RdBPCv.mjs → openai-responses-shared-CwsziD_m.mjs} +385 -178
- package/dist/openai-responses-terminal-usage-Dl3J6zrf.d.mts +47 -0
- package/dist/{openai-tool-schema-CzjyYXun.mjs → openai-tool-schema-BO8rwyAD.mjs} +92 -68
- package/dist/{openai-transport-params-9aPuV5YY.mjs → openai-transport-params-DQeuAvBl.mjs} +157 -47
- package/dist/{positive-integer-41zhOdcV.mjs → positive-integer-DtjCkbue.mjs} +1 -1
- package/dist/{provider-error-BA-v_tKd.mjs → provider-error-DDqw9Qda.mjs} +100 -38
- package/dist/{provider-options-Ceqv1OKk.d.mts → provider-options-DprLsWh9.d.mts} +9 -6
- package/dist/{provider-replay-context-CJ_YvcEW.mjs → provider-replay-context-CnUSOwhr.mjs} +1 -1
- package/dist/{provider-transcript-transform-V5YzU9zh.mjs → provider-transcript-transform-BsRAhuWJ.mjs} +1 -1
- package/dist/{provider-transport-turn-state-D5EXOFL2.mjs → provider-transport-turn-state-CkGToCD2.mjs} +1 -1
- package/dist/{provider-types-CVjKjsuq.d.mts → provider-types-CAKRC7N5.d.mts} +3 -3
- package/dist/provider-types.d.mts +5 -6
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +10 -10
- package/dist/{reasoning-tag-text-partitioner-BcR5pztD.mjs → reasoning-tag-text-partitioner-Dy9IO8Dc.mjs} +15 -7
- package/dist/{simple-options-BQbb4yQL.mjs → simple-options-C6cFWj_f.mjs} +5 -3
- package/dist/{usage-cost-BNWbbXav.mjs → src-DeKjbE8I.mjs} +3 -5
- package/dist/{stream-first-event-timeout-2hfrquuz.mjs → stream-first-event-timeout-C9ZadkJW.mjs} +1 -1
- package/dist/{string-normalization-CmLIasuf.mjs → string-normalization-J9ZiLfGO.mjs} +13 -1
- package/dist/tool-schema-json-projection-CD9c_fK8.mjs +134 -0
- package/dist/{transport-stream-shared-DNvmoWnv.d.mts → transport-stream-shared-BbUkFaHi.d.mts} +4 -4
- package/dist/{transport-stream-shared-zHll9BxO.mjs → transport-stream-shared-D-6FQSHm.mjs} +14 -14
- package/dist/{transport-utils-zrYjICLZ.mjs → transport-utils-1cyq5Y7x.mjs} +3 -3
- package/dist/transports.d.mts +26 -12
- package/dist/transports.mjs +130 -449
- package/dist/{types-Ntv5z2g2.d.mts → types-4_uVs5WH.d.mts} +47 -3
- package/dist/types-DkJfb4W3.d.mts +1 -0
- package/dist/types.d.mts +5 -6
- package/dist/types.mjs +2 -3
- package/dist/{validation-B0t_G2H6.d.mts → validation-Ctzu2DhF.d.mts} +1 -1
- package/dist/{validation-BDzVDnTs.mjs → validation-Dw7cb6BV.mjs} +1 -0
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +10 -5
- package/dist/diagnostics-DnPnOui6.d.mts +0 -29
- package/dist/event-stream-C3WGFsum.d.mts +0 -1
- package/dist/openai-responses-contracts-DDOHA62Y.mjs +0 -245
- package/dist/openai-responses-prompt-observer-internal-f8J7wpsk.mjs +0 -32
- package/dist/src-DDmEryvj.mjs +0 -2
- package/dist/tool-schema-json-projection-ClptDdAO.mjs +0 -82
- package/dist/types-DlfwzH3T.d.mts +0 -1
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { D as Message, G as SimpleStreamOptions, O as Model, Q as ThinkingBudgets, Y as StreamOptions, a as AssistantMessage, et as ThinkingLevel, n as Api } from "../types-
|
|
2
|
-
import { a as readAssistantThinkingAppend } from "../event-stream-
|
|
3
|
-
import "../types-
|
|
1
|
+
import { D as Message, G as SimpleStreamOptions, O as Model, Q as ThinkingBudgets, Y as StreamOptions, a as AssistantMessage, et as ThinkingLevel, n as Api } from "../types-4_uVs5WH.mjs";
|
|
2
|
+
import { a as readAssistantThinkingAppend } from "../event-stream-CCoa-qSI.mjs";
|
|
3
|
+
import "../types-DkJfb4W3.mjs";
|
|
4
4
|
import { t as sanitizeSurrogates } from "../sanitize-unicode-BZiVbGwK.mjs";
|
|
5
|
+
import { n as createDiagnosticRecord } from "../credential-redaction-BKv49aiv.mjs";
|
|
5
6
|
import { n as normalizeStructuredPromptSection, r as sortPromptCacheToolsByName, t as normalizePromptCapabilityIds } from "../prompt-cache-stability-Cwcjv_fx.mjs";
|
|
6
7
|
//#region packages/ai/src/providers/simple-options.d.ts
|
|
7
8
|
type FirstEventStreamOptions = {
|
|
8
9
|
firstEventTimeoutMs?: number;
|
|
9
10
|
onFirstEventTimeout?: (reason: Error) => void;
|
|
10
11
|
};
|
|
11
|
-
export declare function buildBaseOptions(model: Model, options?: SimpleStreamOptions, apiKey?: string): StreamOptions & FirstEventStreamOptions
|
|
12
|
+
export declare function buildBaseOptions(model: Model, options?: SimpleStreamOptions, apiKey?: string): StreamOptions & FirstEventStreamOptions & Pick<SimpleStreamOptions, "serviceTier">;
|
|
12
13
|
export declare function clampMaxTokensToModel(model: Model, requestedMaxTokens: number): number;
|
|
13
14
|
export declare function clampMaxTokensToModel(model: Model, requestedMaxTokens: number | undefined): number | undefined;
|
|
14
15
|
export declare function clampReasoning(effort: ThinkingLevel): Exclude<ThinkingLevel, "xhigh">;
|
|
@@ -111,4 +112,4 @@ export declare function projectCopilotRequestFacts(messages: readonly {
|
|
|
111
112
|
hasImages: boolean;
|
|
112
113
|
};
|
|
113
114
|
//#endregion
|
|
114
|
-
export { normalizePromptCapabilityIds, normalizeStructuredPromptSection, readAssistantThinkingAppend, sanitizeSurrogates, sortPromptCacheToolsByName };
|
|
115
|
+
export { createDiagnosticRecord, normalizePromptCapabilityIds, normalizeStructuredPromptSection, readAssistantThinkingAppend, sanitizeSurrogates, sortPromptCacheToolsByName };
|
package/dist/internal/shared.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { o as readAssistantThinkingAppend } from "../event-stream-D8PARQfL.mjs";
|
|
2
|
-
import { _ as isImageWithMediaPayload, a as FAILED_ASSISTANT_REPLAY_TEXT, c as isReasoningOnlyLengthAssistantTurn, d as describeToolResultMediaPlaceholder, f as describeUnsupportedToolResultMedia, g as hasMediaPayload, h as formatToolResultText, i as transformMessages, l as isStreamErrorFallbackContent, m as extractToolResultText, o as STREAM_ERROR_FALLBACK_TEXT, p as extractToolResultBlockText, s as hasOnlyAssistantReasoningContent, u as resolveFailedAssistantReplay, v as sanitizeSurrogates } from "../host-
|
|
3
|
-
import {
|
|
2
|
+
import { _ as isImageWithMediaPayload, a as FAILED_ASSISTANT_REPLAY_TEXT, c as isReasoningOnlyLengthAssistantTurn, d as describeToolResultMediaPlaceholder, f as describeUnsupportedToolResultMedia, g as hasMediaPayload, h as formatToolResultText, i as transformMessages, l as isStreamErrorFallbackContent, m as extractToolResultText, o as STREAM_ERROR_FALLBACK_TEXT, p as extractToolResultBlockText, s as hasOnlyAssistantReasoningContent, u as resolveFailedAssistantReplay, v as sanitizeSurrogates } from "../host-B4MeUNBc.mjs";
|
|
3
|
+
import { r as createDiagnosticRecord } from "../provider-error-DDqw9Qda.mjs";
|
|
4
|
+
import { _ as normalizeStructuredPromptSection, c as SYSTEM_PROMPT_RELOCATABLE_BOUNDARY, d as prependSystemPromptAdditionAfterCacheBoundary, f as splitSystemPromptCacheBoundary, g as normalizePromptCapabilityIds, h as stripSystemPromptRelocatableBoundary, i as clampReasoning, l as SYSTEM_PROMPT_RELOCATABLE_BOUNDARY_END, m as stripSystemPromptCacheBoundary, n as buildBaseOptions, p as splitSystemPromptRelocatableBoundary, r as clampMaxTokensToModel, s as SYSTEM_PROMPT_CACHE_BOUNDARY, t as adjustMaxTokensForThinking, u as ensureSystemPromptCacheBoundary, v as sortPromptCacheToolsByName } from "../simple-options-C6cFWj_f.mjs";
|
|
4
5
|
import { t as projectCopilotRequestFacts } from "../github-copilot-request-facts-BTEBMeOv.mjs";
|
|
5
6
|
//#region packages/ai/src/utils/tls-certificate-errors.ts
|
|
6
7
|
const HOSTNAME_MISMATCH_CODES = /* @__PURE__ */ new Set(["ERR_TLS_CERT_ALTNAME_INVALID", "HOSTNAME_MISMATCH"]);
|
|
@@ -94,4 +95,4 @@ function inspectTlsCertificateError(error) {
|
|
|
94
95
|
return inspectTlsCertificateErrorInternal(error, /* @__PURE__ */ new Set(), 0);
|
|
95
96
|
}
|
|
96
97
|
//#endregion
|
|
97
|
-
export { FAILED_ASSISTANT_REPLAY_TEXT, STREAM_ERROR_FALLBACK_TEXT, SYSTEM_PROMPT_CACHE_BOUNDARY, SYSTEM_PROMPT_RELOCATABLE_BOUNDARY, SYSTEM_PROMPT_RELOCATABLE_BOUNDARY_END, adjustMaxTokensForThinking, buildBaseOptions, clampMaxTokensToModel, clampReasoning, describeToolResultMediaPlaceholder, describeUnsupportedToolResultMedia, ensureSystemPromptCacheBoundary, extractToolResultBlockText, extractToolResultText, formatToolResultText, hasMediaPayload, hasOnlyAssistantReasoningContent, inspectTlsCertificateError, isImageWithMediaPayload, isReasoningOnlyLengthAssistantTurn, isStreamErrorFallbackContent, normalizePromptCapabilityIds, normalizeStructuredPromptSection, prependSystemPromptAdditionAfterCacheBoundary, projectCopilotRequestFacts, readAssistantThinkingAppend, resolveFailedAssistantReplay, sanitizeSurrogates, sortPromptCacheToolsByName, splitSystemPromptCacheBoundary, splitSystemPromptRelocatableBoundary, stripSystemPromptCacheBoundary, stripSystemPromptRelocatableBoundary, transformMessages };
|
|
98
|
+
export { FAILED_ASSISTANT_REPLAY_TEXT, STREAM_ERROR_FALLBACK_TEXT, SYSTEM_PROMPT_CACHE_BOUNDARY, SYSTEM_PROMPT_RELOCATABLE_BOUNDARY, SYSTEM_PROMPT_RELOCATABLE_BOUNDARY_END, adjustMaxTokensForThinking, buildBaseOptions, clampMaxTokensToModel, clampReasoning, createDiagnosticRecord, describeToolResultMediaPlaceholder, describeUnsupportedToolResultMedia, ensureSystemPromptCacheBoundary, extractToolResultBlockText, extractToolResultText, formatToolResultText, hasMediaPayload, hasOnlyAssistantReasoningContent, inspectTlsCertificateError, isImageWithMediaPayload, isReasoningOnlyLengthAssistantTurn, isStreamErrorFallbackContent, normalizePromptCapabilityIds, normalizeStructuredPromptSection, prependSystemPromptAdditionAfterCacheBoundary, projectCopilotRequestFacts, readAssistantThinkingAppend, resolveFailedAssistantReplay, sanitizeSurrogates, sortPromptCacheToolsByName, splitSystemPromptCacheBoundary, splitSystemPromptRelocatableBoundary, stripSystemPromptCacheBoundary, stripSystemPromptRelocatableBoundary, transformMessages };
|
|
@@ -49,15 +49,15 @@ export declare function stripUnsupportedSchemaKeywords(schema: unknown, unsuppor
|
|
|
49
49
|
//#endregion
|
|
50
50
|
//#region packages/ai/src/providers/tool-schema-json-projection.d.ts
|
|
51
51
|
/** JSON-safe schema value used when projecting runtime tool parameters. */
|
|
52
|
-
|
|
52
|
+
type RuntimeToolInputSchemaJson = null | boolean | number | string | RuntimeToolInputSchemaJson[] | {
|
|
53
53
|
[key: string]: RuntimeToolInputSchemaJson;
|
|
54
54
|
};
|
|
55
55
|
/** Projected runtime tool schema plus validation violations. */
|
|
56
|
-
|
|
56
|
+
type RuntimeToolInputSchemaProjection = {
|
|
57
57
|
readonly schema: RuntimeToolInputSchemaJson;
|
|
58
58
|
readonly violations: readonly string[];
|
|
59
59
|
};
|
|
60
60
|
/** Projects one runtime tool input schema to JSON and reports runtime incompatibilities. */
|
|
61
61
|
export declare function projectRuntimeToolInputSchema(schema: unknown, path?: string): RuntimeToolInputSchemaProjection;
|
|
62
62
|
//#endregion
|
|
63
|
-
export { findOpenAIStrictSchemaViolations, findOpenAIStrictToolProjectionDiagnostics, isStrictOpenAIJsonSchemaCompatible, normalizeOpenAIStrictCompatSchema, normalizeOpenAIStrictToolParameters, normalizeStrictOpenAIJsonSchema, resolveOpenAIProjectedToolsStrictToolFlag };
|
|
63
|
+
export { type RuntimeToolInputSchemaJson, type RuntimeToolInputSchemaProjection, findOpenAIStrictSchemaViolations, findOpenAIStrictToolProjectionDiagnostics, isStrictOpenAIJsonSchemaCompatible, normalizeOpenAIStrictCompatSchema, normalizeOpenAIStrictToolParameters, normalizeStrictOpenAIJsonSchema, resolveOpenAIProjectedToolsStrictToolFlag };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _ as
|
|
1
|
+
import { n as projectRuntimeToolInputSchema } from "../tool-schema-json-projection-CD9c_fK8.mjs";
|
|
2
|
+
import { _ as GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS, a as resolveOpenAIProjectedToolsStrictToolFlag, c as extractToolSchemaModelCompat, d as shouldOmitEmptyArrayItems, g as findLlamacppGbnfSchemaViolations, h as cleanSchemaForLlamacppGbnf, i as normalizeStrictOpenAIJsonSchema, l as normalizeToolParameterSchema, m as LLAMACPP_GBNF_MAX_REPETITION_THRESHOLD, n as isStrictOpenAIJsonSchemaCompatible, o as findOpenAIStrictSchemaViolations, p as stripUnsupportedSchemaKeywords, r as normalizeOpenAIStrictToolParameters, s as normalizeOpenAIStrictCompatSchema, t as findOpenAIStrictToolProjectionDiagnostics, u as resolveUnsupportedToolSchemaKeywords, v as cleanSchemaForGemini } from "../openai-tool-schema-BO8rwyAD.mjs";
|
|
3
3
|
export { GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS, LLAMACPP_GBNF_MAX_REPETITION_THRESHOLD, cleanSchemaForGemini, cleanSchemaForLlamacppGbnf, extractToolSchemaModelCompat, findLlamacppGbnfSchemaViolations, findOpenAIStrictSchemaViolations, findOpenAIStrictToolProjectionDiagnostics, isStrictOpenAIJsonSchemaCompatible, normalizeOpenAIStrictCompatSchema, normalizeOpenAIStrictToolParameters, normalizeStrictOpenAIJsonSchema, normalizeToolParameterSchema, projectRuntimeToolInputSchema, resolveOpenAIProjectedToolsStrictToolFlag, resolveUnsupportedToolSchemaKeywords, shouldOmitEmptyArrayItems, stripUnsupportedSchemaKeywords };
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { r as appendAssistantThinking, t as AssistantMessageEventStream } from "./event-stream-D8PARQfL.mjs";
|
|
2
|
-
import { M as clampThinkingLevel, _ as isImageWithMediaPayload, d as describeToolResultMediaPlaceholder, h as formatToolResultText, j as calculateCost, m as extractToolResultText, n as getAiTransportHost, v as sanitizeSurrogates } from "./host-
|
|
3
|
-
import { m as stripSystemPromptCacheBoundary, n as buildBaseOptions, r as clampMaxTokensToModel, v as sortPromptCacheToolsByName } from "./simple-options-
|
|
2
|
+
import { M as clampThinkingLevel, _ as isImageWithMediaPayload, d as describeToolResultMediaPlaceholder, h as formatToolResultText, j as calculateCost, m as extractToolResultText, n as getAiTransportHost, v as sanitizeSurrogates } from "./host-B4MeUNBc.mjs";
|
|
3
|
+
import { m as stripSystemPromptCacheBoundary, n as buildBaseOptions, r as clampMaxTokensToModel, v as sortPromptCacheToolsByName } from "./simple-options-C6cFWj_f.mjs";
|
|
4
4
|
import { n as getEnvApiKey } from "./env-api-keys-bktO00EJ.mjs";
|
|
5
|
-
import { E as parseStreamingJson, c as finalizeTerminalToolCallArguments, k as shortHash, n as assignTransportErrorDetails, p as notifyProviderHttpResponse, v as transportAbortError, w as createToolArgumentPreviewSchedule } from "./transport-stream-shared-
|
|
5
|
+
import { E as parseStreamingJson, c as finalizeTerminalToolCallArguments, k as shortHash, n as assignTransportErrorDetails, p as notifyProviderHttpResponse, v as transportAbortError, w as createToolArgumentPreviewSchedule } from "./transport-stream-shared-D-6FQSHm.mjs";
|
|
6
6
|
import { t as notifyLlmRequestActivity } from "./llm-request-activity-BjtkplhG.mjs";
|
|
7
|
-
import { t as createAssistantOutput } from "./assistant-output-
|
|
8
|
-
import { t as transformProviderMessages } from "./provider-transcript-transform-
|
|
7
|
+
import { t as createAssistantOutput } from "./assistant-output-BsEkB-vU.mjs";
|
|
8
|
+
import { t as transformProviderMessages } from "./provider-transcript-transform-BsRAhuWJ.mjs";
|
|
9
9
|
import { t as mapOpenAIStopReason } from "./openai-stop-reason-Drnn_6Qj.mjs";
|
|
10
10
|
import { t as createSseByteGuard } from "./streaming-byte-guard-CC-HMn_u.mjs";
|
|
11
11
|
import { randomUUID } from "node:crypto";
|
|
12
12
|
import { HTTPClient } from "@mistralai/mistralai/lib/http";
|
|
13
|
+
import { ReasoningEffort$inboundSchema } from "@mistralai/mistralai/models/components/reasoningeffort.js";
|
|
13
14
|
import { Chat } from "@mistralai/mistralai/sdk/chat";
|
|
14
15
|
//#region packages/ai/src/providers/mistral.ts
|
|
15
16
|
const MISTRAL_TOOL_CALL_ID_LENGTH = 9;
|
|
@@ -143,10 +144,11 @@ const streamSimpleMistral = (model, context, options) => {
|
|
|
143
144
|
const clampedReasoning = options?.reasoning ? clampThinkingLevel(model, options.reasoning) : void 0;
|
|
144
145
|
const reasoning = clampedReasoning === "off" ? void 0 : clampedReasoning;
|
|
145
146
|
const shouldUseReasoning = model.reasoning && reasoning !== void 0;
|
|
147
|
+
const supportsReasoningEffort = usesReasoningEffort(model);
|
|
146
148
|
return streamMistral(model, context, {
|
|
147
149
|
...base,
|
|
148
|
-
promptMode: shouldUseReasoning &&
|
|
149
|
-
reasoningEffort: shouldUseReasoning &&
|
|
150
|
+
promptMode: shouldUseReasoning && !supportsReasoningEffort ? "reasoning" : void 0,
|
|
151
|
+
reasoningEffort: shouldUseReasoning && supportsReasoningEffort ? ReasoningEffort$inboundSchema.parse(model.thinkingLevelMap?.[reasoning] ?? (reasoning === "minimal" ? "none" : "high")) : void 0
|
|
150
152
|
});
|
|
151
153
|
};
|
|
152
154
|
function createMistralToolCallIdNormalizer() {
|
|
@@ -628,12 +630,6 @@ function toChatMessages(messages, supportsImages) {
|
|
|
628
630
|
function usesReasoningEffort(model) {
|
|
629
631
|
return model.id === "mistral-small-2603" || model.id === "mistral-small-latest" || model.id === "mistral-medium-3-5";
|
|
630
632
|
}
|
|
631
|
-
function usesPromptModeReasoning(model) {
|
|
632
|
-
return model.reasoning && !usesReasoningEffort(model);
|
|
633
|
-
}
|
|
634
|
-
function mapReasoningEffort(model, level) {
|
|
635
|
-
return model.thinkingLevelMap?.[level] ?? "high";
|
|
636
|
-
}
|
|
637
633
|
function mapToolChoice(choice, convertedToolNames) {
|
|
638
634
|
if (!choice) return;
|
|
639
635
|
if (convertedToolNames && convertedToolNames.size === 0) {
|
package/dist/{openai-chatgpt-responses-CgO6kZfo.mjs → openai-chatgpt-responses-DWID3EFO.mjs}
RENAMED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { i as formatThrownValue, n as createAssistantMessageDiagnostic, t as appendAssistantMessageDiagnostic } from "./diagnostics-CPeq9F7y.mjs";
|
|
2
2
|
import { t as AssistantMessageEventStream } from "./event-stream-D8PARQfL.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { n as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { u as supportsOpenAITemperature } from "./openai-reasoning-effort-NlFZmfEu.mjs";
|
|
4
|
+
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-B4MeUNBc.mjs";
|
|
5
|
+
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-1wfaIszn.mjs";
|
|
6
|
+
import { m as toErrorObject, o as WEBSOCKET_NON_RETRYABLE_CLOSE_ERROR_CODE, p as extractErrorCodeOrErrno } from "./diagnostics-Dm4bisWG.mjs";
|
|
7
|
+
import { s as resolveTimerTimeoutMs } from "./base64-BQOzsvUH.mjs";
|
|
8
|
+
import { t as MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE } from "./transport-utils-1cyq5Y7x.mjs";
|
|
8
9
|
import { parseRetryAfterHeadersSeconds } from "./internal/retry-after.mjs";
|
|
9
|
-
import { m as stripSystemPromptCacheBoundary, n as buildBaseOptions } from "./simple-options-
|
|
10
|
-
import {
|
|
10
|
+
import { m as stripSystemPromptCacheBoundary, n as buildBaseOptions } from "./simple-options-C6cFWj_f.mjs";
|
|
11
|
+
import { S as createResponseModelTracker, b as createOpenAIProviderAcceptanceHook, g as resolveOpenAISimpleReasoningEffort, h as resolveOpenAIRequestReasoning, x as createOpenAIResponseHook } from "./openai-transport-params-DQeuAvBl.mjs";
|
|
11
12
|
import { n as getEnvApiKey } from "./env-api-keys-bktO00EJ.mjs";
|
|
12
|
-
import { O as headersToRecord, b as withProviderResponseHook, m as notifyProviderStreamOpened, n as assignTransportErrorDetails, v as transportAbortError } from "./transport-stream-shared-
|
|
13
|
-
import { a as withFirstStreamEventTimeout, i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
13
|
+
import { O as headersToRecord, b as withProviderResponseHook, m as notifyProviderStreamOpened, n as assignTransportErrorDetails, v as transportAbortError } from "./transport-stream-shared-D-6FQSHm.mjs";
|
|
14
|
+
import { a as withFirstStreamEventTimeout, i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-C9ZadkJW.mjs";
|
|
15
|
+
import { h as responsesPromptObserver } from "./openai-responses-contracts-DWrfMODE.mjs";
|
|
16
|
+
import { A as resolveNextResponsesEncryptedContentAttempt, E as commitResponsesEncryptedContentAttempt, K as buildOpenAIResponsesReasoningReplayMetadata, O as isInvalidEncryptedContentError, X as suppressOpenAIResponsesCompaction, c as processResponsesStream, i as createResponsesAssistantOutput, j as recordResponsesContextUsage, n as applyResponsesServiceTierPricing, o as convertResponsesToolPayload, r as convertResponsesMessages, u as ResponsesStreamFailure } from "./openai-responses-shared-CwsziD_m.mjs";
|
|
16
17
|
import { t as createSseByteGuard } from "./streaming-byte-guard-CC-HMn_u.mjs";
|
|
17
18
|
import { n as registerSessionResourceCleanup } from "./session-resources-CkR4WWy1.mjs";
|
|
18
|
-
import { t as createResponsesPromptEgressObserver } from "./openai-responses-prompt-observer-internal-
|
|
19
|
+
import { i as resolveOpenAIResponsesTextFormat, t as createResponsesPromptEgressObserver } from "./openai-responses-prompt-observer-internal-C15_-OwV.mjs";
|
|
19
20
|
import { n as resolveOpenAICodexAccountId } from "./openai-chatgpt-jwt-KWcgd0d_.mjs";
|
|
20
21
|
//#region packages/ai/src/providers/openai-chatgpt-responses-protocol.ts
|
|
21
22
|
const OPENAI_CHATGPT_RESPONSES_SUCCESS_BODY_MAX_BYTES = 16777216;
|
|
@@ -190,7 +191,7 @@ const streamOpenAICodexResponses = (model, context, options) => {
|
|
|
190
191
|
websocketStarted = false;
|
|
191
192
|
websocketRequestSent = false;
|
|
192
193
|
try {
|
|
193
|
-
await processWebSocketStream(resolveCodexWebSocketUrl(model.baseUrl), activeAttempt.request, websocketHeaders, output, stream, model, () => {
|
|
194
|
+
const terminal = await processWebSocketStream(resolveCodexWebSocketUrl(model.baseUrl), activeAttempt.request, websocketHeaders, output, stream, model, () => {
|
|
194
195
|
websocketStarted = true;
|
|
195
196
|
}, () => {
|
|
196
197
|
commitSemanticAttempt(activeAttempt);
|
|
@@ -199,6 +200,7 @@ const streamOpenAICodexResponses = (model, context, options) => {
|
|
|
199
200
|
}, options?.signal);
|
|
200
201
|
if (activeSignal?.aborted) throw transportAbortError(activeSignal);
|
|
201
202
|
if (output.stopReason === "aborted" || output.stopReason === "error") throw new CodexApiError(output.errorMessage ?? "An unknown error occurred");
|
|
203
|
+
if (terminal && activeAttempt.kind === "initial") recordResponsesContextUsage(output, model, options, activeAttempt.request, terminal.output, "provider");
|
|
202
204
|
stream.push({
|
|
203
205
|
type: "done",
|
|
204
206
|
reason: output.stopReason,
|
|
@@ -291,7 +293,7 @@ const streamOpenAICodexResponses = (model, context, options) => {
|
|
|
291
293
|
semanticAttempt = nextSemanticAttempt;
|
|
292
294
|
}
|
|
293
295
|
const hookedResponseStream = withProviderResponseHook({
|
|
294
|
-
stream: mapCodexEvents(parseOpenAIChatGptResponsesSse(response)),
|
|
296
|
+
stream: mapCodexEvents(parseOpenAIChatGptResponsesSse(response), response.headers),
|
|
295
297
|
signal: firstEventAbort.signal,
|
|
296
298
|
abort: firstEventAbort.abort,
|
|
297
299
|
hook: createOpenAIProviderAcceptanceHook(options, response, model),
|
|
@@ -300,7 +302,7 @@ const streamOpenAICodexResponses = (model, context, options) => {
|
|
|
300
302
|
partial: output
|
|
301
303
|
})
|
|
302
304
|
});
|
|
303
|
-
await processResponsesStream(hookedResponseStream, output, stream, model, {
|
|
305
|
+
const terminal = await processResponsesStream(hookedResponseStream, output, stream, model, {
|
|
304
306
|
serviceTier: options?.serviceTier,
|
|
305
307
|
firstEventTimeoutMs: getFirstStreamEventTimeoutMs(options),
|
|
306
308
|
abortFirstEventStream: firstEventAbort.abort,
|
|
@@ -315,6 +317,7 @@ const streamOpenAICodexResponses = (model, context, options) => {
|
|
|
315
317
|
});
|
|
316
318
|
if (activeSignal?.aborted) throw transportAbortError(activeSignal);
|
|
317
319
|
if (output.stopReason === "aborted" || output.stopReason === "error") throw new Error(output.errorMessage ?? "An unknown error occurred");
|
|
320
|
+
if (terminal && semanticAttempt.kind === "initial") recordResponsesContextUsage(output, model, options, semanticAttempt.request, terminal.output, "provider");
|
|
318
321
|
stream.push({
|
|
319
322
|
type: "done",
|
|
320
323
|
reason: output.stopReason,
|
|
@@ -325,6 +328,15 @@ const streamOpenAICodexResponses = (model, context, options) => {
|
|
|
325
328
|
const requestTimedOut = isRequestTimeoutError(error, options?.signal, requestTimeoutSignal, requestTimeoutMs) && requestTimeoutMs !== void 0;
|
|
326
329
|
const normalizedError = requestTimedOut && requestTimeoutMs !== void 0 ? formatRequestTimeoutError(requestTimeoutMs, error) : error;
|
|
327
330
|
for (const block of output.content) delete block.partialJson;
|
|
331
|
+
const providerRefusal = readCodexProviderRefusal(normalizedError);
|
|
332
|
+
if (providerRefusal) appendAssistantMessageDiagnostic(output, {
|
|
333
|
+
type: "provider_refusal",
|
|
334
|
+
timestamp: Date.now(),
|
|
335
|
+
details: {
|
|
336
|
+
provider: "openai",
|
|
337
|
+
category: providerRefusal.category
|
|
338
|
+
}
|
|
339
|
+
});
|
|
328
340
|
const terminal = assignTransportErrorDetails(output, normalizedError, options?.signal);
|
|
329
341
|
getAiTransportHost().logWarn("openai-transport", "ChatGPT Responses stream terminated", {
|
|
330
342
|
provider: model.provider,
|
|
@@ -353,7 +365,7 @@ const streamSimpleOpenAICodexResponses = (model, context, options) => {
|
|
|
353
365
|
const resolvedOptions = {
|
|
354
366
|
...buildBaseOptions(model, options, apiKey),
|
|
355
367
|
authProfileId: options?.authProfileId,
|
|
356
|
-
reasoningEffort:
|
|
368
|
+
reasoningEffort: resolveOpenAISimpleReasoningEffort(model, options?.reasoning)
|
|
357
369
|
};
|
|
358
370
|
responsesPromptObserver.copy(options, resolvedOptions);
|
|
359
371
|
return streamOpenAICodexResponses(model, context, resolvedOptions);
|
|
@@ -376,20 +388,24 @@ function buildRequestBody(model, context, options, replayMode = "checkpoint") {
|
|
|
376
388
|
include: ["reasoning.encrypted_content"],
|
|
377
389
|
prompt_cache_key: options?.cacheRetention === "none" ? void 0 : clampOpenAIPromptCacheKey(options?.promptCacheKey ?? options?.sessionId)
|
|
378
390
|
};
|
|
391
|
+
if (options?.responseFormat !== void 0) body.text = {
|
|
392
|
+
...body.text,
|
|
393
|
+
format: resolveOpenAIResponsesTextFormat(options.responseFormat)
|
|
394
|
+
};
|
|
379
395
|
if (options?.temperature !== void 0 && supportsOpenAITemperature(model)) body.temperature = options.temperature;
|
|
380
396
|
if (options?.serviceTier !== void 0) body.service_tier = options.serviceTier;
|
|
381
397
|
if (context.tools) {
|
|
382
|
-
const tools = convertResponsesToolPayload(context.tools, { strict:
|
|
398
|
+
const tools = convertResponsesToolPayload(context.tools, { strict: false });
|
|
383
399
|
if (tools.length > 0) {
|
|
384
400
|
body.tools = tools;
|
|
385
401
|
body.tool_choice = "auto";
|
|
386
402
|
body.parallel_tool_calls = true;
|
|
387
403
|
}
|
|
388
404
|
}
|
|
389
|
-
const effort = options?.reasoningEffort === void 0 ? void 0 :
|
|
405
|
+
const effort = options?.reasoningEffort === void 0 ? void 0 : resolveOpenAIRequestReasoning(model, options.reasoningEffort).effort;
|
|
390
406
|
if (effort !== void 0) body.reasoning = {
|
|
391
407
|
effort,
|
|
392
|
-
summary: options?.reasoningSummary ?? "auto"
|
|
408
|
+
...effort === "none" ? {} : { summary: options?.reasoningSummary ?? "auto" }
|
|
393
409
|
};
|
|
394
410
|
return body;
|
|
395
411
|
}
|
|
@@ -409,6 +425,29 @@ function resolveCodexWebSocketUrl(baseUrl) {
|
|
|
409
425
|
if (url.protocol === "http:") url.protocol = "ws:";
|
|
410
426
|
return url.toString();
|
|
411
427
|
}
|
|
428
|
+
function isJsonRecord(value) {
|
|
429
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Structured refusal code carried by the OpenAI Responses transport. Every
|
|
433
|
+
* terminal Responses path preserves it: a non-OK HTTP body parsed by
|
|
434
|
+
* {@link parseErrorResponse}, an SSE/WebSocket `error` event mapped by
|
|
435
|
+
* {@link extractCodexEventError}, and a `response.failed` event normalized into
|
|
436
|
+
* {@link ResponsesStreamFailure}. Only the app-server surface carries the
|
|
437
|
+
* `codexErrorInfo` discriminator, so both shapes must be read here.
|
|
438
|
+
*/
|
|
439
|
+
const RESPONSES_CYBER_POLICY_ERROR_CODE = "cyber_policy";
|
|
440
|
+
function readCodexProviderRefusal(error) {
|
|
441
|
+
if (error instanceof ResponsesStreamFailure) return error.code === RESPONSES_CYBER_POLICY_ERROR_CODE ? { category: "cyber" } : void 0;
|
|
442
|
+
if (!(error instanceof CodexApiError)) return;
|
|
443
|
+
if (error.code === RESPONSES_CYBER_POLICY_ERROR_CODE) return { category: "cyber" };
|
|
444
|
+
const payload = error.payload;
|
|
445
|
+
const nested = isJsonRecord(payload?.error) ? payload.error : void 0;
|
|
446
|
+
const codexErrorInfo = payload?.codexErrorInfo ?? nested?.codexErrorInfo;
|
|
447
|
+
if (codexErrorInfo === "cyberPolicy") return { category: "cyber" };
|
|
448
|
+
if (codexErrorInfo === "misalignmentPolicyViolation") return { category: "misalignment" };
|
|
449
|
+
return (typeof payload?.message === "string" ? payload.message : typeof nested?.message === "string" ? nested.message : "").startsWith("This content was flagged for possible biological risk.") ? { category: "bio" } : void 0;
|
|
450
|
+
}
|
|
412
451
|
var CodexApiError = class extends Error {
|
|
413
452
|
constructor(message, options) {
|
|
414
453
|
super(message);
|
|
@@ -432,8 +471,11 @@ function extractCodexEventError(event) {
|
|
|
432
471
|
message: typeof event.message === "string" ? event.message : typeof nested?.message === "string" ? nested.message : void 0
|
|
433
472
|
};
|
|
434
473
|
}
|
|
435
|
-
async function* mapCodexEvents(events) {
|
|
474
|
+
async function* mapCodexEvents(events, initialResponseHeaders) {
|
|
475
|
+
const responseModelTracker = createResponseModelTracker();
|
|
476
|
+
responseModelTracker.begin(initialResponseHeaders);
|
|
436
477
|
for await (const event of events) {
|
|
478
|
+
responseModelTracker.observeEvent(event);
|
|
437
479
|
const type = typeof event.type === "string" ? event.type : void 0;
|
|
438
480
|
if (!type) continue;
|
|
439
481
|
if (type === "error") {
|
|
@@ -447,7 +489,8 @@ async function* mapCodexEvents(events) {
|
|
|
447
489
|
const response = event.response;
|
|
448
490
|
const normalizedResponse = response ? {
|
|
449
491
|
...response,
|
|
450
|
-
status: normalizeCodexStatus(response.status)
|
|
492
|
+
status: normalizeCodexStatus(response.status),
|
|
493
|
+
model: responseModelTracker.resolve()
|
|
451
494
|
} : response;
|
|
452
495
|
yield {
|
|
453
496
|
...event,
|
|
@@ -614,11 +657,7 @@ async function acquireWebSocket(url, headers, sessionId, signal) {
|
|
|
614
657
|
const socket = await connectWebSocket(url, headers, signal);
|
|
615
658
|
return {
|
|
616
659
|
socket,
|
|
617
|
-
release: (
|
|
618
|
-
if (keep === false) {
|
|
619
|
-
closeWebSocketSilently(socket);
|
|
620
|
-
return;
|
|
621
|
-
}
|
|
660
|
+
release: () => {
|
|
622
661
|
closeWebSocketSilently(socket);
|
|
623
662
|
}
|
|
624
663
|
};
|
|
@@ -868,7 +907,7 @@ async function processWebSocketStream(url, body, headers, output, stream, model,
|
|
|
868
907
|
...requestBody
|
|
869
908
|
}));
|
|
870
909
|
onRequestSent?.();
|
|
871
|
-
await processResponsesStream(startWebSocketOutputOnFirstEvent(mapCodexEvents(parseWebSocket(socket, options?.signal)), output, stream, onFirstProviderEvent, () => notifyProviderStreamOpened({
|
|
910
|
+
const terminal = await processResponsesStream(startWebSocketOutputOnFirstEvent(mapCodexEvents(parseWebSocket(socket, options?.signal)), output, stream, onFirstProviderEvent, () => notifyProviderStreamOpened({
|
|
872
911
|
options,
|
|
873
912
|
cancelStream: () => {
|
|
874
913
|
keepConnection = false;
|
|
@@ -901,6 +940,7 @@ async function processWebSocketStream(url, body, headers, output, stream, model,
|
|
|
901
940
|
lastResponseItems: responseItems
|
|
902
941
|
};
|
|
903
942
|
}
|
|
943
|
+
return terminal;
|
|
904
944
|
} catch (error) {
|
|
905
945
|
if (entry) entry.continuation = void 0;
|
|
906
946
|
keepConnection = false;
|
|
@@ -963,8 +1003,11 @@ function parseErrorResponse(raw, response) {
|
|
|
963
1003
|
let message = raw || statusText || "Request failed";
|
|
964
1004
|
let friendlyMessage;
|
|
965
1005
|
let code;
|
|
1006
|
+
let payload;
|
|
966
1007
|
try {
|
|
967
|
-
const
|
|
1008
|
+
const parsed = JSON.parse(raw);
|
|
1009
|
+
payload = isJsonRecord(parsed) ? parsed : void 0;
|
|
1010
|
+
const err = parsed?.error;
|
|
968
1011
|
if (err) {
|
|
969
1012
|
code = err.code || err.type || void 0;
|
|
970
1013
|
if (/usage_limit_reached|usage_not_included|rate_limit_exceeded/i.test(code ?? "") || status === 429) {
|
|
@@ -979,7 +1022,8 @@ function parseErrorResponse(raw, response) {
|
|
|
979
1022
|
const retryAfterSuffix = Number.isFinite(retryAfterSeconds) ? `; Retry-After: ${Math.ceil(retryAfterSeconds ?? 0)} seconds` : "";
|
|
980
1023
|
return new CodexApiError(`${friendlyMessage || message}${retryAfterSuffix}`, {
|
|
981
1024
|
code,
|
|
982
|
-
status
|
|
1025
|
+
status,
|
|
1026
|
+
payload
|
|
983
1027
|
});
|
|
984
1028
|
}
|
|
985
1029
|
function extractOpenAICodexAccountId(token) {
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
2
|
import { t as AssistantMessageEventStream } from "./event-stream-D8PARQfL.mjs";
|
|
3
|
-
import { M as clampThinkingLevel } from "./host-
|
|
4
|
-
import {
|
|
3
|
+
import { M as clampThinkingLevel } from "./host-B4MeUNBc.mjs";
|
|
4
|
+
import { i as resolveOpenAICompletionsCompat } from "./openai-completions-compat-CkwdxTZx.mjs";
|
|
5
5
|
import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
|
|
6
|
-
import { n as buildBaseOptions, o as reasoningTagTextPolicy } from "./simple-options-
|
|
7
|
-
import {
|
|
6
|
+
import { n as buildBaseOptions, o as reasoningTagTextPolicy } from "./simple-options-C6cFWj_f.mjs";
|
|
7
|
+
import { C as isOpenAICompletionsThinkingEnabled, b as createOpenAIProviderAcceptanceHook } from "./openai-transport-params-DQeuAvBl.mjs";
|
|
8
8
|
import { n as getEnvApiKey } from "./env-api-keys-bktO00EJ.mjs";
|
|
9
|
-
import { b as withProviderResponseHook, n as assignTransportErrorDetails, v as transportAbortError } from "./transport-stream-shared-
|
|
9
|
+
import { b as withProviderResponseHook, n as assignTransportErrorDetails, v as transportAbortError } from "./transport-stream-shared-D-6FQSHm.mjs";
|
|
10
10
|
import { a as tagUnresolvedTextAsCommentary, t as clearPendingCommentaryText } from "./assistant-text-phase-C20rxWwP.mjs";
|
|
11
|
-
import { t as createAssistantOutput } from "./assistant-output-
|
|
12
|
-
import { a as convertMessages, i as buildOpenAICompletionsRequest, s as finalizeOpenAICompletionsToolCalls, t as processCompletionsStream } from "./openai-completions-stream-
|
|
13
|
-
import { i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-
|
|
14
|
-
import { n as resolveProviderSimpleCompletionHeaders } from "./provider-transport-turn-state-
|
|
11
|
+
import { t as createAssistantOutput } from "./assistant-output-BsEkB-vU.mjs";
|
|
12
|
+
import { a as convertMessages, i as buildOpenAICompletionsRequest, s as finalizeOpenAICompletionsToolCalls, t as processCompletionsStream } from "./openai-completions-stream-Bu98b0Hv.mjs";
|
|
13
|
+
import { i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-C9ZadkJW.mjs";
|
|
14
|
+
import { n as resolveProviderSimpleCompletionHeaders } from "./provider-transport-turn-state-CkGToCD2.mjs";
|
|
15
15
|
import { n as hasCopilotVisionInput, t as buildCopilotDynamicHeaders } from "./github-copilot-headers-B37TB3rB.mjs";
|
|
16
|
-
import { t as createOpenAIProviderClient } from "./openai-provider-client-
|
|
16
|
+
import { t as createOpenAIProviderClient } from "./openai-provider-client-DPo0Hmak.mjs";
|
|
17
17
|
//#region packages/ai/src/providers/openai-completions.ts
|
|
18
18
|
var openai_completions_exports = /* @__PURE__ */ __exportAll({
|
|
19
19
|
convertMessages: () => convertMessages,
|
|
@@ -154,11 +154,10 @@ const streamSimpleOpenAICompletions = (model, context, options) => {
|
|
|
154
154
|
if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
|
|
155
155
|
const base = buildBaseOptions(model, options, apiKey);
|
|
156
156
|
const clampedReasoning = options?.reasoning ? clampThinkingLevel(model, options.reasoning) : void 0;
|
|
157
|
-
const reasoningEffort = clampedReasoning === "off" ? void 0 : clampedReasoning === "max" ? "xhigh" : clampedReasoning;
|
|
158
157
|
const toolChoice = options?.toolChoice;
|
|
159
158
|
return streamOpenAICompletions(model, context, {
|
|
160
159
|
...base,
|
|
161
|
-
reasoningEffort,
|
|
160
|
+
reasoningEffort: clampedReasoning,
|
|
162
161
|
toolChoice
|
|
163
162
|
});
|
|
164
163
|
};
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
2
|
-
import { a as resolveProviderRequestCapabilities } from "./host-policy-
|
|
3
|
-
//#region packages/normalization-core/src/code-points.ts
|
|
4
|
-
/** Truncates to a nonnegative code-point budget; grapheme clusters may be split. */
|
|
5
|
-
function truncateCodePoints(text, maxCodePoints) {
|
|
6
|
-
const limit = Math.max(0, Math.trunc(maxCodePoints) || 0);
|
|
7
|
-
if (text.length <= limit) return text;
|
|
8
|
-
const prefix = [];
|
|
9
|
-
for (const codePoint of text) {
|
|
10
|
-
if (prefix.length >= limit) break;
|
|
11
|
-
prefix.push(codePoint);
|
|
12
|
-
}
|
|
13
|
-
return prefix.join("");
|
|
14
|
-
}
|
|
15
|
-
//#endregion
|
|
2
|
+
import { a as resolveProviderRequestCapabilities } from "./host-policy-DUnXSx0I.mjs";
|
|
16
3
|
//#region packages/ai/src/providers/openai-response-format.ts
|
|
17
4
|
const JSON_SCHEMA_RESPONSE_FORMAT_NAME = "openclaw_response";
|
|
18
5
|
const OLLAMA_CLOUD_ORIGIN = "https://ollama.com";
|
|
@@ -127,9 +114,6 @@ function resolveOpenAICompletionsCompatDefaults(input) {
|
|
|
127
114
|
supportsLongCacheRetention: !isModelStudioLike && provider !== "cloudflare-workers-ai" && provider !== "cloudflare-ai-gateway" && knownProviderFamily !== "together" && !input.baseUrl?.includes("api.cloudflare.com") && !input.baseUrl?.includes("gateway.ai.cloudflare.com") && !input.baseUrl?.includes("api.together.ai") && !input.baseUrl?.includes("api.together.xyz")
|
|
128
115
|
};
|
|
129
116
|
}
|
|
130
|
-
function resolveOpenAICompletionsCompatDefaultsFromCapabilities(input) {
|
|
131
|
-
return resolveOpenAICompletionsCompatDefaults(input);
|
|
132
|
-
}
|
|
133
117
|
/** Detects endpoint capabilities and defaults for an OpenAI-completions model. */
|
|
134
118
|
function detectOpenAICompletionsCompat(model, resolveCapabilities) {
|
|
135
119
|
const capabilities = (resolveCapabilities ?? ((input) => resolveProviderRequestCapabilities(input, model)))({
|
|
@@ -143,7 +127,7 @@ function detectOpenAICompletionsCompat(model, resolveCapabilities) {
|
|
|
143
127
|
});
|
|
144
128
|
return {
|
|
145
129
|
capabilities,
|
|
146
|
-
defaults:
|
|
130
|
+
defaults: resolveOpenAICompletionsCompatDefaults({
|
|
147
131
|
provider: model.provider,
|
|
148
132
|
modelId: model.id,
|
|
149
133
|
baseUrl: model.baseUrl,
|
|
@@ -164,6 +148,8 @@ function resolveOpenAICompletionsCompat(model, resolveCapabilities) {
|
|
|
164
148
|
supportsStore: configured?.supportsStore ?? defaults.supportsStore,
|
|
165
149
|
supportsDeveloperRole: configured?.supportsDeveloperRole ?? defaults.supportsDeveloperRole,
|
|
166
150
|
supportsReasoningEffort: configured?.supportsReasoningEffort ?? defaults.supportsReasoningEffort,
|
|
151
|
+
supportedReasoningEfforts: configured?.supportedReasoningEfforts,
|
|
152
|
+
reasoningEffortMap: configured?.reasoningEffortMap,
|
|
167
153
|
supportsUsageInStreaming: configured?.supportsUsageInStreaming ?? defaults.supportsUsageInStreaming,
|
|
168
154
|
maxTokensField: configured?.maxTokensField ?? defaults.maxTokensField,
|
|
169
155
|
requiresToolResultName: configured?.requiresToolResultName ?? false,
|
|
@@ -186,35 +172,4 @@ function resolveOpenAICompletionsCompat(model, resolveCapabilities) {
|
|
|
186
172
|
};
|
|
187
173
|
}
|
|
188
174
|
//#endregion
|
|
189
|
-
|
|
190
|
-
const EXTENDED_RETENTION_MODELS = /* @__PURE__ */ new Set([
|
|
191
|
-
"gpt-5.5",
|
|
192
|
-
"gpt-5.5-pro",
|
|
193
|
-
"gpt-5.4",
|
|
194
|
-
"gpt-5.2",
|
|
195
|
-
"gpt-5.1-codex-max",
|
|
196
|
-
"gpt-5.1",
|
|
197
|
-
"gpt-5.1-codex",
|
|
198
|
-
"gpt-5.1-codex-mini",
|
|
199
|
-
"gpt-5.1-chat-latest",
|
|
200
|
-
"gpt-5",
|
|
201
|
-
"gpt-5-codex",
|
|
202
|
-
"gpt-4.1"
|
|
203
|
-
]);
|
|
204
|
-
/** Selects documented lifetime fields shared by Responses and Chat Completions. */
|
|
205
|
-
function resolveOpenAIPromptCacheParams(model, cacheRetention, compat) {
|
|
206
|
-
if (cacheRetention !== "long" || !compat.supportsPromptCacheKey || !compat.supportsLongCacheRetention) return {};
|
|
207
|
-
const version = /^gpt-(\d+)(?:\.(\d+))?(?:-|$)/.exec(model.id);
|
|
208
|
-
if (version && (Number(version[1]) > 5 || Number(version[1]) === 5 && Number(version[2]) >= 6)) return { prompt_cache_options: { ttl: "30m" } };
|
|
209
|
-
const modelId = model.id.replace(/-\d{4}-\d{2}-\d{2}$/, "");
|
|
210
|
-
return !isNativeOpenAIEndpoint(model) || EXTENDED_RETENTION_MODELS.has(modelId) ? { prompt_cache_retention: "24h" } : {};
|
|
211
|
-
}
|
|
212
|
-
/** Maximum prompt cache key length accepted by OpenAI-compatible request metadata. */
|
|
213
|
-
const OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH = 64;
|
|
214
|
-
/** Truncates a prompt cache key by Unicode code point count. */
|
|
215
|
-
function clampOpenAIPromptCacheKey(key) {
|
|
216
|
-
if (key === void 0) return;
|
|
217
|
-
return truncateCodePoints(key, 64);
|
|
218
|
-
}
|
|
219
|
-
//#endregion
|
|
220
|
-
export { isNativeOpenAIEndpoint as a, resolveOpenAIPromptCacheKeySupport as c, shouldOmitOllamaCompatResponseFormat as d, detectOpenAICompletionsCompat as i, usesNativeOpenAICodexResponsesBackend as l, clampOpenAIPromptCacheKey as n, isOpenAICodexResponsesModel as o, resolveOpenAIPromptCacheParams as r, resolveOpenAICompletionsCompat as s, OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH as t, resolveOpenAICompletionsResponseFormat as u };
|
|
175
|
+
export { resolveOpenAIPromptCacheKeySupport as a, shouldOmitOllamaCompatResponseFormat as c, resolveOpenAICompletionsCompat as i, isNativeOpenAIEndpoint as n, usesNativeOpenAICodexResponsesBackend as o, isOpenAICodexResponsesModel as r, resolveOpenAICompletionsResponseFormat as s, detectOpenAICompletionsCompat as t };
|
package/dist/{openai-completions-compat-eHgh5UPE.d.mts → openai-completions-compat-JE7gqxb9.d.mts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { M as OpenAICompletionsCompat, O as Model } from "./types-
|
|
3
|
-
import { a as AiProviderRequestPolicyInput, i as AiProviderRequestCapabilities } from "./host-
|
|
1
|
+
import "./index-DaF2QbwS.mjs";
|
|
2
|
+
import { M as OpenAICompletionsCompat, O as Model } from "./types-4_uVs5WH.mjs";
|
|
3
|
+
import { a as AiProviderRequestPolicyInput, i as AiProviderRequestCapabilities } from "./host-FZ1RA_qD.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";
|
|
@@ -24,7 +24,7 @@ type DetectedOpenAICompletionsCompat = {
|
|
|
24
24
|
capabilities: ProviderRequestCapabilities;
|
|
25
25
|
defaults: OpenAICompletionsCompatDefaults;
|
|
26
26
|
};
|
|
27
|
-
type ResolvedOpenAICompletionsCompat = Omit<Required<OpenAICompletionsCompat>, "cacheControlFormat" | "openRouterRouting" | "sendSessionAffinityHeaders" | "reasoningEffortMap"> & {
|
|
27
|
+
type ResolvedOpenAICompletionsCompat = Omit<Required<OpenAICompletionsCompat>, "cacheControlFormat" | "openRouterRouting" | "sendSessionAffinityHeaders" | "reasoningEffortMap" | "supportedReasoningEfforts"> & Pick<OpenAICompletionsCompat, "reasoningEffortMap" | "supportedReasoningEfforts"> & {
|
|
28
28
|
cacheControlFormat?: OpenAICompletionsCompat["cacheControlFormat"];
|
|
29
29
|
openRouterRouting?: OpenAICompletionsCompat["openRouterRouting"];
|
|
30
30
|
sessionAffinity: OpenAICompletionsSessionAffinity;
|