patchwork-os 0.2.0-beta.0 → 0.2.0-beta.10
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 +14 -14
- package/README.md +204 -34
- package/deploy/README.md +1 -1
- package/deploy/bootstrap-vps.sh +14 -9
- package/deploy/deploy-dashboard.sh +25 -1
- package/deploy/macos/README.md +153 -0
- package/deploy/macos/com.patchwork.bridge.plist.template +54 -0
- package/deploy/macos/com.patchwork.tunnel.plist.template +76 -0
- package/deploy/macos/install-mac-bridge.sh +244 -0
- package/deploy/macos/uninstall-mac-bridge.sh +22 -0
- package/dist/activityLog.d.ts +6 -0
- package/dist/activityLog.js +63 -26
- package/dist/activityLog.js.map +1 -1
- package/dist/adapters/claude.js +22 -16
- package/dist/adapters/claude.js.map +1 -1
- package/dist/adapters/gemini.js +15 -11
- package/dist/adapters/gemini.js.map +1 -1
- package/dist/adapters/openai.js +9 -9
- package/dist/adapters/openai.js.map +1 -1
- package/dist/ajv2020.d.ts +25 -0
- package/dist/ajv2020.js +33 -0
- package/dist/ajv2020.js.map +1 -0
- package/dist/analyticsAggregator.d.ts +5 -1
- package/dist/analyticsAggregator.js +16 -5
- package/dist/analyticsAggregator.js.map +1 -1
- package/dist/analyticsConfig.d.ts +29 -0
- package/dist/analyticsConfig.js +102 -0
- package/dist/analyticsConfig.js.map +1 -0
- package/dist/analyticsPrefs.d.ts +49 -2
- package/dist/analyticsPrefs.js +177 -19
- package/dist/analyticsPrefs.js.map +1 -1
- package/dist/analyticsSend.d.ts +17 -1
- package/dist/analyticsSend.js +67 -5
- package/dist/analyticsSend.js.map +1 -1
- package/dist/approvalHttp.d.ts +14 -0
- package/dist/approvalHttp.js +212 -9
- package/dist/approvalHttp.js.map +1 -1
- package/dist/approvalInsights.js +13 -5
- package/dist/approvalInsights.js.map +1 -1
- package/dist/approvalQueue.d.ts +97 -3
- package/dist/approvalQueue.js +193 -19
- package/dist/approvalQueue.js.map +1 -1
- package/dist/approvalSignals.js +19 -11
- package/dist/approvalSignals.js.map +1 -1
- package/dist/automation.d.ts +35 -10
- package/dist/automation.js +133 -37
- package/dist/automation.js.map +1 -1
- package/dist/automationSuggestions.js +10 -8
- package/dist/automationSuggestions.js.map +1 -1
- package/dist/bridge.d.ts +2 -0
- package/dist/bridge.js +238 -51
- package/dist/bridge.js.map +1 -1
- package/dist/bridgeLockDiscovery.d.ts +27 -1
- package/dist/bridgeLockDiscovery.js +38 -11
- package/dist/bridgeLockDiscovery.js.map +1 -1
- package/dist/bridgeToken.js +3 -2
- package/dist/bridgeToken.js.map +1 -1
- package/dist/claudeDriver.d.ts +0 -16
- package/dist/claudeDriver.js +42 -28
- package/dist/claudeDriver.js.map +1 -1
- package/dist/claudeMdPatch.d.ts +9 -3
- package/dist/claudeMdPatch.js +79 -13
- package/dist/claudeMdPatch.js.map +1 -1
- package/dist/claudeOrchestrator.d.ts +13 -1
- package/dist/claudeOrchestrator.js +89 -44
- package/dist/claudeOrchestrator.js.map +1 -1
- package/dist/commands/analytics.d.ts +8 -0
- package/dist/commands/analytics.js +134 -0
- package/dist/commands/analytics.js.map +1 -0
- package/dist/commands/auditEnv.d.ts +36 -0
- package/dist/commands/auditEnv.js +202 -0
- package/dist/commands/auditEnv.js.map +1 -0
- package/dist/commands/dashboard.js +8 -1
- package/dist/commands/dashboard.js.map +1 -1
- package/dist/commands/doctor.d.ts +35 -0
- package/dist/commands/doctor.js +51 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/install.js +3 -0
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/launchd.js +15 -16
- package/dist/commands/launchd.js.map +1 -1
- package/dist/commands/patchworkInit.d.ts +5 -0
- package/dist/commands/patchworkInit.js +89 -7
- package/dist/commands/patchworkInit.js.map +1 -1
- package/dist/commands/recipe.d.ts +110 -0
- package/dist/commands/recipe.js +512 -9
- package/dist/commands/recipe.js.map +1 -1
- package/dist/commands/recipeInstall.js +11 -4
- package/dist/commands/recipeInstall.js.map +1 -1
- package/dist/commands/shadowScan.d.ts +34 -0
- package/dist/commands/shadowScan.js +142 -0
- package/dist/commands/shadowScan.js.map +1 -0
- package/dist/commands/task.js +2 -2
- package/dist/commands/task.js.map +1 -1
- package/dist/commands/tools.d.ts +20 -1
- package/dist/commands/tools.js +112 -3
- package/dist/commands/tools.js.map +1 -1
- package/dist/commands/tracesImport.js +21 -4
- package/dist/commands/tracesImport.js.map +1 -1
- package/dist/commitIssueLinkLog.d.ts +24 -0
- package/dist/commitIssueLinkLog.js +160 -22
- package/dist/commitIssueLinkLog.js.map +1 -1
- package/dist/companions/registry.js +15 -7
- package/dist/companions/registry.js.map +1 -1
- package/dist/config.d.ts +49 -5
- package/dist/config.js +123 -22
- package/dist/config.js.map +1 -1
- package/dist/connectorRoutes.js +913 -413
- package/dist/connectorRoutes.js.map +1 -1
- package/dist/connectors/airtable.d.ts +230 -0
- package/dist/connectors/airtable.js +700 -0
- package/dist/connectors/airtable.js.map +1 -0
- package/dist/connectors/asana.js +13 -9
- package/dist/connectors/asana.js.map +1 -1
- package/dist/connectors/baseConnector.js +25 -3
- package/dist/connectors/baseConnector.js.map +1 -1
- package/dist/connectors/caldiy.d.ts +137 -0
- package/dist/connectors/caldiy.js +424 -0
- package/dist/connectors/caldiy.js.map +1 -0
- package/dist/connectors/circleci.d.ts +162 -0
- package/dist/connectors/circleci.js +576 -0
- package/dist/connectors/circleci.js.map +1 -0
- package/dist/connectors/cloudflare.d.ts +132 -0
- package/dist/connectors/cloudflare.js +622 -0
- package/dist/connectors/cloudflare.js.map +1 -0
- package/dist/connectors/confluence.js +35 -0
- package/dist/connectors/confluence.js.map +1 -1
- package/dist/connectors/connectorRedirectUri.d.ts +30 -0
- package/dist/connectors/connectorRedirectUri.js +38 -0
- package/dist/connectors/connectorRedirectUri.js.map +1 -0
- package/dist/connectors/connectorRegistry.d.ts +63 -0
- package/dist/connectors/connectorRegistry.js +354 -0
- package/dist/connectors/connectorRegistry.js.map +1 -0
- package/dist/connectors/datadog.js +33 -4
- package/dist/connectors/datadog.js.map +1 -1
- package/dist/connectors/discord.js +14 -10
- package/dist/connectors/discord.js.map +1 -1
- package/dist/connectors/elasticsearch.d.ts +141 -0
- package/dist/connectors/elasticsearch.js +601 -0
- package/dist/connectors/elasticsearch.js.map +1 -0
- package/dist/connectors/figma.d.ts +130 -0
- package/dist/connectors/figma.js +387 -0
- package/dist/connectors/figma.js.map +1 -0
- package/dist/connectors/github.d.ts +17 -0
- package/dist/connectors/github.js +53 -2
- package/dist/connectors/github.js.map +1 -1
- package/dist/connectors/gitlab.js +12 -6
- package/dist/connectors/gitlab.js.map +1 -1
- package/dist/connectors/gmail.js +72 -21
- package/dist/connectors/gmail.js.map +1 -1
- package/dist/connectors/googleCalendar.js +8 -8
- package/dist/connectors/googleCalendar.js.map +1 -1
- package/dist/connectors/googleDocs.d.ts +103 -0
- package/dist/connectors/googleDocs.js +409 -0
- package/dist/connectors/googleDocs.js.map +1 -0
- package/dist/connectors/googleDrive.d.ts +12 -0
- package/dist/connectors/googleDrive.js +35 -8
- package/dist/connectors/googleDrive.js.map +1 -1
- package/dist/connectors/grafana.d.ts +133 -0
- package/dist/connectors/grafana.js +478 -0
- package/dist/connectors/grafana.js.map +1 -0
- package/dist/connectors/jira.d.ts +25 -0
- package/dist/connectors/jira.js +245 -2
- package/dist/connectors/jira.js.map +1 -1
- package/dist/connectors/linear.js +1 -1
- package/dist/connectors/linear.js.map +1 -1
- package/dist/connectors/mcpOAuth.js +78 -16
- package/dist/connectors/mcpOAuth.js.map +1 -1
- package/dist/connectors/monday.d.ts +217 -0
- package/dist/connectors/monday.js +655 -0
- package/dist/connectors/monday.js.map +1 -0
- package/dist/connectors/mongodb.d.ts +139 -0
- package/dist/connectors/mongodb.js +455 -0
- package/dist/connectors/mongodb.js.map +1 -0
- package/dist/connectors/oauthStateStore.d.ts +20 -0
- package/dist/connectors/oauthStateStore.js +94 -4
- package/dist/connectors/oauthStateStore.js.map +1 -1
- package/dist/connectors/obsidian.d.ts +83 -0
- package/dist/connectors/obsidian.js +441 -0
- package/dist/connectors/obsidian.js.map +1 -0
- package/dist/connectors/paystack.d.ts +159 -0
- package/dist/connectors/paystack.js +607 -0
- package/dist/connectors/paystack.js.map +1 -0
- package/dist/connectors/pipedrive.d.ts +189 -0
- package/dist/connectors/pipedrive.js +559 -0
- package/dist/connectors/pipedrive.js.map +1 -0
- package/dist/connectors/postgres.d.ts +127 -0
- package/dist/connectors/postgres.js +512 -0
- package/dist/connectors/postgres.js.map +1 -0
- package/dist/connectors/posthog.d.ts +119 -0
- package/dist/connectors/posthog.js +479 -0
- package/dist/connectors/posthog.js.map +1 -0
- package/dist/connectors/redis.d.ts +140 -0
- package/dist/connectors/redis.js +571 -0
- package/dist/connectors/redis.js.map +1 -0
- package/dist/connectors/resend.d.ts +131 -0
- package/dist/connectors/resend.js +529 -0
- package/dist/connectors/resend.js.map +1 -0
- package/dist/connectors/salesforce.d.ts +136 -0
- package/dist/connectors/salesforce.js +603 -0
- package/dist/connectors/salesforce.js.map +1 -0
- package/dist/connectors/secrets.d.ts +51 -0
- package/dist/connectors/secrets.js +102 -0
- package/dist/connectors/secrets.js.map +1 -0
- package/dist/connectors/sendgrid.d.ts +102 -0
- package/dist/connectors/sendgrid.js +423 -0
- package/dist/connectors/sendgrid.js.map +1 -0
- package/dist/connectors/shopify.d.ts +145 -0
- package/dist/connectors/shopify.js +502 -0
- package/dist/connectors/shopify.js.map +1 -0
- package/dist/connectors/slack.d.ts +1 -1
- package/dist/connectors/slack.js +61 -9
- package/dist/connectors/slack.js.map +1 -1
- package/dist/connectors/snowflake.d.ts +119 -0
- package/dist/connectors/snowflake.js +615 -0
- package/dist/connectors/snowflake.js.map +1 -0
- package/dist/connectors/supabase.d.ts +92 -0
- package/dist/connectors/supabase.js +630 -0
- package/dist/connectors/supabase.js.map +1 -0
- package/dist/connectors/todoist.d.ts +117 -0
- package/dist/connectors/todoist.js +485 -0
- package/dist/connectors/todoist.js.map +1 -0
- package/dist/connectors/tokenStorage.js +56 -14
- package/dist/connectors/tokenStorage.js.map +1 -1
- package/dist/connectors/twilio.d.ts +118 -0
- package/dist/connectors/twilio.js +475 -0
- package/dist/connectors/twilio.js.map +1 -0
- package/dist/connectors/vercel.d.ts +110 -0
- package/dist/connectors/vercel.js +479 -0
- package/dist/connectors/vercel.js.map +1 -0
- package/dist/connectors/webflow.d.ts +118 -0
- package/dist/connectors/webflow.js +393 -0
- package/dist/connectors/webflow.js.map +1 -0
- package/dist/connectors/woocommerce.d.ts +220 -0
- package/dist/connectors/woocommerce.js +464 -0
- package/dist/connectors/woocommerce.js.map +1 -0
- package/dist/crypto.js +7 -2
- package/dist/crypto.js.map +1 -1
- package/dist/decisionReplay.js +15 -6
- package/dist/decisionReplay.js.map +1 -1
- package/dist/decisionTraceLog.d.ts +28 -0
- package/dist/decisionTraceLog.js +156 -29
- package/dist/decisionTraceLog.js.map +1 -1
- package/dist/drivers/claude/api.js +5 -4
- package/dist/drivers/claude/api.js.map +1 -1
- package/dist/drivers/claude/envSanitizer.d.ts +0 -6
- package/dist/drivers/claude/envSanitizer.js +17 -2
- package/dist/drivers/claude/envSanitizer.js.map +1 -1
- package/dist/drivers/claude/streamParser.js +5 -4
- package/dist/drivers/claude/streamParser.js.map +1 -1
- package/dist/drivers/claude/subprocess.d.ts +12 -2
- package/dist/drivers/claude/subprocess.js +100 -8
- package/dist/drivers/claude/subprocess.js.map +1 -1
- package/dist/drivers/gemini/api.d.ts +18 -0
- package/dist/drivers/gemini/api.js +29 -0
- package/dist/drivers/gemini/api.js.map +1 -0
- package/dist/drivers/gemini/index.d.ts +22 -0
- package/dist/drivers/gemini/index.js +256 -129
- package/dist/drivers/gemini/index.js.map +1 -1
- package/dist/drivers/index.d.ts +3 -1
- package/dist/drivers/index.js +9 -1
- package/dist/drivers/index.js.map +1 -1
- package/dist/drivers/local/index.d.ts +43 -0
- package/dist/drivers/local/index.js +140 -0
- package/dist/drivers/local/index.js.map +1 -0
- package/dist/drivers/openai/index.js +30 -2
- package/dist/drivers/openai/index.js.map +1 -1
- package/dist/extensionClient.d.ts +37 -4
- package/dist/extensionClient.js +58 -16
- package/dist/extensionClient.js.map +1 -1
- package/dist/featureFlags.d.ts +91 -0
- package/dist/featureFlags.js +174 -3
- package/dist/featureFlags.js.map +1 -1
- package/dist/fileLock.js +21 -12
- package/dist/fileLock.js.map +1 -1
- package/dist/fileLockSync.d.ts +67 -0
- package/dist/fileLockSync.js +126 -0
- package/dist/fileLockSync.js.map +1 -0
- package/dist/fp/activityAnalytics.js +26 -12
- package/dist/fp/activityAnalytics.js.map +1 -1
- package/dist/fp/automationInterpreter.d.ts +15 -1
- package/dist/fp/automationInterpreter.js +217 -82
- package/dist/fp/automationInterpreter.js.map +1 -1
- package/dist/fp/automationProgram.d.ts +30 -0
- package/dist/fp/automationProgram.js.map +1 -1
- package/dist/fp/automationState.d.ts +24 -5
- package/dist/fp/automationState.js +56 -9
- package/dist/fp/automationState.js.map +1 -1
- package/dist/fp/automationUtils.js +1 -1
- package/dist/fp/automationUtils.js.map +1 -1
- package/dist/fp/commandDescription.js +7 -1
- package/dist/fp/commandDescription.js.map +1 -1
- package/dist/fp/extensionSnapshot.js +8 -2
- package/dist/fp/extensionSnapshot.js.map +1 -1
- package/dist/fp/interpreterContext.d.ts +66 -1
- package/dist/fp/interpreterContext.js +91 -1
- package/dist/fp/interpreterContext.js.map +1 -1
- package/dist/fp/policyParser.js +29 -1
- package/dist/fp/policyParser.js.map +1 -1
- package/dist/fsWatchWithFallback.d.ts +36 -0
- package/dist/fsWatchWithFallback.js +128 -0
- package/dist/fsWatchWithFallback.js.map +1 -0
- package/dist/haltPushDispatch.d.ts +33 -0
- package/dist/haltPushDispatch.js +103 -0
- package/dist/haltPushDispatch.js.map +1 -0
- package/dist/httpBodyValidation.d.ts +41 -0
- package/dist/httpBodyValidation.js +45 -0
- package/dist/httpBodyValidation.js.map +1 -0
- package/dist/httpErrorResponse.d.ts +36 -0
- package/dist/httpErrorResponse.js +46 -0
- package/dist/httpErrorResponse.js.map +1 -0
- package/dist/inboxRoutes.d.ts +22 -0
- package/dist/inboxRoutes.js +151 -12
- package/dist/inboxRoutes.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1054 -76
- package/dist/index.js.map +1 -1
- package/dist/installGuard.js +6 -2
- package/dist/installGuard.js.map +1 -1
- package/dist/lockfile.js +31 -4
- package/dist/lockfile.js.map +1 -1
- package/dist/oauth.d.ts +22 -0
- package/dist/oauth.js +46 -0
- package/dist/oauth.js.map +1 -1
- package/dist/oauthRoutes.d.ts +1 -1
- package/dist/oauthRoutes.js +8 -11
- package/dist/oauthRoutes.js.map +1 -1
- package/dist/orchestrator/childBridgeRegistry.js +29 -11
- package/dist/orchestrator/childBridgeRegistry.js.map +1 -1
- package/dist/patchworkConfig.d.ts +57 -1
- package/dist/patchworkConfig.js +125 -5
- package/dist/patchworkConfig.js.map +1 -1
- package/dist/pluginLoader.js +10 -1
- package/dist/pluginLoader.js.map +1 -1
- package/dist/pluginWatcher.js +12 -14
- package/dist/pluginWatcher.js.map +1 -1
- package/dist/preToolUseHook.js +10 -3
- package/dist/preToolUseHook.js.map +1 -1
- package/dist/processTree.d.ts +34 -0
- package/dist/processTree.js +105 -0
- package/dist/processTree.js.map +1 -0
- package/dist/prompts.js +7 -3
- package/dist/prompts.js.map +1 -1
- package/dist/recipeOrchestration.d.ts +9 -0
- package/dist/recipeOrchestration.js +354 -27
- package/dist/recipeOrchestration.js.map +1 -1
- package/dist/recipeRoutes.d.ts +63 -2
- package/dist/recipeRoutes.js +790 -137
- package/dist/recipeRoutes.js.map +1 -1
- package/dist/recipes/RecipeOrchestrator.d.ts +2 -0
- package/dist/recipes/RecipeOrchestrator.js +6 -1
- package/dist/recipes/RecipeOrchestrator.js.map +1 -1
- package/dist/recipes/agentExecutor.d.ts +34 -5
- package/dist/recipes/agentExecutor.js +5 -4
- package/dist/recipes/agentExecutor.js.map +1 -1
- package/dist/recipes/chainedRunner.d.ts +2 -0
- package/dist/recipes/chainedRunner.js +142 -5
- package/dist/recipes/chainedRunner.js.map +1 -1
- package/dist/recipes/connectorPreflight.d.ts +66 -0
- package/dist/recipes/connectorPreflight.js +169 -0
- package/dist/recipes/connectorPreflight.js.map +1 -0
- package/dist/recipes/dependencyGraph.js +13 -5
- package/dist/recipes/dependencyGraph.js.map +1 -1
- package/dist/recipes/githubInstallSource.d.ts +128 -0
- package/dist/recipes/githubInstallSource.js +206 -0
- package/dist/recipes/githubInstallSource.js.map +1 -0
- package/dist/recipes/haltCategory.d.ts +119 -0
- package/dist/recipes/haltCategory.js +188 -0
- package/dist/recipes/haltCategory.js.map +1 -0
- package/dist/recipes/idempotencyKey.d.ts +134 -0
- package/dist/recipes/idempotencyKey.js +322 -0
- package/dist/recipes/idempotencyKey.js.map +1 -0
- package/dist/recipes/installer.js +48 -2
- package/dist/recipes/installer.js.map +1 -1
- package/dist/recipes/judgeSummary.d.ts +50 -0
- package/dist/recipes/judgeSummary.js +47 -0
- package/dist/recipes/judgeSummary.js.map +1 -0
- package/dist/recipes/judgeVerdict.d.ts +48 -0
- package/dist/recipes/judgeVerdict.js +174 -0
- package/dist/recipes/judgeVerdict.js.map +1 -0
- package/dist/recipes/migrations/index.d.ts +9 -0
- package/dist/recipes/migrations/index.js +133 -0
- package/dist/recipes/migrations/index.js.map +1 -1
- package/dist/recipes/names.d.ts +20 -0
- package/dist/recipes/names.js +25 -0
- package/dist/recipes/names.js.map +1 -1
- package/dist/recipes/parser.js +88 -5
- package/dist/recipes/parser.js.map +1 -1
- package/dist/recipes/replayRun.js +1 -1
- package/dist/recipes/replayRun.js.map +1 -1
- package/dist/recipes/runBudget.d.ts +70 -0
- package/dist/recipes/runBudget.js +109 -0
- package/dist/recipes/runBudget.js.map +1 -0
- package/dist/recipes/scheduler.d.ts +30 -0
- package/dist/recipes/scheduler.js +69 -19
- package/dist/recipes/scheduler.js.map +1 -1
- package/dist/recipes/schema.d.ts +36 -0
- package/dist/recipes/schemaGenerator.js +103 -5
- package/dist/recipes/schemaGenerator.js.map +1 -1
- package/dist/recipes/stepObservation.js +9 -0
- package/dist/recipes/stepObservation.js.map +1 -1
- package/dist/recipes/toolRegistry.js +20 -3
- package/dist/recipes/toolRegistry.js.map +1 -1
- package/dist/recipes/tools/fanOut.d.ts +20 -0
- package/dist/recipes/tools/fanOut.js +199 -0
- package/dist/recipes/tools/fanOut.js.map +1 -0
- package/dist/recipes/tools/file.js +5 -2
- package/dist/recipes/tools/file.js.map +1 -1
- package/dist/recipes/tools/github.d.ts +1 -1
- package/dist/recipes/tools/github.js +75 -1
- package/dist/recipes/tools/github.js.map +1 -1
- package/dist/recipes/tools/gmail.js +45 -6
- package/dist/recipes/tools/gmail.js.map +1 -1
- package/dist/recipes/tools/googleDrive.js +64 -0
- package/dist/recipes/tools/googleDrive.js.map +1 -1
- package/dist/recipes/tools/http.d.ts +10 -0
- package/dist/recipes/tools/http.js +176 -0
- package/dist/recipes/tools/http.js.map +1 -0
- package/dist/recipes/tools/index.d.ts +2 -0
- package/dist/recipes/tools/index.js +2 -0
- package/dist/recipes/tools/index.js.map +1 -1
- package/dist/recipes/tools/slack.js +1 -1
- package/dist/recipes/validation.d.ts +17 -0
- package/dist/recipes/validation.js +29 -11
- package/dist/recipes/validation.js.map +1 -1
- package/dist/recipes/workspaceRoot.d.ts +37 -0
- package/dist/recipes/workspaceRoot.js +73 -0
- package/dist/recipes/workspaceRoot.js.map +1 -0
- package/dist/recipes/yamlPositions.d.ts +56 -0
- package/dist/recipes/yamlPositions.js +183 -0
- package/dist/recipes/yamlPositions.js.map +1 -0
- package/dist/recipes/yamlRunner.d.ts +195 -8
- package/dist/recipes/yamlRunner.js +877 -209
- package/dist/recipes/yamlRunner.js.map +1 -1
- package/dist/recipesHttp.d.ts +33 -3
- package/dist/recipesHttp.js +126 -12
- package/dist/recipesHttp.js.map +1 -1
- package/dist/resources.js +21 -13
- package/dist/resources.js.map +1 -1
- package/dist/runLog.d.ts +58 -5
- package/dist/runLog.js +98 -21
- package/dist/runLog.js.map +1 -1
- package/dist/sanitizeParsedJson.d.ts +39 -0
- package/dist/sanitizeParsedJson.js +55 -0
- package/dist/sanitizeParsedJson.js.map +1 -0
- package/dist/schemas/recipe.v1.json +885 -196
- package/dist/server.d.ts +166 -3
- package/dist/server.js +1313 -332
- package/dist/server.js.map +1 -1
- package/dist/sessionCheckpoint.d.ts +8 -0
- package/dist/sessionCheckpoint.js +33 -3
- package/dist/sessionCheckpoint.js.map +1 -1
- package/dist/ssrfGuard.d.ts +16 -0
- package/dist/ssrfGuard.js +87 -4
- package/dist/ssrfGuard.js.map +1 -1
- package/dist/streamableHttp.d.ts +9 -4
- package/dist/streamableHttp.js +76 -20
- package/dist/streamableHttp.js.map +1 -1
- package/dist/telemetry.js +19 -12
- package/dist/telemetry.js.map +1 -1
- package/dist/testing/shadowRun.d.ts +52 -0
- package/dist/testing/shadowRun.js +71 -0
- package/dist/testing/shadowRun.js.map +1 -0
- package/dist/tools/batchLsp.d.ts +3 -0
- package/dist/tools/bridgeDoctor.d.ts +11 -0
- package/dist/tools/bridgeDoctor.js +48 -2
- package/dist/tools/bridgeDoctor.js.map +1 -1
- package/dist/tools/bridgeStatus.d.ts +0 -12
- package/dist/tools/bridgeStatus.js +2 -28
- package/dist/tools/bridgeStatus.js.map +1 -1
- package/dist/tools/cancelClaudeTask.d.ts +1 -0
- package/dist/tools/clipboard.d.ts +2 -0
- package/dist/tools/closeTabs.d.ts +1 -0
- package/dist/tools/codeLens.d.ts +1 -0
- package/dist/tools/createIssueFromAIComment.d.ts +1 -0
- package/dist/tools/ctxGetTaskContext.d.ts +9 -0
- package/dist/tools/ctxGetTaskContext.js +50 -2
- package/dist/tools/ctxGetTaskContext.js.map +1 -1
- package/dist/tools/ctxQueryTraces.js +32 -24
- package/dist/tools/ctxQueryTraces.js.map +1 -1
- 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/detectUnusedCode.js +9 -7
- package/dist/tools/detectUnusedCode.js.map +1 -1
- package/dist/tools/documentLinks.d.ts +1 -0
- package/dist/tools/editText.d.ts +1 -0
- package/dist/tools/editText.js +2 -1
- package/dist/tools/editText.js.map +1 -1
- package/dist/tools/enrichCommit.d.ts +1 -0
- package/dist/tools/enrichStackTrace.js +11 -5
- package/dist/tools/enrichStackTrace.js.map +1 -1
- package/dist/tools/explainDiagnostic.d.ts +1 -0
- package/dist/tools/explainSymbol.d.ts +1 -0
- package/dist/tools/fileOperations.d.ts +3 -0
- package/dist/tools/fileOperations.js +2 -1
- package/dist/tools/fileOperations.js.map +1 -1
- package/dist/tools/fileWatcher.d.ts +2 -0
- package/dist/tools/fileWatcher.js +8 -2
- package/dist/tools/fileWatcher.js.map +1 -1
- package/dist/tools/findFiles.d.ts +1 -0
- package/dist/tools/fixAllLintErrors.d.ts +1 -0
- package/dist/tools/fixAllLintErrors.js +10 -5
- package/dist/tools/fixAllLintErrors.js.map +1 -1
- package/dist/tools/foldingRanges.d.ts +1 -0
- package/dist/tools/formatDocument.d.ts +1 -0
- package/dist/tools/formatDocument.js +10 -5
- package/dist/tools/formatDocument.js.map +1 -1
- package/dist/tools/generateTests.d.ts +1 -0
- package/dist/tools/getAIComments.d.ts +1 -0
- package/dist/tools/getAnalyticsReport.js +5 -1
- package/dist/tools/getAnalyticsReport.js.map +1 -1
- package/dist/tools/getBufferContent.d.ts +1 -0
- package/dist/tools/getChangeImpact.d.ts +1 -0
- package/dist/tools/getChangeImpact.js +23 -14
- package/dist/tools/getChangeImpact.js.map +1 -1
- package/dist/tools/getClaudeTaskStatus.d.ts +1 -0
- package/dist/tools/getCodeCoverage.d.ts +1 -0
- package/dist/tools/getCodeCoverage.js +32 -14
- package/dist/tools/getCodeCoverage.js.map +1 -1
- package/dist/tools/getCommitsForIssue.d.ts +1 -0
- package/dist/tools/getDebugState.d.ts +1 -0
- package/dist/tools/getDiagnostics.js +32 -29
- package/dist/tools/getDiagnostics.js.map +1 -1
- package/dist/tools/getDiffFromHandoff.js +8 -2
- package/dist/tools/getDiffFromHandoff.js.map +1 -1
- package/dist/tools/getDocumentSymbols.d.ts +1 -0
- package/dist/tools/getGitHotspots.d.ts +1 -0
- package/dist/tools/getImportedSignatures.d.ts +1 -0
- package/dist/tools/getImportedSignatures.js +18 -14
- package/dist/tools/getImportedSignatures.js.map +1 -1
- package/dist/tools/getPRTemplate.d.ts +1 -0
- package/dist/tools/getProjectContext.js +23 -10
- package/dist/tools/getProjectContext.js.map +1 -1
- package/dist/tools/getSymbolHistory.d.ts +1 -0
- package/dist/tools/getToolCapabilities.d.ts +10 -5
- package/dist/tools/getToolCapabilities.js +79 -202
- package/dist/tools/getToolCapabilities.js.map +1 -1
- package/dist/tools/getTypeSignature.d.ts +1 -0
- package/dist/tools/getWorkspaceSettings.d.ts +1 -0
- package/dist/tools/gitWrite.d.ts +11 -0
- package/dist/tools/github/actions.d.ts +2 -0
- package/dist/tools/github/composite.d.ts +3 -0
- package/dist/tools/github/issues.d.ts +4 -0
- package/dist/tools/github/pr.d.ts +7 -0
- package/dist/tools/handoffNote.d.ts +1 -0
- package/dist/tools/handoffNote.js +2 -1
- package/dist/tools/handoffNote.js.map +1 -1
- package/dist/tools/headless/lspClient.js +3 -0
- package/dist/tools/headless/lspClient.js.map +1 -1
- package/dist/tools/hoverAtCursor.d.ts +1 -0
- package/dist/tools/httpClient.d.ts +2 -0
- package/dist/tools/httpClient.js +38 -71
- package/dist/tools/httpClient.js.map +1 -1
- package/dist/tools/inlayHints.d.ts +1 -0
- package/dist/tools/launchQuickTask.d.ts +1 -0
- package/dist/tools/listClaudeTasks.d.ts +1 -0
- package/dist/tools/listClaudeTasks.js +10 -8
- package/dist/tools/listClaudeTasks.js.map +1 -1
- package/dist/tools/listTerminals.d.ts +1 -0
- package/dist/tools/lsp.d.ts +15 -0
- package/dist/tools/lsp.js +17 -0
- package/dist/tools/lsp.js.map +1 -1
- package/dist/tools/navigateToSymbolByName.d.ts +1 -0
- package/dist/tools/openDiff.d.ts +1 -0
- package/dist/tools/openDiff.js +4 -1
- package/dist/tools/openDiff.js.map +1 -1
- package/dist/tools/openFile.d.ts +1 -0
- package/dist/tools/openFile.js +4 -1
- package/dist/tools/openFile.js.map +1 -1
- package/dist/tools/openInBrowser.js +6 -1
- package/dist/tools/openInBrowser.js.map +1 -1
- package/dist/tools/organizeImports.d.ts +1 -0
- package/dist/tools/organizeImports.js +5 -3
- package/dist/tools/organizeImports.js.map +1 -1
- package/dist/tools/performanceReport.js +5 -3
- package/dist/tools/performanceReport.js.map +1 -1
- package/dist/tools/planPersistence.d.ts +3 -0
- package/dist/tools/planPersistence.js +4 -1
- package/dist/tools/planPersistence.js.map +1 -1
- package/dist/tools/previewEdit.d.ts +1 -0
- package/dist/tools/previewEdit.js +15 -4
- package/dist/tools/previewEdit.js.map +1 -1
- package/dist/tools/recentTracesDigest.js +54 -11
- package/dist/tools/recentTracesDigest.js.map +1 -1
- package/dist/tools/refactorAnalyze.d.ts +1 -0
- package/dist/tools/refactorExtractFunction.js +4 -1
- package/dist/tools/refactorExtractFunction.js.map +1 -1
- package/dist/tools/refactorPreview.d.ts +1 -0
- package/dist/tools/refactorPreview.js +10 -2
- package/dist/tools/refactorPreview.js.map +1 -1
- package/dist/tools/replaceBlock.d.ts +1 -0
- package/dist/tools/replaceBlock.js +2 -1
- package/dist/tools/replaceBlock.js.map +1 -1
- package/dist/tools/resumeClaudeTask.d.ts +1 -0
- package/dist/tools/runClaudeTask.d.ts +1 -0
- package/dist/tools/runCommand.js +5 -0
- package/dist/tools/runCommand.js.map +1 -1
- package/dist/tools/runTests.js +15 -4
- package/dist/tools/runTests.js.map +1 -1
- package/dist/tools/screenshot.d.ts +1 -0
- package/dist/tools/screenshotAndAnnotate.js +6 -2
- package/dist/tools/screenshotAndAnnotate.js.map +1 -1
- package/dist/tools/searchAndReplace.d.ts +1 -0
- package/dist/tools/searchAndReplace.js +17 -7
- package/dist/tools/searchAndReplace.js.map +1 -1
- package/dist/tools/searchTools.js +20 -19
- 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/signatureHelp.d.ts +1 -0
- package/dist/tools/spawnWorkspace.js +15 -7
- package/dist/tools/spawnWorkspace.js.map +1 -1
- package/dist/tools/terminal.d.ts +6 -0
- package/dist/tools/terminal.js +4 -0
- package/dist/tools/terminal.js.map +1 -1
- package/dist/tools/testRunners/pytest.js +6 -2
- package/dist/tools/testRunners/pytest.js.map +1 -1
- package/dist/tools/testRunners/vitestJest.js +3 -1
- package/dist/tools/testRunners/vitestJest.js.map +1 -1
- package/dist/tools/testTraceToSource.d.ts +1 -0
- package/dist/tools/transaction.d.ts +4 -0
- package/dist/tools/transaction.js +4 -1
- package/dist/tools/transaction.js.map +1 -1
- package/dist/tools/typeHierarchy.d.ts +1 -0
- package/dist/tools/utils.d.ts +22 -0
- package/dist/tools/utils.js +158 -14
- 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/transport.d.ts +3 -1
- package/dist/transport.js +103 -52
- package/dist/transport.js.map +1 -1
- package/dist/winShim.d.ts +34 -0
- package/dist/winShim.js +94 -0
- package/dist/winShim.js.map +1 -0
- package/dist/wireHaltPushDispatch.d.ts +38 -0
- package/dist/wireHaltPushDispatch.js +71 -0
- package/dist/wireHaltPushDispatch.js.map +1 -0
- package/dist/writeFileAtomic.d.ts +23 -0
- package/dist/writeFileAtomic.js +121 -0
- package/dist/writeFileAtomic.js.map +1 -0
- package/package.json +23 -7
- package/scripts/postinstall.mjs +42 -2
- package/scripts/smoke/run-all.mjs +213 -0
- package/scripts/start-all.mjs +572 -0
- package/scripts/start-all.ps1 +209 -0
- package/scripts/start-all.sh +77 -19
- package/scripts/start-orchestrator.ps1 +158 -0
- package/scripts/start-remote.mjs +122 -0
- package/templates/automation-policies/recipe-authoring.json +1 -1
- package/templates/automation-policies/security-first.json +1 -1
- package/templates/automation-policies/strict-lint.json +1 -1
- package/templates/automation-policies/test-driven.json +1 -1
- package/templates/automation-policy.example.json +1 -1
- package/templates/co.patchwork-os.bridge.plist +2 -2
- package/templates/recipes/approval-queue-ui-test.yaml +205 -0
- package/templates/recipes/ctx-loop-test.yaml +1 -1
- package/templates/recipes/fix-errors-on-save.yaml +71 -0
- package/templates/recipes/morning-brief.yaml +5 -2
- package/templates/recipes/project-health-check.yaml +4 -1
- package/templates/recipes/sentry-to-linear.yaml +72 -38
- package/templates/recipes/webhook/apple-watch-health-log.yaml +145 -0
- package/templates/recipes/webhook/customer-escalation.yaml +8 -9
- package/templates/recipes/webhook/meeting-prep.yaml +11 -5
- package/dist/commands/marketplace.d.ts +0 -11
- package/dist/commands/marketplace.js +0 -120
- package/dist/commands/marketplace.js.map +0 -1
- package/dist/recipes/legacyRecipeCompat.d.ts +0 -10
- package/dist/recipes/legacyRecipeCompat.js +0 -131
- package/dist/recipes/legacyRecipeCompat.js.map +0 -1
|
@@ -61,6 +61,7 @@ export function buildDependencyGraph(steps) {
|
|
|
61
61
|
}
|
|
62
62
|
const topologicalOrder = [];
|
|
63
63
|
while (queue.length > 0) {
|
|
64
|
+
// biome-ignore lint/style/noNonNullAssertion: queue.length > 0 guard ensures shift() is defined
|
|
64
65
|
const stepId = queue.shift();
|
|
65
66
|
topologicalOrder.push(stepId);
|
|
66
67
|
const dependents = adjacency.get(stepId) ?? [];
|
|
@@ -163,13 +164,15 @@ export async function executeWithDependencies(graph, executeStep, options) {
|
|
|
163
164
|
resolvers.delete(stepId);
|
|
164
165
|
}
|
|
165
166
|
}
|
|
166
|
-
// Execute with concurrency limit
|
|
167
|
+
// Execute with concurrency limit (clamp to 1 so maxConcurrency:0 or negative never busy-loops)
|
|
168
|
+
const concurrency = Math.max(1, options.maxConcurrency);
|
|
167
169
|
const executing = [];
|
|
168
170
|
const queue = [...graph.topologicalOrder];
|
|
169
171
|
async function processQueue() {
|
|
170
172
|
while (queue.length > 0 || executing.length > 0) {
|
|
171
173
|
// Start new steps if under concurrency limit
|
|
172
|
-
while (executing.length <
|
|
174
|
+
while (executing.length < concurrency && queue.length > 0) {
|
|
175
|
+
// biome-ignore lint/style/noNonNullAssertion: queue.length > 0 guard ensures shift() is defined
|
|
173
176
|
const stepId = queue.shift();
|
|
174
177
|
// C2: push before attaching .then() so indexOf is never -1
|
|
175
178
|
let resolveSlot;
|
|
@@ -192,8 +195,13 @@ export async function executeWithDependencies(graph, executeStep, options) {
|
|
|
192
195
|
}
|
|
193
196
|
/** Get steps that can run immediately (no unresolved dependencies) */
|
|
194
197
|
export function getReadySteps(graph, completed) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
.
|
|
198
|
+
const result = [];
|
|
199
|
+
for (const s of graph.steps) {
|
|
200
|
+
if (!completed.has(s.stepId) &&
|
|
201
|
+
s.awaits.every((dep) => completed.has(dep))) {
|
|
202
|
+
result.push(s.stepId);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return result;
|
|
198
206
|
}
|
|
199
207
|
//# sourceMappingURL=dependencyGraph.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencyGraph.js","sourceRoot":"","sources":["../../src/recipes/dependencyGraph.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAsBH,mDAAmD;AACnD,MAAM,UAAU,oBAAoB,CAClC,KAA+C;IAE/C,MAAM,KAAK,GAAqB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACvD,MAAM,EAAE,CAAC,CAAC,EAAE;QACZ,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,EAAE;QACtB,KAAK;KACN,CAAC,CAAC,CAAC;IAEJ,0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C;IACH,CAAC;IAED,MAAM,YAAY,EAAE,CAAC;IACrB,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,aAAa,CAC3B,KAAsB,EACtB,SAAsB;IAEtB,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC5B,IACE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC;YACxB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAC3C,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses + allowlists the `github:<owner>/<repo>/(recipes|bundles)/<name>`
|
|
3
|
+
* source format used by `POST /recipes/install`.
|
|
4
|
+
*
|
|
5
|
+
* Before this module existed, the install handler hard-coded
|
|
6
|
+
* `github:patchworkos/recipes/...` everywhere — every URL, every
|
|
7
|
+
* prefix match. Third-party orgs / forks / private mirrors could not
|
|
8
|
+
* host recipe catalogs even though the rest of the install pipeline
|
|
9
|
+
* (SSRF guard, parser, scheduler) is org-agnostic.
|
|
10
|
+
*
|
|
11
|
+
* Allowlist policy:
|
|
12
|
+
* - Always includes `patchworkos/recipes` (backward compat).
|
|
13
|
+
* - Operator opts in additional `<owner>/<repo>` entries via the
|
|
14
|
+
* `PATCHWORK_RECIPE_REPO_ALLOWLIST` env var (comma-separated).
|
|
15
|
+
* - Allowlist matching is case-insensitive (GitHub itself is).
|
|
16
|
+
* - Both owner and repo segments must match the strict regex
|
|
17
|
+
* `[a-z0-9_.-]{1,100}` AFTER lowercasing — guards against
|
|
18
|
+
* traversal segments smuggled into the source string.
|
|
19
|
+
*
|
|
20
|
+
* The default-only behaviour matches the audit recommendation: real
|
|
21
|
+
* multi-org support is opt-in, so existing single-org deployments
|
|
22
|
+
* don't see a behaviour change.
|
|
23
|
+
*/
|
|
24
|
+
export type GithubInstallKind = "recipe" | "bundle";
|
|
25
|
+
export interface ParsedGithubInstallSource {
|
|
26
|
+
kind: GithubInstallKind;
|
|
27
|
+
owner: string;
|
|
28
|
+
repo: string;
|
|
29
|
+
/** Recipe name (single basename) or bundle name. */
|
|
30
|
+
name: string;
|
|
31
|
+
}
|
|
32
|
+
export type GithubInstallParseResult = {
|
|
33
|
+
ok: true;
|
|
34
|
+
parsed: ParsedGithubInstallSource;
|
|
35
|
+
} | {
|
|
36
|
+
ok: false;
|
|
37
|
+
code: "bad_shape" | "bad_segment" | "not_allowlisted";
|
|
38
|
+
error: string;
|
|
39
|
+
};
|
|
40
|
+
export declare const SEGMENT_RE: RegExp;
|
|
41
|
+
/**
|
|
42
|
+
* Read the runtime allowlist. Combines the always-on default with
|
|
43
|
+
* whatever the operator has set in PATCHWORK_RECIPE_REPO_ALLOWLIST.
|
|
44
|
+
* Entries are lowercased + de-duplicated; trailing whitespace, empty
|
|
45
|
+
* fragments, and shapes that don't look like `owner/repo` are
|
|
46
|
+
* silently dropped (logging here is the install handler's job, not
|
|
47
|
+
* this pure helper's).
|
|
48
|
+
*/
|
|
49
|
+
export declare function loadAllowlist(env?: NodeJS.ProcessEnv): string[];
|
|
50
|
+
/**
|
|
51
|
+
* Parse a `github:owner/repo/(recipes|bundles)/name` source string
|
|
52
|
+
* against the active allowlist. Pure — does NOT fetch anything; the
|
|
53
|
+
* install handler is responsible for the network leg and the SSRF
|
|
54
|
+
* guard. Returns a discriminated union the caller can map to a 400
|
|
55
|
+
* (bad_shape / bad_segment) or 403 (not_allowlisted) response.
|
|
56
|
+
*/
|
|
57
|
+
export declare function parseGithubInstallSource(source: string, allowlist?: ReadonlyArray<string>): GithubInstallParseResult;
|
|
58
|
+
/**
|
|
59
|
+
* Build the raw.githubusercontent URL for a parsed install source.
|
|
60
|
+
* Always pulls `main` branch HEAD — version pinning is on the
|
|
61
|
+
* deferred audit backlog.
|
|
62
|
+
*/
|
|
63
|
+
export declare function buildGithubRawUrl(parsed: ParsedGithubInstallSource): string;
|
|
64
|
+
/**
|
|
65
|
+
* Build the `api.github.com` Contents-API URL for a parsed install
|
|
66
|
+
* source. Used as a FALLBACK when `raw.githubusercontent.com` is
|
|
67
|
+
* unreachable — many corporate / proxied networks block the raw host
|
|
68
|
+
* even when `api.github.com` is allowed. Combined with the
|
|
69
|
+
* `Accept: application/vnd.github.raw` request header (see
|
|
70
|
+
* `fetchGithubInstallFile`), this endpoint returns the raw file bytes
|
|
71
|
+
* directly — no base64 decode needed. Public repos work unauthenticated.
|
|
72
|
+
*/
|
|
73
|
+
export declare function buildGithubApiUrl(parsed: ParsedGithubInstallSource): string;
|
|
74
|
+
/**
|
|
75
|
+
* Fetch a recipe / bundle file for a parsed `github:` install source
|
|
76
|
+
* with a raw-host-first, API-fallback strategy.
|
|
77
|
+
*
|
|
78
|
+
* 1. Try `raw.githubusercontent.com` (fast path, no rate limit).
|
|
79
|
+
* 2. If that throws a network error OR returns a non-ok response,
|
|
80
|
+
* fall back to `api.github.com/repos/.../contents/...` with the
|
|
81
|
+
* `Accept: application/vnd.github.raw` header (returns raw bytes).
|
|
82
|
+
*
|
|
83
|
+
* Return contract — designed so the caller's existing error mapping
|
|
84
|
+
* (502 / `fetch_network_error`, 404 not-found, upstream-error) is
|
|
85
|
+
* unchanged:
|
|
86
|
+
*
|
|
87
|
+
* - `{ ok: true, response }` — a usable ok `Response`, from whichever
|
|
88
|
+
* host succeeded. Caller reads the body as before.
|
|
89
|
+
* - `{ ok: false, kind: "not_found", response }` — BOTH hosts agree
|
|
90
|
+
* the file does not exist (raw 404 AND api 404). Caller surfaces
|
|
91
|
+
* this as a genuine not-found (404), not a network error.
|
|
92
|
+
* - `{ ok: false, kind: "upstream_error", response }` — a non-ok,
|
|
93
|
+
* non-404 HTTP response (e.g. 5xx / 403 rate-limit). Caller maps
|
|
94
|
+
* the upstream status as today.
|
|
95
|
+
* - `{ ok: false, kind: "network_error", error }` — both hosts threw
|
|
96
|
+
* a network-level error (DNS / connect / abort). Caller surfaces
|
|
97
|
+
* the existing 502 `fetch_network_error` shape.
|
|
98
|
+
*
|
|
99
|
+
* Intentional edge case: when raw returns 404 but the api fallback
|
|
100
|
+
* *network-errors* (rather than also returning 404), the result is
|
|
101
|
+
* classified `not_found`, not `network_error`. This is a deliberate
|
|
102
|
+
* conservative call — a raw 404 is a strong signal the file is absent,
|
|
103
|
+
* and reporting "not found" is more actionable than a generic network
|
|
104
|
+
* error. Do not "fix" this to prefer network_error without weighing
|
|
105
|
+
* that tradeoff (see the matching test case).
|
|
106
|
+
*
|
|
107
|
+
* `signal` (caller's AbortController) and timeout behaviour are
|
|
108
|
+
* preserved — the same signal is passed to both fetch attempts.
|
|
109
|
+
*/
|
|
110
|
+
export type GithubInstallFetchResult = {
|
|
111
|
+
ok: true;
|
|
112
|
+
response: Response;
|
|
113
|
+
} | {
|
|
114
|
+
ok: false;
|
|
115
|
+
kind: "not_found";
|
|
116
|
+
response: Response;
|
|
117
|
+
} | {
|
|
118
|
+
ok: false;
|
|
119
|
+
kind: "upstream_error";
|
|
120
|
+
response: Response;
|
|
121
|
+
} | {
|
|
122
|
+
ok: false;
|
|
123
|
+
kind: "network_error";
|
|
124
|
+
error: unknown;
|
|
125
|
+
};
|
|
126
|
+
export declare function fetchGithubInstallFile(parsed: ParsedGithubInstallSource, init?: {
|
|
127
|
+
signal?: AbortSignal;
|
|
128
|
+
}): Promise<GithubInstallFetchResult>;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses + allowlists the `github:<owner>/<repo>/(recipes|bundles)/<name>`
|
|
3
|
+
* source format used by `POST /recipes/install`.
|
|
4
|
+
*
|
|
5
|
+
* Before this module existed, the install handler hard-coded
|
|
6
|
+
* `github:patchworkos/recipes/...` everywhere — every URL, every
|
|
7
|
+
* prefix match. Third-party orgs / forks / private mirrors could not
|
|
8
|
+
* host recipe catalogs even though the rest of the install pipeline
|
|
9
|
+
* (SSRF guard, parser, scheduler) is org-agnostic.
|
|
10
|
+
*
|
|
11
|
+
* Allowlist policy:
|
|
12
|
+
* - Always includes `patchworkos/recipes` (backward compat).
|
|
13
|
+
* - Operator opts in additional `<owner>/<repo>` entries via the
|
|
14
|
+
* `PATCHWORK_RECIPE_REPO_ALLOWLIST` env var (comma-separated).
|
|
15
|
+
* - Allowlist matching is case-insensitive (GitHub itself is).
|
|
16
|
+
* - Both owner and repo segments must match the strict regex
|
|
17
|
+
* `[a-z0-9_.-]{1,100}` AFTER lowercasing — guards against
|
|
18
|
+
* traversal segments smuggled into the source string.
|
|
19
|
+
*
|
|
20
|
+
* The default-only behaviour matches the audit recommendation: real
|
|
21
|
+
* multi-org support is opt-in, so existing single-org deployments
|
|
22
|
+
* don't see a behaviour change.
|
|
23
|
+
*/
|
|
24
|
+
const DEFAULT_ALLOWLIST = ["patchworkos/recipes"];
|
|
25
|
+
export const SEGMENT_RE = /^(?!.*\.\.)[a-z0-9_.-]{1,100}$/;
|
|
26
|
+
/**
|
|
27
|
+
* Read the runtime allowlist. Combines the always-on default with
|
|
28
|
+
* whatever the operator has set in PATCHWORK_RECIPE_REPO_ALLOWLIST.
|
|
29
|
+
* Entries are lowercased + de-duplicated; trailing whitespace, empty
|
|
30
|
+
* fragments, and shapes that don't look like `owner/repo` are
|
|
31
|
+
* silently dropped (logging here is the install handler's job, not
|
|
32
|
+
* this pure helper's).
|
|
33
|
+
*/
|
|
34
|
+
export function loadAllowlist(env = process.env) {
|
|
35
|
+
const fromEnv = (env.PATCHWORK_RECIPE_REPO_ALLOWLIST ?? "")
|
|
36
|
+
.split(",")
|
|
37
|
+
.map((s) => s.trim().toLowerCase())
|
|
38
|
+
.filter((s) => s.length > 0 && s.includes("/"));
|
|
39
|
+
return Array.from(new Set([...DEFAULT_ALLOWLIST, ...fromEnv]));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Parse a `github:owner/repo/(recipes|bundles)/name` source string
|
|
43
|
+
* against the active allowlist. Pure — does NOT fetch anything; the
|
|
44
|
+
* install handler is responsible for the network leg and the SSRF
|
|
45
|
+
* guard. Returns a discriminated union the caller can map to a 400
|
|
46
|
+
* (bad_shape / bad_segment) or 403 (not_allowlisted) response.
|
|
47
|
+
*/
|
|
48
|
+
export function parseGithubInstallSource(source, allowlist = loadAllowlist()) {
|
|
49
|
+
if (!source.startsWith("github:")) {
|
|
50
|
+
return {
|
|
51
|
+
ok: false,
|
|
52
|
+
code: "bad_shape",
|
|
53
|
+
error: "source must start with 'github:'",
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// After the `github:` prefix we expect <owner>/<repo>/<kind>/<name>.
|
|
57
|
+
// We split into exactly 4 segments — extra trailing slashes or
|
|
58
|
+
// missing components are rejected with `bad_shape` so the response
|
|
59
|
+
// is actionable.
|
|
60
|
+
const tail = source.slice("github:".length);
|
|
61
|
+
const segments = tail.split("/");
|
|
62
|
+
if (segments.length !== 4) {
|
|
63
|
+
return {
|
|
64
|
+
ok: false,
|
|
65
|
+
code: "bad_shape",
|
|
66
|
+
error: "source must match 'github:<owner>/<repo>/(recipes|bundles)/<name>'",
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const [ownerRaw, repoRaw, kindRaw, nameRaw] = segments;
|
|
70
|
+
const owner = ownerRaw.toLowerCase();
|
|
71
|
+
const repo = repoRaw.toLowerCase();
|
|
72
|
+
if (!SEGMENT_RE.test(owner) || !SEGMENT_RE.test(repo)) {
|
|
73
|
+
return {
|
|
74
|
+
ok: false,
|
|
75
|
+
code: "bad_segment",
|
|
76
|
+
error: "owner and repo must match [a-z0-9_.-]{1,100}",
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (kindRaw !== "recipes" && kindRaw !== "bundles") {
|
|
80
|
+
return {
|
|
81
|
+
ok: false,
|
|
82
|
+
code: "bad_shape",
|
|
83
|
+
error: "third path segment must be 'recipes' or 'bundles'",
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
// Reuse the strict basename predicate inline rather than importing
|
|
87
|
+
// recipeInstall.ts here (circular deps), but match its rules:
|
|
88
|
+
// single segment, no `..`, no slashes, conservative charset, ≤100.
|
|
89
|
+
if (!SEGMENT_RE.test(nameRaw.toLowerCase())) {
|
|
90
|
+
return {
|
|
91
|
+
ok: false,
|
|
92
|
+
code: "bad_segment",
|
|
93
|
+
error: "name must match [a-z0-9_.-]{1,100}",
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
const allowSet = new Set(allowlist.map((s) => s.toLowerCase()));
|
|
97
|
+
if (!allowSet.has(`${owner}/${repo}`)) {
|
|
98
|
+
return {
|
|
99
|
+
ok: false,
|
|
100
|
+
code: "not_allowlisted",
|
|
101
|
+
error: `'${owner}/${repo}' is not in the recipe-repo allowlist. Set PATCHWORK_RECIPE_REPO_ALLOWLIST=${owner}/${repo} to opt in.`,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
ok: true,
|
|
106
|
+
parsed: {
|
|
107
|
+
kind: kindRaw === "recipes" ? "recipe" : "bundle",
|
|
108
|
+
owner,
|
|
109
|
+
repo,
|
|
110
|
+
name: nameRaw,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The repo-relative path of the file for a parsed install source.
|
|
116
|
+
* `recipes/<name>/<name>.yaml` or `bundles/<name>/patchwork-bundle.json`.
|
|
117
|
+
*/
|
|
118
|
+
function repoRelativePath(parsed) {
|
|
119
|
+
if (parsed.kind === "recipe") {
|
|
120
|
+
return `recipes/${parsed.name}/${parsed.name}.yaml`;
|
|
121
|
+
}
|
|
122
|
+
return `bundles/${parsed.name}/patchwork-bundle.json`;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Build the raw.githubusercontent URL for a parsed install source.
|
|
126
|
+
* Always pulls `main` branch HEAD — version pinning is on the
|
|
127
|
+
* deferred audit backlog.
|
|
128
|
+
*/
|
|
129
|
+
export function buildGithubRawUrl(parsed) {
|
|
130
|
+
return `https://raw.githubusercontent.com/${parsed.owner}/${parsed.repo}/main/${repoRelativePath(parsed)}`;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Build the `api.github.com` Contents-API URL for a parsed install
|
|
134
|
+
* source. Used as a FALLBACK when `raw.githubusercontent.com` is
|
|
135
|
+
* unreachable — many corporate / proxied networks block the raw host
|
|
136
|
+
* even when `api.github.com` is allowed. Combined with the
|
|
137
|
+
* `Accept: application/vnd.github.raw` request header (see
|
|
138
|
+
* `fetchGithubInstallFile`), this endpoint returns the raw file bytes
|
|
139
|
+
* directly — no base64 decode needed. Public repos work unauthenticated.
|
|
140
|
+
*/
|
|
141
|
+
export function buildGithubApiUrl(parsed) {
|
|
142
|
+
return `https://api.github.com/repos/${parsed.owner}/${parsed.repo}/contents/${repoRelativePath(parsed)}?ref=main`;
|
|
143
|
+
}
|
|
144
|
+
export async function fetchGithubInstallFile(parsed, init = {}) {
|
|
145
|
+
const rawUrl = buildGithubRawUrl(parsed);
|
|
146
|
+
let rawResponse = null;
|
|
147
|
+
let rawNetworkError = null;
|
|
148
|
+
try {
|
|
149
|
+
rawResponse = await fetch(rawUrl, {
|
|
150
|
+
signal: init.signal,
|
|
151
|
+
redirect: "follow",
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
rawNetworkError = err;
|
|
156
|
+
}
|
|
157
|
+
// Fast path: raw host returned a usable response.
|
|
158
|
+
if (rawResponse?.ok) {
|
|
159
|
+
return { ok: true, response: rawResponse };
|
|
160
|
+
}
|
|
161
|
+
// Raw host either threw OR returned non-ok → try the API fallback.
|
|
162
|
+
const apiUrl = buildGithubApiUrl(parsed);
|
|
163
|
+
let apiResponse = null;
|
|
164
|
+
let apiNetworkError = null;
|
|
165
|
+
try {
|
|
166
|
+
apiResponse = await fetch(apiUrl, {
|
|
167
|
+
signal: init.signal,
|
|
168
|
+
redirect: "follow",
|
|
169
|
+
headers: { Accept: "application/vnd.github.raw" },
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
catch (err) {
|
|
173
|
+
apiNetworkError = err;
|
|
174
|
+
}
|
|
175
|
+
if (apiResponse?.ok) {
|
|
176
|
+
return { ok: true, response: apiResponse };
|
|
177
|
+
}
|
|
178
|
+
// Neither host yielded an ok body. Decide which failure to surface.
|
|
179
|
+
//
|
|
180
|
+
// A non-404 HTTP failure (5xx / 403 rate-limit) is the most
|
|
181
|
+
// actionable signal — prefer it over a 404 from the other host, so a
|
|
182
|
+
// transient upstream problem isn't misreported as "recipe missing".
|
|
183
|
+
// The API response is the more authoritative of the two here (raw is
|
|
184
|
+
// a CDN; the API gives proper status codes), so check it first.
|
|
185
|
+
if (apiResponse && apiResponse.status !== 404) {
|
|
186
|
+
return { ok: false, kind: "upstream_error", response: apiResponse };
|
|
187
|
+
}
|
|
188
|
+
if (rawResponse && rawResponse.status !== 404) {
|
|
189
|
+
return { ok: false, kind: "upstream_error", response: rawResponse };
|
|
190
|
+
}
|
|
191
|
+
// Whatever is left is a genuine 404 from one or both hosts → keep
|
|
192
|
+
// the not-found distinction so the caller surfaces a 404, not a 502.
|
|
193
|
+
if (apiResponse && apiResponse.status === 404) {
|
|
194
|
+
return { ok: false, kind: "not_found", response: apiResponse };
|
|
195
|
+
}
|
|
196
|
+
if (rawResponse && rawResponse.status === 404) {
|
|
197
|
+
return { ok: false, kind: "not_found", response: rawResponse };
|
|
198
|
+
}
|
|
199
|
+
// Both hosts threw network errors.
|
|
200
|
+
return {
|
|
201
|
+
ok: false,
|
|
202
|
+
kind: "network_error",
|
|
203
|
+
error: apiNetworkError ?? rawNetworkError,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=githubInstallSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"githubInstallSource.js","sourceRoot":"","sources":["../../src/recipes/githubInstallSource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAoBH,MAAM,iBAAiB,GAA0B,CAAC,qBAAqB,CAAC,CAAC;AACzE,MAAM,CAAC,MAAM,UAAU,GAAG,gCAAgC,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,MAAyB,OAAO,CAAC,GAAG;IAChE,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,+BAA+B,IAAI,EAAE,CAAC;SACxD,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;SAClC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,iBAAiB,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CACtC,MAAc,EACd,YAAmC,aAAa,EAAE;IAElD,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAClC,OAAO;YACL,EAAE,EAAE,KAAK;YACT,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,kCAAkC;SAC1C,CAAC;IACJ,CAAC;IACD,qEAAqE;IACrE,+DAA+D;IAC/D,mEAAmE;IACnE,iBAAiB;IACjB,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAAG,IAAI,CA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AAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;IACtE,CAAC;IACD,kEAAkE;IAClE,qEAAqE;IACrE,IAAI,WAAW,IAAI,WAAW,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QAC9C,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;IACjE,CAAC;IACD,IAAI,WAAW,IAAI,WAAW,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QAC9C,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;IACjE,CAAC;IACD,mCAAmC;IACnC,OAAO;QACL,EAAE,EAAE,KAAK;QACT,IAAI,EAAE,eAAe;QACrB,KAAK,EAAE,eAAe,IAAI,eAAe;KAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Halt-category derivation.
|
|
3
|
+
*
|
|
4
|
+
* PR1c of the Val-inspired plan. PR1 attached a `haltReason` sentence to
|
|
5
|
+
* every error-status StepResult; this module categorises those sentences
|
|
6
|
+
* into a small bounded enum so the dashboard / metrics layer can count
|
|
7
|
+
* them over time. Foundation for "is the haltReason work actually
|
|
8
|
+
* surfacing useful signal, or is everything landing in `unknown`?"
|
|
9
|
+
*
|
|
10
|
+
* The mapping is intentionally pattern-based against the 5 phrases
|
|
11
|
+
* emitted by yamlRunner.ts. Keep this file and those phrases in sync.
|
|
12
|
+
* When a new error site is added, add a category here AND a test.
|
|
13
|
+
*/
|
|
14
|
+
export type HaltCategory = "agent_silent_fail" | "agent_narration_only" | "agent_threw" | "tool_threw" | "tool_error"
|
|
15
|
+
/** Write blocked by the global kill-switch (#422). Distinct from a real tool failure. */
|
|
16
|
+
| "kill_switch"
|
|
17
|
+
/** Recipe's `tokensMax` budget breached (PR2b). */
|
|
18
|
+
| "budget_exceeded"
|
|
19
|
+
/** Per-step `expect` assertion failed (slice 2). */
|
|
20
|
+
| "expect_failed"
|
|
21
|
+
/** Per-step wall-clock `timeout_ms` exceeded (sandbox-alternative slice). */
|
|
22
|
+
| "step_timeout"
|
|
23
|
+
/**
|
|
24
|
+
* Connector returned 401/403 — token expired or scopes insufficient.
|
|
25
|
+
* Actionable: user should reconnect from /connections.
|
|
26
|
+
*/
|
|
27
|
+
| "auth_failure"
|
|
28
|
+
/**
|
|
29
|
+
* External service returned 429 / rate limit. Actionable: retry later
|
|
30
|
+
* or back off the cron cadence.
|
|
31
|
+
*/
|
|
32
|
+
| "rate_limited"
|
|
33
|
+
/**
|
|
34
|
+
* Transport failed before the request reached the service
|
|
35
|
+
* (ECONNREFUSED, ENOTFOUND, fetch failed). Distinct from a 4xx/5xx
|
|
36
|
+
* from the service itself — usually a local network / DNS issue.
|
|
37
|
+
*/
|
|
38
|
+
| "network_error"
|
|
39
|
+
/**
|
|
40
|
+
* Tool needed a connector that isn't configured for this workspace.
|
|
41
|
+
* Actionable: install/connect from /connections.
|
|
42
|
+
*/
|
|
43
|
+
| "missing_connector"
|
|
44
|
+
/** Whole-recipe failure (e.g. circular dependencies) — has no step row. */
|
|
45
|
+
| "run_level" | "unknown";
|
|
46
|
+
/**
|
|
47
|
+
* Human-readable label per category. Shared by the `halts` CLI, the
|
|
48
|
+
* `recipe doctor` command, and (mirrored) the dashboard, so the wording
|
|
49
|
+
* stays consistent across surfaces.
|
|
50
|
+
*/
|
|
51
|
+
export declare const HALT_CATEGORY_LABELS: Record<HaltCategory, string>;
|
|
52
|
+
/**
|
|
53
|
+
* Actionable one-liner per category — "what to do about it". Shared by
|
|
54
|
+
* the `halts` CLI and `recipe doctor` so SSH / mobile users get the fix
|
|
55
|
+
* hint without opening the dashboard.
|
|
56
|
+
*/
|
|
57
|
+
export declare const HALT_CATEGORY_HINTS: Record<HaltCategory, string>;
|
|
58
|
+
export declare function categoriseHaltReason(reason: string | undefined): HaltCategory;
|
|
59
|
+
export interface HaltSummary {
|
|
60
|
+
/** Total error-status step results scanned. */
|
|
61
|
+
total: number;
|
|
62
|
+
/** Per-category counts; categories with zero hits are omitted. */
|
|
63
|
+
byCategory: Partial<Record<HaltCategory, number>>;
|
|
64
|
+
/** Most recent 5 halt reasons (verbatim) for surfacing in the UI. */
|
|
65
|
+
recent: Array<{
|
|
66
|
+
reason: string;
|
|
67
|
+
category: HaltCategory;
|
|
68
|
+
runSeq: number;
|
|
69
|
+
}>;
|
|
70
|
+
}
|
|
71
|
+
interface HaltSummaryInputRun {
|
|
72
|
+
seq: number;
|
|
73
|
+
/** Top-level run status — `run_level` halts are runs with status === "error" but no error stepResults (e.g. circular-dep failure before any step ran). */
|
|
74
|
+
status?: "running" | "done" | "error" | "cancelled" | "interrupted";
|
|
75
|
+
/** Top-level errorMessage — surfaced as a `run_level` halt when no per-step halts cover it. */
|
|
76
|
+
errorMessage?: string;
|
|
77
|
+
stepResults?: Array<{
|
|
78
|
+
status: "ok" | "skipped" | "error";
|
|
79
|
+
haltReason?: string;
|
|
80
|
+
/** Pre-tagged category from yamlRunner throw site — avoids regex re-derivation when present. */
|
|
81
|
+
haltCategory?: HaltCategory;
|
|
82
|
+
}>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Aggregate halt categories across a set of runs. Runs are expected to be
|
|
86
|
+
* sorted newest-first so `recent` reflects the most recent halts.
|
|
87
|
+
*
|
|
88
|
+
* A run contributes:
|
|
89
|
+
* - one entry per error-status stepResult that has a `haltReason`
|
|
90
|
+
* - plus one `run_level` entry if `status === "error"` and there were no
|
|
91
|
+
* per-step halts that already explained it (avoids double-counting).
|
|
92
|
+
*/
|
|
93
|
+
export declare function summariseHalts(runs: HaltSummaryInputRun[]): HaltSummary;
|
|
94
|
+
/**
|
|
95
|
+
* Format a `HaltSummary` as Prometheus text-exposition lines for the
|
|
96
|
+
* `bridge_recipe_halts{category="..."} N` gauge. Returns an empty array
|
|
97
|
+
* when the summary is empty (no HELP/TYPE block emitted in that case so
|
|
98
|
+
* Prom scrapers don't see an orphan declaration).
|
|
99
|
+
*
|
|
100
|
+
* Surfaced via `/metrics` so users with their own observability stack
|
|
101
|
+
* can dashboard halts without using Patchwork's UI.
|
|
102
|
+
*/
|
|
103
|
+
export declare function haltSummaryToPrometheus(summary: HaltSummary): string[];
|
|
104
|
+
/**
|
|
105
|
+
* Derive a one-sentence haltReason from a step's error-status + raw error
|
|
106
|
+
* string. Used by `chainedRunner` to mirror the convention emitted by
|
|
107
|
+
* `yamlRunner`. Returns `undefined` for non-error rows or missing error.
|
|
108
|
+
*
|
|
109
|
+
* Pattern-matches the same phrases `categoriseHaltReason` knows about,
|
|
110
|
+
* so chained-run haltReasons categorise into the same buckets.
|
|
111
|
+
*/
|
|
112
|
+
export declare function deriveHaltReasonFromError(opts: {
|
|
113
|
+
stepId: string;
|
|
114
|
+
toolName?: string;
|
|
115
|
+
isAgent?: boolean;
|
|
116
|
+
status: "ok" | "skipped" | "error";
|
|
117
|
+
error?: string;
|
|
118
|
+
}): string | undefined;
|
|
119
|
+
export {};
|