@cursor/bdk 0.2.6 → 0.2.7

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 (335) hide show
  1. package/dist/bin/agent-serve.js +52 -57
  2. package/dist/channels/github/github-channel.d.ts.map +1 -1
  3. package/dist/channels/github/github-channel.js +34 -8
  4. package/dist/channels/github/types.d.ts +6 -0
  5. package/dist/channels/github/types.d.ts.map +1 -1
  6. package/dist/channels/slack/dispatch.d.ts.map +1 -1
  7. package/dist/channels/slack/dispatch.js +37 -29
  8. package/dist/channels/slack/external-policy.d.ts.map +1 -1
  9. package/dist/channels/slack/external-policy.js +6 -6
  10. package/dist/channels/slack/inbound.d.ts +5 -0
  11. package/dist/channels/slack/inbound.d.ts.map +1 -1
  12. package/dist/channels/slack/inbound.js +13 -0
  13. package/dist/channels/slack/index.d.ts +3 -0
  14. package/dist/channels/slack/index.d.ts.map +1 -1
  15. package/dist/channels/slack/index.js +3 -0
  16. package/dist/channels/slack/log.d.ts +1 -1
  17. package/dist/channels/slack/log.js +1 -1
  18. package/dist/channels/slack/self-identity.d.ts +15 -0
  19. package/dist/channels/slack/self-identity.d.ts.map +1 -0
  20. package/dist/channels/slack/self-identity.js +48 -0
  21. package/dist/channels/slack/sender-name.d.ts +17 -0
  22. package/dist/channels/slack/sender-name.d.ts.map +1 -0
  23. package/dist/channels/slack/sender-name.js +87 -0
  24. package/dist/channels/slack/setup.js +1 -1
  25. package/dist/channels/slack/user-info.d.ts +15 -0
  26. package/dist/channels/slack/user-info.d.ts.map +1 -0
  27. package/dist/channels/slack/user-info.js +57 -0
  28. package/dist/docs/404.html +2 -2
  29. package/dist/docs/assets/{app.CJLKDVza.js → app.oyjtOr3W.js} +4 -4
  30. package/dist/docs/assets/chunks/@localSearchIndexroot.C25zYVuc.js +1 -0
  31. package/dist/docs/assets/chunks/{VPLocalSearchBox.BW9mrQmq.js → VPLocalSearchBox.D0P6J_UJ.js} +1 -1
  32. package/dist/docs/assets/chunks/{arc.D8ZOvM1m.js → arc.B0LY1J1h.js} +1 -1
  33. package/dist/docs/assets/chunks/{architectureDiagram-Q4EWVU46.CXEKhLW-.js → architectureDiagram-Q4EWVU46.dPduLUxY.js} +1 -1
  34. package/dist/docs/assets/chunks/{baseUniq.BJkVKblr.js → baseUniq.B_Ohm21h.js} +1 -1
  35. package/dist/docs/assets/chunks/{blockDiagram-DXYQGD6D.DQDbHxor.js → blockDiagram-DXYQGD6D.B4zcanaJ.js} +1 -1
  36. package/dist/docs/assets/chunks/{c4Diagram-AHTNJAMY.ByMD6LYM.js → c4Diagram-AHTNJAMY.D9Iw21nx.js} +1 -1
  37. package/dist/docs/assets/chunks/channel.CRUyWDV-.js +1 -0
  38. package/dist/docs/assets/chunks/{chunk-4BX2VUAB.Dtq1aVI9.js → chunk-4BX2VUAB.DDVwRShI.js} +1 -1
  39. package/dist/docs/assets/chunks/{chunk-4TB4RGXK.BL_XrkoQ.js → chunk-4TB4RGXK.DsYcdn1i.js} +1 -1
  40. package/dist/docs/assets/chunks/{chunk-55IACEB6.BDPXu94_.js → chunk-55IACEB6.BzzQvcYp.js} +1 -1
  41. package/dist/docs/assets/chunks/{chunk-EDXVE4YY.DhGOQj4k.js → chunk-EDXVE4YY.BMiXZ7FX.js} +1 -1
  42. package/dist/docs/assets/chunks/{chunk-FMBD7UC4.DSF5nr8v.js → chunk-FMBD7UC4.D_mBcLoc.js} +1 -1
  43. package/dist/docs/assets/chunks/{chunk-OYMX7WX6.Day7wayw.js → chunk-OYMX7WX6.CMVjWVMx.js} +1 -1
  44. package/dist/docs/assets/chunks/{chunk-QZHKN3VN.CpBEC0zA.js → chunk-QZHKN3VN.BG-FrPv9.js} +1 -1
  45. package/dist/docs/assets/chunks/{chunk-YZCP3GAM.X_7rY1rx.js → chunk-YZCP3GAM.CkFE1ap3.js} +1 -1
  46. package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.CG_UObcQ.js +1 -0
  47. package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.CG_UObcQ.js +1 -0
  48. package/dist/docs/assets/chunks/clone.NYSZ9qZN.js +1 -0
  49. package/dist/docs/assets/chunks/{cose-bilkent-S5V4N54A.BVRmi2ko.js → cose-bilkent-S5V4N54A.BVNnCTvY.js} +1 -1
  50. package/dist/docs/assets/chunks/{dagre-KV5264BT.Dei9oslB.js → dagre-KV5264BT.CDN5PR9l.js} +1 -1
  51. package/dist/docs/assets/chunks/{diagram-5BDNPKRD._M-efGt7.js → diagram-5BDNPKRD.DQRUlT-i.js} +1 -1
  52. package/dist/docs/assets/chunks/{diagram-G4DWMVQ6.D1Vmhfsj.js → diagram-G4DWMVQ6.CoeblYQT.js} +1 -1
  53. package/dist/docs/assets/chunks/{diagram-MMDJMWI5.cE1bmvAC.js → diagram-MMDJMWI5.DW3ymjl0.js} +1 -1
  54. package/dist/docs/assets/chunks/{diagram-TYMM5635.DkXAfznP.js → diagram-TYMM5635.BP0uN4Jw.js} +1 -1
  55. package/dist/docs/assets/chunks/{erDiagram-SMLLAGMA.DH_pSwPg.js → erDiagram-SMLLAGMA.DVFUWEn4.js} +1 -1
  56. package/dist/docs/assets/chunks/{flowDiagram-DWJPFMVM.kAWVN9j1.js → flowDiagram-DWJPFMVM.HU-eHspv.js} +1 -1
  57. package/dist/docs/assets/chunks/{ganttDiagram-T4ZO3ILL.8r0w49-p.js → ganttDiagram-T4ZO3ILL.DHNhXijY.js} +1 -1
  58. package/dist/docs/assets/chunks/{gitGraphDiagram-UUTBAWPF.BDa7Bi1i.js → gitGraphDiagram-UUTBAWPF.DkISXcO3.js} +1 -1
  59. package/dist/docs/assets/chunks/{graph.BMPXHz_B.js → graph.CCV0fuRR.js} +1 -1
  60. package/dist/docs/assets/chunks/{infoDiagram-42DDH7IO.BmlcqewS.js → infoDiagram-42DDH7IO.bgILzOoc.js} +1 -1
  61. package/dist/docs/assets/chunks/{ishikawaDiagram-UXIWVN3A.CVSEQSul.js → ishikawaDiagram-UXIWVN3A.CuryXC0F.js} +1 -1
  62. package/dist/docs/assets/chunks/{journeyDiagram-VCZTEJTY.BpeWJ5n-.js → journeyDiagram-VCZTEJTY.BL1Pr-wu.js} +1 -1
  63. package/dist/docs/assets/chunks/{kanban-definition-6JOO6SKY.DHbDXuxB.js → kanban-definition-6JOO6SKY.BbGjvk4l.js} +1 -1
  64. package/dist/docs/assets/chunks/{layout.CzrCDgkP.js → layout.C4PfdldS.js} +1 -1
  65. package/dist/docs/assets/chunks/{linear.HwBsflwN.js → linear.C3xD1T6X.js} +1 -1
  66. package/dist/docs/assets/chunks/{min.DqGHolT3.js → min.CzgRAQ9c.js} +1 -1
  67. package/dist/docs/assets/chunks/{mindmap-definition-QFDTVHPH.ZYGlOawh.js → mindmap-definition-QFDTVHPH.CA9rSWum.js} +1 -1
  68. package/dist/docs/assets/chunks/{pieDiagram-DEJITSTG.C2KRXlNR.js → pieDiagram-DEJITSTG.B8MprgJu.js} +1 -1
  69. package/dist/docs/assets/chunks/{quadrantDiagram-34T5L4WZ.CHj3Qefp.js → quadrantDiagram-34T5L4WZ.DndDwbKT.js} +1 -1
  70. package/dist/docs/assets/chunks/{requirementDiagram-MS252O5E.B1L4Tf7k.js → requirementDiagram-MS252O5E.Zhfgwlnn.js} +1 -1
  71. package/dist/docs/assets/chunks/{sankeyDiagram-XADWPNL6.dNR2yi1B.js → sankeyDiagram-XADWPNL6.B6RRm6N5.js} +1 -1
  72. package/dist/docs/assets/chunks/{sequenceDiagram-FGHM5R23.BrvQ3C6m.js → sequenceDiagram-FGHM5R23.Bfmz-1PN.js} +1 -1
  73. package/dist/docs/assets/chunks/{stateDiagram-FHFEXIEX.BtehEykA.js → stateDiagram-FHFEXIEX.gbrdNqgj.js} +1 -1
  74. package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.DOOmulfQ.js +1 -0
  75. package/dist/docs/assets/chunks/{theme.BDHBZUkP.js → theme.gpWjytMh.js} +2 -2
  76. package/dist/docs/assets/chunks/{timeline-definition-GMOUNBTQ.Bn7nhqEN.js → timeline-definition-GMOUNBTQ.Bl1l7M1f.js} +1 -1
  77. package/dist/docs/assets/chunks/{vennDiagram-DHZGUBPP.DKhc38sz.js → vennDiagram-DHZGUBPP.Dfle4U0d.js} +1 -1
  78. package/dist/docs/assets/chunks/{wardley-RL74JXVD.DOXQ0w8J.js → wardley-RL74JXVD.BJrCW6xc.js} +1 -1
  79. package/dist/docs/assets/chunks/{wardleyDiagram-NUSXRM2D.Bbq5B2Ic.js → wardleyDiagram-NUSXRM2D.CM_4lmvZ.js} +1 -1
  80. package/dist/docs/assets/chunks/{xychartDiagram-5P7HB3ND.B77HE1K8.js → xychartDiagram-5P7HB3ND.CHT5X28R.js} +1 -1
  81. package/dist/docs/assets/{reference_cli.md.BsgDqYPh.js → reference_cli.md.GwugN3n-.js} +5 -5
  82. package/dist/docs/assets/reference_cli.md.GwugN3n-.lean.js +1 -0
  83. package/dist/docs/assets/{reference_skills.md.ClkMoQsV.js → reference_skills.md.C0guGcH0.js} +3 -3
  84. package/dist/docs/building-with-agents.html +35 -35
  85. package/dist/docs/deployment.html +35 -35
  86. package/dist/docs/evals.html +35 -35
  87. package/dist/docs/guides/agent-to-agent.html +35 -35
  88. package/dist/docs/guides/bitbucket.html +35 -35
  89. package/dist/docs/guides/cloud-agents.html +35 -35
  90. package/dist/docs/guides/convert-automation.html +35 -35
  91. package/dist/docs/guides/github.html +35 -35
  92. package/dist/docs/guides/gitlab.html +35 -35
  93. package/dist/docs/guides/grokbot-agents.html +35 -35
  94. package/dist/docs/guides/hooks.html +35 -35
  95. package/dist/docs/guides/improve.html +35 -35
  96. package/dist/docs/guides/jev.html +35 -35
  97. package/dist/docs/guides/mcp-oauth.html +35 -35
  98. package/dist/docs/guides/opentelemetry.html +35 -35
  99. package/dist/docs/guides/slack.html +35 -35
  100. package/dist/docs/guides/webhooks.html +35 -35
  101. package/dist/docs/hashmap.json +1 -1
  102. package/dist/docs/hillclimbing.html +35 -35
  103. package/dist/docs/index.html +35 -35
  104. package/dist/docs/llms-full.txt +20 -9
  105. package/dist/docs/quickstart.html +35 -35
  106. package/dist/docs/reference/agent-config.html +35 -35
  107. package/dist/docs/reference/artifacts.html +35 -35
  108. package/dist/docs/reference/channels.html +35 -35
  109. package/dist/docs/reference/cli.html +39 -39
  110. package/dist/docs/reference/cli.md +20 -9
  111. package/dist/docs/reference/connections.html +35 -35
  112. package/dist/docs/reference/evals.html +35 -35
  113. package/dist/docs/reference/extensions.html +35 -35
  114. package/dist/docs/reference/hooks.html +35 -35
  115. package/dist/docs/reference/http-api.html +35 -35
  116. package/dist/docs/reference/instructions.html +35 -35
  117. package/dist/docs/reference/playground.html +35 -35
  118. package/dist/docs/reference/project-layout.html +35 -35
  119. package/dist/docs/reference/prompt.html +35 -35
  120. package/dist/docs/reference/schedules.html +35 -35
  121. package/dist/docs/reference/sessions.html +35 -35
  122. package/dist/docs/reference/skills.html +38 -38
  123. package/dist/docs/reference/subagents.html +35 -35
  124. package/dist/docs/reference/tools.html +35 -35
  125. package/dist/docs/templates/agentic-owners.html +35 -35
  126. package/dist/docs/templates/grokbot-agents.html +35 -35
  127. package/dist/docs/templates/security-reviewer.html +35 -35
  128. package/dist/docs/templates/thermo-quality-review.html +35 -35
  129. package/dist/docs/templates/thermo-review.html +35 -35
  130. package/dist/docs/templates/triage.html +35 -35
  131. package/dist/docs/troubleshooting.html +35 -35
  132. package/dist/extensions/cursor-cloud-agents/extension.d.ts +14 -0
  133. package/dist/extensions/cursor-cloud-agents/extension.d.ts.map +1 -1
  134. package/dist/extensions/cursor-cloud-agents/extension.js +5 -0
  135. package/dist/extensions/cursor-cloud-agents/lib/watch.d.ts +17 -0
  136. package/dist/extensions/cursor-cloud-agents/lib/watch.d.ts.map +1 -0
  137. package/dist/extensions/cursor-cloud-agents/lib/watch.js +99 -0
  138. package/dist/extensions/cursor-cloud-agents/reminders/cloud-agent-stop-watch.d.ts +19 -0
  139. package/dist/extensions/cursor-cloud-agents/reminders/cloud-agent-stop-watch.d.ts.map +1 -0
  140. package/dist/extensions/cursor-cloud-agents/reminders/cloud-agent-stop-watch.js +71 -0
  141. package/dist/extensions/cursor-cloud-agents/skills/handoff.md +9 -5
  142. package/dist/extensions/cursor-cloud-agents/tools/cancel.d.ts.map +1 -1
  143. package/dist/extensions/cursor-cloud-agents/tools/cancel.js +3 -1
  144. package/dist/extensions/cursor-cloud-agents/tools/launch.d.ts.map +1 -1
  145. package/dist/extensions/cursor-cloud-agents/tools/launch.js +3 -2
  146. package/dist/extensions.d.ts +1 -1
  147. package/dist/extensions.js +1 -1
  148. package/dist/files-backends/cursor-hosted.d.ts +22 -83
  149. package/dist/files-backends/cursor-hosted.d.ts.map +1 -1
  150. package/dist/files-backends/cursor-hosted.js +46 -160
  151. package/dist/files.d.ts +9 -32
  152. package/dist/files.d.ts.map +1 -1
  153. package/dist/files.js +7 -32
  154. package/dist/internal/artifacts-store.d.ts +13 -25
  155. package/dist/internal/artifacts-store.d.ts.map +1 -1
  156. package/dist/internal/artifacts-store.js +25 -46
  157. package/dist/internal/cli-ax.d.ts +10 -17
  158. package/dist/internal/cli-ax.d.ts.map +1 -1
  159. package/dist/internal/cli-ax.js +87 -155
  160. package/dist/internal/cli-bitbucket.js +5 -5
  161. package/dist/internal/cli-deploy.d.ts +4 -1
  162. package/dist/internal/cli-deploy.d.ts.map +1 -1
  163. package/dist/internal/cli-deploy.js +117 -20
  164. package/dist/internal/cli-github.js +13 -13
  165. package/dist/internal/cli-gitlab.js +5 -5
  166. package/dist/internal/continuation-identity.d.ts +2 -0
  167. package/dist/internal/continuation-identity.d.ts.map +1 -1
  168. package/dist/internal/continuation-identity.js +4 -0
  169. package/dist/internal/conversation-mirror.d.ts +9 -38
  170. package/dist/internal/conversation-mirror.d.ts.map +1 -1
  171. package/dist/internal/conversation-mirror.js +62 -68
  172. package/dist/internal/cursor/account-mcp.d.ts +1 -1
  173. package/dist/internal/cursor/account-mcp.js +1 -1
  174. package/dist/internal/cursor/backend-client.js +1 -1
  175. package/dist/internal/cursor/github-credentials.js +3 -3
  176. package/dist/internal/cursor/hosted-bound-secrets.d.ts +6 -2
  177. package/dist/internal/cursor/hosted-bound-secrets.d.ts.map +1 -1
  178. package/dist/internal/cursor/hosted-bound-secrets.js +13 -2
  179. package/dist/internal/cursor/hosted-store-secrets.d.ts +13 -37
  180. package/dist/internal/cursor/hosted-store-secrets.d.ts.map +1 -1
  181. package/dist/internal/cursor/hosted-store-secrets.js +13 -37
  182. package/dist/internal/cursor/store-api-client.d.ts +17 -39
  183. package/dist/internal/cursor/store-api-client.d.ts.map +1 -1
  184. package/dist/internal/cursor/store-api-client.js +15 -37
  185. package/dist/internal/cursor-deployment-relay.js +3 -3
  186. package/dist/internal/cursor-event-relay.js +1 -1
  187. package/dist/internal/cursor-relay-core.d.ts +1 -1
  188. package/dist/internal/cursor-relay-core.d.ts.map +1 -1
  189. package/dist/internal/deploy-client.d.ts +55 -63
  190. package/dist/internal/deploy-client.d.ts.map +1 -1
  191. package/dist/internal/deploy-client.js +48 -28
  192. package/dist/internal/discovery/agent.d.ts +1 -1
  193. package/dist/internal/discovery/agent.d.ts.map +1 -1
  194. package/dist/internal/discovery/agent.js +4 -0
  195. package/dist/internal/discovery/extensions.d.ts +2 -1
  196. package/dist/internal/discovery/extensions.d.ts.map +1 -1
  197. package/dist/internal/discovery/extensions.js +11 -1
  198. package/dist/internal/discovery/project.d.ts.map +1 -1
  199. package/dist/internal/discovery/project.js +1 -0
  200. package/dist/internal/distribution.d.ts +2 -2
  201. package/dist/internal/distribution.d.ts.map +1 -1
  202. package/dist/internal/distribution.js +2 -2
  203. package/dist/internal/docs-site.js +3 -3
  204. package/dist/internal/eval-run-store.js +8 -8
  205. package/dist/internal/framework-file-storage.d.ts +10 -34
  206. package/dist/internal/framework-file-storage.d.ts.map +1 -1
  207. package/dist/internal/framework-file-storage.js +12 -39
  208. package/dist/internal/framework-storage-selection.d.ts +10 -46
  209. package/dist/internal/framework-storage-selection.d.ts.map +1 -1
  210. package/dist/internal/framework-storage-selection.js +15 -64
  211. package/dist/internal/github-fanout.js +2 -2
  212. package/dist/internal/handleAgentServeTrigger.d.ts +5 -8
  213. package/dist/internal/handleAgentServeTrigger.d.ts.map +1 -1
  214. package/dist/internal/handleAgentServeTrigger.js +5 -8
  215. package/dist/internal/host-files.js +6 -9
  216. package/dist/internal/host-platforms.js +5 -5
  217. package/dist/internal/hosted-catch.d.ts +3 -2
  218. package/dist/internal/hosted-catch.d.ts.map +1 -1
  219. package/dist/internal/hosted-catch.js +27 -9
  220. package/dist/internal/hosted-delivery-protocol.d.ts +31 -8
  221. package/dist/internal/hosted-delivery-protocol.d.ts.map +1 -1
  222. package/dist/internal/hosted-delivery-protocol.js +102 -1
  223. package/dist/internal/hosted-delivery.d.ts.map +1 -1
  224. package/dist/internal/hosted-delivery.js +32 -12
  225. package/dist/internal/hosted-execution-diag.d.ts +13 -24
  226. package/dist/internal/hosted-execution-diag.d.ts.map +1 -1
  227. package/dist/internal/hosted-execution-diag.js +11 -20
  228. package/dist/internal/hosted-execution-flush.d.ts +22 -10
  229. package/dist/internal/hosted-execution-flush.d.ts.map +1 -1
  230. package/dist/internal/hosted-execution-flush.js +45 -9
  231. package/dist/internal/hosted-managed-automation.js +5 -5
  232. package/dist/internal/hosting.d.ts +5 -10
  233. package/dist/internal/hosting.d.ts.map +1 -1
  234. package/dist/internal/hosting.js +5 -10
  235. package/dist/internal/legacy-command-guard.d.ts +1 -4
  236. package/dist/internal/legacy-command-guard.d.ts.map +1 -1
  237. package/dist/internal/legacy-command-guard.js +2 -11
  238. package/dist/internal/listen-port.js +1 -1
  239. package/dist/internal/local-control-plane.js +6 -6
  240. package/dist/internal/logs-client.d.ts +20 -1
  241. package/dist/internal/logs-client.d.ts.map +1 -1
  242. package/dist/internal/logs-client.js +89 -1
  243. package/dist/internal/mcp-endpoint.js +1 -1
  244. package/dist/internal/otel/collector.js +1 -1
  245. package/dist/internal/otel/runtime.js +13 -13
  246. package/dist/internal/platform-schedule-sync.js +2 -2
  247. package/dist/internal/playground/toolchain.js +6 -6
  248. package/dist/internal/process-memory-telemetry.js +2 -2
  249. package/dist/internal/reminder-runner.d.ts +8 -3
  250. package/dist/internal/reminder-runner.d.ts.map +1 -1
  251. package/dist/internal/reminder-runner.js +51 -52
  252. package/dist/internal/resolve-prod-target.d.ts +1 -12
  253. package/dist/internal/resolve-prod-target.d.ts.map +1 -1
  254. package/dist/internal/resolve-prod-target.js +2 -32
  255. package/dist/internal/resolved-connections.js +8 -8
  256. package/dist/internal/run-client.d.ts +4 -3
  257. package/dist/internal/run-client.d.ts.map +1 -1
  258. package/dist/internal/run-client.js +98 -61
  259. package/dist/internal/runtime-dispatch-runner.d.ts +1 -0
  260. package/dist/internal/runtime-dispatch-runner.d.ts.map +1 -1
  261. package/dist/internal/runtime-dispatch-runner.js +7 -1
  262. package/dist/internal/schedule-runner.js +1 -1
  263. package/dist/internal/sdk-runner.d.ts +4 -0
  264. package/dist/internal/sdk-runner.d.ts.map +1 -1
  265. package/dist/internal/sdk-runner.js +37 -22
  266. package/dist/internal/server.d.ts +2 -0
  267. package/dist/internal/server.d.ts.map +1 -1
  268. package/dist/internal/server.js +39 -38
  269. package/dist/internal/session-engine.d.ts +31 -44
  270. package/dist/internal/session-engine.d.ts.map +1 -1
  271. package/dist/internal/session-engine.js +67 -83
  272. package/dist/internal/session-run-log.d.ts +10 -24
  273. package/dist/internal/session-run-log.d.ts.map +1 -1
  274. package/dist/internal/session-run-log.js +13 -27
  275. package/dist/internal/sessions-client.d.ts.map +1 -1
  276. package/dist/internal/sessions-client.js +6 -3
  277. package/dist/internal/skills-sync.d.ts +3 -5
  278. package/dist/internal/skills-sync.d.ts.map +1 -1
  279. package/dist/internal/skills-sync.js +3 -5
  280. package/dist/internal/start-log-store.d.ts +7 -18
  281. package/dist/internal/start-log-store.d.ts.map +1 -1
  282. package/dist/internal/start-log-store.js +47 -24
  283. package/dist/internal/storage-coordinator.d.ts +7 -10
  284. package/dist/internal/storage-coordinator.d.ts.map +1 -1
  285. package/dist/internal/storage-coordinator.js +18 -20
  286. package/dist/internal/storage-roles.d.ts +5 -0
  287. package/dist/internal/storage-roles.d.ts.map +1 -1
  288. package/dist/internal/store-api-protocol.d.ts +12 -33
  289. package/dist/internal/store-api-protocol.d.ts.map +1 -1
  290. package/dist/internal/store-api-protocol.js +6 -22
  291. package/dist/internal/store-mirror.d.ts +4 -5
  292. package/dist/internal/store-mirror.d.ts.map +1 -1
  293. package/dist/internal/store-mirror.js +6 -8
  294. package/dist/internal/turn-lease-store.d.ts +12 -5
  295. package/dist/internal/turn-lease-store.d.ts.map +1 -1
  296. package/dist/internal/turn-lease-store.js +61 -8
  297. package/dist/internal/v2-hosting.d.ts +4 -7
  298. package/dist/internal/v2-hosting.d.ts.map +1 -1
  299. package/dist/internal/v2-hosting.js +4 -7
  300. package/dist/internal/workspace-sync.d.ts +3 -6
  301. package/dist/internal/workspace-sync.d.ts.map +1 -1
  302. package/dist/internal/workspace-sync.js +3 -6
  303. package/dist/internal/workspace.d.ts +10 -16
  304. package/dist/internal/workspace.d.ts.map +1 -1
  305. package/dist/internal/workspace.js +9 -14
  306. package/dist/memory.d.ts +17 -43
  307. package/dist/memory.d.ts.map +1 -1
  308. package/dist/memory.js +34 -80
  309. package/dist/playground/assets/index-DPKLl4C_.css +1 -0
  310. package/dist/playground/assets/index-MijLHTbB.js +71 -0
  311. package/dist/playground/index.html +2 -2
  312. package/dist/storage-backends/cursor-hosted-v2.d.ts +8 -36
  313. package/dist/storage-backends/cursor-hosted-v2.d.ts.map +1 -1
  314. package/dist/storage-backends/cursor-hosted-v2.js +9 -37
  315. package/dist/storage-backends/cursor-hosted.d.ts +17 -30
  316. package/dist/storage-backends/cursor-hosted.d.ts.map +1 -1
  317. package/dist/storage-backends/cursor-hosted.js +14 -27
  318. package/dist/storage-protocol.d.ts +13 -38
  319. package/dist/storage-protocol.d.ts.map +1 -1
  320. package/dist/storage-protocol.js +14 -39
  321. package/dist/types.d.ts +29 -30
  322. package/dist/types.d.ts.map +1 -1
  323. package/docs/reference/cli.md +20 -9
  324. package/package.json +1 -1
  325. package/templates/pr-autofixer/bot/instructions.md +3 -3
  326. package/dist/docs/assets/chunks/@localSearchIndexroot.Bq-pxRXm.js +0 -1
  327. package/dist/docs/assets/chunks/channel.DCU8W1RP.js +0 -1
  328. package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.DwpXsM06.js +0 -1
  329. package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.DwpXsM06.js +0 -1
  330. package/dist/docs/assets/chunks/clone.DH6Mx2zB.js +0 -1
  331. package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.kzD0-U89.js +0 -1
  332. package/dist/docs/assets/reference_cli.md.BsgDqYPh.lean.js +0 -1
  333. package/dist/playground/assets/index-6BbTPnaT.css +0 -1
  334. package/dist/playground/assets/index-CI7FAmOP.js +0 -71
  335. /package/dist/docs/assets/{reference_skills.md.ClkMoQsV.lean.js → reference_skills.md.C0guGcH0.lean.js} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"handleAgentServeTrigger.d.ts","sourceRoot":"","sources":["../../src/internal/handleAgentServeTrigger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAOxE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAwB,KAAK,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAE9F,MAAM,WAAW,6BAA6B;IAC5C,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,OAAO,EAAE,oBAAoB,CAAC;IAC9B,uEAAuE;IACvE,IAAI,EAAE,kBAAkB,CAAC;CAC1B;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,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AC,CAAC;QACpD,gBAAgB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,kBAAkB,CAAC;KAC7D,CAAC,CAAC;CACJ,GAAG,6BAA6B,EAAE,CAgBlC;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,uBAAuB,CAAC,CAWlC"}
