@mastra/factory 0.28.0-alpha.4 → 0.28.0-alpha.5

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.
Files changed (62) hide show
  1. package/dist/auth.d.ts.map +1 -1
  2. package/dist/auth.js +7 -1
  3. package/dist/auth.js.map +1 -1
  4. package/dist/factory.d.ts.map +1 -1
  5. package/dist/factory.js +4 -16
  6. package/dist/factory.js.map +1 -1
  7. package/dist/feed-events.d.ts +3 -2
  8. package/dist/feed-events.d.ts.map +1 -1
  9. package/dist/feed-events.js +3 -2
  10. package/dist/feed-events.js.map +1 -1
  11. package/dist/integrations/slack/run-error-card.js +1 -0
  12. package/dist/integrations/slack/run-error-card.js.map +1 -1
  13. package/dist/provider-display-name.d.ts.map +1 -1
  14. package/dist/provider-display-name.js +1 -0
  15. package/dist/provider-display-name.js.map +1 -1
  16. package/dist/routes/config.d.ts +7 -1
  17. package/dist/routes/config.d.ts.map +1 -1
  18. package/dist/routes/config.js +105 -22
  19. package/dist/routes/config.js.map +1 -1
  20. package/dist/routes/mastra-gateway.d.ts +19 -0
  21. package/dist/routes/mastra-gateway.d.ts.map +1 -0
  22. package/dist/routes/mastra-gateway.js +120 -0
  23. package/dist/routes/mastra-gateway.js.map +1 -0
  24. package/dist/routes/provider-credentials.d.ts +6 -1
  25. package/dist/routes/provider-credentials.d.ts.map +1 -1
  26. package/dist/routes/provider-credentials.js +32 -2
  27. package/dist/routes/provider-credentials.js.map +1 -1
  28. package/dist/routes/route.d.ts +6 -0
  29. package/dist/routes/route.d.ts.map +1 -1
  30. package/dist/routes/route.js.map +1 -1
  31. package/dist/routes/tenant-credentials.d.ts.map +1 -1
  32. package/dist/routes/tenant-credentials.js +5 -1
  33. package/dist/routes/tenant-credentials.js.map +1 -1
  34. package/dist/run-error.d.ts +1 -1
  35. package/dist/run-error.d.ts.map +1 -1
  36. package/dist/run-error.js +38 -5
  37. package/dist/run-error.js.map +1 -1
  38. package/dist/session/live-sessions.d.ts +11 -4
  39. package/dist/session/live-sessions.d.ts.map +1 -1
  40. package/dist/session/live-sessions.js +31 -10
  41. package/dist/session/live-sessions.js.map +1 -1
  42. package/dist/storage/domains/comments/base.d.ts.map +1 -1
  43. package/dist/storage/domains/comments/base.js +2 -2
  44. package/dist/storage/domains/comments/base.js.map +1 -1
  45. package/dist/storage/domains/comments/routes.d.ts.map +1 -1
  46. package/dist/storage/domains/comments/routes.js +4 -2
  47. package/dist/storage/domains/comments/routes.js.map +1 -1
  48. package/dist/storage/domains/work-items/base.d.ts +6 -9
  49. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  50. package/dist/storage/domains/work-items/base.js +33 -33
  51. package/dist/storage/domains/work-items/base.js.map +1 -1
  52. package/dist/storage/domains/work-items/board-version.d.ts +6 -2
  53. package/dist/storage/domains/work-items/board-version.d.ts.map +1 -1
  54. package/dist/storage/domains/work-items/board-version.js +20 -9
  55. package/dist/storage/domains/work-items/board-version.js.map +1 -1
  56. package/factory-skills/factory-gitlab-rereview/SKILL.md +4 -4
  57. package/factory-skills/factory-gitlab-review/SKILL.md +5 -5
  58. package/factory-skills/factory-rereview/SKILL.md +68 -22
  59. package/factory-skills/factory-review/SKILL.md +68 -22
  60. package/factory-skills/factory-self-review/SKILL.md +5 -6
  61. package/factory-skills/factory-triage/SKILL.md +8 -20
  62. package/package.json +8 -8
