@desplega.ai/agent-swarm 2.14.1 → 2.14.2

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 (346) hide show
  1. package/dist/{acp-adapter-7jv7w8jh.js → acp-adapter-q1vz4hh2.js} +8 -8
  2. package/dist/{acp-targets-0ebmg3et.js → acp-targets-d44eerh4.js} +7 -7
  3. package/dist/{actions-0ds9dx6c.js → actions-z4k4bvss.js} +27 -27
  4. package/dist/{agent-fs-provision-zpbxa9jc.js → agent-fs-provision-aan1cgpx.js} +4 -4
  5. package/dist/{amp-adapter-awh5nn7a.js → amp-adapter-wac3py0p.js} +1 -1
  6. package/dist/{anthropic-messages-gtgp9r85.js → anthropic-messages-njt2r5m4.js} +16 -15
  7. package/dist/{app-nzejkvpp.js → app-wax6qz5e.js} +9 -9
  8. package/dist/{approval-notifications-hbqtb2w3.js → approval-notifications-6fvkhnma.js} +10 -10
  9. package/dist/{assistant-1paft129.js → assistant-e8fe08zx.js} +25 -25
  10. package/dist/{azure-openai-responses-e76k86gf.js → azure-openai-responses-6ewf9rwp.js} +9 -9
  11. package/dist/{boot-args-schema-zs435mfx.js → boot-args-schema-rv97cmnt.js} +1 -1
  12. package/dist/{boot-reembed-91qrd4mz.js → boot-reembed-bcn7frk9.js} +1 -1
  13. package/dist/{boot-reembed-7xq2qgg4.js → boot-reembed-xakrdy6y.js} +1 -1
  14. package/dist/{boot-scrub-sweep-3h5xscw6.js → boot-scrub-sweep-20t8akhf.js} +2 -2
  15. package/dist/{boot-seeds-xkxqa8zc.js → boot-seeds-48rr6r29.js} +4 -4
  16. package/dist/{boxd-464x3w4m.js → boxd-tjpxwecx.js} +2 -2
  17. package/dist/{claude-adapter-6d8eyf2f.js → claude-adapter-0wzwntrj.js} +8 -8
  18. package/dist/{claude-managed-adapter-jzxcaf9m.js → claude-managed-adapter-4xcgt46w.js} +2 -2
  19. package/dist/{claude-managed-setup-5fcx0qh3.js → claude-managed-setup-91cyktw7.js} +5 -5
  20. package/dist/{claude-sdk-session-11vhz1hc.js → claude-sdk-session-ngj4dce5.js} +9658 -9634
  21. package/dist/{cli-hamdfjtx.js → cli-021hrewp.js} +1 -1
  22. package/dist/{cli-pgdqhdkw.js → cli-0kyjrbaa.js} +2 -2
  23. package/dist/{cli-132h67ps.js → cli-0nz04gqv.js} +48 -48
  24. package/dist/{cli-6a77m17n.js → cli-0rrft7s3.js} +2 -2
  25. package/dist/{cli-z0effej1.js → cli-1d9q7qrn.js} +5 -5
  26. package/dist/{cli-tdd9dvw6.js → cli-1t5vhrpv.js} +1 -1
  27. package/dist/{cli-zyf288rw.js → cli-2ja7eadd.js} +1 -1
  28. package/dist/{cli-k9m8fckz.js → cli-3ffzr65w.js} +4 -4
  29. package/dist/{cli-02ba8qx5.js → cli-3kdgm393.js} +4 -4
  30. package/dist/{cli-hh5m39pt.js → cli-3vc518cw.js} +1 -1
  31. package/dist/{cli-5pyes68e.js → cli-5188hq0a.js} +8 -8
  32. package/dist/{cli-zcghfsdg.js → cli-53gt8wfv.js} +1 -1
  33. package/dist/{cli-5t00r6c9.js → cli-5njmmmer.js} +2 -2
  34. package/dist/{cli-etykr11s.js → cli-5rw7nt99.js} +1 -1
  35. package/dist/{cli-6c61yjwy.js → cli-5xx353cy.js} +7554 -1534
  36. package/dist/{cli-by7s3n4p.js → cli-65k149j5.js} +2 -2
  37. package/dist/{cli-1e13gvfn.js → cli-6zpn5hmp.js} +11 -11
  38. package/dist/{cli-rb1z91g8.js → cli-7dpdq7yh.js} +1230 -540
  39. package/dist/{cli-3bagv8rt.js → cli-7wwewkf4.js} +1 -1
  40. package/dist/{cli-288k5ep1.js → cli-83hynhes.js} +15 -11
  41. package/dist/{cli-v84kb7af.js → cli-8ee7xt75.js} +11 -11
  42. package/dist/{cli-v3jxx8dv.js → cli-8ef94zm2.js} +2 -2
  43. package/dist/{cli-9fvk9mv8.js → cli-8gr1bg9t.js} +1 -1
  44. package/dist/{cli-vrb8pvrf.js → cli-9j1qcs0b.js} +6 -6
  45. package/dist/{cli-0dkpdvnn.js → cli-9mvfvggt.js} +5 -5
  46. package/dist/{cli-3bcsc3m7.js → cli-an8bpy60.js} +1 -1
  47. package/dist/{cli-6yhjqd6k.js → cli-azptj8xe.js} +810 -184
  48. package/dist/{cli-3a3hm1z8.js → cli-c0rt16vk.js} +2 -2
  49. package/dist/{cli-byzq8xht.js → cli-c6vhcknq.js} +6 -6
  50. package/dist/{cli-eaqxkeq0.js → cli-cczffwak.js} +8 -8
  51. package/dist/{cli-83kf2y60.js → cli-cgmka83w.js} +6 -6
  52. package/dist/{cli-5xjdft4s.js → cli-d13qgcct.js} +207 -142
  53. package/dist/{cli-k3facve0.js → cli-d5nvy1jy.js} +1 -1
  54. package/dist/{cli-zvsy4abb.js → cli-dev6f0px.js} +3 -3
  55. package/dist/{cli-e1wprqnd.js → cli-dzhht0vq.js} +2 -2
  56. package/dist/{cli-zdkcp8p0.js → cli-e13kbyq0.js} +1 -1
  57. package/dist/{cli-f07sgaax.js → cli-e2k0ej0d.js} +2 -2
  58. package/dist/{cli-dt931hb8.js → cli-ek8b88kv.js} +21 -21
  59. package/dist/{cli-20mkgwev.js → cli-ertcjw6z.js} +249 -19
  60. package/dist/{cli-0qyfna7a.js → cli-f3ta4e67.js} +4 -4
  61. package/dist/{cli-6xrbpj5j.js → cli-f4xv7s0t.js} +4 -4
  62. package/dist/{cli-d1zkys4j.js → cli-fdam1t9b.js} +29 -13
  63. package/dist/{cli-spfz393q.js → cli-feh37wgs.js} +598 -219
  64. package/dist/{cli-ebqx630g.js → cli-fjzjtqna.js} +35 -18
  65. package/dist/{cli-zgsd2w2k.js → cli-fs9t2m2k.js} +16 -16
  66. package/dist/{cli-trvtxwzt.js → cli-g03x26q6.js} +2 -2
  67. package/dist/{cli-0mq8kxfx.js → cli-gnkzh8ed.js} +3 -3
  68. package/dist/{cli-phantfg3.js → cli-gy0r7gb8.js} +40 -15
  69. package/dist/{cli-wsh5vfa7.js → cli-h364asjc.js} +2 -2
  70. package/dist/{cli-3ktfe5jx.js → cli-h3xcfp4c.js} +22 -7
  71. package/dist/{cli-976m0zcw.js → cli-h8k5801a.js} +49 -13
  72. package/dist/{cli-727sq1f9.js → cli-h96yp7xv.js} +2 -2
  73. package/dist/{cli-ytgtqsy9.js → cli-hab0bvrh.js} +1 -1
  74. package/dist/{cli-7dwsn9y5.js → cli-j3wqt73b.js} +4 -4
  75. package/dist/{cli-8kemtj1r.js → cli-jfgaz10x.js} +7 -7
  76. package/dist/{cli-wtwe8vng.js → cli-jrhvywah.js} +25 -24
  77. package/dist/{cli-tjrrabez.js → cli-jrxt5j0n.js} +3 -3
  78. package/dist/{cli-7b7rxz22.js → cli-jw7n9pct.js} +5 -2
  79. package/dist/{cli-k791mabe.js → cli-k9kfck3s.js} +5 -5
  80. package/dist/{cli-44r66df2.js → cli-kkwq5b12.js} +1 -1
  81. package/dist/{cli-e9p9h14n.js → cli-nc842kc9.js} +4 -4
  82. package/dist/{cli-3179w2rz.js → cli-nmj4phcg.js} +1 -1
  83. package/dist/{cli-ny8f5g7t.js → cli-praaw1wh.js} +1 -1
  84. package/dist/{cli-j8fmn3wv.js → cli-q44p4869.js} +7 -7
  85. package/dist/{cli-sq32dgfe.js → cli-q58qt9dw.js} +237 -57
  86. package/dist/{cli-2n7qdqfv.js → cli-qqz5z36e.js} +2 -2
  87. package/dist/{cli-b70cpf8f.js → cli-r7rpy2xz.js} +1 -1
  88. package/dist/{cli-1hj68b3h.js → cli-rcqgr0hs.js} +1 -1
  89. package/dist/{cli-ph95yejc.js → cli-rjc464jg.js} +2 -2
  90. package/dist/{cli-967jrz7j.js → cli-rw3m83j4.js} +15 -15
  91. package/dist/{cli-0vxbrxr3.js → cli-rwcj6wt3.js} +304 -19
  92. package/dist/{cli-yvnnyjxm.js → cli-ryn4y478.js} +1 -1
  93. package/dist/{cli-3g0vbq46.js → cli-s48k2rzx.js} +3 -3
  94. package/dist/{cli-98sea4d9.js → cli-s90wcbk9.js} +2 -2
  95. package/dist/{cli-e2wzzw17.js → cli-svcy72s5.js} +1 -1
  96. package/dist/{cli-643skca1.js → cli-swtwbg85.js} +17 -17
  97. package/dist/{cli-4y2bekkn.js → cli-t1bqpzgz.js} +2 -2
  98. package/dist/{cli-zmfs06hg.js → cli-t5jbjq61.js} +3 -3
  99. package/dist/{cli-mz7ycqn8.js → cli-td2h8zej.js} +6 -6
  100. package/dist/{cli-9t7syepg.js → cli-ttatvwn6.js} +1 -1
  101. package/dist/{cli-v1rhq77v.js → cli-txxcf9s1.js} +6 -6
  102. package/dist/{cli-q4z9s6zs.js → cli-v7az4d1g.js} +2 -2
  103. package/dist/cli-vqt44168.js +14 -0
  104. package/dist/{cli-tkrp183j.js → cli-vs9h3vw2.js} +5 -5
  105. package/dist/{cli-7abeph0b.js → cli-w2fg8kjc.js} +3 -3
  106. package/dist/{cli-sf5kp73f.js → cli-wz7qj1jy.js} +12 -12
  107. package/dist/{cli-ww8wxfzx.js → cli-x5t54ytt.js} +2 -2
  108. package/dist/{cli-nmdy8bzf.js → cli-xphbv66z.js} +1 -1
  109. package/dist/{cli-redtbppc.js → cli-xxgqn93n.js} +3753 -1186
  110. package/dist/{cli-s7bfz1ye.js → cli-z209g721.js} +109 -85
  111. package/dist/{cli-vp2ksaq9.js → cli-z5andw8k.js} +1 -1
  112. package/dist/{cli-xmc2nrtv.js → cli-zr2sc5tr.js} +1 -1
  113. package/dist/{cli-z0c98h7h.js → cli-zrm0610v.js} +61 -54
  114. package/dist/cli.js +41 -40
  115. package/dist/{cloudflare-workers-ai-system-one-w3m0fbf8.js → cloudflare-workers-ai-system-one-kb0tq22h.js} +2 -2
  116. package/dist/{codex-adapter-seht4h9t.js → codex-adapter-0c1ynrmt.js} +5 -5
  117. package/dist/{codex-session-runner-tq95x3gq.js → codex-session-runner-z4t9z7yy.js} +5 -5
  118. package/dist/{commands-0awwqxq5.js → commands-h0jxqdhk.js} +3 -3
  119. package/dist/{controller-hgjx521c.js → controller-4ygy66hv.js} +3 -3
  120. package/dist/{controllers-connect-j4kdmhfj.js → controllers-connect-ynbvv8pv.js} +26 -26
  121. package/dist/core-mj9fzrcm.js +41 -0
  122. package/dist/{cursor-adapter-0rg8wk6j.js → cursor-adapter-9e4d6658.js} +1 -1
  123. package/dist/{db-8xs2js3s.js → db-bg0hxjq1.js} +3 -3
  124. package/dist/{db-dd6hj211.js → db-q12gmpns.js} +2 -2
  125. package/dist/{devtools-b8qts77k.js → devtools-t8my9az6.js} +1 -1
  126. package/dist/{dispatcher-v7drd034.js → dispatcher-v5dbfscq.js} +23 -23
  127. package/dist/{dsh-adapter-ah8npj2x.js → dsh-adapter-z3fneea1.js} +1 -1
  128. package/dist/{e2b-z1g7vpz6.js → e2b-k3kb8b52.js} +3 -3
  129. package/dist/{e2b-hg80w0qr.js → e2b-p269awh6.js} +4 -4
  130. package/dist/{easter-egg-3d-8n4w3s9k.js → easter-egg-3d-y49v5z90.js} +1 -1
  131. package/dist/{embedding-space-0p921zt3.js → embedding-space-mjt5ksq0.js} +5 -5
  132. package/dist/{embeddings-9s7kbrc6.js → embeddings-td9hgnc5.js} +1 -1
  133. package/dist/{execute-x0fy9j0m.js → execute-z8nc8bba.js} +1 -1
  134. package/dist/{external-channel-ktfvn29c.js → external-channel-pjenc2ag.js} +2 -2
  135. package/dist/{fx-adapter-15vjxvgm.js → fx-adapter-pjeztp0n.js} +9 -9
  136. package/dist/getMachineId-bsd-hjs2tbdp.js +36 -0
  137. package/dist/getMachineId-darwin-kzbvr8s3.js +40 -0
  138. package/dist/getMachineId-linux-embmcq2c.js +26 -0
  139. package/dist/getMachineId-unsupported-jvznc6d4.js +20 -0
  140. package/dist/getMachineId-win-qr8z0b13.js +36 -0
  141. package/dist/{google-generative-ai-nzndg246.js → google-generative-ai-tf3w7557.js} +11 -16
  142. package/dist/{google-vertex-ragh3nnw.js → google-vertex-9pj87bd8.js} +15 -17
  143. package/dist/{grok-adapter-77httan0.js → grok-adapter-davbhx8t.js} +9 -9
  144. package/dist/handlers-rf130hnp.js +39 -0
  145. package/dist/{heartbeat-5yaj6dym.js → heartbeat-9hmvqxk0.js} +26 -26
  146. package/dist/{hook-c99nycyh.js → hook-0b1jqs2t.js} +6 -6
  147. package/dist/{hook-2jttae8s.js → hook-1n0sjv8p.js} +7 -7
  148. package/dist/{http-7y9dbfrr.js → http-vykejyjx.js} +412 -183
  149. package/dist/{index-tcegcysh.js → index-07d66kdm.js} +5 -5
  150. package/dist/{index-fqf82sbk.js → index-0hgjxqz8.js} +1 -1
  151. package/dist/{index-t274qhhs.js → index-0nt39qwy.js} +6 -6
  152. package/dist/{index-8p03vx1h.js → index-2xbxq71g.js} +8 -8
  153. package/dist/{index-jvfp0j47.js → index-3j8hffkb.js} +12038 -7667
  154. package/dist/index-8w09aggw.js +43 -0
  155. package/dist/{index-xhp7yp3t.js → index-b3wy4jzs.js} +1 -1
  156. package/dist/{index-6g9rdcrj.js → index-dt9vr7tb.js} +162 -57
  157. package/dist/{index-cw8nxnba.js → index-ezfas4jj.js} +1912 -346
  158. package/dist/index-g2jntx15.js +38 -0
  159. package/dist/{index-h9xnzfhx.js → index-j6sqtb83.js} +101 -72
  160. package/dist/{index-m6g8q65g.js → index-na0tczq0.js} +9268 -10220
  161. package/dist/{index-tn1m3q9b.js → index-p9dkwhwe.js} +3 -3
  162. package/dist/{index-g7rthzrv.js → index-pe2etczf.js} +8 -8
  163. package/dist/index-qffex5k4.js +41 -0
  164. package/dist/index-qrp11tp9.js +4 -0
  165. package/dist/{index-t4n9z755.js → index-ryyrg0d8.js} +406 -317
  166. package/dist/{index-t17p395x.js → index-sf06w57a.js} +13 -13
  167. package/dist/{index-qxcfv8vq.js → index-vybnwd5v.js} +1 -1
  168. package/dist/{index-dm7c6hw5.js → index-wsf1f5pe.js} +27 -27
  169. package/dist/{keepalive-7eyb8y4t.js → keepalive-86z0tzzf.js} +3 -3
  170. package/dist/lead-edmwagkn.js +81 -0
  171. package/dist/{llama-cpp-classify-yvb8vh7w.js → llama-cpp-classify-wd7htn1x.js} +2 -2
  172. package/dist/{maintenance-tdrd8nwv.js → maintenance-19h6tfwz.js} +1 -1
  173. package/dist/{mistral-conversations-w4bncwbt.js → mistral-conversations-txjmc64f.js} +7 -7
  174. package/dist/{module-ES6BEMUI-6htewwha.js → module-ES6BEMUI-44w9s1dx.js} +4 -4
  175. package/dist/{multipart-parser-xevcstye.js → multipart-parser-xqbgwrav.js} +1 -1
  176. package/dist/{oauth-refresh-sweep-f4c7g37h.js → oauth-refresh-sweep-6nmyrv32.js} +2 -2
  177. package/dist/{object-webhooks-p190rdxp.js → object-webhooks-2kynmdf8.js} +7 -7
  178. package/dist/{onboard-56h4sks6.js → onboard-zbpm96mn.js} +5 -5
  179. package/dist/{openai-codex-responses-z2h941b8.js → openai-codex-responses-6ckhys6r.js} +31 -25
  180. package/dist/{openai-completions-5bxdkeg9.js → openai-completions-c9dsq9jh.js} +17 -17
  181. package/dist/{openai-decisions-fyq1p9f9.js → openai-decisions-9vzvv10c.js} +2 -2
  182. package/dist/{openai-responses-dzf3e8r5.js → openai-responses-bhfmt9sa.js} +9 -9
  183. package/dist/{opencode-adapter-xg3yxfr0.js → opencode-adapter-fyqcbdra.js} +5 -5
  184. package/dist/{openrouter-images-0jj12a2q.js → openrouter-images-hkk5p580.js} +3 -3
  185. package/dist/otel-impl-txa20w1h.js +11178 -0
  186. package/dist/{pending-xgv316w0.js → pending-4rxawq8y.js} +24 -24
  187. package/dist/{pi-messages-zk3g4esn.js → pi-messages-py3f96p7.js} +5 -5
  188. package/dist/{pi-mono-adapter-txe0syzb.js → pi-mono-adapter-rnsed1xa.js} +14 -14
  189. package/dist/{pricing-refresh-041zpyhf.js → pricing-refresh-4314hwtw.js} +2 -2
  190. package/dist/{rbac-roles-8f3jbcaf.js → rbac-roles-fztcm8ky.js} +2 -2
  191. package/dist/{rbac-roles-cw7rrw5b.js → rbac-roles-msqt7a3k.js} +3 -3
  192. package/dist/{render-v2-2ezw4mzt.js → render-v2-w49wtecg.js} +9 -9
  193. package/dist/{resume-p14wdx8m.js → resume-gwgtp4m3.js} +12 -12
  194. package/dist/{runtime-he7c9g1r.js → runtime-kkebz8yq.js} +1 -1
  195. package/dist/{session-access-8jvq86fj.js → session-access-kjb19m2w.js} +5 -5
  196. package/dist/{session-source-backfill-6fe3hcgb.js → session-source-backfill-805p4wqr.js} +2 -2
  197. package/dist/{setup-6v0bn4r1.js → setup-q8y168c8.js} +3 -3
  198. package/dist/thread-buffer-yqbffd0t.js +40 -0
  199. package/dist/{tree-visibility-g1a8ff4r.js → tree-visibility-qj323994.js} +2 -2
  200. package/dist/{typesafe-system-one-qkvkgrcz.js → typesafe-system-one-avrdb4zm.js} +2 -2
  201. package/dist/{user-merge-jobs-vjsps179.js → user-merge-jobs-qfp40f2s.js} +3 -3
  202. package/dist/{virtual-modules-mreda4fp.js → virtual-modules-nzxegw0a.js} +7 -7
  203. package/dist/{work-objects-hfw15e35.js → work-objects-hs089w60.js} +25 -25
  204. package/dist/{worker-follow-up-gbaz2ydz.js → worker-follow-up-zwgg20sr.js} +23 -23
  205. package/dist/worker-kg4g7rnx.js +81 -0
  206. package/openapi.json +3 -3
  207. package/package.json +25 -24
  208. package/plugin/commands/create-pr.md +5 -2
  209. package/plugin/pi-skills/create-pr/SKILL.md +5 -2
  210. package/src/apps/sync.ts +7 -2
  211. package/src/be/db/workflow-runs.ts +12 -8
  212. package/src/be/db.ts +4 -1
  213. package/src/be/migrations/367_workflow_run_principal.sql +5 -0
  214. package/src/be/swarm-config-guard.ts +3 -0
  215. package/src/be/task-auto-title-listener.ts +2 -2
  216. package/src/commands/onboard/agent-fs-version.ts +1 -1
  217. package/src/extensions/post-bridge.ts +27 -28
  218. package/src/http/active-sessions.ts +7 -0
  219. package/src/http/agents.ts +7 -0
  220. package/src/http/api-keys.ts +7 -0
  221. package/src/http/approval-requests.ts +4 -0
  222. package/src/http/budgets.ts +2 -0
  223. package/src/http/codex-oauth-keep-warm.ts +6 -2
  224. package/src/http/config.ts +1 -0
  225. package/src/http/context.ts +4 -0
  226. package/src/http/db-query.ts +3 -0
  227. package/src/http/events.ts +2 -0
  228. package/src/http/fs.ts +1 -0
  229. package/src/http/integrations.ts +4 -0
  230. package/src/http/mcp-bridge.ts +1 -0
  231. package/src/http/memory.ts +3 -0
  232. package/src/http/metrics.ts +16 -0
  233. package/src/http/oauth-locks.ts +8 -0
  234. package/src/http/page-proxy.ts +16 -0
  235. package/src/http/pages.ts +9 -0
  236. package/src/http/poll.ts +1 -0
  237. package/src/http/pricing.ts +2 -0
  238. package/src/http/prompt-templates.ts +34 -0
  239. package/src/http/schedules.ts +10 -0
  240. package/src/http/script-runs.ts +24 -0
  241. package/src/http/scripts.ts +1 -0
  242. package/src/http/session-data.ts +2 -0
  243. package/src/http/status.ts +1 -0
  244. package/src/http/tasks.ts +17 -0
  245. package/src/http/trackers/jira.ts +2 -0
  246. package/src/http/trackers/linear.ts +4 -0
  247. package/src/http/users.ts +18 -0
  248. package/src/http/webhooks.ts +12 -0
  249. package/src/http/workflow-events.ts +26 -6
  250. package/src/http/workflows.ts +40 -0
  251. package/src/http/x.ts +4 -0
  252. package/src/linear/app.ts +3 -2
  253. package/src/linear/client.ts +5 -1
  254. package/src/linear/host.ts +40 -0
  255. package/src/linear/oauth.ts +3 -2
  256. package/src/linear/sync.ts +4 -3
  257. package/src/otel-impl.ts +8 -5
  258. package/src/providers/amp-adapter.ts +1 -1
  259. package/src/rbac/legacy-policy.ts +2 -0
  260. package/src/rbac/permissions.ts +5 -0
  261. package/src/scripts-runtime/quickjs-compat.ts +44 -10
  262. package/src/slack/render-v2.ts +50 -23
  263. package/src/slack/reviewed-deliverables.ts +251 -0
  264. package/src/tests/check-pr-body.test.ts +408 -93
  265. package/src/tests/compose-dev-object-store.test.ts +13 -0
  266. package/src/tests/compose-example-object-store.test.ts +67 -0
  267. package/src/tests/db-query.test.ts +8 -4
  268. package/src/tests/e2b-dispatch.test.ts +7 -1
  269. package/src/tests/otel-event-loop-and-logs.test.ts +1 -1
  270. package/src/tests/quickjs-compat.test.ts +40 -4
  271. package/src/tests/rbac-route-verbs-e2e.test.ts +142 -0
  272. package/src/tests/script-connections.test.ts +2 -0
  273. package/src/tests/slack-render-v2.test.ts +52 -8
  274. package/src/tests/workflow-definition-pinning.test.ts +2 -0
  275. package/src/tests/workflow-hitl-routing.test.ts +67 -5
  276. package/src/tests/workflow-replay.test.ts +13 -1
  277. package/src/tests/x402-client.test.ts +82 -0
  278. package/src/tools/memory-rate.ts +2 -2
  279. package/src/tools/prompt-templates/delete.ts +22 -1
  280. package/src/tools/prompt-templates/set.ts +15 -1
  281. package/src/utils/constants.ts +5 -4
  282. package/src/utils/task-citations.ts +11 -0
  283. package/src/workflows/engine.ts +5 -0
  284. package/src/workflows/executors/sub-workflow.ts +5 -7
  285. package/src/workflows/executors/swarm-script.ts +4 -5
  286. package/src/workflows/resume.ts +21 -4
  287. package/src/workflows/run-principal.ts +51 -0
  288. package/src/x402/client.ts +38 -17
  289. package/templates/skills/code-quality/content.md +1 -1
  290. package/templates/skills/pages/content.md +36 -12
  291. package/templates/skills/swarm-docs/content.md +46 -41
  292. package/templates/skills/swarm-scripts/SKILL.md +1 -1
  293. package/templates/skills/swarm-scripts/content.md +1 -1
  294. package/dist/cli-547fsc36.js +0 -15
  295. package/dist/cli-dr6x9qdk.js +0 -15
  296. package/dist/cli-h5cveb69.js +0 -15
  297. package/dist/cli-jngvszex.js +0 -1514
  298. package/dist/cli-p0g0erm9.js +0 -15
  299. package/dist/cli-ph1jce1b.js +0 -16
  300. package/dist/cli-vxxdf2ma.js +0 -15
  301. package/dist/cli-x80zagf5.js +0 -15
  302. package/dist/core-8fw1gwg7.js +0 -41
  303. package/dist/getMachineId-bsd-2rd3pnz7.js +0 -36
  304. package/dist/getMachineId-bsd-3p48mkt1.js +0 -36
  305. package/dist/getMachineId-bsd-bk6tmeen.js +0 -36
  306. package/dist/getMachineId-bsd-pssqgwmm.js +0 -37
  307. package/dist/getMachineId-bsd-v218x3xd.js +0 -36
  308. package/dist/getMachineId-bsd-wbxcazef.js +0 -36
  309. package/dist/getMachineId-bsd-x0942pbz.js +0 -36
  310. package/dist/getMachineId-darwin-5qsy4qcg.js +0 -36
  311. package/dist/getMachineId-darwin-6v7zsshx.js +0 -37
  312. package/dist/getMachineId-darwin-fcc3fjag.js +0 -36
  313. package/dist/getMachineId-darwin-pg84hftj.js +0 -36
  314. package/dist/getMachineId-darwin-tyyevt26.js +0 -36
  315. package/dist/getMachineId-darwin-wagmbf0d.js +0 -36
  316. package/dist/getMachineId-darwin-zvkmwr3y.js +0 -36
  317. package/dist/getMachineId-linux-2ncg1epd.js +0 -29
  318. package/dist/getMachineId-linux-2tmt2ptc.js +0 -29
  319. package/dist/getMachineId-linux-empwyp2y.js +0 -29
  320. package/dist/getMachineId-linux-fanqd45b.js +0 -29
  321. package/dist/getMachineId-linux-h6fyga0x.js +0 -29
  322. package/dist/getMachineId-linux-tbhgz1k9.js +0 -29
  323. package/dist/getMachineId-linux-zrbyw7dt.js +0 -29
  324. package/dist/getMachineId-unsupported-29g9dkgv.js +0 -19
  325. package/dist/getMachineId-unsupported-8xfq8djv.js +0 -19
  326. package/dist/getMachineId-unsupported-8y9cag1p.js +0 -19
  327. package/dist/getMachineId-unsupported-a6sjrm02.js +0 -19
  328. package/dist/getMachineId-unsupported-bp3w7ds0.js +0 -19
  329. package/dist/getMachineId-unsupported-sj6fk8sw.js +0 -19
  330. package/dist/getMachineId-unsupported-v0p5gdxp.js +0 -19
  331. package/dist/getMachineId-win-hc996p0x.js +0 -38
  332. package/dist/getMachineId-win-msq9ad87.js +0 -38
  333. package/dist/getMachineId-win-tajyqwd6.js +0 -38
  334. package/dist/getMachineId-win-tzc163da.js +0 -38
  335. package/dist/getMachineId-win-xdaa0mgq.js +0 -38
  336. package/dist/getMachineId-win-xk6p98m5.js +0 -38
  337. package/dist/getMachineId-win-xtk658fm.js +0 -38
  338. package/dist/handlers-c1jp5b6h.js +0 -39
  339. package/dist/index-7dwh9kxh.js +0 -41
  340. package/dist/index-wp9tarbt.js +0 -43
  341. package/dist/index-z6np2405.js +0 -38
  342. package/dist/lead-50cgn8s1.js +0 -81
  343. package/dist/otel-impl-kepzgm4n.js +0 -55386
  344. package/dist/thread-buffer-8860v1ta.js +0 -40
  345. package/dist/worker-hkm8ftqp.js +0 -81
  346. /package/dist/{node-gbx1t3pa.js → node-q4628t0b.js} +0 -0
