@mastra/factory 0.24.0-alpha.1 → 0.24.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +106 -4
- package/dist/auth.d.ts +14 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +45 -9
- package/dist/auth.js.map +1 -1
- package/dist/boards/review.d.ts.map +1 -1
- package/dist/boards/review.js +21 -1
- package/dist/boards/review.js.map +1 -1
- package/dist/boards/work-transition-policy.d.ts.map +1 -1
- package/dist/boards/work-transition-policy.js +12 -1
- package/dist/boards/work-transition-policy.js.map +1 -1
- package/dist/boards/work.d.ts +14 -0
- package/dist/boards/work.d.ts.map +1 -1
- package/dist/boards/work.js +70 -7
- package/dist/boards/work.js.map +1 -1
- package/dist/capabilities/version-control.d.ts +26 -0
- package/dist/capabilities/version-control.d.ts.map +1 -1
- package/dist/factory.d.ts +8 -0
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +354 -27
- package/dist/factory.js.map +1 -1
- package/dist/integrations/base.d.ts +1 -1
- package/dist/integrations/base.d.ts.map +1 -1
- package/dist/integrations/github/default-rules.d.ts.map +1 -1
- package/dist/integrations/github/default-rules.js +1 -16
- package/dist/integrations/github/default-rules.js.map +1 -1
- package/dist/integrations/github/integration.d.ts.map +1 -1
- package/dist/integrations/github/integration.js +37 -1
- package/dist/integrations/github/integration.js.map +1 -1
- package/dist/integrations/github/routes.d.ts +1 -1
- package/dist/integrations/github/routes.d.ts.map +1 -1
- package/dist/integrations/github/routes.js +19 -11
- package/dist/integrations/github/routes.js.map +1 -1
- package/dist/integrations/github/rules.d.ts.map +1 -1
- package/dist/integrations/github/rules.js +26 -22
- package/dist/integrations/github/rules.js.map +1 -1
- package/dist/integrations/github/sandbox-release.d.ts +15 -3
- package/dist/integrations/github/sandbox-release.d.ts.map +1 -1
- package/dist/integrations/github/sandbox-release.js +20 -3
- package/dist/integrations/github/sandbox-release.js.map +1 -1
- package/dist/integrations/github/sandbox.d.ts +2 -3
- package/dist/integrations/github/sandbox.d.ts.map +1 -1
- package/dist/integrations/github/sandbox.js +78 -7
- package/dist/integrations/github/sandbox.js.map +1 -1
- package/dist/integrations/github/session-subscriptions.d.ts.map +1 -1
- package/dist/integrations/github/session-subscriptions.js +1 -2
- package/dist/integrations/github/session-subscriptions.js.map +1 -1
- package/dist/integrations/github/subscriptions.d.ts +7 -4
- package/dist/integrations/github/subscriptions.d.ts.map +1 -1
- package/dist/integrations/github/subscriptions.js +5 -5
- package/dist/integrations/github/subscriptions.js.map +1 -1
- package/dist/integrations/github/webhook.d.ts +4 -2
- package/dist/integrations/github/webhook.d.ts.map +1 -1
- package/dist/integrations/github/webhook.js +59 -36
- package/dist/integrations/github/webhook.js.map +1 -1
- package/dist/integrations/gitlab/api.d.ts +16 -1
- package/dist/integrations/gitlab/api.d.ts.map +1 -1
- package/dist/integrations/gitlab/api.js +9 -0
- package/dist/integrations/gitlab/api.js.map +1 -1
- package/dist/integrations/gitlab/routes.d.ts.map +1 -1
- package/dist/integrations/gitlab/routes.js +10 -6
- package/dist/integrations/gitlab/routes.js.map +1 -1
- package/dist/integrations/gitlab/rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/rules.js +28 -21
- package/dist/integrations/gitlab/rules.js.map +1 -1
- package/dist/integrations/gitlab/session-subscriptions.d.ts.map +1 -1
- package/dist/integrations/gitlab/session-subscriptions.js +1 -2
- package/dist/integrations/gitlab/session-subscriptions.js.map +1 -1
- package/dist/integrations/gitlab/subscriptions.d.ts +7 -4
- package/dist/integrations/gitlab/subscriptions.d.ts.map +1 -1
- package/dist/integrations/gitlab/subscriptions.js +5 -5
- package/dist/integrations/gitlab/subscriptions.js.map +1 -1
- package/dist/integrations/gitlab/version-control.d.ts.map +1 -1
- package/dist/integrations/gitlab/version-control.js +37 -3
- package/dist/integrations/gitlab/version-control.js.map +1 -1
- package/dist/integrations/incidentio/intake.d.ts +1 -1
- package/dist/integrations/incidentio/intake.d.ts.map +1 -1
- package/dist/integrations/incidentio/intake.js.map +1 -1
- package/dist/integrations/linear/agent-tools.d.ts.map +1 -1
- package/dist/integrations/linear/agent-tools.js.map +1 -1
- package/dist/integrations/platform/connect/routes.d.ts +1 -1
- package/dist/integrations/platform/connect/routes.d.ts.map +1 -1
- package/dist/integrations/platform/connect/routes.js.map +1 -1
- package/dist/integrations/platform/github/integration.d.ts.map +1 -1
- package/dist/integrations/platform/github/integration.js +27 -1
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/platform/incidentio/integration.d.ts +1 -1
- package/dist/integrations/platform/incidentio/integration.d.ts.map +1 -1
- package/dist/integrations/platform/incidentio/integration.js.map +1 -1
- package/dist/integrations/platform/jira/integration.d.ts +1 -1
- package/dist/integrations/platform/jira/integration.d.ts.map +1 -1
- package/dist/integrations/platform/jira/integration.js.map +1 -1
- package/dist/integrations/platform/linear/event-worker.d.ts +1 -1
- package/dist/integrations/platform/linear/event-worker.d.ts.map +1 -1
- package/dist/integrations/platform/linear/event-worker.js.map +1 -1
- package/dist/integrations/slack/integration.d.ts.map +1 -1
- package/dist/integrations/slack/integration.js +33 -6
- package/dist/integrations/slack/integration.js.map +1 -1
- package/dist/integrations/slack/slack.d.ts +16 -5
- package/dist/integrations/slack/slack.d.ts.map +1 -1
- package/dist/integrations/slack/slack.js +137 -64
- package/dist/integrations/slack/slack.js.map +1 -1
- package/dist/integrations/subscription-session.d.ts +14 -0
- package/dist/integrations/subscription-session.d.ts.map +1 -1
- package/dist/integrations/subscription-session.js +30 -16
- package/dist/integrations/subscription-session.js.map +1 -1
- package/dist/mcp/disconnect.d.ts +10 -0
- package/dist/mcp/disconnect.d.ts.map +1 -0
- package/dist/mcp/disconnect.js +44 -0
- package/dist/mcp/disconnect.js.map +1 -0
- package/dist/mcp/routes.d.ts +46 -0
- package/dist/mcp/routes.d.ts.map +1 -0
- package/dist/mcp/routes.js +243 -0
- package/dist/mcp/routes.js.map +1 -0
- package/dist/provider-display-name.d.ts +2 -0
- package/dist/provider-display-name.d.ts.map +1 -0
- package/dist/provider-display-name.js +16 -0
- package/dist/provider-display-name.js.map +1 -0
- package/dist/review-verdict.d.ts +11 -0
- package/dist/review-verdict.d.ts.map +1 -1
- package/dist/review-verdict.js +16 -1
- package/dist/review-verdict.js.map +1 -1
- package/dist/routes/attention-activity.d.ts.map +1 -1
- package/dist/routes/attention-activity.js +5 -2
- package/dist/routes/attention-activity.js.map +1 -1
- package/dist/routes/attention-providers.d.ts +0 -1
- package/dist/routes/attention-providers.d.ts.map +1 -1
- package/dist/routes/attention-providers.js +5 -6
- package/dist/routes/attention-providers.js.map +1 -1
- package/dist/routes/config.d.ts +44 -5
- package/dist/routes/config.d.ts.map +1 -1
- package/dist/routes/config.js +181 -58
- package/dist/routes/config.js.map +1 -1
- package/dist/routes/contracts.d.ts +4 -0
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/contracts.js +3 -1
- package/dist/routes/contracts.js.map +1 -1
- package/dist/routes/custom-provider-source.d.ts +8 -0
- package/dist/routes/custom-provider-source.d.ts.map +1 -1
- package/dist/routes/custom-provider-source.js +22 -1
- package/dist/routes/custom-provider-source.js.map +1 -1
- package/dist/routes/oauth.js +1 -1
- package/dist/routes/oauth.js.map +1 -1
- package/dist/routes/projects.d.ts +1 -1
- package/dist/routes/projects.d.ts.map +1 -1
- package/dist/routes/projects.js +1 -1
- package/dist/routes/projects.js.map +1 -1
- package/dist/routes/provider-credentials.d.ts +7 -2
- package/dist/routes/provider-credentials.d.ts.map +1 -1
- package/dist/routes/provider-credentials.js +30 -8
- package/dist/routes/provider-credentials.js.map +1 -1
- package/dist/routes/skills.d.ts +2 -4
- package/dist/routes/skills.d.ts.map +1 -1
- package/dist/routes/skills.js +19 -65
- package/dist/routes/skills.js.map +1 -1
- package/dist/routes/source-control-sessions.d.ts +9 -1
- package/dist/routes/source-control-sessions.d.ts.map +1 -1
- package/dist/routes/source-control-sessions.js +131 -7
- package/dist/routes/source-control-sessions.js.map +1 -1
- package/dist/routes/surface.d.ts +3 -2
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +7 -3
- package/dist/routes/surface.js.map +1 -1
- package/dist/routes/work-items.d.ts.map +1 -1
- package/dist/routes/work-items.js +60 -120
- package/dist/routes/work-items.js.map +1 -1
- package/dist/rules/binding-context.js +7 -7
- package/dist/rules/binding-context.js.map +1 -1
- package/dist/rules/dispatch-errors.d.ts.map +1 -1
- package/dist/rules/dispatch-errors.js +12 -0
- package/dist/rules/dispatch-errors.js.map +1 -1
- package/dist/rules/dispatcher.d.ts +8 -1
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +117 -12
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/processor.d.ts.map +1 -1
- package/dist/rules/processor.js +2 -1
- package/dist/rules/processor.js.map +1 -1
- package/dist/rules/start-coordinator.d.ts +4 -0
- package/dist/rules/start-coordinator.d.ts.map +1 -1
- package/dist/rules/start-coordinator.js +36 -4
- package/dist/rules/start-coordinator.js.map +1 -1
- package/dist/rules/tools.d.ts.map +1 -1
- package/dist/rules/tools.js +82 -3
- package/dist/rules/tools.js.map +1 -1
- package/dist/rules/transition-service.d.ts +17 -0
- package/dist/rules/transition-service.d.ts.map +1 -1
- package/dist/rules/transition-service.js +25 -0
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/rules/types.d.ts +2 -4
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/types.js +1 -4
- package/dist/rules/types.js.map +1 -1
- package/dist/sandbox/local-factory-sandbox.d.ts.map +1 -1
- package/dist/sandbox/local-factory-sandbox.js +1 -0
- package/dist/sandbox/local-factory-sandbox.js.map +1 -1
- package/dist/sandbox/session-retirement.d.ts +27 -3
- package/dist/sandbox/session-retirement.d.ts.map +1 -1
- package/dist/sandbox/session-retirement.js +158 -20
- package/dist/sandbox/session-retirement.js.map +1 -1
- package/dist/secret-encryption.d.ts.map +1 -1
- package/dist/secret-encryption.js +65 -25
- package/dist/secret-encryption.js.map +1 -1
- package/dist/session/channel-reply-processor.d.ts +36 -0
- package/dist/session/channel-reply-processor.d.ts.map +1 -0
- package/dist/session/channel-reply-processor.js +46 -0
- package/dist/session/channel-reply-processor.js.map +1 -0
- package/dist/session/channel-session-link-processor.d.ts +39 -0
- package/dist/session/channel-session-link-processor.d.ts.map +1 -0
- package/dist/session/channel-session-link-processor.js +100 -0
- package/dist/session/channel-session-link-processor.js.map +1 -0
- package/dist/session/credential-policy.d.ts +1 -1
- package/dist/session/credential-policy.d.ts.map +1 -1
- package/dist/session/credential-policy.js +7 -6
- package/dist/session/credential-policy.js.map +1 -1
- package/dist/session/default-model-hydration.d.ts +1 -0
- package/dist/session/default-model-hydration.d.ts.map +1 -1
- package/dist/session/default-model-hydration.js +3 -2
- package/dist/session/default-model-hydration.js.map +1 -1
- package/dist/session/environment-state-processor.js +1 -1
- package/dist/session/environment-state-processor.js.map +1 -1
- package/dist/session/factory-session.d.ts +19 -1
- package/dist/session/factory-session.d.ts.map +1 -1
- package/dist/session/factory-session.js +5 -2
- package/dist/session/factory-session.js.map +1 -1
- package/dist/session/filesystem-capture.d.ts +3 -3
- package/dist/session/filesystem-capture.d.ts.map +1 -1
- package/dist/session/filesystem-capture.js +16 -17
- package/dist/session/filesystem-capture.js.map +1 -1
- package/dist/session/first-exec-capture.d.ts +1 -1
- package/dist/session/first-exec-capture.d.ts.map +1 -1
- package/dist/session/first-exec-capture.js +1 -1
- package/dist/session/first-exec-capture.js.map +1 -1
- package/dist/session/first-message-capture.d.ts +1 -1
- package/dist/session/first-message-capture.d.ts.map +1 -1
- package/dist/session/first-message-capture.js +1 -1
- package/dist/session/first-message-capture.js.map +1 -1
- package/dist/session/live-sessions.d.ts +1 -1
- package/dist/session/live-sessions.js +1 -1
- package/dist/session/live-sessions.js.map +1 -1
- package/dist/session/memory-settings-hydration.d.ts +1 -1
- package/dist/session/memory-settings-hydration.d.ts.map +1 -1
- package/dist/session/memory-settings-hydration.js +1 -1
- package/dist/session/memory-settings-hydration.js.map +1 -1
- package/dist/session/reply-credential-processor.d.ts +15 -0
- package/dist/session/reply-credential-processor.d.ts.map +1 -0
- package/dist/session/reply-credential-processor.js +38 -0
- package/dist/session/reply-credential-processor.js.map +1 -0
- package/dist/session/resource-migration.d.ts +87 -0
- package/dist/session/resource-migration.d.ts.map +1 -0
- package/dist/session/resource-migration.js +163 -0
- package/dist/session/resource-migration.js.map +1 -0
- package/dist/session/run-audit.d.ts +24 -0
- package/dist/session/run-audit.d.ts.map +1 -1
- package/dist/session/run-audit.js +93 -7
- package/dist/session/run-audit.js.map +1 -1
- package/dist/session/session-threads.d.ts +49 -0
- package/dist/session/session-threads.d.ts.map +1 -0
- package/dist/session/session-threads.js +70 -0
- package/dist/session/session-threads.js.map +1 -0
- package/dist/session/source-control-tools.d.ts +19 -1
- package/dist/session/source-control-tools.d.ts.map +1 -1
- package/dist/session/source-control-tools.js +78 -11
- package/dist/session/source-control-tools.js.map +1 -1
- package/dist/session/thinking-default.d.ts.map +1 -1
- package/dist/session/thinking-default.js +3 -4
- package/dist/session/thinking-default.js.map +1 -1
- package/dist/session/thread-session-stamp.d.ts +21 -0
- package/dist/session/thread-session-stamp.d.ts.map +1 -0
- package/dist/session/thread-session-stamp.js +20 -0
- package/dist/session/thread-session-stamp.js.map +1 -0
- package/dist/session/thread-title-mirror.d.ts +1 -1
- package/dist/session/thread-title-mirror.d.ts.map +1 -1
- package/dist/session/thread-title-mirror.js +1 -1
- package/dist/session/thread-title-mirror.js.map +1 -1
- package/dist/session/work-item-repository.d.ts +1 -1
- package/dist/session/work-item-repository.d.ts.map +1 -1
- package/dist/session/work-item-repository.js.map +1 -1
- package/dist/skills/service.d.ts +6 -8
- package/dist/skills/service.d.ts.map +1 -1
- package/dist/skills/service.js +3 -3
- package/dist/skills/service.js.map +1 -1
- package/dist/storage/domains/audit/agent-audit.d.ts.map +1 -1
- package/dist/storage/domains/audit/agent-audit.js +2 -2
- package/dist/storage/domains/audit/agent-audit.js.map +1 -1
- package/dist/storage/domains/audit/domain.js +1 -1
- package/dist/storage/domains/filesystem/base.d.ts +4 -0
- package/dist/storage/domains/filesystem/base.d.ts.map +1 -1
- package/dist/storage/domains/filesystem/base.js +5 -0
- package/dist/storage/domains/filesystem/base.js.map +1 -1
- package/dist/storage/domains/integrations/base.d.ts +8 -0
- package/dist/storage/domains/integrations/base.d.ts.map +1 -1
- package/dist/storage/domains/integrations/base.js +7 -0
- package/dist/storage/domains/integrations/base.js.map +1 -1
- package/dist/storage/domains/projects/base.d.ts +6 -0
- package/dist/storage/domains/projects/base.d.ts.map +1 -1
- package/dist/storage/domains/projects/base.js +12 -0
- package/dist/storage/domains/projects/base.js.map +1 -1
- package/dist/storage/domains/source-control/base.d.ts +28 -0
- package/dist/storage/domains/source-control/base.d.ts.map +1 -1
- package/dist/storage/domains/source-control/base.js +48 -0
- package/dist/storage/domains/source-control/base.js.map +1 -1
- package/dist/storage/domains/source-control/inmemory.d.ts +8 -0
- package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/source-control/inmemory.js +13 -1
- package/dist/storage/domains/source-control/inmemory.js.map +1 -1
- package/dist/storage/domains/work-items/base.d.ts +79 -7
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +172 -30
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/timing.d.ts +23 -0
- package/dist/timing.d.ts.map +1 -1
- package/dist/timing.js +85 -6
- package/dist/timing.js.map +1 -1
- package/dist/tools/annotations.d.ts +7 -0
- package/dist/tools/annotations.d.ts.map +1 -0
- package/dist/tools/annotations.js +102 -0
- package/dist/tools/annotations.js.map +1 -0
- package/dist/tools/approval-tools.d.ts +15 -0
- package/dist/tools/approval-tools.d.ts.map +1 -0
- package/dist/tools/approval-tools.js +79 -0
- package/dist/tools/approval-tools.js.map +1 -0
- package/dist/tools/deliver.d.ts +71 -0
- package/dist/tools/deliver.d.ts.map +1 -0
- package/dist/tools/deliver.js +129 -0
- package/dist/tools/deliver.js.map +1 -0
- package/dist/tools/index.d.ts +30 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +36 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/messaging-tools.d.ts +28 -0
- package/dist/tools/messaging-tools.d.ts.map +1 -0
- package/dist/tools/messaging-tools.js +396 -0
- package/dist/tools/messaging-tools.js.map +1 -0
- package/dist/tools/permissions.d.ts +31 -0
- package/dist/tools/permissions.d.ts.map +1 -0
- package/dist/tools/permissions.js +48 -0
- package/dist/tools/permissions.js.map +1 -0
- package/dist/tools/read-tools.d.ts +30 -0
- package/dist/tools/read-tools.d.ts.map +1 -0
- package/dist/tools/read-tools.js +293 -0
- package/dist/tools/read-tools.js.map +1 -0
- package/dist/tools/reports.d.ts +174 -0
- package/dist/tools/reports.d.ts.map +1 -0
- package/dist/tools/reports.js +380 -0
- package/dist/tools/reports.js.map +1 -0
- package/dist/tools/run-watch.d.ts +46 -0
- package/dist/tools/run-watch.d.ts.map +1 -0
- package/dist/tools/run-watch.js +102 -0
- package/dist/tools/run-watch.js.map +1 -0
- package/dist/tools/scope.d.ts +54 -0
- package/dist/tools/scope.d.ts.map +1 -0
- package/dist/tools/scope.js +87 -0
- package/dist/tools/scope.js.map +1 -0
- package/dist/tools/session-tools.d.ts +43 -0
- package/dist/tools/session-tools.d.ts.map +1 -0
- package/dist/tools/session-tools.js +410 -0
- package/dist/tools/session-tools.js.map +1 -0
- package/dist/tools/sessions-state-processor.d.ts +41 -0
- package/dist/tools/sessions-state-processor.d.ts.map +1 -0
- package/dist/tools/sessions-state-processor.js +190 -0
- package/dist/tools/sessions-state-processor.js.map +1 -0
- package/dist/tools/side-sessions.d.ts +53 -0
- package/dist/tools/side-sessions.d.ts.map +1 -0
- package/dist/tools/side-sessions.js +83 -0
- package/dist/tools/side-sessions.js.map +1 -0
- package/dist/tools/work-item-tools.d.ts +28 -0
- package/dist/tools/work-item-tools.d.ts.map +1 -0
- package/dist/tools/work-item-tools.js +342 -0
- package/dist/tools/work-item-tools.js.map +1 -0
- package/dist/work-items/create-work-item.d.ts +55 -0
- package/dist/work-items/create-work-item.d.ts.map +1 -0
- package/dist/work-items/create-work-item.js +101 -0
- package/dist/work-items/create-work-item.js.map +1 -0
- package/dist/work-items/decision-actions.d.ts +42 -0
- package/dist/work-items/decision-actions.d.ts.map +1 -0
- package/dist/work-items/decision-actions.js +70 -0
- package/dist/work-items/decision-actions.js.map +1 -0
- package/dist/workspace.d.ts +1 -1
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +15 -7
- package/dist/workspace.js.map +1 -1
- package/factory-skills/factory-gitlab-rereview/SKILL.md +1 -1
- package/factory-skills/factory-gitlab-review/SKILL.md +1 -1
- package/factory-skills/factory-plan/SKILL.md +4 -4
- package/factory-skills/factory-rereview/SKILL.md +3 -1
- package/factory-skills/factory-review/SKILL.md +3 -1
- package/factory-skills/factory-self-review/SKILL.md +46 -0
- package/package.json +13 -13
package/dist/factory.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { timedPhase } from "./timing.js";
|
|
2
|
-
import { buildAuthDisabledRoutes, buildAuthRoutes, createFactoryAuthGate, createFactoryRouteAuth, factoryUserOrgId, getFactoryAuthOrgId, getFactoryAuthUserFromContext, getFactoryAuthUserId } from "./auth.js";
|
|
1
|
+
import { createRequestTimingMiddleware, factoryTimingEnabled, instrumentAsyncMethods, timedPhase } from "./timing.js";
|
|
2
|
+
import { buildAuthDisabledRoutes, buildAuthRoutes, createFactoryAuthGate, createFactoryInteractiveMarker, createFactoryRouteAuth, factoryUserOrgId, getFactoryAuthOrgId, getFactoryAuthUserFromContext, getFactoryAuthUserId } from "./auth.js";
|
|
3
3
|
import { assertFactoryConfigVersion } from "./rules/validation.js";
|
|
4
|
-
import { isTerminalWorkItem } from "./boards/semantics.js";
|
|
4
|
+
import { boardForWorkItem, isTerminalWorkItem } from "./boards/semantics.js";
|
|
5
5
|
import { createBoardRegistry } from "./boards/registry.js";
|
|
6
6
|
import "./boards/index.js";
|
|
7
7
|
import { isValidGitRef } from "./sandbox/git-ref.js";
|
|
@@ -21,32 +21,41 @@ import { PlatformApiClient, platformApiClientConfigFromEnv } from "./integration
|
|
|
21
21
|
import { buildPlatformConnectRoutes } from "./integrations/platform/connect/routes.js";
|
|
22
22
|
import { observeSessionFirstExec } from "./session/first-exec-capture.js";
|
|
23
23
|
import { observeSessionFilesystem } from "./session/filesystem-capture.js";
|
|
24
|
+
import { sessionMemoryResourceId, sessionStampCounts } from "./session/session-threads.js";
|
|
24
25
|
import { createPlaintextFactorySecretEncryption } from "./secret-encryption.js";
|
|
25
26
|
import { ModelCredentialsStorage } from "./storage/domains/credentials/base.js";
|
|
26
27
|
import { createTenantCredentialPrimer, primeTenantCredentials, registerTenantCredentialResolver } from "./routes/tenant-credentials.js";
|
|
27
|
-
import {
|
|
28
|
+
import { hasResolvedOrg } from "./session/org-seed.js";
|
|
29
|
+
import { createSessionAsRowOwner, prepareSessionRunContext } from "./integrations/subscription-session.js";
|
|
28
30
|
import { PlatformGithubIntegration } from "./integrations/platform/github/integration.js";
|
|
29
31
|
import { PlatformGitLabIntegration } from "./integrations/platform/gitlab/integration.js";
|
|
30
32
|
import { PlatformIncidentioIntegration } from "./integrations/platform/incidentio/integration.js";
|
|
31
33
|
import { PlatformJiraIntegration } from "./integrations/platform/jira/integration.js";
|
|
32
34
|
import { PlatformLinearIntegration } from "./integrations/platform/linear/integration.js";
|
|
33
35
|
import { FactoryProjectsStorage } from "./storage/domains/projects/base.js";
|
|
36
|
+
import { SourceControlStorage } from "./storage/domains/source-control/base.js";
|
|
37
|
+
import { createSourceControlSessionLookup } from "./session/factory-session.js";
|
|
38
|
+
import { AuditStorage } from "./storage/domains/audit/base.js";
|
|
39
|
+
import { resolveFactoryToolScope } from "./tools/scope.js";
|
|
40
|
+
import { deliverFactorySessionNotification } from "./tools/deliver.js";
|
|
41
|
+
import { createSessionApprovalNotifier, createSessionRunEndReporter, createStageChangeNotifier, createWorkItemRunEndReporter } from "./tools/reports.js";
|
|
34
42
|
import { resolveFactoryCredentialTenant } from "./session/credential-policy.js";
|
|
35
43
|
import { hydrateSessionMemorySettings, layerPersonalMemorySettings } from "./session/memory-settings-hydration.js";
|
|
36
44
|
import { MemorySettingsStorage, factoryMemorySettingsUserId } from "./storage/domains/memory-settings/base.js";
|
|
37
45
|
import { resolveDeploymentModelProviders } from "./routes/config.js";
|
|
38
|
-
import {
|
|
46
|
+
import { observeSessionRunEnd } from "./session/run-audit.js";
|
|
47
|
+
import { observeSessionRunReports } from "./tools/run-watch.js";
|
|
48
|
+
import { applyFactoryToolPermissions } from "./tools/permissions.js";
|
|
49
|
+
import { createFactoryTools } from "./tools/index.js";
|
|
50
|
+
import { buildFactoryMcpRoutes, resolveMcpAuthorizationServers } from "./mcp/routes.js";
|
|
51
|
+
import { createCustomProvidersPrimer, primeCustomProvidersForRequestContext, registerCustomProvidersSource } from "./routes/custom-provider-source.js";
|
|
39
52
|
import { ProjectRoutes } from "./routes/projects.js";
|
|
40
|
-
import { SourceControlStorage } from "./storage/domains/source-control/base.js";
|
|
41
|
-
import { createSourceControlSessionLookup } from "./session/factory-session.js";
|
|
42
53
|
import { FactoryTransitionService } from "./rules/transition-service.js";
|
|
43
|
-
import { AuditStorage } from "./storage/domains/audit/base.js";
|
|
44
54
|
import { AuditDomain } from "./storage/domains/audit/domain.js";
|
|
45
55
|
import { QueueHealthStorage } from "./storage/domains/queue-health/base.js";
|
|
46
56
|
import { assembleFactoryApiRoutes, buildIntegrationContext } from "./routes/surface.js";
|
|
47
57
|
import { TelemetryRoutes } from "./routes/telemetry.js";
|
|
48
58
|
import { readFactorySessionScope, resolveFactorySessionAddress } from "./rules/binding-context.js";
|
|
49
|
-
import { observeSessionRunEnd } from "./session/run-audit.js";
|
|
50
59
|
import { FactoryFeedReader } from "./storage/domains/comments/feed-context.js";
|
|
51
60
|
import { FactoryDecisionDispatcher } from "./rules/dispatcher.js";
|
|
52
61
|
import { FactoryPhaseStateProcessor, reportMemorySettingsUnavailable } from "./rules/processor.js";
|
|
@@ -56,11 +65,16 @@ import { createFactoryTransitionTools } from "./rules/tools.js";
|
|
|
56
65
|
import { CallbackFactorySandbox } from "./sandbox/callback-factory-sandbox.js";
|
|
57
66
|
import { SessionRetirementCoordinator } from "./sandbox/session-retirement.js";
|
|
58
67
|
import { handleServerError } from "./server-error.js";
|
|
68
|
+
import { FactoryChannelReplyProcessor } from "./session/channel-reply-processor.js";
|
|
69
|
+
import { FactoryChannelSessionLinkProcessor } from "./session/channel-session-link-processor.js";
|
|
59
70
|
import { hydrateSessionDefaultModel } from "./session/default-model-hydration.js";
|
|
60
71
|
import { observeSessionFirstMessage } from "./session/first-message-capture.js";
|
|
61
72
|
import { LiveSessions } from "./session/live-sessions.js";
|
|
73
|
+
import { FactoryReplyCredentialProcessor } from "./session/reply-credential-processor.js";
|
|
74
|
+
import { migrateSessionResources } from "./session/resource-migration.js";
|
|
62
75
|
import { createSourceControlTools } from "./session/source-control-tools.js";
|
|
63
76
|
import { readFactoryThinkingLevel, resolveFactoryThinkingLevel } from "./session/thinking-default.js";
|
|
77
|
+
import { observeSessionThreadStamp } from "./session/thread-session-stamp.js";
|
|
64
78
|
import { observeSessionThreadTitle } from "./session/thread-title-mirror.js";
|
|
65
79
|
import { createSpaStaticMiddleware, resolveUiDistDir } from "./spa-static.js";
|
|
66
80
|
import { createStateSigner } from "./state-signing.js";
|
|
@@ -72,9 +86,12 @@ import { CustomProvidersStorage } from "./storage/domains/custom-providers/base.
|
|
|
72
86
|
import { FilesystemStorage } from "./storage/domains/filesystem/base.js";
|
|
73
87
|
import { IntegrationStorage } from "./storage/domains/integrations/base.js";
|
|
74
88
|
import { ModelDefaultsStorage } from "./storage/domains/model-defaults/base.js";
|
|
89
|
+
import { FactorySessionsStateProcessor } from "./tools/sessions-state-processor.js";
|
|
90
|
+
import { RequestContext } from "@mastra/core/request-context";
|
|
75
91
|
import { hasAuthInit, isUserProvider } from "@mastra/core/server";
|
|
76
92
|
import { MastraAuthStudio } from "@mastra/auth-studio";
|
|
77
93
|
import { prepareAgentControllerMount } from "@mastra/code-sdk";
|
|
94
|
+
import { getDynamicMemory } from "@mastra/code-sdk/agents/memory";
|
|
78
95
|
import { AgentControllerChannels } from "@mastra/core/channels";
|
|
79
96
|
import { EventEmitterPubSub } from "@mastra/core/events";
|
|
80
97
|
import { describeFactorySandbox, isFactorySandbox } from "@mastra/core/workspace";
|
|
@@ -100,6 +117,12 @@ import { describeFactorySandbox, isFactorySandbox } from "@mastra/core/workspace
|
|
|
100
117
|
* and the storage domains those capabilities require.
|
|
101
118
|
*/
|
|
102
119
|
const CONTROLLER_ID = "code";
|
|
120
|
+
/** Why a wake couldn't be run as its Factory session's owner. */
|
|
121
|
+
const WAKE_OWNER_UNRESOLVED = {
|
|
122
|
+
"session-not-found": "no Factory session row names its owner",
|
|
123
|
+
"organization-unresolved": "its owner's organization is unresolved",
|
|
124
|
+
"organization-mismatch": "its owner's organization doesn't match"
|
|
125
|
+
};
|
|
103
126
|
function hasPlatformCredentials() {
|
|
104
127
|
return Boolean(process.env.MASTRA_PLATFORM_ACCESS_TOKEN?.trim() || process.env.MASTRA_PLATFORM_SECRET_KEY?.trim());
|
|
105
128
|
}
|
|
@@ -199,6 +222,7 @@ var MastraFactory = class {
|
|
|
199
222
|
#configVersion;
|
|
200
223
|
#prepared;
|
|
201
224
|
#dispatcher;
|
|
225
|
+
#startCoordinator;
|
|
202
226
|
#factoryProcessor;
|
|
203
227
|
/** Environment builds through the sandbox's `builds`; undefined when the sandbox has none. */
|
|
204
228
|
#environmentBuilds;
|
|
@@ -233,7 +257,7 @@ var MastraFactory = class {
|
|
|
233
257
|
this.#preparing = true;
|
|
234
258
|
const publicOrigin = (this.#config.publicUrl ?? "http://localhost:4111").replace(/\/+$/, "");
|
|
235
259
|
const allowedOrigins = (this.#config.allowedOrigins ?? []).map((o) => o.replace(/\/+$/, "")).filter(Boolean);
|
|
236
|
-
const storage = this.#config.storage;
|
|
260
|
+
const storage = instrumentAsyncMethods(this.#config.storage, "storage");
|
|
237
261
|
const vector = this.#config.vector;
|
|
238
262
|
const pubsub = this.#config.pubsub;
|
|
239
263
|
const eventBus = pubsub ?? new EventEmitterPubSub();
|
|
@@ -243,6 +267,8 @@ var MastraFactory = class {
|
|
|
243
267
|
const secretEncryption = this.#config.secretEncryption ?? createPlaintextFactorySecretEncryption();
|
|
244
268
|
const deploymentModelProviders = resolveDeploymentModelProviders(this.#config.deploymentModelProviders);
|
|
245
269
|
const routeAuth = createFactoryRouteAuth(auth);
|
|
270
|
+
const mcpConfig = this.#config.mcp;
|
|
271
|
+
const mcpAuthorizationServers = mcpConfig === false || mcpConfig?.enabled === false ? [] : resolveMcpAuthorizationServers(auth?.name, mcpConfig);
|
|
246
272
|
const integrations = [...this.#config.integrations ?? []];
|
|
247
273
|
const explicitGithub = integrations.some((integration) => integration.id === "github");
|
|
248
274
|
let installedPlatformGithub = false;
|
|
@@ -349,7 +375,8 @@ var MastraFactory = class {
|
|
|
349
375
|
});
|
|
350
376
|
if (integration.versionControl && integrationSourceControl) integration.versionControl.initialize({ storage: integrationSourceControl });
|
|
351
377
|
}
|
|
352
|
-
const
|
|
378
|
+
const sourceControlHandles = [.../* @__PURE__ */ new Set(["github", ...integrations.filter((integration) => integration.versionControl).map(({ id }) => id)])].map((id) => sourceControlStorage.forIntegration(id));
|
|
379
|
+
const sourceControlSessions = createSourceControlSessionLookup(sourceControlHandles);
|
|
353
380
|
if (auth) registerTenantCredentialResolver(modelCredentialsStorage, deploymentModelProviders, (requestContext) => resolveFactoryCredentialTenant(requestContext, {
|
|
354
381
|
projects: factoryProjectsStorage,
|
|
355
382
|
sourceControl: sourceControlSessions,
|
|
@@ -371,11 +398,32 @@ var MastraFactory = class {
|
|
|
371
398
|
});
|
|
372
399
|
const intakeReady = integrations.some((integration) => integration.intake !== void 0) && storage.isDomainReady("intake");
|
|
373
400
|
const factoryReady = storage.isDomainReady("projects") && storage.isDomainReady("work-items");
|
|
401
|
+
if (storage.isDomainReady("source-control") && storage.isDomainReady("work-items")) await timedPhase("prepare.migrate.sessionResources", async () => {
|
|
402
|
+
try {
|
|
403
|
+
const mastraStorage = storage.getMastraStorage();
|
|
404
|
+
const memory = await mastraStorage.getStore("memory");
|
|
405
|
+
if (!memory) return;
|
|
406
|
+
const sessionMemory = getDynamicMemory(mastraStorage, vector);
|
|
407
|
+
await migrateSessionResources({
|
|
408
|
+
sessions: sourceControlStorage,
|
|
409
|
+
workItems: workItemsStorage,
|
|
410
|
+
...storage.isDomainReady("integrations") ? { integrations: integrationStorage } : {},
|
|
411
|
+
memory,
|
|
412
|
+
threads: sessionMemory({ requestContext: new RequestContext() })
|
|
413
|
+
});
|
|
414
|
+
await sessionMemory.settled();
|
|
415
|
+
} catch (error) {
|
|
416
|
+
console.warn(`[factory] session resource migration stopped early: ${error instanceof Error ? error.message : error}`);
|
|
417
|
+
}
|
|
418
|
+
});
|
|
374
419
|
const knowledgeEnabled = this.#config.knowledge !== void 0 || process.env.MASTRACODE_EXPERIMENTAL_SUBCONSCIOUS === "1";
|
|
375
420
|
const githubIntegration = integrations.find((integration) => integration.id === "github");
|
|
376
421
|
const gitlabIntegration = integrations.find((integration) => integration.id === "gitlab" && integration.intake && integration.versionControl);
|
|
377
422
|
const workItemsReady = storage.isDomainReady("work-items");
|
|
378
|
-
const sessionRetirement = sandboxConfig && storage.isDomainReady("source-control") ? new SessionRetirementCoordinator({
|
|
423
|
+
const sessionRetirement = sandboxConfig && storage.isDomainReady("source-control") ? new SessionRetirementCoordinator({
|
|
424
|
+
invalidateSession: (sessionId) => workspaceRegistry.invalidateSession(sessionId),
|
|
425
|
+
sandbox: sandboxConfig
|
|
426
|
+
}) : void 0;
|
|
379
427
|
const retireTerminalSessions = sessionRetirement && workItemsReady ? async ({ orgId, workItemId }) => {
|
|
380
428
|
const item = await workItemsStorage.get({
|
|
381
429
|
orgId,
|
|
@@ -402,11 +450,73 @@ var MastraFactory = class {
|
|
|
402
450
|
abortSession: async (binding) => {
|
|
403
451
|
const controller = this.#prepared?.base.controller;
|
|
404
452
|
if (!controller) return;
|
|
405
|
-
const session = await controller.
|
|
453
|
+
const session = await controller.getSession(binding.sessionId);
|
|
406
454
|
if (session?.stream.isActive()) session.abort();
|
|
407
455
|
},
|
|
408
456
|
...retireTerminalSessions ? { releaseSandboxes: retireTerminalSessions } : {}
|
|
409
457
|
}) : void 0;
|
|
458
|
+
const factoryMessaging = async () => {
|
|
459
|
+
const controller = this.#prepared?.base.controller;
|
|
460
|
+
const notifications = await controller?.getMastra()?.getStorage()?.getStore("notifications");
|
|
461
|
+
return controller && notifications ? {
|
|
462
|
+
controller,
|
|
463
|
+
notifications
|
|
464
|
+
} : null;
|
|
465
|
+
};
|
|
466
|
+
const factoryReporting = async () => {
|
|
467
|
+
const messaging = await factoryMessaging();
|
|
468
|
+
if (!messaging) return null;
|
|
469
|
+
return {
|
|
470
|
+
notifications: messaging.notifications,
|
|
471
|
+
deliver: (target, notification, options) => deliverFactorySessionNotification({
|
|
472
|
+
controller: messaging.controller,
|
|
473
|
+
sessions: sourceControlSessions,
|
|
474
|
+
runs: workItemsStorage,
|
|
475
|
+
target,
|
|
476
|
+
notification,
|
|
477
|
+
...options
|
|
478
|
+
})
|
|
479
|
+
};
|
|
480
|
+
};
|
|
481
|
+
const sessionReports = {
|
|
482
|
+
sessions: sourceControlSessions,
|
|
483
|
+
workItems: workItemsStorage,
|
|
484
|
+
reporting: factoryReporting
|
|
485
|
+
};
|
|
486
|
+
const reportSessionRunEnd = createSessionRunEndReporter(sessionReports);
|
|
487
|
+
const resolveWakeSession = async ({ resourceId, threadId, thread }) => {
|
|
488
|
+
const stamp = (thread === void 0 ? await this.#prepared?.base.controller.queryThreadById({ threadId }) : thread)?.metadata?.factorySessionId;
|
|
489
|
+
const candidates = [.../* @__PURE__ */ new Set([
|
|
490
|
+
typeof stamp === "string" ? stamp : "",
|
|
491
|
+
threadId,
|
|
492
|
+
resourceId
|
|
493
|
+
])].filter(Boolean);
|
|
494
|
+
for (const sessionId of candidates) {
|
|
495
|
+
const row = await sourceControlSessions.getBySessionId(sessionId);
|
|
496
|
+
if (row && (!(sessionId !== threadId && sessionId !== resourceId) || sessionStampCounts(row, resourceId)) && (resourceId === sessionId || resourceId === await sessionMemoryResourceId(this.#prepared?.base.controller, row, workItemsStorage))) return {
|
|
497
|
+
sessionId,
|
|
498
|
+
row
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
return {
|
|
502
|
+
sessionId: threadId,
|
|
503
|
+
row: null
|
|
504
|
+
};
|
|
505
|
+
};
|
|
506
|
+
const failWake = async ({ sessionId, threadId }, reason) => {
|
|
507
|
+
const message = `Factory session ${sessionId} can't be woken as its owner: ${reason}.`;
|
|
508
|
+
await reportSessionRunEnd({
|
|
509
|
+
sessionId,
|
|
510
|
+
threadId,
|
|
511
|
+
since: /* @__PURE__ */ new Date(),
|
|
512
|
+
outcome: {
|
|
513
|
+
status: "failed",
|
|
514
|
+
reason: message,
|
|
515
|
+
failureCode: "wake-owner-unresolved"
|
|
516
|
+
}
|
|
517
|
+
}).catch((error) => console.warn("[factory] Unable to report a failed wake.", error));
|
|
518
|
+
throw new Error(message);
|
|
519
|
+
};
|
|
410
520
|
const onTerminalStage = terminalCleanup ? (args) => terminalCleanup({
|
|
411
521
|
orgId: args.orgId,
|
|
412
522
|
factoryProjectId: args.factoryProjectId,
|
|
@@ -426,9 +536,42 @@ var MastraFactory = class {
|
|
|
426
536
|
id: factoryProjectId
|
|
427
537
|
}))?.autoApprovePlans ?? false;
|
|
428
538
|
},
|
|
539
|
+
selfReviewEnabled: async ({ orgId, factoryProjectId }) => {
|
|
540
|
+
await factoryProjectsStorage.ensureReady();
|
|
541
|
+
return (await factoryProjectsStorage.get({
|
|
542
|
+
orgId,
|
|
543
|
+
id: factoryProjectId
|
|
544
|
+
}))?.selfReviewEnabled ?? false;
|
|
545
|
+
},
|
|
429
546
|
...onTerminalStage ? { onTerminalStage } : {},
|
|
547
|
+
onTransitionCommitted: createStageChangeNotifier({
|
|
548
|
+
workItems: workItemsStorage,
|
|
549
|
+
reporting: factoryReporting
|
|
550
|
+
}),
|
|
430
551
|
...githubIntegration ? { onAccepted: (args) => reconcileGithubAcceptanceLabels(githubIntegration, sourceControlStorage.forIntegration(githubIntegration.id), args) } : {}
|
|
431
552
|
}) : void 0;
|
|
553
|
+
const factoryToolDeps = {
|
|
554
|
+
workItems: workItemsStorage,
|
|
555
|
+
comments: workItemCommentsStorage,
|
|
556
|
+
feed: commentsDomain,
|
|
557
|
+
audit: auditStorage,
|
|
558
|
+
boards: this.#boards,
|
|
559
|
+
transitionService,
|
|
560
|
+
auditRecorder: auditDomain,
|
|
561
|
+
sessions: sourceControlSessions,
|
|
562
|
+
sessionModel: {
|
|
563
|
+
projects: factoryProjectsStorage,
|
|
564
|
+
modelDefaults: modelDefaultsStorage,
|
|
565
|
+
...auth ? { tenantCatalog: {
|
|
566
|
+
credentials: modelCredentialsStorage,
|
|
567
|
+
customProviders: customProvidersStorage,
|
|
568
|
+
deploymentProviders: deploymentModelProviders
|
|
569
|
+
} } : {}
|
|
570
|
+
},
|
|
571
|
+
intake: intakeStorage,
|
|
572
|
+
startCoordinator: () => this.#startCoordinator,
|
|
573
|
+
messaging: factoryMessaging
|
|
574
|
+
};
|
|
432
575
|
this.#environmentBuilds = this.#sandbox?.builds ? new EnvironmentBuildRunner({
|
|
433
576
|
sandbox: this.#sandbox,
|
|
434
577
|
projects: factoryProjectsStorage,
|
|
@@ -503,7 +646,7 @@ var MastraFactory = class {
|
|
|
503
646
|
...sessionRetirement ? { sessionRetirement } : {},
|
|
504
647
|
...workItemsReady ? {
|
|
505
648
|
workItems: workItemsStorage,
|
|
506
|
-
controller: {
|
|
649
|
+
controller: { getSession: async (sessionId) => this.#prepared?.base.controller.getSession(sessionId) }
|
|
507
650
|
} : {}
|
|
508
651
|
});
|
|
509
652
|
const loadMemorySettings = async ({ requestContext, binding }) => {
|
|
@@ -587,14 +730,78 @@ var MastraFactory = class {
|
|
|
587
730
|
workspaceRegistry
|
|
588
731
|
}),
|
|
589
732
|
disableGithubSignals: true,
|
|
590
|
-
prepareWakeRequestContext: async ({ requestContext, resourceId }) => {
|
|
591
|
-
if (!storage.isDomainReady("source-control"))
|
|
592
|
-
|
|
733
|
+
prepareWakeRequestContext: async ({ requestContext, resourceId, threadId }) => {
|
|
734
|
+
if (!storage.isDomainReady("source-control")) {
|
|
735
|
+
if (auth) await failWake({
|
|
736
|
+
sessionId: threadId,
|
|
737
|
+
threadId
|
|
738
|
+
}, "session storage is not ready");
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
const { sessionId, row } = await resolveWakeSession({
|
|
742
|
+
resourceId,
|
|
743
|
+
threadId
|
|
744
|
+
});
|
|
745
|
+
if (!row) {
|
|
746
|
+
if (auth) await failWake({
|
|
747
|
+
sessionId,
|
|
748
|
+
threadId
|
|
749
|
+
}, WAKE_OWNER_UNRESOLVED["session-not-found"]);
|
|
750
|
+
return;
|
|
751
|
+
}
|
|
752
|
+
const prepared = await prepareSessionRunContext(requestContext, sessionId, { sessions: sourceControlSessions });
|
|
753
|
+
if (prepared !== "prepared") {
|
|
754
|
+
if (auth) await failWake({
|
|
755
|
+
sessionId,
|
|
756
|
+
threadId
|
|
757
|
+
}, WAKE_OWNER_UNRESOLVED[prepared]);
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
await primeCustomProvidersForRequestContext(requestContext);
|
|
593
761
|
},
|
|
762
|
+
...auth ? { resumeWakeSession: async ({ resourceId, threadId }) => {
|
|
763
|
+
const controller = this.#prepared?.base.controller;
|
|
764
|
+
if (!controller) return failWake({
|
|
765
|
+
sessionId: threadId,
|
|
766
|
+
threadId
|
|
767
|
+
}, "the Factory is not started");
|
|
768
|
+
const thread = await controller.queryThreadById({ threadId });
|
|
769
|
+
if (!thread || thread.resourceId !== resourceId) return failWake({
|
|
770
|
+
sessionId: threadId,
|
|
771
|
+
threadId
|
|
772
|
+
}, `thread ${threadId} is not the session's`);
|
|
773
|
+
const { sessionId, row } = storage.isDomainReady("source-control") ? await resolveWakeSession({
|
|
774
|
+
resourceId,
|
|
775
|
+
threadId,
|
|
776
|
+
thread
|
|
777
|
+
}) : {
|
|
778
|
+
sessionId: threadId,
|
|
779
|
+
row: null
|
|
780
|
+
};
|
|
781
|
+
if (!row?.factoryProjectId) return failWake({
|
|
782
|
+
sessionId,
|
|
783
|
+
threadId
|
|
784
|
+
}, WAKE_OWNER_UNRESOLVED["session-not-found"]);
|
|
785
|
+
if (!hasResolvedOrg(row.orgId)) return failWake({
|
|
786
|
+
sessionId,
|
|
787
|
+
threadId
|
|
788
|
+
}, WAKE_OWNER_UNRESOLVED["organization-unresolved"]);
|
|
789
|
+
if (await controller.getSession(sessionId)) return;
|
|
790
|
+
await createSessionAsRowOwner(controller, {
|
|
791
|
+
sessionId,
|
|
792
|
+
ownerResourceId: resourceId,
|
|
793
|
+
row,
|
|
794
|
+
tags: {
|
|
795
|
+
factoryProjectId: row.factoryProjectId,
|
|
796
|
+
...row.projectRepositoryId ? { projectRepositoryId: row.projectRepositoryId } : {}
|
|
797
|
+
},
|
|
798
|
+
threadId
|
|
799
|
+
});
|
|
800
|
+
} } : {},
|
|
594
801
|
disableSettingsOmSeed: true,
|
|
595
802
|
hostInstructions: async ({ requestContext }) => {
|
|
596
803
|
const context = requestContext.get("controller");
|
|
597
|
-
if (context?.threadId && context.
|
|
804
|
+
if (context?.threadId && context.sessionId) {
|
|
598
805
|
const current = context.getState();
|
|
599
806
|
if (!(Boolean(current.factoryProjectId) && Boolean(current.factoryOrgId) && typeof current.untrustedCheckout === "boolean")) {
|
|
600
807
|
const recovered = await resolveFactorySessionAddress({
|
|
@@ -621,10 +828,31 @@ var MastraFactory = class {
|
|
|
621
828
|
...mastraStorageBackend ? { storageBackend: mastraStorageBackend } : {},
|
|
622
829
|
...this.#config.knowledge ? { knowledge: this.#config.knowledge } : {},
|
|
623
830
|
inputProcessors: async ({ requestContext }) => {
|
|
831
|
+
const channelReplyProcessor = new FactoryChannelReplyProcessor();
|
|
624
832
|
const environmentProcessor = new FactoryEnvironmentStateProcessor();
|
|
833
|
+
const sessionsProcessor = workItemsStorage && storage.isDomainReady("source-control") ? [new FactorySessionsStateProcessor({
|
|
834
|
+
authEnabled: routeAuth.enabled(),
|
|
835
|
+
sessions: sourceControlSessions,
|
|
836
|
+
projects: factoryProjectsStorage,
|
|
837
|
+
workItems: workItemsStorage,
|
|
838
|
+
boards: this.#boards,
|
|
839
|
+
isRunning: async (sessionId) => {
|
|
840
|
+
return (await this.#prepared?.base.controller.getSession(sessionId))?.stream.isActive() ?? false;
|
|
841
|
+
},
|
|
842
|
+
lastActivity: async (threadId) => {
|
|
843
|
+
const thread = await this.#prepared?.base.controller.queryThreadById({ threadId });
|
|
844
|
+
return thread?.updatedAt ? new Date(thread.updatedAt) : null;
|
|
845
|
+
},
|
|
846
|
+
notifications: async () => (await factoryMessaging())?.notifications ?? null
|
|
847
|
+
})] : [];
|
|
625
848
|
if (factoryProcessor) {
|
|
626
849
|
await factoryProcessor.prepareMemorySettings(requestContext);
|
|
627
|
-
return [
|
|
850
|
+
return [
|
|
851
|
+
channelReplyProcessor,
|
|
852
|
+
environmentProcessor,
|
|
853
|
+
...sessionsProcessor,
|
|
854
|
+
factoryProcessor
|
|
855
|
+
];
|
|
628
856
|
}
|
|
629
857
|
try {
|
|
630
858
|
await loadMemorySettings({
|
|
@@ -634,8 +862,13 @@ var MastraFactory = class {
|
|
|
634
862
|
} catch (error) {
|
|
635
863
|
reportMemorySettingsUnavailable(requestContext, error instanceof Error ? error.message : String(error));
|
|
636
864
|
}
|
|
637
|
-
return [
|
|
865
|
+
return [
|
|
866
|
+
channelReplyProcessor,
|
|
867
|
+
environmentProcessor,
|
|
868
|
+
...sessionsProcessor
|
|
869
|
+
];
|
|
638
870
|
},
|
|
871
|
+
outputProcessors: [new FactoryChannelSessionLinkProcessor(), new FactoryReplyCredentialProcessor()],
|
|
639
872
|
...vector ? { vector } : {},
|
|
640
873
|
...toolIntegrations.length > 0 || sourceControlToolProviders.length > 0 || workItemsStorage && transitionService ? { extraTools: async ({ requestContext }) => {
|
|
641
874
|
const tools = {};
|
|
@@ -651,7 +884,55 @@ var MastraFactory = class {
|
|
|
651
884
|
if (storage.isDomainReady("source-control")) mergeTools("source-control", await createSourceControlTools({
|
|
652
885
|
requestContext,
|
|
653
886
|
providers: sourceControlToolProviders,
|
|
654
|
-
audit: auditDomain
|
|
887
|
+
audit: auditDomain,
|
|
888
|
+
testChecksEnabled: async ({ orgId, factoryProjectId }) => {
|
|
889
|
+
await factoryProjectsStorage.ensureReady();
|
|
890
|
+
return (await factoryProjectsStorage.get({
|
|
891
|
+
orgId,
|
|
892
|
+
id: factoryProjectId
|
|
893
|
+
}))?.reviewTestChecksEnabled ?? false;
|
|
894
|
+
},
|
|
895
|
+
...workItemsStorage ? {
|
|
896
|
+
selfReviewApprovedHead: async () => {
|
|
897
|
+
const resolution = await resolveFactorySessionAddress({
|
|
898
|
+
requestContext,
|
|
899
|
+
storage: workItemsStorage
|
|
900
|
+
});
|
|
901
|
+
if (!resolution) return void 0;
|
|
902
|
+
const binding = resolution.binding ?? await workItemsStorage.findActiveRunBinding(resolution.address);
|
|
903
|
+
if (!binding) return void 0;
|
|
904
|
+
const item = await workItemsStorage.get({
|
|
905
|
+
orgId: binding.orgId,
|
|
906
|
+
id: binding.workItemId
|
|
907
|
+
});
|
|
908
|
+
if (!item || boardForWorkItem(item) !== "work") return void 0;
|
|
909
|
+
if (typeof item.metadata?.openPullRequestNumber === "number") return void 0;
|
|
910
|
+
if (item.metadata?.selfReviewVerdict === void 0) {
|
|
911
|
+
await factoryProjectsStorage.ensureReady();
|
|
912
|
+
if (!(await factoryProjectsStorage.get({
|
|
913
|
+
orgId: binding.orgId,
|
|
914
|
+
id: binding.factoryProjectId
|
|
915
|
+
}))?.selfReviewEnabled) return void 0;
|
|
916
|
+
}
|
|
917
|
+
const sha = item.metadata?.selfReviewedHeadSha;
|
|
918
|
+
return item.metadata?.selfReviewVerdict === "approve" && typeof sha === "string" ? sha : null;
|
|
919
|
+
},
|
|
920
|
+
boundChangeRequestId: async () => {
|
|
921
|
+
const resolution = await resolveFactorySessionAddress({
|
|
922
|
+
requestContext,
|
|
923
|
+
storage: workItemsStorage
|
|
924
|
+
});
|
|
925
|
+
if (!resolution) return void 0;
|
|
926
|
+
const binding = resolution.binding ?? await workItemsStorage.findActiveRunBinding(resolution.address);
|
|
927
|
+
if (binding?.role !== "review") return void 0;
|
|
928
|
+
const source = (await workItemsStorage.get({
|
|
929
|
+
orgId: binding.orgId,
|
|
930
|
+
id: binding.workItemId
|
|
931
|
+
}))?.externalSource;
|
|
932
|
+
if (!source || !/pull-request|merge-request/.test(source.type)) return void 0;
|
|
933
|
+
return /(\d+)$/.exec(source.externalId)?.[1];
|
|
934
|
+
}
|
|
935
|
+
} : {}
|
|
655
936
|
}));
|
|
656
937
|
if (workItemsStorage && transitionService) {
|
|
657
938
|
mergeTools("factory", await createFactoryTransitionTools({
|
|
@@ -668,6 +949,19 @@ var MastraFactory = class {
|
|
|
668
949
|
uiOrigin: reviewSourceUiOrigin,
|
|
669
950
|
...storage.isDomainReady("source-control") ? { sessions: sourceControlSessions } : {}
|
|
670
951
|
}));
|
|
952
|
+
if (storage.isDomainReady("source-control")) {
|
|
953
|
+
const scope = await resolveFactoryToolScope({
|
|
954
|
+
requestContext,
|
|
955
|
+
authEnabled: routeAuth.enabled(),
|
|
956
|
+
sessions: sourceControlSessions,
|
|
957
|
+
projects: factoryProjectsStorage,
|
|
958
|
+
workItems: workItemsStorage
|
|
959
|
+
});
|
|
960
|
+
if (scope) mergeTools("factory-tools", createFactoryTools({
|
|
961
|
+
scope,
|
|
962
|
+
deps: factoryToolDeps
|
|
963
|
+
}));
|
|
964
|
+
}
|
|
671
965
|
}
|
|
672
966
|
for (const { integration, ready, ensureReady } of toolIntegrations) {
|
|
673
967
|
if (!ready && ensureReady) try {
|
|
@@ -718,6 +1012,14 @@ var MastraFactory = class {
|
|
|
718
1012
|
} : {},
|
|
719
1013
|
buildApiRoutes: ({ controller, authStorage }) => [
|
|
720
1014
|
...auth ? buildAuthRoutes(auth, { publicUrl: publicOrigin }) : buildAuthDisabledRoutes(),
|
|
1015
|
+
...auth && mcpAuthorizationServers.length > 0 ? buildFactoryMcpRoutes({
|
|
1016
|
+
auth: routeAuth,
|
|
1017
|
+
publicOrigin,
|
|
1018
|
+
authorizationServers: mcpAuthorizationServers,
|
|
1019
|
+
projects: factoryProjectsStorage,
|
|
1020
|
+
sourceControls: sourceControlHandles,
|
|
1021
|
+
tools: factoryToolDeps
|
|
1022
|
+
}) : [],
|
|
721
1023
|
...new TelemetryRoutes({
|
|
722
1024
|
auth: routeAuth,
|
|
723
1025
|
providerName: auth?.name,
|
|
@@ -751,7 +1053,8 @@ var MastraFactory = class {
|
|
|
751
1053
|
configVersion,
|
|
752
1054
|
boardRegistry: this.#boards,
|
|
753
1055
|
factoryTransitionService: transitionService,
|
|
754
|
-
onFactoryRuntime: ({ transitionService: runtimeTransitionService, prepareBinding }) => {
|
|
1056
|
+
onFactoryRuntime: ({ transitionService: runtimeTransitionService, startCoordinator, prepareBinding }) => {
|
|
1057
|
+
this.#startCoordinator = startCoordinator;
|
|
755
1058
|
this.#dispatcher ??= new FactoryDecisionDispatcher({
|
|
756
1059
|
controller,
|
|
757
1060
|
transitionService: runtimeTransitionService,
|
|
@@ -787,6 +1090,10 @@ var MastraFactory = class {
|
|
|
787
1090
|
tenant,
|
|
788
1091
|
credentials: modelCredentialsStorage
|
|
789
1092
|
}),
|
|
1093
|
+
reportRunEnd: createWorkItemRunEndReporter({
|
|
1094
|
+
workItems: storage.getDomain("work-items"),
|
|
1095
|
+
reporting: factoryReporting
|
|
1096
|
+
}),
|
|
790
1097
|
resolveLinkedWorkItemParentId: async ({ orgId, factoryProjectId, decision }) => {
|
|
791
1098
|
if (decision.source !== "github-pr") return null;
|
|
792
1099
|
const repositoryId = decision.metadata?.githubRepositoryId;
|
|
@@ -818,18 +1125,25 @@ var MastraFactory = class {
|
|
|
818
1125
|
const onError = { onError: handleServerError };
|
|
819
1126
|
const uiDist = resolveUiDistDir();
|
|
820
1127
|
const spa = uiDist ? [createSpaStaticMiddleware(uiDist)] : [];
|
|
1128
|
+
const timing = factoryTimingEnabled ? [createRequestTimingMiddleware()] : [];
|
|
821
1129
|
if (!auth) return {
|
|
822
|
-
middleware: [
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
1130
|
+
middleware: [
|
|
1131
|
+
...timing,
|
|
1132
|
+
createFactoryInteractiveMarker(),
|
|
1133
|
+
createCustomProvidersPrimer({
|
|
1134
|
+
auth: routeAuth,
|
|
1135
|
+
storage: customProvidersStorage,
|
|
1136
|
+
authEnabled: false
|
|
1137
|
+
}),
|
|
1138
|
+
...spa
|
|
1139
|
+
],
|
|
827
1140
|
...cors,
|
|
828
1141
|
...onError
|
|
829
1142
|
};
|
|
830
1143
|
return {
|
|
831
1144
|
auth,
|
|
832
1145
|
middleware: [
|
|
1146
|
+
...timing,
|
|
833
1147
|
createFactoryAuthGate(auth),
|
|
834
1148
|
createTenantCredentialPrimer({
|
|
835
1149
|
auth: routeAuth,
|
|
@@ -847,6 +1161,7 @@ var MastraFactory = class {
|
|
|
847
1161
|
};
|
|
848
1162
|
}
|
|
849
1163
|
}));
|
|
1164
|
+
const notifyApprovalRequested = createSessionApprovalNotifier(sessionReports);
|
|
850
1165
|
prepared.base.controller.onSessionCreated((session) => {
|
|
851
1166
|
observeSessionFilesystem(session, {
|
|
852
1167
|
filesystem: filesystemStorage,
|
|
@@ -856,6 +1171,17 @@ var MastraFactory = class {
|
|
|
856
1171
|
observeSessionFirstExec(session, { sourceControl: { sessions: sourceControlSessions } });
|
|
857
1172
|
observeSessionThreadTitle(session, { sourceControl: { sessions: sourceControlSessions } });
|
|
858
1173
|
observeSessionRunEnd(session, { audit: auditDomain });
|
|
1174
|
+
observeSessionRunReports(session, (outcome, since) => reportSessionRunEnd({
|
|
1175
|
+
sessionId: session.identity.getId(),
|
|
1176
|
+
threadId: session.thread.getId(),
|
|
1177
|
+
outcome,
|
|
1178
|
+
since
|
|
1179
|
+
}), { onApprovalRequested: (request) => notifyApprovalRequested({
|
|
1180
|
+
sessionId: session.identity.getId(),
|
|
1181
|
+
threadId: session.thread.getId(),
|
|
1182
|
+
...request
|
|
1183
|
+
}) });
|
|
1184
|
+
observeSessionThreadStamp(session);
|
|
859
1185
|
});
|
|
860
1186
|
prepared.base.controller.onSessionCreated((session) => hydrateSessionMemorySettings(session, { sourceControl: { sessions: sourceControlSessions } }), { blocking: true });
|
|
861
1187
|
prepared.base.controller.onSessionCreated((session) => hydrateSessionDefaultModel(session, {
|
|
@@ -864,6 +1190,7 @@ var MastraFactory = class {
|
|
|
864
1190
|
workItems: workItemsStorage,
|
|
865
1191
|
modelDefaults: modelDefaultsStorage
|
|
866
1192
|
}), { blocking: true });
|
|
1193
|
+
prepared.base.controller.onSessionCreated((session) => applyFactoryToolPermissions(session, { sessions: sourceControlSessions }), { blocking: true });
|
|
867
1194
|
this.#prepared = prepared;
|
|
868
1195
|
this.#factoryProcessor = factoryProcessor;
|
|
869
1196
|
const channelRegistrations = integrationRegistrations.filter(({ integration, ready }) => ready && integration.channels);
|