@grok/agent-sdk 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/dist/channels/match-ready/index.d.ts +4 -0
  2. package/dist/channels/match-ready/index.d.ts.map +1 -0
  3. package/dist/channels/match-ready/index.js +2 -0
  4. package/dist/channels/match-ready/match-ready-channel.d.ts +5 -0
  5. package/dist/channels/match-ready/match-ready-channel.d.ts.map +1 -0
  6. package/dist/channels/match-ready/match-ready-channel.js +42 -0
  7. package/dist/channels/match-ready/types.d.ts +25 -0
  8. package/dist/channels/match-ready/types.d.ts.map +1 -0
  9. package/dist/channels/match-ready/types.js +1 -0
  10. package/dist/channels/slack/manifest.d.ts.map +1 -1
  11. package/dist/channels/slack/manifest.js +2 -15
  12. package/dist/docs/404.html +2 -2
  13. package/dist/docs/assets/{app.BSH__xV4.js → app.lt-BYgI2.js} +4 -4
  14. package/dist/docs/assets/changelog.md.DVNB-ApU.js +1 -0
  15. package/dist/docs/assets/changelog.md.DVNB-ApU.lean.js +1 -0
  16. package/dist/docs/assets/chunks/@localSearchIndexroot.DdlR-9Oe.js +1 -0
  17. package/dist/docs/assets/chunks/{VPLocalSearchBox.Cadl7A0k.js → VPLocalSearchBox.v_dV4U2Q.js} +1 -1
  18. package/dist/docs/assets/chunks/{arc.K7t9nNY6.js → arc.5o92kOg5.js} +1 -1
  19. package/dist/docs/assets/chunks/{architectureDiagram-Q4EWVU46.SlHEknkX.js → architectureDiagram-Q4EWVU46.C-oTwnNq.js} +1 -1
  20. package/dist/docs/assets/chunks/{baseUniq.DJLRMLkz.js → baseUniq.zJ-VNOib.js} +1 -1
  21. package/dist/docs/assets/chunks/{blockDiagram-DXYQGD6D.Bs6XxFpe.js → blockDiagram-DXYQGD6D.B9ZJZuPd.js} +1 -1
  22. package/dist/docs/assets/chunks/{c4Diagram-AHTNJAMY.CyLg6Ovc.js → c4Diagram-AHTNJAMY.BBMwSIaN.js} +1 -1
  23. package/dist/docs/assets/chunks/channel.CdyTxaXV.js +1 -0
  24. package/dist/docs/assets/chunks/{chunk-4BX2VUAB.DTQ4TinT.js → chunk-4BX2VUAB.D8qAJpDD.js} +1 -1
  25. package/dist/docs/assets/chunks/{chunk-4TB4RGXK.Es84IgcH.js → chunk-4TB4RGXK.B8QR5cdE.js} +1 -1
  26. package/dist/docs/assets/chunks/{chunk-55IACEB6.Clm3cGPQ.js → chunk-55IACEB6.BsWxVuew.js} +1 -1
  27. package/dist/docs/assets/chunks/{chunk-EDXVE4YY.DE4CRkS5.js → chunk-EDXVE4YY.BeGygY_i.js} +1 -1
  28. package/dist/docs/assets/chunks/{chunk-FMBD7UC4.Bf8HCvqp.js → chunk-FMBD7UC4.DdwgH-ZH.js} +1 -1
  29. package/dist/docs/assets/chunks/{chunk-OYMX7WX6.eub-7nSx.js → chunk-OYMX7WX6.B9zC_ALe.js} +1 -1
  30. package/dist/docs/assets/chunks/{chunk-QZHKN3VN.WyP9VAS_.js → chunk-QZHKN3VN.BIxJ0rcL.js} +1 -1
  31. package/dist/docs/assets/chunks/{chunk-YZCP3GAM.LO9ohhDE.js → chunk-YZCP3GAM.qiM_23_f.js} +1 -1
  32. package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.CeUcN6TW.js +1 -0
  33. package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.CeUcN6TW.js +1 -0
  34. package/dist/docs/assets/chunks/clone.DpIwUbur.js +1 -0
  35. package/dist/docs/assets/chunks/{cose-bilkent-S5V4N54A.D5za6aH0.js → cose-bilkent-S5V4N54A.BKB971D5.js} +1 -1
  36. package/dist/docs/assets/chunks/{dagre-KV5264BT.Dq1daUru.js → dagre-KV5264BT.CcILjJgp.js} +1 -1
  37. package/dist/docs/assets/chunks/{diagram-5BDNPKRD.j1YL5BKS.js → diagram-5BDNPKRD.DkY9A0nu.js} +1 -1
  38. package/dist/docs/assets/chunks/{diagram-G4DWMVQ6.Bi1aLdhC.js → diagram-G4DWMVQ6.BbdzmjMt.js} +1 -1
  39. package/dist/docs/assets/chunks/{diagram-MMDJMWI5.BOzMEkAr.js → diagram-MMDJMWI5.Be0zy1cM.js} +1 -1
  40. package/dist/docs/assets/chunks/{diagram-TYMM5635.Dx2FVhCr.js → diagram-TYMM5635.zOiEycLe.js} +1 -1
  41. package/dist/docs/assets/chunks/{erDiagram-SMLLAGMA.DI4TNkye.js → erDiagram-SMLLAGMA.DUd_9HMF.js} +1 -1
  42. package/dist/docs/assets/chunks/{flowDiagram-DWJPFMVM.C58Z9uPK.js → flowDiagram-DWJPFMVM.2KPYoZBO.js} +1 -1
  43. package/dist/docs/assets/chunks/{ganttDiagram-T4ZO3ILL.DXSpW809.js → ganttDiagram-T4ZO3ILL.DqE8_YpP.js} +1 -1
  44. package/dist/docs/assets/chunks/{gitGraphDiagram-UUTBAWPF.B955oaFl.js → gitGraphDiagram-UUTBAWPF.CO0Tk47h.js} +1 -1
  45. package/dist/docs/assets/chunks/{graph.BQXhKtxS.js → graph.CNe5KbNy.js} +1 -1
  46. package/dist/docs/assets/chunks/{infoDiagram-42DDH7IO.Dozj_-Gm.js → infoDiagram-42DDH7IO.BBhJ1X1B.js} +1 -1
  47. package/dist/docs/assets/chunks/{ishikawaDiagram-UXIWVN3A.D2140OzH.js → ishikawaDiagram-UXIWVN3A.KSIw9w3I.js} +1 -1
  48. package/dist/docs/assets/chunks/{journeyDiagram-VCZTEJTY.DrqrMhCk.js → journeyDiagram-VCZTEJTY.BN2Y5oUJ.js} +1 -1
  49. package/dist/docs/assets/chunks/{kanban-definition-6JOO6SKY.Dv-LTrlw.js → kanban-definition-6JOO6SKY.2KFuDYn_.js} +1 -1
  50. package/dist/docs/assets/chunks/{layout.CGtHp49X.js → layout.Demb_pzL.js} +1 -1
  51. package/dist/docs/assets/chunks/{linear.CHZLYB52.js → linear.kYKxzbbR.js} +1 -1
  52. package/dist/docs/assets/chunks/{min.D4Vt3eIy.js → min.DwmCN5dF.js} +1 -1
  53. package/dist/docs/assets/chunks/{mindmap-definition-QFDTVHPH.BBfpYTea.js → mindmap-definition-QFDTVHPH.CGlz01QG.js} +1 -1
  54. package/dist/docs/assets/chunks/{pieDiagram-DEJITSTG.BVYvElmY.js → pieDiagram-DEJITSTG.n3qsq4nA.js} +1 -1
  55. package/dist/docs/assets/chunks/{quadrantDiagram-34T5L4WZ.C6Gc2mdY.js → quadrantDiagram-34T5L4WZ.CGNJ1GSb.js} +1 -1
  56. package/dist/docs/assets/chunks/{requirementDiagram-MS252O5E.DWa8b4cn.js → requirementDiagram-MS252O5E.VhAzHDwQ.js} +1 -1
  57. package/dist/docs/assets/chunks/{sankeyDiagram-XADWPNL6.Bi-g4ajv.js → sankeyDiagram-XADWPNL6.DmHA5pW-.js} +1 -1
  58. package/dist/docs/assets/chunks/{sequenceDiagram-FGHM5R23.DlU3vVN9.js → sequenceDiagram-FGHM5R23._TC1aKhg.js} +1 -1
  59. package/dist/docs/assets/chunks/{stateDiagram-FHFEXIEX.CeqJRqnU.js → stateDiagram-FHFEXIEX.B-kLjV3O.js} +1 -1
  60. package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.HtBkUH4J.js +1 -0
  61. package/dist/docs/assets/chunks/{theme.DGq7D4tt.js → theme.BaVlHHL-.js} +2 -2
  62. package/dist/docs/assets/chunks/{timeline-definition-GMOUNBTQ.Cqf2kjq9.js → timeline-definition-GMOUNBTQ.CresbphV.js} +1 -1
  63. package/dist/docs/assets/chunks/{vennDiagram-DHZGUBPP.BeOpE_lM.js → vennDiagram-DHZGUBPP.CegHD8Y4.js} +1 -1
  64. package/dist/docs/assets/chunks/{wardley-RL74JXVD.FMQXA-6q.js → wardley-RL74JXVD.DjCmZrUO.js} +1 -1
  65. package/dist/docs/assets/chunks/{wardleyDiagram-NUSXRM2D.BXS65dAC.js → wardleyDiagram-NUSXRM2D.BJ7s1zdZ.js} +1 -1
  66. package/dist/docs/assets/chunks/{xychartDiagram-5P7HB3ND.haEiSxqc.js → xychartDiagram-5P7HB3ND.IrEXlemI.js} +1 -1
  67. package/dist/docs/assets/{reference_agent-config.md.BSNp2uJ7.js → reference_agent-config.md.Bbqf0lgS.js} +11 -3
  68. package/dist/docs/assets/{reference_agent-config.md.BSNp2uJ7.lean.js → reference_agent-config.md.Bbqf0lgS.lean.js} +1 -1
  69. package/dist/docs/assets/{reference_schedules.md.Dd8_d0WG.js → reference_schedules.md.RhQ9ZLo1.js} +3 -3
  70. package/dist/docs/assets/{reference_tools.md.B2OaR1Nb.js → reference_tools.md.BhqW6neF.js} +4 -2
  71. package/dist/docs/assets/{reference_tools.md.B2OaR1Nb.lean.js → reference_tools.md.BhqW6neF.lean.js} +1 -1
  72. package/dist/docs/building-with-agents.html +35 -35
  73. package/dist/docs/changelog.html +36 -36
  74. package/dist/docs/changelog.md +47 -7
  75. package/dist/docs/deployment.html +35 -35
  76. package/dist/docs/evals.html +35 -35
  77. package/dist/docs/guides/agent-to-agent.html +35 -35
  78. package/dist/docs/guides/bitbucket.html +35 -35
  79. package/dist/docs/guides/cloud-agents.html +35 -35
  80. package/dist/docs/guides/convert-automation.html +35 -35
  81. package/dist/docs/guides/github.html +35 -35
  82. package/dist/docs/guides/gitlab.html +35 -35
  83. package/dist/docs/guides/improve.html +35 -35
  84. package/dist/docs/guides/jev.html +35 -35
  85. package/dist/docs/guides/mcp-oauth.html +35 -35
  86. package/dist/docs/guides/migrate.html +35 -35
  87. package/dist/docs/guides/opentelemetry.html +35 -35
  88. package/dist/docs/guides/pagerduty.html +35 -35
  89. package/dist/docs/guides/slack.html +35 -35
  90. package/dist/docs/guides/webhooks.html +35 -35
  91. package/dist/docs/hashmap.json +1 -1
  92. package/dist/docs/hillclimbing.html +35 -35
  93. package/dist/docs/index.html +35 -35
  94. package/dist/docs/llms-full.txt +129 -11
  95. package/dist/docs/quickstart.html +35 -35
  96. package/dist/docs/reference/access.html +35 -35
  97. package/dist/docs/reference/agent-config.html +45 -37
  98. package/dist/docs/reference/agent-config.md +70 -4
  99. package/dist/docs/reference/artifacts.html +35 -35
  100. package/dist/docs/reference/channels.html +35 -35
  101. package/dist/docs/reference/cli.html +35 -35
  102. package/dist/docs/reference/connections.html +35 -35
  103. package/dist/docs/reference/evals.html +35 -35
  104. package/dist/docs/reference/extensions.html +35 -35
  105. package/dist/docs/reference/hooks.html +35 -35
  106. package/dist/docs/reference/http-api.html +35 -35
  107. package/dist/docs/reference/instructions.html +35 -35
  108. package/dist/docs/reference/limits.html +35 -35
  109. package/dist/docs/reference/memory.html +35 -35
  110. package/dist/docs/reference/playground.html +35 -35
  111. package/dist/docs/reference/project-layout.html +35 -35
  112. package/dist/docs/reference/schedules.html +38 -38
  113. package/dist/docs/reference/sessions.html +35 -35
  114. package/dist/docs/reference/skills.html +35 -35
  115. package/dist/docs/reference/subagents.html +35 -35
  116. package/dist/docs/reference/tools.html +39 -37
  117. package/dist/docs/reference/tools.md +12 -0
  118. package/dist/docs/templates/agentic-owners.html +35 -35
  119. package/dist/docs/templates/reviews.html +35 -35
  120. package/dist/docs/troubleshooting.html +35 -35
  121. package/dist/filesystem.d.ts +10 -97
  122. package/dist/filesystem.d.ts.map +1 -1
  123. package/dist/filesystem.js +28 -290
  124. package/dist/index.d.ts +0 -2
  125. package/dist/index.d.ts.map +1 -1
  126. package/dist/index.js +0 -2
  127. package/dist/internal/cli-deploy.d.ts.map +1 -1
  128. package/dist/internal/cli-deploy.js +12 -7
  129. package/dist/internal/continuation-channel.d.ts +3 -3
  130. package/dist/internal/continuation-channel.js +3 -3
  131. package/dist/internal/continuation-identity.d.ts +6 -5
  132. package/dist/internal/continuation-identity.d.ts.map +1 -1
  133. package/dist/internal/continuation-identity.js +17 -2
  134. package/dist/internal/direct-file-tools.d.ts +21 -0
  135. package/dist/internal/direct-file-tools.d.ts.map +1 -0
  136. package/dist/internal/direct-file-tools.js +60 -0
  137. package/dist/internal/discovery/agent.d.ts.map +1 -1
  138. package/dist/internal/discovery/agent.js +71 -66
  139. package/dist/internal/filesystem/walk.d.ts +4 -52
  140. package/dist/internal/filesystem/walk.d.ts.map +1 -1
  141. package/dist/internal/filesystem/walk.js +4 -190
  142. package/dist/internal/hosted-delivery-protocol.d.ts +3 -0
  143. package/dist/internal/hosted-delivery-protocol.d.ts.map +1 -1
  144. package/dist/internal/hosted-delivery-protocol.js +2 -0
  145. package/dist/internal/hosted-delivery.d.ts.map +1 -1
  146. package/dist/internal/hosted-delivery.js +25 -10
  147. package/dist/internal/hosted-execution-latency.d.ts +3 -0
  148. package/dist/internal/hosted-execution-latency.d.ts.map +1 -1
  149. package/dist/internal/hosted-execution-latency.js +11 -0
  150. package/dist/internal/hosted-managed-automation.js +1 -1
  151. package/dist/internal/otel/http.d.ts +2 -1
  152. package/dist/internal/otel/http.d.ts.map +1 -1
  153. package/dist/internal/otel/http.js +2 -3
  154. package/dist/internal/sdk-runner.d.ts +1 -1
  155. package/dist/internal/sdk-runner.d.ts.map +1 -1
  156. package/dist/internal/sdk-runner.js +28 -40
  157. package/dist/internal/server.d.ts.map +1 -1
  158. package/dist/internal/server.js +8 -4
  159. package/dist/internal/session-engine.d.ts +34 -19
  160. package/dist/internal/session-engine.d.ts.map +1 -1
  161. package/dist/internal/session-engine.js +196 -251
  162. package/dist/internal/tcp-address.d.ts +3 -1
  163. package/dist/internal/tcp-address.d.ts.map +1 -1
  164. package/dist/internal/tcp-address.js +6 -0
  165. package/dist/internal/tool-paths.d.ts +8 -0
  166. package/dist/internal/tool-paths.d.ts.map +1 -0
  167. package/dist/internal/tool-paths.js +12 -0
  168. package/dist/internal/workspace-tree.d.ts +27 -0
  169. package/dist/internal/workspace-tree.d.ts.map +1 -0
  170. package/dist/internal/workspace-tree.js +106 -0
  171. package/dist/playground/assets/index-CnFd5R1_.js +62 -0
  172. package/dist/playground/assets/index-DNzRv6G8.css +1 -0
  173. package/dist/playground/index.html +2 -2
  174. package/dist/types.d.ts +48 -23
  175. package/dist/types.d.ts.map +1 -1
  176. package/docs/changelog.md +47 -7
  177. package/docs/reference/agent-config.md +70 -4
  178. package/docs/reference/tools.md +12 -0
  179. package/package.json +9 -14
  180. package/skills/deploy/SKILL.md +1 -1
  181. package/dist/docs/assets/changelog.md.b6H_ea44.js +0 -1
  182. package/dist/docs/assets/changelog.md.b6H_ea44.lean.js +0 -1
  183. package/dist/docs/assets/chunks/@localSearchIndexroot.CiRGcfZg.js +0 -1
  184. package/dist/docs/assets/chunks/channel.CVTdqYx0.js +0 -1
  185. package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.CsJJyx6-.js +0 -1
  186. package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.CsJJyx6-.js +0 -1
  187. package/dist/docs/assets/chunks/clone.Dk8KvtOB.js +0 -1
  188. package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.DE0BnUZh.js +0 -1
  189. package/dist/executors.d.ts +0 -11
  190. package/dist/executors.d.ts.map +0 -1
  191. package/dist/executors.js +0 -21
  192. package/dist/internal/filesystem/format.d.ts +0 -28
  193. package/dist/internal/filesystem/format.d.ts.map +0 -1
  194. package/dist/internal/filesystem/format.js +0 -209
  195. package/dist/internal/filesystem/nearest.d.ts +0 -15
  196. package/dist/internal/filesystem/nearest.d.ts.map +0 -1
  197. package/dist/internal/filesystem/nearest.js +0 -90
  198. package/dist/internal/filesystem/scratch.d.ts +0 -60
  199. package/dist/internal/filesystem/scratch.d.ts.map +0 -1
  200. package/dist/internal/filesystem/scratch.js +0 -187
  201. package/dist/internal/filesystem/sdk-schemas.d.ts +0 -29
  202. package/dist/internal/filesystem/sdk-schemas.d.ts.map +0 -1
  203. package/dist/internal/filesystem/sdk-schemas.js +0 -148
  204. package/dist/internal/filesystem/subagent-inherit.d.ts +0 -39
  205. package/dist/internal/filesystem/subagent-inherit.d.ts.map +0 -1
  206. package/dist/internal/filesystem/subagent-inherit.js +0 -96
  207. package/dist/internal/filesystem/tools.d.ts +0 -59
  208. package/dist/internal/filesystem/tools.d.ts.map +0 -1
  209. package/dist/internal/filesystem/tools.js +0 -634
  210. package/dist/internal/otel/propagation.d.ts +0 -7
  211. package/dist/internal/otel/propagation.d.ts.map +0 -1
  212. package/dist/internal/otel/propagation.js +0 -15
  213. package/dist/internal/sdk-subagent-inherit-support.d.ts +0 -9
  214. package/dist/internal/sdk-subagent-inherit-support.d.ts.map +0 -1
  215. package/dist/internal/sdk-subagent-inherit-support.js +0 -90
  216. package/dist/playground/assets/index-Bno25Cg0.css +0 -1
  217. package/dist/playground/assets/index-SGKsaznh.js +0 -62
  218. /package/dist/docs/assets/{reference_schedules.md.Dd8_d0WG.lean.js → reference_schedules.md.RhQ9ZLo1.lean.js} +0 -0
