mastracode 0.2.0 → 0.3.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 (166) hide show
  1. package/CHANGELOG.md +144 -0
  2. package/README.md +9 -1
  3. package/dist/agents/instructions.d.ts.map +1 -1
  4. package/dist/agents/prompts/base.d.ts +2 -0
  5. package/dist/agents/prompts/base.d.ts.map +1 -1
  6. package/dist/agents/prompts/build.d.ts +1 -1
  7. package/dist/agents/prompts/build.d.ts.map +1 -1
  8. package/dist/agents/prompts/index.d.ts +1 -2
  9. package/dist/agents/prompts/index.d.ts.map +1 -1
  10. package/dist/agents/prompts/plan.d.ts +1 -1
  11. package/dist/agents/prompts/plan.d.ts.map +1 -1
  12. package/dist/agents/prompts/tool-guidance.d.ts +11 -0
  13. package/dist/agents/prompts/tool-guidance.d.ts.map +1 -0
  14. package/dist/agents/workspace.d.ts.map +1 -1
  15. package/dist/auth/storage.d.ts +0 -48
  16. package/dist/auth/storage.d.ts.map +1 -1
  17. package/dist/{chunk-LVGWM7ZS.cjs → chunk-7K5VFY2N.cjs} +768 -1373
  18. package/dist/chunk-7K5VFY2N.cjs.map +1 -0
  19. package/dist/chunk-7TFV3VBB.cjs +8823 -0
  20. package/dist/chunk-7TFV3VBB.cjs.map +1 -0
  21. package/dist/chunk-C6XKRHRK.cjs +853 -0
  22. package/dist/chunk-C6XKRHRK.cjs.map +1 -0
  23. package/dist/{chunk-7V6U7OKQ.js → chunk-HHX6BKLR.js} +234 -121
  24. package/dist/chunk-HHX6BKLR.js.map +1 -0
  25. package/dist/{chunk-FYTZFUHD.js → chunk-LYETHS2L.js} +6389 -5481
  26. package/dist/chunk-LYETHS2L.js.map +1 -0
  27. package/dist/{chunk-BYMDWH2E.js → chunk-V4HZ2AVV.js} +729 -1332
  28. package/dist/chunk-V4HZ2AVV.js.map +1 -0
  29. package/dist/chunk-VRZZSUQE.js +835 -0
  30. package/dist/chunk-VRZZSUQE.js.map +1 -0
  31. package/dist/{chunk-QDLLGD43.cjs → chunk-VZFPT5N7.cjs} +274 -161
  32. package/dist/chunk-VZFPT5N7.cjs.map +1 -0
  33. package/dist/cli.cjs +64 -21
  34. package/dist/cli.cjs.map +1 -1
  35. package/dist/cli.js +61 -18
  36. package/dist/cli.js.map +1 -1
  37. package/dist/index.cjs +2 -2
  38. package/dist/index.d.ts +6 -7
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +1 -1
  41. package/dist/onboarding/index.d.ts +7 -0
  42. package/dist/onboarding/index.d.ts.map +1 -0
  43. package/dist/onboarding/onboarding-inline.d.ts +95 -0
  44. package/dist/onboarding/onboarding-inline.d.ts.map +1 -0
  45. package/dist/onboarding/packs.d.ts +46 -0
  46. package/dist/onboarding/packs.d.ts.map +1 -0
  47. package/dist/onboarding/settings.d.ts +110 -0
  48. package/dist/onboarding/settings.d.ts.map +1 -0
  49. package/dist/storage-52Y5MKTG.js +3 -0
  50. package/dist/storage-52Y5MKTG.js.map +1 -0
  51. package/dist/storage-JFFX7LJJ.cjs +24 -0
  52. package/dist/storage-JFFX7LJJ.cjs.map +1 -0
  53. package/dist/tools/string-replace-lsp.d.ts.map +1 -1
  54. package/dist/tui/command-dispatch.d.ts +8 -0
  55. package/dist/tui/command-dispatch.d.ts.map +1 -0
  56. package/dist/tui/commands/cost.d.ts +3 -0
  57. package/dist/tui/commands/cost.d.ts.map +1 -0
  58. package/dist/tui/commands/diff.d.ts +3 -0
  59. package/dist/tui/commands/diff.d.ts.map +1 -0
  60. package/dist/tui/commands/exit.d.ts +3 -0
  61. package/dist/tui/commands/exit.d.ts.map +1 -0
  62. package/dist/tui/commands/help.d.ts +3 -0
  63. package/dist/tui/commands/help.d.ts.map +1 -0
  64. package/dist/tui/commands/hooks.d.ts +3 -0
  65. package/dist/tui/commands/hooks.d.ts.map +1 -0
  66. package/dist/tui/commands/index.d.ts +27 -0
  67. package/dist/tui/commands/index.d.ts.map +1 -0
  68. package/dist/tui/commands/login.d.ts +3 -0
  69. package/dist/tui/commands/login.d.ts.map +1 -0
  70. package/dist/tui/commands/mcp.d.ts +3 -0
  71. package/dist/tui/commands/mcp.d.ts.map +1 -0
  72. package/dist/tui/commands/mode.d.ts +3 -0
  73. package/dist/tui/commands/mode.d.ts.map +1 -0
  74. package/dist/tui/commands/models-pack.d.ts +3 -0
  75. package/dist/tui/commands/models-pack.d.ts.map +1 -0
  76. package/dist/tui/commands/models.d.ts +3 -0
  77. package/dist/tui/commands/models.d.ts.map +1 -0
  78. package/dist/tui/commands/name.d.ts +3 -0
  79. package/dist/tui/commands/name.d.ts.map +1 -0
  80. package/dist/tui/commands/new.d.ts +3 -0
  81. package/dist/tui/commands/new.d.ts.map +1 -0
  82. package/dist/tui/commands/om.d.ts +3 -0
  83. package/dist/tui/commands/om.d.ts.map +1 -0
  84. package/dist/tui/commands/permissions.d.ts +3 -0
  85. package/dist/tui/commands/permissions.d.ts.map +1 -0
  86. package/dist/tui/commands/resource.d.ts +3 -0
  87. package/dist/tui/commands/resource.d.ts.map +1 -0
  88. package/dist/tui/commands/review.d.ts +3 -0
  89. package/dist/tui/commands/review.d.ts.map +1 -0
  90. package/dist/tui/commands/sandbox.d.ts +3 -0
  91. package/dist/tui/commands/sandbox.d.ts.map +1 -0
  92. package/dist/tui/commands/settings.d.ts +3 -0
  93. package/dist/tui/commands/settings.d.ts.map +1 -0
  94. package/dist/tui/commands/setup.d.ts +3 -0
  95. package/dist/tui/commands/setup.d.ts.map +1 -0
  96. package/dist/tui/commands/skills.d.ts +3 -0
  97. package/dist/tui/commands/skills.d.ts.map +1 -0
  98. package/dist/tui/commands/subagents.d.ts +3 -0
  99. package/dist/tui/commands/subagents.d.ts.map +1 -0
  100. package/dist/tui/commands/think.d.ts +3 -0
  101. package/dist/tui/commands/think.d.ts.map +1 -0
  102. package/dist/tui/commands/thread-tag-dir.d.ts +3 -0
  103. package/dist/tui/commands/thread-tag-dir.d.ts.map +1 -0
  104. package/dist/tui/commands/threads.d.ts +3 -0
  105. package/dist/tui/commands/threads.d.ts.map +1 -0
  106. package/dist/tui/commands/types.d.ts +28 -0
  107. package/dist/tui/commands/types.d.ts.map +1 -0
  108. package/dist/tui/commands/yolo.d.ts +3 -0
  109. package/dist/tui/commands/yolo.d.ts.map +1 -0
  110. package/dist/tui/components/banner.d.ts +9 -0
  111. package/dist/tui/components/banner.d.ts.map +1 -0
  112. package/dist/tui/components/help-overlay.d.ts +15 -0
  113. package/dist/tui/components/help-overlay.d.ts.map +1 -0
  114. package/dist/tui/components/model-selector.d.ts +3 -0
  115. package/dist/tui/components/model-selector.d.ts.map +1 -1
  116. package/dist/tui/components/om-progress.d.ts +4 -30
  117. package/dist/tui/components/om-progress.d.ts.map +1 -1
  118. package/dist/tui/components/settings.d.ts +5 -0
  119. package/dist/tui/components/settings.d.ts.map +1 -1
  120. package/dist/tui/components/tool-execution-enhanced.d.ts.map +1 -1
  121. package/dist/tui/display.d.ts +12 -0
  122. package/dist/tui/display.d.ts.map +1 -0
  123. package/dist/tui/event-dispatch.d.ts +11 -0
  124. package/dist/tui/event-dispatch.d.ts.map +1 -0
  125. package/dist/tui/handlers/agent-lifecycle.d.ts +6 -0
  126. package/dist/tui/handlers/agent-lifecycle.d.ts.map +1 -0
  127. package/dist/tui/handlers/index.d.ts +8 -0
  128. package/dist/tui/handlers/index.d.ts.map +1 -0
  129. package/dist/tui/handlers/message.d.ts +6 -0
  130. package/dist/tui/handlers/message.d.ts.map +1 -0
  131. package/dist/tui/handlers/om.d.ts +11 -0
  132. package/dist/tui/handlers/om.d.ts.map +1 -0
  133. package/dist/tui/handlers/prompts.d.ts +20 -0
  134. package/dist/tui/handlers/prompts.d.ts.map +1 -0
  135. package/dist/tui/handlers/subagent.d.ts +6 -0
  136. package/dist/tui/handlers/subagent.d.ts.map +1 -0
  137. package/dist/tui/handlers/tool.d.ts +30 -0
  138. package/dist/tui/handlers/tool.d.ts.map +1 -0
  139. package/dist/tui/handlers/types.d.ts +33 -0
  140. package/dist/tui/handlers/types.d.ts.map +1 -0
  141. package/dist/tui/mastra-tui.d.ts +9 -221
  142. package/dist/tui/mastra-tui.d.ts.map +1 -1
  143. package/dist/tui/render-messages.d.ts +22 -0
  144. package/dist/tui/render-messages.d.ts.map +1 -0
  145. package/dist/tui/setup.d.ts +17 -0
  146. package/dist/tui/setup.d.ts.map +1 -0
  147. package/dist/tui/shell.d.ts +3 -0
  148. package/dist/tui/shell.d.ts.map +1 -0
  149. package/dist/tui/state.d.ts +4 -24
  150. package/dist/tui/state.d.ts.map +1 -1
  151. package/dist/tui/status-line.d.ts +7 -0
  152. package/dist/tui/status-line.d.ts.map +1 -0
  153. package/dist/tui.cjs +17 -17
  154. package/dist/tui.js +2 -2
  155. package/dist/utils/project.d.ts +37 -9
  156. package/dist/utils/project.d.ts.map +1 -1
  157. package/dist/utils/storage-factory.d.ts +21 -0
  158. package/dist/utils/storage-factory.d.ts.map +1 -0
  159. package/package.json +7 -6
  160. package/dist/chunk-7V6U7OKQ.js.map +0 -1
  161. package/dist/chunk-BQ4ZKTYN.cjs +0 -7915
  162. package/dist/chunk-BQ4ZKTYN.cjs.map +0 -1
  163. package/dist/chunk-BYMDWH2E.js.map +0 -1
  164. package/dist/chunk-FYTZFUHD.js.map +0 -1
  165. package/dist/chunk-LVGWM7ZS.cjs.map +0 -1
  166. package/dist/chunk-QDLLGD43.cjs.map +0 -1
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var chunkLVGWM7ZS_cjs = require('./chunk-LVGWM7ZS.cjs');
3
+ var chunk7K5VFY2N_cjs = require('./chunk-7K5VFY2N.cjs');
4
+ var chunkC6XKRHRK_cjs = require('./chunk-C6XKRHRK.cjs');
4
5
  var chunkMT3YCFCC_cjs = require('./chunk-MT3YCFCC.cjs');
