mastracode 0.22.2 → 0.22.3-alpha.1

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 (45) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/dist/HarnessCompat.d.ts +21 -2
  3. package/dist/HarnessCompat.d.ts.map +1 -1
  4. package/dist/agents/tools.d.ts +4 -3
  5. package/dist/agents/tools.d.ts.map +1 -1
  6. package/dist/agents/workspace.d.ts.map +1 -1
  7. package/dist/{chunk-NFF7IH5X.cjs → chunk-A4W5D25I.cjs} +2 -1096
  8. package/dist/chunk-A4W5D25I.cjs.map +1 -0
  9. package/dist/{chunk-DPPFZEZI.cjs → chunk-AGLPYB76.cjs} +193 -325
  10. package/dist/chunk-AGLPYB76.cjs.map +1 -0
  11. package/dist/{chunk-BOZ3JCCI.cjs → chunk-AXKWCXEW.cjs} +961 -937
  12. package/dist/chunk-AXKWCXEW.cjs.map +1 -0
  13. package/dist/{chunk-7ARENXCP.js → chunk-CD6DZEX6.js} +38 -14
  14. package/dist/chunk-CD6DZEX6.js.map +1 -0
  15. package/dist/{chunk-EXBGEHMR.js → chunk-TWAOLBVC.js} +3 -1094
  16. package/dist/chunk-TWAOLBVC.js.map +1 -0
  17. package/dist/{chunk-AB4G5527.js → chunk-VCIVJV7J.js} +163 -295
  18. package/dist/chunk-VCIVJV7J.js.map +1 -0
  19. package/dist/cli.cjs +18 -18
  20. package/dist/cli.js +3 -3
  21. package/dist/harness-tui-v1.d.ts +2 -0
  22. package/dist/harness-tui-v1.d.ts.map +1 -0
  23. package/dist/index.cjs +3 -3
  24. package/dist/index.d.ts +3 -3
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +1 -1
  27. package/dist/schema.d.ts +11 -4
  28. package/dist/schema.d.ts.map +1 -1
  29. package/dist/tui/event-dispatch.d.ts.map +1 -1
  30. package/dist/tui/handlers/message.d.ts.map +1 -1
  31. package/dist/tui/mastra-tui.d.ts.map +1 -1
  32. package/dist/tui/state.d.ts +3 -1
  33. package/dist/tui/state.d.ts.map +1 -1
  34. package/dist/tui/status-line.d.ts.map +1 -1
  35. package/dist/tui.cjs +19 -19
  36. package/dist/tui.js +2 -2
  37. package/package.json +13 -11
  38. package/dist/chunk-7ARENXCP.js.map +0 -1
  39. package/dist/chunk-AB4G5527.js.map +0 -1
  40. package/dist/chunk-BOZ3JCCI.cjs.map +0 -1
  41. package/dist/chunk-DPPFZEZI.cjs.map +0 -1
  42. package/dist/chunk-EXBGEHMR.js.map +0 -1
  43. package/dist/chunk-NFF7IH5X.cjs.map +0 -1
  44. package/dist/github-signals/index.d.ts +0 -217
  45. package/dist/github-signals/index.d.ts.map +0 -1
@@ -1,18 +1,19 @@
1
1
  'use strict';
2
2
 
3
- var chunkNFF7IH5X_cjs = require('./chunk-NFF7IH5X.cjs');
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 v1 = require('@mastra/core/harness/v1');
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');
@@ -592,6 +592,9 @@ function getDynamicWorkspace({ requestContext, mastra: mastra2 }) {
592
592
  mastra_workspace_edit_file: { ...chunkJHYTJMKT_cjs.TOOL_NAME_OVERRIDES.mastra_workspace_edit_file, enabled: false },
593
593
  mastra_workspace_ast_edit: { ...chunkJHYTJMKT_cjs.TOOL_NAME_OVERRIDES.mastra_workspace_ast_edit, enabled: false }
594
594
  };
595
+ const workspaceTools = {
596
+ ...isPlanMode ? { ...chunkJHYTJMKT_cjs.TOOL_NAME_OVERRIDES, ...planModeTools } : chunkJHYTJMKT_cjs.TOOL_NAME_OVERRIDES
597
+ };
595
598
  let existing;
