rivet-design 0.23.1 → 0.24.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/dist/agent-variants/SessionStore.d.ts +6 -0
- package/dist/agent-variants/SessionStore.d.ts.map +1 -1
- package/dist/agent-variants/SessionStore.js +21 -4
- package/dist/agent-variants/SessionStore.js.map +1 -1
- package/dist/agent-variants/WorkerExecutorService.d.ts.map +1 -1
- package/dist/agent-variants/WorkerExecutorService.js +37 -10
- package/dist/agent-variants/WorkerExecutorService.js.map +1 -1
- package/dist/agent-variants/WorktreeOrchestrator.d.ts +3 -32
- package/dist/agent-variants/WorktreeOrchestrator.d.ts.map +1 -1
- package/dist/agent-variants/WorktreeOrchestrator.js +9 -0
- package/dist/agent-variants/WorktreeOrchestrator.js.map +1 -1
- package/dist/agent-variants/contracts.d.ts +290 -288
- package/dist/agent-variants/contracts.d.ts.map +1 -1
- package/dist/agent-variants/contracts.js.map +1 -1
- package/dist/agent-variants/staticPreviewRefinements.d.ts +2 -0
- package/dist/agent-variants/staticPreviewRefinements.d.ts.map +1 -1
- package/dist/agent-variants/staticPreviewRefinements.js +3 -0
- package/dist/agent-variants/staticPreviewRefinements.js.map +1 -1
- package/dist/agent-variants/variant-start-types.d.ts +38 -0
- package/dist/agent-variants/variant-start-types.d.ts.map +1 -0
- package/dist/agent-variants/variant-start-types.js +3 -0
- package/dist/agent-variants/variant-start-types.js.map +1 -0
- package/dist/agent-variants/videoKeyframes.d.ts.map +1 -1
- package/dist/agent-variants/videoKeyframes.js +3 -2
- package/dist/agent-variants/videoKeyframes.js.map +1 -1
- package/dist/agent-variants/workItemBriefing.d.ts +1 -0
- package/dist/agent-variants/workItemBriefing.d.ts.map +1 -1
- package/dist/agent-variants/workItemBriefing.js +20 -6
- package/dist/agent-variants/workItemBriefing.js.map +1 -1
- package/dist/agent-variants/workItemInput.d.ts +196 -186
- package/dist/agent-variants/workItemInput.d.ts.map +1 -1
- package/dist/agent-variants/workItemInput.js +1 -0
- package/dist/agent-variants/workItemInput.js.map +1 -1
- package/dist/agent-variants/workerRuntime.d.ts +8 -1
- package/dist/agent-variants/workerRuntime.d.ts.map +1 -1
- package/dist/agent-variants/workerRuntime.js +59 -40
- package/dist/agent-variants/workerRuntime.js.map +1 -1
- package/dist/cli/browser.d.ts.map +1 -1
- package/dist/cli/browser.js +5 -3
- package/dist/cli/browser.js.map +1 -1
- package/dist/cli/client.d.ts.map +1 -1
- package/dist/cli/client.js +23 -3
- package/dist/cli/client.js.map +1 -1
- package/dist/cli/commands/context.d.ts.map +1 -1
- package/dist/cli/commands/context.js +10 -35
- package/dist/cli/commands/context.js.map +1 -1
- package/dist/cli/commands/contextRequest.d.ts +1 -0
- package/dist/cli/commands/contextRequest.d.ts.map +1 -1
- package/dist/cli/commands/contextRequest.js +8 -1
- package/dist/cli/commands/contextRequest.js.map +1 -1
- package/dist/cli/commands/contextVerification.d.ts +12 -0
- package/dist/cli/commands/contextVerification.d.ts.map +1 -0
- package/dist/cli/commands/contextVerification.js +48 -0
- package/dist/cli/commands/contextVerification.js.map +1 -0
- package/dist/cli/commands/guidanceReferences.d.ts +1 -1
- package/dist/cli/commands/mcpServe.d.ts +1 -3
- package/dist/cli/commands/mcpServe.d.ts.map +1 -1
- package/dist/cli/commands/mcpServe.js +21 -744
- package/dist/cli/commands/mcpServe.js.map +1 -1
- package/dist/cli/commands/open.d.ts.map +1 -1
- package/dist/cli/commands/open.js +2 -1
- package/dist/cli/commands/open.js.map +1 -1
- package/dist/cli/commands/profile.d.ts.map +1 -1
- package/dist/cli/commands/profile.js +2 -1
- package/dist/cli/commands/profile.js.map +1 -1
- package/dist/cli/commands/serve.d.ts.map +1 -1
- package/dist/cli/commands/serve.js +0 -2
- package/dist/cli/commands/serve.js.map +1 -1
- package/dist/cli/commands/shared.d.ts.map +1 -1
- package/dist/cli/commands/shared.js +5 -2
- package/dist/cli/commands/shared.js.map +1 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +4 -1
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/variants.d.ts.map +1 -1
- package/dist/cli/commands/variants.js +2 -1
- package/dist/cli/commands/variants.js.map +1 -1
- package/dist/cli/editorSession.d.ts +27 -0
- package/dist/cli/editorSession.d.ts.map +1 -0
- package/dist/cli/editorSession.js +50 -0
- package/dist/cli/editorSession.js.map +1 -0
- package/dist/cli/entry.d.ts.map +1 -1
- package/dist/cli/entry.js +2 -0
- package/dist/cli/entry.js.map +1 -1
- package/dist/cli/hostWorkNextAction.d.ts +3 -5
- package/dist/cli/hostWorkNextAction.d.ts.map +1 -1
- package/dist/cli/hostWorkNextAction.js +7 -23
- package/dist/cli/hostWorkNextAction.js.map +1 -1
- package/dist/cli/router.d.ts.map +1 -1
- package/dist/cli/router.js +4 -2
- package/dist/cli/router.js.map +1 -1
- package/dist/cli/serverHandshake.d.ts +1 -0
- package/dist/cli/serverHandshake.d.ts.map +1 -1
- package/dist/cli/serverHandshake.js.map +1 -1
- package/dist/cli/serverUnavailable.d.ts +1 -1
- package/dist/cli/serverUnavailable.d.ts.map +1 -1
- package/dist/cli/serverUnavailable.js +1 -0
- package/dist/cli/serverUnavailable.js.map +1 -1
- package/dist/config/flags.d.ts +3 -0
- package/dist/config/flags.d.ts.map +1 -1
- package/dist/config/flags.js +1 -0
- package/dist/config/flags.js.map +1 -1
- package/dist/config/pluginMetrics.d.ts +2 -0
- package/dist/config/pluginMetrics.d.ts.map +1 -0
- package/dist/config/pluginMetrics.js +234 -0
- package/dist/config/pluginMetrics.js.map +1 -0
- package/dist/config/telemetryPolicy.d.ts +8 -0
- package/dist/config/telemetryPolicy.d.ts.map +1 -0
- package/dist/config/telemetryPolicy.js +25 -0
- package/dist/config/telemetryPolicy.js.map +1 -0
- package/dist/index-core.d.ts +0 -1
- package/dist/index-core.d.ts.map +1 -1
- package/dist/index-core.js +1 -3
- package/dist/index-core.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -15
- package/dist/index.js.map +1 -1
- package/dist/install/allowlists.d.ts.map +1 -1
- package/dist/install/allowlists.js +6 -1
- package/dist/install/allowlists.js.map +1 -1
- package/dist/install/automaticCliUpdate.d.ts.map +1 -1
- package/dist/install/automaticCliUpdate.js +9 -2
- package/dist/install/automaticCliUpdate.js.map +1 -1
- package/dist/install/channelCli.d.ts.map +1 -1
- package/dist/install/channelCli.js +2 -1
- package/dist/install/channelCli.js.map +1 -1
- package/dist/install/channelManager.d.ts.map +1 -1
- package/dist/install/channelManager.js +11 -6
- package/dist/install/channelManager.js.map +1 -1
- package/dist/install/globalBootstrap.d.ts.map +1 -1
- package/dist/install/globalBootstrap.js +5 -1
- package/dist/install/globalBootstrap.js.map +1 -1
- package/dist/install/harnesses.js +1 -1
- package/dist/install/mcpRegistration.d.ts.map +1 -1
- package/dist/install/mcpRegistration.js +7 -4
- package/dist/install/mcpRegistration.js.map +1 -1
- package/dist/library/HubClient.d.ts.map +1 -1
- package/dist/library/HubClient.js +25 -5
- package/dist/library/HubClient.js.map +1 -1
- package/dist/mcp/designContextTools.d.ts +3 -0
- package/dist/mcp/designContextTools.d.ts.map +1 -0
- package/dist/mcp/designContextTools.js +44 -0
- package/dist/mcp/designContextTools.js.map +1 -0
- package/dist/mcp/explorationSchema.d.ts +56 -0
- package/dist/mcp/explorationSchema.d.ts.map +1 -0
- package/dist/mcp/explorationSchema.js +123 -0
- package/dist/mcp/explorationSchema.js.map +1 -0
- package/dist/mcp/explorationTools.d.ts +3 -0
- package/dist/mcp/explorationTools.d.ts.map +1 -0
- package/dist/mcp/explorationTools.js +117 -0
- package/dist/mcp/explorationTools.js.map +1 -0
- package/dist/mcp/getExploration.d.ts +13 -0
- package/dist/mcp/getExploration.d.ts.map +1 -0
- package/dist/mcp/getExploration.js +130 -0
- package/dist/mcp/getExploration.js.map +1 -0
- package/dist/mcp/intentTool.d.ts +60 -0
- package/dist/mcp/intentTool.d.ts.map +1 -0
- package/dist/mcp/intentTool.js +57 -0
- package/dist/mcp/intentTool.js.map +1 -0
- package/dist/mcp/preferenceTools.d.ts +3 -0
- package/dist/mcp/preferenceTools.d.ts.map +1 -0
- package/dist/mcp/preferenceTools.js +164 -0
- package/dist/mcp/preferenceTools.js.map +1 -0
- package/dist/mcp/profileAccess.d.ts +4 -0
- package/dist/mcp/profileAccess.d.ts.map +1 -0
- package/dist/mcp/profileAccess.js +31 -0
- package/dist/mcp/profileAccess.js.map +1 -0
- package/dist/mcp/referenceTools.d.ts +3 -0
- package/dist/mcp/referenceTools.d.ts.map +1 -0
- package/dist/mcp/referenceTools.js +128 -0
- package/dist/mcp/referenceTools.js.map +1 -0
- package/dist/prototype-host.js +37 -2
- package/dist/prototype-host.js.map +1 -1
- package/dist/routes/agentVariants.d.ts.map +1 -1
- package/dist/routes/agentVariants.js +10 -36
- package/dist/routes/agentVariants.js.map +1 -1
- package/dist/routes/editorAccess.d.ts +3 -0
- package/dist/routes/editorAccess.d.ts.map +1 -0
- package/dist/routes/editorAccess.js +33 -0
- package/dist/routes/editorAccess.js.map +1 -0
- package/dist/routes/library/app.d.ts.map +1 -1
- package/dist/routes/library/app.js +2 -0
- package/dist/routes/library/app.js.map +1 -1
- package/dist/routes/library/index.d.ts.map +1 -1
- package/dist/routes/library/index.js +2 -0
- package/dist/routes/library/index.js.map +1 -1
- package/dist/routes/shareAvailability.d.ts +8 -0
- package/dist/routes/shareAvailability.d.ts.map +1 -0
- package/dist/routes/shareAvailability.js +25 -0
- package/dist/routes/shareAvailability.js.map +1 -0
- package/dist/routes/telemetry.d.ts +4 -0
- package/dist/routes/telemetry.d.ts.map +1 -0
- package/dist/routes/telemetry.js +60 -0
- package/dist/routes/telemetry.js.map +1 -0
- package/dist/routes/variantRequestSchema.d.ts +33 -4
- package/dist/routes/variantRequestSchema.d.ts.map +1 -1
- package/dist/routes/variantRequestSchema.js +13 -1
- package/dist/routes/variantRequestSchema.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +230 -127
- package/dist/server.js.map +1 -1
- package/dist/services/CliLogForwarder.js +2 -1
- package/dist/services/CliLogForwarder.js.map +1 -1
- package/dist/services/ConfigManager.d.ts +7 -0
- package/dist/services/ConfigManager.d.ts.map +1 -1
- package/dist/services/ConfigManager.js +31 -24
- package/dist/services/ConfigManager.js.map +1 -1
- package/dist/services/DependencyPreparationService.d.ts.map +1 -1
- package/dist/services/DependencyPreparationService.js +2 -1
- package/dist/services/DependencyPreparationService.js.map +1 -1
- package/dist/services/FeatureFlagService.d.ts.map +1 -1
- package/dist/services/FeatureFlagService.js +13 -2
- package/dist/services/FeatureFlagService.js.map +1 -1
- package/dist/services/GuidanceVerifierRunner.d.ts +0 -1
- package/dist/services/GuidanceVerifierRunner.d.ts.map +1 -1
- package/dist/services/GuidanceVerifierRunner.js +11 -22
- package/dist/services/GuidanceVerifierRunner.js.map +1 -1
- package/dist/services/IntegrationsClient.d.ts +3 -3
- package/dist/services/OperatingSystemServices.d.ts +1 -0
- package/dist/services/OperatingSystemServices.d.ts.map +1 -1
- package/dist/services/OperatingSystemServices.js +3 -2
- package/dist/services/OperatingSystemServices.js.map +1 -1
- package/dist/services/ProjectDetectionService.d.ts.map +1 -1
- package/dist/services/ProjectDetectionService.js +6 -4
- package/dist/services/ProjectDetectionService.js.map +1 -1
- package/dist/services/ProjectFolderPicker.d.ts.map +1 -1
- package/dist/services/ProjectFolderPicker.js +2 -0
- package/dist/services/ProjectFolderPicker.js.map +1 -1
- package/dist/services/ProjectLibrary.d.ts +2 -0
- package/dist/services/ProjectLibrary.d.ts.map +1 -1
- package/dist/services/ProjectLibrary.js +16 -6
- package/dist/services/ProjectLibrary.js.map +1 -1
- package/dist/services/ProjectRegistry.d.ts +3 -2
- package/dist/services/ProjectRegistry.d.ts.map +1 -1
- package/dist/services/ProjectRegistry.js +4 -0
- package/dist/services/ProjectRegistry.js.map +1 -1
- package/dist/services/PrototypeBuildService.d.ts.map +1 -1
- package/dist/services/PrototypeBuildService.js +2 -1
- package/dist/services/PrototypeBuildService.js.map +1 -1
- package/dist/services/StaticPreviewServer.d.ts.map +1 -1
- package/dist/services/StaticPreviewServer.js +2 -1
- package/dist/services/StaticPreviewServer.js.map +1 -1
- package/dist/services/TelemetryService.d.ts +3 -1
- package/dist/services/TelemetryService.d.ts.map +1 -1
- package/dist/services/TelemetryService.js +60 -21
- package/dist/services/TelemetryService.js.map +1 -1
- package/dist/services/TreeStore.d.ts.map +1 -1
- package/dist/services/TreeStore.js +7 -2
- package/dist/services/TreeStore.js.map +1 -1
- package/dist/services/VariantGenerationService.d.ts.map +1 -1
- package/dist/services/VariantGenerationService.js +6 -7
- package/dist/services/VariantGenerationService.js.map +1 -1
- package/dist/services/VariantRunService.d.ts.map +1 -1
- package/dist/services/VariantRunService.js +10 -6
- package/dist/services/VariantRunService.js.map +1 -1
- package/dist/services/WorktreeManager.d.ts.map +1 -1
- package/dist/services/WorktreeManager.js +9 -1
- package/dist/services/WorktreeManager.js.map +1 -1
- package/dist/services/packageManagerProcess.d.ts.map +1 -1
- package/dist/services/packageManagerProcess.js +3 -0
- package/dist/services/packageManagerProcess.js.map +1 -1
- package/dist/services/profiles/DesignProfiles.d.ts +286 -66
- package/dist/services/profiles/DesignProfiles.d.ts.map +1 -1
- package/dist/services/profiles/DesignProfiles.js +346 -91
- package/dist/services/profiles/DesignProfiles.js.map +1 -1
- package/dist/services/profiles/MemoryRuntime.d.ts.map +1 -1
- package/dist/services/profiles/MemoryRuntime.js +4 -6
- package/dist/services/profiles/MemoryRuntime.js.map +1 -1
- package/dist/services/profiles/ProfileAgent.d.ts.map +1 -1
- package/dist/services/profiles/ProfileAgent.js +4 -3
- package/dist/services/profiles/ProfileAgent.js.map +1 -1
- package/dist/services/profiles/ProfileImports.d.ts +2 -2
- package/dist/services/profiles/ProfilePlanning.d.ts +4 -4
- package/dist/services/profiles/ProfilePreparation.d.ts.map +1 -1
- package/dist/services/profiles/ProfilePreparation.js +1 -0
- package/dist/services/profiles/ProfilePreparation.js.map +1 -1
- package/dist/services/profiles/ProfileVariants.d.ts +1 -1
- package/dist/services/profiles/ProfileVariants.d.ts.map +1 -1
- package/dist/services/profiles/ProfileVariants.js +1 -1
- package/dist/services/profiles/ProfileVariants.js.map +1 -1
- package/dist/services/profiles/ReferenceReader.d.ts +3 -3
- package/dist/services/profiles/profileContext.d.ts +1 -1
- package/dist/services/stopRuntimeProcess.d.ts.map +1 -1
- package/dist/services/stopRuntimeProcess.js +2 -0
- package/dist/services/stopRuntimeProcess.js.map +1 -1
- package/dist/storage/library/BundleMetadataStore.d.ts +1 -0
- package/dist/storage/library/BundleMetadataStore.d.ts.map +1 -1
- package/dist/storage/library/BundleMetadataStore.js +17 -0
- package/dist/storage/library/BundleMetadataStore.js.map +1 -1
- package/dist/storage/library/ProjectPreviewCache.d.ts +2 -2
- package/dist/storage/library/ProjectRecords.d.ts +1 -0
- package/dist/storage/library/ProjectRecords.d.ts.map +1 -1
- package/dist/storage/library/ProjectRecords.js +7 -0
- package/dist/storage/library/ProjectRecords.js.map +1 -1
- package/dist/storage/library/database.d.ts +4 -0
- package/dist/storage/library/database.d.ts.map +1 -1
- package/dist/storage/library/database.js +18 -1
- package/dist/storage/library/database.js.map +1 -1
- package/dist/storage/profiles/ProfilePlans.d.ts +19 -18
- package/dist/storage/profiles/ProfilePlans.d.ts.map +1 -1
- package/dist/storage/profiles/ProfilePlans.js +5 -2
- package/dist/storage/profiles/ProfilePlans.js.map +1 -1
- package/dist/storage/profiles/ProfileRecords.d.ts +45 -14
- package/dist/storage/profiles/ProfileRecords.d.ts.map +1 -1
- package/dist/storage/profiles/ProfileRecords.js +59 -4
- package/dist/storage/profiles/ProfileRecords.js.map +1 -1
- package/dist/storage/profiles/planSchema.d.ts +5 -5
- package/dist/storage/profiles/schema.d.ts +8 -8
- package/dist/types/cosmos-profile.d.ts +6 -6
- package/dist/types/cosmos.d.ts +10 -10
- package/dist/types/design-profile.d.ts +32 -32
- package/dist/types/guidance-references.d.ts +20 -20
- package/dist/types/guidance.d.ts +144 -144
- package/dist/types/reference-connectors.d.ts +12 -12
- package/dist/types/reference-onboarding.d.ts +58 -58
- package/dist/types/reference-pages.d.ts +8 -8
- package/dist/types/variant-reference.d.ts +4 -4
- package/dist/types/x-bookmarks.d.ts +16 -16
- package/dist/utils/cloneOrCopyDirSync.d.ts.map +1 -1
- package/dist/utils/cloneOrCopyDirSync.js +2 -0
- package/dist/utils/cloneOrCopyDirSync.js.map +1 -1
- package/dist/utils/editorAccess.d.ts +8 -0
- package/dist/utils/editorAccess.d.ts.map +1 -0
- package/dist/utils/editorAccess.js +23 -0
- package/dist/utils/editorAccess.js.map +1 -0
- package/dist/utils/hostedLogPrivacy.d.ts +2 -0
- package/dist/utils/hostedLogPrivacy.d.ts.map +1 -0
- package/dist/utils/hostedLogPrivacy.js +29 -0
- package/dist/utils/hostedLogPrivacy.js.map +1 -0
- package/dist/utils/hostedLogging.d.ts +2 -0
- package/dist/utils/hostedLogging.d.ts.map +1 -0
- package/dist/utils/hostedLogging.js +18 -0
- package/dist/utils/hostedLogging.js.map +1 -0
- package/dist/utils/loginShellPath.d.ts.map +1 -1
- package/dist/utils/loginShellPath.js +2 -0
- package/dist/utils/loginShellPath.js.map +1 -1
- package/dist/utils/skills/claude-skill.d.ts +1 -1
- package/dist/utils/skills/claude-skill.js +1 -1
- package/dist/utils/skills/cli-guidance.d.ts +1 -1
- package/dist/utils/skills/cli-guidance.d.ts.map +1 -1
- package/dist/utils/skills/cli-guidance.js +56 -27
- package/dist/utils/skills/cli-guidance.js.map +1 -1
- package/dist/utils/skills/codex-skill.d.ts +1 -1
- package/dist/utils/skills/codex-skill.d.ts.map +1 -1
- package/dist/utils/skills/codex-skill.js +6 -2
- package/dist/utils/skills/codex-skill.js.map +1 -1
- package/dist/utils/skills/cursor-rules.d.ts +1 -1
- package/dist/utils/skills/cursor-rules.js +1 -1
- package/dist/utils/subprocessEnvironment.d.ts +6 -0
- package/dist/utils/subprocessEnvironment.d.ts.map +1 -0
- package/dist/utils/subprocessEnvironment.js +214 -0
- package/dist/utils/subprocessEnvironment.js.map +1 -0
- package/package.json +8 -4
- package/src/ui/dist/assets/{LibraryEntry-BUwOgHmJ.js → LibraryEntry-DS6EDW1V.js} +2 -2
- package/src/ui/dist/assets/main-CdH16hGP.js +435 -0
- package/src/ui/dist/index.html +1 -1
- package/dist/routes/git.d.ts +0 -5
- package/dist/routes/git.d.ts.map +0 -1
- package/dist/routes/git.js +0 -261
- package/dist/routes/git.js.map +0 -1
- package/dist/services/CommitMessageGenerator.d.ts +0 -7
- package/dist/services/CommitMessageGenerator.d.ts.map +0 -1
- package/dist/services/CommitMessageGenerator.js +0 -16
- package/dist/services/CommitMessageGenerator.js.map +0 -1
- package/dist/services/LocalGitService.d.ts +0 -61
- package/dist/services/LocalGitService.d.ts.map +0 -1
- package/dist/services/LocalGitService.js +0 -561
- package/dist/services/LocalGitService.js.map +0 -1
- package/dist/services/PRTitleGenerator.d.ts +0 -9
- package/dist/services/PRTitleGenerator.d.ts.map +0 -1
- package/dist/services/PRTitleGenerator.js +0 -36
- package/dist/services/PRTitleGenerator.js.map +0 -1
- package/dist/services/SessionService.d.ts +0 -38
- package/dist/services/SessionService.d.ts.map +0 -1
- package/dist/services/SessionService.js +0 -189
- package/dist/services/SessionService.js.map +0 -1
- package/dist/utils/branchNames.d.ts +0 -2
- package/dist/utils/branchNames.d.ts.map +0 -1
- package/dist/utils/branchNames.js +0 -92
- package/dist/utils/branchNames.js.map +0 -1
- package/dist/utils/hostAgentEnv.d.ts +0 -2
- package/dist/utils/hostAgentEnv.d.ts.map +0 -1
- package/dist/utils/hostAgentEnv.js +0 -15
- package/dist/utils/hostAgentEnv.js.map +0 -1
- package/src/ui/dist/assets/main-DQKavyjz.js +0 -435
package/dist/server.js
CHANGED
|
@@ -37,11 +37,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.startServer = exports.runServerShutdownTasks = exports.isRivetCorsOriginAllowed = exports.isRivetUiStaticAssetPath = exports.isEmbeddedAgentUiHost = exports.resolveEmbeddedAgentUiOrigin = exports.resolveRivetListenHost = exports.sendInactiveVariantsEventStream = exports.readRivetUiIndexHtml = exports.injectRivetUiBootstrap = exports.DIST_UI_PATH = exports.RIVET_CORS_ALLOWED_HEADERS = exports.INACTIVE_VARIANTS_EVENT_HEARTBEAT_MS = void 0;
|
|
40
|
+
const editorSession_1 = require("./cli/editorSession");
|
|
41
|
+
const editorAccess_1 = require("./routes/editorAccess");
|
|
42
|
+
const editorAccess_2 = require("./utils/editorAccess");
|
|
40
43
|
const RuntimeAdmission_1 = require("./services/RuntimeAdmission");
|
|
41
44
|
const account_1 = require("./routes/account");
|
|
42
45
|
const installRef_1 = require("./routes/installRef");
|
|
43
46
|
const installationChannel_1 = require("./install/installationChannel");
|
|
44
47
|
const Sentry = __importStar(require("@sentry/node"));
|
|
48
|
+
const telemetryPolicy_1 = require("./config/telemetryPolicy");
|
|
49
|
+
const telemetry_1 = require("./routes/telemetry");
|
|
45
50
|
const express_1 = __importDefault(require("express"));
|
|
46
51
|
const cors_1 = __importDefault(require("cors"));
|
|
47
52
|
const crypto_1 = require("crypto");
|
|
@@ -53,7 +58,6 @@ const _1 = require(".");
|
|
|
53
58
|
const integrations_1 = require("./routes/integrations");
|
|
54
59
|
const referenceProfiles_1 = require("./routes/referenceProfiles");
|
|
55
60
|
const WorktreeManager_1 = require("./services/WorktreeManager");
|
|
56
|
-
const git_1 = require("./routes/git");
|
|
57
61
|
const support_1 = require("./routes/support");
|
|
58
62
|
const proxy_config_1 = require("./proxy-middleware/proxy-config");
|
|
59
63
|
const StaticFileService_1 = require("./services/StaticFileService");
|
|
@@ -67,7 +71,7 @@ const cli_1 = require("./routes/cli");
|
|
|
67
71
|
const agentVariants_1 = require("./routes/agentVariants");
|
|
68
72
|
const inlineStartTracker_1 = require("./routes/inlineStartTracker");
|
|
69
73
|
const serverHandshake_1 = require("./cli/serverHandshake");
|
|
70
|
-
const
|
|
74
|
+
const telemetry_2 = require("./config/telemetry");
|
|
71
75
|
const HistoryReplayService_1 = require("./services/HistoryReplayService");
|
|
72
76
|
const VariantHistoryService_1 = require("./services/VariantHistoryService");
|
|
73
77
|
const RequestAuthContext_1 = require("./services/RequestAuthContext");
|
|
@@ -81,12 +85,13 @@ const RIVET_UI_INDEX_FILENAME = 'index.html';
|
|
|
81
85
|
const EMBEDDED_AGENT_LISTEN_HOST = '127.0.0.1';
|
|
82
86
|
const EMBEDDED_AGENT_PREVIEW_HOST = 'localhost';
|
|
83
87
|
const OPAQUE_PREVIEW_ORIGIN = 'null';
|
|
84
|
-
const PREVIEW_PORT_ALLOWED_API_RE = /^\/api\/variants\/(?:[^/]+\/static\/|history\/[^/]+\/[^/]+\/preview)/;
|
|
88
|
+
const PREVIEW_PORT_ALLOWED_API_RE = /^\/api\/variants\/(?:[^/]+\/static\/|history\/[^/]+\/[^/]+\/(?:preview|site\/))/;
|
|
85
89
|
exports.INACTIVE_VARIANTS_EVENT_HEARTBEAT_MS = 30_000;
|
|
86
90
|
exports.RIVET_CORS_ALLOWED_HEADERS = [
|
|
87
91
|
'Content-Type',
|
|
88
92
|
'Authorization',
|
|
89
93
|
'x-rivet-queue-token',
|
|
94
|
+
editorAccess_2.EDITOR_ACCESS_TOKEN_HEADER,
|
|
90
95
|
];
|
|
91
96
|
const resolveUiPath = () => {
|
|
92
97
|
const bundledPath = path_1.default.join(__dirname, 'ui/dist');
|
|
@@ -136,7 +141,7 @@ const sendInactiveVariantsEventStream = (req, res) => {
|
|
|
136
141
|
});
|
|
137
142
|
};
|
|
138
143
|
exports.sendInactiveVariantsEventStream = sendInactiveVariantsEventStream;
|
|
139
|
-
const resolveRivetListenHost = (
|
|
144
|
+
const resolveRivetListenHost = (_agentApplyMode) => EMBEDDED_AGENT_LISTEN_HOST;
|
|
140
145
|
exports.resolveRivetListenHost = resolveRivetListenHost;
|
|
141
146
|
const resolveEmbeddedAgentUiOrigin = (port) => `http://${EMBEDDED_AGENT_LISTEN_HOST}:${port}`;
|
|
142
147
|
exports.resolveEmbeddedAgentUiOrigin = resolveEmbeddedAgentUiOrigin;
|
|
@@ -198,16 +203,17 @@ exports.runServerShutdownTasks = runServerShutdownTasks;
|
|
|
198
203
|
const startServer = async (options) => {
|
|
199
204
|
const { userPort, userHost, telemetry, projectPath, framework, staticEntry, sessionBridge, mcpEditor, skipProcessHandlers, } = options;
|
|
200
205
|
const agentApplyMode = options.agentApplyMode;
|
|
206
|
+
const editorAccessToken = (0, editorSession_1.createEditorAccessToken)();
|
|
207
|
+
const startedAt = new Date().toISOString();
|
|
201
208
|
const userPortWithFallback = userPort ?? _1.DEFAULT_USER_PORT;
|
|
202
209
|
const userHostWithFallback = userHost ?? 'localhost';
|
|
203
210
|
const hasUserDevServer = typeof userPort === 'number' && Number.isInteger(userPort) && userPort > 0;
|
|
204
|
-
const isGitEnabled = options.isGitEnabled ?? true;
|
|
205
211
|
const queueAccessToken = sessionBridge && agentApplyMode === 'embedded'
|
|
206
212
|
? (0, crypto_1.randomBytes)(QUEUE_ACCESS_TOKEN_BYTES).toString('base64url')
|
|
207
213
|
: null;
|
|
208
214
|
const variantsOrchestrator = options.variantsRuntime?.orchestrator ?? options.agentVariantsOrchestrator;
|
|
209
215
|
const inlineStartTracker = (0, inlineStartTracker_1.createInlineStartTracker)();
|
|
210
|
-
const runtimeAdmission = new RuntimeAdmission_1.RuntimeAdmission(
|
|
216
|
+
const runtimeAdmission = new RuntimeAdmission_1.RuntimeAdmission(telemetry_2.RIVET_VERSION);
|
|
211
217
|
const variantsBridge = options.variantsRuntime?.bridge ?? sessionBridge;
|
|
212
218
|
const variantRunService = options.variantsRuntime?.runService ?? options.variantRunService;
|
|
213
219
|
const variantHistory = variantsOrchestrator
|
|
@@ -222,65 +228,41 @@ const startServer = async (options) => {
|
|
|
222
228
|
: undefined,
|
|
223
229
|
})
|
|
224
230
|
: null;
|
|
225
|
-
if (process.env.SENTRY_DSN) {
|
|
231
|
+
if (process.env.SENTRY_DSN && (0, telemetryPolicy_1.getTelemetryMode)() === 'full') {
|
|
226
232
|
Sentry.init({
|
|
227
233
|
dsn: process.env.SENTRY_DSN,
|
|
228
234
|
environment: process.env.NODE_ENV ?? 'development',
|
|
229
235
|
});
|
|
230
236
|
}
|
|
231
|
-
const sessionService = new index_core_1.SessionService(projectPath, isGitEnabled, 'main');
|
|
232
|
-
try {
|
|
233
|
-
await sessionService.initializeSession();
|
|
234
|
-
log.info('Git session initialized successfully');
|
|
235
|
-
}
|
|
236
|
-
catch (error) {
|
|
237
|
-
log.warn('Failed to initialize git session, continuing without git tracking:', error);
|
|
238
|
-
}
|
|
239
237
|
let staticService = null;
|
|
240
238
|
if (framework === 'static') {
|
|
241
239
|
const entryPoint = staticEntry || 'index.html';
|
|
242
240
|
staticService = new StaticFileService_1.StaticFileService(projectPath, entryPoint);
|
|
243
241
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
(0, WorktreeManager_1.cleanupOrphanedWorktrees)();
|
|
248
|
-
const results = await Promise.allSettled([
|
|
249
|
-
options.beforeShutdown?.(),
|
|
250
|
-
telemetry?.shutdown(),
|
|
251
|
-
(0, FeatureFlagService_1.getFeatureFlagService)().shutdown(),
|
|
252
|
-
]);
|
|
253
|
-
const labels = ['shutdown hook', 'telemetry', 'feature flags'];
|
|
254
|
-
for (let i = 0; i < results.length; i++) {
|
|
255
|
-
if (results[i].status === 'rejected') {
|
|
256
|
-
log.error(`Failed to cleanup ${labels[i]}:`, results[i].reason);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
(0, serverHandshake_1.removeHandshake)(projectPath, process.pid);
|
|
260
|
-
process.exit(code);
|
|
261
|
-
};
|
|
262
|
-
process.on('SIGINT', () => shutdownAndExit(0));
|
|
263
|
-
process.on('SIGTERM', () => shutdownAndExit(0));
|
|
264
|
-
process.on('uncaughtException', (err) => {
|
|
265
|
-
log.error('Uncaught exception:', err);
|
|
266
|
-
telemetry?.captureException(err, 'uncaught_exception');
|
|
267
|
-
shutdownAndExit(1);
|
|
268
|
-
});
|
|
269
|
-
process.on('unhandledRejection', (reason) => {
|
|
270
|
-
log.error('Unhandled rejection:', reason);
|
|
271
|
-
telemetry?.captureException(reason, 'unhandled_rejection');
|
|
272
|
-
shutdownAndExit(1);
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
const listenPort = options.rivetPort ?? _1.DEFAULT_PORT;
|
|
276
|
-
const previewPort = agentApplyMode === 'embedded' ? options.previewPort : undefined;
|
|
277
|
-
const previewOrigin = previewPort !== undefined
|
|
242
|
+
let listenPort = options.rivetPort ?? _1.DEFAULT_PORT;
|
|
243
|
+
const previewPort = options.previewPort;
|
|
244
|
+
let previewOrigin = previewPort !== undefined
|
|
278
245
|
? `http://${EMBEDDED_AGENT_LISTEN_HOST}:${previewPort}`
|
|
279
|
-
:
|
|
246
|
+
: `http://${EMBEDDED_AGENT_PREVIEW_HOST}:${listenPort}`;
|
|
247
|
+
let userDevProxy = null;
|
|
280
248
|
const app = (0, express_1.default)();
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
|
|
249
|
+
const requireEditorAccess = (0, editorAccess_1.authenticateEditor)(editorAccessToken);
|
|
250
|
+
app.use(editorAccess_2.EDITOR_ACCOUNT_PATHS, requireEditorAccess);
|
|
251
|
+
const editorHost = () => `${EMBEDDED_AGENT_LISTEN_HOST}:${listenPort}`;
|
|
252
|
+
const isPreviewRequest = (req) => req.headers.host === new URL(previewOrigin).host &&
|
|
253
|
+
(previewPort === undefined || req.socket.localPort === previewPort);
|
|
254
|
+
app.use((req, res, next) => {
|
|
255
|
+
const requestHost = req.headers.host;
|
|
256
|
+
const isEditorRequest = requestHost === editorHost() && req.socket.localPort === listenPort;
|
|
257
|
+
if (!isEditorRequest && !isPreviewRequest(req)) {
|
|
258
|
+
res.sendStatus(403);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
next();
|
|
262
|
+
});
|
|
263
|
+
const corsOrigins = new Set([
|
|
264
|
+
(0, exports.resolveEmbeddedAgentUiOrigin)(listenPort),
|
|
265
|
+
]);
|
|
284
266
|
const rawCorsOrigins = process.env.RIVET_CORS_ORIGINS;
|
|
285
267
|
if (rawCorsOrigins) {
|
|
286
268
|
rawCorsOrigins
|
|
@@ -305,22 +287,41 @@ const startServer = async (options) => {
|
|
|
305
287
|
allowedHeaders: exports.RIVET_CORS_ALLOWED_HEADERS,
|
|
306
288
|
})(req, res, next);
|
|
307
289
|
});
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
290
|
+
app.use((req, res, next) => {
|
|
291
|
+
if (!isPreviewRequest(req)) {
|
|
292
|
+
next();
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
if (req.headers[editorAccess_2.EDITOR_ACCESS_TOKEN_HEADER]) {
|
|
296
|
+
res.sendStatus(403);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
const isAppApi = req.path.toLowerCase().startsWith('/api/') &&
|
|
300
|
+
!PREVIEW_PORT_ALLOWED_API_RE.test(req.path.toLowerCase());
|
|
301
|
+
const isEditorUi = req.path.toLowerCase() === '/rivet' ||
|
|
302
|
+
req.path.toLowerCase().startsWith('/rivet/');
|
|
303
|
+
if (isEditorUi || /^\/api\/git(?:\/|$)/i.test(req.path)) {
|
|
304
|
+
res.status(404).end();
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
if (isAppApi) {
|
|
308
|
+
if (userDevProxy) {
|
|
309
|
+
userDevProxy.middleware(req, res, (error) => {
|
|
310
|
+
if (error) {
|
|
311
|
+
next(error);
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
res.sendStatus(404);
|
|
315
|
+
});
|
|
313
316
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
const isEditorUi = req.path === '/rivet' || req.path.startsWith('/rivet/');
|
|
317
|
-
if (isBlockedApi || isEditorUi) {
|
|
318
|
-
res.status(404).end();
|
|
319
|
-
return;
|
|
317
|
+
else {
|
|
318
|
+
res.sendStatus(404);
|
|
320
319
|
}
|
|
321
|
-
|
|
322
|
-
}
|
|
323
|
-
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
next();
|
|
323
|
+
});
|
|
324
|
+
app.use('/api/telemetry', (0, telemetry_1.createTelemetryRouter)(telemetry));
|
|
324
325
|
const jsonBodyParser = express_1.default.json({ limit: '50mb' });
|
|
325
326
|
app.use(jsonBodyParser);
|
|
326
327
|
app.use((req, res, next) => {
|
|
@@ -341,21 +342,27 @@ const startServer = async (options) => {
|
|
|
341
342
|
},
|
|
342
343
|
};
|
|
343
344
|
const sendRivetUiIndex = (req, res) => {
|
|
344
|
-
if (!(0, exports.isEmbeddedAgentUiHost)(req.hostname,
|
|
345
|
+
if (!(0, exports.isEmbeddedAgentUiHost)(req.hostname, 'embedded')) {
|
|
345
346
|
res.redirect(302, `${(0, exports.resolveEmbeddedAgentUiOrigin)(listenPort)}${req.originalUrl}`);
|
|
346
347
|
return;
|
|
347
348
|
}
|
|
348
349
|
setNoStoreHeaders(res);
|
|
350
|
+
const libraryOrigin = options.resolveLibraryOrigin?.();
|
|
351
|
+
res.setHeader('Content-Security-Policy', `frame-ancestors 'self'${libraryOrigin ? ` ${new URL(libraryOrigin).origin}` : ''}`);
|
|
349
352
|
res.type('html').send((0, exports.injectRivetUiBootstrap)((0, exports.readRivetUiIndexHtml)(), {
|
|
350
353
|
agentApplyMode: agentApplyMode ?? null,
|
|
351
354
|
queueAccessToken,
|
|
352
355
|
previewOrigin,
|
|
353
356
|
}));
|
|
354
357
|
};
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
358
|
+
const serveEditorAssets = (directory) => {
|
|
359
|
+
const serve = express_1.default.static(directory, uiStaticOptions);
|
|
360
|
+
return (req, res, next) => isPreviewRequest(req) ? next() : serve(req, res, next);
|
|
361
|
+
};
|
|
362
|
+
app.use('/assets', serveEditorAssets(path_1.default.join(exports.DIST_UI_PATH, 'assets')));
|
|
363
|
+
app.use('/rivet/assets', serveEditorAssets(path_1.default.join(exports.DIST_UI_PATH, 'assets')));
|
|
364
|
+
app.use('/fonts', serveEditorAssets(path_1.default.join(exports.DIST_UI_PATH, 'fonts')));
|
|
365
|
+
app.use('/rivet/fonts', serveEditorAssets(path_1.default.join(exports.DIST_UI_PATH, 'fonts')));
|
|
359
366
|
app.get('/favicon.ico', (_req, res) => {
|
|
360
367
|
res.sendFile('favicon.ico', { root: exports.DIST_UI_PATH });
|
|
361
368
|
});
|
|
@@ -371,7 +378,11 @@ const startServer = async (options) => {
|
|
|
371
378
|
});
|
|
372
379
|
log.info(`Serving UI assets from: ${exports.DIST_UI_PATH}`);
|
|
373
380
|
if (framework === 'static' && !hasUserDevServer) {
|
|
374
|
-
app.get('/', (req, res) => {
|
|
381
|
+
app.get('/', (req, res, next) => {
|
|
382
|
+
if (isPreviewRequest(req)) {
|
|
383
|
+
next();
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
375
386
|
log.debug(`${framework} mode - serving Rivet at root`);
|
|
376
387
|
sendRivetUiIndex(req, res);
|
|
377
388
|
});
|
|
@@ -410,19 +421,28 @@ const startServer = async (options) => {
|
|
|
410
421
|
app.use('/api', (0, integrations_1.createIntegrationsRouter)());
|
|
411
422
|
app.use('/api', (0, referenceProfiles_1.createReferenceProfilesRouter)());
|
|
412
423
|
void (0, WorktreeManager_1.pruneWorktrees)(projectPath);
|
|
413
|
-
|
|
414
|
-
log.info('Git routes disabled for this server instance');
|
|
415
|
-
}
|
|
416
|
-
app.use('/api', (0, git_1.createGitRouter)(sessionService, projectPath, {
|
|
417
|
-
isGitEnabled,
|
|
418
|
-
}));
|
|
424
|
+
app.use('/api/git', (_req, res) => res.sendStatus(404));
|
|
419
425
|
app.use('/api', (0, support_1.createSupportRouter)(telemetry));
|
|
426
|
+
app.use((req, res, next) => {
|
|
427
|
+
const isPreviewPath = req.path.toLowerCase().startsWith('/static') ||
|
|
428
|
+
req.path.toLowerCase().startsWith('/__rivet/preview/') ||
|
|
429
|
+
PREVIEW_PORT_ALLOWED_API_RE.test(req.path.toLowerCase());
|
|
430
|
+
if (!isPreviewRequest(req) && isPreviewPath) {
|
|
431
|
+
if (req.headers[editorAccess_2.EDITOR_ACCESS_TOKEN_HEADER]) {
|
|
432
|
+
res.sendStatus(403);
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
res.redirect(302, `${previewOrigin}${req.originalUrl}`);
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
next();
|
|
439
|
+
});
|
|
420
440
|
if (staticService) {
|
|
421
441
|
app.use((0, static_1.createStaticRoutes)(staticService, projectPath, {
|
|
422
|
-
isPreviewBridgeEnabled:
|
|
423
|
-
expectedPreviewParentOrigin
|
|
424
|
-
|
|
425
|
-
|
|
442
|
+
isPreviewBridgeEnabled: true,
|
|
443
|
+
get expectedPreviewParentOrigin() {
|
|
444
|
+
return (0, exports.resolveEmbeddedAgentUiOrigin)(listenPort);
|
|
445
|
+
},
|
|
426
446
|
}));
|
|
427
447
|
log.info('Static routes mounted at /static');
|
|
428
448
|
}
|
|
@@ -441,8 +461,9 @@ const startServer = async (options) => {
|
|
|
441
461
|
projectPath,
|
|
442
462
|
pid: process.pid,
|
|
443
463
|
channel: (0, installationChannel_1.installationChannel)(),
|
|
444
|
-
rivetVersion:
|
|
464
|
+
rivetVersion: telemetry_2.RIVET_VERSION,
|
|
445
465
|
pluginName: (0, pluginContext_1.getPluginName)(),
|
|
466
|
+
telemetryMode: (0, telemetryPolicy_1.getTelemetryMode)(),
|
|
446
467
|
timestamp: new Date().toISOString(),
|
|
447
468
|
framework,
|
|
448
469
|
ports: {
|
|
@@ -489,7 +510,7 @@ const startServer = async (options) => {
|
|
|
489
510
|
const url = await options.createLibraryViewUrl?.(view);
|
|
490
511
|
if (!url)
|
|
491
512
|
return res.sendStatus(503);
|
|
492
|
-
return res.
|
|
513
|
+
return res.json({ url });
|
|
493
514
|
}
|
|
494
515
|
catch (error) {
|
|
495
516
|
log.error('Could not open the project library', error);
|
|
@@ -518,11 +539,11 @@ const startServer = async (options) => {
|
|
|
518
539
|
}
|
|
519
540
|
if (variantsOrchestrator) {
|
|
520
541
|
app.use('/api', (0, agentVariants_1.createAgentVariantsRouter)(variantsOrchestrator, variantsBridge, telemetry, variantHistory ?? undefined, undefined, variantRunService, historyReplay ?? undefined, {
|
|
521
|
-
isEnabled:
|
|
542
|
+
isEnabled: true,
|
|
522
543
|
resolveLibraryOrigin: options.resolveLibraryOrigin,
|
|
523
|
-
expectedParentOrigin
|
|
524
|
-
|
|
525
|
-
|
|
544
|
+
get expectedParentOrigin() {
|
|
545
|
+
return (0, exports.resolveEmbeddedAgentUiOrigin)(listenPort);
|
|
546
|
+
},
|
|
526
547
|
}, inlineStartTracker, runtimeAdmission));
|
|
527
548
|
log.info('agent-variants routes mounted at /api/variants');
|
|
528
549
|
}
|
|
@@ -534,16 +555,15 @@ const startServer = async (options) => {
|
|
|
534
555
|
(0, exports.sendInactiveVariantsEventStream)(req, res);
|
|
535
556
|
});
|
|
536
557
|
}
|
|
537
|
-
let userDevProxy = null;
|
|
538
558
|
if (framework !== 'static' || hasUserDevServer || variantsBridge) {
|
|
539
559
|
const proxyUserPort = framework === 'static' && !hasUserDevServer
|
|
540
560
|
? NO_USER_DEV_SERVER_PORT
|
|
541
561
|
: userPortWithFallback;
|
|
542
562
|
userDevProxy = (0, proxy_config_1.createUserDevServerProxy)(proxyUserPort, userHostWithFallback, {
|
|
543
|
-
isPreviewBridgeEnabled:
|
|
544
|
-
expectedPreviewParentOrigin
|
|
545
|
-
|
|
546
|
-
|
|
563
|
+
isPreviewBridgeEnabled: true,
|
|
564
|
+
get expectedPreviewParentOrigin() {
|
|
565
|
+
return (0, exports.resolveEmbeddedAgentUiOrigin)(listenPort);
|
|
566
|
+
},
|
|
547
567
|
resolveVariantPreviewPort: (sessionId, variantId, options) => {
|
|
548
568
|
if (options?.source === 'history') {
|
|
549
569
|
return historyReplay?.getPort(sessionId, variantId) ?? null;
|
|
@@ -555,6 +575,25 @@ const startServer = async (options) => {
|
|
|
555
575
|
},
|
|
556
576
|
});
|
|
557
577
|
variantsBridge?.registerVariantTargetSetter(userDevProxy.setVariantTarget);
|
|
578
|
+
app.use((req, res, next) => {
|
|
579
|
+
if (!isPreviewRequest(req)) {
|
|
580
|
+
if (req.path.toLowerCase().startsWith('/api/')) {
|
|
581
|
+
res.sendStatus(404);
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
if (req.headers[editorAccess_2.EDITOR_ACCESS_TOKEN_HEADER]) {
|
|
585
|
+
res.sendStatus(403);
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
res.redirect(302, `${previewOrigin}${req.originalUrl}`);
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
if (req.headers[editorAccess_2.EDITOR_ACCESS_TOKEN_HEADER]) {
|
|
592
|
+
res.sendStatus(403);
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
next();
|
|
596
|
+
});
|
|
558
597
|
app.get('/{*any}', userDevProxy.middleware);
|
|
559
598
|
app.post('/{*any}', userDevProxy.middleware);
|
|
560
599
|
app.put('/{*any}', userDevProxy.middleware);
|
|
@@ -567,7 +606,7 @@ const startServer = async (options) => {
|
|
|
567
606
|
else {
|
|
568
607
|
log.info(`${framework} mode - skipping proxy setup`);
|
|
569
608
|
}
|
|
570
|
-
if (process.env.SENTRY_DSN) {
|
|
609
|
+
if (process.env.SENTRY_DSN && (0, telemetryPolicy_1.getTelemetryMode)() === 'full') {
|
|
571
610
|
Sentry.setupExpressErrorHandler(app);
|
|
572
611
|
}
|
|
573
612
|
app.use((err, req, res, _next) => {
|
|
@@ -598,12 +637,13 @@ const startServer = async (options) => {
|
|
|
598
637
|
pid: process.pid,
|
|
599
638
|
rivetPort: listenPort,
|
|
600
639
|
projectPath,
|
|
601
|
-
startedAt
|
|
640
|
+
startedAt,
|
|
602
641
|
sessionId: sessionBridge?.getSessionId() ?? null,
|
|
603
642
|
applyMode: handshakeApplyMode,
|
|
604
643
|
queueAccessToken,
|
|
605
|
-
rivetVersion:
|
|
644
|
+
rivetVersion: telemetry_2.RIVET_VERSION,
|
|
606
645
|
pluginName: (0, pluginContext_1.getPluginName)(),
|
|
646
|
+
telemetryMode: (0, telemetryPolicy_1.getTelemetryMode)(),
|
|
607
647
|
});
|
|
608
648
|
}
|
|
609
649
|
catch (err) {
|
|
@@ -612,22 +652,37 @@ const startServer = async (options) => {
|
|
|
612
652
|
};
|
|
613
653
|
const retireCliHandshake = () => {
|
|
614
654
|
(0, serverHandshake_1.removeHandshake)(projectPath, process.pid);
|
|
655
|
+
(0, editorSession_1.removeEditorSession)({ pid: process.pid, port: listenPort, projectPath, startedAt }, editorAccessToken);
|
|
615
656
|
};
|
|
616
657
|
const httpServer = await new Promise((resolve, reject) => {
|
|
617
658
|
const listenHost = (0, exports.resolveRivetListenHost)(agentApplyMode);
|
|
618
|
-
const server = listenHost
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
659
|
+
const server = app.listen(listenPort, listenHost, (error) => {
|
|
660
|
+
if (error) {
|
|
661
|
+
reject(error);
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
log.info(`🎨 Rivet server running on http://${listenHost}:${listenPort}`);
|
|
665
|
+
listenPort = server.address().port;
|
|
666
|
+
if (previewPort === undefined)
|
|
667
|
+
previewOrigin = `http://${EMBEDDED_AGENT_PREVIEW_HOST}:${listenPort}`;
|
|
668
|
+
corsOrigins.add((0, exports.resolveEmbeddedAgentUiOrigin)(listenPort));
|
|
669
|
+
try {
|
|
670
|
+
(0, editorSession_1.writeEditorSession)({
|
|
671
|
+
pid: process.pid,
|
|
672
|
+
port: listenPort,
|
|
673
|
+
projectPath,
|
|
674
|
+
token: editorAccessToken,
|
|
675
|
+
startedAt,
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
catch (error) {
|
|
679
|
+
server.close(() => reject(error));
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
writeDevPortFile(listenPort);
|
|
683
|
+
advertiseCliHandshake();
|
|
684
|
+
resolve(server);
|
|
685
|
+
});
|
|
631
686
|
server.on('error', (err) => {
|
|
632
687
|
reject(err);
|
|
633
688
|
});
|
|
@@ -650,28 +705,76 @@ const startServer = async (options) => {
|
|
|
650
705
|
});
|
|
651
706
|
let previewHttpServer = null;
|
|
652
707
|
if (previewPort !== undefined) {
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
proxyUpgrade
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
708
|
+
try {
|
|
709
|
+
previewHttpServer = await new Promise((resolve, reject) => {
|
|
710
|
+
const pServer = (0, http_1.createServer)(app);
|
|
711
|
+
pServer.on('error', reject);
|
|
712
|
+
pServer.on('connection', (socket) => {
|
|
713
|
+
activeSockets.add(socket);
|
|
714
|
+
socket.on('close', () => activeSockets.delete(socket));
|
|
715
|
+
});
|
|
716
|
+
pServer.on('upgrade', (req, socket, head) => {
|
|
717
|
+
const proxyUpgrade = userDevProxy?.middleware?.upgrade;
|
|
718
|
+
if (proxyUpgrade) {
|
|
719
|
+
proxyUpgrade(req, socket, head);
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
socket.destroy();
|
|
723
|
+
});
|
|
724
|
+
pServer.listen(previewPort, EMBEDDED_AGENT_LISTEN_HOST, () => {
|
|
725
|
+
log.info(`🔒 Rivet isolated preview origin on http://${EMBEDDED_AGENT_LISTEN_HOST}:${previewPort}`);
|
|
726
|
+
resolve(pServer);
|
|
727
|
+
});
|
|
667
728
|
});
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
729
|
+
}
|
|
730
|
+
catch (error) {
|
|
731
|
+
removeDevPortFile();
|
|
732
|
+
retireCliHandshake();
|
|
733
|
+
await new Promise((resolve) => {
|
|
734
|
+
httpServer.close(() => resolve());
|
|
735
|
+
for (const socket of activeSockets)
|
|
736
|
+
socket.destroy();
|
|
671
737
|
});
|
|
738
|
+
throw error;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
if (!skipProcessHandlers) {
|
|
742
|
+
const shutdownAndExit = async (code) => {
|
|
743
|
+
log.info('Server shutting down, cleaning up...');
|
|
744
|
+
(0, WorktreeManager_1.cleanupOrphanedWorktrees)();
|
|
745
|
+
const results = await Promise.allSettled([
|
|
746
|
+
options.beforeShutdown?.(),
|
|
747
|
+
telemetry?.shutdown(),
|
|
748
|
+
(0, FeatureFlagService_1.getFeatureFlagService)().shutdown(),
|
|
749
|
+
]);
|
|
750
|
+
const labels = ['shutdown hook', 'telemetry', 'feature flags'];
|
|
751
|
+
for (let i = 0; i < results.length; i++) {
|
|
752
|
+
if (results[i].status === 'rejected') {
|
|
753
|
+
log.error(`Failed to cleanup ${labels[i]}:`, results[i].reason);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
(0, serverHandshake_1.removeHandshake)(projectPath, process.pid);
|
|
757
|
+
(0, editorSession_1.removeEditorSession)({ pid: process.pid, port: listenPort, projectPath, startedAt }, editorAccessToken);
|
|
758
|
+
process.exit(code);
|
|
759
|
+
};
|
|
760
|
+
process.on('SIGINT', () => shutdownAndExit(0));
|
|
761
|
+
process.on('SIGTERM', () => shutdownAndExit(0));
|
|
762
|
+
process.on('uncaughtException', (err) => {
|
|
763
|
+
log.error('Uncaught exception:', err);
|
|
764
|
+
telemetry?.captureException(err, 'uncaught_exception');
|
|
765
|
+
shutdownAndExit(1);
|
|
766
|
+
});
|
|
767
|
+
process.on('unhandledRejection', (reason) => {
|
|
768
|
+
log.error('Unhandled rejection:', reason);
|
|
769
|
+
telemetry?.captureException(reason, 'unhandled_rejection');
|
|
770
|
+
shutdownAndExit(1);
|
|
672
771
|
});
|
|
673
772
|
}
|
|
674
773
|
return {
|
|
774
|
+
editorUrl: (0, editorAccess_2.createEditorUrl)({
|
|
775
|
+
port: httpServer.address().port,
|
|
776
|
+
token: editorAccessToken,
|
|
777
|
+
}),
|
|
675
778
|
close: () => new Promise((resolve, reject) => {
|
|
676
779
|
removeDevPortFile();
|
|
677
780
|
retireCliHandshake();
|