@@ -1 +0,0 @@
1
- import{U as a,D as n}from"../app.BSH__xV4.js";const t=(r,o)=>a.lang.round(n.parse(r)[o]);export{t as c};
@@ -1 +0,0 @@
1
- import{s as a,c as s,a as e,C as t}from"./chunk-4TB4RGXK.Es84IgcH.js";import{_ as i}from"../app.BSH__xV4.js";import"./chunk-FMBD7UC4.Bf8HCvqp.js";import"./chunk-YZCP3GAM.LO9ohhDE.js";import"./chunk-55IACEB6.Clm3cGPQ.js";import"./chunk-EDXVE4YY.DE4CRkS5.js";import"./framework.BNw1pucY.js";import"./theme.DGq7D4tt.js";var f={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{f as diagram};
@@ -1 +0,0 @@
1
- import{s as a,c as s,a as e,C as t}from"./chunk-4TB4RGXK.Es84IgcH.js";import{_ as i}from"../app.BSH__xV4.js";import"./chunk-FMBD7UC4.Bf8HCvqp.js";import"./chunk-YZCP3GAM.LO9ohhDE.js";import"./chunk-55IACEB6.Clm3cGPQ.js";import"./chunk-EDXVE4YY.DE4CRkS5.js";import"./framework.BNw1pucY.js";import"./theme.DGq7D4tt.js";var f={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{f as diagram};
@@ -1 +0,0 @@
1
- import{b as r}from"./graph.BQXhKtxS.js";var e=4;function a(o){return r(o,e)}export{a as c};
@@ -1 +0,0 @@
1
- import{s as r,b as e,a,S as s}from"./chunk-OYMX7WX6.eub-7nSx.js";import{_ as i}from"../app.BSH__xV4.js";import"./chunk-55IACEB6.Clm3cGPQ.js";import"./chunk-EDXVE4YY.DE4CRkS5.js";import"./framework.BNw1pucY.js";import"./theme.DGq7D4tt.js";var u={parser:a,get db(){return new s(2)},renderer:e,styles:r,init:i(t=>{t.state||(t.state={}),t.state.arrowMarkerAbsolute=t.arrowMarkerAbsolute},"init")};export{u as diagram};
@@ -1,11 +0,0 @@
1
- /**
2
- * Published `@grok/agent-sdk/executors` entry.
3
- *
4
- * These adapters are not included in the published package.
5
- */
6
- import type { FileSystem } from "./filesystem.js";
7
- export declare function createFileSystemReadExecutor(root: FileSystem): never;
8
- export declare function createFileSystemWriteExecutor(root: FileSystem): never;
9
- export declare function createFileSystemGrepExecutor(root: FileSystem): never;
10
- export declare function createFileSystemLsExecutor(root: FileSystem): never;
11
- //# sourceMappingURL=executors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"executors.d.ts","sourceRoot":"","sources":["../src/executors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AASlD,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,UAAU,GAAG,KAAK,CAEpE;AAED,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,UAAU,GAAG,KAAK,CAErE;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,UAAU,GAAG,KAAK,CAEpE;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,UAAU,GAAG,KAAK,CAElE"}
package/dist/executors.js DELETED
@@ -1,21 +0,0 @@
1
- /**
2
- * Published `@grok/agent-sdk/executors` entry.
3
- *
4
- * These adapters are not included in the published package.
5
- */
6
- const PUBLISHED_EXECUTORS_ERROR = "@grok/agent-sdk/executors is not included in the published package.";
7
- function unpublishedExecutors(_root) {
8
- throw new Error(PUBLISHED_EXECUTORS_ERROR);
9
- }
10
- export function createFileSystemReadExecutor(root) {
11
- return unpublishedExecutors(root);
12
- }
13
- export function createFileSystemWriteExecutor(root) {
14
- return unpublishedExecutors(root);
15
- }
16
- export function createFileSystemGrepExecutor(root) {
17
- return unpublishedExecutors(root);
18
- }
19
- export function createFileSystemLsExecutor(root) {
20
- return unpublishedExecutors(root);
21
- }
@@ -1,28 +0,0 @@
1
- /**
2
- * Model-facing strings that match Cursor SDK native tool output
3
- * (LocalLsExecutor / read / grep / glob formatters).
4
- */
5
- import type { GrepUnionResult } from "../../filesystem.js";
6
- import type { LsDirectoryTreeNode } from "./walk.js";
7
- /**
8
- * Number already-sliced Read content. `FileSystem.read` applies offset/
9
- * limit; do not window again or line numbers restart at 1.
10
- */
11
- export declare function slicedReadStartLine(totalLines: number, offset?: number): number;
12
- export declare function formatNumberedLines(content: string, options?: {
13
- offset?: number;
14
- limit?: number;
15
- /** When set, `content` is already the window; number from this line. */
16
- startLine?: number;
17
- totalLines?: number;
18
- }): string;
19
- export declare function formatLsTree(result: LsDirectoryTreeNode): string;
20
- export declare function formatGlobOutput(dir: string, files: readonly string[]): string;
21
- export declare function formatGrepOutput(union: GrepUnionResult | undefined): string;
22
- export declare function formatWriteOutput(path: string): string;
23
- export declare function formatStrReplaceOutput(args: {
24
- path: string;
25
- replaceAll: boolean;
26
- occurrencesModified: number;
27
- }): string;
28
- //# sourceMappingURL=format.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/internal/filesystem/format.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAKrD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ/E;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CAChB,GACL,MAAM,CAoBR;AAeD,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAsChE;AAiED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAmB9E;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eAAe,GAAG,SAAS,GAAG,MAAM,CAwC3E;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC;CAC7B,GAAG,MAAM,CAOT"}
@@ -1,209 +0,0 @@
1
- /**
2
- * Model-facing strings that match Cursor SDK native tool output
3
- * (LocalLsExecutor / read / grep / glob formatters).
4
- */
5
- import { posix } from "node:path";
6
- const LS_RENDER_CHARACTER_BUDGET = 10_000;
7
- const GLOB_TOTAL_CHARACTER_BUDGET = 5_000;
8
- /**
9
- * Number already-sliced Read content. `FileSystem.read` applies offset/
10
- * limit; do not window again or line numbers restart at 1.
11
- */
12
- export function slicedReadStartLine(totalLines, offset) {
13
- if (offset === undefined) {
14
- return 1;
15
- }
16
- if (offset < 0) {
17
- return Math.max(1, totalLines + offset + 1);
18
- }
19
- return Math.max(1, offset);
20
- }
21
- export function formatNumberedLines(content, options = {}) {
22
- const lines = content === "" ? [] : content.split("\n");
23
- if (lines.length === 0) {
24
- return "";
25
- }
26
- const { offset, limit, startLine } = options;
27
- let start = 1;
28
- let window = lines;
29
- const total = options.totalLines ?? lines.length;
30
- if (startLine !== undefined) {
31
- start = startLine;
32
- }
33
- else if (offset !== undefined || limit !== undefined) {
34
- const effectiveOffset = offset ?? 1;
35
- const effectiveLimit = limit ?? (effectiveOffset < 0 ? Math.abs(effectiveOffset) : total);
36
- start =
37
- effectiveOffset < 0 ? Math.max(1, total + effectiveOffset + 1) : Math.max(1, effectiveOffset);
38
- const end = Math.min(total, start + effectiveLimit - 1);
39
- window = lines.slice(start - 1, end);
40
- }
41
- return renderNumberedWindow(window, start, total);
42
- }
43
- function renderNumberedWindow(window, start, total) {
44
- const numbered = window.map((line, index) => `${String(start + index).padStart(6, " ")}|${line}`);
45
- let result = numbered.join("\n");
46
- if (start > 1) {
47
- result = `... ${start - 1} ${start - 1 === 1 ? "line" : "lines"} not shown ...\n${result}`;
48
- }
49
- const end = start + window.length - 1;
50
- if (end < total) {
51
- result += `\n... ${total - end} ${total - end === 1 ? "line" : "lines"} not shown ...`;
52
- }
53
- return result;
54
- }
55
- export function formatLsTree(result) {
56
- if (result.childrenWereProcessed &&
57
- result.childrenDirs.length === 0 &&
58
- result.childrenFiles.length === 0) {
59
- const trailingSlash = result.absPath.endsWith("/") ? "" : "/";
60
- return `${result.absPath}${trailingSlash}\n... no children found ...`;
61
- }
62
- const characterBudget = LS_RENDER_CHARACTER_BUDGET;
63
- let toolResponse = renderDirectoryTree(result).result;
64
- if (toolResponse.length > characterBudget) {
65
- toolResponse = renderDirectoryTree(result, true, 0).result;
66
- if (toolResponse.length > characterBudget) {
67
- toolResponse = renderDirectoryTree(result, false, 0).result;
68
- }
69
- }
70
- const notes = [];
71
- if (!result.childrenWereProcessed || toolResponse.length > characterBudget) {
72
- if (toolResponse.length > characterBudget) {
73
- toolResponse = toolResponse.slice(0, characterBudget);
74
- const lastNewlineIndex = toolResponse.lastIndexOf("\n");
75
- if (lastNewlineIndex > 0) {
76
- toolResponse = toolResponse.slice(0, lastNewlineIndex + 1);
77
- }
78
- }
79
- toolResponse += " ...\n";
80
- notes.push(`target_directory is too large (either too many children or their names are too long).` +
81
- ` Immediate children were truncated. Try doing more specific search or use the script tool.`);
82
- }
83
- if (notes.length === 1) {
84
- toolResponse += `\nNote: ${notes[0]}`;
85
- }
86
- return toolResponse;
87
- }
88
- function renderDirectoryTree(rootDirectory, renderExtensionCounts = true, renderDepthLimit) {
89
- function render(dir, depth) {
90
- const indent = " ".repeat(depth);
91
- let result;
92
- if (depth === 0) {
93
- const trailingSep = dir.absPath.endsWith("/") ? "" : "/";
94
- result = `${dir.absPath}${trailingSep}\n`;
95
- }
96
- else {
97
- result = `${indent}- ${posix.basename(dir.absPath)}/\n`;
98
- }
99
- const allChildren = [
100
- ...dir.childrenFiles.map((file) => ({
101
- type: "file",
102
- name: file.name,
103
- })),
104
- ...dir.childrenDirs.map((childDir) => ({
105
- type: "dir",
106
- name: posix.basename(childDir.absPath),
107
- dir: childDir,
108
- })),
109
- ];
110
- allChildren.sort((left, right) => left.name.localeCompare(right.name));
111
- const childIndent = " ".repeat(depth + 1);
112
- for (const child of allChildren) {
113
- if (child.type === "file") {
114
- result += `${childIndent}- ${child.name}\n`;
115
- continue;
116
- }
117
- const childDir = child.dir;
118
- if (childDir.childrenWereProcessed &&
119
- (renderDepthLimit === undefined || depth < renderDepthLimit)) {
120
- result += render(childDir, depth + 1);
121
- continue;
122
- }
123
- const extensionCounts = Object.entries(childDir.fullSubtreeExtensionCounts);
124
- if (extensionCounts.length > 0 && renderExtensionCounts) {
125
- const sorted = [...extensionCounts].sort(([, countA], [, countB]) => countB - countA);
126
- const shown = sorted.slice(0, 3);
127
- const summary = shown
128
- .map(([ext, count]) => `${count} *${ext === "" ? "" : ext}`)
129
- .join(", ");
130
- result += `${childIndent}- ${child.name}/ (${childDir.numFiles} files: ${summary})\n`;
131
- }
132
- else {
133
- result += `${childIndent}- ${child.name}/\n`;
134
- }
135
- }
136
- return result;
137
- }
138
- return { result: render(rootDirectory, 0) };
139
- }
140
- export function formatGlobOutput(dir, files) {
141
- const normalizedRoot = dir.replace(/\/+$/, "") || "/";
142
- const prefix = normalizedRoot === "/" ? "/" : `${normalizedRoot}/`;
143
- const relative = files.map((filePath) => filePath.startsWith(prefix) ? filePath.slice(prefix.length) : filePath);
144
- if (relative.length === 0) {
145
- return `Result of search in '${dir}': 0 files found\n`;
146
- }
147
- let output = `Result of search in '${dir}' (total ${relative.length} file${relative.length === 1 ? "" : "s"}):\n`;
148
- for (let i = 0; i < relative.length; i++) {
149
- const file = relative[i] ?? "";
150
- if (output.length + file.length > GLOB_TOTAL_CHARACTER_BUDGET) {
151
- output += `... ${relative.length - i} more files ... (Do a more specific search if needed)\n`;
152
- break;
153
- }
154
- output += `- ${file}\n`;
155
- }
156
- return output;
157
- }
158
- export function formatGrepOutput(union) {
159
- if (union === undefined) {
160
- return "No matches found";
161
- }
162
- if (union.type === "files") {
163
- if (union.output.files.length === 0) {
164
- return "No files with matches found";
165
- }
166
- return union.output.files.join("\n");
167
- }
168
- if (union.type === "count") {
169
- if (union.output.counts.length === 0) {
170
- return "No matches found";
171
- }
172
- return union.output.counts.map((row) => `${row.file}:${row.count}`).join("\n");
173
- }
174
- if (union.output.matches.length === 0) {
175
- return "No matches found";
176
- }
177
- const lines = [];
178
- let currentFile;
179
- for (const match of union.output.matches) {
180
- if (match.file !== currentFile) {
181
- if (currentFile !== undefined) {
182
- lines.push("");
183
- }
184
- currentFile = match.file;
185
- lines.push(match.file);
186
- }
187
- const before = match.beforeContext ?? [];
188
- const matchLine = match.lineNumber ?? 1;
189
- before.forEach((line, index) => {
190
- lines.push(` ${matchLine - before.length + index}-${line}`);
191
- });
192
- lines.push(` ${match.lineNumber ?? ""}:${match.line}`);
193
- (match.afterContext ?? []).forEach((line, index) => {
194
- lines.push(` ${matchLine + 1 + index}-${line}`);
195
- });
196
- }
197
- return lines.join("\n");
198
- }
199
- export function formatWriteOutput(path) {
200
- return `Wrote contents to ${path}`;
201
- }
202
- export function formatStrReplaceOutput(args) {
203
- if (!args.replaceAll) {
204
- return `The file ${args.path} has been updated.`;
205
- }
206
- const occurrenceLabel = args.occurrencesModified === 1 ? "occurrence" : "occurrences";
207
- const verb = args.occurrencesModified === 1 ? "has" : "have";
208
- return `${args.occurrencesModified} ${occurrenceLabel} in file ${args.path} ${verb} been updated.`;
209
- }
@@ -1,15 +0,0 @@
1
- /**
2
- * Parent-listing neighbors for a Read / LS miss. FileSystem has no
3
- * catalog API; `list(dirname(path))` is the sibling set. Immediate
4
- * children only — a recursive mount must not dump its whole subtree.
5
- */
6
- import { type FileSystem } from "../../filesystem.js";
7
- export declare function nearestListedNames(query: string, names: readonly string[], limit?: number): string[];
8
- export declare function formatMissNeighborHint(path: string, neighbors: readonly string[]): string | undefined;
9
- /**
10
- * One-line miss hint when the parent directory listed siblings.
11
- * `undefined` leaves the caller to throw the ordinary miss.
12
- * @deprecated Deprecated on the package root.
13
- */
14
- export declare function nearestNeighborMissHint(root: Pick<FileSystem, "list">, path: string): Promise<string | undefined>;
15
- //# sourceMappingURL=nearest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nearest.d.ts","sourceRoot":"","sources":["../../../src/internal/filesystem/nearest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,KAAK,UAAU,EAA2C,MAAM,qBAAqB,CAAC;AAK/F,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,KAAK,GAAE,MAAuB,GAC7B,MAAM,EAAE,CAeV;AAED,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,SAAS,MAAM,EAAE,GAC3B,MAAM,GAAG,SAAS,CAKpB;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,EAC9B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAc7B"}
@@ -1,90 +0,0 @@
1
- /**
2
- * Parent-listing neighbors for a Read / LS miss. FileSystem has no
3
- * catalog API; `list(dirname(path))` is the sibling set. Immediate
4
- * children only — a recursive mount must not dump its whole subtree.
5
- */
6
- import { posix } from "node:path";
7
- import { FILE_SYSTEM_SCAN_LIMIT, normalizeFsPath } from "../../filesystem.js";
8
- import { collectList } from "./walk.js";
9
- const NEIGHBOR_LIMIT = 5;
10
- export function nearestListedNames(query, names, limit = NEIGHBOR_LIMIT) {
11
- const queryKey = rankKey(query);
12
- return [...names]
13
- .sort((left, right) => {
14
- const leftKey = rankKey(left);
15
- const rightKey = rankKey(right);
16
- const leftPrefix = isPrefixRelated(queryKey, leftKey) ? 0 : 1;
17
- const rightPrefix = isPrefixRelated(queryKey, rightKey) ? 0 : 1;
18
- if (leftPrefix !== rightPrefix) {
19
- return leftPrefix - rightPrefix;
20
- }
21
- const distance = editDistance(queryKey, leftKey) - editDistance(queryKey, rightKey);
22
- return distance !== 0 ? distance : left.localeCompare(right);
23
- })
24
- .slice(0, limit);
25
- }
26
- export function formatMissNeighborHint(path, neighbors) {
27
- if (neighbors.length === 0) {
28
- return undefined;
29
- }
30
- return `not found: ${path}. nearest: ${neighbors.join(", ")}. do not retry.`;
31
- }
32
- /**
33
- * One-line miss hint when the parent directory listed siblings.
34
- * `undefined` leaves the caller to throw the ordinary miss.
35
- * @deprecated Deprecated on the package root.
36
- */
37
- export async function nearestNeighborMissHint(root, path) {
38
- const missed = normalizeFsPath(path);
39
- const parent = parentDir(missed);
40
- const files = await collectList(root, parent, {
41
- limit: FILE_SYSTEM_SCAN_LIMIT,
42
- });
43
- const names = [
44
- ...new Set(files
45
- .map((file) => relativeToParent(file.path, parent))
46
- .filter((name) => name.length > 0 && !name.includes("/"))),
47
- ].filter((name) => name !== posix.basename(missed));
48
- return formatMissNeighborHint(missed, nearestListedNames(posix.basename(missed), names));
49
- }
50
- function rankKey(name) {
51
- const base = posix.basename(name);
52
- const dot = base.lastIndexOf(".");
53
- return dot > 0 ? base.slice(0, dot) : base;
54
- }
55
- function isPrefixRelated(left, right) {
56
- return left.startsWith(right) || right.startsWith(left);
57
- }
58
- function editDistance(left, right) {
59
- const previous = Array.from({ length: right.length + 1 }, (_, index) => index);
60
- for (let i = 0; i < left.length; i += 1) {
61
- let diagonal = i;
62
- previous[0] = i + 1;
63
- for (let j = 0; j < right.length; j += 1) {
64
- const insertion = (previous[j + 1] ?? 0) + 1;
65
- const deletion = (previous[j] ?? 0) + 1;
66
- const substitution = diagonal + (left[i] === right[j] ? 0 : 1);
67
- diagonal = previous[j + 1] ?? 0;
68
- previous[j + 1] = Math.min(insertion, deletion, substitution);
69
- }
70
- }
71
- return previous[right.length] ?? right.length;
72
- }
73
- function parentDir(path) {
74
- const dir = posix.dirname(path);
75
- return dir === "." || dir === path ? "/" : dir;
76
- }
77
- function relativeToParent(filePath, parent) {
78
- const file = normalizeFsPath(filePath);
79
- const root = parent === "/" || parent === "" ? "/" : normalizeFsPath(parent);
80
- if (root === "/") {
81
- return file.startsWith("/") ? file.slice(1) : file;
82
- }
83
- if (file === root) {
84
- return posix.basename(file);
85
- }
86
- if (file.startsWith(`${root}/`)) {
87
- return file.slice(root.length + 1);
88
- }
89
- return posix.basename(file);
90
- }
@@ -1,60 +0,0 @@
1
- /**
2
- * Host `~/.cursor/projects/{slug(cwd)}/agent-tools/{uuid}.txt` → `/tmp/{uuid}.txt`.
3
- *
4
- * Native WebSearch / WebFetch and oversized MCP results still scratch
5
- * large output on the host, under the Cursor SDK's project dir for the
6
- * harness cwd. The session engine mounts `tempFs()` at `/tmp` with
7
- * `unionFs` and copies only those files onto that tree. This module is
8
- * the host-path translation, not a FileSystem type.
9
- */
10
- import type { FileSystem } from "../../filesystem.js";
11
- export declare const TMP_SCRATCH_PREFIX = "/tmp";
12
- export declare const HOST_AGENT_TOOLS_DIR = "agent-tools";
13
- export declare const WEB_SCRATCH_TOOLS: readonly ["webSearch", "webFetch"];
14
- export declare function isWebScratchTool(name: string | undefined): boolean;
15
- export declare function tmpScratchPath(fileName: string): string;
16
- export declare function hostAgentToolsDir(cwd: string): string;
17
- /**
18
- * Basename of `{hostAgentToolsDir(cwd)}/{uuid}.txt`, or undefined. Other
19
- * paths in a result are ignored.
20
- */
21
- export declare function hostAgentToolsFileName(args: {
22
- cwd: string;
23
- candidate: string;
24
- }): string | undefined;
25
- export declare function remapScratchPath(args: {
26
- cwd: string;
27
- path: string;
28
- }): string;
29
- export declare function remapScratchPaths(input: Record<string, unknown>, cwd: string): Record<string, unknown>;
30
- export declare function rewriteWebScratchText(args: {
31
- cwd: string;
32
- text: string;
33
- }): string;
34
- /** Rewrite host agent-tools paths in a string or a structured tool result. */
35
- export declare function rewriteWebScratchValue(args: {
36
- cwd: string;
37
- value: unknown;
38
- }): unknown;
39
- /**
40
- * WebSearch / WebFetch result. Ingest the host spill and rewrite
41
- * paths onto `/tmp`. Other tools are a no-op.
42
- */
43
- export declare function finishWebScratchTool(args: {
44
- toolName: string | undefined;
45
- result: unknown;
46
- cwd: string;
47
- root: FileSystem;
48
- }): Promise<unknown>;
49
- /** Finish a native web tool on the SDK update that carried its result. */
50
- export declare function applyWebScratchUpdate<T>(args: {
51
- cwd: string;
52
- root: FileSystem;
53
- update: T;
54
- }): Promise<T>;
55
- export declare function ingestHostAgentToolsScratch(args: {
56
- cwd: string;
57
- root: FileSystem;
58
- hostPath?: string;
59
- }): Promise<string[]>;
60
- //# sourceMappingURL=scratch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scratch.d.ts","sourceRoot":"","sources":["../../../src/internal/filesystem/scratch.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,eAAO,MAAM,kBAAkB,SAAS,CAAC;AACzC,eAAO,MAAM,oBAAoB,gBAAgB,CAAC;AAClD,eAAO,MAAM,iBAAiB,YAAI,WAAW,EAAE,UAAU,CAAU,CAAC;AAEpE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAElE;AASD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMrD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,MAAM,GAAG,SAAS,CAUrB;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAM5E;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,GAAG,EAAE,MAAM,GACV,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASzB;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAUjF;AAED,8EAA8E;AAC9E,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAgBrF;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;CAClB,GAAG,OAAO,CAAC,OAAO,CAAC,CAMnB;AAyBD,0EAA0E;AAC1E,wBAAsB,qBAAqB,CAAC,CAAC,EAAE,IAAI,EAAE;IACnD,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,CAAC,CAAC;CACX,GAAG,OAAO,CAAC,CAAC,CAAC,CAYb;AAED,wBAAsB,2BAA2B,CAAC,IAAI,EAAE;IACtD,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAepB"}
@@ -1,187 +0,0 @@
1
- /**
2
- * Host `~/.cursor/projects/{slug(cwd)}/agent-tools/{uuid}.txt` → `/tmp/{uuid}.txt`.
3
- *
4
- * Native WebSearch / WebFetch and oversized MCP results still scratch
5
- * large output on the host, under the Cursor SDK's project dir for the
6
- * harness cwd. The session engine mounts `tempFs()` at `/tmp` with
7
- * `unionFs` and copies only those files onto that tree. This module is
8
- * the host-path translation, not a FileSystem type.
9
- */
10
- import { readdir, readFile, rm } from "node:fs/promises";
11
- import { homedir } from "node:os";
12
- import path from "node:path";
13
- export const TMP_SCRATCH_PREFIX = "/tmp";
14
- export const HOST_AGENT_TOOLS_DIR = "agent-tools";
15
- export const WEB_SCRATCH_TOOLS = ["webSearch", "webFetch"];
16
- export function isWebScratchTool(name) {
17
- return name === "webSearch" || name === "webFetch";
18
- }
19
- const UUID_TXT = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.txt$/i;
20
- const HOST_FOLLOW_UP = /Use shell \/ grep \/ read_file on this path to inspect the page/g;
21
- const OVERLAY_FOLLOW_UP = "Use Read / Grep on this path to inspect the page";
22
- const PATH_KEYS = ["path", "dir", "targetDirectory", "target_directory"];
23
- export function tmpScratchPath(fileName) {
24
- return `${TMP_SCRATCH_PREFIX}/${fileName}`;
25
- }
26
- export function hostAgentToolsDir(cwd) {
27
- const slug = cwd
28
- .replace(/[^a-zA-Z0-9]/g, "-")
29
- .replace(/-+/g, "-")
30
- .replace(/^-+|-+$/g, "");
31
- return path.join(homedir(), ".cursor", "projects", slug, HOST_AGENT_TOOLS_DIR);
32
- }
33
- /**
34
- * Basename of `{hostAgentToolsDir(cwd)}/{uuid}.txt`, or undefined. Other
35
- * paths in a result are ignored.
36
- */
37
- export function hostAgentToolsFileName(args) {
38
- if (args.candidate === "") {
39
- return undefined;
40
- }
41
- const resolved = path.resolve(args.candidate);
42
- if (path.dirname(resolved) !== hostAgentToolsDir(args.cwd)) {
43
- return undefined;
44
- }
45
- const base = path.basename(resolved);
46
- return UUID_TXT.test(base) ? base : undefined;
47
- }
48
- export function remapScratchPath(args) {
49
- const fileName = hostAgentToolsFileName({
50
- cwd: args.cwd,
51
- candidate: args.path,
52
- });
53
- return fileName === undefined ? args.path : tmpScratchPath(fileName);
54
- }
55
- export function remapScratchPaths(input, cwd) {
56
- const next = { ...input };
57
- for (const key of PATH_KEYS) {
58
- const value = next[key];
59
- if (typeof value === "string") {
60
- next[key] = remapScratchPath({ cwd, path: value });
61
- }
62
- }
63
- return next;
64
- }
65
- export function rewriteWebScratchText(args) {
66
- const dir = hostAgentToolsDir(args.cwd);
67
- const escaped = dir.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
68
- const pattern = new RegExp(`${escaped}[/\\\\]([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\.txt)`, "gi");
69
- return args.text
70
- .replace(pattern, (_match, fileName) => tmpScratchPath(fileName))
71
- .replace(HOST_FOLLOW_UP, OVERLAY_FOLLOW_UP);
72
- }
73
- /** Rewrite host agent-tools paths in a string or a structured tool result. */
74
- export function rewriteWebScratchValue(args) {
75
- const { cwd, value } = args;
76
- if (typeof value === "string") {
77
- return rewriteWebScratchText({ cwd, text: value });
78
- }
79
- if (Array.isArray(value)) {
80
- return value.map((item) => rewriteWebScratchValue({ cwd, value: item }));
81
- }
82
- if (value !== null && typeof value === "object") {
83
- const next = {};
84
- for (const [key, item] of Object.entries(value)) {
85
- next[key] = rewriteWebScratchValue({ cwd, value: item });
86
- }
87
- return next;
88
- }
89
- return value;
90
- }
91
- /**
92
- * WebSearch / WebFetch result. Ingest the host spill and rewrite
93
- * paths onto `/tmp`. Other tools are a no-op.
94
- */
95
- export async function finishWebScratchTool(args) {
96
- if (!isWebScratchTool(args.toolName)) {
97
- return args.result;
98
- }
99
- await ingestHostAgentToolsScratch({ cwd: args.cwd, root: args.root });
100
- return rewriteWebScratchValue({ cwd: args.cwd, value: args.result });
101
- }
102
- function completedWebToolCall(update) {
103
- if (update === null || typeof update !== "object") {
104
- return undefined;
105
- }
106
- const rec = update;
107
- const call = rec.type === "tool-call-completed"
108
- ? rec.toolCall
109
- : rec.type === "tool-call-delta" && rec.taskUpdate?.type === "tool-call-completed"
110
- ? rec.taskUpdate.toolCall
111
- : undefined;
112
- if (call === undefined || !isWebScratchTool(call.type)) {
113
- return undefined;
114
- }
115
- return call;
116
- }
117
- /** Finish a native web tool on the SDK update that carried its result. */
118
- export async function applyWebScratchUpdate(args) {
119
- const call = completedWebToolCall(args.update);
120
- if (call === undefined) {
121
- return args.update;
122
- }
123
- call.result = await finishWebScratchTool({
124
- toolName: call.type,
125
- result: call.result,
126
- cwd: args.cwd,
127
- root: args.root,
128
- });
129
- return args.update;
130
- }
131
- export async function ingestHostAgentToolsScratch(args) {
132
- const written = [];
133
- const names = args.hostPath === undefined ? await listHostAgentToolsFiles(args.cwd) : [args.hostPath];
134
- for (const hostPath of names) {
135
- const dest = await copyHostAgentToolsFile({
136
- cwd: args.cwd,
137
- root: args.root,
138
- hostPath,
139
- });
140
- if (dest !== undefined) {
141
- written.push(dest);
142
- }
143
- }
144
- return written;
145
- }
146
- async function listHostAgentToolsFiles(cwd) {
147
- const dir = hostAgentToolsDir(cwd);
148
- try {
149
- const entries = await readdir(dir, { withFileTypes: true });
150
- return entries
151
- .filter((entry) => entry.isFile() && UUID_TXT.test(entry.name))
152
- .map((entry) => path.join(dir, entry.name));
153
- }
154
- catch (error) {
155
- if (isEnoent(error)) {
156
- return [];
157
- }
158
- throw error;
159
- }
160
- }
161
- async function copyHostAgentToolsFile(args) {
162
- const fileName = hostAgentToolsFileName({
163
- cwd: args.cwd,
164
- candidate: args.hostPath,
165
- });
166
- if (fileName === undefined) {
167
- return undefined;
168
- }
169
- const dest = tmpScratchPath(fileName);
170
- const hostPath = path.resolve(args.hostPath);
171
- let bytes;
172
- try {
173
- bytes = await readFile(hostPath);
174
- }
175
- catch (error) {
176
- if (isEnoent(error)) {
177
- return undefined;
178
- }
179
- throw error;
180
- }
181
- await args.root.write(dest, bytes.toString("utf8"));
182
- await rm(hostPath, { force: true });
183
- return dest;
184
- }
185
- function isEnoent(error) {
186
- return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
187
- }