@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
@@ -12,8 +12,9 @@
12
12
  * the channel kind and declared events (`github.pr/v2`, `github.issue/v2`,
13
13
  * `github.none/v2`, `slack.thread/v2`, `origin.pr/v2`,
14
14
  * `deployments.deployment/v2`, `change_monitors.checkpoint/v2`,
15
- * `issues.issue/v2`, …) onto every channel that omitted a
16
- * selector. An explicit per-channel selector still overrides. JSONPath
15
+ * `issues.issue/v2`, `runs.run/v2`, `match_ready.monitor/v2`, …) onto
16
+ * every channel that omitted a selector. An explicit per-channel selector
17
+ * still overrides. JSONPath
17
18
  * and per-agent format strings are rejected.
18
19
  */
19
20
  import { randomBytes } from "node:crypto";
@@ -43,6 +44,7 @@ export const CONTINUATION_SELECTORS = [
43
44
  "change_monitors.checkpoint/v2",
44
45
  "issues.issue/v2",
45
46
  "runs.run/v2",
47
+ "match_ready.monitor/v2",
46
48
  "pagerduty.incident/v2",
47
49
  "pagerduty.none/v2",
48
50
  "none/v1",
@@ -237,6 +239,11 @@ const SELECTOR_FIELDS = {
237
239
  type: "run",
238
240
  kind: "runs",
239
241
  },
242
+ "match_ready.monitor/v2": {
243
+ version: 2,
244
+ type: "match-ready",
245
+ kind: "match_ready",
246
+ },
240
247
  "pagerduty.incident/v2": {
241
248
  version: 2,
242
249
  type: "pagerduty-incident",
@@ -283,6 +290,8 @@ export function defaultContinuationSelector(kind, version = "v1", eventTypes) {
283
290
  return membershipOrNone(eventTypes, "factory-issue", "issues.issue/v2", "none/v2");
284
291
  case "runs":
285
292
  return membershipOrNone(eventTypes, "run", "runs.run/v2", "none/v2");
293
+ case "match_ready":
294
+ return membershipOrNone(eventTypes, "match-ready", "match_ready.monitor/v2", "none/v2");
286
295
  case "pagerduty":
287
296
  return membershipOrNone(eventTypes, "pagerduty-incident", "pagerduty.incident/v2", "pagerduty.none/v2");
288
297
  default:
@@ -316,6 +325,7 @@ const OMITTED_V2_TYPED_TYPE = {
316
325
  change_monitors: "change-monitor-checkpoint",
317
326
  issues: "factory-issue",
318
327
  runs: "run",
328
+ match_ready: "match-ready",
319
329
  pagerduty: "pagerduty-incident",
320
330
  };
321
331
  function isOmittedV2Kind(kind) {
@@ -400,6 +410,7 @@ function isRegisteredKind(kind) {
400
410
  case "change_monitors":
401
411
  case "issues":
402
412
  case "runs":
413
+ case "match_ready":
403
414
  case "pagerduty":
404
415
  return true;
405
416
  default:
@@ -441,6 +452,8 @@ function formatConversationKey(type, fields) {
441
452
  return `issues:${fields.issueName}`;
442
453
  case "run":
443
454
  return `runs:${fields.monitorId}:${fields.runId}`;
455
+ case "match-ready":
456
+ return `match_ready:${fields.changeMonitorName}`;
444
457
  case "pagerduty-incident":
445
458
  return `pagerduty:incident:${fields.incidentId}`;
446
459
  default: {
@@ -636,6 +649,8 @@ export function extractContinuation(type, eventName, payload) {
636
649
  return extractNamedResource("factory-issue", "issueName", payload, "issue");
637
650
  case "run":
638
651
  return extractRun(payload);
652
+ case "match-ready":
653
+ return extractNamedResource("match-ready", "changeMonitorName", payload, "changeMonitor");
639
654
  case "pagerduty-incident":
640
655
  return extractPagerDuty(payload);
641
656
  default: {
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Native file tools for direct tool calls (`POST /v1/tools/:toolName`).
3
+ * The tools themselves are the SDK's `createFileSystemTools`; this module
4
+ * only maps the names a caller may use onto them and applies the agent's
5
+ * `tools` allowlist the way a turn does.
6
+ */
7
+ import type { FileSystemTools, ToolName } from "@cursor/sdk";
8
+ export type DirectFileToolName = keyof FileSystemTools;
9
+ /**
10
+ * The file tool a direct call runs. `edit` with `fileText` or `contents`
11
+ * is Write; any other `edit` is StrReplace.
12
+ */
13
+ export declare function directFileToolName(name: string, input: unknown): DirectFileToolName | undefined;
14
+ /** Omitted `tools` allows every file tool, as it does in a turn. */
15
+ export declare function directFileToolAllowed(name: DirectFileToolName, tools: readonly ToolName[] | undefined): boolean;
16
+ /**
17
+ * Where the SDK spills large WebFetch and WebSearch output for a host
18
+ * cwd. Direct Read calls on a host-disk agent may read it.
19
+ */
20
+ export declare function hostAgentToolsDir(cwd: string): string;
21
+ //# sourceMappingURL=direct-file-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"direct-file-tools.d.ts","sourceRoot":"","sources":["../../src/internal/direct-file-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG7D,MAAM,MAAM,kBAAkB,GAAG,MAAM,eAAe,CAAC;AA6BvD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,kBAAkB,GAAG,SAAS,CAM/F;AAED,oEAAoE;AACpE,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,kBAAkB,EACxB,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,SAAS,GACrC,OAAO,CAET;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMrD"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Native file tools for direct tool calls (`POST /v1/tools/:toolName`).
3
+ * The tools themselves are the SDK's `createFileSystemTools`; this module
4
+ * only maps the names a caller may use onto them and applies the agent's
5
+ * `tools` allowlist the way a turn does.
6
+ */
7
+ import { homedir } from "node:os";
8
+ import path from "node:path";
9
+ import { isRecord } from "./is-record.js";
10
+ const DIRECT_FILE_TOOL_NAMES = {
11
+ read: "Read",
12
+ Read: "Read",
13
+ ls: "LS",
14
+ LS: "LS",
15
+ glob: "Glob",
16
+ Glob: "Glob",
17
+ grep: "Grep",
18
+ Grep: "Grep",
19
+ write: "Write",
20
+ Write: "Write",
21
+ StrReplace: "StrReplace",
22
+ delete: "Delete",
23
+ Delete: "Delete",
24
+ };
25
+ /** The `tools` names that grant each file tool in a turn. */
26
+ const ALLOWLIST_GRANTS = {
27
+ Read: "read",
28
+ LS: "ls",
29
+ Glob: "glob",
30
+ Grep: "grep",
31
+ Write: "edit",
32
+ StrReplace: "edit",
33
+ Delete: "delete",
34
+ };
35
+ /**
36
+ * The file tool a direct call runs. `edit` with `fileText` or `contents`
37
+ * is Write; any other `edit` is StrReplace.
38
+ */
39
+ export function directFileToolName(name, input) {
40
+ if (name === "edit") {
41
+ const args = isRecord(input) ? input : {};
42
+ return "fileText" in args || "contents" in args ? "Write" : "StrReplace";
43
+ }
44
+ return DIRECT_FILE_TOOL_NAMES[name];
45
+ }
46
+ /** Omitted `tools` allows every file tool, as it does in a turn. */
47
+ export function directFileToolAllowed(name, tools) {
48
+ return tools === undefined || tools.includes(ALLOWLIST_GRANTS[name]);
49
+ }
50
+ /**
51
+ * Where the SDK spills large WebFetch and WebSearch output for a host
52
+ * cwd. Direct Read calls on a host-disk agent may read it.
53
+ */
54
+ export function hostAgentToolsDir(cwd) {
55
+ const slug = cwd
56
+ .replace(/[^a-zA-Z0-9]/g, "-")
57
+ .replace(/-+/g, "-")
58
+ .replace(/^-+|-+$/g, "");
59
+ return path.join(homedir(), ".cursor", "projects", slug, "agent-tools");
60
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../src/internal/discovery/agent.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH,OAAO,EAQL,KAAK,aAAa,EACnB,MAAM,gBAAgB,CAAC;AAgBxB,OAAO,EAAE,KAAK,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AAgB,CAAC,GAAG,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0C7F"}
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * Compile one `agent/` directory (and its subagents) into a {@link ResolvedAgent}.
3
3
  */
4
- import { join } from "node:path";
5
- import { assertNoRemovedFileSearchTools, canonicalizeFileSystemToolName, FileSystemConfigError, isRemovedFileSearchTool, resolveFileSystemTools, resolveRootHarnessAllowlist, } from "../../filesystem.js";
4
+ import { join, posix } from "node:path";
5
+ import { assertNoRemovedFileSearchTools, isRemovedFileSearchTool } from "../../filesystem.js";
6
6
  import { DEFAULT_MODEL, } from "../../types.js";
7
- import { synthesizedFileSystemToolNames } from "../filesystem/tools.js";
8
7
  import { FS_AND_ROOT_CONFLICT, withIdentityPreamble } from "../workspace.js";
8
+ import { confinesWorkspaceReads, treeToolAllowlist } from "../workspace-tree.js";
9
9
  import { isValidModelSetting, loadAgentConfig, resolveAgentCwd, resolveArchitecture, resolveConcurrency, resolveFallbackAfterStream, resolveHosting, resolveLocalCwd, rejectPersistentOption, resolveModelFallbacks, } from "./agent-config.js";
10
10
  import { loadConnections, loadHostConnections } from "./connections.js";
11
11
  import { displayPath, pushConfigDiagnostic } from "./context.js";
@@ -85,15 +85,12 @@ export async function loadAgent(ctx, agentDir, options) {
85
85
  const authoredAllowlist = config?.tools;
86
86
  const authored = authoredFileSystem(ctx, agentDir, config);
87
87
  const root = authored?.fs;
88
- const hasRoot = authored !== undefined;
89
88
  if (authored !== undefined) {
90
- if (config?.local?.cwd !== undefined ||
91
- config?.local?.workspaceDir !== undefined ||
92
- config?.local?.sandbox === true) {
89
+ if (config?.local?.cwd !== undefined || config?.local?.workspaceDir !== undefined) {
93
90
  pushConfigDiagnostic(ctx, {
94
91
  severity: "error",
95
92
  path: displayPath(ctx, join(agentDir, "agent.ts")),
96
- message: `\`${authored.field}\` cannot be combined with \`local.cwd\`, \`local.workspaceDir\`, or \`local.sandbox\`. Those fields configure the host tree the override replaced.`,
93
+ message: `\`${authored.field}\` cannot be combined with \`local.cwd\` or \`local.workspaceDir\`. Those fields configure the host tree the override replaced.`,
97
94
  });
98
95
  }
99
96
  if (runtime === "cloud") {
@@ -112,70 +109,58 @@ export async function loadAgent(ctx, agentDir, options) {
112
109
  });
113
110
  }
114
111
  }
115
- const reservedNames = new Set(synthesizedFileSystemToolNames({
116
- hasRoot,
117
- tools: authoredAllowlist,
118
- }));
119
- const clash = tools.find((tool) => {
120
- if (isRemovedFileSearchTool(tool.name) || reservedNames.has(tool.name)) {
121
- return true;
122
- }
123
- const canonical = canonicalizeFileSystemToolName(tool.name);
124
- return canonical !== undefined && reservedNames.has(canonical);
125
- });
126
- if (clash !== undefined) {
112
+ const removedSearchTool = tools.find((tool) => isRemovedFileSearchTool(tool.name));
113
+ if (removedSearchTool !== undefined) {
127
114
  ctx.diagnostics.push({
128
115
  severity: "error",
129
- path: displayPath(ctx, join(agentDir, "tools", `${clash.name}.ts`)),
130
- message: isRemovedFileSearchTool(clash.name)
131
- ? `Semantic search has been removed. Use Grep. Tool name "${clash.name}" is not available.`
132
- : `Tool name "${clash.name}" is reserved for the synthesized FileSystem tool.`,
116
+ path: displayPath(ctx, join(agentDir, "tools", `${removedSearchTool.name}.ts`)),
117
+ message: `Semantic search has been removed. Use Grep. Tool name "${removedSearchTool.name}" is not available.`,
133
118
  });
134
119
  }
135
- if (root === undefined) {
136
- try {
137
- assertNoRemovedFileSearchTools(authoredAllowlist);
138
- }
139
- catch (error) {
140
- pushConfigDiagnostic(ctx, {
141
- severity: "error",
142
- path: displayPath(ctx, join(agentDir, "agent.ts")),
143
- message: error instanceof FileSystemConfigError
144
- ? error.message
145
- : error instanceof Error
146
- ? error.message
147
- : String(error),
148
- });
149
- }
120
+ // A sandboxed host agent with file tools and no shell runs on its session
121
+ // workspace as a tree, so its reads stay in the workspace.
122
+ const workspaceConfined = root === undefined &&
123
+ runtime === "local" &&
124
+ confinesWorkspaceReads({ local: config?.local, tools: authoredAllowlist });
125
+ try {
126
+ assertNoRemovedFileSearchTools(authoredAllowlist);
150
127
  }
151
- let allowedTools = authoredAllowlist === undefined || authoredAllowlist.includes("mcp")
152
- ? authoredAllowlist
153
- : [...authoredAllowlist, "mcp"];
154
- if (root !== undefined) {
155
- try {
156
- if (typeof root !== "function") {
157
- resolveFileSystemTools({
158
- root,
159
- tools: authoredAllowlist,
160
- });
161
- }
162
- else {
163
- resolveRootHarnessAllowlist(authoredAllowlist);
164
- }
165
- allowedTools = authoredAllowlist;
166
- }
167
- catch (error) {
168
- pushConfigDiagnostic(ctx, {
169
- severity: "error",
170
- path: displayPath(ctx, join(agentDir, "agent.ts")),
171
- message: error instanceof FileSystemConfigError
172
- ? error.message
173
- : error instanceof Error
174
- ? error.message
175
- : String(error),
176
- });
177
- }
128
+ catch (error) {
129
+ pushConfigDiagnostic(ctx, {
130
+ severity: "error",
131
+ path: displayPath(ctx, join(agentDir, "agent.ts")),
132
+ message: error instanceof Error ? error.message : String(error),
133
+ });
178
134
  }
135
+ const workspaceProblem = checkWorkspace(config?.workspace);
136
+ if (workspaceProblem !== undefined) {
137
+ pushConfigDiagnostic(ctx, {
138
+ severity: "error",
139
+ path: displayPath(ctx, join(agentDir, "agent.ts")),
140
+ message: workspaceProblem,
141
+ });
142
+ }
143
+ if (root === undefined && !workspaceConfined && config?.workspace !== undefined) {
144
+ pushConfigDiagnostic(ctx, {
145
+ severity: "error",
146
+ path: displayPath(ctx, join(agentDir, "agent.ts")),
147
+ message: "`workspace` places the workspace inside a tree: the one `fs` sets, or the session workspace of a sandboxed agent whose `tools` list file tools and no shell. Set `fs`, or remove it.",
148
+ });
149
+ }
150
+ const treeTools = authoredAllowlist !== undefined && (root !== undefined || workspaceConfined)
151
+ ? treeToolAllowlist(authoredAllowlist)
152
+ : undefined;
153
+ if (treeTools !== undefined && treeTools.dropped.length > 0) {
154
+ pushConfigDiagnostic(ctx, {
155
+ severity: "warning",
156
+ path: displayPath(ctx, join(agentDir, "agent.ts")),
157
+ message: `\`tools\` lists ${treeTools.dropped.join(", ")}, which an agent on a tree cannot run. Agent SDK leaves ${treeTools.dropped.length === 1 ? "it" : "them"} out.`,
158
+ });
159
+ }
160
+ const listedTools = treeTools?.tools ?? authoredAllowlist;
161
+ const allowedTools = listedTools === undefined || listedTools.includes("mcp")
162
+ ? listedTools
163
+ : [...listedTools, "mcp"];
179
164
  // The allowlist states runtime-agnostic intent, but only the local
180
165
  // harness can enforce it (the Cursor SDK rejects tool restrictions on
181
166
  // cloud agents, and the Grok Bot harness has its own fixed toolset) — a
@@ -254,6 +239,7 @@ export async function loadAgent(ctx, agentDir, options) {
254
239
  runtime,
255
240
  fs: root,
256
241
  root: authored?.field === "root" ? root : undefined,
242
+ workspace: config?.workspace === undefined ? undefined : normalizeWorkspace(config.workspace),
257
243
  skillsMount: config?.skills,
258
244
  cloud,
259
245
  local,
@@ -278,6 +264,25 @@ export async function loadAgent(ctx, agentDir, options) {
278
264
  },
279
265
  };
280
266
  }
267
+ /** `workspace` as the SDK's tree paths spell it: normalized, no trailing slash. */
268
+ function normalizeWorkspace(workspace) {
269
+ const normalized = posix.normalize(workspace);
270
+ return normalized.length > 1 && normalized.endsWith("/") ? normalized.slice(0, -1) : normalized;
271
+ }
272
+ /** Why `workspace` cannot be the workspace inside the tree, if it cannot. */
273
+ function checkWorkspace(workspace) {
274
+ if (workspace === undefined) {
275
+ return undefined;
276
+ }
277
+ if (!workspace.startsWith("/") || workspace.includes("\\")) {
278
+ return `\`workspace\` must be an absolute posix path inside \`fs\`, got ${JSON.stringify(workspace)}.`;
279
+ }
280
+ const normalized = posix.normalize(workspace);
281
+ if (normalized === "/tmp" || normalized.startsWith("/tmp/")) {
282
+ return "`workspace` cannot be under `/tmp`: the SDK mounts a fresh `/tmp` over the tree for each turn.";
283
+ }
284
+ return undefined;
285
+ }
281
286
  function authoredFileSystem(ctx, agentDir, config) {
282
287
  if (config?.fs !== undefined && config.root !== undefined) {
283
288
  pushConfigDiagnostic(ctx, {
@@ -1,27 +1,9 @@
1
1
  /**
2
- * Recursive listing, existence probes, and native LS trees. Matches the
3
- * change-monitor VFS contract on origin/main: `list` is files-only and
4
- * recursive; `stat` tells file / directory / missing apart.
2
+ * Flat-index listing helpers for trees that hold a list of file paths
3
+ * (`hostFs`). `list` is files-only and recursive; `stat` tells file /
4
+ * directory / missing apart.
5
5
  */
6
- import { type DirEntry, type FileInfo, type FileSystem, type ListOptions } from "../../filesystem.js";
7
- /**
8
- * Native LS `directoryTreeRoot` (LocalLsExecutor ingest tree).
9
- * Synthesis builds this from `list` + `stat` via `buildLsTree`.
10
- * Not a FileSystem method result and not part of the public
11
- * Agent SDK surface.
12
- */
13
- export interface LsDirectoryTreeNode {
14
- absPath: string;
15
- childrenDirs: LsDirectoryTreeNode[];
16
- childrenFiles: Array<{
17
- name: string;
18
- }>;
19
- childrenWereProcessed: boolean;
20
- fullSubtreeExtensionCounts: Record<string, number>;
21
- numFiles: number;
22
- }
23
- /** Filename-character ingest budget; matches LocalLsExecutor. */
24
- export declare const LS_INGEST_CHARACTER_BUDGET = 2500;
6
+ import { type DirEntry, type FileInfo, type ListOptions } from "../../filesystem.js";
25
7
  /**
26
8
  * Yield the files under `prefix`, sorted. A file whose path equals
27
9
  * `prefix` is not under itself.
@@ -33,25 +15,6 @@ export declare function normalizeListPrefix(prefix?: string): string;
33
15
  * key with this prefix → directory; `""` / `/` → directory; else missing.
34
16
  */
35
17
  export declare function statFromFilePaths(files: Iterable<string>, path: string): FileInfo;
36
- export declare function collectList(root: Pick<FileSystem, "list">, prefix?: string, options?: ListOptions): Promise<DirEntry[]>;
37
- export declare function collectGlob(root: Pick<FileSystem, "glob">, options: {
38
- pattern: string;
39
- dir?: string;
40
- limit?: number;
41
- }): Promise<DirEntry[]>;
42
- /**
43
- * List, then `stat` only when nothing came back. A non-empty listing is
44
- * already a directory (a file is not under itself).
45
- */
46
- export declare function collectListOrStat(root: Pick<FileSystem, "list" | "stat">, path?: string, options?: ListOptions): Promise<{
47
- kind: FileInfo["kind"];
48
- files: DirEntry[];
49
- }>;
50
- /**
51
- * Build the native LS tree from a recursive file listing. Applies the
52
- * LocalLsExecutor ingest budget so a huge directory truncates the same way.
53
- */
54
- export declare function buildLsTree(dir: string, files: readonly DirEntry[]): LsDirectoryTreeNode;
55
18
  /**
56
19
  * Native LS ignore_globs: a pattern that is not already recursive is
57
20
  * matched at any depth (the same `** /` prefix the Cursor SDK native uses).
@@ -59,15 +22,4 @@ export declare function buildLsTree(dir: string, files: readonly DirEntry[]): Ls
59
22
  export declare function applyIgnores(entries: readonly DirEntry[], ignoreGlobs?: readonly string[]): DirEntry[];
60
23
  /** True when `path` matches any {@link ListOptions.excludes} glob. */
61
24
  export declare function isExcludedPath(path: string, excludes?: readonly string[]): boolean;
62
- export declare function lsFromList(root: Pick<FileSystem, "list" | "stat">, path?: string, ignoreGlobs?: readonly string[]): Promise<{
63
- status: "success";
64
- value: {
65
- directoryTreeRoot: LsDirectoryTreeNode;
66
- };
67
- } | {
68
- status: "error";
69
- error: {
70
- message: string;
71
- };
72
- }>;
73
25
  //# sourceMappingURL=walk.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../../../src/internal/filesystem/walk.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,UAAU,EAEf,KAAK,WAAW,EAGjB,MAAM,qBAAqB,CAAC;AAE7B;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,mBAAmB,EAAE,CAAC;IACpC,aAAa,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnD,QAAQ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IAAI,EAAE,MAAM,GAAG,QAAQ,CAgBjF;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,SAAS,QAAQ,EAAE,EAC5B,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,GAC9B,QAAQ,EAAE,CAOZ;AAkBD,sEAAsE;AACtE,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAKlF"}
@@ -1,13 +1,10 @@
1
1
  /**
2
- * Recursive listing, existence probes, and native LS trees. Matches the
3
- * change-monitor VFS contract on origin/main: `list` is files-only and
4
- * recursive; `stat` tells file / directory / missing apart.
2
+ * Flat-index listing helpers for trees that hold a list of file paths
3
+ * (`hostFs`). `list` is files-only and recursive; `stat` tells file /
4
+ * directory / missing apart.
5
5
  */
6
- import { posix } from "node:path";
7
6
  import { minimatch } from "minimatch";
8
- import { FILE_SYSTEM_SCAN_LIMIT, normalizeFsPath, } from "../../filesystem.js";
9
- /** Filename-character ingest budget; matches LocalLsExecutor. */
10
- export const LS_INGEST_CHARACTER_BUDGET = 2_500;
7
+ import { normalizeFsPath, } from "../../filesystem.js";
11
8
  function takeLimit(entries, limit) {
12
9
  if (limit === undefined || !Number.isFinite(limit)) {
13
10
  return [...entries];
@@ -64,135 +61,6 @@ export function statFromFilePaths(files, path) {
64
61
  }
65
62
  return { kind: "missing" };
66
63
  }
67
- export async function collectList(root, prefix, options) {
68
- const entries = [];
69
- if (root.list === undefined) {
70
- return entries;
71
- }
72
- for await (const entry of root.list(prefix, options)) {
73
- entries.push(entry);
74
- }
75
- return entries;
76
- }
77
- export async function collectGlob(root, options) {
78
- const entries = [];
79
- if (root.glob === undefined) {
80
- return entries;
81
- }
82
- const globOptions = options.limit === undefined ? undefined : { limit: options.limit };
83
- for await (const entry of root.glob(options.pattern, options.dir, globOptions)) {
84
- entries.push(entry);
85
- }
86
- return entries;
87
- }
88
- /**
89
- * List, then `stat` only when nothing came back. A non-empty listing is
90
- * already a directory (a file is not under itself).
91
- */
92
- export async function collectListOrStat(root, path, options) {
93
- const files = await collectList(root, path, options);
94
- if (files.length > 0) {
95
- return { kind: "directory", files };
96
- }
97
- if (root.stat === undefined) {
98
- return { kind: "missing", files };
99
- }
100
- const probe = path === undefined || path === "" ? "." : path;
101
- return { kind: (await root.stat(probe)).kind, files };
102
- }
103
- function emptyLsNode(absPath) {
104
- return {
105
- absPath,
106
- childrenDirs: [],
107
- childrenFiles: [],
108
- childrenWereProcessed: true,
109
- fullSubtreeExtensionCounts: {},
110
- numFiles: 0,
111
- };
112
- }
113
- /**
114
- * Build the native LS tree from a recursive file listing. Applies the
115
- * LocalLsExecutor ingest budget so a huge directory truncates the same way.
116
- */
117
- export function buildLsTree(dir, files) {
118
- const rootPath = normalizeListPrefix(dir);
119
- const root = emptyLsNode(rootPath);
120
- const dirNodes = new Map([[rootPath, root]]);
121
- const state = {
122
- charactersUsed: rootPath.length,
123
- budgetExceeded: false,
124
- };
125
- for (const file of files) {
126
- addPathToTree(file.path, rootPath, dirNodes, state, LS_INGEST_CHARACTER_BUDGET);
127
- }
128
- return root;
129
- }
130
- function addPathToTree(filePath, rootPath, dirNodes, state, characterBudget) {
131
- const fileName = posix.basename(filePath);
132
- const dirPath = posixParent(filePath);
133
- ensureDirectoryPath(dirPath, rootPath, dirNodes, state.budgetExceeded);
134
- const parentNode = dirNodes.get(dirPath);
135
- if (parentNode === undefined) {
136
- return;
137
- }
138
- const fileCharCost = fileName.length;
139
- if (!state.budgetExceeded && state.charactersUsed + fileCharCost <= characterBudget) {
140
- parentNode.childrenFiles.push({ name: fileName });
141
- state.charactersUsed += fileCharCost;
142
- return;
143
- }
144
- if (!state.budgetExceeded) {
145
- state.budgetExceeded = true;
146
- let currentDir = dirPath;
147
- while (currentDir.startsWith(rootPath)) {
148
- const node = dirNodes.get(currentDir);
149
- if (node !== undefined) {
150
- node.childrenWereProcessed = false;
151
- }
152
- const parentDir = posixParent(currentDir);
153
- if (parentDir === currentDir) {
154
- break;
155
- }
156
- currentDir = parentDir;
157
- }
158
- }
159
- const extension = posix.extname(filePath);
160
- let currentDir = dirPath;
161
- while (currentDir.startsWith(rootPath)) {
162
- const node = dirNodes.get(currentDir);
163
- if (node !== undefined) {
164
- node.fullSubtreeExtensionCounts[extension] =
165
- (node.fullSubtreeExtensionCounts[extension] ?? 0) + 1;
166
- node.numFiles += 1;
167
- }
168
- const parentDir = posixParent(currentDir);
169
- if (parentDir === currentDir) {
170
- break;
171
- }
172
- currentDir = parentDir;
173
- }
174
- }
175
- function ensureDirectoryPath(dirPath, rootPath, dirNodes, budgetExceeded) {
176
- if (dirNodes.has(dirPath) || dirPath === rootPath) {
177
- return;
178
- }
179
- const parentPath = posixParent(dirPath);
180
- if (parentPath !== dirPath && pathIsUnderRoot(parentPath, rootPath)) {
181
- ensureDirectoryPath(parentPath, rootPath, dirNodes, budgetExceeded);
182
- }
183
- const dirNode = {
184
- ...emptyLsNode(dirPath),
185
- childrenWereProcessed: !budgetExceeded,
186
- };
187
- dirNodes.set(dirPath, dirNode);
188
- const parentNode = dirNodes.get(parentPath);
189
- if (parentNode !== undefined) {
190
- parentNode.childrenDirs.push(dirNode);
191
- }
192
- }
193
- function pathIsUnderRoot(path, rootPath) {
194
- return path === rootPath || path.startsWith(rootPath === "/" ? "/" : `${rootPath}/`);
195
- }
196
64
  /**
197
65
  * Native LS ignore_globs: a pattern that is not already recursive is
198
66
  * matched at any depth (the same `** /` prefix the Cursor SDK native uses).
@@ -223,57 +91,3 @@ export function isExcludedPath(path, excludes) {
223
91
  }
224
92
  return excludes.some((glob) => matchesIgnoreGlob(path, glob));
225
93
  }
226
- export async function lsFromList(root, path, ignoreGlobs) {
227
- const listed = await collectListOrStat(root, path, {
228
- limit: FILE_SYSTEM_SCAN_LIMIT,
229
- ...(ignoreGlobs === undefined || ignoreGlobs.length === 0 ? {} : { excludes: ignoreGlobs }),
230
- });
231
- const treePath = path ?? inferListedRoot(listed.files);
232
- switch (listed.kind) {
233
- case "missing":
234
- return {
235
- status: "error",
236
- error: { message: `Path does not exist: ${treePath}` },
237
- };
238
- case "file":
239
- return {
240
- status: "error",
241
- error: { message: `Path is not a directory: ${treePath}` },
242
- };
243
- case "directory":
244
- return {
245
- status: "success",
246
- value: {
247
- directoryTreeRoot: buildLsTree(treePath, applyIgnores(listed.files, ignoreGlobs)),
248
- },
249
- };
250
- default: {
251
- const unexpected = listed.kind;
252
- return unexpected;
253
- }
254
- }
255
- }
256
- function inferListedRoot(files) {
257
- if (files.length === 0) {
258
- return "/";
259
- }
260
- let prefix = posixParent(files[0].path);
261
- for (const file of files) {
262
- while (prefix !== "/" && file.path !== prefix && !file.path.startsWith(`${prefix}/`)) {
263
- const parent = posixParent(prefix);
264
- if (parent === prefix) {
265
- return "/";
266
- }
267
- prefix = parent;
268
- }
269
- }
270
- return prefix;
271
- }
272
- /**
273
- * `path.posix.dirname` returns `.` for slash-free paths. Treat that as
274
- * the virtual root so LS walks terminate and relative files attach to `/`.
275
- */
276
- function posixParent(path) {
277
- const dir = posix.dirname(path);
278
- return dir === "." || dir === path ? "/" : dir;
279
- }
@@ -4,6 +4,9 @@ export declare const HOSTED_ADMISSION_PATH = "/v1/internal/hosted-admission";
4
4
  export declare const HOSTED_EXECUTION_PATH = "/v1/internal/hosted-execution";
5
5
  export declare const HOSTED_GUEST_RETRY_TRANSIENT = "transient";
6
6
  export declare const HOSTED_GUEST_RETRY_TERMINAL = "terminal";
7
+ export declare const HOSTED_SERVER_TIMING_STEP = "agent_sdk_step";
8
+ export declare const HOSTED_SERVER_TIMING_STEPS: readonly ["handler", "claim", "send", "queue"];
9
+ export type HostedServerTimingStep = (typeof HOSTED_SERVER_TIMING_STEPS)[number];
7
10
  export type HostedGuestRetryDisposition = typeof HOSTED_GUEST_RETRY_TRANSIENT | typeof HOSTED_GUEST_RETRY_TERMINAL;
8
11
  export declare const HOSTED_FAILURE_CLASSIFICATION_VERSION = 1;
9
12
  export type HostedFailureDomain = "configuration" | "protocol" | "platform" | "agent" | "dependency" | "cancellation" | "unknown";