@mastra/factory 0.29.0-alpha.4 → 0.29.0-alpha.6
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 +172 -89
- package/dist/boards/board-events.d.ts +89 -9
- package/dist/boards/board-events.d.ts.map +1 -1
- package/dist/boards/board-events.js +176 -13
- package/dist/boards/board-events.js.map +1 -1
- package/dist/boards/board-writes.d.ts.map +1 -1
- package/dist/boards/board-writes.js +14 -1
- package/dist/boards/board-writes.js.map +1 -1
- package/dist/boards/busy-card.d.ts +11 -0
- package/dist/boards/busy-card.d.ts.map +1 -0
- package/dist/boards/busy-card.js +15 -0
- package/dist/boards/busy-card.js.map +1 -0
- package/dist/boards/card-facts.d.ts.map +1 -1
- package/dist/boards/card-facts.js +18 -4
- package/dist/boards/card-facts.js.map +1 -1
- package/dist/boards/index.d.ts +2 -1
- package/dist/boards/index.d.ts.map +1 -1
- package/dist/boards/index.js +3 -2
- package/dist/boards/intake-dry-run.d.ts +109 -0
- package/dist/boards/intake-dry-run.d.ts.map +1 -0
- package/dist/boards/intake-dry-run.js +158 -0
- package/dist/boards/intake-dry-run.js.map +1 -0
- package/dist/boards/intake-lookup.d.ts +32 -0
- package/dist/boards/intake-lookup.d.ts.map +1 -0
- package/dist/boards/intake-lookup.js +12 -0
- package/dist/boards/intake-lookup.js.map +1 -0
- package/dist/boards/intake-order.d.ts +32 -0
- package/dist/boards/intake-order.d.ts.map +1 -0
- package/dist/boards/intake-order.js +60 -0
- package/dist/boards/intake-order.js.map +1 -0
- package/dist/boards/intake-routing.d.ts +246 -35
- package/dist/boards/intake-routing.d.ts.map +1 -1
- package/dist/boards/intake-routing.js +437 -52
- package/dist/boards/intake-routing.js.map +1 -1
- package/dist/boards/reroute.d.ts +7 -3
- package/dist/boards/reroute.d.ts.map +1 -1
- package/dist/boards/reroute.js +21 -4
- package/dist/boards/reroute.js.map +1 -1
- package/dist/boards/semantics.d.ts +8 -28
- package/dist/boards/semantics.d.ts.map +1 -1
- package/dist/boards/semantics.js +14 -40
- package/dist/boards/semantics.js.map +1 -1
- package/dist/boards/work-routes.d.ts +31 -11
- package/dist/boards/work-routes.d.ts.map +1 -1
- package/dist/boards/work-routes.js +104 -20
- package/dist/boards/work-routes.js.map +1 -1
- package/dist/factory.d.ts +37 -1
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +127 -48
- package/dist/factory.js.map +1 -1
- package/dist/integrations/base.d.ts +9 -0
- package/dist/integrations/base.d.ts.map +1 -1
- package/dist/integrations/dependabot/rules.js +1 -1
- package/dist/integrations/dependabot/rules.js.map +1 -1
- package/dist/integrations/github/default-rules.d.ts +22 -1
- package/dist/integrations/github/default-rules.d.ts.map +1 -1
- package/dist/integrations/github/default-rules.js +23 -5
- package/dist/integrations/github/default-rules.js.map +1 -1
- package/dist/integrations/github/intake-lookup.d.ts +16 -0
- package/dist/integrations/github/intake-lookup.d.ts.map +1 -0
- package/dist/integrations/github/intake-lookup.js +76 -0
- package/dist/integrations/github/intake-lookup.js.map +1 -0
- package/dist/integrations/github/integration.d.ts +19 -5
- package/dist/integrations/github/integration.d.ts.map +1 -1
- package/dist/integrations/github/integration.js +21 -6
- package/dist/integrations/github/integration.js.map +1 -1
- package/dist/integrations/github/issue-intake.d.ts +15 -0
- package/dist/integrations/github/issue-intake.d.ts.map +1 -0
- package/dist/integrations/github/issue-intake.js +50 -0
- package/dist/integrations/github/issue-intake.js.map +1 -0
- package/dist/integrations/github/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/github/issue-reconciler.js +10 -1
- package/dist/integrations/github/issue-reconciler.js.map +1 -1
- package/dist/integrations/github/review-status-reporter.js +1 -1
- package/dist/integrations/github/routes.d.ts.map +1 -1
- package/dist/integrations/github/routes.js +14 -2
- package/dist/integrations/github/routes.js.map +1 -1
- package/dist/integrations/github/rules.d.ts +14 -1
- package/dist/integrations/github/rules.d.ts.map +1 -1
- package/dist/integrations/github/rules.js +221 -30
- package/dist/integrations/github/rules.js.map +1 -1
- package/dist/integrations/github/sandbox.d.ts.map +1 -1
- package/dist/integrations/github/sandbox.js +30 -4
- package/dist/integrations/github/sandbox.js.map +1 -1
- package/dist/integrations/gitlab/default-rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/default-rules.js +19 -3
- package/dist/integrations/gitlab/default-rules.js.map +1 -1
- package/dist/integrations/gitlab/intake-lookup.d.ts +17 -0
- package/dist/integrations/gitlab/intake-lookup.d.ts.map +1 -0
- package/dist/integrations/gitlab/intake-lookup.js +85 -0
- package/dist/integrations/gitlab/intake-lookup.js.map +1 -0
- package/dist/integrations/gitlab/integration.d.ts +5 -0
- package/dist/integrations/gitlab/integration.d.ts.map +1 -1
- package/dist/integrations/gitlab/integration.js +21 -1
- package/dist/integrations/gitlab/integration.js.map +1 -1
- package/dist/integrations/gitlab/rules.d.ts +20 -0
- package/dist/integrations/gitlab/rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/rules.js +108 -12
- package/dist/integrations/gitlab/rules.js.map +1 -1
- package/dist/integrations/incidentio/rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/rules.js +14 -4
- package/dist/integrations/incidentio/rules.js.map +1 -1
- package/dist/integrations/jira/rules.d.ts.map +1 -1
- package/dist/integrations/jira/rules.js +12 -2
- package/dist/integrations/jira/rules.js.map +1 -1
- package/dist/integrations/linear/rules.d.ts.map +1 -1
- package/dist/integrations/linear/rules.js +13 -2
- package/dist/integrations/linear/rules.js.map +1 -1
- package/dist/integrations/platform/connect/routes.d.ts +43 -1
- package/dist/integrations/platform/connect/routes.d.ts.map +1 -1
- package/dist/integrations/platform/connect/routes.js +82 -7
- package/dist/integrations/platform/connect/routes.js.map +1 -1
- package/dist/integrations/platform/connect/session-tools.d.ts +12 -0
- package/dist/integrations/platform/connect/session-tools.d.ts.map +1 -1
- package/dist/integrations/platform/connect/session-tools.js +28 -10
- package/dist/integrations/platform/connect/session-tools.js.map +1 -1
- package/dist/integrations/platform/github/event-worker.js +9 -1
- package/dist/integrations/platform/github/event-worker.js.map +1 -1
- package/dist/integrations/platform/github/integration.d.ts +6 -6
- package/dist/integrations/platform/github/integration.d.ts.map +1 -1
- package/dist/integrations/platform/github/integration.js +22 -3
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/platform/vanta/integration.d.ts.map +1 -1
- package/dist/integrations/platform/vanta/integration.js +3 -3
- package/dist/integrations/platform/vanta/integration.js.map +1 -1
- package/dist/integrations/pull-request-head.d.ts +1 -1
- package/dist/integrations/pull-request-head.d.ts.map +1 -1
- package/dist/integrations/pull-request-head.js +5 -0
- package/dist/integrations/pull-request-head.js.map +1 -1
- package/dist/integrations/vanta/rules.js +1 -1
- package/dist/integrations/vanta/rules.js.map +1 -1
- package/dist/integrations/vanta/sync.d.ts +9 -0
- package/dist/integrations/vanta/sync.d.ts.map +1 -1
- package/dist/integrations/vanta/sync.js +10 -1
- package/dist/integrations/vanta/sync.js.map +1 -1
- package/dist/routes/board-snapshot.d.ts +13 -6
- package/dist/routes/board-snapshot.d.ts.map +1 -1
- package/dist/routes/board-snapshot.js +42 -20
- package/dist/routes/board-snapshot.js.map +1 -1
- package/dist/routes/boards.js.map +1 -1
- package/dist/routes/config.d.ts +17 -2
- package/dist/routes/config.d.ts.map +1 -1
- package/dist/routes/config.js +247 -77
- package/dist/routes/config.js.map +1 -1
- package/dist/routes/contracts.d.ts +1294 -7
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/contracts.js +603 -20
- package/dist/routes/contracts.js.map +1 -1
- package/dist/routes/custom-endpoint-url.d.ts +8 -0
- package/dist/routes/custom-endpoint-url.d.ts.map +1 -0
- package/dist/routes/custom-endpoint-url.js +45 -0
- package/dist/routes/custom-endpoint-url.js.map +1 -0
- package/dist/routes/custom-provider-source.d.ts +24 -8
- package/dist/routes/custom-provider-source.d.ts.map +1 -1
- package/dist/routes/custom-provider-source.js +93 -43
- package/dist/routes/custom-provider-source.js.map +1 -1
- package/dist/routes/intake-check.d.ts +92 -0
- package/dist/routes/intake-check.d.ts.map +1 -0
- package/dist/routes/intake-check.js +322 -0
- package/dist/routes/intake-check.js.map +1 -0
- package/dist/routes/intake-routes.d.ts +10 -2
- package/dist/routes/intake-routes.d.ts.map +1 -1
- package/dist/routes/intake-routes.js +292 -11
- package/dist/routes/intake-routes.js.map +1 -1
- package/dist/routes/intake.d.ts +6 -0
- package/dist/routes/intake.d.ts.map +1 -1
- package/dist/routes/intake.js +20 -0
- package/dist/routes/intake.js.map +1 -1
- package/dist/routes/mastra-gateway.d.ts.map +1 -1
- package/dist/routes/mastra-gateway.js +3 -2
- package/dist/routes/mastra-gateway.js.map +1 -1
- package/dist/routes/project-sessions.d.ts +61 -0
- package/dist/routes/project-sessions.d.ts.map +1 -0
- package/dist/routes/project-sessions.js +135 -0
- package/dist/routes/project-sessions.js.map +1 -0
- package/dist/routes/projects.d.ts +6 -1
- package/dist/routes/projects.d.ts.map +1 -1
- package/dist/routes/projects.js +19 -3
- package/dist/routes/projects.js.map +1 -1
- package/dist/routes/provider-credentials.d.ts +10 -1
- package/dist/routes/provider-credentials.d.ts.map +1 -1
- package/dist/routes/provider-credentials.js +13 -16
- package/dist/routes/provider-credentials.js.map +1 -1
- package/dist/routes/run-queue.d.ts +6 -6
- package/dist/routes/run-queue.d.ts.map +1 -1
- package/dist/routes/run-queue.js +28 -8
- package/dist/routes/run-queue.js.map +1 -1
- package/dist/routes/session-rows.d.ts +30 -0
- package/dist/routes/session-rows.d.ts.map +1 -0
- package/dist/routes/session-rows.js +94 -0
- package/dist/routes/session-rows.js.map +1 -0
- package/dist/routes/source-control-sessions.d.ts +4 -5
- package/dist/routes/source-control-sessions.d.ts.map +1 -1
- package/dist/routes/source-control-sessions.js +8 -87
- package/dist/routes/source-control-sessions.js.map +1 -1
- package/dist/routes/surface.d.ts +16 -1
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +41 -30
- package/dist/routes/surface.js.map +1 -1
- package/dist/routes/tenant-credentials.d.ts.map +1 -1
- package/dist/routes/tenant-credentials.js +4 -4
- package/dist/routes/tenant-credentials.js.map +1 -1
- package/dist/routes/work-item-starters.d.ts +1 -0
- package/dist/routes/work-item-starters.d.ts.map +1 -1
- package/dist/routes/work-item-starters.js +14 -2
- package/dist/routes/work-item-starters.js.map +1 -1
- package/dist/routes/work-items.d.ts +22 -3
- package/dist/routes/work-items.d.ts.map +1 -1
- package/dist/routes/work-items.js +124 -48
- package/dist/routes/work-items.js.map +1 -1
- package/dist/rules/binding-context.d.ts +5 -0
- package/dist/rules/binding-context.d.ts.map +1 -1
- package/dist/rules/binding-context.js +51 -5
- package/dist/rules/binding-context.js.map +1 -1
- package/dist/rules/dispatch-errors.js +1 -1
- package/dist/rules/dispatch-errors.js.map +1 -1
- package/dist/rules/dispatcher.d.ts +39 -7
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +363 -123
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/event-rules.d.ts +69 -1
- package/dist/rules/event-rules.d.ts.map +1 -1
- package/dist/rules/event-rules.js +151 -5
- package/dist/rules/event-rules.js.map +1 -1
- package/dist/rules/review-source-tool.js +1 -1
- package/dist/rules/rule-group.d.ts +18 -1
- package/dist/rules/rule-group.d.ts.map +1 -1
- package/dist/rules/rule-group.js +52 -8
- package/dist/rules/rule-group.js.map +1 -1
- package/dist/rules/run-bearing.d.ts +8 -0
- package/dist/rules/run-bearing.d.ts.map +1 -0
- package/dist/rules/run-bearing.js +11 -0
- package/dist/rules/run-bearing.js.map +1 -0
- package/dist/rules/start-coordinator.d.ts +2 -3
- package/dist/rules/start-coordinator.d.ts.map +1 -1
- package/dist/rules/start-coordinator.js +25 -38
- package/dist/rules/start-coordinator.js.map +1 -1
- package/dist/rules/tools.js +2 -1
- package/dist/rules/tools.js.map +1 -1
- package/dist/rules/transition-service.d.ts +16 -0
- package/dist/rules/transition-service.d.ts.map +1 -1
- package/dist/rules/transition-service.js +34 -10
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/rules/types.d.ts +18 -5
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/types.js +2 -1
- package/dist/rules/types.js.map +1 -1
- package/dist/rules/update-fold.d.ts +32 -0
- package/dist/rules/update-fold.d.ts.map +1 -0
- package/dist/rules/update-fold.js +60 -0
- package/dist/rules/update-fold.js.map +1 -0
- package/dist/rules/validation.d.ts.map +1 -1
- package/dist/rules/validation.js +54 -6
- package/dist/rules/validation.js.map +1 -1
- package/dist/sandbox/session-retirement.d.ts +6 -0
- package/dist/sandbox/session-retirement.d.ts.map +1 -1
- package/dist/sandbox/session-retirement.js +17 -0
- package/dist/sandbox/session-retirement.js.map +1 -1
- package/dist/session/factory-session.d.ts.map +1 -1
- package/dist/session/factory-session.js +2 -1
- package/dist/session/factory-session.js.map +1 -1
- package/dist/session/live-sessions.d.ts +6 -1
- package/dist/session/live-sessions.d.ts.map +1 -1
- package/dist/session/live-sessions.js +4 -0
- package/dist/session/live-sessions.js.map +1 -1
- package/dist/session/resource-migration.d.ts.map +1 -1
- package/dist/session/resource-migration.js +2 -3
- package/dist/session/resource-migration.js.map +1 -1
- package/dist/session/run-audit.d.ts +10 -1
- package/dist/session/run-audit.d.ts.map +1 -1
- package/dist/session/run-audit.js +9 -1
- package/dist/session/run-audit.js.map +1 -1
- package/dist/session/self-review-gate.d.ts +26 -2
- package/dist/session/self-review-gate.d.ts.map +1 -1
- package/dist/session/self-review-gate.js +60 -10
- package/dist/session/self-review-gate.js.map +1 -1
- package/dist/session/session-row-query.d.ts +25 -0
- package/dist/session/session-row-query.d.ts.map +1 -0
- package/dist/session/session-row-query.js +47 -0
- package/dist/session/session-row-query.js.map +1 -0
- package/dist/session/session-row-status.d.ts +16 -0
- package/dist/session/session-row-status.d.ts.map +1 -0
- package/dist/session/session-row-status.js +14 -0
- package/dist/session/session-row-status.js.map +1 -0
- package/dist/session/session-row-view.d.ts +13 -0
- package/dist/session/session-row-view.d.ts.map +1 -0
- package/dist/session/session-row-view.js +118 -0
- package/dist/session/session-row-view.js.map +1 -0
- package/dist/session/session-rows.d.ts +60 -0
- package/dist/session/session-rows.d.ts.map +1 -0
- package/dist/session/session-rows.js +307 -0
- package/dist/session/session-rows.js.map +1 -0
- package/dist/session/session-threads.d.ts.map +1 -1
- package/dist/session/session-threads.js +1 -0
- package/dist/session/session-threads.js.map +1 -1
- package/dist/session/session-unloader.d.ts +101 -0
- package/dist/session/session-unloader.d.ts.map +1 -0
- package/dist/session/session-unloader.js +278 -0
- package/dist/session/session-unloader.js.map +1 -0
- package/dist/session/source-control-tools.d.ts +14 -7
- package/dist/session/source-control-tools.d.ts.map +1 -1
- package/dist/session/source-control-tools.js +10 -2
- package/dist/session/source-control-tools.js.map +1 -1
- package/dist/session/work-item-repository.d.ts +49 -1
- package/dist/session/work-item-repository.d.ts.map +1 -1
- package/dist/session/work-item-repository.js +118 -15
- package/dist/session/work-item-repository.js.map +1 -1
- package/dist/session/work-item-state-processor.d.ts.map +1 -1
- package/dist/session/work-item-state-processor.js +44 -8
- package/dist/session/work-item-state-processor.js.map +1 -1
- package/dist/session-list-changes.d.ts +9 -0
- package/dist/session-list-changes.d.ts.map +1 -0
- package/dist/session-list-changes.js +54 -0
- package/dist/session-list-changes.js.map +1 -0
- package/dist/storage/announced-lists.d.ts +14 -0
- package/dist/storage/announced-lists.d.ts.map +1 -0
- package/dist/storage/announced-lists.js +78 -0
- package/dist/storage/announced-lists.js.map +1 -0
- package/dist/storage/domains/audit/actions.d.ts +2 -1
- package/dist/storage/domains/audit/actions.d.ts.map +1 -1
- package/dist/storage/domains/audit/actions.js +3 -1
- package/dist/storage/domains/audit/actions.js.map +1 -1
- package/dist/storage/domains/boards/base.d.ts +163 -15
- package/dist/storage/domains/boards/base.d.ts.map +1 -1
- package/dist/storage/domains/boards/base.js +440 -48
- package/dist/storage/domains/boards/base.js.map +1 -1
- package/dist/storage/domains/boards/schemas.d.ts +6 -0
- package/dist/storage/domains/boards/schemas.d.ts.map +1 -1
- package/dist/storage/domains/boards/schemas.js +95 -1
- package/dist/storage/domains/boards/schemas.js.map +1 -1
- package/dist/storage/domains/custom-providers/base.d.ts +62 -19
- package/dist/storage/domains/custom-providers/base.d.ts.map +1 -1
- package/dist/storage/domains/custom-providers/base.js +131 -100
- package/dist/storage/domains/custom-providers/base.js.map +1 -1
- package/dist/storage/domains/intake/base.d.ts +25 -7
- package/dist/storage/domains/intake/base.d.ts.map +1 -1
- package/dist/storage/domains/intake/base.js +83 -19
- package/dist/storage/domains/intake/base.js.map +1 -1
- package/dist/storage/domains/projects/base.d.ts.map +1 -1
- package/dist/storage/domains/projects/base.js +19 -10
- package/dist/storage/domains/projects/base.js.map +1 -1
- package/dist/storage/domains/source-control/base.d.ts +8 -0
- package/dist/storage/domains/source-control/base.d.ts.map +1 -1
- package/dist/storage/domains/source-control/base.js +110 -61
- package/dist/storage/domains/source-control/base.js.map +1 -1
- package/dist/storage/domains/source-control/inmemory.d.ts +4 -0
- package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/source-control/inmemory.js +8 -5
- package/dist/storage/domains/source-control/inmemory.js.map +1 -1
- package/dist/storage/domains/work-items/base.d.ts +57 -18
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +168 -83
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/storage/domains/work-items/cards.d.ts +3 -2
- package/dist/storage/domains/work-items/cards.d.ts.map +1 -1
- package/dist/storage/domains/work-items/cards.js +4 -2
- package/dist/storage/domains/work-items/cards.js.map +1 -1
- package/dist/tools/audit-events-tool.d.ts +2 -2
- package/dist/tools/read-tools.d.ts +9 -5
- package/dist/tools/read-tools.d.ts.map +1 -1
- package/dist/tools/read-tools.js +61 -54
- package/dist/tools/read-tools.js.map +1 -1
- package/dist/tools/session-tools.d.ts +0 -13
- package/dist/tools/session-tools.d.ts.map +1 -1
- package/dist/tools/session-tools.js +128 -341
- package/dist/tools/session-tools.js.map +1 -1
- package/dist/tools/work-item-tools.d.ts +3 -0
- package/dist/tools/work-item-tools.d.ts.map +1 -1
- package/dist/tools/work-item-tools.js +99 -27
- package/dist/tools/work-item-tools.js.map +1 -1
- package/dist/work-item-branch.d.ts +4 -0
- package/dist/work-item-branch.d.ts.map +1 -1
- package/dist/work-item-branch.js +7 -1
- package/dist/work-item-branch.js.map +1 -1
- package/dist/work-items/card-context-sessions.d.ts +50 -0
- package/dist/work-items/card-context-sessions.d.ts.map +1 -0
- package/dist/work-items/card-context-sessions.js +84 -0
- package/dist/work-items/card-context-sessions.js.map +1 -0
- package/dist/work-items/card-reference.d.ts +21 -0
- package/dist/work-items/card-reference.d.ts.map +1 -0
- package/dist/work-items/card-reference.js +58 -0
- package/dist/work-items/card-reference.js.map +1 -0
- package/dist/work-items/change-requests.d.ts +87 -0
- package/dist/work-items/change-requests.d.ts.map +1 -0
- package/dist/work-items/change-requests.js +134 -0
- package/dist/work-items/change-requests.js.map +1 -0
- package/dist/work-items/create-work-item.d.ts +7 -2
- package/dist/work-items/create-work-item.d.ts.map +1 -1
- package/dist/work-items/create-work-item.js +44 -13
- package/dist/work-items/create-work-item.js.map +1 -1
- package/dist/work-items/list-related-cards.d.ts.map +1 -1
- package/dist/work-items/list-related-cards.js +1 -1
- package/dist/work-items/list-related-cards.js.map +1 -1
- package/dist/work-items/providers/github.d.ts.map +1 -1
- package/dist/work-items/providers/github.js +1 -0
- package/dist/work-items/providers/github.js.map +1 -1
- package/factory-skills/factory-build/SKILL.md +1 -1
- package/factory-skills/factory-plan/SKILL.md +5 -3
- package/factory-skills/factory-self-review/SKILL.md +2 -0
- package/factory-skills/factory-triage/SKILL.md +1 -1
- package/package.json +10 -10
package/dist/routes/config.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { AuthStorage } from '@mastra/code-sdk/auth/storage';
|
|
|
2
2
|
import type { ProviderAccess } from '@mastra/code-sdk/onboarding/packs';
|
|
3
3
|
import type { ModelReasoningOption } from '@mastra/core/llm';
|
|
4
4
|
import type { ApiRoute } from '@mastra/core/server';
|
|
5
|
-
import type { CredentialRecord, LoginSessionKind, ModelCredentialsStorage } from '../storage/domains/credentials/base.js';
|
|
5
|
+
import type { CredentialRecord, CredentialScope as StoredCredentialScope, LoginSessionKind, ModelCredentialsStorage } from '../storage/domains/credentials/base.js';
|
|
6
6
|
import type { CustomProviderRecord, CustomProvidersStorage } from '../storage/domains/custom-providers/base.js';
|
|
7
7
|
import type { MemorySettingsStorage } from '../storage/domains/memory-settings/base.js';
|
|
8
8
|
import type { ModelDefaultsStorage } from '../storage/domains/model-defaults/base.js';
|
|
@@ -64,6 +64,12 @@ export interface ProviderInfo {
|
|
|
64
64
|
custom?: true;
|
|
65
65
|
/** Tenant mode: Factory can mint this provider's key with the caller's Mastra account (the Mastra Gateway). */
|
|
66
66
|
connectWithMastraAccount?: true;
|
|
67
|
+
/**
|
|
68
|
+
* Tenant mode: the server has its own key for this provider (the Mastra Gateway), which serves
|
|
69
|
+
* any scope that has no stored credential. Reported apart from `source`, which names only the
|
|
70
|
+
* credential that wins for the caller.
|
|
71
|
+
*/
|
|
72
|
+
serverKey?: true;
|
|
67
73
|
}
|
|
68
74
|
/** Minimal session surface the config routes touch. */
|
|
69
75
|
export interface OMSession {
|
|
@@ -111,7 +117,7 @@ export declare function listProviders({ controller, authStorage, tenantCredentia
|
|
|
111
117
|
authStorage?: AuthStorage;
|
|
112
118
|
tenantCredentials?: CredentialRecord[];
|
|
113
119
|
deploymentProviders?: ReadonlySet<string>;
|
|
114
|
-
listCustomProviders?: () => Promise<
|
|
120
|
+
listCustomProviders?: () => Promise<ScopedCustomProvider[]>;
|
|
115
121
|
/** The auth provider can act on the Mastra platform as the caller. */
|
|
116
122
|
connectWithMastraAccount?: boolean;
|
|
117
123
|
}): Promise<ProviderInfo[]>;
|
|
@@ -122,6 +128,15 @@ export interface CustomProviderInfo {
|
|
|
122
128
|
url: string;
|
|
123
129
|
hasApiKey: boolean;
|
|
124
130
|
models: string[];
|
|
131
|
+
/** Saved for the caller (`user`) or for their organization (`org`), like a provider key. */
|
|
132
|
+
scope: StoredCredentialScope;
|
|
133
|
+
/** Why this server refuses to call the endpoint. Its models are not offered until the URL is fixed. */
|
|
134
|
+
urlProblem?: string;
|
|
135
|
+
}
|
|
136
|
+
/** A stored custom provider and the settings scope it is saved at. */
|
|
137
|
+
export interface ScopedCustomProvider {
|
|
138
|
+
record: CustomProviderRecord;
|
|
139
|
+
scope: StoredCredentialScope;
|
|
125
140
|
}
|
|
126
141
|
/**
|
|
127
142
|
* Providers whose credentials can only come from the server process. Amazon
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/routes/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAGjE,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,mCAAmC,CAAC;AAQ7F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAOpD,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/routes/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAGjE,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,mCAAmC,CAAC;AAQ7F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAOpD,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,IAAI,qBAAqB,EACxC,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,wCAAwC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,CAAC,EAAE,uBAAuB,CAAC;IAC3C,yEAAyE;IACzE,aAAa,CAAC,EAAE,oBAAoB,CAAC;IACrC,sEAAsE;IACtE,qBAAqB,CAAC,EAAE,IAAI,CAAC,0BAA0B,CAAC,UAAU,CAAC,EAAE,gBAAgB,CAAC,CAAC;IACvF,cAAc,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,0BAA0B,EAAE,UAAU,CAAC,CAAC,CAAC;IACrE,gFAAgF;IAChF,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,0EAA0E;IAC1E,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,2FAA2F;IAC3F,eAAe,CAAC,EAAE,sBAAsB,CAAC;IACzC,+EAA+E;IAC/E,eAAe,CAAC,EAAE,sBAAsB,CAAC;IACzC,kFAAkF;IAClF,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC5E,6FAA6F;IAC7F,wBAAwB,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC/D;;;OAGG;IACH,mBAAmB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC3C;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,YAAa,SAAQ,KAAK,CAAC,gBAAgB,CAAC;IACvD,MAAM,IAAI,QAAQ,EAAE,CA8/BnB;CACF"}
|
package/dist/routes/config.js
CHANGED
|
@@ -2,8 +2,10 @@ import { resolveFactoryModelPolicy, routedPersonalDefaults } from "../session/cr
|
|
|
2
2
|
import "../session/memory-settings-hydration.js";
|
|
3
3
|
import { effectiveModelScope, factoryProjectSettingsUserId } from "../storage/domains/projects/base.js";
|
|
4
4
|
import { THINKING_LEVELS } from "./contracts.js";
|
|
5
|
+
import { customEndpointUrlProblem } from "./custom-endpoint-url.js";
|
|
6
|
+
import { customProviderOwner } from "./custom-provider-source.js";
|
|
5
7
|
import { MASTRA_SIGN_IN_REQUIRED, MastraGatewayError, createGatewayKey, getGatewayCredits } from "./mastra-gateway.js";
|
|
6
|
-
import { MASTRA_GATEWAY_CATALOG_PROVIDER, WEB_OAUTH_PROVIDERS, credentialLabel, getAuthProviderId, listTenantCredentialsForRequest, resolveCredentialContext, tenantOrgId } from "./provider-credentials.js";
|
|
8
|
+
import { MASTRA_GATEWAY_CATALOG_PROVIDER, WEB_OAUTH_PROVIDERS, credentialLabel, getAuthProviderId, listTenantCredentialsForRequest, resolveCredentialContext, runScopeFor, storedScopeFor, tenantOrgId } from "./provider-credentials.js";
|
|
7
9
|
import { Route, loose } from "./route.js";
|
|
8
10
|
import { readRunningPackages } from "./running-packages.js";
|
|
9
11
|
import { resolveTenantProviderDefaultModel } from "./tenant-credentials.js";
|
|
@@ -12,14 +14,37 @@ import { registerApiRoute } from "@mastra/core/server";
|
|
|
12
14
|
import { MIN_OBSERVATION_THRESHOLD } from "@mastra/code-sdk/constants";
|
|
13
15
|
import { z } from "zod";
|
|
14
16
|
import { MASTRA_GATEWAY_PROVIDER, getCustomProviderId } from "@mastra/code-sdk/onboarding/settings";
|
|
15
|
-
import { MASTRA_GATEWAY_PREFIX } from "@mastra/code-sdk/providers/model-ids";
|
|
16
|
-
import { MastraCodeGateway } from "@mastra/code-sdk/agents/mastracode-gateway";
|
|
17
|
+
import { MASTRA_GATEWAY_PREFIX, normalizeLegacyProviderId } from "@mastra/code-sdk/providers/model-ids";
|
|
18
|
+
import { MASTRACODE_GATEWAY_ID, MastraCodeGateway } from "@mastra/code-sdk/agents/mastracode-gateway";
|
|
17
19
|
import { resolveAutoOMModelId } from "@mastra/code-sdk/onboarding/packs";
|
|
18
20
|
import { AMAZON_BEDROCK_GATEWAY_ID } from "@mastra/code-sdk/providers/amazon-bedrock-gateway";
|
|
19
21
|
import { GOOGLE_VERTEX_GATEWAY_ID } from "@mastra/code-sdk/providers/google-vertex-gateway";
|
|
20
|
-
import { MastraGateway, getModelReasoningOptions } from "@mastra/core/llm";
|
|
22
|
+
import { MastraGateway, PROVIDER_REGISTRY, getModelReasoningOptions } from "@mastra/core/llm";
|
|
21
23
|
// src/routes/config.ts
|
|
22
24
|
/**
|
|
25
|
+
* Whether a custom provider may not take `providerId`, because it already
|
|
26
|
+
* means something to model resolution or to the provider pickers: a provider
|
|
27
|
+
* Factory ships with (even if its catalog failed to load or this server does
|
|
28
|
+
* not enable it), the id its
|
|
29
|
+
* credentials are saved under, an older id rewritten before lookup, or a
|
|
30
|
+
* gateway's own namespace. A custom provider there would be shadowed,
|
|
31
|
+
* rerouted, or shown to others as that provider.
|
|
32
|
+
*/
|
|
33
|
+
async function isReservedProviderId(controller, providerId) {
|
|
34
|
+
if (normalizeLegacyProviderId(providerId) !== providerId) return true;
|
|
35
|
+
const catalog = await controller.listAvailableModels();
|
|
36
|
+
return [
|
|
37
|
+
MASTRA_GATEWAY_CATALOG_PROVIDER,
|
|
38
|
+
MASTRA_GATEWAY_PROVIDER,
|
|
39
|
+
MASTRACODE_GATEWAY_ID,
|
|
40
|
+
AMAZON_BEDROCK_GATEWAY_ID,
|
|
41
|
+
GOOGLE_VERTEX_GATEWAY_ID,
|
|
42
|
+
...Object.keys(WEB_OAUTH_PROVIDERS),
|
|
43
|
+
...Object.keys(PROVIDER_REGISTRY),
|
|
44
|
+
...catalog.map((model) => model.provider)
|
|
45
|
+
].some((id) => id === providerId || getAuthProviderId(id) === providerId);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
23
48
|
* The controller's model catalog, plus the Mastra Gateway's models for tenant
|
|
24
49
|
* callers. The boot-time catalog lists `mastra/...` models only when the server
|
|
25
50
|
* itself has a gateway key; tenants bring their own (connected in one click).
|
|
@@ -59,6 +84,7 @@ async function listProviders({ controller, authStorage, tenantCredentials, deplo
|
|
|
59
84
|
continue;
|
|
60
85
|
}
|
|
61
86
|
const authProviderId = getAuthProviderId(model.provider);
|
|
87
|
+
const serverGatewayKey = model.provider === "mastra" && Boolean(MastraCodeGateway.getMastraGatewayApiKey());
|
|
62
88
|
let source = "none";
|
|
63
89
|
let orgKey;
|
|
64
90
|
let userCredential;
|
|
@@ -77,6 +103,7 @@ async function listProviders({ controller, authStorage, tenantCredentials, deplo
|
|
|
77
103
|
else if (userRec?.credential.type === "api_key") source = "stored-user";
|
|
78
104
|
else if (orgRec?.credential.type === "oauth") source = "oauth-org";
|
|
79
105
|
else if (orgRec?.credential.type === "api_key") source = "stored-org";
|
|
106
|
+
else if (serverGatewayKey) source = "deployment";
|
|
80
107
|
} else if (authStorage?.isLoggedIn(authProviderId)) source = "oauth";
|
|
81
108
|
else if (authStorage?.hasStoredApiKey(model.provider)) source = "stored";
|
|
82
109
|
else if (model.apiKeyEnvVar && process.env[model.apiKeyEnvVar]) source = "env";
|
|
@@ -95,31 +122,49 @@ async function listProviders({ controller, authStorage, tenantCredentials, deplo
|
|
|
95
122
|
supported: true,
|
|
96
123
|
modes: [flowKind]
|
|
97
124
|
} } : {},
|
|
98
|
-
...tenantCredentials && connectWithMastraAccount && model.provider === "mastra" ? { connectWithMastraAccount: true } : {}
|
|
125
|
+
...tenantCredentials && connectWithMastraAccount && model.provider === "mastra" && !serverGatewayKey ? { connectWithMastraAccount: true } : {},
|
|
126
|
+
...tenantCredentials && serverGatewayKey ? { serverKey: true } : {}
|
|
99
127
|
});
|
|
100
128
|
}
|
|
101
129
|
if (listCustomProviders) try {
|
|
102
|
-
for (const record of await listCustomProviders()) {
|
|
103
|
-
|
|
104
|
-
|
|
130
|
+
for (const { record, scope } of await listCustomProviders()) {
|
|
131
|
+
const listed = seen.get(record.providerId);
|
|
132
|
+
if (listed && !listed.custom) continue;
|
|
133
|
+
seen.delete(`${MASTRACODE_GATEWAY_ID}/${record.providerId}`);
|
|
134
|
+
const info = listed ?? {
|
|
105
135
|
provider: record.providerId,
|
|
106
|
-
source:
|
|
136
|
+
source: "none",
|
|
107
137
|
custom: true
|
|
108
|
-
}
|
|
138
|
+
};
|
|
139
|
+
if (!tenantCredentials) info.source = "stored";
|
|
140
|
+
else if (scope === "user") {
|
|
141
|
+
info.userCredential = "api_key";
|
|
142
|
+
info.source = "stored-user";
|
|
143
|
+
} else {
|
|
144
|
+
info.orgCredential = "api_key";
|
|
145
|
+
info.orgKey = true;
|
|
146
|
+
if (info.source === "none") info.source = "stored-org";
|
|
147
|
+
}
|
|
148
|
+
seen.set(record.providerId, info);
|
|
109
149
|
}
|
|
110
150
|
} catch {}
|
|
111
151
|
return Array.from(seen.values()).sort((a, b) => a.provider.localeCompare(b.provider));
|
|
112
152
|
}
|
|
113
153
|
/** Redact a stored custom-provider row for the client (key presence only). */
|
|
114
|
-
function toCustomProviderInfo(record) {
|
|
154
|
+
function toCustomProviderInfo({ record, scope }) {
|
|
115
155
|
return {
|
|
116
156
|
id: record.providerId,
|
|
117
157
|
name: record.name,
|
|
118
158
|
url: record.url,
|
|
119
159
|
hasApiKey: Boolean(record.apiKey),
|
|
120
|
-
models: record.models
|
|
160
|
+
models: record.models,
|
|
161
|
+
scope,
|
|
162
|
+
urlProblem: customEndpointUrlProblem(record.url)
|
|
121
163
|
};
|
|
122
164
|
}
|
|
165
|
+
function isCallable(record) {
|
|
166
|
+
return !customEndpointUrlProblem(record.url);
|
|
167
|
+
}
|
|
123
168
|
/**
|
|
124
169
|
* Resolve the custom-providers context for a request, or a ready-to-return
|
|
125
170
|
* error response. Same posture as memory settings: tenant rows in deployed
|
|
@@ -128,17 +173,21 @@ function toCustomProviderInfo(record) {
|
|
|
128
173
|
async function resolveCustomProvidersContext({ c, auth, customProviders }) {
|
|
129
174
|
await auth.ensureUser(c);
|
|
130
175
|
const tenant = auth.tenant(c);
|
|
131
|
-
|
|
176
|
+
const listAt = (scope) => customProviderOwner(tenant && {
|
|
177
|
+
...tenant,
|
|
178
|
+
credentialScope: runScopeFor(scope)
|
|
179
|
+
}, auth.enabled());
|
|
180
|
+
const user = listAt("user");
|
|
181
|
+
if (!user) return { response: c.json({ error: "unauthorized" }, 401) };
|
|
132
182
|
if (customProviders) try {
|
|
133
183
|
await customProviders.ensureReady();
|
|
134
|
-
return
|
|
184
|
+
return {
|
|
135
185
|
storage: customProviders,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
userId: "local"
|
|
186
|
+
userId: tenant?.userId ?? "local",
|
|
187
|
+
lists: auth.enabled() ? {
|
|
188
|
+
user,
|
|
189
|
+
org: listAt("org")
|
|
190
|
+
} : { user }
|
|
142
191
|
};
|
|
143
192
|
} catch {}
|
|
144
193
|
return { response: c.json({
|
|
@@ -146,10 +195,38 @@ async function resolveCustomProvidersContext({ c, auth, customProviders }) {
|
|
|
146
195
|
message: "Custom provider storage is unavailable — the app database is not configured or failed to start."
|
|
147
196
|
}, 503) };
|
|
148
197
|
}
|
|
149
|
-
/**
|
|
198
|
+
/** Every custom provider the caller can reach in Settings, with the scope each is saved at. */
|
|
199
|
+
async function listScopedCustomProviders(ctx) {
|
|
200
|
+
const [user, org] = await Promise.all([ctx.storage.list(ctx.lists.user), ctx.lists.org ? ctx.storage.list(ctx.lists.org) : []]);
|
|
201
|
+
return [...user.map((record) => ({
|
|
202
|
+
record,
|
|
203
|
+
scope: "user"
|
|
204
|
+
})), ...org.map((record) => ({
|
|
205
|
+
record,
|
|
206
|
+
scope: "org"
|
|
207
|
+
}))];
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* The custom providers model resolution uses for `tenant`, so a catalog never
|
|
211
|
+
* offers a model its session cannot run. Without a tenant the route applies no
|
|
212
|
+
* credential scope, and every list the caller can reach counts — the same rule
|
|
213
|
+
* those routes apply to saved keys.
|
|
214
|
+
*/
|
|
215
|
+
async function listCustomProvidersInEffect({ c, auth, customProviders, tenant }) {
|
|
216
|
+
const ctx = await resolveCustomProvidersContext({
|
|
217
|
+
c,
|
|
218
|
+
auth,
|
|
219
|
+
customProviders
|
|
220
|
+
});
|
|
221
|
+
if ("response" in ctx) return [];
|
|
222
|
+
if (!tenant) return (await listScopedCustomProviders(ctx)).map(({ record }) => record).filter(isCallable);
|
|
223
|
+
const owner = customProviderOwner(tenant, auth.enabled());
|
|
224
|
+
return owner ? (await ctx.storage.list(owner)).filter(isCallable) : [];
|
|
225
|
+
}
|
|
226
|
+
/** Validate + coerce a request body into a custom-provider save. */
|
|
150
227
|
function parseCustomProviderBody(body) {
|
|
151
228
|
if (!body || typeof body !== "object") return { error: "Invalid JSON body" };
|
|
152
|
-
const b = body;
|
|
229
|
+
const b = { ...body };
|
|
153
230
|
const name = typeof b.name === "string" ? b.name.trim() : "";
|
|
154
231
|
if (!name) return { error: "Missing required field: name" };
|
|
155
232
|
const url = typeof b.url === "string" ? b.url.trim() : "";
|
|
@@ -164,9 +241,29 @@ function parseCustomProviderBody(body) {
|
|
|
164
241
|
name,
|
|
165
242
|
url,
|
|
166
243
|
apiKey: typeof b.apiKey === "string" && b.apiKey.trim() ? b.apiKey.trim() : void 0,
|
|
167
|
-
models: Array.isArray(b.models) ? b.models.filter((m) => typeof m === "string" && m.trim().length > 0).map((m) => m.trim()) : []
|
|
244
|
+
models: Array.isArray(b.models) ? b.models.filter((m) => typeof m === "string" && m.trim().length > 0).map((m) => m.trim()) : [],
|
|
245
|
+
previousId: typeof b.previousId === "string" && b.previousId ? b.previousId : void 0,
|
|
246
|
+
scope: b.scope === "org" ? "org" : "user"
|
|
168
247
|
};
|
|
169
248
|
}
|
|
249
|
+
/** What each storage refusal tells the client. */
|
|
250
|
+
const CUSTOM_PROVIDER_REFUSALS = {
|
|
251
|
+
name_taken: {
|
|
252
|
+
status: 409,
|
|
253
|
+
error: "provider_name_taken",
|
|
254
|
+
message: "A provider with this name already exists here. Choose another name."
|
|
255
|
+
},
|
|
256
|
+
not_found: {
|
|
257
|
+
status: 404,
|
|
258
|
+
error: "custom_provider_not_found",
|
|
259
|
+
message: "This provider no longer exists."
|
|
260
|
+
},
|
|
261
|
+
api_key_required: {
|
|
262
|
+
status: 400,
|
|
263
|
+
error: "api_key_required",
|
|
264
|
+
message: "Enter the API key again: the saved key is only kept while the URL stays on the same host."
|
|
265
|
+
}
|
|
266
|
+
};
|
|
170
267
|
/**
|
|
171
268
|
* Providers whose credentials can only come from the server process. Amazon
|
|
172
269
|
* Bedrock uses the AWS credential chain, while Google Vertex uses Application
|
|
@@ -269,18 +366,20 @@ async function buildModelCatalog({ controller, authStorage, tenantCredentials, d
|
|
|
269
366
|
}] : []);
|
|
270
367
|
if (listCustomProviders) try {
|
|
271
368
|
const known = new Set(catalog.map((m) => m.id));
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
369
|
+
for (const record of await listCustomProviders()) {
|
|
370
|
+
const credentialHolder = record.userId === null ? "organization" : "personal";
|
|
371
|
+
for (const model of record.models) {
|
|
372
|
+
const id = `${record.providerId}/${model}`;
|
|
373
|
+
if (known.has(id)) continue;
|
|
374
|
+
known.add(id);
|
|
375
|
+
catalog.push({
|
|
376
|
+
id,
|
|
377
|
+
provider: record.providerId,
|
|
378
|
+
modelName: model,
|
|
379
|
+
hasApiKey: true,
|
|
380
|
+
...tenantCredentials ? { credentialHolder } : {}
|
|
381
|
+
});
|
|
382
|
+
}
|
|
284
383
|
}
|
|
285
384
|
} catch {}
|
|
286
385
|
return catalog.sort((a, b) => a.provider === b.provider ? a.id.localeCompare(b.id) : a.provider.localeCompare(b.provider));
|
|
@@ -290,8 +389,8 @@ async function buildModelCatalog({ controller, authStorage, tenantCredentials, d
|
|
|
290
389
|
* rows) for Factory-scoped sessions, the session owner's for user-scoped ones.
|
|
291
390
|
*/
|
|
292
391
|
async function listSessionScopedCredentials({ credentials, orgId, userId, modelScope }) {
|
|
293
|
-
const
|
|
294
|
-
return (await credentials.listCredentials(orgId, userId)).filter((record) => record.scope ===
|
|
392
|
+
const storedScope = storedScopeFor(modelScope);
|
|
393
|
+
return (await credentials.listCredentials(orgId, userId)).filter((record) => record.scope === storedScope);
|
|
295
394
|
}
|
|
296
395
|
/** Resolve the default-model context for a request, or a ready-to-return error response. */
|
|
297
396
|
async function resolveModelDefaultsContext({ c, auth, modelDefaults }) {
|
|
@@ -419,6 +518,29 @@ var ConfigRoutes = class extends Route {
|
|
|
419
518
|
});
|
|
420
519
|
const gatewayFailure = (c, error) => error instanceof MastraGatewayError ? c.json({ error: error.message }, error.status) : c.json({ error: error instanceof Error ? error.message : String(error) }, 500);
|
|
421
520
|
const onCustomProvidersChanged = options.onCustomProvidersChanged ?? (() => {});
|
|
521
|
+
const customProvidersChanged = (orgId) => {
|
|
522
|
+
onCustomProvidersChanged({ orgId });
|
|
523
|
+
controller.invalidateAvailableModelsCache?.();
|
|
524
|
+
};
|
|
525
|
+
/**
|
|
526
|
+
* The list a custom-provider write addresses. Changing the organization's
|
|
527
|
+
* list takes an admin, as org-wide keys do. No-auth mode has one list,
|
|
528
|
+
* whatever scope the request names.
|
|
529
|
+
*/
|
|
530
|
+
const resolveCustomProviderWrite = async (c, ctx, scope) => {
|
|
531
|
+
if (scope !== "org" || !ctx.lists.org) return {
|
|
532
|
+
owner: ctx.lists.user,
|
|
533
|
+
scope: "user"
|
|
534
|
+
};
|
|
535
|
+
if (!await auth.isOrganizationAdmin(c, ctx.lists.org.orgId)) return { response: c.json({
|
|
536
|
+
error: "organization_admin_required",
|
|
537
|
+
message: "Only organization admins can change org-wide providers."
|
|
538
|
+
}, 403) };
|
|
539
|
+
return {
|
|
540
|
+
owner: ctx.lists.org,
|
|
541
|
+
scope: "org"
|
|
542
|
+
};
|
|
543
|
+
};
|
|
422
544
|
const resolveSessionModelContext = async (c, address, includeDefaultModel = true) => {
|
|
423
545
|
const tenant = auth.tenant(c);
|
|
424
546
|
if (!tenant && auth.enabled()) return { response: c.json({ error: "unauthorized" }, 401) };
|
|
@@ -457,11 +579,17 @@ var ConfigRoutes = class extends Route {
|
|
|
457
579
|
defaultModelId = ownerDefaults?.modelId ?? null;
|
|
458
580
|
personalThinkingLevel = ownerDefaults?.thinkingLevel ?? null;
|
|
459
581
|
}
|
|
582
|
+
const credentialTenant = {
|
|
583
|
+
orgId,
|
|
584
|
+
userId: policy.tenant.userId,
|
|
585
|
+
credentialScope: modelScope
|
|
586
|
+
};
|
|
460
587
|
return {
|
|
461
588
|
tenantCredentials,
|
|
462
589
|
modelScope,
|
|
463
590
|
defaultModelId,
|
|
464
|
-
personalThinkingLevel
|
|
591
|
+
personalThinkingLevel,
|
|
592
|
+
credentialTenant
|
|
465
593
|
};
|
|
466
594
|
};
|
|
467
595
|
const resolveOMResponseContext = async (c, { sessionId, threadId, resourceId, factoryProjectId }) => {
|
|
@@ -471,6 +599,10 @@ var ConfigRoutes = class extends Route {
|
|
|
471
599
|
credentials: options.modelCredentials
|
|
472
600
|
});
|
|
473
601
|
const tenant = auth.tenant(c);
|
|
602
|
+
let customProviderTenant = tenant && {
|
|
603
|
+
...tenant,
|
|
604
|
+
credentialScope: "user"
|
|
605
|
+
};
|
|
474
606
|
if (sessionId !== void 0 && threadId !== void 0) {
|
|
475
607
|
const address = z.object({
|
|
476
608
|
sessionId: z.string().trim().min(1),
|
|
@@ -488,6 +620,7 @@ var ConfigRoutes = class extends Route {
|
|
|
488
620
|
const sessionContext = await resolveSessionModelContext(c, address.data, false);
|
|
489
621
|
if (sessionContext && "response" in sessionContext) return { response: sessionContext.response };
|
|
490
622
|
tenantCredentials = sessionContext?.tenantCredentials;
|
|
623
|
+
customProviderTenant = sessionContext?.credentialTenant;
|
|
491
624
|
} else if (threadId !== void 0) return { response: c.json({ error: "invalid_session_context" }, 400) };
|
|
492
625
|
else if (tenantCredentials && factoryProjectId && tenant) {
|
|
493
626
|
if (!options.factoryProjects) return { response: c.json({ error: "factory_unavailable" }, 503) };
|
|
@@ -497,8 +630,12 @@ var ConfigRoutes = class extends Route {
|
|
|
497
630
|
id: factoryProjectId
|
|
498
631
|
});
|
|
499
632
|
if (!project) return { response: c.json({ error: "factory_project_not_found" }, 404) };
|
|
500
|
-
const
|
|
501
|
-
tenantCredentials = tenantCredentials.filter((record) => record.scope ===
|
|
633
|
+
const credentialScope = effectiveModelScope(project.modelScope, "run");
|
|
634
|
+
tenantCredentials = tenantCredentials.filter((record) => record.scope === storedScopeFor(credentialScope));
|
|
635
|
+
customProviderTenant = {
|
|
636
|
+
...tenant,
|
|
637
|
+
credentialScope
|
|
638
|
+
};
|
|
502
639
|
} else if (tenantCredentials) tenantCredentials = tenantCredentials.filter((record) => record.scope === "user");
|
|
503
640
|
const access = await buildProviderAccess({
|
|
504
641
|
controller,
|
|
@@ -509,12 +646,13 @@ var ConfigRoutes = class extends Route {
|
|
|
509
646
|
const availableProviders = new Set(Object.entries(access).flatMap(([providerId, configured]) => configured ? [providerId] : []));
|
|
510
647
|
if (access["mastra"] || MastraCodeGateway.getMastraGatewayApiKey()) availableProviders.add(MASTRA_GATEWAY_PROVIDER);
|
|
511
648
|
if (options.customProviders) {
|
|
512
|
-
const
|
|
649
|
+
const customProviders = await listCustomProvidersInEffect({
|
|
513
650
|
c: loose(c),
|
|
514
651
|
auth,
|
|
515
|
-
customProviders: options.customProviders
|
|
652
|
+
customProviders: options.customProviders,
|
|
653
|
+
tenant: customProviderTenant
|
|
516
654
|
});
|
|
517
|
-
|
|
655
|
+
for (const provider of customProviders) availableProviders.add(provider.providerId);
|
|
518
656
|
}
|
|
519
657
|
return { availableProviders };
|
|
520
658
|
};
|
|
@@ -566,7 +704,8 @@ var ConfigRoutes = class extends Route {
|
|
|
566
704
|
auth,
|
|
567
705
|
customProviders
|
|
568
706
|
});
|
|
569
|
-
|
|
707
|
+
if ("response" in ctx) return [];
|
|
708
|
+
return (await listScopedCustomProviders(ctx)).filter(({ record }) => isCallable(record));
|
|
570
709
|
} : void 0;
|
|
571
710
|
return c.json({
|
|
572
711
|
providers: await listProviders({
|
|
@@ -668,7 +807,7 @@ var ConfigRoutes = class extends Route {
|
|
|
668
807
|
userId: ctx.userId
|
|
669
808
|
};
|
|
670
809
|
try {
|
|
671
|
-
if (!await ctx.storage.getCredential(tenant, MASTRA_GATEWAY_PROVIDER)) {
|
|
810
|
+
if (!Boolean(MastraCodeGateway.getMastraGatewayApiKey()) && !await ctx.storage.getCredential(tenant, MASTRA_GATEWAY_PROVIDER)) {
|
|
672
811
|
const apiKey = await createGatewayKey(auth, loose(c), ctx.orgId, scope);
|
|
673
812
|
await ctx.storage.setCredential(tenant, MASTRA_GATEWAY_PROVIDER, {
|
|
674
813
|
type: "api_key",
|
|
@@ -758,8 +897,7 @@ var ConfigRoutes = class extends Route {
|
|
|
758
897
|
});
|
|
759
898
|
if ("response" in ctx) return ctx.response;
|
|
760
899
|
try {
|
|
761
|
-
|
|
762
|
-
return c.json({ providers: records.map(toCustomProviderInfo) });
|
|
900
|
+
return c.json({ providers: (await listScopedCustomProviders(ctx)).map(toCustomProviderInfo) });
|
|
763
901
|
} catch (error) {
|
|
764
902
|
return c.json({ error: error instanceof Error ? error.message : String(error) }, 500);
|
|
765
903
|
}
|
|
@@ -783,24 +921,48 @@ var ConfigRoutes = class extends Route {
|
|
|
783
921
|
}
|
|
784
922
|
const parsed = parseCustomProviderBody(body);
|
|
785
923
|
if ("error" in parsed) return c.json({ error: parsed.error }, 400);
|
|
786
|
-
const
|
|
924
|
+
const urlProblem = customEndpointUrlProblem(parsed.url);
|
|
925
|
+
if (urlProblem) return c.json({
|
|
926
|
+
error: "custom_endpoint_url_refused",
|
|
927
|
+
message: urlProblem
|
|
928
|
+
}, 400);
|
|
929
|
+
const target = await resolveCustomProviderWrite(loose(c), ctx, parsed.scope);
|
|
930
|
+
if ("response" in target) return target.response;
|
|
931
|
+
const input = {
|
|
932
|
+
providerId: getCustomProviderId(parsed.name),
|
|
933
|
+
name: parsed.name,
|
|
934
|
+
url: parsed.url,
|
|
935
|
+
apiKey: parsed.apiKey,
|
|
936
|
+
models: parsed.models
|
|
937
|
+
};
|
|
787
938
|
try {
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
939
|
+
if (auth.enabled() && await isReservedProviderId(controller, input.providerId)) return c.json({
|
|
940
|
+
error: "provider_name_taken",
|
|
941
|
+
message: `"${parsed.name}" is reserved for a built-in provider. Choose another name.`
|
|
942
|
+
}, 409);
|
|
943
|
+
const write = parsed.previousId ? await ctx.storage.update({
|
|
944
|
+
owner: target.owner,
|
|
945
|
+
providerId: parsed.previousId,
|
|
946
|
+
input
|
|
947
|
+
}) : await ctx.storage.create({
|
|
948
|
+
owner: target.owner,
|
|
949
|
+
createdBy: ctx.userId,
|
|
950
|
+
input
|
|
799
951
|
});
|
|
800
|
-
|
|
952
|
+
if ("refused" in write) {
|
|
953
|
+
const { status, error, message } = CUSTOM_PROVIDER_REFUSALS[write.refused];
|
|
954
|
+
return c.json({
|
|
955
|
+
error,
|
|
956
|
+
message
|
|
957
|
+
}, status);
|
|
958
|
+
}
|
|
959
|
+
customProvidersChanged(target.owner.orgId);
|
|
801
960
|
return c.json({
|
|
802
961
|
ok: true,
|
|
803
|
-
provider: toCustomProviderInfo(
|
|
962
|
+
provider: toCustomProviderInfo({
|
|
963
|
+
record: write.saved,
|
|
964
|
+
scope: target.scope
|
|
965
|
+
})
|
|
804
966
|
});
|
|
805
967
|
} catch (error) {
|
|
806
968
|
return c.json({ error: error instanceof Error ? error.message : String(error) }, 500);
|
|
@@ -818,12 +980,20 @@ var ConfigRoutes = class extends Route {
|
|
|
818
980
|
});
|
|
819
981
|
if ("response" in ctx) return ctx.response;
|
|
820
982
|
const id = c.req.param("id");
|
|
983
|
+
const target = await resolveCustomProviderWrite(loose(c), ctx, c.req.query("scope"));
|
|
984
|
+
if ("response" in target) return target.response;
|
|
821
985
|
try {
|
|
822
|
-
await ctx.storage.delete({
|
|
823
|
-
|
|
986
|
+
if (!await ctx.storage.delete({
|
|
987
|
+
owner: target.owner,
|
|
824
988
|
providerId: id
|
|
825
|
-
})
|
|
826
|
-
|
|
989
|
+
})) {
|
|
990
|
+
const { status, error, message } = CUSTOM_PROVIDER_REFUSALS.not_found;
|
|
991
|
+
return c.json({
|
|
992
|
+
error,
|
|
993
|
+
message
|
|
994
|
+
}, status);
|
|
995
|
+
}
|
|
996
|
+
customProvidersChanged(target.owner.orgId);
|
|
827
997
|
return c.json({ ok: true });
|
|
828
998
|
} catch (error) {
|
|
829
999
|
return c.json({ error: error instanceof Error ? error.message : String(error) }, 500);
|
|
@@ -845,6 +1015,7 @@ var ConfigRoutes = class extends Route {
|
|
|
845
1015
|
let tenantCredentials = allTenantCredentials;
|
|
846
1016
|
let sessionPolicy;
|
|
847
1017
|
let credentialTenant;
|
|
1018
|
+
let sessionTenant;
|
|
848
1019
|
const resourceId = c.req.query("resourceId");
|
|
849
1020
|
const threadId = c.req.query("threadId");
|
|
850
1021
|
const sessionId = c.req.query("sessionId");
|
|
@@ -866,6 +1037,7 @@ var ConfigRoutes = class extends Route {
|
|
|
866
1037
|
if (context && "response" in context) return context.response;
|
|
867
1038
|
if (context) {
|
|
868
1039
|
tenantCredentials = context.tenantCredentials;
|
|
1040
|
+
sessionTenant = context.credentialTenant;
|
|
869
1041
|
sessionPolicy = {
|
|
870
1042
|
modelScope: context.modelScope,
|
|
871
1043
|
defaultModelId: context.defaultModelId,
|
|
@@ -879,7 +1051,7 @@ var ConfigRoutes = class extends Route {
|
|
|
879
1051
|
if (tenant) credentialTenant = {
|
|
880
1052
|
orgId: tenantOrgId(tenant),
|
|
881
1053
|
userId: tenant.userId,
|
|
882
|
-
credentialScope: scope.data
|
|
1054
|
+
credentialScope: runScopeFor(scope.data)
|
|
883
1055
|
};
|
|
884
1056
|
} else if (allTenantCredentials && factoryProjectId && tenant) {
|
|
885
1057
|
if (!options.factoryProjects) return c.json({ error: "factory_unavailable" }, 503);
|
|
@@ -889,12 +1061,12 @@ var ConfigRoutes = class extends Route {
|
|
|
889
1061
|
id: factoryProjectId
|
|
890
1062
|
});
|
|
891
1063
|
if (!project) return c.json({ error: "factory_project_not_found" }, 404);
|
|
892
|
-
const
|
|
893
|
-
tenantCredentials = allTenantCredentials.filter((record) => record.scope ===
|
|
1064
|
+
const storedScope = project.modelScope === "user" ? "user" : "org";
|
|
1065
|
+
tenantCredentials = allTenantCredentials.filter((record) => record.scope === storedScope);
|
|
894
1066
|
credentialTenant = {
|
|
895
1067
|
orgId: tenantOrgId(tenant),
|
|
896
1068
|
userId: tenant.userId,
|
|
897
|
-
credentialScope:
|
|
1069
|
+
credentialScope: runScopeFor(storedScope)
|
|
898
1070
|
};
|
|
899
1071
|
}
|
|
900
1072
|
const customProviders = options.customProviders;
|
|
@@ -903,14 +1075,12 @@ var ConfigRoutes = class extends Route {
|
|
|
903
1075
|
authStorage,
|
|
904
1076
|
tenantCredentials,
|
|
905
1077
|
deploymentProviders,
|
|
906
|
-
listCustomProviders: customProviders ?
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
return "response" in ctx ? [] : ctx.storage.list({ orgId: ctx.orgId });
|
|
913
|
-
} : void 0
|
|
1078
|
+
listCustomProviders: customProviders ? () => listCustomProvidersInEffect({
|
|
1079
|
+
c: loose(c),
|
|
1080
|
+
auth,
|
|
1081
|
+
customProviders,
|
|
1082
|
+
tenant: sessionTenant ?? credentialTenant
|
|
1083
|
+
}) : void 0
|
|
914
1084
|
});
|
|
915
1085
|
if (!credentialTenant) return c.json({
|
|
916
1086
|
...sessionPolicy,
|