@cursor/july 0.1.105 → 0.1.108

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 (395) hide show
  1. package/README.md +10 -5
  2. package/dist/bin/agent-serve.js +31 -16
  3. package/dist/channels/bitbucket/types.d.ts +2 -4
  4. package/dist/channels/bitbucket/types.d.ts.map +1 -1
  5. package/dist/channels/deployments/types.d.ts +5 -8
  6. package/dist/channels/deployments/types.d.ts.map +1 -1
  7. package/dist/channels/github/github-channel.js +8 -5
  8. package/dist/channels/github/types.d.ts +7 -5
  9. package/dist/channels/github/types.d.ts.map +1 -1
  10. package/dist/channels/gitlab/types.d.ts +2 -5
  11. package/dist/channels/gitlab/types.d.ts.map +1 -1
  12. package/dist/channels/origin/origin-channel.d.ts.map +1 -1
  13. package/dist/channels/origin/origin-channel.js +27 -13
  14. package/dist/channels/origin/types.d.ts +7 -4
  15. package/dist/channels/origin/types.d.ts.map +1 -1
  16. package/dist/channels/slack/defaults.d.ts.map +1 -1
  17. package/dist/channels/slack/defaults.js +3 -0
  18. package/dist/channels/slack/dispatch.d.ts.map +1 -1
  19. package/dist/channels/slack/dispatch.js +1 -1
  20. package/dist/channels/slack/live-delivery.d.ts.map +1 -1
  21. package/dist/channels/slack/live-delivery.js +48 -11
  22. package/dist/channels/slack/types.d.ts +4 -3
  23. package/dist/channels/slack/types.d.ts.map +1 -1
  24. package/dist/channels.d.ts +45 -0
  25. package/dist/channels.d.ts.map +1 -1
  26. package/dist/channels.js +106 -7
  27. package/dist/connections.d.ts +2 -1
  28. package/dist/connections.d.ts.map +1 -1
  29. package/dist/connections.js +2 -1
  30. package/dist/docs/404.html +3 -3
  31. package/dist/docs/ab.html +6 -6
  32. package/dist/docs/assets/{app.BVwaffdK.js → app.BASKM3M4.js} +1 -1
  33. package/dist/docs/assets/chunks/@localSearchIndexroot.BHZYsNVi.js +1 -0
  34. package/dist/docs/assets/chunks/{VPLocalSearchBox.WuWTZ1x8.js → VPLocalSearchBox.BOKxlYGP.js} +2 -2
  35. package/dist/docs/assets/chunks/{theme.BYdI_6sF.js → theme.DbDZW-zb.js} +2 -2
  36. package/dist/docs/assets/{deployment.md.MFPKqsqI.js → deployment.md.JenwuCCB.js} +4 -4
  37. package/dist/docs/assets/{deployment.md.MFPKqsqI.lean.js → deployment.md.JenwuCCB.lean.js} +1 -1
  38. package/dist/docs/assets/{evals.md.CbMoebP1.js → evals.md.C1ekS3k2.js} +1 -1
  39. package/dist/docs/assets/guides_cloud-agents.md.BsloyHdY.js +9 -0
  40. package/dist/docs/assets/{guides_cloud-agents.md.DS8RIjwx.lean.js → guides_cloud-agents.md.BsloyHdY.lean.js} +1 -1
  41. package/dist/docs/assets/{guides_github.md.c0gdGJ-D.js → guides_github.md.BH33UEBJ.js} +1 -1
  42. package/dist/docs/assets/{guides_grokbot-agents.md.DVqdhBKb.js → guides_grokbot-agents.md.DyV-WArv.js} +1 -1
  43. package/dist/docs/assets/guides_improve.md.BGVk32bK.js +14 -0
  44. package/dist/docs/assets/guides_improve.md.BGVk32bK.lean.js +1 -0
  45. package/dist/docs/assets/{guides_opentelemetry.md.COh9jFVg.js → guides_opentelemetry.md.SCRMskno.js} +3 -3
  46. package/dist/docs/assets/{guides_opentelemetry.md.COh9jFVg.lean.js → guides_opentelemetry.md.SCRMskno.lean.js} +1 -1
  47. package/dist/docs/assets/{guides_slack.md.9oHPye9o.js → guides_slack.md.D4RVMM4G.js} +3 -3
  48. package/dist/docs/assets/{guides_slack.md.9oHPye9o.lean.js → guides_slack.md.D4RVMM4G.lean.js} +1 -1
  49. package/dist/docs/assets/index.md.BjH1w2ZW.js +5 -0
  50. package/dist/docs/assets/{reference_agent-config.md.CHNpiyp4.js → reference_agent-config.md.CvoL6pof.js} +1 -1
  51. package/dist/docs/assets/{reference_channels.md.DBGcaB7m.js → reference_channels.md.D-qTqwcq.js} +2 -2
  52. package/dist/docs/assets/{reference_channels.md.DBGcaB7m.lean.js → reference_channels.md.D-qTqwcq.lean.js} +1 -1
  53. package/dist/docs/assets/{reference_cli.md.C6Lo8SEd.js → reference_cli.md.Ca26u0Es.js} +6 -6
  54. package/dist/docs/assets/{reference_cli.md.C6Lo8SEd.lean.js → reference_cli.md.Ca26u0Es.lean.js} +1 -1
  55. package/dist/docs/assets/{reference_connections.md.Di6jJAXF.js → reference_connections.md.BojkC6c5.js} +1 -1
  56. package/dist/docs/assets/{reference_extensions.md.CGmMLblt.js → reference_extensions.md.CPWt00ds.js} +1 -1
  57. package/dist/docs/assets/{scaffolding-agents.md.em43xlY1.js → scaffolding-agents.md.Kctn3OVb.js} +1 -1
  58. package/dist/docs/assets/{skills_create-agent.md.BVoWPcan.js → skills_create-agent.md.Q3h6Je-e.js} +1 -1
  59. package/dist/docs/assets/{skills_debug.md.CDbPhHfg.js → skills_debug.md.CVjCXMFF.js} +1 -1
  60. package/dist/docs/assets/{skills_debug.md.CDbPhHfg.lean.js → skills_debug.md.CVjCXMFF.lean.js} +1 -1
  61. package/dist/docs/assets/{skills_evals.md.723kpUmA.js → skills_evals.md.BhovOvrl.js} +1 -1
  62. package/dist/docs/assets/skills_framework-map.md.D-tFZhFS.js +1 -0
  63. package/dist/docs/assets/{skills_framework-map.md.haibFyoB.lean.js → skills_framework-map.md.D-tFZhFS.lean.js} +1 -1
  64. package/dist/docs/assets/{skills_github.md.D0JahM8c.js → skills_github.md.hgFX_oKY.js} +1 -1
  65. package/dist/docs/assets/{skills_otel.md.CqhobH3B.js → skills_otel.md.B5Ddv1xH.js} +1 -1
  66. package/dist/docs/assets/{style.BRuM8477.css → style.DCD_zyg3.css} +1 -1
  67. package/dist/docs/assets/troubleshooting.md.CYEAO9bM.js +1 -0
  68. package/dist/docs/building-with-agents.html +6 -6
  69. package/dist/docs/concepts.html +5 -5
  70. package/dist/docs/deployment.html +9 -9
  71. package/dist/docs/deployment.md +7 -2
  72. package/dist/docs/evals.html +8 -8
  73. package/dist/docs/evals.md +3 -2
  74. package/dist/docs/guides/agent-to-agent.html +6 -6
  75. package/dist/docs/guides/cloud-agents.html +7 -7
  76. package/dist/docs/guides/cloud-agents.md +4 -3
  77. package/dist/docs/guides/convert-automation.html +6 -6
  78. package/dist/docs/guides/github.html +7 -7
  79. package/dist/docs/guides/github.md +2 -1
  80. package/dist/docs/guides/grokbot-agents.html +7 -7
  81. package/dist/docs/guides/grokbot-agents.md +2 -2
  82. package/dist/docs/guides/human-in-the-loop.html +6 -6
  83. package/dist/docs/guides/improve.html +40 -0
  84. package/dist/docs/guides/improve.md +91 -0
  85. package/dist/docs/guides/mcp-oauth.html +6 -6
  86. package/dist/docs/guides/opentelemetry.html +8 -8
  87. package/dist/docs/guides/opentelemetry.md +3 -4
  88. package/dist/docs/guides/slack.html +8 -8
  89. package/dist/docs/guides/slack.md +2 -1
  90. package/dist/docs/guides/webhooks.html +6 -6
  91. package/dist/docs/hashmap.json +1 -1
  92. package/dist/docs/hillclimbing.html +6 -6
  93. package/dist/docs/index.html +8 -8
  94. package/dist/docs/index.md +4 -0
  95. package/dist/docs/llms-full.txt +180 -61
  96. package/dist/docs/llms.txt +1 -0
  97. package/dist/docs/quickstart.html +6 -6
  98. package/dist/docs/reference/agent-config.html +7 -7
  99. package/dist/docs/reference/agent-config.md +5 -2
  100. package/dist/docs/reference/artifacts.html +6 -6
  101. package/dist/docs/reference/channels.html +7 -7
  102. package/dist/docs/reference/channels.md +11 -19
  103. package/dist/docs/reference/cli.html +11 -11
  104. package/dist/docs/reference/cli.md +23 -13
  105. package/dist/docs/reference/connections.html +8 -8
  106. package/dist/docs/reference/connections.md +2 -1
  107. package/dist/docs/reference/extensions.html +7 -7
  108. package/dist/docs/reference/extensions.md +2 -0
  109. package/dist/docs/reference/hooks.html +6 -6
  110. package/dist/docs/reference/http-api.html +6 -6
  111. package/dist/docs/reference/instructions.html +6 -6
  112. package/dist/docs/reference/playground.html +5 -5
  113. package/dist/docs/reference/project-layout.html +6 -6
  114. package/dist/docs/reference/prompt.html +6 -6
  115. package/dist/docs/reference/result.html +6 -6
  116. package/dist/docs/reference/schedules.html +6 -6
  117. package/dist/docs/reference/sessions.html +5 -5
  118. package/dist/docs/reference/skills.html +6 -6
  119. package/dist/docs/reference/subagents.html +6 -6
  120. package/dist/docs/reference/tools.html +6 -6
  121. package/dist/docs/scaffolding-agents.html +6 -6
  122. package/dist/docs/scaffolding-agents.md +2 -1
  123. package/dist/docs/skills/ab.html +6 -6
  124. package/dist/docs/skills/create-agent.html +8 -8
  125. package/dist/docs/skills/create-agent.md +1 -1
  126. package/dist/docs/skills/debug.html +6 -6
  127. package/dist/docs/skills/debug.md +1 -1
  128. package/dist/docs/skills/evals.html +8 -8
  129. package/dist/docs/skills/evals.md +1 -1
  130. package/dist/docs/skills/framework-map.html +6 -6
  131. package/dist/docs/skills/framework-map.md +4 -2
  132. package/dist/docs/skills/github.html +8 -8
  133. package/dist/docs/skills/github.md +1 -1
  134. package/dist/docs/skills/hillclimb.html +6 -6
  135. package/dist/docs/skills/index.html +5 -5
  136. package/dist/docs/skills/mcp-auth.html +6 -6
  137. package/dist/docs/skills/otel.html +8 -8
  138. package/dist/docs/skills/otel.md +3 -3
  139. package/dist/docs/skills/setup-slack.html +6 -6
  140. package/dist/docs/storage.html +6 -6
  141. package/dist/docs/templates/agentic-owners.html +6 -6
  142. package/dist/docs/templates/agents-md.html +6 -6
  143. package/dist/docs/templates/code-wiki.html +6 -6
  144. package/dist/docs/templates/demo.html +6 -6
  145. package/dist/docs/templates/grokbot-agents.html +6 -6
  146. package/dist/docs/templates/pr-autofixer.html +6 -6
  147. package/dist/docs/templates/security-help.html +6 -6
  148. package/dist/docs/templates/security-reviewer.html +6 -6
  149. package/dist/docs/templates/triage.html +6 -6
  150. package/dist/docs/troubleshooting.html +6 -6
  151. package/dist/docs/troubleshooting.md +1 -1
  152. package/dist/extensions/improve/extension.d.ts +46 -0
  153. package/dist/extensions/improve/extension.d.ts.map +1 -0
  154. package/dist/extensions/improve/extension.js +41 -0
  155. package/dist/extensions/improve/skills/yourself.d.ts +4 -0
  156. package/dist/extensions/improve/skills/yourself.d.ts.map +1 -0
  157. package/dist/extensions/improve/skills/yourself.js +43 -0
  158. package/dist/index.d.ts +4 -5
  159. package/dist/index.d.ts.map +1 -1
  160. package/dist/index.js +3 -4
  161. package/dist/internal/builtin-tools/artifacts.d.ts.map +1 -1
  162. package/dist/internal/builtin-tools/artifacts.js +2 -3
  163. package/dist/internal/channel-route-dispatch.d.ts +13 -0
  164. package/dist/internal/channel-route-dispatch.d.ts.map +1 -0
  165. package/dist/internal/channel-route-dispatch.js +62 -0
  166. package/dist/internal/channel-state.d.ts +17 -0
  167. package/dist/internal/channel-state.d.ts.map +1 -0
  168. package/dist/internal/channel-state.js +78 -0
  169. package/dist/internal/cli-ax.d.ts +7 -0
  170. package/dist/internal/cli-ax.d.ts.map +1 -1
  171. package/dist/internal/cli-ax.js +99 -1
  172. package/dist/internal/cli-cursor.d.ts.map +1 -1
  173. package/dist/internal/cli-cursor.js +2 -0
  174. package/dist/internal/cli-deploy.d.ts.map +1 -1
  175. package/dist/internal/cli-deploy.js +61 -25
  176. package/dist/internal/cli-mcp-oauth.d.ts.map +1 -1
  177. package/dist/internal/cli-mcp-oauth.js +15 -0
  178. package/dist/internal/cli-mcp.d.ts.map +1 -1
  179. package/dist/internal/cli-mcp.js +12 -0
  180. package/dist/internal/cli-slack.d.ts.map +1 -1
  181. package/dist/internal/cli-slack.js +8 -2
  182. package/dist/internal/cursor/backend-client.d.ts +25 -0
  183. package/dist/internal/cursor/backend-client.d.ts.map +1 -1
  184. package/dist/internal/cursor/backend-client.js +57 -2
  185. package/dist/internal/cursor/credentials.d.ts +8 -2
  186. package/dist/internal/cursor/credentials.d.ts.map +1 -1
  187. package/dist/internal/cursor/credentials.js +27 -5
  188. package/dist/internal/deploy-client.d.ts +35 -0
  189. package/dist/internal/deploy-client.d.ts.map +1 -1
  190. package/dist/internal/deploy-client.js +46 -0
  191. package/dist/internal/deploy-manifest.d.ts +26 -0
  192. package/dist/internal/deploy-manifest.d.ts.map +1 -1
  193. package/dist/internal/deploy-manifest.js +99 -13
  194. package/dist/internal/describe-error.d.ts +1 -0
  195. package/dist/internal/describe-error.d.ts.map +1 -1
  196. package/dist/internal/describe-error.js +25 -0
  197. package/dist/internal/discovery/agent.d.ts.map +1 -1
  198. package/dist/internal/discovery/agent.js +1 -0
  199. package/dist/internal/discovery/info.d.ts.map +1 -1
  200. package/dist/internal/discovery/info.js +7 -3
  201. package/dist/internal/discovery/modules.d.ts +1 -1
  202. package/dist/internal/discovery/modules.d.ts.map +1 -1
  203. package/dist/internal/discovery/modules.js +1 -0
  204. package/dist/internal/discovery/project.d.ts.map +1 -1
  205. package/dist/internal/discovery/project.js +3 -0
  206. package/dist/internal/discovery/reminders.d.ts +7 -0
  207. package/dist/internal/discovery/reminders.d.ts.map +1 -0
  208. package/dist/internal/discovery/reminders.js +65 -0
  209. package/dist/internal/discovery/subagent.js +1 -0
  210. package/dist/internal/distribution.d.ts +5 -0
  211. package/dist/internal/distribution.d.ts.map +1 -1
  212. package/dist/internal/distribution.js +17 -0
  213. package/dist/internal/framework-storage-selection.d.ts +14 -3
  214. package/dist/internal/framework-storage-selection.d.ts.map +1 -1
  215. package/dist/internal/framework-storage-selection.js +36 -6
  216. package/dist/internal/guest-network.d.ts +4 -10
  217. package/dist/internal/guest-network.d.ts.map +1 -1
  218. package/dist/internal/guest-network.js +44 -26
  219. package/dist/internal/hosted-admission-adapter.d.ts +2 -0
  220. package/dist/internal/hosted-admission-adapter.d.ts.map +1 -1
  221. package/dist/internal/hosted-catch-protocol.d.ts +51 -0
  222. package/dist/internal/hosted-catch-protocol.d.ts.map +1 -0
  223. package/dist/internal/hosted-catch-protocol.js +103 -0
  224. package/dist/internal/hosted-catch.d.ts +40 -0
  225. package/dist/internal/hosted-catch.d.ts.map +1 -0
  226. package/dist/internal/hosted-catch.js +149 -0
  227. package/dist/internal/hosted-delivery-protocol.d.ts +89 -0
  228. package/dist/internal/hosted-delivery-protocol.d.ts.map +1 -1
  229. package/dist/internal/hosted-delivery-protocol.js +309 -0
  230. package/dist/internal/hosted-delivery.d.ts +20 -1
  231. package/dist/internal/hosted-delivery.d.ts.map +1 -1
  232. package/dist/internal/hosted-delivery.js +179 -36
  233. package/dist/internal/hosted-execution-diag.d.ts +4 -1
  234. package/dist/internal/hosted-execution-diag.d.ts.map +1 -1
  235. package/dist/internal/hosted-execution-diag.js +13 -4
  236. package/dist/internal/hosted-execution-flush.d.ts +3 -0
  237. package/dist/internal/hosted-execution-flush.d.ts.map +1 -1
  238. package/dist/internal/hosted-execution-flush.js +2 -4
  239. package/dist/internal/http-control-plane-session.d.ts +30 -0
  240. package/dist/internal/http-control-plane-session.d.ts.map +1 -0
  241. package/dist/internal/http-control-plane-session.js +83 -0
  242. package/dist/internal/legacy-command-guard.d.ts +22 -0
  243. package/dist/internal/legacy-command-guard.d.ts.map +1 -0
  244. package/dist/internal/legacy-command-guard.js +51 -0
  245. package/dist/internal/local-control-plane.d.ts +18 -2
  246. package/dist/internal/local-control-plane.d.ts.map +1 -1
  247. package/dist/internal/local-control-plane.js +199 -17
  248. package/dist/internal/platform-timers.d.ts +7 -0
  249. package/dist/internal/platform-timers.d.ts.map +1 -1
  250. package/dist/internal/platform-timers.js +139 -0
  251. package/dist/internal/reminder-control-plane-protocol.d.ts +189 -0
  252. package/dist/internal/reminder-control-plane-protocol.d.ts.map +1 -0
  253. package/dist/internal/reminder-control-plane-protocol.js +251 -0
  254. package/dist/internal/reminder-runner.d.ts +56 -6
  255. package/dist/internal/reminder-runner.d.ts.map +1 -1
  256. package/dist/internal/reminder-runner.js +372 -57
  257. package/dist/internal/reminder-schedule.d.ts +5 -2
  258. package/dist/internal/reminder-schedule.d.ts.map +1 -1
  259. package/dist/internal/reminder-schedule.js +8 -6
  260. package/dist/internal/reminder-store.d.ts +24 -7
  261. package/dist/internal/reminder-store.d.ts.map +1 -1
  262. package/dist/internal/reminder-store.js +6 -5
  263. package/dist/internal/request-error-status.d.ts +2 -0
  264. package/dist/internal/request-error-status.d.ts.map +1 -1
  265. package/dist/internal/request-error-status.js +22 -3
  266. package/dist/internal/resolve-prod-target.d.ts +2 -0
  267. package/dist/internal/resolve-prod-target.d.ts.map +1 -1
  268. package/dist/internal/resolve-prod-target.js +13 -0
  269. package/dist/internal/scm/pr-url.d.ts +40 -0
  270. package/dist/internal/scm/pr-url.d.ts.map +1 -1
  271. package/dist/internal/scm/pr-url.js +93 -14
  272. package/dist/internal/sdk-runner.d.ts.map +1 -1
  273. package/dist/internal/sdk-runner.js +4 -3
  274. package/dist/internal/server.d.ts.map +1 -1
  275. package/dist/internal/server.js +118 -77
  276. package/dist/internal/session-engine.d.ts +6 -6
  277. package/dist/internal/session-engine.d.ts.map +1 -1
  278. package/dist/internal/session-engine.js +100 -67
  279. package/dist/playground/assets/{index-BaQzjaNK.js → index-BMDqAeXu.js} +34 -34
  280. package/dist/playground/assets/index-LUgJoWdL.css +1 -0
  281. package/dist/playground/index.html +2 -2
  282. package/dist/reminders.d.ts +24 -5
  283. package/dist/reminders.d.ts.map +1 -1
  284. package/dist/reminders.js +28 -5
  285. package/dist/storage-backends/cursor-hosted.d.ts +6 -0
  286. package/dist/storage-backends/cursor-hosted.d.ts.map +1 -1
  287. package/dist/storage-backends/cursor-hosted.js +29 -1
  288. package/dist/types.d.ts +122 -25
  289. package/dist/types.d.ts.map +1 -1
  290. package/docs/README.md +4 -0
  291. package/docs/deployment.md +7 -2
  292. package/docs/evals.md +3 -2
  293. package/docs/guides/cloud-agents.md +4 -3
  294. package/docs/guides/github.md +2 -1
  295. package/docs/guides/grokbot-agents.md +2 -2
  296. package/docs/guides/improve.md +96 -0
  297. package/docs/guides/opentelemetry.md +3 -4
  298. package/docs/guides/slack.md +2 -1
  299. package/docs/reference/agent-config.md +5 -2
  300. package/docs/reference/channels.md +11 -19
  301. package/docs/reference/cli.md +23 -13
  302. package/docs/reference/connections.md +2 -1
  303. package/docs/reference/extensions.md +2 -0
  304. package/docs/scaffolding-agents.md +2 -1
  305. package/docs/troubleshooting.md +1 -1
  306. package/package.json +10 -3
  307. package/skills/create-agent/SKILL.md +1 -1
  308. package/skills/debug/SKILL.md +1 -1
  309. package/skills/evals/SKILL.md +1 -1
  310. package/skills/framework-map/SKILL.md +4 -2
  311. package/skills/github/SKILL.md +1 -1
  312. package/skills/otel/SKILL.md +3 -3
  313. package/src/bin/agent-serve.ts +28 -11
  314. package/src/channels/bitbucket/types.ts +2 -4
  315. package/src/channels/deployments/types.ts +5 -8
  316. package/src/channels/github/github-channel.ts +8 -8
  317. package/src/channels/github/types.ts +7 -4
  318. package/src/channels/gitlab/types.ts +2 -5
  319. package/src/channels/origin/origin-channel.ts +29 -13
  320. package/src/channels/origin/types.ts +7 -3
  321. package/src/channels/slack/defaults.ts +3 -0
  322. package/src/channels/slack/dispatch.ts +1 -0
  323. package/src/channels/slack/live-delivery.ts +53 -12
  324. package/src/channels/slack/types.ts +4 -3
  325. package/src/channels.ts +157 -10
  326. package/src/connections.ts +2 -1
  327. package/src/extensions/improve/extension.ts +70 -0
  328. package/src/extensions/improve/skills/yourself.ts +50 -0
  329. package/src/index.ts +6 -3
  330. package/src/internal/builtin-tools/artifacts.ts +2 -3
  331. package/src/internal/channel-route-dispatch.ts +66 -0
  332. package/src/internal/channel-state.ts +96 -0
  333. package/src/internal/cli-ax.ts +110 -1
  334. package/src/internal/cli-cursor.ts +4 -1
  335. package/src/internal/cli-deploy.ts +80 -22
  336. package/src/internal/cli-mcp-oauth.ts +18 -0
  337. package/src/internal/cli-mcp.ts +11 -0
  338. package/src/internal/cli-slack.ts +15 -2
  339. package/src/internal/cursor/backend-client.ts +90 -2
  340. package/src/internal/cursor/credentials.ts +35 -7
  341. package/src/internal/deploy-client.ts +70 -0
  342. package/src/internal/deploy-manifest.ts +131 -12
  343. package/src/internal/describe-error.ts +28 -0
  344. package/src/internal/discovery/agent.ts +1 -0
  345. package/src/internal/discovery/info.ts +6 -0
  346. package/src/internal/discovery/modules.ts +2 -4
  347. package/src/internal/discovery/project.ts +3 -0
  348. package/src/internal/discovery/reminders.ts +65 -0
  349. package/src/internal/discovery/subagent.ts +1 -0
  350. package/src/internal/distribution.ts +20 -0
  351. package/src/internal/framework-storage-selection.ts +43 -6
  352. package/src/internal/guest-network.ts +46 -29
  353. package/src/internal/hosted-admission-adapter.ts +2 -0
  354. package/src/internal/hosted-catch-protocol.ts +130 -0
  355. package/src/internal/hosted-catch.ts +192 -0
  356. package/src/internal/hosted-delivery-protocol.ts +483 -0
  357. package/src/internal/hosted-delivery.ts +303 -43
  358. package/src/internal/hosted-execution-diag.ts +21 -3
  359. package/src/internal/hosted-execution-flush.ts +6 -3
  360. package/src/internal/http-control-plane-session.ts +104 -0
  361. package/src/internal/legacy-command-guard.ts +59 -0
  362. package/src/internal/local-control-plane.ts +281 -22
  363. package/src/internal/platform-timers.ts +191 -0
  364. package/src/internal/reminder-control-plane-protocol.ts +512 -0
  365. package/src/internal/reminder-runner.ts +481 -57
  366. package/src/internal/reminder-schedule.ts +11 -6
  367. package/src/internal/reminder-store.ts +27 -7
  368. package/src/internal/request-error-status.ts +27 -3
  369. package/src/internal/resolve-prod-target.ts +15 -0
  370. package/src/internal/scm/pr-url.ts +167 -20
  371. package/src/internal/sdk-runner.ts +2 -1
  372. package/src/internal/server.ts +151 -88
  373. package/src/internal/session-engine.ts +146 -83
  374. package/src/reminders.ts +35 -4
  375. package/src/storage-backends/cursor-hosted.ts +40 -1
  376. package/src/types.ts +134 -26
  377. package/dist/docs/assets/chunks/@localSearchIndexroot.CJxMklAy.js +0 -1
  378. package/dist/docs/assets/guides_cloud-agents.md.DS8RIjwx.js +0 -9
  379. package/dist/docs/assets/index.md.BW_6tOgR.js +0 -5
  380. package/dist/docs/assets/skills_framework-map.md.haibFyoB.js +0 -1
  381. package/dist/docs/assets/troubleshooting.md.Cus_YZga.js +0 -1
  382. package/dist/playground/assets/index-CceqnLTX.css +0 -1
  383. /package/dist/docs/assets/{evals.md.CbMoebP1.lean.js → evals.md.C1ekS3k2.lean.js} +0 -0
  384. /package/dist/docs/assets/{guides_github.md.c0gdGJ-D.lean.js → guides_github.md.BH33UEBJ.lean.js} +0 -0
  385. /package/dist/docs/assets/{guides_grokbot-agents.md.DVqdhBKb.lean.js → guides_grokbot-agents.md.DyV-WArv.lean.js} +0 -0
  386. /package/dist/docs/assets/{index.md.BW_6tOgR.lean.js → index.md.BjH1w2ZW.lean.js} +0 -0
  387. /package/dist/docs/assets/{reference_agent-config.md.CHNpiyp4.lean.js → reference_agent-config.md.CvoL6pof.lean.js} +0 -0
  388. /package/dist/docs/assets/{reference_connections.md.Di6jJAXF.lean.js → reference_connections.md.BojkC6c5.lean.js} +0 -0
  389. /package/dist/docs/assets/{reference_extensions.md.CGmMLblt.lean.js → reference_extensions.md.CPWt00ds.lean.js} +0 -0
  390. /package/dist/docs/assets/{scaffolding-agents.md.em43xlY1.lean.js → scaffolding-agents.md.Kctn3OVb.lean.js} +0 -0
  391. /package/dist/docs/assets/{skills_create-agent.md.BVoWPcan.lean.js → skills_create-agent.md.Q3h6Je-e.lean.js} +0 -0
  392. /package/dist/docs/assets/{skills_evals.md.723kpUmA.lean.js → skills_evals.md.BhovOvrl.lean.js} +0 -0
  393. /package/dist/docs/assets/{skills_github.md.D0JahM8c.lean.js → skills_github.md.hgFX_oKY.lean.js} +0 -0
  394. /package/dist/docs/assets/{skills_otel.md.CqhobH3B.lean.js → skills_otel.md.B5Ddv1xH.lean.js} +0 -0
  395. /package/dist/docs/assets/{troubleshooting.md.Cus_YZga.lean.js → troubleshooting.md.CYEAO9bM.lean.js} +0 -0
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Per-session reminder runner: durable wake subscriptions with
3
- * prompt XOR run, every/cron/delay/at schedules, and until as
4
- * function XOR prompt.
3
+ * prompt XOR named handler XOR run, every/cron/delay/at schedules, and
4
+ * until as function XOR prompt.
5
5
  */