5
6
  var core = require('@mastra/core');
6
7
  var agent = require('@mastra/core/agent');
7
8
  var harness = require('@mastra/core/harness');
8
9
  var logger = require('@mastra/core/logger');
9
- var libsql = require('@mastra/libsql');
10
10
  var fs4 = require('fs');
11
11
  var os = require('os');
12
12
  var path = require('path');
@@ -17,6 +17,8 @@ var child_process = require('child_process');
17
17
  var mcp = require('@mastra/mcp');
18
18
  var zod = require('zod');
19
19
  var llm = require('@mastra/core/llm');
20
+ var libsql = require('@mastra/libsql');
21
+ var pg = require('@mastra/pg');
20
22
 
21
23
  function _interopNamespace(e) {
22
24
  if (e && e.__esModule) return e;
@@ -56,83 +58,15 @@ Current mode: ${ctx.mode}
56
58
  - Your output is displayed on a command line interface. Keep responses concise.
57
59
  - Use Github-flavored markdown for formatting.
58
60
  - Only use emojis if the user explicitly requests it.
59
- - Do NOT use tools to communicate with the user. All text you output is displayed directly.
61
+ - Use tool calls for actions (editing files, running commands, searching, etc.). Use text for communication \u2014 talk to the user in text, not via tools, except for communication tools like \`submit_plan\`, \`ask_user\`, and \`task_write\`.
60
62
  - Prioritize technical accuracy over validating the user's beliefs. Be direct and objective. Respectful correction is more valuable than false agreement.
61
63
 
62
- # Tool Usage Rules
63
-
64
- IMPORTANT: You can ONLY call tools by their exact registered names listed below. Shell commands like \`git\`, \`npm\`, \`ls\`, etc. are NOT tools \u2014 they must be run via the \`execute_command\` tool.
65
-
66
- You have access to the following tools. Use the RIGHT tool for the job:
67
-
68
- **view** \u2014 Read file contents or list directories
69
- - Use this to read files before editing them. NEVER propose changes to code you haven't read.
70
- - Use \`view_range\` for large files to read specific sections.
71
- - For directory listings, this shows 2 levels deep.
72
- - Example: To check lines 50-100 of a large file: \`view("src/big-file.ts", { view_range: [50, 100] })\`
73
-
74
- **grep** \u2014 Search file contents using regex
75
- - Use this for ALL content search (finding functions, variables, error messages, imports, etc.)
76
- - NEVER use \`execute_command\` with grep, rg, or ag. Always use the grep tool.
77
- - Supports regex patterns, file type filtering, and context lines.
78
- - Example: Find where a function is defined: \`grep("function handleSubmit", { glob: "**/*.ts" })\`
79
- - Example: Find all imports of a module: \`grep("from ['"]express['"]", { glob: "**/*.ts" })\`
80
-
81
- **glob** \u2014 Find files by name pattern
82
- - Use this to find files matching a pattern (e.g., "**/*.ts", "src/**/test*").
83
- - NEVER use \`execute_command\` with find or ls for file search. Always use glob.
84
- - Respects .gitignore automatically.
85
- - Example: Find all test files: \`glob("**/*.test.ts")\`
86
- - Example: Find config files: \`glob("**/config.{js,ts,json}")\`
87
-
88
- **string_replace_lsp** \u2014 Edit files by replacing exact text
89
- - You MUST read a file with \`view\` before editing it.
90
- - \`old_str\` must be an exact match of existing text in the file.
91
- - Provide enough surrounding context in \`old_str\` to make it unique.
92
- - For creating new files, use \`write_file\` instead.
93
- - Good: Include 2-3 lines of surrounding context to ensure uniqueness.
94
- - Bad: Using just \`return true;\` \u2014 too common, will match multiple places.
95
-
96
- **write_file** \u2014 Create new files or overwrite existing ones
97
- - Use this to create new files.
98
- - If overwriting an existing file, you MUST have read it first with \`view\`.
99
- - NEVER create files unless necessary. Prefer editing existing files.
100
-
101
- **execute_command** \u2014 Run shell commands
102
- - Use for: git, npm/pnpm, docker, build tools, test runners, and other terminal operations.
103
- - Do NOT use for: file reading (use view), file search (use grep/glob), file editing (use string_replace_lsp/write_file).
104
- - Commands have a 30-second default timeout. Use the \`timeout\` parameter for longer-running commands.
105
- - Pipe to \`| tail -N\` for commands with long output \u2014 the full output streams to the user, only the last N lines are returned to you. If you're building any kind of package you should be tailing.
106
- - Good: Run independent commands in parallel when possible.
107
- - Bad: Running \`cat file.txt\` \u2014 use the view tool instead.
108
-
109
- **web_search** / **web_extract** \u2014 Search the web / extract page content
110
- - Use for looking up documentation, error messages, package APIs.
111
- - Available depending on the model and API keys configured.
112
-
113
- **task_write** \u2014 Track tasks for complex multi-step work
114
- - Use when a task requires 3 or more distinct steps or actions.
115
- - Pass the FULL task list each time (replaces previous list).
116
- - Mark tasks \`in_progress\` BEFORE starting work. Only ONE task should be \`in_progress\` at a time.
117
- - Mark tasks \`completed\` IMMEDIATELY after finishing each task. Do not batch completions.
118
- - Each task has: content (imperative form), status (pending|in_progress|completed), activeForm (present continuous form shown during execution).
119
-
120
- **task_check** \u2014 Check completion status of tasks
121
- - Use this BEFORE deciding you're done with a task to verify all tasks are completed.
122
- - Returns the number of completed, in progress, and pending tasks.
123
- - If any tasks remain incomplete, continue working on them.
124
- - IMPORTANT: Always check task completion before ending work on a complex task.
125
-
126
- **ask_user** \u2014 Ask the user a structured question
127
- - Use when you need clarification, want to validate assumptions, or need the user to make a decision.
128
- - Provide clear, specific questions. End with a question mark.
129
- - Include options (2-4 choices) for structured decisions. Omit options for open-ended questions.
130
- - Don't use this for simple yes/no \u2014 just ask in your text response.
64
+ ${ctx.toolGuidance}
131
65
 
132
66
  # How to Work on Tasks
133
67
 
134
68
  ## Start by Understanding
135
- - Read relevant code before making changes. Use grep/glob to find related files.
69
+ - Read relevant code before making changes. Use search_content/find_files to find related files.
136
70
  - For unfamiliar codebases, check git log to understand recent changes and patterns.
137
71
  - Identify existing conventions (naming, structure, error handling) and follow them.
138
72
 
@@ -168,7 +102,7 @@ You have access to the following tools. Use the RIGHT tool for the job:
168
102
  Don't commit files likely to contain secrets (\`.env\`, \`*.key\`, \`credentials.json\`). Warn if asked.
169
103
 
170
104
  ## Commits
171
- Write commit messages that explain WHY, not just WHAT. Match the repo's existing style. Include \`Co-Authored-By: Mastra Code <noreply@mastra.ai>\` in the message body.
105
+ Write commit messages that explain WHY, not just WHAT. Match the repo's existing style. Include \`Co-Authored-By: Mastra Code${ctx.modelId ? ` (${ctx.modelId})` : ""} <noreply@mastra.ai>\` in the message body.
172
106
 
173
107
  ## Pull Requests
174
108
  Use \`gh pr create\`. Include a summary of what changed and a test plan.
@@ -178,7 +112,7 @@ Use \`gh pr create\`. Include a summary of what changed and a test plan.
178
112
  - 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.
179
113
 
180
114
  # Important Reminders
181
- - NEVER guess file paths or function signatures. Use grep/glob to find them.
115
+ - NEVER guess file paths or function signatures. Use search_content/find_files to find them.
182
116
  - NEVER make up URLs. Only use URLs the user provides or that you find in the codebase.
183
117
  - When referencing code locations, include the file path and line number.
184
118
  - If you're unsure about something, ask the user rather than guessing.
@@ -268,17 +202,8 @@ You are in PLAN mode. Your job is to explore the codebase and design an implemen
268
202
 
269
203
  This mode is **strictly read-only**. You must NOT modify anything.
270
204
 
271
- **Allowed tools:**
272
- - \`view\` \u2014 read files and directories
273
- - \`grep\` \u2014 search file contents
274
- - \`glob\` \u2014 find files by pattern
275
- - \`execute_command\` \u2014 ONLY for read-only commands (git status, git log, git diff, etc.)
276
- - \`submit_plan\` \u2014 submit your completed plan
277
-
278
- **Prohibited actions:**
279
- - Do NOT use \`string_replace_lsp\` or \`write_file\` \u2014 no file modifications
280
- - Do NOT use \`execute_command\` for anything that changes state (no git commit, no npm install, no file creation)
281
- - Do NOT create, delete, or modify any files
205
+ - Do NOT modify, create, or delete any files
206
+ - Do NOT run commands that change state (no git commit, no npm install, no file creation)
282
207
  - Do NOT run build commands, tests, or scripts that have side effects
283
208
 
284
209
  If the user asks you to make changes while in Plan mode, explain that you're in read-only mode and they should switch to Build mode (\`/mode build\`) first.
@@ -287,7 +212,7 @@ If the user asks you to make changes while in Plan mode, explain that you're in
287
212
 
288
213
  Before writing any plan, build a mental model of the codebase:
289
214
  1. Start with the directory structure (\`view\` on the project root or relevant subdirectory).
290
- 2. Find the relevant entry points and core files using \`grep\` and \`glob\`.
215
+ 2. Find the relevant entry points and core files using \`search_content\` and \`find_files\`.
291
216
  3. Read the actual code \u2014 don't assume based on file names alone.
292
217
  4. Trace data flow: where does input come from, how is it transformed, where does it go?
293
218
  5. Identify existing patterns the codebase uses (naming, structure, error handling, testing).
@@ -315,11 +240,19 @@ For each step:
315
240
  - What to check manually
316
241
  - What could go wrong
317
242
 
318
- ## When Done
243
+ ## IMMEDIATE ACTION: Call submit_plan Tool
319
244
 
320
- When your plan is complete, call the \`submit_plan\` tool with:
321
- - **title**: A short descriptive title (e.g., "Add dark mode toggle")
322
- - **plan**: The full plan in markdown, using the structure above (Overview, Complexity, Steps, Verification)
245
+ As soon as your plan is complete, **STOP** and call the \`submit_plan\` tool immediately.
246
+
247
+ **CRITICAL:** Do NOT generate a long text response describing your plan. The plan content belongs in the \`submit_plan\` tool call, not in your text output.
248
+
249
+ When done, call:
250
+ \`\`\`javascript
251
+ submit_plan({
252
+ title: "short descriptive title",
253
+ plan: "your full plan in markdown"
254
+ })
255
+ \`\`\`
323
256
 
324
257
  The user will see the plan rendered inline and can:
325
258
  - **Approve** \u2014 automatically switches to Build mode for implementation
@@ -412,6 +345,96 @@ ${sections.join("\n\n")}
412
345
  `;
413
346
  }
