@cursor/july 0.1.100 → 0.1.102

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 (484) hide show
  1. package/README.md +27 -0
  2. package/dist/bin/agent-serve.js +3 -2
  3. package/dist/channels/deployments/deployments-channel.d.ts +41 -5
  4. package/dist/channels/deployments/deployments-channel.d.ts.map +1 -1
  5. package/dist/channels/deployments/deployments-channel.js +88 -8
  6. package/dist/channels/deployments/types.d.ts +4 -3
  7. package/dist/channels/deployments/types.d.ts.map +1 -1
  8. package/dist/channels/origin/defaults.d.ts +43 -0
  9. package/dist/channels/origin/defaults.d.ts.map +1 -0
  10. package/dist/channels/origin/defaults.js +111 -0
  11. package/dist/channels/origin/index.d.ts +2 -0
  12. package/dist/channels/origin/index.d.ts.map +1 -1
  13. package/dist/channels/origin/index.js +2 -0
  14. package/dist/channels/origin/origin-channel.d.ts +2 -1
  15. package/dist/channels/origin/origin-channel.d.ts.map +1 -1
  16. package/dist/channels/origin/origin-channel.js +24 -3
  17. package/dist/channels/origin/state.d.ts +32 -0
  18. package/dist/channels/origin/state.d.ts.map +1 -0
  19. package/dist/channels/origin/state.js +23 -0
  20. package/dist/channels/origin/types.d.ts +23 -1
  21. package/dist/channels/origin/types.d.ts.map +1 -1
  22. package/dist/channels/slack/api.d.ts +1 -1
  23. package/dist/channels/slack/api.d.ts.map +1 -1
  24. package/dist/channels/slack/api.js +5 -2
  25. package/dist/channels/slack/assistant.d.ts +1 -1
  26. package/dist/channels/slack/assistant.d.ts.map +1 -1
  27. package/dist/channels/slack/code-fences.d.ts +17 -0
  28. package/dist/channels/slack/code-fences.d.ts.map +1 -0
  29. package/dist/channels/slack/code-fences.js +168 -0
  30. package/dist/channels/slack/dispatch.d.ts +3 -2
  31. package/dist/channels/slack/dispatch.d.ts.map +1 -1
  32. package/dist/channels/slack/dispatch.js +28 -8
  33. package/dist/channels/slack/inbound.d.ts +8 -0
  34. package/dist/channels/slack/inbound.d.ts.map +1 -1
  35. package/dist/channels/slack/inbound.js +28 -0
  36. package/dist/channels/slack/index.d.ts +1 -0
  37. package/dist/channels/slack/index.d.ts.map +1 -1
  38. package/dist/channels/slack/index.js +1 -0
  39. package/dist/channels/slack/live-delivery.d.ts.map +1 -1
  40. package/dist/channels/slack/live-delivery.js +11 -4
  41. package/dist/channels/slack/manifest.d.ts.map +1 -1
  42. package/dist/channels/slack/manifest.js +2 -1
  43. package/dist/connections.d.ts +18 -2
  44. package/dist/connections.d.ts.map +1 -1
  45. package/dist/connections.js +18 -2
  46. package/dist/docs/404.html +2 -2
  47. package/dist/docs/ab.html +4 -4
  48. package/dist/docs/assets/{app.DZ1e0Ycq.js → app.CLA03RCz.js} +1 -1
  49. package/dist/docs/assets/chunks/@localSearchIndexroot.FAqdWIXo.js +1 -0
  50. package/dist/docs/assets/chunks/{VPLocalSearchBox.l8omwc6D.js → VPLocalSearchBox.ifxv-cJV.js} +1 -1
  51. package/dist/docs/assets/chunks/{theme.JVcD6gel.js → theme.DWCwM6p-.js} +2 -2
  52. package/dist/docs/assets/concepts.md.rPzW2HZN.js +1 -0
  53. package/dist/docs/assets/guides_cloud-agents.md.DumwWXba.js +9 -0
  54. package/dist/docs/assets/guides_cloud-agents.md.DumwWXba.lean.js +1 -0
  55. package/dist/docs/assets/{guides_cloud-runtime.md.CkYbjnAX.js → guides_cloud-runtime.md.BRirbRAN.js} +1 -1
  56. package/dist/docs/assets/index.md.Kiht7ell.js +5 -0
  57. package/dist/docs/assets/{index.md.Bb4k8kUm.lean.js → index.md.Kiht7ell.lean.js} +1 -1
  58. package/dist/docs/assets/{reference_connections.md.BiGoBAk2.js → reference_connections.md.Di6jJAXF.js} +12 -2
  59. package/dist/docs/assets/{reference_connections.md.BiGoBAk2.lean.js → reference_connections.md.Di6jJAXF.lean.js} +1 -1
  60. package/dist/docs/assets/reference_extensions.md.9WQMZe1l.js +56 -0
  61. package/dist/docs/assets/reference_extensions.md.9WQMZe1l.lean.js +1 -0
  62. package/dist/docs/assets/{reference_http-api.md.BEJx9XVj.js → reference_http-api.md.oySXBO8o.js} +1 -1
  63. package/dist/docs/assets/{reference_project-layout.md.Bv4KOtlB.js → reference_project-layout.md.CA6QP6Lw.js} +2 -2
  64. package/dist/docs/assets/{reference_project-layout.md.Bv4KOtlB.lean.js → reference_project-layout.md.CA6QP6Lw.lean.js} +1 -1
  65. package/dist/docs/assets/{reference_skills.md.BFW9retM.js → reference_skills.md.l2ezAcaN.js} +1 -1
  66. package/dist/docs/assets/{reference_tools.md.CvAHsdSp.js → reference_tools.md.B1up2r9W.js} +1 -1
  67. package/dist/docs/assets/skills_framework-map.md.DDa4MeEW.js +1 -0
  68. package/dist/docs/assets/{skills_framework-map.md.BTi817yv.lean.js → skills_framework-map.md.DDa4MeEW.lean.js} +1 -1
  69. package/dist/docs/building-with-agents.html +4 -4
  70. package/dist/docs/concepts.html +5 -5
  71. package/dist/docs/concepts.md +3 -3
  72. package/dist/docs/deployment.html +4 -4
  73. package/dist/docs/evals.html +4 -4
  74. package/dist/docs/guides/agent-to-agent.html +4 -4
  75. package/dist/docs/guides/cloud-agents.html +35 -0
  76. package/dist/docs/guides/cloud-agents.md +93 -0
  77. package/dist/docs/guides/cloud-runtime.html +6 -6
  78. package/dist/docs/guides/cloud-runtime.md +2 -0
  79. package/dist/docs/guides/convert-automation.html +4 -4
  80. package/dist/docs/guides/github.html +4 -4
  81. package/dist/docs/guides/human-in-the-loop.html +4 -4
  82. package/dist/docs/guides/mcp-oauth.html +4 -4
  83. package/dist/docs/guides/opentelemetry.html +5 -5
  84. package/dist/docs/guides/slack.html +4 -4
  85. package/dist/docs/guides/webhooks.html +4 -4
  86. package/dist/docs/hashmap.json +1 -1
  87. package/dist/docs/hillclimbing.html +4 -4
  88. package/dist/docs/index.html +6 -6
  89. package/dist/docs/index.md +5 -1
  90. package/dist/docs/llms-full.txt +353 -5
  91. package/dist/docs/llms.txt +2 -0
  92. package/dist/docs/quickstart.html +4 -4
  93. package/dist/docs/reference/agent-config.html +4 -4
  94. package/dist/docs/reference/artifacts.html +4 -4
  95. package/dist/docs/reference/channels.html +5 -5
  96. package/dist/docs/reference/cli.html +4 -4
  97. package/dist/docs/reference/connections.html +16 -6
  98. package/dist/docs/reference/connections.md +31 -0
  99. package/dist/docs/reference/extensions.html +82 -0
  100. package/dist/docs/reference/extensions.md +200 -0
  101. package/dist/docs/reference/hooks.html +4 -4
  102. package/dist/docs/reference/http-api.html +6 -6
  103. package/dist/docs/reference/http-api.md +1 -1
  104. package/dist/docs/reference/instructions.html +4 -4
  105. package/dist/docs/reference/playground.html +4 -4
  106. package/dist/docs/reference/project-layout.html +6 -6
  107. package/dist/docs/reference/project-layout.md +3 -0
  108. package/dist/docs/reference/prompt.html +4 -4
  109. package/dist/docs/reference/schedules.html +4 -4
  110. package/dist/docs/reference/sessions.html +4 -4
  111. package/dist/docs/reference/skills.html +6 -6
  112. package/dist/docs/reference/skills.md +2 -0
  113. package/dist/docs/reference/subagents.html +5 -5
  114. package/dist/docs/reference/tools.html +6 -6
  115. package/dist/docs/reference/tools.md +2 -0
  116. package/dist/docs/scaffolding-agents.html +4 -4
  117. package/dist/docs/skills/ab.html +4 -4
  118. package/dist/docs/skills/create-agent.html +4 -4
  119. package/dist/docs/skills/debug.html +4 -4
  120. package/dist/docs/skills/evals.html +4 -4
  121. package/dist/docs/skills/framework-map.html +5 -5
  122. package/dist/docs/skills/framework-map.md +1 -0
  123. package/dist/docs/skills/github.html +4 -4
  124. package/dist/docs/skills/hillclimb.html +4 -4
  125. package/dist/docs/skills/index.html +4 -4
  126. package/dist/docs/skills/mcp-auth.html +4 -4
  127. package/dist/docs/skills/otel.html +4 -4
  128. package/dist/docs/skills/setup-slack.html +4 -4
  129. package/dist/docs/storage.html +4 -4
  130. package/dist/docs/templates/agentic-owners.html +4 -4
  131. package/dist/docs/templates/agents-md.html +4 -4
  132. package/dist/docs/templates/code-wiki.html +4 -4
  133. package/dist/docs/templates/demo.html +4 -4
  134. package/dist/docs/templates/pr-autofixer.html +4 -4
  135. package/dist/docs/templates/security-help.html +4 -4
  136. package/dist/docs/templates/security-reviewer.html +4 -4
  137. package/dist/docs/templates/triage.html +4 -4
  138. package/dist/docs/troubleshooting.html +4 -4
  139. package/dist/extensions/cursor-cloud-agents/extension.d.ts +57 -0
  140. package/dist/extensions/cursor-cloud-agents/extension.d.ts.map +1 -0
  141. package/dist/extensions/cursor-cloud-agents/extension.js +66 -0
  142. package/dist/extensions/cursor-cloud-agents/lib/backend.d.ts +78 -0
  143. package/dist/extensions/cursor-cloud-agents/lib/backend.d.ts.map +1 -0
  144. package/dist/extensions/cursor-cloud-agents/lib/backend.js +286 -0
  145. package/dist/extensions/cursor-cloud-agents/lib/fleet.d.ts +25 -0
  146. package/dist/extensions/cursor-cloud-agents/lib/fleet.d.ts.map +1 -0
  147. package/dist/extensions/cursor-cloud-agents/lib/fleet.js +85 -0
  148. package/dist/extensions/cursor-cloud-agents/lib/inputs.d.ts +5 -0
  149. package/dist/extensions/cursor-cloud-agents/lib/inputs.d.ts.map +1 -0
  150. package/dist/extensions/cursor-cloud-agents/lib/inputs.js +4 -0
  151. package/dist/extensions/cursor-cloud-agents/lib/repos.d.ts +15 -0
  152. package/dist/extensions/cursor-cloud-agents/lib/repos.d.ts.map +1 -0
  153. package/dist/extensions/cursor-cloud-agents/lib/repos.js +55 -0
  154. package/dist/extensions/cursor-cloud-agents/lib/transcript.d.ts +8 -0
  155. package/dist/extensions/cursor-cloud-agents/lib/transcript.d.ts.map +1 -0
  156. package/dist/extensions/cursor-cloud-agents/lib/transcript.js +15 -0
  157. package/dist/extensions/cursor-cloud-agents/skills/handoff.md +41 -0
  158. package/dist/extensions/cursor-cloud-agents/tools/cancel.d.ts +4 -0
  159. package/dist/extensions/cursor-cloud-agents/tools/cancel.d.ts.map +1 -0
  160. package/dist/extensions/cursor-cloud-agents/tools/cancel.js +26 -0
  161. package/dist/extensions/cursor-cloud-agents/tools/dump.d.ts +4 -0
  162. package/dist/extensions/cursor-cloud-agents/tools/dump.d.ts.map +1 -0
  163. package/dist/extensions/cursor-cloud-agents/tools/dump.js +54 -0
  164. package/dist/extensions/cursor-cloud-agents/tools/get.d.ts +4 -0
  165. package/dist/extensions/cursor-cloud-agents/tools/get.d.ts.map +1 -0
  166. package/dist/extensions/cursor-cloud-agents/tools/get.js +25 -0
  167. package/dist/extensions/cursor-cloud-agents/tools/launch.d.ts +4 -0
  168. package/dist/extensions/cursor-cloud-agents/tools/launch.d.ts.map +1 -0
  169. package/dist/extensions/cursor-cloud-agents/tools/launch.js +59 -0
  170. package/dist/extensions/cursor-cloud-agents/tools/list.d.ts +4 -0
  171. package/dist/extensions/cursor-cloud-agents/tools/list.d.ts.map +1 -0
  172. package/dist/extensions/cursor-cloud-agents/tools/list.js +36 -0
  173. package/dist/extensions/cursor-cloud-agents/tools/reply.d.ts +4 -0
  174. package/dist/extensions/cursor-cloud-agents/tools/reply.d.ts.map +1 -0
  175. package/dist/extensions/cursor-cloud-agents/tools/reply.js +35 -0
  176. package/dist/extensions.d.ts +73 -0
  177. package/dist/extensions.d.ts.map +1 -0
  178. package/dist/extensions.js +112 -0
  179. package/dist/files-backends/cursor-hosted.d.ts +0 -8
  180. package/dist/files-backends/cursor-hosted.d.ts.map +1 -1
  181. package/dist/files-backends/cursor-hosted.js +1 -11
  182. package/dist/files.d.ts +5 -1
  183. package/dist/files.d.ts.map +1 -1
  184. package/dist/files.js +22 -18
  185. package/dist/index.d.ts +4 -3
  186. package/dist/index.d.ts.map +1 -1
  187. package/dist/index.js +3 -2
  188. package/dist/internal/advertise-tools.d.ts +4 -1
  189. package/dist/internal/advertise-tools.d.ts.map +1 -1
  190. package/dist/internal/advertise-tools.js +20 -1
  191. package/dist/internal/as-of.d.ts +18 -0
  192. package/dist/internal/as-of.d.ts.map +1 -1
  193. package/dist/internal/as-of.js +131 -0
  194. package/dist/internal/cli-deploy.d.ts.map +1 -1
  195. package/dist/internal/cli-deploy.js +64 -19
  196. package/dist/internal/continuation-identity.d.ts.map +1 -1
  197. package/dist/internal/continuation-identity.js +3 -1
  198. package/dist/internal/conversation-mirror.d.ts.map +1 -1
  199. package/dist/internal/conversation-mirror.js +13 -15
  200. package/dist/internal/cursor/backend-client.d.ts +8 -1
  201. package/dist/internal/cursor/backend-client.d.ts.map +1 -1
  202. package/dist/internal/cursor/backend-client.js +25 -9
  203. package/dist/internal/cursor/hosted-deployment-secrets.d.ts +16 -0
  204. package/dist/internal/cursor/hosted-deployment-secrets.d.ts.map +1 -0
  205. package/dist/internal/cursor/hosted-deployment-secrets.js +61 -0
  206. package/dist/internal/cursor/hosted-store-secrets.d.ts +11 -0
  207. package/dist/internal/cursor/hosted-store-secrets.d.ts.map +1 -1
  208. package/dist/internal/cursor/hosted-store-secrets.js +15 -0
  209. package/dist/internal/cursor-deployment-relay.d.ts +15 -1
  210. package/dist/internal/cursor-deployment-relay.d.ts.map +1 -1
  211. package/dist/internal/cursor-deployment-relay.js +46 -7
  212. package/dist/internal/deploy-client.d.ts +23 -0
  213. package/dist/internal/deploy-client.d.ts.map +1 -1
  214. package/dist/internal/deploy-client.js +54 -12
  215. package/dist/internal/discovery/ab.d.ts +9 -0
  216. package/dist/internal/discovery/ab.d.ts.map +1 -0
  217. package/dist/internal/discovery/ab.js +101 -0
  218. package/dist/internal/discovery/agent-config.d.ts +35 -0
  219. package/dist/internal/discovery/agent-config.d.ts.map +1 -0
  220. package/dist/internal/discovery/agent-config.js +173 -0
  221. package/dist/internal/discovery/agent.d.ts +11 -0
  222. package/dist/internal/discovery/agent.d.ts.map +1 -0
  223. package/dist/internal/discovery/agent.js +306 -0
  224. package/dist/internal/discovery/channels.d.ts +10 -0
  225. package/dist/internal/discovery/channels.d.ts.map +1 -0
  226. package/dist/internal/discovery/channels.js +97 -0
  227. package/dist/internal/discovery/connections.d.ts +17 -0
  228. package/dist/internal/discovery/connections.d.ts.map +1 -0
  229. package/dist/internal/discovery/connections.js +436 -0
  230. package/dist/internal/discovery/context.d.ts +20 -0
  231. package/dist/internal/discovery/context.d.ts.map +1 -0
  232. package/dist/internal/discovery/context.js +30 -0
  233. package/dist/internal/discovery/cursor-plugin.d.ts +25 -0
  234. package/dist/internal/discovery/cursor-plugin.d.ts.map +1 -0
  235. package/dist/internal/discovery/cursor-plugin.js +570 -0
  236. package/dist/internal/discovery/extensions.d.ts +19 -0
  237. package/dist/internal/discovery/extensions.d.ts.map +1 -0
  238. package/dist/internal/discovery/extensions.js +238 -0
  239. package/dist/internal/discovery/fs.d.ts +15 -0
  240. package/dist/internal/discovery/fs.d.ts.map +1 -0
  241. package/dist/internal/discovery/fs.js +115 -0
  242. package/dist/internal/discovery/hooks.d.ts +7 -0
  243. package/dist/internal/discovery/hooks.d.ts.map +1 -0
  244. package/dist/internal/discovery/hooks.js +48 -0
  245. package/dist/internal/discovery/info.d.ts +6 -0
  246. package/dist/internal/discovery/info.d.ts.map +1 -0
  247. package/dist/internal/discovery/info.js +141 -0
  248. package/dist/internal/discovery/instructions.d.ts +7 -0
  249. package/dist/internal/discovery/instructions.d.ts.map +1 -0
  250. package/dist/internal/discovery/instructions.js +95 -0
  251. package/dist/internal/discovery/modules.d.ts +20 -0
  252. package/dist/internal/discovery/modules.d.ts.map +1 -0
  253. package/dist/internal/discovery/modules.js +101 -0
  254. package/dist/internal/discovery/names.d.ts +12 -0
  255. package/dist/internal/discovery/names.d.ts.map +1 -0
  256. package/dist/internal/discovery/names.js +36 -0
  257. package/dist/internal/discovery/project.d.ts +53 -0
  258. package/dist/internal/discovery/project.d.ts.map +1 -0
  259. package/dist/internal/discovery/project.js +239 -0
  260. package/dist/internal/discovery/runtime.d.ts +34 -0
  261. package/dist/internal/discovery/runtime.d.ts.map +1 -0
  262. package/dist/internal/discovery/runtime.js +98 -0
  263. package/dist/internal/discovery/schedules.d.ts +7 -0
  264. package/dist/internal/discovery/schedules.d.ts.map +1 -0
  265. package/dist/internal/discovery/schedules.js +97 -0
  266. package/dist/internal/discovery/seed-files.d.ts +7 -0
  267. package/dist/internal/discovery/seed-files.d.ts.map +1 -0
  268. package/dist/internal/discovery/seed-files.js +41 -0
  269. package/dist/internal/discovery/services.d.ts +17 -0
  270. package/dist/internal/discovery/services.d.ts.map +1 -0
  271. package/dist/internal/discovery/services.js +104 -0
  272. package/dist/internal/discovery/skills.d.ts +16 -0
  273. package/dist/internal/discovery/skills.d.ts.map +1 -0
  274. package/dist/internal/discovery/skills.js +151 -0
  275. package/dist/internal/discovery/subagent.d.ts +13 -0
  276. package/dist/internal/discovery/subagent.d.ts.map +1 -0
  277. package/dist/internal/discovery/subagent.js +19 -0
  278. package/dist/internal/discovery/tools.d.ts +18 -0
  279. package/dist/internal/discovery/tools.d.ts.map +1 -0
  280. package/dist/internal/discovery/tools.js +159 -0
  281. package/dist/internal/discovery.d.ts +8 -62
  282. package/dist/internal/discovery.d.ts.map +1 -1
  283. package/dist/internal/discovery.js +8 -2210
  284. package/dist/internal/distribution.d.ts.map +1 -1
  285. package/dist/internal/distribution.js +5 -0
  286. package/dist/internal/framework-file-storage.d.ts +3 -3
  287. package/dist/internal/framework-file-storage.d.ts.map +1 -1
  288. package/dist/internal/framework-file-storage.js +38 -9
  289. package/dist/internal/framework-storage-selection.d.ts.map +1 -1
  290. package/dist/internal/framework-storage-selection.js +8 -7
  291. package/dist/internal/frontmatter.d.ts +11 -3
  292. package/dist/internal/frontmatter.d.ts.map +1 -1
  293. package/dist/internal/frontmatter.js +29 -3
  294. package/dist/internal/hosted-delivery.d.ts +3 -1
  295. package/dist/internal/hosted-delivery.d.ts.map +1 -1
  296. package/dist/internal/hosted-delivery.js +19 -32
  297. package/dist/internal/hosted-execution-diag.d.ts +5 -0
  298. package/dist/internal/hosted-execution-diag.d.ts.map +1 -1
  299. package/dist/internal/hosted-execution-diag.js +5 -0
  300. package/dist/internal/hosted-execution-flush.d.ts +46 -0
  301. package/dist/internal/hosted-execution-flush.d.ts.map +1 -0
  302. package/dist/internal/hosted-execution-flush.js +81 -0
  303. package/dist/internal/mcp-endpoint.js +1 -0
  304. package/dist/internal/mcp-host.d.ts +2 -1
  305. package/dist/internal/mcp-host.d.ts.map +1 -1
  306. package/dist/internal/mcp-host.js +66 -29
  307. package/dist/internal/otel/collector.d.ts +13 -0
  308. package/dist/internal/otel/collector.d.ts.map +1 -1
  309. package/dist/internal/otel/collector.js +84 -17
  310. package/dist/internal/otel/http.d.ts.map +1 -1
  311. package/dist/internal/otel/http.js +2 -10
  312. package/dist/internal/otel/mcp.d.ts +16 -0
  313. package/dist/internal/otel/mcp.d.ts.map +1 -0
  314. package/dist/internal/otel/mcp.js +68 -0
  315. package/dist/internal/otel/propagation.d.ts +6 -0
  316. package/dist/internal/otel/propagation.d.ts.map +1 -0
  317. package/dist/internal/otel/propagation.js +14 -0
  318. package/dist/internal/otel/runtime.d.ts.map +1 -1
  319. package/dist/internal/otel/runtime.js +2 -0
  320. package/dist/internal/review-comments.d.ts +1 -1
  321. package/dist/internal/review-comments.d.ts.map +1 -1
  322. package/dist/internal/review-comments.js +4 -4
  323. package/dist/internal/server.d.ts +3 -0
  324. package/dist/internal/server.d.ts.map +1 -1
  325. package/dist/internal/server.js +79 -104
  326. package/dist/internal/session-engine.d.ts +14 -7
  327. package/dist/internal/session-engine.d.ts.map +1 -1
  328. package/dist/internal/session-engine.js +113 -66
  329. package/dist/internal/session-run-log.d.ts +3 -1
  330. package/dist/internal/session-run-log.d.ts.map +1 -1
  331. package/dist/internal/session-run-log.js +14 -14
  332. package/dist/internal/start-log-store.d.ts +60 -0
  333. package/dist/internal/start-log-store.d.ts.map +1 -0
  334. package/dist/internal/start-log-store.js +149 -0
  335. package/dist/internal/storage-coordinator.d.ts +4 -1
  336. package/dist/internal/storage-coordinator.d.ts.map +1 -1
  337. package/dist/internal/storage-coordinator.js +15 -13
  338. package/dist/internal/tool-catalog.d.ts.map +1 -1
  339. package/dist/internal/tool-catalog.js +9 -6
  340. package/dist/internal/tool-policy.d.ts +8 -0
  341. package/dist/internal/tool-policy.d.ts.map +1 -1
  342. package/dist/internal/tool-policy.js +19 -7
  343. package/dist/internal/turn-cost.d.ts +14 -0
  344. package/dist/internal/turn-cost.d.ts.map +1 -1
  345. package/dist/internal/turn-cost.js +41 -9
  346. package/dist/internal/v2-hosting.d.ts +22 -0
  347. package/dist/internal/v2-hosting.d.ts.map +1 -0
  348. package/dist/internal/v2-hosting.js +23 -0
  349. package/dist/otel.d.ts +16 -0
  350. package/dist/otel.d.ts.map +1 -1
  351. package/dist/otel.js +26 -0
  352. package/dist/playground/assets/index-B6C9S9nG.css +1 -0
  353. package/dist/playground/assets/{index-DVs98vPL.js → index-ZqNoT8Ie.js} +45 -45
  354. package/dist/playground/index.html +2 -2
  355. package/dist/storage-protocol.d.ts +47 -22
  356. package/dist/storage-protocol.d.ts.map +1 -1
  357. package/dist/storage-protocol.js +90 -54
  358. package/dist/storage.d.ts +2 -2
  359. package/dist/storage.d.ts.map +1 -1
  360. package/dist/storage.js +1 -1
  361. package/dist/tools.d.ts +9 -0
  362. package/dist/tools.d.ts.map +1 -1
  363. package/dist/tools.js +9 -0
  364. package/dist/types.d.ts +154 -6
  365. package/dist/types.d.ts.map +1 -1
  366. package/dist/types.js +29 -1
  367. package/docs/README.md +5 -1
  368. package/docs/concepts.md +3 -3
  369. package/docs/guides/cloud-agents.md +98 -0
  370. package/docs/guides/cloud-runtime.md +2 -0
  371. package/docs/reference/connections.md +31 -0
  372. package/docs/reference/extensions.md +205 -0
  373. package/docs/reference/http-api.md +1 -1
  374. package/docs/reference/project-layout.md +3 -0
  375. package/docs/reference/skills.md +2 -0
  376. package/docs/reference/tools.md +2 -0
  377. package/package.json +18 -4
  378. package/skills/framework-map/SKILL.md +1 -0
  379. package/src/bin/agent-serve.ts +11 -2
  380. package/src/channels/deployments/deployments-channel.ts +117 -8
  381. package/src/channels/deployments/types.ts +4 -3
  382. package/src/channels/origin/defaults.ts +143 -0
  383. package/src/channels/origin/index.ts +2 -0
  384. package/src/channels/origin/origin-channel.ts +37 -1
  385. package/src/channels/origin/state.ts +54 -0
  386. package/src/channels/origin/types.ts +24 -0
  387. package/src/channels/slack/api.ts +6 -3
  388. package/src/channels/slack/assistant.ts +1 -1
  389. package/src/channels/slack/code-fences.ts +183 -0
  390. package/src/channels/slack/dispatch.ts +27 -2
  391. package/src/channels/slack/inbound.ts +37 -0
  392. package/src/channels/slack/index.ts +1 -0
  393. package/src/channels/slack/live-delivery.ts +16 -13
  394. package/src/channels/slack/manifest.ts +2 -1
  395. package/src/connections.ts +18 -1
  396. package/src/extensions/cursor-cloud-agents/extension.ts +120 -0
  397. package/src/extensions/cursor-cloud-agents/lib/backend.ts +395 -0
  398. package/src/extensions/cursor-cloud-agents/lib/fleet.ts +109 -0
  399. package/src/extensions/cursor-cloud-agents/lib/inputs.ts +5 -0
  400. package/src/extensions/cursor-cloud-agents/lib/repos.ts +81 -0
  401. package/src/extensions/cursor-cloud-agents/lib/transcript.ts +23 -0
  402. package/src/extensions/cursor-cloud-agents/skills/handoff.md +41 -0
  403. package/src/extensions/cursor-cloud-agents/tools/cancel.ts +19 -0
  404. package/src/extensions/cursor-cloud-agents/tools/dump.ts +51 -0
  405. package/src/extensions/cursor-cloud-agents/tools/get.ts +18 -0
  406. package/src/extensions/cursor-cloud-agents/tools/launch.ts +64 -0
  407. package/src/extensions/cursor-cloud-agents/tools/list.ts +31 -0
  408. package/src/extensions/cursor-cloud-agents/tools/reply.ts +34 -0
  409. package/src/extensions.ts +141 -0
  410. package/src/files-backends/cursor-hosted.ts +1 -17
  411. package/src/files.ts +43 -34
  412. package/src/index.ts +11 -0
  413. package/src/internal/advertise-tools.ts +37 -12
  414. package/src/internal/as-of.ts +163 -0
  415. package/src/internal/cli-deploy.ts +86 -23
  416. package/src/internal/continuation-identity.ts +3 -1
  417. package/src/internal/conversation-mirror.ts +23 -18
  418. package/src/internal/cursor/backend-client.ts +32 -10
  419. package/src/internal/cursor/hosted-deployment-secrets.ts +72 -0
  420. package/src/internal/cursor/hosted-store-secrets.ts +27 -0
  421. package/src/internal/cursor-deployment-relay.ts +65 -8
  422. package/src/internal/deploy-client.ts +73 -18
  423. package/src/internal/discovery/ab.ts +111 -0
  424. package/src/internal/discovery/agent-config.ts +222 -0
  425. package/src/internal/discovery/agent.ts +360 -0
  426. package/src/internal/discovery/channels.ts +103 -0
  427. package/src/internal/discovery/connections.ts +540 -0
  428. package/src/internal/discovery/context.ts +46 -0
  429. package/src/internal/discovery/cursor-plugin.ts +708 -0
  430. package/src/internal/discovery/extensions.ts +348 -0
  431. package/src/internal/discovery/fs.ts +108 -0
  432. package/src/internal/discovery/hooks.ts +45 -0
  433. package/src/internal/discovery/info.ts +179 -0
  434. package/src/internal/discovery/instructions.ts +113 -0
  435. package/src/internal/discovery/modules.ts +107 -0
  436. package/src/internal/discovery/names.ts +44 -0
  437. package/src/internal/discovery/project.ts +270 -0
  438. package/src/internal/discovery/runtime.ts +159 -0
  439. package/src/internal/discovery/schedules.ts +94 -0
  440. package/src/internal/discovery/seed-files.ts +37 -0
  441. package/src/internal/discovery/services.ts +124 -0
  442. package/src/internal/discovery/skills.ts +176 -0
  443. package/src/internal/discovery/subagent.ts +29 -0
  444. package/src/internal/discovery/tools.ts +182 -0
  445. package/src/internal/discovery.ts +20 -2724
  446. package/src/internal/distribution.ts +5 -0
  447. package/src/internal/framework-file-storage.ts +43 -9
  448. package/src/internal/framework-storage-selection.ts +9 -9
  449. package/src/internal/frontmatter.ts +36 -3
  450. package/src/internal/hosted-delivery.ts +38 -63
  451. package/src/internal/hosted-execution-diag.ts +6 -0
  452. package/src/internal/hosted-execution-flush.ts +142 -0
  453. package/src/internal/mcp-endpoint.ts +1 -0
  454. package/src/internal/mcp-host.ts +116 -37
  455. package/src/internal/otel/collector.ts +125 -25
  456. package/src/internal/otel/http.ts +2 -12
  457. package/src/internal/otel/mcp.ts +69 -0
  458. package/src/internal/otel/propagation.ts +17 -0
  459. package/src/internal/otel/runtime.ts +2 -0
  460. package/src/internal/review-comments.ts +5 -2
  461. package/src/internal/server.ts +81 -100
  462. package/src/internal/session-engine.ts +152 -39
  463. package/src/internal/session-run-log.ts +18 -16
  464. package/src/internal/start-log-store.ts +174 -0
  465. package/src/internal/storage-coordinator.ts +19 -16
  466. package/src/internal/tool-catalog.ts +9 -6
  467. package/src/internal/tool-policy.ts +39 -9
  468. package/src/internal/turn-cost.ts +47 -4
  469. package/src/internal/v2-hosting.ts +38 -0
  470. package/src/otel.ts +38 -0
  471. package/src/storage-protocol.ts +126 -79
  472. package/src/storage.ts +5 -0
  473. package/src/tools.ts +18 -0
  474. package/src/types.ts +213 -14
  475. package/dist/docs/assets/chunks/@localSearchIndexroot.j70vvPL4.js +0 -1
  476. package/dist/docs/assets/concepts.md.lwAgBIMI.js +0 -1
  477. package/dist/docs/assets/index.md.Bb4k8kUm.js +0 -5
  478. package/dist/docs/assets/skills_framework-map.md.BTi817yv.js +0 -1
  479. package/dist/playground/assets/index-BszoQDc6.css +0 -1
  480. /package/dist/docs/assets/{concepts.md.lwAgBIMI.lean.js → concepts.md.rPzW2HZN.lean.js} +0 -0
  481. /package/dist/docs/assets/{guides_cloud-runtime.md.CkYbjnAX.lean.js → guides_cloud-runtime.md.BRirbRAN.lean.js} +0 -0
  482. /package/dist/docs/assets/{reference_http-api.md.BEJx9XVj.lean.js → reference_http-api.md.oySXBO8o.lean.js} +0 -0
  483. /package/dist/docs/assets/{reference_skills.md.BFW9retM.lean.js → reference_skills.md.l2ezAcaN.lean.js} +0 -0
  484. /package/dist/docs/assets/{reference_tools.md.CvAHsdSp.lean.js → reference_tools.md.B1up2r9W.lean.js} +0 -0
