@qwen-code/qwen-code 0.25.4-preview.0 → 0.25.4-preview.1

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 (306) hide show
  1. package/bundled/browser-use/runtime/native-host.js +0 -0
  2. package/bundled/browser-use/runtime/node_modules/playwright-core/bin/reinstall_chrome_beta_linux.sh +0 -0
  3. package/bundled/browser-use/runtime/node_modules/playwright-core/bin/reinstall_chrome_beta_mac.sh +0 -0
  4. package/bundled/browser-use/runtime/node_modules/playwright-core/bin/reinstall_chrome_stable_linux.sh +0 -0
  5. package/bundled/browser-use/runtime/node_modules/playwright-core/bin/reinstall_chrome_stable_mac.sh +0 -0
  6. package/bundled/browser-use/runtime/node_modules/playwright-core/bin/reinstall_msedge_beta_linux.sh +0 -0
  7. package/bundled/browser-use/runtime/node_modules/playwright-core/bin/reinstall_msedge_beta_mac.sh +0 -0
  8. package/bundled/browser-use/runtime/node_modules/playwright-core/bin/reinstall_msedge_dev_linux.sh +0 -0
  9. package/bundled/browser-use/runtime/node_modules/playwright-core/bin/reinstall_msedge_dev_mac.sh +0 -0
  10. package/bundled/browser-use/runtime/node_modules/playwright-core/bin/reinstall_msedge_stable_linux.sh +0 -0
  11. package/bundled/browser-use/runtime/node_modules/playwright-core/bin/reinstall_msedge_stable_mac.sh +0 -0
  12. package/bundled/browser-use/runtime/node_modules/playwright-core/cli.js +0 -0
  13. package/bundled/browser-use/runtime/node_modules/playwright-core/lib/webp_codec.wasm +0 -0
  14. package/bundled/browser-use/runtime/node_modules/playwright-core/lib/xdg-open +0 -0
  15. package/bundled/browser-use/runtime/scripts/native-host-setup.js +0 -0
  16. package/chunks/{MaxSizedBox-M27H235V.js → MaxSizedBox-E4RKSA7W.js} +1 -1
  17. package/chunks/{StandaloneSessionPicker-LWWDDYOW.js → StandaloneSessionPicker-2D3UKLVS.js} +1 -1
  18. package/chunks/{acp-subagent-executor-NUV52JVS.js → acp-subagent-executor-UQYUN6AB.js} +1 -1
  19. package/chunks/{acpAgent-IUJDXLZM.js → acpAgent-P7WGK2BP.js} +3 -3
  20. package/chunks/{advisor-MSOUBMJ6.js → advisor-GCH2MBXT.js} +1 -1
  21. package/chunks/{agent-H7XIWYWQ.js → agent-57T4YAYP.js} +1 -1
  22. package/chunks/{agent-headless-XDN3D3S3.js → agent-headless-IBON3A7N.js} +1 -1
  23. package/chunks/{agent-host-client-AZP3PZXS.js → agent-host-client-LE7P72FR.js} +1 -1
  24. package/chunks/{agent-host-connections-JRVX7I6I.js → agent-host-connections-4DM57L26.js} +1 -1
  25. package/chunks/{anthropicContentGenerator-N7TV53LD.js → anthropicContentGenerator-C4TPFXUK.js} +1 -1
  26. package/chunks/{batch-MKSJFJUH.js → batch-YJJGMJWO.js} +1 -1
  27. package/chunks/{bridge-GNMKKHQ4.js → bridge-FIO2ENBG.js} +1 -1
  28. package/chunks/{channel-settings-store-Y4YCS7JX.js → channel-settings-store-TEBCLK2B.js} +1 -1
  29. package/chunks/{chunk-GPOUP5OK.js → chunk-27MTSS3T.js} +1 -1
  30. package/chunks/{chunk-C4ANA47H.js → chunk-2MGCRPM3.js} +1 -1
  31. package/chunks/{chunk-6DQNNRRC.js → chunk-2WBKWPSO.js} +1 -1
  32. package/chunks/{chunk-CATL2PQS.js → chunk-34WLYVDK.js} +5 -5
  33. package/chunks/{chunk-B7CXPNCV.js → chunk-3J2YNEHG.js} +1 -1
  34. package/chunks/{chunk-VTNHPXNL.js → chunk-3TBFTELA.js} +1 -1
  35. package/chunks/{chunk-7JT34VGK.js → chunk-46I6JBVL.js} +1 -1
  36. package/chunks/{chunk-FEMWELCV.js → chunk-4ZKFLOEH.js} +1 -1
  37. package/chunks/{chunk-7AYXAVTZ.js → chunk-5DUJIOOX.js} +3 -3
  38. package/chunks/{chunk-6QLHJSVW.js → chunk-6PWOLWTH.js} +1 -1
  39. package/chunks/{chunk-OW4QBRSR.js → chunk-6UZ65Z2P.js} +1 -1
  40. package/chunks/{chunk-V2JZO5MS.js → chunk-7DSJE3CL.js} +1 -1
  41. package/chunks/{chunk-TJMHIEYI.js → chunk-7LCY7GGX.js} +1 -1
  42. package/chunks/{chunk-TLJHBK3A.js → chunk-7RNTXEWH.js} +1 -1
  43. package/chunks/{chunk-YZ7OO4AQ.js → chunk-A3IF6IOB.js} +1 -1
  44. package/chunks/{chunk-VTF6AVZB.js → chunk-A6OQSOUO.js} +1 -1
  45. package/chunks/{chunk-Y7YDHCON.js → chunk-AJ6JUUP7.js} +1 -1
  46. package/chunks/{chunk-QTMHQGWQ.js → chunk-AOMEBVFW.js} +1 -1
  47. package/chunks/{chunk-KVTG2ZNH.js → chunk-AUNAS7AS.js} +1 -1
  48. package/chunks/{chunk-BOFD4CN3.js → chunk-AVIDPC5K.js} +1 -1
  49. package/chunks/{chunk-ETYTRKB2.js → chunk-BOLPBPWC.js} +1 -1
  50. package/chunks/{chunk-OAPA66DR.js → chunk-BQQBFDBY.js} +1 -1
  51. package/chunks/{chunk-NOS2CNOI.js → chunk-CN22ATWU.js} +1 -1
  52. package/chunks/{chunk-XYBEQRSZ.js → chunk-DIHJELGW.js} +1 -1
  53. package/chunks/{chunk-XCEL3EDX.js → chunk-DJFCI7TU.js} +1 -1
  54. package/chunks/{chunk-VKEL2XTM.js → chunk-DQPDMFS3.js} +1 -1
  55. package/chunks/{chunk-DJRFEZBY.js → chunk-DSYKB77N.js} +1 -1
  56. package/chunks/{chunk-UEW7Q26E.js → chunk-EDNOGHMN.js} +2 -2
  57. package/chunks/{chunk-RXNGYG64.js → chunk-EE36D2EV.js} +1 -1
  58. package/chunks/{chunk-NZKX7HYL.js → chunk-EGQDN3FJ.js} +1 -1
  59. package/chunks/{chunk-DFRSQK5Q.js → chunk-FHFBCG6N.js} +1 -1
  60. package/chunks/{chunk-PECV2VVZ.js → chunk-GI6T3RBV.js} +1 -1
  61. package/chunks/{chunk-37BNHIUB.js → chunk-GOLT5JXA.js} +1 -1
  62. package/chunks/{chunk-KITFF4GL.js → chunk-IDGXHMNL.js} +1 -1
  63. package/chunks/{chunk-6HIOSLUM.js → chunk-IIZWK7ZP.js} +1 -1
  64. package/chunks/{chunk-MPGEAX4K.js → chunk-IJC6ZH2S.js} +1 -1
  65. package/chunks/{chunk-TLYJVB5H.js → chunk-IO6LSEPV.js} +1 -1
  66. package/chunks/{chunk-QIJKEZZR.js → chunk-IYVNCBMS.js} +1 -1
  67. package/chunks/{chunk-S4GOHFRN.js → chunk-JHGOWK7M.js} +1 -1
  68. package/chunks/{chunk-GHRD2MMC.js → chunk-JRJY343T.js} +1 -1
  69. package/chunks/{chunk-WCYZSCG7.js → chunk-JVUXQU3W.js} +1 -1
  70. package/chunks/{chunk-DMCTJUIJ.js → chunk-K2K2YYWO.js} +1 -1
  71. package/chunks/{chunk-37OHWQHB.js → chunk-KF6HU732.js} +2 -2
  72. package/chunks/{chunk-5LSV73BG.js → chunk-KVWUOBH7.js} +1 -1
  73. package/chunks/{chunk-7V4BAHFT.js → chunk-LBWBGFHD.js} +1 -1
  74. package/chunks/{chunk-RKPHDO42.js → chunk-LDXZT3SG.js} +5 -5
  75. package/chunks/{chunk-BGFA2SAQ.js → chunk-LFOZ6AIH.js} +1 -1
  76. package/chunks/{chunk-4322TZID.js → chunk-LGQHT42X.js} +2 -2
  77. package/chunks/{chunk-PDXZ2CUO.js → chunk-M3O2XDHA.js} +1 -1
  78. package/chunks/{chunk-47K2NMP6.js → chunk-M3UC46LS.js} +1 -1
  79. package/chunks/{chunk-UFRY7WND.js → chunk-M7JLPTQI.js} +1 -1
  80. package/chunks/{chunk-SATEKHQP.js → chunk-MBUXP3IS.js} +1 -1
  81. package/chunks/{chunk-RN6JS263.js → chunk-MEZA3VVH.js} +1 -1
  82. package/chunks/{chunk-OBFKP7RI.js → chunk-MWN6TR36.js} +1 -1
  83. package/chunks/{chunk-VHJ43ZYJ.js → chunk-O7XRQWCG.js} +1 -1
  84. package/chunks/{chunk-H224LNV3.js → chunk-OYFRLT5E.js} +1 -1
  85. package/chunks/{chunk-3NWFV2YF.js → chunk-PMBGV76N.js} +1 -1
  86. package/chunks/{chunk-YFAPACDE.js → chunk-PVM4IVFL.js} +6 -6
  87. package/chunks/{chunk-7WS2EYMQ.js → chunk-PWHD4NK3.js} +1 -1
  88. package/chunks/{chunk-JZIQSEFO.js → chunk-Q54NROBX.js} +1 -1
  89. package/chunks/{chunk-FCLAPJ22.js → chunk-QE7R4DPT.js} +1 -1
  90. package/chunks/{chunk-J6TW7GNF.js → chunk-QIUTQICH.js} +1 -1
  91. package/chunks/{chunk-TWDCN5H2.js → chunk-QK63EULE.js} +1 -1
  92. package/chunks/{chunk-HZZT75LI.js → chunk-QTAC4W7J.js} +1 -1
  93. package/chunks/{chunk-P7DIAJNX.js → chunk-R7HBR4QQ.js} +1 -1
  94. package/chunks/{chunk-U2FJSKS3.js → chunk-RHEMFKMX.js} +1 -1
  95. package/chunks/{chunk-TRRY3QMM.js → chunk-RL57IU47.js} +1 -1
  96. package/chunks/{chunk-SPWDYRDH.js → chunk-S2OOQRLJ.js} +1 -1
  97. package/chunks/{chunk-QBRADQ7L.js → chunk-SWTMWNTZ.js} +1 -1
  98. package/chunks/{chunk-AZUDF52L.js → chunk-SXTKQHFZ.js} +1 -1
  99. package/chunks/{chunk-5RQRSPPD.js → chunk-T5S3MJIK.js} +1 -1
  100. package/chunks/{chunk-I3ORWQ2U.js → chunk-UDGDEIBB.js} +1 -1
  101. package/chunks/{chunk-EMDEBV33.js → chunk-UIFBF3E7.js} +1 -1
  102. package/chunks/{chunk-BGEMWNES.js → chunk-UQDPWI7D.js} +1 -1
  103. package/chunks/{chunk-I5LKOTZT.js → chunk-VON4MVIM.js} +1 -1
  104. package/chunks/{chunk-HJPO6MEW.js → chunk-W5D2T2JK.js} +1 -1
  105. package/chunks/{chunk-F6YYDRMH.js → chunk-WNGYYU67.js} +1 -1
  106. package/chunks/{chunk-S2GKUZZZ.js → chunk-WO3F62ZD.js} +1 -1
  107. package/chunks/{chunk-K7KW3ZJQ.js → chunk-WVY5Q6YY.js} +1 -1
  108. package/chunks/{chunk-GH6DPLWU.js → chunk-Y4Q667BW.js} +1 -1
  109. package/chunks/{chunk-FH74N7Y7.js → chunk-YJLMFUCS.js} +2 -2
  110. package/chunks/{chunk-C3Y2S5AM.js → chunk-YKHRCSKP.js} +1 -1
  111. package/chunks/{chunk-P4UJ7CXJ.js → chunk-YLIS36QA.js} +1 -1
  112. package/chunks/{chunk-4QIFOIBS.js → chunk-YVZ4XZRB.js} +1 -1
  113. package/chunks/{chunk-KGRD6G5J.js → chunk-Z27JJPKN.js} +1 -1
  114. package/chunks/{chunk-KOHHDB2L.js → chunk-ZCIS6MJZ.js} +1 -1
  115. package/chunks/{chunk-QNNDZYVW.js → chunk-ZHLQ222N.js} +1 -1
  116. package/chunks/{chunk-KWRZ3WJO.js → chunk-ZP7MTWMR.js} +1 -1
  117. package/chunks/{codex-subagent-executor-H44VDB5E.js → codex-subagent-executor-6OJVGF2S.js} +1 -1
  118. package/chunks/{config-utils-4X4SV4RL.js → config-utils-FI3A4QAN.js} +1 -1
  119. package/chunks/{contextCommand-4KVOHTAJ.js → contextCommand-YEBZQHG4.js} +1 -1
  120. package/chunks/{core-runtime-4RARI4NX.js → core-runtime-CFMHUAS7.js} +1 -1
  121. package/chunks/{create-sub-session-CNSRJFYG.js → create-sub-session-G26337FT.js} +1 -1
  122. package/chunks/{daemon-git-worktree-guard-6XQQPP2H.js → daemon-git-worktree-guard-ITU6NQIV.js} +1 -1
  123. package/chunks/{daemon-status-provider-PRTEQT5T.js → daemon-status-provider-CSWRGMRX.js} +1 -1
  124. package/chunks/{daemon-trust-policy-GXKJVZDU.js → daemon-trust-policy-IYD7NOGK.js} +1 -1
  125. package/chunks/{daemon-trust-policy-monitor-L2ORKHMM.js → daemon-trust-policy-monitor-OWUP5SYB.js} +1 -1
  126. package/chunks/{deferred-core-runtime-RZQFUSPX.js → deferred-core-runtime-CVCQU7O4.js} +1 -1
  127. package/chunks/{edit-W44XQCIS.js → edit-7YBQLILC.js} +1 -1
  128. package/chunks/{enterPlanMode-B456A2XO.js → enterPlanMode-L3PVSD2P.js} +1 -1
  129. package/chunks/{environment-DSGQSQFS.js → environment-BVEOYQHO.js} +1 -1
  130. package/chunks/{errors-KL725247.js → errors-VQWBGR6D.js} +1 -1
  131. package/chunks/{execution-tool-KT3EBWHG.js → execution-tool-P7CBXSGZ.js} +1 -1
  132. package/chunks/{execution-worker-LPQ4HMN4.js → execution-worker-RZXNYK4B.js} +1 -1
  133. package/chunks/{exitPlanMode-JLKS76IA.js → exitPlanMode-MBUTM3NW.js} +1 -1
  134. package/chunks/{fast-path-5UD52IHH.js → fast-path-T2FDUSHV.js} +1 -1
  135. package/chunks/{glob-LYA2H6X3.js → glob-RH7XXSYE.js} +1 -1
  136. package/chunks/{goal-tools-SHSIDLZX.js → goal-tools-K6XBCE5E.js} +1 -1
  137. package/chunks/{handleAutoUpdate-T4RE6CZN.js → handleAutoUpdate-PG7R3KPH.js} +1 -1
  138. package/chunks/{i18n-5DK327WA.js → i18n-EGTBMA3N.js} +1 -1
  139. package/chunks/{initializer-TJGE4OJA.js → initializer-RIKH4PCP.js} +1 -1
  140. package/chunks/{installationInfo-MZ62GDIC.js → installationInfo-BBADHZLD.js} +1 -1
  141. package/chunks/{interactive-mod-session-YCUBQ6RM.js → interactive-mod-session-7RDKAHZ4.js} +1 -1
  142. package/chunks/{list-4L3LYDQM.js → list-YEGWEHJX.js} +1 -1
  143. package/chunks/{llm-3JQWBZXV.js → llm-D3LHPY27.js} +4 -4
  144. package/chunks/{llm-content-generator-6UPJWPOM.js → llm-content-generator-BLTBMV66.js} +1 -1
  145. package/chunks/{loadedSettingsAdapter-STPKAFJG.js → loadedSettingsAdapter-PLGMKMFO.js} +1 -1
  146. package/chunks/{local-execution-environment-IE5BOI7Y.js → local-execution-environment-4LDKFNC4.js} +1 -1
  147. package/chunks/{loggingContentGenerator-4KKWPZJA.js → loggingContentGenerator-376R7DRI.js} +1 -1
  148. package/chunks/{manage-memory-CRV5SXZZ.js → manage-memory-2ZTIVKNU.js} +1 -1
  149. package/chunks/{managed-execution-engine-FHLEWVND.js → managed-execution-engine-5LOM3MXG.js} +1 -1
  150. package/chunks/{managed-npm-update-BRHPOKDU.js → managed-npm-update-2C5JYEXW.js} +1 -1
  151. package/chunks/{managed-runtime-attestation-worker-GIQKZ5BH.js → managed-runtime-attestation-worker-R2FECMZK.js} +1 -1
  152. package/chunks/{managed-runtime-bootstrap-P72BT46H.js → managed-runtime-bootstrap-KPLGH4UE.js} +1 -1
  153. package/chunks/{managed-runtime-session-worker-IYCJDB5K.js → managed-runtime-session-worker-EVKNPK3V.js} +1 -1
  154. package/chunks/{managed-runtime-ssh-worker-ONT4V5ZG.js → managed-runtime-ssh-worker-IA4HZ3PD.js} +1 -1
  155. package/chunks/{mcp-NXCQVE2Y.js → mcp-S67IJLI6.js} +1 -1
  156. package/chunks/{model-call-collection-3DNL45M5.js → model-call-collection-6OGPDTPG.js} +1 -1
  157. package/chunks/{model-configuration-6HRNYBWV.js → model-configuration-6RWVBOQS.js} +1 -1
  158. package/chunks/{modelConfigUtils-SKBN64ZW.js → modelConfigUtils-M3TVVYAO.js} +1 -1
  159. package/chunks/{monitor-7I7Q73UR.js → monitor-ZHOFTN7N.js} +1 -1
  160. package/chunks/{nonInteractiveCli-YLYRJUBE.js → nonInteractiveCli-6SUGPTJ4.js} +1 -1
  161. package/chunks/{nonInteractiveToolExecutor-U2ASWT63.js → nonInteractiveToolExecutor-SAHBGO3A.js} +1 -1
  162. package/chunks/{notebook-edit-WAD7IQCF.js → notebook-edit-ETUOQH6G.js} +1 -1
  163. package/chunks/{omni-POUUDVU3.js → omni-HV2UBGMZ.js} +1 -1
  164. package/chunks/{openaiContentGenerator-L7X6IVPL.js → openaiContentGenerator-RZCG7E4M.js} +1 -1
  165. package/chunks/{openaiResponsesContentGenerator-7XCMFI6P.js → openaiResponsesContentGenerator-X23L5JV3.js} +1 -1
  166. package/chunks/{pidfile-MQQT2ZDA.js → pidfile-26WXQCHG.js} +1 -1
  167. package/chunks/{processUtils-OZLF72NC.js → processUtils-WXLFGNBT.js} +1 -1
  168. package/chunks/{prompt-terminal-ledger-IYUF6SUU.js → prompt-terminal-ledger-EIZZHF4A.js} +1 -1
  169. package/chunks/{qwenContentGenerator-DKH3ILUO.js → qwenContentGenerator-GOY7Y6KH.js} +1 -1
  170. package/chunks/{reactive-degrade-KSNGHMBN.js → reactive-degrade-MNMTTHO5.js} +1 -1
  171. package/chunks/{read-file-VEELW4OQ.js → read-file-OJNGPNTQ.js} +1 -1
  172. package/chunks/{resumeHistoryUtils-4SFDTBXU.js → resumeHistoryUtils-QWOWF4VY.js} +1 -1
  173. package/chunks/{review-QA6HRLVU.js → review-5S24HP2V.js} +1 -1
  174. package/chunks/{ripGrep-4J6ASSE3.js → ripGrep-Y4PY2MQF.js} +1 -1
  175. package/chunks/{run-qwen-serve-EJ67LA5O.js → run-qwen-serve-EOUUDZUK.js} +2 -2
  176. package/chunks/{runtime-6E2FSB5U.js → runtime-ZBPOQX6E.js} +1 -1
  177. package/chunks/{sandboxConfig-4VE4LNRI.js → sandboxConfig-R7KDS3P5.js} +1 -1
  178. package/chunks/{scheduled-tasks-GM5EJMK7.js → scheduled-tasks-Q6V7D6K6.js} +1 -1
  179. package/chunks/{scheduler-HOSVIIOE.js → scheduler-EBQY6BOK.js} +1 -1
  180. package/chunks/{search-memory-HEAQCHIK.js → search-memory-HX6E23JC.js} +1 -1
  181. package/chunks/{send-message-FAQ7XEZ5.js → send-message-OZCCCH2F.js} +1 -1
  182. package/chunks/{serve-VNKPOWSW.js → serve-CMGCI4BK.js} +1 -1
  183. package/chunks/{server-U2XBJLOV.js → server-7LOAKPDN.js} +3 -3
  184. package/chunks/{session-AZGROSFX.js → session-LVQYZSJE.js} +1 -1
  185. package/chunks/{session-attachments-root-6M2ECUNK.js → session-attachments-root-NWG7JOMN.js} +1 -1
  186. package/chunks/{session-execution-engine-selector-PYDVOSJF.js → session-execution-engine-selector-PHH47ZMA.js} +1 -1
  187. package/chunks/{session-pr-refresh-3IS7DLEV.js → session-pr-refresh-5IACZPCY.js} +1 -1
  188. package/chunks/{sessionService-3FWNA4ZB.js → sessionService-7PFAWLHC.js} +1 -1
  189. package/chunks/{settings-VHKT7JJC.js → settings-CPZBOHN5.js} +1 -1
  190. package/chunks/{shell-TYOPVB7H.js → shell-A7NLPS2W.js} +1 -1
  191. package/chunks/{skill-GJQIE5AX.js → skill-VGANGVOD.js} +1 -1
  192. package/chunks/{skill-settings-76NI6SF3.js → skill-settings-TSZO3X6N.js} +1 -1
  193. package/chunks/{spawnChannel-FMSYLDKB.js → spawnChannel-2JQYNQKT.js} +1 -1
  194. package/chunks/{standalone-update-BPZQDQHD.js → standalone-update-QXC3RM6I.js} +1 -1
  195. package/chunks/{start-opentui-ui-X7XYV5N3.js → start-opentui-ui-BKJ4JHVK.js} +1 -1
  196. package/chunks/{startInteractiveUI-UZDF4JUB.js → startInteractiveUI-4QIPR7ZY.js} +1 -1
  197. package/chunks/{team-create-RFZNEF76.js → team-create-5MU6BGXX.js} +1 -1
  198. package/chunks/{team-plan-approval-MGW3JGSC.js → team-plan-approval-NZUJ6FSA.js} +1 -1
  199. package/chunks/{terminal-image-renderer-3UED5GZV.js → terminal-image-renderer-CTMJULJ2.js} +1 -1
  200. package/chunks/{theme-manager-SF6FSSZW.js → theme-manager-6H7GA6QR.js} +1 -1
  201. package/chunks/{tool-call-W2CJR74U.js → tool-call-XG4CAD5X.js} +1 -1
  202. package/chunks/{tool-result-media-XSFON2ZQ.js → tool-result-media-RJ5ONO7R.js} +1 -1
  203. package/chunks/{tool-search-7GY5YTOU.js → tool-search-KBINGEWV.js} +1 -1
  204. package/chunks/{total-session-admission-OATGW6M5.js → total-session-admission-XNWYCO7G.js} +1 -1
  205. package/chunks/{trustedFolders-AM4PSGUB.js → trustedFolders-JT5MOB3A.js} +1 -1
  206. package/chunks/{update-relaunch-YKY52XUT.js → update-relaunch-HXMQI3HO.js} +1 -1
  207. package/chunks/{updateCheck-RKQ5CPZM.js → updateCheck-XWE3TWL5.js} +1 -1
  208. package/chunks/{upload-config-CBT7ARZY.js → upload-config-ET7NRHU7.js} +1 -1
  209. package/chunks/{useAutoAcceptIndicator-Z3YWPUNO.js → useAutoAcceptIndicator-TPMYKNJX.js} +1 -1
  210. package/chunks/{validateNonInterActiveAuth-7CQHU2RF.js → validateNonInterActiveAuth-U52KMEDS.js} +1 -1
  211. package/chunks/{version-N2OB6KWP.js → version-CW4RTJ3H.js} +1 -1
  212. package/chunks/{web-fetch-L5XCBCBA.js → web-fetch-UPMJ3XIZ.js} +1 -1
  213. package/chunks/{web-search-4EHUA3LJ.js → web-search-PXABWQVC.js} +1 -1
  214. package/chunks/{workflow-FGAUAYIP.js → workflow-UQ4V3NBZ.js} +1 -1
  215. package/chunks/{workflow-ancestor-trust-F7RRN6I3.js → workflow-ancestor-trust-QII5KTUJ.js} +1 -1
  216. package/chunks/{workspace-agents-QW4TKC52.js → workspace-agents-Q3KKMDX2.js} +1 -1
  217. package/chunks/{workspace-providers-status-MFSZT3YA.js → workspace-providers-status-3ASB64FB.js} +1 -1
  218. package/chunks/{workspace-registration-store-WQRDSIEI.js → workspace-registration-store-2NPD6U3B.js} +1 -1
  219. package/chunks/{workspace-registry-FXZFRSCH.js → workspace-registry-6QJKRCDR.js} +1 -1
  220. package/chunks/{workspace-runtime-coordinator-LJ5YAT3A.js → workspace-runtime-coordinator-ZXUWDQIB.js} +1 -1
  221. package/chunks/{workspace-service-U632SUWU.js → workspace-service-YPYTYYUN.js} +1 -1
  222. package/chunks/{workspace-skills-status-M7YXM3LF.js → workspace-skills-status-VTFHQ6R7.js} +1 -1
  223. package/chunks/{workspace-trust-reconciler-NLJGGI4K.js → workspace-trust-reconciler-52CZVPKH.js} +1 -1
  224. package/chunks/{write-file-BJCKSXX7.js → write-file-FDBR76G5.js} +1 -1
  225. package/chunks/{zoom-image-TLJPD4DB.js → zoom-image-MYKWCCXO.js} +1 -1
  226. package/cli.js +2 -2
  227. package/execution-worker.js +1 -1
  228. package/export-transcript-document.js +1 -1
  229. package/package.json +4 -4
  230. package/vendor/landlock-run/arm64-linux/qwen-landlock-run +0 -0
  231. package/vendor/landlock-run/x64-linux/qwen-landlock-run +0 -0
  232. package/vendor/ripgrep/arm64-darwin/rg +0 -0
  233. package/vendor/ripgrep/arm64-linux/rg +0 -0
  234. package/vendor/ripgrep/x64-darwin/rg +0 -0
  235. package/vendor/ripgrep/x64-linux/rg +0 -0
  236. package/vendor/tree-sitter/tree-sitter-bash.wasm +0 -0
  237. package/vendor/tree-sitter/tree-sitter.wasm +0 -0
  238. package/web-shell/assets/{PierreFilePreview-D9tbdFw8.js → PierreFilePreview-DGTp45Z4.js} +1 -1
  239. package/web-shell/assets/{SpreadsheetPreview-CeFAk2s-.js → SpreadsheetPreview-DVC_YVei.js} +1 -1
  240. package/web-shell/assets/{WorkspaceFileBrowser-iaURw8SR.js → WorkspaceFileBrowser-DaQNpS06.js} +1 -1
  241. package/web-shell/assets/{abnfDiagram-VCTEODGH-Z4CT1NCF.js → abnfDiagram-VCTEODGH-wJbiOoPK.js} +1 -1
  242. package/web-shell/assets/{agents-route-B7o2Rq-a.js → agents-route-DUhhA1KI.js} +1 -1
  243. package/web-shell/assets/{arc-DcHBdUJQ.js → arc-CvpNMy1d.js} +1 -1
  244. package/web-shell/assets/{architectureDiagram-5GKGNRK7-DRDhEC81.js → architectureDiagram-5GKGNRK7-DIhi3dIz.js} +1 -1
  245. package/web-shell/assets/{blockDiagram-NRAW4CY4-CYRE6WIc.js → blockDiagram-NRAW4CY4-CoeyTlVJ.js} +1 -1
  246. package/web-shell/assets/{c4Diagram-UCG6FXSJ-CIM8N_Sj.js → c4Diagram-UCG6FXSJ-BYoK_I9M.js} +1 -1
  247. package/web-shell/assets/channel-DvtGOCg6.js +1 -0
  248. package/web-shell/assets/{chunk-2Q5K7J3B-Bbfka9Fe.js → chunk-2Q5K7J3B-BeD4GwPg.js} +1 -1
  249. package/web-shell/assets/{chunk-5VM5RSS4-C02zF3RY.js → chunk-5VM5RSS4-BpkJsB_y.js} +1 -1
  250. package/web-shell/assets/{chunk-F27PBJKO-Dn0wRD2F.js → chunk-F27PBJKO-BROEWQ1J.js} +1 -1
  251. package/web-shell/assets/{chunk-G27WJ6UU-Dwpl3l0W.js → chunk-G27WJ6UU-DA8Wtppt.js} +1 -1
  252. package/web-shell/assets/{chunk-JWPE2WC7-sQbzSoTR.js → chunk-JWPE2WC7-GqB-QFh5.js} +1 -1
  253. package/web-shell/assets/{chunk-LCL6LL3I-DNlNDtfr.js → chunk-LCL6LL3I-DIPUwYsX.js} +1 -1
  254. package/web-shell/assets/{chunk-POPQ4Y6H-BOgf1Dl3.js → chunk-POPQ4Y6H-DbnU-jxX.js} +1 -1
  255. package/web-shell/assets/{chunk-SVP7TREG-DOofWP00.js → chunk-SVP7TREG-DvH7bQ-w.js} +1 -1
  256. package/web-shell/assets/{chunk-XXDRQBXY-Bj9FxhWU.js → chunk-XXDRQBXY-DdVWVo3U.js} +1 -1
  257. package/web-shell/assets/classDiagram-DTDB5LWJ-9NR5W1rE.js +1 -0
  258. package/web-shell/assets/classDiagram-v2-JRS7N3AN-9NR5W1rE.js +1 -0
  259. package/web-shell/assets/{cose-bilkent-JH36ORCC-CUlPjyww.js → cose-bilkent-JH36ORCC-JgMKxP9H.js} +1 -1
  260. package/web-shell/assets/{cynefin-OW5HDTMX-5noArzI7.js → cynefin-OW5HDTMX-BVUpNgVm.js} +1 -1
  261. package/web-shell/assets/{cynefinDiagram-5FMLGOSQ-DELvTqmf.js → cynefinDiagram-5FMLGOSQ-CxAdk-iS.js} +1 -1
  262. package/web-shell/assets/{dagre-3AP2YEHR-CAL6Z3hL.js → dagre-3AP2YEHR-CvXWkM86.js} +1 -1
  263. package/web-shell/assets/{diagram-S7CK7UJ4-DQC2gaIi.js → diagram-S7CK7UJ4-DD_PS4nm.js} +1 -1
  264. package/web-shell/assets/{diagram-UQ7AKVKN-CkU6M-3R.js → diagram-UQ7AKVKN-EVZkTODD.js} +1 -1
  265. package/web-shell/assets/{diagram-VSXAHHWV-CvHpHwVx.js → diagram-VSXAHHWV-CGZc1pZU.js} +1 -1
  266. package/web-shell/assets/{diagram-VX7I27RA-D9l5F9iB.js → diagram-VX7I27RA-DjNql499.js} +1 -1
  267. package/web-shell/assets/{diagram-Z3DM3KII-DW-VFvYx.js → diagram-Z3DM3KII-CCa0WtmR.js} +1 -1
  268. package/web-shell/assets/{docx-preview-8MQfOGQh.js → docx-preview-DpVElxvj.js} +1 -1
  269. package/web-shell/assets/{ebnfDiagram-PWID7BFC-C0Q71wC_.js → ebnfDiagram-PWID7BFC-W2hoOJZF.js} +1 -1
  270. package/web-shell/assets/{erDiagram-SSCWMZ5O-DWDLRh1S.js → erDiagram-SSCWMZ5O-Dz5NxxEb.js} +1 -1
  271. package/web-shell/assets/{flowDiagram-A5DVABFB-CVzJnl1P.js → flowDiagram-A5DVABFB-BTMAn8b5.js} +1 -1
  272. package/web-shell/assets/{ganttDiagram-EL5Y4UJY-B320pcgR.js → ganttDiagram-EL5Y4UJY-BaFrd5ZY.js} +1 -1
  273. package/web-shell/assets/{gitGraphDiagram-WWUBYQGX-Di4uZh-J.js → gitGraphDiagram-WWUBYQGX-IlmdUqRk.js} +1 -1
  274. package/web-shell/assets/{index-Csr8Hx_O.js → index-C2ez0ZjE.js} +1 -1
  275. package/web-shell/assets/{index-C9BecA_H.js → index-Cs-XBNmB.js} +101 -101
  276. package/web-shell/assets/{infoDiagram-RXCK75RN-CbafhxET.js → infoDiagram-RXCK75RN-BHs9kpar.js} +1 -1
  277. package/web-shell/assets/{ishikawaDiagram-5VMMS53U-DrQuIDeR.js → ishikawaDiagram-5VMMS53U-DWCEQ85v.js} +1 -1
  278. package/web-shell/assets/{journeyDiagram-EYS64GPL-BschmjBj.js → journeyDiagram-EYS64GPL-RTDAw9yc.js} +1 -1
  279. package/web-shell/assets/{kanban-definition-3QL26DDD-B7x9BU9N.js → kanban-definition-3QL26DDD-B7Nl9bq6.js} +1 -1
  280. package/web-shell/assets/{layout-BewPaOyO.js → layout-BabjFEb1.js} +1 -1
  281. package/web-shell/assets/{linear-CnLILCVp.js → linear-CZuGjuQd.js} +1 -1
  282. package/web-shell/assets/{mermaid.core-Csj9KPfJ.js → mermaid.core-CK78bIGt.js} +6 -6
  283. package/web-shell/assets/{mindmap-definition-FBJOCRG2-CIGTi5gg.js → mindmap-definition-FBJOCRG2-BbcCi_jP.js} +1 -1
  284. package/web-shell/assets/{pegDiagram-XKGWAZYB-CuWBRQzb.js → pegDiagram-XKGWAZYB-DpLQ7u8i.js} +1 -1
  285. package/web-shell/assets/{pieDiagram-E7YTZNPT-Co5ukXCE.js → pieDiagram-E7YTZNPT-BpWFVtM0.js} +1 -1
  286. package/web-shell/assets/{quadrantDiagram-AXDQQJYC-B0hzjh6o.js → quadrantDiagram-AXDQQJYC-CGzYlaN1.js} +1 -1
  287. package/web-shell/assets/{railroadDiagram-O6MQD6OU-nhkJB0xD.js → railroadDiagram-O6MQD6OU-BNQYW-Zi.js} +1 -1
  288. package/web-shell/assets/{requirementDiagram-EFPCY7ZU-C7NpxjVR.js → requirementDiagram-EFPCY7ZU-C4fCdIDW.js} +1 -1
  289. package/web-shell/assets/{sankeyDiagram-P5KCCOFB-CUWlnhZC.js → sankeyDiagram-P5KCCOFB-BvbbAnMA.js} +1 -1
  290. package/web-shell/assets/{sequenceDiagram-WJ2MYXX4-BoykH0_J.js → sequenceDiagram-WJ2MYXX4-DGXNc6E1.js} +1 -1
  291. package/web-shell/assets/{sizeCapture-X5ZJPWSS-aF-PkSe5.js → sizeCapture-X5ZJPWSS-C4W45Xf5.js} +1 -1
  292. package/web-shell/assets/{stateDiagram-HBIQ2CUA-g5q0b922.js → stateDiagram-HBIQ2CUA-D3q0fen-.js} +1 -1
  293. package/web-shell/assets/stateDiagram-v2-4QOOHH4V-XKoYIi05.js +1 -0
  294. package/web-shell/assets/{swimlanes-XN3QIQJK-BbASszfe.js → swimlanes-XN3QIQJK-D8n-ResR.js} +1 -1
  295. package/web-shell/assets/swimlanesDiagram-VK2B7HYN-C7qJMSzs.js +8 -0
  296. package/web-shell/assets/{timeline-definition-24CTP7MA-AXIV0TJJ.js → timeline-definition-24CTP7MA-Cio4y1mM.js} +1 -1
  297. package/web-shell/assets/{vennDiagram-4TSXK5OY-B-E0rj1h.js → vennDiagram-4TSXK5OY-DVlg0xnc.js} +1 -1
  298. package/web-shell/assets/{wardleyDiagram-VM6X3IG4-DiOOYJ2D.js → wardleyDiagram-VM6X3IG4-CgeIsimQ.js} +1 -1
  299. package/web-shell/assets/{xychartDiagram-S5SC5T6Z-De_z7HkS.js → xychartDiagram-S5SC5T6Z-UXjyTLnU.js} +1 -1
  300. package/web-shell/index.html +1 -1
  301. package/web-shell/sw.js +1 -1
  302. package/web-shell/assets/channel-Bwr9aS_E.js +0 -1
  303. package/web-shell/assets/classDiagram-DTDB5LWJ-BmY8Mmyo.js +0 -1
  304. package/web-shell/assets/classDiagram-v2-JRS7N3AN-BmY8Mmyo.js +0 -1
  305. package/web-shell/assets/stateDiagram-v2-4QOOHH4V-CTOjUMow.js +0 -1
  306. package/web-shell/assets/swimlanesDiagram-VK2B7HYN-Bz6ia3oL.js +0 -8
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{SessionService,TURN_INTERRUPTION_HISTORY_TAIL_COUNT,buildSessionHistoryFromConversation,detectTurnInterruption,effectiveHistoryEnd}from"./chunk-RKPHDO42.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import{__name}from"./chunk-KBWJGX7I.js";init_esbuild_shims();import{closeSync as closeSync2,openSync as openSync2,readSync as readSync2,statSync as statSync2}from"node:fs";init_esbuild_shims();import{appendFileSync,closeSync,mkdirSync,openSync,readFileSync,readSync,statSync}from"node:fs";import*as path from"node:path";function isPromptLedgerTerminalRecord(record){return"terminal"in record}__name(isPromptLedgerTerminalRecord,"isPromptLedgerTerminalRecord");function appendPromptLedgerRecord(filePath,record){mkdirSync(path.dirname(filePath),{recursive:true});sealTornTailSync(filePath);appendFileSync(filePath,`${JSON.stringify(record)}
3
+ import{SessionService,TURN_INTERRUPTION_HISTORY_TAIL_COUNT,buildSessionHistoryFromConversation,detectTurnInterruption,effectiveHistoryEnd}from"./chunk-LDXZT3SG.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import{__name}from"./chunk-KBWJGX7I.js";init_esbuild_shims();import{closeSync as closeSync2,openSync as openSync2,readSync as readSync2,statSync as statSync2}from"node:fs";init_esbuild_shims();import{appendFileSync,closeSync,mkdirSync,openSync,readFileSync,readSync,statSync}from"node:fs";import*as path from"node:path";function isPromptLedgerTerminalRecord(record){return"terminal"in record}__name(isPromptLedgerTerminalRecord,"isPromptLedgerTerminalRecord");function appendPromptLedgerRecord(filePath,record){mkdirSync(path.dirname(filePath),{recursive:true});sealTornTailSync(filePath);appendFileSync(filePath,`${JSON.stringify(record)}
4
4
  `,{encoding:"utf8",mode:384})}__name(appendPromptLedgerRecord,"appendPromptLedgerRecord");function sealTornTailSync(filePath){let stats;try{stats=statSync(filePath)}catch(error){if(error.code==="ENOENT")return;throw error}if(stats.size===0)return;const fd=openSync(filePath,"r");try{const lastByte=Buffer.alloc(1);const bytesRead=readSync(fd,lastByte,0,1,stats.size-1);if(bytesRead===1&&lastByte[0]!==10){appendFileSync(filePath,"\n","utf8")}}finally{closeSync(fd)}}__name(sealTornTailSync,"sealTornTailSync");function coercePromptLedgerRecord(value){if(typeof value!=="object"||value===null)return void 0;const record=value;const promptId=record["promptId"];const at=record["at"];if(record["v"]!==1||typeof promptId!=="string")return void 0;if(typeof at!=="number"||!Number.isFinite(at))return void 0;if(record["state"]==="in_flight"){const tailUuid=record["tailUuid"];return{v:1,promptId,state:"in_flight",...typeof tailUuid==="string"&&tailUuid.length>0?{tailUuid}:{},at}}const terminal=record["terminal"];if(terminal!=="completed"&&terminal!=="cancelled"&&terminal!=="error"&&terminal!=="interrupted"){return void 0}const code=record["code"];const stopReason=record["stopReason"];return{v:1,promptId,terminal,...typeof code==="string"?{code}:{},...typeof stopReason==="string"?{stopReason}:{},at}}__name(coercePromptLedgerRecord,"coercePromptLedgerRecord");function readPromptLedgerRecords(filePath,options){let contents;let dropFirstLine=false;try{const tailBytes=options?.tailBytes;if(tailBytes===void 0){contents=readFileSync(filePath,"utf8")}else{const size=statSync(filePath).size;if(size<=tailBytes){contents=readFileSync(filePath,"utf8")}else{const fd=openSync(filePath,"r");try{const buffer=Buffer.alloc(tailBytes);const bytesRead=readSync(fd,buffer,0,tailBytes,size-tailBytes);contents=buffer.subarray(0,bytesRead).toString("utf8");dropFirstLine=true}finally{closeSync(fd)}}}}catch(error){if(error.code==="ENOENT")return[];throw error}const records=[];const lines=contents.split("\n");for(let i=dropFirstLine?1:0;i<lines.length;i++){const line=lines[i];if(line===void 0||line.length===0)continue;let parsed;try{parsed=JSON.parse(line)}catch{continue}const record=coercePromptLedgerRecord(parsed);if(record!==void 0)records.push(record)}return records}__name(readPromptLedgerRecords,"readPromptLedgerRecords");function danglingInFlightPromptIds(records){const latest=new Map;for(const record of records){latest.set(record.promptId,record)}const dangling=[];for(const[promptId,record]of latest){if(!isPromptLedgerTerminalRecord(record))dangling.push(promptId)}return dangling}__name(danglingInFlightPromptIds,"danglingInFlightPromptIds");var PROMPT_TERMINALS_RESPONSE_LIMIT=64;function recentPromptTerminalRecords(records){const terminals=records.filter(isPromptLedgerTerminalRecord);return terminals.length<=PROMPT_TERMINALS_RESPONSE_LIMIT?terminals:terminals.slice(-PROMPT_TERMINALS_RESPONSE_LIMIT)}__name(recentPromptTerminalRecords,"recentPromptTerminalRecords");function createPromptLedgerSink(workspaceCwd,sessionRuntimeBaseDir){const sessionService=new SessionService(workspaceCwd,{runtimeBaseDir:sessionRuntimeBaseDir});return{appendSync(sessionId,record){appendPromptLedgerRecord(sessionService.getPromptLedgerPath(sessionId),record)},transcriptTailUuid(sessionId){return readTranscriptTailUuid(sessionService.getSessionTranscriptPath(sessionId))}}}__name(createPromptLedgerSink,"createPromptLedgerSink");var TRANSCRIPT_TAIL_BYTES=64*1024;function readTranscriptTailUuid(transcriptPath){let contents;try{const size=statSync2(transcriptPath).size;if(size===0)return void 0;const windowBytes=Math.min(size,TRANSCRIPT_TAIL_BYTES);const buffer=Buffer.alloc(windowBytes);const fd=openSync2(transcriptPath,"r");try{readSync2(fd,buffer,0,windowBytes,size-windowBytes)}finally{closeSync2(fd)}contents=buffer.toString("utf8")}catch{return void 0}const lines=contents.split("\n");for(let i=lines.length-1;i>=0;i--){const line=lines[i];if(line===void 0||line.length===0)continue;try{const uuid=JSON.parse(line).uuid;return typeof uuid==="string"&&uuid.length>0?uuid:void 0}catch{return void 0}}return void 0}__name(readTranscriptTailUuid,"readTranscriptTailUuid");async function reconcileDanglingPromptTerminals(sessionService,sessionId){const ledgerPath=sessionService.getPromptLedgerPath(sessionId);let records;try{records=readPromptLedgerRecords(ledgerPath)}catch{return}const snapshotLength=records.length;const dangling=danglingInFlightPromptIds(records);if(dangling.length===0)return;if(dangling.length>1)return;const target=dangling[0];if(target===void 0)return;const settledPromptIds=new Set(records.filter(isPromptLedgerTerminalRecord).map(r=>r.promptId));let targetAdmission;for(const record2 of records){if(!isPromptLedgerTerminalRecord(record2)&&!settledPromptIds.has(record2.promptId)){targetAdmission=record2}}if(targetAdmission===void 0||targetAdmission.promptId!==target){return}let resumed;try{resumed=await sessionService.loadSession(sessionId)}catch{return}if(resumed===void 0)return;const messages=resumed.conversation.messages;const admissionMarker=targetAdmission.tailUuid;let markerIndex=-1;if(admissionMarker!==void 0){markerIndex=messages.findIndex(record2=>record2.uuid===admissionMarker);let wroteAfterMarker=false;for(let i=markerIndex+1;i<messages.length;i++){const record2=messages[i];if(record2===void 0||record2.type==="system")continue;if(!record2.message||record2.subtype==="realtime_message")continue;wroteAfterMarker=true;break}if(markerIndex<0||!wroteAfterMarker)return}let lastVisibleWriteMs=NaN;let lastVisibleNonSystem;let compressedAfterAdmission=false;let localCommandCompleted=false;const admissionAt=targetAdmission.at;const isAfterAdmission=__name((idx,writeMs)=>admissionMarker!==void 0?idx>markerIndex:Number.isFinite(writeMs)&&writeMs>=admissionAt,"isAfterAdmission");for(let idx=0;idx<messages.length;idx++){const record2=messages[idx];const writeMs=Date.parse(record2.timestamp);if(record2.type==="system"){if(isCompressionResetRecord(record2)){if(isAfterAdmission(idx,writeMs))compressedAfterAdmission=true}else if(!localCommandCompleted&&isAfterAdmission(idx,writeMs)&&isLocalSlashCommandResult(record2,lastVisibleNonSystem)){localCommandCompleted=true}continue}if(!record2.message||record2.subtype==="realtime_message")continue;if(record2.provenance==="system")continue;if(record2.subtype==="agent_mention"||record2.subtype==="agent_message"){continue}if(Number.isFinite(writeMs))lastVisibleWriteMs=writeMs;lastVisibleNonSystem=record2}let lastOtherTerminalAt=0;for(const record2 of records){if(isPromptLedgerTerminalRecord(record2)&&record2.promptId!==target){if(record2.code==="prompt_deadline_exceeded")return;lastOtherTerminalAt=Math.max(lastOtherTerminalAt,record2.at)}}if(compressedAfterAdmission||!Number.isFinite(lastVisibleWriteMs)||lastVisibleWriteMs<=targetAdmission.at||lastVisibleWriteMs<=lastOtherTerminalAt){return}const{apiHistory,completedToolCallIds}=buildSessionHistoryFromConversation(resumed.conversation);const classifiableEnd=effectiveHistoryEnd(apiHistory);const historyTail=apiHistory.slice(Math.max(0,classifiableEnd-TURN_INTERRUPTION_HISTORY_TAIL_COUNT),classifiableEnd);const verdict=detectTurnInterruption(historyTail,completedToolCallIds);const interrupted=verdict.kind!=="none"||tailHoldsAnyFunctionCall(historyTail);const lastVisibleNonSystemType=lastVisibleNonSystem?.type;if(!interrupted&&lastVisibleNonSystemType!=="assistant"&&lastVisibleNonSystemType!=="tool_result"&&!localCommandCompleted){return}let refetch;try{refetch=readPromptLedgerRecords(ledgerPath)}catch{return}if(refetch.length!==snapshotLength)return;const record=interrupted?{v:1,promptId:target,terminal:"interrupted",code:"daemon_lost",at:Date.now()}:{v:1,promptId:target,terminal:"completed",stopReason:"reconstructed_from_transcript",at:Date.now()};try{appendPromptLedgerRecord(ledgerPath,record)}catch{}}__name(reconcileDanglingPromptTerminals,"reconcileDanglingPromptTerminals");function isCompressionResetRecord(record){if(record.type!=="system"||record.subtype!=="chat_compression"){return false}return Boolean(record.systemPayload?.compressedHistory)}__name(isCompressionResetRecord,"isCompressionResetRecord");function isLocalSlashCommandResult(record,previous){if(record.subtype!=="slash_command")return false;const payload=record.systemPayload;const items=payload?.outputHistoryItems;const parts=previous?.message?.parts;const first=parts?.[0];return payload?.phase==="result"&&payload.sentToModel!==true&&Array.isArray(items)&&items.length>0&&items.every(item=>item["type"]==="assistant")&&previous?.type==="user"&&previous.subtype===void 0&&previous.message?.role==="user"&&parts?.length===1&&first!==void 0&&typeof first.text==="string"&&Object.keys(first).length===1&&first.text===payload.rawCommand}__name(isLocalSlashCommandResult,"isLocalSlashCommandResult");function tailHoldsAnyFunctionCall(history){const last=history[history.length-1];if(last?.role!=="model")return false;return(last.parts??[]).some(part=>part.functionCall!==void 0)}__name(tailHoldsAnyFunctionCall,"tailHoldsAnyFunctionCall");var RECENT_TERMINALS_TAIL_BYTES=256*1024;function readRecentPromptTerminals(sessionService,sessionId){try{const terminals=recentPromptTerminalRecords(readPromptLedgerRecords(sessionService.getPromptLedgerPath(sessionId),{tailBytes:RECENT_TERMINALS_TAIL_BYTES}));return terminals.length>0?terminals:void 0}catch{return void 0}}__name(readRecentPromptTerminals,"readRecentPromptTerminals");function withPromptTerminals(session,terminals){if(terminals===void 0||terminals.length===0)return session;return{...session,promptTerminals:[...terminals]}}__name(withPromptTerminals,"withPromptTerminals");export{createPromptLedgerSink,readTranscriptTailUuid,reconcileDanglingPromptTerminals,readRecentPromptTerminals,withPromptTerminals};
5
5
  /**
6
6
  * @license
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{DropNoticeThrottle,DropReceiptCoalescer,getPeerControllerRegistryPath,readPeerControllerRegistrySync,resolveControllerToken,startPeerInbox}from"./chunk-BOFD4CN3.js";import{InboundGate,MAX_HELD_MESSAGES,PEER_ADMISSION_LIMITS,canonicalizeMsgId,drainSendPacer,forgetSendPacerMessages,peerSenderKey,refundSendPacerMessage,refundSendPacerToken,sendDeliveryStatus,settleSentPeerMessage}from"./chunk-MKH3EH7O.js";import{formatPeerDisplay,formatPeerEnvelope}from"./chunk-BYU42MLK.js";import{MESSAGING_SOCKET_ENV,MESSAGING_TOKEN_ENV,clearInheritedPeerMessagingEnv}from"./chunk-NPAX2UFU.js";import{createDebugLogger}from"./chunk-JAUJI56S.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import{__name}from"./chunk-KBWJGX7I.js";init_esbuild_shims();import{randomBytes}from"node:crypto";var debugLogger=createDebugLogger("PEER_MESSAGING");var MAX_ACCEPTED_BACKLOG=MAX_HELD_MESSAGES;var CLOSE_DROP_FLUSH_BOUND_MS=1e3;var MAX_UNHEARD_DROP_NOTICES=20;var RECEIVER_REFILL_MS=PEER_ADMISSION_LIMITS.bucketCapacity/PEER_ADMISSION_LIMITS.refillPerSecond*1e3;var PeerMessaging=class _PeerMessaging{static{__name(this,"PeerMessaging")}inbox=null;gate=null;updateSessionRegistryIpcPath=__name(async()=>{},"updateSessionRegistryIpcPath");getSessionId=null;ownsSessionId=null;settleSentMessage=settleSentPeerMessage;reassertSessionRecord=null;drainMirror=drainSendPacer;forgetMirror=forgetSendPacerMessages;refundMirror=refundSendPacerMessage;refundMirrorToken=refundSendPacerToken;receiptListeners=new Set;dropListeners=new Set;unheardDrops=[];dropReceipts=null;submitFn=null;buffered=[];controllerRegistryPath=null;validControllerIds=null;outstanding=[];queuedPeerCount=null;heldListeners=new Set;listedHeld=null;closed=false;constructor(){}static async start(options){if(options.getSessionId&&options.ownsSessionId){throw new Error("PeerMessaging: pass getSessionId or ownsSessionId, not both")}const messaging=new _PeerMessaging;const controllerRegistryPath=options.controllerRegistryPath??getPeerControllerRegistryPath();messaging.controllerRegistryPath=controllerRegistryPath;const dropReceipts=new DropReceiptCoalescer(({frame,reason,droppedMsgIds})=>{if(!frame.from)return;return sendDeliveryStatus(frame.from,{status:"dropped",origMsgId:frame.msgId,from:messaging.inbox?.socketPath,dropReason:reason,droppedMsgIds},frame.replyToken)},options.dropReceiptTrailMs!==void 0?{trailMs:options.dropReceiptTrailMs}:{});messaging.dropReceipts=dropReceipts;const dropNotices=new DropNoticeThrottle(notice=>messaging.emitDropped(notice));const gate=new InboundGate({getApprovalMode:options.getApprovalMode,getPolicySetting:options.getPolicySetting,...options.getHeldExpiryMs!==void 0?{getHeldExpiryMs:options.getHeldExpiryMs}:{},...options.getPolicyScope?{getPolicyScope:options.getPolicyScope}:{},isControllerValid:__name(id=>messaging.validControllerIds?.has(id)??true,"isControllerValid"),...options.admission?{admission:options.admission}:{},getSessionId:options.getSessionId,...options.ownsSessionId?{ownsSessionId:options.ownsSessionId}:{},deliver:__name((frame,origin)=>messaging.deliver(frame,origin),"deliver"),reportDropped:__name((frame,reason,origin)=>dropReceipts.note(frame,origin??{selfSent:false},reason),"reportDropped"),onDropped:__name((frame,origin,reason)=>dropNotices.note(frame,origin,reason),"onDropped"),reportStatus:__name((frame,status)=>{if(!frame.from)return;return sendDeliveryStatus(frame.from,{status,origMsgId:frame.msgId,from:messaging.inbox?.socketPath},frame.replyToken)},"reportStatus"),onHeldChange:__name(held=>messaging.emitHeldChange(held),"onHeldChange")});messaging.gate=gate;messaging.getSessionId=options.getSessionId??null;messaging.ownsSessionId=options.ownsSessionId??null;messaging.settleSentMessage=options.settleSentMessage??settleSentPeerMessage;messaging.reassertSessionRecord=options.reassertSessionRecord??null;messaging.drainMirror=options.drainMirror??drainSendPacer;messaging.forgetMirror=options.forgetMirror??forgetSendPacerMessages;messaging.refundMirror=options.refundMirror??refundSendPacerMessage;messaging.refundMirrorToken=options.refundMirrorToken??refundSendPacerToken;clearInheritedPeerMessagingEnv();const ipcToken=options.ipcToken??randomBytes(32).toString("hex");const childToken=options.childToken??randomBytes(32).toString("hex");const inbox=await startPeerInbox({...options.socketPath!==void 0?{socketPath:options.socketPath}:{},requiredToken:ipcToken,childToken,resolveController:__name(presented=>resolveControllerToken(presented,controllerRegistryPath),"resolveController"),onFrame:__name((frame,auth,controller)=>messaging.onFrame(frame,{selfSent:auth==="child",...controller?{controller}:{}}),"onFrame")});if(!inbox)return null;messaging.inbox=inbox;messaging.updateSessionRegistryIpcPath=options.updateSessionRegistryIpcPath;await messaging.updateSessionRegistryIpcPath(inbox.socketPath,ipcToken);process.env[MESSAGING_SOCKET_ENV]=inbox.socketPath;process.env[MESSAGING_TOKEN_ENV]=childToken;return messaging}get socketPath(){return this.inbox?.socketPath}setSubmitFn(fn){if(this.closed)return;this.withControllerValidity(()=>{this.submitFn=fn;while(this.buffered.length>0){const head=this.buffered[0];if(!head||!this.submit(head.frame,head.origin))break;this.buffered.shift()}})}setQueuedPeerCount(fn){this.queuedPeerCount=fn}getHeld(){return this.withControllerValidity(()=>this.gate?.getHeld()??[])}getHeldExpiryMs(sessionId){return this.gate?.getHeldExpiryMs(sessionId)??null}recordHeldListing(heldEntries){this.listedHeld=heldEntries.map(entry=>({id:entry.frame.msgId,heldAt:entry.heldAt}))}heldSetChangedSinceListing(){const listed=this.listedHeld;if(listed===null)return true;const pinned=new Map(listed.map(entry=>[entry.id,entry.heldAt]));const current=this.getHeld();if(current.some(entry=>pinned.get(entry.frame.msgId)!==entry.heldAt))return true;const liveIds=current.map(entry=>canonicalizeMsgId(entry.frame.msgId));const liveSet=new Set(liveIds);for(const id of pinned.keys()){const departed=canonicalizeMsgId(id);if(liveSet.has(departed))continue;if(liveIds.some(live=>live.startsWith(departed)))return true}return false}decide(msgId,decision){return this.withControllerValidity(()=>this.gate?.decide(msgId,decision)??"gone")}forgetController(id){return this.withControllerValidity(()=>this.gate?.forgetController(id)??0)}reevaluate(reason){return this.withControllerValidity(()=>this.gate?.reevaluate(reason)??0)}onHeldChange(listener){this.heldListeners.add(listener);try{listener(this.getHeld())}catch(error){debugLogger.debug(`held-change listener threw: ${error instanceof Error?error.message:String(error)}`)}return()=>this.heldListeners.delete(listener)}onReceipt(listener){this.receiptListeners.add(listener);return()=>this.receiptListeners.delete(listener)}onDropped(listener){const first=this.dropListeners.size===0;this.dropListeners.add(listener);if(first&&this.unheardDrops.length>0){const unheard=this.unheardDrops.splice(0,this.unheardDrops.length);for(const notice of unheard){try{listener(notice)}catch(error){debugLogger.debug(`drop listener threw on replay: ${error instanceof Error?error.message:String(error)}`)}}}return()=>this.dropListeners.delete(listener)}emitDropped(notice){if(this.dropListeners.size===0){if(this.unheardDrops.length<MAX_UNHEARD_DROP_NOTICES){this.unheardDrops.push(notice)}return}for(const listener of this.dropListeners){try{listener(notice)}catch(error){debugLogger.debug(`drop listener threw: ${error instanceof Error?error.message:String(error)}`)}}}emitReceipt(receipt){for(const listener of this.receiptListeners){try{listener(receipt)}catch(error){debugLogger.debug(`receipt listener threw: ${error instanceof Error?error.message:String(error)}`)}}}async close(){if(this.closed)return;this.closed=true;const shuttingDown=this.gate?.shutdown();await this.inbox?.close();await shuttingDown;await this.settleUnconsumed();clearInheritedPeerMessagingEnv();await this.updateSessionRegistryIpcPath(void 0);await this.dropReceipts?.flush(CLOSE_DROP_FLUSH_BOUND_MS);this.dropReceipts?.dispose()}async settleUnconsumed(){const queued=this.queuedPeerCount?.()??0;const dropped=this.outstanding.slice(Math.max(0,this.outstanding.length-this.buffered.length-queued));const receipts=dropped.filter(frame=>frame.from!==void 0).map(frame=>sendDeliveryStatus(frame.from,{status:"expired",origMsgId:frame.msgId,from:this.inbox?.socketPath},frame.replyToken));await Promise.allSettled(receipts)}onDroppedReceipt(frame){const ids=[frame.origMsgId,...frame.droppedMsgIds??[]];let first;let settledCount=0;const settledByPath=new Map;for(const id of ids){const settled=this.settleSentMessage(id,"dropped");if(!settled)continue;first??=settled;settledCount+=1;const entry=settledByPath.get(settled.ipcPath)??{ids:[],freshestAgeMs:Number.POSITIVE_INFINITY};entry.ids.push(id);entry.freshestAgeMs=Math.min(entry.freshestAgeMs,settled.ageMs);settledByPath.set(settled.ipcPath,entry)}if(!first){debugLogger.debug(`ignoring dropped receipt for ${frame.origMsgId}: unknown message or repeated receipt`);return}debugLogger.debug(`dropped receipt from ${first.address} (${frame.dropReason??"unspecified"}) settled ${settledCount} message(s)`);if(frame.dropReason==="duplicate"){for(const[ipcPath,entry]of settledByPath){for(const id of entry.ids)this.refundMirrorToken(ipcPath,id)}}else{for(const[ipcPath,entry]of settledByPath){this.forgetMirror(ipcPath,entry.ids)}}if(frame.dropReason==="rate-limited"){for(const[ipcPath,entry]of settledByPath){if(entry.freshestAgeMs<=RECEIVER_REFILL_MS)this.drainMirror(ipcPath)}}this.emitReceipt({status:"dropped",address:first.address,origMsgId:frame.origMsgId,previous:"pending",...frame.dropReason?{dropReason:frame.dropReason}:{},dropped:settledCount})}onFrame(frame,origin){if(frame.type==="control"){if(frame.status==="dropped"){this.onDroppedReceipt(frame);return}const settled=this.settleSentMessage(frame.origMsgId,frame.status);if(!settled){debugLogger.debug(`ignoring delivery status ${frame.status} for ${frame.origMsgId}: unknown message or repeated receipt`);return}debugLogger.debug(`delivery status from ${settled.address}: ${settled.previous} -> ${frame.status} for ${frame.origMsgId}`);if(frame.status!=="held"&&frame.status!=="delivered"){if(frame.status==="misaddressed"){this.refundMirror(settled.ipcPath,frame.origMsgId)}else{this.forgetMirror(settled.ipcPath,[frame.origMsgId])}}this.emitReceipt({status:frame.status,address:settled.address,origMsgId:frame.origMsgId,previous:settled.previous});return}const ownSessionId=this.getSessionId?.();const ownsSessionId=this.ownsSessionId;const misaddressed=ownsSessionId?frame.toSessionId===void 0||!ownsSessionId(frame.toSessionId):frame.toSessionId!==void 0&&ownSessionId!==void 0&&frame.toSessionId!==ownSessionId;if(misaddressed){debugLogger.debug(`refusing peer message ${frame.msgId}: addressed to session ${frame.toSessionId??"(unspecified)"}, this process does not hold it`);if(frame.from){void sendDeliveryStatus(frame.from,{status:"misaddressed",origMsgId:frame.msgId,from:this.inbox?.socketPath},frame.replyToken)}void this.reassertSessionRecord?.().catch(error=>{debugLogger.debug(`re-asserting the session record failed: ${error instanceof Error?error.message:String(error)}`)});return}this.gate?.admit(frame,origin)}deliver(frame,origin){if(!this.submitFn){if(this.buffered.length>=MAX_ACCEPTED_BACKLOG){throw new Error("accepted-message backlog is full")}this.buffered.push({frame,origin});this.trackOutstanding(frame);return}if(this.buffered.length>0){this.withControllerValidity(()=>{while(this.buffered.length>0){const head=this.buffered[0];if(!head||!this.submit(head.frame,head.origin)){throw new Error("accepted-message backlog is full")}this.buffered.shift()}})}if(!this.submit(frame,origin)){throw new Error("accepted-message backlog is full")}this.trackOutstanding(frame)}trackOutstanding(frame){this.outstanding.push(frame);while(this.outstanding.length>2*MAX_ACCEPTED_BACKLOG){this.outstanding.shift()}}withControllerValidity(action){if(this.controllerRegistryPath===null||this.validControllerIds){return action()}this.validControllerIds=new Set(readPeerControllerRegistrySync(this.controllerRegistryPath).controllers.map(controller=>controller.id));for(const delivery of this.buffered){const controller=delivery.origin.controller;if(controller&&!this.validControllerIds.has(controller.id)){delete delivery.origin.controller}}try{return action()}finally{this.validControllerIds=null}}submit(frame,origin){const from=frame.from??(origin.controller?"controller":origin.selfSent?"own process":"unknown session");const attribution={selfSent:origin.selfSent,...origin.controller?{controller:origin.controller}:{}};return this.submitFn?.(formatPeerEnvelope({from,...frame.fromName!==void 0?{fromName:frame.fromName}:{},content:frame.message.content,...attribution}),formatPeerDisplay({from,...frame.fromName!==void 0?{fromName:frame.fromName}:{},content:frame.message.content,...attribution}),{msgId:frame.msgId,admissionKey:peerSenderKey(frame,origin),...frame.from!==void 0?{from:frame.from}:{},...frame.replyToken!==void 0?{replyToken:frame.replyToken}:{},...frame.toSessionId!==void 0?{toSessionId:frame.toSessionId}:{}})??false}drainQueuedFrame(delivery){const ownSessionId=this.getSessionId?.();if(delivery?.toSessionId===void 0||ownSessionId===void 0||delivery.toSessionId===ownSessionId){return true}debugLogger.debug(`dropping queued peer message ${delivery.msgId}: addressed to session ${delivery.toSessionId}, this is ${ownSessionId}`);if(delivery.from){void sendDeliveryStatus(delivery.from,{status:"misaddressed",origMsgId:delivery.msgId,from:this.inbox?.socketPath},delivery.replyToken)}if(delivery.admissionKey!==void 0){this.gate?.forgetAdmittedMessage(delivery.admissionKey,delivery.msgId)}return false}emitHeldChange(held){for(const listener of this.heldListeners){try{listener(held)}catch(error){debugLogger.debug(`held-change listener threw: ${error instanceof Error?error.message:String(error)}`)}}}};init_esbuild_shims();function classifyApiError(error){const status=error.status;const message=error.message?.toLowerCase()??"";if(status===429||message.includes("rate limit")){return"rate_limit"}if(status===401||message.includes("unauthorized")){return"authentication_failed"}if(status===402||status===403||message.includes("billing")||message.includes("quota")){return"billing_error"}if(status===400||message.includes("invalid")){return"invalid_request"}if(status!==void 0&&status>=500){return"server_error"}if(message.includes("max_tokens")||message.includes("token limit")){return"max_output_tokens"}return"unknown"}__name(classifyApiError,"classifyApiError");export{classifyApiError,MAX_ACCEPTED_BACKLOG,PeerMessaging};
3
+ import{DropNoticeThrottle,DropReceiptCoalescer,getPeerControllerRegistryPath,readPeerControllerRegistrySync,resolveControllerToken,startPeerInbox}from"./chunk-AVIDPC5K.js";import{InboundGate,MAX_HELD_MESSAGES,PEER_ADMISSION_LIMITS,canonicalizeMsgId,drainSendPacer,forgetSendPacerMessages,peerSenderKey,refundSendPacerMessage,refundSendPacerToken,sendDeliveryStatus,settleSentPeerMessage}from"./chunk-MKH3EH7O.js";import{formatPeerDisplay,formatPeerEnvelope}from"./chunk-BYU42MLK.js";import{MESSAGING_SOCKET_ENV,MESSAGING_TOKEN_ENV,clearInheritedPeerMessagingEnv}from"./chunk-NPAX2UFU.js";import{createDebugLogger}from"./chunk-JAUJI56S.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import{__name}from"./chunk-KBWJGX7I.js";init_esbuild_shims();import{randomBytes}from"node:crypto";var debugLogger=createDebugLogger("PEER_MESSAGING");var MAX_ACCEPTED_BACKLOG=MAX_HELD_MESSAGES;var CLOSE_DROP_FLUSH_BOUND_MS=1e3;var MAX_UNHEARD_DROP_NOTICES=20;var RECEIVER_REFILL_MS=PEER_ADMISSION_LIMITS.bucketCapacity/PEER_ADMISSION_LIMITS.refillPerSecond*1e3;var PeerMessaging=class _PeerMessaging{static{__name(this,"PeerMessaging")}inbox=null;gate=null;updateSessionRegistryIpcPath=__name(async()=>{},"updateSessionRegistryIpcPath");getSessionId=null;ownsSessionId=null;settleSentMessage=settleSentPeerMessage;reassertSessionRecord=null;drainMirror=drainSendPacer;forgetMirror=forgetSendPacerMessages;refundMirror=refundSendPacerMessage;refundMirrorToken=refundSendPacerToken;receiptListeners=new Set;dropListeners=new Set;unheardDrops=[];dropReceipts=null;submitFn=null;buffered=[];controllerRegistryPath=null;validControllerIds=null;outstanding=[];queuedPeerCount=null;heldListeners=new Set;listedHeld=null;closed=false;constructor(){}static async start(options){if(options.getSessionId&&options.ownsSessionId){throw new Error("PeerMessaging: pass getSessionId or ownsSessionId, not both")}const messaging=new _PeerMessaging;const controllerRegistryPath=options.controllerRegistryPath??getPeerControllerRegistryPath();messaging.controllerRegistryPath=controllerRegistryPath;const dropReceipts=new DropReceiptCoalescer(({frame,reason,droppedMsgIds})=>{if(!frame.from)return;return sendDeliveryStatus(frame.from,{status:"dropped",origMsgId:frame.msgId,from:messaging.inbox?.socketPath,dropReason:reason,droppedMsgIds},frame.replyToken)},options.dropReceiptTrailMs!==void 0?{trailMs:options.dropReceiptTrailMs}:{});messaging.dropReceipts=dropReceipts;const dropNotices=new DropNoticeThrottle(notice=>messaging.emitDropped(notice));const gate=new InboundGate({getApprovalMode:options.getApprovalMode,getPolicySetting:options.getPolicySetting,...options.getHeldExpiryMs!==void 0?{getHeldExpiryMs:options.getHeldExpiryMs}:{},...options.getPolicyScope?{getPolicyScope:options.getPolicyScope}:{},isControllerValid:__name(id=>messaging.validControllerIds?.has(id)??true,"isControllerValid"),...options.admission?{admission:options.admission}:{},getSessionId:options.getSessionId,...options.ownsSessionId?{ownsSessionId:options.ownsSessionId}:{},deliver:__name((frame,origin)=>messaging.deliver(frame,origin),"deliver"),reportDropped:__name((frame,reason,origin)=>dropReceipts.note(frame,origin??{selfSent:false},reason),"reportDropped"),onDropped:__name((frame,origin,reason)=>dropNotices.note(frame,origin,reason),"onDropped"),reportStatus:__name((frame,status)=>{if(!frame.from)return;return sendDeliveryStatus(frame.from,{status,origMsgId:frame.msgId,from:messaging.inbox?.socketPath},frame.replyToken)},"reportStatus"),onHeldChange:__name(held=>messaging.emitHeldChange(held),"onHeldChange")});messaging.gate=gate;messaging.getSessionId=options.getSessionId??null;messaging.ownsSessionId=options.ownsSessionId??null;messaging.settleSentMessage=options.settleSentMessage??settleSentPeerMessage;messaging.reassertSessionRecord=options.reassertSessionRecord??null;messaging.drainMirror=options.drainMirror??drainSendPacer;messaging.forgetMirror=options.forgetMirror??forgetSendPacerMessages;messaging.refundMirror=options.refundMirror??refundSendPacerMessage;messaging.refundMirrorToken=options.refundMirrorToken??refundSendPacerToken;clearInheritedPeerMessagingEnv();const ipcToken=options.ipcToken??randomBytes(32).toString("hex");const childToken=options.childToken??randomBytes(32).toString("hex");const inbox=await startPeerInbox({...options.socketPath!==void 0?{socketPath:options.socketPath}:{},requiredToken:ipcToken,childToken,resolveController:__name(presented=>resolveControllerToken(presented,controllerRegistryPath),"resolveController"),onFrame:__name((frame,auth,controller)=>messaging.onFrame(frame,{selfSent:auth==="child",...controller?{controller}:{}}),"onFrame")});if(!inbox)return null;messaging.inbox=inbox;messaging.updateSessionRegistryIpcPath=options.updateSessionRegistryIpcPath;await messaging.updateSessionRegistryIpcPath(inbox.socketPath,ipcToken);process.env[MESSAGING_SOCKET_ENV]=inbox.socketPath;process.env[MESSAGING_TOKEN_ENV]=childToken;return messaging}get socketPath(){return this.inbox?.socketPath}setSubmitFn(fn){if(this.closed)return;this.withControllerValidity(()=>{this.submitFn=fn;while(this.buffered.length>0){const head=this.buffered[0];if(!head||!this.submit(head.frame,head.origin))break;this.buffered.shift()}})}setQueuedPeerCount(fn){this.queuedPeerCount=fn}getHeld(){return this.withControllerValidity(()=>this.gate?.getHeld()??[])}getHeldExpiryMs(sessionId){return this.gate?.getHeldExpiryMs(sessionId)??null}recordHeldListing(heldEntries){this.listedHeld=heldEntries.map(entry=>({id:entry.frame.msgId,heldAt:entry.heldAt}))}heldSetChangedSinceListing(){const listed=this.listedHeld;if(listed===null)return true;const pinned=new Map(listed.map(entry=>[entry.id,entry.heldAt]));const current=this.getHeld();if(current.some(entry=>pinned.get(entry.frame.msgId)!==entry.heldAt))return true;const liveIds=current.map(entry=>canonicalizeMsgId(entry.frame.msgId));const liveSet=new Set(liveIds);for(const id of pinned.keys()){const departed=canonicalizeMsgId(id);if(liveSet.has(departed))continue;if(liveIds.some(live=>live.startsWith(departed)))return true}return false}decide(msgId,decision){return this.withControllerValidity(()=>this.gate?.decide(msgId,decision)??"gone")}forgetController(id){return this.withControllerValidity(()=>this.gate?.forgetController(id)??0)}reevaluate(reason){return this.withControllerValidity(()=>this.gate?.reevaluate(reason)??0)}onHeldChange(listener){this.heldListeners.add(listener);try{listener(this.getHeld())}catch(error){debugLogger.debug(`held-change listener threw: ${error instanceof Error?error.message:String(error)}`)}return()=>this.heldListeners.delete(listener)}onReceipt(listener){this.receiptListeners.add(listener);return()=>this.receiptListeners.delete(listener)}onDropped(listener){const first=this.dropListeners.size===0;this.dropListeners.add(listener);if(first&&this.unheardDrops.length>0){const unheard=this.unheardDrops.splice(0,this.unheardDrops.length);for(const notice of unheard){try{listener(notice)}catch(error){debugLogger.debug(`drop listener threw on replay: ${error instanceof Error?error.message:String(error)}`)}}}return()=>this.dropListeners.delete(listener)}emitDropped(notice){if(this.dropListeners.size===0){if(this.unheardDrops.length<MAX_UNHEARD_DROP_NOTICES){this.unheardDrops.push(notice)}return}for(const listener of this.dropListeners){try{listener(notice)}catch(error){debugLogger.debug(`drop listener threw: ${error instanceof Error?error.message:String(error)}`)}}}emitReceipt(receipt){for(const listener of this.receiptListeners){try{listener(receipt)}catch(error){debugLogger.debug(`receipt listener threw: ${error instanceof Error?error.message:String(error)}`)}}}async close(){if(this.closed)return;this.closed=true;const shuttingDown=this.gate?.shutdown();await this.inbox?.close();await shuttingDown;await this.settleUnconsumed();clearInheritedPeerMessagingEnv();await this.updateSessionRegistryIpcPath(void 0);await this.dropReceipts?.flush(CLOSE_DROP_FLUSH_BOUND_MS);this.dropReceipts?.dispose()}async settleUnconsumed(){const queued=this.queuedPeerCount?.()??0;const dropped=this.outstanding.slice(Math.max(0,this.outstanding.length-this.buffered.length-queued));const receipts=dropped.filter(frame=>frame.from!==void 0).map(frame=>sendDeliveryStatus(frame.from,{status:"expired",origMsgId:frame.msgId,from:this.inbox?.socketPath},frame.replyToken));await Promise.allSettled(receipts)}onDroppedReceipt(frame){const ids=[frame.origMsgId,...frame.droppedMsgIds??[]];let first;let settledCount=0;const settledByPath=new Map;for(const id of ids){const settled=this.settleSentMessage(id,"dropped");if(!settled)continue;first??=settled;settledCount+=1;const entry=settledByPath.get(settled.ipcPath)??{ids:[],freshestAgeMs:Number.POSITIVE_INFINITY};entry.ids.push(id);entry.freshestAgeMs=Math.min(entry.freshestAgeMs,settled.ageMs);settledByPath.set(settled.ipcPath,entry)}if(!first){debugLogger.debug(`ignoring dropped receipt for ${frame.origMsgId}: unknown message or repeated receipt`);return}debugLogger.debug(`dropped receipt from ${first.address} (${frame.dropReason??"unspecified"}) settled ${settledCount} message(s)`);if(frame.dropReason==="duplicate"){for(const[ipcPath,entry]of settledByPath){for(const id of entry.ids)this.refundMirrorToken(ipcPath,id)}}else{for(const[ipcPath,entry]of settledByPath){this.forgetMirror(ipcPath,entry.ids)}}if(frame.dropReason==="rate-limited"){for(const[ipcPath,entry]of settledByPath){if(entry.freshestAgeMs<=RECEIVER_REFILL_MS)this.drainMirror(ipcPath)}}this.emitReceipt({status:"dropped",address:first.address,origMsgId:frame.origMsgId,previous:"pending",...frame.dropReason?{dropReason:frame.dropReason}:{},dropped:settledCount})}onFrame(frame,origin){if(frame.type==="control"){if(frame.status==="dropped"){this.onDroppedReceipt(frame);return}const settled=this.settleSentMessage(frame.origMsgId,frame.status);if(!settled){debugLogger.debug(`ignoring delivery status ${frame.status} for ${frame.origMsgId}: unknown message or repeated receipt`);return}debugLogger.debug(`delivery status from ${settled.address}: ${settled.previous} -> ${frame.status} for ${frame.origMsgId}`);if(frame.status!=="held"&&frame.status!=="delivered"){if(frame.status==="misaddressed"){this.refundMirror(settled.ipcPath,frame.origMsgId)}else{this.forgetMirror(settled.ipcPath,[frame.origMsgId])}}this.emitReceipt({status:frame.status,address:settled.address,origMsgId:frame.origMsgId,previous:settled.previous});return}const ownSessionId=this.getSessionId?.();const ownsSessionId=this.ownsSessionId;const misaddressed=ownsSessionId?frame.toSessionId===void 0||!ownsSessionId(frame.toSessionId):frame.toSessionId!==void 0&&ownSessionId!==void 0&&frame.toSessionId!==ownSessionId;if(misaddressed){debugLogger.debug(`refusing peer message ${frame.msgId}: addressed to session ${frame.toSessionId??"(unspecified)"}, this process does not hold it`);if(frame.from){void sendDeliveryStatus(frame.from,{status:"misaddressed",origMsgId:frame.msgId,from:this.inbox?.socketPath},frame.replyToken)}void this.reassertSessionRecord?.().catch(error=>{debugLogger.debug(`re-asserting the session record failed: ${error instanceof Error?error.message:String(error)}`)});return}this.gate?.admit(frame,origin)}deliver(frame,origin){if(!this.submitFn){if(this.buffered.length>=MAX_ACCEPTED_BACKLOG){throw new Error("accepted-message backlog is full")}this.buffered.push({frame,origin});this.trackOutstanding(frame);return}if(this.buffered.length>0){this.withControllerValidity(()=>{while(this.buffered.length>0){const head=this.buffered[0];if(!head||!this.submit(head.frame,head.origin)){throw new Error("accepted-message backlog is full")}this.buffered.shift()}})}if(!this.submit(frame,origin)){throw new Error("accepted-message backlog is full")}this.trackOutstanding(frame)}trackOutstanding(frame){this.outstanding.push(frame);while(this.outstanding.length>2*MAX_ACCEPTED_BACKLOG){this.outstanding.shift()}}withControllerValidity(action){if(this.controllerRegistryPath===null||this.validControllerIds){return action()}this.validControllerIds=new Set(readPeerControllerRegistrySync(this.controllerRegistryPath).controllers.map(controller=>controller.id));for(const delivery of this.buffered){const controller=delivery.origin.controller;if(controller&&!this.validControllerIds.has(controller.id)){delete delivery.origin.controller}}try{return action()}finally{this.validControllerIds=null}}submit(frame,origin){const from=frame.from??(origin.controller?"controller":origin.selfSent?"own process":"unknown session");const attribution={selfSent:origin.selfSent,...origin.controller?{controller:origin.controller}:{}};return this.submitFn?.(formatPeerEnvelope({from,...frame.fromName!==void 0?{fromName:frame.fromName}:{},content:frame.message.content,...attribution}),formatPeerDisplay({from,...frame.fromName!==void 0?{fromName:frame.fromName}:{},content:frame.message.content,...attribution}),{msgId:frame.msgId,admissionKey:peerSenderKey(frame,origin),...frame.from!==void 0?{from:frame.from}:{},...frame.replyToken!==void 0?{replyToken:frame.replyToken}:{},...frame.toSessionId!==void 0?{toSessionId:frame.toSessionId}:{}})??false}drainQueuedFrame(delivery){const ownSessionId=this.getSessionId?.();if(delivery?.toSessionId===void 0||ownSessionId===void 0||delivery.toSessionId===ownSessionId){return true}debugLogger.debug(`dropping queued peer message ${delivery.msgId}: addressed to session ${delivery.toSessionId}, this is ${ownSessionId}`);if(delivery.from){void sendDeliveryStatus(delivery.from,{status:"misaddressed",origMsgId:delivery.msgId,from:this.inbox?.socketPath},delivery.replyToken)}if(delivery.admissionKey!==void 0){this.gate?.forgetAdmittedMessage(delivery.admissionKey,delivery.msgId)}return false}emitHeldChange(held){for(const listener of this.heldListeners){try{listener(held)}catch(error){debugLogger.debug(`held-change listener threw: ${error instanceof Error?error.message:String(error)}`)}}}};init_esbuild_shims();function classifyApiError(error){const status=error.status;const message=error.message?.toLowerCase()??"";if(status===429||message.includes("rate limit")){return"rate_limit"}if(status===401||message.includes("unauthorized")){return"authentication_failed"}if(status===402||status===403||message.includes("billing")||message.includes("quota")){return"billing_error"}if(status===400||message.includes("invalid")){return"invalid_request"}if(status!==void 0&&status>=500){return"server_error"}if(message.includes("max_tokens")||message.includes("token limit")){return"max_output_tokens"}return"unknown"}__name(classifyApiError,"classifyApiError");export{classifyApiError,MAX_ACCEPTED_BACKLOG,PeerMessaging};
4
4
  /**
5
5
  * @license
6
6
  * Copyright 2026 Qwen
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{MAX_WORKSPACE_PATH_LENGTH,canonicalizeWorkspace}from"./chunk-L5UULTGF.js";import{getGlobalQwenDirLite}from"./chunk-PTHIQ7ZN.js";import{isWithinRoot}from"./chunk-IDXJIDME.js";import{isUnverifiableIdentityError,openNoFollow}from"./chunk-QXQGUM3Y.js";import{require_proper_lockfile}from"./chunk-YIW3H46P.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import{__name,__toESM}from"./chunk-KBWJGX7I.js";init_esbuild_shims();var import_proper_lockfile=__toESM(require_proper_lockfile(),1);import{createHash}from"node:crypto";import*as fs from"node:fs/promises";import*as os from"node:os";import*as path from"node:path";init_esbuild_shims();var MAX_REGISTERED_WORKSPACES=256;var MAX_CONFIGURED_REGISTERED_WORKSPACES=256;var QWEN_SERVE_MAX_WORKSPACES_ENV="QWEN_SERVE_MAX_WORKSPACES";function resolveMaxRegisteredWorkspaces(configured,env){const raw=env[QWEN_SERVE_MAX_WORKSPACES_ENV];const value=configured??(raw===void 0?MAX_REGISTERED_WORKSPACES:/^\d+$/.test(raw.trim())?Number(raw.trim()):Number.NaN);if(!Number.isSafeInteger(value)||value<1||value>MAX_CONFIGURED_REGISTERED_WORKSPACES){const source=configured===void 0?`${QWEN_SERVE_MAX_WORKSPACES_ENV}=${JSON.stringify(raw)}`:`maxRegisteredWorkspaces option ${String(configured)}`;throw new TypeError(`Invalid ${source}: must be an integer from 1 to ${MAX_CONFIGURED_REGISTERED_WORKSPACES}.`)}return value}__name(resolveMaxRegisteredWorkspaces,"resolveMaxRegisteredWorkspaces");var DuplicateWorkspaceInputError=class extends Error{static{__name(this,"DuplicateWorkspaceInputError")}constructor(workspace){super(`Duplicate --workspace value resolves to ${JSON.stringify(workspace)}. Pass distinct --workspace values.`);this.name="DuplicateWorkspaceInputError"}};var NestedWorkspaceInputError=class extends Error{static{__name(this,"NestedWorkspaceInputError")}constructor(parent,child){super(`Nested --workspace values are not supported yet: ${JSON.stringify(child)} is inside ${JSON.stringify(parent)}. Pass non-nested --workspace values.`);this.name="NestedWorkspaceInputError"}};var MissingWorkspaceInputError=class extends Error{static{__name(this,"MissingWorkspaceInputError")}constructor(){super("--workspace requires a value.");this.name="MissingWorkspaceInputError"}};function normalizeWorkspaceInputs(workspace){if(Array.isArray(workspace)){if(workspace.length===0){throw new MissingWorkspaceInputError}return workspace.map(value=>String(value))}if(workspace===void 0)return[process.cwd()];return[String(workspace)]}__name(normalizeWorkspaceInputs,"normalizeWorkspaceInputs");function isNestedWorkspace(parent,child){return parent!==child&&isWithinRoot(child,parent)}__name(isNestedWorkspace,"isNestedWorkspace");function rejectDuplicateOrNestedWorkspaceInputs(workspaces){if(workspaces.length<=1)return;let canonicalWorkspaces;try{canonicalWorkspaces=workspaces.map(workspace=>canonicalizeWorkspace(workspace))}catch{return}const seen=new Set;for(const workspace of canonicalWorkspaces){if(seen.has(workspace)){throw new DuplicateWorkspaceInputError(workspace)}seen.add(workspace)}for(let i=0;i<canonicalWorkspaces.length;i++){for(let j=i+1;j<canonicalWorkspaces.length;j++){const first=canonicalWorkspaces[i];const second=canonicalWorkspaces[j];if(isNestedWorkspace(first,second)){throw new NestedWorkspaceInputError(first,second)}if(isNestedWorkspace(second,first)){throw new NestedWorkspaceInputError(second,first)}}}}__name(rejectDuplicateOrNestedWorkspaceInputs,"rejectDuplicateOrNestedWorkspaceInputs");function resolveWorkspaceInputs(workspace){const workspaces=normalizeWorkspaceInputs(workspace);rejectDuplicateOrNestedWorkspaceInputs(workspaces);return workspaces}__name(resolveWorkspaceInputs,"resolveWorkspaceInputs");var SCHEMA_VERSION=1;var MAX_SECONDARY_WORKSPACES=MAX_CONFIGURED_REGISTERED_WORKSPACES-1;var MAX_STORE_BYTES=8*1024*1024;var MAX_WORKSPACE_DISPLAY_NAME_LENGTH=256;var LOCK_OPTIONS={realpath:false,stale:1e4,update:2e3,retries:{retries:120,minTimeout:10,maxTimeout:100,factor:1.2,randomize:true}};var WorkspaceDisplayNameValidationError=class extends Error{static{__name(this,"WorkspaceDisplayNameValidationError")}constructor(message){super(message);this.name="WorkspaceDisplayNameValidationError"}};function containsDisplayNameControlCharacter(value){for(const character of value){const codePoint=character.codePointAt(0);if(codePoint<=31||codePoint===127)return true}return false}__name(containsDisplayNameControlCharacter,"containsDisplayNameControlCharacter");function normalizeWorkspaceDisplayName(value){if(typeof value!=="string"){throw new WorkspaceDisplayNameValidationError("Workspace display name must be a string")}const trimmed=value.trim();if(trimmed.length>MAX_WORKSPACE_DISPLAY_NAME_LENGTH){throw new WorkspaceDisplayNameValidationError(`Workspace display name exceeds ${MAX_WORKSPACE_DISPLAY_NAME_LENGTH} characters`)}if(containsDisplayNameControlCharacter(trimmed)){throw new WorkspaceDisplayNameValidationError("Workspace display name contains control characters")}return trimmed.length===0?void 0:trimmed}__name(normalizeWorkspaceDisplayName,"normalizeWorkspaceDisplayName");var WorkspaceRegistrationStoreError=class extends Error{static{__name(this,"WorkspaceRegistrationStoreError")}constructor(message){super(message);this.name="WorkspaceRegistrationStoreError"}};var WorkspaceRegistrationStoreLimitError=class extends WorkspaceRegistrationStoreError{static{__name(this,"WorkspaceRegistrationStoreLimitError")}};var WorkspaceRegistrationStoreTooLargeError=class extends WorkspaceRegistrationStoreError{static{__name(this,"WorkspaceRegistrationStoreTooLargeError")}};var WorkspaceRegistrationStoreCommittedError=class extends WorkspaceRegistrationStoreError{static{__name(this,"WorkspaceRegistrationStoreCommittedError")}};function normalizedScopePath(primaryWorkspace){return os.platform()==="win32"?primaryWorkspace.toLowerCase():primaryWorkspace}__name(normalizedScopePath,"normalizedScopePath");function workspaceRegistrationScopeHash(primaryWorkspace){return createHash("sha256").update(normalizedScopePath(primaryWorkspace)).digest("hex")}__name(workspaceRegistrationScopeHash,"workspaceRegistrationScopeHash");function workspaceRegistrationId(workspace){return createHash("sha256").update(workspace).digest("hex").slice(0,16)}__name(workspaceRegistrationId,"workspaceRegistrationId");function getWorkspaceRegistrationStorePath(primaryWorkspace,qwenHome=getGlobalQwenDirLite()){return path.join(qwenHome,"daemon","workspaces",`${workspaceRegistrationScopeHash(primaryWorkspace)}.json`)}__name(getWorkspaceRegistrationStorePath,"getWorkspaceRegistrationStorePath");function emptySnapshot(primaryWorkspace){return{schemaVersion:SCHEMA_VERSION,primaryWorkspace,workspaces:[]}}__name(emptySnapshot,"emptySnapshot");function validateWorkspacePath(value,label){if(typeof value!=="string"||!path.isAbsolute(value)){throw new WorkspaceRegistrationStoreError(`${label} must be an absolute path`)}if(value.includes("\0")||value.length>MAX_WORKSPACE_PATH_LENGTH){throw new WorkspaceRegistrationStoreError(`${label} is invalid`)}return value}__name(validateWorkspacePath,"validateWorkspacePath");function validateStoredDisplayName(value,label){let displayName;try{displayName=normalizeWorkspaceDisplayName(value)}catch(err){throw new WorkspaceRegistrationStoreError(`${label} is invalid: ${err instanceof Error?err.message:String(err)}`)}if(displayName===void 0){throw new WorkspaceRegistrationStoreError(`${label} must not be empty`)}return displayName}__name(validateStoredDisplayName,"validateStoredDisplayName");function setSnapshotDisplayName(snapshot,registrationId,displayName){if(displayName===void 0){if(!snapshot.displayNames||!Object.hasOwn(snapshot.displayNames,registrationId)){return false}delete snapshot.displayNames[registrationId];if(Object.keys(snapshot.displayNames).length===0){delete snapshot.displayNames}return true}if(snapshot.displayNames?.[registrationId]===displayName)return false;snapshot.displayNames??={};snapshot.displayNames[registrationId]=displayName;return true}__name(setSnapshotDisplayName,"setSnapshotDisplayName");function parseSnapshot(raw,primaryWorkspace){let value;try{value=JSON.parse(raw)}catch{throw new WorkspaceRegistrationStoreError("Workspace registration store contains malformed JSON")}if(typeof value!=="object"||value===null||Array.isArray(value)){throw new WorkspaceRegistrationStoreError("Workspace registration store root must be an object")}const record=value;if(record["schemaVersion"]!==SCHEMA_VERSION){throw new WorkspaceRegistrationStoreError(`Unsupported workspace registration schema ${String(record["schemaVersion"])}`)}const storedPrimary=validateWorkspacePath(record["primaryWorkspace"],"primaryWorkspace");if(normalizedScopePath(storedPrimary)!==normalizedScopePath(primaryWorkspace)){throw new WorkspaceRegistrationStoreError("Workspace registration store primary does not match this daemon")}if(!Array.isArray(record["workspaces"])){throw new WorkspaceRegistrationStoreError("Workspace registration store workspaces must be an array")}if(record["workspaces"].length>MAX_SECONDARY_WORKSPACES){throw new WorkspaceRegistrationStoreError(`Workspace registration store exceeds ${MAX_SECONDARY_WORKSPACES} entries`)}const seen=new Set;const workspaces=record["workspaces"].map((entry,index)=>{const workspace=validateWorkspacePath(entry,`workspaces[${index}]`);const normalizedWorkspace=normalizedScopePath(workspace);if(normalizedWorkspace===normalizedScopePath(primaryWorkspace)){throw new WorkspaceRegistrationStoreError("Primary workspace cannot be stored as a secondary registration")}if(seen.has(normalizedWorkspace)){throw new WorkspaceRegistrationStoreError("Workspace registration store contains duplicate paths")}seen.add(normalizedWorkspace);return workspace});const rawDisplayNames=record["displayNames"];let displayNames;if(rawDisplayNames!==void 0){if(typeof rawDisplayNames!=="object"||rawDisplayNames===null||Array.isArray(rawDisplayNames)){throw new WorkspaceRegistrationStoreError("Workspace registration store displayNames must be an object")}const registrationIds=new Set(workspaces.map(workspaceRegistrationId));for(const[registrationId,value2]of Object.entries(rawDisplayNames)){if(!registrationIds.has(registrationId)){throw new WorkspaceRegistrationStoreError(`Workspace registration store displayNames contains unknown registration id ${JSON.stringify(registrationId)}`)}displayNames??={};displayNames[registrationId]=validateStoredDisplayName(value2,`displayNames[${JSON.stringify(registrationId)}]`)}}return{schemaVersion:SCHEMA_VERSION,primaryWorkspace,workspaces,...displayNames?{displayNames}:{}}}__name(parseSnapshot,"parseSnapshot");var updateChains=new Map;async function withInProcessLock(filePath,work){const previous=updateChains.get(filePath)??Promise.resolve();const next=previous.then(work,work);const settled=next.catch(()=>void 0).finally(()=>{if(updateChains.get(filePath)===settled)updateChains.delete(filePath)});updateChains.set(filePath,settled);return next}__name(withInProcessLock,"withInProcessLock");function compromisedLockError(){return new WorkspaceRegistrationStoreError("Workspace registration store lock was compromised")}__name(compromisedLockError,"compromisedLockError");async function acquireFileLock(filePath){await fs.mkdir(path.dirname(filePath),{recursive:true,mode:448});let compromised=false;const release=await import_proper_lockfile.default.lock(filePath,{...LOCK_OPTIONS,onCompromised:__name(()=>{compromised=true},"onCompromised")});return{assertOwned:__name(()=>{if(compromised)throw compromisedLockError()},"assertOwned"),release:__name(async()=>{try{await release()}catch(err){if(!compromised)throw err}if(compromised)throw compromisedLockError()},"release")}}__name(acquireFileLock,"acquireFileLock");var WorkspaceRegistrationStore=class{constructor(primaryWorkspace,qwenHome){this.primaryWorkspace=primaryWorkspace;validateWorkspacePath(primaryWorkspace,"primaryWorkspace");this.filePath=getWorkspaceRegistrationStorePath(primaryWorkspace,qwenHome)}static{__name(this,"WorkspaceRegistrationStore")}filePath;async read(){try{const entry=await fs.lstat(this.filePath);if(entry.isSymbolicLink()||!entry.isFile()){throw new WorkspaceRegistrationStoreError("Workspace registration store must be a regular file")}}catch(err){if(err.code==="ENOENT"){return emptySnapshot(this.primaryWorkspace)}throw err}let file;try{file=await openNoFollow(this.filePath)}catch(err){if(err.code==="ENOENT"){return emptySnapshot(this.primaryWorkspace)}if(isUnverifiableIdentityError(err)){throw new WorkspaceRegistrationStoreError("Workspace registration store identity could not be verified")}if(err.code==="ELOOP"){throw new WorkspaceRegistrationStoreError("Workspace registration store must be a regular file")}throw err}try{const stat=await file.stat();if(!stat.isFile()){throw new WorkspaceRegistrationStoreError("Workspace registration store must be a regular file")}if(stat.size>MAX_STORE_BYTES){throw new WorkspaceRegistrationStoreTooLargeError(`Workspace registration store exceeds ${MAX_STORE_BYTES} bytes`)}let buffer=Buffer.alloc(Math.max(1,Math.min(stat.size+1,MAX_STORE_BYTES+1)));let totalBytesRead=0;for(;;){if(totalBytesRead===buffer.length){if(totalBytesRead>MAX_STORE_BYTES)break;const grown=Buffer.alloc(Math.min(MAX_STORE_BYTES+1,Math.max(buffer.length*2,totalBytesRead+1)));buffer.copy(grown,0,0,totalBytesRead);buffer=grown}const{bytesRead}=await file.read(buffer,totalBytesRead,buffer.length-totalBytesRead,totalBytesRead);if(bytesRead===0)break;totalBytesRead+=bytesRead}if(totalBytesRead>MAX_STORE_BYTES){throw new WorkspaceRegistrationStoreTooLargeError(`Workspace registration store exceeds ${MAX_STORE_BYTES} bytes`)}return parseSnapshot(buffer.toString("utf8",0,totalBytesRead),this.primaryWorkspace)}finally{await file.close()}}async add(workspace,displayName,maxRegisteredWorkspaces=MAX_REGISTERED_WORKSPACES){const maxSecondaries=resolveMaxRegisteredWorkspaces(maxRegisteredWorkspaces,{})-1;validateWorkspacePath(workspace,"workspace");const normalizedDisplayName=displayName===void 0?void 0:normalizeWorkspaceDisplayName(displayName);if(normalizedScopePath(workspace)===normalizedScopePath(this.primaryWorkspace)){throw new WorkspaceRegistrationStoreError("Primary workspace cannot be stored as a secondary registration")}return this.update(snapshot=>{const normalizedWorkspace=normalizedScopePath(workspace);if(snapshot.workspaces.some(stored=>normalizedScopePath(stored)===normalizedWorkspace)){return false}if(snapshot.workspaces.length>=maxSecondaries){throw new WorkspaceRegistrationStoreLimitError(`Workspace registration store limit of ${maxSecondaries} reached`)}snapshot.workspaces.push(workspace);if(normalizedDisplayName!==void 0){snapshot.displayNames??={};snapshot.displayNames[workspaceRegistrationId(workspace)]=normalizedDisplayName}return true})}async removeById(id){return await this.removeByIds([id])>0}async setDisplayNameByIds(ids,displayName){const normalizedDisplayName=displayName===void 0?void 0:normalizeWorkspaceDisplayName(displayName);const requested=new Set(ids);if(requested.size===0)return 0;let matched=0;await this.update(snapshot=>{let changed=false;for(const workspace of snapshot.workspaces){const registrationId=workspaceRegistrationId(workspace);if(!requested.has(registrationId))continue;matched++;changed=setSnapshotDisplayName(snapshot,registrationId,normalizedDisplayName)||changed}return changed});return matched}async removeByIds(ids){const requested=new Set(ids);if(requested.size===0)return 0;let removed=0;await this.update(snapshot=>{const removedIds=new Set;const retained=snapshot.workspaces.filter(workspace=>{const registrationId=workspaceRegistrationId(workspace);if(!requested.has(registrationId))return true;removed++;removedIds.add(registrationId);return false});if(removed===0)return false;snapshot.workspaces.splice(0,snapshot.workspaces.length,...retained);for(const registrationId of removedIds){setSnapshotDisplayName(snapshot,registrationId,void 0)}return true});return removed}async update(mutate){const{atomicWriteFile}=await import("./deferred-core-runtime-RZQFUSPX.js");return withInProcessLock(this.filePath,async()=>{const lock=await acquireFileLock(this.filePath);let committed=false;let changed=false;let workError;try{const snapshot=await this.read();lock.assertOwned();changed=mutate(snapshot);if(changed){const serialized=`${JSON.stringify(snapshot,null,2)}
3
+ import{MAX_WORKSPACE_PATH_LENGTH,canonicalizeWorkspace}from"./chunk-L5UULTGF.js";import{getGlobalQwenDirLite}from"./chunk-PTHIQ7ZN.js";import{isWithinRoot}from"./chunk-IDXJIDME.js";import{isUnverifiableIdentityError,openNoFollow}from"./chunk-QXQGUM3Y.js";import{require_proper_lockfile}from"./chunk-YIW3H46P.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import{__name,__toESM}from"./chunk-KBWJGX7I.js";init_esbuild_shims();var import_proper_lockfile=__toESM(require_proper_lockfile(),1);import{createHash}from"node:crypto";import*as fs from"node:fs/promises";import*as os from"node:os";import*as path from"node:path";init_esbuild_shims();var MAX_REGISTERED_WORKSPACES=256;var MAX_CONFIGURED_REGISTERED_WORKSPACES=256;var QWEN_SERVE_MAX_WORKSPACES_ENV="QWEN_SERVE_MAX_WORKSPACES";function resolveMaxRegisteredWorkspaces(configured,env){const raw=env[QWEN_SERVE_MAX_WORKSPACES_ENV];const value=configured??(raw===void 0?MAX_REGISTERED_WORKSPACES:/^\d+$/.test(raw.trim())?Number(raw.trim()):Number.NaN);if(!Number.isSafeInteger(value)||value<1||value>MAX_CONFIGURED_REGISTERED_WORKSPACES){const source=configured===void 0?`${QWEN_SERVE_MAX_WORKSPACES_ENV}=${JSON.stringify(raw)}`:`maxRegisteredWorkspaces option ${String(configured)}`;throw new TypeError(`Invalid ${source}: must be an integer from 1 to ${MAX_CONFIGURED_REGISTERED_WORKSPACES}.`)}return value}__name(resolveMaxRegisteredWorkspaces,"resolveMaxRegisteredWorkspaces");var DuplicateWorkspaceInputError=class extends Error{static{__name(this,"DuplicateWorkspaceInputError")}constructor(workspace){super(`Duplicate --workspace value resolves to ${JSON.stringify(workspace)}. Pass distinct --workspace values.`);this.name="DuplicateWorkspaceInputError"}};var NestedWorkspaceInputError=class extends Error{static{__name(this,"NestedWorkspaceInputError")}constructor(parent,child){super(`Nested --workspace values are not supported yet: ${JSON.stringify(child)} is inside ${JSON.stringify(parent)}. Pass non-nested --workspace values.`);this.name="NestedWorkspaceInputError"}};var MissingWorkspaceInputError=class extends Error{static{__name(this,"MissingWorkspaceInputError")}constructor(){super("--workspace requires a value.");this.name="MissingWorkspaceInputError"}};function normalizeWorkspaceInputs(workspace){if(Array.isArray(workspace)){if(workspace.length===0){throw new MissingWorkspaceInputError}return workspace.map(value=>String(value))}if(workspace===void 0)return[process.cwd()];return[String(workspace)]}__name(normalizeWorkspaceInputs,"normalizeWorkspaceInputs");function isNestedWorkspace(parent,child){return parent!==child&&isWithinRoot(child,parent)}__name(isNestedWorkspace,"isNestedWorkspace");function rejectDuplicateOrNestedWorkspaceInputs(workspaces){if(workspaces.length<=1)return;let canonicalWorkspaces;try{canonicalWorkspaces=workspaces.map(workspace=>canonicalizeWorkspace(workspace))}catch{return}const seen=new Set;for(const workspace of canonicalWorkspaces){if(seen.has(workspace)){throw new DuplicateWorkspaceInputError(workspace)}seen.add(workspace)}for(let i=0;i<canonicalWorkspaces.length;i++){for(let j=i+1;j<canonicalWorkspaces.length;j++){const first=canonicalWorkspaces[i];const second=canonicalWorkspaces[j];if(isNestedWorkspace(first,second)){throw new NestedWorkspaceInputError(first,second)}if(isNestedWorkspace(second,first)){throw new NestedWorkspaceInputError(second,first)}}}}__name(rejectDuplicateOrNestedWorkspaceInputs,"rejectDuplicateOrNestedWorkspaceInputs");function resolveWorkspaceInputs(workspace){const workspaces=normalizeWorkspaceInputs(workspace);rejectDuplicateOrNestedWorkspaceInputs(workspaces);return workspaces}__name(resolveWorkspaceInputs,"resolveWorkspaceInputs");var SCHEMA_VERSION=1;var MAX_SECONDARY_WORKSPACES=MAX_CONFIGURED_REGISTERED_WORKSPACES-1;var MAX_STORE_BYTES=8*1024*1024;var MAX_WORKSPACE_DISPLAY_NAME_LENGTH=256;var LOCK_OPTIONS={realpath:false,stale:1e4,update:2e3,retries:{retries:120,minTimeout:10,maxTimeout:100,factor:1.2,randomize:true}};var WorkspaceDisplayNameValidationError=class extends Error{static{__name(this,"WorkspaceDisplayNameValidationError")}constructor(message){super(message);this.name="WorkspaceDisplayNameValidationError"}};function containsDisplayNameControlCharacter(value){for(const character of value){const codePoint=character.codePointAt(0);if(codePoint<=31||codePoint===127)return true}return false}__name(containsDisplayNameControlCharacter,"containsDisplayNameControlCharacter");function normalizeWorkspaceDisplayName(value){if(typeof value!=="string"){throw new WorkspaceDisplayNameValidationError("Workspace display name must be a string")}const trimmed=value.trim();if(trimmed.length>MAX_WORKSPACE_DISPLAY_NAME_LENGTH){throw new WorkspaceDisplayNameValidationError(`Workspace display name exceeds ${MAX_WORKSPACE_DISPLAY_NAME_LENGTH} characters`)}if(containsDisplayNameControlCharacter(trimmed)){throw new WorkspaceDisplayNameValidationError("Workspace display name contains control characters")}return trimmed.length===0?void 0:trimmed}__name(normalizeWorkspaceDisplayName,"normalizeWorkspaceDisplayName");var WorkspaceRegistrationStoreError=class extends Error{static{__name(this,"WorkspaceRegistrationStoreError")}constructor(message){super(message);this.name="WorkspaceRegistrationStoreError"}};var WorkspaceRegistrationStoreLimitError=class extends WorkspaceRegistrationStoreError{static{__name(this,"WorkspaceRegistrationStoreLimitError")}};var WorkspaceRegistrationStoreTooLargeError=class extends WorkspaceRegistrationStoreError{static{__name(this,"WorkspaceRegistrationStoreTooLargeError")}};var WorkspaceRegistrationStoreCommittedError=class extends WorkspaceRegistrationStoreError{static{__name(this,"WorkspaceRegistrationStoreCommittedError")}};function normalizedScopePath(primaryWorkspace){return os.platform()==="win32"?primaryWorkspace.toLowerCase():primaryWorkspace}__name(normalizedScopePath,"normalizedScopePath");function workspaceRegistrationScopeHash(primaryWorkspace){return createHash("sha256").update(normalizedScopePath(primaryWorkspace)).digest("hex")}__name(workspaceRegistrationScopeHash,"workspaceRegistrationScopeHash");function workspaceRegistrationId(workspace){return createHash("sha256").update(workspace).digest("hex").slice(0,16)}__name(workspaceRegistrationId,"workspaceRegistrationId");function getWorkspaceRegistrationStorePath(primaryWorkspace,qwenHome=getGlobalQwenDirLite()){return path.join(qwenHome,"daemon","workspaces",`${workspaceRegistrationScopeHash(primaryWorkspace)}.json`)}__name(getWorkspaceRegistrationStorePath,"getWorkspaceRegistrationStorePath");function emptySnapshot(primaryWorkspace){return{schemaVersion:SCHEMA_VERSION,primaryWorkspace,workspaces:[]}}__name(emptySnapshot,"emptySnapshot");function validateWorkspacePath(value,label){if(typeof value!=="string"||!path.isAbsolute(value)){throw new WorkspaceRegistrationStoreError(`${label} must be an absolute path`)}if(value.includes("\0")||value.length>MAX_WORKSPACE_PATH_LENGTH){throw new WorkspaceRegistrationStoreError(`${label} is invalid`)}return value}__name(validateWorkspacePath,"validateWorkspacePath");function validateStoredDisplayName(value,label){let displayName;try{displayName=normalizeWorkspaceDisplayName(value)}catch(err){throw new WorkspaceRegistrationStoreError(`${label} is invalid: ${err instanceof Error?err.message:String(err)}`)}if(displayName===void 0){throw new WorkspaceRegistrationStoreError(`${label} must not be empty`)}return displayName}__name(validateStoredDisplayName,"validateStoredDisplayName");function setSnapshotDisplayName(snapshot,registrationId,displayName){if(displayName===void 0){if(!snapshot.displayNames||!Object.hasOwn(snapshot.displayNames,registrationId)){return false}delete snapshot.displayNames[registrationId];if(Object.keys(snapshot.displayNames).length===0){delete snapshot.displayNames}return true}if(snapshot.displayNames?.[registrationId]===displayName)return false;snapshot.displayNames??={};snapshot.displayNames[registrationId]=displayName;return true}__name(setSnapshotDisplayName,"setSnapshotDisplayName");function parseSnapshot(raw,primaryWorkspace){let value;try{value=JSON.parse(raw)}catch{throw new WorkspaceRegistrationStoreError("Workspace registration store contains malformed JSON")}if(typeof value!=="object"||value===null||Array.isArray(value)){throw new WorkspaceRegistrationStoreError("Workspace registration store root must be an object")}const record=value;if(record["schemaVersion"]!==SCHEMA_VERSION){throw new WorkspaceRegistrationStoreError(`Unsupported workspace registration schema ${String(record["schemaVersion"])}`)}const storedPrimary=validateWorkspacePath(record["primaryWorkspace"],"primaryWorkspace");if(normalizedScopePath(storedPrimary)!==normalizedScopePath(primaryWorkspace)){throw new WorkspaceRegistrationStoreError("Workspace registration store primary does not match this daemon")}if(!Array.isArray(record["workspaces"])){throw new WorkspaceRegistrationStoreError("Workspace registration store workspaces must be an array")}if(record["workspaces"].length>MAX_SECONDARY_WORKSPACES){throw new WorkspaceRegistrationStoreError(`Workspace registration store exceeds ${MAX_SECONDARY_WORKSPACES} entries`)}const seen=new Set;const workspaces=record["workspaces"].map((entry,index)=>{const workspace=validateWorkspacePath(entry,`workspaces[${index}]`);const normalizedWorkspace=normalizedScopePath(workspace);if(normalizedWorkspace===normalizedScopePath(primaryWorkspace)){throw new WorkspaceRegistrationStoreError("Primary workspace cannot be stored as a secondary registration")}if(seen.has(normalizedWorkspace)){throw new WorkspaceRegistrationStoreError("Workspace registration store contains duplicate paths")}seen.add(normalizedWorkspace);return workspace});const rawDisplayNames=record["displayNames"];let displayNames;if(rawDisplayNames!==void 0){if(typeof rawDisplayNames!=="object"||rawDisplayNames===null||Array.isArray(rawDisplayNames)){throw new WorkspaceRegistrationStoreError("Workspace registration store displayNames must be an object")}const registrationIds=new Set(workspaces.map(workspaceRegistrationId));for(const[registrationId,value2]of Object.entries(rawDisplayNames)){if(!registrationIds.has(registrationId)){throw new WorkspaceRegistrationStoreError(`Workspace registration store displayNames contains unknown registration id ${JSON.stringify(registrationId)}`)}displayNames??={};displayNames[registrationId]=validateStoredDisplayName(value2,`displayNames[${JSON.stringify(registrationId)}]`)}}return{schemaVersion:SCHEMA_VERSION,primaryWorkspace,workspaces,...displayNames?{displayNames}:{}}}__name(parseSnapshot,"parseSnapshot");var updateChains=new Map;async function withInProcessLock(filePath,work){const previous=updateChains.get(filePath)??Promise.resolve();const next=previous.then(work,work);const settled=next.catch(()=>void 0).finally(()=>{if(updateChains.get(filePath)===settled)updateChains.delete(filePath)});updateChains.set(filePath,settled);return next}__name(withInProcessLock,"withInProcessLock");function compromisedLockError(){return new WorkspaceRegistrationStoreError("Workspace registration store lock was compromised")}__name(compromisedLockError,"compromisedLockError");async function acquireFileLock(filePath){await fs.mkdir(path.dirname(filePath),{recursive:true,mode:448});let compromised=false;const release=await import_proper_lockfile.default.lock(filePath,{...LOCK_OPTIONS,onCompromised:__name(()=>{compromised=true},"onCompromised")});return{assertOwned:__name(()=>{if(compromised)throw compromisedLockError()},"assertOwned"),release:__name(async()=>{try{await release()}catch(err){if(!compromised)throw err}if(compromised)throw compromisedLockError()},"release")}}__name(acquireFileLock,"acquireFileLock");var WorkspaceRegistrationStore=class{constructor(primaryWorkspace,qwenHome){this.primaryWorkspace=primaryWorkspace;validateWorkspacePath(primaryWorkspace,"primaryWorkspace");this.filePath=getWorkspaceRegistrationStorePath(primaryWorkspace,qwenHome)}static{__name(this,"WorkspaceRegistrationStore")}filePath;async read(){try{const entry=await fs.lstat(this.filePath);if(entry.isSymbolicLink()||!entry.isFile()){throw new WorkspaceRegistrationStoreError("Workspace registration store must be a regular file")}}catch(err){if(err.code==="ENOENT"){return emptySnapshot(this.primaryWorkspace)}throw err}let file;try{file=await openNoFollow(this.filePath)}catch(err){if(err.code==="ENOENT"){return emptySnapshot(this.primaryWorkspace)}if(isUnverifiableIdentityError(err)){throw new WorkspaceRegistrationStoreError("Workspace registration store identity could not be verified")}if(err.code==="ELOOP"){throw new WorkspaceRegistrationStoreError("Workspace registration store must be a regular file")}throw err}try{const stat=await file.stat();if(!stat.isFile()){throw new WorkspaceRegistrationStoreError("Workspace registration store must be a regular file")}if(stat.size>MAX_STORE_BYTES){throw new WorkspaceRegistrationStoreTooLargeError(`Workspace registration store exceeds ${MAX_STORE_BYTES} bytes`)}let buffer=Buffer.alloc(Math.max(1,Math.min(stat.size+1,MAX_STORE_BYTES+1)));let totalBytesRead=0;for(;;){if(totalBytesRead===buffer.length){if(totalBytesRead>MAX_STORE_BYTES)break;const grown=Buffer.alloc(Math.min(MAX_STORE_BYTES+1,Math.max(buffer.length*2,totalBytesRead+1)));buffer.copy(grown,0,0,totalBytesRead);buffer=grown}const{bytesRead}=await file.read(buffer,totalBytesRead,buffer.length-totalBytesRead,totalBytesRead);if(bytesRead===0)break;totalBytesRead+=bytesRead}if(totalBytesRead>MAX_STORE_BYTES){throw new WorkspaceRegistrationStoreTooLargeError(`Workspace registration store exceeds ${MAX_STORE_BYTES} bytes`)}return parseSnapshot(buffer.toString("utf8",0,totalBytesRead),this.primaryWorkspace)}finally{await file.close()}}async add(workspace,displayName,maxRegisteredWorkspaces=MAX_REGISTERED_WORKSPACES){const maxSecondaries=resolveMaxRegisteredWorkspaces(maxRegisteredWorkspaces,{})-1;validateWorkspacePath(workspace,"workspace");const normalizedDisplayName=displayName===void 0?void 0:normalizeWorkspaceDisplayName(displayName);if(normalizedScopePath(workspace)===normalizedScopePath(this.primaryWorkspace)){throw new WorkspaceRegistrationStoreError("Primary workspace cannot be stored as a secondary registration")}return this.update(snapshot=>{const normalizedWorkspace=normalizedScopePath(workspace);if(snapshot.workspaces.some(stored=>normalizedScopePath(stored)===normalizedWorkspace)){return false}if(snapshot.workspaces.length>=maxSecondaries){throw new WorkspaceRegistrationStoreLimitError(`Workspace registration store limit of ${maxSecondaries} reached`)}snapshot.workspaces.push(workspace);if(normalizedDisplayName!==void 0){snapshot.displayNames??={};snapshot.displayNames[workspaceRegistrationId(workspace)]=normalizedDisplayName}return true})}async removeById(id){return await this.removeByIds([id])>0}async setDisplayNameByIds(ids,displayName){const normalizedDisplayName=displayName===void 0?void 0:normalizeWorkspaceDisplayName(displayName);const requested=new Set(ids);if(requested.size===0)return 0;let matched=0;await this.update(snapshot=>{let changed=false;for(const workspace of snapshot.workspaces){const registrationId=workspaceRegistrationId(workspace);if(!requested.has(registrationId))continue;matched++;changed=setSnapshotDisplayName(snapshot,registrationId,normalizedDisplayName)||changed}return changed});return matched}async removeByIds(ids){const requested=new Set(ids);if(requested.size===0)return 0;let removed=0;await this.update(snapshot=>{const removedIds=new Set;const retained=snapshot.workspaces.filter(workspace=>{const registrationId=workspaceRegistrationId(workspace);if(!requested.has(registrationId))return true;removed++;removedIds.add(registrationId);return false});if(removed===0)return false;snapshot.workspaces.splice(0,snapshot.workspaces.length,...retained);for(const registrationId of removedIds){setSnapshotDisplayName(snapshot,registrationId,void 0)}return true});return removed}async update(mutate){const{atomicWriteFile}=await import("./deferred-core-runtime-CVCQU7O4.js");return withInProcessLock(this.filePath,async()=>{const lock=await acquireFileLock(this.filePath);let committed=false;let changed=false;let workError;try{const snapshot=await this.read();lock.assertOwned();changed=mutate(snapshot);if(changed){const serialized=`${JSON.stringify(snapshot,null,2)}
4
4
  `;if(Buffer.byteLength(serialized,"utf8")>MAX_STORE_BYTES){throw new WorkspaceRegistrationStoreTooLargeError(`Workspace registration store exceeds ${MAX_STORE_BYTES} bytes`)}lock.assertOwned();await atomicWriteFile(this.filePath,serialized,{mode:384,forceMode:true,noFollow:true});committed=true}}catch(err){workError=err}let releaseError;try{await lock.release()}catch(err){releaseError=committed?new WorkspaceRegistrationStoreCommittedError(`Workspace registration update committed but lock release failed: ${err instanceof Error?err.message:String(err)}`):err}if(workError instanceof Error&&releaseError!==void 0&&workError.cause===void 0){workError.cause=releaseError}if(workError!==void 0)throw workError;if(releaseError!==void 0)throw releaseError;return changed})}};export{MAX_REGISTERED_WORKSPACES,resolveMaxRegisteredWorkspaces,resolveWorkspaceInputs,MAX_WORKSPACE_DISPLAY_NAME_LENGTH,WorkspaceDisplayNameValidationError,normalizeWorkspaceDisplayName,WorkspaceRegistrationStoreError,WorkspaceRegistrationStoreLimitError,WorkspaceRegistrationStoreTooLargeError,WorkspaceRegistrationStoreCommittedError,workspaceRegistrationScopeHash,workspaceRegistrationId,getWorkspaceRegistrationStorePath,WorkspaceRegistrationStore};
5
5
  /**
6
6
  * @license