rivet-design 0.12.3 → 0.13.0

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 (535) hide show
  1. package/README.md +50 -26
  2. package/README.npm.md +50 -26
  3. package/bin/rivet.js +39 -24
  4. package/dist/{mcp/agent-variants → agent-variants}/SessionStore.d.ts +11 -19
  5. package/dist/agent-variants/SessionStore.d.ts.map +1 -0
  6. package/dist/{mcp/agent-variants → agent-variants}/SessionStore.js +77 -80
  7. package/dist/agent-variants/SessionStore.js.map +1 -0
  8. package/dist/{mcp/agent-variants → agent-variants}/WorktreeOrchestrator.d.ts +53 -21
  9. package/dist/agent-variants/WorktreeOrchestrator.d.ts.map +1 -0
  10. package/dist/{mcp/agent-variants → agent-variants}/WorktreeOrchestrator.js +291 -49
  11. package/dist/agent-variants/WorktreeOrchestrator.js.map +1 -0
  12. package/dist/{mcp/agent-variants → agent-variants}/WorktreeOrchestrator.testHelpers.d.ts +1 -9
  13. package/dist/agent-variants/WorktreeOrchestrator.testHelpers.d.ts.map +1 -0
  14. package/dist/{mcp/agent-variants → agent-variants}/WorktreeOrchestrator.testHelpers.js +3 -18
  15. package/dist/agent-variants/WorktreeOrchestrator.testHelpers.js.map +1 -0
  16. package/dist/agent-variants/briefContent.d.ts.map +1 -0
  17. package/dist/agent-variants/briefContent.js.map +1 -0
  18. package/dist/{mcp/agent-variants → agent-variants}/contracts.d.ts +715 -721
  19. package/dist/agent-variants/contracts.d.ts.map +1 -0
  20. package/dist/{mcp/agent-variants → agent-variants}/contracts.js +2 -3
  21. package/dist/agent-variants/contracts.js.map +1 -0
  22. package/dist/agent-variants/createProjectArtifacts.d.ts.map +1 -0
  23. package/dist/agent-variants/createProjectArtifacts.js.map +1 -0
  24. package/dist/agent-variants/diffQa.d.ts.map +1 -0
  25. package/dist/agent-variants/diffQa.js.map +1 -0
  26. package/dist/{mcp/agent-variants → agent-variants}/elementRefToTarget.d.ts +1 -1
  27. package/dist/agent-variants/elementRefToTarget.d.ts.map +1 -0
  28. package/dist/agent-variants/elementRefToTarget.js.map +1 -0
  29. package/dist/agent-variants/errors.d.ts.map +1 -0
  30. package/dist/agent-variants/errors.js.map +1 -0
  31. package/dist/agent-variants/generatedDestination.d.ts +29 -0
  32. package/dist/agent-variants/generatedDestination.d.ts.map +1 -0
  33. package/dist/agent-variants/generatedDestination.js +59 -0
  34. package/dist/agent-variants/generatedDestination.js.map +1 -0
  35. package/dist/{mcp/agent-variants → agent-variants}/index.d.ts +3 -6
  36. package/dist/agent-variants/index.d.ts.map +1 -0
  37. package/dist/{mcp/agent-variants → agent-variants}/index.js +3 -6
  38. package/dist/agent-variants/index.js.map +1 -0
  39. package/dist/agent-variants/previewQa.d.ts.map +1 -0
  40. package/dist/agent-variants/previewQa.js.map +1 -0
  41. package/dist/agent-variants/runLabel.d.ts.map +1 -0
  42. package/dist/agent-variants/runLabel.js.map +1 -0
  43. package/dist/agent-variants/runPlan.d.ts.map +1 -0
  44. package/dist/agent-variants/runPlan.js.map +1 -0
  45. package/dist/agent-variants/sourceContext.d.ts.map +1 -0
  46. package/dist/agent-variants/sourceContext.js.map +1 -0
  47. package/dist/agent-variants/variantContext.d.ts.map +1 -0
  48. package/dist/agent-variants/variantContext.js.map +1 -0
  49. package/dist/cli/client.d.ts +43 -0
  50. package/dist/cli/client.d.ts.map +1 -0
  51. package/dist/cli/client.js +109 -0
  52. package/dist/cli/client.js.map +1 -0
  53. package/dist/cli/commandNames.d.ts +9 -0
  54. package/dist/cli/commandNames.d.ts.map +1 -0
  55. package/dist/cli/commandNames.js +24 -0
  56. package/dist/cli/commandNames.js.map +1 -0
  57. package/dist/cli/commands/auth.d.ts +10 -0
  58. package/dist/cli/commands/auth.d.ts.map +1 -0
  59. package/dist/cli/commands/auth.js +81 -0
  60. package/dist/cli/commands/auth.js.map +1 -0
  61. package/dist/cli/commands/elementSelector.d.ts +10 -0
  62. package/dist/cli/commands/elementSelector.d.ts.map +1 -0
  63. package/dist/cli/commands/elementSelector.js +41 -0
  64. package/dist/cli/commands/elementSelector.js.map +1 -0
  65. package/dist/cli/commands/evidence.d.ts +9 -0
  66. package/dist/cli/commands/evidence.d.ts.map +1 -0
  67. package/dist/cli/commands/evidence.js +85 -0
  68. package/dist/cli/commands/evidence.js.map +1 -0
  69. package/dist/cli/commands/mcpServe.d.ts +40 -0
  70. package/dist/cli/commands/mcpServe.d.ts.map +1 -0
  71. package/dist/cli/commands/mcpServe.js +440 -0
  72. package/dist/cli/commands/mcpServe.js.map +1 -0
  73. package/dist/cli/commands/open.d.ts +28 -0
  74. package/dist/cli/commands/open.d.ts.map +1 -0
  75. package/dist/cli/commands/open.js +280 -0
  76. package/dist/cli/commands/open.js.map +1 -0
  77. package/dist/cli/commands/reference.d.ts +8 -0
  78. package/dist/cli/commands/reference.d.ts.map +1 -0
  79. package/dist/cli/commands/reference.js +101 -0
  80. package/dist/cli/commands/reference.js.map +1 -0
  81. package/dist/cli/commands/serve.d.ts +9 -0
  82. package/dist/cli/commands/serve.d.ts.map +1 -0
  83. package/dist/cli/commands/serve.js +182 -0
  84. package/dist/cli/commands/serve.js.map +1 -0
  85. package/dist/cli/commands/shared.d.ts +31 -0
  86. package/dist/cli/commands/shared.d.ts.map +1 -0
  87. package/dist/cli/commands/shared.js +82 -0
  88. package/dist/cli/commands/shared.js.map +1 -0
  89. package/dist/cli/commands/status.d.ts +10 -0
  90. package/dist/cli/commands/status.d.ts.map +1 -0
  91. package/dist/cli/commands/status.js +61 -0
  92. package/dist/cli/commands/status.js.map +1 -0
  93. package/dist/cli/commands/stop.d.ts +8 -0
  94. package/dist/cli/commands/stop.d.ts.map +1 -0
  95. package/dist/cli/commands/stop.js +41 -0
  96. package/dist/cli/commands/stop.js.map +1 -0
  97. package/dist/cli/commands/variants.d.ts +4 -0
  98. package/dist/cli/commands/variants.d.ts.map +1 -0
  99. package/dist/cli/commands/variants.js +374 -0
  100. package/dist/cli/commands/variants.js.map +1 -0
  101. package/dist/cli/commands/wait.d.ts +10 -0
  102. package/dist/cli/commands/wait.d.ts.map +1 -0
  103. package/dist/cli/commands/wait.js +101 -0
  104. package/dist/cli/commands/wait.js.map +1 -0
  105. package/dist/cli/entry.d.ts +12 -0
  106. package/dist/cli/entry.d.ts.map +1 -0
  107. package/dist/cli/entry.js +61 -0
  108. package/dist/cli/entry.js.map +1 -0
  109. package/dist/cli/envelope.d.ts +60 -0
  110. package/dist/cli/envelope.d.ts.map +1 -0
  111. package/dist/cli/envelope.js +57 -0
  112. package/dist/cli/envelope.js.map +1 -0
  113. package/dist/cli/flags.d.ts +20 -0
  114. package/dist/cli/flags.d.ts.map +1 -0
  115. package/dist/cli/flags.js +72 -0
  116. package/dist/cli/flags.js.map +1 -0
  117. package/dist/cli/handoff.d.ts +54 -0
  118. package/dist/cli/handoff.d.ts.map +1 -0
  119. package/dist/cli/handoff.js +106 -0
  120. package/dist/cli/handoff.js.map +1 -0
  121. package/dist/cli/handoffStore.d.ts +24 -0
  122. package/dist/cli/handoffStore.d.ts.map +1 -0
  123. package/dist/cli/handoffStore.js +49 -0
  124. package/dist/cli/handoffStore.js.map +1 -0
  125. package/dist/cli/hostWorkNextAction.d.ts +45 -0
  126. package/dist/cli/hostWorkNextAction.d.ts.map +1 -0
  127. package/dist/cli/hostWorkNextAction.js +43 -0
  128. package/dist/cli/hostWorkNextAction.js.map +1 -0
  129. package/dist/cli/io.d.ts +17 -0
  130. package/dist/cli/io.d.ts.map +1 -0
  131. package/dist/cli/io.js +19 -0
  132. package/dist/cli/io.js.map +1 -0
  133. package/dist/cli/router.d.ts +23 -0
  134. package/dist/cli/router.d.ts.map +1 -0
  135. package/dist/cli/router.js +236 -0
  136. package/dist/cli/router.js.map +1 -0
  137. package/dist/cli/runnerSelection.d.ts +60 -0
  138. package/dist/cli/runnerSelection.d.ts.map +1 -0
  139. package/dist/cli/runnerSelection.js +93 -0
  140. package/dist/cli/runnerSelection.js.map +1 -0
  141. package/dist/cli/serverHandshake.d.ts +51 -0
  142. package/dist/cli/serverHandshake.d.ts.map +1 -0
  143. package/dist/cli/serverHandshake.js +144 -0
  144. package/dist/cli/serverHandshake.js.map +1 -0
  145. package/dist/index.d.ts +2 -14
  146. package/dist/index.d.ts.map +1 -1
  147. package/dist/index.js +84 -138
  148. package/dist/index.js.map +1 -1
  149. package/dist/install/allowlists.d.ts +65 -0
  150. package/dist/install/allowlists.d.ts.map +1 -0
  151. package/dist/install/allowlists.js +333 -0
  152. package/dist/install/allowlists.js.map +1 -0
  153. package/dist/install/codexGuidance.d.ts +11 -0
  154. package/dist/install/codexGuidance.d.ts.map +1 -0
  155. package/dist/install/codexGuidance.js +90 -0
  156. package/dist/install/codexGuidance.js.map +1 -0
  157. package/dist/install/harnesses.d.ts +37 -26
  158. package/dist/install/harnesses.d.ts.map +1 -1
  159. package/dist/install/harnesses.js +312 -502
  160. package/dist/install/harnesses.js.map +1 -1
  161. package/dist/install/legacyMcp.d.ts +26 -0
  162. package/dist/install/legacyMcp.d.ts.map +1 -0
  163. package/dist/install/legacyMcp.js +160 -0
  164. package/dist/install/legacyMcp.js.map +1 -0
  165. package/dist/install/mcpRegistration.d.ts +45 -0
  166. package/dist/install/mcpRegistration.d.ts.map +1 -0
  167. package/dist/install/mcpRegistration.js +215 -0
  168. package/dist/install/mcpRegistration.js.map +1 -0
  169. package/dist/mcp/changeBatchClassification.d.ts +18 -20
  170. package/dist/mcp/changeBatchClassification.d.ts.map +1 -1
  171. package/dist/mcp/changeBatchClassification.js +41 -46
  172. package/dist/mcp/changeBatchClassification.js.map +1 -1
  173. package/dist/proxy-middleware/proxy-config.d.ts +6 -0
  174. package/dist/proxy-middleware/proxy-config.d.ts.map +1 -1
  175. package/dist/proxy-middleware/proxy-config.js +162 -5
  176. package/dist/proxy-middleware/proxy-config.js.map +1 -1
  177. package/dist/routes/agentVariants.d.ts +14 -2
  178. package/dist/routes/agentVariants.d.ts.map +1 -1
  179. package/dist/routes/agentVariants.js +321 -65
  180. package/dist/routes/agentVariants.js.map +1 -1
  181. package/dist/routes/cli.d.ts +31 -0
  182. package/dist/routes/cli.d.ts.map +1 -0
  183. package/dist/routes/cli.js +95 -0
  184. package/dist/routes/cli.js.map +1 -0
  185. package/dist/routes/git.d.ts +1 -0
  186. package/dist/routes/git.d.ts.map +1 -1
  187. package/dist/routes/git.js +2 -1
  188. package/dist/routes/git.js.map +1 -1
  189. package/dist/routes/inlineStartTracker.d.ts +23 -0
  190. package/dist/routes/inlineStartTracker.d.ts.map +1 -0
  191. package/dist/routes/inlineStartTracker.js +17 -0
  192. package/dist/routes/inlineStartTracker.js.map +1 -0
  193. package/dist/routes/mcp.d.ts +2 -12
  194. package/dist/routes/mcp.d.ts.map +1 -1
  195. package/dist/routes/mcp.js +4 -785
  196. package/dist/routes/mcp.js.map +1 -1
  197. package/dist/server.d.ts +24 -9
  198. package/dist/server.d.ts.map +1 -1
  199. package/dist/server.js +169 -33
  200. package/dist/server.js.map +1 -1
  201. package/dist/services/CommitMessageGenerator.d.ts +9 -1
  202. package/dist/services/CommitMessageGenerator.d.ts.map +1 -1
  203. package/dist/services/CommitMessageGenerator.js +4 -1
  204. package/dist/services/CommitMessageGenerator.js.map +1 -1
  205. package/dist/services/ComponentSearchService.d.ts +4 -1
  206. package/dist/services/ComponentSearchService.d.ts.map +1 -1
  207. package/dist/services/ComponentSearchService.js.map +1 -1
  208. package/dist/services/ConfigManager.d.ts +8 -0
  209. package/dist/services/ConfigManager.d.ts.map +1 -1
  210. package/dist/services/ConfigManager.js +9 -0
  211. package/dist/services/ConfigManager.js.map +1 -1
  212. package/dist/services/HistoryReplayService.d.ts +20 -9
  213. package/dist/services/HistoryReplayService.d.ts.map +1 -1
  214. package/dist/services/HistoryReplayService.js +99 -43
  215. package/dist/services/HistoryReplayService.js.map +1 -1
  216. package/dist/services/MCPVariantsTelemetry.d.ts +1 -1
  217. package/dist/services/MCPVariantsTelemetry.d.ts.map +1 -1
  218. package/dist/services/MCPVariantsTelemetry.js +1 -0
  219. package/dist/services/MCPVariantsTelemetry.js.map +1 -1
  220. package/dist/services/PRTitleGenerator.d.ts +10 -2
  221. package/dist/services/PRTitleGenerator.d.ts.map +1 -1
  222. package/dist/services/PRTitleGenerator.js +8 -2
  223. package/dist/services/PRTitleGenerator.js.map +1 -1
  224. package/dist/services/ProjectDetectionService.d.ts.map +1 -1
  225. package/dist/services/ProjectDetectionService.js +14 -4
  226. package/dist/services/ProjectDetectionService.js.map +1 -1
  227. package/dist/services/ProjectMetadataStore.d.ts +115 -0
  228. package/dist/services/ProjectMetadataStore.d.ts.map +1 -0
  229. package/dist/services/ProjectMetadataStore.js +336 -0
  230. package/dist/services/ProjectMetadataStore.js.map +1 -0
  231. package/dist/services/SessionBridgeService.d.ts +52 -224
  232. package/dist/services/SessionBridgeService.d.ts.map +1 -1
  233. package/dist/services/SessionBridgeService.js +97 -649
  234. package/dist/services/SessionBridgeService.js.map +1 -1
  235. package/dist/services/SessionService.d.ts +4 -1
  236. package/dist/services/SessionService.d.ts.map +1 -1
  237. package/dist/services/SessionService.js +7 -4
  238. package/dist/services/SessionService.js.map +1 -1
  239. package/dist/services/StaticFileService.d.ts.map +1 -1
  240. package/dist/services/StaticFileService.js +6 -0
  241. package/dist/services/StaticFileService.js.map +1 -1
  242. package/dist/services/TelemetryService.d.ts +16 -80
  243. package/dist/services/TelemetryService.d.ts.map +1 -1
  244. package/dist/services/TelemetryService.js +18 -94
  245. package/dist/services/TelemetryService.js.map +1 -1
  246. package/dist/services/VariantGenerationService.d.ts +52 -0
  247. package/dist/services/VariantGenerationService.d.ts.map +1 -0
  248. package/dist/services/VariantGenerationService.js +272 -0
  249. package/dist/services/VariantGenerationService.js.map +1 -0
  250. package/dist/services/VariantHistoryService.d.ts +37 -1
  251. package/dist/services/VariantHistoryService.d.ts.map +1 -1
  252. package/dist/services/VariantHistoryService.js +122 -1
  253. package/dist/services/VariantHistoryService.js.map +1 -1
  254. package/dist/services/VariantRunService.d.ts +25 -6
  255. package/dist/services/VariantRunService.d.ts.map +1 -1
  256. package/dist/services/VariantRunService.js +98 -4
  257. package/dist/services/VariantRunService.js.map +1 -1
  258. package/dist/services/VariantsRuntime.d.ts +1 -3
  259. package/dist/services/VariantsRuntime.d.ts.map +1 -1
  260. package/dist/services/VariantsRuntime.js +0 -1
  261. package/dist/services/VariantsRuntime.js.map +1 -1
  262. package/dist/services/WorktreeManager.d.ts +1 -1
  263. package/dist/services/WorktreeManager.d.ts.map +1 -1
  264. package/dist/services/createAgentVariantsOrchestrator.d.ts +2 -2
  265. package/dist/services/createAgentVariantsOrchestrator.d.ts.map +1 -1
  266. package/dist/services/createAgentVariantsOrchestrator.js +2 -3
  267. package/dist/services/createAgentVariantsOrchestrator.js.map +1 -1
  268. package/dist/services/projectMetadataMigrations.d.ts +59 -0
  269. package/dist/services/projectMetadataMigrations.d.ts.map +1 -0
  270. package/dist/services/projectMetadataMigrations.js +109 -0
  271. package/dist/services/projectMetadataMigrations.js.map +1 -0
  272. package/dist/types/change-request-types.d.ts +22 -0
  273. package/dist/types/change-request-types.d.ts.map +1 -1
  274. package/dist/utils/logger.d.ts +2 -1
  275. package/dist/utils/logger.d.ts.map +1 -1
  276. package/dist/utils/logger.js +3 -7
  277. package/dist/utils/logger.js.map +1 -1
  278. package/dist/utils/loopback.d.ts +3 -0
  279. package/dist/utils/loopback.d.ts.map +1 -0
  280. package/dist/utils/loopback.js +13 -0
  281. package/dist/utils/loopback.js.map +1 -0
  282. package/dist/utils/pid.d.ts +3 -0
  283. package/dist/utils/pid.d.ts.map +1 -0
  284. package/dist/utils/pid.js +15 -0
  285. package/dist/utils/pid.js.map +1 -0
  286. package/dist/utils/queueAccess.d.ts +7 -0
  287. package/dist/utils/queueAccess.d.ts.map +1 -1
  288. package/dist/utils/queueAccess.js +8 -1
  289. package/dist/utils/queueAccess.js.map +1 -1
  290. package/dist/utils/shouldRecordHostedDemoSessionAction.d.ts +3 -3
  291. package/dist/utils/shouldRecordHostedDemoSessionAction.d.ts.map +1 -1
  292. package/dist/utils/shouldRecordHostedDemoSessionAction.js +3 -19
  293. package/dist/utils/shouldRecordHostedDemoSessionAction.js.map +1 -1
  294. package/dist/utils/skillWriter.d.ts.map +1 -1
  295. package/dist/utils/skillWriter.js +12 -11
  296. package/dist/utils/skillWriter.js.map +1 -1
  297. package/dist/utils/skills/claude-skill.d.ts +7 -2
  298. package/dist/utils/skills/claude-skill.d.ts.map +1 -1
  299. package/dist/utils/skills/claude-skill.js +10 -83
  300. package/dist/utils/skills/claude-skill.js.map +1 -1
  301. package/dist/utils/skills/cli-guidance.d.ts +12 -0
  302. package/dist/utils/skills/cli-guidance.d.ts.map +1 -0
  303. package/dist/utils/skills/cli-guidance.js +57 -0
  304. package/dist/utils/skills/cli-guidance.js.map +1 -0
  305. package/dist/utils/skills/cursor-rules.d.ts +8 -2
  306. package/dist/utils/skills/cursor-rules.d.ts.map +1 -1
  307. package/dist/utils/skills/cursor-rules.js +11 -80
  308. package/dist/utils/skills/cursor-rules.js.map +1 -1
  309. package/dist/utils/variantSessionStart.d.ts +1 -1
  310. package/dist/utils/variantSessionStart.d.ts.map +1 -1
  311. package/dist/utils/variantSessionStart.js +1 -1
  312. package/dist/utils/variantSessionStart.js.map +1 -1
  313. package/package.json +4 -4
  314. package/src/ui/dist/assets/main-BWOvFoal.js +419 -0
  315. package/src/ui/dist/assets/main-Dyos9I29.css +1 -0
  316. package/src/ui/dist/index.html +2 -2
  317. package/dist/mcp/agent-variants/SessionStore.d.ts.map +0 -1
  318. package/dist/mcp/agent-variants/SessionStore.js.map +0 -1
  319. package/dist/mcp/agent-variants/WorktreeOrchestrator.d.ts.map +0 -1
  320. package/dist/mcp/agent-variants/WorktreeOrchestrator.js.map +0 -1
  321. package/dist/mcp/agent-variants/WorktreeOrchestrator.testHelpers.d.ts.map +0 -1
  322. package/dist/mcp/agent-variants/WorktreeOrchestrator.testHelpers.js.map +0 -1
  323. package/dist/mcp/agent-variants/areNaSourceContext.d.ts +0 -20
  324. package/dist/mcp/agent-variants/areNaSourceContext.d.ts.map +0 -1
  325. package/dist/mcp/agent-variants/areNaSourceContext.js +0 -118
  326. package/dist/mcp/agent-variants/areNaSourceContext.js.map +0 -1
  327. package/dist/mcp/agent-variants/briefContent.d.ts.map +0 -1
  328. package/dist/mcp/agent-variants/briefContent.js.map +0 -1
  329. package/dist/mcp/agent-variants/contracts.d.ts.map +0 -1
  330. package/dist/mcp/agent-variants/contracts.js.map +0 -1
  331. package/dist/mcp/agent-variants/createProjectArtifacts.d.ts.map +0 -1
  332. package/dist/mcp/agent-variants/createProjectArtifacts.js.map +0 -1
  333. package/dist/mcp/agent-variants/createZeroToOneTool.d.ts +0 -63
  334. package/dist/mcp/agent-variants/createZeroToOneTool.d.ts.map +0 -1
  335. package/dist/mcp/agent-variants/createZeroToOneTool.js +0 -265
  336. package/dist/mcp/agent-variants/createZeroToOneTool.js.map +0 -1
  337. package/dist/mcp/agent-variants/diffQa.d.ts.map +0 -1
  338. package/dist/mcp/agent-variants/diffQa.js.map +0 -1
  339. package/dist/mcp/agent-variants/elementRefToTarget.d.ts.map +0 -1
  340. package/dist/mcp/agent-variants/elementRefToTarget.js.map +0 -1
  341. package/dist/mcp/agent-variants/errors.d.ts.map +0 -1
  342. package/dist/mcp/agent-variants/errors.js.map +0 -1
  343. package/dist/mcp/agent-variants/generatedDestination.d.ts +0 -75
  344. package/dist/mcp/agent-variants/generatedDestination.d.ts.map +0 -1
  345. package/dist/mcp/agent-variants/generatedDestination.js +0 -103
  346. package/dist/mcp/agent-variants/generatedDestination.js.map +0 -1
  347. package/dist/mcp/agent-variants/index.d.ts.map +0 -1
  348. package/dist/mcp/agent-variants/index.js.map +0 -1
  349. package/dist/mcp/agent-variants/pendingChangesAdapter.d.ts +0 -38
  350. package/dist/mcp/agent-variants/pendingChangesAdapter.d.ts.map +0 -1
  351. package/dist/mcp/agent-variants/pendingChangesAdapter.js +0 -93
  352. package/dist/mcp/agent-variants/pendingChangesAdapter.js.map +0 -1
  353. package/dist/mcp/agent-variants/pinterestSourceContext.d.ts +0 -23
  354. package/dist/mcp/agent-variants/pinterestSourceContext.d.ts.map +0 -1
  355. package/dist/mcp/agent-variants/pinterestSourceContext.js +0 -137
  356. package/dist/mcp/agent-variants/pinterestSourceContext.js.map +0 -1
  357. package/dist/mcp/agent-variants/previewQa.d.ts.map +0 -1
  358. package/dist/mcp/agent-variants/previewQa.js.map +0 -1
  359. package/dist/mcp/agent-variants/runLabel.d.ts.map +0 -1
  360. package/dist/mcp/agent-variants/runLabel.js.map +0 -1
  361. package/dist/mcp/agent-variants/runPlan.d.ts.map +0 -1
  362. package/dist/mcp/agent-variants/runPlan.js.map +0 -1
  363. package/dist/mcp/agent-variants/sourceContext.d.ts.map +0 -1
  364. package/dist/mcp/agent-variants/sourceContext.js.map +0 -1
  365. package/dist/mcp/agent-variants/tools.d.ts +0 -187
  366. package/dist/mcp/agent-variants/tools.d.ts.map +0 -1
  367. package/dist/mcp/agent-variants/tools.js +0 -1165
  368. package/dist/mcp/agent-variants/tools.js.map +0 -1
  369. package/dist/mcp/agent-variants/variantContext.d.ts.map +0 -1
  370. package/dist/mcp/agent-variants/variantContext.js.map +0 -1
  371. package/dist/mcp/auth/httpOAuthProvider.d.ts +0 -103
  372. package/dist/mcp/auth/httpOAuthProvider.d.ts.map +0 -1
  373. package/dist/mcp/auth/httpOAuthProvider.js +0 -735
  374. package/dist/mcp/auth/httpOAuthProvider.js.map +0 -1
  375. package/dist/mcp/auth/tools.d.ts +0 -39
  376. package/dist/mcp/auth/tools.d.ts.map +0 -1
  377. package/dist/mcp/auth/tools.js +0 -304
  378. package/dist/mcp/auth/tools.js.map +0 -1
  379. package/dist/mcp/branding.d.ts +0 -4
  380. package/dist/mcp/branding.d.ts.map +0 -1
  381. package/dist/mcp/branding.js +0 -8
  382. package/dist/mcp/branding.js.map +0 -1
  383. package/dist/mcp/hostedServer.d.ts +0 -27
  384. package/dist/mcp/hostedServer.d.ts.map +0 -1
  385. package/dist/mcp/hostedServer.js +0 -71
  386. package/dist/mcp/hostedServer.js.map +0 -1
  387. package/dist/mcp/httpServer.d.ts +0 -63
  388. package/dist/mcp/httpServer.d.ts.map +0 -1
  389. package/dist/mcp/httpServer.js +0 -602
  390. package/dist/mcp/httpServer.js.map +0 -1
  391. package/dist/mcp/instructions.d.ts +0 -25
  392. package/dist/mcp/instructions.d.ts.map +0 -1
  393. package/dist/mcp/instructions.js +0 -39
  394. package/dist/mcp/instructions.js.map +0 -1
  395. package/dist/mcp/integrations/tools.d.ts +0 -19
  396. package/dist/mcp/integrations/tools.d.ts.map +0 -1
  397. package/dist/mcp/integrations/tools.js +0 -101
  398. package/dist/mcp/integrations/tools.js.map +0 -1
  399. package/dist/mcp/server.d.ts +0 -214
  400. package/dist/mcp/server.d.ts.map +0 -1
  401. package/dist/mcp/server.js +0 -2536
  402. package/dist/mcp/server.js.map +0 -1
  403. package/dist/mcp/toolAnalytics.d.ts +0 -26
  404. package/dist/mcp/toolAnalytics.d.ts.map +0 -1
  405. package/dist/mcp/toolAnalytics.js +0 -95
  406. package/dist/mcp/toolAnalytics.js.map +0 -1
  407. package/dist/mcp/types.d.ts +0 -7
  408. package/dist/mcp/types.d.ts.map +0 -1
  409. package/dist/mcp/types.js +0 -3
  410. package/dist/mcp/types.js.map +0 -1
  411. package/dist/mcp/watchLoopResumePrompt.d.ts +0 -16
  412. package/dist/mcp/watchLoopResumePrompt.d.ts.map +0 -1
  413. package/dist/mcp/watchLoopResumePrompt.js +0 -21
  414. package/dist/mcp/watchLoopResumePrompt.js.map +0 -1
  415. package/dist/prompts/agentModPrompts.d.ts +0 -4
  416. package/dist/prompts/agentModPrompts.d.ts.map +0 -1
  417. package/dist/prompts/agentModPrompts.js +0 -34
  418. package/dist/prompts/agentModPrompts.js.map +0 -1
  419. package/dist/prompts/tokenWriterPrompts.d.ts +0 -4
  420. package/dist/prompts/tokenWriterPrompts.d.ts.map +0 -1
  421. package/dist/prompts/tokenWriterPrompts.js +0 -59
  422. package/dist/prompts/tokenWriterPrompts.js.map +0 -1
  423. package/dist/routes/comments.d.ts +0 -3
  424. package/dist/routes/comments.d.ts.map +0 -1
  425. package/dist/routes/comments.js +0 -113
  426. package/dist/routes/comments.js.map +0 -1
  427. package/dist/routes/components.d.ts +0 -7
  428. package/dist/routes/components.d.ts.map +0 -1
  429. package/dist/routes/components.js +0 -88
  430. package/dist/routes/components.js.map +0 -1
  431. package/dist/routes/controls.d.ts +0 -7
  432. package/dist/routes/controls.d.ts.map +0 -1
  433. package/dist/routes/controls.js +0 -50
  434. package/dist/routes/controls.js.map +0 -1
  435. package/dist/routes/design.d.ts +0 -2
  436. package/dist/routes/design.d.ts.map +0 -1
  437. package/dist/routes/design.js +0 -29
  438. package/dist/routes/design.js.map +0 -1
  439. package/dist/routes/modifications.d.ts +0 -10
  440. package/dist/routes/modifications.d.ts.map +0 -1
  441. package/dist/routes/modifications.js +0 -394
  442. package/dist/routes/modifications.js.map +0 -1
  443. package/dist/routes/tokens.d.ts +0 -2
  444. package/dist/routes/tokens.d.ts.map +0 -1
  445. package/dist/routes/tokens.js +0 -115
  446. package/dist/routes/tokens.js.map +0 -1
  447. package/dist/services/AgentSessionService.d.ts +0 -91
  448. package/dist/services/AgentSessionService.d.ts.map +0 -1
  449. package/dist/services/AgentSessionService.js +0 -282
  450. package/dist/services/AgentSessionService.js.map +0 -1
  451. package/dist/services/BridgeBatchPipeline.d.ts +0 -103
  452. package/dist/services/BridgeBatchPipeline.d.ts.map +0 -1
  453. package/dist/services/BridgeBatchPipeline.js +0 -295
  454. package/dist/services/BridgeBatchPipeline.js.map +0 -1
  455. package/dist/services/BridgeQueueStore.d.ts +0 -28
  456. package/dist/services/BridgeQueueStore.d.ts.map +0 -1
  457. package/dist/services/BridgeQueueStore.js +0 -88
  458. package/dist/services/BridgeQueueStore.js.map +0 -1
  459. package/dist/services/CSSTokenWriter.d.ts +0 -22
  460. package/dist/services/CSSTokenWriter.d.ts.map +0 -1
  461. package/dist/services/CSSTokenWriter.js +0 -116
  462. package/dist/services/CSSTokenWriter.js.map +0 -1
  463. package/dist/services/DesignTokenService.d.ts +0 -39
  464. package/dist/services/DesignTokenService.d.ts.map +0 -1
  465. package/dist/services/DesignTokenService.js +0 -100
  466. package/dist/services/DesignTokenService.js.map +0 -1
  467. package/dist/services/InlineVariantGenerationService.d.ts +0 -51
  468. package/dist/services/InlineVariantGenerationService.d.ts.map +0 -1
  469. package/dist/services/InlineVariantGenerationService.js +0 -475
  470. package/dist/services/InlineVariantGenerationService.js.map +0 -1
  471. package/dist/services/InterfaceGenerationService.d.ts +0 -12
  472. package/dist/services/InterfaceGenerationService.d.ts.map +0 -1
  473. package/dist/services/InterfaceGenerationService.js +0 -256
  474. package/dist/services/InterfaceGenerationService.js.map +0 -1
  475. package/dist/services/TailwindConfigWriter.d.ts +0 -24
  476. package/dist/services/TailwindConfigWriter.d.ts.map +0 -1
  477. package/dist/services/TailwindConfigWriter.js +0 -105
  478. package/dist/services/TailwindConfigWriter.js.map +0 -1
  479. package/dist/services/TerminalAgentRunner.d.ts +0 -65
  480. package/dist/services/TerminalAgentRunner.d.ts.map +0 -1
  481. package/dist/services/TerminalAgentRunner.js +0 -511
  482. package/dist/services/TerminalAgentRunner.js.map +0 -1
  483. package/dist/services/VisualVariantAgentRunner.d.ts +0 -20
  484. package/dist/services/VisualVariantAgentRunner.d.ts.map +0 -1
  485. package/dist/services/VisualVariantAgentRunner.js +0 -66
  486. package/dist/services/VisualVariantAgentRunner.js.map +0 -1
  487. package/dist/services/adapters/TailwindCSSTokenAdapter.d.ts +0 -35
  488. package/dist/services/adapters/TailwindCSSTokenAdapter.d.ts.map +0 -1
  489. package/dist/services/adapters/TailwindCSSTokenAdapter.js +0 -278
  490. package/dist/services/adapters/TailwindCSSTokenAdapter.js.map +0 -1
  491. package/dist/services/agent/AgentCore.d.ts +0 -126
  492. package/dist/services/agent/AgentCore.d.ts.map +0 -1
  493. package/dist/services/agent/AgentCore.js +0 -759
  494. package/dist/services/agent/AgentCore.js.map +0 -1
  495. package/dist/services/agent/AgentModService.d.ts +0 -98
  496. package/dist/services/agent/AgentModService.d.ts.map +0 -1
  497. package/dist/services/agent/AgentModService.js +0 -400
  498. package/dist/services/agent/AgentModService.js.map +0 -1
  499. package/dist/services/agent/index.d.ts +0 -2
  500. package/dist/services/agent/index.d.ts.map +0 -1
  501. package/dist/services/agent/index.js +0 -6
  502. package/dist/services/agent/index.js.map +0 -1
  503. package/dist/types/editor-interface-types.d.ts +0 -67
  504. package/dist/types/editor-interface-types.d.ts.map +0 -1
  505. package/dist/types/editor-interface-types.js +0 -12
  506. package/dist/types/editor-interface-types.js.map +0 -1
  507. package/dist/utils/elementRefToContext.d.ts +0 -4
  508. package/dist/utils/elementRefToContext.d.ts.map +0 -1
  509. package/dist/utils/elementRefToContext.js +0 -63
  510. package/dist/utils/elementRefToContext.js.map +0 -1
  511. package/dist/utils/skills/shared-variants-protocol.d.ts +0 -69
  512. package/dist/utils/skills/shared-variants-protocol.d.ts.map +0 -1
  513. package/dist/utils/skills/shared-variants-protocol.js +0 -292
  514. package/dist/utils/skills/shared-variants-protocol.js.map +0 -1
  515. package/src/ui/dist/assets/main-CLAqO1bm.js +0 -656
  516. package/src/ui/dist/assets/main-Ke-Q9lWa.css +0 -1
  517. /package/dist/{mcp/agent-variants → agent-variants}/briefContent.d.ts +0 -0
  518. /package/dist/{mcp/agent-variants → agent-variants}/briefContent.js +0 -0
  519. /package/dist/{mcp/agent-variants → agent-variants}/createProjectArtifacts.d.ts +0 -0
  520. /package/dist/{mcp/agent-variants → agent-variants}/createProjectArtifacts.js +0 -0
  521. /package/dist/{mcp/agent-variants → agent-variants}/diffQa.d.ts +0 -0
  522. /package/dist/{mcp/agent-variants → agent-variants}/diffQa.js +0 -0
  523. /package/dist/{mcp/agent-variants → agent-variants}/elementRefToTarget.js +0 -0
  524. /package/dist/{mcp/agent-variants → agent-variants}/errors.d.ts +0 -0
  525. /package/dist/{mcp/agent-variants → agent-variants}/errors.js +0 -0
  526. /package/dist/{mcp/agent-variants → agent-variants}/previewQa.d.ts +0 -0
  527. /package/dist/{mcp/agent-variants → agent-variants}/previewQa.js +0 -0
  528. /package/dist/{mcp/agent-variants → agent-variants}/runLabel.d.ts +0 -0
  529. /package/dist/{mcp/agent-variants → agent-variants}/runLabel.js +0 -0
  530. /package/dist/{mcp/agent-variants → agent-variants}/runPlan.d.ts +0 -0
  531. /package/dist/{mcp/agent-variants → agent-variants}/runPlan.js +0 -0
  532. /package/dist/{mcp/agent-variants → agent-variants}/sourceContext.d.ts +0 -0
  533. /package/dist/{mcp/agent-variants → agent-variants}/sourceContext.js +0 -0
  534. /package/dist/{mcp/agent-variants → agent-variants}/variantContext.d.ts +0 -0
  535. /package/dist/{mcp/agent-variants → agent-variants}/variantContext.js +0 -0
