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,385 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Datadog connector — query metrics, monitors, alerts, and incidents.
|
|
3
|
+
*
|
|
4
|
+
* Auth: API key + Application key.
|
|
5
|
+
* - Env vars: DATADOG_API_KEY, DATADOG_APP_KEY, DATADOG_SITE (optional)
|
|
6
|
+
* - Stored: getSecretJsonSync("datadog") → DatadogTokens
|
|
7
|
+
* - Headers: DD-API-KEY + DD-APPLICATION-KEY
|
|
8
|
+
*
|
|
9
|
+
* Tools: queryMetrics, listMonitors, getMonitor, listActiveAlerts, muteMonitor, listIncidents
|
|
10
|
+
*
|
|
11
|
+
* Extends BaseConnector for unified auth, retry, rate-limit, error handling.
|
|
12
|
+
*/
|
|
13
|
+
import { BaseConnector, } from "./baseConnector.js";
|
|
14
|
+
import { deleteSecretJsonSync, getSecretJsonSync, storeSecretJsonSync, } from "./tokenStorage.js";
|
|
15
|
+
export class DatadogConnector extends BaseConnector {
|
|
16
|
+
providerName = "datadog";
|
|
17
|
+
tokens = null;
|
|
18
|
+
getOAuthConfig() {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
async authenticate() {
|
|
22
|
+
const tokens = loadTokens();
|
|
23
|
+
if (!tokens) {
|
|
24
|
+
throw new Error("Datadog not connected. Run: patchwork-os connect datadog or set DATADOG_API_KEY");
|
|
25
|
+
}
|
|
26
|
+
this.tokens = tokens;
|
|
27
|
+
return {
|
|
28
|
+
token: tokens.apiKey,
|
|
29
|
+
scopes: ["read", "write"],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
async healthCheck() {
|
|
33
|
+
try {
|
|
34
|
+
const result = await this.apiCall(async () => {
|
|
35
|
+
const res = await fetch(`${this.baseUrl()}/api/v1/validate`, {
|
|
36
|
+
headers: this.buildHeaders(),
|
|
37
|
+
});
|
|
38
|
+
if (!res.ok)
|
|
39
|
+
throw new Error(`HTTP ${res.status}`);
|
|
40
|
+
return res.json();
|
|
41
|
+
});
|
|
42
|
+
if ("error" in result)
|
|
43
|
+
return { ok: false, error: result.error };
|
|
44
|
+
return { ok: true };
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
return { ok: false, error: this.normalizeError(err) };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
normalizeError(error) {
|
|
51
|
+
if (error instanceof Response) {
|
|
52
|
+
const s = error.status;
|
|
53
|
+
if (s === 401 || s === 403)
|
|
54
|
+
return {
|
|
55
|
+
code: "auth_expired",
|
|
56
|
+
message: "Datadog authentication failed — check API key and App key",
|
|
57
|
+
retryable: false,
|
|
58
|
+
suggestedAction: "patchwork-os connect datadog",
|
|
59
|
+
};
|
|
60
|
+
if (s === 404)
|
|
61
|
+
return {
|
|
62
|
+
code: "not_found",
|
|
63
|
+
message: "Datadog resource not found",
|
|
64
|
+
retryable: false,
|
|
65
|
+
};
|
|
66
|
+
if (s === 429)
|
|
67
|
+
return {
|
|
68
|
+
code: "rate_limited",
|
|
69
|
+
message: "Datadog API rate limit exceeded",
|
|
70
|
+
retryable: true,
|
|
71
|
+
suggestedAction: "Wait and retry",
|
|
72
|
+
};
|
|
73
|
+
return {
|
|
74
|
+
code: "provider_error",
|
|
75
|
+
message: `Datadog API error: HTTP ${s}`,
|
|
76
|
+
retryable: s >= 500,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (error instanceof Error) {
|
|
80
|
+
if (error.message.includes("ENOTFOUND") ||
|
|
81
|
+
error.message.includes("ECONNREFUSED")) {
|
|
82
|
+
return {
|
|
83
|
+
code: "network_error",
|
|
84
|
+
message: `Cannot connect to Datadog: ${error.message}`,
|
|
85
|
+
retryable: true,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
code: "provider_error",
|
|
91
|
+
message: error instanceof Error ? error.message : String(error),
|
|
92
|
+
retryable: false,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
getStatus() {
|
|
96
|
+
const tokens = loadTokens();
|
|
97
|
+
return {
|
|
98
|
+
id: "datadog",
|
|
99
|
+
status: tokens ? "connected" : "disconnected",
|
|
100
|
+
lastSync: tokens?.connected_at,
|
|
101
|
+
workspace: tokens?.orgName ?? tokens?.site ?? undefined,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
// ── API Methods ────────────────────────────────────────────────────────────
|
|
105
|
+
async queryMetrics(query, from, to) {
|
|
106
|
+
const result = await this.apiCall(async () => {
|
|
107
|
+
const q = encodeURIComponent(query);
|
|
108
|
+
const url = `${this.baseUrl()}/api/v1/query?query=${q}&from=${from}&to=${to}`;
|
|
109
|
+
const res = await fetch(url, { headers: this.buildHeaders() });
|
|
110
|
+
this.updateRateLimitFromHeaders({
|
|
111
|
+
"x-ratelimit-remaining": res.headers.get("x-ratelimit-remaining") ?? undefined,
|
|
112
|
+
"retry-after": res.headers.get("retry-after") ?? undefined,
|
|
113
|
+
});
|
|
114
|
+
if (!res.ok)
|
|
115
|
+
throw res;
|
|
116
|
+
return res.json();
|
|
117
|
+
});
|
|
118
|
+
if ("error" in result)
|
|
119
|
+
throw new Error(result.error.message);
|
|
120
|
+
return result.data;
|
|
121
|
+
}
|
|
122
|
+
async listMonitors(params = {}) {
|
|
123
|
+
const result = await this.apiCall(async () => {
|
|
124
|
+
const qs = new URLSearchParams({ group_states: "all" });
|
|
125
|
+
if (params.tags?.length)
|
|
126
|
+
qs.set("tags", params.tags.join(","));
|
|
127
|
+
if (params.perPage)
|
|
128
|
+
qs.set("per_page", String(params.perPage));
|
|
129
|
+
const res = await fetch(`${this.baseUrl()}/api/v1/monitor?${qs}`, {
|
|
130
|
+
headers: this.buildHeaders(),
|
|
131
|
+
});
|
|
132
|
+
if (!res.ok)
|
|
133
|
+
throw res;
|
|
134
|
+
return res.json();
|
|
135
|
+
});
|
|
136
|
+
if ("error" in result)
|
|
137
|
+
throw new Error(result.error.message);
|
|
138
|
+
return result.data;
|
|
139
|
+
}
|
|
140
|
+
async getMonitor(monitorId) {
|
|
141
|
+
const result = await this.apiCall(async () => {
|
|
142
|
+
const res = await fetch(`${this.baseUrl()}/api/v1/monitor/${monitorId}`, {
|
|
143
|
+
headers: this.buildHeaders(),
|
|
144
|
+
});
|
|
145
|
+
if (!res.ok)
|
|
146
|
+
throw res;
|
|
147
|
+
return res.json();
|
|
148
|
+
});
|
|
149
|
+
if ("error" in result)
|
|
150
|
+
throw new Error(result.error.message);
|
|
151
|
+
return result.data;
|
|
152
|
+
}
|
|
153
|
+
async listActiveAlerts(params = {}) {
|
|
154
|
+
const result = await this.apiCall(async () => {
|
|
155
|
+
const qs = new URLSearchParams({
|
|
156
|
+
monitor_tags: "*",
|
|
157
|
+
group_states: "Alert,Warn",
|
|
158
|
+
with_downtimes: "false",
|
|
159
|
+
});
|
|
160
|
+
if (params.priority !== undefined)
|
|
161
|
+
qs.set("priority", String(params.priority));
|
|
162
|
+
const res = await fetch(`${this.baseUrl()}/api/v1/monitor?${qs}`, {
|
|
163
|
+
headers: this.buildHeaders(),
|
|
164
|
+
});
|
|
165
|
+
if (!res.ok)
|
|
166
|
+
throw res;
|
|
167
|
+
const monitors = (await res.json());
|
|
168
|
+
return monitors.filter((m) => m.overall_state === "Alert" || m.overall_state === "Warn");
|
|
169
|
+
});
|
|
170
|
+
if ("error" in result)
|
|
171
|
+
throw new Error(result.error.message);
|
|
172
|
+
return result.data;
|
|
173
|
+
}
|
|
174
|
+
async muteMonitor(monitorId, end) {
|
|
175
|
+
const result = await this.apiCall(async () => {
|
|
176
|
+
const body = {};
|
|
177
|
+
if (end !== undefined)
|
|
178
|
+
body.end = end;
|
|
179
|
+
const res = await fetch(`${this.baseUrl()}/api/v1/monitor/${monitorId}/mute`, {
|
|
180
|
+
method: "POST",
|
|
181
|
+
headers: this.buildHeaders(),
|
|
182
|
+
body: JSON.stringify(body),
|
|
183
|
+
});
|
|
184
|
+
if (!res.ok)
|
|
185
|
+
throw res;
|
|
186
|
+
return res.json();
|
|
187
|
+
});
|
|
188
|
+
if ("error" in result)
|
|
189
|
+
throw new Error(result.error.message);
|
|
190
|
+
return result.data;
|
|
191
|
+
}
|
|
192
|
+
async listIncidents(params = {}) {
|
|
193
|
+
const result = await this.apiCall(async () => {
|
|
194
|
+
const qs = new URLSearchParams();
|
|
195
|
+
if (params.perPage)
|
|
196
|
+
qs.set("page[size]", String(params.perPage));
|
|
197
|
+
const url = `${this.baseUrl()}/api/v2/incidents${qs.toString() ? `?${qs}` : ""}`;
|
|
198
|
+
const res = await fetch(url, { headers: this.buildHeaders() });
|
|
199
|
+
if (!res.ok)
|
|
200
|
+
throw res;
|
|
201
|
+
return res.json();
|
|
202
|
+
});
|
|
203
|
+
if ("error" in result)
|
|
204
|
+
throw new Error(result.error.message);
|
|
205
|
+
return result.data;
|
|
206
|
+
}
|
|
207
|
+
// ── Helpers ────────────────────────────────────────────────────────────────
|
|
208
|
+
baseUrl() {
|
|
209
|
+
return `https://api.${this.tokens?.site ?? "datadoghq.com"}`;
|
|
210
|
+
}
|
|
211
|
+
buildHeaders() {
|
|
212
|
+
return {
|
|
213
|
+
"DD-API-KEY": this.tokens?.apiKey ?? "",
|
|
214
|
+
"DD-APPLICATION-KEY": this.tokens?.appKey ?? "",
|
|
215
|
+
"Content-Type": "application/json",
|
|
216
|
+
Accept: "application/json",
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
// ── Token persistence ────────────────────────────────────────────────────────
|
|
221
|
+
export function loadTokens() {
|
|
222
|
+
const envApiKey = process.env.DATADOG_API_KEY;
|
|
223
|
+
const envAppKey = process.env.DATADOG_APP_KEY;
|
|
224
|
+
if (envApiKey && envAppKey) {
|
|
225
|
+
return {
|
|
226
|
+
apiKey: envApiKey,
|
|
227
|
+
appKey: envAppKey,
|
|
228
|
+
site: process.env.DATADOG_SITE ?? "datadoghq.com",
|
|
229
|
+
connected_at: new Date().toISOString(),
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
return getSecretJsonSync("datadog");
|
|
233
|
+
}
|
|
234
|
+
export function saveTokens(tokens) {
|
|
235
|
+
storeSecretJsonSync("datadog", tokens);
|
|
236
|
+
}
|
|
237
|
+
export function clearTokens() {
|
|
238
|
+
try {
|
|
239
|
+
deleteSecretJsonSync("datadog");
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
// ignore
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
// ── Singleton instance ───────────────────────────────────────────────────────
|
|
246
|
+
let _instance = null;
|
|
247
|
+
function resetDatadogConnector() {
|
|
248
|
+
_instance = null;
|
|
249
|
+
}
|
|
250
|
+
export function getDatadogConnector() {
|
|
251
|
+
if (!_instance) {
|
|
252
|
+
_instance = new DatadogConnector();
|
|
253
|
+
}
|
|
254
|
+
return _instance;
|
|
255
|
+
}
|
|
256
|
+
export { getDatadogConnector as datadog };
|
|
257
|
+
/**
|
|
258
|
+
* POST /connections/datadog/connect { apiKey, appKey, site? }
|
|
259
|
+
*/
|
|
260
|
+
export async function handleDatadogConnect(body) {
|
|
261
|
+
let apiKey;
|
|
262
|
+
let appKey;
|
|
263
|
+
let site;
|
|
264
|
+
try {
|
|
265
|
+
const parsed = JSON.parse(body);
|
|
266
|
+
if (typeof parsed.apiKey !== "string" || !parsed.apiKey) {
|
|
267
|
+
return {
|
|
268
|
+
status: 400,
|
|
269
|
+
contentType: "application/json",
|
|
270
|
+
body: JSON.stringify({ ok: false, error: "apiKey is required" }),
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
if (typeof parsed.appKey !== "string" || !parsed.appKey) {
|
|
274
|
+
return {
|
|
275
|
+
status: 400,
|
|
276
|
+
contentType: "application/json",
|
|
277
|
+
body: JSON.stringify({ ok: false, error: "appKey is required" }),
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
apiKey = parsed.apiKey;
|
|
281
|
+
appKey = parsed.appKey;
|
|
282
|
+
site =
|
|
283
|
+
typeof parsed.site === "string" && parsed.site
|
|
284
|
+
? parsed.site
|
|
285
|
+
: "datadoghq.com";
|
|
286
|
+
}
|
|
287
|
+
catch {
|
|
288
|
+
return {
|
|
289
|
+
status: 400,
|
|
290
|
+
contentType: "application/json",
|
|
291
|
+
body: JSON.stringify({ ok: false, error: "Invalid JSON body" }),
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
try {
|
|
295
|
+
const res = await fetch(`https://api.${site}/api/v1/validate`, {
|
|
296
|
+
headers: {
|
|
297
|
+
"DD-API-KEY": apiKey,
|
|
298
|
+
"DD-APPLICATION-KEY": appKey,
|
|
299
|
+
Accept: "application/json",
|
|
300
|
+
},
|
|
301
|
+
});
|
|
302
|
+
if (!res.ok) {
|
|
303
|
+
return {
|
|
304
|
+
status: 401,
|
|
305
|
+
contentType: "application/json",
|
|
306
|
+
body: JSON.stringify({
|
|
307
|
+
ok: false,
|
|
308
|
+
error: `Credentials rejected by Datadog (HTTP ${res.status}) — check apiKey and appKey`,
|
|
309
|
+
}),
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
const tokens = {
|
|
313
|
+
apiKey,
|
|
314
|
+
appKey,
|
|
315
|
+
site,
|
|
316
|
+
connected_at: new Date().toISOString(),
|
|
317
|
+
};
|
|
318
|
+
saveTokens(tokens);
|
|
319
|
+
resetDatadogConnector();
|
|
320
|
+
return {
|
|
321
|
+
status: 200,
|
|
322
|
+
contentType: "application/json",
|
|
323
|
+
body: JSON.stringify({
|
|
324
|
+
ok: true,
|
|
325
|
+
site,
|
|
326
|
+
connectedAt: tokens.connected_at,
|
|
327
|
+
}),
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
catch (err) {
|
|
331
|
+
return {
|
|
332
|
+
status: 500,
|
|
333
|
+
contentType: "application/json",
|
|
334
|
+
body: JSON.stringify({
|
|
335
|
+
ok: false,
|
|
336
|
+
error: err instanceof Error ? err.message : String(err),
|
|
337
|
+
}),
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* POST /connections/datadog/test
|
|
343
|
+
*/
|
|
344
|
+
export async function handleDatadogTest() {
|
|
345
|
+
const tokens = loadTokens();
|
|
346
|
+
if (!tokens) {
|
|
347
|
+
return {
|
|
348
|
+
status: 400,
|
|
349
|
+
contentType: "application/json",
|
|
350
|
+
body: JSON.stringify({ ok: false, error: "Datadog not connected" }),
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
try {
|
|
354
|
+
const connector = getDatadogConnector();
|
|
355
|
+
const check = await connector.healthCheck();
|
|
356
|
+
return {
|
|
357
|
+
status: check.ok ? 200 : 401,
|
|
358
|
+
contentType: "application/json",
|
|
359
|
+
body: JSON.stringify(check.ok ? { ok: true } : { ok: false, error: check.error?.message }),
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
catch (err) {
|
|
363
|
+
return {
|
|
364
|
+
status: 500,
|
|
365
|
+
contentType: "application/json",
|
|
366
|
+
body: JSON.stringify({
|
|
367
|
+
ok: false,
|
|
368
|
+
error: err instanceof Error ? err.message : String(err),
|
|
369
|
+
}),
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* DELETE /connections/datadog
|
|
375
|
+
*/
|
|
376
|
+
export function handleDatadogDisconnect() {
|
|
377
|
+
clearTokens();
|
|
378
|
+
resetDatadogConnector();
|
|
379
|
+
return {
|
|
380
|
+
status: 200,
|
|
381
|
+
contentType: "application/json",
|
|
382
|
+
body: JSON.stringify({ ok: true }),
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
//# sourceMappingURL=datadog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datadog.js","sourceRoot":"","sources":["../../src/connectors/datadog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAEL,aAAa,GAGd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAmD3B,MAAM,OAAO,gBAAiB,SAAQ,aAAa;IACxC,YAAY,GAAG,SAAS,CAAC;IAC1B,MAAM,GAAyB,IAAI,CAAC;IAElC,cAAc;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,C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I,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,EAAE,EAAE,KAAK;gBACT,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aACxD,CAAC;SACH,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,WAAW,EAAE,CAAC;IACd,qBAAqB,EAAE,CAAC;IACxB,OAAO;QACL,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,kBAAkB;QAC/B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;KACnC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discord connector — read guilds, channels, messages.
|
|
3
|
+
*
|
|
4
|
+
* OAuth 2.0 Authorization Code Grant. Discord is a confidential client
|
|
5
|
+
* (bridge holds the client secret), so PKCE is not required. Refresh
|
|
6
|
+
* tokens are issued; access tokens expire (typically 7 days).
|
|
7
|
+
*
|
|
8
|
+
* Auth: standard OAuth 2.0 with `client_id` + `client_secret` + `redirect_uri`.
|
|
9
|
+
* - Env vars: DISCORD_CLIENT_ID, DISCORD_CLIENT_SECRET (mirrors slack)
|
|
10
|
+
* - Stored: getSecretJsonSync("discord") → DiscordTokens
|
|
11
|
+
* - Header: Authorization: Bearer <access_token>
|
|
12
|
+
*
|
|
13
|
+
* Tools: getCurrentUser, listGuilds, listChannels, listMessages (read);
|
|
14
|
+
* sendMessage (write).
|
|
15
|
+
*
|
|
16
|
+
* NOTE on writes: Discord's REST API does NOT permit user-context OAuth tokens
|
|
17
|
+
* to send messages on behalf of the user — only bot-scope tokens can hit
|
|
18
|
+
* `POST /channels/{id}/messages`. The current connector authenticates as a
|
|
19
|
+
* regular user (scopes: identify, guilds, messages.read), so `sendMessage`
|
|
20
|
+
* will return a `permission_denied` error until the user re-authenticates
|
|
21
|
+
* with the `bot` scope. The method is wired correctly; the gap is the auth
|
|
22
|
+
* scope, which is left to operators to upgrade when they want write access.
|
|
23
|
+
*
|
|
24
|
+
* HTTP routes (wired in src/server.ts):
|
|
25
|
+
* GET /connections/discord/auth — redirect to Discord consent
|
|
26
|
+
* GET /connections/discord/callback — exchange code for tokens
|
|
27
|
+
* POST /connections/discord/test — ping Discord API
|
|
28
|
+
* DELETE /connections/discord — clear stored tokens
|
|
29
|
+
*
|
|
30
|
+
* Extends BaseConnector for unified auth, retry, rate-limit, error handling.
|
|
31
|
+
* Token refresh is delegated to BaseConnector.refreshToken() via apiCall.
|
|
32
|
+
*/
|
|
33
|
+
import { type AuthContext, BaseConnector, type ConnectorError, type ConnectorStatus, type OAuthConfig } from "./baseConnector.js";
|
|
34
|
+
export interface DiscordTokens {
|
|
35
|
+
access_token: string;
|
|
36
|
+
refresh_token?: string;
|
|
37
|
+
/** ms since epoch; absolute, not relative */
|
|
38
|
+
expires_at?: number;
|
|
39
|
+
scope?: string;
|
|
40
|
+
token_type?: string;
|
|
41
|
+
/** stored at auth time so refresh works even if env vars are absent */
|
|
42
|
+
_client_id?: string;
|
|
43
|
+
_client_secret?: string;
|
|
44
|
+
username?: string;
|
|
45
|
+
user_id?: string;
|
|
46
|
+
connected_at: string;
|
|
47
|
+
}
|
|
48
|
+
export interface DiscordUser {
|
|
49
|
+
id: string;
|
|
50
|
+
username: string;
|
|
51
|
+
discriminator?: string;
|
|
52
|
+
global_name?: string | null;
|
|
53
|
+
avatar?: string | null;
|
|
54
|
+
}
|
|
55
|
+
export interface DiscordGuild {
|
|
56
|
+
id: string;
|
|
57
|
+
name: string;
|
|
58
|
+
icon?: string | null;
|
|
59
|
+
owner?: boolean;
|
|
60
|
+
permissions?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface DiscordChannel {
|
|
63
|
+
id: string;
|
|
64
|
+
type: number;
|
|
65
|
+
name?: string;
|
|
66
|
+
guild_id?: string;
|
|
67
|
+
topic?: string | null;
|
|
68
|
+
position?: number;
|
|
69
|
+
}
|
|
70
|
+
export interface DiscordMessage {
|
|
71
|
+
id: string;
|
|
72
|
+
channel_id: string;
|
|
73
|
+
content: string;
|
|
74
|
+
timestamp: string;
|
|
75
|
+
author: {
|
|
76
|
+
id: string;
|
|
77
|
+
username: string;
|
|
78
|
+
global_name?: string | null;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export declare function loadTokens(): DiscordTokens | null;
|
|
82
|
+
export declare function saveTokens(tokens: DiscordTokens): void;
|
|
83
|
+
export declare function clearTokens(): void;
|
|
84
|
+
export declare function isConnected(): boolean;
|
|
85
|
+
export declare class DiscordConnector extends BaseConnector {
|
|
86
|
+
readonly providerName = "discord";
|
|
87
|
+
protected getOAuthConfig(): OAuthConfig | null;
|
|
88
|
+
authenticate(): Promise<AuthContext>;
|
|
89
|
+
/**
|
|
90
|
+
* Persist refreshed tokens after BaseConnector.refreshToken() updates
|
|
91
|
+
* `this.auth`. BaseConnector calls `saveTokens()` (its own method on the
|
|
92
|
+
* tokenStorage StoredToken shape); we additionally mirror to our
|
|
93
|
+
* Discord-specific JSON so loadTokens() keeps working for HTTP probes.
|
|
94
|
+
*/
|
|
95
|
+
saveTokens(): Promise<void>;
|
|
96
|
+
healthCheck(): Promise<{
|
|
97
|
+
ok: boolean;
|
|
98
|
+
error?: ConnectorError;
|
|
99
|
+
}>;
|
|
100
|
+
normalizeError(error: unknown): ConnectorError;
|
|
101
|
+
getStatus(): ConnectorStatus;
|
|
102
|
+
getCurrentUser(): Promise<DiscordUser>;
|
|
103
|
+
listGuilds(params?: {
|
|
104
|
+
limit?: number;
|
|
105
|
+
}): Promise<DiscordGuild[]>;
|
|
106
|
+
listChannels(guildId: string): Promise<DiscordChannel[]>;
|
|
107
|
+
listMessages(channelId: string, params?: {
|
|
108
|
+
limit?: number;
|
|
109
|
+
}): Promise<DiscordMessage[]>;
|
|
110
|
+
/**
|
|
111
|
+
* Send a message to a Discord channel.
|
|
112
|
+
*
|
|
113
|
+
* Caveat: requires bot-scope OAuth — regular user-context tokens cannot
|
|
114
|
+
* send via this endpoint. On 403 the connector surfaces a
|
|
115
|
+
* `permission_denied` error pointing at the bot-scope requirement.
|
|
116
|
+
*
|
|
117
|
+
* @param channelId Discord channel id (non-empty)
|
|
118
|
+
* @param body { content (≤2000 chars), tts? defaults false }
|
|
119
|
+
*/
|
|
120
|
+
sendMessage(channelId: string, body: {
|
|
121
|
+
content: string;
|
|
122
|
+
tts?: boolean;
|
|
123
|
+
}): Promise<DiscordMessage>;
|
|
124
|
+
private buildHeaders;
|
|
125
|
+
private captureRateLimit;
|
|
126
|
+
}
|
|
127
|
+
export declare function getDiscordConnector(): DiscordConnector;
|
|
128
|
+
export { getDiscordConnector as discord };
|
|
129
|
+
export interface ConnectorHandlerResult {
|
|
130
|
+
status: number;
|
|
131
|
+
body: string;
|
|
132
|
+
contentType?: string;
|
|
133
|
+
redirect?: string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* GET /connections/discord/auth — redirect to Discord consent screen.
|
|
137
|
+
*/
|
|
138
|
+
export declare function handleDiscordAuthorize(): ConnectorHandlerResult;
|
|
139
|
+
/**
|
|
140
|
+
* GET /connections/discord/callback — exchange code for tokens.
|
|
141
|
+
*/
|
|
142
|
+
export declare function handleDiscordCallback(code: string | null, state: string | null, error: string | null): Promise<ConnectorHandlerResult>;
|
|
143
|
+
/**
|
|
144
|
+
* POST /connections/discord/test — verify stored token works.
|
|
145
|
+
*/
|
|
146
|
+
export declare function handleDiscordTest(): Promise<ConnectorHandlerResult>;
|
|
147
|
+
/**
|
|
148
|
+
* DELETE /connections/discord — clear stored tokens (and revoke at Discord).
|
|
149
|
+
*/
|
|
150
|
+
export declare function handleDiscordDisconnect(): Promise<ConnectorHandlerResult>;
|