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.
- package/README.md +50 -26
- package/README.npm.md +50 -26
- package/bin/rivet.js +39 -24
- package/dist/{mcp/agent-variants → agent-variants}/SessionStore.d.ts +11 -19
- package/dist/agent-variants/SessionStore.d.ts.map +1 -0
- package/dist/{mcp/agent-variants → agent-variants}/SessionStore.js +77 -80
- package/dist/agent-variants/SessionStore.js.map +1 -0
- package/dist/{mcp/agent-variants → agent-variants}/WorktreeOrchestrator.d.ts +53 -21
- package/dist/agent-variants/WorktreeOrchestrator.d.ts.map +1 -0
- package/dist/{mcp/agent-variants → agent-variants}/WorktreeOrchestrator.js +291 -49
- package/dist/agent-variants/WorktreeOrchestrator.js.map +1 -0
- package/dist/{mcp/agent-variants → agent-variants}/WorktreeOrchestrator.testHelpers.d.ts +1 -9
- package/dist/agent-variants/WorktreeOrchestrator.testHelpers.d.ts.map +1 -0
- package/dist/{mcp/agent-variants → agent-variants}/WorktreeOrchestrator.testHelpers.js +3 -18
- package/dist/agent-variants/WorktreeOrchestrator.testHelpers.js.map +1 -0
- package/dist/agent-variants/briefContent.d.ts.map +1 -0
- package/dist/agent-variants/briefContent.js.map +1 -0
- package/dist/{mcp/agent-variants → agent-variants}/contracts.d.ts +715 -721
- package/dist/agent-variants/contracts.d.ts.map +1 -0
- package/dist/{mcp/agent-variants → agent-variants}/contracts.js +2 -3
- package/dist/agent-variants/contracts.js.map +1 -0
- package/dist/agent-variants/createProjectArtifacts.d.ts.map +1 -0
- package/dist/agent-variants/createProjectArtifacts.js.map +1 -0
- package/dist/agent-variants/diffQa.d.ts.map +1 -0
- package/dist/agent-variants/diffQa.js.map +1 -0
- package/dist/{mcp/agent-variants → agent-variants}/elementRefToTarget.d.ts +1 -1
- package/dist/agent-variants/elementRefToTarget.d.ts.map +1 -0
- package/dist/agent-variants/elementRefToTarget.js.map +1 -0
- package/dist/agent-variants/errors.d.ts.map +1 -0
- package/dist/agent-variants/errors.js.map +1 -0
- package/dist/agent-variants/generatedDestination.d.ts +29 -0
- package/dist/agent-variants/generatedDestination.d.ts.map +1 -0
- package/dist/agent-variants/generatedDestination.js +59 -0
- package/dist/agent-variants/generatedDestination.js.map +1 -0
- package/dist/{mcp/agent-variants → agent-variants}/index.d.ts +3 -6
- package/dist/agent-variants/index.d.ts.map +1 -0
- package/dist/{mcp/agent-variants → agent-variants}/index.js +3 -6
- package/dist/agent-variants/index.js.map +1 -0
- package/dist/agent-variants/previewQa.d.ts.map +1 -0
- package/dist/agent-variants/previewQa.js.map +1 -0
- package/dist/agent-variants/runLabel.d.ts.map +1 -0
- package/dist/agent-variants/runLabel.js.map +1 -0
- package/dist/agent-variants/runPlan.d.ts.map +1 -0
- package/dist/agent-variants/runPlan.js.map +1 -0
- package/dist/agent-variants/sourceContext.d.ts.map +1 -0
- package/dist/agent-variants/sourceContext.js.map +1 -0
- package/dist/agent-variants/variantContext.d.ts.map +1 -0
- package/dist/agent-variants/variantContext.js.map +1 -0
- package/dist/cli/client.d.ts +43 -0
- package/dist/cli/client.d.ts.map +1 -0
- package/dist/cli/client.js +109 -0
- package/dist/cli/client.js.map +1 -0
- package/dist/cli/commandNames.d.ts +9 -0
- package/dist/cli/commandNames.d.ts.map +1 -0
- package/dist/cli/commandNames.js +24 -0
- package/dist/cli/commandNames.js.map +1 -0
- package/dist/cli/commands/auth.d.ts +10 -0
- package/dist/cli/commands/auth.d.ts.map +1 -0
- package/dist/cli/commands/auth.js +81 -0
- package/dist/cli/commands/auth.js.map +1 -0
- package/dist/cli/commands/elementSelector.d.ts +10 -0
- package/dist/cli/commands/elementSelector.d.ts.map +1 -0
- package/dist/cli/commands/elementSelector.js +41 -0
- package/dist/cli/commands/elementSelector.js.map +1 -0
- package/dist/cli/commands/evidence.d.ts +9 -0
- package/dist/cli/commands/evidence.d.ts.map +1 -0
- package/dist/cli/commands/evidence.js +85 -0
- package/dist/cli/commands/evidence.js.map +1 -0
- package/dist/cli/commands/mcpServe.d.ts +40 -0
- package/dist/cli/commands/mcpServe.d.ts.map +1 -0
- package/dist/cli/commands/mcpServe.js +440 -0
- package/dist/cli/commands/mcpServe.js.map +1 -0
- package/dist/cli/commands/open.d.ts +28 -0
- package/dist/cli/commands/open.d.ts.map +1 -0
- package/dist/cli/commands/open.js +280 -0
- package/dist/cli/commands/open.js.map +1 -0
- package/dist/cli/commands/reference.d.ts +8 -0
- package/dist/cli/commands/reference.d.ts.map +1 -0
- package/dist/cli/commands/reference.js +101 -0
- package/dist/cli/commands/reference.js.map +1 -0
- package/dist/cli/commands/serve.d.ts +9 -0
- package/dist/cli/commands/serve.d.ts.map +1 -0
- package/dist/cli/commands/serve.js +182 -0
- package/dist/cli/commands/serve.js.map +1 -0
- package/dist/cli/commands/shared.d.ts +31 -0
- package/dist/cli/commands/shared.d.ts.map +1 -0
- package/dist/cli/commands/shared.js +82 -0
- package/dist/cli/commands/shared.js.map +1 -0
- package/dist/cli/commands/status.d.ts +10 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +61 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/stop.d.ts +8 -0
- package/dist/cli/commands/stop.d.ts.map +1 -0
- package/dist/cli/commands/stop.js +41 -0
- package/dist/cli/commands/stop.js.map +1 -0
- package/dist/cli/commands/variants.d.ts +4 -0
- package/dist/cli/commands/variants.d.ts.map +1 -0
- package/dist/cli/commands/variants.js +374 -0
- package/dist/cli/commands/variants.js.map +1 -0
- package/dist/cli/commands/wait.d.ts +10 -0
- package/dist/cli/commands/wait.d.ts.map +1 -0
- package/dist/cli/commands/wait.js +101 -0
- package/dist/cli/commands/wait.js.map +1 -0
- package/dist/cli/entry.d.ts +12 -0
- package/dist/cli/entry.d.ts.map +1 -0
- package/dist/cli/entry.js +61 -0
- package/dist/cli/entry.js.map +1 -0
- package/dist/cli/envelope.d.ts +60 -0
- package/dist/cli/envelope.d.ts.map +1 -0
- package/dist/cli/envelope.js +57 -0
- package/dist/cli/envelope.js.map +1 -0
- package/dist/cli/flags.d.ts +20 -0
- package/dist/cli/flags.d.ts.map +1 -0
- package/dist/cli/flags.js +72 -0
- package/dist/cli/flags.js.map +1 -0
- package/dist/cli/handoff.d.ts +54 -0
- package/dist/cli/handoff.d.ts.map +1 -0
- package/dist/cli/handoff.js +106 -0
- package/dist/cli/handoff.js.map +1 -0
- package/dist/cli/handoffStore.d.ts +24 -0
- package/dist/cli/handoffStore.d.ts.map +1 -0
- package/dist/cli/handoffStore.js +49 -0
- package/dist/cli/handoffStore.js.map +1 -0
- package/dist/cli/hostWorkNextAction.d.ts +45 -0
- package/dist/cli/hostWorkNextAction.d.ts.map +1 -0
- package/dist/cli/hostWorkNextAction.js +43 -0
- package/dist/cli/hostWorkNextAction.js.map +1 -0
- package/dist/cli/io.d.ts +17 -0
- package/dist/cli/io.d.ts.map +1 -0
- package/dist/cli/io.js +19 -0
- package/dist/cli/io.js.map +1 -0
- package/dist/cli/router.d.ts +23 -0
- package/dist/cli/router.d.ts.map +1 -0
- package/dist/cli/router.js +236 -0
- package/dist/cli/router.js.map +1 -0
- package/dist/cli/runnerSelection.d.ts +60 -0
- package/dist/cli/runnerSelection.d.ts.map +1 -0
- package/dist/cli/runnerSelection.js +93 -0
- package/dist/cli/runnerSelection.js.map +1 -0
- package/dist/cli/serverHandshake.d.ts +51 -0
- package/dist/cli/serverHandshake.d.ts.map +1 -0
- package/dist/cli/serverHandshake.js +144 -0
- package/dist/cli/serverHandshake.js.map +1 -0
- package/dist/index.d.ts +2 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +84 -138
- package/dist/index.js.map +1 -1
- package/dist/install/allowlists.d.ts +65 -0
- package/dist/install/allowlists.d.ts.map +1 -0
- package/dist/install/allowlists.js +333 -0
- package/dist/install/allowlists.js.map +1 -0
- package/dist/install/codexGuidance.d.ts +11 -0
- package/dist/install/codexGuidance.d.ts.map +1 -0
- package/dist/install/codexGuidance.js +90 -0
- package/dist/install/codexGuidance.js.map +1 -0
- package/dist/install/harnesses.d.ts +37 -26
- package/dist/install/harnesses.d.ts.map +1 -1
- package/dist/install/harnesses.js +312 -502
- package/dist/install/harnesses.js.map +1 -1
- package/dist/install/legacyMcp.d.ts +26 -0
- package/dist/install/legacyMcp.d.ts.map +1 -0
- package/dist/install/legacyMcp.js +160 -0
- package/dist/install/legacyMcp.js.map +1 -0
- package/dist/install/mcpRegistration.d.ts +45 -0
- package/dist/install/mcpRegistration.d.ts.map +1 -0
- package/dist/install/mcpRegistration.js +215 -0
- package/dist/install/mcpRegistration.js.map +1 -0
- package/dist/mcp/changeBatchClassification.d.ts +18 -20
- package/dist/mcp/changeBatchClassification.d.ts.map +1 -1
- package/dist/mcp/changeBatchClassification.js +41 -46
- package/dist/mcp/changeBatchClassification.js.map +1 -1
- package/dist/proxy-middleware/proxy-config.d.ts +6 -0
- package/dist/proxy-middleware/proxy-config.d.ts.map +1 -1
- package/dist/proxy-middleware/proxy-config.js +162 -5
- package/dist/proxy-middleware/proxy-config.js.map +1 -1
- package/dist/routes/agentVariants.d.ts +14 -2
- package/dist/routes/agentVariants.d.ts.map +1 -1
- package/dist/routes/agentVariants.js +321 -65
- package/dist/routes/agentVariants.js.map +1 -1
- package/dist/routes/cli.d.ts +31 -0
- package/dist/routes/cli.d.ts.map +1 -0
- package/dist/routes/cli.js +95 -0
- package/dist/routes/cli.js.map +1 -0
- package/dist/routes/git.d.ts +1 -0
- package/dist/routes/git.d.ts.map +1 -1
- package/dist/routes/git.js +2 -1
- package/dist/routes/git.js.map +1 -1
- package/dist/routes/inlineStartTracker.d.ts +23 -0
- package/dist/routes/inlineStartTracker.d.ts.map +1 -0
- package/dist/routes/inlineStartTracker.js +17 -0
- package/dist/routes/inlineStartTracker.js.map +1 -0
- package/dist/routes/mcp.d.ts +2 -12
- package/dist/routes/mcp.d.ts.map +1 -1
- package/dist/routes/mcp.js +4 -785
- package/dist/routes/mcp.js.map +1 -1
- package/dist/server.d.ts +24 -9
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +169 -33
- package/dist/server.js.map +1 -1
- package/dist/services/CommitMessageGenerator.d.ts +9 -1
- package/dist/services/CommitMessageGenerator.d.ts.map +1 -1
- package/dist/services/CommitMessageGenerator.js +4 -1
- package/dist/services/CommitMessageGenerator.js.map +1 -1
- package/dist/services/ComponentSearchService.d.ts +4 -1
- package/dist/services/ComponentSearchService.d.ts.map +1 -1
- package/dist/services/ComponentSearchService.js.map +1 -1
- package/dist/services/ConfigManager.d.ts +8 -0
- package/dist/services/ConfigManager.d.ts.map +1 -1
- package/dist/services/ConfigManager.js +9 -0
- package/dist/services/ConfigManager.js.map +1 -1
- package/dist/services/HistoryReplayService.d.ts +20 -9
- package/dist/services/HistoryReplayService.d.ts.map +1 -1
- package/dist/services/HistoryReplayService.js +99 -43
- package/dist/services/HistoryReplayService.js.map +1 -1
- package/dist/services/MCPVariantsTelemetry.d.ts +1 -1
- package/dist/services/MCPVariantsTelemetry.d.ts.map +1 -1
- package/dist/services/MCPVariantsTelemetry.js +1 -0
- package/dist/services/MCPVariantsTelemetry.js.map +1 -1
- package/dist/services/PRTitleGenerator.d.ts +10 -2
- package/dist/services/PRTitleGenerator.d.ts.map +1 -1
- package/dist/services/PRTitleGenerator.js +8 -2
- package/dist/services/PRTitleGenerator.js.map +1 -1
- package/dist/services/ProjectDetectionService.d.ts.map +1 -1
- package/dist/services/ProjectDetectionService.js +14 -4
- package/dist/services/ProjectDetectionService.js.map +1 -1
- package/dist/services/ProjectMetadataStore.d.ts +115 -0
- package/dist/services/ProjectMetadataStore.d.ts.map +1 -0
- package/dist/services/ProjectMetadataStore.js +336 -0
- package/dist/services/ProjectMetadataStore.js.map +1 -0
- package/dist/services/SessionBridgeService.d.ts +52 -224
- package/dist/services/SessionBridgeService.d.ts.map +1 -1
- package/dist/services/SessionBridgeService.js +97 -649
- package/dist/services/SessionBridgeService.js.map +1 -1
- package/dist/services/SessionService.d.ts +4 -1
- package/dist/services/SessionService.d.ts.map +1 -1
- package/dist/services/SessionService.js +7 -4
- package/dist/services/SessionService.js.map +1 -1
- package/dist/services/StaticFileService.d.ts.map +1 -1
- package/dist/services/StaticFileService.js +6 -0
- package/dist/services/StaticFileService.js.map +1 -1
- package/dist/services/TelemetryService.d.ts +16 -80
- package/dist/services/TelemetryService.d.ts.map +1 -1
- package/dist/services/TelemetryService.js +18 -94
- package/dist/services/TelemetryService.js.map +1 -1
- package/dist/services/VariantGenerationService.d.ts +52 -0
- package/dist/services/VariantGenerationService.d.ts.map +1 -0
- package/dist/services/VariantGenerationService.js +272 -0
- package/dist/services/VariantGenerationService.js.map +1 -0
- package/dist/services/VariantHistoryService.d.ts +37 -1
- package/dist/services/VariantHistoryService.d.ts.map +1 -1
- package/dist/services/VariantHistoryService.js +122 -1
- package/dist/services/VariantHistoryService.js.map +1 -1
- package/dist/services/VariantRunService.d.ts +25 -6
- package/dist/services/VariantRunService.d.ts.map +1 -1
- package/dist/services/VariantRunService.js +98 -4
- package/dist/services/VariantRunService.js.map +1 -1
- package/dist/services/VariantsRuntime.d.ts +1 -3
- package/dist/services/VariantsRuntime.d.ts.map +1 -1
- package/dist/services/VariantsRuntime.js +0 -1
- package/dist/services/VariantsRuntime.js.map +1 -1
- package/dist/services/WorktreeManager.d.ts +1 -1
- package/dist/services/WorktreeManager.d.ts.map +1 -1
- package/dist/services/createAgentVariantsOrchestrator.d.ts +2 -2
- package/dist/services/createAgentVariantsOrchestrator.d.ts.map +1 -1
- package/dist/services/createAgentVariantsOrchestrator.js +2 -3
- package/dist/services/createAgentVariantsOrchestrator.js.map +1 -1
- package/dist/services/projectMetadataMigrations.d.ts +59 -0
- package/dist/services/projectMetadataMigrations.d.ts.map +1 -0
- package/dist/services/projectMetadataMigrations.js +109 -0
- package/dist/services/projectMetadataMigrations.js.map +1 -0
- package/dist/types/change-request-types.d.ts +22 -0
- package/dist/types/change-request-types.d.ts.map +1 -1
- package/dist/utils/logger.d.ts +2 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +3 -7
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/loopback.d.ts +3 -0
- package/dist/utils/loopback.d.ts.map +1 -0
- package/dist/utils/loopback.js +13 -0
- package/dist/utils/loopback.js.map +1 -0
- package/dist/utils/pid.d.ts +3 -0
- package/dist/utils/pid.d.ts.map +1 -0
- package/dist/utils/pid.js +15 -0
- package/dist/utils/pid.js.map +1 -0
- package/dist/utils/queueAccess.d.ts +7 -0
- package/dist/utils/queueAccess.d.ts.map +1 -1
- package/dist/utils/queueAccess.js +8 -1
- package/dist/utils/queueAccess.js.map +1 -1
- package/dist/utils/shouldRecordHostedDemoSessionAction.d.ts +3 -3
- package/dist/utils/shouldRecordHostedDemoSessionAction.d.ts.map +1 -1
- package/dist/utils/shouldRecordHostedDemoSessionAction.js +3 -19
- package/dist/utils/shouldRecordHostedDemoSessionAction.js.map +1 -1
- package/dist/utils/skillWriter.d.ts.map +1 -1
- package/dist/utils/skillWriter.js +12 -11
- package/dist/utils/skillWriter.js.map +1 -1
- package/dist/utils/skills/claude-skill.d.ts +7 -2
- package/dist/utils/skills/claude-skill.d.ts.map +1 -1
- package/dist/utils/skills/claude-skill.js +10 -83
- package/dist/utils/skills/claude-skill.js.map +1 -1
- package/dist/utils/skills/cli-guidance.d.ts +12 -0
- package/dist/utils/skills/cli-guidance.d.ts.map +1 -0
- package/dist/utils/skills/cli-guidance.js +57 -0
- package/dist/utils/skills/cli-guidance.js.map +1 -0
- package/dist/utils/skills/cursor-rules.d.ts +8 -2
- package/dist/utils/skills/cursor-rules.d.ts.map +1 -1
- package/dist/utils/skills/cursor-rules.js +11 -80
- package/dist/utils/skills/cursor-rules.js.map +1 -1
- package/dist/utils/variantSessionStart.d.ts +1 -1
- package/dist/utils/variantSessionStart.d.ts.map +1 -1
- package/dist/utils/variantSessionStart.js +1 -1
- package/dist/utils/variantSessionStart.js.map +1 -1
- package/package.json +4 -4
- package/src/ui/dist/assets/main-BWOvFoal.js +419 -0
- package/src/ui/dist/assets/main-Dyos9I29.css +1 -0
- package/src/ui/dist/index.html +2 -2
- package/dist/mcp/agent-variants/SessionStore.d.ts.map +0 -1
- package/dist/mcp/agent-variants/SessionStore.js.map +0 -1
- package/dist/mcp/agent-variants/WorktreeOrchestrator.d.ts.map +0 -1
- package/dist/mcp/agent-variants/WorktreeOrchestrator.js.map +0 -1
- package/dist/mcp/agent-variants/WorktreeOrchestrator.testHelpers.d.ts.map +0 -1
- package/dist/mcp/agent-variants/WorktreeOrchestrator.testHelpers.js.map +0 -1
- package/dist/mcp/agent-variants/areNaSourceContext.d.ts +0 -20
- package/dist/mcp/agent-variants/areNaSourceContext.d.ts.map +0 -1
- package/dist/mcp/agent-variants/areNaSourceContext.js +0 -118
- package/dist/mcp/agent-variants/areNaSourceContext.js.map +0 -1
- package/dist/mcp/agent-variants/briefContent.d.ts.map +0 -1
- package/dist/mcp/agent-variants/briefContent.js.map +0 -1
- package/dist/mcp/agent-variants/contracts.d.ts.map +0 -1
- package/dist/mcp/agent-variants/contracts.js.map +0 -1
- package/dist/mcp/agent-variants/createProjectArtifacts.d.ts.map +0 -1
- package/dist/mcp/agent-variants/createProjectArtifacts.js.map +0 -1
- package/dist/mcp/agent-variants/createZeroToOneTool.d.ts +0 -63
- package/dist/mcp/agent-variants/createZeroToOneTool.d.ts.map +0 -1
- package/dist/mcp/agent-variants/createZeroToOneTool.js +0 -265
- package/dist/mcp/agent-variants/createZeroToOneTool.js.map +0 -1
- package/dist/mcp/agent-variants/diffQa.d.ts.map +0 -1
- package/dist/mcp/agent-variants/diffQa.js.map +0 -1
- package/dist/mcp/agent-variants/elementRefToTarget.d.ts.map +0 -1
- package/dist/mcp/agent-variants/elementRefToTarget.js.map +0 -1
- package/dist/mcp/agent-variants/errors.d.ts.map +0 -1
- package/dist/mcp/agent-variants/errors.js.map +0 -1
- package/dist/mcp/agent-variants/generatedDestination.d.ts +0 -75
- package/dist/mcp/agent-variants/generatedDestination.d.ts.map +0 -1
- package/dist/mcp/agent-variants/generatedDestination.js +0 -103
- package/dist/mcp/agent-variants/generatedDestination.js.map +0 -1
- package/dist/mcp/agent-variants/index.d.ts.map +0 -1
- package/dist/mcp/agent-variants/index.js.map +0 -1
- package/dist/mcp/agent-variants/pendingChangesAdapter.d.ts +0 -38
- package/dist/mcp/agent-variants/pendingChangesAdapter.d.ts.map +0 -1
- package/dist/mcp/agent-variants/pendingChangesAdapter.js +0 -93
- package/dist/mcp/agent-variants/pendingChangesAdapter.js.map +0 -1
- package/dist/mcp/agent-variants/pinterestSourceContext.d.ts +0 -23
- package/dist/mcp/agent-variants/pinterestSourceContext.d.ts.map +0 -1
- package/dist/mcp/agent-variants/pinterestSourceContext.js +0 -137
- package/dist/mcp/agent-variants/pinterestSourceContext.js.map +0 -1
- package/dist/mcp/agent-variants/previewQa.d.ts.map +0 -1
- package/dist/mcp/agent-variants/previewQa.js.map +0 -1
- package/dist/mcp/agent-variants/runLabel.d.ts.map +0 -1
- package/dist/mcp/agent-variants/runLabel.js.map +0 -1
- package/dist/mcp/agent-variants/runPlan.d.ts.map +0 -1
- package/dist/mcp/agent-variants/runPlan.js.map +0 -1
- package/dist/mcp/agent-variants/sourceContext.d.ts.map +0 -1
- package/dist/mcp/agent-variants/sourceContext.js.map +0 -1
- package/dist/mcp/agent-variants/tools.d.ts +0 -187
- package/dist/mcp/agent-variants/tools.d.ts.map +0 -1
- package/dist/mcp/agent-variants/tools.js +0 -1165
- package/dist/mcp/agent-variants/tools.js.map +0 -1
- package/dist/mcp/agent-variants/variantContext.d.ts.map +0 -1
- package/dist/mcp/agent-variants/variantContext.js.map +0 -1
- package/dist/mcp/auth/httpOAuthProvider.d.ts +0 -103
- package/dist/mcp/auth/httpOAuthProvider.d.ts.map +0 -1
- package/dist/mcp/auth/httpOAuthProvider.js +0 -735
- package/dist/mcp/auth/httpOAuthProvider.js.map +0 -1
- package/dist/mcp/auth/tools.d.ts +0 -39
- package/dist/mcp/auth/tools.d.ts.map +0 -1
- package/dist/mcp/auth/tools.js +0 -304
- package/dist/mcp/auth/tools.js.map +0 -1
- package/dist/mcp/branding.d.ts +0 -4
- package/dist/mcp/branding.d.ts.map +0 -1
- package/dist/mcp/branding.js +0 -8
- package/dist/mcp/branding.js.map +0 -1
- package/dist/mcp/hostedServer.d.ts +0 -27
- package/dist/mcp/hostedServer.d.ts.map +0 -1
- package/dist/mcp/hostedServer.js +0 -71
- package/dist/mcp/hostedServer.js.map +0 -1
- package/dist/mcp/httpServer.d.ts +0 -63
- package/dist/mcp/httpServer.d.ts.map +0 -1
- package/dist/mcp/httpServer.js +0 -602
- package/dist/mcp/httpServer.js.map +0 -1
- package/dist/mcp/instructions.d.ts +0 -25
- package/dist/mcp/instructions.d.ts.map +0 -1
- package/dist/mcp/instructions.js +0 -39
- package/dist/mcp/instructions.js.map +0 -1
- package/dist/mcp/integrations/tools.d.ts +0 -19
- package/dist/mcp/integrations/tools.d.ts.map +0 -1
- package/dist/mcp/integrations/tools.js +0 -101
- package/dist/mcp/integrations/tools.js.map +0 -1
- package/dist/mcp/server.d.ts +0 -214
- package/dist/mcp/server.d.ts.map +0 -1
- package/dist/mcp/server.js +0 -2536
- package/dist/mcp/server.js.map +0 -1
- package/dist/mcp/toolAnalytics.d.ts +0 -26
- package/dist/mcp/toolAnalytics.d.ts.map +0 -1
- package/dist/mcp/toolAnalytics.js +0 -95
- package/dist/mcp/toolAnalytics.js.map +0 -1
- package/dist/mcp/types.d.ts +0 -7
- package/dist/mcp/types.d.ts.map +0 -1
- package/dist/mcp/types.js +0 -3
- package/dist/mcp/types.js.map +0 -1
- package/dist/mcp/watchLoopResumePrompt.d.ts +0 -16
- package/dist/mcp/watchLoopResumePrompt.d.ts.map +0 -1
- package/dist/mcp/watchLoopResumePrompt.js +0 -21
- package/dist/mcp/watchLoopResumePrompt.js.map +0 -1
- package/dist/prompts/agentModPrompts.d.ts +0 -4
- package/dist/prompts/agentModPrompts.d.ts.map +0 -1
- package/dist/prompts/agentModPrompts.js +0 -34
- package/dist/prompts/agentModPrompts.js.map +0 -1
- package/dist/prompts/tokenWriterPrompts.d.ts +0 -4
- package/dist/prompts/tokenWriterPrompts.d.ts.map +0 -1
- package/dist/prompts/tokenWriterPrompts.js +0 -59
- package/dist/prompts/tokenWriterPrompts.js.map +0 -1
- package/dist/routes/comments.d.ts +0 -3
- package/dist/routes/comments.d.ts.map +0 -1
- package/dist/routes/comments.js +0 -113
- package/dist/routes/comments.js.map +0 -1
- package/dist/routes/components.d.ts +0 -7
- package/dist/routes/components.d.ts.map +0 -1
- package/dist/routes/components.js +0 -88
- package/dist/routes/components.js.map +0 -1
- package/dist/routes/controls.d.ts +0 -7
- package/dist/routes/controls.d.ts.map +0 -1
- package/dist/routes/controls.js +0 -50
- package/dist/routes/controls.js.map +0 -1
- package/dist/routes/design.d.ts +0 -2
- package/dist/routes/design.d.ts.map +0 -1
- package/dist/routes/design.js +0 -29
- package/dist/routes/design.js.map +0 -1
- package/dist/routes/modifications.d.ts +0 -10
- package/dist/routes/modifications.d.ts.map +0 -1
- package/dist/routes/modifications.js +0 -394
- package/dist/routes/modifications.js.map +0 -1
- package/dist/routes/tokens.d.ts +0 -2
- package/dist/routes/tokens.d.ts.map +0 -1
- package/dist/routes/tokens.js +0 -115
- package/dist/routes/tokens.js.map +0 -1
- package/dist/services/AgentSessionService.d.ts +0 -91
- package/dist/services/AgentSessionService.d.ts.map +0 -1
- package/dist/services/AgentSessionService.js +0 -282
- package/dist/services/AgentSessionService.js.map +0 -1
- package/dist/services/BridgeBatchPipeline.d.ts +0 -103
- package/dist/services/BridgeBatchPipeline.d.ts.map +0 -1
- package/dist/services/BridgeBatchPipeline.js +0 -295
- package/dist/services/BridgeBatchPipeline.js.map +0 -1
- package/dist/services/BridgeQueueStore.d.ts +0 -28
- package/dist/services/BridgeQueueStore.d.ts.map +0 -1
- package/dist/services/BridgeQueueStore.js +0 -88
- package/dist/services/BridgeQueueStore.js.map +0 -1
- package/dist/services/CSSTokenWriter.d.ts +0 -22
- package/dist/services/CSSTokenWriter.d.ts.map +0 -1
- package/dist/services/CSSTokenWriter.js +0 -116
- package/dist/services/CSSTokenWriter.js.map +0 -1
- package/dist/services/DesignTokenService.d.ts +0 -39
- package/dist/services/DesignTokenService.d.ts.map +0 -1
- package/dist/services/DesignTokenService.js +0 -100
- package/dist/services/DesignTokenService.js.map +0 -1
- package/dist/services/InlineVariantGenerationService.d.ts +0 -51
- package/dist/services/InlineVariantGenerationService.d.ts.map +0 -1
- package/dist/services/InlineVariantGenerationService.js +0 -475
- package/dist/services/InlineVariantGenerationService.js.map +0 -1
- package/dist/services/InterfaceGenerationService.d.ts +0 -12
- package/dist/services/InterfaceGenerationService.d.ts.map +0 -1
- package/dist/services/InterfaceGenerationService.js +0 -256
- package/dist/services/InterfaceGenerationService.js.map +0 -1
- package/dist/services/TailwindConfigWriter.d.ts +0 -24
- package/dist/services/TailwindConfigWriter.d.ts.map +0 -1
- package/dist/services/TailwindConfigWriter.js +0 -105
- package/dist/services/TailwindConfigWriter.js.map +0 -1
- package/dist/services/TerminalAgentRunner.d.ts +0 -65
- package/dist/services/TerminalAgentRunner.d.ts.map +0 -1
- package/dist/services/TerminalAgentRunner.js +0 -511
- package/dist/services/TerminalAgentRunner.js.map +0 -1
- package/dist/services/VisualVariantAgentRunner.d.ts +0 -20
- package/dist/services/VisualVariantAgentRunner.d.ts.map +0 -1
- package/dist/services/VisualVariantAgentRunner.js +0 -66
- package/dist/services/VisualVariantAgentRunner.js.map +0 -1
- package/dist/services/adapters/TailwindCSSTokenAdapter.d.ts +0 -35
- package/dist/services/adapters/TailwindCSSTokenAdapter.d.ts.map +0 -1
- package/dist/services/adapters/TailwindCSSTokenAdapter.js +0 -278
- package/dist/services/adapters/TailwindCSSTokenAdapter.js.map +0 -1
- package/dist/services/agent/AgentCore.d.ts +0 -126
- package/dist/services/agent/AgentCore.d.ts.map +0 -1
- package/dist/services/agent/AgentCore.js +0 -759
- package/dist/services/agent/AgentCore.js.map +0 -1
- package/dist/services/agent/AgentModService.d.ts +0 -98
- package/dist/services/agent/AgentModService.d.ts.map +0 -1
- package/dist/services/agent/AgentModService.js +0 -400
- package/dist/services/agent/AgentModService.js.map +0 -1
- package/dist/services/agent/index.d.ts +0 -2
- package/dist/services/agent/index.d.ts.map +0 -1
- package/dist/services/agent/index.js +0 -6
- package/dist/services/agent/index.js.map +0 -1
- package/dist/types/editor-interface-types.d.ts +0 -67
- package/dist/types/editor-interface-types.d.ts.map +0 -1
- package/dist/types/editor-interface-types.js +0 -12
- package/dist/types/editor-interface-types.js.map +0 -1
- package/dist/utils/elementRefToContext.d.ts +0 -4
- package/dist/utils/elementRefToContext.d.ts.map +0 -1
- package/dist/utils/elementRefToContext.js +0 -63
- package/dist/utils/elementRefToContext.js.map +0 -1
- package/dist/utils/skills/shared-variants-protocol.d.ts +0 -69
- package/dist/utils/skills/shared-variants-protocol.d.ts.map +0 -1
- package/dist/utils/skills/shared-variants-protocol.js +0 -292
- package/dist/utils/skills/shared-variants-protocol.js.map +0 -1
- package/src/ui/dist/assets/main-CLAqO1bm.js +0 -656
- package/src/ui/dist/assets/main-Ke-Q9lWa.css +0 -1
- /package/dist/{mcp/agent-variants → agent-variants}/briefContent.d.ts +0 -0
- /package/dist/{mcp/agent-variants → agent-variants}/briefContent.js +0 -0
- /package/dist/{mcp/agent-variants → agent-variants}/createProjectArtifacts.d.ts +0 -0
- /package/dist/{mcp/agent-variants → agent-variants}/createProjectArtifacts.js +0 -0
- /package/dist/{mcp/agent-variants → agent-variants}/diffQa.d.ts +0 -0
- /package/dist/{mcp/agent-variants → agent-variants}/diffQa.js +0 -0
- /package/dist/{mcp/agent-variants → agent-variants}/elementRefToTarget.js +0 -0
- /package/dist/{mcp/agent-variants → agent-variants}/errors.d.ts +0 -0
- /package/dist/{mcp/agent-variants → agent-variants}/errors.js +0 -0
- /package/dist/{mcp/agent-variants → agent-variants}/previewQa.d.ts +0 -0
- /package/dist/{mcp/agent-variants → agent-variants}/previewQa.js +0 -0
- /package/dist/{mcp/agent-variants → agent-variants}/runLabel.d.ts +0 -0
- /package/dist/{mcp/agent-variants → agent-variants}/runLabel.js +0 -0
- /package/dist/{mcp/agent-variants → agent-variants}/runPlan.d.ts +0 -0
- /package/dist/{mcp/agent-variants → agent-variants}/runPlan.js +0 -0
- /package/dist/{mcp/agent-variants → agent-variants}/sourceContext.d.ts +0 -0
- /package/dist/{mcp/agent-variants → agent-variants}/sourceContext.js +0 -0
- /package/dist/{mcp/agent-variants → agent-variants}/variantContext.d.ts +0 -0
- /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 =
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
285
|
-
|
|
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
|
-
|
|
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
|
-
|
|
371
|
-
|
|
372
|
-
return this.applyPipeline.hasWork() || this.variantPipeline.hasWork();
|
|
104
|
+
getQueuedBatchMetadata() {
|
|
105
|
+
return [];
|
|
373
106
|
}
|
|
374
|
-
|
|
375
|
-
|
|
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
|
-
|
|
383
|
-
|
|
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
|
-
|
|
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
|
-
|
|
456
|
-
|
|
457
|
-
|
|
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
|
-
|
|
475
|
-
|
|
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
|
-
|
|
553
|
-
|
|
126
|
+
sessionInitiator: this.sessionInitiator,
|
|
127
|
+
resolvedRunner: this.resolvedRunner,
|
|
128
|
+
runnerMismatches: [...this.runnerMismatches],
|
|
554
129
|
};
|
|
555
130
|
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
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
|
-
|
|
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
|
-
|
|
692
|
-
|
|
693
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
755
|
-
|
|
756
|
-
|
|
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.
|
|
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:
|
|
809
|
-
pendingCount,
|
|
810
|
-
leasedVariantRequests:
|
|
811
|
-
oldestPendingChangeEnqueuedAt,
|
|
812
|
-
oldestPendingChangeAgeMs:
|
|
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
|
-
|
|
828
|
-
|
|
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
|
-
|
|
843
|
-
listener();
|
|
844
|
-
}
|
|
845
|
-
catch (err) {
|
|
846
|
-
log.warn('liveness listener threw', err);
|
|
847
|
-
}
|
|
295
|
+
listener();
|
|
848
296
|
}
|
|
849
297
|
}
|
|
850
298
|
}
|