mastracode 0.50.1-alpha.3 → 0.50.1-alpha.4
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.
- package/CHANGELOG.md +16 -0
- package/dist/cli.cjs +2 -2
- package/dist/cli.js +2 -2
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/tui/mastra-tui.d.ts +1 -1
- package/dist/tui/mastra-tui.d.ts.map +1 -1
- package/dist/tui/thread-startup.d.ts +1 -1
- package/dist/tui/thread-startup.d.ts.map +1 -1
- package/dist/{tui-CdCWteO9.cjs → tui-BfBjFTxw.cjs} +67 -25
- package/dist/{tui-CdCWteO9.cjs.map → tui-BfBjFTxw.cjs.map} +1 -1
- package/dist/{tui-CZhAkPMX.js → tui-IoCMmeHj.js} +67 -25
- package/dist/{tui-CZhAkPMX.js.map → tui-IoCMmeHj.js.map} +1 -1
- package/dist/tui.cjs +1 -1
- package/dist/tui.js +1 -1
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# mastracode
|
|
2
2
|
|
|
3
|
+
## 0.50.1-alpha.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- **Showed plugin signal provider startup failures.** A plugin signal provider that fails to start while Mastra Code boots now shows an error in the session, as reload failures do, instead of only printing to the console before the UI starts. ([#30428](https://github.com/mastra-ai/mastra/pull/30428))
|
|
8
|
+
|
|
9
|
+
- **Fixed startup carrying on after you stop Mastra Code.** If you press Ctrl+C while Mastra Code is still starting, startup now stops. Before, it kept going even though Mastra Code was shutting down. It could take the terminal back, resume and lock a thread, clone a thread from another resource, and connect MCP servers. It could also apply the startup model pack, open onboarding, run SessionStart hooks and send the startup prompt. Stopping during onboarding no longer opens the login dialog, switches models or opens the model picker either. Text you typed is also no longer submitted after Mastra Code stops. ([#30431](https://github.com/mastra-ai/mastra/pull/30431))
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`88b4a97`](https://github.com/mastra-ai/mastra/commit/88b4a970426f48731a153e46ed228d0301da32a1), [`33eaa29`](https://github.com/mastra-ai/mastra/commit/33eaa293e28aa8cd86ad68e1eaf44b4929be818d), [`6c647e6`](https://github.com/mastra-ai/mastra/commit/6c647e6faee5a6182d99e2352808df1b57558b67), [`adc0a70`](https://github.com/mastra-ai/mastra/commit/adc0a70bf835d1f81f7bf0af11b247ca115a6683), [`cd2a326`](https://github.com/mastra-ai/mastra/commit/cd2a326988ced13509902dfa50339afcffdbf95e), [`0170d70`](https://github.com/mastra-ai/mastra/commit/0170d700a411ce2b5e64a82bc1133716ae75cbd6), [`4224ee3`](https://github.com/mastra-ai/mastra/commit/4224ee32d3e8fa0f76aedab499c24acc1a564435), [`1072f7c`](https://github.com/mastra-ai/mastra/commit/1072f7c6268db5fb515460fdcdda173592bce450), [`c8a35ac`](https://github.com/mastra-ai/mastra/commit/c8a35ac6243eaef8ef1d9e589a7b75bf44904d8b), [`c8a35ac`](https://github.com/mastra-ai/mastra/commit/c8a35ac6243eaef8ef1d9e589a7b75bf44904d8b)]:
|
|
12
|
+
- @mastra/core@1.84.0-alpha.3
|
|
13
|
+
- @mastra/libsql@1.31.0-alpha.1
|
|
14
|
+
- @mastra/pg@1.37.0-alpha.1
|
|
15
|
+
- @mastra/memory@1.41.2-alpha.2
|
|
16
|
+
- @mastra/mcp@2.10.0-alpha.0
|
|
17
|
+
- @mastra/code-sdk@1.19.1-alpha.4
|
|
18
|
+
|
|
3
19
|
## 0.50.1-alpha.3
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_tui = require("./tui-
|
|
2
|
+
const require_tui = require("./tui-BfBjFTxw.cjs");
|
|
3
3
|
let _mastra_code_sdk = require("@mastra/code-sdk");
|
|
4
4
|
let child_process = require("child_process");
|
|
5
5
|
let fs = require("fs");
|
|
@@ -265,7 +265,7 @@ async function runUpdateCommand({ args = [], output = process.stdout, errorOutpu
|
|
|
265
265
|
}
|
|
266
266
|
// src/version.ts
|
|
267
267
|
function getCurrentVersion() {
|
|
268
|
-
return "0.50.1-alpha.
|
|
268
|
+
return "0.50.1-alpha.4";
|
|
269
269
|
}
|
|
270
270
|
/** Whether the invocation is `mastracode --version` or `mastracode -v`. */
|
|
271
271
|
function isVersionCommand(argv) {
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { D as closeActiveBrowser, E as activeBrowserGeneration, O as discardBrowser, T as TUI_CO_AUTHOR, _ as normalizeThemePreference, a as formatUpdateHeader, g as applyThemePreference, i as formatUpToDate, k as replaceActiveBrowser, n as formatInstallingLabel, o as formatUpdateOutcome, r as formatRegistryError, t as MastraTUI } from "./tui-
|
|
2
|
+
import { D as closeActiveBrowser, E as activeBrowserGeneration, O as discardBrowser, T as TUI_CO_AUTHOR, _ as normalizeThemePreference, a as formatUpdateHeader, g as applyThemePreference, i as formatUpToDate, k as replaceActiveBrowser, n as formatInstallingLabel, o as formatUpdateOutcome, r as formatRegistryError, t as MastraTUI } from "./tui-IoCMmeHj.js";
|
|
3
3
|
import { createMastraCode, resolveSubagentsSetting } from "@mastra/code-sdk";
|
|
4
4
|
import { spawn } from "child_process";
|
|
5
5
|
import fs from "fs";
|
|
@@ -264,7 +264,7 @@ async function runUpdateCommand({ args = [], output = process.stdout, errorOutpu
|
|
|
264
264
|
}
|
|
265
265
|
// src/version.ts
|
|
266
266
|
function getCurrentVersion() {
|
|
267
|
-
return "0.50.1-alpha.
|
|
267
|
+
return "0.50.1-alpha.4";
|
|
268
268
|
}
|
|
269
269
|
/** Whether the invocation is `mastracode --version` or `mastracode -v`. */
|
|
270
270
|
function isVersionCommand(argv) {
|
package/dist/docs/SKILL.md
CHANGED
package/dist/tui/mastra-tui.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MastraTUIOptions, TUIState } from './state.js';
|
|
2
2
|
export type { MastraTUIOptions } from './state.js';
|
|
3
|
-
export declare function syncInitialThreadState(state: TUIState): Promise<void>;
|
|
3
|
+
export declare function syncInitialThreadState(state: TUIState, isCurrent?: () => boolean): Promise<void>;
|
|
4
4
|
export declare function consumePendingImages(text: string, pendingImages: TUIState['pendingImages']): {
|
|
5
5
|
content: string;
|
|
6
6
|
images?: TUIState['pendingImages'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mastra-tui.d.ts","sourceRoot":"","sources":["../../src/tui/mastra-tui.ts"],"names":[],"mappings":"AA0FA,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAW7D,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAkCnD,wBAAsB,sBAAsB,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"mastra-tui.d.ts","sourceRoot":"","sources":["../../src/tui/mastra-tui.ts"],"names":[],"mappings":"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"}
|
|
@@ -13,5 +13,5 @@ export type StartupResumeIssue = {
|
|
|
13
13
|
* locked does not throw; the session is left pending a new thread and the issue
|
|
14
14
|
* is returned so the caller can tell the user once the UI is ready.
|
|
15
15
|
*/
|
|
16
|
-
export declare function resumeThreadOnStartup(state: TUIState, requestedThreadId?: string): Promise<StartupResumeIssue | undefined>;
|
|
16
|
+
export declare function resumeThreadOnStartup(state: TUIState, requestedThreadId?: string, isCurrent?: () => boolean): Promise<StartupResumeIssue | undefined>;
|
|
17
17
|
//# sourceMappingURL=thread-startup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread-startup.d.ts","sourceRoot":"","sources":["../../src/tui/thread-startup.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1E;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,QAAQ,EACf,iBAAiB,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"thread-startup.d.ts","sourceRoot":"","sources":["../../src/tui/thread-startup.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1E;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,QAAQ,EACf,iBAAiB,CAAC,EAAE,MAAM,EAC1B,SAAS,GAAE,MAAM,OAAoB,GACpC,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CA4DzC"}
|
|
@@ -28661,12 +28661,13 @@ var SimpleProgressComponent = class extends _earendil_works_pi_tui.Container {
|
|
|
28661
28661
|
* locked does not throw; the session is left pending a new thread and the issue
|
|
28662
28662
|
* is returned so the caller can tell the user once the UI is ready.
|
|
28663
28663
|
*/
|
|
28664
|
-
async function resumeThreadOnStartup(state, requestedThreadId) {
|
|
28664
|
+
async function resumeThreadOnStartup(state, requestedThreadId, isCurrent = () => true) {
|
|
28665
28665
|
const local = state.local;
|
|
28666
|
-
if (!local) return resumeFactoryThread(state);
|
|
28666
|
+
if (!local) return resumeFactoryThread(state, isCurrent);
|
|
28667
28667
|
const { session, controller } = local;
|
|
28668
28668
|
const currentPath = state.projectInfo.rootPath;
|
|
28669
28669
|
const allThreads = await session.thread.list(requestedThreadId ? { allResources: true } : void 0);
|
|
28670
|
+
if (!isCurrent()) return;
|
|
28670
28671
|
const activeThreadId = session.thread.getId();
|
|
28671
28672
|
if (requestedThreadId) {
|
|
28672
28673
|
const thread = allThreads.find((candidate) => candidate.id === requestedThreadId);
|
|
@@ -28697,11 +28698,13 @@ async function resumeThreadOnStartup(state, requestedThreadId) {
|
|
|
28697
28698
|
}
|
|
28698
28699
|
const threads = allThreads.filter((thread) => thread.metadata?.projectPath === currentPath);
|
|
28699
28700
|
if (threads.length === 0) {
|
|
28700
|
-
if (await cloneDriftedThread(state, local)) return;
|
|
28701
|
+
if (await cloneDriftedThread(state, local, isCurrent)) return;
|
|
28702
|
+
if (!isCurrent()) return;
|
|
28701
28703
|
state.pendingNewThread = true;
|
|
28702
28704
|
return;
|
|
28703
28705
|
}
|
|
28704
28706
|
for (const thread of [...threads].sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime())) {
|
|
28707
|
+
if (!isCurrent()) return;
|
|
28705
28708
|
if (thread.id === session.thread.getId()) return;
|
|
28706
28709
|
try {
|
|
28707
28710
|
await session.thread.switch({ threadId: thread.id });
|
|
@@ -28711,12 +28714,14 @@ async function resumeThreadOnStartup(state, requestedThreadId) {
|
|
|
28711
28714
|
throw error;
|
|
28712
28715
|
}
|
|
28713
28716
|
}
|
|
28717
|
+
if (!isCurrent()) return;
|
|
28714
28718
|
state.pendingNewThread = true;
|
|
28715
28719
|
}
|
|
28716
28720
|
/** Factory sessions own their threads, so local project-path tagging and resource IDs don't apply. */
|
|
28717
|
-
async function resumeFactoryThread(state) {
|
|
28721
|
+
async function resumeFactoryThread(state, isCurrent) {
|
|
28718
28722
|
if (state.session.thread.getId()) return;
|
|
28719
28723
|
const [latest] = (await state.session.thread.list()).sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime());
|
|
28724
|
+
if (!isCurrent()) return;
|
|
28720
28725
|
if (latest) await state.session.thread.switch({ threadId: latest.id });
|
|
28721
28726
|
else state.pendingNewThread = true;
|
|
28722
28727
|
}
|
|
@@ -28730,14 +28735,14 @@ async function startPendingNewThread(state, { session }) {
|
|
|
28730
28735
|
await session.thread.clearAndReleaseLock();
|
|
28731
28736
|
state.pendingNewThread = true;
|
|
28732
28737
|
}
|
|
28733
|
-
async function cloneDriftedThread(state, { session }) {
|
|
28738
|
+
async function cloneDriftedThread(state, { session }, isCurrent) {
|
|
28734
28739
|
const currentPath = state.projectInfo.rootPath;
|
|
28735
28740
|
const currentResourceId = session.identity.getResourceId();
|
|
28736
28741
|
const thread = [...(await session.thread.list({
|
|
28737
28742
|
allResources: true,
|
|
28738
28743
|
metadata: { projectPath: currentPath }
|
|
28739
28744
|
})).filter((thread) => thread.resourceId !== currentResourceId)].sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime())[0];
|
|
28740
|
-
if (!thread) return false;
|
|
28745
|
+
if (!thread || !isCurrent()) return false;
|
|
28741
28746
|
if (await askModalQuestion(state.ui, {
|
|
28742
28747
|
question: [
|
|
28743
28748
|
"This directory is tagged on a different resource.",
|
|
@@ -28756,7 +28761,7 @@ async function cloneDriftedThread(state, { session }) {
|
|
|
28756
28761
|
widthPercent: 80,
|
|
28757
28762
|
maxHeight: "70%"
|
|
28758
28763
|
}
|
|
28759
|
-
}) !== "Clone and resume") return false;
|
|
28764
|
+
}) !== "Clone and resume" || !isCurrent()) return false;
|
|
28760
28765
|
const progress = new SimpleProgressComponent({
|
|
28761
28766
|
showElapsed: false,
|
|
28762
28767
|
showPercentage: false
|
|
@@ -28770,6 +28775,7 @@ async function cloneDriftedThread(state, { session }) {
|
|
|
28770
28775
|
state.ui.requestRender();
|
|
28771
28776
|
try {
|
|
28772
28777
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
28778
|
+
if (!isCurrent()) return false;
|
|
28773
28779
|
progress.updateStatus("Loading cloned thread...");
|
|
28774
28780
|
state.ui.requestRender();
|
|
28775
28781
|
await session.thread.cloneToCurrentResource({
|
|
@@ -28800,15 +28806,16 @@ function fallbackStatusFromMetadata(metadata) {
|
|
|
28800
28806
|
const persisted = metadata?.[_mastra_code_sdk_onboarding_settings.THREAD_FALLBACK_STATUS_KEY];
|
|
28801
28807
|
if (persisted && typeof persisted === "object" && typeof persisted.usingPack === "string" && typeof persisted.failedPack === "string") return persisted;
|
|
28802
28808
|
}
|
|
28803
|
-
async function syncInitialThreadState(state) {
|
|
28809
|
+
async function syncInitialThreadState(state, isCurrent = () => true) {
|
|
28804
28810
|
const initThreadId = state.session.thread.getId();
|
|
28805
28811
|
if (!initThreadId) {
|
|
28806
28812
|
setCurrentThreadTitle(state, void 0);
|
|
28807
28813
|
state.fallbackStatus = void 0;
|
|
28808
28814
|
return;
|
|
28809
28815
|
}
|
|
28816
|
+
const ownsUpdate = () => isCurrent() && state.session.thread.getId() === initThreadId;
|
|
28810
28817
|
const initThreads = await state.session.thread.list();
|
|
28811
|
-
if (
|
|
28818
|
+
if (!ownsUpdate()) return;
|
|
28812
28819
|
const initThread = initThreads.find((t) => t.id === initThreadId);
|
|
28813
28820
|
const metadata = initThread?.metadata;
|
|
28814
28821
|
const persistedFallbackStatus = fallbackStatusFromMetadata(metadata);
|
|
@@ -28817,13 +28824,13 @@ async function syncInitialThreadState(state) {
|
|
|
28817
28824
|
const currentPending = (state.session.state?.get?.())?.[_mastra_code_sdk_auth_account_rotation_processor.MODEL_FALLBACK_STATE_KEY];
|
|
28818
28825
|
if (validPendingFallback || currentPending) {
|
|
28819
28826
|
const updates = { [_mastra_code_sdk_auth_account_rotation_processor.MODEL_FALLBACK_STATE_KEY]: validPendingFallback };
|
|
28820
|
-
if (!(state.session.state.setIf ? await state.session.state.setIf(updates,
|
|
28827
|
+
if (!(state.session.state.setIf ? await state.session.state.setIf(updates, ownsUpdate) : ownsUpdate() ? await state.session.state.set(updates).then(() => true) : false) || !ownsUpdate()) return;
|
|
28821
28828
|
}
|
|
28822
28829
|
setCurrentThreadTitle(state, initThread?.title);
|
|
28823
28830
|
state.fallbackStatus = persistedFallbackStatus;
|
|
28824
28831
|
state.activeGithubPrSubscriptions = getGithubPrSubscriptionsFromMetadata(metadata);
|
|
28825
28832
|
if (state.local) await state.goalManager.loadFromThread(state.local);
|
|
28826
|
-
if (
|
|
28833
|
+
if (!ownsUpdate()) return;
|
|
28827
28834
|
if (!state.goalManager.getGoal()) state.goalManager.loadFromThreadMetadata(metadata);
|
|
28828
28835
|
}
|
|
28829
28836
|
function shouldUseCaffeinate() {
|
|
@@ -28991,15 +28998,19 @@ var MastraTUI = class MastraTUI {
|
|
|
28991
28998
|
*/
|
|
28992
28999
|
async run() {
|
|
28993
29000
|
await this.init();
|
|
29001
|
+
if (this.stopped) return;
|
|
28994
29002
|
const hookMgr = this.state.hookManager;
|
|
28995
29003
|
if (hookMgr) hookMgr.runSessionStart().catch(() => {});
|
|
28996
29004
|
if (this.state.options.initialMessage) {
|
|
28997
29005
|
const { resumeSkipNotice } = this.state.options;
|
|
28998
|
-
|
|
29006
|
+
const resumed = resumeSkipNotice ? await this.resumedConversation() : false;
|
|
29007
|
+
if (this.stopped) return;
|
|
29008
|
+
if (resumeSkipNotice && resumed) showInfo(this.state, resumeSkipNotice);
|
|
28999
29009
|
else await this.submitUserInput(this.state.options.initialMessage);
|
|
29000
29010
|
}
|
|
29001
|
-
while (
|
|
29011
|
+
while (!this.stopped) {
|
|
29002
29012
|
const userInput = await this.getUserInput();
|
|
29013
|
+
if (this.stopped) return;
|
|
29003
29014
|
if (!userInput.trim() && userInput !== " ") continue;
|
|
29004
29015
|
await this.submitUserInput(userInput);
|
|
29005
29016
|
}
|
|
@@ -29035,7 +29046,9 @@ var MastraTUI = class MastraTUI {
|
|
|
29035
29046
|
const { content, images } = consumePendingImages(userInput, this.state.pendingImages);
|
|
29036
29047
|
this.state.pendingImages = [];
|
|
29037
29048
|
const optimisticMessageId = this.renderOptimisticUserMessage(content, images);
|
|
29038
|
-
|
|
29049
|
+
const allowed = await this.runUserPromptHook(userInput);
|
|
29050
|
+
if (this.stopped) return;
|
|
29051
|
+
if (!allowed) {
|
|
29039
29052
|
this.removeOptimisticUserMessage(optimisticMessageId);
|
|
29040
29053
|
return;
|
|
29041
29054
|
}
|
|
@@ -29148,7 +29161,9 @@ var MastraTUI = class MastraTUI {
|
|
|
29148
29161
|
send();
|
|
29149
29162
|
return;
|
|
29150
29163
|
}
|
|
29151
|
-
pendingThread.then(
|
|
29164
|
+
pendingThread.then(() => {
|
|
29165
|
+
if (!this.stopped) send();
|
|
29166
|
+
}).catch((error) => {
|
|
29152
29167
|
this.removeOptimisticUserMessage(optimisticMessageId);
|
|
29153
29168
|
showSessionError(this.state, error);
|
|
29154
29169
|
});
|
|
@@ -29230,6 +29245,9 @@ var MastraTUI = class MastraTUI {
|
|
|
29230
29245
|
this.cleanupKeyHandlers();
|
|
29231
29246
|
this.cleanupKeyHandlers = void 0;
|
|
29232
29247
|
}
|
|
29248
|
+
this.state.editor.onSubmit = void 0;
|
|
29249
|
+
this.pendingUserInputResolve = void 0;
|
|
29250
|
+
this.queuedUserInput = [];
|
|
29233
29251
|
if (this.cleanupPluginReloadListener) {
|
|
29234
29252
|
this.cleanupPluginReloadListener();
|
|
29235
29253
|
this.cleanupPluginReloadListener = void 0;
|
|
@@ -29267,8 +29285,10 @@ var MastraTUI = class MastraTUI {
|
|
|
29267
29285
|
const local = this.state.local;
|
|
29268
29286
|
if (local) {
|
|
29269
29287
|
await local.controller.init();
|
|
29288
|
+
if (this.stopped) return;
|
|
29270
29289
|
await local.controller.getMastra()?.startWorkers();
|
|
29271
29290
|
}
|
|
29291
|
+
if (this.stopped) return;
|
|
29272
29292
|
if (this.state.pluginManager && !this.cleanupPluginReloadListener) this.cleanupPluginReloadListener = this.state.pluginManager.onReload((plugins) => this.refreshPluginRuntimeState(plugins).catch((err) => {
|
|
29273
29293
|
const msg = err instanceof Error ? err.message : String(err);
|
|
29274
29294
|
process.stderr.write(`[plugin runtime refresh] ${msg}\n`);
|
|
@@ -29278,10 +29298,8 @@ var MastraTUI = class MastraTUI {
|
|
|
29278
29298
|
const label = pluginNames.length === 1 ? "Plugin" : "Plugins";
|
|
29279
29299
|
showInfo(this.state, `${label} updated to the latest version: ${pluginNames.join(", ")}`);
|
|
29280
29300
|
});
|
|
29281
|
-
if (this.state.pluginManager && !this.cleanupPluginErrorListener) this.cleanupPluginErrorListener = this.state.pluginManager.onPluginError((event) => {
|
|
29282
|
-
showError(this.state, event.message);
|
|
29283
|
-
});
|
|
29284
29301
|
await loadCustomSlashCommands(this.state);
|
|
29302
|
+
if (this.stopped) return;
|
|
29285
29303
|
setupAutocomplete(this.state);
|
|
29286
29304
|
refreshSkillsAutocomplete(this.state).catch((err) => {
|
|
29287
29305
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -29294,7 +29312,8 @@ var MastraTUI = class MastraTUI {
|
|
|
29294
29312
|
doubleCtrlCMs: MastraTUI.DOUBLE_CTRL_C_MS
|
|
29295
29313
|
});
|
|
29296
29314
|
this.state.ui.start();
|
|
29297
|
-
const startupResumeIssue = await resumeThreadOnStartup(this.state, this.state.options.resumeThreadId);
|
|
29315
|
+
const startupResumeIssue = await resumeThreadOnStartup(this.state, this.state.options.resumeThreadId, () => !this.stopped);
|
|
29316
|
+
if (this.stopped) return;
|
|
29298
29317
|
if (this.state.options.initialPackId) {
|
|
29299
29318
|
const packId = this.state.options.initialPackId;
|
|
29300
29319
|
const settings = (0, _mastra_code_sdk_onboarding_index.loadSettings)();
|
|
@@ -29308,13 +29327,17 @@ var MastraTUI = class MastraTUI {
|
|
|
29308
29327
|
(0, _mastra_code_sdk_onboarding_pack_activation.activateModePackInSettings)(settings, packId);
|
|
29309
29328
|
(0, _mastra_code_sdk_onboarding_index.saveSettings)(settings);
|
|
29310
29329
|
await applyCurrentThreadPack({ state: this.state }, { packId });
|
|
29330
|
+
if (this.stopped) return;
|
|
29311
29331
|
}
|
|
29312
|
-
await this.syncThreadActivePackMetadata();
|
|
29332
|
+
await this.syncThreadActivePackMetadata(void 0, () => !this.stopped);
|
|
29333
|
+
if (this.stopped) return;
|
|
29313
29334
|
subscribeToAgentController(this.state, (event) => this.handleEvent(event));
|
|
29314
29335
|
if (this.state.options.backgroundToolsEnabled) this.cleanupBackgroundCompletionListener = this.state.options.backgroundCompletionEvents?.subscribe((event) => this.handleBackgroundCompletion(event));
|
|
29315
29336
|
if (this.state.session.state.get()?.escapeAsCancel === false) this.state.editor.escapeEnabled = false;
|
|
29316
29337
|
await this.state.local?.controller.loadOMProgress(this.state.local.session);
|
|
29317
|
-
|
|
29338
|
+
if (this.stopped) return;
|
|
29339
|
+
await syncInitialThreadState(this.state, () => !this.stopped);
|
|
29340
|
+
if (this.stopped) return;
|
|
29318
29341
|
this.state.isInitialized = true;
|
|
29319
29342
|
if (this.state.mcpManager?.hasServers()) this.state.mcpManager.initInBackground().then((result) => {
|
|
29320
29343
|
for (const s of result.failed) if (s.needsAuth) showInfo(this.state, `MCP: \u26a0 "${s.name}" needs authentication \u2192 run /mcp to authenticate`);
|
|
@@ -29323,9 +29346,18 @@ var MastraTUI = class MastraTUI {
|
|
|
29323
29346
|
}).catch((error) => {
|
|
29324
29347
|
showInfo(this.state, `MCP: Initialization failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
29325
29348
|
});
|
|
29326
|
-
await this.renderExistingMessagesAndSeedIdleCounter();
|
|
29349
|
+
await this.renderExistingMessagesAndSeedIdleCounter(() => !this.stopped);
|
|
29350
|
+
if (this.stopped) return;
|
|
29327
29351
|
await renderExistingTasks(this.state);
|
|
29328
|
-
if (this.
|
|
29352
|
+
if (this.stopped) return;
|
|
29353
|
+
if (this.stopped) return;
|
|
29354
|
+
if (this.state.pluginManager && !this.cleanupPluginErrorListener) this.cleanupPluginErrorListener = this.state.pluginManager.onPluginError((event) => {
|
|
29355
|
+
showError(this.state, event.message);
|
|
29356
|
+
});
|
|
29357
|
+
if (this.shouldShowOnboarding()) {
|
|
29358
|
+
await this.showOnboarding();
|
|
29359
|
+
if (this.stopped) return;
|
|
29360
|
+
}
|
|
29329
29361
|
if (startupResumeIssue?.kind === "missing") showError(this.state, `Thread not found: ${startupResumeIssue.threadId}. Started a new thread; use /threads to pick an existing one.`);
|
|
29330
29362
|
else if (startupResumeIssue?.kind === "locked") showThreadLockPrompt(this.buildCommandContext(), startupResumeIssue.title, startupResumeIssue.ownerPid, startupResumeIssue.threadId);
|
|
29331
29363
|
this.checkForUpdate().catch(() => {});
|
|
@@ -29766,6 +29798,7 @@ var MastraTUI = class MastraTUI {
|
|
|
29766
29798
|
}
|
|
29767
29799
|
const authMode = await promptAuthMode(this.state.ui, providerName, provider?.authModes);
|
|
29768
29800
|
if (authMode === null) return;
|
|
29801
|
+
if (this.stopped) return;
|
|
29769
29802
|
return new Promise((resolve) => {
|
|
29770
29803
|
const dialog = new LoginDialogComponent(this.state.ui, providerId, (success, message) => {
|
|
29771
29804
|
this.state.ui.hideOverlay();
|
|
@@ -29793,6 +29826,10 @@ var MastraTUI = class MastraTUI {
|
|
|
29793
29826
|
}).then(async () => {
|
|
29794
29827
|
this.state.ui.hideOverlay();
|
|
29795
29828
|
const { PROVIDER_DEFAULT_MODELS } = await import("@mastra/code-sdk/auth/storage");
|
|
29829
|
+
if (this.stopped) {
|
|
29830
|
+
resolve();
|
|
29831
|
+
return;
|
|
29832
|
+
}
|
|
29796
29833
|
const defaultModel = PROVIDER_DEFAULT_MODELS[providerId];
|
|
29797
29834
|
if (defaultModel) {
|
|
29798
29835
|
await this.state.session.model.switch(defaultModel);
|
|
@@ -29813,6 +29850,7 @@ var MastraTUI = class MastraTUI {
|
|
|
29813
29850
|
loggedIn: this.state.authStorage?.isLoggedIn(p.id) ?? false
|
|
29814
29851
|
}));
|
|
29815
29852
|
const access = await this.buildProviderAccess();
|
|
29853
|
+
if (this.stopped) return;
|
|
29816
29854
|
const hasProviderAccess = Object.values(access).some(Boolean);
|
|
29817
29855
|
const savedSettings = (0, _mastra_code_sdk_onboarding_index.loadSettings)();
|
|
29818
29856
|
const modePacks = (0, _mastra_code_sdk_onboarding_index.getAvailableModePacks)(access, savedSettings.customModelPacks);
|
|
@@ -29849,6 +29887,7 @@ var MastraTUI = class MastraTUI {
|
|
|
29849
29887
|
onLogin: (providerId, done) => {
|
|
29850
29888
|
this.performLogin(providerId).then(async () => {
|
|
29851
29889
|
try {
|
|
29890
|
+
if (this.stopped) return;
|
|
29852
29891
|
const updatedAccess = await this.buildProviderAccess();
|
|
29853
29892
|
const updatedHasAccess = Object.values(updatedAccess).some(Boolean);
|
|
29854
29893
|
component.updateModePacks((0, _mastra_code_sdk_onboarding_index.getAvailableModePacks)(updatedAccess, savedSettings.customModelPacks));
|
|
@@ -29862,7 +29901,7 @@ var MastraTUI = class MastraTUI {
|
|
|
29862
29901
|
},
|
|
29863
29902
|
onSelectModel: async (title, modeColor) => {
|
|
29864
29903
|
const availableModels = await this.state.controller.listAvailableModels();
|
|
29865
|
-
if (availableModels.length === 0) return void 0;
|
|
29904
|
+
if (this.stopped || availableModels.length === 0) return void 0;
|
|
29866
29905
|
return new Promise((resolveModel) => {
|
|
29867
29906
|
const selector = new ModelSelectorComponent({
|
|
29868
29907
|
tui: this.state.ui,
|
|
@@ -29899,6 +29938,7 @@ var MastraTUI = class MastraTUI {
|
|
|
29899
29938
|
const modePack = result.modePack;
|
|
29900
29939
|
const modes = this.state.controller.listModes();
|
|
29901
29940
|
await this.state.session.state.set({ yolo: result.yolo });
|
|
29941
|
+
if (this.stopped) return;
|
|
29902
29942
|
const settings = (0, _mastra_code_sdk_onboarding_index.loadSettings)();
|
|
29903
29943
|
settings.onboarding.completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
29904
29944
|
settings.onboarding.skippedAt = null;
|
|
@@ -29931,10 +29971,12 @@ var MastraTUI = class MastraTUI {
|
|
|
29931
29971
|
settings.models.subagentModels = {};
|
|
29932
29972
|
(0, _mastra_code_sdk_onboarding_index.saveSettings)(settings);
|
|
29933
29973
|
await applyCurrentThreadPack({ state: this.state }, { packId: activeModePackId });
|
|
29974
|
+
if (this.stopped) return;
|
|
29934
29975
|
await this.state.session.thread.setSetting({
|
|
29935
29976
|
key: _mastra_code_sdk_onboarding_settings.THREAD_FALLBACK_STATUS_KEY,
|
|
29936
29977
|
value: void 0
|
|
29937
29978
|
});
|
|
29979
|
+
if (this.stopped) return;
|
|
29938
29980
|
this.state.fallbackStatus = void 0;
|
|
29939
29981
|
updateStatusLine(this.state);
|
|
29940
29982
|
await this.refreshModelAuthStatus();
|
|
@@ -30169,4 +30211,4 @@ Object.defineProperty(exports, "theme", {
|
|
|
30169
30211
|
}
|
|
30170
30212
|
});
|
|
30171
30213
|
|
|
30172
|
-
//# sourceMappingURL=tui-
|
|
30214
|
+
//# sourceMappingURL=tui-BfBjFTxw.cjs.map
|