mastracode 0.43.0 → 0.44.0-alpha.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.
@@ -28,7 +28,6 @@ let _mastra_code_sdk_theme_palette = require("@mastra/code-sdk/theme-palette");
28
28
  let chalk = require("chalk");
29
29
  chalk = __toESM(chalk, 1);
30
30
  let child_process = require("child_process");
31
- let crypto = require("crypto");
32
31
  let _mastra_code_sdk_auth_account_rotation_processor = require("@mastra/code-sdk/auth/account-rotation-processor");
33
32
  let _mastra_code_sdk_auth_storage = require("@mastra/code-sdk/auth/storage");
34
33
  let _mastra_code_sdk_onboarding_index = require("@mastra/code-sdk/onboarding/index");
@@ -4892,7 +4891,7 @@ function runPermissionHooksForEvent(state, event) {
4892
4891
  const hookMgr = state.hookManager;
4893
4892
  if (!hookMgr) return;
4894
4893
  if (event.type === "agent_start") {
4895
- if (!hookMgr.getRunId()) hookMgr.setRunId((0, crypto.randomUUID)());
4894
+ if (!hookMgr.getRunId()) hookMgr.setRunId(globalThis.crypto.randomUUID());
4896
4895
  return;
4897
4896
  }
4898
4897
  if (event.type === "tool_approval_required") {
@@ -15215,16 +15214,17 @@ var ThresholdSubmenu = class extends _earendil_works_pi_tui.Container {
15215
15214
  }
15216
15215
  handleInput(data) {
15217
15216
  if (this.inInputMode) {
15218
- if (data === "\r" || data === "\n") {
15217
+ const kb = (0, _earendil_works_pi_tui.getKeybindings)();
15218
+ if (data === "\r" || data === "\n" || kb.matches(data, "tui.input.submit")) {
15219
15219
  const parsed = parseTokenInput(this.input.getValue());
15220
15220
  if (parsed) this.onDone(parsed);
15221
15221
  return;
15222
15222
  }
15223
- if (data === "\x1B" || data === "\x1B\x1B") {
15223
+ if (kb.matches(data, "tui.select.cancel")) {
15224
15224
  this.onBack();
15225
15225
  return;
15226
15226
  }
15227
- if (data === "\x1B[B") {
15227
+ if (kb.matches(data, "tui.select.down")) {
15228
15228
  this.inInputMode = false;
15229
15229
  return;
15230
15230
  }
@@ -16336,6 +16336,33 @@ var SettingsComponent = class extends _earendil_works_pi_tui.Box {
16336
16336
  done(enabled ? "On" : "Off");
16337
16337
  }, () => done())
16338
16338
  },
16339
+ {
16340
+ id: "experimentalAgent",
16341
+ label: "Experimental agent",
16342
+ description: "Run the coding agent on the durable or evented runtime (restart required).",
16343
+ currentValue: config.experimentalAgent === "durable" ? "Durable" : config.experimentalAgent === "evented" ? "Evented" : "Off",
16344
+ submenu: (_currentValue, done) => new SelectSubmenu([
16345
+ {
16346
+ value: "off",
16347
+ label: " Off",
16348
+ description: "Use the standard coding agent"
16349
+ },
16350
+ {
16351
+ value: "durable",
16352
+ label: " Durable",
16353
+ description: "Use resumable durable agent streams"
16354
+ },
16355
+ {
16356
+ value: "evented",
16357
+ label: " Evented",
16358
+ description: "Run the agent loop on the evented workflow engine"
16359
+ }
16360
+ ], config.experimentalAgent ?? "off", (value) => {
16361
+ config.experimentalAgent = value === "off" ? null : value;
16362
+ callbacks.onExperimentalAgentChange(config.experimentalAgent);
16363
+ done(config.experimentalAgent === "durable" ? "Durable" : config.experimentalAgent === "evented" ? "Evented" : "Off");
16364
+ }, () => done())
16365
+ },
16339
16366
  {
16340
16367
  id: "backgroundToolsEnabled",
16341
16368
  label: "Experimental background tools",
@@ -16577,6 +16604,9 @@ function getCurrentModeColor$1(ctx) {
16577
16604
  const color = ctx.state.session.mode.resolve().metadata?.color;
16578
16605
  return typeof color === "string" ? color : void 0;
16579
16606
  }
16607
+ function resolveExperimentalAgentSetting(value) {
16608
+ return value === "durable" || value === "evented" ? value : null;
16609
+ }
16580
16610
  function commandExists$1(command) {
16581
16611
  return new Promise((resolve) => {
16582
16612
  (0, child_process.execFile)("/bin/sh", ["-lc", `command -v ${command}`], (error) => resolve(!error));
@@ -16724,6 +16754,7 @@ async function handleSettingsCommand(ctx) {
16724
16754
  experimentalGithubSignals: globalSettings.signals.experimentalGithubSignals,
16725
16755
  experimentalCrossAgentSignals: globalSettings.signals.experimentalCrossAgentSignals,
16726
16756
  experimentalScheduleTools: globalSettings.signals.experimentalScheduleTools,
16757
+ experimentalAgent: resolveExperimentalAgentSetting(globalSettings.experimentalAgent),
16727
16758
  backgroundToolsEnabled: globalSettings.backgroundTools?.enabled ?? false,
16728
16759
  webSearchProvider: globalSettings.preferences.webSearchProvider === "tavily" && !process.env.TAVILY_API_KEY || globalSettings.preferences.webSearchProvider === "parallel" && !process.env.PARALLEL_API_KEY ? "auto" : globalSettings.preferences.webSearchProvider,
16729
16760
  tavilyKeyAvailable: !!process.env.TAVILY_API_KEY,
@@ -16806,6 +16837,12 @@ async function handleSettingsCommand(ctx) {
16806
16837
  (0, _mastra_code_sdk_onboarding_settings.saveSettings)(current);
16807
16838
  ctx.showInfo(`Experimental schedule tools: ${enabled ? "on" : "off"} (restart required)`);
16808
16839
  },
16840
+ onExperimentalAgentChange: (agent) => {
16841
+ const current = (0, _mastra_code_sdk_onboarding_settings.loadSettings)();
16842
+ current.experimentalAgent = agent;
16843
+ (0, _mastra_code_sdk_onboarding_settings.saveSettings)(current);
16844
+ ctx.showInfo(`Experimental agent: ${agent ?? "off"} (restart required)`);
16845
+ },
16809
16846
  onBackgroundToolsChange: (enabled) => {
16810
16847
  const current = (0, _mastra_code_sdk_onboarding_settings.loadSettings)();
16811
16848
  current.backgroundTools = {
@@ -18258,6 +18295,7 @@ async function openAccountManager(ctx, providerId, providerName, initialAccounts
18258
18295
  });
18259
18296
  }
18260
18297
  async function handleLoginCommand(ctx, mode) {
18298
+ ctx.authStorage?.reload();
18261
18299
  const allProviders = (0, _mastra_code_sdk_auth_storage.getOAuthProviders)();
18262
18300
  const loggedInIds = allProviders.filter((p) => ctx.authStorage?.isLoggedIn(p.id)).map((p) => p.id);
18263
18301
  if (mode === "logout") {
@@ -18284,17 +18322,20 @@ async function handleLoginCommand(ctx, mode) {
18284
18322
  }, async (providerId) => {
18285
18323
  ctx.state.ui.hideOverlay();
18286
18324
  const provider = providers.find((p) => p.id === providerId);
18287
- if (provider) if (mode === "login") {
18288
- const accounts = ctx.authStorage?.listAccounts(provider.id) ?? [];
18289
- if (accounts.length > 0) await openAccountManager(ctx, provider.id, provider.name, accounts);
18290
- else await performLogin(ctx, provider.id);
18291
- } else if (ctx.authStorage) {
18292
- const removedAccountIds = ctx.authStorage.listAccounts(provider.id).map((account) => account.id);
18293
- ctx.authStorage.logout(provider.id);
18294
- removeAccountRoutingPreferences(removedAccountIds);
18295
- ctx.state.controller.invalidateAvailableModelsCache();
18296
- ctx.showInfo(`Logged out from ${provider.name}`);
18297
- } else ctx.showError("Auth storage not configured");
18325
+ if (provider) {
18326
+ ctx.authStorage?.reload();
18327
+ if (mode === "login") {
18328
+ const accounts = ctx.authStorage?.listAccounts(provider.id) ?? [];
18329
+ if (accounts.length > 0) await openAccountManager(ctx, provider.id, provider.name, accounts);
18330
+ else await performLogin(ctx, provider.id);
18331
+ } else if (ctx.authStorage) {
18332
+ const removedAccountIds = ctx.authStorage.listAccounts(provider.id).map((account) => account.id);
18333
+ ctx.authStorage.logout(provider.id);
18334
+ removeAccountRoutingPreferences(removedAccountIds);
18335
+ ctx.state.controller.invalidateAvailableModelsCache();
18336
+ ctx.showInfo(`Logged out from ${provider.name}`);
18337
+ } else ctx.showError("Auth storage not configured");
18338
+ }
18298
18339
  resolve();
18299
18340
  }, () => {
18300
18341
  ctx.state.ui.hideOverlay();
@@ -20433,7 +20474,7 @@ function buildSessionRequestContext(ctx) {
20433
20474
  requestContext.set("controller", controllerContext);
20434
20475
  const resourceId = session.identity?.getResourceId?.() ?? "";
20435
20476
  requestContext.set("MastraMemory", {
20436
- thread: { id: (0, crypto.randomUUID)() },
20477
+ thread: { id: globalThis.crypto.randomUUID() },
20437
20478
  resourceId,
20438
20479
  memoryConfig: void 0
20439
20480
  });
@@ -22851,7 +22892,7 @@ var CustomEditor = class extends _earendil_works_pi_tui.Editor {
22851
22892
  const textColorClose = "\x1B[39m";
22852
22893
  result.push(top);
22853
22894
  const fullText = this.getText();
22854
- let greyRemaining = this.voiceTranscriptText.length > 0 && fullText.endsWith(this.voiceTranscriptText) ? this.voiceTranscriptText.length : 0;
22895
+ let greyRemaining = this.voiceTranscriptText.length > 0 && fullText.endsWith(this.voiceTranscriptText) ? [...this.voiceTranscriptText].length : 0;
22855
22896
  const greyOpen = `\x1b[38;2;${parseHex(theme.getTheme().muted).join(";")}m`;
22856
22897
  for (let i = contentLines.length - 1; i >= 0; i--) if (greyRemaining > 0) {
22857
22898
  const { line, consumed } = this.greyifyTrailing(contentLines[i], greyRemaining, greyOpen, textColorOpen);
@@ -23933,7 +23974,7 @@ async function resolveRecognizer(scriptPath = SCRIPT_PATH, plistPath = PLIST_PAT
23933
23974
  } catch {
23934
23975
  return null;
23935
23976
  }
23936
- const hash = (0, crypto.createHash)("sha256").update("v3").update(source).update("\0").update(plist).digest("hex").slice(0, 16);
23977
+ const hash = Buffer.from(await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(`v3${source}\0${plist}`))).toString("hex").slice(0, 16);
23937
23978
  const dir = cacheDir();
23938
23979
  const appPath = (0, path.join)(dir, `macos-stt-${hash}.app`);
23939
23980
  const binaryPath = (0, path.join)(appPath, "Contents", "MacOS", APP_NAME);
@@ -27610,7 +27651,7 @@ var MastraTUI = class MastraTUI {
27610
27651
  beginLifecycleRun() {
27611
27652
  const hookMgr = this.state.hookManager;
27612
27653
  if (!hookMgr) return;
27613
- if (!hookMgr.getRunId()) hookMgr.setRunId((0, crypto.randomUUID)());
27654
+ if (!hookMgr.getRunId()) hookMgr.setRunId(globalThis.crypto.randomUUID());
27614
27655
  hookMgr.runAgentStart().catch(() => {});
27615
27656
  }
27616
27657
  fireLifecycleHooksForEvent(event) {
@@ -28279,4 +28320,4 @@ Object.defineProperty(exports, "theme", {
28279
28320
  }
28280
28321
  });
28281
28322
 
28282
- //# sourceMappingURL=tui-CMhOuaGl.cjs.map
28323
+ //# sourceMappingURL=tui-DbWDXwmn.cjs.map