@@ -1,14 +1,11 @@
1
1
  /**
2
- * Unified entry for dispatching agent-serve triggers from an external ingress
3
- * (e.g. the Cursor backend GitHub webhook or Origin cursor-internal tap).
4
- * Mirrors Automations' `handleAutomationTrigger`.
2
+ * Dispatches authenticated GitHub and Origin events to matching agents.
5
3
  *
6
- * Callers must authenticate the delivery before invoking this (the backend
7
- * verifies GitHub HMAC at `/github_webhook` and Origin v1ed at the
8
- * cursor-internal app). This fan-out does not re-check signatures — same
9
- * trust model as Bugbot after `verifyGithubRequest`.
4
+ * Callers must authenticate the delivery before invoking this fan-out. It
5
+ * does not re-check provider signatures.
10
6
  *
11
- * Each agent's `onPullRequest` / `onComment` / … hooks decide whether to run.
7
+ * Each agent's `onPullRequest`, `onComment`, and related hooks decide whether
8
+ * to run.
12
9
  */
13
10
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
11
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -203,11 +203,9 @@ function requireSession(sessionId) {
203
203
  }
204
204
  /**
205
205
  * Normalize an author path into key-relative form. Rejects traversal, NUL,
206
- * backslashes, trailing slashes, and the `.cursor*` prefix the Agent Store
207
- * reserves for Cursor-managed content — refusing here turns an opaque failure
208
- * deep in a sink (or a 400 from the hosted API, which accepts each path in
209
- * exactly one spelling) into one the author can act on, and keeps the rule
210
- * identical across sinks.
206
+ * backslashes, trailing slashes, and the `.cursor*` prefix reserved for
207
+ * managed content. Rejecting them here gives authors an actionable error and
208
+ * keeps path rules identical across sinks.
211
209
  */
