mastracode 0.18.0-alpha.7 → 0.18.0-alpha.8
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 +12 -0
- package/dist/agents/memory.d.ts.map +1 -1
- package/dist/agents/thread-caveman-state.d.ts +16 -0
- package/dist/agents/thread-caveman-state.d.ts.map +1 -0
- package/dist/{chunk-DLEPYUVF.cjs → chunk-BV5IMX2N.cjs} +105 -50
- package/dist/chunk-BV5IMX2N.cjs.map +1 -0
- package/dist/{chunk-P4Z7TFM3.cjs → chunk-HSJIIPG6.cjs} +881 -840
- package/dist/chunk-HSJIIPG6.cjs.map +1 -0
- package/dist/{chunk-H3UXL3U6.cjs → chunk-U3HWL5UG.cjs} +3 -2
- package/dist/chunk-U3HWL5UG.cjs.map +1 -0
- package/dist/{chunk-UOD3QQE3.js → chunk-V5DGKR3W.js} +3 -2
- package/dist/chunk-V5DGKR3W.js.map +1 -0
- package/dist/{chunk-35USXMCL.js → chunk-WOKTYUW4.js} +71 -13
- package/dist/chunk-WOKTYUW4.js.map +1 -0
- package/dist/{chunk-PJGHWIG6.js → chunk-XCF2QRID.js} +46 -5
- package/dist/chunk-XCF2QRID.js.map +1 -0
- package/dist/cli.cjs +17 -17
- package/dist/cli.js +3 -3
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/onboarding/settings.d.ts +7 -0
- package/dist/onboarding/settings.d.ts.map +1 -1
- package/dist/schema.d.ts +1 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/tui/commands/om.d.ts.map +1 -1
- package/dist/tui/components/om-settings.d.ts +2 -0
- package/dist/tui/components/om-settings.d.ts.map +1 -1
- package/dist/tui.cjs +19 -19
- package/dist/tui.js +2 -2
- package/dist/utils/token-estimator.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/chunk-35USXMCL.js.map +0 -1
- package/dist/chunk-DLEPYUVF.cjs.map +0 -1
- package/dist/chunk-H3UXL3U6.cjs.map +0 -1
- package/dist/chunk-P4Z7TFM3.cjs.map +0 -1
- package/dist/chunk-PJGHWIG6.js.map +0 -1
- package/dist/chunk-UOD3QQE3.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# mastracode
|
|
2
2
|
|
|
3
|
+
## 0.18.0-alpha.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Replace `js-tiktoken` with `tokenx` for MastraCode web search and extract result truncation to reduce bundle size while preserving lightweight token-estimated output limits. ([#16326](https://github.com/mastra-ai/mastra/pull/16326))
|
|
8
|
+
|
|
9
|
+
- Made caveman-style observations opt-in. Observations and reflections now default to standard prose; turn caveman style back on via `/om` → "Caveman observations". The setting persists per thread, restores when Mastra Code starts, and new threads inherit the last selected value. ([#16275](https://github.com/mastra-ai/mastra/pull/16275))
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`b560d6f`](https://github.com/mastra-ai/mastra/commit/b560d6f88b9b904b15c10f75c949eb145bc27684), [`36b3bbf`](https://github.com/mastra-ai/mastra/commit/36b3bbf5a8d59f7e23d47e29340e76c681b4929c), [`b275631`](https://github.com/mastra-ai/mastra/commit/b275631dc10541a482b2e2d4a3e3cfa843bd5fa1)]:
|
|
12
|
+
- @mastra/core@1.33.0-alpha.6
|
|
13
|
+
- @mastra/memory@1.17.6-alpha.1
|
|
14
|
+
|
|
3
15
|
## 0.18.0-alpha.7
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/agents/memory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/agents/memory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAuExC;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,EAAE,MAAM,CAAC,EAAE,YAAY,IAC3E,oBAAoB;IAAE,cAAc,EAAE,cAAc,CAAA;CAAE,YA0D/D"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Harness } from '@mastra/core/harness';
|
|
2
|
+
/**
|
|
3
|
+
* Wires the `cavemanObservations` toggle into harness thread events so it
|
|
4
|
+
* persists per-thread and new threads inherit the most recent value.
|
|
5
|
+
*
|
|
6
|
+
* This is intentionally implemented in mastracode rather than core: the toggle
|
|
7
|
+
* is a mastracode-specific OM concept, so persistence stays scoped to the host.
|
|
8
|
+
*/
|
|
9
|
+
export declare function attachCavemanThreadStatePersistence(harness: Harness<Record<string, unknown>>): void;
|
|
10
|
+
/**
|
|
11
|
+
* Eagerly restores `cavemanObservations` for the currently-selected thread.
|
|
12
|
+
* Called once at TUI startup after the initial thread is selected, since the
|
|
13
|
+
* subscription set up later misses the startup `thread_changed` event.
|
|
14
|
+
*/
|
|
15
|
+
export declare function restoreCavemanForCurrentThread(harness: Harness<Record<string, unknown>>): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=thread-caveman-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thread-caveman-state.d.ts","sourceRoot":"","sources":["../../src/agents/thread-caveman-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAiB,MAAM,sBAAsB,CAAC;AA0CnE;;;;;;GAMG;AACH,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CASnG;AAED;;;;GAIG;AACH,wBAAsB,8BAA8B,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAI7G"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkU3HWL5UG_cjs = require('./chunk-U3HWL5UG.cjs');
|
|
4
4
|
var chunk24SDVHO7_cjs = require('./chunk-24SDVHO7.cjs');
|
|
5
5
|
var chunkOBFBUWOR_cjs = require('./chunk-OBFBUWOR.cjs');
|
|
6
6
|
var path = require('path');
|
|
@@ -14,8 +14,7 @@ var observability = require('@mastra/observability');
|
|
|
14
14
|
var child_process = require('child_process');
|
|
15
15
|
var tools = require('@mastra/core/tools');
|
|
16
16
|
var tavily = require('@mastra/tavily');
|
|
17
|
-
var
|
|
18
|
-
var o200k_base = require('js-tiktoken/ranks/o200k_base');
|
|
17
|
+
var tokenx = require('tokenx');
|
|
19
18
|
var os = require('os');
|
|
20
19
|
var workspace = require('@mastra/core/workspace');
|
|
21
20
|
var zod = require('zod');
|
|
@@ -31,8 +30,6 @@ var libsql = require('@mastra/libsql');
|
|
|
31
30
|
var pg = require('@mastra/pg');
|
|
32
31
|
|
|
33
32
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
34
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
35
|
-
|
|
36
33
|
function _interopNamespace(e) {
|
|
37
34
|
if (e && e.__esModule) return e;
|
|
38
35
|
var n = Object.create(null);
|
|
@@ -52,7 +49,6 @@ function _interopNamespace(e) {
|
|
|
52
49
|
}
|
|
53
50
|
|
|
54
51
|
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
55
|
-
var o200k_base__default = /*#__PURE__*/_interopDefault(o200k_base);
|
|
56
52
|
var os__namespace = /*#__PURE__*/_interopNamespace(os);
|
|
57
53
|
var fs3__namespace = /*#__PURE__*/_interopNamespace(fs3);
|
|
58
54
|
|
|
@@ -386,16 +382,17 @@ You are in FAST mode. Optimize for speed and brevity.
|
|
|
386
382
|
- If the user asks for a quick edit and you know the file, read it and edit it. Don't ask for confirmation.
|
|
387
383
|
- One tool call to read + one to edit is ideal. Minimize round trips.
|
|
388
384
|
`;
|
|
389
|
-
var enc = new lite.Tiktoken(o200k_base__default.default);
|
|
390
385
|
function sanitizeInput(text) {
|
|
391
386
|
if (!text) return "";
|
|
392
387
|
return (typeof text === `string` ? text : JSON.stringify(text)).replaceAll(`<|endoftext|>`, ``).replaceAll(`<|endofprompt|>`, ``);
|
|
393
388
|
}
|
|
394
389
|
function truncateStringForTokenEstimate(text, desiredTokenCount, fromEnd = true) {
|
|
395
|
-
const
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
390
|
+
const sanitized = sanitizeInput(text);
|
|
391
|
+
const totalTokens = tokenx.estimateTokenCount(sanitized);
|
|
392
|
+
if (totalTokens <= desiredTokenCount) return sanitized;
|
|
393
|
+
const kept = fromEnd ? tokenx.sliceByTokens(sanitized, -desiredTokenCount) : tokenx.sliceByTokens(sanitized, 0, desiredTokenCount);
|
|
394
|
+
return `[Truncated ~${totalTokens - desiredTokenCount} tokens]
|
|
395
|
+
${kept}`;
|
|
399
396
|
}
|
|
400
397
|
|
|
401
398
|
// src/tools/web-search.ts
|
|
@@ -583,8 +580,8 @@ function getDynamicWorkspace({ requestContext, mastra: mastra2 }) {
|
|
|
583
580
|
existing.setToolsConfig(isPlanMode ? { ...chunkOBFBUWOR_cjs.TOOL_NAME_OVERRIDES, ...planModeTools } : chunkOBFBUWOR_cjs.TOOL_NAME_OVERRIDES);
|
|
584
581
|
return existing;
|
|
585
582
|
}
|
|
586
|
-
const userLsp =
|
|
587
|
-
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-
|
|
583
|
+
const userLsp = chunkU3HWL5UG_cjs.loadSettings().lsp ?? {};
|
|
584
|
+
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-BV5IMX2N.cjs', document.baseURI).href)))), "..");
|
|
588
585
|
const lspConfig = {
|
|
589
586
|
...userLsp,
|
|
590
587
|
packageRunner: userLsp.packageRunner || detectPackageRunner(projectPath),
|
|
@@ -1031,18 +1028,19 @@ function getHarnessState(requestContext) {
|
|
|
1031
1028
|
}
|
|
1032
1029
|
function getObserverModel({ requestContext }) {
|
|
1033
1030
|
const state = getHarnessState(requestContext);
|
|
1034
|
-
return
|
|
1031
|
+
return chunkU3HWL5UG_cjs.resolveModel(state?.observerModelId ?? DEFAULT_OM_MODEL_ID, {
|
|
1035
1032
|
remapForCodexOAuth: true,
|
|
1036
1033
|
requestContext
|
|
1037
1034
|
});
|
|
1038
1035
|
}
|
|
1039
1036
|
function getReflectorModel({ requestContext }) {
|
|
1040
1037
|
const state = getHarnessState(requestContext);
|
|
1041
|
-
return
|
|
1038
|
+
return chunkU3HWL5UG_cjs.resolveModel(state?.reflectorModelId ?? DEFAULT_OM_MODEL_ID, {
|
|
1042
1039
|
remapForCodexOAuth: true,
|
|
1043
1040
|
requestContext
|
|
1044
1041
|
});
|
|
1045
1042
|
}
|
|
1043
|
+
var DYNAMIC_AGENTS_MD_INSTRUCTION = 'Messages wrapped in <system-reminder type="dynamic-agents-md" ...>...</system-reminder> are ephemeral project-context instructions injected from files on disk. Do NOT observe or extract information from these messages \u2014 they are reloaded automatically when needed and should not be stored in memory.';
|
|
1046
1044
|
var CAVEMAN_OM_INSTRUCTION = `Respond terse like smart caveman. All technical substance stay. Only fluff die.
|
|
1047
1045
|
|
|
1048
1046
|
Use full caveman compression style.
|
|
@@ -1071,12 +1069,17 @@ function getDynamicMemory(storage, vector) {
|
|
|
1071
1069
|
const omScope = state?.omScope ?? chunk24SDVHO7_cjs.getOmScope(state?.projectPath);
|
|
1072
1070
|
const obsThreshold = state?.observationThreshold ?? DEFAULT_OBS_THRESHOLD;
|
|
1073
1071
|
const refThreshold = state?.reflectionThreshold ?? DEFAULT_REF_THRESHOLD;
|
|
1072
|
+
const caveman = state?.cavemanObservations ?? false;
|
|
1074
1073
|
const observerPreviousObservationTokens = 1e3;
|
|
1075
|
-
const cacheKey = `${obsThreshold}:${refThreshold}:${omScope}:${observerPreviousObservationTokens}`;
|
|
1074
|
+
const cacheKey = `${obsThreshold}:${refThreshold}:${omScope}:${observerPreviousObservationTokens}:${caveman ? 1 : 0}`;
|
|
1076
1075
|
if (cachedMemory && cachedMemoryKey === cacheKey) {
|
|
1077
1076
|
return cachedMemory;
|
|
1078
1077
|
}
|
|
1079
1078
|
const isResourceScope = omScope === "resource";
|
|
1079
|
+
const observerInstruction = caveman ? `${DYNAMIC_AGENTS_MD_INSTRUCTION}
|
|
1080
|
+
|
|
1081
|
+
${CAVEMAN_OM_INSTRUCTION}` : DYNAMIC_AGENTS_MD_INSTRUCTION;
|
|
1082
|
+
const reflectionInstruction = caveman ? CAVEMAN_OM_INSTRUCTION : void 0;
|
|
1080
1083
|
cachedMemory = new memory.Memory({
|
|
1081
1084
|
storage,
|
|
1082
1085
|
vector: vector || false,
|
|
@@ -1097,14 +1100,14 @@ function getDynamicMemory(storage, vector) {
|
|
|
1097
1100
|
blockAfter: 2,
|
|
1098
1101
|
previousObserverTokens: observerPreviousObservationTokens,
|
|
1099
1102
|
threadTitle: true,
|
|
1100
|
-
instruction:
|
|
1103
|
+
instruction: observerInstruction
|
|
1101
1104
|
},
|
|
1102
1105
|
reflection: {
|
|
1103
1106
|
bufferActivation: isResourceScope ? void 0 : 1 / 2,
|
|
1104
1107
|
blockAfter: 1.1,
|
|
1105
1108
|
model: getReflectorModel,
|
|
1106
1109
|
observationTokens: refThreshold,
|
|
1107
|
-
instruction:
|
|
1110
|
+
instruction: reflectionInstruction
|
|
1108
1111
|
}
|
|
1109
1112
|
}
|
|
1110
1113
|
}
|
|
@@ -1225,6 +1228,46 @@ Structure your plan as:
|
|
|
1225
1228
|
Be specific about code locations (file paths, function names, line numbers). Keep the plan actionable and under 500 words.`,
|
|
1226
1229
|
allowedWorkspaceTools: [chunkOBFBUWOR_cjs.MC_TOOLS.VIEW, chunkOBFBUWOR_cjs.MC_TOOLS.SEARCH_CONTENT, chunkOBFBUWOR_cjs.MC_TOOLS.FIND_FILES]
|
|
1227
1230
|
};
|
|
1231
|
+
|
|
1232
|
+
// src/agents/thread-caveman-state.ts
|
|
1233
|
+
var META_KEY = "cavemanObservations";
|
|
1234
|
+
function getStateCaveman(harness) {
|
|
1235
|
+
const value = harness.getState()[META_KEY];
|
|
1236
|
+
return typeof value === "boolean" ? value : void 0;
|
|
1237
|
+
}
|
|
1238
|
+
async function findThread(harness, threadId) {
|
|
1239
|
+
const threads = await harness.listThreads({ allResources: true });
|
|
1240
|
+
return threads.find((t) => t.id === threadId);
|
|
1241
|
+
}
|
|
1242
|
+
async function restoreCavemanForThread(harness, threadId) {
|
|
1243
|
+
const thread = await findThread(harness, threadId);
|
|
1244
|
+
if (harness.getCurrentThreadId() !== threadId) return;
|
|
1245
|
+
const persisted = thread?.metadata?.[META_KEY];
|
|
1246
|
+
if (typeof persisted === "boolean") {
|
|
1247
|
+
if (getStateCaveman(harness) !== persisted) {
|
|
1248
|
+
await harness.setState({ [META_KEY]: persisted });
|
|
1249
|
+
}
|
|
1250
|
+
return;
|
|
1251
|
+
}
|
|
1252
|
+
const current = getStateCaveman(harness);
|
|
1253
|
+
if (typeof current === "boolean") {
|
|
1254
|
+
await harness.setThreadSetting({ key: META_KEY, value: current });
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
function attachCavemanThreadStatePersistence(harness) {
|
|
1258
|
+
harness.subscribe((event) => {
|
|
1259
|
+
if (event.type === "thread_changed" || event.type === "thread_created") {
|
|
1260
|
+
const threadId = event.type === "thread_changed" ? event.threadId : event.thread.id;
|
|
1261
|
+
void restoreCavemanForThread(harness, threadId).catch(() => {
|
|
1262
|
+
});
|
|
1263
|
+
}
|
|
1264
|
+
});
|
|
1265
|
+
}
|
|
1266
|
+
async function restoreCavemanForCurrentThread(harness) {
|
|
1267
|
+
const threadId = harness.getCurrentThreadId();
|
|
1268
|
+
if (!threadId) return;
|
|
1269
|
+
await restoreCavemanForThread(harness, threadId);
|
|
1270
|
+
}
|
|
1228
1271
|
function wrapToolWithHooks(toolName, tool, hookManager) {
|
|
1229
1272
|
if (!hookManager || typeof tool?.execute !== "function") {
|
|
1230
1273
|
return tool;
|
|
@@ -2560,6 +2603,10 @@ var stateSchema = zod.z.object({
|
|
|
2560
2603
|
// Observational Memory threshold settings
|
|
2561
2604
|
observationThreshold: zod.z.number().default(3e4),
|
|
2562
2605
|
reflectionThreshold: zod.z.number().default(4e4),
|
|
2606
|
+
// Whether observations and reflections use the terse caveman-style instruction.
|
|
2607
|
+
// Off by default — caveman style is opt-in via `/om` settings; observers and
|
|
2608
|
+
// reflectors fall back to their built-in (prose) behavior unless enabled.
|
|
2609
|
+
cavemanObservations: zod.z.boolean().default(false),
|
|
2563
2610
|
// Observational Memory scope — 'thread' (per-conversation) or 'resource' (shared across threads)
|
|
2564
2611
|
omScope: zod.z.enum(["thread", "resource"]).optional(),
|
|
2565
2612
|
// Thinking level for model reasoning effort
|
|
@@ -2823,14 +2870,14 @@ var PROVIDER_TO_OAUTH_ID = {
|
|
|
2823
2870
|
};
|
|
2824
2871
|
function createAuthStorage() {
|
|
2825
2872
|
const authStorage = new chunk24SDVHO7_cjs.AuthStorage();
|
|
2826
|
-
|
|
2827
|
-
|
|
2873
|
+
chunkU3HWL5UG_cjs.setAuthStorage(authStorage);
|
|
2874
|
+
chunkU3HWL5UG_cjs.setAuthStorage2(authStorage);
|
|
2828
2875
|
return authStorage;
|
|
2829
2876
|
}
|
|
2830
2877
|
function resolveCloudObservabilityConfig(settings, authStorage, resourceId) {
|
|
2831
2878
|
const resourceConfig = settings.observability.resources[resourceId];
|
|
2832
2879
|
if (resourceConfig) {
|
|
2833
|
-
const token = authStorage.getStoredApiKey(`${
|
|
2880
|
+
const token = authStorage.getStoredApiKey(`${chunkU3HWL5UG_cjs.OBSERVABILITY_AUTH_PREFIX}${resourceId}`);
|
|
2834
2881
|
if (token) {
|
|
2835
2882
|
return { accessToken: token, projectId: resourceConfig.projectId };
|
|
2836
2883
|
}
|
|
@@ -2848,8 +2895,8 @@ async function createMastraCode(config) {
|
|
|
2848
2895
|
}
|
|
2849
2896
|
const gatewayRegistry = llm.GatewayRegistry.getInstance({ useDynamicLoading: true });
|
|
2850
2897
|
const authStorage = createAuthStorage();
|
|
2851
|
-
const globalSettings =
|
|
2852
|
-
const storedGatewayKey = authStorage.getStoredApiKey(
|
|
2898
|
+
const globalSettings = chunkU3HWL5UG_cjs.loadSettings(config?.settingsPath);
|
|
2899
|
+
const storedGatewayKey = authStorage.getStoredApiKey(chunkU3HWL5UG_cjs.MEMORY_GATEWAY_PROVIDER);
|
|
2853
2900
|
const storedGatewayUrl = globalSettings.memoryGateway?.baseUrl;
|
|
2854
2901
|
if (storedGatewayKey) {
|
|
2855
2902
|
process.env["MASTRA_GATEWAY_API_KEY"] ??= storedGatewayKey;
|
|
@@ -2864,11 +2911,11 @@ async function createMastraCode(config) {
|
|
|
2864
2911
|
const envVars = cfg?.apiKeyEnvVar;
|
|
2865
2912
|
providerEnvVars[provider] = Array.isArray(envVars) ? envVars[0] : envVars;
|
|
2866
2913
|
}
|
|
2867
|
-
providerEnvVars[
|
|
2914
|
+
providerEnvVars[chunkU3HWL5UG_cjs.MEMORY_GATEWAY_PROVIDER] ??= "MASTRA_GATEWAY_API_KEY";
|
|
2868
2915
|
authStorage.loadStoredApiKeysIntoEnv(providerEnvVars);
|
|
2869
2916
|
} catch {
|
|
2870
2917
|
authStorage.loadStoredApiKeysIntoEnv({
|
|
2871
|
-
[
|
|
2918
|
+
[chunkU3HWL5UG_cjs.MEMORY_GATEWAY_PROVIDER]: "MASTRA_GATEWAY_API_KEY",
|
|
2872
2919
|
anthropic: "ANTHROPIC_API_KEY",
|
|
2873
2920
|
openai: "OPENAI_API_KEY",
|
|
2874
2921
|
google: "GOOGLE_GENERATIVE_AI_API_KEY",
|
|
@@ -2881,7 +2928,7 @@ async function createMastraCode(config) {
|
|
|
2881
2928
|
} catch (error) {
|
|
2882
2929
|
console.warn("Failed to sync gateways at startup", error);
|
|
2883
2930
|
}
|
|
2884
|
-
const mgApiKey = authStorage.getStoredApiKey(
|
|
2931
|
+
const mgApiKey = authStorage.getStoredApiKey(chunkU3HWL5UG_cjs.MEMORY_GATEWAY_PROVIDER) ?? process.env["MASTRA_GATEWAY_API_KEY"];
|
|
2885
2932
|
const project = chunk24SDVHO7_cjs.detectProject(cwd);
|
|
2886
2933
|
const resourceIdOverride = chunk24SDVHO7_cjs.getResourceIdOverride(project.rootPath);
|
|
2887
2934
|
if (resourceIdOverride) {
|
|
@@ -2983,7 +3030,7 @@ async function createMastraCode(config) {
|
|
|
2983
3030
|
id: "code-agent",
|
|
2984
3031
|
name: "Code Agent",
|
|
2985
3032
|
instructions: getDynamicInstructions,
|
|
2986
|
-
model:
|
|
3033
|
+
model: chunkU3HWL5UG_cjs.getDynamicModel,
|
|
2987
3034
|
tools: createDynamicTools(mcpManager, config?.extraTools, hookManager, config?.disabledTools),
|
|
2988
3035
|
scorers: {
|
|
2989
3036
|
outcome: {
|
|
@@ -3014,21 +3061,21 @@ async function createMastraCode(config) {
|
|
|
3014
3061
|
name: "Build",
|
|
3015
3062
|
default: true,
|
|
3016
3063
|
defaultModelId: "anthropic/claude-opus-4-6",
|
|
3017
|
-
color:
|
|
3064
|
+
color: chunkU3HWL5UG_cjs.mastra.green,
|
|
3018
3065
|
agent: codeAgent
|
|
3019
3066
|
},
|
|
3020
3067
|
{
|
|
3021
3068
|
id: "plan",
|
|
3022
3069
|
name: "Plan",
|
|
3023
3070
|
defaultModelId: "openai/gpt-5.2-codex",
|
|
3024
|
-
color:
|
|
3071
|
+
color: chunkU3HWL5UG_cjs.mastra.purple,
|
|
3025
3072
|
agent: codeAgent
|
|
3026
3073
|
},
|
|
3027
3074
|
{
|
|
3028
3075
|
id: "fast",
|
|
3029
3076
|
name: "Fast",
|
|
3030
3077
|
defaultModelId: "cerebras/zai-glm-4.7",
|
|
3031
|
-
color:
|
|
3078
|
+
color: chunkU3HWL5UG_cjs.mastra.orange,
|
|
3032
3079
|
agent: codeAgent
|
|
3033
3080
|
}
|
|
3034
3081
|
];
|
|
@@ -3065,13 +3112,14 @@ async function createMastraCode(config) {
|
|
|
3065
3112
|
}
|
|
3066
3113
|
} catch {
|
|
3067
3114
|
}
|
|
3068
|
-
const builtinPacks =
|
|
3069
|
-
const builtinOmPacks =
|
|
3070
|
-
const effectiveDefaults =
|
|
3071
|
-
const effectiveObserverModel =
|
|
3072
|
-
const effectiveReflectorModel =
|
|
3115
|
+
const builtinPacks = chunkU3HWL5UG_cjs.getAvailableModePacks(startupAccess);
|
|
3116
|
+
const builtinOmPacks = chunkU3HWL5UG_cjs.getAvailableOmPacks(startupAccess);
|
|
3117
|
+
const effectiveDefaults = chunkU3HWL5UG_cjs.resolveModelDefaults(globalSettings, builtinPacks);
|
|
3118
|
+
const effectiveObserverModel = chunkU3HWL5UG_cjs.resolveOmRoleModel(globalSettings, "observer", builtinOmPacks);
|
|
3119
|
+
const effectiveReflectorModel = chunkU3HWL5UG_cjs.resolveOmRoleModel(globalSettings, "reflector", builtinOmPacks);
|
|
3073
3120
|
const effectiveObservationThreshold = globalSettings.models.omObservationThreshold ?? void 0;
|
|
3074
3121
|
const effectiveReflectionThreshold = globalSettings.models.omReflectionThreshold ?? void 0;
|
|
3122
|
+
const effectiveCavemanObservations = globalSettings.models.omCavemanObservations ?? void 0;
|
|
3075
3123
|
const modes = (config?.modes ?? defaultModes).map((mode) => {
|
|
3076
3124
|
const savedModel = effectiveDefaults[mode.id];
|
|
3077
3125
|
return savedModel ? { ...mode, defaultModelId: savedModel } : mode;
|
|
@@ -3110,6 +3158,9 @@ async function createMastraCode(config) {
|
|
|
3110
3158
|
if (effectiveReflectionThreshold !== void 0) {
|
|
3111
3159
|
globalInitialState.reflectionThreshold = effectiveReflectionThreshold;
|
|
3112
3160
|
}
|
|
3161
|
+
if (effectiveCavemanObservations !== void 0) {
|
|
3162
|
+
globalInitialState.cavemanObservations = effectiveCavemanObservations;
|
|
3163
|
+
}
|
|
3113
3164
|
if (globalSettings.preferences.yolo !== null) {
|
|
3114
3165
|
globalInitialState.yolo = globalSettings.preferences.yolo;
|
|
3115
3166
|
}
|
|
@@ -3132,7 +3183,7 @@ async function createMastraCode(config) {
|
|
|
3132
3183
|
memory,
|
|
3133
3184
|
stateSchema,
|
|
3134
3185
|
subagents,
|
|
3135
|
-
resolveModel: (modelId) =>
|
|
3186
|
+
resolveModel: (modelId) => chunkU3HWL5UG_cjs.resolveModel(modelId),
|
|
3136
3187
|
toolCategoryResolver: chunkOBFBUWOR_cjs.getToolCategory,
|
|
3137
3188
|
initialState: {
|
|
3138
3189
|
projectPath: project.rootPath,
|
|
@@ -3147,7 +3198,7 @@ async function createMastraCode(config) {
|
|
|
3147
3198
|
modes,
|
|
3148
3199
|
heartbeatHandlers: config?.heartbeatHandlers ?? defaultHeartbeatHandlers,
|
|
3149
3200
|
modelAuthChecker: (provider) => {
|
|
3150
|
-
const gatewayKey = authStorage.getStoredApiKey(
|
|
3201
|
+
const gatewayKey = authStorage.getStoredApiKey(chunkU3HWL5UG_cjs.MEMORY_GATEWAY_PROVIDER) ?? process.env["MASTRA_GATEWAY_API_KEY"];
|
|
3151
3202
|
if (gatewayKey) {
|
|
3152
3203
|
const providerConfig = gatewayRegistry.getProviders()[provider];
|
|
3153
3204
|
if (providerConfig?.gateway === "mastra") return true;
|
|
@@ -3171,32 +3222,32 @@ async function createMastraCode(config) {
|
|
|
3171
3222
|
return true;
|
|
3172
3223
|
}
|
|
3173
3224
|
}
|
|
3174
|
-
const customProvider =
|
|
3175
|
-
return provider ===
|
|
3225
|
+
const customProvider = chunkU3HWL5UG_cjs.loadSettings().customProviders.find((entry) => {
|
|
3226
|
+
return provider === chunkU3HWL5UG_cjs.getCustomProviderId(entry.name);
|
|
3176
3227
|
});
|
|
3177
3228
|
if (customProvider) {
|
|
3178
3229
|
return true;
|
|
3179
3230
|
}
|
|
3180
3231
|
return void 0;
|
|
3181
3232
|
},
|
|
3182
|
-
modelUseCountProvider: () =>
|
|
3233
|
+
modelUseCountProvider: () => chunkU3HWL5UG_cjs.loadSettings().modelUseCounts,
|
|
3183
3234
|
modelUseCountTracker: (modelId) => {
|
|
3184
3235
|
try {
|
|
3185
|
-
const settings =
|
|
3236
|
+
const settings = chunkU3HWL5UG_cjs.loadSettings();
|
|
3186
3237
|
settings.modelUseCounts[modelId] = (settings.modelUseCounts[modelId] ?? 0) + 1;
|
|
3187
|
-
|
|
3238
|
+
chunkU3HWL5UG_cjs.saveSettings(settings);
|
|
3188
3239
|
} catch (error) {
|
|
3189
3240
|
console.error("Failed to persist model usage count", error);
|
|
3190
3241
|
}
|
|
3191
3242
|
},
|
|
3192
3243
|
customModelCatalogProvider: () => {
|
|
3193
|
-
const settings =
|
|
3244
|
+
const settings = chunkU3HWL5UG_cjs.loadSettings();
|
|
3194
3245
|
const customModels = [];
|
|
3195
3246
|
for (const provider of settings.customProviders) {
|
|
3196
|
-
const providerId =
|
|
3247
|
+
const providerId = chunkU3HWL5UG_cjs.getCustomProviderId(provider.name);
|
|
3197
3248
|
for (const modelName of provider.models) {
|
|
3198
3249
|
customModels.push({
|
|
3199
|
-
id:
|
|
3250
|
+
id: chunkU3HWL5UG_cjs.toCustomProviderModelId(provider.name, modelName),
|
|
3200
3251
|
provider: providerId,
|
|
3201
3252
|
modelName,
|
|
3202
3253
|
hasApiKey: true,
|
|
@@ -3207,8 +3258,8 @@ async function createMastraCode(config) {
|
|
|
3207
3258
|
return customModels;
|
|
3208
3259
|
},
|
|
3209
3260
|
threadLock: {
|
|
3210
|
-
acquire:
|
|
3211
|
-
release:
|
|
3261
|
+
acquire: chunkU3HWL5UG_cjs.acquireThreadLock,
|
|
3262
|
+
release: chunkU3HWL5UG_cjs.releaseThreadLock
|
|
3212
3263
|
}
|
|
3213
3264
|
});
|
|
3214
3265
|
if (hookManager) {
|
|
@@ -3220,12 +3271,16 @@ async function createMastraCode(config) {
|
|
|
3220
3271
|
}
|
|
3221
3272
|
});
|
|
3222
3273
|
}
|
|
3274
|
+
const cavemanHarness = harness$1;
|
|
3275
|
+
attachCavemanThreadStatePersistence(cavemanHarness);
|
|
3276
|
+
await restoreCavemanForCurrentThread(cavemanHarness).catch(() => {
|
|
3277
|
+
});
|
|
3223
3278
|
return {
|
|
3224
3279
|
harness: harness$1,
|
|
3225
3280
|
mcpManager,
|
|
3226
3281
|
hookManager,
|
|
3227
3282
|
authStorage,
|
|
3228
|
-
resolveModel:
|
|
3283
|
+
resolveModel: chunkU3HWL5UG_cjs.resolveModel,
|
|
3229
3284
|
storageWarning,
|
|
3230
3285
|
observabilityWarning,
|
|
3231
3286
|
builtinPacks,
|
|
@@ -3236,5 +3291,5 @@ async function createMastraCode(config) {
|
|
|
3236
3291
|
|
|
3237
3292
|
exports.createAuthStorage = createAuthStorage;
|
|
3238
3293
|
exports.createMastraCode = createMastraCode;
|
|
3239
|
-
//# sourceMappingURL=chunk-
|
|
3240
|
-
//# sourceMappingURL=chunk-
|
|
3294
|
+
//# sourceMappingURL=chunk-BV5IMX2N.cjs.map
|
|
3295
|
+
//# sourceMappingURL=chunk-BV5IMX2N.cjs.map
|