@cursor/july 0.1.107 → 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 (302) hide show
  1. package/README.md +10 -5
  2. package/dist/bin/agent-serve.js +30 -8
  3. package/dist/channels/github/github-channel.js +8 -5
  4. package/dist/channels/github/types.d.ts +5 -1
  5. package/dist/channels/github/types.d.ts.map +1 -1
  6. package/dist/channels/origin/origin-channel.d.ts.map +1 -1
  7. package/dist/channels/origin/origin-channel.js +27 -13
  8. package/dist/channels/origin/types.d.ts +5 -1
  9. package/dist/channels/origin/types.d.ts.map +1 -1
  10. package/dist/channels.d.ts +45 -0
  11. package/dist/channels.d.ts.map +1 -1
  12. package/dist/channels.js +106 -7
  13. package/dist/connections.d.ts +2 -1
  14. package/dist/connections.d.ts.map +1 -1
  15. package/dist/connections.js +2 -1
  16. package/dist/docs/404.html +2 -2
  17. package/dist/docs/ab.html +4 -4
  18. package/dist/docs/assets/{app.CtuckIiL.js → app.BASKM3M4.js} +1 -1
  19. package/dist/docs/assets/chunks/@localSearchIndexroot.BHZYsNVi.js +1 -0
  20. package/dist/docs/assets/chunks/{VPLocalSearchBox.Bkkhnu8K.js → VPLocalSearchBox.BOKxlYGP.js} +1 -1
  21. package/dist/docs/assets/chunks/{theme.DhpIe0Pa.js → theme.DbDZW-zb.js} +2 -2
  22. package/dist/docs/assets/{deployment.md.MFPKqsqI.js → deployment.md.JenwuCCB.js} +4 -4
  23. package/dist/docs/assets/{deployment.md.MFPKqsqI.lean.js → deployment.md.JenwuCCB.lean.js} +1 -1
  24. package/dist/docs/assets/{evals.md.CbMoebP1.js → evals.md.C1ekS3k2.js} +1 -1
  25. package/dist/docs/assets/guides_cloud-agents.md.BsloyHdY.js +9 -0
  26. package/dist/docs/assets/{guides_cloud-agents.md.DS8RIjwx.lean.js → guides_cloud-agents.md.BsloyHdY.lean.js} +1 -1
  27. package/dist/docs/assets/{guides_github.md.c0gdGJ-D.js → guides_github.md.BH33UEBJ.js} +1 -1
  28. package/dist/docs/assets/{guides_grokbot-agents.md.DVqdhBKb.js → guides_grokbot-agents.md.DyV-WArv.js} +1 -1
  29. package/dist/docs/assets/guides_improve.md.BGVk32bK.js +14 -0
  30. package/dist/docs/assets/guides_improve.md.BGVk32bK.lean.js +1 -0
  31. package/dist/docs/assets/{guides_slack.md.9oHPye9o.js → guides_slack.md.D4RVMM4G.js} +3 -3
  32. package/dist/docs/assets/{guides_slack.md.9oHPye9o.lean.js → guides_slack.md.D4RVMM4G.lean.js} +1 -1
  33. package/dist/docs/assets/index.md.BjH1w2ZW.js +5 -0
  34. package/dist/docs/assets/{reference_agent-config.md.CHNpiyp4.js → reference_agent-config.md.CvoL6pof.js} +1 -1
  35. package/dist/docs/assets/{reference_cli.md.Dm67hd2D.js → reference_cli.md.Ca26u0Es.js} +6 -6
  36. package/dist/docs/assets/{reference_cli.md.Dm67hd2D.lean.js → reference_cli.md.Ca26u0Es.lean.js} +1 -1
  37. package/dist/docs/assets/{reference_connections.md.Di6jJAXF.js → reference_connections.md.BojkC6c5.js} +1 -1
  38. package/dist/docs/assets/{reference_extensions.md.CGmMLblt.js → reference_extensions.md.CPWt00ds.js} +1 -1
  39. package/dist/docs/assets/{scaffolding-agents.md.em43xlY1.js → scaffolding-agents.md.Kctn3OVb.js} +1 -1
  40. package/dist/docs/assets/{skills_create-agent.md.BVoWPcan.js → skills_create-agent.md.Q3h6Je-e.js} +1 -1
  41. package/dist/docs/assets/{skills_debug.md.CDbPhHfg.js → skills_debug.md.CVjCXMFF.js} +1 -1
  42. package/dist/docs/assets/{skills_debug.md.CDbPhHfg.lean.js → skills_debug.md.CVjCXMFF.lean.js} +1 -1
  43. package/dist/docs/assets/{skills_evals.md.723kpUmA.js → skills_evals.md.BhovOvrl.js} +1 -1
  44. package/dist/docs/assets/skills_framework-map.md.D-tFZhFS.js +1 -0
  45. package/dist/docs/assets/{skills_framework-map.md.haibFyoB.lean.js → skills_framework-map.md.D-tFZhFS.lean.js} +1 -1
  46. package/dist/docs/assets/{skills_github.md.D0JahM8c.js → skills_github.md.hgFX_oKY.js} +1 -1
  47. package/dist/docs/assets/troubleshooting.md.CYEAO9bM.js +1 -0
  48. package/dist/docs/building-with-agents.html +4 -4
  49. package/dist/docs/concepts.html +4 -4
  50. package/dist/docs/deployment.html +7 -7
  51. package/dist/docs/deployment.md +7 -2
  52. package/dist/docs/evals.html +6 -6
  53. package/dist/docs/evals.md +3 -2
  54. package/dist/docs/guides/agent-to-agent.html +4 -4
  55. package/dist/docs/guides/cloud-agents.html +6 -6
  56. package/dist/docs/guides/cloud-agents.md +4 -3
  57. package/dist/docs/guides/convert-automation.html +4 -4
  58. package/dist/docs/guides/github.html +5 -5
  59. package/dist/docs/guides/github.md +2 -1
  60. package/dist/docs/guides/grokbot-agents.html +6 -6
  61. package/dist/docs/guides/grokbot-agents.md +2 -2
  62. package/dist/docs/guides/human-in-the-loop.html +4 -4
  63. package/dist/docs/guides/improve.html +40 -0
  64. package/dist/docs/guides/improve.md +91 -0
  65. package/dist/docs/guides/mcp-oauth.html +4 -4
  66. package/dist/docs/guides/opentelemetry.html +5 -5
  67. package/dist/docs/guides/slack.html +6 -6
  68. package/dist/docs/guides/slack.md +2 -1
  69. package/dist/docs/guides/webhooks.html +4 -4
  70. package/dist/docs/hashmap.json +1 -1
  71. package/dist/docs/hillclimbing.html +4 -4
  72. package/dist/docs/index.html +6 -6
  73. package/dist/docs/index.md +4 -0
  74. package/dist/docs/llms-full.txt +158 -33
  75. package/dist/docs/llms.txt +1 -0
  76. package/dist/docs/quickstart.html +4 -4
  77. package/dist/docs/reference/agent-config.html +6 -6
  78. package/dist/docs/reference/agent-config.md +5 -2
  79. package/dist/docs/reference/artifacts.html +4 -4
  80. package/dist/docs/reference/channels.html +4 -4
  81. package/dist/docs/reference/cli.html +10 -10
  82. package/dist/docs/reference/cli.md +18 -11
  83. package/dist/docs/reference/connections.html +6 -6
  84. package/dist/docs/reference/connections.md +2 -1
  85. package/dist/docs/reference/extensions.html +6 -6
  86. package/dist/docs/reference/extensions.md +2 -0
  87. package/dist/docs/reference/hooks.html +4 -4
  88. package/dist/docs/reference/http-api.html +4 -4
  89. package/dist/docs/reference/instructions.html +4 -4
  90. package/dist/docs/reference/playground.html +4 -4
  91. package/dist/docs/reference/project-layout.html +4 -4
  92. package/dist/docs/reference/prompt.html +4 -4
  93. package/dist/docs/reference/result.html +4 -4
  94. package/dist/docs/reference/schedules.html +4 -4
  95. package/dist/docs/reference/sessions.html +4 -4
  96. package/dist/docs/reference/skills.html +4 -4
  97. package/dist/docs/reference/subagents.html +4 -4
  98. package/dist/docs/reference/tools.html +4 -4
  99. package/dist/docs/scaffolding-agents.html +5 -5
  100. package/dist/docs/scaffolding-agents.md +2 -1
  101. package/dist/docs/skills/ab.html +4 -4
  102. package/dist/docs/skills/create-agent.html +6 -6
  103. package/dist/docs/skills/create-agent.md +1 -1
  104. package/dist/docs/skills/debug.html +5 -5
  105. package/dist/docs/skills/debug.md +1 -1
  106. package/dist/docs/skills/evals.html +6 -6
  107. package/dist/docs/skills/evals.md +1 -1
  108. package/dist/docs/skills/framework-map.html +5 -5
  109. package/dist/docs/skills/framework-map.md +4 -2
  110. package/dist/docs/skills/github.html +6 -6
  111. package/dist/docs/skills/github.md +1 -1
  112. package/dist/docs/skills/hillclimb.html +4 -4
  113. package/dist/docs/skills/index.html +4 -4
  114. package/dist/docs/skills/mcp-auth.html +4 -4
  115. package/dist/docs/skills/otel.html +4 -4
  116. package/dist/docs/skills/setup-slack.html +4 -4
  117. package/dist/docs/storage.html +4 -4
  118. package/dist/docs/templates/agentic-owners.html +4 -4
  119. package/dist/docs/templates/agents-md.html +4 -4
  120. package/dist/docs/templates/code-wiki.html +4 -4
  121. package/dist/docs/templates/demo.html +4 -4
  122. package/dist/docs/templates/grokbot-agents.html +4 -4
  123. package/dist/docs/templates/pr-autofixer.html +4 -4
  124. package/dist/docs/templates/security-help.html +4 -4
  125. package/dist/docs/templates/security-reviewer.html +4 -4
  126. package/dist/docs/templates/triage.html +4 -4
  127. package/dist/docs/troubleshooting.html +5 -5
  128. package/dist/docs/troubleshooting.md +1 -1
  129. package/dist/extensions/improve/extension.d.ts +46 -0
  130. package/dist/extensions/improve/extension.d.ts.map +1 -0
  131. package/dist/extensions/improve/extension.js +41 -0
  132. package/dist/extensions/improve/skills/yourself.d.ts +4 -0
  133. package/dist/extensions/improve/skills/yourself.d.ts.map +1 -0
  134. package/dist/extensions/improve/skills/yourself.js +43 -0
  135. package/dist/internal/builtin-tools/artifacts.d.ts.map +1 -1
  136. package/dist/internal/builtin-tools/artifacts.js +2 -3
  137. package/dist/internal/channel-route-dispatch.d.ts +13 -0
  138. package/dist/internal/channel-route-dispatch.d.ts.map +1 -0
  139. package/dist/internal/channel-route-dispatch.js +62 -0
  140. package/dist/internal/channel-state.d.ts +17 -0
  141. package/dist/internal/channel-state.d.ts.map +1 -0
  142. package/dist/internal/channel-state.js +78 -0
  143. package/dist/internal/cli-ax.d.ts +7 -0
  144. package/dist/internal/cli-ax.d.ts.map +1 -1
  145. package/dist/internal/cli-ax.js +99 -1
  146. package/dist/internal/cli-cursor.d.ts.map +1 -1
  147. package/dist/internal/cli-cursor.js +2 -0
  148. package/dist/internal/cli-deploy.d.ts.map +1 -1
  149. package/dist/internal/cli-deploy.js +38 -14
  150. package/dist/internal/cli-mcp-oauth.d.ts.map +1 -1
  151. package/dist/internal/cli-mcp-oauth.js +15 -0
  152. package/dist/internal/cli-mcp.d.ts.map +1 -1
  153. package/dist/internal/cli-mcp.js +12 -0
  154. package/dist/internal/cli-slack.d.ts.map +1 -1
  155. package/dist/internal/cli-slack.js +8 -2
  156. package/dist/internal/cursor/credentials.d.ts +8 -2
  157. package/dist/internal/cursor/credentials.d.ts.map +1 -1
  158. package/dist/internal/cursor/credentials.js +27 -5
  159. package/dist/internal/deploy-client.d.ts +27 -0
  160. package/dist/internal/deploy-client.d.ts.map +1 -1
  161. package/dist/internal/deploy-client.js +32 -0
  162. package/dist/internal/deploy-manifest.d.ts +23 -0
  163. package/dist/internal/deploy-manifest.d.ts.map +1 -1
  164. package/dist/internal/deploy-manifest.js +84 -1
  165. package/dist/internal/describe-error.d.ts +1 -0
  166. package/dist/internal/describe-error.d.ts.map +1 -1
  167. package/dist/internal/describe-error.js +25 -0
  168. package/dist/internal/guest-network.d.ts +4 -10
  169. package/dist/internal/guest-network.d.ts.map +1 -1
  170. package/dist/internal/guest-network.js +42 -26
  171. package/dist/internal/hosted-admission-adapter.d.ts +2 -0
  172. package/dist/internal/hosted-admission-adapter.d.ts.map +1 -1
  173. package/dist/internal/hosted-catch-protocol.d.ts +51 -0
  174. package/dist/internal/hosted-catch-protocol.d.ts.map +1 -0
  175. package/dist/internal/hosted-catch-protocol.js +103 -0
  176. package/dist/internal/hosted-catch.d.ts +40 -0
  177. package/dist/internal/hosted-catch.d.ts.map +1 -0
  178. package/dist/internal/hosted-catch.js +149 -0
  179. package/dist/internal/hosted-delivery-protocol.d.ts +41 -0
  180. package/dist/internal/hosted-delivery-protocol.d.ts.map +1 -1
  181. package/dist/internal/hosted-delivery-protocol.js +249 -0
  182. package/dist/internal/hosted-delivery.d.ts +10 -1
  183. package/dist/internal/hosted-delivery.d.ts.map +1 -1
  184. package/dist/internal/hosted-delivery.js +100 -22
  185. package/dist/internal/hosted-execution-diag.d.ts +4 -1
  186. package/dist/internal/hosted-execution-diag.d.ts.map +1 -1
  187. package/dist/internal/hosted-execution-diag.js +13 -4
  188. package/dist/internal/hosted-execution-flush.d.ts +3 -0
  189. package/dist/internal/hosted-execution-flush.d.ts.map +1 -1
  190. package/dist/internal/hosted-execution-flush.js +2 -4
  191. package/dist/internal/http-control-plane-session.d.ts +30 -0
  192. package/dist/internal/http-control-plane-session.d.ts.map +1 -0
  193. package/dist/internal/http-control-plane-session.js +83 -0
  194. package/dist/internal/legacy-command-guard.d.ts +22 -0
  195. package/dist/internal/legacy-command-guard.d.ts.map +1 -0
  196. package/dist/internal/legacy-command-guard.js +51 -0
  197. package/dist/internal/platform-timers.d.ts +7 -0
  198. package/dist/internal/platform-timers.d.ts.map +1 -1
  199. package/dist/internal/platform-timers.js +139 -0
  200. package/dist/internal/reminder-control-plane-protocol.d.ts +2 -0
  201. package/dist/internal/reminder-control-plane-protocol.d.ts.map +1 -1
  202. package/dist/internal/reminder-control-plane-protocol.js +9 -2
  203. package/dist/internal/reminder-runner.d.ts +8 -0
  204. package/dist/internal/reminder-runner.d.ts.map +1 -1
  205. package/dist/internal/reminder-runner.js +36 -9
  206. package/dist/internal/resolve-prod-target.d.ts +2 -0
  207. package/dist/internal/resolve-prod-target.d.ts.map +1 -1
  208. package/dist/internal/resolve-prod-target.js +13 -0
  209. package/dist/internal/sdk-runner.d.ts.map +1 -1
  210. package/dist/internal/sdk-runner.js +4 -3
  211. package/dist/internal/server.d.ts.map +1 -1
  212. package/dist/internal/server.js +57 -56
  213. package/dist/internal/session-engine.d.ts +2 -6
  214. package/dist/internal/session-engine.d.ts.map +1 -1
  215. package/dist/internal/session-engine.js +95 -67
  216. package/dist/playground/assets/{index-Bq2HpEQB.js → index-BMDqAeXu.js} +28 -28
  217. package/dist/playground/assets/index-LUgJoWdL.css +1 -0
  218. package/dist/playground/index.html +2 -2
  219. package/dist/storage-backends/cursor-hosted.d.ts +6 -0
  220. package/dist/storage-backends/cursor-hosted.d.ts.map +1 -1
  221. package/dist/storage-backends/cursor-hosted.js +29 -1
  222. package/dist/types.d.ts +33 -5
  223. package/dist/types.d.ts.map +1 -1
  224. package/docs/README.md +4 -0
  225. package/docs/deployment.md +7 -2
  226. package/docs/evals.md +3 -2
  227. package/docs/guides/cloud-agents.md +4 -3
  228. package/docs/guides/github.md +2 -1
  229. package/docs/guides/grokbot-agents.md +2 -2
  230. package/docs/guides/improve.md +96 -0
  231. package/docs/guides/slack.md +2 -1
  232. package/docs/reference/agent-config.md +5 -2
  233. package/docs/reference/cli.md +18 -11
  234. package/docs/reference/connections.md +2 -1
  235. package/docs/reference/extensions.md +2 -0
  236. package/docs/scaffolding-agents.md +2 -1
  237. package/docs/troubleshooting.md +1 -1
  238. package/package.json +8 -1
  239. package/skills/create-agent/SKILL.md +1 -1
  240. package/skills/debug/SKILL.md +1 -1
  241. package/skills/evals/SKILL.md +1 -1
  242. package/skills/framework-map/SKILL.md +4 -2
  243. package/skills/github/SKILL.md +1 -1
  244. package/src/bin/agent-serve.ts +27 -2
  245. package/src/channels/github/github-channel.ts +8 -8
  246. package/src/channels/github/types.ts +5 -0
  247. package/src/channels/origin/origin-channel.ts +29 -13
  248. package/src/channels/origin/types.ts +5 -0
  249. package/src/channels.ts +157 -10
  250. package/src/connections.ts +2 -1
  251. package/src/extensions/improve/extension.ts +70 -0
  252. package/src/extensions/improve/skills/yourself.ts +50 -0
  253. package/src/internal/builtin-tools/artifacts.ts +2 -3
  254. package/src/internal/channel-route-dispatch.ts +66 -0
  255. package/src/internal/channel-state.ts +96 -0
  256. package/src/internal/cli-ax.ts +110 -1
  257. package/src/internal/cli-cursor.ts +4 -1
  258. package/src/internal/cli-deploy.ts +50 -10
  259. package/src/internal/cli-mcp-oauth.ts +18 -0
  260. package/src/internal/cli-mcp.ts +11 -0
  261. package/src/internal/cli-slack.ts +15 -2
  262. package/src/internal/cursor/credentials.ts +35 -7
  263. package/src/internal/deploy-client.ts +54 -0
  264. package/src/internal/deploy-manifest.ts +115 -1
  265. package/src/internal/describe-error.ts +28 -0
  266. package/src/internal/guest-network.ts +43 -29
  267. package/src/internal/hosted-admission-adapter.ts +2 -0
  268. package/src/internal/hosted-catch-protocol.ts +130 -0
  269. package/src/internal/hosted-catch.ts +192 -0
  270. package/src/internal/hosted-delivery-protocol.ts +387 -0
  271. package/src/internal/hosted-delivery.ts +155 -22
  272. package/src/internal/hosted-execution-diag.ts +21 -3
  273. package/src/internal/hosted-execution-flush.ts +6 -3
  274. package/src/internal/http-control-plane-session.ts +104 -0
  275. package/src/internal/legacy-command-guard.ts +59 -0
  276. package/src/internal/platform-timers.ts +191 -0
  277. package/src/internal/reminder-control-plane-protocol.ts +15 -2
  278. package/src/internal/reminder-runner.ts +60 -9
  279. package/src/internal/resolve-prod-target.ts +15 -0
  280. package/src/internal/sdk-runner.ts +2 -1
  281. package/src/internal/server.ts +89 -79
  282. package/src/internal/session-engine.ts +141 -83
  283. package/src/storage-backends/cursor-hosted.ts +40 -1
  284. package/src/types.ts +39 -6
  285. package/dist/docs/assets/chunks/@localSearchIndexroot.DXXZxiMv.js +0 -1
  286. package/dist/docs/assets/guides_cloud-agents.md.DS8RIjwx.js +0 -9
  287. package/dist/docs/assets/index.md.BW_6tOgR.js +0 -5
  288. package/dist/docs/assets/skills_framework-map.md.haibFyoB.js +0 -1
  289. package/dist/docs/assets/troubleshooting.md.Cus_YZga.js +0 -1
  290. package/dist/playground/assets/index-CZKKNlmb.css +0 -1
  291. /package/dist/docs/assets/{evals.md.CbMoebP1.lean.js → evals.md.C1ekS3k2.lean.js} +0 -0
  292. /package/dist/docs/assets/{guides_github.md.c0gdGJ-D.lean.js → guides_github.md.BH33UEBJ.lean.js} +0 -0
  293. /package/dist/docs/assets/{guides_grokbot-agents.md.DVqdhBKb.lean.js → guides_grokbot-agents.md.DyV-WArv.lean.js} +0 -0
  294. /package/dist/docs/assets/{index.md.BW_6tOgR.lean.js → index.md.BjH1w2ZW.lean.js} +0 -0
  295. /package/dist/docs/assets/{reference_agent-config.md.CHNpiyp4.lean.js → reference_agent-config.md.CvoL6pof.lean.js} +0 -0
  296. /package/dist/docs/assets/{reference_connections.md.Di6jJAXF.lean.js → reference_connections.md.BojkC6c5.lean.js} +0 -0
  297. /package/dist/docs/assets/{reference_extensions.md.CGmMLblt.lean.js → reference_extensions.md.CPWt00ds.lean.js} +0 -0
  298. /package/dist/docs/assets/{scaffolding-agents.md.em43xlY1.lean.js → scaffolding-agents.md.Kctn3OVb.lean.js} +0 -0
  299. /package/dist/docs/assets/{skills_create-agent.md.BVoWPcan.lean.js → skills_create-agent.md.Q3h6Je-e.lean.js} +0 -0
  300. /package/dist/docs/assets/{skills_evals.md.723kpUmA.lean.js → skills_evals.md.BhovOvrl.lean.js} +0 -0
  301. /package/dist/docs/assets/{skills_github.md.D0JahM8c.lean.js → skills_github.md.hgFX_oKY.lean.js} +0 -0
  302. /package/dist/docs/assets/{troubleshooting.md.Cus_YZga.lean.js → troubleshooting.md.CYEAO9bM.lean.js} +0 -0