212
210
  function normalizeRelPath(path, allowEmpty) {
213
211
  if (typeof path !== "string") {
@@ -224,14 +222,13 @@ function normalizeRelPath(path, allowEmpty) {
224
222
  throw new FilePathRejectedError(`host.files path is not allowed: ${path}`);
225
223
  }
226
224
  // A backslash is a separator on Windows and a literal on POSIX, so a key
227
- // minted from one would name different objects on different hosts — and the
228
- // hosted API refuses it. Same rule as `segment()` below.
225
+ // minted from one would name different objects on different hosts.
229
226
  if (trimmed.includes("\\")) {
230
227
  throw new FilePathRejectedError(`host.files path is not allowed: ${path}`);
231
228
  }
232
- // On an object path, a trailing slash would mint a key ending in "/" — an
229
+ // On an object path, a trailing slash would mint a key ending in "/", an
233
230
  // empty "directory marker" object, never what an author writing a file
234
- // meant, and refused by the hosted API. A listing prefix (`allowEmpty`) is
231
+ // meant. A listing prefix (`allowEmpty`) is
235
232
  // a different thing: there a trailing slash legitimately scopes to a
236
233
  // directory's contents.
237
234
  if (!allowEmpty && trimmed.endsWith("/")) {
@@ -89,7 +89,7 @@ export function warmupHostGitHubAuth(options) {
89
89
  var _a;
90
90
  const source = (_a = options.authSource) !== null && _a !== void 0 ? _a : (yield resolveHostGitHubAuthSource());
91
91
  if (source === "unavailable") {
92
- options.logger("[agent-sdk] GitHub auth: unavailable (set GITHUB_APP_ID + GITHUB_APP_PRIVATE_KEY + GITHUB_APP_INSTALLATION_ID, or GITHUB_TOKEN / GH_TOKEN, or run `gh auth login`)");
92
+ options.logger("[bdk] GitHub auth: unavailable (set GITHUB_APP_ID + GITHUB_APP_PRIVATE_KEY + GITHUB_APP_INSTALLATION_ID, or GITHUB_TOKEN / GH_TOKEN, or run `gh auth login`)");
93
93
  return source;
94
94
  }
95
95
  let exportedGhToken = false;
@@ -98,7 +98,7 @@ export function warmupHostGitHubAuth(options) {
98
98
  exportedGhToken = yield ensureGhCliTokenEnv();
99
99
  }
100
100
  catch (error) {
101
- options.logger(`[agent-sdk] GitHub auth: failed to export GH_TOKEN for gh CLI: ${error instanceof Error ? error.message : String(error)}`);
101
+ options.logger(`[bdk] GitHub auth: failed to export GH_TOKEN for gh CLI: ${error instanceof Error ? error.message : String(error)}`);
102
102
  }
103
103
  }
104
104
  const label = source === "cursor-account"
@@ -111,15 +111,15 @@ export function warmupHostGitHubAuth(options) {
111
111
  ? "GITHUB_TOKEN/GH_TOKEN"
112
112
  : "gh auth token";
113
113
  if (options.github === undefined) {
114
- options.logger(`[agent-sdk] GitHub auth: ${label}`);
114
+ options.logger(`[bdk] GitHub auth: ${label}`);
115
115
  return source;
116
116
  }
117
117
  try {
118
118
  yield options.github.getOctokit();
119
- options.logger(`[agent-sdk] GitHub auth: ${label}`);
119
+ options.logger(`[bdk] GitHub auth: ${label}`);
120
120
  }
121
121
  catch (error) {
122
- options.logger(`[agent-sdk] GitHub auth: ${label} resolved but Octokit warmup failed: ${error instanceof Error ? error.message : String(error)}`);
122
+ options.logger(`[bdk] GitHub auth: ${label} resolved but Octokit warmup failed: ${error instanceof Error ? error.message : String(error)}`);
123
123
  }
124
124
  return source;
125
125
  });
@@ -33,8 +33,9 @@ export declare function replayCatchRequest(input: {
33
33
  }): Promise<Response>;
34
34
  /**
35
35
  * Attach catch admission to an authored channel. Provider packs attach
36
- * their own adapter afterwards and replace this one; the control plane
37
- * never sends `http.request` to a pack kind in any case.
36
+ * their own adapter afterwards and replace this one. A pack that also
37
+ * declares `publicEndpoint()` must replay `http.request` itself —
38
+ * `githubChannel` does — because that catch is no longer this adapter.
38
39
  */
39
40
  export declare function attachCatchAdmission(definition: ChannelDefinition<unknown>, routes: readonly ChannelRoute[]): void;
40
41
  //# sourceMappingURL=hosted-catch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hosted-catch.d.ts","sourceRoot":"","sources":["../../src/internal/hosted-catch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKpG,OAAO,EAGL,KAAK,oBAAoB,EAG1B,MAAM,4BA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sB,kBAAkB,CAAC,KAAK,EAAE;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,SAAS,YAAY,EAAE,CAAC;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,kBAAkB,CAAC;CAC1B,GAAG,OAAO,CAAC,QAAQ,CAAC,CAiFpB;AAgBD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,iBAAiB,CAAC,OAAO,CAAC,EACtC,MAAM,EAAE,SAAS,YAAY,EAAE,GAC9B,IAAI,CAgBN"}
@@ -19,6 +19,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
19
19
  });
