mastracode 0.22.3-alpha.3 → 0.22.3

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 (60) hide show
  1. package/CHANGELOG.md +130 -0
  2. package/dist/HarnessCompat.d.ts +1 -1
  3. package/dist/HarnessCompat.d.ts.map +1 -1
  4. package/dist/agents/prompts/index.d.ts.map +1 -1
  5. package/dist/analytics.d.ts +1 -1
  6. package/dist/analytics.d.ts.map +1 -1
  7. package/dist/{chunk-M7EWUNTS.cjs → chunk-DJEQBK7L.cjs} +1025 -1005
  8. package/dist/chunk-DJEQBK7L.cjs.map +1 -0
  9. package/dist/{chunk-JJI3USQF.cjs → chunk-EATS4KOR.cjs} +103 -113
  10. package/dist/chunk-EATS4KOR.cjs.map +1 -0
  11. package/dist/{chunk-WWR4AASX.js → chunk-FDDVVRPH.js} +68 -78
  12. package/dist/chunk-FDDVVRPH.js.map +1 -0
  13. package/dist/{chunk-ILHDSFV4.cjs → chunk-NKTZDFIU.cjs} +6 -3
  14. package/dist/chunk-NKTZDFIU.cjs.map +1 -0
  15. package/dist/{chunk-CUQA47X4.js → chunk-OXYE6SUY.js} +113 -93
  16. package/dist/chunk-OXYE6SUY.js.map +1 -0
  17. package/dist/{chunk-VPTZ4CZH.js → chunk-W7Y7QIJA.js} +6 -3
  18. package/dist/chunk-W7Y7QIJA.js.map +1 -0
  19. package/dist/cli.cjs +88 -34
  20. package/dist/cli.cjs.map +1 -1
  21. package/dist/cli.js +76 -21
  22. package/dist/cli.js.map +1 -1
  23. package/dist/headless.d.ts.map +1 -1
  24. package/dist/hooks/config.d.ts.map +1 -1
  25. package/dist/index.cjs +3 -3
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +1 -1
  28. package/dist/providers/openai-codex.d.ts.map +1 -1
  29. package/dist/schema.d.ts +0 -2
  30. package/dist/schema.d.ts.map +1 -1
  31. package/dist/tools/request-sandbox-access.d.ts.map +1 -1
  32. package/dist/tui/commands/hooks.d.ts.map +1 -1
  33. package/dist/tui/components/help-overlay.d.ts.map +1 -1
  34. package/dist/tui/components/plan-approval-inline.d.ts +1 -1
  35. package/dist/tui/components/plan-approval-inline.d.ts.map +1 -1
  36. package/dist/tui/event-dispatch.d.ts.map +1 -1
  37. package/dist/tui/handlers/message.d.ts.map +1 -1
  38. package/dist/tui/handlers/prompts.d.ts +6 -6
  39. package/dist/tui/handlers/prompts.d.ts.map +1 -1
  40. package/dist/tui/handlers/types.d.ts +0 -1
  41. package/dist/tui/handlers/types.d.ts.map +1 -1
  42. package/dist/tui/mastra-tui.d.ts.map +1 -1
  43. package/dist/tui/render-messages.d.ts +0 -4
  44. package/dist/tui/render-messages.d.ts.map +1 -1
  45. package/dist/tui/setup.d.ts.map +1 -1
  46. package/dist/tui/status-line.d.ts.map +1 -1
  47. package/dist/tui.cjs +19 -19
  48. package/dist/tui.js +2 -2
  49. package/dist/utils/signals-pubsub.d.ts +18 -11
  50. package/dist/utils/signals-pubsub.d.ts.map +1 -1
  51. package/dist/utils/slash-command-processor.d.ts.map +1 -1
  52. package/package.json +21 -16
  53. package/dist/agents/subagents/audit-tests.d.ts +0 -10
  54. package/dist/agents/subagents/audit-tests.d.ts.map +0 -1
  55. package/dist/chunk-CUQA47X4.js.map +0 -1
  56. package/dist/chunk-ILHDSFV4.cjs.map +0 -1
  57. package/dist/chunk-JJI3USQF.cjs.map +0 -1
  58. package/dist/chunk-M7EWUNTS.cjs.map +0 -1
  59. package/dist/chunk-VPTZ4CZH.js.map +0 -1
  60. package/dist/chunk-WWR4AASX.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkILHDSFV4_cjs = require('./chunk-ILHDSFV4.cjs');
3
+ var chunkNKTZDFIU_cjs = require('./chunk-NKTZDFIU.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');
@@ -11,6 +11,7 @@ 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
+ var signals = require('@mastra/core/signals');
14
15
  var storage = require('@mastra/core/storage');