@@ -6,8 +6,9 @@ export interface FeedScope {
6
6
  export declare function feedTopic(orgId: string, factoryProjectId: string): string;
7
7
  /**
8
8
  * One frame for the whole project: `workItemId` names the item whose comments
9
- * moved, and its absence means only the project's attention did. Never awaited
10
- * — a slow or dead broker must not hold up the write it describes.
9
+ * moved, and its absence means something else on the board did — a card, a
10
+ * decision, a run, or the attention list. Never awaited — a slow or dead broker
11
+ * must not hold up the write it describes.
11
12
  */
12
13
  export declare function touchFeed(pubsub: PubSub, scope: FeedScope, workItemId?: string): void;
13
14
  //# sourceMappingURL=feed-events.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"feed-events.d.ts","sourceRoot":"","sources":["../src/feed-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAarF"}
1
+ {"version":3,"file":"feed-events.d.ts","sourceRoot":"","sources":["../src/feed-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAarF"}
@@ -4,8 +4,9 @@ function feedTopic(orgId, factoryProjectId) {
4
4
  }
5
5
  /**
6
6
  * One frame for the whole project: `workItemId` names the item whose comments
7
- * moved, and its absence means only the project's attention did. Never awaited
8
- * — a slow or dead broker must not hold up the write it describes.
7
+ * moved, and its absence means something else on the board did — a card, a
8
+ * decision, a run, or the attention list. Never awaited — a slow or dead broker
9
+ * must not hold up the write it describes.
9
10
  */
10
11
  function touchFeed(pubsub, scope, workItemId) {
11
12
  pubsub.publish(feedTopic(scope.orgId, scope.factoryProjectId), {
@@ -1 +1 @@
1
- {"version":3,"file":"feed-events.js","names":[],"sources":["../src/feed-events.ts"],"sourcesContent":["import type { PubSub } from '@mastra/core/events';\n\nexport interface FeedScope {\n orgId: string;\n factoryProjectId: string;\n}\n\nexport function feedTopic(orgId: string, factoryProjectId: string): string {\n return `factory.feed.${orgId}.${factoryProjectId}`;\n}\n\n/**\n * One frame for the whole project: `workItemId` names the item whose comments\n * moved, and its absence means only the project's attention did. Never awaited\n * — a slow or dead broker must not hold up the write it describes.\n */\nexport function touchFeed(pubsub: PubSub, scope: FeedScope, workItemId?: string): void {\n pubsub\n .publish(feedTopic(scope.orgId, scope.factoryProjectId), {\n type: 'factory.feed.touched',\n runId: workItemId ?? scope.factoryProjectId,\n data: workItemId ? { workItemId } : {},\n })\n .catch((error: unknown) => {\n console.warn('[Factory] Failed to publish a feed touch', {\n factoryProjectId: scope.factoryProjectId,\n error: error instanceof Error ? error.message : String(error),\n });\n });\n}\n"],"mappings":";AAOA,SAAgB,UAAU,OAAe,kBAAkC;CACzE,OAAO,gBAAgB,MAAM,GAAG;AAClC;;;;;;AAOA,SAAgB,UAAU,QAAgB,OAAkB,YAA2B;CACrF,OACG,QAAQ,UAAU,MAAM,OAAO,MAAM,gBAAgB,GAAG;EACvD,MAAM;EACN,OAAO,cAAc,MAAM;EAC3B,MAAM,aAAa,EAAE,WAAW,IAAI,CAAC;CACvC,CAAC,CAAC,CACD,OAAO,UAAmB;EACzB,QAAQ,KAAK,4CAA4C;GACvD,kBAAkB,MAAM;GACxB,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EAC9D,CAAC;CACH,CAAC;AACL"}
1
+ {"version":3,"file":"feed-events.js","names":[],"sources":["../src/feed-events.ts"],"sourcesContent":["import type { PubSub } from '@mastra/core/events';\n\nexport interface FeedScope {\n orgId: string;\n factoryProjectId: string;\n}\n\nexport function feedTopic(orgId: string, factoryProjectId: string): string {\n return `factory.feed.${orgId}.${factoryProjectId}`;\n}\n\n/**\n * One frame for the whole project: `workItemId` names the item whose comments\n * moved, and its absence means something else on the board did — a card, a\n * decision, a run, or the attention list. Never awaited — a slow or dead broker\n * must not hold up the write it describes.\n */\nexport function touchFeed(pubsub: PubSub, scope: FeedScope, workItemId?: string): void {\n pubsub\n .publish(feedTopic(scope.orgId, scope.factoryProjectId), {\n type: 'factory.feed.touched',\n runId: workItemId ?? scope.factoryProjectId,\n data: workItemId ? { workItemId } : {},\n })\n .catch((error: unknown) => {\n console.warn('[Factory] Failed to publish a feed touch', {\n factoryProjectId: scope.factoryProjectId,\n error: error instanceof Error ? error.message : String(error),\n });\n });\n}\n"],"mappings":";AAOA,SAAgB,UAAU,OAAe,kBAAkC;CACzE,OAAO,gBAAgB,MAAM,GAAG;AAClC;;;;;;;AAQA,SAAgB,UAAU,QAAgB,OAAkB,YAA2B;CACrF,OACG,QAAQ,UAAU,MAAM,OAAO,MAAM,gBAAgB,GAAG;EACvD,MAAM;EACN,OAAO,cAAc,MAAM;EAC3B,MAAM,aAAa,EAAE,WAAW,IAAI,CAAC;CACvC,CAAC,CAAC,CACD,OAAO,UAAmB;EACzB,QAAQ,KAAK,4CAA4C;GACvD,kBAAkB,MAAM;GACxB,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EAC9D,CAAC;CACH,CAAC;AACL"}
@@ -46,6 +46,7 @@ function recoveryLinks(requestContext, recoveries) {
46
46
  url: sessionUrl,
47
47
  label: "Change model"
48
48
  }] : [];
49
+ case "credits": return [];
49
50
  case "continue":
50
51
  case "new_session": return [];
51
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"run-error-card.js","names":[],"sources":["../../../src/integrations/slack/run-error-card.ts"],"sourcesContent":["import type { AgentControllerRequestContext } from '@mastra/core/agent-controller';\nimport type { ChannelErrorContext } from '@mastra/core/channels';\nimport { providerRequestId } from '@mastra/core/error';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport { Actions, Card, CardText, LinkButton } from 'chat';\n\nimport { readFactorySessionScope } from '../../rules/binding-context.js';\nimport type { RunErrorRecovery } from '../../run-error.js';\nimport { describeRunError } from '../../run-error.js';\nimport { runCredential } from '../../session/reply-credential-processor.js';\nimport { modelSettingsLink } from './channel-reply-processor.js';\nimport { sessionLinkFromRequest } from './channel-session-link-processor.js';\n\nexport function slackRunErrorCard(error: Error, { requestContext }: ChannelErrorContext) {\n const { title, message, recoveries, model } = describeRunError(error);\n const requestId = providerRequestId(error);\n const facts = [model && `Model: ${model}`, requestId && `Request id: ${requestId}`].filter(Boolean).join(' · ');\n const credential = model && recoveries.includes('credentials') ? credentialLine(requestContext, model) : undefined;\n const links = requestContext ? recoveryLinks(requestContext, recoveries) : [];\n return Card({\n title: `❌ ${title}`,\n children: [\n CardText(message),\n ...(credential ? [CardText(credential, { style: 'muted' })] : []),\n ...(facts ? [CardText(facts, { style: 'muted' })] : []),\n ...(links.length ? [Actions(links.map(link => LinkButton(link)))] : []),\n ],\n });\n}\n\n/** Only while the session's model is the one that failed: its provider is what names the credential. */\nfunction credentialLine(requestContext: RequestContext | undefined, failedModel: string): string | undefined {\n const controller = requestContext?.get('controller') as AgentControllerRequestContext | undefined;\n const sessionModelId = controller?.session?.modelId;\n if (!sessionModelId) return undefined;\n const slash = sessionModelId.indexOf('/');\n if (slash <= 0 || (sessionModelId !== failedModel && sessionModelId.slice(slash + 1) !== failedModel))\n return undefined;\n const credential = runCredential(requestContext, sessionModelId.slice(0, slash));\n if (!credential) return undefined;\n return `Runs on ${credential.label} · ${credential.ownerId ? 'Personal credential' : 'Shared by the organization'}`;\n}\n\nfunction recoveryLinks(requestContext: RequestContext, recoveries: RunErrorRecovery[]) {\n const factoryProjectId = readFactorySessionScope(requestContext)?.factoryProjectId;\n const settingsUrl = factoryProjectId && modelSettingsLink(factoryProjectId);\n const sessionUrl = sessionLinkFromRequest(requestContext);\n const links = recoveries.flatMap(recovery => {\n switch (recovery) {\n case 'credentials':\n return settingsUrl ? [{ url: settingsUrl, label: 'Review credentials' }] : [];\n case 'model':\n return sessionUrl ? [{ url: sessionUrl, label: 'Change model' }] : [];\n // A reply in the thread continues the run; a mention in a new thread starts a new session.\n case 'continue':\n case 'new_session':\n return [];\n }\n });\n if (links.length || !sessionUrl) return links;\n return [{ url: sessionUrl, label: 'Open session' }];\n}\n"],"mappings":";;;;;;;;AAaA,SAAgB,kBAAkB,OAAc,EAAE,kBAAuC;CACvF,MAAM,EAAE,OAAO,SAAS,YAAY,UAAU,iBAAiB,KAAK;CACpE,MAAM,YAAY,kBAAkB,KAAK;CACzC,MAAM,QAAQ,CAAC,SAAS,UAAU,SAAS,aAAa,eAAe,WAAW,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,KAAK;CAC9G,MAAM,aAAa,SAAS,WAAW,SAAS,aAAa,IAAI,eAAe,gBAAgB,KAAK,IAAI,KAAA;CACzG,MAAM,QAAQ,iBAAiB,cAAc,gBAAgB,UAAU,IAAI,CAAC;CAC5E,OAAO,KAAK;EACV,OAAO,KAAK;EACZ,UAAU;GACR,SAAS,OAAO;GAChB,GAAI,aAAa,CAAC,SAAS,YAAY,EAAE,OAAO,QAAQ,CAAC,CAAC,IAAI,CAAC;GAC/D,GAAI,QAAQ,CAAC,SAAS,OAAO,EAAE,OAAO,QAAQ,CAAC,CAAC,IAAI,CAAC;GACrD,GAAI,MAAM,SAAS,CAAC,QAAQ,MAAM,KAAI,SAAQ,WAAW,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;EACvE;CACF,CAAC;AACH;;AAGA,SAAS,eAAe,gBAA4C,aAAyC;CAE3G,MAAM,kBADa,gBAAgB,IAAI,YAAY,EAAA,EAChB,SAAS;CAC5C,IAAI,CAAC,gBAAgB,OAAO,KAAA;CAC5B,MAAM,QAAQ,eAAe,QAAQ,GAAG;CACxC,IAAI,SAAS,KAAM,mBAAmB,eAAe,eAAe,MAAM,QAAQ,CAAC,MAAM,aACvF,OAAO,KAAA;CACT,MAAM,aAAa,cAAc,gBAAgB,eAAe,MAAM,GAAG,KAAK,CAAC;CAC/E,IAAI,CAAC,YAAY,OAAO,KAAA;CACxB,OAAO,WAAW,WAAW,MAAM,KAAK,WAAW,UAAU,wBAAwB;AACvF;AAEA,SAAS,cAAc,gBAAgC,YAAgC;CACrF,MAAM,mBAAmB,wBAAwB,cAAc,CAAC,EAAE;CAClE,MAAM,cAAc,oBAAoB,kBAAkB,gBAAgB;CAC1E,MAAM,aAAa,uBAAuB,cAAc;CACxD,MAAM,QAAQ,WAAW,SAAQ,aAAY;EAC3C,QAAQ,UAAR;GACE,KAAK,eACH,OAAO,cAAc,CAAC;IAAE,KAAK;IAAa,OAAO;GAAqB,CAAC,IAAI,CAAC;GAC9E,KAAK,SACH,OAAO,aAAa,CAAC;IAAE,KAAK;IAAY,OAAO;GAAe,CAAC,IAAI,CAAC;GAEtE,KAAK;GACL,KAAK,eACH,OAAO,CAAC;EACZ;CACF,CAAC;CACD,IAAI,MAAM,UAAU,CAAC,YAAY,OAAO;CACxC,OAAO,CAAC;EAAE,KAAK;EAAY,OAAO;CAAe,CAAC;AACpD"}
1
+ {"version":3,"file":"run-error-card.js","names":[],"sources":["../../../src/integrations/slack/run-error-card.ts"],"sourcesContent":["import type { AgentControllerRequestContext } from '@mastra/core/agent-controller';\nimport type { ChannelErrorContext } from '@mastra/core/channels';\nimport { providerRequestId } from '@mastra/core/error';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport { Actions, Card, CardText, LinkButton } from 'chat';\n\nimport { readFactorySessionScope } from '../../rules/binding-context.js';\nimport type { RunErrorRecovery } from '../../run-error.js';\nimport { describeRunError } from '../../run-error.js';\nimport { runCredential } from '../../session/reply-credential-processor.js';\nimport { modelSettingsLink } from './channel-reply-processor.js';\nimport { sessionLinkFromRequest } from './channel-session-link-processor.js';\n\nexport function slackRunErrorCard(error: Error, { requestContext }: ChannelErrorContext) {\n const { title, message, recoveries, model } = describeRunError(error);\n const requestId = providerRequestId(error);\n const facts = [model && `Model: ${model}`, requestId && `Request id: ${requestId}`].filter(Boolean).join(' · ');\n const credential = model && recoveries.includes('credentials') ? credentialLine(requestContext, model) : undefined;\n const links = requestContext ? recoveryLinks(requestContext, recoveries) : [];\n return Card({\n title: `❌ ${title}`,\n children: [\n CardText(message),\n ...(credential ? [CardText(credential, { style: 'muted' })] : []),\n ...(facts ? [CardText(facts, { style: 'muted' })] : []),\n ...(links.length ? [Actions(links.map(link => LinkButton(link)))] : []),\n ],\n });\n}\n\n/** Only while the session's model is the one that failed: its provider is what names the credential. */\nfunction credentialLine(requestContext: RequestContext | undefined, failedModel: string): string | undefined {\n const controller = requestContext?.get('controller') as AgentControllerRequestContext | undefined;\n const sessionModelId = controller?.session?.modelId;\n if (!sessionModelId) return undefined;\n const slash = sessionModelId.indexOf('/');\n if (slash <= 0 || (sessionModelId !== failedModel && sessionModelId.slice(slash + 1) !== failedModel))\n return undefined;\n const credential = runCredential(requestContext, sessionModelId.slice(0, slash));\n if (!credential) return undefined;\n return `Runs on ${credential.label} · ${credential.ownerId ? 'Personal credential' : 'Shared by the organization'}`;\n}\n\nfunction recoveryLinks(requestContext: RequestContext, recoveries: RunErrorRecovery[]) {\n const factoryProjectId = readFactorySessionScope(requestContext)?.factoryProjectId;\n const settingsUrl = factoryProjectId && modelSettingsLink(factoryProjectId);\n const sessionUrl = sessionLinkFromRequest(requestContext);\n const links = recoveries.flatMap(recovery => {\n switch (recovery) {\n case 'credentials':\n return settingsUrl ? [{ url: settingsUrl, label: 'Review credentials' }] : [];\n case 'model':\n return sessionUrl ? [{ url: sessionUrl, label: 'Change model' }] : [];\n case 'credits':\n return [];\n // A reply in the thread continues the run; a mention in a new thread starts a new session.\n case 'continue':\n case 'new_session':\n return [];\n }\n });\n if (links.length || !sessionUrl) return links;\n return [{ url: sessionUrl, label: 'Open session' }];\n}\n"],"mappings":";;;;;;;;AAaA,SAAgB,kBAAkB,OAAc,EAAE,kBAAuC;CACvF,MAAM,EAAE,OAAO,SAAS,YAAY,UAAU,iBAAiB,KAAK;CACpE,MAAM,YAAY,kBAAkB,KAAK;C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R;GACE,KAAK,eACH,OAAO,cAAc,CAAC;IAAE,KAAK;IAAa,OAAO;GAAqB,CAAC,IAAI,CAAC;GAC9E,KAAK,SACH,OAAO,aAAa,CAAC;IAAE,KAAK;IAAY,OAAO;GAAe,CAAC,IAAI,CAAC;GACtE,KAAK,WACH,OAAO,CAAC;GAEV,KAAK;GACL,KAAK,eACH,OAAO,CAAC;EACZ;CACF,CAAC;CACD,IAAI,MAAM,UAAU,CAAC,YAAY,OAAO;CACxC,OAAO,CAAC;EAAE,KAAK;EAAY,OAAO;CAAe,CAAC;AACpD"}
@@ -1 +1 @@
1
- {"version":3,"file":"provider-display-name.d.ts","sourceRoot":"","sources":["../src/provider-display-name.ts"],"names":[],"mappings":"AASA,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQ5D"}
1
+ {"version":3,"file":"provider-display-name.d.ts","sourceRoot":"","sources":["../src/provider-display-name.ts"],"names":[],"mappings":"AAUA,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQ5D"}
@@ -3,6 +3,7 @@ const PROVIDER_DISPLAY_NAMES = {
3
3
  anthropic: "Anthropic",
4
4
  "github-copilot": "GitHub Copilot",
5
5
  "kimi-code-plan-cn": "Kimi",
6
+ mastra: "Mastra Gateway",
6
7
  openai: "OpenAI",
7
8
  "openai-codex": "OpenAI",
8
9
  xai: "xAI"
@@ -1 +1 @@
1
- {"version":3,"file":"provider-display-name.js","names":[],"sources":["../src/provider-display-name.ts"],"sourcesContent":["const PROVIDER_DISPLAY_NAMES: Record<string, string> = {\n anthropic: 'Anthropic',\n 'github-copilot': 'GitHub Copilot',\n 'kimi-code-plan-cn': 'Kimi',\n openai: 'OpenAI',\n 'openai-codex': 'OpenAI',\n xai: 'xAI',\n};\n\nexport function providerDisplayName(provider: string): string {\n return (\n PROVIDER_DISPLAY_NAMES[provider] ??\n provider\n .split('-')\n .map(part => part.charAt(0).toUpperCase() + part.slice(1))\n .join(' ')\n );\n}\n"],"mappings":";AAAA,MAAM,yBAAiD;CACrD,WAAW;CACX,kBAAkB;CAClB,qBAAqB;CACrB,QAAQ;CACR,gBAAgB;CAChB,KAAK;AACP;AAEA,SAAgB,oBAAoB,UAA0B;CAC5D,OACE,uBAAuB,aACvB,SACG,MAAM,GAAG,CAAC,CACV,KAAI,SAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CACzD,KAAK,GAAG;AAEf"}
1
+ {"version":3,"file":"provider-display-name.js","names":[],"sources":["../src/provider-display-name.ts"],"sourcesContent":["const PROVIDER_DISPLAY_NAMES: Record<string, string> = {\n anthropic: 'Anthropic',\n 'github-copilot': 'GitHub Copilot',\n 'kimi-code-plan-cn': 'Kimi',\n mastra: 'Mastra Gateway',\n openai: 'OpenAI',\n 'openai-codex': 'OpenAI',\n xai: 'xAI',\n};\n\nexport function providerDisplayName(provider: string): string {\n return (\n PROVIDER_DISPLAY_NAMES[provider] ??\n provider\n .split('-')\n .map(part => part.charAt(0).toUpperCase() + part.slice(1))\n .join(' ')\n );\n}\n"],"mappings":";AAAA,MAAM,yBAAiD;CACrD,WAAW;CACX,kBAAkB;CAClB,qBAAqB;CACrB,QAAQ;CACR,QAAQ;CACR,gBAAgB;CAChB,KAAK;AACP;AAEA,SAAgB,oBAAoB,UAA0B;CAC5D,OACE,uBAAuB,aACvB,SACG,MAAM,GAAG,CAAC,CACV,KAAI,SAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CACzD,KAAK,GAAG;AAEf"}
@@ -62,6 +62,8 @@ export interface ProviderInfo {
62
62
  };
63
63
  /** The provider is a stored custom OpenAI-compatible endpoint. */
64
64
  custom?: true;
65
+ /** Tenant mode: Factory can mint this provider's key with the caller's Mastra account (the Mastra Gateway). */
66
+ connectWithMastraAccount?: true;
65
67
  }
66
68
  /** Minimal session surface the config routes touch. */
67
69
  export interface OMSession {
@@ -84,6 +86,8 @@ export interface ModelCatalog {
84
86
  apiKeyEnvVar?: string;
85
87
  releaseDate?: string;
86
88
  }>>;
89
+ /** Drops cached auth so the next `listAvailableModels` call sees a credential change. */
90
+ invalidateAvailableModelsCache?: () => void;
87
91
  listModes?: () => Array<{
88
92
  id: string;
89
93
  defaultModelId?: string;
@@ -102,12 +106,14 @@ export interface ModelCatalog {
102
106
  * *caller's* tenant rows with user > org precedence and the server-global
103
107
  * `authStorage` is ignored; otherwise the local `auth.json` view is reported.
104
108
  */
105
- export declare function listProviders({ controller, authStorage, tenantCredentials, deploymentProviders, listCustomProviders, }: {
109
+ export declare function listProviders({ controller, authStorage, tenantCredentials, deploymentProviders, listCustomProviders, connectWithMastraAccount, }: {
106
110
  controller: ModelCatalog;
107
111
  authStorage?: AuthStorage;
108
112
  tenantCredentials?: CredentialRecord[];
109
113
  deploymentProviders?: ReadonlySet<string>;
110
114
  listCustomProviders?: () => Promise<CustomProviderRecord[]>;
115
+ /** The auth provider can act on the Mastra platform as the caller. */
116
+ connectWithMastraAccount?: boolean;
111
117
  }): Promise<ProviderInfo[]>;
112
118
  /** A user-defined OpenAI-compatible provider, with key presence (never the key). */
113
119
  export interface CustomProviderInfo {
@@ -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,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,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7F,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,CAs8BnB;CACF"}
@@ -2,7 +2,8 @@ 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 { WEB_OAUTH_PROVIDERS, credentialLabel, getAuthProviderId, listTenantCredentialsForRequest, resolveCredentialContext, tenantOrgId } from "./provider-credentials.js";
5
+ 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";
6
7
  import { Route, loose } from "./route.js";
7
8
  import { readRunningPackages } from "./running-packages.js";
8
9
  import { resolveTenantProviderDefaultModel } from "./tenant-credentials.js";
@@ -10,15 +11,33 @@ import { RequestContext } from "@mastra/core/request-context";
10
11
  import { registerApiRoute } from "@mastra/core/server";
11
12
  import { MIN_OBSERVATION_THRESHOLD } from "@mastra/code-sdk/constants";
12
13
  import { z } from "zod";
14
+ import { MASTRA_GATEWAY_PROVIDER, getCustomProviderId } from "@mastra/code-sdk/onboarding/settings";
13
15
  import { MASTRA_GATEWAY_PREFIX } from "@mastra/code-sdk/providers/model-ids";
14
16
  import { MastraCodeGateway } from "@mastra/code-sdk/agents/mastracode-gateway";
15
17
  import { resolveAutoOMModelId } from "@mastra/code-sdk/onboarding/packs";
16
- import { MASTRA_GATEWAY_PROVIDER, getCustomProviderId } from "@mastra/code-sdk/onboarding/settings";
17
18
  import { AMAZON_BEDROCK_GATEWAY_ID } from "@mastra/code-sdk/providers/amazon-bedrock-gateway";
18
19
  import { GOOGLE_VERTEX_GATEWAY_ID } from "@mastra/code-sdk/providers/google-vertex-gateway";
19
- import { getModelReasoningOptions } from "@mastra/core/llm";
20
+ import { MastraGateway, getModelReasoningOptions } from "@mastra/core/llm";
20
21
  // src/routes/config.ts
21
22
  /**
23
+ * The controller's model catalog, plus the Mastra Gateway's models for tenant
24
+ * callers. The boot-time catalog lists `mastra/...` models only when the server
25
+ * itself has a gateway key; tenants bring their own (connected in one click).
26
+ */
27
+ async function listCatalogModels(controller, tenantCredentials) {
28
+ const models = await controller.listAvailableModels();
29
+ if (!tenantCredentials || models.some((m) => m.provider === "mastra")) return models;
30
+ const gateway = (await new MastraGateway().fetchProviders())[MASTRA_GATEWAY_CATALOG_PROVIDER];
31
+ const gatewayModels = (gateway?.models ?? []).map((modelName) => ({
32
+ id: `${MASTRA_GATEWAY_CATALOG_PROVIDER}/${modelName}`,
33
+ provider: MASTRA_GATEWAY_CATALOG_PROVIDER,
34
+ modelName,
35
+ hasApiKey: false,
36
+ releaseDate: gateway?.modelReleaseDates?.[modelName]
37
+ }));
38
+ return [...models, ...gatewayModels];
39
+ }
40
+ /**
22
41
  * Build a deduplicated, sorted list of providers from the model catalog,
23
42
  * annotated with where each provider's credential currently comes from.
24
43
  * Mirrors the TUI's `/api-keys` provider list.
@@ -27,8 +46,8 @@ import { getModelReasoningOptions } from "@mastra/core/llm";
27
46
  * *caller's* tenant rows with user > org precedence and the server-global
28
47
  * `authStorage` is ignored; otherwise the local `auth.json` view is reported.
29
48
  */
30
- async function listProviders({ controller, authStorage, tenantCredentials, deploymentProviders, listCustomProviders }) {
31
- const models = await controller.listAvailableModels();
49
+ async function listProviders({ controller, authStorage, tenantCredentials, deploymentProviders, listCustomProviders, connectWithMastraAccount }) {
50
+ const models = await listCatalogModels(controller, tenantCredentials);
32
51
  const seen = /* @__PURE__ */ new Map();
33
52
  for (const model of models) {
34
53
  if (seen.has(model.provider)) continue;
@@ -75,7 +94,8 @@ async function listProviders({ controller, authStorage, tenantCredentials, deplo
75
94
  ...flowKind ? { oauth: {
76
95
  supported: true,
77
96
  modes: [flowKind]
78
- } } : {}
97
+ } } : {},
98
+ ...tenantCredentials && connectWithMastraAccount && model.provider === "mastra" ? { connectWithMastraAccount: true } : {}
79
99
  });
80
100
  }
81
101
  if (listCustomProviders) try {
@@ -190,7 +210,7 @@ function tenantModelCredential(records, provider) {
190
210
  * the named providers, plus any other provider that has a usable key.
191
211
  */
192
212
  async function buildProviderAccess({ controller, authStorage, tenantCredentials, deploymentProviders }) {
193
- const models = await controller.listAvailableModels();
213
+ const models = await listCatalogModels(controller, tenantCredentials);
194
214
  const hasModelKey = (provider) => models.some((m) => m.provider === provider && m.hasApiKey);
195
215
  const accessLevel = (provider) => {
196
216
  const authProviderId = getAuthProviderId(provider);
@@ -199,6 +219,7 @@ async function buildProviderAccess({ controller, authStorage, tenantCredentials,
199
219
  const credential = grantingTenantRecord(tenantCredentials, authProviderId)?.credential;
200
220
  if (credential?.type === "oauth") return "oauth";
201
221
  if (credential?.type === "api_key" && credential.key.trim().length > 0) return "apikey";
222
+ if (provider === "mastra" && MastraCodeGateway.getMastraGatewayApiKey()) return "apikey";
202
223
  return false;
203
224
  }
204
225
  if ((authStorage?.get(authProviderId))?.type === "oauth") return "oauth";
@@ -231,7 +252,7 @@ function canUseModelProvider(access, provider) {
231
252
  * picker and `factory_switch_session_model` both use this so they cannot drift.
232
253
  */
233
254
  async function buildModelCatalog({ controller, authStorage, tenantCredentials, deploymentProviders, listCustomProviders }) {
234
- const [models, access] = await Promise.all([controller.listAvailableModels(), buildProviderAccess({
255
+ const [models, access] = await Promise.all([listCatalogModels(controller, tenantCredentials), buildProviderAccess({
235
256
  controller,
236
257
  authStorage: tenantCredentials ? void 0 : authStorage,
237
258
  tenantCredentials,
@@ -389,6 +410,14 @@ var ConfigRoutes = class extends Route {
389
410
  const options = this.deps;
390
411
  const { controller, authStorage, auth, deploymentProviders } = options;
391
412
  const onCredentialsChanged = options.onCredentialsChanged ?? (() => {});
413
+ const connectWithMastraAccount = auth.fetchPlatformAsUser !== void 0;
414
+ const listTenantProviders = (records) => listProviders({
415
+ controller,
416
+ tenantCredentials: records,
417
+ deploymentProviders,
418
+ connectWithMastraAccount
419
+ });
420
+ 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);
392
421
  const onCustomProvidersChanged = options.onCustomProvidersChanged ?? (() => {});
393
422
  const resolveSessionModelContext = async (c, address, includeDefaultModel = true) => {
394
423
  const tenant = auth.tenant(c);
@@ -478,7 +507,7 @@ var ConfigRoutes = class extends Route {
478
507
  deploymentProviders
479
508
  });
480
509
  const availableProviders = new Set(Object.entries(access).flatMap(([providerId, configured]) => configured ? [providerId] : []));
481
- if (MastraCodeGateway.getMastraGatewayApiKey()) availableProviders.add(MASTRA_GATEWAY_PROVIDER);
510
+ if (access["mastra"] || MastraCodeGateway.getMastraGatewayApiKey()) availableProviders.add(MASTRA_GATEWAY_PROVIDER);
482
511
  if (options.customProviders) {
483
512
  const context = await resolveCustomProvidersContext({
484
513
  c: loose(c),
@@ -545,7 +574,8 @@ var ConfigRoutes = class extends Route {
545
574
  authStorage: tenantCredentials ? void 0 : authStorage,
546
575
  tenantCredentials,
547
576
  deploymentProviders,
548
- listCustomProviders
577
+ listCustomProviders,
578
+ connectWithMastraAccount
549
579
  }),
550
580
  ...orgKeyAdmin !== void 0 ? { orgKeyAdmin } : {}
551
581
  });
@@ -592,11 +622,7 @@ var ConfigRoutes = class extends Route {
592
622
  });
593
623
  onCredentialsChanged(tenant);
594
624
  const records = await ctx.storage.listCredentials(ctx.orgId, ctx.userId);
595
- const providers = await listProviders({
596
- controller,
597
- tenantCredentials: records,
598
- deploymentProviders
599
- });
625
+ const providers = await listTenantProviders(records);
600
626
  return c.json({
601
627
  ok: true,
602
628
  provider: providers.find((p) => p.provider === provider)
@@ -604,6 +630,7 @@ var ConfigRoutes = class extends Route {
604
630
  }
605
631
  if (!authStorage) return c.json({ error: "Credential storage is not available" }, 503);
606
632
  authStorage.setStoredApiKey(provider, key, envVar);
633
+ controller.invalidateAvailableModelsCache?.();
607
634
  const providers = await listProviders({
608
635
  controller,
609
636
  authStorage
@@ -617,6 +644,66 @@ var ConfigRoutes = class extends Route {
617
644
  }
618
645
  }
619
646
  }),
647
+ registerApiRoute(`/web/config/providers/${MASTRA_GATEWAY_CATALOG_PROVIDER}/connect`, {
648
+ method: "POST",
649
+ requiresAuth: false,
650
+ handler: async (c) => {
651
+ const ctx = await resolveCredentialContext({
652
+ c: loose(c),
653
+ auth,
654
+ credentials: options.modelCredentials
655
+ });
656
+ if ("response" in ctx) return ctx.response;
657
+ if (ctx.mode !== "tenant") return c.json({ error: MASTRA_SIGN_IN_REQUIRED }, 400);
658
+ let body;
659
+ try {
660
+ body = await c.req.json();
661
+ } catch {
662
+ return c.json({ error: "Invalid JSON body" }, 400);
663
+ }
664
+ const scope = body.scope === "org" ? "org" : "user";
665
+ if (scope === "org" && !await auth.isOrganizationAdmin(loose(c), ctx.orgId)) return c.json({ error: "organization_admin_required" }, 403);
666
+ const tenant = scope === "org" ? { orgId: ctx.orgId } : {
667
+ orgId: ctx.orgId,
668
+ userId: ctx.userId
669
+ };
670
+ try {
671
+ if (!await ctx.storage.getCredential(tenant, MASTRA_GATEWAY_PROVIDER)) {
672
+ const apiKey = await createGatewayKey(auth, loose(c), ctx.orgId, scope);
673
+ await ctx.storage.setCredential(tenant, MASTRA_GATEWAY_PROVIDER, {
674
+ type: "api_key",
675
+ key: apiKey
676
+ });
677
+ onCredentialsChanged(tenant);
678
+ }
679
+ const providers = await listTenantProviders(await ctx.storage.listCredentials(ctx.orgId, ctx.userId));
680
+ return c.json({
681
+ ok: true,
682
+ provider: providers.find((p) => p.provider === MASTRA_GATEWAY_CATALOG_PROVIDER)
683
+ });
684
+ } catch (error) {
685
+ return gatewayFailure(loose(c), error);
686
+ }
687
+ }
688
+ }),
689
+ registerApiRoute(`/web/config/providers/${MASTRA_GATEWAY_CATALOG_PROVIDER}/credits`, {
690
+ method: "GET",
691
+ requiresAuth: false,
692
+ handler: async (c) => {
693
+ const ctx = await resolveCredentialContext({
694
+ c: loose(c),
695
+ auth,
696
+ credentials: options.modelCredentials
697
+ });
698
+ if ("response" in ctx) return ctx.response;
699
+ if (ctx.mode !== "tenant") return c.json({ error: MASTRA_SIGN_IN_REQUIRED }, 400);
700
+ try {
701
+ return c.json(await getGatewayCredits(auth, loose(c), ctx.orgId));
702
+ } catch (error) {
703
+ return gatewayFailure(loose(c), error);
704
+ }
705
+ }
706
+ }),
620
707
  registerApiRoute("/web/config/providers/:provider/key", {
621
708
  method: "DELETE",
622
709
  requiresAuth: false,
@@ -638,19 +725,15 @@ var ConfigRoutes = class extends Route {
638
725
  };
639
726
  await ctx.storage.removeCredential(tenant, getAuthProviderId(provider));
640
727
  onCredentialsChanged(tenant);
641
- const records = await ctx.storage.listCredentials(ctx.orgId, ctx.userId);
642
- const providers = await listProviders({
643
- controller,
644
- tenantCredentials: records,
645
- deploymentProviders
646
- });
728
+ const providers = await listTenantProviders(await ctx.storage.listCredentials(ctx.orgId, ctx.userId));
647
729
  return c.json({
648
730
  ok: true,
649
731
  provider: providers.find((p) => p.provider === provider)
650
732
  });
651
733
  }
652
734
  if (!authStorage) return c.json({ error: "Credential storage is not available" }, 503);
653
- authStorage.remove(`apikey:${provider}`);
735
+ authStorage.removeStoredApiKey(provider);
736
+ controller.invalidateAvailableModelsCache?.();
654
737
  const providers = await listProviders({
655
738
  controller,
656
739
  authStorage