@mastra/code-sdk 1.6.1-alpha.1 → 1.7.0-alpha.11

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.
Files changed (49) hide show
  1. package/dist/agents/instructions.d.ts +14 -2
  2. package/dist/agents/instructions.d.ts.map +1 -1
  3. package/dist/agents/instructions.js +12 -4
  4. package/dist/agents/instructions.js.map +1 -1
  5. package/dist/agents/memory.d.ts +15 -4
  6. package/dist/agents/memory.d.ts.map +1 -1
  7. package/dist/agents/memory.js +29 -17
  8. package/dist/agents/memory.js.map +1 -1
  9. package/dist/agents/prompts/index.d.ts +3 -0
  10. package/dist/agents/prompts/index.d.ts.map +1 -1
  11. package/dist/agents/prompts/index.js +9 -0
  12. package/dist/agents/prompts/index.js.map +1 -1
  13. package/dist/agents/prompts/tool-guidance.d.ts +3 -0
  14. package/dist/agents/prompts/tool-guidance.d.ts.map +1 -1
  15. package/dist/agents/prompts/tool-guidance.js +31 -1
  16. package/dist/agents/prompts/tool-guidance.js.map +1 -1
  17. package/dist/agents/subagents/execute.d.ts +3 -0
  18. package/dist/agents/subagents/execute.d.ts.map +1 -0
  19. package/dist/agents/subagents/execute.js +27 -0
  20. package/dist/agents/subagents/execute.js.map +1 -0
  21. package/dist/agents/subagents/explore.d.ts +3 -0
  22. package/dist/agents/subagents/explore.d.ts.map +1 -0
  23. package/dist/agents/subagents/explore.js +18 -0
  24. package/dist/agents/subagents/explore.js.map +1 -0
  25. package/dist/agents/subagents/plan.d.ts +3 -0
  26. package/dist/agents/subagents/plan.d.ts.map +1 -0
  27. package/dist/agents/subagents/plan.js +18 -0
  28. package/dist/agents/subagents/plan.js.map +1 -0
  29. package/dist/index.d.ts +6 -1
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +36 -5
  32. package/dist/index.js.map +1 -1
  33. package/dist/knowledge-inspector.d.ts.map +1 -1
  34. package/dist/knowledge-inspector.js +16 -9
  35. package/dist/knowledge-inspector.js.map +1 -1
  36. package/dist/knowledge-scope.d.ts +35 -0
  37. package/dist/knowledge-scope.d.ts.map +1 -0
  38. package/dist/knowledge-scope.js +47 -0
  39. package/dist/knowledge-scope.js.map +1 -0
  40. package/dist/providers/amazon-bedrock-gateway.d.ts.map +1 -1
  41. package/dist/providers/amazon-bedrock-gateway.js +1 -0
  42. package/dist/providers/amazon-bedrock-gateway.js.map +1 -1
  43. package/dist/providers/amazon-bedrock.d.ts.map +1 -1
  44. package/dist/providers/amazon-bedrock.js +20 -1
  45. package/dist/providers/amazon-bedrock.js.map +1 -1
  46. package/dist/utils/slash-command-processor.d.ts.map +1 -1
  47. package/dist/utils/slash-command-processor.js +7 -3
  48. package/dist/utils/slash-command-processor.js.map +1 -1
  49. package/package.json +11 -11
