xkzoom 1.5.2 → 1.5.3
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 +57 -43
- package/dist/{chunk-VPRVZWF3.mjs → chunk-37LYF6K2.mjs} +1 -1
- package/dist/{chunk-OCQUSYRP.mjs → chunk-3EV63LAA.mjs} +12 -12
- package/dist/{chunk-W4MKSQGZ.mjs → chunk-3FF266OG.mjs} +1 -1
- package/dist/{chunk-J5HTLG3V.mjs → chunk-3LR4CLDE.mjs} +1 -1
- package/dist/{chunk-CDLS44GZ.mjs → chunk-3TTLV2GM.mjs} +1 -1
- package/dist/{chunk-JG3EPJ32.mjs → chunk-54GVKP6B.mjs} +6 -6
- package/dist/{chunk-M52HZV6R.mjs → chunk-5VR6UOGC.mjs} +1 -1
- package/dist/{chunk-GBG4AJON.mjs → chunk-6EI5MFLD.mjs} +4 -4
- package/dist/{chunk-A23OTVH2.mjs → chunk-6LKZYMIW.mjs} +30 -30
- package/dist/{chunk-TAQQSDJN.mjs → chunk-6SYECCCG.mjs} +6 -6
- package/dist/{chunk-24GJWXMG.mjs → chunk-7MOQ462O.mjs} +1 -1
- package/dist/{chunk-LFZAVCVW.mjs → chunk-AJNXWGX2.mjs} +1 -1
- package/dist/{chunk-5DMSAPS2.mjs → chunk-APQRVOZQ.mjs} +5 -5
- package/dist/{chunk-YAD4VG2K.mjs → chunk-BHT6B2TV.mjs} +36 -6
- package/dist/{chunk-BV76CMVR.mjs → chunk-BN273XTH.mjs} +1 -1
- package/dist/{chunk-IXYH42YO.mjs → chunk-C5VQPAOA.mjs} +1 -1
- package/dist/{chunk-PY7W2X6W.mjs → chunk-CQAQRU4P.mjs} +114 -107
- package/dist/{chunk-Q4XUEIOE.mjs → chunk-CVIZMDMZ.mjs} +1 -1
- package/dist/{chunk-SIIEMWE3.mjs → chunk-DB4XTPJF.mjs} +7 -7
- package/dist/{chunk-URF75O5Z.mjs → chunk-DBYEZK64.mjs} +1 -1
- package/dist/{chunk-GIAML5K5.mjs → chunk-DQ7J7RST.mjs} +1 -1
- package/dist/{chunk-BHMWYAVS.mjs → chunk-DXPZNBSQ.mjs} +3 -3
- package/dist/chunk-E5LABIPO.mjs +201 -0
- package/dist/{chunk-A5DUSLHF.mjs → chunk-ED4H2DM7.mjs} +1 -1
- package/dist/{chunk-KYTJH3R3.mjs → chunk-EE3NRJLQ.mjs} +1 -1
- package/dist/{chunk-T4LPE43H.mjs → chunk-ESYRDWFO.mjs} +11 -11
- package/dist/{chunk-CQUISJWG.mjs → chunk-EYK3W2NV.mjs} +1 -1
- package/dist/{chunk-Z7GTU7KF.mjs → chunk-FAJHYXNU.mjs} +5 -5
- package/dist/{chunk-XHO73X2N.mjs → chunk-FKCGJ3BF.mjs} +2 -2
- package/dist/{chunk-HJN232FK.mjs → chunk-FLVJABFP.mjs} +1 -1
- package/dist/{chunk-H5DIQHEQ.mjs → chunk-FZ7NLBVP.mjs} +45 -16
- package/dist/{chunk-HTU5W436.mjs → chunk-G5LQ2PQ6.mjs} +2 -2
- package/dist/{chunk-LTBQWMAJ.mjs → chunk-GSIZ5FR6.mjs} +2 -2
- package/dist/{chunk-UANVP2AV.mjs → chunk-H4BNL7XG.mjs} +1 -1
- package/dist/{chunk-Q6XX6X24.mjs → chunk-I4LMW3IM.mjs} +1 -1
- package/dist/{chunk-VIZQURO5.mjs → chunk-IGJFAE72.mjs} +9 -9
- package/dist/{chunk-7AZVQS2H.mjs → chunk-IVR74IXK.mjs} +7 -7
- package/dist/{chunk-YILSXMZI.mjs → chunk-KI7AMK7P.mjs} +3 -3
- package/dist/{chunk-EQNHKW6L.mjs → chunk-LJF6JSJB.mjs} +1 -1
- package/dist/{chunk-JD5NPIMO.mjs → chunk-LSQ47CLM.mjs} +27 -27
- package/dist/{chunk-IPIV4NGB.mjs → chunk-LXEKUNXI.mjs} +6 -6
- package/dist/{chunk-HR43WO4Q.mjs → chunk-M6VHS3HQ.mjs} +2 -2
- package/dist/{chunk-4DYFM3EC.mjs → chunk-MI6GFOCU.mjs} +4 -4
- package/dist/{chunk-CFZVBILR.mjs → chunk-MIXYB6BH.mjs} +1 -1
- package/dist/{chunk-K4RHLREV.mjs → chunk-MVKCMXBY.mjs} +1 -1
- package/dist/{chunk-JG3K4N5B.mjs → chunk-NIV5GVCE.mjs} +1 -1
- package/dist/{chunk-ZTKJR7OC.mjs → chunk-OWIXULFQ.mjs} +1 -1
- package/dist/{chunk-Y6SJUTY6.mjs → chunk-P262PAGZ.mjs} +15 -2
- package/dist/{chunk-5JGUBBXN.mjs → chunk-PBBRBETA.mjs} +4 -4
- package/dist/{chunk-EGWLJJY7.mjs → chunk-QSHIFD37.mjs} +2 -2
- package/dist/{chunk-WJIY3BIA.mjs → chunk-QSQ274C6.mjs} +44 -16
- package/dist/{chunk-H5TJYSTV.mjs → chunk-QSUD6TNR.mjs} +5 -5
- package/dist/{chunk-YPAQRMUI.mjs → chunk-QYXYVBTO.mjs} +2 -2
- package/dist/{chunk-OB4JJLDC.mjs → chunk-RVW5XO4A.mjs} +4 -4
- package/dist/{chunk-CNHOCDRM.mjs → chunk-RYSPXH7G.mjs} +2 -2
- package/dist/{chunk-CCCPWU2O.mjs → chunk-RZW4EEPW.mjs} +22 -22
- package/dist/{chunk-GGWUDW5W.mjs → chunk-S5ROBD7X.mjs} +2 -2
- package/dist/{chunk-QUXUHJZW.mjs → chunk-SQHTVHQ7.mjs} +7 -7
- package/dist/{chunk-ZM23SMRO.mjs → chunk-T5ZCLYLJ.mjs} +1 -1
- package/dist/{chunk-NYG3IUXK.mjs → chunk-TER7DFHP.mjs} +1 -1
- package/dist/{chunk-RTANSWHW.mjs → chunk-THN36GA5.mjs} +27 -27
- package/dist/{chunk-GUADF3KN.mjs → chunk-ULXTQSV6.mjs} +4 -0
- package/dist/{chunk-PG5CHH66.mjs → chunk-VHRFLCMY.mjs} +1 -1
- package/dist/{chunk-BSQF7NF4.mjs → chunk-W7OJPFTN.mjs} +2 -2
- package/dist/{chunk-S7FQBXOO.mjs → chunk-WGLYR2YT.mjs} +1 -1
- package/dist/{chunk-G5ZU7562.mjs → chunk-WNI5ZPQY.mjs} +7 -7
- package/dist/{chunk-7FLALKSN.mjs → chunk-WRRJFJ2N.mjs} +7 -7
- package/dist/{chunk-ILROJZBI.mjs → chunk-WV6OKJ4J.mjs} +37 -9
- package/dist/{chunk-ASIBETCT.mjs → chunk-X7P6B2LK.mjs} +10 -10
- package/dist/{chunk-MWRQORKQ.mjs → chunk-XF4EURDX.mjs} +1 -1
- package/dist/{chunk-ETD5LGJY.mjs → chunk-Z3COATFF.mjs} +1 -1
- package/dist/index.js +336 -31
- package/dist/index.mjs +169 -168
- package/dist/mobile/action-planner.js +21 -1
- package/dist/mobile/action-planner.mjs +95 -94
- package/dist/mobile/agent-capabilities.js +21 -1
- package/dist/mobile/agent-capabilities.mjs +96 -95
- package/dist/mobile/agent-shop/handlers.mjs +3 -3
- 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 +104 -103
- package/dist/mobile/anthropic-owned-tool-executor.js +21 -1
- package/dist/mobile/anthropic-owned-tool-executor.mjs +103 -102
- package/dist/mobile/api.mjs +49 -49
- package/dist/mobile/context-compact/compact-artifact-enrich.js +19 -0
- package/dist/mobile/context-compact/compact-artifact-enrich.mjs +16 -15
- package/dist/mobile/context-compact/compact-artifact-writer.mjs +4 -4
- package/dist/mobile/context-compact/compact-engine-artifacts.mjs +5 -5
- package/dist/mobile/context-compact/compact-memory-distill-job.mjs +3 -3
- package/dist/mobile/context-compact/compact-message-collector.mjs +2 -2
- package/dist/mobile/context-compact/compact-orchestrator.js +21 -1
- package/dist/mobile/context-compact/compact-orchestrator.mjs +34 -33
- package/dist/mobile/context-compact/compact-resume-prefetch.mjs +4 -4
- package/dist/mobile/context-compact/compact-summarizer-engine-artifact.js +19 -0
- package/dist/mobile/context-compact/compact-summarizer-engine-artifact.mjs +18 -17
- package/dist/mobile/context-compact/compact-summarizer-llm-request.js +19 -0
- package/dist/mobile/context-compact/compact-summarizer-llm-request.mjs +10 -9
- package/dist/mobile/context-compact/compact-summarizer-llm.js +19 -0
- package/dist/mobile/context-compact/compact-summarizer-llm.mjs +11 -10
- package/dist/mobile/context-compact/compact-summarizer.js +19 -0
- package/dist/mobile/context-compact/compact-summarizer.mjs +15 -14
- package/dist/mobile/context-compact/compact-write-verifier.mjs +2 -2
- 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 +99 -98
- package/dist/mobile/group/conductor-llm.js +19 -0
- package/dist/mobile/group/conductor-llm.mjs +13 -12
- package/dist/mobile/group/conductor-plan-llm.js +19 -0
- package/dist/mobile/group/conductor-plan-llm.mjs +19 -18
- package/dist/mobile/group/delivery-verification.mjs +4 -4
- package/dist/mobile/group/direct-chat-group-context.mjs +1 -1
- package/dist/mobile/group/execution-plan.mjs +5 -5
- package/dist/mobile/group/floor-scheduler.mjs +7 -7
- package/dist/mobile/group/floor-state-store.mjs +6 -6
- package/dist/mobile/group/group-api-handlers.mjs +38 -38
- package/dist/mobile/group/group-peer-private-context.mjs +1 -1
- package/dist/mobile/group/group-session.mjs +19 -19
- package/dist/mobile/group/index.mjs +32 -32
- package/dist/mobile/group/memory-supplement.mjs +10 -10
- package/dist/mobile/group/orchestrator.mjs +30 -30
- package/dist/mobile/group/pipeline-ceo-dept-mention-parse.mjs +3 -3
- package/dist/mobile/group/pipeline-handoff-verification.mjs +3 -3
- package/dist/mobile/group/pipeline-turn-outcome.mjs +2 -2
- package/dist/mobile/group/plan-runtime.mjs +18 -18
- package/dist/mobile/group/relation-distill.mjs +8 -8
- package/dist/mobile/group/runtime-integration.mjs +36 -36
- package/dist/mobile/index.js +336 -31
- package/dist/mobile/index.mjs +164 -163
- package/dist/mobile/interrupted-turn.js +5 -0
- package/dist/mobile/interrupted-turn.mjs +3 -1
- package/dist/mobile/memory-contract-r1-prefetch.mjs +11 -11
- package/dist/mobile/memory-contract-r5-empty-result.mjs +12 -12
- package/dist/mobile/memory-runtime-v2/eval-runner.mjs +4 -4
- package/dist/mobile/memory-runtime-v2/evidence-plan.mjs +5 -5
- package/dist/mobile/memory-runtime-v2/index.mjs +15 -15
- package/dist/mobile/memory-runtime-v2/memory-control-plane.mjs +5 -5
- package/dist/mobile/memory-runtime-v2/memory-readiness.mjs +5 -5
- package/dist/mobile/memory-runtime-v2/orchestrator.mjs +3 -3
- package/dist/mobile/memory-runtime-v2/public-api.mjs +6 -6
- 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 +11 -10
- 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 +10 -9
- package/dist/mobile/native-reply-system-prompt-layers.js +21 -1
- package/dist/mobile/native-reply-system-prompt-layers.mjs +96 -95
- 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 +104 -103
- package/dist/mobile/reply-dispatch-warmup.mjs +2 -2
- package/dist/mobile/runtime.js +336 -31
- package/dist/mobile/runtime.mjs +161 -160
- package/dist/mobile/stream-inbound/mobile-text-stream-pipeline.mjs +3 -3
- package/dist/mobile/tool-use-input-normalize.js +21 -1
- package/dist/mobile/tool-use-input-normalize.mjs +98 -97
- package/dist/mobile/tools/mobile-compact-tool-bridge.js +21 -1
- package/dist/mobile/tools/mobile-compact-tool-bridge.mjs +98 -97
- package/dist/org/dept-context.mjs +4 -4
- package/dist/org/index.mjs +14 -14
- package/dist/owned-tools/ceo-confirm-requirements.mjs +12 -12
- package/dist/owned-tools/ceo-decision.mjs +18 -18
- package/dist/owned-tools/ceo-ops-brief.mjs +12 -12
- package/dist/owned-tools/ceo-redirect.mjs +37 -37
- package/dist/owned-tools/commit-stack-lesson.mjs +13 -13
- package/dist/owned-tools/compact/execute.js +21 -1
- package/dist/owned-tools/compact/execute.mjs +96 -95
- package/dist/owned-tools/compact/gateway-tool-factory.js +21 -1
- package/dist/owned-tools/compact/gateway-tool-factory.mjs +97 -96
- package/dist/owned-tools/compact/registry.js +21 -1
- package/dist/owned-tools/compact/registry.mjs +95 -94
- package/dist/owned-tools/context-compact.js +21 -1
- package/dist/owned-tools/context-compact.mjs +42 -41
- package/dist/owned-tools/groups-history.mjs +1 -1
- package/dist/owned-tools/handoff.mjs +17 -17
- package/dist/owned-tools/memory-control.mjs +7 -7
- package/dist/owned-tools/memory-runtime-eval.mjs +6 -6
- package/dist/owned-tools/message.mjs +2 -2
- package/dist/owned-tools/models-list.mjs +2 -2
- package/dist/owned-tools/register-owned-providers.mjs +5 -5
- package/dist/owned-tools/registry.js +21 -1
- package/dist/owned-tools/registry.mjs +94 -93
- package/dist/owned-tools/router.js +21 -1
- package/dist/owned-tools/router.mjs +95 -94
- package/dist/owned-tools/runtime-bridge.js +21 -1
- package/dist/owned-tools/runtime-bridge.mjs +96 -95
- package/dist/owned-tools/session-status.mjs +1 -1
- package/dist/owned-tools/sessions-history-resolver.mjs +2 -2
- package/dist/owned-tools/sessions-history.mjs +1 -1
- package/dist/owned-tools/sessions-send.mjs +1 -1
- package/dist/owned-tools/subagents.mjs +1 -1
- package/dist/owned-tools/tool-contract-prompt.js +21 -1
- package/dist/owned-tools/tool-contract-prompt.mjs +95 -94
- package/dist/owned-tools/tool-result-envelope.js +21 -1
- package/dist/owned-tools/tool-result-envelope.mjs +97 -96
- package/dist/owned-tools/tool-usage-guide.js +21 -1
- package/dist/owned-tools/tool-usage-guide.mjs +94 -93
- package/dist/owned-tools/tts.mjs +4 -4
- package/dist/owned-tools/web-smoke.mjs +6 -6
- package/dist/project/file-tool-scope-default.mjs +6 -6
- package/dist/project-pipeline/handlers.mjs +37 -37
- package/dist/project-pipeline/index.mjs +40 -40
- package/dist/project-pipeline/pipeline-routing.mjs +2 -2
- package/dist/project-pipeline/post-close-skill-evolution.mjs +5 -5
- package/dist/project-pipeline/project-store.mjs +5 -5
- package/package.json +2 -2
- package/dist/{chunk-UNZ3D3B3.mjs → chunk-3OXBG4OP.mjs} +5 -5
- package/dist/{chunk-NRJWLPTI.mjs → chunk-6AY6OPO5.mjs} +3 -3
- package/dist/{chunk-JA65ZG3H.mjs → chunk-6ZWKLMY3.mjs} +4 -4
- package/dist/{chunk-T23H5D4O.mjs → chunk-AINHKBJW.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-QM7MTC5Q.mjs → chunk-H6LMX5G5.mjs} +3 -3
- package/dist/{chunk-2TBXT3PD.mjs → chunk-J74WVZGF.mjs} +6 -6
- package/dist/{chunk-WPLDZLAL.mjs → chunk-L7PMYQN5.mjs} +3 -3
- package/dist/{chunk-CORUFGMR.mjs → chunk-N3YQ5IL6.mjs} +7 -7
- package/dist/{chunk-5LUTMHVL.mjs → chunk-NXKHSX4M.mjs} +3 -3
- package/dist/{chunk-MGWYJD5Q.mjs → chunk-QCSNRVL2.mjs} +8 -8
|
@@ -1335,6 +1335,199 @@ function parseOpenAiCompletionsSseDataLine(line) {
|
|
|
1335
1335
|
}
|
|
1336
1336
|
}
|
|
1337
1337
|
|
|
1338
|
+
// src/mobile/native-request-diagnostics.ts
|
|
1339
|
+
function compactLogValue(value, maxLen = 180) {
|
|
1340
|
+
const text = String(value ?? "").replace(/\s+/g, " ").trim();
|
|
1341
|
+
if (!text) {
|
|
1342
|
+
return "";
|
|
1343
|
+
}
|
|
1344
|
+
return text.length > maxLen ? `${text.slice(0, maxLen)}...` : text;
|
|
1345
|
+
}
|
|
1346
|
+
function readErrorProp(value, key) {
|
|
1347
|
+
return value && typeof value === "object" ? value[key] : void 0;
|
|
1348
|
+
}
|
|
1349
|
+
function positiveInteger(value) {
|
|
1350
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
1351
|
+
return void 0;
|
|
1352
|
+
}
|
|
1353
|
+
return Math.trunc(value);
|
|
1354
|
+
}
|
|
1355
|
+
function formatNativeFetchErrorForLog(error) {
|
|
1356
|
+
const parts = [];
|
|
1357
|
+
let current = error;
|
|
1358
|
+
for (let depth = 0; depth < 4 && current !== null && current !== void 0; depth += 1) {
|
|
1359
|
+
const prefix = depth === 0 ? "error" : `cause${depth}`;
|
|
1360
|
+
const name = compactLogValue(readErrorProp(current, "name"));
|
|
1361
|
+
const message = current instanceof Error ? compactLogValue(current.message) : compactLogValue(readErrorProp(current, "message") ?? current);
|
|
1362
|
+
const code = compactLogValue(readErrorProp(current, "code"));
|
|
1363
|
+
const errno = compactLogValue(readErrorProp(current, "errno"));
|
|
1364
|
+
if (name) parts.push(`${prefix}Name=${name}`);
|
|
1365
|
+
if (message) parts.push(`${prefix}Message=${message}`);
|
|
1366
|
+
if (code) parts.push(`${prefix}Code=${code}`);
|
|
1367
|
+
if (errno) parts.push(`${prefix}Errno=${errno}`);
|
|
1368
|
+
current = readErrorProp(current, "cause");
|
|
1369
|
+
}
|
|
1370
|
+
return parts.join(" ") || "error=unknown";
|
|
1371
|
+
}
|
|
1372
|
+
function applyConfiguredMaxTokens(requestBody, maxTokens) {
|
|
1373
|
+
const configured = positiveInteger(maxTokens);
|
|
1374
|
+
if (configured === void 0) {
|
|
1375
|
+
return;
|
|
1376
|
+
}
|
|
1377
|
+
const existing = positiveInteger(requestBody.max_tokens);
|
|
1378
|
+
requestBody.max_tokens = existing === void 0 ? configured : Math.min(existing, configured);
|
|
1379
|
+
}
|
|
1380
|
+
function stringifyJsonRequestBody(requestBody) {
|
|
1381
|
+
const bodyText = JSON.stringify(requestBody);
|
|
1382
|
+
return {
|
|
1383
|
+
bodyText,
|
|
1384
|
+
bodyBytes: Buffer.byteLength(bodyText, "utf8")
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1387
|
+
function formatRequestShape(input) {
|
|
1388
|
+
const messageCount = Array.isArray(input.messages) ? input.messages.length : 0;
|
|
1389
|
+
const toolCount = Array.isArray(input.tools) ? input.tools.length : 0;
|
|
1390
|
+
const maxTokens = positiveInteger(input.maxTokens);
|
|
1391
|
+
return `bodyBytes=${input.bodyBytes} messages=${messageCount} tools=${toolCount} max_tokens=${maxTokens ?? "n/a"}`;
|
|
1392
|
+
}
|
|
1393
|
+
var DEFAULT_PROVIDER_FETCH_MAX_ATTEMPTS = 2;
|
|
1394
|
+
var HARD_PROVIDER_FETCH_MAX_ATTEMPTS = 4;
|
|
1395
|
+
var DEFAULT_PROVIDER_FETCH_RETRY_BASE_MS = 350;
|
|
1396
|
+
var HARD_PROVIDER_FETCH_RETRY_BASE_MS = 5e3;
|
|
1397
|
+
var RETRYABLE_NATIVE_FETCH_RE = new RegExp(
|
|
1398
|
+
[
|
|
1399
|
+
"fetch failed",
|
|
1400
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
1401
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
1402
|
+
"UND_ERR_SOCKET",
|
|
1403
|
+
"ECONNRESET",
|
|
1404
|
+
"ETIMEDOUT",
|
|
1405
|
+
"ECONNREFUSED",
|
|
1406
|
+
"ENOTFOUND",
|
|
1407
|
+
"EAI_AGAIN",
|
|
1408
|
+
"socket hang up",
|
|
1409
|
+
"network connection lost",
|
|
1410
|
+
"network request failed"
|
|
1411
|
+
].join("|"),
|
|
1412
|
+
"i"
|
|
1413
|
+
);
|
|
1414
|
+
function readClampedPositiveEnvInt(env, key, fallback, max) {
|
|
1415
|
+
const raw = (env[key] ?? "").trim();
|
|
1416
|
+
const n = Number.parseInt(raw, 10);
|
|
1417
|
+
if (!Number.isFinite(n) || n <= 0) {
|
|
1418
|
+
return fallback;
|
|
1419
|
+
}
|
|
1420
|
+
return Math.min(Math.trunc(n), max);
|
|
1421
|
+
}
|
|
1422
|
+
function readClampedNonNegativeEnvInt(env, key, fallback, max) {
|
|
1423
|
+
const raw = (env[key] ?? "").trim();
|
|
1424
|
+
const n = Number.parseInt(raw, 10);
|
|
1425
|
+
if (!Number.isFinite(n) || n < 0) {
|
|
1426
|
+
return fallback;
|
|
1427
|
+
}
|
|
1428
|
+
return Math.min(Math.trunc(n), max);
|
|
1429
|
+
}
|
|
1430
|
+
function readProviderFetchMaxAttempts(env) {
|
|
1431
|
+
return readClampedPositiveEnvInt(
|
|
1432
|
+
env,
|
|
1433
|
+
"XKZOOM_NATIVE_PROVIDER_FETCH_MAX_ATTEMPTS",
|
|
1434
|
+
DEFAULT_PROVIDER_FETCH_MAX_ATTEMPTS,
|
|
1435
|
+
HARD_PROVIDER_FETCH_MAX_ATTEMPTS
|
|
1436
|
+
);
|
|
1437
|
+
}
|
|
1438
|
+
function readProviderFetchRetryBaseMs(env) {
|
|
1439
|
+
return readClampedNonNegativeEnvInt(
|
|
1440
|
+
env,
|
|
1441
|
+
"XKZOOM_NATIVE_PROVIDER_FETCH_RETRY_BASE_MS",
|
|
1442
|
+
DEFAULT_PROVIDER_FETCH_RETRY_BASE_MS,
|
|
1443
|
+
HARD_PROVIDER_FETCH_RETRY_BASE_MS
|
|
1444
|
+
);
|
|
1445
|
+
}
|
|
1446
|
+
function isAbortLikeFetchError(error) {
|
|
1447
|
+
const name = compactLogValue(readErrorProp(error, "name"));
|
|
1448
|
+
return name === "AbortError";
|
|
1449
|
+
}
|
|
1450
|
+
function collectFetchErrorText(error) {
|
|
1451
|
+
const parts = [];
|
|
1452
|
+
let current = error;
|
|
1453
|
+
for (let depth = 0; depth < 4 && current !== null && current !== void 0; depth += 1) {
|
|
1454
|
+
parts.push(
|
|
1455
|
+
compactLogValue(readErrorProp(current, "name")),
|
|
1456
|
+
current instanceof Error ? compactLogValue(current.message) : compactLogValue(readErrorProp(current, "message") ?? current),
|
|
1457
|
+
compactLogValue(readErrorProp(current, "code")),
|
|
1458
|
+
compactLogValue(readErrorProp(current, "errno"))
|
|
1459
|
+
);
|
|
1460
|
+
current = readErrorProp(current, "cause");
|
|
1461
|
+
}
|
|
1462
|
+
return parts.filter(Boolean).join(" ");
|
|
1463
|
+
}
|
|
1464
|
+
function isRetryableNativeProviderFetchError(error) {
|
|
1465
|
+
return !isAbortLikeFetchError(error) && RETRYABLE_NATIVE_FETCH_RE.test(collectFetchErrorText(error));
|
|
1466
|
+
}
|
|
1467
|
+
function formatProviderRetryContext(context) {
|
|
1468
|
+
const parts = [
|
|
1469
|
+
`provider=${context.providerId}`,
|
|
1470
|
+
`model=${context.model}`,
|
|
1471
|
+
context.adapter ? `adapter=${context.adapter}` : "",
|
|
1472
|
+
typeof context.iteration === "number" ? `iteration=${context.iteration}` : ""
|
|
1473
|
+
];
|
|
1474
|
+
return parts.filter(Boolean).join(" ");
|
|
1475
|
+
}
|
|
1476
|
+
function asAbortSignal(signal) {
|
|
1477
|
+
if (signal && typeof signal === "object" && "aborted" in signal) {
|
|
1478
|
+
return signal;
|
|
1479
|
+
}
|
|
1480
|
+
return void 0;
|
|
1481
|
+
}
|
|
1482
|
+
async function waitForProviderFetchRetryDelay(delayMs, signal) {
|
|
1483
|
+
if (delayMs <= 0) {
|
|
1484
|
+
return;
|
|
1485
|
+
}
|
|
1486
|
+
if (signal?.aborted) {
|
|
1487
|
+
throw new DOMException("Aborted", "AbortError");
|
|
1488
|
+
}
|
|
1489
|
+
await new Promise((resolve, reject) => {
|
|
1490
|
+
const timer = setTimeout(() => {
|
|
1491
|
+
signal?.removeEventListener("abort", onAbort);
|
|
1492
|
+
resolve();
|
|
1493
|
+
}, delayMs);
|
|
1494
|
+
const onAbort = () => {
|
|
1495
|
+
clearTimeout(timer);
|
|
1496
|
+
reject(new DOMException("Aborted", "AbortError"));
|
|
1497
|
+
};
|
|
1498
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
1499
|
+
});
|
|
1500
|
+
}
|
|
1501
|
+
async function fetchNativeProviderWithRetry(url, init, context, env = process.env) {
|
|
1502
|
+
const maxAttempts = readProviderFetchMaxAttempts(env);
|
|
1503
|
+
const retryBaseMs = readProviderFetchRetryBaseMs(env);
|
|
1504
|
+
const signal = asAbortSignal(init.signal);
|
|
1505
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
1506
|
+
try {
|
|
1507
|
+
return await fetch(url, init);
|
|
1508
|
+
} catch (error) {
|
|
1509
|
+
const retry = attempt < maxAttempts && !signal?.aborted && isRetryableNativeProviderFetchError(error);
|
|
1510
|
+
context.log(
|
|
1511
|
+
`[XKZOOM][native-reply][${context.label}] fetch_failed ${url} ${formatProviderRetryContext(context)} attempt=${attempt}/${maxAttempts} retry=${retry ? 1 : 0} ${formatRequestShape({
|
|
1512
|
+
bodyBytes: context.bodyBytes,
|
|
1513
|
+
messages: context.messages,
|
|
1514
|
+
tools: context.tools,
|
|
1515
|
+
maxTokens: context.maxTokens
|
|
1516
|
+
})} ${formatNativeFetchErrorForLog(error)}`
|
|
1517
|
+
);
|
|
1518
|
+
if (!retry) {
|
|
1519
|
+
throw error;
|
|
1520
|
+
}
|
|
1521
|
+
const delayMs = retryBaseMs * attempt;
|
|
1522
|
+
context.log(
|
|
1523
|
+
`[XKZOOM][native-reply][${context.label}] fetch_retry ${url} ${formatProviderRetryContext(context)} nextAttempt=${attempt + 1}/${maxAttempts} delayMs=${delayMs}`
|
|
1524
|
+
);
|
|
1525
|
+
await waitForProviderFetchRetryDelay(delayMs, signal);
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
throw new Error(`native provider fetch retry exhausted: ${url}`);
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1338
1531
|
// src/mobile/native-stream-block-emit.ts
|
|
1339
1532
|
var NATIVE_STREAM_BLOCK_MIN_CHARS_DEFAULT = 8;
|
|
1340
1533
|
function readNativeStreamLiveDeliverEnabled(env = process.env) {
|
|
@@ -1639,12 +1832,36 @@ async function runNativeOpenAiTextStreamToDispatcher(params) {
|
|
|
1639
1832
|
if (params.providerAccelerationPlan || providerAcceleration.application.applied || providerAcceleration.application.warnings.length > 0) {
|
|
1640
1833
|
params.log(formatProviderAccelerationApplication(providerAcceleration.application));
|
|
1641
1834
|
}
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1835
|
+
applyConfiguredMaxTokens(requestBody, cfg.maxTokens);
|
|
1836
|
+
const { bodyText, bodyBytes } = stringifyJsonRequestBody(requestBody);
|
|
1837
|
+
params.log(
|
|
1838
|
+
`[XKZOOM][native-reply][openai-completions] request_shape ${formatRequestShape({
|
|
1839
|
+
bodyBytes,
|
|
1840
|
+
messages: chatMessages,
|
|
1841
|
+
tools: toolsForRequest,
|
|
1842
|
+
maxTokens: requestBody.max_tokens
|
|
1843
|
+
})}`
|
|
1844
|
+
);
|
|
1845
|
+
const res = await fetchNativeProviderWithRetry(
|
|
1846
|
+
url,
|
|
1847
|
+
{
|
|
1848
|
+
method: "POST",
|
|
1849
|
+
headers: buildBearerOpenAiHeaders(cfg),
|
|
1850
|
+
body: bodyText,
|
|
1851
|
+
signal: params.signal
|
|
1852
|
+
},
|
|
1853
|
+
{
|
|
1854
|
+
label: "openai-completions",
|
|
1855
|
+
providerId: cfg.providerId,
|
|
1856
|
+
model: cfg.model,
|
|
1857
|
+
adapter: "openai-completions",
|
|
1858
|
+
bodyBytes,
|
|
1859
|
+
messages: chatMessages,
|
|
1860
|
+
tools: toolsForRequest,
|
|
1861
|
+
maxTokens: requestBody.max_tokens,
|
|
1862
|
+
log: params.log
|
|
1863
|
+
}
|
|
1864
|
+
);
|
|
1648
1865
|
if (!res.ok) {
|
|
1649
1866
|
const t = await res.text();
|
|
1650
1867
|
throw new Error(`native OpenAI HTTP ${res.status}: ${t.slice(0, 500)}`);
|
|
@@ -10,7 +10,8 @@ import {
|
|
|
10
10
|
resolveOpenAiCompletionsToolsFromProvider,
|
|
11
11
|
runNativeOpenAiTextStreamToDispatcher,
|
|
12
12
|
ssePayloadLineToStreamDeltas
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-BHT6B2TV.mjs";
|
|
14
|
+
import "../chunk-E5LABIPO.mjs";
|
|
14
15
|
import "../chunk-C36JYBG7.mjs";
|
|
15
16
|
import "../chunk-PJDUIH5J.mjs";
|
|
16
17
|
import "../chunk-NEDXMES6.mjs";
|
|
@@ -1239,6 +1239,25 @@ var minimaxOpenAiCompletionsAdapter = {
|
|
|
1239
1239
|
id: "minimax"
|
|
1240
1240
|
};
|
|
1241
1241
|
|
|
1242
|
+
// src/mobile/native-request-diagnostics.ts
|
|
1243
|
+
var RETRYABLE_NATIVE_FETCH_RE = new RegExp(
|
|
1244
|
+
[
|
|
1245
|
+
"fetch failed",
|
|
1246
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
1247
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
1248
|
+
"UND_ERR_SOCKET",
|
|
1249
|
+
"ECONNRESET",
|
|
1250
|
+
"ETIMEDOUT",
|
|
1251
|
+
"ECONNREFUSED",
|
|
1252
|
+
"ENOTFOUND",
|
|
1253
|
+
"EAI_AGAIN",
|
|
1254
|
+
"socket hang up",
|
|
1255
|
+
"network connection lost",
|
|
1256
|
+
"network request failed"
|
|
1257
|
+
].join("|"),
|
|
1258
|
+
"i"
|
|
1259
|
+
);
|
|
1260
|
+
|
|
1242
1261
|
// src/mobile/native-openai-text-stream.ts
|
|
1243
1262
|
var isRecord = isGatewayConfigRecord;
|
|
1244
1263
|
function resolveOpenAiCompletionsBodyExtras(provider, baseUrl) {
|
|
@@ -7,10 +7,14 @@ import {
|
|
|
7
7
|
resolveNativeReplyRoute,
|
|
8
8
|
resolveNativeReplyRouteAsync,
|
|
9
9
|
shouldResolveNativeReplyRouteAsync
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-
|
|
10
|
+
} from "../chunk-G5LQ2PQ6.mjs";
|
|
11
|
+
import "../chunk-FZ7NLBVP.mjs";
|
|
12
|
+
import "../chunk-UQLGVSQH.mjs";
|
|
13
|
+
import "../chunk-E7BFLHLM.mjs";
|
|
14
|
+
import "../chunk-SPO74LMZ.mjs";
|
|
15
|
+
import "../chunk-3TTLV2GM.mjs";
|
|
16
|
+
import "../chunk-BHT6B2TV.mjs";
|
|
17
|
+
import "../chunk-E5LABIPO.mjs";
|
|
14
18
|
import "../chunk-C36JYBG7.mjs";
|
|
15
19
|
import "../chunk-PJDUIH5J.mjs";
|
|
16
20
|
import {
|
|
@@ -18,16 +22,13 @@ import {
|
|
|
18
22
|
formatNativeReplyRouteMissMessage
|
|
19
23
|
} from "../chunk-NEDXMES6.mjs";
|
|
20
24
|
import "../chunk-LR5GC3NZ.mjs";
|
|
21
|
-
import "../chunk-UQLGVSQH.mjs";
|
|
22
|
-
import "../chunk-E7BFLHLM.mjs";
|
|
23
|
-
import "../chunk-5AM5MS43.mjs";
|
|
24
|
-
import "../chunk-SPO74LMZ.mjs";
|
|
25
|
-
import "../chunk-LJ5OPMYI.mjs";
|
|
26
25
|
import "../chunk-JHQIGDVB.mjs";
|
|
27
26
|
import "../chunk-DSSVZ47P.mjs";
|
|
28
27
|
import "../chunk-SBBPQQYS.mjs";
|
|
29
28
|
import "../chunk-6GQKKEQA.mjs";
|
|
30
29
|
import "../chunk-QWSPMYE5.mjs";
|
|
30
|
+
import "../chunk-LJ5OPMYI.mjs";
|
|
31
|
+
import "../chunk-5AM5MS43.mjs";
|
|
31
32
|
import "../chunk-KIY5JPAA.mjs";
|
|
32
33
|
import "../chunk-4V5RUOBT.mjs";
|
|
33
34
|
import "../chunk-67ZUQKRE.mjs";
|
|
@@ -19641,6 +19641,25 @@ var minimaxOpenAiCompletionsAdapter = {
|
|
|
19641
19641
|
id: "minimax"
|
|
19642
19642
|
};
|
|
19643
19643
|
|
|
19644
|
+
// src/mobile/native-request-diagnostics.ts
|
|
19645
|
+
var RETRYABLE_NATIVE_FETCH_RE = new RegExp(
|
|
19646
|
+
[
|
|
19647
|
+
"fetch failed",
|
|
19648
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
19649
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
19650
|
+
"UND_ERR_SOCKET",
|
|
19651
|
+
"ECONNRESET",
|
|
19652
|
+
"ETIMEDOUT",
|
|
19653
|
+
"ECONNREFUSED",
|
|
19654
|
+
"ENOTFOUND",
|
|
19655
|
+
"EAI_AGAIN",
|
|
19656
|
+
"socket hang up",
|
|
19657
|
+
"network connection lost",
|
|
19658
|
+
"network request failed"
|
|
19659
|
+
].join("|"),
|
|
19660
|
+
"i"
|
|
19661
|
+
);
|
|
19662
|
+
|
|
19644
19663
|
// src/mobile/native-openai-text-stream.ts
|
|
19645
19664
|
var isRecord5 = isGatewayConfigRecord;
|
|
19646
19665
|
function resolveOpenAiCompletionsBodyExtras(provider, baseUrl) {
|
|
@@ -22121,7 +22140,8 @@ var IMAGE_BLOCK_BUDGET_BYTES = 8 * 1024;
|
|
|
22121
22140
|
|
|
22122
22141
|
// src/mobile/model-context-window-budget.ts
|
|
22123
22142
|
var MIN_TRANSCRIPT_BUDGET_BYTES = 64 * 1024;
|
|
22124
|
-
var
|
|
22143
|
+
var DEFAULT_MAX_NATIVE_TRANSCRIPT_BUDGET_BYTES = 128 * 1024;
|
|
22144
|
+
var HARD_MAX_TRANSCRIPT_BUDGET_BYTES = 4 * 1024 * 1024;
|
|
22125
22145
|
|
|
22126
22146
|
// src/mobile/context-compact/context-budget-gate.ts
|
|
22127
22147
|
function resolveContextBudgetSignalSource() {
|