@@ -1,95 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SessionBridgeService = exports.MAX_APPLY_BATCH_BYTES = exports.MAX_VARIANT_REQUEST_BYTES = exports.MAX_LEASED_VARIANT_BATCHES = exports.MAX_PENDING_APPLY_BATCHES = exports.MAX_PENDING_VARIANT_REQUESTS = void 0;
3
+ exports.SessionBridgeService = void 0;
4
4
  const crypto_1 = require("crypto");
5
5
  const index_core_1 = require("../index-core");
6
- const changeBatchClassification_1 = require("../mcp/changeBatchClassification");
7
- const BridgeBatchPipeline_1 = require("./BridgeBatchPipeline");
8
- const BridgeQueueStore_1 = require("./BridgeQueueStore");
9
6
  const log = (0, index_core_1.createLogger)('SessionBridgeService');
10
- /**
11
- * Upper bound on the variant-request FIFO depth. The queue intentionally
12
- * appends (never clobbers) so concurrent "Vary" runs aren't dropped, but
13
- * without a cap a caller hitting the unauthenticated queue endpoint could
14
- * append unboundedly and exhaust server memory. 16 is far above any real
15
- * concurrent-Vary workload; past it we reject with backpressure (HTTP 429)
16
- * so the request surfaces as an error the user can retry, rather than being
17
- * silently dropped or growing the queue.
18
- */
19
- exports.MAX_PENDING_VARIANT_REQUESTS = 16;
20
- /** FIFO depth cap for apply batches (was a single overwrite slot). */
21
- exports.MAX_PENDING_APPLY_BATCHES = 16;
22
- /** Maximum concurrent variant batches leased to agents/watchers. */
23
- exports.MAX_LEASED_VARIANT_BATCHES = 4;
24
- /**
25
- * Per-batch byte budget for a queued variant-request/refine batch. The count
26
- * cap above bounds HOW MANY batches queue; this bounds how BIG one can be. The
27
- * route schema already caps attached images, but `instruction` / `sourceFiles`
28
- * / element metadata are otherwise bounded only by the (much larger) HTTP body
29
- * limit — so without this a local/LAN caller could pin memory with a few large
30
- * batches × the FIFO depth. ~2MB of non-image text/metadata is generous.
31
- */
32
- exports.MAX_VARIANT_REQUEST_BYTES = 2 * 1024 * 1024;
33
- /** Same per-batch byte cap for apply batches queued on the apply FIFO. */
34
- exports.MAX_APPLY_BATCH_BYTES = exports.MAX_VARIANT_REQUEST_BYTES;
35
- /**
36
- * Manages the lifecycle of an MCP visual editing session and queues
37
- * changes between the Rivet UI and the MCP server.
38
- *
39
- * Instantiated by the MCP server and shared in-memory with the Express
40
- * server so both MCP tool handlers and REST endpoints can access it.
41
- */
7
+ const EMPTY_DEV_SERVER_HEALTH = {
8
+ ownership: 'none',
9
+ host: null,
10
+ port: null,
11
+ isReachable: null,
12
+ reason: 'unknown',
13
+ lastCheckedAt: null,
14
+ startedByRivet: false,
15
+ };
42
16
  class SessionBridgeService {
43
17
  sessionId = null;
18
+ projectPath = null;
19
+ feedback = [];
20
+ status = 'IDLE';
21
+ roundsCompleted = 0;
22
+ telemetryContext = null;
44
23
  _setVariantTarget = null;
45
24
  _variantLookup = null;
46
25
  _isVariantPortAllowed = null;
47
26
  statusAccessToken = null;
48
- projectPath = null;
49
- applyPipeline = new BridgeBatchPipeline_1.BridgeBatchPipeline({
50
- kind: 'apply',
51
- maxQueued: exports.MAX_PENDING_APPLY_BATCHES,
52
- maxConcurrentLeases: 1,
53
- queueFullReason: 'apply_queue_full',
54
- });
55
- variantPipeline = new BridgeBatchPipeline_1.BridgeBatchPipeline({
56
- kind: 'variant',
57
- maxQueued: exports.MAX_PENDING_VARIANT_REQUESTS,
58
- maxConcurrentLeases: exports.MAX_LEASED_VARIANT_BATCHES,
59
- queueFullReason: 'variant_queue_full',
60
- });
61
- telemetryContext = null;
62
- roundsCompleted = 0;
63
- feedback = [];
64
- status = 'IDLE';
65
- // Blocking watch_for_changes waiters, FIFO. A multi-element queue (not a
66
- // single slot) so several concurrent watchers can each block and each wake on
67
- // a DIFFERENT queued change — one change wakes one waiter — letting parallel
68
- // agents pick up distinct batches instead of clobbering each other's waiter.
69
- waitResolvers = [];
70
- /**
71
- * Subscribers notified whenever {@link WatcherLiveness} could have changed
72
- * (queue/drain/waiter register/settle). The variants SSE stream subscribes so
73
- * a strand the user causes — sending a change with no watcher draining it —
74
- * re-pushes the snapshot promptly instead of waiting on the next orchestrator
75
- * event, which a stranded queue never produces.
76
- */
77
- livenessListeners = new Set();
78
- activeRunCorrelation = null;
79
27
  baseDevServerHealth = null;
80
- devServerHealth = {
81
- ownership: 'none',
82
- host: null,
83
- port: null,
84
- isReachable: null,
85
- reason: 'unknown',
86
- lastCheckedAt: null,
87
- startedByRivet: false,
88
- };
89
- /**
90
- * Start a new MCP visual editing session
91
- * @returns The unique session ID
92
- */
28
+ devServerHealth = { ...EMPTY_DEV_SERVER_HEALTH };
29
+ sessionInitiator = null;
30
+ resolvedRunner = null;
31
+ runnerMismatches = [];
32
+ livenessListeners = new Set();
93
33
  startSession(projectPath) {
94
34
  if (this.sessionId) {
95
35
  log.warn('Session already active, ending previous session');
@@ -97,121 +37,54 @@ class SessionBridgeService {
97
37
  }
98
38
  this.sessionId = (0, crypto_1.randomUUID)();
99
39
  this.projectPath = projectPath;
100
- this.applyPipeline = new BridgeBatchPipeline_1.BridgeBatchPipeline({
101
- kind: 'apply',
102
- maxQueued: exports.MAX_PENDING_APPLY_BATCHES,
103
- maxConcurrentLeases: 1,
104
- queueFullReason: 'apply_queue_full',
105
- });
106
- this.variantPipeline = new BridgeBatchPipeline_1.BridgeBatchPipeline({
107
- kind: 'variant',
108
- maxQueued: exports.MAX_PENDING_VARIANT_REQUESTS,
109
- maxConcurrentLeases: exports.MAX_LEASED_VARIANT_BATCHES,
110
- queueFullReason: 'variant_queue_full',
111
- });
112
- const persisted = BridgeQueueStore_1.bridgeQueueStore.load(projectPath, this.sessionId);
113
- if (persisted) {
114
- this.applyPipeline.hydrate(persisted.apply);
115
- this.variantPipeline.hydrate(persisted.variant);
116
- this.roundsCompleted = persisted.roundsCompleted;
117
- }
118
- else {
119
- this.roundsCompleted = 0;
120
- }
121
- this.telemetryContext = null;
122
40
  this.feedback = [];
123
41
  this.status = 'IDLE';
124
- this.activeRunCorrelation = null;
42
+ this.roundsCompleted = 0;
43
+ this.telemetryContext = null;
44
+ this.sessionInitiator = null;
45
+ this.resolvedRunner = null;
46
+ this.runnerMismatches = [];
125
47
  this.baseDevServerHealth = null;
48
+ this.devServerHealth = { ...EMPTY_DEV_SERVER_HEALTH };
126
49
  this._variantLookup = null;
127
50
  this._isVariantPortAllowed = null;
128
51
  this.statusAccessToken = null;
129
- this.devServerHealth = {
130
- ownership: 'none',
131
- host: null,
132
- port: null,
133
- isReachable: null,
134
- reason: 'unknown',
135
- lastCheckedAt: null,
136
- startedByRivet: false,
137
- };
138
52
  log.info(`Session started: ${this.sessionId} for ${projectPath}`);
139
- this.persistQueue();
140
53
  this.notifyLivenessChange();
141
54
  return this.sessionId;
142
55
  }
143
- /** Write the current queue snapshot to disk for MCP restart recovery. */
144
- persistQueue() {
145
- if (!this.sessionId || !this.projectPath) {
146
- return;
147
- }
148
- BridgeQueueStore_1.bridgeQueueStore.save(this.projectPath, this.sessionId, {
149
- ...(0, BridgeQueueStore_1.emptyBridgeQueueSnapshot)(this.projectPath),
150
- apply: this.applyPipeline.snapshot(),
151
- variant: this.variantPipeline.snapshot(),
152
- roundsCompleted: this.roundsCompleted,
153
- updatedAt: Date.now(),
154
- });
155
- }
156
- buildQueuedBatch(intent) {
157
- const requestId = intent.agentRunId ?? intent.traceId ?? (0, crypto_1.randomUUID)();
158
- return {
159
- intent,
160
- enqueuedAt: Date.now(),
161
- leaseId: (0, crypto_1.randomUUID)(),
162
- requestId,
163
- };
164
- }
165
- /**
166
- * Add a feedback message to the session.
167
- * Feedback is shown in the Rivet UI to let the user know what the MCP client is doing.
168
- * Normalizes literal escape sequences (e.g. `\n`, `\t`) that MCP clients sometimes
169
- * emit instead of real whitespace characters.
170
- */
171
56
  reportFeedback(message) {
172
57
  if (!this.sessionId) {
173
58
  log.warn('Cannot report feedback: no active session');
174
59
  return;
175
60
  }
176
- // Internal __RIVET_* signals carry JSON payloads — do not normalize escape
177
- // sequences in them, or the embedded JSON becomes unparseable.
178
61
  const normalized = message.startsWith('__RIVET_')
179
62
  ? message
180
63
  : message.replace(/\\n/g, '\n').replace(/\\t/g, '\t');
181
64
  this.feedback.push(normalized);
182
65
  log.info(`Feedback reported: ${normalized}`);
183
66
  }
184
- /** Get all feedback messages for the current session */
185
67
  getFeedback() {
186
68
  return this.feedback;
187
69
  }
188
- /** Get the current session status */
189
70
  getStatus() {
190
71
  return this.status;
191
72
  }
192
- /** Set the session status (used by MCP tools to indicate progress) */
193
73
  setStatus(status) {
194
74
  if (this.status !== status) {
195
75
  log.info(`Session status changed: ${this.status} -> ${status}`);
196
76
  this.status = status;
197
77
  }
198
78
  }
199
- /** Check whether a session is currently active */
200
79
  isActive() {
201
80
  return this.sessionId !== null;
202
81
  }
203
- /** Get the current session ID, or null if no session is active */
204
82
  getSessionId() {
205
83
  return this.sessionId;
206
84
  }
207
- /** Get the project path for the current session */
208
85
  getProjectPath() {
209
86
  return this.projectPath;
210
87
  }
211
- /**
212
- * Rebind the active session to a new project root after a fresh-variant
213
- * handoff succeeds.
214
- */
215
88
  rebindProjectPath(projectPath) {
216
89
  if (!this.sessionId) {
217
90
  throw new Error('Cannot rebind project path without an active session');
@@ -219,386 +92,70 @@ class SessionBridgeService {
219
92
  this.projectPath = projectPath;
220
93
  log.info(`Session project rebound to ${projectPath}`);
221
94
  }
222
- /**
223
- * Queue changes from the Rivet UI for retrieval by the MCP client.
224
- * Each send appends to the apply or variant FIFO (never overwrites).
225
- */
226
- queueChangeRequest(intent) {
227
- if (!this.sessionId) {
228
- log.warn('Cannot queue changes: no active session');
229
- return { accepted: true };
230
- }
231
- this.feedback = [];
232
- this.updateTelemetryContext(intent.telemetryContext);
233
- let enqueueResult;
234
- if (!(0, changeBatchClassification_1.isMixedVariantBatch)(intent) &&
235
- ((0, changeBatchClassification_1.isSingleVariantRequestBatch)(intent) ||
236
- (0, changeBatchClassification_1.isStaticPreviewRefineBatch)(intent))) {
237
- const approxBytes = Buffer.byteLength(JSON.stringify(intent));
238
- if (approxBytes > exports.MAX_VARIANT_REQUEST_BYTES) {
239
- log.warn(`Variant-request batch too large (${approxBytes} bytes > ${exports.MAX_VARIANT_REQUEST_BYTES}); rejecting`);
240
- return { accepted: false, reason: 'variant_request_too_large' };
241
- }
242
- enqueueResult = this.variantPipeline.enqueue(this.buildQueuedBatch(intent));
243
- if (enqueueResult.accepted) {
244
- log.info(`Variant-request batch queued (${this.variantPipeline.queuedDepth()} pending): ${intent.changes.length} changes`);
245
- }
246
- else {
247
- log.warn(`Variant-request queue full (${exports.MAX_PENDING_VARIANT_REQUESTS} pending); rejecting new batch`);
248
- }
249
- }
250
- else {
251
- const approxBytes = Buffer.byteLength(JSON.stringify(intent));
252
- if (approxBytes > exports.MAX_APPLY_BATCH_BYTES) {
253
- log.warn(`Apply batch too large (${approxBytes} bytes > ${exports.MAX_APPLY_BATCH_BYTES}); rejecting`);
254
- return { accepted: false, reason: 'apply_batch_too_large' };
255
- }
256
- enqueueResult = this.applyPipeline.enqueue(this.buildQueuedBatch(intent));
257
- if (enqueueResult.accepted) {
258
- log.info(`Change request queued (Round ${this.roundsCompleted + 1}): ${intent.changes.length} changes, ${intent.sourceFiles.length} source files`);
259
- }
260
- else {
261
- log.warn(`Apply queue full (${exports.MAX_PENDING_APPLY_BATCHES} pending); rejecting new batch`);
262
- }
263
- }
264
- if (!enqueueResult.accepted) {
265
- return enqueueResult;
266
- }
267
- this.persistQueue();
268
- const waiter = this.waitResolvers.shift();
269
- if (waiter)
270
- waiter(intent);
271
- this.notifyLivenessChange();
272
- return { accepted: true };
273
- }
274
- /**
275
- * Retrieve the oldest queued apply batch intent without leasing it.
276
- */
277
- getPendingChanges() {
278
- return this.applyPipeline.peekHeadIntent();
279
- }
280
- /** True when one or more variant-request/refine batches are queued or leased. */
281
- hasPendingVariantRequests() {
282
- return this.variantPipeline.hasWork();
95
+ hasUnfinishedWork() {
96
+ return false;
283
97
  }
284
- /** Queued variant batches still waiting for lease pickup. */
285
- pendingVariantRequestCount() {
286
- return this.variantPipeline.queuedDepth();
287
- }
288
- /** Non-destructive snapshot of queued variant-request/refine batches. */
289
- peekVariantRequests() {
290
- return this.variantPipeline.peekQueuedIntents();
291
- }
292
- /**
293
- * Resolve the active visual editor project for a queued or leased variant
294
- * request. Returns null for unrelated request ids so direct variant runs keep
295
- * their caller/cwd defaults.
296
- */
297
- resolveVariantRequestProjectPath(requestId) {
298
- if (!this.projectPath || !this.variantPipeline.hasRequestId(requestId)) {
299
- return null;
300
- }
301
- return this.projectPath;
98
+ getChannelDepth(_kind) {
99
+ return { queued: 0, leased: 0 };
302
100
  }
303
- /**
304
- * Lease the oldest eligible batch across apply and variant channels.
305
- * Global FIFO uses oldest `enqueuedAt` among channels that can lease.
306
- */
307
- leaseBatch(requestId) {
308
- if (requestId) {
309
- const applyLease = this.applyPipeline.leaseNext(requestId);
310
- if (applyLease) {
311
- this.persistQueue();
312
- this.notifyLivenessChange();
313
- return applyLease;
314
- }
315
- const variantLease = this.variantPipeline.leaseNext(requestId);
316
- if (variantLease) {
317
- this.persistQueue();
318
- this.notifyLivenessChange();
319
- return variantLease;
320
- }
321
- return null;
322
- }
323
- const candidates = [];
324
- const applyHeadAt = this.applyPipeline.oldestQueuedEnqueuedAt();
325
- if (this.applyPipeline.canLease() && applyHeadAt !== null) {
326
- candidates.push({ kind: 'apply', enqueuedAt: applyHeadAt });
327
- }
328
- const variantHeadAt = this.variantPipeline.oldestQueuedEnqueuedAt();
329
- if (this.variantPipeline.canLease() && variantHeadAt !== null) {
330
- candidates.push({ kind: 'variant', enqueuedAt: variantHeadAt });
331
- }
332
- if (candidates.length === 0) {
333
- return null;
334
- }
335
- candidates.sort((a, b) => a.enqueuedAt - b.enqueuedAt);
336
- const head = candidates[0];
337
- const lease = head.kind === 'apply'
338
- ? this.applyPipeline.leaseNext()
339
- : this.variantPipeline.leaseNext();
340
- if (lease) {
341
- this.persistQueue();
342
- this.notifyLivenessChange();
343
- }
344
- return lease;
345
- }
346
- /**
347
- * Release a leased batch after the agent completes work (`refresh_git` or `ack_batch`).
348
- */
349
- ackBatch(params) {
350
- if (this.applyPipeline.findLease(params.leaseId)) {
351
- const hadLease = Boolean(this.applyPipeline.findLease(params.leaseId));
352
- const result = this.applyPipeline.ack(params);
353
- if (hadLease) {
354
- this.roundsCompleted += 1;
355
- }
356
- this.persistQueue();
357
- this.notifyLivenessChange();
358
- const applyAck = { ...result, kind: 'apply' };
359
- return applyAck;
360
- }
361
- if (this.variantPipeline.findLease(params.leaseId)) {
362
- const result = this.variantPipeline.ack(params);
363
- this.persistQueue();
364
- this.notifyLivenessChange();
365
- const variantAck = { ...result, kind: 'variant' };
366
- return variantAck;
367
- }
368
- return { acked: true, mergedRequestIds: [] };
101
+ getActiveLeaseMetadata() {
102
+ return [];
369
103
  }
370
- /** True when either channel has queued or in-flight leased work. */
371
- hasUnfinishedWork() {
372
- return this.applyPipeline.hasWork() || this.variantPipeline.hasWork();
104
+ getQueuedBatchMetadata() {
105
+ return [];
373
106
  }
374
- /** Queue and leased depth for one channel (status API). */
375
- getChannelDepth(kind) {
376
- const pipeline = kind === 'apply' ? this.applyPipeline : this.variantPipeline;
377
- return {
378
- queued: pipeline.queuedDepth(),
379
- leased: pipeline.leasedDepth(),
380
- };
107
+ getActiveRunCorrelation() {
108
+ return null;
381
109
  }
382
- /** @deprecated Use {@link ackBatch} after the agent completes a leased apply batch. */
383
- shiftVariantRequest() {
384
- const lease = this.variantPipeline.leaseNext();
385
- if (!lease) {
386
- return null;
387
- }
388
- this.variantPipeline.ack({
389
- leaseId: lease.leaseId,
390
- requestId: lease.requestId,
391
- });
392
- this.persistQueue();
393
- this.notifyLivenessChange();
394
- return lease.intent;
395
- }
396
- /**
397
- * Block until changes are queued, or return immediately if already pending.
398
- * Used by watch_for_changes for clients without background monitoring (e.g. Cursor).
399
- * Rejects if the timeout is reached.
400
- */
401
- waitForChanges(timeoutMs = 300_000) {
402
- const existing = this.applyPipeline.peekHeadIntent() ??
403
- this.variantPipeline.peekHeadIntent();
404
- if (existing) {
405
- return Promise.resolve(existing);
406
- }
407
- return new Promise((resolve, reject) => {
408
- const resolver = (intent) => {
409
- clearTimeout(timer);
410
- resolve(intent);
411
- };
412
- const timer = setTimeout(() => {
413
- const idx = this.waitResolvers.indexOf(resolver);
414
- if (idx !== -1)
415
- this.waitResolvers.splice(idx, 1);
416
- this.notifyLivenessChange();
417
- reject(new Error('Timed out waiting for design changes'));
418
- }, timeoutMs);
419
- this.waitResolvers.push(resolver);
420
- this.notifyLivenessChange();
421
- });
110
+ getSettledRequestIds() {
111
+ return [];
422
112
  }
423
- /**
424
- * Ack the active apply lease after processing (legacy alias for tests).
425
- */
426
- clearPending(expectedIntent) {
427
- const snapshot = this.applyPipeline.snapshot();
428
- const activeLease = snapshot.leased[0];
429
- if (activeLease) {
430
- if (expectedIntent && activeLease.intent !== expectedIntent) {
431
- log.info('Pending intent changed while processing; preserving newer intent');
432
- return;
433
- }
434
- this.ackBatch({
435
- leaseId: activeLease.leaseId,
436
- requestId: activeLease.requestId,
437
- });
438
- log.info(`Pending intent cleared, round ${this.roundsCompleted} complete`);
439
- return;
440
- }
441
- const head = this.applyPipeline.peekHeadIntent();
442
- if (!head) {
443
- return;
444
- }
445
- if (expectedIntent && head !== expectedIntent) {
446
- log.info('Pending intent changed while processing; preserving newer intent');
447
- return;
448
- }
449
- const lease = this.applyPipeline.leaseNext();
450
- if (lease) {
451
- this.ackBatch({ leaseId: lease.leaseId, requestId: lease.requestId });
452
- log.info(`Pending intent cleared, round ${this.roundsCompleted} complete`);
453
- }
113
+ getRoundsCompleted() {
114
+ return this.roundsCompleted;
454
115
  }
455
- /** @deprecated Leased batches are released via {@link ackBatch}. */
456
- consumeVariantRequestBatch(expectedIntent) {
457
- const lease = expectedIntent
458
- ? this.findVariantLeaseForIntent(expectedIntent)
459
- : this.variantPipeline.leaseNext();
460
- if (!lease) {
461
- return null;
462
- }
463
- log.info(`variant-request batch consumed (no apply run started, ${lease.intent.changes.length} items)`);
464
- return lease.intent;
465
- }
466
- /** @deprecated Leased batches are released via {@link ackBatch}. */
467
- consumeStaticPreviewRefineBatch(expectedIntent) {
468
- const lease = expectedIntent
469
- ? this.findVariantLeaseForIntent(expectedIntent)
470
- : this.variantPipeline.leaseNext();
471
- if (!lease) {
472
- return null;
116
+ setSessionRuntimeInfo(info) {
117
+ if ('sessionInitiator' in info) {
118
+ this.sessionInitiator = info.sessionInitiator ?? null;
473
119
  }
474
- log.info(`static-preview refine batch consumed (no apply run started, ${lease.intent.changes.length} items)`);
475
- return lease.intent;
476
- }
477
- findVariantLeaseForIntent(expectedIntent) {
478
- const requestId = expectedIntent.agentRunId ?? expectedIntent.traceId;
479
- if (requestId) {
480
- const existing = this.variantPipeline.leaseNext(requestId);
481
- if (existing) {
482
- return existing;
483
- }
484
- const leased = this.variantPipeline.leaseQueuedRequestId(requestId);
485
- if (leased) {
486
- this.persistQueue();
487
- this.notifyLivenessChange();
488
- return leased;
489
- }
120
+ if ('resolvedRunner' in info) {
121
+ this.resolvedRunner = info.resolvedRunner ?? null;
490
122
  }
491
- else {
492
- const head = this.variantPipeline.peekHeadIntent();
493
- if (head === expectedIntent) {
494
- const leased = this.variantPipeline.leaseNext();
495
- if (leased) {
496
- this.persistQueue();
497
- this.notifyLivenessChange();
498
- return leased;
499
- }
500
- }
501
- }
502
- log.info('Pending variant batch no longer queued (already consumed/superseded)');
503
- return null;
504
123
  }
505
- /**
506
- * Remove variant-request comment items from a mixed pending batch while
507
- * preserving all non-variant items for a follow-up apply run.
508
- */
509
- rejectMixedVariantRequestBatch(expectedIntent) {
510
- const intent = this.applyPipeline.peekHeadIntent();
511
- if (!intent)
512
- return null;
513
- if (expectedIntent && intent !== expectedIntent) {
514
- log.info('Pending intent changed while rejecting mixed variant request; preserving newer intent');
515
- return undefined;
516
- }
517
- const nextChanges = intent.changes.filter((change) => !(change.kind === 'comment' && change.variantRequest !== undefined));
518
- if (nextChanges.length === intent.changes.length) {
519
- return intent;
520
- }
521
- if (nextChanges.length === 0) {
522
- this.applyPipeline.replaceHeadQueuedBatch(null);
523
- log.info('Mixed variant batch rejection removed all pending changes');
524
- this.persistQueue();
525
- this.notifyLivenessChange();
526
- return null;
527
- }
528
- const preserved = {
529
- ...intent,
530
- changes: nextChanges,
531
- };
532
- this.applyPipeline.replaceHeadQueuedBatch(preserved);
533
- log.info(`Mixed variant batch rejected; preserved ${nextChanges.length} non-variant items`);
534
- this.persistQueue();
535
- this.notifyLivenessChange();
536
- return preserved;
537
- }
538
- /**
539
- * Mark the currently processing MCP apply run using identifiers from the queued request.
540
- */
541
- startApplyingRun(intent) {
542
- const telemetryContext = this.getTelemetryContext();
543
- const correlation = {
544
- traceId: intent.traceId || (0, crypto_1.randomUUID)(),
545
- agentRunId: intent.agentRunId || (0, crypto_1.randomUUID)(),
546
- startedAt: Date.now(),
547
- browserSessionId: telemetryContext?.browserSessionId,
548
- };
549
- const orphanedRun = this.activeRunCorrelation;
550
- this.activeRunCorrelation = correlation;
124
+ getSessionRuntimeInfo() {
551
125
  return {
552
- newRun: correlation,
553
- orphanedRun,
126
+ sessionInitiator: this.sessionInitiator,
127
+ resolvedRunner: this.resolvedRunner,
128
+ runnerMismatches: [...this.runnerMismatches],
554
129
  };
555
130
  }
556
- /**
557
- * Complete the active MCP run and clear it from bridge state.
558
- */
559
- completeActiveRunCorrelation() {
560
- const correlation = this.activeRunCorrelation;
561
- this.activeRunCorrelation = null;
562
- return correlation;
563
- }
564
- /** Active apply lease, if any (at most one). */
565
- findActiveApplyLease() {
566
- const leased = this.applyPipeline.snapshot().leased;
567
- return leased[0] ?? null;
568
- }
569
- /** Active lease metadata safe to expose for agent recovery. */
570
- getActiveLeaseMetadata(now = Date.now()) {
571
- const leases = [
572
- ...this.applyPipeline.snapshot().leased,
573
- ...this.variantPipeline.snapshot().leased,
574
- ];
575
- return leases
576
- .sort((a, b) => a.leasedAt - b.leasedAt)
577
- .map((lease) => ({
578
- kind: lease.kind,
579
- requestId: lease.requestId,
580
- leaseId: lease.leaseId,
581
- leasedAt: lease.leasedAt,
582
- ageMs: Math.max(0, now - lease.leasedAt),
583
- changeCount: lease.intent.changes.length,
584
- sourceFileCount: lease.intent.sourceFiles.length,
585
- mergedFrom: lease.mergedFrom,
586
- mergedRequestCount: lease.mergedRequestIds.length,
587
- }));
588
- }
589
- /** Get the number of completed editing rounds in this session */
590
- getRoundsCompleted() {
591
- return this.roundsCompleted;
131
+ recordRunnerMismatch(initiator) {
132
+ if (initiator.kind !== 'agent' || initiator.agent === 'unknown')
133
+ return;
134
+ this.runnerMismatches.push({
135
+ agent: initiator.agent,
136
+ ...(initiator.model ? { model: initiator.model } : {}),
137
+ at: Date.now(),
138
+ });
592
139
  }
593
- /** Get telemetry correlation data for the active session */
594
140
  getTelemetryContext() {
595
141
  return this.telemetryContext;
596
142
  }
597
- /** Get dev-server health metadata for the active MCP session. */
143
+ updateTelemetryContext(context) {
144
+ if (!context)
145
+ return;
146
+ const nextContext = {
147
+ ...this.telemetryContext,
148
+ ...context,
149
+ };
150
+ if (nextContext.browserSessionId === undefined &&
151
+ nextContext.browserDistinctId === undefined) {
152
+ return;
153
+ }
154
+ this.telemetryContext = nextContext;
155
+ }
598
156
  getDevServerHealth() {
599
157
  return this.devServerHealth;
600
158
  }
601
- /** Set the base session dev-server context (ownership + endpoint). */
602
159
  setDevServerContext(context) {
603
160
  this.devServerHealth = {
604
161
  ...this.devServerHealth,
@@ -609,7 +166,6 @@ class SessionBridgeService {
609
166
  };
610
167
  this.baseDevServerHealth = { ...this.devServerHealth };
611
168
  }
612
- /** Update session dev-server health reason/reachability. */
613
169
  updateDevServerHealth(update) {
614
170
  this.devServerHealth = {
615
171
  ...this.devServerHealth,
@@ -628,108 +184,55 @@ class SessionBridgeService {
628
184
  this.baseDevServerHealth = { ...this.devServerHealth };
629
185
  }
630
186
  }
631
- /** Merge and store telemetry correlation data for the active session */
632
- updateTelemetryContext(context) {
633
- if (!context) {
634
- return;
635
- }
636
- const nextContext = {
637
- ...this.telemetryContext,
638
- ...context,
639
- };
640
- if (nextContext.browserSessionId === undefined &&
641
- nextContext.browserDistinctId === undefined) {
642
- return;
643
- }
644
- this.telemetryContext = nextContext;
645
- }
646
- /** Inject the proxy's setVariantTarget fn (called from server.ts after proxy is created) */
647
187
  registerVariantTargetSetter(fn) {
648
188
  this._setVariantTarget = fn;
649
189
  }
650
- /** Register a variant-key→port lookup function (called from mcp/server.ts after variant sessions are built) */
651
190
  registerVariantLookup(fn) {
652
191
  this._variantLookup = fn;
653
192
  }
654
- /** Register preview-port allowlist checker tied to the active variant session */
655
193
  registerVariantPortAllowlist(fn) {
656
194
  this._isVariantPortAllowed = fn;
657
195
  }
658
- /** Look up a variant's preview port by stable lookup key */
659
196
  lookupVariantPort(variantKey) {
660
197
  return this._variantLookup?.(variantKey) ?? null;
661
198
  }
662
- /** Check whether a preview port is registered for the active variant session */
663
199
  isVariantPortAllowed(port) {
664
200
  return this._isVariantPortAllowed?.(port) ?? false;
665
201
  }
666
- /** Register a status polling token used by Rivet UI. */
667
202
  setStatusAccessToken(token) {
668
203
  this.statusAccessToken = token;
669
204
  }
670
- /** Check whether a status polling token has already been registered. */
671
205
  hasStatusAccessToken() {
672
206
  return this.statusAccessToken !== null;
673
207
  }
674
- /** Validate status polling token from API requests. */
675
208
  isStatusAccessTokenValid(token) {
676
209
  return Boolean(token) && token === this.statusAccessToken;
677
210
  }
678
- /**
679
- * Advertise a Rivet-spawned committed dev server (vite_app or static
680
- * preview) on `devServerHealth` so `/api/mcp/status` and the iframe's
681
- * `usePreviewUpstreamHealth` probe see `ownership: 'rivet_owned'` + the
682
- * new port. Pass `null` to clear back to the no-server state. Distinct
683
- * from `switchPreviewPort` (which temporarily retargets health while a
684
- * variant preview is active, then restores `baseDevServerHealth`) and from
685
- * `setDevServerContext` (which the MCP server uses for the user's own
686
- * dev server during a regular session). Only the orchestrator's
687
- * commit-handoff path should call this.
688
- */
689
211
  setCommittedDevServerHealth(port) {
690
212
  if (port === null) {
691
- if (this.baseDevServerHealth) {
692
- this.devServerHealth = { ...this.baseDevServerHealth };
693
- return;
694
- }
695
- this.devServerHealth = {
696
- ownership: 'none',
697
- host: null,
698
- port: null,
699
- isReachable: null,
700
- reason: 'unknown',
701
- lastCheckedAt: Date.now(),
702
- startedByRivet: false,
703
- };
213
+ this.devServerHealth = this.baseDevServerHealth
214
+ ? { ...this.baseDevServerHealth }
215
+ : { ...EMPTY_DEV_SERVER_HEALTH, lastCheckedAt: Date.now() };
704
216
  return;
705
217
  }
706
218
  const committedDevServerHealth = {
707
- ...this.devServerHealth,
708
219
  ownership: 'rivet_owned',
709
220
  host: 'localhost',
710
221
  port,
711
222
  isReachable: true,
712
223
  reason: 'healthy',
713
- startedByRivet: true,
714
224
  lastCheckedAt: Date.now(),
225
+ startedByRivet: true,
715
226
  };
716
227
  this.devServerHealth = committedDevServerHealth;
717
228
  this.baseDevServerHealth = { ...committedDevServerHealth };
718
229
  }
719
- /** Switch the proxy to a variant dev server (or back to user's dev server when port is null) */
720
230
  switchPreviewPort(port) {
721
231
  if (!this._setVariantTarget) {
722
- log.warn(`switchPreviewPort(${port}) called but no variant target setter registered — proxy will NOT retarget. (Did open_visual_editor run? Is framework='static'?)`);
723
- }
724
- else {
725
- log.info(`switchPreviewPort → ${port === null ? 'default upstream' : `localhost:${port}`}`);
232
+ log.warn(`switchPreviewPort(${port}) called but no variant target setter registered`);
726
233
  }
727
234
  this._setVariantTarget?.(port);
728
235
  if (port !== null) {
729
- // Retarget `/api/mcp/status` upstream probes to the active variant dev
730
- // server. The proxy already serves this port; without this, health keeps
731
- // checking the (possibly dead) base external port and the iframe shows
732
- // "Preview isn't connected" while variant previews are live.
733
236
  this.devServerHealth = {
734
237
  ownership: 'rivet_owned',
735
238
  host: 'localhost',
@@ -739,112 +242,57 @@ class SessionBridgeService {
739
242
  lastCheckedAt: Date.now(),
740
243
  startedByRivet: true,
741
244
  };
245
+ this.reportFeedback('__RIVET_RELOAD_PREVIEW__');
246
+ return;
742
247
  }
743
- else if (this.baseDevServerHealth) {
248
+ if (this.baseDevServerHealth) {
744
249
  this.devServerHealth = { ...this.baseDevServerHealth };
745
250
  }
746
251
  this.reportFeedback('__RIVET_RELOAD_PREVIEW__');
747
252
  }
748
- /**
749
- * End the current session, clearing all state.
750
- * @returns The total number of completed rounds
751
- */
752
253
  endSession() {
753
254
  const rounds = this.roundsCompleted;
754
- const id = this.sessionId;
755
- const projectPath = this.projectPath;
756
- this.waitResolvers = [];
255
+ if (this.sessionId) {
256
+ log.info(`Session ended: ${this.sessionId}`);
257
+ }
757
258
  this.sessionId = null;
758
259
  this.projectPath = null;
759
- this.applyPipeline = new BridgeBatchPipeline_1.BridgeBatchPipeline({
760
- kind: 'apply',
761
- maxQueued: exports.MAX_PENDING_APPLY_BATCHES,
762
- maxConcurrentLeases: 1,
763
- queueFullReason: 'apply_queue_full',
764
- });
765
- this.variantPipeline = new BridgeBatchPipeline_1.BridgeBatchPipeline({
766
- kind: 'variant',
767
- maxQueued: exports.MAX_PENDING_VARIANT_REQUESTS,
768
- maxConcurrentLeases: exports.MAX_LEASED_VARIANT_BATCHES,
769
- queueFullReason: 'variant_queue_full',
770
- });
771
- this.telemetryContext = null;
772
- this.roundsCompleted = 0;
773
260
  this.feedback = [];
774
261
  this.status = 'IDLE';
775
- this.activeRunCorrelation = null;
262
+ this.roundsCompleted = 0;
263
+ this.telemetryContext = null;
264
+ this.sessionInitiator = null;
265
+ this.resolvedRunner = null;
266
+ this.runnerMismatches = [];
267
+ this.baseDevServerHealth = null;
268
+ this.devServerHealth = { ...EMPTY_DEV_SERVER_HEALTH };
776
269
  this._variantLookup = null;
777
270
  this._isVariantPortAllowed = null;
778
271
  this.statusAccessToken = null;
779
- this.devServerHealth = {
780
- ownership: 'none',
781
- host: null,
782
- port: null,
783
- isReachable: null,
784
- reason: 'unknown',
785
- lastCheckedAt: null,
786
- startedByRivet: false,
787
- };
788
- if (id && projectPath) {
789
- BridgeQueueStore_1.bridgeQueueStore.delete(projectPath, id);
790
- }
791
- log.info(`Session ended: ${id}, ${rounds} rounds completed`);
792
272
  this.notifyLivenessChange();
793
273
  return rounds;
794
274
  }
795
- /**
796
- * Snapshot the real liveness of the change pipeline for stale-watcher
797
- * detection. `watcherActive` reflects a registered `watch_for_changes` waiter,
798
- * NOT channel silence; `oldestPendingChangeAgeMs` is measured against `now`
799
- * (injectable for tests) so a healthy long-poll can never look stuck — only
800
- * genuinely unconsumed, unwatched work does.
801
- */
802
- getWatcherLiveness(now = Date.now()) {
803
- const oldestPendingChangeEnqueuedAt = this.oldestPendingChangeEnqueuedAt();
804
- const pendingCount = this.applyPipeline.queuedDepth() +
805
- this.variantPipeline.queuedDepth() +
806
- this.variantPipeline.leasedDepth();
275
+ getWatcherLiveness(_now = Date.now()) {
807
276
  return {
808
- watcherActive: this.waitResolvers.length > 0,
809
- pendingCount,
810
- leasedVariantRequests: this.variantPipeline.leasedDepth(),
811
- oldestPendingChangeEnqueuedAt,
812
- oldestPendingChangeAgeMs: oldestPendingChangeEnqueuedAt === null
813
- ? null
814
- : Math.max(0, now - oldestPendingChangeEnqueuedAt),
277
+ watcherActive: false,
278
+ pendingCount: 0,
279
+ leasedVariantRequests: 0,
280
+ oldestPendingChangeEnqueuedAt: null,
281
+ oldestPendingChangeAgeMs: null,
815
282
  };
816
283
  }
817
- /**
818
- * Subscribe to changes in {@link getWatcherLiveness} state (queue/drain,
819
- * waiter register/settle, session start/end). Returns an unsubscribe fn.
820
- */
821
284
  onWatcherLivenessChange(listener) {
822
285
  this.livenessListeners.add(listener);
823
286
  return () => {
824
287
  this.livenessListeners.delete(listener);
825
288
  };
826
289
  }
827
- /** Oldest enqueue time across queued apply work or unfinished variant work. */
828
- oldestPendingChangeEnqueuedAt() {
829
- const times = [];
830
- const applyAt = this.applyPipeline.oldestQueuedEnqueuedAt();
831
- if (applyAt !== null) {
832
- times.push(applyAt);
833
- }
834
- const variantAt = this.variantPipeline.oldestUnfinishedEnqueuedAt();
835
- if (variantAt !== null) {
836
- times.push(variantAt);
837
- }
838
- return times.length > 0 ? Math.min(...times) : null;
290
+ pendingVariantRequestCount() {
291
+ return 0;
839
292
  }
840
293
  notifyLivenessChange() {
841
294
  for (const listener of this.livenessListeners) {
842
- try {
843
- listener();
844
- }
845
- catch (err) {
846
- log.warn('liveness listener threw', err);
847
- }
295
+ listener();
848
296
  }
849
297
  }
850
298
  }