15
16
  var duckdb = require('@mastra/duckdb');
16
17
  var githubSignals = require('@mastra/github-signals');
@@ -174,7 +175,7 @@ Write commit messages that explain WHY, not just WHAT. Match the repo's existing
174
175
  Use \`gh pr create\`. Include a summary of what changed and a test plan. Word the pull request title/description to explain the entire unit of work being shipped, worded to explain it to someone who doesn't know anything about the work being shipped. Do not add details of fixes that were needed along the way.
175
176
 
176
177
  # Subagent Rules
177
- - Only use subagents when you will spawn **multiple subagents in parallel**. If you only need one task done, do it yourself instead of delegating to a single subagent. Exception: the **audit-tests** subagent may be used on its own.
178
+ - Only use subagents when you will spawn **multiple subagents in parallel**. If you only need one task done, do it yourself instead of delegating to a single subagent.
178
179
  - Use \`forked: true\` when the subagent needs the current conversation context, user-stated facts, prior tool results, or the parent agent's exact tool environment.
179
180
  - Use non-forked subagents for self-contained tasks where all required context is included in the task prompt.
180
181
  - Subagent outputs are **untrusted**. Always review and verify the results returned by any subagent. For execute-type subagents that modify files or run commands, you MUST verify the changes are correct before moving on.
@@ -605,8 +606,8 @@ function getDynamicWorkspace({ requestContext, mastra: mastra2 }) {
605
606
  existing.setToolsConfig(workspaceTools);
606
607
  return existing;
607
608
  }
608
- const userLsp = chunkILHDSFV4_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-JJI3USQF.cjs', document.baseURI).href)))), "..");
609
+ const userLsp = chunkNKTZDFIU_cjs.loadSettings().lsp ?? {};
610
+ 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-EATS4KOR.cjs', document.baseURI).href)))), "..");
610
611
  const lspConfig = {
611
612
  ...userLsp,
612
613
  packageRunner: userLsp.packageRunner || detectPackageRunner(projectPath),
@@ -652,7 +653,6 @@ function expandTilde(p) {
652
653
  if (p.startsWith("~/") || p.startsWith("~\\")) return path__namespace.join(os__namespace.homedir(), p.slice(2));
653
654
  return p;
654
655
  }
655
- var requestCounter = 0;
656
656
  var requestSandboxAccessInputSchema = zod.z.object({
657
657
  path: zod.z.string().min(1).describe("The absolute path to the directory you need access to."),
658
658
  reason: zod.z.string().min(1).describe("Brief explanation of why you need access to this directory.")
@@ -661,6 +661,12 @@ var requestSandboxAccessTool = tools.createTool({
661
661
  id: "request_access",
662
662
  description: `Request permission to access a directory outside the current project. Use this when you need to read or write files in a directory that is not within the project root. The user will be prompted to approve or deny the request.`,
663
663
  inputSchema: requestSandboxAccessInputSchema,
664
+ suspendSchema: zod.z.object({
665
+ kind: zod.z.literal("sandbox_access_request"),
666
+ path: zod.z.string(),
667
+ reason: zod.z.string()
668
+ }),
669
+ resumeSchema: zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]),
664
670
  execute: async ({ path: requestedPath, reason }, context) => {
665
671
  try {
666
672
  const harnessCtx = context?.requestContext?.get("harness");
@@ -674,37 +680,28 @@ var requestSandboxAccessTool = tools.createTool({
674
680
  isError: false
675
681
  };
676
682
  }
677
- if (!harnessCtx?.emitEvent || !harnessCtx?.registerQuestion) {
678
- return {
679
- content: `Cannot request sandbox access: TUI context not available. The user should manually run /sandbox add ${absolutePath}`,
680
- isError: true
681
- };
683
+ const suspend = context?.agent?.suspend ?? context?.suspend;
684
+ const resumeData = context?.agent?.resumeData ?? context?.resumeData;
685
+ if (resumeData === void 0) {
686
+ if (!suspend) {
687
+ return {
688
+ content: `Cannot request sandbox access: interactive context not available. The user should manually run /sandbox add ${absolutePath}`,
689
+ isError: true
690
+ };
691
+ }
692
+ await suspend({ kind: "sandbox_access_request", path: absolutePath, reason });
693
+ return;
682
694
  }
683
- const questionId = `sandbox_${++requestCounter}_${Date.now()}`;
684
- const answer = await new Promise((resolve3) => {
685
- harnessCtx.registerQuestion({
686
- questionId,
687
- resolve: (answer2) => {
688
- resolve3(Array.isArray(answer2) ? answer2.join(",") : answer2);
689
- }
690
- });
691
- harnessCtx.emitEvent({
692
- type: "sandbox_access_request",
693
- questionId,
694
- path: absolutePath,
695
- reason
696
- });
697
- });
698
- const answerText = Array.isArray(answer) ? answer.join(", ") : answer;
695
+ const answerText = Array.isArray(resumeData) ? resumeData.join(", ") : String(resumeData);
699
696
  const approved = answerText.toLowerCase().startsWith("y") || answerText.toLowerCase() === "approve";
700
697
  if (approved) {
701
- const currentAllowed = harnessCtx.getState?.()?.sandboxAllowedPaths ?? [];
698
+ const currentAllowed = harnessCtx?.getState?.()?.sandboxAllowedPaths ?? [];
702
699
  if (!currentAllowed.includes(absolutePath)) {
703
- harnessCtx.setState?.({
700
+ await harnessCtx?.setState?.({
704
701
  sandboxAllowedPaths: [...currentAllowed, absolutePath]
705
702
  });
706
703
  }
707
- const fs4 = context?.workspace?.filesystem;
704
+ const fs4 = harnessCtx?.workspace?.filesystem ?? context?.workspace?.filesystem;
708
705
  if (fs4 instanceof workspace.LocalFilesystem) {
709
706
  fs4.setAllowedPaths((prev) => [...prev, absolutePath]);
710
707
  }
@@ -991,9 +988,6 @@ ${patchToolGuidance}
991
988
  }
992
989
 
993
990
  // src/agents/prompts/index.ts
994
- function formatTaskPromptValue(value) {
995
- return value.replace(/\s+/g, " ").replace(/[<>{}]/g, (char) => ({ "<": "&lt;", ">": "&gt;", "{": "&#123;", "}": "&#125;" })[char] ?? char).trim();
996
- }
997
991
  var modePrompts = {
998
992
  build: buildModePromptFn,
999
993
  plan: planModePrompt,
@@ -1025,30 +1019,10 @@ function buildFullPrompt(ctx) {
1025
1019
  const entry = modePrompts[ctx.modeId] || modePrompts.build;
1026
1020
  const modeSpecific = (typeof entry === "function" ? entry(ctx) : entry) ?? "";
1027
1021
  const modelSpecific = ctx.modelId ? modelSpecificPrompts[ctx.modelId] ?? "" : "";
1028
- let taskSection = "";
1029
- const tasks = ctx.state?.tasks;
1030
- if (tasks && tasks.length > 0) {
1031
- const lines = tasks.map((t) => {
1032
- const icon = t.status === "completed" ? "\u2713" : t.status === "in_progress" ? "\u25B8" : "\u25CB";
1033
- const id = t.id ? ` {id: ${formatTaskPromptValue(t.id)}}` : "";
1034
- return ` ${icon} [${t.status}]${id} ${formatTaskPromptValue(t.content)}`;
1035
- });
1036
- taskSection = `
1037
- <current-task-list>
1038
- ${lines.join("\n")}
1039
- </current-task-list>
1040
- `;
1041
- }
1042
1022
  const configDir = ctx.state?.configDir;
1043
1023
  const instructionSources = loadAgentInstructions(ctx.workingDir, configDir);
1044
1024
  const instructionsSection = formatAgentInstructions(instructionSources);
1045
- const sections = [
1046
- base,
1047
- taskSection.trim(),
1048
- instructionsSection.trim(),
1049
- modelSpecific.trim(),
1050
- modeSpecific.trim()
1051
- ].filter(Boolean);
1025
+ const sections = [base, instructionsSection.trim(), modelSpecific.trim(), modeSpecific.trim()].filter(Boolean);
1052
1026
  return sections.join("\n\n");
1053
1027
  }
1054
1028
 
@@ -1082,14 +1056,14 @@ function getHarnessState(requestContext) {
1082
1056
  }
1083
1057
  function getObserverModel({ requestContext }) {
1084
1058
  const state = getHarnessState(requestContext);
1085
- return chunkILHDSFV4_cjs.resolveModel(state?.observerModelId ?? chunkJ3ISOP5J_cjs.DEFAULT_OM_MODEL_ID, {
1059
+ return chunkNKTZDFIU_cjs.resolveModel(state?.observerModelId ?? chunkJ3ISOP5J_cjs.DEFAULT_OM_MODEL_ID, {
1086
1060
  remapForCodexOAuth: true,
1087
1061
  requestContext
1088
1062
  });
1089
1063
  }
1090
1064
  function getReflectorModel({ requestContext }) {
1091
1065
  const state = getHarnessState(requestContext);
1092
- return chunkILHDSFV4_cjs.resolveModel(state?.reflectorModelId ?? chunkJ3ISOP5J_cjs.DEFAULT_OM_MODEL_ID, {
1066
+ return chunkNKTZDFIU_cjs.resolveModel(state?.reflectorModelId ?? chunkJ3ISOP5J_cjs.DEFAULT_OM_MODEL_ID, {
1093
1067
  remapForCodexOAuth: true,
1094
1068
  requestContext
1095
1069
  });
@@ -1976,7 +1950,8 @@ var VALID_EVENTS = [
1976
1950
  "Stop",
1977
1951
  "UserPromptSubmit",
1978
1952
  "SessionStart",
1979
- "SessionEnd"
1953
+ "SessionEnd",
1954
+ "Notification"
1980
1955
  ];
1981
1956
  function loadHooksConfig(projectDir, configDirName = chunkJ3ISOP5J_cjs.DEFAULT_CONFIG_DIR) {
1982
1957
  const globalPath = getGlobalHooksPath(configDirName);
@@ -2813,6 +2788,10 @@ function createMcpManager(projectDir, configDirName = chunkJ3ISOP5J_cjs.DEFAULT_
2813
2788
  };
2814
2789
  }
2815
2790
  var stateSchema = zod.z.object({
2791
+ // Session-scoped selection. The legacy Harness stores these in its state and
2792
+ // validates state against this schema, so they MUST be declared here — Zod
2793
+ // strips unknown keys on parse, which would otherwise silently discard the
2794
+ // seeded model and leave the harness with no model selected.
2816
2795
  currentModelId: zod.z.string().optional(),
2817
2796
  modeId: zod.z.string().optional(),
2818
2797
  subagentModelId: zod.z.string().optional(),
@@ -2907,6 +2886,7 @@ async function syncGateways(force = false) {
2907
2886
  isSyncing = false;
2908
2887
  }
2909
2888
  }
2889
+ var THREAD_STREAM_PREFIX = "agent.thread-stream.";
2910
2890
  var SignalsPubSub = class extends events.PubSub {
2911
2891
  #resourceId;
2912
2892
  #sockets = /* @__PURE__ */ new Map();
@@ -2919,16 +2899,16 @@ var SignalsPubSub = class extends events.PubSub {
2919
2899
  get supportedModes() {
2920
2900
  return ["push"];
2921
2901
  }
2922
- async publish(topic, event) {
2902
+ async publish(topic, event, options) {
2923
2903
  const socket = await this.#getOrCreate(topic);
2924
- await socket.publish(topic, event);
2904
+ await socket.publish(topic, event, options);
2925
2905
  }
2926
2906
  async subscribe(topic, cb, options) {
2927
2907
  const socket = await this.#getOrCreate(topic);
2928
2908
  await socket.subscribe(topic, cb, options);
2929
2909
  }
2930
2910
  async unsubscribe(topic, cb) {
2931
- const socket = this.#sockets.get(topic);
2911
+ const socket = this.#sockets.get(this.#topicKey(topic));
2932
2912
  if (!socket) return;
2933
2913
  await socket.unsubscribe(topic, cb);
2934
2914
  }
@@ -2942,42 +2922,51 @@ var SignalsPubSub = class extends events.PubSub {
2942
2922
  }
2943
2923
  /** Get the underlying socket for a topic (for testing/inspection). */
2944
2924
  getSocket(topic) {
2945
- return this.#sockets.get(topic);
2925
+ return this.#sockets.get(this.#topicKey(topic));
2946
2926
  }
2947
2927
  async #getOrCreate(topic) {
2948
2928
  if (this.#closed) throw new Error("SignalsPubSub is closed");
2949
- const existing = this.#sockets.get(topic);
2929
+ const key = this.#topicKey(topic);
2930
+ const existing = this.#sockets.get(key);
2950
2931
  if (existing) return existing;
2951
- let inflight = this.#pending.get(topic);
2932
+ let inflight = this.#pending.get(key);
2952
2933
  if (!inflight) {
2953
- inflight = this.#initSocket(topic);
2954
- this.#pending.set(topic, inflight);
2934
+ inflight = this.#initSocket(topic, key);
2935
+ this.#pending.set(key, inflight);
2955
2936
  }
2956
2937
  const socket = await inflight;
2957
2938
  if (this.#closed) throw new Error("SignalsPubSub is closed");
2958
2939
  return socket;
2959
2940
  }
2960
- async #initSocket(topic) {
2941
+ async #initSocket(topic, key) {
2961
2942
  try {
2962
2943
  const socketPath = await this.#socketPath(topic);
2963
2944
  if (this.#closed) throw new Error("SignalsPubSub is closed");
2964
2945
  const socket = new events.UnixSocketPubSub(socketPath);
2965
- this.#sockets.set(topic, socket);
2946
+ this.#sockets.set(key, socket);
2966
2947
  return socket;
2967
2948
  } finally {
2968
- this.#pending.delete(topic);
2949
+ this.#pending.delete(key);
2969
2950
  }
2970
2951
  }
2971
2952
  async #socketPath(topic) {
2972
- const threadId = this.#extractThreadId(topic);
2953
+ let key = this.#topicKey(topic);
2973
2954
  const dir = path.join("/tmp/mc", this.#resourceId);
2974
2955
  await promises.mkdir(dir, { recursive: true });
2975
- return path.join(dir, `${threadId}.sock`);
2956
+ const candidate = path.join(dir, `${key}.sock`);
2957
+ if (Buffer.byteLength(candidate) > 104) {
2958
+ key = crypto.createHash("sha256").update(key).digest("hex").slice(0, 16);
2959
+ return path.join(dir, `${key}.sock`);
2960
+ }
2961
+ return candidate;
2976
2962
  }
2977
- #extractThreadId(topic) {
2978
- const prefix = "agent.thread-stream.";
2979
- if (topic.startsWith(prefix)) {
2980
- const encoded = topic.slice(prefix.length);
2963
+ /**
2964
+ * Derive a filesystem-safe key for the topic. Thread-stream topics embed
2965
+ * a threadId; all other topics use a sanitized version of the topic name.
2966
+ */
2967
+ #topicKey(topic) {
2968
+ if (topic.startsWith(THREAD_STREAM_PREFIX)) {
2969
+ const encoded = topic.slice(THREAD_STREAM_PREFIX.length);
2981
2970
  try {
2982
2971
  const decoded = decodeURIComponent(encoded);
2983
2972
  const separatorIdx = decoded.indexOf("\0");
@@ -3088,11 +3077,11 @@ function legacyModeToV1(mode, fallbackAgent) {
3088
3077
  const agent = typeof mode.agent === "function" ? mode.agent({}) : mode.agent;
3089
3078
  return {
3090
3079
  id: mode.id,
3091
- agentId: (agent ?? fallbackAgent).id,
3092
3080
  defaultModelId: mode.defaultModelId ?? "openai/gpt-5.5",
3093
3081
  description: mode.name,
3094
3082
  ...mode.id === "plan" ? { transitionsTo: "build" } : {},
3095
3083
  metadata: {
3084
+ agentId: (agent ?? fallbackAgent).id,
3096
3085
  color: mode.color,
3097
3086
  default: mode.default,
3098
3087
  name: mode.name
@@ -3113,15 +3102,15 @@ function applyEffectiveDefaultsToV1Modes(modes, effectiveDefaults) {
3113
3102
  }
3114
3103
  function createAuthStorage() {
3115
3104
  const authStorage = new chunkJ3ISOP5J_cjs.AuthStorage();
3116
- chunkILHDSFV4_cjs.setAuthStorage(authStorage);
3117
- chunkILHDSFV4_cjs.setAuthStorage3(authStorage);
3118
- chunkILHDSFV4_cjs.setAuthStorage2(authStorage);
3105
+ chunkNKTZDFIU_cjs.setAuthStorage(authStorage);
3106
+ chunkNKTZDFIU_cjs.setAuthStorage3(authStorage);
3107
+ chunkNKTZDFIU_cjs.setAuthStorage2(authStorage);
3119
3108
  return authStorage;
3120
3109
  }
3121
3110
  function resolveCloudObservabilityConfig(settings, authStorage, resourceId) {
3122
3111
  const resourceConfig = settings.observability.resources[resourceId];
3123
3112
  if (resourceConfig) {
3124
- const token = authStorage.getStoredApiKey(`${chunkILHDSFV4_cjs.OBSERVABILITY_AUTH_PREFIX}${resourceId}`);
3113
+ const token = authStorage.getStoredApiKey(`${chunkNKTZDFIU_cjs.OBSERVABILITY_AUTH_PREFIX}${resourceId}`);
3125
3114
  if (token) {
3126
3115
  return { accessToken: token, projectId: resourceConfig.projectId };
3127
3116
  }
@@ -3143,8 +3132,8 @@ async function createMastraCode(config) {
3143
3132
  }
3144
3133
  const gatewayRegistry = llm.GatewayRegistry.getInstance({ useDynamicLoading: true });
3145
3134
  const authStorage = createAuthStorage();
3146
- const globalSettings = chunkILHDSFV4_cjs.loadSettings(config?.settingsPath);
3147
- const storedGatewayKey = authStorage.getStoredApiKey(chunkILHDSFV4_cjs.MEMORY_GATEWAY_PROVIDER);
3135
+ const globalSettings = chunkNKTZDFIU_cjs.loadSettings(config?.settingsPath);
3136
+ const storedGatewayKey = authStorage.getStoredApiKey(chunkNKTZDFIU_cjs.MEMORY_GATEWAY_PROVIDER);
3148
3137
  const storedGatewayUrl = globalSettings.memoryGateway?.baseUrl;
3149
3138
  if (storedGatewayKey) {
3150
3139
  process.env["MASTRA_GATEWAY_API_KEY"] ??= storedGatewayKey;
@@ -3159,11 +3148,11 @@ async function createMastraCode(config) {
3159
3148
  const envVars = cfg?.apiKeyEnvVar;
3160
3149
  providerEnvVars[provider] = Array.isArray(envVars) ? envVars[0] : envVars;
3161
3150
  }
3162
- providerEnvVars[chunkILHDSFV4_cjs.MEMORY_GATEWAY_PROVIDER] ??= "MASTRA_GATEWAY_API_KEY";
3151
+ providerEnvVars[chunkNKTZDFIU_cjs.MEMORY_GATEWAY_PROVIDER] ??= "MASTRA_GATEWAY_API_KEY";
3163
3152
  authStorage.loadStoredApiKeysIntoEnv(providerEnvVars);
3164
3153
  } catch {
3165
3154
  authStorage.loadStoredApiKeysIntoEnv({
3166
- [chunkILHDSFV4_cjs.MEMORY_GATEWAY_PROVIDER]: "MASTRA_GATEWAY_API_KEY",
3155
+ [chunkNKTZDFIU_cjs.MEMORY_GATEWAY_PROVIDER]: "MASTRA_GATEWAY_API_KEY",
3167
3156
  anthropic: "ANTHROPIC_API_KEY",
3168
3157
  openai: "OPENAI_API_KEY",
3169
3158
  google: "GOOGLE_GENERATIVE_AI_API_KEY",
@@ -3288,8 +3277,6 @@ async function createMastraCode(config) {
3288
3277
  resourceId,
3289
3278
  modeId: harness$1.getCurrentModeId(),
3290
3279
  workspace: harness$1.getWorkspace(),
3291
- registerQuestion: (params) => harness$1.registerQuestion(params),
3292
- registerPlanApproval: (params) => harness$1.registerPlanApproval(params),
3293
3280
  getSubagentModelId: (params) => harness$1.getSubagentModelId(params)
3294
3281
  };
3295
3282
  requestContext$1.set("harness", harnessContext);
@@ -3307,7 +3294,7 @@ async function createMastraCode(config) {
3307
3294
  id: CODE_AGENT_ID,
3308
3295
  name: "Code Agent",
3309
3296
  instructions: getDynamicInstructions,
3310
- model: chunkILHDSFV4_cjs.getDynamicModel,
3297
+ model: chunkNKTZDFIU_cjs.getDynamicModel,
3311
3298
  tools: createDynamicTools(mcpManager, config?.extraTools, config?.disabledTools, storage$1),
3312
3299
  hooks: createToolHooks(hookManager),
3313
3300
  scorers: {
@@ -3320,7 +3307,10 @@ async function createMastraCode(config) {
3320
3307
  sampling: { type: "ratio", rate: 0.3 }
3321
3308
  }
3322
3309
  },
3323
- signals: githubSignals$1 ? [githubSignals$1] : [],
3310
+ // TaskSignalProvider bundles the task tools + TaskStateProcessor: it merges
3311
+ // the tools into the toolset and registers the task state-signal processor,
3312
+ // so the task list persists across turns and survives OM truncation.
3313
+ signals: [new signals.TaskSignalProvider(), ...githubSignals$1 ? [githubSignals$1] : []],
3324
3314
  inputProcessors: [
3325
3315
  new processors.AgentsMDInjector({
3326
3316
  getIgnoredInstructionPaths: ({ requestContext }) => {
@@ -3337,31 +3327,31 @@ async function createMastraCode(config) {
3337
3327
  const defaultModesV1 = [
3338
3328
  {
3339
3329
  id: "build",
3340
- agentId: CODE_AGENT_ID,
3341
3330
  description: "Build",
3342
3331
  defaultModelId: "anthropic/claude-opus-4-7",
3343
3332
  metadata: {
3344
- color: chunkILHDSFV4_cjs.mastra.green,
3333
+ agentId: CODE_AGENT_ID,
3334
+ color: chunkNKTZDFIU_cjs.mastra.green,
3345
3335
  default: true
3346
3336
  }
3347
3337
  },
3348
3338
  {
3349
3339
  id: "plan",
3350
- agentId: CODE_AGENT_ID,
3351
3340
  description: "Plan",
3352
3341
  transitionsTo: "build",
3353
3342
  defaultModelId: "openai/gpt-5.5",
3354
3343
  metadata: {
3355
- color: chunkILHDSFV4_cjs.mastra.purple
3344
+ agentId: CODE_AGENT_ID,
3345
+ color: chunkNKTZDFIU_cjs.mastra.purple
3356
3346
  }
3357
3347
  },
3358
3348
  {
3359
3349
  id: "fast",
3360
- agentId: CODE_AGENT_ID,
3361
3350
  description: "Fast",
3362
3351
  defaultModelId: "cerebras/zai-glm-4.7",
3363
3352
  metadata: {
3364
- color: chunkILHDSFV4_cjs.mastra.orange
3353
+ agentId: CODE_AGENT_ID,
3354
+ color: chunkNKTZDFIU_cjs.mastra.orange
3365
3355
  }
3366
3356
  }
3367
3357
  ];
@@ -3401,11 +3391,11 @@ async function createMastraCode(config) {
3401
3391
  }
3402
3392
  } catch {
3403
3393
  }
3404
- const builtinPacks = chunkILHDSFV4_cjs.getAvailableModePacks(startupAccess);
3405
- const builtinOmPacks = chunkILHDSFV4_cjs.getAvailableOmPacks(startupAccess);
3406
- const effectiveDefaults = chunkILHDSFV4_cjs.resolveModelDefaults(globalSettings, builtinPacks);
3407
- const effectiveObserverModel = chunkILHDSFV4_cjs.resolveOmRoleModel(globalSettings, "observer", builtinOmPacks);
3408
- const effectiveReflectorModel = chunkILHDSFV4_cjs.resolveOmRoleModel(globalSettings, "reflector", builtinOmPacks);
3394
+ const builtinPacks = chunkNKTZDFIU_cjs.getAvailableModePacks(startupAccess);
3395
+ const builtinOmPacks = chunkNKTZDFIU_cjs.getAvailableOmPacks(startupAccess);
3396
+ const effectiveDefaults = chunkNKTZDFIU_cjs.resolveModelDefaults(globalSettings, builtinPacks);
3397
+ const effectiveObserverModel = chunkNKTZDFIU_cjs.resolveOmRoleModel(globalSettings, "observer", builtinOmPacks);
3398
+ const effectiveReflectorModel = chunkNKTZDFIU_cjs.resolveOmRoleModel(globalSettings, "reflector", builtinOmPacks);
3409
3399
  const effectiveObservationThreshold = globalSettings.models.omObservationThreshold ?? void 0;
3410
3400
  const effectiveReflectionThreshold = globalSettings.models.omReflectionThreshold ?? void 0;
3411
3401
  const effectiveCavemanObservations = globalSettings.models.omCavemanObservations ?? void 0;
@@ -3510,7 +3500,7 @@ async function createMastraCode(config) {
3510
3500
  pubsub: signalsPubSub,
3511
3501
  stateSchema: typedStateSchema,
3512
3502
  subagents,
3513
- resolveModel: (modelId) => chunkILHDSFV4_cjs.resolveModel(modelId),
3503
+ resolveModel: (modelId) => chunkNKTZDFIU_cjs.resolveModel(modelId),
3514
3504
  toolCategoryResolver: chunkJHYTJMKT_cjs.getToolCategory,
3515
3505
  initialState: {
3516
3506
  projectPath: project.rootPath,
@@ -3528,7 +3518,7 @@ async function createMastraCode(config) {
3528
3518
  modes,
3529
3519
  heartbeatHandlers,
3530
3520
  modelAuthChecker: (provider) => {
3531
- const gatewayKey = authStorage.getStoredApiKey(chunkILHDSFV4_cjs.MEMORY_GATEWAY_PROVIDER) ?? process.env["MASTRA_GATEWAY_API_KEY"];
3521
+ const gatewayKey = authStorage.getStoredApiKey(chunkNKTZDFIU_cjs.MEMORY_GATEWAY_PROVIDER) ?? process.env["MASTRA_GATEWAY_API_KEY"];
3532
3522
  if (gatewayKey) {
3533
3523
  const providerConfig = gatewayRegistry.getProviders()[provider];
3534
3524
  if (providerConfig?.gateway === "mastra") return true;
@@ -3552,32 +3542,32 @@ async function createMastraCode(config) {
3552
3542
  return true;
3553
3543
  }
3554
3544
  }
3555
- const customProvider = chunkILHDSFV4_cjs.loadSettings().customProviders.find((entry) => {
3556
- return provider === chunkILHDSFV4_cjs.getCustomProviderId(entry.name);
3545
+ const customProvider = chunkNKTZDFIU_cjs.loadSettings().customProviders.find((entry) => {
3546
+ return provider === chunkNKTZDFIU_cjs.getCustomProviderId(entry.name);
3557
3547
  });
3558
3548
  if (customProvider) {
3559
3549
  return true;
3560
3550
  }
3561
3551
  return void 0;
3562
3552
  },
3563
- modelUseCountProvider: () => chunkILHDSFV4_cjs.loadSettings().modelUseCounts,
3553
+ modelUseCountProvider: () => chunkNKTZDFIU_cjs.loadSettings().modelUseCounts,
3564
3554
  modelUseCountTracker: (modelId) => {
3565
3555
  try {
3566
- const settings = chunkILHDSFV4_cjs.loadSettings();
3556
+ const settings = chunkNKTZDFIU_cjs.loadSettings();
3567
3557
  settings.modelUseCounts[modelId] = (settings.modelUseCounts[modelId] ?? 0) + 1;
3568
- chunkILHDSFV4_cjs.saveSettings(settings);
3558
+ chunkNKTZDFIU_cjs.saveSettings(settings);
3569
3559
  } catch (error) {
3570
3560
  console.error("Failed to persist model usage count", error);
3571
3561
  }
3572
3562
  },
3573
3563
  customModelCatalogProvider: async () => {
3574
- const settings = chunkILHDSFV4_cjs.loadSettings();
3564
+ const settings = chunkNKTZDFIU_cjs.loadSettings();
3575
3565
  const customModels = [];
3576
3566
  for (const provider of settings.customProviders) {
3577
- const providerId = chunkILHDSFV4_cjs.getCustomProviderId(provider.name);
3567
+ const providerId = chunkNKTZDFIU_cjs.getCustomProviderId(provider.name);
3578
3568
  for (const modelName of provider.models) {
3579
3569
  customModels.push({
3580
- id: chunkILHDSFV4_cjs.toCustomProviderModelId(provider.name, modelName),
3570
+ id: chunkNKTZDFIU_cjs.toCustomProviderModelId(provider.name, modelName),
3581
3571
  provider: providerId,
3582
3572
  modelName,
3583
3573
  hasApiKey: true,
@@ -3586,7 +3576,7 @@ async function createMastraCode(config) {
3586
3576
  }
3587
3577
  }
3588
3578
  try {
3589
- const copilotModels = await chunkILHDSFV4_cjs.getCopilotModelCatalog({ authStorage });
3579
+ const copilotModels = await chunkNKTZDFIU_cjs.getCopilotModelCatalog({ authStorage });
3590
3580
  for (const m of copilotModels) {
3591
3581
  customModels.push({
3592
3582
  id: `github-copilot/${m.id}`,
@@ -3602,8 +3592,8 @@ async function createMastraCode(config) {
3602
3592
  return customModels;
3603
3593
  },
3604
3594
  threadLock: crossProcessPubSub ? void 0 : {
3605
- acquire: chunkILHDSFV4_cjs.acquireThreadLock,
3606
- release: chunkILHDSFV4_cjs.releaseThreadLock
3595
+ acquire: chunkNKTZDFIU_cjs.acquireThreadLock,
3596
+ release: chunkNKTZDFIU_cjs.releaseThreadLock
3607
3597
  }
3608
3598
  // , harnessV1
3609
3599
  });
@@ -3650,7 +3640,7 @@ async function createMastraCode(config) {
3650
3640
  hookManager,
3651
3641
  signalsPubSub,
3652
3642
  authStorage,
3653
- resolveModel: chunkILHDSFV4_cjs.resolveModel,
3643
+ resolveModel: chunkNKTZDFIU_cjs.resolveModel,
3654
3644
  storageWarning,
3655
3645
  observabilityWarning,
3656
3646
  builtinPacks,
@@ -3662,5 +3652,5 @@ async function createMastraCode(config) {
3662
3652
 
3663
3653
  exports.createAuthStorage = createAuthStorage;
3664
3654
  exports.createMastraCode = createMastraCode;
3665
- //# sourceMappingURL=chunk-JJI3USQF.cjs.map
3666
- //# sourceMappingURL=chunk-JJI3USQF.cjs.map
3655
+ //# sourceMappingURL=chunk-EATS4KOR.cjs.map
3656
+ //# sourceMappingURL=chunk-EATS4KOR.cjs.map