@cursor/bdk 0.2.9 → 0.2.10

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 (570) hide show
  1. package/dist/artifacts.js +3 -5
  2. package/dist/bin/agent-serve.js +803 -812
  3. package/dist/channels/bitbucket/api.js +305 -321
  4. package/dist/channels/bitbucket/binding.js +97 -61
  5. package/dist/channels/bitbucket/bitbucket-channel.d.ts +15 -1
  6. package/dist/channels/bitbucket/bitbucket-channel.d.ts.map +1 -1
  7. package/dist/channels/bitbucket/bitbucket-channel.js +95 -42
  8. package/dist/channels/bitbucket/bitbucket-webhook.d.ts +11 -0
  9. package/dist/channels/bitbucket/bitbucket-webhook.d.ts.map +1 -1
  10. package/dist/channels/bitbucket/bitbucket-webhook.js +214 -204
  11. package/dist/channels/bitbucket/checks.js +9 -21
  12. package/dist/channels/bitbucket/cursor-account.js +1 -1
  13. package/dist/channels/bitbucket/defaults.js +14 -4
  14. package/dist/channels/bitbucket/events.js +1 -2
  15. package/dist/channels/bitbucket/index.d.ts +6 -2
  16. package/dist/channels/bitbucket/index.d.ts.map +1 -1
  17. package/dist/channels/bitbucket/index.js +6 -2
  18. package/dist/channels/bitbucket/replay.js +80 -56
  19. package/dist/channels/bitbucket/state.js +16 -7
  20. package/dist/channels/bitbucket/types.d.ts +11 -2
  21. package/dist/channels/bitbucket/types.d.ts.map +1 -1
  22. package/dist/channels/checks.js +18 -28
  23. package/dist/channels/deployments/deployments-channel.js +26 -34
  24. package/dist/channels/github/api.js +216 -210
  25. package/dist/channels/github/auth.d.ts +5 -1
  26. package/dist/channels/github/auth.d.ts.map +1 -1
  27. package/dist/channels/github/auth.js +157 -174
  28. package/dist/channels/github/binding.js +48 -39
  29. package/dist/channels/github/checks.js +9 -14
  30. package/dist/channels/github/cursor-account.js +6 -11
  31. package/dist/channels/github/defaults.js +105 -130
  32. package/dist/channels/github/forward.js +13 -17
  33. package/dist/channels/github/github-channel.d.ts +43 -2
  34. package/dist/channels/github/github-channel.d.ts.map +1 -1
  35. package/dist/channels/github/github-channel.js +1228 -958
  36. package/dist/channels/github/progress.js +145 -146
  37. package/dist/channels/github/replay.js +30 -39
  38. package/dist/channels/github/state.js +40 -16
  39. package/dist/channels/github/types.d.ts +30 -6
  40. package/dist/channels/github/types.d.ts.map +1 -1
  41. package/dist/channels/gitlab/api.js +100 -114
  42. package/dist/channels/gitlab/binding.js +52 -33
  43. package/dist/channels/gitlab/checks.js +28 -29
  44. package/dist/channels/gitlab/cursor-account.js +1 -1
  45. package/dist/channels/gitlab/defaults.js +9 -3
  46. package/dist/channels/gitlab/gitlab-channel.d.ts +16 -1
  47. package/dist/channels/gitlab/gitlab-channel.d.ts.map +1 -1
  48. package/dist/channels/gitlab/gitlab-channel.js +95 -42
  49. package/dist/channels/gitlab/gitlab-webhook.d.ts +10 -1
  50. package/dist/channels/gitlab/gitlab-webhook.d.ts.map +1 -1
  51. package/dist/channels/gitlab/gitlab-webhook.js +282 -249
  52. package/dist/channels/gitlab/index.d.ts +6 -2
  53. package/dist/channels/gitlab/index.d.ts.map +1 -1
  54. package/dist/channels/gitlab/index.js +6 -2
  55. package/dist/channels/gitlab/replay.js +50 -27
  56. package/dist/channels/gitlab/state.js +14 -6
  57. package/dist/channels/gitlab/types.d.ts +13 -2
  58. package/dist/channels/gitlab/types.d.ts.map +1 -1
  59. package/dist/channels/origin/api.js +100 -116
  60. package/dist/channels/origin/binding.js +15 -16
  61. package/dist/channels/origin/checks.js +30 -28
  62. package/dist/channels/origin/defaults.js +50 -65
  63. package/dist/channels/origin/origin-channel.js +266 -272
  64. package/dist/channels/origin/origin-webhook.js +70 -88
  65. package/dist/channels/origin/reactions.js +9 -21
  66. package/dist/channels/origin/state.js +13 -5
  67. package/dist/channels/slack/agentic-delivery.js +426 -478
  68. package/dist/channels/slack/agentic-posted.js +9 -10
  69. package/dist/channels/slack/agentic-signals.js +2 -3
  70. package/dist/channels/slack/api.js +417 -427
  71. package/dist/channels/slack/approvals.js +1 -1
  72. package/dist/channels/slack/assistant.js +37 -47
  73. package/dist/channels/slack/attachments.js +188 -206
  74. package/dist/channels/slack/auth.js +8 -6
  75. package/dist/channels/slack/bot-mentions.js +31 -45
  76. package/dist/channels/slack/channel-watch.js +42 -48
  77. package/dist/channels/slack/cli-project.js +112 -137
  78. package/dist/channels/slack/code-fences.js +3 -5
  79. package/dist/channels/slack/constants.js +2 -2
  80. package/dist/channels/slack/credentials.js +23 -38
  81. package/dist/channels/slack/defaults.js +292 -331
  82. package/dist/channels/slack/dispatch.d.ts.map +1 -1
  83. package/dist/channels/slack/dispatch.js +533 -460
  84. package/dist/channels/slack/doctor.js +200 -214
  85. package/dist/channels/slack/eval-directive.js +79 -96
  86. package/dist/channels/slack/event-id-dedupe.js +1 -1
  87. package/dist/channels/slack/external-policy.js +26 -39
  88. package/dist/channels/slack/footer.js +28 -41
  89. package/dist/channels/slack/inbound.d.ts +1 -0
  90. package/dist/channels/slack/inbound.d.ts.map +1 -1
  91. package/dist/channels/slack/inbound.js +50 -31
  92. package/dist/channels/slack/init.d.ts +1 -5
  93. package/dist/channels/slack/init.d.ts.map +1 -1
  94. package/dist/channels/slack/init.js +42 -59
  95. package/dist/channels/slack/interactive.d.ts +9 -3
  96. package/dist/channels/slack/interactive.d.ts.map +1 -1
  97. package/dist/channels/slack/interactive.js +160 -162
  98. package/dist/channels/slack/links.js +1 -2
  99. package/dist/channels/slack/live-delivery.js +172 -190
  100. package/dist/channels/slack/manifest.d.ts.map +1 -1
  101. package/dist/channels/slack/manifest.js +44 -23
  102. package/dist/channels/slack/message-body.js +2 -2
  103. package/dist/channels/slack/nudge-carrier.js +30 -42
  104. package/dist/channels/slack/nudge-store.js +164 -191
  105. package/dist/channels/slack/paint-start.js +66 -81
  106. package/dist/channels/slack/placeholder.js +123 -152
  107. package/dist/channels/slack/pr-ref.js +1 -1
  108. package/dist/channels/slack/progress-delivery.js +65 -78
  109. package/dist/channels/slack/reasoning-card.js +36 -49
  110. package/dist/channels/slack/recording-sink.js +12 -24
  111. package/dist/channels/slack/reply-options.js +7 -12
  112. package/dist/channels/slack/self-identity.js +27 -35
  113. package/dist/channels/slack/sender-name.d.ts +12 -3
  114. package/dist/channels/slack/sender-name.d.ts.map +1 -1
  115. package/dist/channels/slack/sender-name.js +57 -61
  116. package/dist/channels/slack/setup.js +2 -4
  117. package/dist/channels/slack/slack-channel.d.ts +6 -4
  118. package/dist/channels/slack/slack-channel.d.ts.map +1 -1
  119. package/dist/channels/slack/slack-channel.js +441 -308
  120. package/dist/channels/slack/socket-mode.js +38 -52
  121. package/dist/channels/slack/thread-context.js +143 -160
  122. package/dist/channels/slack/tool-approval-events.js +149 -166
  123. package/dist/channels/slack/tool-cards.js +6 -11
  124. package/dist/channels/slack/tool-chip.js +1 -2
  125. package/dist/channels/slack/types.d.ts +15 -17
  126. package/dist/channels/slack/types.d.ts.map +1 -1
  127. package/dist/channels/slack/upload.js +84 -97
  128. package/dist/channels/slack/user-info.js +27 -41
  129. package/dist/channels.js +9 -20
  130. package/dist/dashboard-session-url.js +3 -4
  131. package/dist/docs/404.html +2 -2
  132. package/dist/docs/assets/{app.BNhEdGa8.js → app.DXI7bwox.js} +4 -4
  133. package/dist/docs/assets/{building-with-agents.md.BPjPFxFg.js → building-with-agents.md.Df87rAe1.js} +1 -1
  134. package/dist/docs/assets/chunks/@localSearchIndexroot.CtLtpWcx.js +1 -0
  135. package/dist/docs/assets/chunks/{VPLocalSearchBox.DIdUV1Ph.js → VPLocalSearchBox.BrbO5mEe.js} +1 -1
  136. package/dist/docs/assets/chunks/{arc.lELI4_SR.js → arc.BOG1yms8.js} +1 -1
  137. package/dist/docs/assets/chunks/{architectureDiagram-Q4EWVU46.iCMdvuoM.js → architectureDiagram-Q4EWVU46.C0hsMZnZ.js} +1 -1
  138. package/dist/docs/assets/chunks/{baseUniq.C1-nDJBf.js → baseUniq.H044KjKs.js} +1 -1
  139. package/dist/docs/assets/chunks/{blockDiagram-DXYQGD6D.ClemzBox.js → blockDiagram-DXYQGD6D.BsRW6GoB.js} +1 -1
  140. package/dist/docs/assets/chunks/{c4Diagram-AHTNJAMY.BqTak6cR.js → c4Diagram-AHTNJAMY.B9HV5PFR.js} +1 -1
  141. package/dist/docs/assets/chunks/channel.CBwrU9rP.js +1 -0
  142. package/dist/docs/assets/chunks/{chunk-4BX2VUAB.CUS3qs_R.js → chunk-4BX2VUAB.CPoT_ajl.js} +1 -1
  143. package/dist/docs/assets/chunks/{chunk-4TB4RGXK.dz5fdHcl.js → chunk-4TB4RGXK.DZBwWuCL.js} +1 -1
  144. package/dist/docs/assets/chunks/{chunk-55IACEB6.D6BEBmve.js → chunk-55IACEB6.CZ3yTiyq.js} +1 -1
  145. package/dist/docs/assets/chunks/{chunk-EDXVE4YY.B5uK4ID9.js → chunk-EDXVE4YY.6DfvHSd8.js} +1 -1
  146. package/dist/docs/assets/chunks/{chunk-FMBD7UC4.PgOJgNQs.js → chunk-FMBD7UC4.CpBj8HfK.js} +1 -1
  147. package/dist/docs/assets/chunks/{chunk-OYMX7WX6.CvkTrCii.js → chunk-OYMX7WX6.BdKo8YqS.js} +1 -1
  148. package/dist/docs/assets/chunks/{chunk-QZHKN3VN.BnSfKYsB.js → chunk-QZHKN3VN.BnXNyxJx.js} +1 -1
  149. package/dist/docs/assets/chunks/{chunk-YZCP3GAM.MZH6v5UC.js → chunk-YZCP3GAM.Cg1OcF8G.js} +1 -1
  150. package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.CbC_mrvB.js +1 -0
  151. package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.CbC_mrvB.js +1 -0
  152. package/dist/docs/assets/chunks/clone.BTvFyY1a.js +1 -0
  153. package/dist/docs/assets/chunks/{cose-bilkent-S5V4N54A.BBbw_YZi.js → cose-bilkent-S5V4N54A.1SP8al9c.js} +1 -1
  154. package/dist/docs/assets/chunks/{dagre-KV5264BT.CNJB2l7E.js → dagre-KV5264BT.DS1L6hJt.js} +1 -1
  155. package/dist/docs/assets/chunks/{diagram-5BDNPKRD.BQzlnFfq.js → diagram-5BDNPKRD.ChsausbG.js} +1 -1
  156. package/dist/docs/assets/chunks/{diagram-G4DWMVQ6.DkgqqZMz.js → diagram-G4DWMVQ6.3XsptNWj.js} +1 -1
  157. package/dist/docs/assets/chunks/{diagram-MMDJMWI5.DIT8L7H_.js → diagram-MMDJMWI5.DPA9Dk_P.js} +1 -1
  158. package/dist/docs/assets/chunks/{diagram-TYMM5635.3xLPZWGJ.js → diagram-TYMM5635.BVswXWrB.js} +1 -1
  159. package/dist/docs/assets/chunks/{erDiagram-SMLLAGMA.5_IHz8jF.js → erDiagram-SMLLAGMA.BSak5OSP.js} +1 -1
  160. package/dist/docs/assets/chunks/{flowDiagram-DWJPFMVM.BGUCXz8A.js → flowDiagram-DWJPFMVM.CQgN4TTz.js} +1 -1
  161. package/dist/docs/assets/chunks/{ganttDiagram-T4ZO3ILL.DbfFavS1.js → ganttDiagram-T4ZO3ILL.GrT0kA4a.js} +1 -1
  162. package/dist/docs/assets/chunks/{gitGraphDiagram-UUTBAWPF.D2yKdeNW.js → gitGraphDiagram-UUTBAWPF.CdS7Ucll.js} +1 -1
  163. package/dist/docs/assets/chunks/{graph.CSCxwHba.js → graph.BVqKRmRo.js} +1 -1
  164. package/dist/docs/assets/chunks/{infoDiagram-42DDH7IO.FDeb6xHY.js → infoDiagram-42DDH7IO.C3C9FRto.js} +1 -1
  165. package/dist/docs/assets/chunks/{ishikawaDiagram-UXIWVN3A.DbeYs9VL.js → ishikawaDiagram-UXIWVN3A.2FuAh_Zj.js} +1 -1
  166. package/dist/docs/assets/chunks/{journeyDiagram-VCZTEJTY.CWjKINpx.js → journeyDiagram-VCZTEJTY.CaHMfK4b.js} +1 -1
  167. package/dist/docs/assets/chunks/{kanban-definition-6JOO6SKY.B4FrAlwz.js → kanban-definition-6JOO6SKY.CjhIUwcA.js} +1 -1
  168. package/dist/docs/assets/chunks/{layout.DFGxQ9ab.js → layout.CGU3gfSf.js} +1 -1
  169. package/dist/docs/assets/chunks/{linear.BmjZ-G59.js → linear.DaihpW_n.js} +1 -1
  170. package/dist/docs/assets/chunks/{min.DZSxulMW.js → min.BS-j8kHQ.js} +1 -1
  171. package/dist/docs/assets/chunks/{mindmap-definition-QFDTVHPH.CHLi3-aN.js → mindmap-definition-QFDTVHPH.BVJ1Bbnk.js} +1 -1
  172. package/dist/docs/assets/chunks/{pieDiagram-DEJITSTG.DteG-CkU.js → pieDiagram-DEJITSTG.Cz1WIv9r.js} +1 -1
  173. package/dist/docs/assets/chunks/{quadrantDiagram-34T5L4WZ.D458ipN3.js → quadrantDiagram-34T5L4WZ.DKLFxcjy.js} +1 -1
  174. package/dist/docs/assets/chunks/{requirementDiagram-MS252O5E.DcFgUxst.js → requirementDiagram-MS252O5E.BHegiK7x.js} +1 -1
  175. package/dist/docs/assets/chunks/{sankeyDiagram-XADWPNL6.BwQAMmSA.js → sankeyDiagram-XADWPNL6.DYkY6yPc.js} +1 -1
  176. package/dist/docs/assets/chunks/{sequenceDiagram-FGHM5R23.B_Xdsrh9.js → sequenceDiagram-FGHM5R23.DYQ1QUrI.js} +1 -1
  177. package/dist/docs/assets/chunks/{stateDiagram-FHFEXIEX.CdfDW6-C.js → stateDiagram-FHFEXIEX.Iru8BsFo.js} +1 -1
  178. package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.BYXl4LW6.js +1 -0
  179. package/dist/docs/assets/chunks/{theme.sfdL3srp.js → theme.DaplWQhQ.js} +2 -2
  180. package/dist/docs/assets/chunks/{timeline-definition-GMOUNBTQ.56-4hXaC.js → timeline-definition-GMOUNBTQ.BwFA8hiX.js} +1 -1
  181. package/dist/docs/assets/chunks/{vennDiagram-DHZGUBPP.CvZSQBO7.js → vennDiagram-DHZGUBPP.CZ60W1C_.js} +1 -1
  182. package/dist/docs/assets/chunks/{wardley-RL74JXVD.C9qc8k39.js → wardley-RL74JXVD.iXazD3Z7.js} +1 -1
  183. package/dist/docs/assets/chunks/{wardleyDiagram-NUSXRM2D.D9s0nihi.js → wardleyDiagram-NUSXRM2D.B69D2r8-.js} +1 -1
  184. package/dist/docs/assets/chunks/{xychartDiagram-5P7HB3ND.BVJSpYrC.js → xychartDiagram-5P7HB3ND.CLPZEIU9.js} +1 -1
  185. package/dist/docs/assets/{deployment.md.BdqTiGdc.js → deployment.md.BYuEcDBv.js} +2 -2
  186. package/dist/docs/assets/{guides_bitbucket.md.BB6fqD-M.js → guides_bitbucket.md.CKUayYtD.js} +3 -3
  187. package/dist/docs/assets/{guides_bitbucket.md.BB6fqD-M.lean.js → guides_bitbucket.md.CKUayYtD.lean.js} +1 -1
  188. package/dist/docs/assets/{guides_github.md.Cr1Xlf-m.js → guides_github.md.TuNiZAOQ.js} +4 -4
  189. package/dist/docs/assets/{guides_github.md.Cr1Xlf-m.lean.js → guides_github.md.TuNiZAOQ.lean.js} +1 -1
  190. package/dist/docs/assets/{guides_gitlab.md.CMpmFi4M.js → guides_gitlab.md.CtNI4fSH.js} +4 -4
  191. package/dist/docs/assets/{guides_gitlab.md.CMpmFi4M.lean.js → guides_gitlab.md.CtNI4fSH.lean.js} +1 -1
  192. package/dist/docs/assets/guides_migrate.md.sCAvvlC6.js +7 -0
  193. package/dist/docs/assets/guides_migrate.md.sCAvvlC6.lean.js +1 -0
  194. package/dist/docs/assets/{reference_cli.md.GwugN3n-.js → reference_cli.md.dYCAL2lB.js} +4 -3
  195. package/dist/docs/assets/reference_cli.md.dYCAL2lB.lean.js +1 -0
  196. package/dist/docs/assets/{reference_skills.md.ClkMoQsV.js → reference_skills.md.C0guGcH0.js} +3 -3
  197. package/dist/docs/assets/troubleshooting.md.x-GBa7wN.js +1 -0
  198. package/dist/docs/assets/{troubleshooting.md.Bscj6ODe.lean.js → troubleshooting.md.x-GBa7wN.lean.js} +1 -1
  199. package/dist/docs/building-with-agents.html +37 -37
  200. package/dist/docs/building-with-agents.md +2 -0
  201. package/dist/docs/deployment.html +38 -38
  202. package/dist/docs/deployment.md +7 -0
  203. package/dist/docs/evals.html +36 -36
  204. package/dist/docs/guides/agent-to-agent.html +35 -35
  205. package/dist/docs/guides/bitbucket.html +38 -38
  206. package/dist/docs/guides/bitbucket.md +9 -1
  207. package/dist/docs/guides/cloud-agents.html +35 -35
  208. package/dist/docs/guides/convert-automation.html +35 -35
  209. package/dist/docs/guides/github.html +39 -39
  210. package/dist/docs/guides/github.md +20 -4
  211. package/dist/docs/guides/gitlab.html +38 -38
  212. package/dist/docs/guides/gitlab.md +9 -1
  213. package/dist/docs/guides/grokbot-agents.html +35 -35
  214. package/dist/docs/guides/hooks.html +35 -35
  215. package/dist/docs/guides/improve.html +35 -35
  216. package/dist/docs/guides/jev.html +35 -35
  217. package/dist/docs/guides/mcp-oauth.html +35 -35
  218. package/dist/docs/guides/migrate.html +66 -0
  219. package/dist/docs/guides/migrate.md +122 -0
  220. package/dist/docs/guides/opentelemetry.html +35 -35
  221. package/dist/docs/guides/slack.html +35 -35
  222. package/dist/docs/guides/webhooks.html +35 -35
  223. package/dist/docs/hashmap.json +1 -1
  224. package/dist/docs/hillclimbing.html +35 -35
  225. package/dist/docs/index.html +35 -35
  226. package/dist/docs/llms-full.txt +214 -6
  227. package/dist/docs/llms.txt +1 -0
  228. package/dist/docs/quickstart.html +35 -35
  229. package/dist/docs/reference/agent-config.html +35 -35
  230. package/dist/docs/reference/artifacts.html +35 -35
  231. package/dist/docs/reference/channels.html +35 -35
  232. package/dist/docs/reference/cli.html +39 -38
  233. package/dist/docs/reference/cli.md +39 -0
  234. package/dist/docs/reference/connections.html +35 -35
  235. package/dist/docs/reference/evals.html +35 -35
  236. package/dist/docs/reference/extensions.html +35 -35
  237. package/dist/docs/reference/hooks.html +35 -35
  238. package/dist/docs/reference/http-api.html +35 -35
  239. package/dist/docs/reference/instructions.html +35 -35
  240. package/dist/docs/reference/playground.html +35 -35
  241. package/dist/docs/reference/project-layout.html +35 -35
  242. package/dist/docs/reference/prompt.html +35 -35
  243. package/dist/docs/reference/schedules.html +35 -35
  244. package/dist/docs/reference/sessions.html +35 -35
  245. package/dist/docs/reference/skills.html +38 -38
  246. package/dist/docs/reference/subagents.html +35 -35
  247. package/dist/docs/reference/tools.html +35 -35
  248. package/dist/docs/templates/agentic-owners.html +35 -35
  249. package/dist/docs/templates/grokbot-agents.html +35 -35
  250. package/dist/docs/templates/security-reviewer.html +35 -35
  251. package/dist/docs/templates/thermo-quality-review.html +35 -35
  252. package/dist/docs/templates/thermo-review.html +35 -35
  253. package/dist/docs/templates/triage.html +35 -35
  254. package/dist/docs/troubleshooting.html +36 -36
  255. package/dist/docs/troubleshooting.md +1 -0
  256. package/dist/evals/assertions.js +20 -34
  257. package/dist/evals/expect.js +3 -6
  258. package/dist/evals/judge.js +5 -8
  259. package/dist/evals/loaders.js +45 -62
  260. package/dist/evals/matchers.js +2 -3
  261. package/dist/evals/reporters.js +43 -67
  262. package/dist/evals/results.js +1 -1
  263. package/dist/evals/run-facts.js +5 -6
  264. package/dist/evals.js +27 -15
  265. package/dist/extensions/cursor-cloud-agents/extension.js +4 -1
  266. package/dist/extensions/cursor-cloud-agents/lib/backend.js +100 -126
  267. package/dist/extensions/cursor-cloud-agents/lib/fleet.js +22 -38
  268. package/dist/extensions/cursor-cloud-agents/lib/repos.js +8 -10
  269. package/dist/extensions/cursor-cloud-agents/lib/transcript.js +2 -3
  270. package/dist/extensions/cursor-cloud-agents/lib/watch.js +52 -66
  271. package/dist/extensions/cursor-cloud-agents/reminders/cloud-agent-stop-watch.js +29 -40
  272. package/dist/extensions/cursor-cloud-agents/tools/cancel.js +6 -17
  273. package/dist/extensions/cursor-cloud-agents/tools/dump.js +25 -36
  274. package/dist/extensions/cursor-cloud-agents/tools/get.js +3 -14
  275. package/dist/extensions/cursor-cloud-agents/tools/launch.js +13 -21
  276. package/dist/extensions/cursor-cloud-agents/tools/list.js +8 -19
  277. package/dist/extensions/cursor-cloud-agents/tools/reply.js +5 -16
  278. package/dist/extensions/cursor-grokbot-agents/extension.js +4 -1
  279. package/dist/extensions/cursor-grokbot-agents/lib/agents.js +3 -3
  280. package/dist/extensions/cursor-grokbot-agents/lib/backend.js +53 -73
  281. package/dist/extensions/cursor-grokbot-agents/lib/contacts.js +10 -23
  282. package/dist/extensions/cursor-grokbot-agents/lib/conversation.js +112 -132
  283. package/dist/extensions/cursor-grokbot-agents/lib/lock.js +1 -2
  284. package/dist/extensions/cursor-grokbot-agents/tools/ask.js +5 -16
  285. package/dist/extensions/cursor-grokbot-agents/tools/check.js +4 -15
  286. package/dist/extensions/cursor-grokbot-agents/tools/interrupt.js +2 -13
  287. package/dist/extensions/cursor-grokbot-agents/tools/list.js +11 -23
  288. package/dist/extensions/jev/extension.js +3 -3
  289. package/dist/extensions/jev/lib/evaluate.js +43 -60
  290. package/dist/extensions/jev/tools/evaluate.js +6 -17
  291. package/dist/extensions/slack-communication/tools/post-file.js +1 -1
  292. package/dist/extensions.js +3 -5
  293. package/dist/files-backends/cursor-hosted.js +504 -523
  294. package/dist/files-backends/local-fs.js +72 -134
  295. package/dist/files.js +3 -3
  296. package/dist/filesystem.js +562 -861
  297. package/dist/index.js +16 -35
  298. package/dist/internal/advertise-tools.js +74 -86
  299. package/dist/internal/artifacts-store.js +298 -361
  300. package/dist/internal/as-of.js +2 -4
  301. package/dist/internal/authored-alias-hooks.js +6 -4
  302. package/dist/internal/authored-loaders.js +37 -52
  303. package/dist/internal/bounded-int.js +1 -2
  304. package/dist/internal/bounded.js +13 -24
  305. package/dist/internal/brand.js +1 -1
  306. package/dist/internal/browser-origin-guard.js +4 -4
  307. package/dist/internal/builtin-tools/artifacts.js +15 -27
  308. package/dist/internal/builtin-tools/index.js +2 -3
  309. package/dist/internal/builtin-tools/reminders.js +33 -52
  310. package/dist/internal/channel-architecture.d.ts +21 -0
  311. package/dist/internal/channel-architecture.d.ts.map +1 -0
  312. package/dist/internal/channel-architecture.js +41 -0
  313. package/dist/internal/channel-dispatch.js +3 -4
  314. package/dist/internal/channel-route-dispatch.js +40 -51
  315. package/dist/internal/channel-state.js +1 -1
  316. package/dist/internal/chat-client.js +319 -340
  317. package/dist/internal/cli-ax.js +1262 -1294
  318. package/dist/internal/cli-bitbucket.js +244 -272
  319. package/dist/internal/cli-convert-automation.js +137 -151
  320. package/dist/internal/cli-cursor.js +126 -147
  321. package/dist/internal/cli-deploy.d.ts.map +1 -1
  322. package/dist/internal/cli-deploy.js +1457 -1507
  323. package/dist/internal/cli-docs.js +130 -147
  324. package/dist/internal/cli-github.js +437 -476
  325. package/dist/internal/cli-gitlab.js +259 -288
  326. package/dist/internal/cli-images.js +266 -334
  327. package/dist/internal/cli-manifest.js +25 -37
  328. package/dist/internal/cli-mcp-oauth.js +228 -247
  329. package/dist/internal/cli-mcp.js +358 -383
  330. package/dist/internal/cli-migrate.js +73 -90
  331. package/dist/internal/cli-skills.js +35 -47
  332. package/dist/internal/cli-slack-manual.d.ts +0 -1
  333. package/dist/internal/cli-slack-manual.d.ts.map +1 -1
  334. package/dist/internal/cli-slack-manual.js +175 -204
  335. package/dist/internal/cli-slack.d.ts +1 -1
  336. package/dist/internal/cli-slack.d.ts.map +1 -1
  337. package/dist/internal/cli-slack.js +416 -456
  338. package/dist/internal/cloud-merge.js +7 -3
  339. package/dist/internal/cloud-turn-cost.js +8 -1
  340. package/dist/internal/connection-env.js +5 -6
  341. package/dist/internal/continuation-channel.js +10 -7
  342. package/dist/internal/continuation-identity.js +85 -67
  343. package/dist/internal/conversation-mirror.js +112 -131
  344. package/dist/internal/convert-automation/convert-workflow.js +21 -31
  345. package/dist/internal/cron.js +3 -3
  346. package/dist/internal/cursor/account-mcp.js +147 -146
  347. package/dist/internal/cursor/backend-client.js +290 -320
  348. package/dist/internal/cursor/bound-secret-file.js +3 -3
  349. package/dist/internal/cursor/credentials.js +127 -142
  350. package/dist/internal/cursor/cursor-api-transport.js +4 -8
  351. package/dist/internal/cursor/github-credentials.js +91 -108
  352. package/dist/internal/cursor/hosted-bound-secrets.js +3 -4
  353. package/dist/internal/cursor/hosted-deployment-secrets.js +1 -1
  354. package/dist/internal/cursor/hosted-store-secrets.js +5 -9
  355. package/dist/internal/cursor/session-token.js +36 -48
  356. package/dist/internal/cursor/store-api-client.js +77 -92
  357. package/dist/internal/cursor-account-mcp-auth.js +132 -149
  358. package/dist/internal/cursor-agent-template.js +1 -1
  359. package/dist/internal/cursor-deployment-relay.js +33 -54
  360. package/dist/internal/cursor-event-relay.js +65 -59
  361. package/dist/internal/cursor-relay-core.js +258 -286
  362. package/dist/internal/deferred-channel-session.js +3 -12
  363. package/dist/internal/deploy-client.js +410 -475
  364. package/dist/internal/deploy-manifest.d.ts +17 -0
  365. package/dist/internal/deploy-manifest.d.ts.map +1 -1
  366. package/dist/internal/deploy-manifest.js +71 -21
  367. package/dist/internal/deploy-source.js +31 -43
  368. package/dist/internal/discovery/agent-config.js +45 -59
  369. package/dist/internal/discovery/agent.js +276 -280
  370. package/dist/internal/discovery/channels.js +67 -80
  371. package/dist/internal/discovery/connections.js +286 -296
  372. package/dist/internal/discovery/context.js +2 -13
  373. package/dist/internal/discovery/cursor-plugin.js +223 -259
  374. package/dist/internal/discovery/extension-overlay.js +104 -131
  375. package/dist/internal/discovery/extensions.js +276 -281
  376. package/dist/internal/discovery/fs.js +56 -79
  377. package/dist/internal/discovery/hooks.js +39 -50
  378. package/dist/internal/discovery/info.js +17 -19
  379. package/dist/internal/discovery/instructions.js +58 -71
  380. package/dist/internal/discovery/modules.js +45 -58
  381. package/dist/internal/discovery/project.d.ts.map +1 -1
  382. package/dist/internal/discovery/project.js +192 -215
  383. package/dist/internal/discovery/reminders.js +41 -52
  384. package/dist/internal/discovery/runtime.js +1 -1
  385. package/dist/internal/discovery/schedules.js +71 -82
  386. package/dist/internal/discovery/seed-files.js +21 -32
  387. package/dist/internal/discovery/services.js +74 -96
  388. package/dist/internal/discovery/skills.js +77 -94
  389. package/dist/internal/discovery/subagent.js +79 -95
  390. package/dist/internal/discovery/tools.js +12 -23
  391. package/dist/internal/distribution.js +2 -2
  392. package/dist/internal/docs-site.js +30 -45
  393. package/dist/internal/duration.js +1 -1
  394. package/dist/internal/env-file.js +48 -64
  395. package/dist/internal/eval-judge-model.js +17 -28
  396. package/dist/internal/eval-run-store.js +265 -254
  397. package/dist/internal/eval-runner.d.ts +8 -0
  398. package/dist/internal/eval-runner.d.ts.map +1 -1
  399. package/dist/internal/eval-runner.js +406 -408
  400. package/dist/internal/eval-transport.d.ts +24 -0
  401. package/dist/internal/eval-transport.d.ts.map +1 -0
  402. package/dist/internal/eval-transport.js +22 -0
  403. package/dist/internal/evals-client.js +242 -246
  404. package/dist/internal/event-log.js +72 -120
  405. package/dist/internal/event-mapper.js +30 -31
  406. package/dist/internal/factory-resource-channel.js +16 -30
  407. package/dist/internal/filesystem/errors.js +6 -6
  408. package/dist/internal/filesystem/format.js +10 -13
  409. package/dist/internal/filesystem/merge.js +52 -94
  410. package/dist/internal/filesystem/nearest.js +15 -27
  411. package/dist/internal/filesystem/scratch.js +65 -85
  412. package/dist/internal/filesystem/tools.js +221 -241
  413. package/dist/internal/filesystem/walk.js +76 -143
  414. package/dist/internal/framework-file-storage.js +118 -139
  415. package/dist/internal/framework-storage-selection.js +21 -13
  416. package/dist/internal/frontmatter.js +4 -6
  417. package/dist/internal/github-fanout.js +50 -64
  418. package/dist/internal/guest-network.js +96 -109
  419. package/dist/internal/handleAgentServeTrigger.js +121 -126
  420. package/dist/internal/host-files.js +73 -88
  421. package/dist/internal/host-kv.js +21 -36
  422. package/dist/internal/host-otel.js +22 -19
  423. package/dist/internal/host-platforms.js +49 -63
  424. package/dist/internal/hosted-catch-protocol.d.ts +1 -0
  425. package/dist/internal/hosted-catch-protocol.d.ts.map +1 -1
  426. package/dist/internal/hosted-catch-protocol.js +1 -0
  427. package/dist/internal/hosted-catch.d.ts +5 -3
  428. package/dist/internal/hosted-catch.d.ts.map +1 -1
  429. package/dist/internal/hosted-catch.js +84 -93
  430. package/dist/internal/hosted-delivery-protocol.js +32 -8
  431. package/dist/internal/hosted-delivery.d.ts +13 -1
  432. package/dist/internal/hosted-delivery.d.ts.map +1 -1
  433. package/dist/internal/hosted-delivery.js +614 -584
  434. package/dist/internal/hosted-eval-cases.d.ts +21 -0
  435. package/dist/internal/hosted-eval-cases.d.ts.map +1 -0
  436. package/dist/internal/hosted-eval-cases.js +162 -0
  437. package/dist/internal/hosted-execution-diag.js +38 -30
  438. package/dist/internal/hosted-execution-flush.js +75 -66
  439. package/dist/internal/hosted-execution-latency.js +16 -8
  440. package/dist/internal/hosted-managed-automation.js +2 -2
  441. package/dist/internal/hosting.js +2 -3
  442. package/dist/internal/http-channel-define.js +4 -1
  443. package/dist/internal/http-channel.js +101 -112
  444. package/dist/internal/http-control-plane-session.d.ts +18 -1
  445. package/dist/internal/http-control-plane-session.d.ts.map +1 -1
  446. package/dist/internal/http-control-plane-session.js +66 -32
  447. package/dist/internal/incoming-headers-to-fetch.js +1 -2
  448. package/dist/internal/init-interview.js +73 -93
  449. package/dist/internal/init-project.js +182 -214
  450. package/dist/internal/init-scaffold.js +10 -21
  451. package/dist/internal/inline-stdio-mcp.js +80 -86
  452. package/dist/internal/install-cursor-skills.js +231 -273
  453. package/dist/internal/legacy-command-guard.js +18 -31
  454. package/dist/internal/listen-port.js +34 -45
  455. package/dist/internal/local-control-plane.js +293 -307
  456. package/dist/internal/local-env.js +1 -1
  457. package/dist/internal/local-ingress.js +15 -9
  458. package/dist/internal/log-ring.js +1 -2
  459. package/dist/internal/logs-client.js +207 -227
  460. package/dist/internal/map-pool.js +24 -38
  461. package/dist/internal/mcp-endpoint.js +204 -180
  462. package/dist/internal/mcp-host.js +165 -168
  463. package/dist/internal/mcp-oauth-on-demand.js +170 -207
  464. package/dist/internal/mcp-oauth-persist.js +15 -29
  465. package/dist/internal/mcp-oauth.js +209 -266
  466. package/dist/internal/named-webhook-secret.d.ts +39 -0
  467. package/dist/internal/named-webhook-secret.d.ts.map +1 -0
  468. package/dist/internal/named-webhook-secret.js +47 -0
  469. package/dist/internal/open-browser.js +2 -3
  470. package/dist/internal/otel/collector.js +104 -68
  471. package/dist/internal/otel/config.js +24 -37
  472. package/dist/internal/otel/http.js +5 -7
  473. package/dist/internal/otel/mcp.js +3 -12
  474. package/dist/internal/otel/runtime.js +69 -83
  475. package/dist/internal/package-inline-stdio.js +57 -65
  476. package/dist/internal/peer-connections.js +9 -5
  477. package/dist/internal/platform-schedule-sync.js +39 -54
  478. package/dist/internal/platform-timers.js +176 -210
  479. package/dist/internal/playground/static.js +1 -2
  480. package/dist/internal/playground/toolchain.js +37 -53
  481. package/dist/internal/playground-proxy.js +230 -270
  482. package/dist/internal/process-memory-telemetry.js +33 -51
  483. package/dist/internal/prompt-context.js +3 -6
  484. package/dist/internal/reminder-control-plane-protocol.js +46 -13
  485. package/dist/internal/reminder-runner.js +770 -785
  486. package/dist/internal/reminder-schedule.js +1 -1
  487. package/dist/internal/reminder-store.js +57 -78
  488. package/dist/internal/request-error-status.js +1 -3
  489. package/dist/internal/request-headers.js +2 -2
  490. package/dist/internal/resolve-prod-target.js +119 -135
  491. package/dist/internal/resolved-connections.js +16 -6
  492. package/dist/internal/run-client.js +221 -229
  493. package/dist/internal/runtime-dispatch-runner.js +18 -43
  494. package/dist/internal/schedule-runner.js +49 -58
  495. package/dist/internal/scm/pr-url.js +7 -6
  496. package/dist/internal/sdk-runner.js +388 -363
  497. package/dist/internal/serve-restart.js +26 -39
  498. package/dist/internal/server.d.ts.map +1 -1
  499. package/dist/internal/server.js +1283 -1244
  500. package/dist/internal/session-cost.js +7 -9
  501. package/dist/internal/session-engine.d.ts +3 -1
  502. package/dist/internal/session-engine.d.ts.map +1 -1
  503. package/dist/internal/session-engine.js +2801 -2777
  504. package/dist/internal/session-links.js +12 -16
  505. package/dist/internal/session-run-log.js +134 -82
  506. package/dist/internal/session-store.js +133 -164
  507. package/dist/internal/sessions-client.js +97 -118
  508. package/dist/internal/skill-catalog.js +18 -23
  509. package/dist/internal/skills-sync.js +16 -30
  510. package/dist/internal/slack-provision-client.js +90 -116
  511. package/dist/internal/start-log-store.js +48 -67
  512. package/dist/internal/steering.js +1 -2
  513. package/dist/internal/storage-coordinator.js +160 -196
  514. package/dist/internal/store-mirror.js +16 -30
  515. package/dist/internal/stream-progress.js +6 -8
  516. package/dist/internal/terminal-style.js +3 -4
  517. package/dist/internal/testing/scm-continuation-fixtures.js +6 -2
  518. package/dist/internal/testing/slack-continuation-fixtures.d.ts +26 -0
  519. package/dist/internal/testing/slack-continuation-fixtures.d.ts.map +1 -0
  520. package/dist/internal/testing/slack-continuation-fixtures.js +136 -0
  521. package/dist/internal/tool-catalog.js +11 -5
  522. package/dist/internal/tool-result.js +1 -1
  523. package/dist/internal/trajectory.js +19 -22
  524. package/dist/internal/turn-cost.js +52 -62
  525. package/dist/internal/turn-governor.js +5 -8
  526. package/dist/internal/turn-lease-store.js +85 -105
  527. package/dist/internal/turn-outbox.js +28 -43
  528. package/dist/internal/update-check.js +231 -259
  529. package/dist/internal/v2-hosting.js +1 -2
  530. package/dist/internal/workspace-sync.js +25 -41
  531. package/dist/internal/workspace.js +111 -139
  532. package/dist/kv/memory-kv.js +27 -51
  533. package/dist/memory.js +106 -148
  534. package/dist/otel.js +5 -8
  535. package/dist/playground/assets/index-DXm_VXAQ.css +1 -0
  536. package/dist/playground/assets/{index-Co4CUVTQ.js → index-JekUQERK.js} +45 -45
  537. package/dist/playground/index.html +2 -2
  538. package/dist/prompt.js +2 -4
  539. package/dist/storage-backends/cursor-hosted-v2.js +53 -83
  540. package/dist/storage-backends/cursor-hosted.js +105 -145
  541. package/dist/storage-backends/file-kv.js +100 -128
  542. package/dist/storage-protocol.js +3 -5
  543. package/dist/storage.js +17 -26
  544. package/dist/types.d.ts +68 -0
  545. package/dist/types.d.ts.map +1 -1
  546. package/dist/types.js +20 -18
  547. package/docs/building-with-agents.md +2 -0
  548. package/docs/deployment.md +7 -0
  549. package/docs/guides/bitbucket.md +9 -1
  550. package/docs/guides/github.md +20 -4
  551. package/docs/guides/gitlab.md +9 -1
  552. package/docs/guides/migrate.md +127 -0
  553. package/docs/reference/cli.md +39 -0
  554. package/docs/troubleshooting.md +1 -0
  555. package/package.json +1 -1
  556. package/skills/debug/SKILL.md +1 -0
  557. package/skills/github/SKILL.md +23 -0
  558. package/skills/migrate-v2/SKILL.md +51 -10
  559. package/dist/docs/assets/chunks/@localSearchIndexroot.BJ8UZggu.js +0 -1
  560. package/dist/docs/assets/chunks/channel.BTJ5J9FI.js +0 -1
  561. package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.D4BZ3cVV.js +0 -1
  562. package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.D4BZ3cVV.js +0 -1
  563. package/dist/docs/assets/chunks/clone.62tX-O-1.js +0 -1
  564. package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.DkTs1aEU.js +0 -1
  565. package/dist/docs/assets/reference_cli.md.GwugN3n-.lean.js +0 -1
  566. package/dist/docs/assets/troubleshooting.md.Bscj6ODe.js +0 -1
  567. package/dist/playground/assets/index-C1g_PTTZ.css +0 -1
  568. /package/dist/docs/assets/{building-with-agents.md.BPjPFxFg.lean.js → building-with-agents.md.Df87rAe1.lean.js} +0 -0
  569. /package/dist/docs/assets/{deployment.md.BdqTiGdc.lean.js → deployment.md.BYuEcDBv.lean.js} +0 -0
  570. /package/dist/docs/assets/{reference_skills.md.ClkMoQsV.lean.js → reference_skills.md.C0guGcH0.lean.js} +0 -0