@@ -9,10 +9,144 @@ export type HostedGuestRetryDisposition =
9
9
  | typeof HOSTED_GUEST_RETRY_TRANSIENT
10
10
  | typeof HOSTED_GUEST_RETRY_TERMINAL;
11
11
 
12
+ export const HOSTED_FAILURE_CLASSIFICATION_VERSION = 1;
13
+
14
+ export type HostedFailureDomain =
15
+ | "configuration"
16
+ | "protocol"
17
+ | "platform"
18
+ | "agent"
19
+ | "dependency"
20
+ | "cancellation"
21
+ | "unknown";
22
+
23
+ export type HostedFailureSource =
24
+ | "tas"
25
+ | "factory"
26
+ | "anyrun"
27
+ | "engine"
28
+ | "agent";
29
+
30
+ export type HostedFailureClassification = {
31
+ v: typeof HOSTED_FAILURE_CLASSIFICATION_VERSION;
32
+ domain: HostedFailureDomain;
33
+ source: HostedFailureSource;
34
+ };
35
+
36
+ const HOSTED_FAILURE_DOMAINS = new Set<HostedFailureDomain>([
37
+ "configuration",
38
+ "protocol",
39
+ "platform",
40
+ "agent",
41
+ "dependency",
42
+ "cancellation",
43
+ "unknown",
44
+ ]);
45
+ const HOSTED_FAILURE_SOURCES = new Set<HostedFailureSource>([
46
+ "tas",
47
+ "factory",
48
+ "anyrun",
49
+ "engine",
50
+ "agent",
51
+ ]);
52
+
53
+ export type HostedFailureCode =
54
+ | "agent_admission_threw"
55
+ | "agent_dependency_failed"
56
+ | "background_dispatch_failed"
57
+ | "bound_secrets_not_consumed"
58
+ | "channel_dispatch_failed"
59
+ | "channel_kind_mismatch"
60
+ | "channel_not_found"
61
+ | "channel_outcome_missing"
62
+ | "forbidden"
63
+ | "guest_connect_stalled"
64
+ | "guest_network_unavailable"
65
+ | "hosted_admission_session_mismatch"
66
+ | "hosted_admission_unavailable"
67
+ | "hosted_deferred_session_unusable"
68
+ | "hosted_local_send_rejected"
69
+ | "hosted_send_limit_exceeded"
70
+ | "internal_error"
71
+ | "invalid_hosted_admission"
72
+ | "invalid_hosted_execution"
73
+ | "invalid_request"
74
+ | "method_not_allowed"
75
+ | "not_found"
76
+ | "session_busy"
77
+ | "turn_cancelled"
78
+ | "turn_failed"
79
+ | "unauthorized"
80
+ | "v2_identity_conflict";
81
+
82
+ export const HOSTED_FAILURE_CLASSIFICATIONS: Record<
83
+ HostedFailureCode,
84
+ Omit<HostedFailureClassification, "v">
85
+ > = {
86
+ agent_admission_threw: { domain: "agent", source: "agent" },
87
+ agent_dependency_failed: { domain: "dependency", source: "factory" },
88
+ background_dispatch_failed: { domain: "agent", source: "agent" },
89
+ bound_secrets_not_consumed: { domain: "platform", source: "engine" },
90
+ channel_dispatch_failed: { domain: "agent", source: "agent" },
91
+ channel_kind_mismatch: { domain: "configuration", source: "engine" },
92
+ channel_not_found: { domain: "configuration", source: "engine" },
93
+ channel_outcome_missing: { domain: "protocol", source: "agent" },
94
+ forbidden: { domain: "configuration", source: "engine" },
95
+ guest_connect_stalled: { domain: "platform", source: "engine" },
96
+ guest_network_unavailable: { domain: "platform", source: "anyrun" },
97
+ hosted_admission_session_mismatch: { domain: "protocol", source: "engine" },
98
+ hosted_admission_unavailable: { domain: "platform", source: "engine" },
99
+ hosted_deferred_session_unusable: { domain: "agent", source: "agent" },
100
+ hosted_local_send_rejected: { domain: "agent", source: "agent" },
101
+ hosted_send_limit_exceeded: { domain: "agent", source: "agent" },
102
+ internal_error: { domain: "unknown", source: "engine" },
103
+ invalid_hosted_admission: { domain: "protocol", source: "engine" },
104
+ invalid_hosted_execution: { domain: "protocol", source: "engine" },
105
+ invalid_request: { domain: "protocol", source: "engine" },
106
+ method_not_allowed: { domain: "protocol", source: "engine" },
107
+ not_found: { domain: "protocol", source: "engine" },
108
+ session_busy: { domain: "platform", source: "engine" },
109
+ turn_cancelled: { domain: "cancellation", source: "agent" },
110
+ turn_failed: { domain: "agent", source: "agent" },
111
+ unauthorized: { domain: "configuration", source: "engine" },
112
+ v2_identity_conflict: { domain: "protocol", source: "engine" },
113
+ };
114
+
115
+ export function hostedFailureClassification(
116
+ code: string
117
+ ): HostedFailureClassification {
118
+ const known = HOSTED_FAILURE_CLASSIFICATIONS[code as HostedFailureCode];
119
+ return {
120
+ v: HOSTED_FAILURE_CLASSIFICATION_VERSION,
121
+ domain: known?.domain ?? "unknown",
122
+ source: known?.source ?? "engine",
123
+ };
124
+ }
125
+
126
+ export function parseHostedFailureClassification(
127
+ value: unknown
128
+ ): HostedFailureClassification | undefined {
129
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
130
+ return undefined;
131
+ }
132
+ const body = value as Record<string, unknown>;
133
+ if (
134
+ body.v !== HOSTED_FAILURE_CLASSIFICATION_VERSION ||
135
+ typeof body.domain !== "string" ||
136
+ !HOSTED_FAILURE_DOMAINS.has(body.domain as HostedFailureDomain) ||
137
+ typeof body.source !== "string" ||
138
+ !HOSTED_FAILURE_SOURCES.has(body.source as HostedFailureSource)
139
+ ) {
140
+ return undefined;
141
+ }
142
+ return body as HostedFailureClassification;
143
+ }
144
+
12
145
  export type HostedGuestError = {
13
146
  ok: false;
14
147
  error: string;
15
148
  retry: HostedGuestRetryDisposition;
149
+ classification: HostedFailureClassification;
16
150
  message?: string;
17
151
  turnStatus?: string;
18
152
  };