@@ -148,7 +148,7 @@ import {
148
148
  Instantiate,
149
149
  Evaluate2,
150
150
  Priority
151
- } from "./cli-k791mabe.js";
151
+ } from "./cli-k9kfck3s.js";
152
152
  import {
153
153
  require_index_min
154
154
  } from "./cli-t9wbrgm4.js";
@@ -178,9 +178,9 @@ import {
178
178
  arr,
179
179
  opt,
180
180
  obj,
181
- init_dist2,
181
+ init_dist,
182
182
  validateToolArguments,
183
- init_dist3,
183
+ init_dist2,
184
184
  DEFAULT_RADIUS_GATEWAY,
185
185
  normalizeRadiusGatewayUrl,
186
186
  init_radius_config,
@@ -198,7 +198,7 @@ import {
198
198
  streamSimple2,
199
199
  completeSimple,
200
200
  init_compat
201
- } from "./cli-s7bfz1ye.js";
201
+ } from "./cli-z209g721.js";
202
202
  import {
203
203
  uuidv7
204
204
  } from "./cli-4se3x6qm.js";
@@ -235,7 +235,7 @@ import {
235
235
  getSupportedThinkingLevels,
236
236
  clampThinkingLevel,
237
237
  modelsAreEqual
238
- } from "./cli-9fvk9mv8.js";
238
+ } from "./cli-8gr1bg9t.js";
239
239
  import {
240
240
  EventStream,
241
241
  createAssistantMessageEventStream
@@ -247,7 +247,7 @@ import {
247
247
  mergeClientIdentity,
248
248
  formatUserAgent,
249
249
  getOpenCodeSessionHeaders
250
- } from "./cli-9t7syepg.js";
250
+ } from "./cli-ttatvwn6.js";
251
251
  import {
252
252
  __toESM,
253
253
  __commonJS,
@@ -9334,7 +9334,7 @@ var require_parser_h1 = __commonJS(function(exports, module) {
9334
9334
  var EVENT_RANGE_SIZE = 9;
9335
9335
  var EVENT_HEADERS_SIZE = 19;
9336
9336
  var miloPackage;
9337
- var useWasmSIMD = process.arch !== "ppc64";
9337
+ var useWasmSIMD = process.arch !== "riscv64" && process.arch !== "ppc64";
9338
9338
  if (process.env.UNDICI_NO_WASM_SIMD === "1") {
9339
9339
  useWasmSIMD = false;
9340
9340
  } else if (process.env.UNDICI_NO_WASM_SIMD === "0") {
@@ -10452,14 +10452,35 @@ ${normalizeLinefeeds(value)}\r
10452
10452
  if (util.isDisturbed(object) || object.locked) {
10453
10453
  throw new TypeError("Response body object should not be disturbed or locked");
10454
10454
  }
10455
- stream = webidl.is.ReadableStream(object) ? object : ReadableStream.from(object).pipeThrough(new TransformStream({
10456
- transform(chunk, controller) {
10457
- const bytes = isUint8Array(chunk) ? chunk : Buffer.from(chunk);
10458
- if (bytes.byteLength) {
10459
- controller.enqueue(bytes);
10455
+ if (webidl.is.ReadableStream(object)) {
10456
+ stream = object;
10457
+ } else {
10458
+ const reader = ReadableStream.from(object).getReader();
10459
+ let cancelled = false;
10460
+ stream = new ReadableStream({
10461
+ async pull(controller) {
10462
+ while (true) {
10463
+ const { done, value } = await reader.read();
10464
+ if (cancelled) {
10465
+ return;
10466
+ }
10467
+ if (done) {
10468
+ controller.close();
10469
+ return;
10470
+ }
10471
+ const bytes = isUint8Array(value) ? value : Buffer.from(value);
10472
+ if (bytes.byteLength) {
10473
+ controller.enqueue(bytes);
10474
+ return;
10475
+ }
10476
+ }
10477
+ },
10478
+ cancel(reason) {
10479
+ cancelled = true;
10480
+ return reader.cancel(reason);
10460
10481
  }
10461
- }
10462
- }));
10482
+ }, { highWaterMark: 0 });
10483
+ }
10463
10484
  }
10464
10485
  if (typeof source === "string" || isUint8Array(source)) {
10465
10486
  action = () => source;
@@ -10686,7 +10707,9 @@ var require_client_h1 = __commonJS(function(exports, module) {
10686
10707
  const llhttpWasmData = process.env.JEST_WORKER_ID ? require_llhttp_wasm() : undefined;
10687
10708
  let mod;
10688
10709
  let useWasmSIMD = true;
10689
- if (process.arch === "ppc64") {
10710
+ if (process.arch === "riscv64") {
10711
+ useWasmSIMD = false;
10712
+ } else if (process.arch === "ppc64") {
10690
10713
  const [major, minor] = process.versions.node.split(".").map((n) => parseInt(n, 10));
10691
10714
  if (major < 24 || major === 24 && minor < 12) {
10692
10715
  useWasmSIMD = false;
@@ -11881,7 +11904,6 @@ var require_client_h2 = __commonJS(function(exports, module) {
11881
11904
  } = require_symbols();
11882
11905
  var { channels } = require_diagnostics();
11883
11906
  var kOpenStreams = Symbol("open streams");
11884
- var kRequestStreamId = Symbol("request stream id");
11885
11907
  var kRequestStream = Symbol("request stream");
11886
11908
  var kRequestStreamCleanup = Symbol("request stream cleanup");
11887
11909
  var kRequestStreamState = Symbol("request stream state");
@@ -11889,6 +11911,7 @@ var require_client_h2 = __commonJS(function(exports, module) {
11889
11911
  var kGoAwayReplayAttempts = Symbol("goaway replay attempts");
11890
11912
  var kRefusedStreamRetry = Symbol("refused stream retry");
11891
11913
  var MAX_GOAWAY_REPLAY_ATTEMPTS = 1;
11914
+ var HTTP2_FRAME_TYPE_HEADERS = 1;
11892
11915
  var MIN_PROBE_TIMEOUT = 1000;
11893
11916
  var extractBody;
11894
11917
  var http2;
@@ -11939,14 +11962,14 @@ var require_client_h2 = __commonJS(function(exports, module) {
11939
11962
  if (request == null) {
11940
11963
  continue;
11941
11964
  }
11942
- if (typeof request[kRequestStreamId] !== "number" || request[kRequestStreamId] > maxAcceptedStreamID) {
11965
+ const streamId = request[kRequestStream]?.id;
11966
+ if (typeof streamId !== "number" || streamId > maxAcceptedStreamID) {
11943
11967
  return i;
11944
11968
  }
11945
11969
  }
11946
11970
  return client[kPendingIdx];
11947
11971
  }
11948
11972
  function detachRequestFromStream(request) {
11949
- request[kRequestStreamId] = null;
11950
11973
  request[kRequestStream] = null;
11951
11974
  request[kRequestStreamCleanup] = null;
11952
11975
  }
@@ -11955,7 +11978,6 @@ var require_client_h2 = __commonJS(function(exports, module) {
11955
11978
  const previousStream = request[kRequestStream];
11956
11979
  detachRequestFromStream(request);
11957
11980
  previousCleanup?.(previousStream);
11958
- request[kRequestStreamId] = stream.id;
11959
11981
  request[kRequestStream] = stream;
11960
11982
  request[kRequestStreamCleanup] = cleanup;
11961
11983
  }
@@ -12023,7 +12045,8 @@ var require_client_h2 = __commonJS(function(exports, module) {
12023
12045
  closeStreamSession(stream);
12024
12046
  }
12025
12047
  if (!stream.destroyed && !stream.closed) {
12026
- stream.once("error", noop);
12048
+ stream.off("error", noop);
12049
+ stream.on("error", noop);
12027
12050
  }
12028
12051
  }
12029
12052
  function connectH2(client, socket) {
@@ -12329,14 +12352,12 @@ var require_client_h2 = __commonJS(function(exports, module) {
12329
12352
  }
12330
12353
  }
12331
12354
  }
12332
- for (let i = 0;i < streamsToClose.length; i++) {
12333
- closeStream(streamsToClose[i]);
12334
- }
12335
12355
  if (pendingIdx !== previousPendingIdx) {
12336
12356
  const remainingPendingRequests = client[kQueue].slice(previousPendingIdx);
12337
12357
  client[kQueue].length = pendingIdx;
12338
12358
  client[kQueue].push(...retriableRequests, ...remainingPendingRequests);
12339
12359
  }
12360
+ client[kPendingIdx] = pendingIdx;
12340
12361
  if (client[kHTTP2Session] === this) {
12341
12362
  client[kSocket] = null;
12342
12363
  client[kHTTPContext] = null;
@@ -12348,10 +12369,12 @@ var require_client_h2 = __commonJS(function(exports, module) {
12348
12369
  clearHttp2IdleTimeout(this);
12349
12370
  clearNoStreamsTimeout(this);
12350
12371
  clearHttp2ProbeTimeout(this);
12372
+ for (let i = 0;i < streamsToClose.length; i++) {
12373
+ closeStream(streamsToClose[i]);
12374
+ }
12351
12375
  if (!this.closed && !this.destroyed) {
12352
12376
  this.close();
12353
12377
  }
12354
- client[kPendingIdx] = pendingIdx;
12355
12378
  client.emit("disconnect", client[kUrl], [client], err);
12356
12379
  client[kResume]();
12357
12380
  }
@@ -12426,7 +12449,6 @@ var require_client_h2 = __commonJS(function(exports, module) {
12426
12449
  }
12427
12450
  }
12428
12451
  function onUpgradeStreamClose() {
12429
- this.off("error", noop);
12430
12452
  const state = this[kRequestStreamState];
12431
12453
  this[kRequestStreamState] = null;
12432
12454
  failUpgradeStream(state, new InformationalError("HTTP/2: stream closed before response headers"));
@@ -12495,7 +12517,7 @@ var require_client_h2 = __commonJS(function(exports, module) {
12495
12517
  }
12496
12518
  removeUpgradeStreamListeners(stream);
12497
12519
  if (!stream.destroyed && !stream.closed) {
12498
- stream.once("error", noop);
12520
+ stream.on("error", noop);
12499
12521
  }
12500
12522
  }
12501
12523
  function failUpgradeStream(state, err) {
@@ -12789,7 +12811,7 @@ var require_client_h2 = __commonJS(function(exports, module) {
12789
12811
  }
12790
12812
  if (!stream.destroyed && !stream.closed) {
12791
12813
  removeRequestStreamListeners(stream);
12792
- stream.once("error", noop);
12814
+ stream.on("error", noop);
12793
12815
  }
12794
12816
  }
12795
12817
  function onData(chunk) {
@@ -12902,13 +12924,25 @@ var require_client_h2 = __commonJS(function(exports, module) {
12902
12924
  return false;
12903
12925
  }
12904
12926
  request[kRefusedStreamRetry] = true;
12927
+ requeueStreamRequest(client, state);
12928
+ return true;
12929
+ }
12930
+ function retryUnsentStream(state) {
12931
+ const { client, request, session } = state;
12932
+ if (!session[kReceivedGoAway] || state.responseReceived || request.aborted || request.completed || !canReplayRequest(request) || !registerGoAwayRefusal(request)) {
12933
+ return false;
12934
+ }
12935
+ requeueStreamRequest(client, state);
12936
+ return true;
12937
+ }
12938
+ function requeueStreamRequest(client, state) {
12939
+ const { request } = state;
12905
12940
  detachRequestStreamForClose(request);
12906
12941
  state.stream = null;
12907
12942
  state.requestFinalized = true;
12908
12943
  completeRequest(client, request);
12909
12944
  client[kQueue].splice(client[kPendingIdx], 0, request);
12910
12945
  client[kResume]();
12911
- return true;
12912
12946
  }
12913
12947
  function onError(err) {
12914
12948
  const stream = this;
@@ -12917,6 +12951,7 @@ var require_client_h2 = __commonJS(function(exports, module) {
12917
12951
  return;
12918
12952
  }
12919
12953
  stream.off("error", onError);
12954
+ stream.on("error", noop);
12920
12955
  if (state.responseContentLength != null && state.bytesRead !== state.responseContentLength) {
12921
12956
  err = new ResponseContentLengthMismatchError;
12922
12957
  }
@@ -12935,6 +12970,9 @@ var require_client_h2 = __commonJS(function(exports, module) {
12935
12970
  return;
12936
12971
  }
12937
12972
  stream.off("frameError", onFrameError);
12973
+ if (type === HTTP2_FRAME_TYPE_HEADERS && retryUnsentStream(state)) {
12974
+ return;
12975
+ }
12938
12976
  state.abort(new InformationalError(`HTTP/2: "frameError" received - type ${type}, code ${code}`));
12939
12977
  }
12940
12978
  function onAborted() {
@@ -17829,13 +17867,18 @@ var require_mock_utils = __commonJS(function(exports, module) {
17829
17867
  if (typeof path !== "string") {
17830
17868
  return path;
17831
17869
  }
17870
+ const queryIndex = path.indexOf("?");
17871
+ const search = queryIndex === -1 ? "" : path.slice(queryIndex);
17872
+ if (queryIndex !== -1) {
17873
+ path = path.slice(0, queryIndex);
17874
+ }
17832
17875
  while (path.endsWith("/")) {
17833
17876
  path = path.slice(0, -1);
17834
17877
  }
17835
17878
  if (path.length === 0) {
17836
17879
  path = "/";
17837
17880
  }
17838
- return path;
17881
+ return path + search;
17839
17882
  }
17840
17883
  function buildKey(opts) {
17841
17884
  const { path, method, body, headers, query } = opts;
@@ -17919,6 +17962,9 @@ var require_mock_utils = __commonJS(function(exports, module) {
17919
17962
  paused: false,
17920
17963
  rawHeaders: null,
17921
17964
  rawTrailers: null,
17965
+ get aborted() {
17966
+ return aborted;
17967
+ },
17922
17968
  pause() {
17923
17969
  this.paused = true;
17924
17970
  },
@@ -19557,8 +19603,11 @@ var require_decorator_handler = __commonJS(function(exports, module) {
19557
19603
  onResponseStart(...args) {
19558
19604
  assert(!this.#onCompleteCalled);
19559
19605
  assert(!this.#onErrorCalled);
19560
- assert(!this.#onResponseStartCalled);
19561
- this.#onResponseStartCalled = true;
19606
+ const statusCode = args[1];
19607
+ if (statusCode >= 200) {
19608
+ assert(!this.#onResponseStartCalled);
19609
+ this.#onResponseStartCalled = true;
19610
+ }
19562
19611
  return this.#handler.onResponseStart?.(...args);
19563
19612
  }
19564
19613
  onResponseData(...args) {
@@ -19672,7 +19721,11 @@ var require_redirect_handler = __commonJS(function(exports, module) {
19672
19721
  this.handler.onResponseStart?.(controller, statusCode, headers, statusMessage);
19673
19722
  return;
19674
19723
  }
19675
- this.history[kRedirectCacheControl].push(headers["cache-control"]);
19724
+ this.history[kRedirectCacheControl].push({
19725
+ statusCode,
19726
+ headers: { ...headers },
19727
+ receivedAt: Date.now()
19728
+ });
19676
19729
  const baseUrl = requestOrigin ? new URL(this.opts.path, requestOrigin) : undefined;
19677
19730
  const { origin, pathname, search } = util.parseURL(new URL(this.location, baseUrl));
19678
19731
  const path = search ? `${pathname}${search}` : pathname;
@@ -19739,9 +19792,17 @@ var require_redirect_handler = __commonJS(function(exports, module) {
19739
19792
  function cleanRequestHeaders(headers, removeContent, unknownOrigin, stripHeaders, stripHeadersOnCrossOrigin) {
19740
19793
  const ret = [];
19741
19794
  if (Array.isArray(headers)) {
19742
- for (let i = 0;i < headers.length; i += 2) {
19743
- if (!shouldRemoveHeader(headers[i], removeContent, unknownOrigin, stripHeaders, stripHeadersOnCrossOrigin)) {
19744
- ret.push(headers[i], headers[i + 1]);
19795
+ if (headers.length > 0 && Array.isArray(headers[0])) {
19796
+ for (const [key, value] of headers) {
19797
+ if (!shouldRemoveHeader(key, removeContent, unknownOrigin, stripHeaders, stripHeadersOnCrossOrigin)) {
19798
+ ret.push(key, value);
19799
+ }
19800
+ }
19801
+ } else {
19802
+ for (let i = 0;i < headers.length; i += 2) {
19803
+ if (!shouldRemoveHeader(headers[i], removeContent, unknownOrigin, stripHeaders, stripHeadersOnCrossOrigin)) {
19804
+ ret.push(headers[i], headers[i + 1]);
19805
+ }
19745
19806
  }
19746
19807
  }
19747
19808
  } else if (headers && typeof headers === "object") {
@@ -21542,6 +21603,15 @@ var require_cache_handler = __commonJS(function(exports, module) {
21542
21603
  }
21543
21604
  return false;
21544
21605
  }
21606
+ function appendVaryValues(target, varyValue) {
21607
+ if (Array.isArray(varyValue)) {
21608
+ for (let i = 0;i < varyValue.length; i++) {
21609
+ target.push(varyValue[i]);
21610
+ }
21611
+ } else if (varyValue != null) {
21612
+ target.push(varyValue);
21613
+ }
21614
+ }
21545
21615
  function appendConnectionHeaderTokens(headersToRemove, connectionHeader) {
21546
21616
  const values = Array.isArray(connectionHeader) ? connectionHeader : [connectionHeader];
21547
21617
  for (let i = 0;i < values.length; i++) {
@@ -21603,6 +21673,9 @@ var require_cache_handler = __commonJS(function(exports, module) {
21603
21673
  deleteLocationTargets(store, cacheKey, resHeaders.location);
21604
21674
  deleteLocationTargets(store, cacheKey, resHeaders["content-location"]);
21605
21675
  }
21676
+ function requestCarriesCredentials(headers) {
21677
+ return headers != null && (Object.hasOwn(headers, "authorization") || Object.hasOwn(headers, "cookie") || Object.hasOwn(headers, "proxy-authorization"));
21678
+ }
21606
21679
 
21607
21680
  class CacheHandler {
21608
21681
  #cacheKey;
@@ -21643,21 +21716,22 @@ var require_cache_handler = __commonJS(function(exports, module) {
21643
21716
  invalidateUnsafeRequest(this.#store, this.#cacheKey, resHeaders);
21644
21717
  return downstreamOnHeaders();
21645
21718
  }
21646
- if (this.#history && this.#history.length > 0) {
21647
- const finalUrl = this.#history[this.#history.length - 1];
21648
- if (!sameOrigin(finalUrl.origin, this.#cacheKey.origin)) {
21649
- return downstreamOnHeaders();
21650
- }
21719
+ if (this.#history && this.#history.length > 1 && requestCarriesCredentials(this.#cacheKey.headers)) {
21720
+ return downstreamOnHeaders();
21651
21721
  }
21652
- const redirectCacheControl = this.#history?.[kRedirectCacheControl];
21653
- if (redirectCacheControl) {
21654
- for (const hopCacheControl of redirectCacheControl) {
21655
- const hopDirectives = hopCacheControl ? parseCacheControlHeader(hopCacheControl) : {};
21656
- if (hopDirectives["no-store"] === true || this.#cacheType === "shared" && hopDirectives.private === true) {
21722
+ if (this.#history && this.#history.length > 0) {
21723
+ for (const hopUrl of this.#history) {
21724
+ if (!sameOrigin(hopUrl.origin, this.#cacheKey.origin)) {
21657
21725
  return downstreamOnHeaders();
21658
21726
  }
21659
21727
  }
21660
21728
  }
21729
+ const now = Date.now();
21730
+ const redirectHopInfo = this.#history?.[kRedirectCacheControl];
21731
+ const redirectPolicy = redirectHopInfo?.length > 0 ? getRedirectPolicy(this.#cacheType, this.#cacheKey.method, redirectHopInfo, this.#cacheKey.headers, this.#cacheByDefault, now) : undefined;
21732
+ if (redirectHopInfo?.length > 0 && redirectPolicy === undefined) {
21733
+ return downstreamOnHeaders();
21734
+ }
21661
21735
  const cacheControlHeader = resHeaders["cache-control"];
21662
21736
  const cacheControlDirectives = cacheControlHeader ? parseCacheControlHeader(cacheControlHeader) : {};
21663
21737
  if (revalidationResponseDisallowsCachedReuse(this.#cacheType, resHeaders, cacheControlDirectives)) {
@@ -21677,7 +21751,6 @@ var require_cache_handler = __commonJS(function(exports, module) {
21677
21751
  }
21678
21752
  return downstreamOnHeaders();
21679
21753
  }
21680
- const now = Date.now();
21681
21754
  const resAge = Object.hasOwn(resHeaders, "age") ? getAge(resHeaders.age) : undefined;
21682
21755
  if (resAge !== undefined && resAge >= MAX_RESPONSE_AGE) {
21683
21756
  deleteCachedValueIfNotModified(statusCode, this.#store, this.#cacheKey);
@@ -21700,27 +21773,53 @@ var require_cache_handler = __commonJS(function(exports, module) {
21700
21773
  return downstreamOnHeaders();
21701
21774
  }
21702
21775
  const baseTime = now - currentAge;
21703
- const absoluteStaleAt = staleAt + baseTime;
21776
+ let absoluteStaleAt = staleAt + baseTime;
21777
+ if (redirectPolicy !== undefined) {
21778
+ absoluteStaleAt = Math.min(absoluteStaleAt, redirectPolicy.staleAt);
21779
+ }
21704
21780
  if (now >= absoluteStaleAt && !revalidationOnly) {
21705
21781
  deleteCachedValueIfNotModified(statusCode, this.#store, this.#cacheKey);
21706
21782
  return downstreamOnHeaders();
21707
21783
  }
21708
21784
  let varyDirectives;
21709
- if (this.#cacheKey.headers && resHeaders.vary) {
21710
- varyDirectives = parseVaryHeader(resHeaders.vary, this.#cacheKey.headers);
21711
- if (!varyDirectives) {
21712
- return downstreamOnHeaders();
21785
+ const combinedVary = [];
21786
+ if (redirectHopInfo) {
21787
+ for (const hop of redirectHopInfo) {
21788
+ appendVaryValues(combinedVary, hop?.headers?.vary);
21789
+ }
21790
+ }
21791
+ appendVaryValues(combinedVary, resHeaders.vary);
21792
+ if (combinedVary.length > 0) {
21793
+ for (const varyHeader of combinedVary) {
21794
+ if (hasVaryStar(varyHeader)) {
21795
+ return downstreamOnHeaders();
21796
+ }
21797
+ }
21798
+ if (this.#cacheKey.headers) {
21799
+ varyDirectives = parseVaryHeader(combinedVary, this.#cacheKey.headers);
21800
+ if (!varyDirectives) {
21801
+ return downstreamOnHeaders();
21802
+ }
21803
+ }
21804
+ }
21805
+ let effectiveCacheControlDirectives = cacheControlDirectives;
21806
+ if (redirectPolicy !== undefined) {
21807
+ effectiveCacheControlDirectives = { ...cacheControlDirectives };
21808
+ delete effectiveCacheControlDirectives["stale-while-revalidate"];
21809
+ delete effectiveCacheControlDirectives["stale-if-error"];
21810
+ if (redirectPolicy.requiresRevalidation === true) {
21811
+ effectiveCacheControlDirectives["proxy-revalidate"] = true;
21713
21812
  }
21714
21813
  }
21715
21814
  const cachedAt = baseTime;
21716
- const deleteAt = determineDeleteAt(baseTime, now, cacheControlDirectives, absoluteStaleAt);
21815
+ const deleteAt = determineDeleteAt(baseTime, now, effectiveCacheControlDirectives, absoluteStaleAt);
21717
21816
  const strippedHeaders = stripNecessaryHeaders(resHeaders, cacheControlDirectives);
21718
21817
  const value = {
21719
21818
  statusCode,
21720
21819
  statusMessage,
21721
21820
  headers: strippedHeaders,
21722
21821
  vary: varyDirectives,
21723
- cacheControlDirectives,
21822
+ cacheControlDirectives: effectiveCacheControlDirectives,
21724
21823
  cachedAt,
21725
21824
  staleAt: absoluteStaleAt,
21726
21825
  deleteAt
@@ -21734,6 +21833,13 @@ var require_cache_handler = __commonJS(function(exports, module) {
21734
21833
  done = true;
21735
21834
  this.#downstreamController.release();
21736
21835
  };
21836
+ const failReplay = (err) => {
21837
+ if (done) {
21838
+ return;
21839
+ }
21840
+ done = true;
21841
+ controller.abort(err);
21842
+ };
21737
21843
  const handle304 = (cachedValue) => {
21738
21844
  if (!cachedValue) {
21739
21845
  downstreamOnHeaders();
@@ -21757,14 +21863,18 @@ var require_cache_handler = __commonJS(function(exports, module) {
21757
21863
  if (done) {
21758
21864
  return;
21759
21865
  }
21760
- for (const chunk of bodyIterator) {
21761
- const full = this.#writeStream?.write(chunk) === false;
21762
- this.#handler.onResponseData?.(this.#downstreamController, chunk);
21763
- if (full) {
21764
- return;
21866
+ try {
21867
+ for (const chunk of bodyIterator) {
21868
+ const full = this.#writeStream?.write(chunk) === false;
21869
+ this.#handler.onResponseData?.(this.#downstreamController, chunk);
21870
+ if (full) {
21871
+ return;
21872
+ }
21765
21873
  }
21874
+ finish304();
21875
+ } catch (err) {
21876
+ failReplay(err);
21766
21877
  }
21767
- finish304();
21768
21878
  };
21769
21879
  this.#writeStream.on("error", function() {
21770
21880
  handler.#writeStream = undefined;
@@ -21781,8 +21891,13 @@ var require_cache_handler = __commonJS(function(exports, module) {
21781
21891
  streamCachedBody();
21782
21892
  } else if (typeof cachedValue.body.on === "function") {
21783
21893
  cachedValue.body.on("data", (chunk) => {
21784
- this.#writeStream?.write(chunk);
21785
- this.#handler.onResponseData?.(this.#downstreamController, chunk);
21894
+ try {
21895
+ this.#writeStream?.write(chunk);
21896
+ this.#handler.onResponseData?.(this.#downstreamController, chunk);
21897
+ } catch (err) {
21898
+ cachedValue.body.destroy();
21899
+ failReplay(err);
21900
+ }
21786
21901
  }).on("end", () => {
21787
21902
  this.#writeStream?.end();
21788
21903
  finish304();
@@ -21897,6 +22012,65 @@ var require_cache_handler = __commonJS(function(exports, module) {
21897
22012
  }
21898
22013
  return true;
21899
22014
  }
22015
+ function getRedirectPolicy(cacheType, method, redirectHops, reqHeaders, cacheByDefault, now) {
22016
+ let staleAt = Infinity;
22017
+ let requiresRevalidation = false;
22018
+ for (const hop of redirectHops) {
22019
+ const hopPolicy = getRedirectHopPolicy(cacheType, method, hop, reqHeaders, cacheByDefault);
22020
+ if (hopPolicy === undefined || hopPolicy.staleAt <= now) {
22021
+ return;
22022
+ }
22023
+ staleAt = Math.min(staleAt, hopPolicy.staleAt);
22024
+ requiresRevalidation ||= hopPolicy.requiresRevalidation;
22025
+ }
22026
+ return { staleAt, requiresRevalidation };
22027
+ }
22028
+ function getRedirectHopPolicy(cacheType, method, hop, reqHeaders, cacheByDefault) {
22029
+ if (!Number.isInteger(hop?.statusCode) || !Number.isFinite(hop?.receivedAt)) {
22030
+ return;
22031
+ }
22032
+ const hopHeaders = hop.headers ?? {};
22033
+ const cacheControlHeader = hopHeaders["cache-control"];
22034
+ const hopCacheControl = cacheControlHeader ? parseCacheControlHeader(cacheControlHeader) : {};
22035
+ if (hopHeaders.vary && hasVaryStar(hopHeaders.vary)) {
22036
+ return;
22037
+ }
22038
+ if (hopCacheControl["no-store"] === true) {
22039
+ return;
22040
+ }
22041
+ if (cacheType === "shared" && Object.hasOwn(hopCacheControl, "private")) {
22042
+ return;
22043
+ }
22044
+ if (Object.hasOwn(hopCacheControl, "no-cache") || hopCacheControl["must-revalidate"] === true || cacheType === "shared" && hopCacheControl["proxy-revalidate"] === true) {
22045
+ return;
22046
+ }
22047
+ const heuristicallyCacheable = hopHeaders["last-modified"] && arrayIncludes(HEURISTICALLY_CACHEABLE_STATUS_CODES, hop.statusCode);
22048
+ if (!cacheControlHeader && !hopHeaders.expires && !heuristicallyCacheable && !cacheByDefault) {
22049
+ return;
22050
+ }
22051
+ if (!canCacheResponse(cacheType, method, hop.statusCode, hopHeaders, hopCacheControl, reqHeaders)) {
22052
+ return;
22053
+ }
22054
+ const age = Object.hasOwn(hopHeaders, "age") ? getAge(hopHeaders.age) : undefined;
22055
+ if (age !== undefined && age >= MAX_RESPONSE_AGE) {
22056
+ return;
22057
+ }
22058
+ const responseDate = Object.hasOwn(hopHeaders, "date") ? getDate(hopHeaders.date) : undefined;
22059
+ if (responseDate === null) {
22060
+ return;
22061
+ }
22062
+ const apparentAge = responseDate ? Math.max(0, hop.receivedAt - responseDate.getTime()) : 0;
22063
+ const currentAge = Math.max(apparentAge, age ?? 0);
22064
+ const hasValidator = typeof hopHeaders.etag === "string" && isEtagUsable(hopHeaders.etag) || typeof hopHeaders["last-modified"] === "string";
22065
+ const freshnessLifetime = determineStaleAt(cacheType, hop.receivedAt, age, hopHeaders, responseDate, hopCacheControl, hasValidator) ?? cacheByDefault;
22066
+ if (freshnessLifetime === undefined) {
22067
+ return;
22068
+ }
22069
+ return {
22070
+ staleAt: hop.receivedAt - currentAge + freshnessLifetime,
22071
+ requiresRevalidation: cacheType === "shared" && Object.hasOwn(hopCacheControl, "s-maxage")
22072
+ };
22073
+ }
21900
22074
  function getDate(dateHeader) {
21901
22075
  let dateValue = dateHeader;
21902
22076
  if (Array.isArray(dateValue)) {
@@ -22346,7 +22520,8 @@ var require_cache2 = __commonJS(function(exports, module) {
22346
22520
  normalizeHeaders,
22347
22521
  parseCacheControlHeader,
22348
22522
  isInvalidOrWildcardVaryHeader,
22349
- parseVaryHeader
22523
+ parseVaryHeader,
22524
+ isEtagUsable
22350
22525
  } = require_cache();
22351
22526
  var { AbortError } = require_errors();
22352
22527
  var { parseHttpDate } = require_date();
@@ -22463,6 +22638,34 @@ var require_cache2 = __commonJS(function(exports, module) {
22463
22638
  }
22464
22639
  return headers;
22465
22640
  }
22641
+ function revalidationTargetMatchesCacheKey(cacheKey, context) {
22642
+ const history = context?.history;
22643
+ if (!Array.isArray(history) || history.length === 0) {
22644
+ return true;
22645
+ }
22646
+ try {
22647
+ const cachedUrl = new URL(cacheKey.path, cacheKey.origin);
22648
+ const responseUrl = history[history.length - 1];
22649
+ return responseUrl.origin === cachedUrl.origin && responseUrl.pathname === cachedUrl.pathname && responseUrl.search === cachedUrl.search;
22650
+ } catch {
22651
+ return false;
22652
+ }
22653
+ }
22654
+ function revalidationEtagMatchesCachedValue(result, headers) {
22655
+ if (!Object.hasOwn(headers, "etag")) {
22656
+ return true;
22657
+ }
22658
+ const responseEtag = headers.etag;
22659
+ const cachedEtag = result.etag;
22660
+ if (typeof responseEtag !== "string" || typeof cachedEtag !== "string" || !isEtagUsable(responseEtag) || !isEtagUsable(cachedEtag)) {
22661
+ return false;
22662
+ }
22663
+ if (!responseEtag.startsWith("W/")) {
22664
+ return responseEtag === cachedEtag;
22665
+ }
22666
+ const cachedOpaqueTag = cachedEtag.startsWith("W/") ? cachedEtag.slice(2) : cachedEtag;
22667
+ return responseEtag.slice(2) === cachedOpaqueTag;
22668
+ }
22466
22669
  function isStale(result, cacheControlDirectives, cacheType) {
22467
22670
  const now = Date.now();
22468
22671
  if (now > result.staleAt || result.staleAt <= result.cachedAt) {
@@ -22560,18 +22763,23 @@ var require_cache2 = __commonJS(function(exports, module) {
22560
22763
  };
22561
22764
  stream.on("error", function(err) {
22562
22765
  if (!this.readableEnded) {
22563
- if (typeof handler.onResponseError === "function") {
22564
- handler.onResponseError(controller, err);
22565
- } else {
22566
- throw err;
22567
- }
22766
+ handler.onResponseError?.(controller, err);
22568
22767
  }
22569
22768
  }).on("close", function() {
22570
22769
  if (!this.errored) {
22571
- handler.onResponseEnd?.(controller, {});
22770
+ try {
22771
+ handler.onResponseEnd?.(controller, {});
22772
+ } catch (err) {
22773
+ handler.onResponseError?.(controller, err);
22774
+ }
22572
22775
  }
22573
22776
  });
22574
- handler.onRequestStart?.(controller, context);
22777
+ try {
22778
+ handler.onRequestStart?.(controller, context);
22779
+ } catch (err) {
22780
+ stream.destroy(err);
22781
+ return;
22782
+ }
22575
22783
  if (stream.destroyed) {
22576
22784
  return;
22577
22785
  }
@@ -22580,12 +22788,21 @@ var require_cache2 = __commonJS(function(exports, module) {
22580
22788
  headers.warning = '110 - "response is stale"';
22581
22789
  }
22582
22790
  controller.rawHeaders = util.toRawHeaders(headers);
22583
- handler.onResponseStart?.(controller, result.statusCode, headers, result.statusMessage);
22791
+ try {
22792
+ handler.onResponseStart?.(controller, result.statusCode, headers, result.statusMessage);
22793
+ } catch (err) {
22794
+ stream.destroy(err);
22795
+ return;
22796
+ }
22584
22797
  if (opts.method === "HEAD") {
22585
22798
  stream.destroy();
22586
22799
  } else {
22587
22800
  stream.on("data", function(chunk) {
22588
- handler.onResponseData?.(controller, chunk);
22801
+ try {
22802
+ handler.onResponseData?.(controller, chunk);
22803
+ } catch (err) {
22804
+ stream.destroy(err);
22805
+ }
22589
22806
  });
22590
22807
  }
22591
22808
  }
@@ -22638,27 +22855,26 @@ var require_cache2 = __commonJS(function(exports, module) {
22638
22855
  }
22639
22856
  }
22640
22857
  const headers = makeRevalidationHeaders(opts, result);
22858
+ const refetch = () => {
22859
+ if (util.isStream(result.body)) {
22860
+ result.body.on("error", nop).destroy();
22861
+ }
22862
+ deleteCachedValue(globalOpts.store, cacheKey);
22863
+ return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler));
22864
+ };
22641
22865
  return dispatch({
22642
22866
  ...opts,
22643
22867
  headers
22644
22868
  }, new CacheRevalidationHandler((success, context, statusCode, headers) => {
22645
22869
  if (success) {
22646
22870
  if (statusCode === 304) {
22647
- if (revalidationResponseDisallowsCachedReuse(globalOpts.type, headers)) {
22648
- if (util.isStream(result.body)) {
22649
- result.body.on("error", nop).destroy();
22650
- }
22651
- deleteCachedValue(globalOpts.store, cacheKey);
22652
- return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler));
22871
+ if (!revalidationTargetMatchesCacheKey(cacheKey, context) || !revalidationEtagMatchesCachedValue(result, headers) || revalidationResponseDisallowsCachedReuse(globalOpts.type, headers)) {
22872
+ return refetch();
22653
22873
  }
22654
22874
  if (revalidationResponseUpdatesCacheControl(headers)) {
22655
22875
  deleteCachedValue(globalOpts.store, cacheKey);
22656
22876
  } else if (revalidationResponseAddsVary(result, headers.vary ? parseVaryHeader(headers.vary, opts.headers) : undefined)) {
22657
- if (util.isStream(result.body)) {
22658
- result.body.on("error", nop).destroy();
22659
- }
22660
- deleteCachedValue(globalOpts.store, cacheKey);
22661
- return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler));
22877
+ return refetch();
22662
22878
  }
22663
22879
  }
22664
22880
  sendCachedValue(handler, opts, result, age, context, stale);
@@ -22744,7 +22960,28 @@ var require_cache2 = __commonJS(function(exports, module) {
22744
22960
  }
22745
22961
  const result = store.get(cacheKey);
22746
22962
  if (result && typeof result.then === "function") {
22747
- return result.then((result) => handleResult(dispatch, globalOpts, cacheKey, handler, opts, reqCacheControl, result));
22963
+ return result.then((result) => handleResult(dispatch, globalOpts, cacheKey, handler, opts, reqCacheControl, result)).catch((err) => {
22964
+ if (typeof handler.onResponseError === "function") {
22965
+ handler.onResponseError({
22966
+ rawHeaders: [],
22967
+ rawTrailers: [],
22968
+ pause() {},
22969
+ resume() {},
22970
+ get paused() {
22971
+ return false;
22972
+ },
22973
+ get aborted() {
22974
+ return false;
22975
+ },
22976
+ get reason() {
22977
+ return null;
22978
+ },
22979
+ abort() {}
22980
+ }, err);
22981
+ } else {
22982
+ throw err;
22983
+ }
22984
+ });
22748
22985
  } else {
22749
22986
  return handleResult(dispatch, globalOpts, cacheKey, handler, opts, reqCacheControl, result);
22750
22987
  }
@@ -23524,10 +23761,15 @@ var require_sqlite_cache_store = __commonJS(function(exports, module) {
23524
23761
  var { assertCacheKey, assertCacheValue } = require_cache();
23525
23762
  var { zstdCompressSync, zstdDecompressSync } = __require("node:zlib");
23526
23763
  var DatabaseSync;
23527
- var VERSION = 4;
23764
+ var VERSION = 5;
23528
23765
  var MAX_ENTRY_SIZE = 2 * 1000 * 1000 * 1000;
23529
23766
  var COMPRESS_THRESHOLD = 1024 * 1024;
23530
23767
  var hasZstd = typeof zstdCompressSync === "function" && typeof zstdDecompressSync === "function";
23768
+ var SQLITE_BUSY = 5;
23769
+ var SQLITE_LOCKED = 6;
23770
+ function isLockedError(err) {
23771
+ return err?.errcode === SQLITE_BUSY || err?.errcode === SQLITE_LOCKED;
23772
+ }
23531
23773
  module.exports = class SqliteCacheStore {
23532
23774
  #maxEntrySize = MAX_ENTRY_SIZE;
23533
23775
  #maxCount = Infinity;
@@ -23673,7 +23915,7 @@ var require_sqlite_cache_store = __commonJS(function(exports, module) {
23673
23915
  }
23674
23916
  get(key) {
23675
23917
  assertCacheKey(key);
23676
- const value = this.#findValue(key);
23918
+ const value = this.#lockSafe(() => this.#findValue(key));
23677
23919
  return value ? {
23678
23920
  body: value.body ? value.compressed === "zstd" ? zstdDecompressSync(Buffer.from(value.body.buffer, value.body.byteOffset, value.body.byteLength)) : Buffer.from(value.body.buffer, value.body.byteOffset, value.body.byteLength) : undefined,
23679
23921
  statusCode: value.statusCode,
@@ -23704,11 +23946,11 @@ var require_sqlite_cache_store = __commonJS(function(exports, module) {
23704
23946
  compressed = "zstd";
23705
23947
  }
23706
23948
  }
23707
- const existingValue = this.#findValue(key, true);
23949
+ const existingValue = this.#lockSafe(() => this.#findValue(key, true));
23708
23950
  if (existingValue) {
23709
- this.#updateValueQuery.run(storedBody, compressed, value.deleteAt, value.statusCode, value.statusMessage, value.headers ? JSON.stringify(value.headers) : null, value.etag ? value.etag : null, value.cacheControlDirectives ? JSON.stringify(value.cacheControlDirectives) : null, value.vary ? JSON.stringify(value.vary) : null, value.cachedAt, value.staleAt, existingValue.id);
23951
+ this.#lockSafe(() => this.#updateValueQuery.run(storedBody, compressed, value.deleteAt, value.statusCode, value.statusMessage, value.headers ? JSON.stringify(value.headers) : null, value.etag ? value.etag : null, value.cacheControlDirectives ? JSON.stringify(value.cacheControlDirectives) : null, value.vary ? JSON.stringify(value.vary) : null, value.cachedAt, value.staleAt, existingValue.id));
23710
23952
  } else {
23711
- this.#insertValueQuery.run(url, key.method, storedBody, compressed, value.deleteAt, value.statusCode, value.statusMessage, value.headers ? JSON.stringify(value.headers) : null, value.etag ? value.etag : null, value.cacheControlDirectives ? JSON.stringify(value.cacheControlDirectives) : null, value.vary ? JSON.stringify(value.vary) : null, value.cachedAt, value.staleAt);
23953
+ this.#lockSafe(() => this.#insertValueQuery.run(url, key.method, storedBody, compressed, value.deleteAt, value.statusCode, value.statusMessage, value.headers ? JSON.stringify(value.headers) : null, value.etag ? value.etag : null, value.cacheControlDirectives ? JSON.stringify(value.cacheControlDirectives) : null, value.vary ? JSON.stringify(value.vary) : null, value.cachedAt, value.staleAt));
23712
23954
  this.#prune();
23713
23955
  }
23714
23956
  }
@@ -23739,20 +23981,33 @@ var require_sqlite_cache_store = __commonJS(function(exports, module) {
23739
23981
  if (typeof key !== "object") {
23740
23982
  throw new TypeError(`expected key to be object, got ${typeof key}`);
23741
23983
  }
23742
- this.#deleteByUrlQuery.run(this.#makeValueUrl(key));
23984
+ this.#lockSafe(() => this.#deleteByUrlQuery.run(this.#makeValueUrl(key)));
23985
+ }
23986
+ #lockSafe(fn) {
23987
+ try {
23988
+ return fn();
23989
+ } catch (err) {
23990
+ if (!isLockedError(err)) {
23991
+ throw err;
23992
+ }
23993
+ return;
23994
+ }
23743
23995
  }
23744
23996
  #prune() {
23745
- if (Number.isFinite(this.#maxCount) && this.size <= this.#maxCount) {
23746
- return 0;
23997
+ if (Number.isFinite(this.#maxCount)) {
23998
+ const size = this.#lockSafe(() => this.size);
23999
+ if (size === undefined || size <= this.#maxCount) {
24000
+ return 0;
24001
+ }
23747
24002
  }
23748
24003
  {
23749
- const removed = this.#deleteExpiredValuesQuery.run(Date.now()).changes;
24004
+ const removed = this.#lockSafe(() => this.#deleteExpiredValuesQuery.run(Date.now()).changes);
23750
24005
  if (removed) {
23751
24006
  return removed;
23752
24007
  }
23753
24008
  }
23754
24009
  {
23755
- const removed = this.#deleteOldValuesQuery?.run(Math.max(Math.floor(this.#maxCount * 0.1), 1)).changes;
24010
+ const removed = this.#lockSafe(() => this.#deleteOldValuesQuery?.run(Math.max(Math.floor(this.#maxCount * 0.1), 1)).changes);
23756
24011
  if (removed) {
23757
24012
  return removed;
23758
24013
  }
@@ -24658,41 +24913,66 @@ var require_request2 = __commonJS(function(exports, module) {
24658
24913
  var { URLSerializer } = require_data_url();
24659
24914
  var { kConstruct } = require_symbols();
24660
24915
  var assert = __require("node:assert");
24661
- var { getMaxListeners, setMaxListeners, defaultMaxListeners } = __require("node:events");
24662
- var kAbortController = Symbol("abortController");
24663
- var requestFinalizer = new FinalizationRegistry(({ signal, abort }) => {
24664
- signal.removeEventListener("abort", abort);
24916
+ var requestFinalizer = new FinalizationRegistry(({ signal, reference }) => {
24917
+ removeSignalFollower(signal, reference);
24665
24918
  });
24666
- var dependentControllerMap = new WeakMap;
24667
- var abortSignalHasEventHandlerLeakWarning;
24668
- try {
24669
- abortSignalHasEventHandlerLeakWarning = getMaxListeners(new AbortController().signal) > 0;
24670
- } catch {
24671
- abortSignalHasEventHandlerLeakWarning = false;
24672
- }
24673
- function buildAbort(acRef) {
24674
- return abort;
24675
- function abort() {
24676
- const ac = acRef.deref();
24677
- if (ac !== undefined) {
24678
- requestFinalizer.unregister(abort);
24679
- this.removeEventListener("abort", abort);
24680
- ac.abort(this.reason);
24681
- const controllerList = dependentControllerMap.get(ac.signal);
24682
- if (controllerList !== undefined) {
24683
- if (controllerList.size !== 0) {
24684
- for (const ref of controllerList) {
24685
- const ctrl = ref.deref();
24686
- if (ctrl !== undefined) {
24687
- ctrl.abort(this.reason);
24688
- }
24689
- }
24690
- controllerList.clear();
24691
- }
24692
- dependentControllerMap.delete(ac.signal);
24693
- }
24919
+ var requestSignals = new WeakMap;
24920
+ var signalFollowers = new WeakMap;
24921
+ function removeSignalFollower(signal, reference) {
24922
+ const followers = signalFollowers.get(signal);
24923
+ if (followers instanceof Set) {
24924
+ followers.delete(reference);
24925
+ if (followers.size !== 0)
24926
+ return;
24927
+ }
24928
+ signal.removeEventListener("abort", abortSignalFollowers);
24929
+ signalFollowers.delete(signal);
24930
+ }
24931
+ function abortSignalFollower(reference, reason) {
24932
+ requestFinalizer.unregister(reference);
24933
+ const ac = reference.deref();
24934
+ if (ac !== undefined) {
24935
+ requestSignals.delete(ac.signal);
24936
+ ac.abort(reason);
24937
+ }
24938
+ }
24939
+ function abortSignalFollowers() {
24940
+ this.removeEventListener("abort", abortSignalFollowers);
24941
+ const followers = signalFollowers.get(this);
24942
+ if (followers instanceof Set) {
24943
+ for (const reference of followers) {
24944
+ abortSignalFollower(reference, this.reason);
24694
24945
  }
24946
+ followers.clear();
24947
+ } else {
24948
+ abortSignalFollower(followers, this.reason);
24949
+ }
24950
+ signalFollowers.delete(this);
24951
+ }
24952
+ function createDependentSignal(signal) {
24953
+ const ac = new AbortController;
24954
+ if (signal == null)
24955
+ return ac.signal;
24956
+ if (signal.aborted) {
24957
+ ac.abort(signal.reason);
24958
+ return ac.signal;
24959
+ }
24960
+ const reference = new WeakRef(ac);
24961
+ const followers = signalFollowers.get(signal);
24962
+ if (followers === undefined) {
24963
+ util.addAbortListener(signal, abortSignalFollowers);
24964
+ signalFollowers.set(signal, reference);
24965
+ } else if (followers instanceof WeakRef) {
24966
+ const controllers = new Set;
24967
+ controllers.add(followers);
24968
+ controllers.add(reference);
24969
+ signalFollowers.set(signal, controllers);
24970
+ } else {
24971
+ followers.add(reference);
24695
24972
  }
24973
+ requestFinalizer.register(ac, { signal, reference }, reference);
24974
+ requestSignals.set(ac.signal, { controller: ac, source: signal, reference });
24975
+ return ac.signal;
24696
24976
  }
24697
24977
  var patchMethodWarning = false;
24698
24978
  var setRequestSignal;
@@ -24708,7 +24988,6 @@ var require_request2 = __commonJS(function(exports, module) {
24708
24988
  #dispatcher;
24709
24989
  #headers;
24710
24990
  #state;
24711
- #abortCleanup = null;
24712
24991
  constructor(input, init = undefined) {
24713
24992
  webidl.util.markAsUncloneable(this);
24714
24993
  if (input === kConstruct) {
@@ -24866,27 +25145,7 @@ var require_request2 = __commonJS(function(exports, module) {
24866
25145
  signal = init.signal;
24867
25146
  }
24868
25147
  this.#state = request;
24869
- const ac = new AbortController;
24870
- this.#signal = ac.signal;
24871
- if (signal != null) {
24872
- if (signal.aborted) {
24873
- ac.abort(signal.reason);
24874
- } else {
24875
- this[kAbortController] = ac;
24876
- const acRef = new WeakRef(ac);
24877
- const abort = buildAbort(acRef);
24878
- if (abortSignalHasEventHandlerLeakWarning && getMaxListeners(signal) === defaultMaxListeners) {
24879
- setMaxListeners(1500, signal);
24880
- }
24881
- const removeAbortListener = util.addAbortListener(signal, abort);
24882
- requestFinalizer.register(ac, { signal, abort }, abort);
24883
- this.#abortCleanup = () => {
24884
- requestFinalizer.unregister(abort);
24885
- removeAbortListener();
24886
- this.#abortCleanup = null;
24887
- };
24888
- }
24889
- }
25148
+ this.#signal = createDependentSignal(signal);
24890
25149
  this.#headers = new Headers2(kConstruct);
24891
25150
  setHeadersList(this.#headers, request.headersList);
24892
25151
  setHeadersGuard(this.#headers, "request");
@@ -25030,20 +25289,8 @@ var require_request2 = __commonJS(function(exports, module) {
25030
25289
  throw new TypeError("unusable");
25031
25290
  }
25032
25291
  const clonedRequest = cloneRequest(this.#state);
25033
- const ac = new AbortController;
25034
- if (this.signal.aborted) {
25035
- ac.abort(this.signal.reason);
25036
- } else {
25037
- let list = dependentControllerMap.get(this.signal);
25038
- if (list === undefined) {
25039
- list = new Set;
25040
- dependentControllerMap.set(this.signal, list);
25041
- }
25042
- const acRef = new WeakRef(ac);
25043
- list.add(acRef);
25044
- util.addAbortListener(ac.signal, buildAbort(acRef));
25045
- }
25046
- return fromInnerRequest(clonedRequest, this.#dispatcher, ac.signal, getHeadersGuard(this.#headers));
25292
+ const signal = createDependentSignal(this.#signal);
25293
+ return fromInnerRequest(clonedRequest, this.#dispatcher, signal, getHeadersGuard(this.#headers));
25047
25294
  }
25048
25295
  [nodeUtil.inspect.custom](depth, options) {
25049
25296
  if (options.depth === null) {
@@ -25089,7 +25336,12 @@ var require_request2 = __commonJS(function(exports, module) {
25089
25336
  request.#state = newState;
25090
25337
  };
25091
25338
  removeRequestAbortListener = (request) => {
25092
- request.#abortCleanup?.();
25339
+ const state = requestSignals.get(request.#signal);
25340
+ if (state !== undefined) {
25341
+ requestSignals.delete(request.#signal);
25342
+ requestFinalizer.unregister(state.reference);
25343
+ removeSignalFollower(state.source, state.reference);
25344
+ }
25093
25345
  };
25094
25346
  webidl.is.Request = (arg) => {
25095
25347
  return arg != null && typeof arg === "object" && #state in arg;
@@ -25345,7 +25597,7 @@ var require_subresource_integrity = __commonJS(function(exports, module) {
25345
25597
  }
25346
25598
  function parseMetadata(metadata) {
25347
25599
  const result = [];
25348
- for (const item of metadata.split(" ")) {
25600
+ for (const item of metadata.split(/[\t\n\f\r ]+/)) {
25349
25601
  const expressionAndOptions = item.split("?", 1);
25350
25602
  const algorithmExpression = expressionAndOptions[0];
25351
25603
  let base64Value = "";
@@ -25589,8 +25841,7 @@ var require_fetch = __commonJS(function(exports, module) {
25589
25841
  cleanupAbortListeners();
25590
25842
  },
25591
25843
  processResponse,
25592
- dispatcher: getRequestDispatcher(requestObject),
25593
- requestObject
25844
+ dispatcher: getRequestDispatcher(requestObject)
25594
25845
  });
25595
25846
  return p.promise;
25596
25847
  }
@@ -25649,8 +25900,7 @@ var require_fetch = __commonJS(function(exports, module) {
25649
25900
  processResponseEndOfBody,
25650
25901
  processResponseConsumeBody,
25651
25902
  useParallelQueue = false,
25652
- dispatcher = getGlobalDispatcher(),
25653
- requestObject = null
25903
+ dispatcher = getGlobalDispatcher()
25654
25904
  }) {
25655
25905
  assert(dispatcher);
25656
25906
  let taskDestination = null;
@@ -25673,8 +25923,7 @@ var require_fetch = __commonJS(function(exports, module) {
25673
25923
  processResponseConsumeBody,
25674
25924
  processResponseEndOfBody,
25675
25925
  taskDestination,
25676
- crossOriginIsolatedCapability,
25677
- requestObject
25926
+ crossOriginIsolatedCapability
25678
25927
  };
25679
25928
  assert(!request.body || request.body.stream);
25680
25929
  if (request.window === "client") {
@@ -51404,8 +51653,10 @@ ${source_default.bold("Environment Variables:")}
51404
51653
  CLOUDFLARE_API_KEY - Cloudflare API token (Workers AI and AI Gateway)
51405
51654
  CLOUDFLARE_ACCOUNT_ID - Cloudflare account id (required for both)
51406
51655
  CLOUDFLARE_GATEWAY_ID - Cloudflare AI Gateway slug (required for AI Gateway)
51407
- QWEN_TOKEN_PLAN_API_KEY - Qwen Token Plan API key (international region)
51408
- QWEN_TOKEN_PLAN_CN_API_KEY - Qwen Token Plan API key (China region)
51656
+ QWEN_TOKEN_PLAN_TEAM_API_KEY - Qwen Token Plan Team API key (international region)
51657
+ QWEN_TOKEN_PLAN_TEAM_CN_API_KEY - Qwen Token Plan Team API key (China region)
51658
+ QWEN_TOKEN_PLAN_INDIVIDUAL_API_KEY - Qwen Token Plan Individual API key (international region)
51659
+ QWEN_TOKEN_PLAN_INDIVIDUAL_CN_API_KEY - Qwen Token Plan Individual API key (China region)
51409
51660
  XIAOMI_API_KEY - Xiaomi MiMo API key (api.xiaomimimo.com billing)
51410
51661
  XIAOMI_TOKEN_PLAN_CN_API_KEY - Xiaomi MiMo Token Plan API key (China region)
51411
51662
  XIAOMI_TOKEN_PLAN_AMS_API_KEY - Xiaomi MiMo Token Plan API key (Amsterdam region)
@@ -51439,10 +51690,10 @@ import { readFileSync as readFileSync8 } from "node:fs";
51439
51690
  import { basename as basename8, dirname as dirname13 } from "node:path";
51440
51691
 
51441
51692
  // node_modules/@earendil-works/pi-agent-core/dist/agent.js
51442
- init_dist3();
51693
+ init_dist2();
51443
51694
 
51444
51695
  // node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js
51445
- init_dist3();
51696
+ init_dist2();
51446
51697
 
51447
51698
  // node_modules/@earendil-works/pi-agent-core/dist/stream-fn.js
51448
51699
  var defaultStreamFn;
@@ -51778,9 +52029,6 @@ async function executeToolCallsSequential(currentContext, assistantMessage, tool
51778
52029
  await emitToolResultMessage(toolResultMessage, emit);
51779
52030
  finalizedCalls.push(finalized);
51780
52031
  messages.push(toolResultMessage);
51781
- if (signal?.aborted) {
51782
- break;
51783
- }
51784
52032
  }
51785
52033
  return {
51786
52034
  messages,
@@ -51805,9 +52053,6 @@ async function executeToolCallsParallel(currentContext, assistantMessage, toolCa
51805
52053
  };
51806
52054
  await emitToolExecutionEnd(finalized, emit);
51807
52055
  finalizedCalls.push(finalized);
51808
- if (signal?.aborted) {
51809
- break;
51810
- }
51811
52056
  continue;
51812
52057
  }
51813
52058
  finalizedCalls.push(async () => {
@@ -51825,9 +52070,6 @@ async function executeToolCallsParallel(currentContext, assistantMessage, toolCa
51825
52070
  await emitToolExecutionEnd(finalized, emit);
51826
52071
  return finalized;
51827
52072
  });
51828
- if (signal?.aborted) {
51829
- break;
51830
- }
51831
52073
  }
51832
52074
  const orderedFinalizedCalls = await Promise.all(finalizedCalls.map((entry) => typeof entry === "function" ? entry() : Promise.resolve(entry)));
51833
52075
  const messages = [];
@@ -51858,6 +52100,13 @@ function prepareToolCallArguments(tool, toolCall) {
51858
52100
  };
51859
52101
  }
51860
52102
  async function prepareToolCall(currentContext, assistantMessage, toolCall, config, signal, tools = currentContext.tools ?? []) {
52103
+ if (signal?.aborted) {
52104
+ return {
52105
+ kind: "immediate",
52106
+ result: createErrorToolResult("Operation aborted"),
52107
+ isError: true
52108
+ };
52109
+ }
51861
52110
  const tool = tools.find((t) => t.name === toolCall.name);
51862
52111
  if (!tool) {
51863
52112
  return {
@@ -51895,13 +52144,6 @@ async function prepareToolCall(currentContext, assistantMessage, toolCall, confi
51895
52144
  };
51896
52145
  }
51897
52146
  }
51898
- if (signal?.aborted) {
51899
- return {
51900
- kind: "immediate",
51901
- result: createErrorToolResult("Operation aborted"),
51902
- isError: true
51903
- };
51904
- }
51905
52147
  return {
51906
52148
  kind: "prepared",
51907
52149
  toolCall,
@@ -52417,7 +52659,7 @@ class Agent2 {
52417
52659
  }
52418
52660
  }
52419
52661
  // node_modules/@earendil-works/pi-agent-core/dist/proxy.js
52420
- init_dist3();
52662
+ init_dist2();
52421
52663
  function buildProxyRequestOptions(options) {
52422
52664
  return {
52423
52665
  temperature: options.temperature,
@@ -52679,7 +52921,7 @@ function processProxyEvent(proxyEvent, partial, toolArguments) {
52679
52921
  }
52680
52922
  }
52681
52923
  // node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js
52682
- init_dist3();
52924
+ init_dist2();
52683
52925
  init_compat();
52684
52926
 
52685
52927
  // node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js
@@ -54285,14 +54527,63 @@ function finalizeTruncatedResult(prefix, prefixWidth, ellipsis, ellipsisWidth, m
54285
54527
  }
54286
54528
  return pad ? result + " ".repeat(Math.max(0, maxWidth - visibleWidth)) : result;
54287
54529
  }
54530
+ function isStandaloneGraphemeUnit(code) {
54531
+ if (code >= 32 && code <= 126)
54532
+ return true;
54533
+ if (code >= 160 && code <= 767)
54534
+ return code !== 173;
54535
+ if (code >= 8208 && code <= 11263) {
54536
+ return !(code >= 8232 && code <= 8238) && !(code >= 8288 && code <= 8303) && !(code >= 8400 && code <= 8447);
54537
+ }
54538
+ return code >= 12352 && code <= 12438 || code >= 12448 && code <= 12543 || code >= 19968 && code <= 40959 || code >= 65281 && code <= 65376;
54539
+ }
54540
+ function isStandaloneGraphemeRun(text) {
54541
+ for (let i = 0;i < text.length; i++) {
54542
+ if (!isStandaloneGraphemeUnit(text.charCodeAt(i)))
54543
+ return false;
54544
+ }
54545
+ return true;
54546
+ }
54547
+ function* segmentGraphemes(text) {
54548
+ const standalone = (index) => index < 0 || index >= text.length || isStandaloneGraphemeUnit(text.charCodeAt(index));
54549
+ let complexStart = -1;
54550
+ for (let i = 0;i < text.length; i++) {
54551
+ if (standalone(i) && standalone(i - 1) && standalone(i + 1)) {
54552
+ if (complexStart >= 0) {
54553
+ for (const { segment } of graphemeSegmenter.segment(text.slice(complexStart, i)))
54554
+ yield segment;
54555
+ complexStart = -1;
54556
+ }
54557
+ yield text[i];
54558
+ } else if (complexStart < 0) {
54559
+ complexStart = i;
54560
+ }
54561
+ }
54562
+ if (complexStart >= 0) {
54563
+ for (const { segment } of graphemeSegmenter.segment(text.slice(complexStart)))
54564
+ yield segment;
54565
+ }
54566
+ }
54567
+ function graphemesOf(text) {
54568
+ return isStandaloneGraphemeRun(text) ? text : segmentGraphemes(text);
54569
+ }
54570
+ var singleUnitWidths = new Map;
54288
54571
  function graphemeWidth(segment) {
54289
- if (segment.length === 1) {
54290
- const code = segment.charCodeAt(0);
54291
- if (code >= 32 && code <= 126)
54292
- return 1;
54293
- if (code === 9)
54294
- return 3;
54572
+ if (segment.length !== 1)
54573
+ return clusterWidth(segment);
54574
+ const code = segment.charCodeAt(0);
54575
+ if (code >= 32 && code <= 126)
54576
+ return 1;
54577
+ if (code === 9)
54578
+ return 3;
54579
+ let width = singleUnitWidths.get(code);
54580
+ if (width === undefined) {
54581
+ width = clusterWidth(segment);
54582
+ singleUnitWidths.set(code, width);
54295
54583
  }
54584
+ return width;
54585
+ }
54586
+ function clusterWidth(segment) {
54296
54587
  if (terminalSpacingMarkRegex.test(segment)) {
54297
54588
  return [...segment].length;
54298
54589
  }
@@ -54444,7 +54735,15 @@ function getGraphemeCellRange(line, column) {
54444
54735
  let textEnd = i;
54445
54736
  while (textEnd < line.length && !extractAnsiCode(line, textEnd))
54446
54737
  textEnd++;
54447
- for (const { segment } of graphemeSegmenter.segment(line.slice(i, textEnd))) {
54738
+ const text = line.slice(i, textEnd);
54739
+ if (isPrintableAscii(text)) {
54740
+ if (column >= currentCol && column < currentCol + text.length)
54741
+ return { start: column, end: column + 1 };
54742
+ currentCol += text.length;
54743
+ i = textEnd;
54744
+ continue;
54745
+ }
54746
+ for (const segment of graphemesOf(text)) {
54448
54747
  const width = graphemeWidth(segment);
54449
54748
  if (width > 0 && column >= currentCol && column < currentCol + width) {
54450
54749
  return { start: currentCol, end: currentCol + width };
@@ -55167,7 +55466,22 @@ function sliceWithWidth(line, startCol, length, strict = false) {
55167
55466
  let textEnd = i;
55168
55467
  while (textEnd < line.length && !extractAnsiCode(line, textEnd))
55169
55468
  textEnd++;
55170
- for (const { segment } of graphemeSegmenter.segment(line.slice(i, textEnd))) {
55469
+ const text = line.slice(i, textEnd);
55470
+ if (isPrintableAscii(text)) {
55471
+ const from = Math.max(0, startCol - currentCol);
55472
+ const to = Math.min(text.length, endCol - currentCol);
55473
+ if (to > from) {
55474
+ result += pendingAnsi + text.slice(from, to);
55475
+ pendingAnsi = "";
55476
+ resultWidth += to - from;
55477
+ }
55478
+ currentCol += text.length;
55479
+ i = textEnd;
55480
+ if (currentCol >= endCol)
55481
+ break;
55482
+ continue;
55483
+ }
55484
+ for (const segment of graphemesOf(text)) {
55171
55485
  const w = graphemeWidth(segment);
55172
55486
  const inRange = currentCol >= startCol && currentCol < endCol;
55173
55487
  const fits = !strict || currentCol + w <= endCol;
@@ -57436,6 +57750,33 @@ function isImageLine(line) {
57436
57750
  }
57437
57751
  return line.includes(KITTY_PREFIX) || line.includes(ITERM2_PREFIX);
57438
57752
  }
57753
+ function getImageLineExtent(line) {
57754
+ const kittyStart = line.indexOf(KITTY_PREFIX);
57755
+ if (kittyStart !== -1) {
57756
+ const controls = /\x1b_G([^;]*);/.exec(line)?.[1] ?? "";
57757
+ const columnValue = /(?:^|,)c=(\d+)(?:,|$)/.exec(controls)?.[1];
57758
+ const columns = columnValue === undefined ? getRegisteredKittyImageMetadataFromControls(controls)?.columns : Number.parseInt(columnValue, 10);
57759
+ const startCol = visibleWidth(line.slice(0, kittyStart));
57760
+ const rows = getKittyImagePlacementRows(line) ?? 1;
57761
+ return { firstRow: 0, lastRow: rows - 1, startCol, endCol: startCol + (columns ?? Infinity) };
57762
+ }
57763
+ const iterm2Start = line.indexOf(ITERM2_PREFIX);
57764
+ if (iterm2Start === -1)
57765
+ return;
57766
+ const before = line.slice(0, iterm2Start);
57767
+ const moveUp = /\x1b\[(\d+)A$/.exec(before);
57768
+ const columnValue = /[;=]width=(\d+)[;:]/.exec(line.slice(iterm2Start))?.[1];
57769
+ const startCol = visibleWidth(moveUp ? before.slice(0, moveUp.index) : before);
57770
+ return {
57771
+ firstRow: moveUp ? -Number.parseInt(moveUp[1], 10) : 0,
57772
+ lastRow: 0,
57773
+ startCol,
57774
+ endCol: startCol + (columnValue === undefined ? Infinity : Number.parseInt(columnValue, 10))
57775
+ };
57776
+ }
57777
+ function stripImageSequences(line) {
57778
+ return line.replace(/\x1b_G[^\x1b]*\x1b\\/g, "").replace(/(?:\x1b\[\d+A)?\x1b\]1337;File=[^\x07]*\x07/g, "");
57779
+ }
57439
57780
  function allocateImageId() {
57440
57781
  return Math.floor(Math.random() * 4294967294) + 1;
57441
57782
  }
@@ -57903,10 +58244,44 @@ function parseSizeValue(value, referenceSize) {
57903
58244
  }
57904
58245
  return;
57905
58246
  }
58247
+ function sameLines(a, b) {
58248
+ if (a === b)
58249
+ return true;
58250
+ if (a.length !== b.length)
58251
+ return false;
58252
+ for (let index = 0;index < a.length; index++) {
58253
+ if (a[index] !== b[index])
58254
+ return false;
58255
+ }
58256
+ return true;
58257
+ }
58258
+ function renderChildLines(children, width, previous) {
58259
+ const parts = children.map((child) => child.render(width));
58260
+ if (previous?.width === width && previous.children.length === children.length && children.every((child, index) => child === previous.children[index] && sameLines(parts[index], previous.parts[index]))) {
58261
+ return previous;
58262
+ }
58263
+ const lines = [];
58264
+ for (const part of parts) {
58265
+ for (const line of part)
58266
+ lines.push(line);
58267
+ }
58268
+ return { width, children: [...children], parts, lines };
58269
+ }
58270
+ function dispatchMouseToChildLines(layout, event) {
58271
+ let childY = 0;
58272
+ for (let index = 0;index < layout.children.length; index++) {
58273
+ const childHeight = layout.parts[index].length;
58274
+ if (event.y >= childY && event.y < childY + childHeight) {
58275
+ return dispatchMouseEvent(layout.children[index], { ...event, y: event.y - childY, height: childHeight });
58276
+ }
58277
+ childY += childHeight;
58278
+ }
58279
+ return;
58280
+ }
57906
58281
 
57907
58282
  class Container {
57908
58283
  children = [];
57909
- mouseLayout;
58284
+ childLines;
57910
58285
  addChild(component) {
57911
58286
  this.children.push(component);
57912
58287
  }
@@ -57927,35 +58302,15 @@ class Container {
57927
58302
  handleMouse(event) {
57928
58303
  if (event.y < 0 || event.y >= event.height)
57929
58304
  return;
57930
- const mouseChildren = this.mouseLayout?.width === event.width ? this.mouseLayout.children : this.children.map((component) => ({ component, height: component.render(event.width).length }));
57931
- let childY = 0;
57932
- for (const { component: child, height: childHeight } of mouseChildren) {
57933
- if (event.y >= childY && event.y < childY + childHeight) {
57934
- const result = dispatchMouseEvent(child, {
57935
- ...event,
57936
- y: event.y - childY,
57937
- height: childHeight
57938
- });
57939
- if (result?.focus && this.handleInput)
57940
- return { ...result, focusTarget: this };
57941
- return result;
57942
- }
57943
- childY += childHeight;
57944
- }
57945
- return;
58305
+ const layout = this.childLines?.width === event.width ? this.childLines : renderChildLines(this.children, event.width, undefined);
58306
+ const result = dispatchMouseToChildLines(layout, event);
58307
+ if (result?.focus && this.handleInput)
58308
+ return { ...result, focusTarget: this };
58309
+ return result;
57946
58310
  }
57947
58311
  render(width) {
57948
- const lines = [];
57949
- const mouseChildren = [];
57950
- for (const child of this.children) {
57951
- const childLines = child.render(width);
57952
- mouseChildren.push({ component: child, height: childLines.length });
57953
- for (const line of childLines) {
57954
- lines.push(line);
57955
- }
57956
- }
57957
- this.mouseLayout = { width, children: mouseChildren };
57958
- return lines;
58312
+ this.childLines = renderChildLines(this.children, width, this.childLines);
58313
+ return this.childLines.lines;
57959
58314
  }
57960
58315
  }
57961
58316
  var SEGMENT_RESET = "\x1B[0m\x1B]8;;\x07";
@@ -57974,6 +58329,21 @@ function compositeTuiLine(baseLine, overlayLine, startCol, overlayWidth, totalWi
57974
58329
  const result = base.before + " ".repeat(beforePad) + SEGMENT_RESET + overlay.text + " ".repeat(overlayPad) + SEGMENT_RESET + base.after + " ".repeat(afterPad);
57975
58330
  return visibleWidth(result) <= totalWidth ? result : sliceByColumn(result, 0, totalWidth, true);
57976
58331
  }
58332
+ function hideImagesUnderOverlay(lines, overlay, viewportStart) {
58333
+ if (overlay.height === 0)
58334
+ return;
58335
+ for (let index = Math.max(0, viewportStart - getMaxKittyImageRows());index < lines.length; index++) {
58336
+ const line = lines[index];
58337
+ const extent = getImageLineExtent(line);
58338
+ if (!extent)
58339
+ continue;
58340
+ const firstRow = index + extent.firstRow - viewportStart;
58341
+ const lastRow = index + extent.lastRow - viewportStart;
58342
+ if (firstRow < overlay.row + overlay.height && lastRow >= overlay.row && extent.startCol < overlay.col + overlay.width && extent.endCol > overlay.col) {
58343
+ lines[index] = stripImageSequences(line);
58344
+ }
58345
+ }
58346
+ }
57977
58347
  var VIEWPORT_TUI = Symbol.for("@earendil-works/pi-tui/viewport");
57978
58348
  function isViewportTUI(tui) {
57979
58349
  return tui[VIEWPORT_TUI] === true;
@@ -57984,7 +58354,12 @@ class TuiBase extends Container {
57984
58354
  focusedComponent = null;
57985
58355
  inputListeners = new Set;
57986
58356
  onDebug;
58357
+ suspendSignalHandler;
58358
+ suspendSignalListener = () => this.suspendSignalHandler?.();
58359
+ ownsTerminal = false;
58360
+ suspendSignalListening = false;
57987
58361
  renderRequested = false;
58362
+ contentChanged = true;
57988
58363
  immediateRenderScheduled = false;
57989
58364
  renderTimer;
57990
58365
  lastRenderAt = 0;
@@ -58058,6 +58433,7 @@ class TuiBase extends Container {
58058
58433
  this.setFocusInternal({ component, overlayFocusRestore: "clear" });
58059
58434
  }
58060
58435
  setFocusInternal({ component, overlayFocusRestore }) {
58436
+ this.contentChanged = true;
58061
58437
  const previousFocus = this.focusedComponent;
58062
58438
  let nextFocus = component;
58063
58439
  const previousFocusedOverlay = previousFocus ? this.overlayStack.find((entry) => entry.component === previousFocus && this.isOverlayVisible(entry)) : undefined;
@@ -58331,6 +58707,8 @@ class TuiBase extends Container {
58331
58707
  this.stopped = false;
58332
58708
  process.off("exit", this.exitRestoreHandler);
58333
58709
  process.on("exit", this.exitRestoreHandler);
58710
+ this.ownsTerminal = true;
58711
+ this.updateSuspendSignalListener();
58334
58712
  this.beforeTerminalStart();
58335
58713
  this.terminal.start((data) => this.handleTerminalInput(data), () => this.requestRender());
58336
58714
  this.afterTerminalStart();
@@ -58365,6 +58743,20 @@ class TuiBase extends Container {
58365
58743
  this.terminal.write(enabled ? "\x1B[?2031h" : "\x1B[?2031l");
58366
58744
  }
58367
58745
  }
58746
+ setSuspendSignalHandler(handler) {
58747
+ this.suspendSignalHandler = handler;
58748
+ this.updateSuspendSignalListener();
58749
+ }
58750
+ updateSuspendSignalListener() {
58751
+ const listen = this.ownsTerminal && this.suspendSignalHandler !== undefined;
58752
+ if (listen === this.suspendSignalListening)
58753
+ return;
58754
+ this.suspendSignalListening = listen;
58755
+ if (listen)
58756
+ process.on("SIGTSTP", this.suspendSignalListener);
58757
+ else
58758
+ process.off("SIGTSTP", this.suspendSignalListener);
58759
+ }
58368
58760
  queryCellSize() {
58369
58761
  if (!getCapabilities().images) {
58370
58762
  return;
@@ -58382,10 +58774,13 @@ class TuiBase extends Container {
58382
58774
  this.terminal.showCursor();
58383
58775
  this.terminal.stop();
58384
58776
  this.afterTerminalStop(options);
58777
+ this.ownsTerminal = false;
58778
+ this.updateSuspendSignalListener();
58385
58779
  }
58386
58780
  renderNow(force = false) {
58387
58781
  if (force)
58388
58782
  this.resetRenderState();
58783
+ this.contentChanged = true;
58389
58784
  this.renderRequested = false;
58390
58785
  this.cancelRenderTimer();
58391
58786
  this.lastRenderAt = performance2.now();
@@ -58397,12 +58792,17 @@ class TuiBase extends Container {
58397
58792
  this.requestImmediateRender();
58398
58793
  return;
58399
58794
  }
58795
+ this.contentChanged = true;
58796
+ this.requestViewRender();
58797
+ }
58798
+ requestViewRender() {
58400
58799
  if (this.renderRequested)
58401
58800
  return;
58402
58801
  this.renderRequested = true;
58403
58802
  process.nextTick(() => this.scheduleRender());
58404
58803
  }
58405
58804
  requestImmediateRender() {
58805
+ this.contentChanged = true;
58406
58806
  this.cancelRenderTimer();
58407
58807
  this.renderRequested = true;
58408
58808
  if (this.immediateRenderScheduled)
@@ -58703,6 +59103,7 @@ class TuiBase extends Container {
58703
59103
  }
58704
59104
  const viewportStart = Math.max(0, workingHeight - termHeight);
58705
59105
  for (const { overlayLines, row, col, w } of rendered) {
59106
+ hideImagesUnderOverlay(result, { row, col, width: w, height: overlayLines.length }, viewportStart);
58706
59107
  for (let i = 0;i < overlayLines.length; i++) {
58707
59108
  const idx = viewportStart + row + i;
58708
59109
  if (idx >= 0 && idx < result.length) {
@@ -58775,7 +59176,7 @@ class Box {
58775
59176
  paddingY;
58776
59177
  bgFn;
58777
59178
  cache;
58778
- mouseLayout;
59179
+ childLines;
58779
59180
  constructor(paddingX = 1, paddingY = 1, bgFn) {
58780
59181
  this.paddingX = paddingX;
58781
59182
  this.paddingY = paddingY;
@@ -58805,10 +59206,7 @@ class Box {
58805
59206
  }
58806
59207
  invalidateCache() {
58807
59208
  this.cache = undefined;
58808
- }
58809
- matchCache(width, childLines, bgSample) {
58810
- const cache = this.cache;
58811
- return !!cache && cache.width === width && cache.bgSample === bgSample && cache.childLines.length === childLines.length && cache.childLines.every((line, i) => line === childLines[i]);
59209
+ this.childLines = undefined;
58812
59210
  }
58813
59211
  invalidate() {
58814
59212
  this.invalidateCache();
@@ -58822,21 +59220,8 @@ class Box {
58822
59220
  const contentX = event.x - this.paddingX;
58823
59221
  if (contentY < 0 || contentX < 0 || contentX >= contentWidth)
58824
59222
  return;
58825
- const mouseChildren = this.mouseLayout?.width === contentWidth ? this.mouseLayout.children : this.children.map((component) => ({ component, height: component.render(contentWidth).length }));
58826
- let childY = 0;
58827
- for (const { component: child, height: childHeight } of mouseChildren) {
58828
- if (contentY >= childY && contentY < childY + childHeight) {
58829
- return dispatchMouseEvent(child, {
58830
- ...event,
58831
- x: contentX,
58832
- y: contentY - childY,
58833
- width: contentWidth,
58834
- height: childHeight
58835
- });
58836
- }
58837
- childY += childHeight;
58838
- }
58839
- return;
59223
+ const layout = this.childLines?.width === contentWidth ? this.childLines : renderChildLines(this.children, contentWidth, undefined);
59224
+ return dispatchMouseToChildLines(layout, { ...event, x: contentX, y: contentY, width: contentWidth });
58840
59225
  }
58841
59226
  render(width) {
58842
59227
  if (this.children.length === 0) {
@@ -58844,22 +59229,15 @@ class Box {
58844
59229
  }
58845
59230
  const contentWidth = Math.max(1, width - this.paddingX * 2);
58846
59231
  const leftPad = " ".repeat(this.paddingX);
58847
- const childLines = [];
58848
- const mouseChildren = [];
58849
- for (const child of this.children) {
58850
- const lines = child.render(contentWidth);
58851
- mouseChildren.push({ component: child, height: lines.length });
58852
- for (const line of lines) {
58853
- childLines.push(line);
58854
- }
58855
- }
58856
- this.mouseLayout = { width: contentWidth, children: mouseChildren };
59232
+ this.childLines = renderChildLines(this.children, contentWidth, this.childLines);
59233
+ const childLines = this.childLines.lines;
58857
59234
  if (childLines.length === 0) {
58858
59235
  return [];
58859
59236
  }
58860
59237
  const bgSample = this.bgFn ? this.bgFn("test") : undefined;
58861
- if (this.matchCache(width, childLines, bgSample)) {
58862
- return this.cache.lines;
59238
+ const cache = this.cache;
59239
+ if (cache?.childLines === childLines && cache.width === width && cache.bgSample === bgSample) {
59240
+ return cache.lines;
58863
59241
  }
58864
59242
  const result = [];
58865
59243
  for (let i = 0;i < this.paddingY; i++) {
@@ -60101,13 +60479,15 @@ class Editor {
60101
60479
  if (kb.matches(data, "tui.select.confirm")) {
60102
60480
  const selected = this.autocompleteList.getSelectedItem();
60103
60481
  if (selected && this.autocompleteProvider) {
60482
+ const beforeCursor = (this.state.lines[this.state.cursorLine] || "").slice(0, this.state.cursorCol);
60483
+ const submitsCommand = this.autocompletePrefix.startsWith("/") && this.isInSlashCommandNameContext(beforeCursor);
60104
60484
  this.pushUndoSnapshot();
60105
60485
  this.lastAction = null;
60106
60486
  const result = this.autocompleteProvider.applyCompletion(this.state.lines, this.state.cursorLine, this.state.cursorCol, selected, this.autocompletePrefix);
60107
60487
  this.state.lines = result.lines;
60108
60488
  this.state.cursorLine = result.cursorLine;
60109
60489
  this.setCursorCol(result.cursorCol);
60110
- if (this.autocompletePrefix.startsWith("/")) {
60490
+ if (submitsCommand) {
60111
60491
  this.cancelAutocomplete();
60112
60492
  } else {
60113
60493
  this.cancelAutocomplete();
@@ -61045,6 +61425,9 @@ class Editor {
61045
61425
  isInSlashCommandContext(textBeforeCursor) {
61046
61426
  return this.isSlashMenuAllowed() && textBeforeCursor.trimStart().startsWith("/");
61047
61427
  }
61428
+ isInSlashCommandNameContext(textBeforeCursor) {
61429
+ return this.isInSlashCommandContext(textBeforeCursor) && !textBeforeCursor.trimStart().includes(" ");
61430
+ }
61048
61431
  getBestAutocompleteMatchIndex(items, prefix) {
61049
61432
  if (!prefix)
61050
61433
  return -1;
@@ -61085,7 +61468,7 @@ class Editor {
61085
61468
  return;
61086
61469
  const currentLine = this.state.lines[this.state.cursorLine] || "";
61087
61470
  const beforeCursor = currentLine.slice(0, this.state.cursorCol);
61088
- if (this.isInSlashCommandContext(beforeCursor) && !beforeCursor.trimStart().includes(" ")) {
61471
+ if (this.isInSlashCommandNameContext(beforeCursor)) {
61089
61472
  this.handleSlashCommandCompletion();
61090
61473
  } else {
61091
61474
  this.forceFileAutocomplete(true);
@@ -63633,7 +64016,9 @@ class Markdown {
63633
64016
  const rightMargin = " ".repeat(this.paddingX);
63634
64017
  const bgFn = this.defaultTextStyle?.bgColor;
63635
64018
  const lines = [];
63636
- for (const line of this.renderToken(token, contentWidth, nextTokenType)) {
64019
+ const tokenLines = this.renderToken(token, contentWidth, nextTokenType).flatMap((line) => isImageLine(line) ? line.split(`
64020
+ `) : [line]);
64021
+ for (const line of tokenLines) {
63637
64022
  if (isImageLine(line)) {
63638
64023
  lines.push(line);
63639
64024
  continue;
@@ -64536,8 +64921,11 @@ class SettingsList {
64536
64921
  } else if (kb.matches(data, "tui.select.cancel")) {
64537
64922
  this.onCancel();
64538
64923
  } else if (this.searchEnabled && this.searchInput) {
64924
+ const previousQuery = this.searchInput.getValue();
64539
64925
  this.searchInput.handleInput(data);
64540
- this.applyFilter(this.searchInput.getValue());
64926
+ const query = this.searchInput.getValue();
64927
+ if (query !== previousQuery)
64928
+ this.applyFilter(query);
64541
64929
  }
64542
64930
  }
64543
64931
  getDisplayItems() {
@@ -65792,7 +66180,7 @@ function renderCached(context, component, width) {
65792
66180
  }
65793
66181
  let lines = widths.get(safeWidth);
65794
66182
  if (!lines) {
65795
- lines = component.render(safeWidth);
66183
+ lines = context.reusableOutput?.get(component)?.get(safeWidth) ?? component.render(safeWidth);
65796
66184
  widths.set(safeWidth, lines);
65797
66185
  }
65798
66186
  return lines;
@@ -66035,12 +66423,14 @@ function paintBox(box, screen, totalWidth) {
66035
66423
  }
66036
66424
  paintScrollbar(box, screen, totalWidth);
66037
66425
  }
66038
- function renderLayoutFrame(root, width, height, requestRender) {
66426
+ function renderLayoutFrame(root, width, height, requestRender, reusableOutput) {
66039
66427
  const safeWidth = Math.max(1, Math.floor(width));
66040
66428
  const safeHeight = Math.max(1, Math.floor(height));
66429
+ const renderCache = new Map;
66041
66430
  const context = {
66042
66431
  viewport: { width: safeWidth, height: safeHeight },
66043
- renderCache: new Map,
66432
+ renderCache,
66433
+ reusableOutput,
66044
66434
  requestRender,
66045
66435
  primaryScrollView: undefined
66046
66436
  };
@@ -66057,7 +66447,8 @@ function renderLayoutFrame(root, width, height, requestRender) {
66057
66447
  width: safeWidth,
66058
66448
  height: safeHeight,
66059
66449
  lines,
66060
- ...context.primaryScrollView === undefined ? {} : { primaryScrollView: context.primaryScrollView }
66450
+ ...context.primaryScrollView === undefined ? {} : { primaryScrollView: context.primaryScrollView },
66451
+ renderCache
66061
66452
  };
66062
66453
  }
66063
66454
  function containsPoint(rect, x, y) {
@@ -66432,15 +66823,15 @@ class TuiAltScreen extends TuiBase {
66432
66823
  }
66433
66824
  scrollBy(lines) {
66434
66825
  this.getPrimaryScrollView().scrollBy(lines);
66435
- this.requestRender();
66826
+ this.requestViewRender();
66436
66827
  }
66437
66828
  scrollToTop() {
66438
66829
  this.getPrimaryScrollView().scrollToStart();
66439
- this.requestRender();
66830
+ this.requestViewRender();
66440
66831
  }
66441
66832
  scrollToBottom() {
66442
66833
  this.getPrimaryScrollView().scrollToEnd();
66443
- this.requestRender();
66834
+ this.requestViewRender();
66444
66835
  }
66445
66836
  scrollToPrompt(direction) {
66446
66837
  if (!this.currentLayout)
@@ -66453,7 +66844,7 @@ class TuiAltScreen extends TuiBase {
66453
66844
  if (!OSC133_PROMPT_START.test(lines[row] ?? ""))
66454
66845
  continue;
66455
66846
  scrollView.scrollTo(row);
66456
- this.requestRender();
66847
+ this.requestViewRender();
66457
66848
  return;
66458
66849
  }
66459
66850
  }
@@ -66923,7 +67314,7 @@ class TuiAltScreen extends TuiBase {
66923
67314
  if (remaining !== 0 && !seen.has(primary))
66924
67315
  primary.scrollBy(remaining);
66925
67316
  this.updateScrollbarHover(event.x, event.y);
66926
- this.requestRender();
67317
+ this.requestViewRender();
66927
67318
  }
66928
67319
  parseSgrMouseEvent(data) {
66929
67320
  const match = /^\x1b\[<(\d+);(\d+);(\d+)([Mm])$/.exec(data);
@@ -67168,7 +67559,7 @@ class TuiAltScreen extends TuiBase {
67168
67559
  const point = this.getScrollSelectionPoint(scrollView, pointer.x, pointer.y);
67169
67560
  if (point)
67170
67561
  this.updateSelectionFocus(point);
67171
- this.requestRender();
67562
+ this.requestViewRender();
67172
67563
  }
67173
67564
  stopSelectionAutoScroll() {
67174
67565
  if (this.selectionAutoScrollTimer) {
@@ -67512,9 +67903,12 @@ class TuiAltScreen extends TuiBase {
67512
67903
  const width = Math.max(1, this.terminal.columns);
67513
67904
  const height = Math.max(1, this.terminal.rows);
67514
67905
  const root = this.layoutRoot ?? this.implicitScrollView;
67515
- let nextLayout = renderLayoutFrame(root, width, height, () => this.requestRender());
67906
+ const requestViewRender = () => this.requestViewRender();
67907
+ const reusableOutput = this.contentChanged ? undefined : this.currentLayout?.renderCache;
67908
+ this.contentChanged = false;
67909
+ let nextLayout = renderLayoutFrame(root, width, height, requestViewRender, reusableOutput);
67516
67910
  if (this.refreshSearch(nextLayout)) {
67517
- nextLayout = renderLayoutFrame(root, width, height, () => this.requestRender());
67911
+ nextLayout = renderLayoutFrame(root, width, height, requestViewRender, nextLayout.renderCache);
67518
67912
  }
67519
67913
  let screen = this.resolveFakeCursors(nextLayout.lines.map((line) => line.replace(OSC133_ZONE_PREFIX2, "")));
67520
67914
  screen = this.applySearchHighlights(screen, nextLayout);
@@ -67550,8 +67944,11 @@ class TuiAltScreen extends TuiBase {
67550
67944
  let buffer = BEGIN_SYNCHRONIZED_OUTPUT;
67551
67945
  if (fullRedraw) {
67552
67946
  this.fullRedrawCount += 1;
67553
- const clearImages = this.imageProtocol === "kitty" && hadUploadedKittyImages ? deleteAllKittyPlacements() : this.deleteKittyImages();
67554
- buffer += `${clearImages}\x1B[2J`;
67947
+ if (this.imageProtocol === "kitty" && hadUploadedKittyImages) {
67948
+ buffer += deleteAllKittyPlacements();
67949
+ } else {
67950
+ buffer += `${this.deleteKittyImages()}\x1B[2J`;
67951
+ }
67555
67952
  } else if (imagesNeedRedraw) {
67556
67953
  if (this.imageProtocol === "iterm2")
67557
67954
  buffer += "\x1B[2J";
@@ -68261,7 +68658,7 @@ function loadAllHighlightLanguages() {
68261
68658
  if (!allLanguagesPromise) {
68262
68659
  allLanguagesPromise = new Promise((resolve) => {
68263
68660
  setImmediate(() => {
68264
- import("./index-xhp7yp3t.js").then((m)=>__toESM(m.default,1)).then(() => resolve(), () => {
68661
+ import("./index-b3wy4jzs.js").then((m)=>__toESM(m.default,1)).then(() => resolve(), () => {
68265
68662
  resolve();
68266
68663
  });
68267
68664
  });
@@ -69543,6 +69940,7 @@ var cachedHighlightThemeFor;
69543
69940
  var cachedCliHighlightTheme;
69544
69941
  function buildCliHighlightTheme(t) {
69545
69942
  return {
69943
+ default: (s) => t.fg("text", s),
69546
69944
  keyword: (s) => t.fg("syntaxKeyword", s),
69547
69945
  built_in: (s) => t.fg("syntaxType", s),
69548
69946
  literal: (s) => t.fg("syntaxNumber", s),
@@ -70942,11 +71340,11 @@ async function executeBashWithOperations(command, cwd, operations, options) {
70942
71340
  }
70943
71341
 
70944
71342
  // node_modules/@earendil-works/pi-coding-agent/dist/core/bug-report.js
70945
- init_dist3();
71343
+ init_dist2();
70946
71344
  import * as os3 from "node:os";
70947
71345
 
70948
71346
  // node_modules/@earendil-works/pi-coding-agent/dist/utils/pi-user-agent.js
70949
- init_dist3();
71347
+ init_dist2();
70950
71348
  function getPiUserAgent(version) {
70951
71349
  return formatUserAgent({ userAgent: "detailed", version });
70952
71350
  }
@@ -71012,7 +71410,7 @@ function writeZipArchive(filePath, entries) {
71012
71410
  }
71013
71411
 
71014
71412
  // node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.js
71015
- init_dist3();
71413
+ init_dist2();
71016
71414
  init_compat();
71017
71415
 
71018
71416
  // node_modules/@earendil-works/pi-coding-agent/dist/core/messages.js
@@ -71126,7 +71524,7 @@ function convertToLlm(messages) {
71126
71524
  }
71127
71525
 
71128
71526
  // node_modules/@earendil-works/pi-coding-agent/dist/core/session-manager.js
71129
- init_dist3();
71527
+ init_dist2();
71130
71528
  import { randomUUID as randomUUID2 } from "crypto";
71131
71529
  import { appendFileSync as appendFileSync3, closeSync, createReadStream, existsSync as existsSync4, mkdirSync as mkdirSync3, openSync, readdirSync as readdirSync3, readSync, statSync as statSync4, writeFileSync as writeFileSync3 } from "fs";
71132
71530
  import { readdir, stat } from "fs/promises";
@@ -71550,43 +71948,47 @@ async function buildSessionInfo(filePath, signal, fileStats) {
71550
71948
  const allMessages = [];
71551
71949
  let name;
71552
71950
  let lastActivityTime;
71553
- const rl = createInterface({
71554
- input: createReadStream(filePath, { encoding: "utf8", signal }),
71555
- crlfDelay: Infinity
71556
- });
71557
- for await (const line of rl) {
71558
- const entry = parseSessionEntryLine(line);
71559
- if (!entry)
71560
- continue;
71561
- if (!header) {
71562
- if (entry.type !== "session")
71563
- return null;
71564
- header = entry;
71565
- continue;
71566
- }
71567
- if (entry.type === "session_info") {
71568
- name = entry.name?.trim() || undefined;
71569
- }
71570
- if (entry.type !== "message")
71571
- continue;
71572
- messageCount++;
71573
- const activityTime = getMessageActivityTime(entry);
71574
- if (typeof activityTime === "number") {
71575
- lastActivityTime = Math.max(lastActivityTime ?? 0, activityTime);
71576
- }
71577
- const message = entry.message;
71578
- if (!isMessageWithContent(message))
71579
- continue;
71580
- if (message.role !== "user" && message.role !== "assistant")
71581
- continue;
71582
- const textContent = extractTextContent(message);
71583
- if (!textContent)
71584
- continue;
71585
- allMessages.push(textContent);
71586
- if (!firstMessage && message.role === "user") {
71587
- firstMessage = textContent;
71951
+ const stream = createReadStream(filePath, { encoding: "utf8" });
71952
+ try {
71953
+ const rl = createInterface({ input: stream, crlfDelay: Infinity });
71954
+ for await (const line of rl) {
71955
+ signal?.throwIfAborted();
71956
+ const entry = parseSessionEntryLine(line);
71957
+ if (!entry)
71958
+ continue;
71959
+ if (!header) {
71960
+ if (entry.type !== "session")
71961
+ return null;
71962
+ header = entry;
71963
+ continue;
71964
+ }
71965
+ if (entry.type === "session_info") {
71966
+ name = entry.name?.trim() || undefined;
71967
+ }
71968
+ if (entry.type !== "message")
71969
+ continue;
71970
+ messageCount++;
71971
+ const activityTime = getMessageActivityTime(entry);
71972
+ if (typeof activityTime === "number") {
71973
+ lastActivityTime = Math.max(lastActivityTime ?? 0, activityTime);
71974
+ }
71975
+ const message = entry.message;
71976
+ if (!isMessageWithContent(message))
71977
+ continue;
71978
+ if (message.role !== "user" && message.role !== "assistant")
71979
+ continue;
71980
+ const textContent = extractTextContent(message);
71981
+ if (!textContent)
71982
+ continue;
71983
+ allMessages.push(textContent);
71984
+ if (!firstMessage && message.role === "user") {
71985
+ firstMessage = textContent;
71986
+ }
71588
71987
  }
71988
+ } finally {
71989
+ stream.destroy();
71589
71990
  }
71991
+ signal?.throwIfAborted();
71590
71992
  if (!header)
71591
71993
  return null;
71592
71994
  const cwd = typeof header.cwd === "string" ? header.cwd : "";
@@ -72442,7 +72844,7 @@ function getUsageCostBreakdown(entries) {
72442
72844
  }
72443
72845
 
72444
72846
  // node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/utils.js
72445
- init_dist3();
72847
+ init_dist2();
72446
72848
  function createFileOps() {
72447
72849
  return {
72448
72850
  read: new Set,
@@ -73445,7 +73847,7 @@ ${hint}
73445
73847
  }
73446
73848
 
73447
73849
  // node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/branch-summarization.js
73448
- init_dist3();
73850
+ init_dist2();
73449
73851
  function collectEntriesForBranchSummary(session, oldLeafId, targetId) {
73450
73852
  if (!oldLeafId) {
73451
73853
  return { entries: [], commonAncestorId: null };
@@ -73984,39 +74386,69 @@ function applySgrCode(params, style) {
73984
74386
  i++;
73985
74387
  }
73986
74388
  }
73987
- var ANSI_REGEX = /\x1b\[([\d;]*)m/g;
74389
+ var ANSI_REGEX = /\x1b\[([\d;]*)m|\x1b\[[0-?]*[ -/]*[@-~]|\x1b\]([^\x07\x1b]*)(?:\x07|\x1b\\)|\x1b_[^\x07\x1b]*(?:\x07|\x1b\\)/g;
74390
+ var OSC8_REGEX = /^8;[^;]*;(.*)$/s;
74391
+ var SAFE_LINK_REGEX = /^(?:https?:|mailto:)/i;
74392
+ function stripAnsiEscapes(text) {
74393
+ return text.replace(ANSI_REGEX, "").replace(/\x1b/g, "");
74394
+ }
73988
74395
  function ansiToHtml(text) {
73989
74396
  const style = createEmptyStyle();
73990
74397
  let result = "";
73991
74398
  let lastIndex = 0;
73992
74399
  let inSpan = false;
73993
- ANSI_REGEX.lastIndex = 0;
73994
- let match = ANSI_REGEX.exec(text);
73995
- while (match !== null) {
73996
- const beforeText = text.slice(lastIndex, match.index);
73997
- if (beforeText) {
73998
- result += escapeHtml(beforeText);
73999
- }
74000
- const paramStr = match[1];
74001
- const params = paramStr ? paramStr.split(";").map((p) => parseInt(p, 10) || 0) : [0];
74400
+ let inLink = false;
74401
+ const closeSpan = () => {
74002
74402
  if (inSpan) {
74003
74403
  result += "</span>";
74004
74404
  inSpan = false;
74005
74405
  }
74006
- applySgrCode(params, style);
74406
+ };
74407
+ const openSpan = () => {
74007
74408
  if (hasStyle(style)) {
74008
74409
  result += `<span style="${styleToInlineCSS(style)}">`;
74009
74410
  inSpan = true;
74010
74411
  }
74412
+ };
74413
+ ANSI_REGEX.lastIndex = 0;
74414
+ let match = ANSI_REGEX.exec(text);
74415
+ while (match !== null) {
74416
+ const beforeText = text.slice(lastIndex, match.index);
74417
+ if (beforeText) {
74418
+ result += escapeHtml(beforeText.replace(/\x1b/g, ""));
74419
+ }
74420
+ if (match[1] !== undefined) {
74421
+ const paramStr = match[1];
74422
+ const params = paramStr ? paramStr.split(";").map((p) => parseInt(p, 10) || 0) : [0];
74423
+ closeSpan();
74424
+ applySgrCode(params, style);
74425
+ openSpan();
74426
+ } else if (match[2] !== undefined) {
74427
+ const hyperlink = OSC8_REGEX.exec(match[2]);
74428
+ if (hyperlink) {
74429
+ const url = hyperlink[1].trim().replace(/[\x00-\x1f\x7f]/g, "");
74430
+ closeSpan();
74431
+ if (inLink) {
74432
+ result += "</a>";
74433
+ inLink = false;
74434
+ }
74435
+ if (url && SAFE_LINK_REGEX.test(url)) {
74436
+ result += `<a href="${escapeHtml(url)}">`;
74437
+ inLink = true;
74438
+ }
74439
+ openSpan();
74440
+ }
74441
+ }
74011
74442
  lastIndex = match.index + match[0].length;
74012
74443
  match = ANSI_REGEX.exec(text);
74013
74444
  }
74014
74445
  const remainingText = text.slice(lastIndex);
74015
74446
  if (remainingText) {
74016
- result += escapeHtml(remainingText);
74447
+ result += escapeHtml(remainingText.replace(/\x1b/g, ""));
74017
74448
  }
74018
- if (inSpan) {
74019
- result += "</span>";
74449
+ closeSpan();
74450
+ if (inLink) {
74451
+ result += "</a>";
74020
74452
  }
74021
74453
  return result;
74022
74454
  }
@@ -74025,9 +74457,8 @@ function ansiLinesToHtml(lines) {
74025
74457
  }
74026
74458
 
74027
74459
  // node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/tool-renderer.js
74028
- var ANSI_ESCAPE_REGEX = /\x1b\[[\d;]*m/g;
74029
74460
  function isBlankRenderedLine(line) {
74030
- return line.replace(ANSI_ESCAPE_REGEX, "").trim().length === 0;
74461
+ return stripAnsiEscapes(line).trim().length === 0;
74031
74462
  }
74032
74463
  function trimRenderedResultLines(lines) {
74033
74464
  let start = 0;
@@ -74267,6 +74698,11 @@ function createMcpToolName(server, tool, isTaken = () => false) {
74267
74698
  function mcpNamespace(server) {
74268
74699
  return `mcp__${server.replace(/-/g, "_")}`;
74269
74700
  }
74701
+ function mcpServerSummary(description, instructions) {
74702
+ const text = description?.trim() || instructions?.trim() || "";
74703
+ return (text.split(`
74704
+ `, 1)[0] ?? "").trim();
74705
+ }
74270
74706
  // node_modules/@earendil-works/pi-mcp/dist/output-limit.js
74271
74707
  var MCP_OUTPUT_MAX_BYTES = 20 * 1024;
74272
74708
  async function limitMcpContent(content, saveOutput) {
@@ -74380,6 +74816,7 @@ function createEventBus() {
74380
74816
  // node_modules/@earendil-works/pi-coding-agent/dist/core/exec.js
74381
74817
  import { constants as bufferConstants } from "node:buffer";
74382
74818
  import { spawn as spawn3 } from "node:child_process";
74819
+ import { constants as osConstants } from "node:os";
74383
74820
  import { StringDecoder as StringDecoder2 } from "node:string_decoder";
74384
74821
  var DEFAULT_EXEC_MAX_BUFFER = Math.min(256 * 1024 * 1024, bufferConstants.MAX_STRING_LENGTH);
74385
74822
  var FORCE_KILL_DELAY_MS = 5000;
@@ -74465,7 +74902,7 @@ async function execCommand(command, args, cwd, options) {
74465
74902
  stdout += stdoutDecoder.end();
74466
74903
  stderr += stderrDecoder.end();
74467
74904
  }
74468
- const exitCode = code ?? 0;
74905
+ const exitCode = code ?? (proc.signalCode ? 128 + (osConstants.signals[proc.signalCode] ?? 0) : 1);
74469
74906
  return {
74470
74907
  stdout,
74471
74908
  stderr,
@@ -74721,7 +75158,7 @@ function getCreateJiti() {
74721
75158
  }
74722
75159
  var virtualModulesPromise;
74723
75160
  function getVirtualModules() {
74724
- virtualModulesPromise ??= import("./virtual-modules-mreda4fp.js").then((module) => module.VIRTUAL_MODULES);
75161
+ virtualModulesPromise ??= import("./virtual-modules-nzxegw0a.js").then((module) => module.VIRTUAL_MODULES);
74725
75162
  return virtualModulesPromise;
74726
75163
  }
74727
75164
  var _aliases = null;
@@ -74844,6 +75281,7 @@ function createExtensionRuntime() {
74844
75281
  eventBusUnsubscribers.add(trackedUnsubscribe);
74845
75282
  return trackedUnsubscribe;
74846
75283
  },
75284
+ reportError: () => {},
74847
75285
  registerProvider: (name, config, extensionPath = "<unknown>") => {
74848
75286
  runtime.pendingProviderRegistrations.push({ name, config, extensionPath });
74849
75287
  },
@@ -75093,7 +75531,19 @@ function createExtensionAPI(extension, runtime, cwd, eventBus) {
75093
75531
  },
75094
75532
  on(channel, handler) {
75095
75533
  assertActive();
75096
- const unsubscribe = runtime.trackEventBusSubscription(eventBus.on(channel, handler));
75534
+ const reportingHandler = async (data) => {
75535
+ try {
75536
+ await handler(data);
75537
+ } catch (error) {
75538
+ runtime.reportError({
75539
+ extensionPath: extension.path,
75540
+ event: `events:${channel}`,
75541
+ error: error instanceof Error ? error.message : String(error),
75542
+ stack: error instanceof Error ? error.stack : undefined
75543
+ });
75544
+ }
75545
+ };
75546
+ const unsubscribe = runtime.trackEventBusSubscription(eventBus.on(channel, reportingHandler));
75097
75547
  if (state === "loading")
75098
75548
  loadingUnsubscribers.push(unsubscribe);
75099
75549
  return unsubscribe;
@@ -75319,10 +75769,10 @@ async function discoverAndLoadExtensions(configuredPaths, cwd, agentDir = getAge
75319
75769
  return loadExtensions(allPaths, resolvedCwd, eventBus);
75320
75770
  }
75321
75771
  // node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/runner.js
75322
- init_dist3();
75772
+ init_dist2();
75323
75773
 
75324
75774
  // node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js
75325
- init_dist3();
75775
+ init_dist2();
75326
75776
 
75327
75777
  // node_modules/@earendil-works/pi-coding-agent/dist/core/skills.js
75328
75778
  var import_ignore = __toESM(require_ignore(), 1);
@@ -75990,6 +76440,10 @@ class ExtensionRunner {
75990
76440
  constructor(extensions, runtime, cwd, sessionManager, modelRegistry) {
75991
76441
  this.extensions = extensions;
75992
76442
  this.runtime = runtime;
76443
+ this.runtime.reportError = (error) => {
76444
+ if (!this.staleMessage)
76445
+ this.emitError(error);
76446
+ };
75993
76447
  this.uiContext = noOpUIContext;
75994
76448
  this.cwd = cwd;
75995
76449
  this.sessionManager = sessionManager;
@@ -77028,7 +77482,7 @@ function wrapRegisteredTools(registeredTools, runner) {
77028
77482
  return registeredTools.map((tool) => wrapRegisteredTool(tool, runner));
77029
77483
  }
77030
77484
  // node_modules/@earendil-works/pi-coding-agent/dist/core/provider-composer.js
77031
- init_dist3();
77485
+ init_dist2();
77032
77486
  init_compat();
77033
77487
  init_model_operations();
77034
77488
 
@@ -78202,7 +78656,7 @@ function exportSessionToJsonl(sessionManager, outputPath, createTrailingEntries)
78202
78656
  // node_modules/@earendil-works/pi-coding-agent/dist/core/tools/bash.js
78203
78657
  import { constants as constants3 } from "node:fs";
78204
78658
  import { access as fsAccess } from "node:fs/promises";
78205
- import { constants as osConstants } from "node:os";
78659
+ import { constants as osConstants2 } from "node:os";
78206
78660
  import { spawn as spawn4 } from "child_process";
78207
78661
 
78208
78662
  // node_modules/@earendil-works/pi-coding-agent/dist/core/tools/output-accumulator.js
@@ -78260,7 +78714,8 @@ class OutputAccumulator {
78260
78714
  }
78261
78715
  }
78262
78716
  snapshot(options = {}) {
78263
- const tailTruncation = truncateTail(this.getSnapshotText(), {
78717
+ const snapshotText = this.getSnapshotText() || this.tailText;
78718
+ const tailTruncation = truncateTail(snapshotText, {
78264
78719
  maxLines: this.maxLines,
78265
78720
  maxBytes: this.maxBytes
78266
78721
  });
@@ -78765,7 +79220,7 @@ Cannot execute ${shellName} commands.`);
78765
79220
  throw new Error("aborted");
78766
79221
  }
78767
79222
  const signalCode = child.signalCode;
78768
- const resolvedExitCode = exitCode ?? (signalCode ? 128 + (osConstants.signals[signalCode] ?? 0) : 1);
79223
+ const resolvedExitCode = exitCode ?? (signalCode ? 128 + (osConstants2.signals[signalCode] ?? 0) : 1);
78769
79224
  if (timedOut) {
78770
79225
  throw new ShellTimeoutError(timeout, exitedBeforeDeadlineAfterMs !== undefined ? { exitCode: resolvedExitCode, afterSeconds: Math.round(exitedBeforeDeadlineAfterMs / 100) / 10 } : undefined);
78771
79226
  }
@@ -80238,6 +80693,61 @@ function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
80238
80693
  return acc;
80239
80694
  }
80240
80695
 
80696
+ // node_modules/@isaacs/nonrecursive-glob-match/dist/esm/numeric-range.js
80697
+ var digit = (a, b) => a === b ? { t: "lit", ch: String(a) } : { t: "class", re: new RegExp(`^[${a}-${b}]$`) };
80698
+ var prefix = (d, alts) => alts.map((s) => [digit(d, d), ...s]);
80699
+ var fixed = (a, b) => {
80700
+ if (!a)
80701
+ return [[]];
80702
+ let lo = +a[0];
80703
+ let hi = +b[0];
80704
+ const ra = a.slice(1);
80705
+ const rb = b.slice(1);
80706
+ if (lo === hi)
80707
+ return prefix(lo, fixed(ra, rb));
80708
+ const zeros = "0".repeat(ra.length);
80709
+ const nines = "9".repeat(ra.length);
80710
+ const out = [];
80711
+ if (ra !== zeros)
80712
+ out.push(...prefix(lo++, fixed(ra, nines)));
80713
+ const last = rb === nines ? [] : prefix(hi--, fixed(zeros, rb));
80714
+ if (lo <= hi) {
80715
+ out.push([digit(lo, hi), ...Array.from(ra, () => digit(0, 9))]);
80716
+ }
80717
+ out.push(...last);
80718
+ return out;
80719
+ };
80720
+ var nonneg = (a, b, width) => {
80721
+ if (width) {
80722
+ return fixed(String(a).padStart(width, "0"), String(b).padStart(width, "0"));
80723
+ }
80724
+ const out = [];
80725
+ for (let len = String(a).length;len <= String(b).length; len++) {
80726
+ const lo = Math.max(a, len === 1 ? 0 : 10 ** (len - 1));
80727
+ const hi = Math.min(b, 10 ** len - 1);
80728
+ out.push(...fixed(String(lo), String(hi)));
80729
+ }
80730
+ return out;
80731
+ };
80732
+ var numericRange = (loStr, hiStr) => {
80733
+ let lo = Number(loStr);
80734
+ let hi = Number(hiStr);
80735
+ if (!Number.isSafeInteger(lo) || !Number.isSafeInteger(hi))
80736
+ return;
80737
+ if (lo > hi)
80738
+ [lo, hi] = [hi, lo];
80739
+ const padded = /^-?0\d/.test(loStr) || /^-?0\d/.test(hiStr);
80740
+ const width = padded ? Math.max(loStr.length, hiStr.length) : 0;
80741
+ const out = [];
80742
+ if (lo < 0) {
80743
+ const neg = nonneg(Math.max(-hi, 1), -lo, width && width - 1);
80744
+ out.push(...neg.map((s) => [{ t: "lit", ch: "-" }, ...s]));
80745
+ }
80746
+ if (hi >= 0)
80747
+ out.push(...nonneg(Math.max(lo, 0), hi, width));
80748
+ return out;
80749
+ };
80750
+
80241
80751
  // node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.js
80242
80752
  var posixClasses = {
80243
80753
  "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}"],
@@ -80375,10 +80885,24 @@ var litMatch = (l, c) => {
80375
80885
  ascii[code] ||= l.re.test(c) ? 1 : 2;
80376
80886
  return ascii[code] === 1;
80377
80887
  };
80378
- var tokenize2 = (p, nocase, noext, form) => {
80888
+ var tokenize2 = (p, nocase, noext, form, mark) => {
80379
80889
  const toks = [];
80380
80890
  for (let i = 0;i < p.length; ) {
80381
80891
  const c = String.fromCodePoint(p.codePointAt(i));
80892
+ if (mark) {
80893
+ const m = c === "\\" && p.startsWith(mark, i + 1) ? 1 : 0;
80894
+ if (m || c === mark) {
80895
+ const start = i + m + mark.length;
80896
+ const end = p.indexOf(mark, start);
80897
+ const r = /^(-?\d+)\.\.(-?\d+)$/.exec(p.slice(start, end));
80898
+ const alts = end !== -1 && r && numericRange(r[1], r[2]);
80899
+ if (alts) {
80900
+ toks.push({ t: "ext", type: "@", alts });
80901
+ i = end + mark.length;
80902
+ continue;
80903
+ }
80904
+ }
80905
+ }
80382
80906
  if (c === "\\") {
80383
80907
  const e = p.codePointAt(i + 1);
80384
80908
  const ch = e === undefined ? c : String.fromCodePoint(e);
@@ -80849,7 +81373,7 @@ class Matcher {
80849
81373
  const { nocase = false, noext = false, normalize: n } = options;
80850
81374
  this.#form = n === true ? "NFC" : n || undefined;
80851
81375
  const literal = /^[?*+@]\(\)$/.test(pattern);
80852
- const toks = tokenize2(pattern, nocase, noext || literal, this.#form);
81376
+ const toks = tokenize2(pattern, nocase, noext || literal, this.#form, options.rangeMark);
80853
81377
  let [items] = build(toks, pair(toks), 0, toks.length, true);
80854
81378
  if (this.#form)
80855
81379
  items = normalize(items, this.#form);
@@ -82416,7 +82940,7 @@ function relativizeFindResultPath(resultPath, searchPath, pathModule = path8) {
82416
82940
  }
82417
82941
  var findSchema = _Object_({
82418
82942
  pattern: String2({
82419
- description: "Glob pattern to match files, e.g. '*.ts', '**/*.json', or 'src/**/*.spec.ts'"
82943
+ description: "Glob pattern relative to the search directory, e.g. 'src/**/*.ts'. Without '/', e.g. '*.ts', it matches file names at any depth"
82420
82944
  }),
82421
82945
  path: Optional(String2({ description: "Directory to search in (default: current directory)" })),
82422
82946
  limit: Optional(Number2({ description: "Maximum number of results (default: 1000)" }))
@@ -82539,14 +83063,14 @@ function createFindToolDefinition(cwd, options) {
82539
83063
  if (!insideGitRepo)
82540
83064
  args.push("--no-require-git");
82541
83065
  let effectivePattern = process.platform === "win32" ? pattern.replaceAll("\\", "/") : pattern;
83066
+ effectivePattern = effectivePattern.replace(/^(?:\.\/)+/, "");
82542
83067
  const isPathPattern = effectivePattern.includes("/");
82543
- if (isPathPattern && !effectivePattern.startsWith("/") && !effectivePattern.startsWith("**/") && effectivePattern !== "**") {
82544
- effectivePattern = `**/${effectivePattern}`;
82545
- }
83068
+ const ignoreCase = effectivePattern === effectivePattern.toLowerCase();
83069
+ const isRelativePathPattern = isPathPattern && !path8.isAbsolute(effectivePattern);
82546
83070
  const windowsPathMatcher = process.platform === "win32" && isPathPattern ? new Minimatch(effectivePattern.replace(/\/\*\*$/, "/**/*"), {
82547
83071
  dot: true,
82548
83072
  noext: true,
82549
- nocase: effectivePattern === effectivePattern.toLowerCase()
83073
+ nocase: ignoreCase
82550
83074
  }) : undefined;
82551
83075
  if (windowsPathMatcher) {
82552
83076
  args.push("--", "", searchPath);
@@ -82554,6 +83078,12 @@ function createFindToolDefinition(cwd, options) {
82554
83078
  args.push("--glob", "--max-results", String(effectiveLimit + 1));
82555
83079
  if (isPathPattern)
82556
83080
  args.push("--full-path");
83081
+ if (isRelativePathPattern) {
83082
+ const escapedRoot = searchPath.replace(/\/+$/, "").replace(/[\\*?[\]{}]/g, "\\$&");
83083
+ effectivePattern = `${escapedRoot}/${effectivePattern}`;
83084
+ if (ignoreCase)
83085
+ args.push("--ignore-case");
83086
+ }
82557
83087
  args.push("--", effectivePattern, searchPath);
82558
83088
  }
82559
83089
  if (signal?.aborted)
@@ -82580,7 +83110,8 @@ function createFindToolDefinition(cwd, options) {
82580
83110
  const line = rawLine.replace(/\r$/, "").trim();
82581
83111
  if (!line)
82582
83112
  return;
82583
- if (windowsPathMatcher && !windowsPathMatcher.match(line))
83113
+ const result = relativizeFindResultPath(line, searchPath);
83114
+ if (windowsPathMatcher && !windowsPathMatcher.match(isRelativePathPattern ? result : line))
82584
83115
  return;
82585
83116
  if (resultCount === effectiveLimit) {
82586
83117
  resultLimitReached = true;
@@ -82588,7 +83119,6 @@ function createFindToolDefinition(cwd, options) {
82588
83119
  stopChild?.();
82589
83120
  return;
82590
83121
  }
82591
- const result = relativizeFindResultPath(line, searchPath);
82592
83122
  resultCount++;
82593
83123
  if (outputBytes - 1 <= DEFAULT_MAX_BYTES2)
82594
83124
  storedResults.push(result);
@@ -82732,7 +83262,7 @@ var grepSchema = _Object_({
82732
83262
  pattern: String2({ description: "Search pattern (regex or literal string)" }),
82733
83263
  path: Optional(String2({ description: "Directory or file to search (default: current directory)" })),
82734
83264
  glob: Optional(String2({
82735
- description: "Filter files by glob pattern, relative to path, e.g. '*.ts', 'src/**/*.ts' or '**/*.spec.ts'. A pattern without '/' matches file names at any depth"
83265
+ description: "Filter files by glob pattern relative to path, e.g. 'src/**/*.ts'. Without '/', e.g. '*.ts', it matches file names at any depth"
82736
83266
  })),
82737
83267
  ignoreCase: Optional(Boolean2({ description: "Case-insensitive search (default: false)" })),
82738
83268
  literal: Optional(Boolean2({ description: "Treat pattern as literal string instead of regex (default: false)" })),
@@ -83340,8 +83870,11 @@ function formatCompactReadCall(classification, args, theme) {
83340
83870
  return theme.fg("toolTitle", theme.bold(`read ${classification.kind}`)) + " " + theme.fg("accent", classification.label) + styledReadLineRange(args, theme) + expandHint;
83341
83871
  }
83342
83872
  function formatReadResult(args, result, options, theme, showImages, _cwd, isError) {
83873
+ const unsupportedBy = result.details?.imageUnsupportedByModel;
83874
+ const imageWarning = unsupportedBy ? `
83875
+ ${theme.fg("warning", `[${unsupportedBy} does not support images; it saw a placeholder instead]`)}` : "";
83343
83876
  if (!options.expanded && !isError) {
83344
- return "";
83877
+ return imageWarning;
83345
83878
  }
83346
83879
  const rawPath = str2(args?.file_path ?? args?.path);
83347
83880
  const output = getTextOutput(result, showImages);
@@ -83372,7 +83905,7 @@ ${theme.fg("warning", `[Truncated: showing ${truncation.outputLines} of ${trunca
83372
83905
  ${theme.fg("warning", `[Truncated: ${truncation.outputLines} lines shown (${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES2)} limit)]`)}`;
83373
83906
  }
83374
83907
  }
83375
- return text;
83908
+ return text + imageWarning;
83376
83909
  }
83377
83910
  var readRenderers = {
83378
83911
  renderCall(rawArgs, theme, context) {
@@ -83409,12 +83942,12 @@ var defaultReadOperations = {
83409
83942
  access: (path) => fsAccess3(path, constants7.R_OK),
83410
83943
  detectImageMimeType: detectSupportedImageMimeTypeFromFile
83411
83944
  };
83412
- async function* readLocalFileChunks(path, { signal }) {
83945
+ async function* readLocalFileChunks(path) {
83413
83946
  const handle = await fsOpen(path, "r");
83414
83947
  try {
83415
83948
  const stats = await handle.stat();
83416
83949
  const end = stats.isFile() && stats.size > 0 ? stats.size - 1 : undefined;
83417
- yield* handle.createReadStream({ end, signal, autoClose: false });
83950
+ yield* handle.createReadStream({ end, autoClose: false });
83418
83951
  } finally {
83419
83952
  await handle.close();
83420
83953
  }
@@ -83424,12 +83957,6 @@ function toReadOutput(content) {
83424
83957
  const image = content.find((block) => block.type === "image");
83425
83958
  return image ? { type: "image", data: image.data, mimeType: image.mimeType, note: text } : text;
83426
83959
  }
83427
- function getNonVisionImageNote(model) {
83428
- if (!model || model.input.includes("image")) {
83429
- return;
83430
- }
83431
- return "[Current model does not support images. The image will be omitted from this request.]";
83432
- }
83433
83960
  function isStreamableRange(offset, limit) {
83434
83961
  return (offset === undefined || Number.isInteger(offset)) && (limit === undefined || Number.isInteger(limit) && limit >= 0);
83435
83962
  }
@@ -83560,7 +84087,6 @@ function createReadToolDefinition(cwd, options) {
83560
84087
  const mimeType = ops.detectImageMimeType ? await ops.detectImageMimeType(absolutePath) : undefined;
83561
84088
  let content;
83562
84089
  let details;
83563
- const nonVisionImageNote = getNonVisionImageNote(ctx?.model);
83564
84090
  if (mimeType) {
83565
84091
  const buffer = await ops.readFile(absolutePath);
83566
84092
  const processed = await processImage(buffer, mimeType, {
@@ -83568,11 +84094,8 @@ function createReadToolDefinition(cwd, options) {
83568
84094
  resizeOptions: ctx?.model?.inputLimits?.images?.resize ?? fallbackResizeOptions
83569
84095
  });
83570
84096
  if (!processed.ok) {
83571
- let textNote = `Read image file [${mimeType}]
84097
+ const textNote = `Read image file [${mimeType}]
83572
84098
  ${processed.message}`;
83573
- if (nonVisionImageNote)
83574
- textNote += `
83575
- ${nonVisionImageNote}`;
83576
84099
  content = [{ type: "text", text: textNote }];
83577
84100
  } else {
83578
84101
  let textNote = `Read image file [${processed.mimeType}]`;
@@ -83580,13 +84103,13 @@ ${nonVisionImageNote}`;
83580
84103
  textNote += `
83581
84104
  ${processed.hints.join(`
83582
84105
  `)}`;
83583
- if (nonVisionImageNote)
83584
- textNote += `
83585
- ${nonVisionImageNote}`;
83586
84106
  content = [
83587
84107
  { type: "text", text: textNote },
83588
84108
  { type: "image", data: processed.data, mimeType: processed.mimeType }
83589
84109
  ];
84110
+ if (ctx?.model && !ctx.model.input.includes("image")) {
84111
+ details = { imageUnsupportedByModel: ctx.model.id };
84112
+ }
83590
84113
  }
83591
84114
  } else {
83592
84115
  const startLine = offset ? Math.max(0, offset - 1) : 0;
@@ -83880,7 +84403,7 @@ function createReadOnlyTools(cwd, options) {
83880
84403
  }
83881
84404
 
83882
84405
  // node_modules/@earendil-works/pi-coding-agent/dist/core/virtual-models.js
83883
- init_dist3();
84406
+ init_dist2();
83884
84407
  var VIRTUAL_MODEL_API = "pi-virtual";
83885
84408
  var VIRTUAL_MODEL_STATE_ENTRY = "pi.virtual-model-state";
83886
84409
  var THINKING_LEVELS2 = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
@@ -84062,6 +84585,7 @@ class AgentSession {
84062
84585
  _extensionRunnerRef;
84063
84586
  _initialActiveToolNames;
84064
84587
  _pendingToolNames = new Set;
84588
+ _restoredToolNames = new Set;
84065
84589
  _usesDefaultTools;
84066
84590
  _defaultToolModifiers;
84067
84591
  _allowedTools;
@@ -84076,6 +84600,7 @@ class AgentSession {
84076
84600
  _extensionShutdownHandler;
84077
84601
  _extensionErrorListener;
84078
84602
  _extensionErrorUnsubscriber;
84603
+ _extensionsBound = false;
84079
84604
  _modelRuntime;
84080
84605
  _cacheWarmer;
84081
84606
  _toolRegistry = new Map;
@@ -84891,8 +85416,9 @@ class AgentSession {
84891
85416
  const previous = this.getActiveToolNames();
84892
85417
  this._setActiveTools(toolNames);
84893
85418
  const active = new Set(this.getActiveToolNames());
84894
- if (previous.some((name) => !active.has(name)))
85419
+ if (previous.some((name) => !active.has(name) && this._restoredToolNames.has(name))) {
84895
85420
  this._pendingToolNames.clear();
85421
+ }
84896
85422
  }
84897
85423
  _setActiveTools(toolNames) {
84898
85424
  const tools = this._applyToolLoadout(toolNames);
@@ -85092,6 +85618,7 @@ class AgentSession {
85092
85618
  }
85093
85619
  _restoreToolsFromTranscript(modifiers = []) {
85094
85620
  this._pendingToolNames.clear();
85621
+ this._restoredToolNames.clear();
85095
85622
  const systemMessages = this.sessionManager.getBranch().flatMap((entry) => entry.type === "message" && entry.message.role === "system" ? [entry.message] : []);
85096
85623
  if (systemMessages.length === 0)
85097
85624
  return;
@@ -85099,6 +85626,7 @@ class AgentSession {
85099
85626
  const newTools = [...this._toolRegistry.keys()].filter((name) => !mentioned.has(name) && !this._baseToolDefinitions.has(name) && this._isActivatedOnRegistration(name));
85100
85627
  const names = applyToolModifiers([...getCurrentTools(systemMessages).map((tool) => tool.name), ...newTools], modifiers);
85101
85628
  this._pendingToolNames = new Set(names.filter((name) => this._isAllowedTool(name)));
85629
+ this._restoredToolNames = new Set(applyToolModifiers(getCurrentTools(systemMessages).map((tool) => tool.name), modifiers));
85102
85630
  this._setActiveTools(names);
85103
85631
  }
85104
85632
  async _startRun(trigger, onStarted) {
@@ -86079,6 +86607,7 @@ ${normalized.hints.join(`
86079
86607
  if (bindings.onError !== undefined) {
86080
86608
  this._extensionErrorListener = bindings.onError;
86081
86609
  }
86610
+ this._extensionsBound = true;
86082
86611
  this._applyExtensionBindings(this._extensionRunner);
86083
86612
  await this._extensionRunner.emit(this._sessionStartEvent);
86084
86613
  this._extensionRunner.reportUnhandledMcpServers();
@@ -86394,13 +86923,13 @@ ${normalized.hints.join(`
86394
86923
  const addedDefaultTools = getDefaultTools().filter((name) => !previousDefaultTools.has(name));
86395
86924
  for (const name of this.getActiveToolNames())
86396
86925
  this._pendingToolNames.add(name);
86926
+ this._restoredToolNames = new Set(this.getActiveToolNames());
86397
86927
  this._buildRuntime({
86398
86928
  activeToolNames: [...this.getActiveToolNames(), ...addedDefaultTools],
86399
86929
  flagValues: previousFlagValues,
86400
86930
  includeAllExtensionTools: true
86401
86931
  });
86402
- const hasBindings = this._extensionUIContext || this._extensionCommandContextActions || this._extensionShutdownHandler || this._extensionErrorListener;
86403
- if (hasBindings) {
86932
+ if (this._extensionsBound) {
86404
86933
  await options?.beforeSessionStart?.();
86405
86934
  await this._extensionRunner.emit({ type: "session_start", reason: "reload" });
86406
86935
  this._extensionRunner.reportUnhandledMcpServers();
@@ -86819,7 +87348,7 @@ ${command}` : command;
86819
87348
  if (m.role !== "assistant")
86820
87349
  return false;
86821
87350
  const msg = m;
86822
- if (msg.stopReason === "aborted" && msg.content.length === 0)
87351
+ if (msg.stopReason !== "stop" && !msg.content.some((c) => c.type === "text" && c.text.trim()))
86823
87352
  return false;
86824
87353
  return true;
86825
87354
  });
@@ -87282,14 +87811,14 @@ function readStoredCredential(providerId, authPath = join20(getAgentDir(), "auth
87282
87811
  }
87283
87812
  }
87284
87813
  // node_modules/@earendil-works/pi-coding-agent/dist/core/model-resolver.js
87285
- init_dist3();
87814
+ init_dist2();
87286
87815
  var defaultModelPerProvider = {
87287
87816
  "amazon-bedrock": "us.anthropic.claude-opus-5-5",
87288
87817
  "ant-ling": "Ring-2.6-1T",
87289
87818
  anthropic: "claude-opus-5-5",
87290
- openai: "gpt-6.1-sol",
87291
- azure: "gpt-6.1-sol",
87292
- "openai-codex": "gpt-6.1-sol",
87819
+ openai: "gpt-6.2-sol",
87820
+ azure: "gpt-6.2-sol",
87821
+ "openai-codex": "gpt-6.2-sol",
87293
87822
  radius: "balanced",
87294
87823
  nvidia: "nvidia/nemotron-3.5-super-vl-120b-a12b",
87295
87824
  deepseek: "deepseek-v4-pro",
@@ -87534,13 +88063,6 @@ function resolveModelScopeFromModels(patterns, models) {
87534
88063
  async function resolveModelScopeWithDiagnostics(patterns, modelRuntime, options) {
87535
88064
  return resolveModelScopeFromModels(patterns, await modelRuntime.getAvailable(undefined, options));
87536
88065
  }
87537
- async function resolveModelScope(patterns, modelRuntime, options) {
87538
- const { scopedModels, diagnostics } = await resolveModelScopeWithDiagnostics(patterns, modelRuntime, options);
87539
- for (const diagnostic of diagnostics) {
87540
- console.warn(source_default.yellow(`Warning: ${diagnostic.message}`));
87541
- }
87542
- return scopedModels;
87543
- }
87544
88066
  function resolveCliModel(options) {
87545
88067
  const { cliProvider, cliModel, cliThinking, inlineApiKey, modelRuntime } = options;
87546
88068
  if (!cliModel) {
@@ -87634,7 +88156,7 @@ async function findInitialModel(options) {
87634
88156
  return { model: undefined, thinkingLevel: DEFAULT_THINKING_LEVEL, fallbackMessage: undefined };
87635
88157
  }
87636
88158
  // node_modules/@earendil-works/pi-coding-agent/dist/core/model-runtime.js
87637
- init_dist3();
88159
+ init_dist2();
87638
88160
  init_all();
87639
88161
  init_openrouter();
87640
88162
  init_model_operations();
@@ -92084,13 +92606,13 @@ function stripJsonComments(input) {
92084
92606
  }
92085
92607
 
92086
92608
  // node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.js
92087
- init_dist2();
92609
+ init_dist();
92088
92610
 
92089
92611
  // node_modules/@earendil-works/pi-ai/dist/providers/model-schema.js
92090
- init_dist2();
92612
+ init_dist();
92091
92613
 
92092
92614
  // node_modules/@earendil-works/pi-ai/dist/providers/schema-builders.js
92093
- init_dist2();
92615
+ init_dist();
92094
92616
  function openObject(properties, options = {}) {
92095
92617
  const { additionalProperties, ...annotations } = options;
92096
92618
  const schema = obj(properties, { ...annotations, open: true });
@@ -92287,7 +92809,7 @@ var OpenAICompletionsCompatProperties = {
92287
92809
  description: "Whether the provider supports the store field. Default: auto-detected from URL."
92288
92810
  })),
92289
92811
  supportsDeveloperRole: optionalCompatBoolean({
92290
- description: "Whether the provider supports the developer role instead of system. Default: auto-detected from URL."
92812
+ description: "Whether to send system messages of reasoning models (the system prompt and mid-conversation system messages) with the developer role instead of system. Default: true only for api.openai.com."
92291
92813
  }),
92292
92814
  supportsReasoningEffort: opt(bool({
92293
92815
  description: "Whether the provider supports reasoning_effort. Default: auto-detected from URL."
@@ -92431,7 +92953,7 @@ var OpenAIResponsesCompatProperties = {
92431
92953
  default: false
92432
92954
  })),
92433
92955
  supportsMidConvoEffort: opt(bool({
92434
- description: "Whether thinking level changes are sent as configuration_update input items instead of changing reasoning.effort, so a change keeps the prompt cache. Only used by the openai-responses API, and ignored with Sign in with ChatGPT on the openai provider.",
92956
+ description: "Whether thinking level changes are sent as configuration_update input items instead of changing reasoning.effort, so a change keeps the prompt cache. Used by the openai-responses and openai-codex-responses APIs, and ignored with Sign in with ChatGPT on the openai provider.",
92435
92957
  default: false
92436
92958
  })),
92437
92959
  supportsMaxOutputTokens: opt(bool({
@@ -92491,7 +93013,7 @@ var AnthropicMessagesCompatProperties = {
92491
93013
  default: false
92492
93014
  })),
92493
93015
  supportsMessageThreads: optionalCompatBoolean({
92494
- description: "Whether the endpoint supports Anthropic message threads, which let a request with a session id send only the new messages and continue from the previous reply. Default: true for provider anthropic with a baseUrl on api.anthropic.com, false otherwise. Set true for gateways that forward the thread request field."
93016
+ description: "Whether the endpoint supports Anthropic message threads, which let a request with a session id send only the new messages and continue from the previous reply. Default: true for a baseUrl on api.anthropic.com, false otherwise. Set true for gateways that forward the thread request field."
92495
93017
  }),
92496
93018
  allowedFallbackModels: opt(arr(AnthropicAllowedFallbackModelSchema, {
92497
93019
  maxItems: 3,
@@ -92516,6 +93038,10 @@ var MistralConversationsCompatProperties = {
92516
93038
  supportsMidConvoSystemMessages: optionalCompatBoolean({
92517
93039
  description: "Whether the exact model accepts system messages after the conversation has started. When false, later system messages are folded into the leading system message.",
92518
93040
  default: false
93041
+ }),
93042
+ supportsStrictMode: optionalCompatBoolean({
93043
+ description: "Whether the model supports strict (schema-constrained) function tools.",
93044
+ default: false
92519
93045
  })
92520
93046
  };
92521
93047
  var MistralConversationsCompatSchema = openObject(MistralConversationsCompatProperties, {
@@ -92549,7 +93075,7 @@ var ProviderCompatPropertyOverrides = {
92549
93075
  description: "Controls the prompt_cache_key request field for openai-completions and openai-responses: auto keeps each API's default, enabled sends it whenever caching is active, disabled never sends it. Default: auto."
92550
93076
  }),
92551
93077
  supportsMidConvoEffort: optionalCompatBoolean({
92552
- description: "Whether thinking level changes are sent inside the conversation instead of changing the request's effort, so a change keeps the prompt cache. Used by the anthropic-messages and openai-responses APIs.",
93078
+ description: "Whether thinking level changes are sent inside the conversation instead of changing the request's effort, so a change keeps the prompt cache. Used by the anthropic-messages, openai-responses, and openai-codex-responses APIs.",
92553
93079
  default: false
92554
93080
  }),
92555
93081
  supportsLongCacheRetention: optionalCompatBoolean({
@@ -92880,7 +93406,7 @@ class FileModelsStore {
92880
93406
  }
92881
93407
 
92882
93408
  // node_modules/@earendil-works/pi-coding-agent/dist/core/remote-catalog-provider.js
92883
- init_dist3();
93409
+ init_dist2();
92884
93410
  var DEFAULT_CATALOG_BASE_URL = "https://pi.dev";
92885
93411
  var REMOTE_CATALOG_ATTEMPT_TIMEOUT_MS = 4000;
92886
93412
  var REMOTE_CATALOG_REFRESH_INTERVAL_MS = 4 * 60 * 60 * 1000;
@@ -94060,6 +94586,16 @@ function getEnv() {
94060
94586
  }
94061
94587
  }
94062
94588
  var NETWORK_TIMEOUT_MS2 = 1e4;
94589
+ var CAPTURED_OUTPUT_TAIL_CHARS = 8000;
94590
+ var GIT_PROMPT_FAILURE = /terminal prompts disabled|could not read (Username|Password)|Permission denied \(publickey|Host key verification failed|passphrase/i;
94591
+ var GIT_CREDENTIALS_HINT = "git cannot ask for a password or passphrase while pi runs. Set up a git credential helper or an ssh agent, or install the package once from the shell with `pi install <source>`.";
94592
+ function getNonInteractiveGitEnv(env) {
94593
+ return {
94594
+ ...env,
94595
+ GIT_TERMINAL_PROMPT: "0",
94596
+ GIT_SSH_COMMAND: env.GIT_SSH_COMMAND ?? "ssh -o BatchMode=yes"
94597
+ };
94598
+ }
94063
94599
  var UPDATE_CHECK_CONCURRENCY = 4;
94064
94600
  var GIT_UPDATE_CONCURRENCY = 4;
94065
94601
  function isOfflineModeEnabled2() {
@@ -94587,11 +95123,13 @@ class DefaultPackageManager {
94587
95123
  globalNpmRoot;
94588
95124
  globalNpmRootCommandKey;
94589
95125
  progressCallback;
95126
+ commandOutput;
94590
95127
  constructor(options) {
94591
95128
  this.cwd = resolvePath(options.cwd);
94592
95129
  this.agentDir = resolvePath(options.agentDir);
94593
95130
  this.settingsManager = options.settingsManager;
94594
95131
  this.builtinExtensions = options.builtinExtensions ?? [];
95132
+ this.commandOutput = options.commandOutput ?? "inherit";
94595
95133
  }
94596
95134
  setProgressCallback(callback) {
94597
95135
  this.progressCallback = callback;
@@ -95041,7 +95579,7 @@ class DefaultPackageManager {
95041
95579
  throw new Error(`Missing source: ${resolvedSource}`);
95042
95580
  }
95043
95581
  try {
95044
- await this.installParsedSource(parsed, resolvedScope);
95582
+ await this.withProgress("install", resolvedSource, `Installing ${resolvedSource}...`, () => this.installParsedSource(parsed, resolvedScope));
95045
95583
  return true;
95046
95584
  } catch (error) {
95047
95585
  installFailures.push({
@@ -96183,6 +96721,9 @@ class DefaultPackageManager {
96183
96721
  });
96184
96722
  }
96185
96723
  runCommand(command, args, options) {
96724
+ if (this.commandOutput === "capture") {
96725
+ return this.runCommandCaptured(command, args, options);
96726
+ }
96186
96727
  return new Promise((resolvePromise, reject) => {
96187
96728
  const child = this.spawnCommand(command, args, options);
96188
96729
  child.on("error", reject);
@@ -96195,6 +96736,27 @@ class DefaultPackageManager {
96195
96736
  });
96196
96737
  });
96197
96738
  }
96739
+ async runCommandCaptured(command, args, options) {
96740
+ const child = spawnProcess(command, args, {
96741
+ cwd: options?.cwd,
96742
+ stdio: ["ignore", "pipe", "pipe"],
96743
+ env: getNonInteractiveGitEnv(getEnv())
96744
+ });
96745
+ let output = "";
96746
+ const append = (chunk) => {
96747
+ output = (output + chunk.toString()).slice(-CAPTURED_OUTPUT_TAIL_CHARS);
96748
+ };
96749
+ child.stdout.on("data", append);
96750
+ child.stderr.on("data", append);
96751
+ const code = await waitForChildProcess(child);
96752
+ if (code === 0)
96753
+ return;
96754
+ const tail = output.trim();
96755
+ const hint = command === "git" && GIT_PROMPT_FAILURE.test(tail) ? `
96756
+ ${GIT_CREDENTIALS_HINT}` : "";
96757
+ throw new Error(`${command} ${args.join(" ")} failed with code ${code}${tail ? `:
96758
+ ${tail}` : ""}${hint}`);
96759
+ }
96198
96760
  runCommandSync(command, args) {
96199
96761
  const env = getEnv();
96200
96762
  const result = spawnProcessSync(command, args, {
@@ -96727,8 +97289,10 @@ class DefaultResourceLoader {
96727
97289
  cwd: this.cwd,
96728
97290
  agentDir: this.agentDir,
96729
97291
  settingsManager: this.settingsManager,
96730
- builtinExtensions: [...this.builtinExtensions.keys()]
97292
+ builtinExtensions: [...this.builtinExtensions.keys()],
97293
+ commandOutput: options.packageCommandOutput
96731
97294
  });
97295
+ this.packageManager.setProgressCallback(options.onPackageProgress);
96732
97296
  this.additionalExtensionPaths = options.additionalExtensionPaths ?? [];
96733
97297
  this.additionalSkillPaths = options.additionalSkillPaths ?? [];
96734
97298
  this.additionalPromptTemplatePaths = options.additionalPromptTemplatePaths ?? [];
@@ -97421,7 +97985,7 @@ import { join as join28 } from "node:path";
97421
97985
  init_compat();
97422
97986
 
97423
97987
  // node_modules/@earendil-works/pi-coding-agent/dist/core/cache-warmer.js
97424
- init_dist3();
97988
+ init_dist2();
97425
97989
  function lastPromptTokens(entries) {
97426
97990
  for (let index = entries.length - 1;index >= 0; index--) {
97427
97991
  const entry = entries[index];
@@ -97666,7 +98230,7 @@ function formatCacheWarmingUsage(totalCost, note) {
97666
98230
  }
97667
98231
 
97668
98232
  // node_modules/@earendil-works/pi-coding-agent/dist/core/client-identity.js
97669
- init_dist3();
98233
+ init_dist2();
97670
98234
 
97671
98235
  // node_modules/@earendil-works/pi-coding-agent/dist/core/telemetry.js
97672
98236
  function isTruthyEnvFlag(value) {
@@ -97890,6 +98454,7 @@ class AgentSessionRuntime {
97890
98454
  createRuntime;
97891
98455
  _diagnostics;
97892
98456
  _modelFallbackMessage;
98457
+ reportedDiagnosticKeys = new Set;
97893
98458
  constructor(_session, _services, createRuntime, _diagnostics = [], _modelFallbackMessage) {
97894
98459
  this._session = _session;
97895
98460
  this._services = _services;
@@ -97912,6 +98477,15 @@ class AgentSessionRuntime {
97912
98477
  get modelFallbackMessage() {
97913
98478
  return this._modelFallbackMessage;
97914
98479
  }
98480
+ takeUnreportedDiagnostics() {
98481
+ return this._diagnostics.filter((diagnostic) => {
98482
+ const key = `${diagnostic.type}\x00${diagnostic.message}`;
98483
+ if (this.reportedDiagnosticKeys.has(key))
98484
+ return false;
98485
+ this.reportedDiagnosticKeys.add(key);
98486
+ return true;
98487
+ });
98488
+ }
97915
98489
  setRebindSession(rebindSession) {
97916
98490
  this.rebindSession = rebindSession;
97917
98491
  }
@@ -98884,7 +99458,7 @@ function parseCodemodeSource(input) {
98884
99458
  }
98885
99459
 
98886
99460
  // node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/execute.lazy.js
98887
- var loadCodemodeExecutor = () => import("./execute-x0fy9j0m.js");
99461
+ var loadCodemodeExecutor = () => import("./execute-z8nc8bba.js");
98888
99462
 
98889
99463
  // node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/renderer.js
98890
99464
  var CODE_PREVIEW_LINES = 10;
@@ -100029,7 +100603,7 @@ function createMcpResourceToolDefinitions(options) {
100029
100603
  }
100030
100604
 
100031
100605
  // node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/runtime.lazy.js
100032
- var loadMcpRuntime = () => import("./runtime-he7c9g1r.js");
100606
+ var loadMcpRuntime = () => import("./runtime-kkebz8yq.js");
100033
100607
 
100034
100608
  // node_modules/@earendil-works/pi-coding-agent/dist/utils/clipboard.js
100035
100609
  import { randomUUID as randomUUID3 } from "node:crypto";
@@ -100500,11 +101074,6 @@ function truncate(text, max) {
100500
101074
  return text;
100501
101075
  return max <= 1 ? "" : `${sliceHead(text, max - 1).trimEnd()}…`;
100502
101076
  }
100503
- function serverSummary(server) {
100504
- const text = server.entry.config.description?.trim() || server.connection?.instructions || "";
100505
- return (text.split(`
100506
- `, 1)[0] ?? "").trim();
100507
- }
100508
101077
  function renderServersSection(servers) {
100509
101078
  const listed = servers.filter((server) => isEnabled(server) && hasIndirectTools(server.entry)).sort((a, b) => a.entry.name.localeCompare(b.entry.name));
100510
101079
  if (listed.length === 0)
@@ -100520,7 +101089,7 @@ function renderServersSection(servers) {
100520
101089
  kept--;
100521
101090
  const perServer = kept === 0 ? 0 : Math.min(MAX_SERVER_DESCRIPTION_CHARS, Math.floor((MAX_SERVERS_SECTION_CHARS - size(kept)) / kept) - 2);
100522
101091
  const lines = listed.slice(0, kept).map((server, index) => {
100523
- const summary = perServer > 0 ? truncate(serverSummary(server), perServer) : "";
101092
+ const summary = perServer > 0 ? truncate(mcpServerSummary(server.entry.config.description, server.connection?.instructions), perServer) : "";
100524
101093
  return summary ? `${heads[index]}: ${summary}` : heads[index];
100525
101094
  });
100526
101095
  return [intro, ...lines, ...omitted(listed.length - kept)].join(`
@@ -101472,7 +102041,7 @@ function createToolSearchExtension() {
101472
102041
  }
101473
102042
  var tool_search_default = createToolSearchExtension();
101474
102043
  // node_modules/@earendil-works/pi-coding-agent/dist/main.js
101475
- init_dist3();
102044
+ init_dist2();
101476
102045
  import { createInterface as createInterface5 } from "node:readline";
101477
102046
 
101478
102047
  // node_modules/@earendil-works/pi-coding-agent/dist/cli/auth-command.js
@@ -103007,6 +103576,22 @@ Fell back to the system theme.`);
103007
103576
  }
103008
103577
  }
103009
103578
 
103579
+ // node_modules/@earendil-works/pi-coding-agent/dist/utils/flush-stdout.js
103580
+ var STDOUT_FLUSH_TIMEOUT_MS = 1000;
103581
+ function flushStdout() {
103582
+ return new Promise((resolve) => {
103583
+ const finish = (error) => {
103584
+ clearTimeout(timer);
103585
+ if (!error)
103586
+ process.stdout.off("error", finish);
103587
+ resolve();
103588
+ };
103589
+ const timer = setTimeout(finish, STDOUT_FLUSH_TIMEOUT_MS);
103590
+ process.stdout.on("error", finish);
103591
+ process.stdout.write("", finish);
103592
+ });
103593
+ }
103594
+
103010
103595
  // node_modules/@earendil-works/pi-coding-agent/dist/cli/startup-ui.js
103011
103596
  var OFFICIAL_PACKAGE_NAME = "@earendil-works/pi-coding-agent";
103012
103597
  var OFFICIAL_APP_NAME = "pi";
@@ -103101,6 +103686,7 @@ async function showStartupSelector(settingsManager, title, options) {
103101
103686
  settled = true;
103102
103687
  await clearStartupTui(ui);
103103
103688
  ui.stop();
103689
+ await flushStdout();
103104
103690
  resolve(result);
103105
103691
  };
103106
103692
  const selector = new ExtensionSelectorComponent(title, options.map((option) => option.label), (option) => void finish(options.find((entry) => entry.label === option)?.value), () => void finish(undefined), { tui: ui });
@@ -103125,6 +103711,7 @@ async function showFirstTimeSetup(settingsManager) {
103125
103711
  }
103126
103712
  await clearStartupTui(ui);
103127
103713
  ui.stop();
103714
+ await flushStdout();
103128
103715
  resolve();
103129
103716
  };
103130
103717
  ui.start();
@@ -103157,6 +103744,7 @@ async function showStartupInput(settingsManager, title, placeholder) {
103157
103744
  input.dispose();
103158
103745
  await clearStartupTui(ui);
103159
103746
  ui.stop();
103747
+ await flushStdout();
103160
103748
  resolve(result);
103161
103749
  };
103162
103750
  const input = new ExtensionInputComponent(title, placeholder, (value) => void finish(value), () => void finish(undefined), {
@@ -103612,6 +104200,7 @@ class SessionList {
103612
104200
  filteredSessions = [];
103613
104201
  selectedIndex = 0;
103614
104202
  selectionTouched = false;
104203
+ pendingSelectedPath;
103615
104204
  searchInput;
103616
104205
  showCwd = false;
103617
104206
  sortMode = "threaded";
@@ -103667,8 +104256,9 @@ class SessionList {
103667
104256
  this.nameFilter = nameFilter;
103668
104257
  this.filterSessions(this.searchInput.getValue());
103669
104258
  }
103670
- setSessions(sessions, showCwd) {
103671
- const selectedPath = this.selectionTouched ? this.getSelectedSessionPath() : undefined;
104259
+ setSessions(sessions, showCwd, partial = false) {
104260
+ const pendingPath = this.selectionTouched ? this.pendingSelectedPath : undefined;
104261
+ const selectedPath = this.selectionTouched ? pendingPath ?? this.getSelectedSessionPath() : undefined;
103672
104262
  this.allSessions = sessions;
103673
104263
  this.showCwd = showCwd;
103674
104264
  this.filterSessions(this.searchInput.getValue());
@@ -103676,8 +104266,14 @@ class SessionList {
103676
104266
  this.selectedIndex = 0;
103677
104267
  } else if (selectedPath) {
103678
104268
  const selectedIndex = this.filteredSessions.findIndex((node) => node.session.path === selectedPath);
103679
- if (selectedIndex >= 0)
104269
+ if (selectedIndex >= 0) {
103680
104270
  this.selectedIndex = selectedIndex;
104271
+ this.pendingSelectedPath = undefined;
104272
+ } else if (partial) {
104273
+ this.pendingSelectedPath = selectedPath;
104274
+ } else {
104275
+ this.pendingSelectedPath = undefined;
104276
+ }
103681
104277
  }
103682
104278
  }
103683
104279
  filterSessions(query) {
@@ -103848,14 +104444,14 @@ class SessionList {
103848
104444
  }
103849
104445
  if (kb.matches(keyData, "app.session.deleteNoninvasive")) {
103850
104446
  if (this.searchInput.getValue().length > 0) {
103851
- this.searchInput.handleInput(keyData);
103852
- this.filterSessions(this.searchInput.getValue());
104447
+ this.handleSearchInput(keyData);
103853
104448
  return;
103854
104449
  }
103855
104450
  this.startDeleteConfirmationForSelectedSession();
103856
104451
  return;
103857
104452
  }
103858
104453
  this.selectionTouched = true;
104454
+ this.pendingSelectedPath = undefined;
103859
104455
  if (kb.matches(keyData, "tui.select.up")) {
103860
104456
  this.selectedIndex = Math.max(0, this.selectedIndex - 1);
103861
104457
  } else if (kb.matches(keyData, "tui.select.down")) {
@@ -103874,10 +104470,22 @@ class SessionList {
103874
104470
  this.onCancel();
103875
104471
  }
103876
104472
  } else {
103877
- this.searchInput.handleInput(keyData);
103878
- this.filterSessions(this.searchInput.getValue());
104473
+ this.handleSearchInput(keyData);
103879
104474
  }
103880
104475
  }
104476
+ handleSearchInput(keyData) {
104477
+ const previousQuery = this.searchInput.getValue();
104478
+ this.searchInput.handleInput(keyData);
104479
+ const query = this.searchInput.getValue();
104480
+ if (query === previousQuery)
104481
+ return;
104482
+ this.filterSessions(query);
104483
+ if (!query.trim())
104484
+ return;
104485
+ this.selectedIndex = 0;
104486
+ this.selectionTouched = false;
104487
+ this.pendingSelectedPath = undefined;
104488
+ }
103881
104489
  }
103882
104490
  async function deleteSessionFile(sessionPath) {
103883
104491
  const trashArgs = sessionPath.startsWith("-") ? ["--", sessionPath] : [sessionPath];
@@ -104126,7 +104734,7 @@ class SessionSelectorComponent extends Container {
104126
104734
  this.allSessions = sessions;
104127
104735
  }
104128
104736
  if (scope === this.scope)
104129
- this.sessionList.setSessions(sessions, showCwd);
104737
+ this.sessionList.setSessions(sessions, showCwd, true);
104130
104738
  }
104131
104739
  if (scope !== this.scope)
104132
104740
  return;
@@ -104192,7 +104800,7 @@ class SessionSelectorComponent extends Container {
104192
104800
  const loading = (this.scope === "current" ? this.currentLoad : this.allLoad) !== null;
104193
104801
  this.header.setScope(this.scope);
104194
104802
  this.header.setLoading(loading);
104195
- this.sessionList.setSessions(sessions ?? [], this.scope === "all");
104803
+ this.sessionList.setSessions(sessions ?? [], this.scope === "all", loading || sessions === null);
104196
104804
  this.requestRender();
104197
104805
  if (sessions === null && !loading)
104198
104806
  this.loadScope(this.scope);
@@ -104209,21 +104817,22 @@ async function selectSession(currentSessionsLoader, allSessionsLoader, settingsM
104209
104817
  const keybindings = KeybindingsManager2.create();
104210
104818
  setKeybindings(keybindings);
104211
104819
  let resolved = false;
104820
+ const stopUi = () => {
104821
+ ui.stop();
104822
+ return flushStdout();
104823
+ };
104212
104824
  const selector = new SessionSelectorComponent(currentSessionsLoader, allSessionsLoader, (path) => {
104213
104825
  if (!resolved) {
104214
104826
  resolved = true;
104215
- ui.stop();
104216
- resolve(path);
104827
+ stopUi().then(() => resolve(path));
104217
104828
  }
104218
104829
  }, () => {
104219
104830
  if (!resolved) {
104220
104831
  resolved = true;
104221
- ui.stop();
104222
- resolve(null);
104832
+ stopUi().then(() => resolve(null));
104223
104833
  }
104224
104834
  }, () => {
104225
- ui.stop();
104226
- process.exit(0);
104835
+ stopUi().then(() => process.exit(0));
104227
104836
  }, () => ui.requestRender(), { showRenameHint: false, keybindings });
104228
104837
  ui.addChild(selector);
104229
104838
  ui.setFocus(selector.getSessionList());
@@ -104775,18 +105384,18 @@ class HuggingFaceClient {
104775
105384
  }
104776
105385
 
104777
105386
  // node_modules/@earendil-works/pi-coding-agent/dist/extensions/llama/provider.js
104778
- init_dist3();
105387
+ init_dist2();
104779
105388
 
104780
105389
  // node_modules/@earendil-works/pi-ai/dist/api/llama-cpp-classify.lazy.js
104781
105390
  var llamaCppClassifyApi = () => ({
104782
- classify: async (model, context, options) => (await import("./llama-cpp-classify-yvb8vh7w.js")).classify(model, context, options)
105391
+ classify: async (model, context, options) => (await import("./llama-cpp-classify-wd7htn1x.js")).classify(model, context, options)
104783
105392
  });
104784
105393
 
104785
105394
  // node_modules/@earendil-works/pi-coding-agent/dist/extensions/llama/provider.js
104786
105395
  init_typesafe_system_one_lazy();
104787
105396
  init_compat();
104788
105397
  var LLAMA_PROVIDER_ID = "llama.cpp";
104789
- var DEFAULT_LLAMA_SERVER_URL = "http://127.0.0.1:8080";
105398
+ var DEFAULT_LLAMA_SERVER_URL = "http://127.0.0.1:9931";
104790
105399
  function credentialServerUrl(credential) {
104791
105400
  const value = credential?.env?.LLAMA_BASE_URL;
104792
105401
  return typeof value === "string" && value.trim() ? normalizeLlamaServerUrl(value) : undefined;
@@ -104843,6 +105452,7 @@ function isChatModel(model) {
104843
105452
  }
104844
105453
  function toPiClassifierModel(model, serverUrl, cachedContextWindow) {
104845
105454
  const decision = isDecisionModel(model);
105455
+ const image = decision && model.architecture?.input_modalities?.includes("image") === true;
104846
105456
  return {
104847
105457
  type: "classifier",
104848
105458
  id: model.id,
@@ -104850,9 +105460,10 @@ function toPiClassifierModel(model, serverUrl, cachedContextWindow) {
104850
105460
  api: decision ? "typesafe-system-one" : "llama-cpp-classify",
104851
105461
  provider: LLAMA_PROVIDER_ID,
104852
105462
  baseUrl: decision ? llamaInferenceUrl(serverUrl) : serverUrl,
104853
- input: ["text"],
105463
+ input: image ? ["text", "image"] : ["text"],
104854
105464
  cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
104855
- contextWindow: contextWindowOf(model, cachedContextWindow)
105465
+ contextWindow: contextWindowOf(model, cachedContextWindow),
105466
+ ...image && { compat: { imageInput: "images", sendImageOptInHeader: false } }
104856
105467
  };
104857
105468
  }
104858
105469
  function isLlamaClassifierModel(model) {
@@ -104877,7 +105488,6 @@ function toPiModel(model, serverUrl, props, cachedContextWindow) {
104877
105488
  maxTokens: contextWindow,
104878
105489
  compat: {
104879
105490
  supportsStore: false,
104880
- supportsDeveloperRole: false,
104881
105491
  supportsReasoningEffort: false,
104882
105492
  supportsUsageInStreaming: true,
104883
105493
  supportsStrictMode: false,
@@ -105648,7 +106258,7 @@ var builtInExtensions = [
105648
106258
  ];
105649
106259
 
105650
106260
  // node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/cli.lazy.js
105651
- var loadMcpCommand = () => import("./cli-f07sgaax.js");
106261
+ var loadMcpCommand = () => import("./cli-e2k0ej0d.js");
105652
106262
 
105653
106263
  // node_modules/@earendil-works/pi-coding-agent/dist/migrations.js
105654
106264
  import { existsSync as existsSync22, mkdirSync as mkdirSync11, readdirSync as readdirSync10, readFileSync as readFileSync17, renameSync as renameSync2, rmSync as rmSync4, writeFileSync as writeFileSync11 } from "fs";
@@ -105855,6 +106465,15 @@ function runMigrations(cwd) {
105855
106465
  return { migratedAuthProviders, deprecationWarnings };
105856
106466
  }
105857
106467
 
106468
+ // node_modules/@earendil-works/pi-coding-agent/dist/modes/diagnostics-stderr.js
106469
+ function writeDiagnosticsToStderr(diagnostics) {
106470
+ for (const diagnostic of diagnostics) {
106471
+ const color = diagnostic.type === "error" ? source_default.red : diagnostic.type === "warning" ? source_default.yellow : source_default.dim;
106472
+ const prefix = diagnostic.type === "error" ? "Error: " : diagnostic.type === "warning" ? "Warning: " : "";
106473
+ console.error(color(`${prefix}${diagnostic.message}`));
106474
+ }
106475
+ }
106476
+
105858
106477
  // node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js
105859
106478
  init_compat();
105860
106479
  import * as crypto2 from "node:crypto";
@@ -106239,8 +106858,7 @@ function parseChangelog(changelogPath) {
106239
106858
  });
106240
106859
  }
106241
106860
  return entries;
106242
- } catch (error) {
106243
- console.error(`Warning: Could not parse changelog: ${error}`);
106861
+ } catch {
106244
106862
  return [];
106245
106863
  }
106246
106864
  }
@@ -106848,6 +107466,7 @@ async function shareViaGist(tmpFile, context) {
106848
107466
  proc.stderr?.on("data", (data) => {
106849
107467
  stderr += data.toString();
106850
107468
  });
107469
+ proc.on("error", (error) => resolve({ stdout, stderr: stderr || error.message, code: null }));
106851
107470
  proc.on("close", (code) => resolve({ stdout, stderr, code }));
106852
107471
  });
106853
107472
  if (loader.signal.aborted)
@@ -107586,6 +108205,7 @@ class AssistantMessageComponent extends Container {
107586
108205
  timestamp;
107587
108206
  thinkingVisibilityOverrides = new Map;
107588
108207
  markdownSlots = [];
108208
+ zoneLines;
107589
108209
  constructor(message, hideThinkingBlock = false, markdownTheme = getMarkdownTheme(), hiddenThinkingLabel = "Thinking...", outputPad = 1, markdownTransformers = [], messageId, timestamp) {
107590
108210
  super();
107591
108211
  this.hideThinkingBlock = hideThinkingBlock;
@@ -107632,9 +108252,13 @@ class AssistantMessageComponent extends Container {
107632
108252
  if (this.hasToolCalls || lines.length === 0) {
107633
108253
  return lines;
107634
108254
  }
107635
- lines[0] = OSC133_ZONE_START + lines[0];
107636
- lines[lines.length - 1] = OSC133_ZONE_END + OSC133_ZONE_FINAL + lines[lines.length - 1];
107637
- return lines;
108255
+ if (this.zoneLines?.source !== lines) {
108256
+ const zoned = [...lines];
108257
+ zoned[0] = OSC133_ZONE_START + zoned[0];
108258
+ zoned[zoned.length - 1] = OSC133_ZONE_END + OSC133_ZONE_FINAL + zoned[zoned.length - 1];
108259
+ this.zoneLines = { source: lines, lines: zoned };
108260
+ }
108261
+ return this.zoneLines.lines;
107638
108262
  }
107639
108263
  updateContent(message, isStreaming = this.isStreaming) {
107640
108264
  this.lastMessage = message;
@@ -108238,7 +108862,7 @@ function playEasterEgg3d(tui, egg) {
108238
108862
  if (tui.hasOverlay())
108239
108863
  return true;
108240
108864
  const screen = tui.getScreenLines();
108241
- import("./easter-egg-3d-8n4w3s9k.js").then((module) => module.playEasterEgg3d(tui, screen, egg), () => {});
108865
+ import("./easter-egg-3d-y49v5z90.js").then((module) => module.playEasterEgg3d(tui, screen, egg), () => {});
108242
108866
  return true;
108243
108867
  }
108244
108868
  function playPiLogo3d(tui, column, row) {
@@ -109660,7 +110284,7 @@ function codePointWidth(cp) {
109660
110284
  }
109661
110285
  return 1;
109662
110286
  }
109663
- function clusterWidth(cluster) {
110287
+ function clusterWidth2(cluster) {
109664
110288
  let w = 0;
109665
110289
  let vs16 = false;
109666
110290
  let regional = 0;
@@ -109678,12 +110302,12 @@ function clusterWidth(cluster) {
109678
110302
  }
109679
110303
  function* measured(s) {
109680
110304
  for (const { segment } of segmenter3.segment(s))
109681
- yield [segment, clusterWidth(segment)];
110305
+ yield [segment, clusterWidth2(segment)];
109682
110306
  }
109683
110307
  function stringWidth(s) {
109684
110308
  let w = 0;
109685
110309
  for (const { segment } of segmenter3.segment(s))
109686
- w += clusterWidth(segment);
110310
+ w += clusterWidth2(segment);
109687
110311
  return w;
109688
110312
  }
109689
110313
 
@@ -114051,7 +114675,7 @@ ${codeSpan(styledWarning)}
114051
114675
  }
114052
114676
 
114053
114677
  // node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/model-selector.js
114054
- init_dist3();
114678
+ init_dist2();
114055
114679
 
114056
114680
  // node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/model-catalog-refresh.js
114057
114681
  class ModelCatalogRefreshCoordinator {
@@ -114423,8 +115047,11 @@ class ModelSelectorComponent extends Container {
114423
115047
  this.onSelectAsDefaultCallback(selectedModel.model);
114424
115048
  }
114425
115049
  } else {
115050
+ const previousQuery = this.searchInput.getValue();
114426
115051
  this.searchInput.handleInput(keyData);
114427
- this.filterModels(this.searchInput.getValue());
115052
+ const query = this.searchInput.getValue();
115053
+ if (query !== previousQuery)
115054
+ this.filterModels(query);
114428
115055
  }
114429
115056
  }
114430
115057
  handleSelect(model) {
@@ -114575,7 +115202,7 @@ class OAuthSelectorComponent extends Container {
114575
115202
  }
114576
115203
  filterProviders(query) {
114577
115204
  this.filteredProviders = query ? fuzzyFilter(this.allProviders, query, (provider) => `${provider.name} ${provider.id} ${provider.authType} ${provider.method?.name ?? ""}`) : this.allProviders;
114578
- this.selectedIndex = Math.max(0, Math.min(this.selectedIndex, Math.max(0, this.filteredProviders.length - 1)));
115205
+ this.selectedIndex = query ? 0 : Math.min(this.selectedIndex, Math.max(0, this.filteredProviders.length - 1));
114579
115206
  this.updateList();
114580
115207
  }
114581
115208
  updateList() {
@@ -114637,8 +115264,11 @@ class OAuthSelectorComponent extends Container {
114637
115264
  } else if (kb.matches(keyData, "tui.select.cancel")) {
114638
115265
  this.onCancelCallback();
114639
115266
  } else {
115267
+ const previousQuery = this.searchInput.getValue();
114640
115268
  this.searchInput.handleInput(keyData);
114641
- this.filterProviders(this.searchInput.getValue());
115269
+ const query = this.searchInput.getValue();
115270
+ if (query !== previousQuery)
115271
+ this.filterProviders(query);
114642
115272
  }
114643
115273
  }
114644
115274
  }
@@ -114681,7 +115311,7 @@ class RadiusLoginMenuComponent extends ExtensionSelectorComponent {
114681
115311
  this.stopAnimationTimer = startBrandAnimation(tui, () => this.animating);
114682
115312
  }
114683
115313
  render(width) {
114684
- const lines = super.render(width);
115314
+ const lines = [...super.render(width)];
114685
115315
  const { label, text } = this.radiusOption;
114686
115316
  const selectedLine = new Text(theme.fg("accent", "→ ") + theme.fg("accent", label), 1, 0).render(width)[0];
114687
115317
  const index = selectedLine === undefined ? -1 : lines.indexOf(selectedLine);
@@ -114999,7 +115629,13 @@ class ScopedModelsSelectorComponent extends Container {
114999
115629
  this.callbacks.onCancel();
115000
115630
  return;
115001
115631
  }
115632
+ const previousQuery = this.searchInput.getValue();
115002
115633
  this.searchInput.handleInput(data);
115634
+ const query = this.searchInput.getValue();
115635
+ if (query === previousQuery)
115636
+ return;
115637
+ if (query)
115638
+ this.selectedIndex = 0;
115003
115639
  this.refresh();
115004
115640
  }
115005
115641
  getSearchInput() {
@@ -115008,7 +115644,7 @@ class ScopedModelsSelectorComponent extends Container {
115008
115644
  }
115009
115645
 
115010
115646
  // node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-selector.js
115011
- init_dist3();
115647
+ init_dist2();
115012
115648
 
115013
115649
  // node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-submenu.js
115014
115650
  var SUBMENU_SELECT_LIST_LAYOUT = {
@@ -115079,8 +115715,11 @@ class SelectSubmenu extends Container {
115079
115715
  if (isNav) {
115080
115716
  this.selectList.handleInput(data);
115081
115717
  } else {
115718
+ const previousQuery = this.searchInput.getValue();
115082
115719
  this.searchInput.handleInput(data);
115083
- this.applyFilter(this.searchInput.getValue());
115720
+ const query = this.searchInput.getValue();
115721
+ if (query !== previousQuery)
115722
+ this.applyFilter(query);
115084
115723
  }
115085
115724
  } else {
115086
115725
  this.selectList.handleInput(data);
@@ -116095,8 +116734,11 @@ class ThinkingSelectorComponent extends Container {
116095
116734
  this.selectList.handleInput(keyData);
116096
116735
  return;
116097
116736
  }
116737
+ const previousQuery = this.searchInput.getValue();
116098
116738
  this.searchInput.handleInput(keyData);
116099
- this.applyFilter(this.searchInput.getValue());
116739
+ const query = this.searchInput.getValue();
116740
+ if (query !== previousQuery)
116741
+ this.applyFilter(query);
116100
116742
  }
116101
116743
  getSelectList() {
116102
116744
  return this.selectList;
@@ -116275,7 +116917,8 @@ class ToolExecutionComponent extends Container {
116275
116917
  const lines = [];
116276
116918
  if (contentLines.length > 0) {
116277
116919
  lines.push("");
116278
- lines.push(...contentLines);
116920
+ for (const line of contentLines)
116921
+ lines.push(line);
116279
116922
  }
116280
116923
  for (let i = 0;i < this.imageComponents.length; i++) {
116281
116924
  const spacer = this.imageSpacers[i];
@@ -117559,6 +118202,7 @@ class UserMessageComponent extends Container {
117559
118202
  markdownTransformers;
117560
118203
  messageId;
117561
118204
  timestamp;
118205
+ zoneLines;
117562
118206
  constructor(text, markdownTheme = getMarkdownTheme(), outputPad = 1, markdownTransformers = [], messageId, timestamp) {
117563
118207
  super();
117564
118208
  this.text = text;
@@ -117589,9 +118233,13 @@ class UserMessageComponent extends Container {
117589
118233
  if (lines.length === 0) {
117590
118234
  return lines;
117591
118235
  }
117592
- lines[0] = OSC133_ZONE_START2 + lines[0];
117593
- lines[lines.length - 1] = OSC133_ZONE_END2 + OSC133_ZONE_FINAL2 + lines[lines.length - 1];
117594
- return lines;
118236
+ if (this.zoneLines?.source !== lines) {
118237
+ const zoned = [...lines];
118238
+ zoned[0] = OSC133_ZONE_START2 + zoned[0];
118239
+ zoned[zoned.length - 1] = OSC133_ZONE_END2 + OSC133_ZONE_FINAL2 + zoned[zoned.length - 1];
118240
+ this.zoneLines = { source: lines, lines: zoned };
118241
+ }
118242
+ return this.zoneLines.lines;
117595
118243
  }
117596
118244
  }
117597
118245
 
@@ -117965,6 +118613,36 @@ function formatLoginProviderCompletionDescription(provider) {
117965
118613
  const authTypes = provider.authTypes.map((authType) => formatAuthSelectorProviderType(authType, provider.subscription)).join("/");
117966
118614
  return provider.name === provider.id ? authTypes : `${provider.name} · ${authTypes}`;
117967
118615
  }
118616
+ var REASONING_DROP_DIAGNOSTICS = new Map([
118617
+ [
118618
+ "anthropic_input_transformations",
118619
+ { provider: "Anthropic", droppedType: "thinking_dropped", noun: ["thinking block", "thinking blocks"] }
118620
+ ],
118621
+ [
118622
+ "openai_input_transformations",
118623
+ { provider: "OpenAI", droppedType: "reasoning", noun: ["reasoning item", "reasoning items"] }
118624
+ ]
118625
+ ]);
118626
+ function getDroppedReasoning(message) {
118627
+ for (const diagnostic of message.diagnostics ?? []) {
118628
+ const kind = REASONING_DROP_DIAGNOSTICS.get(diagnostic.type);
118629
+ if (!kind)
118630
+ continue;
118631
+ const transformations = diagnostic.details?.transformations;
118632
+ if (!Array.isArray(transformations))
118633
+ continue;
118634
+ const dropped = transformations.filter((transformation) => typeof transformation === "object" && transformation !== null && transformation.type === kind.droppedType);
118635
+ if (dropped.length === 0)
118636
+ continue;
118637
+ const reasons = new Set;
118638
+ for (const transformation of dropped) {
118639
+ if (typeof transformation.reason === "string")
118640
+ reasons.add(transformation.reason);
118641
+ }
118642
+ return { diagnostic: kind, count: dropped.length, reasons: [...reasons] };
118643
+ }
118644
+ return;
118645
+ }
117968
118646
 
117969
118647
  class InteractiveMode {
117970
118648
  runtimeHost;
@@ -118081,6 +118759,7 @@ class InteractiveMode {
118081
118759
  this.runtimeHost.setRebindSession(async () => {
118082
118760
  await this.rebindCurrentSession({ renderBeforeBind: true });
118083
118761
  this.themeController.applyFromSettings();
118762
+ this.showRuntimeDiagnostics(this.runtimeHost.takeUnreportedDiagnostics());
118084
118763
  });
118085
118764
  this.version = VERSION;
118086
118765
  this.renderer = createInteractiveTui({
@@ -118346,6 +119025,7 @@ class InteractiveMode {
118346
119025
  });
118347
119026
  nextUi.setClearOnShrink(clearOnShrink);
118348
119027
  nextUi.onDebug = onDebug;
119028
+ nextUi.setSuspendSignalHandler(() => this.handleCtrlZ());
118349
119029
  if (nextUi instanceof TuiMainScreen && this.mainScreenRenderState) {
118350
119030
  nextUi.restoreRenderState(this.mainScreenRenderState);
118351
119031
  }
@@ -118403,6 +119083,7 @@ class InteractiveMode {
118403
119083
  this.defaultEditor.onCtrlD = () => this.handleCtrlD();
118404
119084
  this.defaultEditor.onSubmit = (text) => this.handleStartupSubmit(text);
118405
119085
  this.ui.setFocus(this.editor);
119086
+ this.ui.setSuspendSignalHandler(() => this.handleCtrlZ());
118406
119087
  this.ui.start();
118407
119088
  this.isInitialized = true;
118408
119089
  this.programStatus.report();
@@ -118534,15 +119215,7 @@ ${onboarding()}`, this.getStartupExpansionState(), 1, 0);
118534
119215
  }
118535
119216
  });
118536
119217
  const { migratedProviders, startupDiagnostics, modelFallbackMessage, initialMessage, initialImages, initialMessages } = this.options;
118537
- for (const diagnostic of startupDiagnostics ?? []) {
118538
- if (diagnostic.type === "error") {
118539
- this.showError(diagnostic.message);
118540
- } else if (diagnostic.type === "warning") {
118541
- this.showWarning(diagnostic.message);
118542
- } else {
118543
- this.showStatus(diagnostic.message);
118544
- }
118545
- }
119218
+ this.showRuntimeDiagnostics(startupDiagnostics ?? []);
118546
119219
  if (migratedProviders && migratedProviders.length > 0) {
118547
119220
  this.showWarning(`Migrated credentials to auth.json: ${migratedProviders.join(", ")}`);
118548
119221
  }
@@ -119285,6 +119958,17 @@ ${warningLines()}`, 0, 0));
119285
119958
  this.editor.setAutocompleteMaxVisible?.(autocompleteMaxVisible);
119286
119959
  }
119287
119960
  }
119961
+ showRuntimeDiagnostics(diagnostics) {
119962
+ for (const diagnostic of diagnostics) {
119963
+ if (diagnostic.type === "error") {
119964
+ this.showError(diagnostic.message);
119965
+ } else if (diagnostic.type === "warning") {
119966
+ this.showWarning(diagnostic.message);
119967
+ } else {
119968
+ this.showStatus(diagnostic.message);
119969
+ }
119970
+ }
119971
+ }
119288
119972
  async rebindCurrentSession(options = {}) {
119289
119973
  const session = this.session;
119290
119974
  this.unsubscribe?.();
@@ -119319,6 +120003,7 @@ ${warningLines()}`, 0, 0));
119319
120003
  }
119320
120004
  stopThemeWatcher();
119321
120005
  this.stop("transcript");
120006
+ await flushStdout();
119322
120007
  process.exit(1);
119323
120008
  }
119324
120009
  getCrashExtensionHint(error) {
@@ -120850,38 +121535,27 @@ ${message}`, ["Yes", "No"], opts, {
120850
121535
  this.chatContainer.addChild(new Spacer(1));
120851
121536
  this.chatContainer.addChild(new ThemedText(() => theme.fg("warning", `${label}: ${formatTokens(tokens)} tokens billed${cost}`), 1, 0));
120852
121537
  }
120853
- static countDroppedThinkingBlocks(message) {
120854
- let count = 0;
120855
- for (const diagnostic of message.diagnostics ?? []) {
120856
- if (diagnostic.type !== "anthropic_input_transformations")
120857
- continue;
120858
- const transformations = diagnostic.details?.transformations;
120859
- if (!Array.isArray(transformations))
120860
- continue;
120861
- count += transformations.filter((transformation) => typeof transformation === "object" && transformation !== null && transformation.type === "thinking_dropped").length;
120862
- }
120863
- return count;
120864
- }
120865
121538
  maybeShowThinkingDropNotice(message) {
120866
121539
  if (!this.settingsManager.getShowCacheMissNotices())
120867
121540
  return;
120868
- const droppedCount = InteractiveMode.countDroppedThinkingBlocks(message);
120869
- if (droppedCount === 0)
121541
+ const dropped = getDroppedReasoning(message);
121542
+ if (!dropped)
120870
121543
  return;
120871
- let previousDroppedCount = 0;
120872
121544
  const branch = this.sessionManager.getBranch();
120873
121545
  for (let i = branch.length - 1;i >= 0; i--) {
120874
121546
  const entry = branch[i];
120875
121547
  if (entry.type === "message" && entry.message.role === "assistant") {
120876
- previousDroppedCount = InteractiveMode.countDroppedThinkingBlocks(entry.message);
121548
+ const previous = getDroppedReasoning(entry.message);
121549
+ if (previous?.diagnostic === dropped.diagnostic && dropped.count <= previous.count)
121550
+ return;
120877
121551
  break;
120878
121552
  }
120879
121553
  }
120880
- if (droppedCount <= previousDroppedCount)
120881
- return;
120882
- const noun = droppedCount === 1 ? "thinking block" : "thinking blocks";
121554
+ const { provider, noun: nouns } = dropped.diagnostic;
121555
+ const noun = nouns[dropped.count === 1 ? 0 : 1];
121556
+ const reasons = dropped.reasons.length > 0 ? `: ${dropped.reasons.join(", ")}` : "";
120883
121557
  this.chatContainer.addChild(new Spacer(1));
120884
- this.chatContainer.addChild(new ThemedText(() => theme.fg("warning", `Anthropic dropped ${droppedCount} ${noun} (details in session)`), 1, 0));
121558
+ this.chatContainer.addChild(new ThemedText(() => theme.fg("warning", `${provider} dropped ${dropped.count} ${noun}${reasons} (details in session)`), 1, 0));
120885
121559
  }
120886
121560
  maybeShowCacheMissNotice(message) {
120887
121561
  if (!this.settingsManager.getShowCacheMissNotices())
@@ -120965,6 +121639,7 @@ ${message}`, ["Yes", "No"], opts, {
120965
121639
  this.themeController.disableAutoSync();
120966
121640
  await this.ui.terminal.drainInput(1000);
120967
121641
  this.stop();
121642
+ await flushStdout();
120968
121643
  process.exit(0);
120969
121644
  }
120970
121645
  this.themeController.disableAutoSync();
@@ -120973,9 +121648,11 @@ ${message}`, ["Yes", "No"], opts, {
120973
121648
  await this.runtimeHost.dispose();
120974
121649
  const resumeCommand = formatResumeCommand(this.sessionManager);
120975
121650
  if (resumeCommand) {
120976
- process.stdout.write(`${source_default.dim("To resume this session:")} ${resumeCommand}
121651
+ process.stdout.write(`${source_default.dim("To resume this session:")}
121652
+ ${resumeCommand}
120977
121653
  `);
120978
121654
  }
121655
+ await flushStdout();
120979
121656
  process.exit(0);
120980
121657
  }
120981
121658
  emergencyTerminalExit() {
@@ -123271,9 +123948,21 @@ async function runPrintMode(runtimeHost, options) {
123271
123948
  registerSignalHandlers();
123272
123949
  runtimeHost.setRebindSession(async () => {
123273
123950
  await rebindSession();
123951
+ writeDiagnosticsToStderr(runtimeHost.takeUnreportedDiagnostics());
123274
123952
  });
123275
123953
  const rebindSession = async () => {
123276
123954
  session = runtimeHost.session;
123955
+ unsubscribe?.();
123956
+ unsubscribeBackpressure?.();
123957
+ unsubscribe = session.subscribe((event) => {
123958
+ if (mode === "json") {
123959
+ writeRawStdout(`${JSON.stringify(toJsonEvent(event))}
123960
+ `);
123961
+ }
123962
+ });
123963
+ unsubscribeBackpressure = mode === "json" ? session.agent.subscribe(async () => {
123964
+ await waitForRawStdoutBackpressure();
123965
+ }) : undefined;
123277
123966
  await session.bindExtensions({
123278
123967
  mode: mode === "json" ? "json" : "print",
123279
123968
  commandContextActions: {
@@ -123303,17 +123992,6 @@ async function runPrintMode(runtimeHost, options) {
123303
123992
  console.error(`Extension error (${err.extensionPath}): ${err.error}`);
123304
123993
  }
123305
123994
  });
123306
- unsubscribe?.();
123307
- unsubscribeBackpressure?.();
123308
- unsubscribe = session.subscribe((event) => {
123309
- if (mode === "json") {
123310
- writeRawStdout(`${JSON.stringify(toJsonEvent(event))}
123311
- `);
123312
- }
123313
- });
123314
- unsubscribeBackpressure = mode === "json" ? session.agent.subscribe(async () => {
123315
- await waitForRawStdoutBackpressure();
123316
- }) : undefined;
123317
123995
  };
123318
123996
  try {
123319
123997
  if (mode === "json") {
@@ -123913,9 +124591,21 @@ async function runRpcMode(runtimeHost) {
123913
124591
  });
123914
124592
  runtimeHost.setRebindSession(async () => {
123915
124593
  await rebindSession();
124594
+ writeDiagnosticsToStderr(runtimeHost.takeUnreportedDiagnostics());
123916
124595
  });
123917
124596
  const rebindSession = async () => {
123918
124597
  session = runtimeHost.session;
124598
+ unsubscribe?.();
124599
+ unsubscribeBackpressure?.();
124600
+ unsubscribe = session.subscribe((event) => {
124601
+ output(toJsonEvent(event));
124602
+ if (event.type === "agent_settled") {
124603
+ checkShutdownRequested();
124604
+ }
124605
+ });
124606
+ unsubscribeBackpressure = session.agent.subscribe(async () => {
124607
+ await waitForRawStdoutBackpressure();
124608
+ });
123919
124609
  await session.bindExtensions({
123920
124610
  uiContext: createExtensionUIContext(),
123921
124611
  mode: "rpc",
@@ -123950,17 +124640,6 @@ async function runRpcMode(runtimeHost) {
123950
124640
  output({ type: "extension_error", extensionPath: err.extensionPath, event: err.event, error: err.error });
123951
124641
  }
123952
124642
  });
123953
- unsubscribe?.();
123954
- unsubscribeBackpressure?.();
123955
- unsubscribe = session.subscribe((event) => {
123956
- output(toJsonEvent(event));
123957
- if (event.type === "agent_settled") {
123958
- checkShutdownRequested();
123959
- }
123960
- });
123961
- unsubscribeBackpressure = session.agent.subscribe(async () => {
123962
- await waitForRawStdoutBackpressure();
123963
- });
123964
124643
  };
123965
124644
  const registerSignalHandlers = () => {
123966
124645
  const signals = ["SIGTERM"];
@@ -124024,9 +124703,6 @@ async function runRpcMode(runtimeHost) {
124024
124703
  case "new_session": {
124025
124704
  const options = command.parentSession ? { parentSession: command.parentSession } : undefined;
124026
124705
  const result = await runtimeHost.newSession(options);
124027
- if (!result.cancelled) {
124028
- await rebindSession();
124029
- }
124030
124706
  return success(id, "new_session", result);
124031
124707
  }
124032
124708
  case "get_state": {
@@ -124139,16 +124815,10 @@ async function runRpcMode(runtimeHost) {
124139
124815
  }
124140
124816
  case "switch_session": {
124141
124817
  const result = await runtimeHost.switchSession(command.sessionPath);
124142
- if (!result.cancelled) {
124143
- await rebindSession();
124144
- }
124145
124818
  return success(id, "switch_session", result);
124146
124819
  }
124147
124820
  case "fork": {
124148
124821
  const result = await runtimeHost.fork(command.entryId);
124149
- if (!result.cancelled) {
124150
- await rebindSession();
124151
- }
124152
124822
  return success(id, "fork", { text: result.selectedText, cancelled: result.cancelled });
124153
124823
  }
124154
124824
  case "clone": {
@@ -124157,9 +124827,6 @@ async function runRpcMode(runtimeHost) {
124157
124827
  return error(id, "clone", "Cannot clone session: no current entry selected");
124158
124828
  }
124159
124829
  const result = await runtimeHost.fork(leafId, { position: "at" });
124160
- if (!result.cancelled) {
124161
- await rebindSession();
124162
- }
124163
124830
  return success(id, "clone", { cancelled: result.cancelled });
124164
124831
  }
124165
124832
  case "get_fork_messages": {
@@ -124404,9 +125071,9 @@ ${otherErrors.join(`
124404
125071
  }
124405
125072
 
124406
125073
  // node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js
124407
- init_dist3();
125074
+ init_dist2();
124408
125075
  import { existsSync as existsSync26, mkdirSync as mkdirSync15, mkdtempSync as mkdtempSync3, readdirSync as readdirSync11, readFileSync as readFileSync25, renameSync as renameSync4, rmSync as rmSync10, writeFileSync as writeFileSync15 } from "node:fs";
124409
- import { join as join45, resolve as resolve16 } from "node:path";
125076
+ import { delimiter as delimiter2, dirname as dirname26, join as join45, resolve as resolve16 } from "node:path";
124410
125077
  var import_proper_lockfile4 = __toESM(require_proper_lockfile(), 1);
124411
125078
 
124412
125079
  // node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.js
@@ -124766,8 +125433,11 @@ class ResourceList {
124766
125433
  }
124767
125434
  return;
124768
125435
  }
125436
+ const previousQuery = this.searchInput.getValue();
124769
125437
  this.searchInput.handleInput(data);
124770
- this.filterItems(this.searchInput.getValue());
125438
+ const query = this.searchInput.getValue();
125439
+ if (query !== previousQuery)
125440
+ this.filterItems(query);
124771
125441
  }
124772
125442
  toggleResource(item) {
124773
125443
  if (this.writeScope === "project") {
@@ -125111,17 +125781,18 @@ async function selectConfig(options) {
125111
125781
  const ui = new TuiMainScreen(new ProcessTerminal, options.settingsManager.getShowHardwareCursor(), options.agentDir);
125112
125782
  ui.setClearOnShrink(options.settingsManager.getClearOnShrink());
125113
125783
  let resolved = false;
125784
+ const stopUi = () => {
125785
+ ui.stop();
125786
+ stopThemeWatcher();
125787
+ return flushStdout();
125788
+ };
125114
125789
  const selector = new ConfigSelectorComponent(options.resolvedPaths, options.settingsManager, options.cwd, options.agentDir, () => {
125115
125790
  if (!resolved) {
125116
125791
  resolved = true;
125117
- ui.stop();
125118
- stopThemeWatcher();
125119
- resolve();
125792
+ stopUi().then(resolve);
125120
125793
  }
125121
125794
  }, () => {
125122
- ui.stop();
125123
- stopThemeWatcher();
125124
- process.exit(0);
125795
+ stopUi().then(() => process.exit(0));
125125
125796
  }, () => ui.requestRender(), ui.terminal.rows, options.writeScope, options.projectModeAvailable);
125126
125797
  ui.addChild(selector);
125127
125798
  ui.setFocus(selector.getResourceList());
@@ -125248,11 +125919,18 @@ async function runManagedNpmCi(stageDir) {
125248
125919
  if (code !== 0)
125249
125920
  throw new Error(`npm ${args.join(" ")} exited with code ${code ?? "unknown"}`);
125250
125921
  }
125922
+ function getManagedReleaseVerifyEnv() {
125923
+ const nodeDir = dirname26(process.execPath);
125924
+ const pathKey = Object.keys(process.env).find((key) => key.toLowerCase() === "path") ?? "PATH";
125925
+ const currentPath = process.env[pathKey] ?? "";
125926
+ return { ...process.env, [pathKey]: [nodeDir, currentPath].filter(Boolean).join(delimiter2) };
125927
+ }
125251
125928
  function verifyManagedRelease(releaseDir, expectedVersion) {
125252
125929
  const binPath = join45(releaseDir, "node_modules", ".bin", process.platform === "win32" ? `${APP_NAME}.cmd` : APP_NAME);
125253
125930
  const result = spawnProcessSync(binPath, ["--version"], {
125254
125931
  encoding: "utf8",
125255
- stdio: ["ignore", "pipe", "pipe"]
125932
+ stdio: ["ignore", "pipe", "pipe"],
125933
+ env: getManagedReleaseVerifyEnv()
125256
125934
  });
125257
125935
  if (result.error || result.status !== 0) {
125258
125936
  const reason = result.error?.message || result.stderr.trim() || `exit code ${result.status ?? "unknown"}`;
@@ -126201,13 +126879,6 @@ async function readPipedStdin() {
126201
126879
  process.stdin.resume();
126202
126880
  });
126203
126881
  }
126204
- function reportDiagnostics(diagnostics) {
126205
- for (const diagnostic of diagnostics) {
126206
- const color = diagnostic.type === "error" ? source_default.red : diagnostic.type === "warning" ? source_default.yellow : source_default.dim;
126207
- const prefix = diagnostic.type === "error" ? "Error: " : diagnostic.type === "warning" ? "Warning: " : "";
126208
- console.error(color(`${prefix}${diagnostic.message}`));
126209
- }
126210
- }
126211
126882
  function isTruthyEnvFlag2(value) {
126212
126883
  if (!value)
126213
126884
  return false;
@@ -126718,6 +127389,13 @@ async function main(args, options) {
126718
127389
  const resolvedSkillPaths = resolveCliPaths(cwd, parsed.skills);
126719
127390
  const resolvedPromptTemplatePaths = resolveCliPaths(cwd, parsed.promptTemplates);
126720
127391
  const resolvedThemePaths = resolveCliPaths(cwd, parsed.themes);
127392
+ const packageCommandOutput = appMode === "interactive" ? "capture" : "inherit";
127393
+ let announcePackageInstalls = packageCommandOutput === "capture";
127394
+ const onPackageProgress = (event) => {
127395
+ if (announcePackageInstalls && event.type === "start" && event.message) {
127396
+ console.error(source_default.dim(event.message));
127397
+ }
127398
+ };
126721
127399
  const createRuntime = async ({ cwd, agentDir, sessionManager, sessionStartEvent, projectTrustContext }) => {
126722
127400
  const isInitialRuntime = sessionStartEvent === undefined;
126723
127401
  const projectTrustDiagnostics = [];
@@ -126753,6 +127431,8 @@ async function main(args, options) {
126753
127431
  }
126754
127432
  } : undefined,
126755
127433
  resourceLoaderOptions: {
127434
+ packageCommandOutput,
127435
+ onPackageProgress,
126756
127436
  additionalExtensionPaths: resolvedExtensionPaths,
126757
127437
  additionalSkillPaths: resolvedSkillPaths,
126758
127438
  additionalPromptTemplatePaths: resolvedPromptTemplatePaths,
@@ -126783,7 +127463,10 @@ async function main(args, options) {
126783
127463
  }))
126784
127464
  ];
126785
127465
  const modelPatterns = parsed.models ?? settingsManager.getEnabledModels();
126786
- const scopedModels = modelPatterns && modelPatterns.length > 0 ? await resolveModelScope(modelPatterns, modelRuntime, { signal: AbortSignal.timeout(15000) }) : [];
127466
+ const { scopedModels, diagnostics: modelScopeDiagnostics } = modelPatterns && modelPatterns.length > 0 ? await resolveModelScopeWithDiagnostics(modelPatterns, modelRuntime, {
127467
+ signal: AbortSignal.timeout(15000)
127468
+ }) : { scopedModels: [], diagnostics: [] };
127469
+ diagnostics.push(...modelScopeDiagnostics);
126787
127470
  const { options: sessionOptions, cliThinkingFromModel, diagnostics: sessionOptionDiagnostics } = buildSessionOptions(parsed, scopedModels, sessionManager.buildSessionContext().messages.length > 0, modelRuntime, settingsManager);
126788
127471
  diagnostics.push(...sessionOptionDiagnostics);
126789
127472
  if (parsed.apiKey) {
@@ -126812,6 +127495,9 @@ async function main(args, options) {
126812
127495
  if (created.session.model && cliThinkingOverride) {
126813
127496
  created.session.setThinkingLevel(created.session.thinkingLevel);
126814
127497
  }
127498
+ if (created.modelFallbackMessage && created.session.model) {
127499
+ diagnostics.push({ type: "warning", message: created.modelFallbackMessage });
127500
+ }
126815
127501
  return {
126816
127502
  ...created,
126817
127503
  services,
@@ -126830,16 +127516,19 @@ async function main(args, options) {
126830
127516
  setCapabilityOverrides(settingsManager.getTerminalCapabilityOverrides());
126831
127517
  applyHttpProxySettings(settingsManager.getGlobalSettings().httpProxy);
126832
127518
  configureHttpDispatcher(settingsManager.getHttpIdleTimeoutMs());
126833
- const startupDiagnostics = deduplicateDiagnostics([...startupSettingsDiagnostics, ...runtime.diagnostics]);
127519
+ const startupDiagnostics = deduplicateDiagnostics([
127520
+ ...startupSettingsDiagnostics,
127521
+ ...runtime.takeUnreportedDiagnostics()
127522
+ ]);
126834
127523
  const hasRuntimeErrors = runtime.diagnostics.some((diagnostic) => diagnostic.type === "error");
126835
127524
  if (parsed.help) {
126836
- reportDiagnostics(startupDiagnostics);
127525
+ writeDiagnosticsToStderr(startupDiagnostics);
126837
127526
  const extensionFlags = resourceLoader.getExtensions().extensions.flatMap((extension) => Array.from(extension.flags.values()));
126838
127527
  printHelp(extensionFlags);
126839
127528
  process.exit(0);
126840
127529
  }
126841
127530
  if (parsed.listModels !== undefined) {
126842
- reportDiagnostics(startupDiagnostics);
127531
+ writeDiagnosticsToStderr(startupDiagnostics);
126843
127532
  const searchPattern = typeof parsed.listModels === "string" ? parsed.listModels : undefined;
126844
127533
  await listModels(modelRuntime, searchPattern, AbortSignal.timeout(15000));
126845
127534
  process.exit(0);
@@ -126861,7 +127550,7 @@ async function main(args, options) {
126861
127550
  }
126862
127551
  time("resolveModelScope");
126863
127552
  if (appMode !== "interactive" || hasRuntimeErrors) {
126864
- reportDiagnostics(startupDiagnostics);
127553
+ writeDiagnosticsToStderr(startupDiagnostics);
126865
127554
  }
126866
127555
  if (hasRuntimeErrors) {
126867
127556
  if (runtime.diagnostics.some((diagnostic) => diagnostic.message.includes("Failed to load extension"))) {
@@ -126888,10 +127577,11 @@ async function main(args, options) {
126888
127577
  printTimings();
126889
127578
  await runRpcMode(runtime);
126890
127579
  } else if (appMode === "interactive") {
127580
+ announcePackageInstalls = false;
126891
127581
  const interactiveMode = new InteractiveMode(runtime, {
126892
127582
  migratedProviders,
126893
127583
  startupDiagnostics,
126894
- modelFallbackMessage,
127584
+ modelFallbackMessage: session.model ? undefined : modelFallbackMessage,
126895
127585
  autoTrustOnReloadCwd,
126896
127586
  initialMessage,
126897
127587
  initialImages,