596
599
  try {
597
600
  existing = mastra2?.getWorkspaceById(workspaceId);
@@ -599,11 +602,11 @@ function getDynamicWorkspace({ requestContext, mastra: mastra2 }) {
599
602
  }
600
603
  if (existing) {
601
604
  existing.filesystem.setAllowedPaths(allowedPaths);
602
- existing.setToolsConfig(isPlanMode ? { ...chunkJHYTJMKT_cjs.TOOL_NAME_OVERRIDES, ...planModeTools } : chunkJHYTJMKT_cjs.TOOL_NAME_OVERRIDES);
605
+ existing.setToolsConfig(workspaceTools);
603
606
  return existing;
604
607
  }
605
- const userLsp = chunkNFF7IH5X_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-DPPFZEZI.cjs', document.baseURI).href)))), "..");
608
+ const userLsp = chunkA4W5D25I_cjs.loadSettings().lsp ?? {};
609
+ 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-AGLPYB76.cjs', document.baseURI).href)))), "..");
607
610
  const lspConfig = {
608
611
  ...userLsp,
609
612
  packageRunner: userLsp.packageRunner || detectPackageRunner(projectPath),
@@ -621,7 +624,7 @@ function getDynamicWorkspace({ requestContext, mastra: mastra2 }) {
621
624
  workingDirectory: projectPath,
622
625
  env: buildSandboxEnv()
623
626
  }),
624
- tools: isPlanMode ? { ...chunkJHYTJMKT_cjs.TOOL_NAME_OVERRIDES, ...planModeTools } : chunkJHYTJMKT_cjs.TOOL_NAME_OVERRIDES,
627
+ tools: workspaceTools,
625
628
  ...skillPaths.length > 0 ? { skills: skillPaths } : {},
626
629
  lsp: lspConfig
627
630
  });
@@ -1052,7 +1055,7 @@ ${lines.join("\n")}
1052
1055
  // src/agents/instructions.ts