20
20
  };
21
21
  import { acknowledgeTurn, dispatchOutcome, skipped, tagOutcome } from "./channel-dispatch.js";
22
+ import { classifyHostedAdmissionRejection } from "./hosted-delivery-protocol.js";
22
23
  import { invokeChannelRoute } from "./channel-route-dispatch.js";
23
24
  import { DeferredChannelSessionError } from "./deferred-channel-session.js";
24
25
  import { attachHostedAdmissionAdapter } from "./hosted-admission-adapter.js";
@@ -109,21 +110,38 @@ export function replayCatchRequest(input) {
109
110
  // change the verdict, so report a cheap skip that lets the control plane
110
111
  // discard the compute instead of failing and retrying the activity.
111
112
  if (response.status >= 400 && response.status < 500) {
112
- // Logged so a probed public route or a misconfigured provider secret is
113
- // distinguishable from a benign "nothing to do" skip in the guest logs;
114
- // the wire outcome to the control plane is still `skip`.
115
- console.info(`[agent-sdk] catch replay rejected by handler deliveryId=${input.deliveryId} channelId=${input.channelId} route=${envelope.method} ${route.path} status=${String(response.status)}`);
116
- return skipped(`handler rejected the request (${response.status})`, {
117
- status: response.status,
118
- });
113
+ // A handler 4xx (bad Hub signature, schema mismatch, unknown event) is a
114
+ // skip so the control plane does not retry it. The reason is what the
115
+ // control plane logs; this line is the guest copy. Neither includes the
116
+ // secret or the request body.
117
+ const reason = classifyHostedAdmissionRejection(yield handlerErrorCode(response));
118
+ console.info(`[bdk] catch replay rejected by handler deliveryId=${input.deliveryId} channelId=${input.channelId} route=${envelope.method} ${route.path} status=${String(response.status)} reason=${reason}`);
119
+ return skipped(reason, { status: response.status });
119
120
  }
120
121
  return response;
121
122
  });
