patchwork-os 0.2.0-alpha.8 → 0.2.0-beta.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.bridge.md +6 -0
- package/README.md +315 -35
- package/deploy/bootstrap-new-vps.sh +12 -12
- package/deploy/bootstrap-vps.sh +187 -0
- package/deploy/deploy-dashboard.sh +174 -0
- package/deploy/deploy-landing.sh +136 -0
- package/dist/activationMetrics.d.ts +67 -0
- package/dist/activationMetrics.js +255 -0
- package/dist/activationMetrics.js.map +1 -0
- package/dist/activityLog.d.ts +49 -0
- package/dist/activityLog.js +78 -0
- package/dist/activityLog.js.map +1 -1
- package/dist/approvalHttp.d.ts +49 -2
- package/dist/approvalHttp.js +217 -21
- package/dist/approvalHttp.js.map +1 -1
- package/dist/approvalInsights.d.ts +49 -0
- package/dist/approvalInsights.js +97 -0
- package/dist/approvalInsights.js.map +1 -0
- package/dist/approvalQueue.d.ts +27 -1
- package/dist/approvalQueue.js +123 -3
- package/dist/approvalQueue.js.map +1 -1
- package/dist/approvalSignals.d.ts +124 -0
- package/dist/approvalSignals.js +512 -0
- package/dist/approvalSignals.js.map +1 -0
- package/dist/automation.d.ts +57 -0
- package/dist/automation.js +156 -59
- package/dist/automation.js.map +1 -1
- package/dist/automationSuggestions.d.ts +79 -0
- package/dist/automationSuggestions.js +150 -0
- package/dist/automationSuggestions.js.map +1 -0
- package/dist/bridge.d.ts +3 -0
- package/dist/bridge.js +174 -143
- package/dist/bridge.js.map +1 -1
- package/dist/bridgeToken.js +57 -19
- package/dist/bridgeToken.js.map +1 -1
- package/dist/ccPermissions.d.ts +15 -0
- package/dist/ccPermissions.js +21 -4
- package/dist/ccPermissions.js.map +1 -1
- package/dist/claudeDriver.js +74 -16
- package/dist/claudeDriver.js.map +1 -1
- package/dist/claudeOrchestrator.d.ts +1 -1
- package/dist/claudeOrchestrator.js +14 -8
- package/dist/claudeOrchestrator.js.map +1 -1
- package/dist/commands/dashboard.js +1 -1
- package/dist/commands/dashboard.js.map +1 -1
- package/dist/commands/launchd.d.ts +2 -0
- package/dist/commands/launchd.js +94 -0
- package/dist/commands/launchd.js.map +1 -0
- package/dist/commands/patchworkInit.d.ts +8 -0
- package/dist/commands/patchworkInit.js +77 -11
- package/dist/commands/patchworkInit.js.map +1 -1
- package/dist/commands/recipe.d.ts +289 -0
- package/dist/commands/recipe.js +1359 -0
- package/dist/commands/recipe.js.map +1 -0
- package/dist/commands/recipeInstall.d.ts +150 -0
- package/dist/commands/recipeInstall.js +647 -0
- package/dist/commands/recipeInstall.js.map +1 -0
- package/dist/commands/tracesExport.d.ts +83 -0
- package/dist/commands/tracesExport.js +269 -0
- package/dist/commands/tracesExport.js.map +1 -0
- package/dist/commands/tracesImport.d.ts +56 -0
- package/dist/commands/tracesImport.js +161 -0
- package/dist/commands/tracesImport.js.map +1 -0
- package/dist/config.d.ts +22 -1
- package/dist/config.js +108 -9
- package/dist/config.js.map +1 -1
- package/dist/connectorRoutes.d.ts +43 -0
- package/dist/connectorRoutes.js +1609 -0
- package/dist/connectorRoutes.js.map +1 -0
- package/dist/connectors/asana.d.ts +198 -0
- package/dist/connectors/asana.js +679 -0
- package/dist/connectors/asana.js.map +1 -0
- package/dist/connectors/baseConnector.d.ts +153 -0
- package/dist/connectors/baseConnector.js +336 -0
- package/dist/connectors/baseConnector.js.map +1 -0
- package/dist/connectors/confluence.d.ts +111 -0
- package/dist/connectors/confluence.js +406 -0
- package/dist/connectors/confluence.js.map +1 -0
- package/dist/connectors/datadog.d.ts +116 -0
- package/dist/connectors/datadog.js +385 -0
- package/dist/connectors/datadog.js.map +1 -0
- package/dist/connectors/discord.d.ts +150 -0
- package/dist/connectors/discord.js +543 -0
- package/dist/connectors/discord.js.map +1 -0
- package/dist/connectors/fixtureLibrary.d.ts +21 -0
- package/dist/connectors/fixtureLibrary.js +70 -0
- package/dist/connectors/fixtureLibrary.js.map +1 -0
- package/dist/connectors/fixtureRecorder.d.ts +1 -0
- package/dist/connectors/fixtureRecorder.js +35 -0
- package/dist/connectors/fixtureRecorder.js.map +1 -0
- package/dist/connectors/github.js +17 -18
- package/dist/connectors/github.js.map +1 -1
- package/dist/connectors/gitlab.d.ts +180 -0
- package/dist/connectors/gitlab.js +582 -0
- package/dist/connectors/gitlab.js.map +1 -0
- package/dist/connectors/gmail.d.ts +4 -1
- package/dist/connectors/gmail.js +157 -27
- package/dist/connectors/gmail.js.map +1 -1
- package/dist/connectors/googleCalendar.d.ts +4 -1
- package/dist/connectors/googleCalendar.js +88 -25
- package/dist/connectors/googleCalendar.js.map +1 -1
- package/dist/connectors/googleDrive.d.ts +34 -0
- package/dist/connectors/googleDrive.js +321 -0
- package/dist/connectors/googleDrive.js.map +1 -0
- package/dist/connectors/htmlEscape.d.ts +5 -0
- package/dist/connectors/htmlEscape.js +13 -0
- package/dist/connectors/htmlEscape.js.map +1 -0
- package/dist/connectors/hubspot.d.ts +112 -0
- package/dist/connectors/hubspot.js +408 -0
- package/dist/connectors/hubspot.js.map +1 -0
- package/dist/connectors/intercom.d.ts +102 -0
- package/dist/connectors/intercom.js +402 -0
- package/dist/connectors/intercom.js.map +1 -0
- package/dist/connectors/jira.d.ts +98 -0
- package/dist/connectors/jira.js +379 -0
- package/dist/connectors/jira.js.map +1 -0
- package/dist/connectors/linear.js +30 -19
- package/dist/connectors/linear.js.map +1 -1
- package/dist/connectors/mcpOAuth.d.ts +3 -0
- package/dist/connectors/mcpOAuth.js +64 -10
- package/dist/connectors/mcpOAuth.js.map +1 -1
- package/dist/connectors/mockConnector.d.ts +28 -0
- package/dist/connectors/mockConnector.js +81 -0
- package/dist/connectors/mockConnector.js.map +1 -0
- package/dist/connectors/notion.d.ts +143 -0
- package/dist/connectors/notion.js +424 -0
- package/dist/connectors/notion.js.map +1 -0
- package/dist/connectors/oauthStateStore.d.ts +31 -0
- package/dist/connectors/oauthStateStore.js +52 -0
- package/dist/connectors/oauthStateStore.js.map +1 -0
- package/dist/connectors/pagerduty.d.ts +160 -0
- package/dist/connectors/pagerduty.js +464 -0
- package/dist/connectors/pagerduty.js.map +1 -0
- package/dist/connectors/sentry.js +5 -13
- package/dist/connectors/sentry.js.map +1 -1
- package/dist/connectors/slack.d.ts +16 -1
- package/dist/connectors/slack.js +155 -32
- package/dist/connectors/slack.js.map +1 -1
- package/dist/connectors/stripe.d.ts +116 -0
- package/dist/connectors/stripe.js +379 -0
- package/dist/connectors/stripe.js.map +1 -0
- package/dist/connectors/tokenStorage.d.ts +35 -0
- package/dist/connectors/tokenStorage.js +484 -0
- package/dist/connectors/tokenStorage.js.map +1 -0
- package/dist/connectors/zendesk.d.ts +104 -0
- package/dist/connectors/zendesk.js +442 -0
- package/dist/connectors/zendesk.js.map +1 -0
- package/dist/cors.d.ts +10 -0
- package/dist/cors.js +29 -0
- package/dist/cors.js.map +1 -0
- package/dist/decisionReplay.d.ts +72 -0
- package/dist/decisionReplay.js +92 -0
- package/dist/decisionReplay.js.map +1 -0
- package/dist/decisionTraceLog.d.ts +6 -0
- package/dist/decisionTraceLog.js +54 -2
- package/dist/decisionTraceLog.js.map +1 -1
- package/dist/drivers/gemini/index.d.ts +5 -1
- package/dist/drivers/gemini/index.js +39 -5
- package/dist/drivers/gemini/index.js.map +1 -1
- package/dist/drivers/index.d.ts +5 -0
- package/dist/drivers/index.js +1 -1
- package/dist/drivers/index.js.map +1 -1
- package/dist/featureFlags.d.ts +79 -0
- package/dist/featureFlags.js +208 -0
- package/dist/featureFlags.js.map +1 -0
- package/dist/fp/automationInterpreter.js +26 -21
- package/dist/fp/automationInterpreter.js.map +1 -1
- package/dist/fp/automationProgram.d.ts +1 -1
- package/dist/fp/automationProgram.js.map +1 -1
- package/dist/fp/automationState.js +4 -1
- package/dist/fp/automationState.js.map +1 -1
- package/dist/fp/policyParser.js +21 -1
- package/dist/fp/policyParser.js.map +1 -1
- package/dist/inboxRoutes.d.ts +22 -0
- package/dist/inboxRoutes.js +114 -0
- package/dist/inboxRoutes.js.map +1 -0
- package/dist/index.js +1400 -201
- package/dist/index.js.map +1 -1
- package/dist/installGuard.d.ts +25 -0
- package/dist/installGuard.js +48 -0
- package/dist/installGuard.js.map +1 -0
- package/dist/mcpRoutes.d.ts +37 -0
- package/dist/mcpRoutes.js +76 -0
- package/dist/mcpRoutes.js.map +1 -0
- package/dist/oauth.d.ts +7 -1
- package/dist/oauth.js +201 -39
- package/dist/oauth.js.map +1 -1
- package/dist/oauthRoutes.d.ts +32 -0
- package/dist/oauthRoutes.js +124 -0
- package/dist/oauthRoutes.js.map +1 -0
- package/dist/orchestrator/orchestratorBridge.js +2 -2
- package/dist/orchestrator/orchestratorBridge.js.map +1 -1
- package/dist/patchworkConfig.d.ts +16 -0
- package/dist/patchworkConfig.js +1 -1
- package/dist/patchworkConfig.js.map +1 -1
- package/dist/pluginLoader.d.ts +28 -0
- package/dist/pluginLoader.js +77 -11
- package/dist/pluginLoader.js.map +1 -1
- package/dist/pluginWatcher.js +8 -3
- package/dist/pluginWatcher.js.map +1 -1
- package/dist/preToolUseHook.d.ts +12 -0
- package/dist/preToolUseHook.js +23 -0
- package/dist/preToolUseHook.js.map +1 -1
- package/dist/recipeOrchestration.d.ts +121 -0
- package/dist/recipeOrchestration.js +955 -0
- package/dist/recipeOrchestration.js.map +1 -0
- package/dist/recipeRoutes.d.ts +180 -0
- package/dist/recipeRoutes.js +1345 -0
- package/dist/recipeRoutes.js.map +1 -0
- package/dist/recipes/RecipeOrchestrator.d.ts +40 -0
- package/dist/recipes/RecipeOrchestrator.js +51 -0
- package/dist/recipes/RecipeOrchestrator.js.map +1 -0
- package/dist/recipes/agentExecutor.d.ts +29 -0
- package/dist/recipes/agentExecutor.js +49 -0
- package/dist/recipes/agentExecutor.js.map +1 -0
- package/dist/recipes/chainedRunner.d.ts +191 -0
- package/dist/recipes/chainedRunner.js +759 -0
- package/dist/recipes/chainedRunner.js.map +1 -0
- package/dist/recipes/compiler.js +3 -3
- package/dist/recipes/compiler.js.map +1 -1
- package/dist/recipes/dependencyGraph.d.ts +39 -0
- package/dist/recipes/dependencyGraph.js +199 -0
- package/dist/recipes/dependencyGraph.js.map +1 -0
- package/dist/recipes/disabledMarkers.d.ts +48 -0
- package/dist/recipes/disabledMarkers.js +52 -0
- package/dist/recipes/disabledMarkers.js.map +1 -0
- package/dist/recipes/installer.js +3 -3
- package/dist/recipes/installer.js.map +1 -1
- package/dist/recipes/legacyRecipeCompat.d.ts +10 -0
- package/dist/recipes/legacyRecipeCompat.js +131 -0
- package/dist/recipes/legacyRecipeCompat.js.map +1 -0
- package/dist/recipes/manifest.d.ts +47 -0
- package/dist/recipes/manifest.js +156 -0
- package/dist/recipes/manifest.js.map +1 -0
- package/dist/recipes/migrationWarnings.d.ts +12 -0
- package/dist/recipes/migrationWarnings.js +44 -0
- package/dist/recipes/migrationWarnings.js.map +1 -0
- package/dist/recipes/migrations/index.d.ts +24 -0
- package/dist/recipes/migrations/index.js +55 -0
- package/dist/recipes/migrations/index.js.map +1 -0
- package/dist/recipes/migrations/types.d.ts +28 -0
- package/dist/recipes/migrations/types.js +2 -0
- package/dist/recipes/migrations/types.js.map +1 -0
- package/dist/recipes/migrations/v1.d.ts +11 -0
- package/dist/recipes/migrations/v1.js +18 -0
- package/dist/recipes/migrations/v1.js.map +1 -0
- package/dist/recipes/names.d.ts +40 -0
- package/dist/recipes/names.js +66 -0
- package/dist/recipes/names.js.map +1 -0
- package/dist/recipes/nestedRecipeStep.d.ts +58 -0
- package/dist/recipes/nestedRecipeStep.js +95 -0
- package/dist/recipes/nestedRecipeStep.js.map +1 -0
- package/dist/recipes/outputRegistry.d.ts +28 -0
- package/dist/recipes/outputRegistry.js +52 -0
- package/dist/recipes/outputRegistry.js.map +1 -0
- package/dist/recipes/parser.js +4 -1
- package/dist/recipes/parser.js.map +1 -1
- package/dist/recipes/replayRun.d.ts +62 -0
- package/dist/recipes/replayRun.js +97 -0
- package/dist/recipes/replayRun.js.map +1 -0
- package/dist/recipes/resolveRecipePath.d.ts +69 -0
- package/dist/recipes/resolveRecipePath.js +202 -0
- package/dist/recipes/resolveRecipePath.js.map +1 -0
- package/dist/recipes/scheduler.d.ts +23 -7
- package/dist/recipes/scheduler.js +225 -45
- package/dist/recipes/scheduler.js.map +1 -1
- package/dist/recipes/schema.d.ts +17 -2
- package/dist/recipes/schemaGenerator.d.ts +28 -0
- package/dist/recipes/schemaGenerator.js +565 -0
- package/dist/recipes/schemaGenerator.js.map +1 -0
- package/dist/recipes/stepObservation.d.ts +44 -0
- package/dist/recipes/stepObservation.js +232 -0
- package/dist/recipes/stepObservation.js.map +1 -0
- package/dist/recipes/templateEngine.d.ts +62 -0
- package/dist/recipes/templateEngine.js +201 -0
- package/dist/recipes/templateEngine.js.map +1 -0
- package/dist/recipes/toolRegistry.d.ts +186 -0
- package/dist/recipes/toolRegistry.js +309 -0
- package/dist/recipes/toolRegistry.js.map +1 -0
- package/dist/recipes/tools/asana.d.ts +16 -0
- package/dist/recipes/tools/asana.js +524 -0
- package/dist/recipes/tools/asana.js.map +1 -0
- package/dist/recipes/tools/calendar.d.ts +6 -0
- package/dist/recipes/tools/calendar.js +61 -0
- package/dist/recipes/tools/calendar.js.map +1 -0
- package/dist/recipes/tools/confluence.d.ts +6 -0
- package/dist/recipes/tools/confluence.js +254 -0
- package/dist/recipes/tools/confluence.js.map +1 -0
- package/dist/recipes/tools/datadog.d.ts +6 -0
- package/dist/recipes/tools/datadog.js +239 -0
- package/dist/recipes/tools/datadog.js.map +1 -0
- package/dist/recipes/tools/diagnostics.d.ts +6 -0
- package/dist/recipes/tools/diagnostics.js +36 -0
- package/dist/recipes/tools/diagnostics.js.map +1 -0
- package/dist/recipes/tools/discord.d.ts +18 -0
- package/dist/recipes/tools/discord.js +254 -0
- package/dist/recipes/tools/discord.js.map +1 -0
- package/dist/recipes/tools/file.d.ts +12 -0
- package/dist/recipes/tools/file.js +174 -0
- package/dist/recipes/tools/file.js.map +1 -0
- package/dist/recipes/tools/git.d.ts +6 -0
- package/dist/recipes/tools/git.js +63 -0
- package/dist/recipes/tools/git.js.map +1 -0
- package/dist/recipes/tools/github.d.ts +6 -0
- package/dist/recipes/tools/github.js +116 -0
- package/dist/recipes/tools/github.js.map +1 -0
- package/dist/recipes/tools/gitlab.d.ts +11 -0
- package/dist/recipes/tools/gitlab.js +285 -0
- package/dist/recipes/tools/gitlab.js.map +1 -0
- package/dist/recipes/tools/gmail.d.ts +6 -0
- package/dist/recipes/tools/gmail.js +434 -0
- package/dist/recipes/tools/gmail.js.map +1 -0
- package/dist/recipes/tools/googleDrive.d.ts +1 -0
- package/dist/recipes/tools/googleDrive.js +55 -0
- package/dist/recipes/tools/googleDrive.js.map +1 -0
- package/dist/recipes/tools/hubspot.d.ts +6 -0
- package/dist/recipes/tools/hubspot.js +232 -0
- package/dist/recipes/tools/hubspot.js.map +1 -0
- package/dist/recipes/tools/index.d.ts +30 -0
- package/dist/recipes/tools/index.js +33 -0
- package/dist/recipes/tools/index.js.map +1 -0
- package/dist/recipes/tools/intercom.d.ts +6 -0
- package/dist/recipes/tools/intercom.js +226 -0
- package/dist/recipes/tools/intercom.js.map +1 -0
- package/dist/recipes/tools/jira.d.ts +14 -0
- package/dist/recipes/tools/jira.js +369 -0
- package/dist/recipes/tools/jira.js.map +1 -0
- package/dist/recipes/tools/linear.d.ts +7 -0
- package/dist/recipes/tools/linear.js +307 -0
- package/dist/recipes/tools/linear.js.map +1 -0
- package/dist/recipes/tools/meetingNotes.d.ts +21 -0
- package/dist/recipes/tools/meetingNotes.js +701 -0
- package/dist/recipes/tools/meetingNotes.js.map +1 -0
- package/dist/recipes/tools/notion.d.ts +6 -0
- package/dist/recipes/tools/notion.js +278 -0
- package/dist/recipes/tools/notion.js.map +1 -0
- package/dist/recipes/tools/pagerduty.d.ts +15 -0
- package/dist/recipes/tools/pagerduty.js +451 -0
- package/dist/recipes/tools/pagerduty.js.map +1 -0
- package/dist/recipes/tools/sentry.d.ts +12 -0
- package/dist/recipes/tools/sentry.js +73 -0
- package/dist/recipes/tools/sentry.js.map +1 -0
- package/dist/recipes/tools/slack.d.ts +6 -0
- package/dist/recipes/tools/slack.js +82 -0
- package/dist/recipes/tools/slack.js.map +1 -0
- package/dist/recipes/tools/stripe.d.ts +6 -0
- package/dist/recipes/tools/stripe.js +265 -0
- package/dist/recipes/tools/stripe.js.map +1 -0
- package/dist/recipes/tools/zendesk.d.ts +6 -0
- package/dist/recipes/tools/zendesk.js +245 -0
- package/dist/recipes/tools/zendesk.js.map +1 -0
- package/dist/recipes/validation.d.ts +13 -0
- package/dist/recipes/validation.js +617 -0
- package/dist/recipes/validation.js.map +1 -0
- package/dist/recipes/yamlRunner.d.ts +116 -1
- package/dist/recipes/yamlRunner.js +1000 -401
- package/dist/recipes/yamlRunner.js.map +1 -1
- package/dist/recipesHttp.d.ts +137 -6
- package/dist/recipesHttp.js +941 -29
- package/dist/recipesHttp.js.map +1 -1
- package/dist/riskTier.js +7 -1
- package/dist/riskTier.js.map +1 -1
- package/dist/runLog.d.ts +100 -1
- package/dist/runLog.js +258 -5
- package/dist/runLog.js.map +1 -1
- package/dist/schemas/dry-run-plan.v1.json +139 -0
- package/dist/schemas/recipe.v1.json +684 -0
- package/dist/server.d.ts +121 -8
- package/dist/server.js +538 -735
- package/dist/server.js.map +1 -1
- package/dist/ssrfGuard.d.ts +54 -0
- package/dist/ssrfGuard.js +122 -0
- package/dist/ssrfGuard.js.map +1 -0
- package/dist/streamableHttp.d.ts +39 -1
- package/dist/streamableHttp.js +128 -17
- package/dist/streamableHttp.js.map +1 -1
- package/dist/tokenUsageTracker.d.ts +33 -0
- package/dist/tokenUsageTracker.js +146 -0
- package/dist/tokenUsageTracker.js.map +1 -0
- package/dist/tools/activityLog.d.ts +2 -0
- package/dist/tools/addLinearComment.d.ts +1 -0
- package/dist/tools/addLinearComment.js +4 -2
- package/dist/tools/addLinearComment.js.map +1 -1
- package/dist/tools/batchLsp.d.ts +3 -0
- package/dist/tools/bridgeDoctor.d.ts +1 -0
- package/dist/tools/bridgeDoctor.js +2 -2
- package/dist/tools/bridgeDoctor.js.map +1 -1
- package/dist/tools/bridgeStatus.d.ts +1 -0
- package/dist/tools/cancelClaudeTask.d.ts +2 -0
- package/dist/tools/cancelClaudeTask.js +1 -0
- package/dist/tools/cancelClaudeTask.js.map +1 -1
- package/dist/tools/checkDocumentDirty.d.ts +1 -0
- package/dist/tools/clipboard.d.ts +2 -0
- package/dist/tools/closeTabs.d.ts +2 -0
- package/dist/tools/codeLens.d.ts +1 -0
- package/dist/tools/contextBundle.d.ts +1 -0
- package/dist/tools/createIssueFromAIComment.d.ts +1 -0
- package/dist/tools/createLinearIssue.d.ts +1 -0
- package/dist/tools/ctxGetTaskContext.d.ts +1 -0
- package/dist/tools/ctxQueryTraces.d.ts +1 -0
- package/dist/tools/ctxSaveTrace.d.ts +1 -0
- package/dist/tools/debug.d.ts +4 -0
- package/dist/tools/decorations.d.ts +2 -0
- package/dist/tools/documentLinks.d.ts +1 -0
- package/dist/tools/editText.d.ts +1 -0
- package/dist/tools/enrichCommit.d.ts +1 -0
- package/dist/tools/enrichStackTrace.d.ts +1 -0
- package/dist/tools/explainDiagnostic.d.ts +1 -0
- package/dist/tools/explainSymbol.d.ts +1 -0
- package/dist/tools/fetchCalendarEvents.d.ts +1 -0
- package/dist/tools/fetchGithubIssue.d.ts +1 -0
- package/dist/tools/fetchGithubPR.d.ts +1 -0
- package/dist/tools/fetchLinearIssue.d.ts +1 -0
- package/dist/tools/fetchSentryIssue.d.ts +1 -0
- package/dist/tools/fetchSlackProfile.d.ts +1 -0
- package/dist/tools/fetchSlackProfile.js +4 -1
- package/dist/tools/fetchSlackProfile.js.map +1 -1
- package/dist/tools/fileOperations.d.ts +3 -0
- package/dist/tools/fileWatcher.d.ts +2 -0
- package/dist/tools/findFiles.d.ts +1 -0
- package/dist/tools/findRelatedTests.d.ts +1 -0
- package/dist/tools/fixAllLintErrors.d.ts +1 -0
- package/dist/tools/foldingRanges.d.ts +1 -0
- package/dist/tools/formatDocument.d.ts +1 -0
- package/dist/tools/generateTests.d.ts +1 -0
- package/dist/tools/getAIComments.d.ts +1 -0
- package/dist/tools/getAnalyticsReport.d.ts +1 -0
- package/dist/tools/getArchitectureContext.d.ts +1 -0
- package/dist/tools/getBufferContent.d.ts +1 -0
- package/dist/tools/getChangeImpact.d.ts +1 -0
- package/dist/tools/getClaudeTaskStatus.d.ts +2 -0
- package/dist/tools/getClaudeTaskStatus.js +1 -0
- package/dist/tools/getClaudeTaskStatus.js.map +1 -1
- package/dist/tools/getCodeCoverage.d.ts +1 -0
- package/dist/tools/getCommitsForIssue.d.ts +1 -0
- package/dist/tools/getConnectorStatus.d.ts +1 -0
- package/dist/tools/getCurrentSelection.d.ts +2 -0
- package/dist/tools/getDebugState.d.ts +1 -0
- package/dist/tools/getDependencyTree.d.ts +1 -0
- package/dist/tools/getDiagnostics.d.ts +1 -0
- package/dist/tools/getDiffFromHandoff.d.ts +1 -0
- package/dist/tools/getDocumentSymbols.d.ts +25 -0
- package/dist/tools/getDocumentSymbols.js +74 -8
- package/dist/tools/getDocumentSymbols.js.map +1 -1
- package/dist/tools/getFileTree.d.ts +1 -0
- package/dist/tools/getGitDiff.d.ts +1 -0
- package/dist/tools/getGitHotspots.d.ts +1 -0
- package/dist/tools/getGitLog.d.ts +1 -0
- package/dist/tools/getGitStatus.d.ts +1 -0
- package/dist/tools/getImportTree.d.ts +1 -0
- package/dist/tools/getImportedSignatures.d.ts +1 -0
- package/dist/tools/getOpenEditors.d.ts +1 -0
- package/dist/tools/getPRTemplate.d.ts +1 -0
- package/dist/tools/getProjectContext.d.ts +1 -0
- package/dist/tools/getProjectInfo.d.ts +1 -0
- package/dist/tools/getSecurityAdvisories.d.ts +1 -0
- package/dist/tools/getSecurityAdvisories.js +10 -1
- package/dist/tools/getSecurityAdvisories.js.map +1 -1
- package/dist/tools/getSessionUsage.d.ts +4 -0
- package/dist/tools/getSessionUsage.js +3 -0
- package/dist/tools/getSessionUsage.js.map +1 -1
- package/dist/tools/getSymbolHistory.d.ts +1 -0
- package/dist/tools/getToolCapabilities.d.ts +1 -0
- package/dist/tools/getTypeSignature.d.ts +1 -0
- package/dist/tools/getWorkspaceFolders.d.ts +1 -0
- package/dist/tools/getWorkspaceSettings.d.ts +1 -0
- package/dist/tools/gitHistory.d.ts +2 -0
- package/dist/tools/gitWrite.d.ts +11 -0
- package/dist/tools/github/actions.d.ts +2 -0
- package/dist/tools/github/actions.js +4 -2
- package/dist/tools/github/actions.js.map +1 -1
- package/dist/tools/github/composite.d.ts +342 -0
- package/dist/tools/github/composite.js +343 -0
- package/dist/tools/github/composite.js.map +1 -0
- package/dist/tools/github/index.d.ts +1 -0
- package/dist/tools/github/index.js +1 -0
- package/dist/tools/github/index.js.map +1 -1
- package/dist/tools/github/issues.d.ts +4 -0
- package/dist/tools/github/issues.js +8 -4
- package/dist/tools/github/issues.js.map +1 -1
- package/dist/tools/github/pr.d.ts +7 -0
- package/dist/tools/github/pr.js +50 -12
- package/dist/tools/github/pr.js.map +1 -1
- package/dist/tools/handoffNote.d.ts +4 -0
- package/dist/tools/handoffNote.js +2 -0
- package/dist/tools/handoffNote.js.map +1 -1
- package/dist/tools/hoverAtCursor.d.ts +1 -0
- package/dist/tools/httpClient.d.ts +2 -0
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.js +47 -8
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/inlayHints.d.ts +1 -0
- package/dist/tools/launchQuickTask.d.ts +2 -0
- package/dist/tools/launchQuickTask.js +1 -0
- package/dist/tools/launchQuickTask.js.map +1 -1
- package/dist/tools/listClaudeTasks.d.ts +2 -0
- package/dist/tools/listClaudeTasks.js +1 -0
- package/dist/tools/listClaudeTasks.js.map +1 -1
- package/dist/tools/listTerminals.d.ts +1 -0
- package/dist/tools/lsp.d.ts +14 -0
- package/dist/tools/navigateToSymbolByName.d.ts +1 -0
- package/dist/tools/openDiff.d.ts +1 -0
- package/dist/tools/openFile.d.ts +1 -0
- package/dist/tools/openInBrowser.d.ts +1 -0
- package/dist/tools/organizeImports.d.ts +1 -0
- package/dist/tools/performanceReport.d.ts +1 -0
- package/dist/tools/planPersistence.d.ts +5 -0
- package/dist/tools/previewEdit.d.ts +1 -0
- package/dist/tools/refactorAnalyze.d.ts +1 -0
- package/dist/tools/refactorPreview.d.ts +2 -0
- package/dist/tools/refactorPreview.js +1 -0
- package/dist/tools/refactorPreview.js.map +1 -1
- package/dist/tools/replaceBlock.d.ts +1 -0
- package/dist/tools/resumeClaudeTask.d.ts +2 -0
- package/dist/tools/resumeClaudeTask.js +1 -0
- package/dist/tools/resumeClaudeTask.js.map +1 -1
- package/dist/tools/runClaudeTask.d.ts +2 -0
- package/dist/tools/runClaudeTask.js +1 -0
- package/dist/tools/runClaudeTask.js.map +1 -1
- package/dist/tools/runCommand.d.ts +1 -0
- package/dist/tools/runTests.d.ts +1 -0
- package/dist/tools/saveDocument.d.ts +1 -0
- package/dist/tools/screenshotAndAnnotate.d.ts +1 -0
- package/dist/tools/searchAndReplace.d.ts +1 -0
- package/dist/tools/searchTools.d.ts +1 -0
- package/dist/tools/searchTools.js +1 -1
- package/dist/tools/searchTools.js.map +1 -1
- package/dist/tools/searchWorkspace.d.ts +1 -0
- package/dist/tools/selectionRanges.d.ts +1 -0
- package/dist/tools/semanticTokens.d.ts +1 -0
- package/dist/tools/setActiveWorkspaceFolder.d.ts +1 -0
- package/dist/tools/signatureHelp.d.ts +1 -0
- package/dist/tools/slackListChannels.d.ts +1 -0
- package/dist/tools/slackListChannels.js.map +1 -1
- package/dist/tools/slackPostMessage.d.ts +1 -0
- package/dist/tools/slackPostMessage.js +11 -6
- package/dist/tools/slackPostMessage.js.map +1 -1
- package/dist/tools/terminal.d.ts +6 -0
- package/dist/tools/testTraceToSource.d.ts +1 -0
- package/dist/tools/testTraceToSource.js +2 -2
- package/dist/tools/testTraceToSource.js.map +1 -1
- package/dist/tools/transaction.d.ts +23 -0
- package/dist/tools/transaction.js +29 -0
- package/dist/tools/transaction.js.map +1 -1
- package/dist/tools/typeHierarchy.d.ts +1 -0
- package/dist/tools/updateLinearIssue.d.ts +1 -0
- package/dist/tools/updateLinearIssue.js +20 -6
- package/dist/tools/updateLinearIssue.js.map +1 -1
- package/dist/tools/utils.d.ts +2 -0
- package/dist/tools/utils.js.map +1 -1
- package/dist/tools/vscodeCommands.d.ts +2 -0
- package/dist/tools/vscodeTasks.d.ts +2 -0
- package/dist/tools/workspaceSettings.d.ts +1 -0
- package/dist/traceEncryption.d.ts +46 -0
- package/dist/traceEncryption.js +124 -0
- package/dist/traceEncryption.js.map +1 -0
- package/dist/transport.d.ts +46 -1
- package/dist/transport.js +173 -19
- package/dist/transport.js.map +1 -1
- package/package.json +30 -8
- package/scripts/mcp-stdio-shim.cjs +19 -3
- package/scripts/start-all.sh +30 -1
- package/templates/automation-policies/recipe-authoring.json +25 -0
- package/templates/automation-policy.example.json +6 -0
- package/templates/co.patchwork-os.bridge.plist +34 -0
- package/templates/policies/README.md +72 -0
- package/templates/policies/conservative.json +14 -0
- package/templates/policies/developer.json +14 -0
- package/templates/policies/headless-ci.json +24 -0
- package/templates/policies/personal-assistant.json +15 -0
- package/templates/policies/regulated-industry.json +18 -0
- package/templates/recipes/lint-on-save.yaml +1 -2
- package/templates/recipes/morning-brief-slack.yaml +57 -0
- package/templates/recipes/morning-brief.yaml +2 -2
- package/templates/recipes/project-health-check.yaml +50 -0
- package/templates/recipes/webhook/README.md +70 -0
- package/templates/recipes/webhook/capture-thought.yaml +26 -0
- package/templates/recipes/webhook/customer-escalation.yaml +49 -0
- package/templates/recipes/webhook/incident-intake.yaml +46 -0
- package/templates/recipes/webhook/meeting-prep.yaml +48 -0
- package/templates/recipes/webhook/morning-brief.yaml +57 -0
|
@@ -0,0 +1,1609 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connector route dispatcher — extracted from src/server.ts.
|
|
3
|
+
*
|
|
4
|
+
* Owns every `/connections/*` HTTP endpoint (auth start / OAuth callback /
|
|
5
|
+
* test ping / disconnect / connect-with-body) for the 18 supported
|
|
6
|
+
* connectors.
|
|
7
|
+
*
|
|
8
|
+
* Two entrypoints — the split exists because OAuth callbacks must run
|
|
9
|
+
* BEFORE the bearer-auth gate (they're browser redirects from the vendor
|
|
10
|
+
* with no Patchwork token), while CRUD routes must run AFTER it:
|
|
11
|
+
*
|
|
12
|
+
* - `tryHandlePublicConnectorRoute` — `/connections/<vendor>/callback`
|
|
13
|
+
* routes. Server.ts calls this BEFORE bearer-auth.
|
|
14
|
+
* - `tryHandleConnectorRoute` — auth/test/disconnect/connect routes.
|
|
15
|
+
* Server.ts calls this AFTER bearer-auth.
|
|
16
|
+
*
|
|
17
|
+
* Mechanical lift — no behavior change:
|
|
18
|
+
* - Handler bodies are byte-identical to the original blocks save for
|
|
19
|
+
* wrapping a few non-IIFE call sites in `void (async()=>{...})()` so
|
|
20
|
+
* both functions can return boolean synchronously rather than
|
|
21
|
+
* Promise<boolean>. The microtask delay this introduces is invisible
|
|
22
|
+
* to clients — the parent request handler `return`s on a true result
|
|
23
|
+
* either way, and `res.end()` has always been async.
|
|
24
|
+
* - Pre-extraction grep confirmed zero `this.` references in either
|
|
25
|
+
* block, so no dependency injection was needed.
|
|
26
|
+
*/
|
|
27
|
+
import { readBodyWithCap, respond413 } from "./recipeRoutes.js";
|
|
28
|
+
/**
|
|
29
|
+
* Token-paste connector body cap. The legitimate payload is a small JSON
|
|
30
|
+
* envelope (`{token: "...", workspace?: "..."}`) — cap at 16 KB so an
|
|
31
|
+
* authenticated caller can't burn bridge heap streaming a multi-GB body
|
|
32
|
+
* into the unbounded `req.on("data", ...)` handlers each connector route
|
|
33
|
+
* used to have.
|
|
34
|
+
*/
|
|
35
|
+
const CONNECTOR_BODY_CAP = 16 * 1024;
|
|
36
|
+
/**
|
|
37
|
+
* Read the request body with a cap, dispatch to the connector's
|
|
38
|
+
* `handle<Vendor>Connect(body)` function, and write the result. Replaces
|
|
39
|
+
* the 8 near-identical inline blocks that previously each had an
|
|
40
|
+
* unbounded `req.on("data", ...)` accumulation.
|
|
41
|
+
*
|
|
42
|
+
* `loadHandler` is a closure that returns the handler — kept this shape
|
|
43
|
+
* so each call site preserves the lazy `await import()` of the connector
|
|
44
|
+
* module (only loaded on first call, not at bridge startup).
|
|
45
|
+
*/
|
|
46
|
+
async function dispatchConnectorConnect(req, res, loadHandler) {
|
|
47
|
+
const read = await readBodyWithCap(req, CONNECTOR_BODY_CAP);
|
|
48
|
+
if (!read.ok) {
|
|
49
|
+
respond413(res, CONNECTOR_BODY_CAP);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
const handler = await loadHandler();
|
|
54
|
+
const result = await handler(read.body);
|
|
55
|
+
res.writeHead(result.status, {
|
|
56
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
57
|
+
});
|
|
58
|
+
res.end(result.body);
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
if (!res.headersSent) {
|
|
62
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
63
|
+
res.end(JSON.stringify({
|
|
64
|
+
error: err instanceof Error ? err.message : String(err),
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Try to handle a `/connections/<vendor>/callback` route. These are
|
|
71
|
+
* unauthenticated browser redirects from the OAuth vendor and MUST run
|
|
72
|
+
* before the bearer-auth gate. Returns true if the route was dispatched.
|
|
73
|
+
*/
|
|
74
|
+
export function tryHandlePublicConnectorRoute(req, res, parsedUrl) {
|
|
75
|
+
if (parsedUrl.pathname === "/connections/github/callback" &&
|
|
76
|
+
req.method === "GET") {
|
|
77
|
+
void (async () => {
|
|
78
|
+
try {
|
|
79
|
+
const { handleGithubCallback } = await import("./connectors/github.js");
|
|
80
|
+
const code = parsedUrl.searchParams.get("code");
|
|
81
|
+
const state = parsedUrl.searchParams.get("state");
|
|
82
|
+
const error = parsedUrl.searchParams.get("error");
|
|
83
|
+
const result = await handleGithubCallback(code, state, error);
|
|
84
|
+
res.writeHead(result.status, {
|
|
85
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
86
|
+
});
|
|
87
|
+
res.end(result.body);
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
if (!res.headersSent) {
|
|
91
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
92
|
+
res.end(JSON.stringify({
|
|
93
|
+
error: err instanceof Error ? err.message : String(err),
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
})();
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
if (parsedUrl.pathname === "/connections/linear/callback" &&
|
|
101
|
+
req.method === "GET") {
|
|
102
|
+
void (async () => {
|
|
103
|
+
try {
|
|
104
|
+
const { handleLinearCallback } = await import("./connectors/linear.js");
|
|
105
|
+
const code = parsedUrl.searchParams.get("code");
|
|
106
|
+
const state = parsedUrl.searchParams.get("state");
|
|
107
|
+
const error = parsedUrl.searchParams.get("error");
|
|
108
|
+
const result = await handleLinearCallback(code, state, error);
|
|
109
|
+
res.writeHead(result.status, {
|
|
110
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
111
|
+
});
|
|
112
|
+
res.end(result.body);
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
if (!res.headersSent) {
|
|
116
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
117
|
+
res.end(JSON.stringify({
|
|
118
|
+
error: err instanceof Error ? err.message : String(err),
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
})();
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
if (parsedUrl.pathname === "/connections/sentry/callback" &&
|
|
126
|
+
req.method === "GET") {
|
|
127
|
+
void (async () => {
|
|
128
|
+
try {
|
|
129
|
+
const { handleSentryCallback } = await import("./connectors/sentry.js");
|
|
130
|
+
const code = parsedUrl.searchParams.get("code");
|
|
131
|
+
const state = parsedUrl.searchParams.get("state");
|
|
132
|
+
const error = parsedUrl.searchParams.get("error");
|
|
133
|
+
const result = await handleSentryCallback(code, state, error);
|
|
134
|
+
res.writeHead(result.status, {
|
|
135
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
136
|
+
});
|
|
137
|
+
res.end(result.body);
|
|
138
|
+
}
|
|
139
|
+
catch (err) {
|
|
140
|
+
if (!res.headersSent) {
|
|
141
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
142
|
+
res.end(JSON.stringify({
|
|
143
|
+
error: err instanceof Error ? err.message : String(err),
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
})();
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
if (parsedUrl.pathname === "/connections/google-calendar/callback" &&
|
|
151
|
+
req.method === "GET") {
|
|
152
|
+
void (async () => {
|
|
153
|
+
try {
|
|
154
|
+
const { handleCalendarCallback } = await import("./connectors/googleCalendar.js");
|
|
155
|
+
const code = parsedUrl.searchParams.get("code");
|
|
156
|
+
const state = parsedUrl.searchParams.get("state");
|
|
157
|
+
const error = parsedUrl.searchParams.get("error");
|
|
158
|
+
const result = await handleCalendarCallback(code, state, error);
|
|
159
|
+
res.writeHead(result.status, {
|
|
160
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
161
|
+
});
|
|
162
|
+
res.end(result.body);
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
if (!res.headersSent) {
|
|
166
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
167
|
+
res.end(JSON.stringify({
|
|
168
|
+
error: err instanceof Error ? err.message : String(err),
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
})();
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
if (parsedUrl.pathname === "/connections/google-drive/callback" &&
|
|
176
|
+
req.method === "GET") {
|
|
177
|
+
void (async () => {
|
|
178
|
+
try {
|
|
179
|
+
const { handleDriveCallback } = await import("./connectors/googleDrive.js");
|
|
180
|
+
const code = parsedUrl.searchParams.get("code");
|
|
181
|
+
const state = parsedUrl.searchParams.get("state");
|
|
182
|
+
const error = parsedUrl.searchParams.get("error");
|
|
183
|
+
const result = await handleDriveCallback(code, state, error);
|
|
184
|
+
res.writeHead(result.status, {
|
|
185
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
186
|
+
});
|
|
187
|
+
res.end(result.body);
|
|
188
|
+
}
|
|
189
|
+
catch (err) {
|
|
190
|
+
if (!res.headersSent) {
|
|
191
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
192
|
+
res.end(JSON.stringify({
|
|
193
|
+
error: err instanceof Error ? err.message : String(err),
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
})();
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
if (parsedUrl.pathname === "/connections/slack/callback" &&
|
|
201
|
+
req.method === "GET") {
|
|
202
|
+
void (async () => {
|
|
203
|
+
try {
|
|
204
|
+
const { handleSlackCallback } = await import("./connectors/slack.js");
|
|
205
|
+
const code = parsedUrl.searchParams.get("code");
|
|
206
|
+
const state = parsedUrl.searchParams.get("state");
|
|
207
|
+
const error = parsedUrl.searchParams.get("error");
|
|
208
|
+
const result = await handleSlackCallback(code, state, error);
|
|
209
|
+
res.writeHead(result.status, {
|
|
210
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
211
|
+
});
|
|
212
|
+
res.end(result.body);
|
|
213
|
+
}
|
|
214
|
+
catch (err) {
|
|
215
|
+
if (!res.headersSent) {
|
|
216
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
217
|
+
res.end(JSON.stringify({
|
|
218
|
+
error: err instanceof Error ? err.message : String(err),
|
|
219
|
+
}));
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
})();
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
if (parsedUrl.pathname === "/connections/gmail/callback" &&
|
|
226
|
+
req.method === "GET") {
|
|
227
|
+
void (async () => {
|
|
228
|
+
try {
|
|
229
|
+
const { handleGmailCallback } = await import("./connectors/gmail.js");
|
|
230
|
+
const code = parsedUrl.searchParams.get("code");
|
|
231
|
+
const state = parsedUrl.searchParams.get("state");
|
|
232
|
+
const error = parsedUrl.searchParams.get("error");
|
|
233
|
+
const result = await handleGmailCallback(code, state, error);
|
|
234
|
+
res.writeHead(result.status, {
|
|
235
|
+
"Content-Type": result.contentType ?? "text/html",
|
|
236
|
+
});
|
|
237
|
+
res.end(result.body);
|
|
238
|
+
}
|
|
239
|
+
catch (err) {
|
|
240
|
+
if (!res.headersSent) {
|
|
241
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
242
|
+
res.end(JSON.stringify({
|
|
243
|
+
error: err instanceof Error ? err.message : String(err),
|
|
244
|
+
}));
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
})();
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Try to handle a `/connections/*` route (auth start / test / disconnect /
|
|
254
|
+
* connect-with-body). Returns true if the route was dispatched (caller
|
|
255
|
+
* should `return` from the request handler), false if no route matched
|
|
256
|
+
* (caller should fall through to other route checks).
|
|
257
|
+
*
|
|
258
|
+
* The actual response is written asynchronously inside an IIFE; this
|
|
259
|
+
* function returns synchronously as soon as the route is recognized.
|
|
260
|
+
*/
|
|
261
|
+
export function tryHandleConnectorRoute(req, res, parsedUrl) {
|
|
262
|
+
// ── Gmail / Connections endpoints ───────────────────────────────────────
|
|
263
|
+
if (parsedUrl.pathname === "/connections" && req.method === "GET") {
|
|
264
|
+
void (async () => {
|
|
265
|
+
try {
|
|
266
|
+
const { handleConnectionsList } = await import("./connectors/gmail.js");
|
|
267
|
+
const result = await handleConnectionsList();
|
|
268
|
+
res.writeHead(result.status, {
|
|
269
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
270
|
+
});
|
|
271
|
+
res.end(result.body);
|
|
272
|
+
}
|
|
273
|
+
catch (err) {
|
|
274
|
+
if (!res.headersSent) {
|
|
275
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
276
|
+
res.end(JSON.stringify({
|
|
277
|
+
error: err instanceof Error ? err.message : String(err),
|
|
278
|
+
}));
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
})();
|
|
282
|
+
return true;
|
|
283
|
+
}
|
|
284
|
+
if (parsedUrl.pathname === "/connections/gmail/auth" &&
|
|
285
|
+
req.method === "GET") {
|
|
286
|
+
void (async () => {
|
|
287
|
+
try {
|
|
288
|
+
const { handleGmailAuthRedirect } = await import("./connectors/gmail.js");
|
|
289
|
+
const result = handleGmailAuthRedirect();
|
|
290
|
+
if (result.redirect) {
|
|
291
|
+
res.writeHead(302, { Location: result.redirect });
|
|
292
|
+
res.end();
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
res.writeHead(result.status, {
|
|
296
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
297
|
+
});
|
|
298
|
+
res.end(result.body);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
catch (err) {
|
|
302
|
+
if (!res.headersSent) {
|
|
303
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
304
|
+
res.end(JSON.stringify({
|
|
305
|
+
error: err instanceof Error ? err.message : String(err),
|
|
306
|
+
}));
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
})();
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
if (parsedUrl.pathname === "/connections/gmail" && req.method === "DELETE") {
|
|
313
|
+
void (async () => {
|
|
314
|
+
try {
|
|
315
|
+
const { handleGmailDisconnect } = await import("./connectors/gmail.js");
|
|
316
|
+
const result = await handleGmailDisconnect();
|
|
317
|
+
res.writeHead(result.status, {
|
|
318
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
319
|
+
});
|
|
320
|
+
res.end(result.body);
|
|
321
|
+
}
|
|
322
|
+
catch (err) {
|
|
323
|
+
if (!res.headersSent) {
|
|
324
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
325
|
+
res.end(JSON.stringify({
|
|
326
|
+
error: err instanceof Error ? err.message : String(err),
|
|
327
|
+
}));
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
})();
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
if (parsedUrl.pathname === "/connections/gmail/test" &&
|
|
334
|
+
req.method === "POST") {
|
|
335
|
+
void (async () => {
|
|
336
|
+
try {
|
|
337
|
+
const { handleGmailTest } = await import("./connectors/gmail.js");
|
|
338
|
+
const result = await handleGmailTest();
|
|
339
|
+
res.writeHead(result.status, {
|
|
340
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
341
|
+
});
|
|
342
|
+
res.end(result.body);
|
|
343
|
+
}
|
|
344
|
+
catch (err) {
|
|
345
|
+
if (!res.headersSent) {
|
|
346
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
347
|
+
res.end(JSON.stringify({
|
|
348
|
+
error: err instanceof Error ? err.message : String(err),
|
|
349
|
+
}));
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
})();
|
|
353
|
+
return true;
|
|
354
|
+
}
|
|
355
|
+
// ── GitHub MCP connector routes ─────────────────────────────────────
|
|
356
|
+
if (parsedUrl.pathname === "/connections/github/auth" &&
|
|
357
|
+
req.method === "GET") {
|
|
358
|
+
void (async () => {
|
|
359
|
+
try {
|
|
360
|
+
const { handleGithubAuthorize } = await import("./connectors/github.js");
|
|
361
|
+
const result = await handleGithubAuthorize();
|
|
362
|
+
if (result.redirect) {
|
|
363
|
+
res.writeHead(302, { Location: result.redirect });
|
|
364
|
+
res.end();
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
res.writeHead(result.status, {
|
|
368
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
369
|
+
});
|
|
370
|
+
res.end(result.body);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
catch (err) {
|
|
374
|
+
if (!res.headersSent) {
|
|
375
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
376
|
+
res.end(JSON.stringify({
|
|
377
|
+
error: err instanceof Error ? err.message : String(err),
|
|
378
|
+
}));
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
})();
|
|
382
|
+
return true;
|
|
383
|
+
}
|
|
384
|
+
if (parsedUrl.pathname === "/connections/github/test" &&
|
|
385
|
+
req.method === "POST") {
|
|
386
|
+
void (async () => {
|
|
387
|
+
try {
|
|
388
|
+
const { handleGithubTest } = await import("./connectors/github.js");
|
|
389
|
+
const result = await handleGithubTest();
|
|
390
|
+
res.writeHead(result.status, {
|
|
391
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
392
|
+
});
|
|
393
|
+
res.end(result.body);
|
|
394
|
+
}
|
|
395
|
+
catch (err) {
|
|
396
|
+
if (!res.headersSent) {
|
|
397
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
398
|
+
res.end(JSON.stringify({
|
|
399
|
+
error: err instanceof Error ? err.message : String(err),
|
|
400
|
+
}));
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
})();
|
|
404
|
+
return true;
|
|
405
|
+
}
|
|
406
|
+
if (parsedUrl.pathname === "/connections/github" && req.method === "DELETE") {
|
|
407
|
+
void (async () => {
|
|
408
|
+
try {
|
|
409
|
+
const { handleGithubDisconnect } = await import("./connectors/github.js");
|
|
410
|
+
const result = await handleGithubDisconnect();
|
|
411
|
+
res.writeHead(result.status, {
|
|
412
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
413
|
+
});
|
|
414
|
+
res.end(result.body);
|
|
415
|
+
}
|
|
416
|
+
catch (err) {
|
|
417
|
+
if (!res.headersSent) {
|
|
418
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
419
|
+
res.end(JSON.stringify({
|
|
420
|
+
error: err instanceof Error ? err.message : String(err),
|
|
421
|
+
}));
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
})();
|
|
425
|
+
return true;
|
|
426
|
+
}
|
|
427
|
+
// ── Sentry MCP connector routes ─────────────────────────────────────
|
|
428
|
+
if (parsedUrl.pathname === "/connections/sentry/auth" &&
|
|
429
|
+
req.method === "GET") {
|
|
430
|
+
void (async () => {
|
|
431
|
+
try {
|
|
432
|
+
const { handleSentryAuthorize } = await import("./connectors/sentry.js");
|
|
433
|
+
const result = await handleSentryAuthorize();
|
|
434
|
+
if (result.redirect) {
|
|
435
|
+
res.writeHead(302, { Location: result.redirect });
|
|
436
|
+
res.end();
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
439
|
+
res.writeHead(result.status, {
|
|
440
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
441
|
+
});
|
|
442
|
+
res.end(result.body);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
catch (err) {
|
|
446
|
+
if (!res.headersSent) {
|
|
447
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
448
|
+
res.end(JSON.stringify({
|
|
449
|
+
error: err instanceof Error ? err.message : String(err),
|
|
450
|
+
}));
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
})();
|
|
454
|
+
return true;
|
|
455
|
+
}
|
|
456
|
+
if (parsedUrl.pathname === "/connections/sentry/callback" &&
|
|
457
|
+
req.method === "GET") {
|
|
458
|
+
void (async () => {
|
|
459
|
+
try {
|
|
460
|
+
const { handleSentryCallback } = await import("./connectors/sentry.js");
|
|
461
|
+
const code = parsedUrl.searchParams.get("code");
|
|
462
|
+
const state = parsedUrl.searchParams.get("state");
|
|
463
|
+
const error = parsedUrl.searchParams.get("error");
|
|
464
|
+
const result = await handleSentryCallback(code, state, error);
|
|
465
|
+
res.writeHead(result.status, {
|
|
466
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
467
|
+
});
|
|
468
|
+
res.end(result.body);
|
|
469
|
+
}
|
|
470
|
+
catch (err) {
|
|
471
|
+
if (!res.headersSent) {
|
|
472
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
473
|
+
res.end(JSON.stringify({
|
|
474
|
+
error: err instanceof Error ? err.message : String(err),
|
|
475
|
+
}));
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
})();
|
|
479
|
+
return true;
|
|
480
|
+
}
|
|
481
|
+
if (parsedUrl.pathname === "/connections/sentry/test" &&
|
|
482
|
+
req.method === "POST") {
|
|
483
|
+
void (async () => {
|
|
484
|
+
try {
|
|
485
|
+
const { handleSentryTest } = await import("./connectors/sentry.js");
|
|
486
|
+
const result = await handleSentryTest();
|
|
487
|
+
res.writeHead(result.status, {
|
|
488
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
489
|
+
});
|
|
490
|
+
res.end(result.body);
|
|
491
|
+
}
|
|
492
|
+
catch (err) {
|
|
493
|
+
if (!res.headersSent) {
|
|
494
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
495
|
+
res.end(JSON.stringify({
|
|
496
|
+
error: err instanceof Error ? err.message : String(err),
|
|
497
|
+
}));
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
})();
|
|
501
|
+
return true;
|
|
502
|
+
}
|
|
503
|
+
if (parsedUrl.pathname === "/connections/sentry" && req.method === "DELETE") {
|
|
504
|
+
void (async () => {
|
|
505
|
+
try {
|
|
506
|
+
const { handleSentryDisconnect } = await import("./connectors/sentry.js");
|
|
507
|
+
const result = await handleSentryDisconnect();
|
|
508
|
+
res.writeHead(result.status, {
|
|
509
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
510
|
+
});
|
|
511
|
+
res.end(result.body);
|
|
512
|
+
}
|
|
513
|
+
catch (err) {
|
|
514
|
+
if (!res.headersSent) {
|
|
515
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
516
|
+
res.end(JSON.stringify({
|
|
517
|
+
error: err instanceof Error ? err.message : String(err),
|
|
518
|
+
}));
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
})();
|
|
522
|
+
return true;
|
|
523
|
+
}
|
|
524
|
+
// ── Linear MCP connector routes ─────────────────────────────────────
|
|
525
|
+
if (parsedUrl.pathname === "/connections/linear/auth" &&
|
|
526
|
+
req.method === "GET") {
|
|
527
|
+
void (async () => {
|
|
528
|
+
try {
|
|
529
|
+
const { handleLinearAuthorize } = await import("./connectors/linear.js");
|
|
530
|
+
const result = await handleLinearAuthorize();
|
|
531
|
+
if (result.redirect) {
|
|
532
|
+
res.writeHead(302, { Location: result.redirect });
|
|
533
|
+
res.end();
|
|
534
|
+
}
|
|
535
|
+
else {
|
|
536
|
+
res.writeHead(result.status, {
|
|
537
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
538
|
+
});
|
|
539
|
+
res.end(result.body);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
catch (err) {
|
|
543
|
+
if (!res.headersSent) {
|
|
544
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
545
|
+
res.end(JSON.stringify({
|
|
546
|
+
error: err instanceof Error ? err.message : String(err),
|
|
547
|
+
}));
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
})();
|
|
551
|
+
return true;
|
|
552
|
+
}
|
|
553
|
+
if (parsedUrl.pathname === "/connections/linear/callback" &&
|
|
554
|
+
req.method === "GET") {
|
|
555
|
+
void (async () => {
|
|
556
|
+
try {
|
|
557
|
+
const { handleLinearCallback } = await import("./connectors/linear.js");
|
|
558
|
+
const code = parsedUrl.searchParams.get("code");
|
|
559
|
+
const state = parsedUrl.searchParams.get("state");
|
|
560
|
+
const error = parsedUrl.searchParams.get("error");
|
|
561
|
+
const result = await handleLinearCallback(code, state, error);
|
|
562
|
+
res.writeHead(result.status, {
|
|
563
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
564
|
+
});
|
|
565
|
+
res.end(result.body);
|
|
566
|
+
}
|
|
567
|
+
catch (err) {
|
|
568
|
+
if (!res.headersSent) {
|
|
569
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
570
|
+
res.end(JSON.stringify({
|
|
571
|
+
error: err instanceof Error ? err.message : String(err),
|
|
572
|
+
}));
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
})();
|
|
576
|
+
return true;
|
|
577
|
+
}
|
|
578
|
+
if (parsedUrl.pathname === "/connections/linear/test" &&
|
|
579
|
+
req.method === "POST") {
|
|
580
|
+
void (async () => {
|
|
581
|
+
try {
|
|
582
|
+
const { handleLinearTest } = await import("./connectors/linear.js");
|
|
583
|
+
const result = await handleLinearTest();
|
|
584
|
+
res.writeHead(result.status, {
|
|
585
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
586
|
+
});
|
|
587
|
+
res.end(result.body);
|
|
588
|
+
}
|
|
589
|
+
catch (err) {
|
|
590
|
+
if (!res.headersSent) {
|
|
591
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
592
|
+
res.end(JSON.stringify({
|
|
593
|
+
error: err instanceof Error ? err.message : String(err),
|
|
594
|
+
}));
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
})();
|
|
598
|
+
return true;
|
|
599
|
+
}
|
|
600
|
+
if (parsedUrl.pathname === "/connections/linear" && req.method === "DELETE") {
|
|
601
|
+
void (async () => {
|
|
602
|
+
try {
|
|
603
|
+
const { handleLinearDisconnect } = await import("./connectors/linear.js");
|
|
604
|
+
const result = await handleLinearDisconnect();
|
|
605
|
+
res.writeHead(result.status, {
|
|
606
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
607
|
+
});
|
|
608
|
+
res.end(result.body);
|
|
609
|
+
}
|
|
610
|
+
catch (err) {
|
|
611
|
+
if (!res.headersSent) {
|
|
612
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
613
|
+
res.end(JSON.stringify({
|
|
614
|
+
error: err instanceof Error ? err.message : String(err),
|
|
615
|
+
}));
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
})();
|
|
619
|
+
return true;
|
|
620
|
+
}
|
|
621
|
+
// ── Slack connector routes ──────────────────────────────────────
|
|
622
|
+
if ((parsedUrl.pathname === "/connections/slack/auth" ||
|
|
623
|
+
parsedUrl.pathname === "/connections/slack/authorize") &&
|
|
624
|
+
req.method === "GET") {
|
|
625
|
+
void (async () => {
|
|
626
|
+
try {
|
|
627
|
+
const { handleSlackAuthorize } = await import("./connectors/slack.js");
|
|
628
|
+
const result = handleSlackAuthorize();
|
|
629
|
+
if (result.redirect) {
|
|
630
|
+
res.writeHead(302, { Location: result.redirect });
|
|
631
|
+
res.end();
|
|
632
|
+
}
|
|
633
|
+
else {
|
|
634
|
+
res.writeHead(result.status, {
|
|
635
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
636
|
+
});
|
|
637
|
+
res.end(result.body);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
catch (err) {
|
|
641
|
+
if (!res.headersSent) {
|
|
642
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
643
|
+
res.end(JSON.stringify({
|
|
644
|
+
error: err instanceof Error ? err.message : String(err),
|
|
645
|
+
}));
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
})();
|
|
649
|
+
return true;
|
|
650
|
+
}
|
|
651
|
+
if (parsedUrl.pathname === "/connections/slack/test" &&
|
|
652
|
+
req.method === "POST") {
|
|
653
|
+
void (async () => {
|
|
654
|
+
try {
|
|
655
|
+
const { handleSlackTest } = await import("./connectors/slack.js");
|
|
656
|
+
const result = await handleSlackTest();
|
|
657
|
+
res.writeHead(result.status, {
|
|
658
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
659
|
+
});
|
|
660
|
+
res.end(result.body);
|
|
661
|
+
}
|
|
662
|
+
catch (err) {
|
|
663
|
+
if (!res.headersSent) {
|
|
664
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
665
|
+
res.end(JSON.stringify({
|
|
666
|
+
error: err instanceof Error ? err.message : String(err),
|
|
667
|
+
}));
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
})();
|
|
671
|
+
return true;
|
|
672
|
+
}
|
|
673
|
+
if (parsedUrl.pathname === "/connections/slack" && req.method === "DELETE") {
|
|
674
|
+
void (async () => {
|
|
675
|
+
try {
|
|
676
|
+
const { handleSlackDisconnect } = await import("./connectors/slack.js");
|
|
677
|
+
const result = handleSlackDisconnect();
|
|
678
|
+
res.writeHead(result.status, {
|
|
679
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
680
|
+
});
|
|
681
|
+
res.end(result.body);
|
|
682
|
+
}
|
|
683
|
+
catch (err) {
|
|
684
|
+
if (!res.headersSent) {
|
|
685
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
686
|
+
res.end(JSON.stringify({
|
|
687
|
+
error: err instanceof Error ? err.message : String(err),
|
|
688
|
+
}));
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
})();
|
|
692
|
+
return true;
|
|
693
|
+
}
|
|
694
|
+
// ── Discord connector routes ───────────────────────────────────
|
|
695
|
+
if ((parsedUrl.pathname === "/connections/discord/auth" ||
|
|
696
|
+
parsedUrl.pathname === "/connections/discord/authorize") &&
|
|
697
|
+
req.method === "GET") {
|
|
698
|
+
void (async () => {
|
|
699
|
+
try {
|
|
700
|
+
const { handleDiscordAuthorize } = await import("./connectors/discord.js");
|
|
701
|
+
const result = handleDiscordAuthorize();
|
|
702
|
+
if (result.redirect) {
|
|
703
|
+
res.writeHead(302, { Location: result.redirect });
|
|
704
|
+
res.end();
|
|
705
|
+
}
|
|
706
|
+
else {
|
|
707
|
+
res.writeHead(result.status, {
|
|
708
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
709
|
+
});
|
|
710
|
+
res.end(result.body);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
catch (err) {
|
|
714
|
+
if (!res.headersSent) {
|
|
715
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
716
|
+
res.end(JSON.stringify({
|
|
717
|
+
error: err instanceof Error ? err.message : String(err),
|
|
718
|
+
}));
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
})();
|
|
722
|
+
return true;
|
|
723
|
+
}
|
|
724
|
+
if (parsedUrl.pathname === "/connections/discord/callback" &&
|
|
725
|
+
req.method === "GET") {
|
|
726
|
+
void (async () => {
|
|
727
|
+
try {
|
|
728
|
+
const { handleDiscordCallback } = await import("./connectors/discord.js");
|
|
729
|
+
const code = parsedUrl.searchParams.get("code");
|
|
730
|
+
const state = parsedUrl.searchParams.get("state");
|
|
731
|
+
const error = parsedUrl.searchParams.get("error");
|
|
732
|
+
const result = await handleDiscordCallback(code, state, error);
|
|
733
|
+
res.writeHead(result.status, {
|
|
734
|
+
"Content-Type": result.contentType ?? "text/html",
|
|
735
|
+
});
|
|
736
|
+
res.end(result.body);
|
|
737
|
+
}
|
|
738
|
+
catch (err) {
|
|
739
|
+
if (!res.headersSent) {
|
|
740
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
741
|
+
res.end(JSON.stringify({
|
|
742
|
+
error: err instanceof Error ? err.message : String(err),
|
|
743
|
+
}));
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
})();
|
|
747
|
+
return true;
|
|
748
|
+
}
|
|
749
|
+
if (parsedUrl.pathname === "/connections/discord/test" &&
|
|
750
|
+
req.method === "POST") {
|
|
751
|
+
void (async () => {
|
|
752
|
+
try {
|
|
753
|
+
const { handleDiscordTest } = await import("./connectors/discord.js");
|
|
754
|
+
const result = await handleDiscordTest();
|
|
755
|
+
res.writeHead(result.status, {
|
|
756
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
757
|
+
});
|
|
758
|
+
res.end(result.body);
|
|
759
|
+
}
|
|
760
|
+
catch (err) {
|
|
761
|
+
if (!res.headersSent) {
|
|
762
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
763
|
+
res.end(JSON.stringify({
|
|
764
|
+
error: err instanceof Error ? err.message : String(err),
|
|
765
|
+
}));
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
})();
|
|
769
|
+
return true;
|
|
770
|
+
}
|
|
771
|
+
if (parsedUrl.pathname === "/connections/discord" &&
|
|
772
|
+
req.method === "DELETE") {
|
|
773
|
+
void (async () => {
|
|
774
|
+
try {
|
|
775
|
+
const { handleDiscordDisconnect } = await import("./connectors/discord.js");
|
|
776
|
+
const result = await handleDiscordDisconnect();
|
|
777
|
+
res.writeHead(result.status, {
|
|
778
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
779
|
+
});
|
|
780
|
+
res.end(result.body);
|
|
781
|
+
}
|
|
782
|
+
catch (err) {
|
|
783
|
+
if (!res.headersSent) {
|
|
784
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
785
|
+
res.end(JSON.stringify({
|
|
786
|
+
error: err instanceof Error ? err.message : String(err),
|
|
787
|
+
}));
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
})();
|
|
791
|
+
return true;
|
|
792
|
+
}
|
|
793
|
+
// ── Asana connector routes ─────────────────────────────────────
|
|
794
|
+
if ((parsedUrl.pathname === "/connections/asana/auth" ||
|
|
795
|
+
parsedUrl.pathname === "/connections/asana/authorize") &&
|
|
796
|
+
req.method === "GET") {
|
|
797
|
+
void (async () => {
|
|
798
|
+
try {
|
|
799
|
+
const { handleAsanaAuthorize } = await import("./connectors/asana.js");
|
|
800
|
+
const result = handleAsanaAuthorize();
|
|
801
|
+
if (result.redirect) {
|
|
802
|
+
res.writeHead(302, { Location: result.redirect });
|
|
803
|
+
res.end();
|
|
804
|
+
}
|
|
805
|
+
else {
|
|
806
|
+
res.writeHead(result.status, {
|
|
807
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
808
|
+
});
|
|
809
|
+
res.end(result.body);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
catch (err) {
|
|
813
|
+
if (!res.headersSent) {
|
|
814
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
815
|
+
res.end(JSON.stringify({
|
|
816
|
+
error: err instanceof Error ? err.message : String(err),
|
|
817
|
+
}));
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
})();
|
|
821
|
+
return true;
|
|
822
|
+
}
|
|
823
|
+
if (parsedUrl.pathname === "/connections/asana/callback" &&
|
|
824
|
+
req.method === "GET") {
|
|
825
|
+
void (async () => {
|
|
826
|
+
try {
|
|
827
|
+
const { handleAsanaCallback } = await import("./connectors/asana.js");
|
|
828
|
+
const code = parsedUrl.searchParams.get("code");
|
|
829
|
+
const state = parsedUrl.searchParams.get("state");
|
|
830
|
+
const error = parsedUrl.searchParams.get("error");
|
|
831
|
+
const result = await handleAsanaCallback(code, state, error);
|
|
832
|
+
res.writeHead(result.status, {
|
|
833
|
+
"Content-Type": result.contentType ?? "text/html",
|
|
834
|
+
});
|
|
835
|
+
res.end(result.body);
|
|
836
|
+
}
|
|
837
|
+
catch (err) {
|
|
838
|
+
if (!res.headersSent) {
|
|
839
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
840
|
+
res.end(JSON.stringify({
|
|
841
|
+
error: err instanceof Error ? err.message : String(err),
|
|
842
|
+
}));
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
})();
|
|
846
|
+
return true;
|
|
847
|
+
}
|
|
848
|
+
if (parsedUrl.pathname === "/connections/asana/test" &&
|
|
849
|
+
req.method === "POST") {
|
|
850
|
+
void (async () => {
|
|
851
|
+
try {
|
|
852
|
+
const { handleAsanaTest } = await import("./connectors/asana.js");
|
|
853
|
+
const result = await handleAsanaTest();
|
|
854
|
+
res.writeHead(result.status, {
|
|
855
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
856
|
+
});
|
|
857
|
+
res.end(result.body);
|
|
858
|
+
}
|
|
859
|
+
catch (err) {
|
|
860
|
+
if (!res.headersSent) {
|
|
861
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
862
|
+
res.end(JSON.stringify({
|
|
863
|
+
error: err instanceof Error ? err.message : String(err),
|
|
864
|
+
}));
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
})();
|
|
868
|
+
return true;
|
|
869
|
+
}
|
|
870
|
+
if (parsedUrl.pathname === "/connections/asana" && req.method === "DELETE") {
|
|
871
|
+
void (async () => {
|
|
872
|
+
try {
|
|
873
|
+
const { handleAsanaDisconnect } = await import("./connectors/asana.js");
|
|
874
|
+
const result = await handleAsanaDisconnect();
|
|
875
|
+
res.writeHead(result.status, {
|
|
876
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
877
|
+
});
|
|
878
|
+
res.end(result.body);
|
|
879
|
+
}
|
|
880
|
+
catch (err) {
|
|
881
|
+
if (!res.headersSent) {
|
|
882
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
883
|
+
res.end(JSON.stringify({
|
|
884
|
+
error: err instanceof Error ? err.message : String(err),
|
|
885
|
+
}));
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
})();
|
|
889
|
+
return true;
|
|
890
|
+
}
|
|
891
|
+
// ── GitLab connector routes ────────────────────────────────────
|
|
892
|
+
if ((parsedUrl.pathname === "/connections/gitlab/auth" ||
|
|
893
|
+
parsedUrl.pathname === "/connections/gitlab/authorize") &&
|
|
894
|
+
req.method === "GET") {
|
|
895
|
+
void (async () => {
|
|
896
|
+
try {
|
|
897
|
+
const { handleGitLabAuthorize } = await import("./connectors/gitlab.js");
|
|
898
|
+
const result = handleGitLabAuthorize();
|
|
899
|
+
if (result.redirect) {
|
|
900
|
+
res.writeHead(302, { Location: result.redirect });
|
|
901
|
+
res.end();
|
|
902
|
+
}
|
|
903
|
+
else {
|
|
904
|
+
res.writeHead(result.status, {
|
|
905
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
906
|
+
});
|
|
907
|
+
res.end(result.body);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
catch (err) {
|
|
911
|
+
if (!res.headersSent) {
|
|
912
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
913
|
+
res.end(JSON.stringify({
|
|
914
|
+
error: err instanceof Error ? err.message : String(err),
|
|
915
|
+
}));
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
})();
|
|
919
|
+
return true;
|
|
920
|
+
}
|
|
921
|
+
if (parsedUrl.pathname === "/connections/gitlab/callback" &&
|
|
922
|
+
req.method === "GET") {
|
|
923
|
+
void (async () => {
|
|
924
|
+
try {
|
|
925
|
+
const { handleGitLabCallback } = await import("./connectors/gitlab.js");
|
|
926
|
+
const code = parsedUrl.searchParams.get("code");
|
|
927
|
+
const state = parsedUrl.searchParams.get("state");
|
|
928
|
+
const error = parsedUrl.searchParams.get("error");
|
|
929
|
+
const result = await handleGitLabCallback(code, state, error);
|
|
930
|
+
res.writeHead(result.status, {
|
|
931
|
+
"Content-Type": result.contentType ?? "text/html",
|
|
932
|
+
});
|
|
933
|
+
res.end(result.body);
|
|
934
|
+
}
|
|
935
|
+
catch (err) {
|
|
936
|
+
if (!res.headersSent) {
|
|
937
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
938
|
+
res.end(JSON.stringify({
|
|
939
|
+
error: err instanceof Error ? err.message : String(err),
|
|
940
|
+
}));
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
})();
|
|
944
|
+
return true;
|
|
945
|
+
}
|
|
946
|
+
if (parsedUrl.pathname === "/connections/gitlab/test" &&
|
|
947
|
+
req.method === "POST") {
|
|
948
|
+
void (async () => {
|
|
949
|
+
try {
|
|
950
|
+
const { handleGitLabTest } = await import("./connectors/gitlab.js");
|
|
951
|
+
const result = await handleGitLabTest();
|
|
952
|
+
res.writeHead(result.status, {
|
|
953
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
954
|
+
});
|
|
955
|
+
res.end(result.body);
|
|
956
|
+
}
|
|
957
|
+
catch (err) {
|
|
958
|
+
if (!res.headersSent) {
|
|
959
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
960
|
+
res.end(JSON.stringify({
|
|
961
|
+
error: err instanceof Error ? err.message : String(err),
|
|
962
|
+
}));
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
})();
|
|
966
|
+
return true;
|
|
967
|
+
}
|
|
968
|
+
if (parsedUrl.pathname === "/connections/gitlab" && req.method === "DELETE") {
|
|
969
|
+
void (async () => {
|
|
970
|
+
try {
|
|
971
|
+
const { handleGitLabDisconnect } = await import("./connectors/gitlab.js");
|
|
972
|
+
const result = await handleGitLabDisconnect();
|
|
973
|
+
res.writeHead(result.status, {
|
|
974
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
975
|
+
});
|
|
976
|
+
res.end(result.body);
|
|
977
|
+
}
|
|
978
|
+
catch (err) {
|
|
979
|
+
if (!res.headersSent) {
|
|
980
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
981
|
+
res.end(JSON.stringify({
|
|
982
|
+
error: err instanceof Error ? err.message : String(err),
|
|
983
|
+
}));
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
})();
|
|
987
|
+
return true;
|
|
988
|
+
}
|
|
989
|
+
// ── Notion routes ──────────────────────────────────────────────
|
|
990
|
+
if (parsedUrl.pathname === "/connections/notion/connect" &&
|
|
991
|
+
req.method === "POST") {
|
|
992
|
+
void dispatchConnectorConnect(req, res, async () => {
|
|
993
|
+
const m = await import("./connectors/notion.js");
|
|
994
|
+
return m.handleNotionConnect;
|
|
995
|
+
});
|
|
996
|
+
return true;
|
|
997
|
+
}
|
|
998
|
+
if (parsedUrl.pathname === "/connections/notion/test" &&
|
|
999
|
+
req.method === "POST") {
|
|
1000
|
+
void (async () => {
|
|
1001
|
+
try {
|
|
1002
|
+
const { handleNotionTest } = await import("./connectors/notion.js");
|
|
1003
|
+
const result = await handleNotionTest();
|
|
1004
|
+
res.writeHead(result.status, {
|
|
1005
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1006
|
+
});
|
|
1007
|
+
res.end(result.body);
|
|
1008
|
+
}
|
|
1009
|
+
catch (err) {
|
|
1010
|
+
if (!res.headersSent) {
|
|
1011
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1012
|
+
res.end(JSON.stringify({
|
|
1013
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1014
|
+
}));
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
})();
|
|
1018
|
+
return true;
|
|
1019
|
+
}
|
|
1020
|
+
if (parsedUrl.pathname === "/connections/notion" && req.method === "DELETE") {
|
|
1021
|
+
void (async () => {
|
|
1022
|
+
try {
|
|
1023
|
+
const { handleNotionDisconnect } = await import("./connectors/notion.js");
|
|
1024
|
+
const result = handleNotionDisconnect();
|
|
1025
|
+
res.writeHead(result.status, {
|
|
1026
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1027
|
+
});
|
|
1028
|
+
res.end(result.body);
|
|
1029
|
+
}
|
|
1030
|
+
catch (err) {
|
|
1031
|
+
if (!res.headersSent) {
|
|
1032
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1033
|
+
res.end(JSON.stringify({
|
|
1034
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1035
|
+
}));
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
})();
|
|
1039
|
+
return true;
|
|
1040
|
+
}
|
|
1041
|
+
// ── Confluence routes ───────────────────────────────────────────
|
|
1042
|
+
if (parsedUrl.pathname === "/connections/confluence/connect" &&
|
|
1043
|
+
req.method === "POST") {
|
|
1044
|
+
void dispatchConnectorConnect(req, res, async () => {
|
|
1045
|
+
const m = await import("./connectors/confluence.js");
|
|
1046
|
+
return m.handleConfluenceConnect;
|
|
1047
|
+
});
|
|
1048
|
+
return true;
|
|
1049
|
+
}
|
|
1050
|
+
if (parsedUrl.pathname === "/connections/confluence/test" &&
|
|
1051
|
+
req.method === "POST") {
|
|
1052
|
+
void (async () => {
|
|
1053
|
+
try {
|
|
1054
|
+
const { handleConfluenceTest } = await import("./connectors/confluence.js");
|
|
1055
|
+
const result = await handleConfluenceTest();
|
|
1056
|
+
res.writeHead(result.status, {
|
|
1057
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1058
|
+
});
|
|
1059
|
+
res.end(result.body);
|
|
1060
|
+
}
|
|
1061
|
+
catch (err) {
|
|
1062
|
+
if (!res.headersSent) {
|
|
1063
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1064
|
+
res.end(JSON.stringify({
|
|
1065
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1066
|
+
}));
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
})();
|
|
1070
|
+
return true;
|
|
1071
|
+
}
|
|
1072
|
+
if (parsedUrl.pathname === "/connections/confluence" &&
|
|
1073
|
+
req.method === "DELETE") {
|
|
1074
|
+
void (async () => {
|
|
1075
|
+
try {
|
|
1076
|
+
const { handleConfluenceDisconnect } = await import("./connectors/confluence.js");
|
|
1077
|
+
const result = handleConfluenceDisconnect();
|
|
1078
|
+
res.writeHead(result.status, {
|
|
1079
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1080
|
+
});
|
|
1081
|
+
res.end(result.body);
|
|
1082
|
+
}
|
|
1083
|
+
catch (err) {
|
|
1084
|
+
if (!res.headersSent) {
|
|
1085
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1086
|
+
res.end(JSON.stringify({
|
|
1087
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1088
|
+
}));
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
})();
|
|
1092
|
+
return true;
|
|
1093
|
+
}
|
|
1094
|
+
// ── Zendesk routes ──────────────────────────────────────────────
|
|
1095
|
+
if (parsedUrl.pathname === "/connections/zendesk/connect" &&
|
|
1096
|
+
req.method === "POST") {
|
|
1097
|
+
void dispatchConnectorConnect(req, res, async () => {
|
|
1098
|
+
const m = await import("./connectors/zendesk.js");
|
|
1099
|
+
return m.handleZendeskConnect;
|
|
1100
|
+
});
|
|
1101
|
+
return true;
|
|
1102
|
+
}
|
|
1103
|
+
if (parsedUrl.pathname === "/connections/zendesk/test" &&
|
|
1104
|
+
req.method === "POST") {
|
|
1105
|
+
void (async () => {
|
|
1106
|
+
try {
|
|
1107
|
+
const { handleZendeskTest } = await import("./connectors/zendesk.js");
|
|
1108
|
+
const result = await handleZendeskTest();
|
|
1109
|
+
res.writeHead(result.status, {
|
|
1110
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1111
|
+
});
|
|
1112
|
+
res.end(result.body);
|
|
1113
|
+
}
|
|
1114
|
+
catch (err) {
|
|
1115
|
+
if (!res.headersSent) {
|
|
1116
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1117
|
+
res.end(JSON.stringify({
|
|
1118
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1119
|
+
}));
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
})();
|
|
1123
|
+
return true;
|
|
1124
|
+
}
|
|
1125
|
+
if (parsedUrl.pathname === "/connections/zendesk" &&
|
|
1126
|
+
req.method === "DELETE") {
|
|
1127
|
+
void (async () => {
|
|
1128
|
+
try {
|
|
1129
|
+
const { handleZendeskDisconnect } = await import("./connectors/zendesk.js");
|
|
1130
|
+
const result = handleZendeskDisconnect();
|
|
1131
|
+
res.writeHead(result.status, {
|
|
1132
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1133
|
+
});
|
|
1134
|
+
res.end(result.body);
|
|
1135
|
+
}
|
|
1136
|
+
catch (err) {
|
|
1137
|
+
if (!res.headersSent) {
|
|
1138
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1139
|
+
res.end(JSON.stringify({
|
|
1140
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1141
|
+
}));
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
})();
|
|
1145
|
+
return true;
|
|
1146
|
+
}
|
|
1147
|
+
// ── Intercom routes ─────────────────────────────────────────────
|
|
1148
|
+
if (parsedUrl.pathname === "/connections/intercom/connect" &&
|
|
1149
|
+
req.method === "POST") {
|
|
1150
|
+
void dispatchConnectorConnect(req, res, async () => {
|
|
1151
|
+
const m = await import("./connectors/intercom.js");
|
|
1152
|
+
return m.handleIntercomConnect;
|
|
1153
|
+
});
|
|
1154
|
+
return true;
|
|
1155
|
+
}
|
|
1156
|
+
if (parsedUrl.pathname === "/connections/intercom/test" &&
|
|
1157
|
+
req.method === "POST") {
|
|
1158
|
+
void (async () => {
|
|
1159
|
+
try {
|
|
1160
|
+
const { handleIntercomTest } = await import("./connectors/intercom.js");
|
|
1161
|
+
const result = await handleIntercomTest();
|
|
1162
|
+
res.writeHead(result.status, {
|
|
1163
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1164
|
+
});
|
|
1165
|
+
res.end(result.body);
|
|
1166
|
+
}
|
|
1167
|
+
catch (err) {
|
|
1168
|
+
if (!res.headersSent) {
|
|
1169
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1170
|
+
res.end(JSON.stringify({
|
|
1171
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1172
|
+
}));
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
})();
|
|
1176
|
+
return true;
|
|
1177
|
+
}
|
|
1178
|
+
if (parsedUrl.pathname === "/connections/intercom" &&
|
|
1179
|
+
req.method === "DELETE") {
|
|
1180
|
+
void (async () => {
|
|
1181
|
+
try {
|
|
1182
|
+
const { handleIntercomDisconnect } = await import("./connectors/intercom.js");
|
|
1183
|
+
const result = handleIntercomDisconnect();
|
|
1184
|
+
res.writeHead(result.status, {
|
|
1185
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1186
|
+
});
|
|
1187
|
+
res.end(result.body);
|
|
1188
|
+
}
|
|
1189
|
+
catch (err) {
|
|
1190
|
+
if (!res.headersSent) {
|
|
1191
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1192
|
+
res.end(JSON.stringify({
|
|
1193
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1194
|
+
}));
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
})();
|
|
1198
|
+
return true;
|
|
1199
|
+
}
|
|
1200
|
+
// ── HubSpot routes ─────────────────────────────────────────────
|
|
1201
|
+
if (parsedUrl.pathname === "/connections/hubspot/connect" &&
|
|
1202
|
+
req.method === "POST") {
|
|
1203
|
+
void dispatchConnectorConnect(req, res, async () => {
|
|
1204
|
+
const m = await import("./connectors/hubspot.js");
|
|
1205
|
+
return m.handleHubSpotConnect;
|
|
1206
|
+
});
|
|
1207
|
+
return true;
|
|
1208
|
+
}
|
|
1209
|
+
if (parsedUrl.pathname === "/connections/hubspot/test" &&
|
|
1210
|
+
req.method === "POST") {
|
|
1211
|
+
void (async () => {
|
|
1212
|
+
try {
|
|
1213
|
+
const { handleHubSpotTest } = await import("./connectors/hubspot.js");
|
|
1214
|
+
const result = await handleHubSpotTest();
|
|
1215
|
+
res.writeHead(result.status, {
|
|
1216
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1217
|
+
});
|
|
1218
|
+
res.end(result.body);
|
|
1219
|
+
}
|
|
1220
|
+
catch (err) {
|
|
1221
|
+
if (!res.headersSent) {
|
|
1222
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1223
|
+
res.end(JSON.stringify({
|
|
1224
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1225
|
+
}));
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
})();
|
|
1229
|
+
return true;
|
|
1230
|
+
}
|
|
1231
|
+
if (parsedUrl.pathname === "/connections/hubspot" &&
|
|
1232
|
+
req.method === "DELETE") {
|
|
1233
|
+
void (async () => {
|
|
1234
|
+
try {
|
|
1235
|
+
const { handleHubSpotDisconnect } = await import("./connectors/hubspot.js");
|
|
1236
|
+
const result = handleHubSpotDisconnect();
|
|
1237
|
+
res.writeHead(result.status, {
|
|
1238
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1239
|
+
});
|
|
1240
|
+
res.end(result.body);
|
|
1241
|
+
}
|
|
1242
|
+
catch (err) {
|
|
1243
|
+
if (!res.headersSent) {
|
|
1244
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1245
|
+
res.end(JSON.stringify({
|
|
1246
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1247
|
+
}));
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
})();
|
|
1251
|
+
return true;
|
|
1252
|
+
}
|
|
1253
|
+
// ── Datadog routes ─────────────────────────────────────────────
|
|
1254
|
+
if (parsedUrl.pathname === "/connections/datadog/connect" &&
|
|
1255
|
+
req.method === "POST") {
|
|
1256
|
+
void dispatchConnectorConnect(req, res, async () => {
|
|
1257
|
+
const m = await import("./connectors/datadog.js");
|
|
1258
|
+
return m.handleDatadogConnect;
|
|
1259
|
+
});
|
|
1260
|
+
return true;
|
|
1261
|
+
}
|
|
1262
|
+
if (parsedUrl.pathname === "/connections/datadog/test" &&
|
|
1263
|
+
req.method === "POST") {
|
|
1264
|
+
void (async () => {
|
|
1265
|
+
try {
|
|
1266
|
+
const { handleDatadogTest } = await import("./connectors/datadog.js");
|
|
1267
|
+
const result = await handleDatadogTest();
|
|
1268
|
+
res.writeHead(result.status, {
|
|
1269
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1270
|
+
});
|
|
1271
|
+
res.end(result.body);
|
|
1272
|
+
}
|
|
1273
|
+
catch (err) {
|
|
1274
|
+
if (!res.headersSent) {
|
|
1275
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1276
|
+
res.end(JSON.stringify({
|
|
1277
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1278
|
+
}));
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
})();
|
|
1282
|
+
return true;
|
|
1283
|
+
}
|
|
1284
|
+
if (parsedUrl.pathname === "/connections/datadog" &&
|
|
1285
|
+
req.method === "DELETE") {
|
|
1286
|
+
void (async () => {
|
|
1287
|
+
try {
|
|
1288
|
+
const { handleDatadogDisconnect } = await import("./connectors/datadog.js");
|
|
1289
|
+
const result = handleDatadogDisconnect();
|
|
1290
|
+
res.writeHead(result.status, {
|
|
1291
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1292
|
+
});
|
|
1293
|
+
res.end(result.body);
|
|
1294
|
+
}
|
|
1295
|
+
catch (err) {
|
|
1296
|
+
if (!res.headersSent) {
|
|
1297
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1298
|
+
res.end(JSON.stringify({
|
|
1299
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1300
|
+
}));
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
})();
|
|
1304
|
+
return true;
|
|
1305
|
+
}
|
|
1306
|
+
// ── PagerDuty routes ───────────────────────────────────────────
|
|
1307
|
+
if (parsedUrl.pathname === "/connections/pagerduty/connect" &&
|
|
1308
|
+
req.method === "POST") {
|
|
1309
|
+
void dispatchConnectorConnect(req, res, async () => {
|
|
1310
|
+
const m = await import("./connectors/pagerduty.js");
|
|
1311
|
+
return m.handlePagerDutyConnect;
|
|
1312
|
+
});
|
|
1313
|
+
return true;
|
|
1314
|
+
}
|
|
1315
|
+
if (parsedUrl.pathname === "/connections/pagerduty/test" &&
|
|
1316
|
+
req.method === "POST") {
|
|
1317
|
+
void (async () => {
|
|
1318
|
+
try {
|
|
1319
|
+
const { handlePagerDutyTest } = await import("./connectors/pagerduty.js");
|
|
1320
|
+
const result = await handlePagerDutyTest();
|
|
1321
|
+
res.writeHead(result.status, {
|
|
1322
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1323
|
+
});
|
|
1324
|
+
res.end(result.body);
|
|
1325
|
+
}
|
|
1326
|
+
catch (err) {
|
|
1327
|
+
if (!res.headersSent) {
|
|
1328
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1329
|
+
res.end(JSON.stringify({
|
|
1330
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1331
|
+
}));
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
})();
|
|
1335
|
+
return true;
|
|
1336
|
+
}
|
|
1337
|
+
if (parsedUrl.pathname === "/connections/pagerduty" &&
|
|
1338
|
+
req.method === "DELETE") {
|
|
1339
|
+
void (async () => {
|
|
1340
|
+
try {
|
|
1341
|
+
const { handlePagerDutyDisconnect } = await import("./connectors/pagerduty.js");
|
|
1342
|
+
const result = handlePagerDutyDisconnect();
|
|
1343
|
+
res.writeHead(result.status, {
|
|
1344
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1345
|
+
});
|
|
1346
|
+
res.end(result.body);
|
|
1347
|
+
}
|
|
1348
|
+
catch (err) {
|
|
1349
|
+
if (!res.headersSent) {
|
|
1350
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1351
|
+
res.end(JSON.stringify({
|
|
1352
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1353
|
+
}));
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
})();
|
|
1357
|
+
return true;
|
|
1358
|
+
}
|
|
1359
|
+
// ── Stripe routes ───────────────────────────────────────────────
|
|
1360
|
+
if (parsedUrl.pathname === "/connections/stripe/connect" &&
|
|
1361
|
+
req.method === "POST") {
|
|
1362
|
+
void dispatchConnectorConnect(req, res, async () => {
|
|
1363
|
+
const m = await import("./connectors/stripe.js");
|
|
1364
|
+
return m.handleStripeConnect;
|
|
1365
|
+
});
|
|
1366
|
+
return true;
|
|
1367
|
+
}
|
|
1368
|
+
if (parsedUrl.pathname === "/connections/stripe/test" &&
|
|
1369
|
+
req.method === "POST") {
|
|
1370
|
+
void (async () => {
|
|
1371
|
+
try {
|
|
1372
|
+
const { handleStripeTest } = await import("./connectors/stripe.js");
|
|
1373
|
+
const result = await handleStripeTest();
|
|
1374
|
+
res.writeHead(result.status, {
|
|
1375
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1376
|
+
});
|
|
1377
|
+
res.end(result.body);
|
|
1378
|
+
}
|
|
1379
|
+
catch (err) {
|
|
1380
|
+
if (!res.headersSent) {
|
|
1381
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1382
|
+
res.end(JSON.stringify({
|
|
1383
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1384
|
+
}));
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
})();
|
|
1388
|
+
return true;
|
|
1389
|
+
}
|
|
1390
|
+
if (parsedUrl.pathname === "/connections/stripe" && req.method === "DELETE") {
|
|
1391
|
+
void (async () => {
|
|
1392
|
+
try {
|
|
1393
|
+
const { handleStripeDisconnect } = await import("./connectors/stripe.js");
|
|
1394
|
+
const result = handleStripeDisconnect();
|
|
1395
|
+
res.writeHead(result.status, {
|
|
1396
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1397
|
+
});
|
|
1398
|
+
res.end(result.body);
|
|
1399
|
+
}
|
|
1400
|
+
catch (err) {
|
|
1401
|
+
if (!res.headersSent) {
|
|
1402
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1403
|
+
res.end(JSON.stringify({
|
|
1404
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1405
|
+
}));
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
})();
|
|
1409
|
+
return true;
|
|
1410
|
+
}
|
|
1411
|
+
// ── Google Calendar routes ──────────────────────────────────────
|
|
1412
|
+
if (parsedUrl.pathname === "/connections/google-calendar/auth" &&
|
|
1413
|
+
req.method === "GET") {
|
|
1414
|
+
void (async () => {
|
|
1415
|
+
try {
|
|
1416
|
+
const { handleCalendarAuthRedirect } = await import("./connectors/googleCalendar.js");
|
|
1417
|
+
const result = handleCalendarAuthRedirect();
|
|
1418
|
+
if (result.redirect) {
|
|
1419
|
+
res.writeHead(302, { Location: result.redirect });
|
|
1420
|
+
res.end();
|
|
1421
|
+
}
|
|
1422
|
+
else {
|
|
1423
|
+
res.writeHead(result.status, {
|
|
1424
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1425
|
+
});
|
|
1426
|
+
res.end(result.body);
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
catch (err) {
|
|
1430
|
+
if (!res.headersSent) {
|
|
1431
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1432
|
+
res.end(JSON.stringify({
|
|
1433
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1434
|
+
}));
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
})();
|
|
1438
|
+
return true;
|
|
1439
|
+
}
|
|
1440
|
+
if (parsedUrl.pathname === "/connections/google-calendar/callback" &&
|
|
1441
|
+
req.method === "GET") {
|
|
1442
|
+
void (async () => {
|
|
1443
|
+
try {
|
|
1444
|
+
const { handleCalendarCallback } = await import("./connectors/googleCalendar.js");
|
|
1445
|
+
const code = parsedUrl.searchParams.get("code");
|
|
1446
|
+
const state = parsedUrl.searchParams.get("state");
|
|
1447
|
+
const error = parsedUrl.searchParams.get("error");
|
|
1448
|
+
const result = await handleCalendarCallback(code, state, error);
|
|
1449
|
+
res.writeHead(result.status, {
|
|
1450
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1451
|
+
});
|
|
1452
|
+
res.end(result.body);
|
|
1453
|
+
}
|
|
1454
|
+
catch (err) {
|
|
1455
|
+
if (!res.headersSent) {
|
|
1456
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1457
|
+
res.end(JSON.stringify({
|
|
1458
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1459
|
+
}));
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
})();
|
|
1463
|
+
return true;
|
|
1464
|
+
}
|
|
1465
|
+
if (parsedUrl.pathname === "/connections/google-calendar/test" &&
|
|
1466
|
+
req.method === "POST") {
|
|
1467
|
+
void (async () => {
|
|
1468
|
+
try {
|
|
1469
|
+
const { handleCalendarTest } = await import("./connectors/googleCalendar.js");
|
|
1470
|
+
const result = await handleCalendarTest();
|
|
1471
|
+
res.writeHead(result.status, {
|
|
1472
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1473
|
+
});
|
|
1474
|
+
res.end(result.body);
|
|
1475
|
+
}
|
|
1476
|
+
catch (err) {
|
|
1477
|
+
if (!res.headersSent) {
|
|
1478
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1479
|
+
res.end(JSON.stringify({
|
|
1480
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1481
|
+
}));
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
})();
|
|
1485
|
+
return true;
|
|
1486
|
+
}
|
|
1487
|
+
if (parsedUrl.pathname === "/connections/google-calendar" &&
|
|
1488
|
+
req.method === "DELETE") {
|
|
1489
|
+
void (async () => {
|
|
1490
|
+
try {
|
|
1491
|
+
const { handleCalendarDisconnect } = await import("./connectors/googleCalendar.js");
|
|
1492
|
+
const result = await handleCalendarDisconnect();
|
|
1493
|
+
res.writeHead(result.status, {
|
|
1494
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1495
|
+
});
|
|
1496
|
+
res.end(result.body);
|
|
1497
|
+
}
|
|
1498
|
+
catch (err) {
|
|
1499
|
+
if (!res.headersSent) {
|
|
1500
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1501
|
+
res.end(JSON.stringify({
|
|
1502
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1503
|
+
}));
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
})();
|
|
1507
|
+
return true;
|
|
1508
|
+
}
|
|
1509
|
+
// ── Google Drive routes ─────────────────────────────────────────
|
|
1510
|
+
if (parsedUrl.pathname === "/connections/google-drive/auth" &&
|
|
1511
|
+
req.method === "GET") {
|
|
1512
|
+
void (async () => {
|
|
1513
|
+
try {
|
|
1514
|
+
const { handleDriveAuthRedirect } = await import("./connectors/googleDrive.js");
|
|
1515
|
+
const result = handleDriveAuthRedirect();
|
|
1516
|
+
if (result.redirect) {
|
|
1517
|
+
res.writeHead(302, { Location: result.redirect });
|
|
1518
|
+
res.end();
|
|
1519
|
+
}
|
|
1520
|
+
else {
|
|
1521
|
+
res.writeHead(result.status, {
|
|
1522
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1523
|
+
});
|
|
1524
|
+
res.end(result.body);
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
catch (err) {
|
|
1528
|
+
if (!res.headersSent) {
|
|
1529
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1530
|
+
res.end(JSON.stringify({
|
|
1531
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1532
|
+
}));
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
})();
|
|
1536
|
+
return true;
|
|
1537
|
+
}
|
|
1538
|
+
if (parsedUrl.pathname === "/connections/google-drive/callback" &&
|
|
1539
|
+
req.method === "GET") {
|
|
1540
|
+
void (async () => {
|
|
1541
|
+
try {
|
|
1542
|
+
const { handleDriveCallback } = await import("./connectors/googleDrive.js");
|
|
1543
|
+
const code = parsedUrl.searchParams.get("code");
|
|
1544
|
+
const state = parsedUrl.searchParams.get("state");
|
|
1545
|
+
const error = parsedUrl.searchParams.get("error");
|
|
1546
|
+
const result = await handleDriveCallback(code, state, error);
|
|
1547
|
+
res.writeHead(result.status, {
|
|
1548
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1549
|
+
});
|
|
1550
|
+
res.end(result.body);
|
|
1551
|
+
}
|
|
1552
|
+
catch (err) {
|
|
1553
|
+
if (!res.headersSent) {
|
|
1554
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1555
|
+
res.end(JSON.stringify({
|
|
1556
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1557
|
+
}));
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
})();
|
|
1561
|
+
return true;
|
|
1562
|
+
}
|
|
1563
|
+
if (parsedUrl.pathname === "/connections/google-drive/test" &&
|
|
1564
|
+
req.method === "POST") {
|
|
1565
|
+
void (async () => {
|
|
1566
|
+
try {
|
|
1567
|
+
const { handleDriveTest } = await import("./connectors/googleDrive.js");
|
|
1568
|
+
const result = await handleDriveTest();
|
|
1569
|
+
res.writeHead(result.status, {
|
|
1570
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1571
|
+
});
|
|
1572
|
+
res.end(result.body);
|
|
1573
|
+
}
|
|
1574
|
+
catch (err) {
|
|
1575
|
+
if (!res.headersSent) {
|
|
1576
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1577
|
+
res.end(JSON.stringify({
|
|
1578
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1579
|
+
}));
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
})();
|
|
1583
|
+
return true;
|
|
1584
|
+
}
|
|
1585
|
+
if (parsedUrl.pathname === "/connections/google-drive" &&
|
|
1586
|
+
req.method === "DELETE") {
|
|
1587
|
+
void (async () => {
|
|
1588
|
+
try {
|
|
1589
|
+
const { handleDriveDisconnect } = await import("./connectors/googleDrive.js");
|
|
1590
|
+
const result = await handleDriveDisconnect();
|
|
1591
|
+
res.writeHead(result.status, {
|
|
1592
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1593
|
+
});
|
|
1594
|
+
res.end(result.body);
|
|
1595
|
+
}
|
|
1596
|
+
catch (err) {
|
|
1597
|
+
if (!res.headersSent) {
|
|
1598
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1599
|
+
res.end(JSON.stringify({
|
|
1600
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1601
|
+
}));
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
})();
|
|
1605
|
+
return true;
|
|
1606
|
+
}
|
|
1607
|
+
return false;
|
|
1608
|
+
}
|
|
1609
|
+
//# sourceMappingURL=connectorRoutes.js.map
|