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.
Files changed (227) hide show
  1. package/README.md +57 -43
  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/package.json +2 -2
  216. package/dist/{chunk-UNZ3D3B3.mjs → chunk-3OXBG4OP.mjs} +5 -5
  217. package/dist/{chunk-NRJWLPTI.mjs → chunk-6AY6OPO5.mjs} +3 -3
  218. package/dist/{chunk-JA65ZG3H.mjs → chunk-6ZWKLMY3.mjs} +4 -4
  219. package/dist/{chunk-T23H5D4O.mjs → chunk-AINHKBJW.mjs} +3 -3
  220. package/dist/{chunk-2BGXTBZX.mjs → chunk-D3N7EHB2.mjs} +8 -8
  221. package/dist/{chunk-JIY7IOQ5.mjs → chunk-DRY7AJMM.mjs} +3 -3
  222. package/dist/{chunk-QM7MTC5Q.mjs → chunk-H6LMX5G5.mjs} +3 -3
  223. package/dist/{chunk-2TBXT3PD.mjs → chunk-J74WVZGF.mjs} +6 -6
  224. package/dist/{chunk-WPLDZLAL.mjs → chunk-L7PMYQN5.mjs} +3 -3
  225. package/dist/{chunk-CORUFGMR.mjs → chunk-N3YQ5IL6.mjs} +7 -7
  226. package/dist/{chunk-5LUTMHVL.mjs → chunk-NXKHSX4M.mjs} +3 -3
  227. package/dist/{chunk-MGWYJD5Q.mjs → chunk-QCSNRVL2.mjs} +8 -8
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  buildPairwiseRelationImpression
3
- } from "../../chunk-NYG3IUXK.mjs";
4
- import "../../chunk-BHMWYAVS.mjs";
3
+ } from "../../chunk-TER7DFHP.mjs";
4
+ import "../../chunk-DXPZNBSQ.mjs";
5
5
  import "../../chunk-MXXTDG5V.mjs";
6
6
  import "../../chunk-FY2QAWA6.mjs";
7
7
  import "../../chunk-7XD4NIAR.mjs";
@@ -12,18 +12,18 @@ import "../../chunk-DT2WBACK.mjs";
12
12
  import "../../chunk-6SZCPHCL.mjs";
13
13
  import "../../chunk-INHFVKZY.mjs";
14
14
  import "../../chunk-BHA3SMKH.mjs";
15
- import "../../chunk-OJYZLNSD.mjs";
16
- import "../../chunk-UNZ3D3B3.mjs";
15
+ import "../../chunk-3OXBG4OP.mjs";
17
16
  import "../../chunk-NMPWPD2P.mjs";
18
- import "../../chunk-LREFRIQQ.mjs";
17
+ import "../../chunk-FXJGKIYT.mjs";
18
+ import "../../chunk-6GQKKEQA.mjs";
19
+ import "../../chunk-QWSPMYE5.mjs";
20
+ import "../../chunk-OJYZLNSD.mjs";
19
21
  import "../../chunk-KHQZ35IL.mjs";
20
22
  import "../../chunk-QOKQVPZ6.mjs";
21
23
  import "../../chunk-HQLCDNMN.mjs";
22
24
  import "../../chunk-6XBAYBWZ.mjs";
25
+ import "../../chunk-LREFRIQQ.mjs";
23
26
  import "../../chunk-KDZWHGGN.mjs";
24
- import "../../chunk-FXJGKIYT.mjs";
25
- import "../../chunk-6GQKKEQA.mjs";
26
- import "../../chunk-QWSPMYE5.mjs";
27
27
  import "../../chunk-KIY5JPAA.mjs";
28
28
  import "../../chunk-4V5RUOBT.mjs";
29
29
  import "../../chunk-67ZUQKRE.mjs";
@@ -10,24 +10,24 @@ import {
10
10
  tryKickPipelinePostCloseRound,
11
11
  tryRedirectPipelineFloor,
12
12
  tryStopPipelineAfterTerminalDecision
13
- } from "../../chunk-OCQUSYRP.mjs";
13
+ } from "../../chunk-3EV63LAA.mjs";
14
14
  import "../../chunk-UFV3WER4.mjs";
15
15
  import "../../chunk-BSG6WLML.mjs";
16
- import "../../chunk-A23OTVH2.mjs";
17
- import "../../chunk-NYG3IUXK.mjs";
16
+ import "../../chunk-6LKZYMIW.mjs";
17
+ import "../../chunk-TER7DFHP.mjs";
18
18
  import "../../chunk-A5OB3QEO.mjs";
