xkzoom 1.5.2 → 1.5.4
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 +87 -43
- package/dist/{chunk-UANVP2AV.mjs → chunk-27BXVTXH.mjs} +1 -1
- package/dist/{chunk-PY7W2X6W.mjs → chunk-2DR5RT3I.mjs} +52 -45
- package/dist/{chunk-YILSXMZI.mjs → chunk-2IQAT3PE.mjs} +1 -1
- package/dist/{chunk-IXYH42YO.mjs → chunk-2VSERWT6.mjs} +1 -1
- package/dist/{chunk-BSQF7NF4.mjs → chunk-3KJHUTOO.mjs} +2 -2
- package/dist/{chunk-URF75O5Z.mjs → chunk-3VA3YDYL.mjs} +1 -1
- package/dist/{chunk-RTANSWHW.mjs → chunk-3ZH273T7.mjs} +27 -27
- package/dist/{chunk-EQNHKW6L.mjs → chunk-4JXTPCOE.mjs} +1 -1
- package/dist/{chunk-WJIY3BIA.mjs → chunk-5SE4JOKE.mjs} +38 -10
- package/dist/{chunk-JD5NPIMO.mjs → chunk-5YEFG7BF.mjs} +25 -25
- package/dist/{chunk-LTBQWMAJ.mjs → chunk-6W4W5JLG.mjs} +1 -1
- package/dist/{chunk-CDLS44GZ.mjs → chunk-76MFE24I.mjs} +1 -1
- package/dist/{chunk-IPIV4NGB.mjs → chunk-76TKUYY3.mjs} +2 -2
- package/dist/{chunk-T4LPE43H.mjs → chunk-7LEEVP5O.mjs} +1 -1
- package/dist/{chunk-A5DUSLHF.mjs → chunk-DCSERRXG.mjs} +1 -1
- package/dist/{chunk-ASIBETCT.mjs → chunk-E2TTUY6R.mjs} +2 -2
- package/dist/chunk-E5LABIPO.mjs +201 -0
- package/dist/{chunk-KYTJH3R3.mjs → chunk-EE3NRJLQ.mjs} +1 -1
- package/dist/{chunk-SIIEMWE3.mjs → chunk-F35EHL5U.mjs} +3 -3
- package/dist/{chunk-K4RHLREV.mjs → chunk-FG6QCRVN.mjs} +1 -1
- package/dist/{chunk-HJN232FK.mjs → chunk-FLVJABFP.mjs} +1 -1
- package/dist/{chunk-ZM23SMRO.mjs → chunk-GIC2RBVM.mjs} +1 -1
- package/dist/{chunk-HTU5W436.mjs → chunk-GZJMFCRG.mjs} +2 -2
- package/dist/{chunk-JG3EPJ32.mjs → chunk-HAI7DJD2.mjs} +3 -3
- package/dist/{chunk-OB4JJLDC.mjs → chunk-HYSOWPIC.mjs} +2 -2
- package/dist/{chunk-G5ZU7562.mjs → chunk-IDQ5B572.mjs} +6 -6
- package/dist/{chunk-GGWUDW5W.mjs → chunk-IGDJGBAI.mjs} +1 -1
- package/dist/{chunk-A23OTVH2.mjs → chunk-J5AXFEDQ.mjs} +18 -18
- package/dist/{chunk-4DYFM3EC.mjs → chunk-JBKRS62W.mjs} +3 -3
- package/dist/{chunk-OCQUSYRP.mjs → chunk-JFFBD5TV.mjs} +14 -14
- package/dist/{chunk-VPRVZWF3.mjs → chunk-JI67TW4E.mjs} +1 -1
- package/dist/{chunk-GBG4AJON.mjs → chunk-JJKRD5DL.mjs} +1 -1
- package/dist/{chunk-7AZVQS2H.mjs → chunk-JXDHNASC.mjs} +12 -12
- package/dist/{chunk-W4MKSQGZ.mjs → chunk-K7RZQIPZ.mjs} +1 -1
- package/dist/{chunk-J5HTLG3V.mjs → chunk-KPDVZFJY.mjs} +1 -1
- package/dist/{chunk-S7FQBXOO.mjs → chunk-L252ASZW.mjs} +1 -1
- package/dist/{chunk-Z7GTU7KF.mjs → chunk-LESS4N25.mjs} +1 -1
- package/dist/{chunk-5DMSAPS2.mjs → chunk-M3ISDSQP.mjs} +7 -7
- package/dist/{chunk-HR43WO4Q.mjs → chunk-M5IU6U3O.mjs} +2 -2
- package/dist/{chunk-BV76CMVR.mjs → chunk-MBOWNG3A.mjs} +1 -1
- package/dist/{chunk-CCCPWU2O.mjs → chunk-MDZUWIBH.mjs} +4 -4
- package/dist/{chunk-YAD4VG2K.mjs → chunk-MKYCBV3H.mjs} +36 -6
- package/dist/{chunk-CORUFGMR.mjs → chunk-MPGMU75K.mjs} +4 -4
- package/dist/{chunk-7FLALKSN.mjs → chunk-MQKREMOB.mjs} +2 -2
- package/dist/{chunk-H5TJYSTV.mjs → chunk-MRTQWCNC.mjs} +1 -1
- package/dist/{chunk-CNHOCDRM.mjs → chunk-NHICONJ3.mjs} +1 -1
- package/dist/{chunk-5JGUBBXN.mjs → chunk-NIU6GWKB.mjs} +2 -2
- package/dist/{chunk-Q6XX6X24.mjs → chunk-OBYPZT2S.mjs} +6 -6
- package/dist/{chunk-Y6SJUTY6.mjs → chunk-P262PAGZ.mjs} +15 -2
- package/dist/{chunk-YPAQRMUI.mjs → chunk-PETWGCGB.mjs} +1 -1
- package/dist/{chunk-Q4XUEIOE.mjs → chunk-PW3ULDNL.mjs} +1 -1
- package/dist/{chunk-EGWLJJY7.mjs → chunk-RKZ56GST.mjs} +2 -2
- package/dist/{chunk-QUXUHJZW.mjs → chunk-TADSGGK2.mjs} +7 -7
- package/dist/{chunk-ILROJZBI.mjs → chunk-TQBVFKCT.mjs} +37 -9
- package/dist/{chunk-M52HZV6R.mjs → chunk-TVH4LII3.mjs} +1 -1
- package/dist/{chunk-GUADF3KN.mjs → chunk-ULXTQSV6.mjs} +4 -0
- package/dist/{chunk-H5DIQHEQ.mjs → chunk-UXEZFEB3.mjs} +37 -8
- package/dist/{chunk-XHO73X2N.mjs → chunk-VNEPNUBZ.mjs} +13 -13
- package/dist/{chunk-NYG3IUXK.mjs → chunk-W75Z6CZR.mjs} +1 -1
- package/dist/{chunk-PG5CHH66.mjs → chunk-YPKHMAO4.mjs} +1 -1
- package/dist/index.js +336 -31
- package/dist/index.mjs +104 -103
- package/dist/mobile/action-planner.js +21 -1
- package/dist/mobile/action-planner.mjs +60 -59
- package/dist/mobile/agent-capabilities.js +21 -1
- package/dist/mobile/agent-capabilities.mjs +60 -59
- package/dist/mobile/anthropic-incremental-deliver.js +19 -0
- package/dist/mobile/anthropic-incremental-deliver.mjs +3 -2
- package/dist/mobile/anthropic-messages-turn-runner.js +224 -8
- package/dist/mobile/anthropic-messages-turn-runner.mjs +69 -68
- package/dist/mobile/anthropic-owned-tool-executor.js +21 -1
- package/dist/mobile/anthropic-owned-tool-executor.mjs +68 -67
- package/dist/mobile/api.mjs +31 -31
- package/dist/mobile/context-compact/compact-artifact-enrich.js +19 -0
- package/dist/mobile/context-compact/compact-artifact-enrich.mjs +8 -7
- package/dist/mobile/context-compact/compact-orchestrator.js +21 -1
- package/dist/mobile/context-compact/compact-orchestrator.mjs +12 -11
- package/dist/mobile/context-compact/compact-summarizer-engine-artifact.js +19 -0
- package/dist/mobile/context-compact/compact-summarizer-engine-artifact.mjs +8 -7
- package/dist/mobile/context-compact/compact-summarizer-llm-request.js +19 -0
- package/dist/mobile/context-compact/compact-summarizer-llm-request.mjs +5 -4
- package/dist/mobile/context-compact/compact-summarizer-llm.js +19 -0
- package/dist/mobile/context-compact/compact-summarizer-llm.mjs +6 -5
- package/dist/mobile/context-compact/compact-summarizer.js +19 -0
- package/dist/mobile/context-compact/compact-summarizer.mjs +7 -6
- package/dist/mobile/context-compact/context-budget-gate.js +14 -2
- package/dist/mobile/context-compact/context-budget-gate.mjs +2 -2
- package/dist/mobile/context-compact/runtime-compact-hook.js +33 -2
- package/dist/mobile/context-compact/runtime-compact-hook.mjs +64 -63
- package/dist/mobile/group/conductor-llm.js +19 -0
- package/dist/mobile/group/conductor-llm.mjs +7 -6
- package/dist/mobile/group/conductor-plan-llm.js +19 -0
- package/dist/mobile/group/conductor-plan-llm.mjs +7 -6
- package/dist/mobile/group/floor-scheduler.mjs +2 -2
- package/dist/mobile/group/group-api-handlers.mjs +21 -21
- package/dist/mobile/group/group-session.mjs +5 -5
- package/dist/mobile/group/index.mjs +16 -16
- package/dist/mobile/group/memory-supplement.mjs +4 -4
- package/dist/mobile/group/orchestrator.mjs +15 -15
- package/dist/mobile/group/plan-runtime.mjs +4 -4
- package/dist/mobile/group/relation-distill.mjs +3 -3
- package/dist/mobile/group/runtime-integration.mjs +19 -19
- package/dist/mobile/group/team-memory-runtime.mjs +3 -3
- package/dist/mobile/index.js +336 -31
- package/dist/mobile/index.mjs +101 -100
- package/dist/mobile/interrupted-turn.js +5 -0
- package/dist/mobile/interrupted-turn.mjs +3 -1
- package/dist/mobile/memory-contract-r1-prefetch.mjs +5 -5
- package/dist/mobile/memory-contract-r5-empty-result.mjs +6 -6
- package/dist/mobile/memory-runtime-v2/eval-runner.mjs +8 -8
- package/dist/mobile/memory-runtime-v2/evidence-plan.mjs +11 -11
- package/dist/mobile/memory-runtime-v2/index.mjs +31 -31
- package/dist/mobile/memory-runtime-v2/local-source-import.mjs +3 -3
- package/dist/mobile/memory-runtime-v2/memory-control-plane.mjs +11 -11
- package/dist/mobile/memory-runtime-v2/memory-readiness.mjs +11 -11
- package/dist/mobile/memory-runtime-v2/orchestrator.mjs +4 -4
- package/dist/mobile/memory-runtime-v2/project-tool-event.mjs +2 -2
- package/dist/mobile/memory-runtime-v2/public-api.mjs +12 -12
- package/dist/mobile/memory-runtime-v2/retrieval.mjs +2 -2
- package/dist/mobile/model-context-window-budget.js +16 -2
- package/dist/mobile/model-context-window-budget.mjs +3 -1
- package/dist/mobile/native-anthropic-messages-stream.js +223 -7
- package/dist/mobile/native-anthropic-messages-stream.mjs +4 -3
- package/dist/mobile/native-anthropic-turn-errors.mjs +2 -2
- package/dist/mobile/native-openai-text-stream.js +223 -6
- package/dist/mobile/native-openai-text-stream.mjs +2 -1
- package/dist/mobile/native-reply-route.js +19 -0
- package/dist/mobile/native-reply-route.mjs +5 -4
- package/dist/mobile/native-reply-system-prompt-layers.js +21 -1
- package/dist/mobile/native-reply-system-prompt-layers.mjs +61 -60
- package/dist/mobile/native-request-diagnostics.js +230 -0
- package/dist/mobile/native-request-diagnostics.mjs +17 -0
- package/dist/mobile/native-stream-block-emit.js +19 -0
- package/dist/mobile/native-stream-block-emit.mjs +2 -1
- package/dist/mobile/openai-completions-turn-runner.js +224 -8
- package/dist/mobile/openai-completions-turn-runner.mjs +69 -68
- package/dist/mobile/runtime.js +336 -31
- package/dist/mobile/runtime.mjs +100 -99
- package/dist/mobile/stream-inbound/mobile-text-stream-pipeline.mjs +4 -4
- package/dist/mobile/tool-use-input-normalize.js +21 -1
- package/dist/mobile/tool-use-input-normalize.mjs +63 -62
- package/dist/mobile/tools/mobile-compact-tool-bridge.js +21 -1
- package/dist/mobile/tools/mobile-compact-tool-bridge.mjs +63 -62
- package/dist/org/dept-context.mjs +2 -2
- package/dist/org/index.mjs +8 -8
- package/dist/owned-tools/ceo-confirm-requirements.mjs +3 -3
- package/dist/owned-tools/ceo-decision.mjs +4 -4
- package/dist/owned-tools/ceo-ops-brief.mjs +3 -3
- package/dist/owned-tools/ceo-redirect.mjs +20 -20
- package/dist/owned-tools/commit-stack-lesson.mjs +4 -4
- package/dist/owned-tools/compact/execute.js +21 -1
- package/dist/owned-tools/compact/execute.mjs +61 -60
- package/dist/owned-tools/compact/gateway-tool-factory.js +21 -1
- package/dist/owned-tools/compact/gateway-tool-factory.mjs +62 -61
- package/dist/owned-tools/compact/registry.js +21 -1
- package/dist/owned-tools/compact/registry.mjs +60 -59
- package/dist/owned-tools/context-compact.js +21 -1
- package/dist/owned-tools/context-compact.mjs +25 -24
- package/dist/owned-tools/handoff.mjs +3 -3
- package/dist/owned-tools/memory-control.mjs +13 -13
- package/dist/owned-tools/memory-runtime-eval.mjs +12 -12
- package/dist/owned-tools/register-owned-providers.mjs +3 -3
- package/dist/owned-tools/registry.js +21 -1
- package/dist/owned-tools/registry.mjs +59 -58
- package/dist/owned-tools/router.js +21 -1
- package/dist/owned-tools/router.mjs +60 -59
- package/dist/owned-tools/runtime-bridge.js +21 -1
- package/dist/owned-tools/runtime-bridge.mjs +61 -60
- package/dist/owned-tools/tool-contract-prompt.js +21 -1
- package/dist/owned-tools/tool-contract-prompt.mjs +60 -59
- package/dist/owned-tools/tool-result-envelope.js +21 -1
- package/dist/owned-tools/tool-result-envelope.mjs +62 -61
- package/dist/owned-tools/tool-usage-guide.js +21 -1
- package/dist/owned-tools/tool-usage-guide.mjs +59 -58
- package/dist/owned-tools/tts.mjs +2 -2
- package/dist/project-pipeline/handlers.mjs +20 -20
- package/dist/project-pipeline/index.mjs +20 -20
- package/dist/project-pipeline/post-close-skill-evolution.mjs +3 -3
- package/package.json +2 -2
- package/dist/{chunk-KCZIK3TH.mjs → chunk-2QCX6RPN.mjs} +3 -3
- package/dist/{chunk-2BGXTBZX.mjs → chunk-D3N7EHB2.mjs} +8 -8
- package/dist/{chunk-JIY7IOQ5.mjs → chunk-DRY7AJMM.mjs} +3 -3
- package/dist/{chunk-VS2URZFN.mjs → chunk-HWGRW6YP.mjs} +3 -3
- package/dist/{chunk-Q7NYATKS.mjs → chunk-UR6LPERL.mjs} +3 -3
- package/dist/{chunk-TAQQSDJN.mjs → chunk-WPMJCKI2.mjs} +3 -3
- package/dist/{chunk-2TBXT3PD.mjs → chunk-XNQJRIGR.mjs} +9 -9
- package/dist/{chunk-BHMWYAVS.mjs → chunk-YYDDQEY4.mjs} +3 -3
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/mobile/native-request-diagnostics.ts
|
|
21
|
+
var native_request_diagnostics_exports = {};
|
|
22
|
+
__export(native_request_diagnostics_exports, {
|
|
23
|
+
applyConfiguredMaxTokens: () => applyConfiguredMaxTokens,
|
|
24
|
+
fetchNativeProviderWithRetry: () => fetchNativeProviderWithRetry,
|
|
25
|
+
formatNativeFetchErrorForLog: () => formatNativeFetchErrorForLog,
|
|
26
|
+
formatRequestShape: () => formatRequestShape,
|
|
27
|
+
isRetryableNativeProviderFetchError: () => isRetryableNativeProviderFetchError,
|
|
28
|
+
stringifyJsonRequestBody: () => stringifyJsonRequestBody
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(native_request_diagnostics_exports);
|
|
31
|
+
function compactLogValue(value, maxLen = 180) {
|
|
32
|
+
const text = String(value ?? "").replace(/\s+/g, " ").trim();
|
|
33
|
+
if (!text) {
|
|
34
|
+
return "";
|
|
35
|
+
}
|
|
36
|
+
return text.length > maxLen ? `${text.slice(0, maxLen)}...` : text;
|
|
37
|
+
}
|
|
38
|
+
function readErrorProp(value, key) {
|
|
39
|
+
return value && typeof value === "object" ? value[key] : void 0;
|
|
40
|
+
}
|
|
41
|
+
function positiveInteger(value) {
|
|
42
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
43
|
+
return void 0;
|
|
44
|
+
}
|
|
45
|
+
return Math.trunc(value);
|
|
46
|
+
}
|
|
47
|
+
function formatNativeFetchErrorForLog(error) {
|
|
48
|
+
const parts = [];
|
|
49
|
+
let current = error;
|
|
50
|
+
for (let depth = 0; depth < 4 && current !== null && current !== void 0; depth += 1) {
|
|
51
|
+
const prefix = depth === 0 ? "error" : `cause${depth}`;
|
|
52
|
+
const name = compactLogValue(readErrorProp(current, "name"));
|
|
53
|
+
const message = current instanceof Error ? compactLogValue(current.message) : compactLogValue(readErrorProp(current, "message") ?? current);
|
|
54
|
+
const code = compactLogValue(readErrorProp(current, "code"));
|
|
55
|
+
const errno = compactLogValue(readErrorProp(current, "errno"));
|
|
56
|
+
if (name) parts.push(`${prefix}Name=${name}`);
|
|
57
|
+
if (message) parts.push(`${prefix}Message=${message}`);
|
|
58
|
+
if (code) parts.push(`${prefix}Code=${code}`);
|
|
59
|
+
if (errno) parts.push(`${prefix}Errno=${errno}`);
|
|
60
|
+
current = readErrorProp(current, "cause");
|
|
61
|
+
}
|
|
62
|
+
return parts.join(" ") || "error=unknown";
|
|
63
|
+
}
|
|
64
|
+
function applyConfiguredMaxTokens(requestBody, maxTokens) {
|
|
65
|
+
const configured = positiveInteger(maxTokens);
|
|
66
|
+
if (configured === void 0) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const existing = positiveInteger(requestBody.max_tokens);
|
|
70
|
+
requestBody.max_tokens = existing === void 0 ? configured : Math.min(existing, configured);
|
|
71
|
+
}
|
|
72
|
+
function stringifyJsonRequestBody(requestBody) {
|
|
73
|
+
const bodyText = JSON.stringify(requestBody);
|
|
74
|
+
return {
|
|
75
|
+
bodyText,
|
|
76
|
+
bodyBytes: Buffer.byteLength(bodyText, "utf8")
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function formatRequestShape(input) {
|
|
80
|
+
const messageCount = Array.isArray(input.messages) ? input.messages.length : 0;
|
|
81
|
+
const toolCount = Array.isArray(input.tools) ? input.tools.length : 0;
|
|
82
|
+
const maxTokens = positiveInteger(input.maxTokens);
|
|
83
|
+
return `bodyBytes=${input.bodyBytes} messages=${messageCount} tools=${toolCount} max_tokens=${maxTokens ?? "n/a"}`;
|
|
84
|
+
}
|
|
85
|
+
var DEFAULT_PROVIDER_FETCH_MAX_ATTEMPTS = 2;
|
|
86
|
+
var HARD_PROVIDER_FETCH_MAX_ATTEMPTS = 4;
|
|
87
|
+
var DEFAULT_PROVIDER_FETCH_RETRY_BASE_MS = 350;
|
|
88
|
+
var HARD_PROVIDER_FETCH_RETRY_BASE_MS = 5e3;
|
|
89
|
+
var RETRYABLE_NATIVE_FETCH_RE = new RegExp(
|
|
90
|
+
[
|
|
91
|
+
"fetch failed",
|
|
92
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
93
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
94
|
+
"UND_ERR_SOCKET",
|
|
95
|
+
"ECONNRESET",
|
|
96
|
+
"ETIMEDOUT",
|
|
97
|
+
"ECONNREFUSED",
|
|
98
|
+
"ENOTFOUND",
|
|
99
|
+
"EAI_AGAIN",
|
|
100
|
+
"socket hang up",
|
|
101
|
+
"network connection lost",
|
|
102
|
+
"network request failed"
|
|
103
|
+
].join("|"),
|
|
104
|
+
"i"
|
|
105
|
+
);
|
|
106
|
+
function readClampedPositiveEnvInt(env, key, fallback, max) {
|
|
107
|
+
const raw = (env[key] ?? "").trim();
|
|
108
|
+
const n = Number.parseInt(raw, 10);
|
|
109
|
+
if (!Number.isFinite(n) || n <= 0) {
|
|
110
|
+
return fallback;
|
|
111
|
+
}
|
|
112
|
+
return Math.min(Math.trunc(n), max);
|
|
113
|
+
}
|
|
114
|
+
function readClampedNonNegativeEnvInt(env, key, fallback, max) {
|
|
115
|
+
const raw = (env[key] ?? "").trim();
|
|
116
|
+
const n = Number.parseInt(raw, 10);
|
|
117
|
+
if (!Number.isFinite(n) || n < 0) {
|
|
118
|
+
return fallback;
|
|
119
|
+
}
|
|
120
|
+
return Math.min(Math.trunc(n), max);
|
|
121
|
+
}
|
|
122
|
+
function readProviderFetchMaxAttempts(env) {
|
|
123
|
+
return readClampedPositiveEnvInt(
|
|
124
|
+
env,
|
|
125
|
+
"XKZOOM_NATIVE_PROVIDER_FETCH_MAX_ATTEMPTS",
|
|
126
|
+
DEFAULT_PROVIDER_FETCH_MAX_ATTEMPTS,
|
|
127
|
+
HARD_PROVIDER_FETCH_MAX_ATTEMPTS
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
function readProviderFetchRetryBaseMs(env) {
|
|
131
|
+
return readClampedNonNegativeEnvInt(
|
|
132
|
+
env,
|
|
133
|
+
"XKZOOM_NATIVE_PROVIDER_FETCH_RETRY_BASE_MS",
|
|
134
|
+
DEFAULT_PROVIDER_FETCH_RETRY_BASE_MS,
|
|
135
|
+
HARD_PROVIDER_FETCH_RETRY_BASE_MS
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
function isAbortLikeFetchError(error) {
|
|
139
|
+
const name = compactLogValue(readErrorProp(error, "name"));
|
|
140
|
+
return name === "AbortError";
|
|
141
|
+
}
|
|
142
|
+
function collectFetchErrorText(error) {
|
|
143
|
+
const parts = [];
|
|
144
|
+
let current = error;
|
|
145
|
+
for (let depth = 0; depth < 4 && current !== null && current !== void 0; depth += 1) {
|
|
146
|
+
parts.push(
|
|
147
|
+
compactLogValue(readErrorProp(current, "name")),
|
|
148
|
+
current instanceof Error ? compactLogValue(current.message) : compactLogValue(readErrorProp(current, "message") ?? current),
|
|
149
|
+
compactLogValue(readErrorProp(current, "code")),
|
|
150
|
+
compactLogValue(readErrorProp(current, "errno"))
|
|
151
|
+
);
|
|
152
|
+
current = readErrorProp(current, "cause");
|
|
153
|
+
}
|
|
154
|
+
return parts.filter(Boolean).join(" ");
|
|
155
|
+
}
|
|
156
|
+
function isRetryableNativeProviderFetchError(error) {
|
|
157
|
+
return !isAbortLikeFetchError(error) && RETRYABLE_NATIVE_FETCH_RE.test(collectFetchErrorText(error));
|
|
158
|
+
}
|
|
159
|
+
function formatProviderRetryContext(context) {
|
|
160
|
+
const parts = [
|
|
161
|
+
`provider=${context.providerId}`,
|
|
162
|
+
`model=${context.model}`,
|
|
163
|
+
context.adapter ? `adapter=${context.adapter}` : "",
|
|
164
|
+
typeof context.iteration === "number" ? `iteration=${context.iteration}` : ""
|
|
165
|
+
];
|
|
166
|
+
return parts.filter(Boolean).join(" ");
|
|
167
|
+
}
|
|
168
|
+
function asAbortSignal(signal) {
|
|
169
|
+
if (signal && typeof signal === "object" && "aborted" in signal) {
|
|
170
|
+
return signal;
|
|
171
|
+
}
|
|
172
|
+
return void 0;
|
|
173
|
+
}
|
|
174
|
+
async function waitForProviderFetchRetryDelay(delayMs, signal) {
|
|
175
|
+
if (delayMs <= 0) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (signal?.aborted) {
|
|
179
|
+
throw new DOMException("Aborted", "AbortError");
|
|
180
|
+
}
|
|
181
|
+
await new Promise((resolve, reject) => {
|
|
182
|
+
const timer = setTimeout(() => {
|
|
183
|
+
signal?.removeEventListener("abort", onAbort);
|
|
184
|
+
resolve();
|
|
185
|
+
}, delayMs);
|
|
186
|
+
const onAbort = () => {
|
|
187
|
+
clearTimeout(timer);
|
|
188
|
+
reject(new DOMException("Aborted", "AbortError"));
|
|
189
|
+
};
|
|
190
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
async function fetchNativeProviderWithRetry(url, init, context, env = process.env) {
|
|
194
|
+
const maxAttempts = readProviderFetchMaxAttempts(env);
|
|
195
|
+
const retryBaseMs = readProviderFetchRetryBaseMs(env);
|
|
196
|
+
const signal = asAbortSignal(init.signal);
|
|
197
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
198
|
+
try {
|
|
199
|
+
return await fetch(url, init);
|
|
200
|
+
} catch (error) {
|
|
201
|
+
const retry = attempt < maxAttempts && !signal?.aborted && isRetryableNativeProviderFetchError(error);
|
|
202
|
+
context.log(
|
|
203
|
+
`[XKZOOM][native-reply][${context.label}] fetch_failed ${url} ${formatProviderRetryContext(context)} attempt=${attempt}/${maxAttempts} retry=${retry ? 1 : 0} ${formatRequestShape({
|
|
204
|
+
bodyBytes: context.bodyBytes,
|
|
205
|
+
messages: context.messages,
|
|
206
|
+
tools: context.tools,
|
|
207
|
+
maxTokens: context.maxTokens
|
|
208
|
+
})} ${formatNativeFetchErrorForLog(error)}`
|
|
209
|
+
);
|
|
210
|
+
if (!retry) {
|
|
211
|
+
throw error;
|
|
212
|
+
}
|
|
213
|
+
const delayMs = retryBaseMs * attempt;
|
|
214
|
+
context.log(
|
|
215
|
+
`[XKZOOM][native-reply][${context.label}] fetch_retry ${url} ${formatProviderRetryContext(context)} nextAttempt=${attempt + 1}/${maxAttempts} delayMs=${delayMs}`
|
|
216
|
+
);
|
|
217
|
+
await waitForProviderFetchRetryDelay(delayMs, signal);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
throw new Error(`native provider fetch retry exhausted: ${url}`);
|
|
221
|
+
}
|
|
222
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
223
|
+
0 && (module.exports = {
|
|
224
|
+
applyConfiguredMaxTokens,
|
|
225
|
+
fetchNativeProviderWithRetry,
|
|
226
|
+
formatNativeFetchErrorForLog,
|
|
227
|
+
formatRequestShape,
|
|
228
|
+
isRetryableNativeProviderFetchError,
|
|
229
|
+
stringifyJsonRequestBody
|
|
230
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyConfiguredMaxTokens,
|
|
3
|
+
fetchNativeProviderWithRetry,
|
|
4
|
+
formatNativeFetchErrorForLog,
|
|
5
|
+
formatRequestShape,
|
|
6
|
+
isRetryableNativeProviderFetchError,
|
|
7
|
+
stringifyJsonRequestBody
|
|
8
|
+
} from "../chunk-E5LABIPO.mjs";
|
|
9
|
+
import "../chunk-HEBXNMVQ.mjs";
|
|
10
|
+
export {
|
|
11
|
+
applyConfiguredMaxTokens,
|
|
12
|
+
fetchNativeProviderWithRetry,
|
|
13
|
+
formatNativeFetchErrorForLog,
|
|
14
|
+
formatRequestShape,
|
|
15
|
+
isRetryableNativeProviderFetchError,
|
|
16
|
+
stringifyJsonRequestBody
|
|
17
|
+
};
|
|
@@ -640,6 +640,25 @@ var minimaxOpenAiCompletionsAdapter = {
|
|
|
640
640
|
id: "minimax"
|
|
641
641
|
};
|
|
642
642
|
|
|
643
|
+
// src/mobile/native-request-diagnostics.ts
|
|
644
|
+
var RETRYABLE_NATIVE_FETCH_RE = new RegExp(
|
|
645
|
+
[
|
|
646
|
+
"fetch failed",
|
|
647
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
648
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
649
|
+
"UND_ERR_SOCKET",
|
|
650
|
+
"ECONNRESET",
|
|
651
|
+
"ETIMEDOUT",
|
|
652
|
+
"ECONNREFUSED",
|
|
653
|
+
"ENOTFOUND",
|
|
654
|
+
"EAI_AGAIN",
|
|
655
|
+
"socket hang up",
|
|
656
|
+
"network connection lost",
|
|
657
|
+
"network request failed"
|
|
658
|
+
].join("|"),
|
|
659
|
+
"i"
|
|
660
|
+
);
|
|
661
|
+
|
|
643
662
|
// src/mobile/native-openai-text-stream.ts
|
|
644
663
|
function mergeOpenAiCompatibleStreamChunk(fullSoFar, incoming) {
|
|
645
664
|
if (incoming.length === 0) {
|
|
@@ -12,10 +12,11 @@ import {
|
|
|
12
12
|
readNativeStreamReasoningEmitIntervalMs,
|
|
13
13
|
readNativeStreamReasoningMinChars,
|
|
14
14
|
shouldEmitNativeStreamBlock
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-MKYCBV3H.mjs";
|
|
16
16
|
import "../chunk-C36JYBG7.mjs";
|
|
17
17
|
import "../chunk-PJDUIH5J.mjs";
|
|
18
18
|
import "../chunk-NEDXMES6.mjs";
|
|
19
|
+
import "../chunk-E5LABIPO.mjs";
|
|
19
20
|
import "../chunk-LR5GC3NZ.mjs";
|
|
20
21
|
import "../chunk-JHQIGDVB.mjs";
|
|
21
22
|
import "../chunk-DSSVZ47P.mjs";
|
|
@@ -21746,6 +21746,199 @@ function parseOpenAiCompletionsSseDataLine(line) {
|
|
|
21746
21746
|
}
|
|
21747
21747
|
}
|
|
21748
21748
|
|
|
21749
|
+
// src/mobile/native-request-diagnostics.ts
|
|
21750
|
+
function compactLogValue(value, maxLen = 180) {
|
|
21751
|
+
const text = String(value ?? "").replace(/\s+/g, " ").trim();
|
|
21752
|
+
if (!text) {
|
|
21753
|
+
return "";
|
|
21754
|
+
}
|
|
21755
|
+
return text.length > maxLen ? `${text.slice(0, maxLen)}...` : text;
|
|
21756
|
+
}
|
|
21757
|
+
function readErrorProp(value, key) {
|
|
21758
|
+
return value && typeof value === "object" ? value[key] : void 0;
|
|
21759
|
+
}
|
|
21760
|
+
function positiveInteger(value) {
|
|
21761
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
21762
|
+
return void 0;
|
|
21763
|
+
}
|
|
21764
|
+
return Math.trunc(value);
|
|
21765
|
+
}
|
|
21766
|
+
function formatNativeFetchErrorForLog(error) {
|
|
21767
|
+
const parts = [];
|
|
21768
|
+
let current = error;
|
|
21769
|
+
for (let depth = 0; depth < 4 && current !== null && current !== void 0; depth += 1) {
|
|
21770
|
+
const prefix = depth === 0 ? "error" : `cause${depth}`;
|
|
21771
|
+
const name = compactLogValue(readErrorProp(current, "name"));
|
|
21772
|
+
const message = current instanceof Error ? compactLogValue(current.message) : compactLogValue(readErrorProp(current, "message") ?? current);
|
|
21773
|
+
const code = compactLogValue(readErrorProp(current, "code"));
|
|
21774
|
+
const errno = compactLogValue(readErrorProp(current, "errno"));
|
|
21775
|
+
if (name) parts.push(`${prefix}Name=${name}`);
|
|
21776
|
+
if (message) parts.push(`${prefix}Message=${message}`);
|
|
21777
|
+
if (code) parts.push(`${prefix}Code=${code}`);
|
|
21778
|
+
if (errno) parts.push(`${prefix}Errno=${errno}`);
|
|
21779
|
+
current = readErrorProp(current, "cause");
|
|
21780
|
+
}
|
|
21781
|
+
return parts.join(" ") || "error=unknown";
|
|
21782
|
+
}
|
|
21783
|
+
function applyConfiguredMaxTokens(requestBody, maxTokens) {
|
|
21784
|
+
const configured = positiveInteger(maxTokens);
|
|
21785
|
+
if (configured === void 0) {
|
|
21786
|
+
return;
|
|
21787
|
+
}
|
|
21788
|
+
const existing = positiveInteger(requestBody.max_tokens);
|
|
21789
|
+
requestBody.max_tokens = existing === void 0 ? configured : Math.min(existing, configured);
|
|
21790
|
+
}
|
|
21791
|
+
function stringifyJsonRequestBody(requestBody) {
|
|
21792
|
+
const bodyText = JSON.stringify(requestBody);
|
|
21793
|
+
return {
|
|
21794
|
+
bodyText,
|
|
21795
|
+
bodyBytes: Buffer.byteLength(bodyText, "utf8")
|
|
21796
|
+
};
|
|
21797
|
+
}
|
|
21798
|
+
function formatRequestShape(input) {
|
|
21799
|
+
const messageCount = Array.isArray(input.messages) ? input.messages.length : 0;
|
|
21800
|
+
const toolCount = Array.isArray(input.tools) ? input.tools.length : 0;
|
|
21801
|
+
const maxTokens = positiveInteger(input.maxTokens);
|
|
21802
|
+
return `bodyBytes=${input.bodyBytes} messages=${messageCount} tools=${toolCount} max_tokens=${maxTokens ?? "n/a"}`;
|
|
21803
|
+
}
|
|
21804
|
+
var DEFAULT_PROVIDER_FETCH_MAX_ATTEMPTS = 2;
|
|
21805
|
+
var HARD_PROVIDER_FETCH_MAX_ATTEMPTS = 4;
|
|
21806
|
+
var DEFAULT_PROVIDER_FETCH_RETRY_BASE_MS = 350;
|
|
21807
|
+
var HARD_PROVIDER_FETCH_RETRY_BASE_MS = 5e3;
|
|
21808
|
+
var RETRYABLE_NATIVE_FETCH_RE = new RegExp(
|
|
21809
|
+
[
|
|
21810
|
+
"fetch failed",
|
|
21811
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
21812
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
21813
|
+
"UND_ERR_SOCKET",
|
|
21814
|
+
"ECONNRESET",
|
|
21815
|
+
"ETIMEDOUT",
|
|
21816
|
+
"ECONNREFUSED",
|
|
21817
|
+
"ENOTFOUND",
|
|
21818
|
+
"EAI_AGAIN",
|
|
21819
|
+
"socket hang up",
|
|
21820
|
+
"network connection lost",
|
|
21821
|
+
"network request failed"
|
|
21822
|
+
].join("|"),
|
|
21823
|
+
"i"
|
|
21824
|
+
);
|
|
21825
|
+
function readClampedPositiveEnvInt(env, key, fallback, max) {
|
|
21826
|
+
const raw = (env[key] ?? "").trim();
|
|
21827
|
+
const n = Number.parseInt(raw, 10);
|
|
21828
|
+
if (!Number.isFinite(n) || n <= 0) {
|
|
21829
|
+
return fallback;
|
|
21830
|
+
}
|
|
21831
|
+
return Math.min(Math.trunc(n), max);
|
|
21832
|
+
}
|
|
21833
|
+
function readClampedNonNegativeEnvInt(env, key, fallback, max) {
|
|
21834
|
+
const raw = (env[key] ?? "").trim();
|
|
21835
|
+
const n = Number.parseInt(raw, 10);
|
|
21836
|
+
if (!Number.isFinite(n) || n < 0) {
|
|
21837
|
+
return fallback;
|
|
21838
|
+
}
|
|
21839
|
+
return Math.min(Math.trunc(n), max);
|
|
21840
|
+
}
|
|
21841
|
+
function readProviderFetchMaxAttempts(env) {
|
|
21842
|
+
return readClampedPositiveEnvInt(
|
|
21843
|
+
env,
|
|
21844
|
+
"XKZOOM_NATIVE_PROVIDER_FETCH_MAX_ATTEMPTS",
|
|
21845
|
+
DEFAULT_PROVIDER_FETCH_MAX_ATTEMPTS,
|
|
21846
|
+
HARD_PROVIDER_FETCH_MAX_ATTEMPTS
|
|
21847
|
+
);
|
|
21848
|
+
}
|
|
21849
|
+
function readProviderFetchRetryBaseMs(env) {
|
|
21850
|
+
return readClampedNonNegativeEnvInt(
|
|
21851
|
+
env,
|
|
21852
|
+
"XKZOOM_NATIVE_PROVIDER_FETCH_RETRY_BASE_MS",
|
|
21853
|
+
DEFAULT_PROVIDER_FETCH_RETRY_BASE_MS,
|
|
21854
|
+
HARD_PROVIDER_FETCH_RETRY_BASE_MS
|
|
21855
|
+
);
|
|
21856
|
+
}
|
|
21857
|
+
function isAbortLikeFetchError(error) {
|
|
21858
|
+
const name = compactLogValue(readErrorProp(error, "name"));
|
|
21859
|
+
return name === "AbortError";
|
|
21860
|
+
}
|
|
21861
|
+
function collectFetchErrorText(error) {
|
|
21862
|
+
const parts = [];
|
|
21863
|
+
let current = error;
|
|
21864
|
+
for (let depth = 0; depth < 4 && current !== null && current !== void 0; depth += 1) {
|
|
21865
|
+
parts.push(
|
|
21866
|
+
compactLogValue(readErrorProp(current, "name")),
|
|
21867
|
+
current instanceof Error ? compactLogValue(current.message) : compactLogValue(readErrorProp(current, "message") ?? current),
|
|
21868
|
+
compactLogValue(readErrorProp(current, "code")),
|
|
21869
|
+
compactLogValue(readErrorProp(current, "errno"))
|
|
21870
|
+
);
|
|
21871
|
+
current = readErrorProp(current, "cause");
|
|
21872
|
+
}
|
|
21873
|
+
return parts.filter(Boolean).join(" ");
|
|
21874
|
+
}
|
|
21875
|
+
function isRetryableNativeProviderFetchError(error) {
|
|
21876
|
+
return !isAbortLikeFetchError(error) && RETRYABLE_NATIVE_FETCH_RE.test(collectFetchErrorText(error));
|
|
21877
|
+
}
|
|
21878
|
+
function formatProviderRetryContext(context) {
|
|
21879
|
+
const parts = [
|
|
21880
|
+
`provider=${context.providerId}`,
|
|
21881
|
+
`model=${context.model}`,
|
|
21882
|
+
context.adapter ? `adapter=${context.adapter}` : "",
|
|
21883
|
+
typeof context.iteration === "number" ? `iteration=${context.iteration}` : ""
|
|
21884
|
+
];
|
|
21885
|
+
return parts.filter(Boolean).join(" ");
|
|
21886
|
+
}
|
|
21887
|
+
function asAbortSignal(signal) {
|
|
21888
|
+
if (signal && typeof signal === "object" && "aborted" in signal) {
|
|
21889
|
+
return signal;
|
|
21890
|
+
}
|
|
21891
|
+
return void 0;
|
|
21892
|
+
}
|
|
21893
|
+
async function waitForProviderFetchRetryDelay(delayMs, signal) {
|
|
21894
|
+
if (delayMs <= 0) {
|
|
21895
|
+
return;
|
|
21896
|
+
}
|
|
21897
|
+
if (signal?.aborted) {
|
|
21898
|
+
throw new DOMException("Aborted", "AbortError");
|
|
21899
|
+
}
|
|
21900
|
+
await new Promise((resolve9, reject) => {
|
|
21901
|
+
const timer = setTimeout(() => {
|
|
21902
|
+
signal?.removeEventListener("abort", onAbort);
|
|
21903
|
+
resolve9();
|
|
21904
|
+
}, delayMs);
|
|
21905
|
+
const onAbort = () => {
|
|
21906
|
+
clearTimeout(timer);
|
|
21907
|
+
reject(new DOMException("Aborted", "AbortError"));
|
|
21908
|
+
};
|
|
21909
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
21910
|
+
});
|
|
21911
|
+
}
|
|
21912
|
+
async function fetchNativeProviderWithRetry(url, init, context, env = process.env) {
|
|
21913
|
+
const maxAttempts = readProviderFetchMaxAttempts(env);
|
|
21914
|
+
const retryBaseMs = readProviderFetchRetryBaseMs(env);
|
|
21915
|
+
const signal = asAbortSignal(init.signal);
|
|
21916
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
21917
|
+
try {
|
|
21918
|
+
return await fetch(url, init);
|
|
21919
|
+
} catch (error) {
|
|
21920
|
+
const retry = attempt < maxAttempts && !signal?.aborted && isRetryableNativeProviderFetchError(error);
|
|
21921
|
+
context.log(
|
|
21922
|
+
`[XKZOOM][native-reply][${context.label}] fetch_failed ${url} ${formatProviderRetryContext(context)} attempt=${attempt}/${maxAttempts} retry=${retry ? 1 : 0} ${formatRequestShape({
|
|
21923
|
+
bodyBytes: context.bodyBytes,
|
|
21924
|
+
messages: context.messages,
|
|
21925
|
+
tools: context.tools,
|
|
21926
|
+
maxTokens: context.maxTokens
|
|
21927
|
+
})} ${formatNativeFetchErrorForLog(error)}`
|
|
21928
|
+
);
|
|
21929
|
+
if (!retry) {
|
|
21930
|
+
throw error;
|
|
21931
|
+
}
|
|
21932
|
+
const delayMs = retryBaseMs * attempt;
|
|
21933
|
+
context.log(
|
|
21934
|
+
`[XKZOOM][native-reply][${context.label}] fetch_retry ${url} ${formatProviderRetryContext(context)} nextAttempt=${attempt + 1}/${maxAttempts} delayMs=${delayMs}`
|
|
21935
|
+
);
|
|
21936
|
+
await waitForProviderFetchRetryDelay(delayMs, signal);
|
|
21937
|
+
}
|
|
21938
|
+
}
|
|
21939
|
+
throw new Error(`native provider fetch retry exhausted: ${url}`);
|
|
21940
|
+
}
|
|
21941
|
+
|
|
21749
21942
|
// src/mobile/native-openai-text-stream.ts
|
|
21750
21943
|
var isRecord6 = isGatewayConfigRecord;
|
|
21751
21944
|
function resolveOpenAiCompletionsBodyExtras(provider, baseUrl) {
|
|
@@ -24407,7 +24600,8 @@ var IMAGE_BLOCK_BUDGET_BYTES = 8 * 1024;
|
|
|
24407
24600
|
|
|
24408
24601
|
// src/mobile/model-context-window-budget.ts
|
|
24409
24602
|
var MIN_TRANSCRIPT_BUDGET_BYTES = 64 * 1024;
|
|
24410
|
-
var
|
|
24603
|
+
var DEFAULT_MAX_NATIVE_TRANSCRIPT_BUDGET_BYTES = 128 * 1024;
|
|
24604
|
+
var HARD_MAX_TRANSCRIPT_BUDGET_BYTES = 4 * 1024 * 1024;
|
|
24411
24605
|
|
|
24412
24606
|
// src/mobile/context-compact/context-budget-gate.ts
|
|
24413
24607
|
function resolveContextBudgetSignalSource() {
|
|
@@ -39045,15 +39239,37 @@ async function runNativeOpenAiCompletionsTurnToDispatcher(params) {
|
|
|
39045
39239
|
if (params.providerAccelerationPlan || providerAcceleration.application.applied || providerAcceleration.application.warnings.length > 0) {
|
|
39046
39240
|
params.log(formatProviderAccelerationApplication(providerAcceleration.application));
|
|
39047
39241
|
}
|
|
39242
|
+
applyConfiguredMaxTokens(requestBody, cfg.maxTokens);
|
|
39243
|
+
const { bodyText, bodyBytes } = stringifyJsonRequestBody(requestBody);
|
|
39048
39244
|
params.log(
|
|
39049
|
-
`[XKZOOM][native-reply][openai-turn] POST ${url} provider=${cfg.providerId} model=${cfg.model} adapter=${adapter.id} iteration=${iteration} tools=${toolsForRequest ? toolsForRequest.length : 0} tool_choice=${toolChoiceLog} transcriptTurns=${messages.filter((m) => m.role !== "system").length}`
|
|
39245
|
+
`[XKZOOM][native-reply][openai-turn] POST ${url} provider=${cfg.providerId} model=${cfg.model} adapter=${adapter.id} iteration=${iteration} tools=${toolsForRequest ? toolsForRequest.length : 0} tool_choice=${toolChoiceLog} transcriptTurns=${messages.filter((m) => m.role !== "system").length} ` + formatRequestShape({
|
|
39246
|
+
bodyBytes,
|
|
39247
|
+
messages,
|
|
39248
|
+
tools: toolsForRequest,
|
|
39249
|
+
maxTokens: requestBody.max_tokens
|
|
39250
|
+
})
|
|
39251
|
+
);
|
|
39252
|
+
const res = await fetchNativeProviderWithRetry(
|
|
39253
|
+
url,
|
|
39254
|
+
{
|
|
39255
|
+
method: "POST",
|
|
39256
|
+
headers: adapter.buildHeaders(cfg),
|
|
39257
|
+
body: bodyText,
|
|
39258
|
+
signal: params.signal
|
|
39259
|
+
},
|
|
39260
|
+
{
|
|
39261
|
+
label: "openai-turn",
|
|
39262
|
+
providerId: cfg.providerId,
|
|
39263
|
+
model: cfg.model,
|
|
39264
|
+
adapter: adapter.id,
|
|
39265
|
+
iteration,
|
|
39266
|
+
bodyBytes,
|
|
39267
|
+
messages,
|
|
39268
|
+
tools: toolsForRequest,
|
|
39269
|
+
maxTokens: requestBody.max_tokens,
|
|
39270
|
+
log: params.log
|
|
39271
|
+
}
|
|
39050
39272
|
);
|
|
39051
|
-
const res = await fetch(url, {
|
|
39052
|
-
method: "POST",
|
|
39053
|
-
headers: adapter.buildHeaders(cfg),
|
|
39054
|
-
body: JSON.stringify(requestBody),
|
|
39055
|
-
signal: params.signal
|
|
39056
|
-
});
|
|
39057
39273
|
if (!res.ok) {
|
|
39058
39274
|
const t = await res.text();
|
|
39059
39275
|
if (policyToolChoiceApplied && requestAttempt === 0 && isOpenAiToolChoiceCompatibilityHttpError(res.status, t)) {
|