mastracode 0.21.2 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/HarnessCompat.d.ts +21 -2
  3. package/dist/HarnessCompat.d.ts.map +1 -1
  4. package/dist/agents/prompts/tool-guidance.d.ts.map +1 -1
  5. package/dist/agents/tools.d.ts +2 -1
  6. package/dist/agents/tools.d.ts.map +1 -1
  7. package/dist/{chunk-HFGEUXMI.js → chunk-7ZTY5SBK.js} +1154 -13
  8. package/dist/chunk-7ZTY5SBK.js.map +1 -0
  9. package/dist/{chunk-MNOWL5GQ.cjs → chunk-B4IKAUT7.cjs} +3533 -2776
  10. package/dist/chunk-B4IKAUT7.cjs.map +1 -0
  11. package/dist/{chunk-YRX4OMQN.js → chunk-BFO3NTQO.js} +2671 -1914
  12. package/dist/chunk-BFO3NTQO.js.map +1 -0
  13. package/dist/{chunk-A4TDK7QP.cjs → chunk-DFC5V3P7.cjs} +267 -103
  14. package/dist/chunk-DFC5V3P7.cjs.map +1 -0
  15. package/dist/{chunk-DJBUYADN.cjs → chunk-EAUXUMEB.cjs} +1157 -12
  16. package/dist/chunk-EAUXUMEB.cjs.map +1 -0
  17. package/dist/{chunk-AWYGW5ZV.cjs → chunk-JHYTJMKT.cjs} +7 -3
  18. package/dist/chunk-JHYTJMKT.cjs.map +1 -0
  19. package/dist/{chunk-TTAAM2XR.js → chunk-UOFNLVKF.js} +7 -3
  20. package/dist/chunk-UOFNLVKF.js.map +1 -0
  21. package/dist/{chunk-J4DYNVTI.js → chunk-Y5AUV6T3.js} +202 -38
  22. package/dist/chunk-Y5AUV6T3.js.map +1 -0
  23. package/dist/cli.cjs +27 -19
  24. package/dist/cli.cjs.map +1 -1
  25. package/dist/cli.js +12 -4
  26. package/dist/cli.js.map +1 -1
  27. package/dist/github-signals/index.d.ts +217 -0
  28. package/dist/github-signals/index.d.ts.map +1 -0
  29. package/dist/headless.d.ts.map +1 -1
  30. package/dist/index.cjs +3 -3
  31. package/dist/index.d.ts +3 -1
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +1 -1
  34. package/dist/onboarding/settings.d.ts +2 -0
  35. package/dist/onboarding/settings.d.ts.map +1 -1
  36. package/dist/permissions-RL7PPO42.cjs +40 -0
  37. package/dist/{permissions-GWY37IEK.cjs.map → permissions-RL7PPO42.cjs.map} +1 -1
  38. package/dist/permissions-TJGRCT4O.js +3 -0
  39. package/dist/{permissions-EDE3D2DA.js.map → permissions-TJGRCT4O.js.map} +1 -1
  40. package/dist/permissions.d.ts.map +1 -1
  41. package/dist/schema.d.ts +7 -4
  42. package/dist/schema.d.ts.map +1 -1
  43. package/dist/tool-names.d.ts +1 -0
  44. package/dist/tool-names.d.ts.map +1 -1
  45. package/dist/tui/command-dispatch.d.ts.map +1 -1
  46. package/dist/tui/commands/github.d.ts +3 -0
  47. package/dist/tui/commands/github.d.ts.map +1 -0
  48. package/dist/tui/commands/index.d.ts +1 -0
  49. package/dist/tui/commands/index.d.ts.map +1 -1
  50. package/dist/tui/commands/settings.d.ts.map +1 -1
  51. package/dist/tui/components/help-overlay.d.ts.map +1 -1
  52. package/dist/tui/components/notification-summary.d.ts +12 -0
  53. package/dist/tui/components/notification-summary.d.ts.map +1 -0
  54. package/dist/tui/components/notification.d.ts +14 -0
  55. package/dist/tui/components/notification.d.ts.map +1 -0
  56. package/dist/tui/components/reactive-signal.d.ts +11 -0
  57. package/dist/tui/components/reactive-signal.d.ts.map +1 -0
  58. package/dist/tui/components/settings.d.ts +2 -0
  59. package/dist/tui/components/settings.d.ts.map +1 -1
  60. package/dist/tui/components/state-signal.d.ts +13 -0
  61. package/dist/tui/components/state-signal.d.ts.map +1 -0
  62. package/dist/tui/event-dispatch.d.ts.map +1 -1
  63. package/dist/tui/handlers/message.d.ts.map +1 -1
  64. package/dist/tui/mastra-tui.d.ts.map +1 -1
  65. package/dist/tui/render-messages.d.ts.map +1 -1
  66. package/dist/tui/setup.d.ts.map +1 -1
  67. package/dist/tui/state.d.ts +14 -0
  68. package/dist/tui/state.d.ts.map +1 -1
  69. package/dist/tui/status-line.d.ts.map +1 -1
  70. package/dist/tui.cjs +19 -19
  71. package/dist/tui.js +2 -2
  72. package/package.json +10 -10
  73. package/dist/chunk-A4TDK7QP.cjs.map +0 -1
  74. package/dist/chunk-AWYGW5ZV.cjs.map +0 -1
  75. package/dist/chunk-DJBUYADN.cjs.map +0 -1
  76. package/dist/chunk-HFGEUXMI.js.map +0 -1
  77. package/dist/chunk-J4DYNVTI.js.map +0 -1
  78. package/dist/chunk-MNOWL5GQ.cjs.map +0 -1
  79. package/dist/chunk-TTAAM2XR.js.map +0 -1
  80. package/dist/chunk-YRX4OMQN.js.map +0 -1
  81. package/dist/permissions-EDE3D2DA.js +0 -3
  82. package/dist/permissions-GWY37IEK.cjs +0 -40
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkDJBUYADN_cjs = require('./chunk-DJBUYADN.cjs');
3
+ var chunkEAUXUMEB_cjs = require('./chunk-EAUXUMEB.cjs');
4
4
  var chunkJ3ISOP5J_cjs = require('./chunk-J3ISOP5J.cjs');
5
- var chunkAWYGW5ZV_cjs = require('./chunk-AWYGW5ZV.cjs');
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');
@@ -10,6 +10,7 @@ var agent = require('@mastra/core/agent');
10
10
  var v1 = require('@mastra/core/harness/v1');
11
11
  var llm = require('@mastra/core/llm');
12
12
  var processors = require('@mastra/core/processors');
13
+ var requestContext = require('@mastra/core/request-context');
13
14
  var storage = require('@mastra/core/storage');
14
15
  var duckdb = require('@mastra/duckdb');
15
16
  var observability = require('@mastra/observability');
@@ -25,6 +26,7 @@ var fastembed = require('@mastra/fastembed');
25
26
  var memory = require('@mastra/memory');
26
27
  var anthropic = require('@ai-sdk/anthropic');
27
28
  var openai = require('@ai-sdk/openai');
