@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,1362 @@
|
|
|
1
|
+
import { AUTO_TRIAGED_LABEL, NEEDS_APPROVAL_LABEL } from "../../rules/types.js";
|
|
2
|
+
import { listRepositoryCommits } from "./commits.js";
|
|
3
|
+
import { clearGithubPat, getGithubPatStatus, setGithubPat } from "./pat.js";
|
|
4
|
+
import { isValidGitRef } from "../../sandbox/git-ref.js";
|
|
5
|
+
import { MaterializeError, SetupCommandError, commitAll, pushBranch } from "./sandbox.js";
|
|
6
|
+
import { requireExec } from "../../sandbox/materialization.js";
|
|
7
|
+
import { sanitizeSegment } from "../../sandbox/workdir.js";
|
|
8
|
+
import { peekSessionSandbox } from "../../sandbox/session-sandbox.js";
|
|
9
|
+
import { listPullRequestSubscriptionsForThread, subscribeToPullRequest } from "./subscriptions.js";
|
|
10
|
+
import { polledPullRequestEvent } from "./rules.js";
|
|
11
|
+
import { waitForPendingFilesystemCapture } from "../../session/filesystem-capture.js";
|
|
12
|
+
import { normalizeSessionTitle } from "../../session/session-title.js";
|
|
13
|
+
import { getGithubFeatureDiagnostics, isGithubFeatureEnabled } from "./config.js";
|
|
14
|
+
import { reclaimDeletedSessionSandbox } from "./sandbox-release.js";
|
|
15
|
+
import { handleGithubWebhook } from "./webhook.js";
|
|
16
|
+
import { RequestContext } from "@mastra/core/request-context";
|
|
17
|
+
import { registerApiRoute } from "@mastra/core/server";
|
|
18
|
+
import { UniqueViolationError } from "@mastra/core/storage";
|
|
19
|
+
import { resolveModel } from "@mastra/code-sdk/agents/model";
|
|
20
|
+
//#region src/integrations/github/routes.ts
|
|
21
|
+
const sessionOperationLocks = /* @__PURE__ */ new Map();
|
|
22
|
+
const USER_SESSION_BRANCH_PREFIX = "user/session-";
|
|
23
|
+
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
24
|
+
/**
|
|
25
|
+
* Serialize same-session mutations within one Factory process. Factory sessions
|
|
26
|
+
* normally issue these operations sequentially, so this lock is probably not
|
|
27
|
+
* necessary; keep the cheap local guard until that invariant is enforced by
|
|
28
|
+
* the request protocol. It intentionally does not consume a database connection.
|
|
29
|
+
*/
|
|
30
|
+
function withSessionOperationLock(sessionId, fn) {
|
|
31
|
+
const next = (sessionOperationLocks.get(sessionId) ?? Promise.resolve()).then(fn, fn);
|
|
32
|
+
const tail = next.then(() => void 0, () => void 0);
|
|
33
|
+
sessionOperationLocks.set(sessionId, tail);
|
|
34
|
+
tail.then(() => {
|
|
35
|
+
if (sessionOperationLocks.get(sessionId) === tail) sessionOperationLocks.delete(sessionId);
|
|
36
|
+
});
|
|
37
|
+
return next;
|
|
38
|
+
}
|
|
39
|
+
/** Erase a route handler's path-parameterized context to a plain `Context`. */
|
|
40
|
+
function loose(c) {
|
|
41
|
+
return c;
|
|
42
|
+
}
|
|
43
|
+
function pullRequestNumberFromUrl(value, expectedRepo) {
|
|
44
|
+
try {
|
|
45
|
+
const url = new URL(value);
|
|
46
|
+
const match = url.pathname.match(/^\/([^/]+\/[^/]+)\/pull\/(\d+)\/?$/);
|
|
47
|
+
if (url.protocol !== "https:" || url.hostname !== "github.com" || match?.[1]?.toLowerCase() !== expectedRepo.toLowerCase()) return;
|
|
48
|
+
const number = Number(match[2]);
|
|
49
|
+
return Number.isInteger(number) && number > 0 ? number : void 0;
|
|
50
|
+
} catch {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function isJsonObject(value) {
|
|
55
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Resolve the org-scoped tenant for a GitHub request. GitHub project features
|
|
59
|
+
* are org-owned, so they require both a signed-in user and a WorkOS
|
|
60
|
+
* organization. Returns the `(orgId, userId)` tenant (with `orgId` narrowed to a
|
|
61
|
+
* non-null string) or a ready-to-return error response: 401 when unauthenticated,
|
|
62
|
+
* 403 when the user has no organization (personal account).
|
|
63
|
+
*
|
|
64
|
+
* Resolves the session from the request cookie itself (via `auth.ensureUser`)
|
|
65
|
+
* instead of relying on the auth gate's context stash: on platform deploys
|
|
66
|
+
* custom `apiRoutes` run on an isolated sub-app context where the gate's
|
|
67
|
+
* `c.set(...)` is invisible. When the gate stash IS visible (local Hono
|
|
68
|
+
* server), `auth.ensureUser` returns the cached user and this is a no-op.
|
|
69
|
+
*/
|
|
70
|
+
async function resolveOrgTenant(c, auth) {
|
|
71
|
+
await auth.ensureUser(c);
|
|
72
|
+
const tenant = auth.tenant(c);
|
|
73
|
+
if (!tenant) return { response: c.json({ error: "unauthorized" }, 401) };
|
|
74
|
+
if (!tenant.orgId) return { response: c.json({
|
|
75
|
+
error: "organization_required",
|
|
76
|
+
message: "GitHub projects require a WorkOS organization. Personal accounts cannot connect repositories."
|
|
77
|
+
}, 403) };
|
|
78
|
+
return { tenant: {
|
|
79
|
+
orgId: tenant.orgId,
|
|
80
|
+
userId: tenant.userId
|
|
81
|
+
} };
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Parse a 1-based `page` query param. Missing means page 1; anything that is
|
|
85
|
+
* not a small positive integer is rejected (`null`).
|
|
86
|
+
*/
|
|
87
|
+
function parseListPage(raw) {
|
|
88
|
+
if (raw === void 0) return 1;
|
|
89
|
+
if (!/^\d{1,5}$/.test(raw)) return null;
|
|
90
|
+
const page = Number(raw);
|
|
91
|
+
return page >= 1 ? page : null;
|
|
92
|
+
}
|
|
93
|
+
function parseResourceNumber(raw) {
|
|
94
|
+
if (raw === void 0 || !/^\d{1,10}$/.test(raw)) return null;
|
|
95
|
+
const parsed = Number(raw);
|
|
96
|
+
return parsed > 0 ? parsed : null;
|
|
97
|
+
}
|
|
98
|
+
const VALID_ISSUE_LABEL_FILTERS = /* @__PURE__ */ new Set([AUTO_TRIAGED_LABEL, NEEDS_APPROVAL_LABEL]);
|
|
99
|
+
function parseIssueLabelFilter(raw) {
|
|
100
|
+
if (raw === void 0 || raw === "") return void 0;
|
|
101
|
+
if (VALID_ISSUE_LABEL_FILTERS.has(raw)) return raw;
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
async function resolveProjectRepository(args) {
|
|
105
|
+
const projectRepository = await args.github.sourceControlStorage.projectRepositories.get({
|
|
106
|
+
orgId: args.orgId,
|
|
107
|
+
id: args.projectRepositoryId
|
|
108
|
+
});
|
|
109
|
+
if (!projectRepository) return null;
|
|
110
|
+
const connection = await args.github.sourceControlStorage.connections.get({
|
|
111
|
+
orgId: args.orgId,
|
|
112
|
+
id: projectRepository.connectionId
|
|
113
|
+
});
|
|
114
|
+
if (!connection) return null;
|
|
115
|
+
const repository = await args.github.sourceControlStorage.repositories.get({
|
|
116
|
+
orgId: args.orgId,
|
|
117
|
+
id: projectRepository.repositoryId
|
|
118
|
+
});
|
|
119
|
+
if (!repository) return null;
|
|
120
|
+
const installation = await args.github.sourceControlStorage.installations.get({
|
|
121
|
+
orgId: args.orgId,
|
|
122
|
+
id: connection.installationId
|
|
123
|
+
});
|
|
124
|
+
if (!installation) return null;
|
|
125
|
+
return {
|
|
126
|
+
...projectRepository,
|
|
127
|
+
connection,
|
|
128
|
+
installation,
|
|
129
|
+
repository,
|
|
130
|
+
factoryProjectId: connection.factoryProjectId,
|
|
131
|
+
defaultBranch: projectRepository.branch ?? repository.defaultBranch
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function polledIssueEvent(project, issue) {
|
|
135
|
+
const repositoryId = Number(project.repository.externalId);
|
|
136
|
+
const assigneeLogins = issue.assignees ?? (issue.assignee ? [issue.assignee] : []);
|
|
137
|
+
return {
|
|
138
|
+
event: "issues",
|
|
139
|
+
deliveryId: `poll:${repositoryId}:issue:${issue.number}:${issue.createdAt}`,
|
|
140
|
+
payload: {
|
|
141
|
+
action: "opened",
|
|
142
|
+
installation: { id: Number(project.installation.externalId) },
|
|
143
|
+
repository: {
|
|
144
|
+
id: repositoryId,
|
|
145
|
+
full_name: project.repository.slug
|
|
146
|
+
},
|
|
147
|
+
sender: { login: issue.author ?? "__unknown__" },
|
|
148
|
+
issue: {
|
|
149
|
+
number: issue.number,
|
|
150
|
+
title: issue.title,
|
|
151
|
+
html_url: issue.url,
|
|
152
|
+
created_at: issue.createdAt,
|
|
153
|
+
assignees: assigneeLogins.map((login) => ({ login })),
|
|
154
|
+
labels: issue.labels.map((name) => ({ name }))
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function listedPullRequestEvent(project, pullRequest) {
|
|
160
|
+
return polledPullRequestEvent(reconcileRepositoryOf(project), pullRequest.number, listedOpenPullRequestState(pullRequest));
|
|
161
|
+
}
|
|
162
|
+
function reconcileRepositoryOf(project) {
|
|
163
|
+
return {
|
|
164
|
+
id: Number(project.repository.externalId),
|
|
165
|
+
fullName: project.repository.slug,
|
|
166
|
+
installationId: Number(project.installation.externalId)
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function listedOpenPullRequestState(pullRequest) {
|
|
170
|
+
return {
|
|
171
|
+
title: pullRequest.title,
|
|
172
|
+
url: pullRequest.url,
|
|
173
|
+
state: "open",
|
|
174
|
+
draft: false,
|
|
175
|
+
merged: false,
|
|
176
|
+
assignees: pullRequest.assignees,
|
|
177
|
+
requestedReviewers: pullRequest.requestedReviewers,
|
|
178
|
+
labels: pullRequest.labels,
|
|
179
|
+
headBranch: pullRequest.headBranch,
|
|
180
|
+
baseBranch: pullRequest.baseBranch,
|
|
181
|
+
author: pullRequest.author ?? void 0,
|
|
182
|
+
createdAt: pullRequest.createdAt
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
async function ingestPolledEvents(events, ingestFactoryEvent) {
|
|
186
|
+
if (!ingestFactoryEvent) return;
|
|
187
|
+
const rejected = (await Promise.allSettled(events.map((event) => ingestFactoryEvent(event)))).find((result) => result.status === "rejected");
|
|
188
|
+
if (rejected) console.warn("[Mastra Factory] Failed to ingest polled GitHub events", { error: rejected.reason });
|
|
189
|
+
}
|
|
190
|
+
const LINKED_BACKLOG_MAX_PAGES = 5;
|
|
191
|
+
function listedIssueOf(issue) {
|
|
192
|
+
return {
|
|
193
|
+
number: Number(issue.id),
|
|
194
|
+
title: issue.title,
|
|
195
|
+
url: issue.url,
|
|
196
|
+
author: issue.author,
|
|
197
|
+
assignee: issue.assignee,
|
|
198
|
+
assignees: issue.assignees,
|
|
199
|
+
labels: issue.labels,
|
|
200
|
+
createdAt: issue.createdAt
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function listedPullRequestOf(pr) {
|
|
204
|
+
return {
|
|
205
|
+
number: Number(pr.id),
|
|
206
|
+
title: pr.title,
|
|
207
|
+
url: pr.url,
|
|
208
|
+
author: pr.author,
|
|
209
|
+
assignees: pr.assignees ?? [],
|
|
210
|
+
requestedReviewers: pr.requestedReviewers ?? [],
|
|
211
|
+
labels: pr.labels ?? [],
|
|
212
|
+
headBranch: pr.headBranch,
|
|
213
|
+
baseBranch: pr.baseBranch,
|
|
214
|
+
createdAt: pr.createdAt
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Feed a just-linked repository's open issues and pull requests through the
|
|
219
|
+
* same rules ingress the list routes use, so its backlog reaches the board
|
|
220
|
+
* without anyone browsing it. Rows owned by another integration don't resolve
|
|
221
|
+
* through this integration's storage handle and are skipped.
|
|
222
|
+
*/
|
|
223
|
+
async function ingestLinkedRepositoryBacklog(args) {
|
|
224
|
+
if (!args.ingestFactoryEvent) return;
|
|
225
|
+
const project = await resolveProjectRepository(args);
|
|
226
|
+
if (!project) return;
|
|
227
|
+
const connection = {
|
|
228
|
+
type: "app-installation",
|
|
229
|
+
installationId: Number(project.installation.externalId)
|
|
230
|
+
};
|
|
231
|
+
const sourceId = project.repository.slug;
|
|
232
|
+
for (let page = 1; page <= LINKED_BACKLOG_MAX_PAGES; page += 1) {
|
|
233
|
+
const { issues, nextCursor } = await args.github.intake.listIssues({
|
|
234
|
+
connection,
|
|
235
|
+
sourceIds: [sourceId],
|
|
236
|
+
cursor: String(page)
|
|
237
|
+
});
|
|
238
|
+
await ingestPolledEvents(issues.map((issue) => polledIssueEvent(project, listedIssueOf(issue))), args.ingestFactoryEvent);
|
|
239
|
+
if (nextCursor === null) break;
|
|
240
|
+
}
|
|
241
|
+
for (let page = 1; page <= LINKED_BACKLOG_MAX_PAGES; page += 1) {
|
|
242
|
+
const { pullRequests, nextCursor } = await args.github.versionControl.listPullRequests({
|
|
243
|
+
connection,
|
|
244
|
+
sourceId,
|
|
245
|
+
includeDrafts: false,
|
|
246
|
+
cursor: String(page)
|
|
247
|
+
});
|
|
248
|
+
await ingestPolledEvents(pullRequests.map((pr) => listedPullRequestEvent(project, listedPullRequestOf(pr))), args.ingestFactoryEvent);
|
|
249
|
+
if (nextCursor === null) break;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Build the GitHub routes as Mastra `apiRoutes`. When the feature is disabled,
|
|
254
|
+
* returns only the `status` route so the SPA can detect the disabled state.
|
|
255
|
+
*/
|
|
256
|
+
function buildGithubRoutes(options) {
|
|
257
|
+
const routes = [];
|
|
258
|
+
const { auth, sandbox, users, storage, github, stateSigner, controller, memorySettings, emitAudit, sessionRetirement, workItems } = options;
|
|
259
|
+
const diagnostics = () => getGithubFeatureDiagnostics({
|
|
260
|
+
github,
|
|
261
|
+
auth,
|
|
262
|
+
appDbConfigured: storage !== void 0,
|
|
263
|
+
stateSigner,
|
|
264
|
+
sandbox
|
|
265
|
+
});
|
|
266
|
+
routes.push(registerApiRoute("/web/github/status", {
|
|
267
|
+
method: "GET",
|
|
268
|
+
requiresAuth: false,
|
|
269
|
+
handler: async (c) => {
|
|
270
|
+
if (!isGithubFeatureEnabled({
|
|
271
|
+
github,
|
|
272
|
+
auth
|
|
273
|
+
}) || !github || !stateSigner) return c.json({
|
|
274
|
+
enabled: false,
|
|
275
|
+
connected: false,
|
|
276
|
+
installations: [],
|
|
277
|
+
reason: "missing_config",
|
|
278
|
+
diagnostics: diagnostics()
|
|
279
|
+
});
|
|
280
|
+
await auth.ensureUser(loose(c));
|
|
281
|
+
const tenant = auth.tenant(loose(c));
|
|
282
|
+
if (!tenant) return c.json({
|
|
283
|
+
error: "unauthorized",
|
|
284
|
+
reason: "auth_required"
|
|
285
|
+
}, 401);
|
|
286
|
+
if (!tenant.orgId) return c.json({
|
|
287
|
+
enabled: true,
|
|
288
|
+
sandboxEnabled: !!sandbox,
|
|
289
|
+
organizationRequired: true,
|
|
290
|
+
connected: false,
|
|
291
|
+
installations: [],
|
|
292
|
+
reason: "organization_required",
|
|
293
|
+
diagnostics: diagnostics()
|
|
294
|
+
});
|
|
295
|
+
const rows = options.github ? await options.github.sourceControlStorage.installations.list({ orgId: tenant.orgId }) : [];
|
|
296
|
+
const connected = rows.length > 0;
|
|
297
|
+
return c.json({
|
|
298
|
+
enabled: true,
|
|
299
|
+
sandboxEnabled: !!sandbox,
|
|
300
|
+
connected,
|
|
301
|
+
installations: rows.map((r) => ({
|
|
302
|
+
installationId: Number(r.externalId),
|
|
303
|
+
accountLogin: r.accountName,
|
|
304
|
+
accountType: r.accountType
|
|
305
|
+
})),
|
|
306
|
+
reason: connected ? "ready" : "not_connected",
|
|
307
|
+
diagnostics: diagnostics()
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
}));
|
|
311
|
+
if (!isGithubFeatureEnabled({
|
|
312
|
+
github,
|
|
313
|
+
auth
|
|
314
|
+
}) || !github || !stateSigner) return routes;
|
|
315
|
+
const signState = (orgId, userId) => stateSigner.sign(orgId, userId);
|
|
316
|
+
const verifyState = (state) => stateSigner.verify(state);
|
|
317
|
+
routes.push(registerApiRoute("/web/github/subscriptions", {
|
|
318
|
+
method: "GET",
|
|
319
|
+
handler: async (c) => {
|
|
320
|
+
await auth.ensureUser(loose(c));
|
|
321
|
+
const tenant = auth.tenant(loose(c));
|
|
322
|
+
if (!tenant?.orgId) return c.json({ error: "unauthorized" }, 401);
|
|
323
|
+
const resourceId = c.req.query("resourceId");
|
|
324
|
+
const threadId = c.req.query("threadId");
|
|
325
|
+
const sessionScope = c.req.query("scope");
|
|
326
|
+
if (!resourceId || !threadId) return c.json({ error: "resourceId and threadId are required" }, 400);
|
|
327
|
+
const subscriptions = await listPullRequestSubscriptionsForThread({
|
|
328
|
+
orgId: tenant.orgId,
|
|
329
|
+
resourceId,
|
|
330
|
+
threadId,
|
|
331
|
+
sessionScope
|
|
332
|
+
}, github.integrationStorage);
|
|
333
|
+
return c.json({ subscriptions: subscriptions.map((subscription) => ({
|
|
334
|
+
id: subscription.id,
|
|
335
|
+
repoFullName: subscription.data.repositorySlug,
|
|
336
|
+
pullRequestNumber: Number(subscription.data.changeRequestId),
|
|
337
|
+
status: subscription.status,
|
|
338
|
+
url: `https://github.com/${subscription.data.repositorySlug}/pull/${subscription.data.changeRequestId}`
|
|
339
|
+
})) });
|
|
340
|
+
}
|
|
341
|
+
}), registerApiRoute("/web/github/webhook", {
|
|
342
|
+
method: "POST",
|
|
343
|
+
requiresAuth: false,
|
|
344
|
+
handler: async (c) => {
|
|
345
|
+
const result = await handleGithubWebhook(loose(c), {
|
|
346
|
+
github,
|
|
347
|
+
ingestFactoryEvent: options.ingestFactoryEvent,
|
|
348
|
+
...options.controller ? {
|
|
349
|
+
controller: options.controller,
|
|
350
|
+
onTargetError: (subscription, error) => {
|
|
351
|
+
console.warn(`[GitHub Webhook] Delivery failed for subscription ${subscription.id} (${subscription.resourceId}/${subscription.threadId}).`, error);
|
|
352
|
+
}
|
|
353
|
+
} : {}
|
|
354
|
+
});
|
|
355
|
+
return c.json(result.body, result.status);
|
|
356
|
+
}
|
|
357
|
+
}));
|
|
358
|
+
const redirectUri = options.redirectUri ?? `${(options.baseUrl ?? "").replace(/\/$/, "")}/auth/github/callback`;
|
|
359
|
+
routes.push(registerApiRoute("/auth/github/connect", {
|
|
360
|
+
method: "GET",
|
|
361
|
+
requiresAuth: false,
|
|
362
|
+
handler: async (c) => {
|
|
363
|
+
const resolved = await resolveOrgTenant(loose(c), auth);
|
|
364
|
+
if ("response" in resolved) return resolved.response;
|
|
365
|
+
const state = signState(resolved.tenant.orgId, resolved.tenant.userId);
|
|
366
|
+
if (c.req.query("manage")) return c.redirect(github.buildInstallUrl(state));
|
|
367
|
+
return c.redirect(github.buildOAuthIdentifyUrl(state, redirectUri));
|
|
368
|
+
}
|
|
369
|
+
}));
|
|
370
|
+
routes.push(registerApiRoute("/auth/github/callback", {
|
|
371
|
+
method: "GET",
|
|
372
|
+
requiresAuth: false,
|
|
373
|
+
handler: async (c) => {
|
|
374
|
+
const resolved = await resolveOrgTenant(loose(c), auth);
|
|
375
|
+
if ("response" in resolved) return resolved.response;
|
|
376
|
+
const { orgId, userId } = resolved.tenant;
|
|
377
|
+
const state = c.req.query("state");
|
|
378
|
+
if (!state) return c.redirect(github.buildOAuthIdentifyUrl(signState(orgId, userId), redirectUri));
|
|
379
|
+
const stateTenant = verifyState(state);
|
|
380
|
+
if (!stateTenant || stateTenant.userId !== userId || stateTenant.orgId !== orgId) {
|
|
381
|
+
console.warn("[GitHub] Install callback rejected: state/tenant mismatch.", JSON.stringify({
|
|
382
|
+
stateValid: Boolean(stateTenant),
|
|
383
|
+
stateOrgId: stateTenant?.orgId,
|
|
384
|
+
stateUserId: stateTenant?.userId,
|
|
385
|
+
sessionOrgId: orgId,
|
|
386
|
+
sessionUserId: userId
|
|
387
|
+
}));
|
|
388
|
+
return c.redirect("/?github=error");
|
|
389
|
+
}
|
|
390
|
+
const code = c.req.query("code");
|
|
391
|
+
if (!code) return c.redirect(github.buildOAuthIdentifyUrl(signState(orgId, userId), redirectUri));
|
|
392
|
+
try {
|
|
393
|
+
const userToken = await github.exchangeOAuthCode(code, redirectUri);
|
|
394
|
+
const installations = await github.listUserInstallations(userToken);
|
|
395
|
+
if (installations.length === 0) return c.redirect(github.buildInstallUrl(signState(orgId, userId)));
|
|
396
|
+
for (const inst of installations) await github.sourceControlStorage.installations.upsert({
|
|
397
|
+
orgId,
|
|
398
|
+
connectedByUserId: userId,
|
|
399
|
+
externalId: inst.installationId.toString(),
|
|
400
|
+
accountName: inst.accountLogin,
|
|
401
|
+
accountType: inst.accountType
|
|
402
|
+
});
|
|
403
|
+
} catch (error) {
|
|
404
|
+
console.warn(`[GitHub] Install callback failed to persist installations for org ${orgId} / user ${userId}.`, error);
|
|
405
|
+
return c.redirect("/?github=error");
|
|
406
|
+
}
|
|
407
|
+
return c.redirect("/?github=connected");
|
|
408
|
+
}
|
|
409
|
+
}));
|
|
410
|
+
routes.push(registerApiRoute("/web/github/repos", {
|
|
411
|
+
method: "GET",
|
|
412
|
+
requiresAuth: false,
|
|
413
|
+
handler: async (c) => {
|
|
414
|
+
const resolved = await resolveOrgTenant(loose(c), auth);
|
|
415
|
+
if ("response" in resolved) return resolved.response;
|
|
416
|
+
const orgId = resolved.tenant.orgId;
|
|
417
|
+
const installs = await github.sourceControlStorage.installations.list({ orgId });
|
|
418
|
+
const query = (c.req.query("q") ?? "").toLowerCase();
|
|
419
|
+
const fresh = c.req.query("refresh") === "1";
|
|
420
|
+
const listed = await Promise.all(installs.map(async (inst) => {
|
|
421
|
+
try {
|
|
422
|
+
return {
|
|
423
|
+
inst,
|
|
424
|
+
list: await github.listInstallationRepos(Number(inst.externalId), { fresh })
|
|
425
|
+
};
|
|
426
|
+
} catch (err) {
|
|
427
|
+
if (err.status === 403) {
|
|
428
|
+
console.warn(`[Mastra Factory] skipping GitHub installation ${inst.externalId} (${inst.accountName}): ${err.message}`);
|
|
429
|
+
return {
|
|
430
|
+
inst,
|
|
431
|
+
list: []
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
if (err.status !== 404) throw err;
|
|
435
|
+
console.error(`[Mastra Factory] pruning stale GitHub installation ${inst.externalId} (404 from GitHub)`);
|
|
436
|
+
await github.sourceControlStorage.installations.delete({
|
|
437
|
+
orgId,
|
|
438
|
+
id: inst.id
|
|
439
|
+
});
|
|
440
|
+
return {
|
|
441
|
+
inst,
|
|
442
|
+
list: []
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
}));
|
|
446
|
+
const matches = [];
|
|
447
|
+
const seenRepositoryIds = /* @__PURE__ */ new Set();
|
|
448
|
+
for (const { inst, list } of listed) for (const repo of list) {
|
|
449
|
+
if (query && !repo.fullName.toLowerCase().includes(query)) continue;
|
|
450
|
+
if (seenRepositoryIds.has(repo.id)) continue;
|
|
451
|
+
seenRepositoryIds.add(repo.id);
|
|
452
|
+
matches.push({
|
|
453
|
+
inst,
|
|
454
|
+
repo
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
const repos = matches.map(({ inst, repo }) => ({
|
|
458
|
+
...repo,
|
|
459
|
+
installationStorageId: inst.id,
|
|
460
|
+
sandboxProvider: sandbox ? "custom" : "none",
|
|
461
|
+
sandboxWorkdir: `~/${sanitizeSegment(repo.fullName.split("/", 2)[1] || "repo")}`
|
|
462
|
+
}));
|
|
463
|
+
return c.json({ repos });
|
|
464
|
+
}
|
|
465
|
+
}));
|
|
466
|
+
routes.push(registerApiRoute("/web/github/projects/:id/issues", {
|
|
467
|
+
method: "GET",
|
|
468
|
+
requiresAuth: false,
|
|
469
|
+
handler: async (c) => {
|
|
470
|
+
const loaded = await loadOrgProject({
|
|
471
|
+
github,
|
|
472
|
+
auth,
|
|
473
|
+
c: loose(c)
|
|
474
|
+
});
|
|
475
|
+
if ("response" in loaded) return loaded.response;
|
|
476
|
+
const page = parseListPage(c.req.query("page"));
|
|
477
|
+
if (page === null) return c.json({ error: "invalid_page" }, 400);
|
|
478
|
+
const label = parseIssueLabelFilter(c.req.query("label"));
|
|
479
|
+
if (label === null) return c.json({ error: "invalid_label" }, 400);
|
|
480
|
+
try {
|
|
481
|
+
const { issues, nextCursor } = await github.intake.listIssues({
|
|
482
|
+
connection: {
|
|
483
|
+
type: "app-installation",
|
|
484
|
+
installationId: Number(loaded.project.installation.externalId)
|
|
485
|
+
},
|
|
486
|
+
sourceIds: [loaded.project.repository.slug],
|
|
487
|
+
labels: label ? [label] : void 0,
|
|
488
|
+
cursor: String(page)
|
|
489
|
+
});
|
|
490
|
+
const responseIssues = issues.map((issue) => ({
|
|
491
|
+
repositoryId: Number(loaded.project.repository.externalId),
|
|
492
|
+
number: Number(issue.id),
|
|
493
|
+
title: issue.title,
|
|
494
|
+
url: issue.url,
|
|
495
|
+
author: issue.author,
|
|
496
|
+
assignee: issue.assignee,
|
|
497
|
+
assignees: issue.assignees,
|
|
498
|
+
labels: issue.labels,
|
|
499
|
+
comments: issue.commentCount ?? 0,
|
|
500
|
+
createdAt: issue.createdAt,
|
|
501
|
+
updatedAt: issue.updatedAt
|
|
502
|
+
}));
|
|
503
|
+
await ingestPolledEvents(responseIssues.map((issue) => polledIssueEvent(loaded.project, issue)), options.ingestFactoryEvent);
|
|
504
|
+
return c.json({
|
|
505
|
+
issues: responseIssues,
|
|
506
|
+
nextPage: nextCursor === null ? null : Number(nextCursor)
|
|
507
|
+
});
|
|
508
|
+
} catch (err) {
|
|
509
|
+
return c.json({
|
|
510
|
+
error: "github_fetch_failed",
|
|
511
|
+
message: err instanceof Error ? err.message : String(err)
|
|
512
|
+
}, 502);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}));
|
|
516
|
+
routes.push(registerApiRoute("/web/github/projects/:id/issues/:number", {
|
|
517
|
+
method: "GET",
|
|
518
|
+
requiresAuth: false,
|
|
519
|
+
handler: async (c) => {
|
|
520
|
+
const loaded = await loadOrgProject({
|
|
521
|
+
github,
|
|
522
|
+
auth,
|
|
523
|
+
c: loose(c)
|
|
524
|
+
});
|
|
525
|
+
if ("response" in loaded) return loaded.response;
|
|
526
|
+
const number = parseResourceNumber(c.req.param("number"));
|
|
527
|
+
if (number === null) return c.json({ error: "invalid_number" }, 400);
|
|
528
|
+
try {
|
|
529
|
+
const detail = await github.intake.getIssue({
|
|
530
|
+
connection: {
|
|
531
|
+
type: "app-installation",
|
|
532
|
+
installationId: Number(loaded.project.installation.externalId)
|
|
533
|
+
},
|
|
534
|
+
sourceId: loaded.project.repository.slug,
|
|
535
|
+
issueId: String(number)
|
|
536
|
+
});
|
|
537
|
+
if (detail === null) return c.json({ error: "issue_not_found" }, 404);
|
|
538
|
+
return c.json({
|
|
539
|
+
number: Number(detail.id),
|
|
540
|
+
title: detail.title,
|
|
541
|
+
url: detail.url,
|
|
542
|
+
author: detail.author,
|
|
543
|
+
assignee: detail.assignee,
|
|
544
|
+
labels: detail.labels,
|
|
545
|
+
comments: detail.commentCount ?? 0,
|
|
546
|
+
createdAt: detail.createdAt,
|
|
547
|
+
updatedAt: detail.updatedAt,
|
|
548
|
+
description: detail.description
|
|
549
|
+
});
|
|
550
|
+
} catch (err) {
|
|
551
|
+
return c.json({
|
|
552
|
+
error: "github_fetch_failed",
|
|
553
|
+
message: err instanceof Error ? err.message : String(err)
|
|
554
|
+
}, 502);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}));
|
|
558
|
+
routes.push(registerApiRoute("/web/github/projects/:id/prs", {
|
|
559
|
+
method: "GET",
|
|
560
|
+
requiresAuth: false,
|
|
561
|
+
handler: async (c) => {
|
|
562
|
+
const loaded = await loadOrgProject({
|
|
563
|
+
github,
|
|
564
|
+
auth,
|
|
565
|
+
c: loose(c)
|
|
566
|
+
});
|
|
567
|
+
if ("response" in loaded) return loaded.response;
|
|
568
|
+
const page = parseListPage(c.req.query("page"));
|
|
569
|
+
if (page === null) return c.json({ error: "invalid_page" }, 400);
|
|
570
|
+
try {
|
|
571
|
+
const { pullRequests, nextCursor } = await github.versionControl.listPullRequests({
|
|
572
|
+
connection: {
|
|
573
|
+
type: "app-installation",
|
|
574
|
+
installationId: Number(loaded.project.installation.externalId)
|
|
575
|
+
},
|
|
576
|
+
sourceId: loaded.project.repository.slug,
|
|
577
|
+
includeDrafts: false,
|
|
578
|
+
cursor: String(page)
|
|
579
|
+
});
|
|
580
|
+
const responsePullRequests = pullRequests.map((pr) => ({
|
|
581
|
+
repositoryId: Number(loaded.project.repository.externalId),
|
|
582
|
+
number: Number(pr.id),
|
|
583
|
+
title: pr.title,
|
|
584
|
+
url: pr.url,
|
|
585
|
+
author: pr.author,
|
|
586
|
+
assignees: pr.assignees ?? [],
|
|
587
|
+
requestedReviewers: pr.requestedReviewers ?? [],
|
|
588
|
+
labels: pr.labels ?? [],
|
|
589
|
+
baseBranch: pr.baseBranch,
|
|
590
|
+
headBranch: pr.headBranch,
|
|
591
|
+
createdAt: pr.createdAt,
|
|
592
|
+
updatedAt: pr.updatedAt
|
|
593
|
+
}));
|
|
594
|
+
await ingestPolledEvents(responsePullRequests.map((pullRequest) => listedPullRequestEvent(loaded.project, pullRequest)), options.ingestFactoryEvent);
|
|
595
|
+
return c.json({
|
|
596
|
+
pullRequests: responsePullRequests,
|
|
597
|
+
nextPage: nextCursor === null ? null : Number(nextCursor)
|
|
598
|
+
});
|
|
599
|
+
} catch (err) {
|
|
600
|
+
return c.json({
|
|
601
|
+
error: "github_fetch_failed",
|
|
602
|
+
message: err instanceof Error ? err.message : String(err)
|
|
603
|
+
}, 502);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
}));
|
|
607
|
+
routes.push(registerApiRoute("/web/github/projects/:id/prs/:number", {
|
|
608
|
+
method: "GET",
|
|
609
|
+
requiresAuth: false,
|
|
610
|
+
handler: async (c) => {
|
|
611
|
+
const loaded = await loadOrgProject({
|
|
612
|
+
github,
|
|
613
|
+
auth,
|
|
614
|
+
c: loose(c)
|
|
615
|
+
});
|
|
616
|
+
if ("response" in loaded) return loaded.response;
|
|
617
|
+
const number = parseResourceNumber(c.req.param("number"));
|
|
618
|
+
if (number === null) return c.json({ error: "invalid_number" }, 400);
|
|
619
|
+
try {
|
|
620
|
+
const pr = await github.versionControl.getPullRequest({
|
|
621
|
+
connection: {
|
|
622
|
+
type: "app-installation",
|
|
623
|
+
installationId: Number(loaded.project.installation.externalId)
|
|
624
|
+
},
|
|
625
|
+
sourceId: loaded.project.repository.slug,
|
|
626
|
+
pullRequestId: String(number)
|
|
627
|
+
});
|
|
628
|
+
if (pr === null) return c.json({ error: "pull_request_not_found" }, 404);
|
|
629
|
+
return c.json({
|
|
630
|
+
number: Number(pr.id),
|
|
631
|
+
title: pr.title,
|
|
632
|
+
url: pr.url,
|
|
633
|
+
author: pr.author,
|
|
634
|
+
assignees: pr.assignees ?? [],
|
|
635
|
+
requestedReviewers: pr.requestedReviewers ?? [],
|
|
636
|
+
baseBranch: pr.baseBranch,
|
|
637
|
+
headBranch: pr.headBranch,
|
|
638
|
+
createdAt: pr.createdAt,
|
|
639
|
+
updatedAt: pr.updatedAt,
|
|
640
|
+
description: pr.body
|
|
641
|
+
});
|
|
642
|
+
} catch (err) {
|
|
643
|
+
return c.json({
|
|
644
|
+
error: "github_fetch_failed",
|
|
645
|
+
message: err instanceof Error ? err.message : String(err)
|
|
646
|
+
}, 502);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
}));
|
|
650
|
+
routes.push(registerApiRoute("/web/github/projects/:id/settings", {
|
|
651
|
+
method: "GET",
|
|
652
|
+
requiresAuth: false,
|
|
653
|
+
handler: async (c) => {
|
|
654
|
+
const loaded = await loadOrgProject({
|
|
655
|
+
github,
|
|
656
|
+
auth,
|
|
657
|
+
c: loose(c)
|
|
658
|
+
});
|
|
659
|
+
if ("response" in loaded) return loaded.response;
|
|
660
|
+
return c.json({
|
|
661
|
+
setupCommand: loaded.project.setupCommand,
|
|
662
|
+
teardownCommand: loaded.project.teardownCommand
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
}));
|
|
666
|
+
routes.push(registerApiRoute("/web/github/projects/:id/settings", {
|
|
667
|
+
method: "POST",
|
|
668
|
+
requiresAuth: false,
|
|
669
|
+
handler: async (c) => {
|
|
670
|
+
const loaded = await loadOrgProject({
|
|
671
|
+
github,
|
|
672
|
+
auth,
|
|
673
|
+
c: loose(c)
|
|
674
|
+
});
|
|
675
|
+
if ("response" in loaded) return loaded.response;
|
|
676
|
+
let body;
|
|
677
|
+
try {
|
|
678
|
+
body = await c.req.json();
|
|
679
|
+
} catch {
|
|
680
|
+
return c.json({ error: "Invalid JSON body" }, 400);
|
|
681
|
+
}
|
|
682
|
+
for (const command of ["setupCommand", "teardownCommand"]) {
|
|
683
|
+
const value = body[command];
|
|
684
|
+
if (value === void 0) continue;
|
|
685
|
+
if (value !== null && typeof value !== "string") return c.json({ error: `Invalid ${command}` }, 400);
|
|
686
|
+
if (typeof value === "string" && value.length > 2e3) return c.json({ error: `${command} too long (max 2000 characters)` }, 400);
|
|
687
|
+
if (typeof value === "string" && /[\0-\x08\x0b\x0c\x0e-\x1f\x7f]/.test(value)) return c.json({ error: `${command} contains control characters` }, 400);
|
|
688
|
+
}
|
|
689
|
+
const normalizeCommand = (value) => {
|
|
690
|
+
if (value === void 0) return void 0;
|
|
691
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
|
|
692
|
+
};
|
|
693
|
+
const setupCommand = normalizeCommand(body.setupCommand);
|
|
694
|
+
const teardownCommand = normalizeCommand(body.teardownCommand);
|
|
695
|
+
await github.sourceControlStorage.projectRepositories.update({
|
|
696
|
+
orgId: loaded.project.installation.orgId,
|
|
697
|
+
id: loaded.project.id,
|
|
698
|
+
input: {
|
|
699
|
+
...setupCommand !== void 0 ? { setupCommand } : {},
|
|
700
|
+
...teardownCommand !== void 0 ? { teardownCommand } : {}
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
return c.json({
|
|
704
|
+
setupCommand: setupCommand === void 0 ? loaded.project.setupCommand : setupCommand,
|
|
705
|
+
teardownCommand: teardownCommand === void 0 ? loaded.project.teardownCommand : teardownCommand
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
}));
|
|
709
|
+
const parsePatKind = (value) => {
|
|
710
|
+
if (value === void 0 || value === null || value === "default") return "default";
|
|
711
|
+
if (value === "reviewer") return "reviewer";
|
|
712
|
+
return null;
|
|
713
|
+
};
|
|
714
|
+
routes.push(registerApiRoute("/web/github/pat", {
|
|
715
|
+
method: "GET",
|
|
716
|
+
requiresAuth: false,
|
|
717
|
+
handler: async (c) => {
|
|
718
|
+
const resolved = await resolveOrgTenant(loose(c), auth);
|
|
719
|
+
if ("response" in resolved) return resolved.response;
|
|
720
|
+
return c.json(await getGithubPatStatus(() => github.integrationStorage, resolved.tenant.orgId));
|
|
721
|
+
}
|
|
722
|
+
}), registerApiRoute("/web/github/pat", {
|
|
723
|
+
method: "POST",
|
|
724
|
+
requiresAuth: false,
|
|
725
|
+
handler: async (c) => {
|
|
726
|
+
const resolved = await resolveOrgTenant(loose(c), auth);
|
|
727
|
+
if ("response" in resolved) return resolved.response;
|
|
728
|
+
let body;
|
|
729
|
+
try {
|
|
730
|
+
body = await c.req.json();
|
|
731
|
+
} catch {
|
|
732
|
+
return c.json({ error: "Invalid JSON body" }, 400);
|
|
733
|
+
}
|
|
734
|
+
const kind = parsePatKind(body.kind);
|
|
735
|
+
if (!kind) return c.json({ error: "kind must be 'default' or 'reviewer'" }, 400);
|
|
736
|
+
const token = typeof body.token === "string" ? body.token.trim() : "";
|
|
737
|
+
if (!token) return c.json({ error: "A token is required" }, 400);
|
|
738
|
+
if (token.length > 500) return c.json({ error: "Token too long (max 500 characters)" }, 400);
|
|
739
|
+
if (/\s/.test(token)) return c.json({ error: "Token must not contain whitespace" }, 400);
|
|
740
|
+
await setGithubPat(github.integrationStorage, resolved.tenant.orgId, token, kind);
|
|
741
|
+
return c.json(await getGithubPatStatus(() => github.integrationStorage, resolved.tenant.orgId));
|
|
742
|
+
}
|
|
743
|
+
}), registerApiRoute("/web/github/pat", {
|
|
744
|
+
method: "DELETE",
|
|
745
|
+
requiresAuth: false,
|
|
746
|
+
handler: async (c) => {
|
|
747
|
+
const resolved = await resolveOrgTenant(loose(c), auth);
|
|
748
|
+
if ("response" in resolved) return resolved.response;
|
|
749
|
+
const kind = parsePatKind(c.req.query("kind"));
|
|
750
|
+
if (!kind) return c.json({ error: "kind must be 'default' or 'reviewer'" }, 400);
|
|
751
|
+
await clearGithubPat(github.integrationStorage, resolved.tenant.orgId, kind);
|
|
752
|
+
return c.json(await getGithubPatStatus(() => github.integrationStorage, resolved.tenant.orgId));
|
|
753
|
+
}
|
|
754
|
+
}));
|
|
755
|
+
routes.push(...buildProjectGitRoutes({
|
|
756
|
+
github,
|
|
757
|
+
auth,
|
|
758
|
+
sandbox,
|
|
759
|
+
users,
|
|
760
|
+
controller,
|
|
761
|
+
memorySettings,
|
|
762
|
+
emitAudit,
|
|
763
|
+
sessionRetirement,
|
|
764
|
+
workItems
|
|
765
|
+
}));
|
|
766
|
+
return routes;
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Load the org-owned project for a read-only GitHub API route. Unlike
|
|
770
|
+
* `loadOwnedProject`, this never touches sandbox state — the issues/PR list
|
|
771
|
+
* routes only need the repo + installation, so they work before a sandbox is
|
|
772
|
+
* ever provisioned.
|
|
773
|
+
*/
|
|
774
|
+
async function loadOrgProject(options) {
|
|
775
|
+
const { github, auth, c } = options;
|
|
776
|
+
const resolved = await resolveOrgTenant(c, auth);
|
|
777
|
+
if ("response" in resolved) return { response: resolved.response };
|
|
778
|
+
const { orgId, userId } = resolved.tenant;
|
|
779
|
+
const projectRepositoryId = c.req.param("id");
|
|
780
|
+
if (!projectRepositoryId) return { response: c.json({ error: "Project repository not found" }, 404) };
|
|
781
|
+
const project = await resolveProjectRepository({
|
|
782
|
+
github,
|
|
783
|
+
orgId,
|
|
784
|
+
projectRepositoryId
|
|
785
|
+
});
|
|
786
|
+
if (!project) return { response: c.json({ error: "Project repository not found" }, 404) };
|
|
787
|
+
return {
|
|
788
|
+
project,
|
|
789
|
+
orgId,
|
|
790
|
+
userId
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
/** Derive a commit/author identity from the authenticated host user. */
|
|
794
|
+
function identityFromUser(user) {
|
|
795
|
+
const u = user;
|
|
796
|
+
return {
|
|
797
|
+
name: u?.name ?? null,
|
|
798
|
+
email: u?.email ?? null
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
/** Map a sandbox/setup-command error to an actionable HTTP response. */
|
|
802
|
+
function gitErrorResponse(c, err) {
|
|
803
|
+
if (err instanceof SetupCommandError) return c.json({
|
|
804
|
+
error: err.code,
|
|
805
|
+
message: err.message
|
|
806
|
+
}, 502);
|
|
807
|
+
if (err instanceof MaterializeError) return c.json({
|
|
808
|
+
error: err.code,
|
|
809
|
+
message: err.message
|
|
810
|
+
}, 502);
|
|
811
|
+
return c.json({
|
|
812
|
+
error: "git_failed",
|
|
813
|
+
message: err instanceof Error ? err.message : String(err)
|
|
814
|
+
}, 500);
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Load the org-owned project for a git route. Centralizes the auth +
|
|
818
|
+
* org/ownership checks every git route shares: the project is scoped by
|
|
819
|
+
* `(id, orgId)`. Returns the tenant and project, or a ready-to-return error
|
|
820
|
+
* response.
|
|
821
|
+
*/
|
|
822
|
+
async function loadOwnedProject(options) {
|
|
823
|
+
const { github, auth, sandbox, c } = options;
|
|
824
|
+
const resolved = await resolveOrgTenant(c, auth);
|
|
825
|
+
if ("response" in resolved) return { response: resolved.response };
|
|
826
|
+
const { orgId, userId } = resolved.tenant;
|
|
827
|
+
if (!sandbox) return { response: c.json({
|
|
828
|
+
error: "sandbox_not_configured",
|
|
829
|
+
message: "No sandbox provider is configured."
|
|
830
|
+
}, 503) };
|
|
831
|
+
const projectRepositoryId = c.req.param("id");
|
|
832
|
+
if (!projectRepositoryId) return { response: c.json({ error: "Project repository not found" }, 404) };
|
|
833
|
+
const project = await resolveProjectRepository({
|
|
834
|
+
github,
|
|
835
|
+
orgId,
|
|
836
|
+
projectRepositoryId
|
|
837
|
+
});
|
|
838
|
+
if (!project) return { response: c.json({ error: "Project repository not found" }, 404) };
|
|
839
|
+
return {
|
|
840
|
+
orgId,
|
|
841
|
+
userId,
|
|
842
|
+
project
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* One naming per session at a time: a second caller joins the run already in
|
|
847
|
+
* flight instead of paying for another model call and racing its rename.
|
|
848
|
+
*/
|
|
849
|
+
function createSessionNaming() {
|
|
850
|
+
const inFlight = /* @__PURE__ */ new Map();
|
|
851
|
+
return (sessionId, run) => {
|
|
852
|
+
const pending = inFlight.get(sessionId);
|
|
853
|
+
if (pending) return pending;
|
|
854
|
+
const started = run().finally(() => inFlight.delete(sessionId));
|
|
855
|
+
inFlight.set(sessionId, started);
|
|
856
|
+
return started;
|
|
857
|
+
};
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Name a thread with a stored model id. Resolution has to go through
|
|
861
|
+
* mastracode's gateway: a bare id handed to core's model router looks for a
|
|
862
|
+
* process env key instead of the caller's stored provider credentials.
|
|
863
|
+
*/
|
|
864
|
+
function titleModel(modelId) {
|
|
865
|
+
return ({ requestContext }) => resolveModel(modelId, {
|
|
866
|
+
remapForCodexOAuth: true,
|
|
867
|
+
requestContext
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
/** A screenful of history; GitHub caps its own page at 100. */
|
|
871
|
+
const DEFAULT_COMMIT_PAGE = 20;
|
|
872
|
+
const MAX_COMMIT_PAGE = 100;
|
|
873
|
+
const MAX_SESSION_OWNER_PROFILES = 100;
|
|
874
|
+
const MAX_SESSION_OWNER_PROFILE_CACHE_ENTRIES = 500;
|
|
875
|
+
const SESSION_OWNER_PROFILE_TTL_MS = 5 * 6e4;
|
|
876
|
+
function createSessionOwnerProfileResolver(users) {
|
|
877
|
+
const cache = /* @__PURE__ */ new Map();
|
|
878
|
+
const cacheProfile = (userId, profile, expiresAt) => {
|
|
879
|
+
cache.delete(userId);
|
|
880
|
+
cache.set(userId, {
|
|
881
|
+
profile,
|
|
882
|
+
expiresAt
|
|
883
|
+
});
|
|
884
|
+
if (cache.size > MAX_SESSION_OWNER_PROFILE_CACHE_ENTRIES) {
|
|
885
|
+
const oldestUserId = cache.keys().next().value;
|
|
886
|
+
if (oldestUserId !== void 0) cache.delete(oldestUserId);
|
|
887
|
+
}
|
|
888
|
+
};
|
|
889
|
+
return async (userIds) => {
|
|
890
|
+
if (!users) return /* @__PURE__ */ new Map();
|
|
891
|
+
const requestedUserIds = [...new Set(userIds)].slice(0, MAX_SESSION_OWNER_PROFILES);
|
|
892
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
893
|
+
const unresolvedUserIds = [];
|
|
894
|
+
const now = Date.now();
|
|
895
|
+
for (const userId of requestedUserIds) {
|
|
896
|
+
const cached = cache.get(userId);
|
|
897
|
+
if (!cached || cached.expiresAt <= now) {
|
|
898
|
+
cache.delete(userId);
|
|
899
|
+
unresolvedUserIds.push(userId);
|
|
900
|
+
} else if (cached.profile) profiles.set(userId, cached.profile);
|
|
901
|
+
}
|
|
902
|
+
if (unresolvedUserIds.length === 0) return profiles;
|
|
903
|
+
let resolvedUsers;
|
|
904
|
+
if (users.getUsers) try {
|
|
905
|
+
resolvedUsers = await users.getUsers(unresolvedUserIds);
|
|
906
|
+
} catch (error) {
|
|
907
|
+
console.warn("[GitHub Sessions] Bulk session owner profile lookup failed; falling back to individual lookups", { error: error instanceof Error ? error.message : String(error) });
|
|
908
|
+
resolvedUsers = (await Promise.allSettled(unresolvedUserIds.map((userId) => users.getUser(userId)))).filter((result) => result.status === "fulfilled").map((result) => result.value);
|
|
909
|
+
}
|
|
910
|
+
else resolvedUsers = (await Promise.allSettled(unresolvedUserIds.map((userId) => users.getUser(userId)))).filter((result) => result.status === "fulfilled").map((result) => result.value);
|
|
911
|
+
for (const user of resolvedUsers) {
|
|
912
|
+
if (!user) continue;
|
|
913
|
+
const name = user.name?.trim() || user.email?.trim();
|
|
914
|
+
if (!name) continue;
|
|
915
|
+
profiles.set(user.id, {
|
|
916
|
+
id: user.id,
|
|
917
|
+
name,
|
|
918
|
+
...user.avatarUrl ? { avatarUrl: user.avatarUrl } : {}
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
const expiresAt = now + SESSION_OWNER_PROFILE_TTL_MS;
|
|
922
|
+
for (const userId of unresolvedUserIds) cacheProfile(userId, profiles.get(userId), expiresAt);
|
|
923
|
+
return profiles;
|
|
924
|
+
};
|
|
925
|
+
}
|
|
926
|
+
function buildProjectGitRoutes({ github, auth, sandbox, users, controller, memorySettings, emitAudit, sessionRetirement, workItems }) {
|
|
927
|
+
const nameSession = createSessionNaming();
|
|
928
|
+
const resolveSessionOwnerProfiles = createSessionOwnerProfileResolver(users);
|
|
929
|
+
return [
|
|
930
|
+
registerApiRoute("/web/github/projects/:id/sessions", {
|
|
931
|
+
method: "GET",
|
|
932
|
+
requiresAuth: false,
|
|
933
|
+
handler: async (c) => {
|
|
934
|
+
const resolved = await resolveOrgTenant(loose(c), auth);
|
|
935
|
+
if ("response" in resolved) return resolved.response;
|
|
936
|
+
const { orgId, userId } = resolved.tenant;
|
|
937
|
+
const projectRepositoryId = c.req.param("id");
|
|
938
|
+
const project = projectRepositoryId ? await resolveProjectRepository({
|
|
939
|
+
github,
|
|
940
|
+
orgId,
|
|
941
|
+
projectRepositoryId
|
|
942
|
+
}) : null;
|
|
943
|
+
if (!project) return c.json({ error: "Project repository not found" }, 404);
|
|
944
|
+
const sessions = await github.sourceControlStorage.sessions.list({
|
|
945
|
+
projectRepositoryId: project.id,
|
|
946
|
+
viewerUserId: userId
|
|
947
|
+
});
|
|
948
|
+
const owners = await resolveSessionOwnerProfiles(sessions.map((session) => session.userId));
|
|
949
|
+
return c.json({ sessions: sessions.map((session) => {
|
|
950
|
+
const owner = owners.get(session.userId);
|
|
951
|
+
return {
|
|
952
|
+
...session,
|
|
953
|
+
...owner ? { owner } : {}
|
|
954
|
+
};
|
|
955
|
+
}) });
|
|
956
|
+
}
|
|
957
|
+
}),
|
|
958
|
+
registerApiRoute("/web/github/projects/:id/sessions", {
|
|
959
|
+
method: "POST",
|
|
960
|
+
requiresAuth: false,
|
|
961
|
+
handler: async (c) => {
|
|
962
|
+
const resolved = await resolveOrgTenant(loose(c), auth);
|
|
963
|
+
if ("response" in resolved) return resolved.response;
|
|
964
|
+
const { orgId, userId } = resolved.tenant;
|
|
965
|
+
const projectRepositoryId = c.req.param("id");
|
|
966
|
+
const project = projectRepositoryId ? await resolveProjectRepository({
|
|
967
|
+
github,
|
|
968
|
+
orgId,
|
|
969
|
+
projectRepositoryId
|
|
970
|
+
}) : null;
|
|
971
|
+
if (!project) return c.json({ error: "Project repository not found" }, 404);
|
|
972
|
+
let body;
|
|
973
|
+
try {
|
|
974
|
+
body = await c.req.json();
|
|
975
|
+
} catch {
|
|
976
|
+
return c.json({ error: "Invalid JSON body" }, 400);
|
|
977
|
+
}
|
|
978
|
+
if (!isJsonObject(body)) return c.json({ error: "Invalid JSON body" }, 400);
|
|
979
|
+
const requestedBaseBranch = body.baseBranch;
|
|
980
|
+
if (requestedBaseBranch !== void 0 && typeof requestedBaseBranch !== "string") return c.json({ error: "Invalid baseBranch" }, 400);
|
|
981
|
+
const baseBranch = requestedBaseBranch ?? project.defaultBranch;
|
|
982
|
+
if (!isValidGitRef(baseBranch)) return c.json({ error: "Invalid baseBranch" }, 400);
|
|
983
|
+
const requestedSessionId = body.sessionId;
|
|
984
|
+
if (requestedSessionId !== void 0 && (typeof requestedSessionId !== "string" || !UUID_PATTERN.test(requestedSessionId))) return c.json({ error: "Invalid sessionId" }, 400);
|
|
985
|
+
const sessionId = requestedSessionId ?? globalThis.crypto.randomUUID();
|
|
986
|
+
const requestedTitle = body.title;
|
|
987
|
+
if (requestedTitle !== void 0 && typeof requestedTitle !== "string") return c.json({ error: "Invalid title" }, 400);
|
|
988
|
+
const normalizedTitle = requestedTitle === void 0 ? null : normalizeSessionTitle(requestedTitle);
|
|
989
|
+
const requestedBranch = body.branch;
|
|
990
|
+
let branch;
|
|
991
|
+
if (requestedBranch === void 0) branch = `${USER_SESSION_BRANCH_PREFIX}${sessionId}`;
|
|
992
|
+
else if (typeof requestedBranch === "string" && isValidGitRef(requestedBranch)) branch = requestedBranch;
|
|
993
|
+
else return c.json({ error: "Invalid branch" }, 400);
|
|
994
|
+
if (requestedSessionId !== void 0) {
|
|
995
|
+
const existing = await github.sourceControlStorage.sessions.getBySessionId(sessionId);
|
|
996
|
+
if (existing) {
|
|
997
|
+
if (existing.projectRepositoryId !== project.id || existing.orgId !== orgId || existing.userId !== userId || existing.branch !== branch) return c.json({ error: "Session ID conflict" }, 409);
|
|
998
|
+
return c.json({ session: existing });
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
const session = await github.sourceControlStorage.sessions.create({
|
|
1002
|
+
sessionId,
|
|
1003
|
+
projectRepositoryId: project.id,
|
|
1004
|
+
factoryProjectId: project.factoryProjectId,
|
|
1005
|
+
orgId,
|
|
1006
|
+
userId,
|
|
1007
|
+
branch,
|
|
1008
|
+
baseBranch,
|
|
1009
|
+
title: normalizedTitle,
|
|
1010
|
+
visibility: "org"
|
|
1011
|
+
}).catch(async (error) => {
|
|
1012
|
+
if (!(error instanceof UniqueViolationError) || requestedSessionId === void 0) throw error;
|
|
1013
|
+
const conflict = await github.sourceControlStorage.sessions.getBySessionId(sessionId);
|
|
1014
|
+
if (!conflict) throw error;
|
|
1015
|
+
return conflict;
|
|
1016
|
+
});
|
|
1017
|
+
if (requestedSessionId !== void 0 && (session.sessionId !== sessionId || session.projectRepositoryId !== project.id || session.orgId !== orgId || session.userId !== userId || session.branch !== branch)) return c.json({ error: "Session ID conflict" }, 409);
|
|
1018
|
+
return c.json({ session });
|
|
1019
|
+
}
|
|
1020
|
+
}),
|
|
1021
|
+
registerApiRoute("/web/user-sessions/:sessionId", {
|
|
1022
|
+
method: "GET",
|
|
1023
|
+
requiresAuth: false,
|
|
1024
|
+
handler: async (c) => {
|
|
1025
|
+
const resolved = await resolveOrgTenant(loose(c), auth);
|
|
1026
|
+
if ("response" in resolved) return resolved.response;
|
|
1027
|
+
const session = await github.sourceControlStorage.sessions.getBySessionId(c.req.param("sessionId"));
|
|
1028
|
+
if (!session || session.orgId !== resolved.tenant.orgId || session.visibility === "private" && session.userId !== resolved.tenant.userId) return c.json({ error: "Session not found" }, 404);
|
|
1029
|
+
return c.json({ session });
|
|
1030
|
+
}
|
|
1031
|
+
}),
|
|
1032
|
+
registerApiRoute("/web/user-sessions/:sessionId", {
|
|
1033
|
+
method: "DELETE",
|
|
1034
|
+
requiresAuth: false,
|
|
1035
|
+
handler: async (c) => {
|
|
1036
|
+
const resolved = await resolveOrgTenant(loose(c), auth);
|
|
1037
|
+
if ("response" in resolved) return resolved.response;
|
|
1038
|
+
const session = await github.sourceControlStorage.sessions.getBySessionId(c.req.param("sessionId"));
|
|
1039
|
+
if (!session || session.orgId !== resolved.tenant.orgId || session.userId !== resolved.tenant.userId) return c.json({ error: "Session not found" }, 404);
|
|
1040
|
+
try {
|
|
1041
|
+
await waitForPendingFilesystemCapture(session.sessionId).catch((error) => {
|
|
1042
|
+
console.warn("[GitHub Sessions] Failed to drain filesystem capture before delete", {
|
|
1043
|
+
sessionId: session.sessionId,
|
|
1044
|
+
error
|
|
1045
|
+
});
|
|
1046
|
+
});
|
|
1047
|
+
await controller?.deleteSession({ resourceId: session.sessionId });
|
|
1048
|
+
} catch (error) {
|
|
1049
|
+
console.error("[GitHub Sessions] Failed to tear down live controller session", {
|
|
1050
|
+
sessionId: session.sessionId,
|
|
1051
|
+
error
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
if (sessionRetirement) await sessionRetirement.retireSession({
|
|
1055
|
+
sourceControl: github.sourceControlStorage,
|
|
1056
|
+
...workItems ? { workItems } : {},
|
|
1057
|
+
orgId: session.orgId,
|
|
1058
|
+
sessionId: session.sessionId,
|
|
1059
|
+
deleteSession: true
|
|
1060
|
+
});
|
|
1061
|
+
else {
|
|
1062
|
+
await workItems?.clearSessionReferences({
|
|
1063
|
+
orgId: session.orgId,
|
|
1064
|
+
sessionId: session.sessionId
|
|
1065
|
+
});
|
|
1066
|
+
await github.sourceControlStorage.sessions.delete(session.id);
|
|
1067
|
+
reclaimDeletedSessionSandbox({ session }).catch((error) => {
|
|
1068
|
+
console.error("[GitHub Sessions] Failed to reclaim sandbox for deleted session", {
|
|
1069
|
+
sessionId: session.sessionId,
|
|
1070
|
+
sandboxId: session.sandboxId,
|
|
1071
|
+
error
|
|
1072
|
+
});
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
return c.json({ removed: true });
|
|
1076
|
+
}
|
|
1077
|
+
}),
|
|
1078
|
+
registerApiRoute("/web/user-sessions/:sessionId/title", {
|
|
1079
|
+
method: "POST",
|
|
1080
|
+
requiresAuth: false,
|
|
1081
|
+
handler: async (c) => {
|
|
1082
|
+
const resolved = await resolveOrgTenant(loose(c), auth);
|
|
1083
|
+
if ("response" in resolved) return resolved.response;
|
|
1084
|
+
const sessionId = c.req.param("sessionId");
|
|
1085
|
+
const row = await github.sourceControlStorage.sessions.getBySessionId(sessionId);
|
|
1086
|
+
if (!row || row.orgId !== resolved.tenant.orgId || row.userId !== resolved.tenant.userId) return c.json({ error: "Session not found" }, 404);
|
|
1087
|
+
if (!controller) return c.json({ error: "Sessions are not available on this server." }, 503);
|
|
1088
|
+
const thread = (await controller.queryThreads({ resourceId: sessionId })).sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime())[0];
|
|
1089
|
+
if (!thread) return c.json({ error: "This session has no conversation to name yet." }, 409);
|
|
1090
|
+
const stored = await memorySettings.get({
|
|
1091
|
+
orgId: row.orgId,
|
|
1092
|
+
userId: row.userId
|
|
1093
|
+
});
|
|
1094
|
+
const requestContext = new RequestContext();
|
|
1095
|
+
requestContext.set("user", {
|
|
1096
|
+
workosId: row.userId,
|
|
1097
|
+
organizationId: row.orgId
|
|
1098
|
+
});
|
|
1099
|
+
requestContext.set("mastra__factoryMemorySettings", stored);
|
|
1100
|
+
try {
|
|
1101
|
+
const title = await nameSession(sessionId, async () => {
|
|
1102
|
+
const generated = await controller.generateThreadTitle({
|
|
1103
|
+
threadId: thread.id,
|
|
1104
|
+
resourceId: sessionId,
|
|
1105
|
+
requestContext,
|
|
1106
|
+
...stored?.observerModelId ? { model: titleModel(stored.observerModelId) } : {}
|
|
1107
|
+
});
|
|
1108
|
+
const named = generated ? normalizeSessionTitle(generated) : null;
|
|
1109
|
+
if (named) await github.sourceControlStorage.sessions.rename({
|
|
1110
|
+
sessionId,
|
|
1111
|
+
title: named
|
|
1112
|
+
});
|
|
1113
|
+
return named;
|
|
1114
|
+
});
|
|
1115
|
+
if (!title) return c.json({ error: "The model returned an empty title. Try again." }, 502);
|
|
1116
|
+
return c.json({ title });
|
|
1117
|
+
} catch (error) {
|
|
1118
|
+
return c.json({ error: error instanceof Error ? error.message : String(error) }, 500);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
}),
|
|
1122
|
+
registerApiRoute("/web/github/projects/:id/commit", {
|
|
1123
|
+
method: "POST",
|
|
1124
|
+
requiresAuth: false,
|
|
1125
|
+
handler: async (c) => {
|
|
1126
|
+
const owned = await loadOwnedProject({
|
|
1127
|
+
github,
|
|
1128
|
+
auth,
|
|
1129
|
+
sandbox,
|
|
1130
|
+
c: loose(c)
|
|
1131
|
+
});
|
|
1132
|
+
if ("response" in owned) return owned.response;
|
|
1133
|
+
const { userId, project } = owned;
|
|
1134
|
+
let body;
|
|
1135
|
+
try {
|
|
1136
|
+
body = await c.req.json();
|
|
1137
|
+
} catch {
|
|
1138
|
+
return c.json({ error: "Invalid JSON body" }, 400);
|
|
1139
|
+
}
|
|
1140
|
+
if (typeof body.message !== "string" || body.message.trim().length === 0 || body.message.length > 5e3) return c.json({ error: "Invalid message" }, 400);
|
|
1141
|
+
const sessionWorkspace = await resolveSessionWorkspace(github, project.id, userId, body.sessionId);
|
|
1142
|
+
if (!sessionWorkspace) return c.json({ error: "Invalid sessionId" }, 400);
|
|
1143
|
+
const { workdir, sandbox: sessionSandbox } = sessionWorkspace;
|
|
1144
|
+
try {
|
|
1145
|
+
return await withSessionOperationLock(sessionWorkspace.session.sessionId, async () => {
|
|
1146
|
+
const result = await commitAll(sessionSandbox, workdir, body.message, identityFromUser(await auth.ensureUser(loose(c))));
|
|
1147
|
+
if (result.committed) await emitAudit?.({
|
|
1148
|
+
context: loose(c),
|
|
1149
|
+
input: {
|
|
1150
|
+
action: "factory.git.commit",
|
|
1151
|
+
factoryProjectId: project.factoryProjectId,
|
|
1152
|
+
projectRepositoryId: project.id,
|
|
1153
|
+
targets: [{
|
|
1154
|
+
type: "session",
|
|
1155
|
+
id: sessionWorkspace.session.sessionId
|
|
1156
|
+
}],
|
|
1157
|
+
metadata: { sessionId: sessionWorkspace.session.sessionId }
|
|
1158
|
+
}
|
|
1159
|
+
});
|
|
1160
|
+
return c.json({ committed: result.committed });
|
|
1161
|
+
});
|
|
1162
|
+
} catch (err) {
|
|
1163
|
+
return gitErrorResponse(loose(c), err);
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
}),
|
|
1167
|
+
registerApiRoute("/web/github/projects/:id/commits", {
|
|
1168
|
+
method: "GET",
|
|
1169
|
+
requiresAuth: false,
|
|
1170
|
+
handler: async (c) => {
|
|
1171
|
+
const loaded = await loadOrgProject({
|
|
1172
|
+
github,
|
|
1173
|
+
auth,
|
|
1174
|
+
c: loose(c)
|
|
1175
|
+
});
|
|
1176
|
+
if ("response" in loaded) return loaded.response;
|
|
1177
|
+
const { orgId, project } = loaded;
|
|
1178
|
+
const branch = c.req.query("branch") ?? project.defaultBranch;
|
|
1179
|
+
if (!isValidGitRef(branch)) return c.json({ error: "Invalid branch" }, 400);
|
|
1180
|
+
const limit = Math.min(Math.max(Math.floor(Number(c.req.query("limit") ?? DEFAULT_COMMIT_PAGE)) || DEFAULT_COMMIT_PAGE, 1), MAX_COMMIT_PAGE);
|
|
1181
|
+
try {
|
|
1182
|
+
const commits = await listRepositoryCommits(github, {
|
|
1183
|
+
orgId,
|
|
1184
|
+
project,
|
|
1185
|
+
branch,
|
|
1186
|
+
limit
|
|
1187
|
+
});
|
|
1188
|
+
return c.json({
|
|
1189
|
+
commits,
|
|
1190
|
+
branch
|
|
1191
|
+
});
|
|
1192
|
+
} catch (err) {
|
|
1193
|
+
return gitErrorResponse(loose(c), err);
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
}),
|
|
1197
|
+
registerApiRoute("/web/github/projects/:id/push", {
|
|
1198
|
+
method: "POST",
|
|
1199
|
+
requiresAuth: false,
|
|
1200
|
+
handler: async (c) => {
|
|
1201
|
+
const owned = await loadOwnedProject({
|
|
1202
|
+
github,
|
|
1203
|
+
auth,
|
|
1204
|
+
sandbox,
|
|
1205
|
+
c: loose(c)
|
|
1206
|
+
});
|
|
1207
|
+
if ("response" in owned) return owned.response;
|
|
1208
|
+
const { orgId, userId, project } = owned;
|
|
1209
|
+
let body;
|
|
1210
|
+
try {
|
|
1211
|
+
body = await c.req.json();
|
|
1212
|
+
} catch {
|
|
1213
|
+
return c.json({ error: "Invalid JSON body" }, 400);
|
|
1214
|
+
}
|
|
1215
|
+
if (!isValidGitRef(body.branch)) return c.json({ error: "Invalid branch" }, 400);
|
|
1216
|
+
const branch = body.branch;
|
|
1217
|
+
const sessionWorkspace = await resolveSessionWorkspace(github, project.id, userId, body.sessionId);
|
|
1218
|
+
if (!sessionWorkspace) return c.json({ error: "Invalid sessionId" }, 400);
|
|
1219
|
+
const { workdir, sandbox: sessionSandbox } = sessionWorkspace;
|
|
1220
|
+
try {
|
|
1221
|
+
return await withSessionOperationLock(sessionWorkspace.session.sessionId, async () => {
|
|
1222
|
+
const access = await github.versionControl.getRepositoryAccess({
|
|
1223
|
+
orgId,
|
|
1224
|
+
repositoryId: project.repository.id
|
|
1225
|
+
});
|
|
1226
|
+
if (!access.authorization) throw new Error("Repository access did not include a bearer token.");
|
|
1227
|
+
await pushBranch(sessionSandbox, workdir, branch, access.authorization.token, project.repository.slug);
|
|
1228
|
+
await emitAudit?.({
|
|
1229
|
+
context: loose(c),
|
|
1230
|
+
input: {
|
|
1231
|
+
action: "factory.git.push",
|
|
1232
|
+
factoryProjectId: project.factoryProjectId,
|
|
1233
|
+
projectRepositoryId: project.id,
|
|
1234
|
+
targets: [{
|
|
1235
|
+
type: "branch",
|
|
1236
|
+
id: branch
|
|
1237
|
+
}],
|
|
1238
|
+
metadata: {
|
|
1239
|
+
branch,
|
|
1240
|
+
sessionId: sessionWorkspace.session.sessionId
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
});
|
|
1244
|
+
return c.json({
|
|
1245
|
+
pushed: true,
|
|
1246
|
+
branch
|
|
1247
|
+
});
|
|
1248
|
+
});
|
|
1249
|
+
} catch (err) {
|
|
1250
|
+
return gitErrorResponse(loose(c), err);
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
}),
|
|
1254
|
+
registerApiRoute("/web/github/projects/:id/pr", {
|
|
1255
|
+
method: "POST",
|
|
1256
|
+
requiresAuth: false,
|
|
1257
|
+
handler: async (c) => {
|
|
1258
|
+
const owned = await loadOwnedProject({
|
|
1259
|
+
github,
|
|
1260
|
+
auth,
|
|
1261
|
+
sandbox,
|
|
1262
|
+
c: loose(c)
|
|
1263
|
+
});
|
|
1264
|
+
if ("response" in owned) return owned.response;
|
|
1265
|
+
const { orgId, userId, project } = owned;
|
|
1266
|
+
let body;
|
|
1267
|
+
try {
|
|
1268
|
+
body = await c.req.json();
|
|
1269
|
+
} catch {
|
|
1270
|
+
return c.json({ error: "Invalid JSON body" }, 400);
|
|
1271
|
+
}
|
|
1272
|
+
if (!isValidGitRef(body.branch)) return c.json({ error: "Invalid branch" }, 400);
|
|
1273
|
+
const base = body.base === void 0 ? project.defaultBranch : body.base;
|
|
1274
|
+
if (!isValidGitRef(base)) return c.json({ error: "Invalid base" }, 400);
|
|
1275
|
+
if (typeof body.title !== "string" || body.title.trim().length === 0 || body.title.length > 256) return c.json({ error: "Invalid title" }, 400);
|
|
1276
|
+
if (body.body !== void 0 && (typeof body.body !== "string" || body.body.length > 65536)) return c.json({ error: "Invalid body" }, 400);
|
|
1277
|
+
const head = body.branch;
|
|
1278
|
+
const title = body.title;
|
|
1279
|
+
const prBody = body.body;
|
|
1280
|
+
const sessionWorkspace = await resolveSessionWorkspace(github, project.id, userId, body.sessionId);
|
|
1281
|
+
if (!sessionWorkspace) return c.json({ error: "Invalid sessionId" }, 400);
|
|
1282
|
+
try {
|
|
1283
|
+
return await withSessionOperationLock(sessionWorkspace.session.sessionId, async () => {
|
|
1284
|
+
const result = await github.versionControl.createPullRequest({
|
|
1285
|
+
connection: {
|
|
1286
|
+
type: "app-installation",
|
|
1287
|
+
installationId: Number(project.installation.externalId)
|
|
1288
|
+
},
|
|
1289
|
+
sourceId: project.repository.slug,
|
|
1290
|
+
baseBranch: base,
|
|
1291
|
+
headBranch: head,
|
|
1292
|
+
title,
|
|
1293
|
+
body: prBody,
|
|
1294
|
+
actingUserId: userId
|
|
1295
|
+
});
|
|
1296
|
+
await emitAudit?.({
|
|
1297
|
+
context: loose(c),
|
|
1298
|
+
input: {
|
|
1299
|
+
action: "factory.git.pr_opened",
|
|
1300
|
+
factoryProjectId: project.factoryProjectId,
|
|
1301
|
+
projectRepositoryId: project.id,
|
|
1302
|
+
targets: [{
|
|
1303
|
+
type: "pull_request",
|
|
1304
|
+
id: result.url,
|
|
1305
|
+
name: title
|
|
1306
|
+
}],
|
|
1307
|
+
metadata: {
|
|
1308
|
+
branch: head,
|
|
1309
|
+
base,
|
|
1310
|
+
url: result.url
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
});
|
|
1314
|
+
const pullRequestNumber = pullRequestNumberFromUrl(result.url, project.repository.slug);
|
|
1315
|
+
if (pullRequestNumber) {
|
|
1316
|
+
const sessionId = sessionWorkspace.session.sessionId;
|
|
1317
|
+
await subscribeToPullRequest({
|
|
1318
|
+
orgId,
|
|
1319
|
+
installationExternalId: project.installation.externalId,
|
|
1320
|
+
projectRepositoryId: project.id,
|
|
1321
|
+
repositoryExternalId: project.repository.externalId,
|
|
1322
|
+
repositorySlug: project.repository.slug,
|
|
1323
|
+
changeRequestId: pullRequestNumber.toString(),
|
|
1324
|
+
sessionId,
|
|
1325
|
+
ownerId: userId,
|
|
1326
|
+
resourceId: sessionId,
|
|
1327
|
+
threadId: sessionId,
|
|
1328
|
+
source: "factory-pr-create",
|
|
1329
|
+
subscribedByUserId: userId
|
|
1330
|
+
}, github.integrationStorage).catch((error) => {
|
|
1331
|
+
console.warn(`[GitHub] Pull request ${result.url} was created but automatic subscription failed.`, error);
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1334
|
+
return c.json({ url: result.url });
|
|
1335
|
+
});
|
|
1336
|
+
} catch (err) {
|
|
1337
|
+
return c.json({
|
|
1338
|
+
error: "github_pr_create_failed",
|
|
1339
|
+
message: err instanceof Error ? err.message : String(err)
|
|
1340
|
+
}, 502);
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
})
|
|
1344
|
+
];
|
|
1345
|
+
}
|
|
1346
|
+
/** Resolve the materialized workspace owned by a Factory session. */
|
|
1347
|
+
async function resolveSessionWorkspace(github, projectId, userId, sessionId) {
|
|
1348
|
+
if (typeof sessionId !== "string") return;
|
|
1349
|
+
const session = await github.sourceControlStorage.sessions.getBySessionId(sessionId);
|
|
1350
|
+
if (session?.projectRepositoryId !== projectId || session.userId !== userId) return;
|
|
1351
|
+
const entry = peekSessionSandbox(session.id);
|
|
1352
|
+
if (!entry?.workdir) return void 0;
|
|
1353
|
+
return {
|
|
1354
|
+
session,
|
|
1355
|
+
workdir: entry.workdir,
|
|
1356
|
+
sandbox: requireExec(entry.sandbox)
|
|
1357
|
+
};
|
|
1358
|
+
}
|
|
1359
|
+
//#endregion
|
|
1360
|
+
export { buildGithubRoutes, ingestLinkedRepositoryBacklog };
|
|
1361
|
+
|
|
1362
|
+
//# sourceMappingURL=routes.js.map
|