@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,248 @@
|
|
|
1
|
+
import { timedPhase } from "../timing.js";
|
|
2
|
+
import { SETUP_FAILED_MARKER_PATH, SETUP_MARKER_PATH, WORKSPACE_SETUP_MARKER_PATH, repoSetupMarkerPath, setupMarkerContent } from "../packages/_internals/workspace/dist/index.js";
|
|
3
|
+
import { deriveLocalWorkdir, deriveRemoteRepoDir, repoDirUnder, repositoryDirectoryName } from "./workdir.js";
|
|
4
|
+
import path from "path";
|
|
5
|
+
//#region src/sandbox/session-sandbox.ts
|
|
6
|
+
const sessionSandboxes = /* @__PURE__ */ new Map();
|
|
7
|
+
/** The layout of a memoized session, `undefined` until its workdir resolved. */
|
|
8
|
+
function sessionLayout(entry) {
|
|
9
|
+
if (!entry?.workdir) return void 0;
|
|
10
|
+
const slugs = entry.repos?.length ? entry.repos : [entry.ownRepo];
|
|
11
|
+
if (slugs.length === 1) return {
|
|
12
|
+
root: entry.workdir,
|
|
13
|
+
repos: [{
|
|
14
|
+
slug: slugs[0],
|
|
15
|
+
dir: entry.workdir,
|
|
16
|
+
prefix: ""
|
|
17
|
+
}]
|
|
18
|
+
};
|
|
19
|
+
const root = path.posix.dirname(entry.workdir);
|
|
20
|
+
return {
|
|
21
|
+
root,
|
|
22
|
+
repos: slugs.map((slug) => {
|
|
23
|
+
const dir = slug.toLowerCase() === entry.ownRepo.toLowerCase() ? entry.workdir : repoDirUnder(root, slug);
|
|
24
|
+
return {
|
|
25
|
+
slug,
|
|
26
|
+
dir,
|
|
27
|
+
prefix: `${path.posix.basename(dir)}/`
|
|
28
|
+
};
|
|
29
|
+
})
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get the session's memoized sandbox entry, constructing (and memoizing) it on
|
|
34
|
+
* first access. Construction is cheap and side-effect-free by contract; VMs
|
|
35
|
+
* are provisioned on `start()` only. Local sandboxes get their workdir here;
|
|
36
|
+
* remote workdirs are a runtime fact of the VM, resolved on first start.
|
|
37
|
+
*/
|
|
38
|
+
function getSessionSandbox(sessionId, repoFullName, construct, repos) {
|
|
39
|
+
const existing = sessionSandboxes.get(sessionId);
|
|
40
|
+
if (existing) {
|
|
41
|
+
if (repos) existing.repos = repos;
|
|
42
|
+
return existing;
|
|
43
|
+
}
|
|
44
|
+
const sandbox = construct();
|
|
45
|
+
const local = deriveLocalWorkdir(sandbox, repoFullName);
|
|
46
|
+
const entry = {
|
|
47
|
+
sandbox,
|
|
48
|
+
ownRepo: repoFullName,
|
|
49
|
+
...local ? { workdir: local } : {},
|
|
50
|
+
...repos ? { repos } : {}
|
|
51
|
+
};
|
|
52
|
+
sessionSandboxes.set(sessionId, entry);
|
|
53
|
+
return entry;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Resolve (and memoize on the session entry) the session's repo checkout
|
|
57
|
+
* root. Local sandboxes answer synchronously from their configured
|
|
58
|
+
* `workingDirectory`; remote sandboxes clone into the VM's own default cwd,
|
|
59
|
+
* so the first resolution probes it with one `pwd` — the VM tells us where
|
|
60
|
+
* home is, we never invent a path. Calling this against a stopped sandbox
|
|
61
|
+
* lazily starts it (the probe is a command), so passive readers must peek
|
|
62
|
+
* `entry.workdir` instead. The memo is the session's own checkout; another
|
|
63
|
+
* environment repository lives beside it under the same root, so it is
|
|
64
|
+
* answered from the memo's parent without a second probe.
|
|
65
|
+
*/
|
|
66
|
+
async function resolveSessionWorkdir(sessionId, sandbox, repoFullName) {
|
|
67
|
+
const entry = sessionSandboxes.get(sessionId);
|
|
68
|
+
const memo = entry && entry.sandbox === sandbox ? entry : void 0;
|
|
69
|
+
if (memo && memo.ownRepo !== repoFullName) {
|
|
70
|
+
const own = await resolveSessionWorkdir(sessionId, sandbox, memo.ownRepo);
|
|
71
|
+
return repoDirUnder(path.posix.dirname(own), repoFullName);
|
|
72
|
+
}
|
|
73
|
+
if (memo?.workdir) return memo.workdir;
|
|
74
|
+
const workdir = deriveLocalWorkdir(sandbox, repoFullName) ?? deriveRemoteRepoDir(sandbox, repoFullName) ?? repoDirUnder(await probeHome(sandbox), repoFullName);
|
|
75
|
+
if (memo) memo.workdir = workdir;
|
|
76
|
+
return workdir;
|
|
77
|
+
}
|
|
78
|
+
/** One `pwd` in the VM's default shell cwd — its home dir, by provider convention. */
|
|
79
|
+
async function probeHome(sandbox) {
|
|
80
|
+
if (!sandbox.executeCommand) throw new Error(`Sandbox '${sandbox.id}' cannot resolve its workdir: no executeCommand implementation`);
|
|
81
|
+
const probe = await sandbox.executeCommand("pwd");
|
|
82
|
+
const home = probe.stdout.trim().split("\n").pop()?.trim() ?? "";
|
|
83
|
+
if (probe.exitCode !== 0 || !home.startsWith("/")) throw new Error(`Sandbox '${sandbox.id}' default cwd probe failed (exit ${probe.exitCode}): ${probe.stderr.trim() || probe.stdout.trim() || "empty output"}`);
|
|
84
|
+
return home;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The session's memoized sandbox (and its workdir) when one was already
|
|
88
|
+
* constructed in this process, else undefined. Never constructs — passive
|
|
89
|
+
* read paths use this so browsing files cannot provision a VM.
|
|
90
|
+
*/
|
|
91
|
+
function peekSessionSandbox(sessionId) {
|
|
92
|
+
return sessionSandboxes.get(sessionId);
|
|
93
|
+
}
|
|
94
|
+
/** Drop the memoized instance (on stop/destroy/retirement or construction failure). */
|
|
95
|
+
function evictSessionSandbox(sessionId) {
|
|
96
|
+
sessionSandboxes.delete(sessionId);
|
|
97
|
+
failedSetupCommands.delete(sessionId);
|
|
98
|
+
}
|
|
99
|
+
/** Test-only: reset the process-wide memo between tests. */
|
|
100
|
+
function __clearSessionSandboxesForTests() {
|
|
101
|
+
sessionSandboxes.clear();
|
|
102
|
+
failedSetupCommands.clear();
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Setup commands that already failed once for a session. The first failure
|
|
106
|
+
* fails the start loudly — the agent sees the real error in the tool result
|
|
107
|
+
* that triggered it. Recording it lets the next start skip the known-bad
|
|
108
|
+
* command instead of wedging the session behind a permanently failing
|
|
109
|
+
* onStart: clone and checkout still run, and the agent can fix or re-run
|
|
110
|
+
* the setup itself. Keyed by the exact command, one entry per failed command, so an
|
|
111
|
+
* edited setup command runs fresh. In-memory only — a server restart re-runs the (idempotent)
|
|
112
|
+
* setup.
|
|
113
|
+
*/
|
|
114
|
+
const failedSetupCommands = /* @__PURE__ */ new Map();
|
|
115
|
+
function recordFailedSetupCommand(sessionId, command) {
|
|
116
|
+
const failed = failedSetupCommands.get(sessionId) ?? /* @__PURE__ */ new Set();
|
|
117
|
+
failed.add(command);
|
|
118
|
+
failedSetupCommands.set(sessionId, failed);
|
|
119
|
+
}
|
|
120
|
+
function hasFailedSetupCommand(sessionId, command) {
|
|
121
|
+
return failedSetupCommands.get(sessionId)?.has(command) ?? false;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The setup completion marker is a convention shared with the repo templates
|
|
125
|
+
* (`@internal/workspace`): `.mastra-sandbox/setup` beside the checkout,
|
|
126
|
+
* containing a digest of the setup commands. Templates write it as their last
|
|
127
|
+
* build step, so a sandbox booted from a warm image already carries it; the
|
|
128
|
+
* start hook writes it after a successful runtime setup. It is a skip cache,
|
|
129
|
+
* not a correctness mechanism: the setup command is assumed idempotent, and a
|
|
130
|
+
* missing or mismatched marker only re-runs it.
|
|
131
|
+
*
|
|
132
|
+
* The working directory is the parent of the repo dir, which is also the
|
|
133
|
+
* template's build cwd, so this is the file the template's marker step wrote.
|
|
134
|
+
*/
|
|
135
|
+
function markerShellPath(workdir) {
|
|
136
|
+
return `${path.posix.dirname(workdir)}/${SETUP_MARKER_PATH}`;
|
|
137
|
+
}
|
|
138
|
+
async function markerMatches(sandbox, workdir, content) {
|
|
139
|
+
const marker = markerShellPath(workdir);
|
|
140
|
+
return (await sandbox.executeCommand(`test -d "${workdir}/.git" && test -f "${marker}" && [ "$(cat "${marker}")" = "${content}" ]`)).exitCode === 0;
|
|
141
|
+
}
|
|
142
|
+
async function writeMarker(sandbox, workdir, content) {
|
|
143
|
+
const marker = markerShellPath(workdir);
|
|
144
|
+
await sandbox.executeCommand(`mkdir -p "$(dirname "${marker}")" && printf '%s' '${content}' > "${marker}"`).catch(() => {});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Build the session setup hook, which factory attaches to the constructed
|
|
148
|
+
* sandbox with `setOnStart`. Runs inside the sandbox start lifecycle on
|
|
149
|
+
* every start, fresh VM or reconnect: materialize and checkout always run,
|
|
150
|
+
* and the setup command runs unless the sandbox already carries the marker
|
|
151
|
+
* for it (a warm template image, or an earlier successful start). Throwing
|
|
152
|
+
* fails `start()` loudly; core treats onStart errors as fatal.
|
|
153
|
+
*/
|
|
154
|
+
function createSessionSetupHook(run, sessionId, repoFullName, setupCommand) {
|
|
155
|
+
const marker = setupCommand?.trim() ? setupMarkerContent(setupCommand) : void 0;
|
|
156
|
+
return async ({ sandbox }) => {
|
|
157
|
+
if (!sandbox.executeCommand) throw new Error(`Sandbox '${sandbox.id}' cannot run the session setup: no executeCommand implementation`);
|
|
158
|
+
const workdir = await resolveSessionWorkdir(sessionId, sandbox, repoFullName);
|
|
159
|
+
const setupDone = marker ? await timedPhase("workspace.setup-marker", () => markerMatches(sandbox, workdir, marker)) : true;
|
|
160
|
+
if (marker) process.stderr.write(`[factory:setup] ${setupDone ? "marker matches, skipping setup command" : "no matching marker, setup command will run"} (${markerShellPath(workdir)})\n`);
|
|
161
|
+
await run(sandbox, workdir, {
|
|
162
|
+
setupDone,
|
|
163
|
+
markSetupDone: () => marker ? writeMarker(sandbox, workdir, marker) : Promise.resolve()
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Shell-quote one marker file's content. Marker contents are digests, but
|
|
169
|
+
* the quoting keeps an edited command's digest from ever reaching the shell
|
|
170
|
+
* unquoted.
|
|
171
|
+
*/
|
|
172
|
+
function shellQuote(value) {
|
|
173
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* The list-form marker probe: trust a repository's marker only when its
|
|
177
|
+
* checkout exists, the marker names this command, and the template did not
|
|
178
|
+
* record the repository in `setup-failed` (a failed per-repo setup still
|
|
179
|
+
* writes the marker because every step ran; the failure list says it failed).
|
|
180
|
+
*/
|
|
181
|
+
async function repoMarkerMatches(sandbox, root, repoDir, content) {
|
|
182
|
+
const marker = `${root}/${repoSetupMarkerPath(repoDir)}`;
|
|
183
|
+
const failed = `${root}/${SETUP_FAILED_MARKER_PATH}`;
|
|
184
|
+
return (await sandbox.executeCommand(`test -d "${root}/${repoDir}/.git" && test -f "${marker}" && [ "$(cat "${marker}")" = ${shellQuote(content)} ] && ! grep -qxF -- ${shellQuote(repoDir)} "${failed}" 2>/dev/null`)).exitCode === 0;
|
|
185
|
+
}
|
|
186
|
+
/** Write a repository's marker and drop it from `setup-failed`. Best-effort, like `writeMarker`. */
|
|
187
|
+
async function writeRepoMarker(sandbox, root, repoDir, content) {
|
|
188
|
+
const marker = `${root}/${repoSetupMarkerPath(repoDir)}`;
|
|
189
|
+
const failed = `${root}/${SETUP_FAILED_MARKER_PATH}`;
|
|
190
|
+
await sandbox.executeCommand(`mkdir -p "$(dirname "${marker}")" && printf '%s' ${shellQuote(content)} > "${marker}" && { test -f "${failed}" && { grep -vxF -- ${shellQuote(repoDir)} "${failed}" > "${failed}.tmp" || true; } && mv "${failed}.tmp" "${failed}" || true; }`).catch(() => {});
|
|
191
|
+
}
|
|
192
|
+
async function workspaceMarkerMatches(sandbox, root, content) {
|
|
193
|
+
const marker = `${root}/${WORKSPACE_SETUP_MARKER_PATH}`;
|
|
194
|
+
return (await sandbox.executeCommand(`test -f "${marker}" && [ "$(cat "${marker}")" = ${shellQuote(content)} ]`)).exitCode === 0;
|
|
195
|
+
}
|
|
196
|
+
async function writeWorkspaceMarker(sandbox, root, content) {
|
|
197
|
+
const marker = `${root}/${WORKSPACE_SETUP_MARKER_PATH}`;
|
|
198
|
+
await sandbox.executeCommand(`mkdir -p "$(dirname "${marker}")" && printf '%s' ${shellQuote(content)} > "${marker}"`).catch(() => {});
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* The list-form start hook for a session whose factory has an environment:
|
|
202
|
+
* the same lifecycle as `createSessionSetupHook`, with one gate per
|
|
203
|
+
* repository plus one for the workspace setup command. The markers are the
|
|
204
|
+
* ones the multi-repo templates write (`.mastra-sandbox/repos/<repoDir>`,
|
|
205
|
+
* `.mastra-sandbox/workspace-setup`, `.mastra-sandbox/setup-failed`), all
|
|
206
|
+
* under the workspace root, which is the parent of the primary repository's
|
|
207
|
+
* directory: `resolveSessionWorkdir` keeps answering that directory so the
|
|
208
|
+
* PR tools and passive readers see the primary checkout, and the root is
|
|
209
|
+
* derived from it rather than probed twice.
|
|
210
|
+
*
|
|
211
|
+
* `repos` is in position order and must include the primary (`repoFullName`).
|
|
212
|
+
*/
|
|
213
|
+
function createEnvironmentSetupHook(run, sessionId, repoFullName, environment) {
|
|
214
|
+
const workspaceCommand = environment.workspaceSetupCommand?.trim() ? environment.workspaceSetupCommand : void 0;
|
|
215
|
+
const workspaceMarker = workspaceCommand ? setupMarkerContent(workspaceCommand) : void 0;
|
|
216
|
+
return async ({ sandbox }) => {
|
|
217
|
+
if (!sandbox.executeCommand) throw new Error(`Sandbox '${sandbox.id}' cannot run the session setup: no executeCommand implementation`);
|
|
218
|
+
const workdir = await resolveSessionWorkdir(sessionId, sandbox, repoFullName);
|
|
219
|
+
const root = path.posix.dirname(workdir);
|
|
220
|
+
const repos = [];
|
|
221
|
+
for (const repo of environment.repos) {
|
|
222
|
+
const repoDir = repositoryDirectoryName(repo.slug);
|
|
223
|
+
const marker = repo.setupCommand?.trim() ? setupMarkerContent(repo.setupCommand) : void 0;
|
|
224
|
+
const setupDone = marker ? await timedPhase(`workspace.setup-marker(${repoDir})`, () => repoMarkerMatches(sandbox, root, repoDir, marker)) : true;
|
|
225
|
+
if (marker) process.stderr.write(`[factory:setup] ${repo.slug}: ${setupDone ? "marker matches, skipping setup command" : "no matching marker, setup command will run"} (${root}/${repoSetupMarkerPath(repoDir)})\n`);
|
|
226
|
+
repos.push({
|
|
227
|
+
...repo,
|
|
228
|
+
dir: `${root}/${repoDir}`,
|
|
229
|
+
gate: {
|
|
230
|
+
setupDone,
|
|
231
|
+
markSetupDone: () => marker ? writeRepoMarker(sandbox, root, repoDir, marker) : Promise.resolve()
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
await run(sandbox, {
|
|
236
|
+
root,
|
|
237
|
+
repos,
|
|
238
|
+
workspace: {
|
|
239
|
+
setupDone: workspaceMarker ? await timedPhase("workspace.setup-marker(workspace)", () => workspaceMarkerMatches(sandbox, root, workspaceMarker)) : true,
|
|
240
|
+
markSetupDone: () => workspaceMarker ? writeWorkspaceMarker(sandbox, root, workspaceMarker) : Promise.resolve()
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
//#endregion
|
|
246
|
+
export { __clearSessionSandboxesForTests, createEnvironmentSetupHook, createSessionSetupHook, evictSessionSandbox, getSessionSandbox, hasFailedSetupCommand, peekSessionSandbox, recordFailedSetupCommand, resolveSessionWorkdir, sessionLayout };
|
|
247
|
+
|
|
248
|
+
//# sourceMappingURL=session-sandbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-sandbox.js","names":[],"sources":["../../src/sandbox/session-sandbox.ts"],"sourcesContent":["import path from 'node:path';\nimport {\n SETUP_FAILED_MARKER_PATH,\n SETUP_MARKER_PATH,\n WORKSPACE_SETUP_MARKER_PATH,\n repoSetupMarkerPath,\n setupMarkerContent,\n} from '@internal/workspace';\n\nimport type {\n FactorySandbox,\n FactorySandboxContext as CoreFactorySandboxContext,\n MastraSandbox,\n SandboxStartHook,\n WorkspaceSandbox,\n} from '@mastra/core/workspace';\nimport { timedPhase } from '../timing.js';\nimport { deriveLocalWorkdir, deriveRemoteRepoDir, repoDirUnder, repositoryDirectoryName } from './workdir.js';\n\n/**\n * Everything factory knows about a session's sandbox needs: the whole contract\n * between factory and the host's FactorySandbox. Factory owns intent; the\n * provider owns resolving `sessionId` to a runnable VM. Defined in\n * `@mastra/core/workspace` so provider packages can implement it without\n * depending on factory.\n */\nexport type FactorySandboxContext = CoreFactorySandboxContext;\n\n/**\n * The deploy's sandbox configuration: construct a session's sandbox from\n * intent. The sandbox identity is the session id; the provider must honor\n * id-keyed getOrCreate on `start()` (reconnect/resume an existing VM for the\n * id, create otherwise). Construction must be cheap and side-effect-free —\n * VMs are provisioned on `start()` only. Local sandboxes should root their\n * `workingDirectory` at a per-session directory (e.g.\n * `join(root, ctx.sessionId)`); the repo checks out as a subdirectory of it.\n *\n * Forward `ctx.sandboxId` to providers that reattach by physical id so resume\n * reattaches the original VM instead of provisioning a replacement.\n *\n * Returns a `MastraSandbox`, not the bare `WorkspaceSandbox` interface:\n * factory relies on the base class for the start lifecycle and the runtime\n * env, so providers extend it rather than reimplementing the contract.\n *\n * Factory attaches its own session setup to the returned sandbox, so the\n * callback never has to wire it up. A callback may still pass its own\n * `onStart`; it runs after factory's setup, against a prepared workspace.\n *\n * @example\n * ```typescript\n * sandbox: ({ sessionId, sandboxId }) => new E2BSandbox({ id: sessionId, sandboxId })\n * ```\n *\n * A FactorySandbox instance (for example `new E2BFactorySandbox({ apiKey })`)\n * additionally exposes settings and template builds to the environment.\n */\nexport type MastraFactorySandboxConfig = (ctx: FactorySandboxContext) => MastraSandbox;\n\n/**\n * The `sandbox` option of `MastraFactoryConfig`: a FactorySandbox instance\n * (it owns the session sandbox constructor, the repo template and the\n * environment settings schema) or a bare callback, which the factory wraps as a `provider: 'custom'` sandbox with no settings.\n */\nexport type MastraFactorySandboxOption = FactorySandbox | MastraFactorySandboxConfig;\n\n/**\n * What the start hook learned about the setup command before running the\n * session setup, and how to record its completion afterwards.\n */\nexport interface SessionSetupGate {\n /** True when the sandbox already carries a marker for the current setup command. */\n setupDone: boolean;\n /** Write the marker once the setup command succeeded. Best-effort. */\n markSetupDone: () => Promise<void>;\n}\n\n/**\n * The session's setup work, run against a started sandbox on EVERY start.\n * Materialize and checkout are idempotent and must always run (a warm boot\n * still needs its pull); only the setup command consults `gate`.\n */\nexport type SessionSetupRun = (sandbox: WorkspaceSandbox, workdir: string, gate: SessionSetupGate) => Promise<void>;\n\n/** One environment repository as the boot hook needs it: its slug and setup command. */\nexport interface SessionEnvironmentRepository {\n slug: string;\n setupCommand?: string;\n}\n\n/** What the environment hook learned about one repository before the boot runs. */\nexport interface SessionEnvironmentRepositoryGate extends SessionEnvironmentRepository {\n /** `<root>/<repoDir>`, the directory the template cloned this repository into. */\n dir: string;\n gate: SessionSetupGate;\n}\n\n/** The environment hook's view of the workspace: the root, every repository in position order, the workspace gate. */\nexport interface SessionEnvironmentGate {\n /** The workspace root, parent of every repository directory. */\n root: string;\n repos: SessionEnvironmentRepositoryGate[];\n /** Gate for `workspaceSetupCommand`; `setupDone` when there is no command or its marker matches. */\n workspace: SessionSetupGate;\n}\n\n/** The list-form session boot: run on every start, like `SessionSetupRun`. */\nexport type SessionEnvironmentSetupRun = (\n sandbox: WorkspaceSandbox,\n environment: SessionEnvironmentGate,\n) => Promise<void>;\n\n/**\n * Per-process session-id → sandbox instance memo.\n *\n * The provider contract is id-keyed getOrCreate, but provider find-then-create\n * has a real double-create race across independent instances. Memoizing the\n * instance per session makes the base class's per-instance start coalescing\n * apply process-wide per session — the same single-flight scope the fleet's\n * per-binding coalescing provided. Cross-replica races are accepted (the\n * fleet was also per-replica).\n */\ninterface SessionSandboxEntry {\n sandbox: WorkspaceSandbox;\n /**\n * The session's repo checkout root, recorded for passive readers (fs\n * routes, capture, authz). Local sandboxes derive it at construction;\n * remote sandboxes clone into the VM's own home, so it is undefined until\n * `resolveSessionWorkdir` probes the first started VM — passive readers\n * treat an unresolved workdir as \"nothing materialized\".\n */\n workdir?: string;\n /** The session's own repository, the only one `workdir` is ever recorded for. */\n ownRepo: string;\n /** Environment repositories in position order; the session's own repository is among them. */\n repos?: string[];\n}\n\nconst sessionSandboxes = new Map<string, SessionSandboxEntry>();\n\n/** One environment repository as the file readers see it. */\nexport interface SessionLayoutRepository {\n slug: string;\n /** Absolute checkout directory. */\n dir: string;\n /** Path prefix of this checkout under the layout root: empty for a single-repository session, `<dir>/` otherwise. */\n prefix: string;\n}\n\n/**\n * Where a session's files are read from. A session with one repository is\n * rooted at that checkout, as before environments existed; a session with\n * several is rooted at the workspace root with each checkout as a directory\n * beneath it.\n */\nexport interface SessionLayout {\n root: string;\n repos: SessionLayoutRepository[];\n}\n\n/** The layout of a memoized session, `undefined` until its workdir resolved. */\nexport function sessionLayout(entry: SessionSandboxEntry | undefined): SessionLayout | undefined {\n if (!entry?.workdir) return undefined;\n const slugs = entry.repos?.length ? entry.repos : [entry.ownRepo];\n if (slugs.length === 1) {\n return { root: entry.workdir, repos: [{ slug: slugs[0]!, dir: entry.workdir, prefix: '' }] };\n }\n const root = path.posix.dirname(entry.workdir);\n return {\n root,\n repos: slugs.map(slug => {\n const dir = slug.toLowerCase() === entry.ownRepo.toLowerCase() ? entry.workdir! : repoDirUnder(root, slug);\n return { slug, dir, prefix: `${path.posix.basename(dir)}/` };\n }),\n };\n}\n\n/**\n * Get the session's memoized sandbox entry, constructing (and memoizing) it on\n * first access. Construction is cheap and side-effect-free by contract; VMs\n * are provisioned on `start()` only. Local sandboxes get their workdir here;\n * remote workdirs are a runtime fact of the VM, resolved on first start.\n */\nexport function getSessionSandbox(\n sessionId: string,\n repoFullName: string,\n construct: () => WorkspaceSandbox,\n repos?: string[],\n): SessionSandboxEntry {\n const existing = sessionSandboxes.get(sessionId);\n if (existing) {\n // The environment can change between boots; the layout follows the latest.\n if (repos) existing.repos = repos;\n return existing;\n }\n const sandbox = construct();\n const local = deriveLocalWorkdir(sandbox, repoFullName);\n const entry: SessionSandboxEntry = {\n sandbox,\n ownRepo: repoFullName,\n ...(local ? { workdir: local } : {}),\n ...(repos ? { repos } : {}),\n };\n sessionSandboxes.set(sessionId, entry);\n return entry;\n}\n\n/**\n * Resolve (and memoize on the session entry) the session's repo checkout\n * root. Local sandboxes answer synchronously from their configured\n * `workingDirectory`; remote sandboxes clone into the VM's own default cwd,\n * so the first resolution probes it with one `pwd` — the VM tells us where\n * home is, we never invent a path. Calling this against a stopped sandbox\n * lazily starts it (the probe is a command), so passive readers must peek\n * `entry.workdir` instead. The memo is the session's own checkout; another\n * environment repository lives beside it under the same root, so it is\n * answered from the memo's parent without a second probe.\n */\nexport async function resolveSessionWorkdir(\n sessionId: string,\n sandbox: WorkspaceSandbox,\n repoFullName: string,\n): Promise<string> {\n const entry = sessionSandboxes.get(sessionId);\n const memo = entry && entry.sandbox === sandbox ? entry : undefined;\n if (memo && memo.ownRepo !== repoFullName) {\n // Passive readers take `workdir` as the session's own checkout, so a\n // sibling never lands in the memo: resolve the own checkout (cold memo\n // included) and answer the sibling beside it.\n const own = await resolveSessionWorkdir(sessionId, sandbox, memo.ownRepo);\n return repoDirUnder(path.posix.dirname(own), repoFullName);\n }\n if (memo?.workdir) return memo.workdir;\n const workdir =\n deriveLocalWorkdir(sandbox, repoFullName) ??\n deriveRemoteRepoDir(sandbox, repoFullName) ??\n repoDirUnder(await probeHome(sandbox), repoFullName);\n if (memo) memo.workdir = workdir;\n return workdir;\n}\n\n/** One `pwd` in the VM's default shell cwd — its home dir, by provider convention. */\nasync function probeHome(sandbox: WorkspaceSandbox): Promise<string> {\n if (!sandbox.executeCommand) {\n throw new Error(`Sandbox '${sandbox.id}' cannot resolve its workdir: no executeCommand implementation`);\n }\n const probe = await sandbox.executeCommand('pwd');\n const home = probe.stdout.trim().split('\\n').pop()?.trim() ?? '';\n if (probe.exitCode !== 0 || !home.startsWith('/')) {\n throw new Error(\n `Sandbox '${sandbox.id}' default cwd probe failed (exit ${probe.exitCode}): ${\n probe.stderr.trim() || probe.stdout.trim() || 'empty output'\n }`,\n );\n }\n return home;\n}\n\n/**\n * The session's memoized sandbox (and its workdir) when one was already\n * constructed in this process, else undefined. Never constructs — passive\n * read paths use this so browsing files cannot provision a VM.\n */\nexport function peekSessionSandbox(sessionId: string): SessionSandboxEntry | undefined {\n return sessionSandboxes.get(sessionId);\n}\n\n/** Drop the memoized instance (on stop/destroy/retirement or construction failure). */\nexport function evictSessionSandbox(sessionId: string): void {\n sessionSandboxes.delete(sessionId);\n failedSetupCommands.delete(sessionId);\n}\n\n/** Test-only: reset the process-wide memo between tests. */\nexport function __clearSessionSandboxesForTests(): void {\n sessionSandboxes.clear();\n failedSetupCommands.clear();\n}\n\n/**\n * Setup commands that already failed once for a session. The first failure\n * fails the start loudly — the agent sees the real error in the tool result\n * that triggered it. Recording it lets the next start skip the known-bad\n * command instead of wedging the session behind a permanently failing\n * onStart: clone and checkout still run, and the agent can fix or re-run\n * the setup itself. Keyed by the exact command, one entry per failed command, so an\n * edited setup command runs fresh. In-memory only — a server restart re-runs the (idempotent)\n * setup.\n */\nconst failedSetupCommands = new Map<string, Set<string>>();\n\nexport function recordFailedSetupCommand(sessionId: string, command: string): void {\n const failed = failedSetupCommands.get(sessionId) ?? new Set<string>();\n failed.add(command);\n failedSetupCommands.set(sessionId, failed);\n}\n\nexport function hasFailedSetupCommand(sessionId: string, command: string): boolean {\n return failedSetupCommands.get(sessionId)?.has(command) ?? false;\n}\n\n/**\n * The setup completion marker is a convention shared with the repo templates\n * (`@internal/workspace`): `.mastra-sandbox/setup` beside the checkout,\n * containing a digest of the setup commands. Templates write it as their last\n * build step, so a sandbox booted from a warm image already carries it; the\n * start hook writes it after a successful runtime setup. It is a skip cache,\n * not a correctness mechanism: the setup command is assumed idempotent, and a\n * missing or mismatched marker only re-runs it.\n *\n * The working directory is the parent of the repo dir, which is also the\n * template's build cwd, so this is the file the template's marker step wrote.\n */\nfunction markerShellPath(workdir: string): string {\n return `${path.posix.dirname(workdir)}/${SETUP_MARKER_PATH}`;\n}\n\nasync function markerMatches(sandbox: WorkspaceSandbox, workdir: string, content: string): Promise<boolean> {\n // The marker sits beside the checkout, not inside it, so it can outlive a\n // removed checkout (a wiped local session dir, a recovered VM). Trust it\n // only when the checkout it describes exists and it names this command.\n const marker = markerShellPath(workdir);\n const probe = await sandbox.executeCommand!(\n `test -d \"${workdir}/.git\" && test -f \"${marker}\" && [ \"$(cat \"${marker}\")\" = \"${content}\" ]`,\n );\n return probe.exitCode === 0;\n}\n\nasync function writeMarker(sandbox: WorkspaceSandbox, workdir: string, content: string): Promise<void> {\n // Best-effort: a missing marker only re-runs the idempotent setup later.\n const marker = markerShellPath(workdir);\n await sandbox.executeCommand!(`mkdir -p \"$(dirname \"${marker}\")\" && printf '%s' '${content}' > \"${marker}\"`).catch(\n () => {},\n );\n}\n\n/**\n * Build the session setup hook, which factory attaches to the constructed\n * sandbox with `setOnStart`. Runs inside the sandbox start lifecycle on\n * every start, fresh VM or reconnect: materialize and checkout always run,\n * and the setup command runs unless the sandbox already carries the marker\n * for it (a warm template image, or an earlier successful start). Throwing\n * fails `start()` loudly; core treats onStart errors as fatal.\n */\nexport function createSessionSetupHook(\n run: SessionSetupRun,\n sessionId: string,\n repoFullName: string,\n setupCommand: string | undefined,\n): SandboxStartHook {\n // No command, no marker: nothing to gate.\n const marker = setupCommand?.trim() ? setupMarkerContent(setupCommand) : undefined;\n return async ({ sandbox }) => {\n if (!sandbox.executeCommand) {\n throw new Error(`Sandbox '${sandbox.id}' cannot run the session setup: no executeCommand implementation`);\n }\n // Resolved from the live instance (the hook runs inside `start()`, so the\n // VM is up) and memoized on the session entry for passive readers.\n const workdir = await resolveSessionWorkdir(sessionId, sandbox, repoFullName);\n // Probed before materialize so a wiped checkout reads as \"not done\" even\n // though materialize is about to restore it.\n const setupDone = marker\n ? await timedPhase('workspace.setup-marker', () => markerMatches(sandbox, workdir, marker))\n : true;\n if (marker) {\n process.stderr.write(\n `[factory:setup] ${setupDone ? 'marker matches, skipping setup command' : 'no matching marker, setup command will run'} (${markerShellPath(workdir)})\\n`,\n );\n }\n await run(sandbox, workdir, {\n setupDone,\n markSetupDone: () => (marker ? writeMarker(sandbox, workdir, marker) : Promise.resolve()),\n });\n };\n}\n\n/**\n * Shell-quote one marker file's content. Marker contents are digests, but\n * the quoting keeps an edited command's digest from ever reaching the shell\n * unquoted.\n */\nfunction shellQuote(value: string): string {\n return `'${value.replace(/'/g, `'\\\\''`)}'`;\n}\n\n/**\n * The list-form marker probe: trust a repository's marker only when its\n * checkout exists, the marker names this command, and the template did not\n * record the repository in `setup-failed` (a failed per-repo setup still\n * writes the marker because every step ran; the failure list says it failed).\n */\nasync function repoMarkerMatches(\n sandbox: WorkspaceSandbox,\n root: string,\n repoDir: string,\n content: string,\n): Promise<boolean> {\n const marker = `${root}/${repoSetupMarkerPath(repoDir)}`;\n const failed = `${root}/${SETUP_FAILED_MARKER_PATH}`;\n const probe = await sandbox.executeCommand!(\n `test -d \"${root}/${repoDir}/.git\" && test -f \"${marker}\" && [ \"$(cat \"${marker}\")\" = ${shellQuote(content)} ] && ! grep -qxF -- ${shellQuote(repoDir)} \"${failed}\" 2>/dev/null`,\n );\n return probe.exitCode === 0;\n}\n\n/** Write a repository's marker and drop it from `setup-failed`. Best-effort, like `writeMarker`. */\nasync function writeRepoMarker(\n sandbox: WorkspaceSandbox,\n root: string,\n repoDir: string,\n content: string,\n): Promise<void> {\n const marker = `${root}/${repoSetupMarkerPath(repoDir)}`;\n const failed = `${root}/${SETUP_FAILED_MARKER_PATH}`;\n await sandbox.executeCommand!(\n `mkdir -p \"$(dirname \"${marker}\")\" && printf '%s' ${shellQuote(content)} > \"${marker}\" && { test -f \"${failed}\" && { grep -vxF -- ${shellQuote(repoDir)} \"${failed}\" > \"${failed}.tmp\" || true; } && mv \"${failed}.tmp\" \"${failed}\" || true; }`,\n ).catch(() => {});\n}\n\nasync function workspaceMarkerMatches(sandbox: WorkspaceSandbox, root: string, content: string): Promise<boolean> {\n const marker = `${root}/${WORKSPACE_SETUP_MARKER_PATH}`;\n const probe = await sandbox.executeCommand!(\n `test -f \"${marker}\" && [ \"$(cat \"${marker}\")\" = ${shellQuote(content)} ]`,\n );\n return probe.exitCode === 0;\n}\n\nasync function writeWorkspaceMarker(sandbox: WorkspaceSandbox, root: string, content: string): Promise<void> {\n const marker = `${root}/${WORKSPACE_SETUP_MARKER_PATH}`;\n await sandbox.executeCommand!(\n `mkdir -p \"$(dirname \"${marker}\")\" && printf '%s' ${shellQuote(content)} > \"${marker}\"`,\n ).catch(() => {});\n}\n\n/**\n * The list-form start hook for a session whose factory has an environment:\n * the same lifecycle as `createSessionSetupHook`, with one gate per\n * repository plus one for the workspace setup command. The markers are the\n * ones the multi-repo templates write (`.mastra-sandbox/repos/<repoDir>`,\n * `.mastra-sandbox/workspace-setup`, `.mastra-sandbox/setup-failed`), all\n * under the workspace root, which is the parent of the primary repository's\n * directory: `resolveSessionWorkdir` keeps answering that directory so the\n * PR tools and passive readers see the primary checkout, and the root is\n * derived from it rather than probed twice.\n *\n * `repos` is in position order and must include the primary (`repoFullName`).\n */\nexport function createEnvironmentSetupHook(\n run: SessionEnvironmentSetupRun,\n sessionId: string,\n repoFullName: string,\n environment: { repos: SessionEnvironmentRepository[]; workspaceSetupCommand?: string },\n): SandboxStartHook {\n const workspaceCommand = environment.workspaceSetupCommand?.trim() ? environment.workspaceSetupCommand : undefined;\n const workspaceMarker = workspaceCommand ? setupMarkerContent(workspaceCommand) : undefined;\n return async ({ sandbox }) => {\n if (!sandbox.executeCommand) {\n throw new Error(`Sandbox '${sandbox.id}' cannot run the session setup: no executeCommand implementation`);\n }\n const workdir = await resolveSessionWorkdir(sessionId, sandbox, repoFullName);\n const root = path.posix.dirname(workdir);\n const repos: SessionEnvironmentRepositoryGate[] = [];\n for (const repo of environment.repos) {\n const repoDir = repositoryDirectoryName(repo.slug);\n const marker = repo.setupCommand?.trim() ? setupMarkerContent(repo.setupCommand) : undefined;\n const setupDone = marker\n ? await timedPhase(`workspace.setup-marker(${repoDir})`, () =>\n repoMarkerMatches(sandbox, root, repoDir, marker),\n )\n : true;\n if (marker) {\n process.stderr.write(\n `[factory:setup] ${repo.slug}: ${setupDone ? 'marker matches, skipping setup command' : 'no matching marker, setup command will run'} (${root}/${repoSetupMarkerPath(repoDir)})\\n`,\n );\n }\n repos.push({\n ...repo,\n dir: `${root}/${repoDir}`,\n gate: {\n setupDone,\n markSetupDone: () => (marker ? writeRepoMarker(sandbox, root, repoDir, marker) : Promise.resolve()),\n },\n });\n }\n const workspaceDone = workspaceMarker\n ? await timedPhase('workspace.setup-marker(workspace)', () =>\n workspaceMarkerMatches(sandbox, root, workspaceMarker),\n )\n : true;\n await run(sandbox, {\n root,\n repos,\n workspace: {\n setupDone: workspaceDone,\n markSetupDone: () =>\n workspaceMarker ? writeWorkspaceMarker(sandbox, root, workspaceMarker) : Promise.resolve(),\n },\n });\n };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session workdir derivation. Workdirs are never persisted or trusted from
|
|
3
|
+
* storage or client input — the stale-workdir class of production bugs came
|
|
4
|
+
* from reading `session.sandboxWorkdir` written under a different provider.
|
|
5
|
+
*
|
|
6
|
+
* Local sandboxes derive their workdir synchronously from the sandbox's own
|
|
7
|
+
* `workingDirectory` (the per-session directory the deploy's callback chose).
|
|
8
|
+
* Remote sandboxes have no invented path: the repo clones into the VM's own
|
|
9
|
+
* default cwd (its home dir), so the workdir is only knowable once a VM is
|
|
10
|
+
* running — resolved lazily by `resolveSessionWorkdir` via a one-time `pwd`
|
|
11
|
+
* probe and memoized on the session entry.
|
|
12
|
+
*/
|
|
13
|
+
/** Keep each path piece a single safe segment (no separators or traversal). */
|
|
14
|
+
export declare function sanitizeSegment(segment: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Synchronously derivable workdir: local sandboxes expose their host
|
|
17
|
+
* `workingDirectory`; the repo checks out as a contained subdirectory so the
|
|
18
|
+
* setup marker sits beside the clone instead of polluting `git status`
|
|
19
|
+
* inside it. Returns undefined for remote providers, whose workdir is a
|
|
20
|
+
* runtime fact of the VM (`<home>/<repo>`).
|
|
21
|
+
*/
|
|
22
|
+
export declare function deriveLocalWorkdir(sandbox: {
|
|
23
|
+
provider: string;
|
|
24
|
+
workingDirectory?: unknown;
|
|
25
|
+
}, repoFullName: string): string | undefined;
|
|
26
|
+
/** Derive `<workingDirectory>/<repo>` when a remote sandbox declares an absolute root. */
|
|
27
|
+
export declare function deriveRemoteRepoDir(sandbox: {
|
|
28
|
+
provider: string;
|
|
29
|
+
workingDirectory?: unknown;
|
|
30
|
+
}, repoFullName: string): string | undefined;
|
|
31
|
+
/** Join a parent directory and sanitized repository name. */
|
|
32
|
+
export declare function repoDirUnder(parent: string, repoFullName: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* The directory a repository checks out into, under the workspace root. Must
|
|
35
|
+
* agree with the repo templates' private `repoDirName`
|
|
36
|
+
* (`workspaces/platform-workspace/src/repo-template.ts`): the last segment
|
|
37
|
+
* of the clone URL, `[^A-Za-z0-9._-]` replaced by `-`, leading dots dropped,
|
|
38
|
+
* `repo` when nothing is left. A repository slug never ends in `.git`, so
|
|
39
|
+
* both derive the same name for every slug; `workdir.test.ts` pins the
|
|
40
|
+
* template's own fixtures.
|
|
41
|
+
*/
|
|
42
|
+
export declare function repositoryDirectoryName(repoFullName: string): string;
|
|
43
|
+
/** Resolve a workdir under `root`, refusing any path that escapes the configured root. */
|
|
44
|
+
export declare function resolveContainedLocalWorkdir(root: string, ...segments: string[]): string;
|
|
45
|
+
//# sourceMappingURL=workdir.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workdir.d.ts","sourceRoot":"","sources":["../../src/sandbox/workdir.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AAEH,+EAA+E;AAC/E,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGvD;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,EACzD,YAAY,EAAE,MAAM,GACnB,MAAM,GAAG,SAAS,CAMpB;AAED,0FAA0F;AAC1F,wBAAgB,mBAAmB,CACjC,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,EACzD,YAAY,EAAE,MAAM,GACnB,MAAM,GAAG,SAAS,CAMpB;AAED,6DAA6D;AAC7D,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAIzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAGpE;AAED,0FAA0F;AAC1F,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAKxF"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as path$1 from "path";
|
|
2
|
+
//#region src/sandbox/workdir.ts
|
|
3
|
+
/**
|
|
4
|
+
* Session workdir derivation. Workdirs are never persisted or trusted from
|
|
5
|
+
* storage or client input — the stale-workdir class of production bugs came
|
|
6
|
+
* from reading `session.sandboxWorkdir` written under a different provider.
|
|
7
|
+
*
|
|
8
|
+
* Local sandboxes derive their workdir synchronously from the sandbox's own
|
|
9
|
+
* `workingDirectory` (the per-session directory the deploy's callback chose).
|
|
10
|
+
* Remote sandboxes have no invented path: the repo clones into the VM's own
|
|
11
|
+
* default cwd (its home dir), so the workdir is only knowable once a VM is
|
|
12
|
+
* running — resolved lazily by `resolveSessionWorkdir` via a one-time `pwd`
|
|
13
|
+
* probe and memoized on the session entry.
|
|
14
|
+
*/
|
|
15
|
+
/** Keep each path piece a single safe segment (no separators or traversal). */
|
|
16
|
+
function sanitizeSegment(segment) {
|
|
17
|
+
return segment.replace(/[^A-Za-z0-9._-]/g, "-").replace(/^\.+/, "") || "repo";
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Synchronously derivable workdir: local sandboxes expose their host
|
|
21
|
+
* `workingDirectory`; the repo checks out as a contained subdirectory so the
|
|
22
|
+
* setup marker sits beside the clone instead of polluting `git status`
|
|
23
|
+
* inside it. Returns undefined for remote providers, whose workdir is a
|
|
24
|
+
* runtime fact of the VM (`<home>/<repo>`).
|
|
25
|
+
*/
|
|
26
|
+
function deriveLocalWorkdir(sandbox, repoFullName) {
|
|
27
|
+
const wd = sandbox.workingDirectory;
|
|
28
|
+
if (sandbox.provider === "local" && typeof wd === "string" && wd.length > 0) return resolveContainedLocalWorkdir(wd, repositoryDirectoryName(repoFullName));
|
|
29
|
+
}
|
|
30
|
+
/** Derive `<workingDirectory>/<repo>` when a remote sandbox declares an absolute root. */
|
|
31
|
+
function deriveRemoteRepoDir(sandbox, repoFullName) {
|
|
32
|
+
const wd = sandbox.workingDirectory;
|
|
33
|
+
if (sandbox.provider !== "local" && typeof wd === "string" && wd.startsWith("/")) return repoDirUnder(wd, repoFullName);
|
|
34
|
+
}
|
|
35
|
+
/** Join a parent directory and sanitized repository name. */
|
|
36
|
+
function repoDirUnder(parent, repoFullName) {
|
|
37
|
+
let end = parent.length;
|
|
38
|
+
while (end > 0 && parent[end - 1] === "/") end--;
|
|
39
|
+
return `${parent.slice(0, end)}/${repositoryDirectoryName(repoFullName)}`;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The directory a repository checks out into, under the workspace root. Must
|
|
43
|
+
* agree with the repo templates' private `repoDirName`
|
|
44
|
+
* (`workspaces/platform-workspace/src/repo-template.ts`): the last segment
|
|
45
|
+
* of the clone URL, `[^A-Za-z0-9._-]` replaced by `-`, leading dots dropped,
|
|
46
|
+
* `repo` when nothing is left. A repository slug never ends in `.git`, so
|
|
47
|
+
* both derive the same name for every slug; `workdir.test.ts` pins the
|
|
48
|
+
* template's own fixtures.
|
|
49
|
+
*/
|
|
50
|
+
function repositoryDirectoryName(repoFullName) {
|
|
51
|
+
const segments = repoFullName.split("/");
|
|
52
|
+
return sanitizeSegment(segments.length > 1 ? segments.at(-1) || "repo" : "repo");
|
|
53
|
+
}
|
|
54
|
+
/** Resolve a workdir under `root`, refusing any path that escapes the configured root. */
|
|
55
|
+
function resolveContainedLocalWorkdir(root, ...segments) {
|
|
56
|
+
const resolvedRoot = path$1.resolve(root);
|
|
57
|
+
const resolved = path$1.resolve(resolvedRoot, ...segments);
|
|
58
|
+
if (resolved !== resolvedRoot && resolved.startsWith(`${resolvedRoot}${path$1.sep}`)) return resolved;
|
|
59
|
+
throw new Error(`Refusing to use local sandbox path outside configured root: ${resolved}`);
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { deriveLocalWorkdir, deriveRemoteRepoDir, repoDirUnder, repositoryDirectoryName, resolveContainedLocalWorkdir, sanitizeSegment };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=workdir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workdir.js","names":["path"],"sources":["../../src/sandbox/workdir.ts"],"sourcesContent":["import * as path from 'node:path';\n\n/**\n * Session workdir derivation. Workdirs are never persisted or trusted from\n * storage or client input — the stale-workdir class of production bugs came\n * from reading `session.sandboxWorkdir` written under a different provider.\n *\n * Local sandboxes derive their workdir synchronously from the sandbox's own\n * `workingDirectory` (the per-session directory the deploy's callback chose).\n * Remote sandboxes have no invented path: the repo clones into the VM's own\n * default cwd (its home dir), so the workdir is only knowable once a VM is\n * running — resolved lazily by `resolveSessionWorkdir` via a one-time `pwd`\n * probe and memoized on the session entry.\n */\n\n/** Keep each path piece a single safe segment (no separators or traversal). */\nexport function sanitizeSegment(segment: string): string {\n const cleaned = segment.replace(/[^A-Za-z0-9._-]/g, '-').replace(/^\\.+/, '');\n return cleaned || 'repo';\n}\n\n/**\n * Synchronously derivable workdir: local sandboxes expose their host\n * `workingDirectory`; the repo checks out as a contained subdirectory so the\n * setup marker sits beside the clone instead of polluting `git status`\n * inside it. Returns undefined for remote providers, whose workdir is a\n * runtime fact of the VM (`<home>/<repo>`).\n */\nexport function deriveLocalWorkdir(\n sandbox: { provider: string; workingDirectory?: unknown },\n repoFullName: string,\n): string | undefined {\n const wd = sandbox.workingDirectory;\n if (sandbox.provider === 'local' && typeof wd === 'string' && wd.length > 0) {\n return resolveContainedLocalWorkdir(wd, repositoryDirectoryName(repoFullName));\n }\n return undefined;\n}\n\n/** Derive `<workingDirectory>/<repo>` when a remote sandbox declares an absolute root. */\nexport function deriveRemoteRepoDir(\n sandbox: { provider: string; workingDirectory?: unknown },\n repoFullName: string,\n): string | undefined {\n const wd = sandbox.workingDirectory;\n if (sandbox.provider !== 'local' && typeof wd === 'string' && wd.startsWith('/')) {\n return repoDirUnder(wd, repoFullName);\n }\n return undefined;\n}\n\n/** Join a parent directory and sanitized repository name. */\nexport function repoDirUnder(parent: string, repoFullName: string): string {\n let end = parent.length;\n while (end > 0 && parent[end - 1] === '/') end--;\n return `${parent.slice(0, end)}/${repositoryDirectoryName(repoFullName)}`;\n}\n\n/**\n * The directory a repository checks out into, under the workspace root. Must\n * agree with the repo templates' private `repoDirName`\n * (`workspaces/platform-workspace/src/repo-template.ts`): the last segment\n * of the clone URL, `[^A-Za-z0-9._-]` replaced by `-`, leading dots dropped,\n * `repo` when nothing is left. A repository slug never ends in `.git`, so\n * both derive the same name for every slug; `workdir.test.ts` pins the\n * template's own fixtures.\n */\nexport function repositoryDirectoryName(repoFullName: string): string {\n const segments = repoFullName.split('/');\n return sanitizeSegment(segments.length > 1 ? segments.at(-1) || 'repo' : 'repo');\n}\n\n/** Resolve a workdir under `root`, refusing any path that escapes the configured root. */\nexport function resolveContainedLocalWorkdir(root: string, ...segments: string[]): string {\n const resolvedRoot = path.resolve(root);\n const resolved = path.resolve(resolvedRoot, ...segments);\n if (resolved !== resolvedRoot && resolved.startsWith(`${resolvedRoot}${path.sep}`)) return resolved;\n throw new Error(`Refusing to use local sandbox path outside configured root: ${resolved}`);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,gBAAgB,SAAyB;CAEvD,OADgB,QAAQ,QAAQ,oBAAoB,GAAG,CAAC,CAAC,QAAQ,QAAQ,EAC5D,KAAK;AACpB;;;;;;;;AASA,SAAgB,mBACd,SACA,cACoB;CACpB,MAAM,KAAK,QAAQ;CACnB,IAAI,QAAQ,aAAa,WAAW,OAAO,OAAO,YAAY,GAAG,SAAS,GACxE,OAAO,6BAA6B,IAAI,wBAAwB,YAAY,CAAC;AAGjF;;AAGA,SAAgB,oBACd,SACA,cACoB;CACpB,MAAM,KAAK,QAAQ;CACnB,IAAI,QAAQ,aAAa,WAAW,OAAO,OAAO,YAAY,GAAG,WAAW,GAAG,GAC7E,OAAO,aAAa,IAAI,YAAY;AAGxC;;AAGA,SAAgB,aAAa,QAAgB,cAA8B;CACzE,IAAI,MAAM,OAAO;CACjB,OAAO,MAAM,KAAK,OAAO,MAAM,OAAO,KAAK;CAC3C,OAAO,GAAG,OAAO,MAAM,GAAG,GAAG,EAAE,GAAG,wBAAwB,YAAY;AACxE;;;;;;;;;;AAWA,SAAgB,wBAAwB,cAA8B;CACpE,MAAM,WAAW,aAAa,MAAM,GAAG;CACvC,OAAO,gBAAgB,SAAS,SAAS,IAAI,SAAS,GAAG,EAAE,KAAK,SAAS,MAAM;AACjF;;AAGA,SAAgB,6BAA6B,MAAc,GAAG,UAA4B;CACxF,MAAM,eAAeA,OAAK,QAAQ,IAAI;CACtC,MAAM,WAAWA,OAAK,QAAQ,cAAc,GAAG,QAAQ;CACvD,IAAI,aAAa,gBAAgB,SAAS,WAAW,GAAG,eAAeA,OAAK,KAAK,GAAG,OAAO;CAC3F,MAAM,IAAI,MAAM,+DAA+D,UAAU;AAC3F"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface DecryptedFactorySecret<T> {
|
|
2
|
+
value: T;
|
|
3
|
+
needsReencryption: boolean;
|
|
4
|
+
}
|
|
5
|
+
/** Encrypts opaque JSON values before they cross the Factory storage boundary. */
|
|
6
|
+
export interface FactorySecretEncryption {
|
|
7
|
+
encrypt<T>(value: T): Promise<string>;
|
|
8
|
+
decrypt<T>(value: unknown): Promise<DecryptedFactorySecret<T>>;
|
|
9
|
+
}
|
|
10
|
+
export interface FactorySecretEncryptionKey {
|
|
11
|
+
id: string;
|
|
12
|
+
key: Uint8Array;
|
|
13
|
+
}
|
|
14
|
+
export interface FactorySecretEncryptionConfig {
|
|
15
|
+
primary: FactorySecretEncryptionKey;
|
|
16
|
+
previous?: FactorySecretEncryptionKey[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates a versioned AES-256-GCM encryptor. The primary key is used for new
|
|
20
|
+
* writes; previous keys remain decrypt-only until stored values are rotated.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createFactorySecretEncryption(config: FactorySecretEncryptionConfig): FactorySecretEncryption;
|
|
23
|
+
/** Explicit plaintext compatibility for local, no-auth Factory development. */
|
|
24
|
+
export declare function createPlaintextFactorySecretEncryption(): FactorySecretEncryption;
|
|
25
|
+
//# sourceMappingURL=secret-encryption.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-encryption.d.ts","sourceRoot":"","sources":["../src/secret-encryption.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC,KAAK,EAAE,CAAC,CAAC;IACT,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED,kFAAkF;AAClF,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACtC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC;CAChE;AAED,MAAM,WAAW,0BAA0B;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,UAAU,CAAC;CACjB;AAED,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,0BAA0B,CAAC;IACpC,QAAQ,CAAC,EAAE,0BAA0B,EAAE,CAAC;CACzC;AAgCD;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,6BAA6B,GAAG,uBAAuB,CAyD5G;AAED,+EAA+E;AAC/E,wBAAgB,sCAAsC,IAAI,uBAAuB,CAiBhF"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { createCipheriv, createDecipheriv } from "crypto";
|
|
2
|
+
//#region src/secret-encryption.ts
|
|
3
|
+
const ENVELOPE_PREFIX = "mastra:factory-secret:v1:";
|
|
4
|
+
const ALGORITHM = "aes-256-gcm";
|
|
5
|
+
const IV_BYTES = 12;
|
|
6
|
+
function validateKey({ id, key }) {
|
|
7
|
+
if (!id) throw new Error("[FactorySecretEncryption] Key id is required.");
|
|
8
|
+
const buffer = Buffer.from(key);
|
|
9
|
+
if (buffer.byteLength !== 32) throw new Error(`[FactorySecretEncryption] Key "${id}" must be exactly 32 bytes.`);
|
|
10
|
+
return buffer;
|
|
11
|
+
}
|
|
12
|
+
function parseEnvelope(value) {
|
|
13
|
+
let parsed;
|
|
14
|
+
try {
|
|
15
|
+
parsed = JSON.parse(Buffer.from(value.slice(25), "base64url").toString("utf8"));
|
|
16
|
+
} catch {
|
|
17
|
+
throw new Error("[FactorySecretEncryption] Invalid encrypted value.");
|
|
18
|
+
}
|
|
19
|
+
if (!parsed || typeof parsed !== "object" || typeof parsed.keyId !== "string" || typeof parsed.iv !== "string" || typeof parsed.ciphertext !== "string" || typeof parsed.tag !== "string") throw new Error("[FactorySecretEncryption] Invalid encrypted value.");
|
|
20
|
+
return parsed;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates a versioned AES-256-GCM encryptor. The primary key is used for new
|
|
24
|
+
* writes; previous keys remain decrypt-only until stored values are rotated.
|
|
25
|
+
*/
|
|
26
|
+
function createFactorySecretEncryption(config) {
|
|
27
|
+
const primaryKey = validateKey(config.primary);
|
|
28
|
+
const keys = /* @__PURE__ */ new Map([[config.primary.id, primaryKey]]);
|
|
29
|
+
for (const previous of config.previous ?? []) {
|
|
30
|
+
if (keys.has(previous.id)) throw new Error(`[FactorySecretEncryption] Duplicate key id "${previous.id}".`);
|
|
31
|
+
keys.set(previous.id, validateKey(previous));
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
async encrypt(value) {
|
|
35
|
+
const iv = Buffer.from(globalThis.crypto.getRandomValues(new Uint8Array(IV_BYTES)));
|
|
36
|
+
const cipher = createCipheriv(ALGORITHM, primaryKey, iv);
|
|
37
|
+
const ciphertext = Buffer.concat([cipher.update(JSON.stringify(value), "utf8"), cipher.final()]);
|
|
38
|
+
const envelope = {
|
|
39
|
+
keyId: config.primary.id,
|
|
40
|
+
iv: iv.toString("base64url"),
|
|
41
|
+
ciphertext: ciphertext.toString("base64url"),
|
|
42
|
+
tag: cipher.getAuthTag().toString("base64url")
|
|
43
|
+
};
|
|
44
|
+
return `${ENVELOPE_PREFIX}${Buffer.from(JSON.stringify(envelope), "utf8").toString("base64url")}`;
|
|
45
|
+
},
|
|
46
|
+
async decrypt(value) {
|
|
47
|
+
if (typeof value !== "string") return {
|
|
48
|
+
value: structuredClone(value),
|
|
49
|
+
needsReencryption: true
|
|
50
|
+
};
|
|
51
|
+
if (!value.startsWith(ENVELOPE_PREFIX)) try {
|
|
52
|
+
return {
|
|
53
|
+
value: JSON.parse(value),
|
|
54
|
+
needsReencryption: true
|
|
55
|
+
};
|
|
56
|
+
} catch {
|
|
57
|
+
return {
|
|
58
|
+
value,
|
|
59
|
+
needsReencryption: true
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const envelope = parseEnvelope(value);
|
|
63
|
+
const key = keys.get(envelope.keyId);
|
|
64
|
+
if (!key) throw new Error(`[FactorySecretEncryption] Unknown key id "${envelope.keyId}".`);
|
|
65
|
+
try {
|
|
66
|
+
const decipher = createDecipheriv(ALGORITHM, key, Buffer.from(envelope.iv, "base64url"));
|
|
67
|
+
decipher.setAuthTag(Buffer.from(envelope.tag, "base64url"));
|
|
68
|
+
const plaintext = Buffer.concat([decipher.update(Buffer.from(envelope.ciphertext, "base64url")), decipher.final()]).toString("utf8");
|
|
69
|
+
return {
|
|
70
|
+
value: JSON.parse(plaintext),
|
|
71
|
+
needsReencryption: envelope.keyId !== config.primary.id
|
|
72
|
+
};
|
|
73
|
+
} catch {
|
|
74
|
+
throw new Error("[FactorySecretEncryption] Unable to decrypt encrypted value.");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** Explicit plaintext compatibility for local, no-auth Factory development. */
|
|
80
|
+
function createPlaintextFactorySecretEncryption() {
|
|
81
|
+
return {
|
|
82
|
+
async encrypt(value) {
|
|
83
|
+
return JSON.stringify(value);
|
|
84
|
+
},
|
|
85
|
+
async decrypt(value) {
|
|
86
|
+
if (typeof value !== "string") return {
|
|
87
|
+
value: structuredClone(value),
|
|
88
|
+
needsReencryption: false
|
|
89
|
+
};
|
|
90
|
+
try {
|
|
91
|
+
return {
|
|
92
|
+
value: JSON.parse(value),
|
|
93
|
+
needsReencryption: false
|
|
94
|
+
};
|
|
95
|
+
} catch {
|
|
96
|
+
return {
|
|
97
|
+
value,
|
|
98
|
+
needsReencryption: true
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
export { createFactorySecretEncryption, createPlaintextFactorySecretEncryption };
|
|
106
|
+
|
|
107
|
+
//# sourceMappingURL=secret-encryption.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-encryption.js","names":[],"sources":["../src/secret-encryption.ts"],"sourcesContent":["import { createCipheriv, createDecipheriv } from 'node:crypto';\n\nconst ENVELOPE_PREFIX = 'mastra:factory-secret:v1:';\nconst ALGORITHM = 'aes-256-gcm';\nconst IV_BYTES = 12;\n\ninterface SecretEnvelopeV1 {\n keyId: string;\n iv: string;\n ciphertext: string;\n tag: string;\n}\n\nexport interface DecryptedFactorySecret<T> {\n value: T;\n needsReencryption: boolean;\n}\n\n/** Encrypts opaque JSON values before they cross the Factory storage boundary. */\nexport interface FactorySecretEncryption {\n encrypt<T>(value: T): Promise<string>;\n decrypt<T>(value: unknown): Promise<DecryptedFactorySecret<T>>;\n}\n\nexport interface FactorySecretEncryptionKey {\n id: string;\n key: Uint8Array;\n}\n\nexport interface FactorySecretEncryptionConfig {\n primary: FactorySecretEncryptionKey;\n previous?: FactorySecretEncryptionKey[];\n}\n\nfunction validateKey({ id, key }: FactorySecretEncryptionKey): Buffer {\n if (!id) throw new Error('[FactorySecretEncryption] Key id is required.');\n const buffer = Buffer.from(key);\n if (buffer.byteLength !== 32) {\n throw new Error(`[FactorySecretEncryption] Key \"${id}\" must be exactly 32 bytes.`);\n }\n return buffer;\n}\n\nfunction parseEnvelope(value: string): SecretEnvelopeV1 {\n let parsed: unknown;\n try {\n parsed = JSON.parse(Buffer.from(value.slice(ENVELOPE_PREFIX.length), 'base64url').toString('utf8'));\n } catch {\n throw new Error('[FactorySecretEncryption] Invalid encrypted value.');\n }\n\n if (\n !parsed ||\n typeof parsed !== 'object' ||\n typeof (parsed as SecretEnvelopeV1).keyId !== 'string' ||\n typeof (parsed as SecretEnvelopeV1).iv !== 'string' ||\n typeof (parsed as SecretEnvelopeV1).ciphertext !== 'string' ||\n typeof (parsed as SecretEnvelopeV1).tag !== 'string'\n ) {\n throw new Error('[FactorySecretEncryption] Invalid encrypted value.');\n }\n return parsed as SecretEnvelopeV1;\n}\n\n/**\n * Creates a versioned AES-256-GCM encryptor. The primary key is used for new\n * writes; previous keys remain decrypt-only until stored values are rotated.\n */\nexport function createFactorySecretEncryption(config: FactorySecretEncryptionConfig): FactorySecretEncryption {\n const primaryKey = validateKey(config.primary);\n const keys = new Map<string, Buffer>([[config.primary.id, primaryKey]]);\n for (const previous of config.previous ?? []) {\n if (keys.has(previous.id)) throw new Error(`[FactorySecretEncryption] Duplicate key id \"${previous.id}\".`);\n keys.set(previous.id, validateKey(previous));\n }\n\n return {\n async encrypt<T>(value: T): Promise<string> {\n const iv = Buffer.from(globalThis.crypto.getRandomValues(new Uint8Array(IV_BYTES)));\n const cipher = createCipheriv(ALGORITHM, primaryKey, iv);\n const ciphertext = Buffer.concat([cipher.update(JSON.stringify(value), 'utf8'), cipher.final()]);\n const envelope: SecretEnvelopeV1 = {\n keyId: config.primary.id,\n iv: iv.toString('base64url'),\n ciphertext: ciphertext.toString('base64url'),\n tag: cipher.getAuthTag().toString('base64url'),\n };\n return `${ENVELOPE_PREFIX}${Buffer.from(JSON.stringify(envelope), 'utf8').toString('base64url')}`;\n },\n\n async decrypt<T>(value: unknown): Promise<DecryptedFactorySecret<T>> {\n if (typeof value !== 'string') {\n return { value: structuredClone(value) as T, needsReencryption: true };\n }\n if (!value.startsWith(ENVELOPE_PREFIX)) {\n // JSON text written by the plaintext encryptor, or a raw pre-encryption\n // secret string. Decode it the same way the plaintext encryptor does so\n // migration encrypts the original value, not its JSON text.\n try {\n return { value: JSON.parse(value) as T, needsReencryption: true };\n } catch {\n return { value: value as T, needsReencryption: true };\n }\n }\n\n const envelope = parseEnvelope(value);\n const key = keys.get(envelope.keyId);\n if (!key) throw new Error(`[FactorySecretEncryption] Unknown key id \"${envelope.keyId}\".`);\n\n try {\n const decipher = createDecipheriv(ALGORITHM, key, Buffer.from(envelope.iv, 'base64url'));\n decipher.setAuthTag(Buffer.from(envelope.tag, 'base64url'));\n const plaintext = Buffer.concat([\n decipher.update(Buffer.from(envelope.ciphertext, 'base64url')),\n decipher.final(),\n ]).toString('utf8');\n return {\n value: JSON.parse(plaintext) as T,\n needsReencryption: envelope.keyId !== config.primary.id,\n };\n } catch {\n throw new Error('[FactorySecretEncryption] Unable to decrypt encrypted value.');\n }\n },\n };\n}\n\n/** Explicit plaintext compatibility for local, no-auth Factory development. */\nexport function createPlaintextFactorySecretEncryption(): FactorySecretEncryption {\n return {\n async encrypt<T>(value: T): Promise<string> {\n return JSON.stringify(value);\n },\n async decrypt<T>(value: unknown): Promise<DecryptedFactorySecret<T>> {\n if (typeof value !== 'string') return { value: structuredClone(value) as T, needsReencryption: false };\n try {\n return { value: JSON.parse(value) as T, needsReencryption: false };\n } catch {\n // Pre-encryption rows stored raw secret strings (e.g. a bare\n // `custom_providers.api_key`), not JSON. Treat the raw string as the\n // value and flag it so migration rewrites it in the current format.\n return { value: value as T, needsReencryption: true };\n }\n },\n };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-wide error handler for the MastraCode web surface.
|
|
3
|
+
*
|
|
4
|
+
* Installed as `server.onError`, which the deployer applies to the top-level
|
|
5
|
+
* Hono app AND the custom-route sub-app (`/web/*`, `/auth/*`) — without it,
|
|
6
|
+
* unexpected route errors surface as an opaque `Internal Server Error` with no
|
|
7
|
+
* server-side trace.
|
|
8
|
+
*/
|
|
9
|
+
import type { Context } from 'hono';
|
|
10
|
+
/** Handle a route error: log full detail server-side, return structured JSON. */
|
|
11
|
+
export declare function handleServerError(err: Error, c: Context): Response;
|
|
12
|
+
//# sourceMappingURL=server-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-error.d.ts","sourceRoot":"","sources":["../src/server-error.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAGpC,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,GAAG,QAAQ,CAiBlE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HTTPException } from "hono/http-exception";
|
|
2
|
+
//#region src/server-error.ts
|
|
3
|
+
/** Handle a route error: log full detail server-side, return structured JSON. */
|
|
4
|
+
function handleServerError(err, c) {
|
|
5
|
+
if (err instanceof HTTPException) return c.json({ error: err.message }, err.status);
|
|
6
|
+
const detail = err instanceof Error ? err.stack ?? err.message : String(err);
|
|
7
|
+
console.error(`[Mastra Factory] ${c.req.method} ${c.req.path} failed: ${detail}`);
|
|
8
|
+
return c.json({
|
|
9
|
+
error: "internal_error",
|
|
10
|
+
message: err instanceof Error ? err.message : String(err)
|
|
11
|
+
}, 500);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { handleServerError };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=server-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-error.js","names":[],"sources":["../src/server-error.ts"],"sourcesContent":["/**\n * Server-wide error handler for the MastraCode web surface.\n *\n * Installed as `server.onError`, which the deployer applies to the top-level\n * Hono app AND the custom-route sub-app (`/web/*`, `/auth/*`) — without it,\n * unexpected route errors surface as an opaque `Internal Server Error` with no\n * server-side trace.\n */\n\nimport type { Context } from 'hono';\nimport { HTTPException } from 'hono/http-exception';\n\n/** Handle a route error: log full detail server-side, return structured JSON. */\nexport function handleServerError(err: Error, c: Context): Response {\n // Deliberate HTTP errors (auth middleware, body limits, handlers) keep their\n // status + message; they are expected flows, not server faults.\n if (err instanceof HTTPException) {\n return c.json({ error: err.message }, err.status);\n }\n\n const detail = err instanceof Error ? (err.stack ?? err.message) : String(err);\n console.error(`[Mastra Factory] ${c.req.method} ${c.req.path} failed: ${detail}`);\n\n return c.json(\n {\n error: 'internal_error',\n message: err instanceof Error ? err.message : String(err),\n },\n 500,\n );\n}\n"],"mappings":";;;AAaA,SAAgB,kBAAkB,KAAY,GAAsB;CAGlE,IAAI,eAAe,eACjB,OAAO,EAAE,KAAK,EAAE,OAAO,IAAI,QAAQ,GAAG,IAAI,MAAM;CAGlD,MAAM,SAAS,eAAe,QAAS,IAAI,SAAS,IAAI,UAAW,OAAO,GAAG;CAC7E,QAAQ,MAAM,oBAAoB,EAAE,IAAI,OAAO,GAAG,EAAE,IAAI,KAAK,WAAW,QAAQ;CAEhF,OAAO,EAAE,KACP;EACE,OAAO;EACP,SAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;CAC1D,GACA,GACF;AACF"}
|