@cursor/july 0.1.95 → 0.1.97

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 (424) hide show
  1. package/AGENTS.md +3 -4
  2. package/README.md +3 -2
  3. package/dist/bin/agent-serve.js +14 -3
  4. package/dist/channels/deployments/types.d.ts +1 -1
  5. package/dist/channels/deployments/types.d.ts.map +1 -1
  6. package/dist/channels/deployments/types.js +1 -0
  7. package/dist/channels/origin/api.d.ts +72 -15
  8. package/dist/channels/origin/api.d.ts.map +1 -1
  9. package/dist/channels/origin/api.js +185 -28
  10. package/dist/channels/origin/binding.d.ts +13 -2
  11. package/dist/channels/origin/binding.d.ts.map +1 -1
  12. package/dist/channels/origin/binding.js +41 -25
  13. package/dist/channels/origin/checks.d.ts +6 -6
  14. package/dist/channels/origin/checks.js +6 -6
  15. package/dist/channels/origin/cursor-account.d.ts +5 -3
  16. package/dist/channels/origin/cursor-account.d.ts.map +1 -1
  17. package/dist/channels/origin/cursor-account.js +5 -3
  18. package/dist/channels/origin/index.d.ts +1 -0
  19. package/dist/channels/origin/index.d.ts.map +1 -1
  20. package/dist/channels/origin/index.js +1 -0
  21. package/dist/channels/origin/origin-channel.d.ts.map +1 -1
  22. package/dist/channels/origin/origin-channel.js +3 -0
  23. package/dist/channels/origin/reactions.d.ts +56 -0
  24. package/dist/channels/origin/reactions.d.ts.map +1 -0
  25. package/dist/channels/origin/reactions.js +67 -0
  26. package/dist/channels/origin/types.d.ts +11 -0
  27. package/dist/channels/origin/types.d.ts.map +1 -1
  28. package/dist/channels/slack/api.d.ts +9 -0
  29. package/dist/channels/slack/api.d.ts.map +1 -1
  30. package/dist/channels/slack/api.js +36 -5
  31. package/dist/channels/slack/approvals.d.ts +16 -0
  32. package/dist/channels/slack/approvals.d.ts.map +1 -1
  33. package/dist/channels/slack/approvals.js +86 -0
  34. package/dist/channels/slack/cli-project.d.ts +19 -0
  35. package/dist/channels/slack/cli-project.d.ts.map +1 -0
  36. package/dist/channels/slack/cli-project.js +234 -0
  37. package/dist/channels/slack/defaults.d.ts.map +1 -1
  38. package/dist/channels/slack/defaults.js +110 -81
  39. package/dist/channels/slack/dispatch.d.ts +7 -1
  40. package/dist/channels/slack/dispatch.d.ts.map +1 -1
  41. package/dist/channels/slack/dispatch.js +47 -23
  42. package/dist/channels/slack/inbound.d.ts +8 -0
  43. package/dist/channels/slack/inbound.d.ts.map +1 -1
  44. package/dist/channels/slack/inbound.js +32 -0
  45. package/dist/channels/slack/init.d.ts +3 -2
  46. package/dist/channels/slack/init.d.ts.map +1 -1
  47. package/dist/channels/slack/init.js +5 -5
  48. package/dist/channels/slack/interactive.d.ts +2 -1
  49. package/dist/channels/slack/interactive.d.ts.map +1 -1
  50. package/dist/channels/slack/interactive.js +15 -4
  51. package/dist/channels/slack/live-delivery.d.ts +26 -29
  52. package/dist/channels/slack/live-delivery.d.ts.map +1 -1
  53. package/dist/channels/slack/live-delivery.js +172 -73
  54. package/dist/channels/slack/manifest.d.ts +1 -1
  55. package/dist/channels/slack/manifest.d.ts.map +1 -1
  56. package/dist/channels/slack/manifest.js +6 -2
  57. package/dist/channels/slack/nudge-carrier.d.ts +2 -0
  58. package/dist/channels/slack/nudge-carrier.d.ts.map +1 -1
  59. package/dist/channels/slack/nudge-carrier.js +48 -1
  60. package/dist/channels/slack/setup.d.ts +1 -1
  61. package/dist/channels/slack/setup.d.ts.map +1 -1
  62. package/dist/channels/slack/setup.js +10 -6
  63. package/dist/channels/slack/slack-channel.d.ts.map +1 -1
  64. package/dist/channels/slack/slack-channel.js +3 -2
  65. package/dist/channels/slack/tool-approval-events.d.ts.map +1 -1
  66. package/dist/channels/slack/tool-approval-events.js +91 -1
  67. package/dist/docs/404.html +2 -2
  68. package/dist/docs/ab.html +4 -4
  69. package/dist/docs/assets/{app.BBj0klBO.js → app.B3rWNYE1.js} +1 -1
  70. package/dist/docs/assets/chunks/@localSearchIndexroot.BU9nHdnQ.js +1 -0
  71. package/dist/docs/assets/chunks/{VPLocalSearchBox.CUEXpL78.js → VPLocalSearchBox.C1lhqJJR.js} +1 -1
  72. package/dist/docs/assets/chunks/{theme.DabmQnia.js → theme.B40_SXuv.js} +2 -2
  73. package/dist/docs/assets/{deployment.md.D9msOFOW.js → deployment.md.MFPKqsqI.js} +2 -2
  74. package/dist/docs/assets/{guides_mcp-oauth.md.DPYmBCbV.js → guides_mcp-oauth.md.CN-6YmTJ.js} +4 -4
  75. package/dist/docs/assets/{guides_mcp-oauth.md.DPYmBCbV.lean.js → guides_mcp-oauth.md.CN-6YmTJ.lean.js} +1 -1
  76. package/dist/docs/assets/guides_slack.md.VDXQV3ja.js +22 -0
  77. package/dist/docs/assets/guides_slack.md.VDXQV3ja.lean.js +1 -0
  78. package/dist/docs/assets/index.md.CVeRUOeZ.js +5 -0
  79. package/dist/docs/assets/{index.md.BoHaMdeZ.lean.js → index.md.CVeRUOeZ.lean.js} +1 -1
  80. package/dist/docs/assets/{reference_agent-config.md.Cp_x38Nl.js → reference_agent-config.md.BHeYMgme.js} +1 -1
  81. package/dist/docs/assets/{reference_cli.md.BsMOxDvh.js → reference_cli.md.RyZf5OTE.js} +10 -6
  82. package/dist/docs/assets/{reference_cli.md.BsMOxDvh.lean.js → reference_cli.md.RyZf5OTE.lean.js} +1 -1
  83. package/dist/docs/assets/{reference_connections.md.BH8Oc0D0.js → reference_connections.md.DxldvyIB.js} +4 -3
  84. package/dist/docs/assets/{reference_http-api.md.D89k1mdm.js → reference_http-api.md.5zOAbV86.js} +1 -1
  85. package/dist/docs/assets/reference_sessions.md.NxFP_CAC.js +1 -0
  86. package/dist/docs/assets/{reference_tools.md.BHeXn2id.js → reference_tools.md.B84gw9Ii.js} +1 -1
  87. package/dist/docs/assets/templates_agents-md.md.CXSMZljE.js +2 -0
  88. package/dist/docs/assets/templates_agents-md.md.CXSMZljE.lean.js +1 -0
  89. package/dist/docs/assets/templates_code-wiki.md.CDYZIBFN.js +2 -0
  90. package/dist/docs/assets/templates_code-wiki.md.CDYZIBFN.lean.js +1 -0
  91. package/dist/docs/assets/troubleshooting.md.DCiPBhYs.js +1 -0
  92. package/dist/docs/building-with-agents.html +4 -4
  93. package/dist/docs/concepts.html +4 -4
  94. package/dist/docs/deployment.html +7 -7
  95. package/dist/docs/deployment.md +5 -4
  96. package/dist/docs/evals.html +4 -4
  97. package/dist/docs/guides/agent-to-agent.html +4 -4
  98. package/dist/docs/guides/cloud-runtime.html +4 -4
  99. package/dist/docs/guides/convert-automation.html +4 -4
  100. package/dist/docs/guides/github.html +4 -4
  101. package/dist/docs/guides/human-in-the-loop.html +4 -4
  102. package/dist/docs/guides/mcp-oauth.html +8 -8
  103. package/dist/docs/guides/mcp-oauth.md +26 -8
  104. package/dist/docs/guides/opentelemetry.html +4 -4
  105. package/dist/docs/guides/slack.html +17 -33
  106. package/dist/docs/guides/slack.md +92 -201
  107. package/dist/docs/guides/webhooks.html +4 -4
  108. package/dist/docs/hashmap.json +1 -1
  109. package/dist/docs/hillclimbing.html +4 -4
  110. package/dist/docs/index.html +6 -6
  111. package/dist/docs/index.md +7 -3
  112. package/dist/docs/llms-full.txt +398 -653
  113. package/dist/docs/llms.txt +3 -2
  114. package/dist/docs/quickstart.html +4 -4
  115. package/dist/docs/reference/agent-config.html +6 -6
  116. package/dist/docs/reference/agent-config.md +2 -2
  117. package/dist/docs/reference/artifacts.html +4 -4
  118. package/dist/docs/reference/channels.html +4 -4
  119. package/dist/docs/reference/cli.html +14 -10
  120. package/dist/docs/reference/cli.md +39 -16
  121. package/dist/docs/reference/connections.html +9 -8
  122. package/dist/docs/reference/connections.md +6 -3
  123. package/dist/docs/reference/hooks.html +4 -4
  124. package/dist/docs/reference/http-api.html +6 -6
  125. package/dist/docs/reference/http-api.md +2 -1
  126. package/dist/docs/reference/instructions.html +4 -4
  127. package/dist/docs/reference/playground.html +4 -4
  128. package/dist/docs/reference/project-layout.html +4 -4
  129. package/dist/docs/reference/prompt.html +4 -4
  130. package/dist/docs/reference/schedules.html +4 -4
  131. package/dist/docs/reference/sessions.html +5 -5
  132. package/dist/docs/reference/sessions.md +4 -2
  133. package/dist/docs/reference/skills.html +4 -4
  134. package/dist/docs/reference/subagents.html +4 -4
  135. package/dist/docs/reference/tools.html +6 -6
  136. package/dist/docs/reference/tools.md +9 -2
  137. package/dist/docs/scaffolding-agents.html +4 -4
  138. package/dist/docs/storage.html +4 -4
  139. package/dist/docs/templates/agentic-owners.html +4 -4
  140. package/dist/docs/templates/agents-md.html +28 -0
  141. package/dist/docs/templates/agents-md.md +105 -0
  142. package/dist/docs/templates/code-wiki.html +28 -0
  143. package/dist/docs/templates/code-wiki.md +91 -0
  144. package/dist/docs/templates/demo.html +5 -5
  145. package/dist/docs/templates/pr-autofixer.html +4 -4
  146. package/dist/docs/templates/security-help.html +4 -4
  147. package/dist/docs/templates/security-reviewer.html +5 -5
  148. package/dist/docs/templates/triage.html +4 -4
  149. package/dist/docs/troubleshooting.html +5 -5
  150. package/dist/docs/troubleshooting.md +2 -2
  151. package/dist/evals/run-facts.d.ts.map +1 -1
  152. package/dist/evals/run-facts.js +27 -0
  153. package/dist/files-backends/cursor-hosted.d.ts +26 -4
  154. package/dist/files-backends/cursor-hosted.d.ts.map +1 -1
  155. package/dist/files-backends/cursor-hosted.js +32 -4
  156. package/dist/internal/advertise-tools.d.ts +2 -0
  157. package/dist/internal/advertise-tools.d.ts.map +1 -1
  158. package/dist/internal/advertise-tools.js +30 -10
  159. package/dist/internal/approval-gate.d.ts +12 -13
  160. package/dist/internal/approval-gate.d.ts.map +1 -1
  161. package/dist/internal/approval-gate.js +16 -21
  162. package/dist/internal/bounded.d.ts +7 -0
  163. package/dist/internal/bounded.d.ts.map +1 -0
  164. package/dist/internal/bounded.js +32 -0
  165. package/dist/internal/chat-client.js +10 -0
  166. package/dist/internal/cli-deploy.d.ts +5 -0
  167. package/dist/internal/cli-deploy.d.ts.map +1 -1
  168. package/dist/internal/cli-deploy.js +57 -18
  169. package/dist/internal/cli-mcp-oauth.js +8 -18
  170. package/dist/internal/cli-slack-manual.d.ts +24 -2
  171. package/dist/internal/cli-slack-manual.d.ts.map +1 -1
  172. package/dist/internal/cli-slack-manual.js +251 -20
  173. package/dist/internal/cli-slack.d.ts +9 -2
  174. package/dist/internal/cli-slack.d.ts.map +1 -1
  175. package/dist/internal/cli-slack.js +29 -82
  176. package/dist/internal/conversation-mirror.d.ts +11 -8
  177. package/dist/internal/conversation-mirror.d.ts.map +1 -1
  178. package/dist/internal/conversation-mirror.js +116 -55
  179. package/dist/internal/cursor/account-mcp.d.ts +1 -0
  180. package/dist/internal/cursor/account-mcp.d.ts.map +1 -1
  181. package/dist/internal/cursor/account-mcp.js +17 -0
  182. package/dist/internal/cursor/backend-client.d.ts.map +1 -1
  183. package/dist/internal/cursor/backend-client.js +22 -48
  184. package/dist/internal/cursor/session-token.d.ts +45 -0
  185. package/dist/internal/cursor/session-token.d.ts.map +1 -0
  186. package/dist/internal/cursor/session-token.js +99 -0
  187. package/dist/internal/cursor-agent-template.d.ts +1 -1
  188. package/dist/internal/cursor-agent-template.d.ts.map +1 -1
  189. package/dist/internal/cursor-agent-template.js +2 -0
  190. package/dist/internal/deploy-client.d.ts +17 -0
  191. package/dist/internal/deploy-client.d.ts.map +1 -1
  192. package/dist/internal/deploy-client.js +31 -10
  193. package/dist/internal/env-file.d.ts +19 -0
  194. package/dist/internal/env-file.d.ts.map +1 -0
  195. package/dist/internal/env-file.js +90 -0
  196. package/dist/internal/framework-file-storage.d.ts +61 -0
  197. package/dist/internal/framework-file-storage.d.ts.map +1 -0
  198. package/dist/internal/framework-file-storage.js +210 -0
  199. package/dist/internal/framework-storage-selection.d.ts +11 -5
  200. package/dist/internal/framework-storage-selection.d.ts.map +1 -1
  201. package/dist/internal/framework-storage-selection.js +38 -11
  202. package/dist/internal/hosted-delivery-protocol.d.ts +7 -0
  203. package/dist/internal/hosted-delivery-protocol.d.ts.map +1 -1
  204. package/dist/internal/hosted-delivery-protocol.js +7 -0
  205. package/dist/internal/hosted-delivery.d.ts +13 -0
  206. package/dist/internal/hosted-delivery.d.ts.map +1 -1
  207. package/dist/internal/hosted-delivery.js +64 -19
  208. package/dist/internal/hosted-execution-diag.d.ts +48 -0
  209. package/dist/internal/hosted-execution-diag.d.ts.map +1 -0
  210. package/dist/internal/hosted-execution-diag.js +150 -0
  211. package/dist/internal/http-channel.d.ts.map +1 -1
  212. package/dist/internal/http-channel.js +81 -1
  213. package/dist/internal/init-project.d.ts.map +1 -1
  214. package/dist/internal/init-project.js +4 -0
  215. package/dist/internal/install-cursor-skills.d.ts.map +1 -1
  216. package/dist/internal/install-cursor-skills.js +1 -3
  217. package/dist/internal/logs-client.d.ts +5 -0
  218. package/dist/internal/logs-client.d.ts.map +1 -1
  219. package/dist/internal/logs-client.js +5 -0
  220. package/dist/internal/managed-delivery.d.ts +80 -0
  221. package/dist/internal/managed-delivery.d.ts.map +1 -0
  222. package/dist/internal/managed-delivery.js +86 -0
  223. package/dist/internal/mcp-endpoint.js +2 -3
  224. package/dist/internal/mcp-host.d.ts +10 -0
  225. package/dist/internal/mcp-host.d.ts.map +1 -1
  226. package/dist/internal/mcp-host.js +57 -8
  227. package/dist/internal/mcp-oauth-on-demand.d.ts +68 -0
  228. package/dist/internal/mcp-oauth-on-demand.d.ts.map +1 -0
  229. package/dist/internal/mcp-oauth-on-demand.js +287 -0
  230. package/dist/internal/mcp-oauth-persist.d.ts +42 -0
  231. package/dist/internal/mcp-oauth-persist.d.ts.map +1 -0
  232. package/dist/internal/mcp-oauth-persist.js +92 -0
  233. package/dist/internal/mcp-oauth.d.ts +1 -0
  234. package/dist/internal/mcp-oauth.d.ts.map +1 -1
  235. package/dist/internal/mcp-oauth.js +10 -2
  236. package/dist/internal/otel/collector.d.ts.map +1 -1
  237. package/dist/internal/otel/collector.js +22 -9
  238. package/dist/internal/runtime-dispatch-runner.d.ts +5 -1
  239. package/dist/internal/runtime-dispatch-runner.d.ts.map +1 -1
  240. package/dist/internal/runtime-dispatch-runner.js +7 -0
  241. package/dist/internal/sdk-runner.d.ts +11 -0
  242. package/dist/internal/sdk-runner.d.ts.map +1 -1
  243. package/dist/internal/sdk-runner.js +39 -8
  244. package/dist/internal/server.d.ts +3 -0
  245. package/dist/internal/server.d.ts.map +1 -1
  246. package/dist/internal/server.js +49 -21
  247. package/dist/internal/session-engine.d.ts +101 -3
  248. package/dist/internal/session-engine.d.ts.map +1 -1
  249. package/dist/internal/session-engine.js +577 -46
  250. package/dist/internal/sessions-client.d.ts +9 -7
  251. package/dist/internal/sessions-client.d.ts.map +1 -1
  252. package/dist/internal/sessions-client.js +3 -1
  253. package/dist/internal/steering.d.ts +15 -0
  254. package/dist/internal/steering.d.ts.map +1 -0
  255. package/dist/internal/steering.js +18 -0
  256. package/dist/internal/storage-coordinator.d.ts +7 -0
  257. package/dist/internal/storage-coordinator.d.ts.map +1 -1
  258. package/dist/internal/storage-coordinator.js +28 -5
  259. package/dist/internal/storage-roles.d.ts +5 -0
  260. package/dist/internal/storage-roles.d.ts.map +1 -1
  261. package/dist/internal/stream-progress.d.ts.map +1 -1
  262. package/dist/internal/stream-progress.js +10 -0
  263. package/dist/internal/tool-policy.d.ts +9 -1
  264. package/dist/internal/tool-policy.d.ts.map +1 -1
  265. package/dist/internal/tool-policy.js +13 -0
  266. package/dist/internal/trajectory.d.ts.map +1 -1
  267. package/dist/internal/trajectory.js +10 -0
  268. package/dist/internal/turn-outbox.d.ts +24 -0
  269. package/dist/internal/turn-outbox.d.ts.map +1 -0
  270. package/dist/internal/turn-outbox.js +80 -0
  271. package/dist/playground/assets/{index-CZA1uEWA.js → index-DrkI6y5O.js} +51 -51
  272. package/dist/playground/assets/index-DzNGwm7q.css +1 -0
  273. package/dist/playground/index.html +2 -2
  274. package/dist/storage-backends/cursor-hosted.d.ts +9 -6
  275. package/dist/storage-backends/cursor-hosted.d.ts.map +1 -1
  276. package/dist/storage-backends/cursor-hosted.js +16 -3
  277. package/dist/storage.d.ts +8 -0
  278. package/dist/storage.d.ts.map +1 -1
  279. package/dist/types.d.ts +65 -8
  280. package/dist/types.d.ts.map +1 -1
  281. package/docs/README.md +7 -3
  282. package/docs/deployment.md +5 -4
  283. package/docs/guides/mcp-oauth.md +26 -8
  284. package/docs/guides/slack.md +93 -202
  285. package/docs/reference/agent-config.md +2 -2
  286. package/docs/reference/cli.md +39 -16
  287. package/docs/reference/connections.md +6 -3
  288. package/docs/reference/http-api.md +2 -1
  289. package/docs/reference/sessions.md +4 -2
  290. package/docs/reference/tools.md +9 -2
  291. package/docs/templates/agents-md.md +110 -0
  292. package/docs/templates/code-wiki.md +96 -0
  293. package/docs/troubleshooting.md +2 -2
  294. package/package.json +2 -2
  295. package/skills/ab/SKILL.md +13 -97
  296. package/skills/create-agent/SKILL.md +124 -223
  297. package/skills/debug/SKILL.md +34 -68
  298. package/skills/evals/SKILL.md +55 -180
  299. package/skills/framework-map/SKILL.md +83 -145
  300. package/skills/github/SKILL.md +53 -111
  301. package/skills/hillclimb/SKILL.md +40 -163
  302. package/skills/mcp-auth/SKILL.md +51 -107
  303. package/skills/otel/SKILL.md +22 -68
  304. package/skills/setup-slack/SKILL.md +91 -212
  305. package/src/bin/agent-serve.ts +13 -1
  306. package/src/channels/deployments/types.ts +1 -0
  307. package/src/channels/origin/api.ts +264 -33
  308. package/src/channels/origin/binding.ts +57 -28
  309. package/src/channels/origin/checks.ts +6 -6
  310. package/src/channels/origin/cursor-account.ts +5 -3
  311. package/src/channels/origin/index.ts +1 -0
  312. package/src/channels/origin/origin-channel.ts +4 -0
  313. package/src/channels/origin/reactions.ts +82 -0
  314. package/src/channels/origin/types.ts +11 -0
  315. package/src/channels/slack/api.ts +41 -5
  316. package/src/channels/slack/approvals.ts +105 -0
  317. package/src/channels/slack/cli-project.ts +267 -0
  318. package/src/channels/slack/defaults.ts +122 -93
  319. package/src/channels/slack/dispatch.ts +56 -22
  320. package/src/channels/slack/inbound.ts +43 -0
  321. package/src/channels/slack/init.ts +10 -5
  322. package/src/channels/slack/interactive.ts +35 -9
  323. package/src/channels/slack/live-delivery.ts +235 -114
  324. package/src/channels/slack/manifest.ts +6 -2
  325. package/src/channels/slack/nudge-carrier.ts +48 -1
  326. package/src/channels/slack/setup.ts +10 -6
  327. package/src/channels/slack/slack-channel.ts +3 -0
  328. package/src/channels/slack/tool-approval-events.ts +93 -0
  329. package/src/evals/run-facts.ts +32 -0
  330. package/src/files-backends/cursor-hosted.ts +40 -7
  331. package/src/internal/advertise-tools.ts +49 -12
  332. package/src/internal/approval-gate.ts +20 -29
  333. package/src/internal/bounded.ts +28 -0
  334. package/src/internal/chat-client.ts +19 -0
  335. package/src/internal/cli-deploy.ts +91 -9
  336. package/src/internal/cli-mcp-oauth.ts +7 -21
  337. package/src/internal/cli-slack-manual.ts +350 -18
  338. package/src/internal/cli-slack.ts +40 -84
  339. package/src/internal/conversation-mirror.ts +145 -69
  340. package/src/internal/cursor/account-mcp.ts +21 -0
  341. package/src/internal/cursor/backend-client.ts +34 -58
  342. package/src/internal/cursor/session-token.ts +115 -0
  343. package/src/internal/cursor-agent-template.ts +2 -0
  344. package/src/internal/deploy-client.ts +43 -0
  345. package/src/internal/env-file.ts +84 -0
  346. package/src/internal/framework-file-storage.ts +228 -0
  347. package/src/internal/framework-storage-selection.ts +51 -11
  348. package/src/internal/hosted-delivery-protocol.ts +7 -0
  349. package/src/internal/hosted-delivery.ts +107 -24
  350. package/src/internal/hosted-execution-diag.ts +207 -0
  351. package/src/internal/http-channel.ts +99 -0
  352. package/src/internal/init-project.ts +4 -0
  353. package/src/internal/install-cursor-skills.ts +1 -4
  354. package/src/internal/logs-client.ts +5 -0
  355. package/src/internal/managed-delivery.ts +125 -0
  356. package/src/internal/mcp-endpoint.ts +13 -4
  357. package/src/internal/mcp-host.ts +77 -11
  358. package/src/internal/mcp-oauth-on-demand.ts +352 -0
  359. package/src/internal/mcp-oauth-persist.ts +127 -0
  360. package/src/internal/mcp-oauth.ts +17 -1
  361. package/src/internal/otel/collector.ts +30 -0
  362. package/src/internal/runtime-dispatch-runner.ts +10 -0
  363. package/src/internal/sdk-runner.ts +56 -8
  364. package/src/internal/server.ts +61 -9
  365. package/src/internal/session-engine.ts +723 -60
  366. package/src/internal/sessions-client.ts +17 -8
  367. package/src/internal/steering.ts +17 -0
  368. package/src/internal/storage-coordinator.ts +38 -8
  369. package/src/internal/storage-roles.ts +7 -0
  370. package/src/internal/stream-progress.ts +19 -0
  371. package/src/internal/tool-policy.ts +18 -0
  372. package/src/internal/trajectory.ts +10 -0
  373. package/src/internal/turn-outbox.ts +85 -0
  374. package/src/storage-backends/cursor-hosted.ts +22 -8
  375. package/src/storage.ts +12 -0
  376. package/src/types.ts +70 -9
  377. package/templates/agents-md/README.md +39 -0
  378. package/templates/agents-md/agent/agent.ts +8 -0
  379. package/templates/agents-md/agent/channels/github.ts +10 -0
  380. package/templates/agents-md/agent/channels/queue.ts +28 -0
  381. package/templates/agents-md/agent/channels/slack.ts +9 -0
  382. package/templates/agents-md/agent/instructions.md +39 -0
  383. package/templates/agents-md/agent/lib/collect.ts +439 -0
  384. package/templates/agents-md/agent/lib/config.ts +8 -0
  385. package/templates/agents-md/agent/lib/paths.ts +51 -0
  386. package/templates/agents-md/agent/schedules/weekly.ts +17 -0
  387. package/templates/agents-md/agent/tools/apply_agents.ts +226 -0
  388. package/templates/agents-md/evals/agents.eval.ts +135 -0
  389. package/templates/agents-md/evals/evals.config.ts +5 -0
  390. package/templates/agents-md/init.json +38 -0
  391. package/templates/agents-md/package.json +18 -0
  392. package/templates/agents-md/tsconfig.json +12 -0
  393. package/templates/code-wiki/README.md +34 -0
  394. package/templates/code-wiki/agent/agent.ts +8 -0
  395. package/templates/code-wiki/agent/channels/github.ts +144 -0
  396. package/templates/code-wiki/agent/instructions.md +39 -0
  397. package/templates/code-wiki/agent/lib/repos.ts +5 -0
  398. package/templates/code-wiki/agent/lib/wiki.ts +22 -0
  399. package/templates/code-wiki/agent/tools/apply_wiki.ts +219 -0
  400. package/templates/code-wiki/evals/evals.config.ts +5 -0
  401. package/templates/code-wiki/evals/wiki.eval.ts +132 -0
  402. package/templates/code-wiki/init.json +25 -0
  403. package/templates/code-wiki/package.json +18 -0
  404. package/templates/code-wiki/tsconfig.json +12 -0
  405. package/dist/docs/assets/chunks/@localSearchIndexroot.oqPawjiD.js +0 -1
  406. package/dist/docs/assets/guides_slack.md.C32HsdKk.js +0 -38
  407. package/dist/docs/assets/guides_slack.md.C32HsdKk.lean.js +0 -1
  408. package/dist/docs/assets/index.md.BoHaMdeZ.js +0 -5
  409. package/dist/docs/assets/reference_sessions.md.D0mIh4KK.js +0 -1
  410. package/dist/docs/assets/troubleshooting.md.Ctv3T8C2.js +0 -1
  411. package/dist/docs/design/agsh.md +0 -406
  412. package/dist/internal/deployment-scm-event-stream.d.ts +0 -116
  413. package/dist/internal/deployment-scm-event-stream.d.ts.map +0 -1
  414. package/dist/internal/deployment-scm-event-stream.js +0 -474
  415. package/dist/playground/assets/index-CF7hUDnQ.css +0 -1
  416. package/docs/design/agsh.md +0 -406
  417. package/src/internal/deployment-scm-event-stream.ts +0 -593
  418. /package/dist/docs/assets/{deployment.md.D9msOFOW.lean.js → deployment.md.MFPKqsqI.lean.js} +0 -0
  419. /package/dist/docs/assets/{reference_agent-config.md.Cp_x38Nl.lean.js → reference_agent-config.md.BHeYMgme.lean.js} +0 -0
  420. /package/dist/docs/assets/{reference_connections.md.BH8Oc0D0.lean.js → reference_connections.md.DxldvyIB.lean.js} +0 -0
  421. /package/dist/docs/assets/{reference_http-api.md.D89k1mdm.lean.js → reference_http-api.md.5zOAbV86.lean.js} +0 -0
  422. /package/dist/docs/assets/{reference_sessions.md.D0mIh4KK.lean.js → reference_sessions.md.NxFP_CAC.lean.js} +0 -0
  423. /package/dist/docs/assets/{reference_tools.md.BHeXn2id.lean.js → reference_tools.md.B84gw9Ii.lean.js} +0 -0
  424. /package/dist/docs/assets/{troubleshooting.md.Ctv3T8C2.lean.js → troubleshooting.md.DCiPBhYs.lean.js} +0 -0
