mastracode 0.46.0-alpha.8 → 0.46.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.
@@ -1,5 +1,6 @@
1
1
  import * as fs$1 from "fs";
2
2
  import fs, { existsSync, readFileSync, statSync, unlinkSync } from "fs";
3
+ import { activateModePackInSettings, listResolvableModePacks, resolvePackSelection } from "@mastra/code-sdk/onboarding/pack-activation";
3
4
  import { MASTRA_GATEWAY_DEFAULT_URL, MASTRA_GATEWAY_PROVIDER, OBSERVABILITY_AUTH_PREFIX, THREAD_ACTIVE_MODEL_PACK_ID_KEY, THREAD_FALLBACK_STATUS_KEY, VIEWPORT_PRESETS, checkProfileProviderMismatch, createBrowserFromSettings, getCustomProviderId, loadSettings, migrateAccountPreferences, parseThreadSettings, parseViewportInput, pruneRemovedAccountPreferences, resolveDefaultThinkingLevel, resolveModePackModels, resolveStagehandModel, resolveThreadActiveModelPackId, saveSettings, setProfileProvider, stripMastraCodeCustomProviderPrefix, toActiveBrowserSettings, toCustomProviderModelId } from "@mastra/code-sdk/onboarding/settings";
4
5
  import { ThreadLockError } from "@mastra/code-sdk/utils/thread-lock";
5
6
  import { mastraBrand } from "@mastra/code-sdk/theme-palette";
@@ -28,7 +29,6 @@ import { getCatalogThinkingLevels, runCatalogThinkingLevel } from "@mastra/code-
28
29
  import { VALID_EVENTS } from "@mastra/code-sdk/hooks/index";
29
30
  import { openUrlInBrowser } from "@mastra/code-sdk/utils/open-url";
30
31
  import { parseError } from "@mastra/code-sdk/utils/errors";
31
- import { getAvailableModePacks as getAvailableModePacks$1, getBuiltinModePack, listBuiltinModePacks, resolveAutoOMModelId, resolveModePackFallbackChain } from "@mastra/code-sdk/onboarding/packs";
32
32
  import { formatSkillActivation } from "@mastra/core/workspace";
33
33
  import { approvePlanFile, readPlanFile, resolvePlanPath } from "@mastra/code-sdk/utils/plans";
34
34
  import { TASKS_STATE_ID } from "@mastra/core/tools";
@@ -45,6 +45,7 @@ import { highlight } from "cli-highlight";
45
45
  import { TOOL_CATEGORIES, getToolCategory } from "@mastra/code-sdk/permissions";
46
46
  import { parse } from "jsonriver";
47
47
  import { stripVTControlCharacters } from "util";
48
+ import { getAvailableModePacks as getAvailableModePacks$1, getBuiltinModePack, resolveAutoOMModelId, resolveModePackFallbackChain } from "@mastra/code-sdk/onboarding/packs";
48
49
  import { getClipboardImage, getClipboardText, setClipboardText } from "@mastra/code-sdk/clipboard/index";
49
50
  import { removeCustomPackFromSettings } from "@mastra/code-sdk/onboarding/custom-packs";
50
51
  import { getActiveRouteMemoryModelId } from "@mastra/code-sdk/agents/model";
@@ -5232,54 +5233,6 @@ function modelRoutesMatch(current, expected) {
5232
5233
  return candidate.id === entry.id && candidate.label === entry.label && candidate.modelId === entry.modelId && candidate.accountId === entry.accountId && candidate.memoryModelId === entry.memoryModelId;
5233
5234
  });
5234
5235
  }