122
123
  }
124
+ /** Short handler error token, such as `missing_secret`. Never a secret or a body. */
125
+ function handlerErrorCode(response) {
126
+ return __awaiter(this, void 0, void 0, function* () {
127
+ try {
128
+ const body = (yield response.clone().json());
129
+ if (typeof body !== "object" || body === null || Array.isArray(body)) {
130
+ return undefined;
131
+ }
132
+ const error = body.error;
133
+ return typeof error === "string" && /^[a-z0-9_]{1,64}$/.test(error) ? error : undefined;
134
+ }
135
+ catch (_a) {
136
+ return undefined;
137
+ }
138
+ });
139
+ }
123
140
  /**
124
141
  * Attach catch admission to an authored channel. Provider packs attach
125
- * their own adapter afterwards and replace this one; the control plane
126
- * never sends `http.request` to a pack kind in any case.
142
+ * their own adapter afterwards and replace this one. A pack that also
143
+ * declares `publicEndpoint()` must replay `http.request` itself —
144
+ * `githubChannel` does — because that catch is no longer this adapter.
127
145
  */
128
146
  export function attachCatchAdmission(definition, routes) {
129
147
  var _a;
@@ -1,9 +1,3 @@
1
- /**
2
- * Private control-plane/engine wire contract. Version 2 is unreleased and
3
- * intentionally strict: unknown fields and modes fail closed. After release,
4
- * any shape or semantic change must use a new version and a rolling
5
- * compatibility window. See `docs/agent-serve/hosted-delivery-protocol.md`.
6
- */
7
1
  export declare const HOSTED_DELIVERY_PROTOCOL_VERSION = 2;
8
2
  export declare const HOSTED_DELIVERY_HEADER = "x-agent-sdk-hosted-delivery";
9
3
  export declare const HOSTED_ADMISSION_PATH = "/v1/internal/hosted-admission";
@@ -19,7 +13,7 @@ export type HostedFailureClassification = {
19
13
  domain: HostedFailureDomain;
20
14
  source: HostedFailureSource;
21
15
  };
22
- export type HostedFailureCode = "agent_admission_threw" | "agent_dependency_failed" | "background_dispatch_failed" | "bound_secrets_not_consumed" | "channel_dispatch_failed" | "channel_kind_mismatch" | "channel_not_found" | "channel_outcome_missing" | "forbidden" | "guest_connect_stalled" | "guest_network_unavailable" | "hosted_admission_session_mismatch" | "hosted_admission_unavailable" | "hosted_deferred_session_unusable" | "hosted_local_send_rejected" | "hosted_send_limit_exceeded" | "internal_error" | "invalid_hosted_admission" | "invalid_hosted_execution" | "invalid_request" | "method_not_allowed" | "not_found" | "session_busy" | "turn_cancelled" | "turn_failed" | "unauthorized" | "unpaid_invoice" | "usage_limit" | "v2_identity_conflict";
16
+ export type HostedFailureCode = "agent_admission_threw" | "agent_dependency_failed" | "background_dispatch_failed" | "bound_secrets_missing" | "bound_secrets_not_consumed" | "channel_dispatch_failed" | "channel_kind_mismatch" | "channel_not_found" | "channel_outcome_missing" | "forbidden" | "guest_connect_stalled" | "guest_network_unavailable" | "hosted_admission_session_mismatch" | "hosted_admission_unavailable" | "hosted_deferred_session_unusable" | "hosted_local_send_rejected" | "hosted_send_limit_exceeded" | "internal_error" | "invalid_hosted_admission" | "invalid_hosted_execution" | "invalid_request" | "method_not_allowed" | "not_found" | "session_busy" | "turn_cancelled" | "turn_failed" | "unauthorized" | "unpaid_invoice" | "usage_limit" | "v2_identity_conflict";
23
17
  export declare const HOSTED_FAILURE_CLASSIFICATIONS: Record<HostedFailureCode, Omit<HostedFailureClassification, "v">>;
24
18
  export declare function hostedFailureClassification(code: string): HostedFailureClassification;
25
19
  export declare function parseHostedFailureClassification(value: unknown): HostedFailureClassification | undefined;
@@ -32,6 +26,8 @@ export type HostedGuestError = {
32
26
  turnStatus?: string;
33
27
  /** Runner/SDK code (`unknown`, `canceled`, …). Not the human message. */
34
28
  errorCode?: string;
29
+ /** `@cursor/bdk` version of the process that produced this response. */
30
+ engineVersion?: string;
35
31
  };
36
32
  /**
37
33
  * Hosted delivery is the only HTTP surface whose failures drive Temporal
@@ -142,20 +138,47 @@ export type HostedAdmissionStatus = {
142
138
  deliveryId: string;
143
139
  };
144
140
  export type HostedAdmission = HostedAdmissionStart | HostedAdmissionStatus;
141
+ /**
142
+ * Handler 4xx reasons an admission skip can carry. Benign skips (nothing to
143
+ * do) omit `rejection`. Engine HTTP failures use the hosted failure codes
144
+ * instead and are not skips.
145
+ */
146
+ export declare const HOSTED_ADMISSION_REJECTION_REASONS: readonly ["missing_secret", "missing_signature", "signature_mismatch", "invalid_signature", "invalid_token", "invalid_json", "invalid_payload", "unbound_origin_app", "invalid_app", "invalid_installation", "handler_rejected"];
147
+ export type HostedAdmissionRejectionReason = (typeof HOSTED_ADMISSION_REJECTION_REASONS)[number];
148
+ export type HostedAdmissionHandlerRejection = {
149
+ reason: HostedAdmissionRejectionReason;
150
+ status: number;
151
+ };
145
152
  export type HostedAdmissionOutcome = {
146
153
  ok: true;
147
154
  v: 2;
148
- outcome: "skip" | "task";
155
+ outcome: "skip";
156
+ rejection?: HostedAdmissionHandlerRejection;
157
+ engineVersion?: string;
158
+ } | {
159
+ ok: true;
160
+ v: 2;
161
+ outcome: "task";
162
+ engineVersion?: string;
149
163
  } | {
150
164
  ok: true;
151
165
  v: 2;
152
166
  outcome: "send";
153
167
  admissionToken: string;
168
+ engineVersion?: string;
154
169
  } | {
155
170
  ok: true;
156
171
  v: 2;
157
172
  outcome: "started" | "running";
173
+ engineVersion?: string;
158
174
  };
175
+ /**
176
+ * Map a handler `error` token onto the closed admission-rejection set.
177
+ * GitHub's `mismatch` becomes `signature_mismatch`. Payload-specific names
178
+ * become `invalid_payload`. Anything else is `handler_rejected`.
179
+ */
180
+ export declare function classifyHostedAdmissionRejection(error: string | undefined): HostedAdmissionRejectionReason;
181
+ export declare function parseHostedAdmissionHandlerRejection(value: unknown): HostedAdmissionHandlerRejection | undefined;
159
182
  /**
160
183
  * Cap on delivery IDs an owner execute may report as consumed (primary +
161
184
  * accepted active-guest enqueues). Enqueue requests beyond this return
@@ -1 +1 @@
1
- {"version":3,"file":"hosted-delivery-protocol.d.ts","sourceRoot":"","sources":["../../src/internal/hosted-delivery-protocol.ts"],"names":[],"mappings":"AAA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wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,sBAAsB,GAAG,SAAS,CAwB9F"}
1
+ {"version":3,"file":"hosted-delivery-protocol.d.ts","sourceRoot":"","sources":["../../src/internal/hosted-delivery-protocol.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,gCAAgC,IAAI,CAAC;AAClD,eAAO,MAAM,sBAAsB,gCAAgC,CAAC;AACpE,eAAO,MAAM,qBAAqB,kCAAkC,CAAC;AACrE,eAAO,MAAM,qBAAqB,kCAAkC,CAAC;AACrE,eAAO,MAAM,4BAA4B,cAAc,CAAC;AACxD,eAAO,MAAM,2BAA2B,aAAa,CAAC;AAEtD,MAAM,MAAM,2BAA2B,GACnC,OAAO,4BAA4B,GACnC,OAAO,2BAA2B,CAAC;AAEvC,eAAO,MAAM,qCAAqC,IAAI,CAAC;AAEvD,MAAM,MAAM,mBAAmB,GAC3B,eAAe,GACf,UAAU,GACV,UAAU,GACV,OAAO,GACP,YAAY,GACZ,cAAc,GACd,SAAS,CAAC;AAEd,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEpF,MAAM,MAAM,2BAA2B,GAAG;IACxC,CAAC,EAAE,OAAO,qCAAqC,CAAC;IAChD,MAAM,EAAE,mBAAmB,CAAC;IAC5B,MAAM,EAAE,mBAAmB,CAAC;CAC7B,CAAC;AAmBF,MAAM,MAAM,iBAAiB,GACzB,uBAAuB,GACvB,yBAAyB,GACzB,4BAA4B,GAC5B,uBAAuB,GACvB,4BAA4B,GAC5B,yBAAyB,GACzB,uBAAuB,GACvB,mBAAmB,GACnB,yBAAyB,GACzB,WAAW,GACX,uBAAuB,GACvB,2BAA2B,GAC3B,mCAAmC,GACnC,8BAA8B,GAC9B,kCAAkC,GAClC,4BAA4B,GAC5B,4BAA4B,GAC5B,gBAAgB,GAChB,0BAA0B,GAC1B,0BAA0B,GAC1B,iBAAiB,GACjB,oBAA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B,GACD;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,CAAC,EAAE,CAAC,CAAC;IAAC,OAAO,EAAE,UAAU,CAAA;CAAE,GACvC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,CAAC,EAAE,CAAC,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,GACzC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,CAAC,EAAE,CAAC,CAAC;IAAC,OAAO,EAAE,SAAS,CAAA;CAAE,GACtC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,CAAC,EAAE,CAAC,CAAC;IAAC,OAAO,EAAE,SAAS,CAAA;CAAE,CAAC;AAgB3C,eAAO,MAAM,4BAA4B,EAAE,WAAW,CAAC,MAAM,CAAsC,CAAC;AACpG,eAAO,MAAM,qCAAqC,EAAE,WAAW,CAAC,MAAM,CAKpE,CAAC;AAoGH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,SAAS,CA8BhF;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,SAAS,CAkBhF;AAiBD,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,sBAAsB,GAAG,SAAS,CAoC9F;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,OAAO,CAKjF;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,OAAO,GACb,yBAAyB,GAAG,SAAS,CAqBvC;AA2FD;;;GAGG;AACH,wBAAgB,wCAAwC,CACtD,KAAK,EAAE,OAAO,GACb,mCAAmC,GAAG,SAAS,CAyGjD;AAWD,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,sBAAsB,GAAG,SAAS,CAqC9F"}
@@ -4,6 +4,7 @@
4
4
  * any shape or semantic change must use a new version and a rolling
5
5
  * compatibility window. See `docs/agent-serve/hosted-delivery-protocol.md`.
6
6
  */
7
+ import { packageVersion } from "./distribution.js";
7
8
  export const HOSTED_DELIVERY_PROTOCOL_VERSION = 2;
8
9
  export const HOSTED_DELIVERY_HEADER = "x-agent-sdk-hosted-delivery";
9
10
  export const HOSTED_ADMISSION_PATH = "/v1/internal/hosted-admission";
@@ -31,6 +32,7 @@ export const HOSTED_FAILURE_CLASSIFICATIONS = {
31
32
  agent_admission_threw: { domain: "agent", source: "agent" },
32
33
  agent_dependency_failed: { domain: "dependency", source: "factory" },
33
34
  background_dispatch_failed: { domain: "agent", source: "agent" },
35
+ bound_secrets_missing: { domain: "platform", source: "engine" },
34
36
  bound_secrets_not_consumed: { domain: "platform", source: "engine" },
35
37
  channel_dispatch_failed: { domain: "agent", source: "agent" },
36
38
  channel_kind_mismatch: { domain: "configuration", source: "engine" },
@@ -95,6 +97,7 @@ export function hostedGuestErrorResponse(input) {
95
97
  message: input.message,
96
98
  turnStatus: input.turnStatus,
97
99
  errorCode: input.errorCode,
100
+ engineVersion: packageVersion(),
98
101
  };
99
102
  return Response.json(body, { status: input.status });
100
103
  }
@@ -116,6 +119,84 @@ export const HOSTED_REMINDER_CHANNEL_KIND = "agent-sdk:reminder";
116
119
  * Payload is {@link HostedReminderFirePayload}.
117
120
  */
118
121
  export const HOSTED_REMINDER_EVENT_TYPE = "agent-sdk.reminder/fire";
122
+ /**
123
+ * Handler 4xx reasons an admission skip can carry. Benign skips (nothing to
124
+ * do) omit `rejection`. Engine HTTP failures use the hosted failure codes
125
+ * instead and are not skips.
126
+ */
127
+ export const HOSTED_ADMISSION_REJECTION_REASONS = [
128
+ "missing_secret",
129
+ "missing_signature",
130
+ "signature_mismatch",
131
+ "invalid_signature",
132
+ "invalid_token",
133
+ "invalid_json",
134
+ "invalid_payload",
135
+ "unbound_origin_app",
136
+ "invalid_app",
137
+ "invalid_installation",
138
+ "handler_rejected",
139
+ ];
140
+ const HOSTED_ADMISSION_REJECTION_REASON_SET = new Set(HOSTED_ADMISSION_REJECTION_REASONS);
141
+ /** Handler `error` values that all mean the payload did not match the channel schema. */
142
+ const HOSTED_ADMISSION_INVALID_PAYLOAD_ERRORS = new Set([
143
+ "invalid_pull_request_payload",
144
+ "invalid_issue_comment_payload",
145
+ "invalid_review_comment_payload",
146
+ "invalid_issues_payload",
147
+ "invalid_check_suite_payload",
148
+ "invalid_check_run_payload",
149
+ "invalid_workflow_run_payload",
150
+ "invalid_status_payload",
151
+ "invalid_gitlab_payload",
152
+ "invalid_origin_payload",
153
+ "invalid_origin_comment_payload",
154
+ "invalid_bitbucket_payload",
155
+ "invalid_deployment_event",
156
+ ]);
157
+ const HOSTED_ADMISSION_REJECTION_KEYS = new Set(["reason", "status"]);
158
+ /**
159
+ * Map a handler `error` token onto the closed admission-rejection set.
160
+ * GitHub's `mismatch` becomes `signature_mismatch`. Payload-specific names
161
+ * become `invalid_payload`. Anything else is `handler_rejected`.
162
+ */
163
+ export function classifyHostedAdmissionRejection(error) {
164
+ switch (error) {
165
+ case "missing_secret":
166
+ case "missing_signature":
167
+ case "invalid_signature":
168
+ case "invalid_token":
169
+ case "invalid_json":
170
+ case "unbound_origin_app":
171
+ case "invalid_app":
172
+ case "invalid_installation":
173
+ return error;
174
+ case "mismatch":
175
+ return "signature_mismatch";
176
+ default:
177
+ return error !== undefined && HOSTED_ADMISSION_INVALID_PAYLOAD_ERRORS.has(error)
178
+ ? "invalid_payload"
179
+ : "handler_rejected";
180
+ }
181
+ }
182
+ export function parseHostedAdmissionHandlerRejection(value) {
183
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
184
+ return undefined;
185
+ }
186
+ const body = value;
187
+ if (Object.keys(body).some(key => !HOSTED_ADMISSION_REJECTION_KEYS.has(key))) {
188
+ return undefined;
189
+ }
190
+ if (typeof body.reason !== "string" ||
191
+ !HOSTED_ADMISSION_REJECTION_REASON_SET.has(body.reason) ||
192
+ typeof body.status !== "number" ||
193
+ !Number.isInteger(body.status) ||
194
+ body.status < 400 ||
195
+ body.status > 499) {
196
+ return undefined;
197
+ }
198
+ return { reason: body.reason, status: body.status };
199
+ }
119
200
  /**
120
201
  * Cap on delivery IDs an owner execute may report as consumed (primary +
121
202
  * accepted active-guest enqueues). Enqueue requests beyond this return
@@ -513,7 +594,14 @@ export function parseHostedReminderFireDescriptorPayload(value) {
513
594
  }
514
595
  return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ protocolVersion: 1, id: body.id, fireCount: body.fireCount, generation: body.generation, purpose: body.purpose, channelId: body.channelId, continuationToken: body.continuationToken }, (target === undefined ? {} : { target })), { scheduleKind: body.scheduleKind, scheduleValue: body.scheduleValue }), (body.intervalMs === undefined ? {} : { intervalMs: body.intervalMs })), (body.prompt === undefined ? {} : { prompt: body.prompt })), (body.handler === undefined ? {} : { handler: body.handler })), (args === undefined ? {} : { args })), { hasRunHandler: body.hasRunHandler, hasUntilFn: body.hasUntilFn }), (body.untilPrompt === undefined ? {} : { untilPrompt: body.untilPrompt })), { busyPolicy: body.busyPolicy, nextFireAtMs: body.nextFireAtMs, claimedAtMs: body.claimedAtMs });
515
596
  }
516
- const HOSTED_ADMISSION_OUTCOME_KEYS = new Set(["ok", "v", "outcome", "admissionToken"]);
597
+ const HOSTED_ADMISSION_OUTCOME_KEYS = new Set([
598
+ "ok",
599
+ "v",
600
+ "outcome",
601
+ "admissionToken",
602
+ "rejection",
603
+ "engineVersion",
604
+ ]);
517
605
  export function parseHostedAdmissionOutcome(value) {
518
606
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
519
607
  return undefined;
@@ -535,5 +623,18 @@ export function parseHostedAdmissionOutcome(value) {
535
623
  if (body.outcome !== "send" && Object.hasOwn(body, "admissionToken")) {
536
624
  return undefined;
537
625
  }
626
+ if (Object.hasOwn(body, "rejection")) {
627
+ if (body.outcome !== "skip") {
628
+ return undefined;
629
+ }
630
+ const rejection = parseHostedAdmissionHandlerRejection(body.rejection);
631
+ if (rejection === undefined) {
632
+ return undefined;
633
+ }
634
+ body.rejection = rejection;
635
+ }
636
+ if (Object.hasOwn(body, "engineVersion") && !boundedString(body.engineVersion, 64)) {
637
+ return undefined;
638
+ }
538
639
  return body;
539
640
  }
@@ -1 +1 @@
1
- {"version":3,"file":"hosted-delivery.d.ts","sourceRoot":"","sources":["../../src/internal/hosted-delivery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,kBAAkB,EAAE,kBAAkB,EAAe,MAAM,aAAa,CAAC;AAEnG,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,kCAAkC,CAAC;AAO1C,OAAO,EAKL,KAAK,sBAAsB,EAG5B,MAAM,oBAAoB,CAAC;AAS5B,OAAO,EAQL,KAAK,oBAAoB,EAGzB,KAAK,mCAAmC,EAQzC,MAAM,+BAA+B,CAAC;AAmBvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAIlD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAErE,KAAK,aAAa,GAAG;IACnB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,kBAAkB,CAAC;CAC1B,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,sBAAsB,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B,CAAC;AA8JF;;;;;;;;;GASG;AACH,wBAAsB,uBAAuB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAU9F;AAmQD,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IACjD,MAAM,E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;IAC1C;;;OAGG;IACH,mBAAmB,CAAC,IAAI,OAAO,CAAC,sBAAsB,GAAG,OAAO,CAAC,CAAC;IAClE;;;;OAIG;IACH,mBAAmB,CAAC,IAAI,wBAAwB,CAAC;CAClD,GAAG,IAAI,CA+nBP"}
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { randomBytes } from "node:crypto";
11
+ import { packageVersion } from "./distribution.js";
11
12
  import { dispatchOutcome } from "./channel-dispatch.js";
12
13
  import { consumeHostedBoundSecrets, } from "./cursor/hosted-bound-secrets.js";
13
14
  import { createDeferredChannelSession, DeferredChannelSessionError, } from "./deferred-channel-session.js";
@@ -16,9 +17,9 @@ import { classifyExpectedDeliveryFailure } from "./expected-delivery-failure.js"
16
17
  import { formatGuestNetworkServerTiming, GUEST_CONNECT_STALLED, GUEST_NETWORK_UNAVAILABLE, GuestNetworkUnavailableError, waitForGuestNetworkReady, } from "./guest-network.js";
17
18
  import { getHostedAdmissionAdapter, } from "./hosted-admission-adapter.js";
18
19
  import { HostedAdmissionLocalSendError, runDuringHostedAdmission, } from "./hosted-admission-context.js";
19
- import { HOSTED_ADMISSION_PATH, HOSTED_DELIVERY_HEADER, HOSTED_DELIVERY_PROTOCOL_VERSION, HOSTED_EXECUTION_PATH, HOSTED_GUEST_RETRY_TERMINAL, HOSTED_GUEST_RETRY_TRANSIENT, HOSTED_MAX_CONSUMED_DELIVERY_IDS, hostedFailureClassification, hostedGuestErrorResponse, isHostedReminderAdmission, parseHostedAdmission, parseHostedExecution, parseHostedReminderFireDescriptorPayload, parseHostedReminderFirePayload, } from "./hosted-delivery-protocol.js";
20
+ import { HOSTED_ADMISSION_PATH, HOSTED_DELIVERY_HEADER, HOSTED_DELIVERY_PROTOCOL_VERSION, HOSTED_EXECUTION_PATH, HOSTED_GUEST_RETRY_TERMINAL, HOSTED_GUEST_RETRY_TRANSIENT, HOSTED_MAX_CONSUMED_DELIVERY_IDS, hostedFailureClassification, hostedGuestErrorResponse, isHostedReminderAdmission, parseHostedAdmissionHandlerRejection, parseHostedAdmission, parseHostedExecution, parseHostedReminderFireDescriptorPayload, parseHostedReminderFirePayload, } from "./hosted-delivery-protocol.js";
20
21
  import { abortReasonFromTurnStatus, HOSTED_EXECUTION_DIAG_RUNNING_STATUS, hostedExecutionDiagId, } from "./hosted-execution-diag.js";
21
- import { flushHostedExecutionRecord, } from "./hosted-execution-flush.js";
22
+ import { flushHostedExecutionRecord, refreshStartLogWhile, } from "./hosted-execution-flush.js";
22
23
  import { finalizeHostedExecutionLatency, formatHostedExecutionLatencyServerTiming, hostedExecutionNow, runWithHostedExecutionLatency, } from "./hosted-execution-latency.js";
23
24
  import { recordHostedManagedAutomation } from "./hosted-managed-automation.js";
24
25
  import { readJsonObject } from "./http-channel.js";
@@ -309,15 +310,34 @@ function runAdmission(input, adapter) {
309
310
  response: terminalHostedError(502, "channel_outcome_missing"),
310
311
  };
311
312
  }
313
+ const rejection = outcome === "skip" ? yield handlerRejection(dispatched) : undefined;
312
314
  return {
313
- response: Response.json({
314
- ok: true,
315
- v: HOSTED_DELIVERY_PROTOCOL_VERSION,
316
- outcome,
317
- }),
315
+ response: Response.json(Object.assign({ ok: true, v: HOSTED_DELIVERY_PROTOCOL_VERSION, outcome }, (rejection === undefined ? {} : { rejection, engineVersion: packageVersion() }))),
318
316
  };
319
317
  });
320
318
  }
319
+ /** Handler 4xx on a skip. Benign skips (nothing to do) have no status. */
320
+ function handlerRejection(response) {
321
+ return __awaiter(this, void 0, void 0, function* () {
322
+ try {
323
+ const body = (yield response.clone().json());
324
+ if (typeof body !== "object" || body === null || Array.isArray(body)) {
325
+ return undefined;
326
+ }
327
+ const record = body;
328
+ if (record.skipped !== true) {
329
+ return undefined;
330
+ }
331
+ return parseHostedAdmissionHandlerRejection({
332
+ reason: record.reason,
333
+ status: record.status,
334
+ });
335
+ }
336
+ catch (_a) {
337
+ return undefined;
338
+ }
339
+ });
340
+ }
321
341
  function withServerTiming(response, durationMs, guestNetwork, latency) {
322
342
  const parts = [`agent_sdk;desc="hosted";dur=${Math.max(0, durationMs).toFixed(1)}`];
323
343
  if (guestNetwork !== undefined) {
@@ -368,7 +388,7 @@ function logGuestNetworkWait(phase, stats) {
368
388
  if (stats.outcome === "skipped") {
369
389
  return;
370
390
  }
371
- console.info(`[agent-sdk] guest network ${stats.outcome} phase=${phase} waitMs=${String(stats.waitMs)} probes=${String(stats.probeAttempts)}`);
391
+ console.info(`[bdk] guest network ${stats.outcome} phase=${phase} waitMs=${String(stats.waitMs)} probes=${String(stats.probeAttempts)}`);
372
392
  }
373
393
  export function registerHostedDeliveryRoute(input) {
374
394
  var _a, _b;
@@ -502,7 +522,7 @@ export function registerHostedDeliveryRoute(input) {
502
522
  !Array.isArray(rawAdmission)
503
523
  ? Object.keys(rawAdmission)
504
524
  : [];
505
- console.info(`[agent-sdk] hosted admission rejected: envelope failed to parse keys=${JSON.stringify(rawKeys)} hasManagedAutomation=${String(rawKeys.includes("managedAutomation"))}`);
525
+ console.info(`[bdk] hosted admission rejected: envelope failed to parse keys=${JSON.stringify(rawKeys)} hasManagedAutomation=${String(rawKeys.includes("managedAutomation"))}`);
506
526
  return finish(terminalHostedError(400, "invalid_hosted_admission", "Expected a supported Agent SDK hosted-admission envelope."));
507
527
  }
508
528
  pruneExpired();
@@ -533,7 +553,7 @@ export function registerHostedDeliveryRoute(input) {
533
553
  : responseFromReply(existing.settledReply);
534
554
  }
535
555
  }
536
- console.info(`[agent-sdk] hosted admission received deliveryId=${delivery.deliveryId} channelId=${delivery.channelId} channelKind=${delivery.channelKind} eventType=${delivery.eventType} sessionMode=${delivery.sessionMode} managedAutomation=${delivery.managedAutomation === undefined ? "<absent>" : `automationUuid=${delivery.managedAutomation.automationUuid} mcpServerNames=${String(delivery.managedAutomation.mcpServerNames.length)} slackChannels=${delivery.managedAutomation.slackChannels === undefined ? "<absent>" : JSON.stringify(delivery.managedAutomation.slackChannels)}`}`);
556
+ console.info(`[bdk] hosted admission received deliveryId=${delivery.deliveryId} channelId=${delivery.channelId} channelKind=${delivery.channelKind} eventType=${delivery.eventType} sessionMode=${delivery.sessionMode} managedAutomation=${delivery.managedAutomation === undefined ? "<absent>" : `automationUuid=${delivery.managedAutomation.automationUuid} mcpServerNames=${String(delivery.managedAutomation.mcpServerNames.length)} slackChannels=${delivery.managedAutomation.slackChannels === undefined ? "<absent>" : JSON.stringify(delivery.managedAutomation.slackChannels)}`}`);
537
557
  recordHostedManagedAutomation(delivery);
538
558
  const reminder = isHostedReminderAdmission(delivery);
539
559
  const definition = reminder
@@ -693,7 +713,7 @@ export function registerHostedDeliveryRoute(input) {
693
713
  sessionId,
694
714
  turnStatus: HOSTED_EXECUTION_DIAG_RUNNING_STATUS,
695
715
  });
696
- const outcome = yield session.waitForCompletion();
716
+ const outcome = yield refreshStartLogWhile(sinks, execution.sessionPublicId, () => session.waitForCompletion());
697
717
  completionAt = hostedExecutionNow();
698
718
  // Status is the owner turn. waitForCompletion still waited
699
719
  // for any drained successor so this process is not parked
@@ -856,7 +876,7 @@ function enqueueIntoActiveOwner(input) {
856
876
  }
857
877
  resolveResult({ outcome: "not_active" });
858
878
  if (!(error instanceof HostedEnqueueNotActiveError)) {
859
- console.warn(`[agent-sdk] hosted enqueue inject failed deliveryId=${input.deliveryId}: ${error instanceof Error ? error.message : String(error)}`);
879
+ console.warn(`[bdk] hosted enqueue inject failed deliveryId=${input.deliveryId}: ${error instanceof Error ? error.message : String(error)}`);
860
880
  }
861
881
  }
