xkzoom 1.5.1 → 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.
Files changed (228) hide show
  1. package/README.md +125 -55
  2. package/dist/{chunk-VPRVZWF3.mjs → chunk-37LYF6K2.mjs} +1 -1
  3. package/dist/{chunk-OCQUSYRP.mjs → chunk-3EV63LAA.mjs} +12 -12
  4. package/dist/{chunk-W4MKSQGZ.mjs → chunk-3FF266OG.mjs} +1 -1
  5. package/dist/{chunk-J5HTLG3V.mjs → chunk-3LR4CLDE.mjs} +1 -1
  6. package/dist/{chunk-CDLS44GZ.mjs → chunk-3TTLV2GM.mjs} +1 -1
  7. package/dist/{chunk-JG3EPJ32.mjs → chunk-54GVKP6B.mjs} +6 -6
  8. package/dist/{chunk-M52HZV6R.mjs → chunk-5VR6UOGC.mjs} +1 -1
  9. package/dist/{chunk-GBG4AJON.mjs → chunk-6EI5MFLD.mjs} +4 -4
  10. package/dist/{chunk-A23OTVH2.mjs → chunk-6LKZYMIW.mjs} +30 -30
  11. package/dist/{chunk-TAQQSDJN.mjs → chunk-6SYECCCG.mjs} +6 -6
  12. package/dist/{chunk-24GJWXMG.mjs → chunk-7MOQ462O.mjs} +1 -1
  13. package/dist/{chunk-LFZAVCVW.mjs → chunk-AJNXWGX2.mjs} +1 -1
  14. package/dist/{chunk-5DMSAPS2.mjs → chunk-APQRVOZQ.mjs} +5 -5
  15. package/dist/{chunk-YAD4VG2K.mjs → chunk-BHT6B2TV.mjs} +36 -6
  16. package/dist/{chunk-BV76CMVR.mjs → chunk-BN273XTH.mjs} +1 -1
  17. package/dist/{chunk-IXYH42YO.mjs → chunk-C5VQPAOA.mjs} +1 -1
  18. package/dist/{chunk-PY7W2X6W.mjs → chunk-CQAQRU4P.mjs} +114 -107
  19. package/dist/{chunk-Q4XUEIOE.mjs → chunk-CVIZMDMZ.mjs} +1 -1
  20. package/dist/{chunk-SIIEMWE3.mjs → chunk-DB4XTPJF.mjs} +7 -7
  21. package/dist/{chunk-URF75O5Z.mjs → chunk-DBYEZK64.mjs} +1 -1
  22. package/dist/{chunk-GIAML5K5.mjs → chunk-DQ7J7RST.mjs} +1 -1
  23. package/dist/{chunk-BHMWYAVS.mjs → chunk-DXPZNBSQ.mjs} +3 -3
  24. package/dist/chunk-E5LABIPO.mjs +201 -0
  25. package/dist/{chunk-A5DUSLHF.mjs → chunk-ED4H2DM7.mjs} +1 -1
  26. package/dist/{chunk-KYTJH3R3.mjs → chunk-EE3NRJLQ.mjs} +1 -1
  27. package/dist/{chunk-T4LPE43H.mjs → chunk-ESYRDWFO.mjs} +11 -11
  28. package/dist/{chunk-CQUISJWG.mjs → chunk-EYK3W2NV.mjs} +1 -1
  29. package/dist/{chunk-Z7GTU7KF.mjs → chunk-FAJHYXNU.mjs} +5 -5
  30. package/dist/{chunk-XHO73X2N.mjs → chunk-FKCGJ3BF.mjs} +2 -2
  31. package/dist/{chunk-HJN232FK.mjs → chunk-FLVJABFP.mjs} +1 -1
  32. package/dist/{chunk-H5DIQHEQ.mjs → chunk-FZ7NLBVP.mjs} +45 -16
  33. package/dist/{chunk-HTU5W436.mjs → chunk-G5LQ2PQ6.mjs} +2 -2
  34. package/dist/{chunk-LTBQWMAJ.mjs → chunk-GSIZ5FR6.mjs} +2 -2
  35. package/dist/{chunk-UANVP2AV.mjs → chunk-H4BNL7XG.mjs} +1 -1
  36. package/dist/{chunk-Q6XX6X24.mjs → chunk-I4LMW3IM.mjs} +1 -1
  37. package/dist/{chunk-VIZQURO5.mjs → chunk-IGJFAE72.mjs} +9 -9
  38. package/dist/{chunk-7AZVQS2H.mjs → chunk-IVR74IXK.mjs} +7 -7
  39. package/dist/{chunk-YILSXMZI.mjs → chunk-KI7AMK7P.mjs} +3 -3
  40. package/dist/{chunk-EQNHKW6L.mjs → chunk-LJF6JSJB.mjs} +1 -1
  41. package/dist/{chunk-JD5NPIMO.mjs → chunk-LSQ47CLM.mjs} +27 -27
  42. package/dist/{chunk-IPIV4NGB.mjs → chunk-LXEKUNXI.mjs} +6 -6
  43. package/dist/{chunk-HR43WO4Q.mjs → chunk-M6VHS3HQ.mjs} +2 -2
  44. package/dist/{chunk-4DYFM3EC.mjs → chunk-MI6GFOCU.mjs} +4 -4
  45. package/dist/{chunk-CFZVBILR.mjs → chunk-MIXYB6BH.mjs} +1 -1
  46. package/dist/{chunk-K4RHLREV.mjs → chunk-MVKCMXBY.mjs} +1 -1
  47. package/dist/{chunk-JG3K4N5B.mjs → chunk-NIV5GVCE.mjs} +1 -1
  48. package/dist/{chunk-ZTKJR7OC.mjs → chunk-OWIXULFQ.mjs} +1 -1
  49. package/dist/{chunk-Y6SJUTY6.mjs → chunk-P262PAGZ.mjs} +15 -2
  50. package/dist/{chunk-5JGUBBXN.mjs → chunk-PBBRBETA.mjs} +4 -4
  51. package/dist/{chunk-EGWLJJY7.mjs → chunk-QSHIFD37.mjs} +2 -2
  52. package/dist/{chunk-WJIY3BIA.mjs → chunk-QSQ274C6.mjs} +44 -16
  53. package/dist/{chunk-H5TJYSTV.mjs → chunk-QSUD6TNR.mjs} +5 -5
  54. package/dist/{chunk-YPAQRMUI.mjs → chunk-QYXYVBTO.mjs} +2 -2
  55. package/dist/{chunk-OB4JJLDC.mjs → chunk-RVW5XO4A.mjs} +4 -4
  56. package/dist/{chunk-CNHOCDRM.mjs → chunk-RYSPXH7G.mjs} +2 -2
  57. package/dist/{chunk-CCCPWU2O.mjs → chunk-RZW4EEPW.mjs} +22 -22
  58. package/dist/{chunk-GGWUDW5W.mjs → chunk-S5ROBD7X.mjs} +2 -2
  59. package/dist/{chunk-QUXUHJZW.mjs → chunk-SQHTVHQ7.mjs} +7 -7
  60. package/dist/{chunk-ZM23SMRO.mjs → chunk-T5ZCLYLJ.mjs} +1 -1
  61. package/dist/{chunk-NYG3IUXK.mjs → chunk-TER7DFHP.mjs} +1 -1
  62. package/dist/{chunk-RTANSWHW.mjs → chunk-THN36GA5.mjs} +27 -27
  63. package/dist/{chunk-GUADF3KN.mjs → chunk-ULXTQSV6.mjs} +4 -0
  64. package/dist/{chunk-PG5CHH66.mjs → chunk-VHRFLCMY.mjs} +1 -1
  65. package/dist/{chunk-BSQF7NF4.mjs → chunk-W7OJPFTN.mjs} +2 -2
  66. package/dist/{chunk-S7FQBXOO.mjs → chunk-WGLYR2YT.mjs} +1 -1
  67. package/dist/{chunk-G5ZU7562.mjs → chunk-WNI5ZPQY.mjs} +7 -7
  68. package/dist/{chunk-7FLALKSN.mjs → chunk-WRRJFJ2N.mjs} +7 -7
  69. package/dist/{chunk-ILROJZBI.mjs → chunk-WV6OKJ4J.mjs} +37 -9
  70. package/dist/{chunk-ASIBETCT.mjs → chunk-X7P6B2LK.mjs} +10 -10
  71. package/dist/{chunk-MWRQORKQ.mjs → chunk-XF4EURDX.mjs} +1 -1
  72. package/dist/{chunk-ETD5LGJY.mjs → chunk-Z3COATFF.mjs} +1 -1
  73. package/dist/index.js +336 -31
  74. package/dist/index.mjs +169 -168
  75. package/dist/mobile/action-planner.js +21 -1
  76. package/dist/mobile/action-planner.mjs +95 -94
  77. package/dist/mobile/agent-capabilities.js +21 -1
  78. package/dist/mobile/agent-capabilities.mjs +96 -95
  79. package/dist/mobile/agent-shop/handlers.mjs +3 -3
  80. package/dist/mobile/anthropic-incremental-deliver.js +19 -0
  81. package/dist/mobile/anthropic-incremental-deliver.mjs +3 -2
  82. package/dist/mobile/anthropic-messages-turn-runner.js +224 -8
  83. package/dist/mobile/anthropic-messages-turn-runner.mjs +104 -103
  84. package/dist/mobile/anthropic-owned-tool-executor.js +21 -1
  85. package/dist/mobile/anthropic-owned-tool-executor.mjs +103 -102
  86. package/dist/mobile/api.mjs +49 -49
  87. package/dist/mobile/context-compact/compact-artifact-enrich.js +19 -0
  88. package/dist/mobile/context-compact/compact-artifact-enrich.mjs +16 -15
  89. package/dist/mobile/context-compact/compact-artifact-writer.mjs +4 -4
  90. package/dist/mobile/context-compact/compact-engine-artifacts.mjs +5 -5
  91. package/dist/mobile/context-compact/compact-memory-distill-job.mjs +3 -3
  92. package/dist/mobile/context-compact/compact-message-collector.mjs +2 -2
  93. package/dist/mobile/context-compact/compact-orchestrator.js +21 -1
  94. package/dist/mobile/context-compact/compact-orchestrator.mjs +34 -33
  95. package/dist/mobile/context-compact/compact-resume-prefetch.mjs +4 -4
  96. package/dist/mobile/context-compact/compact-summarizer-engine-artifact.js +19 -0
  97. package/dist/mobile/context-compact/compact-summarizer-engine-artifact.mjs +18 -17
  98. package/dist/mobile/context-compact/compact-summarizer-llm-request.js +19 -0
  99. package/dist/mobile/context-compact/compact-summarizer-llm-request.mjs +10 -9
  100. package/dist/mobile/context-compact/compact-summarizer-llm.js +19 -0
  101. package/dist/mobile/context-compact/compact-summarizer-llm.mjs +11 -10
  102. package/dist/mobile/context-compact/compact-summarizer.js +19 -0
  103. package/dist/mobile/context-compact/compact-summarizer.mjs +15 -14
  104. package/dist/mobile/context-compact/compact-write-verifier.mjs +2 -2
  105. package/dist/mobile/context-compact/context-budget-gate.js +14 -2
  106. package/dist/mobile/context-compact/context-budget-gate.mjs +2 -2
  107. package/dist/mobile/context-compact/runtime-compact-hook.js +33 -2
  108. package/dist/mobile/context-compact/runtime-compact-hook.mjs +99 -98
  109. package/dist/mobile/group/conductor-llm.js +19 -0
  110. package/dist/mobile/group/conductor-llm.mjs +13 -12
  111. package/dist/mobile/group/conductor-plan-llm.js +19 -0
  112. package/dist/mobile/group/conductor-plan-llm.mjs +19 -18
  113. package/dist/mobile/group/delivery-verification.mjs +4 -4
  114. package/dist/mobile/group/direct-chat-group-context.mjs +1 -1
  115. package/dist/mobile/group/execution-plan.mjs +5 -5
  116. package/dist/mobile/group/floor-scheduler.mjs +7 -7
  117. package/dist/mobile/group/floor-state-store.mjs +6 -6
  118. package/dist/mobile/group/group-api-handlers.mjs +38 -38
  119. package/dist/mobile/group/group-peer-private-context.mjs +1 -1
  120. package/dist/mobile/group/group-session.mjs +19 -19
  121. package/dist/mobile/group/index.mjs +32 -32
  122. package/dist/mobile/group/memory-supplement.mjs +10 -10
  123. package/dist/mobile/group/orchestrator.mjs +30 -30
  124. package/dist/mobile/group/pipeline-ceo-dept-mention-parse.mjs +3 -3
  125. package/dist/mobile/group/pipeline-handoff-verification.mjs +3 -3
  126. package/dist/mobile/group/pipeline-turn-outcome.mjs +2 -2
  127. package/dist/mobile/group/plan-runtime.mjs +18 -18
  128. package/dist/mobile/group/relation-distill.mjs +8 -8
  129. package/dist/mobile/group/runtime-integration.mjs +36 -36
  130. package/dist/mobile/index.js +336 -31
  131. package/dist/mobile/index.mjs +164 -163
  132. package/dist/mobile/interrupted-turn.js +5 -0
  133. package/dist/mobile/interrupted-turn.mjs +3 -1
  134. package/dist/mobile/memory-contract-r1-prefetch.mjs +11 -11
  135. package/dist/mobile/memory-contract-r5-empty-result.mjs +12 -12
  136. package/dist/mobile/memory-runtime-v2/eval-runner.mjs +4 -4
  137. package/dist/mobile/memory-runtime-v2/evidence-plan.mjs +5 -5
  138. package/dist/mobile/memory-runtime-v2/index.mjs +15 -15
  139. package/dist/mobile/memory-runtime-v2/memory-control-plane.mjs +5 -5
  140. package/dist/mobile/memory-runtime-v2/memory-readiness.mjs +5 -5
  141. package/dist/mobile/memory-runtime-v2/orchestrator.mjs +3 -3
  142. package/dist/mobile/memory-runtime-v2/public-api.mjs +6 -6
  143. package/dist/mobile/model-context-window-budget.js +16 -2
  144. package/dist/mobile/model-context-window-budget.mjs +3 -1
  145. package/dist/mobile/native-anthropic-messages-stream.js +223 -7
  146. package/dist/mobile/native-anthropic-messages-stream.mjs +11 -10
  147. package/dist/mobile/native-anthropic-turn-errors.mjs +2 -2
  148. package/dist/mobile/native-openai-text-stream.js +223 -6
  149. package/dist/mobile/native-openai-text-stream.mjs +2 -1
  150. package/dist/mobile/native-reply-route.js +19 -0
  151. package/dist/mobile/native-reply-route.mjs +10 -9
  152. package/dist/mobile/native-reply-system-prompt-layers.js +21 -1
  153. package/dist/mobile/native-reply-system-prompt-layers.mjs +96 -95
  154. package/dist/mobile/native-request-diagnostics.js +230 -0
  155. package/dist/mobile/native-request-diagnostics.mjs +17 -0
  156. package/dist/mobile/native-stream-block-emit.js +19 -0
  157. package/dist/mobile/native-stream-block-emit.mjs +2 -1
  158. package/dist/mobile/openai-completions-turn-runner.js +224 -8
  159. package/dist/mobile/openai-completions-turn-runner.mjs +104 -103
  160. package/dist/mobile/reply-dispatch-warmup.mjs +2 -2
  161. package/dist/mobile/runtime.js +336 -31
  162. package/dist/mobile/runtime.mjs +161 -160
  163. package/dist/mobile/stream-inbound/mobile-text-stream-pipeline.mjs +3 -3
  164. package/dist/mobile/tool-use-input-normalize.js +21 -1
  165. package/dist/mobile/tool-use-input-normalize.mjs +98 -97
  166. package/dist/mobile/tools/mobile-compact-tool-bridge.js +21 -1
  167. package/dist/mobile/tools/mobile-compact-tool-bridge.mjs +98 -97
  168. package/dist/org/dept-context.mjs +4 -4
  169. package/dist/org/index.mjs +14 -14
  170. package/dist/owned-tools/ceo-confirm-requirements.mjs +12 -12
  171. package/dist/owned-tools/ceo-decision.mjs +18 -18
  172. package/dist/owned-tools/ceo-ops-brief.mjs +12 -12
  173. package/dist/owned-tools/ceo-redirect.mjs +37 -37
  174. package/dist/owned-tools/commit-stack-lesson.mjs +13 -13
  175. package/dist/owned-tools/compact/execute.js +21 -1
  176. package/dist/owned-tools/compact/execute.mjs +96 -95
  177. package/dist/owned-tools/compact/gateway-tool-factory.js +21 -1
  178. package/dist/owned-tools/compact/gateway-tool-factory.mjs +97 -96
  179. package/dist/owned-tools/compact/registry.js +21 -1
  180. package/dist/owned-tools/compact/registry.mjs +95 -94
  181. package/dist/owned-tools/context-compact.js +21 -1
  182. package/dist/owned-tools/context-compact.mjs +42 -41
  183. package/dist/owned-tools/groups-history.mjs +1 -1
  184. package/dist/owned-tools/handoff.mjs +17 -17
  185. package/dist/owned-tools/memory-control.mjs +7 -7
  186. package/dist/owned-tools/memory-runtime-eval.mjs +6 -6
  187. package/dist/owned-tools/message.mjs +2 -2
  188. package/dist/owned-tools/models-list.mjs +2 -2
  189. package/dist/owned-tools/register-owned-providers.mjs +5 -5
  190. package/dist/owned-tools/registry.js +21 -1
  191. package/dist/owned-tools/registry.mjs +94 -93
  192. package/dist/owned-tools/router.js +21 -1
  193. package/dist/owned-tools/router.mjs +95 -94
  194. package/dist/owned-tools/runtime-bridge.js +21 -1
  195. package/dist/owned-tools/runtime-bridge.mjs +96 -95
  196. package/dist/owned-tools/session-status.mjs +1 -1
  197. package/dist/owned-tools/sessions-history-resolver.mjs +2 -2
  198. package/dist/owned-tools/sessions-history.mjs +1 -1
  199. package/dist/owned-tools/sessions-send.mjs +1 -1
  200. package/dist/owned-tools/subagents.mjs +1 -1
  201. package/dist/owned-tools/tool-contract-prompt.js +21 -1
  202. package/dist/owned-tools/tool-contract-prompt.mjs +95 -94
  203. package/dist/owned-tools/tool-result-envelope.js +21 -1
  204. package/dist/owned-tools/tool-result-envelope.mjs +97 -96
  205. package/dist/owned-tools/tool-usage-guide.js +21 -1
  206. package/dist/owned-tools/tool-usage-guide.mjs +94 -93
  207. package/dist/owned-tools/tts.mjs +4 -4
  208. package/dist/owned-tools/web-smoke.mjs +6 -6
  209. package/dist/project/file-tool-scope-default.mjs +6 -6
  210. package/dist/project-pipeline/handlers.mjs +37 -37
  211. package/dist/project-pipeline/index.mjs +40 -40
  212. package/dist/project-pipeline/pipeline-routing.mjs +2 -2
  213. package/dist/project-pipeline/post-close-skill-evolution.mjs +5 -5
  214. package/dist/project-pipeline/project-store.mjs +5 -5
  215. package/gateway-core/README.md +6 -0
  216. package/package.json +5 -2
  217. package/dist/{chunk-UNZ3D3B3.mjs → chunk-3OXBG4OP.mjs} +5 -5
  218. package/dist/{chunk-NRJWLPTI.mjs → chunk-6AY6OPO5.mjs} +3 -3
  219. package/dist/{chunk-JA65ZG3H.mjs → chunk-6ZWKLMY3.mjs} +4 -4
  220. package/dist/{chunk-T23H5D4O.mjs → chunk-AINHKBJW.mjs} +3 -3
  221. package/dist/{chunk-2BGXTBZX.mjs → chunk-D3N7EHB2.mjs} +8 -8
  222. package/dist/{chunk-JIY7IOQ5.mjs → chunk-DRY7AJMM.mjs} +3 -3
  223. package/dist/{chunk-QM7MTC5Q.mjs → chunk-H6LMX5G5.mjs} +3 -3
  224. package/dist/{chunk-2TBXT3PD.mjs → chunk-J74WVZGF.mjs} +6 -6
  225. package/dist/{chunk-WPLDZLAL.mjs → chunk-L7PMYQN5.mjs} +3 -3
  226. package/dist/{chunk-CORUFGMR.mjs → chunk-N3YQ5IL6.mjs} +7 -7
  227. package/dist/{chunk-5LUTMHVL.mjs → chunk-NXKHSX4M.mjs} +3 -3
  228. package/dist/{chunk-MGWYJD5Q.mjs → chunk-QCSNRVL2.mjs} +8 -8
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  buildMvpAnthropicToolSchemas,
3
3
  executeAnthropicToolUse