1053
1056
  async function getDynamicInstructions({ requestContext }) {
1054
1057
  const harnessContext = requestContext.get("harness");
1055
- const state = harnessContext?.state;
1058
+ const state = harnessContext?.getState?.();
1056
1059
  const modeId = harnessContext?.modeId ?? "build";
1057
1060
  const projectPath = state?.projectPath ?? process.cwd();
1058
1061
  const promptCtx = {
@@ -1079,14 +1082,14 @@ function getHarnessState(requestContext) {
1079
1082
  }
1080
1083
  function getObserverModel({ requestContext }) {
1081
1084
  const state = getHarnessState(requestContext);
1082
- return chunkNFF7IH5X_cjs.resolveModel(state?.observerModelId ?? chunkJ3ISOP5J_cjs.DEFAULT_OM_MODEL_ID, {
1085
+ return chunkA4W5D25I_cjs.resolveModel(state?.observerModelId ?? chunkJ3ISOP5J_cjs.DEFAULT_OM_MODEL_ID, {
1083
1086
  remapForCodexOAuth: true,
1084
1087
  requestContext
1085
1088
  });
1086
1089
  }
1087
1090
  function getReflectorModel({ requestContext }) {
1088
1091
  const state = getHarnessState(requestContext);
1089
- return chunkNFF7IH5X_cjs.resolveModel(state?.reflectorModelId ?? chunkJ3ISOP5J_cjs.DEFAULT_OM_MODEL_ID, {
1092
+ return chunkA4W5D25I_cjs.resolveModel(state?.reflectorModelId ?? chunkJ3ISOP5J_cjs.DEFAULT_OM_MODEL_ID, {
1090
1093
  remapForCodexOAuth: true,
1091
1094
  requestContext
1092
1095
  });
@@ -1369,40 +1372,34 @@ var LazyNotificationsStorage = class extends notifications.NotificationsStorage
1369
1372
  return (await this.getNotificationsStorage()).dangerouslyClearAll();
1370
1373
  }
1371
1374
  };
1372
- function wrapToolWithHooks(toolName, tool, hookManager) {
1373
- if (!hookManager || typeof tool?.execute !== "function") {
1374
- return tool;
1375
- }
1375
+ function createToolHooks(hookManager) {
1376
+ if (!hookManager) return void 0;
1376
1377
  return {
1377
- ...tool,
1378
- async execute(input, toolContext) {
1378
+ beforeToolCall: async ({ toolName, input }) => {
1379
1379
  const preResult = await hookManager.runPreToolUse(toolName, input);
1380
1380
  if (!preResult.allowed) {
1381
1381
  return {
1382
- error: preResult.blockReason ?? `Blocked by PreToolUse hook for tool "${toolName}"`
1383
- };
1384
- }
1385
- let output;
1386
- let toolError = false;
1387
- try {
1388
- output = await tool.execute?.(input, toolContext);
1389
- return output;
1390
- } catch (error) {
1391
- toolError = true;
1392
- output = {
1393
- error: error instanceof Error ? error.message : String(error)
1382
+ proceed: false,
1383
+ output: {
1384
+ error: preResult.blockReason ?? `Blocked by PreToolUse hook for tool "${toolName}"`
1385
+ }
1394
1386
  };
1395
- throw error;
1396
- } finally {
1397
- await hookManager.runPostToolUse(toolName, input, output, toolError).catch(() => void 0);
1398
1387
  }
1388
+ },
1389
+ afterToolCall: async ({ toolName, input, output, error }) => {
1390
+ await hookManager.runPostToolUse(
1391
+ toolName,
1392
+ input,
1393
+ error ? { error: error instanceof Error ? error.message : String(error) } : output,
1394
+ Boolean(error)
1395
+ ).catch(() => void 0);
1399
1396
  }
1400
1397
  };
1401
1398
  }
1402
- function createDynamicTools(mcpManager, extraTools, hookManager, disabledTools, storage) {
1399
+ function createDynamicTools(mcpManager, extraTools, disabledTools, storage) {
1403
1400
  return function getDynamicTools({ requestContext }) {
1404
1401
  const ctx = requestContext.get("harness");
1405
- const state = ctx?.getState();
1402
+ const state = ctx?.getState?.();
1406
1403
  const modelId = state?.currentModelId;
1407
1404
  const isAnthropicModel = modelId?.startsWith("anthropic/");
1408
1405
  const isOpenAIModel = modelId?.startsWith("openai/");
@@ -1449,9 +1446,6 @@ function createDynamicTools(mcpManager, extraTools, hookManager, disabledTools,
1449
1446
  }
1450
1447
  }
1451
1448
  }
1452
- for (const [toolName, tool] of Object.entries(tools)) {
1453
- tools[toolName] = wrapToolWithHooks(toolName, tool, hookManager);
1454
- }
1455
1449
  return tools;
1456
1450
  };
1457
1451
  }
@@ -1976,122 +1970,6 @@ function v1ModeToLegacy(mode, agent) {
1976
1970
  agent
1977
1971
  };
1978
1972
  }
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
1973
  var VALID_EVENTS = [
2096
1974
  "PreToolUse",
2097
1975
  "PostToolUse",
@@ -2935,15 +2813,14 @@ function createMcpManager(projectDir, configDirName = chunkJ3ISOP5J_cjs.DEFAULT_
2935
2813
  };
2936
2814
  }
2937
2815
  var stateSchema = zod.z.object({
2816
+ currentModelId: zod.z.string().optional(),
2817
+ modeId: zod.z.string().optional(),
2818
+ subagentModelId: zod.z.string().optional(),
2938
2819
  projectPath: zod.z.string().optional(),
2939
2820
  projectName: zod.z.string().optional(),
2940
2821
  configDir: zod.z.string().default(chunkJ3ISOP5J_cjs.DEFAULT_CONFIG_DIR),
2941
2822
  gitBranch: zod.z.string().optional(),
2942
2823
  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
2824
  // Observational Memory model settings
2948
2825
  observerModelId: zod.z.string().default(chunkJ3ISOP5J_cjs.DEFAULT_OM_MODEL_ID),
2949
2826
  reflectorModelId: zod.z.string().default(chunkJ3ISOP5J_cjs.DEFAULT_OM_MODEL_ID),
@@ -3236,15 +3113,15 @@ function applyEffectiveDefaultsToV1Modes(modes, effectiveDefaults) {
3236
3113
  }
3237
3114
  function createAuthStorage() {
3238
3115
  const authStorage = new chunkJ3ISOP5J_cjs.AuthStorage();
3239
- chunkNFF7IH5X_cjs.setAuthStorage(authStorage);
3240
- chunkNFF7IH5X_cjs.setAuthStorage3(authStorage);
3241
- chunkNFF7IH5X_cjs.setAuthStorage2(authStorage);
3116
+ chunkA4W5D25I_cjs.setAuthStorage(authStorage);
3117
+ chunkA4W5D25I_cjs.setAuthStorage3(authStorage);
3118
+ chunkA4W5D25I_cjs.setAuthStorage2(authStorage);
3242
3119
  return authStorage;
3243
3120
  }
3244
3121
  function resolveCloudObservabilityConfig(settings, authStorage, resourceId) {
3245
3122
  const resourceConfig = settings.observability.resources[resourceId];
3246
3123
  if (resourceConfig) {
3247
- const token = authStorage.getStoredApiKey(`${chunkNFF7IH5X_cjs.OBSERVABILITY_AUTH_PREFIX}${resourceId}`);
3124
+ const token = authStorage.getStoredApiKey(`${chunkA4W5D25I_cjs.OBSERVABILITY_AUTH_PREFIX}${resourceId}`);
3248
3125
  if (token) {
3249
3126
  return { accessToken: token, projectId: resourceConfig.projectId };
3250
3127
  }
@@ -3266,8 +3143,8 @@ async function createMastraCode(config) {
3266
3143
  }
3267
3144
  const gatewayRegistry = llm.GatewayRegistry.getInstance({ useDynamicLoading: true });
3268
3145
  const authStorage = createAuthStorage();
3269
- const globalSettings = chunkNFF7IH5X_cjs.loadSettings(config?.settingsPath);
3270
- const storedGatewayKey = authStorage.getStoredApiKey(chunkNFF7IH5X_cjs.MEMORY_GATEWAY_PROVIDER);
3146
+ const globalSettings = chunkA4W5D25I_cjs.loadSettings(config?.settingsPath);
3147
+ const storedGatewayKey = authStorage.getStoredApiKey(chunkA4W5D25I_cjs.MEMORY_GATEWAY_PROVIDER);
3271
3148
  const storedGatewayUrl = globalSettings.memoryGateway?.baseUrl;
3272
3149
  if (storedGatewayKey) {
3273
3150
  process.env["MASTRA_GATEWAY_API_KEY"] ??= storedGatewayKey;
@@ -3282,11 +3159,11 @@ async function createMastraCode(config) {
3282
3159
  const envVars = cfg?.apiKeyEnvVar;
3283
3160
  providerEnvVars[provider] = Array.isArray(envVars) ? envVars[0] : envVars;
3284
3161
  }
3285
- providerEnvVars[chunkNFF7IH5X_cjs.MEMORY_GATEWAY_PROVIDER] ??= "MASTRA_GATEWAY_API_KEY";
3162
+ providerEnvVars[chunkA4W5D25I_cjs.MEMORY_GATEWAY_PROVIDER] ??= "MASTRA_GATEWAY_API_KEY";
3286
3163
  authStorage.loadStoredApiKeysIntoEnv(providerEnvVars);
3287
3164
  } catch {
3288
3165
  authStorage.loadStoredApiKeysIntoEnv({
3289
- [chunkNFF7IH5X_cjs.MEMORY_GATEWAY_PROVIDER]: "MASTRA_GATEWAY_API_KEY",
3166
+ [chunkA4W5D25I_cjs.MEMORY_GATEWAY_PROVIDER]: "MASTRA_GATEWAY_API_KEY",
3290
3167
  anthropic: "ANTHROPIC_API_KEY",
3291
3168
  openai: "OPENAI_API_KEY",
3292
3169
  google: "GOOGLE_GENERATIVE_AI_API_KEY",
@@ -3398,13 +3275,41 @@ async function createMastraCode(config) {
3398
3275
  const hookManager = config?.disableHooks ? void 0 : new HookManager(project.rootPath, "session-init", configDir);
3399
3276
  const outcomeScorer = createOutcomeScorer();
3400
3277
  const efficiencyScorer = createEfficiencyScorer();
3401
- const githubSignalsProcessor = globalSettings.signals?.experimentalGithubSignals ? new chunkNFF7IH5X_cjs.GithubSignals({ cwd: project.rootPath }) : void 0;
3278
+ const githubSignals$1 = globalSettings.signals?.experimentalGithubSignals ? new githubSignals.GithubSignals({
3279
+ cwd: project.rootPath,
3280
+ getNotificationStreamOptions: ({ resourceId, threadId }) => {
3281
+ const requestContext$1 = new requestContext.RequestContext();
3282
+ const harnessContext = {
3283
+ harnessId: harness$1.id,
3284
+ state: harness$1.getState(),
3285
+ getState: () => harness$1.getState(),
3286
+ setState: (updates) => harness$1.setState(updates),
3287
+ threadId,
3288
+ resourceId,
3289
+ modeId: harness$1.getCurrentModeId(),
3290
+ workspace: harness$1.getWorkspace(),
3291
+ registerQuestion: (params) => harness$1.registerQuestion(params),
3292
+ registerPlanApproval: (params) => harness$1.registerPlanApproval(params),
3293
+ getSubagentModelId: (params) => harness$1.getSubagentModelId(params)
3294
+ };
3295
+ requestContext$1.set("harness", harnessContext);
3296
+ return {
3297
+ memory: { thread: threadId, resource: resourceId },
3298
+ requestContext: requestContext$1,
3299
+ maxSteps: 1e3,
3300
+ savePerStep: false,
3301
+ requireToolApproval: harness$1.getState().yolo !== true,
3302
+ modelSettings: { temperature: 1 }
3303
+ };
3304
+ }
3305
+ }) : void 0;
3402
3306
  const codeAgent = new agent.Agent({
3403
3307
  id: CODE_AGENT_ID,
3404
3308
  name: "Code Agent",
3405
3309
  instructions: getDynamicInstructions,
3406
- model: chunkNFF7IH5X_cjs.getDynamicModel,
3407
- tools: createDynamicTools(mcpManager, config?.extraTools, hookManager, config?.disabledTools, storage$1),
3310
+ model: chunkA4W5D25I_cjs.getDynamicModel,
3311
+ tools: createDynamicTools(mcpManager, config?.extraTools, config?.disabledTools, storage$1),
3312
+ hooks: createToolHooks(hookManager),
3408
3313
  scorers: {
3409
3314
  outcome: {
3410
3315
  scorer: outcomeScorer,
@@ -3415,6 +3320,7 @@ async function createMastraCode(config) {
3415
3320
  sampling: { type: "ratio", rate: 0.3 }
3416
3321
  }
3417
3322
  },
3323
+ signals: githubSignals$1 ? [githubSignals$1] : [],
3418
3324
  inputProcessors: [
3419
3325
  new processors.AgentsMDInjector({
3420
3326
  getIgnoredInstructionPaths: ({ requestContext }) => {
@@ -3423,38 +3329,10 @@ async function createMastraCode(config) {
3423
3329
  return getStaticallyLoadedInstructionPaths(projectPath);
3424
3330
  }
3425
3331
  }),
3426
- ...githubSignalsProcessor ? [githubSignalsProcessor] : [],
3427
3332
  new processors.ProviderHistoryCompat()
3428
3333
  ],
3429
3334
  errorProcessors: [new processors.StreamErrorRetryProcessor(), new processors.PrefillErrorHandler(), new processors.ProviderHistoryCompat()]
3430
3335
  });
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
3336
  const defaultSubagents = [exploreSubagent, planSubagent, executeSubagent];
3459
3337
  const defaultModesV1 = [
3460
3338
  {
@@ -3463,7 +3341,7 @@ async function createMastraCode(config) {
3463
3341
  description: "Build",
3464
3342
  defaultModelId: "anthropic/claude-opus-4-7",
3465
3343
  metadata: {
3466
- color: chunkNFF7IH5X_cjs.mastra.green,
3344
+ color: chunkA4W5D25I_cjs.mastra.green,
3467
3345
  default: true
3468
3346
  }
3469
3347
  },
@@ -3474,7 +3352,7 @@ async function createMastraCode(config) {
3474
3352
  transitionsTo: "build",
3475
3353
  defaultModelId: "openai/gpt-5.5",
3476
3354
  metadata: {
3477
- color: chunkNFF7IH5X_cjs.mastra.purple
3355
+ color: chunkA4W5D25I_cjs.mastra.purple
3478
3356
  }
3479
3357
  },
3480
3358
  {
@@ -3483,7 +3361,7 @@ async function createMastraCode(config) {
3483
3361
  description: "Fast",
3484
3362
  defaultModelId: "cerebras/zai-glm-4.7",
3485
3363
  metadata: {
3486
- color: chunkNFF7IH5X_cjs.mastra.orange
3364
+ color: chunkA4W5D25I_cjs.mastra.orange
3487
3365
  }
3488
3366
  }
3489
3367
  ];
@@ -3523,11 +3401,11 @@ async function createMastraCode(config) {
3523
3401
  }
3524
3402
  } catch {
3525
3403
  }
3526
- const builtinPacks = chunkNFF7IH5X_cjs.getAvailableModePacks(startupAccess);
3527
- const builtinOmPacks = chunkNFF7IH5X_cjs.getAvailableOmPacks(startupAccess);
3528
- const effectiveDefaults = chunkNFF7IH5X_cjs.resolveModelDefaults(globalSettings, builtinPacks);
3529
- const effectiveObserverModel = chunkNFF7IH5X_cjs.resolveOmRoleModel(globalSettings, "observer", builtinOmPacks);
3530
- const effectiveReflectorModel = chunkNFF7IH5X_cjs.resolveOmRoleModel(globalSettings, "reflector", builtinOmPacks);
3404
+ const builtinPacks = chunkA4W5D25I_cjs.getAvailableModePacks(startupAccess);
3405
+ const builtinOmPacks = chunkA4W5D25I_cjs.getAvailableOmPacks(startupAccess);
3406
+ const effectiveDefaults = chunkA4W5D25I_cjs.resolveModelDefaults(globalSettings, builtinPacks);
3407
+ const effectiveObserverModel = chunkA4W5D25I_cjs.resolveOmRoleModel(globalSettings, "observer", builtinOmPacks);
3408
+ const effectiveReflectorModel = chunkA4W5D25I_cjs.resolveOmRoleModel(globalSettings, "reflector", builtinOmPacks);
3531
3409
  const effectiveObservationThreshold = globalSettings.models.omObservationThreshold ?? void 0;
3532
3410
  const effectiveReflectionThreshold = globalSettings.models.omReflectionThreshold ?? void 0;
3533
3411
  const effectiveCavemanObservations = globalSettings.models.omCavemanObservations ?? void 0;
@@ -3622,125 +3500,115 @@ async function createMastraCode(config) {
3622
3500
  });
3623
3501
  })
3624
3502
  );
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
3503
  const typedStateSchema = stateSchema;
3634
- const harness = new HarnessCompat(
3635
- {
3636
- id: "mastra-code",
3637
- resourceId: project.resourceId,
3638
- storage: storage$1,
3639
- observability: observability$1,
3640
- memory,
3641
- pubsub: signalsPubSub,
3642
- stateSchema: typedStateSchema,
3643
- subagents,
3644
- resolveModel: (modelId) => chunkNFF7IH5X_cjs.resolveModel(modelId),
3645
- toolCategoryResolver: chunkJHYTJMKT_cjs.getToolCategory,
3646
- initialState: {
3647
- projectPath: project.rootPath,
3648
- projectName: project.name,
3649
- gitBranch: project.gitBranch,
3650
- yolo: true,
3651
- ...globalInitialState,
3652
- ...config?.initialState,
3653
- // configDir must always win over initialState spreads to stay in sync
3654
- // with MCP/hooks/storage which were already initialized with this value.
3655
- configDir
3656
- },
3657
- workspace: config?.workspace ?? getDynamicWorkspace,
3658
- browser: config?.browser,
3659
- modes,
3660
- heartbeatHandlers,
3661
- modelAuthChecker: (provider) => {
3662
- const gatewayKey = authStorage.getStoredApiKey(chunkNFF7IH5X_cjs.MEMORY_GATEWAY_PROVIDER) ?? process.env["MASTRA_GATEWAY_API_KEY"];
3663
- if (gatewayKey) {
3664
- const providerConfig = gatewayRegistry.getProviders()[provider];
3665
- if (providerConfig?.gateway === "mastra") return true;
3666
- }
3667
- const oauthId = PROVIDER_TO_OAUTH_ID[provider];
3668
- if (oauthId && authStorage.isLoggedIn(oauthId)) {
3669
- return true;
3670
- }
3671
- if (authStorage.hasStoredApiKey(provider)) {
3504
+ const harness$1 = new harness.Harness({
3505
+ id: "mastra-code",
3506
+ resourceId: project.resourceId,
3507
+ storage: storage$1,
3508
+ observability: observability$1,
3509
+ memory,
3510
+ pubsub: signalsPubSub,
3511
+ stateSchema: typedStateSchema,
3512
+ subagents,
3513
+ resolveModel: (modelId) => chunkA4W5D25I_cjs.resolveModel(modelId),
3514
+ toolCategoryResolver: chunkJHYTJMKT_cjs.getToolCategory,
3515
+ initialState: {
3516
+ projectPath: project.rootPath,
3517
+ projectName: project.name,
3518
+ gitBranch: project.gitBranch,
3519
+ yolo: true,
3520
+ ...globalInitialState,
3521
+ ...config?.initialState,
3522
+ // configDir must always win over initialState spreads to stay in sync
3523
+ // with MCP/hooks/storage which were already initialized with this value.
3524
+ configDir
3525
+ },
3526
+ workspace: config?.workspace ?? ((args) => getDynamicWorkspace(args)),
3527
+ browser: config?.browser,
3528
+ modes,
3529
+ heartbeatHandlers,
3530
+ modelAuthChecker: (provider) => {
3531
+ const gatewayKey = authStorage.getStoredApiKey(chunkA4W5D25I_cjs.MEMORY_GATEWAY_PROVIDER) ?? process.env["MASTRA_GATEWAY_API_KEY"];
3532
+ if (gatewayKey) {
3533
+ const providerConfig = gatewayRegistry.getProviders()[provider];
3534
+ if (providerConfig?.gateway === "mastra") return true;
3535
+ }
3536
+ const oauthId = PROVIDER_TO_OAUTH_ID[provider];
3537
+ if (oauthId && authStorage.isLoggedIn(oauthId)) {
3538
+ return true;
3539
+ }
3540
+ if (authStorage.hasStoredApiKey(provider)) {
3541
+ return true;
3542
+ }
3543
+ if (provider === "anthropic") {
3544
+ const cred = authStorage.get("anthropic");
3545
+ if (cred?.type === "api_key" && cred.key.trim().length > 0) {
3672
3546
  return true;
3673
3547
  }
3674
- if (provider === "anthropic") {
3675
- const cred = authStorage.get("anthropic");
3676
- if (cred?.type === "api_key" && cred.key.trim().length > 0) {
3677
- return true;
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) {
3548
+ }
3549
+ if (provider === "openai") {
3550
+ const cred = authStorage.get("openai-codex");
3551
+ if (cred?.type === "api_key" && cred.key.trim().length > 0) {
3690
3552
  return true;
3691
3553
  }
3692
- return void 0;
3693
- },
3694
- modelUseCountProvider: () => chunkNFF7IH5X_cjs.loadSettings().modelUseCounts,
3695
- modelUseCountTracker: (modelId) => {
3696
- try {
3697
- const settings = chunkNFF7IH5X_cjs.loadSettings();
3698
- settings.modelUseCounts[modelId] = (settings.modelUseCounts[modelId] ?? 0) + 1;
3699
- chunkNFF7IH5X_cjs.saveSettings(settings);
3700
- } catch (error) {
3701
- console.error("Failed to persist model usage count", error);
3702
- }
3703
- },
3704
- customModelCatalogProvider: async () => {
3705
- const settings = chunkNFF7IH5X_cjs.loadSettings();
3706
- const customModels = [];
3707
- for (const provider of settings.customProviders) {
3708
- const providerId = chunkNFF7IH5X_cjs.getCustomProviderId(provider.name);
3709
- for (const modelName of provider.models) {
3710
- customModels.push({
3711
- id: chunkNFF7IH5X_cjs.toCustomProviderModelId(provider.name, modelName),
3712
- provider: providerId,
3713
- modelName,
3714
- hasApiKey: true,
3715
- apiKeyEnvVar: void 0
3716
- });
3717
- }
3554
+ }
3555
+ const customProvider = chunkA4W5D25I_cjs.loadSettings().customProviders.find((entry) => {
3556
+ return provider === chunkA4W5D25I_cjs.getCustomProviderId(entry.name);
3557
+ });
3558
+ if (customProvider) {
3559
+ return true;
3560
+ }
3561
+ return void 0;
3562
+ },
3563
+ modelUseCountProvider: () => chunkA4W5D25I_cjs.loadSettings().modelUseCounts,
3564
+ modelUseCountTracker: (modelId) => {
3565
+ try {
3566
+ const settings = chunkA4W5D25I_cjs.loadSettings();
3567
+ settings.modelUseCounts[modelId] = (settings.modelUseCounts[modelId] ?? 0) + 1;
3568
+ chunkA4W5D25I_cjs.saveSettings(settings);
3569
+ } catch (error) {
3570
+ console.error("Failed to persist model usage count", error);
3571
+ }
3572
+ },
3573
+ customModelCatalogProvider: async () => {
3574
+ const settings = chunkA4W5D25I_cjs.loadSettings();
3575
+ const customModels = [];
3576
+ for (const provider of settings.customProviders) {
3577
+ const providerId = chunkA4W5D25I_cjs.getCustomProviderId(provider.name);
3578
+ for (const modelName of provider.models) {
3579
+ customModels.push({
3580
+ id: chunkA4W5D25I_cjs.toCustomProviderModelId(provider.name, modelName),
3581
+ provider: providerId,
3582
+ modelName,
3583
+ hasApiKey: true,
3584
+ apiKeyEnvVar: void 0
3585
+ });
3718
3586
  }
3719
- try {
3720
- const copilotModels = await chunkNFF7IH5X_cjs.getCopilotModelCatalog({ authStorage });
3721
- for (const m of copilotModels) {
3722
- customModels.push({
3723
- id: `github-copilot/${m.id}`,
3724
- provider: "github-copilot",
3725
- modelName: m.id,
3726
- hasApiKey: true,
3727
- apiKeyEnvVar: void 0
3728
- });
3729
- }
3730
- } catch (error) {
3731
- console.warn("Failed to load GitHub Copilot model catalog:", error);
3587
+ }
3588
+ try {
3589
+ const copilotModels = await chunkA4W5D25I_cjs.getCopilotModelCatalog({ authStorage });
3590
+ for (const m of copilotModels) {
3591
+ customModels.push({
3592
+ id: `github-copilot/${m.id}`,
3593
+ provider: "github-copilot",
3594
+ modelName: m.id,
3595
+ hasApiKey: true,
3596
+ apiKeyEnvVar: void 0
3597
+ });
3732
3598
  }
3733
- return customModels;
3734
- },
3735
- threadLock: crossProcessPubSub ? void 0 : {
3736
- acquire: chunkNFF7IH5X_cjs.acquireThreadLock,
3737
- release: chunkNFF7IH5X_cjs.releaseThreadLock
3599
+ } catch (error) {
3600
+ console.warn("Failed to load GitHub Copilot model catalog:", error);
3738
3601
  }
3602
+ return customModels;
3739
3603
  },
3740
- harnessV1
3741
- );
3604
+ threadLock: crossProcessPubSub ? void 0 : {
3605
+ acquire: chunkA4W5D25I_cjs.acquireThreadLock,
3606
+ release: chunkA4W5D25I_cjs.releaseThreadLock
3607
+ }
3608
+ // , harnessV1
3609
+ });
3742
3610
  if (hookManager) {
3743
- harness.subscribe((event) => {
3611
+ harness$1.subscribe((event) => {
3744
3612
  if (event.type === "thread_changed") {
3745
3613
  hookManager.setSessionId(event.threadId);
3746
3614
  } else if (event.type === "thread_created") {
@@ -3748,17 +3616,17 @@ async function createMastraCode(config) {
3748
3616
  }
3749
3617
  });
3750
3618
  }
3751
- if (githubSignalsProcessor) {
3619
+ if (githubSignals$1) {
3752
3620
  const startGithubPollingForCurrentThread = async (threadId) => {
3753
3621
  if (!threadId) return;
3754
- githubSignalsProcessor.stopAllPolling();
3622
+ githubSignals$1.stopAllPolling();
3755
3623
  try {
3756
- const threads2 = await harness.listThreads({ allResources: true });
3624
+ const threads2 = await harness$1.listThreads({ allResources: true });
3757
3625
  const thread = threads2.find((item) => item.id === threadId);
3758
- await githubSignalsProcessor.startPollingForThread(
3626
+ await githubSignals$1.startPollingForThread(
3759
3627
  {
3760
3628
  threadId,
3761
- resourceId: thread?.resourceId ?? harness.getResourceId()
3629
+ resourceId: thread?.resourceId ?? harness$1.getResourceId()
3762
3630
  },
3763
3631
  { pollImmediately: true }
3764
3632
  );
@@ -3766,33 +3634,33 @@ async function createMastraCode(config) {
3766
3634
  console.warn("Failed to start GitHub PR polling:", error);
3767
3635
  }
3768
3636
  };
3769
- harness.subscribe((event) => {
3637
+ harness$1.subscribe((event) => {
3770
3638
  if (event.type === "thread_changed") void startGithubPollingForCurrentThread(event.threadId);
3771
3639
  else if (event.type === "thread_created") void startGithubPollingForCurrentThread(event.thread.id);
3772
3640
  });
3773
- void startGithubPollingForCurrentThread(harness.getCurrentThreadId());
3641
+ void startGithubPollingForCurrentThread(harness$1.getCurrentThreadId());
3774
3642
  }
3775
- const omThreadStateHarness = harness;
3643
+ const omThreadStateHarness = harness$1;
3776
3644
  attachOMThreadStatePersistence(omThreadStateHarness);
3777
3645
  await restoreOMThreadStateForCurrentThread(omThreadStateHarness).catch(() => {
3778
3646
  });
3779
3647
  return {
3780
- harness,
3648
+ harness: harness$1,
3781
3649
  mcpManager,
3782
3650
  hookManager,
3783
3651
  signalsPubSub,
3784
3652
  authStorage,
3785
- resolveModel: chunkNFF7IH5X_cjs.resolveModel,
3653
+ resolveModel: chunkA4W5D25I_cjs.resolveModel,
3786
3654
  storageWarning,
3787
3655
  observabilityWarning,
3788
3656
  builtinPacks,
3789
3657
  builtinOmPacks,
3790
3658
  effectiveDefaults,
3791
- githubSignals: githubSignalsProcessor
3659
+ githubSignals: githubSignals$1
3792
3660
  };
3793
3661
  }
3794
3662
 
3795
3663
  exports.createAuthStorage = createAuthStorage;
3796
3664
  exports.createMastraCode = createMastraCode;
3797
- //# sourceMappingURL=chunk-DPPFZEZI.cjs.map
3798
- //# sourceMappingURL=chunk-DPPFZEZI.cjs.map
3665
+ //# sourceMappingURL=chunk-AGLPYB76.cjs.map
3666
+ //# sourceMappingURL=chunk-AGLPYB76.cjs.map