@mastra/code-sdk 1.5.0-alpha.7 → 1.5.0-alpha.9
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 +25 -0
- package/dist/agents/memory.d.ts.map +1 -1
- package/dist/agents/memory.js +35 -32
- package/dist/agents/memory.js.map +1 -1
- package/dist/agents/prompts/index.d.ts.map +1 -1
- package/dist/agents/prompts/index.js +2 -2
- package/dist/agents/prompts/index.js.map +1 -1
- package/dist/agents/tools.d.ts +2 -1
- package/dist/agents/tools.d.ts.map +1 -1
- package/dist/agents/tools.js +4 -5
- package/dist/agents/tools.js.map +1 -1
- package/dist/onboarding/settings.d.ts +9 -0
- package/dist/onboarding/settings.d.ts.map +1 -1
- package/dist/onboarding/settings.js +13 -3
- package/dist/onboarding/settings.js.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +2 -2
- package/dist/tools/web-search.d.ts +81 -2
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +98 -4
- package/dist/tools/web-search.js.map +1 -1
- package/dist/workflows/register-primitives.d.ts +4 -4
- package/dist/workflows/register-primitives.d.ts.map +1 -1
- package/dist/workflows/register-primitives.js +5 -4
- package/dist/workflows/register-primitives.js.map +1 -1
- package/package.json +8 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-search.js","names":[],"sources":["../../src/tools/web-search.ts"],"sourcesContent":["import { createTool } from '@mastra/core/tools';\nimport { createTavilySearchTool, createTavilyExtractTool } from '@mastra/tavily';\n\nimport { truncateStringForTokenEstimate } from '../utils/token-estimator.js';\n\nconst MAX_WEB_SEARCH_TOKENS = 2_000;\nconst MAX_WEB_EXTRACT_TOKENS = 2_000;\n\nconst MIN_RELEVANCE_SCORE = 0.25;\n\n/**\n * Check whether a Tavily API key is available in the environment.\n * Used by main.ts to decide whether to include Tavily tools or fall back\n * to Anthropic's native web search.\n */\nexport function hasTavilyKey(): boolean {\n return !!process.env.TAVILY_API_KEY;\n}\n\n/**\n * Wraps the @mastra/tavily search tool with mastracode-specific behavior:\n * relevance filtering, markdown string formatting, and token truncation.\n * The underlying Tavily tool handles client init, input validation, and the API call.\n */\nexport function createWebSearchTool() {\n const tavilySearchTool = createTavilySearchTool();\n\n return createTool({\n id: 'web-search',\n description: tavilySearchTool.description!,\n inputSchema: tavilySearchTool.inputSchema!,\n execute: async (input, context) => {\n const output: any = await tavilySearchTool.execute!(input as any, context as any);\n\n const parts: string[] = [];\n\n if (output.answer) {\n parts.push(`Answer: ${output.answer}`);\n }\n\n const filtered = output.results.filter((r: any) => (r.score ?? 1) >= MIN_RELEVANCE_SCORE);\n for (const r of filtered) {\n parts.push(`## ${r.title}\\n${r.url}\\n${r.content}`);\n }\n\n const images = (output.images || []).map((img: any) => img.url).filter(Boolean);\n if (images.length > 0) {\n parts.push(`Images:\\n${images.join('\\n')}`);\n }\n\n const text = parts.join('\\n\\n');\n return truncateStringForTokenEstimate(text, MAX_WEB_SEARCH_TOKENS);\n },\n });\n}\n\n/**\n * Wraps the @mastra/tavily extract tool with mastracode-specific behavior:\n * markdown string formatting and token truncation.\n */\nexport function createWebExtractTool() {\n const tavilyExtractTool = createTavilyExtractTool();\n\n return createTool({\n id: 'web-extract',\n description: tavilyExtractTool.description!,\n inputSchema: tavilyExtractTool.inputSchema!,\n execute: async (input, context) => {\n const output: any = await tavilyExtractTool.execute!(input as any, context as any);\n\n const parts: string[] = [];\n\n for (const r of output.results) {\n parts.push(`## ${r.url}\\n${r.rawContent}`);\n }\n\n for (const r of output.failedResults) {\n parts.push(`## ${r.url}\\nError: ${r.error}`);\n }\n\n const text = parts.join('\\n\\n');\n return truncateStringForTokenEstimate(text, MAX_WEB_EXTRACT_TOKENS);\n },\n });\n}\n"],"mappings":";;;;AAKA,MAAM,wBAAwB;AAC9B,MAAM,yBAAyB;AAE/B,MAAM,sBAAsB;;;;;;AAO5B,SA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AC;AACH"}
|
|
1
|
+
{"version":3,"file":"web-search.js","names":[],"sources":["../../src/tools/web-search.ts"],"sourcesContent":["import { createTool, isValidationError, type ValidationError } from '@mastra/core/tools';\nimport { createParallelSearchTool, createParallelExtractTool } from '@mastra/parallel';\nimport { createTavilySearchTool, createTavilyExtractTool } from '@mastra/tavily';\nimport { z } from 'zod';\n\nimport { loadSettings, type WebSearchProviderSetting } from '../onboarding/settings.js';\nimport { truncateStringForTokenEstimate } from '../utils/token-estimator.js';\n\nconst MAX_WEB_SEARCH_TOKENS = 2_000;\nconst MAX_WEB_EXTRACT_TOKENS = 2_000;\n\nconst MIN_RELEVANCE_SCORE = 0.25;\n\nconst parallelWebSearchInputSchema = z.object({\n query: z.string().min(1).describe('The search query'),\n});\n\nfunction requireParallelOutput<T>(output: T | ValidationError | void, operation: 'search' | 'extract'): T {\n if (output === undefined) {\n throw new Error(`Parallel ${operation} returned no output`);\n }\n\n if (isValidationError(output)) {\n throw new Error(output.message);\n }\n\n return output;\n}\n\n/**\n * Check whether a Tavily API key is available in the environment.\n * Used to select model-independent web tools before falling back to\n * model-native web search.\n */\nexport function hasTavilyKey(): boolean {\n return !!process.env.TAVILY_API_KEY;\n}\n\n/** Check whether a Parallel API key is available in the environment. */\nexport function hasParallelKey(): boolean {\n return !!process.env.PARALLEL_API_KEY;\n}\n\n/**\n * Wraps the @mastra/tavily search tool with mastracode-specific behavior:\n * relevance filtering, markdown string formatting, and token truncation.\n * The underlying Tavily tool handles client init, input validation, and the API call.\n */\nexport function createWebSearchTool() {\n const tavilySearchTool = createTavilySearchTool();\n\n return createTool({\n id: 'web-search',\n description: tavilySearchTool.description!,\n inputSchema: tavilySearchTool.inputSchema!,\n execute: async (input, context) => {\n const output: any = await tavilySearchTool.execute!(input as any, context as any);\n\n const parts: string[] = [];\n\n if (output.answer) {\n parts.push(`Answer: ${output.answer}`);\n }\n\n const filtered = output.results.filter((r: any) => (r.score ?? 1) >= MIN_RELEVANCE_SCORE);\n for (const r of filtered) {\n parts.push(`## ${r.title}\\n${r.url}\\n${r.content}`);\n }\n\n const images = (output.images || []).map((img: any) => img.url).filter(Boolean);\n if (images.length > 0) {\n parts.push(`Images:\\n${images.join('\\n')}`);\n }\n\n const text = parts.join('\\n\\n');\n return truncateStringForTokenEstimate(text, MAX_WEB_SEARCH_TOKENS);\n },\n });\n}\n\n/**\n * Wraps the @mastra/tavily extract tool with mastracode-specific behavior:\n * markdown string formatting and token truncation.\n */\nexport function createWebExtractTool() {\n const tavilyExtractTool = createTavilyExtractTool();\n\n return createTool({\n id: 'web-extract',\n description: tavilyExtractTool.description!,\n inputSchema: tavilyExtractTool.inputSchema!,\n execute: async (input, context) => {\n const output: any = await tavilyExtractTool.execute!(input as any, context as any);\n\n const parts: string[] = [];\n\n for (const r of output.results) {\n parts.push(`## ${r.url}\\n${r.rawContent}`);\n }\n\n for (const r of output.failedResults) {\n parts.push(`## ${r.url}\\nError: ${r.error}`);\n }\n\n const text = parts.join('\\n\\n');\n return truncateStringForTokenEstimate(text, MAX_WEB_EXTRACT_TOKENS);\n },\n });\n}\n\n/**\n * Wraps the @mastra/parallel search tool with Mastra Code's standard tool id,\n * markdown string output, and token truncation.\n */\nexport function createParallelWebSearchTool() {\n const parallelSearchTool = createParallelSearchTool();\n\n return createTool({\n id: 'web-search',\n description: parallelSearchTool.description!,\n inputSchema: parallelWebSearchInputSchema,\n execute: async (input, context) => {\n const output = requireParallelOutput(\n await parallelSearchTool.execute!({ searchQueries: [input.query] }, context),\n 'search',\n );\n const parts: string[] = [];\n\n for (const result of output.results) {\n const title = result.title || result.url;\n const excerpts = (result.excerpts || []).filter(Boolean).join('\\n');\n parts.push([`## ${title}`, result.url, excerpts].filter(Boolean).join('\\n'));\n }\n\n return truncateStringForTokenEstimate(parts.join('\\n\\n'), MAX_WEB_SEARCH_TOKENS);\n },\n });\n}\n\n/**\n * Wraps the @mastra/parallel extract tool with Mastra Code's standard tool id,\n * markdown string output, and token truncation.\n */\nexport function createParallelWebExtractTool() {\n const parallelExtractTool = createParallelExtractTool();\n\n return createTool({\n id: 'web-extract',\n description: parallelExtractTool.description!,\n inputSchema: parallelExtractTool.inputSchema!,\n execute: async (input, context) => {\n const output = requireParallelOutput(await parallelExtractTool.execute!(input, context), 'extract');\n const parts: string[] = [];\n\n for (const result of output.results) {\n const content = result.fullContent || (result.excerpts || []).filter(Boolean).join('\\n');\n parts.push([`## ${result.url}`, content].filter(Boolean).join('\\n'));\n }\n\n for (const error of output.errors) {\n const status = error.httpStatusCode ? ` (${error.httpStatusCode})` : '';\n parts.push([`## ${error.url}`, `Error: ${error.errorType}${status}`, error.content].filter(Boolean).join('\\n'));\n }\n\n return truncateStringForTokenEstimate(parts.join('\\n\\n'), MAX_WEB_EXTRACT_TOKENS);\n },\n });\n}\n\n/**\n * Resolve which model-independent web provider to use. An explicit user\n * preference wins while its API key is configured; otherwise `auto` picks the\n * first configured provider key (Tavily, then Parallel).\n */\nexport function resolveWebSearchProvider(\n preference: WebSearchProviderSetting = 'auto',\n): 'tavily' | 'parallel' | undefined {\n if (preference === 'tavily' && hasTavilyKey()) return 'tavily';\n if (preference === 'parallel' && hasParallelKey()) return 'parallel';\n\n // `auto`, or an explicit choice whose key is no longer configured.\n if (hasTavilyKey()) return 'tavily';\n if (hasParallelKey()) return 'parallel';\n return undefined;\n}\n\n/**\n * Create the configured model-independent web tools for the provider selected\n * via the `webSearchProvider` preference (set in the TUI settings panel).\n */\nexport function createConfiguredWebTools() {\n const provider = resolveWebSearchProvider(loadSettings().preferences.webSearchProvider);\n\n if (provider === 'parallel') {\n return {\n web_search: createParallelWebSearchTool(),\n web_extract: createParallelWebExtractTool(),\n };\n }\n\n if (provider === 'tavily') {\n return {\n web_search: createWebSearchTool(),\n web_extract: createWebExtractTool(),\n };\n }\n\n return undefined;\n}\n"],"mappings":";;;;;;;AAQA,MAAM,wBAAwB;AAC9B,MAAM,yBAAyB;AAE/B,MAAM,sBAAsB;AAE5B,MAAM,+BAA+B,EAAE,OAA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,QAAkB,CAAC;GAEzB,KAAK,MAAM,UAAU,OAAO,SAAS;IACnC,MAAM,UAAU,OAAO,gBAAgB,OAAO,YAAY,CAAC,EAAA,CAAG,OAAO,OAAO,CAAC,CAAC,KAAK,IAAI;IACvF,MAAM,KAAK,CAAC,MAAM,OAAO,OAAO,OAAO,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC;GACrE;GAEA,KAAK,MAAM,SAAS,OAAO,QAAQ;IACjC,MAAM,SAAS,MAAM,iBAAiB,KAAK,MAAM,eAAe,KAAK;IACrE,MAAM,KAAK;KAAC,MAAM,MAAM;KAAO,UAAU,MAAM,YAAY;KAAU,MAAM;IAAO,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC;GAChH;GAEA,OAAO,+BAA+B,MAAM,KAAK,MAAM,GAAG,sBAAsB;EAClF;CACF,CAAC;AACH;;;;;;AAOA,SAAgB,yBACd,aAAuC,QACJ;CACnC,IAAI,eAAe,YAAY,aAAa,GAAG,OAAO;CACtD,IAAI,eAAe,cAAc,eAAe,GAAG,OAAO;CAG1D,IAAI,aAAa,GAAG,OAAO;CAC3B,IAAI,eAAe,GAAG,OAAO;AAE/B;;;;;AAMA,SAAgB,2BAA2B;CACzC,MAAM,WAAW,yBAAyB,aAAa,CAAC,CAAC,YAAY,iBAAiB;CAEtF,IAAI,aAAa,YACf,OAAO;EACL,YAAY,4BAA4B;EACxC,aAAa,6BAA6B;CAC5C;CAGF,IAAI,aAAa,UACf,OAAO;EACL,YAAY,oBAAoB;EAChC,aAAa,qBAAqB;CACpC;AAIJ"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - workflow-builder sub-agent (so `create-workflow` can delegate)
|
|
8
8
|
* - code-agent (as a plain agent, callable via agent steps)
|
|
9
9
|
* - workspace tools (view/write/edit/find_files/execute_command/etc.)
|
|
10
|
-
* - web tools
|
|
10
|
+
* - configured model-independent web tools so workflows can compose search/extract steps
|
|
11
11
|
* - notification_inbox
|
|
12
12
|
* - snapshot of MCP tools from mcpManager
|
|
13
13
|
*
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
* Tradeoffs:
|
|
19
19
|
* - MCP tools are snapshotted. Servers added after boot are invisible to
|
|
20
20
|
* the workflow-builder until restart.
|
|
21
|
-
* -
|
|
21
|
+
* - Provider-native (Anthropic/OpenAI) web
|
|
22
22
|
* tools are skipped because they'd freeze workflows to one model provider.
|
|
23
|
-
* - Workflow tool steps get the closed-over workspace + auth (
|
|
24
|
-
* MCP server credentials), not per-request permissions — deliberate; if
|
|
23
|
+
* - Workflow tool steps get the closed-over workspace + auth (web provider
|
|
24
|
+
* key, MCP server credentials), not per-request permissions — deliberate; if
|
|
25
25
|
* the user built + saved the workflow they meant to run it.
|
|
26
26
|
*/
|
|
27
27
|
import type { Agent } from '@mastra/core/agent';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-primitives.d.ts","sourceRoot":"","sources":["../../src/workflows/register-primitives.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAMlD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAIzC,MAAM,WAAW,wCAAwC;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB;;;;OAIG;IACH,SAAS,EAAE,KAAK,CAAC;IACjB;;;OAGG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,wBAAsB,iCAAiC,CACrD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,wCAAwC,GAChD,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"register-primitives.d.ts","sourceRoot":"","sources":["../../src/workflows/register-primitives.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAMlD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAIzC,MAAM,WAAW,wCAAwC;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB;;;;OAIG;IACH,SAAS,EAAE,KAAK,CAAC;IACjB;;;OAGG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,wBAAsB,iCAAiC,CACrD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,wCAAwC,GAChD,OAAO,CAAC,IAAI,CAAC,CAkDf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MC_TOOLS } from "../tool-names.js";
|
|
2
|
-
import {
|
|
2
|
+
import { createConfiguredWebTools } from "../tools/web-search.js";
|
|
3
3
|
import { MASTRACODE_WORKSPACE_TOOLS } from "../agents/tool-availability.js";
|
|
4
4
|
import { LazyNotificationsStorage } from "../agents/tools.js";
|
|
5
5
|
import { workflowBuilderAgent } from "../agents/workflow-builder-agent.js";
|
|
@@ -22,9 +22,10 @@ async function registerWorkflowBuilderPrimitives(mastra, options) {
|
|
|
22
22
|
});
|
|
23
23
|
const workspaceTools = await createWorkspaceTools(workspace, { workspace });
|
|
24
24
|
for (const [toolId, tool] of Object.entries(workspaceTools)) mastra.addTool(tool, toolId);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
mastra.addTool(
|
|
25
|
+
const configuredWebTools = createConfiguredWebTools();
|
|
26
|
+
if (configuredWebTools) {
|
|
27
|
+
mastra.addTool(configuredWebTools.web_search, "web-search");
|
|
28
|
+
mastra.addTool(configuredWebTools.web_extract, "web-extract");
|
|
28
29
|
}
|
|
29
30
|
const storage = mastra.getStorage();
|
|
30
31
|
if (storage) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-primitives.js","names":[],"sources":["../../src/workflows/register-primitives.ts"],"sourcesContent":["/**\n * Statically register workflow-related primitives on the mastracode Mastra\n * instance so `mastra.listTools()` + `mastra.listAgents()` — and, therefore,\n * the workflow-builder's discovery + the workflow rehydrator — see everything\n * a workflow might want to compose:\n *\n * - workflow-builder sub-agent (so `create-workflow` can delegate)\n * - code-agent (as a plain agent, callable via agent steps)\n * - workspace tools (view/write/edit/find_files/execute_command/etc.)\n * - web tools
|
|
1
|
+
{"version":3,"file":"register-primitives.js","names":[],"sources":["../../src/workflows/register-primitives.ts"],"sourcesContent":["/**\n * Statically register workflow-related primitives on the mastracode Mastra\n * instance so `mastra.listTools()` + `mastra.listAgents()` — and, therefore,\n * the workflow-builder's discovery + the workflow rehydrator — see everything\n * a workflow might want to compose:\n *\n * - workflow-builder sub-agent (so `create-workflow` can delegate)\n * - code-agent (as a plain agent, callable via agent steps)\n * - workspace tools (view/write/edit/find_files/execute_command/etc.)\n * - configured model-independent web tools so workflows can compose search/extract steps\n * - notification_inbox\n * - snapshot of MCP tools from mcpManager\n *\n * Called after `controller.init()` but before `startWorkers()` in both boot\n * paths, so `loadStoredWorkflows()` (inside startWorkers) sees the full\n * registry when rehydrating previously-saved workflows.\n *\n * Tradeoffs:\n * - MCP tools are snapshotted. Servers added after boot are invisible to\n * the workflow-builder until restart.\n * - Provider-native (Anthropic/OpenAI) web\n * tools are skipped because they'd freeze workflows to one model provider.\n * - Workflow tool steps get the closed-over workspace + auth (web provider\n * key, MCP server credentials), not per-request permissions — deliberate; if\n * the user built + saved the workflow they meant to run it.\n */\nimport type { Agent } from '@mastra/core/agent';\nimport type { Mastra } from '@mastra/core/mastra';\nimport { createNotificationInboxTool } from '@mastra/core/notifications';\nimport { LocalFilesystem, LocalSandbox, Workspace, createWorkspaceTools } from '@mastra/core/workspace';\nimport { MASTRACODE_WORKSPACE_TOOLS } from '../agents/tool-availability.js';\nimport { LazyNotificationsStorage } from '../agents/tools.js';\nimport { workflowBuilderAgent } from '../agents/workflow-builder-agent.js';\nimport type { McpManager } from '../mcp';\nimport { MC_TOOLS } from '../tool-names.js';\nimport { createConfiguredWebTools } from '../tools/web-search.js';\n\nexport interface RegisterWorkflowBuilderPrimitivesOptions {\n projectPath: string;\n /**\n * Extra allowed paths the workspace can read/write. Mastracode normally\n * collects skill paths + sandboxAllowedPaths per-request; for the workflow\n * workspace we accept anything the caller wants up-front and trust the\n * worker process to honour the user's intent.\n */\n allowedPaths?: string[];\n /**\n * The code-agent Agent instance. Registered as `code-agent` so workflows\n * can compose it in agent steps. It already has full dynamic tool access\n * (workspace/MCP/web/etc.) via its own `tools: createDynamicTools(...)`.\n */\n codeAgent: Agent;\n /**\n * McpManager for snapshotting MCP tools at boot. Omit or pass undefined\n * if MCP is disabled — workflow-builder will just see fewer tools.\n */\n mcpManager?: McpManager;\n}\n\nexport async function registerWorkflowBuilderPrimitives(\n mastra: Mastra,\n options: RegisterWorkflowBuilderPrimitivesOptions,\n): Promise<void> {\n const { projectPath, allowedPaths = [], codeAgent, mcpManager } = options;\n\n // 1. Agents workflows can compose.\n mastra.addAgent(workflowBuilderAgent, 'workflow-builder');\n mastra.addAgent(codeAgent, 'code-agent');\n\n // 2. Workspace tools — bound to a project-rooted local workspace.\n const workspace = new Workspace({\n id: 'workflow-builder-workspace',\n name: 'Mastra Code Workspace (workflows)',\n filesystem: new LocalFilesystem({\n basePath: projectPath,\n allowedPaths: [projectPath, ...allowedPaths],\n }),\n sandbox: new LocalSandbox({ workingDirectory: projectPath }),\n tools: MASTRACODE_WORKSPACE_TOOLS,\n });\n const workspaceTools = await createWorkspaceTools(workspace, { workspace });\n for (const [toolId, tool] of Object.entries(workspaceTools)) {\n mastra.addTool(tool, toolId);\n }\n\n // 3. Model-independent web tools. Provider-native web tools (Anthropic/OpenAI)\n // are model-locked and would freeze workflows to one provider.\n const configuredWebTools = createConfiguredWebTools();\n if (configuredWebTools) {\n mastra.addTool(configuredWebTools.web_search, 'web-search');\n mastra.addTool(configuredWebTools.web_extract, 'web-extract');\n }\n\n // 4. notification_inbox — LazyNotificationsStorage resolves the notifications\n // domain per-call rather than at boot, so it works even when the domain\n // isn't fully initialised yet.\n const storage = mastra.getStorage();\n if (storage) {\n const notificationInbox = createNotificationInboxTool({\n storage: new LazyNotificationsStorage(storage as never),\n });\n mastra.addTool(notificationInbox, MC_TOOLS.NOTIFICATION_INBOX);\n }\n\n // 5. MCP tools — snapshot the current set. Ids are already server-namespaced\n // (`${serverName}_${toolName}`), so the workflow rehydrator's\n // `mastra.getTool(id)` resolves them at run time.\n if (mcpManager) {\n for (const [toolId, tool] of Object.entries(mcpManager.getTools())) {\n mastra.addTool(tool, toolId);\n }\n }\n}\n"],"mappings":";;;;;;;;AA2DA,eAAsB,kCACpB,QACA,SACe;CACf,MAAM,EAAE,aAAa,eAAe,CAAC,GAAG,WAAW,eAAe;CAGlE,OAAO,SAAS,sBAAsB,kBAAkB;CACxD,OAAO,SAAS,WAAW,YAAY;CAGvC,MAAM,YAAY,IAAI,UAAU;EAC9B,IAAI;EACJ,MAAM;EACN,YAAY,IAAI,gBAAgB;GAC9B,UAAU;GACV,cAAc,CAAC,aAAa,GAAG,YAAY;EAC7C,CAAC;EACD,SAAS,IAAI,aAAa,EAAE,kBAAkB,YAAY,CAAC;EAC3D,OAAO;CACT,CAAC;CACD,MAAM,iBAAiB,MAAM,qBAAqB,WAAW,EAAE,UAAU,CAAC;CAC1E,KAAK,MAAM,CAAC,QAAQ,SAAS,OAAO,QAAQ,cAAc,GACxD,OAAO,QAAQ,MAAM,MAAM;CAK7B,MAAM,qBAAqB,yBAAyB;CACpD,IAAI,oBAAoB;EACtB,OAAO,QAAQ,mBAAmB,YAAY,YAAY;EAC1D,OAAO,QAAQ,mBAAmB,aAAa,aAAa;CAC9D;CAKA,MAAM,UAAU,OAAO,WAAW;CAClC,IAAI,SAAS;EACX,MAAM,oBAAoB,4BAA4B,EACpD,SAAS,IAAI,yBAAyB,OAAgB,EACxD,CAAC;EACD,OAAO,QAAQ,mBAAmB,SAAS,kBAAkB;CAC/D;CAKA,IAAI,YACF,KAAK,MAAM,CAAC,QAAQ,SAAS,OAAO,QAAQ,WAAW,SAAS,CAAC,GAC/D,OAAO,QAAQ,MAAM,MAAM;AAGjC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/code-sdk",
|
|
3
|
-
"version": "1.5.0-alpha.
|
|
3
|
+
"version": "1.5.0-alpha.9",
|
|
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,18 +58,19 @@
|
|
|
58
58
|
"yaml": "^2.7.1",
|
|
59
59
|
"zod": "^4.3.6",
|
|
60
60
|
"@mastra/agent-browser": "0.5.1",
|
|
61
|
-
"@mastra/core": "1.62.0-alpha.
|
|
62
|
-
"@mastra/github-signals": "0.2.5",
|
|
61
|
+
"@mastra/core": "1.62.0-alpha.9",
|
|
63
62
|
"@mastra/duckdb": "1.6.3-alpha.0",
|
|
64
63
|
"@mastra/fastembed": "1.2.0",
|
|
64
|
+
"@mastra/libsql": "1.22.0-alpha.2",
|
|
65
|
+
"@mastra/github-signals": "0.2.5",
|
|
65
66
|
"@mastra/mcp": "1.17.2-alpha.2",
|
|
66
|
-
"@mastra/memory": "1.28.0-alpha.2",
|
|
67
67
|
"@mastra/observability": "1.17.2-alpha.1",
|
|
68
|
-
"@mastra/
|
|
68
|
+
"@mastra/pg": "1.22.0-alpha.4",
|
|
69
|
+
"@mastra/memory": "1.28.0-alpha.3",
|
|
70
|
+
"@mastra/schema-compat": "1.3.7",
|
|
69
71
|
"@mastra/stagehand": "0.3.3",
|
|
70
72
|
"@mastra/tavily": "1.1.1",
|
|
71
|
-
"@mastra/
|
|
72
|
-
"@mastra/pg": "1.22.0-alpha.3"
|
|
73
|
+
"@mastra/parallel": "0.1.0-alpha.0"
|
|
73
74
|
},
|
|
74
75
|
"devDependencies": {
|
|
75
76
|
"@libsql/client": "^0.17.4",
|