19
19
  import "../../chunk-CRN5R5GG.mjs";
20
20
  import "../../chunk-VAERBRDX.mjs";
21
21
  import "../../chunk-L4Z7ND7Z.mjs";
22
- import "../../chunk-YILSXMZI.mjs";
22
+ import "../../chunk-KI7AMK7P.mjs";
23
23
  import "../../chunk-UPZP6IT3.mjs";
24
24
  import "../../chunk-YH3GFC5X.mjs";
25
25
  import "../../chunk-C3CZKA3E.mjs";
26
- import "../../chunk-GIAML5K5.mjs";
26
+ import "../../chunk-DQ7J7RST.mjs";
27
27
  import "../../chunk-DCAXPHP4.mjs";
28
28
  import "../../chunk-QFW3ZP6R.mjs";
29
29
  import "../../chunk-RSMNVCI6.mjs";
30
- import "../../chunk-BHMWYAVS.mjs";
30
+ import "../../chunk-DXPZNBSQ.mjs";
31
31
  import "../../chunk-MXXTDG5V.mjs";
32
32
  import "../../chunk-FY2QAWA6.mjs";
33
33
  import "../../chunk-7XD4NIAR.mjs";
@@ -41,24 +41,20 @@ import "../../chunk-HJCKITZG.mjs";
41
41
  import "../../chunk-TOCC5J66.mjs";
42
42
  import "../../chunk-DT2WBACK.mjs";
43
43
  import "../../chunk-AZVEPDT6.mjs";
44
- import "../../chunk-S4AIBE4O.mjs";
45
- import "../../chunk-LOGWIK2T.mjs";
46
- import "../../chunk-Z7C7KX3U.mjs";
47
- import "../../chunk-QRMV5CAE.mjs";
48
44
  import "../../chunk-RZOILUDC.mjs";
49
45
  import "../../chunk-BJ6YI2DJ.mjs";
46
+ import "../../chunk-6SZCPHCL.mjs";
50
47
  import "../../chunk-4POYX4AW.mjs";
51
48
  import "../../chunk-NJYJS6MU.mjs";
52
- import "../../chunk-6SZCPHCL.mjs";
53
- import "../../chunk-LFZAVCVW.mjs";
49
+ import "../../chunk-AJNXWGX2.mjs";
54
50
  import "../../chunk-INHFVKZY.mjs";
55
- import "../../chunk-24GJWXMG.mjs";
56
- import "../../chunk-ETD5LGJY.mjs";
57
- import "../../chunk-MWRQORKQ.mjs";
58
- import "../../chunk-T23H5D4O.mjs";
51
+ import "../../chunk-7MOQ462O.mjs";
52
+ import "../../chunk-Z3COATFF.mjs";
53
+ import "../../chunk-XF4EURDX.mjs";
54
+ import "../../chunk-AINHKBJW.mjs";
59
55
  import "../../chunk-BHA3SMKH.mjs";
60
56
  import "../../chunk-GYZ4IXUD.mjs";
61
- import "../../chunk-A5DUSLHF.mjs";
57
+ import "../../chunk-ED4H2DM7.mjs";
62
58
  import "../../chunk-Q7NYATKS.mjs";
63
59
  import "../../chunk-M2GS2K6H.mjs";
64
60
  import "../../chunk-24ASGNQU.mjs";
@@ -78,42 +74,46 @@ import "../../chunk-R4TQVAMP.mjs";
78
74
  import "../../chunk-U2HA2HLE.mjs";
79
75
  import "../../chunk-KPJOJH6H.mjs";
80
76
  import "../../chunk-QJX4OXDZ.mjs";
81
- import "../../chunk-LCR7EVVU.mjs";
82
77
  import "../../chunk-6ZVXCJTG.mjs";
83
78
  import "../../chunk-VTZUX3F6.mjs";
84
79
  import "../../chunk-DPNXFDFK.mjs";
85
80
  import "../../chunk-WRZWEAMN.mjs";
86
81
  import "../../chunk-IKQPTA2J.mjs";
82
+ import "../../chunk-LCR7EVVU.mjs";
87
83
  import "../../chunk-GEXTQELG.mjs";
88
- import "../../chunk-5DMSAPS2.mjs";
84
+ import "../../chunk-AFD4DOFH.mjs";
85
+ import "../../chunk-APQRVOZQ.mjs";
89
86
  import "../../chunk-LDBMLTV2.mjs";
