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,484 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token Storage — secure credential storage for OAuth tokens.
|
|
3
|
+
*
|
|
4
|
+
* Platform-specific implementations:
|
|
5
|
+
* - macOS: Keychain (security command)
|
|
6
|
+
* - Windows: DPAPI (data protection API via PowerShell)
|
|
7
|
+
* - Linux: Secret Service API (via secret-tool or libsecret)
|
|
8
|
+
*
|
|
9
|
+
* Falls back to file-based encrypted storage if native APIs unavailable.
|
|
10
|
+
*/
|
|
11
|
+
import { spawnSync } from "node:child_process";
|
|
12
|
+
import crypto from "node:crypto";
|
|
13
|
+
import { chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, unlinkSync, writeFileSync, } from "node:fs";
|
|
14
|
+
import os from "node:os";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
const SERVICE_NAME = "patchwork-os";
|
|
17
|
+
function storageKey(provider) {
|
|
18
|
+
return `${SERVICE_NAME}.${provider}`;
|
|
19
|
+
}
|
|
20
|
+
function parseJson(json) {
|
|
21
|
+
if (json === null) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
return JSON.parse(json);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function storeSecretJsonSync(provider, value) {
|
|
32
|
+
const key = storageKey(provider);
|
|
33
|
+
const json = JSON.stringify(value);
|
|
34
|
+
if (resolveBackend() === "file") {
|
|
35
|
+
setEncryptedFileSync(key, json);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (setKeychainItemSync(key, json)) {
|
|
39
|
+
deleteEncryptedFileSync(key);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
setEncryptedFileSync(key, json);
|
|
43
|
+
}
|
|
44
|
+
export function getSecretJsonSync(provider) {
|
|
45
|
+
const key = storageKey(provider);
|
|
46
|
+
if (resolveBackend() === "file") {
|
|
47
|
+
return parseJson(getEncryptedFileSync(key));
|
|
48
|
+
}
|
|
49
|
+
const fromKeychain = getKeychainItemSync(key);
|
|
50
|
+
if (fromKeychain !== null) {
|
|
51
|
+
return parseJson(fromKeychain);
|
|
52
|
+
}
|
|
53
|
+
return parseJson(getEncryptedFileSync(key));
|
|
54
|
+
}
|
|
55
|
+
export function deleteSecretJsonSync(provider) {
|
|
56
|
+
const key = storageKey(provider);
|
|
57
|
+
if (resolveBackend() === "file") {
|
|
58
|
+
deleteEncryptedFileSync(key);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
deleteKeychainItemSync(key);
|
|
62
|
+
deleteEncryptedFileSync(key);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Store tokens securely for a provider.
|
|
66
|
+
*/
|
|
67
|
+
export async function storeTokens(provider, tokens) {
|
|
68
|
+
storeSecretJsonSync(provider, tokens);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Retrieve stored tokens for a provider.
|
|
72
|
+
*/
|
|
73
|
+
export async function getTokens(provider) {
|
|
74
|
+
return getSecretJsonSync(provider);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Delete stored tokens for a provider.
|
|
78
|
+
*/
|
|
79
|
+
export async function deleteTokens(provider) {
|
|
80
|
+
deleteSecretJsonSync(provider);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* List all providers with stored tokens.
|
|
84
|
+
*/
|
|
85
|
+
export async function listStoredProviders() {
|
|
86
|
+
if (resolveBackend() === "file") {
|
|
87
|
+
return (await listEncryptedFiles()).sort();
|
|
88
|
+
}
|
|
89
|
+
const providers = [];
|
|
90
|
+
// Check keychain
|
|
91
|
+
const keychainProviders = await listKeychainItems();
|
|
92
|
+
providers.push(...keychainProviders);
|
|
93
|
+
// Check file storage
|
|
94
|
+
const fileProviders = await listEncryptedFiles();
|
|
95
|
+
for (const p of fileProviders) {
|
|
96
|
+
if (!providers.includes(p)) {
|
|
97
|
+
providers.push(p);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return providers.sort();
|
|
101
|
+
}
|
|
102
|
+
// Platform implementations are defined at the end of this file
|
|
103
|
+
// ============================================================================
|
|
104
|
+
// Windows DPAPI (via PowerShell)
|
|
105
|
+
// ============================================================================
|
|
106
|
+
function setWindowsCredentialSync(key, value) {
|
|
107
|
+
if (process.platform !== "win32")
|
|
108
|
+
return false;
|
|
109
|
+
try {
|
|
110
|
+
const script = `
|
|
111
|
+
$bytes = [System.Text.Encoding]::UTF8.GetBytes('${value.replace(/'/g, "''")}')
|
|
112
|
+
$protected = [System.Security.Cryptography.ProtectedData]::Protect($bytes, $null, [System.Security.Cryptography.DataProtectionScope]::CurrentUser)
|
|
113
|
+
$path = Join-Path $env:LOCALAPPDATA "PatchworkOS" "tokens"
|
|
114
|
+
if (-not (Test-Path $path)) { New-Item -ItemType Directory -Path $path -Force | Out-Null }
|
|
115
|
+
$protected | Set-Content -Path (Join-Path $path "${key}.bin") -Encoding Byte
|
|
116
|
+
`;
|
|
117
|
+
const result = spawnSync("powershell", ["-Command", script], {
|
|
118
|
+
encoding: "utf-8",
|
|
119
|
+
timeout: 10000,
|
|
120
|
+
});
|
|
121
|
+
return result.status === 0;
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function getWindowsCredentialSync(key) {
|
|
128
|
+
if (process.platform !== "win32")
|
|
129
|
+
return null;
|
|
130
|
+
try {
|
|
131
|
+
const script = `
|
|
132
|
+
$path = Join-Path $env:LOCALAPPDATA "PatchworkOS" "tokens" "${key}.bin"
|
|
133
|
+
if (Test-Path $path) {
|
|
134
|
+
$bytes = Get-Content -Path $path -Encoding Byte -Raw
|
|
135
|
+
$unprotected = [System.Security.Cryptography.ProtectedData]::Unprotect($bytes, $null, [System.Security.Cryptography.DataProtectionScope]::CurrentUser)
|
|
136
|
+
[System.Text.Encoding]::UTF8.GetString($unprotected)
|
|
137
|
+
}
|
|
138
|
+
`;
|
|
139
|
+
const result = spawnSync("powershell", ["-Command", script], {
|
|
140
|
+
encoding: "utf-8",
|
|
141
|
+
timeout: 10000,
|
|
142
|
+
});
|
|
143
|
+
if (result.status !== 0) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
return result.stdout.trim() || null;
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// ============================================================================
|
|
153
|
+
// Encrypted File Storage (Fallback)
|
|
154
|
+
// ============================================================================
|
|
155
|
+
function getStorageDir() {
|
|
156
|
+
const base = process.env.PATCHWORK_HOME ?? join(os.homedir(), ".patchwork");
|
|
157
|
+
return join(base, "tokens");
|
|
158
|
+
}
|
|
159
|
+
const MASTER_KEY_FILE = ".master.key";
|
|
160
|
+
let cachedKey = null;
|
|
161
|
+
let cachedKeyDir = null;
|
|
162
|
+
function legacyDerivedKey() {
|
|
163
|
+
// Legacy key: sha256(hostname + username). Kept only for one-time migration
|
|
164
|
+
// of existing encrypted files. New data is encrypted with the random master key.
|
|
165
|
+
const machineId = `${os.hostname()}-${os.userInfo().username}`;
|
|
166
|
+
return crypto.createHash("sha256").update(machineId).digest().slice(0, 32);
|
|
167
|
+
}
|
|
168
|
+
function getEncryptionKey() {
|
|
169
|
+
const dir = getStorageDir();
|
|
170
|
+
const keyPath = join(dir, MASTER_KEY_FILE);
|
|
171
|
+
if (cachedKey && cachedKeyDir === dir && existsSync(keyPath)) {
|
|
172
|
+
return cachedKey;
|
|
173
|
+
}
|
|
174
|
+
if (existsSync(keyPath)) {
|
|
175
|
+
try {
|
|
176
|
+
const key = readFileSync(keyPath);
|
|
177
|
+
if (key.length === 32) {
|
|
178
|
+
cachedKey = key;
|
|
179
|
+
cachedKeyDir = dir;
|
|
180
|
+
return key;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
// fall through to regenerate
|
|
185
|
+
}
|
|
186
|
+
// Corrupt or unreadable — replace.
|
|
187
|
+
try {
|
|
188
|
+
unlinkSync(keyPath);
|
|
189
|
+
}
|
|
190
|
+
catch { }
|
|
191
|
+
}
|
|
192
|
+
if (!existsSync(dir)) {
|
|
193
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
194
|
+
}
|
|
195
|
+
const key = crypto.randomBytes(32);
|
|
196
|
+
try {
|
|
197
|
+
// flag "wx" = O_EXCL: fail if another process created the file in between.
|
|
198
|
+
writeFileSync(keyPath, key, { flag: "wx", mode: 0o600 });
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
// Another process may have written it first; prefer that one for consistency.
|
|
202
|
+
try {
|
|
203
|
+
const existing = readFileSync(keyPath);
|
|
204
|
+
if (existing.length === 32) {
|
|
205
|
+
cachedKey = existing;
|
|
206
|
+
cachedKeyDir = dir;
|
|
207
|
+
return existing;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
catch { }
|
|
211
|
+
// Best effort: fall through with the in-memory key.
|
|
212
|
+
}
|
|
213
|
+
cachedKey = key;
|
|
214
|
+
cachedKeyDir = dir;
|
|
215
|
+
return key;
|
|
216
|
+
}
|
|
217
|
+
function encrypt(text) {
|
|
218
|
+
const iv = crypto.randomBytes(16);
|
|
219
|
+
const cipher = crypto.createCipheriv("aes-256-gcm", getEncryptionKey(), iv);
|
|
220
|
+
let encrypted = cipher.update(text, "utf8", "hex");
|
|
221
|
+
encrypted += cipher.final("hex");
|
|
222
|
+
const authTag = cipher.getAuthTag();
|
|
223
|
+
return `${iv.toString("hex")}:${authTag.toString("hex")}:${encrypted}`;
|
|
224
|
+
}
|
|
225
|
+
function decryptWith(key, encryptedData) {
|
|
226
|
+
try {
|
|
227
|
+
const [ivHex, authTagHex, encrypted] = encryptedData.split(":");
|
|
228
|
+
if (!ivHex || !authTagHex || !encrypted)
|
|
229
|
+
return null;
|
|
230
|
+
const decipher = crypto.createDecipheriv("aes-256-gcm", key, Buffer.from(ivHex, "hex"));
|
|
231
|
+
decipher.setAuthTag(Buffer.from(authTagHex, "hex"));
|
|
232
|
+
let decrypted = decipher.update(encrypted, "hex", "utf8");
|
|
233
|
+
decrypted += decipher.final("utf8");
|
|
234
|
+
return decrypted;
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function decrypt(encryptedData) {
|
|
241
|
+
return decryptWith(getEncryptionKey(), encryptedData);
|
|
242
|
+
}
|
|
243
|
+
function setEncryptedFileSync(key, value) {
|
|
244
|
+
const dir = getStorageDir();
|
|
245
|
+
if (!existsSync(dir)) {
|
|
246
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
247
|
+
}
|
|
248
|
+
const encrypted = encrypt(value);
|
|
249
|
+
const finalPath = join(dir, `${key}.enc`);
|
|
250
|
+
// Atomic write: tmp file + rename. Without this a concurrent reader can
|
|
251
|
+
// observe torn ciphertext mid-write → decrypt() returns null → caller
|
|
252
|
+
// treats the connector as disconnected and triggers a full re-auth.
|
|
253
|
+
// The macOS keychain backend is already atomic at OS level; this guard
|
|
254
|
+
// is for the file backend.
|
|
255
|
+
const tmpPath = `${finalPath}.tmp.${process.pid}.${crypto
|
|
256
|
+
.randomBytes(8)
|
|
257
|
+
.toString("hex")}`;
|
|
258
|
+
try {
|
|
259
|
+
writeFileSync(tmpPath, encrypted, { mode: 0o600 });
|
|
260
|
+
// Belt-and-braces: writeFileSync honours mode on file create, but if
|
|
261
|
+
// the file pre-existed with a permissive mode we'd inherit it. Force
|
|
262
|
+
// 0o600 before rename takes the inode.
|
|
263
|
+
chmodSync(tmpPath, 0o600);
|
|
264
|
+
renameSync(tmpPath, finalPath);
|
|
265
|
+
}
|
|
266
|
+
catch (err) {
|
|
267
|
+
try {
|
|
268
|
+
unlinkSync(tmpPath);
|
|
269
|
+
}
|
|
270
|
+
catch {
|
|
271
|
+
// tmp may not exist — best-effort cleanup
|
|
272
|
+
}
|
|
273
|
+
throw err;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
function getEncryptedFileSync(key) {
|
|
277
|
+
const filePath = join(getStorageDir(), `${key}.enc`);
|
|
278
|
+
if (!existsSync(filePath))
|
|
279
|
+
return null;
|
|
280
|
+
try {
|
|
281
|
+
const encrypted = readFileSync(filePath, "utf-8");
|
|
282
|
+
const plain = decrypt(encrypted);
|
|
283
|
+
if (plain !== null)
|
|
284
|
+
return plain;
|
|
285
|
+
// One-time migration: files encrypted with the old hostname-derived key
|
|
286
|
+
// are re-encrypted under the random master key.
|
|
287
|
+
const legacyPlain = decryptWith(legacyDerivedKey(), encrypted);
|
|
288
|
+
if (legacyPlain !== null) {
|
|
289
|
+
setEncryptedFileSync(key, legacyPlain);
|
|
290
|
+
return legacyPlain;
|
|
291
|
+
}
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
catch {
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function deleteEncryptedFileSync(key) {
|
|
299
|
+
const filePath = join(getStorageDir(), `${key}.enc`);
|
|
300
|
+
if (existsSync(filePath)) {
|
|
301
|
+
try {
|
|
302
|
+
unlinkSync(filePath);
|
|
303
|
+
}
|
|
304
|
+
catch { }
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
function listEncryptedFiles() {
|
|
308
|
+
const dir = getStorageDir();
|
|
309
|
+
if (!existsSync(dir))
|
|
310
|
+
return [];
|
|
311
|
+
try {
|
|
312
|
+
const files = readdirSync(dir);
|
|
313
|
+
return files
|
|
314
|
+
.filter((f) => f.endsWith(".enc"))
|
|
315
|
+
.map((f) => f.replace(`${SERVICE_NAME}.`, "").replace(".enc", ""));
|
|
316
|
+
}
|
|
317
|
+
catch {
|
|
318
|
+
return [];
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function deleteWindowsCredentialSync(key) {
|
|
322
|
+
if (process.platform !== "win32")
|
|
323
|
+
return false;
|
|
324
|
+
try {
|
|
325
|
+
const localAppData = process.env.LOCALAPPDATA;
|
|
326
|
+
if (!localAppData)
|
|
327
|
+
return false;
|
|
328
|
+
const filePath = join(localAppData, "PatchworkOS", "tokens", `${key}.bin`);
|
|
329
|
+
if (!existsSync(filePath))
|
|
330
|
+
return true;
|
|
331
|
+
unlinkSync(filePath);
|
|
332
|
+
return true;
|
|
333
|
+
}
|
|
334
|
+
catch {
|
|
335
|
+
return false;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
// ============================================================================
|
|
339
|
+
// Helpers
|
|
340
|
+
// ============================================================================
|
|
341
|
+
function resolveBackend() {
|
|
342
|
+
const backend = process.env.PATCHWORK_TOKEN_STORAGE_BACKEND;
|
|
343
|
+
if (backend === "file" || backend === "native" || backend === "auto") {
|
|
344
|
+
return backend;
|
|
345
|
+
}
|
|
346
|
+
return "auto";
|
|
347
|
+
}
|
|
348
|
+
// Platform abstraction
|
|
349
|
+
function setKeychainItemSync(key, value) {
|
|
350
|
+
if (process.platform === "darwin") {
|
|
351
|
+
return setMacOSKeychainItemSync(key, value);
|
|
352
|
+
}
|
|
353
|
+
if (process.platform === "win32") {
|
|
354
|
+
return setWindowsCredentialSync(key, value);
|
|
355
|
+
}
|
|
356
|
+
return setLinuxSecretSync(key, value);
|
|
357
|
+
}
|
|
358
|
+
function getKeychainItemSync(key) {
|
|
359
|
+
if (process.platform === "darwin") {
|
|
360
|
+
return getMacOSKeychainItemSync(key);
|
|
361
|
+
}
|
|
362
|
+
if (process.platform === "win32") {
|
|
363
|
+
return getWindowsCredentialSync(key);
|
|
364
|
+
}
|
|
365
|
+
return getLinuxSecretSync(key);
|
|
366
|
+
}
|
|
367
|
+
function deleteKeychainItemSync(key) {
|
|
368
|
+
if (process.platform === "darwin") {
|
|
369
|
+
return deleteMacOSKeychainItemSync(key);
|
|
370
|
+
}
|
|
371
|
+
if (process.platform === "win32") {
|
|
372
|
+
return deleteWindowsCredentialSync(key);
|
|
373
|
+
}
|
|
374
|
+
return deleteLinuxSecretSync(key);
|
|
375
|
+
}
|
|
376
|
+
function listKeychainItems() {
|
|
377
|
+
if (process.platform === "darwin") {
|
|
378
|
+
return listMacOSKeychainItems();
|
|
379
|
+
}
|
|
380
|
+
if (process.platform === "win32") {
|
|
381
|
+
// Handled by file listing
|
|
382
|
+
return [];
|
|
383
|
+
}
|
|
384
|
+
return listLinuxSecrets();
|
|
385
|
+
}
|
|
386
|
+
// Linux Secret Service
|
|
387
|
+
function setLinuxSecretSync(key, value) {
|
|
388
|
+
try {
|
|
389
|
+
const result = spawnSync("secret-tool", ["store", "--label", key, "service", SERVICE_NAME, "account", key], { input: value, encoding: "utf-8", timeout: 5000 });
|
|
390
|
+
return result.status === 0;
|
|
391
|
+
}
|
|
392
|
+
catch {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
function getLinuxSecretSync(key) {
|
|
397
|
+
try {
|
|
398
|
+
const result = spawnSync("secret-tool", ["lookup", "service", SERVICE_NAME, "account", key], { encoding: "utf-8", timeout: 5000 });
|
|
399
|
+
if (result.status === 0 && result.stdout) {
|
|
400
|
+
return result.stdout.trim();
|
|
401
|
+
}
|
|
402
|
+
return null;
|
|
403
|
+
}
|
|
404
|
+
catch {
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
function deleteLinuxSecretSync(key) {
|
|
409
|
+
try {
|
|
410
|
+
const result = spawnSync("secret-tool", ["clear", "service", SERVICE_NAME, "account", key], { encoding: "utf-8", timeout: 5000 });
|
|
411
|
+
return result.status === 0;
|
|
412
|
+
}
|
|
413
|
+
catch {
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
function listLinuxSecrets() {
|
|
418
|
+
// secret-tool doesn't have a list command; we'd need libsecret bindings
|
|
419
|
+
return [];
|
|
420
|
+
}
|
|
421
|
+
// Rename the platform-specific functions to avoid conflicts
|
|
422
|
+
function setMacOSKeychainItemSync(key, value) {
|
|
423
|
+
try {
|
|
424
|
+
const result = spawnSync("security", [
|
|
425
|
+
"add-generic-password",
|
|
426
|
+
"-s",
|
|
427
|
+
key,
|
|
428
|
+
"-a",
|
|
429
|
+
SERVICE_NAME,
|
|
430
|
+
"-w",
|
|
431
|
+
value,
|
|
432
|
+
"-U",
|
|
433
|
+
], { encoding: "utf-8", timeout: 5000 });
|
|
434
|
+
return result.status === 0;
|
|
435
|
+
}
|
|
436
|
+
catch {
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
function getMacOSKeychainItemSync(key) {
|
|
441
|
+
try {
|
|
442
|
+
const result = spawnSync("security", ["find-generic-password", "-s", key, "-a", SERVICE_NAME, "-w"], { encoding: "utf-8", timeout: 5000 });
|
|
443
|
+
if (result.status === 0 && result.stdout) {
|
|
444
|
+
return result.stdout.trim();
|
|
445
|
+
}
|
|
446
|
+
return null;
|
|
447
|
+
}
|
|
448
|
+
catch {
|
|
449
|
+
return null;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
function deleteMacOSKeychainItemSync(key) {
|
|
453
|
+
try {
|
|
454
|
+
const result = spawnSync("security", ["delete-generic-password", "-s", key, "-a", SERVICE_NAME], { encoding: "utf-8", timeout: 5000 });
|
|
455
|
+
return result.status === 0;
|
|
456
|
+
}
|
|
457
|
+
catch {
|
|
458
|
+
return false;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
function listMacOSKeychainItems() {
|
|
462
|
+
try {
|
|
463
|
+
const result = spawnSync("security", ["dump-keychain"], {
|
|
464
|
+
encoding: "utf-8",
|
|
465
|
+
timeout: 10000,
|
|
466
|
+
});
|
|
467
|
+
if (result.status !== 0)
|
|
468
|
+
return [];
|
|
469
|
+
const providers = [];
|
|
470
|
+
const regex = new RegExp(`svce<blob>=${SERVICE_NAME}\\.([^\\s]+)`, "g");
|
|
471
|
+
let match;
|
|
472
|
+
while ((match = regex.exec(result.stdout)) !== null) {
|
|
473
|
+
const provider = match[1];
|
|
474
|
+
if (provider) {
|
|
475
|
+
providers.push(provider);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return providers;
|
|
479
|
+
}
|
|
480
|
+
catch {
|
|
481
|
+
return [];
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
//# sourceMappingURL=tokenStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenStorage.js","sourceRoot":"","sources":["../../src/connectors/tokenStorage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,YAAY,GAAG,cAAc,CAAC;AAWpC,SAAS,UAAU,CAAC,QAAgB;IAClC,OAAO,GAAG,YAAY,IAAI,QAAQ,EAAE,CAAC;AACvC,CAAC;AAED,SAAS,SAAS,CAAI,IAAmB;IACvC,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,QAAgB,EAAE,KAAc;IAClE,MAAM,GAAG,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IACjC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAEnC,IAAI,cAAc,EAAE,KAAK,MAAM,EAAE,CAAC;QAChC,oBAAoB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAChC,OAAO;IACT,CAAC;IAED,IAAI,mBAAmB,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC;QACnC,uBAAu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ENDESK_SUBDOMAIN
|
|
6
|
+
* - Stored: getSecretJsonSync("zendesk") → ZendeskTokens
|
|
7
|
+
* - Basic auth: `email/token:api_token` (Zendesk token auth convention)
|
|
8
|
+
*
|
|
9
|
+
* Tools: listTickets, getTicket, addComment, updateStatus, listUsers
|
|
10
|
+
*
|
|
11
|
+
* Extends BaseConnector for unified auth, retry, rate-limit, error handling.
|
|
12
|
+
*/
|
|
13
|
+
import { type AuthContext, BaseConnector, type ConnectorError, type ConnectorStatus } from "./baseConnector.js";
|
|
14
|
+
export interface ZendeskTokens {
|
|
15
|
+
apiToken: string;
|
|
16
|
+
email: string;
|
|
17
|
+
subdomain: string;
|
|
18
|
+
connected_at: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ZendeskTicket {
|
|
21
|
+
id: number;
|
|
22
|
+
subject: string;
|
|
23
|
+
description: string;
|
|
24
|
+
status: "new" | "open" | "pending" | "hold" | "solved" | "closed";
|
|
25
|
+
priority: "urgent" | "high" | "normal" | "low" | null;
|
|
26
|
+
type: "problem" | "incident" | "question" | "task" | null;
|
|
27
|
+
requester_id: number;
|
|
28
|
+
assignee_id: number | null;
|
|
29
|
+
group_id: number | null;
|
|
30
|
+
tags: string[];
|
|
31
|
+
created_at: string;
|
|
32
|
+
updated_at: string;
|
|
33
|
+
url: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ZendeskComment {
|
|
36
|
+
id: number;
|
|
37
|
+
type: "Comment" | "VoiceComment";
|
|
38
|
+
author_id: number;
|
|
39
|
+
body: string;
|
|
40
|
+
html_body: string;
|
|
41
|
+
public: boolean;
|
|
42
|
+
created_at: string;
|
|
43
|
+
}
|
|
44
|
+
export interface ZendeskUser {
|
|
45
|
+
id: number;
|
|
46
|
+
name: string;
|
|
47
|
+
email: string;
|
|
48
|
+
role: "end-user" | "agent" | "admin";
|
|
49
|
+
active: boolean;
|
|
50
|
+
created_at: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ZendeskListResult<T> {
|
|
53
|
+
results: T[];
|
|
54
|
+
count: number;
|
|
55
|
+
next_page: string | null;
|
|
56
|
+
previous_page: string | null;
|
|
57
|
+
}
|
|
58
|
+
export declare class ZendeskConnector extends BaseConnector {
|
|
59
|
+
readonly providerName = "zendesk";
|
|
60
|
+
private tokens;
|
|
61
|
+
protected getOAuthConfig(): null;
|
|
62
|
+
authenticate(): Promise<AuthContext>;
|
|
63
|
+
healthCheck(): Promise<{
|
|
64
|
+
ok: boolean;
|
|
65
|
+
error?: ConnectorError;
|
|
66
|
+
}>;
|
|
67
|
+
normalizeError(error: unknown): ConnectorError;
|
|
68
|
+
getStatus(): ConnectorStatus;
|
|
69
|
+
listTickets(params?: {
|
|
70
|
+
status?: ZendeskTicket["status"];
|
|
71
|
+
assigneeId?: number;
|
|
72
|
+
query?: string;
|
|
73
|
+
perPage?: number;
|
|
74
|
+
}): Promise<ZendeskListResult<ZendeskTicket>>;
|
|
75
|
+
getTicket(ticketId: number): Promise<ZendeskTicket | null>;
|
|
76
|
+
getTicketComments(ticketId: number): Promise<ZendeskComment[]>;
|
|
77
|
+
addComment(ticketId: number, body: string, isPublic?: boolean): Promise<ZendeskTicket>;
|
|
78
|
+
updateStatus(ticketId: number, status: ZendeskTicket["status"]): Promise<ZendeskTicket>;
|
|
79
|
+
listUsers(role?: ZendeskUser["role"], perPage?: number): Promise<ZendeskUser[]>;
|
|
80
|
+
private baseUrl;
|
|
81
|
+
private buildHeaders;
|
|
82
|
+
}
|
|
83
|
+
export declare function loadTokens(): ZendeskTokens | null;
|
|
84
|
+
export declare function saveTokens(tokens: ZendeskTokens): void;
|
|
85
|
+
export declare function clearTokens(): void;
|
|
86
|
+
export declare function getZendeskConnector(): ZendeskConnector;
|
|
87
|
+
export { getZendeskConnector as zendesk };
|
|
88
|
+
export interface ConnectorHandlerResult {
|
|
89
|
+
status: number;
|
|
90
|
+
body: string;
|
|
91
|
+
contentType?: string;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* POST /connections/zendesk/connect { apiToken, email, subdomain }
|
|
95
|
+
*/
|
|
96
|
+
export declare function handleZendeskConnect(body: string): Promise<ConnectorHandlerResult>;
|
|
97
|
+
/**
|
|
98
|
+
* POST /connections/zendesk/test
|
|
99
|
+
*/
|
|
100
|
+
export declare function handleZendeskTest(): Promise<ConnectorHandlerResult>;
|
|
101
|
+
/**
|
|
102
|
+
* DELETE /connections/zendesk
|
|
103
|
+
*/
|
|
104
|
+
export declare function handleZendeskDisconnect(): ConnectorHandlerResult;
|