414
347
 
348
+ // src/agents/prompts/tool-guidance.ts
349
+ function buildToolGuidance(modeId, options = {}) {
350
+ const sections = [];
351
+ sections.push(`# Tool Usage Rules
352
+
353
+ IMPORTANT: You can ONLY call tools by their exact registered names listed below. Shell commands like \`git\`, \`npm\`, \`ls\`, etc. are NOT tools \u2014 they must be run via the \`execute_command\` tool.
354
+
355
+ You have access to the following tools. Use the RIGHT tool for the job:`);
356
+ sections.push(`
357
+ **view** \u2014 Read file contents or list directories
358
+ - Use this to read files before editing them. NEVER propose changes to code you haven't read.
359
+ - Use \`view_range\` for large files to read specific sections.
360
+ - For directory listings, this shows 2 levels deep.
361
+ - Example: To check lines 50-100 of a large file: \`view("src/big-file.ts", { view_range: [50, 100] })\`
362
+
363
+ **search_content** \u2014 Search file contents using regex
364
+ - Use this for ALL content search (finding functions, variables, error messages, imports, etc.)
365
+ - NEVER use \`execute_command\` with grep, rg, or ag. Always use the search_content tool.
366
+ - Supports regex patterns, file type filtering, and context lines.
367
+ - Example: Find where a function is defined: \`search_content("function handleSubmit", { glob: "**/*.ts" })\`
368
+ - Example: Find all imports of a module: \`search_content("from ['\\"]express['\\"]", { glob: "**/*.ts" })\`
369
+
370
+ **find_files** \u2014 Find files by name pattern
371
+ - Use this to find files matching a pattern (e.g., "**/*.ts", "src/**/test*").
372
+ - NEVER use \`execute_command\` with find or ls for file search. Always use find_files.
373
+ - Respects .gitignore automatically.
374
+ - Example: Find all test files: \`find_files("**/*.test.ts")\`
375
+ - Example: Find config files: \`find_files("**/config.{js,ts,json}")\`
376
+
377
+ **execute_command** \u2014 Run shell commands
378
+ - Use for: git, npm/pnpm, docker, build tools, test runners, and other terminal operations.
379
+ - Do NOT use for: file reading (use view), file search (use search_content/find_files), file editing (use string_replace_lsp/write_file).
380
+ - Commands have a 30-second default timeout. Use the \`timeout\` parameter for longer-running commands.
381
+ - Pipe to \`| tail -N\` for commands with long output \u2014 the full output streams to the user, only the last N lines are returned to you. If you're building any kind of package you should be tailing.
382
+ - Good: Run independent commands in parallel when possible.
383
+ - Bad: Running \`cat file.txt\` \u2014 use the view tool instead.`);
384
+ if (modeId !== "plan") {
385
+ sections.push(`
386
+ **string_replace_lsp** \u2014 Edit files by replacing exact text
387
+ - You MUST read a file with \`view\` before editing it.
388
+ - \`old_str\` must be an exact match of existing text in the file.
389
+ - Provide enough surrounding context in \`old_str\` to make it unique.
390
+ - For creating new files, use \`write_file\` instead.
391
+ - Good: Include 2-3 lines of surrounding context to ensure uniqueness.
392
+ - Bad: Using just \`return true;\` \u2014 too common, will match multiple places.
393
+
394
+ **write_file** \u2014 Create new files or overwrite existing ones
395
+ - Use this to create new files.
396
+ - If overwriting an existing file, you MUST have read it first with \`view\`.
397
+ - NEVER create files unless necessary. Prefer editing existing files.`);
398
+ }
399
+ if (options.hasWebSearch) {
400
+ sections.push(`
401
+ **web_search** / **web_extract** \u2014 Search the web / extract page content
402
+ - Use for looking up documentation, error messages, package APIs.`);
403
+ }
404
+ sections.push(`
405
+ **task_write** \u2014 Track tasks for complex multi-step work
406
+ - Use when a task requires 3 or more distinct steps or actions.
407
+ - Pass the FULL task list each time (replaces previous list).
408
+ - Mark tasks \`in_progress\` BEFORE starting work. Only ONE task should be \`in_progress\` at a time.
409
+ - Mark tasks \`completed\` IMMEDIATELY after finishing each task. Do not batch completions.
410
+ - Each task has: content (imperative form), status (pending|in_progress|completed), activeForm (present continuous form shown during execution).
411
+
412
+ **task_check** \u2014 Check completion status of tasks
413
+ - Use this BEFORE deciding you're done with a task to verify all tasks are completed.
414
+ - Returns the number of completed, in progress, and pending tasks.
415
+ - If any tasks remain incomplete, continue working on them.
416
+ - IMPORTANT: Always check task completion before ending work on a complex task.
417
+
418
+ **ask_user** \u2014 Ask the user a structured question
419
+ - Use when you need clarification, want to validate assumptions, or need the user to make a decision.
420
+ - Provide clear, specific questions. End with a question mark.
421
+ - Include options (2-4 choices) for structured decisions. Omit options for open-ended questions.
422
+ - Don't use this for simple yes/no \u2014 just ask in your text response.`);
423
+ if (modeId === "plan") {
424
+ sections.push(`
425
+ **submit_plan** \u2014 Submit a completed implementation plan for user review
426
+ - Call this tool when your plan is complete. Do NOT just describe your plan in text \u2014 you MUST call this tool.
427
+ - The plan will be rendered as markdown and the user can approve, reject, or request changes.
428
+ - On approval, the system automatically switches to the default mode so you can implement.
429
+ - Takes two arguments: \`title\` (short descriptive title) and \`plan\` (full plan in markdown).`);
430
+ }
431
+ sections.push(`
432
+ **subagent** \u2014 Delegate a focused task to a specialized subagent
433
+ - Only use subagents when you will spawn **multiple subagents in parallel**. If you only need one task done, do it yourself.
434
+ - Subagent outputs are **untrusted**. Always review and verify the results.`);
435
+ return sections.join("\n");
436
+ }
437
+
415
438
  // src/agents/prompts/index.ts
