mastracode 0.22.3 → 0.23.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 (181) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/dist/HarnessCompat.d.ts +2 -2
  3. package/dist/HarnessCompat.d.ts.map +1 -1
  4. package/dist/agents/mastracode-gateway.d.ts +58 -0
  5. package/dist/agents/mastracode-gateway.d.ts.map +1 -0
  6. package/dist/agents/model.d.ts +26 -28
  7. package/dist/agents/model.d.ts.map +1 -1
  8. package/dist/agents/{subagents/execute.d.ts → modes/build.d.ts} +3 -3
  9. package/dist/agents/modes/build.d.ts.map +1 -0
  10. package/dist/agents/{subagents → modes}/explore.d.ts +2 -2
  11. package/dist/agents/modes/explore.d.ts.map +1 -0
  12. package/dist/agents/modes/plan.d.ts +6 -0
  13. package/dist/agents/modes/plan.d.ts.map +1 -0
  14. package/dist/{chunk-EATS4KOR.cjs → chunk-3CO7PY6M.cjs} +1094 -239
  15. package/dist/chunk-3CO7PY6M.cjs.map +1 -0
  16. package/dist/{chunk-DJEQBK7L.cjs → chunk-CBPEMMRV.cjs} +1659 -2010
  17. package/dist/chunk-CBPEMMRV.cjs.map +1 -0
  18. package/dist/{chunk-W7Y7QIJA.js → chunk-FXYM4OEI.js} +14 -805
  19. package/dist/chunk-FXYM4OEI.js.map +1 -0
  20. package/dist/{chunk-OXYE6SUY.js → chunk-GKGPZBID.js} +836 -1187
  21. package/dist/chunk-GKGPZBID.js.map +1 -0
  22. package/dist/{chunk-FDDVVRPH.js → chunk-RDIIIT54.js} +1076 -221
  23. package/dist/chunk-RDIIIT54.js.map +1 -0
  24. package/dist/{chunk-NKTZDFIU.cjs → chunk-XPPJHUAD.cjs} +12 -809
  25. package/dist/chunk-XPPJHUAD.cjs.map +1 -0
  26. package/dist/cli.cjs +18 -18
  27. package/dist/cli.js +3 -3
  28. package/dist/index.cjs +3 -3
  29. package/dist/index.d.ts +4 -5
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +1 -1
  32. package/dist/mcp/manager.d.ts.map +1 -1
  33. package/dist/onboarding/onboarding-inline.d.ts +2 -2
  34. package/dist/onboarding/onboarding-inline.d.ts.map +1 -1
  35. package/dist/onboarding/settings.d.ts.map +1 -1
  36. package/dist/providers/claude-max.d.ts.map +1 -1
  37. package/dist/tui/chat-boundary-reconciliation.d.ts +18 -1
  38. package/dist/tui/chat-boundary-reconciliation.d.ts.map +1 -1
  39. package/dist/tui/command-dispatch.d.ts.map +1 -1
  40. package/dist/tui/commands/browser.d.ts.map +1 -1
  41. package/dist/tui/commands/goal.d.ts.map +1 -1
  42. package/dist/tui/commands/mode.d.ts.map +1 -1
  43. package/dist/tui/commands/new.d.ts.map +1 -1
  44. package/dist/tui/commands/settings.d.ts.map +1 -1
  45. package/dist/tui/commands/skills.d.ts.map +1 -1
  46. package/dist/tui/components/api-key-dialog.d.ts +2 -2
  47. package/dist/tui/components/api-key-dialog.d.ts.map +1 -1
  48. package/dist/tui/components/ask-question-dialog.d.ts +2 -2
  49. package/dist/tui/components/ask-question-dialog.d.ts.map +1 -1
  50. package/dist/tui/components/ask-question-inline.d.ts +4 -2
  51. package/dist/tui/components/ask-question-inline.d.ts.map +1 -1
  52. package/dist/tui/components/assistant-message.d.ts +2 -2
  53. package/dist/tui/components/assistant-message.d.ts.map +1 -1
  54. package/dist/tui/components/chat-boundary-spacer.d.ts +9 -9
  55. package/dist/tui/components/chat-boundary-spacer.d.ts.map +1 -1
  56. package/dist/tui/components/chat-spacing.d.ts +1 -1
  57. package/dist/tui/components/chat-spacing.d.ts.map +1 -1
  58. package/dist/tui/components/collapsible.d.ts +2 -2
  59. package/dist/tui/components/collapsible.d.ts.map +1 -1
  60. package/dist/tui/components/custom-editor.d.ts +2 -2
  61. package/dist/tui/components/custom-editor.d.ts.map +1 -1
  62. package/dist/tui/components/diff-output.d.ts +3 -1
  63. package/dist/tui/components/diff-output.d.ts.map +1 -1
  64. package/dist/tui/components/error-display.d.ts +4 -2
  65. package/dist/tui/components/error-display.d.ts.map +1 -1
  66. package/dist/tui/components/goal-cycles-dialog.d.ts +2 -2
  67. package/dist/tui/components/goal-cycles-dialog.d.ts.map +1 -1
  68. package/dist/tui/components/idle-counter.d.ts +1 -1
  69. package/dist/tui/components/idle-counter.d.ts.map +1 -1
  70. package/dist/tui/components/judge-display.d.ts +14 -2
  71. package/dist/tui/components/judge-display.d.ts.map +1 -1
  72. package/dist/tui/components/login-dialog.d.ts +2 -2
  73. package/dist/tui/components/login-dialog.d.ts.map +1 -1
  74. package/dist/tui/components/login-mode-selector.d.ts +2 -2
  75. package/dist/tui/components/login-mode-selector.d.ts.map +1 -1
  76. package/dist/tui/components/login-selector.d.ts +1 -1
  77. package/dist/tui/components/login-selector.d.ts.map +1 -1
  78. package/dist/tui/components/masked-input.d.ts +1 -1
  79. package/dist/tui/components/masked-input.d.ts.map +1 -1
  80. package/dist/tui/components/mcp-selector.d.ts +2 -2
  81. package/dist/tui/components/mcp-selector.d.ts.map +1 -1
  82. package/dist/tui/components/model-selector.d.ts +2 -2
  83. package/dist/tui/components/model-selector.d.ts.map +1 -1
  84. package/dist/tui/components/multi-step-progress.d.ts +3 -1
  85. package/dist/tui/components/multi-step-progress.d.ts.map +1 -1
  86. package/dist/tui/components/multiline-input.d.ts +1 -1
  87. package/dist/tui/components/multiline-input.d.ts.map +1 -1
  88. package/dist/tui/components/notification-summary.d.ts +1 -1
  89. package/dist/tui/components/notification-summary.d.ts.map +1 -1
  90. package/dist/tui/components/notification.d.ts +1 -1
  91. package/dist/tui/components/notification.d.ts.map +1 -1
  92. package/dist/tui/components/om-marker.d.ts +3 -1
  93. package/dist/tui/components/om-marker.d.ts.map +1 -1
  94. package/dist/tui/components/om-output.d.ts +3 -1
  95. package/dist/tui/components/om-output.d.ts.map +1 -1
  96. package/dist/tui/components/om-progress.d.ts +1 -1
  97. package/dist/tui/components/om-progress.d.ts.map +1 -1
  98. package/dist/tui/components/om-settings.d.ts +2 -2
  99. package/dist/tui/components/om-settings.d.ts.map +1 -1
  100. package/dist/tui/components/plan-approval-inline.d.ts +2 -2
  101. package/dist/tui/components/plan-approval-inline.d.ts.map +1 -1
  102. package/dist/tui/components/reactive-signal.d.ts +1 -1
  103. package/dist/tui/components/reactive-signal.d.ts.map +1 -1
  104. package/dist/tui/components/settings.d.ts +2 -2
  105. package/dist/tui/components/settings.d.ts.map +1 -1
  106. package/dist/tui/components/shell-output.d.ts +3 -1
  107. package/dist/tui/components/shell-output.d.ts.map +1 -1
  108. package/dist/tui/components/simple-progress.d.ts +1 -1
  109. package/dist/tui/components/simple-progress.d.ts.map +1 -1
  110. package/dist/tui/components/slash-command.d.ts +3 -1
  111. package/dist/tui/components/slash-command.d.ts.map +1 -1
  112. package/dist/tui/components/state-signal.d.ts +1 -1
  113. package/dist/tui/components/state-signal.d.ts.map +1 -1
  114. package/dist/tui/components/subagent-execution.d.ts +2 -2
  115. package/dist/tui/components/subagent-execution.d.ts.map +1 -1
  116. package/dist/tui/components/system-reminder.d.ts +1 -1
  117. package/dist/tui/components/system-reminder.d.ts.map +1 -1
  118. package/dist/tui/components/task-progress.d.ts +1 -1
  119. package/dist/tui/components/task-progress.d.ts.map +1 -1
  120. package/dist/tui/components/temporal-gap.d.ts +3 -1
  121. package/dist/tui/components/temporal-gap.d.ts.map +1 -1
  122. package/dist/tui/components/thinking-settings.d.ts +2 -2
  123. package/dist/tui/components/thinking-settings.d.ts.map +1 -1
  124. package/dist/tui/components/thread-selector.d.ts +2 -2
  125. package/dist/tui/components/thread-selector.d.ts.map +1 -1
  126. package/dist/tui/components/tool-approval-dialog.d.ts +2 -2
  127. package/dist/tui/components/tool-approval-dialog.d.ts.map +1 -1
  128. package/dist/tui/components/tool-execution-enhanced.d.ts +2 -2
  129. package/dist/tui/components/tool-execution-enhanced.d.ts.map +1 -1
  130. package/dist/tui/components/tool-validation-error.d.ts +2 -2
  131. package/dist/tui/components/tool-validation-error.d.ts.map +1 -1
  132. package/dist/tui/components/user-message.d.ts +2 -2
  133. package/dist/tui/components/user-message.d.ts.map +1 -1
  134. package/dist/tui/components/wrapping-autocomplete-list.d.ts +1 -1
  135. package/dist/tui/components/wrapping-autocomplete-list.d.ts.map +1 -1
  136. package/dist/tui/components/wrapping-select-list.d.ts +1 -1
  137. package/dist/tui/components/wrapping-select-list.d.ts.map +1 -1
  138. package/dist/tui/display.d.ts.map +1 -1
  139. package/dist/tui/event-dispatch.d.ts.map +1 -1
  140. package/dist/tui/goal-manager.d.ts +48 -40
  141. package/dist/tui/goal-manager.d.ts.map +1 -1
  142. package/dist/tui/handlers/agent-lifecycle.d.ts +13 -0
  143. package/dist/tui/handlers/agent-lifecycle.d.ts.map +1 -1
  144. package/dist/tui/handlers/index.d.ts +1 -1
  145. package/dist/tui/handlers/index.d.ts.map +1 -1
  146. package/dist/tui/handlers/message.d.ts.map +1 -1
  147. package/dist/tui/handlers/om.d.ts.map +1 -1
  148. package/dist/tui/handlers/tool.d.ts.map +1 -1
  149. package/dist/tui/handlers/types.d.ts +1 -1
  150. package/dist/tui/handlers/types.d.ts.map +1 -1
  151. package/dist/tui/mastra-tui.d.ts.map +1 -1
  152. package/dist/tui/modal-question.d.ts +1 -1
  153. package/dist/tui/modal-question.d.ts.map +1 -1
  154. package/dist/tui/overlay.d.ts +1 -1
  155. package/dist/tui/overlay.d.ts.map +1 -1
  156. package/dist/tui/prompt-api-key.d.ts +1 -1
  157. package/dist/tui/prompt-api-key.d.ts.map +1 -1
  158. package/dist/tui/render-messages.d.ts +1 -1
  159. package/dist/tui/render-messages.d.ts.map +1 -1
  160. package/dist/tui/setup.d.ts.map +1 -1
  161. package/dist/tui/shell.d.ts.map +1 -1
  162. package/dist/tui/state.d.ts +2 -2
  163. package/dist/tui/state.d.ts.map +1 -1
  164. package/dist/tui/status-line.d.ts.map +1 -1
  165. package/dist/tui/theme.d.ts +1 -1
  166. package/dist/tui/theme.d.ts.map +1 -1
  167. package/dist/tui.cjs +19 -19
  168. package/dist/tui.js +2 -2
  169. package/package.json +20 -20
  170. package/dist/agents/coding.d.ts +0 -2
  171. package/dist/agents/coding.d.ts.map +0 -1
  172. package/dist/agents/subagents/execute.d.ts.map +0 -1
  173. package/dist/agents/subagents/explore.d.ts.map +0 -1
  174. package/dist/agents/subagents/plan.d.ts +0 -10
  175. package/dist/agents/subagents/plan.d.ts.map +0 -1
  176. package/dist/chunk-DJEQBK7L.cjs.map +0 -1
  177. package/dist/chunk-EATS4KOR.cjs.map +0 -1
  178. package/dist/chunk-FDDVVRPH.js.map +0 -1
  179. package/dist/chunk-NKTZDFIU.cjs.map +0 -1
  180. package/dist/chunk-OXYE6SUY.js.map +0 -1
  181. package/dist/chunk-W7Y7QIJA.js.map +0 -1