@@ -0,0 +1,210 @@
1
+ /**
2
+ * Framework-level file storage for v2 hosted engines.
3
+ *
4
+ * Hosted deployments carry two file stores with different audiences:
5
+ *
6
+ * - the **user-level** store (`AGENT_SERVE_STORE_SOURCE_ID`) holds
7
+ * author-facing bytes — `ctx.host.files`, skills, memory, artifacts — and
8
+ * is browsable from the dashboard and mountable on cloud-runtime VMs;
9
+ * - the **framework-level** store (`AGENT_SERVE_FRAMEWORK_STORE_SOURCE_ID`)
10
+ * holds engine-owned session state — session records, event transcripts,
11
+ * the continuation index, and the SDK conversation mirror — and is never
12
+ * exposed to authors or models.
13
+ *
14
+ * This module puts framework session state on the framework store. The
15
+ * {@link storageKeys} scheme was designed for exactly this: keys are a
16
+ * stable versioned contract that sinks may route on, so
17
+ * {@link composeFrameworkStorage} splits one {@link StorageConfig} by key
18
+ * kind — `session` / `session-events` / `continuation` go to the framework
19
+ * file store (file-shaped; the store accepts values up to 64 MiB per
20
+ * object without chunking, versus the KV proxy's 1 MiB row cap), while
21
+ * author `kv`, eval runs, A/B samples, and conditional writes stay on the
22
+ * control-plane KV proxy (the dashboard reads them there, and CAS needs a
23
+ * database).
24
+ *
25
+ * v2 only, by construction: the composite is selected in
26
+ * framework-storage-selection.ts, which v1 never reaches with a
27
+ * platform-selected definition.
28
+ */
29
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
30
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
31
+ return new (P || (P = Promise))(function (resolve, reject) {
32
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
33
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
34
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
35
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
36
+ });
37
+ };
38
+ import { STORAGE_KEY_ROOT } from "../storage-protocol.js";
39
+ import { mapBounded } from "./bounded.js";
40
+ /**
41
+ * Key kinds (`agentkit/v1/{agent}/{kind}/…`) that live on the framework
42
+ * file store. Everything else stays on the KV sink.
43
+ */
44
+ const FRAMEWORK_FILE_KINDS = new Set([
45
+ "session",
46
+ "session-events",
47
+ "continuation",
48
+ ]);
49
+ /**
50
+ * Whether a framework-minted key (or list prefix) belongs on the framework
51
+ * file store. Prefixes used by the coordinator are always at least
52
+ * kind-scoped (`…/{agent}/session/`), so a prefix routes wholly to one side.
53
+ */
54
+ export function isFrameworkFileKey(key) {
55
+ if (!key.startsWith(`${STORAGE_KEY_ROOT}/`)) {
56
+ return false;
57
+ }
58
+ const rest = key.slice(STORAGE_KEY_ROOT.length + 1);
59
+ const agentEnd = rest.indexOf("/");
60
+ if (agentEnd === -1) {
61
+ return false;
62
+ }
63
+ const afterAgent = rest.slice(agentEnd + 1);
64
+ const kindEnd = afterAgent.indexOf("/");
65
+ const kind = kindEnd === -1 ? afterAgent : afterAgent.slice(0, kindEnd);
66
+ return FRAMEWORK_FILE_KINDS.has(kind);
67
+ }
68
+ /**
69
+ * Adapt a {@link FileSink} to the `defineStorage` KV core. Storage keys are
70
+ * framework-minted (URI-encoded, length-bounded segments — see
71
+ * {@link storageKeys}), so they are used as file keys verbatim; values are
72
+ * stored as JSON bytes. Parse failures throw: on the lazy-restore path a
73
+ * corrupt document must fail the follow-up rather than read as a miss, and
74
+ * the startup bulk restore already logs-and-skips a throwing `list`.
75
+ */
76
+ /** Parallel per-key reads backing `list` (each is presign + object GET). */
77
+ const LIST_READ_CONCURRENCY = 8;
78
+ /**
79
+ * A storage key whose path the file store cannot represent (an empty, `.`,
80
+ * or `..` segment — possible only through caller-controlled segments such
81
+ * as continuation tokens or a caller-supplied session id). Such an object
82
+ * can never exist in the store, so reads are a definitive miss rather than
83
+ * a per-request 400 that the lazy-restore path would propagate forever.
84
+ */
85
+ function isUnrepresentableFileKey(key) {
86
+ return key
87
+ .split("/")
88
+ .some((segment) => segment === "" || segment === "." || segment === "..");
89
+ }
90
+ export function fileSinkStorageCore(sink) {
91
+ return {
92
+ put(key, value) {
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ if (isUnrepresentableFileKey(key)) {
95
+ // Loud rather than silent: the coordinator logs and drops failed
96
+ // mirror writes (at-most-once), and awaited callers must not
97
+ // believe an impossible write landed.
98
+ throw new Error(`framework file storage: key "${key}" has a path segment the store cannot represent`);
99
+ }
100
+ yield sink.put(key, new TextEncoder().encode(JSON.stringify(value)));
101
+ });
102
+ },
103
+ get(key) {
104
+ return __awaiter(this, void 0, void 0, function* () {
105
+ if (isUnrepresentableFileKey(key)) {
106
+ return undefined;
107
+ }
108
+ const body = yield sink.get(key);
109
+ if (body === undefined) {
110
+ return undefined;
111
+ }
112
+ return decodeDocument(key, body instanceof Uint8Array ? body : body.body);
113
+ });
114
+ },
115
+ delete(key) {
116
+ return __awaiter(this, void 0, void 0, function* () {
117
+ if (isUnrepresentableFileKey(key)) {
118
+ return;
119
+ }
120
+ yield sink.delete(key);
121
+ });
122
+ },
123
+ list(prefix) {
124
+ return __awaiter(this, void 0, void 0, function* () {
125
+ const entries = yield sink.list(prefix);
126
+ // FileSink.list returns metadata only, so each value is its own
127
+ // read; bound the fan-out — a bulk read here sits on restore paths.
128
+ const bodies = yield mapBounded(entries, LIST_READ_CONCURRENCY, (entry) => sink.get(entry.key));
129
+ const out = [];
130
+ for (let index = 0; index < entries.length; index += 1) {
131
+ const entry = entries[index];
132
+ const body = bodies[index];
133
+ if (entry === undefined || body === undefined) {
134
+ // Deleted between list and read; a miss is not corruption.
135
+ continue;
136
+ }
137
+ out.push({
138
+ key: entry.key,
139
+ value: decodeDocument(entry.key, body instanceof Uint8Array ? body : body.body),
140
+ });
141
+ }
142
+ return out;
143
+ });
144
+ },
145
+ };
146
+ }
147
+ function decodeDocument(key, bytes) {
148
+ try {
149
+ return JSON.parse(new TextDecoder().decode(bytes));
150
+ }
151
+ catch (error) {
152
+ throw new Error(`framework file storage: stored document at "${key}" is not JSON (${error instanceof Error ? error.message : String(error)})`);
153
+ }
154
+ }
155
+ /**
156
+ * Split one storage core by key kind: framework session state to `files`,
157
+ * everything else to `kv`. Spread over the KV backend when building the
158
+ * full definition so its `evals` / `abs` groups (and the cursor-hosted
159
+ * marker) ride along untouched; wrap the KV `cas` group with
160
+ * {@link frameworkGuardedCas} rather than spreading it as-is.
161
+ */
162
+ export function composeFrameworkStorage(input) {
163
+ const route = (key) => isFrameworkFileKey(key) ? input.files : input.kv;
164
+ return {
165
+ put: (key, value, ctx) => route(key).put(key, value, ctx),
166
+ get: (key, ctx) => route(key).get(key, ctx),
167
+ delete: (key, ctx) => route(key).delete(key, ctx),
168
+ list: (prefix, ctx) => route(prefix).list(prefix, ctx),
169
+ // Session records — the only `listNewest` consumer — are framework file
170
+ // keys, and the file store has no write-time ordering. Spreading the KV
171
+ // backend's `listNewest` through would query rows that live elsewhere
172
+ // (stale KV leftovers, or nothing), so the composed core explicitly has
173
+ // none and the engine falls back to the routed `list`.
174
+ listNewest: undefined,
175
+ };
176
+ }
177
+ /**
178
+ * The KV backend's conditional writes, refusing framework-file keys.
179
+ *
180
+ * CAS runs on the KV proxy (a database row version); the plain core routes
181
+ * framework session state to the file store. A future coordination path
182
+ * that CASes a `session/` or `continuation/` key would otherwise read and
183
+ * write a different store than the plain path — silent split-brain. Fail
184
+ * loudly instead; nothing in the package CASes those kinds today.
185
+ */
186
+ export function frameworkGuardedCas(cas) {
187
+ const refuse = (key) => {
188
+ if (isFrameworkFileKey(key)) {
189
+ throw new Error(`framework file storage: conditional writes are KV-only, but "${key}" routes to the framework file store`);
190
+ }
191
+ };
192
+ return {
193
+ getWithVersion: (key, ctx) => {
194
+ refuse(key);
195
+ return cas.getWithVersion(key, ctx);
196
+ },
197
+ putIfAbsent: (key, value, ctx) => {
198
+ refuse(key);
199
+ return cas.putIfAbsent(key, value, ctx);
200
+ },
201
+ putIfVersion: (key, value, expectedVersion, ctx) => {
202
+ refuse(key);
203
+ return cas.putIfVersion(key, value, expectedVersion, ctx);
204
+ },
205
+ listKeys: (prefix, ctx) => {
206
+ refuse(prefix);
207
+ return cas.listKeys(prefix, ctx);
208
+ },
209
+ };
210
+ }
@@ -17,11 +17,17 @@
17
17
  *
