@cursor/bdk 0.2.15 → 0.2.16

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 (232) hide show
  1. package/dist/bin/agent-serve.js +41 -3
  2. package/dist/channels/github/index.d.ts +1 -1
  3. package/dist/channels/github/index.d.ts.map +1 -1
  4. package/dist/channels/github/index.js +1 -1
  5. package/dist/docs/404.html +2 -2
  6. package/dist/docs/assets/{app.CRMxF0qX.js → app.BSrZkTHD.js} +4 -4
  7. package/dist/docs/assets/chunks/@localSearchIndexroot.JUnN1Be1.js +1 -0
  8. package/dist/docs/assets/chunks/{VPLocalSearchBox.C4BiQe53.js → VPLocalSearchBox.BxmgcwIX.js} +1 -1
  9. package/dist/docs/assets/chunks/{arc.D1TA2Mxn.js → arc.CAid9y9R.js} +1 -1
  10. package/dist/docs/assets/chunks/{architectureDiagram-Q4EWVU46.CA-hBJCN.js → architectureDiagram-Q4EWVU46.kLxg-1A5.js} +1 -1
  11. package/dist/docs/assets/chunks/{baseUniq.CzsSgiab.js → baseUniq.BWvpjFlO.js} +1 -1
  12. package/dist/docs/assets/chunks/{blockDiagram-DXYQGD6D.sxrH_f0l.js → blockDiagram-DXYQGD6D.DyjX8R7M.js} +1 -1
  13. package/dist/docs/assets/chunks/{c4Diagram-AHTNJAMY.D_Z3mqAl.js → c4Diagram-AHTNJAMY.DBdWlnqr.js} +1 -1
  14. package/dist/docs/assets/chunks/channel.CWc3NN9g.js +1 -0
  15. package/dist/docs/assets/chunks/{chunk-4BX2VUAB.BS6_uTUf.js → chunk-4BX2VUAB.T5enPS2D.js} +1 -1
  16. package/dist/docs/assets/chunks/{chunk-4TB4RGXK.D-URAeTU.js → chunk-4TB4RGXK.D6zswRAS.js} +1 -1
  17. package/dist/docs/assets/chunks/{chunk-55IACEB6.b4SZc5kO.js → chunk-55IACEB6.Bh05N-a3.js} +1 -1
  18. package/dist/docs/assets/chunks/{chunk-EDXVE4YY.DLKEEDkN.js → chunk-EDXVE4YY.DZv_O-d9.js} +1 -1
  19. package/dist/docs/assets/chunks/{chunk-FMBD7UC4.3SyQHgpY.js → chunk-FMBD7UC4.BY53CZaL.js} +1 -1
  20. package/dist/docs/assets/chunks/{chunk-OYMX7WX6.DBKKaFeS.js → chunk-OYMX7WX6.CO5lI2PE.js} +1 -1
  21. package/dist/docs/assets/chunks/{chunk-QZHKN3VN.BhCYeR7H.js → chunk-QZHKN3VN.DMfpW0s4.js} +1 -1
  22. package/dist/docs/assets/chunks/{chunk-YZCP3GAM.Cpg0VgI7.js → chunk-YZCP3GAM.COPT56Nr.js} +1 -1
  23. package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.D5a745iS.js +1 -0
  24. package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.D5a745iS.js +1 -0
  25. package/dist/docs/assets/chunks/clone.CCGVqN_B.js +1 -0
  26. package/dist/docs/assets/chunks/{cose-bilkent-S5V4N54A.4q0YNZN6.js → cose-bilkent-S5V4N54A.BJSj7zzd.js} +1 -1
  27. package/dist/docs/assets/chunks/{dagre-KV5264BT.Bk_CcQPr.js → dagre-KV5264BT.DDv7IQZT.js} +1 -1
  28. package/dist/docs/assets/chunks/{diagram-5BDNPKRD.CgreoM_Z.js → diagram-5BDNPKRD.BUoE9HFH.js} +1 -1
  29. package/dist/docs/assets/chunks/{diagram-G4DWMVQ6.DlZGpm6W.js → diagram-G4DWMVQ6.BF3JtrnJ.js} +1 -1
  30. package/dist/docs/assets/chunks/{diagram-MMDJMWI5.BxtXxgIR.js → diagram-MMDJMWI5.BvuCWc4e.js} +1 -1
  31. package/dist/docs/assets/chunks/{diagram-TYMM5635.DSzlJp2D.js → diagram-TYMM5635._EqUGqFN.js} +1 -1
  32. package/dist/docs/assets/chunks/{erDiagram-SMLLAGMA.BN1YUmEV.js → erDiagram-SMLLAGMA.DxNvSdzj.js} +1 -1
  33. package/dist/docs/assets/chunks/{flowDiagram-DWJPFMVM.B61NGNYu.js → flowDiagram-DWJPFMVM.DVtRP546.js} +1 -1
  34. package/dist/docs/assets/chunks/{ganttDiagram-T4ZO3ILL.DR-tto3M.js → ganttDiagram-T4ZO3ILL.Bn9vb7xI.js} +1 -1
  35. package/dist/docs/assets/chunks/{gitGraphDiagram-UUTBAWPF.CBPs2W_2.js → gitGraphDiagram-UUTBAWPF.45r6n737.js} +1 -1
  36. package/dist/docs/assets/chunks/{graph.DmlaqzCE.js → graph.BOkX3Ws_.js} +1 -1
  37. package/dist/docs/assets/chunks/{infoDiagram-42DDH7IO.obPv-fFg.js → infoDiagram-42DDH7IO.DyBCcxOm.js} +1 -1
  38. package/dist/docs/assets/chunks/{ishikawaDiagram-UXIWVN3A.CXHTUcM3.js → ishikawaDiagram-UXIWVN3A.kg0ywDlx.js} +1 -1
  39. package/dist/docs/assets/chunks/{journeyDiagram-VCZTEJTY.BoVHerYZ.js → journeyDiagram-VCZTEJTY.BUfrLnXA.js} +1 -1
  40. package/dist/docs/assets/chunks/{kanban-definition-6JOO6SKY.CfYmPHZg.js → kanban-definition-6JOO6SKY.Bn7X35b2.js} +1 -1
  41. package/dist/docs/assets/chunks/{layout.621UdAhB.js → layout.B0QW6d8M.js} +1 -1
  42. package/dist/docs/assets/chunks/{linear.Cz_zRKjr.js → linear.C59eCF0D.js} +1 -1
  43. package/dist/docs/assets/chunks/{min.ON4GjCH7.js → min.BnDl0p08.js} +1 -1
  44. package/dist/docs/assets/chunks/{mindmap-definition-QFDTVHPH.DLPMLJlv.js → mindmap-definition-QFDTVHPH.u2HYLooo.js} +1 -1
  45. package/dist/docs/assets/chunks/{pieDiagram-DEJITSTG.BFp11AYt.js → pieDiagram-DEJITSTG.CbnIrr9l.js} +1 -1
  46. package/dist/docs/assets/chunks/{quadrantDiagram-34T5L4WZ.ChX7xo6B.js → quadrantDiagram-34T5L4WZ.D2zWIixq.js} +1 -1
  47. package/dist/docs/assets/chunks/{requirementDiagram-MS252O5E.DbKtHG_Q.js → requirementDiagram-MS252O5E.DvOFa3oO.js} +1 -1
  48. package/dist/docs/assets/chunks/{sankeyDiagram-XADWPNL6.Spw8tv-7.js → sankeyDiagram-XADWPNL6.BfKCkH3x.js} +1 -1
  49. package/dist/docs/assets/chunks/{sequenceDiagram-FGHM5R23.BYso9LlE.js → sequenceDiagram-FGHM5R23.CUPKdYN0.js} +1 -1
  50. package/dist/docs/assets/chunks/{stateDiagram-FHFEXIEX.D8l54jqW.js → stateDiagram-FHFEXIEX.CimDCRiK.js} +1 -1
  51. package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.ClNUVSTQ.js +1 -0
  52. package/dist/docs/assets/chunks/{theme.m_Ethbkv.js → theme.CKht7z82.js} +2 -2
  53. package/dist/docs/assets/chunks/{timeline-definition-GMOUNBTQ.BLdhhyy9.js → timeline-definition-GMOUNBTQ.BFTd5qKs.js} +1 -1
  54. package/dist/docs/assets/chunks/{vennDiagram-DHZGUBPP.CyGT2F_P.js → vennDiagram-DHZGUBPP.N6t5MmCb.js} +1 -1
  55. package/dist/docs/assets/chunks/wardley-RL74JXVD.D2G6Zyds.js +162 -0
  56. package/dist/docs/assets/chunks/{wardleyDiagram-NUSXRM2D.p_Sz9p1i.js → wardleyDiagram-NUSXRM2D.BqScALbL.js} +1 -1
  57. package/dist/docs/assets/chunks/{xychartDiagram-5P7HB3ND.DtXsNUaf.js → xychartDiagram-5P7HB3ND.Br0WiDkT.js} +1 -1
  58. package/dist/docs/assets/{reference_agent-config.md.DrtLxWgR.js → reference_agent-config.md.DYA6ge6t.js} +7 -4
  59. package/dist/docs/assets/{reference_agent-config.md.DrtLxWgR.lean.js → reference_agent-config.md.DYA6ge6t.lean.js} +1 -1
  60. package/dist/docs/assets/{reference_cli.md.BYNIHwbi.js → reference_cli.md.2d2Y0O-d.js} +2 -2
  61. package/dist/docs/assets/{reference_evals.md.if--BLd0.js → reference_evals.md.Ccwp4x3o.js} +3 -3
  62. package/dist/docs/assets/{reference_evals.md.if--BLd0.lean.js → reference_evals.md.Ccwp4x3o.lean.js} +1 -1
  63. package/dist/docs/assets/{reference_skills.md.Ckddg6KX.js → reference_skills.md.C2GWh7g8.js} +3 -3
  64. package/dist/docs/building-with-agents.html +35 -35
  65. package/dist/docs/deployment.html +35 -35
  66. package/dist/docs/evals.html +35 -35
  67. package/dist/docs/guides/agent-to-agent.html +35 -35
  68. package/dist/docs/guides/bitbucket.html +35 -35
  69. package/dist/docs/guides/cloud-agents.html +35 -35
  70. package/dist/docs/guides/convert-automation.html +35 -35
  71. package/dist/docs/guides/github.html +35 -35
  72. package/dist/docs/guides/gitlab.html +35 -35
  73. package/dist/docs/guides/grokbot-agents.html +35 -35
  74. package/dist/docs/guides/hooks.html +35 -35
  75. package/dist/docs/guides/improve.html +35 -35
  76. package/dist/docs/guides/jev.html +35 -35
  77. package/dist/docs/guides/mcp-oauth.html +35 -35
  78. package/dist/docs/guides/migrate.html +35 -35
  79. package/dist/docs/guides/opentelemetry.html +35 -35
  80. package/dist/docs/guides/slack.html +35 -35
  81. package/dist/docs/guides/webhooks.html +35 -35
  82. package/dist/docs/hashmap.json +1 -1
  83. package/dist/docs/hillclimbing.html +35 -35
  84. package/dist/docs/index.html +35 -35
  85. package/dist/docs/llms-full.txt +41 -3
  86. package/dist/docs/quickstart.html +35 -35
  87. package/dist/docs/reference/agent-config.html +41 -38
  88. package/dist/docs/reference/agent-config.md +26 -1
  89. package/dist/docs/reference/artifacts.html +35 -35
  90. package/dist/docs/reference/channels.html +35 -35
  91. package/dist/docs/reference/cli.html +38 -38
  92. package/dist/docs/reference/cli.md +2 -2
  93. package/dist/docs/reference/connections.html +35 -35
  94. package/dist/docs/reference/evals.html +37 -37
  95. package/dist/docs/reference/evals.md +13 -0
  96. package/dist/docs/reference/extensions.html +35 -35
  97. package/dist/docs/reference/hooks.html +35 -35
  98. package/dist/docs/reference/http-api.html +35 -35
  99. package/dist/docs/reference/instructions.html +35 -35
  100. package/dist/docs/reference/playground.html +35 -35
  101. package/dist/docs/reference/project-layout.html +35 -35
  102. package/dist/docs/reference/prompt.html +35 -35
  103. package/dist/docs/reference/schedules.html +35 -35
  104. package/dist/docs/reference/sessions.html +35 -35
  105. package/dist/docs/reference/skills.html +38 -38
  106. package/dist/docs/reference/subagents.html +35 -35
  107. package/dist/docs/reference/tools.html +35 -35
  108. package/dist/docs/templates/agentic-owners.html +35 -35
  109. package/dist/docs/templates/grokbot-agents.html +35 -35
  110. package/dist/docs/templates/security-reviewer.html +35 -35
  111. package/dist/docs/templates/thermo-quality-review.html +35 -35
  112. package/dist/docs/templates/thermo-review.html +35 -35
  113. package/dist/docs/templates/triage.html +35 -35
  114. package/dist/docs/troubleshooting.html +35 -35
  115. package/dist/filesystem.d.ts.map +1 -1
  116. package/dist/filesystem.js +4 -8
  117. package/dist/internal/cli-convert-automation.js +9 -19
  118. package/dist/internal/cli-deploy.d.ts +1 -1
  119. package/dist/internal/cli-deploy.d.ts.map +1 -1
  120. package/dist/internal/cli-deploy.js +4 -3
  121. package/dist/internal/cli-init-grokbot.d.ts +29 -0
  122. package/dist/internal/cli-init-grokbot.d.ts.map +1 -0
  123. package/dist/internal/cli-init-grokbot.js +181 -0
  124. package/dist/internal/cli-slack.js +1 -1
  125. package/dist/internal/comment-safe.d.ts +8 -0
  126. package/dist/internal/comment-safe.d.ts.map +1 -0
  127. package/dist/internal/comment-safe.js +12 -0
  128. package/dist/internal/convert-automation/convert-workflow.d.ts.map +1 -1
  129. package/dist/internal/convert-automation/convert-workflow.js +2 -14
  130. package/dist/internal/convert-grokbot/answers.d.ts +127 -0
  131. package/dist/internal/convert-grokbot/answers.d.ts.map +1 -0
  132. package/dist/internal/convert-grokbot/answers.js +443 -0
  133. package/dist/internal/convert-grokbot/bot.d.ts +50 -0
  134. package/dist/internal/convert-grokbot/bot.d.ts.map +1 -0
  135. package/dist/internal/convert-grokbot/bot.js +72 -0
  136. package/dist/internal/convert-grokbot/checks.d.ts +26 -0
  137. package/dist/internal/convert-grokbot/checks.d.ts.map +1 -0
  138. package/dist/internal/convert-grokbot/checks.js +170 -0
  139. package/dist/internal/convert-grokbot/convert.d.ts +60 -0
  140. package/dist/internal/convert-grokbot/convert.d.ts.map +1 -0
  141. package/dist/internal/convert-grokbot/convert.js +470 -0
  142. package/dist/internal/convert-grokbot/handoff.d.ts +44 -0
  143. package/dist/internal/convert-grokbot/handoff.d.ts.map +1 -0
  144. package/dist/internal/convert-grokbot/handoff.js +160 -0
  145. package/dist/internal/convert-grokbot/recipe.d.ts +61 -0
  146. package/dist/internal/convert-grokbot/recipe.d.ts.map +1 -0
  147. package/dist/internal/convert-grokbot/recipe.js +94 -0
  148. package/dist/internal/convert-grokbot/routine.d.ts +51 -0
  149. package/dist/internal/convert-grokbot/routine.d.ts.map +1 -0
  150. package/dist/internal/convert-grokbot/routine.js +128 -0
  151. package/dist/internal/convert-grokbot/slack.d.ts +28 -0
  152. package/dist/internal/convert-grokbot/slack.d.ts.map +1 -0
  153. package/dist/internal/convert-grokbot/slack.js +50 -0
  154. package/dist/internal/deploy-client.d.ts +0 -2
  155. package/dist/internal/deploy-client.d.ts.map +1 -1
  156. package/dist/internal/deploy-client.js +2 -11
  157. package/dist/internal/discovery/names.d.ts +2 -0
  158. package/dist/internal/discovery/names.d.ts.map +1 -1
  159. package/dist/internal/discovery/names.js +2 -0
  160. package/dist/internal/discovery/project.d.ts.map +1 -1
  161. package/dist/internal/discovery/project.js +1 -3
  162. package/dist/internal/eval-judge-model.d.ts +10 -5
  163. package/dist/internal/eval-judge-model.d.ts.map +1 -1
  164. package/dist/internal/eval-judge-model.js +36 -25
  165. package/dist/internal/filesystem/subagent-inherit.d.ts +39 -0
  166. package/dist/internal/filesystem/subagent-inherit.d.ts.map +1 -0
  167. package/dist/internal/filesystem/subagent-inherit.js +96 -0
  168. package/dist/internal/filesystem/tools.d.ts +6 -0
  169. package/dist/internal/filesystem/tools.d.ts.map +1 -1
  170. package/dist/internal/filesystem/tools.js +38 -1
  171. package/dist/internal/hosted-delivery.d.ts.map +1 -1
  172. package/dist/internal/hosted-delivery.js +24 -1
  173. package/dist/internal/hosting.d.ts +1 -1
  174. package/dist/internal/hosting.d.ts.map +1 -1
  175. package/dist/internal/hosting.js +7 -3
  176. package/dist/internal/init-interview.d.ts +3 -5
  177. package/dist/internal/init-interview.d.ts.map +1 -1
  178. package/dist/internal/init-interview.js +15 -88
  179. package/dist/internal/init-project.d.ts +13 -0
  180. package/dist/internal/init-project.d.ts.map +1 -1
  181. package/dist/internal/init-project.js +30 -37
  182. package/dist/internal/init-scaffold.d.ts +11 -0
  183. package/dist/internal/init-scaffold.d.ts.map +1 -1
  184. package/dist/internal/init-scaffold.js +47 -13
  185. package/dist/internal/interview/agent-questions.d.ts +19 -0
  186. package/dist/internal/interview/agent-questions.d.ts.map +1 -0
  187. package/dist/internal/interview/agent-questions.js +120 -0
  188. package/dist/internal/interview/question.d.ts +82 -0
  189. package/dist/internal/interview/question.d.ts.map +1 -0
  190. package/dist/internal/interview/question.js +198 -0
  191. package/dist/internal/local-control-plane.d.ts.map +1 -1
  192. package/dist/internal/local-control-plane.js +5 -1
  193. package/dist/internal/otel/collector.d.ts +2 -0
  194. package/dist/internal/otel/collector.d.ts.map +1 -1
  195. package/dist/internal/otel/collector.js +4 -0
  196. package/dist/internal/resolve-prod-target.d.ts.map +1 -1
  197. package/dist/internal/resolve-prod-target.js +2 -1
  198. package/dist/internal/sdk-runner.d.ts.map +1 -1
  199. package/dist/internal/sdk-runner.js +38 -14
  200. package/dist/internal/sdk-subagent-inherit-support.d.ts +9 -0
  201. package/dist/internal/sdk-subagent-inherit-support.d.ts.map +1 -0
  202. package/dist/internal/sdk-subagent-inherit-support.js +89 -0
  203. package/dist/internal/session-engine.d.ts +13 -0
  204. package/dist/internal/session-engine.d.ts.map +1 -1
  205. package/dist/internal/session-engine.js +59 -11
  206. package/dist/internal/{convert-automation/slug.d.ts → slug.d.ts} +4 -1
  207. package/dist/internal/slug.d.ts.map +1 -0
  208. package/dist/internal/{convert-automation/slug.js → slug.js} +11 -1
  209. package/dist/playground/assets/index-7fVUOA5l.css +1 -0
  210. package/dist/playground/assets/{index-DCsq6f_I.js → index-U3TRnwAP.js} +43 -43
  211. package/dist/playground/index.html +2 -2
  212. package/dist/types.d.ts +10 -1
  213. package/dist/types.d.ts.map +1 -1
  214. package/docs/reference/agent-config.md +26 -1
  215. package/docs/reference/cli.md +2 -2
  216. package/docs/reference/evals.md +13 -0
  217. package/package.json +6 -5
  218. package/schemas/grokbot-answers.schema.json +343 -0
  219. package/skills/create-agent/SKILL.md +7 -5
  220. package/templates/agentic-owners/bot/lib/owners/handles.ts +1 -1
  221. package/templates/agentic-owners/bot/lib/owners/matching.ts +20 -9
  222. package/dist/docs/assets/chunks/@localSearchIndexroot.BZwvb2LN.js +0 -1
  223. package/dist/docs/assets/chunks/channel.D7DtboxW.js +0 -1
  224. package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.irslOV8B.js +0 -1
  225. package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.irslOV8B.js +0 -1
  226. package/dist/docs/assets/chunks/clone.DosLeDYL.js +0 -1
  227. package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.CAYMmzGj.js +0 -1
  228. package/dist/docs/assets/chunks/wardley-RL74JXVD.C5JJS3bh.js +0 -162
  229. package/dist/internal/convert-automation/slug.d.ts.map +0 -1
  230. package/dist/playground/assets/index-BVYWBxLU.css +0 -1
  231. /package/dist/docs/assets/{reference_cli.md.BYNIHwbi.lean.js → reference_cli.md.2d2Y0O-d.lean.js} +0 -0
  232. /package/dist/docs/assets/{reference_skills.md.Ckddg6KX.lean.js → reference_skills.md.C2GWh7g8.lean.js} +0 -0
