mastracode 0.22.2 → 0.22.3-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/HarnessCompat.d.ts +21 -2
- package/dist/HarnessCompat.d.ts.map +1 -1
- package/dist/{chunk-NFF7IH5X.cjs → chunk-A4W5D25I.cjs} +2 -1096
- package/dist/chunk-A4W5D25I.cjs.map +1 -0
- package/dist/{chunk-7ARENXCP.js → chunk-CLB7WNWJ.js} +5 -6
- package/dist/{chunk-7ARENXCP.js.map → chunk-CLB7WNWJ.js.map} +1 -1
- package/dist/{chunk-BOZ3JCCI.cjs → chunk-LGR7SHQ7.cjs} +928 -929
- package/dist/chunk-LGR7SHQ7.cjs.map +1 -0
- package/dist/{chunk-DPPFZEZI.cjs → chunk-TU3VBXJJ.cjs} +170 -297
- package/dist/chunk-TU3VBXJJ.cjs.map +1 -0
- package/dist/{chunk-EXBGEHMR.js → chunk-TWAOLBVC.js} +3 -1094
- package/dist/chunk-TWAOLBVC.js.map +1 -0
- package/dist/{chunk-AB4G5527.js → chunk-XHOQR364.js} +140 -267
- package/dist/chunk-XHOQR364.js.map +1 -0
- package/dist/cli.cjs +18 -18
- package/dist/cli.js +3 -3
- package/dist/harness-tui-v1.d.ts +2 -0
- package/dist/harness-tui-v1.d.ts.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/schema.d.ts +11 -4
- package/dist/schema.d.ts.map +1 -1
- package/dist/tui/state.d.ts +1 -1
- package/dist/tui/state.d.ts.map +1 -1
- package/dist/tui.cjs +19 -19
- package/dist/tui.js +2 -2
- package/package.json +14 -12
- package/dist/chunk-AB4G5527.js.map +0 -1
- package/dist/chunk-BOZ3JCCI.cjs.map +0 -1
- package/dist/chunk-DPPFZEZI.cjs.map +0 -1
- package/dist/chunk-EXBGEHMR.js.map +0 -1
- package/dist/chunk-NFF7IH5X.cjs.map +0 -1
- package/dist/github-signals/index.d.ts +0 -217
- package/dist/github-signals/index.d.ts.map +0 -1
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkA4W5D25I_cjs = require('./chunk-A4W5D25I.cjs');
|
|
4
4
|
var chunkJ3ISOP5J_cjs = require('./chunk-J3ISOP5J.cjs');
|
|
5
5
|
var chunkJHYTJMKT_cjs = require('./chunk-JHYTJMKT.cjs');
|
|
6
6
|
var crypto = require('crypto');
|
|
7
7
|
var os = require('os');
|
|
8
8
|
var path = require('path');
|
|
9
9
|
var agent = require('@mastra/core/agent');
|
|
10
|
-
var
|
|
10
|
+
var harness = require('@mastra/core/harness');
|
|
11
11
|
var llm = require('@mastra/core/llm');
|
|
12
12
|
var processors = require('@mastra/core/processors');
|
|
13
13
|
var requestContext = require('@mastra/core/request-context');
|
|
14
14
|
var storage = require('@mastra/core/storage');
|
|
15
15
|
var duckdb = require('@mastra/duckdb');
|
|
16
|
+
var githubSignals = require('@mastra/github-signals');
|
|
16
17
|
var observability = require('@mastra/observability');
|
|
17
18
|
var child_process = require('child_process');
|
|
18
19
|
var tools = require('@mastra/core/tools');
|
|
@@ -28,7 +29,6 @@ var anthropic = require('@ai-sdk/anthropic');
|
|
|
28
29
|
var openai = require('@ai-sdk/openai');
|
|
29
30
|
var notifications = require('@mastra/core/notifications');
|
|
30
31
|
var evals = require('@mastra/core/evals');
|
|
31
|
-
var harness = require('@mastra/core/harness');
|
|
32
32
|
var mcp = require('@mastra/mcp');
|
|
33
33
|
var promises = require('fs/promises');
|
|
34
34
|
var events = require('@mastra/core/events');
|
|
@@ -602,8 +602,8 @@ function getDynamicWorkspace({ requestContext, mastra: mastra2 }) {
|
|
|
602
602
|
existing.setToolsConfig(isPlanMode ? { ...chunkJHYTJMKT_cjs.TOOL_NAME_OVERRIDES, ...planModeTools } : chunkJHYTJMKT_cjs.TOOL_NAME_OVERRIDES);
|
|
603
603
|
return existing;
|
|
604
604
|
}
|
|
605
|
-
const userLsp =
|
|
606
|
-
const mcModulePath = path.join(path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
605
|
+
const userLsp = chunkA4W5D25I_cjs.loadSettings().lsp ?? {};
|
|
606
|
+
const mcModulePath = path.join(path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-TU3VBXJJ.cjs', document.baseURI).href)))), "..");
|
|
607
607
|
const lspConfig = {
|
|
608
608
|
...userLsp,
|
|
609
609
|
packageRunner: userLsp.packageRunner || detectPackageRunner(projectPath),
|
|
@@ -1052,7 +1052,7 @@ ${lines.join("\n")}
|
|
|
1052
1052
|
// src/agents/instructions.ts
|
|
1053
1053
|
async function getDynamicInstructions({ requestContext }) {
|
|
1054
1054
|
const harnessContext = requestContext.get("harness");
|
|
1055
|
-
const state = harnessContext?.
|
|
1055
|
+
const state = harnessContext?.getState?.();
|
|
1056
1056
|
const modeId = harnessContext?.modeId ?? "build";
|
|
1057
1057
|
const projectPath = state?.projectPath ?? process.cwd();
|
|
1058
1058
|
const promptCtx = {
|
|
@@ -1079,14 +1079,14 @@ function getHarnessState(requestContext) {
|
|
|
1079
1079
|
}
|
|
1080
1080
|
function getObserverModel({ requestContext }) {
|
|
1081
1081
|
const state = getHarnessState(requestContext);
|
|
1082
|
-
return
|
|
1082
|
+
return chunkA4W5D25I_cjs.resolveModel(state?.observerModelId ?? chunkJ3ISOP5J_cjs.DEFAULT_OM_MODEL_ID, {
|
|
1083
1083
|
remapForCodexOAuth: true,
|
|
1084
1084
|
requestContext
|
|
1085
1085
|
});
|
|
1086
1086
|
}
|
|
1087
1087
|
function getReflectorModel({ requestContext }) {
|
|
1088
1088
|
const state = getHarnessState(requestContext);
|
|
1089
|
-
return
|
|
1089
|
+
return chunkA4W5D25I_cjs.resolveModel(state?.reflectorModelId ?? chunkJ3ISOP5J_cjs.DEFAULT_OM_MODEL_ID, {
|
|
1090
1090
|
remapForCodexOAuth: true,
|
|
1091
1091
|
requestContext
|
|
1092
1092
|
});
|
|
@@ -1402,7 +1402,7 @@ function wrapToolWithHooks(toolName, tool, hookManager) {
|
|
|
1402
1402
|
function createDynamicTools(mcpManager, extraTools, hookManager, disabledTools, storage) {
|
|
1403
1403
|
return function getDynamicTools({ requestContext }) {
|
|
1404
1404
|
const ctx = requestContext.get("harness");
|
|
1405
|
-
const state = ctx?.getState();
|
|
1405
|
+
const state = ctx?.getState?.();
|
|
1406
1406
|
const modelId = state?.currentModelId;
|
|
1407
1407
|
const isAnthropicModel = modelId?.startsWith("anthropic/");
|
|
1408
1408
|
const isOpenAIModel = modelId?.startsWith("openai/");
|
|
@@ -1976,122 +1976,6 @@ function v1ModeToLegacy(mode, agent) {
|
|
|
1976
1976
|
agent
|
|
1977
1977
|
};
|
|
1978
1978
|
}
|
|
1979
|
-
var HarnessCompat = class extends harness.Harness {
|
|
1980
|
-
#session;
|
|
1981
|
-
#harnessV1;
|
|
1982
|
-
constructor(args, harnessV1) {
|
|
1983
|
-
super(args);
|
|
1984
|
-
this.#harnessV1 = harnessV1;
|
|
1985
|
-
}
|
|
1986
|
-
async switchThread({ threadId }) {
|
|
1987
|
-
const modes = this.listModes();
|
|
1988
|
-
this.#session = await this.#harnessV1.session({
|
|
1989
|
-
threadId,
|
|
1990
|
-
resourceId: this.getResourceId()
|
|
1991
|
-
});
|
|
1992
|
-
const defaultModelId = modes.find((mode) => mode.id === this.#session.getMode().id)?.defaultModelId;
|
|
1993
|
-
if (defaultModelId) {
|
|
1994
|
-
this.#session.setModelId(defaultModelId);
|
|
1995
|
-
}
|
|
1996
|
-
await super.switchThread({ threadId });
|
|
1997
|
-
}
|
|
1998
|
-
async listThreads(options) {
|
|
1999
|
-
const [sessions, legacyThreads] = await Promise.all([this.#harnessV1.listSessions(), super.listThreads(options)]);
|
|
2000
|
-
const resourceId = this.getResourceId();
|
|
2001
|
-
const sessionThreads = sessions.filter((session) => options?.allResources || session.resourceId === resourceId).map((session) => {
|
|
2002
|
-
const legacyThread = legacyThreads.find(
|
|
2003
|
-
(thread) => thread.id === session.threadId && (!thread.resourceId || thread.resourceId === session.resourceId)
|
|
2004
|
-
);
|
|
2005
|
-
const metadata = legacyThread?.metadata;
|
|
2006
|
-
if (!options?.includeForkedSubagents && metadata?.forkedSubagent === true) {
|
|
2007
|
-
return void 0;
|
|
2008
|
-
}
|
|
2009
|
-
return {
|
|
2010
|
-
id: session.threadId,
|
|
2011
|
-
resourceId: session.resourceId,
|
|
2012
|
-
createdAt: session.createdAt,
|
|
2013
|
-
updatedAt: session.lastActivityAt,
|
|
2014
|
-
metadata: {
|
|
2015
|
-
...metadata,
|
|
2016
|
-
sessionId: session.id,
|
|
2017
|
-
modeId: session.modeId,
|
|
2018
|
-
modelId: session.modelId,
|
|
2019
|
-
parentSessionId: session.parentSessionId,
|
|
2020
|
-
origin: session.origin
|
|
2021
|
-
}
|
|
2022
|
-
};
|
|
2023
|
-
}).filter((thread) => thread !== void 0);
|
|
2024
|
-
const sessionKeys = new Set(sessionThreads.map((thread) => `${thread.resourceId}:${thread.id}`));
|
|
2025
|
-
const sessionThreadIds = new Set(sessionThreads.map((thread) => thread.id));
|
|
2026
|
-
return [
|
|
2027
|
-
...sessionThreads,
|
|
2028
|
-
...legacyThreads.filter(
|
|
2029
|
-
(thread) => !sessionKeys.has(`${thread.resourceId}:${thread.id}`) && !(!thread.resourceId && sessionThreadIds.has(thread.id))
|
|
2030
|
-
)
|
|
2031
|
-
];
|
|
2032
|
-
}
|
|
2033
|
-
async cloneSession(opts = {}) {
|
|
2034
|
-
const session = this.#session;
|
|
2035
|
-
if (!session) {
|
|
2036
|
-
throw new Error("No active session to clone");
|
|
2037
|
-
}
|
|
2038
|
-
return this.#harnessV1.cloneSession(session, opts);
|
|
2039
|
-
}
|
|
2040
|
-
async cloneThread({
|
|
2041
|
-
sourceThreadId,
|
|
2042
|
-
title,
|
|
2043
|
-
resourceId
|
|
2044
|
-
} = {}) {
|
|
2045
|
-
const sourceId = sourceThreadId ?? this.getCurrentThreadId();
|
|
2046
|
-
if (!sourceId) {
|
|
2047
|
-
throw new Error("No source thread to clone");
|
|
2048
|
-
}
|
|
2049
|
-
const sourceResourceId = resourceId ?? this.getResourceId();
|
|
2050
|
-
const currentSession = this.#session;
|
|
2051
|
-
const sourceSession = currentSession?.threadId === sourceId && currentSession.resourceId === sourceResourceId ? currentSession : await this.#harnessV1.session({
|
|
2052
|
-
threadId: sourceId,
|
|
2053
|
-
resourceId: sourceResourceId
|
|
2054
|
-
});
|
|
2055
|
-
this.#session = await this.#harnessV1.cloneSession(sourceSession, { title });
|
|
2056
|
-
const thread = await this.#session.getThread();
|
|
2057
|
-
if (!thread) {
|
|
2058
|
-
throw new Error("Failed to load cloned thread");
|
|
2059
|
-
}
|
|
2060
|
-
return {
|
|
2061
|
-
id: thread.id,
|
|
2062
|
-
resourceId: thread.resourceId,
|
|
2063
|
-
title: title ?? thread.title ?? "Cloned Thread",
|
|
2064
|
-
createdAt: thread.createdAt,
|
|
2065
|
-
updatedAt: thread.updatedAt,
|
|
2066
|
-
metadata: thread.metadata
|
|
2067
|
-
};
|
|
2068
|
-
}
|
|
2069
|
-
getCurrentMode() {
|
|
2070
|
-
if (!this.#session) {
|
|
2071
|
-
return super.getCurrentMode();
|
|
2072
|
-
}
|
|
2073
|
-
const mode = this.#session.getMode();
|
|
2074
|
-
const mastra2 = this.getMastra();
|
|
2075
|
-
if (!mastra2) {
|
|
2076
|
-
throw new Error("HarnessCompat requires an initialized Mastra instance");
|
|
2077
|
-
}
|
|
2078
|
-
return v1ModeToLegacy(mode, mastra2.getAgentById(mode.agentId));
|
|
2079
|
-
}
|
|
2080
|
-
/**
|
|
2081
|
-
* Switch to a different mode.
|
|
2082
|
-
* Aborts any in-progress generation and switches to the mode's default model.
|
|
2083
|
-
*/
|
|
2084
|
-
async switchMode({ modeId }) {
|
|
2085
|
-
const mode = this.#harnessV1.getMode(modeId);
|
|
2086
|
-
if (!mode) {
|
|
2087
|
-
throw new Error(`Mode not found: ${modeId}`);
|
|
2088
|
-
}
|
|
2089
|
-
if (this.#session) {
|
|
2090
|
-
this.#session.setMode(mode);
|
|
2091
|
-
}
|
|
2092
|
-
await super.switchMode({ modeId });
|
|
2093
|
-
}
|
|
2094
|
-
};
|
|
2095
1979
|
var VALID_EVENTS = [
|
|
2096
1980
|
"PreToolUse",
|
|
2097
1981
|
"PostToolUse",
|
|
@@ -2935,15 +2819,14 @@ function createMcpManager(projectDir, configDirName = chunkJ3ISOP5J_cjs.DEFAULT_
|
|
|
2935
2819
|
};
|
|
2936
2820
|
}
|
|
2937
2821
|
var stateSchema = zod.z.object({
|
|
2822
|
+
currentModelId: zod.z.string().optional(),
|
|
2823
|
+
modeId: zod.z.string().optional(),
|
|
2824
|
+
subagentModelId: zod.z.string().optional(),
|
|
2938
2825
|
projectPath: zod.z.string().optional(),
|
|
2939
2826
|
projectName: zod.z.string().optional(),
|
|
2940
2827
|
configDir: zod.z.string().default(chunkJ3ISOP5J_cjs.DEFAULT_CONFIG_DIR),
|
|
2941
2828
|
gitBranch: zod.z.string().optional(),
|
|
2942
2829
|
lastCommand: zod.z.string().optional(),
|
|
2943
|
-
currentModelId: zod.z.string().default(""),
|
|
2944
|
-
// Subagent model settings (per-thread/per-mode)
|
|
2945
|
-
subagentModelId: zod.z.string().optional(),
|
|
2946
|
-
// Thread-level default for subagents
|
|
2947
2830
|
// Observational Memory model settings
|
|
2948
2831
|
observerModelId: zod.z.string().default(chunkJ3ISOP5J_cjs.DEFAULT_OM_MODEL_ID),
|
|
2949
2832
|
reflectorModelId: zod.z.string().default(chunkJ3ISOP5J_cjs.DEFAULT_OM_MODEL_ID),
|
|
@@ -3236,15 +3119,15 @@ function applyEffectiveDefaultsToV1Modes(modes, effectiveDefaults) {
|
|
|
3236
3119
|
}
|
|
3237
3120
|
function createAuthStorage() {
|
|
3238
3121
|
const authStorage = new chunkJ3ISOP5J_cjs.AuthStorage();
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3122
|
+
chunkA4W5D25I_cjs.setAuthStorage(authStorage);
|
|
3123
|
+
chunkA4W5D25I_cjs.setAuthStorage3(authStorage);
|
|
3124
|
+
chunkA4W5D25I_cjs.setAuthStorage2(authStorage);
|
|
3242
3125
|
return authStorage;
|
|
3243
3126
|
}
|
|
3244
3127
|
function resolveCloudObservabilityConfig(settings, authStorage, resourceId) {
|
|
3245
3128
|
const resourceConfig = settings.observability.resources[resourceId];
|
|
3246
3129
|
if (resourceConfig) {
|
|
3247
|
-
const token = authStorage.getStoredApiKey(`${
|
|
3130
|
+
const token = authStorage.getStoredApiKey(`${chunkA4W5D25I_cjs.OBSERVABILITY_AUTH_PREFIX}${resourceId}`);
|
|
3248
3131
|
if (token) {
|
|
3249
3132
|
return { accessToken: token, projectId: resourceConfig.projectId };
|
|
3250
3133
|
}
|
|
@@ -3266,8 +3149,8 @@ async function createMastraCode(config) {
|
|
|
3266
3149
|
}
|
|
3267
3150
|
const gatewayRegistry = llm.GatewayRegistry.getInstance({ useDynamicLoading: true });
|
|
3268
3151
|
const authStorage = createAuthStorage();
|
|
3269
|
-
const globalSettings =
|
|
3270
|
-
const storedGatewayKey = authStorage.getStoredApiKey(
|
|
3152
|
+
const globalSettings = chunkA4W5D25I_cjs.loadSettings(config?.settingsPath);
|
|
3153
|
+
const storedGatewayKey = authStorage.getStoredApiKey(chunkA4W5D25I_cjs.MEMORY_GATEWAY_PROVIDER);
|
|
3271
3154
|
const storedGatewayUrl = globalSettings.memoryGateway?.baseUrl;
|
|
3272
3155
|
if (storedGatewayKey) {
|
|
3273
3156
|
process.env["MASTRA_GATEWAY_API_KEY"] ??= storedGatewayKey;
|
|
@@ -3282,11 +3165,11 @@ async function createMastraCode(config) {
|
|
|
3282
3165
|
const envVars = cfg?.apiKeyEnvVar;
|
|
3283
3166
|
providerEnvVars[provider] = Array.isArray(envVars) ? envVars[0] : envVars;
|
|
3284
3167
|
}
|
|
3285
|
-
providerEnvVars[
|
|
3168
|
+
providerEnvVars[chunkA4W5D25I_cjs.MEMORY_GATEWAY_PROVIDER] ??= "MASTRA_GATEWAY_API_KEY";
|
|
3286
3169
|
authStorage.loadStoredApiKeysIntoEnv(providerEnvVars);
|
|
3287
3170
|
} catch {
|
|
3288
3171
|
authStorage.loadStoredApiKeysIntoEnv({
|
|
3289
|
-
[
|
|
3172
|
+
[chunkA4W5D25I_cjs.MEMORY_GATEWAY_PROVIDER]: "MASTRA_GATEWAY_API_KEY",
|
|
3290
3173
|
anthropic: "ANTHROPIC_API_KEY",
|
|
3291
3174
|
openai: "OPENAI_API_KEY",
|
|
3292
3175
|
google: "GOOGLE_GENERATIVE_AI_API_KEY",
|
|
@@ -3398,12 +3281,39 @@ async function createMastraCode(config) {
|
|
|
3398
3281
|
const hookManager = config?.disableHooks ? void 0 : new HookManager(project.rootPath, "session-init", configDir);
|
|
3399
3282
|
const outcomeScorer = createOutcomeScorer();
|
|
3400
3283
|
const efficiencyScorer = createEfficiencyScorer();
|
|
3401
|
-
const
|
|
3284
|
+
const githubSignals$1 = globalSettings.signals?.experimentalGithubSignals ? new githubSignals.GithubSignals({
|
|
3285
|
+
cwd: project.rootPath,
|
|
3286
|
+
getNotificationStreamOptions: ({ resourceId, threadId }) => {
|
|
3287
|
+
const requestContext$1 = new requestContext.RequestContext();
|
|
3288
|
+
const harnessContext = {
|
|
3289
|
+
harnessId: harness$1.id,
|
|
3290
|
+
state: harness$1.getState(),
|
|
3291
|
+
getState: () => harness$1.getState(),
|
|
3292
|
+
setState: (updates) => harness$1.setState(updates),
|
|
3293
|
+
threadId,
|
|
3294
|
+
resourceId,
|
|
3295
|
+
modeId: harness$1.getCurrentModeId(),
|
|
3296
|
+
workspace: harness$1.getWorkspace(),
|
|
3297
|
+
registerQuestion: (params) => harness$1.registerQuestion(params),
|
|
3298
|
+
registerPlanApproval: (params) => harness$1.registerPlanApproval(params),
|
|
3299
|
+
getSubagentModelId: (params) => harness$1.getSubagentModelId(params)
|
|
3300
|
+
};
|
|
3301
|
+
requestContext$1.set("harness", harnessContext);
|
|
3302
|
+
return {
|
|
3303
|
+
memory: { thread: threadId, resource: resourceId },
|
|
3304
|
+
requestContext: requestContext$1,
|
|
3305
|
+
maxSteps: 1e3,
|
|
3306
|
+
savePerStep: false,
|
|
3307
|
+
requireToolApproval: harness$1.getState().yolo !== true,
|
|
3308
|
+
modelSettings: { temperature: 1 }
|
|
3309
|
+
};
|
|
3310
|
+
}
|
|
3311
|
+
}) : void 0;
|
|
3402
3312
|
const codeAgent = new agent.Agent({
|
|
3403
3313
|
id: CODE_AGENT_ID,
|
|
3404
3314
|
name: "Code Agent",
|
|
3405
3315
|
instructions: getDynamicInstructions,
|
|
3406
|
-
model:
|
|
3316
|
+
model: chunkA4W5D25I_cjs.getDynamicModel,
|
|
3407
3317
|
tools: createDynamicTools(mcpManager, config?.extraTools, hookManager, config?.disabledTools, storage$1),
|
|
3408
3318
|
scorers: {
|
|
3409
3319
|
outcome: {
|
|
@@ -3415,6 +3325,7 @@ async function createMastraCode(config) {
|
|
|
3415
3325
|
sampling: { type: "ratio", rate: 0.3 }
|
|
3416
3326
|
}
|
|
3417
3327
|
},
|
|
3328
|
+
signals: githubSignals$1 ? [githubSignals$1] : [],
|
|
3418
3329
|
inputProcessors: [
|
|
3419
3330
|
new processors.AgentsMDInjector({
|
|
3420
3331
|
getIgnoredInstructionPaths: ({ requestContext }) => {
|
|
@@ -3423,38 +3334,10 @@ async function createMastraCode(config) {
|
|
|
3423
3334
|
return getStaticallyLoadedInstructionPaths(projectPath);
|
|
3424
3335
|
}
|
|
3425
3336
|
}),
|
|
3426
|
-
...githubSignalsProcessor ? [githubSignalsProcessor] : [],
|
|
3427
3337
|
new processors.ProviderHistoryCompat()
|
|
3428
3338
|
],
|
|
3429
3339
|
errorProcessors: [new processors.StreamErrorRetryProcessor(), new processors.PrefillErrorHandler(), new processors.ProviderHistoryCompat()]
|
|
3430
3340
|
});
|
|
3431
|
-
githubSignalsProcessor?.addAgent(codeAgent, {
|
|
3432
|
-
getNotificationStreamOptions: ({ resourceId, threadId }) => {
|
|
3433
|
-
const requestContext$1 = new requestContext.RequestContext();
|
|
3434
|
-
const harnessContext = {
|
|
3435
|
-
harnessId: harness.id,
|
|
3436
|
-
state: harness.getState(),
|
|
3437
|
-
getState: () => harness.getState(),
|
|
3438
|
-
setState: (updates) => harness.setState(updates),
|
|
3439
|
-
threadId,
|
|
3440
|
-
resourceId,
|
|
3441
|
-
modeId: harness.getCurrentModeId(),
|
|
3442
|
-
workspace: harness.getWorkspace(),
|
|
3443
|
-
registerQuestion: (params) => harness.registerQuestion(params),
|
|
3444
|
-
registerPlanApproval: (params) => harness.registerPlanApproval(params),
|
|
3445
|
-
getSubagentModelId: (params) => harness.getSubagentModelId(params)
|
|
3446
|
-
};
|
|
3447
|
-
requestContext$1.set("harness", harnessContext);
|
|
3448
|
-
return {
|
|
3449
|
-
memory: { thread: threadId, resource: resourceId },
|
|
3450
|
-
requestContext: requestContext$1,
|
|
3451
|
-
maxSteps: 1e3,
|
|
3452
|
-
savePerStep: false,
|
|
3453
|
-
requireToolApproval: harness.getState().yolo !== true,
|
|
3454
|
-
modelSettings: { temperature: 1 }
|
|
3455
|
-
};
|
|
3456
|
-
}
|
|
3457
|
-
});
|
|
3458
3341
|
const defaultSubagents = [exploreSubagent, planSubagent, executeSubagent];
|
|
3459
3342
|
const defaultModesV1 = [
|
|
3460
3343
|
{
|
|
@@ -3463,7 +3346,7 @@ async function createMastraCode(config) {
|
|
|
3463
3346
|
description: "Build",
|
|
3464
3347
|
defaultModelId: "anthropic/claude-opus-4-7",
|
|
3465
3348
|
metadata: {
|
|
3466
|
-
color:
|
|
3349
|
+
color: chunkA4W5D25I_cjs.mastra.green,
|
|
3467
3350
|
default: true
|
|
3468
3351
|
}
|
|
3469
3352
|
},
|
|
@@ -3474,7 +3357,7 @@ async function createMastraCode(config) {
|
|
|
3474
3357
|
transitionsTo: "build",
|
|
3475
3358
|
defaultModelId: "openai/gpt-5.5",
|
|
3476
3359
|
metadata: {
|
|
3477
|
-
color:
|
|
3360
|
+
color: chunkA4W5D25I_cjs.mastra.purple
|
|
3478
3361
|
}
|
|
3479
3362
|
},
|
|
3480
3363
|
{
|
|
@@ -3483,7 +3366,7 @@ async function createMastraCode(config) {
|
|
|
3483
3366
|
description: "Fast",
|
|
3484
3367
|
defaultModelId: "cerebras/zai-glm-4.7",
|
|
3485
3368
|
metadata: {
|
|
3486
|
-
color:
|
|
3369
|
+
color: chunkA4W5D25I_cjs.mastra.orange
|
|
3487
3370
|
}
|
|
3488
3371
|
}
|
|
3489
3372
|
];
|
|
@@ -3523,11 +3406,11 @@ async function createMastraCode(config) {
|
|
|
3523
3406
|
}
|
|
3524
3407
|
} catch {
|
|
3525
3408
|
}
|
|
3526
|
-
const builtinPacks =
|
|
3527
|
-
const builtinOmPacks =
|
|
3528
|
-
const effectiveDefaults =
|
|
3529
|
-
const effectiveObserverModel =
|
|
3530
|
-
const effectiveReflectorModel =
|
|
3409
|
+
const builtinPacks = chunkA4W5D25I_cjs.getAvailableModePacks(startupAccess);
|
|
3410
|
+
const builtinOmPacks = chunkA4W5D25I_cjs.getAvailableOmPacks(startupAccess);
|
|
3411
|
+
const effectiveDefaults = chunkA4W5D25I_cjs.resolveModelDefaults(globalSettings, builtinPacks);
|
|
3412
|
+
const effectiveObserverModel = chunkA4W5D25I_cjs.resolveOmRoleModel(globalSettings, "observer", builtinOmPacks);
|
|
3413
|
+
const effectiveReflectorModel = chunkA4W5D25I_cjs.resolveOmRoleModel(globalSettings, "reflector", builtinOmPacks);
|
|
3531
3414
|
const effectiveObservationThreshold = globalSettings.models.omObservationThreshold ?? void 0;
|
|
3532
3415
|
const effectiveReflectionThreshold = globalSettings.models.omReflectionThreshold ?? void 0;
|
|
3533
3416
|
const effectiveCavemanObservations = globalSettings.models.omCavemanObservations ?? void 0;
|
|
@@ -3622,125 +3505,115 @@ async function createMastraCode(config) {
|
|
|
3622
3505
|
});
|
|
3623
3506
|
})
|
|
3624
3507
|
);
|
|
3625
|
-
const harnessV1 = new v1.Harness({
|
|
3626
|
-
ownerId,
|
|
3627
|
-
agents: { [CODE_AGENT_ID]: codeAgent },
|
|
3628
|
-
memory,
|
|
3629
|
-
modes: modesV1,
|
|
3630
|
-
defaultModeId,
|
|
3631
|
-
storage: harnessStorage
|
|
3632
|
-
});
|
|
3633
3508
|
const typedStateSchema = stateSchema;
|
|
3634
|
-
const harness = new
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3509
|
+
const harness$1 = new harness.Harness({
|
|
3510
|
+
id: "mastra-code",
|
|
3511
|
+
resourceId: project.resourceId,
|
|
3512
|
+
storage: storage$1,
|
|
3513
|
+
observability: observability$1,
|
|
3514
|
+
memory,
|
|
3515
|
+
pubsub: signalsPubSub,
|
|
3516
|
+
stateSchema: typedStateSchema,
|
|
3517
|
+
subagents,
|
|
3518
|
+
resolveModel: (modelId) => chunkA4W5D25I_cjs.resolveModel(modelId),
|
|
3519
|
+
toolCategoryResolver: chunkJHYTJMKT_cjs.getToolCategory,
|
|
3520
|
+
initialState: {
|
|
3521
|
+
projectPath: project.rootPath,
|
|
3522
|
+
projectName: project.name,
|
|
3523
|
+
gitBranch: project.gitBranch,
|
|
3524
|
+
yolo: true,
|
|
3525
|
+
...globalInitialState,
|
|
3526
|
+
...config?.initialState,
|
|
3527
|
+
// configDir must always win over initialState spreads to stay in sync
|
|
3528
|
+
// with MCP/hooks/storage which were already initialized with this value.
|
|
3529
|
+
configDir
|
|
3530
|
+
},
|
|
3531
|
+
workspace: config?.workspace ?? getDynamicWorkspace,
|
|
3532
|
+
browser: config?.browser,
|
|
3533
|
+
modes,
|
|
3534
|
+
heartbeatHandlers,
|
|
3535
|
+
modelAuthChecker: (provider) => {
|
|
3536
|
+
const gatewayKey = authStorage.getStoredApiKey(chunkA4W5D25I_cjs.MEMORY_GATEWAY_PROVIDER) ?? process.env["MASTRA_GATEWAY_API_KEY"];
|
|
3537
|
+
if (gatewayKey) {
|
|
3538
|
+
const providerConfig = gatewayRegistry.getProviders()[provider];
|
|
3539
|
+
if (providerConfig?.gateway === "mastra") return true;
|
|
3540
|
+
}
|
|
3541
|
+
const oauthId = PROVIDER_TO_OAUTH_ID[provider];
|
|
3542
|
+
if (oauthId && authStorage.isLoggedIn(oauthId)) {
|
|
3543
|
+
return true;
|
|
3544
|
+
}
|
|
3545
|
+
if (authStorage.hasStoredApiKey(provider)) {
|
|
3546
|
+
return true;
|
|
3547
|
+
}
|
|
3548
|
+
if (provider === "anthropic") {
|
|
3549
|
+
const cred = authStorage.get("anthropic");
|
|
3550
|
+
if (cred?.type === "api_key" && cred.key.trim().length > 0) {
|
|
3672
3551
|
return true;
|
|
3673
3552
|
}
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
}
|
|
3679
|
-
}
|
|
3680
|
-
if (provider === "openai") {
|
|
3681
|
-
const cred = authStorage.get("openai-codex");
|
|
3682
|
-
if (cred?.type === "api_key" && cred.key.trim().length > 0) {
|
|
3683
|
-
return true;
|
|
3684
|
-
}
|
|
3685
|
-
}
|
|
3686
|
-
const customProvider = chunkNFF7IH5X_cjs.loadSettings().customProviders.find((entry) => {
|
|
3687
|
-
return provider === chunkNFF7IH5X_cjs.getCustomProviderId(entry.name);
|
|
3688
|
-
});
|
|
3689
|
-
if (customProvider) {
|
|
3553
|
+
}
|
|
3554
|
+
if (provider === "openai") {
|
|
3555
|
+
const cred = authStorage.get("openai-codex");
|
|
3556
|
+
if (cred?.type === "api_key" && cred.key.trim().length > 0) {
|
|
3690
3557
|
return true;
|
|
3691
3558
|
}
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3559
|
+
}
|
|
3560
|
+
const customProvider = chunkA4W5D25I_cjs.loadSettings().customProviders.find((entry) => {
|
|
3561
|
+
return provider === chunkA4W5D25I_cjs.getCustomProviderId(entry.name);
|
|
3562
|
+
});
|
|
3563
|
+
if (customProvider) {
|
|
3564
|
+
return true;
|
|
3565
|
+
}
|
|
3566
|
+
return void 0;
|
|
3567
|
+
},
|
|
3568
|
+
modelUseCountProvider: () => chunkA4W5D25I_cjs.loadSettings().modelUseCounts,
|
|
3569
|
+
modelUseCountTracker: (modelId) => {
|
|
3570
|
+
try {
|
|
3571
|
+
const settings = chunkA4W5D25I_cjs.loadSettings();
|
|
3572
|
+
settings.modelUseCounts[modelId] = (settings.modelUseCounts[modelId] ?? 0) + 1;
|
|
3573
|
+
chunkA4W5D25I_cjs.saveSettings(settings);
|
|
3574
|
+
} catch (error) {
|
|
3575
|
+
console.error("Failed to persist model usage count", error);
|
|
3576
|
+
}
|
|
3577
|
+
},
|
|
3578
|
+
customModelCatalogProvider: async () => {
|
|
3579
|
+
const settings = chunkA4W5D25I_cjs.loadSettings();
|
|
3580
|
+
const customModels = [];
|
|
3581
|
+
for (const provider of settings.customProviders) {
|
|
3582
|
+
const providerId = chunkA4W5D25I_cjs.getCustomProviderId(provider.name);
|
|
3583
|
+
for (const modelName of provider.models) {
|
|
3584
|
+
customModels.push({
|
|
3585
|
+
id: chunkA4W5D25I_cjs.toCustomProviderModelId(provider.name, modelName),
|
|
3586
|
+
provider: providerId,
|
|
3587
|
+
modelName,
|
|
3588
|
+
hasApiKey: true,
|
|
3589
|
+
apiKeyEnvVar: void 0
|
|
3590
|
+
});
|
|
3718
3591
|
}
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
}
|
|
3730
|
-
} catch (error) {
|
|
3731
|
-
console.warn("Failed to load GitHub Copilot model catalog:", error);
|
|
3592
|
+
}
|
|
3593
|
+
try {
|
|
3594
|
+
const copilotModels = await chunkA4W5D25I_cjs.getCopilotModelCatalog({ authStorage });
|
|
3595
|
+
for (const m of copilotModels) {
|
|
3596
|
+
customModels.push({
|
|
3597
|
+
id: `github-copilot/${m.id}`,
|
|
3598
|
+
provider: "github-copilot",
|
|
3599
|
+
modelName: m.id,
|
|
3600
|
+
hasApiKey: true,
|
|
3601
|
+
apiKeyEnvVar: void 0
|
|
3602
|
+
});
|
|
3732
3603
|
}
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
threadLock: crossProcessPubSub ? void 0 : {
|
|
3736
|
-
acquire: chunkNFF7IH5X_cjs.acquireThreadLock,
|
|
3737
|
-
release: chunkNFF7IH5X_cjs.releaseThreadLock
|
|
3604
|
+
} catch (error) {
|
|
3605
|
+
console.warn("Failed to load GitHub Copilot model catalog:", error);
|
|
3738
3606
|
}
|
|
3607
|
+
return customModels;
|
|
3739
3608
|
},
|
|
3740
|
-
|
|
3741
|
-
|
|
3609
|
+
threadLock: crossProcessPubSub ? void 0 : {
|
|
3610
|
+
acquire: chunkA4W5D25I_cjs.acquireThreadLock,
|
|
3611
|
+
release: chunkA4W5D25I_cjs.releaseThreadLock
|
|
3612
|
+
}
|
|
3613
|
+
// , harnessV1
|
|
3614
|
+
});
|
|
3742
3615
|
if (hookManager) {
|
|
3743
|
-
harness.subscribe((event) => {
|
|
3616
|
+
harness$1.subscribe((event) => {
|
|
3744
3617
|
if (event.type === "thread_changed") {
|
|
3745
3618
|
hookManager.setSessionId(event.threadId);
|
|
3746
3619
|
} else if (event.type === "thread_created") {
|
|
@@ -3748,17 +3621,17 @@ async function createMastraCode(config) {
|
|
|
3748
3621
|
}
|
|
3749
3622
|
});
|
|
3750
3623
|
}
|
|
3751
|
-
if (
|
|
3624
|
+
if (githubSignals$1) {
|
|
3752
3625
|
const startGithubPollingForCurrentThread = async (threadId) => {
|
|
3753
3626
|
if (!threadId) return;
|
|
3754
|
-
|
|
3627
|
+
githubSignals$1.stopAllPolling();
|
|
3755
3628
|
try {
|
|
3756
|
-
const threads2 = await harness.listThreads({ allResources: true });
|
|
3629
|
+
const threads2 = await harness$1.listThreads({ allResources: true });
|
|
3757
3630
|
const thread = threads2.find((item) => item.id === threadId);
|
|
3758
|
-
await
|
|
3631
|
+
await githubSignals$1.startPollingForThread(
|
|
3759
3632
|
{
|
|
3760
3633
|
threadId,
|
|
3761
|
-
resourceId: thread?.resourceId ?? harness.getResourceId()
|
|
3634
|
+
resourceId: thread?.resourceId ?? harness$1.getResourceId()
|
|
3762
3635
|
},
|
|
3763
3636
|
{ pollImmediately: true }
|
|
3764
3637
|
);
|
|
@@ -3766,33 +3639,33 @@ async function createMastraCode(config) {
|
|
|
3766
3639
|
console.warn("Failed to start GitHub PR polling:", error);
|
|
3767
3640
|
}
|
|
3768
3641
|
};
|
|
3769
|
-
harness.subscribe((event) => {
|
|
3642
|
+
harness$1.subscribe((event) => {
|
|
3770
3643
|
if (event.type === "thread_changed") void startGithubPollingForCurrentThread(event.threadId);
|
|
3771
3644
|
else if (event.type === "thread_created") void startGithubPollingForCurrentThread(event.thread.id);
|
|
3772
3645
|
});
|
|
3773
|
-
void startGithubPollingForCurrentThread(harness.getCurrentThreadId());
|
|
3646
|
+
void startGithubPollingForCurrentThread(harness$1.getCurrentThreadId());
|
|
3774
3647
|
}
|
|
3775
|
-
const omThreadStateHarness = harness;
|
|
3648
|
+
const omThreadStateHarness = harness$1;
|
|
3776
3649
|
attachOMThreadStatePersistence(omThreadStateHarness);
|
|
3777
3650
|
await restoreOMThreadStateForCurrentThread(omThreadStateHarness).catch(() => {
|
|
3778
3651
|
});
|
|
3779
3652
|
return {
|
|
3780
|
-
harness,
|
|
3653
|
+
harness: harness$1,
|
|
3781
3654
|
mcpManager,
|
|
3782
3655
|
hookManager,
|
|
3783
3656
|
signalsPubSub,
|
|
3784
3657
|
authStorage,
|
|
3785
|
-
resolveModel:
|
|
3658
|
+
resolveModel: chunkA4W5D25I_cjs.resolveModel,
|
|
3786
3659
|
storageWarning,
|
|
3787
3660
|
observabilityWarning,
|
|
3788
3661
|
builtinPacks,
|
|
3789
3662
|
builtinOmPacks,
|
|
3790
3663
|
effectiveDefaults,
|
|
3791
|
-
githubSignals:
|
|
3664
|
+
githubSignals: githubSignals$1
|
|
3792
3665
|
};
|
|
3793
3666
|
}
|
|
3794
3667
|
|
|
3795
3668
|
exports.createAuthStorage = createAuthStorage;
|
|
3796
3669
|
exports.createMastraCode = createMastraCode;
|
|
3797
|
-
//# sourceMappingURL=chunk-
|
|
3798
|
-
//# sourceMappingURL=chunk-
|
|
3670
|
+
//# sourceMappingURL=chunk-TU3VBXJJ.cjs.map
|
|
3671
|
+
//# sourceMappingURL=chunk-TU3VBXJJ.cjs.map
|