@@ -33,6 +167,7 @@ export function hostedGuestErrorResponse(input: {
33
167
  ok: false,
34
168
  error: input.error,
35
169
  retry: input.retry,
170
+ classification: hostedFailureClassification(input.error),
36
171
  message: input.message,
37
172
  turnStatus: input.turnStatus,
38
173
  };
@@ -66,6 +201,30 @@ export type HostedReminderFirePayload = {
66
201
  fireCount: number;
67
202
  };
68
203
 
204
+ /** Protocol v1 immutable fire descriptor (architecture v2 CP path). */
205
+ export type HostedReminderFireDescriptorPayload = {
206
+ protocolVersion: 1;
207
+ id: string;
208
+ fireCount: number;
209
+ generation: number;
210
+ purpose: string;
211
+ channelId: string;
212
+ continuationToken: string;
213
+ target?: Record<string, unknown>;
214
+ scheduleKind: "every" | "cron" | "delay" | "at";
215
+ scheduleValue: string;
216
+ intervalMs?: number;
217
+ prompt?: string;
218
+ handler?: string;
219
+ args?: Record<string, unknown>;
220
+ hasRunHandler: boolean;
221
+ hasUntilFn: boolean;
222
+ untilPrompt?: string;
223
+ busyPolicy: "skipIfBusy" | "queueBehindTurn";
224
+ nextFireAtMs: number;
225
+ claimedAtMs: number;
226
+ };
227
+
69
228
  export type HostedAdmissionManagedAutomation = {
70
229
  automationUuid: string;
71
230
  mcpServerNames: string[];
@@ -267,6 +426,234 @@ export function parseHostedReminderFirePayload(
267
426
  };
268
427
  }
269
428
 
429
+ const HOSTED_REMINDER_FIRE_DESCRIPTOR_KEYS = new Set([
430
+ "protocolVersion",
431
+ "id",
432
+ "fireCount",
433
+ "generation",
434
+ "purpose",
435
+ "channelId",
436
+ "continuationToken",
437
+ "target",
438
+ "scheduleKind",
439
+ "scheduleValue",
440
+ "intervalMs",
441
+ "prompt",
442
+ "handler",
443
+ "args",
444
+ "hasRunHandler",
445
+ "hasUntilFn",
446
+ "untilPrompt",
447
+ "busyPolicy",
448
+ "nextFireAtMs",
449
+ "claimedAtMs",
450
+ ]);
451
+
452
+ const HOSTED_REMINDER_SCHEDULE_KINDS = new Set([
453
+ "every",
454
+ "cron",
455
+ "delay",
456
+ "at",
457
+ ]);
458
+ const HOSTED_REMINDER_BUSY_POLICIES = new Set([
459
+ "skipIfBusy",
460
+ "queueBehindTurn",
461
+ ]);
462
+
463
+ const HOSTED_REMINDER_JSON_MAX_DEPTH = 8;
464
+
465
+ /** Reject non-JSON values (NaN/Infinity/undefined/bigint/function/symbol). */
466
+ function isJsonSafeValue(value: unknown, depth: number): boolean {
467
+ if (depth > HOSTED_REMINDER_JSON_MAX_DEPTH) {
468
+ return false;
469
+ }
470
+ if (value === null) {
471
+ return true;
472
+ }
473
+ const type = typeof value;
474
+ if (type === "string" || type === "boolean") {
475
+ return true;
476
+ }
477
+ if (type === "number") {
478
+ return Number.isFinite(value);
479
+ }
480
+ if (type !== "object") {
481
+ return false;
482
+ }
483
+ if (Array.isArray(value)) {
484
+ return value.every((entry) => isJsonSafeValue(entry, depth + 1));
485
+ }
486
+ const proto = Object.getPrototypeOf(value);
487
+ if (proto !== Object.prototype && proto !== null) {
488
+ return false;
489
+ }
490
+ for (const entry of Object.values(value as Record<string, unknown>)) {
491
+ if (!isJsonSafeValue(entry, depth + 1)) {
492
+ return false;
493
+ }
494
+ }
495
+ return true;
496
+ }
497
+
498
+ function parseOptionalJsonObjectField(
499
+ value: unknown,
500
+ maxBytes: number
501
+ ): Record<string, unknown> | undefined {
502
+ if (value === undefined) {
503
+ return undefined;
504
+ }
505
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
506
+ return undefined;
507
+ }
508
+ if (!isJsonSafeValue(value, 0)) {
509
+ return undefined;
510
+ }
511
+ try {
512
+ const encoded = JSON.stringify(value);
513
+ if (
514
+ encoded === undefined ||
515
+ Buffer.byteLength(encoded, "utf8") > maxBytes
516
+ ) {
517
+ return undefined;
518
+ }
519
+ const roundTrip = JSON.parse(encoded) as unknown;
520
+ if (
521
+ typeof roundTrip !== "object" ||
522
+ roundTrip === null ||
523
+ Array.isArray(roundTrip)
524
+ ) {
525
+ return undefined;
526
+ }
527
+ return roundTrip as Record<string, unknown>;
528
+ } catch {
529
+ return undefined;
530
+ }
531
+ }
532
+
533
+ /**
534
+ * Parse the immutable CP fire descriptor. Rejects unknown keys, non-enum
535
+ * schedule/busy values, and non-JSON-safe optional object fields.
536
+ */
537
+ export function parseHostedReminderFireDescriptorPayload(
538
+ value: unknown
539
+ ): HostedReminderFireDescriptorPayload | undefined {
540
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
541
+ return undefined;
542
+ }
543
+ const body = value as Record<string, unknown>;
544
+ if (
545
+ Object.keys(body).some(
546
+ (key) => !HOSTED_REMINDER_FIRE_DESCRIPTOR_KEYS.has(key)
547
+ )
548
+ ) {
549
+ return undefined;
550
+ }
551
+ if (
552
+ body.protocolVersion !== 1 ||
553
+ typeof body.id !== "string" ||
554
+ body.id.length === 0 ||
555
+ body.id.length > 128 ||
556
+ typeof body.fireCount !== "number" ||
557
+ !Number.isInteger(body.fireCount) ||
558
+ body.fireCount < 0 ||
559
+ typeof body.generation !== "number" ||
560
+ !Number.isInteger(body.generation) ||
561
+ body.generation < 0 ||
562
+ typeof body.purpose !== "string" ||
563
+ body.purpose.length === 0 ||
564
+ body.purpose.length > 512 ||
565
+ typeof body.channelId !== "string" ||
566
+ body.channelId.length === 0 ||
567
+ body.channelId.length > 128 ||
568
+ typeof body.continuationToken !== "string" ||
569
+ body.continuationToken.length === 0 ||
570
+ body.continuationToken.length > 512 ||
571
+ typeof body.scheduleKind !== "string" ||
572
+ !HOSTED_REMINDER_SCHEDULE_KINDS.has(body.scheduleKind) ||
573
+ typeof body.scheduleValue !== "string" ||
574
+ body.scheduleValue.length === 0 ||
575
+ body.scheduleValue.length > 512 ||
576
+ typeof body.hasRunHandler !== "boolean" ||
577
+ typeof body.hasUntilFn !== "boolean" ||
578
+ typeof body.busyPolicy !== "string" ||
579
+ !HOSTED_REMINDER_BUSY_POLICIES.has(body.busyPolicy) ||
580
+ typeof body.nextFireAtMs !== "number" ||
581
+ !Number.isFinite(body.nextFireAtMs) ||
582
+ typeof body.claimedAtMs !== "number" ||
583
+ !Number.isFinite(body.claimedAtMs) ||
584
+ !Number.isInteger(body.claimedAtMs) ||
585
+ body.claimedAtMs < 0
586
+ ) {
587
+ return undefined;
588
+ }
589
+ if (body.intervalMs !== undefined) {
590
+ if (
591
+ typeof body.intervalMs !== "number" ||
592
+ !Number.isFinite(body.intervalMs) ||
593
+ !Number.isInteger(body.intervalMs) ||
594
+ body.intervalMs <= 0
595
+ ) {
596
+ return undefined;
597
+ }
598
+ }
599
+ if (body.prompt !== undefined) {
600
+ if (typeof body.prompt !== "string" || body.prompt.length > 8192) {
601
+ return undefined;
602
+ }
603
+ }
604
+ if (body.handler !== undefined) {
605
+ if (
606
+ typeof body.handler !== "string" ||
607
+ body.handler.length === 0 ||
608
+ body.handler.length > 128
609
+ ) {
610
+ return undefined;
611
+ }
612
+ }
613
+ if (body.untilPrompt !== undefined) {
614
+ if (
615
+ typeof body.untilPrompt !== "string" ||
616
+ body.untilPrompt.length > 8192
617
+ ) {
618
+ return undefined;
619
+ }
620
+ }
621
+ const target = parseOptionalJsonObjectField(body.target, 16 * 1024);
622
+ if (body.target !== undefined && target === undefined) {
623
+ return undefined;
624
+ }
625
+ const args = parseOptionalJsonObjectField(body.args, 32 * 1024);
626
+ if (body.args !== undefined && args === undefined) {
627
+ return undefined;
628
+ }
629
+ return {
630
+ protocolVersion: 1,
631
+ id: body.id,
632
+ fireCount: body.fireCount,
633
+ generation: body.generation,
634
+ purpose: body.purpose,
635
+ channelId: body.channelId,
636
+ continuationToken: body.continuationToken,
637
+ ...(target === undefined ? {} : { target }),
638
+ scheduleKind:
639
+ body.scheduleKind as HostedReminderFireDescriptorPayload["scheduleKind"],
640
+ scheduleValue: body.scheduleValue,
641
+ ...(body.intervalMs === undefined ? {} : { intervalMs: body.intervalMs }),
642
+ ...(body.prompt === undefined ? {} : { prompt: body.prompt }),
643
+ ...(body.handler === undefined ? {} : { handler: body.handler }),
644
+ ...(args === undefined ? {} : { args }),
645
+ hasRunHandler: body.hasRunHandler,
646
+ hasUntilFn: body.hasUntilFn,
647
+ ...(body.untilPrompt === undefined
648
+ ? {}
649
+ : { untilPrompt: body.untilPrompt }),
650
+ busyPolicy:
651
+ body.busyPolicy as HostedReminderFireDescriptorPayload["busyPolicy"],
652
+ nextFireAtMs: body.nextFireAtMs,
653
+ claimedAtMs: body.claimedAtMs,
654
+ };
655
+ }
656
+
270
657
  export function parseHostedAdmissionOutcome(
271
658
  value: unknown
272
659
  ): HostedAdmissionOutcome | undefined {