@mastra/factory 0.0.0-aggregate-trace-20261015182851
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/LICENSE.md +32 -0
- package/README.md +671 -0
- package/dist/auth.d.ts +201 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +623 -0
- package/dist/auth.js.map +1 -0
- package/dist/boards/define-board.d.ts +111 -0
- package/dist/boards/define-board.d.ts.map +1 -0
- package/dist/boards/define-board.js +156 -0
- package/dist/boards/define-board.js.map +1 -0
- package/dist/boards/index.d.ts +14 -0
- package/dist/boards/index.d.ts.map +1 -0
- package/dist/boards/index.js +21 -0
- package/dist/boards/index.js.map +1 -0
- package/dist/boards/registry.d.ts +16 -0
- package/dist/boards/registry.d.ts.map +1 -0
- package/dist/boards/registry.js +25 -0
- package/dist/boards/registry.js.map +1 -0
- package/dist/boards/relocate.d.ts +21 -0
- package/dist/boards/relocate.d.ts.map +1 -0
- package/dist/boards/relocate.js +58 -0
- package/dist/boards/relocate.js.map +1 -0
- package/dist/boards/review.d.ts +6 -0
- package/dist/boards/review.d.ts.map +1 -0
- package/dist/boards/review.js +104 -0
- package/dist/boards/review.js.map +1 -0
- package/dist/boards/semantics.d.ts +68 -0
- package/dist/boards/semantics.d.ts.map +1 -0
- package/dist/boards/semantics.js +119 -0
- package/dist/boards/semantics.js.map +1 -0
- package/dist/boards/transition-policy.d.ts +67 -0
- package/dist/boards/transition-policy.d.ts.map +1 -0
- package/dist/boards/transition-policy.js +36 -0
- package/dist/boards/transition-policy.js.map +1 -0
- package/dist/boards/work-tool-rules.d.ts +8 -0
- package/dist/boards/work-tool-rules.d.ts.map +1 -0
- package/dist/boards/work-tool-rules.js +20 -0
- package/dist/boards/work-tool-rules.js.map +1 -0
- package/dist/boards/work-transition-policy.d.ts +3 -0
- package/dist/boards/work-transition-policy.d.ts.map +1 -0
- package/dist/boards/work-transition-policy.js +46 -0
- package/dist/boards/work-transition-policy.js.map +1 -0
- package/dist/boards/work.d.ts +4 -0
- package/dist/boards/work.d.ts.map +1 -0
- package/dist/boards/work.js +222 -0
- package/dist/boards/work.js.map +1 -0
- package/dist/capabilities/connection.d.ts +9 -0
- package/dist/capabilities/connection.d.ts.map +1 -0
- package/dist/capabilities/connection.js +1 -0
- package/dist/capabilities/intake.d.ts +153 -0
- package/dist/capabilities/intake.d.ts.map +1 -0
- package/dist/capabilities/intake.js +1 -0
- package/dist/capabilities/version-control.d.ts +268 -0
- package/dist/capabilities/version-control.d.ts.map +1 -0
- package/dist/capabilities/version-control.js +1 -0
- package/dist/environment/build-runner.d.ts +72 -0
- package/dist/environment/build-runner.d.ts.map +1 -0
- package/dist/environment/build-runner.js +131 -0
- package/dist/environment/build-runner.js.map +1 -0
- package/dist/environment/build-schedule.d.ts +40 -0
- package/dist/environment/build-schedule.d.ts.map +1 -0
- package/dist/environment/build-schedule.js +94 -0
- package/dist/environment/build-schedule.js.map +1 -0
- package/dist/environment/build-workflow.d.ts +62 -0
- package/dist/environment/build-workflow.d.ts.map +1 -0
- package/dist/environment/build-workflow.js +149 -0
- package/dist/environment/build-workflow.js.map +1 -0
- package/dist/environment/build.d.ts +111 -0
- package/dist/environment/build.d.ts.map +1 -0
- package/dist/environment/build.js +344 -0
- package/dist/environment/build.js.map +1 -0
- package/dist/environment/heads.d.ts +36 -0
- package/dist/environment/heads.d.ts.map +1 -0
- package/dist/environment/heads.js +60 -0
- package/dist/environment/heads.js.map +1 -0
- package/dist/factory.d.ts +225 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/factory.js +1006 -0
- package/dist/factory.js.map +1 -0
- package/dist/feed-events.d.ts +13 -0
- package/dist/feed-events.d.ts.map +1 -0
- package/dist/feed-events.js +25 -0
- package/dist/feed-events.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/integrations/base.d.ts +302 -0
- package/dist/integrations/base.d.ts.map +1 -0
- package/dist/integrations/base.js +1 -0
- package/dist/integrations/github/acceptance-labels.d.ts +16 -0
- package/dist/integrations/github/acceptance-labels.d.ts.map +1 -0
- package/dist/integrations/github/acceptance-labels.js +55 -0
- package/dist/integrations/github/acceptance-labels.js.map +1 -0
- package/dist/integrations/github/app-identity.d.ts +43 -0
- package/dist/integrations/github/app-identity.d.ts.map +1 -0
- package/dist/integrations/github/app-identity.js +62 -0
- package/dist/integrations/github/app-identity.js.map +1 -0
- package/dist/integrations/github/commits.d.ts +40 -0
- package/dist/integrations/github/commits.d.ts.map +1 -0
- package/dist/integrations/github/commits.js +48 -0
- package/dist/integrations/github/commits.js.map +1 -0
- package/dist/integrations/github/config.d.ts +60 -0
- package/dist/integrations/github/config.d.ts.map +1 -0
- package/dist/integrations/github/config.js +42 -0
- package/dist/integrations/github/config.js.map +1 -0
- package/dist/integrations/github/default-rules.d.ts +218 -0
- package/dist/integrations/github/default-rules.d.ts.map +1 -0
- package/dist/integrations/github/default-rules.js +296 -0
- package/dist/integrations/github/default-rules.js.map +1 -0
- package/dist/integrations/github/integration.d.ts +270 -0
- package/dist/integrations/github/integration.d.ts.map +1 -0
- package/dist/integrations/github/integration.js +1375 -0
- package/dist/integrations/github/integration.js.map +1 -0
- package/dist/integrations/github/issue-reconciler.d.ts +28 -0
- package/dist/integrations/github/issue-reconciler.d.ts.map +1 -0
- package/dist/integrations/github/issue-reconciler.js +138 -0
- package/dist/integrations/github/issue-reconciler.js.map +1 -0
- package/dist/integrations/github/pat.d.ts +38 -0
- package/dist/integrations/github/pat.d.ts.map +1 -0
- package/dist/integrations/github/pat.js +59 -0
- package/dist/integrations/github/pat.js.map +1 -0
- package/dist/integrations/github/provenance.d.ts +34 -0
- package/dist/integrations/github/provenance.d.ts.map +1 -0
- package/dist/integrations/github/provenance.js +91 -0
- package/dist/integrations/github/provenance.js.map +1 -0
- package/dist/integrations/github/reconcile-worker.d.ts +45 -0
- package/dist/integrations/github/reconcile-worker.d.ts.map +1 -0
- package/dist/integrations/github/reconcile-worker.js +189 -0
- package/dist/integrations/github/reconcile-worker.js.map +1 -0
- package/dist/integrations/github/reconciliation-config.d.ts +3 -0
- package/dist/integrations/github/reconciliation-config.d.ts.map +1 -0
- package/dist/integrations/github/reconciliation-config.js +19 -0
- package/dist/integrations/github/reconciliation-config.js.map +1 -0
- package/dist/integrations/github/routes.d.ts +90 -0
- package/dist/integrations/github/routes.d.ts.map +1 -0
- package/dist/integrations/github/routes.js +1362 -0
- package/dist/integrations/github/routes.js.map +1 -0
- package/dist/integrations/github/rules.d.ts +173 -0
- package/dist/integrations/github/rules.d.ts.map +1 -0
- package/dist/integrations/github/rules.js +1021 -0
- package/dist/integrations/github/rules.js.map +1 -0
- package/dist/integrations/github/sandbox-release.d.ts +25 -0
- package/dist/integrations/github/sandbox-release.d.ts.map +1 -0
- package/dist/integrations/github/sandbox-release.js +38 -0
- package/dist/integrations/github/sandbox-release.js.map +1 -0
- package/dist/integrations/github/sandbox.d.ts +234 -0
- package/dist/integrations/github/sandbox.d.ts.map +1 -0
- package/dist/integrations/github/sandbox.js +947 -0
- package/dist/integrations/github/sandbox.js.map +1 -0
- package/dist/integrations/github/session-subscriptions.d.ts +28 -0
- package/dist/integrations/github/session-subscriptions.d.ts.map +1 -0
- package/dist/integrations/github/session-subscriptions.js +283 -0
- package/dist/integrations/github/session-subscriptions.js.map +1 -0
- package/dist/integrations/github/settle-or-abort.d.ts +7 -0
- package/dist/integrations/github/settle-or-abort.d.ts.map +1 -0
- package/dist/integrations/github/settle-or-abort.js +25 -0
- package/dist/integrations/github/settle-or-abort.js.map +1 -0
- package/dist/integrations/github/stale-reviews.d.ts +22 -0
- package/dist/integrations/github/stale-reviews.d.ts.map +1 -0
- package/dist/integrations/github/stale-reviews.js +70 -0
- package/dist/integrations/github/stale-reviews.js.map +1 -0
- package/dist/integrations/github/subscriptions.d.ts +54 -0
- package/dist/integrations/github/subscriptions.d.ts.map +1 -0
- package/dist/integrations/github/subscriptions.js +64 -0
- package/dist/integrations/github/subscriptions.js.map +1 -0
- package/dist/integrations/github/token-refresh.d.ts +31 -0
- package/dist/integrations/github/token-refresh.d.ts.map +1 -0
- package/dist/integrations/github/token-refresh.js +42 -0
- package/dist/integrations/github/token-refresh.js.map +1 -0
- package/dist/integrations/github/webhook.d.ts +139 -0
- package/dist/integrations/github/webhook.d.ts.map +1 -0
- package/dist/integrations/github/webhook.js +432 -0
- package/dist/integrations/github/webhook.js.map +1 -0
- package/dist/integrations/gitlab/agent-tools.d.ts +14 -0
- package/dist/integrations/gitlab/agent-tools.d.ts.map +1 -0
- package/dist/integrations/gitlab/agent-tools.js +42 -0
- package/dist/integrations/gitlab/agent-tools.js.map +1 -0
- package/dist/integrations/gitlab/api.d.ts +222 -0
- package/dist/integrations/gitlab/api.d.ts.map +1 -0
- package/dist/integrations/gitlab/api.js +274 -0
- package/dist/integrations/gitlab/api.js.map +1 -0
- package/dist/integrations/gitlab/default-rules.d.ts +125 -0
- package/dist/integrations/gitlab/default-rules.d.ts.map +1 -0
- package/dist/integrations/gitlab/default-rules.js +180 -0
- package/dist/integrations/gitlab/default-rules.js.map +1 -0
- package/dist/integrations/gitlab/integration.d.ts +138 -0
- package/dist/integrations/gitlab/integration.d.ts.map +1 -0
- package/dist/integrations/gitlab/integration.js +705 -0
- package/dist/integrations/gitlab/integration.js.map +1 -0
- package/dist/integrations/gitlab/issue-reconciler.d.ts +6 -0
- package/dist/integrations/gitlab/issue-reconciler.d.ts.map +1 -0
- package/dist/integrations/gitlab/issue-reconciler.js +123 -0
- package/dist/integrations/gitlab/issue-reconciler.js.map +1 -0
- package/dist/integrations/gitlab/merge-request-reconciler.d.ts +6 -0
- package/dist/integrations/gitlab/merge-request-reconciler.d.ts.map +1 -0
- package/dist/integrations/gitlab/merge-request-reconciler.js +267 -0
- package/dist/integrations/gitlab/merge-request-reconciler.js.map +1 -0
- package/dist/integrations/gitlab/reconciler.d.ts +5 -0
- package/dist/integrations/gitlab/reconciler.d.ts.map +1 -0
- package/dist/integrations/gitlab/reconciler.js +31 -0
- package/dist/integrations/gitlab/reconciler.js.map +1 -0
- package/dist/integrations/gitlab/reconciliation-config.d.ts +3 -0
- package/dist/integrations/gitlab/reconciliation-config.d.ts.map +1 -0
- package/dist/integrations/gitlab/reconciliation-config.js +17 -0
- package/dist/integrations/gitlab/reconciliation-config.js.map +1 -0
- package/dist/integrations/gitlab/routes.d.ts +20 -0
- package/dist/integrations/gitlab/routes.d.ts.map +1 -0
- package/dist/integrations/gitlab/routes.js +474 -0
- package/dist/integrations/gitlab/routes.js.map +1 -0
- package/dist/integrations/gitlab/rules.d.ts +35 -0
- package/dist/integrations/gitlab/rules.d.ts.map +1 -0
- package/dist/integrations/gitlab/rules.js +502 -0
- package/dist/integrations/gitlab/rules.js.map +1 -0
- package/dist/integrations/gitlab/session-subscriptions.d.ts +32 -0
- package/dist/integrations/gitlab/session-subscriptions.d.ts.map +1 -0
- package/dist/integrations/gitlab/session-subscriptions.js +193 -0
- package/dist/integrations/gitlab/session-subscriptions.js.map +1 -0
- package/dist/integrations/gitlab/subscriptions.d.ts +70 -0
- package/dist/integrations/gitlab/subscriptions.d.ts.map +1 -0
- package/dist/integrations/gitlab/subscriptions.js +76 -0
- package/dist/integrations/gitlab/subscriptions.js.map +1 -0
- package/dist/integrations/gitlab/version-control.d.ts +16 -0
- package/dist/integrations/gitlab/version-control.d.ts.map +1 -0
- package/dist/integrations/gitlab/version-control.js +621 -0
- package/dist/integrations/gitlab/version-control.js.map +1 -0
- package/dist/integrations/gitlab/webhook-dispatch.d.ts +75 -0
- package/dist/integrations/gitlab/webhook-dispatch.d.ts.map +1 -0
- package/dist/integrations/gitlab/webhook-dispatch.js +235 -0
- package/dist/integrations/gitlab/webhook-dispatch.js.map +1 -0
- package/dist/integrations/gitlab/webhook.d.ts +72 -0
- package/dist/integrations/gitlab/webhook.d.ts.map +1 -0
- package/dist/integrations/gitlab/webhook.js +201 -0
- package/dist/integrations/gitlab/webhook.js.map +1 -0
- package/dist/integrations/incidentio/agent-tools.d.ts +49 -0
- package/dist/integrations/incidentio/agent-tools.d.ts.map +1 -0
- package/dist/integrations/incidentio/agent-tools.js +90 -0
- package/dist/integrations/incidentio/agent-tools.js.map +1 -0
- package/dist/integrations/incidentio/api.d.ts +400 -0
- package/dist/integrations/incidentio/api.d.ts.map +1 -0
- package/dist/integrations/incidentio/api.js +192 -0
- package/dist/integrations/incidentio/api.js.map +1 -0
- package/dist/integrations/incidentio/claim.d.ts +8 -0
- package/dist/integrations/incidentio/claim.d.ts.map +1 -0
- package/dist/integrations/incidentio/claim.js +14 -0
- package/dist/integrations/incidentio/claim.js.map +1 -0
- package/dist/integrations/incidentio/default-rules.d.ts +46 -0
- package/dist/integrations/incidentio/default-rules.d.ts.map +1 -0
- package/dist/integrations/incidentio/default-rules.js +68 -0
- package/dist/integrations/incidentio/default-rules.js.map +1 -0
- package/dist/integrations/incidentio/intake.d.ts +10 -0
- package/dist/integrations/incidentio/intake.d.ts.map +1 -0
- package/dist/integrations/incidentio/intake.js +307 -0
- package/dist/integrations/incidentio/intake.js.map +1 -0
- package/dist/integrations/incidentio/integration.d.ts +63 -0
- package/dist/integrations/incidentio/integration.d.ts.map +1 -0
- package/dist/integrations/incidentio/integration.js +141 -0
- package/dist/integrations/incidentio/integration.js.map +1 -0
- package/dist/integrations/incidentio/issue-reconciler.d.ts +10 -0
- package/dist/integrations/incidentio/issue-reconciler.d.ts.map +1 -0
- package/dist/integrations/incidentio/issue-reconciler.js +75 -0
- package/dist/integrations/incidentio/issue-reconciler.js.map +1 -0
- package/dist/integrations/incidentio/reconciliation-config.d.ts +3 -0
- package/dist/integrations/incidentio/reconciliation-config.d.ts.map +1 -0
- package/dist/integrations/incidentio/reconciliation-config.js +17 -0
- package/dist/integrations/incidentio/reconciliation-config.js.map +1 -0
- package/dist/integrations/incidentio/routes.d.ts +76 -0
- package/dist/integrations/incidentio/routes.d.ts.map +1 -0
- package/dist/integrations/incidentio/routes.js +249 -0
- package/dist/integrations/incidentio/routes.js.map +1 -0
- package/dist/integrations/incidentio/rules.d.ts +55 -0
- package/dist/integrations/incidentio/rules.d.ts.map +1 -0
- package/dist/integrations/incidentio/rules.js +189 -0
- package/dist/integrations/incidentio/rules.js.map +1 -0
- package/dist/integrations/issue-reconcile-worker.d.ts +19 -0
- package/dist/integrations/issue-reconcile-worker.d.ts.map +1 -0
- package/dist/integrations/issue-reconcile-worker.js +97 -0
- package/dist/integrations/issue-reconcile-worker.js.map +1 -0
- package/dist/integrations/issue-reconciler.d.ts +51 -0
- package/dist/integrations/issue-reconciler.d.ts.map +1 -0
- package/dist/integrations/issue-reconciler.js +158 -0
- package/dist/integrations/issue-reconciler.js.map +1 -0
- package/dist/integrations/jira/adf.d.ts +26 -0
- package/dist/integrations/jira/adf.d.ts.map +1 -0
- package/dist/integrations/jira/adf.js +73 -0
- package/dist/integrations/jira/adf.js.map +1 -0
- package/dist/integrations/jira/agent-tools.d.ts +45 -0
- package/dist/integrations/jira/agent-tools.d.ts.map +1 -0
- package/dist/integrations/jira/agent-tools.js +87 -0
- package/dist/integrations/jira/agent-tools.js.map +1 -0
- package/dist/integrations/jira/api.d.ts +157 -0
- package/dist/integrations/jira/api.d.ts.map +1 -0
- package/dist/integrations/jira/api.js +141 -0
- package/dist/integrations/jira/api.js.map +1 -0
- package/dist/integrations/jira/claim.d.ts +9 -0
- package/dist/integrations/jira/claim.d.ts.map +1 -0
- package/dist/integrations/jira/claim.js +15 -0
- package/dist/integrations/jira/claim.js.map +1 -0
- package/dist/integrations/jira/default-rules.d.ts +47 -0
- package/dist/integrations/jira/default-rules.d.ts.map +1 -0
- package/dist/integrations/jira/default-rules.js +69 -0
- package/dist/integrations/jira/default-rules.js.map +1 -0
- package/dist/integrations/jira/integration.d.ts +114 -0
- package/dist/integrations/jira/integration.d.ts.map +1 -0
- package/dist/integrations/jira/integration.js +407 -0
- package/dist/integrations/jira/integration.js.map +1 -0
- package/dist/integrations/jira/issue-reconciler.d.ts +10 -0
- package/dist/integrations/jira/issue-reconciler.d.ts.map +1 -0
- package/dist/integrations/jira/issue-reconciler.js +70 -0
- package/dist/integrations/jira/issue-reconciler.js.map +1 -0
- package/dist/integrations/jira/reconciliation-config.d.ts +3 -0
- package/dist/integrations/jira/reconciliation-config.d.ts.map +1 -0
- package/dist/integrations/jira/reconciliation-config.js +17 -0
- package/dist/integrations/jira/reconciliation-config.js.map +1 -0
- package/dist/integrations/jira/routes.d.ts +54 -0
- package/dist/integrations/jira/routes.d.ts.map +1 -0
- package/dist/integrations/jira/routes.js +260 -0
- package/dist/integrations/jira/routes.js.map +1 -0
- package/dist/integrations/jira/rules.d.ts +57 -0
- package/dist/integrations/jira/rules.d.ts.map +1 -0
- package/dist/integrations/jira/rules.js +189 -0
- package/dist/integrations/jira/rules.js.map +1 -0
- package/dist/integrations/linear/agent-tools.d.ts +34 -0
- package/dist/integrations/linear/agent-tools.d.ts.map +1 -0
- package/dist/integrations/linear/agent-tools.js +87 -0
- package/dist/integrations/linear/agent-tools.js.map +1 -0
- package/dist/integrations/linear/claim.d.ts +8 -0
- package/dist/integrations/linear/claim.d.ts.map +1 -0
- package/dist/integrations/linear/claim.js +14 -0
- package/dist/integrations/linear/claim.js.map +1 -0
- package/dist/integrations/linear/default-rules.d.ts +46 -0
- package/dist/integrations/linear/default-rules.d.ts.map +1 -0
- package/dist/integrations/linear/default-rules.js +70 -0
- package/dist/integrations/linear/default-rules.js.map +1 -0
- package/dist/integrations/linear/integration.d.ts +260 -0
- package/dist/integrations/linear/integration.d.ts.map +1 -0
- package/dist/integrations/linear/integration.js +900 -0
- package/dist/integrations/linear/integration.js.map +1 -0
- package/dist/integrations/linear/issue-reconciler.d.ts +8 -0
- package/dist/integrations/linear/issue-reconciler.d.ts.map +1 -0
- package/dist/integrations/linear/issue-reconciler.js +73 -0
- package/dist/integrations/linear/issue-reconciler.js.map +1 -0
- package/dist/integrations/linear/reconciliation-config.d.ts +3 -0
- package/dist/integrations/linear/reconciliation-config.d.ts.map +1 -0
- package/dist/integrations/linear/reconciliation-config.js +21 -0
- package/dist/integrations/linear/reconciliation-config.js.map +1 -0
- package/dist/integrations/linear/routes.d.ts +81 -0
- package/dist/integrations/linear/routes.d.ts.map +1 -0
- package/dist/integrations/linear/routes.js +380 -0
- package/dist/integrations/linear/routes.js.map +1 -0
- package/dist/integrations/linear/rules.d.ts +54 -0
- package/dist/integrations/linear/rules.d.ts.map +1 -0
- package/dist/integrations/linear/rules.js +189 -0
- package/dist/integrations/linear/rules.js.map +1 -0
- package/dist/integrations/linear/storage.d.ts +65 -0
- package/dist/integrations/linear/storage.d.ts.map +1 -0
- package/dist/integrations/linear/storage.js +1 -0
- package/dist/integrations/platform/api-client.d.ts +26 -0
- package/dist/integrations/platform/api-client.d.ts.map +1 -0
- package/dist/integrations/platform/api-client.js +177 -0
- package/dist/integrations/platform/api-client.js.map +1 -0
- package/dist/integrations/platform/connect/routes.d.ts +39 -0
- package/dist/integrations/platform/connect/routes.d.ts.map +1 -0
- package/dist/integrations/platform/connect/routes.js +133 -0
- package/dist/integrations/platform/connect/routes.js.map +1 -0
- package/dist/integrations/platform/github/event-worker.d.ts +58 -0
- package/dist/integrations/platform/github/event-worker.d.ts.map +1 -0
- package/dist/integrations/platform/github/event-worker.js +449 -0
- package/dist/integrations/platform/github/event-worker.js.map +1 -0
- package/dist/integrations/platform/github/integration.d.ts +89 -0
- package/dist/integrations/platform/github/integration.d.ts.map +1 -0
- package/dist/integrations/platform/github/integration.js +1266 -0
- package/dist/integrations/platform/github/integration.js.map +1 -0
- package/dist/integrations/platform/gitlab/event-worker.d.ts +64 -0
- package/dist/integrations/platform/gitlab/event-worker.d.ts.map +1 -0
- package/dist/integrations/platform/gitlab/event-worker.js +305 -0
- package/dist/integrations/platform/gitlab/event-worker.js.map +1 -0
- package/dist/integrations/platform/gitlab/integration.d.ts +57 -0
- package/dist/integrations/platform/gitlab/integration.d.ts.map +1 -0
- package/dist/integrations/platform/gitlab/integration.js +113 -0
- package/dist/integrations/platform/gitlab/integration.js.map +1 -0
- package/dist/integrations/platform/incidentio/integration.d.ts +74 -0
- package/dist/integrations/platform/incidentio/integration.d.ts.map +1 -0
- package/dist/integrations/platform/incidentio/integration.js +406 -0
- package/dist/integrations/platform/incidentio/integration.js.map +1 -0
- package/dist/integrations/platform/jira/agent-tools.d.ts +36 -0
- package/dist/integrations/platform/jira/agent-tools.d.ts.map +1 -0
- package/dist/integrations/platform/jira/agent-tools.js +85 -0
- package/dist/integrations/platform/jira/agent-tools.js.map +1 -0
- package/dist/integrations/platform/jira/integration.d.ts +65 -0
- package/dist/integrations/platform/jira/integration.d.ts.map +1 -0
- package/dist/integrations/platform/jira/integration.js +546 -0
- package/dist/integrations/platform/jira/integration.js.map +1 -0
- package/dist/integrations/platform/jira/routes.d.ts +55 -0
- package/dist/integrations/platform/jira/routes.d.ts.map +1 -0
- package/dist/integrations/platform/jira/routes.js +274 -0
- package/dist/integrations/platform/jira/routes.js.map +1 -0
- package/dist/integrations/platform/linear/event-worker.d.ts +105 -0
- package/dist/integrations/platform/linear/event-worker.d.ts.map +1 -0
- package/dist/integrations/platform/linear/event-worker.js +379 -0
- package/dist/integrations/platform/linear/event-worker.js.map +1 -0
- package/dist/integrations/platform/linear/integration.d.ts +92 -0
- package/dist/integrations/platform/linear/integration.d.ts.map +1 -0
- package/dist/integrations/platform/linear/integration.js +754 -0
- package/dist/integrations/platform/linear/integration.js.map +1 -0
- package/dist/integrations/pull-request-head.d.ts +18 -0
- package/dist/integrations/pull-request-head.d.ts.map +1 -0
- package/dist/integrations/pull-request-head.js +45 -0
- package/dist/integrations/pull-request-head.js.map +1 -0
- package/dist/integrations/reconciliation-config.d.ts +3 -0
- package/dist/integrations/reconciliation-config.d.ts.map +1 -0
- package/dist/integrations/reconciliation-config.js +16 -0
- package/dist/integrations/reconciliation-config.js.map +1 -0
- package/dist/integrations/slack/connect-route.d.ts +46 -0
- package/dist/integrations/slack/connect-route.d.ts.map +1 -0
- package/dist/integrations/slack/connect-route.js +186 -0
- package/dist/integrations/slack/connect-route.js.map +1 -0
- package/dist/integrations/slack/emoji-shortcodes.generated.d.ts +8 -0
- package/dist/integrations/slack/emoji-shortcodes.generated.d.ts.map +1 -0
- package/dist/integrations/slack/emoji-shortcodes.generated.js +1985 -0
- package/dist/integrations/slack/emoji-shortcodes.generated.js.map +1 -0
- package/dist/integrations/slack/emoji.d.ts +3 -0
- package/dist/integrations/slack/emoji.d.ts.map +1 -0
- package/dist/integrations/slack/emoji.js +12 -0
- package/dist/integrations/slack/emoji.js.map +1 -0
- package/dist/integrations/slack/feed-publisher.d.ts +26 -0
- package/dist/integrations/slack/feed-publisher.d.ts.map +1 -0
- package/dist/integrations/slack/feed-publisher.js +44 -0
- package/dist/integrations/slack/feed-publisher.js.map +1 -0
- package/dist/integrations/slack/integration.d.ts +80 -0
- package/dist/integrations/slack/integration.d.ts.map +1 -0
- package/dist/integrations/slack/integration.js +93 -0
- package/dist/integrations/slack/integration.js.map +1 -0
- package/dist/integrations/slack/slack.d.ts +205 -0
- package/dist/integrations/slack/slack.d.ts.map +1 -0
- package/dist/integrations/slack/slack.js +653 -0
- package/dist/integrations/slack/slack.js.map +1 -0
- package/dist/integrations/subscription-session.d.ts +49 -0
- package/dist/integrations/subscription-session.d.ts.map +1 -0
- package/dist/integrations/subscription-session.js +103 -0
- package/dist/integrations/subscription-session.js.map +1 -0
- package/dist/integrations/workos/integration.d.ts +39 -0
- package/dist/integrations/workos/integration.d.ts.map +1 -0
- package/dist/integrations/workos/integration.js +91 -0
- package/dist/integrations/workos/integration.js.map +1 -0
- package/dist/packages/_internals/workspace/dist/index.js +48 -0
- package/dist/packages/_internals/workspace/dist/index.js.map +1 -0
- package/dist/platform-auth-host.d.ts +4 -0
- package/dist/platform-auth-host.d.ts.map +1 -0
- package/dist/platform-auth-host.js +18 -0
- package/dist/platform-auth-host.js.map +1 -0
- package/dist/review-verdict.d.ts +6 -0
- package/dist/review-verdict.d.ts.map +1 -0
- package/dist/review-verdict.js +14 -0
- package/dist/review-verdict.js.map +1 -0
- package/dist/routes/attention-activity.d.ts +23 -0
- package/dist/routes/attention-activity.d.ts.map +1 -0
- package/dist/routes/attention-activity.js +152 -0
- package/dist/routes/attention-activity.js.map +1 -0
- package/dist/routes/attention-parked.d.ts +22 -0
- package/dist/routes/attention-parked.d.ts.map +1 -0
- package/dist/routes/attention-parked.js +136 -0
- package/dist/routes/attention-parked.js.map +1 -0
- package/dist/routes/attention-proposed.d.ts +3 -0
- package/dist/routes/attention-proposed.d.ts.map +1 -0
- package/dist/routes/attention-proposed.js +21 -0
- package/dist/routes/attention-proposed.js.map +1 -0
- package/dist/routes/attention-providers.d.ts +159 -0
- package/dist/routes/attention-providers.d.ts.map +1 -0
- package/dist/routes/attention-providers.js +524 -0
- package/dist/routes/attention-providers.js.map +1 -0
- package/dist/routes/attention.d.ts +23 -0
- package/dist/routes/attention.d.ts.map +1 -0
- package/dist/routes/attention.js +219 -0
- package/dist/routes/attention.js.map +1 -0
- package/dist/routes/automation-runs.d.ts +37 -0
- package/dist/routes/automation-runs.d.ts.map +1 -0
- package/dist/routes/automation-runs.js +196 -0
- package/dist/routes/automation-runs.js.map +1 -0
- package/dist/routes/config.d.ts +238 -0
- package/dist/routes/config.d.ts.map +1 -0
- package/dist/routes/config.js +1011 -0
- package/dist/routes/config.js.map +1 -0
- package/dist/routes/contracts.d.ts +1080 -0
- package/dist/routes/contracts.d.ts.map +1 -0
- package/dist/routes/contracts.js +673 -0
- package/dist/routes/contracts.js.map +1 -0
- package/dist/routes/custom-provider-source.d.ts +52 -0
- package/dist/routes/custom-provider-source.d.ts.map +1 -0
- package/dist/routes/custom-provider-source.js +124 -0
- package/dist/routes/custom-provider-source.js.map +1 -0
- package/dist/routes/fs.d.ts +189 -0
- package/dist/routes/fs.d.ts.map +1 -0
- package/dist/routes/fs.js +916 -0
- package/dist/routes/fs.js.map +1 -0
- package/dist/routes/intake.d.ts +64 -0
- package/dist/routes/intake.d.ts.map +1 -0
- package/dist/routes/intake.js +627 -0
- package/dist/routes/intake.js.map +1 -0
- package/dist/routes/knowledge.d.ts +247 -0
- package/dist/routes/knowledge.d.ts.map +1 -0
- package/dist/routes/knowledge.js +1128 -0
- package/dist/routes/knowledge.js.map +1 -0
- package/dist/routes/oauth.d.ts +43 -0
- package/dist/routes/oauth.d.ts.map +1 -0
- package/dist/routes/oauth.js +477 -0
- package/dist/routes/oauth.js.map +1 -0
- package/dist/routes/projects.d.ts +68 -0
- package/dist/routes/projects.d.ts.map +1 -0
- package/dist/routes/projects.js +919 -0
- package/dist/routes/projects.js.map +1 -0
- package/dist/routes/provider-credentials.d.ts +82 -0
- package/dist/routes/provider-credentials.d.ts.map +1 -0
- package/dist/routes/provider-credentials.js +80 -0
- package/dist/routes/provider-credentials.js.map +1 -0
- package/dist/routes/route.d.ts +48 -0
- package/dist/routes/route.d.ts.map +1 -0
- package/dist/routes/route.js +15 -0
- package/dist/routes/route.js.map +1 -0
- package/dist/routes/skills.d.ts +30 -0
- package/dist/routes/skills.d.ts.map +1 -0
- package/dist/routes/skills.js +198 -0
- package/dist/routes/skills.js.map +1 -0
- package/dist/routes/source-control-sessions.d.ts +22 -0
- package/dist/routes/source-control-sessions.d.ts.map +1 -0
- package/dist/routes/source-control-sessions.js +356 -0
- package/dist/routes/source-control-sessions.js.map +1 -0
- package/dist/routes/source-control-settings.d.ts +10 -0
- package/dist/routes/source-control-settings.d.ts.map +1 -0
- package/dist/routes/source-control-settings.js +87 -0
- package/dist/routes/source-control-settings.js.map +1 -0
- package/dist/routes/supervisor.d.ts +25 -0
- package/dist/routes/supervisor.d.ts.map +1 -0
- package/dist/routes/supervisor.js +35 -0
- package/dist/routes/supervisor.js.map +1 -0
- package/dist/routes/surface.d.ts +133 -0
- package/dist/routes/surface.d.ts.map +1 -0
- package/dist/routes/surface.js +518 -0
- package/dist/routes/surface.js.map +1 -0
- package/dist/routes/telemetry.d.ts +13 -0
- package/dist/routes/telemetry.d.ts.map +1 -0
- package/dist/routes/telemetry.js +60 -0
- package/dist/routes/telemetry.js.map +1 -0
- package/dist/routes/tenant-credentials.d.ts +87 -0
- package/dist/routes/tenant-credentials.d.ts.map +1 -0
- package/dist/routes/tenant-credentials.js +219 -0
- package/dist/routes/tenant-credentials.js.map +1 -0
- package/dist/routes/work-items.d.ts +49 -0
- package/dist/routes/work-items.d.ts.map +1 -0
- package/dist/routes/work-items.js +633 -0
- package/dist/routes/work-items.js.map +1 -0
- package/dist/rules/binding-context.d.ts +59 -0
- package/dist/rules/binding-context.d.ts.map +1 -0
- package/dist/rules/binding-context.js +134 -0
- package/dist/rules/binding-context.js.map +1 -0
- package/dist/rules/decision-applicability.d.ts +32 -0
- package/dist/rules/decision-applicability.d.ts.map +1 -0
- package/dist/rules/decision-applicability.js +56 -0
- package/dist/rules/decision-applicability.js.map +1 -0
- package/dist/rules/dispatch-errors.d.ts +13 -0
- package/dist/rules/dispatch-errors.d.ts.map +1 -0
- package/dist/rules/dispatch-errors.js +105 -0
- package/dist/rules/dispatch-errors.js.map +1 -0
- package/dist/rules/dispatcher.d.ts +86 -0
- package/dist/rules/dispatcher.d.ts.map +1 -0
- package/dist/rules/dispatcher.js +1159 -0
- package/dist/rules/dispatcher.js.map +1 -0
- package/dist/rules/event-rules.d.ts +23 -0
- package/dist/rules/event-rules.d.ts.map +1 -0
- package/dist/rules/event-rules.js +46 -0
- package/dist/rules/event-rules.js.map +1 -0
- package/dist/rules/index.d.ts +6 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +4 -0
- package/dist/rules/processor.d.ts +90 -0
- package/dist/rules/processor.d.ts.map +1 -0
- package/dist/rules/processor.js +486 -0
- package/dist/rules/processor.js.map +1 -0
- package/dist/rules/resolve.d.ts +15 -0
- package/dist/rules/resolve.d.ts.map +1 -0
- package/dist/rules/resolve.js +23 -0
- package/dist/rules/resolve.js.map +1 -0
- package/dist/rules/review-source-tool.d.ts +105 -0
- package/dist/rules/review-source-tool.d.ts.map +1 -0
- package/dist/rules/review-source-tool.js +109 -0
- package/dist/rules/review-source-tool.js.map +1 -0
- package/dist/rules/start-coordinator.d.ts +64 -0
- package/dist/rules/start-coordinator.d.ts.map +1 -0
- package/dist/rules/start-coordinator.js +246 -0
- package/dist/rules/start-coordinator.js.map +1 -0
- package/dist/rules/terminal-cleanup.d.ts +38 -0
- package/dist/rules/terminal-cleanup.d.ts.map +1 -0
- package/dist/rules/terminal-cleanup.js +68 -0
- package/dist/rules/terminal-cleanup.js.map +1 -0
- package/dist/rules/tools.d.ts +15 -0
- package/dist/rules/tools.d.ts.map +1 -0
- package/dist/rules/tools.js +185 -0
- package/dist/rules/tools.js.map +1 -0
- package/dist/rules/transition-service.d.ts +93 -0
- package/dist/rules/transition-service.d.ts.map +1 -0
- package/dist/rules/transition-service.js +402 -0
- package/dist/rules/transition-service.js.map +1 -0
- package/dist/rules/types.d.ts +553 -0
- package/dist/rules/types.d.ts.map +1 -0
- package/dist/rules/types.js +154 -0
- package/dist/rules/types.js.map +1 -0
- package/dist/rules/validation.d.ts +21 -0
- package/dist/rules/validation.d.ts.map +1 -0
- package/dist/rules/validation.js +327 -0
- package/dist/rules/validation.js.map +1 -0
- package/dist/sandbox/callback-factory-sandbox.d.ts +15 -0
- package/dist/sandbox/callback-factory-sandbox.d.ts.map +1 -0
- package/dist/sandbox/callback-factory-sandbox.js +22 -0
- package/dist/sandbox/callback-factory-sandbox.js.map +1 -0
- package/dist/sandbox/git-ref.d.ts +7 -0
- package/dist/sandbox/git-ref.d.ts.map +1 -0
- package/dist/sandbox/git-ref.js +15 -0
- package/dist/sandbox/git-ref.js.map +1 -0
- package/dist/sandbox/local-factory-sandbox.d.ts +20 -0
- package/dist/sandbox/local-factory-sandbox.d.ts.map +1 -0
- package/dist/sandbox/local-factory-sandbox.js +27 -0
- package/dist/sandbox/local-factory-sandbox.js.map +1 -0
- package/dist/sandbox/materialization.d.ts +41 -0
- package/dist/sandbox/materialization.d.ts.map +1 -0
- package/dist/sandbox/materialization.js +18 -0
- package/dist/sandbox/materialization.js.map +1 -0
- package/dist/sandbox/session-retirement.d.ts +45 -0
- package/dist/sandbox/session-retirement.d.ts.map +1 -0
- package/dist/sandbox/session-retirement.js +153 -0
- package/dist/sandbox/session-retirement.js.map +1 -0
- package/dist/sandbox/session-sandbox.d.ts +185 -0
- package/dist/sandbox/session-sandbox.d.ts.map +1 -0
- package/dist/sandbox/session-sandbox.js +248 -0
- package/dist/sandbox/session-sandbox.js.map +1 -0
- package/dist/sandbox/workdir.d.ts +45 -0
- package/dist/sandbox/workdir.d.ts.map +1 -0
- package/dist/sandbox/workdir.js +64 -0
- package/dist/sandbox/workdir.js.map +1 -0
- package/dist/secret-encryption.d.ts +25 -0
- package/dist/secret-encryption.d.ts.map +1 -0
- package/dist/secret-encryption.js +107 -0
- package/dist/secret-encryption.js.map +1 -0
- package/dist/server-error.d.ts +12 -0
- package/dist/server-error.d.ts.map +1 -0
- package/dist/server-error.js +16 -0
- package/dist/server-error.js.map +1 -0
- package/dist/session/credential-policy.d.ts +20 -0
- package/dist/session/credential-policy.d.ts.map +1 -0
- package/dist/session/credential-policy.js +70 -0
- package/dist/session/credential-policy.js.map +1 -0
- package/dist/session/default-model-hydration.d.ts +46 -0
- package/dist/session/default-model-hydration.d.ts.map +1 -0
- package/dist/session/default-model-hydration.js +85 -0
- package/dist/session/default-model-hydration.js.map +1 -0
- package/dist/session/environment-repositories.d.ts +31 -0
- package/dist/session/environment-repositories.d.ts.map +1 -0
- package/dist/session/environment-repositories.js +89 -0
- package/dist/session/environment-repositories.js.map +1 -0
- package/dist/session/environment-state-processor.d.ts +59 -0
- package/dist/session/environment-state-processor.d.ts.map +1 -0
- package/dist/session/environment-state-processor.js +105 -0
- package/dist/session/environment-state-processor.js.map +1 -0
- package/dist/session/factory-session.d.ts +159 -0
- package/dist/session/factory-session.d.ts.map +1 -0
- package/dist/session/factory-session.js +226 -0
- package/dist/session/factory-session.js.map +1 -0
- package/dist/session/filesystem-capture.d.ts +50 -0
- package/dist/session/filesystem-capture.d.ts.map +1 -0
- package/dist/session/filesystem-capture.js +231 -0
- package/dist/session/filesystem-capture.js.map +1 -0
- package/dist/session/first-exec-capture.d.ts +38 -0
- package/dist/session/first-exec-capture.d.ts.map +1 -0
- package/dist/session/first-exec-capture.js +91 -0
- package/dist/session/first-exec-capture.js.map +1 -0
- package/dist/session/first-message-capture.d.ts +33 -0
- package/dist/session/first-message-capture.d.ts.map +1 -0
- package/dist/session/first-message-capture.js +35 -0
- package/dist/session/first-message-capture.js.map +1 -0
- package/dist/session/live-sessions.d.ts +63 -0
- package/dist/session/live-sessions.d.ts.map +1 -0
- package/dist/session/live-sessions.js +90 -0
- package/dist/session/live-sessions.js.map +1 -0
- package/dist/session/memory-settings-hydration.d.ts +36 -0
- package/dist/session/memory-settings-hydration.d.ts.map +1 -0
- package/dist/session/memory-settings-hydration.js +43 -0
- package/dist/session/memory-settings-hydration.js.map +1 -0
- package/dist/session/org-seed.d.ts +67 -0
- package/dist/session/org-seed.d.ts.map +1 -0
- package/dist/session/org-seed.js +53 -0
- package/dist/session/org-seed.js.map +1 -0
- package/dist/session/run-audit.d.ts +54 -0
- package/dist/session/run-audit.d.ts.map +1 -0
- package/dist/session/run-audit.js +124 -0
- package/dist/session/run-audit.js.map +1 -0
- package/dist/session/session-title.d.ts +7 -0
- package/dist/session/session-title.d.ts.map +1 -0
- package/dist/session/session-title.js +14 -0
- package/dist/session/session-title.js.map +1 -0
- package/dist/session/shell-commands.d.ts +5 -0
- package/dist/session/shell-commands.d.ts.map +1 -0
- package/dist/session/shell-commands.js +25 -0
- package/dist/session/shell-commands.js.map +1 -0
- package/dist/session/source-control-tools.d.ts +25 -0
- package/dist/session/source-control-tools.d.ts.map +1 -0
- package/dist/session/source-control-tools.js +594 -0
- package/dist/session/source-control-tools.js.map +1 -0
- package/dist/session/thread-title-mirror.d.ts +35 -0
- package/dist/session/thread-title-mirror.d.ts.map +1 -0
- package/dist/session/thread-title-mirror.js +51 -0
- package/dist/session/thread-title-mirror.js.map +1 -0
- package/dist/session/work-item-repository.d.ts +21 -0
- package/dist/session/work-item-repository.d.ts.map +1 -0
- package/dist/session/work-item-repository.js +113 -0
- package/dist/session/work-item-repository.js.map +1 -0
- package/dist/skills/catalog.d.ts +14 -0
- package/dist/skills/catalog.d.ts.map +1 -0
- package/dist/skills/catalog.js +62 -0
- package/dist/skills/catalog.js.map +1 -0
- package/dist/skills/service.d.ts +70 -0
- package/dist/skills/service.d.ts.map +1 -0
- package/dist/skills/service.js +88 -0
- package/dist/skills/service.js.map +1 -0
- package/dist/spa-static.d.ts +33 -0
- package/dist/spa-static.d.ts.map +1 -0
- package/dist/spa-static.js +104 -0
- package/dist/spa-static.js.map +1 -0
- package/dist/state-signing.d.ts +59 -0
- package/dist/state-signing.d.ts.map +1 -0
- package/dist/state-signing.js +83 -0
- package/dist/state-signing.js.map +1 -0
- package/dist/storage/domains/audit/actions.d.ts +24 -0
- package/dist/storage/domains/audit/actions.d.ts.map +1 -0
- package/dist/storage/domains/audit/actions.js +69 -0
- package/dist/storage/domains/audit/actions.js.map +1 -0
- package/dist/storage/domains/audit/actors.d.ts +5 -0
- package/dist/storage/domains/audit/actors.d.ts.map +1 -0
- package/dist/storage/domains/audit/actors.js +25 -0
- package/dist/storage/domains/audit/actors.js.map +1 -0
- package/dist/storage/domains/audit/agent-audit.d.ts +30 -0
- package/dist/storage/domains/audit/agent-audit.d.ts.map +1 -0
- package/dist/storage/domains/audit/agent-audit.js +93 -0
- package/dist/storage/domains/audit/agent-audit.js.map +1 -0
- package/dist/storage/domains/audit/base.d.ts +133 -0
- package/dist/storage/domains/audit/base.d.ts.map +1 -0
- package/dist/storage/domains/audit/base.js +206 -0
- package/dist/storage/domains/audit/base.js.map +1 -0
- package/dist/storage/domains/audit/domain.d.ts +79 -0
- package/dist/storage/domains/audit/domain.d.ts.map +1 -0
- package/dist/storage/domains/audit/domain.js +248 -0
- package/dist/storage/domains/audit/domain.js.map +1 -0
- package/dist/storage/domains/audit/wire.d.ts +24 -0
- package/dist/storage/domains/audit/wire.d.ts.map +1 -0
- package/dist/storage/domains/audit/wire.js +16 -0
- package/dist/storage/domains/audit/wire.js.map +1 -0
- package/dist/storage/domains/channel-identity/base.d.ts +100 -0
- package/dist/storage/domains/channel-identity/base.d.ts.map +1 -0
- package/dist/storage/domains/channel-identity/base.js +164 -0
- package/dist/storage/domains/channel-identity/base.js.map +1 -0
- package/dist/storage/domains/comments/activity.d.ts +40 -0
- package/dist/storage/domains/comments/activity.d.ts.map +1 -0
- package/dist/storage/domains/comments/activity.js +94 -0
- package/dist/storage/domains/comments/activity.js.map +1 -0
- package/dist/storage/domains/comments/actor.d.ts +51 -0
- package/dist/storage/domains/comments/actor.d.ts.map +1 -0
- package/dist/storage/domains/comments/actor.js +38 -0
- package/dist/storage/domains/comments/actor.js.map +1 -0
- package/dist/storage/domains/comments/base.d.ts +245 -0
- package/dist/storage/domains/comments/base.d.ts.map +1 -0
- package/dist/storage/domains/comments/base.js +533 -0
- package/dist/storage/domains/comments/base.js.map +1 -0
- package/dist/storage/domains/comments/domain.d.ts +135 -0
- package/dist/storage/domains/comments/domain.d.ts.map +1 -0
- package/dist/storage/domains/comments/domain.js +285 -0
- package/dist/storage/domains/comments/domain.js.map +1 -0
- package/dist/storage/domains/comments/feed-context.d.ts +22 -0
- package/dist/storage/domains/comments/feed-context.d.ts.map +1 -0
- package/dist/storage/domains/comments/feed-context.js +89 -0
- package/dist/storage/domains/comments/feed-context.js.map +1 -0
- package/dist/storage/domains/comments/feed-sync.d.ts +21 -0
- package/dist/storage/domains/comments/feed-sync.d.ts.map +1 -0
- package/dist/storage/domains/comments/feed-sync.js +1 -0
- package/dist/storage/domains/comments/parse.d.ts +23 -0
- package/dist/storage/domains/comments/parse.d.ts.map +1 -0
- package/dist/storage/domains/comments/parse.js +90 -0
- package/dist/storage/domains/comments/parse.js.map +1 -0
- package/dist/storage/domains/comments/routes.d.ts +24 -0
- package/dist/storage/domains/comments/routes.d.ts.map +1 -0
- package/dist/storage/domains/comments/routes.js +302 -0
- package/dist/storage/domains/comments/routes.js.map +1 -0
- package/dist/storage/domains/comments/schema.d.ts +5 -0
- package/dist/storage/domains/comments/schema.d.ts.map +1 -0
- package/dist/storage/domains/comments/schema.js +179 -0
- package/dist/storage/domains/comments/schema.js.map +1 -0
- package/dist/storage/domains/comments/wire.d.ts +40 -0
- package/dist/storage/domains/comments/wire.d.ts.map +1 -0
- package/dist/storage/domains/comments/wire.js +37 -0
- package/dist/storage/domains/comments/wire.js.map +1 -0
- package/dist/storage/domains/credentials/base.d.ts +136 -0
- package/dist/storage/domains/credentials/base.d.ts.map +1 -0
- package/dist/storage/domains/credentials/base.js +294 -0
- package/dist/storage/domains/credentials/base.js.map +1 -0
- package/dist/storage/domains/custom-providers/base.d.ts +59 -0
- package/dist/storage/domains/custom-providers/base.d.ts.map +1 -0
- package/dist/storage/domains/custom-providers/base.js +176 -0
- package/dist/storage/domains/custom-providers/base.js.map +1 -0
- package/dist/storage/domains/filesystem/base.d.ts +26 -0
- package/dist/storage/domains/filesystem/base.d.ts.map +1 -0
- package/dist/storage/domains/filesystem/base.js +74 -0
- package/dist/storage/domains/filesystem/base.js.map +1 -0
- package/dist/storage/domains/intake/base.d.ts +150 -0
- package/dist/storage/domains/intake/base.d.ts.map +1 -0
- package/dist/storage/domains/intake/base.js +431 -0
- package/dist/storage/domains/intake/base.js.map +1 -0
- package/dist/storage/domains/integrations/base.d.ts +128 -0
- package/dist/storage/domains/integrations/base.d.ts.map +1 -0
- package/dist/storage/domains/integrations/base.js +333 -0
- package/dist/storage/domains/integrations/base.js.map +1 -0
- package/dist/storage/domains/memory-settings/base.d.ts +58 -0
- package/dist/storage/domains/memory-settings/base.d.ts.map +1 -0
- package/dist/storage/domains/memory-settings/base.js +129 -0
- package/dist/storage/domains/memory-settings/base.js.map +1 -0
- package/dist/storage/domains/model-defaults/base.d.ts +29 -0
- package/dist/storage/domains/model-defaults/base.d.ts.map +1 -0
- package/dist/storage/domains/model-defaults/base.js +79 -0
- package/dist/storage/domains/model-defaults/base.js.map +1 -0
- package/dist/storage/domains/projects/base.d.ts +191 -0
- package/dist/storage/domains/projects/base.d.ts.map +1 -0
- package/dist/storage/domains/projects/base.js +352 -0
- package/dist/storage/domains/projects/base.js.map +1 -0
- package/dist/storage/domains/queue-health/base.d.ts +52 -0
- package/dist/storage/domains/queue-health/base.d.ts.map +1 -0
- package/dist/storage/domains/queue-health/base.js +122 -0
- package/dist/storage/domains/queue-health/base.js.map +1 -0
- package/dist/storage/domains/source-control/base.d.ts +422 -0
- package/dist/storage/domains/source-control/base.d.ts.map +1 -0
- package/dist/storage/domains/source-control/base.js +1114 -0
- package/dist/storage/domains/source-control/base.js.map +1 -0
- package/dist/storage/domains/source-control/inmemory.d.ts +147 -0
- package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -0
- package/dist/storage/domains/source-control/inmemory.js +416 -0
- package/dist/storage/domains/source-control/inmemory.js.map +1 -0
- package/dist/storage/domains/work-items/base.d.ts +794 -0
- package/dist/storage/domains/work-items/base.d.ts.map +1 -0
- package/dist/storage/domains/work-items/base.js +2747 -0
- package/dist/storage/domains/work-items/base.js.map +1 -0
- package/dist/storage/domains/work-items/board-version.d.ts +26 -0
- package/dist/storage/domains/work-items/board-version.d.ts.map +1 -0
- package/dist/storage/domains/work-items/board-version.js +110 -0
- package/dist/storage/domains/work-items/board-version.js.map +1 -0
- package/dist/storage/domains/work-items/metrics.d.ts +97 -0
- package/dist/storage/domains/work-items/metrics.d.ts.map +1 -0
- package/dist/storage/domains/work-items/metrics.js +226 -0
- package/dist/storage/domains/work-items/metrics.js.map +1 -0
- package/dist/supervisor/health-worker.d.ts +19 -0
- package/dist/supervisor/health-worker.d.ts.map +1 -0
- package/dist/supervisor/health-worker.js +74 -0
- package/dist/supervisor/health-worker.js.map +1 -0
- package/dist/supervisor/health.d.ts +79 -0
- package/dist/supervisor/health.d.ts.map +1 -0
- package/dist/supervisor/health.js +228 -0
- package/dist/supervisor/health.js.map +1 -0
- package/dist/supervisor/instructions.d.ts +6 -0
- package/dist/supervisor/instructions.d.ts.map +1 -0
- package/dist/supervisor/instructions.js +66 -0
- package/dist/supervisor/instructions.js.map +1 -0
- package/dist/supervisor/read-tools.d.ts +43 -0
- package/dist/supervisor/read-tools.d.ts.map +1 -0
- package/dist/supervisor/read-tools.js +343 -0
- package/dist/supervisor/read-tools.js.map +1 -0
- package/dist/supervisor/session-messaging.d.ts +26 -0
- package/dist/supervisor/session-messaging.d.ts.map +1 -0
- package/dist/supervisor/session-messaging.js +21 -0
- package/dist/supervisor/session-messaging.js.map +1 -0
- package/dist/supervisor/session.d.ts +38 -0
- package/dist/supervisor/session.d.ts.map +1 -0
- package/dist/supervisor/session.js +79 -0
- package/dist/supervisor/session.js.map +1 -0
- package/dist/supervisor/write-tools.d.ts +30 -0
- package/dist/supervisor/write-tools.d.ts.map +1 -0
- package/dist/supervisor/write-tools.js +231 -0
- package/dist/supervisor/write-tools.js.map +1 -0
- package/dist/telemetry-types.d.ts +7 -0
- package/dist/telemetry-types.d.ts.map +1 -0
- package/dist/telemetry-types.js +24 -0
- package/dist/telemetry-types.js.map +1 -0
- package/dist/telemetry.d.ts +9 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +47 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/timing.d.ts +15 -0
- package/dist/timing.d.ts.map +1 -0
- package/dist/timing.js +34 -0
- package/dist/timing.js.map +1 -0
- package/dist/work-item-branch.d.ts +33 -0
- package/dist/work-item-branch.d.ts.map +1 -0
- package/dist/work-item-branch.js +70 -0
- package/dist/work-item-branch.js.map +1 -0
- package/dist/workspace.d.ts +131 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +995 -0
- package/dist/workspace.js.map +1 -0
- package/factory-skills/configure-factory-rules/SKILL.md +122 -0
- package/factory-skills/factory-complete-issue/SKILL.md +24 -0
- package/factory-skills/factory-gitlab-rereview/SKILL.md +22 -0
- package/factory-skills/factory-gitlab-review/SKILL.md +48 -0
- package/factory-skills/factory-plan/SKILL.md +72 -0
- package/factory-skills/factory-rereview/SKILL.md +225 -0
- package/factory-skills/factory-review/SKILL.md +214 -0
- package/factory-skills/factory-review/references/archaeology.md +225 -0
- package/factory-skills/factory-review/references/categories/README.md +34 -0
- package/factory-skills/factory-review/references/categories/behavior-change.md +36 -0
- package/factory-skills/factory-review/references/categories/bug-fix.md +37 -0
- package/factory-skills/factory-review/references/categories/docs.md +32 -0
- package/factory-skills/factory-review/references/categories/experimental-flagged.md +34 -0
- package/factory-skills/factory-review/references/categories/infra-tooling.md +37 -0
- package/factory-skills/factory-review/references/categories/internal-capability.md +35 -0
- package/factory-skills/factory-review/references/categories/large-cross-cutting.md +35 -0
- package/factory-skills/factory-review/references/categories/mechanical.md +36 -0
- package/factory-skills/factory-review/references/categories/performance.md +33 -0
- package/factory-skills/factory-review/references/categories/public-api.md +38 -0
- package/factory-skills/factory-review/references/categories/refactor.md +35 -0
- package/factory-skills/factory-review/references/categories/revert.md +31 -0
- package/factory-skills/factory-review/references/categories/schema-storage.md +39 -0
- package/factory-skills/factory-review/references/categories/security.md +35 -0
- package/factory-skills/factory-review/references/categories/tests-only.md +38 -0
- package/factory-skills/factory-triage/SKILL.md +197 -0
- package/package.json +92 -0
|
@@ -0,0 +1,1266 @@
|
|
|
1
|
+
import { attachGithubReconciler, attachGithubRules } from "../../github/rules.js";
|
|
2
|
+
import { createGithubSubscriptionTools, parseCreatedPullRequest, subscribeCurrentSessionToPullRequest } from "../../github/session-subscriptions.js";
|
|
3
|
+
import { PlatformApiClient, PlatformApiError, logPlatformInfo, logPlatformWarn, platformApiClientConfigFromEnv } from "../api-client.js";
|
|
4
|
+
import { GithubAppIdentity } from "../../github/app-identity.js";
|
|
5
|
+
import { resolveGithubRules } from "../../github/default-rules.js";
|
|
6
|
+
import { attachGithubIssueReconciler } from "../../github/issue-reconciler.js";
|
|
7
|
+
import { reconcileInterval, reconciliationEnabled } from "../../github/reconciliation-config.js";
|
|
8
|
+
import { parseAuthorizedBotsEnv } from "../../github/webhook.js";
|
|
9
|
+
import { buildGithubRoutes } from "../../github/routes.js";
|
|
10
|
+
import { settleOrAbort } from "../../github/settle-or-abort.js";
|
|
11
|
+
import { PlatformGithubEventWorker } from "./event-worker.js";
|
|
12
|
+
import { registerApiRoute } from "@mastra/core/server";
|
|
13
|
+
import { Octokit } from "@octokit/rest";
|
|
14
|
+
//#region src/integrations/platform/github/integration.ts
|
|
15
|
+
const PAGE_SIZE = 30;
|
|
16
|
+
const OPEN_ISSUE_DISCOVERY_MAX_PAGES = 5;
|
|
17
|
+
const API_PREFIX = "/v1/server";
|
|
18
|
+
/**
|
|
19
|
+
* Slug of the GitHub App this integration posts as. Platform credentials do not
|
|
20
|
+
* carry their own identity, so Factory cannot otherwise recognise its own
|
|
21
|
+
* writes — and failing to recognise them makes Factory wake itself. Override
|
|
22
|
+
* with `MASTRA_PLATFORM_GITHUB_APP_SLUG` when pointing at a non-production App.
|
|
23
|
+
*/
|
|
24
|
+
const PLATFORM_GITHUB_APP_SLUG = "mastra-platform";
|
|
25
|
+
/**
|
|
26
|
+
* How long an installation's repository listing may be reused. The repos
|
|
27
|
+
* route and token minting both call it — often several times within one UI
|
|
28
|
+
* interaction — and each call is a full Platform round trip.
|
|
29
|
+
*/
|
|
30
|
+
const INSTALLATION_REPOS_CACHE_TTL_MS = 3e4;
|
|
31
|
+
/**
|
|
32
|
+
* How long a minted repository-scoped token may be reused. GitHub
|
|
33
|
+
* installation tokens live ~60 minutes; 5 minutes keeps a wide validity
|
|
34
|
+
* margin while collapsing the per-session-materialization mint round trip.
|
|
35
|
+
*/
|
|
36
|
+
const REPOSITORY_ACCESS_CACHE_TTL_MS = 5 * 6e4;
|
|
37
|
+
/**
|
|
38
|
+
* How long a collaborator permission lookup may be reused. The reconcile
|
|
39
|
+
* sweep re-stamps every open card's author and the event tail gates every
|
|
40
|
+
* human-authored event on it, so one login can cost dozens of identical
|
|
41
|
+
* requests per cycle against the installation's REST budget. Revoked access
|
|
42
|
+
* reads as trusted for at most this long.
|
|
43
|
+
*/
|
|
44
|
+
const COLLABORATOR_PERMISSION_CACHE_TTL_MS = 30 * 6e4;
|
|
45
|
+
/** Bound on the shared upstream lookup; callers race their own signal against it. */
|
|
46
|
+
const COLLABORATOR_PERMISSION_LOOKUP_TIMEOUT_MS = 1e4;
|
|
47
|
+
/**
|
|
48
|
+
* Upper bound for both TTL caches. Entries expire lazily on re-access, so
|
|
49
|
+
* without a hard cap keys that stop being queried would accumulate for the
|
|
50
|
+
* integration's (long) lifetime. Insertion-order eviction — matches the
|
|
51
|
+
* bounded verification cache in `@mastra/auth-studio`.
|
|
52
|
+
*/
|
|
53
|
+
const MAX_CACHE_ENTRIES = 1e3;
|
|
54
|
+
function setBounded(cache, key, value) {
|
|
55
|
+
cache.delete(key);
|
|
56
|
+
cache.set(key, value);
|
|
57
|
+
if (cache.size > MAX_CACHE_ENTRIES) {
|
|
58
|
+
const oldest = cache.keys().next().value;
|
|
59
|
+
if (oldest !== void 0) cache.delete(oldest);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const REPOSITORY_TOKEN_PERMISSIONS = {
|
|
63
|
+
contents: "write",
|
|
64
|
+
issues: "write",
|
|
65
|
+
pull_requests: "write"
|
|
66
|
+
};
|
|
67
|
+
/** The Platform mints one installation token for at most this many named repositories. */
|
|
68
|
+
const MAX_REPOSITORIES_PER_TOKEN = 10;
|
|
69
|
+
function loose(c) {
|
|
70
|
+
return c;
|
|
71
|
+
}
|
|
72
|
+
function routeBaseUrl(ctx, requestUrl) {
|
|
73
|
+
return (ctx.baseUrl || new URL(requestUrl).origin).replace(/\/+$/, "");
|
|
74
|
+
}
|
|
75
|
+
var PlatformGithubIntegration = class {
|
|
76
|
+
id = "github";
|
|
77
|
+
#rules;
|
|
78
|
+
get rules() {
|
|
79
|
+
return this.#rules;
|
|
80
|
+
}
|
|
81
|
+
#client;
|
|
82
|
+
#endpointHost;
|
|
83
|
+
#slug;
|
|
84
|
+
/**
|
|
85
|
+
* Factory's own GitHub identity. Platform credentials do not carry the login
|
|
86
|
+
* they post as, so this starts from the configured slug (usually absent on a
|
|
87
|
+
* Platform deployment) and is corrected the first time Factory writes.
|
|
88
|
+
*/
|
|
89
|
+
identity;
|
|
90
|
+
/**
|
|
91
|
+
* Extra reviewer bot logins this deployment trusts for author-gated
|
|
92
|
+
* notifications, merged over the built-in defaults.
|
|
93
|
+
*/
|
|
94
|
+
authorizedBots;
|
|
95
|
+
#pollingEnabled;
|
|
96
|
+
#pollingIntervalMs;
|
|
97
|
+
#pullRequestReconcileEnabled;
|
|
98
|
+
#issueReconcileEnabled;
|
|
99
|
+
#pullRequestReconcileIntervalMs;
|
|
100
|
+
#issueReconcileIntervalMs;
|
|
101
|
+
#storage;
|
|
102
|
+
#integrationStorage;
|
|
103
|
+
/** installationId → cached repository listing (TTL-bounded). */
|
|
104
|
+
#installationReposCache = /* @__PURE__ */ new Map();
|
|
105
|
+
/** `orgId:repositoryId` → cached repository access (TTL-bounded). */
|
|
106
|
+
#repositoryAccessCache = /* @__PURE__ */ new Map();
|
|
107
|
+
/** `owner/repo:login` → cached collaborator permission (TTL-bounded). */
|
|
108
|
+
#collaboratorPermissionCache = /* @__PURE__ */ new Map();
|
|
109
|
+
/** Same key → lookup already in flight, so overlapping callers share one request. */
|
|
110
|
+
#collaboratorPermissionInFlight = /* @__PURE__ */ new Map();
|
|
111
|
+
intake = {
|
|
112
|
+
resolveIntakeDispatch: (input) => this.#resolveIntakeDispatch(input),
|
|
113
|
+
listSources: async ({ orgId, userId }) => {
|
|
114
|
+
const usable = (await this.#client.request("GET", `${API_PREFIX}/github-app/installations`)).installations.filter((installation) => installation.usable && !installation.suspendedAt);
|
|
115
|
+
return (await Promise.all(usable.map(async (installation) => {
|
|
116
|
+
const storedInstallation = await this.versionControl.registerInstallation({
|
|
117
|
+
orgId,
|
|
118
|
+
userId,
|
|
119
|
+
installation: {
|
|
120
|
+
externalId: String(installation.installationId),
|
|
121
|
+
accountName: installation.accountLogin,
|
|
122
|
+
accountType: installation.accountType
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
const result = await this.#client.request("GET", `${API_PREFIX}/github-app/installations/${installation.installationId}/repositories`);
|
|
126
|
+
await this.versionControl.registerRepositories({
|
|
127
|
+
orgId,
|
|
128
|
+
installationId: storedInstallation.id,
|
|
129
|
+
repositories: result.repositories.map((repository) => ({
|
|
130
|
+
externalId: String(repository.id),
|
|
131
|
+
slug: repository.fullName,
|
|
132
|
+
defaultBranch: repository.defaultBranch,
|
|
133
|
+
metadata: {
|
|
134
|
+
private: repository.private,
|
|
135
|
+
url: repository.htmlUrl
|
|
136
|
+
}
|
|
137
|
+
}))
|
|
138
|
+
});
|
|
139
|
+
return result.repositories.map((repository) => ({
|
|
140
|
+
repository,
|
|
141
|
+
installation
|
|
142
|
+
}));
|
|
143
|
+
}))).flat().map(({ repository, installation }) => ({
|
|
144
|
+
id: repository.fullName,
|
|
145
|
+
name: repository.fullName,
|
|
146
|
+
type: "repository",
|
|
147
|
+
metadata: {
|
|
148
|
+
installationId: installation.installationId,
|
|
149
|
+
accountLogin: installation.accountLogin,
|
|
150
|
+
accountType: installation.accountType,
|
|
151
|
+
repositoryId: repository.id,
|
|
152
|
+
defaultBranch: repository.defaultBranch,
|
|
153
|
+
private: repository.private,
|
|
154
|
+
url: repository.htmlUrl
|
|
155
|
+
}
|
|
156
|
+
}));
|
|
157
|
+
},
|
|
158
|
+
listItems: async ({ sourceIds, cursor }) => {
|
|
159
|
+
const page = parsePositiveCursor(cursor);
|
|
160
|
+
const pages = await Promise.all(sourceIds.map(async (sourceId) => {
|
|
161
|
+
const connection = {
|
|
162
|
+
type: "app-installation",
|
|
163
|
+
installationId: 1
|
|
164
|
+
};
|
|
165
|
+
const [issues, pullRequests] = await Promise.all([this.#listIssues(connection, sourceId, page), this.#listPullRequests({
|
|
166
|
+
connection,
|
|
167
|
+
sourceId,
|
|
168
|
+
includeDrafts: false,
|
|
169
|
+
cursor: String(page)
|
|
170
|
+
})]);
|
|
171
|
+
return {
|
|
172
|
+
items: [...issues.issues.map((issue) => ({
|
|
173
|
+
source: {
|
|
174
|
+
type: "issue",
|
|
175
|
+
externalId: `${sourceId}:${issue.id}`,
|
|
176
|
+
url: issue.url
|
|
177
|
+
},
|
|
178
|
+
sourceId,
|
|
179
|
+
title: issue.title,
|
|
180
|
+
status: issue.state ?? void 0,
|
|
181
|
+
labels: issue.labels,
|
|
182
|
+
assignee: issue.assignee,
|
|
183
|
+
createdAt: issue.createdAt,
|
|
184
|
+
updatedAt: issue.updatedAt,
|
|
185
|
+
metadata: {
|
|
186
|
+
repository: sourceId,
|
|
187
|
+
number: Number(issue.id),
|
|
188
|
+
author: issue.author
|
|
189
|
+
}
|
|
190
|
+
})), ...pullRequests.pullRequests.map((pullRequest) => ({
|
|
191
|
+
source: {
|
|
192
|
+
type: "pull-request",
|
|
193
|
+
externalId: `${sourceId}:${pullRequest.id}`,
|
|
194
|
+
url: pullRequest.url
|
|
195
|
+
},
|
|
196
|
+
sourceId,
|
|
197
|
+
title: pullRequest.title,
|
|
198
|
+
status: pullRequest.state,
|
|
199
|
+
createdAt: pullRequest.createdAt,
|
|
200
|
+
updatedAt: pullRequest.updatedAt,
|
|
201
|
+
metadata: {
|
|
202
|
+
repository: sourceId,
|
|
203
|
+
number: Number(pullRequest.id),
|
|
204
|
+
author: pullRequest.author,
|
|
205
|
+
baseBranch: pullRequest.baseBranch,
|
|
206
|
+
headBranch: pullRequest.headBranch
|
|
207
|
+
}
|
|
208
|
+
}))],
|
|
209
|
+
hasNextPage: issues.nextCursor !== null || pullRequests.nextCursor !== null
|
|
210
|
+
};
|
|
211
|
+
}));
|
|
212
|
+
return {
|
|
213
|
+
items: pages.flatMap((result) => result.items),
|
|
214
|
+
nextCursor: pages.some((result) => result.hasNextPage) ? String(page + 1) : null
|
|
215
|
+
};
|
|
216
|
+
},
|
|
217
|
+
listIssues: async (input) => {
|
|
218
|
+
requireGithubConnection(input.connection);
|
|
219
|
+
const sourceId = requireSingleSource(input.sourceIds, "GitHub Intake requires exactly one repository source.");
|
|
220
|
+
return this.#listIssues(input.connection, sourceId, parsePositiveCursor(input.cursor), input.labels);
|
|
221
|
+
},
|
|
222
|
+
getIssue: (input) => this.#getIssue(input.connection, input.sourceId, input.issueId),
|
|
223
|
+
createComment: (input) => this.#createIssueComment(input),
|
|
224
|
+
updateIssue: (input) => this.#updateIntakeIssue(input)
|
|
225
|
+
};
|
|
226
|
+
versionControl = {
|
|
227
|
+
initialize: ({ storage }) => {
|
|
228
|
+
this.#storage = storage;
|
|
229
|
+
},
|
|
230
|
+
registerInstallation: ({ orgId, userId, installation }) => this.storage.installations.upsert({
|
|
231
|
+
orgId,
|
|
232
|
+
connectedByUserId: userId,
|
|
233
|
+
externalId: installation.externalId,
|
|
234
|
+
accountName: installation.accountName,
|
|
235
|
+
accountType: installation.accountType,
|
|
236
|
+
providerMetadata: installation.metadata
|
|
237
|
+
}),
|
|
238
|
+
registerRepositories: ({ orgId, installationId, repositories }) => Promise.all(repositories.map((repository) => this.storage.repositories.upsert({
|
|
239
|
+
orgId,
|
|
240
|
+
input: {
|
|
241
|
+
installationId,
|
|
242
|
+
externalId: repository.externalId,
|
|
243
|
+
slug: repository.slug,
|
|
244
|
+
defaultBranch: repository.defaultBranch,
|
|
245
|
+
providerMetadata: repository.metadata
|
|
246
|
+
}
|
|
247
|
+
}))),
|
|
248
|
+
getRepositoryTarget: async ({ orgId, repositoryId }) => {
|
|
249
|
+
const repository = await this.storage.repositories.get({
|
|
250
|
+
orgId,
|
|
251
|
+
id: repositoryId
|
|
252
|
+
});
|
|
253
|
+
if (!repository) throw new Error("Version-control repository not found.");
|
|
254
|
+
const installation = await this.storage.installations.get({
|
|
255
|
+
orgId,
|
|
256
|
+
id: repository.installationId
|
|
257
|
+
});
|
|
258
|
+
if (!installation) throw new Error("Version-control installation not found.");
|
|
259
|
+
const installationId = parsePositiveInteger(installation.externalId);
|
|
260
|
+
if (installationId === null) throw new Error("GitHub installation id is invalid.");
|
|
261
|
+
return {
|
|
262
|
+
connection: {
|
|
263
|
+
type: "app-installation",
|
|
264
|
+
installationId
|
|
265
|
+
},
|
|
266
|
+
sourceId: repository.slug
|
|
267
|
+
};
|
|
268
|
+
},
|
|
269
|
+
getRepositoryAccess: async ({ orgId, repositoryId }) => {
|
|
270
|
+
const cacheKey = `${orgId}:${repositoryId}`;
|
|
271
|
+
const cached = this.#repositoryAccessCache.get(cacheKey);
|
|
272
|
+
if (cached && cached.expiresAt > Date.now()) return cached.access;
|
|
273
|
+
this.#repositoryAccessCache.delete(cacheKey);
|
|
274
|
+
const repository = await this.storage.repositories.get({
|
|
275
|
+
orgId,
|
|
276
|
+
id: repositoryId
|
|
277
|
+
});
|
|
278
|
+
if (!repository) throw new Error("Version-control repository not found.");
|
|
279
|
+
const cloneUrl = `https://github.com/${repository.slug}.git`;
|
|
280
|
+
const installation = await this.storage.installations.get({
|
|
281
|
+
orgId,
|
|
282
|
+
id: repository.installationId
|
|
283
|
+
});
|
|
284
|
+
if (!installation) throw new Error("Version-control installation not found.");
|
|
285
|
+
const installationId = parsePositiveInteger(installation.externalId);
|
|
286
|
+
if (installationId === null) throw new Error("GitHub installation id is invalid.");
|
|
287
|
+
const repositoryName = splitRepository(repository.slug).repo;
|
|
288
|
+
try {
|
|
289
|
+
const access = {
|
|
290
|
+
cloneUrl,
|
|
291
|
+
authorization: {
|
|
292
|
+
scheme: "bearer",
|
|
293
|
+
token: (await this.#client.request("POST", `${API_PREFIX}/github-app/installations/${installationId}/token`, {
|
|
294
|
+
repositories: [repositoryName],
|
|
295
|
+
permissions: REPOSITORY_TOKEN_PERMISSIONS
|
|
296
|
+
})).token
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
setBounded(this.#repositoryAccessCache, cacheKey, {
|
|
300
|
+
access,
|
|
301
|
+
expiresAt: Date.now() + REPOSITORY_ACCESS_CACHE_TTL_MS
|
|
302
|
+
});
|
|
303
|
+
return access;
|
|
304
|
+
} catch (err) {
|
|
305
|
+
if (!isDeadInstallation(err) || !installation.accountName) throw err;
|
|
306
|
+
const newInstallation = (await this.storage.installations.list({ orgId })).find((inst) => inst.accountName === installation.accountName && inst.id !== installation.id);
|
|
307
|
+
if (!newInstallation) throw err;
|
|
308
|
+
const newInstallationId = parsePositiveInteger(newInstallation.externalId);
|
|
309
|
+
if (newInstallationId === null) throw err;
|
|
310
|
+
await this.storage.repositories.migrateInstallation({
|
|
311
|
+
orgId,
|
|
312
|
+
id: repositoryId,
|
|
313
|
+
newInstallationId: newInstallation.id
|
|
314
|
+
});
|
|
315
|
+
const access = {
|
|
316
|
+
cloneUrl,
|
|
317
|
+
authorization: {
|
|
318
|
+
scheme: "bearer",
|
|
319
|
+
token: (await this.#client.request("POST", `${API_PREFIX}/github-app/installations/${newInstallationId}/token`, {
|
|
320
|
+
repositories: [repositoryName],
|
|
321
|
+
permissions: REPOSITORY_TOKEN_PERMISSIONS
|
|
322
|
+
})).token
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
setBounded(this.#repositoryAccessCache, cacheKey, {
|
|
326
|
+
access,
|
|
327
|
+
expiresAt: Date.now() + REPOSITORY_ACCESS_CACHE_TTL_MS
|
|
328
|
+
});
|
|
329
|
+
return access;
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
getRepositoriesAccess: async ({ orgId, repositoryIds }) => {
|
|
333
|
+
const ids = [...new Set(repositoryIds)];
|
|
334
|
+
if (ids.length === 0 || ids.length > MAX_REPOSITORIES_PER_TOKEN) return void 0;
|
|
335
|
+
const cacheKey = `${orgId}:${[...ids].sort().join(",")}`;
|
|
336
|
+
const cached = this.#repositoryAccessCache.get(cacheKey);
|
|
337
|
+
if (cached && cached.expiresAt > Date.now()) return cached.access;
|
|
338
|
+
this.#repositoryAccessCache.delete(cacheKey);
|
|
339
|
+
const repositories = await Promise.all(ids.map((id) => this.storage.repositories.get({
|
|
340
|
+
orgId,
|
|
341
|
+
id
|
|
342
|
+
})));
|
|
343
|
+
if (repositories.some((repository) => !repository)) throw new Error("Version-control repository not found.");
|
|
344
|
+
const found = repositories;
|
|
345
|
+
if (new Set(found.map((repository) => repository.installationId)).size !== 1) return void 0;
|
|
346
|
+
const installation = await this.storage.installations.get({
|
|
347
|
+
orgId,
|
|
348
|
+
id: found[0].installationId
|
|
349
|
+
});
|
|
350
|
+
if (!installation) throw new Error("Version-control installation not found.");
|
|
351
|
+
const installationId = parsePositiveInteger(installation.externalId);
|
|
352
|
+
if (installationId === null) throw new Error("GitHub installation id is invalid.");
|
|
353
|
+
const token = await this.#client.request("POST", `${API_PREFIX}/github-app/installations/${installationId}/token`, {
|
|
354
|
+
repositories: found.map((repository) => splitRepository(repository.slug).repo),
|
|
355
|
+
permissions: REPOSITORY_TOKEN_PERMISSIONS
|
|
356
|
+
});
|
|
357
|
+
const access = {
|
|
358
|
+
cloneUrl: `https://github.com/${found[0].slug}.git`,
|
|
359
|
+
authorization: {
|
|
360
|
+
scheme: "bearer",
|
|
361
|
+
token: token.token
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
setBounded(this.#repositoryAccessCache, cacheKey, {
|
|
365
|
+
access,
|
|
366
|
+
expiresAt: Date.now() + REPOSITORY_ACCESS_CACHE_TTL_MS
|
|
367
|
+
});
|
|
368
|
+
return access;
|
|
369
|
+
},
|
|
370
|
+
listPullRequests: (input) => this.#listPullRequests(input),
|
|
371
|
+
getPullRequest: (input) => this.#getPullRequest(input),
|
|
372
|
+
createPullRequest: (input) => this.#createPullRequest(input),
|
|
373
|
+
updatePullRequest: (input) => this.#updatePullRequest(input),
|
|
374
|
+
closePullRequest: (input) => this.#updatePullRequest({
|
|
375
|
+
...input,
|
|
376
|
+
state: "closed"
|
|
377
|
+
}),
|
|
378
|
+
mergePullRequest: (input) => this.#mergePullRequest(input),
|
|
379
|
+
listComments: (input) => this.#listComments(input),
|
|
380
|
+
createComment: (input) => this.#createComment(input),
|
|
381
|
+
updateComment: (input) => this.#updateComment(input),
|
|
382
|
+
deleteComment: (input) => this.#deleteComment(input),
|
|
383
|
+
listReviews: (input) => this.#listReviews(input),
|
|
384
|
+
getReview: (input) => this.#getReview(input),
|
|
385
|
+
createReview: (input) => this.#createReview(input),
|
|
386
|
+
updateReview: (input) => this.#updateReview(input),
|
|
387
|
+
submitReview: (input) => this.#submitReview(input),
|
|
388
|
+
dismissReview: (input) => this.#dismissReview(input),
|
|
389
|
+
deletePendingReview: (input) => this.#deletePendingReview(input),
|
|
390
|
+
listReviewComments: (input) => this.#listReviewComments(input),
|
|
391
|
+
createReviewComment: (input) => this.#createReviewComment(input),
|
|
392
|
+
updateReviewComment: (input) => this.#updateReviewComment(input),
|
|
393
|
+
deleteReviewComment: (input) => this.#deleteReviewComment(input),
|
|
394
|
+
listRequestedReviewers: (input) => this.#requestedReviewers("GET", input),
|
|
395
|
+
requestReviewers: (input) => this.#requestedReviewers("POST", input),
|
|
396
|
+
removeRequestedReviewers: (input) => this.#requestedReviewers("DELETE", input)
|
|
397
|
+
};
|
|
398
|
+
constructor(options = {}) {
|
|
399
|
+
this.#rules = resolveGithubRules(options.rules);
|
|
400
|
+
const config = platformApiClientConfigFromEnv();
|
|
401
|
+
this.#client = new PlatformApiClient(config);
|
|
402
|
+
this.#endpointHost = new URL(config.baseUrl).host;
|
|
403
|
+
this.#slug = options.slug;
|
|
404
|
+
this.identity = new GithubAppIdentity(process.env.MASTRA_PLATFORM_GITHUB_APP_SLUG?.trim() || PLATFORM_GITHUB_APP_SLUG);
|
|
405
|
+
this.authorizedBots = parseAuthorizedBotsEnv(process.env.MASTRACODE_GITHUB_AUTHORIZED_BOTS) ?? [];
|
|
406
|
+
this.#pollingEnabled = process.env.MASTRA_PLATFORM_GITHUB_POLLING_ENABLED?.trim().toLowerCase() !== "false";
|
|
407
|
+
this.#pollingIntervalMs = optionalPositiveIntegerEnv("MASTRA_PLATFORM_GITHUB_POLLING_INTERVAL_MS");
|
|
408
|
+
const legacyReconcileEnabled = process.env.MASTRA_PLATFORM_GITHUB_RECONCILE_ENABLED;
|
|
409
|
+
this.#pullRequestReconcileEnabled = reconciliationEnabled(process.env.MASTRACODE_PLATFORM_GITHUB_PR_RECONCILE_ENABLED, legacyReconcileEnabled);
|
|
410
|
+
this.#issueReconcileEnabled = reconciliationEnabled(process.env.MASTRACODE_PLATFORM_GITHUB_ISSUE_RECONCILE_ENABLED, legacyReconcileEnabled);
|
|
411
|
+
const legacyReconcileIntervalMs = reconcileInterval(process.env.MASTRACODE_PLATFORM_GITHUB_RECONCILE_INTERVAL_MS);
|
|
412
|
+
this.#pullRequestReconcileIntervalMs = reconcileInterval(process.env.MASTRACODE_PLATFORM_GITHUB_PR_RECONCILE_INTERVAL_MS) ?? legacyReconcileIntervalMs;
|
|
413
|
+
this.#issueReconcileIntervalMs = reconcileInterval(process.env.MASTRACODE_PLATFORM_GITHUB_ISSUE_RECONCILE_INTERVAL_MS) ?? legacyReconcileIntervalMs;
|
|
414
|
+
}
|
|
415
|
+
/** GitHub App slug when the deployment explicitly provides it. */
|
|
416
|
+
get slug() {
|
|
417
|
+
return this.#slug;
|
|
418
|
+
}
|
|
419
|
+
isFactoryCommentAuthor(login) {
|
|
420
|
+
return typeof login === "string" && this.identity.matches(login);
|
|
421
|
+
}
|
|
422
|
+
get storage() {
|
|
423
|
+
if (!this.#storage) throw new Error("PlatformGithubIntegration source-control storage has not been initialized.");
|
|
424
|
+
return this.#storage;
|
|
425
|
+
}
|
|
426
|
+
get sourceControlStorage() {
|
|
427
|
+
return this.storage;
|
|
428
|
+
}
|
|
429
|
+
get integrationStorage() {
|
|
430
|
+
if (!this.#integrationStorage) throw new Error("PlatformGithubIntegration generic storage has not been initialized.");
|
|
431
|
+
return this.#integrationStorage;
|
|
432
|
+
}
|
|
433
|
+
/** Resolve a stored GitHub locator without scanning installations or repositories. */
|
|
434
|
+
async #resolveIntakeDispatch({ orgId, externalSource }) {
|
|
435
|
+
const target = parseGithubExternalTarget(externalSource.externalId);
|
|
436
|
+
if (!target) return null;
|
|
437
|
+
const repository = target.repository.includes("/") ? target.repository : (await this.storage.repositories.findByExternalId({
|
|
438
|
+
orgId,
|
|
439
|
+
externalId: target.repository
|
|
440
|
+
}))?.slug;
|
|
441
|
+
if (!repository) return null;
|
|
442
|
+
return {
|
|
443
|
+
connection: {
|
|
444
|
+
type: "app-installation",
|
|
445
|
+
installationId: 1
|
|
446
|
+
},
|
|
447
|
+
sourceId: repository,
|
|
448
|
+
issueId: target.issueId
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
initialize({ storage }) {
|
|
452
|
+
this.#integrationStorage = storage;
|
|
453
|
+
logPlatformInfo("Platform GitHub integration initialized", {
|
|
454
|
+
endpointHost: this.#endpointHost,
|
|
455
|
+
pollingEnabled: this.#pollingEnabled,
|
|
456
|
+
pollingIntervalMs: this.#pollingIntervalMs,
|
|
457
|
+
pullRequestReconcileEnabled: this.#pullRequestReconcileEnabled,
|
|
458
|
+
issueReconcileEnabled: this.#issueReconcileEnabled
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
routes(ctx) {
|
|
462
|
+
const ingestFactoryEvent = attachGithubRules(this, ctx);
|
|
463
|
+
return [
|
|
464
|
+
this.#statusRoute(ctx),
|
|
465
|
+
this.#connectRoute(ctx),
|
|
466
|
+
this.#connectUserRoute(ctx),
|
|
467
|
+
...buildGithubRoutes({
|
|
468
|
+
auth: ctx.auth,
|
|
469
|
+
sandbox: ctx.sandbox,
|
|
470
|
+
storage: ctx.factoryStorage,
|
|
471
|
+
github: this,
|
|
472
|
+
stateSigner: ctx.stateSigner,
|
|
473
|
+
baseUrl: ctx.baseUrl,
|
|
474
|
+
controller: ctx.controller,
|
|
475
|
+
memorySettings: ctx.storage.memorySettings,
|
|
476
|
+
projects: ctx.storage.projects,
|
|
477
|
+
emitAudit: ctx.hooks?.emitAudit,
|
|
478
|
+
ingestFactoryEvent,
|
|
479
|
+
...ctx.workItems ? { workItems: ctx.workItems } : {}
|
|
480
|
+
}).filter((route) => route.path !== "/web/github/status" && route.path !== "/web/github/webhook" && !route.path.startsWith("/auth/github/"))
|
|
481
|
+
];
|
|
482
|
+
}
|
|
483
|
+
#statusRoute(ctx) {
|
|
484
|
+
return registerApiRoute("/web/github/status", {
|
|
485
|
+
method: "GET",
|
|
486
|
+
requiresAuth: false,
|
|
487
|
+
handler: async (c) => {
|
|
488
|
+
await ctx.auth.ensureUser(loose(c));
|
|
489
|
+
const tenant = ctx.auth.tenant(loose(c));
|
|
490
|
+
if (!tenant) return c.json({
|
|
491
|
+
error: "unauthorized",
|
|
492
|
+
reason: "auth_required"
|
|
493
|
+
}, 401);
|
|
494
|
+
if (!tenant.orgId) return c.json({
|
|
495
|
+
enabled: true,
|
|
496
|
+
sandboxEnabled: !!ctx.sandbox,
|
|
497
|
+
organizationRequired: true,
|
|
498
|
+
connected: false,
|
|
499
|
+
installations: [],
|
|
500
|
+
userConnected: false,
|
|
501
|
+
userGithubUsername: null,
|
|
502
|
+
reason: "organization_required",
|
|
503
|
+
diagnostics: this.diagnostics()
|
|
504
|
+
});
|
|
505
|
+
const [installations, userConnection] = await Promise.all([this.#syncInstallations(tenant.orgId, tenant.userId), this.#fetchUserConnection(tenant.userId)]);
|
|
506
|
+
return c.json({
|
|
507
|
+
enabled: true,
|
|
508
|
+
sandboxEnabled: !!ctx.sandbox,
|
|
509
|
+
connected: installations.length > 0,
|
|
510
|
+
installations: installations.map((installation) => ({
|
|
511
|
+
installationId: Number(installation.externalId),
|
|
512
|
+
accountLogin: installation.accountName,
|
|
513
|
+
accountType: installation.accountType
|
|
514
|
+
})),
|
|
515
|
+
userConnected: userConnection.connected,
|
|
516
|
+
userGithubUsername: userConnection.githubUsername,
|
|
517
|
+
reason: installations.length > 0 ? "ready" : "not_connected",
|
|
518
|
+
diagnostics: this.diagnostics()
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
#connectRoute(ctx) {
|
|
524
|
+
return registerApiRoute("/auth/github/connect", {
|
|
525
|
+
method: "GET",
|
|
526
|
+
requiresAuth: false,
|
|
527
|
+
handler: async (c) => {
|
|
528
|
+
await ctx.auth.ensureUser(loose(c));
|
|
529
|
+
const tenant = ctx.auth.tenant(loose(c));
|
|
530
|
+
if (!tenant?.orgId) return c.json({ error: "unauthorized" }, 401);
|
|
531
|
+
const redirectTo = c.req.query("redirectTo") || c.req.query("return_to") || "/";
|
|
532
|
+
const originator = routeBaseUrl(ctx, c.req.url);
|
|
533
|
+
logPlatformInfo("Starting Platform GitHub connect flow", {
|
|
534
|
+
orgId: tenant.orgId,
|
|
535
|
+
redirectTo,
|
|
536
|
+
originator
|
|
537
|
+
});
|
|
538
|
+
const query = new URLSearchParams({
|
|
539
|
+
action: "install",
|
|
540
|
+
redirectTo,
|
|
541
|
+
originator
|
|
542
|
+
});
|
|
543
|
+
const { url } = await this.#client.request("GET", `${API_PREFIX}/github-app/install-url?${query}`);
|
|
544
|
+
return c.redirect(url);
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
#connectUserRoute(ctx) {
|
|
549
|
+
return registerApiRoute("/auth/github/connect-user", {
|
|
550
|
+
method: "GET",
|
|
551
|
+
requiresAuth: false,
|
|
552
|
+
handler: async (c) => {
|
|
553
|
+
await ctx.auth.ensureUser(loose(c));
|
|
554
|
+
const tenant = ctx.auth.tenant(loose(c));
|
|
555
|
+
if (!tenant?.orgId) return c.json({ error: "unauthorized" }, 401);
|
|
556
|
+
const redirectTo = c.req.query("redirectTo") || c.req.query("return_to") || "/";
|
|
557
|
+
const originator = routeBaseUrl(ctx, c.req.url);
|
|
558
|
+
logPlatformInfo("Starting Platform GitHub user authorization flow", {
|
|
559
|
+
orgId: tenant.orgId,
|
|
560
|
+
redirectTo,
|
|
561
|
+
originator
|
|
562
|
+
});
|
|
563
|
+
const query = new URLSearchParams({
|
|
564
|
+
userId: tenant.userId,
|
|
565
|
+
redirectTo,
|
|
566
|
+
originator
|
|
567
|
+
});
|
|
568
|
+
const { url } = await this.#client.request("GET", `${API_PREFIX}/github-app/authenticate?${query}`);
|
|
569
|
+
return c.redirect(url);
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* Personal GitHub connection status for the acting user. Returns
|
|
575
|
+
* not-connected when the platform predates the user-connection endpoint.
|
|
576
|
+
*/
|
|
577
|
+
async #fetchUserConnection(userId) {
|
|
578
|
+
try {
|
|
579
|
+
const connection = await this.#client.request("GET", `${API_PREFIX}/github-app/user-connection?${new URLSearchParams({ userId })}`);
|
|
580
|
+
if (!connection.connected && connection.reason) logPlatformWarn("Platform GitHub user connection verification failed", {
|
|
581
|
+
userId,
|
|
582
|
+
reason: connection.reason
|
|
583
|
+
});
|
|
584
|
+
return connection;
|
|
585
|
+
} catch {
|
|
586
|
+
return {
|
|
587
|
+
connected: false,
|
|
588
|
+
githubUsername: null
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
async #syncInstallations(orgId, userId) {
|
|
593
|
+
const usableInstallations = (await this.#client.request("GET", `${API_PREFIX}/github-app/installations`)).installations.filter((installation) => installation.usable && !installation.suspendedAt);
|
|
594
|
+
return Promise.all(usableInstallations.map((installation) => this.versionControl.registerInstallation({
|
|
595
|
+
orgId,
|
|
596
|
+
userId,
|
|
597
|
+
installation: {
|
|
598
|
+
externalId: String(installation.installationId),
|
|
599
|
+
accountName: installation.accountLogin,
|
|
600
|
+
accountType: installation.accountType
|
|
601
|
+
}
|
|
602
|
+
})));
|
|
603
|
+
}
|
|
604
|
+
workers(ctx) {
|
|
605
|
+
if (!this.#pollingEnabled && !this.#pullRequestReconcileEnabled && !this.#issueReconcileEnabled) return [];
|
|
606
|
+
if (!ctx.controller) throw new Error("Platform GitHub event polling requires the mounted Mastra Code controller.");
|
|
607
|
+
return [new PlatformGithubEventWorker({
|
|
608
|
+
client: this.#client,
|
|
609
|
+
controller: ctx.controller,
|
|
610
|
+
github: this,
|
|
611
|
+
storage: ctx.storage.generic,
|
|
612
|
+
ingestFactoryEvent: attachGithubRules(this, ctx),
|
|
613
|
+
reconcileFactoryState: this.#pullRequestReconcileEnabled ? attachGithubReconciler(this, ctx, (input) => this.fetchPullRequestState(input)) : void 0,
|
|
614
|
+
reconcileIssuesFactoryState: this.#issueReconcileEnabled ? attachGithubIssueReconciler(this, ctx, (input) => this.fetchIssueState(input), (input) => this.listOpenIssueStates(input)) : void 0,
|
|
615
|
+
pollEventsEnabled: this.#pollingEnabled,
|
|
616
|
+
intervalMs: this.#pollingIntervalMs,
|
|
617
|
+
pullRequestReconcileIntervalMs: this.#pullRequestReconcileIntervalMs,
|
|
618
|
+
issueReconcileIntervalMs: this.#issueReconcileIntervalMs,
|
|
619
|
+
sourceControl: {
|
|
620
|
+
projectRepositories: {
|
|
621
|
+
listConfiguredExternalKeys: () => this.storage.projectRepositories.listConfiguredExternalKeys(),
|
|
622
|
+
listByExternalRepository: (args) => this.storage.projectRepositories.listByExternalRepository(args)
|
|
623
|
+
},
|
|
624
|
+
repositories: { findByExternalId: (args) => this.storage.repositories.findByExternalId(args) }
|
|
625
|
+
}
|
|
626
|
+
})];
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Reads live PR state through the Platform GitHub proxy for the merge
|
|
630
|
+
* reconciler. Returns undefined when the PR cannot be resolved (missing,
|
|
631
|
+
* proxy error) so a sweep never fabricates a merge.
|
|
632
|
+
*/
|
|
633
|
+
async fetchPullRequestState(input) {
|
|
634
|
+
let repository;
|
|
635
|
+
try {
|
|
636
|
+
repository = splitRepository(input.repository);
|
|
637
|
+
} catch {
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
try {
|
|
641
|
+
const result = await this.#client.request("GET", `${API_PREFIX}/github/repos/${encodeURIComponent(repository.owner)}/${encodeURIComponent(repository.repo)}/pulls/${input.number}`);
|
|
642
|
+
return {
|
|
643
|
+
title: result.title ?? `PR ${input.number}`,
|
|
644
|
+
url: result.html_url ?? `https://github.com/${input.repository}/pull/${input.number}`,
|
|
645
|
+
state: result.state === "closed" ? "closed" : "open",
|
|
646
|
+
draft: result.draft === true,
|
|
647
|
+
merged: result.merged === true,
|
|
648
|
+
assignees: (result.assignees ?? []).flatMap((assignee) => assignee.login ? [assignee.login] : []),
|
|
649
|
+
requestedReviewers: (result.requested_reviewers ?? []).flatMap((reviewer) => reviewer.login ? [reviewer.login] : []),
|
|
650
|
+
labels: (result.labels ?? []).flatMap((label) => typeof label === "string" ? [label] : label.name ? [label.name] : []),
|
|
651
|
+
headBranch: result.head?.ref ?? "",
|
|
652
|
+
baseBranch: result.base?.ref ?? "",
|
|
653
|
+
...result.user?.login ? { author: result.user.login } : {},
|
|
654
|
+
...result.created_at ? { createdAt: result.created_at } : {},
|
|
655
|
+
...result.merged_by?.login ? { mergedBy: result.merged_by.login } : {}
|
|
656
|
+
};
|
|
657
|
+
} catch {
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Reads live issue state through the Platform GitHub proxy for the
|
|
663
|
+
* reconciler. Returns undefined when the issue cannot be resolved (missing,
|
|
664
|
+
* is actually a PR, proxy error) so a sweep never fabricates a close.
|
|
665
|
+
*/
|
|
666
|
+
async fetchIssueState(input) {
|
|
667
|
+
let repository;
|
|
668
|
+
try {
|
|
669
|
+
repository = splitRepository(input.repository);
|
|
670
|
+
} catch {
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
try {
|
|
674
|
+
const result = await this.#client.request("GET", `${API_PREFIX}/github/repos/${encodeURIComponent(repository.owner)}/${encodeURIComponent(repository.repo)}/issues/${input.number}`);
|
|
675
|
+
if (result.pull_request) return void 0;
|
|
676
|
+
return {
|
|
677
|
+
title: result.title ?? `Issue ${input.number}`,
|
|
678
|
+
url: result.html_url ?? `https://github.com/${input.repository}/issues/${input.number}`,
|
|
679
|
+
state: result.state === "closed" ? "closed" : "open",
|
|
680
|
+
...result.state_reason ? { stateReason: result.state_reason } : {},
|
|
681
|
+
assignees: (result.assignees ?? []).flatMap((assignee) => assignee.login ? [assignee.login] : []),
|
|
682
|
+
labels: (result.labels ?? []).map((label) => typeof label === "string" ? label : label.name).filter((name) => Boolean(name)),
|
|
683
|
+
...result.user?.login ? { author: result.user.login } : {},
|
|
684
|
+
...result.created_at ? { createdAt: result.created_at } : {},
|
|
685
|
+
...result.updated_at ? { updatedAt: result.updated_at } : {}
|
|
686
|
+
};
|
|
687
|
+
} catch {
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
async listOpenIssueStates(input) {
|
|
692
|
+
const issues = [];
|
|
693
|
+
for (let page = 1; page <= OPEN_ISSUE_DISCOVERY_MAX_PAGES; page += 1) {
|
|
694
|
+
const query = new URLSearchParams({
|
|
695
|
+
state: "open",
|
|
696
|
+
page: String(page),
|
|
697
|
+
per_page: String(PAGE_SIZE)
|
|
698
|
+
});
|
|
699
|
+
const result = await this.#client.request("GET", `${repositoryPath(input.repository, "issues")}?${query}`);
|
|
700
|
+
for (const issue of result.issues) issues.push({
|
|
701
|
+
number: issue.number,
|
|
702
|
+
title: issue.title,
|
|
703
|
+
url: issue.htmlUrl,
|
|
704
|
+
state: "open",
|
|
705
|
+
assignees: issue.assignees,
|
|
706
|
+
labels: issue.labels,
|
|
707
|
+
...issue.user?.login ? { author: issue.user.login } : {},
|
|
708
|
+
createdAt: issue.createdAt,
|
|
709
|
+
updatedAt: issue.updatedAt
|
|
710
|
+
});
|
|
711
|
+
if (result.issues.length < PAGE_SIZE) break;
|
|
712
|
+
}
|
|
713
|
+
return issues;
|
|
714
|
+
}
|
|
715
|
+
async upsertFactoryTriageComment(input) {
|
|
716
|
+
const comments = [];
|
|
717
|
+
for (let page = 1;; page += 1) {
|
|
718
|
+
const query = new URLSearchParams({
|
|
719
|
+
page: String(page),
|
|
720
|
+
per_page: String(PAGE_SIZE)
|
|
721
|
+
});
|
|
722
|
+
const result = await this.#client.request("GET", `${repositoryPath(input.repository, `issues/${input.issueNumber}/comments`)}?${query}`);
|
|
723
|
+
comments.push(...result.comments);
|
|
724
|
+
if (result.comments.length < PAGE_SIZE) break;
|
|
725
|
+
}
|
|
726
|
+
const existing = comments.filter((comment) => comment.body.includes("<!-- mastra-factory-triage -->") && this.isFactoryCommentAuthor(comment.user?.login)).sort((left, right) => left.id - right.id)[0];
|
|
727
|
+
if (existing) {
|
|
728
|
+
const comment = await this.#client.request("PATCH", repositoryPath(input.repository, `issues/comments/${existing.id}`), { body: input.body });
|
|
729
|
+
this.#observeSelfAuthor(comment, void 0);
|
|
730
|
+
return {
|
|
731
|
+
action: "updated",
|
|
732
|
+
commentId: String(comment.id),
|
|
733
|
+
url: comment.htmlUrl
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
const comment = await this.#client.request("POST", repositoryPath(input.repository, `issues/${input.issueNumber}/comments`), { body: input.body });
|
|
737
|
+
this.#observeSelfAuthor(comment, void 0);
|
|
738
|
+
return {
|
|
739
|
+
action: "created",
|
|
740
|
+
commentId: String(comment.id),
|
|
741
|
+
url: comment.htmlUrl
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
sessionTools({ requestContext }) {
|
|
745
|
+
return createGithubSubscriptionTools(requestContext, this);
|
|
746
|
+
}
|
|
747
|
+
async postToolObserver({ toolContext, requestContext }) {
|
|
748
|
+
const pullRequestUrl = parseCreatedPullRequest(toolContext);
|
|
749
|
+
if (!pullRequestUrl || !requestContext) return;
|
|
750
|
+
await subscribeCurrentSessionToPullRequest(requestContext, pullRequestUrl, "auto-gh-pr-create", this);
|
|
751
|
+
}
|
|
752
|
+
diagnostics() {
|
|
753
|
+
return {
|
|
754
|
+
mode: "platform",
|
|
755
|
+
endpointHost: this.#endpointHost,
|
|
756
|
+
polling: {
|
|
757
|
+
enabled: this.#pollingEnabled,
|
|
758
|
+
...this.#pollingIntervalMs === void 0 ? {} : { intervalMs: this.#pollingIntervalMs }
|
|
759
|
+
},
|
|
760
|
+
reconcile: {
|
|
761
|
+
pullRequests: {
|
|
762
|
+
enabled: this.#pullRequestReconcileEnabled,
|
|
763
|
+
...this.#pullRequestReconcileIntervalMs === void 0 ? {} : { intervalMs: this.#pullRequestReconcileIntervalMs }
|
|
764
|
+
},
|
|
765
|
+
issues: {
|
|
766
|
+
enabled: this.#issueReconcileEnabled,
|
|
767
|
+
...this.#issueReconcileIntervalMs === void 0 ? {} : { intervalMs: this.#issueReconcileIntervalMs }
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
async getRepositoryCollaboratorPermission(_installationId, repoFullName, username, signal) {
|
|
773
|
+
let repository;
|
|
774
|
+
try {
|
|
775
|
+
repository = splitRepository(repoFullName);
|
|
776
|
+
} catch {
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
const cacheKey = `${repository.owner}/${repository.repo}:${username.toLowerCase()}`;
|
|
780
|
+
const cached = this.#collaboratorPermissionCache.get(cacheKey);
|
|
781
|
+
if (cached && cached.expiresAt > Date.now()) return cached.permission;
|
|
782
|
+
this.#collaboratorPermissionCache.delete(cacheKey);
|
|
783
|
+
const inFlight = this.#collaboratorPermissionInFlight.get(cacheKey);
|
|
784
|
+
if (inFlight) return settleOrAbort(inFlight, signal, void 0);
|
|
785
|
+
const lookup = (async () => {
|
|
786
|
+
try {
|
|
787
|
+
const result = await this.#client.request("GET", `${API_PREFIX}/github/repos/${encodeURIComponent(repository.owner)}/${encodeURIComponent(repository.repo)}/collaborators/${encodeURIComponent(username)}/permission`, void 0, { signal: AbortSignal.timeout(COLLABORATOR_PERMISSION_LOOKUP_TIMEOUT_MS) });
|
|
788
|
+
setBounded(this.#collaboratorPermissionCache, cacheKey, {
|
|
789
|
+
permission: result.permission,
|
|
790
|
+
expiresAt: Date.now() + COLLABORATOR_PERMISSION_CACHE_TTL_MS
|
|
791
|
+
});
|
|
792
|
+
return result.permission;
|
|
793
|
+
} catch {
|
|
794
|
+
return;
|
|
795
|
+
} finally {
|
|
796
|
+
this.#collaboratorPermissionInFlight.delete(cacheKey);
|
|
797
|
+
}
|
|
798
|
+
})();
|
|
799
|
+
this.#collaboratorPermissionInFlight.set(cacheKey, lookup);
|
|
800
|
+
return settleOrAbort(lookup, signal, void 0);
|
|
801
|
+
}
|
|
802
|
+
async listInstallationRepos(installationId, options) {
|
|
803
|
+
const cached = this.#installationReposCache.get(installationId);
|
|
804
|
+
if (!options?.fresh && cached && cached.expiresAt > Date.now()) return cached.repos;
|
|
805
|
+
this.#installationReposCache.delete(installationId);
|
|
806
|
+
const repos = (await this.#client.request("GET", `${API_PREFIX}/github-app/installations/${installationId}/repositories`)).repositories.map((repository) => ({
|
|
807
|
+
...repository,
|
|
808
|
+
installationId
|
|
809
|
+
}));
|
|
810
|
+
setBounded(this.#installationReposCache, installationId, {
|
|
811
|
+
repos,
|
|
812
|
+
expiresAt: Date.now() + INSTALLATION_REPOS_CACHE_TTL_MS
|
|
813
|
+
});
|
|
814
|
+
return repos;
|
|
815
|
+
}
|
|
816
|
+
async mintInstallationToken(installationId) {
|
|
817
|
+
const repositories = await this.listInstallationRepos(installationId);
|
|
818
|
+
if (repositories.length === 0 || repositories.length > MAX_REPOSITORIES_PER_TOKEN) throw new Error("Platform GitHub token minting requires between one and ten installation repositories.");
|
|
819
|
+
return (await this.#client.request("POST", `${API_PREFIX}/github-app/installations/${installationId}/token`, {
|
|
820
|
+
repositories: repositories.map((repository) => repository.name),
|
|
821
|
+
permissions: REPOSITORY_TOKEN_PERMISSIONS
|
|
822
|
+
})).token;
|
|
823
|
+
}
|
|
824
|
+
async addIssueLabels(_installationId, sourceId, issueNumber, labels) {
|
|
825
|
+
return (await this.#client.request("POST", repositoryPath(sourceId, `issues/${issueNumber}/labels`), { labels })).labels;
|
|
826
|
+
}
|
|
827
|
+
async removeIssueLabel(_installationId, sourceId, issueNumber, label) {
|
|
828
|
+
const name = label.trim();
|
|
829
|
+
if (!name) return;
|
|
830
|
+
await this.#client.request("DELETE", repositoryPath(sourceId, `issues/${issueNumber}/labels/${encodeURIComponent(name)}`));
|
|
831
|
+
}
|
|
832
|
+
getInstallationOctokit(_installationId) {
|
|
833
|
+
return { pulls: { get: async ({ owner, repo, pull_number }) => {
|
|
834
|
+
const data = await this.#client.request("GET", repositoryPath(`${owner}/${repo}`, `pulls/${pull_number}`));
|
|
835
|
+
return { data: {
|
|
836
|
+
base: { repo: { id: data.base.repo.id } },
|
|
837
|
+
head: { ref: data.head.ref }
|
|
838
|
+
} };
|
|
839
|
+
} } };
|
|
840
|
+
}
|
|
841
|
+
async #listIssues(connection, sourceId, page, labels) {
|
|
842
|
+
requireGithubConnection(connection);
|
|
843
|
+
const path = repositoryPath(sourceId, "issues");
|
|
844
|
+
const query = new URLSearchParams({
|
|
845
|
+
state: "open",
|
|
846
|
+
page: String(page),
|
|
847
|
+
per_page: String(PAGE_SIZE)
|
|
848
|
+
});
|
|
849
|
+
const normalizedLabels = normalizeLabels(labels);
|
|
850
|
+
if (normalizedLabels.length > 0) query.set("label", normalizedLabels.join(","));
|
|
851
|
+
const result = await this.#client.request("GET", `${path}?${query}`);
|
|
852
|
+
return {
|
|
853
|
+
issues: result.issues.map((issue) => parseIntakeIssue(sourceId, issue)),
|
|
854
|
+
nextCursor: result.issues.length > 0 ? String(page + 1) : null
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
async #getIssue(connection, sourceId, issueId) {
|
|
858
|
+
requireGithubConnection(connection);
|
|
859
|
+
const repository = requireSource(sourceId, "GitHub Intake requires a repository source.");
|
|
860
|
+
const issueNumber = requirePositiveId(issueId, "issue");
|
|
861
|
+
try {
|
|
862
|
+
const [issue, comments] = await Promise.all([this.#client.request("GET", repositoryPath(repository, `issues/${issueNumber}`)), this.#client.request("GET", `${repositoryPath(repository, `issues/${issueNumber}/comments`)}?per_page=100`)]);
|
|
863
|
+
return parseIntakeIssueDetail(repository, issue, comments.comments);
|
|
864
|
+
} catch (error) {
|
|
865
|
+
if (isNotFound(error)) return null;
|
|
866
|
+
throw error;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
async #updateIntakeIssue(input) {
|
|
870
|
+
requireGithubConnection(input.connection);
|
|
871
|
+
const repository = requireSource(input.sourceId, "GitHub Intake requires a repository source.");
|
|
872
|
+
const issueNumber = requirePositiveId(input.issueId, "issue");
|
|
873
|
+
if (input.state.kind === "byName") {
|
|
874
|
+
logPlatformWarn(`Platform GitHub: updateIssue byName is not supported (name=${input.state.name}); ignoring.`);
|
|
875
|
+
return null;
|
|
876
|
+
}
|
|
877
|
+
const targetState = input.state.stateType === "unstarted" || input.state.stateType === "started" ? "open" : "closed";
|
|
878
|
+
const stateReason = targetState === "closed" ? input.state.stateType === "canceled" ? "not_planned" : "completed" : null;
|
|
879
|
+
try {
|
|
880
|
+
await this.#client.request("GET", repositoryPath(repository, `pulls/${issueNumber}`));
|
|
881
|
+
logPlatformWarn(`Platform GitHub: updateIssue rejected — target ${repository}#${issueNumber} is a pull request.`);
|
|
882
|
+
return null;
|
|
883
|
+
} catch (error) {
|
|
884
|
+
if (!isNotFound(error)) throw error;
|
|
885
|
+
}
|
|
886
|
+
try {
|
|
887
|
+
return parseIntakeIssue(repository, await this.#client.request("PATCH", repositoryPath(repository, `issues/${issueNumber}`), {
|
|
888
|
+
state: targetState,
|
|
889
|
+
...stateReason ? { state_reason: stateReason } : {}
|
|
890
|
+
}, { actingUserId: input.actingUserId }));
|
|
891
|
+
} catch (error) {
|
|
892
|
+
if (isNotFound(error)) return null;
|
|
893
|
+
throw error;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Learn Factory's own login from a write it just made. Skipped when the write
|
|
898
|
+
* was made on behalf of a user — that comment is authored by the human, and
|
|
899
|
+
* recording it would teach Factory to mistake a person for itself.
|
|
900
|
+
*/
|
|
901
|
+
#observeSelfAuthor(comment, actingUserId) {
|
|
902
|
+
if (actingUserId) return;
|
|
903
|
+
this.identity.observeSelfAuthor(comment.user?.login);
|
|
904
|
+
}
|
|
905
|
+
async #createIssueComment(input) {
|
|
906
|
+
requireGithubConnection(input.connection);
|
|
907
|
+
const repository = requireSource(input.sourceId, "GitHub Intake requires a repository source.");
|
|
908
|
+
const issueNumber = requirePositiveId(input.issueId, "issue");
|
|
909
|
+
try {
|
|
910
|
+
const comment = await this.#client.request("POST", repositoryPath(repository, `issues/${issueNumber}/comments`), { body: input.body }, { actingUserId: input.actingUserId });
|
|
911
|
+
this.#observeSelfAuthor(comment, input.actingUserId);
|
|
912
|
+
return {
|
|
913
|
+
id: String(comment.id),
|
|
914
|
+
url: comment.htmlUrl
|
|
915
|
+
};
|
|
916
|
+
} catch (error) {
|
|
917
|
+
if (isNotFound(error)) return null;
|
|
918
|
+
throw error;
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
async #listPullRequests(input) {
|
|
922
|
+
requireGithubConnection(input.connection);
|
|
923
|
+
const page = parsePositiveCursor(input.cursor);
|
|
924
|
+
const query = new URLSearchParams({
|
|
925
|
+
state: input.state ?? "open",
|
|
926
|
+
page: String(page),
|
|
927
|
+
per_page: String(PAGE_SIZE)
|
|
928
|
+
});
|
|
929
|
+
const result = await this.#client.request("GET", `${repositoryPath(input.sourceId, "pulls")}?${query}`);
|
|
930
|
+
return {
|
|
931
|
+
pullRequests: result.pullRequests.filter((pullRequest) => input.includeDrafts !== false || !pullRequest.draft).map(parsePullRequest),
|
|
932
|
+
nextCursor: result.pullRequests.length === PAGE_SIZE ? String(page + 1) : null
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
async #getPullRequest(input) {
|
|
936
|
+
try {
|
|
937
|
+
return parsePullRequest(await this.#client.request("GET", pullRequestPath(input, input.pullRequestId)));
|
|
938
|
+
} catch (error) {
|
|
939
|
+
if (isNotFound(error)) return null;
|
|
940
|
+
throw error;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
async #createPullRequest(input) {
|
|
944
|
+
requireGithubConnection(input.connection);
|
|
945
|
+
const result = await this.#client.request("POST", repositoryPath(input.sourceId, "pulls"), {
|
|
946
|
+
head: input.headBranch,
|
|
947
|
+
base: input.baseBranch,
|
|
948
|
+
title: input.title,
|
|
949
|
+
body: input.body,
|
|
950
|
+
draft: input.draft
|
|
951
|
+
}, { actingUserId: input.actingUserId });
|
|
952
|
+
const created = parsePullRequest(result);
|
|
953
|
+
if (input.actingUserId && input.connection.type === "app-installation") try {
|
|
954
|
+
const user = await this.#fetchUserConnection(input.actingUserId);
|
|
955
|
+
const login = user.githubUsername;
|
|
956
|
+
if (user.connected && login) {
|
|
957
|
+
const { owner, repo } = splitRepository(input.sourceId);
|
|
958
|
+
const { token } = await this.#client.request("POST", `${API_PREFIX}/github-app/installations/${input.connection.installationId}/token`, {
|
|
959
|
+
repositories: [repo],
|
|
960
|
+
permissions: REPOSITORY_TOKEN_PERMISSIONS
|
|
961
|
+
});
|
|
962
|
+
const { data } = await new Octokit({
|
|
963
|
+
auth: token,
|
|
964
|
+
request: { timeout: 15e3 }
|
|
965
|
+
}).issues.addAssignees({
|
|
966
|
+
owner,
|
|
967
|
+
repo,
|
|
968
|
+
issue_number: result.number,
|
|
969
|
+
assignees: [login]
|
|
970
|
+
});
|
|
971
|
+
if (!data.assignees?.some((assignee) => assignee.login?.toLowerCase() === login.toLowerCase())) logPlatformWarn("GitHub did not assign the PR opener", {
|
|
972
|
+
url: created.url,
|
|
973
|
+
login
|
|
974
|
+
});
|
|
975
|
+
else created.assignees = data.assignees.flatMap((assignee) => assignee.login ? [assignee.login] : []);
|
|
976
|
+
}
|
|
977
|
+
} catch (error) {
|
|
978
|
+
logPlatformWarn("Failed to assign the PR opener", {
|
|
979
|
+
url: created.url,
|
|
980
|
+
error: error instanceof Error ? error.message : String(error)
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
return created;
|
|
984
|
+
}
|
|
985
|
+
async #updatePullRequest(input) {
|
|
986
|
+
return parsePullRequest(await this.#client.request("PATCH", pullRequestPath(input, input.pullRequestId), {
|
|
987
|
+
title: input.title,
|
|
988
|
+
body: input.body === null ? "" : input.body,
|
|
989
|
+
base: input.baseBranch,
|
|
990
|
+
state: input.state
|
|
991
|
+
}, { actingUserId: input.actingUserId }));
|
|
992
|
+
}
|
|
993
|
+
#mergePullRequest(input) {
|
|
994
|
+
return this.#client.request("PUT", `${pullRequestPath(input, input.pullRequestId)}/merge`, {
|
|
995
|
+
commitTitle: input.commitTitle,
|
|
996
|
+
commitMessage: input.commitMessage,
|
|
997
|
+
method: input.method
|
|
998
|
+
}, { actingUserId: input.actingUserId });
|
|
999
|
+
}
|
|
1000
|
+
async #listComments(input) {
|
|
1001
|
+
const page = parsePositiveCursor(input.cursor);
|
|
1002
|
+
const result = await this.#client.request("GET", `${repositoryPath(input.sourceId, `issues/${requirePositiveId(input.pullRequestId, "pull request")}/comments`)}?page=${page}&per_page=${PAGE_SIZE}`);
|
|
1003
|
+
return {
|
|
1004
|
+
comments: result.comments.map(parseComment),
|
|
1005
|
+
nextCursor: result.comments.length === PAGE_SIZE ? String(page + 1) : null
|
|
1006
|
+
};
|
|
1007
|
+
}
|
|
1008
|
+
async #createComment(input) {
|
|
1009
|
+
const comment = await this.#client.request("POST", repositoryPath(input.sourceId, `issues/${requirePositiveId(input.pullRequestId, "pull request")}/comments`), { body: input.body }, { actingUserId: input.actingUserId });
|
|
1010
|
+
this.#observeSelfAuthor(comment, input.actingUserId);
|
|
1011
|
+
return parseComment(comment);
|
|
1012
|
+
}
|
|
1013
|
+
async #updateComment(input) {
|
|
1014
|
+
requireGithubConnection(input.connection);
|
|
1015
|
+
return parseComment(await this.#client.request("PATCH", repositoryPath(input.sourceId, `issues/comments/${requirePositiveId(input.commentId, "comment")}`), { body: input.body }, { actingUserId: input.actingUserId }));
|
|
1016
|
+
}
|
|
1017
|
+
async #deleteComment(input) {
|
|
1018
|
+
requireGithubConnection(input.connection);
|
|
1019
|
+
await this.#client.request("DELETE", repositoryPath(input.sourceId, `issues/comments/${requirePositiveId(input.commentId, "comment")}`), void 0, { actingUserId: input.actingUserId });
|
|
1020
|
+
}
|
|
1021
|
+
async #listReviews(input) {
|
|
1022
|
+
const page = parsePositiveCursor(input.cursor);
|
|
1023
|
+
const result = await this.#client.request("GET", `${pullRequestPath(input, input.pullRequestId)}/reviews?page=${page}&per_page=${PAGE_SIZE}`);
|
|
1024
|
+
return {
|
|
1025
|
+
reviews: result.reviews.map(parseReview),
|
|
1026
|
+
nextCursor: result.reviews.length === PAGE_SIZE ? String(page + 1) : null
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
async #getReview(input) {
|
|
1030
|
+
try {
|
|
1031
|
+
return parseReview(await this.#client.request("GET", `${pullRequestPath(input, input.pullRequestId)}/reviews/${requirePositiveId(input.reviewId, "review")}`));
|
|
1032
|
+
} catch (error) {
|
|
1033
|
+
if (isNotFound(error)) return null;
|
|
1034
|
+
throw error;
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
async #createReview(input) {
|
|
1038
|
+
return parseReview(await this.#client.request("POST", `${pullRequestPath(input, input.pullRequestId)}/reviews`, {
|
|
1039
|
+
body: input.body,
|
|
1040
|
+
commitId: input.commitId,
|
|
1041
|
+
event: input.event ? reviewEvent(input.event) : void 0
|
|
1042
|
+
}, { actingUserId: input.actingUserId }));
|
|
1043
|
+
}
|
|
1044
|
+
async #updateReview(input) {
|
|
1045
|
+
return parseReview(await this.#client.request("PUT", `${pullRequestPath(input, input.pullRequestId)}/reviews/${requirePositiveId(input.reviewId, "review")}`, { body: input.body }, { actingUserId: input.actingUserId }));
|
|
1046
|
+
}
|
|
1047
|
+
async #submitReview(input) {
|
|
1048
|
+
return parseReview(await this.#client.request("POST", `${pullRequestPath(input, input.pullRequestId)}/reviews/${requirePositiveId(input.reviewId, "review")}/events`, {
|
|
1049
|
+
body: input.body,
|
|
1050
|
+
event: reviewEvent(input.event)
|
|
1051
|
+
}, { actingUserId: input.actingUserId }));
|
|
1052
|
+
}
|
|
1053
|
+
async #dismissReview(input) {
|
|
1054
|
+
return parseReview(await this.#client.request("PUT", `${pullRequestPath(input, input.pullRequestId)}/reviews/${requirePositiveId(input.reviewId, "review")}/dismissals`, { message: input.message }, { actingUserId: input.actingUserId }));
|
|
1055
|
+
}
|
|
1056
|
+
async #deletePendingReview(input) {
|
|
1057
|
+
await this.#client.request("DELETE", `${pullRequestPath(input, input.pullRequestId)}/reviews/${requirePositiveId(input.reviewId, "review")}`, void 0, { actingUserId: input.actingUserId });
|
|
1058
|
+
}
|
|
1059
|
+
async #listReviewComments(input) {
|
|
1060
|
+
const page = parsePositiveCursor(input.cursor);
|
|
1061
|
+
const result = await this.#client.request("GET", `${pullRequestPath(input, input.pullRequestId)}/comments?page=${page}&per_page=${PAGE_SIZE}`);
|
|
1062
|
+
return {
|
|
1063
|
+
comments: result.comments.map(parseReviewComment),
|
|
1064
|
+
nextCursor: result.comments.length === PAGE_SIZE ? String(page + 1) : null
|
|
1065
|
+
};
|
|
1066
|
+
}
|
|
1067
|
+
async #createReviewComment(input) {
|
|
1068
|
+
let body;
|
|
1069
|
+
if (input.replyToId !== void 0) body = {
|
|
1070
|
+
body: input.body,
|
|
1071
|
+
replyToId: requirePositiveId(input.replyToId, "review comment")
|
|
1072
|
+
};
|
|
1073
|
+
else {
|
|
1074
|
+
if (!input.commitId || !input.path || input.line === void 0 || !input.side) throw new Error("A review comment requires commitId, path, line, and side unless it is a reply.");
|
|
1075
|
+
body = {
|
|
1076
|
+
body: input.body,
|
|
1077
|
+
commitId: input.commitId,
|
|
1078
|
+
path: input.path,
|
|
1079
|
+
line: input.line,
|
|
1080
|
+
side: input.side.toUpperCase(),
|
|
1081
|
+
startLine: input.startLine,
|
|
1082
|
+
startSide: input.startSide?.toUpperCase()
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1085
|
+
return parseReviewComment(await this.#client.request("POST", `${pullRequestPath(input, input.pullRequestId)}/comments`, body, { actingUserId: input.actingUserId }));
|
|
1086
|
+
}
|
|
1087
|
+
async #updateReviewComment(input) {
|
|
1088
|
+
requireGithubConnection(input.connection);
|
|
1089
|
+
return parseReviewComment(await this.#client.request("PATCH", repositoryPath(input.sourceId, `pulls/comments/${requirePositiveId(input.commentId, "review comment")}`), { body: input.body }, { actingUserId: input.actingUserId }));
|
|
1090
|
+
}
|
|
1091
|
+
async #deleteReviewComment(input) {
|
|
1092
|
+
requireGithubConnection(input.connection);
|
|
1093
|
+
await this.#client.request("DELETE", repositoryPath(input.sourceId, `pulls/comments/${requirePositiveId(input.commentId, "review comment")}`), void 0, { actingUserId: input.actingUserId });
|
|
1094
|
+
}
|
|
1095
|
+
#requestedReviewers(method, input) {
|
|
1096
|
+
requireGithubConnection(input.connection);
|
|
1097
|
+
return this.#client.request(method, `${pullRequestPath(input, input.pullRequestId)}/requested-reviewers`, method === "GET" ? void 0 : {
|
|
1098
|
+
users: input.users,
|
|
1099
|
+
teams: input.teams
|
|
1100
|
+
}, method === "GET" ? void 0 : { actingUserId: input.actingUserId });
|
|
1101
|
+
}
|
|
1102
|
+
};
|
|
1103
|
+
function repositoryPath(sourceId, suffix) {
|
|
1104
|
+
const { owner, repo } = splitRepository(sourceId);
|
|
1105
|
+
return `${API_PREFIX}/github/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/${suffix}`;
|
|
1106
|
+
}
|
|
1107
|
+
function pullRequestPath(input, pullRequestId) {
|
|
1108
|
+
requireGithubConnection(input.connection);
|
|
1109
|
+
return repositoryPath(input.sourceId, `pulls/${requirePositiveId(pullRequestId, "pull request")}`);
|
|
1110
|
+
}
|
|
1111
|
+
function splitRepository(sourceId) {
|
|
1112
|
+
const slash = sourceId.indexOf("/");
|
|
1113
|
+
if (slash <= 0 || slash === sourceId.length - 1) throw new Error("GitHub capabilities require an owner/repository source.");
|
|
1114
|
+
return {
|
|
1115
|
+
owner: sourceId.slice(0, slash),
|
|
1116
|
+
repo: sourceId.slice(slash + 1)
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
function parseIntakeIssue(sourceId, issue) {
|
|
1120
|
+
return {
|
|
1121
|
+
id: String(issue.number),
|
|
1122
|
+
identifier: `#${issue.number}`,
|
|
1123
|
+
title: issue.title,
|
|
1124
|
+
url: issue.htmlUrl,
|
|
1125
|
+
author: issue.user?.login ?? null,
|
|
1126
|
+
state: issue.state,
|
|
1127
|
+
stateType: issue.state,
|
|
1128
|
+
priority: null,
|
|
1129
|
+
assignee: issue.assignees[0] ?? null,
|
|
1130
|
+
assignees: issue.assignees,
|
|
1131
|
+
source: sourceId,
|
|
1132
|
+
labels: issue.labels,
|
|
1133
|
+
commentCount: issue.commentCount,
|
|
1134
|
+
createdAt: issue.createdAt,
|
|
1135
|
+
updatedAt: issue.updatedAt
|
|
1136
|
+
};
|
|
1137
|
+
}
|
|
1138
|
+
function parseIntakeIssueDetail(sourceId, issue, comments) {
|
|
1139
|
+
return {
|
|
1140
|
+
...parseIntakeIssue(sourceId, issue),
|
|
1141
|
+
description: issue.body?.trim() ? issue.body : null,
|
|
1142
|
+
comments: comments.map((comment) => ({
|
|
1143
|
+
author: comment.user?.login ?? null,
|
|
1144
|
+
body: comment.body,
|
|
1145
|
+
createdAt: comment.createdAt
|
|
1146
|
+
}))
|
|
1147
|
+
};
|
|
1148
|
+
}
|
|
1149
|
+
function parsePullRequest(pullRequest) {
|
|
1150
|
+
return {
|
|
1151
|
+
id: String(pullRequest.number),
|
|
1152
|
+
title: pullRequest.title,
|
|
1153
|
+
url: pullRequest.htmlUrl,
|
|
1154
|
+
author: pullRequest.user?.login ?? null,
|
|
1155
|
+
assignees: pullRequest.assignees ?? [],
|
|
1156
|
+
requestedReviewers: pullRequest.requestedReviewers ?? [],
|
|
1157
|
+
labels: pullRequest.labels ?? [],
|
|
1158
|
+
body: pullRequest.body?.trim() ? pullRequest.body : null,
|
|
1159
|
+
state: pullRequest.state,
|
|
1160
|
+
draft: pullRequest.draft,
|
|
1161
|
+
merged: pullRequest.merged,
|
|
1162
|
+
mergeable: pullRequest.mergeable,
|
|
1163
|
+
baseBranch: pullRequest.base.ref,
|
|
1164
|
+
headBranch: pullRequest.head.ref,
|
|
1165
|
+
headSha: pullRequest.head.sha,
|
|
1166
|
+
createdAt: pullRequest.createdAt,
|
|
1167
|
+
updatedAt: pullRequest.updatedAt
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
function parseComment(comment) {
|
|
1171
|
+
return {
|
|
1172
|
+
id: String(comment.id),
|
|
1173
|
+
url: comment.htmlUrl,
|
|
1174
|
+
author: comment.user?.login ?? null,
|
|
1175
|
+
body: comment.body,
|
|
1176
|
+
createdAt: comment.createdAt,
|
|
1177
|
+
updatedAt: comment.updatedAt
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1180
|
+
function parseReview(review) {
|
|
1181
|
+
return {
|
|
1182
|
+
id: String(review.id),
|
|
1183
|
+
url: review.htmlUrl,
|
|
1184
|
+
author: review.user?.login ?? null,
|
|
1185
|
+
body: review.body?.trim() ? review.body : null,
|
|
1186
|
+
state: {
|
|
1187
|
+
PENDING: "pending",
|
|
1188
|
+
COMMENTED: "commented",
|
|
1189
|
+
APPROVED: "approved",
|
|
1190
|
+
CHANGES_REQUESTED: "changes-requested",
|
|
1191
|
+
DISMISSED: "dismissed"
|
|
1192
|
+
}[review.state],
|
|
1193
|
+
commitId: review.commitId,
|
|
1194
|
+
submittedAt: review.submittedAt
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1197
|
+
function parseReviewComment(comment) {
|
|
1198
|
+
return {
|
|
1199
|
+
...parseComment(comment),
|
|
1200
|
+
path: comment.path,
|
|
1201
|
+
line: comment.line,
|
|
1202
|
+
side: comment.side?.toLowerCase(),
|
|
1203
|
+
commitId: comment.commitId,
|
|
1204
|
+
replyToId: comment.replyToId === null ? null : String(comment.replyToId)
|
|
1205
|
+
};
|
|
1206
|
+
}
|
|
1207
|
+
function requireGithubConnection(connection) {
|
|
1208
|
+
if (connection.type !== "app-installation" && connection.type !== "oauth") throw new Error("GitHub capabilities require a GitHub connection.");
|
|
1209
|
+
}
|
|
1210
|
+
function requireSingleSource(sourceIds, message) {
|
|
1211
|
+
if (sourceIds.length !== 1) throw new Error(message);
|
|
1212
|
+
return sourceIds[0];
|
|
1213
|
+
}
|
|
1214
|
+
function requireSource(sourceId, message) {
|
|
1215
|
+
if (!sourceId) throw new Error(message);
|
|
1216
|
+
return sourceId;
|
|
1217
|
+
}
|
|
1218
|
+
function normalizeLabels(labels) {
|
|
1219
|
+
return [...new Set((labels ?? []).map((label) => label.trim()).filter(Boolean))];
|
|
1220
|
+
}
|
|
1221
|
+
function parsePositiveCursor(cursor) {
|
|
1222
|
+
if (cursor === void 0) return 1;
|
|
1223
|
+
const parsed = parsePositiveInteger(cursor);
|
|
1224
|
+
if (parsed === null) throw new Error("GitHub cursor must be a positive page number.");
|
|
1225
|
+
return parsed;
|
|
1226
|
+
}
|
|
1227
|
+
function parsePositiveInteger(value) {
|
|
1228
|
+
if (!/^\d+$/.test(value)) return null;
|
|
1229
|
+
const parsed = Number(value);
|
|
1230
|
+
return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : null;
|
|
1231
|
+
}
|
|
1232
|
+
function parseGithubExternalTarget(externalId) {
|
|
1233
|
+
const match = externalId.match(/^(.+\/.+):(\d+)$/) ?? externalId.match(/^github:(\d+):(?:issue|pull-request):(\d+)$/) ?? externalId.match(/^(\d+):(\d+)$/);
|
|
1234
|
+
if (!match?.[1] || !match[2] || parsePositiveInteger(match[2]) === null) return null;
|
|
1235
|
+
return {
|
|
1236
|
+
repository: match[1],
|
|
1237
|
+
issueId: match[2]
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1240
|
+
function optionalPositiveIntegerEnv(name) {
|
|
1241
|
+
const value = process.env[name]?.trim();
|
|
1242
|
+
if (!value) return void 0;
|
|
1243
|
+
const parsed = parsePositiveInteger(value);
|
|
1244
|
+
if (parsed === null) throw new Error(`${name} must be a positive integer.`);
|
|
1245
|
+
return parsed;
|
|
1246
|
+
}
|
|
1247
|
+
function requirePositiveId(value, resource) {
|
|
1248
|
+
const parsed = parsePositiveInteger(value);
|
|
1249
|
+
if (parsed === null) throw new Error(`GitHub ${resource} id must be a positive integer.`);
|
|
1250
|
+
return parsed;
|
|
1251
|
+
}
|
|
1252
|
+
function reviewEvent(event) {
|
|
1253
|
+
if (event === "approve") return "APPROVE";
|
|
1254
|
+
if (event === "request-changes") return "REQUEST_CHANGES";
|
|
1255
|
+
return "COMMENT";
|
|
1256
|
+
}
|
|
1257
|
+
function isNotFound(error) {
|
|
1258
|
+
return error instanceof PlatformApiError && error.status === 404;
|
|
1259
|
+
}
|
|
1260
|
+
function isDeadInstallation(error) {
|
|
1261
|
+
return error instanceof PlatformApiError && (error.status === 404 || error.status === 409);
|
|
1262
|
+
}
|
|
1263
|
+
//#endregion
|
|
1264
|
+
export { PlatformGithubIntegration };
|
|
1265
|
+
|
|
1266
|
+
//# sourceMappingURL=integration.js.map
|