@mastra/code-sdk 1.18.0-alpha.1 → 1.18.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.
@@ -0,0 +1,23 @@
1
+ import { MastraModelGateway } from '@mastra/core/llm';
2
+ import type { GatewayAuthRequest, GatewayAuthResult, GatewayLanguageModel, ProviderConfig } from '@mastra/core/llm';
3
+ export declare const GOOGLE_VERTEX_GATEWAY_ID = "google-vertex";
4
+ export declare function hasGoogleVertexConfiguration(): boolean;
5
+ export declare class GoogleVertexGateway extends MastraModelGateway {
6
+ readonly id = "google-vertex";
7
+ readonly name = "Google Vertex AI";
8
+ shouldEnable(): boolean;
9
+ fetchProviders(): Promise<Record<string, ProviderConfig>>;
10
+ buildUrl(_modelId: string): string | undefined;
11
+ getApiKey(_modelId: string): Promise<string>;
12
+ resolveAuth(_request: GatewayAuthRequest): GatewayAuthResult | undefined;
13
+ resolveLanguageModel(args: {
14
+ modelId: string;
15
+ providerId: string;
16
+ apiKey: string;
17
+ headers?: Record<string, string>;
18
+ transport?: any;
19
+ responsesWebSocket?: any;
20
+ }): GatewayLanguageModel;
21
+ }
22
+ export declare function createGoogleVertexGateway(): GoogleVertexGateway;
23
+ //# sourceMappingURL=google-vertex-gateway.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-vertex-gateway.d.ts","sourceRoot":"","sources":["../../src/providers/google-vertex-gateway.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGpH,eAAO,MAAM,wBAAwB,kBAAkB,CAAC;AAExD,wBAAgB,4BAA4B,IAAI,OAAO,CAEtD;AAWD,qBAAa,mBAAoB,SAAQ,kBAAkB;IACzD,QAAQ,CAAC,EAAE,mBAA4B;IACvC,QAAQ,CAAC,IAAI,sBAAsB;IAEnC,YAAY,IAAI,OAAO,CAEtB;IAEK,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAW9D;IAED,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE7C;IAEK,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEjD;IAED,WAAW,CAAC,QAAQ,EAAE,kBAAkB,GAAG,iBAAiB,GAAG,SAAS,CAIvE;IAED,oBAAoB,CAAC,IAAI,EAAE;QACzB,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,SAAS,CAAC,EAAE,GAAG,CAAC;QAChB,kBAAkB,CAAC,EAAE,GAAG,CAAC;KAC1B,GAAG,oBAAoB,CAEvB;CACF;AAED,wBAAgB,yBAAyB,IAAI,mBAAmB,CAE/D"}
@@ -0,0 +1,51 @@
1
+ import { getGoogleVertexModelCatalog } from "./google-vertex.js";
2
+ import { MastraModelGateway } from "@mastra/core/llm";
3
+ import { createVertex } from "@ai-sdk/google-vertex";
4
+ // src/providers/google-vertex-gateway.ts
5
+ const GOOGLE_VERTEX_GATEWAY_ID = "google-vertex";
6
+ function hasGoogleVertexConfiguration() {
7
+ return Boolean(process.env.GOOGLE_VERTEX_PROJECT?.trim() && process.env.GOOGLE_VERTEX_LOCATION?.trim());
8
+ }
9
+ function googleVertexProvider(modelId, headers) {
10
+ return createVertex({
11
+ project: process.env.GOOGLE_VERTEX_PROJECT?.trim(),
12
+ location: process.env.GOOGLE_VERTEX_LOCATION?.trim(),
13
+ headers
14
+ })(modelId);
15
+ }
16
+ var GoogleVertexGateway = class extends MastraModelGateway {
17
+ id = GOOGLE_VERTEX_GATEWAY_ID;
18
+ name = "Google Vertex AI";
19
+ shouldEnable() {
20
+ return hasGoogleVertexConfiguration();
21
+ }
22
+ async fetchProviders() {
23
+ const models = await getGoogleVertexModelCatalog();
24
+ return { [GOOGLE_VERTEX_GATEWAY_ID]: {
25
+ name: "Google Vertex AI",
26
+ apiKeyEnvVar: "",
27
+ apiKeyHeader: "Authorization",
28
+ gateway: this.id,
29
+ models: models.map((model) => model.id)
30
+ } };
31
+ }
32
+ buildUrl(_modelId) {}
33
+ async getApiKey(_modelId) {
34
+ return hasGoogleVertexConfiguration() ? "google-application-default-credentials" : "";
35
+ }
36
+ resolveAuth(_request) {
37
+ return hasGoogleVertexConfiguration() ? {
38
+ apiKey: "google-application-default-credentials",
39
+ source: "gateway"
40
+ } : void 0;
41
+ }
42
+ resolveLanguageModel(args) {
43
+ return googleVertexProvider(args.modelId, args.headers);
44
+ }
45
+ };
46
+ function createGoogleVertexGateway() {
47
+ return new GoogleVertexGateway();
48
+ }
49
+ export { GOOGLE_VERTEX_GATEWAY_ID, GoogleVertexGateway, createGoogleVertexGateway, hasGoogleVertexConfiguration };
50
+
51
+ //# sourceMappingURL=google-vertex-gateway.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-vertex-gateway.js","names":[],"sources":["../../src/providers/google-vertex-gateway.ts"],"sourcesContent":["import { createVertex } from '@ai-sdk/google-vertex';\nimport { MastraModelGateway } from '@mastra/core/llm';\nimport type { GatewayAuthRequest, GatewayAuthResult, GatewayLanguageModel, ProviderConfig } from '@mastra/core/llm';\nimport { getGoogleVertexModelCatalog } from './google-vertex.js';\n\nexport const GOOGLE_VERTEX_GATEWAY_ID = 'google-vertex';\n\nexport function hasGoogleVertexConfiguration(): boolean {\n return Boolean(process.env.GOOGLE_VERTEX_PROJECT?.trim() && process.env.GOOGLE_VERTEX_LOCATION?.trim());\n}\n\nfunction googleVertexProvider(modelId: string, headers?: Record<string, string>) {\n const vertex = createVertex({\n project: process.env.GOOGLE_VERTEX_PROJECT?.trim(),\n location: process.env.GOOGLE_VERTEX_LOCATION?.trim(),\n headers,\n });\n return vertex(modelId);\n}\n\nexport class GoogleVertexGateway extends MastraModelGateway {\n readonly id = GOOGLE_VERTEX_GATEWAY_ID;\n readonly name = 'Google Vertex AI';\n\n shouldEnable(): boolean {\n return hasGoogleVertexConfiguration();\n }\n\n async fetchProviders(): Promise<Record<string, ProviderConfig>> {\n const models = await getGoogleVertexModelCatalog();\n return {\n [GOOGLE_VERTEX_GATEWAY_ID]: {\n name: 'Google Vertex AI',\n apiKeyEnvVar: '',\n apiKeyHeader: 'Authorization',\n gateway: this.id,\n models: models.map(model => model.id),\n },\n };\n }\n\n buildUrl(_modelId: string): string | undefined {\n return undefined;\n }\n\n async getApiKey(_modelId: string): Promise<string> {\n return hasGoogleVertexConfiguration() ? 'google-application-default-credentials' : '';\n }\n\n resolveAuth(_request: GatewayAuthRequest): GatewayAuthResult | undefined {\n return hasGoogleVertexConfiguration()\n ? { apiKey: 'google-application-default-credentials', source: 'gateway' }\n : undefined;\n }\n\n resolveLanguageModel(args: {\n modelId: string;\n providerId: string;\n apiKey: string;\n headers?: Record<string, string>;\n transport?: any;\n responsesWebSocket?: any;\n }): GatewayLanguageModel {\n return googleVertexProvider(args.modelId, args.headers) as unknown as GatewayLanguageModel;\n }\n}\n\nexport function createGoogleVertexGateway(): GoogleVertexGateway {\n return new GoogleVertexGateway();\n}\n"],"mappings":";;;;AAKA,MAAa,2BAA2B;AAExC,SAAgB,+BAAwC;CACtD,OAAO,QAAQ,QAAQ,IAAI,uBAAuB,KAAK,KAAK,QAAQ,IAAI,wBAAwB,KAAK,CAAC;AACxG;AAEA,SAAS,qBAAqB,SAAiB,SAAkC;CAM/E,OALe,aAAa;EAC1B,SAAS,QAAQ,IAAI,uBAAuB,KAAK;EACjD,UAAU,QAAQ,IAAI,wBAAwB,KAAK;EACnD;CACF,CACY,CAAC,CAAC,OAAO;AACvB;AAEA,IAAa,sBAAb,cAAyC,mBAAmB;CAC1D,KAAc;CACd,OAAgB;CAEhB,eAAwB;EACtB,OAAO,6BAA6B;CACtC;CAEA,MAAM,iBAA0D;EAC9D,MAAM,SAAS,MAAM,4BAA4B;EACjD,OAAO,GACJ,2BAA2B;GAC1B,MAAM;GACN,cAAc;GACd,cAAc;GACd,SAAS,KAAK;GACd,QAAQ,OAAO,KAAI,UAAS,MAAM,EAAE;EACtC,EACF;CACF;CAEA,SAAS,UAAsC,CAE/C;CAEA,MAAM,UAAU,UAAmC;EACjD,OAAO,6BAA6B,IAAI,2CAA2C;CACrF;CAEA,YAAY,UAA6D;EACvE,OAAO,6BAA6B,IAChC;GAAE,QAAQ;GAA0C,QAAQ;EAAU,IACtE,KAAA;CACN;CAEA,qBAAqB,MAOI;EACvB,OAAO,qBAAqB,KAAK,SAAS,KAAK,OAAO;CACxD;AACF;AAEA,SAAgB,4BAAiD;CAC/D,OAAO,IAAI,oBAAoB;AACjC"}
@@ -0,0 +1,6 @@
1
+ export interface GoogleVertexModelEntry {
2
+ id: string;
3
+ }
4
+ export declare function clearGoogleVertexCatalogCache(): void;
5
+ export declare function getGoogleVertexModelCatalog(): Promise<GoogleVertexModelEntry[]>;
6
+ //# sourceMappingURL=google-vertex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-vertex.d.ts","sourceRoot":"","sources":["../../src/providers/google-vertex.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;CACZ;AAaD,wBAAgB,6BAA6B,IAAI,IAAI,CAGpD;AAiBD,wBAAsB,2BAA2B,IAAI,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAgCrF"}
@@ -0,0 +1,53 @@
1
+ // src/providers/google-vertex.ts
2
+ const MODELS_DEV_API_URL = "https://models.dev/api.json";
3
+ const GOOGLE_VERTEX_PROVIDER_ID = "google-vertex";
4
+ const CATALOG_TTL_MS = 36e5;
5
+ const CATALOG_FAILURE_TTL_MS = 6e4;
6
+ const CATALOG_FETCH_TIMEOUT_MS = 5e3;
7
+ const GOOGLE_VERTEX_FALLBACK_MODELS = [{ id: "gemini-3.8-flash" }];
8
+ let catalogCache = null;
9
+ let inflightFetch = null;
10
+ function clearGoogleVertexCatalogCache() {
11
+ catalogCache = null;
12
+ inflightFetch = null;
13
+ }
14
+ async function fetchGoogleVertexModels(signal) {
15
+ const response = await fetch(MODELS_DEV_API_URL, { signal });
16
+ if (!response.ok) throw new Error(`models.dev returned ${response.status}`);
17
+ const data = await response.json();
18
+ const models = Object.keys(data[GOOGLE_VERTEX_PROVIDER_ID]?.models ?? {}).sort().map((id) => ({ id }));
19
+ if (models.length === 0) throw new Error("models.dev returned no Google Vertex models");
20
+ return models;
21
+ }
22
+ async function getGoogleVertexModelCatalog() {
23
+ if (catalogCache && Date.now() - catalogCache.fetchedAt < catalogCache.ttl) return catalogCache.models;
24
+ if (inflightFetch) return inflightFetch;
25
+ inflightFetch = (async () => {
26
+ const controller = new AbortController();
27
+ const timer = setTimeout(() => controller.abort(), CATALOG_FETCH_TIMEOUT_MS);
28
+ try {
29
+ const models = await fetchGoogleVertexModels(controller.signal);
30
+ catalogCache = {
31
+ fetchedAt: Date.now(),
32
+ ttl: CATALOG_TTL_MS,
33
+ models
34
+ };
35
+ return models;
36
+ } catch (error) {
37
+ catalogCache = {
38
+ fetchedAt: Date.now(),
39
+ ttl: CATALOG_FAILURE_TTL_MS,
40
+ models: GOOGLE_VERTEX_FALLBACK_MODELS
41
+ };
42
+ console.warn("Failed to fetch live Google Vertex models, using fallback list:", error instanceof Error ? error.message : error);
43
+ return GOOGLE_VERTEX_FALLBACK_MODELS;
44
+ } finally {
45
+ clearTimeout(timer);
46
+ inflightFetch = null;
47
+ }
48
+ })();
49
+ return inflightFetch;
50
+ }
51
+ export { clearGoogleVertexCatalogCache, getGoogleVertexModelCatalog };
52
+
53
+ //# sourceMappingURL=google-vertex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-vertex.js","names":[],"sources":["../../src/providers/google-vertex.ts"],"sourcesContent":["const MODELS_DEV_API_URL = 'https://models.dev/api.json';\nconst GOOGLE_VERTEX_PROVIDER_ID = 'google-vertex';\nconst CATALOG_TTL_MS = 60 * 60 * 1000;\nconst CATALOG_FAILURE_TTL_MS = 60 * 1000;\nconst CATALOG_FETCH_TIMEOUT_MS = 5_000;\n\nexport interface GoogleVertexModelEntry {\n id: string;\n}\n\nconst GOOGLE_VERTEX_FALLBACK_MODELS: GoogleVertexModelEntry[] = [{ id: 'gemini-3.8-flash' }];\n\ninterface CatalogCacheEntry {\n fetchedAt: number;\n ttl: number;\n models: GoogleVertexModelEntry[];\n}\n\nlet catalogCache: CatalogCacheEntry | null = null;\nlet inflightFetch: Promise<GoogleVertexModelEntry[]> | null = null;\n\nexport function clearGoogleVertexCatalogCache(): void {\n catalogCache = null;\n inflightFetch = null;\n}\n\nasync function fetchGoogleVertexModels(signal: AbortSignal): Promise<GoogleVertexModelEntry[]> {\n const response = await fetch(MODELS_DEV_API_URL, { signal });\n if (!response.ok) {\n throw new Error(`models.dev returned ${response.status}`);\n }\n const data = (await response.json()) as Record<string, { models?: Record<string, unknown> }>;\n const models = Object.keys(data[GOOGLE_VERTEX_PROVIDER_ID]?.models ?? {})\n .sort()\n .map(id => ({ id }));\n if (models.length === 0) {\n throw new Error('models.dev returned no Google Vertex models');\n }\n return models;\n}\n\nexport async function getGoogleVertexModelCatalog(): Promise<GoogleVertexModelEntry[]> {\n const now = Date.now();\n if (catalogCache && now - catalogCache.fetchedAt < catalogCache.ttl) {\n return catalogCache.models;\n }\n if (inflightFetch) return inflightFetch;\n\n inflightFetch = (async () => {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), CATALOG_FETCH_TIMEOUT_MS);\n try {\n const models = await fetchGoogleVertexModels(controller.signal);\n catalogCache = { fetchedAt: Date.now(), ttl: CATALOG_TTL_MS, models };\n return models;\n } catch (error) {\n catalogCache = {\n fetchedAt: Date.now(),\n ttl: CATALOG_FAILURE_TTL_MS,\n models: GOOGLE_VERTEX_FALLBACK_MODELS,\n };\n console.warn(\n 'Failed to fetch live Google Vertex models, using fallback list:',\n error instanceof Error ? error.message : error,\n );\n return GOOGLE_VERTEX_FALLBACK_MODELS;\n } finally {\n clearTimeout(timer);\n inflightFetch = null;\n }\n })();\n\n return inflightFetch;\n}\n"],"mappings":";AAAA,MAAM,qBAAqB;AAC3B,MAAM,4BAA4B;AAClC,MAAM,iBAAiB;AACvB,MAAM,yBAAyB;AAC/B,MAAM,2BAA2B;AAMjC,MAAM,gCAA0D,CAAC,EAAE,IAAI,mBAAmB,CAAC;AAQ3F,IAAI,eAAyC;AAC7C,IAAI,gBAA0D;AAE9D,SAAgB,gCAAsC;CACpD,eAAe;CACf,gBAAgB;AAClB;AAEA,eAAe,wBAAwB,QAAwD;CAC7F,MAAM,WAAW,MAAM,MAAM,oBAAoB,EAAE,OAAO,CAAC;CAC3D,IAAI,CAAC,SAAS,IACZ,MAAM,IAAI,MAAM,uBAAuB,SAAS,QAAQ;CAE1D,MAAM,OAAQ,MAAM,SAAS,KAAK;CAClC,MAAM,SAAS,OAAO,KAAK,KAAK,0BAA0B,EAAE,UAAU,CAAC,CAAC,CAAC,CACtE,KAAK,CAAC,CACN,KAAI,QAAO,EAAE,GAAG,EAAE;CACrB,IAAI,OAAO,WAAW,GACpB,MAAM,IAAI,MAAM,6CAA6C;CAE/D,OAAO;AACT;AAEA,eAAsB,8BAAiE;CAErF,IAAI,gBADQ,KAAK,IACK,IAAI,aAAa,YAAY,aAAa,KAC9D,OAAO,aAAa;CAEtB,IAAI,eAAe,OAAO;CAE1B,iBAAiB,YAAY;EAC3B,MAAM,aAAa,IAAI,gBAAgB;EACvC,MAAM,QAAQ,iBAAiB,WAAW,MAAM,GAAG,wBAAwB;EAC3E,IAAI;GACF,MAAM,SAAS,MAAM,wBAAwB,WAAW,MAAM;GAC9D,eAAe;IAAE,WAAW,KAAK,IAAI;IAAG,KAAK;IAAgB;GAAO;GACpE,OAAO;EACT,SAAS,OAAO;GACd,eAAe;IACb,WAAW,KAAK,IAAI;IACpB,KAAK;IACL,QAAQ;GACV;GACA,QAAQ,KACN,mEACA,iBAAiB,QAAQ,MAAM,UAAU,KAC3C;GACA,OAAO;EACT,UAAU;GACR,aAAa,KAAK;GAClB,gBAAgB;EAClB;CACF,EAAA,CAAG;CAEH,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/code-sdk",
3
- "version": "1.18.0-alpha.1",
3
+ "version": "1.18.0-alpha.2",
4
4
  "description": "Mastra Code SDK: the agent core behind Mastra Code (everything except the TUI) — build your own UIs and surfaces on top of it",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -48,6 +48,7 @@
