xkzoom 1.5.4 → 1.5.6

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 (423) hide show
  1. package/README.md +65 -0
  2. package/dist/{chunk-YPKHMAO4.mjs → chunk-22VRM3T3.mjs} +1 -1
  3. package/dist/{chunk-XL3MUGFG.mjs → chunk-2B3A3C2V.mjs} +1 -1
  4. package/dist/{chunk-UQLGVSQH.mjs → chunk-2F65KBU2.mjs} +8 -9
  5. package/dist/chunk-2L4VMCM2.mjs +15 -0
  6. package/dist/{chunk-WQSQXDUL.mjs → chunk-2LN3ODBA.mjs} +1 -1
  7. package/dist/{chunk-OBYPZT2S.mjs → chunk-2YB6BHIB.mjs} +9 -9
  8. package/dist/chunk-35SKU3FL.mjs +279 -0
  9. package/dist/{chunk-PETWGCGB.mjs → chunk-3JHD7MGZ.mjs} +2 -2
  10. package/dist/{chunk-PW3ULDNL.mjs → chunk-3QE7GUJC.mjs} +1 -1
  11. package/dist/{chunk-JI67TW4E.mjs → chunk-4XJFA7V3.mjs} +1 -1
  12. package/dist/{chunk-CQUISJWG.mjs → chunk-5G3UUQ36.mjs} +2 -2
  13. package/dist/{chunk-HYSOWPIC.mjs → chunk-6KCPL45H.mjs} +5 -5
  14. package/dist/{chunk-2IQAT3PE.mjs → chunk-6OY3GOUH.mjs} +6 -6
  15. package/dist/{chunk-LBZCBBHU.mjs → chunk-72IPGTJZ.mjs} +1 -1
  16. package/dist/{chunk-TVH4LII3.mjs → chunk-74S3DUNZ.mjs} +1 -1
  17. package/dist/{chunk-MPGMU75K.mjs → chunk-7C7HREZO.mjs} +12 -12
  18. package/dist/{chunk-BFSOQ5IG.mjs → chunk-7HQEB7IJ.mjs} +3 -3
  19. package/dist/{chunk-3VA3YDYL.mjs → chunk-7TKZKTS5.mjs} +1 -1
  20. package/dist/{chunk-M3ISDSQP.mjs → chunk-A4BZZNPW.mjs} +5 -5
  21. package/dist/{chunk-BJ6YI2DJ.mjs → chunk-AEE3DM6S.mjs} +1 -1
  22. package/dist/{chunk-4JXTPCOE.mjs → chunk-ANGNUW6F.mjs} +5 -5
  23. package/dist/{chunk-GZZ7KO57.mjs → chunk-BJFTC4GW.mjs} +21 -1
  24. package/dist/{chunk-GYZ4IXUD.mjs → chunk-CLN4OVFM.mjs} +3 -6
  25. package/dist/{chunk-3KJHUTOO.mjs → chunk-CLVSQ3FG.mjs} +2 -2
  26. package/dist/{chunk-IKQ7CLX3.mjs → chunk-CSKP6E6Y.mjs} +2 -2
  27. package/dist/{chunk-LWCO2YNI.mjs → chunk-CVWDLRQI.mjs} +1 -1
  28. package/dist/{chunk-FG6QCRVN.mjs → chunk-D4TNMY2O.mjs} +2 -2
  29. package/dist/{chunk-FLVJABFP.mjs → chunk-DODTDJSF.mjs} +10 -8
  30. package/dist/{chunk-MWRQORKQ.mjs → chunk-E36MAP7Y.mjs} +1 -1
  31. package/dist/{chunk-CFZVBILR.mjs → chunk-EHL345OC.mjs} +4 -4
  32. package/dist/chunk-F3Y7WDC6.mjs +108 -0
  33. package/dist/{chunk-Q33JD64H.mjs → chunk-FCK6QFJB.mjs} +1 -1
  34. package/dist/{chunk-3ZH273T7.mjs → chunk-FEEEY457.mjs} +71 -55
  35. package/dist/{chunk-MDZUWIBH.mjs → chunk-G3E2E6DD.mjs} +38 -38
  36. package/dist/{chunk-WXELBVXY.mjs → chunk-GC2H3KNZ.mjs} +1 -1
  37. package/dist/{chunk-5SE4JOKE.mjs → chunk-GHWAAAG6.mjs} +309 -262
  38. package/dist/{chunk-5YEFG7BF.mjs → chunk-GNDVHDPO.mjs} +52 -52
  39. package/dist/chunk-H4NINXMV.mjs +95 -0
  40. package/dist/{chunk-TQBVFKCT.mjs → chunk-H6W42R46.mjs} +194 -154
  41. package/dist/chunk-H7ILBOZU.mjs +48 -0
  42. package/dist/{chunk-7LEEVP5O.mjs → chunk-H7QNACAJ.mjs} +12 -12
  43. package/dist/chunk-HCYIE2PR.mjs +130 -0
  44. package/dist/{chunk-E2TTUY6R.mjs → chunk-HHPHIVCC.mjs} +11 -11
  45. package/dist/{chunk-P262PAGZ.mjs → chunk-HLYVEYML.mjs} +15 -2
  46. package/dist/{chunk-GZJMFCRG.mjs → chunk-HNYI45WM.mjs} +23 -4
  47. package/dist/{chunk-JFFBD5TV.mjs → chunk-HOII5XBJ.mjs} +17 -17
  48. package/dist/{chunk-T23H5D4O.mjs → chunk-HPZG5VVI.mjs} +3 -9
  49. package/dist/chunk-HQHICFPO.mjs +58 -0
  50. package/dist/{chunk-DRY7AJMM.mjs → chunk-HQPA2MV5.mjs} +7 -7
  51. package/dist/{chunk-NJAPWQ4D.mjs → chunk-ICKBF7KF.mjs} +2 -60
  52. package/dist/{chunk-HAI7DJD2.mjs → chunk-IEF2AMNW.mjs} +7 -7
  53. package/dist/{chunk-VIZQURO5.mjs → chunk-IGJFAE72.mjs} +9 -9
  54. package/dist/{chunk-IT2GAHAL.mjs → chunk-IHMPR5HT.mjs} +1 -1
  55. package/dist/{chunk-PJKLQF3K.mjs → chunk-INFZEMQK.mjs} +1 -1
  56. package/dist/{chunk-MKYCBV3H.mjs → chunk-J4FQVXEA.mjs} +7 -7
  57. package/dist/{chunk-27BXVTXH.mjs → chunk-JN5EMEXS.mjs} +1 -1
  58. package/dist/{chunk-4WWT6OC2.mjs → chunk-JTKSYLZE.mjs} +26 -48
  59. package/dist/{chunk-ZTKJR7OC.mjs → chunk-K5IQLMJQ.mjs} +4 -4
  60. package/dist/{chunk-GIAML5K5.mjs → chunk-K5JMXCH5.mjs} +1 -1
  61. package/dist/{chunk-JJKRD5DL.mjs → chunk-KBEY4ZQV.mjs} +4 -4
  62. package/dist/{chunk-EL6TOIFZ.mjs → chunk-KHQPC6I7.mjs} +1 -16
  63. package/dist/{chunk-VNEPNUBZ.mjs → chunk-L3PV2ZNB.mjs} +15 -15
  64. package/dist/{chunk-MQKREMOB.mjs → chunk-L7N2B4LX.mjs} +8 -8
  65. package/dist/{chunk-PS6X3CND.mjs → chunk-LKSRZTSL.mjs} +1 -0
  66. package/dist/{chunk-DCSERRXG.mjs → chunk-LNPOTNGJ.mjs} +1 -1
  67. package/dist/chunk-LOMDPHVQ.mjs +42 -0
  68. package/dist/chunk-LQHI5VK2.mjs +26 -0
  69. package/dist/{chunk-J5AXFEDQ.mjs → chunk-LTTSUVF5.mjs} +52 -52
  70. package/dist/{chunk-LESS4N25.mjs → chunk-LV3CI5A4.mjs} +5 -5
  71. package/dist/{chunk-JG3K4N5B.mjs → chunk-M3E2R3PT.mjs} +1 -1
  72. package/dist/{chunk-WPMJCKI2.mjs → chunk-M7DB4RAC.mjs} +9 -9
  73. package/dist/{chunk-COYZO24J.mjs → chunk-MCD5TOFD.mjs} +1 -1
  74. package/dist/{chunk-AP4WVS6L.mjs → chunk-MCJPAZBQ.mjs} +1 -1
  75. package/dist/{chunk-T6XDJ2QQ.mjs → chunk-MGIGU4G6.mjs} +119 -18
  76. package/dist/{chunk-ZMQ3UOGP.mjs → chunk-MMWLRPKT.mjs} +13 -1
  77. package/dist/{chunk-NIU6GWKB.mjs → chunk-MNLMVNF5.mjs} +5 -5
  78. package/dist/{chunk-W75Z6CZR.mjs → chunk-MXKSS63B.mjs} +2 -2
  79. package/dist/{chunk-TADSGGK2.mjs → chunk-N4X2MAF2.mjs} +14 -28
  80. package/dist/{chunk-E7BFLHLM.mjs → chunk-NDPDPELV.mjs} +1 -16
  81. package/dist/{chunk-24GJWXMG.mjs → chunk-NI2PDCVA.mjs} +3 -3
  82. package/dist/{chunk-BSG6WLML.mjs → chunk-NI4N35JN.mjs} +1 -1
  83. package/dist/{chunk-Z2JNJLJM.mjs → chunk-NLUF66E7.mjs} +1 -1
  84. package/dist/{chunk-RKZ56GST.mjs → chunk-NRPE77A3.mjs} +2 -2
  85. package/dist/{chunk-76TKUYY3.mjs → chunk-NTVWS2MO.mjs} +6 -6
  86. package/dist/{chunk-YYDDQEY4.mjs → chunk-NV7SYEH7.mjs} +2 -2
  87. package/dist/{chunk-6W4W5JLG.mjs → chunk-NXVXMXL5.mjs} +3 -3
  88. package/dist/{chunk-PINXXWFJ.mjs → chunk-OGT25PYJ.mjs} +1 -1
  89. package/dist/{chunk-3STOFADV.mjs → chunk-OHCBAEML.mjs} +1 -0
  90. package/dist/{chunk-L252ASZW.mjs → chunk-OPTSEYTI.mjs} +1 -1
  91. package/dist/{chunk-B4YKXZ5W.mjs → chunk-OQMIECO2.mjs} +1 -1
  92. package/dist/{chunk-D3N7EHB2.mjs → chunk-PH5QACOX.mjs} +19 -19
  93. package/dist/{chunk-6MOIFLPP.mjs → chunk-PKJLFQRF.mjs} +1 -1
  94. package/dist/{chunk-M5IU6U3O.mjs → chunk-POOU2U4R.mjs} +2 -2
  95. package/dist/{chunk-IGDJGBAI.mjs → chunk-PPMT66BN.mjs} +3 -3
  96. package/dist/{chunk-RZOILUDC.mjs → chunk-PSZPHCUP.mjs} +1 -1
  97. package/dist/{chunk-MXXTDG5V.mjs → chunk-PVSCARHF.mjs} +1 -1
  98. package/dist/chunk-PW6NSDMI.mjs +117 -0
  99. package/dist/{chunk-NHICONJ3.mjs → chunk-PZAMMLMJ.mjs} +3 -3
  100. package/dist/{chunk-IDQ5B572.mjs → chunk-QDN74R5G.mjs} +5 -5
  101. package/dist/{chunk-VWAUDB4X.mjs → chunk-QHIZRYTO.mjs} +2 -2
  102. package/dist/{chunk-2DR5RT3I.mjs → chunk-QITZ7SAD.mjs} +499 -943
  103. package/dist/{chunk-N2CMVW47.mjs → chunk-QRHBGABQ.mjs} +7 -3
  104. package/dist/{chunk-F35EHL5U.mjs → chunk-RM6GZ2SF.mjs} +7 -7
  105. package/dist/{chunk-JXDHNASC.mjs → chunk-RUMRGCYN.mjs} +85 -42
  106. package/dist/{chunk-K7RZQIPZ.mjs → chunk-S54MBJWY.mjs} +6 -4
  107. package/dist/{chunk-MBOWNG3A.mjs → chunk-S573TMN6.mjs} +2 -2
  108. package/dist/{chunk-UFV3WER4.mjs → chunk-SJ5LNKAH.mjs} +1 -1
  109. package/dist/chunk-SJWQGIQU.mjs +99 -0
  110. package/dist/{chunk-KWQEFCOY.mjs → chunk-SMHFMHQ2.mjs} +1 -1
  111. package/dist/{chunk-LGNLS7ZN.mjs → chunk-SPUVJNKO.mjs} +2 -2
  112. package/dist/{chunk-JBKRS62W.mjs → chunk-T3EJW65E.mjs} +6 -6
  113. package/dist/{chunk-6ZVXCJTG.mjs → chunk-TBLUKDLO.mjs} +91 -1
  114. package/dist/{chunk-76MFE24I.mjs → chunk-TKZWE5DB.mjs} +1 -1
  115. package/dist/{chunk-3CPVI6Y2.mjs → chunk-TRSW7QJW.mjs} +1 -1
  116. package/dist/{chunk-UXEZFEB3.mjs → chunk-TSS3NVRA.mjs} +18 -17
  117. package/dist/{chunk-WRZWEAMN.mjs → chunk-TU75ILAE.mjs} +1 -1
  118. package/dist/{chunk-E5LABIPO.mjs → chunk-U2NKGGVL.mjs} +3 -2
  119. package/dist/{chunk-KLQSTA6K.mjs → chunk-U7TPS3MS.mjs} +1 -1
  120. package/dist/chunk-UOCUHKR5.mjs +21 -0
  121. package/dist/{chunk-VA7SUI2L.mjs → chunk-VD4DIRCW.mjs} +1 -1
  122. package/dist/chunk-VHQ5WHXF.mjs +17 -0
  123. package/dist/{chunk-MRTQWCNC.mjs → chunk-VMRVJ2VF.mjs} +9 -9
  124. package/dist/{chunk-MJDJIPB4.mjs → chunk-VRG32WNZ.mjs} +1 -1
  125. package/dist/chunk-W5XO4T4J.mjs +63 -0
  126. package/dist/{chunk-5ZMY6RTR.mjs → chunk-WASHQYUB.mjs} +2 -2
  127. package/dist/{chunk-XNQJRIGR.mjs → chunk-WHP2GNEC.mjs} +66 -15
  128. package/dist/chunk-WI7PS7YW.mjs +79 -0
  129. package/dist/{chunk-GIC2RBVM.mjs → chunk-WMLZDHER.mjs} +51 -33
  130. package/dist/{chunk-4POYX4AW.mjs → chunk-WVTJXJY4.mjs} +1 -1
  131. package/dist/{chunk-KPDVZFJY.mjs → chunk-WYCMXDZT.mjs} +1 -1
  132. package/dist/{chunk-LFZAVCVW.mjs → chunk-XD5XGGQA.mjs} +1 -1
  133. package/dist/{chunk-NEDXMES6.mjs → chunk-YAGU7I25.mjs} +2 -2
  134. package/dist/{chunk-TRMEHTAT.mjs → chunk-YSI3ZONB.mjs} +1 -1
  135. package/dist/chunk-YTBKWX7J.mjs +102 -0
  136. package/dist/chunk-YYUB3HQR.mjs +119 -0
  137. package/dist/{chunk-CTKIQWTE.mjs → chunk-ZOJEC5RT.mjs} +1 -1
  138. package/dist/{chunk-2VSERWT6.mjs → chunk-ZXJY3JIP.mjs} +2 -2
  139. package/dist/index.js +7773 -6876
  140. package/dist/index.mjs +271 -256
  141. package/dist/mobile/action-planner.js +492 -389
  142. package/dist/mobile/action-planner.mjs +155 -155
  143. package/dist/mobile/agent-capabilities.js +492 -389
  144. package/dist/mobile/agent-capabilities.mjs +155 -155
  145. package/dist/mobile/agent-shop/handlers.mjs +5 -5
  146. package/dist/mobile/agents-watch.js +346 -0
  147. package/dist/mobile/agents-watch.mjs +13 -0
  148. package/dist/mobile/anthropic-incremental-deliver.mjs +4 -4
  149. package/dist/mobile/anthropic-messages-turn-runner.js +1160 -887
  150. package/dist/mobile/anthropic-messages-turn-runner.mjs +172 -170
  151. package/dist/mobile/anthropic-owned-tool-executor.js +542 -435
  152. package/dist/mobile/anthropic-owned-tool-executor.mjs +169 -169
  153. package/dist/mobile/anthropic-provider-adapter.js +23 -18
  154. package/dist/mobile/anthropic-provider-adapter.mjs +3 -2
  155. package/dist/mobile/api.js +236 -147
  156. package/dist/mobile/api.mjs +84 -83
  157. package/dist/mobile/auth.mjs +1 -1
  158. package/dist/mobile/bucket-events/emit-bucket-frame.js +327 -0
  159. package/dist/mobile/bucket-events/emit-bucket-frame.mjs +8 -3
  160. package/dist/mobile/bucket-events/register-bucket-gateway-bridge.js +320 -3
  161. package/dist/mobile/bucket-events/register-bucket-gateway-bridge.mjs +9 -4
  162. package/dist/mobile/channel.mjs +2 -2
  163. package/dist/mobile/chinese-monologue-deliver-partition.js +21 -1
  164. package/dist/mobile/chinese-monologue-deliver-partition.mjs +1 -1
  165. package/dist/mobile/context-compact/compact-artifact-enrich.mjs +18 -18
  166. package/dist/mobile/context-compact/compact-artifact-writer.mjs +3 -3
  167. package/dist/mobile/context-compact/compact-engine-artifacts.mjs +5 -5
  168. package/dist/mobile/context-compact/compact-memory-distill-job.mjs +3 -3
  169. package/dist/mobile/context-compact/compact-message-collector.mjs +2 -2
  170. package/dist/mobile/context-compact/compact-orchestrator.js +8 -22
  171. package/dist/mobile/context-compact/compact-orchestrator.mjs +41 -41
  172. package/dist/mobile/context-compact/compact-resume-prefetch.mjs +3 -3
  173. package/dist/mobile/context-compact/compact-summarizer-engine-artifact.mjs +20 -20
  174. package/dist/mobile/context-compact/compact-summarizer-llm-request.js +2 -1
  175. package/dist/mobile/context-compact/compact-summarizer-llm-request.mjs +11 -11
  176. package/dist/mobile/context-compact/compact-summarizer-llm.js +5 -19
  177. package/dist/mobile/context-compact/compact-summarizer-llm.mjs +12 -12
  178. package/dist/mobile/context-compact/compact-summarizer.js +5 -19
  179. package/dist/mobile/context-compact/compact-summarizer.mjs +17 -17
  180. package/dist/mobile/context-compact/compact-visible-tool-chain.mjs +2 -2
  181. package/dist/mobile/context-compact/compact-write-verifier.mjs +2 -2
  182. package/dist/mobile/context-compact/context-budget-gate.js +111 -84
  183. package/dist/mobile/context-compact/context-budget-gate.mjs +5 -5
  184. package/dist/mobile/context-compact/native-transcript-budget.js +151 -79
  185. package/dist/mobile/context-compact/native-transcript-budget.mjs +7 -3
  186. package/dist/mobile/context-compact/runtime-compact-hook.js +592 -468
  187. package/dist/mobile/context-compact/runtime-compact-hook.mjs +158 -158
  188. package/dist/mobile/dispatch/compact-resume-contract.js +567 -0
  189. package/dist/mobile/dispatch/compact-resume-contract.mjs +39 -0
  190. package/dist/mobile/dispatch/dispatch-context-assembly.js +588 -0
  191. package/dist/mobile/dispatch/dispatch-context-assembly.mjs +20 -0
  192. package/dist/mobile/dispatch/dispatch-route.js +547 -0
  193. package/dist/mobile/dispatch/dispatch-route.mjs +23 -0
  194. package/dist/mobile/dispatch/dispatch-streaming.js +51 -0
  195. package/dist/mobile/dispatch/dispatch-streaming.mjs +9 -0
  196. package/dist/mobile/dispatch/finalize-contract.js +147 -0
  197. package/dist/mobile/dispatch/finalize-contract.mjs +38 -0
  198. package/dist/mobile/dispatch/inbound-prep.js +671 -0
  199. package/dist/mobile/dispatch/inbound-prep.mjs +31 -0
  200. package/dist/mobile/dispatch/interrupted-snapshot.js +190 -0
  201. package/dist/mobile/dispatch/interrupted-snapshot.mjs +11 -0
  202. package/dist/mobile/dispatch/mobile-dispatch-error.js +41 -0
  203. package/dist/mobile/dispatch/mobile-dispatch-error.mjs +7 -0
  204. package/dist/mobile/dispatch/native-turn-executor.js +42662 -0
  205. package/dist/mobile/dispatch/native-turn-executor.mjs +320 -0
  206. package/dist/mobile/dispatch/native-turn-route.js +1465 -0
  207. package/dist/mobile/dispatch/native-turn-route.mjs +34 -0
  208. package/dist/mobile/dispatch/native-turn-transcript.js +1134 -0
  209. package/dist/mobile/dispatch/native-turn-transcript.mjs +29 -0
  210. package/dist/mobile/group/conductor-llm.js +5 -19
  211. package/dist/mobile/group/conductor-llm.mjs +15 -15
  212. package/dist/mobile/group/conductor-plan-llm.js +5 -19
  213. package/dist/mobile/group/conductor-plan-llm.mjs +22 -22
  214. package/dist/mobile/group/delivery-verification.js +61 -13
  215. package/dist/mobile/group/delivery-verification.mjs +4 -4
  216. package/dist/mobile/group/direct-chat-group-context.mjs +6 -6
  217. package/dist/mobile/group/execution-plan.js +61 -13
  218. package/dist/mobile/group/execution-plan.mjs +5 -5
  219. package/dist/mobile/group/floor-scheduler.mjs +9 -9
  220. package/dist/mobile/group/floor-state-store.mjs +6 -6
  221. package/dist/mobile/group/group-api-handlers.js +3 -0
  222. package/dist/mobile/group/group-api-handlers.mjs +61 -60
  223. package/dist/mobile/group/group-peer-private-context.mjs +5 -5
  224. package/dist/mobile/group/group-session.mjs +25 -25
  225. package/dist/mobile/group/index.js +63 -17
  226. package/dist/mobile/group/index.mjs +51 -50
  227. package/dist/mobile/group/memory-supplement.mjs +9 -9
  228. package/dist/mobile/group/mention.mjs +3 -3
  229. package/dist/mobile/group/normal-group-router.mjs +2 -2
  230. package/dist/mobile/group/orchestrator.js +62 -17
  231. package/dist/mobile/group/orchestrator.mjs +44 -44
  232. package/dist/mobile/group/pipeline-ceo-dept-mention-parse.mjs +3 -3
  233. package/dist/mobile/group/pipeline-handoff-verification.js +4 -10
  234. package/dist/mobile/group/pipeline-handoff-verification.mjs +3 -3
  235. package/dist/mobile/group/pipeline-turn-outcome.js +5 -14
  236. package/dist/mobile/group/pipeline-turn-outcome.mjs +2 -2
  237. package/dist/mobile/group/plan-runtime.js +61 -13
  238. package/dist/mobile/group/plan-runtime.mjs +26 -26
  239. package/dist/mobile/group/relation-distill.mjs +10 -10
  240. package/dist/mobile/group/remarks.mjs +4 -4
  241. package/dist/mobile/group/runtime-integration.js +65 -17
  242. package/dist/mobile/group/runtime-integration.mjs +59 -58
  243. package/dist/mobile/group/team-memory-runtime.mjs +3 -3
  244. package/dist/mobile/group/transcript-projection.js +1 -0
  245. package/dist/mobile/group/transcript-projection.mjs +4 -3
  246. package/dist/mobile/index.js +8046 -7126
  247. package/dist/mobile/index.mjs +256 -241
  248. package/dist/mobile/memory-contract-r1-prefetch.mjs +10 -10
  249. package/dist/mobile/memory-contract-r1.js +1 -1
  250. package/dist/mobile/memory-contract-r1.mjs +1 -1
  251. package/dist/mobile/memory-contract-r5-empty-result.mjs +11 -11
  252. package/dist/mobile/memory-runtime-v2/checkpoint-policy.js +1 -61
  253. package/dist/mobile/memory-runtime-v2/checkpoint-policy.mjs +2 -2
  254. package/dist/mobile/memory-runtime-v2/context-pack.js +16 -2
  255. package/dist/mobile/memory-runtime-v2/context-pack.mjs +2 -2
  256. package/dist/mobile/memory-runtime-v2/eval-runner.js +231 -145
  257. package/dist/mobile/memory-runtime-v2/eval-runner.mjs +20 -14
  258. package/dist/mobile/memory-runtime-v2/evidence-plan.js +233 -147
  259. package/dist/mobile/memory-runtime-v2/evidence-plan.mjs +22 -16
  260. package/dist/mobile/memory-runtime-v2/index.js +242 -147
  261. package/dist/mobile/memory-runtime-v2/index.mjs +58 -46
  262. package/dist/mobile/memory-runtime-v2/local-source-import.mjs +3 -3
  263. package/dist/mobile/memory-runtime-v2/long-run-guard.js +1 -119
  264. package/dist/mobile/memory-runtime-v2/long-run-guard.mjs +3 -3
  265. package/dist/mobile/memory-runtime-v2/memory-control-plane.js +233 -147
  266. package/dist/mobile/memory-runtime-v2/memory-control-plane.mjs +22 -16
  267. package/dist/mobile/memory-runtime-v2/memory-evidence-graph.mjs +2 -2
  268. package/dist/mobile/memory-runtime-v2/memory-readiness.js +232 -146
  269. package/dist/mobile/memory-runtime-v2/memory-readiness.mjs +22 -16
  270. package/dist/mobile/memory-runtime-v2/orchestrator.js +17 -3
  271. package/dist/mobile/memory-runtime-v2/orchestrator.mjs +7 -7
  272. package/dist/mobile/memory-runtime-v2/project-tool-event.mjs +2 -2
  273. package/dist/mobile/memory-runtime-v2/public-api.js +233 -147
  274. package/dist/mobile/memory-runtime-v2/public-api.mjs +23 -17
  275. package/dist/mobile/memory-runtime-v2/retrieval.mjs +2 -2
  276. package/dist/mobile/memory-runtime-v2/run-ledger.js +29 -48
  277. package/dist/mobile/memory-runtime-v2/run-ledger.mjs +7 -1
  278. package/dist/mobile/minimax-m3.js +2 -20
  279. package/dist/mobile/minimax-m3.mjs +3 -9
  280. package/dist/mobile/model-context-window-budget.js +19 -4
  281. package/dist/mobile/model-context-window-budget.mjs +7 -3
  282. package/dist/mobile/model-turn-runner.js +61 -2
  283. package/dist/mobile/model-turn-runner.mjs +12 -6
  284. package/dist/mobile/native-anthropic-messages-stream.js +7 -22
  285. package/dist/mobile/native-anthropic-messages-stream.mjs +12 -12
  286. package/dist/mobile/native-openai-text-stream.js +1 -2
  287. package/dist/mobile/native-openai-text-stream.mjs +3 -3
  288. package/dist/mobile/native-provider-api-key.js +2 -2
  289. package/dist/mobile/native-provider-api-key.mjs +1 -1
  290. package/dist/mobile/native-reply-route.js +25 -4
  291. package/dist/mobile/native-reply-route.mjs +13 -11
  292. package/dist/mobile/native-reply-system-prompt-layers.js +497 -392
  293. package/dist/mobile/native-reply-system-prompt-layers.mjs +155 -155
  294. package/dist/mobile/native-reply-system-prompt.js +1 -0
  295. package/dist/mobile/native-reply-system-prompt.mjs +1 -1
  296. package/dist/mobile/native-reply-transcript.js +125 -0
  297. package/dist/mobile/native-reply-transcript.mjs +7 -2
  298. package/dist/mobile/native-request-diagnostics.js +4 -2
  299. package/dist/mobile/native-request-diagnostics.mjs +3 -1
  300. package/dist/mobile/native-stream-block-emit.mjs +3 -3
  301. package/dist/mobile/openai-completions-turn-runner.js +874 -608
  302. package/dist/mobile/openai-completions-turn-runner.mjs +172 -170
  303. package/dist/mobile/reply-dispatch-warmup.mjs +5 -5
  304. package/dist/mobile/runtime.js +8272 -7353
  305. package/dist/mobile/runtime.mjs +253 -238
  306. package/dist/mobile/session-dispatch/mobile-session-agent-event-bridge.mjs +1 -1
  307. package/dist/mobile/store.mjs +3 -3
  308. package/dist/mobile/stream-inbound/mobile-text-stream-pipeline.js +321 -9
  309. package/dist/mobile/stream-inbound/mobile-text-stream-pipeline.mjs +11 -4
  310. package/dist/mobile/system-prompt-snapshot.mjs +4 -4
  311. package/dist/mobile/tool-result-final-summary.js +145 -0
  312. package/dist/mobile/tool-result-final-summary.mjs +11 -0
  313. package/dist/mobile/tool-use-input-normalize.js +492 -389
  314. package/dist/mobile/tool-use-input-normalize.mjs +158 -158
  315. package/dist/mobile/tools/mobile-compact-tool-bridge.js +492 -389
  316. package/dist/mobile/tools/mobile-compact-tool-bridge.mjs +157 -157
  317. package/dist/mobile/types.js +1 -0
  318. package/dist/mobile/types.mjs +1 -1
  319. package/dist/mobile/websocket.js +327 -0
  320. package/dist/mobile/websocket.mjs +7 -2
  321. package/dist/mobile/workspace-startup-pointer.js +1 -1
  322. package/dist/mobile/workspace-startup-pointer.mjs +1 -1
  323. package/dist/org/dept-context.mjs +4 -4
  324. package/dist/org/index.mjs +8 -8
  325. package/dist/owned-tools/agent-tool-config.mjs +2 -2
  326. package/dist/owned-tools/agents-list.mjs +6 -6
  327. package/dist/owned-tools/ceo-confirm-requirements.mjs +15 -15
  328. package/dist/owned-tools/ceo-decision.js +72 -18
  329. package/dist/owned-tools/ceo-decision.mjs +22 -22
  330. package/dist/owned-tools/ceo-ops-brief.mjs +15 -15
  331. package/dist/owned-tools/ceo-redirect.js +3 -0
  332. package/dist/owned-tools/ceo-redirect.mjs +60 -59
  333. package/dist/owned-tools/commit-stack-lesson.mjs +16 -16
  334. package/dist/owned-tools/compact/execute.js +492 -389
  335. package/dist/owned-tools/compact/execute.mjs +155 -155
  336. package/dist/owned-tools/compact/gateway-tool-factory.js +492 -389
  337. package/dist/owned-tools/compact/gateway-tool-factory.mjs +156 -156
  338. package/dist/owned-tools/compact/registry.js +492 -389
  339. package/dist/owned-tools/compact/registry.mjs +154 -154
  340. package/dist/owned-tools/context-compact.js +8 -22
  341. package/dist/owned-tools/context-compact.mjs +69 -63
  342. package/dist/owned-tools/edit.mjs +2 -2
  343. package/dist/owned-tools/exec-primitives.mjs +2 -2
  344. package/dist/owned-tools/exec.js +112 -9
  345. package/dist/owned-tools/exec.mjs +12 -8
  346. package/dist/owned-tools/groups-history.mjs +10 -10
  347. package/dist/owned-tools/handoff.mjs +21 -21
  348. package/dist/owned-tools/internal-tool-names.js +40 -0
  349. package/dist/owned-tools/internal-tool-names.mjs +9 -0
  350. package/dist/owned-tools/media-asset-library.mjs +2 -2
  351. package/dist/owned-tools/memory-control.mjs +24 -18
  352. package/dist/owned-tools/memory-get.js +7 -3
  353. package/dist/owned-tools/memory-get.mjs +1 -1
  354. package/dist/owned-tools/memory-runtime-eval.js +232 -146
  355. package/dist/owned-tools/memory-runtime-eval.mjs +23 -17
  356. package/dist/owned-tools/message.mjs +7 -7
  357. package/dist/owned-tools/models-list.mjs +2 -2
  358. package/dist/owned-tools/owned-reply.mjs +6 -6
  359. package/dist/owned-tools/owned-tool-payload-failure.js +3 -6
  360. package/dist/owned-tools/owned-tool-payload-failure.mjs +1 -1
  361. package/dist/owned-tools/process-registry.mjs +2 -2
  362. package/dist/owned-tools/process.mjs +3 -3
  363. package/dist/owned-tools/providers/minimax-video-generate.mjs +2 -2
  364. package/dist/owned-tools/providers/minimax-voice.mjs +2 -2
  365. package/dist/owned-tools/read.mjs +2 -2
  366. package/dist/owned-tools/register-owned-providers.mjs +12 -12
  367. package/dist/owned-tools/registry.js +497 -389
  368. package/dist/owned-tools/registry.mjs +158 -153
  369. package/dist/owned-tools/router.js +554 -451
  370. package/dist/owned-tools/router.mjs +154 -154
  371. package/dist/owned-tools/runtime-bridge.js +554 -451
  372. package/dist/owned-tools/runtime-bridge.mjs +156 -156
  373. package/dist/owned-tools/runtime-data.mjs +5 -5
  374. package/dist/owned-tools/session-status.mjs +7 -7
  375. package/dist/owned-tools/sessions-history-resolver.mjs +9 -9
  376. package/dist/owned-tools/sessions-history.mjs +8 -8
  377. package/dist/owned-tools/sessions-list.mjs +6 -6
  378. package/dist/owned-tools/sessions-send.mjs +7 -7
  379. package/dist/owned-tools/skills-create.mjs +6 -6
  380. package/dist/owned-tools/subagents.mjs +7 -7
  381. package/dist/owned-tools/tool-contract-prompt.js +497 -392
  382. package/dist/owned-tools/tool-contract-prompt.mjs +154 -154
  383. package/dist/owned-tools/tool-result-envelope.js +526 -405
  384. package/dist/owned-tools/tool-result-envelope.mjs +159 -159
  385. package/dist/owned-tools/tool-usage-guide.js +492 -389
  386. package/dist/owned-tools/tool-usage-guide.mjs +153 -153
  387. package/dist/owned-tools/tool-validation.mjs +2 -2
  388. package/dist/owned-tools/tts.mjs +6 -6
  389. package/dist/owned-tools/web-smoke.mjs +9 -9
  390. package/dist/owned-tools/write.mjs +2 -2
  391. package/dist/project/file-tool-scope-default.mjs +6 -6
  392. package/dist/project/file-tool-scope.js +1 -1
  393. package/dist/project/file-tool-scope.mjs +1 -1
  394. package/dist/project-pipeline/handlers.js +3 -0
  395. package/dist/project-pipeline/handlers.mjs +60 -59
  396. package/dist/project-pipeline/index.js +3 -0
  397. package/dist/project-pipeline/index.mjs +62 -61
  398. package/dist/project-pipeline/pipeline-routing.mjs +2 -2
  399. package/dist/project-pipeline/post-close-skill-evolution.mjs +5 -5
  400. package/dist/project-pipeline/project-store.mjs +5 -5
  401. package/gateway-core/runtime/reply/chinese-monologue-deliver-partition.cjs +27 -6
  402. package/package.json +2 -2
  403. package/dist/chunk-4IWTTXQE.mjs +0 -113
  404. package/dist/chunk-ETD5LGJY.mjs +0 -25
  405. package/gateway-core/README.md +0 -6
  406. package/dist/{chunk-MGWYJD5Q.mjs → chunk-2YNBEBKQ.mjs} +14 -14
  407. package/dist/{chunk-QM7MTC5Q.mjs → chunk-522D52FC.mjs} +3 -3
  408. package/dist/{chunk-QADC4VKT.mjs → chunk-5MXGINNQ.mjs} +4 -4
  409. package/dist/{chunk-BRJJML7A.mjs → chunk-5NFOBSYF.mjs} +3 -3
  410. package/dist/{chunk-NRJWLPTI.mjs → chunk-6AY6OPO5.mjs} +3 -3
  411. package/dist/{chunk-JA65ZG3H.mjs → chunk-BYGWNFCJ.mjs} +4 -4
  412. package/dist/{chunk-I7O5UR24.mjs → chunk-JX3URYQG.mjs} +4 -4
  413. package/dist/{chunk-2QCX6RPN.mjs → chunk-KCZIK3TH.mjs} +3 -3
  414. package/dist/{chunk-WPLDZLAL.mjs → chunk-L7PMYQN5.mjs} +3 -3
  415. package/dist/{chunk-H2UCPL5O.mjs → chunk-LY7M7Z7M.mjs} +3 -3
  416. package/dist/{chunk-UNZ3D3B3.mjs → chunk-MK32KUVI.mjs} +6 -6
  417. package/dist/{chunk-5LUTMHVL.mjs → chunk-NXKHSX4M.mjs} +3 -3
  418. package/dist/{chunk-QVEQRCOD.mjs → chunk-PIDPHIN6.mjs} +4 -4
  419. package/dist/{chunk-UR6LPERL.mjs → chunk-Q7NYATKS.mjs} +3 -3
  420. package/dist/{chunk-TQOUQIVS.mjs → chunk-V3XUPTZQ.mjs} +3 -3
  421. package/dist/{chunk-HWGRW6YP.mjs → chunk-VS2URZFN.mjs} +3 -3
  422. package/dist/{chunk-CVXJ45WI.mjs → chunk-WTOP2LEF.mjs} +5 -5
  423. package/dist/{chunk-FY2QAWA6.mjs → chunk-YI7E3RUY.mjs} +5 -5
