rivet-design 0.12.4 → 0.13.1
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 +13 -20
- package/dist/agent-variants/SessionStore.d.ts.map +1 -0
- package/dist/{mcp/agent-variants → agent-variants}/SessionStore.js +74 -84
- package/dist/agent-variants/SessionStore.js.map +1 -0
- package/dist/{mcp/agent-variants → agent-variants}/WorktreeOrchestrator.d.ts +58 -25
- package/dist/agent-variants/WorktreeOrchestrator.d.ts.map +1 -0
- package/dist/{mcp/agent-variants → agent-variants}/WorktreeOrchestrator.js +299 -57
- 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 +716 -722
- package/dist/agent-variants/contracts.d.ts.map +1 -0
- package/dist/{mcp/agent-variants → agent-variants}/contracts.js +4 -5
- 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 +485 -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 +435 -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 +20 -20
- package/dist/mcp/changeBatchClassification.d.ts.map +1 -1
- package/dist/mcp/changeBatchClassification.js +46 -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 +366 -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 +45 -0
- package/dist/services/VariantGenerationService.d.ts.map +1 -0
- package/dist/services/VariantGenerationService.js +214 -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 +99 -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 +32 -4
- 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 +59 -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-B725ucb9.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-Dnah9pII.css +0 -1
- package/src/ui/dist/assets/main-plq7aT76.js +0 -656
- /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
|
@@ -9,18 +9,23 @@ const path_1 = __importDefault(require("path"));
|
|
|
9
9
|
const express_1 = require("express");
|
|
10
10
|
const v3_1 = require("zod/v3");
|
|
11
11
|
const logger_1 = require("../utils/logger");
|
|
12
|
-
const agent_variants_1 = require("../
|
|
13
|
-
const contracts_1 = require("../
|
|
12
|
+
const agent_variants_1 = require("../agent-variants");
|
|
13
|
+
const contracts_1 = require("../agent-variants/contracts");
|
|
14
14
|
const changeBatchClassification_1 = require("../mcp/changeBatchClassification");
|
|
15
15
|
const createAgentVariantsOrchestrator_1 = require("../services/createAgentVariantsOrchestrator");
|
|
16
16
|
const VariantHistoryService_1 = require("../services/VariantHistoryService");
|
|
17
17
|
const PrototypeDeployService_1 = require("../services/PrototypeDeployService");
|
|
18
18
|
const HistoryReplayService_1 = require("../services/HistoryReplayService");
|
|
19
|
-
const runLabel_1 = require("../
|
|
19
|
+
const runLabel_1 = require("../agent-variants/runLabel");
|
|
20
20
|
const evaluateFlags_1 = require("../config/evaluateFlags");
|
|
21
21
|
const featureFlagUserKey_1 = require("../config/featureFlagUserKey");
|
|
22
22
|
const variantSessionStart_1 = require("../utils/variantSessionStart");
|
|
23
|
+
const inlineStartTracker_1 = require("./inlineStartTracker");
|
|
24
|
+
const loopback_1 = require("../utils/loopback");
|
|
25
|
+
const preview_bridge_1 = require("../proxy-middleware/preview-bridge");
|
|
23
26
|
const log = (0, logger_1.createLogger)('AgentVariantsRouter');
|
|
27
|
+
const DIRECTION_TITLE_MAX_WORDS = 5;
|
|
28
|
+
const DIRECTION_SUBTITLE_MAX_WORDS = 10;
|
|
24
29
|
/**
|
|
25
30
|
* Public CDN hosts agent-generated previews are allowed to load code/assets
|
|
26
31
|
* from. We don't control which CDN the agent emits: p5.js, three.js, and
|
|
@@ -61,16 +66,32 @@ const PREVIEW_CDN_HOSTS = [
|
|
|
61
66
|
* without widening blast radius, and the per-CDN allowlist above goes away.
|
|
62
67
|
* Until that migration lands, broadening PREVIEW_CDN_HOSTS is the stopgap.
|
|
63
68
|
*/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
/**
|
|
70
|
+
* CSP for agent-generated static previews. Previews are served same-origin on
|
|
71
|
+
* the isolated preview port, so `'self'` resolves to the preview document's own
|
|
72
|
+
* origin and its sibling assets (CSS/JS/GLB/textures) load normally.
|
|
73
|
+
*
|
|
74
|
+
* `frame-ancestors` must also allow the editor origin: with the isolated
|
|
75
|
+
* preview origin the editor lives on a different origin than the preview, so
|
|
76
|
+
* `'self'` alone would block the editor from framing the variant preview
|
|
77
|
+
* (`frame-ancestors 'self' → refused to connect`). See
|
|
78
|
+
* docs/preview-target-addressing-design.md.
|
|
79
|
+
*/
|
|
80
|
+
const buildStaticPreviewCsp = (parentFrameOrigin) => {
|
|
81
|
+
const frameAncestors = parentFrameOrigin
|
|
82
|
+
? `'self' ${parentFrameOrigin}`
|
|
83
|
+
: "'self'";
|
|
84
|
+
return [
|
|
85
|
+
"default-src 'self' data: blob:",
|
|
86
|
+
`script-src 'self' 'unsafe-inline' blob: ${PREVIEW_CDN_HOSTS}`,
|
|
87
|
+
`style-src 'self' 'unsafe-inline' ${PREVIEW_CDN_HOSTS}`,
|
|
88
|
+
"img-src 'self' data: blob: https:",
|
|
89
|
+
`font-src 'self' data: ${PREVIEW_CDN_HOSTS}`,
|
|
90
|
+
`connect-src 'self' blob: ${PREVIEW_CDN_HOSTS}`,
|
|
91
|
+
`frame-ancestors ${frameAncestors}`,
|
|
92
|
+
"base-uri 'self'",
|
|
93
|
+
].join('; ');
|
|
94
|
+
};
|
|
74
95
|
const previewPortBody = v3_1.z.object({
|
|
75
96
|
variantId: v3_1.z.string().min(1).nullable(),
|
|
76
97
|
});
|
|
@@ -120,6 +141,73 @@ const commentReferenceItemSchema = v3_1.z.object({
|
|
|
120
141
|
label: v3_1.z.string().min(1),
|
|
121
142
|
origin: v3_1.z.enum(['live', 'history']),
|
|
122
143
|
});
|
|
144
|
+
const inlineVariantTargetSchema = v3_1.z.object({
|
|
145
|
+
kind: v3_1.z.literal('variant'),
|
|
146
|
+
sessionId: v3_1.z.string().min(1),
|
|
147
|
+
variantId: v3_1.z.string().min(1),
|
|
148
|
+
});
|
|
149
|
+
const inlineStaticPreviewTargetSchema = v3_1.z.object({
|
|
150
|
+
kind: v3_1.z.literal('static_preview'),
|
|
151
|
+
sessionId: v3_1.z.string().min(1),
|
|
152
|
+
variantId: v3_1.z.string().min(1),
|
|
153
|
+
});
|
|
154
|
+
const inlineVariantBriefSchema = contracts_1.startVariantsBriefContent.superRefine((brief, context) => {
|
|
155
|
+
const titleWordCount = brief.label.trim().split(/\s+/).length;
|
|
156
|
+
const subtitleWordCount = brief.body.trim().split(/\s+/).length;
|
|
157
|
+
if (titleWordCount > DIRECTION_TITLE_MAX_WORDS) {
|
|
158
|
+
context.addIssue({
|
|
159
|
+
code: v3_1.z.ZodIssueCode.custom,
|
|
160
|
+
path: ['label'],
|
|
161
|
+
message: 'direction titles must contain at most 5 words',
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
if (subtitleWordCount > DIRECTION_SUBTITLE_MAX_WORDS) {
|
|
165
|
+
context.addIssue({
|
|
166
|
+
code: v3_1.z.ZodIssueCode.custom,
|
|
167
|
+
path: ['body'],
|
|
168
|
+
message: 'direction subtitles must contain at most 10 words',
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
const inlineVariantRequestSchema = v3_1.z
|
|
173
|
+
.object({
|
|
174
|
+
count: v3_1.z.number().int().min(contracts_1.VARIANT_COUNT_MIN).max(contracts_1.VARIANT_COUNT_MAX),
|
|
175
|
+
mode: v3_1.z.enum(['existing', 'zero_to_one']).optional(),
|
|
176
|
+
briefs: v3_1.z
|
|
177
|
+
.array(inlineVariantBriefSchema)
|
|
178
|
+
.min(contracts_1.VARIANT_COUNT_MIN)
|
|
179
|
+
.max(contracts_1.VARIANT_COUNT_MAX)
|
|
180
|
+
.optional(),
|
|
181
|
+
})
|
|
182
|
+
.superRefine((request, context) => {
|
|
183
|
+
if (request.briefs && request.briefs.length !== request.count) {
|
|
184
|
+
context.addIssue({
|
|
185
|
+
code: v3_1.z.ZodIssueCode.custom,
|
|
186
|
+
path: ['briefs'],
|
|
187
|
+
message: 'briefs length must match count',
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
if (request.briefs) {
|
|
191
|
+
const labels = request.briefs.map((brief) => brief.label.trim().toLowerCase().replace(/\s+/g, ' '));
|
|
192
|
+
if (new Set(labels).size !== labels.length) {
|
|
193
|
+
context.addIssue({
|
|
194
|
+
code: v3_1.z.ZodIssueCode.custom,
|
|
195
|
+
path: ['briefs'],
|
|
196
|
+
message: 'brief labels must be distinct',
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
const inlineInitiatorSchema = v3_1.z
|
|
202
|
+
.discriminatedUnion('kind', [
|
|
203
|
+
v3_1.z.object({ kind: v3_1.z.literal('human') }),
|
|
204
|
+
v3_1.z.object({
|
|
205
|
+
kind: v3_1.z.literal('agent'),
|
|
206
|
+
agent: v3_1.z.enum(['claude', 'codex', 'cursor', 'unknown']),
|
|
207
|
+
model: v3_1.z.string().max(200).optional(),
|
|
208
|
+
}),
|
|
209
|
+
])
|
|
210
|
+
.optional();
|
|
123
211
|
const inlineVariantBody = v3_1.z.object({
|
|
124
212
|
changes: v3_1.z
|
|
125
213
|
.array(v3_1.z
|
|
@@ -130,17 +218,15 @@ const inlineVariantBody = v3_1.z.object({
|
|
|
130
218
|
instruction: v3_1.z.string().min(1),
|
|
131
219
|
images: v3_1.z.array(v3_1.z.string()).optional(),
|
|
132
220
|
references: v3_1.z.array(commentReferenceItemSchema).max(8).optional(),
|
|
133
|
-
variantRequest:
|
|
134
|
-
count: v3_1.z
|
|
135
|
-
.number()
|
|
136
|
-
.int()
|
|
137
|
-
.min(contracts_1.VARIANT_COUNT_MIN)
|
|
138
|
-
.max(contracts_1.VARIANT_COUNT_MAX),
|
|
139
|
-
}),
|
|
221
|
+
variantRequest: inlineVariantRequestSchema,
|
|
140
222
|
})
|
|
141
223
|
.passthrough())
|
|
142
224
|
.min(1),
|
|
143
225
|
sourceFiles: v3_1.z.array(v3_1.z.string()).optional(),
|
|
226
|
+
/** Vary on an existing variant: attaches to the active session. */
|
|
227
|
+
target: inlineVariantTargetSchema.optional(),
|
|
228
|
+
/** Vary on an HTML-only static preview: forks it via the refine flow. */
|
|
229
|
+
staticPreviewTarget: inlineStaticPreviewTargetSchema.optional(),
|
|
144
230
|
telemetryContext: v3_1.z
|
|
145
231
|
.object({
|
|
146
232
|
browserSessionId: v3_1.z.string().optional(),
|
|
@@ -149,6 +235,19 @@ const inlineVariantBody = v3_1.z.object({
|
|
|
149
235
|
.optional(),
|
|
150
236
|
traceId: v3_1.z.string().optional(),
|
|
151
237
|
agentRunId: v3_1.z.string().optional(),
|
|
238
|
+
initiator: inlineInitiatorSchema,
|
|
239
|
+
});
|
|
240
|
+
const hostVariantCompleteBody = v3_1.z.object({
|
|
241
|
+
status: v3_1.z.enum(['succeeded', 'failed', 'cancelled']).default('succeeded'),
|
|
242
|
+
output: v3_1.z.unknown().optional(),
|
|
243
|
+
error: v3_1.z
|
|
244
|
+
.object({
|
|
245
|
+
code: v3_1.z.string().min(1),
|
|
246
|
+
message: v3_1.z.string().min(1),
|
|
247
|
+
})
|
|
248
|
+
.optional(),
|
|
249
|
+
title: v3_1.z.string().min(1).max(120).optional(),
|
|
250
|
+
description: v3_1.z.string().min(1).max(400).optional(),
|
|
152
251
|
});
|
|
153
252
|
// Shared by the active-session and history rename routes. Trim first so a
|
|
154
253
|
// whitespace-only title is rejected, and cap the length so an over-long label
|
|
@@ -200,19 +299,18 @@ const escapeHtml = (value) => value.replace(/[&<>"']/g, (char) => {
|
|
|
200
299
|
*/
|
|
201
300
|
const getVariantShareTitle = (manifest) => {
|
|
202
301
|
const title = [manifest.label, manifest.brief, manifest.sessionPrompt].find((candidate) => candidate.trim().length > 0);
|
|
203
|
-
return (
|
|
204
|
-
VARIANT_SHARE_TITLE_FALLBACK);
|
|
302
|
+
return (0, PrototypeDeployService_1.normalizePrototypeShareTitle)(title) ?? VARIANT_SHARE_TITLE_FALLBACK;
|
|
205
303
|
};
|
|
206
304
|
/**
|
|
207
305
|
* Selects the run prompt for a public canvas share, with a stable fallback.
|
|
208
306
|
*/
|
|
209
307
|
const getCanvasShareTitle = (sessionPrompt) => {
|
|
210
|
-
return ((0, PrototypeDeployService_1.normalizePrototypeShareTitle)(sessionPrompt) ??
|
|
211
|
-
CANVAS_SHARE_TITLE_FALLBACK);
|
|
308
|
+
return ((0, PrototypeDeployService_1.normalizePrototypeShareTitle)(sessionPrompt) ?? CANVAS_SHARE_TITLE_FALLBACK);
|
|
212
309
|
};
|
|
213
310
|
const CANVAS_IFRAME_SANDBOX = 'allow-scripts allow-forms allow-popups';
|
|
214
311
|
const RIVET_SOCIAL_IMAGE_URL = 'https://rivet.design/images/rivet-social.png';
|
|
215
312
|
const RIVET_DEFAULT_SHARE_DESCRIPTION = 'Built with Rivet — the visual editor for design';
|
|
313
|
+
const UNSUPPORTED_PROTOTYPE_DEPLOY_MESSAGE = "This prototype can't be deployed — only buildable app directions or static previews are supported.";
|
|
216
314
|
/**
|
|
217
315
|
* Render a public canvas page that puts every deployed direction in one shareable view.
|
|
218
316
|
*/
|
|
@@ -444,7 +542,7 @@ const stampWatcherLiveness = (snapshot, liveness, pendingVariantRequestCount, ac
|
|
|
444
542
|
};
|
|
445
543
|
};
|
|
446
544
|
exports.stampWatcherLiveness = stampWatcherLiveness;
|
|
447
|
-
const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHistoryOverride, deployServiceOverride, variantRunService, historyReplayOverride) => {
|
|
545
|
+
const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHistoryOverride, deployServiceOverride, variantRunService, historyReplayOverride, previewBridge, inlineStartTrackerOverride) => {
|
|
448
546
|
const router = (0, express_1.Router)();
|
|
449
547
|
// `agent_variants.*` events from this router (preview switches, active-project
|
|
450
548
|
// transitions) must carry the browser's PostHog $session_id to link to a
|
|
@@ -467,7 +565,19 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
467
565
|
? (port) => bridge.switchPreviewPort(port)
|
|
468
566
|
: undefined,
|
|
469
567
|
});
|
|
470
|
-
|
|
568
|
+
const inlineStartTracker = inlineStartTrackerOverride ?? (0, inlineStartTracker_1.createInlineStartTracker)();
|
|
569
|
+
const touchActiveVariantSession = () => {
|
|
570
|
+
orchestrator.touchActiveSession?.();
|
|
571
|
+
};
|
|
572
|
+
const touchVariantSession = (sessionId) => {
|
|
573
|
+
orchestrator.touchSession?.(sessionId);
|
|
574
|
+
};
|
|
575
|
+
router.use('/variants', (req, _res, next) => {
|
|
576
|
+
if ((0, loopback_1.isLoopbackAddress)(req.socket.remoteAddress)) {
|
|
577
|
+
touchActiveVariantSession();
|
|
578
|
+
}
|
|
579
|
+
next();
|
|
580
|
+
});
|
|
471
581
|
/**
|
|
472
582
|
* Stamp the live watcher liveness onto a snapshot before it leaves the server.
|
|
473
583
|
* The `typeof` guards keep partial bridge mocks (and a missing bridge) from
|
|
@@ -566,6 +676,31 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
566
676
|
});
|
|
567
677
|
return true;
|
|
568
678
|
};
|
|
679
|
+
/**
|
|
680
|
+
* Resolve the saved app directory a deploy build should run from.
|
|
681
|
+
*/
|
|
682
|
+
const resolveDeployableAppDir = async (args) => {
|
|
683
|
+
const manifest = args.variant.manifest;
|
|
684
|
+
if (manifest.projectKind === 'fresh' &&
|
|
685
|
+
manifest.artifact.kind === 'project') {
|
|
686
|
+
return path_1.default.join(args.variant.variantDir, 'files');
|
|
687
|
+
}
|
|
688
|
+
if (manifest.projectKind !== 'existing' ||
|
|
689
|
+
!manifest.tree ||
|
|
690
|
+
manifest.serve?.kind !== 'dev-server') {
|
|
691
|
+
return null;
|
|
692
|
+
}
|
|
693
|
+
const cacheDir = await variantHistory.store.extractToCache({
|
|
694
|
+
projectPath: args.projectPath,
|
|
695
|
+
treeSha: manifest.tree.treeSha,
|
|
696
|
+
commitish: manifest.tree.ref,
|
|
697
|
+
});
|
|
698
|
+
const appDir = resolvePathWithinRoot(cacheDir, manifest.serve.recipe.cwd);
|
|
699
|
+
if (!appDir || !node_fs_1.default.existsSync(path_1.default.join(appDir, 'package.json'))) {
|
|
700
|
+
return null;
|
|
701
|
+
}
|
|
702
|
+
return appDir;
|
|
703
|
+
};
|
|
569
704
|
/**
|
|
570
705
|
* Deploy one persisted variant and append the returned public URL to history.
|
|
571
706
|
*/
|
|
@@ -594,18 +729,20 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
594
729
|
// — upload files/ directly, no build needed.
|
|
595
730
|
result = await deployService.deployStatic(filesDir, { title });
|
|
596
731
|
}
|
|
597
|
-
else if (args.variant.manifest.projectKind === 'fresh' &&
|
|
598
|
-
args.variant.manifest.artifact.kind === 'project') {
|
|
599
|
-
// Buildable fresh Vite app — compile then upload.
|
|
600
|
-
result = await deployService.deploy(filesDir, { title });
|
|
601
|
-
}
|
|
602
732
|
else {
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
733
|
+
const appDir = await resolveDeployableAppDir({
|
|
734
|
+
projectPath: args.projectPath,
|
|
735
|
+
variant: args.variant,
|
|
736
|
+
});
|
|
737
|
+
if (!appDir) {
|
|
738
|
+
return {
|
|
739
|
+
ok: false,
|
|
740
|
+
status: 422,
|
|
741
|
+
errorCode: 'RUNTIME_VALIDATION_FAILED',
|
|
742
|
+
message: UNSUPPORTED_PROTOTYPE_DEPLOY_MESSAGE,
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
result = await deployService.deploy(appDir, { title });
|
|
609
746
|
}
|
|
610
747
|
const deployment = {
|
|
611
748
|
deployId: result.deployId,
|
|
@@ -646,13 +783,37 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
646
783
|
});
|
|
647
784
|
return;
|
|
648
785
|
}
|
|
786
|
+
// Resolve a variant target that points at an HTML-only static preview:
|
|
787
|
+
// those requests fork through the refine flow rather than code-gen (a
|
|
788
|
+
// static preview has no worktree to edit). Gate on the TRUE work-item kind
|
|
789
|
+
// — never on HTML presence or the client's claim: an existing-project
|
|
790
|
+
// `code_gen` variant materialized as a static preview serves HTML and
|
|
791
|
+
// displays as `static_artifact`, but owns a worktree and MUST fork via the
|
|
792
|
+
// code_gen path (the static fork would reject it with VARIANT_NOT_EDITABLE).
|
|
793
|
+
const batchTarget = parsed.data.target;
|
|
794
|
+
const claimedStaticTarget = parsed.data.staticPreviewTarget ??
|
|
795
|
+
(batchTarget
|
|
796
|
+
? {
|
|
797
|
+
kind: 'static_preview',
|
|
798
|
+
sessionId: batchTarget.sessionId,
|
|
799
|
+
variantId: batchTarget.variantId,
|
|
800
|
+
}
|
|
801
|
+
: undefined);
|
|
802
|
+
const staticPreviewTarget = claimedStaticTarget &&
|
|
803
|
+
orchestrator.getVariantWorkItemKind(claimedStaticTarget.sessionId, claimedStaticTarget.variantId) === 'static_preview'
|
|
804
|
+
? claimedStaticTarget
|
|
805
|
+
: undefined;
|
|
649
806
|
const request = {
|
|
650
807
|
changes: parsed.data.changes,
|
|
651
808
|
sourceFiles: parsed.data.sourceFiles ?? [],
|
|
809
|
+
target: batchTarget,
|
|
810
|
+
staticPreviewTarget,
|
|
652
811
|
telemetryContext: parsed.data.telemetryContext,
|
|
653
812
|
traceId: parsed.data.traceId,
|
|
654
813
|
agentRunId: parsed.data.agentRunId,
|
|
814
|
+
initiator: parsed.data.initiator,
|
|
655
815
|
};
|
|
816
|
+
bridge?.updateTelemetryContext(request.telemetryContext);
|
|
656
817
|
if ((0, changeBatchClassification_1.isMixedVariantBatch)(request) || !(0, changeBatchClassification_1.isSingleVariantRequestBatch)(request)) {
|
|
657
818
|
res.status(400).json({
|
|
658
819
|
error: 'Invalid inline variants batch',
|
|
@@ -662,18 +823,63 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
662
823
|
return;
|
|
663
824
|
}
|
|
664
825
|
const activeVariantsSession = orchestrator.buildActiveSnapshot();
|
|
665
|
-
|
|
666
|
-
|
|
826
|
+
// A targeted request attaches to the active session as a new concurrent
|
|
827
|
+
// run — allowed while a session is live, but only against the CURRENTLY
|
|
828
|
+
// active session (mirrors the queue-changes intake guards).
|
|
829
|
+
const effectiveTarget = batchTarget ?? staticPreviewTarget;
|
|
830
|
+
if (effectiveTarget &&
|
|
831
|
+
activeVariantsSession.active === true &&
|
|
832
|
+
effectiveTarget.sessionId !== activeVariantsSession.sessionId) {
|
|
833
|
+
res.status(400).json({
|
|
834
|
+
error: 'Stale variant target',
|
|
835
|
+
details: 'The targeted variants session is not the active one. Refresh the editor and retry.',
|
|
836
|
+
reason: 'stale_target',
|
|
837
|
+
});
|
|
838
|
+
return;
|
|
839
|
+
}
|
|
840
|
+
if (!effectiveTarget &&
|
|
841
|
+
(0, variantSessionStart_1.isVariantSessionStartBlocked)(activeVariantsSession)) {
|
|
842
|
+
const stage = activeVariantsSession.active === true
|
|
843
|
+
? activeVariantsSession.stage
|
|
844
|
+
: undefined;
|
|
845
|
+
const sessionId = activeVariantsSession.active === true
|
|
846
|
+
? activeVariantsSession.sessionId
|
|
847
|
+
: undefined;
|
|
667
848
|
res.status(400).json({
|
|
668
849
|
error: 'Variants session already active',
|
|
669
|
-
|
|
850
|
+
// Name the blocker so callers are not flying blind, and never
|
|
851
|
+
// recommend cancel as remediation: cancelling to unblock destroys
|
|
852
|
+
// the user's in-progress work. Only a human should decide that.
|
|
853
|
+
details: `A variants session is active${sessionId
|
|
854
|
+
? ` (session ${sessionId}${stage ? `, stage ${stage}` : ''})`
|
|
855
|
+
: ''}. Wait for it to settle (poll status), target it with --target to refine it, or ask the user before cancelling anything.`,
|
|
670
856
|
reason: 'active_session',
|
|
671
857
|
});
|
|
672
858
|
return;
|
|
673
859
|
}
|
|
674
|
-
|
|
860
|
+
if (!effectiveTarget && inlineStartTracker.isStarting()) {
|
|
861
|
+
res.status(400).json({
|
|
862
|
+
error: 'Variants start already in progress',
|
|
863
|
+
details: 'A variants start for this project is still being processed (provisioning can take a while) — status reports it as `variants.starting`. Poll status until the session registers or the start settles, then retry. Do not cancel anything.',
|
|
864
|
+
reason: 'start_in_flight',
|
|
865
|
+
});
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
if (!effectiveTarget) {
|
|
869
|
+
inlineStartTracker.begin();
|
|
870
|
+
}
|
|
675
871
|
try {
|
|
676
|
-
const
|
|
872
|
+
const isStaticPreviewFork = Boolean(staticPreviewTarget);
|
|
873
|
+
if (isStaticPreviewFork && !variantRunService.refineStaticPreviewBatch) {
|
|
874
|
+
res.status(503).json({
|
|
875
|
+
error: 'Static preview refinement unavailable',
|
|
876
|
+
reason: 'inline_variants_unavailable',
|
|
877
|
+
});
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
880
|
+
const result = isStaticPreviewFork
|
|
881
|
+
? await variantRunService.refineStaticPreviewBatch(request)
|
|
882
|
+
: await variantRunService.startElementVariants(request);
|
|
677
883
|
if (!result.success) {
|
|
678
884
|
res.status(500).json({
|
|
679
885
|
error: result.error ?? 'Inline variants run failed',
|
|
@@ -691,13 +897,62 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
691
897
|
});
|
|
692
898
|
}
|
|
693
899
|
finally {
|
|
694
|
-
|
|
900
|
+
if (!effectiveTarget) {
|
|
901
|
+
inlineStartTracker.end();
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
});
|
|
905
|
+
router.post('/variants/:sessionId/work/:workItemId/complete', async (req, res) => {
|
|
906
|
+
if (rejectNonLocalRequest(req, res))
|
|
907
|
+
return;
|
|
908
|
+
if (!variantRunService) {
|
|
909
|
+
res.status(503).json({
|
|
910
|
+
error: 'Variants unavailable',
|
|
911
|
+
reason: 'variants_unavailable',
|
|
912
|
+
});
|
|
913
|
+
return;
|
|
914
|
+
}
|
|
915
|
+
const parsed = hostVariantCompleteBody.safeParse(req.body);
|
|
916
|
+
if (!parsed.success) {
|
|
917
|
+
res.status(400).json({
|
|
918
|
+
error: 'Invalid host work completion payload',
|
|
919
|
+
details: parsed.error.flatten(),
|
|
920
|
+
});
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
try {
|
|
924
|
+
const result = await variantRunService.completeHostWork({
|
|
925
|
+
sessionId: req.params.sessionId,
|
|
926
|
+
workItemId: req.params.workItemId,
|
|
927
|
+
status: parsed.data.status,
|
|
928
|
+
...(parsed.data.output !== undefined
|
|
929
|
+
? { output: parsed.data.output }
|
|
930
|
+
: {}),
|
|
931
|
+
...(parsed.data.error ? { error: parsed.data.error } : {}),
|
|
932
|
+
...(parsed.data.title ? { title: parsed.data.title } : {}),
|
|
933
|
+
...(parsed.data.description
|
|
934
|
+
? { description: parsed.data.description }
|
|
935
|
+
: {}),
|
|
936
|
+
});
|
|
937
|
+
res.status(200).json(result);
|
|
938
|
+
}
|
|
939
|
+
catch (err) {
|
|
940
|
+
const status = err instanceof agent_variants_1.AgentVariantsError ? 400 : 500;
|
|
941
|
+
res.status(status).json({
|
|
942
|
+
error: err instanceof Error ? err.message : 'Host work completion failed',
|
|
943
|
+
reason: err instanceof agent_variants_1.AgentVariantsError
|
|
944
|
+
? err.code
|
|
945
|
+
: 'host_work_completion_failed',
|
|
946
|
+
});
|
|
695
947
|
}
|
|
696
948
|
});
|
|
697
949
|
router.get('/variants/active', (req, res) => {
|
|
698
950
|
if (rejectNonLocalRequest(req, res))
|
|
699
951
|
return;
|
|
700
|
-
res.json(stampLiveness(
|
|
952
|
+
res.json(stampLiveness({
|
|
953
|
+
...orchestrator.buildActiveSnapshot(),
|
|
954
|
+
starting: inlineStartTracker.isStarting(),
|
|
955
|
+
}));
|
|
701
956
|
});
|
|
702
957
|
/**
|
|
703
958
|
* Server-Sent Events stream for the iframe chip. Pushes a fresh
|
|
@@ -725,7 +980,13 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
725
980
|
// so the initial state and every subscribed update carry them.
|
|
726
981
|
const writeSnapshot = (snapshot) => {
|
|
727
982
|
try {
|
|
728
|
-
|
|
983
|
+
const activeSnapshot = snapshot && typeof snapshot === 'object'
|
|
984
|
+
? {
|
|
985
|
+
...snapshot,
|
|
986
|
+
starting: inlineStartTracker.isStarting(),
|
|
987
|
+
}
|
|
988
|
+
: snapshot;
|
|
989
|
+
res.write(`data: ${JSON.stringify(stampLiveness(activeSnapshot))}\n\n`);
|
|
729
990
|
}
|
|
730
991
|
catch (err) {
|
|
731
992
|
log.warn('SSE write failed (client likely disconnected)', err);
|
|
@@ -748,6 +1009,7 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
748
1009
|
const releaseUiClient = orchestrator.registerUiClient();
|
|
749
1010
|
const heartbeat = setInterval(() => {
|
|
750
1011
|
try {
|
|
1012
|
+
touchActiveVariantSession();
|
|
751
1013
|
res.write(': heartbeat\n\n');
|
|
752
1014
|
}
|
|
753
1015
|
catch {
|
|
@@ -799,7 +1061,11 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
799
1061
|
return;
|
|
800
1062
|
}
|
|
801
1063
|
try {
|
|
802
|
-
const entries = (await Promise.all(resolveHistoryProjectPaths({ projectPath }).map((historyProjectPath) =>
|
|
1064
|
+
const entries = (await Promise.all(resolveHistoryProjectPaths({ projectPath }).map((historyProjectPath) =>
|
|
1065
|
+
// Reads the SQLite metadata index when it's usable and falls
|
|
1066
|
+
// back to the manifest walk otherwise — same entries, faster
|
|
1067
|
+
// list. Detail/preview routes stay manifest/file-backed.
|
|
1068
|
+
variantHistory.listVariantsFromIndex({
|
|
803
1069
|
projectPath: historyProjectPath,
|
|
804
1070
|
status: statusParam,
|
|
805
1071
|
})))).flat();
|
|
@@ -827,6 +1093,7 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
827
1093
|
runLabel: entry.manifest.runLabel ??
|
|
828
1094
|
(0, runLabel_1.deriveRunLabel)(entry.manifest.sessionPrompt),
|
|
829
1095
|
kind: manifestKind(entry.manifest),
|
|
1096
|
+
projectKind: entry.manifest.projectKind,
|
|
830
1097
|
status: entry.manifest.status,
|
|
831
1098
|
createdAt: entry.manifest.createdAt,
|
|
832
1099
|
statusChangedAt: entry.manifest.statusChangedAt,
|
|
@@ -834,6 +1101,7 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
834
1101
|
hasStaticPreview: entry.hasStaticPreview,
|
|
835
1102
|
preview: entry.manifest.preview,
|
|
836
1103
|
artifact: entry.manifest.artifact,
|
|
1104
|
+
parentVariant: entry.manifest.parentVariant,
|
|
837
1105
|
// Tree-store fields (absent on legacy entries): `serve` tells the
|
|
838
1106
|
// panel how a tree-backed entry previews (static → history preview
|
|
839
1107
|
// route; dev-server → the replay run route), `hasTree` marks the
|
|
@@ -850,23 +1118,29 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
850
1118
|
// Mirror the live static route's split: the HTML document and its sibling
|
|
851
1119
|
// assets are served by separate handlers, so the preview CSP is attached
|
|
852
1120
|
// structurally (document only) rather than via a runtime content-type branch.
|
|
853
|
-
router.get('/variants/history/:sessionId/:variantId/preview', async (req, res) => serveHistoryPreview(req, res, variantHistory, resolveProjectPath, resolveHistoryProjectPaths, { isDocument: true }));
|
|
1121
|
+
router.get('/variants/history/:sessionId/:variantId/preview', async (req, res) => serveHistoryPreview(req, res, variantHistory, resolveProjectPath, resolveHistoryProjectPaths, { isDocument: true }, previewBridge));
|
|
854
1122
|
router.get('/variants/history/:sessionId/:variantId/preview/{*assetPath}', async (req, res) => serveHistoryPreview(req, res, variantHistory, resolveProjectPath, resolveHistoryProjectPaths, { isDocument: false }));
|
|
855
|
-
// Stop
|
|
1123
|
+
// Stop history replay servers. Registered before the
|
|
856
1124
|
// parameterized history routes purely for clarity — method+arity keep it
|
|
857
1125
|
// unambiguous either way.
|
|
858
1126
|
router.post('/variants/history/replay/stop', async (req, res) => {
|
|
859
1127
|
if (rejectNonLocalRequest(req, res))
|
|
860
1128
|
return;
|
|
861
|
-
|
|
1129
|
+
const sessionId = typeof req.query.sessionId === 'string' ? req.query.sessionId : null;
|
|
1130
|
+
const variantId = typeof req.query.variantId === 'string' ? req.query.variantId : null;
|
|
1131
|
+
if (sessionId && variantId) {
|
|
1132
|
+
await historyReplay.stop({ sessionId, variantId });
|
|
1133
|
+
}
|
|
1134
|
+
else {
|
|
1135
|
+
await historyReplay.stop();
|
|
1136
|
+
}
|
|
862
1137
|
res.json({ stopped: true });
|
|
863
1138
|
});
|
|
864
1139
|
/**
|
|
865
1140
|
* Boot a past dev-server variant from its tree-store ref: materialize the
|
|
866
1141
|
* exact tree, overlay runtime (.env / node_modules), start the persisted
|
|
867
|
-
* serve recipe, and retarget the preview proxy at the new
|
|
868
|
-
*
|
|
869
|
-
* docs/variant-history-tree-store-design.md.
|
|
1142
|
+
* serve recipe, and optionally retarget the main preview proxy at the new
|
|
1143
|
+
* port. See docs/variant-history-tree-store-design.md.
|
|
870
1144
|
*/
|
|
871
1145
|
router.post('/variants/history/:sessionId/:variantId/run', async (req, res) => {
|
|
872
1146
|
if (rejectNonLocalRequest(req, res))
|
|
@@ -898,6 +1172,7 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
898
1172
|
projectPath: found.projectPath,
|
|
899
1173
|
sessionId,
|
|
900
1174
|
variantId,
|
|
1175
|
+
retargetProxy: req.query.targetAddressed !== '1',
|
|
901
1176
|
});
|
|
902
1177
|
res.json(result);
|
|
903
1178
|
}
|
|
@@ -991,6 +1266,7 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
991
1266
|
});
|
|
992
1267
|
return;
|
|
993
1268
|
}
|
|
1269
|
+
touchVariantSession(sessionId);
|
|
994
1270
|
try {
|
|
995
1271
|
if (!parsed.data.variantId) {
|
|
996
1272
|
variantsTelemetry?.trackAgentVariantsPreviewSwitchStarted({
|
|
@@ -1229,20 +1505,29 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
1229
1505
|
res.redirect(301, req.originalUrl + '/');
|
|
1230
1506
|
return;
|
|
1231
1507
|
}
|
|
1232
|
-
const
|
|
1508
|
+
const withBaseHref = hasAssets
|
|
1233
1509
|
? injectBaseHref(html,
|
|
1234
1510
|
// Trailing slash is required so `./avatar.glb` resolves to
|
|
1235
1511
|
// `.../static/<vid>/avatar.glb`, not `.../static/avatar.glb`.
|
|
1236
1512
|
`/api/variants/${encodeURIComponent(sessionId)}/static/${encodeURIComponent(variantId)}/`)
|
|
1237
1513
|
: html;
|
|
1514
|
+
// In embedded mode the visual editor drives this iframe over the preview
|
|
1515
|
+
// bridge; without the injected listener, selecting/commenting on the
|
|
1516
|
+
// variant times out (`Preview bridge timed out`) and the comment input
|
|
1517
|
+
// never opens. Mirror the base static route (`routes/static.ts`).
|
|
1518
|
+
const finalHtml = previewBridge?.isEnabled
|
|
1519
|
+
? (0, preview_bridge_1.injectPreviewBridge)(withBaseHref, {
|
|
1520
|
+
expectedParentOrigin: previewBridge.expectedParentOrigin,
|
|
1521
|
+
})
|
|
1522
|
+
: withBaseHref;
|
|
1238
1523
|
// Constrain the blast radius of agent-generated scripts. See
|
|
1239
|
-
//
|
|
1524
|
+
// buildStaticPreviewCsp for the policy and the isolated-origin migration
|
|
1240
1525
|
// that will eventually let us drop the per-CDN allowlist.
|
|
1241
1526
|
res
|
|
1242
1527
|
.status(200)
|
|
1243
1528
|
.type('html')
|
|
1244
1529
|
.set('Cache-Control', 'no-store')
|
|
1245
|
-
.set('Content-Security-Policy',
|
|
1530
|
+
.set('Content-Security-Policy', buildStaticPreviewCsp(previewBridge?.expectedParentOrigin))
|
|
1246
1531
|
.set('X-Content-Type-Options', 'nosniff')
|
|
1247
1532
|
.send(finalHtml);
|
|
1248
1533
|
}
|
|
@@ -1828,7 +2113,7 @@ exports.createAgentVariantsRouter = createAgentVariantsRouter;
|
|
|
1828
2113
|
* preview CSP; sibling assets (css/js/images) carry none, since a CSP header is
|
|
1829
2114
|
* only load-bearing on the document that fetches sub-resources.
|
|
1830
2115
|
*/
|
|
1831
|
-
const serveHistoryPreview = async (req, res, variantHistory, resolveProjectPath, resolveHistoryProjectPaths, { isDocument }) => {
|
|
2116
|
+
const serveHistoryPreview = async (req, res, variantHistory, resolveProjectPath, resolveHistoryProjectPaths, { isDocument }, previewBridge) => {
|
|
1832
2117
|
if (rejectNonLocalRequest(req, res))
|
|
1833
2118
|
return;
|
|
1834
2119
|
const invalidRawAssetPath = getInvalidRawHistoryPreviewAssetPath(req);
|
|
@@ -1891,8 +2176,17 @@ const serveHistoryPreview = async (req, res, variantHistory, resolveProjectPath,
|
|
|
1891
2176
|
// blanking out where the live preview rendered.
|
|
1892
2177
|
if (isDocument) {
|
|
1893
2178
|
res
|
|
1894
|
-
.set('Content-Security-Policy',
|
|
2179
|
+
.set('Content-Security-Policy', buildStaticPreviewCsp(previewBridge?.expectedParentOrigin))
|
|
1895
2180
|
.set('X-Content-Type-Options', 'nosniff');
|
|
2181
|
+
// Embedded mode drives this snapshot iframe over the preview bridge; the
|
|
2182
|
+
// listener must be present or selecting/commenting on a past variant
|
|
2183
|
+
// times out (`Preview bridge timed out`). Matches the live static route.
|
|
2184
|
+
if (previewBridge?.isEnabled) {
|
|
2185
|
+
res.send((0, preview_bridge_1.injectPreviewBridge)(file.body.toString('utf8'), {
|
|
2186
|
+
expectedParentOrigin: previewBridge.expectedParentOrigin,
|
|
2187
|
+
}));
|
|
2188
|
+
return;
|
|
2189
|
+
}
|
|
1896
2190
|
}
|
|
1897
2191
|
res.send(file.body);
|
|
1898
2192
|
}
|
|
@@ -1932,9 +2226,23 @@ const getInvalidRawHistoryPreviewAssetPath = (req) => {
|
|
|
1932
2226
|
}
|
|
1933
2227
|
return null;
|
|
1934
2228
|
};
|
|
2229
|
+
/**
|
|
2230
|
+
* Resolve a child path while rejecting paths that escape the intended root.
|
|
2231
|
+
*/
|
|
2232
|
+
const resolvePathWithinRoot = (rootPath, childPath) => {
|
|
2233
|
+
const absolutePath = path_1.default.resolve(rootPath, childPath);
|
|
2234
|
+
const relativePath = path_1.default.relative(rootPath, absolutePath);
|
|
2235
|
+
if (relativePath === '' ||
|
|
2236
|
+
(relativePath.length > 0 &&
|
|
2237
|
+
!relativePath.startsWith('..') &&
|
|
2238
|
+
!path_1.default.isAbsolute(relativePath))) {
|
|
2239
|
+
return absolutePath;
|
|
2240
|
+
}
|
|
2241
|
+
return null;
|
|
2242
|
+
};
|
|
1935
2243
|
function rejectNonLocalRequest(req, res) {
|
|
1936
2244
|
const remoteAddress = req.socket.remoteAddress;
|
|
1937
|
-
if (isLoopbackAddress(remoteAddress))
|
|
2245
|
+
if ((0, loopback_1.isLoopbackAddress)(remoteAddress))
|
|
1938
2246
|
return false;
|
|
1939
2247
|
res.status(403).json({
|
|
1940
2248
|
errorCode: 'RUNTIME_VALIDATION_FAILED',
|
|
@@ -1942,13 +2250,6 @@ function rejectNonLocalRequest(req, res) {
|
|
|
1942
2250
|
});
|
|
1943
2251
|
return true;
|
|
1944
2252
|
}
|
|
1945
|
-
function isLoopbackAddress(remoteAddress) {
|
|
1946
|
-
if (!remoteAddress)
|
|
1947
|
-
return false;
|
|
1948
|
-
return (remoteAddress === '127.0.0.1' ||
|
|
1949
|
-
remoteAddress === '::1' ||
|
|
1950
|
-
remoteAddress.startsWith('::ffff:127.'));
|
|
1951
|
-
}
|
|
1952
2253
|
function stateForSession(orchestrator, sessionId) {
|
|
1953
2254
|
const stage = orchestrator.getStage(sessionId);
|
|
1954
2255
|
const briefs = orchestrator.getBriefs(sessionId);
|