@@ -3,12 +3,6 @@
3
3
  var chunkJ3ISOP5J_cjs = require('./chunk-J3ISOP5J.cjs');
4
4
  var fs = require('fs');
5
5
  var path = require('path');
6
- var anthropic = require('@ai-sdk/anthropic');
7
- var ai = require('ai');
8
- var openaiCompatible = require('@ai-sdk/openai-compatible');
9
- var schemaCompat = require('@mastra/schema-compat');
10
- var openai = require('@ai-sdk/openai');
11
- var llm = require('@mastra/core/llm');
12
6
  var chalk = require('chalk');
13
7
 
14
8
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -528,6 +522,9 @@ function checkProfileProviderMismatch(profilePath, targetProvider) {
528
522
  }
529
523
  return void 0;
530
524
  }
525
+ function browserRecordingOptions() {
526
+ return { outputDir: path.join(chunkJ3ISOP5J_cjs.getAppDataDir(), "browser-recordings") };
527
+ }
531
528
  async function createBrowserFromSettings(settings) {
532
529
  if (!settings.enabled) {
533
530
  return void 0;
@@ -541,807 +538,19 @@ async function createBrowserFromSettings(settings) {
541
538
  env: stagehand?.env ?? "LOCAL",
542
539
  apiKey: stagehand?.apiKey ?? process.env.BROWSERBASE_API_KEY,
543
540
  projectId: stagehand?.projectId ?? process.env.BROWSERBASE_PROJECT_ID,
544
- preserveUserDataDir: stagehand?.preserveUserDataDir
541
+ preserveUserDataDir: stagehand?.preserveUserDataDir,
542
+ recording: browserRecordingOptions()
545
543
  };
546
544
  return cdpUrl ? new StagehandBrowser({ ...launchConfig, cdpUrl, scope: "shared", ...stagehandOpts }) : new StagehandBrowser({ ...launchConfig, ...stagehandOpts });
547
545
  } else if (provider === "agent-browser") {
548
546
  const { AgentBrowser } = await import('@mastra/agent-browser');
549
- return cdpUrl ? new AgentBrowser({ ...launchConfig, cdpUrl, scope: "shared", storageState: agentBrowser?.storageState }) : new AgentBrowser({ ...launchConfig, storageState: agentBrowser?.storageState, scope });
550
- }
551
- throw new Error(`Unsupported browser provider: ${provider}`);
552
- }
553
- var claudeCodeIdentity = "You are Claude Code, Anthropic's official CLI for Claude.";
554
- var authStorageInstance = null;
555
- function getAuthStorage() {
556
- if (!authStorageInstance) {
557
- authStorageInstance = new chunkJ3ISOP5J_cjs.AuthStorage();
558
- }
559
- return authStorageInstance;
560
- }
561
- function setAuthStorage(storage) {
562
- authStorageInstance = storage ?? null;
563
- }
564
- var claudeCodeMiddleware = {
565
- specificationVersion: "v3",
566
- transformParams: async ({ params }) => {
567
- const systemMessage = {
568
- role: "system",
569
- content: claudeCodeIdentity
570
- };
571
- if (params.temperature) {
572
- delete params.topP;
573
- }
574
- return {
575
- ...params,
576
- prompt: [systemMessage, ...params.prompt]
577
- };
578
- }
579
- };
580
- var promptCacheMiddleware = {
581
- specificationVersion: "v3",
582
- transformParams: async ({ params }) => {
583
- const prompt = [...params.prompt];
584
- const cacheControl = { type: "ephemeral", ttl: "5m" };
585
- const addCacheToMessage = (msg) => {
586
- if (typeof msg.content === "string") {
587
- return {
588
- ...msg,
589
- providerOptions: {
590
- ...msg.providerOptions,
591
- anthropic: { ...msg.providerOptions?.anthropic, cacheControl }
592
- }
593
- };
594
- }
595
- if (Array.isArray(msg.content) && msg.content.length > 0) {
596
- const content = [...msg.content];
597
- const lastPart = content[content.length - 1];
598
- content[content.length - 1] = {
599
- ...lastPart,
600
- providerOptions: {
601
- ...lastPart.providerOptions,
602
- anthropic: { ...lastPart.providerOptions?.anthropic, cacheControl }
603
- }
604
- };
605
- return { ...msg, content };
606
- }
607
- return msg;
608
- };
609
- let lastSystemIdx = -1;
610
- for (let i = prompt.length - 1; i >= 0; i--) {
611
- if (prompt[i].role === "system") {
612
- lastSystemIdx = i;
613
- break;
614
- }
615
- }
616
- if (lastSystemIdx >= 0) {
617
- prompt[lastSystemIdx] = addCacheToMessage(prompt[lastSystemIdx]);
618
- }
619
- const lastIdx = prompt.length - 1;
620
- if (lastIdx >= 0 && lastIdx !== lastSystemIdx) {
621
- prompt[lastIdx] = addCacheToMessage(prompt[lastIdx]);
622
- }
623
- return { ...params, prompt };
624
- }
625
- };
626
- function buildAnthropicOAuthFetch(opts = {}) {
627
- return (async (url, init) => {
628
- const storage = opts.authStorage ?? getAuthStorage();
629
- storage.reload();
630
- const storedCred = storage.get("anthropic");
631
- if (storedCred?.type === "api_key") {
632
- throw new Error("Anthropic API key credential is configured, but OAuth is required.");
633
- }
634
- const accessToken = await storage.getApiKey("anthropic");
635
- if (!accessToken) {
636
- throw new Error("Not logged in to Anthropic. Run /login first.");
637
- }
638
- const headers = new Headers();
639
- if (init?.headers) {
640
- const source = init.headers instanceof Headers ? init.headers : Array.isArray(init.headers) ? new Headers(init.headers) : new Headers(init.headers);
641
- source.forEach((value, key) => {
642
- const lower = key.toLowerCase();
643
- if (lower !== "authorization" && lower !== "x-api-key") {
644
- headers.set(key, value);
645
- }
646
- });
647
- }
648
- headers.set("Authorization", `Bearer ${accessToken}`);
649
- headers.set(
650
- "anthropic-beta",
651
- "oauth-2025-04-20,claude-code-20250219,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14"
652
- );
653
- headers.set("anthropic-version", "2023-06-01");
654
- try {
655
- return await fetch(url, { ...init, headers });
656
- } catch (error) {
657
- if (error && typeof error === "object") {
658
- Object.assign(error, {
659
- requestUrl: url instanceof URL ? url.toString() : typeof url === "string" ? url : url.url
660
- });
661
- }
662
- throw error;
663
- }
664
- });
665
- }
666
- function opencodeClaudeMaxProvider(modelId = "claude-sonnet-4-20250514", options) {
667
- const headers = options?.headers;
668
- if (process.env.NODE_ENV === "test" || process.env.VITEST) {
669
- const anthropic2 = anthropic.createAnthropic({
670
- apiKey: "test-api-key",
671
- headers
672
- });
673
- return ai.wrapLanguageModel({
674
- model: anthropic2(modelId),
675
- middleware: [claudeCodeMiddleware, promptCacheMiddleware]
676
- });
677
- }
678
- const anthropic$1 = anthropic.createAnthropic({
679
- apiKey: "oauth-placeholder",
680
- headers,
681
- fetch: buildAnthropicOAuthFetch()
682
- });
683
- return ai.wrapLanguageModel({
684
- model: anthropic$1(modelId),
685
- middleware: [claudeCodeMiddleware, promptCacheMiddleware]
686
- });
687
- }
688
- var COPILOT_PROVIDER_ID = "github-copilot";
689
- var authStorageInstance2 = null;
690
- function getAuthStorage2() {
691
- if (!authStorageInstance2) {
692
- authStorageInstance2 = new chunkJ3ISOP5J_cjs.AuthStorage();
693
- }
694
- return authStorageInstance2;
695
- }
696
- function setAuthStorage2(storage) {
697
- authStorageInstance2 = storage ?? null;
698
- }
699
- function detectIsAgent(body) {
700
- if (!body || typeof body !== "object") return false;
701
- const obj = body;
702
- const messages = obj.messages;
703
- if (Array.isArray(messages) && messages.length > 0) {
704
- const last = messages[messages.length - 1];
705
- if (last?.role && last.role !== "user") return true;
706
- if (Array.isArray(last?.content)) {
707
- const hasToolResult = last.content.some(
708
- (part) => part && typeof part === "object" && part.type === "tool_result"
709
- );
710
- if (hasToolResult) return true;
711
- }
712
- }
713
- const input = obj.input;
714
- if (Array.isArray(input) && input.length > 0) {
715
- const last = input[input.length - 1];
716
- if (last?.role && last.role !== "user") return true;
717
- }
718
- return false;
719
- }
720
- function detectIsVision(body) {
721
- if (!body || typeof body !== "object") return false;
722
- const obj = body;
723
- const matchPart = (part) => {
724
- if (!part || typeof part !== "object") return false;
725
- const t = part.type;
726
- return t === "image" || t === "image_url" || t === "input_image";
727
- };
728
- const messages = obj.messages;
729
- if (Array.isArray(messages)) {
730
- return messages.some(
731
- (msg) => msg && typeof msg === "object" && Array.isArray(msg.content) && msg.content.some(matchPart)
732
- );
733
- }
734
- const input = obj.input;
735
- if (Array.isArray(input)) {
736
- return input.some(
737
- (item) => item && typeof item === "object" && Array.isArray(item.content) && item.content.some(matchPart)
738
- );
739
- }
740
- return false;
741
- }
742
- function buildGitHubCopilotOAuthFetch(opts = {}) {
743
- return (async (url, init) => {
744
- const storage = opts.authStorage ?? getAuthStorage2();
745
- storage.reload();
746
- const cred = storage.get(COPILOT_PROVIDER_ID);
747
- if (!cred || cred.type !== "oauth") {
748
- throw new Error("Not logged in to GitHub Copilot. Run /login first.");
749
- }
750
- const accessToken = await storage.getApiKey(COPILOT_PROVIDER_ID);
751
- if (!accessToken) {
752
- throw new Error("Failed to refresh GitHub Copilot token. Please /login again.");
753
- }
754
- storage.reload();
755
- const enterpriseUrl = cred.enterpriseUrl;
756
- let parsedBody;
757
- if (typeof init?.body === "string") {
758
- try {
759
- parsedBody = JSON.parse(init.body);
760
- } catch {
761
- parsedBody = void 0;
762
- }
763
- }
764
- const isAgent = detectIsAgent(parsedBody);
765
- const isVision = detectIsVision(parsedBody);
766
- const headers = new Headers();
767
- if (init?.headers) {
768
- const source = init.headers instanceof Headers ? init.headers : Array.isArray(init.headers) ? new Headers(init.headers) : new Headers(init.headers);
769
- source.forEach((value, key) => {
770
- const lower = key.toLowerCase();
771
- if (lower !== "authorization" && lower !== "x-api-key") {
772
- headers.set(key, value);
773
- }
774
- });
775
- }
776
- headers.set("Authorization", `Bearer ${accessToken}`);
777
- headers.set("x-initiator", isAgent ? "agent" : "user");
778
- headers.set("Openai-Intent", "conversation-edits");
779
- if (isVision) {
780
- headers.set("Copilot-Vision-Request", "true");
781
- }
782
- for (const [key, value] of Object.entries(chunkJ3ISOP5J_cjs.COPILOT_HEADERS)) {
783
- if (!headers.has(key)) {
784
- headers.set(key, value);
785
- }
786
- }
787
- const finalUrl = opts.rewriteUrl !== false ? rewriteToCopilotBase(url, accessToken, enterpriseUrl) : url instanceof URL ? url : typeof url === "string" ? new URL(url) : new URL(url.url);
788
- try {
789
- return await fetch(finalUrl, { ...init, headers });
790
- } catch (error) {
791
- if (error && typeof error === "object") {
792
- Object.assign(error, {
793
- requestUrl: finalUrl.toString()
794
- });
795
- }
796
- throw error;
797
- }
798
- });
799
- }
800
- function rewriteToCopilotBase(url, token, enterpriseDomain) {
801
- const original = url instanceof URL ? url : new URL(typeof url === "string" ? url : url.url);
802
- const base = new URL(chunkJ3ISOP5J_cjs.getGitHubCopilotBaseUrl(token, enterpriseDomain));
803
- const pathname = original.pathname.replace(/^\/v1(\/|$)/, "/");
804
- return new URL(`${pathname}${original.search}`, base);
805
- }
806
- function isGeminiModel(modelId) {
807
- return modelId.startsWith("gemini-");
808
- }
809
- function applyGeminiSchemaCompatToTools(modelId, tools) {
810
- if (!Array.isArray(tools)) {
811
- return tools;
812
- }
813
- const compatLayer = new schemaCompat.GoogleSchemaCompatLayer({
814
- provider: COPILOT_PROVIDER_ID,
815
- modelId,
816
- supportsStructuredOutputs: false
817
- });
818
- return tools.map((tool) => {
819
- if (!tool || typeof tool !== "object" || tool.type !== "function") {
820
- return tool;
821
- }
822
- const functionTool = tool;
823
- if (!functionTool.inputSchema) {
824
- return tool;
825
- }
826
- return {
827
- ...functionTool,
828
- inputSchema: schemaCompat.applyCompatLayer({
829
- schema: functionTool.inputSchema,
830
- compatLayers: [compatLayer],
831
- mode: "aiSdkSchema"
832
- }).jsonSchema
547
+ const agentBrowserOpts = {
548
+ storageState: agentBrowser?.storageState,
549
+ recording: browserRecordingOptions()
833
550
  };
834
- });
835
- }
836
- function createCopilotMiddleware(modelId) {
837
- return {
838
- specificationVersion: "v3",
839
- transformParams: async ({ params }) => {
840
- if (params.temperature !== void 0 && params.temperature !== null) {
841
- delete params.topP;
842
- }
843
- if (isGeminiModel(modelId)) {
844
- params.tools = applyGeminiSchemaCompatToTools(
845
- modelId,
846
- params.tools
847
- );
848
- }
849
- return params;
850
- }
851
- };
852
- }
853
- function githubCopilotProvider(modelId = "gpt-4.1", options) {
854
- const headers = options?.headers;
855
- const copilot = openaiCompatible.createOpenAICompatible({
856
- name: COPILOT_PROVIDER_ID,
857
- baseURL: "https://api.githubcopilot.com",
858
- apiKey: process.env.NODE_ENV === "test" || process.env.VITEST ? "test-api-key" : "oauth-placeholder",
859
- headers,
860
- fetch: process.env.NODE_ENV === "test" || process.env.VITEST ? void 0 : buildGitHubCopilotOAuthFetch({ rewriteUrl: false })
861
- });
862
- return ai.wrapLanguageModel({
863
- model: copilot.chatModel(modelId),
864
- middleware: [createCopilotMiddleware(modelId)]
865
- });
866
- }
867
- var COPILOT_FALLBACK_MODELS = [
868
- {
869
- id: "gpt-4.1",
870
- name: "GPT-4.1",
871
- vendor: "OpenAI",
872
- supportedEndpoints: ["/chat/completions"],
873
- isAnthropicShaped: false,
874
- supportsVision: true,
875
- supportsToolCalls: true
876
- }
877
- ];
878
- var CATALOG_TTL_MS = 10 * 60 * 1e3;
879
- var CATALOG_FAILURE_TTL_MS = 60 * 1e3;
880
- var CATALOG_FETCH_TIMEOUT_MS = 5e3;
881
- var catalogCache = null;
882
- var inflightFetch = null;
883
- async function getCopilotModelCatalog(opts = {}) {
884
- const storage = opts.authStorage ?? getAuthStorage2();
885
- storage.reload();
886
- const cred = storage.get(COPILOT_PROVIDER_ID);
887
- if (!cred || cred.type !== "oauth") {
888
- return [];
551
+ return cdpUrl ? new AgentBrowser({ ...launchConfig, cdpUrl, scope: "shared", ...agentBrowserOpts }) : new AgentBrowser({ ...launchConfig, ...agentBrowserOpts, scope });
889
552
  }
890
- const now = Date.now();
891
- if (catalogCache && now - catalogCache.fetchedAt < catalogCache.ttl) {
892
- return catalogCache.models;
893
- }
894
- if (inflightFetch) return inflightFetch;
895
- inflightFetch = (async () => {
896
- try {
897
- const accessToken = await storage.getApiKey(COPILOT_PROVIDER_ID);
898
- if (!accessToken) throw new Error("No Copilot bearer token");
899
- storage.reload();
900
- const refreshed = storage.get(COPILOT_PROVIDER_ID);
901
- const enterpriseUrl = refreshed?.enterpriseUrl;
902
- const baseUrl = chunkJ3ISOP5J_cjs.getGitHubCopilotBaseUrl(accessToken, enterpriseUrl);
903
- const controller = new AbortController();
904
- const timer = setTimeout(() => controller.abort(), CATALOG_FETCH_TIMEOUT_MS);
905
- try {
906
- const models = await chunkJ3ISOP5J_cjs.fetchCopilotModels({
907
- baseUrl,
908
- bearerToken: accessToken,
909
- signal: controller.signal
910
- });
911
- catalogCache = { fetchedAt: Date.now(), ttl: CATALOG_TTL_MS, models };
912
- return models;
913
- } finally {
914
- clearTimeout(timer);
915
- }
916
- } catch (error) {
917
- catalogCache = {
918
- fetchedAt: Date.now(),
919
- ttl: CATALOG_FAILURE_TTL_MS,
920
- models: COPILOT_FALLBACK_MODELS
921
- };
922
- console.warn(
923
- "Failed to fetch live GitHub Copilot models, using fallback list:",
924
- error instanceof Error ? error.message : error
925
- );
926
- return COPILOT_FALLBACK_MODELS;
927
- } finally {
928
- inflightFetch = null;
929
- }
930
- })();
931
- return inflightFetch;
932
- }
933
- var CODEX_API_ENDPOINT = "https://chatgpt.com/backend-api/codex/responses";
934
- var CODEX_ORIGINATOR = "mastracode";
935
- var CODEX_USER_AGENT = "mastracode";
936
- var authStorageInstance3 = null;
937
- function getAuthStorage3() {
938
- if (!authStorageInstance3) {
939
- authStorageInstance3 = new chunkJ3ISOP5J_cjs.AuthStorage();
940
- }
941
- return authStorageInstance3;
942
- }
943
- function setAuthStorage3(storage) {
944
- authStorageInstance3 = storage ?? null;
945
- }
946
- var CODEX_INSTRUCTIONS = `You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
947
-
948
- IMPORTANT: You should be concise, direct, and helpful. Focus on solving the user's problem efficiently.`;
949
- var GPT5_MODEL_RE = /^gpt-5(?:\.|-|$)/;
950
- function getEffectiveThinkingLevel(modelId, level) {
951
- if (GPT5_MODEL_RE.test(modelId) && level === "off") {
952
- return "low";
953
- }
954
- return level;
955
- }
956
- var THINKING_LEVEL_TO_REASONING_EFFORT = {
957
- off: void 0,
958
- low: "low",
959
- medium: "medium",
960
- high: "high",
961
- xhigh: "xhigh"
962
- };
963
- function createCodexMiddleware(reasoningEffort) {
964
- return {
965
- specificationVersion: "v3",
966
- transformParams: async ({ params }) => {
967
- if (params.temperature !== void 0 && params.temperature !== null) {
968
- delete params.topP;
969
- }
970
- params.providerOptions = {
971
- ...params.providerOptions,
972
- openai: {
973
- ...params.providerOptions?.openai ?? {},
974
- instructions: CODEX_INSTRUCTIONS,
975
- // Codex API requires store to be false
976
- store: false,
977
- // Enable reasoning for Codex models — without this, the model
978
- // skips the reasoning/action phase and goes straight to final_answer,
979
- // resulting in narration instead of tool calls.
980
- ...reasoningEffort ? { reasoningEffort } : {}
981
- }
982
- };
983
- return params;
984
- }
985
- };
986
- }
987
- function buildOpenAICodexOAuthFetch(opts = {}) {
988
- return (async (url, init) => {
989
- const storage = opts.authStorage ?? getAuthStorage3();
990
- storage.reload();
991
- const cred = storage.get("openai-codex");
992
- if (!cred || cred.type !== "oauth") {
993
- throw new Error("Not logged in to OpenAI Codex. Run /login first.");
994
- }
995
- let accessToken = cred.access;
996
- if (Date.now() >= cred.expires) {
997
- const refreshedToken = await storage.getApiKey("openai-codex");
998
- if (!refreshedToken) {
999
- throw new Error("Failed to refresh OpenAI Codex token. Please /login again.");
1000
- }
1001
- accessToken = refreshedToken;
1002
- storage.reload();
1003
- }
1004
- const accountId = cred.accountId;
1005
- const headers = new Headers();
1006
- if (init?.headers) {
1007
- if (init.headers instanceof Headers) {
1008
- init.headers.forEach((value, key) => {
1009
- if (key.toLowerCase() !== "authorization") {
1010
- headers.set(key, value);
1011
- }
1012
- });
1013
- } else if (Array.isArray(init.headers)) {
1014
- for (const [key, value] of init.headers) {
1015
- if (key.toLowerCase() !== "authorization" && value !== void 0) {
1016
- headers.set(key, String(value));
1017
- }
1018
- }
1019
- } else {
1020
- for (const [key, value] of Object.entries(init.headers)) {
1021
- if (key.toLowerCase() !== "authorization" && value !== void 0) {
1022
- headers.set(key, String(value));
1023
- }
1024
- }
1025
- }
1026
- }
1027
- headers.set("Authorization", `Bearer ${accessToken}`);
1028
- if (!headers.has("originator")) {
1029
- headers.set("originator", CODEX_ORIGINATOR);
1030
- }
1031
- if (!headers.has("User-Agent")) {
1032
- headers.set("User-Agent", CODEX_USER_AGENT);
1033
- }
1034
- if (accountId) {
1035
- headers.set("ChatGPT-Account-ID", accountId);
1036
- }
1037
- const parsed = url instanceof URL ? url : new URL(typeof url === "string" ? url : url.url);
1038
- const shouldRewrite = opts.rewriteUrl !== false && (parsed.pathname.includes("/v1/responses") || parsed.pathname.includes("/chat/completions"));
1039
- const finalUrl = shouldRewrite ? new URL(CODEX_API_ENDPOINT) : parsed;
1040
- try {
1041
- return await fetch(finalUrl, { ...init, headers });
1042
- } catch (error) {
1043
- if (error && typeof error === "object") {
1044
- Object.assign(error, {
1045
- requestUrl: finalUrl.toString()
1046
- });
1047
- }
1048
- throw error;
1049
- }
1050
- });
1051
- }
1052
- function openaiCodexProvider(modelId = "codex-mini-latest", options) {
1053
- const requestedLevel = options?.thinkingLevel ?? "medium";
1054
- const effectiveLevel = getEffectiveThinkingLevel(modelId, requestedLevel);
1055
- const reasoningEffort = THINKING_LEVEL_TO_REASONING_EFFORT[effectiveLevel];
1056
- const middleware = createCodexMiddleware(reasoningEffort);
1057
- const headers = options?.headers;
1058
- const baseURL = process.env.OPENAI_BASE_URL;
1059
- if (process.env.NODE_ENV === "test" || process.env.VITEST) {
1060
- const openai2 = openai.createOpenAI({
1061
- apiKey: "test-api-key",
1062
- baseURL,
1063
- headers
1064
- });
1065
- return ai.wrapLanguageModel({
1066
- model: openai2.responses(modelId),
1067
- middleware: [middleware]
1068
- });
1069
- }
1070
- const openai$1 = openai.createOpenAI({
1071
- apiKey: "oauth-dummy-key",
1072
- baseURL,
1073
- headers,
1074
- fetch: buildOpenAICodexOAuthFetch()
1075
- });
1076
- return ai.wrapLanguageModel({
1077
- model: openai$1.responses(modelId),
1078
- middleware: [middleware]
1079
- });
1080
- }
1081
- var authStorage = new chunkJ3ISOP5J_cjs.AuthStorage();
1082
- var OPENAI_PREFIX = "openai/";
1083
- var MASTRA_GATEWAY_PREFIX = "mastra/";
1084
- var MASTRACODE_GATEWAY_ID = "mastracode";
1085
- var CODEX_OPENAI_MODEL_REMAPS = {
1086
- "gpt-5.3": "gpt-5.3-codex",
1087
- "gpt-5.2": "gpt-5.2-codex",
1088
- "gpt-5.1": "gpt-5.1-codex",
1089
- "gpt-5.1-mini": "gpt-5.1-codex-mini",
1090
- "gpt-5": "gpt-5-codex"
1091
- };
1092
- function getHarnessHeaders(requestContext) {
1093
- const harnessContext = requestContext?.get("harness");
1094
- const headers = {
1095
- ...harnessContext?.threadId ? { "x-thread-id": harnessContext.threadId } : {},
1096
- ...harnessContext?.resourceId ? { "x-resource-id": harnessContext.resourceId } : {}
1097
- };
1098
- return Object.keys(headers).length > 0 ? headers : void 0;
1099
- }
1100
- function stripMastraGatewayPrefix(modelId) {
1101
- return modelId.startsWith(MASTRA_GATEWAY_PREFIX) ? modelId.substring(MASTRA_GATEWAY_PREFIX.length) : modelId;
1102
- }
1103
- function normalizeAnthropicModelId(modelId) {
1104
- return modelId.replace(/\.(?=\d)/g, "-");
1105
- }
1106
- function remapOpenAIModelForCodexOAuth(modelId) {
1107
- const normalizedModelId = stripMastraGatewayPrefix(modelId);
1108
- if (!normalizedModelId.startsWith(OPENAI_PREFIX)) {
1109
- return modelId;
1110
- }
1111
- const openaiModelId = normalizedModelId.substring(OPENAI_PREFIX.length);
1112
- if (openaiModelId.includes("-codex")) {
1113
- return modelId;
1114
- }
1115
- const codexModelId = CODEX_OPENAI_MODEL_REMAPS[openaiModelId];
1116
- if (!codexModelId) {
1117
- return modelId;
1118
- }
1119
- const remappedModelId = `${OPENAI_PREFIX}${codexModelId}`;
1120
- return modelId.startsWith(MASTRA_GATEWAY_PREFIX) ? `${MASTRA_GATEWAY_PREFIX}${remappedModelId}` : remappedModelId;
1121
- }
1122
- function getAnthropicApiKey() {
1123
- const storedCred = authStorage.get("anthropic");
1124
- if (storedCred?.type === "api_key" && storedCred.key.trim().length > 0) {
1125
- return storedCred.key.trim();
1126
- }
1127
- const dedicatedKey = authStorage.getStoredApiKey("anthropic")?.trim();
1128
- if (dedicatedKey) return dedicatedKey;
1129
- return process.env.ANTHROPIC_API_KEY?.trim() || void 0;
1130
- }
1131
- function getOpenAIApiKey() {
1132
- const storedCred = authStorage.get("openai-codex");
1133
- if (storedCred?.type === "api_key" && storedCred.key.trim().length > 0) {
1134
- return storedCred.key.trim();
1135
- }
1136
- const dedicatedKey = authStorage.getStoredApiKey("openai-codex")?.trim();
1137
- if (dedicatedKey) return dedicatedKey;
1138
- return process.env.OPENAI_API_KEY?.trim() || void 0;
1139
- }
1140
- function anthropicApiKeyProvider(modelId, apiKey, headers) {
1141
- const anthropic$1 = anthropic.createAnthropic({ apiKey, headers });
1142
- return ai.wrapLanguageModel({
1143
- model: anthropic$1(modelId),
1144
- middleware: [promptCacheMiddleware]
1145
- });
1146
- }
1147
- function openaiApiKeyProvider(modelId, apiKey, headers) {
1148
- const openai$1 = openai.createOpenAI({ apiKey, baseURL: process.env.OPENAI_BASE_URL, headers });
1149
- return ai.wrapLanguageModel({
1150
- model: openai$1.responses(modelId),
1151
- middleware: []
1152
- });
1153
- }
1154
- function getProviderAuthKey(providerId) {
1155
- const authProviderId = providerId === "openai" ? "openai-codex" : providerId;
1156
- const storedCred = authStorage.get(authProviderId);
1157
- if (storedCred?.type === "api_key" && storedCred.key.trim().length > 0) {
1158
- return storedCred.key.trim();
1159
- }
1160
- return authStorage.getStoredApiKey(authProviderId)?.trim() || void 0;
1161
- }
1162
- function resolveAuth(request, memoryGatewayApiKey) {
1163
- const apiKey = getProviderAuthKey(request.providerId);
1164
- return apiKey ? { apiKey, source: "gateway" } : void 0;
1165
- }
1166
- function createMastraCodeGateway({
1167
- mastraGatewayBaseUrl,
1168
- mastraGatewayApiKey,
1169
- routeThroughMastraGateway,
1170
- thinkingLevel,
1171
- customProviders
1172
- }) {
1173
- const mastraGateway = new llm.MastraGateway({ baseUrl: mastraGatewayBaseUrl });
1174
- return {
1175
- id: MASTRACODE_GATEWAY_ID,
1176
- name: "MastraCode Gateway",
1177
- async fetchProviders() {
1178
- return {};
1179
- },
1180
- buildUrl(modelId) {
1181
- return routeThroughMastraGateway ? mastraGateway.buildUrl(modelId) : modelId;
1182
- },
1183
- async getApiKey(modelId) {
1184
- const providerId = stripMastraGatewayPrefix(modelId).split("/", 1)[0];
1185
- if (routeThroughMastraGateway) return mastraGatewayApiKey ?? "";
1186
- return providerId ? getProviderAuthKey(providerId) ?? "" : "";
1187
- },
1188
- resolveAuth(request) {
1189
- if (routeThroughMastraGateway && mastraGatewayApiKey) {
1190
- return { apiKey: mastraGatewayApiKey, source: "gateway" };
1191
- }
1192
- const customProvider = customProviders.find(
1193
- (provider) => request.providerId === getCustomProviderId(provider.name)
1194
- );
1195
- if (customProvider?.apiKey) {
1196
- return { apiKey: customProvider.apiKey, source: "gateway" };
1197
- }
1198
- return resolveAuth(request);
1199
- },
1200
- resolveLanguageModel(args) {
1201
- const customProvider = customProviders.find((provider) => args.providerId === getCustomProviderId(provider.name));
1202
- if (customProvider) {
1203
- const provider = openaiCompatible.createOpenAICompatible({
1204
- name: args.providerId,
1205
- baseURL: customProvider.url,
1206
- apiKey: args.apiKey,
1207
- headers: args.headers
1208
- });
1209
- return provider.chatModel(args.modelId);
1210
- }
1211
- if (args.providerId === "github-copilot") {
1212
- return githubCopilotProvider(args.modelId, { headers: args.headers });
1213
- }
1214
- if (args.providerId === "moonshotai") {
1215
- if (!process.env.MOONSHOT_AI_API_KEY) {
1216
- throw new Error(`Need MOONSHOT_AI_API_KEY`);
1217
- }
1218
- return anthropic.createAnthropic({
1219
- apiKey: process.env.MOONSHOT_AI_API_KEY,
1220
- baseURL: "https://api.moonshot.ai/anthropic/v1",
1221
- name: "moonshotai.anthropicv1",
1222
- headers: args.headers
1223
- })(args.modelId);
1224
- }
1225
- if (args.providerId === "anthropic") {
1226
- const bareModelId = normalizeAnthropicModelId(args.modelId);
1227
- const storedCred = authStorage.get("anthropic");
1228
- if (routeThroughMastraGateway) {
1229
- if (storedCred?.type === "oauth") {
1230
- const anthropic$1 = anthropic.createAnthropic({
1231
- apiKey: "oauth-gateway-placeholder",
1232
- baseURL: `${mastraGatewayBaseUrl}/v1`,
1233
- headers: {
1234
- [llm.GATEWAY_AUTH_HEADER]: `Bearer ${args.apiKey}`,
1235
- ...args.headers
1236
- },
1237
- fetch: buildAnthropicOAuthFetch({ authStorage })
1238
- });
1239
- return ai.wrapLanguageModel({
1240
- model: anthropic$1(bareModelId),
1241
- middleware: [claudeCodeMiddleware, promptCacheMiddleware]
1242
- });
1243
- }
1244
- return mastraGateway.resolveLanguageModel({ ...args, modelId: bareModelId });
1245
- }
1246
- if (storedCred?.type === "oauth") {
1247
- return opencodeClaudeMaxProvider(bareModelId, { headers: args.headers });
1248
- }
1249
- if (storedCred?.type === "api_key" && storedCred.key.trim().length > 0) {
1250
- return anthropicApiKeyProvider(
1251
- bareModelId,
1252
- storedCred.key.trim(),
1253
- args.headers
1254
- );
1255
- }
1256
- const apiKey = getAnthropicApiKey();
1257
- if (apiKey) {
1258
- return anthropicApiKeyProvider(bareModelId, apiKey, args.headers);
1259
- }
1260
- return opencodeClaudeMaxProvider(bareModelId, { headers: args.headers });
1261
- }
1262
- if (args.providerId === "openai") {
1263
- const storedCred = authStorage.get("openai-codex");
1264
- if (routeThroughMastraGateway) {
1265
- if (storedCred?.type === "oauth") {
1266
- const resolvedModelId = remapOpenAIModelForCodexOAuth(`openai/${args.modelId}`);
1267
- const resolvedBareModelId = resolvedModelId.substring(OPENAI_PREFIX.length);
1268
- const requestedLevel = thinkingLevel ?? "medium";
1269
- const effectiveLevel = getEffectiveThinkingLevel(resolvedBareModelId, requestedLevel);
1270
- const reasoningEffort = THINKING_LEVEL_TO_REASONING_EFFORT[effectiveLevel];
1271
- const middleware = createCodexMiddleware(reasoningEffort);
1272
- const openai$1 = openai.createOpenAI({
1273
- apiKey: "oauth-gateway-placeholder",
1274
- baseURL: `${mastraGatewayBaseUrl}/v1`,
1275
- headers: {
1276
- [llm.GATEWAY_AUTH_HEADER]: `Bearer ${args.apiKey}`,
1277
- ...args.headers
1278
- },
1279
- fetch: buildOpenAICodexOAuthFetch({ authStorage, rewriteUrl: false })
1280
- });
1281
- return ai.wrapLanguageModel({
1282
- model: openai$1.responses(resolvedBareModelId),
1283
- middleware: [middleware]
1284
- });
1285
- }
1286
- return mastraGateway.resolveLanguageModel(args);
1287
- }
1288
- if (storedCred?.type === "oauth") {
1289
- const resolvedModelId = remapOpenAIModelForCodexOAuth(`openai/${args.modelId}`);
1290
- return openaiCodexProvider(resolvedModelId.substring(OPENAI_PREFIX.length), {
1291
- thinkingLevel,
1292
- headers: args.headers
1293
- });
1294
- }
1295
- const apiKey = getOpenAIApiKey();
1296
- if (apiKey) {
1297
- return openaiApiKeyProvider(args.modelId, apiKey, args.headers);
1298
- }
1299
- }
1300
- if (routeThroughMastraGateway) {
1301
- return mastraGateway.resolveLanguageModel(args);
1302
- }
1303
- return new llm.ModelRouterLanguageModel({
1304
- id: `${args.providerId}/${args.modelId}`,
1305
- headers: args.headers
1306
- });
1307
- },
1308
- serializeForSpan() {
1309
- return { id: MASTRACODE_GATEWAY_ID, name: "MastraCode Gateway" };
1310
- }
1311
- };
1312
- }
1313
- function resolveModelId(modelId) {
1314
- return modelId;
1315
- }
1316
- function resolveModel(modelId, options) {
1317
- authStorage.reload();
1318
- const headers = getHarnessHeaders(options?.requestContext);
1319
- const settings = loadSettings();
1320
- const resolvedRouterModelId = resolveModelId(modelId);
1321
- const isMastraGatewayModel = resolvedRouterModelId.startsWith(MASTRA_GATEWAY_PREFIX);
1322
- const normalizedModelId = stripMastraGatewayPrefix(resolvedRouterModelId);
1323
- const mgApiKey = authStorage.getStoredApiKey(MEMORY_GATEWAY_PROVIDER) ?? process.env["MASTRA_GATEWAY_API_KEY"];
1324
- const rawGatewayBase = settings.memoryGateway?.baseUrl ?? process.env["MASTRA_GATEWAY_URL"] ?? "https://gateway-api.mastra.ai";
1325
- const gateway = createMastraCodeGateway({
1326
- mastraGatewayBaseUrl: rawGatewayBase.replace(/\/+$/, "").replace(/\/v1$/, ""),
1327
- mastraGatewayApiKey: mgApiKey,
1328
- routeThroughMastraGateway: Boolean(mgApiKey && isMastraGatewayModel),
1329
- thinkingLevel: options?.thinkingLevel,
1330
- customProviders: settings.customProviders
1331
- });
1332
- return new llm.ModelRouterLanguageModel(
1333
- { id: `${MASTRACODE_GATEWAY_ID}/${normalizedModelId}`, headers },
1334
- [gateway]
1335
- );
1336
- }
1337
- function getDynamicModel({ requestContext }) {
1338
- const harnessContext = requestContext.get("harness");
1339
- const modelId = harnessContext?.state?.currentModelId;
1340
- if (!modelId) {
1341
- throw new Error("No model selected. Use /models to select a model first.");
1342
- }
1343
- const thinkingLevel = harnessContext?.state?.thinkingLevel;
1344
- return resolveModel(modelId, { thinkingLevel, requestContext });
553
+ throw new Error(`Unsupported browser provider: ${provider}`);
1345
554
  }
1346
555
 
1347
556
  // src/onboarding/packs.ts
@@ -2003,9 +1212,7 @@ exports.ensureTerminalGlyphContrast = ensureTerminalGlyphContrast;
2003
1212
  exports.extendedColors = extendedColors;
2004
1213
  exports.getAvailableModePacks = getAvailableModePacks;
2005
1214
  exports.getAvailableOmPacks = getAvailableOmPacks;
2006
- exports.getCopilotModelCatalog = getCopilotModelCatalog;
2007
1215
  exports.getCustomProviderId = getCustomProviderId;
2008
- exports.getDynamicModel = getDynamicModel;
2009
1216
  exports.getEditorTheme = getEditorTheme;
2010
1217
  exports.getMarkdownTheme = getMarkdownTheme;
2011
1218
  exports.getSelectListTheme = getSelectListTheme;
@@ -2018,18 +1225,14 @@ exports.mastra = mastra;
2018
1225
  exports.mastraBrand = mastraBrand;
2019
1226
  exports.releaseAllThreadLocks = releaseAllThreadLocks;
2020
1227
  exports.releaseThreadLock = releaseThreadLock;
2021
- exports.resolveModel = resolveModel;
2022
1228
  exports.resolveModelDefaults = resolveModelDefaults;
2023
1229
  exports.resolveOmRoleModel = resolveOmRoleModel;
2024
1230
  exports.resolveThreadActiveModelPackId = resolveThreadActiveModelPackId;
2025
1231
  exports.restoreTerminalForeground = restoreTerminalForeground;
2026
1232
  exports.saveSettings = saveSettings;
2027
- exports.setAuthStorage = setAuthStorage;
2028
- exports.setAuthStorage2 = setAuthStorage2;
2029
- exports.setAuthStorage3 = setAuthStorage3;
2030
1233
  exports.setProfileProvider = setProfileProvider;
2031
1234
  exports.theme = theme;
2032
1235
  exports.tintHex = tintHex;
2033
1236
  exports.toCustomProviderModelId = toCustomProviderModelId;
2034
- //# sourceMappingURL=chunk-NKTZDFIU.cjs.map
2035
- //# sourceMappingURL=chunk-NKTZDFIU.cjs.map
1237
+ //# sourceMappingURL=chunk-XPPJHUAD.cjs.map
1238
+ //# sourceMappingURL=chunk-XPPJHUAD.cjs.map