@bryanhu/codexly 0.3.0 → 0.5.0

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 (253) hide show
  1. package/CHANGELOG.md +45 -1
  2. package/README.md +3 -1
  3. package/README.zh-CN.md +3 -1
  4. package/dist/{chunk-Y7HG5THF.js → chunk-4PA52XB7.js} +938 -83
  5. package/dist/{chunk-VZLNYRY3.js → chunk-AGMOIRX4.js} +1 -1
  6. package/dist/{chunk-3OBVX5TN.js → chunk-RNTA4MFS.js} +9 -1
  7. package/dist/{chunk-6HXWAD7A.js → chunk-UAJCHOZK.js} +1260 -466
  8. package/dist/{chunk-DR6HEQ7V.js → chunk-ZSWNUDDK.js} +123 -7
  9. package/dist/cli.js +10 -6
  10. package/dist/client/index.js +35 -5
  11. package/dist/core/index.js +1 -1
  12. package/dist/protocol/index.js +1 -1
  13. package/dist/providers/codex/index.js +3 -3
  14. package/dist/server/index.js +5 -5
  15. package/dist/sqlite-state-worker.js +117 -7
  16. package/dist/web/.vite/manifest.json +406 -273
  17. package/dist/web/.vite/manifest.json.br +0 -0
  18. package/dist/web/.vite/manifest.json.gz +0 -0
  19. package/dist/web/assets/button-group-GolVMDRO.js +1 -0
  20. package/dist/web/assets/button-group-GolVMDRO.js.br +0 -0
  21. package/dist/web/assets/button-group-GolVMDRO.js.gz +0 -0
  22. package/dist/web/assets/check-DufG-ZUa.js +1 -0
  23. package/dist/web/assets/check-DufG-ZUa.js.br +0 -0
  24. package/dist/web/assets/check-DufG-ZUa.js.gz +0 -0
  25. package/dist/web/assets/checkbox-37DlWLBa.js +1 -0
  26. package/dist/web/assets/checkbox-37DlWLBa.js.br +0 -0
  27. package/dist/web/assets/checkbox-37DlWLBa.js.gz +0 -0
  28. package/dist/web/assets/{chunk-BO2N2NFS-Cv0xdEIU.js → chunk-BO2N2NFS-C9R62W5i.js} +4 -4
  29. package/dist/web/assets/chunk-BO2N2NFS-C9R62W5i.js.br +0 -0
  30. package/dist/web/assets/chunk-BO2N2NFS-C9R62W5i.js.gz +0 -0
  31. package/dist/web/assets/{code-highlighter-XA2cEb7n.js → code-highlighter-B_sQt157.js} +1 -1
  32. package/dist/web/assets/code-highlighter-B_sQt157.js.br +0 -0
  33. package/dist/web/assets/code-highlighter-B_sQt157.js.gz +0 -0
  34. package/dist/web/assets/code-languages-lQDTaxNN.js +2 -0
  35. package/dist/web/assets/code-languages-lQDTaxNN.js.br +0 -0
  36. package/dist/web/assets/code-languages-lQDTaxNN.js.gz +0 -0
  37. package/dist/web/assets/context-menu-Dag_JnAP.js +1 -0
  38. package/dist/web/assets/context-menu-Dag_JnAP.js.br +0 -0
  39. package/dist/web/assets/context-menu-Dag_JnAP.js.gz +0 -0
  40. package/dist/web/assets/cpp-DrC1WCyF.js +1 -0
  41. package/dist/web/assets/cpp-DrC1WCyF.js.br +0 -0
  42. package/dist/web/assets/cpp-DrC1WCyF.js.gz +0 -0
  43. package/dist/web/assets/cpp-DuI2J82L.js +1 -0
  44. package/dist/web/assets/cpp-DuI2J82L.js.br +0 -0
  45. package/dist/web/assets/cpp-DuI2J82L.js.gz +0 -0
  46. package/dist/web/assets/dist-D75B5EEW.js +1 -0
  47. package/dist/web/assets/dist-D75B5EEW.js.br +0 -0
  48. package/dist/web/assets/dist-D75B5EEW.js.gz +0 -0
  49. package/dist/web/assets/dist-rI8Y0b5t.js +1 -0
  50. package/dist/web/assets/dist-rI8Y0b5t.js.br +0 -0
  51. package/dist/web/assets/dist-rI8Y0b5t.js.gz +0 -0
  52. package/dist/web/assets/{engine-compile-DQ0HPfe0.js → engine-compile-Bqjaa_8Z.js} +14 -14
  53. package/dist/web/assets/engine-compile-Bqjaa_8Z.js.br +0 -0
  54. package/dist/web/assets/engine-compile-Bqjaa_8Z.js.gz +0 -0
  55. package/dist/web/assets/es2015-Bu8fG2VP.js +41 -0
  56. package/dist/web/assets/es2015-Bu8fG2VP.js.br +0 -0
  57. package/dist/web/assets/es2015-Bu8fG2VP.js.gz +0 -0
  58. package/dist/web/assets/file-code-corner-BfUyC-bF.js +1 -0
  59. package/dist/web/assets/file-code-corner-BfUyC-bF.js.br +1 -0
  60. package/dist/web/assets/file-code-corner-BfUyC-bF.js.gz +0 -0
  61. package/dist/web/assets/file-navigation-view-preference-De4_ih3I.js +1 -0
  62. package/dist/web/assets/file-navigation-view-preference-De4_ih3I.js.br +0 -0
  63. package/dist/web/assets/file-navigation-view-preference-De4_ih3I.js.gz +0 -0
  64. package/dist/web/assets/file-review-dialog-D6itznUk.js +2 -0
  65. package/dist/web/assets/file-review-dialog-D6itznUk.js.br +0 -0
  66. package/dist/web/assets/file-review-dialog-D6itznUk.js.gz +0 -0
  67. package/dist/web/assets/file-tree-CFUaXf_b.js +1 -0
  68. package/dist/web/assets/file-tree-CFUaXf_b.js.br +0 -0
  69. package/dist/web/assets/file-tree-CFUaXf_b.js.gz +0 -0
  70. package/dist/web/assets/git-commit-horizontal-BsjVPZ9W.js +1 -0
  71. package/dist/web/assets/git-commit-horizontal-BsjVPZ9W.js.br +0 -0
  72. package/dist/web/assets/git-commit-horizontal-BsjVPZ9W.js.gz +0 -0
  73. package/dist/web/assets/git-history-panel-DIr_4cfP.js +2 -0
  74. package/dist/web/assets/git-history-panel-DIr_4cfP.js.br +0 -0
  75. package/dist/web/assets/git-history-panel-DIr_4cfP.js.gz +0 -0
  76. package/dist/web/assets/global-settings-dialog-CWeXTy89.js +1 -0
  77. package/dist/web/assets/global-settings-dialog-CWeXTy89.js.br +0 -0
  78. package/dist/web/assets/global-settings-dialog-CWeXTy89.js.gz +0 -0
  79. package/dist/web/assets/grammar-cpp-support-CH6jZNJS.js +1 -0
  80. package/dist/web/assets/grammar-cpp-support-CH6jZNJS.js.br +0 -0
  81. package/dist/web/assets/grammar-cpp-support-CH6jZNJS.js.gz +0 -0
  82. package/dist/web/assets/{highlighted-body-OFNGDK62-3Xd1uGCw.js → highlighted-body-OFNGDK62-J6vd4AIe.js} +1 -1
  83. package/dist/web/assets/highlighted-body-OFNGDK62-J6vd4AIe.js.br +0 -0
  84. package/dist/web/assets/highlighted-body-OFNGDK62-J6vd4AIe.js.gz +0 -0
  85. package/dist/web/assets/index-CMCPev5S.js +4 -0
  86. package/dist/web/assets/index-CMCPev5S.js.br +0 -0
  87. package/dist/web/assets/index-CMCPev5S.js.gz +0 -0
  88. package/dist/web/assets/index-CcSDzrvO.css +2 -0
  89. package/dist/web/assets/index-CcSDzrvO.css.br +0 -0
  90. package/dist/web/assets/index-CcSDzrvO.css.gz +0 -0
  91. package/dist/web/assets/lazy-message-response-kziUJe0I.js +2 -0
  92. package/dist/web/assets/lazy-message-response-kziUJe0I.js.br +0 -0
  93. package/dist/web/assets/lazy-message-response-kziUJe0I.js.gz +0 -0
  94. package/dist/web/assets/loader-circle-DUyazd0N.js +1 -0
  95. package/dist/web/assets/loader-circle-DUyazd0N.js.br +0 -0
  96. package/dist/web/assets/loader-circle-DUyazd0N.js.gz +0 -0
  97. package/dist/web/assets/mermaid-GHXKKRXX-6KIGYUKQ.js +1 -0
  98. package/dist/web/assets/mermaid-GHXKKRXX-6KIGYUKQ.js.br +0 -0
  99. package/dist/web/assets/mermaid-GHXKKRXX-6KIGYUKQ.js.gz +0 -0
  100. package/dist/web/assets/message-response-BH1WLiOG.js +7 -0
  101. package/dist/web/assets/message-response-BH1WLiOG.js.br +0 -0
  102. package/dist/web/assets/message-response-BH1WLiOG.js.gz +0 -0
  103. package/dist/web/assets/{patch-diff-viewer-DHfvCO4S.js → patch-diff-viewer-BP7d9z00.js} +2 -2
  104. package/dist/web/assets/patch-diff-viewer-BP7d9z00.js.br +0 -0
  105. package/dist/web/assets/patch-diff-viewer-BP7d9z00.js.gz +0 -0
  106. package/dist/web/assets/{perl-Br95gH8g.js → perl-C4NAnH_t.js} +1 -1
  107. package/dist/web/assets/perl-C4NAnH_t.js.br +0 -0
  108. package/dist/web/assets/{perl-Br95gH8g.js.gz → perl-C4NAnH_t.js.gz} +0 -0
  109. package/dist/web/assets/{php-CYrBA5iX.js → php-CQT4wx5i.js} +1 -1
  110. package/dist/web/assets/php-CQT4wx5i.js.br +0 -0
  111. package/dist/web/assets/{php-CYrBA5iX.js.gz → php-CQT4wx5i.js.gz} +0 -0
  112. package/dist/web/assets/project-file-popup-page-BqEZEv1s.js +1 -0
  113. package/dist/web/assets/project-file-popup-page-BqEZEv1s.js.br +0 -0
  114. package/dist/web/assets/project-file-popup-page-BqEZEv1s.js.gz +0 -0
  115. package/dist/web/assets/project-source-panel-BkRa6eOs.js +3 -0
  116. package/dist/web/assets/project-source-panel-BkRa6eOs.js.br +0 -0
  117. package/dist/web/assets/project-source-panel-BkRa6eOs.js.gz +0 -0
  118. package/dist/web/assets/prompt-input-controls-5tCLhg2X.js +1 -0
  119. package/dist/web/assets/prompt-input-controls-5tCLhg2X.js.br +0 -0
  120. package/dist/web/assets/prompt-input-controls-5tCLhg2X.js.gz +0 -0
  121. package/dist/web/assets/prompt-reference-token-Dnq6GpIQ.js +1 -0
  122. package/dist/web/assets/prompt-reference-token-Dnq6GpIQ.js.br +3 -0
  123. package/dist/web/assets/prompt-reference-token-Dnq6GpIQ.js.gz +0 -0
  124. package/dist/web/assets/provider-connection-queries-BPczkhUT.js +1 -0
  125. package/dist/web/assets/provider-connection-queries-BPczkhUT.js.br +0 -0
  126. package/dist/web/assets/provider-connection-queries-BPczkhUT.js.gz +0 -0
  127. package/dist/web/assets/{ruby-CbXu8Ywv.js → ruby-Oh3ZbUP2.js} +1 -1
  128. package/dist/web/assets/ruby-Oh3ZbUP2.js.br +0 -0
  129. package/dist/web/assets/ruby-Oh3ZbUP2.js.gz +0 -0
  130. package/dist/web/assets/{shiki-bundle-CNYWcrCX.js → shiki-bundle-VSjMZiOC.js} +1 -1
  131. package/dist/web/assets/shiki-bundle-VSjMZiOC.js.br +0 -0
  132. package/dist/web/assets/shiki-bundle-VSjMZiOC.js.gz +0 -0
  133. package/dist/web/assets/swift-CyEgAFGc.js +1 -0
  134. package/dist/web/assets/swift-CyEgAFGc.js.br +0 -0
  135. package/dist/web/assets/swift-CyEgAFGc.js.gz +0 -0
  136. package/dist/web/assets/tooltip-jGsHGylL.js +1 -0
  137. package/dist/web/assets/tooltip-jGsHGylL.js.br +0 -0
  138. package/dist/web/assets/tooltip-jGsHGylL.js.gz +0 -0
  139. package/dist/web/assets/upload-D6X3pnK5.js +1 -0
  140. package/dist/web/assets/upload-D6X3pnK5.js.br +0 -0
  141. package/dist/web/assets/upload-D6X3pnK5.js.gz +0 -0
  142. package/dist/web/assets/useInfiniteQuery-Bs3l5hx7.js +1 -0
  143. package/dist/web/assets/useInfiniteQuery-Bs3l5hx7.js.br +0 -0
  144. package/dist/web/assets/useInfiniteQuery-Bs3l5hx7.js.gz +0 -0
  145. package/dist/web/assets/{vue-BpAUjojh.js → vue-BcFuTOIy.js} +1 -1
  146. package/dist/web/assets/vue-BcFuTOIy.js.br +0 -0
  147. package/dist/web/assets/vue-BcFuTOIy.js.gz +0 -0
  148. package/dist/web/assets/workbench-inspector-changes-BbHDvE9x.js +2 -0
  149. package/dist/web/assets/workbench-inspector-changes-BbHDvE9x.js.br +0 -0
  150. package/dist/web/assets/workbench-inspector-changes-BbHDvE9x.js.gz +0 -0
  151. package/dist/web/assets/workbench-pet-canvas-DRzsdZ1c.js +1 -0
  152. package/dist/web/assets/workbench-pet-canvas-DRzsdZ1c.js.br +0 -0
  153. package/dist/web/assets/workbench-pet-canvas-DRzsdZ1c.js.gz +0 -0
  154. package/dist/web/assets/workbench-shell-wnOOfeVI.js +15 -0
  155. package/dist/web/assets/workbench-shell-wnOOfeVI.js.br +0 -0
  156. package/dist/web/assets/workbench-shell-wnOOfeVI.js.gz +0 -0
  157. package/dist/web/index.html +12 -8
  158. package/dist/web/index.html.br +0 -0
  159. package/dist/web/index.html.gz +0 -0
  160. package/package.json +7 -10
  161. package/dist/web/assets/button-B0Zy5xUw.js +0 -1
  162. package/dist/web/assets/button-B0Zy5xUw.js.br +0 -0
  163. package/dist/web/assets/button-B0Zy5xUw.js.gz +0 -0
  164. package/dist/web/assets/button-group-Czp67RFV.js +0 -1
  165. package/dist/web/assets/button-group-Czp67RFV.js.br +0 -0
  166. package/dist/web/assets/button-group-Czp67RFV.js.gz +0 -0
  167. package/dist/web/assets/checkbox-J-dVFT8h.js +0 -1
  168. package/dist/web/assets/checkbox-J-dVFT8h.js.br +0 -0
  169. package/dist/web/assets/checkbox-J-dVFT8h.js.gz +0 -0
  170. package/dist/web/assets/chunk-BO2N2NFS-Cv0xdEIU.js.br +0 -0
  171. package/dist/web/assets/chunk-BO2N2NFS-Cv0xdEIU.js.gz +0 -0
  172. package/dist/web/assets/code-highlighter-XA2cEb7n.js.br +0 -0
  173. package/dist/web/assets/code-highlighter-XA2cEb7n.js.gz +0 -0
  174. package/dist/web/assets/code-languages-B1bG8xP9.js +0 -2
  175. package/dist/web/assets/code-languages-B1bG8xP9.js.br +0 -0
  176. package/dist/web/assets/code-languages-B1bG8xP9.js.gz +0 -0
  177. package/dist/web/assets/cpp-BcHBJY00.js +0 -1
  178. package/dist/web/assets/cpp-BcHBJY00.js.br +0 -0
  179. package/dist/web/assets/cpp-BcHBJY00.js.gz +0 -0
  180. package/dist/web/assets/cpp-CIkEvbIe.js +0 -1
  181. package/dist/web/assets/cpp-CIkEvbIe.js.br +0 -0
  182. package/dist/web/assets/cpp-CIkEvbIe.js.gz +0 -0
  183. package/dist/web/assets/engine-compile-DQ0HPfe0.js.br +0 -0
  184. package/dist/web/assets/engine-compile-DQ0HPfe0.js.gz +0 -0
  185. package/dist/web/assets/es2015-D1QRD4rq.js +0 -41
  186. package/dist/web/assets/es2015-D1QRD4rq.js.br +0 -0
  187. package/dist/web/assets/es2015-D1QRD4rq.js.gz +0 -0
  188. package/dist/web/assets/file-fDjkn3KE.js +0 -1
  189. package/dist/web/assets/file-fDjkn3KE.js.br +0 -2
  190. package/dist/web/assets/file-fDjkn3KE.js.gz +0 -0
  191. package/dist/web/assets/file-review-dialog-a4LVk4QA.js +0 -2
  192. package/dist/web/assets/file-review-dialog-a4LVk4QA.js.br +0 -0
  193. package/dist/web/assets/file-review-dialog-a4LVk4QA.js.gz +0 -0
  194. package/dist/web/assets/file-tree-Dh8mZi4H.js +0 -1
  195. package/dist/web/assets/file-tree-Dh8mZi4H.js.br +0 -0
  196. package/dist/web/assets/file-tree-Dh8mZi4H.js.gz +0 -0
  197. package/dist/web/assets/git-commit-horizontal-DqCudnTd.js +0 -1
  198. package/dist/web/assets/git-commit-horizontal-DqCudnTd.js.br +0 -0
  199. package/dist/web/assets/git-commit-horizontal-DqCudnTd.js.gz +0 -0
  200. package/dist/web/assets/git-history-panel-C0BqsVJw.js +0 -2
  201. package/dist/web/assets/git-history-panel-C0BqsVJw.js.br +0 -0
  202. package/dist/web/assets/git-history-panel-C0BqsVJw.js.gz +0 -0
  203. package/dist/web/assets/global-settings-dialog-DAk0qzab.js +0 -1
  204. package/dist/web/assets/global-settings-dialog-DAk0qzab.js.br +0 -0
  205. package/dist/web/assets/global-settings-dialog-DAk0qzab.js.gz +0 -0
  206. package/dist/web/assets/grammar-cpp-support-CV8oNpIY.js +0 -1
  207. package/dist/web/assets/grammar-cpp-support-CV8oNpIY.js.br +0 -0
  208. package/dist/web/assets/grammar-cpp-support-CV8oNpIY.js.gz +0 -0
  209. package/dist/web/assets/highlighted-body-OFNGDK62-3Xd1uGCw.js.br +0 -0
  210. package/dist/web/assets/highlighted-body-OFNGDK62-3Xd1uGCw.js.gz +0 -0
  211. package/dist/web/assets/index-C9MtcGVc.js +0 -4
  212. package/dist/web/assets/index-C9MtcGVc.js.br +0 -0
  213. package/dist/web/assets/index-C9MtcGVc.js.gz +0 -0
  214. package/dist/web/assets/index-DAs_avwK.css +0 -2
  215. package/dist/web/assets/index-DAs_avwK.css.br +0 -0
  216. package/dist/web/assets/index-DAs_avwK.css.gz +0 -0
  217. package/dist/web/assets/lazy-message-response-BDqsH4Ww.js +0 -2
  218. package/dist/web/assets/lazy-message-response-BDqsH4Ww.js.br +0 -0
  219. package/dist/web/assets/lazy-message-response-BDqsH4Ww.js.gz +0 -0
  220. package/dist/web/assets/mermaid-GHXKKRXX-Cp6mRHuL.js +0 -1
  221. package/dist/web/assets/mermaid-GHXKKRXX-Cp6mRHuL.js.br +0 -0
  222. package/dist/web/assets/mermaid-GHXKKRXX-Cp6mRHuL.js.gz +0 -0
  223. package/dist/web/assets/message-response-DyFE9GSy.js +0 -7
  224. package/dist/web/assets/message-response-DyFE9GSy.js.br +0 -0
  225. package/dist/web/assets/message-response-DyFE9GSy.js.gz +0 -0
  226. package/dist/web/assets/patch-diff-viewer-DHfvCO4S.js.br +0 -0
  227. package/dist/web/assets/patch-diff-viewer-DHfvCO4S.js.gz +0 -0
  228. package/dist/web/assets/perl-Br95gH8g.js.br +0 -0
  229. package/dist/web/assets/php-CYrBA5iX.js.br +0 -0
  230. package/dist/web/assets/prompt-input-controls-CLj9lxlf.js +0 -1
  231. package/dist/web/assets/prompt-input-controls-CLj9lxlf.js.br +0 -0
  232. package/dist/web/assets/prompt-input-controls-CLj9lxlf.js.gz +0 -0
  233. package/dist/web/assets/prompt-reference-token-Cxx6C-IR.js +0 -1
  234. package/dist/web/assets/prompt-reference-token-Cxx6C-IR.js.br +0 -0
  235. package/dist/web/assets/prompt-reference-token-Cxx6C-IR.js.gz +0 -0
  236. package/dist/web/assets/provider-connection-queries-C2Fn0xx2.js +0 -1
  237. package/dist/web/assets/provider-connection-queries-C2Fn0xx2.js.br +0 -0
  238. package/dist/web/assets/provider-connection-queries-C2Fn0xx2.js.gz +0 -0
  239. package/dist/web/assets/ruby-CbXu8Ywv.js.br +0 -0
  240. package/dist/web/assets/ruby-CbXu8Ywv.js.gz +0 -0
  241. package/dist/web/assets/shiki-bundle-CNYWcrCX.js.br +0 -0
  242. package/dist/web/assets/shiki-bundle-CNYWcrCX.js.gz +0 -0
  243. package/dist/web/assets/swift-DonLKvLd.js +0 -1
  244. package/dist/web/assets/swift-DonLKvLd.js.br +0 -0
  245. package/dist/web/assets/swift-DonLKvLd.js.gz +0 -0
  246. package/dist/web/assets/vue-BpAUjojh.js.br +0 -0
  247. package/dist/web/assets/vue-BpAUjojh.js.gz +0 -0
  248. package/dist/web/assets/workbench-inspector-changes-fibkZGwp.js +0 -1
  249. package/dist/web/assets/workbench-inspector-changes-fibkZGwp.js.br +0 -0
  250. package/dist/web/assets/workbench-inspector-changes-fibkZGwp.js.gz +0 -0
  251. package/dist/web/assets/workbench-shell-eo1pFJFk.js +0 -13
  252. package/dist/web/assets/workbench-shell-eo1pFJFk.js.br +0 -0
  253. package/dist/web/assets/workbench-shell-eo1pFJFk.js.gz +0 -0