@@ -7,17 +7,22 @@
7
7
  * prompt injection needs. A reply that talks the judge into running a tool would
8
8
  * do so on the machine running the eval CLI, under the runner's credentials.
9
9
  *
10
- * The session is therefore confined on every axis the SDK exposes:
10
+ * The session is therefore given nothing to act with:
11
11
  *
12
- * - `sandboxOptions.enabled` so any tool call the judge is talked into is
13
- * confined rather than run directly against the host.
12
+ * - `tools: []` so the model is offered no built-in tools and can only reply
13
+ * with text. An injected reply has no shell, file, or MCP call to invoke.
14
+ * Omitting `tools` leaves the default toolset in place.
14
15
  * - `mcpServers: {}` so no MCP surface is reachable.
15
16
  * - `settingSources: []` plus an empty temp `cwd`, so there is no repo to act on
16
17
  * and no ambient `AGENTS.md` / `.cursor` rule can steer a verdict.
18
+ * - `sandboxOptions: { enabled: false }` so grading never requests a local
19
+ * sandbox. Omitting the field is not the same: a `~/.cursor/sandbox.json`
20
+ * policy still counts as a sandbox request and throws on hosts that cannot
21
+ * sandbox. With no tools left, there is nothing for a sandbox to confine.
17
22
  *