416
439
  var modePrompts = {
417
440
  build: buildModePromptFn,
@@ -419,23 +442,22 @@ var modePrompts = {
419
442
  fast: fastModePrompt
420
443
  };
421
444
  function buildFullPrompt(ctx) {
445
+ const modelId = ctx.state?.currentModelId;
446
+ const hasWebSearch = chunk7K5VFY2N_cjs.hasTavilyKey() || !!modelId && modelId.startsWith("anthropic/");
447
+ const toolGuidance = buildToolGuidance(ctx.modeId, { hasWebSearch });
422
448
  const baseCtx = {
423
449
  projectPath: ctx.workingDir,
424
450
  projectName: ctx.projectName || "unknown",
425
451
  gitBranch: ctx.gitBranch,
426
452
  platform: process.platform,
427
453
  date: ctx.currentDate,
428
- mode: ctx.modeId};
454
+ mode: ctx.modeId,
455
+ modelId: ctx.modelId,
456
+ toolGuidance
457
+ };
429
458
  const base = buildBasePrompt(baseCtx);
430
459
  const entry = modePrompts[ctx.modeId] || modePrompts.build;
431
460
  const modeSpecific = typeof entry === "function" ? entry(ctx) : entry;
432
- let toolsSection = "";
433
- if (ctx.availableTools) {
434
- toolsSection = `
435
- # Available Tools for ${ctx.modeId} mode:
436
- ${ctx.availableTools}
437
- `;
438
- }
439
461
  let taskSection = "";
440
462
  const tasks = ctx.state?.tasks;
441
463
  if (tasks && tasks.length > 0) {
@@ -451,7 +473,7 @@ ${lines.join("\n")}
451
473
  }
452
474
  const instructionSources = loadAgentInstructions(ctx.workingDir);
453
475
  const instructionsSection = formatAgentInstructions(instructionSources);
454
- return base + toolsSection + taskSection + instructionsSection + "\n" + modeSpecific;
476
+ return base + taskSection + instructionsSection + "\n" + modeSpecific;
455
477
  }