90
- import "../../chunk-OJYZLNSD.mjs";
91
87
  import "../../chunk-F23B3GJV.mjs";
92
- import "../../chunk-UNZ3D3B3.mjs";
88
+ import "../../chunk-3OXBG4OP.mjs";
93
89
  import "../../chunk-NMPWPD2P.mjs";
94
- import "../../chunk-TAQQSDJN.mjs";
90
+ import "../../chunk-FXJGKIYT.mjs";
91
+ import "../../chunk-VE2NKY44.mjs";
92
+ import "../../chunk-DJPMIVQY.mjs";
93
+ import "../../chunk-IXY2XMGE.mjs";
94
+ import "../../chunk-PS6X3CND.mjs";
95
+ import "../../chunk-BF7STJF7.mjs";
96
+ import "../../chunk-DSSVZ47P.mjs";
97
+ import "../../chunk-SBBPQQYS.mjs";
98
+ import "../../chunk-6GQKKEQA.mjs";
99
+ import "../../chunk-QWSPMYE5.mjs";
100
+ import "../../chunk-S4AIBE4O.mjs";
101
+ import "../../chunk-LOGWIK2T.mjs";
102
+ import "../../chunk-OJYZLNSD.mjs";
103
+ import "../../chunk-Z7C7KX3U.mjs";
104
+ import "../../chunk-QRMV5CAE.mjs";
105
+ import "../../chunk-6SYECCCG.mjs";
95
106
  import "../../chunk-HJK5A3DD.mjs";
96
- import "../../chunk-JA65ZG3H.mjs";
97
- import "../../chunk-LREFRIQQ.mjs";
107
+ import "../../chunk-6ZWKLMY3.mjs";
98
108
  import "../../chunk-KHQZ35IL.mjs";
99
109
  import "../../chunk-QOKQVPZ6.mjs";
100
110
  import "../../chunk-HQLCDNMN.mjs";
101
111
  import "../../chunk-6XBAYBWZ.mjs";
112
+ import "../../chunk-LREFRIQQ.mjs";
102
113
  import "../../chunk-I3T745ZX.mjs";
114
+ import "../../chunk-KDZWHGGN.mjs";
103
115
  import "../../chunk-Q7YUHFMS.mjs";
104
116
  import "../../chunk-2B6C5VWQ.mjs";
105
- import "../../chunk-KDZWHGGN.mjs";
106
- import "../../chunk-AFD4DOFH.mjs";
107
- import "../../chunk-DJPMIVQY.mjs";
108
- import "../../chunk-FXJGKIYT.mjs";
109
- import "../../chunk-IXY2XMGE.mjs";
110
- import "../../chunk-BF7STJF7.mjs";
111
- import "../../chunk-PS6X3CND.mjs";
112
- import "../../chunk-VE2NKY44.mjs";
113
- import "../../chunk-DSSVZ47P.mjs";
114
- import "../../chunk-SBBPQQYS.mjs";
115
- import "../../chunk-6GQKKEQA.mjs";
116
- import "../../chunk-QWSPMYE5.mjs";
117
117
  import "../../chunk-JYDRRVX4.mjs";
118
118
  import "../../chunk-YT3WVUYZ.mjs";
119
119
  import "../../chunk-DT4YTQQN.mjs";
@@ -36405,6 +36405,199 @@ function parseOpenAiCompletionsSseDataLine(line) {
36405
36405
  }
36406
36406
  }
36407
36407
 
