@openclaw/ai 2026.10.5-beta.4 → 2026.10.10-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/dist/{anthropic-BalhAzs-.mjs → anthropic-D6spfBri.mjs} +16 -18
- package/dist/{anthropic-payload-policy-DGblkHL5.d.mts → anthropic-payload-policy-Cr8xjazC.d.mts} +6 -3
- package/dist/{anthropic-stream-reducer-DkKeXXx4.mjs → anthropic-stream-reducer-CzPXOaLM.mjs} +59 -226
- package/dist/anthropic-tool-projection-BdAS3rtJ.mjs +165 -0
- package/dist/anthropic-tool-projection-DKH-aEWU.d.mts +51 -0
- package/dist/{api-registry-BhXXYdRA.d.mts → api-registry-gDt0faai.d.mts} +2 -2
- package/dist/{assistant-output-BuhRpLeD.mjs → assistant-output-6iFA1nbC.mjs} +2 -2
- package/dist/{azure-openai-responses-DfT9Ndd8.mjs → azure-openai-responses-0TqHwnlD.mjs} +8 -8
- package/dist/{cloudflare-5qSGvIUH.mjs → cloudflare-Dttf8jKq.mjs} +1 -1
- package/dist/{credential-redaction-BHxruEH6.d.mts → credential-redaction-XvsPf7Yi.d.mts} +1 -0
- package/dist/{diagnostics-tQasYct1.mjs → diagnostics-Cv7cW3pS.mjs} +3 -3
- package/dist/diagnostics.d.mts +6 -6
- package/dist/diagnostics.mjs +2 -2
- package/dist/{env-api-keys-CrxwdylR.mjs → env-api-keys-Xd8dm_aV.mjs} +10 -34
- package/dist/event-stream-CDpFza-M.d.mts +1 -0
- package/dist/{event-stream-BcqWLo_u.d.mts → event-stream-CzpE1g_o.d.mts} +1 -1
- package/dist/event-stream.d.mts +2 -2
- package/dist/{github-copilot-request-facts-DEE6gcB9.mjs → github-copilot-request-facts-F-EmvkpW.mjs} +1 -1
- package/dist/{google-interactions-9SSqsJg9.mjs → google-interactions-CTEBy9od.mjs} +19 -37
- package/dist/{google-messages-DsB7fmoQ.mjs → google-messages-DfpHVTaD.mjs} +18 -6
- package/dist/{google-provider-stream-CcEI2-MC.mjs → google-provider-stream-DJ8ANfsS.mjs} +6 -6
- package/dist/{google-shared-zGR0QUyS.mjs → google-shared-VTcCJLW3.mjs} +28 -41
- package/dist/{google-vertex-Dw_abY1w.mjs → google-vertex-Bkfizj7M.mjs} +3 -3
- package/dist/{google-sYI2wnY6.mjs → google-zWpkDSeN.mjs} +4 -4
- package/dist/{host-Bf3NjYNj.mjs → host-B2gk-d1H.mjs} +5 -11
- package/dist/{host-CTDz7LXD.d.mts → host-jJOffdlW.d.mts} +4 -6
- package/dist/{host-policy-BzZluO6_.mjs → host-policy-mpqGhbeM.mjs} +1 -1
- package/dist/{index-BYDvopUB.d.mts → index-DSprYWaz.d.mts} +7 -5
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +6 -6
- package/dist/internal/anthropic.d.mts +7 -53
- package/dist/internal/anthropic.mjs +6 -5
- package/dist/internal/google-model-family.d.mts +2 -0
- package/dist/internal/google-model-family.mjs +7 -3
- package/dist/internal/openai-completions-compat.d.mts +1 -1
- package/dist/internal/openai-completions-compat.mjs +1 -1
- package/dist/internal/openai-responses-payload-policy.d.mts +3 -3
- package/dist/internal/openai-responses-payload-policy.mjs +3 -3
- package/dist/internal/openai.d.mts +17 -26
- package/dist/internal/openai.mjs +10 -10
- package/dist/internal/retry-after.d.mts +1 -1
- package/dist/internal/retry-after.mjs +80 -55
- package/dist/internal/runtime.d.mts +9 -31
- package/dist/internal/runtime.mjs +10 -116
- package/dist/internal/shared.d.mts +9 -7
- package/dist/internal/shared.mjs +8 -6
- package/dist/internal/tool-schema.d.mts +83 -5
- package/dist/internal/tool-schema.mjs +4 -3
- package/dist/{mistral-dCDCR5ur.mjs → mistral-CATJrwne.mjs} +32 -35
- package/dist/model-request-body-BD5vy4rP.d.mts +17 -0
- package/dist/{number-coercion-C3hztWoY.mjs → number-coercion-37gmNkuA.mjs} +1 -1
- package/dist/{openai-chatgpt-responses-BHI3uCcA.mjs → openai-chatgpt-responses-CtdnpWwe.mjs} +95 -63
- package/dist/{openai-completions-CrVgnFrV.mjs → openai-completions-B6sET3oI.mjs} +10 -8
- package/dist/{openai-completions-compat-i-nLZxFy.d.mts → openai-completions-compat-1gsjP-KO.d.mts} +6 -3
- package/dist/{openai-completions-compat-CYX18uDk.mjs → openai-completions-compat-CFhQ3UVU.mjs} +7 -2
- package/dist/{openai-completions-transport-Dy4CZo9Q.mjs → openai-completions-transport-DviPEqw3.mjs} +370 -237
- package/dist/{openai-prompt-cache-r93BJhjm.mjs → openai-prompt-cache-DJ_P143P.mjs} +1 -1
- package/dist/{openai-prompt-cache-DIPMrMFy.d.mts → openai-prompt-cache-DgjD-UL5.d.mts} +2 -2
- package/dist/{openai-responses-D5oiAUOG.mjs → openai-responses-BXsJK-mD.mjs} +13 -15
- package/dist/{openai-responses-compaction-replay-B2FE4Nw8.d.mts → openai-responses-compaction-replay-Cvnl_nCq.d.mts} +5 -5
- package/dist/{openai-responses-contracts-DlKMMTxK.mjs → openai-responses-contracts-Bx-16mnf.mjs} +45 -6
- package/dist/{openai-responses-contracts-DKqMJ1Ct.d.mts → openai-responses-contracts-CQ4_AWjL.d.mts} +20 -8
- package/dist/{openai-responses-endpoint-CinGh4VZ.mjs → openai-responses-endpoint-D4v-eeYy.mjs} +55 -22
- package/dist/{openai-responses-payload-policy-C7GsA1y0.d.mts → openai-responses-payload-policy-BzM52TTH.d.mts} +9 -3
- package/dist/openai-responses-request-lifecycle-CTdAb2v1.mjs +246 -0
- package/dist/{openai-responses-shared-D-aDYAkJ.mjs → openai-responses-shared-Bv_1NtH9.mjs} +284 -160
- package/dist/{openai-responses-terminal-usage-BygjiAdi.d.mts → openai-responses-terminal-usage-CpVjkqn-.d.mts} +2 -2
- package/dist/{openai-tool-schema-DDPXsvJP.mjs → openai-tool-schema-Buv0GXFb.mjs} +170 -237
- package/dist/overflow-DJHXTNBQ.mjs +117 -0
- package/dist/{positive-integer-CqWjqSi9.mjs → positive-integer-Bb4Evc7L.mjs} +1 -1
- package/dist/prompt-cache-stability-D_MeCQFI.mjs +32 -0
- package/dist/{provider-error-xumb1V3F.d.mts → provider-error-CnaWYTRY.d.mts} +1 -0
- package/dist/{provider-error-CF9GWCs2.mjs → provider-error-qtZD2inE.mjs} +75 -13
- package/dist/{provider-options-CVrXZBtA.d.mts → provider-options-DeYeaflL.d.mts} +52 -6
- package/dist/{text-signature-Drb4Erb8.mjs → provider-replay-context-J6CfU3m1.mjs} +5 -14
- package/dist/{provider-transport-turn-state-BOpxgm-J.mjs → provider-transport-turn-state-Jxppzuc2.mjs} +5 -5
- package/dist/{provider-types-CHtRx0dI.d.mts → provider-types-ODq57rG_.d.mts} +3 -3
- package/dist/provider-types.d.mts +6 -6
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +11 -11
- package/dist/{reasoning-tag-text-partitioner-CpOy9-IQ.mjs → reasoning-tag-text-partitioner-DzlRubwU.mjs} +134 -47
- package/dist/{required-api-key-CFJvcFy_.mjs → required-api-key-D088S4Cd.mjs} +1 -1
- package/dist/{retry-after-CdCURCVg.d.mts → retry-after-sw-XX8aC.d.mts} +1 -1
- package/dist/sanitize-unicode-CRGuMONI.mjs +8 -0
- package/dist/sanitize-unicode-ZqVLLEKC.d.mts +27 -0
- package/dist/{session-resources-D1wgDQ8C.mjs → session-resources-vKvGIE3J.mjs} +1 -10
- package/dist/{simple-options-BAu4B54D.mjs → simple-options-BYgC6kse.mjs} +68 -79
- package/dist/{src-C44MKrW5.mjs → src-CyA0zJnt.mjs} +6 -2
- package/dist/{stream-Dd8DwRFL.mjs → stream-DLBirT0e.mjs} +8 -47
- package/dist/{stream-first-event-timeout-Dc42hKv6.mjs → stream-first-event-timeout-D_TfJHRJ.mjs} +1 -1
- package/dist/{string-coerce-CtgOVOSv.mjs → string-coerce-Cj8sqWHx.mjs} +26 -1
- package/dist/tool-schema-json-projection-B0hHDV7N.mjs +492 -0
- package/dist/{transport-stream-shared-BmpzDtdQ.d.mts → transport-stream-shared-8ru8eX4s.d.mts} +5 -5
- package/dist/{transport-stream-shared-CWGOuLcA.mjs → transport-stream-shared-CzQlAzJH.mjs} +27 -75
- package/dist/transports.d.mts +34 -28
- package/dist/transports.mjs +42 -48
- package/dist/{types-CQc6JNG4.mjs → types-BXd0kI8-.mjs} +1 -1
- package/dist/types-CBJthzJX.d.mts +1 -0
- package/dist/{types-Bd2T86VJ.d.mts → types-CVYzKrMl.d.mts} +20 -3
- package/dist/types.d.mts +6 -6
- package/dist/types.mjs +4 -4
- package/dist/{validation-ZX_sPVV0.mjs → validation-9FSkE8T-.mjs} +22 -3
- package/dist/{validation-DdGB1yy3.d.mts → validation-BQ5u20Ru.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +3 -3
- package/dist/assistant-text-phase-Bn1hbvK9.mjs +0 -50
- package/dist/event-stream-6UNs-AhN.d.mts +0 -1
- package/dist/expect-lbe3Hgrh.mjs +0 -8
- package/dist/json-schema-Bp07Qui3.mjs +0 -22
- package/dist/openai-responses-request-lifecycle-NSIJo9jY.mjs +0 -67
- package/dist/openai-tool-projection-793cE3QX.d.mts +0 -37
- package/dist/openai-tool-schema-a5ysBBga.d.mts +0 -32
- package/dist/rolldown-runtime-BhDjJH2R.mjs +0 -15
- package/dist/sanitize-unicode-CjDG6jJx.d.mts +0 -5
- package/dist/string-normalization-I3ux50s9.mjs +0 -28
- package/dist/tool-schema-json-projection-B8sG1I9v.mjs +0 -180
- package/dist/types-Kdfw_04V.d.mts +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import "../index-
|
|
2
|
-
import { $ as StopReason, Q as SimpleStreamOptions, d as Context, k as Model, tt as StreamFunction } from "../types-
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import "../
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { n as
|
|
9
|
-
import
|
|
10
|
-
import "../
|
|
1
|
+
import "../index-DSprYWaz.mjs";
|
|
2
|
+
import { $ as StopReason, Q as SimpleStreamOptions, d as Context, k as Model, tt as StreamFunction } from "../types-CVYzKrMl.mjs";
|
|
3
|
+
import { A as supportsOpenAITemperature, C as isOpenAIGpt6Model, D as resolveOpenAIReasoningEffortMapping, E as resolveOpenAIReasoningEffortForModel, O as resolveOpenAISupportedReasoningEfforts, S as isOpenAIGpt56Model, T as resolveOpenAIModelReasoningEfforts, _ as reconcileOpenAIResponsesToolChoice, a as BaseOpenAIStreamOptions, b as isOpenAIGpt54MiniModel, c as OpenAICompletionsOptions, f as reasoningTagTextPolicy, g as reconcileOpenAICompletionsToolChoice, h as projectOpenAITools, k as supportsOpenAIReasoningEffort, m as OpenAIToolProjection, o as CodeModeToolSurfaceObservation, p as OpenAICompletionsToolChoice, u as codeModeToolSurfaceObserver, v as OpenAIApiReasoningEffort, w as normalizeOpenAIReasoningEffort, x as isOpenAIGpt55Model, y as OpenAIReasoningEffort } from "../provider-options-DeYeaflL.mjs";
|
|
4
|
+
import "../types-CBJthzJX.mjs";
|
|
5
|
+
import { t as ResolvedOpenAICompletionsCompat } from "../openai-completions-compat-1gsjP-KO.mjs";
|
|
6
|
+
import { c as responsesPromptObserver, f as OpenAIRequestReasoningEffort, l as responsesServiceTierObserver, o as ResponsesPromptObservation, s as ResponsesServiceTierObservation } from "../openai-responses-contracts-CQ4_AWjL.mjs";
|
|
7
|
+
import { n as clampOpenAIPromptCacheKey, r as resolveOpenAIPromptCacheParams, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "../openai-prompt-cache-DgjD-UL5.mjs";
|
|
8
|
+
import { a as resolveResponsesTerminalStopReason, i as readResponsesReasoningTokens, n as isResponsesOutputLimitToolCallError, r as mapResponsesTerminalUsage, t as ResponsesTerminalUsagePayload } from "../openai-responses-terminal-usage-CpVjkqn-.mjs";
|
|
9
|
+
import "../openai-responses-compaction-replay-Cvnl_nCq.mjs";
|
|
10
|
+
import { n as modelRequestBodyState, t as encodedModelRequestBodyStream } from "../model-request-body-BD5vy4rP.mjs";
|
|
11
11
|
import { ResponseCreateParamsStreaming, ResponseInputItem } from "openai/resources/responses/responses.js";
|
|
12
12
|
import { ChatCompletionMessageParam } from "openai/resources/chat/completions.js";
|
|
13
13
|
//#region packages/ai/src/providers/azure-deployment-map.d.ts
|
|
@@ -34,6 +34,7 @@ export declare function isOpenAICompatibleAzureResponsesBaseUrl(baseUrl: string)
|
|
|
34
34
|
export declare function convertMessages(model: Model<"openai-completions">, context: Context, compat: ResolvedOpenAICompletionsCompat, options?: {
|
|
35
35
|
cacheOptOutIndexes?: Set<number>;
|
|
36
36
|
preserveSystemPromptCacheBoundary?: boolean;
|
|
37
|
+
supportsTools?: boolean;
|
|
37
38
|
}): ChatCompletionMessageParam[];
|
|
38
39
|
//#endregion
|
|
39
40
|
//#region packages/ai/src/providers/openai-completions.d.ts
|
|
@@ -135,6 +136,11 @@ type ResponsesRequestLifecycle = {
|
|
|
135
136
|
accepted(responseId: string, signal?: AbortSignal): Promise<void>;
|
|
136
137
|
settle(): Promise<void>;
|
|
137
138
|
};
|
|
139
|
+
/** A full-input side request must neither consume nor replace a session's continuation. */
|
|
140
|
+
export declare const independentResponsesRequest: {
|
|
141
|
+
set(options: object): void;
|
|
142
|
+
has(options: object | undefined): boolean;
|
|
143
|
+
};
|
|
138
144
|
/** Private transport carrier: serialized options cannot mint host authority. */
|
|
139
145
|
export declare const responsesRequestLifecycle: {
|
|
140
146
|
set(options: object, lifecycle: ResponsesRequestLifecycle): void;
|
|
@@ -147,19 +153,4 @@ export declare function bindResponsesInputMessage(source: Extract<Context["messa
|
|
|
147
153
|
role: "user";
|
|
148
154
|
}>): (input: unknown) => boolean;
|
|
149
155
|
//#endregion
|
|
150
|
-
|
|
151
|
-
type EncodedModelRequestBody = {
|
|
152
|
-
body: Uint8Array<ArrayBuffer>;
|
|
153
|
-
stream: boolean;
|
|
154
|
-
};
|
|
155
|
-
type ModelRequestBodyState = {
|
|
156
|
-
enabled?: boolean;
|
|
157
|
-
encode?: (payload: unknown) => Promise<EncodedModelRequestBody>;
|
|
158
|
-
onBytes?: (bytes: number) => void;
|
|
159
|
-
};
|
|
160
|
-
/** Call-local state survives option spreads; no payload is cached across requests. */
|
|
161
|
-
export declare function modelRequestBodyState(options: object, inheritFrom?: object): ModelRequestBodyState;
|
|
162
|
-
export declare function serializeModelRequestBody(payload: unknown): EncodedModelRequestBody;
|
|
163
|
-
export declare function encodedModelRequestBodyStream(body: unknown): boolean | undefined;
|
|
164
|
-
//#endregion
|
|
165
|
-
export { type CodeModeToolSurfaceObservation, OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH, OpenAIApiReasoningEffort, type OpenAICompletionsOptions, type OpenAICompletionsToolChoice, OpenAIReasoningEffort, type OpenAIToolProjection, type ResponsesPromptObservation, type ResponsesServiceTierObservation, ResponsesTerminalUsagePayload, clampOpenAIPromptCacheKey, codeModeToolSurfaceObserver, isOpenAIGpt54MiniModel, isOpenAIGpt55Model, isOpenAIGpt56Model, isOpenAIGpt6Model, isResponsesOutputLimitToolCallError, mapResponsesTerminalUsage, normalizeOpenAIReasoningEffort, projectOpenAITools, readResponsesReasoningTokens, reasoningTagTextPolicy, reconcileOpenAICompletionsToolChoice, reconcileOpenAIResponsesToolChoice, resolveOpenAIModelReasoningEfforts, resolveOpenAIPromptCacheParams, resolveOpenAIReasoningEffortForModel, resolveOpenAIReasoningEffortMapping, resolveOpenAISupportedReasoningEfforts, resolveResponsesTerminalStopReason, responsesPromptObserver, responsesServiceTierObserver, supportsOpenAIReasoningEffort, supportsOpenAITemperature };
|
|
156
|
+
export { type CodeModeToolSurfaceObservation, OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH, OpenAIApiReasoningEffort, type OpenAICompletionsOptions, type OpenAICompletionsToolChoice, OpenAIReasoningEffort, type OpenAIToolProjection, type ResponsesPromptObservation, type ResponsesServiceTierObservation, ResponsesTerminalUsagePayload, clampOpenAIPromptCacheKey, codeModeToolSurfaceObserver, encodedModelRequestBodyStream, isOpenAIGpt54MiniModel, isOpenAIGpt55Model, isOpenAIGpt56Model, isOpenAIGpt6Model, isResponsesOutputLimitToolCallError, mapResponsesTerminalUsage, modelRequestBodyState, normalizeOpenAIReasoningEffort, projectOpenAITools, readResponsesReasoningTokens, reasoningTagTextPolicy, reconcileOpenAICompletionsToolChoice, reconcileOpenAIResponsesToolChoice, resolveOpenAIModelReasoningEfforts, resolveOpenAIPromptCacheParams, resolveOpenAIReasoningEffortForModel, resolveOpenAIReasoningEffortMapping, resolveOpenAISupportedReasoningEfforts, resolveResponsesTerminalStopReason, responsesPromptObserver, responsesServiceTierObserver, supportsOpenAIReasoningEffort, supportsOpenAITemperature };
|
package/dist/internal/openai.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
import { n as clampOpenAIPromptCacheKey, r as resolveOpenAIPromptCacheParams, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "../openai-prompt-cache-
|
|
3
|
-
import { _ as resolveResponsesTerminalStopReason, g as readResponsesReasoningTokens, h as mapResponsesTerminalUsage, m as isResponsesOutputLimitToolCallError } from "../diagnostics-
|
|
4
|
-
import { a as encodedModelRequestBodyStream,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { A as supportsOpenAITemperature, C as isOpenAIGpt6Model, D as resolveOpenAIReasoningEffortMapping, E as resolveOpenAIReasoningEffortForModel, O as resolveOpenAISupportedReasoningEfforts, S as isOpenAIGpt56Model, T as resolveOpenAIModelReasoningEfforts, _ as responsesServiceTierObserver, b as isOpenAIGpt54MiniModel, g as responsesPromptObserver, k as supportsOpenAIReasoningEffort, w as normalizeOpenAIReasoningEffort, x as isOpenAIGpt55Model } from "../openai-responses-contracts-Bx-16mnf.mjs";
|
|
2
|
+
import { n as clampOpenAIPromptCacheKey, r as resolveOpenAIPromptCacheParams, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "../openai-prompt-cache-DJ_P143P.mjs";
|
|
3
|
+
import { _ as resolveResponsesTerminalStopReason, g as readResponsesReasoningTokens, h as mapResponsesTerminalUsage, m as isResponsesOutputLimitToolCallError } from "../diagnostics-Cv7cW3pS.mjs";
|
|
4
|
+
import { a as encodedModelRequestBodyStream, g as reasoningTagTextPolicy, m as codeModeToolSurfaceObserver, o as modelRequestBodyState } from "../simple-options-BYgC6kse.mjs";
|
|
5
|
+
import { a as hasResponsesWebSearchTool, s as convertMessages } from "../openai-completions-transport-DviPEqw3.mjs";
|
|
6
|
+
import { Ct as reconcileOpenAIResponsesToolChoice, N as bindResponsesInputMessage, St as reconcileOpenAICompletionsToolChoice, _ as isResponsesTextContentPartType, d as AZURE_RESPONSES_TEXT_CONTENT_PART_TYPE, f as AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE, g as isAzureResponsesTextDeltaEventType, h as isAzureResponsesTextDeltaEvent, l as createResponsesToolCallTracker, m as OPENAI_RESPONSES_OUTPUT_TEXT_DELTA_EVENT_TYPE, p as OPENAI_RESPONSES_OUTPUT_TEXT_CONTENT_PART_TYPE, u as readResponsesToolCallItemIdentity, v as isResponsesTextDeltaEventType, xt as projectOpenAITools, y as resolveResponsesMessageSnapshotCollapse } from "../openai-responses-shared-Bv_1NtH9.mjs";
|
|
7
7
|
import { t as mapOpenAIStopReason } from "../openai-stop-reason-8s70vDXj.mjs";
|
|
8
8
|
import { i as resolveAzureDeploymentNameFromMap, n as isTraditionalAzureOpenAIHost, r as parseAzureDeploymentNameMap, t as isOpenAICompatibleAzureResponsesBaseUrl } from "../azure-openai-responses-client-compat-D0dvJMbZ.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import { n as streamOpenAICompletions, r as streamSimpleOpenAICompletions } from "../openai-completions-
|
|
11
|
-
import { n as streamOpenAIResponses, r as streamSimpleOpenAIResponses } from "../openai-responses-
|
|
12
|
-
export { AZURE_RESPONSES_TEXT_CONTENT_PART_TYPE, AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE, OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH, OPENAI_RESPONSES_OUTPUT_TEXT_CONTENT_PART_TYPE, OPENAI_RESPONSES_OUTPUT_TEXT_DELTA_EVENT_TYPE, bindResponsesInputMessage, clampOpenAIPromptCacheKey, codeModeToolSurfaceObserver, convertMessages, createResponsesToolCallTracker, encodedModelRequestBodyStream, hasResponsesWebSearchTool, isAzureResponsesTextDeltaEvent, isAzureResponsesTextDeltaEventType, isOpenAICompatibleAzureResponsesBaseUrl, isOpenAIGpt54MiniModel, isOpenAIGpt55Model, isOpenAIGpt56Model, isOpenAIGpt6Model, isResponsesOutputLimitToolCallError, isResponsesTextContentPartType, isResponsesTextDeltaEventType, isTraditionalAzureOpenAIHost, mapOpenAIStopReason, mapResponsesTerminalUsage, modelRequestBodyState, normalizeOpenAIReasoningEffort, parseAzureDeploymentNameMap, projectOpenAITools, readResponsesReasoningTokens, readResponsesToolCallItemIdentity, reasoningTagTextPolicy, reconcileOpenAICompletionsToolChoice, reconcileOpenAIResponsesToolChoice, resolveAzureDeploymentNameFromMap, resolveOpenAIModelReasoningEfforts, resolveOpenAIPromptCacheParams, resolveOpenAIReasoningEffortForModel, resolveOpenAIReasoningEffortMapping, resolveOpenAISupportedReasoningEfforts, resolveResponsesMessageSnapshotCollapse, resolveResponsesTerminalStopReason, responsesPromptObserver, responsesRequestLifecycle, responsesServiceTierObserver,
|
|
9
|
+
import { n as responsesRequestLifecycle, t as independentResponsesRequest } from "../openai-responses-request-lifecycle-CTdAb2v1.mjs";
|
|
10
|
+
import { n as streamOpenAICompletions, r as streamSimpleOpenAICompletions } from "../openai-completions-B6sET3oI.mjs";
|
|
11
|
+
import { n as streamOpenAIResponses, r as streamSimpleOpenAIResponses } from "../openai-responses-BXsJK-mD.mjs";
|
|
12
|
+
export { AZURE_RESPONSES_TEXT_CONTENT_PART_TYPE, AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE, OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH, OPENAI_RESPONSES_OUTPUT_TEXT_CONTENT_PART_TYPE, OPENAI_RESPONSES_OUTPUT_TEXT_DELTA_EVENT_TYPE, bindResponsesInputMessage, clampOpenAIPromptCacheKey, codeModeToolSurfaceObserver, convertMessages, createResponsesToolCallTracker, encodedModelRequestBodyStream, hasResponsesWebSearchTool, independentResponsesRequest, isAzureResponsesTextDeltaEvent, isAzureResponsesTextDeltaEventType, isOpenAICompatibleAzureResponsesBaseUrl, isOpenAIGpt54MiniModel, isOpenAIGpt55Model, isOpenAIGpt56Model, isOpenAIGpt6Model, isResponsesOutputLimitToolCallError, isResponsesTextContentPartType, isResponsesTextDeltaEventType, isTraditionalAzureOpenAIHost, mapOpenAIStopReason, mapResponsesTerminalUsage, modelRequestBodyState, normalizeOpenAIReasoningEffort, parseAzureDeploymentNameMap, projectOpenAITools, readResponsesReasoningTokens, readResponsesToolCallItemIdentity, reasoningTagTextPolicy, reconcileOpenAICompletionsToolChoice, reconcileOpenAIResponsesToolChoice, resolveAzureDeploymentNameFromMap, resolveOpenAIModelReasoningEfforts, resolveOpenAIPromptCacheParams, resolveOpenAIReasoningEffortForModel, resolveOpenAIReasoningEffortMapping, resolveOpenAISupportedReasoningEfforts, resolveResponsesMessageSnapshotCollapse, resolveResponsesTerminalStopReason, responsesPromptObserver, responsesRequestLifecycle, responsesServiceTierObserver, streamOpenAICompletions, streamOpenAIResponses, streamSimpleOpenAICompletions, streamSimpleOpenAIResponses, supportsOpenAIReasoningEffort, supportsOpenAITemperature };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as parseRetryAfterHttpDateMs, n as parseRetryAfterErrorSeconds, r as parseRetryAfterHeadersSeconds, t as parseHttpDateInstant } from "../retry-after-
|
|
1
|
+
import { i as parseRetryAfterHttpDateMs, n as parseRetryAfterErrorSeconds, r as parseRetryAfterHeadersSeconds, t as parseHttpDateInstant } from "../retry-after-sw-XX8aC.mjs";
|
|
2
2
|
export { parseHttpDateInstant, parseRetryAfterErrorSeconds, parseRetryAfterHeadersSeconds, parseRetryAfterHttpDateMs };
|
|
@@ -22,15 +22,6 @@ const HTTP_DATE_SHORT_WEEKDAY_INDEX = new Map([
|
|
|
22
22
|
"Fri",
|
|
23
23
|
"Sat"
|
|
24
24
|
].map((weekday, index) => [weekday, index]));
|
|
25
|
-
const HTTP_DATE_LONG_WEEKDAY_INDEX = new Map([
|
|
26
|
-
"Sunday",
|
|
27
|
-
"Monday",
|
|
28
|
-
"Tuesday",
|
|
29
|
-
"Wednesday",
|
|
30
|
-
"Thursday",
|
|
31
|
-
"Friday",
|
|
32
|
-
"Saturday"
|
|
33
|
-
].map((weekday, index) => [weekday, index]));
|
|
34
25
|
const IMF_FIXDATE_RE = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d{2}) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d{2}):(\d{2}):(\d{2}) GMT$/;
|
|
35
26
|
const OBSOLETE_RFC850_DATE_RE = /^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d{2})-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d{2}) (\d{2}):(\d{2}):(\d{2}) GMT$/;
|
|
36
27
|
const OBSOLETE_ASCTIME_DATE_RE = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{2}| \d) (\d{2}):(\d{2}):(\d{2}) (\d{4})$/;
|
|
@@ -38,20 +29,30 @@ function ownDataValue(value, key) {
|
|
|
38
29
|
return value && typeof value === "object" ? Object.getOwnPropertyDescriptor(value, key)?.value : void 0;
|
|
39
30
|
}
|
|
40
31
|
/** Reads only retry timing metadata, without invoking provider getters or serialization hooks. */
|
|
41
|
-
function parseRetryAfterHeadersSeconds(headers, nowMs = Date.now()) {
|
|
32
|
+
function parseRetryAfterHeadersSeconds(headers, nowMs = Date.now(), status) {
|
|
42
33
|
if (!headers || typeof headers !== "object") return;
|
|
43
34
|
try {
|
|
44
35
|
let entries;
|
|
45
36
|
try {
|
|
46
|
-
entries = [
|
|
37
|
+
entries = [
|
|
38
|
+
"retry-after",
|
|
39
|
+
"retry-after-ms",
|
|
40
|
+
"x-ratelimit-remaining-tokens",
|
|
41
|
+
"x-ratelimit-reset-tokens",
|
|
42
|
+
"x-ratelimit-remaining-requests",
|
|
43
|
+
"x-ratelimit-reset-requests",
|
|
44
|
+
"x-ratelimit-remaining-project-tokens",
|
|
45
|
+
"x-ratelimit-reset-project-tokens"
|
|
46
|
+
].map((key) => [key, Headers.prototype.get.call(headers, key)]);
|
|
47
47
|
} catch {
|
|
48
48
|
entries = Object.getOwnPropertyNames(headers).flatMap((key) => {
|
|
49
49
|
const name = key.toLowerCase();
|
|
50
|
-
return name === "retry-after" || name === "retry-after-ms" ? [[name, ownDataValue(headers, key)]] : [];
|
|
50
|
+
return name === "retry-after" || name === "retry-after-ms" || /^x-ratelimit-(?:remaining|reset)-(?:tokens|requests|project-tokens)$/.test(name) ? [[name, ownDataValue(headers, key)]] : [];
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
let floor;
|
|
54
54
|
for (const [key, value] of entries) {
|
|
55
|
+
if (key.startsWith("x-ratelimit-")) continue;
|
|
55
56
|
const text = typeof value === "string" ? value.trim() : typeof value === "number" ? String(value) : "";
|
|
56
57
|
const milliseconds = key === "retry-after-ms";
|
|
57
58
|
const numeric = typeof value === "number" ? value >= 0 && (milliseconds || Number.isInteger(value) || value === Infinity) : (milliseconds ? /^\d+(?:\.\d+)?$/ : /^\d+$/).test(text);
|
|
@@ -60,17 +61,51 @@ function parseRetryAfterHeadersSeconds(headers, nowMs = Date.now()) {
|
|
|
60
61
|
const seconds = numeric ? Number.isFinite(number) && number <= Number.MAX_SAFE_INTEGER ? number / (milliseconds ? 1e3 : 1) : Infinity : retryAt === void 0 ? void 0 : Math.max(0, (retryAt - nowMs) / 1e3);
|
|
61
62
|
if (seconds !== void 0) floor = Math.max(floor ?? 0, seconds);
|
|
62
63
|
}
|
|
64
|
+
if (status === 429) {
|
|
65
|
+
const values = new Map(entries);
|
|
66
|
+
for (const dimension of [
|
|
67
|
+
"tokens",
|
|
68
|
+
"requests",
|
|
69
|
+
"project-tokens"
|
|
70
|
+
]) {
|
|
71
|
+
const remaining = values.get(`x-ratelimit-remaining-${dimension}`);
|
|
72
|
+
const numericRemaining = typeof remaining === "number" ? remaining : typeof remaining === "string" && /^-?\d+(?:\.\d+)?$/.test(remaining.trim()) ? Number(remaining) : NaN;
|
|
73
|
+
if (!Number.isFinite(numericRemaining) || numericRemaining > 0) continue;
|
|
74
|
+
const reset = values.get(`x-ratelimit-reset-${dimension}`);
|
|
75
|
+
const seconds = typeof reset === "string" ? parseQuotaResetSeconds(reset) : void 0;
|
|
76
|
+
if (seconds !== void 0) floor = Math.max(floor ?? 0, seconds);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
63
79
|
return floor;
|
|
64
80
|
} catch {
|
|
65
81
|
return;
|
|
66
82
|
}
|
|
67
83
|
}
|
|
84
|
+
function parseQuotaResetSeconds(value) {
|
|
85
|
+
if (!/^(?:\d+(?:\.\d+)?(?:ms|s|m|h))+$/.test(value)) return;
|
|
86
|
+
const scales = {
|
|
87
|
+
ms: .001,
|
|
88
|
+
s: 1,
|
|
89
|
+
m: 60,
|
|
90
|
+
h: 3600
|
|
91
|
+
};
|
|
92
|
+
let seconds = 0;
|
|
93
|
+
for (const match of value.matchAll(/(\d+(?:\.\d+)?)(ms|s|m|h)/g)) {
|
|
94
|
+
const scale = scales[match[2] ?? ""];
|
|
95
|
+
if (scale === void 0) return;
|
|
96
|
+
seconds += Number(match[1]) * scale;
|
|
97
|
+
}
|
|
98
|
+
return Number.isFinite(seconds) && seconds <= Number.MAX_SAFE_INTEGER ? seconds : Infinity;
|
|
99
|
+
}
|
|
68
100
|
/** SDK errors carry native response headers separately from their error body. */
|
|
69
101
|
function parseRetryAfterErrorSeconds(error, nowMs = Date.now()) {
|
|
70
102
|
try {
|
|
71
|
-
const
|
|
72
|
-
const response =
|
|
73
|
-
|
|
103
|
+
const status = ownDataValue(error, "status") ?? ownDataValue(error, "statusCode");
|
|
104
|
+
const response = ownDataValue(error, "response");
|
|
105
|
+
const responseStatus = ownDataValue(response, "status") ?? ownDataValue(response, "statusCode");
|
|
106
|
+
const direct = parseRetryAfterHeadersSeconds(ownDataValue(error, "headers"), nowMs, typeof status === "number" ? status : void 0);
|
|
107
|
+
const responseSeconds = parseRetryAfterHeadersSeconds(ownDataValue(response, "headers"), nowMs, typeof responseStatus === "number" ? responseStatus : typeof status === "number" ? status : void 0);
|
|
108
|
+
return direct === void 0 && responseSeconds === void 0 ? void 0 : Math.max(direct ?? 0, responseSeconds ?? 0);
|
|
74
109
|
} catch {
|
|
75
110
|
return;
|
|
76
111
|
}
|
|
@@ -81,50 +116,40 @@ function parseRetryAfterHttpDateMs(value, nowMs = Date.now()) {
|
|
|
81
116
|
}
|
|
82
117
|
/** Parse all three HTTP-date forms while retaining leap-second ordering. */
|
|
83
118
|
function parseHttpDateInstant(value, nowMs = Date.now()) {
|
|
84
|
-
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
month
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
119
|
+
let fields = (IMF_FIXDATE_RE.exec(value) ?? OBSOLETE_RFC850_DATE_RE.exec(value))?.slice(1);
|
|
120
|
+
if (!fields) {
|
|
121
|
+
const asctimeDate = OBSOLETE_ASCTIME_DATE_RE.exec(value);
|
|
122
|
+
if (!asctimeDate) return;
|
|
123
|
+
const [, weekday, month, day, hours, minutes, seconds, year] = asctimeDate;
|
|
124
|
+
fields = [
|
|
125
|
+
weekday,
|
|
126
|
+
day,
|
|
127
|
+
month,
|
|
128
|
+
year,
|
|
129
|
+
hours,
|
|
130
|
+
minutes,
|
|
131
|
+
seconds
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
const [weekday, day, month, year, hours, minutes, seconds] = fields;
|
|
135
|
+
const components = {
|
|
136
|
+
weekday: HTTP_DATE_SHORT_WEEKDAY_INDEX.get((weekday ?? "").slice(0, 3)),
|
|
137
|
+
year: Number.parseInt(year ?? "", 10),
|
|
138
|
+
month: HTTP_DATE_MONTH_INDEX.get(month ?? ""),
|
|
139
|
+
day: Number.parseInt(day ?? "", 10),
|
|
140
|
+
hours: Number.parseInt(hours ?? "", 10),
|
|
141
|
+
minutes: Number.parseInt(minutes ?? "", 10),
|
|
142
|
+
seconds: Number.parseInt(seconds ?? "", 10)
|
|
143
|
+
};
|
|
144
|
+
if (year?.length === 2) {
|
|
96
145
|
const now = new Date(nowMs);
|
|
97
146
|
if (Number.isNaN(now.getTime())) return;
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
const components = {
|
|
101
|
-
weekday: HTTP_DATE_LONG_WEEKDAY_INDEX.get(rfc850Date[1] ?? ""),
|
|
102
|
-
month: HTTP_DATE_MONTH_INDEX.get(rfc850Date[3] ?? ""),
|
|
103
|
-
day: Number.parseInt(rfc850Date[2] ?? "", 10),
|
|
104
|
-
hours: Number.parseInt(rfc850Date[5] ?? "", 10),
|
|
105
|
-
minutes: Number.parseInt(rfc850Date[6] ?? "", 10),
|
|
106
|
-
seconds: Number.parseInt(rfc850Date[7] ?? "", 10)
|
|
107
|
-
};
|
|
108
|
-
const candidate = parseHttpDateCalendarMs({
|
|
109
|
-
year: candidateYear,
|
|
110
|
-
...components
|
|
111
|
-
});
|
|
147
|
+
components.year += Math.floor(now.getUTCFullYear() / 100) * 100;
|
|
148
|
+
const candidate = parseHttpDateCalendarMs(components);
|
|
112
149
|
if (candidate === void 0) return;
|
|
113
|
-
|
|
114
|
-
year: candidate > Date.UTC(now.getUTCFullYear() + 50, now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds()) ? candidateYear - 100 : candidateYear,
|
|
115
|
-
...components
|
|
116
|
-
});
|
|
150
|
+
if (candidate > Date.UTC(now.getUTCFullYear() + 50, now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds())) components.year -= 100;
|
|
117
151
|
}
|
|
118
|
-
|
|
119
|
-
if (asctimeDate) return parseHttpDateComponents({
|
|
120
|
-
weekday: HTTP_DATE_SHORT_WEEKDAY_INDEX.get(asctimeDate[1] ?? ""),
|
|
121
|
-
year: Number.parseInt(asctimeDate[7] ?? "", 10),
|
|
122
|
-
month: HTTP_DATE_MONTH_INDEX.get(asctimeDate[2] ?? ""),
|
|
123
|
-
day: Number.parseInt((asctimeDate[3] ?? "").trim(), 10),
|
|
124
|
-
hours: Number.parseInt(asctimeDate[4] ?? "", 10),
|
|
125
|
-
minutes: Number.parseInt(asctimeDate[5] ?? "", 10),
|
|
126
|
-
seconds: Number.parseInt(asctimeDate[6] ?? "", 10)
|
|
127
|
-
});
|
|
152
|
+
return parseHttpDateComponents(components);
|
|
128
153
|
}
|
|
129
154
|
function parseHttpDateComponents(components) {
|
|
130
155
|
const timestamp = parseHttpDateCalendarMs(components);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import "../index-
|
|
2
|
-
import { M as ModelThinkingLevel, Q as SimpleStreamOptions, U as ProviderStreamOptions, a as AssistantMessage, d as Context, k as Model, n as Api, nt as StreamOptions, pt as Usage, s as AssistantMessageEventStreamContract } from "../types-
|
|
3
|
-
import { i as getEventStreamCompletion } from "../event-stream-
|
|
4
|
-
import { a as RegisteredApiProvider, t as ApiProvider } from "../api-registry-
|
|
5
|
-
import { m as getDefaultAiTransportHost } from "../host-
|
|
6
|
-
import "../types-
|
|
7
|
-
import { t as sanitizeSurrogates } from "../sanitize-unicode-
|
|
8
|
-
import { v as parseTerminalToolCallArguments } from "../transport-stream-shared-
|
|
1
|
+
import "../index-DSprYWaz.mjs";
|
|
2
|
+
import { M as ModelThinkingLevel, Q as SimpleStreamOptions, U as ProviderStreamOptions, a as AssistantMessage, d as Context, k as Model, n as Api, nt as StreamOptions, pt as Usage, s as AssistantMessageEventStreamContract } from "../types-CVYzKrMl.mjs";
|
|
3
|
+
import { i as getEventStreamCompletion } from "../event-stream-CzpE1g_o.mjs";
|
|
4
|
+
import { a as RegisteredApiProvider, t as ApiProvider } from "../api-registry-gDt0faai.mjs";
|
|
5
|
+
import { m as getDefaultAiTransportHost } from "../host-jJOffdlW.mjs";
|
|
6
|
+
import "../types-CBJthzJX.mjs";
|
|
7
|
+
import { n as isContextOverflow, t as sanitizeSurrogates } from "../sanitize-unicode-ZqVLLEKC.mjs";
|
|
8
|
+
import { v as parseTerminalToolCallArguments } from "../transport-stream-shared-8ru8eX4s.mjs";
|
|
9
9
|
//#region packages/ai/src/internal/default-runtime.d.ts
|
|
10
10
|
export declare const defaultApiRegistry: {
|
|
11
11
|
registerApiProvider: <TApi extends Api, TOptions extends StreamOptions>(provider: ApiProvider<TApi, TOptions>, sourceId?: string) => void;
|
|
@@ -87,8 +87,6 @@ export type SessionResourceCleanup = (sessionId?: string, owner?: SessionResourc
|
|
|
87
87
|
export declare function getSessionResourceOwnerId(owner: SessionResourceOwner): number;
|
|
88
88
|
/** Registers a session-resource cleanup hook and returns an unregister function. */
|
|
89
89
|
export declare function registerSessionResourceCleanup(cleanup: SessionResourceCleanup): () => void;
|
|
90
|
-
/** Registers metadata cleanup that runs only after every resource cleanup succeeds. */
|
|
91
|
-
export declare function registerSessionResourceCleanupObserver(observer: SessionResourceCleanup): () => void;
|
|
92
90
|
/** Runs all registered cleanup hooks, aggregating failures after every hook has run. */
|
|
93
91
|
export declare function cleanupSessionResources(sessionId?: string, owner?: SessionResourceOwner): void;
|
|
94
92
|
//#endregion
|
|
@@ -159,26 +157,6 @@ export type OpenAICodexJwtPayload = {
|
|
|
159
157
|
export declare function decodeOpenAICodexJwtPayload(token: string): OpenAICodexJwtPayload | null;
|
|
160
158
|
export declare function resolveOpenAICodexAccountId(token: string): string | null;
|
|
161
159
|
//#endregion
|
|
162
|
-
//#region packages/ai/src/utils/overflow.d.ts
|
|
163
|
-
declare const CONTEXT_OVERFLOW_PATTERN_SCOPES: {
|
|
164
|
-
readonly "assistant-error": RegExp[];
|
|
165
|
-
readonly "failover-explicit": RegExp[];
|
|
166
|
-
readonly "provider-fallback": RegExp[];
|
|
167
|
-
readonly "failover-hint": readonly [RegExp];
|
|
168
|
-
readonly "context-window-too-small": readonly [RegExp];
|
|
169
|
-
readonly "tpm-rate-limit-hint": readonly [RegExp];
|
|
170
|
-
readonly "rate-limit-hint": readonly [RegExp];
|
|
171
|
-
};
|
|
172
|
-
export type ContextOverflowMessageScope = keyof typeof CONTEXT_OVERFLOW_PATTERN_SCOPES;
|
|
173
|
-
/** Match one canonical context-overflow wording scope without applying caller policy. */
|
|
174
|
-
export declare function matchesContextOverflowMessage(errorMessage: string, scope: ContextOverflowMessageScope): boolean;
|
|
175
|
-
/**
|
|
176
|
-
* Match provider overflow errors, or infer overflow from reported context usage.
|
|
177
|
-
* A context window enables silent-overflow detection; silent truncation without
|
|
178
|
-
* a length stop remains undetectable because the original token count is unknown.
|
|
179
|
-
*/
|
|
180
|
-
export declare function isContextOverflow(message: AssistantMessage, contextWindow?: number): boolean;
|
|
181
|
-
//#endregion
|
|
182
160
|
//#region packages/markdown-core/src/reasoning-tag-parser.d.ts
|
|
183
161
|
type ReasoningTagTextDelta = {
|
|
184
162
|
kind: "text";
|
|
@@ -253,4 +231,4 @@ export declare function createSseByteGuard(reader: ReadableStreamDefaultReader<U
|
|
|
253
231
|
/** Lazily bound an SDK response while preserving upstream cancellation. */
|
|
254
232
|
export declare function boundResponseBody(response: Response, options: ReadSseStreamWithLimitOptions): Response;
|
|
255
233
|
//#endregion
|
|
256
|
-
export { type ReasoningTagTextDelta, type ReasoningTagTextPartitioner, complete, completeSimple, getApiProvider, getApiProviders, getEventStreamCompletion, parseTerminalToolCallArguments, sanitizeSurrogates, stream, streamSimple };
|
|
234
|
+
export { type ReasoningTagTextDelta, type ReasoningTagTextPartitioner, complete, completeSimple, getApiProvider, getApiProviders, getEventStreamCompletion, isContextOverflow, parseTerminalToolCallArguments, sanitizeSurrogates, stream, streamSimple };
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as createReasoningTagTextPartitioner } from "../reasoning-tag-text-partitioner-DzlRubwU.mjs";
|
|
2
2
|
import { o as getEventStreamCompletion } from "../event-stream-X2gmsUWv.mjs";
|
|
3
|
-
import { r as createApiRegistry, t as createLlmRuntime } from "../stream-
|
|
4
|
-
import { A as getSupportedThinkingLevels, D as applyProviderReportedUsageCost, E as headersToRecord, O as calculateCost, j as modelsAreEqual, k as clampThinkingLevel } from "../host-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { r as createApiRegistry, t as createLlmRuntime } from "../stream-DLBirT0e.mjs";
|
|
4
|
+
import { A as getSupportedThinkingLevels, D as applyProviderReportedUsageCost, E as headersToRecord, O as calculateCost, j as modelsAreEqual, k as clampThinkingLevel } from "../host-B2gk-d1H.mjs";
|
|
5
|
+
import { n as getSessionResourceOwnerId, r as registerSessionResourceCleanup, t as cleanupSessionResources } from "../session-resources-vKvGIE3J.mjs";
|
|
6
|
+
import { t as sanitizeSurrogates } from "../sanitize-unicode-CRGuMONI.mjs";
|
|
7
|
+
import { A as shortHash, D as parseJsonWithRepair, E as createToolArgumentPreviewSchedule, O as parseStreamingJson, g as parseTerminalToolCallArguments, k as repairJson } from "../transport-stream-shared-CzQlAzJH.mjs";
|
|
8
|
+
import { n as getEnvApiKey, t as findEnvKeys } from "../env-api-keys-Xd8dm_aV.mjs";
|
|
8
9
|
import { t as createDeferredEventBuffer } from "../deferred-event-buffer-DAvyP7qA.mjs";
|
|
9
10
|
import { n as onLlmRequestActivity, t as notifyLlmRequestActivity } from "../llm-request-activity-CfMuh5cC.mjs";
|
|
10
|
-
import { a as withFirstStreamEventTimeout, i as getFirstStreamEventTimeoutMs, n as createFirstStreamEventTimeoutError, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "../stream-first-event-timeout-
|
|
11
|
+
import { a as withFirstStreamEventTimeout, i as getFirstStreamEventTimeoutMs, n as createFirstStreamEventTimeoutError, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "../stream-first-event-timeout-D_TfJHRJ.mjs";
|
|
11
12
|
import { n as createSseByteGuard, t as boundResponseBody } from "../streaming-byte-guard-DBXr1XYn.mjs";
|
|
12
|
-
import { t as createReasoningTagTextPartitioner } from "../reasoning-tag-text-partitioner-CpOy9-IQ.mjs";
|
|
13
13
|
import { n as resolveOpenAICodexAccountId, t as decodeOpenAICodexJwtPayload } from "../openai-chatgpt-jwt-KWcgd0d_.mjs";
|
|
14
|
+
import { t as isContextOverflow } from "../overflow-DJHXTNBQ.mjs";
|
|
14
15
|
//#region packages/ai/src/internal/default-runtime.ts
|
|
15
16
|
const DEFAULT_RUNTIME_KEY = Symbol.for("openclaw.ai.defaultRuntime");
|
|
16
17
|
function resolveDefaultRuntime() {
|
|
@@ -30,111 +31,4 @@ const defaultLlmRuntime = defaultRuntime.runtime;
|
|
|
30
31
|
const { getApiProvider, getApiProviders } = defaultApiRegistry;
|
|
31
32
|
const { stream, complete, streamSimple, completeSimple } = defaultLlmRuntime;
|
|
32
33
|
//#endregion
|
|
33
|
-
|
|
34
|
-
const CONFIGURED_CONTEXT_SIZE_OVERFLOW_RE = /prompt has [\d,]+ tokens?, but the configured context size is [\d,]+ tokens?/i;
|
|
35
|
-
const CONTEXT_OVERFLOW_PATTERN_SCOPES = {
|
|
36
|
-
"assistant-error": [
|
|
37
|
-
/prompt is too long/i,
|
|
38
|
-
/request_too_large/i,
|
|
39
|
-
/input length and `?max_tokens`? exceed context limit: [\d,]+ \+ [\d,]+ > [\d,]+/i,
|
|
40
|
-
/input is too long for requested model/i,
|
|
41
|
-
/exceeds the context window/i,
|
|
42
|
-
/exceeds (?:the )?(?:model'?s )?maximum context length(?: of [\d,]+ tokens?|\s*\([\d,]+\))/i,
|
|
43
|
-
/input token count.*exceeds the maximum/i,
|
|
44
|
-
/maximum prompt length is \d+/i,
|
|
45
|
-
/reduce the length of the messages/i,
|
|
46
|
-
/maximum context length is \d+ tokens/i,
|
|
47
|
-
/exceeds (?:the )?maximum allowed input length of [\d,]+ tokens?/i,
|
|
48
|
-
/input \(\d+ tokens\) is longer than the model'?s context length \(\d+ tokens\)/i,
|
|
49
|
-
/exceeds the limit of \d+/i,
|
|
50
|
-
/(?:exceeds the available context size|context size has been exceeded)/i,
|
|
51
|
-
/greater than the context length/i,
|
|
52
|
-
/context window exceeds limit/i,
|
|
53
|
-
/exceeded model token limit/i,
|
|
54
|
-
/tokens? in request more than max tokens? allowed/i,
|
|
55
|
-
/prompt exceeds max(?:imum)? length/i,
|
|
56
|
-
/too large for model with \d+ maximum context length/i,
|
|
57
|
-
CONFIGURED_CONTEXT_SIZE_OVERFLOW_RE,
|
|
58
|
-
/model_context_window_exceeded/i,
|
|
59
|
-
/prompt too long; exceeded (?:max )?context length/i,
|
|
60
|
-
/context[_ ]length[_ ]exceeded/i,
|
|
61
|
-
/too many tokens/i,
|
|
62
|
-
/token limit exceeded/i,
|
|
63
|
-
/^413\s*(?:status code)?\s*\(no body\)/i
|
|
64
|
-
],
|
|
65
|
-
"failover-explicit": [
|
|
66
|
-
/request_too_large/i,
|
|
67
|
-
/context_overflow/i,
|
|
68
|
-
CONFIGURED_CONTEXT_SIZE_OVERFLOW_RE,
|
|
69
|
-
/invalid_argument[\s\S]*maximum number of tokens/i,
|
|
70
|
-
/request exceeds the maximum size/i,
|
|
71
|
-
/context length exceeded/i,
|
|
72
|
-
/maximum context length/i,
|
|
73
|
-
/prompt is too long/i,
|
|
74
|
-
/prompt too long/i,
|
|
75
|
-
/exceeds model context window/i,
|
|
76
|
-
/model token limit/i,
|
|
77
|
-
/input exceeds[\s\S]*maximum number of tokens/i,
|
|
78
|
-
/^(?=[\s\S]*context window)(?=[\s\S]*ran out of (?:room|space))/i,
|
|
79
|
-
/request size exceeds[\s\S]*context window/i,
|
|
80
|
-
/context overflow:/i,
|
|
81
|
-
/exceed context limit/i,
|
|
82
|
-
/exceeds the model'?s maximum context/i,
|
|
83
|
-
/max_tokens[\s\S]*exceed[\s\S]*context/i,
|
|
84
|
-
/input(?: length[\s\S]*exceed[\s\S]*context| \([\d,]+\s*tokens?\) is longer than (?:the )?model'?s context length)/i,
|
|
85
|
-
/413[\s\S]*too large/i,
|
|
86
|
-
/context_window_exceeded/i,
|
|
87
|
-
/input length [\d,]+\s+tokens? exceeds the model limit/i,
|
|
88
|
-
/上下文过长|上下文超出|上下文长度超|超出最大上下文|请压缩上下文/
|
|
89
|
-
],
|
|
90
|
-
"provider-fallback": [
|
|
91
|
-
/\binput token count exceeds the maximum number of input tokens\b/i,
|
|
92
|
-
/\binput is too long for this model\b/i,
|
|
93
|
-
/\binput exceeds the maximum number of tokens\b/i,
|
|
94
|
-
/\bollama error:\s*context length exceeded(?:,\s*too many tokens)?\b/i,
|
|
95
|
-
/\btotal tokens?.*exceeds? (?:the )?(?:model(?:'s)? )?(?:max|maximum|limit)/i,
|
|
96
|
-
/\b(?:(?:request|prompt) \(\d[\d,]*\s*tokens?\) exceeds (?:the )?available context size|context size has been exceeded)\b/i,
|
|
97
|
-
/\binput (?:is )?too long for (?:the )?model\b/i
|
|
98
|
-
],
|
|
99
|
-
"failover-hint": [/context.*overflow|context window.*(too (?:large|long)|exceed|over|limit|max(?:imum)?|requested|sent|tokens)|prompt.*(too (?:large|long)|exceed|over|limit|max(?:imum)?)|(?:request|input).*(?:context|window|length|token).*(too (?:large|long)|exceed|over|limit|max(?:imum)?)/i],
|
|
100
|
-
"context-window-too-small": [/context window.*(too small|minimum is)/i],
|
|
101
|
-
"tpm-rate-limit-hint": [/\btpm\b|tokens per minute/i],
|
|
102
|
-
"rate-limit-hint": [/rate limit|too many requests|requests per (?:minute|hour|day)|quota|throttl|429\b|tokens per day/i]
|
|
103
|
-
};
|
|
104
|
-
/** Match one canonical context-overflow wording scope without applying caller policy. */
|
|
105
|
-
function matchesContextOverflowMessage(errorMessage, scope) {
|
|
106
|
-
return CONTEXT_OVERFLOW_PATTERN_SCOPES[scope].some((pattern) => pattern.test(errorMessage));
|
|
107
|
-
}
|
|
108
|
-
const NON_OVERFLOW_PATTERNS = [
|
|
109
|
-
/^(Throttling error|Service unavailable):/i,
|
|
110
|
-
/rate limit/i,
|
|
111
|
-
/too many requests/i
|
|
112
|
-
];
|
|
113
|
-
function resolveContextInputTokens(message) {
|
|
114
|
-
if (message.usage.contextUsage?.state === "available") return message.usage.contextUsage.promptTokens;
|
|
115
|
-
if (message.usage.contextUsage?.state === "unavailable") return;
|
|
116
|
-
return message.usage.input + message.usage.cacheRead + message.usage.cacheWrite;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Match provider overflow errors, or infer overflow from reported context usage.
|
|
120
|
-
* A context window enables silent-overflow detection; silent truncation without
|
|
121
|
-
* a length stop remains undetectable because the original token count is unknown.
|
|
122
|
-
*/
|
|
123
|
-
function isContextOverflow(message, contextWindow) {
|
|
124
|
-
if (isProviderRefusalAssistantError(message)) return false;
|
|
125
|
-
if (message.stopReason === "error" && message.errorMessage) {
|
|
126
|
-
const errorMessage = message.errorMessage;
|
|
127
|
-
if (!NON_OVERFLOW_PATTERNS.some((p) => p.test(errorMessage)) && matchesContextOverflowMessage(errorMessage, "assistant-error")) return true;
|
|
128
|
-
}
|
|
129
|
-
if (contextWindow && message.stopReason === "stop") {
|
|
130
|
-
const inputTokens = resolveContextInputTokens(message);
|
|
131
|
-
if (inputTokens !== void 0 && inputTokens > contextWindow) return true;
|
|
132
|
-
}
|
|
133
|
-
if (contextWindow && message.stopReason === "length" && message.usage.output === 0) {
|
|
134
|
-
const inputTokens = resolveContextInputTokens(message);
|
|
135
|
-
if (inputTokens !== void 0 && inputTokens >= contextWindow * .99) return true;
|
|
136
|
-
}
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
//#endregion
|
|
140
|
-
export { applyProviderReportedUsageCost, boundResponseBody, calculateCost, clampThinkingLevel, cleanupSessionResources, complete, completeSimple, createDeferredEventBuffer, createFirstStreamEventAbortController, createFirstStreamEventTimeoutError, createReasoningTagTextPartitioner, createSseByteGuard, createToolArgumentPreviewSchedule, decodeOpenAICodexJwtPayload, defaultApiRegistry, defaultLlmRuntime, findEnvKeys, getApiProvider, getApiProviders, getEnvApiKey, getEventStreamCompletion, getFirstStreamEventTimeoutHandler, getFirstStreamEventTimeoutMs, getSessionResourceOwnerId, getSupportedThinkingLevels, headersToRecord, isContextOverflow, matchesContextOverflowMessage, modelsAreEqual, notifyLlmRequestActivity, onLlmRequestActivity, parseJsonWithRepair, parseStreamingJson, parseTerminalToolCallArguments, registerSessionResourceCleanup, registerSessionResourceCleanupObserver, repairJson, resolveOpenAICodexAccountId, sanitizeSurrogates, shortHash, stream, streamSimple, withFirstStreamEventTimeout };
|
|
34
|
+
export { applyProviderReportedUsageCost, boundResponseBody, calculateCost, clampThinkingLevel, cleanupSessionResources, complete, completeSimple, createDeferredEventBuffer, createFirstStreamEventAbortController, createFirstStreamEventTimeoutError, createReasoningTagTextPartitioner, createSseByteGuard, createToolArgumentPreviewSchedule, decodeOpenAICodexJwtPayload, defaultApiRegistry, defaultLlmRuntime, findEnvKeys, getApiProvider, getApiProviders, getEnvApiKey, getEventStreamCompletion, getFirstStreamEventTimeoutHandler, getFirstStreamEventTimeoutMs, getSessionResourceOwnerId, getSupportedThinkingLevels, headersToRecord, isContextOverflow, modelsAreEqual, notifyLlmRequestActivity, onLlmRequestActivity, parseJsonWithRepair, parseStreamingJson, parseTerminalToolCallArguments, registerSessionResourceCleanup, repairJson, resolveOpenAICodexAccountId, sanitizeSurrogates, shortHash, stream, streamSimple, withFirstStreamEventTimeout };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { O as Message, Q as SimpleStreamOptions, a as AssistantMessage, at as ThinkingBudgets, k as Model, n as Api, nt as StreamOptions, st as ThinkingLevel } from "../types-
|
|
2
|
-
import { a as readAssistantThinkingAppend } from "../event-stream-
|
|
3
|
-
import "../
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { O as Message, Q as SimpleStreamOptions, a as AssistantMessage, at as ThinkingBudgets, k as Model, n as Api, nt as StreamOptions, st as ThinkingLevel } from "../types-CVYzKrMl.mjs";
|
|
2
|
+
import { a as readAssistantThinkingAppend } from "../event-stream-CzpE1g_o.mjs";
|
|
3
|
+
import { d as preparedRequestSuffix } from "../provider-options-DeYeaflL.mjs";
|
|
4
|
+
import "../types-CBJthzJX.mjs";
|
|
5
|
+
import { r as serializeModelRequestBody } from "../model-request-body-BD5vy4rP.mjs";
|
|
6
|
+
import { r as matchesContextOverflowMessage, t as sanitizeSurrogates } from "../sanitize-unicode-ZqVLLEKC.mjs";
|
|
7
|
+
import { i as projectProviderError } from "../provider-error-CnaWYTRY.mjs";
|
|
8
|
+
import { n as createDiagnosticRecord, r as isCredentialFieldName } from "../credential-redaction-XvsPf7Yi.mjs";
|
|
7
9
|
import { n as normalizeStructuredPromptSection, r as sortPromptCacheToolsByName, t as normalizePromptCapabilityIds } from "../prompt-cache-stability-Cwcjv_fx.mjs";
|
|
8
10
|
//#region packages/ai/src/providers/simple-options.d.ts
|
|
9
11
|
type FirstEventStreamOptions = {
|
|
@@ -117,4 +119,4 @@ export declare function projectCopilotRequestFacts(messages: readonly {
|
|
|
117
119
|
hasImages: boolean;
|
|
118
120
|
};
|
|
119
121
|
//#endregion
|
|
120
|
-
export { createDiagnosticRecord, isCredentialFieldName, normalizePromptCapabilityIds, normalizeStructuredPromptSection, projectProviderError, readAssistantThinkingAppend, sanitizeSurrogates, sortPromptCacheToolsByName };
|
|
122
|
+
export { createDiagnosticRecord, isCredentialFieldName, matchesContextOverflowMessage, normalizePromptCapabilityIds, normalizeStructuredPromptSection, preparedRequestSuffix, projectProviderError, readAssistantThinkingAppend, sanitizeSurrogates, serializeModelRequestBody, sortPromptCacheToolsByName };
|
package/dist/internal/shared.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { s as readAssistantThinkingAppend } from "../event-stream-X2gmsUWv.mjs";
|
|
2
|
-
import { M as hasMediaPayload, N as isImageWithMediaPayload, c as transformMessages, d as hasOnlyAssistantReasoningContent, f as isReasoningOnlyLengthAssistantTurn, l as FAILED_ASSISTANT_REPLAY_TEXT, m as resolveFailedAssistantReplay, p as isStreamErrorFallbackContent, u as STREAM_ERROR_FALLBACK_TEXT } from "../host-
|
|
3
|
-
import { i as isCredentialFieldName, n as projectProviderError, r as createDiagnosticRecord } from "../provider-error-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as
|
|
2
|
+
import { M as hasMediaPayload, N as isImageWithMediaPayload, c as transformMessages, d as hasOnlyAssistantReasoningContent, f as isReasoningOnlyLengthAssistantTurn, l as FAILED_ASSISTANT_REPLAY_TEXT, m as resolveFailedAssistantReplay, p as isStreamErrorFallbackContent, u as STREAM_ERROR_FALLBACK_TEXT } from "../host-B2gk-d1H.mjs";
|
|
3
|
+
import { i as isCredentialFieldName, n as projectProviderError, r as createDiagnosticRecord } from "../provider-error-qtZD2inE.mjs";
|
|
4
|
+
import { t as sanitizeSurrogates } from "../sanitize-unicode-CRGuMONI.mjs";
|
|
5
|
+
import { n as normalizeStructuredPromptSection, r as sortPromptCacheToolsByName, t as normalizePromptCapabilityIds } from "../prompt-cache-stability-D_MeCQFI.mjs";
|
|
6
|
+
import { C as splitSystemPromptRelocatableBoundary, S as splitSystemPromptCacheBoundary, T as stripSystemPromptRelocatableBoundary, _ as SYSTEM_PROMPT_CACHE_BOUNDARY, b as ensureSystemPromptCacheBoundary, c as serializeModelRequestBody, d as extractToolResultBlockText, f as extractToolResultText, h as preparedRequestSuffix, i as clampReasoning, l as describeToolResultMediaPlaceholder, n as buildBaseOptions, p as formatToolResultText, r as clampMaxTokensToModel, t as adjustMaxTokensForThinking, u as describeUnsupportedToolResultMedia, v as SYSTEM_PROMPT_RELOCATABLE_BOUNDARY, w as stripSystemPromptCacheBoundary, x as prependSystemPromptAdditionAfterCacheBoundary, y as SYSTEM_PROMPT_RELOCATABLE_BOUNDARY_END } from "../simple-options-BYgC6kse.mjs";
|
|
7
|
+
import { t as projectCopilotRequestFacts } from "../github-copilot-request-facts-F-EmvkpW.mjs";
|
|
8
|
+
import { n as matchesContextOverflowMessage } from "../overflow-DJHXTNBQ.mjs";
|
|
7
9
|
//#region packages/ai/src/utils/tls-certificate-errors.ts
|
|
8
10
|
const HOSTNAME_MISMATCH_CODES = /* @__PURE__ */ new Set(["ERR_TLS_CERT_ALTNAME_INVALID", "HOSTNAME_MISMATCH"]);
|
|
9
11
|
const CERTIFICATE_INVALID_CODES = /* @__PURE__ */ new Set([
|
|
@@ -95,4 +97,4 @@ function inspectTlsCertificateError(error) {
|
|
|
95
97
|
return inspectTlsCertificateErrorInternal(error, /* @__PURE__ */ new Set(), 0);
|
|
96
98
|
}
|
|
97
99
|
//#endregion
|
|
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, isCredentialFieldName, isImageWithMediaPayload, isReasoningOnlyLengthAssistantTurn, isStreamErrorFallbackContent, normalizePromptCapabilityIds, normalizeStructuredPromptSection, prependSystemPromptAdditionAfterCacheBoundary, projectCopilotRequestFacts, projectProviderError, readAssistantThinkingAppend, resolveFailedAssistantReplay, sanitizeSurrogates, sortPromptCacheToolsByName, splitSystemPromptCacheBoundary, splitSystemPromptRelocatableBoundary, stripSystemPromptCacheBoundary, stripSystemPromptRelocatableBoundary, transformMessages };
|
|
100
|
+
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, isCredentialFieldName, isImageWithMediaPayload, isReasoningOnlyLengthAssistantTurn, isStreamErrorFallbackContent, matchesContextOverflowMessage, normalizePromptCapabilityIds, normalizeStructuredPromptSection, preparedRequestSuffix, prependSystemPromptAdditionAfterCacheBoundary, projectCopilotRequestFacts, projectProviderError, readAssistantThinkingAppend, resolveFailedAssistantReplay, sanitizeSurrogates, serializeModelRequestBody, sortPromptCacheToolsByName, splitSystemPromptCacheBoundary, splitSystemPromptRelocatableBoundary, stripSystemPromptCacheBoundary, stripSystemPromptRelocatableBoundary, transformMessages };
|