@@ -0,0 +1 @@
1
+ {"version":3,"file":"explore.d.ts","sourceRoot":"","sources":["../../../src/agents/subagents/explore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAG7E,eAAO,MAAM,eAAe,EAAE,uBAM7B,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { MC_TOOLS } from "../../tool-names.js";
2
+ //#region src/agents/subagents/explore.ts
3
+ const exploreSubagent = {
4
+ id: "explore",
5
+ name: "Explore",
6
+ description: "Explore the codebase and answer focused questions without modifying files.",
7
+ instructions: `You are a read-only codebase exploration agent. Read relevant files before drawing conclusions. Use view, find_files, search_content, and file_stat to investigate. Do not modify files or run shell commands. Return concise findings with file paths and line numbers, and clearly distinguish verified facts from assumptions.`,
8
+ allowedWorkspaceTools: [
9
+ MC_TOOLS.VIEW,
10
+ MC_TOOLS.FIND_FILES,
11
+ MC_TOOLS.SEARCH_CONTENT,
12
+ MC_TOOLS.FILE_STAT
13
+ ]
14
+ };
15
+ //#endregion
16
+ export { exploreSubagent };
17
+
18
+ //# sourceMappingURL=explore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"explore.js","names":[],"sources":["../../../src/agents/subagents/explore.ts"],"sourcesContent":["import type { AgentControllerSubagent } from '@mastra/core/agent-controller';\nimport { MC_TOOLS } from '../../tool-names.js';\n\nexport const exploreSubagent: AgentControllerSubagent = {\n id: 'explore',\n name: 'Explore',\n description: 'Explore the codebase and answer focused questions without modifying files.',\n instructions: `You are a read-only codebase exploration agent. Read relevant files before drawing conclusions. Use view, find_files, search_content, and file_stat to investigate. Do not modify files or run shell commands. Return concise findings with file paths and line numbers, and clearly distinguish verified facts from assumptions.`,\n allowedWorkspaceTools: [MC_TOOLS.VIEW, MC_TOOLS.FIND_FILES, MC_TOOLS.SEARCH_CONTENT, MC_TOOLS.FILE_STAT],\n};\n"],"mappings":";;AAGA,MAAa,kBAA2C;CACtD,IAAI;CACJ,MAAM;CACN,aAAa;CACb,cAAc;CACd,uBAAuB;EAAC,SAAS;EAAM,SAAS;EAAY,SAAS;EAAgB,SAAS;CAAS;AACzG"}
@@ -0,0 +1,3 @@
1
+ import type { AgentControllerSubagent } from '@mastra/core/agent-controller';
2
+ export declare const planSubagent: AgentControllerSubagent;
3
+ //# sourceMappingURL=plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../src/agents/subagents/plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAG7E,eAAO,MAAM,YAAY,EAAE,uBAM1B,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { MC_TOOLS } from "../../tool-names.js";
2
+ //#region src/agents/subagents/plan.ts
3
+ const planSubagent = {
4
+ id: "plan",
5
+ name: "Plan",
6
+ description: "Investigate a task and propose an implementation plan without modifying files.",
7
+ instructions: `You are a read-only planning agent. Inspect the relevant code using view, find_files, search_content, and file_stat before proposing changes. Do not modify files or run shell commands. Return a concise implementation plan with file paths, ordered steps, risks, and concrete verification criteria. State assumptions and unresolved questions.`,
8
+ allowedWorkspaceTools: [
9
+ MC_TOOLS.VIEW,
10
+ MC_TOOLS.FIND_FILES,
11
+ MC_TOOLS.SEARCH_CONTENT,
12
+ MC_TOOLS.FILE_STAT
13
+ ]
14
+ };
15
+ //#endregion
16
+ export { planSubagent };
17
+
18
+ //# sourceMappingURL=plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.js","names":[],"sources":["../../../src/agents/subagents/plan.ts"],"sourcesContent":["import type { AgentControllerSubagent } from '@mastra/core/agent-controller';\nimport { MC_TOOLS } from '../../tool-names.js';\n\nexport const planSubagent: AgentControllerSubagent = {\n id: 'plan',\n name: 'Plan',\n description: 'Investigate a task and propose an implementation plan without modifying files.',\n instructions: `You are a read-only planning agent. Inspect the relevant code using view, find_files, search_content, and file_stat before proposing changes. Do not modify files or run shell commands. Return a concise implementation plan with file paths, ordered steps, risks, and concrete verification criteria. State assumptions and unresolved questions.`,\n allowedWorkspaceTools: [MC_TOOLS.VIEW, MC_TOOLS.FIND_FILES, MC_TOOLS.SEARCH_CONTENT, MC_TOOLS.FILE_STAT],\n};\n"],"mappings":";;AAGA,MAAa,eAAwC;CACnD,IAAI;CACJ,MAAM;CACN,aAAa;CACb,cAAc;CACd,uBAAuB;EAAC,SAAS;EAAM,SAAS;EAAY,SAAS;EAAgB,SAAS;CAAS;AACzG"}
package/dist/index.d.ts CHANGED
@@ -26,7 +26,7 @@ export interface MastraCodeConfig {
26
26
  homeDir?: string;
27
27
  /** Override modes (model IDs, colors, which modes exist). Default: build/plan/fast */
28
28
  modes?: AgentControllerMode[];
29
- /** Override or extend subagent definitions. Default: explore/plan/execute */
29
+ /** Replace subagent definitions. Default: explore/plan/execute. An empty array disables subagents. */
30
30
  subagents?: AgentControllerSubagent[];
31
31
  /** Extra tools merged into the dynamic tool set. Can be a static record or a (sync or async) function that receives requestContext. */
32
32
  extraTools?: Record<string, ToolLike | undefined> | ((ctx: {
@@ -57,6 +57,10 @@ export interface MastraCodeConfig {
57
57
  settingsPath?: string;
58
58
  /** Initial state overrides (yolo, thinkingLevel, etc.) */
59
59
  initialState?: Partial<MastraCodeState>;
60
+ /** Trusted host instructions resolved outside mutable session state. */
61
+ hostInstructions?: string | ((ctx: {
62
+ requestContext: RequestContext;
63
+ }) => string | undefined | Promise<string | undefined>);
60
64
  /** Override id generation for threads/messages. Primarily useful for deterministic tests. */
61
65
  idGenerator?: AgentControllerConfig<MastraCodeState>['idGenerator'];
62
66
  /** Override interval handlers. Default: gateway-sync */
@@ -326,6 +330,7 @@ export declare function prepareAgentControllerMount(config?: MastraCodeConfig &
326
330
  */
327
331
  export declare const createMastraCode: typeof bootLocalAgentController;
328
332
  export * from './knowledge-inspector.js';
333
+ export { LOCAL_KNOWLEDGE_ORG_ID } from './knowledge-scope.js';
329
334
  /**
330
335
  * Programmatic headless API. `runMC` runs an already-built controller/session
331
336
  * (from {@link createMastraCode}) as an async-iterable run that also resolves to
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EAErB,mBAAmB,EACnB,uBAAuB,EAEvB,OAAO,EACR,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAS7C,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAmB,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,EAAE,a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AAY,CAAC,CAAC;QAC5C,WAAW,EAAE,WAAW,CAAC;KAC1B,KAAK,IAAI,CAAC,WAAW,CAAC,qBAAqB,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAC;CACzF,GACA,OAAO,CAAC;IACT,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,+BAA+B,CAAC,CAAC,CAAC;IAClE,UAAU,EAAE,WAAW,CAAC,qBAAqB,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjE,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B,CAAC,CA0CD;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,iCAA2B,CAAC;AACzD,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D;;;;GAIG;AACH,OAAO,EACL,KAAK,EACL,QAAQ,EACR,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,aAAa,EACb,eAAe,EACf,UAAU,EACV,kBAAkB,EAClB,KAAK,EACL,gBAAgB,EAChB,cAAc,GACf,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -8,16 +8,20 @@ import { hasCredentialStoreProvider } from "./agents/credential-resolver.js";
8
8
  import { getDynamicWorkspace, getGoalJudgeTools } from "./agents/workspace.js";
9
9
  import { createGitRefInstructionReader, createGitRefReminderReader, getStaticallyLoadedInstructionPaths } from "./agents/prompts/agent-instructions.js";
10
10
  import { getDynamicInstructions } from "./agents/instructions.js";
11
+ import { LOCAL_KNOWLEDGE_ORG_ID } from "./knowledge-scope.js";
11
12
  import { createAmazonBedrockGateway } from "./providers/amazon-bedrock-gateway.js";
12
13
  import { setAuthStorage as setAuthStorage$1 } from "./providers/claude-max.js";
13
14
  import { setAuthStorage as setAuthStorage$2 } from "./providers/github-copilot.js";
14
15
  import { setAuthStorage as setAuthStorage$3 } from "./providers/kimi-coding.js";
15
16
  import { setAuthStorage as setAuthStorage$4 } from "./providers/xai.js";
16
17
  import { createMastraCodeGateway, getDynamicModel, getGoalJudgeModel, resolveModel } from "./agents/model.js";
17
- import { getDynamicMemory } from "./agents/memory.js";
18
+ import { getDynamicMemory, hasSubconsciousTools } from "./agents/memory.js";
18
19
  import { buildMode } from "./agents/modes/build.js";
19
20
  import { fastMode } from "./agents/modes/explore.js";
20
21
  import { planMode } from "./agents/modes/plan.js";
22
+ import { executeSubagent } from "./agents/subagents/execute.js";
23
+ import { exploreSubagent } from "./agents/subagents/explore.js";
24
+ import { planSubagent } from "./agents/subagents/plan.js";
21
25
  import { attachOMThreadStatePersistence, restoreOMThreadStateForCurrentThread } from "./agents/thread-caveman-state.js";
22
26
  import { createDynamicTools, createToolHooks } from "./agents/tools.js";
23
27
  import { createOutcomeScorer } from "./evals/scorers/outcome.js";
@@ -321,6 +325,7 @@ async function createMastraCodeAgentController(config) {
321
325
  closeVector: vector instanceof LibSQLVector ? () => vector.close() : void 0
322
326
  });
323
327
  const memory = config?.memory === false ? void 0 : config?.memory ?? getDynamicMemory(storage, vector);
328
+ const hasSubconscious = config?.memory === void 0 ? (state) => hasSubconsciousTools(vector, state) : false;
324
329
  const mcpManager = config?.disableMcp ? void 0 : createMcpManager(project.rootPath, configDir, config?.mcpServers, globalSettings.mcp);
325
330
  const hookManager = config?.disableHooks ? void 0 : new HookManager(project.rootPath, "session-init", configDir, homeDir, project.isWorktree ? {
326
331
  path: project.rootPath,
@@ -439,7 +444,15 @@ async function createMastraCodeAgentController(config) {
439
444
  id: CODE_AGENT_ID,
440
445
  name: "Code Agent",
441
446
  workspace: void 0,
442
- instructions: getDynamicInstructions,
447
+ instructions: async ({ requestContext }) => {
448
+ const configured = config?.hostInstructions;
449
+ return getDynamicInstructions({
450
+ requestContext,
451
+ hostInstructions: typeof configured === "function" ? await configured({ requestContext }) : configured,
452
+ hasSubconscious,
453
+ hasSubagents: subagents.length > 0
454
+ });
455
+ },
443
456
  model: (ctx) => getDynamicModel(ctx, config?.settingsPath),
444
457
  notifications: { deliveryPolicy: { decide: async (input) => {
445
458
  const decision = defaultNotificationDeliveryDecision(input);
@@ -573,7 +586,25 @@ async function createMastraCodeAgentController(config) {
573
586
  const effectiveCavemanObservations = globalSettings.models.omCavemanObservations ?? void 0;
574
587
  const effectiveObserveAttachments = globalSettings.models.omObserveAttachments ?? "auto";
575
588
  const modes = addPluginToolsToModeAllowlists(applyEffectiveDefaultsToModes(config?.modes ? config.modes : defaultModes, effectiveDefaults), Object.keys(pluginTools));
576
- if (!(modes.find((mode) => mode.metadata?.default === true)?.id ?? modes.find((mode) => mode.id === "build")?.id ?? modes[0]?.id)) throw new Error("MastraCode requires at least one mode");
589
+ const defaultModeId = modes.find((mode) => mode.metadata?.default === true)?.id ?? modes.find((mode) => mode.id === "build")?.id ?? modes[0]?.id;
590
+ if (!defaultModeId) throw new Error("MastraCode requires at least one mode");
591
+ const subagentModeMap = {
592
+ explore: "fast",
593
+ plan: "plan",
594
+ execute: "build"
595
+ };
596
+ const disabledTools = new Set(config?.disabledTools);
597
+ const subagents = (config?.subagents ?? [
598
+ exploreSubagent,
599
+ planSubagent,
600
+ executeSubagent
601
+ ]).map((definition) => ({
602
+ ...definition,
603
+ ...config?.subagents == null && { defaultModelId: modes.find((mode) => mode.id === subagentModeMap[definition.id])?.defaultModelId ?? modes.find((mode) => mode.id === defaultModeId)?.defaultModelId },
604
+ allowedControllerTools: definition.allowedControllerTools?.filter((name) => !disabledTools.has(name)),
605
+ allowedWorkspaceTools: definition.allowedWorkspaceTools?.filter((name) => !disabledTools.has(name)),
606
+ ...definition.tools && { tools: Object.fromEntries(Object.entries(definition.tools).filter(([name]) => !disabledTools.has(name))) }
607
+ }));
577
608
  const globalInitialState = {};
578
609
  if (!config?.disableSettingsOmSeed) {
579
610
  if (effectiveObserverModel) globalInitialState.observerModelId = effectiveObserverModel;
@@ -597,7 +628,7 @@ async function createMastraCodeAgentController(config) {
597
628
  pubsub: signalsPubSub,
598
629
  stateSchema: typedStateSchema,
599
630
  agent: codeAgent,
600
- subagents: config?.subagents ?? [],
631
+ subagents,
601
632
  gateways: [amazonBedrockGateway, mastraCodeGateway],
602
633
  workspace: config?.workspace ?? ((args) => getDynamicWorkspace(args)),
603
634
  browser: config?.browser,
@@ -883,6 +914,6 @@ async function prepareAgentControllerMount(config) {
883
914
  */
884
915
  const createMastraCode = bootLocalAgentController;
885
916
  //#endregion
886
- export { KnowledgeInspectorError, autoApprovePolicy, bootLocalAgentController, createAuthStorage, createKnowledgeInspector, createMastraCode, createMastraCodeAgentController, denyPolicy, formatHuman, formatJsonl, hasHeadlessFlag, mountAgentControllerOnMastra, permissionModeToPolicy, prepareAgentControllerMount, renderJsonResult, renderTextResult, runMC, runMCCli, wireSessionConcerns };
917
+ export { KnowledgeInspectorError, LOCAL_KNOWLEDGE_ORG_ID, autoApprovePolicy, bootLocalAgentController, createAuthStorage, createKnowledgeInspector, createMastraCode, createMastraCodeAgentController, denyPolicy, formatHuman, formatJsonl, hasHeadlessFlag, mountAgentControllerOnMastra, permissionModeToPolicy, prepareAgentControllerMount, renderJsonResult, renderTextResult, runMC, runMCCli, wireSessionConcerns };
887
918
 
888
919
  //# sourceMappingURL=index.js.map