36408
+ // src/mobile/native-request-diagnostics.ts
36409
+ function compactLogValue(value, maxLen = 180) {
36410
+ const text2 = String(value ?? "").replace(/\s+/g, " ").trim();
36411
+ if (!text2) {
36412
+ return "";
36413
+ }
36414
+ return text2.length > maxLen ? `${text2.slice(0, maxLen)}...` : text2;
36415
+ }
36416
+ function readErrorProp(value, key2) {
36417
+ return value && typeof value === "object" ? value[key2] : void 0;
36418
+ }
36419
+ function positiveInteger2(value) {
36420
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
36421
+ return void 0;
36422
+ }
36423
+ return Math.trunc(value);
36424
+ }
36425
+ function formatNativeFetchErrorForLog(error) {
36426
+ const parts = [];
36427
+ let current = error;
36428
+ for (let depth = 0; depth < 4 && current !== null && current !== void 0; depth += 1) {
36429
+ const prefix = depth === 0 ? "error" : `cause${depth}`;
36430
+ const name = compactLogValue(readErrorProp(current, "name"));
36431
+ const message = current instanceof Error ? compactLogValue(current.message) : compactLogValue(readErrorProp(current, "message") ?? current);
36432
+ const code = compactLogValue(readErrorProp(current, "code"));
36433
+ const errno = compactLogValue(readErrorProp(current, "errno"));
36434
+ if (name) parts.push(`${prefix}Name=${name}`);
36435
+ if (message) parts.push(`${prefix}Message=${message}`);
36436
+ if (code) parts.push(`${prefix}Code=${code}`);
36437
+ if (errno) parts.push(`${prefix}Errno=${errno}`);
36438
+ current = readErrorProp(current, "cause");
36439
+ }
36440
+ return parts.join(" ") || "error=unknown";
36441
+ }
36442
+ function applyConfiguredMaxTokens(requestBody, maxTokens) {
36443
+ const configured = positiveInteger2(maxTokens);
36444
+ if (configured === void 0) {
36445
+ return;
36446
+ }
36447
+ const existing = positiveInteger2(requestBody.max_tokens);
36448
+ requestBody.max_tokens = existing === void 0 ? configured : Math.min(existing, configured);
36449
+ }
36450
+ function stringifyJsonRequestBody(requestBody) {
36451
+ const bodyText = JSON.stringify(requestBody);
36452
+ return {
36453
+ bodyText,
36454
+ bodyBytes: Buffer.byteLength(bodyText, "utf8")
36455
+ };
36456
+ }
36457
+ function formatRequestShape(input) {
36458
+ const messageCount = Array.isArray(input.messages) ? input.messages.length : 0;
36459
+ const toolCount = Array.isArray(input.tools) ? input.tools.length : 0;
36460
+ const maxTokens = positiveInteger2(input.maxTokens);
36461
+ return `bodyBytes=${input.bodyBytes} messages=${messageCount} tools=${toolCount} max_tokens=${maxTokens ?? "n/a"}`;
36462
+ }
36463
+ var DEFAULT_PROVIDER_FETCH_MAX_ATTEMPTS = 2;
36464
+ var HARD_PROVIDER_FETCH_MAX_ATTEMPTS = 4;
36465
+ var DEFAULT_PROVIDER_FETCH_RETRY_BASE_MS = 350;
36466
+ var HARD_PROVIDER_FETCH_RETRY_BASE_MS = 5e3;
36467
+ var RETRYABLE_NATIVE_FETCH_RE = new RegExp(
36468
+ [
36469
+ "fetch failed",
36470
+ "UND_ERR_CONNECT_TIMEOUT",
36471
+ "UND_ERR_HEADERS_TIMEOUT",
36472
+ "UND_ERR_SOCKET",
36473
+ "ECONNRESET",
36474
+ "ETIMEDOUT",
36475
+ "ECONNREFUSED",
36476
+ "ENOTFOUND",
36477
+ "EAI_AGAIN",
36478
+ "socket hang up",
36479
+ "network connection lost",
36480
+ "network request failed"
36481
+ ].join("|"),
36482
+ "i"
36483
+ );
36484
+ function readClampedPositiveEnvInt(env, key2, fallback, max) {
36485
+ const raw = (env[key2] ?? "").trim();
36486
+ const n = Number.parseInt(raw, 10);
36487
+ if (!Number.isFinite(n) || n <= 0) {
36488
+ return fallback;
36489
+ }
36490
+ return Math.min(Math.trunc(n), max);
36491
+ }
36492
+ function readClampedNonNegativeEnvInt(env, key2, fallback, max) {
36493
+ const raw = (env[key2] ?? "").trim();
36494
+ const n = Number.parseInt(raw, 10);
36495
+ if (!Number.isFinite(n) || n < 0) {
36496
+ return fallback;
36497
+ }
36498
+ return Math.min(Math.trunc(n), max);
36499
+ }
36500
+ function readProviderFetchMaxAttempts(env) {
36501
+ return readClampedPositiveEnvInt(
36502
+ env,
36503
+ "XKZOOM_NATIVE_PROVIDER_FETCH_MAX_ATTEMPTS",
36504
+ DEFAULT_PROVIDER_FETCH_MAX_ATTEMPTS,
36505
+ HARD_PROVIDER_FETCH_MAX_ATTEMPTS
36506
+ );
36507
+ }
36508
+ function readProviderFetchRetryBaseMs(env) {
36509
+ return readClampedNonNegativeEnvInt(
36510
+ env,
36511
+ "XKZOOM_NATIVE_PROVIDER_FETCH_RETRY_BASE_MS",
36512
+ DEFAULT_PROVIDER_FETCH_RETRY_BASE_MS,
36513
+ HARD_PROVIDER_FETCH_RETRY_BASE_MS
36514
+ );
36515
+ }
36516
+ function isAbortLikeFetchError(error) {
36517
+ const name = compactLogValue(readErrorProp(error, "name"));
36518
+ return name === "AbortError";
36519
+ }
36520
+ function collectFetchErrorText(error) {
36521
+ const parts = [];
36522
+ let current = error;
36523
+ for (let depth = 0; depth < 4 && current !== null && current !== void 0; depth += 1) {
36524
+ parts.push(
36525
+ compactLogValue(readErrorProp(current, "name")),
36526
+ current instanceof Error ? compactLogValue(current.message) : compactLogValue(readErrorProp(current, "message") ?? current),
36527
+ compactLogValue(readErrorProp(current, "code")),
36528
+ compactLogValue(readErrorProp(current, "errno"))
36529
+ );
36530
+ current = readErrorProp(current, "cause");
36531
+ }
36532
+ return parts.filter(Boolean).join(" ");
36533
+ }
36534
+ function isRetryableNativeProviderFetchError(error) {
36535
+ return !isAbortLikeFetchError(error) && RETRYABLE_NATIVE_FETCH_RE.test(collectFetchErrorText(error));
36536
+ }
36537
+ function formatProviderRetryContext(context) {
36538
+ const parts = [
36539
+ `provider=${context.providerId}`,
36540
+ `model=${context.model}`,
36541
+ context.adapter ? `adapter=${context.adapter}` : "",
36542
+ typeof context.iteration === "number" ? `iteration=${context.iteration}` : ""
36543
+ ];
36544
+ return parts.filter(Boolean).join(" ");
36545
+ }
36546
+ function asAbortSignal(signal) {
36547
+ if (signal && typeof signal === "object" && "aborted" in signal) {
36548
+ return signal;
36549
+ }
36550
+ return void 0;
36551
+ }
36552
+ async function waitForProviderFetchRetryDelay(delayMs, signal) {
36553
+ if (delayMs <= 0) {
36554
+ return;
36555
+ }
36556
+ if (signal?.aborted) {
36557
+ throw new DOMException("Aborted", "AbortError");
36558
+ }
36559
+ await new Promise((resolve10, reject) => {
36560
+ const timer = setTimeout(() => {
36561
+ signal?.removeEventListener("abort", onAbort);
36562
+ resolve10();
36563
+ }, delayMs);
36564
+ const onAbort = () => {
36565
+ clearTimeout(timer);
36566
+ reject(new DOMException("Aborted", "AbortError"));
36567
+ };
36568
+ signal?.addEventListener("abort", onAbort, { once: true });
36569
+ });
36570
+ }
36571
+ async function fetchNativeProviderWithRetry(url, init, context, env = process.env) {
36572
+ const maxAttempts = readProviderFetchMaxAttempts(env);
36573
+ const retryBaseMs = readProviderFetchRetryBaseMs(env);
36574
+ const signal = asAbortSignal(init.signal);
36575
+ for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
36576
+ try {
36577
+ return await fetch(url, init);
36578
+ } catch (error) {
36579
+ const retry = attempt < maxAttempts && !signal?.aborted && isRetryableNativeProviderFetchError(error);
36580
+ context.log(
36581
+ `[XKZOOM][native-reply][${context.label}] fetch_failed ${url} ${formatProviderRetryContext(context)} attempt=${attempt}/${maxAttempts} retry=${retry ? 1 : 0} ${formatRequestShape({
36582
+ bodyBytes: context.bodyBytes,
36583
+ messages: context.messages,
36584
+ tools: context.tools,
36585
+ maxTokens: context.maxTokens
36586
+ })} ${formatNativeFetchErrorForLog(error)}`
36587
+ );
36588
+ if (!retry) {
36589
+ throw error;
36590
+ }
36591
+ const delayMs = retryBaseMs * attempt;
36592
+ context.log(
36593
+ `[XKZOOM][native-reply][${context.label}] fetch_retry ${url} ${formatProviderRetryContext(context)} nextAttempt=${attempt + 1}/${maxAttempts} delayMs=${delayMs}`
36594
+ );
36595
+ await waitForProviderFetchRetryDelay(delayMs, signal);
36596
+ }
36597
+ }
36598
+ throw new Error(`native provider fetch retry exhausted: ${url}`);
36599
+ }
36600
+
36408
36601
  // src/mobile/native-openai-text-stream.ts
