mastracode 0.18.1-alpha.1 → 0.19.0-alpha.0

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 (54) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/agents/model.d.ts.map +1 -1
  3. package/dist/auth/index.d.ts +1 -0
  4. package/dist/auth/index.d.ts.map +1 -1
  5. package/dist/auth/providers/openai-codex.d.ts +38 -3
  6. package/dist/auth/providers/openai-codex.d.ts.map +1 -1
  7. package/dist/auth/types.d.ts +20 -0
  8. package/dist/auth/types.d.ts.map +1 -1
  9. package/dist/{chunk-36KKPIKN.js → chunk-6NJTBUS6.js} +118 -8
  10. package/dist/chunk-6NJTBUS6.js.map +1 -0
  11. package/dist/{chunk-MGQHBND3.cjs → chunk-AA3TCUFQ.cjs} +25 -17
  12. package/dist/chunk-AA3TCUFQ.cjs.map +1 -0
  13. package/dist/{chunk-XAU4ESBR.cjs → chunk-C3WRKFS5.cjs} +160 -50
  14. package/dist/chunk-C3WRKFS5.cjs.map +1 -0
  15. package/dist/{chunk-EQBHZCMR.js → chunk-EDDYCMKX.js} +173 -53
  16. package/dist/chunk-EDDYCMKX.js.map +1 -0
  17. package/dist/{chunk-E5U4IMBB.cjs → chunk-M6OQ6SUR.cjs} +173 -53
  18. package/dist/chunk-M6OQ6SUR.cjs.map +1 -0
  19. package/dist/{chunk-7B7SVMEN.js → chunk-VCMICSFF.js} +14 -6
  20. package/dist/chunk-VCMICSFF.js.map +1 -0
  21. package/dist/{chunk-RNJ3EJCF.cjs → chunk-WKFOHBT6.cjs} +943 -862
  22. package/dist/chunk-WKFOHBT6.cjs.map +1 -0
  23. package/dist/{chunk-UBDF4DF5.js → chunk-X2UYDRKA.js} +89 -8
  24. package/dist/chunk-X2UYDRKA.js.map +1 -0
  25. package/dist/cli.cjs +19 -19
  26. package/dist/cli.js +4 -4
  27. package/dist/index.cjs +3 -3
  28. package/dist/index.js +1 -1
  29. package/dist/mcp/config.d.ts.map +1 -1
  30. package/dist/mcp/manager.d.ts.map +1 -1
  31. package/dist/mcp/types.d.ts +17 -0
  32. package/dist/mcp/types.d.ts.map +1 -1
  33. package/dist/providers/openai-codex.d.ts.map +1 -1
  34. package/dist/storage-DDIKKKQB.js +3 -0
  35. package/dist/{storage-AL27BSBS.js.map → storage-DDIKKKQB.js.map} +1 -1
  36. package/dist/storage-IFMPN24O.cjs +24 -0
  37. package/dist/{storage-DB6SRCPR.cjs.map → storage-IFMPN24O.cjs.map} +1 -1
  38. package/dist/tui/commands/login.d.ts.map +1 -1
  39. package/dist/tui/components/login-mode-selector.d.ts +26 -0
  40. package/dist/tui/components/login-mode-selector.d.ts.map +1 -0
  41. package/dist/tui/mastra-tui.d.ts.map +1 -1
  42. package/dist/tui.cjs +19 -19
  43. package/dist/tui.js +2 -2
  44. package/package.json +9 -9
  45. package/dist/chunk-36KKPIKN.js.map +0 -1
  46. package/dist/chunk-7B7SVMEN.js.map +0 -1
  47. package/dist/chunk-E5U4IMBB.cjs.map +0 -1
  48. package/dist/chunk-EQBHZCMR.js.map +0 -1
  49. package/dist/chunk-MGQHBND3.cjs.map +0 -1
  50. package/dist/chunk-RNJ3EJCF.cjs.map +0 -1
  51. package/dist/chunk-UBDF4DF5.js.map +0 -1
  52. package/dist/chunk-XAU4ESBR.cjs.map +0 -1
  53. package/dist/storage-AL27BSBS.js +0 -3
  54. package/dist/storage-DB6SRCPR.cjs +0 -24
package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # mastracode
2
2
 
