@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,105 @@
|
|
|
1
|
+
import type { RequestContext } from '@mastra/core/request-context';
|
|
2
|
+
import type { IntegrationTools } from '../integrations/base.js';
|
|
3
|
+
import type { WorkItemsStorage } from '../storage/domains/work-items/base.js';
|
|
4
|
+
import type { FactorySessionSourceLookup } from './binding-context.js';
|
|
5
|
+
export interface ReviewSourceOutput {
|
|
6
|
+
/**
|
|
7
|
+
* Browser-facing deep-link back to the Factory session that produced this
|
|
8
|
+
* review — the only field a review body publishes. Everything else on this
|
|
9
|
+
* shape is an input to in-run cross-checks and the session handoff, never a
|
|
10
|
+
* published field, so the GitHub/GitLab audience never sees the upstream
|
|
11
|
+
* Linear/Jira slug through the review comment.
|
|
12
|
+
*/
|
|
13
|
+
sessionUrl: string;
|
|
14
|
+
/**
|
|
15
|
+
* PR/MR author recorded on the review card at intake — for GitHub this is
|
|
16
|
+
* `pullRequest.user.login`, for GitLab it is the GitLab username. The skill
|
|
17
|
+
* cross-checks it against the same REST field of the reviewed PR
|
|
18
|
+
* (`gh api repos/<owner>/<repo>/pulls/<number> --jq .user.login`; `gh pr view`
|
|
19
|
+
* formats App authors as `app/<slug>` instead of `<slug>[bot]`) or the
|
|
20
|
+
* equivalent MR fetch; a mismatch means the session is bound to a different
|
|
21
|
+
* PR/MR than the one being reviewed.
|
|
22
|
+
*/
|
|
23
|
+
triggeredBy: string | null;
|
|
24
|
+
/**
|
|
25
|
+
* The externalSource recorded on the review card itself — the PR/MR the
|
|
26
|
+
* session was intake-bound to. The skill cross-checks the reviewed PR/MR
|
|
27
|
+
* against this shape so a review can never quietly land on the wrong target.
|
|
28
|
+
*/
|
|
29
|
+
reviewTarget: {
|
|
30
|
+
integrationId: string;
|
|
31
|
+
type: string;
|
|
32
|
+
externalId: string;
|
|
33
|
+
url: string | null;
|
|
34
|
+
} | null;
|
|
35
|
+
/**
|
|
36
|
+
* Repository identity stamped on the review card at intake — the
|
|
37
|
+
* binding-side value for the null-`url` cross-check fallback. The skill must
|
|
38
|
+
* compare this against an identity resolved independently of the card (e.g.
|
|
39
|
+
* `gh api repos/<owner>/<repo> --jq .id` — the numeric REST id — for the
|
|
40
|
+
* session checkout's repository);
|
|
41
|
+
* comparing two values derived from the same checkout proves nothing.
|
|
42
|
+
* `null` when intake recorded no repository identity — in that case there
|
|
43
|
+
* is no verifiable bound repository and the fallback must not publish.
|
|
44
|
+
*/
|
|
45
|
+
boundRepository: {
|
|
46
|
+
provider: 'github';
|
|
47
|
+
repositoryId: number;
|
|
48
|
+
} | {
|
|
49
|
+
provider: 'gitlab';
|
|
50
|
+
host: string | null;
|
|
51
|
+
projectId: number;
|
|
52
|
+
} | null;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Normalize the operator-provided browser-facing UI origin (the
|
|
56
|
+
* `MASTRACODE_PUBLIC_URL` env var) into the `uiOrigin` the tool accepts.
|
|
57
|
+
*
|
|
58
|
+
* Blank counts as unset: `mastracode/web/.env.schema` ships
|
|
59
|
+
* `MASTRACODE_PUBLIC_URL=` as the operator-facing line, so an empty or
|
|
60
|
+
* whitespace-only value is the expected "not configured" state — it must map
|
|
61
|
+
* to `null` (tool omitted) rather than register the tool and publish a
|
|
62
|
+
* hostless `sessionUrl` into a public review body.
|
|
63
|
+
*/
|
|
64
|
+
export declare function resolveReviewSourceUiOrigin(raw: string | undefined): string | null;
|
|
65
|
+
/**
|
|
66
|
+
* `factory_review_source` — read the routing facts behind the current review
|
|
67
|
+
* session (session deep-link, PR/MR author, the review target) so the review
|
|
68
|
+
* agent can attribute its verdict to a concrete originating run and detect a
|
|
69
|
+
* mis-targeted review before it publishes.
|
|
70
|
+
*
|
|
71
|
+
* The tool exists to make cross-PR misattribution detectable both in-run and
|
|
72
|
+
* after the fact: a review lands on GitHub/GitLab with the Factory session URL
|
|
73
|
+
* that produced it, and the human who investigates a suspicious review can
|
|
74
|
+
* jump straight to the run.
|
|
75
|
+
*
|
|
76
|
+
* All fields are derived server-side from the bound work item — nothing enters
|
|
77
|
+
* from the agent's tool arguments — so the session URL always points at the
|
|
78
|
+
* caller's own session, never one it was asked to name.
|
|
79
|
+
*
|
|
80
|
+
* The tool is intentionally omitted (returns `{}`) whenever it cannot produce
|
|
81
|
+
* a complete, correct provenance shape: no resolvable session address, no
|
|
82
|
+
* active binding, a non-review-role binding, no bound work item, or no
|
|
83
|
+
* configured browser-facing UI origin. Skills treat tool-absent identically to
|
|
84
|
+
* tool-failed: stop-don't-publish.
|
|
85
|
+
*/
|
|
86
|
+
export declare function createReviewSourceTool(options: {
|
|
87
|
+
requestContext: RequestContext;
|
|
88
|
+
storage: Pick<WorkItemsStorage, 'findActiveRunBindingByThread' | 'findActiveRunBinding' | 'get'>;
|
|
89
|
+
sessions?: FactorySessionSourceLookup;
|
|
90
|
+
/**
|
|
91
|
+
* Browser-facing UI origin, no trailing slash. In a separate-SPA deployment
|
|
92
|
+
* (API host distinct from UI host) this is the UI host — the origin the
|
|
93
|
+
* emitted session link opens in. `MastraFactoryConfig.publicUrl` is the API
|
|
94
|
+
* origin and must not be used here; the caller resolves the UI origin (see
|
|
95
|
+
* `factory.ts`) via the `MASTRACODE_PUBLIC_URL` env var.
|
|
96
|
+
*
|
|
97
|
+
* `null` means no browser-facing origin is configured. Match the Slack
|
|
98
|
+
* session-link surface (`integrations/slack/slack.ts:168-171`, `:809-812`),
|
|
99
|
+
* which omits the deep-link entirely rather than publishing an API/localhost
|
|
100
|
+
* URL into a public body: the tool is dropped from the toolset, and the
|
|
101
|
+
* skill's tool-not-available branch stops publication.
|
|
102
|
+
*/
|
|
103
|
+
uiOrigin: string | null;
|
|
104
|
+
}): Promise<IntegrationTools>;
|
|
105
|
+
//# sourceMappingURL=review-source-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review-source-tool.d.ts","sourceRoot":"","sources":["../../src/rules/review-source-tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAInE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAe,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAC3F,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAGvE,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;;;;OAQG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;;;OAIG;IACH,YAAY,EAAE;QACZ,aAAa,EAAE,MAAM,CAAC;QACtB,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;KACpB,GAAG,IAAI,CAAC;IACT;;;;;;;;;OASG;IACH,eAAe,EACX;QAAE,QAAQ,EAAE,QAAQ,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,GAC5C;QAAE,QAAQ,EAAE,QAAQ,CAAC;QAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAC9D,IAAI,CAAC;CACV;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAElF;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE;IACpD,cAAc,EAAE,cAAc,CAAC;IAC/B,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,8BAA8B,GAAG,sBAAsB,GAAG,KAAK,CAAC,CAAC;IACjG,QAAQ,CAAC,EAAE,0BAA0B,CAAC;IACtC;;;;;;;;;;;;OAYG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAyC5B"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { resolveFactorySessionAddress } from "./binding-context.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { createTool } from "@mastra/core/tools";
|
|
4
|
+
//#region src/rules/review-source-tool.ts
|
|
5
|
+
/**
|
|
6
|
+
* Normalize the operator-provided browser-facing UI origin (the
|
|
7
|
+
* `MASTRACODE_PUBLIC_URL` env var) into the `uiOrigin` the tool accepts.
|
|
8
|
+
*
|
|
9
|
+
* Blank counts as unset: `mastracode/web/.env.schema` ships
|
|
10
|
+
* `MASTRACODE_PUBLIC_URL=` as the operator-facing line, so an empty or
|
|
11
|
+
* whitespace-only value is the expected "not configured" state — it must map
|
|
12
|
+
* to `null` (tool omitted) rather than register the tool and publish a
|
|
13
|
+
* hostless `sessionUrl` into a public review body.
|
|
14
|
+
*/
|
|
15
|
+
function resolveReviewSourceUiOrigin(raw) {
|
|
16
|
+
return raw?.trim().replace(/\/+$/, "") || null;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* `factory_review_source` — read the routing facts behind the current review
|
|
20
|
+
* session (session deep-link, PR/MR author, the review target) so the review
|
|
21
|
+
* agent can attribute its verdict to a concrete originating run and detect a
|
|
22
|
+
* mis-targeted review before it publishes.
|
|
23
|
+
*
|
|
24
|
+
* The tool exists to make cross-PR misattribution detectable both in-run and
|
|
25
|
+
* after the fact: a review lands on GitHub/GitLab with the Factory session URL
|
|
26
|
+
* that produced it, and the human who investigates a suspicious review can
|
|
27
|
+
* jump straight to the run.
|
|
28
|
+
*
|
|
29
|
+
* All fields are derived server-side from the bound work item — nothing enters
|
|
30
|
+
* from the agent's tool arguments — so the session URL always points at the
|
|
31
|
+
* caller's own session, never one it was asked to name.
|
|
32
|
+
*
|
|
33
|
+
* The tool is intentionally omitted (returns `{}`) whenever it cannot produce
|
|
34
|
+
* a complete, correct provenance shape: no resolvable session address, no
|
|
35
|
+
* active binding, a non-review-role binding, no bound work item, or no
|
|
36
|
+
* configured browser-facing UI origin. Skills treat tool-absent identically to
|
|
37
|
+
* tool-failed: stop-don't-publish.
|
|
38
|
+
*/
|
|
39
|
+
async function createReviewSourceTool(options) {
|
|
40
|
+
if (options.uiOrigin === null) return {};
|
|
41
|
+
const resolution = await resolveFactorySessionAddress({
|
|
42
|
+
requestContext: options.requestContext,
|
|
43
|
+
storage: options.storage,
|
|
44
|
+
sessions: options.sessions
|
|
45
|
+
});
|
|
46
|
+
if (!resolution) return {};
|
|
47
|
+
const binding = resolution.binding ?? await options.storage.findActiveRunBinding(resolution.address);
|
|
48
|
+
if (!binding || binding.role !== "review") return {};
|
|
49
|
+
const item = await options.storage.get({
|
|
50
|
+
orgId: binding.orgId,
|
|
51
|
+
id: binding.workItemId
|
|
52
|
+
});
|
|
53
|
+
if (!item) return {};
|
|
54
|
+
const output = {
|
|
55
|
+
sessionUrl: buildSessionUrl({
|
|
56
|
+
uiOrigin: options.uiOrigin,
|
|
57
|
+
factoryProjectId: binding.factoryProjectId,
|
|
58
|
+
sessionId: binding.sessionId,
|
|
59
|
+
threadId: binding.threadId
|
|
60
|
+
}),
|
|
61
|
+
triggeredBy: readPullRequestAuthor(item),
|
|
62
|
+
reviewTarget: readReviewTarget(item),
|
|
63
|
+
boundRepository: readBoundRepository(item)
|
|
64
|
+
};
|
|
65
|
+
return { factory_review_source: createTool({
|
|
66
|
+
id: "factory_review_source",
|
|
67
|
+
description: "Read the routing facts behind this review session: a deep-link back to the Factory session that produced the review, the PR/MR author recorded on the review card, and the review target (the PR/MR the session was intake-bound to). Publish the session URL in the required `Factory Session` block of every review body so a misattributed review can always be traced back to the run that produced it. Cross-check `triggeredBy` and `reviewTarget` against the PR/MR you fetched in Phase 1, using `boundRepository` as the intake-stamped repository identity when `reviewTarget.url` is null; do not publish the `triggeredBy`, `reviewTarget`, or `boundRepository` fields.",
|
|
68
|
+
inputSchema: z.object({}),
|
|
69
|
+
execute: async () => output
|
|
70
|
+
}) };
|
|
71
|
+
}
|
|
72
|
+
function buildSessionUrl(input) {
|
|
73
|
+
return `${input.uiOrigin.replace(/\/+$/, "")}/factories/${encodeURIComponent(input.factoryProjectId)}/workspaces/${encodeURIComponent(input.sessionId)}/threads/${encodeURIComponent(input.threadId)}`;
|
|
74
|
+
}
|
|
75
|
+
function readReviewTarget(item) {
|
|
76
|
+
const source = item.externalSource;
|
|
77
|
+
if (!source) return null;
|
|
78
|
+
return {
|
|
79
|
+
integrationId: source.integrationId,
|
|
80
|
+
type: source.type,
|
|
81
|
+
externalId: source.externalId,
|
|
82
|
+
url: typeof source.url === "string" && source.url ? source.url : null
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function readBoundRepository(item) {
|
|
86
|
+
const metadata = item.metadata;
|
|
87
|
+
if (!metadata) return null;
|
|
88
|
+
if (typeof metadata.githubRepositoryId === "number") return {
|
|
89
|
+
provider: "github",
|
|
90
|
+
repositoryId: metadata.githubRepositoryId
|
|
91
|
+
};
|
|
92
|
+
if (typeof metadata.gitlabProjectId === "number") return {
|
|
93
|
+
provider: "gitlab",
|
|
94
|
+
host: typeof metadata.gitlabHost === "string" && metadata.gitlabHost ? metadata.gitlabHost : null,
|
|
95
|
+
projectId: metadata.gitlabProjectId
|
|
96
|
+
};
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
function readPullRequestAuthor(item) {
|
|
100
|
+
const metadata = item.metadata;
|
|
101
|
+
if (!metadata) return null;
|
|
102
|
+
const author = metadata.author;
|
|
103
|
+
if (typeof author === "string" && author.trim()) return author.trim();
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
export { createReviewSourceTool, resolveReviewSourceUiOrigin };
|
|
108
|
+
|
|
109
|
+
//# sourceMappingURL=review-source-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review-source-tool.js","names":[],"sources":["../../src/rules/review-source-tool.ts"],"sourcesContent":["import type { RequestContext } from '@mastra/core/request-context';\nimport { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\nimport type { IntegrationTools } from '../integrations/base.js';\nimport type { WorkItemRow, WorkItemsStorage } from '../storage/domains/work-items/base.js';\nimport type { FactorySessionSourceLookup } from './binding-context.js';\nimport { resolveFactorySessionAddress } from './binding-context.js';\n\nexport interface ReviewSourceOutput {\n /**\n * Browser-facing deep-link back to the Factory session that produced this\n * review — the only field a review body publishes. Everything else on this\n * shape is an input to in-run cross-checks and the session handoff, never a\n * published field, so the GitHub/GitLab audience never sees the upstream\n * Linear/Jira slug through the review comment.\n */\n sessionUrl: string;\n /**\n * PR/MR author recorded on the review card at intake — for GitHub this is\n * `pullRequest.user.login`, for GitLab it is the GitLab username. The skill\n * cross-checks it against the same REST field of the reviewed PR\n * (`gh api repos/<owner>/<repo>/pulls/<number> --jq .user.login`; `gh pr view`\n * formats App authors as `app/<slug>` instead of `<slug>[bot]`) or the\n * equivalent MR fetch; a mismatch means the session is bound to a different\n * PR/MR than the one being reviewed.\n */\n triggeredBy: string | null;\n /**\n * The externalSource recorded on the review card itself — the PR/MR the\n * session was intake-bound to. The skill cross-checks the reviewed PR/MR\n * against this shape so a review can never quietly land on the wrong target.\n */\n reviewTarget: {\n integrationId: string;\n type: string;\n externalId: string;\n url: string | null;\n } | null;\n /**\n * Repository identity stamped on the review card at intake — the\n * binding-side value for the null-`url` cross-check fallback. The skill must\n * compare this against an identity resolved independently of the card (e.g.\n * `gh api repos/<owner>/<repo> --jq .id` — the numeric REST id — for the\n * session checkout's repository);\n * comparing two values derived from the same checkout proves nothing.\n * `null` when intake recorded no repository identity — in that case there\n * is no verifiable bound repository and the fallback must not publish.\n */\n boundRepository:\n | { provider: 'github'; repositoryId: number }\n | { provider: 'gitlab'; host: string | null; projectId: number }\n | null;\n}\n\n/**\n * Normalize the operator-provided browser-facing UI origin (the\n * `MASTRACODE_PUBLIC_URL` env var) into the `uiOrigin` the tool accepts.\n *\n * Blank counts as unset: `mastracode/web/.env.schema` ships\n * `MASTRACODE_PUBLIC_URL=` as the operator-facing line, so an empty or\n * whitespace-only value is the expected \"not configured\" state — it must map\n * to `null` (tool omitted) rather than register the tool and publish a\n * hostless `sessionUrl` into a public review body.\n */\nexport function resolveReviewSourceUiOrigin(raw: string | undefined): string | null {\n return raw?.trim().replace(/\\/+$/, '') || null;\n}\n\n/**\n * `factory_review_source` — read the routing facts behind the current review\n * session (session deep-link, PR/MR author, the review target) so the review\n * agent can attribute its verdict to a concrete originating run and detect a\n * mis-targeted review before it publishes.\n *\n * The tool exists to make cross-PR misattribution detectable both in-run and\n * after the fact: a review lands on GitHub/GitLab with the Factory session URL\n * that produced it, and the human who investigates a suspicious review can\n * jump straight to the run.\n *\n * All fields are derived server-side from the bound work item — nothing enters\n * from the agent's tool arguments — so the session URL always points at the\n * caller's own session, never one it was asked to name.\n *\n * The tool is intentionally omitted (returns `{}`) whenever it cannot produce\n * a complete, correct provenance shape: no resolvable session address, no\n * active binding, a non-review-role binding, no bound work item, or no\n * configured browser-facing UI origin. Skills treat tool-absent identically to\n * tool-failed: stop-don't-publish.\n */\nexport async function createReviewSourceTool(options: {\n requestContext: RequestContext;\n storage: Pick<WorkItemsStorage, 'findActiveRunBindingByThread' | 'findActiveRunBinding' | 'get'>;\n sessions?: FactorySessionSourceLookup;\n /**\n * Browser-facing UI origin, no trailing slash. In a separate-SPA deployment\n * (API host distinct from UI host) this is the UI host — the origin the\n * emitted session link opens in. `MastraFactoryConfig.publicUrl` is the API\n * origin and must not be used here; the caller resolves the UI origin (see\n * `factory.ts`) via the `MASTRACODE_PUBLIC_URL` env var.\n *\n * `null` means no browser-facing origin is configured. Match the Slack\n * session-link surface (`integrations/slack/slack.ts:168-171`, `:809-812`),\n * which omits the deep-link entirely rather than publishing an API/localhost\n * URL into a public body: the tool is dropped from the toolset, and the\n * skill's tool-not-available branch stops publication.\n */\n uiOrigin: string | null;\n}): Promise<IntegrationTools> {\n if (options.uiOrigin === null) return {};\n const resolution = await resolveFactorySessionAddress({\n requestContext: options.requestContext,\n storage: options.storage,\n sessions: options.sessions,\n });\n if (!resolution) return {};\n const binding = resolution.binding ?? (await options.storage.findActiveRunBinding(resolution.address));\n // The tool exists only for review-role sessions. Work/plan/triage runs never\n // publish reviews on GitHub, so exposing them the tool would just clutter\n // their prompt.\n if (!binding || binding.role !== 'review') return {};\n\n const item = await options.storage.get({ orgId: binding.orgId, id: binding.workItemId });\n if (!item) return {};\n\n const sessionUrl = buildSessionUrl({\n uiOrigin: options.uiOrigin,\n factoryProjectId: binding.factoryProjectId,\n sessionId: binding.sessionId,\n threadId: binding.threadId,\n });\n const triggeredBy = readPullRequestAuthor(item);\n const reviewTarget = readReviewTarget(item);\n const boundRepository = readBoundRepository(item);\n // Every field is pre-resolved server-side and returned as a plain object.\n // The tool takes no arguments and does no further I/O, so a review-role\n // session either sees a complete provenance shape or the tool is absent —\n // the skill treats those branches identically (stop-don't-publish).\n const output: ReviewSourceOutput = { sessionUrl, triggeredBy, reviewTarget, boundRepository };\n\n return {\n factory_review_source: createTool({\n id: 'factory_review_source',\n description:\n 'Read the routing facts behind this review session: a deep-link back to the Factory session that produced the review, the PR/MR author recorded on the review card, and the review target (the PR/MR the session was intake-bound to). Publish the session URL in the required `Factory Session` block of every review body so a misattributed review can always be traced back to the run that produced it. Cross-check `triggeredBy` and `reviewTarget` against the PR/MR you fetched in Phase 1, using `boundRepository` as the intake-stamped repository identity when `reviewTarget.url` is null; do not publish the `triggeredBy`, `reviewTarget`, or `boundRepository` fields.',\n inputSchema: z.object({}),\n execute: async (): Promise<ReviewSourceOutput> => output,\n }),\n };\n}\n\nfunction buildSessionUrl(input: {\n uiOrigin: string;\n factoryProjectId: string;\n sessionId: string;\n threadId: string;\n}): string {\n const origin = input.uiOrigin.replace(/\\/+$/, '');\n return `${origin}/factories/${encodeURIComponent(input.factoryProjectId)}/workspaces/${encodeURIComponent(input.sessionId)}/threads/${encodeURIComponent(input.threadId)}`;\n}\n\nfunction readReviewTarget(item: WorkItemRow): ReviewSourceOutput['reviewTarget'] {\n const source = item.externalSource;\n if (!source) return null;\n return {\n integrationId: source.integrationId,\n type: source.type,\n externalId: source.externalId,\n url: typeof source.url === 'string' && source.url ? source.url : null,\n };\n}\n\nfunction readBoundRepository(item: WorkItemRow): ReviewSourceOutput['boundRepository'] {\n const metadata = item.metadata;\n if (!metadata) return null;\n // Intake stamps repository identity on every PR/MR card:\n // `github/default-rules.ts` writes `githubRepositoryId`, and\n // `gitlab/default-rules.ts` writes `gitlabHost` + `gitlabProjectId`.\n if (typeof metadata.githubRepositoryId === 'number') {\n return { provider: 'github', repositoryId: metadata.githubRepositoryId };\n }\n if (typeof metadata.gitlabProjectId === 'number') {\n return {\n provider: 'gitlab',\n host: typeof metadata.gitlabHost === 'string' && metadata.gitlabHost ? metadata.gitlabHost : null,\n projectId: metadata.gitlabProjectId,\n };\n }\n return null;\n}\n\nfunction readPullRequestAuthor(item: WorkItemRow): string | null {\n const metadata = item.metadata;\n if (!metadata) return null;\n const author = metadata.author;\n if (typeof author === 'string' && author.trim()) return author.trim();\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;AAiEA,SAAgB,4BAA4B,KAAwC;CAClF,OAAO,KAAK,KAAK,CAAC,CAAC,QAAQ,QAAQ,EAAE,KAAK;AAC5C;;;;;;;;;;;;;;;;;;;;;;AAuBA,eAAsB,uBAAuB,SAkBf;CAC5B,IAAI,QAAQ,aAAa,MAAM,OAAO,CAAC;CACvC,MAAM,aAAa,MAAM,6BAA6B;EACpD,gBAAgB,QAAQ;EACxB,SAAS,QAAQ;EACjB,UAAU,QAAQ;CACpB,CAAC;CACD,IAAI,CAAC,YAAY,OAAO,CAAC;CACzB,MAAM,UAAU,WAAW,WAAY,MAAM,QAAQ,QAAQ,qBAAqB,WAAW,OAAO;CAIpG,IAAI,CAAC,WAAW,QAAQ,SAAS,UAAU,OAAO,CAAC;CAEnD,MAAM,OAAO,MAAM,QAAQ,QAAQ,IAAI;EAAE,OAAO,QAAQ;EAAO,IAAI,QAAQ;CAAW,CAAC;CACvF,IAAI,CAAC,MAAM,OAAO,CAAC;CAenB,MAAM,SAA6B;EAAE,YAblB,gBAAgB;GACjC,UAAU,QAAQ;GAClB,kBAAkB,QAAQ;GAC1B,WAAW,QAAQ;GACnB,UAAU,QAAQ;EACpB,CAQ8C;EAAG,aAP7B,sBAAsB,IAOiB;EAAG,cANzC,iBAAiB,IAMmC;EAAG,iBALpD,oBAAoB,IAK8C;CAAE;CAE5F,OAAO,EACL,uBAAuB,WAAW;EAChC,IAAI;EACJ,aACE;EACF,aAAa,EAAE,OAAO,CAAC,CAAC;EACxB,SAAS,YAAyC;CACpD,CAAC,EACH;AACF;AAEA,SAAS,gBAAgB,OAKd;CAET,OAAO,GADQ,MAAM,SAAS,QAAQ,QAAQ,EAC/B,EAAE,aAAa,mBAAmB,MAAM,gBAAgB,EAAE,cAAc,mBAAmB,MAAM,SAAS,EAAE,WAAW,mBAAmB,MAAM,QAAQ;AACzK;AAEA,SAAS,iBAAiB,MAAuD;CAC/E,MAAM,SAAS,KAAK;CACpB,IAAI,CAAC,QAAQ,OAAO;CACpB,OAAO;EACL,eAAe,OAAO;EACtB,MAAM,OAAO;EACb,YAAY,OAAO;EACnB,KAAK,OAAO,OAAO,QAAQ,YAAY,OAAO,MAAM,OAAO,MAAM;CACnE;AACF;AAEA,SAAS,oBAAoB,MAA0D;CACrF,MAAM,WAAW,KAAK;CACtB,IAAI,CAAC,UAAU,OAAO;CAItB,IAAI,OAAO,SAAS,uBAAuB,UACzC,OAAO;EAAE,UAAU;EAAU,cAAc,SAAS;CAAmB;CAEzE,IAAI,OAAO,SAAS,oBAAoB,UACtC,OAAO;EACL,UAAU;EACV,MAAM,OAAO,SAAS,eAAe,YAAY,SAAS,aAAa,SAAS,aAAa;EAC7F,WAAW,SAAS;CACtB;CAEF,OAAO;AACT;AAEA,SAAS,sBAAsB,MAAkC;CAC/D,MAAM,WAAW,KAAK;CACtB,IAAI,CAAC,UAAU,OAAO;CACtB,MAAM,SAAS,SAAS;CACxB,IAAI,OAAO,WAAW,YAAY,OAAO,KAAK,GAAG,OAAO,OAAO,KAAK;CACpE,OAAO;AACT"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { MastraCodeState } from '@mastra/code-sdk/schema';
|
|
2
|
+
import type { AgentController } from '@mastra/core/agent-controller';
|
|
3
|
+
import { RequestContext } from '@mastra/core/request-context';
|
|
4
|
+
import type { IntakeStorage } from '../storage/domains/intake/base.js';
|
|
5
|
+
import type { ModelDefaultsStorage } from '../storage/domains/model-defaults/base.js';
|
|
6
|
+
import type { EffectiveModelScope, FactoryProjectsStorage } from '../storage/domains/projects/base.js';
|
|
7
|
+
import type { SourceControlStorageHandle } from '../storage/domains/source-control/base.js';
|
|
8
|
+
import type { CreateWorkItemInput, WorkItemsStorage } from '../storage/domains/work-items/base.js';
|
|
9
|
+
import type { FactoryTransitionService } from './transition-service.js';
|
|
10
|
+
import type { FactoryRuleStage, FactoryTransitionResult } from './types.js';
|
|
11
|
+
export interface FactoryStartRequest {
|
|
12
|
+
orgId: string;
|
|
13
|
+
userId: string;
|
|
14
|
+
factoryProjectId: string;
|
|
15
|
+
sessionId: string;
|
|
16
|
+
threadTitle: string;
|
|
17
|
+
kickoffKey: string;
|
|
18
|
+
/** Where the arrival path lands the card; a session opened on an existing card names none. */
|
|
19
|
+
destinationStage?: FactoryRuleStage;
|
|
20
|
+
/** The run's effective scope; a hybrid Factory's runs use the Factory's model and credentials. */
|
|
21
|
+
modelScope: EffectiveModelScope;
|
|
22
|
+
defaultModelId?: string;
|
|
23
|
+
workItem: {
|
|
24
|
+
id?: string;
|
|
25
|
+
role: string;
|
|
26
|
+
input: CreateWorkItemInput;
|
|
27
|
+
};
|
|
28
|
+
requestContext?: RequestContext;
|
|
29
|
+
}
|
|
30
|
+
export declare class WorkItemRepositoryError extends Error {
|
|
31
|
+
readonly code: 'repository_mismatch' | 'repository_ambiguous' | 'repository_unlinked';
|
|
32
|
+
readonly candidates: string[];
|
|
33
|
+
constructor(code: 'repository_mismatch' | 'repository_ambiguous' | 'repository_unlinked', message: string, candidates?: string[]);
|
|
34
|
+
}
|
|
35
|
+
export declare class FactoryStartTransitionError extends Error {
|
|
36
|
+
readonly result: Extract<FactoryTransitionResult, {
|
|
37
|
+
status: 'rejected';
|
|
38
|
+
}>;
|
|
39
|
+
constructor(result: Extract<FactoryTransitionResult, {
|
|
40
|
+
status: 'rejected';
|
|
41
|
+
}>);
|
|
42
|
+
}
|
|
43
|
+
export interface FactoryStartPreparedResult {
|
|
44
|
+
workItemId: string;
|
|
45
|
+
bindingId: string;
|
|
46
|
+
threadId: string;
|
|
47
|
+
resourceId: string;
|
|
48
|
+
sessionId: string;
|
|
49
|
+
branch: string;
|
|
50
|
+
revision: number;
|
|
51
|
+
kickoffStatus: 'pending' | 'leased' | 'retry' | 'sent' | 'failed';
|
|
52
|
+
replayed: boolean;
|
|
53
|
+
}
|
|
54
|
+
type FactoryController = AgentController<MastraCodeState>;
|
|
55
|
+
export declare class FactoryStartCoordinator {
|
|
56
|
+
#private;
|
|
57
|
+
constructor(controller: FactoryController, storage: WorkItemsStorage, transitionService?: Pick<FactoryTransitionService, 'transition'>, sourceControl?: SourceControlStorageHandle | ((request: FactoryStartRequest) => SourceControlStorageHandle | undefined | Promise<SourceControlStorageHandle | undefined>), intake?: IntakeStorage, sessionModel?: {
|
|
58
|
+
projects: FactoryProjectsStorage;
|
|
59
|
+
modelDefaults: ModelDefaultsStorage;
|
|
60
|
+
});
|
|
61
|
+
prepare(request: FactoryStartRequest): Promise<FactoryStartPreparedResult>;
|
|
62
|
+
}
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=start-coordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-coordinator.d.ts","sourceRoot":"","sources":["../../src/rules/start-coordinator.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { boardForWorkItem } from "../boards/semantics.js";
|
|
2
|
+
import "../boards/index.js";
|
|
3
|
+
import { primeTenantCredentialsForTenant } from "../routes/tenant-credentials.js";
|
|
4
|
+
import { hydrateFactorySession, resolveFactorySessionModel } from "../session/factory-session.js";
|
|
5
|
+
import { resolveWorkItemRepository } from "../session/work-item-repository.js";
|
|
6
|
+
import { RequestContext } from "@mastra/core/request-context";
|
|
7
|
+
//#region src/rules/start-coordinator.ts
|
|
8
|
+
var WorkItemRepositoryError = class extends Error {
|
|
9
|
+
code;
|
|
10
|
+
candidates;
|
|
11
|
+
constructor(code, message, candidates = []) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.candidates = candidates;
|
|
15
|
+
this.name = "WorkItemRepositoryError";
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var FactoryStartTransitionError = class extends Error {
|
|
19
|
+
result;
|
|
20
|
+
constructor(result) {
|
|
21
|
+
super(result.reason);
|
|
22
|
+
this.name = "FactoryStartTransitionError";
|
|
23
|
+
this.result = result;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
async function resolveSourceSession(storage, request) {
|
|
27
|
+
const session = await storage.sessions.getBySessionId(request.sessionId);
|
|
28
|
+
if (!session || session.orgId !== request.orgId || session.userId !== request.userId) throw new Error("Factory session not found");
|
|
29
|
+
const projectRepositoryId = session.projectRepositoryId;
|
|
30
|
+
if (!projectRepositoryId) throw new Error("Factory session repository not found");
|
|
31
|
+
const projectRepository = await storage.projectRepositories.get({
|
|
32
|
+
orgId: request.orgId,
|
|
33
|
+
id: projectRepositoryId
|
|
34
|
+
});
|
|
35
|
+
if (!projectRepository) throw new Error("Factory session repository not found");
|
|
36
|
+
const connection = await storage.connections.get({
|
|
37
|
+
orgId: request.orgId,
|
|
38
|
+
id: projectRepository.connectionId
|
|
39
|
+
});
|
|
40
|
+
if (!connection || connection.factoryProjectId !== request.factoryProjectId) throw new Error("Factory session does not belong to this project");
|
|
41
|
+
return {
|
|
42
|
+
...session,
|
|
43
|
+
projectRepositoryId
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
async function configureThread(session, request) {
|
|
47
|
+
const threadId = session.thread.requireId();
|
|
48
|
+
await session.thread.rename({
|
|
49
|
+
title: request.threadTitle,
|
|
50
|
+
pin: false
|
|
51
|
+
});
|
|
52
|
+
await session.thread.setSetting({
|
|
53
|
+
key: "factorySessionId",
|
|
54
|
+
value: request.sessionId
|
|
55
|
+
});
|
|
56
|
+
return threadId;
|
|
57
|
+
}
|
|
58
|
+
var FactoryStartCoordinator = class {
|
|
59
|
+
#controller;
|
|
60
|
+
#storage;
|
|
61
|
+
#transitionService;
|
|
62
|
+
#sourceControl;
|
|
63
|
+
#intake;
|
|
64
|
+
#projects;
|
|
65
|
+
#modelDefaults;
|
|
66
|
+
constructor(controller, storage, transitionService, sourceControl, intake, sessionModel) {
|
|
67
|
+
this.#controller = controller;
|
|
68
|
+
this.#storage = storage;
|
|
69
|
+
this.#transitionService = transitionService;
|
|
70
|
+
this.#sourceControl = sourceControl;
|
|
71
|
+
this.#intake = intake;
|
|
72
|
+
this.#projects = sessionModel?.projects;
|
|
73
|
+
this.#modelDefaults = sessionModel?.modelDefaults;
|
|
74
|
+
}
|
|
75
|
+
async prepare(request) {
|
|
76
|
+
const storage = this.#storage;
|
|
77
|
+
const sourceControl = typeof this.#sourceControl === "function" ? await this.#sourceControl(request) : this.#sourceControl;
|
|
78
|
+
if (!sourceControl) throw new Error("Factory source control storage is unavailable");
|
|
79
|
+
const sourceSession = await resolveSourceSession(sourceControl, request);
|
|
80
|
+
const sessionModel = this.#projects && this.#modelDefaults ? await resolveFactorySessionModel({
|
|
81
|
+
projects: this.#projects,
|
|
82
|
+
modelDefaults: this.#modelDefaults,
|
|
83
|
+
factoryProjectId: request.factoryProjectId,
|
|
84
|
+
orgId: request.orgId,
|
|
85
|
+
ownerUserId: sourceSession.userId,
|
|
86
|
+
context: "run"
|
|
87
|
+
}) : {
|
|
88
|
+
modelScope: request.modelScope,
|
|
89
|
+
modelId: request.defaultModelId
|
|
90
|
+
};
|
|
91
|
+
const storedItem = request.workItem.id ? await storage.get({
|
|
92
|
+
orgId: request.orgId,
|
|
93
|
+
id: request.workItem.id
|
|
94
|
+
}) : null;
|
|
95
|
+
const intakeConfig = await this.#intake?.getConfig({
|
|
96
|
+
orgId: request.orgId,
|
|
97
|
+
integrationIds: ["linear"]
|
|
98
|
+
});
|
|
99
|
+
let repository = await resolveWorkItemRepository({
|
|
100
|
+
sourceControl,
|
|
101
|
+
orgId: request.orgId,
|
|
102
|
+
factoryProjectId: request.factoryProjectId,
|
|
103
|
+
item: storedItem ?? { metadata: request.workItem.input.metadata ?? null },
|
|
104
|
+
linearRepositoryMap: intakeConfig?.linear?.repositoryByLinearProject
|
|
105
|
+
});
|
|
106
|
+
if (repository.status === "ambiguous") {
|
|
107
|
+
if (storedItem?.sessions[request.workItem.role]?.sessionId !== sourceSession.sessionId) throw new WorkItemRepositoryError("repository_ambiguous", `Choose a repository for this work item: ${repository.candidates.join(", ")}.`, repository.candidates);
|
|
108
|
+
const link = await sourceControl.projectRepositories.get({
|
|
109
|
+
orgId: request.orgId,
|
|
110
|
+
id: sourceSession.projectRepositoryId
|
|
111
|
+
});
|
|
112
|
+
const linked = link && await sourceControl.repositories.get({
|
|
113
|
+
orgId: request.orgId,
|
|
114
|
+
id: link.repositoryId
|
|
115
|
+
});
|
|
116
|
+
const currentLinks = link ? await sourceControl.projectRepositories.list({
|
|
117
|
+
orgId: request.orgId,
|
|
118
|
+
connectionId: link.connectionId
|
|
119
|
+
}) : [];
|
|
120
|
+
if (!linked || !repository.candidates.includes(linked.slug) || !currentLinks.some((candidate) => candidate.id === sourceSession.projectRepositoryId)) throw new WorkItemRepositoryError("repository_unlinked", "The existing session repository is not linked to this Factory.");
|
|
121
|
+
repository = {
|
|
122
|
+
status: "resolved",
|
|
123
|
+
slug: linked.slug,
|
|
124
|
+
projectRepositoryId: sourceSession.projectRepositoryId
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
if (repository.status === "unlinked") throw new WorkItemRepositoryError("repository_unlinked", repository.hint);
|
|
128
|
+
if (repository.projectRepositoryId !== sourceSession.projectRepositoryId) throw new WorkItemRepositoryError("repository_mismatch", `This run session is bound to a different repository than ${repository.slug}.`);
|
|
129
|
+
const requestContext = request.requestContext ?? new RequestContext();
|
|
130
|
+
const existingUser = requestContext.get("user");
|
|
131
|
+
if (!existingUser || typeof existingUser !== "object") requestContext.set("user", {
|
|
132
|
+
workosId: request.userId,
|
|
133
|
+
organizationId: request.orgId
|
|
134
|
+
});
|
|
135
|
+
const untrustedCheckout = request.workItem.input.externalSource?.type === "pull-request";
|
|
136
|
+
const metadataBaseBranch = request.workItem.input.metadata?.baseBranch;
|
|
137
|
+
const baseRef = (sourceSession.baseBranch || void 0) ?? (typeof metadataBaseBranch === "string" && metadataBaseBranch ? metadataBaseBranch : void 0);
|
|
138
|
+
const sessionTags = {
|
|
139
|
+
factoryProjectId: request.factoryProjectId,
|
|
140
|
+
projectRepositoryId: sourceSession.projectRepositoryId
|
|
141
|
+
};
|
|
142
|
+
const session = await this.#controller.createSession({
|
|
143
|
+
id: sourceSession.sessionId,
|
|
144
|
+
ownerId: request.userId,
|
|
145
|
+
resourceId: sourceSession.sessionId,
|
|
146
|
+
threadId: sourceSession.sessionId,
|
|
147
|
+
requestContext,
|
|
148
|
+
tags: sessionTags
|
|
149
|
+
});
|
|
150
|
+
const targetRepositoryInstruction = `Target repository: ${repository.slug}. Before editing files or creating a pull request, verify this session's checkout matches the target repository.`;
|
|
151
|
+
const existingPluginInstructions = session.state.get()?.pluginInstructions ?? [];
|
|
152
|
+
await session.state.set({
|
|
153
|
+
...sessionTags,
|
|
154
|
+
factoryOrgId: request.orgId,
|
|
155
|
+
factoryModelScope: sessionModel.modelScope,
|
|
156
|
+
factoryOwnerUserId: sourceSession.userId,
|
|
157
|
+
pluginInstructions: [...existingPluginInstructions.filter((instruction) => instruction !== targetRepositoryInstruction), targetRepositoryInstruction],
|
|
158
|
+
...untrustedCheckout ? {
|
|
159
|
+
untrustedCheckout: true,
|
|
160
|
+
...baseRef ? { baseRef } : {}
|
|
161
|
+
} : {}
|
|
162
|
+
});
|
|
163
|
+
await primeTenantCredentialsForTenant({
|
|
164
|
+
orgId: request.orgId,
|
|
165
|
+
userId: sourceSession.userId,
|
|
166
|
+
credentialScope: sessionModel.modelScope
|
|
167
|
+
});
|
|
168
|
+
await hydrateFactorySession(session, {
|
|
169
|
+
orgId: request.orgId,
|
|
170
|
+
modelScope: sessionModel.modelScope,
|
|
171
|
+
ownerUserId: sourceSession.userId,
|
|
172
|
+
defaultModelId: sessionModel.modelId
|
|
173
|
+
});
|
|
174
|
+
await session.permissions.setForTool({
|
|
175
|
+
toolName: "factory_transition_work_item",
|
|
176
|
+
policy: "allow"
|
|
177
|
+
});
|
|
178
|
+
const threadId = await configureThread(session, request);
|
|
179
|
+
const prepared = await storage.prepareRunStart({
|
|
180
|
+
orgId: request.orgId,
|
|
181
|
+
userId: request.userId,
|
|
182
|
+
factoryProjectId: request.factoryProjectId,
|
|
183
|
+
workItem: {
|
|
184
|
+
id: request.workItem.id,
|
|
185
|
+
input: request.workItem.input
|
|
186
|
+
},
|
|
187
|
+
role: request.workItem.role,
|
|
188
|
+
session: {
|
|
189
|
+
sessionId: sourceSession.sessionId,
|
|
190
|
+
branch: sourceSession.branch,
|
|
191
|
+
threadId
|
|
192
|
+
},
|
|
193
|
+
resourceId: sourceSession.sessionId,
|
|
194
|
+
kickoffKey: request.kickoffKey,
|
|
195
|
+
kickoffMessage: null
|
|
196
|
+
});
|
|
197
|
+
await session.thread.setSetting({
|
|
198
|
+
key: "factoryWorkItemId",
|
|
199
|
+
value: prepared.item.id
|
|
200
|
+
});
|
|
201
|
+
let revision = prepared.item.revision;
|
|
202
|
+
const destinationStage = request.destinationStage;
|
|
203
|
+
if (destinationStage && (prepared.item.stages.length !== 1 || prepared.item.stages[0] !== destinationStage)) {
|
|
204
|
+
if (!this.#transitionService) throw new Error("Factory transition service is unavailable.");
|
|
205
|
+
const transition = await this.#transitionService.transition({
|
|
206
|
+
orgId: request.orgId,
|
|
207
|
+
factoryProjectId: request.factoryProjectId,
|
|
208
|
+
workItemId: prepared.item.id,
|
|
209
|
+
board: boardForWorkItem(prepared.item),
|
|
210
|
+
stage: destinationStage,
|
|
211
|
+
expectedRevision: prepared.item.revision,
|
|
212
|
+
actor: {
|
|
213
|
+
type: "human",
|
|
214
|
+
id: request.userId
|
|
215
|
+
},
|
|
216
|
+
ingress: {
|
|
217
|
+
type: "human",
|
|
218
|
+
identity: `start:${request.kickoffKey}:transition`
|
|
219
|
+
},
|
|
220
|
+
cause: "run_start"
|
|
221
|
+
});
|
|
222
|
+
if (transition.status === "rejected") {
|
|
223
|
+
await storage.markPendingStart(prepared.binding.id, "failed", transition.reason);
|
|
224
|
+
throw new FactoryStartTransitionError(transition);
|
|
225
|
+
}
|
|
226
|
+
revision = transition.revision;
|
|
227
|
+
}
|
|
228
|
+
await storage.markPendingStart(prepared.binding.id, "sent");
|
|
229
|
+
prepared.pendingStart.status = "sent";
|
|
230
|
+
return {
|
|
231
|
+
workItemId: prepared.item.id,
|
|
232
|
+
bindingId: prepared.binding.id,
|
|
233
|
+
threadId,
|
|
234
|
+
resourceId: sourceSession.sessionId,
|
|
235
|
+
sessionId: sourceSession.sessionId,
|
|
236
|
+
branch: sourceSession.branch,
|
|
237
|
+
revision,
|
|
238
|
+
kickoffStatus: prepared.pendingStart.status,
|
|
239
|
+
replayed: prepared.replayed
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
//#endregion
|
|
244
|
+
export { FactoryStartCoordinator, FactoryStartTransitionError, WorkItemRepositoryError };
|
|
245
|
+
|
|
246
|
+
//# sourceMappingURL=start-coordinator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-coordinator.js","names":["#controller","#storage","#transitionService","#sourceControl","#intake","#projects","#modelDefaults"],"sources":["../../src/rules/start-coordinator.ts"],"sourcesContent":["import type { MastraCodeState } from '@mastra/code-sdk/schema';\nimport type { AgentController } from '@mastra/core/agent-controller';\nimport { RequestContext } from '@mastra/core/request-context';\n\nimport { boardForWorkItem } from '../boards/index.js';\nimport { primeTenantCredentialsForTenant } from '../routes/tenant-credentials.js';\nimport { hydrateFactorySession, resolveFactorySessionModel } from '../session/factory-session.js';\nimport { resolveWorkItemRepository } from '../session/work-item-repository.js';\nimport type { IntakeStorage } from '../storage/domains/intake/base.js';\nimport type { ModelDefaultsStorage } from '../storage/domains/model-defaults/base.js';\nimport type { EffectiveModelScope, FactoryProjectsStorage } from '../storage/domains/projects/base.js';\nimport type { SourceControlSession, SourceControlStorageHandle } from '../storage/domains/source-control/base.js';\nimport type { CreateWorkItemInput, WorkItemsStorage } from '../storage/domains/work-items/base.js';\nimport type { FactoryTransitionService } from './transition-service.js';\nimport type { FactoryRuleStage, FactoryTransitionResult } from './types.js';\n\nexport interface FactoryStartRequest {\n orgId: string;\n userId: string;\n factoryProjectId: string;\n sessionId: string;\n threadTitle: string;\n kickoffKey: string;\n /** Where the arrival path lands the card; a session opened on an existing card names none. */\n destinationStage?: FactoryRuleStage;\n /** The run's effective scope; a hybrid Factory's runs use the Factory's model and credentials. */\n modelScope: EffectiveModelScope;\n defaultModelId?: string;\n workItem: {\n id?: string;\n role: string;\n input: CreateWorkItemInput;\n };\n requestContext?: RequestContext;\n}\n\nexport class WorkItemRepositoryError extends Error {\n constructor(\n readonly code: 'repository_mismatch' | 'repository_ambiguous' | 'repository_unlinked',\n message: string,\n readonly candidates: string[] = [],\n ) {\n super(message);\n this.name = 'WorkItemRepositoryError';\n }\n}\n\nexport class FactoryStartTransitionError extends Error {\n readonly result: Extract<FactoryTransitionResult, { status: 'rejected' }>;\n\n constructor(result: Extract<FactoryTransitionResult, { status: 'rejected' }>) {\n super(result.reason);\n this.name = 'FactoryStartTransitionError';\n this.result = result;\n }\n}\n\nexport interface FactoryStartPreparedResult {\n workItemId: string;\n bindingId: string;\n threadId: string;\n resourceId: string;\n sessionId: string;\n branch: string;\n revision: number;\n kickoffStatus: 'pending' | 'leased' | 'retry' | 'sent' | 'failed';\n replayed: boolean;\n}\n\ntype FactoryController = AgentController<MastraCodeState>;\ntype FactorySession = Awaited<ReturnType<FactoryController['createSession']>>;\n\nasync function resolveSourceSession(\n storage: SourceControlStorageHandle,\n request: FactoryStartRequest,\n): Promise<SourceControlSession & { projectRepositoryId: string }> {\n const session = await storage.sessions.getBySessionId(request.sessionId);\n if (!session || session.orgId !== request.orgId || session.userId !== request.userId) {\n throw new Error('Factory session not found');\n }\n const projectRepositoryId = session.projectRepositoryId;\n if (!projectRepositoryId) throw new Error('Factory session repository not found');\n const projectRepository = await storage.projectRepositories.get({ orgId: request.orgId, id: projectRepositoryId });\n if (!projectRepository) throw new Error('Factory session repository not found');\n const connection = await storage.connections.get({ orgId: request.orgId, id: projectRepository.connectionId });\n if (!connection || connection.factoryProjectId !== request.factoryProjectId) {\n throw new Error('Factory session does not belong to this project');\n }\n return { ...session, projectRepositoryId };\n}\n\nasync function configureThread(session: FactorySession, request: FactoryStartRequest): Promise<string> {\n const threadId = session.thread.requireId();\n // Derived from the work item, not a user rename, so leave the title\n // unpinned and let auto-naming keep refining it.\n await session.thread.rename({ title: request.threadTitle, pin: false });\n await session.thread.setSetting({ key: 'factorySessionId', value: request.sessionId });\n return threadId;\n}\n\nexport class FactoryStartCoordinator {\n readonly #controller: FactoryController;\n readonly #storage: WorkItemsStorage;\n readonly #transitionService?: Pick<FactoryTransitionService, 'transition'>;\n readonly #sourceControl?:\n | SourceControlStorageHandle\n | ((\n request: FactoryStartRequest,\n ) => SourceControlStorageHandle | undefined | Promise<SourceControlStorageHandle | undefined>);\n readonly #intake?: IntakeStorage;\n readonly #projects?: FactoryProjectsStorage;\n readonly #modelDefaults?: ModelDefaultsStorage;\n\n constructor(\n controller: FactoryController,\n storage: WorkItemsStorage,\n transitionService?: Pick<FactoryTransitionService, 'transition'>,\n sourceControl?:\n | SourceControlStorageHandle\n | ((\n request: FactoryStartRequest,\n ) => SourceControlStorageHandle | undefined | Promise<SourceControlStorageHandle | undefined>),\n intake?: IntakeStorage,\n sessionModel?: { projects: FactoryProjectsStorage; modelDefaults: ModelDefaultsStorage },\n ) {\n this.#controller = controller;\n this.#storage = storage;\n this.#transitionService = transitionService;\n this.#sourceControl = sourceControl;\n this.#intake = intake;\n this.#projects = sessionModel?.projects;\n this.#modelDefaults = sessionModel?.modelDefaults;\n }\n\n async prepare(request: FactoryStartRequest): Promise<FactoryStartPreparedResult> {\n const storage = this.#storage;\n const sourceControl =\n typeof this.#sourceControl === 'function' ? await this.#sourceControl(request) : this.#sourceControl;\n if (!sourceControl) throw new Error('Factory source control storage is unavailable');\n const sourceSession = await resolveSourceSession(sourceControl, request);\n const sessionModel =\n this.#projects && this.#modelDefaults\n ? await resolveFactorySessionModel({\n projects: this.#projects,\n modelDefaults: this.#modelDefaults,\n factoryProjectId: request.factoryProjectId,\n orgId: request.orgId,\n ownerUserId: sourceSession.userId,\n context: 'run',\n })\n : { modelScope: request.modelScope, modelId: request.defaultModelId };\n const storedItem = request.workItem.id\n ? await storage.get({ orgId: request.orgId, id: request.workItem.id })\n : null;\n const intakeConfig = await this.#intake?.getConfig({ orgId: request.orgId, integrationIds: ['linear'] });\n let repository = await resolveWorkItemRepository({\n sourceControl,\n orgId: request.orgId,\n factoryProjectId: request.factoryProjectId,\n item: storedItem ?? { metadata: request.workItem.input.metadata ?? null },\n linearRepositoryMap: intakeConfig?.linear?.repositoryByLinearProject,\n });\n if (repository.status === 'ambiguous') {\n // A retry of this role's existing session keeps its already-chosen\n // repository; a newly minted session must not choose for the card.\n if (storedItem?.sessions[request.workItem.role]?.sessionId !== sourceSession.sessionId) {\n throw new WorkItemRepositoryError(\n 'repository_ambiguous',\n `Choose a repository for this work item: ${repository.candidates.join(', ')}.`,\n repository.candidates,\n );\n }\n const link = await sourceControl.projectRepositories.get({\n orgId: request.orgId,\n id: sourceSession.projectRepositoryId,\n });\n const linked = link && (await sourceControl.repositories.get({ orgId: request.orgId, id: link.repositoryId }));\n const currentLinks = link\n ? await sourceControl.projectRepositories.list({ orgId: request.orgId, connectionId: link.connectionId })\n : [];\n if (\n !linked ||\n !repository.candidates.includes(linked.slug) ||\n !currentLinks.some(candidate => candidate.id === sourceSession.projectRepositoryId)\n ) {\n throw new WorkItemRepositoryError(\n 'repository_unlinked',\n 'The existing session repository is not linked to this Factory.',\n );\n }\n repository = { status: 'resolved', slug: linked.slug, projectRepositoryId: sourceSession.projectRepositoryId };\n }\n if (repository.status === 'unlinked') {\n throw new WorkItemRepositoryError('repository_unlinked', repository.hint);\n }\n if (repository.projectRepositoryId !== sourceSession.projectRepositoryId) {\n throw new WorkItemRepositoryError(\n 'repository_mismatch',\n `This run session is bound to a different repository than ${repository.slug}.`,\n );\n }\n const requestContext = request.requestContext ?? new RequestContext();\n // Preserve an authenticated caller when present. Autonomous starts still\n // need a principal so deployed credential resolution can authenticate the\n // request before selecting the stamped session owner's exclusive scope.\n const existingUser = requestContext.get('user');\n if (!existingUser || typeof existingUser !== 'object') {\n requestContext.set('user', {\n workosId: request.userId,\n organizationId: request.orgId,\n });\n }\n // Sessions kicked off against third-party content (a PR under review, or\n // any pull-request-sourced work item) get `untrustedCheckout` so the SDK\n // never ingests the checkout's AGENTS.md/CLAUDE.md into the system prompt\n // or reminders — those files are attacker-writable in a PR branch.\n const untrustedCheckout = request.workItem.input.externalSource?.type === 'pull-request';\n // The trusted ref the SDK may serve project instruction files from on an\n // untrusted checkout (the PR's base branch). Prefer the session record's\n // base branch; fall back to the intake metadata captured from the PR.\n const metadataBaseBranch = request.workItem.input.metadata?.baseBranch;\n const baseRef =\n (sourceSession.baseBranch || undefined) ??\n (typeof metadataBaseBranch === 'string' && metadataBaseBranch ? metadataBaseBranch : undefined);\n const sessionTags = {\n factoryProjectId: request.factoryProjectId,\n projectRepositoryId: sourceSession.projectRepositoryId,\n };\n const session = await this.#controller.createSession({\n id: sourceSession.sessionId,\n ownerId: request.userId,\n resourceId: sourceSession.sessionId,\n threadId: sourceSession.sessionId,\n requestContext,\n tags: sessionTags,\n });\n // Bound-agent authority gates (the transition tool, the factory-phase\n // processor, workspace token selection) resolve the session address from\n // controller state. Seed it server-side — `tags` covers fresh creation,\n // the explicit setState covers get-or-create returning a session another\n // caller created without them — so autonomous runs never depend on a\n // browser connecting to populate the state. `untrustedCheckout` is a\n // boolean so it rides only on state (tags are string-valued).\n const targetRepositoryInstruction = `Target repository: ${repository.slug}. Before editing files or creating a pull request, verify this session's checkout matches the target repository.`;\n const existingPluginInstructions = session.state.get()?.pluginInstructions ?? [];\n await session.state.set({\n ...sessionTags,\n // The authoritative org id for every downstream identity read (the\n // memory seam's organizationId): the session owner is a USER id, not an\n // org, so it must never be improvised from ownerId.\n factoryOrgId: request.orgId,\n factoryModelScope: sessionModel.modelScope,\n factoryOwnerUserId: sourceSession.userId,\n pluginInstructions: [\n ...existingPluginInstructions.filter(instruction => instruction !== targetRepositoryInstruction),\n targetRepositoryInstruction,\n ],\n ...(untrustedCheckout ? { untrustedCheckout: true, ...(baseRef ? { baseRef } : {}) } : {}),\n });\n await primeTenantCredentialsForTenant({\n orgId: request.orgId,\n userId: sourceSession.userId,\n credentialScope: sessionModel.modelScope,\n });\n // Apply the factory's main model before any model-dependent run work.\n // Observational-memory settings are loaded per invocation by the input processor.\n await hydrateFactorySession(session, {\n orgId: request.orgId,\n modelScope: sessionModel.modelScope,\n ownerUserId: sourceSession.userId,\n defaultModelId: sessionModel.modelId,\n });\n // The tool is `requireApproval`, and that prompt parks the run whether or not\n // someone pressed Start — a person is reading the plan, not an approval queue.\n // Starting the run was already the say-so; the rules engine still governs.\n await session.permissions.setForTool({ toolName: 'factory_transition_work_item', policy: 'allow' });\n const threadId = await configureThread(session, request);\n const prepared = await storage.prepareRunStart({\n orgId: request.orgId,\n userId: request.userId,\n factoryProjectId: request.factoryProjectId,\n workItem: { id: request.workItem.id, input: request.workItem.input },\n role: request.workItem.role,\n session: { sessionId: sourceSession.sessionId, branch: sourceSession.branch, threadId },\n resourceId: sourceSession.sessionId,\n kickoffKey: request.kickoffKey,\n kickoffMessage: null,\n });\n await session.thread.setSetting({ key: 'factoryWorkItemId', value: prepared.item.id });\n\n let revision = prepared.item.revision;\n const destinationStage = request.destinationStage;\n if (destinationStage && (prepared.item.stages.length !== 1 || prepared.item.stages[0] !== destinationStage)) {\n if (!this.#transitionService) throw new Error('Factory transition service is unavailable.');\n const transition = await this.#transitionService.transition({\n orgId: request.orgId,\n factoryProjectId: request.factoryProjectId,\n workItemId: prepared.item.id,\n board: boardForWorkItem(prepared.item),\n stage: destinationStage,\n expectedRevision: prepared.item.revision,\n actor: { type: 'human', id: request.userId },\n ingress: { type: 'human', identity: `start:${request.kickoffKey}:transition` },\n cause: 'run_start',\n });\n if (transition.status === 'rejected') {\n await storage.markPendingStart(prepared.binding.id, 'failed', transition.reason);\n throw new FactoryStartTransitionError(transition);\n }\n revision = transition.revision;\n }\n\n await storage.markPendingStart(prepared.binding.id, 'sent');\n prepared.pendingStart.status = 'sent';\n\n return {\n workItemId: prepared.item.id,\n bindingId: prepared.binding.id,\n threadId,\n resourceId: sourceSession.sessionId,\n sessionId: sourceSession.sessionId,\n branch: sourceSession.branch,\n revision,\n kickoffStatus: prepared.pendingStart.status,\n replayed: prepared.replayed,\n };\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { FactoryRunBindingRecord, WorkItemsStorage } from '../storage/domains/work-items/base.js';
|
|
2
|
+
export interface TerminalStageCleanupOptions {
|
|
3
|
+
workItems: Pick<WorkItemsStorage, 'get' | 'listRunBindings' | 'revokeRunBindingsForWorkItem' | 'supersedeTerminalDecisionsForWorkItem' | 'findRunBindingBySession'>;
|
|
4
|
+
/** Final ingest of trailing tool results before the binding is revoked. */
|
|
5
|
+
reconcileBinding?: (binding: FactoryRunBindingRecord) => Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Abort the live controller run bound to a retired seat. Without this the
|
|
8
|
+
* model keeps executing unbound after its binding is revoked (its transition
|
|
9
|
+
* tool vanishes or throws), and the parked run can later be resumed and
|
|
10
|
+
* rationalize a false blocked state.
|
|
11
|
+
*/
|
|
12
|
+
abortSession?: (binding: FactoryRunBindingRecord) => Promise<void>;
|
|
13
|
+
/** Release the item's session sandboxes back to the reuse pool. */
|
|
14
|
+
releaseSandboxes?: (args: TerminalStageCleanupArgs) => Promise<unknown>;
|
|
15
|
+
}
|
|
16
|
+
export interface TerminalStageCleanupArgs {
|
|
17
|
+
orgId: string;
|
|
18
|
+
factoryProjectId: string;
|
|
19
|
+
workItemId: string;
|
|
20
|
+
/** Revision produced by the terminal transition that scheduled this cleanup. */
|
|
21
|
+
revision?: number;
|
|
22
|
+
/**
|
|
23
|
+
* The bound agent seat whose own tool call drove this terminal transition, if
|
|
24
|
+
* any. Its run is already returning from the tool call; aborting it would
|
|
25
|
+
* interrupt its own completion, so it is left alone.
|
|
26
|
+
*/
|
|
27
|
+
initiatingBindingId?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Terminal-stage cleanup for a work item: ingest any trailing tool results
|
|
31
|
+
* from the item's bound threads, revoke its active run bindings so completed
|
|
32
|
+
* items leave the reconcile walk (the active set otherwise grows forever),
|
|
33
|
+
* dismiss the runs still parked on it, then release its sandboxes. Every step
|
|
34
|
+
* is best-effort — a committed transition never fails on cleanup; leaked
|
|
35
|
+
* bindings are drained by the staleness sweep.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createTerminalStageCleanup(options: TerminalStageCleanupOptions): (args: TerminalStageCleanupArgs) => Promise<void>;
|
|
38
|
+
//# sourceMappingURL=terminal-cleanup.d.ts.map
|