18
18
  * - **Cursor-managed hosting** (the deployment-generation environment
19
19
  * variable is set, same signal that registers `GET /v1/manifest`):
20
- * the Cursor-hosted backend, so session records, event chunks, `host.kv`,
21
- * eval runs, and A/B samples land in the control plane and survive pod
22
- * replacement. The API key resolves through the full credential chain on
23
- * every call because hosted freeze snapshots listen unsigned and the
24
- * binder drops the key file after restore.
20
+ * the Cursor-hosted backend. When the deployment carries a
21
+ * **framework-level file store**
22
+ * (`AGENT_SERVE_FRAMEWORK_STORE_SOURCE_ID`), session records, event
23
+ * transcripts, and the continuation index live there file-shaped state
24
+ * on file storage, apart from the author-facing user store — while
25
+ * `host.kv`, eval runs, A/B samples, and conditional writes stay on the
26
+ * control-plane KV proxy (see framework-file-storage.ts). Without one
27
+ * (a deploy predating framework-store provisioning), everything goes to
28
+ * the KV proxy as before. The API key resolves through the full
29
+ * credential chain on every call because hosted freeze snapshots listen
30
+ * unsigned and the binder drops the key file after restore.
25
31
  * - **Self-hosted**: no mirror. `--state-root` is the durable copy, which
