@mastra/factory 0.28.0-alpha.0 → 0.28.0-alpha.2
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 +210 -42
- 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/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 +78 -14
- 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/factory.d.ts +63 -9
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +187 -22
- 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 +4 -3
- package/dist/integrations/base.d.ts +6 -0
- package/dist/integrations/base.d.ts.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/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 +2 -5
- 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 +77 -6
- package/dist/integrations/github/rules.js.map +1 -1
- 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/merge-request-reconciler.js +1 -1
- package/dist/integrations/gitlab/routes.d.ts.map +1 -1
- package/dist/integrations/gitlab/routes.js +1 -3
- 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 +69 -4
- package/dist/integrations/gitlab/rules.js.map +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/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 +35 -3
- 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/routes.d.ts.map +1 -1
- package/dist/integrations/jira/routes.js +1 -4
- 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 +35 -3
- 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/routes.d.ts.map +1 -1
- package/dist/integrations/linear/routes.js +1 -4
- 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 +35 -3
- 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/integration.d.ts.map +1 -1
- package/dist/integrations/platform/github/integration.js +1 -3
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/platform/jira/routes.d.ts.map +1 -1
- package/dist/integrations/platform/jira/routes.js +1 -4
- 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 +1 -3
- 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/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.map +1 -1
- package/dist/integrations/slack/integration.js +2 -0
- package/dist/integrations/slack/integration.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 +110 -43
- package/dist/integrations/slack/slack.js.map +1 -1
- 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/routes.js +1 -1
- package/dist/packages/_internals/workspace/dist/index.js +1 -1
- package/dist/routes/attention-activity.js +1 -1
- package/dist/routes/attention-providers.js +1 -1
- package/dist/routes/automation-runs.d.ts.map +1 -1
- package/dist/routes/automation-runs.js +1 -4
- 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 +3 -8
- package/dist/routes/config.js.map +1 -1
- package/dist/routes/contracts.d.ts +132 -0
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/contracts.js +77 -29
- package/dist/routes/contracts.js.map +1 -1
- package/dist/routes/fs.d.ts.map +1 -1
- package/dist/routes/fs.js +1 -4
- 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 +3 -5
- 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 +7 -4
- 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 +1 -4
- 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 +1 -3
- 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 +11 -1
- package/dist/routes/surface.js.map +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 +1 -4
- package/dist/routes/work-items.js.map +1 -1
- package/dist/rules/decision-applicability.js +1 -1
- package/dist/rules/dispatcher.d.ts +28 -0
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +391 -93
- 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/processor.js +1 -1
- package/dist/rules/processor.js.map +1 -1
- 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 +4 -2
- 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/session/credential-policy.d.ts +2 -2
- package/dist/session/credential-policy.d.ts.map +1 -1
- package/dist/session/credential-policy.js +3 -3
- 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/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/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 +1 -3
- 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/routes.d.ts.map +1 -1
- package/dist/storage/domains/comments/routes.js +1 -3
- 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/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 +31 -2
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +197 -44
- 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 +54 -4
- package/dist/storage/domains/work-items/cards.js.map +1 -1
- 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/read-tools.d.ts +2 -2
- package/dist/tools/read-tools.d.ts.map +1 -1
- package/dist/tools/read-tools.js +7 -6
- package/dist/tools/read-tools.js.map +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.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 +2 -2
- 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/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 +170 -62
- package/dist/work-items/split-migration.js.map +1 -1
- package/dist/workspace.js +2 -2
- package/package.json +12 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-credentials.d.ts","sourceRoot":"","sources":["../../src/routes/provider-credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAIpC,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;GAKG;AACH,OAAO,EAAE,uBAAuB,IAAI,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEpG;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,CAK1G,CAAC;AAEF,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,sBAIvG;AAED,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,uBAAu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C;AAOD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAE9E;AAED;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,EAC7C,CAAC,EACD,IAAI,EACJ,WAAW,GACZ,EAAE;IACD,CAAC,EAAE,OAAO,CAAC;IACX,IAAI,EAAE,SAAS,CAAC;IAChB,qEAAqE;IACrE,WAAW,CAAC,EAAE,uBAAuB,CAAC;CACvC,GAAG,OAAO,CAAC,iBAAiB,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC,CAuBtD;AAED;;;;;;GAMG;AACH,wBAAsB,+BAA+B,CAAC,EACpD,CAAC,EACD,IAAI,EACJ,WAAW,EACX,MAAM,GACP,EAAE;IACD,CAAC,EAAE,OAAO,CAAC;IACX,IAAI,EAAE,SAAS,CAAC;IAChB,qEAAqE;IACrE,WAAW,CAAC,EAAE,uBAAuB,CAAC;IACtC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,gBAAgB,EAAE,GAAG,SAAS,CAAC,CAO1C"}
|
|
@@ -37,9 +37,12 @@ function credentialLabel(provider, credentialType) {
|
|
|
37
37
|
*/
|
|
38
38
|
async function getTenantCredentialsStorage(credentials) {
|
|
39
39
|
if (!credentials) return void 0;
|
|
40
|
+
const failedAt = failedInitAt.get(credentials);
|
|
41
|
+
if (failedAt !== void 0 && Date.now() - failedAt < INIT_RETRY_MS) return void 0;
|
|
40
42
|
try {
|
|
41
43
|
await credentials.ensureReady();
|
|
42
44
|
} catch (error) {
|
|
45
|
+
failedInitAt.set(credentials, Date.now());
|
|
43
46
|
if (error !== lastReportedInitError) {
|
|
44
47
|
lastReportedInitError = error;
|
|
45
48
|
console.error("[factory] model credential storage is unavailable; providers will show as not set:", error);
|
|
@@ -49,6 +52,9 @@ async function getTenantCredentialsStorage(credentials) {
|
|
|
49
52
|
return credentials;
|
|
50
53
|
}
|
|
51
54
|
let lastReportedInitError;
|
|
55
|
+
/** Init is a full table scan and callers run per request and per model call, so a failure retries at most this often. */
|
|
56
|
+
const INIT_RETRY_MS = 15e3;
|
|
57
|
+
const failedInitAt = /* @__PURE__ */ new WeakMap();
|
|
52
58
|
/**
|
|
53
59
|
* Org key for tenant rows. Personal accounts get an org bootstrapped by the
|
|
54
60
|
* auth adapter (`ensureOrg`); if one still isn't present, scope rows under a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-credentials.js","names":[],"sources":["../../src/routes/provider-credentials.ts"],"sourcesContent":["/**\n * Per-request model-provider credential context.\n *\n * The provider config/OAuth routes serve two deployment shapes:\n *\n * - **Local** (no web auth adapter): credentials live in the server-global\n * file-backed `AuthStorage` (`auth.json`) — unchanged TUI behavior.\n * - **Tenant** (auth adapter active): credentials live in the\n * `model-credentials` factory storage domain, scoped per `(orgId, userId)`\n * with optional org-wide rows (`userId` absent).\n *\n * `resolveCredentialContext` decides which shape a request is in: an\n * authenticated user always gets the tenant path; an unauthenticated request\n * is rejected when auth is enabled and falls back to local otherwise.\n */\n\nimport type { Context } from 'hono';\n\nimport { factoryUserOrgId } from '../auth.js';\nimport { providerDisplayName } from '../provider-display-name.js';\nimport type {\n CredentialRecord,\n LoginSessionKind,\n ModelCredentialsStorage,\n} from '../storage/domains/credentials/base.js';\nimport type { RouteAuth } from './route.js';\n\n/**\n * OAuth credentials are stored under the credential id, which differs from the\n * catalog provider id for OpenAI (`openai-codex`) and Kimi (`kimi-for-coding`).\n * Tenant rows use the same keying so one lookup serves both OAuth tokens and\n * API keys, and match what model resolution reads.\n */\nexport { getCredentialProviderId as getAuthProviderId } from '@mastra/code-sdk/providers/model-ids';\n\n/**\n * Providers that support a browser-driven OAuth sign-in flow, keyed by\n * *catalog* provider id (what the routes and settings UI use). All flows need\n * no inbound connection to the server: Anthropic uses paste-code PKCE, the\n * rest use RFC 8628-style device codes. `subscription` names the plan the\n * sign-in bills, as shown under a reply and in the composer.\n */\nexport const WEB_OAUTH_PROVIDERS: Readonly<Record<string, { flow: LoginSessionKind; subscription: string }>> = {\n anthropic: { flow: 'paste-code', subscription: 'Claude Pro/Max' },\n openai: { flow: 'device-code', subscription: 'ChatGPT Plus/Pro' },\n 'github-copilot': { flow: 'device-code', subscription: 'GitHub Copilot' },\n xai: { flow: 'device-code', subscription: 'SuperGrok/X Premium+' },\n};\n\nexport function credentialLabel(provider: string, credentialType: CredentialRecord['credential']['type']) {\n return credentialType === 'api_key'\n ? `${providerDisplayName(provider)} API key`\n : WEB_OAUTH_PROVIDERS[provider]?.subscription;\n}\n\nexport type CredentialContext =\n | { mode: 'local' }\n | { mode: 'tenant'; storage: ModelCredentialsStorage; orgId: string; userId: string };\n\n/**\n * The tenant credentials domain, when registered and ready. `undefined` means\n * the factory never ran (no handle threaded in) or the domain's init failed\n * (fail-soft — callers report the feature unavailable instead of crashing).\n */\nexport async function getTenantCredentialsStorage(\n credentials: ModelCredentialsStorage | undefined,\n): Promise<ModelCredentialsStorage | undefined> {\n if (!credentials) return undefined;\n try {\n await credentials.ensureReady();\n } catch (error) {\n // Callers degrade to \"no credentials\", so this log is the only trace of why.\n if (error !== lastReportedInitError) {\n lastReportedInitError = error;\n console.error('[factory] model credential storage is unavailable; providers will show as not set:', error);\n }\n return undefined;\n }\n return credentials;\n}\n\nlet lastReportedInitError: unknown;\n\n/**\n * Org key for tenant rows. Personal accounts get an org bootstrapped by the\n * auth adapter (`ensureOrg`); if one still isn't present, scope rows under a\n * per-user synthetic org so credentials never become server-global.\n */\nexport function tenantOrgId(tenant: { orgId?: string; userId: string }): string {\n return tenant.orgId ?? factoryUserOrgId({ id: tenant.userId }) ?? `user:${tenant.userId}`;\n}\n\n/**\n * Resolve the credential context for a request, or a ready-to-return error\n * response. Mutating credential routes call this and hard-fail (401/503)\n * when the tenant path is required but unavailable.\n */\nexport async function resolveCredentialContext({\n c,\n auth,\n credentials,\n}: {\n c: Context;\n auth: RouteAuth;\n /** Tenant credential domain handle; absent in local (no-DB) mode. */\n credentials?: ModelCredentialsStorage;\n}): Promise<CredentialContext | { response: Response }> {\n await auth.ensureUser(c);\n const tenant = auth.tenant(c);\n if (!tenant) {\n // When an auth provider is active, credential operations always require a\n // signed-in caller — otherwise one anonymous request could write keys for\n // everyone. Without a provider this is a single-user local server.\n if (auth.enabled()) return { response: c.json({ error: 'unauthorized' }, 401) };\n return { mode: 'local' };\n }\n const storage = await getTenantCredentialsStorage(credentials);\n if (!storage) {\n return {\n response: c.json(\n {\n error: 'credentials_unavailable',\n message: 'Tenant credential storage is unavailable — the app database is not configured or failed to start.',\n },\n 503,\n ),\n };\n }\n return { mode: 'tenant', storage, orgId: tenantOrgId(tenant), userId: tenant.userId };\n}\n\n/**\n * List the caller's tenant credential records for provider listing, or\n * `undefined` in local mode (caller should fall back to `AuthStorage`).\n * Read-only and degradation-friendly: an authenticated caller with the domain\n * unavailable gets an empty list (sources show `env`/`none`) instead of a 503\n * so the settings page still renders.\n */\nexport async function listTenantCredentialsForRequest({\n c,\n auth,\n credentials,\n userId,\n}: {\n c: Context;\n auth: RouteAuth;\n /** Tenant credential domain handle; absent in local (no-DB) mode. */\n credentials?: ModelCredentialsStorage;\n /**\n * List another member's rows instead of the caller's — used when a preview\n * must mirror a run that authenticates as the addressed session's owner.\n */\n userId?: string;\n}): Promise<CredentialRecord[] | undefined> {\n await auth.ensureUser(c);\n const tenant = auth.tenant(c);\n if (!tenant) return auth.enabled() ? [] : undefined;\n const storage = await getTenantCredentialsStorage(credentials);\n if (!storage) return [];\n return storage.listCredentials(tenantOrgId(tenant), userId ?? tenant.userId);\n}\n"],"mappings":";;;;;;;;;;;AA0CA,MAAa,sBAAkG;CAC7G,WAAW;EAAE,MAAM;EAAc,cAAc;CAAiB;CAChE,QAAQ;EAAE,MAAM;EAAe,cAAc;CAAmB;CAChE,kBAAkB;EAAE,MAAM;EAAe,cAAc;CAAiB;CACxE,KAAK;EAAE,MAAM;EAAe,cAAc;CAAuB;AACnE;AAEA,SAAgB,gBAAgB,UAAkB,gBAAwD;CACxG,OAAO,mBAAmB,YACtB,GAAG,oBAAoB,QAAQ,EAAE,YACjC,oBAAoB,SAAS,EAAE;AACrC;;;;;;AAWA,eAAsB,4BACpB,aAC8C;CAC9C,IAAI,CAAC,aAAa,OAAO,KAAA;CACzB,IAAI;EACF,MAAM,YAAY,YAAY;CAChC,SAAS,OAAO;
|
|
1
|
+
{"version":3,"file":"provider-credentials.js","names":[],"sources":["../../src/routes/provider-credentials.ts"],"sourcesContent":["/**\n * Per-request model-provider credential context.\n *\n * The provider config/OAuth routes serve two deployment shapes:\n *\n * - **Local** (no web auth adapter): credentials live in the server-global\n * file-backed `AuthStorage` (`auth.json`) — unchanged TUI behavior.\n * - **Tenant** (auth adapter active): credentials live in the\n * `model-credentials` factory storage domain, scoped per `(orgId, userId)`\n * with optional org-wide rows (`userId` absent).\n *\n * `resolveCredentialContext` decides which shape a request is in: an\n * authenticated user always gets the tenant path; an unauthenticated request\n * is rejected when auth is enabled and falls back to local otherwise.\n */\n\nimport type { Context } from 'hono';\n\nimport { factoryUserOrgId } from '../auth.js';\nimport { providerDisplayName } from '../provider-display-name.js';\nimport type {\n CredentialRecord,\n LoginSessionKind,\n ModelCredentialsStorage,\n} from '../storage/domains/credentials/base.js';\nimport type { RouteAuth } from './route.js';\n\n/**\n * OAuth credentials are stored under the credential id, which differs from the\n * catalog provider id for OpenAI (`openai-codex`) and Kimi (`kimi-for-coding`).\n * Tenant rows use the same keying so one lookup serves both OAuth tokens and\n * API keys, and match what model resolution reads.\n */\nexport { getCredentialProviderId as getAuthProviderId } from '@mastra/code-sdk/providers/model-ids';\n\n/**\n * Providers that support a browser-driven OAuth sign-in flow, keyed by\n * *catalog* provider id (what the routes and settings UI use). All flows need\n * no inbound connection to the server: Anthropic uses paste-code PKCE, the\n * rest use RFC 8628-style device codes. `subscription` names the plan the\n * sign-in bills, as shown under a reply and in the composer.\n */\nexport const WEB_OAUTH_PROVIDERS: Readonly<Record<string, { flow: LoginSessionKind; subscription: string }>> = {\n anthropic: { flow: 'paste-code', subscription: 'Claude Pro/Max' },\n openai: { flow: 'device-code', subscription: 'ChatGPT Plus/Pro' },\n 'github-copilot': { flow: 'device-code', subscription: 'GitHub Copilot' },\n xai: { flow: 'device-code', subscription: 'SuperGrok/X Premium+' },\n};\n\nexport function credentialLabel(provider: string, credentialType: CredentialRecord['credential']['type']) {\n return credentialType === 'api_key'\n ? `${providerDisplayName(provider)} API key`\n : WEB_OAUTH_PROVIDERS[provider]?.subscription;\n}\n\nexport type CredentialContext =\n | { mode: 'local' }\n | { mode: 'tenant'; storage: ModelCredentialsStorage; orgId: string; userId: string };\n\n/**\n * The tenant credentials domain, when registered and ready. `undefined` means\n * the factory never ran (no handle threaded in) or the domain's init failed\n * (fail-soft — callers report the feature unavailable instead of crashing).\n */\nexport async function getTenantCredentialsStorage(\n credentials: ModelCredentialsStorage | undefined,\n): Promise<ModelCredentialsStorage | undefined> {\n if (!credentials) return undefined;\n const failedAt = failedInitAt.get(credentials);\n if (failedAt !== undefined && Date.now() - failedAt < INIT_RETRY_MS) return undefined;\n try {\n await credentials.ensureReady();\n } catch (error) {\n failedInitAt.set(credentials, Date.now());\n // Callers degrade to \"no credentials\", so this log is the only trace of why.\n if (error !== lastReportedInitError) {\n lastReportedInitError = error;\n console.error('[factory] model credential storage is unavailable; providers will show as not set:', error);\n }\n return undefined;\n }\n return credentials;\n}\n\nlet lastReportedInitError: unknown;\n/** Init is a full table scan and callers run per request and per model call, so a failure retries at most this often. */\nconst INIT_RETRY_MS = 15_000;\nconst failedInitAt = new WeakMap<ModelCredentialsStorage, number>();\n\n/**\n * Org key for tenant rows. Personal accounts get an org bootstrapped by the\n * auth adapter (`ensureOrg`); if one still isn't present, scope rows under a\n * per-user synthetic org so credentials never become server-global.\n */\nexport function tenantOrgId(tenant: { orgId?: string; userId: string }): string {\n return tenant.orgId ?? factoryUserOrgId({ id: tenant.userId }) ?? `user:${tenant.userId}`;\n}\n\n/**\n * Resolve the credential context for a request, or a ready-to-return error\n * response. Mutating credential routes call this and hard-fail (401/503)\n * when the tenant path is required but unavailable.\n */\nexport async function resolveCredentialContext({\n c,\n auth,\n credentials,\n}: {\n c: Context;\n auth: RouteAuth;\n /** Tenant credential domain handle; absent in local (no-DB) mode. */\n credentials?: ModelCredentialsStorage;\n}): Promise<CredentialContext | { response: Response }> {\n await auth.ensureUser(c);\n const tenant = auth.tenant(c);\n if (!tenant) {\n // When an auth provider is active, credential operations always require a\n // signed-in caller — otherwise one anonymous request could write keys for\n // everyone. Without a provider this is a single-user local server.\n if (auth.enabled()) return { response: c.json({ error: 'unauthorized' }, 401) };\n return { mode: 'local' };\n }\n const storage = await getTenantCredentialsStorage(credentials);\n if (!storage) {\n return {\n response: c.json(\n {\n error: 'credentials_unavailable',\n message: 'Tenant credential storage is unavailable — the app database is not configured or failed to start.',\n },\n 503,\n ),\n };\n }\n return { mode: 'tenant', storage, orgId: tenantOrgId(tenant), userId: tenant.userId };\n}\n\n/**\n * List the caller's tenant credential records for provider listing, or\n * `undefined` in local mode (caller should fall back to `AuthStorage`).\n * Read-only and degradation-friendly: an authenticated caller with the domain\n * unavailable gets an empty list (sources show `env`/`none`) instead of a 503\n * so the settings page still renders.\n */\nexport async function listTenantCredentialsForRequest({\n c,\n auth,\n credentials,\n userId,\n}: {\n c: Context;\n auth: RouteAuth;\n /** Tenant credential domain handle; absent in local (no-DB) mode. */\n credentials?: ModelCredentialsStorage;\n /**\n * List another member's rows instead of the caller's — used when a preview\n * must mirror a run that authenticates as the addressed session's owner.\n */\n userId?: string;\n}): Promise<CredentialRecord[] | undefined> {\n await auth.ensureUser(c);\n const tenant = auth.tenant(c);\n if (!tenant) return auth.enabled() ? [] : undefined;\n const storage = await getTenantCredentialsStorage(credentials);\n if (!storage) return [];\n return storage.listCredentials(tenantOrgId(tenant), userId ?? tenant.userId);\n}\n"],"m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AAW;CAC7D,IAAI,CAAC,SACH,OAAO,EACL,UAAU,EAAE,KACV;EACE,OAAO;EACP,SAAS;CACX,GACA,GACF,EACF;CAEF,OAAO;EAAE,MAAM;EAAU;EAAS,OAAO,YAAY,MAAM;EAAG,QAAQ,OAAO;CAAO;AACtF;;;;;;;;AASA,eAAsB,gCAAgC,EACpD,GACA,MACA,aACA,UAW0C;CAC1C,MAAM,KAAK,WAAW,CAAC;CACvB,MAAM,SAAS,KAAK,OAAO,CAAC;CAC5B,IAAI,CAAC,QAAQ,OAAO,KAAK,QAAQ,IAAI,CAAC,IAAI,KAAA;CAC1C,MAAM,UAAU,MAAM,4BAA4B,WAAW;CAC7D,IAAI,CAAC,SAAS,OAAO,CAAC;CACtB,OAAO,QAAQ,gBAAgB,YAAY,MAAM,GAAG,UAAU,OAAO,MAAM;AAC7E"}
|
package/dist/routes/route.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ export interface RouteAuth {
|
|
|
35
35
|
export interface RouteDependencies {
|
|
36
36
|
auth: RouteAuth;
|
|
37
37
|
}
|
|
38
|
+
/** A host's hono can differ from this package's, so a handler's `Context` only reaches route helpers through `unknown`. */
|
|
39
|
+
export declare function loose(c: unknown): Context;
|
|
38
40
|
/**
|
|
39
41
|
* A route module: constructed once at boot with its dependencies, then asked
|
|
40
42
|
* for the `ApiRoute[]` it serves.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../src/routes/route.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,wDAAwD;IACxD,OAAO,IAAI,OAAO,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,C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,CAAC;CAC3E;AAED,yDAAyD;AACzD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,2HAA2H;AAC3H,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAEzC;AAED;;;GAGG;AACH,8BAAsB,KAAK,CAAC,KAAK,SAAS,iBAAiB,GAAG,iBAAiB;IAC7E,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAE/B,YAAY,IAAI,EAAE,KAAK,EAEtB;IAED,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,IAAI,QAAQ,EAAE,CAAC;CAC/B"}
|
package/dist/routes/route.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
// src/routes/route.ts
|
|
2
|
+
/** A host's hono can differ from this package's, so a handler's `Context` only reaches route helpers through `unknown`. */
|
|
3
|
+
function loose(c) {
|
|
4
|
+
return c;
|
|
5
|
+
}
|
|
2
6
|
/**
|
|
3
7
|
* A route module: constructed once at boot with its dependencies, then asked
|
|
4
8
|
* for the `ApiRoute[]` it serves.
|
|
@@ -9,6 +13,6 @@ var Route = class {
|
|
|
9
13
|
this.deps = deps;
|
|
10
14
|
}
|
|
11
15
|
};
|
|
12
|
-
export { Route };
|
|
16
|
+
export { Route, loose };
|
|
13
17
|
|
|
14
18
|
//# sourceMappingURL=route.js.map
|
package/dist/routes/route.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.js","names":[],"sources":["../../src/routes/route.ts"],"sourcesContent":["/**\n * Base class for factory route modules.\n *\n * Route modules build Mastra `apiRoutes` from injected dependencies instead of\n * reaching into host globals. The host server (e.g. `mastracode/web`) supplies\n * the auth seam and storage domain handles at construction time, so the routes\n * stay portable and testable with fakes.\n */\n\nimport type { ApiRoute } from '@mastra/core/server';\nimport type { Context } from 'hono';\n\n/**\n * The auth surface factory routes need, implemented by the host server.\n *\n * Local (no-auth) deployments implement this with a stub where `enabled()`\n * returns `false` and `tenant()` returns `undefined` — routes then take their\n * single-user local paths.\n */\nexport interface RouteAuth {\n /** Whether an auth provider is active (tenant mode). */\n enabled(): boolean;\n /**\n * Resolve (and cache) the signed-in user for the request, if any. Must be\n * called before `tenant()` so the request context is populated.\n */\n ensureUser(c: Context): Promise<unknown>;\n /** Tenant identity for the request, when signed in. */\n tenant(c: Context): { orgId?: string; userId: string } | undefined;\n /** Fail-closed check that the caller administers the given organization. */\n isOrganizationAdmin(c: Context, organizationId: string): Promise<boolean>;\n}\n\n/** Dependencies shared by every factory route module. */\nexport interface RouteDependencies {\n auth: RouteAuth;\n}\n\n/**\n * A route module: constructed once at boot with its dependencies, then asked\n * for the `ApiRoute[]` it serves.\n */\nexport abstract class Route<TDeps extends RouteDependencies = RouteDependencies> {\n protected readonly deps: TDeps;\n\n constructor(deps: TDeps) {\n this.deps = deps;\n }\n\n /** Build the Mastra `apiRoutes` served by this module. */\n abstract routes(): ApiRoute[];\n}\n"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"route.js","names":[],"sources":["../../src/routes/route.ts"],"sourcesContent":["/**\n * Base class for factory route modules.\n *\n * Route modules build Mastra `apiRoutes` from injected dependencies instead of\n * reaching into host globals. The host server (e.g. `mastracode/web`) supplies\n * the auth seam and storage domain handles at construction time, so the routes\n * stay portable and testable with fakes.\n */\n\nimport type { ApiRoute } from '@mastra/core/server';\nimport type { Context } from 'hono';\n\n/**\n * The auth surface factory routes need, implemented by the host server.\n *\n * Local (no-auth) deployments implement this with a stub where `enabled()`\n * returns `false` and `tenant()` returns `undefined` — routes then take their\n * single-user local paths.\n */\nexport interface RouteAuth {\n /** Whether an auth provider is active (tenant mode). */\n enabled(): boolean;\n /**\n * Resolve (and cache) the signed-in user for the request, if any. Must be\n * called before `tenant()` so the request context is populated.\n */\n ensureUser(c: Context): Promise<unknown>;\n /** Tenant identity for the request, when signed in. */\n tenant(c: Context): { orgId?: string; userId: string } | undefined;\n /** Fail-closed check that the caller administers the given organization. */\n isOrganizationAdmin(c: Context, organizationId: string): Promise<boolean>;\n}\n\n/** Dependencies shared by every factory route module. */\nexport interface RouteDependencies {\n auth: RouteAuth;\n}\n\n/** A host's hono can differ from this package's, so a handler's `Context` only reaches route helpers through `unknown`. */\nexport function loose(c: unknown): Context {\n return c as Context;\n}\n\n/**\n * A route module: constructed once at boot with its dependencies, then asked\n * for the `ApiRoute[]` it serves.\n */\nexport abstract class Route<TDeps extends RouteDependencies = RouteDependencies> {\n protected readonly deps: TDeps;\n\n constructor(deps: TDeps) {\n this.deps = deps;\n }\n\n /** Build the Mastra `apiRoutes` served by this module. */\n abstract routes(): ApiRoute[];\n}\n"],"mappings":";;AAuCA,SAAgB,MAAM,GAAqB;CACzC,OAAO;AACT;;;;;AAMA,IAAsB,QAAtB,MAAiF;CAC/E;CAEA,YAAY,MAAa;EACvB,KAAK,OAAO;CACd;AAIF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../src/routes/skills.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAIpC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACxF,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AAE5F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY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O,EAAE,OAAO,EAAE,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAC;IACpH,8GAA8G;IAC9G,MAAM,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;IAChC,2GAA2G;IAC3G,SAAS,CAAC,EAAE;QACV,QAAQ,EAAE,IAAI,CAAC,sBAAsB,EAAE,aAAa,GAAG,KAAK,CAAC,CAAC;QAC9D,OAAO,EAAE,IAAI,CAAC,qBAAqB,EAAE,aAAa,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAAC;QAC3F,KAAK,EAAE,YAAY,CAAC;KACrB,CAAC;CACH;AA2BD,qBAAa,WAAY,SAAQ,KAAK,CAAC,eAAe,CAAC;;IAsErD,MAAM,IAAI,QAAQ,EAAE,CA2KnB;CACF"}
|
package/dist/routes/skills.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { hashSkillContent, listFactorySkills, readFactorySkillOriginals } from "../skills/catalog.js";
|
|
2
2
|
import { SkillInvocationError, formatSkillMessage, resolveSkillInvocation } from "../skills/service.js";
|
|
3
3
|
import { FACTORY_ROUTE_CONTRACTS, skillOverrideSaveRequestSchema } from "./contracts.js";
|
|
4
|
-
import { Route } from "./route.js";
|
|
4
|
+
import { Route, loose } from "./route.js";
|
|
5
5
|
import { registerApiRoute } from "@mastra/core/server";
|
|
6
6
|
// src/routes/skills.ts
|
|
7
7
|
const MAX_SESSION_ID_LENGTH = 512;
|
|
8
8
|
const MAX_ARGUMENTS_LENGTH = 16384;
|
|
9
9
|
const SKILL_NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
10
10
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
11
|
-
function loose(context) {
|
|
12
|
-
return context;
|
|
13
|
-
}
|
|
14
11
|
function parseBody(value) {
|
|
15
12
|
if (!value || typeof value !== "object") return void 0;
|
|
16
13
|
const input = value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skills.js","names":[],"sources":["../../src/routes/skills.ts"],"sourcesContent":["import type { MastraCodeState } from '@mastra/code-sdk/schema';\nimport type { AgentController } from '@mastra/core/agent-controller';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport type { ApiRoute } from '@mastra/core/server';\nimport { registerApiRoute } from '@mastra/core/server';\nimport type { InlineSkill } from '@mastra/core/skills';\nimport type { Context } from 'hono';\n\nimport { hashSkillContent, listFactorySkills, readFactorySkillOriginals } from '../skills/catalog.js';\nimport { formatSkillMessage, resolveSkillInvocation, SkillInvocationError } from '../skills/service.js';\nimport type { AuditEmitter } from '../storage/domains/audit/domain.js';\nimport type { FactoryProjectsStorage } from '../storage/domains/projects/base.js';\nimport type { SkillOverridesStorage } from '../storage/domains/skill-overrides/base.js';\nimport type { SourceControlStorageHandle } from '../storage/domains/source-control/base.js';\nimport { FACTORY_ROUTE_CONTRACTS, skillOverrideSaveRequestSchema } from './contracts.js';\nimport type { RouteDependencies } from './route.js';\nimport { Route } from './route.js';\n\nconst MAX_SESSION_ID_LENGTH = 512;\nconst MAX_ARGUMENTS_LENGTH = 16_384;\nconst SKILL_NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\nconst UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\ninterface SkillInvocationBody {\n sessionId: string;\n name: string;\n arguments?: string;\n}\n\ninterface SessionAuthorizationResult {\n allowed: boolean;\n status?: 400 | 401 | 403;\n code?: 'invalid_request' | 'unauthorized' | 'session_forbidden';\n message?: string;\n}\n\nexport interface SkillRoutesDeps extends RouteDependencies {\n controllerId: string;\n controller: Pick<AgentController<MastraCodeState>, 'getSession'>;\n sourceControlStorage?: SourceControlStorageHandle;\n ensureSourceControlReady?: () => Promise<void>;\n authorizeSessionAddress?: (context: Context, address: { sessionId: string }) => Promise<SessionAuthorizationResult>;\n /** App skills from `MastraFactory({ skills })`, listed in the catalog alongside folder and bundled skills. */\n skills?: readonly InlineSkill[];\n /** Per-project skill edits. Without it the catalog lists originals only and edit routes are not served. */\n overrides?: {\n projects: Pick<FactoryProjectsStorage, 'ensureReady' | 'get'>;\n storage: Pick<SkillOverridesStorage, 'ensureReady' | 'list' | 'get' | 'upsert' | 'delete'>;\n audit: AuditEmitter;\n };\n}\n\ntype ProjectAccess = { orgId: string; userId: string; projectId: string } | { response: Response };\n\nfunction loose(context: unknown): Context {\n return context as Context;\n}\n\nfunction parseBody(value: unknown): SkillInvocationBody | undefined {\n if (!value || typeof value !== 'object') return undefined;\n const input = value as Record<string, unknown>;\n if (typeof input.sessionId !== 'string' || input.sessionId.length === 0) return undefined;\n if (input.sessionId.length > MAX_SESSION_ID_LENGTH) return undefined;\n if (typeof input.name !== 'string' || input.name.length > 64 || !SKILL_NAME_RE.test(input.name)) return undefined;\n if (input.arguments !== undefined) {\n if (typeof input.arguments !== 'string' || input.arguments.length > MAX_ARGUMENTS_LENGTH) return undefined;\n }\n return {\n sessionId: input.sessionId,\n name: input.name,\n ...(input.arguments !== undefined ? { arguments: input.arguments } : {}),\n };\n}\n\nconst SESSION_FORBIDDEN: SessionAuthorizationResult = {\n allowed: false,\n status: 403,\n code: 'session_forbidden',\n message: 'Session access denied.',\n};\n\nexport class SkillRoutes extends Route<SkillRoutesDeps> {\n async #authorizeSessionAddress(\n context: Context,\n address: { sessionId: string },\n ): Promise<SessionAuthorizationResult> {\n const { auth, sourceControlStorage: storage, ensureSourceControlReady } = this.deps;\n if (!auth.enabled()) return { allowed: true };\n\n await auth.ensureUser(context);\n const tenant = auth.tenant(context);\n if (!tenant) {\n return { allowed: false, status: 401, code: 'unauthorized', message: 'Authentication required.' };\n }\n\n // Personal sessions created without a session id are addressed by the\n // authenticated WorkOS user id and need no app DB.\n if (address.sessionId === tenant.userId) return { allowed: true };\n\n // Factory sessions are addressed by their source-control session id.\n if (!UUID_RE.test(address.sessionId)) {\n return { allowed: false, status: 400, code: 'invalid_request', message: 'Invalid skill invocation request.' };\n }\n if (!tenant.orgId || !storage) return SESSION_FORBIDDEN;\n if (ensureSourceControlReady) {\n try {\n await ensureSourceControlReady();\n } catch {\n return SESSION_FORBIDDEN;\n }\n }\n const row = await storage.sessions.getBySessionId(address.sessionId);\n if (!row || row.orgId !== tenant.orgId || !row.projectRepositoryId) return SESSION_FORBIDDEN;\n // The session must be one the viewer can see under its repository.\n const visible = await storage.sessions.list({\n projectRepositoryId: row.projectRepositoryId,\n viewerUserId: tenant.userId,\n });\n return visible.some(session => session.sessionId === address.sessionId) ? { allowed: true } : SESSION_FORBIDDEN;\n }\n\n /** Resolves the signed-in tenant and a project of its organization, or the error response. */\n async #projectAccess(c: Context, projectId: string | undefined): Promise<ProjectAccess> {\n const { auth, overrides } = this.deps;\n await auth.ensureUser(c);\n const tenant = auth.tenant(c);\n if (!tenant) return { response: c.json({ error: 'unauthorized', message: 'Authentication required.' }, 401) };\n if (!tenant.orgId) {\n return {\n response: c.json({ error: 'organization_required', message: 'Factory projects require an organization.' }, 403),\n };\n }\n if (!overrides || !projectId) return { response: c.json({ error: 'Project not found' }, 404) };\n await overrides.projects.ensureReady();\n const project = await overrides.projects.get({ orgId: tenant.orgId, id: projectId });\n if (!project) return { response: c.json({ error: 'Project not found' }, 404) };\n return { orgId: tenant.orgId, userId: tenant.userId, projectId };\n }\n\n /** Org admins edit skills; with auth disabled the single local user does. */\n async #canEdit(c: Context, orgId: string): Promise<boolean> {\n const { auth } = this.deps;\n return !auth.enabled() || (await auth.isOrganizationAdmin(c, orgId));\n }\n\n async #catalogEntry(scope: { orgId: string; projectId: string }, name: string) {\n const { overrides, skills } = this.deps;\n const edits = overrides ? await overrides.storage.list(scope) : [];\n return (await listFactorySkills(skills, edits)).find(skill => skill.name === name);\n }\n\n routes(): ApiRoute[] {\n const { controllerId, controller, authorizeSessionAddress: customAuthorize } = this.deps;\n const authorize =\n customAuthorize ??\n ((context: Context, address: { sessionId: string }) => this.#authorizeSessionAddress(context, address));\n const handleSkillRequest = async (context: unknown, dispatch: boolean) => {\n const c = loose(context);\n if (c.req.param('controllerId') !== controllerId) {\n return c.json({ error: 'controller_not_found', message: 'Agent controller not found.' }, 404);\n }\n\n let rawBody: unknown;\n try {\n rawBody = await c.req.json();\n } catch {\n return c.json({ error: 'invalid_request', message: 'Invalid JSON body.' }, 400);\n }\n const body = parseBody(rawBody);\n if (!body) {\n return c.json({ error: 'invalid_request', message: 'Invalid skill invocation request.' }, 400);\n }\n\n const authorization = await authorize(c, { sessionId: body.sessionId });\n if (!authorization.allowed) {\n return c.json({ error: authorization.code, message: authorization.message }, authorization.status ?? 403);\n }\n\n try {\n const resolved = await resolveSkillInvocation(controller, body);\n const message = formatSkillMessage(resolved.skillName, resolved.contents);\n if (dispatch) {\n const requestContext = c.get('requestContext' as never) as RequestContext | undefined;\n void resolved.session\n .sendMessage({ content: message, ...(requestContext ? { requestContext } : {}) })\n .catch((error: unknown) => {\n console.error('Workspace skill dispatch failed after acceptance', error);\n });\n }\n return c.json({ ok: true, skill: resolved.skillName, message });\n } catch (error) {\n if (error instanceof SkillInvocationError) {\n return c.json({ error: error.code, message: error.message }, 404);\n }\n throw error;\n }\n };\n\n const handleFactorySkillsList = async (context: unknown) => {\n const c = loose(context);\n const { auth, overrides } = this.deps;\n const query = FACTORY_ROUTE_CONTRACTS.skillList.querySchema.safeParse(c.req.query());\n if (!query.success) return c.json({ error: 'invalid_request', message: 'Invalid project id.' }, 400);\n const { projectId } = query.data;\n if (projectId !== undefined) {\n const access = await this.#projectAccess(c, projectId);\n if ('response' in access) return access.response;\n await overrides!.storage.ensureReady();\n const edits = await overrides!.storage.list(access);\n return c.json({\n skills: await listFactorySkills(this.deps.skills, edits),\n canEdit: await this.#canEdit(c, access.orgId),\n });\n }\n if (auth.enabled()) {\n await auth.ensureUser(c);\n if (!auth.tenant(c)) {\n return c.json({ error: 'unauthorized', message: 'Authentication required.' }, 401);\n }\n }\n return c.json({ skills: await listFactorySkills(this.deps.skills) });\n };\n\n const handleSkillEdit = async (context: unknown, revert: boolean) => {\n const c = loose(context);\n const { overrides } = this.deps;\n const contract = revert ? FACTORY_ROUTE_CONTRACTS.skillOverrideRevert : FACTORY_ROUTE_CONTRACTS.skillOverrideSave;\n const path = contract.pathSchema.safeParse({ id: c.req.param('id'), name: c.req.param('name') });\n if (!path.success) return c.json({ error: 'not_found', message: 'Skill not found.' }, 404);\n const access = await this.#projectAccess(c, path.data.id);\n if ('response' in access) return access.response;\n if (!(await this.#canEdit(c, access.orgId))) {\n return c.json(\n { error: 'forbidden', message: 'Organization administrator access is required to edit skills.' },\n 403,\n );\n }\n const name = path.data.name;\n const original = (await readFactorySkillOriginals(this.deps.skills)).get(name);\n if (!original) return c.json({ error: 'not_found', message: `Skill \"${name}\" not found.` }, 404);\n const scope = { orgId: access.orgId, projectId: access.projectId, skillName: name };\n await overrides!.storage.ensureReady();\n\n if (revert) {\n if (await overrides!.storage.delete(scope)) {\n await overrides!.audit.emit({\n context: c,\n input: {\n action: 'factory.skill.reverted',\n targets: [{ type: 'skill', id: name }],\n factoryProjectId: access.projectId,\n },\n });\n }\n return c.json({ skill: await this.#catalogEntry(access, name) });\n }\n\n let body: unknown;\n try {\n body = await c.req.json();\n } catch {\n return c.json({ error: 'invalid_request', message: 'Invalid JSON body.' }, 400);\n }\n const request = skillOverrideSaveRequestSchema.safeParse({\n ...(body && typeof body === 'object' ? body : {}),\n ...path.data,\n });\n if (!request.success) {\n return c.json(\n { error: 'invalid_skill', message: request.error.issues.map(issue => issue.message).join('\\n') },\n 400,\n );\n }\n await overrides!.storage.upsert({\n ...scope,\n content: request.data.content,\n baseHash: hashSkillContent(original.raw),\n updatedBy: access.userId,\n });\n await overrides!.audit.emit({\n context: c,\n input: {\n action: 'factory.skill.updated',\n targets: [{ type: 'skill', id: name }],\n factoryProjectId: access.projectId,\n metadata: { origin: original.origin },\n },\n });\n return c.json({ skill: await this.#catalogEntry(access, name) });\n };\n\n return [\n registerApiRoute(FACTORY_ROUTE_CONTRACTS.skillList.path, {\n method: FACTORY_ROUTE_CONTRACTS.skillList.method,\n requiresAuth: false,\n handler: context => handleFactorySkillsList(context),\n }),\n ...(this.deps.overrides\n ? [\n registerApiRoute(FACTORY_ROUTE_CONTRACTS.skillOverrideSave.path, {\n method: FACTORY_ROUTE_CONTRACTS.skillOverrideSave.method,\n requiresAuth: false,\n handler: context => handleSkillEdit(context, false),\n }),\n registerApiRoute(FACTORY_ROUTE_CONTRACTS.skillOverrideRevert.path, {\n method: FACTORY_ROUTE_CONTRACTS.skillOverrideRevert.method,\n requiresAuth: false,\n handler: context => handleSkillEdit(context, true),\n }),\n ]\n : []),\n registerApiRoute('/web/agent-controller/:controllerId/skills/prepare', {\n method: 'POST',\n requiresAuth: false,\n handler: context => handleSkillRequest(context, false),\n }),\n registerApiRoute('/web/agent-controller/:controllerId/skills/invoke', {\n method: 'POST',\n requiresAuth: false,\n handler: context => handleSkillRequest(context, true),\n }),\n ];\n }\n}\n"],"mappings":";;;;;;AAkBA,MAAM,wBAAwB;AAC9B,MAAM,uBAAuB;AAC7B,MAAM,gBAAgB;AACtB,MAAM,UAAU;AAiChB,SAAS,MAAM,SAA2B;CACxC,OAAO;AACT;AAEA,SAAS,UAAU,OAAiD;CAClE,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO,KAAA;CAChD,MAAM,QAAQ;CACd,IAAI,OAAO,MAAM,cAAc,YAAY,MAAM,UAAU,WAAW,GAAG,OAAO,KAAA;CAChF,IAAI,MAAM,UAAU,SAAS,uBAAuB,OAAO,KAAA;CAC3D,IAAI,OAAO,MAAM,SAAS,YAAY,MAAM,KAAK,SAAS,MAAM,CAAC,cAAc,KAAK,MAAM,IAAI,GAAG,OAAO,KAAA;CACxG,IAAI,MAAM,cAAc,KAAA,GAClB;MAAA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AK;IACtB,UAAU,iBAAiB,SAAS,GAAG;IACvC,WAAW,OAAO;GACpB,CAAC;GACD,MAAM,UAAW,MAAM,KAAK;IAC1B,SAAS;IACT,OAAO;KACL,QAAQ;KACR,SAAS,CAAC;MAAE,MAAM;MAAS,IAAI;KAAK,CAAC;KACrC,kBAAkB,OAAO;KACzB,UAAU,EAAE,QAAQ,SAAS,OAAO;IACtC;GACF,CAAC;GACD,OAAO,EAAE,KAAK,EAAE,OAAO,MAAM,KAAK,cAAc,QAAQ,IAAI,EAAE,CAAC;EACjE;EAEA,OAAO;GACL,iBAAiB,wBAAwB,UAAU,MAAM;IACvD,QAAQ,wBAAwB,UAAU;IAC1C,cAAc;IACd,UAAS,YAAW,wBAAwB,OAAO;GACrD,CAAC;GACD,GAAI,KAAK,KAAK,YACV,CACE,iBAAiB,wBAAwB,kBAAkB,MAAM;IAC/D,QAAQ,wBAAwB,kBAAkB;IAClD,cAAc;IACd,UAAS,YAAW,gBAAgB,SAAS,KAAK;GACpD,CAAC,GACD,iBAAiB,wBAAwB,oBAAoB,MAAM;IACjE,QAAQ,wBAAwB,oBAAoB;IACpD,cAAc;IACd,UAAS,YAAW,gBAAgB,SAAS,IAAI;GACnD,CAAC,CACH,IACA,CAAC;GACL,iBAAiB,sDAAsD;IACrE,QAAQ;IACR,cAAc;IACd,UAAS,YAAW,mBAAmB,SAAS,KAAK;GACvD,CAAC;GACD,iBAAiB,qDAAqD;IACpE,QAAQ;IACR,cAAc;IACd,UAAS,YAAW,mBAAmB,SAAS,IAAI;GACtD,CAAC;EACH;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"skills.js","names":[],"sources":["../../src/routes/skills.ts"],"sourcesContent":["import type { MastraCodeState } from '@mastra/code-sdk/schema';\nimport type { AgentController } from '@mastra/core/agent-controller';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport type { ApiRoute } from '@mastra/core/server';\nimport { registerApiRoute } from '@mastra/core/server';\nimport type { InlineSkill } from '@mastra/core/skills';\nimport type { Context } from 'hono';\n\nimport { hashSkillContent, listFactorySkills, readFactorySkillOriginals } from '../skills/catalog.js';\nimport { formatSkillMessage, resolveSkillInvocation, SkillInvocationError } from '../skills/service.js';\nimport type { AuditEmitter } from '../storage/domains/audit/domain.js';\nimport type { FactoryProjectsStorage } from '../storage/domains/projects/base.js';\nimport type { SkillOverridesStorage } from '../storage/domains/skill-overrides/base.js';\nimport type { SourceControlStorageHandle } from '../storage/domains/source-control/base.js';\nimport { FACTORY_ROUTE_CONTRACTS, skillOverrideSaveRequestSchema } from './contracts.js';\nimport type { RouteDependencies } from './route.js';\nimport { loose, Route } from './route.js';\n\nconst MAX_SESSION_ID_LENGTH = 512;\nconst MAX_ARGUMENTS_LENGTH = 16_384;\nconst SKILL_NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\nconst UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\ninterface SkillInvocationBody {\n sessionId: string;\n name: string;\n arguments?: string;\n}\n\ninterface SessionAuthorizationResult {\n allowed: boolean;\n status?: 400 | 401 | 403;\n code?: 'invalid_request' | 'unauthorized' | 'session_forbidden';\n message?: string;\n}\n\nexport interface SkillRoutesDeps extends RouteDependencies {\n controllerId: string;\n controller: Pick<AgentController<MastraCodeState>, 'getSession'>;\n sourceControlStorage?: SourceControlStorageHandle;\n ensureSourceControlReady?: () => Promise<void>;\n authorizeSessionAddress?: (context: Context, address: { sessionId: string }) => Promise<SessionAuthorizationResult>;\n /** App skills from `MastraFactory({ skills })`, listed in the catalog alongside folder and bundled skills. */\n skills?: readonly InlineSkill[];\n /** Per-project skill edits. Without it the catalog lists originals only and edit routes are not served. */\n overrides?: {\n projects: Pick<FactoryProjectsStorage, 'ensureReady' | 'get'>;\n storage: Pick<SkillOverridesStorage, 'ensureReady' | 'list' | 'get' | 'upsert' | 'delete'>;\n audit: AuditEmitter;\n };\n}\n\ntype ProjectAccess = { orgId: string; userId: string; projectId: string } | { response: Response };\n\nfunction parseBody(value: unknown): SkillInvocationBody | undefined {\n if (!value || typeof value !== 'object') return undefined;\n const input = value as Record<string, unknown>;\n if (typeof input.sessionId !== 'string' || input.sessionId.length === 0) return undefined;\n if (input.sessionId.length > MAX_SESSION_ID_LENGTH) return undefined;\n if (typeof input.name !== 'string' || input.name.length > 64 || !SKILL_NAME_RE.test(input.name)) return undefined;\n if (input.arguments !== undefined) {\n if (typeof input.arguments !== 'string' || input.arguments.length > MAX_ARGUMENTS_LENGTH) return undefined;\n }\n return {\n sessionId: input.sessionId,\n name: input.name,\n ...(input.arguments !== undefined ? { arguments: input.arguments } : {}),\n };\n}\n\nconst SESSION_FORBIDDEN: SessionAuthorizationResult = {\n allowed: false,\n status: 403,\n code: 'session_forbidden',\n message: 'Session access denied.',\n};\n\nexport class SkillRoutes extends Route<SkillRoutesDeps> {\n async #authorizeSessionAddress(\n context: Context,\n address: { sessionId: string },\n ): Promise<SessionAuthorizationResult> {\n const { auth, sourceControlStorage: storage, ensureSourceControlReady } = this.deps;\n if (!auth.enabled()) return { allowed: true };\n\n await auth.ensureUser(context);\n const tenant = auth.tenant(context);\n if (!tenant) {\n return { allowed: false, status: 401, code: 'unauthorized', message: 'Authentication required.' };\n }\n\n // Personal sessions created without a session id are addressed by the\n // authenticated WorkOS user id and need no app DB.\n if (address.sessionId === tenant.userId) return { allowed: true };\n\n // Factory sessions are addressed by their source-control session id.\n if (!UUID_RE.test(address.sessionId)) {\n return { allowed: false, status: 400, code: 'invalid_request', message: 'Invalid skill invocation request.' };\n }\n if (!tenant.orgId || !storage) return SESSION_FORBIDDEN;\n if (ensureSourceControlReady) {\n try {\n await ensureSourceControlReady();\n } catch {\n return SESSION_FORBIDDEN;\n }\n }\n const row = await storage.sessions.getBySessionId(address.sessionId);\n if (!row || row.orgId !== tenant.orgId || !row.projectRepositoryId) return SESSION_FORBIDDEN;\n // The session must be one the viewer can see under its repository.\n const visible = await storage.sessions.list({\n projectRepositoryId: row.projectRepositoryId,\n viewerUserId: tenant.userId,\n });\n return visible.some(session => session.sessionId === address.sessionId) ? { allowed: true } : SESSION_FORBIDDEN;\n }\n\n /** Resolves the signed-in tenant and a project of its organization, or the error response. */\n async #projectAccess(c: Context, projectId: string | undefined): Promise<ProjectAccess> {\n const { auth, overrides } = this.deps;\n await auth.ensureUser(c);\n const tenant = auth.tenant(c);\n if (!tenant) return { response: c.json({ error: 'unauthorized', message: 'Authentication required.' }, 401) };\n if (!tenant.orgId) {\n return {\n response: c.json({ error: 'organization_required', message: 'Factory projects require an organization.' }, 403),\n };\n }\n if (!overrides || !projectId) return { response: c.json({ error: 'Project not found' }, 404) };\n await overrides.projects.ensureReady();\n const project = await overrides.projects.get({ orgId: tenant.orgId, id: projectId });\n if (!project) return { response: c.json({ error: 'Project not found' }, 404) };\n return { orgId: tenant.orgId, userId: tenant.userId, projectId };\n }\n\n /** Org admins edit skills; with auth disabled the single local user does. */\n async #canEdit(c: Context, orgId: string): Promise<boolean> {\n const { auth } = this.deps;\n return !auth.enabled() || (await auth.isOrganizationAdmin(c, orgId));\n }\n\n async #catalogEntry(scope: { orgId: string; projectId: string }, name: string) {\n const { overrides, skills } = this.deps;\n const edits = overrides ? await overrides.storage.list(scope) : [];\n return (await listFactorySkills(skills, edits)).find(skill => skill.name === name);\n }\n\n routes(): ApiRoute[] {\n const { controllerId, controller, authorizeSessionAddress: customAuthorize } = this.deps;\n const authorize =\n customAuthorize ??\n ((context: Context, address: { sessionId: string }) => this.#authorizeSessionAddress(context, address));\n const handleSkillRequest = async (context: unknown, dispatch: boolean) => {\n const c = loose(context);\n if (c.req.param('controllerId') !== controllerId) {\n return c.json({ error: 'controller_not_found', message: 'Agent controller not found.' }, 404);\n }\n\n let rawBody: unknown;\n try {\n rawBody = await c.req.json();\n } catch {\n return c.json({ error: 'invalid_request', message: 'Invalid JSON body.' }, 400);\n }\n const body = parseBody(rawBody);\n if (!body) {\n return c.json({ error: 'invalid_request', message: 'Invalid skill invocation request.' }, 400);\n }\n\n const authorization = await authorize(c, { sessionId: body.sessionId });\n if (!authorization.allowed) {\n return c.json({ error: authorization.code, message: authorization.message }, authorization.status ?? 403);\n }\n\n try {\n const resolved = await resolveSkillInvocation(controller, body);\n const message = formatSkillMessage(resolved.skillName, resolved.contents);\n if (dispatch) {\n const requestContext = c.get('requestContext' as never) as RequestContext | undefined;\n void resolved.session\n .sendMessage({ content: message, ...(requestContext ? { requestContext } : {}) })\n .catch((error: unknown) => {\n console.error('Workspace skill dispatch failed after acceptance', error);\n });\n }\n return c.json({ ok: true, skill: resolved.skillName, message });\n } catch (error) {\n if (error instanceof SkillInvocationError) {\n return c.json({ error: error.code, message: error.message }, 404);\n }\n throw error;\n }\n };\n\n const handleFactorySkillsList = async (context: unknown) => {\n const c = loose(context);\n const { auth, overrides } = this.deps;\n const query = FACTORY_ROUTE_CONTRACTS.skillList.querySchema.safeParse(c.req.query());\n if (!query.success) return c.json({ error: 'invalid_request', message: 'Invalid project id.' }, 400);\n const { projectId } = query.data;\n if (projectId !== undefined) {\n const access = await this.#projectAccess(c, projectId);\n if ('response' in access) return access.response;\n await overrides!.storage.ensureReady();\n const edits = await overrides!.storage.list(access);\n return c.json({\n skills: await listFactorySkills(this.deps.skills, edits),\n canEdit: await this.#canEdit(c, access.orgId),\n });\n }\n if (auth.enabled()) {\n await auth.ensureUser(c);\n if (!auth.tenant(c)) {\n return c.json({ error: 'unauthorized', message: 'Authentication required.' }, 401);\n }\n }\n return c.json({ skills: await listFactorySkills(this.deps.skills) });\n };\n\n const handleSkillEdit = async (context: unknown, revert: boolean) => {\n const c = loose(context);\n const { overrides } = this.deps;\n const contract = revert ? FACTORY_ROUTE_CONTRACTS.skillOverrideRevert : FACTORY_ROUTE_CONTRACTS.skillOverrideSave;\n const path = contract.pathSchema.safeParse({ id: c.req.param('id'), name: c.req.param('name') });\n if (!path.success) return c.json({ error: 'not_found', message: 'Skill not found.' }, 404);\n const access = await this.#projectAccess(c, path.data.id);\n if ('response' in access) return access.response;\n if (!(await this.#canEdit(c, access.orgId))) {\n return c.json(\n { error: 'forbidden', message: 'Organization administrator access is required to edit skills.' },\n 403,\n );\n }\n const name = path.data.name;\n const original = (await readFactorySkillOriginals(this.deps.skills)).get(name);\n if (!original) return c.json({ error: 'not_found', message: `Skill \"${name}\" not found.` }, 404);\n const scope = { orgId: access.orgId, projectId: access.projectId, skillName: name };\n await overrides!.storage.ensureReady();\n\n if (revert) {\n if (await overrides!.storage.delete(scope)) {\n await overrides!.audit.emit({\n context: c,\n input: {\n action: 'factory.skill.reverted',\n targets: [{ type: 'skill', id: name }],\n factoryProjectId: access.projectId,\n },\n });\n }\n return c.json({ skill: await this.#catalogEntry(access, name) });\n }\n\n let body: unknown;\n try {\n body = await c.req.json();\n } catch {\n return c.json({ error: 'invalid_request', message: 'Invalid JSON body.' }, 400);\n }\n const request = skillOverrideSaveRequestSchema.safeParse({\n ...(body && typeof body === 'object' ? body : {}),\n ...path.data,\n });\n if (!request.success) {\n return c.json(\n { error: 'invalid_skill', message: request.error.issues.map(issue => issue.message).join('\\n') },\n 400,\n );\n }\n await overrides!.storage.upsert({\n ...scope,\n content: request.data.content,\n baseHash: hashSkillContent(original.raw),\n updatedBy: access.userId,\n });\n await overrides!.audit.emit({\n context: c,\n input: {\n action: 'factory.skill.updated',\n targets: [{ type: 'skill', id: name }],\n factoryProjectId: access.projectId,\n metadata: { origin: original.origin },\n },\n });\n return c.json({ skill: await this.#catalogEntry(access, name) });\n };\n\n return [\n registerApiRoute(FACTORY_ROUTE_CONTRACTS.skillList.path, {\n method: FACTORY_ROUTE_CONTRACTS.skillList.method,\n requiresAuth: false,\n handler: context => handleFactorySkillsList(context),\n }),\n ...(this.deps.overrides\n ? [\n registerApiRoute(FACTORY_ROUTE_CONTRACTS.skillOverrideSave.path, {\n method: FACTORY_ROUTE_CONTRACTS.skillOverrideSave.method,\n requiresAuth: false,\n handler: context => handleSkillEdit(context, false),\n }),\n registerApiRoute(FACTORY_ROUTE_CONTRACTS.skillOverrideRevert.path, {\n method: FACTORY_ROUTE_CONTRACTS.skillOverrideRevert.method,\n requiresAuth: false,\n handler: context => handleSkillEdit(context, true),\n }),\n ]\n : []),\n registerApiRoute('/web/agent-controller/:controllerId/skills/prepare', {\n method: 'POST',\n requiresAuth: false,\n handler: context => handleSkillRequest(context, false),\n }),\n registerApiRoute('/web/agent-controller/:controllerId/skills/invoke', {\n method: 'POST',\n requiresAuth: false,\n handler: context => handleSkillRequest(context, true),\n }),\n ];\n }\n}\n"],"mappings":";;;;;;AAkBA,MAAM,wBAAwB;AAC9B,MAAM,uBAAuB;AAC7B,MAAM,gBAAgB;AACtB,MAAM,UAAU;AAiChB,SAAS,UAAU,OAAiD;CAClE,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO,KAAA;CAChD,MAAM,QAAQ;CACd,IAAI,OAAO,MAAM,cAAc,YAAY,MAAM,UAAU,WAAW,GAAG,OAAO,KAAA;CAChF,IAAI,MAAM,UAAU,SAAS,uBAAuB,OAAO,KAAA;CAC3D,IAAI,OAAO,MAAM,SAAS,YAAY,MAAM,KAAK,SAAS,MAAM,CAAC,cAAc,KAAK,MAAM,IAAI,GAAG,OAAO,KAAA;CACxG,IAAI,MAAM,cAAc,KAAA,GAClB;MAAA,OAAO,MAAM,cAAc,YAAY,MAAM,UAAU,SAAS,sBAAsB,OAAO,KAAA;CAAA;CAEnG,OAAO;EACL,WAAW,MAAM;EACjB,MAAM,MAAM;EACZ,GAAI,MAAM,cAAc,KAAA,IAAY,EAAE,WAAW,MAAM,UAAU,IAAI,CAAC;CACxE;AACF;AAEA,MAAM,oBAAgD;CACpD,SAAS;CACT,QAAQ;CACR,MAAM;CACN,SAAS;AACX;AAEA,IAAa,cAAb,cAAiC,MAAuB;CACtD,MAAM,yBACJ,SACA,SACqC;EACrC,MAAM,EAAE,MAAM,sBAAsB,SAAS,6BAA6B,KAAK;EAC/E,IAAI,CAAC,KAAK,QAAQ,GAA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cAAc;IACd,UAAS,YAAW,wBAAwB,OAAO;GACrD,CAAC;GACD,GAAI,KAAK,KAAK,YACV,CACE,iBAAiB,wBAAwB,kBAAkB,MAAM;IAC/D,QAAQ,wBAAwB,kBAAkB;IAClD,cAAc;IACd,UAAS,YAAW,gBAAgB,SAAS,KAAK;GACpD,CAAC,GACD,iBAAiB,wBAAwB,oBAAoB,MAAM;IACjE,QAAQ,wBAAwB,oBAAoB;IACpD,cAAc;IACd,UAAS,YAAW,gBAAgB,SAAS,IAAI;GACnD,CAAC,CACH,IACA,CAAC;GACL,iBAAiB,sDAAsD;IACrE,QAAQ;IACR,cAAc;IACd,UAAS,YAAW,mBAAmB,SAAS,KAAK;GACvD,CAAC;GACD,iBAAiB,qDAAqD;IACpE,QAAQ;IACR,cAAc;IACd,UAAS,YAAW,mBAAmB,SAAS,IAAI;GACtD,CAAC;EACH;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-control-sessions.d.ts","sourceRoot":"","sources":["../../src/routes/source-control-sessions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG1D,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAQnE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAarF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACxF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,KAAK,EAGV,0BAA0B,EAC3B,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3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,4BAA4B,CAAC;IACjD,mFAAmF;IACnF,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,sGAAsG;IACtG,UAAU,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAC;IAC5D,8EAA8E;IAC9E,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,SAAS,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,wBAAwB,GAAG,yBAAyB,CAAC,CAAC;IACzF,kGAAkG;IAClG,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACpF;AA2cD,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,iCAAiC,GAAG,QAAQ,EAAE,CA6YtG"}
|
|
@@ -5,6 +5,7 @@ import { seedSessionOrg } from "../session/org-seed.js";
|
|
|
5
5
|
import { isRunBound, isWorkerSession, listFactorySessionThreads, sessionMemoryResourceId, sessionThreadsToMove, userSessionResourceFor } from "../session/session-threads.js";
|
|
6
6
|
import { normalizeSessionTitle } from "../session/session-title.js";
|
|
7
7
|
import { SESSION_OWNER_SIGNAL_TAG } from "../session-owner-signal.js";
|
|
8
|
+
import { loose } from "./route.js";
|
|
8
9
|
import { canReadSessionResource, canSwitchSessionModel, canViewSourceControlSession } from "./session-access.js";
|
|
9
10
|
import { RequestContext } from "@mastra/core/request-context";
|
|
10
11
|
import { registerApiRoute } from "@mastra/core/server";
|
|
@@ -12,9 +13,6 @@ import { UniqueViolationError } from "@mastra/core/storage";
|
|
|
12
13
|
import { resolveModel } from "@mastra/code-sdk/agents/model";
|
|
13
14
|
import { createSignal } from "@mastra/core/signals";
|
|
14
15
|
// src/routes/source-control-sessions.ts
|
|
15
|
-
function loose(c) {
|
|
16
|
-
return c;
|
|
17
|
-
}
|
|
18
16
|
const USER_SESSION_BRANCH_PREFIX = "user/session-";
|
|
19
17
|
const SLACK_SESSION_BRANCH_PREFIX = "slack/";
|
|
20
18
|
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|