456
478
 
457
479
  // src/agents/instructions.ts
@@ -466,6 +488,7 @@ function getDynamicInstructions({ requestContext }) {
466
488
  platform: process.platform,
467
489
  date: (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
468
490
  mode: modeId,
491
+ modelId: state?.currentModelId || void 0,
469
492
  activePlan: state?.activePlan ?? null,
470
493
  modeId,
471
494
  currentDate: (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
@@ -488,16 +511,16 @@ function getHarnessState(requestContext) {
488
511
  }
489
512
  function getObserverModel({ requestContext }) {
490
513
  const state = getHarnessState(requestContext);
491
- return chunkLVGWM7ZS_cjs.resolveModel(state?.observerModelId ?? DEFAULT_OM_MODEL_ID);
514
+ return chunk7K5VFY2N_cjs.resolveModel(state?.observerModelId ?? DEFAULT_OM_MODEL_ID);
492
515
  }
493
516
  function getReflectorModel({ requestContext }) {
494
517
  const state = getHarnessState(requestContext);
495
- return chunkLVGWM7ZS_cjs.resolveModel(state?.reflectorModelId ?? DEFAULT_OM_MODEL_ID);
518
+ return chunk7K5VFY2N_cjs.resolveModel(state?.reflectorModelId ?? DEFAULT_OM_MODEL_ID);
496
519
  }
497
520
  function getDynamicMemory(storage) {
498
521
  return ({ requestContext }) => {
499
522
  const state = getHarnessState(requestContext);
500
- const omScope = chunkLVGWM7ZS_cjs.getOmScope(state?.projectPath);
523
+ const omScope = chunkC6XKRHRK_cjs.getOmScope(state?.projectPath);
501
524
  const obsThreshold = state?.observationThreshold ?? DEFAULT_OBS_THRESHOLD;
502
525
  const refThreshold = state?.reflectionThreshold ?? DEFAULT_REF_THRESHOLD;
503
526
  const cacheKey = `${obsThreshold}:${refThreshold}:${omScope}`;
@@ -544,26 +567,26 @@ function createDynamicTools(mcpManager) {
544
567
  const modelId = state?.currentModelId;
545
568
  const isAnthropicModel = modelId?.startsWith("anthropic/");
546
569
  const projectPath = state?.projectPath ?? "";
547
- const viewTool = chunkLVGWM7ZS_cjs.createViewTool(projectPath);
548
- const grepTool = chunkLVGWM7ZS_cjs.createGrepTool(projectPath);
549
- const globTool = chunkLVGWM7ZS_cjs.createGlobTool(projectPath);
550
- const executeCommandTool = chunkLVGWM7ZS_cjs.createExecuteCommandTool(projectPath);
551
- const writeFileTool = chunkLVGWM7ZS_cjs.createWriteFileTool(projectPath);
570
+ const viewTool = chunk7K5VFY2N_cjs.createViewTool(projectPath);
571
+ const grepTool = chunk7K5VFY2N_cjs.createGrepTool(projectPath);
572
+ const globTool = chunk7K5VFY2N_cjs.createGlobTool(projectPath);
573
+ const executeCommandTool = chunk7K5VFY2N_cjs.createExecuteCommandTool(projectPath);
574
+ const writeFileTool = chunk7K5VFY2N_cjs.createWriteFileTool(projectPath);
552
575
  const tools = {
553
576
  view: viewTool,
554
577
  search_content: grepTool,
555
578
  find_files: globTool,
556
579
  execute_command: executeCommandTool,
557
- request_sandbox_access: chunkLVGWM7ZS_cjs.requestSandboxAccessTool
580
+ request_sandbox_access: chunk7K5VFY2N_cjs.requestSandboxAccessTool
558
581
  };
559
582
  if (modeId !== "plan") {
560
- tools.string_replace_lsp = chunkLVGWM7ZS_cjs.stringReplaceLspTool;
561
- tools.ast_smart_edit = chunkLVGWM7ZS_cjs.astSmartEditTool;
583
+ tools.string_replace_lsp = chunk7K5VFY2N_cjs.stringReplaceLspTool;
584
+ tools.ast_smart_edit = chunk7K5VFY2N_cjs.astSmartEditTool;
562
585
  tools.write_file = writeFileTool;
563
586
  }
564
- if (chunkLVGWM7ZS_cjs.hasTavilyKey()) {
565
- tools.web_search = chunkLVGWM7ZS_cjs.createWebSearchTool();
566
- tools.web_extract = chunkLVGWM7ZS_cjs.createWebExtractTool();
587
+ if (chunk7K5VFY2N_cjs.hasTavilyKey()) {
588
+ tools.web_search = chunk7K5VFY2N_cjs.createWebSearchTool();
589
+ tools.web_extract = chunk7K5VFY2N_cjs.createWebExtractTool();
567
590
  } else if (isAnthropicModel) {
568
591
  const anthropic$1 = anthropic.createAnthropic({});
569
592
  tools.web_search = anthropic$1.tools.webSearch_20250305();
@@ -635,6 +658,11 @@ function getDynamicWorkspace({ requestContext }) {
635
658
  workingDirectory: projectPath,
636
659
  env: process.env
637
660
  }),
661
+ // Disable workspace tools — built-in tools are used instead.
662
+ // Workspace tools use different output formats (e.g. → separator, offset/limit params)
663
+ // that the TUI renderers don't fully support yet.
664
+ // We will update to use workspace tools very soon - just disabling until then
665
+ tools: { enabled: false },
638
666
  ...skillPaths.length > 0 ? { skills: skillPaths } : {}
639
667
  });
640
668
  workspace$1.filesystem.setAllowedPaths([...skillPaths, ...sandboxPaths.map((p) => path__namespace.default.resolve(p))]);
@@ -1305,43 +1333,91 @@ async function syncGateways(force = false) {
1305
1333
  isSyncing = false;
1306
1334
  }
1307
1335
  }
1336
+ function createFallbackLibSQL() {
1337
+ return new libsql.LibSQLStore({
1338
+ id: "mastra-code-storage",
1339
+ url: `file:${chunkC6XKRHRK_cjs.getDatabasePath()}`
1340
+ });
1341
+ }
1342
+ async function createStorage(config) {
1343
+ if (config.backend === "pg") {
1344
+ return createPgStorage(config);
1345
+ }
1346
+ return {
1347
+ storage: new libsql.LibSQLStore({
1348
+ id: "mastra-code-storage",
1349
+ url: config.url,
1350
+ ...config.authToken ? { authToken: config.authToken } : {}
1351
+ })
1352
+ };
1353
+ }
1354
+ async function createPgStorage(config) {
1355
+ if (!config.connectionString && !config.host) {
1356
+ return {
1357
+ storage: createFallbackLibSQL(),
1358
+ warning: "PostgreSQL backend selected but no connection info configured. Using LibSQL fallback. Set a connection string via /settings."
1359
+ };
1360
+ }
1361
+ const base = {
1362
+ id: "mastra-code-storage",
1363
+ ...config.schemaName ? { schemaName: config.schemaName } : {},
1364
+ ...config.disableInit ? { disableInit: config.disableInit } : {},
1365
+ ...config.skipDefaultIndexes ? { skipDefaultIndexes: config.skipDefaultIndexes } : {}
1366
+ };
1367
+ const store = config.connectionString ? new pg.PostgresStore({ ...base, connectionString: config.connectionString }) : new pg.PostgresStore({
1368
+ ...base,
1369
+ host: config.host,
1370
+ port: config.port,
1371
+ database: config.database,
1372
+ user: config.user,
1373
+ password: config.password
1374
+ });
1375
+ try {
1376
+ await store.init();
1377
+ } catch (err) {
1378
+ const msg = err?.message ?? String(err);
1379
+ const target = config.connectionString ?? `${config.host}:${config.port ?? 5432}`;
1380
+ try {
1381
+ await store.close();
1382
+ } catch {
1383
+ }
1384
+ return {
1385
+ storage: createFallbackLibSQL(),
1386
+ warning: `Failed to connect to PostgreSQL at ${target}: ${msg}
1387
+ Using LibSQL fallback. Fix the connection via /settings.`
1388
+ };
1389
+ }
1390
+ return { storage: store };
1391
+ }
1308
1392
 
1309
1393
  // src/index.ts
1310
1394
  var PROVIDER_TO_OAUTH_ID = {
1311
1395
  anthropic: "anthropic",
1312
1396
  openai: "openai-codex"
1313
1397
  };
1314
- function createMastraCode(config) {
1398
+ async function createMastraCode(config) {
1315
1399
  const cwd = config?.cwd ?? process.cwd();
1316
- const authStorage = new chunkLVGWM7ZS_cjs.AuthStorage();
1317
- chunkLVGWM7ZS_cjs.setAuthStorage(authStorage);
1318
- chunkLVGWM7ZS_cjs.setAuthStorage2(authStorage);
1319
- const project = chunkLVGWM7ZS_cjs.detectProject(cwd);
1320
- const resourceIdOverride = chunkLVGWM7ZS_cjs.getResourceIdOverride(project.rootPath);
1400
+ const authStorage = new chunkC6XKRHRK_cjs.AuthStorage();
1401
+ chunk7K5VFY2N_cjs.setAuthStorage(authStorage);
1402
+ chunk7K5VFY2N_cjs.setAuthStorage2(authStorage);
1403
+ const project = chunkC6XKRHRK_cjs.detectProject(cwd);
1404
+ const resourceIdOverride = chunkC6XKRHRK_cjs.getResourceIdOverride(project.rootPath);
1321
1405
  if (resourceIdOverride) {
1322
1406
  project.resourceId = resourceIdOverride;
1323
1407
  project.resourceIdOverride = true;
1324
1408
  }
1325
- console.info(`Project: ${project.name}`);
1326
- console.info(`Resource ID: ${project.resourceId}${project.resourceIdOverride ? " (override)" : ""}`);
1327
- if (project.gitBranch) console.info(`Branch: ${project.gitBranch}`);
1328
- if (project.isWorktree) console.info(`Worktree of: ${project.mainRepoPath}`);
1329
- const userId = chunkLVGWM7ZS_cjs.getUserId(project.rootPath);
1330
- console.info(`User: ${userId}`);
1331
- console.info("--------------------------------");
1332
- const storageConfig = config?.storage ?? chunkLVGWM7ZS_cjs.getStorageConfig(project.rootPath);
1333
- const storage = new libsql.LibSQLStore({
1334
- id: "mastra-code-storage",
1335
- url: storageConfig.url,
1336
- ...storageConfig.authToken ? { authToken: storageConfig.authToken } : {}
1337
- });
1409
+ const globalSettings = chunk7K5VFY2N_cjs.loadSettings();
1410
+ const storageConfig = config?.storage ?? chunkC6XKRHRK_cjs.getStorageConfig(project.rootPath, globalSettings.storage);
1411
+ const storageResult = await createStorage(storageConfig);
1412
+ const storage = storageResult.storage;
1413
+ const storageWarning = storageResult.warning;
1338
1414
  const memory = getDynamicMemory(storage);
1339
1415
  const mcpManager = config?.disableMcp ? void 0 : createMcpManager(project.rootPath);
1340
1416
  const codeAgentInstance = new agent.Agent({
1341
1417
  id: "code-agent",
1342
1418
  name: "Code Agent",
1343
1419
  instructions: getDynamicInstructions,
1344
- model: chunkLVGWM7ZS_cjs.getDynamicModel,
1420
+ model: chunk7K5VFY2N_cjs.getDynamicModel,
1345
1421
  tools: createDynamicTools(mcpManager)
1346
1422
  });
1347
1423
  const mastraInstance = new core.Mastra({
@@ -1356,11 +1432,11 @@ function createMastraCode(config) {
1356
1432
  const hookCount = Object.values(hookConfig).reduce((sum, hooks) => sum + (hooks?.length ?? 0), 0);
1357
1433
  console.info(`Hooks: ${hookCount} hook(s) configured`);
1358
1434
  }
1359
- const viewTool = chunkLVGWM7ZS_cjs.createViewTool(project.rootPath);
1360
- const grepTool = chunkLVGWM7ZS_cjs.createGrepTool(project.rootPath);
1361
- const globTool = chunkLVGWM7ZS_cjs.createGlobTool(project.rootPath);
1362
- const executeCommandTool = chunkLVGWM7ZS_cjs.createExecuteCommandTool(project.rootPath);
1363
- const writeFileTool = chunkLVGWM7ZS_cjs.createWriteFileTool(project.rootPath);
1435
+ const viewTool = chunk7K5VFY2N_cjs.createViewTool(project.rootPath);
1436
+ const grepTool = chunk7K5VFY2N_cjs.createGrepTool(project.rootPath);
1437
+ const globTool = chunk7K5VFY2N_cjs.createGlobTool(project.rootPath);
1438
+ const executeCommandTool = chunk7K5VFY2N_cjs.createExecuteCommandTool(project.rootPath);
1439
+ const writeFileTool = chunk7K5VFY2N_cjs.createWriteFileTool(project.rootPath);
1364
1440
  const readOnlyTools = {
1365
1441
  view: viewTool,
1366
1442
  search_content: grepTool,
@@ -1368,27 +1444,27 @@ function createMastraCode(config) {
1368
1444
  };
1369
1445
  const defaultSubagents = [
1370
1446
  {
1371
- id: chunkLVGWM7ZS_cjs.exploreSubagent.id,
1372
- name: chunkLVGWM7ZS_cjs.exploreSubagent.name,
1447
+ id: chunk7K5VFY2N_cjs.exploreSubagent.id,
1448
+ name: chunk7K5VFY2N_cjs.exploreSubagent.name,
1373
1449
  description: "Read-only codebase exploration. Use for questions like 'find all usages of X', 'how does module Y work'.",
1374
- instructions: chunkLVGWM7ZS_cjs.exploreSubagent.instructions,
1450
+ instructions: chunk7K5VFY2N_cjs.exploreSubagent.instructions,
1375
1451
  tools: readOnlyTools
1376
1452
  },
1377
1453
  {
1378
- id: chunkLVGWM7ZS_cjs.planSubagent.id,
1379
- name: chunkLVGWM7ZS_cjs.planSubagent.name,
1454
+ id: chunk7K5VFY2N_cjs.planSubagent.id,
1455
+ name: chunk7K5VFY2N_cjs.planSubagent.name,
1380
1456
  description: "Read-only analysis and planning. Use for 'create an implementation plan for X', 'analyze the architecture of Y'.",
1381
- instructions: chunkLVGWM7ZS_cjs.planSubagent.instructions,
1457
+ instructions: chunk7K5VFY2N_cjs.planSubagent.instructions,
1382
1458
  tools: readOnlyTools
1383
1459
  },
1384
1460
  {
1385
- id: chunkLVGWM7ZS_cjs.executeSubagent.id,
1386
- name: chunkLVGWM7ZS_cjs.executeSubagent.name,
1461
+ id: chunk7K5VFY2N_cjs.executeSubagent.id,
1462
+ name: chunk7K5VFY2N_cjs.executeSubagent.name,
1387
1463
  description: "Task execution with write capabilities. Use for 'implement feature X', 'fix bug Y', 'refactor module Z'.",
1388
- instructions: chunkLVGWM7ZS_cjs.executeSubagent.instructions,
1464
+ instructions: chunk7K5VFY2N_cjs.executeSubagent.instructions,
1389
1465
  tools: {
1390
1466
  ...readOnlyTools,
1391
- string_replace_lsp: chunkLVGWM7ZS_cjs.stringReplaceLspTool,
1467
+ string_replace_lsp: chunk7K5VFY2N_cjs.stringReplaceLspTool,
1392
1468
  write_file: writeFileTool,
1393
1469
  execute_command: executeCommandTool,
1394
1470
  task_write: harness.taskWriteTool,
@@ -1402,21 +1478,21 @@ function createMastraCode(config) {
1402
1478
  name: "Build",
1403
1479
  default: true,
1404
1480
  defaultModelId: "anthropic/claude-opus-4-6",
1405
- color: chunkLVGWM7ZS_cjs.mastra.purple,
1481
+ color: chunk7K5VFY2N_cjs.mastra.purple,
1406
1482
  agent: codeAgent
1407
1483
  },
1408
1484
  {
1409
1485
  id: "plan",
1410
1486
  name: "Plan",
1411
1487
  defaultModelId: "openai/gpt-5.2-codex",
1412
- color: chunkLVGWM7ZS_cjs.mastra.blue,
1488
+ color: chunk7K5VFY2N_cjs.mastra.blue,
1413
1489
  agent: codeAgent
1414
1490
  },
1415
1491
  {
1416
1492
  id: "fast",
1417
1493
  name: "Fast",
1418
1494
  defaultModelId: "cerebras/zai-glm-4.7",
1419
- color: chunkLVGWM7ZS_cjs.mastra.green,
1495
+ color: chunk7K5VFY2N_cjs.mastra.green,
1420
1496
  agent: codeAgent
1421
1497
  }
1422
1498
  ];
@@ -1427,24 +1503,61 @@ function createMastraCode(config) {
1427
1503
  handler: () => syncGateways()
1428
1504
  }
1429
1505
  ];
1506
+ const startupAccess = {
1507
+ anthropic: authStorage.isLoggedIn("anthropic") ? "oauth" : process.env.ANTHROPIC_API_KEY ? "apikey" : false,
1508
+ openai: authStorage.isLoggedIn("openai-codex") ? "oauth" : process.env.OPENAI_API_KEY ? "apikey" : false,
1509
+ cerebras: process.env.CEREBRAS_API_KEY ? "apikey" : false,
1510
+ google: process.env.GOOGLE_GENERATIVE_AI_API_KEY ? "apikey" : false,
1511
+ deepseek: process.env.DEEPSEEK_API_KEY ? "apikey" : false
1512
+ };
1513
+ const builtinPacks = chunk7K5VFY2N_cjs.getAvailableModePacks(startupAccess);
1514
+ const builtinOmPacks = chunk7K5VFY2N_cjs.getAvailableOmPacks(startupAccess);
1515
+ const effectiveDefaults = chunk7K5VFY2N_cjs.resolveModelDefaults(globalSettings, builtinPacks);
1516
+ const effectiveOmModel = chunk7K5VFY2N_cjs.resolveOmModel(globalSettings, builtinOmPacks);
1517
+ const modes = (config?.modes ?? defaultModes).map((mode) => {
1518
+ const savedModel = effectiveDefaults[mode.id];
1519
+ return savedModel ? { ...mode, defaultModelId: savedModel } : mode;
1520
+ });
1521
+ const subagentModeMap = { explore: "fast", plan: "plan", execute: "build" };
1522
+ const subagents = (config?.subagents ?? defaultSubagents).map((sa) => {
1523
+ const modeId = subagentModeMap[sa.id];
1524
+ const model = modeId ? effectiveDefaults[modeId] : void 0;
1525
+ return model ? { ...sa, defaultModelId: model } : sa;
1526
+ });
1527
+ const globalInitialState = {};
1528
+ if (effectiveOmModel) {
1529
+ globalInitialState.observerModelId = effectiveOmModel;
1530
+ globalInitialState.reflectorModelId = effectiveOmModel;
1531
+ }
1532
+ if (globalSettings.preferences.yolo !== null) {
1533
+ globalInitialState.yolo = globalSettings.preferences.yolo;
1534
+ }
1535
+ for (const [key, modelId] of Object.entries(globalSettings.models.subagentModels)) {
1536
+ if (key === "_default") {
1537
+ globalInitialState.subagentModelId = modelId;
1538
+ } else {
1539
+ globalInitialState[`subagentModelId_${key}`] = modelId;
1540
+ }
1541
+ }
1430
1542
  const harness$1 = new harness.Harness({
1431
1543
  id: "mastra-code",
1432
1544
  resourceId: project.resourceId,
1433
1545
  storage,
1434
1546
  memory,
1435
1547
  stateSchema,
1436
- subagents: config?.subagents ?? defaultSubagents,
1437
- resolveModel: chunkLVGWM7ZS_cjs.resolveModel,
1548
+ subagents,
1549
+ resolveModel: chunk7K5VFY2N_cjs.resolveModel,
1438
1550
  toolCategoryResolver: chunkMT3YCFCC_cjs.getToolCategory,
1439
1551
  initialState: {
1440
1552
  projectPath: project.rootPath,
1441
1553
  projectName: project.name,
1442
1554
  gitBranch: project.gitBranch,
1443
1555
  yolo: true,
1556
+ ...globalInitialState,
1444
1557
  ...config?.initialState
1445
1558
  },
1446
1559
  workspace: getDynamicWorkspace,
1447
- modes: config?.modes ?? defaultModes,
1560
+ modes,
1448
1561
  heartbeatHandlers: config?.heartbeatHandlers ?? defaultHeartbeatHandlers,
1449
1562
  modelAuthChecker: (provider) => {
1450
1563
  const oauthId = PROVIDER_TO_OAUTH_ID[provider];
@@ -1453,10 +1566,10 @@ function createMastraCode(config) {
1453
1566
  }
1454
1567
  return void 0;
1455
1568
  },
1456
- modelUseCountProvider: () => authStorage.getAllModelUseCounts(),
1569
+ modelUseCountProvider: () => chunk7K5VFY2N_cjs.loadSettings().modelUseCounts,
1457
1570
  threadLock: {
1458
- acquire: chunkLVGWM7ZS_cjs.acquireThreadLock,
1459
- release: chunkLVGWM7ZS_cjs.releaseThreadLock
1571
+ acquire: chunk7K5VFY2N_cjs.acquireThreadLock,
1572
+ release: chunk7K5VFY2N_cjs.releaseThreadLock
1460
1573
  }
1461
1574
  });
1462
1575
  if (hookManager) {
@@ -1468,9 +1581,9 @@ function createMastraCode(config) {
1468
1581
  }
1469
1582
  });
1470
1583
  }
1471
- return { harness: harness$1, mcpManager, hookManager, authStorage };
1584
+ return { harness: harness$1, mcpManager, hookManager, authStorage, storageWarning };
1472
1585
  }
1473
1586
 
1474
1587
  exports.createMastraCode = createMastraCode;
1475
- //# sourceMappingURL=chunk-QDLLGD43.cjs.map
1476
- //# sourceMappingURL=chunk-QDLLGD43.cjs.map
1588
+ //# sourceMappingURL=chunk-VZFPT5N7.cjs.map
1589
+ //# sourceMappingURL=chunk-VZFPT5N7.cjs.map