862
882
  }))();
@@ -1,31 +1,24 @@
1
1
  /**
2
- * Guest-local TAS diag (`hosted-execution.json`). Flushed with the durable
3
- * session-run document and the `start.log` tee by
4
- * `hosted-execution-flush.ts`.
2
+ * Local diagnostic record for one hosted execution. Flushed with durable
3
+ * execution history and process output.
5
4
  */
6
5
  import { type HostedFailureClassification } from "./hosted-delivery-protocol.js";
7
6
  export declare const HOSTED_EXECUTION_DIAG_VERSION = 1;
8
7
  /** Cap so a runaway message cannot fill the guest disk or the host log. */
9
8
  export declare const HOSTED_EXECUTION_DIAG_MAX_BYTES = 4096;
10
9
  /**
11
- * Correlate the on-disk record with the execution that produced it. One pod
12
- * serves many deliveries of a continuation session, and the file lives at a
13
- * single fixed path, so without this the host can read a *previous*
14
- * delivery's terminal record whenever July never reaches its own write —
15
- * the 9-minute host POST timeout, a 409 on an expired admission token, or a
16
- * replayed token that short-circuits on the memoized reply.
10
+ * Correlate the fixed-path record with the execution that produced it. An
11
+ * interrupted attempt can otherwise leave the previous execution's terminal
12
+ * record behind.
17
13
  *
18
- * Derived from the admission token (which both sides already hold) rather
19
- * than carried on the wire. The digest is one-way, so the token itself never
20
- * reaches the guest disk or the host logs.
14
+ * Derive the id from the admission token. The one-way digest prevents the
15
+ * token itself from reaching disk or logs.
21
16
  */