3
+ ## 0.19.0-alpha.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Improved OpenAI Codex OAuth support in Mastra Code. When you select the Codex provider in `/login` or during onboarding, Mastra Code now asks how to sign in — **Browser (local callback)** or **Device code (headless)** — so the device-code flow is discoverable without setting an env var. `MASTRACODE_OPENAI_CODEX_AUTH_MODE=device` still works as a preselect for scripted environments. ([#16548](https://github.com/mastra-ai/mastra/pull/16548))
8
+
9
+ HTTP MCP server config can now pass OAuth client metadata to `@mastra/mcp` and store per-server OAuth state without sharing tokens across projects:
10
+
11
+ ```json
12
+ {
13
+ "mcpServers": {
14
+ "remote-api": {
15
+ "url": "https://mcp.example.com/mcp",
16
+ "oauth": {
17
+ "redirectUrl": "http://localhost:3000/oauth/callback"
18
+ }
19
+ }
20
+ }
21
+ }
22
+ ```
23
+
24
+ ### Patch Changes
25
+
26
+ - Updated dependencies [[`20787de`](https://github.com/mastra-ai/mastra/commit/20787de5965234a1af28fe35f49437c537dbfa0d), [`784ad98`](https://github.com/mastra-ai/mastra/commit/784ad989549de91dc5d33ab8ef36caa6f7dcd34e), [`0d53730`](https://github.com/mastra-ai/mastra/commit/0d53730c1ed87ef80c87caa5701c4170ea8028e6)]:
27
+ - @mastra/core@1.34.0-alpha.0
28
+
29
+ ## 0.18.1
30
+
31
+ ### Patch Changes
32
+
33
+ - Fixed a bug where clicking Approve on a plan from `/plan` mode would show the system reminder twice and sometimes hang instead of starting build execution. Approving now reliably triggers the build agent with a single reminder. ([#16521](https://github.com/mastra-ai/mastra/pull/16521))
34
+
35
+ - Updated dependencies [[`6ba46dc`](https://github.com/mastra-ai/mastra/commit/6ba46dc1ac04af635d0f59377d7384ca6af44cd1), [`3e63fca`](https://github.com/mastra-ai/mastra/commit/3e63fca7aa41269b2a9518effdd09b8ab8f1ff04), [`bc386e0`](https://github.com/mastra-ai/mastra/commit/bc386e08249dd30f3e66cf59de0c151a8dc26afb)]:
36
+ - @mastra/core@1.33.1
37
+
3
38
  ## 0.18.1-alpha.1
4
39
 
5
40
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/agents/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAsC,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AACh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} from './providers/anthropic.js';
7
7
  export { githubCopilotOAuthProvider } from './providers/github-copilot.js';
8
+ export { openaiCodexOAuthProvider } from './providers/openai-codex.js';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC"}
@@ -7,7 +7,26 @@
7
7
  * NOTE: This module uses Node.js crypto and http for the OAuth callback.
8
8
  * It is only intended for CLI use, not browser environments.
9
9
  */
10
- import type { OAuthCredentials, OAuthPrompt, OAuthProviderInterface } from '../types.js';
10
+ import type { AuthMode, OAuthCredentials, OAuthPrompt, OAuthProviderInterface } from '../types.js';
11
+ export declare const OPENAI_CODEX_AUTH_MODES: ReadonlyArray<AuthMode>;
12
+ declare const JWT_CLAIM_PATH = "https://api.openai.com/auth";
13
+ type JwtPayload = {
14
+ chatgpt_account_id?: string;
15
+ [JWT_CLAIM_PATH]?: {
16
+ chatgpt_account_id?: string;
17
+ };
18
+ [key: string]: unknown;
19
+ };
20
+ declare function decodeJwt(token: string): JwtPayload | null;
21
+ declare function extractAccountIdFromClaims(payload: JwtPayload | null | undefined): string | null;
22
+ declare function getAccountId(tokens: {
23
+ idToken?: string;
24
+ access: string;
25
+ }, fallback?: string): string | undefined;
26
+ declare function requireAccountId(tokens: {
27
+ idToken?: string;
28
+ access: string;
29
+ }, fallback?: string): string;
11
30
  declare function createAuthorizationFlow(redirectUri: string, state: string, originator?: string): Promise<{
12
31
  verifier: string;
13
32
  url: string;
@@ -26,6 +45,15 @@ type CallbackPorts = {
26
45
  fallbackPort: number;
27
46
  };
28
47
  declare function startLocalOAuthServer(state: string, ports?: CallbackPorts): Promise<OAuthServerInfo>;
48
+ declare function loginOpenAICodexDevice(options: {
49
+ onAuth: (info: {
50
+ url: string;
51
+ instructions?: string;
52
+ }) => void;
53
+ onProgress?: (message: string) => void;
54
+ signal?: AbortSignal;
55
+ sleep?: (ms: number) => Promise<void>;
56
+ }): Promise<OAuthCredentials>;
29
57
  /**
30
58
  * Login with OpenAI Codex OAuth
31
59
  *
@@ -35,7 +63,7 @@ declare function startLocalOAuthServer(state: string, ports?: CallbackPorts): Pr
35
63
  * @param options.onManualCodeInput - Optional promise that resolves with user-pasted code.
36
64
  * Races with browser callback - whichever completes first wins.
37
65
  * Useful for showing paste input immediately alongside browser flow.
38
- * @param options.originator - OAuth originator parameter (defaults to "pi")
66
+ * @param options.originator - OAuth originator parameter (defaults to "mastracode")
39
67
  */
40
68
  export declare function loginOpenAICodex(options: {
41
69
  onAuth: (info: {
@@ -45,16 +73,23 @@ export declare function loginOpenAICodex(options: {
45
73
  onPrompt: (prompt: OAuthPrompt) => Promise<string>;
46
74
  onProgress?: (message: string) => void;
47
75
  onManualCodeInput?: () => Promise<string>;
76
+ signal?: AbortSignal;
48
77
  originator?: string;
78
+ mode?: 'browser' | 'device';
49
79
  }): Promise<OAuthCredentials>;
50
80
  export declare const __testing: {
51
81
  createAuthorizationFlow: typeof createAuthorizationFlow;
82
+ decodeJwt: typeof decodeJwt;
83
+ extractAccountIdFromClaims: typeof extractAccountIdFromClaims;
84
+ getAccountId: typeof getAccountId;
85
+ loginOpenAICodexDevice: typeof loginOpenAICodexDevice;
86
+ requireAccountId: typeof requireAccountId;
52
87
  startLocalOAuthServer: typeof startLocalOAuthServer;
53
88
  };
54
89
  /**
55
90
  * Refresh OpenAI Codex OAuth token
56
91
  */
57
- export declare function refreshOpenAICodexToken(refreshToken: string): Promise<OAuthCredentials>;
92
+ export declare function refreshOpenAICodexToken(refreshToken: string, previousAccountId?: string): Promise<OAuthCredentials>;
58
93
  export declare const openaiCodexOAuthProvider: OAuthProviderInterface;
59
94
  export {};
60
95
  //# sourceMappingURL=openai-codex.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"openai-codex.d.ts","sourceRoot":"","sources":["../../../src/auth/providers/openai-codex.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAyBH,OAAO,KAAK,EAAE,gBAAgB,EAAuB,WAAW,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAyK9G,iBAAe,uBAAuB,CACpC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,MAAa,GACxB,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAgB5C;AAED,KAAK,eAAe,GAAG;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,WAAW,EAAE,MAAM,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;CACrD,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAkDF,iBAAe,qBAAqB,CAClC,KAAK,EAAE,MAAM,EACb,KAAK,GAAE,aAAoC,GAC1C,OAAO,CAAC,eAAe,CAAC,CA4E1B;AASD;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB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AAA;KAAE,KAAK,IAAI,CAAC;IAC/D,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAgG5B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE;IAC9C,MAAM,EAAE,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC/D,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACnD,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1C,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;CAC7B,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA0H5B;AAED,eAAO,MAAM,SAAS;;;;;;;;CAQrB,CAAC;AAEF;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,YAAY,EAAE,MAAM,EACpB,iBAAiB,CAAC,EAAE,MAAM,GACzB,OAAO,CAAC,gBAAgB,CAAC,CAc3B;AAED,eAAO,MAAM,wBAAwB,EAAE,sBAyBtC,CAAC"}
@@ -17,18 +17,38 @@ export interface OAuthPrompt {
17
17
  placeholder?: string;
18
18
  allowEmpty?: boolean;
19
19
  }
20
+ /**
21
+ * A selectable authentication mode for an OAuth provider.
22
+ * Providers that support multiple flows (e.g. browser callback vs. device code)
23
+ * advertise them via `OAuthProviderInterface.authModes`. The TUI shows a
24
+ * sub-selector when more than one mode is available so users don't need to
25
+ * discover the flow through environment variables.
26
+ */
27
+ export interface AuthMode {
28
+ id: string;
29
+ name: string;
30
+ description?: string;
31
+ }
20
32
  export interface OAuthLoginCallbacks {
21
33
  onAuth: (info: OAuthAuthInfo) => void;
22
34
  onPrompt: (prompt: OAuthPrompt) => Promise<string>;
23
35
  onProgress?: (message: string) => void;
24
36
  onManualCodeInput?: () => Promise<string>;
25
37
  signal?: AbortSignal;
38
+ /** Selected authentication mode id (matches one of `OAuthProviderInterface.authModes`). */
39
+ authMode?: string;
26
40
  }
27
41
  export interface OAuthProviderInterface {
28
42
  readonly id: OAuthProviderId;
29
43
  readonly name: string;
30
44
  /** Whether this provider uses a local callback server (vs manual code paste) */
31
45
  readonly usesCallbackServer?: boolean;
46
+ /**
47
+ * Optional list of selectable auth flows. When set with two or more entries,
48
+ * the TUI prompts the user to pick a mode before starting the login flow and
49
+ * forwards the choice via `OAuthLoginCallbacks.authMode`.
50
+ */
51
+ readonly authModes?: ReadonlyArray<AuthMode>;
32
52
  /** Run the login flow, return credentials to persist */
33
53
  login(callbacks: OAuthLoginCallbacks): Promise<OAuthCredentials>;
34
54
  /** Refresh expired credentials, return updated credentials to persist */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/auth/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC;AAErC,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MA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AAS,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAE7C,wDAAwD;IACxD,KAAK,CAAC,SAAS,EAAE,mBAAmB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAEjE,yEAAyE;IACzE,YAAY,CAAC,WAAW,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAEvE,6DAA6D;IAC7D,SAAS,CAAC,WAAW,EAAE,gBAAgB,GAAG,MAAM,CAAC;CAClD;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,SAAS,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,OAAO,CAAC;CACf,GAAG,gBAAgB,CAAC;AAErB,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG,eAAe,CAAC;AAEhE,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
- import { setAuthStorage, setAuthStorage3, setAuthStorage2, loadSettings, MEMORY_GATEWAY_PROVIDER, getDynamicModel, getAvailableModePacks, getAvailableOmPacks, resolveModelDefaults, resolveOmRoleModel, mastra, releaseThreadLock, acquireThreadLock, getCustomProviderId, toCustomProviderModelId, getCopilotModelCatalog, saveSettings, resolveModel, OBSERVABILITY_AUTH_PREFIX } from './chunk-7B7SVMEN.js';
2
- import { AuthStorage, detectProject, getResourceIdOverride, getStorageConfig, getObservabilityDatabasePath, getVectorDatabasePath, getCurrentGitBranch, getOmScope, getDatabasePath } from './chunk-EQBHZCMR.js';
1
+ import { setAuthStorage, setAuthStorage3, setAuthStorage2, loadSettings, MEMORY_GATEWAY_PROVIDER, getDynamicModel, getAvailableModePacks, getAvailableOmPacks, resolveModelDefaults, resolveOmRoleModel, mastra, releaseThreadLock, acquireThreadLock, getCustomProviderId, toCustomProviderModelId, getCopilotModelCatalog, saveSettings, resolveModel, OBSERVABILITY_AUTH_PREFIX } from './chunk-VCMICSFF.js';
2
+ import { AuthStorage, detectProject, getResourceIdOverride, getStorageConfig, getObservabilityDatabasePath, getVectorDatabasePath, getCurrentGitBranch, getOmScope, getDatabasePath, getAppDataDir } from './chunk-EDDYCMKX.js';
3
3
  import { MC_TOOLS, getToolCategory, TOOL_NAME_OVERRIDES } from './chunk-TTAAM2XR.js';
4
4
  import * as path from 'path';
5
5
  import path__default, { normalize, join, dirname } from 'path';
@@ -19,14 +19,14 @@ import os__default, { homedir } from 'os';
19
19
  import { LocalFilesystem, Workspace, LocalSandbox } from '@mastra/core/workspace';
20
20
  import { z } from 'zod';
21
21
  import * as fs2 from 'fs';
22
- import { readFileSync, existsSync } from 'fs';
22
+ import { readFileSync, existsSync, mkdirSync, writeFileSync, renameSync } from 'fs';
23
23
  import { fileURLToPath } from 'url';
24
24
  import { fastembed } from '@mastra/fastembed';
25
25
  import { Memory } from '@mastra/memory';
26
26
  import { createAnthropic } from '@ai-sdk/anthropic';
27
27
  import { createOpenAI } from '@ai-sdk/openai';
28
28
  import { createScorer, filterRun } from '@mastra/core/evals';
29
- import { MCPClient } from '@mastra/mcp';
29
+ import { MCPClient, MCPOAuthClientProvider } from '@mastra/mcp';
30
30
  import { LibSQLStore, LibSQLVector } from '@mastra/libsql';
31
31
  import { PostgresStore } from '@mastra/pg';
32
32
 
@@ -2246,9 +2246,15 @@ function validateConfig2(raw) {
2246
2246
  };
2247
2247
  } else if (classification.kind === "http") {
2248
2248
  const e = entry;
2249
+ const oauthResult = parseOAuthConfig(e.oauth);
2250
+ if (oauthResult.reason) {
2251
+ skippedServers.push({ name, reason: oauthResult.reason });
2252
+ continue;
2253
+ }
2249
2254
  servers[name] = {
2250
2255
  url: e.url,
2251
- headers: typeof e.headers === "object" && e.headers !== null ? e.headers : void 0
2256
+ headers: typeof e.headers === "object" && e.headers !== null ? e.headers : void 0,
2257
+ oauth: oauthResult.config
2252
2258
  };
2253
2259
  } else {
2254
2260
  skippedServers.push({ name, reason: classification.reason });
@@ -2263,6 +2269,37 @@ function validateConfig2(raw) {
2263
2269
  }
2264
2270
  return result;
2265
2271
  }
2272
+ function parseOAuthConfig(raw) {
2273
+ if (raw === void 0) return {};
2274
+ if (!raw || typeof raw !== "object") {
2275
+ return { reason: "Invalid OAuth config: expected an object" };
2276
+ }
2277
+ const obj = raw;
2278
+ if (typeof obj.redirectUrl !== "string") {
2279
+ return { reason: 'Invalid OAuth config: missing required field "redirectUrl"' };
2280
+ }
2281
+ try {
2282
+ const redirectUrl = new URL(obj.redirectUrl);
2283
+ const isLoopback = redirectUrl.hostname === "localhost" || redirectUrl.hostname.startsWith("127.") || redirectUrl.hostname === "[::1]";
2284
+ if (redirectUrl.protocol !== "https:" && !(redirectUrl.protocol === "http:" && isLoopback)) {
2285
+ return { reason: "Invalid OAuth redirectUrl: must use HTTPS unless it is a loopback HTTP URL" };
2286
+ }
2287
+ } catch {
2288
+ return { reason: `Invalid OAuth redirectUrl: "${obj.redirectUrl}"` };
2289
+ }
2290
+ if (obj.scopes !== void 0 && (!Array.isArray(obj.scopes) || obj.scopes.some((scope) => typeof scope !== "string"))) {
2291
+ return { reason: 'Invalid OAuth config: "scopes" must be an array of strings' };
2292
+ }
2293
+ return {
2294
+ config: {
2295
+ redirectUrl: obj.redirectUrl,
2296
+ clientName: typeof obj.clientName === "string" ? obj.clientName : void 0,
2297
+ scopes: obj.scopes,
2298
+ clientId: typeof obj.clientId === "string" ? obj.clientId : void 0,
2299
+ clientSecret: typeof obj.clientSecret === "string" ? obj.clientSecret : void 0
2300
+ }
2301
+ };
2302
+ }
2266
2303
  function mergeConfigs2(...configs) {
2267
2304
  const merged = {};
2268
2305
  const allSkipped = [];
@@ -2297,6 +2334,60 @@ var MASTRACODE_MCP_TIMEOUT_MS = 7 * 24 * 60 * 60 * 1e3;
2297
2334
  function getTransport(cfg) {
2298
2335
  return "url" in cfg ? "http" : "stdio";
2299
2336
  }
2337
+ var FileOAuthStorage = class {
2338
+ constructor(filePath) {
2339
+ this.filePath = filePath;
2340
+ }
2341
+ get(key) {
2342
+ return this.read()[key];
2343
+ }
2344
+ set(key, value) {
2345
+ const data = this.read();
2346
+ data[key] = value;
2347
+ this.write(data);
2348
+ }
2349
+ delete(key) {
2350
+ const data = this.read();
2351
+ delete data[key];
2352
+ this.write(data);
2353
+ }
2354
+ read() {
2355
+ if (!existsSync(this.filePath)) return {};
2356
+ try {
2357
+ return JSON.parse(readFileSync(this.filePath, "utf-8"));
2358
+ } catch {
2359
+ return {};
2360
+ }
2361
+ }
2362
+ write(data) {
2363
+ const dir = dirname(this.filePath);
2364
+ if (!existsSync(dir)) {
2365
+ mkdirSync(dir, { recursive: true, mode: 448 });
2366
+ }
2367
+ const tmpPath = `${this.filePath}.tmp`;
2368
+ writeFileSync(tmpPath, JSON.stringify(data, null, 2), { encoding: "utf-8", mode: 384 });
2369
+ renameSync(tmpPath, this.filePath);
2370
+ }
2371
+ };
2372
+ function getOAuthStoragePath(projectDir, name, cfg) {
2373
+ const key = JSON.stringify({
2374
+ projectDir,
2375
+ name,
2376
+ url: cfg.url,
2377
+ redirectUrl: cfg.oauth?.redirectUrl,
2378
+ clientId: cfg.oauth?.clientId,
2379
+ scopes: cfg.oauth?.scopes ?? []
2380
+ });
2381
+ return join(getAppDataDir(), "mcp-oauth", `${getStorageKeyFingerprint(key)}.json`);
2382
+ }
2383
+ function getStorageKeyFingerprint(value) {
2384
+ let fingerprint = 0xcbf29ce484222325n;
2385
+ for (let i = 0; i < value.length; i += 1) {
2386
+ fingerprint ^= BigInt(value.charCodeAt(i));
2387
+ fingerprint = BigInt.asUintN(64, fingerprint * 0x100000001b3n);
2388
+ }
2389
+ return fingerprint.toString(16).padStart(16, "0");
2390
+ }
2300
2391
  function createMcpManager(projectDir, extraServers) {
2301
2392
  const applyExtraServers = (base) => {
2302
2393
  if (!extraServers || Object.keys(extraServers).length === 0) return base;
@@ -2338,6 +2429,24 @@ function createMcpManager(projectDir, extraServers) {
2338
2429
  }
2339
2430
  });
2340
2431
  }
2432
+ function createOAuthProvider(name, cfg) {
2433
+ if (!cfg.oauth) return void 0;
2434
+ return new MCPOAuthClientProvider({
2435
+ redirectUrl: cfg.oauth.redirectUrl,
2436
+ clientMetadata: {
2437
+ redirect_uris: [cfg.oauth.redirectUrl],
2438
+ client_name: cfg.oauth.clientName ?? `Mastra Code MCP ${name}`,
2439
+ grant_types: ["authorization_code", "refresh_token"],
2440
+ response_types: ["code"],
2441
+ ...cfg.oauth.scopes?.length ? { scope: cfg.oauth.scopes.join(" ") } : {}
2442
+ },
2443
+ clientInformation: cfg.oauth.clientId ? {
2444
+ client_id: cfg.oauth.clientId,
2445
+ ...cfg.oauth.clientSecret ? { client_secret: cfg.oauth.clientSecret } : {}
2446
+ } : void 0,
2447
+ storage: new FileOAuthStorage(getOAuthStoragePath(projectDir, name, cfg))
2448
+ });
2449
+ }
2341
2450
  function buildServerDefs(servers) {
2342
2451
  const defs = {};
2343
2452
  for (const [name, cfg] of Object.entries(servers)) {
@@ -2345,7 +2454,8 @@ function createMcpManager(projectDir, extraServers) {
2345
2454
  const httpCfg = cfg;
2346
2455
  defs[name] = {
2347
2456
  url: new URL(httpCfg.url),
2348
- requestInit: httpCfg.headers ? { headers: httpCfg.headers } : void 0
2457
+ requestInit: httpCfg.headers ? { headers: httpCfg.headers } : void 0,
2458
+ authProvider: createOAuthProvider(name, httpCfg)
2349
2459
  };
2350
2460
  } else {
2351
2461
  defs[name] = { command: cfg.command, args: cfg.args, env: cfg.env, stderr: "pipe" };
@@ -3192,5 +3302,5 @@ async function createMastraCode(config) {
3192
3302
  }
3193
3303
 
3194
3304
  export { createAuthStorage, createMastraCode };
3195
- //# sourceMappingURL=chunk-36KKPIKN.js.map
3196
- //# sourceMappingURL=chunk-36KKPIKN.js.map
3305
+ //# sourceMappingURL=chunk-6NJTBUS6.js.map
3306
+ //# sourceMappingURL=chunk-6NJTBUS6.js.map