@@ -1,48 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __rest = (this && this.__rest) || function (s, e) {
11
- var t = {};
12
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
- t[p] = s[p];
14
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
- t[p[i]] = s[p[i]];
18
- }
19
- return t;
20
- };
21
- var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
22
- var __asyncValues = (this && this.__asyncValues) || function (o) {
23
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
24
- var m = o[Symbol.asyncIterator], i;
25
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
26
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
27
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
28
- };
29
- var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
30
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
31
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
32
- return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
33
- function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
34
- function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
35
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
36
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
37
- function fulfill(value) { resume("next", value); }
38
- function reject(value) { resume("throw", value); }
39
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
40
- };
41
- var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
42
- var i, p;
43
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
44
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
45
- };
46
1
  import { Buffer } from "node:buffer";
47
2
  import { mkdir, readdir, readFile, rm, stat, writeFile } from "node:fs/promises";
48
3
  import path from "node:path";
@@ -58,7 +13,7 @@ import { isExcludedPath, listFilesFromPaths, mergeSortedByPath, statFromFilePath
58
13
  * `ListRepoPaths` from `/repo`. Smaller than Origin's 10k default
59
14
  * so a recursive listing does not materialize a huge response.
60
15
  */
61
- export const FILE_SYSTEM_SCAN_LIMIT = 1000;
16
+ export const FILE_SYSTEM_SCAN_LIMIT = 1_000;
62
17
  export const FILE_SYSTEM_TOOL_NAMES = [
63
18
  "Read",
64
19
  "LS",
@@ -300,7 +255,7 @@ function compileGrepPattern(pattern, caseInsensitive, path = "/") {
300
255
  try {
301
256
  return new RegExp(pattern, caseInsensitive === true ? "i" : undefined);
302
257
  }
303
- catch (_a) {
258
+ catch {
304
259
  throw new InvalidGrepPatternError(pattern, path);
305
260
  }
306
261
  }
@@ -319,34 +274,19 @@ function normalizeMaxResults(maxResults) {
319
274
  }
320
275
  return Math.max(0, Math.floor(maxResults));
321
276
  }
322
- function limitResults(source, maxResults) {
323
- return __asyncGenerator(this, arguments, function* limitResults_1() {
324
- var _a, e_1, _b, _c;
325
- const cap = normalizeMaxResults(maxResults);
326
- if (cap === 0) {
327
- return yield __await(void 0);
328
- }
329
- let n = 0;
330
- try {
331
- for (var _d = true, source_1 = __asyncValues(source), source_1_1; source_1_1 = yield __await(source_1.next()), _a = source_1_1.done, !_a; _d = true) {
332
- _c = source_1_1.value;
333
- _d = false;
334
- const item = _c;
335
- yield yield __await(item);
336
- n++;
337
- if (cap !== undefined && n >= cap) {
338
- return yield __await(void 0);
339
- }
340
- }
341
- }
342
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
343
- finally {
344
- try {
345
- if (!_d && !_a && (_b = source_1.return)) yield __await(_b.call(source_1));
346
- }
347
- finally { if (e_1) throw e_1.error; }
277
+ async function* limitResults(source, maxResults) {
278
+ const cap = normalizeMaxResults(maxResults);
279
+ if (cap === 0) {
280
+ return;
281
+ }
282
+ let n = 0;
283
+ for await (const item of source) {
284
+ yield item;
285
+ n++;
286
+ if (cap !== undefined && n >= cap) {
287
+ return;
348
288
  }
349
- });
289
+ }
350
290
  }
351
291
  function grepPushdownLimit(query, opts) {
352
292
  // Count and files_with_matches paginate after grouping by file.
@@ -374,65 +314,53 @@ function compareSearchResult(left, right) {
374
314
  }
375
315
  return left.path < right.path ? -1 : left.path > right.path ? 1 : 0;
376
316
  }
377
- export function collectGrepMatches(root, query, opts) {
378
- return __awaiter(this, void 0, void 0, function* () {
379
- var _a, e_2, _b, _c;
380
- const matches = [];
381
- const offset = opts.offset !== undefined && opts.offset > 0 ? opts.offset : 0;
382
- const headLimit = opts.headLimit !== undefined && opts.headLimit > 0 ? opts.headLimit : undefined;
383
- const skippedFiles = new Set();
384
- const acceptedFiles = new Set();
385
- let skippedItems = 0;
386
- let takenItems = 0;
387
- const pushdown = grepPushdownLimit(query, Object.assign({ outputMode: opts.outputMode, offset }, (opts.headLimit === undefined ? {} : { headLimit: opts.headLimit })));
388
- const grepQuery = pushdown === undefined ? query : Object.assign(Object.assign({}, query), { maxResults: pushdown });
389
- try {
390
- for (var _d = true, _e = __asyncValues(root.grep(grepQuery)), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
391
- _c = _f.value;
392
- _d = false;
393
- const match = _c;
394
- if (opts.outputMode === "content") {
395
- if (skippedItems < offset) {
396
- skippedItems++;
397
- continue;
398
- }
399
- matches.push(match);
400
- takenItems++;
401
- if (headLimit !== undefined && takenItems >= headLimit) {
402
- break;
403
- }
404
- continue;
405
- }
406
- if (skippedFiles.has(match.path)) {
407
- continue;
408
- }
409
- if (!acceptedFiles.has(match.path)) {
410
- if (skippedItems < offset) {
411
- skippedFiles.add(match.path);
412
- skippedItems++;
413
- continue;
414
- }
415
- if (headLimit !== undefined && takenItems >= headLimit) {
416
- break;
417
- }
418
- acceptedFiles.add(match.path);
419
- takenItems++;
420
- }
421
- matches.push(match);
317
+ export async function collectGrepMatches(root, query, opts) {
318
+ const matches = [];
319
+ const offset = opts.offset !== undefined && opts.offset > 0 ? opts.offset : 0;
320
+ const headLimit = opts.headLimit !== undefined && opts.headLimit > 0 ? opts.headLimit : undefined;
321
+ const skippedFiles = new Set();
322
+ const acceptedFiles = new Set();
323
+ let skippedItems = 0;
324
+ let takenItems = 0;
325
+ const pushdown = grepPushdownLimit(query, {
326
+ outputMode: opts.outputMode,
327
+ offset,
328
+ ...(opts.headLimit === undefined ? {} : { headLimit: opts.headLimit }),
329
+ });
330
+ const grepQuery = pushdown === undefined ? query : { ...query, maxResults: pushdown };
331
+ for await (const match of root.grep(grepQuery)) {
332
+ if (opts.outputMode === "content") {
333
+ if (skippedItems < offset) {
334
+ skippedItems++;
335
+ continue;
422
336
  }
337
+ matches.push(match);
338
+ takenItems++;
339
+ if (headLimit !== undefined && takenItems >= headLimit) {
340
+ break;
341
+ }
342
+ continue;
423
343
  }
424
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
425
- finally {
426
- try {
427
- if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
344
+ if (skippedFiles.has(match.path)) {
345
+ continue;
346
+ }
347
+ if (!acceptedFiles.has(match.path)) {
348
+ if (skippedItems < offset) {
349
+ skippedFiles.add(match.path);
350
+ skippedItems++;
351
+ continue;
428
352
  }
429
- finally { if (e_2) throw e_2.error; }
353
+ if (headLimit !== undefined && takenItems >= headLimit) {
354
+ break;
355
+ }
356
+ acceptedFiles.add(match.path);
357
+ takenItems++;
430
358
  }
431
- return matches;
432
- });
359
+ matches.push(match);
360
+ }
361
+ return matches;
433
362
  }
434
363
  export function shapeGrepUnion(matches, outputMode) {
435
- var _a;
436
364
  if (outputMode === "files_with_matches") {
437
365
  const files = [...new Set(matches.map(match => match.path))];
438
366
  return { type: "files", output: { files, count: files.length } };
@@ -440,7 +368,7 @@ export function shapeGrepUnion(matches, outputMode) {
440
368
  if (outputMode === "count") {
441
369
  const counts = new Map();
442
370
  for (const match of matches) {
443
- counts.set(match.path, ((_a = counts.get(match.path)) !== null && _a !== void 0 ? _a : 0) + 1);
371
+ counts.set(match.path, (counts.get(match.path) ?? 0) + 1);
444
372
  }
445
373
  return {
446
374
  type: "count",
@@ -453,7 +381,13 @@ export function shapeGrepUnion(matches, outputMode) {
453
381
  return {
454
382
  type: "content",
455
383
  output: {
456
- matches: matches.map(match => (Object.assign(Object.assign({ file: match.path, lineNumber: match.lineNumber, line: match.line }, (match.beforeContext === undefined ? {} : { beforeContext: match.beforeContext })), (match.afterContext === undefined ? {} : { afterContext: match.afterContext })))),
384
+ matches: matches.map(match => ({
385
+ file: match.path,
386
+ lineNumber: match.lineNumber,
387
+ line: match.line,
388
+ ...(match.beforeContext === undefined ? {} : { beforeContext: match.beforeContext }),
389
+ ...(match.afterContext === undefined ? {} : { afterContext: match.afterContext }),
390
+ })),
457
391
  totalMatches: matches.length,
458
392
  },
459
393
  };
@@ -528,28 +462,26 @@ export function virtualWorkspaceWritePath(relativePath) {
528
462
  }
529
463
  return dest;
530
464
  }
531
- export function writeWorkspaceFilesToRoot(root, files) {
532
- return __awaiter(this, void 0, void 0, function* () {
533
- for (const [relativePath, contents] of Object.entries(files)) {
534
- // Refuse escapes, then write the sanitized relative dest so
535
- // `localFileSystem` joins against cwd and `tempFs` still normalizes
536
- // `a.txt` → `/a.txt`. Never forward an absolute host path.
537
- const dest = virtualWorkspaceWritePath(relativePath);
538
- const relativeDest = dest.replace(/^\//, "");
539
- if (relativeDest === "") {
540
- throw new FileSystemConfigError(`Refusing to write the virtual root: ${relativePath}`);
541
- }
542
- const fileText = typeof contents === "string"
543
- ? contents
544
- : Buffer.from(contents.data, "base64").toString("utf8");
545
- try {
546
- yield root.write(relativeDest, fileText);
547
- }
548
- catch (error) {
549
- throw new FileSystemConfigError(`workspaceFiles failed to write ${relativePath}: ${error instanceof Error ? error.message : "write failed"}`);
550
- }
465
+ export async function writeWorkspaceFilesToRoot(root, files) {
466
+ for (const [relativePath, contents] of Object.entries(files)) {
467
+ // Refuse escapes, then write the sanitized relative dest so
468
+ // `localFileSystem` joins against cwd and `tempFs` still normalizes
469
+ // `a.txt` → `/a.txt`. Never forward an absolute host path.
470
+ const dest = virtualWorkspaceWritePath(relativePath);
471
+ const relativeDest = dest.replace(/^\//, "");
472
+ if (relativeDest === "") {
473
+ throw new FileSystemConfigError(`Refusing to write the virtual root: ${relativePath}`);
551
474
  }
552
- });
475
+ const fileText = typeof contents === "string"
476
+ ? contents
477
+ : Buffer.from(contents.data, "base64").toString("utf8");
478
+ try {
479
+ await root.write(relativeDest, fileText);
480
+ }
481
+ catch (error) {
482
+ throw new FileSystemConfigError(`workspaceFiles failed to write ${relativePath}: ${error instanceof Error ? error.message : "write failed"}`);
483
+ }
484
+ }
553
485
  }
554
486
  function replaceLiteral(args) {
555
487
  if (args.replaceAll) {
@@ -607,22 +539,20 @@ function applyExactEdit(args) {
607
539
  * this helper's contract; FileSystem implementations do not
608
540
  * implement edit. Native StrReplace calls this.
609
541
  */
610
- export function strReplaceOnFileSystem(root, query) {
611
- return __awaiter(this, void 0, void 0, function* () {
612
- const existing = yield root.read(query.path);
613
- if (typeof existing !== "string") {
614
- throw new EditError(query.path, `${query.path} is not text`);
615
- }
616
- const applied = applyExactEdit({
617
- existing,
618
- oldText: query.oldText,
619
- newText: query.newText,
620
- replaceAll: query.replaceAll === true,
621
- path: query.path,
622
- });
623
- yield root.write(query.path, applied.contents);
624
- return { occurrencesModified: applied.occurrencesModified };
542
+ export async function strReplaceOnFileSystem(root, query) {
543
+ const existing = await root.read(query.path);
544
+ if (typeof existing !== "string") {
545
+ throw new EditError(query.path, `${query.path} is not text`);
546
+ }
547
+ const applied = applyExactEdit({
548
+ existing,
549
+ oldText: query.oldText,
550
+ newText: query.newText,
551
+ replaceAll: query.replaceAll === true,
552
+ path: query.path,
625
553
  });
554
+ await root.write(query.path, applied.contents);
555
+ return { occurrencesModified: applied.occurrencesModified };
626
556
  }
627
557
  /** Native Read offset/limit: 1-indexed, negative offset counts from the end. */
628
558
  export function sliceReadContent(content, offset, limit) {
@@ -631,14 +561,14 @@ export function sliceReadContent(content, offset, limit) {
631
561
  }
632
562
  const lines = content === "" ? [] : content.split("\n");
633
563
  const total = lines.length;
634
- const effectiveOffset = offset !== null && offset !== void 0 ? offset : 1;
635
- const effectiveLimit = limit !== null && limit !== void 0 ? limit : (effectiveOffset < 0 ? Math.abs(effectiveOffset) : total);
564
+ const effectiveOffset = offset ?? 1;
565
+ const effectiveLimit = limit ?? (effectiveOffset < 0 ? Math.abs(effectiveOffset) : total);
636
566
  const startIndex = effectiveOffset < 0 ? Math.max(0, total + effectiveOffset) : Math.max(0, effectiveOffset - 1);
637
567
  const endIndex = Math.min(total, startIndex + effectiveLimit);
638
568
  return lines.slice(startIndex, endIndex).join("\n");
639
569
  }
640
- function emptySearch(_query) { return __asyncGenerator(this, arguments, function* emptySearch_1() { }); }
641
- function emptyStream() { return __asyncGenerator(this, arguments, function* emptyStream_1() { }); }
570
+ async function* emptySearch(_query) { }
571
+ async function* emptyStream() { }
642
572
  /**
643
573
  * A FileSystem with no files. Use as an overlay leaf or a missing
644
574
  * catalog so a miss stays {@link FileNotFoundError} instead of
@@ -649,32 +579,22 @@ export function emptyFs() {
649
579
  return {
650
580
  list: () => emptyStream(),
651
581
  glob: () => emptyStream(),
652
- grep(query) {
653
- return __asyncGenerator(this, arguments, function* grep_1() {
654
- compileGrepPattern(query.pattern, query.caseInsensitive, query.path === undefined || query.path === "" ? "/" : normalizeFsPath(query.path));
655
- yield __await(yield* __asyncDelegator(__asyncValues(emptyStream())));
656
- });
582
+ async *grep(query) {
583
+ compileGrepPattern(query.pattern, query.caseInsensitive, query.path === undefined || query.path === "" ? "/" : normalizeFsPath(query.path));
584
+ yield* emptyStream();
657
585
  },
658
586
  search: emptySearch,
659
- stat(path) {
660
- return __awaiter(this, void 0, void 0, function* () {
661
- return statFromFilePaths([], path);
662
- });
587
+ async stat(path) {
588
+ return statFromFilePaths([], path);
663
589
  },
664
- read(path) {
665
- return __awaiter(this, void 0, void 0, function* () {
666
- throw new FileNotFoundError(normalizeFsPath(path));
667
- });
590
+ async read(path) {
591
+ throw new FileNotFoundError(normalizeFsPath(path));
668
592
  },
669
- write(path) {
670
- return __awaiter(this, void 0, void 0, function* () {
671
- throw new ReadOnlyMountError(normalizeFsPath(path));
672
- });
593
+ async write(path) {
594
+ throw new ReadOnlyMountError(normalizeFsPath(path));
673
595
  },
674
- delete(path) {
675
- return __awaiter(this, void 0, void 0, function* () {
676
- throw new ReadOnlyMountError(normalizeFsPath(path));
677
- });
596
+ async delete(path) {
597
+ throw new ReadOnlyMountError(normalizeFsPath(path));
678
598
  },
679
599
  };
680
600
  }
@@ -697,109 +617,84 @@ export function tempFs(files = {}) {
697
617
  size: typeof content === "string" ? content.length : content.byteLength,
698
618
  })), prefix, options);
699
619
  },
700
- stat(path) {
701
- return __awaiter(this, void 0, void 0, function* () {
702
- return statFromFilePaths(store.keys(), path);
703
- });
620
+ async stat(path) {
621
+ return statFromFilePaths(store.keys(), path);
704
622
  },
705
623
  };
706
624
  return {
707
625
  list(prefix, options) {
708
626
  return listed.list(prefix, options);
709
627
  },
710
- stat(path) {
711
- return __awaiter(this, void 0, void 0, function* () {
712
- return listed.stat(path);
713
- });
628
+ async stat(path) {
629
+ return listed.stat(path);
714
630
  },
715
- read(inputPath) {
716
- return __awaiter(this, void 0, void 0, function* () {
717
- const path = normalizeFsPath(inputPath);
718
- const content = store.get(path);
719
- if (content === undefined) {
720
- throw new FileNotFoundError(path);
721
- }
722
- return content;
723
- });
631
+ async read(inputPath) {
632
+ const path = normalizeFsPath(inputPath);
633
+ const content = store.get(path);
634
+ if (content === undefined) {
635
+ throw new FileNotFoundError(path);
636
+ }
637
+ return content;
724
638
  },
725
- grep(query) {
726
- return __asyncGenerator(this, arguments, function* grep_2() {
727
- yield __await(yield* __asyncDelegator(__asyncValues(limitResults(uncapped(), query.maxResults))));
728
- function uncapped() {
729
- return __asyncGenerator(this, arguments, function* uncapped_1() {
730
- var _a, e_3, _b, _c;
731
- const regex = compileGrepPattern(query.pattern, query.caseInsensitive, query.path === undefined || query.path === "" ? "/" : normalizeFsPath(query.path));
732
- const scope = query.path === undefined || query.path === "" ? "/" : normalizeFsPath(query.path);
733
- const exact = store.get(scope);
734
- if (scope !== "/" && exact !== undefined) {
735
- if (query.glob !== undefined &&
736
- !pathMatchesGlob(scope, scope, query.glob, {
737
- matchBasename: true,
738
- })) {
739
- return yield __await(void 0);
740
- }
741
- if (isExcludedPath(scope, query.excludes)) {
742
- return yield __await(void 0);
743
- }
744
- yield __await(yield* __asyncDelegator(__asyncValues(grepFileContent({
745
- path: scope,
746
- content: fileSystemText(exact),
747
- regex,
748
- }))));
749
- return yield __await(void 0);
750
- }
751
- try {
752
- for (var _d = true, _e = __asyncValues(listed.list(scope === "/" ? undefined : scope, query.excludes === undefined ? undefined : { excludes: query.excludes })), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
753
- _c = _f.value;
754
- _d = false;
755
- const entry = _c;
756
- if (query.glob !== undefined &&
757
- !pathMatchesGlob(entry.path, scope, query.glob, {
758
- matchBasename: true,
759
- })) {
760
- continue;
761
- }
762
- const content = store.get(entry.path);
763
- if (content === undefined) {
764
- continue;
765
- }
766
- yield __await(yield* __asyncDelegator(__asyncValues(grepFileContent({
767
- path: entry.path,
768
- content: fileSystemText(content),
769
- regex,
770
- }))));
771
- }
772
- }
773
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
774
- finally {
775
- try {
776
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
777
- }
778
- finally { if (e_3) throw e_3.error; }
779
- }
639
+ async *grep(query) {
640
+ yield* limitResults(uncapped(), query.maxResults);
641
+ async function* uncapped() {
642
+ const regex = compileGrepPattern(query.pattern, query.caseInsensitive, query.path === undefined || query.path === "" ? "/" : normalizeFsPath(query.path));
643
+ const scope = query.path === undefined || query.path === "" ? "/" : normalizeFsPath(query.path);
644
+ const exact = store.get(scope);
645
+ if (scope !== "/" && exact !== undefined) {
646
+ if (query.glob !== undefined &&
647
+ !pathMatchesGlob(scope, scope, query.glob, {
648
+ matchBasename: true,
649
+ })) {
650
+ return;
651
+ }
652
+ if (isExcludedPath(scope, query.excludes)) {
653
+ return;
654
+ }
655
+ yield* grepFileContent({
656
+ path: scope,
657
+ content: fileSystemText(exact),
658
+ regex,
780
659
  });
660
+ return;
781
661
  }
782
- });
662
+ for await (const entry of listed.list(scope === "/" ? undefined : scope, query.excludes === undefined ? undefined : { excludes: query.excludes })) {
663
+ if (query.glob !== undefined &&
664
+ !pathMatchesGlob(entry.path, scope, query.glob, {
665
+ matchBasename: true,
666
+ })) {
667
+ continue;
668
+ }
669
+ const content = store.get(entry.path);
670
+ if (content === undefined) {
671
+ continue;
672
+ }
673
+ yield* grepFileContent({
674
+ path: entry.path,
675
+ content: fileSystemText(content),
676
+ regex,
677
+ });
678
+ }
679
+ }
783
680
  },
784
- glob(pattern, dir, options) {
785
- return __asyncGenerator(this, arguments, function* glob_1() {
786
- const scope = dir === undefined || dir === "" ? "/" : normalizeFsPath(dir);
787
- yield __await(yield* __asyncDelegator(__asyncValues(globFromList(listed.list(scope === "/" ? undefined : scope), Object.assign({ pattern, dir: scope }, ((options === null || options === void 0 ? void 0 : options.limit) === undefined ? {} : { limit: options.limit }))))));
681
+ async *glob(pattern, dir, options) {
682
+ const scope = dir === undefined || dir === "" ? "/" : normalizeFsPath(dir);
683
+ yield* globFromList(listed.list(scope === "/" ? undefined : scope), {
684
+ pattern,
685
+ dir: scope,
686
+ ...(options?.limit === undefined ? {} : { limit: options.limit }),
788
687
  });
789
688
  },
790
- write(inputPath, contents) {
791
- return __awaiter(this, void 0, void 0, function* () {
792
- store.set(normalizeFsPath(inputPath), contents);
793
- });
689
+ async write(inputPath, contents) {
690
+ store.set(normalizeFsPath(inputPath), contents);
794
691
  },
795
- delete(inputPath) {
796
- return __awaiter(this, void 0, void 0, function* () {
797
- const path = normalizeFsPath(inputPath);
798
- if (!store.has(path)) {
799
- throw new FileNotFoundError(path);
800
- }
801
- store.delete(path);
802
- });
692
+ async delete(inputPath) {
693
+ const path = normalizeFsPath(inputPath);
694
+ if (!store.has(path)) {
695
+ throw new FileNotFoundError(path);
696
+ }
697
+ store.delete(path);
803
698
  },
804
699
  search: emptySearch,
805
700
  };
@@ -813,48 +708,44 @@ function throwLocalReadError(error, filePath) {
813
708
  function skipWalkDir(name) {
814
709
  return name === ".git" || name === "node_modules";
815
710
  }
816
- function walkLocalFiles(rootDir) {
817
- return __awaiter(this, void 0, void 0, function* () {
818
- const found = [];
819
- const stack = [rootDir];
820
- while (stack.length > 0) {
821
- const current = stack.pop();
822
- if (current === undefined) {
823
- break;
824
- }
825
- let entries;
826
- try {
827
- entries = yield readdir(current, { withFileTypes: true });
828
- }
829
- catch (_a) {
830
- continue;
831
- }
832
- for (const entry of entries) {
833
- const full = path.join(current, entry.name);
834
- // Same as the pre-root host walk and native LS/Glob/Grep: Dirent
835
- // isDirectory/isFile do not follow links, so workspace `memory/`
836
- // and other symlinks are not enumerated. Exact-path read/stat still
837
- // follow.
838
- if (entry.isDirectory()) {
839
- if (!skipWalkDir(entry.name)) {
840
- stack.push(full);
841
- }
842
- }
843
- else if (entry.isFile()) {
844
- found.push(full);
711
+ async function walkLocalFiles(rootDir) {
712
+ const found = [];
713
+ const stack = [rootDir];
714
+ while (stack.length > 0) {
715
+ const current = stack.pop();
716
+ if (current === undefined) {
717
+ break;
718
+ }
719
+ let entries;
720
+ try {
721
+ entries = await readdir(current, { withFileTypes: true });
722
+ }
723
+ catch {
724
+ continue;
725
+ }
726
+ for (const entry of entries) {
727
+ const full = path.join(current, entry.name);
728
+ // Same as the pre-root host walk and native LS/Glob/Grep: Dirent
729
+ // isDirectory/isFile do not follow links, so workspace `memory/`
730
+ // and other symlinks are not enumerated. Exact-path read/stat still
731
+ // follow.
732
+ if (entry.isDirectory()) {
733
+ if (!skipWalkDir(entry.name)) {
734
+ stack.push(full);
845
735
  }
846
736
  }
737
+ else if (entry.isFile()) {
738
+ found.push(full);
739
+ }
847
740
  }
848
- found.sort((left, right) => left.localeCompare(right));
849
- return found;
850
- });
741
+ }
742
+ found.sort((left, right) => left.localeCompare(right));
743
+ return found;
851
744
  }
852
- function listLocalFiles(rootDir) {
853
- return __asyncGenerator(this, arguments, function* listLocalFiles_1() {
854
- for (const filePath of yield __await(walkLocalFiles(rootDir))) {
855
- yield yield __await({ path: filePath });
856
- }
857
- });
745
+ async function* listLocalFiles(rootDir) {
746
+ for (const filePath of await walkLocalFiles(rootDir)) {
747
+ yield { path: filePath };
748
+ }
858
749
  }
859
750
  /**
860
751
  * Host-disk FileSystem. Relative paths resolve against `cwd`; absolute
@@ -867,128 +758,100 @@ export function localFileSystem(options) {
867
758
  const cwd = path.resolve(options.cwd);
868
759
  const resolvePath = (input) => path.isAbsolute(input) ? path.resolve(input) : path.resolve(cwd, input);
869
760
  return {
870
- list(prefix, options) {
871
- return __asyncGenerator(this, arguments, function* list_1() {
872
- yield __await(yield* __asyncDelegator(__asyncValues(limitResults(uncapped(), options === null || options === void 0 ? void 0 : options.limit))));
873
- function uncapped() {
874
- return __asyncGenerator(this, arguments, function* uncapped_2() {
875
- var _a, e_4, _b, _c;
876
- const dirPath = prefix === undefined || prefix === "" || prefix === "." ? cwd : resolvePath(prefix);
877
- try {
878
- for (var _d = true, _e = __asyncValues(listLocalFiles(dirPath)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
879
- _c = _f.value;
880
- _d = false;
881
- const entry = _c;
882
- if (!isExcludedPath(entry.path, options === null || options === void 0 ? void 0 : options.excludes)) {
883
- yield yield __await(entry);
884
- }
885
- }
886
- }
887
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
888
- finally {
889
- try {
890
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
891
- }
892
- finally { if (e_4) throw e_4.error; }
893
- }
894
- });
761
+ async *list(prefix, options) {
762
+ yield* limitResults(uncapped(), options?.limit);
763
+ async function* uncapped() {
764
+ const dirPath = prefix === undefined || prefix === "" || prefix === "." ? cwd : resolvePath(prefix);
765
+ for await (const entry of listLocalFiles(dirPath)) {
766
+ if (!isExcludedPath(entry.path, options?.excludes)) {
767
+ yield entry;
768
+ }
895
769
  }
896
- });
770
+ }
897
771
  },
898
- stat(probePath) {
899
- return __awaiter(this, void 0, void 0, function* () {
900
- const filePath = resolvePath(probePath);
901
- try {
902
- const info = yield stat(filePath);
903
- return { kind: info.isDirectory() ? "directory" : "file" };
904
- }
905
- catch (_a) {
906
- return { kind: "missing" };
772
+ async stat(probePath) {
773
+ const filePath = resolvePath(probePath);
774
+ try {
775
+ const info = await stat(filePath);
776
+ return { kind: info.isDirectory() ? "directory" : "file" };
777
+ }
778
+ catch {
779
+ return { kind: "missing" };
780
+ }
781
+ },
782
+ async read(inputPath) {
783
+ const filePath = resolvePath(inputPath);
784
+ try {
785
+ const bytes = await readFile(filePath);
786
+ if (detectImageMimeType(bytes, filePath) !== undefined) {
787
+ return new Uint8Array(bytes);
907
788
  }
908
- });
789
+ return bytes.toString("utf8");
790
+ }
791
+ catch (error) {
792
+ throwLocalReadError(error, filePath);
793
+ }
909
794
  },
910
- read(inputPath) {
911
- return __awaiter(this, void 0, void 0, function* () {
912
- const filePath = resolvePath(inputPath);
795
+ async *grep(query) {
796
+ yield* limitResults(uncapped(), query.maxResults);
797
+ async function* uncapped() {
798
+ const searchRoot = resolvePath(query.path ?? cwd);
799
+ const regex = compileGrepPattern(query.pattern, query.caseInsensitive, searchRoot);
800
+ let filesToSearch;
913
801
  try {
914
- const bytes = yield readFile(filePath);
915
- if (detectImageMimeType(bytes, filePath) !== undefined) {
916
- return new Uint8Array(bytes);
917
- }
918
- return bytes.toString("utf8");
802
+ const info = await stat(searchRoot);
803
+ filesToSearch = info.isFile() ? [searchRoot] : await walkLocalFiles(searchRoot);
919
804
  }
920
805
  catch (error) {
921
- throwLocalReadError(error, filePath);
806
+ throwLocalReadError(error, searchRoot);
922
807
  }
923
- });
924
- },
925
- grep(query) {
926
- return __asyncGenerator(this, arguments, function* grep_3() {
927
- yield __await(yield* __asyncDelegator(__asyncValues(limitResults(uncapped(), query.maxResults))));
928
- function uncapped() {
929
- return __asyncGenerator(this, arguments, function* uncapped_3() {
930
- var _a;
931
- const searchRoot = resolvePath((_a = query.path) !== null && _a !== void 0 ? _a : cwd);
932
- const regex = compileGrepPattern(query.pattern, query.caseInsensitive, searchRoot);
933
- let filesToSearch;
934
- try {
935
- const info = yield __await(stat(searchRoot));
936
- filesToSearch = info.isFile() ? [searchRoot] : yield __await(walkLocalFiles(searchRoot));
937
- }
938
- catch (error) {
939
- throwLocalReadError(error, searchRoot);
940
- }
941
- for (const filePath of filesToSearch) {
942
- if (query.glob !== undefined &&
943
- !pathMatchesGlob(filePath, searchRoot, query.glob, {
944
- matchBasename: true,
945
- })) {
946
- continue;
947
- }
948
- if (isExcludedPath(filePath, query.excludes)) {
949
- continue;
950
- }
951
- let content;
952
- try {
953
- content = yield __await(readFile(filePath, "utf8"));
954
- }
955
- catch (_b) {
956
- continue;
957
- }
958
- yield __await(yield* __asyncDelegator(__asyncValues(grepFileContent({ path: filePath, content, regex }))));
959
- }
960
- });
808
+ for (const filePath of filesToSearch) {
809
+ if (query.glob !== undefined &&
810
+ !pathMatchesGlob(filePath, searchRoot, query.glob, {
811
+ matchBasename: true,
812
+ })) {
813
+ continue;
814
+ }
815
+ if (isExcludedPath(filePath, query.excludes)) {
816
+ continue;
817
+ }
818
+ let content;
819
+ try {
820
+ content = await readFile(filePath, "utf8");
821
+ }
822
+ catch {
823
+ continue;
824
+ }
825
+ yield* grepFileContent({ path: filePath, content, regex });
961
826
  }
962
- });
827
+ }
963
828
  },
964
- glob(pattern, dir, options) {
965
- return __asyncGenerator(this, arguments, function* glob_2() {
966
- const dirPath = dir === undefined || dir === "" || dir === "." ? cwd : resolvePath(dir);
967
- yield __await(yield* __asyncDelegator(__asyncValues(globFromList(listLocalFiles(dirPath), Object.assign({ pattern, dir: dirPath }, ((options === null || options === void 0 ? void 0 : options.limit) === undefined ? {} : { limit: options.limit }))))));
829
+ async *glob(pattern, dir, options) {
830
+ const dirPath = dir === undefined || dir === "" || dir === "." ? cwd : resolvePath(dir);
831
+ yield* globFromList(listLocalFiles(dirPath), {
832
+ pattern,
833
+ dir: dirPath,
834
+ ...(options?.limit === undefined ? {} : { limit: options.limit }),
968
835
  });
969
836
  },
970
- write(inputPath, contents) {
971
- return __awaiter(this, void 0, void 0, function* () {
972
- const filePath = resolvePath(inputPath);
973
- try {
974
- yield mkdir(path.dirname(filePath), { recursive: true });
975
- yield writeFile(filePath, contents, "utf8");
976
- }
977
- catch (error) {
978
- throw new WriteFailedError(filePath, fsErrorMessage(error, `write failed: ${filePath}`));
979
- }
980
- });
837
+ async write(inputPath, contents) {
838
+ const filePath = resolvePath(inputPath);
839
+ try {
840
+ await mkdir(path.dirname(filePath), { recursive: true });
841
+ await writeFile(filePath, contents, "utf8");
842
+ }
843
+ catch (error) {
844
+ throw new WriteFailedError(filePath, fsErrorMessage(error, `write failed: ${filePath}`));
845
+ }
981
846
  },
982
- delete(inputPath) {
983
- return __awaiter(this, void 0, void 0, function* () {
984
- const filePath = resolvePath(inputPath);
985
- try {
986
- yield rm(filePath);
987
- }
988
- catch (error) {
989
- throwLocalReadError(error, filePath);
990
- }
991
- });
847
+ async delete(inputPath) {
848
+ const filePath = resolvePath(inputPath);
849
+ try {
850
+ await rm(filePath);
851
+ }
852
+ catch (error) {
853
+ throwLocalReadError(error, filePath);
854
+ }
992
855
  },
993
856
  search: emptySearch,
994
857
  };
@@ -1028,80 +891,35 @@ function toParentPath(path, prefix) {
1028
891
  }
1029
892
  return path.startsWith("/") ? `${prefix}${path}` : `${prefix}/${path}`;
1030
893
  }
1031
- function mapMountEntries(source, prefix) {
1032
- return __asyncGenerator(this, arguments, function* mapMountEntries_1() {
1033
- var _a, e_5, _b, _c;
1034
- try {
1035
- try {
1036
- for (var _d = true, source_2 = __asyncValues(source), source_2_1; source_2_1 = yield __await(source_2.next()), _a = source_2_1.done, !_a; _d = true) {
1037
- _c = source_2_1.value;
1038
- _d = false;
1039
- const entry = _c;
1040
- yield yield __await(Object.assign(Object.assign({}, entry), { path: toParentPath(entry.path, prefix) }));
1041
- }
1042
- }
1043
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
1044
- finally {
1045
- try {
1046
- if (!_d && !_a && (_b = source_2.return)) yield __await(_b.call(source_2));
1047
- }
1048
- finally { if (e_5) throw e_5.error; }
1049
- }
1050
- }
1051
- catch (error) {
1052
- throw remapPathError(error, prefix);
894
+ async function* mapMountEntries(source, prefix) {
895
+ try {
896
+ for await (const entry of source) {
897
+ yield { ...entry, path: toParentPath(entry.path, prefix) };
1053
898
  }
1054
- });
899
+ }
900
+ catch (error) {
901
+ throw remapPathError(error, prefix);
902
+ }
1055
903
  }
1056
- function mapMountGrep(source, prefix) {
1057
- return __asyncGenerator(this, arguments, function* mapMountGrep_1() {
1058
- var _a, e_6, _b, _c;
1059
- try {
1060
- try {
1061
- for (var _d = true, source_3 = __asyncValues(source), source_3_1; source_3_1 = yield __await(source_3.next()), _a = source_3_1.done, !_a; _d = true) {
1062
- _c = source_3_1.value;
1063
- _d = false;
1064
- const hit = _c;
1065
- yield yield __await(Object.assign(Object.assign({}, hit), { path: toParentPath(hit.path, prefix) }));
1066
- }
1067
- }
1068
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
1069
- finally {
1070
- try {
1071
- if (!_d && !_a && (_b = source_3.return)) yield __await(_b.call(source_3));
1072
- }
1073
- finally { if (e_6) throw e_6.error; }
1074
- }
1075
- }
1076
- catch (error) {
1077
- throw remapPathError(error, prefix);
904
+ async function* mapMountGrep(source, prefix) {
905
+ try {
906
+ for await (const hit of source) {
907
+ yield { ...hit, path: toParentPath(hit.path, prefix) };
1078
908
  }
1079
- });
909
+ }
910
+ catch (error) {
911
+ throw remapPathError(error, prefix);
912
+ }
1080
913
  }
1081
- function mapMountSearch(source, prefix) {
1082
- return __asyncGenerator(this, arguments, function* mapMountSearch_1() {
1083
- var _a, e_7, _b, _c;
1084
- try {
1085
- try {
1086
- for (var _d = true, source_4 = __asyncValues(source), source_4_1; source_4_1 = yield __await(source_4.next()), _a = source_4_1.done, !_a; _d = true) {
1087
- _c = source_4_1.value;
1088
- _d = false;
1089
- const hit = _c;
1090
- yield yield __await(Object.assign(Object.assign({}, hit), { path: toParentPath(hit.path, prefix) }));
1091
- }
1092
- }
1093
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
1094
- finally {
1095
- try {
1096
- if (!_d && !_a && (_b = source_4.return)) yield __await(_b.call(source_4));
1097
- }
1098
- finally { if (e_7) throw e_7.error; }
1099
- }
1100
- }
1101
- catch (error) {
1102
- throw remapPathError(error, prefix);
914
+ async function* mapMountSearch(source, prefix) {
915
+ try {
916
+ for await (const hit of source) {
917
+ yield { ...hit, path: toParentPath(hit.path, prefix) };
1103
918
  }
1104
- });
919
+ }
920
+ catch (error) {
921
+ throw remapPathError(error, prefix);
922
+ }
1105
923
  }
1106
924
  function childSearchQuery(query, prefix) {
1107
925
  if (query.targetDirectories === undefined || query.targetDirectories.length === 0) {
@@ -1112,21 +930,21 @@ function childSearchQuery(query, prefix) {
1112
930
  const normalized = normalizeFsPath(dir);
1113
931
  // `/` is every mount, the same way grep at `/` fans out.
1114
932
  if (normalized === "/") {
1115
- return Object.assign(Object.assign({}, query), { targetDirectories: undefined });
933
+ return { ...query, targetDirectories: undefined };
1116
934
  }
1117
935
  if (!pathHasSegmentPrefix({ path: normalized, prefix })) {
1118
936
  continue;
1119
937
  }
1120
938
  const child = toChildPath(normalized, prefix);
1121
939
  if (child === "/") {
1122
- return Object.assign(Object.assign({}, query), { targetDirectories: undefined });
940
+ return { ...query, targetDirectories: undefined };
1123
941
  }
1124
942
  dirs.push(child);
1125
943
  }
1126
944
  if (dirs.length === 0) {
1127
945
  return undefined;
1128
946
  }
1129
- return Object.assign(Object.assign({}, query), { targetDirectories: dirs });
947
+ return { ...query, targetDirectories: dirs };
1130
948
  }
1131
949
  /**
1132
950
  * Longest-prefix compose, path-segment match. Every verb is
@@ -1159,161 +977,125 @@ export function unionFs(mounts) {
1159
977
  const noMount = (path) => {
1160
978
  throw new NoMountError(path);
1161
979
  };
1162
- const forward = (path, run) => __awaiter(this, void 0, void 0, function* () {
980
+ const forward = async (path, run) => {
1163
981
  const mount = longestMount(path, entries);
1164
982
  if (mount === undefined) {
1165
983
  return noMount(path);
1166
984
  }
1167
985
  const childPath = toChildPath(path, mount.prefix);
1168
986
  try {
1169
- return yield run(mount.fs, childPath);
987
+ return await run(mount.fs, childPath);
1170
988
  }
1171
989
  catch (error) {
1172
990
  throw remapPathError(error, mount.prefix);
1173
991
  }
1174
- });
992
+ };
1175
993
  const isRootPath = (value) => value === undefined || value === "" || value === "/";
1176
994
  return {
1177
- list(prefix, options) {
1178
- return __asyncGenerator(this, arguments, function* list_2() {
1179
- yield __await(yield* __asyncDelegator(__asyncValues(limitResults(uncapped(), options === null || options === void 0 ? void 0 : options.limit))));
1180
- function uncapped() {
1181
- return __asyncGenerator(this, arguments, function* uncapped_4() {
1182
- if (isRootPath(prefix)) {
1183
- yield __await(yield* __asyncDelegator(__asyncValues(mergeSortedByPath(entries.map(mount => mapMountEntries(mount.fs.list(undefined, options), mount.prefix)), { unique: true }))));
1184
- return yield __await(void 0);
1185
- }
1186
- const path = normalizeFsPath(prefix !== null && prefix !== void 0 ? prefix : "/");
1187
- const mount = longestMount(path, entries);
1188
- if (mount === undefined) {
1189
- return yield __await(void 0);
1190
- }
1191
- const childPath = toChildPath(path, mount.prefix);
1192
- yield __await(yield* __asyncDelegator(__asyncValues(mapMountEntries(mount.fs.list(childPath === "/" ? undefined : childPath, options), mount.prefix))));
1193
- });
1194
- }
1195
- });
1196
- },
1197
- stat(path) {
1198
- return __awaiter(this, void 0, void 0, function* () {
1199
- const normalized = normalizeFsPath(path);
1200
- if (normalized === "/") {
1201
- return { kind: "directory" };
995
+ async *list(prefix, options) {
996
+ yield* limitResults(uncapped(), options?.limit);
997
+ async function* uncapped() {
998
+ if (isRootPath(prefix)) {
999
+ yield* mergeSortedByPath(entries.map(mount => mapMountEntries(mount.fs.list(undefined, options), mount.prefix)), { unique: true });
1000
+ return;
1202
1001
  }
1203
- if (entries.some(entry => entry.prefix === normalized)) {
1204
- return { kind: "directory" };
1205
- }
1206
- const mount = longestMount(normalized, entries);
1002
+ const path = normalizeFsPath(prefix ?? "/");
1003
+ const mount = longestMount(path, entries);
1207
1004
  if (mount === undefined) {
1208
- return { kind: "missing" };
1005
+ return;
1209
1006
  }
1210
- return mount.fs.stat(toChildPath(normalized, mount.prefix));
1211
- });
1007
+ const childPath = toChildPath(path, mount.prefix);
1008
+ yield* mapMountEntries(mount.fs.list(childPath === "/" ? undefined : childPath, options), mount.prefix);
1009
+ }
1212
1010
  },
1213
- read(path) {
1214
- return __awaiter(this, void 0, void 0, function* () {
1215
- const normalized = normalizeFsPath(path);
1216
- return forward(normalized, (fs, childPath) => fs.read(childPath));
1217
- });
1011
+ async stat(path) {
1012
+ const normalized = normalizeFsPath(path);
1013
+ if (normalized === "/") {
1014
+ return { kind: "directory" };
1015
+ }
1016
+ if (entries.some(entry => entry.prefix === normalized)) {
1017
+ return { kind: "directory" };
1018
+ }
1019
+ const mount = longestMount(normalized, entries);
1020
+ if (mount === undefined) {
1021
+ return { kind: "missing" };
1022
+ }
1023
+ return mount.fs.stat(toChildPath(normalized, mount.prefix));
1218
1024
  },
1219
- write(path, contents) {
1220
- return __awaiter(this, void 0, void 0, function* () {
1221
- const normalized = normalizeFsPath(path);
1222
- return forward(normalized, (fs, childPath) => fs.write(childPath, contents));
1223
- });
1025
+ async read(path) {
1026
+ const normalized = normalizeFsPath(path);
1027
+ return forward(normalized, (fs, childPath) => fs.read(childPath));
1224
1028
  },
1225
- delete(path) {
1226
- return __awaiter(this, void 0, void 0, function* () {
1227
- const normalized = normalizeFsPath(path);
1228
- return forward(normalized, (fs, childPath) => fs.delete(childPath));
1229
- });
1029
+ async write(path, contents) {
1030
+ const normalized = normalizeFsPath(path);
1031
+ return forward(normalized, (fs, childPath) => fs.write(childPath, contents));
1230
1032
  },
1231
- grep(query) {
1232
- return __asyncGenerator(this, arguments, function* grep_4() {
1233
- yield __await(yield* __asyncDelegator(__asyncValues(limitResults(uncapped(), query.maxResults))));
1234
- function uncapped() {
1235
- return __asyncGenerator(this, arguments, function* uncapped_5() {
1236
- const scope = query.path === undefined || query.path === "" ? "/" : normalizeFsPath(query.path);
1237
- if (scope === "/") {
1238
- yield __await(yield* __asyncDelegator(__asyncValues(mergeSorted(entries.map(mount => mapMountGrep(mount.fs.grep(Object.assign(Object.assign({}, query), { path: undefined })), mount.prefix)), { compare: compareGrepResult }))));
1239
- return yield __await(void 0);
1240
- }
1241
- const mount = longestMount(scope, entries);
1242
- if (mount === undefined) {
1243
- return yield __await(void 0);
1244
- }
1245
- const childPath = toChildPath(scope, mount.prefix);
1246
- yield __await(yield* __asyncDelegator(__asyncValues(mapMountGrep(mount.fs.grep(Object.assign(Object.assign({}, query), { path: childPath === "/" ? undefined : childPath })), mount.prefix))));
1247
- });
1248
- }
1249
- });
1033
+ async delete(path) {
1034
+ const normalized = normalizeFsPath(path);
1035
+ return forward(normalized, (fs, childPath) => fs.delete(childPath));
1250
1036
  },
1251
- search(query) {
1252
- return __asyncGenerator(this, arguments, function* search_1() {
1253
- yield __await(yield* __asyncDelegator(__asyncValues(limitResults(uncapped(), query.maxResults))));
1254
- function uncapped() {
1255
- return __asyncGenerator(this, arguments, function* uncapped_6() {
1256
- const sources = [];
1257
- for (const mount of entries) {
1258
- const childQuery = childSearchQuery(query, mount.prefix);
1259
- if (childQuery === undefined) {
1260
- continue;
1261
- }
1262
- sources.push(mapMountSearch(mount.fs.search(childQuery), mount.prefix));
1263
- }
1264
- yield __await(yield* __asyncDelegator(__asyncValues(mergeSorted(sources, { compare: compareSearchResult }))));
1265
- });
1037
+ async *grep(query) {
1038
+ yield* limitResults(uncapped(), query.maxResults);
1039
+ async function* uncapped() {
1040
+ const scope = query.path === undefined || query.path === "" ? "/" : normalizeFsPath(query.path);
1041
+ if (scope === "/") {
1042
+ yield* mergeSorted(entries.map(mount => mapMountGrep(mount.fs.grep({ ...query, path: undefined }), mount.prefix)), { compare: compareGrepResult });
1043
+ return;
1266
1044
  }
1267
- });
1268
- },
1269
- glob(pattern, dir, options) {
1270
- return __asyncGenerator(this, arguments, function* glob_3() {
1271
- yield __await(yield* __asyncDelegator(__asyncValues(limitResults(uncapped(), options === null || options === void 0 ? void 0 : options.limit))));
1272
- function uncapped() {
1273
- return __asyncGenerator(this, arguments, function* uncapped_7() {
1274
- const scope = dir === undefined || dir === "" ? "/" : normalizeFsPath(dir);
1275
- if (scope === "/") {
1276
- yield __await(yield* __asyncDelegator(__asyncValues(mergeSortedByPath(entries.map(mount => mapMountEntries(mount.fs.glob(pattern, undefined, options), mount.prefix)), { unique: true }))));
1277
- return yield __await(void 0);
1278
- }
1279
- const mount = longestMount(scope, entries);
1280
- if (mount === undefined) {
1281
- return yield __await(void 0);
1282
- }
1283
- const childPath = toChildPath(scope, mount.prefix);
1284
- yield __await(yield* __asyncDelegator(__asyncValues(mapMountEntries(mount.fs.glob(pattern, childPath === "/" ? undefined : childPath, options), mount.prefix))));
1285
- });
1045
+ const mount = longestMount(scope, entries);
1046
+ if (mount === undefined) {
1047
+ return;
1286
1048
  }
1287
- });
1049
+ const childPath = toChildPath(scope, mount.prefix);
1050
+ yield* mapMountGrep(mount.fs.grep({
1051
+ ...query,
1052
+ path: childPath === "/" ? undefined : childPath,
1053
+ }), mount.prefix);
1054
+ }
1288
1055
  },
1289
- };
1290
- }
1291
- function collectLayerPaths(layer) {
1292
- return __awaiter(this, void 0, void 0, function* () {
1293
- var _a, e_8, _b, _c;
1294
- const paths = [];
1295
- try {
1296
- try {
1297
- for (var _d = true, _e = __asyncValues(layer.list()), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
1298
- _c = _f.value;
1299
- _d = false;
1300
- const entry = _c;
1301
- paths.push(entry.path);
1056
+ async *search(query) {
1057
+ yield* limitResults(uncapped(), query.maxResults);
1058
+ async function* uncapped() {
1059
+ const sources = [];
1060
+ for (const mount of entries) {
1061
+ const childQuery = childSearchQuery(query, mount.prefix);
1062
+ if (childQuery === undefined) {
1063
+ continue;
1064
+ }
1065
+ sources.push(mapMountSearch(mount.fs.search(childQuery), mount.prefix));
1302
1066
  }
1067
+ yield* mergeSorted(sources, { compare: compareSearchResult });
1303
1068
  }
1304
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
1305
- finally {
1306
- try {
1307
- if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
1069
+ },
1070
+ async *glob(pattern, dir, options) {
1071
+ yield* limitResults(uncapped(), options?.limit);
1072
+ async function* uncapped() {
1073
+ const scope = dir === undefined || dir === "" ? "/" : normalizeFsPath(dir);
1074
+ if (scope === "/") {
1075
+ yield* mergeSortedByPath(entries.map(mount => mapMountEntries(mount.fs.glob(pattern, undefined, options), mount.prefix)), { unique: true });
1076
+ return;
1308
1077
  }
1309
- finally { if (e_8) throw e_8.error; }
1078
+ const mount = longestMount(scope, entries);
1079
+ if (mount === undefined) {
1080
+ return;
1081
+ }
1082
+ const childPath = toChildPath(scope, mount.prefix);
1083
+ yield* mapMountEntries(mount.fs.glob(pattern, childPath === "/" ? undefined : childPath, options), mount.prefix);
1310
1084
  }
1085
+ },
1086
+ };
1087
+ }
1088
+ async function collectLayerPaths(layer) {
1089
+ const paths = [];
1090
+ try {
1091
+ for await (const entry of layer.list()) {
1092
+ paths.push(entry.path);
1311
1093
  }
1312
- catch (_g) {
1313
- // A layer that cannot list also cannot own paths.
1314
- }
1315
- return paths;
1316
- });
1094
+ }
1095
+ catch {
1096
+ // A layer that cannot list also cannot own paths.
1097
+ }
1098
+ return paths;
1317
1099
  }
1318
1100
  /**
1319
1101
  * Same-root overlay: earlier layers win. Read-only.
@@ -1326,41 +1108,27 @@ export function overlayFs(layers) {
1326
1108
  if (layers.length === 0) {
1327
1109
  throw new Error("overlayFs needs at least one layer.");
1328
1110
  }
1329
- const walkLayers = (collect) => __awaiter(this, void 0, void 0, function* () {
1330
- var _a, e_9, _b, _c;
1111
+ const walkLayers = async (collect) => {
1331
1112
  const streams = [];
1332
1113
  let failure;
1333
1114
  let served = false;
1334
1115
  for (const layer of layers) {
1335
1116
  const collected = [];
1336
1117
  try {
1337
- try {
1338
- for (var _d = true, _e = (e_9 = void 0, __asyncValues(yield collect(layer))), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
1339
- _c = _f.value;
1340
- _d = false;
1341
- const entry = _c;
1342
- collected.push(entry);
1343
- }
1344
- }
1345
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
1346
- finally {
1347
- try {
1348
- if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
1349
- }
1350
- finally { if (e_9) throw e_9.error; }
1118
+ for await (const entry of await collect(layer)) {
1119
+ collected.push(entry);
1351
1120
  }
1352
1121
  }
1353
1122
  catch (error) {
1354
- failure !== null && failure !== void 0 ? failure : (failure = error);
1123
+ failure ??= error;
1355
1124
  continue;
1356
1125
  }
1357
1126
  served = true;
1358
1127
  streams.push(collected);
1359
1128
  }
1360
1129
  return { streams, failure, served };
1361
- });
1362
- const collectOverlayHits = (queryFn, rethrow) => __awaiter(this, void 0, void 0, function* () {
1363
- var _a, e_10, _b, _c;
1130
+ };
1131
+ const collectOverlayHits = async (queryFn, rethrow) => {
1364
1132
  const streams = [];
1365
1133
  const shadowed = new Set();
1366
1134
  let failure;
@@ -1368,34 +1136,22 @@ export function overlayFs(layers) {
1368
1136
  for (const layer of layers) {
1369
1137
  const collected = [];
1370
1138
  try {
1371
- try {
1372
- for (var _d = true, _e = (e_10 = void 0, __asyncValues(queryFn(layer))), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
1373
- _c = _f.value;
1374
- _d = false;
1375
- const hit = _c;
1376
- if (!shadowed.has(hit.path)) {
1377
- collected.push(hit);
1378
- }
1379
- }
1380
- }
1381
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
1382
- finally {
1383
- try {
1384
- if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
1139
+ for await (const hit of queryFn(layer)) {
1140
+ if (!shadowed.has(hit.path)) {
1141
+ collected.push(hit);
1385
1142
  }
1386
- finally { if (e_10) throw e_10.error; }
1387
1143
  }
1388
1144
  served = true;
1389
1145
  }
1390
1146
  catch (error) {
1391
- if ((rethrow === null || rethrow === void 0 ? void 0 : rethrow(error)) === true) {
1147
+ if (rethrow?.(error) === true) {
1392
1148
  throw error;
1393
1149
  }
1394
- failure !== null && failure !== void 0 ? failure : (failure = error);
1150
+ failure ??= error;
1395
1151
  continue;
1396
1152
  }
1397
1153
  streams.push(collected);
1398
- for (const path of yield collectLayerPaths(layer)) {
1154
+ for (const path of await collectLayerPaths(layer)) {
1399
1155
  shadowed.add(path);
1400
1156
  }
1401
1157
  }
@@ -1403,91 +1159,75 @@ export function overlayFs(layers) {
1403
1159
  throw failure;
1404
1160
  }
1405
1161
  return streams;
1406
- });
1162
+ };
1407
1163
  return {
1408
- list(prefix, options) {
1409
- return __asyncGenerator(this, arguments, function* list_3() {
1410
- const { streams, failure, served } = yield __await(walkLayers(layer => layer.list(prefix, options)));
1411
- if (!served && failure !== undefined) {
1412
- throw failure;
1413
- }
1414
- yield __await(yield* __asyncDelegator(__asyncValues(limitResults(mergeSortedByPath(streams, { unique: true }), options === null || options === void 0 ? void 0 : options.limit))));
1415
- });
1164
+ async *list(prefix, options) {
1165
+ const { streams, failure, served } = await walkLayers(layer => layer.list(prefix, options));
1166
+ if (!served && failure !== undefined) {
1167
+ throw failure;
1168
+ }
1169
+ yield* limitResults(mergeSortedByPath(streams, { unique: true }), options?.limit);
1416
1170
  },
1417
- stat(path) {
1418
- return __awaiter(this, void 0, void 0, function* () {
1419
- let failure;
1420
- let sawMissing = false;
1421
- for (const layer of layers) {
1422
- try {
1423
- const info = yield layer.stat(path);
1424
- if (info.kind !== "missing") {
1425
- return info;
1426
- }
1427
- sawMissing = true;
1428
- }
1429
- catch (error) {
1430
- failure !== null && failure !== void 0 ? failure : (failure = error);
1171
+ async stat(path) {
1172
+ let failure;
1173
+ let sawMissing = false;
1174
+ for (const layer of layers) {
1175
+ try {
1176
+ const info = await layer.stat(path);
1177
+ if (info.kind !== "missing") {
1178
+ return info;
1431
1179
  }
1180
+ sawMissing = true;
1432
1181
  }
1433
- if (!sawMissing && failure !== undefined) {
1434
- throw failure;
1182
+ catch (error) {
1183
+ failure ??= error;
1435
1184
  }
1436
- return { kind: "missing" };
1437
- });
1185
+ }
1186
+ if (!sawMissing && failure !== undefined) {
1187
+ throw failure;
1188
+ }
1189
+ return { kind: "missing" };
1438
1190
  },
1439
- glob(pattern, dir, options) {
1440
- return __asyncGenerator(this, arguments, function* glob_4() {
1441
- const { streams, failure, served } = yield __await(walkLayers(layer => layer.glob(pattern, dir, options)));
1442
- if (!served && failure !== undefined) {
1443
- throw failure;
1444
- }
1445
- yield __await(yield* __asyncDelegator(__asyncValues(limitResults(mergeSortedByPath(streams, { unique: true }), options === null || options === void 0 ? void 0 : options.limit))));
1446
- });
1191
+ async *glob(pattern, dir, options) {
1192
+ const { streams, failure, served } = await walkLayers(layer => layer.glob(pattern, dir, options));
1193
+ if (!served && failure !== undefined) {
1194
+ throw failure;
1195
+ }
1196
+ yield* limitResults(mergeSortedByPath(streams, { unique: true }), options?.limit);
1447
1197
  },
1448
- read(path) {
1449
- return __awaiter(this, void 0, void 0, function* () {
1450
- let failure;
1451
- for (const layer of layers) {
1452
- try {
1453
- return yield layer.read(path);
1454
- }
1455
- catch (error) {
1456
- if (isFileNotFoundError(error)) {
1457
- continue;
1458
- }
1459
- failure !== null && failure !== void 0 ? failure : (failure = error);
1460
- }
1198
+ async read(path) {
1199
+ let failure;
1200
+ for (const layer of layers) {
1201
+ try {
1202
+ return await layer.read(path);
1461
1203
  }
1462
- if (failure !== undefined) {
1463
- throw failure;
1204
+ catch (error) {
1205
+ if (isFileNotFoundError(error)) {
1206
+ continue;
1207
+ }
1208
+ failure ??= error;
1464
1209
  }
1465
- throw new FileNotFoundError(path);
1466
- });
1210
+ }
1211
+ if (failure !== undefined) {
1212
+ throw failure;
1213
+ }
1214
+ throw new FileNotFoundError(path);
1467
1215
  },
1468
- grep(query) {
1469
- return __asyncGenerator(this, arguments, function* grep_5() {
1470
- const { maxResults } = query, uncappedQuery = __rest(query, ["maxResults"]);
1471
- yield __await(yield* __asyncDelegator(__asyncValues(limitResults(mergeSorted(yield __await(collectOverlayHits(layer => layer.grep(uncappedQuery), error => isInvalidGrepPatternError(error))), { compare: compareGrepResult }), maxResults))));
1472
- });
1216
+ async *grep(query) {
1217
+ const { maxResults, ...uncappedQuery } = query;
1218
+ yield* limitResults(mergeSorted(await collectOverlayHits(layer => layer.grep(uncappedQuery), error => isInvalidGrepPatternError(error)), { compare: compareGrepResult }), maxResults);
1473
1219
  },
1474
- write(path) {
1475
- return __awaiter(this, void 0, void 0, function* () {
1476
- throw new ReadOnlyMountError(path);
1477
- });
1220
+ async write(path) {
1221
+ throw new ReadOnlyMountError(path);
1478
1222
  },
1479
- delete(path) {
1480
- return __awaiter(this, void 0, void 0, function* () {
1481
- throw new ReadOnlyMountError(path);
1482
- });
1223
+ async delete(path) {
1224
+ throw new ReadOnlyMountError(path);
1483
1225
  },
1484
- search(query) {
1485
- return __asyncGenerator(this, arguments, function* search_2() {
1486
- const { maxResults } = query, uncappedQuery = __rest(query, ["maxResults"]);
1487
- yield __await(yield* __asyncDelegator(__asyncValues(limitResults(mergeSorted(yield __await(collectOverlayHits(layer => layer.search(uncappedQuery))), {
1488
- compare: compareSearchResult,
1489
- }), maxResults))));
1490
- });
1226
+ async *search(query) {
1227
+ const { maxResults, ...uncappedQuery } = query;
1228
+ yield* limitResults(mergeSorted(await collectOverlayHits(layer => layer.search(uncappedQuery)), {
1229
+ compare: compareSearchResult,
1230
+ }), maxResults);
1491
1231
  },
1492
1232
  };
1493
1233
  }
@@ -1512,41 +1252,37 @@ export function hostFs(files, scope) {
1512
1252
  const callOptions = { scope };
1513
1253
  const readEtags = new Map();
1514
1254
  const listed = {
1515
- list(prefix, options) {
1516
- return __asyncGenerator(this, arguments, function* list_4() {
1517
- const entries = yield __await(files.list(undefined, callOptions));
1518
- yield __await(yield* __asyncDelegator(__asyncValues(listFilesFromPaths(entries.map(entry => ({
1519
- path: normalizeFsPath(entry.path),
1520
- size: entry.size,
1521
- })), prefix, options))));
1522
- });
1255
+ async *list(prefix, options) {
1256
+ const entries = await files.list(undefined, callOptions);
1257
+ yield* listFilesFromPaths(entries.map(entry => ({
1258
+ path: normalizeFsPath(entry.path),
1259
+ size: entry.size,
1260
+ })), prefix, options);
1523
1261
  },
1524
- stat(path) {
1525
- return __awaiter(this, void 0, void 0, function* () {
1526
- const entries = yield files.list(undefined, callOptions);
1527
- return statFromFilePaths(entries.map(entry => normalizeFsPath(entry.path)), path);
1528
- });
1262
+ async stat(path) {
1263
+ const entries = await files.list(undefined, callOptions);
1264
+ return statFromFilePaths(entries.map(entry => normalizeFsPath(entry.path)), path);
1529
1265
  },
1530
1266
  };
1531
- const readText = (inputPath) => __awaiter(this, void 0, void 0, function* () {
1267
+ const readText = async (inputPath) => {
1532
1268
  const path = normalizeFsPath(inputPath);
1533
1269
  const key = hostKey(path);
1534
1270
  if (key === "") {
1535
1271
  throw new FileNotFoundError(path);
1536
1272
  }
1537
- const [content, stat] = yield Promise.all([
1273
+ const [content, stat] = await Promise.all([
1538
1274
  files.read(key, callOptions),
1539
1275
  files.stat(key, callOptions),
1540
1276
  ]);
1541
1277
  if (content === undefined) {
1542
1278
  throw new FileNotFoundError(path);
1543
1279
  }
1544
- if ((stat === null || stat === void 0 ? void 0 : stat.etag) !== undefined) {
1280
+ if (stat?.etag !== undefined) {
1545
1281
  readEtags.set(key, stat.etag);
1546
1282
  }
1547
1283
  return content;
1548
- });
1549
- const writeHost = (inputPath, contents) => __awaiter(this, void 0, void 0, function* () {
1284
+ };
1285
+ const writeHost = async (inputPath, contents) => {
1550
1286
  const path = normalizeFsPath(inputPath);
1551
1287
  const key = hostKey(path);
1552
1288
  if (key === "") {
@@ -1555,10 +1291,15 @@ export function hostFs(files, scope) {
1555
1291
  try {
1556
1292
  if (files.capabilities.conflictDetection) {
1557
1293
  const etag = readEtags.get(key);
1558
- yield files.write(key, contents, Object.assign(Object.assign({}, callOptions), (etag === undefined ? {} : { ifMatch: etag })));
1294
+ await files.write(key, contents, {
1295
+ ...callOptions,
1296
+ // No cached etag: unconditional create/overwrite. After a
1297
+ // successful read or write, CAS on that etag.
1298
+ ...(etag === undefined ? {} : { ifMatch: etag }),
1299
+ });
1559
1300
  }
1560
1301
  else {
1561
- yield files.write(key, contents, callOptions);
1302
+ await files.write(key, contents, callOptions);
1562
1303
  }
1563
1304
  }
1564
1305
  catch (error) {
@@ -1567,132 +1308,92 @@ export function hostFs(files, scope) {
1567
1308
  }
1568
1309
  throw error;
1569
1310
  }
1570
- const stat = yield files.stat(key, callOptions);
1571
- if ((stat === null || stat === void 0 ? void 0 : stat.etag) !== undefined) {
1311
+ const stat = await files.stat(key, callOptions);
1312
+ if (stat?.etag !== undefined) {
1572
1313
  readEtags.set(key, stat.etag);
1573
1314
  }
1574
1315
  else {
1575
1316
  readEtags.delete(key);
1576
1317
  }
1577
- });
1318
+ };
1578
1319
  return {
1579
1320
  list(prefix, options) {
1580
1321
  return listed.list(prefix, options);
1581
1322
  },
1582
- stat(path) {
1583
- return __awaiter(this, void 0, void 0, function* () {
1584
- return listed.stat(path);
1585
- });
1323
+ async stat(path) {
1324
+ return listed.stat(path);
1586
1325
  },
1587
- read(path) {
1588
- return __awaiter(this, void 0, void 0, function* () {
1589
- return readText(path);
1590
- });
1326
+ async read(path) {
1327
+ return readText(path);
1591
1328
  },
1592
- grep(query) {
1593
- return __asyncGenerator(this, arguments, function* grep_6() {
1594
- yield __await(yield* __asyncDelegator(__asyncValues(limitResults(uncapped(), query.maxResults))));
1595
- function uncapped() {
1596
- return __asyncGenerator(this, arguments, function* uncapped_8() {
1597
- var _a, e_11, _b, _c;
1598
- const scopePath = query.path === undefined || query.path === "" ? "/" : normalizeFsPath(query.path);
1599
- const regex = compileGrepPattern(query.pattern, query.caseInsensitive, scopePath);
1600
- const info = yield __await(listed.stat(scopePath));
1601
- if (scopePath !== "/" && info.kind === "file") {
1602
- if (query.glob !== undefined &&
1603
- !pathMatchesGlob(scopePath, scopePath, query.glob, {
1604
- matchBasename: true,
1605
- })) {
1606
- return yield __await(void 0);
1607
- }
1608
- if (isExcludedPath(scopePath, query.excludes)) {
1609
- return yield __await(void 0);
1610
- }
1611
- yield __await(yield* __asyncDelegator(__asyncValues(grepFileContent({
1612
- path: scopePath,
1613
- content: yield __await(readText(scopePath)),
1614
- regex,
1615
- }))));
1616
- return yield __await(void 0);
1617
- }
1618
- try {
1619
- for (var _d = true, _e = __asyncValues(listed.list(scopePath === "/" ? undefined : scopePath, query.excludes === undefined ? undefined : { excludes: query.excludes })), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
1620
- _c = _f.value;
1621
- _d = false;
1622
- const entry = _c;
1623
- if (query.glob !== undefined &&
1624
- !pathMatchesGlob(entry.path, scopePath, query.glob, {
1625
- matchBasename: true,
1626
- })) {
1627
- continue;
1628
- }
1629
- yield __await(yield* __asyncDelegator(__asyncValues(grepFileContent({
1630
- path: entry.path,
1631
- content: yield __await(readText(entry.path)),
1632
- regex,
1633
- }))));
1634
- }
1635
- }
1636
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
1637
- finally {
1638
- try {
1639
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
1640
- }
1641
- finally { if (e_11) throw e_11.error; }
1642
- }
1329
+ async *grep(query) {
1330
+ yield* limitResults(uncapped(), query.maxResults);
1331
+ async function* uncapped() {
1332
+ const scopePath = query.path === undefined || query.path === "" ? "/" : normalizeFsPath(query.path);
1333
+ const regex = compileGrepPattern(query.pattern, query.caseInsensitive, scopePath);
1334
+ const info = await listed.stat(scopePath);
1335
+ if (scopePath !== "/" && info.kind === "file") {
1336
+ if (query.glob !== undefined &&
1337
+ !pathMatchesGlob(scopePath, scopePath, query.glob, {
1338
+ matchBasename: true,
1339
+ })) {
1340
+ return;
1341
+ }
1342
+ if (isExcludedPath(scopePath, query.excludes)) {
1343
+ return;
1344
+ }
1345
+ yield* grepFileContent({
1346
+ path: scopePath,
1347
+ content: await readText(scopePath),
1348
+ regex,
1643
1349
  });
1350
+ return;
1644
1351
  }
1645
- });
1352
+ for await (const entry of listed.list(scopePath === "/" ? undefined : scopePath, query.excludes === undefined ? undefined : { excludes: query.excludes })) {
1353
+ if (query.glob !== undefined &&
1354
+ !pathMatchesGlob(entry.path, scopePath, query.glob, {
1355
+ matchBasename: true,
1356
+ })) {
1357
+ continue;
1358
+ }
1359
+ yield* grepFileContent({
1360
+ path: entry.path,
1361
+ content: await readText(entry.path),
1362
+ regex,
1363
+ });
1364
+ }
1365
+ }
1646
1366
  },
1647
- glob(pattern, dir, options) {
1648
- return __asyncGenerator(this, arguments, function* glob_5() {
1649
- const dirPath = dir === undefined || dir === "" ? "/" : normalizeFsPath(dir);
1650
- yield __await(yield* __asyncDelegator(__asyncValues(globFromList(listed.list(dirPath === "/" ? undefined : dirPath), Object.assign({ pattern, dir: dirPath }, ((options === null || options === void 0 ? void 0 : options.limit) === undefined ? {} : { limit: options.limit }))))));
1367
+ async *glob(pattern, dir, options) {
1368
+ const dirPath = dir === undefined || dir === "" ? "/" : normalizeFsPath(dir);
1369
+ yield* globFromList(listed.list(dirPath === "/" ? undefined : dirPath), {
1370
+ pattern,
1371
+ dir: dirPath,
1372
+ ...(options?.limit === undefined ? {} : { limit: options.limit }),
1651
1373
  });
1652
1374
  },
1653
- write(inputPath, contents) {
1654
- return __awaiter(this, void 0, void 0, function* () {
1655
- yield writeHost(inputPath, contents);
1656
- });
1375
+ async write(inputPath, contents) {
1376
+ await writeHost(inputPath, contents);
1657
1377
  },
1658
- delete(inputPath) {
1659
- return __awaiter(this, void 0, void 0, function* () {
1660
- const path = normalizeFsPath(inputPath);
1661
- const key = hostKey(path);
1662
- if (key === "" || !(yield files.exists(key, callOptions))) {
1663
- throw new FileNotFoundError(path);
1664
- }
1665
- yield files.remove(key, callOptions);
1666
- readEtags.delete(key);
1667
- });
1378
+ async delete(inputPath) {
1379
+ const path = normalizeFsPath(inputPath);
1380
+ const key = hostKey(path);
1381
+ if (key === "" || !(await files.exists(key, callOptions))) {
1382
+ throw new FileNotFoundError(path);
1383
+ }
1384
+ await files.remove(key, callOptions);
1385
+ readEtags.delete(key);
1668
1386
  },
1669
1387
  search: emptySearch,
1670
1388
  };
1671
1389
  }
1672
- function globFromList(source, options) {
1673
- return __asyncGenerator(this, arguments, function* globFromList_1() {
1674
- yield __await(yield* __asyncDelegator(__asyncValues(limitResults(uncapped(), options.limit))));
1675
- function uncapped() {
1676
- return __asyncGenerator(this, arguments, function* uncapped_9() {
1677
- var _a, e_12, _b, _c;
1678
- try {
1679
- for (var _d = true, source_5 = __asyncValues(source), source_5_1; source_5_1 = yield __await(source_5.next()), _a = source_5_1.done, !_a; _d = true) {
1680
- _c = source_5_1.value;
1681
- _d = false;
1682
- const entry = _c;
1683
- if (pathMatchesGlob(entry.path, options.dir, options.pattern)) {
1684
- yield yield __await(entry);
1685
- }
1686
- }
1687
- }
1688
- catch (e_12_1) { e_12 = { error: e_12_1 }; }
1689
- finally {
1690
- try {
1691
- if (!_d && !_a && (_b = source_5.return)) yield __await(_b.call(source_5));
1692
- }
1693
- finally { if (e_12) throw e_12.error; }
1694
- }
1695
- });
1390
+ async function* globFromList(source, options) {
1391
+ yield* limitResults(uncapped(), options.limit);
1392
+ async function* uncapped() {
1393
+ for await (const entry of source) {
1394
+ if (pathMatchesGlob(entry.path, options.dir, options.pattern)) {
1395
+ yield entry;
1396
+ }
1696
1397
  }
1697
- });
1398
+ }
1698
1399
  }