22
17
  export declare function hostedExecutionDiagId(admissionToken: string): string;
23
18
  export type HostedExecutionDiagAbortReason = "signal_abort" | "runner_cancelled" | "runner_error" | "execute_throw";
24
19
  /**
25
- * Bounded guest-side record of one hosted-execution attempt. No prompt,
26
- * tool content, or API key — the host copies known keys onto the Temporal
27
- * activity span for Datadog. `errorCode` and `message` are logged ungated;
28
- * `stack` stays behind the internal-diag gate.
20
+ * Bounded record of one hosted execution. It omits prompts, tool content, and
21
+ * credentials. Stack details remain behind the diagnostic gate.
29
22
  */
30
23
  export type HostedExecutionDiag = {
31
24
  v: typeof HOSTED_EXECUTION_DIAG_VERSION;
@@ -50,19 +43,15 @@ export type HostedExecutionDiag = {
50
43
  };
51
44
  /** Written before the turn starts so a stalled execution still has a record. */
52
45
  export declare const HOSTED_EXECUTION_DIAG_RUNNING_STATUS = "running";
53
- /** First line + frames; factory `last_error` is 1024 chars with a TAS prefix. */
46
+ /** Bounds for a short error stack summary. */
54
47
  export declare const HOSTED_ERROR_STACK_LINE_COUNT = 5;
55
48
  export declare const HOSTED_ERROR_SNIPPET_MAX_CHARS = 700;
56
49
  /**
57
- * Bounded throw text for on-disk diag `stack` (and non-hosted 500 bodies).
58
- * Prefers `Error.stack` (message line + `at` frames). Hosted HTTP `message`
59
- * uses {@link hostedErrorMessageOnly} so customer Datadog stays frame-free.
50
+ * Bounded throw text for diagnostics and non-hosted 500 bodies. Prefers
51
+ * `Error.stack` with its message and first frames.
60
52
  */
61
53
  export declare function hostedErrorStackSnippet(error: unknown): string;
62
- /**
63
- * Guest throw text without `at` frames. Hosted 500 `message` is ungated on
64
- * TAS (`hostedGuestMessage` / `last_error`); stack frames stay on `stack`.
65
- */
54
+ /** Hosted response text without stack frames. */
66
55
  export declare function hostedErrorMessageOnly(error: unknown): string;
67
56
  export declare function hostedExecutionDiagPath(stateRoot: string): string;
68
57
  export declare function abortReasonFromTurnStatus(status: string, cancellationReason: "signal" | "runner" | undefined): HostedExecutionDiagAbortReason | undefined;