@mastra/factory 0.27.0 → 0.28.0-alpha.1
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 +215 -41
- package/dist/boards/board-events.d.ts +34 -0
- package/dist/boards/board-events.d.ts.map +1 -0
- package/dist/boards/board-events.js +50 -0
- package/dist/boards/board-events.js.map +1 -0
- package/dist/boards/board-writes.d.ts +86 -0
- package/dist/boards/board-writes.d.ts.map +1 -0
- package/dist/boards/board-writes.js +252 -0
- package/dist/boards/board-writes.js.map +1 -0
- package/dist/boards/define-board.d.ts +16 -5
- package/dist/boards/define-board.d.ts.map +1 -1
- package/dist/boards/define-board.js +30 -8
- package/dist/boards/define-board.js.map +1 -1
- package/dist/boards/index.js +1 -1
- package/dist/boards/intake-routing.d.ts +30 -6
- package/dist/boards/intake-routing.d.ts.map +1 -1
- package/dist/boards/intake-routing.js +43 -5
- package/dist/boards/intake-routing.js.map +1 -1
- package/dist/boards/legacy-plan-role.d.ts.map +1 -1
- package/dist/boards/legacy-plan-role.js +8 -4
- package/dist/boards/legacy-plan-role.js.map +1 -1
- package/dist/boards/phase-automation.d.ts.map +1 -1
- package/dist/boards/phase-automation.js +7 -2
- package/dist/boards/phase-automation.js.map +1 -1
- package/dist/boards/project-boards.d.ts +18 -7
- package/dist/boards/project-boards.d.ts.map +1 -1
- package/dist/boards/project-boards.js +79 -15
- package/dist/boards/project-boards.js.map +1 -1
- package/dist/boards/stored-board.d.ts +59 -1
- package/dist/boards/stored-board.d.ts.map +1 -1
- package/dist/boards/stored-board.js +219 -7
- package/dist/boards/stored-board.js.map +1 -1
- package/dist/boards/work.js +1 -1
- package/dist/dispatch-wake.d.ts +13 -0
- package/dist/dispatch-wake.d.ts.map +1 -0
- package/dist/dispatch-wake.js +30 -0
- package/dist/dispatch-wake.js.map +1 -0
- package/dist/environment/build-runner.d.ts +1 -1
- package/dist/environment/build-runner.d.ts.map +1 -1
- package/dist/environment/build-runner.js +2 -2
- package/dist/environment/build-workflow.d.ts +1 -1
- package/dist/environment/build-workflow.d.ts.map +1 -1
- package/dist/environment/build-workflow.js +1 -1
- package/dist/environment/build.js +1 -1
- package/dist/factory.d.ts +63 -9
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +237 -59
- package/dist/factory.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -9
- package/dist/integrations/base.d.ts +6 -0
- package/dist/integrations/base.d.ts.map +1 -1
- package/dist/integrations/channel-thread-announcements.d.ts +5 -0
- package/dist/integrations/channel-thread-announcements.d.ts.map +1 -1
- package/dist/integrations/channel-thread-announcements.js +24 -2
- package/dist/integrations/channel-thread-announcements.js.map +1 -1
- package/dist/integrations/github/acceptance-labels.d.ts +4 -0
- package/dist/integrations/github/acceptance-labels.d.ts.map +1 -1
- package/dist/integrations/github/acceptance-labels.js +1 -1
- package/dist/integrations/github/acceptance-labels.js.map +1 -1
- package/dist/integrations/github/default-rules.d.ts +2 -9
- package/dist/integrations/github/default-rules.d.ts.map +1 -1
- package/dist/integrations/github/default-rules.js +7 -6
- package/dist/integrations/github/default-rules.js.map +1 -1
- package/dist/integrations/github/integration.js +2 -2
- package/dist/integrations/github/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/github/issue-reconciler.js +17 -1
- package/dist/integrations/github/issue-reconciler.js.map +1 -1
- package/dist/integrations/github/review-status-comment.d.ts +61 -0
- package/dist/integrations/github/review-status-comment.d.ts.map +1 -0
- package/dist/integrations/github/review-status-comment.js +217 -0
- package/dist/integrations/github/review-status-comment.js.map +1 -0
- package/dist/integrations/github/review-status-reporter.d.ts +42 -0
- package/dist/integrations/github/review-status-reporter.d.ts.map +1 -0
- package/dist/integrations/github/review-status-reporter.js +100 -0
- package/dist/integrations/github/review-status-reporter.js.map +1 -0
- package/dist/integrations/github/review-status.d.ts +28 -0
- package/dist/integrations/github/review-status.d.ts.map +1 -0
- package/dist/integrations/github/review-status.js +95 -0
- package/dist/integrations/github/review-status.js.map +1 -0
- package/dist/integrations/github/routes.d.ts.map +1 -1
- package/dist/integrations/github/routes.js +19 -21
- package/dist/integrations/github/routes.js.map +1 -1
- package/dist/integrations/github/rules.d.ts +13 -1
- package/dist/integrations/github/rules.d.ts.map +1 -1
- package/dist/integrations/github/rules.js +80 -9
- package/dist/integrations/github/rules.js.map +1 -1
- package/dist/integrations/github/sandbox.js +1 -1
- package/dist/integrations/github/session-subscriptions.js +3 -3
- package/dist/integrations/github/webhook.js +2 -2
- package/dist/integrations/gitlab/default-rules.d.ts +24 -9
- package/dist/integrations/gitlab/default-rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/default-rules.js +4 -4
- package/dist/integrations/gitlab/default-rules.js.map +1 -1
- package/dist/integrations/gitlab/integration.js +2 -2
- package/dist/integrations/gitlab/issue-reconciler.js +1 -1
- package/dist/integrations/gitlab/merge-request-reconciler.js +2 -2
- package/dist/integrations/gitlab/routes.d.ts.map +1 -1
- package/dist/integrations/gitlab/routes.js +2 -4
- package/dist/integrations/gitlab/routes.js.map +1 -1
- package/dist/integrations/gitlab/rules.d.ts +16 -0
- package/dist/integrations/gitlab/rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/rules.js +71 -6
- package/dist/integrations/gitlab/rules.js.map +1 -1
- package/dist/integrations/gitlab/session-subscriptions.js +1 -1
- package/dist/integrations/gitlab/webhook-dispatch.js +1 -1
- package/dist/integrations/incidentio/default-rules.d.ts +1 -9
- package/dist/integrations/incidentio/default-rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/default-rules.js +3 -4
- package/dist/integrations/incidentio/default-rules.js.map +1 -1
- package/dist/integrations/incidentio/integration.js +3 -3
- package/dist/integrations/incidentio/routes.d.ts.map +1 -1
- package/dist/integrations/incidentio/routes.js +1 -4
- package/dist/integrations/incidentio/routes.js.map +1 -1
- package/dist/integrations/incidentio/rules.d.ts +7 -0
- package/dist/integrations/incidentio/rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/rules.js +37 -5
- package/dist/integrations/incidentio/rules.js.map +1 -1
- package/dist/integrations/jira/default-rules.d.ts +1 -9
- package/dist/integrations/jira/default-rules.d.ts.map +1 -1
- package/dist/integrations/jira/default-rules.js +3 -4
- package/dist/integrations/jira/default-rules.js.map +1 -1
- package/dist/integrations/jira/integration.js +2 -2
- package/dist/integrations/jira/routes.d.ts.map +1 -1
- package/dist/integrations/jira/routes.js +2 -5
- package/dist/integrations/jira/routes.js.map +1 -1
- package/dist/integrations/jira/rules.d.ts +7 -0
- package/dist/integrations/jira/rules.d.ts.map +1 -1
- package/dist/integrations/jira/rules.js +37 -5
- package/dist/integrations/jira/rules.js.map +1 -1
- package/dist/integrations/linear/default-rules.d.ts +1 -9
- package/dist/integrations/linear/default-rules.d.ts.map +1 -1
- package/dist/integrations/linear/default-rules.js +3 -4
- package/dist/integrations/linear/default-rules.js.map +1 -1
- package/dist/integrations/linear/integration.js +2 -2
- package/dist/integrations/linear/routes.d.ts +21 -1
- package/dist/integrations/linear/routes.d.ts.map +1 -1
- package/dist/integrations/linear/routes.js +21 -6
- package/dist/integrations/linear/routes.js.map +1 -1
- package/dist/integrations/linear/rules.d.ts +7 -0
- package/dist/integrations/linear/rules.d.ts.map +1 -1
- package/dist/integrations/linear/rules.js +37 -5
- package/dist/integrations/linear/rules.js.map +1 -1
- package/dist/integrations/platform/connect/routes.d.ts +7 -1
- package/dist/integrations/platform/connect/routes.d.ts.map +1 -1
- package/dist/integrations/platform/connect/routes.js +42 -5
- package/dist/integrations/platform/connect/routes.js.map +1 -1
- package/dist/integrations/platform/connect/session-tools.d.ts +7 -0
- package/dist/integrations/platform/connect/session-tools.d.ts.map +1 -0
- package/dist/integrations/platform/connect/session-tools.js +30 -0
- package/dist/integrations/platform/connect/session-tools.js.map +1 -0
- package/dist/integrations/platform/github/event-worker.js +1 -1
- package/dist/integrations/platform/github/integration.d.ts.map +1 -1
- package/dist/integrations/platform/github/integration.js +9 -8
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/platform/gitlab/event-worker.js +1 -1
- package/dist/integrations/platform/gitlab/integration.js +2 -2
- package/dist/integrations/platform/incidentio/integration.js +5 -5
- package/dist/integrations/platform/jira/agent-tools.js +1 -1
- package/dist/integrations/platform/jira/integration.js +2 -2
- package/dist/integrations/platform/jira/routes.d.ts.map +1 -1
- package/dist/integrations/platform/jira/routes.js +2 -5
- package/dist/integrations/platform/jira/routes.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 +9 -0
- package/dist/integrations/platform/linear/event-worker.js.map +1 -1
- package/dist/integrations/platform/linear/integration.d.ts.map +1 -1
- package/dist/integrations/platform/linear/integration.js +150 -48
- package/dist/integrations/platform/linear/integration.js.map +1 -1
- package/dist/integrations/slack/channel-reply-processor.d.ts +2 -0
- package/dist/integrations/slack/channel-reply-processor.d.ts.map +1 -1
- package/dist/integrations/slack/channel-reply-processor.js +6 -1
- package/dist/integrations/slack/channel-reply-processor.js.map +1 -1
- package/dist/integrations/slack/chat-tools.d.ts +16 -0
- package/dist/integrations/slack/chat-tools.d.ts.map +1 -0
- package/dist/integrations/slack/chat-tools.js +215 -0
- package/dist/integrations/slack/chat-tools.js.map +1 -0
- package/dist/integrations/slack/connect-route.d.ts.map +1 -1
- package/dist/integrations/slack/connect-route.js +1 -1
- package/dist/integrations/slack/connect-route.js.map +1 -1
- package/dist/integrations/slack/integration.d.ts +19 -3
- package/dist/integrations/slack/integration.d.ts.map +1 -1
- package/dist/integrations/slack/integration.js +27 -8
- package/dist/integrations/slack/integration.js.map +1 -1
- package/dist/integrations/slack/run-error-card.js +1 -1
- package/dist/integrations/slack/share-file-tool.d.ts +8 -0
- package/dist/integrations/slack/share-file-tool.d.ts.map +1 -1
- package/dist/integrations/slack/share-file-tool.js +13 -4
- package/dist/integrations/slack/share-file-tool.js.map +1 -1
- package/dist/integrations/slack/slack.d.ts +12 -10
- package/dist/integrations/slack/slack.d.ts.map +1 -1
- package/dist/integrations/slack/slack.js +113 -46
- package/dist/integrations/slack/slack.js.map +1 -1
- package/dist/integrations/slack/tool-settings.d.ts +26 -0
- package/dist/integrations/slack/tool-settings.d.ts.map +1 -0
- package/dist/integrations/slack/tool-settings.js +35 -0
- package/dist/integrations/slack/tool-settings.js.map +1 -0
- package/dist/integrations/slack/voice-clips.d.ts +32 -0
- package/dist/integrations/slack/voice-clips.d.ts.map +1 -0
- package/dist/integrations/slack/voice-clips.js +201 -0
- package/dist/integrations/slack/voice-clips.js.map +1 -0
- package/dist/integrations/workos/integration.d.ts.map +1 -1
- package/dist/integrations/workos/integration.js +1 -3
- package/dist/integrations/workos/integration.js.map +1 -1
- package/dist/mcp/events.js +1 -1
- package/dist/mcp/routes.js +2 -2
- package/dist/packages/_internals/workspace/dist/index.js +1 -1
- package/dist/routes/attention-activity.js +1 -1
- package/dist/routes/attention-providers.js +2 -2
- package/dist/routes/attention.js +2 -2
- package/dist/routes/automation-runs.d.ts.map +1 -1
- package/dist/routes/automation-runs.js +2 -5
- package/dist/routes/automation-runs.js.map +1 -1
- package/dist/routes/boards.d.ts +8 -6
- package/dist/routes/boards.d.ts.map +1 -1
- package/dist/routes/boards.js +73 -143
- package/dist/routes/boards.js.map +1 -1
- package/dist/routes/config.d.ts.map +1 -1
- package/dist/routes/config.js +6 -11
- package/dist/routes/config.js.map +1 -1
- package/dist/routes/contracts.d.ts +162 -2
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/contracts.js +98 -33
- package/dist/routes/contracts.js.map +1 -1
- package/dist/routes/fs.d.ts.map +1 -1
- package/dist/routes/fs.js +2 -5
- package/dist/routes/fs.js.map +1 -1
- package/dist/routes/intake-routes.d.ts.map +1 -1
- package/dist/routes/intake-routes.js +19 -12
- package/dist/routes/intake-routes.js.map +1 -1
- package/dist/routes/intake.d.ts.map +1 -1
- package/dist/routes/intake.js +4 -6
- package/dist/routes/intake.js.map +1 -1
- package/dist/routes/knowledge.d.ts.map +1 -1
- package/dist/routes/knowledge.js +1 -4
- package/dist/routes/knowledge.js.map +1 -1
- package/dist/routes/oauth.d.ts.map +1 -1
- package/dist/routes/oauth.js +1 -4
- package/dist/routes/oauth.js.map +1 -1
- package/dist/routes/projects.d.ts +3 -0
- package/dist/routes/projects.d.ts.map +1 -1
- package/dist/routes/projects.js +42 -28
- package/dist/routes/projects.js.map +1 -1
- package/dist/routes/provider-credentials.d.ts.map +1 -1
- package/dist/routes/provider-credentials.js +6 -0
- package/dist/routes/provider-credentials.js.map +1 -1
- package/dist/routes/route.d.ts +2 -0
- package/dist/routes/route.d.ts.map +1 -1
- package/dist/routes/route.js +5 -1
- package/dist/routes/route.js.map +1 -1
- package/dist/routes/skills.d.ts.map +1 -1
- package/dist/routes/skills.js +2 -5
- package/dist/routes/skills.js.map +1 -1
- package/dist/routes/source-control-sessions.d.ts.map +1 -1
- package/dist/routes/source-control-sessions.js +3 -5
- package/dist/routes/source-control-sessions.js.map +1 -1
- package/dist/routes/source-control-settings.d.ts.map +1 -1
- package/dist/routes/source-control-settings.js +3 -2
- package/dist/routes/source-control-settings.js.map +1 -1
- package/dist/routes/surface.d.ts +3 -1
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +27 -17
- package/dist/routes/surface.js.map +1 -1
- package/dist/routes/telemetry.js +1 -1
- package/dist/routes/voice.d.ts +48 -0
- package/dist/routes/voice.d.ts.map +1 -0
- package/dist/routes/voice.js +248 -0
- package/dist/routes/voice.js.map +1 -0
- package/dist/routes/work-items.d.ts.map +1 -1
- package/dist/routes/work-items.js +9 -12
- package/dist/routes/work-items.js.map +1 -1
- package/dist/rules/decision-applicability.js +1 -1
- package/dist/rules/dispatcher.d.ts +42 -0
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +522 -136
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/event-rules.d.ts +40 -1
- package/dist/rules/event-rules.d.ts.map +1 -1
- package/dist/rules/event-rules.js +59 -1
- package/dist/rules/event-rules.js.map +1 -1
- package/dist/rules/index.js +1 -1
- package/dist/rules/processor.d.ts +2 -0
- package/dist/rules/processor.d.ts.map +1 -1
- package/dist/rules/processor.js +5 -4
- package/dist/rules/processor.js.map +1 -1
- package/dist/rules/start-coordinator.js +2 -2
- package/dist/rules/terminal-cleanup.js.map +1 -1
- package/dist/rules/tools.js +5 -5
- package/dist/rules/transition-service.d.ts +9 -0
- package/dist/rules/transition-service.d.ts.map +1 -1
- package/dist/rules/transition-service.js +9 -7
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/rules/types.d.ts +54 -3
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/types.js +2 -0
- package/dist/rules/types.js.map +1 -1
- package/dist/rules/validation.d.ts.map +1 -1
- package/dist/rules/validation.js +57 -2
- package/dist/rules/validation.js.map +1 -1
- package/dist/sandbox/session-retirement.js +2 -2
- package/dist/sandbox/session-sandbox.js +1 -1
- package/dist/session/credential-policy.d.ts +2 -2
- package/dist/session/credential-policy.d.ts.map +1 -1
- package/dist/session/credential-policy.js +4 -4
- package/dist/session/credential-policy.js.map +1 -1
- package/dist/session/default-model-hydration.d.ts +2 -2
- package/dist/session/default-model-hydration.d.ts.map +1 -1
- package/dist/session/default-model-hydration.js +4 -4
- package/dist/session/default-model-hydration.js.map +1 -1
- package/dist/session/factory-session.js +3 -3
- package/dist/session/self-review-gate.js +1 -1
- package/dist/session/session-threads.d.ts +8 -0
- package/dist/session/session-threads.d.ts.map +1 -1
- package/dist/session/session-threads.js +11 -1
- package/dist/session/session-threads.js.map +1 -1
- package/dist/session/source-control-tools.js +3 -3
- package/dist/skills/catalog.js +1 -1
- package/dist/storage/domains/audit/actions.d.ts +1 -1
- package/dist/storage/domains/audit/actions.d.ts.map +1 -1
- package/dist/storage/domains/audit/actions.js +2 -1
- package/dist/storage/domains/audit/actions.js.map +1 -1
- package/dist/storage/domains/audit/domain.d.ts.map +1 -1
- package/dist/storage/domains/audit/domain.js +2 -4
- package/dist/storage/domains/audit/domain.js.map +1 -1
- package/dist/storage/domains/boards/base.d.ts +32 -1
- package/dist/storage/domains/boards/base.d.ts.map +1 -1
- package/dist/storage/domains/boards/base.js +155 -8
- package/dist/storage/domains/boards/base.js.map +1 -1
- package/dist/storage/domains/boards/schemas.d.ts.map +1 -1
- package/dist/storage/domains/boards/schemas.js +13 -1
- package/dist/storage/domains/boards/schemas.js.map +1 -1
- package/dist/storage/domains/comments/base.js +3 -3
- package/dist/storage/domains/comments/domain.js +3 -3
- package/dist/storage/domains/comments/routes.d.ts.map +1 -1
- package/dist/storage/domains/comments/routes.js +2 -4
- package/dist/storage/domains/comments/routes.js.map +1 -1
- package/dist/storage/domains/memory-settings/base.d.ts +0 -8
- package/dist/storage/domains/memory-settings/base.d.ts.map +1 -1
- package/dist/storage/domains/memory-settings/base.js +1 -11
- package/dist/storage/domains/memory-settings/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 +9 -1
- package/dist/storage/domains/projects/base.js.map +1 -1
- package/dist/storage/domains/source-control/base.d.ts +20 -0
- package/dist/storage/domains/source-control/base.d.ts.map +1 -1
- package/dist/storage/domains/source-control/base.js +42 -0
- package/dist/storage/domains/source-control/base.js.map +1 -1
- package/dist/storage/domains/source-control/inmemory.d.ts +5 -1
- package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/source-control/inmemory.js +23 -0
- package/dist/storage/domains/source-control/inmemory.js.map +1 -1
- package/dist/storage/domains/voice-settings/base.d.ts +31 -0
- package/dist/storage/domains/voice-settings/base.d.ts.map +1 -0
- package/dist/storage/domains/voice-settings/base.js +81 -0
- package/dist/storage/domains/voice-settings/base.js.map +1 -0
- package/dist/storage/domains/work-items/base.d.ts +47 -7
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +251 -115
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/storage/domains/work-items/cards.d.ts +6 -1
- package/dist/storage/domains/work-items/cards.d.ts.map +1 -1
- package/dist/storage/domains/work-items/cards.js +55 -5
- package/dist/storage/domains/work-items/cards.js.map +1 -1
- package/dist/storage/domains/work-items/claimable-work.d.ts +15 -0
- package/dist/storage/domains/work-items/claimable-work.d.ts.map +1 -0
- package/dist/storage/domains/work-items/claimable-work.js +51 -0
- package/dist/storage/domains/work-items/claimable-work.js.map +1 -0
- package/dist/storage/domains/work-items/work-item-schema.d.ts +2 -0
- package/dist/storage/domains/work-items/work-item-schema.d.ts.map +1 -1
- package/dist/storage/domains/work-items/work-item-schema.js +24 -1
- package/dist/storage/domains/work-items/work-item-schema.js.map +1 -1
- package/dist/timing.d.ts +1 -0
- package/dist/timing.d.ts.map +1 -1
- package/dist/timing.js +1 -1
- package/dist/timing.js.map +1 -1
- package/dist/tools/index.js +2 -2
- package/dist/tools/messaging-tools.js +1 -1
- package/dist/tools/read-tools.d.ts +2 -2
- package/dist/tools/read-tools.d.ts.map +1 -1
- package/dist/tools/read-tools.js +10 -9
- package/dist/tools/read-tools.js.map +1 -1
- package/dist/tools/scope.js +1 -1
- package/dist/tools/session-tools.d.ts +1 -1
- package/dist/tools/session-tools.d.ts.map +1 -1
- package/dist/tools/session-tools.js +9 -9
- package/dist/tools/session-tools.js.map +1 -1
- package/dist/tools/sessions-state-processor.d.ts +1 -1
- package/dist/tools/sessions-state-processor.d.ts.map +1 -1
- package/dist/tools/sessions-state-processor.js +9 -2
- package/dist/tools/sessions-state-processor.js.map +1 -1
- package/dist/tools/work-item-tools.js +4 -4
- package/dist/voice/rate-limit.d.ts +13 -0
- package/dist/voice/rate-limit.d.ts.map +1 -0
- package/dist/voice/rate-limit.js +36 -0
- package/dist/voice/rate-limit.js.map +1 -0
- package/dist/voice/realtime.d.ts +13 -0
- package/dist/voice/realtime.d.ts.map +1 -0
- package/dist/voice/realtime.js +56 -0
- package/dist/voice/realtime.js.map +1 -0
- package/dist/voice/transcription.d.ts +51 -0
- package/dist/voice/transcription.d.ts.map +1 -0
- package/dist/voice/transcription.js +112 -0
- package/dist/voice/transcription.js.map +1 -0
- package/dist/work-items/create-work-item.js +2 -2
- package/dist/work-items/decision-actions.js +2 -2
- package/dist/work-items/providers/gitlab.js +1 -1
- package/dist/work-items/providers/incidentio.js +1 -1
- package/dist/work-items/providers/index.js +1 -1
- package/dist/work-items/providers/jira.js +1 -1
- package/dist/work-items/providers/linear.js +1 -1
- package/dist/work-items/split-backfill.d.ts +13 -0
- package/dist/work-items/split-backfill.d.ts.map +1 -0
- package/dist/work-items/split-backfill.js +32 -0
- package/dist/work-items/split-backfill.js.map +1 -0
- package/dist/work-items/split-migration.d.ts +39 -2
- package/dist/work-items/split-migration.d.ts.map +1 -1
- package/dist/work-items/split-migration.js +171 -63
- package/dist/work-items/split-migration.js.map +1 -1
- package/dist/workspace.d.ts +2 -0
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +12 -9
- package/dist/workspace.js.map +1 -1
- package/package.json +10 -9
package/dist/factory.js
CHANGED
|
@@ -1,103 +1,111 @@
|
|
|
1
|
-
import { createRequestTimingMiddleware, factoryTimingEnabled, instrumentAsyncMethods, timedPhase } from "./timing.js";
|
|
2
1
|
import { buildAuthDisabledRoutes, buildAuthRoutes, createFactoryAuthGate, createFactoryInteractiveMarker, createFactoryRouteAuth, getFactoryAuthOrgId, getFactoryAuthUserFromContext, getFactoryAuthUserId } from "./auth.js";
|
|
3
|
-
import {
|
|
2
|
+
import { BoardWriteError, BoardWrites } from "./boards/board-writes.js";
|
|
4
3
|
import { isDefinedBoard } from "./boards/define-board.js";
|
|
5
|
-
import { WorkItemSplitModeError, WorkItemsStorage } from "./storage/domains/work-items/base.js";
|
|
6
|
-
import { isTerminalWorkItem } from "./boards/semantics.js";
|
|
7
|
-
import { createBoardRegistry } from "./boards/registry.js";
|
|
8
4
|
import "./boards/index.js";
|
|
9
|
-
import { isValidGitRef } from "./sandbox/git-ref.js";
|
|
10
|
-
import { peekSessionSandbox } from "./sandbox/session-sandbox.js";
|
|
11
|
-
import { FactoryEnvironmentStateProcessor } from "./session/environment-state-processor.js";
|
|
12
|
-
import { FactoryWorkspaceRegistry, createWorkspaceFactory } from "./workspace.js";
|
|
13
|
-
import { assertFactorySkills, findBoardSkillProblems } from "./skills/app-skills.js";
|
|
14
5
|
import { ProjectBoardCache } from "./boards/project-boards.js";
|
|
15
|
-
import {
|
|
6
|
+
import { publishDispatchWake, subscribeDispatchWakes } from "./dispatch-wake.js";
|
|
16
7
|
import { EnvironmentBuildRunner } from "./environment/build-runner.js";
|
|
8
|
+
import { ENVIRONMENT_BUILD_WORKFLOW_ID } from "./environment/build-workflow.js";
|
|
17
9
|
import { touchFeed } from "./feed-events.js";
|
|
18
10
|
import { reconcileGithubAcceptanceLabels } from "./integrations/github/acceptance-labels.js";
|
|
19
|
-
import { IntakeStorage } from "./storage/domains/intake/base.js";
|
|
20
|
-
import { isFactoryGithubLogin, trustedCollaborator } from "./integrations/github/rules.js";
|
|
21
|
-
import { environmentSlugs, resolveSessionRepositories } from "./session/environment-repositories.js";
|
|
22
11
|
import { recordFactoryPullRequestProvenance, resolveFactoryPullRequestParentWorkItemId } from "./integrations/github/provenance.js";
|
|
12
|
+
import { createBoardRegistry } from "./boards/registry.js";
|
|
13
|
+
import { boardForWorkItem, isTerminalWorkItem } from "./boards/semantics.js";
|
|
14
|
+
import { createGithubReviewStatusReporter, reviewStatusAnimationFromEnv } from "./integrations/github/review-status-reporter.js";
|
|
15
|
+
import { isFactoryGithubLogin, trustedCollaborator } from "./integrations/github/rules.js";
|
|
23
16
|
import { dismissStaleFactoryReviews } from "./integrations/github/stale-reviews.js";
|
|
24
17
|
import { PlatformApiClient, platformApiClientConfigFromEnv } from "./integrations/platform/api-client.js";
|
|
25
|
-
import { buildPlatformConnectRoutes } from "./integrations/platform/connect/routes.js";
|
|
26
|
-
import {
|
|
27
|
-
import { ModelCredentialsStorage } from "./storage/domains/credentials/base.js";
|
|
28
|
-
import { tenantOrgId } from "./routes/provider-credentials.js";
|
|
29
|
-
import { createTenantCredentialPrimer, primeTenantCredentials, registerTenantCredentialResolver } from "./routes/tenant-credentials.js";
|
|
30
|
-
import { hasResolvedOrg } from "./session/org-seed.js";
|
|
18
|
+
import { buildConnectToolsRoute, buildPlatformConnectRoutes } from "./integrations/platform/connect/routes.js";
|
|
19
|
+
import { platformConnectTools } from "./integrations/platform/connect/session-tools.js";
|
|
31
20
|
import { createSessionAsRowOwner, prepareSessionRunContext } from "./integrations/subscription-session.js";
|
|
32
|
-
import { FactoryProjectsStorage } from "./storage/domains/projects/base.js";
|
|
33
|
-
import { SourceControlStorage } from "./storage/domains/source-control/base.js";
|
|
34
|
-
import { createSourceControlSessionLookup } from "./session/factory-session.js";
|
|
35
|
-
import { AuditStorage } from "./storage/domains/audit/base.js";
|
|
36
|
-
import { sessionMemoryResourceId, sessionStampCounts } from "./session/session-threads.js";
|
|
37
|
-
import { resolveFactoryToolScope } from "./tools/scope.js";
|
|
38
|
-
import { deliverFactorySessionNotification } from "./tools/deliver.js";
|
|
39
|
-
import { createSessionApprovalNotifier, createSessionRunEndReporter, createStageChangeNotifier, createWorkItemRunEndReporter } from "./tools/reports.js";
|
|
40
|
-
import { StoredBoardsStorage } from "./storage/domains/boards/base.js";
|
|
41
|
-
import { resolveFactoryCredentialTenant, resolveFactoryModelPolicy } from "./session/credential-policy.js";
|
|
42
|
-
import { hydrateSessionMemorySettings } from "./session/memory-settings-hydration.js";
|
|
43
|
-
import { MemorySettingsStorage, factoryMemorySettingsUserId } from "./storage/domains/memory-settings/base.js";
|
|
44
|
-
import { resolveDeploymentModelProviders } from "./routes/config.js";
|
|
45
|
-
import { observeSessionFirstExec } from "./session/first-exec-capture.js";
|
|
46
|
-
import { observeSessionFilesystem } from "./session/filesystem-capture.js";
|
|
47
|
-
import { createSessionAccessGuard } from "./routes/session-access.js";
|
|
48
|
-
import { observeSessionRunEnd } from "./session/run-audit.js";
|
|
49
|
-
import { observeSessionRunReports } from "./tools/run-watch.js";
|
|
50
|
-
import { applyFactoryToolPermissions } from "./tools/permissions.js";
|
|
51
|
-
import { createFactoryTools } from "./tools/index.js";
|
|
52
21
|
import { buildFactoryMcpRoutes, resolveMcpAuthorizationServers } from "./mcp/routes.js";
|
|
22
|
+
import { resolveDeploymentModelProviders } from "./routes/config.js";
|
|
53
23
|
import { createCustomProvidersPrimer, primeCustomProvidersForRequestContext, registerCustomProvidersSource } from "./routes/custom-provider-source.js";
|
|
54
24
|
import { ProjectRoutes } from "./routes/projects.js";
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
import { QueueHealthStorage } from "./storage/domains/queue-health/base.js";
|
|
25
|
+
import { tenantOrgId } from "./routes/provider-credentials.js";
|
|
26
|
+
import { createSessionAccessGuard } from "./routes/session-access.js";
|
|
58
27
|
import { assembleFactoryApiRoutes, buildIntegrationContext } from "./routes/surface.js";
|
|
59
28
|
import { TelemetryRoutes } from "./routes/telemetry.js";
|
|
29
|
+
import { createTenantCredentialPrimer, primeTenantCredentials, registerTenantCredentialResolver } from "./routes/tenant-credentials.js";
|
|
60
30
|
import { readFactorySessionScope, resolveFactorySessionAddress } from "./rules/binding-context.js";
|
|
61
|
-
import { FactoryFeedReader } from "./storage/domains/comments/feed-context.js";
|
|
62
31
|
import { FactoryDecisionDispatcher } from "./rules/dispatcher.js";
|
|
63
32
|
import { FactoryPhaseStateProcessor, reportMemorySettingsUnavailable } from "./rules/processor.js";
|
|
64
33
|
import { createReviewSourceTool, resolveReviewSourceUiOrigin } from "./rules/review-source-tool.js";
|
|
65
34
|
import { createTerminalStageCleanup } from "./rules/terminal-cleanup.js";
|
|
66
35
|
import { createFactoryTransitionTools } from "./rules/tools.js";
|
|
36
|
+
import { FactoryTransitionService } from "./rules/transition-service.js";
|
|
37
|
+
import { assertFactoryConfigVersion } from "./rules/validation.js";
|
|
67
38
|
import { CallbackFactorySandbox } from "./sandbox/callback-factory-sandbox.js";
|
|
39
|
+
import { isValidGitRef } from "./sandbox/git-ref.js";
|
|
68
40
|
import { LocalFactorySandbox } from "./sandbox/local-factory-sandbox.js";
|
|
69
41
|
import { SessionRetirementCoordinator } from "./sandbox/session-retirement.js";
|
|
42
|
+
import { resolveFactoryToolScope } from "./tools/scope.js";
|
|
43
|
+
import { peekSessionSandbox } from "./sandbox/session-sandbox.js";
|
|
44
|
+
import { createPlaintextFactorySecretEncryption } from "./secret-encryption.js";
|
|
70
45
|
import { handleServerError } from "./server-error.js";
|
|
46
|
+
import { resolveFactoryCredentialTenant, resolveFactoryModelPolicy } from "./session/credential-policy.js";
|
|
71
47
|
import { hydrateSessionDefaultModel } from "./session/default-model-hydration.js";
|
|
48
|
+
import { environmentSlugs, resolveSessionRepositories } from "./session/environment-repositories.js";
|
|
49
|
+
import { FactoryEnvironmentStateProcessor } from "./session/environment-state-processor.js";
|
|
50
|
+
import { createSourceControlSessionLookup } from "./session/factory-session.js";
|
|
51
|
+
import { observeSessionFilesystem } from "./session/filesystem-capture.js";
|
|
52
|
+
import { observeSessionFirstExec } from "./session/first-exec-capture.js";
|
|
53
|
+
import { applyFactoryToolPermissions } from "./tools/permissions.js";
|
|
72
54
|
import { observeSessionFirstMessage } from "./session/first-message-capture.js";
|
|
73
55
|
import { LiveSessions } from "./session/live-sessions.js";
|
|
56
|
+
import { hydrateSessionMemorySettings } from "./session/memory-settings-hydration.js";
|
|
57
|
+
import { hasResolvedOrg } from "./session/org-seed.js";
|
|
74
58
|
import { FactoryReplyCredentialProcessor } from "./session/reply-credential-processor.js";
|
|
75
59
|
import { migrateSessionResources, privatizeOwnerResourceSessions } from "./session/resource-migration.js";
|
|
60
|
+
import { observeSessionRunEnd } from "./session/run-audit.js";
|
|
76
61
|
import { selfReviewApprovedHead } from "./session/self-review-gate.js";
|
|
62
|
+
import { sessionMemoryResourceId, sessionStampCounts } from "./session/session-threads.js";
|
|
77
63
|
import { createSourceControlTools } from "./session/source-control-tools.js";
|
|
78
64
|
import { resolveFactoryThinkingLevel } from "./session/thinking-default.js";
|
|
79
65
|
import { observeSessionThreadStamp } from "./session/thread-session-stamp.js";
|
|
80
66
|
import { observeSessionThreadTitle } from "./session/thread-title-mirror.js";
|
|
67
|
+
import { assertFactorySkills, findBoardSkillProblems } from "./skills/app-skills.js";
|
|
81
68
|
import { createSpaStaticMiddleware, resolveUiDistDir } from "./spa-static.js";
|
|
82
69
|
import { createStateSigner } from "./state-signing.js";
|
|
83
70
|
import { observeAgentGitAction } from "./storage/domains/audit/agent-audit.js";
|
|
71
|
+
import { AuditStorage } from "./storage/domains/audit/base.js";
|
|
72
|
+
import { AuditDomain } from "./storage/domains/audit/domain.js";
|
|
73
|
+
import { StoredBoardsStorage } from "./storage/domains/boards/base.js";
|
|
84
74
|
import { ChannelIdentityStorage } from "./storage/domains/channel-identity/base.js";
|
|
85
75
|
import { WorkItemCommentsStorage } from "./storage/domains/comments/base.js";
|
|
86
76
|
import { CommentsDomain } from "./storage/domains/comments/domain.js";
|
|
77
|
+
import { FactoryFeedReader } from "./storage/domains/comments/feed-context.js";
|
|
78
|
+
import { ModelCredentialsStorage } from "./storage/domains/credentials/base.js";
|
|
87
79
|
import { CustomProvidersStorage } from "./storage/domains/custom-providers/base.js";
|
|
88
80
|
import { FilesystemStorage } from "./storage/domains/filesystem/base.js";
|
|
81
|
+
import { IntakeStorage } from "./storage/domains/intake/base.js";
|
|
89
82
|
import { IntegrationStorage } from "./storage/domains/integrations/base.js";
|
|
83
|
+
import { MemorySettingsStorage } from "./storage/domains/memory-settings/base.js";
|
|
90
84
|
import { ModelDefaultsStorage } from "./storage/domains/model-defaults/base.js";
|
|
85
|
+
import { FactoryProjectsStorage, factoryProjectSettingsUserId } from "./storage/domains/projects/base.js";
|
|
86
|
+
import { QueueHealthStorage } from "./storage/domains/queue-health/base.js";
|
|
91
87
|
import { SkillOverridesStorage } from "./storage/domains/skill-overrides/base.js";
|
|
88
|
+
import { SourceControlStorage } from "./storage/domains/source-control/base.js";
|
|
89
|
+
import { VoiceSettingsStorage } from "./storage/domains/voice-settings/base.js";
|
|
90
|
+
import { WorkItemSplitModeError, WorkItemsStorage } from "./storage/domains/work-items/base.js";
|
|
91
|
+
import { createRequestTimingMiddleware, factoryTimingEnabled, instrumentAsyncMethods, logTiming, timedPhase } from "./timing.js";
|
|
92
|
+
import { deliverFactorySessionNotification } from "./tools/deliver.js";
|
|
93
|
+
import { createFactoryTools } from "./tools/index.js";
|
|
94
|
+
import { createSessionApprovalNotifier, createSessionRunEndReporter, createStageChangeNotifier, createWorkItemRunEndReporter } from "./tools/reports.js";
|
|
95
|
+
import { observeSessionRunReports } from "./tools/run-watch.js";
|
|
92
96
|
import { createFactorySandboxTools } from "./tools/sandbox-tools.js";
|
|
93
97
|
import { FactorySessionsStateProcessor } from "./tools/sessions-state-processor.js";
|
|
98
|
+
import { backfillUntilDone } from "./work-items/split-backfill.js";
|
|
99
|
+
import { FACTORY_PLANS_DIR, FactoryWorkspaceRegistry, createWorkspaceFactory } from "./workspace.js";
|
|
94
100
|
import { RequestContext } from "@mastra/core/request-context";
|
|
95
101
|
import { hasAuthInit, isUserProvider } from "@mastra/core/server";
|
|
102
|
+
import { EventEmitterPubSub } from "@mastra/core/events";
|
|
103
|
+
import { existsSync } from "fs";
|
|
96
104
|
import { MastraAuthStudio } from "@mastra/auth-studio";
|
|
97
105
|
import { prepareAgentControllerMount } from "@mastra/code-sdk";
|
|
98
106
|
import { getDynamicMemory } from "@mastra/code-sdk/agents/memory";
|
|
107
|
+
import { getGlobalMcpPath } from "@mastra/code-sdk/mcp/config";
|
|
99
108
|
import { AgentControllerChannels } from "@mastra/core/channels";
|
|
100
|
-
import { EventEmitterPubSub } from "@mastra/core/events";
|
|
101
109
|
import { describeFactorySandbox, isFactorySandbox } from "@mastra/core/workspace";
|
|
102
110
|
// src/factory.ts
|
|
103
111
|
/**
|
|
@@ -154,6 +162,20 @@ async function platformDefaultSandbox() {
|
|
|
154
162
|
const { PlatformFactorySandbox } = await import("@mastra/platform-workspace");
|
|
155
163
|
return new PlatformFactorySandbox();
|
|
156
164
|
}
|
|
165
|
+
function platformConnectProjectId() {
|
|
166
|
+
if (!hasPlatformCredentials()) return void 0;
|
|
167
|
+
const projectId = process.env.MASTRA_PROJECT_ID?.trim();
|
|
168
|
+
if (!projectId) {
|
|
169
|
+
console.warn("MastraFactory: Platform credentials are set but MASTRA_PROJECT_ID is missing, so sessions get no Mastra Connect tools.");
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
return projectId;
|
|
173
|
+
}
|
|
174
|
+
function warnIgnoredMcpConfig() {
|
|
175
|
+
const mcpPath = getGlobalMcpPath();
|
|
176
|
+
if (!existsSync(mcpPath)) return;
|
|
177
|
+
console.warn(`MastraFactory: ${mcpPath} is ignored; Factory sessions don't load mcp.json. Pass MCP tools through the \`tools\` option or attach a Mastra Connect connection to the Platform project.`);
|
|
178
|
+
}
|
|
157
179
|
/**
|
|
158
180
|
* Default auth provider — `MastraAuthStudio`, which proxies identity to the
|
|
159
181
|
* shared Mastra platform API and resolves its own env (`MASTRA_SHARED_API_URL`,
|
|
@@ -186,7 +208,7 @@ let warnedDefinedBoards = false;
|
|
|
186
208
|
function warnDefinedBoards(boards) {
|
|
187
209
|
if (warnedDefinedBoards || ![...boards.values()].some(isDefinedBoard)) return;
|
|
188
210
|
warnedDefinedBoards = true;
|
|
189
|
-
console.warn("[Mastra Factory] MastraFactory({ boards }) and defineBoard() are deprecated: boards
|
|
211
|
+
console.warn("[Mastra Factory] MastraFactory({ boards }) and defineBoard() are deprecated: boards live in the database, and each project stores these definitions once. Write board definitions into projects with factory.upsertBoard(), or manage them through the boards API; see the README \"Stored boards\" section and mastra-ai/mastra#28920.");
|
|
190
212
|
}
|
|
191
213
|
/**
|
|
192
214
|
* The fleet-era `sandbox` options and what replaced each one. Only the keys
|
|
@@ -222,10 +244,15 @@ var MastraFactory = class {
|
|
|
222
244
|
#boards;
|
|
223
245
|
/** Each project's boards: the code boards plus the boards it stored. Undefined until `prepare()` or when the boards domain is down. */
|
|
224
246
|
#projectBoards;
|
|
247
|
+
/** Writes to stored boards for `upsertBoard()`; undefined until `prepare()` or when the boards domain is down. */
|
|
248
|
+
#boardStore;
|
|
225
249
|
#skills;
|
|
226
250
|
#configVersion;
|
|
227
251
|
#prepared;
|
|
228
252
|
#dispatcher;
|
|
253
|
+
/** Names this replica on the dispatch-wake topic so it can skip its own echoes. */
|
|
254
|
+
#dispatchWakeOrigin = globalThis.crypto.randomUUID();
|
|
255
|
+
#unsubscribeDispatchWakes;
|
|
229
256
|
#startCoordinator;
|
|
230
257
|
#factoryProcessor;
|
|
231
258
|
#channelShutdowns = [];
|
|
@@ -234,6 +261,8 @@ var MastraFactory = class {
|
|
|
234
261
|
#environmentBuilds;
|
|
235
262
|
/** The background session resource migration; resolves `true` when it moved run bindings. */
|
|
236
263
|
#sessionResourceMigration;
|
|
264
|
+
#workItemSplitBackfill;
|
|
265
|
+
#prepareStartedAt;
|
|
237
266
|
#preparing = false;
|
|
238
267
|
constructor(config) {
|
|
239
268
|
if (!config?.storage) throw new Error("MastraFactory: 'storage' is required. Pass a FactoryStorage backend — e.g. new PgFactoryStorage({ connectionString }) from '@mastra/pg' for deployments, or new LibSQLFactoryStorage({ url }) from '@mastra/libsql' for local dev.");
|
|
@@ -259,6 +288,74 @@ var MastraFactory = class {
|
|
|
259
288
|
return this.#sandboxDescription;
|
|
260
289
|
}
|
|
261
290
|
/**
|
|
291
|
+
* Writes a board definition into projects: each project that has no board under its key gets
|
|
292
|
+
* it, and each one that has it, edited or not, has it replaced at the next revision. Use it to
|
|
293
|
+
* push a board from code into projects; it isn't run for you, and projects created later don't
|
|
294
|
+
* get it until you run it again. A Work or app board's key keeps that board's code behaviour,
|
|
295
|
+
* so the definition is checked as an edit is; a new key gets none (no handlers, outcomes, tool or
|
|
296
|
+
* event rules). The board is validated once, as the boards API does, and each write is audited
|
|
297
|
+
* as `factory.board.created` or `factory.board.updated` by `system:factory`. Refusals throw a
|
|
298
|
+
* `BoardWriteError` (`invalid_board`, `unknown_skill`, `code_behaviour`, `code_board` for the
|
|
299
|
+
* legacy Review board, `phase_in_use` when cards sit in a phase it removes, `project_not_found`).
|
|
300
|
+
* Available after `prepare()`.
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```ts
|
|
304
|
+
* const { inserted, updated, unchanged } = await factory.upsertBoard(
|
|
305
|
+
* {
|
|
306
|
+
* key: 'bugs',
|
|
307
|
+
* name: 'Bugs',
|
|
308
|
+
* phases: [
|
|
309
|
+
* { key: 'reported', name: 'Reported', kind: 'resting', nextPhases: ['fixing'] },
|
|
310
|
+
* { key: 'fixing', name: 'Fixing', kind: 'working', runner: { context: 'work' }, nextPhases: ['fixed'] },
|
|
311
|
+
* { key: 'fixed', name: 'Fixed', kind: 'terminal' },
|
|
312
|
+
* ],
|
|
313
|
+
* },
|
|
314
|
+
* { projects: 'all' },
|
|
315
|
+
* );
|
|
316
|
+
* ```
|
|
317
|
+
*/
|
|
318
|
+
async upsertBoard(board, options) {
|
|
319
|
+
const store = this.#boardStore;
|
|
320
|
+
if (!store) throw new Error(this.#preparing ? "MastraFactory.upsertBoard(): the boards storage isn't available, so boards can't be stored." : "MastraFactory.upsertBoard() needs prepare() first.");
|
|
321
|
+
const { writes, projects, audit } = store;
|
|
322
|
+
const input = writes.validate(board);
|
|
323
|
+
writes.refuseCodeBoard(input.key, "edit");
|
|
324
|
+
await projects.ensureReady();
|
|
325
|
+
let scopes;
|
|
326
|
+
if (options.projects === "all") scopes = (await projects.listAll()).map((project) => ({
|
|
327
|
+
orgId: project.orgId,
|
|
328
|
+
factoryProjectId: project.id
|
|
329
|
+
}));
|
|
330
|
+
else {
|
|
331
|
+
scopes = [...options.projects];
|
|
332
|
+
for (const scope of scopes) if (!await projects.get({
|
|
333
|
+
orgId: scope.orgId,
|
|
334
|
+
id: scope.factoryProjectId
|
|
335
|
+
})) throw new BoardWriteError(404, {
|
|
336
|
+
error: "project_not_found",
|
|
337
|
+
message: `Project "${scope.factoryProjectId}" does not exist.`
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
const result = {
|
|
341
|
+
inserted: [],
|
|
342
|
+
updated: [],
|
|
343
|
+
unchanged: []
|
|
344
|
+
};
|
|
345
|
+
for (const scope of scopes) result[await writes.upsert(scope, input, {
|
|
346
|
+
id: "factory",
|
|
347
|
+
audit: async (entry) => {
|
|
348
|
+
await audit.record({
|
|
349
|
+
orgId: scope.orgId,
|
|
350
|
+
actorId: "factory",
|
|
351
|
+
actorType: "system",
|
|
352
|
+
...entry
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
})].push(scope);
|
|
356
|
+
return result;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
262
359
|
* Resolve feature readiness, wire every dependency explicitly, and assemble
|
|
263
360
|
* everything needed to construct the server-owned Mastra. Returns the args
|
|
264
361
|
* for the `new Mastra(...)` literal that must live in the entry file.
|
|
@@ -266,6 +363,8 @@ var MastraFactory = class {
|
|
|
266
363
|
async prepare() {
|
|
267
364
|
if (this.#preparing) throw new Error("MastraFactory.prepare() called twice");
|
|
268
365
|
this.#preparing = true;
|
|
366
|
+
this.#prepareStartedAt = performance.now();
|
|
367
|
+
warnIgnoredMcpConfig();
|
|
269
368
|
const publicOrigin = (this.#config.publicUrl ?? "http://localhost:4111").replace(/\/+$/, "");
|
|
270
369
|
const allowedOrigins = (this.#config.allowedOrigins ?? []).map((o) => o.replace(/\/+$/, "")).filter(Boolean);
|
|
271
370
|
const storage = instrumentAsyncMethods(this.#config.storage, "storage");
|
|
@@ -321,6 +420,10 @@ var MastraFactory = class {
|
|
|
321
420
|
const auditStorage = storage.registerDomain(new AuditStorage());
|
|
322
421
|
const workItemsStorage = storage.registerDomain(new WorkItemsStorage());
|
|
323
422
|
workItemsStorage.onAttentionChanged((scope) => touchFeed(eventBus, scope));
|
|
423
|
+
workItemsStorage.onClaimableWork(() => publishDispatchWake(eventBus, this.#dispatchWakeOrigin));
|
|
424
|
+
this.#unsubscribeDispatchWakes = subscribeDispatchWakes(eventBus, this.#dispatchWakeOrigin, () => this.#dispatcher?.wake()).catch((error) => {
|
|
425
|
+
console.warn(`[factory] subscribing to dispatcher wakes failed; other replicas' work waits for this replica's own wakes: ${error instanceof Error ? error.message : error}`);
|
|
426
|
+
});
|
|
324
427
|
workItemsStorage.useTerminalPhasePredicate((item) => isTerminalWorkItem(this.#projectBoards?.forProject(item) ?? this.#boards, item));
|
|
325
428
|
const modelCredentialsStorage = storage.registerDomain(new ModelCredentialsStorage(secretEncryption));
|
|
326
429
|
const modelDefaultsStorage = storage.registerDomain(new ModelDefaultsStorage());
|
|
@@ -347,7 +450,8 @@ var MastraFactory = class {
|
|
|
347
450
|
workItems: workItemsStorage,
|
|
348
451
|
channelIdentity: channelIdentityStorage,
|
|
349
452
|
comments: workItemCommentsStorage,
|
|
350
|
-
skillOverrides: skillOverridesStorage
|
|
453
|
+
skillOverrides: skillOverridesStorage,
|
|
454
|
+
voiceSettings: storage.registerDomain(new VoiceSettingsStorage())
|
|
351
455
|
};
|
|
352
456
|
const auditDomain = new AuditDomain({
|
|
353
457
|
auth: routeAuth,
|
|
@@ -399,9 +503,35 @@ var MastraFactory = class {
|
|
|
399
503
|
codeSkills: this.#skills
|
|
400
504
|
});
|
|
401
505
|
this.#projectBoards = projectBoards;
|
|
506
|
+
this.#boardStore = {
|
|
507
|
+
writes: new BoardWrites({
|
|
508
|
+
storage: storedBoardsStorage,
|
|
509
|
+
boards: projectBoards,
|
|
510
|
+
workItems: workItemsStorage
|
|
511
|
+
}),
|
|
512
|
+
projects: factoryProjectsStorage,
|
|
513
|
+
audit: auditDomain
|
|
514
|
+
};
|
|
402
515
|
await timedPhase("prepare.boards.preload", () => projectBoards.preload().catch((error) => console.warn(`[factory] loading project boards at startup failed; each project loads on first use: ${error instanceof Error ? error.message : error}`)));
|
|
403
516
|
}
|
|
404
517
|
const boards = this.#projectBoards ?? this.#boards;
|
|
518
|
+
if (storage.isDomainReady("work-items") && !workItemsStorage.legacyMode) {
|
|
519
|
+
const projectBoards = this.#projectBoards;
|
|
520
|
+
const projects = projectBoards ? new Set((await factoryProjectsStorage.listAll()).map((project) => `${project.orgId}\u0000${project.id}`)) : void 0;
|
|
521
|
+
const isTerminal = async (card) => {
|
|
522
|
+
let registry = this.#boards;
|
|
523
|
+
if (projectBoards) {
|
|
524
|
+
if (!projects.has(`${card.orgId}\u0000${card.factoryProjectId}`)) return false;
|
|
525
|
+
try {
|
|
526
|
+
registry = await projectBoards.load(card);
|
|
527
|
+
} catch {
|
|
528
|
+
return false;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
return registry.has(boardForWorkItem(card)) && isTerminalWorkItem(registry, card);
|
|
532
|
+
};
|
|
533
|
+
await timedPhase("prepare.migrate.workItemSplit", () => workItemsStorage.migrateOpenLegacyCards(isTerminal));
|
|
534
|
+
}
|
|
405
535
|
if (storage.isDomainReady("work-items")) await timedPhase("prepare.workItems.heldTriageCards", () => workItemsStorage.returnHeldTriageCards().then((moved) => {
|
|
406
536
|
if (moved.length > 0) console.info(`[factory] moved ${moved.length} card(s) held for triage acceptance back to Intake`);
|
|
407
537
|
}).catch((error) => console.warn(`[factory] moving cards held for triage acceptance back to Intake failed: ${error instanceof Error ? error.message : error}`)));
|
|
@@ -470,6 +600,13 @@ var MastraFactory = class {
|
|
|
470
600
|
return false;
|
|
471
601
|
}
|
|
472
602
|
});
|
|
603
|
+
if (workItemsStorage.legacyBackfillPending) {
|
|
604
|
+
const controller = new AbortController();
|
|
605
|
+
this.#workItemSplitBackfill = {
|
|
606
|
+
controller,
|
|
607
|
+
promise: timedPhase("background.migrate.workItemSplit", () => backfillUntilDone(() => workItemsStorage.backfillLegacyCards({ signal: controller.signal }), controller.signal))
|
|
608
|
+
};
|
|
609
|
+
}
|
|
473
610
|
const knowledgeEnabled = this.#config.knowledge !== void 0;
|
|
474
611
|
const githubIntegration = integrations.find((integration) => integration.id === "github");
|
|
475
612
|
const gitlabIntegration = integrations.find((integration) => integration.id === "gitlab" && integration.intake && integration.versionControl);
|
|
@@ -632,6 +769,7 @@ var MastraFactory = class {
|
|
|
632
769
|
const environmentBuilds = this.#environmentBuilds;
|
|
633
770
|
const projectRoutes = new ProjectRoutes({
|
|
634
771
|
auth: routeAuth,
|
|
772
|
+
...this.#projectBoards ? { boards: this.#projectBoards } : {},
|
|
635
773
|
sandbox: this.#sandbox,
|
|
636
774
|
...environmentBuilds ? { environmentBuilds } : {},
|
|
637
775
|
projects: factoryProjectsStorage,
|
|
@@ -718,7 +856,7 @@ var MastraFactory = class {
|
|
|
718
856
|
const orgId = tenantOrgId(policy.tenant);
|
|
719
857
|
return policy.tenant.credentialScope === "factory" && policy.factoryProjectId ? {
|
|
720
858
|
orgId,
|
|
721
|
-
userId:
|
|
859
|
+
userId: factoryProjectSettingsUserId(policy.factoryProjectId)
|
|
722
860
|
} : {
|
|
723
861
|
orgId,
|
|
724
862
|
userId: policy.tenant.userId
|
|
@@ -732,7 +870,7 @@ var MastraFactory = class {
|
|
|
732
870
|
};
|
|
733
871
|
return {
|
|
734
872
|
orgId: binding?.orgId ?? scope?.factoryOrgId ?? "local",
|
|
735
|
-
userId:
|
|
873
|
+
userId: factoryProjectSettingsUserId(factoryProjectId)
|
|
736
874
|
};
|
|
737
875
|
};
|
|
738
876
|
const loadMemorySettings = async ({ requestContext, binding }) => {
|
|
@@ -752,6 +890,7 @@ var MastraFactory = class {
|
|
|
752
890
|
boards,
|
|
753
891
|
loadMemorySettings,
|
|
754
892
|
defaultThinkingLevel: resolveDefaultThinkingLevel,
|
|
893
|
+
onBoundThreadRun: () => this.#dispatcher?.noteBoundThreadRun(),
|
|
755
894
|
...transitionService ? { transitionService } : {},
|
|
756
895
|
...githubIntegration ? { recordPullRequestProvenance: (input) => recordFactoryPullRequestProvenance(githubIntegration, sourceControlStorage.forIntegration("github"), integrationStorage.forIntegration("github"), workItemsStorage, input) } : {},
|
|
757
896
|
messageReader: { listMessages: async (input) => {
|
|
@@ -776,12 +915,16 @@ var MastraFactory = class {
|
|
|
776
915
|
versionControl: integration.versionControl,
|
|
777
916
|
storage: sourceControlStorage.forIntegration(integration.id)
|
|
778
917
|
}] : []);
|
|
918
|
+
const connectToolsProjectId = this.#config.tools === void 0 ? platformConnectProjectId() : void 0;
|
|
919
|
+
const sessionTools = this.#config.tools ?? (connectToolsProjectId ? platformConnectTools(connectToolsProjectId) : void 0);
|
|
920
|
+
const warnedConfiguredToolClashes = /* @__PURE__ */ new Set();
|
|
779
921
|
const prepared = await timedPhase("prepare.controllerMount", () => prepareAgentControllerMount({
|
|
780
922
|
controllerId: CONTROLLER_ID,
|
|
781
923
|
browser: this.#config.browser,
|
|
782
924
|
coAuthor: { name: "mastra-platform[bot]" },
|
|
783
925
|
...this.#config.disableBuiltinTools?.length ? { disableBuiltinTools: this.#config.disableBuiltinTools } : {},
|
|
784
926
|
modes: false,
|
|
927
|
+
plansDir: FACTORY_PLANS_DIR,
|
|
785
928
|
subagents: [],
|
|
786
929
|
resolveDefaultThinkingLevel: ({ requestContext }) => resolveDefaultThinkingLevel(requestContext),
|
|
787
930
|
workspace: createWorkspaceFactory({
|
|
@@ -800,6 +943,7 @@ var MastraFactory = class {
|
|
|
800
943
|
workspaceRegistry
|
|
801
944
|
}),
|
|
802
945
|
disableGithubSignals: true,
|
|
946
|
+
disableMcp: true,
|
|
803
947
|
prepareWakeRequestContext: async ({ requestContext, resourceId, threadId }) => {
|
|
804
948
|
if (!storage.isDomainReady("source-control")) {
|
|
805
949
|
if (auth) await failWake({
|
|
@@ -1035,6 +1179,17 @@ var MastraFactory = class {
|
|
|
1035
1179
|
if (integration.agentTools) mergeTools(integration.id, await integration.agentTools({ requestContext }));
|
|
1036
1180
|
if (integration.sessionTools) mergeTools(integration.id, integration.sessionTools({ requestContext }));
|
|
1037
1181
|
}
|
|
1182
|
+
if (sessionTools) {
|
|
1183
|
+
const contributed = typeof sessionTools === "function" ? await sessionTools({ requestContext }) : sessionTools;
|
|
1184
|
+
for (const [name, tool] of Object.entries(contributed)) {
|
|
1185
|
+
const owner = toolOwners.get(name);
|
|
1186
|
+
if (!owner) tools[name] = tool;
|
|
1187
|
+
else if (!warnedConfiguredToolClashes.has(name)) {
|
|
1188
|
+
warnedConfiguredToolClashes.add(name);
|
|
1189
|
+
console.warn(`[factory] configured tool '${name}' is not offered to sessions: '${owner}' already provides a tool with that name.`);
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1038
1193
|
return tools;
|
|
1039
1194
|
},
|
|
1040
1195
|
postToolObserver: async (toolContext) => {
|
|
@@ -1157,13 +1312,22 @@ var MastraFactory = class {
|
|
|
1157
1312
|
reconcileToolResults: () => factoryProcessor?.reconcileAllBoundThreads() ?? Promise.resolve(),
|
|
1158
1313
|
prepareBinding,
|
|
1159
1314
|
feedReader: new FactoryFeedReader(workItemCommentsStorage),
|
|
1160
|
-
...githubIntegration ? {
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1315
|
+
...githubIntegration ? {
|
|
1316
|
+
dismissStaleReviews: async (decision) => {
|
|
1317
|
+
await dismissStaleFactoryReviews(githubIntegration.versionControl, decision, (login) => isFactoryGithubLogin(githubIntegration, login), (login) => trustedCollaborator(githubIntegration, {
|
|
1318
|
+
installationId: decision.installationId,
|
|
1319
|
+
repository: decision.repository,
|
|
1320
|
+
login
|
|
1321
|
+
}));
|
|
1322
|
+
},
|
|
1323
|
+
reportReviewStatus: createGithubReviewStatusReporter({
|
|
1324
|
+
github: githubIntegration,
|
|
1325
|
+
sourceControl: sourceControlStorage.forIntegration(githubIntegration.id),
|
|
1326
|
+
workItems: workItemsStorage,
|
|
1327
|
+
reviewerName: process.env.FACTORY_REVIEW_STATUS_NAME?.trim() || "Factory",
|
|
1328
|
+
...reviewStatusAnimationFromEnv(process.env)
|
|
1329
|
+
})
|
|
1330
|
+
} : {},
|
|
1167
1331
|
primeCredentials: (tenant) => primeTenantCredentials({
|
|
1168
1332
|
tenant,
|
|
1169
1333
|
credentials: modelCredentialsStorage
|
|
@@ -1193,7 +1357,11 @@ var MastraFactory = class {
|
|
|
1193
1357
|
...hasPlatformCredentials() ? buildPlatformConnectRoutes({
|
|
1194
1358
|
auth: routeAuth,
|
|
1195
1359
|
client: new PlatformApiClient(platformApiClientConfigFromEnv())
|
|
1196
|
-
}) : []
|
|
1360
|
+
}) : [],
|
|
1361
|
+
buildConnectToolsRoute(routeAuth, connectToolsProjectId ? {
|
|
1362
|
+
client: new PlatformApiClient(platformApiClientConfigFromEnv()),
|
|
1363
|
+
projectId: connectToolsProjectId
|
|
1364
|
+
} : void 0)
|
|
1197
1365
|
],
|
|
1198
1366
|
buildServerConfig: () => {
|
|
1199
1367
|
const mcpCors = {
|
|
@@ -1375,6 +1543,7 @@ var MastraFactory = class {
|
|
|
1375
1543
|
await timedPhase("finalize.reconcileBoundThreads", () => this.#factoryProcessor?.reconcileAllBoundThreads() ?? Promise.resolve());
|
|
1376
1544
|
this.#sessionResourceMigration?.then((movedRunBindings) => movedRunBindings ? this.#factoryProcessor?.reconcileAllBoundThreads() : void 0).catch((error) => console.warn(`[factory] reconciling bound threads after the session resource migration failed: ${error instanceof Error ? error.message : error}`));
|
|
1377
1545
|
this.#dispatcher?.start();
|
|
1546
|
+
if (this.#prepareStartedAt !== void 0) logTiming(`boot ${Math.round(performance.now() - this.#prepareStartedAt)}ms`);
|
|
1378
1547
|
}
|
|
1379
1548
|
/** Stop Factory-owned background work and channel transports before the host process shuts down. */
|
|
1380
1549
|
async shutdown() {
|
|
@@ -1382,8 +1551,17 @@ var MastraFactory = class {
|
|
|
1382
1551
|
const channelShutdowns = this.#channelShutdowns;
|
|
1383
1552
|
this.#channelShutdowns = [];
|
|
1384
1553
|
const shutdownPromise = (async () => {
|
|
1385
|
-
const
|
|
1386
|
-
|
|
1554
|
+
const unsubscribeDispatchWakes = this.#unsubscribeDispatchWakes;
|
|
1555
|
+
this.#unsubscribeDispatchWakes = void 0;
|
|
1556
|
+
await unsubscribeDispatchWakes?.then((unsubscribe) => unsubscribe?.()).catch((error) => console.warn(`[factory] unsubscribing from dispatcher wakes failed: ${error instanceof Error ? error.message : error}`));
|
|
1557
|
+
const backfill = this.#workItemSplitBackfill;
|
|
1558
|
+
backfill?.controller.abort();
|
|
1559
|
+
const results = await Promise.allSettled([
|
|
1560
|
+
this.#dispatcher?.stop() ?? Promise.resolve(),
|
|
1561
|
+
backfill?.promise ?? Promise.resolve(),
|
|
1562
|
+
...channelShutdowns.map(async (shutdown) => shutdown())
|
|
1563
|
+
]);
|
|
1564
|
+
results.slice(2).forEach((result, index) => {
|
|
1387
1565
|
if (result.status === "rejected") this.#channelShutdowns.push(channelShutdowns[index]);
|
|
1388
1566
|
});
|
|
1389
1567
|
const failure = results.find((result) => result.status === "rejected");
|