@mastra/code-sdk 1.19.0-alpha.1 → 1.19.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.
- package/dist/acp/runtime.d.ts.map +1 -1
- package/dist/acp/runtime.js +1 -0
- package/dist/acp/runtime.js.map +1 -1
- package/dist/agent-connections/tools.d.ts.map +1 -1
- package/dist/agent-connections/tools.js +67 -2
- package/dist/agent-connections/tools.js.map +1 -1
- package/dist/agents/fastembed-subprocess.d.ts +31 -0
- package/dist/agents/fastembed-subprocess.d.ts.map +1 -0
- package/dist/agents/fastembed-subprocess.js +202 -0
- package/dist/agents/fastembed-subprocess.js.map +1 -0
- package/dist/agents/instructions.d.ts +5 -2
- package/dist/agents/instructions.d.ts.map +1 -1
- package/dist/agents/instructions.js +6 -4
- package/dist/agents/instructions.js.map +1 -1
- package/dist/agents/mastracode-gateway.d.ts.map +1 -1
- package/dist/agents/mastracode-gateway.js +2 -2
- package/dist/agents/mastracode-gateway.js.map +1 -1
- package/dist/agents/memory.d.ts.map +1 -1
- package/dist/agents/memory.js +4 -6
- package/dist/agents/memory.js.map +1 -1
- package/dist/agents/model.d.ts.map +1 -1
- package/dist/agents/model.js +10 -5
- package/dist/agents/model.js.map +1 -1
- package/dist/agents/modes/build.js +1 -1
- package/dist/agents/modes/build.js.map +1 -1
- package/dist/agents/modes/plan.js +1 -1
- package/dist/agents/modes/plan.js.map +1 -1
- package/dist/agents/prompts/agent-instructions.d.ts +24 -1
- package/dist/agents/prompts/agent-instructions.d.ts.map +1 -1
- package/dist/agents/prompts/agent-instructions.js +386 -41
- package/dist/agents/prompts/agent-instructions.js.map +1 -1
- package/dist/agents/prompts/index.d.ts +3 -1
- package/dist/agents/prompts/index.d.ts.map +1 -1
- package/dist/agents/prompts/index.js +16 -5
- package/dist/agents/prompts/index.js.map +1 -1
- package/dist/agents/prompts/plan.d.ts +2 -0
- package/dist/agents/prompts/plan.d.ts.map +1 -1
- package/dist/agents/prompts/plan.js +10 -8
- package/dist/agents/prompts/plan.js.map +1 -1
- package/dist/agents/sandbox-filesystem.d.ts +25 -0
- package/dist/agents/sandbox-filesystem.d.ts.map +1 -1
- package/dist/agents/sandbox-filesystem.js +47 -6
- package/dist/agents/sandbox-filesystem.js.map +1 -1
- package/dist/auth/account-rotation-processor.d.ts +23 -0
- package/dist/auth/account-rotation-processor.d.ts.map +1 -1
- package/dist/auth/account-rotation-processor.js +63 -1
- package/dist/auth/account-rotation-processor.js.map +1 -1
- package/dist/auth/index.js +2 -2
- package/dist/auth/storage.d.ts +8 -0
- package/dist/auth/storage.d.ts.map +1 -1
- package/dist/auth/storage.js +37 -3
- package/dist/auth/storage.js.map +1 -1
- package/dist/experimental-agent.d.ts +8 -0
- package/dist/experimental-agent.d.ts.map +1 -1
- package/dist/experimental-agent.js +12 -1
- package/dist/experimental-agent.js.map +1 -1
- package/dist/headless/cli.d.ts.map +1 -1
- package/dist/headless/cli.js +2 -1
- package/dist/headless/cli.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -9
- package/dist/index.js.map +1 -1
- package/dist/onboarding/settings.d.ts +4 -0
- package/dist/onboarding/settings.d.ts.map +1 -1
- package/dist/onboarding/settings.js +6 -2
- package/dist/onboarding/settings.js.map +1 -1
- package/dist/schedules/scheduler.d.ts.map +1 -1
- package/dist/schedules/scheduler.js +3 -2
- package/dist/schedules/scheduler.js.map +1 -1
- package/dist/utils/token-estimator.d.ts.map +1 -1
- package/dist/utils/token-estimator.js +2 -1
- package/dist/utils/token-estimator.js.map +1 -1
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -9,17 +9,17 @@ import { canUseProvider, createMastraCodeGateway, getDynamicModel, getGoalJudgeM
|
|
|
9
9
|
import { buildMode } from "./agents/modes/build.js";
|
|
10
10
|
import { fastMode } from "./agents/modes/explore.js";
|
|
11
11
|
import { createPlanMode } from "./agents/modes/plan.js";
|
|
12
|
-
import { createGitRefReminderReader, instructionSourcePaths, loadSessionInstructions, sessionInstructionRoots } from "./agents/prompts/agent-instructions.js";
|
|
12
|
+
import { createGitRefReminderReader, createGitRefReminderReaderAsync, instructionSourcePaths, loadSessionInstructions, loadSessionInstructionsAsync, sessionInstructionRoots } from "./agents/prompts/agent-instructions.js";
|
|
13
13
|
import { builtinSubagents, resolveSubagentsSetting } from "./agents/subagents/index.js";
|
|
14
14
|
import { attachOMThreadStatePersistence, restoreOMThreadStateForCurrentThread } from "./agents/thread-caveman-state.js";
|
|
15
15
|
import { createDynamicTools, createToolHooks } from "./agents/tools.js";
|
|
16
16
|
import { getDynamicWorkspace, getGoalJudgeTools } from "./agents/workspace.js";
|
|
17
|
-
import { AccountRotationProcessor, AccountStartNoticeProcessor, MODEL_FALLBACK_STATE_KEY } from "./auth/account-rotation-processor.js";
|
|
17
|
+
import { AccountRotationProcessor, AccountStartNoticeProcessor, MODEL_FALLBACK_STATE_KEY, isStreamCutAfterResponse } from "./auth/account-rotation-processor.js";
|
|
18
18
|
import { isKimiCodingDeviceId } from "./auth/providers/kimi-coding.js";
|
|
19
19
|
import { AuthStorage } from "./auth/storage.js";
|
|
20
20
|
import { CODE_AGENT_ID, DEFAULT_OM_MODEL_ID, validateConfigDirName } from "./constants.js";
|
|
21
21
|
import "./evals/scorers/index.js";
|
|
22
|
-
import { resolveExperimentalAgent, validateExperimentalAgent, wrapExperimentalAgent } from "./experimental-agent.js";
|
|
22
|
+
import { resolveAgentStreamsOff, resolveExperimentalAgent, validateExperimentalAgent, wrapExperimentalAgent } from "./experimental-agent.js";
|
|
23
23
|
import "./hooks/index.js";
|
|
24
24
|
import { KnowledgeInspectorError, createKnowledgeInspector } from "./knowledge-inspector.js";
|
|
25
25
|
import { LOCAL_KNOWLEDGE_ORG_ID, knowledgeUnresolvedScopes, resolveKnowledgeSessionScopes } from "./knowledge-scope.js";
|
|
@@ -257,10 +257,11 @@ async function createMastraCodeAgentController(config) {
|
|
|
257
257
|
const authStorage = createAuthStorage();
|
|
258
258
|
const globalSettings = loadSettings(config?.settingsPath);
|
|
259
259
|
const experimentalAgent = resolveExperimentalAgent(globalSettings);
|
|
260
|
+
const agentStreamsOff = resolveAgentStreamsOff();
|
|
260
261
|
const backgroundToolsEnabled = globalSettings.backgroundTools?.enabled ?? false;
|
|
261
262
|
const storedGatewayKey = authStorage.getStoredApiKey(MASTRA_GATEWAY_PROVIDER);
|
|
262
263
|
const storedGatewayUrl = globalSettings.memoryGateway?.baseUrl;
|
|
263
|
-
if (storedGatewayKey)
|
|
264
|
+
if (storedGatewayKey) authStorage.loadStoredApiKeysIntoEnv({ [MASTRA_GATEWAY_PROVIDER]: "MASTRA_GATEWAY_API_KEY" });
|
|
264
265
|
if (storedGatewayUrl) process.env["MASTRA_GATEWAY_URL"] ??= storedGatewayUrl;
|
|
265
266
|
if (!hasCredentialStoreProvider()) try {
|
|
266
267
|
const registry = PROVIDER_REGISTRY;
|
|
@@ -631,7 +632,7 @@ async function createMastraCodeAgentController(config) {
|
|
|
631
632
|
if (state?.untrustedCheckout !== true || typeof state?.baseRef !== "string") return void 0;
|
|
632
633
|
const projectPath = state?.projectPath ?? project.rootPath;
|
|
633
634
|
const [primary] = sessionInstructionRoots(projectPath, state.instructionRoots);
|
|
634
|
-
const reader = createGitRefReminderReader(primary, state.baseRef);
|
|
635
|
+
const reader = "supportsAsyncInstructionReaders" in AgentsMDInjector ? createGitRefReminderReaderAsync(primary, state.baseRef) : createGitRefReminderReader(primary, state.baseRef);
|
|
635
636
|
if (primary === projectPath) return reader;
|
|
636
637
|
const outsidePrimary = (filePath) => {
|
|
637
638
|
const inProject = path.relative(projectPath, filePath);
|
|
@@ -642,7 +643,11 @@ async function createMastraCodeAgentController(config) {
|
|
|
642
643
|
return {
|
|
643
644
|
...reader,
|
|
644
645
|
pathExists: (filePath) => !outsidePrimary(filePath) && reader.pathExists(filePath),
|
|
645
|
-
isDirectory: (filePath) => !outsidePrimary(filePath) && reader.isDirectory(filePath)
|
|
646
|
+
isDirectory: (filePath) => !outsidePrimary(filePath) && reader.isDirectory(filePath),
|
|
647
|
+
readFile: (filePath) => {
|
|
648
|
+
if (outsidePrimary(filePath)) throw new Error(`Not found at ref ${state.baseRef}: ${filePath}`);
|
|
649
|
+
return reader.readFile(filePath);
|
|
650
|
+
}
|
|
646
651
|
};
|
|
647
652
|
},
|
|
648
653
|
getIgnoredInstructionPaths: ({ requestContext }) => {
|
|
@@ -650,13 +655,14 @@ async function createMastraCodeAgentController(config) {
|
|
|
650
655
|
const projectPath = state?.projectPath ?? project.rootPath;
|
|
651
656
|
const untrusted = state?.untrustedCheckout === true && typeof state?.baseRef === "string";
|
|
652
657
|
const roots = sessionInstructionRoots(projectPath, state?.instructionRoots);
|
|
653
|
-
const
|
|
658
|
+
const options = {
|
|
654
659
|
workingDir: projectPath,
|
|
655
660
|
instructionRoots: state?.instructionRoots,
|
|
656
661
|
untrustedCheckout: untrusted,
|
|
657
662
|
baseRef: untrusted ? state?.baseRef : void 0
|
|
658
|
-
}
|
|
659
|
-
return instructionSourcePaths(
|
|
663
|
+
};
|
|
664
|
+
if (!("supportsAsyncInstructionReaders" in AgentsMDInjector)) return instructionSourcePaths(loadSessionInstructions(options), roots);
|
|
665
|
+
return loadSessionInstructionsAsync(options).then((sources) => instructionSourcePaths(sources, roots));
|
|
660
666
|
}
|
|
661
667
|
})
|
|
662
668
|
];
|
|
@@ -709,6 +715,7 @@ async function createMastraCodeAgentController(config) {
|
|
|
709
715
|
const baseCodeAgent = createCodingAgent({
|
|
710
716
|
id: CODE_AGENT_ID,
|
|
711
717
|
name: "Code Agent",
|
|
718
|
+
...agentStreamsOff ? { durable: false } : {},
|
|
712
719
|
workspace: void 0,
|
|
713
720
|
...knowledge ? {
|
|
714
721
|
knowledge,
|
|
@@ -727,6 +734,7 @@ async function createMastraCodeAgentController(config) {
|
|
|
727
734
|
coAuthor: config?.coAuthor,
|
|
728
735
|
hasSubagents: subagents.length > 0,
|
|
729
736
|
disabledBuiltinTools: config?.disableBuiltinTools,
|
|
737
|
+
planApprovalStartsGoal: config?.planApprovalStartsGoal,
|
|
730
738
|
plansDir: config?.plansDir,
|
|
731
739
|
disabledTools: config?.disabledTools
|
|
732
740
|
});
|
|
@@ -828,6 +836,10 @@ async function createMastraCodeAgentController(config) {
|
|
|
828
836
|
new ProviderHistoryCompat(),
|
|
829
837
|
new CyberRefusalHandler(),
|
|
830
838
|
new StreamErrorRetryProcessor({ matchers: [
|
|
839
|
+
{
|
|
840
|
+
match: isStreamCutAfterResponse,
|
|
841
|
+
maxRetries: 0
|
|
842
|
+
},
|
|
831
843
|
{
|
|
832
844
|
match: isBadRequestError,
|
|
833
845
|
maxRetries: 1,
|