@mastra/code-sdk 1.15.0-alpha.1 → 1.15.0-alpha.2
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/agents/workspace.d.ts.map +1 -1
- package/dist/agents/workspace.js +1 -0
- package/dist/agents/workspace.js.map +1 -1
- package/dist/headless/cli.d.ts +7 -0
- package/dist/headless/cli.d.ts.map +1 -1
- package/dist/headless/cli.js +19 -3
- package/dist/headless/cli.js.map +1 -1
- package/dist/headless/flags.d.ts.map +1 -1
- package/dist/headless/flags.js +2 -1
- package/dist/headless/flags.js.map +1 -1
- package/dist/headless/format.d.ts +2 -0
- package/dist/headless/format.d.ts.map +1 -1
- package/dist/headless/format.js +13 -1
- package/dist/headless/format.js.map +1 -1
- package/dist/headless/run-mc.d.ts.map +1 -1
- package/dist/headless/run-mc.js +48 -20
- package/dist/headless/run-mc.js.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/dist/providers/model-ids.d.ts +1 -0
- package/dist/providers/model-ids.d.ts.map +1 -1
- package/dist/providers/model-ids.js +6 -4
- package/dist/providers/model-ids.js.map +1 -1
- package/dist/tools/workflows/create-workflow.d.ts.map +1 -1
- package/dist/tools/workflows/create-workflow.js +5 -1
- package/dist/tools/workflows/create-workflow.js.map +1 -1
- package/dist/workflows/register-primitives.js +4 -1
- package/dist/workflows/register-primitives.js.map +1 -1
- package/package.json +10 -10
|
@@ -16,6 +16,7 @@ export declare function stripMastraGatewayPrefix(modelId: string): string;
|
|
|
16
16
|
export declare const KIMI_CODING_PROVIDER_ID = "kimi-code-plan-cn";
|
|
17
17
|
/** Credential id the Kimi login stores accounts under. */
|
|
18
18
|
export declare const KIMI_CODING_CREDENTIAL_ID = "kimi-for-coding";
|
|
19
|
+
export declare function normalizeLegacyProviderId(providerId: string): string;
|
|
19
20
|
/**
|
|
20
21
|
* Map model ids saved by older Mastra Code versions (packs, OM settings,
|
|
21
22
|
* thread metadata) to the current catalog id:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-ids.d.ts","sourceRoot":"","sources":["../../src/providers/model-ids.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,gBAAgB,eAAe,CAAC;AAC7C,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAE/C,sGAAsG;AACtG,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjE;AAeD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,sBAAsB,CAAC;AAC3D,0DAA0D;AAC1D,eAAO,MAAM,yBAAyB,oBAAoB,CAAC;AAS3D;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"model-ids.d.ts","sourceRoot":"","sources":["../../src/providers/model-ids.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,gBAAgB,eAAe,CAAC;AAC7C,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAE/C,sGAAsG;AACtG,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjE;AAeD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,sBAAsB,CAAC;AAC3D,0DAA0D;AAC1D,eAAO,MAAM,yBAAyB,oBAAoB,CAAC;AAS3D,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAS9D;AAED,oEAAoE;AACpE,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAIlE;AAED,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAoBrE"}
|
|
@@ -41,6 +41,9 @@ const LEGACY_MASTRACODE_NAMESPACED_PROVIDERS = /* @__PURE__ */ new Set([
|
|
|
41
41
|
]);
|
|
42
42
|
/** Provider ids Mastra Code defined itself before augmenting the models.dev provider. */
|
|
43
43
|
const LEGACY_PROVIDER_IDS = { [KIMI_CODING_CREDENTIAL_ID]: KIMI_CODING_PROVIDER_ID };
|
|
44
|
+
function normalizeLegacyProviderId(providerId) {
|
|
45
|
+
return LEGACY_PROVIDER_IDS[providerId] ?? providerId;
|
|
46
|
+
}
|
|
44
47
|
/**
|
|
45
48
|
* Map model ids saved by older Mastra Code versions (packs, OM settings,
|
|
46
49
|
* thread metadata) to the current catalog id:
|
|
@@ -53,9 +56,8 @@ function normalizeLegacyModelId(modelId) {
|
|
|
53
56
|
const namespacedProvider = normalized.startsWith("mastracode/") ? normalized.split("/", 3)[1] : void 0;
|
|
54
57
|
if (namespacedProvider && LEGACY_MASTRACODE_NAMESPACED_PROVIDERS.has(namespacedProvider)) normalized = normalized.slice(11);
|
|
55
58
|
const slash = normalized.indexOf("/");
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return replacement ? `${replacement}${normalized.slice(slash)}` : normalized;
|
|
59
|
+
if (slash <= 0) return normalized;
|
|
60
|
+
return `${normalizeLegacyProviderId(normalized.slice(0, slash))}${normalized.slice(slash)}`;
|
|
59
61
|
}
|
|
60
62
|
/** Credential-store id that authenticates a catalog provider id. */
|
|
61
63
|
function getCredentialProviderId(providerId) {
|
|
@@ -74,6 +76,6 @@ function remapOpenAIModelForCodexOAuth(modelId) {
|
|
|
74
76
|
return modelId.startsWith("mastra/") ? `${MASTRA_GATEWAY_PREFIX}${remappedModelId}` : remappedModelId;
|
|
75
77
|
}
|
|
76
78
|
//#endregion
|
|
77
|
-
export { ANTHROPIC_PREFIX, KIMI_CODING_CREDENTIAL_ID, KIMI_CODING_PROVIDER_ID, MASTRA_GATEWAY_PREFIX, OPENAI_PREFIX, getCredentialProviderId, normalizeAnthropicModelId, normalizeLegacyModelId, remapOpenAIModelForCodexOAuth, stripMastraGatewayPrefix };
|
|
79
|
+
export { ANTHROPIC_PREFIX, KIMI_CODING_CREDENTIAL_ID, KIMI_CODING_PROVIDER_ID, MASTRA_GATEWAY_PREFIX, OPENAI_PREFIX, getCredentialProviderId, normalizeAnthropicModelId, normalizeLegacyModelId, normalizeLegacyProviderId, remapOpenAIModelForCodexOAuth, stripMastraGatewayPrefix };
|
|
78
80
|
|
|
79
81
|
//# sourceMappingURL=model-ids.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-ids.js","names":[],"sources":["../../src/providers/model-ids.ts"],"sourcesContent":["/**\n * Model-id helpers shared by the model gateway and the browser settings\n * module. Kept dependency-free so neither side has to import the other.\n */\n\nexport const OPENAI_PREFIX = 'openai/';\nexport const ANTHROPIC_PREFIX = 'anthropic/';\nexport const MASTRA_GATEWAY_PREFIX = 'mastra/';\n\n/** Anthropic's API only accepts dashed ids (`claude-opus-4-6`), but catalogs may list dotted ones. */\nexport function normalizeAnthropicModelId(modelId: string): string {\n return modelId.replace(/\\.(?=\\d)/g, '-');\n}\n\n/**\n * The Codex ChatGPT-account endpoint serves some OpenAI models only under a\n * `-codex` id. Applied wherever a model id is sent over Codex OAuth (chat\n * agents and Stagehand alike) so both paths hit the same upstream model.\n */\nconst CODEX_OPENAI_MODEL_REMAPS: Record<string, string> = {\n 'gpt-5.3': 'gpt-5.3-codex',\n 'gpt-5.2': 'gpt-5.2-codex',\n 'gpt-5.1': 'gpt-5.1-codex',\n 'gpt-5.1-mini': 'gpt-5.1-codex-mini',\n 'gpt-5': 'gpt-5-codex',\n};\n\nexport function stripMastraGatewayPrefix(modelId: string): string {\n return modelId.startsWith(MASTRA_GATEWAY_PREFIX) ? modelId.substring(MASTRA_GATEWAY_PREFIX.length) : modelId;\n}\n\n/**\n * Kimi For Coding subscriptions are served from `api.kimi.com`, which models.dev\n * lists as `kimi-code-plan-cn`. Mastra Code augments that provider with the\n * Kimi OAuth/API-key credential instead of defining its own.\n */\nexport const KIMI_CODING_PROVIDER_ID = 'kimi-code-plan-cn';\n/** Credential id the Kimi login stores accounts under. */\nexport const KIMI_CODING_CREDENTIAL_ID = 'kimi-for-coding';\n\n/** Providers Mastra Code used to catalog as `mastracode/<provider>/<model>`. */\nconst LEGACY_MASTRACODE_NAMESPACED_PROVIDERS = new Set(['amazon-bedrock', 'github-copilot', KIMI_CODING_CREDENTIAL_ID]);\n/** Provider ids Mastra Code defined itself before augmenting the models.dev provider. */\nconst LEGACY_PROVIDER_IDS: Record<string, string> = {\n [KIMI_CODING_CREDENTIAL_ID]: KIMI_CODING_PROVIDER_ID,\n};\n\n/**\n * Map model ids saved by older Mastra Code versions (packs, OM settings,\n * thread metadata) to the current catalog id:\n * `mastracode/kimi-for-coding/k3` and `kimi-for-coding/k3` → `kimi-code-plan-cn/k3`,\n * `mastracode/github-copilot/<m>` → `github-copilot/<m>`,\n * `mastracode/amazon-bedrock/<m>` → `amazon-bedrock/<m>`.\n */\nexport function normalizeLegacyModelId(modelId: string): string {\n let normalized = modelId;\n const namespacedProvider = normalized.startsWith('mastracode/') ? normalized.split('/', 3)[1] : undefined;\n if (namespacedProvider && LEGACY_MASTRACODE_NAMESPACED_PROVIDERS.has(namespacedProvider)) {\n normalized = normalized.slice('mastracode/'.length);\n }\n const slash = normalized.indexOf('/');\n
|
|
1
|
+
{"version":3,"file":"model-ids.js","names":[],"sources":["../../src/providers/model-ids.ts"],"sourcesContent":["/**\n * Model-id helpers shared by the model gateway and the browser settings\n * module. Kept dependency-free so neither side has to import the other.\n */\n\nexport const OPENAI_PREFIX = 'openai/';\nexport const ANTHROPIC_PREFIX = 'anthropic/';\nexport const MASTRA_GATEWAY_PREFIX = 'mastra/';\n\n/** Anthropic's API only accepts dashed ids (`claude-opus-4-6`), but catalogs may list dotted ones. */\nexport function normalizeAnthropicModelId(modelId: string): string {\n return modelId.replace(/\\.(?=\\d)/g, '-');\n}\n\n/**\n * The Codex ChatGPT-account endpoint serves some OpenAI models only under a\n * `-codex` id. Applied wherever a model id is sent over Codex OAuth (chat\n * agents and Stagehand alike) so both paths hit the same upstream model.\n */\nconst CODEX_OPENAI_MODEL_REMAPS: Record<string, string> = {\n 'gpt-5.3': 'gpt-5.3-codex',\n 'gpt-5.2': 'gpt-5.2-codex',\n 'gpt-5.1': 'gpt-5.1-codex',\n 'gpt-5.1-mini': 'gpt-5.1-codex-mini',\n 'gpt-5': 'gpt-5-codex',\n};\n\nexport function stripMastraGatewayPrefix(modelId: string): string {\n return modelId.startsWith(MASTRA_GATEWAY_PREFIX) ? modelId.substring(MASTRA_GATEWAY_PREFIX.length) : modelId;\n}\n\n/**\n * Kimi For Coding subscriptions are served from `api.kimi.com`, which models.dev\n * lists as `kimi-code-plan-cn`. Mastra Code augments that provider with the\n * Kimi OAuth/API-key credential instead of defining its own.\n */\nexport const KIMI_CODING_PROVIDER_ID = 'kimi-code-plan-cn';\n/** Credential id the Kimi login stores accounts under. */\nexport const KIMI_CODING_CREDENTIAL_ID = 'kimi-for-coding';\n\n/** Providers Mastra Code used to catalog as `mastracode/<provider>/<model>`. */\nconst LEGACY_MASTRACODE_NAMESPACED_PROVIDERS = new Set(['amazon-bedrock', 'github-copilot', KIMI_CODING_CREDENTIAL_ID]);\n/** Provider ids Mastra Code defined itself before augmenting the models.dev provider. */\nconst LEGACY_PROVIDER_IDS: Record<string, string> = {\n [KIMI_CODING_CREDENTIAL_ID]: KIMI_CODING_PROVIDER_ID,\n};\n\nexport function normalizeLegacyProviderId(providerId: string): string {\n return LEGACY_PROVIDER_IDS[providerId] ?? providerId;\n}\n\n/**\n * Map model ids saved by older Mastra Code versions (packs, OM settings,\n * thread metadata) to the current catalog id:\n * `mastracode/kimi-for-coding/k3` and `kimi-for-coding/k3` → `kimi-code-plan-cn/k3`,\n * `mastracode/github-copilot/<m>` → `github-copilot/<m>`,\n * `mastracode/amazon-bedrock/<m>` → `amazon-bedrock/<m>`.\n */\nexport function normalizeLegacyModelId(modelId: string): string {\n let normalized = modelId;\n const namespacedProvider = normalized.startsWith('mastracode/') ? normalized.split('/', 3)[1] : undefined;\n if (namespacedProvider && LEGACY_MASTRACODE_NAMESPACED_PROVIDERS.has(namespacedProvider)) {\n normalized = normalized.slice('mastracode/'.length);\n }\n const slash = normalized.indexOf('/');\n if (slash <= 0) return normalized;\n return `${normalizeLegacyProviderId(normalized.slice(0, slash))}${normalized.slice(slash)}`;\n}\n\n/** Credential-store id that authenticates a catalog provider id. */\nexport function getCredentialProviderId(providerId: string): string {\n if (providerId === 'openai') return 'openai-codex';\n if (providerId === KIMI_CODING_PROVIDER_ID) return KIMI_CODING_CREDENTIAL_ID;\n return providerId;\n}\n\nexport function remapOpenAIModelForCodexOAuth(modelId: string): string {\n const normalizedModelId = stripMastraGatewayPrefix(modelId);\n\n if (!normalizedModelId.startsWith(OPENAI_PREFIX)) {\n return modelId;\n }\n\n const openaiModelId = normalizedModelId.substring(OPENAI_PREFIX.length);\n\n if (openaiModelId.includes('-codex')) {\n return modelId;\n }\n\n const codexModelId = CODEX_OPENAI_MODEL_REMAPS[openaiModelId];\n if (!codexModelId) {\n return modelId;\n }\n\n const remappedModelId = `${OPENAI_PREFIX}${codexModelId}`;\n return modelId.startsWith(MASTRA_GATEWAY_PREFIX) ? `${MASTRA_GATEWAY_PREFIX}${remappedModelId}` : remappedModelId;\n}\n"],"mappings":";;;;;AAKA,MAAa,gBAAgB;AAC7B,MAAa,mBAAmB;AAChC,MAAa,wBAAwB;;AAGrC,SAAgB,0BAA0B,SAAyB;CACjE,OAAO,QAAQ,QAAQ,aAAa,GAAG;AACzC;;;;;;AAOA,MAAM,4BAAoD;CACxD,WAAW;CACX,WAAW;CACX,WAAW;CACX,gBAAgB;CAChB,SAAS;AACX;AAEA,SAAgB,yBAAyB,SAAyB;CAChE,OAAO,QAAQ,WAAA,SAAgC,IAAI,QAAQ,UAAU,CAA4B,IAAI;AACvG;;;;;;AAOA,MAAa,0BAA0B;;AAEvC,MAAa,4BAA4B;;AAGzC,MAAM,yDAAyC,IAAI,IAAI;CAAC;CAAkB;CAAkB;AAAyB,CAAC;;AAEtH,MAAM,sBAA8C,GACjD,4BAA4B,wBAC/B;AAEA,SAAgB,0BAA0B,YAA4B;CACpE,OAAO,oBAAoB,eAAe;AAC5C;;;;;;;;AASA,SAAgB,uBAAuB,SAAyB;CAC9D,IAAI,aAAa;CACjB,MAAM,qBAAqB,WAAW,WAAW,aAAa,IAAI,WAAW,MAAM,KAAK,CAAC,CAAC,CAAC,KAAK,KAAA;CAChG,IAAI,sBAAsB,uCAAuC,IAAI,kBAAkB,GACrF,aAAa,WAAW,MAAM,EAAoB;CAEpD,MAAM,QAAQ,WAAW,QAAQ,GAAG;CACpC,IAAI,SAAS,GAAG,OAAO;CACvB,OAAO,GAAG,0BAA0B,WAAW,MAAM,GAAG,KAAK,CAAC,IAAI,WAAW,MAAM,KAAK;AAC1F;;AAGA,SAAgB,wBAAwB,YAA4B;CAClE,IAAI,eAAe,UAAU,OAAO;CACpC,IAAI,eAAA,qBAAwC,OAAO;CACnD,OAAO;AACT;AAEA,SAAgB,8BAA8B,SAAyB;CACrE,MAAM,oBAAoB,yBAAyB,OAAO;CAE1D,IAAI,CAAC,kBAAkB,WAAA,SAAwB,GAC7C,OAAO;CAGT,MAAM,gBAAgB,kBAAkB,UAAU,CAAoB;CAEtE,IAAI,cAAc,SAAS,QAAQ,GACjC,OAAO;CAGT,MAAM,eAAe,0BAA0B;CAC/C,IAAI,CAAC,cACH,OAAO;CAGT,MAAM,kBAAkB,GAAG,gBAAgB;CAC3C,OAAO,QAAQ,WAAA,SAAgC,IAAI,GAAG,wBAAwB,oBAAoB;AACpG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-workflow.d.ts","sourceRoot":"","sources":["../../../src/tools/workflows/create-workflow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-workflow.d.ts","sourceRoot":"","sources":["../../../src/tools/workflows/create-workflow.ts"],"names":[],"mappings":"AA6BA,eAAO,MAAM,kBAAkB;;;;;8HA2G7B,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MASTRA_RESOURCE_ID_KEY, MASTRA_THREAD_ID_KEY, RequestContext } from "@mastra/core/request-context";
|
|
1
2
|
import { createTool } from "@mastra/core/tools";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
//#region src/tools/workflows/create-workflow.ts
|
|
@@ -27,7 +28,10 @@ const createWorkflowTool = createTool({
|
|
|
27
28
|
if (!mastra) throw new Error("create-workflow requires a Mastra context.");
|
|
28
29
|
const builder = mastra.getAgent("workflow-builder");
|
|
29
30
|
if (!builder) throw new Error("The \"workflow-builder\" sub-agent is not registered on this Mastra instance. Cannot build workflows.");
|
|
30
|
-
const
|
|
31
|
+
const builderRequestContext = requestContext ? new RequestContext(requestContext.entries()) : void 0;
|
|
32
|
+
builderRequestContext?.delete(MASTRA_THREAD_ID_KEY);
|
|
33
|
+
builderRequestContext?.delete(MASTRA_RESOURCE_ID_KEY);
|
|
34
|
+
const stream = await builder.stream(request, { requestContext: builderRequestContext });
|
|
31
35
|
let workflowId;
|
|
32
36
|
let saveAttempted = false;
|
|
33
37
|
let saveSucceeded = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-workflow.js","names":[],"sources":["../../../src/tools/workflows/create-workflow.ts"],"sourcesContent":["/**\n * Parent-mode tool: delegate workflow construction to the workflow-builder\n * sub-agent. The parent code-agent calls this with the user's request verbatim;\n * the sub-agent runs its own discovery → compose → save loop and returns a\n * one-paragraph summary the parent relays to the user.\n *\n * The split exists so the parent code-agent's system prompt stays focused on\n * coding and isn't polluted with the long workflow-authoring contract.\n */\nimport type { Mastra } from '@mastra/core/mastra';\nimport { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\n/**\n * Coerce an unknown thrown value into a readable string. Sub-agent tool errors\n * come through the stream in various shapes (Error, plain object, string) —\n * normalise so the parent tool's error message is always useful.\n */\nfunction stringifyError(err: unknown): string {\n if (err instanceof Error) return err.message;\n if (typeof err === 'string') return err;\n try {\n return JSON.stringify(err) ?? String(err);\n } catch {\n return String(err);\n }\n}\n\nexport const createWorkflowTool = createTool({\n id: 'create-workflow',\n description:\n 'Build and save a Dynamic Workflow on behalf of the user. Pass the user request verbatim — a focused sub-agent handles discovery, construction, and persistence, then returns a summary. Use this whenever the user asks to \"build a workflow\", \"compose a workflow\", or similar. Do NOT try to construct workflows inline yourself.',\n inputSchema: z.object({\n request: z.string().describe('The user request, verbatim — do not paraphrase or summarise.'),\n }),\n outputSchema: z.object({\n summary: z.string().describe('Natural-language summary of what the sub-agent built. Relay this to the user.'),\n workflowId: z.string().optional().describe('The id of the saved workflow, if save-workflow returned ok.'),\n }),\n execute: async ({ request }, { mastra, requestContext }) => {\n if (!mastra) throw new Error('create-workflow requires a Mastra context.');\n const builder = (mastra as Mastra).getAgent('workflow-builder' as never);\n if (!builder) {\n throw new Error(\n 'The \"workflow-builder\" sub-agent is not registered on this Mastra instance. Cannot build workflows.',\n );\n }\n\n // Propagate the parent code-agent's requestContext so the sub-agent's\n // dynamic model resolver (getDynamicModel) sees controller.session.modelId.\n // Without this the sub-agent throws \"No model selected\" even when the user\n // has /models configured for the main code-agent.\n const stream = await builder.stream(request, { requestContext });\n\n // Sub-agent runs its own tool loop. We MUST verify save-workflow actually\n // ran and returned ok — otherwise the sub-agent's natural-language \"summary\"\n // is worthless (it will happily claim success without ever calling the tool,\n // or claim success after save-workflow threw). Surface every error the\n // sub-agent's tools produce so the caller sees them instead of a fake ok.\n let workflowId: string | undefined;\n let saveAttempted = false;\n let saveSucceeded = false;\n const toolErrors: Array<{ toolName: string; error: string }> = [];\n\n const reader = stream.fullStream.getReader();\n let streamCompleted = false;\n try {\n while (true) {\n const { value, done } = await reader.read();\n if (done) {\n streamCompleted = true;\n break;\n }\n if (value?.type === 'tool-call' && value.payload?.toolName === 'save-workflow') {\n saveAttempted = true;\n }\n if (value?.type === 'tool-result' && value.payload?.toolName === 'save-workflow') {\n const result = value.payload.result as { id?: string; ok?: boolean } | undefined;\n if (result && result.ok === true && typeof result.id === 'string') {\n workflowId = result.id;\n saveSucceeded = true;\n }\n }\n if (value?.type === 'tool-error' && typeof value.payload?.toolName === 'string') {\n toolErrors.push({ toolName: value.payload.toolName, error: stringifyError(value.payload.error) });\n }\n }\n } finally {\n if (!streamCompleted) {\n await reader.cancel().catch(() => undefined);\n }\n reader.releaseLock();\n }\n\n const summary = await stream.text;\n\n // If save-workflow errored, surface that error explicitly — do NOT return\n // the sub-agent's summary as if things were fine.\n const saveErrors = toolErrors.filter(e => e.toolName === 'save-workflow');\n if (saveErrors.length > 0 && !saveSucceeded) {\n throw new Error(\n `create-workflow failed: save-workflow threw ${saveErrors.length} error(s):\\n- ${saveErrors\n .map(e => e.error)\n .join('\\n- ')}\\n\\nSub-agent summary (unreliable, save did not succeed):\\n${summary}`,\n );\n }\n\n // If save-workflow was never called, the sub-agent gave up (or hallucinated\n // success). Fail loudly so the caller doesn't think a workflow exists.\n if (!saveAttempted) {\n const otherErrors = toolErrors.length\n ? `\\n\\nOther sub-agent tool errors:\\n- ${toolErrors.map(e => `${e.toolName}: ${e.error}`).join('\\n- ')}`\n : '';\n throw new Error(\n `create-workflow failed: the workflow-builder sub-agent never called save-workflow. No workflow was persisted.${otherErrors}\\n\\nSub-agent summary:\\n${summary}`,\n );\n }\n\n // Save was attempted but never returned ok (no tool-result with { ok: true, id }).\n if (!saveSucceeded) {\n const otherErrors = toolErrors.length\n ? `\\n\\nSub-agent tool errors:\\n- ${toolErrors.map(e => `${e.toolName}: ${e.error}`).join('\\n- ')}`\n : '';\n throw new Error(\n `create-workflow failed: save-workflow was called but did not return { ok: true }.${otherErrors}\\n\\nSub-agent summary:\\n${summary}`,\n );\n }\n\n return { summary, workflowId };\n },\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-workflow.js","names":[],"sources":["../../../src/tools/workflows/create-workflow.ts"],"sourcesContent":["/**\n * Parent-mode tool: delegate workflow construction to the workflow-builder\n * sub-agent. The parent code-agent calls this with the user's request verbatim;\n * the sub-agent runs its own discovery → compose → save loop and returns a\n * one-paragraph summary the parent relays to the user.\n *\n * The split exists so the parent code-agent's system prompt stays focused on\n * coding and isn't polluted with the long workflow-authoring contract.\n */\nimport type { Mastra } from '@mastra/core/mastra';\nimport { MASTRA_RESOURCE_ID_KEY, MASTRA_THREAD_ID_KEY, RequestContext } from '@mastra/core/request-context';\nimport { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\n/**\n * Coerce an unknown thrown value into a readable string. Sub-agent tool errors\n * come through the stream in various shapes (Error, plain object, string) —\n * normalise so the parent tool's error message is always useful.\n */\nfunction stringifyError(err: unknown): string {\n if (err instanceof Error) return err.message;\n if (typeof err === 'string') return err;\n try {\n return JSON.stringify(err) ?? String(err);\n } catch {\n return String(err);\n }\n}\n\nexport const createWorkflowTool = createTool({\n id: 'create-workflow',\n description:\n 'Build and save a Dynamic Workflow on behalf of the user. Pass the user request verbatim — a focused sub-agent handles discovery, construction, and persistence, then returns a summary. Use this whenever the user asks to \"build a workflow\", \"compose a workflow\", or similar. Do NOT try to construct workflows inline yourself.',\n inputSchema: z.object({\n request: z.string().describe('The user request, verbatim — do not paraphrase or summarise.'),\n }),\n outputSchema: z.object({\n summary: z.string().describe('Natural-language summary of what the sub-agent built. Relay this to the user.'),\n workflowId: z.string().optional().describe('The id of the saved workflow, if save-workflow returned ok.'),\n }),\n execute: async ({ request }, { mastra, requestContext }) => {\n if (!mastra) throw new Error('create-workflow requires a Mastra context.');\n const builder = (mastra as Mastra).getAgent('workflow-builder' as never);\n if (!builder) {\n throw new Error(\n 'The \"workflow-builder\" sub-agent is not registered on this Mastra instance. Cannot build workflows.',\n );\n }\n\n // Propagate the parent code-agent's requestContext so the sub-agent's\n // dynamic model resolver (getDynamicModel) sees controller.session.modelId.\n // Without this the sub-agent throws \"No model selected\" even when the user\n // has /models configured for the main code-agent.\n // Drop the reserved memory keys: they would bind the builder to the parent\n // run's thread, and the builder would wait on the run that is waiting on it.\n const builderRequestContext = requestContext ? new RequestContext(requestContext.entries()) : undefined;\n builderRequestContext?.delete(MASTRA_THREAD_ID_KEY);\n builderRequestContext?.delete(MASTRA_RESOURCE_ID_KEY);\n const stream = await builder.stream(request, { requestContext: builderRequestContext });\n\n // Sub-agent runs its own tool loop. We MUST verify save-workflow actually\n // ran and returned ok — otherwise the sub-agent's natural-language \"summary\"\n // is worthless (it will happily claim success without ever calling the tool,\n // or claim success after save-workflow threw). Surface every error the\n // sub-agent's tools produce so the caller sees them instead of a fake ok.\n let workflowId: string | undefined;\n let saveAttempted = false;\n let saveSucceeded = false;\n const toolErrors: Array<{ toolName: string; error: string }> = [];\n\n const reader = stream.fullStream.getReader();\n let streamCompleted = false;\n try {\n while (true) {\n const { value, done } = await reader.read();\n if (done) {\n streamCompleted = true;\n break;\n }\n if (value?.type === 'tool-call' && value.payload?.toolName === 'save-workflow') {\n saveAttempted = true;\n }\n if (value?.type === 'tool-result' && value.payload?.toolName === 'save-workflow') {\n const result = value.payload.result as { id?: string; ok?: boolean } | undefined;\n if (result && result.ok === true && typeof result.id === 'string') {\n workflowId = result.id;\n saveSucceeded = true;\n }\n }\n if (value?.type === 'tool-error' && typeof value.payload?.toolName === 'string') {\n toolErrors.push({ toolName: value.payload.toolName, error: stringifyError(value.payload.error) });\n }\n }\n } finally {\n if (!streamCompleted) {\n await reader.cancel().catch(() => undefined);\n }\n reader.releaseLock();\n }\n\n const summary = await stream.text;\n\n // If save-workflow errored, surface that error explicitly — do NOT return\n // the sub-agent's summary as if things were fine.\n const saveErrors = toolErrors.filter(e => e.toolName === 'save-workflow');\n if (saveErrors.length > 0 && !saveSucceeded) {\n throw new Error(\n `create-workflow failed: save-workflow threw ${saveErrors.length} error(s):\\n- ${saveErrors\n .map(e => e.error)\n .join('\\n- ')}\\n\\nSub-agent summary (unreliable, save did not succeed):\\n${summary}`,\n );\n }\n\n // If save-workflow was never called, the sub-agent gave up (or hallucinated\n // success). Fail loudly so the caller doesn't think a workflow exists.\n if (!saveAttempted) {\n const otherErrors = toolErrors.length\n ? `\\n\\nOther sub-agent tool errors:\\n- ${toolErrors.map(e => `${e.toolName}: ${e.error}`).join('\\n- ')}`\n : '';\n throw new Error(\n `create-workflow failed: the workflow-builder sub-agent never called save-workflow. No workflow was persisted.${otherErrors}\\n\\nSub-agent summary:\\n${summary}`,\n );\n }\n\n // Save was attempted but never returned ok (no tool-result with { ok: true, id }).\n if (!saveSucceeded) {\n const otherErrors = toolErrors.length\n ? `\\n\\nSub-agent tool errors:\\n- ${toolErrors.map(e => `${e.toolName}: ${e.error}`).join('\\n- ')}`\n : '';\n throw new Error(\n `create-workflow failed: save-workflow was called but did not return { ok: true }.${otherErrors}\\n\\nSub-agent summary:\\n${summary}`,\n );\n }\n\n return { summary, workflowId };\n },\n});\n"],"mappings":"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"}
|
|
@@ -17,7 +17,10 @@ async function registerWorkflowBuilderPrimitives(mastra, options) {
|
|
|
17
17
|
basePath: projectPath,
|
|
18
18
|
allowedPaths: [projectPath, ...allowedPaths]
|
|
19
19
|
}),
|
|
20
|
-
sandbox: new LocalSandbox({
|
|
20
|
+
sandbox: new LocalSandbox({
|
|
21
|
+
workingDirectory: projectPath,
|
|
22
|
+
timeout: 3e4
|
|
23
|
+
}),
|
|
21
24
|
tools: createMastraCodeWorkspaceTools()
|
|
22
25
|
});
|
|
23
26
|
const workspaceTools = await createWorkspaceTools(workspace, { workspace });
|
|
@@ -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 * - 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 { createMastraCodeWorkspaceTools } 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: createMastraCodeWorkspaceTools(),\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,
|
|
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 { createMastraCodeWorkspaceTools } 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, timeout: 30_000 }),\n tools: createMastraCodeWorkspaceTools(),\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;GAAE,kBAAkB;GAAa,SAAS;EAAO,CAAC;EAC5E,OAAO,+BAA+B;CACxC,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.15.0-alpha.
|
|
3
|
+
"version": "1.15.0-alpha.2",
|
|
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": {
|
|
@@ -63,19 +63,19 @@
|
|
|
63
63
|
"yaml": "^2.7.1",
|
|
64
64
|
"zod": "^4.6.4",
|
|
65
65
|
"@mastra/agent-browser": "0.5.4-alpha.0",
|
|
66
|
-
"@mastra/
|
|
67
|
-
"@mastra/
|
|
66
|
+
"@mastra/duckdb": "1.15.0-alpha.2",
|
|
67
|
+
"@mastra/core": "1.79.0-alpha.2",
|
|
68
68
|
"@mastra/github-signals": "0.5.2-alpha.0",
|
|
69
|
-
"@mastra/
|
|
69
|
+
"@mastra/libsql": "1.27.0-alpha.2",
|
|
70
|
+
"@mastra/fastembed": "1.3.4-alpha.1",
|
|
70
71
|
"@mastra/mcp": "2.4.2-alpha.0",
|
|
71
72
|
"@mastra/memory": "1.39.0-alpha.0",
|
|
72
|
-
"@mastra/parallel": "0.1.3-alpha.0",
|
|
73
73
|
"@mastra/observability": "1.21.0-alpha.1",
|
|
74
|
-
"@mastra/
|
|
75
|
-
"@mastra/pg": "1.32.0-alpha.
|
|
76
|
-
"@mastra/tavily": "1.1.3-alpha.0",
|
|
74
|
+
"@mastra/parallel": "0.1.3-alpha.0",
|
|
75
|
+
"@mastra/pg": "1.32.0-alpha.2",
|
|
77
76
|
"@mastra/schema-compat": "1.3.16-alpha.0",
|
|
78
|
-
"@mastra/stagehand": "0.3.6-alpha.0"
|
|
77
|
+
"@mastra/stagehand": "0.3.6-alpha.0",
|
|
78
|
+
"@mastra/tavily": "1.1.3-alpha.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@libsql/client": "^0.18.0",
|
|
@@ -86,8 +86,8 @@
|
|
|
86
86
|
"typescript": "^6.0.3",
|
|
87
87
|
"typescript-eslint": "^8.57.0",
|
|
88
88
|
"vitest": "4.1.11",
|
|
89
|
-
"@internal/lint": "0.0.144",
|
|
90
89
|
"@internal/types-builder": "0.0.119",
|
|
90
|
+
"@internal/lint": "0.0.144",
|
|
91
91
|
"@internal/workspace-test-utils": "0.0.88"
|
|
92
92
|
},
|
|
93
93
|
"engines": {
|