@openclaw/ai 2026.10.10 → 2026.11.5-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 -1
- package/dist/.source-module-urls/fe058cc430242ce2ab0dfbcbe153e240a52cf9c3072c3dc0a73e5f956b6ba49b.json +1 -0
- package/dist/anthropic-CTND83W3.mjs +182 -0
- package/dist/{anthropic-payload-policy-rqCq9sT_.d.mts → anthropic-payload-policy-CXCJ5Pmj.d.mts} +21 -4
- package/dist/{anthropic-stream-reducer-C__ByTq1.mjs → anthropic-stream-lifecycle-rJe4OH5H.mjs} +845 -649
- package/dist/{anthropic-tool-projection-JTvMo4KG.d.mts → anthropic-tool-projection-D5DyrL6C.d.mts} +6 -7
- package/dist/{anthropic-tool-projection-DA_KeluM.mjs → anthropic-tool-projection-dGRfr4iT.mjs} +22 -32
- package/dist/{api-registry-gDt0faai.d.mts → api-registry-DY2MLUyg.d.mts} +2 -2
- package/dist/assistant-output-CD4kY9gu.mjs +16 -0
- package/dist/{azure-openai-responses-DHzTwi-y.mjs → azure-openai-responses-BhoLtP4Z.mjs} +46 -52
- package/dist/{cloudflare-Dttf8jKq.mjs → cloudflare-BJ2_Xabx.mjs} +1 -1
- package/dist/{credential-redaction-XvsPf7Yi.d.mts → credential-redaction-DrgndwTJ.d.mts} +5 -3
- package/dist/{deferred-event-buffer-DAvyP7qA.mjs → deferred-event-buffer-tIGkTkTm.mjs} +1 -2
- package/dist/{diagnostics-Cv7cW3pS.mjs → diagnostics-CloVGQiK.mjs} +42 -19
- package/dist/{diagnostics-DzrF1h4J.mjs → diagnostics-o1PrVNQb.mjs} +11 -4
- package/dist/diagnostics.d.mts +6 -7
- package/dist/diagnostics.mjs +4 -4
- package/dist/{env-api-keys-Xd8dm_aV.mjs → env-api-keys-BuHc86ya.mjs} +1 -26
- package/dist/event-stream-B4ZcSvsu.d.mts +1 -0
- package/dist/{event-stream-CzpE1g_o.d.mts → event-stream-BYmtRe8-.d.mts} +1 -1
- package/dist/event-stream.d.mts +2 -2
- package/dist/event-stream.mjs +1 -2
- package/dist/expect-lbe3Hgrh.mjs +8 -0
- package/dist/{github-copilot-request-facts-F-EmvkpW.mjs → github-copilot-request-facts-BZ_EMo7X.mjs} +1 -1
- package/dist/{google-CZ6uGVkV.mjs → google-1uObh-eI.mjs} +7 -8
- package/dist/{google-interactions-qd4flmND.mjs → google-interactions-CY8Xb87S.mjs} +208 -233
- package/dist/{google-messages-B-svbJuN.mjs → google-messages-CwBqSoa4.mjs} +16 -13
- package/dist/{google-provider-stream-DlhaCvCf.mjs → google-provider-stream-D30s9EZp.mjs} +17 -10
- package/dist/{google-shared-Cif7nve-.mjs → google-shared-li0lmEZK.mjs} +70 -42
- package/dist/{google-vertex-BZTcYnWU.mjs → google-vertex-B5CHglca.mjs} +3 -3
- package/dist/{host-rCxf5Tjd.mjs → host-DX7ORpeH.mjs} +57 -46
- package/dist/{host-jJOffdlW.d.mts → host-ccbwPC3A.d.mts} +17 -9
- package/dist/{host-policy-Ci1cKluf.mjs → host-policy-jCZebuXx.mjs} +2 -2
- package/dist/index-Bczt0MnO.d.mts +17 -0
- package/dist/index.d.mts +8 -7
- package/dist/index.mjs +9 -7
- package/dist/internal/anthropic.d.mts +21 -26
- package/dist/internal/anthropic.mjs +6 -6
- package/dist/internal/google-model-family.mjs +1 -1
- package/dist/internal/google.d.mts +15 -0
- package/dist/internal/google.mjs +1 -0
- package/dist/internal/model-request-body.d.mts +37 -0
- package/dist/internal/model-request-body.mjs +106 -0
- package/dist/internal/openai-completions-compat.d.mts +5 -1
- package/dist/internal/openai-completions-compat.mjs +3 -2
- 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 +14 -12
- package/dist/internal/openai.mjs +11 -10
- package/dist/internal/reasoning-tag-text-partitioner.d.mts +26 -0
- package/dist/{reasoning-tag-text-partitioner-DzlRubwU.mjs → internal/reasoning-tag-text-partitioner.mjs} +313 -122
- package/dist/internal/retry-after.d.mts +2 -2
- package/dist/internal/retry-after.mjs +165 -27
- package/dist/internal/runtime.d.mts +15 -41
- package/dist/internal/runtime.mjs +9 -10
- package/dist/internal/shared.d.mts +21 -25
- package/dist/internal/shared.mjs +9 -98
- package/dist/internal/tool-schema.d.mts +10 -10
- package/dist/internal/tool-schema.mjs +4 -4
- package/dist/{llm-request-activity-CfMuh5cC.mjs → llm-request-activity-DzaHoRAU.mjs} +2 -2
- package/dist/mistral-F5_asrmU.mjs +3741 -0
- package/dist/mistral.LICENSE +201 -0
- package/dist/{model-transport-url-BrsjjdjR.d.mts → model-transport-url-BdksnBqu.d.mts} +6 -8
- package/dist/{number-coercion-37gmNkuA.mjs → number-coercion-C7HsBgUL.mjs} +7 -2
- package/dist/observe-async-iterator-AlARO5wS.d.mts +178 -0
- package/dist/observe-async-iterator-DgmegcZR.mjs +181 -0
- package/dist/{openai-chatgpt-responses-iGYDPbmc.mjs → openai-chatgpt-responses-BIK7HROH.mjs} +61 -80
- package/dist/{openai-completions-CDy5u1mv.mjs → openai-completions-ClJ7QHEB.mjs} +5 -5
- package/dist/{openai-completions-compat-CBvb2eld.d.mts → openai-completions-compat-CJ-NsDzg.d.mts} +12 -6
- package/dist/{openai-completions-compat-CJ0OXZgi.mjs → openai-completions-compat-CstlTQuF.mjs} +74 -50
- package/dist/openai-completions-reasoning-replay-BwT1xwRI.mjs +45 -0
- package/dist/{openai-completions-transport-DLrm5EWi.mjs → openai-completions-transport-C6J4_oGf.mjs} +501 -563
- package/dist/{openai-prompt-cache-DgjD-UL5.d.mts → openai-prompt-cache-BZGaIWYh.d.mts} +4 -4
- package/dist/{openai-prompt-cache-h8vXRiaH.mjs → openai-prompt-cache-CgDoFhO0.mjs} +5 -4
- package/dist/openai-responses-Beifmf1s.mjs +89 -0
- package/dist/{openai-responses-compaction-replay-DUBbsfku.d.mts → openai-responses-compaction-replay-CNHk6k53.d.mts} +4 -4
- package/dist/{openai-responses-contracts-gnl6ZRs1.d.mts → openai-responses-contracts-BXMcvO7F.d.mts} +4 -10
- package/dist/{openai-responses-contracts-DCG51Us0.mjs → openai-responses-contracts-xU-n9AJJ.mjs} +36 -37
- package/dist/{openai-responses-endpoint-JbBT8IDv.mjs → openai-responses-endpoint-DCkURKS0.mjs} +55 -8
- package/dist/{openai-responses-payload-policy-BzM52TTH.d.mts → openai-responses-payload-policy-DyE30gdD.d.mts} +7 -7
- package/dist/{openai-responses-request-lifecycle-DuMpdA6y.mjs → openai-responses-request-lifecycle-o-ODC_rF.mjs} +12 -26
- package/dist/{openai-responses-shared-CNfHudFg.mjs → openai-responses-shared-CrFDkZ0N.mjs} +637 -389
- package/dist/{openai-responses-terminal-usage-CpVjkqn-.d.mts → openai-responses-terminal-usage-D7IhRA6i.d.mts} +9 -3
- package/dist/{openai-tool-schema-CGhEl7ao.mjs → openai-tool-schema-CsoYgnWy.mjs} +97 -122
- package/dist/otel-D-BkX8bB.mjs +766 -0
- package/dist/{overflow-OF3PgPbw.mjs → overflow-CpApyjG2.mjs} +1 -1
- package/dist/{positive-integer-Bb4Evc7L.mjs → positive-integer-DiqE5vNi.mjs} +2 -3
- package/dist/{prompt-cache-stability-D_MeCQFI.mjs → prompt-cache-stability-w-ICeyOI.mjs} +1 -1
- package/dist/{provider-error-qtZD2inE.mjs → provider-error-DD-fo4Rz.mjs} +71 -234
- package/dist/{provider-options-Bo8GzTGX.d.mts → provider-options-Mo8NM5d1.d.mts} +15 -4
- package/dist/{provider-replay-context-BC23HyZo.mjs → provider-replay-context-xyU7-CiT.mjs} +2 -2
- package/dist/provider-transcript-transform-BHq3Q4nc.mjs +32 -0
- package/dist/{provider-transport-turn-state-B11rmZpv.mjs → provider-transport-turn-state-DQd9K4Pd.mjs} +3 -3
- package/dist/{provider-types-ODq57rG_.d.mts → provider-types-B1e98js5.d.mts} +6 -4
- package/dist/provider-types.d.mts +7 -6
- package/dist/provider-types.mjs +2 -1
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +26 -29
- package/dist/{record-coerce-CNDovvft.mjs → record-coerce-BQaoiN3r.mjs} +4 -1
- package/dist/request-headers-DO4Mqhw1.mjs +10 -0
- package/dist/{required-api-key-D088S4Cd.mjs → required-api-key-2zZTkmsi.mjs} +1 -1
- package/dist/retry-after-DnHBlFS2.d.mts +45 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/{sanitize-unicode-ZqVLLEKC.d.mts → sanitize-unicode-BISmUlUv.d.mts} +2 -2
- package/dist/{simple-options-BdJJbzZk.mjs → simple-options-tLSeECry.mjs} +108 -82
- package/dist/src-BUsVkrNt.mjs +105 -0
- package/dist/{src-CyA0zJnt.mjs → src-CQ7nH2mL.mjs} +4 -7
- package/dist/stable-stringify-CchQEmeA.mjs +84 -0
- package/dist/{stream-DQqGjhbq.mjs → stream-DrtAWu7c.mjs} +2 -6
- package/dist/{stream-first-event-timeout-D_TfJHRJ.mjs → stream-first-event-timeout-B7RcufAV.mjs} +16 -13
- package/dist/{string-coerce-Cj8sqWHx.mjs → string-coerce-BCuWMIrk.mjs} +1 -1
- package/dist/string-normalization-B8TDDBX_.mjs +32 -0
- package/dist/telemetry-B9f7K_Xe.mjs +582 -0
- package/dist/{tool-schema-json-projection-Cvq69Ajp.mjs → tool-schema-json-projection-BQpiJlXJ.mjs} +53 -69
- package/dist/{transport-stream-shared-DdnJGEj0.mjs → transport-stream-shared-D2uFMhMc.mjs} +177 -93
- package/dist/{transport-stream-shared-8ru8eX4s.d.mts → transport-stream-shared-D3IAU4jn.d.mts} +29 -15
- package/dist/{transport-utils-CcCAuFVS.mjs → transport-utils-Da_39MYi.mjs} +23 -38
- package/dist/transports.d.mts +39 -38
- package/dist/transports.mjs +214 -295
- package/dist/{types-CVYzKrMl.d.mts → types-BVdTf0YV.d.mts} +38 -3
- package/dist/types-Cb3-5WM9.d.mts +1 -0
- package/dist/{types-BXd0kI8-.mjs → types-OVEWUaDh.mjs} +3 -1
- package/dist/types.d.mts +7 -6
- package/dist/types.mjs +7 -5
- package/dist/{validation-9FSkE8T-.mjs → validation-DGXqfvkj.mjs} +45 -27
- package/dist/{validation-BQ5u20Ru.d.mts → validation-QmyD0E5A.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -2
- package/package.json +40 -6
- package/dist/anthropic-B54Ts1tV.mjs +0 -221
- package/dist/assistant-output-DbgdWAhJ.mjs +0 -47
- package/dist/event-stream-CDpFza-M.d.mts +0 -1
- package/dist/index-DSprYWaz.d.mts +0 -185
- package/dist/mistral-C_ImzxlK.mjs +0 -512
- package/dist/model-request-body-BD5vy4rP.d.mts +0 -17
- package/dist/openai-responses-Cp2QPq7K.mjs +0 -87
- package/dist/retry-after-sw-XX8aC.d.mts +0 -15
- package/dist/types-CBJthzJX.d.mts +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./types-
|
|
1
|
+
import { P as OpenAICompletionsCompat, at as StreamOptions, k as Model, l as CacheRetention } from "./types-BVdTf0YV.mjs";
|
|
2
|
+
import "./types-Cb3-5WM9.mjs";
|
|
3
3
|
//#region packages/ai/src/providers/openai-prompt-cache.d.ts
|
|
4
4
|
/** Selects documented lifetime fields shared by Responses and Chat Completions. */
|
|
5
|
-
declare function resolveOpenAIPromptCacheParams(model: Pick<Model, "id" | "provider" | "baseUrl">, cacheRetention: CacheRetention, compat: Required<Pick<OpenAICompletionsCompat, "supportsPromptCacheKey" | "supportsLongCacheRetention"
|
|
5
|
+
declare function resolveOpenAIPromptCacheParams(model: Pick<Model, "id" | "provider" | "baseUrl">, cacheRetention: CacheRetention, compat: Required<Pick<OpenAICompletionsCompat, "supportsPromptCacheKey" | "supportsLongCacheRetention">>, promptCacheTtl?: StreamOptions["promptCacheTtl"]): {
|
|
6
6
|
prompt_cache_retention?: "24h";
|
|
7
7
|
prompt_cache_options?: {
|
|
8
|
-
ttl: "30m";
|
|
8
|
+
ttl: "30m" | "12h";
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
11
|
/** Maximum prompt cache key length accepted by OpenAI-compatible request metadata. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as isNativeOpenAIEndpoint } from "./openai-completions-compat-CstlTQuF.mjs";
|
|
2
2
|
//#region packages/normalization-core/src/code-points.ts
|
|
3
3
|
/** Truncates to a nonnegative code-point budget; grapheme clusters may be split. */
|
|
4
4
|
function truncateCodePoints(text, maxCodePoints) {
|
|
@@ -28,10 +28,11 @@ const EXTENDED_RETENTION_MODELS = /* @__PURE__ */ new Set([
|
|
|
28
28
|
"gpt-4.1"
|
|
29
29
|
]);
|
|
30
30
|
/** Selects documented lifetime fields shared by Responses and Chat Completions. */
|
|
31
|
-
function resolveOpenAIPromptCacheParams(model, cacheRetention, compat) {
|
|
32
|
-
if (cacheRetention
|
|
31
|
+
function resolveOpenAIPromptCacheParams(model, cacheRetention, compat, promptCacheTtl) {
|
|
32
|
+
if (cacheRetention === "none" || !compat.supportsPromptCacheKey || !compat.supportsLongCacheRetention) return {};
|
|
33
33
|
const version = /^gpt-(\d+)(?:\.(\d+))?(?:-|$)/.exec(model.id);
|
|
34
|
-
if (version && (Number(version[1]) > 5 || Number(version[1]) === 5 && Number(version[2]) >= 6)) return { prompt_cache_options: { ttl: "30m" } };
|
|
34
|
+
if (version && (Number(version[1]) > 5 || Number(version[1]) === 5 && Number(version[2]) >= 6)) return promptCacheTtl || cacheRetention === "long" ? { prompt_cache_options: { ttl: promptCacheTtl ?? "30m" } } : {};
|
|
35
|
+
if (cacheRetention !== "long") return {};
|
|
35
36
|
const modelId = model.id.replace(/-\d{4}-\d{2}-\d{2}$/, "");
|
|
36
37
|
return !isNativeOpenAIEndpoint(model) || EXTENDED_RETENTION_MODELS.has(modelId) ? { prompt_cache_retention: "24h" } : {};
|
|
37
38
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { t as AssistantMessageEventStream } from "./event-stream-X2gmsUWv.mjs";
|
|
3
|
+
import { n as clampOpenAIPromptCacheKey, r as resolveOpenAIPromptCacheParams } from "./openai-prompt-cache-CgDoFhO0.mjs";
|
|
4
|
+
import { a as resolveOpenAICompletionsCompat } from "./openai-completions-compat-CstlTQuF.mjs";
|
|
5
|
+
import { i as resolveCacheRetention, r as buildCopilotDynamicHeaders } from "./cloudflare-BJ2_Xabx.mjs";
|
|
6
|
+
import { n as buildBaseOptions } from "./simple-options-tLSeECry.mjs";
|
|
7
|
+
import { n as getEnvApiKey } from "./env-api-keys-BuHc86ya.mjs";
|
|
8
|
+
import { t as createAssistantOutput } from "./assistant-output-CD4kY9gu.mjs";
|
|
9
|
+
import { F as convertProviderResponsesMessages, n as applyResponsesServiceTierPricing, r as runResponsesStreamLifecycle, t as applyCommonResponsesParams, vt as resolveOpenAISimpleReasoningEffort } from "./openai-responses-shared-CrFDkZ0N.mjs";
|
|
10
|
+
import { i as createOpenAIProviderClient, n as resolveProviderSimpleCompletionHeaders } from "./provider-transport-turn-state-DQd9K4Pd.mjs";
|
|
11
|
+
import { t as requireApiKey } from "./required-api-key-2zZTkmsi.mjs";
|
|
12
|
+
//#region packages/ai/src/providers/openai-responses.ts
|
|
13
|
+
var openai_responses_exports = /* @__PURE__ */ __exportAll({
|
|
14
|
+
streamOpenAIResponses: () => streamOpenAIResponses,
|
|
15
|
+
streamSimpleOpenAIResponses: () => streamSimpleOpenAIResponses
|
|
16
|
+
});
|
|
17
|
+
const OPENAI_TOOL_CALL_PROVIDERS = /* @__PURE__ */ new Set(["openai", "opencode"]);
|
|
18
|
+
function getCompat(model) {
|
|
19
|
+
return {
|
|
20
|
+
...resolveOpenAICompletionsCompat(model),
|
|
21
|
+
sendSessionIdHeader: model.compat?.sendSessionIdHeader ?? true
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const streamOpenAIResponses = (model, context, options) => {
|
|
25
|
+
const stream = new AssistantMessageEventStream();
|
|
26
|
+
const output = createAssistantOutput(model);
|
|
27
|
+
runResponsesStreamLifecycle({
|
|
28
|
+
stream,
|
|
29
|
+
model,
|
|
30
|
+
output,
|
|
31
|
+
context,
|
|
32
|
+
options,
|
|
33
|
+
createClient: () => {
|
|
34
|
+
const apiKey = options?.apiKey || getEnvApiKey(model.provider) || "";
|
|
35
|
+
const cacheSessionId = resolveCacheRetention(options?.cacheRetention) === "none" ? void 0 : options?.sessionId;
|
|
36
|
+
if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
|
|
37
|
+
const compat = getCompat(model);
|
|
38
|
+
const headers = { ...model.headers };
|
|
39
|
+
if (model.provider === "github-copilot") Object.assign(headers, buildCopilotDynamicHeaders(context.messages));
|
|
40
|
+
if (cacheSessionId) {
|
|
41
|
+
if (compat.sendSessionIdHeader) headers.session_id = cacheSessionId;
|
|
42
|
+
headers["x-client-request-id"] = cacheSessionId;
|
|
43
|
+
}
|
|
44
|
+
return createOpenAIProviderClient(model, apiKey, headers, resolveProviderSimpleCompletionHeaders(model, options), options?.onResponse);
|
|
45
|
+
},
|
|
46
|
+
buildParams: (_requestModel, replayMode) => {
|
|
47
|
+
const messages = convertProviderResponsesMessages(model, context, OPENAI_TOOL_CALL_PROVIDERS, {
|
|
48
|
+
replayResponsesItemIds: options?.replayResponsesItemIds ?? false,
|
|
49
|
+
sessionId: options?.sessionId,
|
|
50
|
+
authProfileId: options?.authProfileId,
|
|
51
|
+
mutableInput: Boolean(options?.onPayload),
|
|
52
|
+
replayMode
|
|
53
|
+
});
|
|
54
|
+
const cacheRetention = resolveCacheRetention(options?.cacheRetention);
|
|
55
|
+
const compat = getCompat(model);
|
|
56
|
+
const params = {
|
|
57
|
+
model: model.id,
|
|
58
|
+
input: messages,
|
|
59
|
+
stream: true,
|
|
60
|
+
prompt_cache_key: cacheRetention === "none" || !compat.supportsPromptCacheKey ? void 0 : clampOpenAIPromptCacheKey(options?.promptCacheKey ?? options?.sessionId),
|
|
61
|
+
...resolveOpenAIPromptCacheParams(model, cacheRetention, compat, options?.promptCacheTtl),
|
|
62
|
+
store: false
|
|
63
|
+
};
|
|
64
|
+
if (options?.serviceTier !== void 0) params.service_tier = options.serviceTier;
|
|
65
|
+
applyCommonResponsesParams(params, model, context, options, { setDefaultReasoningOff: model.provider !== "github-copilot" });
|
|
66
|
+
return params;
|
|
67
|
+
},
|
|
68
|
+
processStreamOptions: {
|
|
69
|
+
serviceTier: options?.serviceTier,
|
|
70
|
+
applyServiceTierPricing: (usage, serviceTier) => applyResponsesServiceTierPricing(usage, serviceTier, model)
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return stream;
|
|
74
|
+
};
|
|
75
|
+
const streamSimpleOpenAIResponses = (model, context, options) => {
|
|
76
|
+
const apiKey = requireApiKey(model.provider, options?.apiKey);
|
|
77
|
+
const base = buildBaseOptions(model, options, apiKey);
|
|
78
|
+
const replayOptions = options;
|
|
79
|
+
return streamOpenAIResponses(model, context, {
|
|
80
|
+
...base,
|
|
81
|
+
authProfileId: replayOptions?.authProfileId,
|
|
82
|
+
openclawCodeModeToolSurface: replayOptions?.openclawCodeModeToolSurface,
|
|
83
|
+
openclawCodeModeAllowedHostedToolTypes: replayOptions?.openclawCodeModeAllowedHostedToolTypes,
|
|
84
|
+
reasoningEffort: resolveOpenAISimpleReasoningEffort(model, options?.reasoning),
|
|
85
|
+
replayResponsesItemIds: replayOptions?.replayResponsesItemIds
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
//#endregion
|
|
89
|
+
export { streamOpenAIResponses as n, streamSimpleOpenAIResponses as r, openai_responses_exports as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import
|
|
3
|
-
import "./provider-options-
|
|
4
|
-
import { i as ReplayableResponseCompactionItem, r as OpenAIResponsesReasoningReplayMetadata, u as OpenAIResponsesCompactionOutput } from "./openai-responses-contracts-
|
|
1
|
+
import { a as AssistantMessage, k as Model } from "./types-BVdTf0YV.mjs";
|
|
2
|
+
import "./index-Bczt0MnO.mjs";
|
|
3
|
+
import "./provider-options-Mo8NM5d1.mjs";
|
|
4
|
+
import { i as ReplayableResponseCompactionItem, r as OpenAIResponsesReasoningReplayMetadata, u as OpenAIResponsesCompactionOutput } from "./openai-responses-contracts-BXMcvO7F.mjs";
|
|
5
5
|
import "openai/resources/responses/responses.js";
|
|
6
6
|
//#region packages/ai/src/transports/openai-responses-compaction-replay.d.ts
|
|
7
7
|
declare function captureOpenAIResponsesCompaction(output: Pick<AssistantMessage, "providerReplay">, item: ReplayableResponseCompactionItem, boundary: number | "retained-users", model: Model, captureMetadata?: OpenAIResponsesReasoningReplayMetadata, compactedOutput?: OpenAIResponsesCompactionOutput, outputTokens?: number): void;
|
package/dist/{openai-responses-contracts-gnl6ZRs1.d.mts → openai-responses-contracts-BXMcvO7F.d.mts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import "./
|
|
1
|
+
import { N as ModelThinkingLevel, k as Model, n as Api } from "./types-BVdTf0YV.mjs";
|
|
2
|
+
import "./index-Bczt0MnO.mjs";
|
|
3
|
+
import "./types-Cb3-5WM9.mjs";
|
|
4
|
+
import { a as BaseOpenAIStreamOptions, b as OpenAIReasoningEffort } from "./provider-options-Mo8NM5d1.mjs";
|
|
5
5
|
import { Response, ResponseCompactionItem, ResponseCreateParamsStreaming, ResponseInputItem, ResponseOutputMessage, ResponseReasoningItem } from "openai/resources/responses/responses.js";
|
|
6
6
|
//#region packages/ai/src/providers/openai-request-reasoning.d.ts
|
|
7
7
|
type OpenAIRequestReasoningEffort = ModelThinkingLevel | "none";
|
|
@@ -53,12 +53,6 @@ type ResponsesPromptObservation = {
|
|
|
53
53
|
expectedChars: number;
|
|
54
54
|
observedChars: number;
|
|
55
55
|
matchesAssembledPrompt: boolean;
|
|
56
|
-
model?: string;
|
|
57
|
-
reasoningEffort?: string;
|
|
58
|
-
sessionsSpawn?: {
|
|
59
|
-
strict?: boolean;
|
|
60
|
-
categoryRequired: boolean;
|
|
61
|
-
};
|
|
62
56
|
};
|
|
63
57
|
type ResponsesPromptObserver = (observation: ResponsesPromptObservation) => void;
|
|
64
58
|
declare const responsesPromptObserver: {
|
package/dist/{openai-responses-contracts-DCG51Us0.mjs → openai-responses-contracts-xU-n9AJJ.mjs}
RENAMED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { i as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE } from "./types-
|
|
2
|
-
import { i as asOptionalRecord, o as isRecord } from "./record-coerce-
|
|
3
|
-
import {
|
|
1
|
+
import { i as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE } from "./types-OVEWUaDh.mjs";
|
|
2
|
+
import { a as asRecord, i as asOptionalRecord, o as isRecord, r as asOptionalObjectRecord } from "./record-coerce-BQaoiN3r.mjs";
|
|
3
|
+
import { r as normalizeLowercaseStringOrEmpty } from "./string-coerce-BCuWMIrk.mjs";
|
|
4
|
+
import { r as normalizeUniqueTrimmedStringList } from "./string-normalization-B8TDDBX_.mjs";
|
|
4
5
|
//#region packages/llm-core/src/model-data.ts
|
|
5
6
|
const MODEL_DATA_APIS = [
|
|
6
7
|
"openai-completions",
|
|
@@ -68,30 +69,19 @@ function listMappedModelThinkingLevels(model) {
|
|
|
68
69
|
return MODEL_CATALOG_THINKING_LEVELS.filter((level) => mapped.has(level));
|
|
69
70
|
}
|
|
70
71
|
//#endregion
|
|
71
|
-
//#region packages/
|
|
72
|
-
/**
|
|
73
|
-
function
|
|
74
|
-
|
|
72
|
+
//#region packages/ai/src/transports/openai-reasoning-compat.ts
|
|
73
|
+
/** Explicit model reasoning-effort compatibility metadata. */
|
|
74
|
+
function readCompatReasoningEffortMap(compat) {
|
|
75
|
+
const rawMap = asOptionalObjectRecord(asOptionalObjectRecord(compat)?.reasoningEffortMap);
|
|
76
|
+
if (!rawMap) return {};
|
|
77
|
+
return Object.fromEntries(Object.entries(rawMap).filter((entry) => typeof entry[1] === "string"));
|
|
75
78
|
}
|
|
76
|
-
/**
|
|
77
|
-
function
|
|
78
|
-
return
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return uniqueValues(values);
|
|
83
|
-
}
|
|
84
|
-
/** Normalizes array-backed string lists and rejects non-array input as empty. */
|
|
85
|
-
function normalizeTrimmedStringList(value) {
|
|
86
|
-
if (!Array.isArray(value)) return [];
|
|
87
|
-
return value.flatMap((entry) => {
|
|
88
|
-
const normalized = normalizeOptionalString(entry);
|
|
89
|
-
return normalized ? [normalized] : [];
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
/** Normalizes an array-backed string list and removes duplicates. */
|
|
93
|
-
function normalizeUniqueTrimmedStringList(value) {
|
|
94
|
-
return uniqueStrings(normalizeTrimmedStringList(value));
|
|
79
|
+
/** Resolves the reasoning effort remap for an OpenAI-compatible model. */
|
|
80
|
+
function resolveOpenAIReasoningEffortMap(model, fallbackMap = {}) {
|
|
81
|
+
return {
|
|
82
|
+
...fallbackMap,
|
|
83
|
+
...readCompatReasoningEffortMap(model.compat)
|
|
84
|
+
};
|
|
95
85
|
}
|
|
96
86
|
//#endregion
|
|
97
87
|
//#region packages/ai/src/providers/openai-reasoning-effort.ts
|
|
@@ -208,13 +198,6 @@ function normalizeOpenAIReasoningEffort(effort) {
|
|
|
208
198
|
const folded = trimmed.toLowerCase();
|
|
209
199
|
return CANONICAL_REASONING_EFFORTS.has(folded) ? folded : trimmed;
|
|
210
200
|
}
|
|
211
|
-
function readCompatReasoningEfforts(compat) {
|
|
212
|
-
if (!compat || typeof compat !== "object") return;
|
|
213
|
-
if (compat.supportsReasoningEffort === false) return [];
|
|
214
|
-
const raw = compat.supportedReasoningEfforts;
|
|
215
|
-
if (!Array.isArray(raw)) return;
|
|
216
|
-
return normalizeUniqueTrimmedStringList(raw);
|
|
217
|
-
}
|
|
218
201
|
function isDisabledReasoningEffort(effort) {
|
|
219
202
|
return effort === "none" || effort === "off";
|
|
220
203
|
}
|
|
@@ -224,8 +207,12 @@ function resolveOpenAISupportedReasoningEfforts(model) {
|
|
|
224
207
|
}
|
|
225
208
|
/** Read a declared or known model contract, leaving unknown compatible models unspecified. */
|
|
226
209
|
function resolveOpenAIModelReasoningEfforts(model) {
|
|
227
|
-
const
|
|
228
|
-
if (
|
|
210
|
+
const compat = model.compat;
|
|
211
|
+
if (compat && typeof compat === "object") {
|
|
212
|
+
if (compat.supportsReasoningEffort === false) return [];
|
|
213
|
+
const raw = compat.supportedReasoningEfforts;
|
|
214
|
+
if (Array.isArray(raw)) return normalizeUniqueTrimmedStringList(raw);
|
|
215
|
+
}
|
|
229
216
|
const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
|
|
230
217
|
const api = resolveOpenAIThinkingApi(model.api);
|
|
231
218
|
const supportsMax = api !== "openai-completions";
|
|
@@ -258,7 +245,10 @@ function supportsOpenAITemperature(model) {
|
|
|
258
245
|
}
|
|
259
246
|
/** Return whether a model accepts a requested reasoning effort. */
|
|
260
247
|
function supportsOpenAIReasoningEffort(model, effort) {
|
|
261
|
-
|
|
248
|
+
const requested = normalizeOpenAIReasoningEffort(effort);
|
|
249
|
+
const supported = resolveOpenAIModelReasoningEfforts(model);
|
|
250
|
+
if (supported !== void 0) return supported.includes(requested);
|
|
251
|
+
return GENERIC_REASONING_EFFORTS.some((value) => value === requested) || [...Object.values(resolveOpenAIReasoningEffortMap({ compat: model.compat })), ...Object.values(asRecord(model.thinkingLevelMap))].some((value) => typeof value === "string" && value.trim() === requested);
|
|
262
252
|
}
|
|
263
253
|
/** Read provider mappings without folding provider-native labels. */
|
|
264
254
|
function resolveOpenAIReasoningEffortMapping(effort, mapping) {
|
|
@@ -311,6 +301,15 @@ const OPENAI_RESPONSES_APIS = /* @__PURE__ */ new Set([
|
|
|
311
301
|
"openclaw-openai-chatgpt-responses-transport",
|
|
312
302
|
"openclaw-azure-openai-responses-transport"
|
|
313
303
|
]);
|
|
304
|
+
const OPENAI_RESPONSES_TOOL_CALL_PROVIDERS = /* @__PURE__ */ new Set([
|
|
305
|
+
"openai",
|
|
306
|
+
"opencode",
|
|
307
|
+
"azure-openai-responses",
|
|
308
|
+
"github-copilot"
|
|
309
|
+
]);
|
|
310
|
+
function isResponsesTerminalEventType(value) {
|
|
311
|
+
return value === "response.completed" || value === "response.incomplete" || value === "response.failed";
|
|
312
|
+
}
|
|
314
313
|
var OpenAIResponsesWebSocketPreDispatchError = class extends Error {
|
|
315
314
|
constructor(cause) {
|
|
316
315
|
super("OpenAI Responses WebSocket failed before request dispatch", { cause });
|
|
@@ -405,4 +404,4 @@ const responsesServiceTierObserver = {
|
|
|
405
404
|
}
|
|
406
405
|
};
|
|
407
406
|
//#endregion
|
|
408
|
-
export {
|
|
407
|
+
export { resolveOpenAIReasoningEffortMapping as A, isOpenAIGpt54MiniModel as C, normalizeOpenAIReasoningEffort as D, isOpenAIGpt6Model as E, MODEL_CATALOG_THINKING_LEVELS as F, listMappedModelThinkingLevels as I, resolveModelServiceTierContextTokens as L, supportsOpenAIReasoningEffort as M, supportsOpenAITemperature as N, resolveOpenAIModelReasoningEfforts as O, resolveOpenAIReasoningEffortMap as P, resolveOpenAIThinkingApi as R, applyOpenAICompletionsToolReasoning as S, isOpenAIGpt56Model as T, parseOpenAIResponsesWebSocketServerError as _, OPENAI_RESPONSES_COMPACTION_REPLAY_TYPE as a, isResponsesServiceTierRejection as b, OPENAI_RESPONSES_RETAINED_COMPACTION_REPLAY_TYPE as c, OpenAIResponsesWebSocketPreDispatchError as d, OpenAIResponsesWebSocketSafeRetryError as f, isResponsesTerminalEventType as g, isPreviousResponseRejection as h, OPENAI_RESPONSES_APIS as i, resolveOpenAISupportedReasoningEfforts as j, resolveOpenAIReasoningEffortForModel as k, OPENAI_RESPONSES_TOOL_CALL_PROVIDERS as l, RESPONSE_FAILED_NO_DETAILS_MESSAGE as m, DEFAULT_AZURE_OPENAI_API_VERSION as n, OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY as o, RESPONSES_RETAINED_USER as p, OPENAI_CODEX_RESPONSES_DEFAULT_INSTRUCTIONS as r, OPENAI_RESPONSES_REASONING_REPLAY_META_KEY as s, AZURE_RESPONSES_FIRST_EVENT_TIMEOUT_MS as t, OpenAIResponsesWebSocketPostDispatchError as u, responsesPromptObserver as v, isOpenAIGpt55Model as w, nextResponsesServiceTier as x, responsesServiceTierObserver as y };
|
package/dist/{openai-responses-endpoint-JbBT8IDv.mjs → openai-responses-endpoint-DCkURKS0.mjs}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { o as isRecord } from "./record-coerce-
|
|
2
|
-
import { a as normalizeOptionalLowercaseString, l as readStringValue, n as normalizeFastMode, r as normalizeLowercaseStringOrEmpty } from "./string-coerce-
|
|
3
|
-
import {
|
|
1
|
+
import { o as isRecord } from "./record-coerce-BQaoiN3r.mjs";
|
|
2
|
+
import { a as normalizeOptionalLowercaseString, l as readStringValue, n as normalizeFastMode, r as normalizeLowercaseStringOrEmpty } from "./string-coerce-BCuWMIrk.mjs";
|
|
3
|
+
import { L as resolveModelServiceTierContextTokens, M as supportsOpenAIReasoningEffort, i as OPENAI_RESPONSES_APIS } from "./openai-responses-contracts-xU-n9AJJ.mjs";
|
|
4
4
|
import { t as canonicalizeBase64 } from "./base64-C8CdcsjU.mjs";
|
|
5
|
-
import { t as parsePositiveInteger } from "./positive-integer-
|
|
5
|
+
import { t as parsePositiveInteger } from "./positive-integer-DiqE5vNi.mjs";
|
|
6
6
|
import { n as createSseByteGuard } from "./streaming-byte-guard-DBXr1XYn.mjs";
|
|
7
7
|
//#region packages/model-catalog-core/src/provider-id.ts
|
|
8
8
|
function normalizeProviderId(provider) {
|
|
@@ -129,7 +129,13 @@ function stripDisabledOpenAIReasoningPayload(payloadObj) {
|
|
|
129
129
|
/** Strip returned-item metadata rejected by strict Responses-compatible endpoints. */
|
|
130
130
|
function stripInputItemStatuses(input) {
|
|
131
131
|
if (!Array.isArray(input)) return;
|
|
132
|
-
for (
|
|
132
|
+
for (let index = 0; index < input.length; index++) {
|
|
133
|
+
const item = input[index];
|
|
134
|
+
if (item && typeof item === "object" && !Array.isArray(item) && "status" in item) {
|
|
135
|
+
const { status: _, ...rest } = item;
|
|
136
|
+
input[index] = rest;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
133
139
|
}
|
|
134
140
|
/** Resolve payload mutation policy for one OpenAI Responses-style model endpoint. */
|
|
135
141
|
function resolveOpenAIResponsesPayloadPolicy(model, options = {}) {
|
|
@@ -137,7 +143,10 @@ function resolveOpenAIResponsesPayloadPolicy(model, options = {}) {
|
|
|
137
143
|
const storeMode = options.storeMode ?? "provider-policy";
|
|
138
144
|
const explicitStore = storeMode === "preserve" ? void 0 : storeMode === "disable" || storeMode === "transport-default" && !capabilities.explicitContinuationOptIn ? capabilities.supportsResponsesStoreField ? false : void 0 : capabilities.allowsResponsesStore || capabilities.explicitContinuationOptIn ? true : void 0;
|
|
139
145
|
const isResponsesApi = isOpenAIResponsesApi(normalizeOptionalLowercaseString(model.api));
|
|
140
|
-
const shouldStripDisabledReasoningPayload = isResponsesApi && !supportsOpenAIReasoningEffort(capabilities.usesKnownNativeOpenAIRoute ? model : {
|
|
146
|
+
const shouldStripDisabledReasoningPayload = isResponsesApi && !supportsOpenAIReasoningEffort(capabilities.usesKnownNativeOpenAIRoute ? model : {
|
|
147
|
+
compat: model.compat,
|
|
148
|
+
thinkingLevelMap: model.thinkingLevelMap
|
|
149
|
+
}, "none");
|
|
141
150
|
const shouldStripInputStatus = isResponsesApi && !capabilities.usesKnownNativeOpenAIRoute;
|
|
142
151
|
const serverCompactionPlan = resolveOpenAIResponsesServerCompactionPlan(model, options.extraParams);
|
|
143
152
|
const usesInstructionsField = readCompatPayloadBoolean(model.compat, "supportsInstructions") ?? capabilities.usesVerifiedInstructionsEndpoint;
|
|
@@ -239,11 +248,49 @@ function sanitizeInlineImageDataUrl(imageUrl) {
|
|
|
239
248
|
* auditable.
|
|
240
249
|
*/
|
|
241
250
|
const IMAGE_OMITTED_TEXT = "omitted image payload: invalid inline image data";
|
|
251
|
+
const sourceImages = /* @__PURE__ */ new WeakMap();
|
|
252
|
+
const inputImages = /* @__PURE__ */ new WeakMap();
|
|
253
|
+
/** Reuse scalar image work, never the mutable item exposed to payload hooks. */
|
|
254
|
+
function buildResponsesInputImage(source) {
|
|
255
|
+
const { mimeType, data } = source;
|
|
256
|
+
let payload = sourceImages.get(source);
|
|
257
|
+
if (!payload || payload.mimeType !== mimeType || payload.data !== data) {
|
|
258
|
+
payload = {
|
|
259
|
+
mimeType,
|
|
260
|
+
data
|
|
261
|
+
};
|
|
262
|
+
sourceImages.set(source, payload);
|
|
263
|
+
}
|
|
264
|
+
const url = `data:${mimeType};base64,${data}`;
|
|
265
|
+
const input = {
|
|
266
|
+
type: "input_image",
|
|
267
|
+
detail: "auto",
|
|
268
|
+
image_url: url
|
|
269
|
+
};
|
|
270
|
+
inputImages.set(input, {
|
|
271
|
+
url,
|
|
272
|
+
payload
|
|
273
|
+
});
|
|
274
|
+
return input;
|
|
275
|
+
}
|
|
276
|
+
function sanitizePreparedImage(payload, url) {
|
|
277
|
+
if (payload.sanitized === void 0) {
|
|
278
|
+
const normalizedUrl = sanitizeInlineImageDataUrl(url);
|
|
279
|
+
payload.sanitized = normalizedUrl ? {
|
|
280
|
+
mimeType: normalizedUrl.slice(5, normalizedUrl.indexOf(";")),
|
|
281
|
+
...normalizedUrl.slice(normalizedUrl.indexOf(",") + 1) === payload.data ? {} : { normalizedUrl }
|
|
282
|
+
} : false;
|
|
283
|
+
}
|
|
284
|
+
const sanitized = payload.sanitized;
|
|
285
|
+
return sanitized ? sanitized.normalizedUrl ?? (sanitized.mimeType === payload.mimeType ? url : `data:${sanitized.mimeType};base64,${payload.data}`) : void 0;
|
|
286
|
+
}
|
|
242
287
|
function sanitizeValue(value) {
|
|
243
288
|
if (Array.isArray(value)) return value.map(sanitizeValue);
|
|
244
289
|
if (!isRecord(value)) return value;
|
|
245
290
|
if (value.type === "input_image" && typeof value.image_url === "string") {
|
|
246
|
-
const
|
|
291
|
+
const url = value.image_url;
|
|
292
|
+
const prepared = inputImages.get(value);
|
|
293
|
+
const imageUrl = prepared?.url === url ? sanitizePreparedImage(prepared.payload, url) : sanitizeInlineImageDataUrl(url);
|
|
247
294
|
return imageUrl ? {
|
|
248
295
|
...value,
|
|
249
296
|
image_url: imageUrl
|
|
@@ -397,4 +444,4 @@ function supportsNativeOpenAIResponsesEndpoint(params) {
|
|
|
397
444
|
return params.provider.trim().toLowerCase() === "openai" && params.api === "openai-responses" && isOfficialOpenAIResponsesBaseUrl(params.baseUrl);
|
|
398
445
|
}
|
|
399
446
|
//#endregion
|
|
400
|
-
export { isOpenAIResponsesCompactionOutput as a,
|
|
447
|
+
export { isOpenAIResponsesCompactionOutput as a, sanitizeResponsesImagePayload as c, resolveOpenAIResponsesCompactEndpointPlan as d, resolveOpenAIResponsesPayloadPolicy as f, getOpenAIResponsesCompactionOutputError as i, applyOpenAIResponsesPayloadPolicy as l, resolveOpenAIResponsesServerCompactionPlan as m, supportsNativeOpenAIResponsesEndpoint as n, readOpenAIResponsesCompactionWindow as o, resolveOpenAIResponsesRequestContextTokens as p, createBoundedOpenAIResponsesCompactionFetch as r, buildResponsesInputImage as s, isOfficialOpenAIResponsesBaseUrl as t, normalizeOpenAIServiceTier as u };
|
|
@@ -7,12 +7,7 @@ type OpenAIResponsesPayloadModel = {
|
|
|
7
7
|
contextTokens?: unknown;
|
|
8
8
|
contextWindow?: unknown;
|
|
9
9
|
compat?: unknown;
|
|
10
|
-
|
|
11
|
-
type OpenAIResponsesPayloadPolicyOptions = {
|
|
12
|
-
extraParams?: Record<string, unknown>;
|
|
13
|
-
storeMode?: "provider-policy" | "transport-default" | "disable" | "preserve";
|
|
14
|
-
enablePromptCacheStripping?: boolean;
|
|
15
|
-
enableServerCompaction?: boolean;
|
|
10
|
+
thinkingLevelMap?: unknown;
|
|
16
11
|
};
|
|
17
12
|
type OpenAIResponsesPayloadPolicy = {
|
|
18
13
|
allowsServiceTier: boolean;
|
|
@@ -43,7 +38,12 @@ _purpose?: "manual" | "budget"): {
|
|
|
43
38
|
enabled: boolean;
|
|
44
39
|
};
|
|
45
40
|
/** Resolve payload mutation policy for one OpenAI Responses-style model endpoint. */
|
|
46
|
-
declare function resolveOpenAIResponsesPayloadPolicy(model: OpenAIResponsesPayloadModel, options?:
|
|
41
|
+
declare function resolveOpenAIResponsesPayloadPolicy(model: OpenAIResponsesPayloadModel, options?: {
|
|
42
|
+
extraParams?: Record<string, unknown>;
|
|
43
|
+
storeMode?: "provider-policy" | "transport-default" | "disable" | "preserve";
|
|
44
|
+
enablePromptCacheStripping?: boolean;
|
|
45
|
+
enableServerCompaction?: boolean;
|
|
46
|
+
}): OpenAIResponsesPayloadPolicy;
|
|
47
47
|
/** Mutate a Responses request payload according to the resolved endpoint policy. */
|
|
48
48
|
declare function applyOpenAIResponsesPayloadPolicy(payloadObj: Record<string, unknown>, policy: OpenAIResponsesPayloadPolicy): void;
|
|
49
49
|
//#endregion
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { o as isRecord } from "./record-coerce-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import "./transport-utils-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { rt as buildOpenAIResponsesReasoningReplayMetadata } from "./openai-responses-shared-
|
|
9
|
-
import { a as isOpenAIResponsesCompactionOutput,
|
|
1
|
+
import { o as isRecord } from "./record-coerce-BQaoiN3r.mjs";
|
|
2
|
+
import { p as RESPONSES_RETAINED_USER, v as responsesPromptObserver } from "./openai-responses-contracts-xU-n9AJJ.mjs";
|
|
3
|
+
import { n as estimateTokensFromChars, t as estimateStringChars } from "./src-BUsVkrNt.mjs";
|
|
4
|
+
import "./transport-utils-Da_39MYi.mjs";
|
|
5
|
+
import { t as stableStringify } from "./stable-stringify-CchQEmeA.mjs";
|
|
6
|
+
import { y as prepareSystemPrompt } from "./simple-options-tLSeECry.mjs";
|
|
7
|
+
import { C as sha256Hex } from "./tool-schema-json-projection-BQpiJlXJ.mjs";
|
|
8
|
+
import { rt as buildOpenAIResponsesReasoningReplayMetadata } from "./openai-responses-shared-CrFDkZ0N.mjs";
|
|
9
|
+
import { a as isOpenAIResponsesCompactionOutput, c as sanitizeResponsesImagePayload } from "./openai-responses-endpoint-DCkURKS0.mjs";
|
|
10
10
|
//#region packages/ai/src/transports/openai-responses-compact-request.ts
|
|
11
11
|
const COMPACT_REQUEST = Symbol("openaiResponsesCompactRequest");
|
|
12
12
|
function claimResponsesCompactRequest(options) {
|
|
@@ -169,16 +169,6 @@ function retainV2Users(input) {
|
|
|
169
169
|
}
|
|
170
170
|
//#endregion
|
|
171
171
|
//#region packages/ai/src/transports/openai-responses-prompt-observer-internal.ts
|
|
172
|
-
function readSessionsSpawnSchema(tools) {
|
|
173
|
-
if (!Array.isArray(tools)) return;
|
|
174
|
-
const tool = tools.find((candidate) => isRecord(candidate) && candidate.name === "sessions_spawn");
|
|
175
|
-
if (!isRecord(tool)) return;
|
|
176
|
-
const parameters = isRecord(tool.parameters) ? tool.parameters : void 0;
|
|
177
|
-
return {
|
|
178
|
-
...typeof tool.strict === "boolean" ? { strict: tool.strict } : {},
|
|
179
|
-
categoryRequired: Array.isArray(parameters?.required) && parameters.required.includes("category")
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
172
|
function readFinalResponsesPrompt(request) {
|
|
183
173
|
if (typeof request.instructions === "string") return ["instructions", request.instructions];
|
|
184
174
|
const message = (Array.isArray(request.input) ? request.input : []).find((item) => {
|
|
@@ -190,22 +180,18 @@ function readFinalResponsesPrompt(request) {
|
|
|
190
180
|
const observedPrompt = typeof content === "string" ? content : Array.isArray(content) ? content.flatMap((part) => part.type === "input_text" ? [part.text] : []).join("") : "";
|
|
191
181
|
return [message.role === "developer" ? "input.developer" : "input.system", observedPrompt];
|
|
192
182
|
}
|
|
193
|
-
function createResponsesPromptEgressObserver(options,
|
|
183
|
+
function createResponsesPromptEgressObserver(options, context) {
|
|
194
184
|
const observer = options ? responsesPromptObserver.get(options) : void 0;
|
|
195
185
|
if (!observer) return;
|
|
196
|
-
const expectedPrompt =
|
|
186
|
+
const expectedPrompt = prepareSystemPrompt(context.systemPrompt ?? "", context.preparedSystemPrompt).instructions;
|
|
197
187
|
return (request, metadata) => {
|
|
198
188
|
const [promptSource, observedPrompt] = readFinalResponsesPrompt(request);
|
|
199
|
-
const sessionsSpawn = readSessionsSpawnSchema(request.tools);
|
|
200
189
|
observer({
|
|
201
190
|
...metadata,
|
|
202
191
|
promptSource,
|
|
203
192
|
expectedChars: expectedPrompt.length,
|
|
204
193
|
observedChars: observedPrompt.length,
|
|
205
|
-
matchesAssembledPrompt: promptSource !== "missing" && observedPrompt === expectedPrompt
|
|
206
|
-
...typeof request.model === "string" ? { model: request.model } : {},
|
|
207
|
-
...typeof request.reasoning?.effort === "string" ? { reasoningEffort: request.reasoning.effort } : {},
|
|
208
|
-
...sessionsSpawn ? { sessionsSpawn } : {}
|
|
194
|
+
matchesAssembledPrompt: promptSource !== "missing" && observedPrompt === expectedPrompt
|
|
209
195
|
});
|
|
210
196
|
};
|
|
211
197
|
}
|