4
- } from "./chunk-QUXUHJZW.mjs";
4
+ } from "./chunk-SQHTVHQ7.mjs";
5
5
  import {
6
6
  appendNativeStreamTextDelta,
7
7
  mergeNativeStreamTextDelta,
@@ -9,7 +9,13 @@ import {
9
9
  mergeOpenAiToolCallDelta,
10
10
  readNativeStreamBlockMinChars,
11
11
  readNativeStreamLiveDeliverEnabled
12
- } from "./chunk-YAD4VG2K.mjs";
12
+ } from "./chunk-BHT6B2TV.mjs";
13
+ import {
14
+ applyConfiguredMaxTokens,
15
+ fetchNativeProviderWithRetry,
16
+ formatRequestShape,
17
+ stringifyJsonRequestBody
18
+ } from "./chunk-E5LABIPO.mjs";
13
19
  import {
14
20
  parseOpenAiCompletionsSseDataLine
15
21
  } from "./chunk-C36JYBG7.mjs";
@@ -433,15 +439,37 @@ async function runNativeOpenAiCompletionsTurnToDispatcher(params) {
433
439
  if (params.providerAccelerationPlan || providerAcceleration.application.applied || providerAcceleration.application.warnings.length > 0) {
434
440
  params.log(formatProviderAccelerationApplication(providerAcceleration.application));
435
441
  }
442
+ applyConfiguredMaxTokens(requestBody, cfg.maxTokens);
443
+ const { bodyText, bodyBytes } = stringifyJsonRequestBody(requestBody);
436
444
  params.log(
437
- `[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}`
445
+ `[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({
446
+ bodyBytes,
447
+ messages,
448
+ tools: toolsForRequest,
449
+ maxTokens: requestBody.max_tokens
450
+ })
451
+ );
452
+ const res = await fetchNativeProviderWithRetry(
453
+ url,
454
+ {
455
+ method: "POST",
456
+ headers: adapter.buildHeaders(cfg),
457
+ body: bodyText,
458
+ signal: params.signal
459
+ },
460
+ {
461
+ label: "openai-turn",
462
+ providerId: cfg.providerId,
463
+ model: cfg.model,
464
+ adapter: adapter.id,
465
+ iteration,
466
+ bodyBytes,
467
+ messages,
468
+ tools: toolsForRequest,
469
+ maxTokens: requestBody.max_tokens,
470
+ log: params.log
471
+ }
438
472
  );
439
- const res = await fetch(url, {
440
- method: "POST",
441
- headers: adapter.buildHeaders(cfg),
442
- body: JSON.stringify(requestBody),
443
- signal: params.signal
444
- });
445
473
  if (!res.ok) {
446
474
  const t = await res.text();
447
475
  if (policyToolChoiceApplied && requestAttempt === 0 && isOpenAiToolChoiceCompatibilityHttpError(res.status, t)) {
@@ -3,11 +3,11 @@ import {
3
3
  } from "./chunk-NZPFW3RO.mjs";
4
4
  import {
5
5
  createInitialFloorState
6
- } from "./chunk-BHMWYAVS.mjs";
6
+ } from "./chunk-DXPZNBSQ.mjs";
7
7
  import {
8
8
  getGroupFloorState,
9
9
  setGroupFloorState
10
- } from "./chunk-LFZAVCVW.mjs";
10
+ } from "./chunk-AJNXWGX2.mjs";
11
11
  import {
12
12
  GROUP_FLOOR_PLAN_SCHEDULING_REASON
13
13
  } from "./chunk-INHFVKZY.mjs";
@@ -22,16 +22,10 @@ import {
22
22
  linkTeamToProject,
23
23
  submitProjectBrief,
24
24
  updateOrgProjectCeoSettings
25
- } from "./chunk-UNZ3D3B3.mjs";
25
+ } from "./chunk-3OXBG4OP.mjs";
26
26
  import {
27
27
  isOrgPipelineCharter
28
- } from "./chunk-TAQQSDJN.mjs";
29
- import {
30
- ORG_PIPELINE_CHARTER_RULES,
31
- ORG_PIPELINE_DEPT_ORDER,
32
- ORG_PIPELINE_TEMPLATE_ID,
33
- resolveDeptRoleAssignments
34
- } from "./chunk-LREFRIQQ.mjs";
28
+ } from "./chunk-6SYECCCG.mjs";
35
29
  import {
36
30
  PipelineCharterValidationError,
37
31
  buildMembersFromDepartments,
@@ -42,6 +36,12 @@ import {
42
36
  import {
43
37
  parseDynamicDeptSlugFromPhase
44
38
  } from "./chunk-6XBAYBWZ.mjs";
39
+ import {
40
+ ORG_PIPELINE_CHARTER_RULES,
41
+ ORG_PIPELINE_DEPT_ORDER,
42
+ ORG_PIPELINE_TEMPLATE_ID,
43
+ resolveDeptRoleAssignments
44
+ } from "./chunk-LREFRIQQ.mjs";
45
45
  import {
46
46
  ensureOrgPipelineCharter,
47
47
  ensureTeamCharterFromMembers,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  assessPipelineHandoffFromToolCalls
3
- } from "./chunk-T23H5D4O.mjs";
3
+ } from "./chunk-AINHKBJW.mjs";
4
4
 
5
5
  // src/mobile/group/pipeline-handoff-verification.ts
6
6
  var PIPELINE_HANDOFF_CLAIM_PATTERN = /(?:已交接|已经完成交接|交接给|交给(?:产品|研发|审计|调研)|handoff(?:\s*工具)?(?:已|成功)|(?:product|research|dev|audit)_active|流水线(?:已|正常)推进|下游(?:部门)?已激活|补交\s*handoff)/i;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  assessPipelineHandoffClaimVerification
3
- } from "./chunk-MWRQORKQ.mjs";
3
+ } from "./chunk-XF4EURDX.mjs";
4
4
 
5
5
  // src/mobile/group/delivery-verification.ts
6
6
  var COMPLETION_CLAIM_PATTERN = /(?:已完成|已经完成|做完了|搞定了|修改成功|写入成功|创建成功|删除成功|已改成|已更新|已保存)/i;
package/dist/index.js CHANGED
@@ -39902,6 +39902,199 @@ function parseOpenAiCompletionsSseDataLine(line) {
39902
39902
  }
39903
39903
  }
39904
39904
 
39905
+ // src/mobile/native-request-diagnostics.ts
39906
+ function compactLogValue(value, maxLen = 180) {
39907
+ const text2 = String(value ?? "").replace(/\s+/g, " ").trim();
39908
+ if (!text2) {
39909
+ return "";
39910
+ }
39911
+ return text2.length > maxLen ? `${text2.slice(0, maxLen)}...` : text2;
39912
+ }
39913
+ function readErrorProp(value, key2) {
39914
+ return value && typeof value === "object" ? value[key2] : void 0;
39915
+ }
39916
+ function positiveInteger2(value) {
39917
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
39918
+ return void 0;
39919
+ }
39920
+ return Math.trunc(value);
39921
+ }
39922
+ function formatNativeFetchErrorForLog(error) {
39923
+ const parts = [];
39924
+ let current = error;
39925
+ for (let depth = 0; depth < 4 && current !== null && current !== void 0; depth += 1) {
39926
+ const prefix = depth === 0 ? "error" : `cause${depth}`;
39927
+ const name = compactLogValue(readErrorProp(current, "name"));
39928
+ const message = current instanceof Error ? compactLogValue(current.message) : compactLogValue(readErrorProp(current, "message") ?? current);
39929
+ const code = compactLogValue(readErrorProp(current, "code"));
39930
+ const errno = compactLogValue(readErrorProp(current, "errno"));
39931
+ if (name) parts.push(`${prefix}Name=${name}`);
39932
+ if (message) parts.push(`${prefix}Message=${message}`);
39933
+ if (code) parts.push(`${prefix}Code=${code}`);
39934
+ if (errno) parts.push(`${prefix}Errno=${errno}`);
39935
+ current = readErrorProp(current, "cause");
39936
+ }
39937
+ return parts.join(" ") || "error=unknown";
39938
+ }
39939
+ function applyConfiguredMaxTokens(requestBody, maxTokens) {
39940
+ const configured = positiveInteger2(maxTokens);
39941
+ if (configured === void 0) {
39942
+ return;
39943
+ }
39944
+ const existing = positiveInteger2(requestBody.max_tokens);
39945
+ requestBody.max_tokens = existing === void 0 ? configured : Math.min(existing, configured);
39946
+ }
39947
+ function stringifyJsonRequestBody(requestBody) {
39948
+ const bodyText = JSON.stringify(requestBody);
39949
+ return {
39950
+ bodyText,
39951
+ bodyBytes: Buffer.byteLength(bodyText, "utf8")
39952
+ };
39953
+ }
39954
+ function formatRequestShape(input) {
39955
+ const messageCount = Array.isArray(input.messages) ? input.messages.length : 0;
39956
+ const toolCount = Array.isArray(input.tools) ? input.tools.length : 0;
39957
+ const maxTokens = positiveInteger2(input.maxTokens);
39958
+ return `bodyBytes=${input.bodyBytes} messages=${messageCount} tools=${toolCount} max_tokens=${maxTokens ?? "n/a"}`;
39959
+ }
39960
+ var DEFAULT_PROVIDER_FETCH_MAX_ATTEMPTS = 2;
39961
+ var HARD_PROVIDER_FETCH_MAX_ATTEMPTS = 4;
39962
+ var DEFAULT_PROVIDER_FETCH_RETRY_BASE_MS = 350;
39963
+ var HARD_PROVIDER_FETCH_RETRY_BASE_MS = 5e3;
39964
+ var RETRYABLE_NATIVE_FETCH_RE = new RegExp(
39965
+ [
39966
+ "fetch failed",
39967
+ "UND_ERR_CONNECT_TIMEOUT",
39968
+ "UND_ERR_HEADERS_TIMEOUT",
39969
+ "UND_ERR_SOCKET",
39970
+ "ECONNRESET",
39971
+ "ETIMEDOUT",
39972
+ "ECONNREFUSED",
39973
+ "ENOTFOUND",
39974
+ "EAI_AGAIN",
39975
+ "socket hang up",
39976
+ "network connection lost",
39977
+ "network request failed"
39978
+ ].join("|"),
39979
+ "i"
39980
+ );
39981
+ function readClampedPositiveEnvInt(env, key2, fallback, max) {
39982
+ const raw = (env[key2] ?? "").trim();
39983
+ const n = Number.parseInt(raw, 10);
39984
+ if (!Number.isFinite(n) || n <= 0) {
39985
+ return fallback;
39986
+ }
39987
+ return Math.min(Math.trunc(n), max);
39988
+ }
39989
+ function readClampedNonNegativeEnvInt(env, key2, fallback, max) {
39990
+ const raw = (env[key2] ?? "").trim();
39991
+ const n = Number.parseInt(raw, 10);
39992
+ if (!Number.isFinite(n) || n < 0) {
39993
+ return fallback;
39994
+ }
39995
+ return Math.min(Math.trunc(n), max);
39996
+ }
39997
+ function readProviderFetchMaxAttempts(env) {
39998
+ return readClampedPositiveEnvInt(
39999
+ env,
40000
+ "XKZOOM_NATIVE_PROVIDER_FETCH_MAX_ATTEMPTS",
40001
+ DEFAULT_PROVIDER_FETCH_MAX_ATTEMPTS,
40002
+ HARD_PROVIDER_FETCH_MAX_ATTEMPTS
40003
+ );
40004
+ }
40005
+ function readProviderFetchRetryBaseMs(env) {
40006
+ return readClampedNonNegativeEnvInt(
40007
+ env,
40008
+ "XKZOOM_NATIVE_PROVIDER_FETCH_RETRY_BASE_MS",
40009
+ DEFAULT_PROVIDER_FETCH_RETRY_BASE_MS,
40010
+ HARD_PROVIDER_FETCH_RETRY_BASE_MS
40011
+ );
40012
+ }
40013
+ function isAbortLikeFetchError(error) {
40014
+ const name = compactLogValue(readErrorProp(error, "name"));
40015
+ return name === "AbortError";
40016
+ }
40017
+ function collectFetchErrorText(error) {
40018
+ const parts = [];
40019
+ let current = error;
40020
+ for (let depth = 0; depth < 4 && current !== null && current !== void 0; depth += 1) {
40021
+ parts.push(
40022
+ compactLogValue(readErrorProp(current, "name")),
40023
+ current instanceof Error ? compactLogValue(current.message) : compactLogValue(readErrorProp(current, "message") ?? current),
40024
+ compactLogValue(readErrorProp(current, "code")),
40025
+ compactLogValue(readErrorProp(current, "errno"))
40026
+ );
40027
+ current = readErrorProp(current, "cause");
40028
+ }
40029
+ return parts.filter(Boolean).join(" ");
40030
+ }
40031
+ function isRetryableNativeProviderFetchError(error) {
40032
+ return !isAbortLikeFetchError(error) && RETRYABLE_NATIVE_FETCH_RE.test(collectFetchErrorText(error));
40033
+ }
40034
+ function formatProviderRetryContext(context) {
40035
+ const parts = [
40036
+ `provider=${context.providerId}`,
40037
+ `model=${context.model}`,
40038
+ context.adapter ? `adapter=${context.adapter}` : "",
40039
+ typeof context.iteration === "number" ? `iteration=${context.iteration}` : ""
40040
+ ];
40041
+ return parts.filter(Boolean).join(" ");
40042
+ }
40043
+ function asAbortSignal(signal) {
40044
+ if (signal && typeof signal === "object" && "aborted" in signal) {
40045
+ return signal;
40046
+ }
40047
+ return void 0;
40048
+ }
40049
+ async function waitForProviderFetchRetryDelay(delayMs, signal) {
40050
+ if (delayMs <= 0) {
40051
+ return;
40052
+ }
40053
+ if (signal?.aborted) {
40054
+ throw new DOMException("Aborted", "AbortError");
40055
+ }
40056
+ await new Promise((resolve10, reject) => {
40057
+ const timer = setTimeout(() => {
40058
+ signal?.removeEventListener("abort", onAbort);
40059
+ resolve10();
40060
+ }, delayMs);
40061
+ const onAbort = () => {
40062
+ clearTimeout(timer);
40063
+ reject(new DOMException("Aborted", "AbortError"));
40064
+ };
40065
+ signal?.addEventListener("abort", onAbort, { once: true });
40066
+ });
40067
+ }
40068
+ async function fetchNativeProviderWithRetry(url, init, context, env = process.env) {
40069
+ const maxAttempts = readProviderFetchMaxAttempts(env);
40070
+ const retryBaseMs = readProviderFetchRetryBaseMs(env);
40071
+ const signal = asAbortSignal(init.signal);
40072
+ for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
40073
+ try {
40074
+ return await fetch(url, init);
40075
+ } catch (error) {
40076
+ const retry = attempt < maxAttempts && !signal?.aborted && isRetryableNativeProviderFetchError(error);
40077
+ context.log(
40078
+ `[XKZOOM][native-reply][${context.label}] fetch_failed ${url} ${formatProviderRetryContext(context)} attempt=${attempt}/${maxAttempts} retry=${retry ? 1 : 0} ${formatRequestShape({
40079
+ bodyBytes: context.bodyBytes,
40080
+ messages: context.messages,
40081
+ tools: context.tools,
40082
+ maxTokens: context.maxTokens
40083
+ })} ${formatNativeFetchErrorForLog(error)}`
40084
+ );
40085
+ if (!retry) {
40086
+ throw error;
40087
+ }
40088
+ const delayMs = retryBaseMs * attempt;
40089
+ context.log(
40090
+ `[XKZOOM][native-reply][${context.label}] fetch_retry ${url} ${formatProviderRetryContext(context)} nextAttempt=${attempt + 1}/${maxAttempts} delayMs=${delayMs}`
40091
+ );
40092
+ await waitForProviderFetchRetryDelay(delayMs, signal);
40093
+ }
40094
+ }
40095
+ throw new Error(`native provider fetch retry exhausted: ${url}`);
40096
+ }
40097
+
39905
40098
  // src/mobile/native-openai-text-stream.ts
39906
40099
  var isRecord6 = isGatewayConfigRecord;
39907
40100
  function resolveOpenAiCompletionsBodyExtras(provider, baseUrl) {
@@ -40122,12 +40315,36 @@ async function runNativeOpenAiTextStreamToDispatcher(params) {
40122
40315
  if (params.providerAccelerationPlan || providerAcceleration.application.applied || providerAcceleration.application.warnings.length > 0) {
40123
40316
  params.log(formatProviderAccelerationApplication(providerAcceleration.application));
40124
40317
  }
40125
- const res = await fetch(url, {
40126
- method: "POST",
40127
- headers: buildBearerOpenAiHeaders(cfg),
40128
- body: JSON.stringify(requestBody),
40129
- signal: params.signal
40130
- });
40318
+ applyConfiguredMaxTokens(requestBody, cfg.maxTokens);
40319
+ const { bodyText, bodyBytes } = stringifyJsonRequestBody(requestBody);
40320
+ params.log(
40321
+ `[XKZOOM][native-reply][openai-completions] request_shape ${formatRequestShape({
40322
+ bodyBytes,
40323
+ messages: chatMessages,
40324
+ tools: toolsForRequest,
40325
+ maxTokens: requestBody.max_tokens
40326
+ })}`
40327
+ );
40328
+ const res = await fetchNativeProviderWithRetry(
40329
+ url,
40330
+ {
40331
+ method: "POST",
40332
+ headers: buildBearerOpenAiHeaders(cfg),
40333
+ body: bodyText,
40334
+ signal: params.signal
40335
+ },
40336
+ {
40337
+ label: "openai-completions",
40338
+ providerId: cfg.providerId,
40339
+ model: cfg.model,
40340
+ adapter: "openai-completions",
40341
+ bodyBytes,
40342
+ messages: chatMessages,
40343
+ tools: toolsForRequest,
40344
+ maxTokens: requestBody.max_tokens,
40345
+ log: params.log
40346
+ }
40347
+ );
40131
40348
  if (!res.ok) {
40132
40349
  const t = await res.text();
40133
40350
  throw new Error(`native OpenAI HTTP ${res.status}: ${t.slice(0, 500)}`);
@@ -41584,7 +41801,8 @@ async function runNativeAnthropicMessagesStreamToDispatcher(params) {
41584
41801
  if (params.providerAccelerationPlan || providerAcceleration.application.applied || providerAcceleration.application.warnings.length > 0) {
41585
41802
  params.log(formatProviderAccelerationApplication2(providerAcceleration.application));
41586
41803
  }
41587
- const thinkingForBody = selectAnthropicAdapterByBaseUrl(cfg.baseUrl).resolveThinkingForBody({
41804
+ const adapter = selectAnthropicAdapterByBaseUrl(cfg.baseUrl);
41805
+ const thinkingForBody = adapter.resolveThinkingForBody({
41588
41806
  reasoningMode: params.reasoningMode,
41589
41807
  model: cfg.model,
41590
41808
  configuredThinking: requestBody.thinking
@@ -41592,12 +41810,34 @@ async function runNativeAnthropicMessagesStreamToDispatcher(params) {
41592
41810
  if (thinkingForBody !== void 0) {
41593
41811
  requestBody.thinking = thinkingForBody;
41594
41812
  }
41595
- const res = await fetch(url, {
41596
- method: "POST",
41597
- headers: buildNativeAnthropicRequestHeaders(cfg),
41598
- body: JSON.stringify(requestBody),
41599
- signal: params.signal
41600
- });
41813
+ applyConfiguredMaxTokens(requestBody, cfg.maxTokens);
41814
+ const { bodyText, bodyBytes } = stringifyJsonRequestBody(requestBody);
41815
+ params.log(
41816
+ `[XKZOOM][native-reply][anthropic-messages] request_shape ${formatRequestShape({
41817
+ bodyBytes,
41818
+ messages: transcriptMessages,
41819
+ maxTokens: requestBody.max_tokens
41820
+ })}`
41821
+ );
41822
+ const res = await fetchNativeProviderWithRetry(
41823
+ url,
41824
+ {
41825
+ method: "POST",
41826
+ headers: buildNativeAnthropicRequestHeaders(cfg),
41827
+ body: bodyText,
41828
+ signal: params.signal
41829
+ },
41830
+ {
41831
+ label: "anthropic-messages",
41832
+ providerId: cfg.providerId,
41833
+ model: cfg.model,
41834
+ adapter: adapter.id,
41835
+ bodyBytes,
41836
+ messages: transcriptMessages,
41837
+ maxTokens: requestBody.max_tokens,
41838
+ log: params.log
41839
+ }
41840
+ );
41601
41841
  if (!res.ok) {
41602
41842
  const t = await res.text();
41603
41843
  throw new Error(`native anthropic-messages HTTP ${res.status}: ${t.slice(0, 500)}`);
@@ -43740,15 +43980,27 @@ function buildSessionTranscriptMeterFromMessages(messages) {
43740
43980
  var TRANSCRIPT_BUDGET_BYTES_PER_TOKEN = 4;
43741
43981
  var TRANSCRIPT_CONTEXT_WINDOW_RATIO = 0.35;
43742
43982
  var MIN_TRANSCRIPT_BUDGET_BYTES = 64 * 1024;
43743
- var MAX_TRANSCRIPT_BUDGET_BYTES = 4 * 1024 * 1024;
43744
- function positiveInteger2(value) {
43983
+ var DEFAULT_MAX_NATIVE_TRANSCRIPT_BUDGET_BYTES = 128 * 1024;
43984
+ var HARD_MAX_TRANSCRIPT_BUDGET_BYTES = 4 * 1024 * 1024;
43985
+ function positiveInteger3(value) {
43745
43986
  if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
43746
43987
  return void 0;
43747
43988
  }
43748
43989
  return Math.trunc(value);
43749
43990
  }
43991
+ function readMaxTranscriptBudgetBytes(env = process.env) {
43992
+ const raw = env.XKZOOM_NATIVE_TRANSCRIPT_MAX_REQUEST_BYTES?.trim();
43993
+ if (!raw) {
43994
+ return DEFAULT_MAX_NATIVE_TRANSCRIPT_BUDGET_BYTES;
43995
+ }
43996
+ const parsed = Number.parseInt(raw, 10);
43997
+ if (!Number.isFinite(parsed) || parsed <= 0) {
43998
+ return DEFAULT_MAX_NATIVE_TRANSCRIPT_BUDGET_BYTES;
43999
+ }
44000
+ return Math.min(HARD_MAX_TRANSCRIPT_BUDGET_BYTES, Math.max(MIN_TRANSCRIPT_BUDGET_BYTES, parsed));
44001
+ }
43750
44002
  function resolveTranscriptBudgetBytesForContextWindow(contextWindowTokens) {
43751
- const tokens = positiveInteger2(contextWindowTokens);
44003
+ const tokens = positiveInteger3(contextWindowTokens);
43752
44004
  if (tokens === void 0) {
43753
44005
  return void 0;
43754
44006
  }
@@ -43756,7 +44008,7 @@ function resolveTranscriptBudgetBytesForContextWindow(contextWindowTokens) {
43756
44008
  tokens * TRANSCRIPT_CONTEXT_WINDOW_RATIO * TRANSCRIPT_BUDGET_BYTES_PER_TOKEN
43757
44009
  );
43758
44010
  return Math.min(
43759
- MAX_TRANSCRIPT_BUDGET_BYTES,
44011
+ readMaxTranscriptBudgetBytes(),
43760
44012
  Math.max(MIN_TRANSCRIPT_BUDGET_BYTES, estimated)
43761
44013
  );
43762
44014
  }
@@ -57545,15 +57797,37 @@ async function runNativeOpenAiCompletionsTurnToDispatcher(params) {
57545
57797
  if (params.providerAccelerationPlan || providerAcceleration.application.applied || providerAcceleration.application.warnings.length > 0) {
57546
57798
  params.log(formatProviderAccelerationApplication3(providerAcceleration.application));
57547
57799
  }
57800
+ applyConfiguredMaxTokens(requestBody, cfg.maxTokens);
57801
+ const { bodyText, bodyBytes } = stringifyJsonRequestBody(requestBody);
57548
57802
  params.log(
57549
- `[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}`
57803
+ `[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({
57804
+ bodyBytes,
57805
+ messages,
57806
+ tools: toolsForRequest,
57807
+ maxTokens: requestBody.max_tokens
57808
+ })
57809
+ );
57810
+ const res = await fetchNativeProviderWithRetry(
57811
+ url,
57812
+ {
57813
+ method: "POST",
57814
+ headers: adapter.buildHeaders(cfg),
57815
+ body: bodyText,
57816
+ signal: params.signal
57817
+ },
57818
+ {
57819
+ label: "openai-turn",
57820
+ providerId: cfg.providerId,
57821
+ model: cfg.model,
57822
+ adapter: adapter.id,
57823
+ iteration,
57824
+ bodyBytes,
57825
+ messages,
57826
+ tools: toolsForRequest,
57827
+ maxTokens: requestBody.max_tokens,
57828
+ log: params.log
57829
+ }
57550
57830
  );
57551
- const res = await fetch(url, {
57552
- method: "POST",
57553
- headers: adapter.buildHeaders(cfg),
57554
- body: JSON.stringify(requestBody),
57555
- signal: params.signal
57556
- });
57557
57831
  if (!res.ok) {
57558
57832
  const t = await res.text();
57559
57833
  if (policyToolChoiceApplied && requestAttempt === 0 && isOpenAiToolChoiceCompatibilityHttpError(res.status, t)) {
@@ -58384,15 +58658,37 @@ function createFetchAnthropicTurnStreamFn(cfg, log, providerAccelerationPlan, pr
58384
58658
  toolChoiceLog = `skipped(${policy.kind}:adapter-undefined)`;
58385
58659
  }
58386
58660
  }
58661
+ applyConfiguredMaxTokens(requestBody, cfg.maxTokens);
58662
+ const { bodyText, bodyBytes } = stringifyJsonRequestBody(requestBody);
58387
58663
  log(
58388
- `[XKZOOM][native-reply][anthropic-turn] POST ${url} adapter=${adapter.id} provider=${cfg.providerId} model=${cfg.model} iteration=${req.iteration} tools=${Array.isArray(req.tools) ? req.tools.length : 0} tool_choice=${toolChoiceLog}` + (requestBody.thinking !== void 0 && requestBody.thinking !== null ? ` thinking=${requestBody.thinking.type ?? "1"}` : " thinking=0")
58664
+ `[XKZOOM][native-reply][anthropic-turn] POST ${url} adapter=${adapter.id} provider=${cfg.providerId} model=${cfg.model} iteration=${req.iteration} tools=${Array.isArray(req.tools) ? req.tools.length : 0} tool_choice=${toolChoiceLog}` + (requestBody.thinking !== void 0 && requestBody.thinking !== null ? ` thinking=${requestBody.thinking.type ?? "1"}` : " thinking=0") + ` ${formatRequestShape({
58665
+ bodyBytes,
58666
+ messages: req.messages,
58667
+ tools: req.tools,
58668
+ maxTokens: requestBody.max_tokens
58669
+ })}`
58670
+ );
58671
+ const res = await fetchNativeProviderWithRetry(
58672
+ url,
58673
+ {
58674
+ method: "POST",
58675
+ headers,
58676
+ body: bodyText,
58677
+ signal
58678
+ },
58679
+ {
58680
+ label: "anthropic-turn",
58681
+ providerId: cfg.providerId,
58682
+ model: cfg.model,
58683
+ adapter: adapter.id,
58684
+ iteration: req.iteration,
58685
+ bodyBytes,
58686
+ messages: req.messages,
58687
+ tools: req.tools,
58688
+ maxTokens: requestBody.max_tokens,
58689
+ log
58690
+ }
58389
58691
  );
58390
- const res = await fetch(url, {
58391
- method: "POST",
58392
- headers,
58393
- body: JSON.stringify(requestBody),
58394
- signal
58395
- });
58396
58692
  if (!res.ok) {
58397
58693
  const t = await res.text();
58398
58694
  throw new Error(`native anthropic-turn HTTP ${res.status}: ${t.slice(0, 500)}`);
@@ -58642,6 +58938,9 @@ function createInterruptedTurnSnapshot(params) {
58642
58938
  ...clipText(errMessage, MAX_PREVIEW_CHARS) ? { errorMessage: clipText(errMessage, MAX_PREVIEW_CHARS) } : {}
58643
58939
  };
58644
58940
  }
58941
+ function hasInterruptedTurnRecoveryEvidence(snapshot) {
58942
+ return snapshot.visibleTextLength > 0 || Boolean(snapshot.assistantPartialText?.trim()) || Boolean(snapshot.toolCallSummaries?.length);
58943
+ }
58645
58944
  function isInterruptedTurnResumeRequest(text2) {
58646
58945
  const raw = typeof text2 === "string" ? text2.trim() : "";
58647
58946
  if (!raw) {
@@ -62725,6 +63024,12 @@ ${inbound.bodyText}` : inbound.bodyText;
62725
63024
  lastToolName: params.lastToolName ?? lastToolNameForInterruptedTurn,
62726
63025
  error: params.error
62727
63026
  });
63027
+ if (!hasInterruptedTurnRecoveryEvidence(snapshot)) {
63028
+ this.logInfo(
63029
+ `[XKZOOM][turn-timeout][snapshot] skipped session=${session.id} conversationId=${identity.conversationId ?? "none"} userMessage=${userMessage.id} targetMessage=${target.id} assistantMessage=${assistantMessage?.id ?? "none"} turn_timeout_kind=${snapshot.turn_timeout_kind} recoverableEvidence=0 visibleTextLength=${snapshot.visibleTextLength}`
63030
+ );
63031
+ return null;
63032
+ }
62728
63033
  target.interruptedTurn = snapshot;
62729
63034
  this.store.persistMessage(session.id, target.id);
62730
63035
  this.logInfo(