48
48
  "@agentclientprotocol/sdk": "^0.21.1",
49
49
  "@ai-sdk/amazon-bedrock": "^5.0.125",
50
50
  "@ai-sdk/anthropic": "^3.0.135",
51
+ "@ai-sdk/google-vertex": "^3.0.185",
51
52
  "@ai-sdk/openai": "^3.0.132",
52
53
  "@ai-sdk/openai-compatible": "^2.0.87",
53
54
  "@ast-grep/napi": "^0.42.3",
@@ -63,16 +64,16 @@
63
64
  "yaml": "^2.9.1",
64
65
  "zod": "^4.6.7",
65
66
  "@mastra/agent-browser": "0.6.0",
66
- "@mastra/client-js": "1.59.0-alpha.1",
67
- "@mastra/duckdb": "1.18.0-alpha.0",
67
+ "@mastra/client-js": "1.59.0-alpha.2",
68
+ "@mastra/duckdb": "1.18.0-alpha.1",
68
69
  "@mastra/fastembed": "1.3.6",
69
70
  "@mastra/github-signals": "0.5.2",
70
- "@mastra/libsql": "1.29.0-alpha.0",
71
- "@mastra/mcp": "2.8.0-alpha.0",
72
- "@mastra/memory": "1.41.0-alpha.1",
73
- "@mastra/observability": "1.23.1-alpha.0",
74
- "@mastra/parallel": "0.1.4",
75
- "@mastra/pg": "1.35.0-alpha.1",
71
+ "@mastra/libsql": "1.29.0-alpha.1",
72
+ "@mastra/mcp": "2.8.0-alpha.1",
73
+ "@mastra/memory": "1.41.0-alpha.2",
74
+ "@mastra/observability": "1.23.1-alpha.1",
75
+ "@mastra/parallel": "0.1.5-alpha.0",
76
+ "@mastra/pg": "1.35.0-alpha.2",
76
77
  "@mastra/schema-compat": "1.3.17",
77
78
  "@mastra/stagehand": "0.4.0",
78
79
  "@mastra/tavily": "1.1.3"
@@ -89,7 +90,7 @@
89
90
  "@internal/lint": "0.0.147",
90
91
  "@internal/types-builder": "0.0.122",
91
92
  "@internal/workspace-test-utils": "0.0.91",
92
- "@mastra/core": "1.82.0-alpha.1"
93
+ "@mastra/core": "1.82.0-alpha.2"
93
94
  },
94
95
  "peerDependencies": {
95
96
  "@mastra/core": ">=1.81.0-0 <2.0.0-0"