@@ -131,6 +131,11 @@ export const AUTHORING_ENTRY_FILES: ReadonlyArray<
131
131
  ["channels/origin", "channels/origin/index.js"],
132
132
  ["channels/deployments", "channels/deployments/index.js"],
133
133
  ["skills", "skills.js"],
134
+ ["extensions", "extensions.js"],
135
+ [
136
+ "extensions/cursor-cloud-agents",
137
+ "extensions/cursor-cloud-agents/extension.js",
138
+ ],
134
139
  ["schedules", "schedules.js"],
135
140
  ["reminders", "reminders.js"],
136
141
  ["connections", "connections.js"],
@@ -15,9 +15,9 @@
15
15
  * {@link storageKeys} scheme was designed for exactly this: keys are a
16
16
  * stable versioned contract that sinks may route on, so
17
17
  * {@link composeFrameworkStorage} splits one {@link StorageConfig} by key
18
- * kind — `session` / `session-events` / `session-runs` / `continuation`
19
- * go to the framework file store (file-shaped; the store accepts values
20
- * up to 64 MiB per
18
+ * kind — `session` / `session-events` / `session-runs` / `logs` /
19
+ * `continuation` go to the framework file store (file-shaped; the store
20
+ * accepts values up to 64 MiB per
21
21
  * object without chunking, versus the KV proxy's 1 MiB row cap), while
22
22
  * author `kv`, eval runs, A/B samples, and conditional writes stay on the
23
23
  * control-plane KV proxy (the dashboard reads them there, and CAS needs a
@@ -30,18 +30,19 @@
30
30
 
31
31
  import type { FileSink } from "../files.js";
32
32
  import type { StorageConfig, StorageEntry } from "../storage.js";
33
- import { STORAGE_KEY_ROOT } from "../storage-protocol.js";
33
+ import { AGENTSDK_STORAGE_KEY_ROOT } from "../storage-protocol.js";
34
34
  import type { JsonValue } from "../types.js";
35
35
  import { mapBounded } from "./bounded.js";
36
36
 
37
37
  /**
38
- * Key kinds (`agentkit/v1/{agent}/{kind}/…`) that live on the framework
38
+ * Key kinds (`agentsdk/v1/{agent}/{kind}/…`) that live on the framework
39
39
  * file store. Everything else stays on the KV sink.
40
40
  */
41
41
  const FRAMEWORK_FILE_KINDS: ReadonlySet<string> = new Set([
42
42
  "session",
43
43
  "session-events",
44
44
  "session-runs",
45
+ "logs",
45
46
  "continuation",
46
47
  ]);
47
48
 
@@ -51,10 +52,10 @@ const FRAMEWORK_FILE_KINDS: ReadonlySet<string> = new Set([
51
52
  * kind-scoped (`…/{agent}/session/`), so a prefix routes wholly to one side.
52
53
  */
53
54
  export function isFrameworkFileKey(key: string): boolean {
54
- if (!key.startsWith(`${STORAGE_KEY_ROOT}/`)) {
55
+ if (!key.startsWith(`${AGENTSDK_STORAGE_KEY_ROOT}/`)) {
55
56
  return false;
56
57
  }
57
- const rest = key.slice(STORAGE_KEY_ROOT.length + 1);
58
+ const rest = key.slice(AGENTSDK_STORAGE_KEY_ROOT.length + 1);
58
59
  const agentEnd = rest.indexOf("/");
59
60
  if (agentEnd === -1) {
60
61
  return false;
@@ -105,7 +106,7 @@ export function fileSinkStorageCore(sink: FileSink): FileSinkStorageCore {
105
106
  `framework file storage: key "${key}" has a path segment the store cannot represent`
106
107
  );
107
108
  }
108
- await sink.put(key, new TextEncoder().encode(JSON.stringify(value)));
109
+ await sink.put(key, encodeDocument(key, value));
109
110
  },
110
111
  async get(key): Promise<JsonValue | undefined> {
111
112
  if (isUnrepresentableFileKey(key)) {
@@ -151,9 +152,42 @@ export function fileSinkStorageCore(sink: FileSink): FileSinkStorageCore {
151
152
  };
152
153
  }
153
154
 
155
+ function frameworkFileKind(key: string): string | undefined {
156
+ if (!key.startsWith(`${AGENTSDK_STORAGE_KEY_ROOT}/`)) {
157
+ return undefined;
158
+ }
159
+ const rest = key.slice(AGENTSDK_STORAGE_KEY_ROOT.length + 1);
160
+ const agentEnd = rest.indexOf("/");
161
+ if (agentEnd === -1) {
162
+ return undefined;
163
+ }
164
+ const afterAgent = rest.slice(agentEnd + 1);
165
+ const kindEnd = afterAgent.indexOf("/");
166
+ return kindEnd === -1 ? afterAgent : afterAgent.slice(0, kindEnd);
167
+ }
168
+
169
+ function isLogKey(key: string): boolean {
170
+ return frameworkFileKind(key) === "logs";
171
+ }
172
+
173
+ function encodeDocument(key: string, value: JsonValue): Uint8Array {
174
+ // start.log is raw UTF-8, not a JSON document. Stringify would quote
175
+ // every line and store a JSON string literal instead of the tee.
176
+ if (isLogKey(key)) {
177
+ return new TextEncoder().encode(
178
+ typeof value === "string" ? value : JSON.stringify(value)
179
+ );
180
+ }
181
+ return new TextEncoder().encode(JSON.stringify(value));
182
+ }
183
+
154
184
  function decodeDocument(key: string, bytes: Uint8Array): JsonValue {
185
+ const text = new TextDecoder().decode(bytes);
186
+ if (isLogKey(key)) {
187
+ return text;
188
+ }
155
189
  try {
156
- return JSON.parse(new TextDecoder().decode(bytes)) as JsonValue;
190
+ return JSON.parse(text) as JsonValue;
157
191
  } catch (error) {
158
192
  throw new Error(
159
193
  `framework file storage: stored document at "${key}" is not JSON (${
@@ -42,20 +42,17 @@
42
42
  * pod's filesystem.
43
43
  */
44
44
 
45
- import {
46
- cursorFrameworkStoreSourceId,
47
- cursorHostedFiles,
48
- } from "../files-backends/cursor-hosted.js";
45
+ import { cursorHostedFiles } from "../files-backends/cursor-hosted.js";
49
46
  import { defineStorage, type StorageDefinition } from "../storage.js";
50
47
  import { cursorHostedStorageV2 } from "../storage-backends/cursor-hosted-v2.js";
51
48
  import type { AgentArchitecture } from "../types.js";
52
49
  import { resolveApiKeySync } from "./cursor/credentials.js";
53
- import { AGENT_SERVE_GENERATION_ENV_VAR } from "./cursor-relay-core.js";
54
50
  import {
55
51
  composeFrameworkStorage,
56
52
  fileSinkStorageCore,
57
53
  frameworkGuardedCas,
58
54
  } from "./framework-file-storage.js";
55
+ import { resolveAgentV2Hosting } from "./v2-hosting.js";
59
56
 
60
57
  export interface FrameworkStorageSelectionInput {
61
58
  /** `agent/storage.ts`, when the author wrote one (v1 only: discovery rejects it on v2). */
@@ -87,8 +84,11 @@ export function selectFrameworkStorageDefinition(
87
84
  'defineStorage (agent/storage.ts) is not supported on architecture "v2": storage is platform-selected. Delete the file.'
88
85
  );
89
86
  }
90
- const env = input.env ?? process.env;
91
- if (env[AGENT_SERVE_GENERATION_ENV_VAR] === undefined) {
87
+ const hosting = resolveAgentV2Hosting({
88
+ architecture: input.architecture,
89
+ env: input.env as NodeJS.ProcessEnv | undefined,
90
+ });
91
+ if (hosting.kind !== "cursor-managed") {
92
92
  // Self-hosted v2: the state root is the durable copy.
93
93
  return undefined;
94
94
  }
@@ -98,7 +98,6 @@ export function selectFrameworkStorageDefinition(
98
98
  // comes up). Follow-ups restore lazily by continuation or session id;
99
99
  // GET /v1/sessions lists from the sink either way.
100
100
  const policy = { restore: "off" } as const;
101
- const envSnapshot = env as NodeJS.ProcessEnv;
102
101
  // Full chain (env → bind file → stored login): frozen engines listen
103
102
  // unsigned and bind store ids + CURSOR_API_KEY at task time, after this
104
103
  // definition is constructed.
@@ -118,7 +117,8 @@ export function selectFrameworkStorageDefinition(
118
117
  kv,
119
118
  files: fileSinkStorageCore(
120
119
  cursorHostedFiles({
121
- resolveStoreSourceId: () => cursorFrameworkStoreSourceId(envSnapshot),
120
+ resolveStoreSourceId: () =>
121
+ hosting.resolveStoreIds().frameworkStoreSourceId,
122
122
  resolveApiKey,
123
123
  })
124
124
  ),
@@ -1,15 +1,48 @@
1
1
  /**
2
- * Minimal frontmatter parser. Supports the flat `key: value` scalar subset
3
- * used by authored markdown (skill descriptions, schedule cron expressions)
4
- * without pulling in a YAML dependency.
2
+ * Frontmatter parsers. Authored markdown (skill descriptions, schedule cron
3
+ * expressions) uses the flat `key: value` scalar subset; Cursor plugin
4
+ * markdown is full YAML (folded descriptions, lists).
5
5
  */
6
6
 
7
+ import { JSON_SCHEMA, load as parseYaml } from "js-yaml";
8
+
7
9
  export interface ParsedFrontmatter {
8
10
  data: Record<string, string>;
9
11
  body: string;
10
12
  }
11
13
 
14
+ export interface ParsedYamlFrontmatter {
15
+ data: Record<string, unknown>;
16
+ body: string;
17
+ /** Why the block did not parse as a YAML mapping; `data` is then empty. */
18
+ error?: string;
19
+ }
20
+
12
21
  const FRONTMATTER_OPEN = /^---\s*$/;
22
+ const YAML_FRONTMATTER = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/;
23
+
24
+ /** YAML frontmatter with the JSON schema (no custom tags). */
25
+ export function parseYamlFrontmatter(source: string): ParsedYamlFrontmatter {
26
+ const match = YAML_FRONTMATTER.exec(source);
27
+ if (match === null) {
28
+ return { data: {}, body: source };
29
+ }
30
+ const body = match[2] ?? "";
31
+ let data: unknown;
32
+ try {
33
+ data = parseYaml(match[1] ?? "", { schema: JSON_SCHEMA });
34
+ } catch (error) {
35
+ const message = error instanceof Error ? error.message : String(error);
36
+ return { data: {}, body, error: message };
37
+ }
38
+ if (data === undefined || data === null) {
39
+ return { data: {}, body };
40
+ }
41
+ if (typeof data !== "object" || Array.isArray(data)) {
42
+ return { data: {}, body, error: "frontmatter is not a mapping" };
43
+ }
44
+ return { data: data as Record<string, unknown>, body };
45
+ }
13
46
 
14
47
  export function parseFrontmatter(source: string): ParsedFrontmatter {
15
48
  const lines = source.split(/\r?\n/);
@@ -4,6 +4,7 @@ import type {
4
4
  ChannelHandlerArgs,
5
5
  SendMessageOptions,
6
6
  } from "../types.js";
7
+ import { refreshBoundDeploymentSecrets } from "./cursor/hosted-deployment-secrets.js";
7
8
  import {
8
9
  createDeferredChannelSession,
9
10
  DeferredChannelSessionError,
@@ -28,19 +29,17 @@ import {
28
29
  import {
29
30
  abortReasonFromTurnStatus,
30
31
  HOSTED_EXECUTION_DIAG_RUNNING_STATUS,
31
- hostedErrorStackSnippet,
32
32
  hostedExecutionDiagId,
33
- writeHostedExecutionDiag,
34
33
  } from "./hosted-execution-diag.js";
34
+ import {
35
+ flushHostedExecutionRecord,
36
+ type HostedExecutionFlushSinks,
37
+ } from "./hosted-execution-flush.js";
35
38
  import { recordHostedManagedAutomation } from "./hosted-managed-automation.js";
36
39
  import { errorResponse, readJsonObject } from "./http-channel.js";
37
40
  import type { LogRingEntry } from "./log-ring.js";
38
41
  import type { Router } from "./router.js";
39
- import {
40
- type SessionRunExecutionWrite,
41
- serializeSessionRunError,
42
- snapshotSessionRunLogs,
43
- } from "./session-run-log.js";
42
+ import type { SessionRunExecutionWrite } from "./session-run-log.js";
44
43
 
45
44
  type DispatchInput = {
46
45
  delivery: HostedAdmission;
@@ -279,6 +278,8 @@ export function registerHostedDeliveryRoute(input: {
279
278
  * store; this path still awaits so a parked pod cannot shed the write.
280
279
  */
281
280
  persistSessionRun?(write: SessionRunExecutionWrite): Promise<void>;
281
+ /** Snapshot the local `start.log` tee onto `logs/{ses_…}`. */
282
+ flushStartLog?(startLogId: string): Promise<void>;
282
283
  /** Snapshot of the process log ring at persist time. */
283
284
  snapshotLogs?(): LogRingEntry[];
284
285
  }): void {
@@ -318,6 +319,7 @@ export function registerHostedDeliveryRoute(input: {
318
319
  pattern: `${input.base}${HOSTED_ADMISSION_PATH}`,
319
320
  auth: [auth],
320
321
  handler: async (request) => {
322
+ refreshBoundDeploymentSecrets();
321
323
  const startedAt = performance.now();
322
324
  const finish = (response: Response) =>
323
325
  withServerTiming(response, performance.now() - startedAt);
@@ -373,6 +375,7 @@ export function registerHostedDeliveryRoute(input: {
373
375
  pattern: `${input.base}${HOSTED_EXECUTION_PATH}`,
374
376
  auth: [auth],
375
377
  handler: async (request) => {
378
+ refreshBoundDeploymentSecrets();
376
379
  const startedAt = performance.now();
377
380
  const finish = (response: Response) =>
378
381
  withServerTiming(response, performance.now() - startedAt);
@@ -414,6 +417,20 @@ export function registerHostedDeliveryRoute(input: {
414
417
  admitted.execution ??= (async (): Promise<ExecutionReply> => {
415
418
  const startedAt = performance.now();
416
419
  const executionId = hostedExecutionDiagId(execution.admissionToken);
420
+ const sinks: HostedExecutionFlushSinks = {
421
+ ...(input.stateRoot === undefined
422
+ ? {}
423
+ : { stateRoot: input.stateRoot }),
424
+ ...(input.persistSessionRun === undefined
425
+ ? {}
426
+ : { persistSessionRun: input.persistSessionRun }),
427
+ ...(input.flushStartLog === undefined
428
+ ? {}
429
+ : { flushStartLog: input.flushStartLog }),
430
+ ...(input.snapshotLogs === undefined
431
+ ? {}
432
+ : { snapshotLogs: input.snapshotLogs }),
433
+ };
417
434
  const writeDiag = async (fields: {
418
435
  sessionId: string;
419
436
  turnStatus: string;
@@ -423,62 +440,20 @@ export function registerHostedDeliveryRoute(input: {
423
440
  | "execute_throw";
424
441
  error?: unknown;
425
442
  }): Promise<void> => {
426
- const durationMs = Math.max(
427
- 0,
428
- Math.round(performance.now() - startedAt)
429
- );
430
- const message =
431
- fields.message === undefined
432
- ? undefined
433
- : boundedMessage(fields.message);
434
- const stack =
435
- fields.error === undefined
436
- ? undefined
437
- : hostedErrorStackSnippet(fields.error);
438
- if (input.stateRoot !== undefined) {
439
- await writeHostedExecutionDiag(input.stateRoot, {
440
- v: 1,
441
- executionId,
442
- writtenAt: new Date().toISOString(),
443
- sessionPublicId: execution.sessionPublicId,
444
- sessionId: fields.sessionId,
445
- turnStatus: fields.turnStatus,
446
- durationMs,
447
- ...(message === undefined ? {} : { message }),
448
- ...(stack === undefined || stack.length === 0 ? {} : { stack }),
449
- ...(message !== undefined && /abort/i.test(message)
450
- ? { signalAborted: true }
451
- : {}),
452
- ...(fields.abortReason === undefined
453
- ? {}
454
- : { abortReason: fields.abortReason }),
455
- });
456
- }
457
- if (input.persistSessionRun === undefined) {
458
- return;
459
- }
460
- const error =
461
- fields.error === undefined
462
- ? undefined
463
- : serializeSessionRunError(fields.error);
464
- try {
465
- await input.persistSessionRun({
466
- executionId,
467
- writtenAt: new Date().toISOString(),
468
- sessionPublicId: execution.sessionPublicId,
469
- sessionId: fields.sessionId,
470
- turnStatus: fields.turnStatus,
471
- durationMs,
472
- ...(fields.abortReason === undefined
473
- ? {}
474
- : { abortReason: fields.abortReason }),
475
- ...(message === undefined ? {} : { message }),
476
- ...(error === undefined ? {} : { error }),
477
- logs: snapshotSessionRunLogs(input.snapshotLogs?.() ?? []),
478
- });
479
- } catch {
480
- // Soft-fail: a store outage must not change the HTTP reply.
481
- }
443
+ await flushHostedExecutionRecord(sinks, {
444
+ executionId,
445
+ sessionPublicId: execution.sessionPublicId,
446
+ sessionId: fields.sessionId,
447
+ turnStatus: fields.turnStatus,
448
+ durationMs: Math.max(0, Math.round(performance.now() - startedAt)),
449
+ ...(fields.message === undefined
450
+ ? {}
451
+ : { message: fields.message }),
452
+ ...(fields.abortReason === undefined
453
+ ? {}
454
+ : { abortReason: fields.abortReason }),
455
+ ...(fields.error === undefined ? {} : { error: fields.error }),
456
+ });
482
457
  };
483
458
  // Claim the file before the turn runs. The host reads it after its
484
459
  // own POST returns, which for a 9-minute timeout is while this turn
@@ -1,3 +1,9 @@
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`.
5
+ */
6
+
1
7
  import { createHash, randomBytes } from "node:crypto";
2
8
  import { mkdir, rename, unlink, writeFile } from "node:fs/promises";
3
9
  import { join } from "node:path";
@@ -0,0 +1,142 @@
1
+ /**
2
+ * One hosted-execution flush. Two artifacts, same moments:
3
+ *
4
+ * - Guest-local `hosted-execution.json` — TAS failed-execute diag.
5
+ * - Durable `session-runs/{ses_…}` plus the `start.log` tee — dashboard.
6
+ *
7
+ * Claim (`running`) → terminal → process-death. Process-death upgrades the
8
+ * durable document and re-snapshots the tee; the local json stays `running`
9
+ * so TAS does not treat a previous delivery's terminal record as this one.
10
+ */
11
+
12
+ import {
13
+ type HostedExecutionDiagAbortReason,
14
+ hostedErrorStackSnippet,
15
+ writeHostedExecutionDiag,
16
+ } from "./hosted-execution-diag.js";
17
+ import type { LogRingEntry } from "./log-ring.js";
18
+ import {
19
+ type SessionRunAbortReason,
20
+ type SessionRunExecutionWrite,
21
+ serializeSessionRunError,
22
+ snapshotSessionRunLogs,
23
+ } from "./session-run-log.js";
24
+
25
+ const MAX_ERROR_MESSAGE_LENGTH = 1024;
26
+
27
+ function boundedMessage(text: string): string {
28
+ return text.length > MAX_ERROR_MESSAGE_LENGTH
29
+ ? `${text.slice(0, MAX_ERROR_MESSAGE_LENGTH)}…`
30
+ : text;
31
+ }
32
+
33
+ export type HostedExecutionFlushSinks = {
34
+ /** Serve `--state-root`. Omit to skip the guest-local TAS diag. */
35
+ stateRoot?: string;
36
+ persistSessionRun?(write: SessionRunExecutionWrite): Promise<void>;
37
+ flushStartLog?(startLogId: string): Promise<void>;
38
+ snapshotLogs?(): LogRingEntry[];
39
+ };
40
+
41
+ export type HostedExecutionFlushFields = {
42
+ executionId: string;
43
+ sessionPublicId: string;
44
+ sessionId: string;
45
+ turnStatus: string;
46
+ durationMs: number;
47
+ message?: string;
48
+ abortReason?: HostedExecutionDiagAbortReason;
49
+ error?: unknown;
50
+ };
51
+
52
+ /**
53
+ * Write the local TAS diag and the durable session-run + tee together.
54
+ * Soft-fail per sink so a store outage does not change hosted HTTP.
55
+ */
56
+ export async function flushHostedExecutionRecord(
57
+ sinks: HostedExecutionFlushSinks,
58
+ fields: HostedExecutionFlushFields
59
+ ): Promise<void> {
60
+ const writtenAt = new Date().toISOString();
61
+ const message =
62
+ fields.message === undefined ? undefined : boundedMessage(fields.message);
63
+ const stack =
64
+ fields.error === undefined
65
+ ? undefined
66
+ : hostedErrorStackSnippet(fields.error);
67
+ if (sinks.stateRoot !== undefined) {
68
+ await writeHostedExecutionDiag(sinks.stateRoot, {
69
+ v: 1,
70
+ executionId: fields.executionId,
71
+ writtenAt,
72
+ sessionPublicId: fields.sessionPublicId,
73
+ sessionId: fields.sessionId,
74
+ turnStatus: fields.turnStatus,
75
+ durationMs: fields.durationMs,
76
+ ...(message === undefined ? {} : { message }),
77
+ ...(stack === undefined || stack.length === 0 ? {} : { stack }),
78
+ ...(message !== undefined && /abort/i.test(message)
79
+ ? { signalAborted: true }
80
+ : {}),
81
+ ...(fields.abortReason === undefined
82
+ ? {}
83
+ : { abortReason: fields.abortReason }),
84
+ });
85
+ }
86
+ if (sinks.persistSessionRun !== undefined) {
87
+ const error =
88
+ fields.error === undefined
89
+ ? undefined
90
+ : serializeSessionRunError(fields.error);
91
+ try {
92
+ await sinks.persistSessionRun({
93
+ executionId: fields.executionId,
94
+ writtenAt,
95
+ sessionPublicId: fields.sessionPublicId,
96
+ sessionId: fields.sessionId,
97
+ turnStatus: fields.turnStatus,
98
+ durationMs: fields.durationMs,
99
+ ...(fields.abortReason === undefined
100
+ ? {}
101
+ : { abortReason: fields.abortReason }),
102
+ ...(message === undefined ? {} : { message }),
103
+ ...(error === undefined ? {} : { error }),
104
+ logs: snapshotSessionRunLogs(sinks.snapshotLogs?.() ?? []),
105
+ });
106
+ } catch {
107
+ // Soft-fail: a store outage must not change the HTTP reply.
108
+ }
109
+ }
110
+ if (sinks.flushStartLog !== undefined) {
111
+ try {
112
+ await sinks.flushStartLog(fields.sessionPublicId);
113
+ } catch {
114
+ // Soft-fail: same posture as the session-run persist.
115
+ }
116
+ }
117
+ }
118
+
119
+ /**
120
+ * Durable-only crash flush. Leaves `hosted-execution.json` at `running`.
121
+ */
122
+ export async function flushHostedExecutionProcessDeath(args: {
123
+ flushProcessDeath: (
124
+ reason: Extract<
125
+ SessionRunAbortReason,
126
+ "process_exit" | "uncaught_exception" | "unhandled_rejection"
127
+ >,
128
+ error?: unknown
129
+ ) => Promise<void>;
130
+ flushStartLog?: (startLogId: string) => Promise<void>;
131
+ startLogId?: string;
132
+ reason: Extract<
133
+ SessionRunAbortReason,
134
+ "process_exit" | "uncaught_exception" | "unhandled_rejection"
135
+ >;
136
+ error?: unknown;
137
+ }): Promise<void> {
138
+ await args.flushProcessDeath(args.reason, args.error);
139
+ if (args.startLogId !== undefined && args.flushStartLog !== undefined) {
140
+ await args.flushStartLog(args.startLogId);
141
+ }
142
+ }
@@ -326,6 +326,7 @@ function buildConnectionBridgeMcpServer(
326
326
  sessionId: sessionId ?? "",
327
327
  connectionName,
328
328
  toolName: request.params.name,
329
+ input: request.params.arguments,
329
330
  });
330
331
  if (answer.answered) {
331
332
  return sdkResultToMcpResult(answer.result);