@mastra/code-sdk 1.18.0 → 1.19.0-alpha.1
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/dist/acp/agent.js +2 -2
- package/dist/acp/runtime.js +2 -2
- package/dist/agent-connections/state-processor.js +3 -3
- package/dist/agent-connections/tools.js +2 -2
- package/dist/agents/instructions.d.ts +5 -2
- package/dist/agents/instructions.d.ts.map +1 -1
- package/dist/agents/instructions.js +5 -3
- package/dist/agents/instructions.js.map +1 -1
- package/dist/agents/mastracode-gateway.d.ts +1 -0
- package/dist/agents/mastracode-gateway.d.ts.map +1 -1
- package/dist/agents/mastracode-gateway.js +12 -8
- package/dist/agents/mastracode-gateway.js.map +1 -1
- package/dist/agents/memory.js +2 -2
- package/dist/agents/model.js +5 -5
- package/dist/agents/prompts/index.d.ts +2 -0
- package/dist/agents/prompts/index.d.ts.map +1 -1
- package/dist/agents/prompts/index.js +8 -5
- package/dist/agents/prompts/index.js.map +1 -1
- package/dist/agents/prompts/plan.d.ts +1 -0
- package/dist/agents/prompts/plan.d.ts.map +1 -1
- package/dist/agents/prompts/plan.js +4 -1
- package/dist/agents/prompts/plan.js.map +1 -1
- package/dist/agents/prompts/tool-guidance.d.ts.map +1 -1
- package/dist/agents/prompts/tool-guidance.js +9 -1
- package/dist/agents/prompts/tool-guidance.js.map +1 -1
- package/dist/agents/tool-availability.d.ts +7 -2
- package/dist/agents/tool-availability.d.ts.map +1 -1
- package/dist/agents/tool-availability.js +15 -7
- package/dist/agents/tool-availability.js.map +1 -1
- package/dist/agents/tools.js +2 -2
- package/dist/agents/workflow-builder-agent.js +2 -2
- package/dist/agents/workspace.d.ts +3 -1
- package/dist/agents/workspace.d.ts.map +1 -1
- package/dist/agents/workspace.js +3 -3
- package/dist/agents/workspace.js.map +1 -1
- package/dist/auth/account-rotation-processor.js +4 -4
- package/dist/auth/index.js +3 -3
- package/dist/evals/index.js +1 -1
- package/dist/factory/client.d.ts +4 -1
- package/dist/factory/client.d.ts.map +1 -1
- package/dist/factory/client.js +22 -7
- package/dist/factory/client.js.map +1 -1
- package/dist/headless/cli.js +7 -7
- package/dist/headless/index.js +2 -2
- package/dist/headless/run-mc.js +2 -2
- package/dist/hooks/index.js +2 -2
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -33
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/onboarding/settings.js +2 -2
- package/dist/plugins/install.js +2 -2
- package/dist/plugins/manager.js +3 -3
- package/dist/providers/claude-max.js +5 -5
- package/dist/providers/claude-max.js.map +1 -1
- package/dist/providers/github-copilot.js +2 -2
- package/dist/providers/github-copilot.js.map +1 -1
- package/dist/providers/google-thinking.js +1 -1
- package/dist/providers/google-thinking.js.map +1 -1
- package/dist/providers/kimi-coding.js +1 -1
- package/dist/providers/openai-codex.js +5 -5
- package/dist/providers/openai-codex.js.map +1 -1
- package/dist/providers/provider-thinking.d.ts +1 -1
- package/dist/providers/provider-thinking.d.ts.map +1 -1
- package/dist/providers/provider-thinking.js +2 -2
- package/dist/providers/provider-thinking.js.map +1 -1
- package/dist/providers/xai.js +1 -1
- package/dist/schedules/tools.js +1 -1
- package/dist/tools/utils.js +1 -1
- package/dist/tools/workflows/list-available-tools.js +1 -1
- package/dist/utils/plans.d.ts +2 -0
- package/dist/utils/plans.d.ts.map +1 -1
- package/dist/utils/plans.js +6 -0
- package/dist/utils/plans.js.map +1 -1
- package/dist/utils/prune-cli.js +2 -2
- package/dist/voice/stt-registry.d.ts +6 -3
- package/dist/voice/stt-registry.d.ts.map +1 -1
- package/dist/voice/stt-registry.js +13 -10
- package/dist/voice/stt-registry.js.map +1 -1
- package/dist/voice/transcribe.d.ts +10 -0
- package/dist/voice/transcribe.d.ts.map +1 -0
- package/dist/voice/transcribe.js +77 -0
- package/dist/voice/transcribe.js.map +1 -0
- package/dist/workflows/register-primitives.js +2 -2
- package/package.json +19 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-thinking.js","names":[],"sources":["../../src/providers/provider-thinking.ts"],"sourcesContent":["import { getModelReasoningOptions, ModelRouterLanguageModel } from '@mastra/core/llm';\nimport { wrapLanguageModel } from 'ai';\nimport type { JSONValue } from 'ai';\nimport { requestableReasoningOptions, runThinkingLevel } from '../thinking.js';\nimport type { ThinkingLevelSetting } from '../thinking.js';\nimport { thinkingRequestFormatFor } from './thinking-request.js';\n\ntype ProviderOptions = Record<string, Record<string, JSONValue | undefined>>;\n\nexport interface ProviderThinkingOptions {\n optionsKey: string;\n options: Record<string, JSONValue>;\n controlKeys: ReadonlySet<string>;\n}\n\nexport function providerThinkingOptions(\n routedModelId: string,\n level: ThinkingLevelSetting | undefined,\n): ProviderThinkingOptions | undefined {\n const format = thinkingRequestFormatFor(routedModelId);\n if (!format || !level) return undefined;\n const catalogOptions = getModelReasoningOptions(routedModelId);\n const requestable = requestableReasoningOptions(routedModelId, catalogOptions);\n const runLevel = runThinkingLevel(routedModelId, level, catalogOptions);\n if (!requestable?.length || runLevel === 'off') return undefined;\n const effortOptions = format.sendEffort?.(runLevel);\n const sendsEffort = requestable.some(option => option.type === 'effort');\n const options = sendsEffort ? effortOptions : format.enableThinking;\n if (!options) return undefined;\n const controlKeys = new Set([...Object.keys(effortOptions ?? {}), ...Object.keys(format.enableThinking ?? {})]);\n return { optionsKey: format.optionsKey, options, controlKeys };\n}\n\nfunction withThinkingOptions<CallOptions extends { providerOptions?: ProviderOptions }>(\n callOptions: CallOptions,\n thinking: ProviderThinkingOptions | undefined,\n): CallOptions {\n if (!thinking) return callOptions;\n const callerOptions = callOptions.providerOptions?.[thinking.optionsKey] ?? {};\n const callerSetThinking = Object.keys(callerOptions).some(key => thinking.controlKeys.has(key));\n if (callerSetThinking) return callOptions;\n return {\n ...callOptions,\n providerOptions: {\n ...callOptions.providerOptions,\n [thinking.optionsKey]: { ...callerOptions, ...thinking.options },\n },\n };\n}\n\ntype AiSdkLanguageModel = Parameters<typeof wrapLanguageModel>[0]['model'];\n\nexport function withThinkingOptionsModel(\n model:
|
|
1
|
+
{"version":3,"file":"provider-thinking.js","names":[],"sources":["../../src/providers/provider-thinking.ts"],"sourcesContent":["import { getModelReasoningOptions, ModelRouterLanguageModel } from '@mastra/core/llm';\nimport { wrapLanguageModel } from 'ai';\nimport type { JSONValue } from 'ai';\nimport { requestableReasoningOptions, runThinkingLevel } from '../thinking.js';\nimport type { ThinkingLevelSetting } from '../thinking.js';\nimport { thinkingRequestFormatFor } from './thinking-request.js';\n\ntype ProviderOptions = Record<string, Record<string, JSONValue | undefined>>;\n\nexport interface ProviderThinkingOptions {\n optionsKey: string;\n options: Record<string, JSONValue>;\n controlKeys: ReadonlySet<string>;\n}\n\nexport function providerThinkingOptions(\n routedModelId: string,\n level: ThinkingLevelSetting | undefined,\n): ProviderThinkingOptions | undefined {\n const format = thinkingRequestFormatFor(routedModelId);\n if (!format || !level) return undefined;\n const catalogOptions = getModelReasoningOptions(routedModelId);\n const requestable = requestableReasoningOptions(routedModelId, catalogOptions);\n const runLevel = runThinkingLevel(routedModelId, level, catalogOptions);\n if (!requestable?.length || runLevel === 'off') return undefined;\n const effortOptions = format.sendEffort?.(runLevel);\n const sendsEffort = requestable.some(option => option.type === 'effort');\n const options = sendsEffort ? effortOptions : format.enableThinking;\n if (!options) return undefined;\n const controlKeys = new Set([...Object.keys(effortOptions ?? {}), ...Object.keys(format.enableThinking ?? {})]);\n return { optionsKey: format.optionsKey, options, controlKeys };\n}\n\nfunction withThinkingOptions<CallOptions extends { providerOptions?: ProviderOptions }>(\n callOptions: CallOptions,\n thinking: ProviderThinkingOptions | undefined,\n): CallOptions {\n if (!thinking) return callOptions;\n const callerOptions = callOptions.providerOptions?.[thinking.optionsKey] ?? {};\n const callerSetThinking = Object.keys(callerOptions).some(key => thinking.controlKeys.has(key));\n if (callerSetThinking) return callOptions;\n return {\n ...callOptions,\n providerOptions: {\n ...callOptions.providerOptions,\n [thinking.optionsKey]: { ...callerOptions, ...thinking.options },\n },\n };\n}\n\ntype AiSdkLanguageModel = Parameters<typeof wrapLanguageModel>[0]['model'];\n\nexport function withThinkingOptionsModel<Model extends AiSdkLanguageModel>(\n model: Model,\n thinking: ProviderThinkingOptions | undefined,\n): Model | ReturnType<typeof wrapLanguageModel> {\n if (!thinking) return model;\n return wrapLanguageModel({\n model,\n middleware: {\n specificationVersion: 'v4',\n transformParams: async ({ params }) => withThinkingOptions(params, thinking),\n },\n });\n}\n\ntype RouterConfig = ConstructorParameters<typeof ModelRouterLanguageModel>[0];\ntype RouterCallOptions = Parameters<ModelRouterLanguageModel['doStream']>[0];\ntype RouterCallResult = ReturnType<ModelRouterLanguageModel['doStream']>;\n\nexport class ModelRouterLanguageModelWithThinking extends ModelRouterLanguageModel {\n readonly #thinking: ProviderThinkingOptions | undefined;\n\n constructor(config: RouterConfig, thinking: ProviderThinkingOptions | undefined) {\n super(config);\n this.#thinking = thinking;\n }\n\n override doGenerate(options: RouterCallOptions): RouterCallResult {\n return super.doGenerate(withThinkingOptions(options, this.#thinking));\n }\n\n override doStream(options: RouterCallOptions): RouterCallResult {\n return super.doStream(withThinkingOptions(options, this.#thinking));\n }\n}\n"],"mappings":";;;;;AAeA,SAAgB,wBACd,eACA,OACqC;CACrC,MAAM,SAAS,yBAAyB,aAAa;CACrD,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO,KAAA;CAC9B,MAAM,iBAAiB,yBAAyB,aAAa;CAC7D,MAAM,cAAc,4BAA4B,eAAe,cAAc;CAC7E,MAAM,WAAW,iBAAiB,eAAe,OAAO,cAAc;CACtE,IAAI,CAAC,aAAa,UAAU,aAAa,OAAO,OAAO,KAAA;CACvD,MAAM,gBAAgB,OAAO,aAAa,QAAQ;CAElD,MAAM,UADc,YAAY,MAAK,WAAU,OAAO,SAAS,QACrC,IAAI,gBAAgB,OAAO;CACrD,IAAI,CAAC,SAAS,OAAO,KAAA;CACrB,MAAM,8BAAc,IAAI,IAAI,CAAC,GAAG,OAAO,KAAK,iBAAiB,CAAC,CAAC,GAAG,GAAG,OAAO,KAAK,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC;CAC9G,OAAO;EAAE,YAAY,OAAO;EAAY;EAAS;CAAY;AAC/D;AAEA,SAAS,oBACP,aACA,UACa;CACb,IAAI,CAAC,UAAU,OAAO;CACtB,MAAM,gBAAgB,YAAY,kBAAkB,SAAS,eAAe,CAAC;CAE7E,IAD0B,OAAO,KAAK,aAAa,CAAC,CAAC,MAAK,QAAO,SAAS,YAAY,IAAI,GAAG,CACzE,GAAG,OAAO;CAC9B,OAAO;EACL,GAAG;EACH,iBAAiB;GACf,GAAG,YAAY;IACd,SAAS,aAAa;IAAE,GAAG;IAAe,GAAG,SAAS;GAAQ;EACjE;CACF;AACF;AAIA,SAAgB,yBACd,OACA,UAC8C;CAC9C,IAAI,CAAC,UAAU,OAAO;CACtB,OAAO,kBAAkB;EACvB;EACA,YAAY;GACV,sBAAsB;GACtB,iBAAiB,OAAO,EAAE,aAAa,oBAAoB,QAAQ,QAAQ;EAC7E;CACF,CAAC;AACH;AAMA,IAAa,uCAAb,cAA0D,yBAAyB;CACjF;CAEA,YAAY,QAAsB,UAA+C;EAC/E,MAAM,MAAM;EACZ,KAAK,YAAY;CACnB;CAEA,WAAoB,SAA8C;EAChE,OAAO,MAAM,WAAW,oBAAoB,SAAS,KAAK,SAAS,CAAC;CACtE;CAEA,SAAkB,SAA8C;EAC9D,OAAO,MAAM,SAAS,oBAAoB,SAAS,KAAK,SAAS,CAAC;CACpE;AACF"}
|
package/dist/providers/xai.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AuthStorage } from "../auth/storage.js";
|
|
2
1
|
import { ProviderAuthRequiredError, rejectUnauthorizedResponse } from "../auth/provider-auth-error.js";
|
|
2
|
+
import { AuthStorage } from "../auth/storage.js";
|
|
3
3
|
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
4
4
|
// src/providers/xai.ts
|
|
5
5
|
/**
|
package/dist/schedules/tools.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseInterval, validateInterval } from "./interval.js";
|
|
2
|
-
import { describeScheduleSource, shortScheduleId } from "./scheduler.js";
|
|
3
2
|
import { resolveScriptCommand } from "./run-script.js";
|
|
3
|
+
import { describeScheduleSource, shortScheduleId } from "./scheduler.js";
|
|
4
4
|
import * as path$1 from "path";
|
|
5
5
|
import { createTool } from "@mastra/core/tools";
|
|
6
6
|
import { z } from "zod";
|
package/dist/tools/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { WORKFLOW_BUILDER_NOISE_TOOL_IDS } from "./tool-ids.js";
|
|
2
1
|
import { extractJsonSchema } from "./extract-json-schema.js";
|
|
2
|
+
import { WORKFLOW_BUILDER_NOISE_TOOL_IDS } from "./tool-ids.js";
|
|
3
3
|
import { createTool } from "@mastra/core/tools";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
// src/tools/workflows/list-available-tools.ts
|
package/dist/utils/plans.d.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
export declare function getPlansDir(): string;
|
|
3
3
|
export interface LocalPlansOptions {
|
|
4
4
|
factoryProjectId?: string | null;
|
|
5
|
+
/** Host-configured workspace-relative plans directory; wins over the default. */
|
|
6
|
+
plansDir?: string;
|
|
5
7
|
}
|
|
6
8
|
/** Workspace-relative directory the agent writes plan files into. */
|
|
7
9
|
export declare function getLocalPlansRelativeDir(options?: LocalPlansOptions): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plans.d.ts","sourceRoot":"","sources":["../../src/utils/plans.ts"],"names":[],"mappings":"AAKA,yDAAyD;AACzD,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,MAAM,WAAW,iBAAiB;IAChC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"plans.d.ts","sourceRoot":"","sources":["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,wBAAsB,eAAe,CAAC,IAAI,EAAE;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAc9B"}
|
package/dist/utils/plans.js
CHANGED
|
@@ -9,6 +9,12 @@ function getPlansDir() {
|
|
|
9
9
|
}
|
|
10
10
|
/** Workspace-relative directory the agent writes plan files into. */
|
|
11
11
|
function getLocalPlansRelativeDir(options = {}) {
|
|
12
|
+
if (options.plansDir) {
|
|
13
|
+
const dir = path.normalize(options.plansDir);
|
|
14
|
+
let end = dir.length;
|
|
15
|
+
while (end > 0 && (dir[end - 1] === "/" || dir[end - 1] === "\\")) end--;
|
|
16
|
+
return dir.slice(0, end);
|
|
17
|
+
}
|
|
12
18
|
return options.factoryProjectId ? path.join(".artifacts", "plans") : path.join(DEFAULT_CONFIG_DIR, "plans");
|
|
13
19
|
}
|
|
14
20
|
/** Local (project-scoped) plans directory where the agent writes named plan files. */
|
package/dist/utils/plans.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plans.js","names":[],"sources":["../../src/utils/plans.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { DEFAULT_CONFIG_DIR } from '../constants.js';\nimport { getAppDataDir } from './project.js';\n\n/** Global plans directory for approved-plan archives. */\nexport function getPlansDir(): string {\n return process.env.MASTRA_PLANS_DIR ?? path.join(getAppDataDir(), 'plans');\n}\n\nexport interface LocalPlansOptions {\n factoryProjectId?: string | null;\n}\n\n/** Workspace-relative directory the agent writes plan files into. */\nexport function getLocalPlansRelativeDir(options: LocalPlansOptions = {}): string {\n return options.factoryProjectId ? path.join('.artifacts', 'plans') : path.join(DEFAULT_CONFIG_DIR, 'plans');\n}\n\n/** Local (project-scoped) plans directory where the agent writes named plan files. */\nexport function getLocalPlansDir(projectPath: string, options: LocalPlansOptions = {}): string {\n return path.join(projectPath, getLocalPlansRelativeDir(options));\n}\n\nfunction slugify(str: string): string {\n const slug = str\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-|-$/g, '');\n return slug || 'untitled';\n}\n\n/** Derive a plan filename from a title (e.g. `add-dark-mode.md`). */\nexport function getPlanFilename(title: string): string {\n return `${slugify(title)}.md`;\n}\n\n/**\n * Suggested workspace-relative path for a new plan file, shown in plan-mode prompts.\n * Without a title we fall back to a generic name the agent can rename later.\n */\nexport function getSuggestedPlanRelativePath(title?: string, options: LocalPlansOptions = {}): string {\n const filename = title ? getPlanFilename(title) : 'plan.md';\n return path.join(getLocalPlansRelativeDir(options), filename);\n}\n\n/**\n * Resolve a plan path submitted by the agent (absolute or project-relative) to an\n * absolute path. Returns `undefined` when no usable path was provided.\n */\nexport function resolvePlanPath(projectPath: string, submittedPath: string): string | undefined {\n if (!submittedPath) return undefined;\n return path.isAbsolute(submittedPath) ? submittedPath : path.resolve(projectPath, submittedPath);\n}\n\n/**\n * Whether `targetPath` (absolute or project-relative) is a valid plan file: a `.md`\n * file located directly inside the project's configured plan directory. Used by the\n * plan-mode write guard so the agent can write any named plan file there, but nothing\n * outside that directory.\n */\nexport function isPlanFilePath(projectPath: string, targetPath: string, options: LocalPlansOptions = {}): boolean {\n const abs = resolvePlanPath(projectPath, targetPath);\n if (!abs) return false;\n if (path.extname(abs).toLowerCase() !== '.md') return false;\n\n const plansDir = path.resolve(getLocalPlansDir(projectPath, options));\n const rel = path.relative(plansDir, abs);\n // Must be directly inside the plans dir (no nested subdirectories, no escaping it).\n if (rel === '' || rel.startsWith('..') || path.isAbsolute(rel)) return false;\n return !rel.includes(path.sep);\n}\n\nexport async function savePlanToDisk(opts: {\n title: string;\n plan: string;\n resourceId: string;\n plansDir?: string;\n}): Promise<void> {\n const { title, plan, resourceId } = opts;\n const plansDir = opts.plansDir ?? getPlansDir();\n const baseDir = path.resolve(plansDir);\n const dir = path.resolve(baseDir, resourceId);\n const rel = path.relative(baseDir, dir);\n if (rel.startsWith('..') || path.isAbsolute(rel)) {\n throw new Error(`Invalid resourceId: ${resourceId}`);\n }\n\n await fs.mkdir(dir, { recursive: true });\n\n const now = new Date();\n const timestamp = now.toISOString().replace(/:/g, '-');\n const slug = slugify(title);\n const filename = `${timestamp}-${slug}.md`;\n\n const content = `# ${title}\\n\\nApproved: ${now.toISOString()}\\n\\n${plan}\\n`;\n\n await fs.writeFile(path.join(dir, filename), content, 'utf-8');\n}\n\n/**\n * Read a plan markdown file by absolute path.\n *\n * The leading `# <title>` heading (if present) is parsed as the title and the remaining\n * content is returned as the plan body. Returns `undefined` when the file does not exist.\n */\nexport async function readPlanFile(absPath: string): Promise<{ title: string; plan: string } | undefined> {\n let raw: string;\n try {\n raw = await fs.readFile(absPath, 'utf-8');\n } catch {\n return undefined;\n }\n\n const lines = raw.split(/\\r?\\n/);\n const headingIndex = lines.findIndex(line => line.trim().length > 0);\n const heading = headingIndex >= 0 ? lines[headingIndex] : undefined;\n if (heading?.startsWith('# ')) {\n const title = heading.slice(2).trim();\n const plan = lines\n .slice(headingIndex + 1)\n .join('\\n')\n .replace(/^\\n+/, '')\n .trimEnd();\n return { title, plan };\n }\n\n return { title: '', plan: raw.trimEnd() };\n}\n\n/**\n * Approve the plan file at `planPath`: write a timestamped copy to the global plans\n * archive so approved plans are findable later. The local named plan file is left in\n * place so the user can review every plan made over time.\n *\n * Returns the local plan filename (e.g. `add-dark-mode.md`), or `undefined` when there\n * was no plan file to approve.\n */\nexport async function approvePlanFile(opts: {\n planPath: string;\n title: string;\n resourceId: string;\n plansDir?: string;\n}): Promise<string | undefined> {\n const { planPath, title, resourceId, plansDir } = opts;\n\n const current = await readPlanFile(planPath);\n if (!current) {\n return undefined;\n }\n\n const resolvedTitle = title || current.title || 'Implementation Plan';\n\n // Global archive (timestamped, never overwritten) so approved plans are findable later.\n await savePlanToDisk({ title: resolvedTitle, plan: current.plan, resourceId, plansDir });\n\n return path.basename(planPath);\n}\n"],"mappings":";;;;;;AAMA,SAAgB,cAAsB;CACpC,OAAO,QAAQ,IAAI,oBAAoB,KAAK,KAAK,cAAc,GAAG,OAAO;AAC3E;;
|
|
1
|
+
{"version":3,"file":"plans.js","names":[],"sources":["../../src/utils/plans.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { DEFAULT_CONFIG_DIR } from '../constants.js';\nimport { getAppDataDir } from './project.js';\n\n/** Global plans directory for approved-plan archives. */\nexport function getPlansDir(): string {\n return process.env.MASTRA_PLANS_DIR ?? path.join(getAppDataDir(), 'plans');\n}\n\nexport interface LocalPlansOptions {\n factoryProjectId?: string | null;\n /** Host-configured workspace-relative plans directory; wins over the default. */\n plansDir?: string;\n}\n\n/** Workspace-relative directory the agent writes plan files into. */\nexport function getLocalPlansRelativeDir(options: LocalPlansOptions = {}): string {\n if (options.plansDir) {\n const dir = path.normalize(options.plansDir);\n let end = dir.length;\n while (end > 0 && (dir[end - 1] === '/' || dir[end - 1] === '\\\\')) end--;\n return dir.slice(0, end);\n }\n return options.factoryProjectId ? path.join('.artifacts', 'plans') : path.join(DEFAULT_CONFIG_DIR, 'plans');\n}\n\n/** Local (project-scoped) plans directory where the agent writes named plan files. */\nexport function getLocalPlansDir(projectPath: string, options: LocalPlansOptions = {}): string {\n return path.join(projectPath, getLocalPlansRelativeDir(options));\n}\n\nfunction slugify(str: string): string {\n const slug = str\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-|-$/g, '');\n return slug || 'untitled';\n}\n\n/** Derive a plan filename from a title (e.g. `add-dark-mode.md`). */\nexport function getPlanFilename(title: string): string {\n return `${slugify(title)}.md`;\n}\n\n/**\n * Suggested workspace-relative path for a new plan file, shown in plan-mode prompts.\n * Without a title we fall back to a generic name the agent can rename later.\n */\nexport function getSuggestedPlanRelativePath(title?: string, options: LocalPlansOptions = {}): string {\n const filename = title ? getPlanFilename(title) : 'plan.md';\n return path.join(getLocalPlansRelativeDir(options), filename);\n}\n\n/**\n * Resolve a plan path submitted by the agent (absolute or project-relative) to an\n * absolute path. Returns `undefined` when no usable path was provided.\n */\nexport function resolvePlanPath(projectPath: string, submittedPath: string): string | undefined {\n if (!submittedPath) return undefined;\n return path.isAbsolute(submittedPath) ? submittedPath : path.resolve(projectPath, submittedPath);\n}\n\n/**\n * Whether `targetPath` (absolute or project-relative) is a valid plan file: a `.md`\n * file located directly inside the project's configured plan directory. Used by the\n * plan-mode write guard so the agent can write any named plan file there, but nothing\n * outside that directory.\n */\nexport function isPlanFilePath(projectPath: string, targetPath: string, options: LocalPlansOptions = {}): boolean {\n const abs = resolvePlanPath(projectPath, targetPath);\n if (!abs) return false;\n if (path.extname(abs).toLowerCase() !== '.md') return false;\n\n const plansDir = path.resolve(getLocalPlansDir(projectPath, options));\n const rel = path.relative(plansDir, abs);\n // Must be directly inside the plans dir (no nested subdirectories, no escaping it).\n if (rel === '' || rel.startsWith('..') || path.isAbsolute(rel)) return false;\n return !rel.includes(path.sep);\n}\n\nexport async function savePlanToDisk(opts: {\n title: string;\n plan: string;\n resourceId: string;\n plansDir?: string;\n}): Promise<void> {\n const { title, plan, resourceId } = opts;\n const plansDir = opts.plansDir ?? getPlansDir();\n const baseDir = path.resolve(plansDir);\n const dir = path.resolve(baseDir, resourceId);\n const rel = path.relative(baseDir, dir);\n if (rel.startsWith('..') || path.isAbsolute(rel)) {\n throw new Error(`Invalid resourceId: ${resourceId}`);\n }\n\n await fs.mkdir(dir, { recursive: true });\n\n const now = new Date();\n const timestamp = now.toISOString().replace(/:/g, '-');\n const slug = slugify(title);\n const filename = `${timestamp}-${slug}.md`;\n\n const content = `# ${title}\\n\\nApproved: ${now.toISOString()}\\n\\n${plan}\\n`;\n\n await fs.writeFile(path.join(dir, filename), content, 'utf-8');\n}\n\n/**\n * Read a plan markdown file by absolute path.\n *\n * The leading `# <title>` heading (if present) is parsed as the title and the remaining\n * content is returned as the plan body. Returns `undefined` when the file does not exist.\n */\nexport async function readPlanFile(absPath: string): Promise<{ title: string; plan: string } | undefined> {\n let raw: string;\n try {\n raw = await fs.readFile(absPath, 'utf-8');\n } catch {\n return undefined;\n }\n\n const lines = raw.split(/\\r?\\n/);\n const headingIndex = lines.findIndex(line => line.trim().length > 0);\n const heading = headingIndex >= 0 ? lines[headingIndex] : undefined;\n if (heading?.startsWith('# ')) {\n const title = heading.slice(2).trim();\n const plan = lines\n .slice(headingIndex + 1)\n .join('\\n')\n .replace(/^\\n+/, '')\n .trimEnd();\n return { title, plan };\n }\n\n return { title: '', plan: raw.trimEnd() };\n}\n\n/**\n * Approve the plan file at `planPath`: write a timestamped copy to the global plans\n * archive so approved plans are findable later. The local named plan file is left in\n * place so the user can review every plan made over time.\n *\n * Returns the local plan filename (e.g. `add-dark-mode.md`), or `undefined` when there\n * was no plan file to approve.\n */\nexport async function approvePlanFile(opts: {\n planPath: string;\n title: string;\n resourceId: string;\n plansDir?: string;\n}): Promise<string | undefined> {\n const { planPath, title, resourceId, plansDir } = opts;\n\n const current = await readPlanFile(planPath);\n if (!current) {\n return undefined;\n }\n\n const resolvedTitle = title || current.title || 'Implementation Plan';\n\n // Global archive (timestamped, never overwritten) so approved plans are findable later.\n await savePlanToDisk({ title: resolvedTitle, plan: current.plan, resourceId, plansDir });\n\n return path.basename(planPath);\n}\n"],"mappings":";;;;;;AAMA,SAAgB,cAAsB;CACpC,OAAO,QAAQ,IAAI,oBAAoB,KAAK,KAAK,cAAc,GAAG,OAAO;AAC3E;;AASA,SAAgB,yBAAyB,UAA6B,CAAC,GAAW;CAChF,IAAI,QAAQ,UAAU;EACpB,MAAM,MAAM,KAAK,UAAU,QAAQ,QAAQ;EAC3C,IAAI,MAAM,IAAI;EACd,OAAO,MAAM,MAAM,IAAI,MAAM,OAAO,OAAO,IAAI,MAAM,OAAO,OAAO;EACnE,OAAO,IAAI,MAAM,GAAG,GAAG;CACzB;CACA,OAAO,QAAQ,mBAAmB,KAAK,KAAK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Ae;EAAE,OAHD,SAAS,QAAQ,SAAS;EAGH,MAAM,QAAQ;EAAM;EAAY;CAAS,CAAC;CAEvF,OAAO,KAAK,SAAS,QAAQ;AAC/B"}
|
package/dist/utils/prune-cli.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DEFAULT_CONFIG_DIR } from "../constants.js";
|
|
2
|
-
import { detectProject, getStorageConfig } from "./project.js";
|
|
3
2
|
import { loadSettings } from "../onboarding/settings.js";
|
|
4
3
|
import { acquireMaintenanceLock } from "./maintenance-lock.js";
|
|
5
|
-
import {
|
|
4
|
+
import { detectProject, getStorageConfig } from "./project.js";
|
|
6
5
|
import { createStorage, createVectorStore } from "./storage-factory.js";
|
|
6
|
+
import { DEFAULT_RETENTION, createStorageMaintenance, resolveLocalDbFiles, runStorageMaintenance } from "./storage-maintenance.js";
|
|
7
7
|
import path from "path";
|
|
8
8
|
import { LibSQLVector } from "@mastra/libsql";
|
|
9
9
|
// src/utils/prune-cli.ts
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
* built on the OpenAI client — `openai` uses the default endpoint, every other
|
|
12
12
|
* OpenAI-compatible host supplies its `baseURL`. Deepgram is the exception: it
|
|
13
13
|
* is not OpenAI-compatible, so it resolves through `@mastra/voice-deepgram`
|
|
14
|
-
* (`DeepgramVoice`)
|
|
15
|
-
*
|
|
14
|
+
* (`DeepgramVoice`), and Mistral through `@mastra/voice-mistral`. Neither is
|
|
15
|
+
* in the models.dev STT snapshot, so both are added by hand.
|
|
16
16
|
*
|
|
17
17
|
* The accompanying snapshot test (`__tests__/stt-registry.test.ts`) re-derives
|
|
18
18
|
* the models.dev-backed entries from a checked-in snapshot so this list stays
|
|
@@ -25,8 +25,9 @@
|
|
|
25
25
|
* (its `/audio/transcriptions` endpoint follows the OpenAI shape).
|
|
26
26
|
* - `deepgram`: `DeepgramVoice` from `@mastra/voice-deepgram` (not
|
|
27
27
|
* OpenAI-compatible; uses the Deepgram SDK).
|
|
28
|
+
* - `mistral`: `MistralVoice` from `@mastra/voice-mistral`.
|
|
28
29
|
*/
|
|
29
|
-
export type STTResolver = 'openai' | 'openai-compatible' | 'deepgram';
|
|
30
|
+
export type STTResolver = 'openai' | 'openai-compatible' | 'deepgram' | 'mistral';
|
|
30
31
|
export interface STTModel {
|
|
31
32
|
/** models.dev provider id (also the AuthStorage key for the API key). */
|
|
32
33
|
provider: string;
|
|
@@ -38,6 +39,7 @@ export interface STTModel {
|
|
|
38
39
|
resolver: STTResolver;
|
|
39
40
|
/** Base URL for `openai-compatible` providers (from models.dev `api`). */
|
|
40
41
|
baseURL?: string;
|
|
42
|
+
realtimeModel?: string;
|
|
41
43
|
}
|
|
42
44
|
/**
|
|
43
45
|
* The curated STT catalog. Order matters: the first entry for a provider is its
|
|
@@ -55,6 +57,7 @@ export declare function sttProviders(): string[];
|
|
|
55
57
|
export declare function sttModelsForProvider(provider: string): STTModel[];
|
|
56
58
|
/** The default (first) model for a provider, or undefined if unknown. */
|
|
57
59
|
export declare function defaultModelForProvider(provider: string): STTModel | undefined;
|
|
60
|
+
export declare function findSTTModel(provider: string, model: string): STTModel | undefined;
|
|
58
61
|
/**
|
|
59
62
|
* Resolve a provider/model pair to a concrete registry entry.
|
|
60
63
|
* Falls back to the provider default (then the global default) so callers
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stt-registry.d.ts","sourceRoot":"","sources":["../../src/voice/stt-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH
|
|
1
|
+
{"version":3,"file":"stt-registry.d.ts","sourceRoot":"","sources":["../../src/voice/stt-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,mBAAmB,GAAG,UAAU,GAAG,SAAS,CAAC;AAElF,MAAM,WAAW,QAAQ;IACvB,yEAAyE;IACzE,QAAQ,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,QAAQ,EAAE,WAAW,CAAC;IACtB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,SAAS,QAAQ,EA4FhC,CAAC;AAEX,2DAA2D;AAC3D,eAAO,MAAM,iBAAiB,EAAE,QAAyB,CAAC;AAE1D,wDAAwD;AACxD,eAAO,MAAM,oBAAoB,QAA6B,CAAC;AAE/D,6CAA6C;AAC7C,wBAAgB,YAAY,IAAI,MAAM,EAAE,CAUvC;AAED,4DAA4D;AAC5D,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,CAEjE;AAED,yEAAyE;AACzE,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAE9E;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAElF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,CAG3E"}
|
|
@@ -43,6 +43,13 @@ const STT_MODELS = [
|
|
|
43
43
|
label: "Deepgram Nova-3",
|
|
44
44
|
resolver: "deepgram"
|
|
45
45
|
},
|
|
46
|
+
{
|
|
47
|
+
provider: "mistral",
|
|
48
|
+
model: "voxtral-mini-latest",
|
|
49
|
+
label: "Mistral Voxtral Mini",
|
|
50
|
+
resolver: "mistral",
|
|
51
|
+
realtimeModel: "voxtral-mini-transcribe-realtime-3"
|
|
52
|
+
},
|
|
46
53
|
{
|
|
47
54
|
provider: "alibaba",
|
|
48
55
|
model: "qwen3-asr-flash",
|
|
@@ -122,22 +129,18 @@ function sttModelsForProvider(provider) {
|
|
|
122
129
|
function defaultModelForProvider(provider) {
|
|
123
130
|
return STT_MODELS.find((m) => m.provider === provider);
|
|
124
131
|
}
|
|
132
|
+
function findSTTModel(provider, model) {
|
|
133
|
+
return STT_MODELS.find((m) => m.provider === provider && m.model === model);
|
|
134
|
+
}
|
|
125
135
|
/**
|
|
126
136
|
* Resolve a provider/model pair to a concrete registry entry.
|
|
127
137
|
* Falls back to the provider default (then the global default) so callers
|
|
128
138
|
* always get a usable entry even if settings name an unknown model.
|
|
129
139
|
*/
|
|
130
140
|
function resolveSTTModel(provider, model) {
|
|
131
|
-
if (provider)
|
|
132
|
-
|
|
133
|
-
const exact = STT_MODELS.find((m) => m.provider === provider && m.model === model);
|
|
134
|
-
if (exact) return exact;
|
|
135
|
-
}
|
|
136
|
-
const providerDefault = defaultModelForProvider(provider);
|
|
137
|
-
if (providerDefault) return providerDefault;
|
|
138
|
-
}
|
|
139
|
-
return DEFAULT_STT_MODEL;
|
|
141
|
+
if (!provider) return DEFAULT_STT_MODEL;
|
|
142
|
+
return (model ? findSTTModel(provider, model) : void 0) ?? defaultModelForProvider(provider) ?? DEFAULT_STT_MODEL;
|
|
140
143
|
}
|
|
141
|
-
export { DEFAULT_STT_MODEL, DEFAULT_STT_PROVIDER, STT_MODELS, defaultModelForProvider, resolveSTTModel, sttModelsForProvider, sttProviders };
|
|
144
|
+
export { DEFAULT_STT_MODEL, DEFAULT_STT_PROVIDER, STT_MODELS, defaultModelForProvider, findSTTModel, resolveSTTModel, sttModelsForProvider, sttProviders };
|
|
142
145
|
|
|
143
146
|
//# sourceMappingURL=stt-registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stt-registry.js","names":[],"sources":["../../src/voice/stt-registry.ts"],"sourcesContent":["/**\n * Speech-to-text (STT) model registry for push-to-talk voice input.\n *\n * This is the single source of truth shared by the `/voice` settings picker,\n * settings validation, and the cloud transcription resolver. Entries are\n * derived from models.dev (https://models.dev/api.json): a model is treated as\n * STT when its modalities are audio-in / text-out with no text input.\n *\n * Most cloud providers here speak the OpenAI `/audio/transcriptions` shape, so\n * the cloud engine resolves them through Mastra's `OpenAIVoice` (`MastraVoice`)\n * built on the OpenAI client — `openai` uses the default endpoint, every other\n * OpenAI-compatible host supplies its `baseURL`. Deepgram is the exception: it\n * is not OpenAI-compatible, so it resolves through `@mastra/voice-deepgram`\n * (`DeepgramVoice`)
|
|
1
|
+
{"version":3,"file":"stt-registry.js","names":[],"sources":["../../src/voice/stt-registry.ts"],"sourcesContent":["/**\n * Speech-to-text (STT) model registry for push-to-talk voice input.\n *\n * This is the single source of truth shared by the `/voice` settings picker,\n * settings validation, and the cloud transcription resolver. Entries are\n * derived from models.dev (https://models.dev/api.json): a model is treated as\n * STT when its modalities are audio-in / text-out with no text input.\n *\n * Most cloud providers here speak the OpenAI `/audio/transcriptions` shape, so\n * the cloud engine resolves them through Mastra's `OpenAIVoice` (`MastraVoice`)\n * built on the OpenAI client — `openai` uses the default endpoint, every other\n * OpenAI-compatible host supplies its `baseURL`. Deepgram is the exception: it\n * is not OpenAI-compatible, so it resolves through `@mastra/voice-deepgram`\n * (`DeepgramVoice`), and Mistral through `@mastra/voice-mistral`. Neither is\n * in the models.dev STT snapshot, so both are added by hand.\n *\n * The accompanying snapshot test (`__tests__/stt-registry.test.ts`) re-derives\n * the models.dev-backed entries from a checked-in snapshot so this list stays\n * honest and can be refreshed deliberately rather than drifting by hand.\n */\n\n/**\n * How a provider's transcription model is constructed.\n * - `openai`: `OpenAIVoice` with the default OpenAI endpoint.\n * - `openai-compatible`: `OpenAIVoice` pointed at the host's `baseURL`\n * (its `/audio/transcriptions` endpoint follows the OpenAI shape).\n * - `deepgram`: `DeepgramVoice` from `@mastra/voice-deepgram` (not\n * OpenAI-compatible; uses the Deepgram SDK).\n * - `mistral`: `MistralVoice` from `@mastra/voice-mistral`.\n */\nexport type STTResolver = 'openai' | 'openai-compatible' | 'deepgram' | 'mistral';\n\nexport interface STTModel {\n /** models.dev provider id (also the AuthStorage key for the API key). */\n provider: string;\n /** Bare model id passed to the provider's transcription factory. */\n model: string;\n /** Human-friendly label for the picker. */\n label: string;\n /** How to build the transcription model. */\n resolver: STTResolver;\n /** Base URL for `openai-compatible` providers (from models.dev `api`). */\n baseURL?: string;\n realtimeModel?: string;\n}\n\n/**\n * The curated STT catalog. Order matters: the first entry for a provider is its\n * default model, and the first overall entry (`openai`/`whisper-1`) is the\n * global default.\n */\nexport const STT_MODELS: readonly STTModel[] = [\n // OpenAI — default provider.\n { provider: 'openai', model: 'whisper-1', label: 'OpenAI Whisper', resolver: 'openai' },\n { provider: 'openai', model: 'gpt-4o-transcribe', label: 'OpenAI GPT-4o Transcribe', resolver: 'openai' },\n {\n provider: 'openai',\n model: 'gpt-4o-mini-transcribe',\n label: 'OpenAI GPT-4o mini Transcribe',\n resolver: 'openai',\n },\n // Groq — fast, cheap whisper hosting via its OpenAI-compatible endpoint.\n {\n provider: 'groq',\n model: 'whisper-large-v3-turbo',\n label: 'Groq Whisper Large v3 Turbo',\n resolver: 'openai-compatible',\n baseURL: 'https://api.groq.com/openai/v1',\n },\n {\n provider: 'groq',\n model: 'whisper-large-v3',\n label: 'Groq Whisper Large v3',\n resolver: 'openai-compatible',\n baseURL: 'https://api.groq.com/openai/v1',\n },\n // Deepgram — dedicated STT provider (not OpenAI-compatible); via @mastra/voice-deepgram.\n { provider: 'deepgram', model: 'nova-3', label: 'Deepgram Nova-3', resolver: 'deepgram' },\n {\n provider: 'mistral',\n model: 'voxtral-mini-latest',\n label: 'Mistral Voxtral Mini',\n resolver: 'mistral',\n realtimeModel: 'voxtral-mini-transcribe-realtime-3',\n },\n // Alibaba Qwen ASR (OpenAI-compatible endpoints).\n {\n provider: 'alibaba',\n model: 'qwen3-asr-flash',\n label: 'Alibaba Qwen3 ASR Flash',\n resolver: 'openai-compatible',\n baseURL: 'https://dashscope-intl.aliyuncs.com/compatible-mode/v1',\n },\n {\n provider: 'alibaba-cn',\n model: 'qwen3-asr-flash',\n label: 'Alibaba Qwen3 ASR Flash (China)',\n resolver: 'openai-compatible',\n baseURL: 'https://dashscope.aliyuncs.com/compatible-mode/v1',\n },\n // Whisper hosts (OpenAI-compatible endpoints).\n {\n provider: 'scaleway',\n model: 'whisper-large-v3',\n label: 'Scaleway Whisper Large v3',\n resolver: 'openai-compatible',\n baseURL: 'https://api.scaleway.ai/v1',\n },\n {\n provider: 'nvidia',\n model: 'openai/whisper-large-v3',\n label: 'Nvidia Whisper Large v3',\n resolver: 'openai-compatible',\n baseURL: 'https://integrate.api.nvidia.com/v1',\n },\n {\n provider: 'nearai',\n model: 'openai/whisper-large-v3',\n label: 'NEAR AI Whisper Large v3',\n resolver: 'openai-compatible',\n baseURL: 'https://cloud-api.near.ai/v1',\n },\n {\n provider: 'evroc',\n model: 'openai/whisper-large-v3-turbo',\n label: 'evroc Whisper Large v3 Turbo',\n resolver: 'openai-compatible',\n baseURL: 'https://models.think.evroc.com/v1',\n },\n {\n provider: 'evroc',\n model: 'openai/whisper-large-v3',\n label: 'evroc Whisper Large v3',\n resolver: 'openai-compatible',\n baseURL: 'https://models.think.evroc.com/v1',\n },\n {\n provider: 'evroc',\n model: 'KBLab/kb-whisper-large',\n label: 'evroc KB-Whisper Large',\n resolver: 'openai-compatible',\n baseURL: 'https://models.think.evroc.com/v1',\n },\n] as const;\n\n/** The global default STT model (first registry entry). */\nexport const DEFAULT_STT_MODEL: STTModel = STT_MODELS[0]!;\n\n/** The default STT provider when none is configured. */\nexport const DEFAULT_STT_PROVIDER = DEFAULT_STT_MODEL.provider;\n\n/** Unique provider ids in registry order. */\nexport function sttProviders(): string[] {\n const seen = new Set<string>();\n const out: string[] = [];\n for (const m of STT_MODELS) {\n if (!seen.has(m.provider)) {\n seen.add(m.provider);\n out.push(m.provider);\n }\n }\n return out;\n}\n\n/** All models offered for a provider, in registry order. */\nexport function sttModelsForProvider(provider: string): STTModel[] {\n return STT_MODELS.filter(m => m.provider === provider);\n}\n\n/** The default (first) model for a provider, or undefined if unknown. */\nexport function defaultModelForProvider(provider: string): STTModel | undefined {\n return STT_MODELS.find(m => m.provider === provider);\n}\n\nexport function findSTTModel(provider: string, model: string): STTModel | undefined {\n return STT_MODELS.find(m => m.provider === provider && m.model === model);\n}\n\n/**\n * Resolve a provider/model pair to a concrete registry entry.\n * Falls back to the provider default (then the global default) so callers\n * always get a usable entry even if settings name an unknown model.\n */\nexport function resolveSTTModel(provider?: string, model?: string): STTModel {\n if (!provider) return DEFAULT_STT_MODEL;\n return (model ? findSTTModel(provider, model) : undefined) ?? defaultModelForProvider(provider) ?? DEFAULT_STT_MODEL;\n}\n"],"mappings":";;;;;;AAmDA,MAAa,aAAkC;CAE7C;EAAE,UAAU;EAAU,OAAO;EAAa,OAAO;EAAkB,UAAU;CAAS;CACtF;EAAE,UAAU;EAAU,OAAO;EAAqB,OAAO;EAA4B,UAAU;CAAS;CACxG;EACE,UAAU;EACV,OAAO;EACP,OAAO;EACP,UAAU;CACZ;CAEA;EACE,UAAU;EACV,OAAO;EACP,OAAO;EACP,UAAU;EACV,SAAS;CACX;CACA;EACE,UAAU;EACV,OAAO;EACP,OAAO;EACP,UAAU;EACV,SAAS;CACX;CAEA;EAAE,UAAU;EAAY,OAAO;EAAU,OAAO;EAAmB,UAAU;CAAW;CACxF;EACE,UAAU;EACV,OAAO;EACP,OAAO;EACP,UAAU;EACV,eAAe;CACjB;CAEA;EACE,UAAU;EACV,OAAO;EACP,OAAO;EACP,UAAU;EACV,SAAS;CACX;CACA;EACE,UAAU;EACV,OAAO;EACP,OAAO;EACP,UAAU;EACV,SAAS;CACX;CAEA;EACE,UAAU;EACV,OAAO;EACP,OAAO;EACP,UAAU;EACV,SAAS;CACX;CACA;EACE,UAAU;EACV,OAAO;EACP,OAAO;EACP,UAAU;EACV,SAAS;CACX;CACA;EACE,UAAU;EACV,OAAO;EACP,OAAO;EACP,UAAU;EACV,SAAS;CACX;CACA;EACE,UAAU;EACV,OAAO;EACP,OAAO;EACP,UAAU;EACV,SAAS;CACX;CACA;EACE,UAAU;EACV,OAAO;EACP,OAAO;EACP,UAAU;EACV,SAAS;CACX;CACA;EACE,UAAU;EACV,OAAO;EACP,OAAO;EACP,UAAU;EACV,SAAS;CACX;AACF;;AAGA,MAAa,oBAA8B,WAAW;;AAGtD,MAAa,uBAAuB,kBAAkB;;AAGtD,SAAgB,eAAyB;CACvC,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,MAAgB,CAAC;CACvB,KAAK,MAAM,KAAK,YACd,IAAI,CAAC,KAAK,IAAI,EAAE,QAAQ,GAAG;EACzB,KAAK,IAAI,EAAE,QAAQ;EACnB,IAAI,KAAK,EAAE,QAAQ;CACrB;CAEF,OAAO;AACT;;AAGA,SAAgB,qBAAqB,UAA8B;CACjE,OAAO,WAAW,QAAO,MAAK,EAAE,aAAa,QAAQ;AACvD;;AAGA,SAAgB,wBAAwB,UAAwC;CAC9E,OAAO,WAAW,MAAK,MAAK,EAAE,aAAa,QAAQ;AACrD;AAEA,SAAgB,aAAa,UAAkB,OAAqC;CAClF,OAAO,WAAW,MAAK,MAAK,EAAE,aAAa,YAAY,EAAE,UAAU,KAAK;AAC1E;;;;;;AAOA,SAAgB,gBAAgB,UAAmB,OAA0B;CAC3E,IAAI,CAAC,UAAU,OAAO;CACtB,QAAQ,QAAQ,aAAa,UAAU,KAAK,IAAI,KAAA,MAAc,wBAAwB,QAAQ,KAAK;AACrG"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AuthStorage } from '../auth/storage.js';
|
|
2
|
+
import type { STTModel } from './stt-registry.js';
|
|
3
|
+
export declare function sttApiKeyEnvVar(provider: string): string | undefined;
|
|
4
|
+
export declare function resolveSTTApiKey(provider: string, authStorage?: AuthStorage): string | undefined;
|
|
5
|
+
export interface STTTranscriber {
|
|
6
|
+
/** `filetype` is the extension the provider reads the format from (`wav`, `webm`, `m4a`…). */
|
|
7
|
+
transcribe(audio: Buffer, filetype: string): Promise<string>;
|
|
8
|
+
}
|
|
9
|
+
export declare function createSTTTranscriber(entry: STTModel, apiKey: string): Promise<STTTranscriber>;
|
|
10
|
+
//# sourceMappingURL=transcribe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcribe.d.ts","sourceRoot":"","sources":["../../src/voice/transcribe.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAQlD,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEpE;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAIhG;AA0DD,MAAM,WAAW,cAAc;IAC7B,8FAA8F;IAC9F,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC9D;AAED,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAgBnG"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { providerApiKeyEnvVar } from "../agents/mastracode-gateway.js";
|
|
2
|
+
import { Readable } from "stream";
|
|
3
|
+
// src/voice/transcribe.ts
|
|
4
|
+
const STT_ONLY_API_KEY_ENV_VARS = { deepgram: "DEEPGRAM_API_KEY" };
|
|
5
|
+
const STT_TIMEOUT_MS = 6e4;
|
|
6
|
+
const STT_MAX_RETRIES = 1;
|
|
7
|
+
function sttApiKeyEnvVar(provider) {
|
|
8
|
+
return STT_ONLY_API_KEY_ENV_VARS[provider] ?? providerApiKeyEnvVar(provider);
|
|
9
|
+
}
|
|
10
|
+
function resolveSTTApiKey(provider, authStorage) {
|
|
11
|
+
const envVar = sttApiKeyEnvVar(provider);
|
|
12
|
+
return (envVar ? process.env[envVar]?.trim() : void 0) || authStorage?.getStoredApiKey(provider);
|
|
13
|
+
}
|
|
14
|
+
function listenWithFiletype(voice) {
|
|
15
|
+
return (audio, filetype) => voice.listen(Readable.from(audio), { filetype });
|
|
16
|
+
}
|
|
17
|
+
function openAIClientOptions(entry, apiKey) {
|
|
18
|
+
return {
|
|
19
|
+
timeout: STT_TIMEOUT_MS,
|
|
20
|
+
maxRetries: STT_MAX_RETRIES,
|
|
21
|
+
...apiKey === process.env.OPENAI_API_KEY?.trim() ? {} : {
|
|
22
|
+
organization: null,
|
|
23
|
+
project: null
|
|
24
|
+
},
|
|
25
|
+
...entry.resolver === "openai-compatible" && entry.baseURL ? { baseURL: entry.baseURL } : {}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
async function buildListen(entry, apiKey) {
|
|
29
|
+
if (entry.resolver === "deepgram") {
|
|
30
|
+
const { DeepgramVoice } = await import("@mastra/voice-deepgram");
|
|
31
|
+
const voice = new DeepgramVoice({ listeningModel: {
|
|
32
|
+
name: entry.model,
|
|
33
|
+
apiKey
|
|
34
|
+
} });
|
|
35
|
+
return (audio) => voice.listen(Readable.from(audio));
|
|
36
|
+
}
|
|
37
|
+
const speechModel = { apiKey };
|
|
38
|
+
if (entry.resolver === "mistral") {
|
|
39
|
+
const { MistralVoice } = await import("@mastra/voice-mistral");
|
|
40
|
+
return listenWithFiletype(new MistralVoice({
|
|
41
|
+
speechModel,
|
|
42
|
+
listeningModel: {
|
|
43
|
+
name: entry.model,
|
|
44
|
+
apiKey
|
|
45
|
+
}
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
const { OpenAIVoice } = await import("@mastra/voice-openai");
|
|
49
|
+
return listenWithFiletype(new OpenAIVoice({
|
|
50
|
+
speechModel,
|
|
51
|
+
listeningModel: {
|
|
52
|
+
name: entry.model,
|
|
53
|
+
apiKey,
|
|
54
|
+
options: openAIClientOptions(entry, apiKey)
|
|
55
|
+
}
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
function normalizeTranscript(result) {
|
|
59
|
+
return (typeof result === "string" ? result : result.transcript ?? "").trim();
|
|
60
|
+
}
|
|
61
|
+
async function createSTTTranscriber(entry, apiKey) {
|
|
62
|
+
const listen = await buildListen(entry, apiKey);
|
|
63
|
+
return { async transcribe(audio, filetype) {
|
|
64
|
+
let timer;
|
|
65
|
+
const timeout = new Promise((_, reject) => {
|
|
66
|
+
timer = setTimeout(() => reject(/* @__PURE__ */ new Error("Speech-to-text timed out after 1 minute.")), STT_TIMEOUT_MS);
|
|
67
|
+
});
|
|
68
|
+
try {
|
|
69
|
+
return normalizeTranscript(await Promise.race([listen(audio, filetype), timeout]));
|
|
70
|
+
} finally {
|
|
71
|
+
clearTimeout(timer);
|
|
72
|
+
}
|
|
73
|
+
} };
|
|
74
|
+
}
|
|
75
|
+
export { createSTTTranscriber, resolveSTTApiKey, sttApiKeyEnvVar };
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=transcribe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcribe.js","names":[],"sources":["../../src/voice/transcribe.ts"],"sourcesContent":["// OAuth (Codex) tokens cannot call the transcription endpoints, so callers pass a real provider API key.\n\nimport { Readable } from 'node:stream';\n\nimport type { DeepgramModel } from '@mastra/voice-deepgram';\nimport type { OpenAIConfig } from '@mastra/voice-openai';\n\nimport { providerApiKeyEnvVar } from '../agents/mastracode-gateway.js';\nimport type { AuthStorage } from '../auth/storage.js';\nimport type { STTModel } from './stt-registry.js';\n\nconst STT_ONLY_API_KEY_ENV_VARS: Record<string, string> = { deepgram: 'DEEPGRAM_API_KEY' };\n\nconst STT_TIMEOUT_MS = 60_000;\n\nconst STT_MAX_RETRIES = 1;\n\nexport function sttApiKeyEnvVar(provider: string): string | undefined {\n return STT_ONLY_API_KEY_ENV_VARS[provider] ?? providerApiKeyEnvVar(provider);\n}\n\nexport function resolveSTTApiKey(provider: string, authStorage?: AuthStorage): string | undefined {\n const envVar = sttApiKeyEnvVar(provider);\n const fromEnv = envVar ? process.env[envVar]?.trim() : undefined;\n return fromEnv || authStorage?.getStoredApiKey(provider);\n}\n\n/** Structural, because each `@mastra/voice-*` package extends its own bundled `MastraVoice`. */\ninterface VoiceListener {\n listen(\n audioStream: NodeJS.ReadableStream,\n options?: Record<string, unknown>,\n ): Promise<string | { transcript?: string }>;\n}\n\ntype Listen = (audio: Buffer, filetype: string) => Promise<string | { transcript?: string }>;\n\nfunction listenWithFiletype(voice: VoiceListener): Listen {\n return (audio, filetype) => voice.listen(Readable.from(audio), { filetype });\n}\n\n// The OpenAI SDK reads OPENAI_ORG_ID and OPENAI_PROJECT_ID, which belong to the OPENAI_API_KEY account only.\nfunction openAIClientOptions(entry: STTModel, apiKey: string): OpenAIConfig['options'] {\n return {\n timeout: STT_TIMEOUT_MS,\n maxRetries: STT_MAX_RETRIES,\n ...(apiKey === process.env.OPENAI_API_KEY?.trim() ? {} : { organization: null, project: null }),\n ...(entry.resolver === 'openai-compatible' && entry.baseURL ? { baseURL: entry.baseURL } : {}),\n };\n}\n\n// Each voice SDK loads on first dictation, not with every session.\nasync function buildListen(entry: STTModel, apiKey: string): Promise<Listen> {\n if (entry.resolver === 'deepgram') {\n const { DeepgramVoice } = await import('@mastra/voice-deepgram');\n // `name` is typed for Deepgram's own ids; the registry's model string is passed verbatim.\n const voice = new DeepgramVoice({ listeningModel: { name: entry.model as DeepgramModel, apiKey } });\n return audio => voice.listen(Readable.from(audio));\n }\n // The OpenAI and Mistral constructors also build a TTS client and throw without its key.\n const speechModel = { apiKey };\n if (entry.resolver === 'mistral') {\n const { MistralVoice } = await import('@mastra/voice-mistral');\n return listenWithFiletype(new MistralVoice({ speechModel, listeningModel: { name: entry.model, apiKey } }));\n }\n const { OpenAIVoice } = await import('@mastra/voice-openai');\n return listenWithFiletype(\n new OpenAIVoice({\n speechModel,\n listeningModel: {\n // Typed for OpenAI's own ids; the client accepts any model string and baseURL.\n name: entry.model as OpenAIConfig['name'],\n apiKey,\n options: openAIClientOptions(entry, apiKey),\n },\n }),\n );\n}\n\nfunction normalizeTranscript(result: string | { transcript?: string }): string {\n return (typeof result === 'string' ? result : (result.transcript ?? '')).trim();\n}\n\nexport interface STTTranscriber {\n /** `filetype` is the extension the provider reads the format from (`wav`, `webm`, `m4a`…). */\n transcribe(audio: Buffer, filetype: string): Promise<string>;\n}\n\nexport async function createSTTTranscriber(entry: STTModel, apiKey: string): Promise<STTTranscriber> {\n const listen = await buildListen(entry, apiKey);\n return {\n async transcribe(audio, filetype) {\n let timer: NodeJS.Timeout | undefined;\n // Only the OpenAI client takes a timeout; Mistral and Deepgram calls, and an OpenAI retry after a slow attempt, are abandoned here, not cancelled.\n const timeout = new Promise<never>((_, reject) => {\n timer = setTimeout(() => reject(new Error('Speech-to-text timed out after 1 minute.')), STT_TIMEOUT_MS);\n });\n try {\n return normalizeTranscript(await Promise.race([listen(audio, filetype), timeout]));\n } finally {\n clearTimeout(timer);\n }\n },\n };\n}\n"],"mappings":";;;AAWA,MAAM,4BAAoD,EAAE,UAAU,mBAAmB;AAEzF,MAAM,iBAAiB;AAEvB,MAAM,kBAAkB;AAExB,SAAgB,gBAAgB,UAAsC;CACpE,OAAO,0BAA0B,aAAa,qBAAqB,QAAQ;AAC7E;AAEA,SAAgB,iBAAiB,UAAkB,aAA+C;CAChG,MAAM,SAAS,gBAAgB,QAAQ;CAEvC,QADgB,SAAS,QAAQ,IAAI,OAAO,EAAE,KAAK,IAAI,KAAA,MACrC,aAAa,gBAAgB,QAAQ;AACzD;AAYA,SAAS,mBAAmB,OAA8B;CACxD,QAAQ,OAAO,aAAa,MAAM,OAAO,SAAS,KAAK,KAAK,GAAG,EAAE,SAAS,CAAC;AAC7E;AAGA,SAAS,oBAAoB,OAAiB,QAAyC;CACrF,OAAO;EACL,SAAS;EACT,YAAY;EACZ,GA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AO,QAAQ,GAAG,OAAO,CAAC,CAAC;EACnF,UAAU;GACR,aAAa,KAAK;EACpB;CACF,EACF;AACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { MC_TOOLS } from "../tool-names.js";
|
|
2
|
-
import { createConfiguredWebTools } from "../tools/web-search.js";
|
|
3
1
|
import { createMastraCodeWorkspaceTools } from "../agents/tool-availability.js";
|
|
4
2
|
import { LazyNotificationsStorage } from "../agents/tools.js";
|
|
5
3
|
import { workflowBuilderAgent } from "../agents/workflow-builder-agent.js";
|
|
4
|
+
import { MC_TOOLS } from "../tool-names.js";
|
|
5
|
+
import { createConfiguredWebTools } from "../tools/web-search.js";
|
|
6
6
|
import { LocalFilesystem, LocalSandbox, Workspace, createWorkspaceTools } from "@mastra/core/workspace";
|
|
7
7
|
import { createNotificationInboxTool } from "@mastra/core/notifications";
|
|
8
8
|
// src/workflows/register-primitives.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/code-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0-alpha.1",
|
|
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": {
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@agentclientprotocol/sdk": "^0.21.1",
|
|
49
49
|
"@ai-sdk/amazon-bedrock": "^5.0.130",
|
|
50
|
-
"@ai-sdk/anthropic": "^
|
|
50
|
+
"@ai-sdk/anthropic": "^4.0.94",
|
|
51
51
|
"@ai-sdk/google-vertex": "^3.0.186",
|
|
52
|
-
"@ai-sdk/openai": "^
|
|
53
|
-
"@ai-sdk/openai-compatible": "^
|
|
52
|
+
"@ai-sdk/openai": "^4.0.106",
|
|
53
|
+
"@ai-sdk/openai-compatible": "^3.0.82",
|
|
54
54
|
"@ast-grep/napi": "^0.42.3",
|
|
55
55
|
"@aws-sdk/credential-providers": "^3.1156.0",
|
|
56
|
-
"ai": "^
|
|
56
|
+
"ai": "^7.0.159",
|
|
57
57
|
"execa": "^9.6.1",
|
|
58
58
|
"libsql": "^0.5.29",
|
|
59
59
|
"posthog-node": "^5.57.1",
|
|
@@ -64,21 +64,25 @@
|
|
|
64
64
|
"yaml": "^2.9.1",
|
|
65
65
|
"zod": "^4.6.7",
|
|
66
66
|
"@mastra/agent-browser": "0.6.0",
|
|
67
|
-
"@mastra/client-js": "1.
|
|
68
|
-
"@mastra/duckdb": "1.
|
|
67
|
+
"@mastra/client-js": "1.60.0-alpha.1",
|
|
68
|
+
"@mastra/duckdb": "1.19.0-alpha.1",
|
|
69
69
|
"@mastra/fastembed": "1.3.6",
|
|
70
70
|
"@mastra/github-signals": "0.5.2",
|
|
71
|
-
"@mastra/libsql": "1.
|
|
72
|
-
"@mastra/mcp": "2.
|
|
73
|
-
"@mastra/memory": "1.41.0",
|
|
74
|
-
"@mastra/observability": "1.23.1",
|
|
71
|
+
"@mastra/libsql": "1.30.0-alpha.0",
|
|
72
|
+
"@mastra/mcp": "2.9.0-alpha.1",
|
|
73
|
+
"@mastra/memory": "1.41.1-alpha.0",
|
|
74
|
+
"@mastra/observability": "1.23.2-alpha.1",
|
|
75
75
|
"@mastra/parallel": "0.1.5",
|
|
76
|
-
"@mastra/pg": "1.
|
|
76
|
+
"@mastra/pg": "1.36.0-alpha.1",
|
|
77
77
|
"@mastra/schema-compat": "1.3.17",
|
|
78
78
|
"@mastra/stagehand": "0.4.0",
|
|
79
|
-
"@mastra/tavily": "1.1.3"
|
|
79
|
+
"@mastra/tavily": "1.1.3",
|
|
80
|
+
"@mastra/voice-deepgram": "0.13.4-alpha.0",
|
|
81
|
+
"@mastra/voice-mistral": "0.1.3",
|
|
82
|
+
"@mastra/voice-openai": "0.13.4"
|
|
80
83
|
},
|
|
81
84
|
"devDependencies": {
|
|
85
|
+
"@ai-sdk/provider": "^4.0.35",
|
|
82
86
|
"@copilotkit/aimock": "^1.46.0",
|
|
83
87
|
"@libsql/client": "^0.18.0",
|
|
84
88
|
"@types/node": "22.19.15",
|
|
@@ -90,10 +94,10 @@
|
|
|
90
94
|
"@internal/lint": "0.0.148",
|
|
91
95
|
"@internal/types-builder": "0.0.123",
|
|
92
96
|
"@internal/workspace-test-utils": "0.0.92",
|
|
93
|
-
"@mastra/core": "1.
|
|
97
|
+
"@mastra/core": "1.83.0-alpha.1"
|
|
94
98
|
},
|
|
95
99
|
"peerDependencies": {
|
|
96
|
-
"@mastra/core": ">=1.
|
|
100
|
+
"@mastra/core": ">=1.83.0-0 <2.0.0-0"
|
|
97
101
|
},
|
|
98
102
|
"engines": {
|
|
99
103
|
"node": ">=22.19.0"
|