18
23
  * The prompt side is hardened separately: `evals/judge.ts` fences untrusted
19
- * content behind a per-call boundary. Both halves matter — this one limits blast
20
- * radius, that one removes the instruction channel.
24
+ * content behind a per-call boundary. Both halves matter — this one removes
25
+ * the tool channel, that one removes the instruction channel.
21
26
  *
22
27
  * Grading also declines outright when the credential's backend and the SDK's
23
28
  * backend disagree, rather than sending a key somewhere it was not minted for
@@ -89,30 +94,36 @@ export const callJudgeModel = async ({ prompt, model }) => {
89
94
  // Imported lazily so a tree of fully deterministic evals never loads the SDK.
90
95
  const { Agent } = await import("@cursor/sdk");
91
96
  const cwd = await mkdtemp(join(tmpdir(), "agentkit-eval-judge-"));
92
- const agent = await Agent.create({
93
- apiKey: resolved.apiKey,
94
- model: typeof model === "string" ? { id: model } : model,
95
- // See the module comment: grading embeds untrusted agent output, so the
96
- // session gets no MCP surface, no ambient settings, an empty working
97
- // directory, and a sandbox around anything it does attempt.
98
- mcpServers: {},
99
- local: {
100
- cwd,
101
- settingSources: [],
102
- sandboxOptions: { enabled: true },
103
- },
104
- });
105
97
  try {
106
- const run = await agent.send(prompt);
107
- const result = await run.wait();
108
- if (result.status === "error" || result.status === "cancelled") {
109
- const detail = result.error?.message ?? result.result ?? result.status;
110
- throw new Error(`eval judge run failed: ${detail}`);
98
+ const agent = await Agent.create({
99
+ apiKey: resolved.apiKey,
100
+ model: typeof model === "string" ? { id: model } : model,
101
+ // See the module comment: grading embeds untrusted agent output, so the
102
+ // session gets no tools, no MCP surface, no ambient settings, and an
103
+ // empty working directory. Sandbox is explicitly off so a per-user
104
+ // sandbox config cannot re-request one.
105
+ tools: [],
106
+ mcpServers: {},
107
+ local: {
108
+ cwd,
109
+ settingSources: [],
110
+ sandboxOptions: { enabled: false },
111
+ },
112
+ });
113
+ try {
114
+ const run = await agent.send(prompt);
115
+ const result = await run.wait();
116
+ if (result.status === "error" || result.status === "cancelled") {
117
+ const detail = result.error?.message ?? result.result ?? result.status;
118
+ throw new Error(`eval judge run failed: ${detail}`);
119
+ }
120
+ return result.result ?? "";
121
+ }
122
+ finally {
123
+ agent.close();
111
124
  }
112
- return result.result ?? "";
113
125
  }
114
126
  finally {
115
- agent.close();
116
127
  await rm(cwd, { recursive: true, force: true }).catch(() => undefined);
117
128
  }
118
129
  };
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Task-child inherit for an authored virtual root.
3
+ *
4
+ * The SDK calls `resourceProviderOptions` once per child session id,
5
+ * including nested `Task` grandchildren, and reuses that result for the
6
+ * child runtime. Each id gets its own {@link childOverlayFs} over the
7
+ * session union (authored tree plus `/tmp` scratch), so a child write
8
+ * cannot clobber the parent or a sibling. The FileSystem handle is not
9
+ * placed on the SDK request.
10
+ *
11
+ * Native executor overrides load on the first child. A static import
12
+ * would pull workspace-only packages into every CLI start. The published
13
+ * package omits that module; children then keep shell suppressed and
14
+ * reach the same overlay through synthesized file tools.
15
+ */
16
+ import type { LocalSubagentInherit, LocalSubagentResourceProviderFields } from "@cursor/sdk";
17
+ import { type FileSystem } from "../../filesystem.js";
18
+ /**
19
+ * Structural view of the checkout-only executor module. Naming that module
20
+ * in a type query would pull it into `tsc -p tsconfig.build.json` even
21
+ * though the build config excludes it, and the published program cannot
22
+ * see its workspace-only imports.
23
+ */
24
+ type ChildToolExecutor = NonNullable<LocalSubagentResourceProviderFields["overrideReadExecutor"]>;
25
+ interface FileSystemExecutorModule {
26
+ createFileSystemReadExecutor(root: FileSystem): ChildToolExecutor;
27
+ createFileSystemWriteExecutor(root: FileSystem): ChildToolExecutor;
28
+ createFileSystemGrepExecutor(root: FileSystem): ChildToolExecutor;
29
+ createFileSystemLsExecutor(root: FileSystem): ChildToolExecutor;
30
+ }
31
+ export interface RootSubagentBinding {
32
+ readonly inherit: LocalSubagentInherit;
33
+ /** Overlay for a Task child. Do not pass the parent session id. */
34
+ fileSystemForSession(sessionId: string): FileSystem;
35
+ }
36
+ export declare function createRootSubagentInherit(parent: FileSystem): RootSubagentBinding;
37
+ export declare function resourceFieldsForChild(overlay: FileSystem, executors: FileSystemExecutorModule | undefined): LocalSubagentResourceProviderFields;
38
+ export {};
39
+ //# sourceMappingURL=subagent-inherit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subagent-inherit.d.ts","sourceRoot":"","sources":["../../../src/internal/filesystem/subagent-inherit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,mCAAmC,EAAE,MAAM,aAAa,CAAC;AAC7F,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtE;;;;;GAKG;AACH,KAAK,iBAAiB,GAAG,WAAW,CAAC,mCAAmC,CAAC,sBAAsB,CAAC,CAAC,CAAC;AAElG,UAAU,wBAAwB;IAChC,4BAA4B,CAAC,IAAI,EAAE,UAAU,GAAG,iBAAiB,CAAC;IAClE,6BAA6B,CAAC,IAAI,EAAE,UAAU,GAAG,iBAAiB,CAAC;IACnE,4BAA4B,CAAC,IAAI,EAAE,UAAU,GAAG,iBAAiB,CAAC;IAClE,0BAA0B,CAAC,IAAI,EAAE,UAAU,GAAG,iBAAiB,CAAC;CACjE;AAUD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;IACvC,mEAAmE;IACnE,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAAC;CACrD;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,UAAU,GAAG,mBAAmB,CAcjF;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,UAAU,EACnB,SAAS,EAAE,wBAAwB,GAAG,SAAS,GAC9C,mCAAmC,CAWrC"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Task-child inherit for an authored virtual root.
3
+ *
4
+ * The SDK calls `resourceProviderOptions` once per child session id,
5
+ * including nested `Task` grandchildren, and reuses that result for the
6
+ * child runtime. Each id gets its own {@link childOverlayFs} over the
7
+ * session union (authored tree plus `/tmp` scratch), so a child write
8
+ * cannot clobber the parent or a sibling. The FileSystem handle is not
9
+ * placed on the SDK request.
10
+ *
11
+ * Native executor overrides load on the first child. A static import
12
+ * would pull workspace-only packages into every CLI start. The published
13
+ * package omits that module; children then keep shell suppressed and
14
+ * reach the same overlay through synthesized file tools.
15
+ */
16
+ import { childOverlayFs } from "../../filesystem.js";
17
+ /**
18
+ * Widened to `string` on purpose. A string-literal dynamic import is still
19
+ * a static dependency, so the published declaration build would compile the
20
+ * excluded executor module. Node and the test runner resolve this relative
21
+ * to this file.
22
+ */
23
+ const FILE_SYSTEM_EXECUTORS_SPECIFIER = "../../filesystem-executors.js";
24
+ export function createRootSubagentInherit(parent) {
25
+ const overlays = new Map();
26
+ return {
27
+ inherit: {
28
+ reportedWorkspacePath: "/",
29
+ resourceProviderOptions: async (context) => {
30
+ const overlay = childOverlayFor(overlays, parent, context.sessionId);
31
+ return resourceFieldsForChild(overlay, await loadFileSystemExecutors());
32
+ },
33
+ },
34
+ fileSystemForSession(sessionId) {
35
+ return childOverlayFor(overlays, parent, sessionId);
36
+ },
37
+ };
38
+ }
39
+ export function resourceFieldsForChild(overlay, executors) {
40
+ if (executors === undefined) {
41
+ return { suppressDefaultShellExecutor: true };
42
+ }
43
+ return {
44
+ overrideReadExecutor: executors.createFileSystemReadExecutor(overlay),
45
+ overrideWriteExecutor: executors.createFileSystemWriteExecutor(overlay),
46
+ overrideGrepExecutor: executors.createFileSystemGrepExecutor(overlay),
47
+ overrideLsExecutor: executors.createFileSystemLsExecutor(overlay),
48
+ suppressDefaultShellExecutor: true,
49
+ };
50
+ }
51
+ async function loadFileSystemExecutors() {
52
+ try {
53
+ const loaded = await import(FILE_SYSTEM_EXECUTORS_SPECIFIER);
54
+ if (!isFileSystemExecutorModule(loaded)) {
55
+ throw new Error("filesystem executors module is missing its factories");
56
+ }
57
+ return loaded;
58
+ }
59
+ catch (error) {
60
+ if (isMissingModule(error)) {
61
+ return undefined;
62
+ }
63
+ throw error;
64
+ }
65
+ }
66
+ function isFileSystemExecutorModule(value) {
67
+ if (typeof value !== "object" || value === null) {
68
+ return false;
69
+ }
70
+ const candidate = value;
71
+ return (typeof candidate.createFileSystemReadExecutor === "function" &&
72
+ typeof candidate.createFileSystemWriteExecutor === "function" &&
73
+ typeof candidate.createFileSystemGrepExecutor === "function" &&
74
+ typeof candidate.createFileSystemLsExecutor === "function");
75
+ }
76
+ function isMissingModule(error) {
77
+ if (typeof error !== "object" || error === null) {
78
+ return false;
79
+ }
80
+ if ("code" in error && error.code === "ERR_MODULE_NOT_FOUND") {
81
+ return true;
82
+ }
83
+ return "cause" in error && isMissingModule(error.cause);
84
+ }
85
+ function childOverlayFor(overlays, parent, sessionId) {
86
+ if (sessionId === undefined || sessionId === "") {
87
+ return childOverlayFs(parent);
88
+ }
89
+ const existing = overlays.get(sessionId);
90
+ if (existing !== undefined) {
91
+ return existing;
92
+ }
93
+ const created = childOverlayFs(parent);
94
+ overlays.set(sessionId, created);
95
+ return created;
96
+ }
@@ -38,5 +38,11 @@ export declare function synthesizedFileSystemToolNames(options: {
38
38
  export declare function fileSystemTool(root: FileSystem, name: string, input?: Record<string, unknown>): DiscoveredTool | undefined;
39
39
  /** Validate and run the same tool a turn or `callTool` would. */
40
40
  export declare function runFileSystemTool(root: FileSystem, name: string, input?: Record<string, unknown>): Promise<unknown>;
41
+ /**
42
+ * Run `fn` with synthesized file tools bound to `root`. Task children use
43
+ * this so Read/Write/Delete hit their overlay instead of the parent tree
44
+ * the tools were built against.
45
+ */
46
+ export declare function runWithFileSystem<T>(root: FileSystem, fn: () => Promise<T>): Promise<T>;
41
47
  export declare function synthesizeFileSystemTools(root: FileSystem, filter?: readonly FileSystemToolName[]): DiscoveredTool[];
42
48
  //# sourceMappingURL=tools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/internal/filesystem/tools.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EAIL,KAAK,UAAU,EACf,KAAK,kBAAkB,EAYxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,gBAAgB,CAAC;AAgCrE,eAAO,MAAM,kCAAkC,YAC7C,MAAM,EACN,IAAI,EACJ,MAAM,EACN,MAAM,EACN,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,gBAAgB,CACR,CAAC;AAEX,MAAM,MAAM,6BAA6B,GAAG,CAAC,OAAO,kCAAkC,CAAC,CAAC,MAAM,CAAC,CAAC;AAIhG,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAMrE;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GACnC,kBAAkB,EAAE,GAAG,SAAS,CAmBlC;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GACnC,kBAAkB,EAAE,GAAG,SAAS,CAKlC;AAKD;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,EAAE;IACtD,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B,GAAG,SAAS,6BAA6B,EAAE,CAW3C;AA2lBD;;;;GAI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B,8BAA8B,CAAC,OAAO,EAAE;IACtD,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B,GAAG,SAAS,6BAA6B,EAAE,CAW3C;AA2lBD;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAClC,cAAc,GAAG,SAAS,CAS5B;AAED,iEAAiE;AACjE,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAClC,OAAO,CAAC,OAAO,CAAC,CAclB;AAID;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAEvF;AA8BD,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,UAAU,EAChB,MAAM,CAAC,EAAE,SAAS,kBAAkB,EAAE,GACrC,cAAc,EAAE,CAQlB"}
@@ -5,6 +5,7 @@
5
5
  * Each tool is a `defineTool` whose runtime `inputSchema` accepts those
6
6
  * fields plus the native aliases the harness still sends.
7
7
  */
8
+ import { AsyncLocalStorage } from "node:async_hooks";
8
9
  import { Buffer } from "node:buffer";
9
10
  import { minimatch } from "minimatch";
10
11
  import { z } from "zod";
@@ -600,11 +601,47 @@ export async function runFileSystemTool(root, name, input = {}) {
600
601
  }
601
602
  return execute(validation.value, {});
602
603
  }
604
+ const fileSystemStorage = new AsyncLocalStorage();
605
+ /**
606
+ * Run `fn` with synthesized file tools bound to `root`. Task children use
607
+ * this so Read/Write/Delete hit their overlay instead of the parent tree
608
+ * the tools were built against.
609
+ */
610
+ export function runWithFileSystem(root, fn) {
611
+ return fileSystemStorage.run(root, fn);
612
+ }
613
+ function bindActiveFileSystem(root, tool) {
614
+ const execute = tool.definition.execute;
615
+ if (execute === undefined) {
616
+ return tool;
617
+ }
618
+ return {
619
+ ...tool,
620
+ definition: {
621
+ ...tool.definition,
622
+ execute: (input, ctx) => {
623
+ const active = fileSystemStorage.getStore();
624
+ if (active === undefined || active === root) {
625
+ return execute(input, ctx);
626
+ }
627
+ const canonical = canonicalizeFileSystemToolName(tool.name);
628
+ if (canonical === undefined) {
629
+ return execute(input, ctx);
630
+ }
631
+ const reboundExecute = FILE_SYSTEM_TOOL_FACTORIES[canonical](active).definition.execute;
632
+ if (reboundExecute === undefined) {
633
+ return execute(input, ctx);
634
+ }
635
+ return reboundExecute(input, ctx);
636
+ },
637
+ },
638
+ };
639
+ }
603
640
  export function synthesizeFileSystemTools(root, filter) {
604
641
  const tools = [];
605
642
  for (const name of SYNTHESIZED_FILE_SYSTEM_TOOL_NAMES) {
606
643
  if (wantsTool(filter, name)) {
607
- tools.push(FILE_SYSTEM_TOOL_FACTORIES[name](root));
644
+ tools.push(bindActiveFileSystem(root, FILE_SYSTEM_TOOL_FACTORIES[name](root)));
608
645
  }
609
646
  }
610
647
  return tools;
@@ -1 +1 @@
1
- {"version":3,"file":"hosted-delivery.d.ts","sourceRoot":"","sources":["../../src/internal/hosted-delivery.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAEnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,kCAAkC,CAAC;AAO1C,OAAO,EAKL,KAAK,sBAAsB,EAG5B,MAAM,oBAAoB,CAAC;AAS5B,OAAO,EAQL,KAAK,oBAAoB,EAIzB,KAAK,mCAAmC,EAWzC,MAAM,+BAA+B,CAAC;AAsBvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAIlD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa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E,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,8DAA8D;IAC9D,aAAa,CAAC,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,wDAAwD;IACxD,YAAY,CAAC,IAAI,YAAY,EAAE,CAAC;IAChC;;;;;OAKG;IACH,eAAe,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C;;;OAGG;IACH,mBAAmB,CAAC,IAAI,OAAO,CAAC,sBAAsB,GAAG,OAAO,CAAC,CAAC;IAClE;;;;OAIG;IACH,mBAAmB,CAAC,IAAI,wBAAwB,CAAC;IACjD;;;OAGG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B,GAAG,IAAI,CAurBP"}
@@ -1,5 +1,5 @@
1
1
  import { randomBytes } from "node:crypto";
2
- import { metrics } from "@opentelemetry/api";
2
+ import { metrics, trace } from "@opentelemetry/api";
3
3
  import { packageVersion } from "./distribution.js";
4
4
  import { dispatchOutcome } from "./channel-dispatch.js";
5
5
  import { consumeHostedBoundSecrets, } from "./cursor/hosted-bound-secrets.js";
@@ -482,11 +482,16 @@ export function registerHostedDeliveryRoute(input) {
482
482
  if (definition === undefined) {
483
483
  return await responseToReply(finish(terminalHostedError(404, "channel_not_found", `No channel named "${delivery.channelId}" is mounted.`)));
484
484
  }
485
+ const endHandler = startHostedSpan("admission.handler", {
486
+ "agent_sdk.channel_kind": delivery.channelKind,
487
+ "agent_sdk.delivery_id": delivery.deliveryId,
488
+ });
485
489
  const admitted = await dispatchHostedAdmission({
486
490
  delivery,
487
491
  definition,
488
492
  args: input.buildHandlerArgs(delivery.channelId),
489
493
  });
494
+ endHandler();
490
495
  if (admitted.pendingSend === undefined) {
491
496
  return await responseToReply(finish(admitted.response));
492
497
  }
@@ -682,7 +687,13 @@ export function registerHostedDeliveryRoute(input) {
682
687
  admitted.expiresAt = Date.now() + ownerTurnPendingTtlMs;
683
688
  }
684
689
  admitted.execution ??= afterHostedWork(input.flushOtel, async () => {
690
+ const spanAttributes = {
691
+ "agent_sdk.channel_kind": admitted.channelKind,
692
+ "agent_sdk.session_public_id": execution.sessionPublicId,
693
+ };
694
+ const endNetworkWait = startHostedSpan("execute.network_wait", spanAttributes);
685
695
  const network = await finishNetworkWait("execution");
696
+ endNetworkWait();
686
697
  guestNetwork = network.timing;
687
698
  if (network.response !== undefined) {
688
699
  return await responseToReply(finish(network.response));
@@ -729,10 +740,12 @@ export function registerHostedDeliveryRoute(input) {
729
740
  // still be running; the marker prevents it from surfacing the
730
741
  // previous delivery's terminal record. The store copies are
731
742
  // dashboard history, so the turn does not wait on them.
743
+ const endClaim = startHostedSpan("execute.claim", spanAttributes);
732
744
  await writeDiag({
733
745
  sessionId: "",
734
746
  turnStatus: HOSTED_EXECUTION_DIAG_RUNNING_STATUS,
735
747
  }, { awaitDurable: false });
748
+ endClaim();
736
749
  let sessionId = "";
737
750
  const owner = {
738
751
  primaryDeliveryId: admitted.deliveryId,
@@ -753,6 +766,7 @@ export function registerHostedDeliveryRoute(input) {
753
766
  key: admitted.send.mailboxContinuationKey,
754
767
  },
755
768
  };
769
+ const endSend = startHostedSpan("execute.send", spanAttributes);
756
770
  const session = input.startSend === undefined
757
771
  ? await args.send(admitted.send.message, options)
758
772
  : await input.startSend({
@@ -761,6 +775,7 @@ export function registerHostedDeliveryRoute(input) {
761
775
  options,
762
776
  sessionPublicId: execution.sessionPublicId,
763
777
  });
778
+ endSend();
764
779
  sessionId = session.id;
765
780
  // The pre-turn claim used an empty sessionId. Stamp the
766
781
  // engine id now so a dashboard / session-view poll that
@@ -1033,6 +1048,14 @@ function hostedFailureForUnfinishedTurn(outcome) {
1033
1048
  }
1034
1049
  return { error: "turn_failed", retry: HOSTED_GUEST_RETRY_TERMINAL };
1035
1050
  }
1051
+ /**
1052
+ * `agent_sdk.hosted.<step>` span; call the result to end it. The delivery
1053
+ * replies before this work finishes, so the inbound HTTP span never covers it.
1054
+ */
1055
+ function startHostedSpan(step, attributes) {
1056
+ const span = trace.getTracer("agent_sdk").startSpan(`agent_sdk.hosted.${step}`, { attributes });
1057
+ return () => span.end();
1058
+ }
1036
1059
  async function afterHostedWork(flushOtel, work) {
1037
1060
  try {
1038
1061
  const result = await work();
@@ -51,6 +51,6 @@ export declare function hostingEntryErrors(declared: {
51
51
  * grammar plus platform-managed names (`CURSOR_*`, hosted storage).
52
52
  */
53
53
  export declare function validateSettableSecretName(name: string): string | undefined;
54
- /** `owner/name` — mirrors the backend's cursor-event repo grammar. */
54
+ /** `owner/name`, `gitlab.com/<group>/…/<project>`, or `bitbucket.org/<workspace>/<repo>`. Mirrors the backend's deploy repository grammar. */
55
55
  export declare function isValidCursorEventRepo(repo: string): boolean;
56
56
  //# sourceMappingURL=hosting.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hosting.d.ts","sourceRoot":"","sources":["../../src/internal/hosting.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,+EAA+E;AAC/E,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,kCAAkC;AAClC,eAAO,MAAM,WAAW,KAAK,CAAC;AAC9B,sCAAsC;AACtC,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAC3C,8BAA8B;AAC9B,eAAO,MAAM,sBAAsB,KAAK,CAAC;AACzC,mEAAmE;AACnE,eAAO,MAAM,2BAA2B,YAAY,CAAC;AACrD,oEAAoE;AACpE,eAAO,MAAM,oBAAoB,MAAM,CAAC;AACxC,sDAAsD;AACtD,eAAO,MAAM,yBAAyB,EAAE,MAA+B,CAAC;AAIxE,gFAAgF;AAChF,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAK3E;AAED;;;GAGG;AACH,eAAO,MAAM,oCAAoC,YAAI,2BAA2B,CAAU,CAAC;AAW3F,4EAA4E;AAC5E,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CASv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M,GAAG,SAAS,CASvE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQnE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAQ1D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE;IAC3C,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC,GAAG,MAAM,EAAE,CAmBX;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAS3E;AAQD,8IAA8I;AAC9I,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE5D"}
@@ -110,8 +110,12 @@ export function validateSettableSecretName(name) {
110
110
  }
111
111
  return undefined;
112
112
  }
113
- const CURSOR_EVENT_REPO_PATTERN = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
114
- /** `owner/name` — mirrors the backend's cursor-event repo grammar. */
113
+ const CURSOR_EVENT_REPO_PATTERNS = [
114
+ /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/,
115
+ /^gitlab\.com\/[a-z0-9_.-]+(?:\/[a-z0-9_.-]+){1,9}$/i,
116
+ /^bitbucket\.org\/[a-z0-9_-]+\/[a-z0-9_.-]+$/i,
117
+ ];
118
+ /** `owner/name`, `gitlab.com/<group>/…/<project>`, or `bitbucket.org/<workspace>/<repo>`. Mirrors the backend's deploy repository grammar. */
115
119
  export function isValidCursorEventRepo(repo) {
116
- return CURSOR_EVENT_REPO_PATTERN.test(repo) && !repo.includes("..");
120
+ return CURSOR_EVENT_REPO_PATTERNS.some((pattern) => pattern.test(repo)) && !repo.includes("..");
117
121
  }
@@ -2,7 +2,9 @@
2
2
  * Template `init.json`: questions `init` asks, and string replacements
3
3
  * it applies while copying the scaffold.
4
4
  */
5
+ import { type InterviewQuestion } from "./interview/question.js";
5
6
  export declare const TEMPLATE_INIT_FILE = "init.json";
7
+ /** The JSON-authorable subset of {@link InterviewQuestion}. */
6
8
  export interface TemplateQuestion {
7
9
  id: string;
8
10
  prompt: string;
@@ -54,13 +56,9 @@ export interface CollectAnswersInput {
54
56
  spec: TemplateInitSpec;
55
57
  vars?: Record<string, string>;
56
58
  interactive: boolean;
57
- ask?: (question: TemplateQuestion) => Promise<string>;
59
+ ask?: (question: InterviewQuestion) => Promise<string>;
58
60
  out?: (text: string) => void;
59
61
  }
60
62
  export declare function collectTemplateAnswers(input: CollectAnswersInput): Promise<ParseAnswersResult>;
61
63
  export declare function applyInitReplacements(contents: string, rel: string, spec: TemplateInitSpec, answers: Record<string, string>): string;
62
- export declare function promptTemplateQuestion(question: TemplateQuestion, options?: {
63
- input?: NodeJS.ReadableStream;
64
- output?: NodeJS.WritableStream;
65
- }): Promise<string>;
66
64
  //# sourceMappingURL=init-interview.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"init-interview.d.ts","sourceRoot":"","sources":["../../src/internal/init-interview.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,eAAO,MAAM,kBAAkB,cAAc,CAAC;AAE9C,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,KAAK,CAAC,EAAE,iBAAiB,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,YAAY,GAAG,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E,IAAI,CAAC;IAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GACvE;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjC,4DAA4D;AAC5D,wBAAsB,eAAe,CAAC,KAAK,EAAE;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,WAAW,EAAE,OAAO,CAAC;CACtB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAkBjC;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,gBAAgB,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,WAAW,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACvD,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B;AAOD,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,kBAAkB,CAAC,CAY7B;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,MAAM,CAiBR"}
@@ -4,9 +4,9 @@
4
4
  */
5
5
  import { readFile } from "node:fs/promises";
6
6
  import { join } from "node:path";
7
- import { createInterface } from "node:readline";
8
7
  import { parseCursorGithubRepoScope } from "../channels/github/cursor-account.js";
9
8
  import { describeError } from "./describe-error.js";
9
+ import { collectAnswers } from "./interview/question.js";
10
10
  import { isRecord } from "./is-record.js";
11
11
  export const TEMPLATE_INIT_FILE = "init.json";
12
12
  export function posixRel(rel) {
@@ -81,40 +81,21 @@ export async function runTemplateInit(input) {
81
81
  return { ok: false, error: describeError(error) };
82
82
  }
83
83
  }
84
+ const PARSERS = {
85
+ "owner-repo-list": (value) => parseCursorGithubRepoScope(value.split(",").map((repo) => repo.trim())).repos.join(", "),
86
+ };
84
87
  export async function collectTemplateAnswers(input) {
85
- const vars = input.vars ?? {};
86
- const answers = {};
87
- const ask = input.ask ?? promptTemplateQuestion;
88
- const out = input.out ?? ((text) => process.stdout.write(text));
89
- for (const question of input.spec.questions) {
90
- if (question.id in vars || !input.interactive) {
91
- const raw = vars[question.id]?.trim() || question.default;
92
- if (raw === undefined) {
93
- // Skipping would scaffold the template's sample answer (e.g. owner/repo).
94
- return {
95
- ok: false,
96
- error: `${question.id} is required: pass --var ${question.id}=... (${question.prompt})`,
97
- };
98
- }
99
- const parsed = parseQuestionValue(question, raw);
100
- if (!parsed.ok) {
101
- return parsed;
102
- }
103
- answers[question.id] = parsed.value;
104
- continue;
105
- }
106
- for (;;) {
107
- const line = await ask(question);
108
- const value = line.trim() === "" && question.default !== undefined ? question.default : line;
109
- const parsed = parseQuestionValue(question, value);
110
- if (parsed.ok) {
111
- answers[question.id] = parsed.value;
112
- break;
113
- }
114
- out(`${parsed.error}\n`);
115
- }
116
- }
117
- return { ok: true, answers };
88
+ const collected = await collectAnswers({
89
+ questions: input.spec.questions.map((question) => ({
90
+ ...question,
91
+ parse: question.parse === undefined ? undefined : PARSERS[question.parse],
92
+ })),
93
+ given: input.vars,
94
+ interactive: input.interactive,
95
+ ask: input.ask,
96
+ out: input.out,
97
+ });
98
+ return collected.ok ? { ok: true, answers: collected.answers } : collected;
118
99
  }
119
100
  export function applyInitReplacements(contents, rel, spec, answers) {
120
101
  const file = posixRel(rel);
@@ -134,63 +115,9 @@ export function applyInitReplacements(contents, rel, spec, answers) {
134
115
  }
135
116
  return next;
136
117
  }
137
- export async function promptTemplateQuestion(question, options = {}) {
138
- const input = options.input ?? process.stdin;
139
- const output = options.output ?? process.stdout;
140
- const rl = createInterface({ input, output });
141
- const suffix = promptSuffix(question);
142
- try {
143
- if (question.hint !== undefined) {
144
- output.write(` ${question.hint}\n`);
145
- }
146
- return await new Promise((resolve) => {
147
- rl.question(`${question.prompt}${suffix} `, resolve);
148
- });
149
- }
150
- finally {
151
- rl.close();
152
- }
153
- }
154
118
  function replaceLiteral(haystack, find, value) {
155
119
  return haystack.replaceAll(find, () => value);
156
120
  }
157
- function promptSuffix(question) {
158
- if (question.choices !== undefined && question.choices.length > 0) {
159
- return ` [${question.choices.join("/")}]`;
160
- }
161
- if (question.default !== undefined) {
162
- return ` [${question.default}]`;
163
- }
164
- if (question.placeholder !== undefined) {
165
- return ` (${question.placeholder})`;
166
- }
167
- return "";
168
- }
169
- function parseQuestionValue(question, raw) {
170
- const trimmed = raw.trim();
171
- if (trimmed === "") {
172
- return { ok: false, error: `${question.id} is required.` };
173
- }
174
- if (question.choices !== undefined && question.choices.length > 0) {
175
- if (!question.choices.includes(trimmed)) {
176
- return {
177
- ok: false,
178
- error: `${question.id} must be one of ${question.choices.join(", ")}.`,
179
- };
180
- }
181
- return { ok: true, value: trimmed };
182
- }
183
- if (question.parse === "owner-repo-list") {
184
- try {
185
- const scope = parseCursorGithubRepoScope(trimmed.split(",").map((repo) => repo.trim()));
186
- return { ok: true, value: scope.repos.join(", ") };
187
- }
188
- catch (error) {
189
- return { ok: false, error: describeError(error) };
190
- }
191
- }
192
- return { ok: true, value: trimmed };
193
- }
194
121
  function formatReplaceValue(rule, answers) {
195
122
  const raw = answers[rule.answer];
196
123
  if (raw === undefined || raw === "") {
@@ -54,8 +54,21 @@ export type InitTargetCheck = {
54
54
  * (or the reverse).
55
55
  */
56
56
  export declare function checkInitTarget(rootDir: string, template: string | undefined): InitTargetCheck;
57
+ /** Flags one `init` path takes and the other does not, checked before either runs. */
58
+ export declare function initFlagConflict(flags: {
59
+ fromGrokbot?: string;
60
+ answers?: string;
61
+ dryRun?: boolean;
62
+ template?: string;
63
+ vars?: readonly string[];
64
+ }): string | undefined;
57
65
  export declare function initProject(options: InitProjectOptions): Promise<InitProjectResult>;
58
66
  export declare function isEexist(error: unknown): boolean;
67
+ /** Writes a file unless one is already there; the action says which. */
68
+ export declare function writeNewFile(rootDir: string, file: {
69
+ path: string;
70
+ contents: string | Uint8Array;
71
+ }): Promise<InitFileAction>;
59
72
  export interface InstallScaffoldDependenciesOptions {
60
73
  /**
61
74
  * `inherit` streams npm output to the terminal (human `init`);