@@ -1546,7 +1546,7 @@ function formatRuntimeContextStateBlock(input) {
1546
1546
  lines.push("fileScopes: project | agent | memory");
1547
1547
  lines.push("defaultFileScope: agent (pipeline group chat or user project/repo intent \u2192 project at runtime)");
1548
1548
  lines.push(
1549
- "workspaceDiscipline: IDENTITY/SOUL/USER/MEMORY/AGENTS.md live ONLY under agentWorkspace \u2014 use scope=agent or scope=memory; never treat projectRoot as your identity directory."
1549
+ "workspaceDiscipline: IDENTITY/SOUL/USER/MEMORY/AGENTS.md live ONLY under agentWorkspace \u2014 use scope=agent (scope=memory only reads MEMORY.md/USER.md/memory/**); never treat projectRoot as your identity directory."
1550
1550
  );
1551
1551
  lines.push(
1552
1552
  "projectRoot is the active task codebase (scope=project only); agentWorkspace is your persona, memory, and user inbound attachments (media/inbound and file/inbound)."
@@ -1660,6 +1660,23 @@ var init_tool_result_compact = __esm({
1660
1660
  }
1661
1661
  });
1662
1662
 
1663
+ // src/owned-tools/internal-tool-names.ts
1664
+ function isOwnedInternalToolName(name) {
1665
+ return OWNED_INTERNAL_TOOL_NAMES.has(name);
1666
+ }
1667
+ var OWNED_INTERNAL_TOOL_NAMES;
1668
+ var init_internal_tool_names = __esm({
1669
+ "src/owned-tools/internal-tool-names.ts"() {
1670
+ "use strict";
1671
+ OWNED_INTERNAL_TOOL_NAMES = /* @__PURE__ */ new Set([
1672
+ "diary_search",
1673
+ "notes_search",
1674
+ "notes_get",
1675
+ "summarize"
1676
+ ]);
1677
+ }
1678
+ });
1679
+
1663
1680
  // src/mobile/native-reply-transcript.ts
1664
1681
  function visibleUserText2(msg) {
1665
1682
  return stripInlineBase64FromLiveText(visibleUserText(msg));
@@ -1742,6 +1759,9 @@ function userContentBlocksFromMessage(msg) {
1742
1759
  function completedToolCalls(msg) {
1743
1760
  const list = msg.toolCalls ?? [];
1744
1761
  return list.filter((tc) => {
1762
+ if (typeof tc.name === "string" && isOwnedInternalToolName(tc.name)) {
1763
+ return false;
1764
+ }
1745
1765
  const hasResult = typeof tc.result === "string" && tc.result.length > 0 || typeof tc.partialResult === "string" && tc.partialResult.length > 0;
1746
1766
  return hasResult && (tc.status === "success" || tc.status === "error");
1747
1767
  });
@@ -1834,6 +1854,78 @@ function clipTranscriptChunks(chunks, maxTurns) {
1834
1854
  function transcriptEntriesByteLength(entries) {
1835
1855
  return Buffer.byteLength(JSON.stringify(entries), "utf8");
1836
1856
  }
1857
+ function transcriptForByteMeasure(transcript) {
1858
+ let imageBlocks = 0;
1859
+ const stripped = transcript.map((msg) => ({
1860
+ role: msg.role,
1861
+ content: msg.content.map((block) => {
1862
+ if (block.type === "image") {
1863
+ imageBlocks += 1;
1864
+ return { type: "image" };
1865
+ }
1866
+ return block;
1867
+ })
1868
+ }));
1869
+ return { stripped, imageBlocks };
1870
+ }
1871
+ function textFromToolResultContent(content) {
1872
+ if (typeof content === "string") {
1873
+ return content;
1874
+ }
1875
+ if (!Array.isArray(content)) {
1876
+ return "";
1877
+ }
1878
+ const parts = [];
1879
+ for (const item of content) {
1880
+ if (item && typeof item === "object" && item.type === "text") {
1881
+ const text = item.text;
1882
+ if (typeof text === "string" && text.trim()) {
1883
+ parts.push(text);
1884
+ }
1885
+ }
1886
+ }
1887
+ return parts.join("\n");
1888
+ }
1889
+ function summarizableTextFromTranscriptMessage(msg) {
1890
+ const parts = [];
1891
+ for (const block of msg.content) {
1892
+ if (block.type === "text") {
1893
+ parts.push(block.text);
1894
+ continue;
1895
+ }
1896
+ if (block.type === "thinking") {
1897
+ parts.push(block.thinking);
1898
+ continue;
1899
+ }
1900
+ if (block.type === "tool_use") {
1901
+ parts.push(JSON.stringify(block.input ?? {}));
1902
+ continue;
1903
+ }
1904
+ if (block.type === "tool_result") {
1905
+ parts.push(textFromToolResultContent(block.content));
1906
+ }
1907
+ }
1908
+ return sanitizeTranscriptTextForArchive(parts.join("\n"));
1909
+ }
1910
+ function measureTranscriptMessageSummarizableBytes(msg) {
1911
+ return measureSanitizedArchiveTextBytes(summarizableTextFromTranscriptMessage(msg));
1912
+ }
1913
+ function measureNativeReplyTranscriptMessages(transcript) {
1914
+ if (transcript.length === 0) {
1915
+ return { rawBytes: 0, summarizableBytes: 0, transcriptTurns: 0 };
1916
+ }
1917
+ const { stripped, imageBlocks } = transcriptForByteMeasure(transcript);
1918
+ const rawBytes = Buffer.byteLength(JSON.stringify(stripped), "utf8") + imageBlocks * IMAGE_BLOCK_BUDGET_BYTES;
1919
+ let summarizableBytes = 0;
1920
+ for (const msg of transcript) {
1921
+ summarizableBytes += measureTranscriptMessageSummarizableBytes(msg);
1922
+ }
1923
+ return {
1924
+ rawBytes,
1925
+ summarizableBytes,
1926
+ transcriptTurns: transcript.length
1927
+ };
1928
+ }
1837
1929
  function clipTranscriptChunksByBudget(chunks, maxBytes) {
1838
1930
  if (!Number.isFinite(maxBytes) || maxBytes <= 0) {
1839
1931
  return [];
@@ -1930,10 +2022,17 @@ function buildNativeReplyTranscriptMessages(sessionMessages, options) {
1930
2022
  }
1931
2023
  return clipTranscriptChunks(chunks, maxTurns);
1932
2024
  }
2025
+ function projectMessagesForAPI(sessionMessages, options) {
2026
+ const messages = buildNativeReplyTranscriptMessages([...sessionMessages], options);
2027
+ return {
2028
+ messages,
2029
+ budget: measureNativeReplyTranscriptMessages(messages)
2030
+ };
2031
+ }
1933
2032
  function toolResultsTranscriptMessage(results) {
1934
2033
  return { role: "user", content: results };
1935
2034
  }
1936
- var import_node_fs6, import_node_path8, DEFAULT_MAX_TURNS;
2035
+ var import_node_fs6, import_node_path8, DEFAULT_MAX_TURNS, IMAGE_BLOCK_BUDGET_BYTES;
1937
2036
  var init_native_reply_transcript = __esm({
1938
2037
  "src/mobile/native-reply-transcript.ts"() {
1939
2038
  "use strict";
@@ -1943,7 +2042,9 @@ var init_native_reply_transcript = __esm({
1943
2042
  init_chat_visible_text();
1944
2043
  init_transcript_media_sanitize();
1945
2044
  init_tool_result_compact();
2045
+ init_internal_tool_names();
1946
2046
  DEFAULT_MAX_TURNS = 24;
2047
+ IMAGE_BLOCK_BUDGET_BYTES = 8 * 1024;
1947
2048
  }
1948
2049
  });
1949
2050
 
@@ -8669,215 +8770,21 @@ var init_memory_consolidate = __esm({
8669
8770
  }
8670
8771
  });
8671
8772
 
8672
- // src/mobile/group/team-memory-runtime.ts
8673
- function normalizeTeamId(teamId) {
8674
- return teamId?.trim() || "";
8675
- }
8676
- function evidenceRef(input) {
8677
- return input.minutesPath?.trim() || `team_minutes:${input.minutes.team_id}:${input.minutes.session_id}:${input.minutes.created_at}`;
8678
- }
8679
- function compactLine(value, max = 360) {
8680
- const normalized = value?.replace(/\s+/gu, " ").trim();
8681
- if (!normalized) return void 0;
8682
- return normalized.length <= max ? normalized : `${normalized.slice(0, max - 3)}...`;
8683
- }
8684
- function buildContent(minutes) {
8685
- const viewpointLines = minutes.viewpoints.map((view) => {
8686
- const summary = compactLine(view.summary, 240);
8687
- return summary ? `- ${view.agent_id}: ${summary}` : void 0;
8688
- }).filter((line) => Boolean(line));
8689
- return [
8690
- `Group convergence memory for team ${minutes.team_id}.`,
8691
- minutes.topic ? `Topic: ${compactLine(minutes.topic, 240)}` : void 0,
8692
- minutes.conclusion ? `Conclusion: ${compactLine(minutes.conclusion, 360)}` : void 0,
8693
- minutes.participants.length ? `Participants: ${minutes.participants.join(", ")}` : void 0,
8694
- viewpointLines.length ? ["Viewpoints:", ...viewpointLines].join("\n") : void 0,
8695
- minutes.disagreements?.length ? ["Disagreements:", ...minutes.disagreements.map((item) => `- ${compactLine(item, 220)}`)].join("\n") : void 0,
8696
- minutes.todos?.length ? ["Todos:", ...minutes.todos.map((todo) => `- ${todo.owner_agent_id}: ${compactLine(todo.item, 180)}`)].join("\n") : void 0,
8697
- minutes.budget_usage ? `Budget: rounds=${minutes.budget_usage.rounds ?? 0}; messages=${minutes.budget_usage.messages ?? 0}` : void 0
8698
- ].filter(Boolean).join("\n");
8699
- }
8700
- async function recordGroupConvergenceTeamMemory(input) {
8701
- const teamId = normalizeTeamId(input.teamId ?? input.minutes.team_id);
8702
- if (!teamId || teamId === "unknown") {
8703
- return { ok: false, imported: false, skippedReason: "missing_team_id" };
8704
- }
8705
- const ref = evidenceRef(input);
8706
- const scope = { type: "team", id: teamId };
8707
- const existing = await readMemoryRecords(scope, 5e3);
8708
- const duplicate = existing.find((record2) => record2.evidenceRefs.includes(ref));
8709
- if (duplicate) {
8710
- return { ok: true, imported: false, skippedReason: "duplicate", record: duplicate, consolidated: false };
8711
- }
8712
- const record = await ingestMemoryEvent({
8713
- scope,
8714
- kind: "episode",
8715
- content: buildContent({ ...input.minutes, team_id: teamId }),
8716
- evidenceRefs: [ref, `session:${input.sessionId}`],
8717
- confidence: 0.82,
8718
- visibility: "team",
8719
- tags: [
8720
- "group-convergence",
8721
- `team:${teamId}`,
8722
- `session:${input.sessionId}`,
8723
- ...input.minutes.topic ? [`topic:${input.minutes.topic}`] : []
8724
- ]
8725
- });
8726
- try {
8727
- await runMemoryConsolidation({
8728
- scope,
8729
- reason: "group-convergence-team-memory",
8730
- budgetClass: "background"
8731
- });
8732
- return { ok: true, imported: true, record, consolidated: true };
8733
- } catch (error) {
8734
- return {
8735
- ok: true,
8736
- imported: true,
8737
- record,
8738
- consolidated: false,
8739
- consolidationError: error instanceof Error ? error.message : String(error)
8740
- };
8741
- }
8742
- }
8743
- var init_team_memory_runtime = __esm({
8744
- "src/mobile/group/team-memory-runtime.ts"() {
8745
- "use strict";
8746
- init_memory_consolidate();
8747
- init_memory_event();
8748
- }
8749
- });
8750
-
8751
- // src/mobile/group/agent-personalization-key.ts
8752
- function catalogIdFromMbti(mbti) {
8753
- return `z-${mbti.trim().toLowerCase()}`;
8754
- }
8755
- function catalogStableKey(catalogId) {
8756
- return `${CATALOG_PERSONALIZATION_PREFIX}${catalogId.trim()}`;
8757
- }
8758
- function mbtiStableKey(mbti) {
8759
- return `${MBTI_PERSONALIZATION_PREFIX}${mbti.trim().toUpperCase()}`;
8760
- }
8761
- function resolveCatalogIdForAgent(agent) {
8762
- const mbti = agent.enrichment?.mbti?.trim().toUpperCase();
8763
- if (!mbti) {
8764
- return null;
8765
- }
8766
- return catalogIdFromMbti(mbti);
8767
- }
8768
- function lookupKeysForAgent(agent) {
8769
- const keys = [];
8770
- const catalogId = resolveCatalogIdForAgent(agent);
8771
- if (catalogId) {
8772
- keys.push(catalogStableKey(catalogId));
8773
- }
8774
- const mbti = agent.enrichment?.mbti?.trim().toUpperCase();
8775
- if (mbti) {
8776
- keys.push(mbtiStableKey(mbti));
8777
- }
8778
- const id = agent.id.trim();
8779
- if (id) {
8780
- keys.push(id);
8781
- }
8782
- return [...new Set(keys)];
8783
- }
8784
- function lookupPersonalizationValue(map, agent) {
8785
- if (!map) {
8786
- return "";
8787
- }
8788
- for (const key of lookupKeysForAgent(agent)) {
8789
- const v = map[key]?.trim();
8790
- if (v) {
8791
- return v;
8792
- }
8793
- }
8794
- return "";
8795
- }
8796
- var CATALOG_PERSONALIZATION_PREFIX, MBTI_PERSONALIZATION_PREFIX;
8797
- var init_agent_personalization_key = __esm({
8798
- "src/mobile/group/agent-personalization-key.ts"() {
8799
- "use strict";
8800
- CATALOG_PERSONALIZATION_PREFIX = "catalog:";
8801
- MBTI_PERSONALIZATION_PREFIX = "mbti:";
8802
- }
8803
- });
8804
-
8805
- // src/mobile/group/remarks.ts
8806
- function agentRefFromId(agentId) {
8807
- const agent = getMobileChatStore().getAgentById(agentId);
8808
- if (!agent) {
8809
- return { id: agentId };
8810
- }
8811
- return {
8812
- id: agent.id,
8813
- enrichment: agent.enrichment?.mbti ? { mbti: agent.enrichment.mbti } : null
8814
- };
8815
- }
8816
- function snapshotRemarkMap() {
8817
- return Object.fromEntries(remarkByAgentId.entries());
8818
- }
8819
- function getAgentRemark(agentId) {
8820
- const id = agentId.trim();
8821
- if (!id) {
8822
- return void 0;
8823
- }
8824
- const direct = remarkByAgentId.get(id);
8825
- if (direct) {
8826
- return direct;
8827
- }
8828
- const viaAlias = lookupPersonalizationValue(snapshotRemarkMap(), agentRefFromId(id));
8829
- return viaAlias || void 0;
8830
- }
8831
- function buildAgentUserRemarkAwarenessBlock(agentId, mode = "direct") {
8832
- const remark = getAgentRemark(agentId);
8833
- if (!remark) {
8834
- return void 0;
8835
- }
8836
- if (mode === "group") {
8837
- return [
8838
- `\u8001\u677F\u7ED9\u4F60\u8D77\u7684\u5907\u6CE8\u662F\u300C${remark}\u300D\u2014\u2014\u8FD9\u662F\u7528\u6237\u79F0\u547C\u4F60\u7684\u540D\u5B57\uFF0C\u4E0D\u662F\u7528\u6237\u7684\u540D\u5B57\u3002`,
8839
- `\u7FA4\u91CC\u6709\u4EBA\u8FD9\u6837\u558A\u5C31\u662F\u5728\u53EB\u4F60\uFF1B\u4E0D\u8981\u7528\u300C\u4F60\u597D ${remark}\u300D\u5411\u7528\u6237\u6253\u62DB\u547C\u3002`,
8840
- `\u88AB\u95EE\u53CA\u300C\u4F60\u7684\u5907\u6CE8/\u804C\u4F4D\u300D\u65F6\uFF0C\u76F4\u63A5\u56DE\u7B54\u300C${remark}\u300D\uFF0C\u4E0D\u8981\u6539\u7B54 MBTI \u7C7B\u578B\u540D\u6216\u5546\u5E97\u5C55\u793A\u540D\u3002`
8841
- ].join(" ");
8842
- }
8843
- return [
8844
- `\u7528\u6237\uFF08\u8001\u677F\uFF09\u7ED9\u4F60\u8D77\u7684\u5907\u6CE8\u662F\u300C${remark}\u300D\u3002`,
8845
- "\u8FD9\u662F\u7528\u6237\u79F0\u547C\u4F60\u7684\u540D\u5B57\uFF08\u4F60\u7684\u4E13\u5C5E\u53EB\u6CD5\uFF09\uFF0C\u4E0D\u662F\u7528\u6237\u7684\u540D\u5B57\u3002",
8846
- `\u81EA\u6211\u4ECB\u7ECD\u6216\u88AB\u95EE\u53CA\u79F0\u547C\u65F6\uFF0C\u53EF\u8BF4\u300C\u6211\u662F ${remark}\u300D\u6216\u300C\u4F60\u53EF\u4EE5\u53EB\u6211 ${remark}\u300D\uFF1B\u4E0D\u8981\u7528\u300C\u4F60\u597D ${remark}\u300D\u5411\u7528\u6237\u6253\u62DB\u547C\u3002`,
8847
- "\u5982\u4F55\u79F0\u547C\u7528\u6237\u89C1 USER.md\uFF08file scope=memory\uFF09\u3002"
8848
- ].join(" ");
8849
- }
8850
- function createRemarkResolver() {
8851
- return (agentId) => getAgentRemark(agentId);
8852
- }
8853
- var remarkByAgentId;
8854
- var init_remarks = __esm({
8855
- "src/mobile/group/remarks.ts"() {
8856
- "use strict";
8857
- init_store();
8858
- init_agent_personalization_key();
8859
- remarkByAgentId = /* @__PURE__ */ new Map();
8860
- }
8861
- });
8862
-
8863
8773
  // src/owned-tools/owned-tool-payload-failure.ts
8864
8774
  function ownedToolPayloadIndicatesFailure(payload) {
8865
8775
  if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
8866
8776
  return false;
8867
8777
  }
8868
8778
  const record = payload;
8779
+ if (record.is_error === true) {
8780
+ return true;
8781
+ }
8869
8782
  if (record.ok === false) {
8870
8783
  return true;
8871
8784
  }
8872
8785
  if (record.ok === true) {
8873
8786
  return false;
8874
8787
  }
8875
- if (typeof record.exitCode === "number" && record.exitCode !== 0) {
8876
- return true;
8877
- }
8878
- if (typeof record.error === "string" && record.error.trim()) {
8879
- return true;
8880
- }
8881
8788
  return false;
8882
8789
  }
8883
8790
  var init_owned_tool_payload_failure = __esm({
@@ -8904,15 +8811,12 @@ function assessSingleHandoffToolCall(tc) {
8904
8811
  }
8905
8812
  const envelope = parseHandoffPayload(tc.result ?? tc.partialResult);
8906
8813
  if (!envelope) {
8907
- return tc.status === "success" ? { kind: "succeeded" } : { kind: "none" };
8814
+ return { kind: "none" };
8908
8815
  }
8909
8816
  if (ownedToolPayloadIndicatesFailure(envelope)) {
8910
8817
  return { kind: "failed" };
8911
8818
  }
8912
8819
  const data = envelope.data && typeof envelope.data === "object" && !Array.isArray(envelope.data) ? envelope.data : envelope;
8913
- if (data.ok === false) {
8914
- return { kind: "failed" };
8915
- }
8916
8820
  const phase = typeof data.phase === "string" ? data.phase : void 0;
8917
8821
  return { kind: "succeeded", phase };
8918
8822
  }
@@ -8939,15 +8843,12 @@ function assessSingleCeoDecisionToolCall(tc) {
8939
8843
  }
8940
8844
  const envelope = parseHandoffPayload(tc.result ?? tc.partialResult);
8941
8845
  if (!envelope) {
8942
- return tc.status === "success" ? { kind: "succeeded" } : { kind: "none" };
8846
+ return { kind: "none" };
8943
8847
  }
8944
8848
  if (ownedToolPayloadIndicatesFailure(envelope)) {
8945
8849
  return { kind: "failed" };
8946
8850
  }
8947
8851
  const data = envelope.data && typeof envelope.data === "object" && !Array.isArray(envelope.data) ? envelope.data : envelope;
8948
- if (data.ok === false) {
8949
- return { kind: "failed" };
8950
- }
8951
8852
  const phase = typeof data.phase === "string" ? data.phase : void 0;
8952
8853
  return { kind: "succeeded", phase };
8953
8854
  }
@@ -9049,13 +8950,67 @@ var init_pipeline_handoff_verification = __esm({
9049
8950
  });
9050
8951
 
9051
8952
  // src/mobile/group/delivery-verification.ts
8953
+ function parseToolResult(raw) {
8954
+ const trimmed = raw?.trim();
8955
+ if (!trimmed) {
8956
+ return void 0;
8957
+ }
8958
+ try {
8959
+ return JSON.parse(trimmed);
8960
+ } catch {
8961
+ return trimmed;
8962
+ }
8963
+ }
8964
+ function hasNonEmptyString(value) {
8965
+ return typeof value === "string" && value.trim().length > 0;
8966
+ }
8967
+ function recordHasEvidenceField(value, depth = 0) {
8968
+ if (!value || typeof value !== "object" || depth > 4) {
8969
+ return false;
8970
+ }
8971
+ if (Array.isArray(value)) {
8972
+ return value.some((entry) => recordHasEvidenceField(entry, depth + 1));
8973
+ }
8974
+ const record = value;
8975
+ for (const [key, fieldValue] of Object.entries(record)) {
8976
+ const normalizedKey = key.toLowerCase();
8977
+ const keyLooksLikeEvidence = normalizedKey === "path" || normalizedKey === "abspath" || normalizedKey === "filepath" || normalizedKey === "targetpath" || normalizedKey === "resolvedpath" || normalizedKey === "hash" || normalizedKey === "sha256" || normalizedKey === "digest" || normalizedKey === "checksum" || normalizedKey === "exitcode" || normalizedKey === "stdout" || normalizedKey === "stderr" || normalizedKey === "byteswritten" || normalizedKey === "sizebytes" || normalizedKey === "url" || normalizedKey === "mediaurl";
8978
+ if (keyLooksLikeEvidence && (hasNonEmptyString(fieldValue) || typeof fieldValue === "number" && Number.isFinite(fieldValue))) {
8979
+ return true;
8980
+ }
8981
+ if (recordHasEvidenceField(fieldValue, depth + 1)) {
8982
+ return true;
8983
+ }
8984
+ }
8985
+ return false;
8986
+ }
8987
+ function toolCallHasCompletionEvidence(tc) {
8988
+ if (tc.status !== "success" || tc.isError) {
8989
+ return false;
8990
+ }
8991
+ const result = parseToolResult(tc.result ?? tc.partialResult);
8992
+ const args = tc.args ?? {};
8993
+ const resultHasEvidence = recordHasEvidenceField(result);
8994
+ const argsHaveEvidence = recordHasEvidenceField(args);
8995
+ const tool = tc.name.trim().toLowerCase();
8996
+ if (tool === "exec") {
8997
+ return argsHaveEvidence || resultHasEvidence || hasNonEmptyString(args.command);
8998
+ }
8999
+ if (tool === "write" || tool === "edit" || tool === "read" || tool === "pdf") {
9000
+ return argsHaveEvidence || resultHasEvidence;
9001
+ }
9002
+ if (tool === "image_generate" || tool === "video_generate" || tool === "music_generate") {
9003
+ return argsHaveEvidence || resultHasEvidence;
9004
+ }
9005
+ return resultHasEvidence;
9006
+ }
9052
9007
  function assessGenericCompletionVerification(text, toolCalls) {
9053
9008
  const trimmed = text.trim();
9054
9009
  if (!trimmed || !COMPLETION_CLAIM_PATTERN.test(trimmed)) {
9055
9010
  return void 0;
9056
9011
  }
9057
- const hasSuccessTool = (toolCalls ?? []).some((tc) => tc.status === "success");
9058
- return hasSuccessTool ? "verified" : "unverified";
9012
+ const hasEvidenceBackedTool = (toolCalls ?? []).some((tc) => toolCallHasCompletionEvidence(tc));
9013
+ return hasEvidenceBackedTool ? "verified" : "unverified";
9059
9014
  }
9060
9015
  function assessDeliveryVerification(text, toolCalls) {
9061
9016
  const handoffClaim = assessPipelineHandoffClaimVerification(text, toolCalls);
@@ -9069,7 +9024,198 @@ var init_delivery_verification = __esm({
9069
9024
  "src/mobile/group/delivery-verification.ts"() {
9070
9025
  "use strict";
9071
9026
  init_pipeline_handoff_verification();
9072
- COMPLETION_CLAIM_PATTERN = /(?:已完成|已经完成|做完了|搞定了|修改成功|写入成功|创建成功|删除成功|已改成|已更新|已保存)/i;
9027
+ COMPLETION_CLAIM_PATTERN = /(?:已完成|已经完成|做完了|搞定了|修改成功|写入成功|创建成功|删除成功|已改成|已更新|已保存|已修改|已写入|已创建|已删除|已检查|已验证|跑完了|\d+\s*(?:个|件)?\s*(?:文件|目录|路径))/i;
9028
+ }
9029
+ });
9030
+
9031
+ // src/mobile/group/team-memory-runtime.ts
9032
+ function normalizeTeamId(teamId) {
9033
+ return teamId?.trim() || "";
9034
+ }
9035
+ function evidenceRef(input) {
9036
+ return input.minutesPath?.trim() || `team_minutes:${input.minutes.team_id}:${input.minutes.session_id}:${input.minutes.created_at}`;
9037
+ }
9038
+ function compactLine(value, max = 360) {
9039
+ const normalized = value?.replace(/\s+/gu, " ").trim();
9040
+ if (!normalized) return void 0;
9041
+ return normalized.length <= max ? normalized : `${normalized.slice(0, max - 3)}...`;
9042
+ }
9043
+ function buildContent(minutes) {
9044
+ const viewpointLines = minutes.viewpoints.map((view) => {
9045
+ const summary = compactLine(view.summary, 240);
9046
+ return summary ? `- ${view.agent_id}: ${summary}` : void 0;
9047
+ }).filter((line) => Boolean(line));
9048
+ return [
9049
+ `Group convergence memory for team ${minutes.team_id}.`,
9050
+ minutes.topic ? `Topic: ${compactLine(minutes.topic, 240)}` : void 0,
9051
+ minutes.conclusion ? `Conclusion: ${compactLine(minutes.conclusion, 360)}` : void 0,
9052
+ minutes.participants.length ? `Participants: ${minutes.participants.join(", ")}` : void 0,
9053
+ viewpointLines.length ? ["Viewpoints:", ...viewpointLines].join("\n") : void 0,
9054
+ minutes.disagreements?.length ? ["Disagreements:", ...minutes.disagreements.map((item) => `- ${compactLine(item, 220)}`)].join("\n") : void 0,
9055
+ minutes.todos?.length ? ["Todos:", ...minutes.todos.map((todo) => `- ${todo.owner_agent_id}: ${compactLine(todo.item, 180)}`)].join("\n") : void 0,
9056
+ minutes.budget_usage ? `Budget: rounds=${minutes.budget_usage.rounds ?? 0}; messages=${minutes.budget_usage.messages ?? 0}` : void 0
9057
+ ].filter(Boolean).join("\n");
9058
+ }
9059
+ async function recordGroupConvergenceTeamMemory(input) {
9060
+ const teamId = normalizeTeamId(input.teamId ?? input.minutes.team_id);
9061
+ if (!teamId || teamId === "unknown") {
9062
+ return { ok: false, imported: false, skippedReason: "missing_team_id" };
9063
+ }
9064
+ const ref = evidenceRef(input);
9065
+ const scope = { type: "team", id: teamId };
9066
+ const existing = await readMemoryRecords(scope, 5e3);
9067
+ const duplicate = existing.find((record2) => record2.evidenceRefs.includes(ref));
9068
+ if (duplicate) {
9069
+ return { ok: true, imported: false, skippedReason: "duplicate", record: duplicate, consolidated: false };
9070
+ }
9071
+ const record = await ingestMemoryEvent({
9072
+ scope,
9073
+ kind: "episode",
9074
+ content: buildContent({ ...input.minutes, team_id: teamId }),
9075
+ evidenceRefs: [ref, `session:${input.sessionId}`],
9076
+ confidence: 0.82,
9077
+ visibility: "team",
9078
+ tags: [
9079
+ "group-convergence",
9080
+ `team:${teamId}`,
9081
+ `session:${input.sessionId}`,
9082
+ ...input.minutes.topic ? [`topic:${input.minutes.topic}`] : []
9083
+ ]
9084
+ });
9085
+ try {
9086
+ await runMemoryConsolidation({
9087
+ scope,
9088
+ reason: "group-convergence-team-memory",
9089
+ budgetClass: "background"
9090
+ });
9091
+ return { ok: true, imported: true, record, consolidated: true };
9092
+ } catch (error) {
9093
+ return {
9094
+ ok: true,
9095
+ imported: true,
9096
+ record,
9097
+ consolidated: false,
9098
+ consolidationError: error instanceof Error ? error.message : String(error)
9099
+ };
9100
+ }
9101
+ }
9102
+ var init_team_memory_runtime = __esm({
9103
+ "src/mobile/group/team-memory-runtime.ts"() {
9104
+ "use strict";
9105
+ init_memory_consolidate();
9106
+ init_memory_event();
9107
+ }
9108
+ });
9109
+
9110
+ // src/mobile/group/agent-personalization-key.ts
9111
+ function catalogIdFromMbti(mbti) {
9112
+ return `z-${mbti.trim().toLowerCase()}`;
9113
+ }
9114
+ function catalogStableKey(catalogId) {
9115
+ return `${CATALOG_PERSONALIZATION_PREFIX}${catalogId.trim()}`;
9116
+ }
9117
+ function mbtiStableKey(mbti) {
9118
+ return `${MBTI_PERSONALIZATION_PREFIX}${mbti.trim().toUpperCase()}`;
9119
+ }
9120
+ function resolveCatalogIdForAgent(agent) {
9121
+ const mbti = agent.enrichment?.mbti?.trim().toUpperCase();
9122
+ if (!mbti) {
9123
+ return null;
9124
+ }
9125
+ return catalogIdFromMbti(mbti);
9126
+ }
9127
+ function lookupKeysForAgent(agent) {
9128
+ const keys = [];
9129
+ const catalogId = resolveCatalogIdForAgent(agent);
9130
+ if (catalogId) {
9131
+ keys.push(catalogStableKey(catalogId));
9132
+ }
9133
+ const mbti = agent.enrichment?.mbti?.trim().toUpperCase();
9134
+ if (mbti) {
9135
+ keys.push(mbtiStableKey(mbti));
9136
+ }
9137
+ const id = agent.id.trim();
9138
+ if (id) {
9139
+ keys.push(id);
9140
+ }
9141
+ return [...new Set(keys)];
9142
+ }
9143
+ function lookupPersonalizationValue(map, agent) {
9144
+ if (!map) {
9145
+ return "";
9146
+ }
9147
+ for (const key of lookupKeysForAgent(agent)) {
9148
+ const v = map[key]?.trim();
9149
+ if (v) {
9150
+ return v;
9151
+ }
9152
+ }
9153
+ return "";
9154
+ }
9155
+ var CATALOG_PERSONALIZATION_PREFIX, MBTI_PERSONALIZATION_PREFIX;
9156
+ var init_agent_personalization_key = __esm({
9157
+ "src/mobile/group/agent-personalization-key.ts"() {
9158
+ "use strict";
9159
+ CATALOG_PERSONALIZATION_PREFIX = "catalog:";
9160
+ MBTI_PERSONALIZATION_PREFIX = "mbti:";
9161
+ }
9162
+ });
9163
+
9164
+ // src/mobile/group/remarks.ts
9165
+ function agentRefFromId(agentId) {
9166
+ const agent = getMobileChatStore().getAgentById(agentId);
9167
+ if (!agent) {
9168
+ return { id: agentId };
9169
+ }
9170
+ return {
9171
+ id: agent.id,
9172
+ enrichment: agent.enrichment?.mbti ? { mbti: agent.enrichment.mbti } : null
9173
+ };
9174
+ }
9175
+ function snapshotRemarkMap() {
9176
+ return Object.fromEntries(remarkByAgentId.entries());
9177
+ }
9178
+ function getAgentRemark(agentId) {
9179
+ const id = agentId.trim();
9180
+ if (!id) {
9181
+ return void 0;
9182
+ }
9183
+ const direct = remarkByAgentId.get(id);
9184
+ if (direct) {
9185
+ return direct;
9186
+ }
9187
+ const viaAlias = lookupPersonalizationValue(snapshotRemarkMap(), agentRefFromId(id));
9188
+ return viaAlias || void 0;
9189
+ }
9190
+ function buildAgentUserRemarkAwarenessBlock(agentId, mode = "direct") {
9191
+ const remark = getAgentRemark(agentId);
9192
+ if (!remark) {
9193
+ return void 0;
9194
+ }
9195
+ if (mode === "group") {
9196
+ return [
9197
+ `\u8001\u677F\u7ED9\u4F60\u8D77\u7684\u5907\u6CE8\u662F\u300C${remark}\u300D\u2014\u2014\u8FD9\u662F\u7528\u6237\u79F0\u547C\u4F60\u7684\u540D\u5B57\uFF0C\u4E0D\u662F\u7528\u6237\u7684\u540D\u5B57\u3002`,
9198
+ `\u7FA4\u91CC\u6709\u4EBA\u8FD9\u6837\u558A\u5C31\u662F\u5728\u53EB\u4F60\uFF1B\u4E0D\u8981\u7528\u300C\u4F60\u597D ${remark}\u300D\u5411\u7528\u6237\u6253\u62DB\u547C\u3002`,
9199
+ `\u88AB\u95EE\u53CA\u300C\u4F60\u7684\u5907\u6CE8/\u804C\u4F4D\u300D\u65F6\uFF0C\u76F4\u63A5\u56DE\u7B54\u300C${remark}\u300D\uFF0C\u4E0D\u8981\u6539\u7B54 MBTI \u7C7B\u578B\u540D\u6216\u5546\u5E97\u5C55\u793A\u540D\u3002`
9200
+ ].join(" ");
9201
+ }
9202
+ return [
9203
+ `\u7528\u6237\uFF08\u8001\u677F\uFF09\u7ED9\u4F60\u8D77\u7684\u5907\u6CE8\u662F\u300C${remark}\u300D\u3002`,
9204
+ "\u8FD9\u662F\u7528\u6237\u79F0\u547C\u4F60\u7684\u540D\u5B57\uFF08\u4F60\u7684\u4E13\u5C5E\u53EB\u6CD5\uFF09\uFF0C\u4E0D\u662F\u7528\u6237\u7684\u540D\u5B57\u3002",
9205
+ `\u81EA\u6211\u4ECB\u7ECD\u6216\u88AB\u95EE\u53CA\u79F0\u547C\u65F6\uFF0C\u53EF\u8BF4\u300C\u6211\u662F ${remark}\u300D\u6216\u300C\u4F60\u53EF\u4EE5\u53EB\u6211 ${remark}\u300D\uFF1B\u4E0D\u8981\u7528\u300C\u4F60\u597D ${remark}\u300D\u5411\u7528\u6237\u6253\u62DB\u547C\u3002`,
9206
+ "\u5982\u4F55\u79F0\u547C\u7528\u6237\u89C1 USER.md\uFF08file scope=memory\uFF09\u3002"
9207
+ ].join(" ");
9208
+ }
9209
+ function createRemarkResolver() {
9210
+ return (agentId) => getAgentRemark(agentId);
9211
+ }
9212
+ var remarkByAgentId;
9213
+ var init_remarks = __esm({
9214
+ "src/mobile/group/remarks.ts"() {
9215
+ "use strict";
9216
+ init_store();
9217
+ init_agent_personalization_key();
9218
+ remarkByAgentId = /* @__PURE__ */ new Map();
9073
9219
  }
9074
9220
  });
9075
9221
 
@@ -16529,93 +16675,18 @@ async function executeSummarizeTranscript(opts) {
16529
16675
  }
16530
16676
  }
16531
16677
 
16532
- // src/mobile/context-compact/native-transcript-budget.ts
16678
+ // src/mobile/context-compact/context-budget-gate.ts
16533
16679
  init_native_reply_transcript();
16534
- init_transcript_media_sanitize();
16535
- var IMAGE_BLOCK_BUDGET_BYTES = 8 * 1024;
16536
- function transcriptForByteMeasure(transcript) {
16537
- let imageBlocks = 0;
16538
- const stripped = transcript.map((msg) => ({
16539
- role: msg.role,
16540
- content: msg.content.map((block) => {
16541
- if (block.type === "image") {
16542
- imageBlocks += 1;
16543
- return { type: "image" };
16544
- }
16545
- return block;
16546
- })
16547
- }));
16548
- return { stripped, imageBlocks };
16549
- }
16550
- function textFromToolResultContent(content) {
16551
- if (typeof content === "string") {
16552
- return content;
16553
- }
16554
- if (!Array.isArray(content)) {
16555
- return "";
16556
- }
16557
- const parts = [];
16558
- for (const item of content) {
16559
- if (item && typeof item === "object" && item.type === "text") {
16560
- const text = item.text;
16561
- if (typeof text === "string" && text.trim()) {
16562
- parts.push(text);
16563
- }
16564
- }
16565
- }
16566
- return parts.join("\n");
16567
- }
16568
- function summarizableTextFromTranscriptMessage(msg) {
16569
- const parts = [];
16570
- for (const block of msg.content) {
16571
- if (block.type === "text") {
16572
- parts.push(block.text);
16573
- continue;
16574
- }
16575
- if (block.type === "thinking") {
16576
- parts.push(block.thinking);
16577
- continue;
16578
- }
16579
- if (block.type === "tool_use") {
16580
- parts.push(JSON.stringify(block.input ?? {}));
16581
- continue;
16582
- }
16583
- if (block.type === "tool_result") {
16584
- parts.push(textFromToolResultContent(block.content));
16585
- }
16586
- }
16587
- return sanitizeTranscriptTextForArchive(parts.join("\n"));
16588
- }
16589
- function measureTranscriptMessageSummarizableBytes(msg) {
16590
- return measureSanitizedArchiveTextBytes(summarizableTextFromTranscriptMessage(msg));
16591
- }
16592
- function measureNativeTranscriptBudget(messages, options) {
16593
- const transcript = buildNativeReplyTranscriptMessages(
16594
- [...messages],
16595
- options?.maxTurns !== void 0 ? { maxTurns: options.maxTurns } : void 0
16596
- );
16597
- if (transcript.length === 0) {
16598
- return { rawBytes: 0, summarizableBytes: 0, transcriptTurns: 0 };
16599
- }
16600
- const { stripped, imageBlocks } = transcriptForByteMeasure(transcript);
16601
- const rawBytes = Buffer.byteLength(JSON.stringify(stripped), "utf8") + imageBlocks * IMAGE_BLOCK_BUDGET_BYTES;
16602
- let summarizableBytes = 0;
16603
- for (const msg of transcript) {
16604
- summarizableBytes += measureTranscriptMessageSummarizableBytes(msg);
16605
- }
16606
- return {
16607
- rawBytes,
16608
- summarizableBytes,
16609
- transcriptTurns: transcript.length
16610
- };
16611
- }
16612
16680
 
16613
16681
  // src/mobile/model-context-window-budget.ts
16614
16682
  var TRANSCRIPT_BUDGET_BYTES_PER_TOKEN = 4;
16615
16683
  var TRANSCRIPT_CONTEXT_WINDOW_RATIO = 0.35;
16616
16684
  var MIN_TRANSCRIPT_BUDGET_BYTES = 64 * 1024;
16617
- var DEFAULT_MAX_NATIVE_TRANSCRIPT_BUDGET_BYTES = 128 * 1024;
16685
+ var DEFAULT_TRANSCRIPT_BUDGET_BYTES = 512 * 1024;
16686
+ var DEFAULT_MAX_NATIVE_TRANSCRIPT_BUDGET_BYTES = DEFAULT_TRANSCRIPT_BUDGET_BYTES;
16618
16687
  var HARD_MAX_TRANSCRIPT_BUDGET_BYTES = 4 * 1024 * 1024;
16688
+ var CONTEXT_JSONL_COMPACT_BYTES_ENV = "XKZOOM_CONTEXT_JSONL_COMPACT_BYTES";
16689
+ var NATIVE_TRANSCRIPT_MAX_REQUEST_BYTES_ENV = "XKZOOM_NATIVE_TRANSCRIPT_MAX_REQUEST_BYTES";
16619
16690
  function positiveInteger(value) {
16620
16691
  if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
16621
16692
  return void 0;
@@ -16623,7 +16694,7 @@ function positiveInteger(value) {
16623
16694
  return Math.trunc(value);
16624
16695
  }
16625
16696
  function readMaxTranscriptBudgetBytes(env = process.env) {
16626
- const raw = env.XKZOOM_NATIVE_TRANSCRIPT_MAX_REQUEST_BYTES?.trim();
16697
+ const raw = env[NATIVE_TRANSCRIPT_MAX_REQUEST_BYTES_ENV]?.trim();
16627
16698
  if (!raw) {
16628
16699
  return DEFAULT_MAX_NATIVE_TRANSCRIPT_BUDGET_BYTES;
16629
16700
  }
@@ -16633,6 +16704,14 @@ function readMaxTranscriptBudgetBytes(env = process.env) {
16633
16704
  }
16634
16705
  return Math.min(HARD_MAX_TRANSCRIPT_BUDGET_BYTES, Math.max(MIN_TRANSCRIPT_BUDGET_BYTES, parsed));
16635
16706
  }
16707
+ function resolveTranscriptFallbackBudgetBytes(env = process.env) {
16708
+ const raw = env[CONTEXT_JSONL_COMPACT_BYTES_ENV]?.trim();
16709
+ if (!raw) {
16710
+ return DEFAULT_TRANSCRIPT_BUDGET_BYTES;
16711
+ }
16712
+ const parsed = Number.parseInt(raw, 10);
16713
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_TRANSCRIPT_BUDGET_BYTES;
16714
+ }
16636
16715
  function resolveTranscriptBudgetBytesForContextWindow(contextWindowTokens) {
16637
16716
  const tokens = positiveInteger(contextWindowTokens);
16638
16717
  if (tokens === void 0) {
@@ -16650,7 +16729,7 @@ function resolveTranscriptBudgetBytesForContextWindow(contextWindowTokens) {
16650
16729
  // src/mobile/context-compact/context-budget-gate.ts
16651
16730
  function resolveContextBudgetSignalSource() {
16652
16731
  const raw = (process.env.XKZOOM_CONTEXT_BUDGET_SOURCE ?? "native").trim().toLowerCase();
16653
- if (raw === "legacy" || raw === "legacy" || raw === "jsonl") {
16732
+ if (raw === "legacy" || raw === "jsonl") {
16654
16733
  return "gateway-jsonl";
16655
16734
  }
16656
16735
  return "native-transcript";
@@ -16668,7 +16747,7 @@ function readNonNegativeIntEnv(name, fallback) {
16668
16747
  return Number.isFinite(n) && n >= 0 ? n : fallback;
16669
16748
  }
16670
16749
  function resolveJsonlCompactThresholdBytes() {
16671
- return readPositiveIntEnv("XKZOOM_CONTEXT_JSONL_COMPACT_BYTES", 524288);
16750
+ return resolveTranscriptFallbackBudgetBytes();
16672
16751
  }
16673
16752
  function resolvePromptCharWarnThreshold() {
16674
16753
  return readPositiveIntEnv("XKZOOM_CONTEXT_PROMPT_CHAR_WARN", 32e3);
@@ -16727,10 +16806,11 @@ async function evaluateContextBudgetGate(input) {
16727
16806
  let source = "gateway-jsonl";
16728
16807
  let transcriptTurns;
16729
16808
  if (budgetSource === "native-transcript" && Array.isArray(nativeMessages)) {
16730
- const nativeBudget = measureNativeTranscriptBudget(
16809
+ const nativeProjection = projectMessagesForAPI(
16731
16810
  nativeMessages,
16732
16811
  modelContextBudgetBytes !== void 0 ? { maxTurns: Number.MAX_SAFE_INTEGER } : void 0
16733
16812
  );
16813
+ const nativeBudget = nativeProjection.budget;
16734
16814
  jsonlBytes = nativeBudget.rawBytes;
16735
16815
  summarizableBytes = nativeBudget.summarizableBytes;
16736
16816
  transcriptTurns = nativeBudget.transcriptTurns;
@@ -19491,6 +19571,7 @@ var minimaxOpenAiCompletionsAdapter = {
19491
19571
  };
19492
19572
 
19493
19573
  // src/mobile/native-request-diagnostics.ts
19574
+ var PROTOCOL_FALLBACK_MAX_TOKENS = 16384;
19494
19575
  var RETRYABLE_NATIVE_FETCH_RE = new RegExp(
19495
19576
  [
19496
19577
  "fetch failed",
@@ -19600,8 +19681,6 @@ function toolChoicePolicyToMinimaxAnthropicToolChoiceWire(policy) {
19600
19681
 
19601
19682
  // src/mobile/minimax-m3.ts
19602
19683
  var MINIMAX_M3_MODEL_ID = "MiniMax-M3";
19603
- var MINIMAX_M3_DEFAULT_MAX_TOKENS = 131072;
19604
- var MINIMAX_M3_MAX_TOKENS_ENV = "XKZOOM_MINIMAX_M3_MAX_TOKENS";
19605
19684
  function isMinimaxM3Model(modelId) {
19606
19685
  return (modelId ?? "").trim() === MINIMAX_M3_MODEL_ID;
19607
19686
  }
@@ -19613,16 +19692,6 @@ function resolveMinimaxM3AnthropicThinking(params) {
19613
19692
  if (params.reasoningMode === "off") return "disabled";
19614
19693
  return "adaptive";
19615
19694
  }
19616
- function resolveMinimaxM3DefaultMaxTokens(env = process.env) {
19617
- const raw = env[MINIMAX_M3_MAX_TOKENS_ENV];
19618
- if (typeof raw === "string" && raw.trim()) {
19619
- const n = Number.parseInt(raw.trim(), 10);
19620
- if (Number.isFinite(n) && n > 0) {
19621
- return n;
19622
- }
19623
- }
19624
- return MINIMAX_M3_DEFAULT_MAX_TOKENS;
19625
- }
19626
19695
  function normalizeMinimaxM3ThinkingType(value) {
19627
19696
  if (value && typeof value === "object" && !Array.isArray(value)) {
19628
19697
  const raw = typeof value.type === "string" ? value.type.trim().toLowerCase() : "";
@@ -19706,7 +19775,7 @@ var genericAnthropicAdapter = {
19706
19775
  return genericThinking(input);
19707
19776
  },
19708
19777
  defaultBodyExtras() {
19709
- return { max_tokens: 16384 };
19778
+ return { max_tokens: PROTOCOL_FALLBACK_MAX_TOKENS };
19710
19779
  },
19711
19780
  forcedToolChoiceSupported() {
19712
19781
  return true;
@@ -19774,11 +19843,8 @@ var minimaxAnthropicAdapter = {
19774
19843
  }
19775
19844
  return void 0;
19776
19845
  },
19777
- defaultBodyExtras(input) {
19778
- if (isMinimaxM3Model(input?.model)) {
19779
- return { max_tokens: resolveMinimaxM3DefaultMaxTokens(input?.env) };
19780
- }
19781
- return { max_tokens: 16384 };
19846
+ defaultBodyExtras() {
19847
+ return { max_tokens: PROTOCOL_FALLBACK_MAX_TOKENS };
19782
19848
  },
19783
19849
  forcedToolChoiceSupported() {
19784
19850
  return true;
@@ -19821,7 +19887,7 @@ function resolveAnthropicMessagesBodyExtras(provider) {
19821
19887
  }
19822
19888
  return isGatewayConfigRecord(raw) ? { ...raw } : {};
19823
19889
  }
19824
- return { max_tokens: 16384 };
19890
+ return { max_tokens: PROTOCOL_FALLBACK_MAX_TOKENS };
19825
19891
  }
19826
19892
  function resolveNativeAnthropicMessagesConfigFromGatewayConfig(cfg, options) {
19827
19893
  const slice = resolveProviderSliceFromGatewayConfig(cfg, {
@@ -22502,6 +22568,9 @@ async function runCompactPipeline(ctx) {
22502
22568
  return runCompactSummarizerPipeline(ctx);
22503
22569
  }
22504
22570
 
22571
+ // src/owned-tools/registry.ts
22572
+ init_internal_tool_names();
22573
+
22505
22574
  // src/owned-tools/agents-list.ts
22506
22575
  init_runtime_data();
22507
22576
  init_tool_descriptor();
@@ -23757,52 +23826,28 @@ function uniqueAppend(existing, incoming, max) {
23757
23826
  function normalizeEvidenceRefs(refs) {
23758
23827
  return uniqueAppend([], refs, 20);
23759
23828
  }
23760
- function hasRepeatedToolWithoutEvidence(events) {
23761
- const recent = events.filter((event) => event.kind === "tool").slice(-3);
23762
- if (recent.length < 3) {
23763
- return false;
23764
- }
23765
- const [first] = recent;
23766
- return recent.every(
23767
- (event) => event.kind === "tool" && event.toolName && event.toolName === first.toolName && event.toolArgsHash && event.toolArgsHash === first.toolArgsHash && event.newEvidence !== true
23768
- );
23769
- }
23770
- function hasRepeatedToolFailure(events) {
23771
- const recentFailures = events.filter((event) => event.kind === "tool" && event.outcome === "failed").slice(-3);
23772
- if (recentFailures.length < 3) {
23773
- return false;
23774
- }
23775
- const first = recentFailures[0];
23776
- return recentFailures.every(
23777
- (event) => event.toolName && event.toolName === first?.toolName && (!first?.toolArgsHash || event.toolArgsHash === first.toolArgsHash)
23778
- );
23779
- }
23780
- function hasRepeatedFailure(events) {
23781
- const recentFailures = events.filter((event) => event.kind === "failure").slice(-3);
23782
- if (recentFailures.length < 3) {
23783
- return false;
23784
- }
23785
- const firstSummary = recentFailures[0]?.summary.trim().toLowerCase();
23786
- return Boolean(firstSummary) && recentFailures.every((event) => event.summary.trim().toLowerCase() === firstSummary);
23787
- }
23788
- function evaluateLoopBreaker(events, at) {
23789
- if (hasRepeatedToolFailure(events)) {
23790
- return { tripped: true, reason: "repeated_tool_failure", at };
23791
- }
23792
- if (hasRepeatedToolWithoutEvidence(events)) {
23793
- return { tripped: true, reason: "repeated_tool_without_new_evidence", at };
23794
- }
23795
- if (hasRepeatedFailure(events)) {
23796
- return { tripped: true, reason: "repeated_failure", at };
23797
- }
23798
- return void 0;
23799
- }
23800
23829
  async function readRunLedger(taskId) {
23801
23830
  return readJsonFile(resolveRunLedgerPath(taskId));
23802
23831
  }
23803
23832
  async function readRunLedgerEvents(taskId, limit) {
23804
23833
  return readJsonLines(resolveRunLedgerEventLogPath(taskId), limit);
23805
23834
  }
23835
+ function readLegacyRunLedgerLoopMarker(ledger) {
23836
+ if (!ledger) return null;
23837
+ const marker = ledger.loopBreaker;
23838
+ if (!marker || typeof marker !== "object") return null;
23839
+ const record = marker;
23840
+ const reason = typeof record.reason === "string" ? record.reason.trim() : "";
23841
+ const at = typeof record.at === "string" ? record.at.trim() : "";
23842
+ return {
23843
+ tripped: record.tripped === true,
23844
+ reason: reason || "legacy_loop_marker",
23845
+ at: at || "unknown"
23846
+ };
23847
+ }
23848
+ function legacyRunLedgerLoopMarkerTripped(ledger) {
23849
+ return readLegacyRunLedgerLoopMarker(ledger)?.tripped === true;
23850
+ }
23806
23851
  async function updateRunLedger(input) {
23807
23852
  if (!input.taskId.trim()) {
23808
23853
  throw new Error("run_ledger.update requires taskId");
@@ -23856,12 +23901,7 @@ async function updateRunLedger(input) {
23856
23901
  openLoops,
23857
23902
  ...input.nextStep ? { nextStep: input.nextStep.trim() } : base.nextStep ? { nextStep: base.nextStep } : {}
23858
23903
  };
23859
- const loopBreaker = evaluateLoopBreaker(events, now);
23860
- if (loopBreaker) {
23861
- next.loopBreaker = loopBreaker;
23862
- } else if (base.loopBreaker?.tripped) {
23863
- next.loopBreaker = base.loopBreaker;
23864
- }
23904
+ delete next.loopBreaker;
23865
23905
  const logEntry = {
23866
23906
  schemaVersion: RUN_LEDGER_EVENT_SCHEMA_VERSION,
23867
23907
  taskId: input.taskId,
@@ -23887,8 +23927,9 @@ function formatRunLedgerBlock(ledger) {
23887
23927
  const failures = ledger.failures.slice(-5).map((failure) => `- ${failure}`);
23888
23928
  const artifacts = ledger.artifactRefs.slice(-6).map((artifact) => `- ${artifact}`);
23889
23929
  const loops = ledger.openLoops.slice(-6).map((loop) => `- ${loop}`);
23890
- const breaker = ledger.loopBreaker?.tripped ? `
23891
- Loop breaker: ${ledger.loopBreaker.reason} at ${ledger.loopBreaker.at}` : "";
23930
+ const legacyLoopMarker = readLegacyRunLedgerLoopMarker(ledger);
23931
+ const breaker = legacyLoopMarker?.tripped ? `
23932
+ Legacy loop marker (not a runtime blocker): ${legacyLoopMarker.reason} at ${legacyLoopMarker.at}` : "";
23892
23933
  return [
23893
23934
  "## Active Task Ledger",
23894
23935
  `Task: ${ledger.taskId}`,
@@ -26696,6 +26737,7 @@ var import_node_path47 = __toESM(require("path"));
26696
26737
  var import_node_crypto20 = require("crypto");
26697
26738
  var import_node_fs48 = require("fs");
26698
26739
  var import_node_path45 = __toESM(require("path"));
26740
+ init_delivery_verification();
26699
26741
  init_team_memory_runtime();
26700
26742
  init_memory_event();
26701
26743
  init_memory_consolidate();
@@ -26728,13 +26770,6 @@ function lastCheckpointAtMs(ledger) {
26728
26770
  }
26729
26771
  return parseIsoMs(ledger.createdAt);
26730
26772
  }
26731
- function hasCheckpointAfter(ledger, at) {
26732
- const atMs = parseIsoMs(at);
26733
- if (atMs === null) {
26734
- return false;
26735
- }
26736
- return ledger.events.some((event) => event.kind === "checkpoint" && (parseIsoMs(event.at) ?? 0) >= atMs);
26737
- }
26738
26773
  function evaluateRunLedgerCheckpoint(ledger, policy = {}, now = /* @__PURE__ */ new Date()) {
26739
26774
  const lastEvent = ledger.events.at(-1);
26740
26775
  const lastIdx = lastCheckpointIndex(ledger.events);
@@ -26746,14 +26781,6 @@ function evaluateRunLedgerCheckpoint(ledger, policy = {}, now = /* @__PURE__ */
26746
26781
  if (lastEvent?.kind === "checkpoint" || eventsSinceLastCheckpoint <= 0) {
26747
26782
  return { shouldCheckpoint: false, eventsSinceLastCheckpoint, msSinceLastCheckpoint };
26748
26783
  }
26749
- if (policy.forceOnLoopBreaker !== false && ledger.loopBreaker?.tripped && !hasCheckpointAfter(ledger, ledger.loopBreaker.at)) {
26750
- return {
26751
- shouldCheckpoint: true,
26752
- reason: "loop_breaker",
26753
- eventsSinceLastCheckpoint,
26754
- msSinceLastCheckpoint
26755
- };
26756
- }
26757
26784
  if (eventsSinceLastCheckpoint >= maxEvents) {
26758
26785
  return {
26759
26786
  shouldCheckpoint: true,
@@ -26820,15 +26847,6 @@ function stableNormalize(value, seen = /* @__PURE__ */ new WeakSet()) {
26820
26847
  function sha256Hex2(value) {
26821
26848
  return (0, import_node_crypto18.createHash)("sha256").update(value).digest("hex");
26822
26849
  }
26823
- function lastNonCheckpointEvents(ledger, limit) {
26824
- return ledger.events.filter((event) => event.kind !== "checkpoint").slice(-limit);
26825
- }
26826
- function currentWouldRepeatNoEvidence(ledger, toolName, toolArgsHash) {
26827
- const recent = lastNonCheckpointEvents(ledger, 2);
26828
- return recent.length === 2 && recent.every(
26829
- (event) => event.kind === "tool" && event.toolName === toolName && event.toolArgsHash === toolArgsHash && event.newEvidence !== true
26830
- );
26831
- }
26832
26850
  function hasNewEvidence(outcome, resultContent) {
26833
26851
  return outcome === "ok" && typeof resultContent === "string" && resultContent.trim().length > 0;
26834
26852
  }
@@ -26845,55 +26863,6 @@ function deriveRunLedgerToolArgsHash(toolName, toolArgs) {
26845
26863
  async function assessLongRunToolCall(input) {
26846
26864
  const toolArgsHash = deriveRunLedgerToolArgsHash(input.toolName, input.toolArgs);
26847
26865
  const ledger = await readRunLedger(input.taskId);
26848
- if (ledger?.loopBreaker?.tripped) {
26849
- return {
26850
- allowed: false,
26851
- code: "RUN_LEDGER_LOOP_BREAKER",
26852
- reason: ledger.loopBreaker.reason,
26853
- detail: `RunLedger ${input.taskId} tripped loop breaker at ${ledger.loopBreaker.at}; checkpoint or change strategy before executing more tools.`,
26854
- toolArgsHash,
26855
- ledger,
26856
- checkpointed: false
26857
- };
26858
- }
26859
- if (ledger && currentWouldRepeatNoEvidence(ledger, input.toolName, toolArgsHash)) {
26860
- const updated = await updateRunLedger({
26861
- taskId: input.taskId,
26862
- agentId: input.agentId,
26863
- ...input.sessionId ? { sessionId: input.sessionId } : {},
26864
- ...input.teamId ? { teamId: input.teamId } : {},
26865
- goal: ledger.goal,
26866
- phase: "loop_breaker",
26867
- event: {
26868
- kind: "tool",
26869
- summary: `blocked repeated no-evidence tool call ${input.toolName}`,
26870
- toolName: input.toolName,
26871
- toolArgsHash,
26872
- outcome: "failed",
26873
- newEvidence: false,
26874
- evidenceRefs: input.evidenceRefs
26875
- },
26876
- artifactRefs: ledger.artifactRefs,
26877
- openLoops: [
26878
- ...ledger.openLoops,
26879
- `blocked repeated no-evidence tool call: ${input.toolName} args=${toolArgsHash}`
26880
- ],
26881
- nextStep: "Stop repeating the same tool arguments; inspect prior evidence, change strategy, or ask for clarification."
26882
- });
26883
- const checkpoint = await maybeCheckpointRunLedger({
26884
- ledger: updated,
26885
- policy: { forceOnLoopBreaker: true }
26886
- });
26887
- return {
26888
- allowed: false,
26889
- code: "RUN_LEDGER_REPEAT_TOOL_NO_EVIDENCE",
26890
- reason: "repeated_tool_without_new_evidence",
26891
- detail: `The previous two non-checkpoint ledger events already used ${input.toolName} with argsHash=${toolArgsHash} and no new evidence.`,
26892
- toolArgsHash,
26893
- ledger: checkpoint.ledger,
26894
- checkpointed: checkpoint.checkpointed
26895
- };
26896
- }
26897
26866
  return { allowed: true, toolArgsHash, ledger };
26898
26867
  }
26899
26868
  async function recordLongRunToolResult(input) {
@@ -27328,7 +27297,7 @@ async function evalProjectDetail(runId) {
27328
27297
  day: 2,
27329
27298
  category: "failure",
27330
27299
  query: "What Day 2 failure reason must be remembered for repeated tools?",
27331
- expected: "Day 2 failure shield: repeated same-tool no-evidence calls must trip RUN_LEDGER_REPEAT_TOOL_NO_EVIDENCE before another execution.",
27300
+ expected: "Day 2 failure shield: repeated same-tool no-evidence calls stay recorded in RunLedger, while maxTurns, prompt guidance, and is_error tool results steer recovery instead of a runtime blocker.",
27332
27301
  evidenceRef: "eval:project:day2:failure"
27333
27302
  },
27334
27303
  {
@@ -27562,6 +27531,53 @@ async function evalEvidenceTrace(runId) {
27562
27531
  }
27563
27532
  );
27564
27533
  }
27534
+ async function evalToolResultCompletionEvidence(_runId) {
27535
+ const verbalCompletionClaim = "\u5DF2\u5B8C\u6210\u4FEE\u6539\uFF0C\u5171\u5904\u7406 8 \u4E2A\u6587\u4EF6";
27536
+ const noToolResultVerification = assessDeliveryVerification(verbalCompletionClaim, []);
27537
+ const unrelatedSuccessToolCalls = [
27538
+ {
27539
+ toolCallId: "eval-agents-list-1",
27540
+ name: "agents_list",
27541
+ status: "success",
27542
+ result: JSON.stringify({ ok: true, data: [{ id: "dev" }] }),
27543
+ startedAt: "2026-01-01T00:00:00.000Z"
27544
+ }
27545
+ ];
27546
+ const unrelatedToolVerification = assessDeliveryVerification(verbalCompletionClaim, unrelatedSuccessToolCalls);
27547
+ const evidenceBackedToolCalls = [
27548
+ {
27549
+ toolCallId: "eval-write-1",
27550
+ name: "write",
27551
+ status: "success",
27552
+ args: { path: "docs/report.md" },
27553
+ result: JSON.stringify({
27554
+ ok: true,
27555
+ tool: "write",
27556
+ data: {
27557
+ path: "docs/report.md",
27558
+ bytesWritten: 128
27559
+ }
27560
+ }),
27561
+ startedAt: "2026-01-01T00:00:01.000Z"
27562
+ }
27563
+ ];
27564
+ const evidenceToolVerification = assessDeliveryVerification(verbalCompletionClaim, evidenceBackedToolCalls);
27565
+ return caseFromCheck(
27566
+ "tool-result-completion-evidence-boundary",
27567
+ "evidence_trace",
27568
+ noToolResultVerification === "unverified" && unrelatedToolVerification === "unverified" && evidenceToolVerification === "verified",
27569
+ "Verbal completion claims fail without matching tool_result evidence and pass only when an evidence-backed tool result is attached.",
27570
+ ["src/mobile/group/delivery-verification.ts", "eval:tool-result-completion-evidence"],
27571
+ {
27572
+ noToolResultVerification,
27573
+ unrelatedToolVerification,
27574
+ evidenceToolVerification,
27575
+ matchingToolResultCount: 0,
27576
+ unrelatedSuccessToolCount: unrelatedSuccessToolCalls.length,
27577
+ evidenceBackedToolCount: evidenceBackedToolCalls.length
27578
+ }
27579
+ );
27580
+ }
27565
27581
  async function evalTeamIsolation(runId, workspaceRoot) {
27566
27582
  const memberAgentIds = [
27567
27583
  `eval-agent-architect-${runId}`,
@@ -27704,7 +27720,7 @@ async function evalLongRun(runId) {
27704
27720
  evidenceRefs: ["eval:long-run:start"],
27705
27721
  newEvidence: true
27706
27722
  },
27707
- openLoops: ["verify checkpoint cadence", "verify idempotent side effects", "verify resume after loop breaker"],
27723
+ openLoops: ["verify checkpoint cadence", "verify idempotent side effects", "verify resume after repeated no-evidence telemetry"],
27708
27724
  nextStep: "Continue bounded multi-tool execution with durable ledger checkpoints."
27709
27725
  });
27710
27726
  for (let step = 0; step < totalSteps; step += 1) {
@@ -27715,7 +27731,7 @@ async function evalLongRun(runId) {
27715
27731
  shard: `shard-${step % 11}`,
27716
27732
  query: `memory-runtime-v2-long-run-${runId}-${step}`
27717
27733
  };
27718
- const guard = await assessLongRunToolCall({
27734
+ const guard2 = await assessLongRunToolCall({
27719
27735
  taskId,
27720
27736
  agentId,
27721
27737
  sessionId,
@@ -27723,15 +27739,6 @@ async function evalLongRun(runId) {
27723
27739
  toolArgs,
27724
27740
  evidenceRefs: [`eval:long-run:guard:${step}`]
27725
27741
  });
27726
- if (!guard.allowed) {
27727
- return failCase(
27728
- "long-run-7x24-recovery",
27729
- "long_run",
27730
- `Unexpected guard block during varied 7x24 run: ${guard.reason}`,
27731
- ["eval:long-run:unexpected-block"],
27732
- { step, guard }
27733
- );
27734
- }
27735
27742
  const result = await recordLongRunToolResult({
27736
27743
  taskId,
27737
27744
  agentId,
@@ -27793,13 +27800,13 @@ async function evalLongRun(runId) {
27793
27800
  evidenceRefs: [`eval:long-run:no-evidence:${i}`]
27794
27801
  });
27795
27802
  }
27796
- const blocked = await assessLongRunToolCall({
27803
+ const guard = await assessLongRunToolCall({
27797
27804
  taskId,
27798
27805
  agentId,
27799
27806
  sessionId,
27800
27807
  toolName: repeatedToolName,
27801
27808
  toolArgs: repeatedToolArgs,
27802
- evidenceRefs: ["eval:long-run:no-evidence:block"]
27809
+ evidenceRefs: ["eval:long-run:no-evidence:record"]
27803
27810
  });
27804
27811
  const resumedLedger = await readRunLedger(taskId);
27805
27812
  const eventLog = await readRunLedgerEvents(taskId);
@@ -27813,7 +27820,7 @@ async function evalLongRun(runId) {
27813
27820
  taskId,
27814
27821
  project: null,
27815
27822
  agentWorkspaceRoot: workspaceRootForLongRun(runId),
27816
- queryText: "resume after repeated no evidence loop breaker",
27823
+ queryText: "resume after repeated no-evidence telemetry without a runtime blocker",
27817
27824
  recentTurnsBlock: "Runtime resumes after a synthetic 7x24 tool loop without replaying the full event log.",
27818
27825
  budgetClass: "balanced"
27819
27826
  });
@@ -27822,13 +27829,14 @@ async function evalLongRun(runId) {
27822
27829
  const appendOnlyHasStart = eventLog.some((entry) => entry.event.summary.includes("Start synthetic 7x24"));
27823
27830
  const appendOnlyHasFinalStep = eventLog.some((entry) => entry.event.evidenceRefs.includes(`eval:long-run:step:${totalSteps - 1}`));
27824
27831
  const snapshotBounded = (resumedLedger?.events.length ?? Number.POSITIVE_INFINITY) <= 200;
27825
- const resumeContainsBreaker = renderedResume.includes("Loop breaker: repeated_tool_without_new_evidence") && renderedResume.includes("Stop repeating the same tool arguments");
27832
+ const resumeContainsRepeatedNoEvidence = renderedResume.includes("owned tool web_fetch outcome=inconclusive") || renderedResume.includes("same-empty-result");
27833
+ const legacyLoopMarkerTripped = legacyRunLedgerLoopMarkerTripped(resumedLedger);
27826
27834
  return caseFromCheck(
27827
27835
  "long-run-7x24-recovery",
27828
27836
  "long_run",
27829
- !blocked.allowed && blocked.code === "RUN_LEDGER_REPEAT_TOOL_NO_EVIDENCE" && blocked.checkpointed && checkpointCount >= 8 && checkpointEventCount >= checkpointCount && sideEffectExecuteCount === 1 && sideEffectReplayCount === 1 && snapshotBounded && eventLog.length > totalSteps && appendOnlyHasStart && appendOnlyHasFinalStep && recentEvents.at(-1)?.event.kind === "checkpoint" && resumedLedger?.loopBreaker?.reason === "repeated_tool_without_new_evidence" && resumeContainsBreaker,
27830
- "A 7x24 synthetic multi-tool run checkpoints durably, replays idempotent side effects, trips the loop breaker on repeated no-evidence calls, and resumes from bounded ledger state plus append-only event log.",
27831
- ["eval:long-run:start", `ledger:${taskId}`, "eval:long-run:idempotency:complete", "eval:long-run:no-evidence:block"],
27837
+ guard.allowed && checkpointCount >= 8 && checkpointEventCount >= checkpointCount && sideEffectExecuteCount === 1 && sideEffectReplayCount === 1 && snapshotBounded && eventLog.length > totalSteps && appendOnlyHasStart && appendOnlyHasFinalStep && recentEvents.at(-1)?.event.kind === "tool" && !legacyLoopMarkerTripped && resumeContainsRepeatedNoEvidence,
27838
+ "A 7x24 synthetic multi-tool run checkpoints durably, replays idempotent side effects, records repeated no-evidence calls without blocking execution, and resumes from bounded ledger state plus append-only event log.",
27839
+ ["eval:long-run:start", `ledger:${taskId}`, "eval:long-run:idempotency:complete", "eval:long-run:no-evidence:record"],
27832
27840
  {
27833
27841
  simulatedHours,
27834
27842
  totalToolSteps: totalSteps,
@@ -27838,13 +27846,12 @@ async function evalLongRun(runId) {
27838
27846
  checkpointEventCount,
27839
27847
  sideEffectExecuteCount,
27840
27848
  sideEffectReplayCount,
27841
- blockedCode: blocked.allowed ? null : blocked.code,
27842
- blockedReason: blocked.allowed ? null : blocked.reason,
27843
- blockedCheckpointed: blocked.allowed ? false : blocked.checkpointed,
27849
+ guardAllowed: guard.allowed,
27850
+ legacyLoopMarkerTripped,
27844
27851
  appendOnlyHasStart,
27845
27852
  appendOnlyHasFinalStep,
27846
27853
  latestRecentEventKind: recentEvents.at(-1)?.event.kind,
27847
- resumeContainsBreaker
27854
+ resumeContainsRepeatedNoEvidence
27848
27855
  }
27849
27856
  );
27850
27857
  }
@@ -28379,6 +28386,7 @@ async function runMemoryRuntimeV2SelfEval(input = {}) {
28379
28386
  evalContinuity,
28380
28387
  evalProjectDetail,
28381
28388
  evalEvidenceTrace,
28389
+ evalToolResultCompletionEvidence,
28382
28390
  evalTeamIsolation,
28383
28391
  evalLongRun,
28384
28392
  evalSideEffect,
@@ -29469,7 +29477,7 @@ function buildGates(input) {
29469
29477
  category: "long_run",
29470
29478
  title: "7x24 durable tool execution",
29471
29479
  status: casePassed(evalReport, "long_run") && casePassed(evalReport, "side_effect") ? "proven" : evalFailed ? "blocked" : "partial",
29472
- summary: "Long tasks must checkpoint, keep append-only event logs, replay idempotent side effects, and trip loop breakers on repeated no-evidence work.",
29480
+ summary: "Long tasks must checkpoint, keep append-only event logs, replay idempotent side effects, and preserve repeated no-evidence telemetry without blocking tool execution.",
29473
29481
  evidenceRefs: ["src/mobile/memory-runtime-v2/long-run-guard.ts", "src/mobile/memory-runtime-v2/tool-side-effect.ts", ...caseEvidence(evalReport, "long_run"), ...caseEvidence(evalReport, "side_effect")],
29474
29482
  blockers: evalFailed ? ["Latest long-run or side-effect eval did not pass."] : [],
29475
29483
  nextActions: casePassed(evalReport, "long_run") ? ["Add wall-clock soak and process-restart recovery evidence."] : ["Run the 7x24 synthetic long-run eval."]
@@ -31050,6 +31058,105 @@ function appendChainAbortNotice(stderr, command, exitCode) {
31050
31058
 
31051
31059
  ${notice}` : notice;
31052
31060
  }
31061
+ function extractProbeLeadingToken(command) {
31062
+ let cmd = command.trim();
31063
+ const psMatch = /^(?:powershell|pwsh)(?:\.exe)?\b[\s\S]*?\s-(?:c|command)\s+(.+)$/i.exec(cmd);
31064
+ if (psMatch?.[1]) {
31065
+ cmd = psMatch[1].trim().replace(/^["'&{}\s]+/, "");
31066
+ }
31067
+ const first = cmd.split(/[\s;|]+/, 1)[0] ?? "";
31068
+ return first.replace(/^["']+/, "").replace(/\.exe$/i, "").toLowerCase();
31069
+ }
31070
+ var PROBE_COMMAND_TOKENS = /* @__PURE__ */ new Set([
31071
+ "findstr",
31072
+ "find",
31073
+ "where",
31074
+ "grep",
31075
+ "rg",
31076
+ "egrep",
31077
+ "fgrep",
31078
+ "dir",
31079
+ "get-command",
31080
+ "get-childitem",
31081
+ "gci"
31082
+ ]);
31083
+ function execNonzeroIsBenignProbe(record) {
31084
+ if (record.exitCode !== 1) {
31085
+ return false;
31086
+ }
31087
+ if (String(record.stderr ?? "").trim()) {
31088
+ return false;
31089
+ }
31090
+ const token = extractProbeLeadingToken(record.command);
31091
+ if (PROBE_COMMAND_TOKENS.has(token)) {
31092
+ return true;
31093
+ }
31094
+ if (token === "pip" || token === "pip3") {
31095
+ return /\bpip3?\b[\s\S]*\b(show|index)\b/i.test(record.command);
31096
+ }
31097
+ return false;
31098
+ }
31099
+ function execExitZeroLooksInconclusive(record) {
31100
+ const stdout = String(record.stdout ?? "").trim();
31101
+ const stderr = String(record.stderr ?? "").trim();
31102
+ const psShellError = /CommandNotFoundException|无法将|is not recognized as an internal or external command/i.test(stderr);
31103
+ return !stdout && Boolean(stderr) || psShellError;
31104
+ }
31105
+ function classifyOwnedExecResultSemantic(result) {
31106
+ if (result.background === true) {
31107
+ return { isError: false, summary: "exec started (background)" };
31108
+ }
31109
+ const stdout = String(result.stdout ?? "").trim();
31110
+ const stderr = String(result.stderr ?? "").trim();
31111
+ if (result.exitCode === 0) {
31112
+ if (execExitZeroLooksInconclusive(result)) {
31113
+ return {
31114
+ isError: true,
31115
+ code: "EXEC_INCONCLUSIVE",
31116
+ error: "exec exit 0 but output inconclusive (stderr indicates shell failure)",
31117
+ detail: stderr || "empty stdout with stderr errors \u2014 not a verification"
31118
+ };
31119
+ }
31120
+ return {
31121
+ isError: false,
31122
+ summary: stdout ? `exit 0 \u2014 ${stdout.slice(0, 240)}` : "exit 0 (INCONCLUSIVE: empty stdout \u2014 exit 0 alone is not a verification)"
31123
+ };
31124
+ }
31125
+ if (execNonzeroIsBenignProbe(result)) {
31126
+ return {
31127
+ isError: false,
31128
+ summary: stdout ? `exit 1 (probe no match) \u2014 ${stdout.slice(0, 240)}` : "exit 1 (probe returned no match / not found \u2014 this is a valid empty result, not a command error)"
31129
+ };
31130
+ }
31131
+ if (result.exitCode === 124) {
31132
+ return {
31133
+ isError: true,
31134
+ code: "EXEC_TIMEOUT",
31135
+ error: `command timed out (exit ${result.exitCode})`,
31136
+ detail: stderr || stdout || void 0
31137
+ };
31138
+ }
31139
+ if (stderr.includes("[XKZOOM] command chain")) {
31140
+ return {
31141
+ isError: true,
31142
+ code: "EXEC_CHAIN_ABORT",
31143
+ error: `command chain aborted (exit ${result.exitCode})`,
31144
+ detail: stderr || stdout || void 0
31145
+ };
31146
+ }
31147
+ return {
31148
+ isError: true,
31149
+ code: "EXEC_NONZERO_EXIT",
31150
+ error: `command exited with code ${result.exitCode}`,
31151
+ detail: stderr || stdout || void 0
31152
+ };
31153
+ }
31154
+ function withOwnedExecSemantics(result) {
31155
+ return {
31156
+ ...result,
31157
+ semantic: result.semantic ?? classifyOwnedExecResultSemantic(result)
31158
+ };
31159
+ }
31053
31160
  function detectOutOfRootAbsolutePaths(command, root) {
31054
31161
  const rootAbs = path36.resolve(root);
31055
31162
  const out = [];
@@ -31074,7 +31181,7 @@ function readOwnedExecParams(params) {
31074
31181
  async function runOwnedExec(params) {
31075
31182
  const primitive = await runExecPrimitiveAction({ root: params.root, toolParams: params.toolParams });
31076
31183
  if (primitive) {
31077
- return primitive;
31184
+ return withOwnedExecSemantics(primitive);
31078
31185
  }
31079
31186
  const parsed = readOwnedExecParams(params.toolParams);
31080
31187
  if (!parsed.command?.trim()) throw new Error("command is required (or use action=route_smoke|npm_script)");
@@ -31129,7 +31236,7 @@ async function runOwnedExec(params) {
31129
31236
  spawnPty: params.spawnPty,
31130
31237
  now: params.now
31131
31238
  });
31132
- return {
31239
+ return withOwnedExecSemantics({
31133
31240
  command: effectiveCommand,
31134
31241
  cwd,
31135
31242
  activeRoot: rootAbs,
@@ -31140,7 +31247,7 @@ async function runOwnedExec(params) {
31140
31247
  sessionId: started.sessionId,
31141
31248
  ...started.pid !== void 0 ? { pid: started.pid } : {},
31142
31249
  ...warningList ? { warnings: warningList } : {}
31143
- };
31250
+ });
31144
31251
  }
31145
31252
  const timeoutSec = resolveForegroundExecTimeoutSec(effectiveCommand, parsed.timeoutSec);
31146
31253
  const timeoutMs = timeoutSec * 1e3;
@@ -31156,7 +31263,7 @@ async function runOwnedExec(params) {
31156
31263
  windowsHide: true,
31157
31264
  encoding: "utf8"
31158
31265
  });
31159
- return {
31266
+ return withOwnedExecSemantics({
31160
31267
  command: effectiveCommand,
31161
31268
  cwd,
31162
31269
  activeRoot: rootAbs,
@@ -31164,14 +31271,14 @@ async function runOwnedExec(params) {
31164
31271
  stdout: truncateCapture2(String(stdout ?? "")),
31165
31272
  stderr: truncateCapture2(String(stderr ?? "")),
31166
31273
  ...warningList ? { warnings: warningList } : {}
31167
- };
31274
+ });
31168
31275
  } catch (err) {
31169
31276
  const record = err;
31170
31277
  const exitCode = typeof record.code === "number" ? record.code : record.killed ? 124 : 1;
31171
31278
  const stderr = truncateCapture2(
31172
31279
  appendChainAbortNotice(String(record.stderr ?? ""), effectiveCommand, exitCode)
31173
31280
  );
31174
- return {
31281
+ return withOwnedExecSemantics({
31175
31282
  command: effectiveCommand,
31176
31283
  cwd,
31177
31284
  activeRoot: rootAbs,
@@ -31179,7 +31286,7 @@ async function runOwnedExec(params) {
31179
31286
  stdout: truncateCapture2(String(record.stdout ?? "")),
31180
31287
  stderr,
31181
31288
  ...warningList ? { warnings: warningList } : {}
31182
- };
31289
+ });
31183
31290
  }
31184
31291
  }
31185
31292
  var execTool = defineTool({
@@ -33419,8 +33526,12 @@ async function readOwnedMemoryFile(params) {
33419
33526
  const relPath = path38.relative(workspaceDir, absPath).replace(/\\/g, "/");
33420
33527
  const allowedWorkspace = relPath.length > 0 && !relPath.startsWith("..") && !path38.isAbsolute(relPath) && isMemoryPath(relPath);
33421
33528
  const allowedAdditional = allowedWorkspace ? false : await isAllowedAdditionalPath(workspaceDir, absPath, params.extraPaths);
33422
- if (!allowedWorkspace && !allowedAdditional) throw new Error("path required");
33423
- if (!absPath.endsWith(".md")) throw new Error("path required");
33529
+ if (!allowedWorkspace && !allowedAdditional) {
33530
+ throw new Error(
33531
+ "memory_get only reads MEMORY.md or memory/** \u2014 use read(scope=agent) for AGENTS.md/SOUL.md/USER.md."
33532
+ );
33533
+ }
33534
+ if (!absPath.endsWith(".md")) throw new Error("memory_get requires a .md path.");
33424
33535
  const stat4 = await statRegularFile(absPath);
33425
33536
  if (stat4.missing || !stat4.file) {
33426
33537
  return { text: "", path: relPath };
@@ -33447,7 +33558,7 @@ async function readOwnedMemoryFile(params) {
33447
33558
  }
33448
33559
  var memoryGetTool = defineTool({
33449
33560
  name: "memory_get",
33450
- doc: "Read a file from the agent's memory workspace (MEMORY.md, memory/**, USER.md).",
33561
+ doc: "Read a file from the agent's memory workspace (MEMORY.md or memory/**).",
33451
33562
  inputScope: "memory-workspace",
33452
33563
  properties: {
33453
33564
  path: { type: "string", description: "Memory file path, e.g. MEMORY.md or memory/notes/x.md." },
@@ -36329,6 +36440,19 @@ var OWNED_TURN_TOOL_BY_NAME = new Map(
36329
36440
  OWNED_TURN_TOOLS.map((tool) => [tool.name, tool])
36330
36441
  );
36331
36442
  var OWNED_TURN_TOOL_NAMES = OWNED_TURN_TOOLS.map((tool) => tool.name);
36443
+ (() => {
36444
+ const derived = new Set(OWNED_INTERNAL_TOOL_CATALOG.map((entry) => entry.tool.name));
36445
+ for (const name of derived) {
36446
+ if (!OWNED_INTERNAL_TOOL_NAMES.has(name)) {
36447
+ throw new Error(`OWNED_INTERNAL_TOOL_NAMES missing internal tool: ${name}`);
36448
+ }
36449
+ }
36450
+ for (const name of OWNED_INTERNAL_TOOL_NAMES) {
36451
+ if (!derived.has(name)) {
36452
+ throw new Error(`OWNED_INTERNAL_TOOL_NAMES has stale internal tool: ${name}`);
36453
+ }
36454
+ }
36455
+ })();
36332
36456
 
36333
36457
  // src/owned-tools/compact/registry.ts
36334
36458
  var COMPACT_OWNED_TOOLS = OWNED_INTERNAL_TOOL_CATALOG.map((entry) => entry.tool).filter((tool) => ["diary_search", "notes_search", "notes_get", "summarize"].includes(tool.name));