6
6
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
7
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -13,11 +13,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
13
13
  });
14
14
  };
15
15
  import { randomBytes } from "node:crypto";
16
+ import { channelContinuationIdentity, httpContinuationIdentity, } from "./continuation-channel.js";
17
+ import { continuationSource } from "./continuation-identity.js";
18
+ import { NAME_PATTERN } from "./discovery/names.js";
16
19
  import { parseDuration } from "./duration.js";
20
+ import { REMINDER_CP_PROTOCOL_VERSION, scheduleSpecFromCreateInput, toWireReschedule, } from "./reminder-control-plane-protocol.js";
17
21
  import { defaultBusyPolicy, MAX_TIMER_MS, nextCronFireMs, ReminderValidationError, resolveSchedule, } from "./reminder-schedule.js";
18
22
  import { APP_AUTH } from "./schedule-runner.js";
19
- import { SessionBusyError } from "./session-engine.js";
23
+ import { HTTP_CHANNEL_ID, SessionBusyError, } from "./session-engine.js";
20
24
  export { ReminderValidationError } from "./reminder-schedule.js";
25
+ /** Max UTF-8 byte length of `JSON.stringify(args)` on named-handler create. */
26
+ export const REMINDER_ARGS_MAX_BYTES = 32 * 1024;
21
27
  export class UnknownReminderError extends Error {
22
28
  constructor(reminderId, availableReminderIds) {
23
29
  super(`Unknown reminder "${reminderId}"`);
@@ -25,9 +31,46 @@ export class UnknownReminderError extends Error {
25
31
  this.name = "UnknownReminderError";
26
32
  }
27
33
  }
34
+ /**
35
+ * Server wiring for {@link ReminderRunnerOptions.rejectAnonymousHandlers}:
36
+ * architecture v2 always rejects anonymous run/until (local or hosted).
37
+ */
38
+ export function rejectAnonymousReminderHandlers(options) {
39
+ return options.architecture === "v2";
40
+ }
28
41
  function newReminderId() {
29
42
  return `rem_${randomBytes(8).toString("hex")}`;
30
43
  }
44
+ function isJsonObject(value) {
45
+ return (typeof value === "object" &&
46
+ value !== null &&
47
+ !Array.isArray(value) &&
48
+ Object.values(value).every(isJsonValue));
49
+ }
50
+ function isJsonValue(value) {
51
+ if (value === null ||
52
+ typeof value === "string" ||
53
+ typeof value === "boolean") {
54
+ return true;
55
+ }
56
+ if (typeof value === "number") {
57
+ return Number.isFinite(value);
58
+ }
59
+ if (Array.isArray(value)) {
60
+ return value.every(isJsonValue);
61
+ }
62
+ return isJsonObject(value);
63
+ }
64
+ /** Same stem rules as `agent/reminders/<name>.ts` discovery. */
65
+ function isValidReminderHandlerName(name) {
66
+ return NAME_PATTERN.test(name) && !name.includes("__");
67
+ }
68
+ function assertReminderArgsSize(args) {
69
+ const bytes = Buffer.byteLength(JSON.stringify(args), "utf8");
70
+ if (bytes > REMINDER_ARGS_MAX_BYTES) {
71
+ throw new ReminderValidationError(`reminders.create args exceed ${REMINDER_ARGS_MAX_BYTES} bytes (got ${bytes})`);
72
+ }
73
+ }
31
74
  function toInfo(record) {
32
75
  return {
33
76
  id: record.id,
@@ -38,9 +81,11 @@ function toInfo(record) {
38
81
  scheduleKind: record.scheduleKind,
39
82
  scheduleValue: record.scheduleValue,
40
83
  prompt: record.prompt,
84
+ handler: record.handler,
85
+ args: record.args,
41
86
  untilPrompt: record.untilPrompt,
42
87
  busyPolicy: record.busyPolicy,
43
- status: record.status,
88
+ status: record.status === "firing" ? "armed" : record.status,
44
89
  disarmReason: record.disarmReason,
45
90
  fireCount: record.fireCount,
46
91
  nextFireAt: new Date(record.nextFireAtMs).toISOString(),
@@ -69,17 +114,31 @@ function buildFirePrompt(record) {
69
114
  return lines.join("\n");
70
115
  }
71
116
  export class ReminderRunner {
72
- constructor(engine, logger = () => { }, platformTimers) {
117
+ constructor(engine, logger = () => { }, platformTimers, options = {}) {
118
+ var _a;
73
119
  this.engine = engine;
74
120
  this.logger = logger;
75
121
  this.platformTimers = platformTimers;
76
122
  this.records = new Map();
77
123
  this.handlers = new Map();
124
+ this.namedHandlers = new Map();
125
+ this.namedHandlerNames = new Map();
78
126
  this.timers = new Map();
79
127
  this.firing = new Set();
80
128
  /** Single-flight idle gates keyed by `channelId:continuationToken`. */
81
129
  this.idleGates = new Map();
82
130
  this.started = false;
131
+ this.rejectAnonymousHandlers = options.rejectAnonymousHandlers === true;
132
+ this.controlPlane = options.controlPlane;
133
+ this.architecture = options.architecture;
134
+ for (const reminder of (_a = options.namedHandlers) !== null && _a !== void 0 ? _a : []) {
135
+ this.namedHandlers.set(reminder.name, reminder.definition);
136
+ this.namedHandlerNames.set(reminder.definition, reminder.name);
137
+ }
138
+ }
139
+ /** True when create/cancel/rekey/fire go through the CP protocol. */
140
+ get usesControlPlaneProtocol() {
141
+ return this.controlPlane !== undefined && this.architecture === "v2";
83
142
  }
84
143
  /**
85
144
  * Load reminder documents from the control plane into memory. Does not
@@ -107,6 +166,13 @@ export class ReminderRunner {
107
166
  if (record.status !== "armed") {
108
167
  continue;
109
168
  }
169
+ if (record.handler !== undefined) {
170
+ if (this.namedHandlers.get(record.handler) === undefined) {
171
+ yield this.disarm(record, "handler_missing");
172
+ disarmedOrphan += 1;
173
+ }
174
+ continue;
175
+ }
110
176
  if ((record.hasRunHandler === true || record.hasUntilFn === true) &&
111
177
  this.handlers.get(record.id) === undefined) {
112
178
  yield this.disarm(record, "handler_lost_on_restart");
@@ -135,6 +201,16 @@ export class ReminderRunner {
135
201
  let restored = 0;
136
202
  let disarmedOrphan = 0;
137
203
  for (const record of armed) {
204
+ if (record.handler !== undefined) {
205
+ if (this.namedHandlers.get(record.handler) === undefined) {
206
+ yield this.disarm(record, "handler_missing");
207
+ disarmedOrphan += 1;
208
+ continue;
209
+ }
210
+ this.armTimer(record);
211
+ restored += 1;
212
+ continue;
213
+ }
138
214
  if ((record.hasRunHandler === true || record.hasUntilFn === true) &&
139
215
  this.handlers.get(record.id) === undefined) {
140
216
  yield this.disarm(record, "handler_lost_on_restart");
@@ -207,11 +283,13 @@ export class ReminderRunner {
207
283
  }
208
284
  create(input) {
209
285
  return __awaiter(this, void 0, void 0, function* () {
210
- var _a;
286
+ var _a, _b;
211
287
  const hasPrompt = input.prompt !== undefined;
212
288
  const hasRun = input.run !== undefined;
213
- if (hasPrompt === hasRun) {
214
- throw new ReminderValidationError("reminders.create requires exactly one of prompt or run");
289
+ const hasHandler = input.handler !== undefined;
290
+ const formCount = [hasPrompt, hasRun, hasHandler].filter(Boolean).length;
291
+ if (formCount !== 1) {
292
+ throw new ReminderValidationError("reminders.create requires exactly one of prompt, handler, or run");
215
293
  }
216
294
  if (input.continuationToken.trim() === "") {
217
295
  throw new ReminderValidationError("continuationToken is required");
@@ -222,41 +300,111 @@ export class ReminderRunner {
222
300
  if (input.purpose.trim() === "") {
223
301
  throw new ReminderValidationError("purpose is required");
224
302
  }
225
- const schedule = resolveSchedule(input);
226
- const busyPolicy = (_a = input.busyPolicy) !== null && _a !== void 0 ? _a : defaultBusyPolicy(schedule.kind);
227
- const now = new Date().toISOString();
228
- const id = newReminderId();
229
303
  const untilPrompt = typeof input.until === "string" ? input.until : undefined;
230
304
  const untilFn = typeof input.until === "function" ? input.until : undefined;
305
+ if (hasHandler && input.until !== undefined) {
306
+ throw new ReminderValidationError("reminders.create: until is not valid with handler; encode the stop condition in args and the handler body");
307
+ }
308
+ if (this.rejectAnonymousHandlers) {
309
+ if (hasRun) {
310
+ throw new ReminderValidationError("reminders.create: anonymous run handlers are not durable on architecture v2; author agent/reminders/<name>.ts and pass handler + args");
311
+ }
312
+ if (untilFn !== undefined) {
313
+ throw new ReminderValidationError("reminders.create: function until is not durable on architecture v2; use a string until prompt");
314
+ }
315
+ }
316
+ let handlerName;
317
+ let handlerArgs;
318
+ if (hasHandler) {
319
+ const handler = input.handler;
320
+ const name = typeof handler === "string"
321
+ ? handler.trim()
322
+ : this.namedHandlerNames.get(handler);
323
+ if (name === undefined) {
324
+ throw new ReminderValidationError("Unknown reminder handler definition (expected a default export discovered under agent/reminders/)");
325
+ }
326
+ if (name === "") {
327
+ throw new ReminderValidationError("handler name is required");
328
+ }
329
+ if (!isValidReminderHandlerName(name)) {
330
+ throw new ReminderValidationError(name.includes("__")
331
+ ? `Invalid reminder handler name "${name}": may not contain "__"`
332
+ : `Invalid reminder handler name "${name}": must match ${NAME_PATTERN}`);
333
+ }
334
+ if (this.namedHandlers.get(name) === undefined) {
335
+ throw new ReminderValidationError(`Unknown reminder handler "${name}" (expected agent/reminders/${name}.ts)`);
336
+ }
337
+ if (input.args !== undefined && !isJsonObject(input.args)) {
338
+ throw new ReminderValidationError("reminders.create args must be a JSON object");
339
+ }
340
+ handlerName = name;
341
+ handlerArgs = (_a = input.args) !== null && _a !== void 0 ? _a : {};
342
+ assertReminderArgsSize(handlerArgs);
343
+ }
344
+ else if (input.args !== undefined) {
345
+ throw new ReminderValidationError("reminders.create args is only valid with handler");
346
+ }
347
+ const schedule = resolveSchedule(input);
348
+ const busyPolicy = (_b = input.busyPolicy) !== null && _b !== void 0 ? _b : defaultBusyPolicy(schedule.kind);
231
349
  const hasRunHandler = input.run !== undefined;
232
350
  const hasUntilFn = untilFn !== undefined;
233
- const record = {
234
- version: 1,
235
- id,
236
- purpose: input.purpose,
237
- channelId: input.channelId,
238
- continuationToken: input.continuationToken,
239
- target: input.target,
240
- scheduleKind: schedule.kind,
241
- scheduleValue: schedule.value,
242
- intervalMs: schedule.intervalMs,
243
- prompt: input.prompt,
244
- hasRunHandler,
245
- hasUntilFn,
246
- untilPrompt,
247
- busyPolicy,
248
- status: "armed",
249
- fireCount: 0,
250
- nextFireAtMs: schedule.nextFireAtMs,
251
- createdAt: now,
252
- updatedAt: now,
253
- };
254
- yield this.persist(record);
255
- this.handlers.set(id, {
351
+ let record;
352
+ if (this.usesControlPlaneProtocol) {
353
+ const intent = {
354
+ protocolVersion: REMINDER_CP_PROTOCOL_VERSION,
355
+ purpose: input.purpose,
356
+ channelId: input.channelId,
357
+ continuationToken: input.continuationToken,
358
+ target: input.target,
359
+ // CP recalculates nextFireAtMs / intervalMs from the raw schedule.
360
+ schedule: scheduleSpecFromCreateInput(input),
361
+ prompt: input.prompt,
362
+ handler: handlerName,
363
+ args: handlerArgs,
364
+ hasRunHandler,
365
+ hasUntilFn,
366
+ untilPrompt,
367
+ busyPolicy,
368
+ };
369
+ record = yield this.controlPlane.createReminder(intent);
370
+ this.records.set(record.id, record);
371
+ }
372
+ else {
373
+ const now = new Date().toISOString();
374
+ const id = newReminderId();
375
+ record = {
376
+ version: 1,
377
+ id,
378
+ purpose: input.purpose,
379
+ channelId: input.channelId,
380
+ continuationToken: input.continuationToken,
381
+ target: input.target,
382
+ scheduleKind: schedule.kind,
383
+ scheduleValue: schedule.value,
384
+ intervalMs: schedule.intervalMs,
385
+ prompt: input.prompt,
386
+ handler: handlerName,
387
+ args: handlerArgs,
388
+ hasRunHandler,
389
+ hasUntilFn,
390
+ untilPrompt,
391
+ busyPolicy,
392
+ status: "armed",
393
+ fireCount: 0,
394
+ nextFireAtMs: schedule.nextFireAtMs,
395
+ generation: 0,
396
+ createdAt: now,
397
+ updatedAt: now,
398
+ };
399
+ yield this.persist(record);
400
+ }
401
+ this.handlers.set(record.id, {
256
402
  run: input.run,
257
403
  untilFn,
258
404
  });
259
- if (this.started && this.platformTimers === undefined) {
405
+ if (this.started &&
406
+ this.platformTimers === undefined &&
407
+ !this.usesControlPlaneProtocol) {
260
408
  this.armTimer(record);
261
409
  }
262
410
  return toInfo(record);
@@ -267,8 +415,11 @@ export class ReminderRunner {
267
415
  const all = yield this.allRecords();
268
416
  return all
269
417
  .filter((r) => {
270
- if ((filter === null || filter === void 0 ? void 0 : filter.status) !== undefined && r.status !== filter.status) {
271
- return false;
418
+ if ((filter === null || filter === void 0 ? void 0 : filter.status) !== undefined) {
419
+ const publicStatus = r.status === "firing" ? "armed" : r.status;
420
+ if (publicStatus !== filter.status) {
421
+ return false;
422
+ }
272
423
  }
273
424
  if ((filter === null || filter === void 0 ? void 0 : filter.purpose) !== undefined && r.purpose !== filter.purpose) {
274
425
  return false;
@@ -290,15 +441,27 @@ export class ReminderRunner {
290
441
  }
291
442
  cancel(id_1) {
292
443
  return __awaiter(this, arguments, void 0, function* (id, reason = "explicit_cancel") {
444
+ var _a;
445
+ if (this.usesControlPlaneProtocol) {
446
+ const updated = yield this.controlPlane.cancelReminder(id, reason);
447
+ if (updated === undefined) {
448
+ this.records.delete(id);
449
+ this.handlers.delete(id);
450
+ return undefined;
451
+ }
452
+ this.records.set(id, updated);
453
+ this.handlers.delete(id);
454
+ return toInfo(updated);
455
+ }
293
456
  const record = yield this.getRecord(id);
294
457
  if (record === undefined) {
295
458
  return undefined;
296
459
  }
297
- if (record.status !== "armed") {
460
+ if (record.status !== "armed" && record.status !== "firing") {
298
461
  return toInfo(record);
299
462
  }
300
463
  this.clearTimer(id);
301
- const updated = Object.assign(Object.assign({}, record), { status: "cancelled", disarmReason: reason, updatedAt: new Date().toISOString() });
464
+ const updated = Object.assign(Object.assign({}, record), { status: "cancelled", disarmReason: reason, generation: ((_a = record.generation) !== null && _a !== void 0 ? _a : 0) + 1, updatedAt: new Date().toISOString() });
302
465
  yield this.persist(updated);
303
466
  this.handlers.delete(id);
304
467
  return toInfo(updated);
@@ -326,14 +489,18 @@ export class ReminderRunner {
326
489
  */
327
490
  rekeyContinuation(channelId, oldToken, newToken) {
328
491
  return __awaiter(this, void 0, void 0, function* () {
329
- const armed = (yield this.allRecords()).filter((r) => r.status === "armed");
492
+ var _a;
493
+ if (this.usesControlPlaneProtocol) {
494
+ return this.controlPlane.rekeyReminders(channelId, oldToken, newToken);
495
+ }
496
+ const armed = (yield this.allRecords()).filter((r) => r.status === "armed" || r.status === "firing");
330
497
  let n = 0;
331
498
  for (const record of armed) {
332
499
  if (record.channelId !== channelId ||
333
500
  record.continuationToken !== oldToken) {
334
501
  continue;
335
502
  }
336
- yield this.persist(Object.assign(Object.assign({}, record), { continuationToken: newToken, updatedAt: new Date().toISOString() }));
503
+ yield this.persist(Object.assign(Object.assign({}, record), { continuationToken: newToken, generation: ((_a = record.generation) !== null && _a !== void 0 ? _a : 0) + 1, updatedAt: new Date().toISOString() }));
337
504
  n += 1;
338
505
  }
339
506
  return n;
@@ -359,6 +526,108 @@ export class ReminderRunner {
359
526
  return Object.assign({ reminderId }, result);
360
527
  });
361
528
  }
529
+ /**
530
+ * Architecture v2 / CP protocol guest entrypoint: execute an immutable fire
531
+ * descriptor and return an outcome. Does not mint ids or mutate
532
+ * authoritative status/fireCount — the control plane applies the outcome.
533
+ */
534
+ executeFire(descriptor) {
535
+ return __awaiter(this, void 0, void 0, function* () {
536
+ var _a;
537
+ const record = this.recordFromDescriptor(descriptor);
538
+ this.records.set(record.id, record);
539
+ const live = (_a = this.handlers.get(record.id)) !== null && _a !== void 0 ? _a : {};
540
+ if (record.handler !== undefined) {
541
+ if (this.resolveNamedHandler(record.handler) === undefined) {
542
+ return { kind: "stop", reason: "handler_missing" };
543
+ }
544
+ }
545
+ else if ((record.hasRunHandler === true || record.hasUntilFn === true) &&
546
+ live.run === undefined &&
547
+ live.untilFn === undefined) {
548
+ return { kind: "stop", reason: "handler_lost_on_restart" };
549
+ }
550
+ if (live.untilFn !== undefined) {
551
+ try {
552
+ const done = yield live.untilFn(this.buildUntilContext(record));
553
+ if (done) {
554
+ return { kind: "stop", reason: "until_fn" };
555
+ }
556
+ }
557
+ catch (error) {
558
+ this.logger(`[agent-sdk] reminder "${record.id}" until() failed: ${error instanceof Error ? error.message : String(error)}`);
559
+ }
560
+ }
561
+ if (yield this.isSessionBusy(record.channelId, record.continuationToken)) {
562
+ if (record.busyPolicy === "skipIfBusy") {
563
+ this.logger(`[agent-sdk] reminder "${record.id}" (${record.purpose}) skipped: session busy`);
564
+ return { kind: "skipped" };
565
+ }
566
+ yield this.whenSessionIdle(record.channelId, record.continuationToken);
567
+ }
568
+ let result;
569
+ if (record.handler !== undefined) {
570
+ const named = this.resolveNamedHandler(record.handler);
571
+ if (named === undefined) {
572
+ return { kind: "stop", reason: "handler_missing" };
573
+ }
574
+ result = yield named.run(this.buildFireContext(record));
575
+ }
576
+ else if (live.run !== undefined) {
577
+ result = yield live.run(this.buildFireContext(record));
578
+ }
579
+ else if (record.prompt !== undefined) {
580
+ result = yield this.deliverPrompt(record);
581
+ }
582
+ else {
583
+ return { kind: "stop", reason: "missing_handler" };
584
+ }
585
+ if (result.action === "stop") {
586
+ return { kind: "stop", reason: "run_stop" };
587
+ }
588
+ if (result.action === "skip") {
589
+ return {
590
+ kind: "skipped",
591
+ reschedule: result.reschedule !== undefined
592
+ ? toWireReschedule(result.reschedule)
593
+ : undefined,
594
+ };
595
+ }
596
+ return {
597
+ kind: "delivered",
598
+ reschedule: result.reschedule !== undefined
599
+ ? toWireReschedule(result.reschedule)
600
+ : undefined,
601
+ };
602
+ });
603
+ }
604
+ recordFromDescriptor(descriptor) {
605
+ const now = new Date().toISOString();
606
+ return {
607
+ version: 1,
608
+ id: descriptor.id,
609
+ purpose: descriptor.purpose,
610
+ channelId: descriptor.channelId,
611
+ continuationToken: descriptor.continuationToken,
612
+ target: descriptor.target,
613
+ scheduleKind: descriptor.scheduleKind,
614
+ scheduleValue: descriptor.scheduleValue,
615
+ intervalMs: descriptor.intervalMs,
616
+ prompt: descriptor.prompt,
617
+ handler: descriptor.handler,
618
+ args: descriptor.args,
619
+ hasRunHandler: descriptor.hasRunHandler,
620
+ hasUntilFn: descriptor.hasUntilFn,
621
+ untilPrompt: descriptor.untilPrompt,
622
+ busyPolicy: descriptor.busyPolicy,
623
+ status: "firing",
624
+ fireCount: descriptor.fireCount,
625
+ nextFireAtMs: descriptor.nextFireAtMs,
626
+ generation: descriptor.generation,
627
+ createdAt: now,
628
+ updatedAt: now,
629
+ };
630
+ }
362
631
  armTimer(record) {
363
632
  var _a;
364
633
  this.clearTimer(record.id);
@@ -401,6 +670,9 @@ export class ReminderRunner {
401
670
  this.timers.delete(id);
402
671
  }
403
672
  }
673
+ resolveNamedHandler(name) {
674
+ return this.namedHandlers.get(name);
675
+ }
404
676
  fire(id_1) {
405
677
  return __awaiter(this, arguments, void 0, function* (id, opts = {}) {
406
678
  var _a, _b;
@@ -420,7 +692,13 @@ export class ReminderRunner {
420
692
  return { outcome: "noop", reason: "not_due" };
421
693
  }
422
694
  const live = (_a = this.handlers.get(id)) !== null && _a !== void 0 ? _a : {};
423
- if ((record.hasRunHandler === true || record.hasUntilFn === true) &&
695
+ if (record.handler !== undefined) {
696
+ if (this.resolveNamedHandler(record.handler) === undefined) {
697
+ yield this.disarm(record, "handler_missing");
698
+ return { outcome: "noop", reason: "handler_missing" };
699
+ }
700
+ }
701
+ else if ((record.hasRunHandler === true || record.hasUntilFn === true) &&
424
702
  live.run === undefined &&
425
703
  live.untilFn === undefined) {
426
704
  yield this.disarm(record, "handler_lost_on_restart");
@@ -452,9 +730,16 @@ export class ReminderRunner {
452
730
  }
453
731
  }
454
732
  let result;
455
- if (live.run !== undefined) {
456
- const fireCtx = this.buildFireContext(record);
457
- result = yield live.run(fireCtx);
733
+ if (record.handler !== undefined) {
734
+ const named = this.resolveNamedHandler(record.handler);
735
+ if (named === undefined) {
736
+ yield this.disarm(record, "handler_missing");
737
+ return { outcome: "noop", reason: "handler_missing" };
738
+ }
739
+ result = yield named.run(this.buildFireContext(record));
740
+ }
741
+ else if (live.run !== undefined) {
742
+ result = yield live.run(this.buildFireContext(record));
458
743
  }
459
744
  else if (record.prompt !== undefined) {
460
745
  result = yield this.deliverPrompt(record);
@@ -485,7 +770,7 @@ export class ReminderRunner {
485
770
  return { outcome: "fired", reason: "skipped" };
486
771
  }
487
772
  yield this.afterFire(latest, "delivered", result.reschedule);
488
- this.logger(`[agent-sdk] reminder "${id}" (${record.purpose}) delivered`);
773
+ this.logger(`[agent-sdk] reminder "${id}" (${record.purpose}) fired`);
489
774
  return { outcome: "fired", reason: "delivered" };
490
775
  }
491
776
  finally {
@@ -534,19 +819,51 @@ export class ReminderRunner {
534
819
  return __awaiter(this, void 0, void 0, function* () {
535
820
  const auth = yield this.resolveFollowupAuth(record.channelId, record.continuationToken);
536
821
  if (auth === undefined) {
537
- yield this.disarm(record, "session_gone");
822
+ // Under CP protocol, return stop and let the CP apply/CAS; do not
823
+ // mutate authoritative status from the guest mid-fire.
824
+ if (!this.usesControlPlaneProtocol) {
825
+ yield this.disarm(record, "session_gone");
826
+ }
538
827
  return { action: "stop" };
539
828
  }
540
829
  return this.sendFollowup(record, buildFirePrompt(record), auth);
541
830
  });
542
831
  }
832
+ /**
833
+ * Join the reminder's existing session. Control-plane (`/v2`) channels
834
+ * refuse authored `continuationToken`; pass the stored key as
835
+ * {@link EngineSendOptions.mailboxContinuation} so the engine reuses the
836
+ * CP-selected identity without channel admission.
837
+ */
838
+ followupSendOptions(record, auth) {
839
+ if (this.channelUsesControlPlaneContinuation(record.channelId)) {
840
+ return {
841
+ auth,
842
+ mailboxContinuation: { key: record.continuationToken },
843
+ };
844
+ }
845
+ return {
846
+ auth,
847
+ continuationToken: record.continuationToken,
848
+ };
849
+ }
850
+ channelUsesControlPlaneContinuation(channelId) {
851
+ var _a;
852
+ const project = this.engine.project;
853
+ // Test doubles may omit `project`; keep the legacy continuationToken path.
854
+ if (project === undefined) {
855
+ return false;
856
+ }
857
+ const identity = channelId === HTTP_CHANNEL_ID
858
+ ? httpContinuationIdentity(project.httpChannel)
859
+ : channelContinuationIdentity((_a = project.channels.find((channel) => channel.id === channelId)) === null || _a === void 0 ? void 0 : _a.definition);
860
+ return continuationSource(identity) === "control-plane";
861
+ }
543
862
  sendFollowup(record, message, auth) {
544
863
  return __awaiter(this, void 0, void 0, function* () {
864
+ const sendOptions = this.followupSendOptions(record, auth);
545
865
  try {
546
- const session = yield this.engine.send(record.channelId, message, {
547
- auth,
548
- continuationToken: record.continuationToken,
549
- });
866
+ const session = yield this.engine.send(record.channelId, message, sendOptions);
550
867
  this.engine.trackBackground(this.engine.waitForCompletion(session.id));
551
868
  return { action: "delivered" };
552
869
  }
@@ -557,10 +874,7 @@ export class ReminderRunner {
557
874
  }
558
875
  yield this.whenSessionIdle(record.channelId, record.continuationToken);
559
876
  try {
560
- const session = yield this.engine.send(record.channelId, message, {
561
- auth,
562
- continuationToken: record.continuationToken,
563
- });
877
+ const session = yield this.engine.send(record.channelId, message, sendOptions);
564
878
  this.engine.trackBackground(this.engine.waitForCompletion(session.id));
565
879
  return { action: "delivered" };
566
880
  }
@@ -576,13 +890,14 @@ export class ReminderRunner {
576
890
  });
577
891
  }
578
892
  buildFireContext(record) {
579
- var _a;
893
+ var _a, _b;
580
894
  const self = this;
581
895
  return {
582
896
  id: record.id,
583
897
  purpose: record.purpose,
584
898
  fireCount: record.fireCount,
585
899
  target: Object.assign({ channelId: record.channelId, continuationToken: record.continuationToken }, ((_a = record.target) !== null && _a !== void 0 ? _a : {})),
900
+ args: (_b = record.args) !== null && _b !== void 0 ? _b : {},
586
901
  host: this.engine.host,
587
902
  mcp: this.engine.host.mcp,
588
903
  appAuth: APP_AUTH,
@@ -13,8 +13,11 @@ export interface ResolvedSchedule {
13
13
  intervalMs?: number;
14
14
  nextFireAtMs: number;
15
15
  }
16
- /** Resolve create-input schedule fields into a concrete next-fire plan. */
17
- export declare function resolveSchedule(input: ReminderCreateInput): ResolvedSchedule;
16
+ /**
17
+ * Resolve create-input schedule fields into a concrete next-fire plan.
18
+ * Pass `nowMs` for deterministic CP / test resolution; CP owns this call.
19
+ */
20
+ export declare function resolveSchedule(input: Pick<ReminderCreateInput, "every" | "cron" | "delay" | "at">, nowMs?: number): ResolvedSchedule;
18
21
  /** Next UTC fire strictly after `afterMs` for a 5-field cron. */
19
22
  export declare function nextCronFireMs(cronSource: string, afterMs: number): number;
20
23
  /** Default busy policy: recurring may skip; one-shots queue behind the turn. */
@@ -1 +1 @@
1
- {"version":3,"file":"reminder-schedule.d.ts","sourceRoot":"","sources":["../../src/internal/reminder-schedule.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAI7E,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED,4EAA4E;AAC5E,eAAO,MAAM,YAAY,aAAgB,CAAC;AAE1C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,oBAAoB,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,KAAK,EAAE,mBAAmB,GAAG,gBAAgB,CA2D5E;AAED,iEAAiE;AACjE,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAU1E;AAED,gFAAgF;AAChF,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,oBAAoB,GACzB,YAAY,GAAG,iBAAiB,CAElC"}
1
+ {"version":3,"file":"reminder-schedule.d.ts","sourceRoot":"","sources":["../../src/internal/reminder-schedule.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAI7E,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED,4EAA4E;AAC5E,eAAO,MAAM,YAAY,aAAgB,CAAC;AAE1C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,oBAAoB,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,IAAI,CAAC,mBAAmB,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,EACnE,KAAK,GAAE,MAAmB,GACzB,gBAAgB,CA0DlB;AAED,iEAAiE;AACjE,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAU1E;AAED,gFAAgF;AAChF,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,oBAAoB,GACzB,YAAY,GAAG,iBAAiB,CAElC"}