@@ -1,16 +1,16 @@
1
1
  import { createRequire } from 'node:module';
2
- import { value_exports } from './chunk-VZLNYRY3.js';
3
- import { require_pino, CodexProtocolMappingError, CodexProviderConnectionError, RpcConnectionClosedError, RpcProtocolError, RpcResponseError, RpcTimeoutError } from './chunk-Y7HG5THF.js';
4
- import { PendingRequestResolutionError } from './chunk-3OBVX5TN.js';
5
- import { AGENT_FILE_EXTENSIONS, AGENT_FILE_MEDIA_TYPES, MAX_AGENT_IMAGES, MAX_AGENT_IMAGE_TOTAL_BYTES, MAX_AGENT_FILE_TOTAL_BYTES, DEFAULT_COMMIT_MESSAGE_MODEL, TEMPORARY_TASK_API_PATH, TEMPORARY_TASK_SCOPE_ID, MAX_AGENT_FILE_BYTES, AccessStatusResponseSchema, PairAccessRequestSchema, HealthResponseSchema, AppInfoResponseSchema, AgentMutationErrorSchema, InstallAppUpdateResponseSchema, InstallAppUpdateRequestSchema, EventStreamMetricsResponseSchema, AgentCapabilitiesSchema, AgentModelPageSchema, AgentGlobalSettingsResponseSchema, AgentGlobalSettingsSchema, MAX_AGENT_IMAGE_BYTES, MAX_AGENT_TEXT_BYTES, AgentProviderConnectionStatusSchema, StartOfficialProviderLoginResponseSchema, StartOfficialProviderLoginRequestSchema, AgentProviderConnectionMutationResponseSchema, CancelProviderLoginRequestSchema, ConfigureCustomProviderResponseSchema, ConfigureCustomProviderRequestSchema, ProjectPageSchema, HostFileListingSchema, HostFileQuerySchema, ProjectDirectoryListingSchema, ProjectDirectoryQuerySchema, ProjectOpenCapabilitiesResponseSchema, OpenProjectResponseSchema, ProjectRootQuerySchema, OpenProjectRequestSchema, ReorderProjectsResponseSchema, ReorderProjectsRequestSchema, AgentSkillPageSchema, AgentProjectDefaultsResponseSchema, AgentProjectDefaultsSchema, AddProjectResponseSchema, AddProjectRequestSchema, RenameProjectResponseSchema, RenameProjectRequestSchema, RemoveProjectResponseSchema, RemoveProjectRequestSchema, AgentTaskPageSchema, UnsubscribeAgentTaskResponseSchema, AgentTaskSnapshotResponseSchema, AgentMcpServerPageSchema, AgentBackgroundTerminalPageSchema, TerminateAgentBackgroundTerminalResponseSchema, PinAgentTaskResponseSchema, PinAgentTaskRequestSchema, RenameAgentTaskResponseSchema, RenameAgentTaskRequestSchema, ArchiveAgentTaskResponseSchema, ArchiveAgentTaskRequestSchema, UnarchiveAgentTaskResponseSchema, UnarchiveAgentTaskRequestSchema, DeleteAgentTaskResponseSchema, DeleteAgentTaskRequestSchema, StartAgentTaskResponseSchema, StartAgentTaskRequestSchema, StartAgentTurnResponseSchema, StartAgentTurnRequestSchema, SteerAgentTurnResponseSchema, SteerAgentTurnRequestSchema, InterruptAgentTurnResponseSchema, InterruptAgentTurnRequestSchema, ResolvePendingRequestResponseSchema, ResolvePendingRequestRequestSchema, AgentQueuedSubmissionPageSchema, AddAgentQueuedSubmissionResponseSchema, AddAgentQueuedSubmissionRequestSchema, UpdateAgentQueuedSubmissionResponseSchema, UpdateAgentQueuedSubmissionRequestSchema, DeleteAgentQueuedSubmissionResponseSchema, ReorderAgentQueuedSubmissionsResponseSchema, ReorderAgentQueuedSubmissionsRequestSchema, StartAgentQueuedSubmissionResponseSchema, StartAgentQueuedSubmissionRequestSchema, AgentProviderConnectionRecordSchema, ProjectGitStatusSchema, ProjectGitStatusQuerySchema, ProjectGitHistoryPageSchema, ProjectGitHistoryQuerySchema, ProjectGitCommitFilesPageSchema, ProjectGitCommitFilesQuerySchema, ProjectGitCommitFileDiffSchema, ProjectGitCommitFileDiffQuerySchema, SwitchProjectBranchRequestSchema, CreateProjectBranchRequestSchema, GenerateCommitMessageResponseSchema, GenerateCommitMessageRequestSchema, CommitProjectChangesResponseSchema, CommitProjectChangesRequestSchema, ProjectFileTreeSchema, ProjectFileTreeQuerySchema, ProjectFileSearchPageSchema, ProjectFileSearchQuerySchema, StopProjectFileSearchResponseSchema, StopProjectFileSearchRequestSchema, ProjectSourceFileQuerySchema, ProjectSourceFileSchema, AgentAttachmentUploadResponseSchema, HostFileKindSchema, ImportHostAttachmentRequestSchema, AgentAttachmentKindSchema, AgentTaskSettingsResponseSchema, AgentTaskSettingsSchema, ReloadAgentMcpServersResponseSchema, ReloadAgentMcpServersRequestSchema, ReviewAgentTaskResponseSchema, ReviewAgentTaskRequestSchema, CompactAgentTaskResponseSchema, CompactAgentTaskRequestSchema, ForkAgentTaskResponseSchema, ForkAgentTaskRequestSchema, UploadAgentFeedbackResponseSchema, UploadAgentFeedbackRequestSchema, OpenAgentTaskAttachmentResponseSchema, OpenAgentTaskAttachmentRequestSchema, UpdateAgentGoalResponseSchema, UpdateAgentGoalRequestSchema, ClearAgentGoalResponseSchema, ProjectGitWorktreePageSchema, ProjectWorktreeMutationResponseSchema, CreateProjectWorktreeRequestSchema, SwitchProjectWorktreeRequestSchema, MAX_EVENT_BATCH_SIZE } from './chunk-DR6HEQ7V.js';
2
+ import { value_exports } from './chunk-AGMOIRX4.js';
3
+ import { require_pino, require_safe_stable_stringify, CodexProtocolMappingError, CodexProviderConnectionError, RpcConnectionClosedError, RpcProtocolError, RpcResponseError, RpcTimeoutError } from './chunk-4PA52XB7.js';
4
+ import { WorkbenchPetProviderError, PendingRequestResolutionError } from './chunk-RNTA4MFS.js';
5
+ import { AGENT_FILE_EXTENSIONS, AGENT_FILE_MEDIA_TYPES, DEFAULT_COMMIT_MESSAGE_MODEL, TEMPORARY_TASK_API_PATH, TEMPORARY_TASK_SCOPE_ID, MAX_AGENT_FILE_BYTES, AccessStatusResponseSchema, PairAccessRequestSchema, HealthResponseSchema, AppInfoResponseSchema, AgentMutationErrorSchema, InstallAppUpdateResponseSchema, InstallAppUpdateRequestSchema, EventStreamMetricsResponseSchema, AgentCapabilitiesSchema, AgentModelPageSchema, AgentGlobalSettingsResponseSchema, AgentGlobalSettingsSchema, MAX_AGENT_IMAGE_BYTES, MAX_AGENT_TEXT_BYTES, AgentProviderConnectionStatusSchema, StartOfficialProviderLoginResponseSchema, StartOfficialProviderLoginRequestSchema, AgentProviderConnectionMutationResponseSchema, CancelProviderLoginRequestSchema, ConfigureCustomProviderResponseSchema, ConfigureCustomProviderRequestSchema, WorkbenchPetCatalogResponseSchema, WorkbenchPetDownloadResponseSchema, WorkbenchPetDownloadRequestSchema, ProjectPageSchema, HostFileListingSchema, HostFileQuerySchema, ProjectDirectoryListingSchema, ProjectDirectoryQuerySchema, ProjectOpenCapabilitiesResponseSchema, OpenProjectResponseSchema, ProjectRootQuerySchema, OpenProjectRequestSchema, ReorderProjectsResponseSchema, ReorderProjectsRequestSchema, AgentSkillPageSchema, AgentProjectDefaultsResponseSchema, AgentProjectDefaultsSchema, AddProjectResponseSchema, AddProjectRequestSchema, RenameProjectResponseSchema, RenameProjectRequestSchema, RemoveProjectResponseSchema, RemoveProjectRequestSchema, AgentTaskPageSchema, UnsubscribeAgentTaskResponseSchema, AgentTaskSnapshotResponseSchema, AgentMcpServerPageSchema, AgentBackgroundTerminalPageSchema, TerminateAgentBackgroundTerminalResponseSchema, PinAgentTaskResponseSchema, PinAgentTaskRequestSchema, RenameAgentTaskResponseSchema, RenameAgentTaskRequestSchema, ArchiveAgentTaskResponseSchema, ArchiveAgentTaskRequestSchema, UnarchiveAgentTaskResponseSchema, UnarchiveAgentTaskRequestSchema, DeleteAgentTaskResponseSchema, DeleteAgentTaskRequestSchema, StartAgentTaskResponseSchema, StartAgentTaskRequestSchema, StartAgentTurnResponseSchema, StartAgentTurnRequestSchema, SteerAgentTurnResponseSchema, SteerAgentTurnRequestSchema, InterruptAgentTurnResponseSchema, InterruptAgentTurnRequestSchema, ResolvePendingRequestResponseSchema, ResolvePendingRequestRequestSchema, AgentQueuedSubmissionPageSchema, AddAgentQueuedSubmissionResponseSchema, AddAgentQueuedSubmissionRequestSchema, UpdateAgentQueuedSubmissionResponseSchema, UpdateAgentQueuedSubmissionRequestSchema, DeleteAgentQueuedSubmissionResponseSchema, ReorderAgentQueuedSubmissionsResponseSchema, ReorderAgentQueuedSubmissionsRequestSchema, StartAgentQueuedSubmissionResponseSchema, StartAgentQueuedSubmissionRequestSchema, AgentPromptInputSchema, AgentProviderConnectionRecordSchema, MAX_AGENT_IMAGES, MAX_AGENT_IMAGE_TOTAL_BYTES, MAX_AGENT_FILE_TOTAL_BYTES, ProjectGitStatusSchema, ProjectGitStatusQuerySchema, ProjectGitHistoryPageSchema, ProjectGitHistoryQuerySchema, ProjectGitCommitFilesPageSchema, ProjectGitCommitFilesQuerySchema, ProjectGitCommitFileDiffSchema, ProjectGitCommitFileDiffQuerySchema, SwitchProjectBranchRequestSchema, CreateProjectBranchRequestSchema, GenerateCommitMessageResponseSchema, GenerateCommitMessageRequestSchema, CommitProjectChangesResponseSchema, CommitProjectChangesRequestSchema, ProjectFileTreeSchema, ProjectFileTreeQuerySchema, ProjectFileSearchPageSchema, ProjectFileSearchQuerySchema, StopProjectFileSearchResponseSchema, StopProjectFileSearchRequestSchema, ProjectSourceFileQuerySchema, ProjectSourceFileSchema, AgentAttachmentUploadResponseSchema, HostFileKindSchema, ImportHostAttachmentRequestSchema, AgentAttachmentKindSchema, AgentTaskSettingsResponseSchema, AgentTaskSettingsSchema, ReloadAgentMcpServersResponseSchema, ReloadAgentMcpServersRequestSchema, ReviewAgentTaskResponseSchema, ReviewAgentTaskRequestSchema, CompactAgentTaskResponseSchema, CompactAgentTaskRequestSchema, ForkAgentTaskResponseSchema, ForkAgentTaskRequestSchema, UploadAgentFeedbackResponseSchema, UploadAgentFeedbackRequestSchema, OpenAgentTaskAttachmentResponseSchema, OpenAgentTaskAttachmentRequestSchema, UpdateAgentGoalResponseSchema, UpdateAgentGoalRequestSchema, ClearAgentGoalResponseSchema, ProjectGitWorktreePageSchema, ProjectWorktreeMutationResponseSchema, CreateProjectWorktreeRequestSchema, SwitchProjectWorktreeRequestSchema, RenameProjectFileResponseSchema, RenameProjectFileRequestSchema, DeleteProjectFileResponseSchema, DeleteProjectFileRequestSchema, MAX_EVENT_BATCH_SIZE } from './chunk-ZSWNUDDK.js';
6
6
  import { __commonJS, __require, __toESM } from './chunk-K6J42667.js';
7
7
  import { Buffer as Buffer$1 } from 'buffer';
8
- import { Readable, Transform } from 'stream';
9
8
  import { randomBytes, createHash, timingSafeEqual, randomUUID } from 'crypto';
10
9
  import { createWriteStream, constants, createReadStream } from 'fs';
11
- import { realpath, lstat, stat, readFile, open, mkdir, rm, readdir, access, unlink, readlink } from 'fs/promises';
10
+ import { mkdtemp, rm, realpath, lstat, stat, readFile, open, mkdir, readdir, rename, access, unlink, readlink } from 'fs/promises';
12
11
  import { tmpdir, homedir } from 'os';
13
- import { isAbsolute, join, dirname, resolve, relative, sep, basename, extname, normalize, win32, posix } from 'path';
12
+ import { join, isAbsolute, dirname, resolve, relative, sep, basename, extname, normalize, win32, posix } from 'path';
13
+ import { Transform, Readable } from 'stream';
14
14
  import { pipeline } from 'stream/promises';
15
15
  import { TextDecoder as TextDecoder$1 } from 'util';
16
16
  import { spawn } from 'child_process';