5235
- function listResolvableModePacks(settings) {
5236
- return [...listBuiltinModePacks(), ...settings.customModelPacks.map((pack) => ({
5237
- id: `custom:${pack.name}`,
5238
- name: pack.name,
5239
- description: "Saved custom pack",
5240
- models: {
5241
- build: pack.models.build ?? "",
5242
- plan: pack.models.plan ?? "",
5243
- fast: pack.models.fast ?? "",
5244
- ...pack.models.memory ? { memory: pack.models.memory } : {}
5245
- }
5246
- }))];
5247
- }
5248
- function resolvePackSelection(settings, packId, modeId) {
5249
- const packs = listResolvableModePacks(settings);
5250
- const packsById = new Map(packs.map((pack) => [pack.id, pack]));
5251
- const pack = packsById.get(packId);
5252
- if (!pack) return void 0;
5253
- const packModels = resolveModePackModels(settings, pack);
5254
- const modelId = packModels[modeId];
5255
- if (!modelId) return void 0;
5256
- return {
5257
- modelId,
5258
- subagentModels: Object.fromEntries(Object.entries({
5259
- explore: "fast",
5260
- plan: "plan",
5261
- execute: "build"
5262
- }).flatMap(([agentType, subagentModeId]) => {
5263
- const subagentModelId = packModels[subagentModeId];
5264
- return subagentModelId ? [[agentType, subagentModelId]] : [];
5265
- })),
5266
- modelRoute: { entries: resolveModePackFallbackChain(settings.models.packFallbacks, packId, settings.customModelPacks).flatMap((routeId) => {
5267
- const routePack = packsById.get(routeId);
5268
- if (!routePack) return [];
5269
- const routeModels = resolveModePackModels(settings, routePack);
5270
- const routeModelId = routeModels[modeId];
5271
- if (!routeModelId) return [];
5272
- const accountId = settings.models.packAccountPreferences?.[routeId]?.[routeModelId];
5273
- return [{
5274
- id: routeId,
5275
- label: routePack.name,
5276
- modelId: routeModelId,
5277
- ...accountId ? { accountId } : {},
5278
- ...routeModels.memory ? { memoryModelId: routeModels.memory } : {}
5279
- }];
5280
- }) }
5281
- };
5282
- }
5283
5236
  async function applyPackToSession(ctx, packId, options = {}) {
5284
5237
  const settings = options.settings ?? loadSettings();
5285
5238
  const modeId = options.modeId ?? ctx.state.session.mode.get();
@@ -27028,6 +26981,20 @@ var MastraTUI = class MastraTUI {
27028
26981
  });
27029
26982
  this.state.ui.start();
27030
26983
  const startupResumeIssue = await resumeThreadOnStartup(this.state, this.state.options.resumeThreadId);
26984
+ if (this.state.options.initialPackId) {
26985
+ const packId = this.state.options.initialPackId;
26986
+ const settings = loadSettings$1();
26987
+ const modeId = this.state.session.mode.get();
26988
+ if (!resolvePackSelection(settings, packId, modeId)) {
26989
+ this.stop();
26990
+ process.stderr.write(`Error: Model pack "${packId}" has no model for ${modeId} mode\n`);
26991
+ this.exit(1);
26992
+ return;
26993
+ }
26994
+ activateModePackInSettings(settings, packId);
26995
+ saveSettings$1(settings);
26996
+ await applyCurrentThreadPack({ state: this.state }, { packId });
26997
+ }
27031
26998
  await this.syncThreadActivePackMetadata();
27032
26999
  subscribeToAgentController(this.state, (event) => this.handleEvent(event));
27033
27000
  if (this.state.options.backgroundToolsEnabled) this.cleanupBackgroundCompletionListener = this.state.options.backgroundCompletionEvents?.subscribe((event) => this.handleBackgroundCompletion(event));
@@ -27716,4 +27683,4 @@ var MastraTUI = class MastraTUI {
27716
27683
  //#endregion
27717
27684
  export { restoreTerminalForeground as C, mastraBrand as S, TUI_CO_AUTHOR as T, applyThemeMode as _, formatUpToDate as a, getThemeMode as b, LoginSelectorComponent as c, formatOMStatus as d, UserMessageComponent as f, detectTerminalTheme as g, AssistantMessageComponent as h, formatRegistryError as i, LoginDialogComponent as l, ModelSelectorComponent as m, createTUIState as n, formatUpdateHeader as o, ToolExecutionComponentEnhanced as p, formatInstallingLabel as r, formatUpdateOutcome as s, MastraTUI as t, OMProgressComponent as u, getEditorTheme as v, theme as w, mastra as x, getMarkdownTheme as y };
27718
27685
 
27719
- //# sourceMappingURL=tui-BqcIy2hd.js.map
27686
+ //# sourceMappingURL=tui-Cvs2FMoN.js.map