26
32
  * is correct when the operator owns the disk.
27
33
  *
@@ -1 +1 @@
1
- {"version":3,"file":"framework-storage-selection.d.ts","sourceRoot":"","sources":["../../src/internal/framework-storage-selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAiB,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIrD,MAAM,WAAW,8BAA8B;IAC7C,2FAA2F;IAC3F,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACjD,0DAA0D;IAC1D,QAAQ,CAAC,YAAY,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACtD,iEAAiE;IACjE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CACnD;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,8BAA8B,GACpC,iBAAiB,GAAG,SAAS,CA2B/B"}
1
+ {"version":3,"file":"framework-storage-selection.d.ts","sourceRoot":"","sources":["../../src/internal/framework-storage-selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAMH,OAAO,EAAiB,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AASrD,MAAM,WAAW,8BAA8B;IAC7C,2FAA2F;IAC3F,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACjD,0DAA0D;IAC1D,QAAQ,CAAC,YAAY,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACtD,iEAAiE;IACjE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CACnD;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,8BAA8B,GACpC,iBAAiB,GAAG,SAAS,CAoD/B"}
@@ -17,11 +17,17 @@
17
17
  *
18
18
  * - **Cursor-managed hosting** (the deployment-generation environment
19
19
  * variable is set, same signal that registers `GET /v1/manifest`):
20
- * the Cursor-hosted backend, so session records, event chunks, `host.kv`,
21
- * eval runs, and A/B samples land in the control plane and survive pod
22
- * replacement. The API key resolves through the full credential chain on
23
- * every call because hosted freeze snapshots listen unsigned and the
24
- * binder drops the key file after restore.
20
+ * the Cursor-hosted backend. When the deployment carries a
21
+ * **framework-level file store**
22
+ * (`AGENT_SERVE_FRAMEWORK_STORE_SOURCE_ID`), session records, event
23
+ * transcripts, and the continuation index live there file-shaped state
24
+ * on file storage, apart from the author-facing user store — while
25
+ * `host.kv`, eval runs, A/B samples, and conditional writes stay on the
26
+ * control-plane KV proxy (see framework-file-storage.ts). Without one
27
+ * (a deploy predating framework-store provisioning), everything goes to
28
+ * the KV proxy as before. The API key resolves through the full
29
+ * credential chain on every call because hosted freeze snapshots listen
30
+ * unsigned and the binder drops the key file after restore.
25
31
  * - **Self-hosted**: no mirror. `--state-root` is the durable copy, which
26
32
  * is correct when the operator owns the disk.
27
33
  *
@@ -33,10 +39,12 @@
33
39
  * the session store; what this selects is the durable mirror *beyond* the
34
40
  * pod's filesystem.
35
41
  */
42
+ import { cursorFrameworkStoreSourceId, cursorHostedFiles, } from "../files-backends/cursor-hosted.js";
36
43
  import { defineStorage } from "../storage.js";
37
44
  import { cursorHostedStorage } from "../storage-backends/cursor-hosted.js";
38
45
  import { resolveApiKeySync } from "./cursor/credentials.js";
39
46
  import { AGENT_SERVE_GENERATION_ENV_VAR } from "./cursor-relay-core.js";
47
+ import { composeFrameworkStorage, fileSinkStorageCore, frameworkGuardedCas, } from "./framework-file-storage.js";
40
48
  /**
41
49
  * Pick the backend for framework session state.
42
50
  *
@@ -60,10 +68,29 @@ export function selectFrameworkStorageDefinition(input) {
60
68
  // Self-hosted v2: the state root is the durable copy.
61
69
  return undefined;
62
70
  }
63
- return defineStorage(Object.assign({ name: "cursor-hosted" }, cursorHostedStorage({
64
- // Full chain (env key file stored login): frozen engines listen
65
- // unsigned and bind CURSOR_API_KEY_FILE at task time, after this
66
- // definition is constructed.
67
- apiKey: () => { var _a; return (_a = resolveApiKeySync()) === null || _a === void 0 ? void 0 : _a.apiKey; },
68
- })));
71
+ // Hosted v2 pods wake per delivery: bulk-restoring up to the default
72
+ // 1000 sessions on every boot is waste (and against the file-store
73
+ // backend it is per-key HTTP round trips before the listener even
74
+ // comes up). Follow-ups restore lazily by continuation or session id;
75
+ // GET /v1/sessions lists from the sink either way.
76
+ const policy = { restore: "off" };
77
+ // Full chain (env → key file → stored login): frozen engines listen
78
+ // unsigned and bind CURSOR_API_KEY_FILE at task time, after this
79
+ // definition is constructed.
80
+ const resolveApiKey = () => { var _a; return (_a = resolveApiKeySync()) === null || _a === void 0 ? void 0 : _a.apiKey; };
81
+ const kv = cursorHostedStorage({ resolveApiKey });
82
+ const frameworkStoreId = cursorFrameworkStoreSourceId(env);
83
+ if (frameworkStoreId === undefined) {
84
+ return defineStorage(Object.assign({ name: "cursor-hosted", policy }, kv));
85
+ }
86
+ // Framework session state on the framework-level file store; author kv,
87
+ // evals, and A/B tables stay on the KV proxy (spread from `kv`, which
88
+ // also carries the cursor-hosted marker for GET /v1/sessions).
89
+ return defineStorage(Object.assign(Object.assign(Object.assign({ name: "cursor-hosted (framework files)", policy }, kv), composeFrameworkStorage({
90
+ kv,
91
+ files: fileSinkStorageCore(cursorHostedFiles({ storeSourceId: frameworkStoreId, resolveApiKey })),
92
+ })), {
93
+ // CAS stays on the KV proxy but must refuse framework-file keys, or a
94
+ // future coordination path would split-brain against the plain core.
95
+ cas: frameworkGuardedCas(kv.cas) }));
69
96
  }
@@ -2,6 +2,13 @@ export declare const HOSTED_DELIVERY_PROTOCOL_VERSION = 2;
2
2
  export declare const HOSTED_DELIVERY_HEADER = "x-agent-sdk-hosted-delivery";
3
3
  export declare const HOSTED_ADMISSION_PATH = "/v1/internal/hosted-admission";
4
4
  export declare const HOSTED_EXECUTION_PATH = "/v1/internal/hosted-execution";
5
+ /**
6
+ * Filename under the serve `--state-root` (not the per-slug SessionEngine
7
+ * dir). Hosted freeze uses `/workspace/.agent-serve`; the Temporal host
8
+ * reads this path after hosted-execution and logs it on the activity span.
9
+ * Must match `AGENT_SERVE_ENGINE_HOSTED_EXECUTION_DIAG_PATH` basename.
10
+ */
11
+ export declare const HOSTED_EXECUTION_DIAG_FILENAME = "hosted-execution.json";
5
12
  export type HostedAdmissionManagedAutomation = {
6
13
  automationUuid: string;
7
14
  mcpServerNames: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"hosted-delivery-prot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,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhE,MAAM,MAAM,eAAe,GAAG;IAC5B,CAAC,EAAE,CAAC,CAAC;IACL,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,EAAE,IAAI,CAAC;IACT,CAAC,EAAE,CAAC,CAAC;IACL,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAsDF,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,GACb,eAAe,GAAG,SAAS,CAuB7B;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,GACb,eAAe,GAAG,SAAS,CAe7B;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,OAAO,GACb,sBAAsB,GAAG,SAAS,CAkBpC"}
@@ -2,6 +2,13 @@ export const HOSTED_DELIVERY_PROTOCOL_VERSION = 2;
2
2
  export const HOSTED_DELIVERY_HEADER = "x-agent-sdk-hosted-delivery";
3
3
  export const HOSTED_ADMISSION_PATH = "/v1/internal/hosted-admission";
4
4
  export const HOSTED_EXECUTION_PATH = "/v1/internal/hosted-execution";
5
+ /**
6
+ * Filename under the serve `--state-root` (not the per-slug SessionEngine
7
+ * dir). Hosted freeze uses `/workspace/.agent-serve`; the Temporal host
8
+ * reads this path after hosted-execution and logs it on the activity span.
9
+ * Must match `AGENT_SERVE_ENGINE_HOSTED_EXECUTION_DIAG_PATH` basename.
10
+ */
11
+ export const HOSTED_EXECUTION_DIAG_FILENAME = "hosted-execution.json";
5
12
  const DELIVERY_KEYS = new Set([
6
13
  "v",
7
14
  "channelId",
@@ -32,6 +32,19 @@ export declare function registerHostedDeliveryRoute(input: {
32
32
  definition: object;
33
33
  }>;
34
34
  buildHandlerArgs(channelId: string, sessionPublicId?: string): ChannelHandlerArgs;
35
+ /**
36
+ * Await the session's durable mirror (dispatch chain + storage queue)
37
+ * before the execution reply: the control plane may park the pod the
38
+ * moment the reply lands, and a shed session-record flush would strand
39
+ * the conversation on the next wake.
40
+ */
41
+ drainSessionDurability?(sessionId: string): Promise<void>;
42
+ /**
43
+ * Serve `--state-root` (not the per-slug SessionEngine dir). Hosted
44
+ * freeze is `/workspace/.agent-serve`; the Temporal host reads
45
+ * `hosted-execution.json` from that path after the POST returns.
46
+ */
47
+ stateRoot?: string;
35
48
  }): void;
36
49
  export {};
37
50
  //# sourceMappingURL=hosted-delivery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hosted-delivery.d.ts","sourceRoot":"","sources":["../../src/internal/hosted-delivery.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAEV,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AASrB,OAAO,EAKL,KAAK,eAAe,EAGrB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,KAAK,aAAa,GAAG;IACnB,QAAQ,EAAE,eAAe,CAAC;IAC1B,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;AA6DF;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,aAAa,GACnB,OAAO,CAAC,iBAAiB,CAAC,CAa5B;AA2GD,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,KAAK,C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e,CAAC,EAAE,MAAM,GACvB,kBAAkB,CAAC;IACtB;;;;;OAKG;IACH,sBAAsB,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,IAAI,CAsOP"}
@@ -12,6 +12,7 @@ import { dispatchGitHubWebhook, getGitHubChannelOptions, getGitHubDispatchOutcom
12
12
  import { createDeferredChannelSession, DeferredChannelSessionError, } from "./deferred-channel-session.js";
13
13
  import { HostedAdmissionLocalSendError, runDuringHostedAdmission, } from "./hosted-admission-context.js";
14
14
  import { HOSTED_ADMISSION_PATH, HOSTED_DELIVERY_HEADER, HOSTED_DELIVERY_PROTOCOL_VERSION, HOSTED_EXECUTION_PATH, parseHostedAdmission, parseHostedExecution, } from "./hosted-delivery-protocol.js";
15
+ import { abortReasonFromTurnStatus, HOSTED_EXECUTION_DIAG_RUNNING_STATUS, hostedExecutionDiagId, writeHostedExecutionDiag, } from "./hosted-execution-diag.js";
15
16
  import { recordHostedManagedAutomation } from "./hosted-managed-automation.js";
16
17
  import { errorResponse, readJsonObject } from "./http-channel.js";
17
18
  /**
@@ -247,30 +248,74 @@ export function registerHostedDeliveryRoute(input) {
247
248
  }
248
249
  admitted.sessionPublicId = execution.sessionPublicId;
249
250
  (_a = admitted.execution) !== null && _a !== void 0 ? _a : (admitted.execution = (() => __awaiter(this, void 0, void 0, function* () {
250
- const args = input.buildHandlerArgs(admitted.send.channelId, execution.sessionPublicId);
251
- const session = yield args.send(admitted.send.message, Object.assign(Object.assign({}, admitted.send.options), { mailboxContinuation: {
252
- key: admitted.send.mailboxContinuationKey,
253
- } }));
254
- const outcome = yield session.waitForCompletion();
255
- if (outcome.status !== "finished") {
251
+ var _a;
252
+ const startedAt = performance.now();
253
+ const executionId = hostedExecutionDiagId(execution.admissionToken);
254
+ const writeDiag = (fields) => __awaiter(this, void 0, void 0, function* () {
255
+ if (input.stateRoot === undefined) {
256
+ return;
257
+ }
258
+ const message = fields.message === undefined
259
+ ? undefined
260
+ : boundedMessage(fields.message);
261
+ yield writeHostedExecutionDiag(input.stateRoot, Object.assign(Object.assign(Object.assign({ v: 1, executionId, writtenAt: new Date().toISOString(), sessionPublicId: execution.sessionPublicId, sessionId: fields.sessionId, turnStatus: fields.turnStatus, durationMs: Math.max(0, Math.round(performance.now() - startedAt)) }, (message === undefined ? {} : { message })), (message !== undefined && /abort/i.test(message)
262
+ ? { signalAborted: true }
263
+ : {})), (fields.abortReason === undefined
264
+ ? {}
265
+ : { abortReason: fields.abortReason })));
266
+ });
267
+ // Claim the file before the turn runs. The host reads it after its
268
+ // own POST returns, which for a 9-minute timeout is while this turn
269
+ // is still going; without this marker that read would surface the
270
+ // PREVIOUS delivery's terminal record as if it were this one's.
271
+ yield writeDiag({
272
+ sessionId: "",
273
+ turnStatus: HOSTED_EXECUTION_DIAG_RUNNING_STATUS,
274
+ });
275
+ try {
276
+ const args = input.buildHandlerArgs(admitted.send.channelId, execution.sessionPublicId);
277
+ const session = yield args.send(admitted.send.message, Object.assign(Object.assign({}, admitted.send.options), { mailboxContinuation: {
278
+ key: admitted.send.mailboxContinuationKey,
279
+ } }));
280
+ const outcome = yield session.waitForCompletion();
281
+ // Failed turns drain too: their record/continuation updates must
282
+ // survive the park just like a finished turn's.
283
+ yield (_a = input.drainSessionDurability) === null || _a === void 0 ? void 0 : _a.call(input, session.id);
284
+ yield writeDiag({
285
+ sessionId: session.id,
286
+ turnStatus: outcome.status,
287
+ message: outcome.errorMessage,
288
+ abortReason: abortReasonFromTurnStatus(outcome.status, outcome.errorMessage),
289
+ });
290
+ if (outcome.status !== "finished") {
291
+ return {
292
+ status: 503,
293
+ body: {
294
+ ok: false,
295
+ error: "turn_failed",
296
+ turnStatus: outcome.status,
297
+ message: outcome.errorMessage,
298
+ },
299
+ };
300
+ }
256
301
  return {
257
- status: 503,
302
+ status: 200,
258
303
  body: {
259
- ok: false,
260
- error: "turn_failed",
261
- turnStatus: outcome.status,
262
- message: outcome.errorMessage,
304
+ ok: true,
305
+ v: HOSTED_DELIVERY_PROTOCOL_VERSION,
306
+ outcome: "send",
263
307
  },
264
308
  };
265
309
  }
266
- return {
267
- status: 200,
268
- body: {
269
- ok: true,
270
- v: HOSTED_DELIVERY_PROTOCOL_VERSION,
271
- outcome: "send",
272
- },
273
- };
310
+ catch (error) {
311
+ yield writeDiag({
312
+ sessionId: "",
313
+ turnStatus: "error",
314
+ message: error instanceof Error ? error.message : String(error),
315
+ abortReason: "execute_throw",
316
+ });
317
+ throw error;
318
+ }
274
319
  }))());
275
320
  const reply = yield admitted.execution;
276
321
  return finish(Response.json(reply.body, { status: reply.status }));
@@ -0,0 +1,48 @@
1
+ export declare const HOSTED_EXECUTION_DIAG_VERSION = 1;
2
+ /** Cap so a runaway message cannot fill the guest disk or the host log. */
3
+ export declare const HOSTED_EXECUTION_DIAG_MAX_BYTES = 4096;
4
+ /**
5
+ * Correlate the on-disk record with the execution that produced it. One pod
6
+ * serves many deliveries of a continuation session, and the file lives at a
7
+ * single fixed path, so without this the host can read a *previous*
8
+ * delivery's terminal record whenever July never reaches its own write —
9
+ * the 9-minute host POST timeout, a 409 on an expired admission token, or a
10
+ * replayed token that short-circuits on the memoized reply.
11
+ *
12
+ * Derived from the admission token (which both sides already hold) rather
13
+ * than carried on the wire. The digest is one-way, so the token itself never
14
+ * reaches the guest disk or the host logs.
15
+ */
16
+ export declare function hostedExecutionDiagId(admissionToken: string): string;
17
+ export type HostedExecutionDiagAbortReason = "signal_abort" | "runner_cancelled" | "runner_error" | "execute_throw";
18
+ /**
19
+ * Bounded guest-side record of one hosted-execution attempt. No prompt,
20
+ * tool content, or API key — the host copies known keys onto the Temporal
21
+ * activity span for Datadog.
22
+ */
23
+ export type HostedExecutionDiag = {
24
+ v: typeof HOSTED_EXECUTION_DIAG_VERSION;
25
+ /** {@link hostedExecutionDiagId} of the execution that wrote this record. */
26
+ executionId: string;
27
+ writtenAt: string;
28
+ sessionPublicId: string;
29
+ sessionId: string;
30
+ /** Terminal {@link TurnOutcome} status, or `running` before the turn ends. */
31
+ turnStatus: string;
32
+ durationMs: number;
33
+ message?: string;
34
+ signalAborted?: boolean;
35
+ requestId?: string;
36
+ abortReason?: HostedExecutionDiagAbortReason;
37
+ };
38
+ /** Written before the turn starts so a stalled execution still has a record. */
39
+ export declare const HOSTED_EXECUTION_DIAG_RUNNING_STATUS = "running";
40
+ export declare function hostedExecutionDiagPath(stateRoot: string): string;
41
+ export declare function abortReasonFromTurnStatus(status: string, message: string | undefined): HostedExecutionDiagAbortReason | undefined;
42
+ export declare function parseHostedExecutionDiag(raw: string): HostedExecutionDiag | undefined;
43
+ /**
44
+ * Overwrite the per-execution diag file. Soft-fail: a write error must not
45
+ * change the hosted-execution HTTP reply.
46
+ */
47
+ export declare function writeHostedExecutionDiag(stateRoot: string, diag: HostedExecutionDiag): Promise<void>;
48
+ //# sourceMappingURL=hosted-execution-diag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosted-execution-diag.d.ts","sourceRoot":"","sources":["../../src/internal/hosted-execution-diag.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,6BAA6B,IAAI,CAAC;AAC/C,2EAA2E;AAC3E,eAAO,MAAM,+BAA+B,OAAO,CAAC;AAEpD;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED,MAAM,MAAM,8BAA8B,GACtC,cAAc,GACd,kBAAkB,GAClB,cAAc,GACd,eAAe,CAAC;AAEpB;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,CAAC,EAAE,OAAO,6BAA6B,CAAC;IACxC,6EAA6E;IAC7E,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,UA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