mastracode 0.15.0-alpha.9 → 0.15.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,92 @@
1
1
  # mastracode
2
2
 
3
+ ## 0.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added `--output-format` flag to headless mode, accepting `text`, `json`, and `stream-json` for automation and CI use cases. Coexists with all existing headless flags. ([#15423](https://github.com/mastra-ai/mastra/pull/15423))
8
+
9
+ - Added share and import features for model packs. You can now share a custom model pack configuration by copying it to the clipboard, and import a shared pack from someone else using the new Import Pack option in the /models command. ([#15370](https://github.com/mastra-ai/mastra/pull/15370))
10
+
11
+ - Added `--model`, `--mode`, `--thinking-level`, and `--settings` CLI flags to headless mode for controlling model selection, execution mode, and thinking level without interactive TUI. Uses the same `settings.json` as the interactive TUI — pass `--settings <path>` for CI or other environments, or omit to use the default global settings. Added `settingsPath` option to `createMastraCode()` for programmatic use. ([#14909](https://github.com/mastra-ai/mastra/pull/14909))
12
+
13
+ - Added the `@mastra/tavily` integration with first-class Mastra tools for Tavily web search, extract, crawl, and map APIs, and migrated `mastracode`'s web search tools to use it. ([#15448](https://github.com/mastra-ai/mastra/pull/15448))
14
+
15
+ ### Patch Changes
16
+
17
+ - Improved observational memory activation output in MastraCode. ([#15365](https://github.com/mastra-ai/mastra/pull/15365))
18
+
19
+ **What changed**
20
+ - Added a separate Observation TTL line when buffered context activates after inactivity
21
+ - Removed repeated TTL text from each activation line so grouped activations are easier to scan
22
+
23
+ This makes long idle-thread activations much easier to read in the terminal.
24
+
25
+ - Fix API key resolution to check stored key slot and env vars. ([#15483](https://github.com/mastra-ai/mastra/pull/15483))
26
+
27
+ `getAnthropicApiKey()` and `getOpenAIApiKey()` now check `authStorage.getStoredApiKey()` and `process.env` in addition to the main credential slot. Fixes API keys becoming invisible to `resolveModel` after OAuth connect/disconnect cycles.
28
+
29
+ - Fixed the observational memory reflection activation label in MastraCode so it describes the actual change to the observation pool. ([#15462](https://github.com/mastra-ai/mastra/pull/15462))
30
+
31
+ Reflection activations now render as `before → after obs tokens (-delta)` instead of implying that message tokens were removed. Observation activations still use the existing `-X msg tokens, +Y obs tokens` format.
32
+
33
+ - Fixed a security issue where several parsing and tracing paths could slow down on malformed or attacker-crafted input. Normal behavior is unchanged, and these packages now handle pathological input in linear time. ([#15566](https://github.com/mastra-ai/mastra/pull/15566))
34
+
35
+ - Updated the default Anthropic mode pack models. Users signed in with an Anthropic Max subscription now get `claude-opus-4-7` for `build` and `plan`, and API-key users get `claude-sonnet-4-6` for `build` and `plan`. The `fast` model is unchanged. ([#15458](https://github.com/mastra-ai/mastra/pull/15458))
36
+
37
+ - Improved observational memory activation output to show when a provider or model switch triggered buffered observation activation. ([#15420](https://github.com/mastra-ai/mastra/pull/15420))
38
+
39
+ - Updated dependencies [[`20f59b8`](https://github.com/mastra-ai/mastra/commit/20f59b876cf91199efbc49a0e36b391240708f08), [`aba393e`](https://github.com/mastra-ai/mastra/commit/aba393e2da7390c69b80e516a4f153cda6f09376), [`3d83d06`](https://github.com/mastra-ai/mastra/commit/3d83d06f776f00fb5f4163dddd32a030c5c20844), [`e2687a7`](https://github.com/mastra-ai/mastra/commit/e2687a7408790c384563816a9a28ed06735684c9), [`fdd54cf`](https://github.com/mastra-ai/mastra/commit/fdd54cf612a9af876e9fdd85e534454f6e7dd518), [`d63ffdb`](https://github.com/mastra-ai/mastra/commit/d63ffdbb2c11e76fe5ea45faab44bc15460f010c), [`6315317`](https://github.com/mastra-ai/mastra/commit/63153175fe9a7b224e5be7c209bbebc01dd9b0d5), [`a371ac5`](https://github.com/mastra-ai/mastra/commit/a371ac534aa1bb368a1acf9d8b313378dfdc787e), [`0474c2b`](https://github.com/mastra-ai/mastra/commit/0474c2b2e7c7e1ad8691dca031284841391ff1ef), [`f607106`](https://github.com/mastra-ai/mastra/commit/f607106854c6416c4a07d4082604b9f66d047221), [`0a5fa1d`](https://github.com/mastra-ai/mastra/commit/0a5fa1d3cb0583889d06687155f26fd7d2edc76c), [`7e0e63e`](https://github.com/mastra-ai/mastra/commit/7e0e63e2e485e84442351f4c7a79a424c83539dc), [`ea43e64`](https://github.com/mastra-ai/mastra/commit/ea43e646dd95d507694b6112b0bf1df22ad552b2), [`f607106`](https://github.com/mastra-ai/mastra/commit/f607106854c6416c4a07d4082604b9f66d047221), [`30456b6`](https://github.com/mastra-ai/mastra/commit/30456b6b08c8fd17e109dd093b73d93b65e83bc5), [`9d11a8c`](https://github.com/mastra-ai/mastra/commit/9d11a8c1c8924eb975a245a5884d40ca1b7e0491), [`3a347a9`](https://github.com/mastra-ai/mastra/commit/3a347a95c563df027d082bcc82ddc31b88410744), [`2ca2d23`](https://github.com/mastra-ai/mastra/commit/2ca2d23913dec4e6cb0fa8e8eecb1184af7ccd81), [`9d3b24b`](https://github.com/mastra-ai/mastra/commit/9d3b24b19407ae9c09586cf7766d38dc4dff4a69), [`7020c06`](https://github.com/mastra-ai/mastra/commit/7020c0690b199d9da337f0e805f16948e557922e), [`00d1b16`](https://github.com/mastra-ai/mastra/commit/00d1b16b401199cb294fa23f43336547db4dca9b), [`47cee3e`](https://github.com/mastra-ai/mastra/commit/47cee3e137fe39109cf7fffd2a8cf47b76dc702e), [`62919a6`](https://github.com/mastra-ai/mastra/commit/62919a6ee0fbf3779ad21a97b1ec6696515d5104), [`d246696`](https://github.com/mastra-ai/mastra/commit/d246696139a3144a5b21b042d41c532688e957e1), [`354f9ce`](https://github.com/mastra-ai/mastra/commit/354f9ce1ca6af2074b6a196a23f8ec30012dccca), [`16e34ca`](https://github.com/mastra-ai/mastra/commit/16e34caa98b9a114b17a6125e4e3fd87f169d0d0), [`7020c06`](https://github.com/mastra-ai/mastra/commit/7020c0690b199d9da337f0e805f16948e557922e), [`8786a61`](https://github.com/mastra-ai/mastra/commit/8786a61fa54ba265f85eeff9985ca39863d18bb6), [`9467ea8`](https://github.com/mastra-ai/mastra/commit/9467ea87695749a53dfc041576410ebf9ee7bb67), [`7338d94`](https://github.com/mastra-ai/mastra/commit/7338d949380cf68b095342e8e42610dc51d557c1), [`c80dc16`](https://github.com/mastra-ai/mastra/commit/c80dc16e113e6cc159f510ffde501ad4711b2189), [`af8a57e`](https://github.com/mastra-ai/mastra/commit/af8a57ed9ba9685ad8601d5b71ae3706da6222f9), [`d63ffdb`](https://github.com/mastra-ai/mastra/commit/d63ffdbb2c11e76fe5ea45faab44bc15460f010c), [`c79dde7`](https://github.com/mastra-ai/mastra/commit/c79dde70a89398301e9d46a901807f5892b10909), [`47cee3e`](https://github.com/mastra-ai/mastra/commit/47cee3e137fe39109cf7fffd2a8cf47b76dc702e), [`1bd5104`](https://github.com/mastra-ai/mastra/commit/1bd51048b6da93507276d6623e3fd96a9e1a8944), [`ad0d3e8`](https://github.com/mastra-ai/mastra/commit/ad0d3e80db7472a73e26d3516c04df0513c2c189), [`e9837b5`](https://github.com/mastra-ai/mastra/commit/e9837b53699e18711b09e0ca010a4106376f2653), [`c65aec3`](https://github.com/mastra-ai/mastra/commit/c65aec356cc037ee7c4b30ccea946807d4c4f443), [`8f1b280`](https://github.com/mastra-ai/mastra/commit/8f1b280b7fe6999ec654f160cb69c1a8719e7a57), [`92dcf02`](https://github.com/mastra-ai/mastra/commit/92dcf029294210ac91b090900c1a0555a425c57a), [`0fd90a2`](https://github.com/mastra-ai/mastra/commit/0fd90a215caf5fca8099c15a67ca03e4427747a3), [`0fd90a2`](https://github.com/mastra-ai/mastra/commit/0fd90a215caf5fca8099c15a67ca03e4427747a3), [`8fb2405`](https://github.com/mastra-ai/mastra/commit/8fb2405138f2d208b7962ad03f121ca25bcc28c5), [`12df98c`](https://github.com/mastra-ai/mastra/commit/12df98c4904643d9481f5c78f3bed443725b4c96)]:
40
+ - @mastra/core@1.26.0
41
+ - @mastra/pg@1.9.2
42
+ - @mastra/libsql@1.9.0
43
+ - @mastra/memory@1.16.0
44
+ - @mastra/tavily@1.0.0
45
+ - @mastra/mcp@1.5.1
46
+
47
+ ## 0.15.0-alpha.13
48
+
49
+ ### Patch Changes
50
+
51
+ - Updated dependencies:
52
+ - @mastra/core@1.26.0-alpha.13
53
+
54
+ ## 0.15.0-alpha.12
55
+
56
+ ### Minor Changes
57
+
58
+ - Added the `@mastra/tavily` integration with first-class Mastra tools for Tavily web search, extract, crawl, and map APIs, and migrated `mastracode`'s web search tools to use it. ([#15448](https://github.com/mastra-ai/mastra/pull/15448))
59
+
60
+ ### Patch Changes
61
+
62
+ - Updated dependencies [[`a371ac5`](https://github.com/mastra-ai/mastra/commit/a371ac534aa1bb368a1acf9d8b313378dfdc787e), [`3a347a9`](https://github.com/mastra-ai/mastra/commit/3a347a95c563df027d082bcc82ddc31b88410744), [`2ca2d23`](https://github.com/mastra-ai/mastra/commit/2ca2d23913dec4e6cb0fa8e8eecb1184af7ccd81), [`47cee3e`](https://github.com/mastra-ai/mastra/commit/47cee3e137fe39109cf7fffd2a8cf47b76dc702e), [`c80dc16`](https://github.com/mastra-ai/mastra/commit/c80dc16e113e6cc159f510ffde501ad4711b2189), [`47cee3e`](https://github.com/mastra-ai/mastra/commit/47cee3e137fe39109cf7fffd2a8cf47b76dc702e)]:
63
+ - @mastra/core@1.26.0-alpha.12
64
+ - @mastra/memory@1.16.0-alpha.4
65
+ - @mastra/tavily@1.0.0-alpha.1
66
+
67
+ ## 0.15.0-alpha.11
68
+
69
+ ### Patch Changes
70
+
71
+ - Updated dependencies [[`20f59b8`](https://github.com/mastra-ai/mastra/commit/20f59b876cf91199efbc49a0e36b391240708f08), [`e2687a7`](https://github.com/mastra-ai/mastra/commit/e2687a7408790c384563816a9a28ed06735684c9), [`ad0d3e8`](https://github.com/mastra-ai/mastra/commit/ad0d3e80db7472a73e26d3516c04df0513c2c189), [`8f1b280`](https://github.com/mastra-ai/mastra/commit/8f1b280b7fe6999ec654f160cb69c1a8719e7a57), [`12df98c`](https://github.com/mastra-ai/mastra/commit/12df98c4904643d9481f5c78f3bed443725b4c96)]:
72
+ - @mastra/core@1.26.0-alpha.11
73
+ - @mastra/libsql@1.9.0-alpha.2
74
+ - @mastra/pg@1.9.2-alpha.1
75
+
76
+ ## 0.15.0-alpha.10
77
+
78
+ ### Minor Changes
79
+
80
+ - Added `--output-format` flag to headless mode, accepting `text`, `json`, and `stream-json` for automation and CI use cases. Coexists with all existing headless flags. ([#15423](https://github.com/mastra-ai/mastra/pull/15423))
81
+
82
+ ### Patch Changes
83
+
84
+ - Fixed a security issue where several parsing and tracing paths could slow down on malformed or attacker-crafted input. Normal behavior is unchanged, and these packages now handle pathological input in linear time. ([#15566](https://github.com/mastra-ai/mastra/pull/15566))
85
+
86
+ - Updated dependencies [[`aba393e`](https://github.com/mastra-ai/mastra/commit/aba393e2da7390c69b80e516a4f153cda6f09376), [`0a5fa1d`](https://github.com/mastra-ai/mastra/commit/0a5fa1d3cb0583889d06687155f26fd7d2edc76c), [`ea43e64`](https://github.com/mastra-ai/mastra/commit/ea43e646dd95d507694b6112b0bf1df22ad552b2), [`00d1b16`](https://github.com/mastra-ai/mastra/commit/00d1b16b401199cb294fa23f43336547db4dca9b), [`af8a57e`](https://github.com/mastra-ai/mastra/commit/af8a57ed9ba9685ad8601d5b71ae3706da6222f9)]:
87
+ - @mastra/core@1.26.0-alpha.10
88
+ - @mastra/memory@1.16.0-alpha.3
89
+
3
90
  ## 0.15.0-alpha.9
4
91
 
5
92
  ### Patch Changes
@@ -6,8 +6,7 @@ import { taskCheckTool, taskWriteTool, Harness } from '@mastra/core/harness';
6
6
  import { GatewayRegistry, PROVIDER_REGISTRY, ModelRouterLanguageModel, GATEWAY_AUTH_HEADER, MastraGateway, ModelsDevGateway, NetlifyGateway } from '@mastra/core/llm';
7
7
  import { PrefillErrorHandler, AgentsMDInjector } from '@mastra/core/processors';
8
8
  import { createTool } from '@mastra/core/tools';
9
- import { tavily } from '@tavily/core';
10
- import { z } from 'zod';
9
+ import { createTavilySearchTool, createTavilyExtractTool } from '@mastra/tavily';
11
10
  import { Tiktoken } from 'js-tiktoken/lite';
12
11
  import o200k_base from 'js-tiktoken/ranks/o200k_base';
13
12
  import * as os from 'os';
@@ -15,6 +14,7 @@ import os__default, { homedir } from 'os';
15
14
  import * as path from 'path';
16
15
  import path__default, { normalize, join, dirname } from 'path';
17
16
  import { LocalFilesystem, Workspace, LocalSandbox } from '@mastra/core/workspace';
17
+ import { z } from 'zod';
18
18
  import * as fs3 from 'fs';
19
19
  import fs3__default, { readFileSync, existsSync } from 'fs';
20
20
  import { fileURLToPath } from 'url';
@@ -325,95 +325,56 @@ ${enc.decode(tokens.slice(fromEnd ? -desiredTokenCount : 0, fromEnd ? void 0 : d
325
325
  var MAX_WEB_SEARCH_TOKENS = 2e3;
326
326
  var MAX_WEB_EXTRACT_TOKENS = 2e3;
327
327
  var MIN_RELEVANCE_SCORE = 0.25;
328
- var cachedTavilyClient = null;
329
- function getTavilyClient() {
330
- if (cachedTavilyClient) return cachedTavilyClient;
331
- const apiKey = process.env.TAVILY_API_KEY;
332
- if (!apiKey) return null;
333
- cachedTavilyClient = tavily({ apiKey });
334
- return cachedTavilyClient;
335
- }
336
328
  function hasTavilyKey() {
337
329
  return !!process.env.TAVILY_API_KEY;
338
330
  }
339
331
  function createWebSearchTool() {
332
+ const tavilySearchTool = createTavilySearchTool();
340
333
  return createTool({
341
334
  id: "web-search",
342
- description: "Search the web for information. Use this to find documentation, look up error messages, check package APIs, or research any topic. Returns relevant web results with content snippets and optionally images.",
343
- inputSchema: z.object({
344
- query: z.string().describe("The search query"),
345
- searchDepth: z.enum(["basic", "advanced"]).optional().default("basic").describe("Search depth - 'basic' for quick searches, 'advanced' for more thorough results"),
346
- maxResults: z.number().optional().default(10).describe("Maximum number of results to return"),
347
- includeImages: z.boolean().optional().default(false).describe("Whether to include related images in results")
348
- }),
349
- execute: async (context) => {
350
- const tavilyClient = getTavilyClient();
351
- if (!tavilyClient) {
352
- return "No results (TAVILY_API_KEY not configured)";
335
+ description: tavilySearchTool.description,
336
+ inputSchema: tavilySearchTool.inputSchema,
337
+ execute: async (input, context) => {
338
+ const output = await tavilySearchTool.execute(input, context);
339
+ const parts = [];
340
+ if (output.answer) {
341
+ parts.push(`Answer: ${output.answer}`);
353
342
  }
354
- try {
355
- const response = await tavilyClient.search(context.query, {
356
- searchDepth: context.searchDepth || "basic",
357
- maxResults: context.maxResults || 10,
358
- includeAnswer: true,
359
- includeImages: context.includeImages || false
360
- });
361
- const filteredResults = response.results.filter((r) => (r.score ?? 1) >= MIN_RELEVANCE_SCORE);
362
- const parts = [];
363
- if (response.answer) {
364
- parts.push(`Answer: ${response.answer}`);
365
- }
366
- for (const r of filteredResults) {
367
- parts.push(`## ${r.title}
343
+ const filtered = output.results.filter((r) => (r.score ?? 1) >= MIN_RELEVANCE_SCORE);
344
+ for (const r of filtered) {
345
+ parts.push(`## ${r.title}
368
346
  ${r.url}
369
347
  ${r.content}`);
370
- }
371
- const images = (response.images || []).map((img) => typeof img === "string" ? img : img.url || "").filter(Boolean);
372
- if (images.length > 0) {
373
- parts.push(`Images:
348
+ }
349
+ const images = (output.images || []).map((img) => img.url).filter(Boolean);
350
+ if (images.length > 0) {
351
+ parts.push(`Images:
374
352
  ${images.join("\n")}`);
375
- }
376
- const text = parts.join("\n\n");
377
- return truncateStringForTokenEstimate(text, MAX_WEB_SEARCH_TOKENS);
378
- } catch {
379
- return "No results";
380
353
  }
354
+ const text = parts.join("\n\n");
355
+ return truncateStringForTokenEstimate(text, MAX_WEB_SEARCH_TOKENS);
381
356
  }
382
357
  });
383
358
  }
384
359
  function createWebExtractTool() {
360
+ const tavilyExtractTool = createTavilyExtractTool();
385
361
  return createTool({
386
362
  id: "web-extract",
387
- description: "Extract content from one or more URLs. Use this to read web pages, documentation, articles, or any URL. Returns the raw content in markdown format. You can provide up to 20 URLs at once.",
388
- inputSchema: z.object({
389
- urls: z.array(z.string()).min(1).max(20).describe("URLs to extract content from (max 20)"),
390
- extractDepth: z.enum(["basic", "advanced"]).optional().default("basic").describe("Extraction depth - 'basic' for simple text, 'advanced' for JS-rendered pages"),
391
- includeImages: z.boolean().optional().default(false).describe("Whether to include extracted image URLs")
392
- }),
393
- execute: async (context) => {
394
- const tavilyClient = getTavilyClient();
395
- if (!tavilyClient) {
396
- return "Extraction failed (TAVILY_API_KEY not configured)";
397
- }
398
- try {
399
- const response = await tavilyClient.extract(context.urls, {
400
- extractDepth: context.extractDepth || "basic",
401
- includeImages: context.includeImages || false
402
- });
403
- const parts = [];
404
- for (const r of response.results || []) {
405
- parts.push(`## ${r.url}
363
+ description: tavilyExtractTool.description,
364
+ inputSchema: tavilyExtractTool.inputSchema,
365
+ execute: async (input, context) => {
366
+ const output = await tavilyExtractTool.execute(input, context);
367
+ const parts = [];
368
+ for (const r of output.results) {
369
+ parts.push(`## ${r.url}
406
370
  ${r.rawContent}`);
407
- }
408
- for (const r of response.failedResults || []) {
409
- parts.push(`## ${r.url}
371
+ }
372
+ for (const r of output.failedResults) {
373
+ parts.push(`## ${r.url}
410
374
  Error: ${r.error}`);
411
- }
412
- const text = parts.join("\n\n");
413
- return truncateStringForTokenEstimate(text, MAX_WEB_EXTRACT_TOKENS);
414
- } catch (error) {
415
- return `Extraction failed: ${String(error)}`;
416
375
  }
376
+ const text = parts.join("\n\n");
377
+ return truncateStringForTokenEstimate(text, MAX_WEB_EXTRACT_TOKENS);
417
378
  }
418
379
  });
419
380
  }
@@ -2957,5 +2918,5 @@ async function createMastraCode(config) {
2957
2918
  }
2958
2919
 
2959
2920
  export { createAuthStorage, createMastraCode };
2960
- //# sourceMappingURL=chunk-F2J4KWM7.js.map
2961
- //# sourceMappingURL=chunk-F2J4KWM7.js.map
2921
+ //# sourceMappingURL=chunk-CP3ZSNLI.js.map
2922
+ //# sourceMappingURL=chunk-CP3ZSNLI.js.map