@mastra/code-sdk 1.5.0-alpha.8 → 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 +7 -0
- 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 +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @mastra/code-sdk
|
|
2
2
|
|
|
3
|
+
## 1.5.0-alpha.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`eb9ecaa`](https://github.com/mastra-ai/mastra/commit/eb9ecaa89c36e889749e3b825cfc507ce7f7980b), [`3e8727e`](https://github.com/mastra-ai/mastra/commit/3e8727e11ec1a5d733acedb5c872896394be18c1)]:
|
|
8
|
+
- @mastra/core@1.62.0-alpha.9
|
|
9
|
+
|
|
3
10
|
## 1.5.0-alpha.8
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG3C,OAAO,KAAK,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAkBpF,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,iBAAiB,EAAE,cAAc,CAAC;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAQD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,aAAa;IAC5B,uDAAuD;IACvD,EAAE,EAAE,MAAM,CAAC;IACX,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,gEAAgE;AAChE,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,MAAM,CAKpE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAE1D;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,aAAa,GAAG,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG3C,OAAO,KAAK,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAkBpF,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,iBAAiB,EAAE,cAAc,CAAC;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAQD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,aAAa;IAC5B,uDAAuD;IACvD,EAAE,EAAE,MAAM,CAAC;IACX,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,gEAAgE;AAChE,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,MAAM,CAKpE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAE1D;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,aAAa,GAAG,aAAa,EAAE,CAsG3E"}
|
|
@@ -4,7 +4,7 @@ import { getLocalPlansRelativeDir } from "../../utils/plans.js";
|
|
|
4
4
|
import { planModePrompt } from "./plan.js";
|
|
5
5
|
import { fastModePrompt } from "./fast.js";
|
|
6
6
|
import { MC_TOOLS } from "../../tool-names.js";
|
|
7
|
-
import { hasTavilyKey } from "../../tools/web-search.js";
|
|
7
|
+
import { hasParallelKey, hasTavilyKey } from "../../tools/web-search.js";
|
|
8
8
|
import "../../tools/index.js";
|
|
9
9
|
import { AGENT_INSTRUCTIONS_HEADING, createGitRefInstructionReader, formatInstructionSource, loadAgentInstructions } from "./agent-instructions.js";
|
|
10
10
|
import { modelSpecificPrompts } from "./model.js";
|
|
@@ -33,7 +33,7 @@ function buildFullPrompt(ctx) {
|
|
|
33
33
|
*/
|
|
34
34
|
function buildFullPromptSections(ctx) {
|
|
35
35
|
const modelId = ctx.modelId;
|
|
36
|
-
const hasWebSearch = hasTavilyKey() || !!modelId && modelId.startsWith("anthropic/");
|
|
36
|
+
const hasWebSearch = hasParallelKey() || hasTavilyKey() || !!modelId && (modelId.startsWith("anthropic/") || modelId.startsWith("openai/"));
|
|
37
37
|
const deniedTools = /* @__PURE__ */ new Set();
|
|
38
38
|
const permRules = ctx.state?.permissionRules;
|
|
39
39
|
if (permRules?.tools) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/agents/prompts/index.ts"],"sourcesContent":["/**\n * Prompt system — exports the prompt builder and mode-specific prompts.\n */\n\nexport { buildModePrompt, buildModePromptFn } from './build.js';\nexport { planModePrompt } from './plan.js';\nexport { fastModePrompt } from './fast.js';\n\nimport { buildBasePrompt } from '@mastra/core/coding-agent';\nimport type { PromptContext as BasePromptContext } from '@mastra/core/coding-agent';\nimport { loadSettings, resolveLspSetting } from '../../onboarding/settings.js';\nimport { MC_TOOLS } from '../../tool-names.js';\nimport { hasTavilyKey } from '../../tools/index.js';\nimport { getLocalPlansRelativeDir } from '../../utils/plans.js';\nimport {\n loadAgentInstructions,\n formatInstructionSource,\n createGitRefInstructionReader,\n AGENT_INSTRUCTIONS_HEADING,\n} from './agent-instructions.js';\nimport { buildModePromptFn } from './build.js';\nimport { fastModePrompt } from './fast.js';\nimport { modelSpecificPrompts } from './model.js';\nimport { planModePrompt } from './plan.js';\nimport { buildToolGuidance } from './tool-guidance.js';\n\n// Extended prompt context that includes runtime information\nexport interface PromptContext extends Omit<BasePromptContext, 'toolGuidance'> {\n modeId: string;\n state?: any;\n currentDate: string;\n workingDir: string;\n}\n\nconst modePrompts: Record<string, string | ((ctx: PromptContext) => string)> = {\n build: buildModePromptFn,\n plan: planModePrompt,\n fast: fastModePrompt,\n};\n\n/**\n * One labeled piece of the assembled system prompt.\n *\n * The system prompt is a single string by the time it reaches the model, which\n * makes it impossible to say which configuration source is responsible for\n * which share of the context window. Building it as labeled sections and\n * joining them at the end keeps that attribution available to the `/context`\n * audit while guaranteeing the audit measures the exact text that is sent —\n * a parallel \"describe the prompt\" path would drift and report numbers for a\n * prompt that is no longer assembled this way.\n */\nexport interface PromptSection {\n /** Stable identifier, unique within a single build. */\n id: string;\n /** Human-readable label for display. */\n label: string;\n /** Optional provenance (e.g. the instruction file path). */\n detail?: string;\n /** The exact text contributed to the prompt. */\n content: string;\n}\n\n/** Join prompt sections into the final system prompt string. */\nexport function joinPromptSections(sections: PromptSection[]): string {\n return sections\n .map(section => section.content)\n .filter(Boolean)\n .join('\\n\\n');\n}\n\n/**\n * Build the full system prompt for a given mode and context.\n * Combines the base prompt with mode-specific instructions.\n */\nexport function buildFullPrompt(ctx: PromptContext): string {\n return joinPromptSections(buildFullPromptSections(ctx));\n}\n\n/**\n * Build the system prompt as labeled sections. `buildFullPrompt` is the join of\n * these, so the two can never disagree about what the model receives.\n */\nexport function buildFullPromptSections(ctx: PromptContext): PromptSection[] {\n // Determine whether web search tools are available\n const modelId = ctx.modelId;\n const hasWebSearch = hasTavilyKey() || (!!modelId && modelId.startsWith('anthropic/'));\n\n // Collect per-tool deny rules so guidance omits denied tools\n const deniedTools = new Set<string>();\n const permRules = ctx.state?.permissionRules as { tools?: Record<string, string> } | undefined;\n if (permRules?.tools) {\n for (const [name, policy] of Object.entries(permRules.tools)) {\n if (policy === 'deny') deniedTools.add(name);\n }\n }\n\n // LSP is opt-in — when it is off the tool is never registered, so its\n // guidance must not be advertised either.\n if (resolveLspSetting(loadSettings().lsp) === false) deniedTools.add(MC_TOOLS.LSP_INSPECT);\n\n // Build mode-aware tool guidance\n const factoryProjectId = typeof ctx.state?.factoryProjectId === 'string' ? ctx.state.factoryProjectId : undefined;\n const toolGuidance = buildToolGuidance(ctx.modeId, {\n hasWebSearch,\n deniedTools,\n plansDir: getLocalPlansRelativeDir({ factoryProjectId }),\n });\n\n // Map new context to base context\n const baseCtx: BasePromptContext = {\n projectPath: ctx.workingDir,\n projectName: ctx.projectName || 'unknown',\n gitBranch: ctx.gitBranch,\n platform: process.platform,\n commonBinaries: ctx.commonBinaries,\n date: ctx.currentDate,\n mode: ctx.modeId,\n modelId: ctx.modelId,\n activePlan: ctx.state?.activePlan,\n toolGuidance,\n };\n\n const base = buildBasePrompt(baseCtx);\n const entry = modePrompts[ctx.modeId] || modePrompts.build;\n const modeSpecific = (typeof entry === 'function' ? entry(ctx) : entry) ?? '';\n const modelSpecific = ctx.modelId\n ? (modelSpecificPrompts[ctx.modelId as keyof typeof modelSpecificPrompts] ?? '')\n : '';\n\n // The current task list is carried on the agent state-signal lane (see\n // TaskStateProcessor) rather than injected into the cached system prompt. This\n // keeps the prompt prefix stable across task updates (preserving prompt cache)\n // while still surviving observational-memory truncation.\n\n // Load and inject agent instructions from AGENTS.md/CLAUDE.md files.\n // Untrusted checkouts (e.g. a PR branch under review) never read\n // project-scope files off the working tree: their AGENTS.md is\n // attacker-writable and would otherwise land in the system prompt as\n // trusted configuration. When the session carries a trusted base ref, the\n // project instructions are served from that ref instead (`git show`);\n // without one, project-scope files are skipped entirely. Home-directory\n // (global) instructions belong to whoever owns the machine, so hosts that\n // run sessions for someone else opt out of them entirely.\n const configDir = ctx.state?.configDir as string | undefined;\n const untrustedCheckout = ctx.state?.untrustedCheckout === true;\n const skipGlobalInstructions = ctx.state?.skipGlobalInstructions === true;\n const baseRef = typeof ctx.state?.baseRef === 'string' ? ctx.state.baseRef : undefined;\n const projectReader = untrustedCheckout\n ? baseRef\n ? createGitRefInstructionReader(ctx.workingDir, baseRef)\n : { exists: () => false, read: () => '' }\n : undefined;\n const instructionSources = loadAgentInstructions(ctx.workingDir, configDir, projectReader, {\n skipGlobal: skipGlobalInstructions,\n });\n // Emitted per source so each AGENTS.md/CLAUDE.md can be costed individually.\n // The heading rides on the first source's section, which is exactly how\n // `formatAgentInstructions` lays the block out, so joining the sections\n // reproduces its output byte for byte.\n const instructionSections: PromptSection[] = instructionSources.map((source, index) => {\n const isFirst = index === 0;\n const isLast = index === instructionSources.length - 1;\n let content = formatInstructionSource(source);\n if (isFirst) content = `${AGENT_INSTRUCTIONS_HEADING}\\n\\n${content}`;\n // The block as a whole used to be trimmed, which only ever affected the\n // trailing whitespace of the final source's content.\n if (isLast) content = content.trimEnd();\n return {\n id: `agent-instructions:${source.path}:${index}`,\n label: `${source.scope === 'global' ? 'Global' : 'Project'} instructions`,\n detail: source.ref ? `${source.path} (at ref ${source.ref})` : source.path,\n content,\n };\n });\n\n return [\n { id: 'base-prompt', label: 'Base system prompt', content: base },\n ...instructionSections,\n { id: 'model-prompt', label: 'Model-specific prompt', detail: ctx.modelId, content: modelSpecific.trim() },\n { id: 'mode-prompt', label: 'Mode prompt', detail: ctx.modeId, content: modeSpecific.trim() },\n ].filter(section => Boolean(section.content));\n}\n"],"mappings":";;;;;;;;;;;;;AAkCA,MAAM,cAAyE;CAC7E,OAAO;CACP,MAAM;CACN,MAAM;AACR;;AAyBA,SAAgB,mBAAmB,UAAmC;CACpE,OAAO,SACJ,KAAI,YAAW,QAAQ,OAAO,CAAC,CAC/B,OAAO,OAAO,CAAC,CACf,KAAK,MAAM;AAChB;;;;;AAMA,SAAgB,gBAAgB,KAA4B;CAC1D,OAAO,mBAAmB,wBAAwB,GAAG,CAAC;AACxD;;;;;AAMA,SAAgB,wBAAwB,KAAqC;CAE3E,MAAM,UAAU,IAAI;CACpB,MAAM,eAAe,aAAa,KAAM,CAAC,CAAC,WAAW,QAAQ,WAAW,YAAY;CAGpF,MAAM,8BAAc,IAAI,IAAY;CACpC,MAAM,YAAY,IAAI,OAAO;CAC7B,IAAI,WAAW,OACR;OAAA,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,UAAU,KAAK,GACzD,IAAI,WAAW,QAAQ,YAAY,IAAI,IAAI;CAAA;CAM/C,IAAI,kBAAkB,aAAa,CAAC,CAAC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O;GACL,IAAI,sBAAsB,OAAO,KAAK,GAAG;GACzC,OAAO,GAAG,OAAO,UAAU,WAAW,WAAW,UAAU;GAC3D,QAAQ,OAAO,MAAM,GAAG,OAAO,KAAK,WAAW,OAAO,IAAI,KAAK,OAAO;GACtE;EACF;CACF,CAAC;CAED,OAAO;EACL;GAAE,IAAI;GAAe,OAAO;GAAsB,SAAS;EAAK;EAChE,GAAG;EACH;GAAE,IAAI;GAAgB,OAAO;GAAyB,QAAQ,IAAI;GAAS,SAAS,cAAc,KAAK;EAAE;EACzG;GAAE,IAAI;GAAe,OAAO;GAAe,QAAQ,IAAI;GAAQ,SAAS,aAAa,KAAK;EAAE;CAC9F,CAAC,CAAC,QAAO,YAAW,QAAQ,QAAQ,OAAO,CAAC;AAC9C"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/agents/prompts/index.ts"],"sourcesContent":["/**\n * Prompt system — exports the prompt builder and mode-specific prompts.\n */\n\nexport { buildModePrompt, buildModePromptFn } from './build.js';\nexport { planModePrompt } from './plan.js';\nexport { fastModePrompt } from './fast.js';\n\nimport { buildBasePrompt } from '@mastra/core/coding-agent';\nimport type { PromptContext as BasePromptContext } from '@mastra/core/coding-agent';\nimport { loadSettings, resolveLspSetting } from '../../onboarding/settings.js';\nimport { MC_TOOLS } from '../../tool-names.js';\nimport { hasParallelKey, hasTavilyKey } from '../../tools/index.js';\nimport { getLocalPlansRelativeDir } from '../../utils/plans.js';\nimport {\n loadAgentInstructions,\n formatInstructionSource,\n createGitRefInstructionReader,\n AGENT_INSTRUCTIONS_HEADING,\n} from './agent-instructions.js';\nimport { buildModePromptFn } from './build.js';\nimport { fastModePrompt } from './fast.js';\nimport { modelSpecificPrompts } from './model.js';\nimport { planModePrompt } from './plan.js';\nimport { buildToolGuidance } from './tool-guidance.js';\n\n// Extended prompt context that includes runtime information\nexport interface PromptContext extends Omit<BasePromptContext, 'toolGuidance'> {\n modeId: string;\n state?: any;\n currentDate: string;\n workingDir: string;\n}\n\nconst modePrompts: Record<string, string | ((ctx: PromptContext) => string)> = {\n build: buildModePromptFn,\n plan: planModePrompt,\n fast: fastModePrompt,\n};\n\n/**\n * One labeled piece of the assembled system prompt.\n *\n * The system prompt is a single string by the time it reaches the model, which\n * makes it impossible to say which configuration source is responsible for\n * which share of the context window. Building it as labeled sections and\n * joining them at the end keeps that attribution available to the `/context`\n * audit while guaranteeing the audit measures the exact text that is sent —\n * a parallel \"describe the prompt\" path would drift and report numbers for a\n * prompt that is no longer assembled this way.\n */\nexport interface PromptSection {\n /** Stable identifier, unique within a single build. */\n id: string;\n /** Human-readable label for display. */\n label: string;\n /** Optional provenance (e.g. the instruction file path). */\n detail?: string;\n /** The exact text contributed to the prompt. */\n content: string;\n}\n\n/** Join prompt sections into the final system prompt string. */\nexport function joinPromptSections(sections: PromptSection[]): string {\n return sections\n .map(section => section.content)\n .filter(Boolean)\n .join('\\n\\n');\n}\n\n/**\n * Build the full system prompt for a given mode and context.\n * Combines the base prompt with mode-specific instructions.\n */\nexport function buildFullPrompt(ctx: PromptContext): string {\n return joinPromptSections(buildFullPromptSections(ctx));\n}\n\n/**\n * Build the system prompt as labeled sections. `buildFullPrompt` is the join of\n * these, so the two can never disagree about what the model receives.\n */\nexport function buildFullPromptSections(ctx: PromptContext): PromptSection[] {\n // Determine whether web search tools are available\n const modelId = ctx.modelId;\n const hasWebSearch =\n hasParallelKey() ||\n hasTavilyKey() ||\n (!!modelId && (modelId.startsWith('anthropic/') || modelId.startsWith('openai/')));\n\n // Collect per-tool deny rules so guidance omits denied tools\n const deniedTools = new Set<string>();\n const permRules = ctx.state?.permissionRules as { tools?: Record<string, string> } | undefined;\n if (permRules?.tools) {\n for (const [name, policy] of Object.entries(permRules.tools)) {\n if (policy === 'deny') deniedTools.add(name);\n }\n }\n\n // LSP is opt-in — when it is off the tool is never registered, so its\n // guidance must not be advertised either.\n if (resolveLspSetting(loadSettings().lsp) === false) deniedTools.add(MC_TOOLS.LSP_INSPECT);\n\n // Build mode-aware tool guidance\n const factoryProjectId = typeof ctx.state?.factoryProjectId === 'string' ? ctx.state.factoryProjectId : undefined;\n const toolGuidance = buildToolGuidance(ctx.modeId, {\n hasWebSearch,\n deniedTools,\n plansDir: getLocalPlansRelativeDir({ factoryProjectId }),\n });\n\n // Map new context to base context\n const baseCtx: BasePromptContext = {\n projectPath: ctx.workingDir,\n projectName: ctx.projectName || 'unknown',\n gitBranch: ctx.gitBranch,\n platform: process.platform,\n commonBinaries: ctx.commonBinaries,\n date: ctx.currentDate,\n mode: ctx.modeId,\n modelId: ctx.modelId,\n activePlan: ctx.state?.activePlan,\n toolGuidance,\n };\n\n const base = buildBasePrompt(baseCtx);\n const entry = modePrompts[ctx.modeId] || modePrompts.build;\n const modeSpecific = (typeof entry === 'function' ? entry(ctx) : entry) ?? '';\n const modelSpecific = ctx.modelId\n ? (modelSpecificPrompts[ctx.modelId as keyof typeof modelSpecificPrompts] ?? '')\n : '';\n\n // The current task list is carried on the agent state-signal lane (see\n // TaskStateProcessor) rather than injected into the cached system prompt. This\n // keeps the prompt prefix stable across task updates (preserving prompt cache)\n // while still surviving observational-memory truncation.\n\n // Load and inject agent instructions from AGENTS.md/CLAUDE.md files.\n // Untrusted checkouts (e.g. a PR branch under review) never read\n // project-scope files off the working tree: their AGENTS.md is\n // attacker-writable and would otherwise land in the system prompt as\n // trusted configuration. When the session carries a trusted base ref, the\n // project instructions are served from that ref instead (`git show`);\n // without one, project-scope files are skipped entirely. Home-directory\n // (global) instructions belong to whoever owns the machine, so hosts that\n // run sessions for someone else opt out of them entirely.\n const configDir = ctx.state?.configDir as string | undefined;\n const untrustedCheckout = ctx.state?.untrustedCheckout === true;\n const skipGlobalInstructions = ctx.state?.skipGlobalInstructions === true;\n const baseRef = typeof ctx.state?.baseRef === 'string' ? ctx.state.baseRef : undefined;\n const projectReader = untrustedCheckout\n ? baseRef\n ? createGitRefInstructionReader(ctx.workingDir, baseRef)\n : { exists: () => false, read: () => '' }\n : undefined;\n const instructionSources = loadAgentInstructions(ctx.workingDir, configDir, projectReader, {\n skipGlobal: skipGlobalInstructions,\n });\n // Emitted per source so each AGENTS.md/CLAUDE.md can be costed individually.\n // The heading rides on the first source's section, which is exactly how\n // `formatAgentInstructions` lays the block out, so joining the sections\n // reproduces its output byte for byte.\n const instructionSections: PromptSection[] = instructionSources.map((source, index) => {\n const isFirst = index === 0;\n const isLast = index === instructionSources.length - 1;\n let content = formatInstructionSource(source);\n if (isFirst) content = `${AGENT_INSTRUCTIONS_HEADING}\\n\\n${content}`;\n // The block as a whole used to be trimmed, which only ever affected the\n // trailing whitespace of the final source's content.\n if (isLast) content = content.trimEnd();\n return {\n id: `agent-instructions:${source.path}:${index}`,\n label: `${source.scope === 'global' ? 'Global' : 'Project'} instructions`,\n detail: source.ref ? `${source.path} (at ref ${source.ref})` : source.path,\n content,\n };\n });\n\n return [\n { id: 'base-prompt', label: 'Base system prompt', content: base },\n ...instructionSections,\n { id: 'model-prompt', label: 'Model-specific prompt', detail: ctx.modelId, content: modelSpecific.trim() },\n { id: 'mode-prompt', label: 'Mode prompt', detail: ctx.modeId, content: modeSpecific.trim() },\n ].filter(section => Boolean(section.content));\n}\n"],"mappings":";;;;;;;;;;;;;AAkCA,MAAM,cAAyE;CAC7E,OAAO;CACP,MAAM;CACN,MAAM;AACR;;AAyBA,SAAgB,mBAAmB,UAAmC;CACpE,OAAO,SACJ,KAAI,YAAW,QAAQ,OAAO,CAAC,CAC/B,OAAO,OAAO,CAAC,CACf,KAAK,MAAM;AAChB;;;;;AAMA,SAAgB,gBAAgB,KAA4B;CAC1D,OAAO,mBAAmB,wBAAwB,GAAG,CAAC;AACxD;;;;;AAMA,SAAgB,wBAAwB,KAAqC;CAE3E,MAAM,UAAU,IAAI;CACpB,MAAM,eACJ,eAAe,KACf,aAAa,KACZ,CAAC,CAAC,YAAY,QAAQ,WAAW,YAAY,KAAK,QAAQ,WAAW,SAAS;CAGjF,MAAM,8BAAc,IAAI,IAAY;CACpC,MAA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,MAAM,UAAU,UAAU;EAC1B,MAAM,SAAS,UAAU,mBAAmB,SAAS;EACrD,IAAI,UAAU,wBAAwB,MAAM;EAC5C,IAAI,SAAS,UAAU,GAAG,2BAA2B,MAAM;EAG3D,IAAI,QAAQ,UAAU,QAAQ,QAAQ;EACtC,OAAO;GACL,IAAI,sBAAsB,OAAO,KAAK,GAAG;GACzC,OAAO,GAAG,OAAO,UAAU,WAAW,WAAW,UAAU;GAC3D,QAAQ,OAAO,MAAM,GAAG,OAAO,KAAK,WAAW,OAAO,IAAI,KAAK,OAAO;GACtE;EACF;CACF,CAAC;CAED,OAAO;EACL;GAAE,IAAI;GAAe,OAAO;GAAsB,SAAS;EAAK;EAChE,GAAG;EACH;GAAE,IAAI;GAAgB,OAAO;GAAyB,QAAQ,IAAI;GAAS,SAAS,cAAc,KAAK;EAAE;EACzG;GAAE,IAAI;GAAe,OAAO;GAAe,QAAQ,IAAI;GAAQ,SAAS,aAAa,KAAK;EAAE;CAC9F,CAAC,CAAC,QAAO,YAAW,QAAQ,QAAQ,OAAO,CAAC;AAC9C"}
|
package/dist/agents/tools.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ToolsInput } from '@mastra/core/agent';
|
|
1
2
|
import { NotificationsStorage } from '@mastra/core/notifications';
|
|
2
3
|
import type { CreateNotificationInput, ListDueNotificationsInput, ListNotificationsInput, UpdateNotificationInput } from '@mastra/core/notifications';
|
|
3
4
|
import type { RequestContext } from '@mastra/core/request-context';
|
|
@@ -30,6 +31,6 @@ type DynamicToolProvider = Record<string, ToolLike | undefined> | ((ctx: {
|
|
|
30
31
|
}) => Record<string, ToolLike | undefined> | Promise<Record<string, ToolLike | undefined>>);
|
|
31
32
|
export declare function createDynamicTools(mcpManager?: McpManager, extraTools?: DynamicToolProvider, disabledTools?: string[], storage?: MastraCompositeStore, pluginTools?: Record<string, ToolLike>): ({ requestContext, }: {
|
|
32
33
|
requestContext: RequestContext;
|
|
33
|
-
}) =>
|
|
34
|
+
}) => ToolsInput | Promise<ToolsInput>;
|
|
34
35
|
export {};
|
|
35
36
|
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/agents/tools.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/agents/tools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAA+B,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAC/F,OAAO,KAAK,EACV,uBAAuB,EACvB,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAWlD,4DAA4D;AAC5D,MAAM,MAAM,QAAQ,GAAG;IACrB,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CAC1D,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAExB,qBAAa,wBAAyB,SAAQ,oBAAoB;IACpD,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,oBAAoB;YAI5C,uBAAuB;IAQ/B,kBAAkB,CAAC,KAAK,EAAE,uBAAuB;IAIjD,iBAAiB,CAAC,KAAK,EAAE,sBAAsB;IAI/C,oBAAoB,CAAC,KAAK,EAAE,yBAAyB;IAIrD,eAAe,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE;IAIvD,kBAAkB,CAAC,KAAK,EAAE,uBAAuB;IAIjD,mBAAmB;CAG1B;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,oBAAoB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEvF,wBAAgB,eAAe,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,SAAS,GAAG,SAAS,CAoCrH;AAED,KAAK,mBAAmB,GACpB,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAC,GACpC,CAAC,CAAC,GAAG,EAAE;IACL,cAAc,EAAE,cAAc,CAAC;CAChC,KAAK,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAEhG,wBAAgB,kBAAkB,CAChC,UAAU,CAAC,EAAE,UAAU,EACvB,UAAU,CAAC,EAAE,mBAAmB,EAChC,aAAa,CAAC,EAAE,MAAM,EAAE,EACxB,OAAO,CAAC,EAAE,oBAAoB,EAC9B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAEN,qBAE7B;IACD,cAAc,EAAE,cAAc,CAAC;CAChC,KAAG,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CA6FrC"}
|
package/dist/agents/tools.js
CHANGED
|
@@ -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 { requestSandboxAccessTool } from "../tools/request-sandbox-access.js";
|
|
4
4
|
import "../tools/index.js";
|
|
5
5
|
import { createWorkflowTool } from "../tools/workflows/create-workflow.js";
|
|
@@ -81,10 +81,9 @@ function createDynamicTools(mcpManager, extraTools, disabledTools, storage, plug
|
|
|
81
81
|
[WORKFLOW_MANAGEMENT_TOOL_IDS.deleteWorkflow]: deleteWorkflowTool
|
|
82
82
|
};
|
|
83
83
|
if (storage) tools[MC_TOOLS.NOTIFICATION_INBOX] = createNotificationInboxTool({ storage: new LazyNotificationsStorage(storage) });
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
} else if (isAnthropicModel) tools.web_search = createAnthropic({}).tools.webSearch_20250305();
|
|
84
|
+
const configuredWebTools = createConfiguredWebTools();
|
|
85
|
+
if (configuredWebTools) Object.assign(tools, configuredWebTools);
|
|
86
|
+
else if (isAnthropicModel) tools.web_search = createAnthropic({}).tools.webSearch_20250305();
|
|
88
87
|
else if (isOpenAIModel) tools.web_search = createOpenAI({}).tools.webSearch();
|
|
89
88
|
if (mcpManager) {
|
|
90
89
|
const mcpTools = mcpManager.getTools();
|
package/dist/agents/tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","names":[],"sources":["../../src/agents/tools.ts"],"sourcesContent":["import { createAnthropic } from '@ai-sdk/anthropic';\nimport { createOpenAI } from '@ai-sdk/openai';\nimport type { AgentControllerRequestContext } from '@mastra/core/agent-controller';\nimport { createNotificationInboxTool, NotificationsStorage } from '@mastra/core/notifications';\nimport type {\n CreateNotificationInput,\n ListDueNotificationsInput,\n ListNotificationsInput,\n UpdateNotificationInput,\n} from '@mastra/core/notifications';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport type { MastraCompositeStore } from '@mastra/core/storage';\nimport type { ToolAfterHookContext, ToolHooks } from '@mastra/core/tools';\nimport type { HookManager } from '../hooks/index.js';\nimport type { McpManager } from '../mcp/index.js';\nimport type { MastraCodeComposedState } from '../schema.js';\nimport { MC_TOOLS } from '../tool-names.js';\nimport { createWebSearchTool, createWebExtractTool, hasTavilyKey, requestSandboxAccessTool } from '../tools/index.js';\nimport { createWorkflowTool } from '../tools/workflows/create-workflow.js';\nimport { deleteWorkflowTool } from '../tools/workflows/delete-workflow.js';\nimport { getWorkflowTool } from '../tools/workflows/get-workflow.js';\nimport { listWorkflowsTool } from '../tools/workflows/list-workflows.js';\nimport { runWorkflowTool } from '../tools/workflows/run-workflow.js';\nimport { WORKFLOW_MANAGEMENT_TOOL_IDS } from '../tools/workflows/tool-ids.js';\n\n/** Minimal shape for tools passed to createDynamicTools. */\nexport type ToolLike = {\n execute?: (...args: any[]) => Promise<unknown> | unknown;\n} & Record<string, any>;\n\nexport class LazyNotificationsStorage extends NotificationsStorage {\n constructor(private readonly storage: MastraCompositeStore) {\n super();\n }\n\n private async getNotificationsStorage(): Promise<NotificationsStorage> {\n const notifications = await this.storage.getStore('notifications');\n if (!notifications) {\n throw new Error('notification_inbox requires a notifications storage domain');\n }\n return notifications;\n }\n\n async createNotification(input: CreateNotificationInput) {\n return (await this.getNotificationsStorage()).createNotification(input);\n }\n\n async listNotifications(input: ListNotificationsInput) {\n return (await this.getNotificationsStorage()).listNotifications(input);\n }\n\n async listDueNotifications(input: ListDueNotificationsInput) {\n return (await this.getNotificationsStorage()).listDueNotifications(input);\n }\n\n async getNotification(input: { threadId: string; id: string }) {\n return (await this.getNotificationsStorage()).getNotification(input);\n }\n\n async updateNotification(input: UpdateNotificationInput) {\n return (await this.getNotificationsStorage()).updateNotification(input);\n }\n\n async dangerouslyClearAll() {\n return (await this.getNotificationsStorage()).dangerouslyClearAll();\n }\n}\n\nexport type PostToolObserver = (context: ToolAfterHookContext) => void | Promise<void>;\n\nexport function createToolHooks(hookManager?: HookManager, postToolObserver?: PostToolObserver): ToolHooks | undefined {\n if (!hookManager && !postToolObserver) return undefined;\n\n return {\n beforeToolCall: async ({ toolName, input }) => {\n if (!hookManager) return;\n const preResult = await hookManager.runPreToolUse(toolName, input);\n if (!preResult.allowed) {\n return {\n proceed: false as const,\n output: {\n error: preResult.blockReason ?? `Blocked by PreToolUse hook for tool \"${toolName}\"`,\n },\n };\n }\n },\n afterToolCall: async context => {\n const { toolName, input, output, error } = context;\n if (hookManager) {\n const failed = error !== undefined;\n await hookManager\n .runPostToolUse(\n toolName,\n input,\n failed ? { error: error instanceof Error ? error.message : String(error) } : output,\n failed,\n )\n .catch(() => undefined);\n }\n await Promise.resolve()\n .then(() => postToolObserver?.(context))\n .catch(error => {\n console.warn(`[MastraCode] Post-tool observer failed for ${toolName}.`, error);\n });\n },\n };\n}\n\ntype DynamicToolProvider =\n | Record<string, ToolLike | undefined>\n | ((ctx: {\n requestContext: RequestContext;\n }) => Record<string, ToolLike | undefined> | Promise<Record<string, ToolLike | undefined>>);\n\nexport function createDynamicTools(\n mcpManager?: McpManager,\n extraTools?: DynamicToolProvider,\n disabledTools?: string[],\n storage?: MastraCompositeStore,\n pluginTools?: Record<string, ToolLike>,\n) {\n return function getDynamicTools({\n requestContext,\n }: {\n requestContext: RequestContext;\n }): Record<string, ToolLike> | Promise<Record<string, ToolLike>> {\n const ctx = requestContext.get('controller') as AgentControllerRequestContext<MastraCodeComposedState> | undefined;\n const state = ctx?.getState();\n\n const modelId = ctx?.session?.modelId;\n const isAnthropicModel = modelId?.startsWith('anthropic/');\n const isOpenAIModel = modelId?.startsWith('openai/');\n\n // Filesystem, grep, glob, edit, write, execute_command, and process\n // management tools are now provided by the workspace (see workspace.ts).\n // Only tools without a workspace equivalent remain here.\n const tools: Record<string, ToolLike> = {\n request_access: requestSandboxAccessTool,\n // Workflow surface. `create-workflow` delegates to the workflow-builder\n // sub-agent; the other four are Dynamic Workflow management operations.\n // Permission categories live in permissions.ts (TOOL_CATEGORY_MAP).\n [WORKFLOW_MANAGEMENT_TOOL_IDS.createWorkflow]: createWorkflowTool,\n [WORKFLOW_MANAGEMENT_TOOL_IDS.listWorkflows]: listWorkflowsTool,\n [WORKFLOW_MANAGEMENT_TOOL_IDS.getWorkflow]: getWorkflowTool,\n [WORKFLOW_MANAGEMENT_TOOL_IDS.runWorkflow]: runWorkflowTool,\n [WORKFLOW_MANAGEMENT_TOOL_IDS.deleteWorkflow]: deleteWorkflowTool,\n };\n\n if (storage) {\n tools[MC_TOOLS.NOTIFICATION_INBOX] = createNotificationInboxTool({\n storage: new LazyNotificationsStorage(storage),\n });\n }\n\n if (hasTavilyKey()) {\n tools.web_search = createWebSearchTool();\n tools.web_extract = createWebExtractTool();\n } else if (isAnthropicModel) {\n const anthropic = createAnthropic({});\n tools.web_search = anthropic.tools.webSearch_20250305();\n } else if (isOpenAIModel) {\n const openai = createOpenAI({});\n tools.web_search = openai.tools.webSearch();\n }\n\n if (mcpManager) {\n const mcpTools = mcpManager.getTools();\n Object.assign(tools, mcpTools);\n }\n\n const finish = (resolvedExtra: Record<string, ToolLike | undefined> | undefined) => {\n if (resolvedExtra) {\n for (const [name, tool] of Object.entries(resolvedExtra)) {\n if (tool && !(name in tools)) {\n tools[name] = tool;\n }\n }\n }\n\n if (pluginTools) {\n for (const [name, tool] of Object.entries(pluginTools)) {\n if (!(name in tools)) {\n tools[name] = tool;\n }\n }\n }\n\n // Remove tools explicitly disabled via config so the model never sees them.\n if (disabledTools?.length) {\n for (const toolName of disabledTools) {\n delete tools[toolName];\n }\n }\n\n // Remove tools that have a per-tool 'deny' policy so the model never sees them.\n const permissionRules = state?.permissionRules;\n if (permissionRules?.tools) {\n for (const [name, policy] of Object.entries(permissionRules.tools)) {\n if (policy === 'deny') {\n delete tools[name];\n }\n }\n }\n\n return tools;\n };\n\n if (typeof extraTools === 'function') {\n const resolved = extraTools({ requestContext });\n // Stay synchronous for sync providers; only go async when the provider does.\n if (resolved && typeof (resolved as PromiseLike<unknown>).then === 'function') {\n return Promise.resolve(resolved).then(finish);\n }\n return finish(resolved as Record<string, ToolLike | undefined>);\n }\n\n return finish(extraTools);\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AA8BA,IAAa,2BAAb,cAA8C,qBAAqB;CACpC;CAA7B,YAAY,SAAgD;EAC1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,IAAI,aACG;SAAA,MAAM,CAAC,MAAM,SAAS,OAAO,QAAQ,WAAW,GACnD,IAAI,EAAE,QAAQ,QACZ,MAAM,QAAQ;GAAA;GAMpB,IAAI,eAAe,QACjB,KAAK,MAAM,YAAY,eACrB,OAAO,MAAM;GAKjB,MAAM,kBAAkB,OAAO;GAC/B,IAAI,iBAAiB,OACd;SAAA,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,gBAAgB,KAAK,GAC/D,IAAI,WAAW,QACb,OAAO,MAAM;GAAA;GAKnB,OAAO;EACT;EAEA,IAAI,OAAO,eAAe,YAAY;GACpC,MAAM,WAAW,WAAW,EAAE,eAAe,CAAC;GAE9C,IAAI,YAAY,OAAQ,SAAkC,SAAS,YACjE,OAAO,QAAQ,QAAQ,QAAQ,CAAC,CAAC,KAAK,MAAM;GAE9C,OAAO,OAAO,QAAgD;EAChE;EAEA,OAAO,OAAO,UAAU;CAC1B;AACF"}
|
|
1
|
+
{"version":3,"file":"tools.js","names":[],"sources":["../../src/agents/tools.ts"],"sourcesContent":["import { createAnthropic } from '@ai-sdk/anthropic';\nimport { createOpenAI } from '@ai-sdk/openai';\nimport type { ToolsInput } from '@mastra/core/agent';\nimport type { AgentControllerRequestContext } from '@mastra/core/agent-controller';\nimport { createNotificationInboxTool, NotificationsStorage } from '@mastra/core/notifications';\nimport type {\n CreateNotificationInput,\n ListDueNotificationsInput,\n ListNotificationsInput,\n UpdateNotificationInput,\n} from '@mastra/core/notifications';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport type { MastraCompositeStore } from '@mastra/core/storage';\nimport type { ToolAfterHookContext, ToolHooks } from '@mastra/core/tools';\nimport type { HookManager } from '../hooks/index.js';\nimport type { McpManager } from '../mcp/index.js';\nimport type { MastraCodeComposedState } from '../schema.js';\nimport { MC_TOOLS } from '../tool-names.js';\nimport { createConfiguredWebTools, requestSandboxAccessTool } from '../tools/index.js';\nimport { createWorkflowTool } from '../tools/workflows/create-workflow.js';\nimport { deleteWorkflowTool } from '../tools/workflows/delete-workflow.js';\nimport { getWorkflowTool } from '../tools/workflows/get-workflow.js';\nimport { listWorkflowsTool } from '../tools/workflows/list-workflows.js';\nimport { runWorkflowTool } from '../tools/workflows/run-workflow.js';\nimport { WORKFLOW_MANAGEMENT_TOOL_IDS } from '../tools/workflows/tool-ids.js';\n\n/** Minimal shape for tools passed to createDynamicTools. */\nexport type ToolLike = {\n execute?: (...args: any[]) => Promise<unknown> | unknown;\n} & Record<string, any>;\n\nexport class LazyNotificationsStorage extends NotificationsStorage {\n constructor(private readonly storage: MastraCompositeStore) {\n super();\n }\n\n private async getNotificationsStorage(): Promise<NotificationsStorage> {\n const notifications = await this.storage.getStore('notifications');\n if (!notifications) {\n throw new Error('notification_inbox requires a notifications storage domain');\n }\n return notifications;\n }\n\n async createNotification(input: CreateNotificationInput) {\n return (await this.getNotificationsStorage()).createNotification(input);\n }\n\n async listNotifications(input: ListNotificationsInput) {\n return (await this.getNotificationsStorage()).listNotifications(input);\n }\n\n async listDueNotifications(input: ListDueNotificationsInput) {\n return (await this.getNotificationsStorage()).listDueNotifications(input);\n }\n\n async getNotification(input: { threadId: string; id: string }) {\n return (await this.getNotificationsStorage()).getNotification(input);\n }\n\n async updateNotification(input: UpdateNotificationInput) {\n return (await this.getNotificationsStorage()).updateNotification(input);\n }\n\n async dangerouslyClearAll() {\n return (await this.getNotificationsStorage()).dangerouslyClearAll();\n }\n}\n\nexport type PostToolObserver = (context: ToolAfterHookContext) => void | Promise<void>;\n\nexport function createToolHooks(hookManager?: HookManager, postToolObserver?: PostToolObserver): ToolHooks | undefined {\n if (!hookManager && !postToolObserver) return undefined;\n\n return {\n beforeToolCall: async ({ toolName, input }) => {\n if (!hookManager) return;\n const preResult = await hookManager.runPreToolUse(toolName, input);\n if (!preResult.allowed) {\n return {\n proceed: false as const,\n output: {\n error: preResult.blockReason ?? `Blocked by PreToolUse hook for tool \"${toolName}\"`,\n },\n };\n }\n },\n afterToolCall: async context => {\n const { toolName, input, output, error } = context;\n if (hookManager) {\n const failed = error !== undefined;\n await hookManager\n .runPostToolUse(\n toolName,\n input,\n failed ? { error: error instanceof Error ? error.message : String(error) } : output,\n failed,\n )\n .catch(() => undefined);\n }\n await Promise.resolve()\n .then(() => postToolObserver?.(context))\n .catch(error => {\n console.warn(`[MastraCode] Post-tool observer failed for ${toolName}.`, error);\n });\n },\n };\n}\n\ntype DynamicToolProvider =\n | Record<string, ToolLike | undefined>\n | ((ctx: {\n requestContext: RequestContext;\n }) => Record<string, ToolLike | undefined> | Promise<Record<string, ToolLike | undefined>>);\n\nexport function createDynamicTools(\n mcpManager?: McpManager,\n extraTools?: DynamicToolProvider,\n disabledTools?: string[],\n storage?: MastraCompositeStore,\n pluginTools?: Record<string, ToolLike>,\n) {\n return function getDynamicTools({\n requestContext,\n }: {\n requestContext: RequestContext;\n }): ToolsInput | Promise<ToolsInput> {\n const ctx = requestContext.get('controller') as AgentControllerRequestContext<MastraCodeComposedState> | undefined;\n const state = ctx?.getState();\n\n const modelId = ctx?.session?.modelId;\n const isAnthropicModel = modelId?.startsWith('anthropic/');\n const isOpenAIModel = modelId?.startsWith('openai/');\n\n // Filesystem, grep, glob, edit, write, execute_command, and process\n // management tools are now provided by the workspace (see workspace.ts).\n // Only tools without a workspace equivalent remain here.\n const tools: Record<string, ToolLike> = {\n request_access: requestSandboxAccessTool,\n // Workflow surface. `create-workflow` delegates to the workflow-builder\n // sub-agent; the other four are Dynamic Workflow management operations.\n // Permission categories live in permissions.ts (TOOL_CATEGORY_MAP).\n [WORKFLOW_MANAGEMENT_TOOL_IDS.createWorkflow]: createWorkflowTool,\n [WORKFLOW_MANAGEMENT_TOOL_IDS.listWorkflows]: listWorkflowsTool,\n [WORKFLOW_MANAGEMENT_TOOL_IDS.getWorkflow]: getWorkflowTool,\n [WORKFLOW_MANAGEMENT_TOOL_IDS.runWorkflow]: runWorkflowTool,\n [WORKFLOW_MANAGEMENT_TOOL_IDS.deleteWorkflow]: deleteWorkflowTool,\n };\n\n if (storage) {\n tools[MC_TOOLS.NOTIFICATION_INBOX] = createNotificationInboxTool({\n storage: new LazyNotificationsStorage(storage),\n });\n }\n\n const configuredWebTools = createConfiguredWebTools();\n if (configuredWebTools) {\n Object.assign(tools, configuredWebTools);\n } else if (isAnthropicModel) {\n const anthropic = createAnthropic({});\n tools.web_search = anthropic.tools.webSearch_20250305();\n } else if (isOpenAIModel) {\n const openai = createOpenAI({});\n tools.web_search = openai.tools.webSearch();\n }\n\n if (mcpManager) {\n const mcpTools = mcpManager.getTools();\n Object.assign(tools, mcpTools);\n }\n\n const finish = (resolvedExtra: Record<string, ToolLike | undefined> | undefined) => {\n if (resolvedExtra) {\n for (const [name, tool] of Object.entries(resolvedExtra)) {\n if (tool && !(name in tools)) {\n tools[name] = tool;\n }\n }\n }\n\n if (pluginTools) {\n for (const [name, tool] of Object.entries(pluginTools)) {\n if (!(name in tools)) {\n tools[name] = tool;\n }\n }\n }\n\n // Remove tools explicitly disabled via config so the model never sees them.\n if (disabledTools?.length) {\n for (const toolName of disabledTools) {\n delete tools[toolName];\n }\n }\n\n // Remove tools that have a per-tool 'deny' policy so the model never sees them.\n const permissionRules = state?.permissionRules;\n if (permissionRules?.tools) {\n for (const [name, policy] of Object.entries(permissionRules.tools)) {\n if (policy === 'deny') {\n delete tools[name];\n }\n }\n }\n\n return tools as ToolsInput;\n };\n\n if (typeof extraTools === 'function') {\n const resolved = extraTools({ requestContext });\n // Stay synchronous for sync providers; only go async when the provider does.\n if (resolved && typeof (resolved as PromiseLike<unknown>).then === 'function') {\n return Promise.resolve(resolved).then(finish);\n }\n return finish(resolved as Record<string, ToolLike | undefined>);\n }\n\n return finish(extraTools);\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AA+BA,IAAa,2BAAb,cAA8C,qBAAqB;CACpC;CAA7B,YAAY,SAAgD;EAC1D,MAAM;EADqB,KAAA,UAAA;CAE7B;CAEA,MAAc,0BAAyD;EACrE,MAAM,gBAAgB,MAAM,KAAK,QA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AQ;GAAA;GAMpB,IAAI,eAAe,QACjB,KAAK,MAAM,YAAY,eACrB,OAAO,MAAM;GAKjB,MAAM,kBAAkB,OAAO;GAC/B,IAAI,iBAAiB,OACd;SAAA,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,gBAAgB,KAAK,GAC/D,IAAI,WAAW,QACb,OAAO,MAAM;GAAA;GAKnB,OAAO;EACT;EAEA,IAAI,OAAO,eAAe,YAAY;GACpC,MAAM,WAAW,WAAW,EAAE,eAAe,CAAC;GAE9C,IAAI,YAAY,OAAQ,SAAkC,SAAS,YACjE,OAAO,QAAQ,QAAQ,QAAQ,CAAC,CAAC,KAAK,MAAM;GAE9C,OAAO,OAAO,QAAgD;EAChE;EAEA,OAAO,OAAO,UAAU;CAC1B;AACF"}
|
|
@@ -57,6 +57,8 @@ export declare const MASTRA_GATEWAY_DEFAULT_URL = "https://gateway-api.mastra.ai
|
|
|
57
57
|
export declare const MEMORY_GATEWAY_PROVIDER = "mastra-gateway";
|
|
58
58
|
/** @deprecated Renamed to {@link MASTRA_GATEWAY_DEFAULT_URL}. */
|
|
59
59
|
export declare const MEMORY_GATEWAY_DEFAULT_URL = "https://gateway-api.mastra.ai";
|
|
60
|
+
/** Preferred model-independent web search/extract provider. */
|
|
61
|
+
export type WebSearchProviderSetting = 'auto' | 'tavily' | 'parallel';
|
|
60
62
|
/** Browser provider type. */
|
|
61
63
|
export type BrowserProvider = 'stagehand' | 'agent-browser';
|
|
62
64
|
/** Direct TUI `!` shell passthrough mode. */
|
|
@@ -250,6 +252,12 @@ export interface GlobalSettings {
|
|
|
250
252
|
quietMode: boolean;
|
|
251
253
|
/** Maximum quiet-mode detail preview lines for compact tool calls. Set to 0 to hide previews. */
|
|
252
254
|
quietModeMaxToolPreviewLines: number;
|
|
255
|
+
/**
|
|
256
|
+
* Default web search/extract provider. `auto` picks the first configured
|
|
257
|
+
* provider key (Tavily, then Parallel). An explicit provider is only
|
|
258
|
+
* honored while its API key is configured.
|
|
259
|
+
*/
|
|
260
|
+
webSearchProvider: WebSearchProviderSetting;
|
|
253
261
|
};
|
|
254
262
|
storage: StorageSettings;
|
|
255
263
|
customModelPacks: CustomPack[];
|
|
@@ -296,6 +304,7 @@ export declare const OBSERVABILITY_AUTH_PREFIX = "observability:";
|
|
|
296
304
|
export declare const STORAGE_DEFAULTS: StorageSettings;
|
|
297
305
|
/** Default STT engine: on-device macOS recognizer where available, else cloud. */
|
|
298
306
|
export declare function defaultVoiceEngine(): VoiceEngine;
|
|
307
|
+
export declare const WEB_SEARCH_PROVIDER_VALUES: WebSearchProviderSetting[];
|
|
299
308
|
export declare function getSettingsPath(): string;
|
|
300
309
|
export declare function getCustomProviderId(name: string): string;
|
|
301
310
|
export declare function toCustomProviderModelId(providerName: string, modelName: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/onboarding/settings.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAQxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC/E,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAIhF,yEAAyE;AACzE,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,+DAA+D;AAC/D,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;I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,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAcnF;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,GAAG,IAAI,CAMvF;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,cAAc,EAAE,eAAe,GAC9B,eAAe,GAAG,SAAS,CAS7B;AAMD;;;;GAIG;AACH,wBAAsB,yBAAyB,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CA4E7G"}
|
|
@@ -110,7 +110,8 @@ const DEFAULTS = {
|
|
|
110
110
|
theme: "auto",
|
|
111
111
|
thinkingLevel: "off",
|
|
112
112
|
quietMode: false,
|
|
113
|
-
quietModeMaxToolPreviewLines: 2
|
|
113
|
+
quietModeMaxToolPreviewLines: 2,
|
|
114
|
+
webSearchProvider: "auto"
|
|
114
115
|
},
|
|
115
116
|
storage: { ...STORAGE_DEFAULTS },
|
|
116
117
|
customModelPacks: [],
|
|
@@ -145,6 +146,11 @@ const DEFAULTS = {
|
|
|
145
146
|
localTracing: false
|
|
146
147
|
}
|
|
147
148
|
};
|
|
149
|
+
const WEB_SEARCH_PROVIDER_VALUES = [
|
|
150
|
+
"auto",
|
|
151
|
+
"tavily",
|
|
152
|
+
"parallel"
|
|
153
|
+
];
|
|
148
154
|
const QUIET_MODE_MAX_TOOL_PREVIEW_LINES_MAX = 8;
|
|
149
155
|
const loadedSignalSettings = /* @__PURE__ */ new WeakMap();
|
|
150
156
|
function cloneSignalSettings(signals) {
|
|
@@ -157,6 +163,9 @@ function rememberLoadedSettings(settings) {
|
|
|
157
163
|
function signalSettingsEqual(left, right) {
|
|
158
164
|
return left.unixSocketPubSub === right.unixSocketPubSub && left.experimentalGithubSignals === right.experimentalGithubSignals;
|
|
159
165
|
}
|
|
166
|
+
function parseWebSearchProvider(value) {
|
|
167
|
+
return typeof value === "string" && WEB_SEARCH_PROVIDER_VALUES.includes(value) ? value : DEFAULTS.preferences.webSearchProvider;
|
|
168
|
+
}
|
|
160
169
|
function parseThinkingLevel(value) {
|
|
161
170
|
return isThinkingLevelSetting(value) ? value : DEFAULTS.preferences.thinkingLevel;
|
|
162
171
|
}
|
|
@@ -176,7 +185,8 @@ function parsePreferences(rawPreferences) {
|
|
|
176
185
|
...DEFAULTS.preferences,
|
|
177
186
|
...raw,
|
|
178
187
|
thinkingLevel: parseThinkingLevel(raw.thinkingLevel),
|
|
179
|
-
quietModeMaxToolPreviewLines: parseQuietModeMaxToolPreviewLines(raw.quietModeMaxToolPreviewLines)
|
|
188
|
+
quietModeMaxToolPreviewLines: parseQuietModeMaxToolPreviewLines(raw.quietModeMaxToolPreviewLines),
|
|
189
|
+
webSearchProvider: parseWebSearchProvider(raw.webSearchProvider)
|
|
180
190
|
};
|
|
181
191
|
}
|
|
182
192
|
function parseSignalSettings(rawSignals) {
|
|
@@ -798,6 +808,6 @@ async function createBrowserFromSettings(settings) {
|
|
|
798
808
|
throw new Error(`Unsupported browser provider: ${provider}`);
|
|
799
809
|
}
|
|
800
810
|
//#endregion
|
|
801
|
-
export { MASTRA_GATEWAY_DEFAULT_URL, MASTRA_GATEWAY_PROVIDER, MEMORY_GATEWAY_DEFAULT_URL, MEMORY_GATEWAY_PROVIDER, OBSERVABILITY_AUTH_PREFIX, STORAGE_DEFAULTS, THINKING_LEVEL_VALUES, THREAD_ACTIVE_MODEL_PACK_ID_KEY, VIEWPORT_PRESETS, checkProfileProviderMismatch, createBrowserFromSettings, defaultVoiceEngine, getCustomProviderId, getProfileProvider, getSettingsPath, isThinkingLevelSetting, loadSettings, migrateLegacyVariedPack, parseCustomProviders, parseThreadSettings, parseViewportInput, resolveDefaultThinkingLevel, resolveLspSetting, resolveModelDefaults, resolveOmModel, resolveOmRoleModel, resolveThreadActiveModelPackId, saveSettings, setProfileProvider, stripMastraCodeCustomProviderPrefix, toCustomProviderModelId };
|
|
811
|
+
export { MASTRA_GATEWAY_DEFAULT_URL, MASTRA_GATEWAY_PROVIDER, MEMORY_GATEWAY_DEFAULT_URL, MEMORY_GATEWAY_PROVIDER, OBSERVABILITY_AUTH_PREFIX, STORAGE_DEFAULTS, THINKING_LEVEL_VALUES, THREAD_ACTIVE_MODEL_PACK_ID_KEY, VIEWPORT_PRESETS, WEB_SEARCH_PROVIDER_VALUES, checkProfileProviderMismatch, createBrowserFromSettings, defaultVoiceEngine, getCustomProviderId, getProfileProvider, getSettingsPath, isThinkingLevelSetting, loadSettings, migrateLegacyVariedPack, parseCustomProviders, parseThreadSettings, parseViewportInput, resolveDefaultThinkingLevel, resolveLspSetting, resolveModelDefaults, resolveOmModel, resolveOmRoleModel, resolveThreadActiveModelPackId, saveSettings, setProfileProvider, stripMastraCodeCustomProviderPrefix, toCustomProviderModelId };
|
|
802
812
|
|
|
803
813
|
//# sourceMappingURL=settings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","names":["resolveThinkingDefault"],"sources":["../../src/onboarding/settings.ts"],"sourcesContent":["/**\n * Persistent global settings stored in the app data directory as settings.json.\n * This file persists onboarding state AND user preferences (model choices, yolo, etc.)\n * so they carry across threads and restarts.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport type { MastraBrowser } from '@mastra/core/browser';\nimport type { LSPConfig } from '@mastra/core/workspace';\nimport { AuthStorage } from '../auth/storage.js';\nimport { buildCodexStagehandFetch, createCodexMiddleware } from '../providers/openai-codex.js';\nimport {\n isThinkingLevelSetting,\n resolveDefaultThinkingLevel as resolveThinkingDefault,\n THINKING_LEVEL_VALUES,\n} from '../thinking.js';\nimport type { ThinkingLevelSetting, ThinkingLevelSource } from '../thinking.js';\nexport { isThinkingLevelSetting, THINKING_LEVEL_VALUES } from '../thinking.js';\nexport type { ThinkingLevelSetting, ThinkingLevelSource } from '../thinking.js';\nimport { getAppDataDir } from '../utils/project.js';\nimport { DEFAULT_STT_PROVIDER, resolveSTTModel } from '../voice/stt-registry.js';\n\n/** A saved custom pack — user-defined model selections for each mode. */\nexport interface CustomPack {\n name: string;\n models: Record<string, string>;\n createdAt: string;\n}\n\n/** A saved custom provider for OpenAI-compatible endpoints. */\nexport interface CustomProviderSetting {\n name: string;\n url: string;\n apiKey?: string;\n models: string[];\n}\n\n/** Storage backend type. */\nexport type StorageBackend = 'libsql' | 'pg';\n\n/** LibSQL-specific storage settings. */\nexport interface LibSQLStorageSettings {\n url?: string;\n authToken?: string;\n}\n\n/** PostgreSQL-specific storage settings. */\nexport interface PgStorageSettings {\n connectionString?: string;\n host?: string;\n port?: number;\n database?: string;\n user?: string;\n password?: string;\n schemaName?: string;\n disableInit?: boolean;\n skipDefaultIndexes?: boolean;\n}\n\n/** Storage configuration persisted in global settings. */\nexport interface StorageSettings {\n /** Which backend to use. Default: 'libsql'. */\n backend: StorageBackend;\n /** LibSQL-specific config (used when backend is 'libsql'). */\n libsql: LibSQLStorageSettings;\n /** PostgreSQL-specific config (used when backend is 'pg'). */\n pg: PgStorageSettings;\n}\n\n/** Gateway provider key used in AuthStorage. */\nexport const MASTRA_GATEWAY_PROVIDER = 'mastra-gateway';\n\n/** Default gateway URL. */\nexport const MASTRA_GATEWAY_DEFAULT_URL = 'https://gateway-api.mastra.ai';\n\n/** @deprecated Renamed to {@link MASTRA_GATEWAY_PROVIDER}. */\nexport const MEMORY_GATEWAY_PROVIDER = MASTRA_GATEWAY_PROVIDER;\n\n/** @deprecated Renamed to {@link MASTRA_GATEWAY_DEFAULT_URL}. */\nexport const MEMORY_GATEWAY_DEFAULT_URL = MASTRA_GATEWAY_DEFAULT_URL;\n\n/** Browser provider type. */\nexport type BrowserProvider = 'stagehand' | 'agent-browser';\n\n/** Direct TUI `!` shell passthrough mode. */\nexport type ShellPassthroughSettingsMode = 'default' | 'path' | 'login';\n\n/** Direct TUI `!` shell command language. */\nexport type ShellPassthroughSettingsFamily = 'posix' | 'cmd' | 'powershell';\n\n/** Direct TUI `!` shell passthrough configuration. */\nexport interface ShellPassthroughSettings {\n mode?: ShellPassthroughSettingsMode | string;\n executable?: string;\n family?: ShellPassthroughSettingsFamily | string;\n}\n\n/** STT engine: on-device macOS recognizer or a cloud provider. */\nexport type VoiceEngine = 'macos-native' | 'cloud';\n\n/** Voice (hold-space dictation) configuration persisted in global settings. */\nexport interface VoiceSettings {\n /** Whether hold-space voice input is enabled. */\n enabled: boolean;\n /** Which STT engine to use. Defaults to macOS native on darwin, else cloud. */\n engine: VoiceEngine;\n /** Cloud provider id (matches an STT registry entry). Cloud engine only. */\n provider: string;\n /** Cloud model id; defaults to the provider's first registry model. */\n model?: string;\n}\n\n/** Stagehand environment type. */\nexport type StagehandEnv = 'LOCAL' | 'BROWSERBASE';\n\n/**\n * Browser viewport: explicit dimensions, or `'window'` to follow the real\n * browser window instead of emulating a fixed size.\n */\nexport type BrowserViewport = { width: number; height: number } | 'window';\n\n/** Named viewport sizes offered by `/browser set viewport`. */\nexport const VIEWPORT_PRESETS = {\n desktop: { width: 1280, height: 720 },\n 'desktop-hd': { width: 1920, height: 1080 },\n laptop: { width: 1440, height: 900 },\n tablet: { width: 768, height: 1024 },\n mobile: { width: 390, height: 844 },\n} as const satisfies Record<string, { width: number; height: number }>;\n\nexport type ViewportPreset = keyof typeof VIEWPORT_PRESETS;\n\n/**\n * Largest viewport dimension accepted. Guards against typos that would launch a\n * browser far larger than any display.\n */\nconst MAX_VIEWPORT_DIMENSION = 10000;\n\nfunction isValidDimension(value: unknown): value is number {\n return typeof value === 'number' && Number.isInteger(value) && value > 0 && value <= MAX_VIEWPORT_DIMENSION;\n}\n\n/**\n * Parse a `WIDTHxHEIGHT` string (e.g. `1280x720`), a preset name, or `window`.\n * Returns undefined when the input is not a usable viewport.\n */\nexport function parseViewportInput(input: string): BrowserViewport | undefined {\n const value = input.trim().toLowerCase();\n if (!value) return undefined;\n if (value === 'window') return 'window';\n if (value in VIEWPORT_PRESETS) return { ...VIEWPORT_PRESETS[value as ViewportPreset] };\n\n const match = /^(\\d+)\\s*[x×]\\s*(\\d+)$/.exec(value);\n if (!match) return undefined;\n const width = Number(match[1]);\n const height = Number(match[2]);\n if (!isValidDimension(width) || !isValidDimension(height)) return undefined;\n return { width, height };\n}\n\n/** Stagehand-specific browser settings. */\nexport interface StagehandSettings {\n env: StagehandEnv;\n apiKey?: string;\n projectId?: string;\n /**\n * Model Stagehand uses for its AI operations, as `provider/model`\n * (for example `anthropic/claude-sonnet-4-5`). Stagehand resolves the\n * provider's API key from the environment (`ANTHROPIC_API_KEY`,\n * `OPENAI_API_KEY`, and so on). Defaults to Stagehand's own default.\n */\n model?: string;\n /** Whether to preserve the user data directory after the browser closes. */\n preserveUserDataDir?: boolean;\n}\n\n/** AgentBrowser-specific browser settings. */\nexport interface AgentBrowserSettings {\n /** Path to a Playwright storage state file (JSON) containing cookies and localStorage. */\n storageState?: string;\n}\n\n/** Browser configuration persisted in global settings. */\nexport interface BrowserSettings {\n /** Whether browser automation is enabled. */\n enabled: boolean;\n /** Which browser provider to use. */\n provider: BrowserProvider;\n /** Whether to run headless (no visible browser window). */\n headless: boolean;\n /**\n * Browser viewport dimensions, or `'window'` to disable viewport emulation so\n * the page follows the real browser window.\n */\n viewport?: BrowserViewport;\n /** CDP URL for connecting to an existing browser. */\n cdpUrl?: string;\n /** Path to a Chrome/Chromium user data directory (profile). */\n profile?: string;\n /** Path to the browser executable to use. */\n executablePath?: string;\n /** Browser scope — 'shared' (all threads share one browser) or 'thread' (each thread gets its own). */\n scope?: 'shared' | 'thread';\n /** Stagehand-specific settings. */\n stagehand?: StagehandSettings;\n /** AgentBrowser-specific settings. */\n agentBrowser?: AgentBrowserSettings;\n}\n\nexport interface GlobalSettings {\n // Onboarding tracking\n onboarding: {\n completedAt: string | null;\n skippedAt: string | null;\n version: number;\n modePackId: string | null;\n omPackId: string | null;\n quietModePreferenceSelected: boolean;\n };\n // Global model preferences (applied to new threads)\n models: {\n /**\n * Active model pack ID. Built-in packs use their id directly (\"anthropic\",\n * \"openai\"). Custom packs use \"custom:<name>\".\n * When set, models are resolved from the pack at startup so pack updates\n * (e.g. new model versions) apply automatically.\n * Cleared when the user manually overrides via /models (falls back to modeDefaults).\n */\n activeModelPackId: string | null;\n /** Explicit per-mode overrides — used when no activeModelPackId is set. */\n modeDefaults: Record<string, string>;\n /**\n * Per-mode reasoning-effort defaults (e.g. { build: \"high\", plan: \"xhigh\" }).\n * Resolved at request time; falls back to `preferences.thinkingLevel` for\n * modes without an entry. Overridden per-session via /think or the session\n * settings panel.\n */\n modeThinkingDefaults: Record<string, ThinkingLevelSetting>;\n /**\n * Active OM pack ID (e.g. \"gemini\", \"anthropic\", \"custom\").\n * When set, the OM model is resolved from the pack at startup so pack\n * updates (e.g. new model versions) apply automatically.\n * Cleared when the user manually overrides via /om (falls back to omModelOverride).\n */\n activeOmPackId: string | null;\n /**\n * Shared OM model override — used for both observer and reflector when a\n * role-specific override is not set. Kept for back-compat with older settings\n * files and set by onboarding when the user picks a custom OM pack.\n */\n omModelOverride: string | null;\n /**\n * Explicit Observer model override — takes precedence over `omModelOverride`\n * when set. Written by `/om` when the observer model is changed independently.\n */\n observerModelOverride: string | null;\n /**\n * Explicit Reflector model override — takes precedence over `omModelOverride`\n * when set. Written by `/om` when the reflector model is changed independently.\n */\n reflectorModelOverride: string | null;\n /** Default OM observation threshold used for new threads unless overridden per-thread. */\n omObservationThreshold: number | null;\n /** Default OM reflection threshold used for new threads unless overridden per-thread. */\n omReflectionThreshold: number | null;\n /**\n * Whether observations and reflections use the terse caveman-style instruction.\n * `null` means inherit the built-in default (currently `false` — caveman is\n * opt-in via `/om` settings). Used as the default for new threads unless\n * overridden per-thread.\n */\n omCavemanObservations: boolean | null;\n /**\n * Whether Observational Memory forwards image/file attachment parts to the\n * Observer LLM. `null` ⇒ inherit built-in default ('auto'). 'auto' checks\n * model capabilities; true/false forces the setting.\n */\n omObserveAttachments: 'auto' | boolean | null;\n /** Per-agent-type subagent model overrides (e.g. { explore: \"openai/gpt-5.1-codex-mini\" }) */\n subagentModels: Record<string, string>;\n /** Default judge model for /goal. */\n goalJudgeModel: string | null;\n /** Default max attempts for /goal. */\n goalMaxTurns: number | null;\n };\n // Global behavior preferences\n preferences: {\n yolo: boolean | null;\n theme: 'auto' | 'dark' | 'light';\n /** Default reasoning effort level used for all threads/models unless overridden in-session. */\n thinkingLevel: ThinkingLevelSetting;\n /** When true, components like subagent output collapse to compact summaries on completion. */\n quietMode: boolean;\n /** Maximum quiet-mode detail preview lines for compact tool calls. Set to 0 to hide previews. */\n quietModeMaxToolPreviewLines: number;\n };\n // Storage backend configuration\n storage: StorageSettings;\n // User-created custom model packs\n customModelPacks: CustomPack[];\n // User-created custom providers with custom models\n customProviders: CustomProviderSetting[];\n // Model usage counts for ranking in the selector\n modelUseCounts: Record<string, number>;\n // Version the user dismissed the update prompt for (skip until they manually update past this)\n updateDismissedVersion: string | null;\n // Mastra gateway configuration\n memoryGateway: { baseUrl?: string };\n // LSP configuration forwarded to the workspace. Disabled unless the user\n // opts in with `true` or an LSPConfig object.\n lsp?: boolean | LSPConfig;\n // Browser automation configuration\n browser: BrowserSettings;\n // Direct TUI `!` shell passthrough configuration\n shellPassthrough: ShellPassthroughSettings;\n // Hold-space voice input configuration\n voice: VoiceSettings;\n // Signal routing configuration\n signals: SignalSettings;\n // Read-only discovery of MCP servers configured by other coding agents\n mcp: McpDiscoverySettings;\n // Cloud observability configuration (per-resource project IDs; tokens stored in auth.json)\n observability: ObservabilitySettings;\n}\n\nexport interface McpDiscoverySettings {\n /** Reuse top-level MCP servers from ~/.claude.json. */\n claudeCodeGlobal: boolean;\n /** Reuse MCP servers from $CODEX_HOME/config.toml or ~/.codex/config.toml. */\n codexGlobal: boolean;\n}\n\nexport interface SignalSettings {\n /** Opt into local Unix socket PubSub for cross-process signal routing. */\n unixSocketPubSub: boolean;\n /** Experimental: enable GitHub PR subscription signals backed by gitcrawl. */\n experimentalGithubSignals: boolean;\n}\n\nexport interface ObservabilityResourceConfig {\n /** Cloud project ID for this resource */\n projectId: string;\n /** When this config was created */\n configuredAt: string;\n}\n\nexport interface ObservabilitySettings {\n /** Per-resource cloud project configs, keyed by resourceId */\n resources: Record<string, ObservabilityResourceConfig>;\n /** Whether to store traces locally in DuckDB. Off by default to avoid disk usage. */\n localTracing: boolean;\n}\n\n/** Auth key prefix for observability tokens stored per-resource in auth.json */\nexport const OBSERVABILITY_AUTH_PREFIX = 'observability:';\n\nexport const STORAGE_DEFAULTS: StorageSettings = {\n backend: 'libsql',\n libsql: {},\n pg: {},\n};\n\n/** Default STT engine: on-device macOS recognizer where available, else cloud. */\nexport function defaultVoiceEngine(): VoiceEngine {\n return process.platform === 'darwin' ? 'macos-native' : 'cloud';\n}\n\nconst DEFAULTS: GlobalSettings = {\n onboarding: {\n completedAt: null,\n skippedAt: null,\n version: 0,\n modePackId: null,\n omPackId: null,\n quietModePreferenceSelected: true,\n },\n models: {\n activeModelPackId: null,\n modeDefaults: {},\n modeThinkingDefaults: {},\n activeOmPackId: null,\n omModelOverride: null,\n observerModelOverride: null,\n reflectorModelOverride: null,\n omObservationThreshold: null,\n omReflectionThreshold: null,\n omCavemanObservations: null,\n omObserveAttachments: null,\n subagentModels: {},\n goalJudgeModel: null,\n goalMaxTurns: null,\n },\n preferences: {\n yolo: null,\n theme: 'auto',\n thinkingLevel: 'off',\n quietMode: false,\n quietModeMaxToolPreviewLines: 2,\n },\n storage: { ...STORAGE_DEFAULTS },\n customModelPacks: [],\n customProviders: [],\n modelUseCounts: {},\n updateDismissedVersion: null,\n memoryGateway: {},\n lsp: false,\n browser: {\n enabled: false,\n provider: 'stagehand',\n headless: false,\n viewport: { ...VIEWPORT_PRESETS.desktop },\n stagehand: { env: 'LOCAL' },\n },\n shellPassthrough: { mode: 'default' },\n voice: { enabled: false, engine: defaultVoiceEngine(), provider: DEFAULT_STT_PROVIDER },\n signals: { unixSocketPubSub: false, experimentalGithubSignals: false },\n mcp: { claudeCodeGlobal: false, codexGlobal: false },\n observability: { resources: {}, localTracing: false },\n};\n\nconst QUIET_MODE_MAX_TOOL_PREVIEW_LINES_MAX = 8;\nconst loadedSignalSettings = new WeakMap<GlobalSettings, SignalSettings>();\n\nfunction cloneSignalSettings(signals: SignalSettings): SignalSettings {\n return { ...signals };\n}\n\nfunction rememberLoadedSettings(settings: GlobalSettings): GlobalSettings {\n loadedSignalSettings.set(settings, cloneSignalSettings(settings.signals));\n return settings;\n}\n\nfunction signalSettingsEqual(left: SignalSettings, right: SignalSettings): boolean {\n return (\n left.unixSocketPubSub === right.unixSocketPubSub &&\n left.experimentalGithubSignals === right.experimentalGithubSignals\n );\n}\n\nfunction parseThinkingLevel(value: unknown): ThinkingLevelSetting {\n return isThinkingLevelSetting(value) ? value : DEFAULTS.preferences.thinkingLevel;\n}\n\nfunction parseModeThinkingDefaults(value: unknown): Record<string, ThinkingLevelSetting> {\n if (!value || typeof value !== 'object') return {};\n const result: Record<string, ThinkingLevelSetting> = {};\n for (const [mode, level] of Object.entries(value as Record<string, unknown>)) {\n if (isThinkingLevelSetting(level)) {\n result[mode] = level;\n }\n }\n return result;\n}\n\nfunction parseQuietModeMaxToolPreviewLines(value: unknown): number {\n const rawValue =\n typeof value === 'number' && Number.isFinite(value) ? value : DEFAULTS.preferences.quietModeMaxToolPreviewLines;\n return Math.min(QUIET_MODE_MAX_TOOL_PREVIEW_LINES_MAX, Math.max(0, Math.floor(rawValue)));\n}\n\nfunction parsePreferences(rawPreferences: unknown): GlobalSettings['preferences'] {\n const raw = rawPreferences && typeof rawPreferences === 'object' ? (rawPreferences as Record<string, unknown>) : {};\n\n return {\n ...DEFAULTS.preferences,\n ...raw,\n thinkingLevel: parseThinkingLevel(raw.thinkingLevel),\n quietModeMaxToolPreviewLines: parseQuietModeMaxToolPreviewLines(raw.quietModeMaxToolPreviewLines),\n };\n}\n\nfunction parseSignalSettings(rawSignals: unknown): SignalSettings {\n const raw = rawSignals && typeof rawSignals === 'object' ? (rawSignals as Record<string, unknown>) : {};\n return {\n unixSocketPubSub:\n typeof raw.unixSocketPubSub === 'boolean' ? raw.unixSocketPubSub : DEFAULTS.signals.unixSocketPubSub,\n experimentalGithubSignals:\n typeof raw.experimentalGithubSignals === 'boolean'\n ? raw.experimentalGithubSignals\n : DEFAULTS.signals.experimentalGithubSignals,\n };\n}\n\nfunction parseMcpDiscoverySettings(rawMcp: unknown): McpDiscoverySettings {\n const raw = rawMcp && typeof rawMcp === 'object' ? (rawMcp as Record<string, unknown>) : {};\n return {\n claudeCodeGlobal: typeof raw.claudeCodeGlobal === 'boolean' ? raw.claudeCodeGlobal : DEFAULTS.mcp.claudeCodeGlobal,\n codexGlobal: typeof raw.codexGlobal === 'boolean' ? raw.codexGlobal : DEFAULTS.mcp.codexGlobal,\n };\n}\n\nfunction hasQuietModePreferenceSelected(rawOnboarding: unknown): boolean {\n return Boolean(\n rawOnboarding &&\n typeof rawOnboarding === 'object' &&\n Object.prototype.hasOwnProperty.call(rawOnboarding, 'quietModePreferenceSelected'),\n );\n}\n\nfunction applyQuietModePreferenceRollout(settings: GlobalSettings, rawOnboarding: unknown): void {\n if (hasQuietModePreferenceSelected(rawOnboarding)) return;\n settings.onboarding.quietModePreferenceSelected = settings.preferences.quietMode === true;\n}\n\nfunction getNewInstallDefaults(): GlobalSettings {\n const settings = structuredClone(DEFAULTS);\n settings.preferences.quietMode = true;\n settings.onboarding.quietModePreferenceSelected = true;\n return settings;\n}\n\nexport function getSettingsPath(): string {\n return join(getAppDataDir(), 'settings.json');\n}\n\nexport function getCustomProviderId(name: string): string {\n const slug = name\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '');\n return slug || 'provider';\n}\n\nexport function toCustomProviderModelId(providerName: string, modelName: string): string {\n const providerId = getCustomProviderId(providerName);\n const trimmedModelName = modelName.trim();\n const providerPrefix = `${providerId}/`;\n if (trimmedModelName.startsWith(providerPrefix)) {\n return trimmedModelName;\n }\n return `${providerId}/${trimmedModelName}`;\n}\n\n/**\n * The shared gateway catalog namespaces provider keys under their owning\n * gateway id, so a custom provider's models surface in the `/models` catalog\n * as `mastracode/<providerId>/<model>` instead of the canonical\n * `<providerId>/<model>` that model resolution expects. Persisting the\n * gateway-qualified id verbatim breaks lookup later (the provider is parsed\n * as `mastracode`). Strip the prefix before saving — but only when the\n * middle segment matches one of the user's configured custom providers, so\n * legitimate `mastracode/...` gateway-routed ids are left untouched.\n */\nexport function stripMastraCodeCustomProviderPrefix(\n modelId: string,\n customProviders: Array<Pick<CustomProviderSetting, 'name'>>,\n): string {\n const gatewayPrefix = 'mastracode/';\n if (!modelId.startsWith(gatewayPrefix)) return modelId;\n\n const rest = modelId.slice(gatewayPrefix.length);\n const [providerId, ...modelParts] = rest.split('/');\n if (!providerId || modelParts.length === 0 || modelParts.some(part => part.length === 0)) return modelId;\n\n const isCustomProvider = customProviders.some(provider => getCustomProviderId(provider.name) === providerId);\n return isCustomProvider ? rest : modelId;\n}\n\nexport function parseCustomProviders(rawProviders: unknown): CustomProviderSetting[] {\n if (!Array.isArray(rawProviders)) return [];\n\n const parsedProviders: CustomProviderSetting[] = [];\n for (const rawProvider of rawProviders) {\n if (!rawProvider || typeof rawProvider !== 'object') continue;\n\n const candidate = rawProvider as Record<string, unknown>;\n const name = typeof candidate.name === 'string' ? candidate.name.trim() : '';\n const url = typeof candidate.url === 'string' ? candidate.url.trim() : '';\n if (!name || !url) continue;\n\n const providerId = getCustomProviderId(name);\n const models = Array.isArray(candidate.models)\n ? [\n ...new Set(\n candidate.models\n .filter((model): model is string => typeof model === 'string')\n .map(model => model.trim())\n .map(model => {\n const providerPrefix = `${providerId}/`;\n if (model.startsWith(providerPrefix)) {\n return model.slice(providerPrefix.length);\n }\n return model;\n }),\n ),\n ].filter(model => model.length > 0)\n : [];\n\n const apiKey =\n typeof candidate.apiKey === 'string' && candidate.apiKey.trim().length > 0 ? candidate.apiKey.trim() : undefined;\n\n parsedProviders.push({\n name,\n url,\n ...(apiKey ? { apiKey } : {}),\n models,\n });\n }\n\n return parsedProviders;\n}\n\nconst BROWSER_PROVIDERS = new Set<BrowserProvider>(['stagehand', 'agent-browser']);\nconst STAGEHAND_ENVS = new Set<StagehandEnv>(['LOCAL', 'BROWSERBASE']);\n\n/**\n * Normalize a Stagehand model id, which must be provider-qualified.\n *\n * Stagehand reads the segment before the first slash as the provider, so a\n * bare id like `gpt-4.1` is rejected as an unknown provider and a trailing\n * slash leaves an empty model name that only fails once a request is made.\n * Neither is usable, so both are dropped here rather than persisted.\n *\n * The provider name itself is checked where the command is issued, which can\n * name the supported providers in an error; this module is on the startup path\n * and only imports Stagehand lazily.\n *\n * @returns the trimmed model id, or undefined when it is unusable.\n */\nfunction parseStagehandModel(value: unknown): string | undefined {\n if (typeof value !== 'string') return undefined;\n const model = value.trim();\n const separator = model.indexOf('/');\n if (separator <= 0) return undefined;\n return model.slice(separator + 1).trim() ? model : undefined;\n}\n\n/**\n * Validate a viewport read from settings.json, falling back to the default when\n * it is missing or malformed.\n */\nfunction parseStoredViewport(raw: unknown): BrowserViewport {\n if (raw === 'window') return 'window';\n if (raw && typeof raw === 'object') {\n const { width, height } = raw as Record<string, unknown>;\n if (isValidDimension(width) && isValidDimension(height)) return { width, height };\n }\n return { ...VIEWPORT_PRESETS.desktop };\n}\n\n/**\n * Validate the `lsp` setting from JSON. Accepts both the boolean opt-in/opt-out\n * form and the full LSPConfig object; anything else is treated as unset.\n */\nfunction parseLspSettings(raw: unknown): boolean | LSPConfig | undefined {\n if (typeof raw === 'boolean') return raw;\n if (raw && typeof raw === 'object') return raw as LSPConfig;\n return undefined;\n}\n\n/**\n * Resolve the effective LSP config. LSP is opt-in: `false` and an absent\n * setting both mean disabled, `true` means enabled with defaults.\n */\nexport function resolveLspSetting(lsp: boolean | LSPConfig | undefined): LSPConfig | false {\n if (lsp === true) return {};\n if (!lsp) return false;\n return lsp;\n}\n\n/**\n * Deep-merge and validate browser settings from JSON.\n * Explicitly validates types to handle malformed settings.json gracefully.\n */\nfunction parseBrowserSettings(rawBrowser: unknown): BrowserSettings {\n const raw = rawBrowser && typeof rawBrowser === 'object' ? (rawBrowser as Record<string, unknown>) : {};\n const rawStagehand =\n raw.stagehand && typeof raw.stagehand === 'object' ? (raw.stagehand as Record<string, unknown>) : {};\n const stagehandModel = parseStagehandModel(rawStagehand.model);\n const rawAgentBrowser =\n raw.agentBrowser && typeof raw.agentBrowser === 'object' ? (raw.agentBrowser as Record<string, unknown>) : {};\n\n return {\n enabled: typeof raw.enabled === 'boolean' ? raw.enabled : DEFAULTS.browser.enabled,\n provider:\n typeof raw.provider === 'string' && BROWSER_PROVIDERS.has(raw.provider as BrowserProvider)\n ? (raw.provider as BrowserProvider)\n : DEFAULTS.browser.provider,\n headless: typeof raw.headless === 'boolean' ? raw.headless : DEFAULTS.browser.headless,\n cdpUrl: typeof raw.cdpUrl === 'string' && raw.cdpUrl.trim() ? raw.cdpUrl.trim() : undefined,\n profile: typeof raw.profile === 'string' && raw.profile.trim() ? raw.profile.trim() : undefined,\n executablePath:\n typeof raw.executablePath === 'string' && raw.executablePath.trim() ? raw.executablePath.trim() : undefined,\n viewport: parseStoredViewport(raw.viewport),\n scope: typeof raw.scope === 'string' && (raw.scope === 'shared' || raw.scope === 'thread') ? raw.scope : undefined,\n stagehand: {\n env:\n typeof rawStagehand.env === 'string' && STAGEHAND_ENVS.has(rawStagehand.env as StagehandEnv)\n ? (rawStagehand.env as StagehandEnv)\n : DEFAULTS.browser.stagehand!.env,\n ...(typeof rawStagehand.apiKey === 'string' && rawStagehand.apiKey.trim()\n ? { apiKey: rawStagehand.apiKey.trim() }\n : {}),\n ...(typeof rawStagehand.projectId === 'string' && rawStagehand.projectId.trim()\n ? { projectId: rawStagehand.projectId.trim() }\n : {}),\n ...(stagehandModel ? { model: stagehandModel } : {}),\n ...(typeof rawStagehand.preserveUserDataDir === 'boolean'\n ? { preserveUserDataDir: rawStagehand.preserveUserDataDir }\n : {}),\n },\n agentBrowser:\n typeof rawAgentBrowser.storageState === 'string' && rawAgentBrowser.storageState.trim()\n ? { storageState: rawAgentBrowser.storageState.trim() }\n : undefined,\n };\n}\n\nfunction parseShellPassthroughSettings(rawShellPassthrough: unknown): ShellPassthroughSettings {\n const raw =\n rawShellPassthrough && typeof rawShellPassthrough === 'object'\n ? (rawShellPassthrough as Record<string, unknown>)\n : {};\n const executable = typeof raw.executable === 'string' && raw.executable.trim() ? raw.executable.trim() : undefined;\n const family = typeof raw.family === 'string' && raw.family.trim() ? raw.family.trim() : undefined;\n const mode = typeof raw.mode === 'string' && raw.mode.trim() ? raw.mode.trim() : undefined;\n const defaultMode = executable ? undefined : DEFAULTS.shellPassthrough.mode;\n\n return {\n ...((mode ?? defaultMode) ? { mode: mode ?? defaultMode } : {}),\n ...(executable ? { executable } : {}),\n ...(family ? { family } : {}),\n };\n}\n\nfunction parseVoiceSettings(rawVoice: unknown): VoiceSettings {\n const raw = rawVoice && typeof rawVoice === 'object' ? (rawVoice as Record<string, unknown>) : {};\n const enabled = typeof raw.enabled === 'boolean' ? raw.enabled : DEFAULTS.voice.enabled;\n const engine: VoiceEngine =\n raw.engine === 'macos-native' || raw.engine === 'cloud' ? raw.engine : defaultVoiceEngine();\n // Validate provider/model against the registry, falling back to a usable entry\n // so old `{ enabled }`-only files and unknown values still resolve cleanly.\n const provider = typeof raw.provider === 'string' ? raw.provider : DEFAULTS.voice.provider;\n const model = typeof raw.model === 'string' ? raw.model : undefined;\n const resolved = resolveSTTModel(provider, model);\n return {\n enabled,\n engine,\n provider: resolved.provider,\n model: resolved.model,\n };\n}\n\nconst VALID_PROJECT_ID = /^[a-zA-Z0-9_-]+$/;\n\nfunction parseObservabilitySettings(raw: unknown): ObservabilitySettings {\n if (!raw || typeof raw !== 'object') return { resources: {}, localTracing: false };\n const obj = raw as Record<string, unknown>;\n const localTracing = obj.localTracing === true;\n const rawResources = obj.resources;\n if (!rawResources || typeof rawResources !== 'object') return { resources: {}, localTracing };\n const resources: Record<string, ObservabilityResourceConfig> = {};\n for (const [key, val] of Object.entries(rawResources as Record<string, unknown>)) {\n if (val && typeof val === 'object') {\n const v = val as Record<string, unknown>;\n if (typeof v.projectId === 'string' && VALID_PROJECT_ID.test(v.projectId)) {\n resources[key] = {\n projectId: v.projectId,\n configuredAt: typeof v.configuredAt === 'string' ? v.configuredAt : new Date().toISOString(),\n };\n }\n }\n }\n return { resources, localTracing };\n}\n\n/**\n * One-time migration: move model-related data from auth.json to settings.json.\n * Reads `_modelRanks`, `_modeModelId_*`, `_subagentModelId*` from auth.json,\n * merges them into settings, removes them from auth.json, and writes both files.\n * No-ops if auth.json has no _ prefixed model data.\n */\nfunction migrateFromAuth(settingsPath: string): boolean {\n const authPath = join(getAppDataDir(), 'auth.json');\n if (!existsSync(authPath)) return false;\n\n let authData: Record<string, any>;\n try {\n authData = JSON.parse(readFileSync(authPath, 'utf-8'));\n } catch {\n return false;\n }\n\n const modelKeys = Object.keys(authData).filter(k => k.startsWith('_'));\n if (modelKeys.length === 0) return false;\n\n // Load existing settings (or defaults) and merge auth data into it\n let settings: GlobalSettings;\n if (existsSync(settingsPath)) {\n try {\n const raw = JSON.parse(readFileSync(settingsPath, 'utf-8'));\n settings = {\n onboarding: { ...DEFAULTS.onboarding, ...raw.onboarding },\n models: { ...DEFAULTS.models, ...raw.models },\n preferences: parsePreferences(raw.preferences),\n storage: {\n ...STORAGE_DEFAULTS,\n ...raw.storage,\n libsql: { ...STORAGE_DEFAULTS.libsql, ...raw.storage?.libsql },\n pg: { ...STORAGE_DEFAULTS.pg, ...raw.storage?.pg },\n },\n customModelPacks: Array.isArray(raw.customModelPacks) ? raw.customModelPacks : [],\n customProviders: parseCustomProviders(raw.customProviders),\n modelUseCounts: raw.modelUseCounts && typeof raw.modelUseCounts === 'object' ? raw.modelUseCounts : {},\n updateDismissedVersion: typeof raw.updateDismissedVersion === 'string' ? raw.updateDismissedVersion : null,\n memoryGateway: raw.memoryGateway && typeof raw.memoryGateway === 'object' ? raw.memoryGateway : {},\n lsp: parseLspSettings(raw.lsp),\n browser: parseBrowserSettings(raw.browser),\n shellPassthrough: parseShellPassthroughSettings(raw.shellPassthrough),\n voice: parseVoiceSettings(raw.voice),\n signals: parseSignalSettings(raw.signals),\n mcp: parseMcpDiscoverySettings(raw.mcp),\n observability: parseObservabilitySettings(raw.observability),\n };\n applyQuietModePreferenceRollout(settings, raw.onboarding);\n } catch {\n settings = structuredClone(DEFAULTS);\n }\n } else {\n settings = structuredClone(DEFAULTS);\n }\n\n // Migrate model use counts (only if settings doesn't already have them)\n if (authData._modelRanks && typeof authData._modelRanks === 'object') {\n settings.modelUseCounts = { ...authData._modelRanks, ...settings.modelUseCounts };\n }\n\n // Migrate per-mode model defaults (don't overwrite existing settings)\n for (const key of modelKeys) {\n const modeMatch = key.match(/^_modeModelId_(.+)$/);\n if (modeMatch?.[1] && typeof authData[key] === 'string' && !settings.models.modeDefaults[modeMatch[1]]) {\n settings.models.modeDefaults[modeMatch[1]] = authData[key];\n }\n }\n\n // Migrate subagent models (don't overwrite existing settings)\n for (const key of modelKeys) {\n if (key === '_subagentModelId' && typeof authData[key] === 'string' && !settings.models.subagentModels['default']) {\n settings.models.subagentModels['default'] = authData[key];\n }\n const saMatch = key.match(/^_subagentModelId_(.+)$/);\n if (saMatch?.[1] && typeof authData[key] === 'string' && !settings.models.subagentModels[saMatch[1]]) {\n settings.models.subagentModels[saMatch[1]] = authData[key];\n }\n }\n\n // Write migrated settings\n saveSettings(settings, settingsPath);\n\n // Clean up auth.json — remove _ prefixed keys\n for (const key of modelKeys) {\n delete authData[key];\n }\n try {\n writeFileSync(authPath, JSON.stringify(authData, null, 2), 'utf-8');\n } catch {\n // Non-fatal — settings are saved, auth cleanup can fail\n }\n\n return true;\n}\n\nconst LEGACY_VARIED_MODELS: Record<string, string> = {\n plan: 'openai/gpt-5.4',\n build: 'anthropic/claude-sonnet-4-5',\n fast: 'anthropic/claude-haiku-4-5',\n};\n\nexport function migrateLegacyVariedPack(settings: GlobalSettings): boolean {\n const legacyPackId = 'varied';\n const customPackId = 'custom:varied';\n const hasLegacyReference =\n settings.models.activeModelPackId === legacyPackId || settings.onboarding.modePackId === legacyPackId;\n\n if (!hasLegacyReference) return false;\n\n const existingIdx = settings.customModelPacks.findIndex(p => p.name === 'varied');\n if (existingIdx >= 0) {\n const existing = settings.customModelPacks[existingIdx]!;\n const modelsMatch = Object.entries(LEGACY_VARIED_MODELS).every(([k, v]) => existing.models[k] === v);\n if (!modelsMatch) {\n existing.models = { ...LEGACY_VARIED_MODELS };\n }\n } else {\n settings.customModelPacks.push({\n name: 'varied',\n models: { ...LEGACY_VARIED_MODELS },\n createdAt: new Date().toISOString(),\n });\n }\n\n if (settings.models.activeModelPackId === legacyPackId) {\n settings.models.activeModelPackId = customPackId;\n if (Object.keys(settings.models.modeDefaults).length === 0) {\n settings.models.modeDefaults = { ...LEGACY_VARIED_MODELS };\n }\n }\n\n if (settings.onboarding.modePackId === legacyPackId) {\n settings.onboarding.modePackId = customPackId;\n }\n\n return true;\n}\n\nexport function loadSettings(filePath: string = getSettingsPath()): GlobalSettings {\n // One-time migration: move model data from auth.json into settings.json\n migrateFromAuth(filePath);\n\n if (!existsSync(filePath)) return rememberLoadedSettings(getNewInstallDefaults());\n try {\n const raw = JSON.parse(readFileSync(filePath, 'utf-8'));\n // Spread raw first to preserve unknown top-level keys (forward-compatibility),\n // then overlay with parsed/typed fields so known keys are always correct.\n const settings: GlobalSettings = {\n ...raw,\n onboarding: { ...DEFAULTS.onboarding, ...raw.onboarding },\n models: {\n ...DEFAULTS.models,\n ...raw.models,\n modeThinkingDefaults: parseModeThinkingDefaults(raw.models?.modeThinkingDefaults),\n },\n preferences: parsePreferences(raw.preferences),\n storage: {\n ...STORAGE_DEFAULTS,\n ...raw.storage,\n libsql: { ...STORAGE_DEFAULTS.libsql, ...raw.storage?.libsql },\n pg: { ...STORAGE_DEFAULTS.pg, ...raw.storage?.pg },\n },\n customModelPacks: Array.isArray(raw.customModelPacks) ? raw.customModelPacks : [],\n customProviders: parseCustomProviders(raw.customProviders),\n modelUseCounts: raw.modelUseCounts && typeof raw.modelUseCounts === 'object' ? raw.modelUseCounts : {},\n updateDismissedVersion: typeof raw.updateDismissedVersion === 'string' ? raw.updateDismissedVersion : null,\n memoryGateway: raw.memoryGateway && typeof raw.memoryGateway === 'object' ? raw.memoryGateway : {},\n lsp: parseLspSettings(raw.lsp),\n browser: parseBrowserSettings(raw.browser),\n shellPassthrough: parseShellPassthroughSettings(raw.shellPassthrough),\n voice: parseVoiceSettings(raw.voice),\n signals: parseSignalSettings(raw.signals),\n mcp: parseMcpDiscoverySettings(raw.mcp),\n observability: parseObservabilitySettings(raw.observability),\n };\n\n // Migrate legacy omModelId → omModelOverride\n let settingsChanged = false;\n if (!hasQuietModePreferenceSelected(raw.onboarding)) {\n applyQuietModePreferenceRollout(settings, raw.onboarding);\n settingsChanged = true;\n }\n if (raw.models?.omModelId && !settings.models.omModelOverride) {\n settings.models.omModelOverride = raw.models.omModelId;\n settingsChanged = true;\n }\n\n if (migrateLegacyVariedPack(settings)) {\n settingsChanged = true;\n }\n\n if (settingsChanged) {\n saveSettings(settings, filePath);\n }\n\n return rememberLoadedSettings(settings);\n } catch {\n return rememberLoadedSettings(structuredClone(DEFAULTS));\n }\n}\n\nexport const THREAD_ACTIVE_MODEL_PACK_ID_KEY = 'activeModelPackId';\n\nexport interface ThreadSettings {\n activeModelPackId: string | null;\n modeModelIds: Record<string, string>;\n}\n\nexport function parseThreadSettings(metadata: Record<string, unknown> | undefined): ThreadSettings {\n const modeModelIds: Record<string, string> = {};\n for (const [key, value] of Object.entries(metadata ?? {})) {\n const modeMatch = key.match(/^modeModelId_(.+)$/);\n if (modeMatch?.[1] && typeof value === 'string' && value.length > 0) {\n modeModelIds[modeMatch[1]] = value;\n }\n }\n\n const rawPackId = metadata?.[THREAD_ACTIVE_MODEL_PACK_ID_KEY];\n const activeModelPackId = typeof rawPackId === 'string' && rawPackId.length > 0 ? rawPackId : null;\n\n return {\n activeModelPackId,\n modeModelIds,\n };\n}\n\n/**\n * Resolve active model pack id for the current thread.\n *\n * Priority:\n * 1) explicit thread metadata activeModelPackId\n * 2) inferred from thread modeModelId_* values\n * 3) global settings.models.activeModelPackId\n */\nexport function resolveThreadActiveModelPackId(\n settings: GlobalSettings,\n builtinPacks: Array<{ id: string; models: Record<string, string> }>,\n metadata: Record<string, unknown> | undefined,\n): string | null {\n const threadSettings = parseThreadSettings(metadata);\n\n const isKnownPack = (packId: string): boolean => {\n if (packId.startsWith('custom:')) {\n const name = packId.slice('custom:'.length);\n return settings.customModelPacks.some(p => p.name === name);\n }\n return builtinPacks.some(p => p.id === packId);\n };\n\n if (threadSettings.activeModelPackId && isKnownPack(threadSettings.activeModelPackId)) {\n return threadSettings.activeModelPackId;\n }\n\n const allPacks: Array<{ id: string; models: Record<string, string> }> = [\n ...builtinPacks,\n ...settings.customModelPacks.map(p => ({ id: `custom:${p.name}`, models: p.models })),\n ];\n\n for (const pack of allPacks) {\n const packEntries = Object.entries(pack.models);\n const threadEntries = Object.keys(threadSettings.modeModelIds);\n const matches =\n packEntries.length === threadEntries.length &&\n packEntries.every(([modeId, modelId]) => threadSettings.modeModelIds[modeId] === modelId);\n if (matches) return pack.id;\n }\n\n if (settings.models.activeModelPackId && isKnownPack(settings.models.activeModelPackId)) {\n return settings.models.activeModelPackId;\n }\n\n return null;\n}\n\n/**\n * Resolve effective per-mode model defaults.\n *\n * If `activeModelPackId` is set, looks up the pack (built-in or custom) and\n * returns its models. Falls back to the explicit `modeDefaults` map.\n *\n * @param settings The loaded global settings.\n * @param builtinPacks Built-in packs for the current provider access\n * (from `getAvailableModePacks`). Pass `[]` if unavailable.\n */\nexport function resolveModelDefaults(\n settings: GlobalSettings,\n builtinPacks: Array<{ id: string; models: Record<string, string> }>,\n): Record<string, string> {\n const { activeModelPackId, modeDefaults } = settings.models;\n if (!activeModelPackId) return modeDefaults;\n\n // Custom pack: \"custom:<name>\"\n if (activeModelPackId.startsWith('custom:')) {\n const name = activeModelPackId.slice('custom:'.length);\n const pack = settings.customModelPacks.find(p => p.name === name);\n if (pack) return pack.models;\n // Custom pack was deleted — fall through to modeDefaults\n return modeDefaults;\n }\n\n // Built-in pack\n const builtin = builtinPacks.find(p => p.id === activeModelPackId);\n if (builtin) return builtin.models;\n\n // Unknown pack id — fall through\n return modeDefaults;\n}\n\n/**\n * Resolve the default reasoning-effort level for a mode.\n *\n * Lookup order:\n * 1. `models.modeThinkingDefaults[mode]` when set for the mode.\n * 2. The global `preferences.thinkingLevel`.\n *\n * Session-level overrides (via /think or the session settings panel) take\n * precedence over both and are handled by the caller.\n */\nexport function resolveDefaultThinkingLevel(\n settings: GlobalSettings,\n mode?: string | null,\n): { level: ThinkingLevelSetting; source: ThinkingLevelSource } {\n return resolveThinkingDefault(\n {\n globalDefault: settings.preferences.thinkingLevel,\n modeDefaults: settings.models.modeThinkingDefaults,\n },\n mode,\n );\n}\n\n/**\n * Resolve the effective model ID for one of the two OM roles.\n *\n * Lookup order:\n * 1. The role-specific override (`observerModelOverride` /\n * `reflectorModelOverride`) if set.\n * 2. If `activeOmPackId` points at a built-in pack, that pack's model.\n * 3. The shared `omModelOverride` fallback.\n *\n * @param settings The loaded global settings.\n * @param role Which OM role to resolve (`'observer'` or `'reflector'`).\n * @param builtinOmPacks Built-in OM packs for the current provider access\n * (from `getAvailableOmPacks`). Pass `[]` if unavailable.\n */\nexport function resolveOmRoleModel(\n settings: GlobalSettings,\n role: 'observer' | 'reflector',\n builtinOmPacks: Array<{ id: string; modelId: string }>,\n): string | null {\n const { activeOmPackId, omModelOverride, observerModelOverride, reflectorModelOverride } = settings.models;\n const roleOverride = role === 'observer' ? observerModelOverride : reflectorModelOverride;\n if (roleOverride) return roleOverride;\n\n if (!activeOmPackId) return omModelOverride;\n if (activeOmPackId === 'custom') return omModelOverride;\n\n const pack = builtinOmPacks.find(p => p.id === activeOmPackId);\n if (pack) return pack.modelId;\n\n return omModelOverride;\n}\n\n/**\n * @deprecated Use `resolveOmRoleModel(settings, 'observer' | 'reflector', ...)`.\n * Equivalent to resolving the observer role (existing callers set both observer\n * and reflector to the same value).\n */\nexport function resolveOmModel(\n settings: GlobalSettings,\n builtinOmPacks: Array<{ id: string; modelId: string }>,\n): string | null {\n return resolveOmRoleModel(settings, 'observer', builtinOmPacks);\n}\n\nfunction getSignalSettingsForSave(settings: GlobalSettings, filePath: string): SignalSettings {\n const loadedSignals = loadedSignalSettings.get(settings);\n if (!loadedSignals || !signalSettingsEqual(settings.signals, loadedSignals) || !existsSync(filePath)) {\n return settings.signals;\n }\n\n try {\n const currentRaw = JSON.parse(readFileSync(filePath, 'utf-8')) as Record<string, unknown>;\n const currentSignals = parseSignalSettings(currentRaw.signals);\n if (!signalSettingsEqual(currentSignals, loadedSignals)) {\n return currentSignals;\n }\n } catch {\n // If the current file is unreadable, fall back to the caller's settings.\n }\n\n return settings.signals;\n}\n\nexport function saveSettings(settings: GlobalSettings, filePath: string = getSettingsPath()): void {\n const dir = dirname(filePath);\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n const signals = getSignalSettingsForSave(settings, filePath);\n settings.signals = signals;\n loadedSignalSettings.set(settings, cloneSignalSettings(signals));\n writeFileSync(filePath, JSON.stringify(settings, null, 2), 'utf-8');\n}\n\n/** Marker file name to track which provider last used a profile. */\nconst PROFILE_PROVIDER_MARKER = '.mastra-provider';\n\n/**\n * Check which provider last used a profile directory.\n * Returns the provider name if the marker exists, undefined otherwise.\n */\nexport function getProfileProvider(profilePath: string): BrowserProvider | undefined {\n const markerPath = join(profilePath, PROFILE_PROVIDER_MARKER);\n if (!existsSync(markerPath)) {\n return undefined;\n }\n try {\n const content = readFileSync(markerPath, 'utf-8').trim();\n if (content === 'stagehand' || content === 'agent-browser') {\n return content;\n }\n return undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Write the provider marker to a profile directory.\n * Creates the directory if it doesn't exist.\n */\nexport function setProfileProvider(profilePath: string, provider: BrowserProvider): void {\n const markerPath = join(profilePath, PROFILE_PROVIDER_MARKER);\n if (!existsSync(profilePath)) {\n mkdirSync(profilePath, { recursive: true });\n }\n writeFileSync(markerPath, provider, 'utf-8');\n}\n\n/**\n * Check if a profile has a provider mismatch.\n * Returns the existing provider if there's a mismatch, undefined otherwise.\n */\nexport function checkProfileProviderMismatch(\n profilePath: string | undefined,\n targetProvider: BrowserProvider,\n): BrowserProvider | undefined {\n if (!profilePath) {\n return undefined;\n }\n const existingProvider = getProfileProvider(profilePath);\n if (existingProvider && existingProvider !== targetProvider) {\n return existingProvider;\n }\n return undefined;\n}\n\nfunction browserRecordingOptions() {\n return { outputDir: join(getAppDataDir(), 'browser-recordings') };\n}\n\n/**\n * Create a browser instance from settings.\n * Shared by startup (main.ts) and live reconfiguration (/browser command).\n * Returns undefined if browser is disabled.\n */\nexport async function createBrowserFromSettings(settings: BrowserSettings): Promise<MastraBrowser | undefined> {\n if (!settings.enabled) {\n return undefined;\n }\n\n const { provider, headless, viewport, cdpUrl, profile, executablePath, stagehand, agentBrowser } = settings;\n\n // Chrome only allows one process per profile directory, so force 'shared' scope\n // when a profile is set. Otherwise use the user's setting (or provider default).\n const scope = profile ? ('shared' as const) : settings.scope;\n\n // Common launch options (no CDP)\n const launchConfig = { headless, viewport, profile, executablePath, scope } as const;\n\n if (provider === 'stagehand') {\n const { StagehandBrowser } = await import('@mastra/stagehand');\n const stagehandOpts: Record<string, unknown> = {\n env: stagehand?.env ?? 'LOCAL',\n apiKey: stagehand?.apiKey ?? process.env.BROWSERBASE_API_KEY,\n projectId: stagehand?.projectId ?? process.env.BROWSERBASE_PROJECT_ID,\n preserveUserDataDir: stagehand?.preserveUserDataDir,\n recording: browserRecordingOptions(),\n };\n\n // When the user has an active OpenAI Codex (ChatGPT) subscription, route\n // Stagehand through the Codex endpoint. We use the AI SDK provider's\n // standard hooks (baseURL, headers, fetch, and middleware) instead of a\n // URL-rewriting fetch:\n // - baseURL: target Codex's Responses API directly (no URL rewriting).\n // - headers: static Codex identifiers (originator, UA, account id).\n // - fetch: a tiny refresher that injects the live OAuth bearer per call,\n // since AI SDK takes `apiKey` as a static string.\n // - middleware: createCodexMiddleware() sets `store: false`, which Codex\n // requires on every request.\n // Model is `gpt-5.4-mini`, the current ChatGPT-sign-in Codex whitelist\n // pick suited to Stagehand's vision + structured-output workload.\n //\n // An explicitly configured model wins: Codex is a fallback for users who\n // have no model of their own, not an override of one they chose. Stagehand\n // resolves the provider's API key from the environment for plain\n // `provider/model` strings, so no key plumbing is needed here.\n const authStorage = new AuthStorage();\n const cred = authStorage.get('openai-codex');\n if (stagehand?.model) {\n stagehandOpts.model = stagehand.model;\n } else if (cred?.type === 'oauth') {\n const accountId = (cred as any).accountId as string | undefined;\n stagehandOpts.model = {\n modelName: 'openai/gpt-5.4-mini',\n apiKey: 'codex-oauth',\n baseURL: 'https://chatgpt.com/backend-api/codex',\n headers: {\n originator: 'mastracode',\n 'User-Agent': 'mastracode',\n ...(accountId ? { 'ChatGPT-Account-ID': accountId } : {}),\n },\n fetch: buildCodexStagehandFetch(authStorage),\n middleware: createCodexMiddleware(),\n } as any;\n }\n\n return cdpUrl\n ? new StagehandBrowser({ ...launchConfig, cdpUrl, scope: 'shared', ...stagehandOpts })\n : new StagehandBrowser({ ...launchConfig, ...stagehandOpts });\n } else if (provider === 'agent-browser') {\n const { AgentBrowser } = await import('@mastra/agent-browser');\n const agentBrowserOpts = {\n storageState: agentBrowser?.storageState,\n recording: browserRecordingOptions(),\n };\n return cdpUrl\n ? new AgentBrowser({ ...launchConfig, cdpUrl, scope: 'shared', ...agentBrowserOpts })\n : new AgentBrowser({ ...launchConfig, ...agentBrowserOpts, scope });\n }\n\n throw new Error(`Unsupported browser provider: ${provider}`);\n}\n"],"mappings":";;;;;;;;;;;;;;AAuEA,MAAa,0BAA0B;;AAGvC,MAAa,6BAA6B;;AAG1C,MAAa,0BAA0B;;AAGvC,MAAa,6BAA6B;;AA2C1C,MAAa,mB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MAAM,YAAa,KAAa;GAChC,cAAc,QAAQ;IACpB,WAAW;IACX,QAAQ;IACR,SAAS;IACT,SAAS;KACP,YAAY;KACZ,cAAc;KACd,GAAI,YAAY,EAAE,sBAAsB,UAAU,IAAI,CAAC;IACzD;IACA,OAAO,yBAAyB,WAAW;IAC3C,YAAY,sBAAsB;GACpC;EACF;EAEA,OAAO,SACH,IAAI,iBAAiB;GAAE,GAAG;GAAc;GAAQ,OAAO;GAAU,GAAG;EAAc,CAAC,IACnF,IAAI,iBAAiB;GAAE,GAAG;GAAc,GAAG;EAAc,CAAC;CAChE,OAAO,IAAI,aAAa,iBAAiB;EACvC,MAAM,EAAE,iBAAiB,MAAM,OAAO;EACtC,MAAM,mBAAmB;GACvB,cAAc,cAAc;GAC5B,WAAW,wBAAwB;EACrC;EACA,OAAO,SACH,IAAI,aAAa;GAAE,GAAG;GAAc;GAAQ,OAAO;GAAU,GAAG;EAAiB,CAAC,IAClF,IAAI,aAAa;GAAE,GAAG;GAAc,GAAG;GAAkB;EAAM,CAAC;CACtE;CAEA,MAAM,IAAI,MAAM,iCAAiC,UAAU;AAC7D"}
|
|
1
|
+
{"version":3,"file":"settings.js","names":["resolveThinkingDefault"],"sources":["../../src/onboarding/settings.ts"],"sourcesContent":["/**\n * Persistent global settings stored in the app data directory as settings.json.\n * This file persists onboarding state AND user preferences (model choices, yolo, etc.)\n * so they carry across threads and restarts.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport type { MastraBrowser } from '@mastra/core/browser';\nimport type { LSPConfig } from '@mastra/core/workspace';\nimport { AuthStorage } from '../auth/storage.js';\nimport { buildCodexStagehandFetch, createCodexMiddleware } from '../providers/openai-codex.js';\nimport {\n isThinkingLevelSetting,\n resolveDefaultThinkingLevel as resolveThinkingDefault,\n THINKING_LEVEL_VALUES,\n} from '../thinking.js';\nimport type { ThinkingLevelSetting, ThinkingLevelSource } from '../thinking.js';\nexport { isThinkingLevelSetting, THINKING_LEVEL_VALUES } from '../thinking.js';\nexport type { ThinkingLevelSetting, ThinkingLevelSource } from '../thinking.js';\nimport { getAppDataDir } from '../utils/project.js';\nimport { DEFAULT_STT_PROVIDER, resolveSTTModel } from '../voice/stt-registry.js';\n\n/** A saved custom pack — user-defined model selections for each mode. */\nexport interface CustomPack {\n name: string;\n models: Record<string, string>;\n createdAt: string;\n}\n\n/** A saved custom provider for OpenAI-compatible endpoints. */\nexport interface CustomProviderSetting {\n name: string;\n url: string;\n apiKey?: string;\n models: string[];\n}\n\n/** Storage backend type. */\nexport type StorageBackend = 'libsql' | 'pg';\n\n/** LibSQL-specific storage settings. */\nexport interface LibSQLStorageSettings {\n url?: string;\n authToken?: string;\n}\n\n/** PostgreSQL-specific storage settings. */\nexport interface PgStorageSettings {\n connectionString?: string;\n host?: string;\n port?: number;\n database?: string;\n user?: string;\n password?: string;\n schemaName?: string;\n disableInit?: boolean;\n skipDefaultIndexes?: boolean;\n}\n\n/** Storage configuration persisted in global settings. */\nexport interface StorageSettings {\n /** Which backend to use. Default: 'libsql'. */\n backend: StorageBackend;\n /** LibSQL-specific config (used when backend is 'libsql'). */\n libsql: LibSQLStorageSettings;\n /** PostgreSQL-specific config (used when backend is 'pg'). */\n pg: PgStorageSettings;\n}\n\n/** Gateway provider key used in AuthStorage. */\nexport const MASTRA_GATEWAY_PROVIDER = 'mastra-gateway';\n\n/** Default gateway URL. */\nexport const MASTRA_GATEWAY_DEFAULT_URL = 'https://gateway-api.mastra.ai';\n\n/** @deprecated Renamed to {@link MASTRA_GATEWAY_PROVIDER}. */\nexport const MEMORY_GATEWAY_PROVIDER = MASTRA_GATEWAY_PROVIDER;\n\n/** @deprecated Renamed to {@link MASTRA_GATEWAY_DEFAULT_URL}. */\nexport const MEMORY_GATEWAY_DEFAULT_URL = MASTRA_GATEWAY_DEFAULT_URL;\n\n/** Preferred model-independent web search/extract provider. */\nexport type WebSearchProviderSetting = 'auto' | 'tavily' | 'parallel';\n\n/** Browser provider type. */\nexport type BrowserProvider = 'stagehand' | 'agent-browser';\n\n/** Direct TUI `!` shell passthrough mode. */\nexport type ShellPassthroughSettingsMode = 'default' | 'path' | 'login';\n\n/** Direct TUI `!` shell command language. */\nexport type ShellPassthroughSettingsFamily = 'posix' | 'cmd' | 'powershell';\n\n/** Direct TUI `!` shell passthrough configuration. */\nexport interface ShellPassthroughSettings {\n mode?: ShellPassthroughSettingsMode | string;\n executable?: string;\n family?: ShellPassthroughSettingsFamily | string;\n}\n\n/** STT engine: on-device macOS recognizer or a cloud provider. */\nexport type VoiceEngine = 'macos-native' | 'cloud';\n\n/** Voice (hold-space dictation) configuration persisted in global settings. */\nexport interface VoiceSettings {\n /** Whether hold-space voice input is enabled. */\n enabled: boolean;\n /** Which STT engine to use. Defaults to macOS native on darwin, else cloud. */\n engine: VoiceEngine;\n /** Cloud provider id (matches an STT registry entry). Cloud engine only. */\n provider: string;\n /** Cloud model id; defaults to the provider's first registry model. */\n model?: string;\n}\n\n/** Stagehand environment type. */\nexport type StagehandEnv = 'LOCAL' | 'BROWSERBASE';\n\n/**\n * Browser viewport: explicit dimensions, or `'window'` to follow the real\n * browser window instead of emulating a fixed size.\n */\nexport type BrowserViewport = { width: number; height: number } | 'window';\n\n/** Named viewport sizes offered by `/browser set viewport`. */\nexport const VIEWPORT_PRESETS = {\n desktop: { width: 1280, height: 720 },\n 'desktop-hd': { width: 1920, height: 1080 },\n laptop: { width: 1440, height: 900 },\n tablet: { width: 768, height: 1024 },\n mobile: { width: 390, height: 844 },\n} as const satisfies Record<string, { width: number; height: number }>;\n\nexport type ViewportPreset = keyof typeof VIEWPORT_PRESETS;\n\n/**\n * Largest viewport dimension accepted. Guards against typos that would launch a\n * browser far larger than any display.\n */\nconst MAX_VIEWPORT_DIMENSION = 10000;\n\nfunction isValidDimension(value: unknown): value is number {\n return typeof value === 'number' && Number.isInteger(value) && value > 0 && value <= MAX_VIEWPORT_DIMENSION;\n}\n\n/**\n * Parse a `WIDTHxHEIGHT` string (e.g. `1280x720`), a preset name, or `window`.\n * Returns undefined when the input is not a usable viewport.\n */\nexport function parseViewportInput(input: string): BrowserViewport | undefined {\n const value = input.trim().toLowerCase();\n if (!value) return undefined;\n if (value === 'window') return 'window';\n if (value in VIEWPORT_PRESETS) return { ...VIEWPORT_PRESETS[value as ViewportPreset] };\n\n const match = /^(\\d+)\\s*[x×]\\s*(\\d+)$/.exec(value);\n if (!match) return undefined;\n const width = Number(match[1]);\n const height = Number(match[2]);\n if (!isValidDimension(width) || !isValidDimension(height)) return undefined;\n return { width, height };\n}\n\n/** Stagehand-specific browser settings. */\nexport interface StagehandSettings {\n env: StagehandEnv;\n apiKey?: string;\n projectId?: string;\n /**\n * Model Stagehand uses for its AI operations, as `provider/model`\n * (for example `anthropic/claude-sonnet-4-5`). Stagehand resolves the\n * provider's API key from the environment (`ANTHROPIC_API_KEY`,\n * `OPENAI_API_KEY`, and so on). Defaults to Stagehand's own default.\n */\n model?: string;\n /** Whether to preserve the user data directory after the browser closes. */\n preserveUserDataDir?: boolean;\n}\n\n/** AgentBrowser-specific browser settings. */\nexport interface AgentBrowserSettings {\n /** Path to a Playwright storage state file (JSON) containing cookies and localStorage. */\n storageState?: string;\n}\n\n/** Browser configuration persisted in global settings. */\nexport interface BrowserSettings {\n /** Whether browser automation is enabled. */\n enabled: boolean;\n /** Which browser provider to use. */\n provider: BrowserProvider;\n /** Whether to run headless (no visible browser window). */\n headless: boolean;\n /**\n * Browser viewport dimensions, or `'window'` to disable viewport emulation so\n * the page follows the real browser window.\n */\n viewport?: BrowserViewport;\n /** CDP URL for connecting to an existing browser. */\n cdpUrl?: string;\n /** Path to a Chrome/Chromium user data directory (profile). */\n profile?: string;\n /** Path to the browser executable to use. */\n executablePath?: string;\n /** Browser scope — 'shared' (all threads share one browser) or 'thread' (each thread gets its own). */\n scope?: 'shared' | 'thread';\n /** Stagehand-specific settings. */\n stagehand?: StagehandSettings;\n /** AgentBrowser-specific settings. */\n agentBrowser?: AgentBrowserSettings;\n}\n\nexport interface GlobalSettings {\n // Onboarding tracking\n onboarding: {\n completedAt: string | null;\n skippedAt: string | null;\n version: number;\n modePackId: string | null;\n omPackId: string | null;\n quietModePreferenceSelected: boolean;\n };\n // Global model preferences (applied to new threads)\n models: {\n /**\n * Active model pack ID. Built-in packs use their id directly (\"anthropic\",\n * \"openai\"). Custom packs use \"custom:<name>\".\n * When set, models are resolved from the pack at startup so pack updates\n * (e.g. new model versions) apply automatically.\n * Cleared when the user manually overrides via /models (falls back to modeDefaults).\n */\n activeModelPackId: string | null;\n /** Explicit per-mode overrides — used when no activeModelPackId is set. */\n modeDefaults: Record<string, string>;\n /**\n * Per-mode reasoning-effort defaults (e.g. { build: \"high\", plan: \"xhigh\" }).\n * Resolved at request time; falls back to `preferences.thinkingLevel` for\n * modes without an entry. Overridden per-session via /think or the session\n * settings panel.\n */\n modeThinkingDefaults: Record<string, ThinkingLevelSetting>;\n /**\n * Active OM pack ID (e.g. \"gemini\", \"anthropic\", \"custom\").\n * When set, the OM model is resolved from the pack at startup so pack\n * updates (e.g. new model versions) apply automatically.\n * Cleared when the user manually overrides via /om (falls back to omModelOverride).\n */\n activeOmPackId: string | null;\n /**\n * Shared OM model override — used for both observer and reflector when a\n * role-specific override is not set. Kept for back-compat with older settings\n * files and set by onboarding when the user picks a custom OM pack.\n */\n omModelOverride: string | null;\n /**\n * Explicit Observer model override — takes precedence over `omModelOverride`\n * when set. Written by `/om` when the observer model is changed independently.\n */\n observerModelOverride: string | null;\n /**\n * Explicit Reflector model override — takes precedence over `omModelOverride`\n * when set. Written by `/om` when the reflector model is changed independently.\n */\n reflectorModelOverride: string | null;\n /** Default OM observation threshold used for new threads unless overridden per-thread. */\n omObservationThreshold: number | null;\n /** Default OM reflection threshold used for new threads unless overridden per-thread. */\n omReflectionThreshold: number | null;\n /**\n * Whether observations and reflections use the terse caveman-style instruction.\n * `null` means inherit the built-in default (currently `false` — caveman is\n * opt-in via `/om` settings). Used as the default for new threads unless\n * overridden per-thread.\n */\n omCavemanObservations: boolean | null;\n /**\n * Whether Observational Memory forwards image/file attachment parts to the\n * Observer LLM. `null` ⇒ inherit built-in default ('auto'). 'auto' checks\n * model capabilities; true/false forces the setting.\n */\n omObserveAttachments: 'auto' | boolean | null;\n /** Per-agent-type subagent model overrides (e.g. { explore: \"openai/gpt-5.1-codex-mini\" }) */\n subagentModels: Record<string, string>;\n /** Default judge model for /goal. */\n goalJudgeModel: string | null;\n /** Default max attempts for /goal. */\n goalMaxTurns: number | null;\n };\n // Global behavior preferences\n preferences: {\n yolo: boolean | null;\n theme: 'auto' | 'dark' | 'light';\n /** Default reasoning effort level used for all threads/models unless overridden in-session. */\n thinkingLevel: ThinkingLevelSetting;\n /** When true, components like subagent output collapse to compact summaries on completion. */\n quietMode: boolean;\n /** Maximum quiet-mode detail preview lines for compact tool calls. Set to 0 to hide previews. */\n quietModeMaxToolPreviewLines: number;\n /**\n * Default web search/extract provider. `auto` picks the first configured\n * provider key (Tavily, then Parallel). An explicit provider is only\n * honored while its API key is configured.\n */\n webSearchProvider: WebSearchProviderSetting;\n };\n // Storage backend configuration\n storage: StorageSettings;\n // User-created custom model packs\n customModelPacks: CustomPack[];\n // User-created custom providers with custom models\n customProviders: CustomProviderSetting[];\n // Model usage counts for ranking in the selector\n modelUseCounts: Record<string, number>;\n // Version the user dismissed the update prompt for (skip until they manually update past this)\n updateDismissedVersion: string | null;\n // Mastra gateway configuration\n memoryGateway: { baseUrl?: string };\n // LSP configuration forwarded to the workspace. Disabled unless the user\n // opts in with `true` or an LSPConfig object.\n lsp?: boolean | LSPConfig;\n // Browser automation configuration\n browser: BrowserSettings;\n // Direct TUI `!` shell passthrough configuration\n shellPassthrough: ShellPassthroughSettings;\n // Hold-space voice input configuration\n voice: VoiceSettings;\n // Signal routing configuration\n signals: SignalSettings;\n // Read-only discovery of MCP servers configured by other coding agents\n mcp: McpDiscoverySettings;\n // Cloud observability configuration (per-resource project IDs; tokens stored in auth.json)\n observability: ObservabilitySettings;\n}\n\nexport interface McpDiscoverySettings {\n /** Reuse top-level MCP servers from ~/.claude.json. */\n claudeCodeGlobal: boolean;\n /** Reuse MCP servers from $CODEX_HOME/config.toml or ~/.codex/config.toml. */\n codexGlobal: boolean;\n}\n\nexport interface SignalSettings {\n /** Opt into local Unix socket PubSub for cross-process signal routing. */\n unixSocketPubSub: boolean;\n /** Experimental: enable GitHub PR subscription signals backed by gitcrawl. */\n experimentalGithubSignals: boolean;\n}\n\nexport interface ObservabilityResourceConfig {\n /** Cloud project ID for this resource */\n projectId: string;\n /** When this config was created */\n configuredAt: string;\n}\n\nexport interface ObservabilitySettings {\n /** Per-resource cloud project configs, keyed by resourceId */\n resources: Record<string, ObservabilityResourceConfig>;\n /** Whether to store traces locally in DuckDB. Off by default to avoid disk usage. */\n localTracing: boolean;\n}\n\n/** Auth key prefix for observability tokens stored per-resource in auth.json */\nexport const OBSERVABILITY_AUTH_PREFIX = 'observability:';\n\nexport const STORAGE_DEFAULTS: StorageSettings = {\n backend: 'libsql',\n libsql: {},\n pg: {},\n};\n\n/** Default STT engine: on-device macOS recognizer where available, else cloud. */\nexport function defaultVoiceEngine(): VoiceEngine {\n return process.platform === 'darwin' ? 'macos-native' : 'cloud';\n}\n\nconst DEFAULTS: GlobalSettings = {\n onboarding: {\n completedAt: null,\n skippedAt: null,\n version: 0,\n modePackId: null,\n omPackId: null,\n quietModePreferenceSelected: true,\n },\n models: {\n activeModelPackId: null,\n modeDefaults: {},\n modeThinkingDefaults: {},\n activeOmPackId: null,\n omModelOverride: null,\n observerModelOverride: null,\n reflectorModelOverride: null,\n omObservationThreshold: null,\n omReflectionThreshold: null,\n omCavemanObservations: null,\n omObserveAttachments: null,\n subagentModels: {},\n goalJudgeModel: null,\n goalMaxTurns: null,\n },\n preferences: {\n yolo: null,\n theme: 'auto',\n thinkingLevel: 'off',\n quietMode: false,\n quietModeMaxToolPreviewLines: 2,\n webSearchProvider: 'auto',\n },\n storage: { ...STORAGE_DEFAULTS },\n customModelPacks: [],\n customProviders: [],\n modelUseCounts: {},\n updateDismissedVersion: null,\n memoryGateway: {},\n lsp: false,\n browser: {\n enabled: false,\n provider: 'stagehand',\n headless: false,\n viewport: { ...VIEWPORT_PRESETS.desktop },\n stagehand: { env: 'LOCAL' },\n },\n shellPassthrough: { mode: 'default' },\n voice: { enabled: false, engine: defaultVoiceEngine(), provider: DEFAULT_STT_PROVIDER },\n signals: { unixSocketPubSub: false, experimentalGithubSignals: false },\n mcp: { claudeCodeGlobal: false, codexGlobal: false },\n observability: { resources: {}, localTracing: false },\n};\n\nexport const WEB_SEARCH_PROVIDER_VALUES: WebSearchProviderSetting[] = ['auto', 'tavily', 'parallel'];\nconst QUIET_MODE_MAX_TOOL_PREVIEW_LINES_MAX = 8;\nconst loadedSignalSettings = new WeakMap<GlobalSettings, SignalSettings>();\n\nfunction cloneSignalSettings(signals: SignalSettings): SignalSettings {\n return { ...signals };\n}\n\nfunction rememberLoadedSettings(settings: GlobalSettings): GlobalSettings {\n loadedSignalSettings.set(settings, cloneSignalSettings(settings.signals));\n return settings;\n}\n\nfunction signalSettingsEqual(left: SignalSettings, right: SignalSettings): boolean {\n return (\n left.unixSocketPubSub === right.unixSocketPubSub &&\n left.experimentalGithubSignals === right.experimentalGithubSignals\n );\n}\n\nfunction parseWebSearchProvider(value: unknown): WebSearchProviderSetting {\n return typeof value === 'string' && WEB_SEARCH_PROVIDER_VALUES.includes(value as WebSearchProviderSetting)\n ? (value as WebSearchProviderSetting)\n : DEFAULTS.preferences.webSearchProvider;\n}\n\nfunction parseThinkingLevel(value: unknown): ThinkingLevelSetting {\n return isThinkingLevelSetting(value) ? value : DEFAULTS.preferences.thinkingLevel;\n}\n\nfunction parseModeThinkingDefaults(value: unknown): Record<string, ThinkingLevelSetting> {\n if (!value || typeof value !== 'object') return {};\n const result: Record<string, ThinkingLevelSetting> = {};\n for (const [mode, level] of Object.entries(value as Record<string, unknown>)) {\n if (isThinkingLevelSetting(level)) {\n result[mode] = level;\n }\n }\n return result;\n}\n\nfunction parseQuietModeMaxToolPreviewLines(value: unknown): number {\n const rawValue =\n typeof value === 'number' && Number.isFinite(value) ? value : DEFAULTS.preferences.quietModeMaxToolPreviewLines;\n return Math.min(QUIET_MODE_MAX_TOOL_PREVIEW_LINES_MAX, Math.max(0, Math.floor(rawValue)));\n}\n\nfunction parsePreferences(rawPreferences: unknown): GlobalSettings['preferences'] {\n const raw = rawPreferences && typeof rawPreferences === 'object' ? (rawPreferences as Record<string, unknown>) : {};\n\n return {\n ...DEFAULTS.preferences,\n ...raw,\n thinkingLevel: parseThinkingLevel(raw.thinkingLevel),\n quietModeMaxToolPreviewLines: parseQuietModeMaxToolPreviewLines(raw.quietModeMaxToolPreviewLines),\n webSearchProvider: parseWebSearchProvider(raw.webSearchProvider),\n };\n}\n\nfunction parseSignalSettings(rawSignals: unknown): SignalSettings {\n const raw = rawSignals && typeof rawSignals === 'object' ? (rawSignals as Record<string, unknown>) : {};\n return {\n unixSocketPubSub:\n typeof raw.unixSocketPubSub === 'boolean' ? raw.unixSocketPubSub : DEFAULTS.signals.unixSocketPubSub,\n experimentalGithubSignals:\n typeof raw.experimentalGithubSignals === 'boolean'\n ? raw.experimentalGithubSignals\n : DEFAULTS.signals.experimentalGithubSignals,\n };\n}\n\nfunction parseMcpDiscoverySettings(rawMcp: unknown): McpDiscoverySettings {\n const raw = rawMcp && typeof rawMcp === 'object' ? (rawMcp as Record<string, unknown>) : {};\n return {\n claudeCodeGlobal: typeof raw.claudeCodeGlobal === 'boolean' ? raw.claudeCodeGlobal : DEFAULTS.mcp.claudeCodeGlobal,\n codexGlobal: typeof raw.codexGlobal === 'boolean' ? raw.codexGlobal : DEFAULTS.mcp.codexGlobal,\n };\n}\n\nfunction hasQuietModePreferenceSelected(rawOnboarding: unknown): boolean {\n return Boolean(\n rawOnboarding &&\n typeof rawOnboarding === 'object' &&\n Object.prototype.hasOwnProperty.call(rawOnboarding, 'quietModePreferenceSelected'),\n );\n}\n\nfunction applyQuietModePreferenceRollout(settings: GlobalSettings, rawOnboarding: unknown): void {\n if (hasQuietModePreferenceSelected(rawOnboarding)) return;\n settings.onboarding.quietModePreferenceSelected = settings.preferences.quietMode === true;\n}\n\nfunction getNewInstallDefaults(): GlobalSettings {\n const settings = structuredClone(DEFAULTS);\n settings.preferences.quietMode = true;\n settings.onboarding.quietModePreferenceSelected = true;\n return settings;\n}\n\nexport function getSettingsPath(): string {\n return join(getAppDataDir(), 'settings.json');\n}\n\nexport function getCustomProviderId(name: string): string {\n const slug = name\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '');\n return slug || 'provider';\n}\n\nexport function toCustomProviderModelId(providerName: string, modelName: string): string {\n const providerId = getCustomProviderId(providerName);\n const trimmedModelName = modelName.trim();\n const providerPrefix = `${providerId}/`;\n if (trimmedModelName.startsWith(providerPrefix)) {\n return trimmedModelName;\n }\n return `${providerId}/${trimmedModelName}`;\n}\n\n/**\n * The shared gateway catalog namespaces provider keys under their owning\n * gateway id, so a custom provider's models surface in the `/models` catalog\n * as `mastracode/<providerId>/<model>` instead of the canonical\n * `<providerId>/<model>` that model resolution expects. Persisting the\n * gateway-qualified id verbatim breaks lookup later (the provider is parsed\n * as `mastracode`). Strip the prefix before saving — but only when the\n * middle segment matches one of the user's configured custom providers, so\n * legitimate `mastracode/...` gateway-routed ids are left untouched.\n */\nexport function stripMastraCodeCustomProviderPrefix(\n modelId: string,\n customProviders: Array<Pick<CustomProviderSetting, 'name'>>,\n): string {\n const gatewayPrefix = 'mastracode/';\n if (!modelId.startsWith(gatewayPrefix)) return modelId;\n\n const rest = modelId.slice(gatewayPrefix.length);\n const [providerId, ...modelParts] = rest.split('/');\n if (!providerId || modelParts.length === 0 || modelParts.some(part => part.length === 0)) return modelId;\n\n const isCustomProvider = customProviders.some(provider => getCustomProviderId(provider.name) === providerId);\n return isCustomProvider ? rest : modelId;\n}\n\nexport function parseCustomProviders(rawProviders: unknown): CustomProviderSetting[] {\n if (!Array.isArray(rawProviders)) return [];\n\n const parsedProviders: CustomProviderSetting[] = [];\n for (const rawProvider of rawProviders) {\n if (!rawProvider || typeof rawProvider !== 'object') continue;\n\n const candidate = rawProvider as Record<string, unknown>;\n const name = typeof candidate.name === 'string' ? candidate.name.trim() : '';\n const url = typeof candidate.url === 'string' ? candidate.url.trim() : '';\n if (!name || !url) continue;\n\n const providerId = getCustomProviderId(name);\n const models = Array.isArray(candidate.models)\n ? [\n ...new Set(\n candidate.models\n .filter((model): model is string => typeof model === 'string')\n .map(model => model.trim())\n .map(model => {\n const providerPrefix = `${providerId}/`;\n if (model.startsWith(providerPrefix)) {\n return model.slice(providerPrefix.length);\n }\n return model;\n }),\n ),\n ].filter(model => model.length > 0)\n : [];\n\n const apiKey =\n typeof candidate.apiKey === 'string' && candidate.apiKey.trim().length > 0 ? candidate.apiKey.trim() : undefined;\n\n parsedProviders.push({\n name,\n url,\n ...(apiKey ? { apiKey } : {}),\n models,\n });\n }\n\n return parsedProviders;\n}\n\nconst BROWSER_PROVIDERS = new Set<BrowserProvider>(['stagehand', 'agent-browser']);\nconst STAGEHAND_ENVS = new Set<StagehandEnv>(['LOCAL', 'BROWSERBASE']);\n\n/**\n * Normalize a Stagehand model id, which must be provider-qualified.\n *\n * Stagehand reads the segment before the first slash as the provider, so a\n * bare id like `gpt-4.1` is rejected as an unknown provider and a trailing\n * slash leaves an empty model name that only fails once a request is made.\n * Neither is usable, so both are dropped here rather than persisted.\n *\n * The provider name itself is checked where the command is issued, which can\n * name the supported providers in an error; this module is on the startup path\n * and only imports Stagehand lazily.\n *\n * @returns the trimmed model id, or undefined when it is unusable.\n */\nfunction parseStagehandModel(value: unknown): string | undefined {\n if (typeof value !== 'string') return undefined;\n const model = value.trim();\n const separator = model.indexOf('/');\n if (separator <= 0) return undefined;\n return model.slice(separator + 1).trim() ? model : undefined;\n}\n\n/**\n * Validate a viewport read from settings.json, falling back to the default when\n * it is missing or malformed.\n */\nfunction parseStoredViewport(raw: unknown): BrowserViewport {\n if (raw === 'window') return 'window';\n if (raw && typeof raw === 'object') {\n const { width, height } = raw as Record<string, unknown>;\n if (isValidDimension(width) && isValidDimension(height)) return { width, height };\n }\n return { ...VIEWPORT_PRESETS.desktop };\n}\n\n/**\n * Validate the `lsp` setting from JSON. Accepts both the boolean opt-in/opt-out\n * form and the full LSPConfig object; anything else is treated as unset.\n */\nfunction parseLspSettings(raw: unknown): boolean | LSPConfig | undefined {\n if (typeof raw === 'boolean') return raw;\n if (raw && typeof raw === 'object') return raw as LSPConfig;\n return undefined;\n}\n\n/**\n * Resolve the effective LSP config. LSP is opt-in: `false` and an absent\n * setting both mean disabled, `true` means enabled with defaults.\n */\nexport function resolveLspSetting(lsp: boolean | LSPConfig | undefined): LSPConfig | false {\n if (lsp === true) return {};\n if (!lsp) return false;\n return lsp;\n}\n\n/**\n * Deep-merge and validate browser settings from JSON.\n * Explicitly validates types to handle malformed settings.json gracefully.\n */\nfunction parseBrowserSettings(rawBrowser: unknown): BrowserSettings {\n const raw = rawBrowser && typeof rawBrowser === 'object' ? (rawBrowser as Record<string, unknown>) : {};\n const rawStagehand =\n raw.stagehand && typeof raw.stagehand === 'object' ? (raw.stagehand as Record<string, unknown>) : {};\n const stagehandModel = parseStagehandModel(rawStagehand.model);\n const rawAgentBrowser =\n raw.agentBrowser && typeof raw.agentBrowser === 'object' ? (raw.agentBrowser as Record<string, unknown>) : {};\n\n return {\n enabled: typeof raw.enabled === 'boolean' ? raw.enabled : DEFAULTS.browser.enabled,\n provider:\n typeof raw.provider === 'string' && BROWSER_PROVIDERS.has(raw.provider as BrowserProvider)\n ? (raw.provider as BrowserProvider)\n : DEFAULTS.browser.provider,\n headless: typeof raw.headless === 'boolean' ? raw.headless : DEFAULTS.browser.headless,\n cdpUrl: typeof raw.cdpUrl === 'string' && raw.cdpUrl.trim() ? raw.cdpUrl.trim() : undefined,\n profile: typeof raw.profile === 'string' && raw.profile.trim() ? raw.profile.trim() : undefined,\n executablePath:\n typeof raw.executablePath === 'string' && raw.executablePath.trim() ? raw.executablePath.trim() : undefined,\n viewport: parseStoredViewport(raw.viewport),\n scope: typeof raw.scope === 'string' && (raw.scope === 'shared' || raw.scope === 'thread') ? raw.scope : undefined,\n stagehand: {\n env:\n typeof rawStagehand.env === 'string' && STAGEHAND_ENVS.has(rawStagehand.env as StagehandEnv)\n ? (rawStagehand.env as StagehandEnv)\n : DEFAULTS.browser.stagehand!.env,\n ...(typeof rawStagehand.apiKey === 'string' && rawStagehand.apiKey.trim()\n ? { apiKey: rawStagehand.apiKey.trim() }\n : {}),\n ...(typeof rawStagehand.projectId === 'string' && rawStagehand.projectId.trim()\n ? { projectId: rawStagehand.projectId.trim() }\n : {}),\n ...(stagehandModel ? { model: stagehandModel } : {}),\n ...(typeof rawStagehand.preserveUserDataDir === 'boolean'\n ? { preserveUserDataDir: rawStagehand.preserveUserDataDir }\n : {}),\n },\n agentBrowser:\n typeof rawAgentBrowser.storageState === 'string' && rawAgentBrowser.storageState.trim()\n ? { storageState: rawAgentBrowser.storageState.trim() }\n : undefined,\n };\n}\n\nfunction parseShellPassthroughSettings(rawShellPassthrough: unknown): ShellPassthroughSettings {\n const raw =\n rawShellPassthrough && typeof rawShellPassthrough === 'object'\n ? (rawShellPassthrough as Record<string, unknown>)\n : {};\n const executable = typeof raw.executable === 'string' && raw.executable.trim() ? raw.executable.trim() : undefined;\n const family = typeof raw.family === 'string' && raw.family.trim() ? raw.family.trim() : undefined;\n const mode = typeof raw.mode === 'string' && raw.mode.trim() ? raw.mode.trim() : undefined;\n const defaultMode = executable ? undefined : DEFAULTS.shellPassthrough.mode;\n\n return {\n ...((mode ?? defaultMode) ? { mode: mode ?? defaultMode } : {}),\n ...(executable ? { executable } : {}),\n ...(family ? { family } : {}),\n };\n}\n\nfunction parseVoiceSettings(rawVoice: unknown): VoiceSettings {\n const raw = rawVoice && typeof rawVoice === 'object' ? (rawVoice as Record<string, unknown>) : {};\n const enabled = typeof raw.enabled === 'boolean' ? raw.enabled : DEFAULTS.voice.enabled;\n const engine: VoiceEngine =\n raw.engine === 'macos-native' || raw.engine === 'cloud' ? raw.engine : defaultVoiceEngine();\n // Validate provider/model against the registry, falling back to a usable entry\n // so old `{ enabled }`-only files and unknown values still resolve cleanly.\n const provider = typeof raw.provider === 'string' ? raw.provider : DEFAULTS.voice.provider;\n const model = typeof raw.model === 'string' ? raw.model : undefined;\n const resolved = resolveSTTModel(provider, model);\n return {\n enabled,\n engine,\n provider: resolved.provider,\n model: resolved.model,\n };\n}\n\nconst VALID_PROJECT_ID = /^[a-zA-Z0-9_-]+$/;\n\nfunction parseObservabilitySettings(raw: unknown): ObservabilitySettings {\n if (!raw || typeof raw !== 'object') return { resources: {}, localTracing: false };\n const obj = raw as Record<string, unknown>;\n const localTracing = obj.localTracing === true;\n const rawResources = obj.resources;\n if (!rawResources || typeof rawResources !== 'object') return { resources: {}, localTracing };\n const resources: Record<string, ObservabilityResourceConfig> = {};\n for (const [key, val] of Object.entries(rawResources as Record<string, unknown>)) {\n if (val && typeof val === 'object') {\n const v = val as Record<string, unknown>;\n if (typeof v.projectId === 'string' && VALID_PROJECT_ID.test(v.projectId)) {\n resources[key] = {\n projectId: v.projectId,\n configuredAt: typeof v.configuredAt === 'string' ? v.configuredAt : new Date().toISOString(),\n };\n }\n }\n }\n return { resources, localTracing };\n}\n\n/**\n * One-time migration: move model-related data from auth.json to settings.json.\n * Reads `_modelRanks`, `_modeModelId_*`, `_subagentModelId*` from auth.json,\n * merges them into settings, removes them from auth.json, and writes both files.\n * No-ops if auth.json has no _ prefixed model data.\n */\nfunction migrateFromAuth(settingsPath: string): boolean {\n const authPath = join(getAppDataDir(), 'auth.json');\n if (!existsSync(authPath)) return false;\n\n let authData: Record<string, any>;\n try {\n authData = JSON.parse(readFileSync(authPath, 'utf-8'));\n } catch {\n return false;\n }\n\n const modelKeys = Object.keys(authData).filter(k => k.startsWith('_'));\n if (modelKeys.length === 0) return false;\n\n // Load existing settings (or defaults) and merge auth data into it\n let settings: GlobalSettings;\n if (existsSync(settingsPath)) {\n try {\n const raw = JSON.parse(readFileSync(settingsPath, 'utf-8'));\n settings = {\n onboarding: { ...DEFAULTS.onboarding, ...raw.onboarding },\n models: { ...DEFAULTS.models, ...raw.models },\n preferences: parsePreferences(raw.preferences),\n storage: {\n ...STORAGE_DEFAULTS,\n ...raw.storage,\n libsql: { ...STORAGE_DEFAULTS.libsql, ...raw.storage?.libsql },\n pg: { ...STORAGE_DEFAULTS.pg, ...raw.storage?.pg },\n },\n customModelPacks: Array.isArray(raw.customModelPacks) ? raw.customModelPacks : [],\n customProviders: parseCustomProviders(raw.customProviders),\n modelUseCounts: raw.modelUseCounts && typeof raw.modelUseCounts === 'object' ? raw.modelUseCounts : {},\n updateDismissedVersion: typeof raw.updateDismissedVersion === 'string' ? raw.updateDismissedVersion : null,\n memoryGateway: raw.memoryGateway && typeof raw.memoryGateway === 'object' ? raw.memoryGateway : {},\n lsp: parseLspSettings(raw.lsp),\n browser: parseBrowserSettings(raw.browser),\n shellPassthrough: parseShellPassthroughSettings(raw.shellPassthrough),\n voice: parseVoiceSettings(raw.voice),\n signals: parseSignalSettings(raw.signals),\n mcp: parseMcpDiscoverySettings(raw.mcp),\n observability: parseObservabilitySettings(raw.observability),\n };\n applyQuietModePreferenceRollout(settings, raw.onboarding);\n } catch {\n settings = structuredClone(DEFAULTS);\n }\n } else {\n settings = structuredClone(DEFAULTS);\n }\n\n // Migrate model use counts (only if settings doesn't already have them)\n if (authData._modelRanks && typeof authData._modelRanks === 'object') {\n settings.modelUseCounts = { ...authData._modelRanks, ...settings.modelUseCounts };\n }\n\n // Migrate per-mode model defaults (don't overwrite existing settings)\n for (const key of modelKeys) {\n const modeMatch = key.match(/^_modeModelId_(.+)$/);\n if (modeMatch?.[1] && typeof authData[key] === 'string' && !settings.models.modeDefaults[modeMatch[1]]) {\n settings.models.modeDefaults[modeMatch[1]] = authData[key];\n }\n }\n\n // Migrate subagent models (don't overwrite existing settings)\n for (const key of modelKeys) {\n if (key === '_subagentModelId' && typeof authData[key] === 'string' && !settings.models.subagentModels['default']) {\n settings.models.subagentModels['default'] = authData[key];\n }\n const saMatch = key.match(/^_subagentModelId_(.+)$/);\n if (saMatch?.[1] && typeof authData[key] === 'string' && !settings.models.subagentModels[saMatch[1]]) {\n settings.models.subagentModels[saMatch[1]] = authData[key];\n }\n }\n\n // Write migrated settings\n saveSettings(settings, settingsPath);\n\n // Clean up auth.json — remove _ prefixed keys\n for (const key of modelKeys) {\n delete authData[key];\n }\n try {\n writeFileSync(authPath, JSON.stringify(authData, null, 2), 'utf-8');\n } catch {\n // Non-fatal — settings are saved, auth cleanup can fail\n }\n\n return true;\n}\n\nconst LEGACY_VARIED_MODELS: Record<string, string> = {\n plan: 'openai/gpt-5.4',\n build: 'anthropic/claude-sonnet-4-5',\n fast: 'anthropic/claude-haiku-4-5',\n};\n\nexport function migrateLegacyVariedPack(settings: GlobalSettings): boolean {\n const legacyPackId = 'varied';\n const customPackId = 'custom:varied';\n const hasLegacyReference =\n settings.models.activeModelPackId === legacyPackId || settings.onboarding.modePackId === legacyPackId;\n\n if (!hasLegacyReference) return false;\n\n const existingIdx = settings.customModelPacks.findIndex(p => p.name === 'varied');\n if (existingIdx >= 0) {\n const existing = settings.customModelPacks[existingIdx]!;\n const modelsMatch = Object.entries(LEGACY_VARIED_MODELS).every(([k, v]) => existing.models[k] === v);\n if (!modelsMatch) {\n existing.models = { ...LEGACY_VARIED_MODELS };\n }\n } else {\n settings.customModelPacks.push({\n name: 'varied',\n models: { ...LEGACY_VARIED_MODELS },\n createdAt: new Date().toISOString(),\n });\n }\n\n if (settings.models.activeModelPackId === legacyPackId) {\n settings.models.activeModelPackId = customPackId;\n if (Object.keys(settings.models.modeDefaults).length === 0) {\n settings.models.modeDefaults = { ...LEGACY_VARIED_MODELS };\n }\n }\n\n if (settings.onboarding.modePackId === legacyPackId) {\n settings.onboarding.modePackId = customPackId;\n }\n\n return true;\n}\n\nexport function loadSettings(filePath: string = getSettingsPath()): GlobalSettings {\n // One-time migration: move model data from auth.json into settings.json\n migrateFromAuth(filePath);\n\n if (!existsSync(filePath)) return rememberLoadedSettings(getNewInstallDefaults());\n try {\n const raw = JSON.parse(readFileSync(filePath, 'utf-8'));\n // Spread raw first to preserve unknown top-level keys (forward-compatibility),\n // then overlay with parsed/typed fields so known keys are always correct.\n const settings: GlobalSettings = {\n ...raw,\n onboarding: { ...DEFAULTS.onboarding, ...raw.onboarding },\n models: {\n ...DEFAULTS.models,\n ...raw.models,\n modeThinkingDefaults: parseModeThinkingDefaults(raw.models?.modeThinkingDefaults),\n },\n preferences: parsePreferences(raw.preferences),\n storage: {\n ...STORAGE_DEFAULTS,\n ...raw.storage,\n libsql: { ...STORAGE_DEFAULTS.libsql, ...raw.storage?.libsql },\n pg: { ...STORAGE_DEFAULTS.pg, ...raw.storage?.pg },\n },\n customModelPacks: Array.isArray(raw.customModelPacks) ? raw.customModelPacks : [],\n customProviders: parseCustomProviders(raw.customProviders),\n modelUseCounts: raw.modelUseCounts && typeof raw.modelUseCounts === 'object' ? raw.modelUseCounts : {},\n updateDismissedVersion: typeof raw.updateDismissedVersion === 'string' ? raw.updateDismissedVersion : null,\n memoryGateway: raw.memoryGateway && typeof raw.memoryGateway === 'object' ? raw.memoryGateway : {},\n lsp: parseLspSettings(raw.lsp),\n browser: parseBrowserSettings(raw.browser),\n shellPassthrough: parseShellPassthroughSettings(raw.shellPassthrough),\n voice: parseVoiceSettings(raw.voice),\n signals: parseSignalSettings(raw.signals),\n mcp: parseMcpDiscoverySettings(raw.mcp),\n observability: parseObservabilitySettings(raw.observability),\n };\n\n // Migrate legacy omModelId → omModelOverride\n let settingsChanged = false;\n if (!hasQuietModePreferenceSelected(raw.onboarding)) {\n applyQuietModePreferenceRollout(settings, raw.onboarding);\n settingsChanged = true;\n }\n if (raw.models?.omModelId && !settings.models.omModelOverride) {\n settings.models.omModelOverride = raw.models.omModelId;\n settingsChanged = true;\n }\n\n if (migrateLegacyVariedPack(settings)) {\n settingsChanged = true;\n }\n\n if (settingsChanged) {\n saveSettings(settings, filePath);\n }\n\n return rememberLoadedSettings(settings);\n } catch {\n return rememberLoadedSettings(structuredClone(DEFAULTS));\n }\n}\n\nexport const THREAD_ACTIVE_MODEL_PACK_ID_KEY = 'activeModelPackId';\n\nexport interface ThreadSettings {\n activeModelPackId: string | null;\n modeModelIds: Record<string, string>;\n}\n\nexport function parseThreadSettings(metadata: Record<string, unknown> | undefined): ThreadSettings {\n const modeModelIds: Record<string, string> = {};\n for (const [key, value] of Object.entries(metadata ?? {})) {\n const modeMatch = key.match(/^modeModelId_(.+)$/);\n if (modeMatch?.[1] && typeof value === 'string' && value.length > 0) {\n modeModelIds[modeMatch[1]] = value;\n }\n }\n\n const rawPackId = metadata?.[THREAD_ACTIVE_MODEL_PACK_ID_KEY];\n const activeModelPackId = typeof rawPackId === 'string' && rawPackId.length > 0 ? rawPackId : null;\n\n return {\n activeModelPackId,\n modeModelIds,\n };\n}\n\n/**\n * Resolve active model pack id for the current thread.\n *\n * Priority:\n * 1) explicit thread metadata activeModelPackId\n * 2) inferred from thread modeModelId_* values\n * 3) global settings.models.activeModelPackId\n */\nexport function resolveThreadActiveModelPackId(\n settings: GlobalSettings,\n builtinPacks: Array<{ id: string; models: Record<string, string> }>,\n metadata: Record<string, unknown> | undefined,\n): string | null {\n const threadSettings = parseThreadSettings(metadata);\n\n const isKnownPack = (packId: string): boolean => {\n if (packId.startsWith('custom:')) {\n const name = packId.slice('custom:'.length);\n return settings.customModelPacks.some(p => p.name === name);\n }\n return builtinPacks.some(p => p.id === packId);\n };\n\n if (threadSettings.activeModelPackId && isKnownPack(threadSettings.activeModelPackId)) {\n return threadSettings.activeModelPackId;\n }\n\n const allPacks: Array<{ id: string; models: Record<string, string> }> = [\n ...builtinPacks,\n ...settings.customModelPacks.map(p => ({ id: `custom:${p.name}`, models: p.models })),\n ];\n\n for (const pack of allPacks) {\n const packEntries = Object.entries(pack.models);\n const threadEntries = Object.keys(threadSettings.modeModelIds);\n const matches =\n packEntries.length === threadEntries.length &&\n packEntries.every(([modeId, modelId]) => threadSettings.modeModelIds[modeId] === modelId);\n if (matches) return pack.id;\n }\n\n if (settings.models.activeModelPackId && isKnownPack(settings.models.activeModelPackId)) {\n return settings.models.activeModelPackId;\n }\n\n return null;\n}\n\n/**\n * Resolve effective per-mode model defaults.\n *\n * If `activeModelPackId` is set, looks up the pack (built-in or custom) and\n * returns its models. Falls back to the explicit `modeDefaults` map.\n *\n * @param settings The loaded global settings.\n * @param builtinPacks Built-in packs for the current provider access\n * (from `getAvailableModePacks`). Pass `[]` if unavailable.\n */\nexport function resolveModelDefaults(\n settings: GlobalSettings,\n builtinPacks: Array<{ id: string; models: Record<string, string> }>,\n): Record<string, string> {\n const { activeModelPackId, modeDefaults } = settings.models;\n if (!activeModelPackId) return modeDefaults;\n\n // Custom pack: \"custom:<name>\"\n if (activeModelPackId.startsWith('custom:')) {\n const name = activeModelPackId.slice('custom:'.length);\n const pack = settings.customModelPacks.find(p => p.name === name);\n if (pack) return pack.models;\n // Custom pack was deleted — fall through to modeDefaults\n return modeDefaults;\n }\n\n // Built-in pack\n const builtin = builtinPacks.find(p => p.id === activeModelPackId);\n if (builtin) return builtin.models;\n\n // Unknown pack id — fall through\n return modeDefaults;\n}\n\n/**\n * Resolve the default reasoning-effort level for a mode.\n *\n * Lookup order:\n * 1. `models.modeThinkingDefaults[mode]` when set for the mode.\n * 2. The global `preferences.thinkingLevel`.\n *\n * Session-level overrides (via /think or the session settings panel) take\n * precedence over both and are handled by the caller.\n */\nexport function resolveDefaultThinkingLevel(\n settings: GlobalSettings,\n mode?: string | null,\n): { level: ThinkingLevelSetting; source: ThinkingLevelSource } {\n return resolveThinkingDefault(\n {\n globalDefault: settings.preferences.thinkingLevel,\n modeDefaults: settings.models.modeThinkingDefaults,\n },\n mode,\n );\n}\n\n/**\n * Resolve the effective model ID for one of the two OM roles.\n *\n * Lookup order:\n * 1. The role-specific override (`observerModelOverride` /\n * `reflectorModelOverride`) if set.\n * 2. If `activeOmPackId` points at a built-in pack, that pack's model.\n * 3. The shared `omModelOverride` fallback.\n *\n * @param settings The loaded global settings.\n * @param role Which OM role to resolve (`'observer'` or `'reflector'`).\n * @param builtinOmPacks Built-in OM packs for the current provider access\n * (from `getAvailableOmPacks`). Pass `[]` if unavailable.\n */\nexport function resolveOmRoleModel(\n settings: GlobalSettings,\n role: 'observer' | 'reflector',\n builtinOmPacks: Array<{ id: string; modelId: string }>,\n): string | null {\n const { activeOmPackId, omModelOverride, observerModelOverride, reflectorModelOverride } = settings.models;\n const roleOverride = role === 'observer' ? observerModelOverride : reflectorModelOverride;\n if (roleOverride) return roleOverride;\n\n if (!activeOmPackId) return omModelOverride;\n if (activeOmPackId === 'custom') return omModelOverride;\n\n const pack = builtinOmPacks.find(p => p.id === activeOmPackId);\n if (pack) return pack.modelId;\n\n return omModelOverride;\n}\n\n/**\n * @deprecated Use `resolveOmRoleModel(settings, 'observer' | 'reflector', ...)`.\n * Equivalent to resolving the observer role (existing callers set both observer\n * and reflector to the same value).\n */\nexport function resolveOmModel(\n settings: GlobalSettings,\n builtinOmPacks: Array<{ id: string; modelId: string }>,\n): string | null {\n return resolveOmRoleModel(settings, 'observer', builtinOmPacks);\n}\n\nfunction getSignalSettingsForSave(settings: GlobalSettings, filePath: string): SignalSettings {\n const loadedSignals = loadedSignalSettings.get(settings);\n if (!loadedSignals || !signalSettingsEqual(settings.signals, loadedSignals) || !existsSync(filePath)) {\n return settings.signals;\n }\n\n try {\n const currentRaw = JSON.parse(readFileSync(filePath, 'utf-8')) as Record<string, unknown>;\n const currentSignals = parseSignalSettings(currentRaw.signals);\n if (!signalSettingsEqual(currentSignals, loadedSignals)) {\n return currentSignals;\n }\n } catch {\n // If the current file is unreadable, fall back to the caller's settings.\n }\n\n return settings.signals;\n}\n\nexport function saveSettings(settings: GlobalSettings, filePath: string = getSettingsPath()): void {\n const dir = dirname(filePath);\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n const signals = getSignalSettingsForSave(settings, filePath);\n settings.signals = signals;\n loadedSignalSettings.set(settings, cloneSignalSettings(signals));\n writeFileSync(filePath, JSON.stringify(settings, null, 2), 'utf-8');\n}\n\n/** Marker file name to track which provider last used a profile. */\nconst PROFILE_PROVIDER_MARKER = '.mastra-provider';\n\n/**\n * Check which provider last used a profile directory.\n * Returns the provider name if the marker exists, undefined otherwise.\n */\nexport function getProfileProvider(profilePath: string): BrowserProvider | undefined {\n const markerPath = join(profilePath, PROFILE_PROVIDER_MARKER);\n if (!existsSync(markerPath)) {\n return undefined;\n }\n try {\n const content = readFileSync(markerPath, 'utf-8').trim();\n if (content === 'stagehand' || content === 'agent-browser') {\n return content;\n }\n return undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Write the provider marker to a profile directory.\n * Creates the directory if it doesn't exist.\n */\nexport function setProfileProvider(profilePath: string, provider: BrowserProvider): void {\n const markerPath = join(profilePath, PROFILE_PROVIDER_MARKER);\n if (!existsSync(profilePath)) {\n mkdirSync(profilePath, { recursive: true });\n }\n writeFileSync(markerPath, provider, 'utf-8');\n}\n\n/**\n * Check if a profile has a provider mismatch.\n * Returns the existing provider if there's a mismatch, undefined otherwise.\n */\nexport function checkProfileProviderMismatch(\n profilePath: string | undefined,\n targetProvider: BrowserProvider,\n): BrowserProvider | undefined {\n if (!profilePath) {\n return undefined;\n }\n const existingProvider = getProfileProvider(profilePath);\n if (existingProvider && existingProvider !== targetProvider) {\n return existingProvider;\n }\n return undefined;\n}\n\nfunction browserRecordingOptions() {\n return { outputDir: join(getAppDataDir(), 'browser-recordings') };\n}\n\n/**\n * Create a browser instance from settings.\n * Shared by startup (main.ts) and live reconfiguration (/browser command).\n * Returns undefined if browser is disabled.\n */\nexport async function createBrowserFromSettings(settings: BrowserSettings): Promise<MastraBrowser | undefined> {\n if (!settings.enabled) {\n return undefined;\n }\n\n const { provider, headless, viewport, cdpUrl, profile, executablePath, stagehand, agentBrowser } = settings;\n\n // Chrome only allows one process per profile directory, so force 'shared' scope\n // when a profile is set. Otherwise use the user's setting (or provider default).\n const scope = profile ? ('shared' as const) : settings.scope;\n\n // Common launch options (no CDP)\n const launchConfig = { headless, viewport, profile, executablePath, scope } as const;\n\n if (provider === 'stagehand') {\n const { StagehandBrowser } = await import('@mastra/stagehand');\n const stagehandOpts: Record<string, unknown> = {\n env: stagehand?.env ?? 'LOCAL',\n apiKey: stagehand?.apiKey ?? process.env.BROWSERBASE_API_KEY,\n projectId: stagehand?.projectId ?? process.env.BROWSERBASE_PROJECT_ID,\n preserveUserDataDir: stagehand?.preserveUserDataDir,\n recording: browserRecordingOptions(),\n };\n\n // When the user has an active OpenAI Codex (ChatGPT) subscription, route\n // Stagehand through the Codex endpoint. We use the AI SDK provider's\n // standard hooks (baseURL, headers, fetch, and middleware) instead of a\n // URL-rewriting fetch:\n // - baseURL: target Codex's Responses API directly (no URL rewriting).\n // - headers: static Codex identifiers (originator, UA, account id).\n // - fetch: a tiny refresher that injects the live OAuth bearer per call,\n // since AI SDK takes `apiKey` as a static string.\n // - middleware: createCodexMiddleware() sets `store: false`, which Codex\n // requires on every request.\n // Model is `gpt-5.4-mini`, the current ChatGPT-sign-in Codex whitelist\n // pick suited to Stagehand's vision + structured-output workload.\n //\n // An explicitly configured model wins: Codex is a fallback for users who\n // have no model of their own, not an override of one they chose. Stagehand\n // resolves the provider's API key from the environment for plain\n // `provider/model` strings, so no key plumbing is needed here.\n const authStorage = new AuthStorage();\n const cred = authStorage.get('openai-codex');\n if (stagehand?.model) {\n stagehandOpts.model = stagehand.model;\n } else if (cred?.type === 'oauth') {\n const accountId = (cred as any).accountId as string | undefined;\n stagehandOpts.model = {\n modelName: 'openai/gpt-5.4-mini',\n apiKey: 'codex-oauth',\n baseURL: 'https://chatgpt.com/backend-api/codex',\n headers: {\n originator: 'mastracode',\n 'User-Agent': 'mastracode',\n ...(accountId ? { 'ChatGPT-Account-ID': accountId } : {}),\n },\n fetch: buildCodexStagehandFetch(authStorage),\n middleware: createCodexMiddleware(),\n } as any;\n }\n\n return cdpUrl\n ? new StagehandBrowser({ ...launchConfig, cdpUrl, scope: 'shared', ...stagehandOpts })\n : new StagehandBrowser({ ...launchConfig, ...stagehandOpts });\n } else if (provider === 'agent-browser') {\n const { AgentBrowser } = await import('@mastra/agent-browser');\n const agentBrowserOpts = {\n storageState: agentBrowser?.storageState,\n recording: browserRecordingOptions(),\n };\n return cdpUrl\n ? new AgentBrowser({ ...launchConfig, cdpUrl, scope: 'shared', ...agentBrowserOpts })\n : new AgentBrowser({ ...launchConfig, ...agentBrowserOpts, scope });\n }\n\n throw new Error(`Unsupported browser provider: ${provider}`);\n}\n"],"mappings":";;;;;;;;;;;;;;AAuEA,MAAa,0BAA0B;;AAGvC,MAAa,6BAA6B;;AAG1C,MAAa,0BAA0B;;AAGvC,MAAa,6BAA6B;;AA8C1C,MAAa,mBAAmB;CAC9B,SAAS;EAAE,OAAO;EAAM,QAAQ;CAAI;CACpC,cAAc;EAAE,OAAO;EAAM,QAAQ;CAAK;CAC1C,QAAQ;EAAE,OAAO;EAAM,QAAQ;CAAI;CACnC,QAAQ;EAAE,OAAO;EAAK,QAAQ;CAAK;CACnC,QAAQ;EAAE,OAAO;EAAK,QAAQ;CAAI;AACpC;;;;;AAQA,MAAM,yBAAyB;AAE/B,SAAS,iBAAiB,OAAiC;CACzD,OAAO,OAAO,UAAU,YAAY,OAAO,UAAU,KAAK,KAAK,QAAQ,KAAK,SAAS;AACvF;;;;;AAMA,SAAgB,mBAAmB,OAA4C;CAC7E,MAAM,QAAQ,MAAM,KAAK,CAAC,CAAC,YAAY;CACvC,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,IAAI,UAAU,UAAU,OAAO;CAC/B,IAAI,SAAS,kBAAkB,OAAO,EAAE,GAAG,iBAAiB,OAAyB;CAErF,MAAM,QAAQ,yBAAyB,KAAK,KAAK;CACjD,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,MA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vB,cAAc,cAAc;GAC5B,WAAW,wBAAwB;EACrC;EACA,OAAO,SACH,IAAI,aAAa;GAAE,GAAG;GAAc;GAAQ,OAAO;GAAU,GAAG;EAAiB,CAAC,IAClF,IAAI,aAAa;GAAE,GAAG;GAAc,GAAG;GAAkB;EAAM,CAAC;CACtE;CAEA,MAAM,IAAI,MAAM,iCAAiC,UAAU;AAC7D"}
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tool exports for Mastra Code
|
|
3
3
|
*/
|
|
4
|
-
export {
|
|
4
|
+
export { createConfiguredWebTools, createParallelWebExtractTool, createParallelWebSearchTool, createWebExtractTool, createWebSearchTool, hasParallelKey, hasTavilyKey, resolveWebSearchProvider, } from './web-search.js';
|
|
5
5
|
export { requestSandboxAccessTool } from './request-sandbox-access.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC5B,2BAA2B,EAC3B,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC"}
|
package/dist/tools/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { createWebExtractTool, createWebSearchTool, hasTavilyKey } from "./web-search.js";
|
|
1
|
+
import { createConfiguredWebTools, createParallelWebExtractTool, createParallelWebSearchTool, createWebExtractTool, createWebSearchTool, hasParallelKey, hasTavilyKey, resolveWebSearchProvider } from "./web-search.js";
|
|
2
2
|
import { requestSandboxAccessTool } from "./request-sandbox-access.js";
|
|
3
|
-
export { createWebExtractTool, createWebSearchTool, hasTavilyKey, requestSandboxAccessTool };
|
|
3
|
+
export { createConfiguredWebTools, createParallelWebExtractTool, createParallelWebSearchTool, createWebExtractTool, createWebSearchTool, hasParallelKey, hasTavilyKey, requestSandboxAccessTool, resolveWebSearchProvider };
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { type WebSearchProviderSetting } from '../onboarding/settings.js';
|
|
1
2
|
/**
|
|
2
3
|
* Check whether a Tavily API key is available in the environment.
|
|
3
|
-
* Used
|
|
4
|
-
*
|
|
4
|
+
* Used to select model-independent web tools before falling back to
|
|
5
|
+
* model-native web search.
|
|
5
6
|
*/
|
|
6
7
|
export declare function hasTavilyKey(): boolean;
|
|
8
|
+
/** Check whether a Parallel API key is available in the environment. */
|
|
9
|
+
export declare function hasParallelKey(): boolean;
|
|
7
10
|
/**
|
|
8
11
|
* Wraps the @mastra/tavily search tool with mastracode-specific behavior:
|
|
9
12
|
* relevance filtering, markdown string formatting, and token truncation.
|
|
@@ -32,4 +35,80 @@ export declare function createWebExtractTool(): import("@mastra/core/tools").Too
|
|
|
32
35
|
includeImages?: boolean | undefined;
|
|
33
36
|
format?: "markdown" | "text" | undefined;
|
|
34
37
|
}, unknown, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "web-extract", unknown>;
|
|
38
|
+
/**
|
|
39
|
+
* Wraps the @mastra/parallel search tool with Mastra Code's standard tool id,
|
|
40
|
+
* markdown string output, and token truncation.
|
|
41
|
+
*/
|
|
42
|
+
export declare function createParallelWebSearchTool(): import("@mastra/core/tools").Tool<{
|
|
43
|
+
query: string;
|
|
44
|
+
}, unknown, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "web-search", unknown>;
|
|
45
|
+
/**
|
|
46
|
+
* Wraps the @mastra/parallel extract tool with Mastra Code's standard tool id,
|
|
47
|
+
* markdown string output, and token truncation.
|
|
48
|
+
*/
|
|
49
|
+
export declare function createParallelWebExtractTool(): import("@mastra/core/tools").Tool<{
|
|
50
|
+
urls: string[];
|
|
51
|
+
objective?: string | undefined;
|
|
52
|
+
searchQueries?: string[] | undefined;
|
|
53
|
+
excerptMaxCharsPerResult?: number | undefined;
|
|
54
|
+
clientModel?: string | undefined;
|
|
55
|
+
fullContent?: number | boolean | undefined;
|
|
56
|
+
maxCharsTotal?: number | undefined;
|
|
57
|
+
fetchPolicy?: {
|
|
58
|
+
maxAgeSeconds?: number | undefined;
|
|
59
|
+
timeoutSeconds?: number | undefined;
|
|
60
|
+
disableCacheFallback?: boolean | undefined;
|
|
61
|
+
} | undefined;
|
|
62
|
+
sessionId?: string | undefined;
|
|
63
|
+
}, unknown, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "web-extract", unknown>;
|
|
64
|
+
/**
|
|
65
|
+
* Resolve which model-independent web provider to use. An explicit user
|
|
66
|
+
* preference wins while its API key is configured; otherwise `auto` picks the
|
|
67
|
+
* first configured provider key (Tavily, then Parallel).
|
|
68
|
+
*/
|
|
69
|
+
export declare function resolveWebSearchProvider(preference?: WebSearchProviderSetting): 'tavily' | 'parallel' | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Create the configured model-independent web tools for the provider selected
|
|
72
|
+
* via the `webSearchProvider` preference (set in the TUI settings panel).
|
|
73
|
+
*/
|
|
74
|
+
export declare function createConfiguredWebTools(): {
|
|
75
|
+
web_search: import("@mastra/core/tools").Tool<{
|
|
76
|
+
query: string;
|
|
77
|
+
}, unknown, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "web-search", unknown>;
|
|
78
|
+
web_extract: import("@mastra/core/tools").Tool<{
|
|
79
|
+
urls: string[];
|
|
80
|
+
objective?: string | undefined;
|
|
81
|
+
searchQueries?: string[] | undefined;
|
|
82
|
+
excerptMaxCharsPerResult?: number | undefined;
|
|
83
|
+
clientModel?: string | undefined;
|
|
84
|
+
fullContent?: number | boolean | undefined;
|
|
85
|
+
maxCharsTotal?: number | undefined;
|
|
86
|
+
fetchPolicy?: {
|
|
87
|
+
maxAgeSeconds?: number | undefined;
|
|
88
|
+
timeoutSeconds?: number | undefined;
|
|
89
|
+
disableCacheFallback?: boolean | undefined;
|
|
90
|
+
} | undefined;
|
|
91
|
+
sessionId?: string | undefined;
|
|
92
|
+
}, unknown, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "web-extract", unknown>;
|
|
93
|
+
} | {
|
|
94
|
+
web_search: import("@mastra/core/tools").Tool<{
|
|
95
|
+
query: string;
|
|
96
|
+
searchDepth?: "basic" | "advanced" | "fast" | "ultra-fast" | undefined;
|
|
97
|
+
maxResults?: number | undefined;
|
|
98
|
+
includeAnswer?: boolean | "basic" | "advanced" | undefined;
|
|
99
|
+
includeImages?: boolean | undefined;
|
|
100
|
+
includeImageDescriptions?: boolean | undefined;
|
|
101
|
+
includeRawContent?: false | "markdown" | "text" | undefined;
|
|
102
|
+
includeDomains?: string[] | undefined;
|
|
103
|
+
excludeDomains?: string[] | undefined;
|
|
104
|
+
timeRange?: "day" | "week" | "month" | "year" | undefined;
|
|
105
|
+
}, unknown, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "web-search", unknown>;
|
|
106
|
+
web_extract: import("@mastra/core/tools").Tool<{
|
|
107
|
+
urls: string[];
|
|
108
|
+
extractDepth?: "basic" | "advanced" | undefined;
|
|
109
|
+
query?: string | undefined;
|
|
110
|
+
includeImages?: boolean | undefined;
|
|
111
|
+
format?: "markdown" | "text" | undefined;
|
|
112
|
+
}, unknown, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "web-extract", unknown>;
|
|
113
|
+
} | undefined;
|
|
35
114
|
//# sourceMappingURL=web-search.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-search.d.ts","sourceRoot":"","sources":["../../src/tools/web-search.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"web-search.d.ts","sourceRoot":"","sources":["../../src/tools/web-search.ts"],"names":[],"mappings":"AAKA,OAAO,EAAgB,KAAK,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAwBxF;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAEtC;AAED,wEAAwE;AACxE,wBAAgB,cAAc,IAAI,OAAO,CAExC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB;;;;;;;;;;;mIA8BlC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB;;;;;;oIAwBnC;AAED;;;GAGG;AACH,wBAAgB,2BAA2B;;mIAuB1C;AAED;;;GAGG;AACH,wBAAgB,4BAA4B;;;;;;;;;qBAtI1C,CAAC;sBAEK,CAAC;4BAEe,CAAC;;;oIA0JxB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,GAAE,wBAAiC,GAC5C,QAAQ,GAAG,UAAU,GAAG,SAAS,CAQnC;AAED;;;GAGG;AACH,wBAAgB,wBAAwB;;;;;;;;;;;;;yBArLtC,CAAC;0BAEK,CAAC;gCAEe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;cAmMxB"}
|
package/dist/tools/web-search.js
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
|
+
import { loadSettings } from "../onboarding/settings.js";
|
|
1
2
|
import { truncateStringForTokenEstimate } from "../utils/token-estimator.js";
|
|
2
|
-
import { createTool } from "@mastra/core/tools";
|
|
3
|
+
import { createTool, isValidationError } from "@mastra/core/tools";
|
|
4
|
+
import { createParallelExtractTool, createParallelSearchTool } from "@mastra/parallel";
|
|
3
5
|
import { createTavilyExtractTool, createTavilySearchTool } from "@mastra/tavily";
|
|
6
|
+
import { z } from "zod";
|
|
4
7
|
//#region src/tools/web-search.ts
|
|
5
8
|
const MAX_WEB_SEARCH_TOKENS = 2e3;
|
|
6
9
|
const MAX_WEB_EXTRACT_TOKENS = 2e3;
|
|
7
10
|
const MIN_RELEVANCE_SCORE = .25;
|
|
11
|
+
const parallelWebSearchInputSchema = z.object({ query: z.string().min(1).describe("The search query") });
|
|
12
|
+
function requireParallelOutput(output, operation) {
|
|
13
|
+
if (output === void 0) throw new Error(`Parallel ${operation} returned no output`);
|
|
14
|
+
if (isValidationError(output)) throw new Error(output.message);
|
|
15
|
+
return output;
|
|
16
|
+
}
|
|
8
17
|
/**
|
|
9
18
|
* Check whether a Tavily API key is available in the environment.
|
|
10
|
-
* Used
|
|
11
|
-
*
|
|
19
|
+
* Used to select model-independent web tools before falling back to
|
|
20
|
+
* model-native web search.
|
|
12
21
|
*/
|
|
13
22
|
function hasTavilyKey() {
|
|
14
23
|
return !!process.env.TAVILY_API_KEY;
|
|
15
24
|
}
|
|
25
|
+
/** Check whether a Parallel API key is available in the environment. */
|
|
26
|
+
function hasParallelKey() {
|
|
27
|
+
return !!process.env.PARALLEL_API_KEY;
|
|
28
|
+
}
|
|
16
29
|
/**
|
|
17
30
|
* Wraps the @mastra/tavily search tool with mastracode-specific behavior:
|
|
18
31
|
* relevance filtering, markdown string formatting, and token truncation.
|
|
@@ -55,7 +68,88 @@ function createWebExtractTool() {
|
|
|
55
68
|
}
|
|
56
69
|
});
|
|
57
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Wraps the @mastra/parallel search tool with Mastra Code's standard tool id,
|
|
73
|
+
* markdown string output, and token truncation.
|
|
74
|
+
*/
|
|
75
|
+
function createParallelWebSearchTool() {
|
|
76
|
+
const parallelSearchTool = createParallelSearchTool();
|
|
77
|
+
return createTool({
|
|
78
|
+
id: "web-search",
|
|
79
|
+
description: parallelSearchTool.description,
|
|
80
|
+
inputSchema: parallelWebSearchInputSchema,
|
|
81
|
+
execute: async (input, context) => {
|
|
82
|
+
const output = requireParallelOutput(await parallelSearchTool.execute({ searchQueries: [input.query] }, context), "search");
|
|
83
|
+
const parts = [];
|
|
84
|
+
for (const result of output.results) {
|
|
85
|
+
const title = result.title || result.url;
|
|
86
|
+
const excerpts = (result.excerpts || []).filter(Boolean).join("\n");
|
|
87
|
+
parts.push([
|
|
88
|
+
`## ${title}`,
|
|
89
|
+
result.url,
|
|
90
|
+
excerpts
|
|
91
|
+
].filter(Boolean).join("\n"));
|
|
92
|
+
}
|
|
93
|
+
return truncateStringForTokenEstimate(parts.join("\n\n"), MAX_WEB_SEARCH_TOKENS);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Wraps the @mastra/parallel extract tool with Mastra Code's standard tool id,
|
|
99
|
+
* markdown string output, and token truncation.
|
|
100
|
+
*/
|
|
101
|
+
function createParallelWebExtractTool() {
|
|
102
|
+
const parallelExtractTool = createParallelExtractTool();
|
|
103
|
+
return createTool({
|
|
104
|
+
id: "web-extract",
|
|
105
|
+
description: parallelExtractTool.description,
|
|
106
|
+
inputSchema: parallelExtractTool.inputSchema,
|
|
107
|
+
execute: async (input, context) => {
|
|
108
|
+
const output = requireParallelOutput(await parallelExtractTool.execute(input, context), "extract");
|
|
109
|
+
const parts = [];
|
|
110
|
+
for (const result of output.results) {
|
|
111
|
+
const content = result.fullContent || (result.excerpts || []).filter(Boolean).join("\n");
|
|
112
|
+
parts.push([`## ${result.url}`, content].filter(Boolean).join("\n"));
|
|
113
|
+
}
|
|
114
|
+
for (const error of output.errors) {
|
|
115
|
+
const status = error.httpStatusCode ? ` (${error.httpStatusCode})` : "";
|
|
116
|
+
parts.push([
|
|
117
|
+
`## ${error.url}`,
|
|
118
|
+
`Error: ${error.errorType}${status}`,
|
|
119
|
+
error.content
|
|
120
|
+
].filter(Boolean).join("\n"));
|
|
121
|
+
}
|
|
122
|
+
return truncateStringForTokenEstimate(parts.join("\n\n"), MAX_WEB_EXTRACT_TOKENS);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Resolve which model-independent web provider to use. An explicit user
|
|
128
|
+
* preference wins while its API key is configured; otherwise `auto` picks the
|
|
129
|
+
* first configured provider key (Tavily, then Parallel).
|
|
130
|
+
*/
|
|
131
|
+
function resolveWebSearchProvider(preference = "auto") {
|
|
132
|
+
if (preference === "tavily" && hasTavilyKey()) return "tavily";
|
|
133
|
+
if (preference === "parallel" && hasParallelKey()) return "parallel";
|
|
134
|
+
if (hasTavilyKey()) return "tavily";
|
|
135
|
+
if (hasParallelKey()) return "parallel";
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Create the configured model-independent web tools for the provider selected
|
|
139
|
+
* via the `webSearchProvider` preference (set in the TUI settings panel).
|
|
140
|
+
*/
|
|
141
|
+
function createConfiguredWebTools() {
|
|
142
|
+
const provider = resolveWebSearchProvider(loadSettings().preferences.webSearchProvider);
|
|
143
|
+
if (provider === "parallel") return {
|
|
144
|
+
web_search: createParallelWebSearchTool(),
|
|
145
|
+
web_extract: createParallelWebExtractTool()
|
|
146
|
+
};
|
|
147
|
+
if (provider === "tavily") return {
|
|
148
|
+
web_search: createWebSearchTool(),
|
|
149
|
+
web_extract: createWebExtractTool()
|
|
150
|
+
};
|
|
151
|
+
}
|
|
58
152
|
//#endregion
|
|
59
|
-
export { createWebExtractTool, createWebSearchTool, hasTavilyKey };
|
|
153
|
+
export { createConfiguredWebTools, createParallelWebExtractTool, createParallelWebSearchTool, createWebExtractTool, createWebSearchTool, hasParallelKey, hasTavilyKey, resolveWebSearchProvider };
|
|
60
154
|
|
|
61
155
|
//# sourceMappingURL=web-search.js.map
|
|
@@ -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 });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AM,EAAE,IAAI,WAAW,EAAE,OAAO;GAI7C,OAAO,+BADM,MAAM,KAAK,MACiB,GAAG,sBAAsB;EACpE;CACF,CAAC;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":";;;;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ace 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": {
|
|
@@ -57,19 +57,20 @@
|
|
|
57
57
|
"vscode-languageserver-protocol": "^3.17.5",
|
|
58
58
|
"yaml": "^2.7.1",
|
|
59
59
|
"zod": "^4.3.6",
|
|
60
|
-
"@mastra/core": "1.62.0-alpha.8",
|
|
61
60
|
"@mastra/agent-browser": "0.5.1",
|
|
61
|
+
"@mastra/core": "1.62.0-alpha.9",
|
|
62
62
|
"@mastra/duckdb": "1.6.3-alpha.0",
|
|
63
63
|
"@mastra/fastembed": "1.2.0",
|
|
64
|
-
"@mastra/github-signals": "0.2.5",
|
|
65
64
|
"@mastra/libsql": "1.22.0-alpha.2",
|
|
65
|
+
"@mastra/github-signals": "0.2.5",
|
|
66
66
|
"@mastra/mcp": "1.17.2-alpha.2",
|
|
67
67
|
"@mastra/observability": "1.17.2-alpha.1",
|
|
68
|
-
"@mastra/memory": "1.28.0-alpha.3",
|
|
69
68
|
"@mastra/pg": "1.22.0-alpha.4",
|
|
69
|
+
"@mastra/memory": "1.28.0-alpha.3",
|
|
70
70
|
"@mastra/schema-compat": "1.3.7",
|
|
71
71
|
"@mastra/stagehand": "0.3.3",
|
|
72
|
-
"@mastra/tavily": "1.1.1"
|
|
72
|
+
"@mastra/tavily": "1.1.1",
|
|
73
|
+
"@mastra/parallel": "0.1.0-alpha.0"
|
|
73
74
|
},
|
|
74
75
|
"devDependencies": {
|
|
75
76
|
"@libsql/client": "^0.17.4",
|