@mastra/code-sdk 1.7.0-alpha.6 → 1.7.0-alpha.8

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.
@@ -1 +1 @@
1
- {"version":3,"file":"amazon-bedrock.d.ts","sourceRoot":"","sources":["../../src/providers/amazon-bedrock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;CACZ;AAsBD,8DAA8D;AAC9D,wBAAgB,wBAAwB,IAAI,IAAI,CAG/C;AAeD;;;;;;;;;;GAUG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAiC3E"}
1
+ {"version":3,"file":"amazon-bedrock.d.ts","sourceRoot":"","sources":["../../src/providers/amazon-bedrock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;CACZ;AAyDD,8DAA8D;AAC9D,wBAAgB,wBAAwB,IAAI,IAAI,CAG/C;AAiBD;;;;;;;;;;GAUG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAiC3E"}
@@ -15,6 +15,25 @@ const CATALOG_TTL_MS = 3600 * 1e3;
15
15
  const CATALOG_FAILURE_TTL_MS = 60 * 1e3;
16
16
  const CATALOG_FETCH_TIMEOUT_MS = 5e3;
17
17
  /**
18
+ * True when the catalog entry asks for a transport this catalog cannot serve.
19
+ *
20
+ * Every id returned here is handed to `createAmazonBedrock()(modelId)` by
21
+ * `amazon-bedrock-gateway.ts`, i.e. the Converse API, unconditionally. A
22
+ * `provider` override in the catalog means the model wants a different endpoint
23
+ * and API shape: the nine `bedrock-mantle` models point at
24
+ * `https://bedrock-mantle.${AWS_REGION}.api.aws/openai/v1` with
25
+ * `shape: "responses"`. Advertising them makes them selectable in `/models` and
26
+ * in packs even though the request that follows cannot reach them.
27
+ *
28
+ * Filtering is deliberately conservative: it hides what is currently unusable
29
+ * rather than guessing at a transport. Routing these to Mantle properly is a
30
+ * separate change and a design call for the maintainers.
31
+ */
32
+ function needsUnsupportedTransport(entry) {
33
+ const provider = entry?.provider;
34
+ return Boolean(provider && (provider.npm || provider.api || provider.shape));
35
+ }
36
+ /**
18
37
  * A small, stable fallback so Bedrock packs keep working offline or when
19
38
  * models.dev is unreachable. Intentionally minimal — the live catalog is the
20
39
  * source of truth and supersedes this within one fetch.
@@ -35,7 +54,7 @@ async function fetchBedrockModels(signal) {
35
54
  const response = await fetch(MODELS_DEV_API_URL, { signal });
36
55
  if (!response.ok) throw new Error(`models.dev returned ${response.status}`);
37
56
  const models = (await response.json())[BEDROCK_PROVIDER_ID]?.models ?? {};
38
- return Object.keys(models).sort().map((id) => ({ id }));
57
+ return Object.entries(models).filter(([, entry]) => !needsUnsupportedTransport(entry)).map(([id]) => id).sort().map((id) => ({ id }));
39
58
  }
40
59
  /**
41
60
  * Return the available Amazon Bedrock models.
@@ -1 +1 @@
1
- {"version":3,"file":"amazon-bedrock.js","names":[],"sources":["../../src/providers/amazon-bedrock.ts"],"sourcesContent":["/**\n * Amazon Bedrock model catalog.\n *\n * Bedrock is not part of mastracode's gateway-synced model router (it\n * authenticates with AWS SigV4 rather than an API key / base URL, so it is\n * resolved directly in `agents/model.ts`). To still offer Bedrock models in the\n * `/models` picker and packs, we fetch the public models.dev catalog — the same\n * source the model router uses — and expose the `amazon-bedrock` provider's\n * model list. This mirrors the GitHub Copilot catalog approach.\n */\n\nconst MODELS_DEV_API_URL = 'https://models.dev/api.json';\nconst BEDROCK_PROVIDER_ID = 'amazon-bedrock';\n\nconst CATALOG_TTL_MS = 60 * 60 * 1000;\nconst CATALOG_FAILURE_TTL_MS = 60 * 1000;\nconst CATALOG_FETCH_TIMEOUT_MS = 5_000;\n\nexport interface BedrockModelEntry {\n id: string;\n}\n\n/**\n * A small, stable fallback so Bedrock packs keep working offline or when\n * models.dev is unreachable. Intentionally minimal — the live catalog is the\n * source of truth and supersedes this within one fetch.\n */\nconst BEDROCK_FALLBACK_MODELS: BedrockModelEntry[] = [\n { id: 'us.anthropic.claude-opus-4-6-v1' },\n { id: 'us.anthropic.claude-sonnet-4-5-20250929-v1:0' },\n { id: 'us.anthropic.claude-haiku-4-5-20251001-v1:0' },\n];\n\ninterface CatalogCacheEntry {\n fetchedAt: number;\n ttl: number;\n models: BedrockModelEntry[];\n}\n\nlet catalogCache: CatalogCacheEntry | null = null;\nlet inflightFetch: Promise<BedrockModelEntry[]> | null = null;\n\n/** Reset the in-process Bedrock catalog cache (test seam). */\nexport function clearBedrockCatalogCache(): void {\n catalogCache = null;\n inflightFetch = null;\n}\n\nasync function fetchBedrockModels(signal: AbortSignal): Promise<BedrockModelEntry[]> {\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 provider = data[BEDROCK_PROVIDER_ID];\n const models = provider?.models ?? {};\n return Object.keys(models)\n .sort()\n .map(id => ({ id }));\n}\n\n/**\n * Return the available Amazon Bedrock models.\n *\n * - Returns the cached list when a recent fetch succeeded.\n * - On cache miss / expiry, fetches the models.dev catalog with a 5s timeout and\n * caches it for an hour.\n * - On fetch failure, returns a small hard-coded fallback (so packs still work\n * offline) and caches that briefly to avoid hammering the network.\n *\n * Concurrent calls during a fetch share the inflight promise.\n */\nexport async function getBedrockModelCatalog(): Promise<BedrockModelEntry[]> {\n const now = Date.now();\n if (catalogCache && now - catalogCache.fetchedAt < catalogCache.ttl) {\n return catalogCache.models;\n }\n\n if (inflightFetch) return inflightFetch;\n\n inflightFetch = (async (): Promise<BedrockModelEntry[]> => {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), CATALOG_FETCH_TIMEOUT_MS);\n try {\n const models = await fetchBedrockModels(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: BEDROCK_FALLBACK_MODELS,\n };\n console.warn(\n 'Failed to fetch live Amazon Bedrock models, using fallback list:',\n error instanceof Error ? error.message : error,\n );\n return BEDROCK_FALLBACK_MODELS;\n } finally {\n clearTimeout(timer);\n inflightFetch = null;\n }\n })();\n\n return inflightFetch;\n}\n"],"mappings":";;;;;;;;;;;AAWA,MAAM,qBAAqB;AAC3B,MAAM,sBAAsB;AAE5B,MAAM,iBAAiB,OAAU;AACjC,MAAM,yBAAyB,KAAK;AACpC,MAAM,2BAA2B;;;;;;AAWjC,MAAM,0BAA+C;CACnD,EAAE,IAAI,kCAAkC;CACxC,EAAE,IAAI,+CAA+C;CACrD,EAAE,IAAI,8CAA8C;AACtD;AAQA,IAAI,eAAyC;AAC7C,IAAI,gBAAqD;;AAGzD,SAAgB,2BAAiC;CAC/C,eAAe;CACf,gBAAgB;AAClB;AAEA,eAAe,mBAAmB,QAAmD;CACnF,MAAM,WAAW,MAAM,MAAM,oBAAoB,EAAE,OAAO,CAAC;CAC3D,IAAI,CAAC,SAAS,IACZ,MAAM,IAAI,MAAM,uBAAuB,SAAS,QAAQ;CAI1D,MAAM,UADW,MADG,SAAS,KAAK,EAAA,CACZ,oBACC,EAAE,UAAU,CAAC;CACpC,OAAO,OAAO,KAAK,MAAM,CAAC,CACvB,KAAK,CAAC,CACN,KAAI,QAAO,EAAE,GAAG,EAAE;AACvB;;;;;;;;;;;;AAaA,eAAsB,yBAAuD;CAE3E,IAAI,gBADQ,KAAK,IACK,IAAI,aAAa,YAAY,aAAa,KAC9D,OAAO,aAAa;CAGtB,IAAI,eAAe,OAAO;CAE1B,iBAAiB,YAA0C;EACzD,MAAM,aAAa,IAAI,gBAAgB;EACvC,MAAM,QAAQ,iBAAiB,WAAW,MAAM,GAAG,wBAAwB;EAC3E,IAAI;GACF,MAAM,SAAS,MAAM,mBAAmB,WAAW,MAAM;GACzD,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,oEACA,iBAAiB,QAAQ,MAAM,UAAU,KAC3C;GACA,OAAO;EACT,UAAU;GACR,aAAa,KAAK;GAClB,gBAAgB;EAClB;CACF,EAAA,CAAG;CAEH,OAAO;AACT"}
1
+ {"version":3,"file":"amazon-bedrock.js","names":[],"sources":["../../src/providers/amazon-bedrock.ts"],"sourcesContent":["/**\n * Amazon Bedrock model catalog.\n *\n * Bedrock is not part of mastracode's gateway-synced model router (it\n * authenticates with AWS SigV4 rather than an API key / base URL, so it is\n * resolved directly in `agents/model.ts`). To still offer Bedrock models in the\n * `/models` picker and packs, we fetch the public models.dev catalog — the same\n * source the model router uses — and expose the `amazon-bedrock` provider's\n * model list. This mirrors the GitHub Copilot catalog approach.\n */\n\nconst MODELS_DEV_API_URL = 'https://models.dev/api.json';\nconst BEDROCK_PROVIDER_ID = 'amazon-bedrock';\n\nconst CATALOG_TTL_MS = 60 * 60 * 1000;\nconst CATALOG_FAILURE_TTL_MS = 60 * 1000;\nconst CATALOG_FETCH_TIMEOUT_MS = 5_000;\n\nexport interface BedrockModelEntry {\n id: string;\n}\n\n/**\n * A models.dev catalog entry for one Bedrock model.\n *\n * Most entries carry no `provider` block: they are served by the SigV4\n * `bedrock-runtime` Converse API, which is what this catalog feeds. An entry\n * that *does* carry one is overriding that transport.\n */\ninterface BedrockCatalogEntry {\n provider?: {\n npm?: string;\n api?: string;\n shape?: string;\n };\n}\n\n/**\n * True when the catalog entry asks for a transport this catalog cannot serve.\n *\n * Every id returned here is handed to `createAmazonBedrock()(modelId)` by\n * `amazon-bedrock-gateway.ts`, i.e. the Converse API, unconditionally. A\n * `provider` override in the catalog means the model wants a different endpoint\n * and API shape: the nine `bedrock-mantle` models point at\n * `https://bedrock-mantle.${AWS_REGION}.api.aws/openai/v1` with\n * `shape: \"responses\"`. Advertising them makes them selectable in `/models` and\n * in packs even though the request that follows cannot reach them.\n *\n * Filtering is deliberately conservative: it hides what is currently unusable\n * rather than guessing at a transport. Routing these to Mantle properly is a\n * separate change and a design call for the maintainers.\n */\nfunction needsUnsupportedTransport(entry: unknown): boolean {\n const provider = (entry as BedrockCatalogEntry | null)?.provider;\n return Boolean(provider && (provider.npm || provider.api || provider.shape));\n}\n\n/**\n * A small, stable fallback so Bedrock packs keep working offline or when\n * models.dev is unreachable. Intentionally minimal — the live catalog is the\n * source of truth and supersedes this within one fetch.\n */\nconst BEDROCK_FALLBACK_MODELS: BedrockModelEntry[] = [\n { id: 'us.anthropic.claude-opus-4-6-v1' },\n { id: 'us.anthropic.claude-sonnet-4-5-20250929-v1:0' },\n { id: 'us.anthropic.claude-haiku-4-5-20251001-v1:0' },\n];\n\ninterface CatalogCacheEntry {\n fetchedAt: number;\n ttl: number;\n models: BedrockModelEntry[];\n}\n\nlet catalogCache: CatalogCacheEntry | null = null;\nlet inflightFetch: Promise<BedrockModelEntry[]> | null = null;\n\n/** Reset the in-process Bedrock catalog cache (test seam). */\nexport function clearBedrockCatalogCache(): void {\n catalogCache = null;\n inflightFetch = null;\n}\n\nasync function fetchBedrockModels(signal: AbortSignal): Promise<BedrockModelEntry[]> {\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 provider = data[BEDROCK_PROVIDER_ID];\n const models = provider?.models ?? {};\n return Object.entries(models)\n .filter(([, entry]) => !needsUnsupportedTransport(entry))\n .map(([id]) => id)\n .sort()\n .map(id => ({ id }));\n}\n\n/**\n * Return the available Amazon Bedrock models.\n *\n * - Returns the cached list when a recent fetch succeeded.\n * - On cache miss / expiry, fetches the models.dev catalog with a 5s timeout and\n * caches it for an hour.\n * - On fetch failure, returns a small hard-coded fallback (so packs still work\n * offline) and caches that briefly to avoid hammering the network.\n *\n * Concurrent calls during a fetch share the inflight promise.\n */\nexport async function getBedrockModelCatalog(): Promise<BedrockModelEntry[]> {\n const now = Date.now();\n if (catalogCache && now - catalogCache.fetchedAt < catalogCache.ttl) {\n return catalogCache.models;\n }\n\n if (inflightFetch) return inflightFetch;\n\n inflightFetch = (async (): Promise<BedrockModelEntry[]> => {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), CATALOG_FETCH_TIMEOUT_MS);\n try {\n const models = await fetchBedrockModels(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: BEDROCK_FALLBACK_MODELS,\n };\n console.warn(\n 'Failed to fetch live Amazon Bedrock models, using fallback list:',\n error instanceof Error ? error.message : error,\n );\n return BEDROCK_FALLBACK_MODELS;\n } finally {\n clearTimeout(timer);\n inflightFetch = null;\n }\n })();\n\n return inflightFetch;\n}\n"],"mappings":";;;;;;;;;;;AAWA,MAAM,qBAAqB;AAC3B,MAAM,sBAAsB;AAE5B,MAAM,iBAAiB,OAAU;AACjC,MAAM,yBAAyB,KAAK;AACpC,MAAM,2BAA2B;;;;;;;;;;;;;;;;AAoCjC,SAAS,0BAA0B,OAAyB;CAC1D,MAAM,WAAY,OAAsC;CACxD,OAAO,QAAQ,aAAa,SAAS,OAAO,SAAS,OAAO,SAAS,MAAM;AAC7E;;;;;;AAOA,MAAM,0BAA+C;CACnD,EAAE,IAAI,kCAAkC;CACxC,EAAE,IAAI,+CAA+C;CACrD,EAAE,IAAI,8CAA8C;AACtD;AAQA,IAAI,eAAyC;AAC7C,IAAI,gBAAqD;;AAGzD,SAAgB,2BAAiC;CAC/C,eAAe;CACf,gBAAgB;AAClB;AAEA,eAAe,mBAAmB,QAAmD;CACnF,MAAM,WAAW,MAAM,MAAM,oBAAoB,EAAE,OAAO,CAAC;CAC3D,IAAI,CAAC,SAAS,IACZ,MAAM,IAAI,MAAM,uBAAuB,SAAS,QAAQ;CAI1D,MAAM,UADW,MADG,SAAS,KAAK,EAAA,CACZ,oBACC,EAAE,UAAU,CAAC;CACpC,OAAO,OAAO,QAAQ,MAAM,CAAC,CAC1B,QAAQ,GAAG,WAAW,CAAC,0BAA0B,KAAK,CAAC,CAAC,CACxD,KAAK,CAAC,QAAQ,EAAE,CAAC,CACjB,KAAK,CAAC,CACN,KAAI,QAAO,EAAE,GAAG,EAAE;AACvB;;;;;;;;;;;;AAaA,eAAsB,yBAAuD;CAE3E,IAAI,gBADQ,KAAK,IACK,IAAI,aAAa,YAAY,aAAa,KAC9D,OAAO,aAAa;CAGtB,IAAI,eAAe,OAAO;CAE1B,iBAAiB,YAA0C;EACzD,MAAM,aAAa,IAAI,gBAAgB;EACvC,MAAM,QAAQ,iBAAiB,WAAW,MAAM,GAAG,wBAAwB;EAC3E,IAAI;GACF,MAAM,SAAS,MAAM,mBAAmB,WAAW,MAAM;GACzD,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,oEACA,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.7.0-alpha.6",
3
+ "version": "1.7.0-alpha.8",
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": {
@@ -58,17 +58,17 @@
58
58
  "zod": "^4.3.6",
59
59
  "@mastra/agent-browser": "0.5.2",
60
60
  "@mastra/duckdb": "1.7.0-alpha.1",
61
- "@mastra/core": "1.65.0-alpha.5",
62
61
  "@mastra/fastembed": "1.3.1",
63
62
  "@mastra/libsql": "1.22.4-alpha.0",
64
63
  "@mastra/github-signals": "0.4.0",
65
64
  "@mastra/mcp": "1.17.3",
66
- "@mastra/observability": "1.17.6-alpha.1",
67
65
  "@mastra/memory": "1.28.3-alpha.2",
66
+ "@mastra/observability": "1.17.6-alpha.1",
68
67
  "@mastra/parallel": "0.1.1",
69
- "@mastra/pg": "1.23.0-alpha.1",
68
+ "@mastra/pg": "1.23.0-alpha.2",
70
69
  "@mastra/schema-compat": "1.3.8",
71
70
  "@mastra/stagehand": "0.3.4",
71
+ "@mastra/core": "1.65.0-alpha.7",
72
72
  "@mastra/tavily": "1.1.2"
73
73
  },
74
74
  "devDependencies": {