mastracode 0.22.3-alpha.2 → 0.22.3-alpha.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,54 @@
1
1
  # mastracode
2
2
 
3
+ ## 0.22.3-alpha.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Added interface-first model gateways while keeping the existing `MastraModelGateway` base class backwards compatible. ([#17608](https://github.com/mastra-ai/mastra/pull/17608))
8
+
9
+ Added `MastraModelGatewayInterface` for plain object/custom gateway implementations and optional gateway `resolveAuth` hooks.
10
+
11
+ Moved MastraCode gateway-routed OAuth model construction into a custom Mastra gateway so `ModelRouterLanguageModel` can route through gateway `resolveAuth` and provider-specific `resolveLanguageModel` behavior.
12
+
13
+ **Usage:**
14
+
15
+ ```typescript
16
+ import { MastraModelGatewayInterface, ModelRouterLanguageModel } from '@mastra/core/llm';
17
+
18
+ const myGateway: MastraModelGatewayInterface = {
19
+ id: 'my-gateway',
20
+ name: 'My Gateway',
21
+ async fetchProviders() {
22
+ return {};
23
+ },
24
+ buildUrl() {
25
+ return 'https://api.example.com';
26
+ },
27
+ async getApiKey() {
28
+ return process.env.API_KEY ?? '';
29
+ },
30
+ // Optional: own authentication lookup
31
+ async resolveAuth(request) {
32
+ return { apiKey: process.env.API_KEY, source: 'gateway' };
33
+ },
34
+ async resolveLanguageModel({ modelId, providerId, apiKey }) {
35
+ // Return an AI SDK language model instance
36
+ },
37
+ };
38
+
39
+ // Register and route through the gateway
40
+ const router = new ModelRouterLanguageModel({ modelId: 'my-gateway/provider/model' }, [myGateway]);
41
+ ```
42
+
43
+ **Additional changes in this release:**
44
+ - Inline three-tier auth resolution (explicit → gateway.resolveAuth → legacy getApiKey) into `ModelRouterLanguageModel.resolveAuth` and deprecate the standalone `resolveModelAuth` helper.
45
+ - Fix `defaultGateways` deduplication in the `Mastra` class to use `getGatewayId(gateway)` instead of registry keys.
46
+ - Remove no-op `resolveModelId` identity function in mastracode in favor of direct usage.
47
+ - Fix `defaultNameGenerator` regex in `_llm-recorder` to anchor directory matches to path boundaries (prevents false matches like `-auth` suffixes).
48
+
49
+ - Updated dependencies [[`34839c1`](https://github.com/mastra-ai/mastra/commit/34839c1910b6964bf59ed0cee58844efebbb684e), [`053735a`](https://github.com/mastra-ai/mastra/commit/053735a75c2c18e23ce34d9468007efa4a45f4c4), [`34839c1`](https://github.com/mastra-ai/mastra/commit/34839c1910b6964bf59ed0cee58844efebbb684e), [`34839c1`](https://github.com/mastra-ai/mastra/commit/34839c1910b6964bf59ed0cee58844efebbb684e), [`a952852`](https://github.com/mastra-ai/mastra/commit/a952852c971a21fb646cd907c75fcf4443cdc963)]:
50
+ - @mastra/core@1.42.0-alpha.3
51
+
3
52
  ## 0.22.3-alpha.2
4
53
 
5
54
  ### Patch Changes
@@ -1,6 +1,7 @@
1
1
  import { createAnthropic } from '@ai-sdk/anthropic';
2
2
  import { createOpenAI } from '@ai-sdk/openai';
3
3
  import { ModelRouterLanguageModel } from '@mastra/core/llm';
4
+ import type { GatewayAuthRequest, GatewayAuthResult } from '@mastra/core/llm';
4
5
  import type { RequestContext } from '@mastra/core/request-context';
5
6
  import { opencodeClaudeMaxProvider } from '../providers/claude-max.js';
6
7
  import { githubCopilotProvider } from '../providers/github-copilot.js';
@@ -18,6 +19,13 @@ export declare function getAnthropicApiKey(): string | undefined;
18
19
  * Main slot → dedicated apikey: slot → env var.
19
20
  */
20
21
  export declare function getOpenAIApiKey(): string | undefined;
22
+ export declare function resolveAuth(request: GatewayAuthRequest, memoryGatewayApiKey?: string): GatewayAuthResult | undefined;
23
+ /**
24
+ * Placeholder for future model ID normalization.
25
+ * Currently returns the input unchanged, but exists as a seam
26
+ * for aliasing, casing fixes, or validation in the future.
27
+ */
28
+ export declare function resolveModelId(modelId: string): string;
21
29
  /**
22
30
  * Resolve a model ID to the correct provider instance.
23
31
  * Shared by the main agent, observer, and reflector.
@@ -1 +1 @@
1
- {"version":3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;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,aAAa,CAAC;IAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAAC,cAAc,CAAC,EAAE,cAAc,CAAA;CAAE,GACzG,aAAa,CAuBf;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAAE,cAAc,EAAE,EAAE;IAAE,cAAc,EAAE,cAAc,CAAA;CAAE,GAAG,aAAa,CAWrG"}
@@ -1,4 +1,4 @@
1
- import { tintHex, mastra, theme, getMarkdownTheme, CHAT_INDENT, BOX_INDENT, getTermWidth, ensureTerminalGlyphContrast, TERM_WIDTH_BUFFER, getEditorTheme, loadSettings, MEMORY_GATEWAY_PROVIDER, getAvailableModePacks, resolveThreadActiveModelPackId, saveSettings, getAvailableOmPacks, ONBOARDING_VERSION, THREAD_ACTIVE_MODEL_PACK_ID_KEY, BOX_INDENT_STR, resolveModel, ThreadLockError, getSelectListTheme, luminance, extendedColors, MEMORY_GATEWAY_DEFAULT_URL, getThemeMode, applyThemeMode, createBrowserFromSettings, setProfileProvider, getCustomProviderId, OBSERVABILITY_AUTH_PREFIX, checkProfileProviderMismatch, getSettingsListTheme, mastraBrand, toCustomProviderModelId } from './chunk-TWAOLBVC.js';
1
+ import { tintHex, mastra, theme, getMarkdownTheme, CHAT_INDENT, BOX_INDENT, getTermWidth, ensureTerminalGlyphContrast, TERM_WIDTH_BUFFER, getEditorTheme, loadSettings, MEMORY_GATEWAY_PROVIDER, getAvailableModePacks, resolveThreadActiveModelPackId, saveSettings, getAvailableOmPacks, ONBOARDING_VERSION, THREAD_ACTIVE_MODEL_PACK_ID_KEY, BOX_INDENT_STR, resolveModel, ThreadLockError, getSelectListTheme, luminance, extendedColors, MEMORY_GATEWAY_DEFAULT_URL, getThemeMode, applyThemeMode, createBrowserFromSettings, setProfileProvider, getCustomProviderId, OBSERVABILITY_AUTH_PREFIX, checkProfileProviderMismatch, getSettingsListTheme, mastraBrand, toCustomProviderModelId } from './chunk-VPTZ4CZH.js';
2
2
  import { getOAuthProviders, detectProject, DEFAULT_CONFIG_DIR, getUserId, getCurrentGitBranchAsync, getUserName, PROVIDER_DEFAULT_MODELS, getAppDataDir } from './chunk-5FT2NNFO.js';
3
3
  import { MC_TOOLS, getToolCategory, TOOL_CATEGORIES } from './chunk-UOFNLVKF.js';
4
4
  import { exec, spawn, execFile, execSync, execFileSync } from 'child_process';
@@ -1174,7 +1174,7 @@ function getInstallCommand(pm, version) {
1174
1174
  }
1175
1175
  function getCurrentVersion() {
1176
1176
  {
1177
- return "0.22.3-alpha.2";
1177
+ return "0.22.3-alpha.3";
1178
1178
  }
1179
1179
  }
1180
1180
  async function fetchLatestVersion() {
@@ -19371,5 +19371,5 @@ Would you like to update now?`;
19371
19371
  };
19372
19372
 
19373
19373
  export { AssistantMessageComponent, LoginDialogComponent, LoginSelectorComponent, MastraTUI, ModelSelectorComponent, OMProgressComponent, ToolExecutionComponentEnhanced, UserMessageComponent, createTUIState, detectTerminalTheme, formatOMStatus, getCurrentVersion };
19374
- //# sourceMappingURL=chunk-HW7OKY3W.js.map
19375
- //# sourceMappingURL=chunk-HW7OKY3W.js.map
19374
+ //# sourceMappingURL=chunk-CUQA47X4.js.map
19375
+ //# sourceMappingURL=chunk-CUQA47X4.js.map