@@ -286,41 +286,41 @@ var require_queue = __commonJS({
286
286
  queue.drained = drained;
287
287
  return queue;
288
288
  function push(value) {
289
- var p2 = new Promise(function(resolve7, reject) {
289
+ var p2 = new Promise(function(resolve8, reject) {
290
290
  pushCb(value, function(err, result) {
291
291
  if (err) {
292
292
  reject(err);
293
293
  return;
294
294
  }
295
- resolve7(result);
295
+ resolve8(result);
296
296
  });
297
297
  });
298
298
  p2.catch(noop);
299
299
  return p2;
300
300
  }
301
301
  function unshift(value) {
302
- var p2 = new Promise(function(resolve7, reject) {
302
+ var p2 = new Promise(function(resolve8, reject) {
303
303
  unshiftCb(value, function(err, result) {
304
304
  if (err) {
305
305
  reject(err);
306
306
  return;
307
307
  }
308
- resolve7(result);
308
+ resolve8(result);
309
309
  });
310
310
  });
311
311
  p2.catch(noop);
312
312
  return p2;
313
313
  }
314
314
  function drained() {
315
- var p2 = new Promise(function(resolve7) {
315
+ var p2 = new Promise(function(resolve8) {
316
316
  process.nextTick(function() {
317
317
  if (queue.idle()) {
318
- resolve7();
318
+ resolve8();
319
319
  } else {
320
320
  var previousDrain = queue.drain;
321
321
  queue.drain = function() {
322
322
  if (typeof previousDrain === "function") previousDrain();
323
- resolve7();
323
+ resolve8();
324
324
  queue.drain = previousDrain;
325
325
  };
326
326
  }
@@ -657,8 +657,8 @@ var require_create_promise = __commonJS({
657
657
  reject: null,
658
658
  promise: null
659
659
  };
660
- obj.promise = new Promise((resolve7, reject) => {
661
- obj.resolve = resolve7;
660
+ obj.promise = new Promise((resolve8, reject) => {
661
+ obj.resolve = resolve8;
662
662
  obj.reject = reject;
663
663
  });
664
664
  return obj;
@@ -921,11 +921,11 @@ var require_thenify = __commonJS({
921
921
  return;
922
922
  }
923
923
  debug2("thenify");
924
- return (resolve7, reject) => {
924
+ return (resolve8, reject) => {
925
925
  const p2 = this._loadRegistered();
926
926
  return p2.then(() => {
927
927
  this[kThenifyDoNotWrap] = true;
928
- return resolve7(this._server);
928
+ return resolve8(this._server);
929
929
  }, reject);
930
930
  };
931
931
  }
@@ -1060,12 +1060,12 @@ var require_avvio = __commonJS({
1060
1060
  inherits(Boot, EE);
1061
1061
  if ("asyncDispose" in Symbol) {
1062
1062
  Boot.prototype[Symbol.asyncDispose] = function() {
1063
- return new Promise((resolve7, reject) => {
1063
+ return new Promise((resolve8, reject) => {
1064
1064
  this.close((err) => {
1065
1065
  if (err) {
1066
1066
  return reject(err);
1067
1067
  }
1068
- resolve7();
1068
+ resolve8();
1069
1069
  });
1070
1070
  });
1071
1071
  };
@@ -1212,12 +1212,12 @@ var require_avvio = __commonJS({
1212
1212
  throw new AVV_ERR_CALLBACK_NOT_FN("close", typeof func);
1213
1213
  }
1214
1214
  } else {
1215
- promise = new Promise(function(resolve7, reject) {
1215
+ promise = new Promise(function(resolve8, reject) {
1216
1216
  func = function(err) {
1217
1217
  if (err) {
1218
1218
  return reject(err);
1219
1219
  }
1220
- resolve7();
1220
+ resolve8();
1221
1221
  };
1222
1222
  });
1223
1223
  }
@@ -1237,7 +1237,7 @@ var require_avvio = __commonJS({
1237
1237
  queueMicrotask(this.start.bind(this));
1238
1238
  return;
1239
1239
  }
1240
- return new Promise((resolve7, reject) => {
1240
+ return new Promise((resolve8, reject) => {
1241
1241
  this._readyQ.push(readyPromiseCB);
1242
1242
  this.start();
1243
1243
  const relativeContext = this._current[0].server;
@@ -1245,7 +1245,7 @@ var require_avvio = __commonJS({
1245
1245
  if (err) {
1246
1246
  reject(err);
1247
1247
  } else {
1248
- resolve7(relativeContext);
1248
+ resolve8(relativeContext);
1249
1249
  }
1250
1250
  process.nextTick(done);
1251
1251
  }
@@ -2556,8 +2556,8 @@ var require_promise = __commonJS({
2556
2556
  var { kTestInternals } = require_symbols2();
2557
2557
  function withResolvers() {
2558
2558
  let res, rej;
2559
- const promise = new Promise((resolve7, reject) => {
2560
- res = resolve7;
2559
+ const promise = new Promise((resolve8, reject) => {
2560
+ res = resolve8;
2561
2561
  rej = reject;
2562
2562
  });
2563
2563
  return { promise, resolve: res, reject: rej };
@@ -2655,15 +2655,15 @@ var require_server = __commonJS({
2655
2655
  if (cb === void 0) {
2656
2656
  const listening = listenPromise.call(this, server, listenOptions);
2657
2657
  return listening.then((address) => {
2658
- const { promise, resolve: resolve7 } = PonyPromise.withResolvers();
2658
+ const { promise, resolve: resolve8 } = PonyPromise.withResolvers();
2659
2659
  if (host === "localhost") {
2660
2660
  multipleBindings.call(this, server, httpHandler, options, listenOptions, () => {
2661
2661
  this[kState].listening = true;
2662
- resolve7(address);
2662
+ resolve8(address);
2663
2663
  onListenHookRunner(this);
2664
2664
  });
2665
2665
  } else {
2666
- resolve7(address);
2666
+ resolve8(address);
2667
2667
  onListenHookRunner(this);
2668
2668
  }
2669
2669
  return promise;
@@ -2790,7 +2790,7 @@ var require_server = __commonJS({
2790
2790
  }
2791
2791
  return this.ready().then(() => {
2792
2792
  if (this[kState].aborted) return;
2793
- const { promise, resolve: resolve7, reject } = PonyPromise.withResolvers();
2793
+ const { promise, resolve: resolve8, reject } = PonyPromise.withResolvers();
2794
2794
  const errEventHandler = (err) => {
2795
2795
  cleanup();
2796
2796
  this[kState].listening = false;
@@ -2799,7 +2799,7 @@ var require_server = __commonJS({
2799
2799
  const listeningEventHandler = () => {
2800
2800
  cleanup();
2801
2801
  this[kState].listening = true;
2802
- resolve7(logServerAddress.call(
2802
+ resolve8(logServerAddress.call(
2803
2803
  this,
2804
2804
  server,
2805
2805
  listenOptions.listenTextResolver || defaultResolveServerListeningText
@@ -9621,7 +9621,7 @@ var require_codegen = __commonJS({
9621
9621
  AND: new code_1._Code("&&"),
9622
9622
  ADD: new code_1._Code("+")
9623
9623
  };
9624
- var Node = class {
9624
+ var Node2 = class {
9625
9625
  optimizeNodes() {
9626
9626
  return this;
9627
9627
  }
@@ -9629,7 +9629,7 @@ var require_codegen = __commonJS({
9629
9629
  return this;
9630
9630
  }
9631
9631
  };
9632
- var Def = class extends Node {
9632
+ var Def = class extends Node2 {
9633
9633
  constructor(varKind, name, rhs) {
9634
9634
  super();
9635
9635
  this.varKind = varKind;
@@ -9652,7 +9652,7 @@ var require_codegen = __commonJS({
9652
9652
  return this.rhs instanceof code_1._CodeOrName ? this.rhs.names : {};
9653
9653
  }
9654
9654
  };
9655
- var Assign = class extends Node {
9655
+ var Assign = class extends Node2 {
9656
9656
  constructor(lhs, rhs, sideEffects) {
9657
9657
  super();
9658
9658
  this.lhs = lhs;
@@ -9682,7 +9682,7 @@ var require_codegen = __commonJS({
9682
9682
  return `${this.lhs} ${this.op}= ${this.rhs};` + _n;
9683
9683
  }
9684
9684
  };
9685
- var Label = class extends Node {
9685
+ var Label = class extends Node2 {
9686
9686
  constructor(label) {
9687
9687
  super();
9688
9688
  this.label = label;
@@ -9692,7 +9692,7 @@ var require_codegen = __commonJS({
9692
9692
  return `${this.label}:` + _n;
9693
9693
  }
9694
9694
  };
9695
- var Break = class extends Node {
9695
+ var Break = class extends Node2 {
9696
9696
  constructor(label) {
9697
9697
  super();
9698
9698
  this.label = label;
@@ -9703,7 +9703,7 @@ var require_codegen = __commonJS({
9703
9703
  return `break${label};` + _n;
9704
9704
  }
9705
9705
  };
9706
- var Throw = class extends Node {
9706
+ var Throw = class extends Node2 {
9707
9707
  constructor(error) {
9708
9708
  super();
9709
9709
  this.error = error;
@@ -9715,7 +9715,7 @@ var require_codegen = __commonJS({
9715
9715
  return this.error.names;
9716
9716
  }
9717
9717
  };
9718
- var AnyCode = class extends Node {
9718
+ var AnyCode = class extends Node2 {
9719
9719
  constructor(code) {
9720
9720
  super();
9721
9721
  this.code = code;
@@ -9734,7 +9734,7 @@ var require_codegen = __commonJS({
9734
9734
  return this.code instanceof code_1._CodeOrName ? this.code.names : {};
9735
9735
  }
9736
9736
  };
9737
- var ParentNode = class extends Node {
9737
+ var ParentNode = class extends Node2 {
9738
9738
  constructor(nodes = []) {
9739
9739
  super();
9740
9740
  this.nodes = nodes;
@@ -12196,7 +12196,7 @@ var require_compile = __commonJS({
12196
12196
  const schOrFunc = root.refs[ref];
12197
12197
  if (schOrFunc)
12198
12198
  return schOrFunc;
12199
- let _sch = resolve7.call(this, root, ref);
12199
+ let _sch = resolve8.call(this, root, ref);
12200
12200
  if (_sch === void 0) {
12201
12201
  const schema = (_a2 = root.localRefs) === null || _a2 === void 0 ? void 0 : _a2[ref];
12202
12202
  const { schemaId } = this.opts;
@@ -12223,7 +12223,7 @@ var require_compile = __commonJS({
12223
12223
  function sameSchemaEnv(s1, s2) {
12224
12224
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
12225
12225
  }
12226
- function resolve7(root, ref) {
12226
+ function resolve8(root, ref) {
12227
12227
  let sch;
12228
12228
  while (typeof (sch = this.refs[ref]) == "string")
12229
12229
  ref = sch;
@@ -12851,7 +12851,7 @@ var require_fast_uri = __commonJS({
12851
12851
  }
12852
12852
  return uri;
12853
12853
  }
12854
- function resolve7(baseURI, relativeURI, options) {
12854
+ function resolve8(baseURI, relativeURI, options) {
12855
12855
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
12856
12856
  const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
12857
12857
  const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
@@ -12862,49 +12862,49 @@ var require_fast_uri = __commonJS({
12862
12862
  schemelessOptions.skipEscape = true;
12863
12863
  return serialize(resolved, schemelessOptions);
12864
12864
  }
12865
- function resolveComponent(base, relative6, options, skipNormalization) {
12865
+ function resolveComponent(base, relative7, options, skipNormalization) {
12866
12866
  const target = {};
12867
12867
  if (!skipNormalization) {
12868
12868
  base = parse(serialize(base, options), options);
12869
- relative6 = parse(serialize(relative6, options), options);
12869
+ relative7 = parse(serialize(relative7, options), options);
12870
12870
  }
12871
12871
  options = options || {};
12872
- if (!options.tolerant && relative6.scheme) {
12873
- target.scheme = relative6.scheme;
12874
- target.userinfo = relative6.userinfo;
12875
- target.host = relative6.host;
12876
- target.port = relative6.port;
12877
- target.path = removeDotSegments(relative6.path || "");
12878
- target.query = relative6.query;
12872
+ if (!options.tolerant && relative7.scheme) {
12873
+ target.scheme = relative7.scheme;
12874
+ target.userinfo = relative7.userinfo;
12875
+ target.host = relative7.host;
12876
+ target.port = relative7.port;
12877
+ target.path = removeDotSegments(relative7.path || "");
12878
+ target.query = relative7.query;
12879
12879
  } else {
12880
- if (relative6.userinfo !== void 0 || relative6.host !== void 0 || relative6.port !== void 0) {
12881
- target.userinfo = relative6.userinfo;
12882
- target.host = relative6.host;
12883
- target.port = relative6.port;
12884
- target.path = removeDotSegments(relative6.path || "");
12885
- target.query = relative6.query;
12880
+ if (relative7.userinfo !== void 0 || relative7.host !== void 0 || relative7.port !== void 0) {
12881
+ target.userinfo = relative7.userinfo;
12882
+ target.host = relative7.host;
12883
+ target.port = relative7.port;
12884
+ target.path = removeDotSegments(relative7.path || "");
12885
+ target.query = relative7.query;
12886
12886
  } else {
12887
- if (!relative6.path) {
12887
+ if (!relative7.path) {
12888
12888
  target.path = base.path;
12889
- if (relative6.query !== void 0) {
12890
- target.query = relative6.query;
12889
+ if (relative7.query !== void 0) {
12890
+ target.query = relative7.query;
12891
12891
  } else {
12892
12892
  target.query = base.query;
12893
12893
  }
12894
12894
  } else {
12895
- if (relative6.path[0] === "/") {
12896
- target.path = removeDotSegments(relative6.path);
12895
+ if (relative7.path[0] === "/") {
12896
+ target.path = removeDotSegments(relative7.path);
12897
12897
  } else {
12898
12898
  if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
12899
- target.path = "/" + relative6.path;
12899
+ target.path = "/" + relative7.path;
12900
12900
  } else if (!base.path) {
12901
- target.path = relative6.path;
12901
+ target.path = relative7.path;
12902
12902
  } else {
12903
- target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative6.path;
12903
+ target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative7.path;
12904
12904
  }
12905
12905
  target.path = removeDotSegments(target.path);
12906
12906
  }
12907
- target.query = relative6.query;
12907
+ target.query = relative7.query;
12908
12908
  }
12909
12909
  target.userinfo = base.userinfo;
12910
12910
  target.host = base.host;
@@ -12912,7 +12912,7 @@ var require_fast_uri = __commonJS({
12912
12912
  }
12913
12913
  target.scheme = base.scheme;
12914
12914
  }
12915
- target.fragment = relative6.fragment;
12915
+ target.fragment = relative7.fragment;
12916
12916
  return target;
12917
12917
  }
12918
12918
  function equal(uriA, uriB, options) {
@@ -13135,7 +13135,7 @@ var require_fast_uri = __commonJS({
13135
13135
  var fastUri = {
13136
13136
  SCHEMES,
13137
13137
  normalize: normalize2,
13138
- resolve: resolve7,
13138
+ resolve: resolve8,
13139
13139
  resolveComponent,
13140
13140
  equal,
13141
13141
  serialize,
@@ -18962,7 +18962,7 @@ var require_fast_uri2 = __commonJS({
18962
18962
  }
18963
18963
  return uri;
18964
18964
  }
18965
- function resolve7(baseURI, relativeURI, options) {
18965
+ function resolve8(baseURI, relativeURI, options) {
18966
18966
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
18967
18967
  const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
18968
18968
  const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
@@ -18973,49 +18973,49 @@ var require_fast_uri2 = __commonJS({
18973
18973
  schemelessOptions.skipEscape = true;
18974
18974
  return serialize(resolved, schemelessOptions);
18975
18975
  }
18976
- function resolveComponent(base, relative6, options, skipNormalization) {
18976
+ function resolveComponent(base, relative7, options, skipNormalization) {
18977
18977
  const target = {};
18978
18978
  if (!skipNormalization) {
18979
18979
  base = parse(serialize(base, options), options);
18980
- relative6 = parse(serialize(relative6, options), options);
18980
+ relative7 = parse(serialize(relative7, options), options);
18981
18981
  }
18982
18982
  options = options || {};
18983
- if (!options.tolerant && relative6.scheme) {
18984
- target.scheme = relative6.scheme;
18985
- target.userinfo = relative6.userinfo;
18986
- target.host = relative6.host;
18987
- target.port = relative6.port;
18988
- target.path = removeDotSegments(relative6.path || "");
18989
- target.query = relative6.query;
18983
+ if (!options.tolerant && relative7.scheme) {
18984
+ target.scheme = relative7.scheme;
18985
+ target.userinfo = relative7.userinfo;
18986
+ target.host = relative7.host;
18987
+ target.port = relative7.port;
18988
+ target.path = removeDotSegments(relative7.path || "");
18989
+ target.query = relative7.query;
18990
18990
  } else {
18991
- if (relative6.userinfo !== void 0 || relative6.host !== void 0 || relative6.port !== void 0) {
18992
- target.userinfo = relative6.userinfo;
18993
- target.host = relative6.host;
18994
- target.port = relative6.port;
18995
- target.path = removeDotSegments(relative6.path || "");
18996
- target.query = relative6.query;
18991
+ if (relative7.userinfo !== void 0 || relative7.host !== void 0 || relative7.port !== void 0) {
18992
+ target.userinfo = relative7.userinfo;
18993
+ target.host = relative7.host;
18994
+ target.port = relative7.port;
18995
+ target.path = removeDotSegments(relative7.path || "");
18996
+ target.query = relative7.query;
18997
18997
  } else {
18998
- if (!relative6.path) {
18998
+ if (!relative7.path) {
18999
18999
  target.path = base.path;
19000
- if (relative6.query !== void 0) {
19001
- target.query = relative6.query;
19000
+ if (relative7.query !== void 0) {
19001
+ target.query = relative7.query;
19002
19002
  } else {
19003
19003
  target.query = base.query;
19004
19004
  }
19005
19005
  } else {
19006
- if (relative6.path[0] === "/") {
19007
- target.path = removeDotSegments(relative6.path);
19006
+ if (relative7.path[0] === "/") {
19007
+ target.path = removeDotSegments(relative7.path);
19008
19008
  } else {
19009
19009
  if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
19010
- target.path = "/" + relative6.path;
19010
+ target.path = "/" + relative7.path;
19011
19011
  } else if (!base.path) {
19012
- target.path = relative6.path;
19012
+ target.path = relative7.path;
19013
19013
  } else {
19014
- target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative6.path;
19014
+ target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative7.path;
19015
19015
  }
19016
19016
  target.path = removeDotSegments(target.path);
19017
19017
  }
19018
- target.query = relative6.query;
19018
+ target.query = relative7.query;
19019
19019
  }
19020
19020
  target.userinfo = base.userinfo;
19021
19021
  target.host = base.host;
@@ -19023,7 +19023,7 @@ var require_fast_uri2 = __commonJS({
19023
19023
  }
19024
19024
  target.scheme = base.scheme;
19025
19025
  }
19026
- target.fragment = relative6.fragment;
19026
+ target.fragment = relative7.fragment;
19027
19027
  return target;
19028
19028
  }
19029
19029
  function equal(uriA, uriB, options) {
@@ -19245,7 +19245,7 @@ var require_fast_uri2 = __commonJS({
19245
19245
  var fastUri = {
19246
19246
  SCHEMES,
19247
19247
  normalize: normalize2,
19248
- resolve: resolve7,
19248
+ resolve: resolve8,
19249
19249
  resolveComponent,
19250
19250
  equal,
19251
19251
  serialize,
@@ -26191,7 +26191,7 @@ var require_node = __commonJS({
26191
26191
  PARAMETRIC: 1,
26192
26192
  WILDCARD: 2
26193
26193
  };
26194
- var Node = class {
26194
+ var Node2 = class {
26195
26195
  constructor() {
26196
26196
  this.isLeafNode = false;
26197
26197
  this.routes = null;
@@ -26209,7 +26209,7 @@ var require_node = __commonJS({
26209
26209
  this.handlerStorage.addHandler(constrainer, route);
26210
26210
  }
26211
26211
  };
26212
- var ParentNode = class extends Node {
26212
+ var ParentNode = class extends Node2 {
26213
26213
  constructor() {
26214
26214
  super();
26215
26215
  this.staticChildren = {};
@@ -26359,7 +26359,7 @@ var require_node = __commonJS({
26359
26359
  return this.findStaticMatchingChild(path, pathIndex);
26360
26360
  }
26361
26361
  };
26362
- var WildcardNode = class extends Node {
26362
+ var WildcardNode = class extends Node2 {
26363
26363
  constructor() {
26364
26364
  super();
26365
26365
  this.kind = NODE_TYPES.WILDCARD;
@@ -28587,7 +28587,7 @@ var require_parse_url = __commonJS({
28587
28587
  // node_modules/.pnpm/light-my-request@6.6.0/node_modules/light-my-request/lib/form-data.js
28588
28588
  var require_form_data = __commonJS({
28589
28589
  "node_modules/.pnpm/light-my-request@6.6.0/node_modules/light-my-request/lib/form-data.js"(exports, module) {
28590
- var { randomUUID: randomUUID3 } = __require("crypto");
28590
+ var { randomUUID: randomUUID4 } = __require("crypto");
28591
28591
  var { Readable: Readable3 } = __require("stream");
28592
28592
  var textEncoder;
28593
28593
  function isFormDataLike(payload) {
@@ -28595,7 +28595,7 @@ var require_form_data = __commonJS({
28595
28595
  }
28596
28596
  function formDataToStream(formdata) {
28597
28597
  textEncoder = textEncoder ?? new TextEncoder();
28598
- const boundary = `----formdata-${randomUUID3()}`;
28598
+ const boundary = `----formdata-${randomUUID4()}`;
28599
28599
  const prefix = `--${boundary}\r
28600
28600
  Content-Disposition: form-data`;
28601
28601
  const escape2 = (str) => str.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
@@ -30093,9 +30093,9 @@ var require_light_my_request = __commonJS({
30093
30093
  const res = new Response(req, callback);
30094
30094
  return makeRequest(dispatchFunc, server, req, res);
30095
30095
  } else {
30096
- return new Promise((resolve7, reject) => {
30096
+ return new Promise((resolve8, reject) => {
30097
30097
  const req = new RequestConstructor(options);
30098
- const res = new Response(req, resolve7, reject);
30098
+ const res = new Response(req, resolve8, reject);
30099
30099
  makeRequest(dispatchFunc, server, req, res);
30100
30100
  });
30101
30101
  }
@@ -34473,14 +34473,14 @@ var require_generateId = __commonJS({
34473
34473
  var require_stream_consumer = __commonJS({
34474
34474
  "node_modules/.pnpm/@fastify+multipart@10.1.0/node_modules/@fastify/multipart/lib/stream-consumer.js"(exports, module) {
34475
34475
  module.exports = function streamToNull(stream) {
34476
- return new Promise((resolve7, reject) => {
34476
+ return new Promise((resolve8, reject) => {
34477
34477
  stream.on("data", () => {
34478
34478
  });
34479
34479
  stream.on("close", () => {
34480
- resolve7();
34480
+ resolve8();
34481
34481
  });
34482
34482
  stream.on("end", () => {
34483
- resolve7();
34483
+ resolve8();
34484
34484
  });
34485
34485
  stream.on("error", (error) => {
34486
34486
  reject(error);
@@ -34823,10 +34823,10 @@ var require_multipart2 = __commonJS({
34823
34823
  }
34824
34824
  };
34825
34825
  const parts = () => {
34826
- return new Promise((resolve7, reject) => {
34826
+ return new Promise((resolve8, reject) => {
34827
34827
  handle((val) => {
34828
34828
  if (val instanceof Error) return reject(val);
34829
- resolve7(val);
34829
+ resolve8(val);
34830
34830
  });
34831
34831
  });
34832
34832
  };
@@ -35007,7 +35007,7 @@ var require_multipart2 = __commonJS({
35007
35007
  parts = this.parts(options2);
35008
35008
  }
35009
35009
  this.savedRequestFiles = [];
35010
- const tmpdir2 = options2?.tmpdir || os.tmpdir();
35010
+ const tmpdir3 = options2?.tmpdir || os.tmpdir();
35011
35011
  this.tmpUploads = [];
35012
35012
  let i2 = 0;
35013
35013
  for await (const part of parts) {
@@ -35015,7 +35015,7 @@ var require_multipart2 = __commonJS({
35015
35015
  if (!part.file) {
35016
35016
  continue;
35017
35017
  }
35018
- const filepath = path.join(tmpdir2, generateId() + path.extname(part.filename || "file" + i2++));
35018
+ const filepath = path.join(tmpdir3, generateId() + path.extname(part.filename || "file" + i2++));
35019
35019
  const target = createWriteStream2(filepath);
35020
35020
  try {
35021
35021
  this.tmpUploads.push(filepath);
@@ -38492,7 +38492,7 @@ var require_parseTokenList = __commonJS({
38492
38492
  // node_modules/.pnpm/depd@2.0.0/node_modules/depd/index.js
38493
38493
  var require_depd = __commonJS({
38494
38494
  "node_modules/.pnpm/depd@2.0.0/node_modules/depd/index.js"(exports, module) {
38495
- var relative6 = __require("path").relative;
38495
+ var relative7 = __require("path").relative;
38496
38496
  module.exports = depd;
38497
38497
  var basePath = process.cwd();
38498
38498
  function containsNamespace(str, namespace) {
@@ -38684,7 +38684,7 @@ var require_depd = __commonJS({
38684
38684
  return formatted;
38685
38685
  }
38686
38686
  function formatLocation(callSite) {
38687
- return relative6(basePath, callSite[0]) + ":" + callSite[1] + ":" + callSite[2];
38687
+ return relative7(basePath, callSite[0]) + ":" + callSite[1] + ":" + callSite[2];
38688
38688
  }
38689
38689
  function getStack() {
38690
38690
  var limit = Error.stackTraceLimit;
@@ -39211,9 +39211,9 @@ var require_send = __commonJS({
39211
39211
  var { parseTokenList } = require_parseTokenList();
39212
39212
  var { createHttpError } = require_createHttpError();
39213
39213
  var extname3 = path.extname;
39214
- var join9 = path.join;
39214
+ var join10 = path.join;
39215
39215
  var normalize2 = path.normalize;
39216
- var resolve7 = path.resolve;
39216
+ var resolve8 = path.resolve;
39217
39217
  var sep5 = path.sep;
39218
39218
  var Readable3 = stream.Readable;
39219
39219
  var BYTES_RANGE_REGEXP = /^ *bytes=/;
@@ -39260,7 +39260,7 @@ var require_send = __commonJS({
39260
39260
  const lastModified = options.lastModified !== void 0 ? Boolean(options.lastModified) : true;
39261
39261
  const maxage = normalizeMaxAge(options.maxAge ?? options.maxage);
39262
39262
  const maxContentRangeChunkSize = options.maxContentRangeChunkSize !== void 0 ? Number(options.maxContentRangeChunkSize) : null;
39263
- const root = options.root ? resolve7(options.root) : null;
39263
+ const root = options.root ? resolve8(options.root) : null;
39264
39264
  const highWaterMark = Number.isSafeInteger(options.highWaterMark) && options.highWaterMark > 0 ? options.highWaterMark : null;
39265
39265
  return {
39266
39266
  acceptRanges,
@@ -39298,14 +39298,14 @@ var require_send = __commonJS({
39298
39298
  return { statusCode: 403 };
39299
39299
  }
39300
39300
  parts = path2.split(sep5);
39301
- path2 = normalize2(join9(root, path2));
39301
+ path2 = normalize2(join10(root, path2));
39302
39302
  } else {
39303
39303
  if (UP_PATH_REGEXP.test(path2)) {
39304
39304
  debug2('malicious path "%s"', path2);
39305
39305
  return { statusCode: 403 };
39306
39306
  }
39307
39307
  parts = normalize2(path2).split(sep5);
39308
- path2 = resolve7(path2);
39308
+ path2 = resolve8(path2);
39309
39309
  }
39310
39310
  return { path: path2, parts };
39311
39311
  }
@@ -39401,9 +39401,9 @@ var require_send = __commonJS({
39401
39401
  );
39402
39402
  }
39403
39403
  function tryStat(path2) {
39404
- return new Promise((resolve8) => {
39404
+ return new Promise((resolve9) => {
39405
39405
  fs.stat(path2, function onstat(error, stat4) {
39406
- resolve8({ error, stat: stat4 });
39406
+ resolve9({ error, stat: stat4 });
39407
39407
  });
39408
39408
  });
39409
39409
  }
@@ -39581,7 +39581,7 @@ var require_send = __commonJS({
39581
39581
  let err;
39582
39582
  for (let i2 = 0; i2 < options.index.length; i2++) {
39583
39583
  const index = options.index[i2];
39584
- const p2 = join9(path2, index);
39584
+ const p2 = join10(path2, index);
39585
39585
  const { error, stat: stat4 } = await tryStat(p2);
39586
39586
  if (error) {
39587
39587
  err = error;
@@ -40490,8 +40490,8 @@ var require_static = __commonJS({
40490
40490
  }
40491
40491
  }
40492
40492
  }
40493
- for (const [dirname6, rootPath] of indexDirs.entries()) {
40494
- const pathname = dirname6 + (dirname6.endsWith("/") ? "" : "/");
40493
+ for (const [dirname7, rootPath] of indexDirs.entries()) {
40494
+ const pathname = dirname7 + (dirname7.endsWith("/") ? "" : "/");
40495
40495
  const file = "/" + pathname.replace(prefix, "");
40496
40496
  setUpHeadAndGet(routeOpts, pathname, file, rootPath);
40497
40497
  if (opts.redirect === true) {
@@ -44663,12 +44663,12 @@ var require_buffer_list = __commonJS({
44663
44663
  return (String )(input);
44664
44664
  }
44665
44665
  var _require = __require("buffer");
44666
- var Buffer9 = _require.Buffer;
44666
+ var Buffer10 = _require.Buffer;
44667
44667
  var _require2 = __require("util");
44668
44668
  var inspect = _require2.inspect;
44669
44669
  var custom = inspect && inspect.custom || "inspect";
44670
44670
  function copyBuffer(src, target, offset) {
44671
- Buffer9.prototype.copy.call(src, target, offset);
44671
+ Buffer10.prototype.copy.call(src, target, offset);
44672
44672
  }
44673
44673
  module.exports = /* @__PURE__ */ (function() {
44674
44674
  function BufferList() {
@@ -44718,7 +44718,7 @@ var require_buffer_list = __commonJS({
44718
44718
  }
44719
44719
  }, {
44720
44720
  key: "join",
44721
- value: function join9(s) {
44721
+ value: function join10(s) {
44722
44722
  if (this.length === 0) return "";
44723
44723
  var p2 = this.head;
44724
44724
  var ret = "" + p2.data;
@@ -44728,8 +44728,8 @@ var require_buffer_list = __commonJS({
44728
44728
  }, {
44729
44729
  key: "concat",
44730
44730
  value: function concat(n) {
44731
- if (this.length === 0) return Buffer9.alloc(0);
44732
- var ret = Buffer9.allocUnsafe(n >>> 0);
44731
+ if (this.length === 0) return Buffer10.alloc(0);
44732
+ var ret = Buffer10.allocUnsafe(n >>> 0);
44733
44733
  var p2 = this.head;
44734
44734
  var i2 = 0;
44735
44735
  while (p2) {
@@ -44793,7 +44793,7 @@ var require_buffer_list = __commonJS({
44793
44793
  }, {
44794
44794
  key: "_getBuffer",
44795
44795
  value: function _getBuffer(n) {
44796
- var ret = Buffer9.allocUnsafe(n);
44796
+ var ret = Buffer10.allocUnsafe(n);
44797
44797
  var p2 = this.head;
44798
44798
  var c3 = 1;
44799
44799
  p2.data.copy(ret);
@@ -45072,14 +45072,14 @@ var require_stream_writable = __commonJS({
45072
45072
  deprecate: require_node3()
45073
45073
  };
45074
45074
  var Stream = require_stream2();
45075
- var Buffer9 = __require("buffer").Buffer;
45075
+ var Buffer10 = __require("buffer").Buffer;
45076
45076
  var OurUint8Array = (typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {}).Uint8Array || function() {
45077
45077
  };
45078
45078
  function _uint8ArrayToBuffer(chunk) {
45079
- return Buffer9.from(chunk);
45079
+ return Buffer10.from(chunk);
45080
45080
  }
45081
45081
  function _isUint8Array(obj) {
45082
- return Buffer9.isBuffer(obj) || obj instanceof OurUint8Array;
45082
+ return Buffer10.isBuffer(obj) || obj instanceof OurUint8Array;
45083
45083
  }
45084
45084
  var destroyImpl = require_destroy();
45085
45085
  var _require = require_state();
@@ -45207,7 +45207,7 @@ var require_stream_writable = __commonJS({
45207
45207
  var state = this._writableState;
45208
45208
  var ret = false;
45209
45209
  var isBuf = !state.objectMode && _isUint8Array(chunk);
45210
- if (isBuf && !Buffer9.isBuffer(chunk)) {
45210
+ if (isBuf && !Buffer10.isBuffer(chunk)) {
45211
45211
  chunk = _uint8ArrayToBuffer(chunk);
45212
45212
  }
45213
45213
  if (typeof encoding === "function") {
@@ -45251,7 +45251,7 @@ var require_stream_writable = __commonJS({
45251
45251
  });
45252
45252
  function decodeChunk(state, chunk, encoding) {
45253
45253
  if (!state.objectMode && state.decodeStrings !== false && typeof chunk === "string") {
45254
- chunk = Buffer9.from(chunk, encoding);
45254
+ chunk = Buffer10.from(chunk, encoding);
45255
45255
  }
45256
45256
  return chunk;
45257
45257
  }
@@ -45620,34 +45620,34 @@ var require_stream_duplex = __commonJS({
45620
45620
  var require_safe_buffer = __commonJS({
45621
45621
  "node_modules/.pnpm/safe-buffer@5.2.1/node_modules/safe-buffer/index.js"(exports, module) {
45622
45622
  var buffer = __require("buffer");
45623
- var Buffer9 = buffer.Buffer;
45623
+ var Buffer10 = buffer.Buffer;
45624
45624
  function copyProps(src, dst) {
45625
45625
  for (var key in src) {
45626
45626
  dst[key] = src[key];
45627
45627
  }
45628
45628
  }
45629
- if (Buffer9.from && Buffer9.alloc && Buffer9.allocUnsafe && Buffer9.allocUnsafeSlow) {
45629
+ if (Buffer10.from && Buffer10.alloc && Buffer10.allocUnsafe && Buffer10.allocUnsafeSlow) {
45630
45630
  module.exports = buffer;
45631
45631
  } else {
45632
45632
  copyProps(buffer, exports);
45633
45633
  exports.Buffer = SafeBuffer;
45634
45634
  }
45635
45635
  function SafeBuffer(arg, encodingOrOffset, length) {
45636
- return Buffer9(arg, encodingOrOffset, length);
45636
+ return Buffer10(arg, encodingOrOffset, length);
45637
45637
  }
45638
- SafeBuffer.prototype = Object.create(Buffer9.prototype);
45639
- copyProps(Buffer9, SafeBuffer);
45638
+ SafeBuffer.prototype = Object.create(Buffer10.prototype);
45639
+ copyProps(Buffer10, SafeBuffer);
45640
45640
  SafeBuffer.from = function(arg, encodingOrOffset, length) {
45641
45641
  if (typeof arg === "number") {
45642
45642
  throw new TypeError("Argument must not be a number");
45643
45643
  }
45644
- return Buffer9(arg, encodingOrOffset, length);
45644
+ return Buffer10(arg, encodingOrOffset, length);
45645
45645
  };
45646
45646
  SafeBuffer.alloc = function(size, fill, encoding) {
45647
45647
  if (typeof size !== "number") {
45648
45648
  throw new TypeError("Argument must be a number");
45649
45649
  }
45650
- var buf = Buffer9(size);
45650
+ var buf = Buffer10(size);
45651
45651
  if (fill !== void 0) {
45652
45652
  if (typeof encoding === "string") {
45653
45653
  buf.fill(fill, encoding);
@@ -45663,7 +45663,7 @@ var require_safe_buffer = __commonJS({
45663
45663
  if (typeof size !== "number") {
45664
45664
  throw new TypeError("Argument must be a number");
45665
45665
  }
45666
- return Buffer9(size);
45666
+ return Buffer10(size);
45667
45667
  };
45668
45668
  SafeBuffer.allocUnsafeSlow = function(size) {
45669
45669
  if (typeof size !== "number") {
@@ -45677,8 +45677,8 @@ var require_safe_buffer = __commonJS({
45677
45677
  // node_modules/.pnpm/string_decoder@1.3.0/node_modules/string_decoder/lib/string_decoder.js
45678
45678
  var require_string_decoder = __commonJS({
45679
45679
  "node_modules/.pnpm/string_decoder@1.3.0/node_modules/string_decoder/lib/string_decoder.js"(exports) {
45680
- var Buffer9 = require_safe_buffer().Buffer;
45681
- var isEncoding = Buffer9.isEncoding || function(encoding) {
45680
+ var Buffer10 = require_safe_buffer().Buffer;
45681
+ var isEncoding = Buffer10.isEncoding || function(encoding) {
45682
45682
  encoding = "" + encoding;
45683
45683
  switch (encoding && encoding.toLowerCase()) {
45684
45684
  case "hex":
@@ -45726,7 +45726,7 @@ var require_string_decoder = __commonJS({
45726
45726
  }
45727
45727
  function normalizeEncoding(enc) {
45728
45728
  var nenc = _normalizeEncoding(enc);
45729
- if (typeof nenc !== "string" && (Buffer9.isEncoding === isEncoding || !isEncoding(enc))) throw new Error("Unknown encoding: " + enc);
45729
+ if (typeof nenc !== "string" && (Buffer10.isEncoding === isEncoding || !isEncoding(enc))) throw new Error("Unknown encoding: " + enc);
45730
45730
  return nenc || enc;
45731
45731
  }
45732
45732
  exports.StringDecoder = StringDecoder;
@@ -45755,7 +45755,7 @@ var require_string_decoder = __commonJS({
45755
45755
  }
45756
45756
  this.lastNeed = 0;
45757
45757
  this.lastTotal = 0;
45758
- this.lastChar = Buffer9.allocUnsafe(nb);
45758
+ this.lastChar = Buffer10.allocUnsafe(nb);
45759
45759
  }
45760
45760
  StringDecoder.prototype.write = function(buf) {
45761
45761
  if (buf.length === 0) return "";
@@ -46041,14 +46041,14 @@ var require_async_iterator = __commonJS({
46041
46041
  };
46042
46042
  }
46043
46043
  function readAndResolve(iter) {
46044
- var resolve7 = iter[kLastResolve];
46045
- if (resolve7 !== null) {
46044
+ var resolve8 = iter[kLastResolve];
46045
+ if (resolve8 !== null) {
46046
46046
  var data = iter[kStream].read();
46047
46047
  if (data !== null) {
46048
46048
  iter[kLastPromise] = null;
46049
46049
  iter[kLastResolve] = null;
46050
46050
  iter[kLastReject] = null;
46051
- resolve7(createIterResult(data, false));
46051
+ resolve8(createIterResult(data, false));
46052
46052
  }
46053
46053
  }
46054
46054
  }
@@ -46056,13 +46056,13 @@ var require_async_iterator = __commonJS({
46056
46056
  process.nextTick(readAndResolve, iter);
46057
46057
  }
46058
46058
  function wrapForNext(lastPromise, iter) {
46059
- return function(resolve7, reject) {
46059
+ return function(resolve8, reject) {
46060
46060
  lastPromise.then(function() {
46061
46061
  if (iter[kEnded]) {
46062
- resolve7(createIterResult(void 0, true));
46062
+ resolve8(createIterResult(void 0, true));
46063
46063
  return;
46064
46064
  }
46065
- iter[kHandlePromise](resolve7, reject);
46065
+ iter[kHandlePromise](resolve8, reject);
46066
46066
  }, reject);
46067
46067
  };
46068
46068
  }
@@ -46082,12 +46082,12 @@ var require_async_iterator = __commonJS({
46082
46082
  return Promise.resolve(createIterResult(void 0, true));
46083
46083
  }
46084
46084
  if (this[kStream].destroyed) {
46085
- return new Promise(function(resolve7, reject) {
46085
+ return new Promise(function(resolve8, reject) {
46086
46086
  process.nextTick(function() {
46087
46087
  if (_this[kError]) {
46088
46088
  reject(_this[kError]);
46089
46089
  } else {
46090
- resolve7(createIterResult(void 0, true));
46090
+ resolve8(createIterResult(void 0, true));
46091
46091
  }
46092
46092
  });
46093
46093
  });
@@ -46110,13 +46110,13 @@ var require_async_iterator = __commonJS({
46110
46110
  return this;
46111
46111
  }), _defineProperty(_Object$setPrototypeO, "return", function _return() {
46112
46112
  var _this2 = this;
46113
- return new Promise(function(resolve7, reject) {
46113
+ return new Promise(function(resolve8, reject) {
46114
46114
  _this2[kStream].destroy(null, function(err) {
46115
46115
  if (err) {
46116
46116
  reject(err);
46117
46117
  return;
46118
46118
  }
46119
- resolve7(createIterResult(void 0, true));
46119
+ resolve8(createIterResult(void 0, true));
46120
46120
  });
46121
46121
  });
46122
46122
  }), _Object$setPrototypeO), AsyncIteratorPrototype);
@@ -46138,15 +46138,15 @@ var require_async_iterator = __commonJS({
46138
46138
  value: stream._readableState.endEmitted,
46139
46139
  writable: true
46140
46140
  }), _defineProperty(_Object$create, kHandlePromise, {
46141
- value: function value(resolve7, reject) {
46141
+ value: function value(resolve8, reject) {
46142
46142
  var data = iterator[kStream].read();
46143
46143
  if (data) {
46144
46144
  iterator[kLastPromise] = null;
46145
46145
  iterator[kLastResolve] = null;
46146
46146
  iterator[kLastReject] = null;
46147
- resolve7(createIterResult(data, false));
46147
+ resolve8(createIterResult(data, false));
46148
46148
  } else {
46149
- iterator[kLastResolve] = resolve7;
46149
+ iterator[kLastResolve] = resolve8;
46150
46150
  iterator[kLastReject] = reject;
46151
46151
  }
46152
46152
  },
@@ -46165,12 +46165,12 @@ var require_async_iterator = __commonJS({
46165
46165
  iterator[kError] = err;
46166
46166
  return;
46167
46167
  }
46168
- var resolve7 = iterator[kLastResolve];
46169
- if (resolve7 !== null) {
46168
+ var resolve8 = iterator[kLastResolve];
46169
+ if (resolve8 !== null) {
46170
46170
  iterator[kLastPromise] = null;
46171
46171
  iterator[kLastResolve] = null;
46172
46172
  iterator[kLastReject] = null;
46173
- resolve7(createIterResult(void 0, true));
46173
+ resolve8(createIterResult(void 0, true));
46174
46174
  }
46175
46175
  iterator[kEnded] = true;
46176
46176
  });
@@ -46184,7 +46184,7 @@ var require_async_iterator = __commonJS({
46184
46184
  // node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/from.js
46185
46185
  var require_from = __commonJS({
46186
46186
  "node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/from.js"(exports, module) {
46187
- function asyncGeneratorStep(gen, resolve7, reject, _next, _throw, key, arg) {
46187
+ function asyncGeneratorStep(gen, resolve8, reject, _next, _throw, key, arg) {
46188
46188
  try {
46189
46189
  var info = gen[key](arg);
46190
46190
  var value = info.value;
@@ -46193,7 +46193,7 @@ var require_from = __commonJS({
46193
46193
  return;
46194
46194
  }
46195
46195
  if (info.done) {
46196
- resolve7(value);
46196
+ resolve8(value);
46197
46197
  } else {
46198
46198
  Promise.resolve(value).then(_next, _throw);
46199
46199
  }
@@ -46201,13 +46201,13 @@ var require_from = __commonJS({
46201
46201
  function _asyncToGenerator(fn) {
46202
46202
  return function() {
46203
46203
  var self2 = this, args = arguments;
46204
- return new Promise(function(resolve7, reject) {
46204
+ return new Promise(function(resolve8, reject) {
46205
46205
  var gen = fn.apply(self2, args);
46206
46206
  function _next(value) {
46207
- asyncGeneratorStep(gen, resolve7, reject, _next, _throw, "next", value);
46207
+ asyncGeneratorStep(gen, resolve8, reject, _next, _throw, "next", value);
46208
46208
  }
46209
46209
  function _throw(err) {
46210
- asyncGeneratorStep(gen, resolve7, reject, _next, _throw, "throw", err);
46210
+ asyncGeneratorStep(gen, resolve8, reject, _next, _throw, "throw", err);
46211
46211
  }
46212
46212
  _next(void 0);
46213
46213
  });
@@ -46312,14 +46312,14 @@ var require_stream_readable = __commonJS({
46312
46312
  return emitter.listeners(type).length;
46313
46313
  };
46314
46314
  var Stream = require_stream2();
46315
- var Buffer9 = __require("buffer").Buffer;
46315
+ var Buffer10 = __require("buffer").Buffer;
46316
46316
  var OurUint8Array = (typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {}).Uint8Array || function() {
46317
46317
  };
46318
46318
  function _uint8ArrayToBuffer(chunk) {
46319
- return Buffer9.from(chunk);
46319
+ return Buffer10.from(chunk);
46320
46320
  }
46321
46321
  function _isUint8Array(obj) {
46322
- return Buffer9.isBuffer(obj) || obj instanceof OurUint8Array;
46322
+ return Buffer10.isBuffer(obj) || obj instanceof OurUint8Array;
46323
46323
  }
46324
46324
  var debugUtil = __require("util");
46325
46325
  var debug2;
@@ -46427,7 +46427,7 @@ var require_stream_readable = __commonJS({
46427
46427
  if (typeof chunk === "string") {
46428
46428
  encoding = encoding || state.defaultEncoding;
46429
46429
  if (encoding !== state.encoding) {
46430
- chunk = Buffer9.from(chunk, encoding);
46430
+ chunk = Buffer10.from(chunk, encoding);
46431
46431
  encoding = "";
46432
46432
  }
46433
46433
  skipChunkCheck = true;
@@ -46452,7 +46452,7 @@ var require_stream_readable = __commonJS({
46452
46452
  if (er) {
46453
46453
  errorOrDestroy(stream, er);
46454
46454
  } else if (state.objectMode || chunk && chunk.length > 0) {
46455
- if (typeof chunk !== "string" && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer9.prototype) {
46455
+ if (typeof chunk !== "string" && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer10.prototype) {
46456
46456
  chunk = _uint8ArrayToBuffer(chunk);
46457
46457
  }
46458
46458
  if (addToFront) {
@@ -47674,16 +47674,16 @@ var require_websocket2 = __commonJS({
47674
47674
  const clientStream = new Duplexify(client2Server, server2Client);
47675
47675
  const ws = new WebSocket(null, void 0, { isServer: false });
47676
47676
  const head = Buffer.from([]);
47677
- let resolve7, reject;
47677
+ let resolve8, reject;
47678
47678
  const promise = new Promise((_resolve, _reject) => {
47679
- resolve7 = _resolve;
47679
+ resolve8 = _resolve;
47680
47680
  reject = _reject;
47681
47681
  });
47682
47682
  typeof options.onInit === "function" && options.onInit(ws);
47683
47683
  ws.on("open", () => {
47684
47684
  typeof options.onOpen === "function" && options.onOpen(ws);
47685
47685
  clientStream.removeListener("data", onData);
47686
- resolve7(ws);
47686
+ resolve8(ws);
47687
47687
  });
47688
47688
  const onData = (chunk) => {
47689
47689
  if (chunk.toString().includes("HTTP/1.1 101 Switching Protocols")) {
@@ -48180,20 +48180,16 @@ var AttachmentQueueIndex = class {
48180
48180
  this.#attachmentIdsByQueue.delete(key);
48181
48181
  return ids;
48182
48182
  }
48183
+ replace(projectId, queuedSubmissionId, attachmentIds) {
48184
+ const key = queueKey(projectId, queuedSubmissionId);
48185
+ const previous = this.#attachmentIdsByQueue.get(key) ?? /* @__PURE__ */ new Set();
48186
+ const next = new Set(attachmentIds);
48187
+ this.#attachmentIdsByQueue.set(key, next);
48188
+ return [...previous].filter((id) => !next.has(id));
48189
+ }
48183
48190
  hasAttachment(attachmentId) {
48184
48191
  return [...this.#attachmentIdsByQueue.values()].some((ids) => ids.has(attachmentId));
48185
48192
  }
48186
- releaseMissing(projectId, retainedQueueIds) {
48187
- const prefix = `${projectId}\0`;
48188
- const releasedAttachmentIds = [];
48189
- for (const [key, ids] of this.#attachmentIdsByQueue) {
48190
- if (key.startsWith(prefix) && !retainedQueueIds.has(key.slice(prefix.length))) {
48191
- releasedAttachmentIds.push(...ids);
48192
- this.#attachmentIdsByQueue.delete(key);
48193
- }
48194
- }
48195
- return releasedAttachmentIds;
48196
- }
48197
48193
  deleteAttachment(attachmentId) {
48198
48194
  for (const [key, ids] of this.#attachmentIdsByQueue) {
48199
48195
  ids.delete(attachmentId);
@@ -48521,7 +48517,7 @@ var AttachmentStore = class {
48521
48517
  }
48522
48518
  }
48523
48519
  }
48524
- retainQueue(projectId, ids, queuedSubmissionId) {
48520
+ async retainQueue(projectId, ids, queuedSubmissionId, replaceExisting = false) {
48525
48521
  const uniqueIds = [...new Set(ids)];
48526
48522
  for (const id of uniqueIds) {
48527
48523
  const entry = this.#entries.get(id);
@@ -48530,8 +48526,12 @@ var AttachmentStore = class {
48530
48526
  }
48531
48527
  entry.expiresAt = this.#clock() + this.#ttlMs;
48532
48528
  }
48533
- this.#queueIndex.retain(projectId, queuedSubmissionId, uniqueIds);
48534
- return Promise.resolve();
48529
+ if (!replaceExisting) {
48530
+ this.#queueIndex.retain(projectId, queuedSubmissionId, uniqueIds);
48531
+ return;
48532
+ }
48533
+ const removed = this.#queueIndex.replace(projectId, queuedSubmissionId, uniqueIds);
48534
+ await Promise.all(removed.map((attachmentId) => this.#delete(attachmentId)));
48535
48535
  }
48536
48536
  startQueue(projectId, queuedSubmissionId, turnId) {
48537
48537
  for (const attachmentId of this.#queueIndex.take(projectId, queuedSubmissionId)) {
@@ -48543,15 +48543,6 @@ var AttachmentStore = class {
48543
48543
  }
48544
48544
  return Promise.resolve();
48545
48545
  }
48546
- reconcileQueue(projectId, queuedSubmissionIds) {
48547
- const retainedIds = new Set(queuedSubmissionIds);
48548
- for (const attachmentId of this.#queueIndex.releaseMissing(projectId, retainedIds)) {
48549
- const entry = this.#entries.get(attachmentId);
48550
- if (entry?.projectId === projectId) {
48551
- entry.expiresAt = this.#clock() + this.#ttlMs;
48552
- }
48553
- }
48554
- }
48555
48546
  async releaseQueue(projectId, queuedSubmissionId) {
48556
48547
  const attachmentIds = this.#queueIndex.take(projectId, queuedSubmissionId);
48557
48548
  await Promise.all(attachmentIds.map((attachmentId) => this.#delete(attachmentId)));
@@ -53588,34 +53579,167 @@ function originalErrorMessage(error, fallback) {
53588
53579
  if (typeof error === "string" && error.length > 0) return error;
53589
53580
  return fallback;
53590
53581
  }
53582
+
53583
+ // node_modules/.pnpm/yocto-queue@1.2.2/node_modules/yocto-queue/index.js
53584
+ var Node = class {
53585
+ value;
53586
+ next;
53587
+ constructor(value) {
53588
+ this.value = value;
53589
+ }
53590
+ };
53591
+ var Queue = class {
53592
+ #head;
53593
+ #tail;
53594
+ #size;
53595
+ constructor() {
53596
+ this.clear();
53597
+ }
53598
+ enqueue(value) {
53599
+ const node = new Node(value);
53600
+ if (this.#head) {
53601
+ this.#tail.next = node;
53602
+ this.#tail = node;
53603
+ } else {
53604
+ this.#head = node;
53605
+ this.#tail = node;
53606
+ }
53607
+ this.#size++;
53608
+ }
53609
+ dequeue() {
53610
+ const current = this.#head;
53611
+ if (!current) {
53612
+ return;
53613
+ }
53614
+ this.#head = this.#head.next;
53615
+ this.#size--;
53616
+ if (!this.#head) {
53617
+ this.#tail = void 0;
53618
+ }
53619
+ return current.value;
53620
+ }
53621
+ peek() {
53622
+ if (!this.#head) {
53623
+ return;
53624
+ }
53625
+ return this.#head.value;
53626
+ }
53627
+ clear() {
53628
+ this.#head = void 0;
53629
+ this.#tail = void 0;
53630
+ this.#size = 0;
53631
+ }
53632
+ get size() {
53633
+ return this.#size;
53634
+ }
53635
+ *[Symbol.iterator]() {
53636
+ let current = this.#head;
53637
+ while (current) {
53638
+ yield current.value;
53639
+ current = current.next;
53640
+ }
53641
+ }
53642
+ *drain() {
53643
+ while (this.#head) {
53644
+ yield this.dequeue();
53645
+ }
53646
+ }
53647
+ };
53648
+
53649
+ // node_modules/.pnpm/p-limit@7.3.1/node_modules/p-limit/index.js
53650
+ function pLimit(concurrency) {
53651
+ let rejectOnClear = false;
53652
+ if (typeof concurrency === "object") {
53653
+ ({ concurrency, rejectOnClear = false } = concurrency);
53654
+ }
53655
+ validateConcurrency(concurrency);
53656
+ if (typeof rejectOnClear !== "boolean") {
53657
+ throw new TypeError("Expected `rejectOnClear` to be a boolean");
53658
+ }
53659
+ const queue = new Queue();
53660
+ let activeCount = 0;
53661
+ const resumeNext = () => {
53662
+ if (activeCount < concurrency && queue.size > 0) {
53663
+ activeCount++;
53664
+ queue.dequeue().run();
53665
+ }
53666
+ };
53667
+ const next = () => {
53668
+ activeCount--;
53669
+ resumeNext();
53670
+ };
53671
+ const run = async (function_, resolve8, arguments_) => {
53672
+ const result = (async () => function_(...arguments_))();
53673
+ resolve8(result);
53674
+ try {
53675
+ await result;
53676
+ } catch {
53677
+ }
53678
+ next();
53679
+ };
53680
+ const enqueue = (function_, resolve8, reject, arguments_) => {
53681
+ const queueItem = { reject };
53682
+ new Promise((internalResolve) => {
53683
+ queueItem.run = internalResolve;
53684
+ queue.enqueue(queueItem);
53685
+ }).then(run.bind(void 0, function_, resolve8, arguments_));
53686
+ if (activeCount < concurrency) {
53687
+ resumeNext();
53688
+ }
53689
+ };
53690
+ const generator = (function_, ...arguments_) => new Promise((resolve8, reject) => {
53691
+ enqueue(function_, resolve8, reject, arguments_);
53692
+ });
53693
+ Object.defineProperties(generator, {
53694
+ activeCount: {
53695
+ get: () => activeCount
53696
+ },
53697
+ pendingCount: {
53698
+ get: () => queue.size
53699
+ },
53700
+ clearQueue: {
53701
+ value() {
53702
+ if (!rejectOnClear) {
53703
+ queue.clear();
53704
+ return;
53705
+ }
53706
+ const abortError = AbortSignal.abort().reason;
53707
+ while (queue.size > 0) {
53708
+ queue.dequeue().reject(abortError);
53709
+ }
53710
+ }
53711
+ },
53712
+ concurrency: {
53713
+ get: () => concurrency,
53714
+ set(newConcurrency) {
53715
+ validateConcurrency(newConcurrency);
53716
+ concurrency = newConcurrency;
53717
+ queueMicrotask(() => {
53718
+ while (activeCount < concurrency && queue.size > 0) {
53719
+ resumeNext();
53720
+ }
53721
+ });
53722
+ }
53723
+ },
53724
+ map: {
53725
+ async value(iterable, function_) {
53726
+ const promises = Array.from(iterable, (value, index) => generator(function_, value, index));
53727
+ return Promise.all(promises);
53728
+ }
53729
+ }
53730
+ });
53731
+ return generator;
53732
+ }
53733
+ function validateConcurrency(concurrency) {
53734
+ if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
53735
+ throw new TypeError("Expected `concurrency` to be a number from 1 and up");
53736
+ }
53737
+ }
53591
53738
  var MAX_GIT_COMMAND_CONCURRENCY = 4;
53592
53739
  var MAX_FILE_IO_CONCURRENCY = 8;
53593
53740
  var MAX_WORKING_TREE_DIFF_BYTES = 10 * 1024 * 1024;
53594
53741
  var MAX_WORKING_TREE_FILES = 1e3;
53595
53742
  var MAX_UNTRACKED_DIFF_BYTES = 5 * 1024 * 1024;
53596
- function createConcurrencyLimiter(maxConcurrency) {
53597
- let activeOperations = 0;
53598
- const pendingOperations = [];
53599
- const startNext = () => {
53600
- while (activeOperations < maxConcurrency) {
53601
- const startOperation = pendingOperations.shift();
53602
- if (startOperation === void 0) {
53603
- return;
53604
- }
53605
- startOperation();
53606
- }
53607
- };
53608
- return (operation) => new Promise((resolvePromise, rejectPromise) => {
53609
- pendingOperations.push(() => {
53610
- activeOperations += 1;
53611
- void Promise.resolve().then(operation).then(resolvePromise, rejectPromise).finally(() => {
53612
- activeOperations -= 1;
53613
- startNext();
53614
- });
53615
- });
53616
- startNext();
53617
- });
53618
- }
53619
53743
  async function mapWithConcurrency(items, maxConcurrency, mapper) {
53620
53744
  const results = new Array(items.length);
53621
53745
  let nextIndex = 0;
@@ -54077,7 +54201,7 @@ async function readGitWorkingTreeStatus(projectRoot, gitCommandExecutor = execut
54077
54201
  }
54078
54202
  const resolvedProjectRoot = await realpath(projectRoot);
54079
54203
  const budget = new WorkingTreeReadBudget();
54080
- const limitGitCommand = createConcurrencyLimiter(MAX_GIT_COMMAND_CONCURRENCY);
54204
+ const limitGitCommand = pLimit(MAX_GIT_COMMAND_CONCURRENCY);
54081
54205
  const limitedGitCommandExecutor = (repositoryRoot, arguments_) => limitGitCommand(() => gitCommandExecutor(repositoryRoot, arguments_));
54082
54206
  let status2;
54083
54207
  let repositoryBranches = {
@@ -54175,11 +54299,11 @@ var GitCommandError = class extends Error {
54175
54299
  function literalPath(path) {
54176
54300
  return `:(literal)${path}`;
54177
54301
  }
54178
- async function executeGit2(repositoryRoot, arguments_, input = "") {
54179
- return new Promise((resolve7, reject) => {
54302
+ async function executeGit2(repositoryRoot, arguments_, input = "", environment = {}) {
54303
+ return new Promise((resolve8, reject) => {
54180
54304
  const consumesInput = input !== "";
54181
54305
  const child = spawn("git", ["-C", repositoryRoot, ...arguments_], {
54182
- env: { ...createGitEnvironment(), GIT_TERMINAL_PROMPT: "0" },
54306
+ env: { ...createGitEnvironment(), ...environment, GIT_TERMINAL_PROMPT: "0" },
54183
54307
  shell: false,
54184
54308
  // 无输入命令不创建 stdin pipe,避免短命令退出后写端异步触发 EPIPE。
54185
54309
  stdio: [consumesInput ? "pipe" : "ignore", "pipe", "pipe"],
@@ -54198,7 +54322,7 @@ async function executeGit2(repositoryRoot, arguments_, input = "") {
54198
54322
  if (error !== void 0) {
54199
54323
  reject(error);
54200
54324
  } else if (result !== void 0) {
54201
- resolve7(result);
54325
+ resolve8(result);
54202
54326
  }
54203
54327
  };
54204
54328
  const collect = (target, chunk) => {
@@ -54276,30 +54400,56 @@ async function commitSelectedProjectChanges(projectRoot, request) {
54276
54400
  }
54277
54401
  const selectedPaths = request.paths.map(literalPath);
54278
54402
  const stagedPaths = new Set(status2.staged.map((change) => change.path));
54279
- const untrackedPaths = status2.unstaged.filter(
54280
- (change) => change.kind === "create" && !stagedPaths.has(change.path) && request.paths.includes(change.path)
54281
- ).map((change) => literalPath(change.path));
54282
- if (untrackedPaths.length > 0) {
54283
- await executeGit2(repositoryRoot, ["add", "--intent-to-add", "--", ...untrackedPaths]).catch(
54284
- (error) => {
54285
- throw new GitCommitError(
54286
- "GIT_COMMIT_FAILED",
54287
- originalErrorMessage(error, "Selected files could not be prepared")
54403
+ const selectedStagedPaths = request.paths.filter((path) => stagedPaths.has(path));
54404
+ const selectedUnstagedPaths = request.paths.filter((path) => !stagedPaths.has(path));
54405
+ const temporaryIndexRoot = await mkdtemp(join(tmpdir(), "codexly-git-index-"));
54406
+ const temporaryIndexEnvironment = {
54407
+ GIT_INDEX_FILE: join(temporaryIndexRoot, "index")
54408
+ };
54409
+ try {
54410
+ await executeGit2(repositoryRoot, ["read-tree", "HEAD"], "", temporaryIndexEnvironment);
54411
+ if (selectedStagedPaths.length > 0) {
54412
+ const stagedEntries = await executeGit2(repositoryRoot, [
54413
+ "ls-files",
54414
+ "--stage",
54415
+ "-z",
54416
+ "--",
54417
+ ...selectedStagedPaths.map(literalPath)
54418
+ ]);
54419
+ await executeGit2(
54420
+ repositoryRoot,
54421
+ ["update-index", "--force-remove", "--", ...selectedStagedPaths],
54422
+ "",
54423
+ temporaryIndexEnvironment
54424
+ );
54425
+ if (stagedEntries.stdout.length > 0) {
54426
+ await executeGit2(
54427
+ repositoryRoot,
54428
+ ["update-index", "-z", "--index-info"],
54429
+ stagedEntries.stdout,
54430
+ temporaryIndexEnvironment
54288
54431
  );
54289
54432
  }
54290
- );
54291
- }
54292
- try {
54433
+ }
54434
+ if (selectedUnstagedPaths.length > 0) {
54435
+ await executeGit2(
54436
+ repositoryRoot,
54437
+ ["add", "--", ...selectedUnstagedPaths.map(literalPath)],
54438
+ "",
54439
+ temporaryIndexEnvironment
54440
+ );
54441
+ }
54293
54442
  await executeGit2(
54294
54443
  repositoryRoot,
54295
- ["commit", "--only", "--file=-", "--", ...selectedPaths],
54296
- request.message
54444
+ ["commit", "--file=-"],
54445
+ request.message,
54446
+ temporaryIndexEnvironment
54297
54447
  );
54448
+ await executeGit2(repositoryRoot, ["reset", "--quiet", "HEAD", "--", ...selectedPaths]);
54298
54449
  } catch (error) {
54299
- if (untrackedPaths.length > 0) {
54300
- await executeGit2(repositoryRoot, ["reset", "--", ...untrackedPaths]).catch(() => void 0);
54301
- }
54302
54450
  throw new GitCommitError("GIT_COMMIT_FAILED", originalErrorMessage(error, "Git commit failed"));
54451
+ } finally {
54452
+ await rm(temporaryIndexRoot, { force: true, recursive: true }).catch(() => void 0);
54303
54453
  }
54304
54454
  const commitSha = (await executeGit2(repositoryRoot, ["rev-parse", "HEAD"])).stdout.trim();
54305
54455
  let pushStatus = "not_requested";
@@ -55156,6 +55306,13 @@ function toMcpProviderHttpError(error) {
55156
55306
  return new MutationHttpError("PROVIDER_ERROR", message, 502, true);
55157
55307
  }
55158
55308
  var import_fastify = __toESM(require_fastify(), 1);
55309
+
55310
+ // node_modules/.pnpm/safe-stable-stringify@2.5.0/node_modules/safe-stable-stringify/esm/wrapper.js
55311
+ var import__ = __toESM(require_safe_stable_stringify(), 1);
55312
+ import__.default.configure;
55313
+ var wrapper_default = import__.default;
55314
+
55315
+ // packages/server/src/server-runtime.ts
55159
55316
  var MULTIPART_ENVELOPE_BYTES = 64 * 1024;
55160
55317
  function maximumAttachmentBytes(kind) {
55161
55318
  if (kind === "image") {
@@ -55300,19 +55457,12 @@ var CodexlyLogController = class extends import_fastify.LogController {
55300
55457
  }
55301
55458
  }
55302
55459
  };
55303
- function normalizeJsonForFingerprint(value) {
55304
- if (Array.isArray(value)) {
55305
- return value.map(normalizeJsonForFingerprint);
55306
- }
55307
- if (typeof value !== "object" || value === null) {
55308
- return value;
55309
- }
55310
- return Object.fromEntries(
55311
- Object.entries(value).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, item]) => [key, normalizeJsonForFingerprint(item)])
55312
- );
55313
- }
55314
55460
  function fingerprintPayload(payload) {
55315
- return JSON.stringify(normalizeJsonForFingerprint(payload));
55461
+ const fingerprint = wrapper_default(payload);
55462
+ if (fingerprint === void 0) {
55463
+ throw new TypeError("Payload must be JSON-serializable");
55464
+ }
55465
+ return fingerprint;
55316
55466
  }
55317
55467
  function toPendingRequestHttpError(error) {
55318
55468
  switch (error.code) {
@@ -55405,7 +55555,7 @@ async function generateCommitMessageWithCodex(provider, prompt, settings) {
55405
55555
  let timeout;
55406
55556
  let unsubscribeEvents;
55407
55557
  try {
55408
- const completedTurn = new Promise((resolve7, reject) => {
55558
+ const completedTurn = new Promise((resolve8, reject) => {
55409
55559
  unsubscribeEvents = provider.subscribeEvents(
55410
55560
  (event) => {
55411
55561
  if (event.taskId !== task.id) {
@@ -55415,7 +55565,7 @@ async function generateCommitMessageWithCodex(provider, prompt, settings) {
55415
55565
  completedAssistantMessages.set(event.turnId, event.payload.item.text);
55416
55566
  } else if (event.type === "turn.completed") {
55417
55567
  turnFinished = true;
55418
- resolve7(event.payload.turn);
55568
+ resolve8(event.payload.turn);
55419
55569
  } else if (event.type === "provider.error" && !event.payload.willRetry) {
55420
55570
  reject(new Error(event.payload.message));
55421
55571
  }
@@ -55659,6 +55809,71 @@ async function readProjectFileTree(projectRoot, directoryPath) {
55659
55809
  }
55660
55810
  return { entries, path: directoryPath ?? null };
55661
55811
  }
55812
+ var MAX_PROJECT_FILE_DEPTH = 20;
55813
+ var validFileName = /^(?!\.\.?$)[^/\\]{1,255}$/u;
55814
+ function parseProjectRelativePath(path) {
55815
+ const segments = path.split("/");
55816
+ if (path.startsWith("/") || path.endsWith("/") || path.includes("\\") || /^[A-Za-z]:/u.test(path) || segments.length > MAX_PROJECT_FILE_DEPTH || segments.some((segment) => segment === "" || segment === "." || segment === "..")) {
55817
+ throw new TypeError("Project file path is invalid");
55818
+ }
55819
+ return segments;
55820
+ }
55821
+ function assertPathInsideRoot(rootPath, targetPath) {
55822
+ const pathFromRoot = relative(rootPath, targetPath);
55823
+ if (pathFromRoot === "" || pathFromRoot === ".." || pathFromRoot.startsWith(`..${String.raw`/`}`)) {
55824
+ throw new TypeError("Project file path is outside the project root");
55825
+ }
55826
+ if (pathFromRoot.startsWith("..\\") || resolve(rootPath, pathFromRoot) !== targetPath) {
55827
+ throw new TypeError("Project file path is outside the project root");
55828
+ }
55829
+ }
55830
+ async function resolveProjectFileTarget(projectRoot, path) {
55831
+ const resolvedRoot = await realpath(projectRoot);
55832
+ const segments = parseProjectRelativePath(path);
55833
+ const absolutePath = resolve(resolvedRoot, ...segments);
55834
+ const resolvedParent = await realpath(dirname(absolutePath));
55835
+ assertPathInsideRoot(resolvedRoot, absolutePath);
55836
+ if (resolvedParent !== resolvedRoot) {
55837
+ assertPathInsideRoot(resolvedRoot, resolvedParent);
55838
+ }
55839
+ const stats = await lstat(absolutePath);
55840
+ if (stats.isSymbolicLink()) {
55841
+ throw new TypeError("Project file target must not be a symbolic link");
55842
+ }
55843
+ if (!stats.isFile() && !stats.isDirectory()) {
55844
+ throw new TypeError("Project file target is not a file or directory");
55845
+ }
55846
+ return { absolutePath, resolvedRoot };
55847
+ }
55848
+ async function pathExists2(path) {
55849
+ try {
55850
+ await lstat(path);
55851
+ return true;
55852
+ } catch (error) {
55853
+ if (error.code === "ENOENT") return false;
55854
+ throw error;
55855
+ }
55856
+ }
55857
+ async function renameProjectFile(projectRoot, path, name) {
55858
+ if (!validFileName.test(name) || name.includes("\0") || name.includes("\r") || name.includes("\n")) {
55859
+ throw new TypeError("Project file name is invalid");
55860
+ }
55861
+ const { absolutePath, resolvedRoot } = await resolveProjectFileTarget(projectRoot, path);
55862
+ const targetPath = resolve(dirname(absolutePath), name);
55863
+ assertPathInsideRoot(resolvedRoot, targetPath);
55864
+ if (await pathExists2(targetPath)) {
55865
+ throw new TypeError("Project file rename target already exists");
55866
+ }
55867
+ await rename(absolutePath, targetPath);
55868
+ const separatorIndex = path.lastIndexOf("/");
55869
+ const renamedPath = separatorIndex === -1 ? name : `${path.slice(0, separatorIndex)}/${name}`;
55870
+ return { path: renamedPath };
55871
+ }
55872
+ async function deleteProjectFile(projectRoot, path) {
55873
+ const { absolutePath } = await resolveProjectFileTarget(projectRoot, path);
55874
+ await rm(absolutePath, { recursive: true });
55875
+ return { path, status: "deleted" };
55876
+ }
55662
55877
  var MAX_PROJECT_IMAGE_PREVIEW_BYTES = 20 * 1024 * 1024;
55663
55878
  function isOutsideProject(relativePath) {
55664
55879
  return relativePath === ".." || relativePath.startsWith(`..${sep}`) || isAbsolute(relativePath);
@@ -55797,6 +56012,78 @@ async function readProjectSourceFile(projectRoot, requestedPath, cursor = 0) {
55797
56012
  path: isAbsoluteReference ? resolvedSourcePath : projectRelativePath.split(sep).join("/")
55798
56013
  };
55799
56014
  }
56015
+ function createProviderTurnInputResolver(attachmentStore) {
56016
+ return async (projectId, input, provider, taskId) => {
56017
+ const requestedIds = input.attachments.map((attachment) => attachment.id);
56018
+ if (new Set(requestedIds).size !== requestedIds.length) {
56019
+ throw new MutationHttpError("INVALID_REQUEST", "Duplicate attachments are not allowed", 400);
56020
+ }
56021
+ const attachmentIds = [];
56022
+ const attachments = [];
56023
+ for (const requestedId of requestedIds) {
56024
+ try {
56025
+ const [resolved2] = await attachmentStore.resolve(projectId, [requestedId]);
56026
+ if (resolved2 !== void 0) {
56027
+ attachmentIds.push(requestedId);
56028
+ attachments.push(resolved2);
56029
+ continue;
56030
+ }
56031
+ } catch (error) {
56032
+ if (!(error instanceof AttachmentNotFoundError)) throw error;
56033
+ }
56034
+ const historical = provider === void 0 || taskId === void 0 ? void 0 : await provider.readTaskAttachment(taskId, requestedId);
56035
+ if (historical === void 0) {
56036
+ throw new MutationHttpError(
56037
+ "ATTACHMENT_NOT_FOUND",
56038
+ "Attachment was not found or has expired",
56039
+ 404
56040
+ );
56041
+ }
56042
+ const cloned = await attachmentStore.add(projectId, {
56043
+ content: Readable.from([historical.content]),
56044
+ kind: historical.kind,
56045
+ mediaType: historical.mediaType,
56046
+ name: historical.name
56047
+ });
56048
+ const [resolved] = await attachmentStore.resolve(projectId, [cloned.attachment.id]);
56049
+ if (resolved !== void 0) {
56050
+ attachmentIds.push(cloned.attachment.id);
56051
+ attachments.push(resolved);
56052
+ }
56053
+ }
56054
+ const imageBytes = attachments.reduce(
56055
+ (total, attachment) => total + (attachment.kind === "image" ? attachment.size : 0),
56056
+ 0
56057
+ );
56058
+ const fileBytes = attachments.reduce(
56059
+ (total, attachment) => total + (attachment.kind === "image" ? 0 : attachment.size),
56060
+ 0
56061
+ );
56062
+ const imageCount = attachments.filter((attachment) => attachment.kind === "image").length;
56063
+ if (imageCount > MAX_AGENT_IMAGES || imageBytes > MAX_AGENT_IMAGE_TOTAL_BYTES) {
56064
+ throw new MutationHttpError("INVALID_REQUEST", "Image input limit exceeded", 400);
56065
+ }
56066
+ if (fileBytes > MAX_AGENT_FILE_TOTAL_BYTES) {
56067
+ throw new MutationHttpError("INVALID_REQUEST", "File input limit exceeded", 400);
56068
+ }
56069
+ return {
56070
+ attachmentIds,
56071
+ providerInput: {
56072
+ files: attachments.flatMap(
56073
+ (attachment) => attachment.kind === "file" ? [{ mediaType: attachment.mediaType, name: attachment.name, path: attachment.path }] : []
56074
+ ),
56075
+ images: attachments.flatMap(
56076
+ (attachment) => attachment.kind === "image" ? [{ mediaType: attachment.mediaType, url: attachment.url }] : []
56077
+ ),
56078
+ skills: input.skills,
56079
+ text: input.text,
56080
+ textAttachments: attachments.flatMap(
56081
+ (attachment) => attachment.kind === "text" ? [{ name: attachment.name, text: attachment.text }] : []
56082
+ )
56083
+ }
56084
+ };
56085
+ };
56086
+ }
55800
56087
  var DEFAULT_LAUNCH_CONFIRMATION_MS = 500;
55801
56088
  function readEnvironmentValue(environment, names) {
55802
56089
  for (const name of names) {
@@ -55813,15 +56100,15 @@ function readEnvironmentValue(environment, names) {
55813
56100
  }
55814
56101
  return void 0;
55815
56102
  }
55816
- async function firstExisting(candidates, pathExists2) {
56103
+ async function firstExisting(candidates, pathExists3) {
55817
56104
  for (const candidate of candidates) {
55818
- if (candidate !== void 0 && await pathExists2(candidate)) {
56105
+ if (candidate !== void 0 && await pathExists3(candidate)) {
55819
56106
  return candidate;
55820
56107
  }
55821
56108
  }
55822
56109
  return void 0;
55823
56110
  }
55824
- async function findPathExecutable(command, platform, environment, pathExists2) {
56111
+ async function findPathExecutable(command, platform, environment, pathExists3) {
55825
56112
  const pathValue = readEnvironmentValue(environment, ["PATH"]);
55826
56113
  if (pathValue === void 0) {
55827
56114
  return void 0;
@@ -55830,7 +56117,7 @@ async function findPathExecutable(command, platform, environment, pathExists2) {
55830
56117
  const delimiter = platform === "win32" ? ";" : ":";
55831
56118
  return firstExisting(
55832
56119
  pathValue.split(delimiter).filter(Boolean).map((directory) => pathApi.join(directory, command)),
55833
- pathExists2
56120
+ pathExists3
55834
56121
  );
55835
56122
  }
55836
56123
  function addCommand(commands, app, file, args, options = {}) {
@@ -55850,14 +56137,14 @@ function macAppCandidates(home, appName) {
55850
56137
  ...home === void 0 ? [] : [posix.join(home, "Applications", `${appName}.app`)]
55851
56138
  ];
55852
56139
  }
55853
- async function resolveMacCommands(environment, pathExists2) {
56140
+ async function resolveMacCommands(environment, pathExists3) {
55854
56141
  const commands = /* @__PURE__ */ new Map();
55855
- const open5 = await firstExisting(["/usr/bin/open"], pathExists2);
56142
+ const open5 = await firstExisting(["/usr/bin/open"], pathExists3);
55856
56143
  if (open5 === void 0) {
55857
56144
  return commands;
55858
56145
  }
55859
56146
  const home = readEnvironmentValue(environment, ["HOME"]);
55860
- const resolveApp = (name) => firstExisting(macAppCandidates(home, name), pathExists2);
56147
+ const resolveApp = (name) => firstExisting(macAppCandidates(home, name), pathExists3);
55861
56148
  const addMacApp = async (id, name, kind) => {
55862
56149
  const appPath = await resolveApp(name);
55863
56150
  addCommand(commands, { id, kind, name }, appPath === void 0 ? void 0 : open5, (target) => [
@@ -55884,7 +56171,7 @@ async function resolveMacCommands(environment, pathExists2) {
55884
56171
  );
55885
56172
  const terminalPath = await firstExisting(
55886
56173
  ["/System/Applications/Utilities/Terminal.app", "/Applications/Utilities/Terminal.app"],
55887
- pathExists2
56174
+ pathExists3
55888
56175
  );
55889
56176
  addCommand(
55890
56177
  commands,
@@ -55897,9 +56184,9 @@ async function resolveMacCommands(environment, pathExists2) {
55897
56184
  await addMacApp("android-studio", "Android Studio", "editor");
55898
56185
  return commands;
55899
56186
  }
55900
- async function resolveLinuxCommands(environment, pathExists2) {
56187
+ async function resolveLinuxCommands(environment, pathExists3) {
55901
56188
  const commands = /* @__PURE__ */ new Map();
55902
- const find = (command) => findPathExecutable(command, "linux", environment, pathExists2);
56189
+ const find = (command) => findPathExecutable(command, "linux", environment, pathExists3);
55903
56190
  addCommand(commands, { id: "zed", kind: "editor", name: "Zed" }, await find("zed"), (target) => [
55904
56191
  target.absolutePath
55905
56192
  ]);
@@ -55955,7 +56242,7 @@ async function resolveLinuxCommands(environment, pathExists2) {
55955
56242
  );
55956
56243
  const androidStudio = await firstExisting(
55957
56244
  ["/opt/android-studio/bin/studio.sh", await find("android-studio"), await find("studio.sh")],
55958
- pathExists2
56245
+ pathExists3
55959
56246
  );
55960
56247
  addCommand(
55961
56248
  commands,
@@ -55965,19 +56252,19 @@ async function resolveLinuxCommands(environment, pathExists2) {
55965
56252
  );
55966
56253
  return commands;
55967
56254
  }
55968
- async function resolveWindowsCommands(environment, pathExists2) {
56255
+ async function resolveWindowsCommands(environment, pathExists3) {
55969
56256
  const commands = /* @__PURE__ */ new Map();
55970
56257
  const systemRoot = readEnvironmentValue(environment, ["SystemRoot", "WINDIR"]);
55971
56258
  const localAppData = readEnvironmentValue(environment, ["LOCALAPPDATA"]);
55972
56259
  const programFiles = readEnvironmentValue(environment, ["ProgramFiles"]);
55973
56260
  const programFilesX86 = readEnvironmentValue(environment, ["ProgramFiles(x86)"]);
55974
- const find = (command) => findPathExecutable(command, "win32", environment, pathExists2);
56261
+ const find = (command) => findPathExecutable(command, "win32", environment, pathExists3);
55975
56262
  const zed = await firstExisting(
55976
56263
  [
55977
56264
  localAppData === void 0 ? void 0 : win32.join(localAppData, "Programs", "Zed", "Zed.exe"),
55978
56265
  await find("Zed.exe")
55979
56266
  ],
55980
- pathExists2
56267
+ pathExists3
55981
56268
  );
55982
56269
  addCommand(commands, { id: "zed", kind: "editor", name: "Zed" }, zed, (target) => [
55983
56270
  target.absolutePath
@@ -55987,7 +56274,7 @@ async function resolveWindowsCommands(environment, pathExists2) {
55987
56274
  localAppData === void 0 ? void 0 : win32.join(localAppData, "Programs", "Windsurf", "Windsurf.exe"),
55988
56275
  await find("Windsurf.exe")
55989
56276
  ],
55990
- pathExists2
56277
+ pathExists3
55991
56278
  );
55992
56279
  addCommand(commands, { id: "windsurf", kind: "editor", name: "Windsurf" }, windsurf, (target) => [
55993
56280
  target.absolutePath
@@ -55999,7 +56286,7 @@ async function resolveWindowsCommands(environment, pathExists2) {
55999
56286
  programFilesX86 === void 0 ? void 0 : win32.join(programFilesX86, "Microsoft VS Code", "Code.exe"),
56000
56287
  await find("Code.exe")
56001
56288
  ],
56002
- pathExists2
56289
+ pathExists3
56003
56290
  );
56004
56291
  addCommand(
56005
56292
  commands,
@@ -56012,7 +56299,7 @@ async function resolveWindowsCommands(environment, pathExists2) {
56012
56299
  systemRoot === void 0 ? void 0 : win32.join(systemRoot, "explorer.exe"),
56013
56300
  await find("explorer.exe")
56014
56301
  ],
56015
- pathExists2
56302
+ pathExists3
56016
56303
  );
56017
56304
  addCommand(
56018
56305
  commands,
@@ -56033,7 +56320,7 @@ async function resolveWindowsCommands(environment, pathExists2) {
56033
56320
  localAppData === void 0 ? void 0 : win32.join(localAppData, "Microsoft", "WindowsApps", "wt.exe"),
56034
56321
  await find("wt.exe")
56035
56322
  ],
56036
- pathExists2
56323
+ pathExists3
56037
56324
  );
56038
56325
  addCommand(
56039
56326
  commands,
@@ -56046,7 +56333,7 @@ async function resolveWindowsCommands(environment, pathExists2) {
56046
56333
  readEnvironmentValue(environment, ["COMSPEC"]),
56047
56334
  systemRoot === void 0 ? void 0 : win32.join(systemRoot, "System32", "cmd.exe")
56048
56335
  ],
56049
- pathExists2
56336
+ pathExists3
56050
56337
  );
56051
56338
  addCommand(
56052
56339
  commands,
@@ -56060,7 +56347,7 @@ async function resolveWindowsCommands(environment, pathExists2) {
56060
56347
  programFilesX86 === void 0 ? void 0 : win32.join(programFilesX86, "Android", "Android Studio", "bin", "studio64.exe"),
56061
56348
  await find("studio64.exe")
56062
56349
  ],
56063
- pathExists2
56350
+ pathExists3
56064
56351
  );
56065
56352
  addCommand(
56066
56353
  commands,
@@ -56163,7 +56450,7 @@ async function defaultPathExists(path) {
56163
56450
  }
56164
56451
  }
56165
56452
  function defaultSpawnDetached(file, args, options, launchConfirmationMs) {
56166
- return new Promise((resolve7, reject) => {
56453
+ return new Promise((resolve8, reject) => {
56167
56454
  const { observeEarlyExit, ...spawnOptions } = options;
56168
56455
  const child = spawn(file, [...args], {
56169
56456
  ...spawnOptions,
@@ -56191,20 +56478,20 @@ function defaultSpawnDetached(file, args, options, launchConfirmationMs) {
56191
56478
  if (!observeEarlyExit) {
56192
56479
  settle(() => {
56193
56480
  child.unref();
56194
- resolve7();
56481
+ resolve8();
56195
56482
  });
56196
56483
  return;
56197
56484
  }
56198
56485
  confirmationTimer = setTimeout(() => {
56199
56486
  settle(() => {
56200
56487
  child.unref();
56201
- resolve7();
56488
+ resolve8();
56202
56489
  });
56203
56490
  }, launchConfirmationMs);
56204
56491
  });
56205
56492
  child.once("exit", (exitCode, signal) => {
56206
56493
  if (exitCode === 0) {
56207
- settle(resolve7);
56494
+ settle(resolve8);
56208
56495
  return;
56209
56496
  }
56210
56497
  const reason = signal ? `signal ${signal}` : `code ${String(exitCode)}`;
@@ -56217,17 +56504,17 @@ function defaultSpawnDetached(file, args, options, launchConfirmationMs) {
56217
56504
  function createProjectOpenService(options = {}) {
56218
56505
  const platform = options.platform ?? process.platform;
56219
56506
  const environment = options.environment ?? process.env;
56220
- const pathExists2 = options.pathExists ?? defaultPathExists;
56507
+ const pathExists3 = options.pathExists ?? defaultPathExists;
56221
56508
  const launchConfirmationMs = options.launchConfirmationMs ?? DEFAULT_LAUNCH_CONFIRMATION_MS;
56222
56509
  const spawnDetached = options.spawnDetached ?? ((file, args, spawnOptions) => defaultSpawnDetached(file, args, spawnOptions, launchConfirmationMs));
56223
56510
  const resolveCommands = () => {
56224
56511
  switch (platform) {
56225
56512
  case "darwin":
56226
- return resolveMacCommands(environment, pathExists2);
56513
+ return resolveMacCommands(environment, pathExists3);
56227
56514
  case "linux":
56228
- return resolveLinuxCommands(environment, pathExists2);
56515
+ return resolveLinuxCommands(environment, pathExists3);
56229
56516
  case "win32":
56230
- return resolveWindowsCommands(environment, pathExists2);
56517
+ return resolveWindowsCommands(environment, pathExists3);
56231
56518
  }
56232
56519
  };
56233
56520
  return {
@@ -56253,19 +56540,6 @@ function createProjectOpenService(options = {}) {
56253
56540
  }
56254
56541
  };
56255
56542
  }
56256
- async function reconcileQueuedAttachments(attachmentStore, projectId, taskId, queue) {
56257
- const queuedSubmissionIds = [];
56258
- let cursor;
56259
- do {
56260
- const page = await queue.list(taskId, {
56261
- ...cursor === void 0 ? {} : { cursor },
56262
- limit: 100
56263
- });
56264
- queuedSubmissionIds.push(...page.data.map((submission) => submission.id));
56265
- cursor = page.nextCursor ?? void 0;
56266
- } while (cursor !== void 0);
56267
- attachmentStore.reconcileQueue(projectId, queuedSubmissionIds);
56268
- }
56269
56543
  function createProjectRuntimeContext(options) {
56270
56544
  const eventStream = new AgentEventStream({
56271
56545
  ...options.eventBufferSize === void 0 ? {} : { capacity: options.eventBufferSize },
@@ -56282,14 +56556,12 @@ function createProjectRuntimeContext(options) {
56282
56556
  options.onActivity();
56283
56557
  if (event.type === "turn.completed") {
56284
56558
  void attachmentStore.releaseTurn(scope.id, event.payload.turn.id).catch(onAttachmentReleaseError);
56285
- }
56286
- if (event.type === "queue.changed" && provider.queue !== void 0) {
56287
- void reconcileQueuedAttachments(
56288
- attachmentStore,
56289
- scope.id,
56290
- event.taskId,
56291
- provider.queue
56292
- ).catch(onAttachmentReleaseError);
56559
+ void options.onTurnCompleted?.({
56560
+ eventStream,
56561
+ projectId: scope.id,
56562
+ provider,
56563
+ taskId: event.taskId
56564
+ }).catch(onAttachmentReleaseError);
56293
56565
  }
56294
56566
  if (event.type === "project.git_metadata_changed") {
56295
56567
  invalidateProjectGitBranchCache(event.payload.rootPath);
@@ -56385,8 +56657,8 @@ var ProjectRuntimeLifecycleLock = class {
56385
56657
  async run(projectId, operation) {
56386
56658
  const predecessor = this.#tails.get(projectId) ?? Promise.resolve();
56387
56659
  let release;
56388
- const tail = new Promise((resolve7) => {
56389
- release = resolve7;
56660
+ const tail = new Promise((resolve8) => {
56661
+ release = resolve8;
56390
56662
  });
56391
56663
  this.#tails.set(projectId, tail);
56392
56664
  await predecessor.catch(() => void 0);
@@ -56400,6 +56672,224 @@ var ProjectRuntimeLifecycleLock = class {
56400
56672
  }
56401
56673
  }
56402
56674
  };
56675
+ var TaskQueueBlockedError = class extends Error {
56676
+ constructor() {
56677
+ super("Task queue is blocked by an edited submission");
56678
+ this.name = "TaskQueueBlockedError";
56679
+ }
56680
+ };
56681
+ var TaskQueueItemNotFoundError = class extends Error {
56682
+ constructor() {
56683
+ super("Queued submission was not found");
56684
+ this.name = "TaskQueueItemNotFoundError";
56685
+ }
56686
+ };
56687
+ var PersistentTaskQueue = class {
56688
+ #attachmentStore;
56689
+ #locks = /* @__PURE__ */ new Map();
56690
+ #readTaskSettings;
56691
+ #repository;
56692
+ #resolveProviderInput;
56693
+ constructor(options) {
56694
+ this.#attachmentStore = options.attachmentStore;
56695
+ this.#readTaskSettings = options.readTaskSettings;
56696
+ this.#repository = options.repository;
56697
+ this.#resolveProviderInput = options.resolveProviderInput;
56698
+ }
56699
+ async add(runtime, input, clientUserMessageId) {
56700
+ const { attachmentIds } = await this.#resolveProviderInput(
56701
+ runtime.projectId,
56702
+ input,
56703
+ runtime.provider,
56704
+ runtime.taskId
56705
+ );
56706
+ const storedInput = { ...input, attachments: attachmentIds.map((id) => ({ id })) };
56707
+ const record = await this.#repository.addQueue({
56708
+ clientUserMessageId,
56709
+ id: randomUUID(),
56710
+ input: storedInput,
56711
+ projectId: runtime.projectId,
56712
+ status: "queued",
56713
+ taskId: runtime.taskId
56714
+ });
56715
+ await this.#attachmentStore.retainQueue(runtime.projectId, attachmentIds, record.id);
56716
+ this.#publishChanged(runtime);
56717
+ return this.#mapRecord(record);
56718
+ }
56719
+ async delete(runtime, queuedSubmissionId) {
56720
+ return this.#withTaskLock(runtime, async () => {
56721
+ const deleted = await this.#repository.deleteQueue(
56722
+ runtime.projectId,
56723
+ runtime.taskId,
56724
+ queuedSubmissionId
56725
+ );
56726
+ if (deleted) {
56727
+ await this.#attachmentStore.releaseQueue(runtime.projectId, queuedSubmissionId);
56728
+ this.#publishChanged(runtime);
56729
+ }
56730
+ return deleted;
56731
+ });
56732
+ }
56733
+ async list(runtime) {
56734
+ const records = await this.#repository.listQueue(runtime.projectId, runtime.taskId);
56735
+ return Promise.all(records.map((record) => this.#mapRecord(record)));
56736
+ }
56737
+ async reorder(runtime, queuedSubmissionIds) {
56738
+ await this.#withTaskLock(runtime, async () => {
56739
+ await this.#repository.reorderQueue(runtime.projectId, runtime.taskId, queuedSubmissionIds);
56740
+ this.#publishChanged(runtime);
56741
+ });
56742
+ }
56743
+ async start(runtime, queuedSubmissionId) {
56744
+ const turn = await this.#withTaskLock(
56745
+ runtime,
56746
+ () => this.#startUnlocked(runtime, queuedSubmissionId)
56747
+ );
56748
+ if (turn === void 0) {
56749
+ throw new TaskQueueItemNotFoundError();
56750
+ }
56751
+ return turn;
56752
+ }
56753
+ async startNext(runtime) {
56754
+ await this.#withTaskLock(runtime, async () => {
56755
+ const [first2] = await this.#repository.listQueue(runtime.projectId, runtime.taskId);
56756
+ if (first2?.status !== "queued") return;
56757
+ await this.#startUnlocked(runtime, first2.id);
56758
+ });
56759
+ }
56760
+ async update(runtime, queuedSubmissionId, input, status2) {
56761
+ return this.#withTaskLock(runtime, async () => {
56762
+ const { attachmentIds } = await this.#resolveProviderInput(
56763
+ runtime.projectId,
56764
+ input,
56765
+ runtime.provider,
56766
+ runtime.taskId
56767
+ );
56768
+ const storedInput = { ...input, attachments: attachmentIds.map((id) => ({ id })) };
56769
+ const record = await this.#repository.updateQueue(
56770
+ runtime.projectId,
56771
+ runtime.taskId,
56772
+ queuedSubmissionId,
56773
+ storedInput,
56774
+ status2
56775
+ );
56776
+ if (record === void 0) throw new TaskQueueItemNotFoundError();
56777
+ await this.#attachmentStore.retainQueue(
56778
+ runtime.projectId,
56779
+ attachmentIds,
56780
+ queuedSubmissionId,
56781
+ true
56782
+ );
56783
+ this.#publishChanged(runtime);
56784
+ return this.#mapRecord(record);
56785
+ });
56786
+ }
56787
+ async #mapRecord(record) {
56788
+ const attachments = await Promise.all(
56789
+ record.input.attachments.map(
56790
+ async ({ id }) => (await this.#attachmentStore.read(record.projectId, id)).attachment
56791
+ )
56792
+ );
56793
+ return {
56794
+ attachments,
56795
+ clientUserMessageId: record.clientUserMessageId,
56796
+ id: record.id,
56797
+ skills: record.input.skills,
56798
+ status: record.status,
56799
+ text: record.input.text
56800
+ };
56801
+ }
56802
+ #publishChanged(runtime) {
56803
+ runtime.eventStream.publish({ payload: {}, taskId: runtime.taskId, type: "queue.changed" });
56804
+ }
56805
+ async #startUnlocked(runtime, queuedSubmissionId) {
56806
+ const records = await this.#repository.listQueue(runtime.projectId, runtime.taskId);
56807
+ const selectedIndex = queuedSubmissionId === void 0 ? 0 : records.findIndex((record) => record.id === queuedSubmissionId);
56808
+ if (selectedIndex < 0) return void 0;
56809
+ const editingIndex = records.findIndex((record) => record.status === "editing");
56810
+ if (editingIndex >= 0 && selectedIndex >= editingIndex) throw new TaskQueueBlockedError();
56811
+ const selected = records[selectedIndex];
56812
+ if (selected?.status !== "queued") throw new TaskQueueBlockedError();
56813
+ const task = await runtime.provider.readTask(runtime.taskId);
56814
+ if (task?.turns.some((turn2) => turn2.status === "running") === true) {
56815
+ throw new TaskQueueBlockedError();
56816
+ }
56817
+ const { providerInput } = await this.#resolveProviderInput(
56818
+ runtime.projectId,
56819
+ selected.input,
56820
+ runtime.provider,
56821
+ runtime.taskId
56822
+ );
56823
+ const settings = await this.#readTaskSettings(runtime.projectId, runtime.taskId);
56824
+ const turn = await runtime.provider.startTurn(runtime.taskId, providerInput, settings);
56825
+ await this.#repository.deleteQueue(runtime.projectId, runtime.taskId, selected.id);
56826
+ await this.#attachmentStore.startQueue(runtime.projectId, selected.id, turn.id);
56827
+ this.#publishChanged(runtime);
56828
+ return turn;
56829
+ }
56830
+ async #withTaskLock(runtime, action) {
56831
+ const key = `${runtime.projectId}\0${runtime.taskId}`;
56832
+ const previous = this.#locks.get(key) ?? Promise.resolve();
56833
+ let release;
56834
+ const current = new Promise((resolve8) => {
56835
+ release = resolve8;
56836
+ });
56837
+ const tail = previous.then(() => current);
56838
+ this.#locks.set(key, tail);
56839
+ await previous;
56840
+ try {
56841
+ return await action();
56842
+ } finally {
56843
+ release();
56844
+ if (this.#locks.get(key) === tail) this.#locks.delete(key);
56845
+ }
56846
+ }
56847
+ };
56848
+
56849
+ // packages/server/src/memory-task-queue-repository.ts
56850
+ function createMemoryTaskQueueRepository() {
56851
+ const records = /* @__PURE__ */ new Map();
56852
+ const key = (projectId, taskId) => `${projectId}\0${taskId}`;
56853
+ return {
56854
+ addQueue(record) {
56855
+ const queue = records.get(key(record.projectId, record.taskId)) ?? [];
56856
+ queue.push(record);
56857
+ records.set(key(record.projectId, record.taskId), queue);
56858
+ return Promise.resolve(record);
56859
+ },
56860
+ deleteQueue(projectId, taskId, queuedSubmissionId) {
56861
+ const queue = records.get(key(projectId, taskId)) ?? [];
56862
+ const index = queue.findIndex((record) => record.id === queuedSubmissionId);
56863
+ if (index < 0) return Promise.resolve(false);
56864
+ queue.splice(index, 1);
56865
+ return Promise.resolve(true);
56866
+ },
56867
+ listQueue(projectId, taskId) {
56868
+ return Promise.resolve([...records.get(key(projectId, taskId)) ?? []]);
56869
+ },
56870
+ reorderQueue(projectId, taskId, queuedSubmissionIds) {
56871
+ const queue = records.get(key(projectId, taskId)) ?? [];
56872
+ const byId = new Map(queue.map((record) => [record.id, record]));
56873
+ if (queuedSubmissionIds.length !== queue.length || new Set(queuedSubmissionIds).size !== queue.length || queuedSubmissionIds.some((id) => !byId.has(id))) {
56874
+ throw new Error("Task queue order must contain every queued submission exactly once");
56875
+ }
56876
+ records.set(
56877
+ key(projectId, taskId),
56878
+ queuedSubmissionIds.map((id) => byId.get(id))
56879
+ );
56880
+ return Promise.resolve();
56881
+ },
56882
+ updateQueue(projectId, taskId, queuedSubmissionId, input, status2) {
56883
+ const queue = records.get(key(projectId, taskId)) ?? [];
56884
+ const index = queue.findIndex((record) => record.id === queuedSubmissionId);
56885
+ const current = queue[index];
56886
+ if (current === void 0) return Promise.resolve(void 0);
56887
+ const updated = { ...current, input, status: status2 };
56888
+ queue[index] = updated;
56889
+ return Promise.resolve(updated);
56890
+ }
56891
+ };
56892
+ }
56403
56893
  var ProjectDirectoryBrowserError = class extends Error {
56404
56894
  constructor(message, reason, options) {
56405
56895
  super(message, options);
@@ -56901,6 +57391,106 @@ async function filterProjectFileSearchMatches(projectRoot, page) {
56901
57391
  return { data };
56902
57392
  }
56903
57393
 
57394
+ // packages/server/src/routes/project-file-mutation-routes.ts
57395
+ function mapProjectFileMutationError(error) {
57396
+ if (error instanceof ProjectRootScopeError) {
57397
+ throw new MutationHttpError(
57398
+ error.code === "PROJECT_NOT_FOUND" ? "PROJECT_NOT_FOUND" : "INVALID_REQUEST",
57399
+ error.message,
57400
+ error.code === "PROJECT_NOT_FOUND" ? 404 : 400
57401
+ );
57402
+ }
57403
+ const errorCode = error.code;
57404
+ if (errorCode === "ENOENT") {
57405
+ throw new MutationHttpError("PROJECT_FILE_NOT_FOUND", "Project file was not found", 404);
57406
+ }
57407
+ if (error instanceof TypeError) {
57408
+ const conflict = error.message.includes("already exists");
57409
+ throw new MutationHttpError(
57410
+ conflict ? "PROJECT_FILE_CONFLICT" : "INVALID_REQUEST",
57411
+ conflict ? "A file or directory with that name already exists" : "Project file request is invalid",
57412
+ conflict ? 409 : 400
57413
+ );
57414
+ }
57415
+ throw new MutationHttpError("PROJECT_FILE_MUTATION_FAILED", "Project file mutation failed", 500);
57416
+ }
57417
+ var mutationResponses = {
57418
+ 400: AgentMutationErrorSchema,
57419
+ 404: AgentMutationErrorSchema,
57420
+ 409: AgentMutationErrorSchema,
57421
+ 500: AgentMutationErrorSchema,
57422
+ 503: AgentMutationErrorSchema
57423
+ };
57424
+ function registerProjectFileMutationRoutes(app, context, resolveProjectFileRoot2) {
57425
+ const { deleteProjectFile: deleteProjectFile2, renameProjectFile: renameProjectFile2, runIdempotent } = context;
57426
+ app.post(
57427
+ "/v1/projects/:projectId/files/rename",
57428
+ {
57429
+ schema: {
57430
+ body: RenameProjectFileRequestSchema,
57431
+ headers: IdempotencyHeadersSchema,
57432
+ params: ProjectParamsSchema,
57433
+ querystring: ProjectRootQuerySchema,
57434
+ response: { 200: RenameProjectFileResponseSchema, ...mutationResponses }
57435
+ }
57436
+ },
57437
+ async (request) => runIdempotent(
57438
+ [
57439
+ "rename-project-file",
57440
+ request.params.projectId,
57441
+ request.query.rootPath,
57442
+ request.body.path
57443
+ ],
57444
+ request.headers["idempotency-key"],
57445
+ request.body,
57446
+ async () => {
57447
+ try {
57448
+ const root = await resolveProjectFileRoot2(
57449
+ request.params.projectId,
57450
+ request.query.rootPath
57451
+ );
57452
+ return await renameProjectFile2(root.path, request.body.path, request.body.name);
57453
+ } catch (error) {
57454
+ mapProjectFileMutationError(error);
57455
+ }
57456
+ }
57457
+ )
57458
+ );
57459
+ app.post(
57460
+ "/v1/projects/:projectId/files/delete",
57461
+ {
57462
+ schema: {
57463
+ body: DeleteProjectFileRequestSchema,
57464
+ headers: IdempotencyHeadersSchema,
57465
+ params: ProjectParamsSchema,
57466
+ querystring: ProjectRootQuerySchema,
57467
+ response: { 200: DeleteProjectFileResponseSchema, ...mutationResponses }
57468
+ }
57469
+ },
57470
+ async (request) => runIdempotent(
57471
+ [
57472
+ "delete-project-file",
57473
+ request.params.projectId,
57474
+ request.query.rootPath,
57475
+ request.body.path
57476
+ ],
57477
+ request.headers["idempotency-key"],
57478
+ request.body,
57479
+ async () => {
57480
+ try {
57481
+ const root = await resolveProjectFileRoot2(
57482
+ request.params.projectId,
57483
+ request.query.rootPath
57484
+ );
57485
+ return await deleteProjectFile2(root.path, request.body.path);
57486
+ } catch (error) {
57487
+ mapProjectFileMutationError(error);
57488
+ }
57489
+ }
57490
+ )
57491
+ );
57492
+ }
57493
+
56904
57494
  // packages/server/src/routes/project-file-routes.ts
56905
57495
  async function resolveReadRoot(repository, getProjectContext, projectId, rootPath, reply) {
56906
57496
  try {
@@ -56942,6 +57532,11 @@ function registerProjectFileRoutes(app, context) {
56942
57532
  resolveHostAttachment: resolveHostAttachment2,
56943
57533
  stopProjectFileSearch
56944
57534
  } = context;
57535
+ registerProjectFileMutationRoutes(
57536
+ app,
57537
+ context,
57538
+ (projectId, rootPath) => resolveProjectFileRoot(projectRepository, getProjectContext, projectId, rootPath)
57539
+ );
56945
57540
  app.get(
56946
57541
  "/v1/projects/:projectId/files/tree",
56947
57542
  {
@@ -58278,7 +58873,7 @@ var registerProjectRoutes = (app, context, done) => {
58278
58873
  };
58279
58874
 
58280
58875
  // packages/server/src/routes/provider-connection-routes.ts
58281
- var mutationResponses = {
58876
+ var mutationResponses2 = {
58282
58877
  400: AgentMutationErrorSchema,
58283
58878
  409: AgentMutationErrorSchema,
58284
58879
  502: AgentMutationErrorSchema,
@@ -58297,7 +58892,7 @@ var registerProviderConnectionRoutes = (app, context, done) => {
58297
58892
  schema: {
58298
58893
  body: StartOfficialProviderLoginRequestSchema,
58299
58894
  headers: IdempotencyHeadersSchema,
58300
- response: { 200: StartOfficialProviderLoginResponseSchema, ...mutationResponses }
58895
+ response: { 200: StartOfficialProviderLoginResponseSchema, ...mutationResponses2 }
58301
58896
  }
58302
58897
  },
58303
58898
  (request) => runIdempotent(
@@ -58323,7 +58918,7 @@ var registerProviderConnectionRoutes = (app, context, done) => {
58323
58918
  schema: {
58324
58919
  body: CancelProviderLoginRequestSchema,
58325
58920
  headers: IdempotencyHeadersSchema,
58326
- response: { 200: AgentProviderConnectionMutationResponseSchema, ...mutationResponses }
58921
+ response: { 200: AgentProviderConnectionMutationResponseSchema, ...mutationResponses2 }
58327
58922
  }
58328
58923
  },
58329
58924
  (request) => runIdempotent(
@@ -58339,7 +58934,7 @@ var registerProviderConnectionRoutes = (app, context, done) => {
58339
58934
  schema: {
58340
58935
  body: ConfigureCustomProviderRequestSchema,
58341
58936
  headers: IdempotencyHeadersSchema,
58342
- response: { 200: ConfigureCustomProviderResponseSchema, ...mutationResponses }
58937
+ response: { 200: ConfigureCustomProviderResponseSchema, ...mutationResponses2 }
58343
58938
  }
58344
58939
  },
58345
58940
  (request) => runIdempotent(
@@ -58365,7 +58960,7 @@ var registerProviderConnectionRoutes = (app, context, done) => {
58365
58960
  schema: {
58366
58961
  body: StartOfficialProviderLoginRequestSchema,
58367
58962
  headers: IdempotencyHeadersSchema,
58368
- response: { 200: AgentProviderConnectionMutationResponseSchema, ...mutationResponses }
58963
+ response: { 200: AgentProviderConnectionMutationResponseSchema, ...mutationResponses2 }
58369
58964
  }
58370
58965
  },
58371
58966
  (request) => runIdempotent(
@@ -58377,10 +58972,215 @@ var registerProviderConnectionRoutes = (app, context, done) => {
58377
58972
  );
58378
58973
  done();
58379
58974
  };
58975
+ var PetAssetParamsSchema = {
58976
+ additionalProperties: false,
58977
+ properties: { assetId: { pattern: "^[a-f0-9]{64}$", type: "string" } },
58978
+ required: ["assetId"],
58979
+ type: "object"
58980
+ };
58981
+ var registerPetRoutes = (app, { petProvider, runIdempotent }, done) => {
58982
+ app.get(
58983
+ "/v1/pets",
58984
+ {
58985
+ schema: {
58986
+ response: { 200: WorkbenchPetCatalogResponseSchema, 500: ErrorResponseSchema }
58987
+ }
58988
+ },
58989
+ async (_request, reply) => {
58990
+ try {
58991
+ return { data: await petProvider.listPets() };
58992
+ } catch {
58993
+ return reply.code(500).send({ code: "PET_CATALOG_UNAVAILABLE", message: "Pet catalog is unavailable" });
58994
+ }
58995
+ }
58996
+ );
58997
+ app.get(
58998
+ "/v1/pets/assets/:assetId",
58999
+ {
59000
+ schema: {
59001
+ params: PetAssetParamsSchema,
59002
+ response: {
59003
+ 404: ErrorResponseSchema,
59004
+ 422: ErrorResponseSchema,
59005
+ 500: ErrorResponseSchema
59006
+ }
59007
+ }
59008
+ },
59009
+ async (request, reply) => {
59010
+ try {
59011
+ const asset = await petProvider.openPetAsset(request.params.assetId);
59012
+ if (asset === void 0) {
59013
+ return await reply.code(404).send({ code: "PET_NOT_FOUND", message: "Pet asset not found" });
59014
+ }
59015
+ reply.header("Cache-Control", "private, no-cache").header("Cross-Origin-Resource-Policy", "same-origin").header("ETag", asset.etag).header("X-Content-Type-Options", "nosniff");
59016
+ if (request.headers["if-none-match"] === asset.etag) return await reply.code(304).send();
59017
+ return await reply.type(asset.contentType).send(Buffer$1.from(asset.content));
59018
+ } catch (error) {
59019
+ if (error instanceof WorkbenchPetProviderError && error.code === "invalid") {
59020
+ return await reply.code(422).send({ code: "PET_ASSET_INVALID", message: "Pet asset is invalid" });
59021
+ }
59022
+ return await reply.code(500).send({ code: "PET_ASSET_UNAVAILABLE", message: "Pet asset is unavailable" });
59023
+ }
59024
+ }
59025
+ );
59026
+ app.post(
59027
+ "/v1/pets/downloads",
59028
+ {
59029
+ schema: {
59030
+ body: WorkbenchPetDownloadRequestSchema,
59031
+ headers: IdempotencyHeadersSchema,
59032
+ response: {
59033
+ 200: WorkbenchPetDownloadResponseSchema,
59034
+ 400: AgentMutationErrorSchema,
59035
+ 404: AgentMutationErrorSchema,
59036
+ 409: AgentMutationErrorSchema,
59037
+ 502: AgentMutationErrorSchema,
59038
+ 503: AgentMutationErrorSchema
59039
+ }
59040
+ }
59041
+ },
59042
+ async (request) => runIdempotent(
59043
+ ["download-workbench-pet", request.body.petId],
59044
+ request.headers["idempotency-key"],
59045
+ request.body,
59046
+ async () => {
59047
+ try {
59048
+ return { data: await petProvider.ensurePetAsset(request.body.petId) };
59049
+ } catch (error) {
59050
+ if (error instanceof WorkbenchPetProviderError) {
59051
+ if (error.code === "not_found") {
59052
+ throw new MutationHttpError("PET_NOT_FOUND", "Pet not found", 404);
59053
+ }
59054
+ if (error.code === "invalid") {
59055
+ throw new MutationHttpError("PET_ASSET_INVALID", "Pet cannot be downloaded", 400);
59056
+ }
59057
+ }
59058
+ throw new MutationHttpError(
59059
+ "PET_DOWNLOAD_FAILED",
59060
+ "Pet asset download failed",
59061
+ 502,
59062
+ true
59063
+ );
59064
+ }
59065
+ }
59066
+ )
59067
+ );
59068
+ done();
59069
+ };
59070
+
59071
+ // packages/server/src/bing-wallpaper.ts
59072
+ var BING_ORIGIN = "https://www.bing.com";
59073
+ var BING_METADATA_URL = `${BING_ORIGIN}/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=zh-CN`;
59074
+ var FETCH_TIMEOUT_MS = 1e4;
59075
+ var MAX_METADATA_BYTES = 64 * 1024;
59076
+ var MAX_WALLPAPER_BYTES = 20 * 1024 * 1024;
59077
+ function fetchWithGlobal(input, init) {
59078
+ return globalThis.fetch(input, init);
59079
+ }
59080
+ async function readBoundedBody(response, maximumBytes, label) {
59081
+ if (!response.ok || response.body === null) {
59082
+ throw new Error(`Bing wallpaper ${label} request failed`);
59083
+ }
59084
+ const declaredLength = Number(response.headers.get("content-length"));
59085
+ if (Number.isFinite(declaredLength) && declaredLength > maximumBytes) {
59086
+ throw new Error(`Bing wallpaper ${label} response is too large`);
59087
+ }
59088
+ const chunks = [];
59089
+ let totalBytes = 0;
59090
+ const reader = response.body.getReader();
59091
+ let result = await reader.read();
59092
+ while (!result.done) {
59093
+ const chunk = result.value;
59094
+ totalBytes += chunk.byteLength;
59095
+ if (totalBytes > maximumBytes) {
59096
+ await reader.cancel();
59097
+ throw new Error(`Bing wallpaper ${label} response is too large`);
59098
+ }
59099
+ chunks.push(Buffer.from(chunk));
59100
+ result = await reader.read();
59101
+ }
59102
+ return Buffer.concat(chunks, totalBytes);
59103
+ }
59104
+ function readImageUrl(metadata) {
59105
+ let value;
59106
+ try {
59107
+ value = JSON.parse(metadata.toString("utf8"));
59108
+ } catch {
59109
+ throw new Error("Bing wallpaper returned invalid metadata");
59110
+ }
59111
+ const images = isRecord(value) ? value["images"] : null;
59112
+ const image = Array.isArray(images) ? images[0] : null;
59113
+ const path = isRecord(image) ? image["url"] : null;
59114
+ if (typeof path !== "string" || !path.startsWith("/")) {
59115
+ throw new Error("Bing wallpaper returned an invalid image URL");
59116
+ }
59117
+ const url = new URL(path, BING_ORIGIN);
59118
+ if (url.origin !== BING_ORIGIN || url.pathname !== "/th") {
59119
+ throw new Error("Bing wallpaper returned an invalid image URL");
59120
+ }
59121
+ return url.toString();
59122
+ }
59123
+ function isRecord(value) {
59124
+ return typeof value === "object" && value !== null && !Array.isArray(value);
59125
+ }
59126
+ async function loadWallpaper(fetcher) {
59127
+ const metadataResponse = await fetcher(BING_METADATA_URL, {
59128
+ redirect: "error",
59129
+ signal: AbortSignal.timeout(FETCH_TIMEOUT_MS)
59130
+ });
59131
+ if (!metadataResponse.headers.get("content-type")?.startsWith("application/json")) {
59132
+ throw new Error("Bing wallpaper returned invalid metadata content type");
59133
+ }
59134
+ const metadata = await readBoundedBody(metadataResponse, MAX_METADATA_BYTES, "metadata");
59135
+ const imageUrl = readImageUrl(metadata);
59136
+ const imageResponse = await fetcher(imageUrl, {
59137
+ redirect: "error",
59138
+ signal: AbortSignal.timeout(FETCH_TIMEOUT_MS)
59139
+ });
59140
+ if (!imageResponse.headers.get("content-type")?.startsWith("image/jpeg")) {
59141
+ throw new Error("Bing wallpaper returned invalid image content type");
59142
+ }
59143
+ const body = await readBoundedBody(imageResponse, MAX_WALLPAPER_BYTES, "image");
59144
+ if (body.length < 4 || body[0] !== 255 || body[1] !== 216 || body[2] !== 255) {
59145
+ throw new Error("Bing wallpaper returned invalid JPEG content");
59146
+ }
59147
+ return { body, contentType: "image/jpeg" };
59148
+ }
59149
+ function createBingWallpaperService({
59150
+ fetcher = fetchWithGlobal
59151
+ } = {}) {
59152
+ let cached = null;
59153
+ let pending = null;
59154
+ let loadGeneration = 0;
59155
+ return {
59156
+ read(day) {
59157
+ if (cached?.day === day) return Promise.resolve(cached.wallpaper);
59158
+ if (pending?.day === day) return pending.promise;
59159
+ const generation = ++loadGeneration;
59160
+ const promise = loadWallpaper(fetcher).then((wallpaper) => {
59161
+ if (generation === loadGeneration) cached = { day, wallpaper };
59162
+ return wallpaper;
59163
+ });
59164
+ pending = { day, promise };
59165
+ const clearPending = () => {
59166
+ if (pending?.promise === promise) pending = null;
59167
+ };
59168
+ void promise.then(clearPending, clearPending);
59169
+ return promise;
59170
+ }
59171
+ };
59172
+ }
58380
59173
 
58381
59174
  // packages/server/src/routes/runtime-routes.ts
58382
59175
  var APP_UPDATE_HANDLER_TIMEOUT_MS = 15e4;
59176
+ var BingWallpaperQuerySchema = {
59177
+ additionalProperties: false,
59178
+ properties: { day: { pattern: "^\\d{4}-\\d{2}-\\d{2}$", type: "string" } },
59179
+ required: ["day"],
59180
+ type: "object"
59181
+ };
58383
59182
  var registerRuntimeRoutes = (app, context, done) => {
59183
+ const bingWallpaper = createBingWallpaperService();
58384
59184
  const {
58385
59185
  assertValidProjectDefaults: assertValidProjectDefaults2,
58386
59186
  capabilities,
@@ -58402,6 +59202,14 @@ var registerRuntimeRoutes = (app, context, done) => {
58402
59202
  { schema: { response: { 200: AppInfoResponseSchema } } },
58403
59203
  () => readAppInfo()
58404
59204
  );
59205
+ app.get(
59206
+ "/v1/workbench-background/bing",
59207
+ { schema: { querystring: BingWallpaperQuerySchema } },
59208
+ async (request, reply) => {
59209
+ const wallpaper = await bingWallpaper.read(request.query.day);
59210
+ return reply.type(wallpaper.contentType).send(wallpaper.body);
59211
+ }
59212
+ );
58405
59213
  app.post(
58406
59214
  "/v1/app-update",
58407
59215
  {
@@ -59406,7 +60214,7 @@ var registerTurnRoutes = (app, context, done) => {
59406
60214
  }
59407
60215
  },
59408
60216
  async (request, reply) => {
59409
- const turn = await runIdempotent(
60217
+ const started = await runIdempotent(
59410
60218
  ["start-turn", request.params.projectId, request.params.taskId],
59411
60219
  request.headers["idempotency-key"],
59412
60220
  request.body,
@@ -59432,7 +60240,8 @@ var registerTurnRoutes = (app, context, done) => {
59432
60240
  request.params.taskId,
59433
60241
  turnOptions
59434
60242
  );
59435
- const turn2 = await context2.provider.startTurn(
60243
+ const checkpoint = context2.eventStream.checkpoint;
60244
+ const turn = await context2.provider.startTurn(
59436
60245
  request.params.taskId,
59437
60246
  providerInput,
59438
60247
  turnOptions
@@ -59440,12 +60249,16 @@ var registerTurnRoutes = (app, context, done) => {
59440
60249
  await attachmentStore.consume(
59441
60250
  request.params.projectId,
59442
60251
  attachmentIds,
59443
- turn2.status === "running" ? turn2.id : void 0
60252
+ turn.status === "running" ? turn.id : void 0
59444
60253
  );
59445
- return turn2;
60254
+ return { checkpoint, turn };
59446
60255
  }
59447
60256
  );
59448
- return reply.code(201).send({ taskId: request.params.taskId, turn });
60257
+ return reply.code(201).send({
60258
+ checkpoint: started.checkpoint,
60259
+ taskId: request.params.taskId,
60260
+ turn: started.turn
60261
+ });
59449
60262
  }
59450
60263
  );
59451
60264
  app.post(
@@ -59630,8 +60443,17 @@ var registerTurnRoutes = (app, context, done) => {
59630
60443
  };
59631
60444
 
59632
60445
  // packages/server/src/routes/queue-routes.ts
60446
+ function toQueueHttpError(error) {
60447
+ if (error instanceof TaskQueueBlockedError) {
60448
+ throw new MutationHttpError("TURN_NOT_RUNNING", error.message, 409);
60449
+ }
60450
+ if (error instanceof TaskQueueItemNotFoundError) {
60451
+ throw new MutationHttpError("TASK_NOT_FOUND", error.message, 404);
60452
+ }
60453
+ throw error;
60454
+ }
59633
60455
  var registerQueueRoutes = (app, context, done) => {
59634
- const { attachmentStore, getProjectContext, resolveProviderTurnInput, runIdempotent } = context;
60456
+ const { getProjectContext, runIdempotent, taskQueue } = context;
59635
60457
  const readQueue = async (params) => {
59636
60458
  const projectContext = await getProjectContext(params.projectId);
59637
60459
  if (projectContext === void 0) {
@@ -59641,10 +60463,12 @@ var registerQueueRoutes = (app, context, done) => {
59641
60463
  if (task?.projectId !== projectContext.scope.id) {
59642
60464
  throw new MutationHttpError("TASK_NOT_FOUND", "Task not found", 404);
59643
60465
  }
59644
- if (projectContext.provider.queue === void 0) {
59645
- throw new MutationHttpError("PROVIDER_ERROR", "Task queue is unavailable", 503);
59646
- }
59647
- return { provider: projectContext.provider, queue: projectContext.provider.queue };
60466
+ return {
60467
+ eventStream: projectContext.eventStream,
60468
+ projectId: params.projectId,
60469
+ provider: projectContext.provider,
60470
+ taskId: params.taskId
60471
+ };
59648
60472
  };
59649
60473
  app.get(
59650
60474
  "/v1/projects/:projectId/tasks/:taskId/queue",
@@ -59656,11 +60480,15 @@ var registerQueueRoutes = (app, context, done) => {
59656
60480
  }
59657
60481
  },
59658
60482
  async (request) => {
59659
- const { queue } = await readQueue(request.params);
59660
- return queue.list(request.params.taskId, {
59661
- ...request.query.cursor === void 0 ? {} : { cursor: request.query.cursor },
59662
- ...request.query.limit === void 0 ? {} : { limit: request.query.limit }
59663
- });
60483
+ const runtime = await readQueue(request.params);
60484
+ const data = await taskQueue.list(runtime);
60485
+ const offset = Number(request.query.cursor ?? "0");
60486
+ const limit = request.query.limit ?? 100;
60487
+ const nextOffset = offset + limit;
60488
+ return {
60489
+ data: data.slice(offset, nextOffset),
60490
+ nextCursor: nextOffset < data.length ? String(nextOffset) : null
60491
+ };
59664
60492
  }
59665
60493
  );
59666
60494
  app.post(
@@ -59679,24 +60507,8 @@ var registerQueueRoutes = (app, context, done) => {
59679
60507
  request.headers["idempotency-key"],
59680
60508
  request.body,
59681
60509
  async () => {
59682
- const { provider, queue } = await readQueue(request.params);
59683
- const { attachmentIds, providerInput } = await resolveProviderTurnInput(
59684
- request.params.projectId,
59685
- request.body.input,
59686
- provider,
59687
- request.params.taskId
59688
- );
59689
- const queuedSubmission2 = await queue.add(
59690
- request.params.taskId,
59691
- providerInput,
59692
- request.body.clientUserMessageId
59693
- );
59694
- await attachmentStore.retainQueue(
59695
- request.params.projectId,
59696
- attachmentIds,
59697
- queuedSubmission2.id
59698
- );
59699
- return queuedSubmission2;
60510
+ const runtime = await readQueue(request.params);
60511
+ return taskQueue.add(runtime, request.body.input, request.body.clientUserMessageId);
59700
60512
  }
59701
60513
  );
59702
60514
  return reply.code(201).send({ queuedSubmission });
@@ -59718,28 +60530,13 @@ var registerQueueRoutes = (app, context, done) => {
59718
60530
  request.headers["idempotency-key"],
59719
60531
  { ...request.body, queuedSubmissionId: request.params.queuedSubmissionId },
59720
60532
  async () => {
59721
- const { provider, queue } = await readQueue(request.params);
59722
- const { attachmentIds, providerInput } = await resolveProviderTurnInput(
59723
- request.params.projectId,
59724
- request.body.input,
59725
- provider,
59726
- request.params.taskId
59727
- );
59728
- const queuedSubmission2 = await queue.update(
59729
- request.params.taskId,
60533
+ const runtime = await readQueue(request.params);
60534
+ return taskQueue.update(
60535
+ runtime,
59730
60536
  request.params.queuedSubmissionId,
59731
- providerInput
59732
- );
59733
- await attachmentStore.releaseQueue(
59734
- request.params.projectId,
59735
- request.params.queuedSubmissionId
59736
- );
59737
- await attachmentStore.retainQueue(
59738
- request.params.projectId,
59739
- attachmentIds,
59740
- queuedSubmission2.id
60537
+ request.body.input,
60538
+ request.body.status
59741
60539
  );
59742
- return queuedSubmission2;
59743
60540
  }
59744
60541
  );
59745
60542
  return { queuedSubmission };
@@ -59760,18 +60557,8 @@ var registerQueueRoutes = (app, context, done) => {
59760
60557
  request.headers["idempotency-key"],
59761
60558
  { queuedSubmissionId: request.params.queuedSubmissionId },
59762
60559
  async () => {
59763
- const { queue } = await readQueue(request.params);
59764
- const deleted2 = await queue.delete(
59765
- request.params.taskId,
59766
- request.params.queuedSubmissionId
59767
- );
59768
- if (deleted2) {
59769
- await attachmentStore.releaseQueue(
59770
- request.params.projectId,
59771
- request.params.queuedSubmissionId
59772
- );
59773
- }
59774
- return deleted2;
60560
+ const runtime = await readQueue(request.params);
60561
+ return taskQueue.delete(runtime, request.params.queuedSubmissionId);
59775
60562
  }
59776
60563
  );
59777
60564
  return { deleted };
@@ -59793,8 +60580,8 @@ var registerQueueRoutes = (app, context, done) => {
59793
60580
  request.headers["idempotency-key"],
59794
60581
  request.body,
59795
60582
  async () => {
59796
- const { queue } = await readQueue(request.params);
59797
- await queue.reorder(request.params.taskId, request.body.queuedSubmissionIds);
60583
+ const runtime = await readQueue(request.params);
60584
+ await taskQueue.reorder(runtime, request.body.queuedSubmissionIds);
59798
60585
  return { status: "reordered" };
59799
60586
  }
59800
60587
  );
@@ -59817,13 +60604,12 @@ var registerQueueRoutes = (app, context, done) => {
59817
60604
  request.headers["idempotency-key"],
59818
60605
  request.body,
59819
60606
  async () => {
59820
- const { queue } = await readQueue(request.params);
59821
- const queuedSubmissionId = request.body.queuedSubmissionId ?? (await queue.list(request.params.taskId)).data[0]?.id;
59822
- const turn2 = await queue.start(request.params.taskId, queuedSubmissionId);
59823
- if (queuedSubmissionId !== void 0) {
59824
- await attachmentStore.startQueue(request.params.projectId, queuedSubmissionId, turn2.id);
60607
+ const runtime = await readQueue(request.params);
60608
+ try {
60609
+ return await taskQueue.start(runtime, request.body.queuedSubmissionId);
60610
+ } catch (error) {
60611
+ toQueueHttpError(error);
59825
60612
  }
59826
- return turn2;
59827
60613
  }
59828
60614
  );
59829
60615
  return reply.code(201).send({ taskId: request.params.taskId, turn });
@@ -60037,7 +60823,9 @@ async function configureServerDelivery(app, options) {
60037
60823
  "X-Content-Type-Options": "nosniff",
60038
60824
  "X-Frame-Options": "DENY"
60039
60825
  });
60040
- if (request.url.startsWith("/v1/")) {
60826
+ if (request.url.startsWith("/v1/pets/assets/")) {
60827
+ reply.header("Cache-Control", "private, no-cache");
60828
+ } else if (request.url.startsWith("/v1/")) {
60041
60829
  reply.header("Cache-Control", "no-store");
60042
60830
  }
60043
60831
  return payload;
@@ -60071,6 +60859,7 @@ async function configureServerDelivery(app, options) {
60071
60859
  retryable: false
60072
60860
  });
60073
60861
  }
60862
+ request.log.error({ err: error }, "Unhandled request error");
60074
60863
  return reply.code(explicitStatusCode).send({
60075
60864
  code: "INTERNAL_ERROR",
60076
60865
  message: "Internal server error",
@@ -60220,86 +61009,7 @@ async function createCodexlyServer(options) {
60220
61009
  const readSourceFile = options.readProjectSourceFile ?? readProjectSourceFile;
60221
61010
  const projectOpenService = options.projectOpenService ?? createProjectOpenService();
60222
61011
  const attachmentStore = new AttachmentStore();
60223
- const resolveProviderTurnInput = async (projectId, input, provider, taskId) => {
60224
- const requestedAttachmentIds = input.attachments.map((attachment) => attachment.id);
60225
- if (new Set(requestedAttachmentIds).size !== requestedAttachmentIds.length) {
60226
- throw new MutationHttpError("INVALID_REQUEST", "Duplicate attachments are not allowed", 400);
60227
- }
60228
- const attachmentIds = [];
60229
- const resolvedAttachments = [];
60230
- for (const requestedId of requestedAttachmentIds) {
60231
- try {
60232
- const [resolved2] = await attachmentStore.resolve(projectId, [requestedId]);
60233
- if (resolved2 !== void 0) {
60234
- attachmentIds.push(requestedId);
60235
- resolvedAttachments.push(resolved2);
60236
- continue;
60237
- }
60238
- } catch (error) {
60239
- if (!(error instanceof AttachmentNotFoundError)) {
60240
- throw error;
60241
- }
60242
- }
60243
- const historical = provider === void 0 || taskId === void 0 ? void 0 : await provider.readTaskAttachment(taskId, requestedId);
60244
- if (historical === void 0) {
60245
- throw new MutationHttpError(
60246
- "ATTACHMENT_NOT_FOUND",
60247
- "Attachment was not found or has expired",
60248
- 404
60249
- );
60250
- }
60251
- const cloned = await attachmentStore.add(projectId, {
60252
- content: Readable.from([historical.content]),
60253
- kind: historical.kind,
60254
- mediaType: historical.mediaType,
60255
- name: historical.name
60256
- });
60257
- const [resolved] = await attachmentStore.resolve(projectId, [cloned.attachment.id]);
60258
- if (resolved !== void 0) {
60259
- attachmentIds.push(cloned.attachment.id);
60260
- resolvedAttachments.push(resolved);
60261
- }
60262
- }
60263
- const imageBytes = resolvedAttachments.reduce(
60264
- (total, attachment) => total + (attachment.kind === "image" ? attachment.size : 0),
60265
- 0
60266
- );
60267
- const fileBytes = resolvedAttachments.reduce(
60268
- (total, attachment) => total + (attachment.kind === "image" ? 0 : attachment.size),
60269
- 0
60270
- );
60271
- const imageCount = resolvedAttachments.filter(
60272
- (attachment) => attachment.kind === "image"
60273
- ).length;
60274
- if (imageCount > MAX_AGENT_IMAGES || imageBytes > MAX_AGENT_IMAGE_TOTAL_BYTES) {
60275
- throw new MutationHttpError("INVALID_REQUEST", "Image input limit exceeded", 400);
60276
- }
60277
- if (fileBytes > MAX_AGENT_FILE_TOTAL_BYTES) {
60278
- throw new MutationHttpError("INVALID_REQUEST", "File input limit exceeded", 400);
60279
- }
60280
- return {
60281
- attachmentIds,
60282
- providerInput: {
60283
- files: resolvedAttachments.flatMap(
60284
- (attachment) => attachment.kind === "file" ? [
60285
- {
60286
- mediaType: attachment.mediaType,
60287
- name: attachment.name,
60288
- path: attachment.path
60289
- }
60290
- ] : []
60291
- ),
60292
- images: resolvedAttachments.flatMap(
60293
- (attachment) => attachment.kind === "image" ? [{ mediaType: attachment.mediaType, url: attachment.url }] : []
60294
- ),
60295
- skills: input.skills,
60296
- text: input.text,
60297
- textAttachments: resolvedAttachments.flatMap(
60298
- (attachment) => attachment.kind === "text" ? [{ name: attachment.name, text: attachment.text }] : []
60299
- )
60300
- }
60301
- };
60302
- };
61012
+ const resolveProviderTurnInput = createProviderTurnInputResolver(attachmentStore);
60303
61013
  const capabilities = await options.provider.getCapabilities();
60304
61014
  const modelCatalogCacheMaxBytes = options.modelCatalogCacheMaxBytes ?? DEFAULT_MODEL_CATALOG_CACHE_MAX_BYTES;
60305
61015
  const modelCatalogCacheTtlMs = options.modelCatalogCacheTtlMs ?? DEFAULT_MODEL_CATALOG_CACHE_TTL_MS;
@@ -60346,6 +61056,7 @@ async function createCodexlyServer(options) {
60346
61056
  onAttachmentReleaseError: (error) => {
60347
61057
  app.log.warn({ error }, "Failed to release turn attachments");
60348
61058
  },
61059
+ onTurnCompleted: (runtime) => taskQueue.startNext(runtime),
60349
61060
  provider: resolved.provider,
60350
61061
  scope: resolved.scope
60351
61062
  });
@@ -60406,6 +61117,7 @@ async function createCodexlyServer(options) {
60406
61117
  defaultOpenAppId: stored?.defaultOpenAppId ?? null,
60407
61118
  fastMode: stored?.fastMode ?? false,
60408
61119
  followUpBehavior: stored?.followUpBehavior ?? "queue",
61120
+ pet: stored?.pet ?? { enabled: false, selectedPetId: null },
60409
61121
  ...effectiveModel
60410
61122
  };
60411
61123
  };
@@ -60448,6 +61160,12 @@ async function createCodexlyServer(options) {
60448
61160
  };
60449
61161
  return effective;
60450
61162
  };
61163
+ const taskQueue = new PersistentTaskQueue({
61164
+ attachmentStore,
61165
+ readTaskSettings: readEffectiveTaskSettings,
61166
+ repository: options.queueRepository ?? createMemoryTaskQueueRepository(),
61167
+ resolveProviderInput: resolveProviderTurnInput
61168
+ });
60451
61169
  const activeGitMutations = /* @__PURE__ */ new Set();
60452
61170
  const taskStartRecoveries = /* @__PURE__ */ new Map();
60453
61171
  const idempotencyCacheSize = options.idempotencyCacheSize ?? DEFAULT_IDEMPOTENCY_CACHE_SIZE;
@@ -60493,12 +61211,15 @@ async function createCodexlyServer(options) {
60493
61211
  projectOpenService,
60494
61212
  projectRepository: options.projectRepository,
60495
61213
  provider: options.provider,
61214
+ petProvider: options.petProvider,
60496
61215
  providerConnectionRepository: options.providerConnectionRepository,
60497
61216
  readAppInfo: options.readAppInfo,
60498
61217
  readEffectiveGlobalSettings,
60499
61218
  readEffectiveProjectDefaults,
60500
61219
  readEffectiveTaskSettings,
60501
61220
  readFileTree,
61221
+ deleteProjectFile: options.deleteProjectFile ?? deleteProjectFile,
61222
+ renameProjectFile: options.renameProjectFile ?? renameProjectFile,
60502
61223
  searchProjectFiles,
60503
61224
  stopProjectFileSearch,
60504
61225
  readHostFileDirectory: options.readHostFileDirectory ?? readHostFileDirectory,
@@ -60518,6 +61239,7 @@ async function createCodexlyServer(options) {
60518
61239
  resolveHostAttachment: options.resolveHostAttachment ?? resolveHostAttachment,
60519
61240
  settingsRepository: options.settingsRepository,
60520
61241
  taskFromSnapshot,
61242
+ taskQueue,
60521
61243
  taskStartRecoveries,
60522
61244
  switchProjectBranch: options.switchProjectBranch ?? switchProjectBranch,
60523
61245
  resolveProjectWorktree: options.resolveProjectWorktree ?? resolveProjectWorktree,
@@ -60530,6 +61252,7 @@ async function createCodexlyServer(options) {
60530
61252
  });
60531
61253
  await app.register(registerRuntimeRoutes, routeContext);
60532
61254
  await app.register(registerProviderConnectionRoutes, routeContext);
61255
+ await app.register(registerPetRoutes, routeContext);
60533
61256
  await app.register(registerProjectRoutes, routeContext);
60534
61257
  await app.register(registerTaskRoutes, routeContext);
60535
61258
  await app.register(registerTurnRoutes, routeContext);
@@ -60628,6 +61351,16 @@ var GLOBAL_SETTINGS_MIGRATIONS = [
60628
61351
  FAST_MODE_SETTING_MIGRATION,
60629
61352
  PRESERVE_LEGACY_GLOBAL_SETTINGS_COLUMNS_MIGRATION
60630
61353
  ];
61354
+ var WORKBENCH_PET_SETTINGS_MIGRATION = {
61355
+ name: "add_workbench_pet_settings",
61356
+ sql: `
61357
+ ALTER TABLE global_settings
61358
+ ADD COLUMN pet_enabled INTEGER NOT NULL DEFAULT 0
61359
+ CHECK (pet_enabled IN (0, 1));
61360
+ ALTER TABLE global_settings ADD COLUMN pet_id TEXT;
61361
+ `,
61362
+ version: 23
61363
+ };
60631
61364
 
60632
61365
  // packages/server/src/sqlite-state-migrations.ts
60633
61366
  var SQLITE_MIGRATIONS = [
@@ -60998,10 +61731,37 @@ var SQLITE_MIGRATIONS = [
60998
61731
  CHECK (fast_mode IN (0, 1));
60999
61732
  `,
61000
61733
  version: 21
61001
- }
61734
+ },
61735
+ {
61736
+ name: "persist_task_queue",
61737
+ sql: `
61738
+ CREATE TABLE task_queue (
61739
+ project_id TEXT NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
61740
+ task_id TEXT NOT NULL,
61741
+ id TEXT NOT NULL,
61742
+ client_user_message_id TEXT NOT NULL,
61743
+ input_json TEXT NOT NULL,
61744
+ status TEXT NOT NULL CHECK (status IN ('editing', 'queued')),
61745
+ position INTEGER NOT NULL,
61746
+ updated_at TEXT NOT NULL,
61747
+ PRIMARY KEY (project_id, task_id, id),
61748
+ UNIQUE (project_id, task_id, position)
61749
+ ) STRICT;
61750
+ `,
61751
+ version: 22
61752
+ },
61753
+ WORKBENCH_PET_SETTINGS_MIGRATION
61002
61754
  ];
61003
61755
 
61004
61756
  // packages/server/src/sqlite-state-repository.ts
61757
+ function parseQueueWorkerRecord(record) {
61758
+ const input = JSON.parse(record.inputJson);
61759
+ if (!value_exports.Check(AgentPromptInputSchema, input)) {
61760
+ throw new Error("Persisted task queue input is invalid");
61761
+ }
61762
+ const { inputJson: _inputJson, ...identity } = record;
61763
+ return { ...identity, input };
61764
+ }
61005
61765
  var DEFAULT_SQLITE_REQUEST_TIMEOUT_MS = 1e4;
61006
61766
  var SqliteStateRepository = class _SqliteStateRepository {
61007
61767
  #now;
@@ -61157,6 +61917,40 @@ var SqliteStateRepository = class _SqliteStateRepository {
61157
61917
  setProjectOrder(projectIds) {
61158
61918
  return this.#call("setProjectOrder", { projectIds });
61159
61919
  }
61920
+ async addQueue(record) {
61921
+ const { input, ...metadata } = record;
61922
+ return parseQueueWorkerRecord(
61923
+ await this.#call("addTaskQueueRecord", {
61924
+ ...metadata,
61925
+ inputJson: JSON.stringify(input),
61926
+ updatedAt: this.#now().toISOString()
61927
+ })
61928
+ );
61929
+ }
61930
+ deleteQueue(projectId, taskId, queuedSubmissionId) {
61931
+ return this.#call("deleteTaskQueueRecord", { projectId, queuedSubmissionId, taskId });
61932
+ }
61933
+ async listQueue(projectId, taskId) {
61934
+ const records = await this.#call("listTaskQueueRecords", {
61935
+ projectId,
61936
+ taskId
61937
+ });
61938
+ return records.map(parseQueueWorkerRecord);
61939
+ }
61940
+ reorderQueue(projectId, taskId, queuedSubmissionIds) {
61941
+ return this.#call("reorderTaskQueueRecords", { projectId, queuedSubmissionIds, taskId });
61942
+ }
61943
+ async updateQueue(projectId, taskId, queuedSubmissionId, input, status2) {
61944
+ const record = await this.#call("updateTaskQueueRecord", {
61945
+ inputJson: JSON.stringify(input),
61946
+ projectId,
61947
+ queuedSubmissionId,
61948
+ status: status2,
61949
+ taskId,
61950
+ updatedAt: this.#now().toISOString()
61951
+ });
61952
+ return record === void 0 ? void 0 : parseQueueWorkerRecord(record);
61953
+ }
61160
61954
  readProjectDefaults(projectId) {
61161
61955
  return this.#call("readProjectDefaults", { projectId });
61162
61956
  }