29
+ var notifications = require('@mastra/core/notifications');
28
30
  var evals = require('@mastra/core/evals');
29
31
  var harness = require('@mastra/core/harness');
30
32
  var mcp = require('@mastra/mcp');
@@ -586,9 +588,9 @@ function getDynamicWorkspace({ requestContext, mastra: mastra2 }) {
586
588
  const allowedPaths = [...skillPaths, ...DEFAULT_ALLOWED_PATHS, ...sandboxPaths.map((p) => path__namespace.default.resolve(p))];
587
589
  const isPlanMode = modeId === "plan";
588
590
  const planModeTools = {
589
- mastra_workspace_write_file: { ...chunkAWYGW5ZV_cjs.TOOL_NAME_OVERRIDES.mastra_workspace_write_file, enabled: false },
590
- mastra_workspace_edit_file: { ...chunkAWYGW5ZV_cjs.TOOL_NAME_OVERRIDES.mastra_workspace_edit_file, enabled: false },
591
- mastra_workspace_ast_edit: { ...chunkAWYGW5ZV_cjs.TOOL_NAME_OVERRIDES.mastra_workspace_ast_edit, enabled: false }
591
+ mastra_workspace_write_file: { ...chunkJHYTJMKT_cjs.TOOL_NAME_OVERRIDES.mastra_workspace_write_file, enabled: false },
592
+ mastra_workspace_edit_file: { ...chunkJHYTJMKT_cjs.TOOL_NAME_OVERRIDES.mastra_workspace_edit_file, enabled: false },
593
+ mastra_workspace_ast_edit: { ...chunkJHYTJMKT_cjs.TOOL_NAME_OVERRIDES.mastra_workspace_ast_edit, enabled: false }
592
594
  };
593
595
  let existing;
594
596
  try {
@@ -597,11 +599,11 @@ function getDynamicWorkspace({ requestContext, mastra: mastra2 }) {
597
599
  }
598
600
  if (existing) {
599
601
  existing.filesystem.setAllowedPaths(allowedPaths);
600
- existing.setToolsConfig(isPlanMode ? { ...chunkAWYGW5ZV_cjs.TOOL_NAME_OVERRIDES, ...planModeTools } : chunkAWYGW5ZV_cjs.TOOL_NAME_OVERRIDES);
602
+ existing.setToolsConfig(isPlanMode ? { ...chunkJHYTJMKT_cjs.TOOL_NAME_OVERRIDES, ...planModeTools } : chunkJHYTJMKT_cjs.TOOL_NAME_OVERRIDES);
601
603
  return existing;
602
604
  }
603
- const userLsp = chunkDJBUYADN_cjs.loadSettings().lsp ?? {};
604
- 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-A4TDK7QP.cjs', document.baseURI).href)))), "..");
605
+ const userLsp = chunkEAUXUMEB_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-DFC5V3P7.cjs', document.baseURI).href)))), "..");
605
607
  const lspConfig = {
606
608
  ...userLsp,
607
609
  packageRunner: userLsp.packageRunner || detectPackageRunner(projectPath),
@@ -619,7 +621,7 @@ function getDynamicWorkspace({ requestContext, mastra: mastra2 }) {
619
621
  workingDirectory: projectPath,
620
622
  env: buildSandboxEnv()
621
623
  }),
622
- tools: isPlanMode ? { ...chunkAWYGW5ZV_cjs.TOOL_NAME_OVERRIDES, ...planModeTools } : chunkAWYGW5ZV_cjs.TOOL_NAME_OVERRIDES,
624
+ tools: isPlanMode ? { ...chunkJHYTJMKT_cjs.TOOL_NAME_OVERRIDES, ...planModeTools } : chunkJHYTJMKT_cjs.TOOL_NAME_OVERRIDES,
623
625
  ...skillPaths.length > 0 ? { skills: skillPaths } : {},
624
626
  lsp: lspConfig
625
627
  });
@@ -825,74 +827,82 @@ IMPORTANT: You can ONLY call tools by their exact registered names listed below.
825
827
 
826
828
  You have access to the following tools. Use the RIGHT tool for the job:`);
827
829
  const readTools = [];
828
- if (!denied.has(chunkAWYGW5ZV_cjs.MC_TOOLS.VIEW)) {
830
+ if (!denied.has(chunkJHYTJMKT_cjs.MC_TOOLS.VIEW)) {
829
831
  readTools.push(`
830
- **${chunkAWYGW5ZV_cjs.MC_TOOLS.VIEW}** \u2014 Read file contents
832
+ **${chunkJHYTJMKT_cjs.MC_TOOLS.VIEW}** \u2014 Read file contents
831
833
  - Use this to read files before editing them. NEVER propose changes to code you haven't read.
832
834
  - Use \`offset\` (1-indexed start line) and \`limit\` (number of lines) for large files.
833
835
  - Example: Read lines 50-100: \`{ path: "src/big-file.ts", offset: 50, limit: 51 }\`
834
- - To list directories, use \`${chunkAWYGW5ZV_cjs.MC_TOOLS.FIND_FILES}\` instead.`);
836
+ - To list directories, use \`${chunkJHYTJMKT_cjs.MC_TOOLS.FIND_FILES}\` instead.`);
835
837
  }
