@grok/agent-sdk 0.2.29 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/channels/slack/cli-project.js +1 -1
- package/dist/channels/slack/slack-channel.d.ts.map +1 -1
- package/dist/channels/slack/slack-channel.js +27 -14
- package/dist/docs/404.html +2 -2
- package/dist/docs/assets/{app.DMrZKFjI.js → app.BSH__xV4.js} +4 -4
- package/dist/docs/assets/building-with-agents.md.Bo3ct-rf.js +6 -0
- package/dist/docs/assets/{building-with-agents.md.Bf1yH2tG.lean.js → building-with-agents.md.Bo3ct-rf.lean.js} +1 -1
- package/dist/docs/assets/changelog.md.b6H_ea44.js +1 -0
- package/dist/docs/assets/changelog.md.b6H_ea44.lean.js +1 -0
- package/dist/docs/assets/chunks/@localSearchIndexroot.CiRGcfZg.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.DQvuw1KA.js → VPLocalSearchBox.Cadl7A0k.js} +1 -1
- package/dist/docs/assets/chunks/{arc.ahOG-Qza.js → arc.K7t9nNY6.js} +1 -1
- package/dist/docs/assets/chunks/{architectureDiagram-Q4EWVU46.BcgfYNO_.js → architectureDiagram-Q4EWVU46.SlHEknkX.js} +1 -1
- package/dist/docs/assets/chunks/{baseUniq.DeIYZrWh.js → baseUniq.DJLRMLkz.js} +1 -1
- package/dist/docs/assets/chunks/{blockDiagram-DXYQGD6D.HjJ2goMX.js → blockDiagram-DXYQGD6D.Bs6XxFpe.js} +1 -1
- package/dist/docs/assets/chunks/{c4Diagram-AHTNJAMY.C1QTb9GM.js → c4Diagram-AHTNJAMY.CyLg6Ovc.js} +1 -1
- package/dist/docs/assets/chunks/channel.CVTdqYx0.js +1 -0
- package/dist/docs/assets/chunks/{chunk-4BX2VUAB.UuZiDiVp.js → chunk-4BX2VUAB.DTQ4TinT.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-4TB4RGXK.5A3YmkhI.js → chunk-4TB4RGXK.Es84IgcH.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-55IACEB6.B4uf1yYV.js → chunk-55IACEB6.Clm3cGPQ.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-EDXVE4YY.CoXBce8t.js → chunk-EDXVE4YY.DE4CRkS5.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-FMBD7UC4.DnC5NO4e.js → chunk-FMBD7UC4.Bf8HCvqp.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-OYMX7WX6.CzfHCeIi.js → chunk-OYMX7WX6.eub-7nSx.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-QZHKN3VN.C6tcwkVd.js → chunk-QZHKN3VN.WyP9VAS_.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-YZCP3GAM._oboyZ1A.js → chunk-YZCP3GAM.LO9ohhDE.js} +1 -1
- package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.CsJJyx6-.js +1 -0
- package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.CsJJyx6-.js +1 -0
- package/dist/docs/assets/chunks/clone.Dk8KvtOB.js +1 -0
- package/dist/docs/assets/chunks/{cose-bilkent-S5V4N54A.BfPVKeId.js → cose-bilkent-S5V4N54A.D5za6aH0.js} +1 -1
- package/dist/docs/assets/chunks/{dagre-KV5264BT.CLMLc0lD.js → dagre-KV5264BT.Dq1daUru.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-5BDNPKRD.C7OF7UfH.js → diagram-5BDNPKRD.j1YL5BKS.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-G4DWMVQ6.Dpao0Bl1.js → diagram-G4DWMVQ6.Bi1aLdhC.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-MMDJMWI5.DLnM9eLp.js → diagram-MMDJMWI5.BOzMEkAr.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-TYMM5635.BcpVgA_M.js → diagram-TYMM5635.Dx2FVhCr.js} +1 -1
- package/dist/docs/assets/chunks/{erDiagram-SMLLAGMA.CsL5JuCV.js → erDiagram-SMLLAGMA.DI4TNkye.js} +1 -1
- package/dist/docs/assets/chunks/{flowDiagram-DWJPFMVM.MFihq9AF.js → flowDiagram-DWJPFMVM.C58Z9uPK.js} +1 -1
- package/dist/docs/assets/chunks/{ganttDiagram-T4ZO3ILL.CJeLodyG.js → ganttDiagram-T4ZO3ILL.DXSpW809.js} +1 -1
- package/dist/docs/assets/chunks/{gitGraphDiagram-UUTBAWPF.1HhlE45Z.js → gitGraphDiagram-UUTBAWPF.B955oaFl.js} +1 -1
- package/dist/docs/assets/chunks/{graph.BS02KkWA.js → graph.BQXhKtxS.js} +1 -1
- package/dist/docs/assets/chunks/{infoDiagram-42DDH7IO.fp5gvytQ.js → infoDiagram-42DDH7IO.Dozj_-Gm.js} +1 -1
- package/dist/docs/assets/chunks/{ishikawaDiagram-UXIWVN3A.C6Wk1V4I.js → ishikawaDiagram-UXIWVN3A.D2140OzH.js} +1 -1
- package/dist/docs/assets/chunks/{journeyDiagram-VCZTEJTY.qJt4uJ_H.js → journeyDiagram-VCZTEJTY.DrqrMhCk.js} +1 -1
- package/dist/docs/assets/chunks/{kanban-definition-6JOO6SKY.z2tG9kly.js → kanban-definition-6JOO6SKY.Dv-LTrlw.js} +1 -1
- package/dist/docs/assets/chunks/{layout.BPCkdejr.js → layout.CGtHp49X.js} +1 -1
- package/dist/docs/assets/chunks/{linear.CL3TC3u7.js → linear.CHZLYB52.js} +1 -1
- package/dist/docs/assets/chunks/{min.SPrSp704.js → min.D4Vt3eIy.js} +1 -1
- package/dist/docs/assets/chunks/{mindmap-definition-QFDTVHPH.DgrQRFZW.js → mindmap-definition-QFDTVHPH.BBfpYTea.js} +1 -1
- package/dist/docs/assets/chunks/{pieDiagram-DEJITSTG.Ba7yxiW2.js → pieDiagram-DEJITSTG.BVYvElmY.js} +1 -1
- package/dist/docs/assets/chunks/{quadrantDiagram-34T5L4WZ.Bvskad4p.js → quadrantDiagram-34T5L4WZ.C6Gc2mdY.js} +1 -1
- package/dist/docs/assets/chunks/{requirementDiagram-MS252O5E.Ce70ugV9.js → requirementDiagram-MS252O5E.DWa8b4cn.js} +1 -1
- package/dist/docs/assets/chunks/{sankeyDiagram-XADWPNL6.BJ5OEULO.js → sankeyDiagram-XADWPNL6.Bi-g4ajv.js} +1 -1
- package/dist/docs/assets/chunks/{sequenceDiagram-FGHM5R23.C8a1hDs6.js → sequenceDiagram-FGHM5R23.DlU3vVN9.js} +1 -1
- package/dist/docs/assets/chunks/{stateDiagram-FHFEXIEX.D2D8A5CK.js → stateDiagram-FHFEXIEX.CeqJRqnU.js} +1 -1
- package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.DE0BnUZh.js +1 -0
- package/dist/docs/assets/chunks/{theme.DRciHmS1.js → theme.DGq7D4tt.js} +2 -2
- package/dist/docs/assets/chunks/{timeline-definition-GMOUNBTQ.C4ePrY8-.js → timeline-definition-GMOUNBTQ.Cqf2kjq9.js} +1 -1
- package/dist/docs/assets/chunks/{vennDiagram-DHZGUBPP.Dzso6dEA.js → vennDiagram-DHZGUBPP.BeOpE_lM.js} +1 -1
- package/dist/docs/assets/chunks/{wardley-RL74JXVD.djgXR0ar.js → wardley-RL74JXVD.FMQXA-6q.js} +1 -1
- package/dist/docs/assets/chunks/{wardleyDiagram-NUSXRM2D.Bf2ICxjh.js → wardleyDiagram-NUSXRM2D.BXS65dAC.js} +1 -1
- package/dist/docs/assets/chunks/{xychartDiagram-5P7HB3ND.DEH4BcVJ.js → xychartDiagram-5P7HB3ND.haEiSxqc.js} +1 -1
- package/dist/docs/assets/deployment.md.DJtuDVLh.js +31 -0
- package/dist/docs/assets/{deployment.md.KW0Ni_rY.lean.js → deployment.md.DJtuDVLh.lean.js} +1 -1
- package/dist/docs/assets/evals.md.Dne6VRmZ.js +49 -0
- package/dist/docs/assets/evals.md.Dne6VRmZ.lean.js +1 -0
- package/dist/docs/assets/{guides_agent-to-agent.md.D1D5f6Jc.js → guides_agent-to-agent.md.DcB3nhOz.js} +8 -8
- package/dist/docs/assets/guides_agent-to-agent.md.DcB3nhOz.lean.js +1 -0
- package/dist/docs/assets/{guides_bitbucket.md.DkjkBRU8.js → guides_bitbucket.md.BiA6ZMFW.js} +27 -27
- package/dist/docs/assets/{guides_bitbucket.md.DkjkBRU8.lean.js → guides_bitbucket.md.BiA6ZMFW.lean.js} +1 -1
- package/dist/docs/assets/guides_cloud-agents.md.CiXAW6on.js +9 -0
- package/dist/docs/assets/{guides_cloud-agents.md.Ceyjv0ul.lean.js → guides_cloud-agents.md.CiXAW6on.lean.js} +1 -1
- package/dist/docs/assets/guides_convert-automation.md.BvTxsJ8J.js +26 -0
- package/dist/docs/assets/{guides_convert-automation.md.BjraCvok.lean.js → guides_convert-automation.md.BvTxsJ8J.lean.js} +1 -1
- package/dist/docs/assets/{guides_github.md.CgN5sNbW.js → guides_github.md.CcuZ7keS.js} +11 -19
- package/dist/docs/assets/{guides_github.md.CgN5sNbW.lean.js → guides_github.md.CcuZ7keS.lean.js} +1 -1
- package/dist/docs/assets/{guides_gitlab.md.DCE0p7_w.js → guides_gitlab.md.DcKusOcU.js} +63 -73
- package/dist/docs/assets/{guides_gitlab.md.DCE0p7_w.lean.js → guides_gitlab.md.DcKusOcU.lean.js} +1 -1
- package/dist/docs/assets/guides_improve.md.o3WOGR7n.js +16 -0
- package/dist/docs/assets/{guides_improve.md.BFYtrtLE.lean.js → guides_improve.md.o3WOGR7n.lean.js} +1 -1
- package/dist/docs/assets/{guides_jev.md.CEqLgjj9.js → guides_jev.md.DGCzkMUN.js} +20 -60
- package/dist/docs/assets/{guides_jev.md.CEqLgjj9.lean.js → guides_jev.md.DGCzkMUN.lean.js} +1 -1
- package/dist/docs/assets/{guides_mcp-oauth.md.DrGY92u4.js → guides_mcp-oauth.md.GVPMKcYl.js} +3 -5
- package/dist/docs/assets/{guides_mcp-oauth.md.DrGY92u4.lean.js → guides_mcp-oauth.md.GVPMKcYl.lean.js} +1 -1
- package/dist/docs/assets/guides_migrate.md.B8CZxnnX.js +3 -0
- package/dist/docs/assets/{guides_migrate.md.RS9Eu-Xh.lean.js → guides_migrate.md.B8CZxnnX.lean.js} +1 -1
- package/dist/docs/assets/guides_opentelemetry.md.BRSktBHt.js +26 -0
- package/dist/docs/assets/guides_opentelemetry.md.BRSktBHt.lean.js +1 -0
- package/dist/docs/assets/guides_pagerduty.md.pMXUkZZc.js +61 -0
- package/dist/docs/assets/guides_pagerduty.md.pMXUkZZc.lean.js +1 -0
- package/dist/docs/assets/guides_slack.md.D7Rwyva4.js +82 -0
- package/dist/docs/assets/{guides_slack.md.BwXHURvY.lean.js → guides_slack.md.D7Rwyva4.lean.js} +1 -1
- package/dist/docs/assets/{guides_webhooks.md.BJk63ZTs.js → guides_webhooks.md.B5DXt2v1.js} +7 -7
- package/dist/docs/assets/{guides_webhooks.md.BJk63ZTs.lean.js → guides_webhooks.md.B5DXt2v1.lean.js} +1 -1
- package/dist/docs/assets/hillclimbing.md.M51bF-oT.js +5 -0
- package/dist/docs/assets/hillclimbing.md.M51bF-oT.lean.js +1 -0
- package/dist/docs/assets/index.md.DnJPj_B6.js +14 -0
- package/dist/docs/assets/index.md.DnJPj_B6.lean.js +1 -0
- package/dist/docs/assets/quickstart.md.r-oE8nkX.js +113 -0
- package/dist/docs/assets/{quickstart.md.CljDaJBi.lean.js → quickstart.md.r-oE8nkX.lean.js} +1 -1
- package/dist/docs/assets/reference_access.md.C5lblfUC.js +1 -0
- package/dist/docs/assets/reference_access.md.C5lblfUC.lean.js +1 -0
- package/dist/docs/assets/reference_agent-config.md.BSNp2uJ7.js +27 -0
- package/dist/docs/assets/{reference_agent-config.md.Ck29qYNj.lean.js → reference_agent-config.md.BSNp2uJ7.lean.js} +1 -1
- package/dist/docs/assets/reference_artifacts.md.BJpAI7h9.js +17 -0
- package/dist/docs/assets/{reference_artifacts.md.C-hKR2hp.lean.js → reference_artifacts.md.BJpAI7h9.lean.js} +1 -1
- package/dist/docs/assets/reference_channels.md.CPWOpdsC.js +21 -0
- package/dist/docs/assets/{reference_channels.md.DsJfGSBJ.lean.js → reference_channels.md.CPWOpdsC.lean.js} +1 -1
- package/dist/docs/assets/reference_cli.md.DHm6DmYk.js +83 -0
- package/dist/docs/assets/reference_cli.md.DHm6DmYk.lean.js +1 -0
- package/dist/docs/assets/reference_connections.md.DoY4vrDH.js +54 -0
- package/dist/docs/assets/{reference_connections.md.BoAotr7_.lean.js → reference_connections.md.DoY4vrDH.lean.js} +1 -1
- package/dist/docs/assets/reference_evals.md.DgfUtfIc.js +69 -0
- package/dist/docs/assets/{reference_evals.md.2BXeMiO2.lean.js → reference_evals.md.DgfUtfIc.lean.js} +1 -1
- package/dist/docs/assets/{reference_extensions.md.DI5X5x8p.js → reference_extensions.md.DHbW6eOf.js} +6 -8
- package/dist/docs/assets/{reference_extensions.md.DI5X5x8p.lean.js → reference_extensions.md.DHbW6eOf.lean.js} +1 -1
- package/dist/docs/assets/reference_hooks.md.vbIM394-.js +39 -0
- package/dist/docs/assets/reference_hooks.md.vbIM394-.lean.js +1 -0
- package/dist/docs/assets/reference_http-api.md.C7Cb0r2J.js +7 -0
- package/dist/docs/assets/{reference_http-api.md._RWELr3d.lean.js → reference_http-api.md.C7Cb0r2J.lean.js} +1 -1
- package/dist/docs/assets/reference_instructions.md.CV6Qq0UX.js +14 -0
- package/dist/docs/assets/reference_instructions.md.CV6Qq0UX.lean.js +1 -0
- package/dist/docs/assets/reference_limits.md.CbdtFr4T.js +8 -0
- package/dist/docs/assets/reference_limits.md.CbdtFr4T.lean.js +1 -0
- package/dist/docs/assets/reference_memory.md.CdoJISM-.js +3 -0
- package/dist/docs/assets/{reference_memory.md.Dd7cyV9V.lean.js → reference_memory.md.CdoJISM-.lean.js} +1 -1
- package/dist/docs/assets/reference_playground.md.DIUsRAcy.js +1 -0
- package/dist/docs/assets/{reference_playground.md.CQiJk9CM.lean.js → reference_playground.md.DIUsRAcy.lean.js} +1 -1
- package/dist/docs/assets/reference_project-layout.md.9DiKoE16.js +26 -0
- package/dist/docs/assets/reference_project-layout.md.9DiKoE16.lean.js +1 -0
- package/dist/docs/assets/reference_schedules.md.Dd8_d0WG.js +45 -0
- package/dist/docs/assets/{reference_schedules.md.RC47aFm4.lean.js → reference_schedules.md.Dd8_d0WG.lean.js} +1 -1
- package/dist/docs/assets/reference_sessions.md.NXVQt9mP.js +22 -0
- package/dist/docs/assets/{reference_sessions.md.C7KFhWXV.lean.js → reference_sessions.md.NXVQt9mP.lean.js} +1 -1
- package/dist/docs/assets/{reference_skills.md.Dej2zQxi.js → reference_skills.md.DzCPNPkG.js} +4 -4
- package/dist/docs/assets/{reference_skills.md.Dej2zQxi.lean.js → reference_skills.md.DzCPNPkG.lean.js} +1 -1
- package/dist/docs/assets/reference_subagents.md.Dvpq2sUu.js +10 -0
- package/dist/docs/assets/{reference_subagents.md.CAhvW4yS.lean.js → reference_subagents.md.Dvpq2sUu.lean.js} +1 -1
- package/dist/docs/assets/reference_tools.md.B2OaR1Nb.js +62 -0
- package/dist/docs/assets/{reference_tools.md.DQr7Fnhu.lean.js → reference_tools.md.B2OaR1Nb.lean.js} +1 -1
- package/dist/docs/assets/templates_agentic-owners.md.B6ZmKAzT.js +13 -0
- package/dist/docs/assets/{templates_agentic-owners.md.Dh2nDSqg.lean.js → templates_agentic-owners.md.B6ZmKAzT.lean.js} +1 -1
- package/dist/docs/assets/templates_reviews.md.dr9Xv_KM.js +10 -0
- package/dist/docs/assets/templates_reviews.md.dr9Xv_KM.lean.js +1 -0
- package/dist/docs/assets/troubleshooting.md.DfKKvW1R.js +3 -0
- package/dist/docs/assets/{troubleshooting.md.CGOdNVAL.lean.js → troubleshooting.md.DfKKvW1R.lean.js} +1 -1
- package/dist/docs/building-with-agents.html +41 -44
- package/dist/docs/building-with-agents.md +11 -104
- package/dist/docs/changelog.html +37 -37
- package/dist/docs/changelog.md +14 -145
- package/dist/docs/deployment.html +54 -54
- package/dist/docs/deployment.md +97 -270
- package/dist/docs/evals.html +52 -71
- package/dist/docs/evals.md +33 -129
- package/dist/docs/guides/agent-to-agent.html +43 -43
- package/dist/docs/guides/agent-to-agent.md +29 -64
- package/dist/docs/guides/bitbucket.html +62 -62
- package/dist/docs/guides/bitbucket.md +73 -134
- package/dist/docs/guides/cloud-agents.html +37 -37
- package/dist/docs/guides/cloud-agents.md +23 -53
- package/dist/docs/guides/convert-automation.html +39 -56
- package/dist/docs/guides/convert-automation.md +31 -115
- package/dist/docs/guides/github.html +46 -54
- package/dist/docs/guides/github.md +49 -131
- package/dist/docs/guides/gitlab.html +98 -108
- package/dist/docs/guides/gitlab.md +104 -184
- package/dist/docs/guides/improve.html +38 -43
- package/dist/docs/guides/improve.md +24 -90
- package/dist/docs/guides/jev.html +55 -95
- package/dist/docs/guides/jev.md +53 -160
- package/dist/docs/guides/mcp-oauth.html +38 -40
- package/dist/docs/guides/mcp-oauth.md +33 -67
- package/dist/docs/guides/migrate.html +38 -43
- package/dist/docs/guides/migrate.md +56 -130
- package/dist/docs/guides/opentelemetry.html +41 -43
- package/dist/docs/guides/opentelemetry.md +32 -27
- package/dist/docs/guides/pagerduty.html +50 -49
- package/dist/docs/guides/pagerduty.md +65 -199
- package/dist/docs/guides/slack.html +51 -57
- package/dist/docs/guides/slack.md +76 -204
- package/dist/docs/guides/webhooks.html +42 -42
- package/dist/docs/guides/webhooks.md +64 -146
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +40 -42
- package/dist/docs/hillclimbing.md +40 -102
- package/dist/docs/index.html +49 -61
- package/dist/docs/index.md +42 -82
- package/dist/docs/llms-full.txt +2272 -5711
- package/dist/docs/llms.txt +9 -14
- package/dist/docs/quickstart.html +95 -152
- package/dist/docs/quickstart.md +91 -180
- package/dist/docs/reference/access.html +36 -36
- package/dist/docs/reference/access.md +7 -12
- package/dist/docs/reference/agent-config.html +45 -58
- package/dist/docs/reference/agent-config.md +92 -176
- package/dist/docs/reference/artifacts.html +38 -39
- package/dist/docs/reference/artifacts.md +38 -62
- package/dist/docs/reference/channels.html +38 -39
- package/dist/docs/reference/channels.md +102 -151
- package/dist/docs/reference/cli.html +68 -84
- package/dist/docs/reference/cli.md +232 -697
- package/dist/docs/reference/connections.html +45 -57
- package/dist/docs/reference/connections.md +83 -164
- package/dist/docs/reference/evals.html +47 -54
- package/dist/docs/reference/evals.md +75 -141
- package/dist/docs/reference/extensions.html +41 -43
- package/dist/docs/reference/extensions.md +37 -70
- package/dist/docs/reference/hooks.html +40 -52
- package/dist/docs/reference/hooks.md +62 -133
- package/dist/docs/reference/http-api.html +38 -42
- package/dist/docs/reference/http-api.md +66 -118
- package/dist/docs/reference/instructions.html +39 -39
- package/dist/docs/reference/instructions.md +19 -29
- package/dist/docs/reference/limits.html +38 -38
- package/dist/docs/reference/limits.md +9 -21
- package/dist/docs/reference/memory.html +37 -38
- package/dist/docs/reference/memory.md +38 -75
- package/dist/docs/reference/playground.html +36 -36
- package/dist/docs/reference/playground.md +14 -22
- package/dist/docs/reference/project-layout.html +49 -48
- package/dist/docs/reference/project-layout.md +38 -84
- package/dist/docs/reference/schedules.html +44 -46
- package/dist/docs/reference/schedules.md +59 -90
- package/dist/docs/reference/sessions.html +37 -37
- package/dist/docs/reference/sessions.md +66 -113
- package/dist/docs/reference/skills.html +39 -39
- package/dist/docs/reference/skills.md +11 -31
- package/dist/docs/reference/subagents.html +37 -37
- package/dist/docs/reference/subagents.md +17 -31
- package/dist/docs/reference/tools.html +47 -64
- package/dist/docs/reference/tools.md +48 -130
- package/dist/docs/templates/agentic-owners.html +38 -38
- package/dist/docs/templates/agentic-owners.md +50 -74
- package/dist/docs/templates/reviews.html +69 -0
- package/dist/docs/templates/reviews.md +71 -0
- package/dist/docs/troubleshooting.html +38 -36
- package/dist/docs/troubleshooting.md +48 -101
- package/dist/filesystem.d.ts +7 -320
- package/dist/filesystem.d.ts.map +1 -1
- package/dist/filesystem.js +10 -691
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/authored-alias-hooks.d.ts +6 -0
- package/dist/internal/authored-alias-hooks.d.ts.map +1 -1
- package/dist/internal/authored-alias-hooks.js +12 -0
- package/dist/internal/authored-loaders.js +10 -1
- package/dist/internal/cli/commands/scaffold.js +1 -1
- package/dist/internal/cli-deploy.js +1 -1
- package/dist/internal/cli-docs.js +1 -1
- package/dist/internal/cli-images.js +1 -1
- package/dist/internal/cli-skills.js +1 -1
- package/dist/internal/continuation-session-ids.d.ts +15 -0
- package/dist/internal/continuation-session-ids.d.ts.map +1 -0
- package/dist/internal/continuation-session-ids.js +43 -0
- package/dist/internal/cursor/credentials.js +1 -1
- package/dist/internal/deploy-manifest.d.ts +1 -0
- package/dist/internal/deploy-manifest.d.ts.map +1 -1
- package/dist/internal/deploy-manifest.js +0 -1
- package/dist/internal/discovery/agent-config.d.ts +2 -6
- package/dist/internal/discovery/agent-config.d.ts.map +1 -1
- package/dist/internal/discovery/agent-config.js +8 -25
- package/dist/internal/discovery/agent.d.ts.map +1 -1
- package/dist/internal/discovery/agent.js +2 -3
- package/dist/internal/discovery/project.d.ts.map +1 -1
- package/dist/internal/discovery/project.js +15 -0
- package/dist/internal/filesystem/walk.d.ts +1 -5
- package/dist/internal/filesystem/walk.d.ts.map +1 -1
- package/dist/internal/filesystem/walk.js +1 -9
- package/dist/internal/hosted-catch-protocol.d.ts +3 -3
- package/dist/internal/hosted-catch-protocol.js +3 -3
- package/dist/internal/hosted-fetch.d.ts +7 -0
- package/dist/internal/hosted-fetch.d.ts.map +1 -0
- package/dist/internal/hosted-fetch.js +26 -0
- package/dist/internal/init-project.d.ts.map +1 -1
- package/dist/internal/init-project.js +7 -5
- package/dist/internal/install-cursor-skills.d.ts +5 -6
- package/dist/internal/install-cursor-skills.d.ts.map +1 -1
- package/dist/internal/install-cursor-skills.js +19 -4
- package/dist/internal/mcp-endpoint.js +4 -4
- package/dist/internal/model-config.d.ts.map +1 -1
- package/dist/internal/model-config.js +11 -4
- package/dist/internal/platform-timers.d.ts +3 -7
- package/dist/internal/platform-timers.d.ts.map +1 -1
- package/dist/internal/platform-timers.js +10 -51
- package/dist/internal/reminder-runner.js +1 -1
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +6 -1
- package/dist/internal/session-engine.d.ts +3 -0
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +13 -4
- package/dist/internal/shallow-clone.js +1 -1
- package/dist/playground/assets/index-Bno25Cg0.css +1 -0
- package/dist/playground/assets/index-SGKsaznh.js +62 -0
- package/dist/playground/index.html +2 -2
- package/dist/types.d.ts +6 -17
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -2
- package/docs/README.md +42 -82
- package/docs/building-with-agents.md +11 -104
- package/docs/changelog.md +15 -146
- package/docs/deployment.md +97 -270
- package/docs/evals.md +34 -130
- package/docs/guides/agent-to-agent.md +29 -64
- package/docs/guides/bitbucket.md +73 -134
- package/docs/guides/cloud-agents.md +23 -53
- package/docs/guides/convert-automation.md +31 -115
- package/docs/guides/github.md +49 -131
- package/docs/guides/gitlab.md +104 -184
- package/docs/guides/improve.md +24 -90
- package/docs/guides/jev.md +53 -160
- package/docs/guides/mcp-oauth.md +33 -67
- package/docs/guides/migrate.md +56 -130
- package/docs/guides/opentelemetry.md +37 -27
- package/docs/guides/pagerduty.md +68 -200
- package/docs/guides/slack.md +76 -204
- package/docs/guides/webhooks.md +64 -146
- package/docs/hillclimbing.md +41 -103
- package/docs/quickstart.md +91 -180
- package/docs/reference/access.md +7 -12
- package/docs/reference/agent-config.md +92 -176
- package/docs/reference/artifacts.md +38 -62
- package/docs/reference/channels.md +102 -151
- package/docs/reference/cli.md +232 -697
- package/docs/reference/connections.md +83 -164
- package/docs/reference/evals.md +75 -141
- package/docs/reference/extensions.md +37 -70
- package/docs/reference/hooks.md +61 -132
- package/docs/reference/http-api.md +66 -118
- package/docs/reference/instructions.md +20 -30
- package/docs/reference/limits.md +10 -22
- package/docs/reference/memory.md +38 -75
- package/docs/reference/playground.md +14 -22
- package/docs/reference/project-layout.md +38 -84
- package/docs/reference/schedules.md +59 -90
- package/docs/reference/sessions.md +66 -113
- package/docs/reference/skills.md +12 -32
- package/docs/reference/subagents.md +17 -31
- package/docs/reference/tools.md +48 -130
- package/docs/templates/agentic-owners.md +50 -74
- package/docs/templates/reviews.md +76 -0
- package/docs/troubleshooting.md +48 -101
- package/package.json +4 -4
- package/skills/cli/SKILL.md +1 -1
- package/skills/create-agent/SKILL.md +61 -7
- package/skills/debug/SKILL.md +1 -1
- package/skills/deploy/SKILL.md +3 -3
- package/skills/evals/SKILL.md +1 -1
- package/skills/framework-map/SKILL.md +2 -2
- package/skills/github/SKILL.md +1 -1
- package/skills/hillclimb/SKILL.md +1 -1
- package/skills/mcp-auth/SKILL.md +1 -1
- package/skills/migrate-v2/SKILL.md +2 -3
- package/skills/otel/SKILL.md +1 -1
- package/skills/setup-slack/SKILL.md +2 -2
- package/dist/docs/assets/building-with-agents.md.Bf1yH2tG.js +0 -9
- package/dist/docs/assets/changelog.md.DrLFQUlu.js +0 -1
- package/dist/docs/assets/changelog.md.DrLFQUlu.lean.js +0 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.Dpd_wxVU.js +0 -1
- package/dist/docs/assets/chunks/channel._fZX_hvU.js +0 -1
- package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.eClS1Q0E.js +0 -1
- package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.eClS1Q0E.js +0 -1
- package/dist/docs/assets/chunks/clone.W1Phdw9P.js +0 -1
- package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.77yf4kRr.js +0 -1
- package/dist/docs/assets/deployment.md.KW0Ni_rY.js +0 -31
- package/dist/docs/assets/evals.md.DiljU__Z.js +0 -68
- package/dist/docs/assets/evals.md.DiljU__Z.lean.js +0 -1
- package/dist/docs/assets/guides_agent-to-agent.md.D1D5f6Jc.lean.js +0 -1
- package/dist/docs/assets/guides_cloud-agents.md.Ceyjv0ul.js +0 -9
- package/dist/docs/assets/guides_convert-automation.md.BjraCvok.js +0 -43
- package/dist/docs/assets/guides_hooks.md.BjeEiM7s.js +0 -54
- package/dist/docs/assets/guides_hooks.md.BjeEiM7s.lean.js +0 -1
- package/dist/docs/assets/guides_improve.md.BFYtrtLE.js +0 -21
- package/dist/docs/assets/guides_migrate.md.RS9Eu-Xh.js +0 -8
- package/dist/docs/assets/guides_opentelemetry.md.CoZ1kNyd.js +0 -28
- package/dist/docs/assets/guides_opentelemetry.md.CoZ1kNyd.lean.js +0 -1
- package/dist/docs/assets/guides_pagerduty.md.mnKXe9U0.js +0 -60
- package/dist/docs/assets/guides_pagerduty.md.mnKXe9U0.lean.js +0 -1
- package/dist/docs/assets/guides_slack.md.BwXHURvY.js +0 -88
- package/dist/docs/assets/hillclimbing.md.By61f3uq.js +0 -7
- package/dist/docs/assets/hillclimbing.md.By61f3uq.lean.js +0 -1
- package/dist/docs/assets/index.md.CAruw_rp.js +0 -26
- package/dist/docs/assets/index.md.CAruw_rp.lean.js +0 -1
- package/dist/docs/assets/quickstart.md.CljDaJBi.js +0 -170
- package/dist/docs/assets/reference_access.md.CEtibb4i.js +0 -1
- package/dist/docs/assets/reference_access.md.CEtibb4i.lean.js +0 -1
- package/dist/docs/assets/reference_agent-config.md.Ck29qYNj.js +0 -40
- package/dist/docs/assets/reference_artifacts.md.C-hKR2hp.js +0 -18
- package/dist/docs/assets/reference_channels.md.DsJfGSBJ.js +0 -22
- package/dist/docs/assets/reference_cli.md.BkdLRbXg.js +0 -99
- package/dist/docs/assets/reference_cli.md.BkdLRbXg.lean.js +0 -1
- package/dist/docs/assets/reference_connections.md.BoAotr7_.js +0 -66
- package/dist/docs/assets/reference_evals.md.2BXeMiO2.js +0 -76
- package/dist/docs/assets/reference_hooks.md.B-bwJuiG.js +0 -51
- package/dist/docs/assets/reference_hooks.md.B-bwJuiG.lean.js +0 -1
- package/dist/docs/assets/reference_http-api.md._RWELr3d.js +0 -11
- package/dist/docs/assets/reference_instructions.md.yL2hXLnl.js +0 -14
- package/dist/docs/assets/reference_instructions.md.yL2hXLnl.lean.js +0 -1
- package/dist/docs/assets/reference_limits.md.BCCnvt3o.js +0 -8
- package/dist/docs/assets/reference_limits.md.BCCnvt3o.lean.js +0 -1
- package/dist/docs/assets/reference_memory.md.Dd7cyV9V.js +0 -4
- package/dist/docs/assets/reference_playground.md.CQiJk9CM.js +0 -1
- package/dist/docs/assets/reference_project-layout.md.BamcPDUn.js +0 -25
- package/dist/docs/assets/reference_project-layout.md.BamcPDUn.lean.js +0 -1
- package/dist/docs/assets/reference_prompt.md.BMjm1Jp3.js +0 -9
- package/dist/docs/assets/reference_prompt.md.BMjm1Jp3.lean.js +0 -1
- package/dist/docs/assets/reference_schedules.md.RC47aFm4.js +0 -47
- package/dist/docs/assets/reference_sessions.md.C7KFhWXV.js +0 -22
- package/dist/docs/assets/reference_subagents.md.CAhvW4yS.js +0 -10
- package/dist/docs/assets/reference_tools.md.DQr7Fnhu.js +0 -79
- package/dist/docs/assets/templates_agentic-owners.md.Dh2nDSqg.js +0 -13
- package/dist/docs/assets/templates_security-reviewer.md.DnwXdnB5.js +0 -3
- package/dist/docs/assets/templates_security-reviewer.md.DnwXdnB5.lean.js +0 -1
- package/dist/docs/assets/templates_thermo-quality-review.md.MJIdHkzE.js +0 -3
- package/dist/docs/assets/templates_thermo-quality-review.md.MJIdHkzE.lean.js +0 -1
- package/dist/docs/assets/templates_thermo-review.md.DfN1OFOl.js +0 -3
- package/dist/docs/assets/templates_thermo-review.md.DfN1OFOl.lean.js +0 -1
- package/dist/docs/assets/templates_triage.md.BYWMloV4.js +0 -9
- package/dist/docs/assets/templates_triage.md.BYWMloV4.lean.js +0 -1
- package/dist/docs/assets/troubleshooting.md.CGOdNVAL.js +0 -1
- package/dist/docs/guides/hooks.html +0 -113
- package/dist/docs/guides/hooks.md +0 -116
- package/dist/docs/package/skills/create-agent/SKILL.md +0 -178
- package/dist/docs/package/skills/evals/SKILL.md +0 -145
- package/dist/docs/package/skills/github/SKILL.md +0 -133
- package/dist/docs/package/skills/hillclimb/SKILL.md +0 -63
- package/dist/docs/package/skills/mcp-auth/SKILL.md +0 -60
- package/dist/docs/package/skills/migrate-v2/SKILL.md +0 -394
- package/dist/docs/package/skills/setup-slack/SKILL.md +0 -136
- package/dist/docs/reference/prompt.html +0 -68
- package/dist/docs/reference/prompt.md +0 -47
- package/dist/docs/templates/security-reviewer.html +0 -62
- package/dist/docs/templates/security-reviewer.md +0 -81
- package/dist/docs/templates/thermo-quality-review.html +0 -62
- package/dist/docs/templates/thermo-quality-review.md +0 -75
- package/dist/docs/templates/thermo-review.html +0 -62
- package/dist/docs/templates/thermo-review.md +0 -75
- package/dist/docs/templates/triage.html +0 -68
- package/dist/docs/templates/triage.md +0 -101
- package/dist/internal/filesystem/errors.d.ts +0 -64
- package/dist/internal/filesystem/errors.d.ts.map +0 -1
- package/dist/internal/filesystem/errors.js +0 -180
- package/dist/internal/filesystem/merge.d.ts +0 -34
- package/dist/internal/filesystem/merge.d.ts.map +0 -1
- package/dist/internal/filesystem/merge.js +0 -154
- package/dist/playground/assets/index-Cl9zvmmf.js +0 -62
- package/dist/playground/assets/index-F8b5WvWi.css +0 -1
- package/docs/guides/hooks.md +0 -121
- package/docs/reference/prompt.md +0 -52
- package/docs/templates/security-reviewer.md +0 -86
- package/docs/templates/thermo-quality-review.md +0 -80
- package/docs/templates/thermo-review.md +0 -80
- package/docs/templates/triage.md +0 -106
package/dist/filesystem.js
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import { Buffer } from "node:buffer";
|
|
2
2
|
import { lstat, mkdir, readdir, readFile, readlink, realpath, rm, stat, writeFile, } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { FileNotFoundError, InvalidGrepPatternError, PathError, tempFs, unionFs, WriteFailedError, } from "@cursor/sdk";
|
|
4
5
|
import { minimatch } from "minimatch";
|
|
5
6
|
import { FileConflictError } from "./files.js";
|
|
6
|
-
import { EditError, FileNotFoundError, InvalidGrepPatternError, isFileNotFoundError, isInvalidGrepPatternError, NoMountError, PathError, ReadOnlyMountError, remapPathError, WriteFailedError, } from "./internal/filesystem/errors.js";
|
|
7
7
|
import { MEMORY_DIR_NAME } from "./internal/memory-dir.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import { isExcludedPath, listFilesFromPaths, mergeSortedByPath, statFromFilePaths, } from "./internal/filesystem/walk.js";
|
|
11
|
-
/**
|
|
12
|
-
* Default scan cap for synthesized LS / Glob and for Origin
|
|
13
|
-
* `ListRepoPaths` from `/repo`. Smaller than Origin's 10k default
|
|
14
|
-
* so a recursive listing does not materialize a huge response.
|
|
15
|
-
*/
|
|
16
|
-
export const FILE_SYSTEM_SCAN_LIMIT = 1_000;
|
|
8
|
+
import { isExcludedPath, listFilesFromPaths, statFromFilePaths, } from "./internal/filesystem/walk.js";
|
|
9
|
+
export { childOverlayFs, DeleteNotSupportedError, EditError, emptyFs, FILE_SYSTEM_SCAN_LIMIT, FileNotFoundError, InvalidGrepPatternError, isFileNotFoundError, isInvalidGrepPatternError, NoMountError, overlayFs, PathError, ReadOnlyMountError, readOnlyFs, remapPathError, strReplaceOnFileSystem, tempFs, unionFs, WriteFailedError, } from "@cursor/sdk";
|
|
17
10
|
export const FILE_SYSTEM_TOOL_NAMES = [
|
|
18
11
|
"Read",
|
|
19
12
|
"LS",
|
|
@@ -499,77 +492,6 @@ export async function writeWorkspaceFilesToRoot(root, files) {
|
|
|
499
492
|
}
|
|
500
493
|
}
|
|
501
494
|
}
|
|
502
|
-
function replaceLiteral(args) {
|
|
503
|
-
if (args.replaceAll) {
|
|
504
|
-
return args.existing.split(args.oldText).join(args.newText);
|
|
505
|
-
}
|
|
506
|
-
const index = args.existing.indexOf(args.oldText);
|
|
507
|
-
if (index === -1) {
|
|
508
|
-
return args.existing;
|
|
509
|
-
}
|
|
510
|
-
return (args.existing.slice(0, index) + args.newText + args.existing.slice(index + args.oldText.length));
|
|
511
|
-
}
|
|
512
|
-
function countNonOverlapping(haystack, needle) {
|
|
513
|
-
let count = 0;
|
|
514
|
-
let from = 0;
|
|
515
|
-
while (from <= haystack.length - needle.length) {
|
|
516
|
-
const index = haystack.indexOf(needle, from);
|
|
517
|
-
if (index === -1) {
|
|
518
|
-
break;
|
|
519
|
-
}
|
|
520
|
-
count++;
|
|
521
|
-
from = index + needle.length;
|
|
522
|
-
}
|
|
523
|
-
return count;
|
|
524
|
-
}
|
|
525
|
-
/**
|
|
526
|
-
* Exact, non-overlapping str-replace. Uniqueness is the FileSystem
|
|
527
|
-
* contract: more than one match fails unless `replaceAll`.
|
|
528
|
-
*/
|
|
529
|
-
function applyExactEdit(args) {
|
|
530
|
-
if (args.oldText === "") {
|
|
531
|
-
throw new EditError(args.path, "oldText is empty");
|
|
532
|
-
}
|
|
533
|
-
if (args.oldText === args.newText) {
|
|
534
|
-
throw new EditError(args.path, "oldText and newText are exactly the same");
|
|
535
|
-
}
|
|
536
|
-
const occurrences = countNonOverlapping(args.existing, args.oldText);
|
|
537
|
-
if (occurrences === 0) {
|
|
538
|
-
throw new EditError(args.path, "The string to replace was not found in the file");
|
|
539
|
-
}
|
|
540
|
-
if (occurrences > 1 && !args.replaceAll) {
|
|
541
|
-
throw new EditError(args.path, "The string to replace was found multiple times in the file. Use replace_all to replace all occurrences, or include more context to only edit one occurrence.");
|
|
542
|
-
}
|
|
543
|
-
return {
|
|
544
|
-
contents: replaceLiteral({
|
|
545
|
-
existing: args.existing,
|
|
546
|
-
oldText: args.oldText,
|
|
547
|
-
newText: args.newText,
|
|
548
|
-
replaceAll: args.replaceAll,
|
|
549
|
-
}),
|
|
550
|
-
occurrencesModified: occurrences,
|
|
551
|
-
};
|
|
552
|
-
}
|
|
553
|
-
/**
|
|
554
|
-
* Exact str-replace as `read` + apply + `write`. Uniqueness is
|
|
555
|
-
* this helper's contract; FileSystem implementations do not
|
|
556
|
-
* implement edit. Native StrReplace calls this.
|
|
557
|
-
*/
|
|
558
|
-
export async function strReplaceOnFileSystem(root, query) {
|
|
559
|
-
const existing = await root.read(query.path);
|
|
560
|
-
if (typeof existing !== "string") {
|
|
561
|
-
throw new EditError(query.path, `${query.path} is not text`);
|
|
562
|
-
}
|
|
563
|
-
const applied = applyExactEdit({
|
|
564
|
-
existing,
|
|
565
|
-
oldText: query.oldText,
|
|
566
|
-
newText: query.newText,
|
|
567
|
-
replaceAll: query.replaceAll === true,
|
|
568
|
-
path: query.path,
|
|
569
|
-
});
|
|
570
|
-
await root.write(query.path, applied.contents);
|
|
571
|
-
return { occurrencesModified: applied.occurrencesModified };
|
|
572
|
-
}
|
|
573
495
|
/** Native Read offset/limit: 1-indexed, negative offset counts from the end. */
|
|
574
496
|
export function sliceReadContent(content, offset, limit) {
|
|
575
497
|
if (offset === undefined && limit === undefined) {
|
|
@@ -583,135 +505,6 @@ export function sliceReadContent(content, offset, limit) {
|
|
|
583
505
|
const endIndex = Math.min(total, startIndex + effectiveLimit);
|
|
584
506
|
return lines.slice(startIndex, endIndex).join("\n");
|
|
585
507
|
}
|
|
586
|
-
async function* emptyStream() { }
|
|
587
|
-
/**
|
|
588
|
-
* A FileSystem with no files. Use as an overlay leaf or a missing
|
|
589
|
-
* catalog so a miss stays {@link FileNotFoundError} instead of
|
|
590
|
-
* {@link NoMountError}. Writes and deletes throw
|
|
591
|
-
* {@link ReadOnlyMountError} — an empty tree is never a sink.
|
|
592
|
-
*/
|
|
593
|
-
export function emptyFs() {
|
|
594
|
-
return {
|
|
595
|
-
list: () => emptyStream(),
|
|
596
|
-
glob: () => emptyStream(),
|
|
597
|
-
async *grep(query) {
|
|
598
|
-
compileGrepPattern(query.pattern, query.caseInsensitive, query.path === undefined || query.path === "" ? "/" : normalizeFsPath(query.path));
|
|
599
|
-
yield* emptyStream();
|
|
600
|
-
},
|
|
601
|
-
async stat(path) {
|
|
602
|
-
return statFromFilePaths([], path);
|
|
603
|
-
},
|
|
604
|
-
async read(path) {
|
|
605
|
-
throw new FileNotFoundError(normalizeFsPath(path));
|
|
606
|
-
},
|
|
607
|
-
async write(path) {
|
|
608
|
-
throw new ReadOnlyMountError(normalizeFsPath(path));
|
|
609
|
-
},
|
|
610
|
-
async delete(path) {
|
|
611
|
-
throw new ReadOnlyMountError(normalizeFsPath(path));
|
|
612
|
-
},
|
|
613
|
-
};
|
|
614
|
-
}
|
|
615
|
-
/**
|
|
616
|
-
* In-memory FileSystem for tests and fixtures. Keys are absolute
|
|
617
|
-
* posix paths (`/a.txt`) and are normalized on ingest. Honors the
|
|
618
|
-
* {@link FileSystem} order and path contracts.
|
|
619
|
-
* Creates `/agent-tools` on first scratch
|
|
620
|
-
* write the same way any other path is created.
|
|
621
|
-
*/
|
|
622
|
-
export function tempFs(files = {}) {
|
|
623
|
-
const store = new Map();
|
|
624
|
-
for (const [path, content] of Object.entries(files)) {
|
|
625
|
-
store.set(normalizeFsPath(path), content);
|
|
626
|
-
}
|
|
627
|
-
const listed = {
|
|
628
|
-
list(prefix, options) {
|
|
629
|
-
return listFilesFromPaths([...store.entries()].map(([filePath, content]) => ({
|
|
630
|
-
path: filePath,
|
|
631
|
-
size: typeof content === "string" ? content.length : content.byteLength,
|
|
632
|
-
})), prefix, options);
|
|
633
|
-
},
|
|
634
|
-
async stat(path) {
|
|
635
|
-
return statFromFilePaths(store.keys(), path);
|
|
636
|
-
},
|
|
637
|
-
};
|
|
638
|
-
return {
|
|
639
|
-
list(prefix, options) {
|
|
640
|
-
return listed.list(prefix, options);
|
|
641
|
-
},
|
|
642
|
-
async stat(path) {
|
|
643
|
-
return listed.stat(path);
|
|
644
|
-
},
|
|
645
|
-
async read(inputPath) {
|
|
646
|
-
const path = normalizeFsPath(inputPath);
|
|
647
|
-
const content = store.get(path);
|
|
648
|
-
if (content === undefined) {
|
|
649
|
-
throw new FileNotFoundError(path);
|
|
650
|
-
}
|
|
651
|
-
return content;
|
|
652
|
-
},
|
|
653
|
-
async *grep(query) {
|
|
654
|
-
yield* limitResults(uncapped(), query.maxResults);
|
|
655
|
-
async function* uncapped() {
|
|
656
|
-
const regex = compileGrepPattern(query.pattern, query.caseInsensitive, query.path === undefined || query.path === "" ? "/" : normalizeFsPath(query.path));
|
|
657
|
-
const scope = query.path === undefined || query.path === "" ? "/" : normalizeFsPath(query.path);
|
|
658
|
-
const exact = store.get(scope);
|
|
659
|
-
if (scope !== "/" && exact !== undefined) {
|
|
660
|
-
if (query.glob !== undefined &&
|
|
661
|
-
!pathMatchesGlob(scope, scope, query.glob, {
|
|
662
|
-
matchBasename: true,
|
|
663
|
-
})) {
|
|
664
|
-
return;
|
|
665
|
-
}
|
|
666
|
-
if (isExcludedPath(scope, query.excludes)) {
|
|
667
|
-
return;
|
|
668
|
-
}
|
|
669
|
-
yield* grepFileContent({
|
|
670
|
-
path: scope,
|
|
671
|
-
content: fileSystemText(exact),
|
|
672
|
-
regex,
|
|
673
|
-
});
|
|
674
|
-
return;
|
|
675
|
-
}
|
|
676
|
-
for await (const entry of listed.list(scope === "/" ? undefined : scope, query.excludes === undefined ? undefined : { excludes: query.excludes })) {
|
|
677
|
-
if (query.glob !== undefined &&
|
|
678
|
-
!pathMatchesGlob(entry.path, scope, query.glob, {
|
|
679
|
-
matchBasename: true,
|
|
680
|
-
})) {
|
|
681
|
-
continue;
|
|
682
|
-
}
|
|
683
|
-
const content = store.get(entry.path);
|
|
684
|
-
if (content === undefined) {
|
|
685
|
-
continue;
|
|
686
|
-
}
|
|
687
|
-
yield* grepFileContent({
|
|
688
|
-
path: entry.path,
|
|
689
|
-
content: fileSystemText(content),
|
|
690
|
-
regex,
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
},
|
|
695
|
-
async *glob(pattern, dir, options) {
|
|
696
|
-
const scope = dir === undefined || dir === "" ? "/" : normalizeFsPath(dir);
|
|
697
|
-
yield* globFromList(listed.list(scope === "/" ? undefined : scope), {
|
|
698
|
-
pattern,
|
|
699
|
-
dir: scope,
|
|
700
|
-
...(options?.limit === undefined ? {} : { limit: options.limit }),
|
|
701
|
-
});
|
|
702
|
-
},
|
|
703
|
-
async write(inputPath, contents) {
|
|
704
|
-
store.set(normalizeFsPath(inputPath), contents);
|
|
705
|
-
},
|
|
706
|
-
async delete(inputPath) {
|
|
707
|
-
const path = normalizeFsPath(inputPath);
|
|
708
|
-
if (!store.has(path)) {
|
|
709
|
-
throw new FileNotFoundError(path);
|
|
710
|
-
}
|
|
711
|
-
store.delete(path);
|
|
712
|
-
},
|
|
713
|
-
};
|
|
714
|
-
}
|
|
715
508
|
function fsErrorMessage(error, fallback) {
|
|
716
509
|
return error instanceof Error ? error.message : fallback;
|
|
717
510
|
}
|
|
@@ -970,7 +763,9 @@ export function localFileSystem(options) {
|
|
|
970
763
|
const filePath = await resolveWritable(inputPath);
|
|
971
764
|
try {
|
|
972
765
|
await mkdir(path.dirname(filePath), { recursive: true });
|
|
973
|
-
await
|
|
766
|
+
await (typeof contents === "string"
|
|
767
|
+
? writeFile(filePath, contents, "utf8")
|
|
768
|
+
: writeFile(filePath, contents));
|
|
974
769
|
}
|
|
975
770
|
catch (error) {
|
|
976
771
|
throw new WriteFailedError(filePath, fsErrorMessage(error, `write failed: ${filePath}`));
|
|
@@ -987,76 +782,6 @@ export function localFileSystem(options) {
|
|
|
987
782
|
},
|
|
988
783
|
};
|
|
989
784
|
}
|
|
990
|
-
function longestMount(path, mounts) {
|
|
991
|
-
let best;
|
|
992
|
-
for (const mount of mounts) {
|
|
993
|
-
if (!pathHasSegmentPrefix({ path, prefix: mount.prefix })) {
|
|
994
|
-
continue;
|
|
995
|
-
}
|
|
996
|
-
if (best === undefined || mount.prefix.length > best.prefix.length) {
|
|
997
|
-
best = mount;
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
return best;
|
|
1001
|
-
}
|
|
1002
|
-
/** Each mount strictly under `path`. */
|
|
1003
|
-
function nestedMounts(path, mounts) {
|
|
1004
|
-
return mounts.filter((mount) => mount.prefix !== path && pathHasSegmentPrefix({ path: mount.prefix, prefix: path }));
|
|
1005
|
-
}
|
|
1006
|
-
/**
|
|
1007
|
-
* A glob from `scope` into a mount nested under it. The pattern is relative
|
|
1008
|
-
* to `scope`, not to the mount, so the mount is listed and each path matched.
|
|
1009
|
-
*/
|
|
1010
|
-
async function* globNestedMount(mount, scope, pattern) {
|
|
1011
|
-
for await (const entry of mapMountEntries(mount.fs.list(undefined), mount.prefix)) {
|
|
1012
|
-
if (pathMatchesGlob(entry.path, scope, pattern)) {
|
|
1013
|
-
yield entry;
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
/** Namespace path → child path. `/host/a.md` on `/host` is `/a.md`. */
|
|
1018
|
-
function toChildPath(path, prefix) {
|
|
1019
|
-
if (prefix === "/") {
|
|
1020
|
-
return path;
|
|
1021
|
-
}
|
|
1022
|
-
if (path === prefix) {
|
|
1023
|
-
return "/";
|
|
1024
|
-
}
|
|
1025
|
-
if (path.startsWith(`${prefix}/`)) {
|
|
1026
|
-
return path.slice(prefix.length);
|
|
1027
|
-
}
|
|
1028
|
-
return path;
|
|
1029
|
-
}
|
|
1030
|
-
/** Child path → namespace path. `/a.md` on `/host` is `/host/a.md`. */
|
|
1031
|
-
function toParentPath(path, prefix) {
|
|
1032
|
-
if (prefix === "/") {
|
|
1033
|
-
return path;
|
|
1034
|
-
}
|
|
1035
|
-
if (path === "/" || path === "") {
|
|
1036
|
-
return prefix;
|
|
1037
|
-
}
|
|
1038
|
-
return path.startsWith("/") ? `${prefix}${path}` : `${prefix}/${path}`;
|
|
1039
|
-
}
|
|
1040
|
-
async function* mapMountEntries(source, prefix) {
|
|
1041
|
-
try {
|
|
1042
|
-
for await (const entry of source) {
|
|
1043
|
-
yield { ...entry, path: toParentPath(entry.path, prefix) };
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
catch (error) {
|
|
1047
|
-
throw remapPathError(error, prefix);
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1050
|
-
async function* mapMountGrep(source, prefix) {
|
|
1051
|
-
try {
|
|
1052
|
-
for await (const hit of source) {
|
|
1053
|
-
yield { ...hit, path: toParentPath(hit.path, prefix) };
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
catch (error) {
|
|
1057
|
-
throw remapPathError(error, prefix);
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
785
|
function omittedScan(path) {
|
|
1061
786
|
return path === undefined || path === "";
|
|
1062
787
|
}
|
|
@@ -1088,416 +813,6 @@ export function sessionFileSystem(options) {
|
|
|
1088
813
|
grep: (query) => (omittedScan(query.path) ? options.authored.grep(query) : union.grep(query)),
|
|
1089
814
|
};
|
|
1090
815
|
}
|
|
1091
|
-
/** Forwards reads. `write` and `delete` throw `read-only mount`. */
|
|
1092
|
-
export function readOnlyFs(inner) {
|
|
1093
|
-
return {
|
|
1094
|
-
list: (prefix, options) => inner.list(prefix, options),
|
|
1095
|
-
stat: (path) => inner.stat(path),
|
|
1096
|
-
glob: (pattern, dir, options) => inner.glob(pattern, dir, options),
|
|
1097
|
-
read: (path) => inner.read(path),
|
|
1098
|
-
grep: (query) => inner.grep(query),
|
|
1099
|
-
async write(path) {
|
|
1100
|
-
throw new ReadOnlyMountError(normalizeFsPath(path));
|
|
1101
|
-
},
|
|
1102
|
-
async delete(path) {
|
|
1103
|
-
throw new ReadOnlyMountError(normalizeFsPath(path));
|
|
1104
|
-
},
|
|
1105
|
-
};
|
|
1106
|
-
}
|
|
1107
|
-
/**
|
|
1108
|
-
* Longest-prefix compose, path-segment match. Every verb is
|
|
1109
|
-
* defined. Does not synthesize `shell`. `/agent` is not a
|
|
1110
|
-
* prefix of `/agent-tools`.
|
|
1111
|
-
*
|
|
1112
|
-
* The record keys are mount points. Each child is a FileSystem
|
|
1113
|
-
* rooted at `/`. `unionFs` strips the prefix on the way in and
|
|
1114
|
-
* re-prefixes yields (and error paths) on the way out:
|
|
1115
|
-
* `unionFs({ "/host": hostFs(...) })` — the child never sees
|
|
1116
|
-
* `/host`.
|
|
1117
|
-
*
|
|
1118
|
-
* A path with no mount:
|
|
1119
|
-
* - `read` / `write` / `delete`: throw
|
|
1120
|
-
* `no mount for path: ${path}`
|
|
1121
|
-
* - `list` / `glob` / `grep`: empty iterator
|
|
1122
|
-
* - `stat`: `{ kind: "missing" }` (`/`, exact mount prefixes, and
|
|
1123
|
-
* their parents are `{ kind: "directory" }`)
|
|
1124
|
-
*
|
|
1125
|
-
* `list` and `glob` below `/` also yield the files of each mount nested
|
|
1126
|
-
* under that directory, as `list` and `glob` of `/` do. A nested glob
|
|
1127
|
-
* lists that mount and matches each path against the pattern. `grep`
|
|
1128
|
-
* stays on the mount that covers the path.
|
|
1129
|
-
*
|
|
1130
|
-
* Sources are already sorted longest prefix first. List and glob use
|
|
1131
|
-
* `unique` so that earlier source wins a tie.
|
|
1132
|
-
*/
|
|
1133
|
-
export function unionFs(mounts) {
|
|
1134
|
-
const entries = Object.entries(mounts).map(([prefix, fs]) => ({
|
|
1135
|
-
prefix: normalizeFsPath(prefix),
|
|
1136
|
-
fs,
|
|
1137
|
-
}));
|
|
1138
|
-
entries.sort((a, b) => b.prefix.length - a.prefix.length);
|
|
1139
|
-
const noMount = (path) => {
|
|
1140
|
-
throw new NoMountError(path);
|
|
1141
|
-
};
|
|
1142
|
-
const forward = async (path, run) => {
|
|
1143
|
-
const mount = longestMount(path, entries);
|
|
1144
|
-
if (mount === undefined) {
|
|
1145
|
-
return noMount(path);
|
|
1146
|
-
}
|
|
1147
|
-
const childPath = toChildPath(path, mount.prefix);
|
|
1148
|
-
try {
|
|
1149
|
-
return await run(mount.fs, childPath);
|
|
1150
|
-
}
|
|
1151
|
-
catch (error) {
|
|
1152
|
-
throw remapPathError(error, mount.prefix);
|
|
1153
|
-
}
|
|
1154
|
-
};
|
|
1155
|
-
const isRootPath = (value) => value === undefined || value === "" || value === "/";
|
|
1156
|
-
return {
|
|
1157
|
-
async *list(prefix, options) {
|
|
1158
|
-
yield* limitResults(uncapped(), options?.limit);
|
|
1159
|
-
async function* uncapped() {
|
|
1160
|
-
if (isRootPath(prefix)) {
|
|
1161
|
-
yield* mergeSortedByPath(entries.map((mount) => mapMountEntries(mount.fs.list(undefined, options), mount.prefix)), { unique: true });
|
|
1162
|
-
return;
|
|
1163
|
-
}
|
|
1164
|
-
const path = normalizeFsPath(prefix ?? "/");
|
|
1165
|
-
const mount = longestMount(path, entries);
|
|
1166
|
-
const sources = nestedMounts(path, entries).map((nested) => mapMountEntries(nested.fs.list(undefined, options), nested.prefix));
|
|
1167
|
-
if (mount !== undefined) {
|
|
1168
|
-
const childPath = toChildPath(path, mount.prefix);
|
|
1169
|
-
sources.push(mapMountEntries(mount.fs.list(childPath === "/" ? undefined : childPath, options), mount.prefix));
|
|
1170
|
-
}
|
|
1171
|
-
yield* mergeSortedByPath(sources, { unique: true });
|
|
1172
|
-
}
|
|
1173
|
-
},
|
|
1174
|
-
async stat(path) {
|
|
1175
|
-
const normalized = normalizeFsPath(path);
|
|
1176
|
-
if (normalized === "/") {
|
|
1177
|
-
return { kind: "directory" };
|
|
1178
|
-
}
|
|
1179
|
-
if (entries.some((entry) => entry.prefix === normalized)) {
|
|
1180
|
-
return { kind: "directory" };
|
|
1181
|
-
}
|
|
1182
|
-
const mount = longestMount(normalized, entries);
|
|
1183
|
-
const info = mount === undefined
|
|
1184
|
-
? { kind: "missing" }
|
|
1185
|
-
: await mount.fs.stat(toChildPath(normalized, mount.prefix));
|
|
1186
|
-
if (info.kind === "missing" && nestedMounts(normalized, entries).length > 0) {
|
|
1187
|
-
return { kind: "directory" };
|
|
1188
|
-
}
|
|
1189
|
-
return info;
|
|
1190
|
-
},
|
|
1191
|
-
async read(path) {
|
|
1192
|
-
const normalized = normalizeFsPath(path);
|
|
1193
|
-
return forward(normalized, (fs, childPath) => fs.read(childPath));
|
|
1194
|
-
},
|
|
1195
|
-
async write(path, contents) {
|
|
1196
|
-
const normalized = normalizeFsPath(path);
|
|
1197
|
-
return forward(normalized, (fs, childPath) => fs.write(childPath, contents));
|
|
1198
|
-
},
|
|
1199
|
-
async delete(path) {
|
|
1200
|
-
const normalized = normalizeFsPath(path);
|
|
1201
|
-
return forward(normalized, (fs, childPath) => fs.delete(childPath));
|
|
1202
|
-
},
|
|
1203
|
-
async *grep(query) {
|
|
1204
|
-
yield* limitResults(uncapped(), query.maxResults);
|
|
1205
|
-
async function* uncapped() {
|
|
1206
|
-
const scope = query.path === undefined || query.path === "" ? "/" : normalizeFsPath(query.path);
|
|
1207
|
-
if (scope === "/") {
|
|
1208
|
-
yield* mergeSorted(entries.map((mount) => mapMountGrep(mount.fs.grep({ ...query, path: undefined }), mount.prefix)), { compare: compareGrepResult });
|
|
1209
|
-
return;
|
|
1210
|
-
}
|
|
1211
|
-
const mount = longestMount(scope, entries);
|
|
1212
|
-
if (mount === undefined) {
|
|
1213
|
-
return;
|
|
1214
|
-
}
|
|
1215
|
-
const childPath = toChildPath(scope, mount.prefix);
|
|
1216
|
-
yield* mapMountGrep(mount.fs.grep({
|
|
1217
|
-
...query,
|
|
1218
|
-
path: childPath === "/" ? undefined : childPath,
|
|
1219
|
-
}), mount.prefix);
|
|
1220
|
-
}
|
|
1221
|
-
},
|
|
1222
|
-
async *glob(pattern, dir, options) {
|
|
1223
|
-
yield* limitResults(uncapped(), options?.limit);
|
|
1224
|
-
async function* uncapped() {
|
|
1225
|
-
const scope = dir === undefined || dir === "" ? "/" : normalizeFsPath(dir);
|
|
1226
|
-
if (scope === "/") {
|
|
1227
|
-
yield* mergeSortedByPath(entries.map((mount) => mapMountEntries(mount.fs.glob(pattern, undefined, options), mount.prefix)), { unique: true });
|
|
1228
|
-
return;
|
|
1229
|
-
}
|
|
1230
|
-
const mount = longestMount(scope, entries);
|
|
1231
|
-
const sources = nestedMounts(scope, entries).map((nested) => globNestedMount(nested, scope, pattern));
|
|
1232
|
-
if (mount !== undefined) {
|
|
1233
|
-
const childPath = toChildPath(scope, mount.prefix);
|
|
1234
|
-
sources.push(mapMountEntries(mount.fs.glob(pattern, childPath === "/" ? undefined : childPath, options), mount.prefix));
|
|
1235
|
-
}
|
|
1236
|
-
yield* mergeSortedByPath(sources, { unique: true });
|
|
1237
|
-
}
|
|
1238
|
-
},
|
|
1239
|
-
};
|
|
1240
|
-
}
|
|
1241
|
-
async function collectLayerPaths(layer) {
|
|
1242
|
-
const paths = [];
|
|
1243
|
-
try {
|
|
1244
|
-
for await (const entry of layer.list()) {
|
|
1245
|
-
paths.push(entry.path);
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
catch {
|
|
1249
|
-
// A layer that cannot list also cannot own paths.
|
|
1250
|
-
}
|
|
1251
|
-
return paths;
|
|
1252
|
-
}
|
|
1253
|
-
/**
|
|
1254
|
-
* Same-root overlay: earlier layers win. Read-only.
|
|
1255
|
-
*
|
|
1256
|
-
* A downed layer costs its own files, not the overlay. Mutations
|
|
1257
|
-
* throw `read-only mount` / `read-only mount: ${path}`. Empty
|
|
1258
|
-
* `layers` throws `overlayFs needs at least one layer.`
|
|
1259
|
-
*/
|
|
1260
|
-
export function overlayFs(layers) {
|
|
1261
|
-
if (layers.length === 0) {
|
|
1262
|
-
throw new Error("overlayFs needs at least one layer.");
|
|
1263
|
-
}
|
|
1264
|
-
const walkLayers = async (collect) => {
|
|
1265
|
-
const streams = [];
|
|
1266
|
-
let failure;
|
|
1267
|
-
let served = false;
|
|
1268
|
-
for (const layer of layers) {
|
|
1269
|
-
const collected = [];
|
|
1270
|
-
try {
|
|
1271
|
-
for await (const entry of await collect(layer)) {
|
|
1272
|
-
collected.push(entry);
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
|
-
catch (error) {
|
|
1276
|
-
failure ??= error;
|
|
1277
|
-
continue;
|
|
1278
|
-
}
|
|
1279
|
-
served = true;
|
|
1280
|
-
streams.push(collected);
|
|
1281
|
-
}
|
|
1282
|
-
return { streams, failure, served };
|
|
1283
|
-
};
|
|
1284
|
-
const collectOverlayHits = async (queryFn, rethrow) => {
|
|
1285
|
-
const streams = [];
|
|
1286
|
-
const shadowed = new Set();
|
|
1287
|
-
let failure;
|
|
1288
|
-
let served = false;
|
|
1289
|
-
for (const layer of layers) {
|
|
1290
|
-
const collected = [];
|
|
1291
|
-
try {
|
|
1292
|
-
for await (const hit of queryFn(layer)) {
|
|
1293
|
-
if (!shadowed.has(hit.path)) {
|
|
1294
|
-
collected.push(hit);
|
|
1295
|
-
}
|
|
1296
|
-
}
|
|
1297
|
-
served = true;
|
|
1298
|
-
}
|
|
1299
|
-
catch (error) {
|
|
1300
|
-
if (rethrow?.(error) === true) {
|
|
1301
|
-
throw error;
|
|
1302
|
-
}
|
|
1303
|
-
failure ??= error;
|
|
1304
|
-
continue;
|
|
1305
|
-
}
|
|
1306
|
-
streams.push(collected);
|
|
1307
|
-
for (const path of await collectLayerPaths(layer)) {
|
|
1308
|
-
shadowed.add(path);
|
|
1309
|
-
}
|
|
1310
|
-
}
|
|
1311
|
-
if (!served && failure !== undefined) {
|
|
1312
|
-
throw failure;
|
|
1313
|
-
}
|
|
1314
|
-
return streams;
|
|
1315
|
-
};
|
|
1316
|
-
return {
|
|
1317
|
-
async *list(prefix, options) {
|
|
1318
|
-
const { streams, failure, served } = await walkLayers((layer) => layer.list(prefix, options));
|
|
1319
|
-
if (!served && failure !== undefined) {
|
|
1320
|
-
throw failure;
|
|
1321
|
-
}
|
|
1322
|
-
yield* limitResults(mergeSortedByPath(streams, { unique: true }), options?.limit);
|
|
1323
|
-
},
|
|
1324
|
-
async stat(path) {
|
|
1325
|
-
let failure;
|
|
1326
|
-
let sawMissing = false;
|
|
1327
|
-
for (const layer of layers) {
|
|
1328
|
-
try {
|
|
1329
|
-
const info = await layer.stat(path);
|
|
1330
|
-
if (info.kind !== "missing") {
|
|
1331
|
-
return info;
|
|
1332
|
-
}
|
|
1333
|
-
sawMissing = true;
|
|
1334
|
-
}
|
|
1335
|
-
catch (error) {
|
|
1336
|
-
failure ??= error;
|
|
1337
|
-
}
|
|
1338
|
-
}
|
|
1339
|
-
if (!sawMissing && failure !== undefined) {
|
|
1340
|
-
throw failure;
|
|
1341
|
-
}
|
|
1342
|
-
return { kind: "missing" };
|
|
1343
|
-
},
|
|
1344
|
-
async *glob(pattern, dir, options) {
|
|
1345
|
-
const { streams, failure, served } = await walkLayers((layer) => layer.glob(pattern, dir, options));
|
|
1346
|
-
if (!served && failure !== undefined) {
|
|
1347
|
-
throw failure;
|
|
1348
|
-
}
|
|
1349
|
-
yield* limitResults(mergeSortedByPath(streams, { unique: true }), options?.limit);
|
|
1350
|
-
},
|
|
1351
|
-
async read(path) {
|
|
1352
|
-
let failure;
|
|
1353
|
-
for (const layer of layers) {
|
|
1354
|
-
try {
|
|
1355
|
-
return await layer.read(path);
|
|
1356
|
-
}
|
|
1357
|
-
catch (error) {
|
|
1358
|
-
if (isFileNotFoundError(error)) {
|
|
1359
|
-
continue;
|
|
1360
|
-
}
|
|
1361
|
-
failure ??= error;
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
if (failure !== undefined) {
|
|
1365
|
-
throw failure;
|
|
1366
|
-
}
|
|
1367
|
-
throw new FileNotFoundError(path);
|
|
1368
|
-
},
|
|
1369
|
-
async *grep(query) {
|
|
1370
|
-
const { maxResults, ...uncappedQuery } = query;
|
|
1371
|
-
yield* limitResults(mergeSorted(await collectOverlayHits((layer) => layer.grep(uncappedQuery), (error) => isInvalidGrepPatternError(error)), { compare: compareGrepResult }), maxResults);
|
|
1372
|
-
},
|
|
1373
|
-
async write(path) {
|
|
1374
|
-
throw new ReadOnlyMountError(path);
|
|
1375
|
-
},
|
|
1376
|
-
async delete(path) {
|
|
1377
|
-
throw new ReadOnlyMountError(path);
|
|
1378
|
-
},
|
|
1379
|
-
};
|
|
1380
|
-
}
|
|
1381
|
-
/**
|
|
1382
|
-
* Hide `hidden` paths on `base` without mutating it. Used as the
|
|
1383
|
-
* lower layer of {@link childOverlayFs}. Deletes of parent files
|
|
1384
|
-
* are whiteouts in that set; writes never reach `base`.
|
|
1385
|
-
*/
|
|
1386
|
-
function hidePaths(base, hidden) {
|
|
1387
|
-
const visible = (filePath) => !hidden.has(normalizeFsPath(filePath));
|
|
1388
|
-
return {
|
|
1389
|
-
async *list(prefix, options) {
|
|
1390
|
-
for await (const entry of base.list(prefix, options)) {
|
|
1391
|
-
if (visible(entry.path)) {
|
|
1392
|
-
yield entry;
|
|
1393
|
-
}
|
|
1394
|
-
}
|
|
1395
|
-
},
|
|
1396
|
-
async stat(path) {
|
|
1397
|
-
const normalized = normalizeFsPath(path);
|
|
1398
|
-
if (hidden.has(normalized)) {
|
|
1399
|
-
return { kind: "missing" };
|
|
1400
|
-
}
|
|
1401
|
-
return base.stat(path);
|
|
1402
|
-
},
|
|
1403
|
-
async *glob(pattern, dir, options) {
|
|
1404
|
-
for await (const entry of base.glob(pattern, dir, options)) {
|
|
1405
|
-
if (visible(entry.path)) {
|
|
1406
|
-
yield entry;
|
|
1407
|
-
}
|
|
1408
|
-
}
|
|
1409
|
-
},
|
|
1410
|
-
async read(path) {
|
|
1411
|
-
const normalized = normalizeFsPath(path);
|
|
1412
|
-
if (hidden.has(normalized)) {
|
|
1413
|
-
throw new FileNotFoundError(normalized);
|
|
1414
|
-
}
|
|
1415
|
-
return base.read(path);
|
|
1416
|
-
},
|
|
1417
|
-
async *grep(query) {
|
|
1418
|
-
for await (const hit of base.grep(query)) {
|
|
1419
|
-
if (visible(hit.path)) {
|
|
1420
|
-
yield hit;
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
},
|
|
1424
|
-
async write(path) {
|
|
1425
|
-
throw new ReadOnlyMountError(normalizeFsPath(path));
|
|
1426
|
-
},
|
|
1427
|
-
async delete(path) {
|
|
1428
|
-
throw new ReadOnlyMountError(normalizeFsPath(path));
|
|
1429
|
-
},
|
|
1430
|
-
};
|
|
1431
|
-
}
|
|
1432
|
-
/**
|
|
1433
|
-
* `stat` reports `{ kind: "missing" }` for both a hole in a mount and
|
|
1434
|
-
* a path no mount owns. `read` is the verb that throws
|
|
1435
|
-
* `no mount for path` — reuse that so a child write cannot invent
|
|
1436
|
-
* a file outside the parent's root.
|
|
1437
|
-
*/
|
|
1438
|
-
async function assertParentAddressable(parent, path) {
|
|
1439
|
-
const info = await parent.stat(path);
|
|
1440
|
-
if (info.kind !== "missing") {
|
|
1441
|
-
return;
|
|
1442
|
-
}
|
|
1443
|
-
try {
|
|
1444
|
-
await parent.read(path);
|
|
1445
|
-
}
|
|
1446
|
-
catch (error) {
|
|
1447
|
-
if (isFileNotFoundError(error)) {
|
|
1448
|
-
return;
|
|
1449
|
-
}
|
|
1450
|
-
throw error;
|
|
1451
|
-
}
|
|
1452
|
-
}
|
|
1453
|
-
/**
|
|
1454
|
-
* Writable child view over `parent`. Reads use `overlayFs` order:
|
|
1455
|
-
* a private `tempFs` scratch, then `parent`. Writes and deletes land
|
|
1456
|
-
* on that scratch. A delete of a parent file is a whiteout, so the
|
|
1457
|
-
* child stops seeing it. `parent` is never mutated.
|
|
1458
|
-
*
|
|
1459
|
-
* FileSystem has no shell. Callers that bind executors to this handle
|
|
1460
|
-
* omit shell.
|
|
1461
|
-
*/
|
|
1462
|
-
export function childOverlayFs(parent) {
|
|
1463
|
-
const scratch = tempFs();
|
|
1464
|
-
const hidden = new Set();
|
|
1465
|
-
const view = overlayFs([scratch, hidePaths(parent, hidden)]);
|
|
1466
|
-
return {
|
|
1467
|
-
list: (prefix, options) => view.list(prefix, options),
|
|
1468
|
-
stat: (path) => view.stat(path),
|
|
1469
|
-
glob: (pattern, dir, options) => view.glob(pattern, dir, options),
|
|
1470
|
-
read: (path) => view.read(path),
|
|
1471
|
-
grep: (query) => view.grep(query),
|
|
1472
|
-
async write(path, contents) {
|
|
1473
|
-
const normalized = normalizeFsPath(path);
|
|
1474
|
-
await assertParentAddressable(parent, normalized);
|
|
1475
|
-
const existing = await view.stat(normalized);
|
|
1476
|
-
if (existing.kind === "directory") {
|
|
1477
|
-
throw new WriteFailedError(normalized, `path is a directory: ${normalized}`);
|
|
1478
|
-
}
|
|
1479
|
-
hidden.delete(normalized);
|
|
1480
|
-
await scratch.write(normalized, contents);
|
|
1481
|
-
},
|
|
1482
|
-
async delete(path) {
|
|
1483
|
-
const normalized = normalizeFsPath(path);
|
|
1484
|
-
await assertParentAddressable(parent, normalized);
|
|
1485
|
-
const info = await view.stat(normalized);
|
|
1486
|
-
if (info.kind !== "file") {
|
|
1487
|
-
throw new FileNotFoundError(normalized);
|
|
1488
|
-
}
|
|
1489
|
-
hidden.add(normalized);
|
|
1490
|
-
try {
|
|
1491
|
-
await scratch.delete(normalized);
|
|
1492
|
-
}
|
|
1493
|
-
catch (error) {
|
|
1494
|
-
if (!isFileNotFoundError(error)) {
|
|
1495
|
-
throw error;
|
|
1496
|
-
}
|
|
1497
|
-
}
|
|
1498
|
-
},
|
|
1499
|
-
};
|
|
1500
|
-
}
|
|
1501
816
|
function hostKey(path) {
|
|
1502
817
|
const normalized = normalizeFsPath(path);
|
|
1503
818
|
return normalized === "/" ? "" : normalized.slice(1);
|
|
@@ -1639,6 +954,10 @@ export function hostFs(files, scope) {
|
|
|
1639
954
|
});
|
|
1640
955
|
},
|
|
1641
956
|
async write(inputPath, contents) {
|
|
957
|
+
if (typeof contents !== "string") {
|
|
958
|
+
const path = normalizeFsPath(inputPath);
|
|
959
|
+
throw new WriteFailedError(path, `write failed: ${path} (host files store text only)`);
|
|
960
|
+
}
|
|
1642
961
|
await writeHost(inputPath, contents);
|
|
1643
962
|
},
|
|
1644
963
|
async delete(inputPath) {
|