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
|
@@ -9,17 +9,20 @@ 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');
|
|
24
27
|
/**
|
|
25
28
|
* Public CDN hosts agent-generated previews are allowed to load code/assets
|
|
@@ -61,16 +64,32 @@ const PREVIEW_CDN_HOSTS = [
|
|
|
61
64
|
* without widening blast radius, and the per-CDN allowlist above goes away.
|
|
62
65
|
* Until that migration lands, broadening PREVIEW_CDN_HOSTS is the stopgap.
|
|
63
66
|
*/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
/**
|
|
68
|
+
* CSP for agent-generated static previews. Previews are served same-origin on
|
|
69
|
+
* the isolated preview port, so `'self'` resolves to the preview document's own
|
|
70
|
+
* origin and its sibling assets (CSS/JS/GLB/textures) load normally.
|
|
71
|
+
*
|
|
72
|
+
* `frame-ancestors` must also allow the editor origin: with the isolated
|
|
73
|
+
* preview origin the editor lives on a different origin than the preview, so
|
|
74
|
+
* `'self'` alone would block the editor from framing the variant preview
|
|
75
|
+
* (`frame-ancestors 'self' → refused to connect`). See
|
|
76
|
+
* docs/preview-target-addressing-design.md.
|
|
77
|
+
*/
|
|
78
|
+
const buildStaticPreviewCsp = (parentFrameOrigin) => {
|
|
79
|
+
const frameAncestors = parentFrameOrigin
|
|
80
|
+
? `'self' ${parentFrameOrigin}`
|
|
81
|
+
: "'self'";
|
|
82
|
+
return [
|
|
83
|
+
"default-src 'self' data: blob:",
|
|
84
|
+
`script-src 'self' 'unsafe-inline' blob: ${PREVIEW_CDN_HOSTS}`,
|
|
85
|
+
`style-src 'self' 'unsafe-inline' ${PREVIEW_CDN_HOSTS}`,
|
|
86
|
+
"img-src 'self' data: blob: https:",
|
|
87
|
+
`font-src 'self' data: ${PREVIEW_CDN_HOSTS}`,
|
|
88
|
+
`connect-src 'self' blob: ${PREVIEW_CDN_HOSTS}`,
|
|
89
|
+
`frame-ancestors ${frameAncestors}`,
|
|
90
|
+
"base-uri 'self'",
|
|
91
|
+
].join('; ');
|
|
92
|
+
};
|
|
74
93
|
const previewPortBody = v3_1.z.object({
|
|
75
94
|
variantId: v3_1.z.string().min(1).nullable(),
|
|
76
95
|
});
|
|
@@ -120,6 +139,30 @@ const commentReferenceItemSchema = v3_1.z.object({
|
|
|
120
139
|
label: v3_1.z.string().min(1),
|
|
121
140
|
origin: v3_1.z.enum(['live', 'history']),
|
|
122
141
|
});
|
|
142
|
+
const inlineVariantTargetSchema = v3_1.z.object({
|
|
143
|
+
kind: v3_1.z.literal('variant'),
|
|
144
|
+
sessionId: v3_1.z.string().min(1),
|
|
145
|
+
variantId: v3_1.z.string().min(1),
|
|
146
|
+
});
|
|
147
|
+
const inlineStaticPreviewTargetSchema = v3_1.z.object({
|
|
148
|
+
kind: v3_1.z.literal('static_preview'),
|
|
149
|
+
sessionId: v3_1.z.string().min(1),
|
|
150
|
+
variantId: v3_1.z.string().min(1),
|
|
151
|
+
});
|
|
152
|
+
const inlineVariantRequestSchema = v3_1.z.object({
|
|
153
|
+
count: v3_1.z.number().int().min(contracts_1.VARIANT_COUNT_MIN).max(contracts_1.VARIANT_COUNT_MAX),
|
|
154
|
+
mode: v3_1.z.enum(['existing', 'zero_to_one']).optional(),
|
|
155
|
+
});
|
|
156
|
+
const inlineInitiatorSchema = v3_1.z
|
|
157
|
+
.discriminatedUnion('kind', [
|
|
158
|
+
v3_1.z.object({ kind: v3_1.z.literal('human') }),
|
|
159
|
+
v3_1.z.object({
|
|
160
|
+
kind: v3_1.z.literal('agent'),
|
|
161
|
+
agent: v3_1.z.enum(['claude', 'codex', 'cursor', 'unknown']),
|
|
162
|
+
model: v3_1.z.string().max(200).optional(),
|
|
163
|
+
}),
|
|
164
|
+
])
|
|
165
|
+
.optional();
|
|
123
166
|
const inlineVariantBody = v3_1.z.object({
|
|
124
167
|
changes: v3_1.z
|
|
125
168
|
.array(v3_1.z
|
|
@@ -130,17 +173,15 @@ const inlineVariantBody = v3_1.z.object({
|
|
|
130
173
|
instruction: v3_1.z.string().min(1),
|
|
131
174
|
images: v3_1.z.array(v3_1.z.string()).optional(),
|
|
132
175
|
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
|
-
}),
|
|
176
|
+
variantRequest: inlineVariantRequestSchema,
|
|
140
177
|
})
|
|
141
178
|
.passthrough())
|
|
142
179
|
.min(1),
|
|
143
180
|
sourceFiles: v3_1.z.array(v3_1.z.string()).optional(),
|
|
181
|
+
/** Vary on an existing variant: attaches to the active session. */
|
|
182
|
+
target: inlineVariantTargetSchema.optional(),
|
|
183
|
+
/** Vary on an HTML-only static preview: forks it via the refine flow. */
|
|
184
|
+
staticPreviewTarget: inlineStaticPreviewTargetSchema.optional(),
|
|
144
185
|
telemetryContext: v3_1.z
|
|
145
186
|
.object({
|
|
146
187
|
browserSessionId: v3_1.z.string().optional(),
|
|
@@ -149,6 +190,19 @@ const inlineVariantBody = v3_1.z.object({
|
|
|
149
190
|
.optional(),
|
|
150
191
|
traceId: v3_1.z.string().optional(),
|
|
151
192
|
agentRunId: v3_1.z.string().optional(),
|
|
193
|
+
initiator: inlineInitiatorSchema,
|
|
194
|
+
});
|
|
195
|
+
const hostVariantCompleteBody = v3_1.z.object({
|
|
196
|
+
status: v3_1.z.enum(['succeeded', 'failed', 'cancelled']).default('succeeded'),
|
|
197
|
+
output: v3_1.z.unknown().optional(),
|
|
198
|
+
error: v3_1.z
|
|
199
|
+
.object({
|
|
200
|
+
code: v3_1.z.string().min(1),
|
|
201
|
+
message: v3_1.z.string().min(1),
|
|
202
|
+
})
|
|
203
|
+
.optional(),
|
|
204
|
+
title: v3_1.z.string().min(1).max(120).optional(),
|
|
205
|
+
description: v3_1.z.string().min(1).max(400).optional(),
|
|
152
206
|
});
|
|
153
207
|
// Shared by the active-session and history rename routes. Trim first so a
|
|
154
208
|
// whitespace-only title is rejected, and cap the length so an over-long label
|
|
@@ -200,19 +254,18 @@ const escapeHtml = (value) => value.replace(/[&<>"']/g, (char) => {
|
|
|
200
254
|
*/
|
|
201
255
|
const getVariantShareTitle = (manifest) => {
|
|
202
256
|
const title = [manifest.label, manifest.brief, manifest.sessionPrompt].find((candidate) => candidate.trim().length > 0);
|
|
203
|
-
return (
|
|
204
|
-
VARIANT_SHARE_TITLE_FALLBACK);
|
|
257
|
+
return (0, PrototypeDeployService_1.normalizePrototypeShareTitle)(title) ?? VARIANT_SHARE_TITLE_FALLBACK;
|
|
205
258
|
};
|
|
206
259
|
/**
|
|
207
260
|
* Selects the run prompt for a public canvas share, with a stable fallback.
|
|
208
261
|
*/
|
|
209
262
|
const getCanvasShareTitle = (sessionPrompt) => {
|
|
210
|
-
return ((0, PrototypeDeployService_1.normalizePrototypeShareTitle)(sessionPrompt) ??
|
|
211
|
-
CANVAS_SHARE_TITLE_FALLBACK);
|
|
263
|
+
return ((0, PrototypeDeployService_1.normalizePrototypeShareTitle)(sessionPrompt) ?? CANVAS_SHARE_TITLE_FALLBACK);
|
|
212
264
|
};
|
|
213
265
|
const CANVAS_IFRAME_SANDBOX = 'allow-scripts allow-forms allow-popups';
|
|
214
266
|
const RIVET_SOCIAL_IMAGE_URL = 'https://rivet.design/images/rivet-social.png';
|
|
215
267
|
const RIVET_DEFAULT_SHARE_DESCRIPTION = 'Built with Rivet — the visual editor for design';
|
|
268
|
+
const UNSUPPORTED_PROTOTYPE_DEPLOY_MESSAGE = "This prototype can't be deployed — only buildable app directions or static previews are supported.";
|
|
216
269
|
/**
|
|
217
270
|
* Render a public canvas page that puts every deployed direction in one shareable view.
|
|
218
271
|
*/
|
|
@@ -444,7 +497,7 @@ const stampWatcherLiveness = (snapshot, liveness, pendingVariantRequestCount, ac
|
|
|
444
497
|
};
|
|
445
498
|
};
|
|
446
499
|
exports.stampWatcherLiveness = stampWatcherLiveness;
|
|
447
|
-
const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHistoryOverride, deployServiceOverride, variantRunService, historyReplayOverride) => {
|
|
500
|
+
const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHistoryOverride, deployServiceOverride, variantRunService, historyReplayOverride, previewBridge, inlineStartTrackerOverride) => {
|
|
448
501
|
const router = (0, express_1.Router)();
|
|
449
502
|
// `agent_variants.*` events from this router (preview switches, active-project
|
|
450
503
|
// transitions) must carry the browser's PostHog $session_id to link to a
|
|
@@ -467,7 +520,19 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
467
520
|
? (port) => bridge.switchPreviewPort(port)
|
|
468
521
|
: undefined,
|
|
469
522
|
});
|
|
470
|
-
|
|
523
|
+
const inlineStartTracker = inlineStartTrackerOverride ?? (0, inlineStartTracker_1.createInlineStartTracker)();
|
|
524
|
+
const touchActiveVariantSession = () => {
|
|
525
|
+
orchestrator.touchActiveSession?.();
|
|
526
|
+
};
|
|
527
|
+
const touchVariantSession = (sessionId) => {
|
|
528
|
+
orchestrator.touchSession?.(sessionId);
|
|
529
|
+
};
|
|
530
|
+
router.use('/variants', (req, _res, next) => {
|
|
531
|
+
if ((0, loopback_1.isLoopbackAddress)(req.socket.remoteAddress)) {
|
|
532
|
+
touchActiveVariantSession();
|
|
533
|
+
}
|
|
534
|
+
next();
|
|
535
|
+
});
|
|
471
536
|
/**
|
|
472
537
|
* Stamp the live watcher liveness onto a snapshot before it leaves the server.
|
|
473
538
|
* The `typeof` guards keep partial bridge mocks (and a missing bridge) from
|
|
@@ -566,6 +631,31 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
566
631
|
});
|
|
567
632
|
return true;
|
|
568
633
|
};
|
|
634
|
+
/**
|
|
635
|
+
* Resolve the saved app directory a deploy build should run from.
|
|
636
|
+
*/
|
|
637
|
+
const resolveDeployableAppDir = async (args) => {
|
|
638
|
+
const manifest = args.variant.manifest;
|
|
639
|
+
if (manifest.projectKind === 'fresh' &&
|
|
640
|
+
manifest.artifact.kind === 'project') {
|
|
641
|
+
return path_1.default.join(args.variant.variantDir, 'files');
|
|
642
|
+
}
|
|
643
|
+
if (manifest.projectKind !== 'existing' ||
|
|
644
|
+
!manifest.tree ||
|
|
645
|
+
manifest.serve?.kind !== 'dev-server') {
|
|
646
|
+
return null;
|
|
647
|
+
}
|
|
648
|
+
const cacheDir = await variantHistory.store.extractToCache({
|
|
649
|
+
projectPath: args.projectPath,
|
|
650
|
+
treeSha: manifest.tree.treeSha,
|
|
651
|
+
commitish: manifest.tree.ref,
|
|
652
|
+
});
|
|
653
|
+
const appDir = resolvePathWithinRoot(cacheDir, manifest.serve.recipe.cwd);
|
|
654
|
+
if (!appDir || !node_fs_1.default.existsSync(path_1.default.join(appDir, 'package.json'))) {
|
|
655
|
+
return null;
|
|
656
|
+
}
|
|
657
|
+
return appDir;
|
|
658
|
+
};
|
|
569
659
|
/**
|
|
570
660
|
* Deploy one persisted variant and append the returned public URL to history.
|
|
571
661
|
*/
|
|
@@ -594,18 +684,20 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
594
684
|
// — upload files/ directly, no build needed.
|
|
595
685
|
result = await deployService.deployStatic(filesDir, { title });
|
|
596
686
|
}
|
|
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
687
|
else {
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
688
|
+
const appDir = await resolveDeployableAppDir({
|
|
689
|
+
projectPath: args.projectPath,
|
|
690
|
+
variant: args.variant,
|
|
691
|
+
});
|
|
692
|
+
if (!appDir) {
|
|
693
|
+
return {
|
|
694
|
+
ok: false,
|
|
695
|
+
status: 422,
|
|
696
|
+
errorCode: 'RUNTIME_VALIDATION_FAILED',
|
|
697
|
+
message: UNSUPPORTED_PROTOTYPE_DEPLOY_MESSAGE,
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
result = await deployService.deploy(appDir, { title });
|
|
609
701
|
}
|
|
610
702
|
const deployment = {
|
|
611
703
|
deployId: result.deployId,
|
|
@@ -646,13 +738,37 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
646
738
|
});
|
|
647
739
|
return;
|
|
648
740
|
}
|
|
741
|
+
// Resolve a variant target that points at an HTML-only static preview:
|
|
742
|
+
// those requests fork through the refine flow rather than code-gen (a
|
|
743
|
+
// static preview has no worktree to edit). Gate on the TRUE work-item kind
|
|
744
|
+
// — never on HTML presence or the client's claim: an existing-project
|
|
745
|
+
// `code_gen` variant materialized as a static preview serves HTML and
|
|
746
|
+
// displays as `static_artifact`, but owns a worktree and MUST fork via the
|
|
747
|
+
// code_gen path (the static fork would reject it with VARIANT_NOT_EDITABLE).
|
|
748
|
+
const batchTarget = parsed.data.target;
|
|
749
|
+
const claimedStaticTarget = parsed.data.staticPreviewTarget ??
|
|
750
|
+
(batchTarget
|
|
751
|
+
? {
|
|
752
|
+
kind: 'static_preview',
|
|
753
|
+
sessionId: batchTarget.sessionId,
|
|
754
|
+
variantId: batchTarget.variantId,
|
|
755
|
+
}
|
|
756
|
+
: undefined);
|
|
757
|
+
const staticPreviewTarget = claimedStaticTarget &&
|
|
758
|
+
orchestrator.getVariantWorkItemKind(claimedStaticTarget.sessionId, claimedStaticTarget.variantId) === 'static_preview'
|
|
759
|
+
? claimedStaticTarget
|
|
760
|
+
: undefined;
|
|
649
761
|
const request = {
|
|
650
762
|
changes: parsed.data.changes,
|
|
651
763
|
sourceFiles: parsed.data.sourceFiles ?? [],
|
|
764
|
+
target: batchTarget,
|
|
765
|
+
staticPreviewTarget,
|
|
652
766
|
telemetryContext: parsed.data.telemetryContext,
|
|
653
767
|
traceId: parsed.data.traceId,
|
|
654
768
|
agentRunId: parsed.data.agentRunId,
|
|
769
|
+
initiator: parsed.data.initiator,
|
|
655
770
|
};
|
|
771
|
+
bridge?.updateTelemetryContext(request.telemetryContext);
|
|
656
772
|
if ((0, changeBatchClassification_1.isMixedVariantBatch)(request) || !(0, changeBatchClassification_1.isSingleVariantRequestBatch)(request)) {
|
|
657
773
|
res.status(400).json({
|
|
658
774
|
error: 'Invalid inline variants batch',
|
|
@@ -662,18 +778,63 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
662
778
|
return;
|
|
663
779
|
}
|
|
664
780
|
const activeVariantsSession = orchestrator.buildActiveSnapshot();
|
|
665
|
-
|
|
666
|
-
|
|
781
|
+
// A targeted request attaches to the active session as a new concurrent
|
|
782
|
+
// run — allowed while a session is live, but only against the CURRENTLY
|
|
783
|
+
// active session (mirrors the queue-changes intake guards).
|
|
784
|
+
const effectiveTarget = batchTarget ?? staticPreviewTarget;
|
|
785
|
+
if (effectiveTarget &&
|
|
786
|
+
activeVariantsSession.active === true &&
|
|
787
|
+
effectiveTarget.sessionId !== activeVariantsSession.sessionId) {
|
|
788
|
+
res.status(400).json({
|
|
789
|
+
error: 'Stale variant target',
|
|
790
|
+
details: 'The targeted variants session is not the active one. Refresh the editor and retry.',
|
|
791
|
+
reason: 'stale_target',
|
|
792
|
+
});
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
if (!effectiveTarget &&
|
|
796
|
+
(0, variantSessionStart_1.isVariantSessionStartBlocked)(activeVariantsSession)) {
|
|
797
|
+
const stage = activeVariantsSession.active === true
|
|
798
|
+
? activeVariantsSession.stage
|
|
799
|
+
: undefined;
|
|
800
|
+
const sessionId = activeVariantsSession.active === true
|
|
801
|
+
? activeVariantsSession.sessionId
|
|
802
|
+
: undefined;
|
|
667
803
|
res.status(400).json({
|
|
668
804
|
error: 'Variants session already active',
|
|
669
|
-
|
|
805
|
+
// Name the blocker so callers are not flying blind, and never
|
|
806
|
+
// recommend cancel as remediation: cancelling to unblock destroys
|
|
807
|
+
// the user's in-progress work. Only a human should decide that.
|
|
808
|
+
details: `A variants session is active${sessionId
|
|
809
|
+
? ` (session ${sessionId}${stage ? `, stage ${stage}` : ''})`
|
|
810
|
+
: ''}. Wait for it to settle (poll status), target it with --target to refine it, or ask the user before cancelling anything.`,
|
|
670
811
|
reason: 'active_session',
|
|
671
812
|
});
|
|
672
813
|
return;
|
|
673
814
|
}
|
|
674
|
-
|
|
815
|
+
if (!effectiveTarget && inlineStartTracker.isStarting()) {
|
|
816
|
+
res.status(400).json({
|
|
817
|
+
error: 'Variants start already in progress',
|
|
818
|
+
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.',
|
|
819
|
+
reason: 'start_in_flight',
|
|
820
|
+
});
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
if (!effectiveTarget) {
|
|
824
|
+
inlineStartTracker.begin();
|
|
825
|
+
}
|
|
675
826
|
try {
|
|
676
|
-
const
|
|
827
|
+
const isStaticPreviewFork = Boolean(staticPreviewTarget);
|
|
828
|
+
if (isStaticPreviewFork && !variantRunService.refineStaticPreviewBatch) {
|
|
829
|
+
res.status(503).json({
|
|
830
|
+
error: 'Static preview refinement unavailable',
|
|
831
|
+
reason: 'inline_variants_unavailable',
|
|
832
|
+
});
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
const result = isStaticPreviewFork
|
|
836
|
+
? await variantRunService.refineStaticPreviewBatch(request)
|
|
837
|
+
: await variantRunService.startElementVariants(request);
|
|
677
838
|
if (!result.success) {
|
|
678
839
|
res.status(500).json({
|
|
679
840
|
error: result.error ?? 'Inline variants run failed',
|
|
@@ -691,13 +852,62 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
691
852
|
});
|
|
692
853
|
}
|
|
693
854
|
finally {
|
|
694
|
-
|
|
855
|
+
if (!effectiveTarget) {
|
|
856
|
+
inlineStartTracker.end();
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
});
|
|
860
|
+
router.post('/variants/:sessionId/work/:workItemId/complete', async (req, res) => {
|
|
861
|
+
if (rejectNonLocalRequest(req, res))
|
|
862
|
+
return;
|
|
863
|
+
if (!variantRunService) {
|
|
864
|
+
res.status(503).json({
|
|
865
|
+
error: 'Variants unavailable',
|
|
866
|
+
reason: 'variants_unavailable',
|
|
867
|
+
});
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
const parsed = hostVariantCompleteBody.safeParse(req.body);
|
|
871
|
+
if (!parsed.success) {
|
|
872
|
+
res.status(400).json({
|
|
873
|
+
error: 'Invalid host work completion payload',
|
|
874
|
+
details: parsed.error.flatten(),
|
|
875
|
+
});
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
try {
|
|
879
|
+
const result = await variantRunService.completeHostWork({
|
|
880
|
+
sessionId: req.params.sessionId,
|
|
881
|
+
workItemId: req.params.workItemId,
|
|
882
|
+
status: parsed.data.status,
|
|
883
|
+
...(parsed.data.output !== undefined
|
|
884
|
+
? { output: parsed.data.output }
|
|
885
|
+
: {}),
|
|
886
|
+
...(parsed.data.error ? { error: parsed.data.error } : {}),
|
|
887
|
+
...(parsed.data.title ? { title: parsed.data.title } : {}),
|
|
888
|
+
...(parsed.data.description
|
|
889
|
+
? { description: parsed.data.description }
|
|
890
|
+
: {}),
|
|
891
|
+
});
|
|
892
|
+
res.status(200).json(result);
|
|
893
|
+
}
|
|
894
|
+
catch (err) {
|
|
895
|
+
const status = err instanceof agent_variants_1.AgentVariantsError ? 400 : 500;
|
|
896
|
+
res.status(status).json({
|
|
897
|
+
error: err instanceof Error ? err.message : 'Host work completion failed',
|
|
898
|
+
reason: err instanceof agent_variants_1.AgentVariantsError
|
|
899
|
+
? err.code
|
|
900
|
+
: 'host_work_completion_failed',
|
|
901
|
+
});
|
|
695
902
|
}
|
|
696
903
|
});
|
|
697
904
|
router.get('/variants/active', (req, res) => {
|
|
698
905
|
if (rejectNonLocalRequest(req, res))
|
|
699
906
|
return;
|
|
700
|
-
res.json(stampLiveness(
|
|
907
|
+
res.json(stampLiveness({
|
|
908
|
+
...orchestrator.buildActiveSnapshot(),
|
|
909
|
+
starting: inlineStartTracker.isStarting(),
|
|
910
|
+
}));
|
|
701
911
|
});
|
|
702
912
|
/**
|
|
703
913
|
* Server-Sent Events stream for the iframe chip. Pushes a fresh
|
|
@@ -725,7 +935,13 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
725
935
|
// so the initial state and every subscribed update carry them.
|
|
726
936
|
const writeSnapshot = (snapshot) => {
|
|
727
937
|
try {
|
|
728
|
-
|
|
938
|
+
const activeSnapshot = snapshot && typeof snapshot === 'object'
|
|
939
|
+
? {
|
|
940
|
+
...snapshot,
|
|
941
|
+
starting: inlineStartTracker.isStarting(),
|
|
942
|
+
}
|
|
943
|
+
: snapshot;
|
|
944
|
+
res.write(`data: ${JSON.stringify(stampLiveness(activeSnapshot))}\n\n`);
|
|
729
945
|
}
|
|
730
946
|
catch (err) {
|
|
731
947
|
log.warn('SSE write failed (client likely disconnected)', err);
|
|
@@ -748,6 +964,7 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
748
964
|
const releaseUiClient = orchestrator.registerUiClient();
|
|
749
965
|
const heartbeat = setInterval(() => {
|
|
750
966
|
try {
|
|
967
|
+
touchActiveVariantSession();
|
|
751
968
|
res.write(': heartbeat\n\n');
|
|
752
969
|
}
|
|
753
970
|
catch {
|
|
@@ -799,7 +1016,11 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
799
1016
|
return;
|
|
800
1017
|
}
|
|
801
1018
|
try {
|
|
802
|
-
const entries = (await Promise.all(resolveHistoryProjectPaths({ projectPath }).map((historyProjectPath) =>
|
|
1019
|
+
const entries = (await Promise.all(resolveHistoryProjectPaths({ projectPath }).map((historyProjectPath) =>
|
|
1020
|
+
// Reads the SQLite metadata index when it's usable and falls
|
|
1021
|
+
// back to the manifest walk otherwise — same entries, faster
|
|
1022
|
+
// list. Detail/preview routes stay manifest/file-backed.
|
|
1023
|
+
variantHistory.listVariantsFromIndex({
|
|
803
1024
|
projectPath: historyProjectPath,
|
|
804
1025
|
status: statusParam,
|
|
805
1026
|
})))).flat();
|
|
@@ -827,6 +1048,7 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
827
1048
|
runLabel: entry.manifest.runLabel ??
|
|
828
1049
|
(0, runLabel_1.deriveRunLabel)(entry.manifest.sessionPrompt),
|
|
829
1050
|
kind: manifestKind(entry.manifest),
|
|
1051
|
+
projectKind: entry.manifest.projectKind,
|
|
830
1052
|
status: entry.manifest.status,
|
|
831
1053
|
createdAt: entry.manifest.createdAt,
|
|
832
1054
|
statusChangedAt: entry.manifest.statusChangedAt,
|
|
@@ -834,6 +1056,7 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
834
1056
|
hasStaticPreview: entry.hasStaticPreview,
|
|
835
1057
|
preview: entry.manifest.preview,
|
|
836
1058
|
artifact: entry.manifest.artifact,
|
|
1059
|
+
parentVariant: entry.manifest.parentVariant,
|
|
837
1060
|
// Tree-store fields (absent on legacy entries): `serve` tells the
|
|
838
1061
|
// panel how a tree-backed entry previews (static → history preview
|
|
839
1062
|
// route; dev-server → the replay run route), `hasTree` marks the
|
|
@@ -850,23 +1073,29 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
850
1073
|
// Mirror the live static route's split: the HTML document and its sibling
|
|
851
1074
|
// assets are served by separate handlers, so the preview CSP is attached
|
|
852
1075
|
// 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 }));
|
|
1076
|
+
router.get('/variants/history/:sessionId/:variantId/preview', async (req, res) => serveHistoryPreview(req, res, variantHistory, resolveProjectPath, resolveHistoryProjectPaths, { isDocument: true }, previewBridge));
|
|
854
1077
|
router.get('/variants/history/:sessionId/:variantId/preview/{*assetPath}', async (req, res) => serveHistoryPreview(req, res, variantHistory, resolveProjectPath, resolveHistoryProjectPaths, { isDocument: false }));
|
|
855
|
-
// Stop
|
|
1078
|
+
// Stop history replay servers. Registered before the
|
|
856
1079
|
// parameterized history routes purely for clarity — method+arity keep it
|
|
857
1080
|
// unambiguous either way.
|
|
858
1081
|
router.post('/variants/history/replay/stop', async (req, res) => {
|
|
859
1082
|
if (rejectNonLocalRequest(req, res))
|
|
860
1083
|
return;
|
|
861
|
-
|
|
1084
|
+
const sessionId = typeof req.query.sessionId === 'string' ? req.query.sessionId : null;
|
|
1085
|
+
const variantId = typeof req.query.variantId === 'string' ? req.query.variantId : null;
|
|
1086
|
+
if (sessionId && variantId) {
|
|
1087
|
+
await historyReplay.stop({ sessionId, variantId });
|
|
1088
|
+
}
|
|
1089
|
+
else {
|
|
1090
|
+
await historyReplay.stop();
|
|
1091
|
+
}
|
|
862
1092
|
res.json({ stopped: true });
|
|
863
1093
|
});
|
|
864
1094
|
/**
|
|
865
1095
|
* Boot a past dev-server variant from its tree-store ref: materialize the
|
|
866
1096
|
* 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.
|
|
1097
|
+
* serve recipe, and optionally retarget the main preview proxy at the new
|
|
1098
|
+
* port. See docs/variant-history-tree-store-design.md.
|
|
870
1099
|
*/
|
|
871
1100
|
router.post('/variants/history/:sessionId/:variantId/run', async (req, res) => {
|
|
872
1101
|
if (rejectNonLocalRequest(req, res))
|
|
@@ -898,6 +1127,7 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
898
1127
|
projectPath: found.projectPath,
|
|
899
1128
|
sessionId,
|
|
900
1129
|
variantId,
|
|
1130
|
+
retargetProxy: req.query.targetAddressed !== '1',
|
|
901
1131
|
});
|
|
902
1132
|
res.json(result);
|
|
903
1133
|
}
|
|
@@ -991,6 +1221,7 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
991
1221
|
});
|
|
992
1222
|
return;
|
|
993
1223
|
}
|
|
1224
|
+
touchVariantSession(sessionId);
|
|
994
1225
|
try {
|
|
995
1226
|
if (!parsed.data.variantId) {
|
|
996
1227
|
variantsTelemetry?.trackAgentVariantsPreviewSwitchStarted({
|
|
@@ -1229,20 +1460,29 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
|
|
|
1229
1460
|
res.redirect(301, req.originalUrl + '/');
|
|
1230
1461
|
return;
|
|
1231
1462
|
}
|
|
1232
|
-
const
|
|
1463
|
+
const withBaseHref = hasAssets
|
|
1233
1464
|
? injectBaseHref(html,
|
|
1234
1465
|
// Trailing slash is required so `./avatar.glb` resolves to
|
|
1235
1466
|
// `.../static/<vid>/avatar.glb`, not `.../static/avatar.glb`.
|
|
1236
1467
|
`/api/variants/${encodeURIComponent(sessionId)}/static/${encodeURIComponent(variantId)}/`)
|
|
1237
1468
|
: html;
|
|
1469
|
+
// In embedded mode the visual editor drives this iframe over the preview
|
|
1470
|
+
// bridge; without the injected listener, selecting/commenting on the
|
|
1471
|
+
// variant times out (`Preview bridge timed out`) and the comment input
|
|
1472
|
+
// never opens. Mirror the base static route (`routes/static.ts`).
|
|
1473
|
+
const finalHtml = previewBridge?.isEnabled
|
|
1474
|
+
? (0, preview_bridge_1.injectPreviewBridge)(withBaseHref, {
|
|
1475
|
+
expectedParentOrigin: previewBridge.expectedParentOrigin,
|
|
1476
|
+
})
|
|
1477
|
+
: withBaseHref;
|
|
1238
1478
|
// Constrain the blast radius of agent-generated scripts. See
|
|
1239
|
-
//
|
|
1479
|
+
// buildStaticPreviewCsp for the policy and the isolated-origin migration
|
|
1240
1480
|
// that will eventually let us drop the per-CDN allowlist.
|
|
1241
1481
|
res
|
|
1242
1482
|
.status(200)
|
|
1243
1483
|
.type('html')
|
|
1244
1484
|
.set('Cache-Control', 'no-store')
|
|
1245
|
-
.set('Content-Security-Policy',
|
|
1485
|
+
.set('Content-Security-Policy', buildStaticPreviewCsp(previewBridge?.expectedParentOrigin))
|
|
1246
1486
|
.set('X-Content-Type-Options', 'nosniff')
|
|
1247
1487
|
.send(finalHtml);
|
|
1248
1488
|
}
|
|
@@ -1828,7 +2068,7 @@ exports.createAgentVariantsRouter = createAgentVariantsRouter;
|
|
|
1828
2068
|
* preview CSP; sibling assets (css/js/images) carry none, since a CSP header is
|
|
1829
2069
|
* only load-bearing on the document that fetches sub-resources.
|
|
1830
2070
|
*/
|
|
1831
|
-
const serveHistoryPreview = async (req, res, variantHistory, resolveProjectPath, resolveHistoryProjectPaths, { isDocument }) => {
|
|
2071
|
+
const serveHistoryPreview = async (req, res, variantHistory, resolveProjectPath, resolveHistoryProjectPaths, { isDocument }, previewBridge) => {
|
|
1832
2072
|
if (rejectNonLocalRequest(req, res))
|
|
1833
2073
|
return;
|
|
1834
2074
|
const invalidRawAssetPath = getInvalidRawHistoryPreviewAssetPath(req);
|
|
@@ -1891,8 +2131,17 @@ const serveHistoryPreview = async (req, res, variantHistory, resolveProjectPath,
|
|
|
1891
2131
|
// blanking out where the live preview rendered.
|
|
1892
2132
|
if (isDocument) {
|
|
1893
2133
|
res
|
|
1894
|
-
.set('Content-Security-Policy',
|
|
2134
|
+
.set('Content-Security-Policy', buildStaticPreviewCsp(previewBridge?.expectedParentOrigin))
|
|
1895
2135
|
.set('X-Content-Type-Options', 'nosniff');
|
|
2136
|
+
// Embedded mode drives this snapshot iframe over the preview bridge; the
|
|
2137
|
+
// listener must be present or selecting/commenting on a past variant
|
|
2138
|
+
// times out (`Preview bridge timed out`). Matches the live static route.
|
|
2139
|
+
if (previewBridge?.isEnabled) {
|
|
2140
|
+
res.send((0, preview_bridge_1.injectPreviewBridge)(file.body.toString('utf8'), {
|
|
2141
|
+
expectedParentOrigin: previewBridge.expectedParentOrigin,
|
|
2142
|
+
}));
|
|
2143
|
+
return;
|
|
2144
|
+
}
|
|
1896
2145
|
}
|
|
1897
2146
|
res.send(file.body);
|
|
1898
2147
|
}
|
|
@@ -1932,9 +2181,23 @@ const getInvalidRawHistoryPreviewAssetPath = (req) => {
|
|
|
1932
2181
|
}
|
|
1933
2182
|
return null;
|
|
1934
2183
|
};
|
|
2184
|
+
/**
|
|
2185
|
+
* Resolve a child path while rejecting paths that escape the intended root.
|
|
2186
|
+
*/
|
|
2187
|
+
const resolvePathWithinRoot = (rootPath, childPath) => {
|
|
2188
|
+
const absolutePath = path_1.default.resolve(rootPath, childPath);
|
|
2189
|
+
const relativePath = path_1.default.relative(rootPath, absolutePath);
|
|
2190
|
+
if (relativePath === '' ||
|
|
2191
|
+
(relativePath.length > 0 &&
|
|
2192
|
+
!relativePath.startsWith('..') &&
|
|
2193
|
+
!path_1.default.isAbsolute(relativePath))) {
|
|
2194
|
+
return absolutePath;
|
|
2195
|
+
}
|
|
2196
|
+
return null;
|
|
2197
|
+
};
|
|
1935
2198
|
function rejectNonLocalRequest(req, res) {
|
|
1936
2199
|
const remoteAddress = req.socket.remoteAddress;
|
|
1937
|
-
if (isLoopbackAddress(remoteAddress))
|
|
2200
|
+
if ((0, loopback_1.isLoopbackAddress)(remoteAddress))
|
|
1938
2201
|
return false;
|
|
1939
2202
|
res.status(403).json({
|
|
1940
2203
|
errorCode: 'RUNTIME_VALIDATION_FAILED',
|
|
@@ -1942,13 +2205,6 @@ function rejectNonLocalRequest(req, res) {
|
|
|
1942
2205
|
});
|
|
1943
2206
|
return true;
|
|
1944
2207
|
}
|
|
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
2208
|
function stateForSession(orchestrator, sessionId) {
|
|
1953
2209
|
const stage = orchestrator.getStage(sessionId);
|
|
1954
2210
|
const briefs = orchestrator.getBriefs(sessionId);
|