836
- if (!denied.has(chunkAWYGW5ZV_cjs.MC_TOOLS.SEARCH_CONTENT)) {
838
+ if (!denied.has(chunkJHYTJMKT_cjs.MC_TOOLS.SEARCH_CONTENT)) {
837
839
  readTools.push(`
838
- **${chunkAWYGW5ZV_cjs.MC_TOOLS.SEARCH_CONTENT}** \u2014 Search file contents using regex
840
+ **${chunkJHYTJMKT_cjs.MC_TOOLS.SEARCH_CONTENT}** \u2014 Search file contents using regex
839
841
  - Preferred for content search (finding functions, variables, error messages, imports, etc.)
840
842
  - Use \`path\` to filter by directory or glob pattern. Supports \`contextLines\`, \`caseSensitive\`, and \`maxCount\`.
841
843
  - Example: Find a function: \`{ pattern: "function handleSubmit", path: "**/*.ts" }\`
842
844
  - Example: Find imports: \`{ pattern: "from ['\\"\\]express['\\"\\]", path: "**/*.ts" }\`
843
845
  - Respects .gitignore by default.`);
844
846
  }
845
- if (!denied.has(chunkAWYGW5ZV_cjs.MC_TOOLS.FIND_FILES)) {
847
+ if (!denied.has(chunkJHYTJMKT_cjs.MC_TOOLS.FIND_FILES)) {
846
848
  readTools.push(`
847
- **${chunkAWYGW5ZV_cjs.MC_TOOLS.FIND_FILES}** \u2014 List files and directories as a tree
849
+ **${chunkJHYTJMKT_cjs.MC_TOOLS.FIND_FILES}** \u2014 List files and directories as a tree
848
850
  - Preferred for exploring project structure and finding files by pattern.
849
851
  - Returns tree-style output. Respects .gitignore by default.
850
852
  - Example: List project root: \`{ path: "./" }\`
851
853
  - Example: Find test files: \`{ path: "./src", pattern: "**/*.test.ts" }\`
852
854
  - Example: Find config files: \`{ pattern: "*.config.{js,ts,json}" }\``);
853
855
  }
854
- if (!denied.has(chunkAWYGW5ZV_cjs.MC_TOOLS.EXECUTE_COMMAND)) {
856
+ if (!denied.has(chunkJHYTJMKT_cjs.MC_TOOLS.EXECUTE_COMMAND)) {
855
857
  readTools.push(`
856
- **${chunkAWYGW5ZV_cjs.MC_TOOLS.EXECUTE_COMMAND}** \u2014 Run shell commands
858
+ **${chunkJHYTJMKT_cjs.MC_TOOLS.EXECUTE_COMMAND}** \u2014 Run shell commands
857
859
  - Use for: git, npm/pnpm, docker, build tools, test runners, and other terminal operations.
858
- - Prefer dedicated tools for: file reading (${chunkAWYGW5ZV_cjs.MC_TOOLS.VIEW}), file search (${chunkAWYGW5ZV_cjs.MC_TOOLS.SEARCH_CONTENT}/${chunkAWYGW5ZV_cjs.MC_TOOLS.FIND_FILES}), file editing (${chunkAWYGW5ZV_cjs.MC_TOOLS.STRING_REPLACE_LSP}/${chunkAWYGW5ZV_cjs.MC_TOOLS.WRITE_FILE}).
860
+ - Prefer dedicated tools for: file reading (${chunkJHYTJMKT_cjs.MC_TOOLS.VIEW}), file search (${chunkJHYTJMKT_cjs.MC_TOOLS.SEARCH_CONTENT}/${chunkJHYTJMKT_cjs.MC_TOOLS.FIND_FILES}), file editing (${chunkJHYTJMKT_cjs.MC_TOOLS.STRING_REPLACE_LSP}/${chunkJHYTJMKT_cjs.MC_TOOLS.WRITE_FILE}).
859
861
  - Commands have a 30-second default timeout. Use \`timeout\` for longer commands, \`cwd\` for working directory.
860
862
  - Use the \`tail\` parameter or pipe to \`| tail -N\` to limit output \u2014 the full output streams to the user, only the tail is returned to you. If you're building any kind of package you should be tailing.
861
863
  - Good: Run independent commands in parallel when possible.
862
- - Bad: Running \`cat file.txt\` \u2014 use the ${chunkAWYGW5ZV_cjs.MC_TOOLS.VIEW} tool instead.`);
864
+ - Bad: Running \`cat file.txt\` \u2014 use the ${chunkJHYTJMKT_cjs.MC_TOOLS.VIEW} tool instead.`);
863
865
  }
864
- if (!denied.has(chunkAWYGW5ZV_cjs.MC_TOOLS.LSP_INSPECT)) {
866
+ if (!denied.has(chunkJHYTJMKT_cjs.MC_TOOLS.LSP_INSPECT)) {
865
867
  readTools.push(`
866
- **${chunkAWYGW5ZV_cjs.MC_TOOLS.LSP_INSPECT}** \u2014 Inspect code using Language Server Protocol
868
+ **${chunkJHYTJMKT_cjs.MC_TOOLS.LSP_INSPECT}** \u2014 Inspect code using Language Server Protocol
867
869
  - Use this for type information, hover docs, go-to-definition, and finding implementations for a symbol.
868
870
  - Best when you already know the file and line and need semantic code intelligence rather than raw file contents.
869
871
  - Input: \`path\` (absolute file path), \`line\` (1-indexed line number), \`match\` (the exact line content with exactly one \`<<<\` cursor marker).
870
872
  - Output includes: \`hover\`, \`definition\` (compact location with preview), and \`implementation\` (compact usage/implementation locations).
871
873
  - Example: \`{ path: "/abs/path/src/foo.ts", line: 10, match: "const foo = <<<bar()" }\` \u2014 inspect the symbol at the \`<<<\` position.
872
- - Use \`${chunkAWYGW5ZV_cjs.MC_TOOLS.VIEW}\` when you need to read the implementation or surrounding code.
873
- - Use \`${chunkAWYGW5ZV_cjs.MC_TOOLS.SEARCH_CONTENT}\` or \`${chunkAWYGW5ZV_cjs.MC_TOOLS.FIND_FILES}\` first if you do not yet know where the symbol is.`);
874
+ - Use \`${chunkJHYTJMKT_cjs.MC_TOOLS.VIEW}\` when you need to read the implementation or surrounding code.
875
+ - Use \`${chunkJHYTJMKT_cjs.MC_TOOLS.SEARCH_CONTENT}\` or \`${chunkJHYTJMKT_cjs.MC_TOOLS.FIND_FILES}\` first if you do not yet know where the symbol is.`);
876
+ }
877
+ if (!denied.has(chunkJHYTJMKT_cjs.MC_TOOLS.NOTIFICATION_INBOX)) {
878
+ readTools.push(`
879
+ **${chunkJHYTJMKT_cjs.MC_TOOLS.NOTIFICATION_INBOX}** \u2014 Inspect and manage notification inbox records
880
+ - Use this when a \`<notification-summary>\` says pending notifications exist.
881
+ - Use \`{ "action": "list", "status": "pending" }\` or \`{ "action": "search", "query": "..." }\` to find notification records for the current thread.
882
+ - Use \`read\` to deliver unread notification signals into the chat and mark them seen; the tool result summarizes the count instead of exposing notification contents.
883
+ - Use \`dismiss\` or \`archive\` only when the user asks or the notification is no longer relevant.`);
874
884
  }
875
885
  if (readTools.length > 0) {
876
886
  sections.push(readTools.join("\n"));
877
887
  }
878
888
  if (modeId !== "plan") {
879
889
  const writeTools = [];
880
- if (!denied.has(chunkAWYGW5ZV_cjs.MC_TOOLS.STRING_REPLACE_LSP)) {
890
+ if (!denied.has(chunkJHYTJMKT_cjs.MC_TOOLS.STRING_REPLACE_LSP)) {
881
891
  writeTools.push(`
882
- **${chunkAWYGW5ZV_cjs.MC_TOOLS.STRING_REPLACE_LSP}** \u2014 Edit files by replacing exact text
883
- - You MUST read a file with \`${chunkAWYGW5ZV_cjs.MC_TOOLS.VIEW}\` before editing it.
892
+ **${chunkJHYTJMKT_cjs.MC_TOOLS.STRING_REPLACE_LSP}** \u2014 Edit files by replacing exact text
893
+ - You MUST read a file with \`${chunkJHYTJMKT_cjs.MC_TOOLS.VIEW}\` before editing it.
884
894
  - \`old_string\` must be an exact match of existing text in the file.
885
895
  - Provide enough surrounding context in \`old_string\` to make it unique.
886
896
  - Use \`replace_all: true\` to replace all occurrences (default: false, requires unique match).
887
- - For creating new files, use \`${chunkAWYGW5ZV_cjs.MC_TOOLS.WRITE_FILE}\` instead.
897
+ - For creating new files, use \`${chunkJHYTJMKT_cjs.MC_TOOLS.WRITE_FILE}\` instead.
888
898
  - Good: Include 2-3 lines of surrounding context to ensure uniqueness.
889
899
  - Bad: Using just \`return true;\` \u2014 too common, will match multiple places.`);
890
900
  }
891
- if (!denied.has(chunkAWYGW5ZV_cjs.MC_TOOLS.WRITE_FILE)) {
901
+ if (!denied.has(chunkJHYTJMKT_cjs.MC_TOOLS.WRITE_FILE)) {
892
902
  writeTools.push(`
893
- **${chunkAWYGW5ZV_cjs.MC_TOOLS.WRITE_FILE}** \u2014 Create new files or overwrite existing ones
903
+ **${chunkJHYTJMKT_cjs.MC_TOOLS.WRITE_FILE}** \u2014 Create new files or overwrite existing ones
894
904
  - Use this to create new files.
895
- - If overwriting an existing file, you MUST have read it first with \`${chunkAWYGW5ZV_cjs.MC_TOOLS.VIEW}\`.
905
+ - If overwriting an existing file, you MUST have read it first with \`${chunkJHYTJMKT_cjs.MC_TOOLS.VIEW}\`.
896
906
  - Prefer editing existing files over creating new ones.`);
897
907
  }
898
908
  if (writeTools.length > 0) {
@@ -1042,7 +1052,7 @@ ${lines.join("\n")}
1042
1052
  // src/agents/instructions.ts
1043
1053
  async function getDynamicInstructions({ requestContext }) {
1044
1054
  const harnessContext = requestContext.get("harness");
1045
- const state = harnessContext?.state;
1055
+ const state = harnessContext?.getState?.();
1046
1056
  const modeId = harnessContext?.modeId ?? "build";
1047
1057
  const projectPath = state?.projectPath ?? process.cwd();
1048
1058
  const promptCtx = {
@@ -1069,14 +1079,14 @@ function getHarnessState(requestContext) {
1069
1079
  }
1070
1080
  function getObserverModel({ requestContext }) {
1071
1081
  const state = getHarnessState(requestContext);
1072
- return chunkDJBUYADN_cjs.resolveModel(state?.observerModelId ?? chunkJ3ISOP5J_cjs.DEFAULT_OM_MODEL_ID, {
1082
+ return chunkEAUXUMEB_cjs.resolveModel(state?.observerModelId ?? chunkJ3ISOP5J_cjs.DEFAULT_OM_MODEL_ID, {
1073
1083
  remapForCodexOAuth: true,
1074
1084
  requestContext
1075
1085
  });
1076
1086
  }
1077
1087
  function getReflectorModel({ requestContext }) {
1078
1088
  const state = getHarnessState(requestContext);
1079
- return chunkDJBUYADN_cjs.resolveModel(state?.reflectorModelId ?? chunkJ3ISOP5J_cjs.DEFAULT_OM_MODEL_ID, {
1089
+ return chunkEAUXUMEB_cjs.resolveModel(state?.reflectorModelId ?? chunkJ3ISOP5J_cjs.DEFAULT_OM_MODEL_ID, {
1080
1090
  remapForCodexOAuth: true,
1081
1091
  requestContext
1082
1092
  });
@@ -1230,7 +1240,7 @@ End with a structured summary:
1230
1240
  . **Details**: Additional context if needed
1231
1241
 
1232
1242
  Keep your summary under 300 words.`,
1233
- allowedWorkspaceTools: [chunkAWYGW5ZV_cjs.MC_TOOLS.VIEW, chunkAWYGW5ZV_cjs.MC_TOOLS.SEARCH_CONTENT, chunkAWYGW5ZV_cjs.MC_TOOLS.FIND_FILES]
1243
+ allowedWorkspaceTools: [chunkJHYTJMKT_cjs.MC_TOOLS.VIEW, chunkJHYTJMKT_cjs.MC_TOOLS.SEARCH_CONTENT, chunkJHYTJMKT_cjs.MC_TOOLS.FIND_FILES]
1234
1244
  };
1235
1245
 
1236
1246
  // src/agents/subagents/plan.ts
@@ -1266,7 +1276,7 @@ Structure your plan as:
1266
1276
  . **Risks**: Potential issues or edge cases (if any)
1267
1277
 
1268
1278
  Be specific about code locations (file paths, function names, line numbers). Keep the plan actionable and under 500 words.`,
1269
- allowedWorkspaceTools: [chunkAWYGW5ZV_cjs.MC_TOOLS.VIEW, chunkAWYGW5ZV_cjs.MC_TOOLS.SEARCH_CONTENT, chunkAWYGW5ZV_cjs.MC_TOOLS.FIND_FILES]
1279
+ allowedWorkspaceTools: [chunkJHYTJMKT_cjs.MC_TOOLS.VIEW, chunkJHYTJMKT_cjs.MC_TOOLS.SEARCH_CONTENT, chunkJHYTJMKT_cjs.MC_TOOLS.FIND_FILES]
1270
1280
  };
1271
1281
 
1272
1282
  // src/agents/thread-caveman-state.ts
@@ -1327,6 +1337,38 @@ async function restoreOMThreadStateForCurrentThread(harness) {
1327
1337
  if (!threadId) return;
1328
1338
  await restoreSettingsForThread(harness, threadId);
1329
1339
  }
1340
+ var LazyNotificationsStorage = class extends notifications.NotificationsStorage {
1341
+ constructor(storage) {
1342
+ super();
1343
+ this.storage = storage;
1344
+ }
1345
+ storage;
1346
+ async getNotificationsStorage() {
1347
+ const notifications = await this.storage.getStore("notifications");
1348
+ if (!notifications) {
1349
+ throw new Error("notification_inbox requires a notifications storage domain");
1350
+ }
1351
+ return notifications;
1352
+ }
1353
+ async createNotification(input) {
1354
+ return (await this.getNotificationsStorage()).createNotification(input);
1355
+ }
1356
+ async listNotifications(input) {
1357
+ return (await this.getNotificationsStorage()).listNotifications(input);
1358
+ }
1359
+ async listDueNotifications(input) {
1360
+ return (await this.getNotificationsStorage()).listDueNotifications(input);
1361
+ }
1362
+ async getNotification(input) {
1363
+ return (await this.getNotificationsStorage()).getNotification(input);
1364
+ }
1365
+ async updateNotification(input) {
1366
+ return (await this.getNotificationsStorage()).updateNotification(input);
1367
+ }
1368
+ async dangerouslyClearAll() {
1369
+ return (await this.getNotificationsStorage()).dangerouslyClearAll();
1370
+ }
1371
+ };
1330
1372
  function wrapToolWithHooks(toolName, tool, hookManager) {
1331
1373
  if (!hookManager || typeof tool?.execute !== "function") {
1332
1374
  return tool;
@@ -1357,16 +1399,21 @@ function wrapToolWithHooks(toolName, tool, hookManager) {
1357
1399
  }
1358
1400
  };
1359
1401
  }
1360
- function createDynamicTools(mcpManager, extraTools, hookManager, disabledTools) {
1402
+ function createDynamicTools(mcpManager, extraTools, hookManager, disabledTools, storage) {
1361
1403
  return function getDynamicTools({ requestContext }) {
1362
1404
  const ctx = requestContext.get("harness");
1363
- const state = ctx?.getState();
1405
+ const state = ctx?.getState?.();
1364
1406
  const modelId = state?.currentModelId;
1365
1407
  const isAnthropicModel = modelId?.startsWith("anthropic/");
1366
1408
  const isOpenAIModel = modelId?.startsWith("openai/");
1367
1409
  const tools = {
1368
1410
  request_access: requestSandboxAccessTool
1369
1411
  };
1412
+ if (storage) {
1413
+ tools[chunkJHYTJMKT_cjs.MC_TOOLS.NOTIFICATION_INBOX] = notifications.createNotificationInboxTool({
1414
+ storage: new LazyNotificationsStorage(storage)
1415
+ });
1416
+ }
1370
1417
  if (hasTavilyKey()) {
1371
1418
  tools.web_search = createWebSearchTool();
1372
1419
  tools.web_extract = createWebExtractTool();
@@ -1936,15 +1983,62 @@ var HarnessCompat = class extends harness.Harness {
1936
1983
  super(args);
1937
1984
  this.#harnessV1 = harnessV1;
1938
1985
  }
1986
+ getState() {
1987
+ const state = super.getState();
1988
+ let session;
1989
+ try {
1990
+ session = this.#session;
1991
+ } catch {
1992
+ session = void 0;
1993
+ }
1994
+ if (!session) {
1995
+ return state;
1996
+ }
1997
+ return {
1998
+ ...state,
1999
+ ...session.getState(),
2000
+ currentModelId: session.getModelId(),
2001
+ modeId: session.getMode().id
2002
+ };
2003
+ }
2004
+ async setState(updates) {
2005
+ const { currentModelId, modeId, ...harnessUpdates } = updates;
2006
+ let session;
2007
+ try {
2008
+ session = this.#session;
2009
+ } catch {
2010
+ session = void 0;
2011
+ }
2012
+ if (session) {
2013
+ if (typeof currentModelId === "string") {
2014
+ session.setModelId(currentModelId);
2015
+ }
2016
+ if (typeof modeId === "string" && modeId !== session.getMode().id) {
2017
+ await this.switchMode({ modeId });
2018
+ }
2019
+ }
2020
+ if (Object.keys(harnessUpdates).length > 0) {
2021
+ if (session) {
2022
+ await session.setState(harnessUpdates);
2023
+ }
2024
+ await super.setState(harnessUpdates);
2025
+ }
2026
+ }
2027
+ getSubagentModelId({ agentType } = {}) {
2028
+ return super.getSubagentModelId({ agentType });
2029
+ }
2030
+ async setSubagentModelId({ modelId, agentType }) {
2031
+ await super.setSubagentModelId({ modelId, agentType });
2032
+ }
1939
2033
  async switchThread({ threadId }) {
1940
- const modes = this.listModes();
1941
- this.#session = await this.#harnessV1.session({
2034
+ const currentModelId = this.getState().currentModelId;
2035
+ const session = await this.#harnessV1.session({
1942
2036
  threadId,
1943
2037
  resourceId: this.getResourceId()
1944
2038
  });
1945
- const defaultModelId = modes.find((mode) => mode.id === this.#session.getMode().id)?.defaultModelId;
1946
- if (defaultModelId) {
1947
- this.#session.setModelId(defaultModelId);
2039
+ this.#session = session;
2040
+ if (typeof currentModelId === "string" && currentModelId.length > 0) {
2041
+ session.setModelId(currentModelId);
1948
2042
  }
1949
2043
  await super.switchThread({ threadId });
1950
2044
  }
@@ -2039,12 +2133,24 @@ var HarnessCompat = class extends harness.Harness {
2039
2133
  if (!mode) {
2040
2134
  throw new Error(`Mode not found: ${modeId}`);
2041
2135
  }
2042
- if (!this.#session) {
2043
- throw new Error("No active session to switch mode");
2136
+ if (this.#session) {
2137
+ this.#session.setMode(mode);
2044
2138
  }
2045
- this.#session.setMode(mode);
2046
2139
  await super.switchMode({ modeId });
2047
2140
  }
2141
+ /**
2142
+ * Activate a skill on the current v1 session.
2143
+ *
2144
+ * Pass-through to `Session.useSkill` — returns the resolved instructions
2145
+ * string, or throws `HarnessSkillNotFoundError` if the skill is missing.
2146
+ * Throws if there is no active session.
2147
+ */
2148
+ async useSkill(name, opts) {
2149
+ if (!this.#session) {
2150
+ throw new Error("No active session to use skill");
2151
+ }
2152
+ return this.#session.useSkill(name, opts);
2153
+ }
2048
2154
  };
2049
2155
  var VALID_EVENTS = [
2050
2156
  "PreToolUse",
@@ -2889,15 +2995,12 @@ function createMcpManager(projectDir, configDirName = chunkJ3ISOP5J_cjs.DEFAULT_
2889
2995
  };
2890
2996
  }
2891
2997
  var stateSchema = zod.z.object({
2998
+ subagentModelId: zod.z.string().optional(),
2892
2999
  projectPath: zod.z.string().optional(),
2893
3000
  projectName: zod.z.string().optional(),
2894
3001
  configDir: zod.z.string().default(chunkJ3ISOP5J_cjs.DEFAULT_CONFIG_DIR),
2895
3002
  gitBranch: zod.z.string().optional(),
2896
3003
  lastCommand: zod.z.string().optional(),
2897
- currentModelId: zod.z.string().default(""),
2898
- // Subagent model settings (per-thread/per-mode)
2899
- subagentModelId: zod.z.string().optional(),
2900
- // Thread-level default for subagents
2901
3004
  // Observational Memory model settings
2902
3005
  observerModelId: zod.z.string().default(chunkJ3ISOP5J_cjs.DEFAULT_OM_MODEL_ID),
2903
3006
  reflectorModelId: zod.z.string().default(chunkJ3ISOP5J_cjs.DEFAULT_OM_MODEL_ID),
@@ -3190,15 +3293,15 @@ function applyEffectiveDefaultsToV1Modes(modes, effectiveDefaults) {
3190
3293
  }
3191
3294
  function createAuthStorage() {
3192
3295
  const authStorage = new chunkJ3ISOP5J_cjs.AuthStorage();
3193
- chunkDJBUYADN_cjs.setAuthStorage(authStorage);
3194
- chunkDJBUYADN_cjs.setAuthStorage3(authStorage);
3195
- chunkDJBUYADN_cjs.setAuthStorage2(authStorage);
3296
+ chunkEAUXUMEB_cjs.setAuthStorage(authStorage);
3297
+ chunkEAUXUMEB_cjs.setAuthStorage3(authStorage);
3298
+ chunkEAUXUMEB_cjs.setAuthStorage2(authStorage);
3196
3299
  return authStorage;
3197
3300
  }
3198
3301
  function resolveCloudObservabilityConfig(settings, authStorage, resourceId) {
3199
3302
  const resourceConfig = settings.observability.resources[resourceId];
3200
3303
  if (resourceConfig) {
3201
- const token = authStorage.getStoredApiKey(`${chunkDJBUYADN_cjs.OBSERVABILITY_AUTH_PREFIX}${resourceId}`);
3304
+ const token = authStorage.getStoredApiKey(`${chunkEAUXUMEB_cjs.OBSERVABILITY_AUTH_PREFIX}${resourceId}`);
3202
3305
  if (token) {
3203
3306
  return { accessToken: token, projectId: resourceConfig.projectId };
3204
3307
  }
@@ -3220,8 +3323,8 @@ async function createMastraCode(config) {
3220
3323
  }
3221
3324
  const gatewayRegistry = llm.GatewayRegistry.getInstance({ useDynamicLoading: true });
3222
3325
  const authStorage = createAuthStorage();
3223
- const globalSettings = chunkDJBUYADN_cjs.loadSettings(config?.settingsPath);
3224
- const storedGatewayKey = authStorage.getStoredApiKey(chunkDJBUYADN_cjs.MEMORY_GATEWAY_PROVIDER);
3326
+ const globalSettings = chunkEAUXUMEB_cjs.loadSettings(config?.settingsPath);
3327
+ const storedGatewayKey = authStorage.getStoredApiKey(chunkEAUXUMEB_cjs.MEMORY_GATEWAY_PROVIDER);
3225
3328
  const storedGatewayUrl = globalSettings.memoryGateway?.baseUrl;
3226
3329
  if (storedGatewayKey) {
3227
3330
  process.env["MASTRA_GATEWAY_API_KEY"] ??= storedGatewayKey;
@@ -3236,11 +3339,11 @@ async function createMastraCode(config) {
3236
3339
  const envVars = cfg?.apiKeyEnvVar;
3237
3340
  providerEnvVars[provider] = Array.isArray(envVars) ? envVars[0] : envVars;
3238
3341
  }
3239
- providerEnvVars[chunkDJBUYADN_cjs.MEMORY_GATEWAY_PROVIDER] ??= "MASTRA_GATEWAY_API_KEY";
3342
+ providerEnvVars[chunkEAUXUMEB_cjs.MEMORY_GATEWAY_PROVIDER] ??= "MASTRA_GATEWAY_API_KEY";
3240
3343
  authStorage.loadStoredApiKeysIntoEnv(providerEnvVars);
3241
3344
  } catch {
3242
3345
  authStorage.loadStoredApiKeysIntoEnv({
3243
- [chunkDJBUYADN_cjs.MEMORY_GATEWAY_PROVIDER]: "MASTRA_GATEWAY_API_KEY",
3346
+ [chunkEAUXUMEB_cjs.MEMORY_GATEWAY_PROVIDER]: "MASTRA_GATEWAY_API_KEY",
3244
3347
  anthropic: "ANTHROPIC_API_KEY",
3245
3348
  openai: "OPENAI_API_KEY",
3246
3349
  google: "GOOGLE_GENERATIVE_AI_API_KEY",
@@ -3309,7 +3412,7 @@ async function createMastraCode(config) {
3309
3412
  // Environment & project:
3310
3413
  // state.projectName, state.gitBranch
3311
3414
  // Model configuration:
3312
- // state.currentModelId, state.subagentModelId
3415
+ // state.currentModelId
3313
3416
  // Agent settings:
3314
3417
  // state.yolo, state.thinkingLevel, state.smartEditing
3315
3418
  // Observational memory settings:
@@ -3326,7 +3429,6 @@ async function createMastraCode(config) {
3326
3429
  "harness.state.gitBranch",
3327
3430
  // Model configuration
3328
3431
  "harness.state.currentModelId",
3329
- "harness.state.subagentModelId",
3330
3432
  // Agent settings
3331
3433
  "harness.state.yolo",
3332
3434
  "harness.state.thinkingLevel",
@@ -3352,12 +3454,13 @@ async function createMastraCode(config) {
3352
3454
  const hookManager = config?.disableHooks ? void 0 : new HookManager(project.rootPath, "session-init", configDir);
3353
3455
  const outcomeScorer = createOutcomeScorer();
3354
3456
  const efficiencyScorer = createEfficiencyScorer();
3457
+ const githubSignalsProcessor = globalSettings.signals?.experimentalGithubSignals ? new chunkEAUXUMEB_cjs.GithubSignals({ cwd: project.rootPath }) : void 0;
3355
3458
  const codeAgent = new agent.Agent({
3356
3459
  id: CODE_AGENT_ID,
3357
3460
  name: "Code Agent",
3358
3461
  instructions: getDynamicInstructions,
3359
- model: chunkDJBUYADN_cjs.getDynamicModel,
3360
- tools: createDynamicTools(mcpManager, config?.extraTools, hookManager, config?.disabledTools),
3462
+ model: chunkEAUXUMEB_cjs.getDynamicModel,
3463
+ tools: createDynamicTools(mcpManager, config?.extraTools, hookManager, config?.disabledTools, storage$1),
3361
3464
  scorers: {
3362
3465
  outcome: {
3363
3466
  scorer: outcomeScorer,
@@ -3376,10 +3479,38 @@ async function createMastraCode(config) {
3376
3479
  return getStaticallyLoadedInstructionPaths(projectPath);
3377
3480
  }
3378
3481
  }),
3482
+ ...githubSignalsProcessor ? [githubSignalsProcessor] : [],
3379
3483
  new processors.ProviderHistoryCompat()
3380
3484
  ],
3381
3485
  errorProcessors: [new processors.StreamErrorRetryProcessor(), new processors.PrefillErrorHandler(), new processors.ProviderHistoryCompat()]
3382
3486
  });
3487
+ githubSignalsProcessor?.addAgent(codeAgent, {
3488
+ getNotificationStreamOptions: ({ resourceId, threadId }) => {
3489
+ const requestContext$1 = new requestContext.RequestContext();
3490
+ const harnessContext = {
3491
+ harnessId: harness.id,
3492
+ state: harness.getState(),
3493
+ getState: () => harness.getState(),
3494
+ setState: (updates) => harness.setState(updates),
3495
+ threadId,
3496
+ resourceId,
3497
+ modeId: harness.getCurrentModeId(),
3498
+ workspace: harness.getWorkspace(),
3499
+ registerQuestion: (params) => harness.registerQuestion(params),
3500
+ registerPlanApproval: (params) => harness.registerPlanApproval(params),
3501
+ getSubagentModelId: (params) => harness.getSubagentModelId(params)
3502
+ };
3503
+ requestContext$1.set("harness", harnessContext);
3504
+ return {
3505
+ memory: { thread: threadId, resource: resourceId },
3506
+ requestContext: requestContext$1,
3507
+ maxSteps: 1e3,
3508
+ savePerStep: false,
3509
+ requireToolApproval: harness.getState().yolo !== true,
3510
+ modelSettings: { temperature: 1 }
3511
+ };
3512
+ }
3513
+ });
3383
3514
  const defaultSubagents = [exploreSubagent, planSubagent, executeSubagent];
3384
3515
  const defaultModesV1 = [
3385
3516
  {
@@ -3388,7 +3519,7 @@ async function createMastraCode(config) {
3388
3519
  description: "Build",
3389
3520
  defaultModelId: "anthropic/claude-opus-4-7",
3390
3521
  metadata: {
3391
- color: chunkDJBUYADN_cjs.mastra.green,
3522
+ color: chunkEAUXUMEB_cjs.mastra.green,
3392
3523
  default: true
3393
3524
  }
3394
3525
  },
@@ -3399,7 +3530,7 @@ async function createMastraCode(config) {
3399
3530
  transitionsTo: "build",
3400
3531
  defaultModelId: "openai/gpt-5.5",
3401
3532
  metadata: {
3402
- color: chunkDJBUYADN_cjs.mastra.purple
3533
+ color: chunkEAUXUMEB_cjs.mastra.purple
3403
3534
  }
3404
3535
  },
3405
3536
  {
@@ -3408,7 +3539,7 @@ async function createMastraCode(config) {
3408
3539
  description: "Fast",
3409
3540
  defaultModelId: "cerebras/zai-glm-4.7",
3410
3541
  metadata: {
3411
- color: chunkDJBUYADN_cjs.mastra.orange
3542
+ color: chunkEAUXUMEB_cjs.mastra.orange
3412
3543
  }
3413
3544
  }
3414
3545
  ];
@@ -3419,6 +3550,7 @@ async function createMastraCode(config) {
3419
3550
  handler: () => syncGateways()
3420
3551
  }
3421
3552
  ];
3553
+ const heartbeatHandlers = config?.heartbeatHandlers ?? defaultHeartbeatHandlers;
3422
3554
  const anthropicCred = authStorage.get("anthropic");
3423
3555
  const openaiCred = authStorage.get("openai-codex");
3424
3556
  const githubCopilotCred = authStorage.get("github-copilot");
@@ -3447,11 +3579,11 @@ async function createMastraCode(config) {
3447
3579
  }
3448
3580
  } catch {
3449
3581
  }
3450
- const builtinPacks = chunkDJBUYADN_cjs.getAvailableModePacks(startupAccess);
3451
- const builtinOmPacks = chunkDJBUYADN_cjs.getAvailableOmPacks(startupAccess);
3452
- const effectiveDefaults = chunkDJBUYADN_cjs.resolveModelDefaults(globalSettings, builtinPacks);
3453
- const effectiveObserverModel = chunkDJBUYADN_cjs.resolveOmRoleModel(globalSettings, "observer", builtinOmPacks);
3454
- const effectiveReflectorModel = chunkDJBUYADN_cjs.resolveOmRoleModel(globalSettings, "reflector", builtinOmPacks);
3582
+ const builtinPacks = chunkEAUXUMEB_cjs.getAvailableModePacks(startupAccess);
3583
+ const builtinOmPacks = chunkEAUXUMEB_cjs.getAvailableOmPacks(startupAccess);
3584
+ const effectiveDefaults = chunkEAUXUMEB_cjs.resolveModelDefaults(globalSettings, builtinPacks);
3585
+ const effectiveObserverModel = chunkEAUXUMEB_cjs.resolveOmRoleModel(globalSettings, "observer", builtinOmPacks);
3586
+ const effectiveReflectorModel = chunkEAUXUMEB_cjs.resolveOmRoleModel(globalSettings, "reflector", builtinOmPacks);
3455
3587
  const effectiveObservationThreshold = globalSettings.models.omObservationThreshold ?? void 0;
3456
3588
  const effectiveReflectionThreshold = globalSettings.models.omReflectionThreshold ?? void 0;
3457
3589
  const effectiveCavemanObservations = globalSettings.models.omCavemanObservations ?? void 0;
@@ -3546,15 +3678,32 @@ async function createMastraCode(config) {
3546
3678
  });
3547
3679
  })
3548
3680
  );
3681
+ const typedStateSchema = stateSchema;
3682
+ const initialState = {
3683
+ projectPath: project.rootPath,
3684
+ projectName: project.name,
3685
+ gitBranch: project.gitBranch,
3686
+ yolo: true,
3687
+ ...globalInitialState,
3688
+ ...config?.initialState,
3689
+ // configDir must always win over initialState spreads to stay in sync
3690
+ // with MCP/hooks/storage which were already initialized with this value.
3691
+ configDir
3692
+ };
3693
+ const workspace = config?.workspace ?? getDynamicWorkspace;
3549
3694
  const harnessV1 = new v1.Harness({
3550
3695
  ownerId,
3551
3696
  agents: { [CODE_AGENT_ID]: codeAgent },
3552
3697
  memory,
3553
3698
  modes: modesV1,
3554
3699
  defaultModeId,
3555
- storage: harnessStorage
3700
+ storage: harnessStorage,
3701
+ stateSchema: typedStateSchema,
3702
+ initialState,
3703
+ workspace,
3704
+ resolveModel: (modelId) => chunkEAUXUMEB_cjs.resolveModel(modelId),
3705
+ toolCategoryResolver: (name) => chunkJHYTJMKT_cjs.getToolCategory(name) ?? null
3556
3706
  });
3557
- const typedStateSchema = stateSchema;
3558
3707
  const harness = new HarnessCompat(
3559
3708
  {
3560
3709
  id: "mastra-code",
@@ -3565,25 +3714,15 @@ async function createMastraCode(config) {
3565
3714
  pubsub: signalsPubSub,
3566
3715
  stateSchema: typedStateSchema,
3567
3716
  subagents,
3568
- resolveModel: (modelId) => chunkDJBUYADN_cjs.resolveModel(modelId),
3569
- toolCategoryResolver: chunkAWYGW5ZV_cjs.getToolCategory,
3570
- initialState: {
3571
- projectPath: project.rootPath,
3572
- projectName: project.name,
3573
- gitBranch: project.gitBranch,
3574
- yolo: true,
3575
- ...globalInitialState,
3576
- ...config?.initialState,
3577
- // configDir must always win over initialState spreads to stay in sync
3578
- // with MCP/hooks/storage which were already initialized with this value.
3579
- configDir
3580
- },
3581
- workspace: config?.workspace ?? getDynamicWorkspace,
3717
+ resolveModel: (modelId) => chunkEAUXUMEB_cjs.resolveModel(modelId),
3718
+ toolCategoryResolver: chunkJHYTJMKT_cjs.getToolCategory,
3719
+ initialState,
3720
+ workspace,
3582
3721
  browser: config?.browser,
3583
3722
  modes,
3584
- heartbeatHandlers: config?.heartbeatHandlers ?? defaultHeartbeatHandlers,
3723
+ heartbeatHandlers,
3585
3724
  modelAuthChecker: (provider) => {
3586
- const gatewayKey = authStorage.getStoredApiKey(chunkDJBUYADN_cjs.MEMORY_GATEWAY_PROVIDER) ?? process.env["MASTRA_GATEWAY_API_KEY"];
3725
+ const gatewayKey = authStorage.getStoredApiKey(chunkEAUXUMEB_cjs.MEMORY_GATEWAY_PROVIDER) ?? process.env["MASTRA_GATEWAY_API_KEY"];
3587
3726
  if (gatewayKey) {
3588
3727
  const providerConfig = gatewayRegistry.getProviders()[provider];
3589
3728
  if (providerConfig?.gateway === "mastra") return true;
@@ -3607,32 +3746,32 @@ async function createMastraCode(config) {
3607
3746
  return true;
3608
3747
  }
3609
3748
  }
3610
- const customProvider = chunkDJBUYADN_cjs.loadSettings().customProviders.find((entry) => {
3611
- return provider === chunkDJBUYADN_cjs.getCustomProviderId(entry.name);
3749
+ const customProvider = chunkEAUXUMEB_cjs.loadSettings().customProviders.find((entry) => {
3750
+ return provider === chunkEAUXUMEB_cjs.getCustomProviderId(entry.name);
3612
3751
  });
3613
3752
  if (customProvider) {
3614
3753
  return true;
3615
3754
  }
3616
3755
  return void 0;
3617
3756
  },
3618
- modelUseCountProvider: () => chunkDJBUYADN_cjs.loadSettings().modelUseCounts,
3757
+ modelUseCountProvider: () => chunkEAUXUMEB_cjs.loadSettings().modelUseCounts,
3619
3758
  modelUseCountTracker: (modelId) => {
3620
3759
  try {
3621
- const settings = chunkDJBUYADN_cjs.loadSettings();
3760
+ const settings = chunkEAUXUMEB_cjs.loadSettings();
3622
3761
  settings.modelUseCounts[modelId] = (settings.modelUseCounts[modelId] ?? 0) + 1;
3623
- chunkDJBUYADN_cjs.saveSettings(settings);
3762
+ chunkEAUXUMEB_cjs.saveSettings(settings);
3624
3763
  } catch (error) {
3625
3764
  console.error("Failed to persist model usage count", error);
3626
3765
  }
3627
3766
  },
3628
3767
  customModelCatalogProvider: async () => {
3629
- const settings = chunkDJBUYADN_cjs.loadSettings();
3768
+ const settings = chunkEAUXUMEB_cjs.loadSettings();
3630
3769
  const customModels = [];
3631
3770
  for (const provider of settings.customProviders) {
3632
- const providerId = chunkDJBUYADN_cjs.getCustomProviderId(provider.name);
3771
+ const providerId = chunkEAUXUMEB_cjs.getCustomProviderId(provider.name);
3633
3772
  for (const modelName of provider.models) {
3634
3773
  customModels.push({
3635
- id: chunkDJBUYADN_cjs.toCustomProviderModelId(provider.name, modelName),
3774
+ id: chunkEAUXUMEB_cjs.toCustomProviderModelId(provider.name, modelName),
3636
3775
  provider: providerId,
3637
3776
  modelName,
3638
3777
  hasApiKey: true,
@@ -3641,7 +3780,7 @@ async function createMastraCode(config) {
3641
3780
  }
3642
3781
  }
3643
3782
  try {
3644
- const copilotModels = await chunkDJBUYADN_cjs.getCopilotModelCatalog({ authStorage });
3783
+ const copilotModels = await chunkEAUXUMEB_cjs.getCopilotModelCatalog({ authStorage });
3645
3784
  for (const m of copilotModels) {
3646
3785
  customModels.push({
3647
3786
  id: `github-copilot/${m.id}`,
@@ -3657,8 +3796,8 @@ async function createMastraCode(config) {
3657
3796
  return customModels;
3658
3797
  },
3659
3798
  threadLock: crossProcessPubSub ? void 0 : {
3660
- acquire: chunkDJBUYADN_cjs.acquireThreadLock,
3661
- release: chunkDJBUYADN_cjs.releaseThreadLock
3799
+ acquire: chunkEAUXUMEB_cjs.acquireThreadLock,
3800
+ release: chunkEAUXUMEB_cjs.releaseThreadLock
3662
3801
  }
3663
3802
  },
3664
3803
  harnessV1
@@ -3672,6 +3811,30 @@ async function createMastraCode(config) {
3672
3811
  }
3673
3812
  });
3674
3813
  }
3814
+ if (githubSignalsProcessor) {
3815
+ const startGithubPollingForCurrentThread = async (threadId) => {
3816
+ if (!threadId) return;
3817
+ githubSignalsProcessor.stopAllPolling();
3818
+ try {
3819
+ const threads2 = await harness.listThreads({ allResources: true });
3820
+ const thread = threads2.find((item) => item.id === threadId);
3821
+ await githubSignalsProcessor.startPollingForThread(
3822
+ {
3823
+ threadId,
3824
+ resourceId: thread?.resourceId ?? harness.getResourceId()
3825
+ },
3826
+ { pollImmediately: true }
3827
+ );
3828
+ } catch (error) {
3829
+ console.warn("Failed to start GitHub PR polling:", error);
3830
+ }
3831
+ };
3832
+ harness.subscribe((event) => {
3833
+ if (event.type === "thread_changed") void startGithubPollingForCurrentThread(event.threadId);
3834
+ else if (event.type === "thread_created") void startGithubPollingForCurrentThread(event.thread.id);
3835
+ });
3836
+ void startGithubPollingForCurrentThread(harness.getCurrentThreadId());
3837
+ }
3675
3838
  const omThreadStateHarness = harness;
3676
3839
  attachOMThreadStatePersistence(omThreadStateHarness);
3677
3840
  await restoreOMThreadStateForCurrentThread(omThreadStateHarness).catch(() => {
@@ -3682,16 +3845,17 @@ async function createMastraCode(config) {
3682
3845
  hookManager,
3683
3846
  signalsPubSub,
3684
3847
  authStorage,
3685
- resolveModel: chunkDJBUYADN_cjs.resolveModel,
3848
+ resolveModel: chunkEAUXUMEB_cjs.resolveModel,
3686
3849
  storageWarning,
3687
3850
  observabilityWarning,
3688
3851
  builtinPacks,
3689
3852
  builtinOmPacks,
3690
- effectiveDefaults
3853
+ effectiveDefaults,
3854
+ githubSignals: githubSignalsProcessor
3691
3855
  };
3692
3856
  }
3693
3857
 
3694
3858
  exports.createAuthStorage = createAuthStorage;
3695
3859
  exports.createMastraCode = createMastraCode;
3696
- //# sourceMappingURL=chunk-A4TDK7QP.cjs.map
3697
- //# sourceMappingURL=chunk-A4TDK7QP.cjs.map
3860
+ //# sourceMappingURL=chunk-DFC5V3P7.cjs.map
3861
+ //# sourceMappingURL=chunk-DFC5V3P7.cjs.map