36409
36602
  var isRecord6 = isGatewayConfigRecord;
36410
36603
  function resolveOpenAiCompletionsBodyExtras(provider, baseUrl) {
@@ -36625,12 +36818,36 @@ async function runNativeOpenAiTextStreamToDispatcher(params) {
36625
36818
  if (params.providerAccelerationPlan || providerAcceleration.application.applied || providerAcceleration.application.warnings.length > 0) {
36626
36819
  params.log(formatProviderAccelerationApplication(providerAcceleration.application));
36627
36820
  }
36628
- const res = await fetch(url, {
36629
- method: "POST",
36630
- headers: buildBearerOpenAiHeaders(cfg),
36631
- body: JSON.stringify(requestBody),
36632
- signal: params.signal
36633
- });
36821
+ applyConfiguredMaxTokens(requestBody, cfg.maxTokens);
36822
+ const { bodyText, bodyBytes } = stringifyJsonRequestBody(requestBody);
36823
+ params.log(
36824
+ `[XKZOOM][native-reply][openai-completions] request_shape ${formatRequestShape({
36825
+ bodyBytes,
36826
+ messages: chatMessages,
36827
+ tools: toolsForRequest,
36828
+ maxTokens: requestBody.max_tokens
36829
+ })}`
36830
+ );
36831
+ const res = await fetchNativeProviderWithRetry(
36832
+ url,
36833
+ {
36834
+ method: "POST",
36835
+ headers: buildBearerOpenAiHeaders(cfg),
36836
+ body: bodyText,
36837
+ signal: params.signal
36838
+ },
36839
+ {
36840
+ label: "openai-completions",
36841
+ providerId: cfg.providerId,
36842
+ model: cfg.model,
36843
+ adapter: "openai-completions",
36844
+ bodyBytes,
36845
+ messages: chatMessages,
36846
+ tools: toolsForRequest,
36847
+ maxTokens: requestBody.max_tokens,
36848
+ log: params.log
36849
+ }
36850
+ );
36634
36851
  if (!res.ok) {
36635
36852
  const t = await res.text();
36636
36853
  throw new Error(`native OpenAI HTTP ${res.status}: ${t.slice(0, 500)}`);
@@ -38087,7 +38304,8 @@ async function runNativeAnthropicMessagesStreamToDispatcher(params) {
38087
38304
  if (params.providerAccelerationPlan || providerAcceleration.application.applied || providerAcceleration.application.warnings.length > 0) {
38088
38305
  params.log(formatProviderAccelerationApplication2(providerAcceleration.application));
38089
38306
  }
38090
- const thinkingForBody = selectAnthropicAdapterByBaseUrl(cfg.baseUrl).resolveThinkingForBody({
38307
+ const adapter = selectAnthropicAdapterByBaseUrl(cfg.baseUrl);
38308
+ const thinkingForBody = adapter.resolveThinkingForBody({
38091
38309
  reasoningMode: params.reasoningMode,
38092
38310
  model: cfg.model,
38093
38311
  configuredThinking: requestBody.thinking
@@ -38095,12 +38313,34 @@ async function runNativeAnthropicMessagesStreamToDispatcher(params) {
38095
38313
  if (thinkingForBody !== void 0) {
38096
38314
  requestBody.thinking = thinkingForBody;
38097
38315
  }
38098
- const res = await fetch(url, {
38099
- method: "POST",
38100
- headers: buildNativeAnthropicRequestHeaders(cfg),
38101
- body: JSON.stringify(requestBody),
38102
- signal: params.signal
38103
- });
38316
+ applyConfiguredMaxTokens(requestBody, cfg.maxTokens);
38317
+ const { bodyText, bodyBytes } = stringifyJsonRequestBody(requestBody);
38318
+ params.log(
38319
+ `[XKZOOM][native-reply][anthropic-messages] request_shape ${formatRequestShape({
38320
+ bodyBytes,
38321
+ messages: transcriptMessages,
38322
+ maxTokens: requestBody.max_tokens
38323
+ })}`
38324
+ );
38325
+ const res = await fetchNativeProviderWithRetry(
38326
+ url,
38327
+ {
38328
+ method: "POST",
38329
+ headers: buildNativeAnthropicRequestHeaders(cfg),
38330
+ body: bodyText,
38331
+ signal: params.signal
38332
+ },
38333
+ {
38334
+ label: "anthropic-messages",
38335
+ providerId: cfg.providerId,
38336
+ model: cfg.model,
38337
+ adapter: adapter.id,
38338
+ bodyBytes,
38339
+ messages: transcriptMessages,
38340
+ maxTokens: requestBody.max_tokens,
38341
+ log: params.log
38342
+ }
38343
+ );
38104
38344
  if (!res.ok) {
38105
38345
  const t = await res.text();
38106
38346
  throw new Error(`native anthropic-messages HTTP ${res.status}: ${t.slice(0, 500)}`);
@@ -40242,15 +40482,27 @@ function buildSessionTranscriptMeterFromMessages(messages) {
40242
40482
  var TRANSCRIPT_BUDGET_BYTES_PER_TOKEN = 4;
40243
40483
  var TRANSCRIPT_CONTEXT_WINDOW_RATIO = 0.35;
40244
40484
  var MIN_TRANSCRIPT_BUDGET_BYTES = 64 * 1024;
40245
- var MAX_TRANSCRIPT_BUDGET_BYTES = 4 * 1024 * 1024;
40246
- function positiveInteger2(value) {
40485
+ var DEFAULT_MAX_NATIVE_TRANSCRIPT_BUDGET_BYTES = 128 * 1024;
40486
+ var HARD_MAX_TRANSCRIPT_BUDGET_BYTES = 4 * 1024 * 1024;
40487
+ function positiveInteger3(value) {
40247
40488
  if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
40248
40489
  return void 0;
40249
40490
  }
40250
40491
  return Math.trunc(value);
40251
40492
  }
40493
+ function readMaxTranscriptBudgetBytes(env = process.env) {
40494
+ const raw = env.XKZOOM_NATIVE_TRANSCRIPT_MAX_REQUEST_BYTES?.trim();
40495
+ if (!raw) {
40496
+ return DEFAULT_MAX_NATIVE_TRANSCRIPT_BUDGET_BYTES;
40497
+ }
40498
+ const parsed = Number.parseInt(raw, 10);
40499
+ if (!Number.isFinite(parsed) || parsed <= 0) {
40500
+ return DEFAULT_MAX_NATIVE_TRANSCRIPT_BUDGET_BYTES;
40501
+ }
40502
+ return Math.min(HARD_MAX_TRANSCRIPT_BUDGET_BYTES, Math.max(MIN_TRANSCRIPT_BUDGET_BYTES, parsed));
40503
+ }
40252
40504
  function resolveTranscriptBudgetBytesForContextWindow(contextWindowTokens) {
40253
- const tokens = positiveInteger2(contextWindowTokens);
40505
+ const tokens = positiveInteger3(contextWindowTokens);
40254
40506
  if (tokens === void 0) {
40255
40507
  return void 0;
40256
40508
  }
@@ -40258,7 +40510,7 @@ function resolveTranscriptBudgetBytesForContextWindow(contextWindowTokens) {
40258
40510
  tokens * TRANSCRIPT_CONTEXT_WINDOW_RATIO * TRANSCRIPT_BUDGET_BYTES_PER_TOKEN
40259
40511
  );
40260
40512
  return Math.min(
40261
- MAX_TRANSCRIPT_BUDGET_BYTES,
40513
+ readMaxTranscriptBudgetBytes(),
40262
40514
  Math.max(MIN_TRANSCRIPT_BUDGET_BYTES, estimated)
40263
40515
  );
40264
40516
  }
@@ -54639,15 +54891,37 @@ async function runNativeOpenAiCompletionsTurnToDispatcher(params) {
54639
54891
  if (params.providerAccelerationPlan || providerAcceleration.application.applied || providerAcceleration.application.warnings.length > 0) {
54640
54892
  params.log(formatProviderAccelerationApplication3(providerAcceleration.application));
54641
54893
  }
54894
+ applyConfiguredMaxTokens(requestBody, cfg.maxTokens);
54895
+ const { bodyText, bodyBytes } = stringifyJsonRequestBody(requestBody);
54642
54896
  params.log(
54643
- `[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}`
54897
+ `[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({
54898
+ bodyBytes,
54899
+ messages,
54900
+ tools: toolsForRequest,
54901
+ maxTokens: requestBody.max_tokens
54902
+ })
54903
+ );
54904
+ const res = await fetchNativeProviderWithRetry(
54905
+ url,
54906
+ {
54907
+ method: "POST",
54908
+ headers: adapter.buildHeaders(cfg),
54909
+ body: bodyText,
54910
+ signal: params.signal
54911
+ },
54912
+ {
54913
+ label: "openai-turn",
54914
+ providerId: cfg.providerId,
54915
+ model: cfg.model,
54916
+ adapter: adapter.id,
54917
+ iteration,
54918
+ bodyBytes,
54919
+ messages,
54920
+ tools: toolsForRequest,
54921
+ maxTokens: requestBody.max_tokens,
54922
+ log: params.log
54923
+ }
54644
54924
  );
54645
- const res = await fetch(url, {
54646
- method: "POST",
54647
- headers: adapter.buildHeaders(cfg),
54648
- body: JSON.stringify(requestBody),
54649
- signal: params.signal
54650
- });
54651
54925
  if (!res.ok) {
54652
54926
  const t = await res.text();
54653
54927
  if (policyToolChoiceApplied && requestAttempt === 0 && isOpenAiToolChoiceCompatibilityHttpError(res.status, t)) {
@@ -55478,15 +55752,37 @@ function createFetchAnthropicTurnStreamFn(cfg, log, providerAccelerationPlan, pr
55478
55752
  toolChoiceLog = `skipped(${policy.kind}:adapter-undefined)`;
55479
55753
  }
55480
55754
  }
55755
+ applyConfiguredMaxTokens(requestBody, cfg.maxTokens);
55756
+ const { bodyText, bodyBytes } = stringifyJsonRequestBody(requestBody);
55481
55757
  log(
55482
- `[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")
55758
+ `[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({
55759
+ bodyBytes,
55760
+ messages: req.messages,
55761
+ tools: req.tools,
55762
+ maxTokens: requestBody.max_tokens
55763
+ })}`
55764
+ );
55765
+ const res = await fetchNativeProviderWithRetry(
55766
+ url,
55767
+ {
55768
+ method: "POST",
55769
+ headers,
55770
+ body: bodyText,
55771
+ signal
55772
+ },
55773
+ {
55774
+ label: "anthropic-turn",
55775
+ providerId: cfg.providerId,
55776
+ model: cfg.model,
55777
+ adapter: adapter.id,
55778
+ iteration: req.iteration,
55779
+ bodyBytes,
55780
+ messages: req.messages,
55781
+ tools: req.tools,
55782
+ maxTokens: requestBody.max_tokens,
55783
+ log
55784
+ }
55483
55785
  );
55484
- const res = await fetch(url, {
55485
- method: "POST",
55486
- headers,
55487
- body: JSON.stringify(requestBody),
55488
- signal
55489
- });
55490
55786
  if (!res.ok) {
55491
55787
  const t = await res.text();
55492
55788
  throw new Error(`native anthropic-turn HTTP ${res.status}: ${t.slice(0, 500)}`);
@@ -55736,6 +56032,9 @@ function createInterruptedTurnSnapshot(params) {
55736
56032
  ...clipText(errMessage, MAX_PREVIEW_CHARS) ? { errorMessage: clipText(errMessage, MAX_PREVIEW_CHARS) } : {}
55737
56033
  };
55738
56034
  }
56035
+ function hasInterruptedTurnRecoveryEvidence(snapshot) {
56036
+ return snapshot.visibleTextLength > 0 || Boolean(snapshot.assistantPartialText?.trim()) || Boolean(snapshot.toolCallSummaries?.length);
56037
+ }
55739
56038
  function isInterruptedTurnResumeRequest(text2) {
55740
56039
  const raw = typeof text2 === "string" ? text2.trim() : "";
55741
56040
  if (!raw) {
@@ -59813,6 +60112,12 @@ ${inbound.bodyText}` : inbound.bodyText;
59813
60112
  lastToolName: params.lastToolName ?? lastToolNameForInterruptedTurn,
59814
60113
  error: params.error
59815
60114
  });
60115
+ if (!hasInterruptedTurnRecoveryEvidence(snapshot)) {
60116
+ this.logInfo(
60117
+ `[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}`
60118
+ );
60119
+ return null;
60120
+ }
59816
60121
  target.interruptedTurn = snapshot;
59817
60122
  this.store.persistMessage(session.id, target.id);
59818
60123
  this.logInfo(